@rpack-dev/core 0.1.2-4752725 → 0.1.2-5eab4e2

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 ADDED
@@ -0,0 +1,165 @@
1
+ GNU LESSER GENERAL PUBLIC LICENSE
2
+ Version 3, 29 June 2007
3
+
4
+ Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
5
+ Everyone is permitted to copy and distribute verbatim copies
6
+ of this license document, but changing it is not allowed.
7
+
8
+
9
+ This version of the GNU Lesser General Public License incorporates
10
+ the terms and conditions of version 3 of the GNU General Public
11
+ License, supplemented by the additional permissions listed below.
12
+
13
+ 0. Additional Definitions.
14
+
15
+ As used herein, "this License" refers to version 3 of the GNU Lesser
16
+ General Public License, and the "GNU GPL" refers to version 3 of the GNU
17
+ General Public License.
18
+
19
+ "The Library" refers to a covered work governed by this License,
20
+ other than an Application or a Combined Work as defined below.
21
+
22
+ An "Application" is any work that makes use of an interface provided
23
+ by the Library, but which is not otherwise based on the Library.
24
+ Defining a subclass of a class defined by the Library is deemed a mode
25
+ of using an interface provided by the Library.
26
+
27
+ A "Combined Work" is a work produced by combining or linking an
28
+ Application with the Library. The particular version of the Library
29
+ with which the Combined Work was made is also called the "Linked
30
+ Version".
31
+
32
+ The "Minimal Corresponding Source" for a Combined Work means the
33
+ Corresponding Source for the Combined Work, excluding any source code
34
+ for portions of the Combined Work that, considered in isolation, are
35
+ based on the Application, and not on the Linked Version.
36
+
37
+ The "Corresponding Application Code" for a Combined Work means the
38
+ object code and/or source code for the Application, including any data
39
+ and utility programs needed for reproducing the Combined Work from the
40
+ Application, but excluding the System Libraries of the Combined Work.
41
+
42
+ 1. Exception to Section 3 of the GNU GPL.
43
+
44
+ You may convey a covered work under sections 3 and 4 of this License
45
+ without being bound by section 3 of the GNU GPL.
46
+
47
+ 2. Conveying Modified Versions.
48
+
49
+ If you modify a copy of the Library, and, in your modifications, a
50
+ facility refers to a function or data to be supplied by an Application
51
+ that uses the facility (other than as an argument passed when the
52
+ facility is invoked), then you may convey a copy of the modified
53
+ version:
54
+
55
+ a) under this License, provided that you make a good faith effort to
56
+ ensure that, in the event an Application does not supply the
57
+ function or data, the facility still operates, and performs
58
+ whatever part of its purpose remains meaningful, or
59
+
60
+ b) under the GNU GPL, with none of the additional permissions of
61
+ this License applicable to that copy.
62
+
63
+ 3. Object Code Incorporating Material from Library Header Files.
64
+
65
+ The object code form of an Application may incorporate material from
66
+ a header file that is part of the Library. You may convey such object
67
+ code under terms of your choice, provided that, if the incorporated
68
+ material is not limited to numerical parameters, data structure
69
+ layouts and accessors, or small macros, inline functions and templates
70
+ (ten or fewer lines in length), you do both of the following:
71
+
72
+ a) Give prominent notice with each copy of the object code that the
73
+ Library is used in it and that the Library and its use are
74
+ covered by this License.
75
+
76
+ b) Accompany the object code with a copy of the GNU GPL and this license
77
+ document.
78
+
79
+ 4. Combined Works.
80
+
81
+ You may convey a Combined Work under terms of your choice that,
82
+ taken together, effectively do not restrict modification of the
83
+ portions of the Library contained in the Combined Work and reverse
84
+ engineering for debugging such modifications, if you also do each of
85
+ the following:
86
+
87
+ a) Give prominent notice with each copy of the Combined Work that
88
+ the Library is used in it and that the Library and its use are
89
+ covered by this License.
90
+
91
+ b) Accompany the Combined Work with a copy of the GNU GPL and this license
92
+ document.
93
+
94
+ c) For a Combined Work that displays copyright notices during
95
+ execution, include the copyright notice for the Library among
96
+ these notices, as well as a reference directing the user to the
97
+ copies of the GNU GPL and this license document.
98
+
99
+ d) Do one of the following:
100
+
101
+ 0) Convey the Minimal Corresponding Source under the terms of this
102
+ License, and the Corresponding Application Code in a form
103
+ suitable for, and under terms that permit, the user to
104
+ recombine or relink the Application with a modified version of
105
+ the Linked Version to produce a modified Combined Work, in the
106
+ manner specified by section 6 of the GNU GPL for conveying
107
+ Corresponding Source.
108
+
109
+ 1) Use a suitable shared library mechanism for linking with the
110
+ Library. A suitable mechanism is one that (a) uses at run time
111
+ a copy of the Library already present on the user's computer
112
+ system, and (b) will operate properly with a modified version
113
+ of the Library that is interface-compatible with the Linked
114
+ Version.
115
+
116
+ e) Provide Installation Information, but only if you would otherwise
117
+ be required to provide such information under section 6 of the
118
+ GNU GPL, and only to the extent that such information is
119
+ necessary to install and execute a modified version of the
120
+ Combined Work produced by recombining or relinking the
121
+ Application with a modified version of the Linked Version. (If
122
+ you use option 4d0, the Installation Information must accompany
123
+ the Minimal Corresponding Source and Corresponding Application
124
+ Code. If you use option 4d1, you must provide the Installation
125
+ Information in the manner specified by section 6 of the GNU GPL
126
+ for conveying Corresponding Source.)
127
+
128
+ 5. Combined Libraries.
129
+
130
+ You may place library facilities that are a work based on the
131
+ Library side by side in a single library together with other library
132
+ facilities that are not Applications and are not covered by this
133
+ License, and convey such a combined library under terms of your
134
+ choice, if you do both of the following:
135
+
136
+ a) Accompany the combined library with a copy of the same work based
137
+ on the Library, uncombined with any other library facilities,
138
+ conveyed under the terms of this License.
139
+
140
+ b) Give prominent notice with the combined library that part of it
141
+ is a work based on the Library, and explaining where to find the
142
+ accompanying uncombined form of the same work.
143
+
144
+ 6. Revised Versions of the GNU Lesser General Public License.
145
+
146
+ The Free Software Foundation may publish revised and/or new versions
147
+ of the GNU Lesser General Public License from time to time. Such new
148
+ versions will be similar in spirit to the present version, but may
149
+ differ in detail to address new problems or concerns.
150
+
151
+ Each version is given a distinguishing version number. If the
152
+ Library as you received it specifies that a certain numbered version
153
+ of the GNU Lesser General Public License "or any later version"
154
+ applies to it, you have the option of following the terms and
155
+ conditions either of that published version or of any later version
156
+ published by the Free Software Foundation. If the Library as you
157
+ received it does not specify a version number of the GNU Lesser
158
+ General Public License, you may choose any version of the GNU Lesser
159
+ General Public License ever published by the Free Software Foundation.
160
+
161
+ If the Library as you received it specifies that a proxy can decide
162
+ whether future versions of the GNU Lesser General Public License shall
163
+ apply, that proxy's public statement of acceptance of any version is
164
+ permanent authorization for you to choose that version for the
165
+ Library.
@@ -1 +1 @@
1
- !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.RPack=t():e.RPack=t()}(this,()=>(()=>{"use strict";var e={d:(t,r)=>{for(var s in r)e.o(r,s)&&!e.o(t,s)&&Object.defineProperty(t,s,{enumerable:!0,get:r[s]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{AsyncIterableIteratorMirror:()=>s,DefaultPublicRegistryOptions:()=>d,DefaultRegistryOptions:()=>c,FilteredIterableIterator:()=>p,LazyBatchedAsyncIterableIterator:()=>j,LazyPromise:()=>i,LocalObject:()=>m,LocalRegistry:()=>P,LocalRemoteMap:()=>a,Messenger:()=>v,NetworkManager:()=>M,PluginThread:()=>S,ProxyManager:()=>h,RPPlatform:()=>T,RPPlugin:()=>I,RegistryManager:()=>E,RemoteAsyncIterator:()=>r,RemoteObject:()=>R,RemoteProxyManager:()=>l,RemoteRegistry:()=>b,RemoteRegistryManager:()=>k,StringUtils:()=>o,Utils:()=>n,default:()=>A});class r{constructor(e,t){this.manager=e,this.iteratorKeySupplier=t,this.iteratorKey=null,this.iteratorKeyPromise=null,this.finished=!1}[Symbol.asyncIterator](){return this}async getIteratorKey(){return null!==this.iteratorKey?this.iteratorKey:null!==this.iteratorKeyPromise?this.iteratorKeyPromise:this.iteratorKeyPromise=this.iteratorKeySupplier().then(e=>this.iteratorKey=e)}async next(...[e]){if(this.finished)return{done:!0,value:void 0};let t=await this.manager.requestRemoteIteratorNext(await this.getIteratorKey(),e);return t.done&&(this.finished=!0),t}async return(e){return this.finished||(this.manager.requestRemoteIteratorClose(await this.getIteratorKey()),this.finished=!0),{done:!0,value:e}}async throw(e){throw this.finished||(this.manager.requestRemoteIteratorClose(await this.getIteratorKey()),this.finished=!0),e}}class s{constructor(e,t=e=>e){this.it=e,this.converter=t}[Symbol.asyncIterator](){return this}async next(...e){let t=this.it.next(...e);return void 0!==t.value&&(t.value=this.converter(t.value)),t}async return(e){if(void 0!==this.it.return){let t=this.it.return(e);return void 0!==t.value&&(t.value=this.converter(t.value)),t}return{done:!0,value:e}}async throw(e){if(void 0!==this.it.throw){let t=this.it.throw(e);return void 0!==t.value&&(t.value=this.converter(t.value)),t}throw e}}class i{constructor(e){this.promise=new Promise((e,t)=>{this.resolveFunc=e,this.rejectFunc=t}),this.completed=!1,this.errored=!1,e?.then(this.resolve,this.reject)}resolve(e){this.completed||(this.completed=!0,this.errored=!1,this.resolveFunc(e))}reject(e){this.completed||(this.completed=!0,this.errored=!0,this.rejectFunc(e))}getPromise(){return this.promise}then(e,t){return this.promise.then(e,t)}isComplete(){return this.completed}isErrored(){return this.errored}}class n{static NATURAL_COLLATOR=new Intl.Collator(void 0,{numeric:!0});static async getLargeFile(e,t,r){let s=await fetch(e,t);if(!s.body)return;let i=s.body.getReader(),n=[],o=0,a=s.headers.get("Content-Length"),l=null==a?0:parseInt(a);for(r||(r=()=>{});;){let e=await i.read();if(e.done)break;o+=e.value.length,r(o,l),n.push(e.value)}return await new Blob(n).arrayBuffer()}static binarySearch(e,t,r){let s=0,i=e.length-1;for(;s<=i;){let n=i+s>>1,o=r(t,e[n]);if(o>0)s=n+1;else{if(!(o<0))return n;i=n-1}}return-s-1}static binarySearch2(e,t,r,s){let i=0,n=e.length-1;for(;i<=n;){let o=n+i>>1,a=s(t,r(e[o]));if(a>0)i=o+1;else{if(!(a<0))return o;n=o-1}}return-i-1}static loadImageAsync(e){let t=new i;const r=new Image;return r.onload=()=>t.resolve(r),r.onerror=t.reject,r.src=e,t.getPromise()}static naturalComparator(e=e=>e?e.toString():"null"){return(t,r)=>this.NATURAL_COLLATOR.compare(e(t),e(r))}static naturalSort(e,t=e=>e?e.toString():"null"){return e.sort(this.naturalComparator(t)),e}static async asyncSort(e,t){if(e.length<=1)return e;const r=Math.floor(e.length/2);let s=await this.asyncSort(e.slice(0,r),t),i=await this.asyncSort(e.slice(r),t),n=0,o=0,a=0;for(;n<s.length&&o<i.length;)await t(s[n],i[o])<=0?(e[a]=s[n],n++):(e[a]=i[o],o++),a++;for(;n<s.length;)e[a]=s[n],n++,a++;for(;o<i.length;)e[a]=i[o],o++,a++;return e}static tableString(e,t,r){let s,i=["|"],n=" ",o="left";r&&(void 0!==r.separator&&(i=r.separator instanceof Array?r.separator:[r.separator]),void 0!==r.headers&&(s=r.headers),void 0!==r.padding&&(n=r.padding),void 0!==r.textAlign&&(o=r.textAlign));let a=e.map(e=>t(e)),l=[];for(let e of a)for(let t=0;t<e.length;t++)"number"==typeof l[t]?l[t]=Math.max(l[t],e[t].length):l[t]=e[t].length;if(s)for(let e=0;e<s.length;e++)"number"==typeof l[e]?l[e]=Math.max(l[e],s[e].length):l[e]=s[e].length;if("right"==o){if(s)for(let e=0;e<s.length;e++)s[e]=n+s[e].padStart(l[e]," ")+n;for(let e of a)for(let t=0;t<e.length;t++)e[t]=n+e[t].padStart(l[t]," ")+n}else if("center"==o){if(s)for(let e=0;e<s.length;e++)s[e]=n+s[e].padEnd(Math.ceil((l[e]-s[e].length)/2)+s[e].length," ").padStart(l[e]," ")+n;for(let e of a)for(let t=0;t<e.length;t++)e[t]=n+e[t].padEnd(Math.ceil((l[t]-e[t].length)/2)+e[t].length," ").padStart(l[t]," ")+n}else{if(s)for(let e=0;e<s.length;e++)s[e]=n+s[e].padEnd(l[e]," ")+n;for(let e of a)for(let t=0;t<e.length;t++)e[t]=n+e[t].padEnd(l[t]," ")+n}let h="";if(s){let e="";for(let t=0;t<s.length;t++){if(t>0){let r=i[(t-1)%i.length];h+=r,e+=r}h+=s[t],e+="-".repeat(s[t].length)}h+="\n"+e+"\n"}for(let e=0;e<a.length;e++){let t=a[e];e>0&&(h+="\n");for(let e=0;e<t.length;e++)e>0&&(h+=i[e%i.length]),h+=t[e]}return h}static getEnumKeys(e){let t=[];for(let r of Object.getOwnPropertyNames(e))isNaN(parseInt(r))&&t.push(r);return t}static getEnumConstants(e){let t=[];for(let r of Object.getOwnPropertyNames(e))if(isNaN(parseInt(r))){let s=e[r];t.push(s)}return t}static presentOrDefault(e,t){return void 0===e?t:e}static generateRandomInt(e,t){return void 0===t&&(t=e,e=0),t=Math.floor(t),(e=Math.ceil(e))+Math.floor(Math.random()*(t-e))}static pickRandomElement(e){let t=Object.keys(e);return e[t[this.generateRandomInt(t.length)]]}}class o{static LOWERCASE_LETTERS="abcdefghijklmnopqrstuvwxyz";static UPPERCASE_LETTERS="ABCDEFGHIJKLMNOPQRSTUVWXYZ";static NUMBERS="0123456789";static LOWERCASE_UPPERCASE=o.LOWERCASE_LETTERS+o.UPPERCASE_LETTERS;static ALPHANUMERIC=o.LOWERCASE_UPPERCASE+o.NUMBERS;static generateNonce(){return this.generateString(this.ALPHANUMERIC,20)}static generateString(e,t){let r="";for(let s=0;s<t;s++)r+=n.pickRandomElement(e);return r}static capitalize(e){return e.substring(0,1).toUpperCase()+e.substring(1)}static count(e,t){return(e.match(new RegExp(this.escapeRegExp(t),"g"))||[]).length}static escapeRegExp(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}}class a{constructor(e,t,r,s){this.parent=e,this.localMap=new Map,this.remoteSet=new Set,this.registry=new FinalizationRegistry(e=>{this.remoteSet.delete(e)&&t.sendPacket({id:"proxy:cleanup",type:r,key:e})}),t.addHandler("proxy:cleanup",e=>{if(e.type!=r)return;let t=this.delete(e.key);void 0!==t&&void 0!==s&&s(t)})}generateKey(e){for(;;){let t=o.generateNonce();if(!this.localMap.has(t))return this.localMap.set(t,e),t}}addLocal(e,t){return t?(this.localMap.set(t,e),t):this.generateKey(e)}get(e){return this.localMap.get(e)}delete(e){let t=this.localMap.get(e);return this.localMap.delete(e),t}registerRemote(e,t){this.registry.register(t,e)}has(e){return this.localMap.has(e)}hasRemote(e){return this.remoteSet.has(e)}deleteRemote(e){return this.remoteSet.delete(e)}}class l{constructor(e,t,r){this.parent=e,this.threadId=t,this.messenger=r,this.objects=new a(this,r,"object"),this.functions=new a(this,r,"function"),this.iterators=new a(this,r,"iterator",e=>{e.return&&e.return().then()}),this.messenger.addHandler("proxy:refresh_object_request",this.onObjectRefresh.bind(this)),this.messenger.addHandler("proxy:method_request",this.onMethod.bind(this)),this.messenger.addHandler("proxy:function_request",this.onFunction.bind(this)),this.messenger.addHandler("proxy:create_iterator_request",this.onIteratorCreate.bind(this)),this.messenger.addHandler("proxy:iterator_next_request",this.onIteratorNext.bind(this)),this.messenger.addHandler("proxy:iterator_close_request",this.onIteratorClose.bind(this))}getThreadId(){return this.threadId}serialize(e,t){return this.parent.getRPack().getNetworkManager().serialize(this.threadId,e,t)}deserialize(e){return this.parent.getRPack().getNetworkManager().deserialize(this.threadId,e)}sendValue(e,t,r,s){this.messenger.sendPacket({id:e,nonce:t,value:this.serialize(r),...s})}sendError(e,t,r){this.messenger.sendPacket({id:e,nonce:t,error:this.serialize(r)})}sendErrorRaw(e,t,r){this.sendError(e,t,new Error(r))}onObjectRefresh(e){let t=e.objectKey;if(!this.objects.has(t))return void this.sendErrorRaw("proxy:refresh_object_response",e.nonce,"Unknown object key "+t);let r=this.objects.get(t);this.sendValue("proxy:refresh_object_response",e.nonce,r)}onMethod(e){let t=e.objectKey;if(!this.objects.has(t))return void this.sendErrorRaw("proxy:method_response",e.nonce,"Unknown object key "+t);let r=this.objects.get(t),s=e.method;if(!(s in r))return void this.sendErrorRaw("proxy:method_response",e.nonce,"Property "+s+" is not present in object "+t);let i=r[s],n=e.args.map(e=>this.deserialize(e)),o=i.apply(r,n);Promise.resolve(o).then(t=>{this.sendValue("proxy:method_response",e.nonce,t)},t=>{this.sendError("proxy:method_response",e.nonce,t)})}onFunction(e){let t=e.functionKey;if(!this.functions.has(t))return void this.sendErrorRaw("proxy:function_response",e.nonce,"Unknown function key "+t);let r=this.functions.get(t)(...e.args.map(e=>this.deserialize(e)));Promise.resolve(r).then(t=>{this.sendValue("proxy:function_response",e.nonce,t)},t=>{this.sendError("proxy:function_response",e.nonce,t)})}onIteratorCreate(e){let t=e.objectKey;if(!this.objects.has(t))return void this.sendErrorRaw("proxy:create_iterator_response",e.nonce,"Unknown object key "+t);let r,s=this.objects.get(t);if(s[Symbol.iterator]){let e=s[Symbol.iterator]();r=this.declareLocalIterator(e)}else{if(!s[Symbol.asyncIterator])return void this.sendErrorRaw("proxy:create_iterator_response",e.nonce,"Object "+t+" is not iterable");{let e=s[Symbol.asyncIterator]();r=this.declareLocalAsyncIterator(e)}}this.messenger.sendPacket({id:"proxy:create_iterator_response",nonce:e.nonce,iteratorKey:r})}onIteratorNext(e){let t=e.iteratorKey,r=void 0===e.value?void 0:this.deserialize(e.value);this.iterators.has(t)?this.iterators.get(t).next(r).then(t=>{this.sendValue("proxy:iterator_next_response",e.nonce,t.value,{done:t.done??!1})},t=>{this.sendError("proxy:iterator_next_response",e.nonce,t)}):this.sendErrorRaw("proxy:iterator_next_response",e.nonce,"Unknown iterator key "+t)}onIteratorClose(e){let t=e.iteratorKey;if(this.iterators.has(t)){let e=this.iterators.get(t);e.return&&e.return().then(),this.iterators.delete(t)}}declareLocalObject(e,t){return this.objects.addLocal(e,t)}declareLocalIterator(e){return this.iterators.addLocal(new s(e))}declareLocalAsyncIterator(e){return this.iterators.addLocal(e)}declareFunction(e){return this.functions.addLocal(e)}declareRemoteIterator(e,t){this.iterators.registerRemote(e,t)}requestRemoteObjectIterator(e){let t=new r(this,async()=>{const r=await this.messenger.sendPacketWithNoncePromise("proxy:create_iterator_request",{objectKey:e},"proxy:create_iterator_response");if(r.error)throw this.deserialize(r.error);let s=r.iteratorKey;return this.declareRemoteIterator(s,t),s});return t}async requestRemoteIteratorNext(e,t){if(!this.iterators.hasRemote(e))return{done:!0,value:void 0};let r=await this.messenger.sendPacketWithNoncePromise("proxy:iterator_next_request",{iteratorKey:e,value:void 0===t?void 0:this.serialize(t)},"proxy:iterator_next_response");if(r.error)throw this.deserialize(r.error);{let e=this.deserialize(r.value);return{done:r.done,value:e}}}requestRemoteIteratorClose(e){this.iterators.hasRemote(e)&&(this.messenger.sendPacket({id:"proxy:iterator_close_request",iteratorKey:e}),this.iterators.deleteRemote(e))}async refreshRemote(e){let t=await this.messenger.sendPacketWithNoncePromise("proxy:refresh_object_request",{objectKey:e},"proxy:refresh_object_response");if(t.error)throw this.deserialize(t.error);let r=this.deserialize(t.value);return this.objects.registerRemote(e,r),r}async requestRemoteMethod(e,t,r){let s=await this.messenger.sendPacketWithNoncePromise("proxy:method_request",{objectKey:e,method:t,args:r.map(e=>this.serialize(e))},"proxy:method_response");if(s.error)throw this.deserialize(s.error);return this.deserialize(s.value)}async requestRemoteFunction(e,t){let r=await this.messenger.sendPacketWithNoncePromise("proxy:function_request",{functionKey:e,args:t.map(e=>this.serialize(e))},"proxy:function_response");if(r.error)throw this.deserialize(r.error);return this.deserialize(r.value)}}class h{constructor(e){this.rpack=e,this.remotes=new Map}createRemote(e,t){let r=new l(this,e,t);return this.remotes.set(e,r),r}getRPack(){return this.rpack}getRemote(e){return this.remotes.get(e)}}const d={localsAreProxied:!1,verifyLocals:!0,allowShared:!1},c={...d};let g;var u;(u=g||(g={})).withDefaultOptions=function(e){let t={...c};if(void 0!==e)for(let r in c)r in e&&(t[r]=e[r]);return t},u.withPublicDefaultOptions=function(e){let t={...d};if(void 0!==e)for(let r in d)r in e&&(t[r]=e[r]);return t};const y=g;class p{constructor(e,t,r=!0){this.it=e,this.filter=r?t:e=>void 0!==e&&t(e)}[Symbol.iterator](){return this}next(...e){for(;;){let t=this.it.next(...e);if(this.filter(t.value)||t.done)return t}}return(e){return void 0!==this.it.return?this.it.return(e):{done:!0,value:e}}throw(e){if(void 0!==this.it.throw)return this.it.throw(e);throw e}}class m{get(e,t,r){let s=e[t];return"function"==typeof s?(...r)=>Promise.resolve(e[t](...r)):s}}let f,w=Symbol("isProxy"),_=Symbol("getFunctions");class R{constructor(e,t,r,s,i,n){this.remoteProxy=e,this.objectKey=t,this.typeName=r,this.knownProps=new Map;for(let[t,r]of Object.entries(s))this.knownProps.set(t,e.deserialize(r));this.functions=i,this.iterable=n}get(e,t,r){if(t===Symbol.asyncIterator){if(!this.iterable)return;return()=>{this.remoteProxy.requestRemoteObjectIterator(this.objectKey)}}if(t===w)return!0;if(t===_)return this.functions;if("symbol"!=typeof t){if("constructor"===t){let e=()=>{throw new Error("Cannot call constructor of remote object")};return Object.defineProperty(e,"name",{value:this.typeName}),e}return this.knownProps.has(t)?this.knownProps.get(t):this.functions.includes(t)?(...e)=>this.remoteProxy.requestRemoteMethod(this.objectKey,t,e):void 0}}ownKeys(e){return[...this.knownProps.keys()]}getOwnPropertyDescriptor(e,t){if("symbol"!=typeof t)return this.knownProps.has(t)?{enumerable:!0,configurable:!0}:void 0}has(e,t){return t===Symbol.asyncIterator?this.iterable:!("symbol"==typeof t||!this.knownProps.has(t)&&!this.functions.includes(t))}static fromObject(e,t){return new R(e,t.objectKey,t.typeName,{},t.functions,t.iterable)}static fromRegistryEntry(e,t){return new R(e,t.objectKey,t.typeName,t.props,t.functions,t.iterable)}static isProxy(e){return!0===e[w]}static getFunctions(e){return this.isProxy(e)?e[_]:[]}}class P{constructor(e,t,r){this.manager=e,this.options=r,this.publicOptions=y.withPublicDefaultOptions(r),this.registryId=t,this.map=new Map}getRegistryManager(){return this.manager}getRegistryId(){return this.registryId}getOptions(){return this.publicOptions}getAllEntriesByThread(e){let t=new p(this.map.values(),t=>t.ownerThread===e);return new s(t)}getAllEntries(){return new s(this.map.values())}getAll(){return new s(this.map.values(),e=>e.data)}async get(e){let t=this.map.get(e);if(t)return t.data}async getEntry(e){return this.map.get(e)}async has(e){return this.map.has(e)}async add(e,t){return!this.map.has(e)&&(this.__localAdd(e,this.manager.getRPack().getNetworkManager().getCurrentThreadId(),t),!0)}async remove(e){return this.map.delete(e)}async size(){return this.map.size}__removeAll(e){for(let[t,r]of this.map)r.ownerThread===e&&this.map.delete(t)}__localAdd(e,t,r){if(this.map.has(e)&&this.map.get(e).ownerThread!==t)return!1;if(this.options.localsAreProxied&&!R.isProxy(r)&&"object"==typeof r&&(r=new Proxy(r,new m)),!this.options.allowShared&&null===t)throw new Error("Shared values are not allowed due to allowShared being set to false.");return this.map.set(e,{key:e,ownerThread:t,data:r}),!0}__localRemove(e,t){return(!this.map.has(e)||this.map.get(e).ownerThread===t)&&this.map.delete(e)}__localGet(e){return this.map.get(e)?.data}}class b{constructor(e,t,r,s){this.manager=e,this.options=s,this.remoteThread=t,this.registryId=r,this.localEntries=new Map}getRemote(){return this.manager.getRemote(this.remoteThread)}getRegistryManager(){return this.manager}getRegistryId(){return this.registryId}getOptions(){return this.options}get(e){return this.localEntries.has(e)?(this.options.verifyLocals,Promise.resolve(this.localEntries.get(e).data)):this.getRemote().requestGet(this.registryId,e)}getEntry(e){return this.localEntries.has(e)?(this.options.verifyLocals,Promise.resolve(this.localEntries.get(e))):this.getRemote().requestGetEntry(this.registryId,e)}getAllEntriesByThread(e){return this.getRemote().requestGetAllEntriesByThread(this.registryId,e)}getAllEntries(){return this.getRemote().requestGetAllEntries(this.registryId)}getAll(){return this.getRemote().requestGetAll(this.registryId)}has(e){return this.getRemote().requestHas(this.registryId,e)}async add(e,t){return this.__localAdd(e,this.manager.getRPack().getNetworkManager().getCurrentThreadId(),t),this.getRemote().requestAdd(this.registryId,null,e,t).then(t=>(t||this.localEntries.delete(e),t))}remove(e){return this.getRemote().requestRemove(this.registryId,null,e)}size(){return this.getRemote().requestSize(this.registryId)}__forwardAdd(e,t,r){return this.getRemote().requestAdd(this.registryId,t,e,r)}__forwardRemove(e,t){return this.getRemote().requestRemove(this.registryId,t,e)}__localAdd(e,t,r){if(this.localEntries.has(e)&&this.localEntries.get(e).ownerThread!==t)return!1;if(this.options.localsAreProxied&&!R.isProxy(r)&&"object"==typeof r&&(r=new Proxy(r,new m)),!this.options.allowShared&&null===t)throw new Error("Shared values are not allowed due to allowShared being set to false.");return this.localEntries.set(e,{key:e,ownerThread:t,data:r}),!0}__localGet(e){return this.localEntries.get(e)?.data}}class v{constructor(e){this.handlerLists={},this.sender=e}getHandlerList(e){let t=this.handlerLists[e];return t||(t=[],this.handlerLists[e]=t),t}addHandler(e,t){this.getHandlerList(e).splice(0,0,t)}removeHandler(e,t){let r=this.getHandlerList(e),s=r.indexOf(t);return s>-1&&(r.splice(s,1),!0)}promiseHandlerImpl(e,t,r){let s,i,n=new Promise((e,t)=>{s=e,i=t});return e.push(e=>t(e,s)),void 0!==r&&setTimeout(()=>{i("Timeout was reached: "+r)},r),n}addPromiseNonceHandler(e,t,r){return this.promiseHandlerImpl(this.getHandlerList(e),(e,r)=>{if(e.nonce==t)return r(e),!1},r)}addPromiseHandler(e,t){return this.promiseHandlerImpl(this.getHandlerList(e),(e,t)=>(t(e),!1),t)}receivePacket(e){let t=e.id,r=this.getHandlerList(t);if(r)for(let t=r.length-1;t>=0;t--)!1===(0,r[t])(e)&&r.splice(t,1)}sendPacket(e){this.sender(e)}sendPacketWithNoncePromise(e,t,r,s){let i=o.generateNonce(),n=this.addPromiseNonceHandler(r,i,s);return this.sendPacket({...t,id:e,nonce:i}),n}static cast(e){return e}}class I{getRPack(){return this.rpack}async onInit(){}async onShutdown(){}static __setInstance(e,t){void 0===e.rpack&&(e.rpack=t)}}class k{constructor(e,t,r){this.parent=e,this.remoteThreadId=t,this.messenger=r,r.addHandler("registry:add_request",this.onAdd.bind(this)),r.addHandler("registry:has_request",this.onHas.bind(this)),r.addHandler("registry:remove_request",this.onRemove.bind(this)),r.addHandler("registry:size_request",this.onSize.bind(this)),r.addHandler("registry:get_request",this.onGet.bind(this)),r.addHandler("registry:get_entry_request",this.onGetEntry.bind(this)),r.addHandler("registry:get_all_entries_request",this.onGetAllEntries.bind(this)),r.addHandler("registry:get_all_entries_by_thread_request",this.onGetAllEntriesByThread.bind(this)),r.addHandler("registry:get_all_request",this.onGetAll.bind(this))}getCurrentThread(){return this.parent.getRPack().getNetworkManager().getCurrentThreadId()}getRemote(){return this.parent.getRPack().getProxyManager().getRemote(this.remoteThreadId)}serialize(e,t){return this.parent.getRPack().getNetworkManager().serialize(this.remoteThreadId,e,t)}deserialize(e){return this.parent.getRPack().getNetworkManager().deserialize(this.remoteThreadId,e)}sendError(e,t,r){this.messenger.sendPacket({id:e,nonce:t,error:this.serialize(r)})}sendErrorRaw(e,t,r){this.sendError(e,t,new Error(r))}async onAdd(e){let t=await this.parent.getRegistry(e.registryId);if(void 0===t)return void this.sendErrorRaw("registry:add_response",e.nonce,"Unknown registry "+e.registryId);let r=e.ownerThread;if(r!==this.remoteThreadId&&this.remoteThreadId!==M.HOST_THREAD_ID)return void this.sendErrorRaw("registry:add_response",e.nonce,"Non-host threads cannot forward registry requests");let s=this.deserialize(e.value);if(t instanceof b)t.__forwardAdd(e.key,r,s).then(t=>{this.messenger.sendPacket({id:"registry:add_response",nonce:e.nonce,value:t})},t=>{this.sendError("registry:add_response",e.nonce,t)});else if(t instanceof P){let i=t.__localAdd(e.key,r,s);this.messenger.sendPacket({id:"registry:add_response",nonce:e.nonce,value:i})}else this.sendErrorRaw("registry:add_response",e.nonce,"Weird registry type: "+t.constructor.name)}async onHas(e){let t=await this.parent.getRegistry(e.registryId);if(void 0!==t)return t.has(e.key).then(t=>{this.messenger.sendPacket({id:"registry:has_response",nonce:e.nonce,value:t})},t=>{this.sendError("registry:has_response",e.nonce,t)});this.sendErrorRaw("registry:has_response",e.nonce,"Unknown registry "+e.registryId)}async onRemove(e){let t=await this.parent.getRegistry(e.registryId);if(void 0===t)return void this.sendErrorRaw("registry:remove_response",e.nonce,"Unknown registry "+e.registryId);let r=e.ownerThread;if(r===this.remoteThreadId||this.remoteThreadId===M.HOST_THREAD_ID)if(t instanceof b)t.__forwardRemove(e.key,r).then(t=>{this.messenger.sendPacket({id:"registry:remove_response",nonce:e.nonce,value:t})},t=>{this.sendError("registry:remove_response",e.nonce,t)});else if(t instanceof P){let s=t.__localRemove(e.key,r);this.messenger.sendPacket({id:"registry:remove_response",nonce:e.nonce,value:s})}else this.sendErrorRaw("registry:remove_response",e.nonce,"Weird registry type: "+t.constructor.name);else this.sendErrorRaw("registry:remove_response",e.nonce,"Non-host threads cannot forward registry requests")}async onSize(e){let t=await this.parent.getRegistry(e.registryId);if(void 0!==t)return t.size().then(t=>{this.messenger.sendPacket({id:"registry:size_response",nonce:e.nonce,value:t})},t=>{this.sendError("registry:size_response",e.nonce,t)});this.sendErrorRaw("registry:size_response",e.nonce,"Unknown registry "+e.registryId)}async onGet(e){let t=await this.parent.getRegistry(e.registryId);if(void 0!==t)return t.get(e.key).then(t=>{this.messenger.sendPacket({id:"registry:get_response",nonce:e.nonce,value:this.serialize(t,{objectMode:"registry"})})},t=>{this.sendError("registry:get_response",e.nonce,t)});this.sendErrorRaw("registry:get_response",e.nonce,"Unknown registry "+e.registryId)}async onGetEntry(e){let t=await this.parent.getRegistry(e.registryId);if(void 0!==t)return t.getEntry(e.key).then(t=>{void 0!==t?this.messenger.sendPacket({id:"registry:get_entry_response",nonce:e.nonce,value:{key:this.serialize(t.key),ownerThread:t?.ownerThread,data:this.serialize(t.key,{objectMode:"registry"})}}):this.messenger.sendPacket({id:"registry:get_entry_response",nonce:e.nonce,value:null})},t=>{this.sendError("registry:get_entry_response",e.nonce,t)});this.sendErrorRaw("registry:get_entry_response",e.nonce,"Unknown registry "+e.registryId)}async onGetAllEntries(e){let t=await this.parent.getRegistry(e.registryId);if(void 0===t)return void this.sendErrorRaw("registry:get_all_entries_response",e.nonce,"Unknown registry "+e.registryId);let r=this.getRemote(),s=t.getAllEntries(),i=r.declareLocalAsyncIterator(s);this.messenger.sendPacket({id:"registry:get_all_entries_response",nonce:e.nonce,iteratorKey:i})}async onGetAllEntriesByThread(e){let t=await this.parent.getRegistry(e.registryId);if(void 0===t)return void this.sendErrorRaw("registry:get_all_entries_by_thread_response",e.nonce,"Unknown registry "+e.registryId);let r=this.getRemote(),s=t.getAllEntriesByThread(e.ownerThread),i=r.declareLocalAsyncIterator(s);this.messenger.sendPacket({id:"registry:get_all_entries_by_thread_response",nonce:e.nonce,iteratorKey:i})}async onGetAll(e){let t=await this.parent.getRegistry(e.registryId);if(void 0===t)return void this.sendErrorRaw("registry:get_all_response",e.nonce,"Unknown registry "+e.registryId);let r=this.getRemote(),s=t.getAll(),i=r.declareLocalAsyncIterator(s);this.messenger.sendPacket({id:"registry:get_all_response",nonce:e.nonce,iteratorKey:i})}async requestAdd(e,t,r,s){let i=await this.messenger.sendPacketWithNoncePromise("registry:add_request",{registryId:e,ownerThread:t??this.getCurrentThread(),key:r,value:this.serialize(s,{objectMode:"registry"})},"registry:add_response");if(i.error)throw this.deserialize(i.error);return i.value}async requestHas(e,t){let r=await this.messenger.sendPacketWithNoncePromise("registry:has_request",{registryId:e,key:t},"registry:has_response");if(r.error)throw this.deserialize(r.error);return r.value}async requestRemove(e,t,r){let s=await this.messenger.sendPacketWithNoncePromise("registry:remove_request",{registryId:e,ownerThread:t??this.getCurrentThread(),key:r},"registry:remove_response");if(s.error)throw this.deserialize(s.error);return s.value}async requestSize(e){let t=await this.messenger.sendPacketWithNoncePromise("registry:size_request",{registryId:e},"registry:size_response");if(t.error)throw this.deserialize(t.error);return t.value}async requestGet(e,t){let r=await this.messenger.sendPacketWithNoncePromise("registry:get_request",{registryId:e,key:t},"registry:get_response");if(r.error)throw this.deserialize(r.error);if(null!=r.value)return this.deserialize(r.value)}async requestGetEntry(e,t){let r=await this.messenger.sendPacketWithNoncePromise("registry:get_entry_request",{registryId:e,key:t},"registry:get_entry_response");if(r.error)throw this.deserialize(r.error);if(null!=r.value)return{key:this.deserialize(r.value.key),ownerThread:r.value.ownerThread,data:this.deserialize(r.value.data)}}requestGetAllEntries(e){let t=this.getRemote(),s=new r(t,async()=>{const r=await this.messenger.sendPacketWithNoncePromise("registry:get_all_entries_request",{registryId:e},"registry:get_all_entries_response");if(r.error)throw this.deserialize(r.error);let i=r.iteratorKey;return t.declareRemoteIterator(i,s),i});return s}requestGetAllEntriesByThread(e,t){let s=this.getRemote(),i=new r(s,async()=>{const r=await this.messenger.sendPacketWithNoncePromise("registry:get_all_entries_by_thread_request",{registryId:e,ownerThread:t},"registry:get_all_entries_by_thread_response");if(r.error)throw this.deserialize(r.error);let n=r.iteratorKey;return s.declareRemoteIterator(n,i),n});return i}requestGetAll(e){let t=this.getRemote(),s=new r(t,async()=>{const r=await this.messenger.sendPacketWithNoncePromise("registry:get_all_request",{registryId:e},"registry:get_all_response");if(r.error)throw this.deserialize(r.error);let i=r.iteratorKey;return t.declareRemoteIterator(i,s),i});return s}}class E{static META_REGISTRY_ID="rpack:registry";static PLUGIN_REGISTRY_ID="rpack:plugin";constructor(e){this.rpack=e,this.remotes=new Map,this.metaRegistry=this.__createInternalRegistry(E.META_REGISTRY_ID,{localsAreProxied:!1,allowShared:!0})}async createRegistry(e,t){let r=new P(this,e,y.withDefaultOptions(t));if(await this.metaRegistry.add(e,r))return r;throw new Error("Failed to create registry "+e)}getRPack(){return this.rpack}createRemote(e,t){let r=new k(this,e,t);return this.remotes.set(e,r),r}getRemote(e){return this.remotes.get(e)}getRegistry(e){return this.metaRegistry.get(e)}__createInternalRegistry(e,t){let r;return r=this.rpack.isPluginThread()?new b(this,M.HOST_THREAD_ID,e,y.withPublicDefaultOptions(t)):new P(this,e,y.withDefaultOptions(t)),this.rpack.getLoadPromise().then(()=>{this.metaRegistry.__localAdd(e,null,r)}),r}__deserializeRegistry(e,t,r){if(this.metaRegistry instanceof P||this.metaRegistry instanceof b){let s=this.metaRegistry.__localGet(e);if(void 0!==s)return s;let i=new b(this,t,e,r);return this.metaRegistry.__localAdd(e,t,i),i}throw new Error("Weird registry type: "+this.metaRegistry.constructor.name)}}(f||(f={})).isSubclass=function(e,t){return t.prototype.isPrototypeOf(e.prototype)};const x=f;class M{static HOST_THREAD_ID="host";constructor(e,t,r){this.rpack=e,this.wellKnownMap=new Map,this.wellKnownReverseMap=new Map,this.mapWellKnown("RPack",e),this.mapWellKnown("NetworkManager",e.getNetworkManager()),this.mapWellKnown("ProxyManager",e.getProxyManager()),this.mapWellKnown("RegistryManager",e.getRegistryManager()),this.plugin=null,this.pluginRegistry=e.getRegistryManager().__createInternalRegistry(E.PLUGIN_REGISTRY_ID,{}),this.threadId=t,void 0===r?this.threads=new Map:this.hostMessenger=r}mapWellKnown(e,t){this.wellKnownMap.set(t,{type:"well_known",kind:e}),this.wellKnownReverseMap.set(e,t)}async __initPlugin(e){if(null!==this.plugin)throw new Error("Cannot initialize a plugin twice");let t=await import(e);if(!("default"in t))throw new Error("Failed to import plugin "+e+": no default export");let r=t.default;if("function"!=typeof r)throw new Error("Failed to import plugin "+e+": default export is not a class");if(r.length>0)throw new Error("Failed to import plugin "+e+": default export's constructor expects arguments (should be empty)");if(!x.isSubclass(r,I))throw new Error("Failed to import plugin "+e+": default export is not a subclass of RPPlugin");this.plugin=new r,I.__setInstance(this.plugin,this.rpack),await this.plugin.onInit();let s=e.replace(/\.\/(\S+)\.js/g,"$1");await this.pluginRegistry.add(s,this.plugin),this.hostMessenger.addHandler("thread:shutdown_request",async e=>{await this.plugin.onShutdown(),this.hostMessenger.sendPacket({id:"thread:shutdown_response",nonce:e.nonce})})}getRPack(){return this.rpack}getHostMessenger(){return this.hostMessenger}getCurrentThreadId(){return this.threadId}getPlugin(e){return this.pluginRegistry.get(e)}getPluginRegistry(){return this.pluginRegistry}__initRemotes(e,t){this.rpack.getProxyManager().createRemote(e,v.cast(t)),this.rpack.getRegistryManager().createRemote(e,v.cast(t))}async __createThread(e){if(!this.threads)throw new Error("Cannot create a Worker from a Worker!");let t=o.generateNonce();for(;this.threads.has(t);)t=o.generateNonce();console.debug("Starting new thread "+t);let r=await this.rpack.getPlatform().createPluginThread(t,e);this.threads.set(t,r);let s=r.getMessenger(),i=null;for(let r=0;r<6;r++)try{console.debug("Waiting for thread "+t);let r=o.generateNonce();s.sendPacket({id:"thread:hello_request",nonce:r,threadId:t,scriptUrl:e}),await s.addPromiseNonceHandler("thread:hello_response",r),this.__initRemotes(t,v.cast(s)),console.debug("Thread "+t+" started"),i=r;break}catch{console.debug("Thread "+t+" timed out. Trying again...")}if(null===i)throw console.debug("Thread "+t+" failed to start, aborting"),await r.terminate(),this.threads.delete(t),new Error("Thread "+t+" failed to start");return await s.addPromiseNonceHandler("thread:plugin_load",i),console.debug("Plugin loaded in thread "+t),t}ensureJSONInner(e,t,r,s){if("string"==typeof t||"number"==typeof t||"boolean"==typeof t||null==t)return!0;if("object"==typeof t){if(Array.isArray(t)){for(let i=0;i<t.length;i++)if(!this.ensureJSONInner(e,t[i],r,s+"["+i+"]"))return!1;return!0}if(Object.getPrototypeOf(t)===Object.prototype){for(let i in t)if(!this.ensureJSONInner(e,t[i],r,s+"."+i))return!1;return!0}}if(r)throw new TypeError("Failed to validate object "+e+" as JSON: root"+s+" is not a JSON-like object");return!1}ensureJSON(e,t){return this.ensureJSONInner(e,e,t??!1)}getFunctionNames(e){if(R.isProxy(e))return R.getFunctions(e);let t=[],r=Object.getPrototypeOf(e);for(;void 0!==r&&r!==Object.prototype;)t.push(...Object.getOwnPropertyNames(r)),r=Object.getPrototypeOf(r);let s=t.indexOf("constructor");s>-1&&t.splice(s,1);for(let r=t.length-1;r>=0;r--)"function"!=typeof e[t[r]]&&t.splice(r,1);return t}serialize(e,t,r){if(void 0===t)return{type:"undefined"};if(!R.isProxy(t)&&("string"==typeof t||"number"==typeof t||"boolean"==typeof t||null==t||Object.getPrototypeOf(t)===Object.prototype&&this.ensureJSON(t,!1)))return{type:"json",value:t};if(t instanceof P||t instanceof b)return{type:"registry",registryId:t.getRegistryId(),options:t.getOptions()};if(t instanceof Error)return{type:"error",errorType:t.name,name:t.name,message:t.message,stack:t.stack};if("function"==typeof t)return{type:"function",functionKey:this.rpack.getProxyManager().getRemote(e).declareFunction(t)};if(this.wellKnownMap.has(t))return this.wellKnownMap.get(t);if(null===t)throw new Error("Null past the null checK?");if("registry"==r?.objectMode){let r=this.rpack.getProxyManager().getRemote(e).declareLocalObject(t),s={},i=this.getFunctionNames(t);for(let r of Object.keys(t))s[r]=this.serialize(e,t[r]);return{type:"registry_entry",objectKey:r,typeName:t.constructor.name,props:s,functions:i,iterable:Symbol.iterator in t||Symbol.asyncIterator in t}}{let r=this.rpack.getProxyManager().getRemote(e).declareLocalObject(t),s=Object.keys(t),i=this.getFunctionNames(t);return{type:"object",objectKey:r,typeName:t.constructor.name,props:s,functions:i,iterable:Symbol.iterator in t||Symbol.asyncIterator in t}}}deserialize(e,t){let r=this.rpack.getProxyManager().getRemote(e),s=t.type;switch(t.type){case"undefined":return;case"json":return t.value;case"registry":return this.rpack.getRegistryManager().__deserializeRegistry(t.registryId,e,t.options);case"registry_entry":return new Proxy({},R.fromRegistryEntry(r,t));case"object":return new Proxy({},R.fromObject(r,t));case"function":return(...e)=>r.requestRemoteFunction(t.functionKey,e);case"well_known":return this.wellKnownReverseMap.get(t.kind);case"error":let i;switch(t.errorType){case"Error":i=new Error;break;case"EvalError":i=new EvalError;break;case"RangeError":i=new RangeError;break;case"ReferenceError":i=new ReferenceError;break;case"SyntaxError":i=new SyntaxError;break;case"TypeError":i=new TypeError;break;case"URIError":i=new URIError}return i.name=t.name,i.message=t.message,i.stack=t.stack,i;default:throw new Error("Failed to deserialize unknown type: "+s)}}}class S{constructor(e,t){this.threadId=e,this.messenger=t}getThreadId(){return this.threadId}getMessenger(){return this.messenger}}class T{constructor(e){this.id=e}}class j{constructor(e,t,r){this.supplier=e,this.completeHandler=t,this.errorHandler=r,this.lastBatch=null,this.lastIndex=-1}[Symbol.asyncIterator](){return this}async next(){if(this.result)return this.result;null==this.lastBatch&&(this.lastBatch=await this.supplier(),this.lastIndex=0);let e=this.lastBatch.values[this.lastIndex];if(this.lastIndex++,this.lastIndex==this.lastBatch.values.length){let e=this.lastBatch;if(this.lastBatch=null,e.done)return this.result={done:!0,value:void 0},this.result}return{done:!1,value:e}}async return(e){return await this.completeHandler(e),this.result={value:this.result,done:!0},this.result}async throw(){return await this.errorHandler(),this.result={value:void 0,done:!0},this.result}}class A{static platform=null;static platformLoadPromise=new i;static initPlatform(e){if(null!==this.platform)throw new Error("Platform already initialized");this.platform=e,this.platformLoadPromise.resolve(e)}static async createInstance(e){if(e&&void 0!==this.instance)return this.instance;let t=await this.platformLoadPromise.getPromise(),r=await t.createRPackInstance(e=>new A(e));return e&&(this.instance=r),r}static getInstance(){return this.instance}constructor(e){this.pluginThread=e.pluginThread,this.loadPromise=e.loadPromise,this.platform=e.platform,this.proxyManager=new h(this),this.registryManager=new E(this),this.networkManager=new M(this,e.threadId,e.hostMessenger)}getLoadPromise(){return this.loadPromise}getRegistryManager(){return this.registryManager}getProxyManager(){return this.proxyManager}getNetworkManager(){return this.networkManager}isPluginThread(){return this.pluginThread}getPlugin(e){return this.getNetworkManager().getPlugin(e)}getPlatform(){return this.platform}}return t})());
1
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.RPack=t():e.RPack=t()}(this,()=>(()=>{"use strict";var e={d:(t,r)=>{for(var s in r)e.o(r,s)&&!e.o(t,s)&&Object.defineProperty(t,s,{enumerable:!0,get:r[s]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{AsyncIterableIteratorMirror:()=>s,DefaultPublicRegistryOptions:()=>d,DefaultRegistryOptions:()=>c,FilteredIterableIterator:()=>p,LazyBatchedAsyncIterableIterator:()=>A,LazyPromise:()=>i,LocalObject:()=>m,LocalRegistry:()=>P,LocalRemoteMap:()=>a,Messenger:()=>v,NetworkManager:()=>M,PluginThread:()=>S,ProxyManager:()=>h,RPPlatform:()=>T,RPPlugin:()=>k,RPVersion:()=>j,RegistryManager:()=>I,RemoteAsyncIterator:()=>r,RemoteObject:()=>R,RemoteProxyManager:()=>l,RemoteRegistry:()=>b,RemoteRegistryManager:()=>E,StringUtils:()=>o,Utils:()=>n,default:()=>O});class r{constructor(e,t){this.manager=e,this.iteratorKeySupplier=t,this.iteratorKey=null,this.iteratorKeyPromise=null,this.finished=!1}[Symbol.asyncIterator](){return this}async getIteratorKey(){return null!==this.iteratorKey?this.iteratorKey:null!==this.iteratorKeyPromise?this.iteratorKeyPromise:this.iteratorKeyPromise=this.iteratorKeySupplier().then(e=>this.iteratorKey=e)}async next(...[e]){if(this.finished)return{done:!0,value:void 0};let t=await this.manager.requestRemoteIteratorNext(await this.getIteratorKey(),e);return t.done&&(this.finished=!0),t}async return(e){return this.finished||(this.manager.requestRemoteIteratorClose(await this.getIteratorKey()),this.finished=!0),{done:!0,value:e}}async throw(e){throw this.finished||(this.manager.requestRemoteIteratorClose(await this.getIteratorKey()),this.finished=!0),e}}class s{constructor(e,t=e=>e){this.it=e,this.converter=t}[Symbol.asyncIterator](){return this}async next(...e){let t=this.it.next(...e);return void 0!==t.value&&(t.value=this.converter(t.value)),t}async return(e){if(void 0!==this.it.return){let t=this.it.return(e);return void 0!==t.value&&(t.value=this.converter(t.value)),t}return{done:!0,value:e}}async throw(e){if(void 0!==this.it.throw){let t=this.it.throw(e);return void 0!==t.value&&(t.value=this.converter(t.value)),t}throw e}}class i{constructor(e){this.promise=new Promise((e,t)=>{this.resolveFunc=e,this.rejectFunc=t}),this.completed=!1,this.errored=!1,e?.then(this.resolve,this.reject)}resolve(e){this.completed||(this.completed=!0,this.errored=!1,this.resolveFunc(e))}reject(e){this.completed||(this.completed=!0,this.errored=!0,this.rejectFunc(e))}getPromise(){return this.promise}then(e,t){return this.promise.then(e,t)}isComplete(){return this.completed}isErrored(){return this.errored}}class n{static NATURAL_COLLATOR=new Intl.Collator(void 0,{numeric:!0});static async getLargeFile(e,t,r){let s=await fetch(e,t);if(!s.body)return;let i=s.body.getReader(),n=[],o=0,a=s.headers.get("Content-Length"),l=null==a?0:parseInt(a);for(r||(r=()=>{});;){let e=await i.read();if(e.done)break;o+=e.value.length,r(o,l),n.push(e.value)}return await new Blob(n).arrayBuffer()}static binarySearch(e,t,r){let s=0,i=e.length-1;for(;s<=i;){let n=i+s>>1,o=r(t,e[n]);if(o>0)s=n+1;else{if(!(o<0))return n;i=n-1}}return-s-1}static binarySearch2(e,t,r,s){let i=0,n=e.length-1;for(;i<=n;){let o=n+i>>1,a=s(t,r(e[o]));if(a>0)i=o+1;else{if(!(a<0))return o;n=o-1}}return-i-1}static loadImageAsync(e){let t=new i;const r=new Image;return r.onload=()=>t.resolve(r),r.onerror=t.reject,r.src=e,t.getPromise()}static naturalComparator(e=e=>e?e.toString():"null"){return(t,r)=>this.NATURAL_COLLATOR.compare(e(t),e(r))}static naturalSort(e,t=e=>e?e.toString():"null"){return e.sort(this.naturalComparator(t)),e}static async asyncSort(e,t){if(e.length<=1)return e;const r=Math.floor(e.length/2);let s=await this.asyncSort(e.slice(0,r),t),i=await this.asyncSort(e.slice(r),t),n=0,o=0,a=0;for(;n<s.length&&o<i.length;)await t(s[n],i[o])<=0?(e[a]=s[n],n++):(e[a]=i[o],o++),a++;for(;n<s.length;)e[a]=s[n],n++,a++;for(;o<i.length;)e[a]=i[o],o++,a++;return e}static tableString(e,t,r){let s,i=["|"],n=" ",o="left";r&&(void 0!==r.separator&&(i=r.separator instanceof Array?r.separator:[r.separator]),void 0!==r.headers&&(s=r.headers),void 0!==r.padding&&(n=r.padding),void 0!==r.textAlign&&(o=r.textAlign));let a=e.map(e=>t(e)),l=[];for(let e of a)for(let t=0;t<e.length;t++)"number"==typeof l[t]?l[t]=Math.max(l[t],e[t].length):l[t]=e[t].length;if(s)for(let e=0;e<s.length;e++)"number"==typeof l[e]?l[e]=Math.max(l[e],s[e].length):l[e]=s[e].length;if("right"==o){if(s)for(let e=0;e<s.length;e++)s[e]=n+s[e].padStart(l[e]," ")+n;for(let e of a)for(let t=0;t<e.length;t++)e[t]=n+e[t].padStart(l[t]," ")+n}else if("center"==o){if(s)for(let e=0;e<s.length;e++)s[e]=n+s[e].padEnd(Math.ceil((l[e]-s[e].length)/2)+s[e].length," ").padStart(l[e]," ")+n;for(let e of a)for(let t=0;t<e.length;t++)e[t]=n+e[t].padEnd(Math.ceil((l[t]-e[t].length)/2)+e[t].length," ").padStart(l[t]," ")+n}else{if(s)for(let e=0;e<s.length;e++)s[e]=n+s[e].padEnd(l[e]," ")+n;for(let e of a)for(let t=0;t<e.length;t++)e[t]=n+e[t].padEnd(l[t]," ")+n}let h="";if(s){let e="";for(let t=0;t<s.length;t++){if(t>0){let r=i[(t-1)%i.length];h+=r,e+=r}h+=s[t],e+="-".repeat(s[t].length)}h+="\n"+e+"\n"}for(let e=0;e<a.length;e++){let t=a[e];e>0&&(h+="\n");for(let e=0;e<t.length;e++)e>0&&(h+=i[e%i.length]),h+=t[e]}return h}static getEnumKeys(e){let t=[];for(let r of Object.getOwnPropertyNames(e))isNaN(parseInt(r))&&t.push(r);return t}static getEnumConstants(e){let t=[];for(let r of Object.getOwnPropertyNames(e))if(isNaN(parseInt(r))){let s=e[r];t.push(s)}return t}static presentOrDefault(e,t){return void 0===e?t:e}static generateRandomInt(e,t){return void 0===t&&(t=e,e=0),t=Math.floor(t),(e=Math.ceil(e))+Math.floor(Math.random()*(t-e))}static pickRandomElement(e){let t=Object.keys(e);return e[t[this.generateRandomInt(t.length)]]}}class o{static LOWERCASE_LETTERS="abcdefghijklmnopqrstuvwxyz";static UPPERCASE_LETTERS="ABCDEFGHIJKLMNOPQRSTUVWXYZ";static NUMBERS="0123456789";static LOWERCASE_UPPERCASE=o.LOWERCASE_LETTERS+o.UPPERCASE_LETTERS;static ALPHANUMERIC=o.LOWERCASE_UPPERCASE+o.NUMBERS;static generateNonce(){return this.generateString(this.ALPHANUMERIC,20)}static generateString(e,t){let r="";for(let s=0;s<t;s++)r+=n.pickRandomElement(e);return r}static capitalize(e){return e.substring(0,1).toUpperCase()+e.substring(1)}static count(e,t){return(e.match(new RegExp(this.escapeRegExp(t),"g"))||[]).length}static escapeRegExp(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}}class a{constructor(e,t,r,s){this.parent=e,this.localMap=new Map,this.remoteSet=new Set,this.registry=new FinalizationRegistry(e=>{this.remoteSet.delete(e)&&t.sendPacket({id:"proxy:cleanup",type:r,key:e})}),t.addHandler("proxy:cleanup",e=>{if(e.type!=r)return;let t=this.delete(e.key);void 0!==t&&void 0!==s&&s(t)})}generateKey(e){for(;;){let t=o.generateNonce();if(!this.localMap.has(t))return this.localMap.set(t,e),t}}addLocal(e,t){return t?(this.localMap.set(t,e),t):this.generateKey(e)}get(e){return this.localMap.get(e)}delete(e){let t=this.localMap.get(e);return this.localMap.delete(e),t}registerRemote(e,t){this.registry.register(t,e)}has(e){return this.localMap.has(e)}hasRemote(e){return this.remoteSet.has(e)}deleteRemote(e){return this.remoteSet.delete(e)}}class l{constructor(e,t,r){this.parent=e,this.threadId=t,this.messenger=r,this.objects=new a(this,r,"object"),this.functions=new a(this,r,"function"),this.iterators=new a(this,r,"iterator",e=>{e.return&&e.return().then()}),this.messenger.addHandler("proxy:refresh_object_request",this.onObjectRefresh.bind(this)),this.messenger.addHandler("proxy:method_request",this.onMethod.bind(this)),this.messenger.addHandler("proxy:function_request",this.onFunction.bind(this)),this.messenger.addHandler("proxy:create_iterator_request",this.onIteratorCreate.bind(this)),this.messenger.addHandler("proxy:iterator_next_request",this.onIteratorNext.bind(this)),this.messenger.addHandler("proxy:iterator_close_request",this.onIteratorClose.bind(this))}getThreadId(){return this.threadId}serialize(e,t){return this.parent.getRPack().getNetworkManager().serialize(this.threadId,e,t)}deserialize(e){return this.parent.getRPack().getNetworkManager().deserialize(this.threadId,e)}sendValue(e,t,r,s){this.messenger.sendPacket({id:e,nonce:t,value:this.serialize(r),...s})}sendError(e,t,r){this.messenger.sendPacket({id:e,nonce:t,error:this.serialize(r)})}sendErrorRaw(e,t,r){this.sendError(e,t,new Error(r))}onObjectRefresh(e){let t=e.objectKey;if(!this.objects.has(t))return void this.sendErrorRaw("proxy:refresh_object_response",e.nonce,"Unknown object key "+t);let r=this.objects.get(t);this.sendValue("proxy:refresh_object_response",e.nonce,r)}onMethod(e){let t=e.objectKey;if(!this.objects.has(t))return void this.sendErrorRaw("proxy:method_response",e.nonce,"Unknown object key "+t);let r=this.objects.get(t),s=e.method;if(!(s in r))return void this.sendErrorRaw("proxy:method_response",e.nonce,"Property "+s+" is not present in object "+t);let i=r[s],n=e.args.map(e=>this.deserialize(e)),o=i.apply(r,n);Promise.resolve(o).then(t=>{this.sendValue("proxy:method_response",e.nonce,t)},t=>{this.sendError("proxy:method_response",e.nonce,t)})}onFunction(e){let t=e.functionKey;if(!this.functions.has(t))return void this.sendErrorRaw("proxy:function_response",e.nonce,"Unknown function key "+t);let r=this.functions.get(t)(...e.args.map(e=>this.deserialize(e)));Promise.resolve(r).then(t=>{this.sendValue("proxy:function_response",e.nonce,t)},t=>{this.sendError("proxy:function_response",e.nonce,t)})}onIteratorCreate(e){let t=e.objectKey;if(!this.objects.has(t))return void this.sendErrorRaw("proxy:create_iterator_response",e.nonce,"Unknown object key "+t);let r,s=this.objects.get(t);if(s[Symbol.iterator]){let e=s[Symbol.iterator]();r=this.declareLocalIterator(e)}else{if(!s[Symbol.asyncIterator])return void this.sendErrorRaw("proxy:create_iterator_response",e.nonce,"Object "+t+" is not iterable");{let e=s[Symbol.asyncIterator]();r=this.declareLocalAsyncIterator(e)}}this.messenger.sendPacket({id:"proxy:create_iterator_response",nonce:e.nonce,iteratorKey:r})}onIteratorNext(e){let t=e.iteratorKey,r=void 0===e.value?void 0:this.deserialize(e.value);this.iterators.has(t)?this.iterators.get(t).next(r).then(t=>{this.sendValue("proxy:iterator_next_response",e.nonce,t.value,{done:t.done??!1})},t=>{this.sendError("proxy:iterator_next_response",e.nonce,t)}):this.sendErrorRaw("proxy:iterator_next_response",e.nonce,"Unknown iterator key "+t)}onIteratorClose(e){let t=e.iteratorKey;if(this.iterators.has(t)){let e=this.iterators.get(t);e.return&&e.return().then(),this.iterators.delete(t)}}declareLocalObject(e,t){return this.objects.addLocal(e,t)}declareLocalIterator(e){return this.iterators.addLocal(new s(e))}declareLocalAsyncIterator(e){return this.iterators.addLocal(e)}declareFunction(e){return this.functions.addLocal(e)}declareRemoteIterator(e,t){this.iterators.registerRemote(e,t)}requestRemoteObjectIterator(e){let t=new r(this,async()=>{const r=await this.messenger.sendPacketWithNoncePromise("proxy:create_iterator_request",{objectKey:e},"proxy:create_iterator_response");if(r.error)throw this.deserialize(r.error);let s=r.iteratorKey;return this.declareRemoteIterator(s,t),s});return t}async requestRemoteIteratorNext(e,t){if(!this.iterators.hasRemote(e))return{done:!0,value:void 0};let r=await this.messenger.sendPacketWithNoncePromise("proxy:iterator_next_request",{iteratorKey:e,value:void 0===t?void 0:this.serialize(t)},"proxy:iterator_next_response");if(r.error)throw this.deserialize(r.error);{let e=this.deserialize(r.value);return{done:r.done,value:e}}}requestRemoteIteratorClose(e){this.iterators.hasRemote(e)&&(this.messenger.sendPacket({id:"proxy:iterator_close_request",iteratorKey:e}),this.iterators.deleteRemote(e))}async refreshRemote(e){let t=await this.messenger.sendPacketWithNoncePromise("proxy:refresh_object_request",{objectKey:e},"proxy:refresh_object_response");if(t.error)throw this.deserialize(t.error);let r=this.deserialize(t.value);return this.objects.registerRemote(e,r),r}async requestRemoteMethod(e,t,r){let s=await this.messenger.sendPacketWithNoncePromise("proxy:method_request",{objectKey:e,method:t,args:r.map(e=>this.serialize(e))},"proxy:method_response");if(s.error)throw this.deserialize(s.error);return this.deserialize(s.value)}async requestRemoteFunction(e,t){let r=await this.messenger.sendPacketWithNoncePromise("proxy:function_request",{functionKey:e,args:t.map(e=>this.serialize(e))},"proxy:function_response");if(r.error)throw this.deserialize(r.error);return this.deserialize(r.value)}}class h{constructor(e){this.rpack=e,this.remotes=new Map}createRemote(e,t){let r=new l(this,e,t);return this.remotes.set(e,r),r}getRPack(){return this.rpack}getRemote(e){return this.remotes.get(e)}}const d={localsAreProxied:!1,verifyLocals:!0,allowShared:!1},c={...d};let g;var u;(u=g||(g={})).withDefaultOptions=function(e){let t={...c};if(void 0!==e)for(let r in c)r in e&&(t[r]=e[r]);return t},u.withPublicDefaultOptions=function(e){let t={...d};if(void 0!==e)for(let r in d)r in e&&(t[r]=e[r]);return t};const y=g;class p{constructor(e,t,r=!0){this.it=e,this.filter=r?t:e=>void 0!==e&&t(e)}[Symbol.iterator](){return this}next(...e){for(;;){let t=this.it.next(...e);if(this.filter(t.value)||t.done)return t}}return(e){return void 0!==this.it.return?this.it.return(e):{done:!0,value:e}}throw(e){if(void 0!==this.it.throw)return this.it.throw(e);throw e}}class m{get(e,t,r){let s=e[t];return"function"==typeof s?(...r)=>Promise.resolve(e[t](...r)):s}}let f,w=Symbol("isProxy"),_=Symbol("getFunctions");class R{constructor(e,t,r,s,i,n){this.remoteProxy=e,this.objectKey=t,this.typeName=r,this.knownProps=new Map;for(let[t,r]of Object.entries(s))this.knownProps.set(t,e.deserialize(r));this.functions=i,this.iterable=n}get(e,t,r){if(t===Symbol.asyncIterator){if(!this.iterable)return;return()=>{this.remoteProxy.requestRemoteObjectIterator(this.objectKey)}}if(t===w)return!0;if(t===_)return this.functions;if("symbol"!=typeof t){if("constructor"===t){let e=()=>{throw new Error("Cannot call constructor of remote object")};return Object.defineProperty(e,"name",{value:this.typeName}),e}return this.knownProps.has(t)?this.knownProps.get(t):this.functions.includes(t)?(...e)=>this.remoteProxy.requestRemoteMethod(this.objectKey,t,e):void 0}}ownKeys(e){return[...this.knownProps.keys()]}getOwnPropertyDescriptor(e,t){if("symbol"!=typeof t)return this.knownProps.has(t)?{enumerable:!0,configurable:!0}:void 0}has(e,t){return t===Symbol.asyncIterator?this.iterable:!("symbol"==typeof t||!this.knownProps.has(t)&&!this.functions.includes(t))}static fromObject(e,t){return new R(e,t.objectKey,t.typeName,{},t.functions,t.iterable)}static fromRegistryEntry(e,t){return new R(e,t.objectKey,t.typeName,t.props,t.functions,t.iterable)}static isProxy(e){return!0===e[w]}static getFunctions(e){return this.isProxy(e)?e[_]:[]}}class P{constructor(e,t,r){this.manager=e,this.options=r,this.publicOptions=y.withPublicDefaultOptions(r),this.registryId=t,this.map=new Map}getRegistryManager(){return this.manager}getRegistryId(){return this.registryId}getOptions(){return this.publicOptions}getAllEntriesByThread(e){let t=new p(this.map.values(),t=>t.ownerThread===e);return new s(t)}getAllEntries(){return new s(this.map.values())}getAll(){return new s(this.map.values(),e=>e.data)}async get(e){let t=this.map.get(e);if(t)return t.data}async getEntry(e){return this.map.get(e)}async has(e){return this.map.has(e)}async add(e,t){return!this.map.has(e)&&(this.__localAdd(e,this.manager.getRPack().getNetworkManager().getCurrentThreadId(),t),!0)}async remove(e){return this.map.delete(e)}async size(){return this.map.size}__removeAll(e){for(let[t,r]of this.map)r.ownerThread===e&&this.map.delete(t)}__localAdd(e,t,r){if(this.map.has(e)&&this.map.get(e).ownerThread!==t)return!1;if(this.options.localsAreProxied&&!R.isProxy(r)&&"object"==typeof r&&(r=new Proxy(r,new m)),!this.options.allowShared&&null===t)throw new Error("Shared values are not allowed due to allowShared being set to false.");return this.map.set(e,{key:e,ownerThread:t,data:r}),!0}__localRemove(e,t){return(!this.map.has(e)||this.map.get(e).ownerThread===t)&&this.map.delete(e)}__localGet(e){return this.map.get(e)?.data}}class b{constructor(e,t,r,s){this.manager=e,this.options=s,this.remoteThread=t,this.registryId=r,this.localEntries=new Map}getRemote(){return this.manager.getRemote(this.remoteThread)}getRegistryManager(){return this.manager}getRegistryId(){return this.registryId}getOptions(){return this.options}get(e){return this.localEntries.has(e)?(this.options.verifyLocals,Promise.resolve(this.localEntries.get(e).data)):this.getRemote().requestGet(this.registryId,e)}getEntry(e){return this.localEntries.has(e)?(this.options.verifyLocals,Promise.resolve(this.localEntries.get(e))):this.getRemote().requestGetEntry(this.registryId,e)}getAllEntriesByThread(e){return this.getRemote().requestGetAllEntriesByThread(this.registryId,e)}getAllEntries(){return this.getRemote().requestGetAllEntries(this.registryId)}getAll(){return this.getRemote().requestGetAll(this.registryId)}has(e){return this.getRemote().requestHas(this.registryId,e)}async add(e,t){return this.__localAdd(e,this.manager.getRPack().getNetworkManager().getCurrentThreadId(),t),this.getRemote().requestAdd(this.registryId,null,e,t).then(t=>(t||this.localEntries.delete(e),t))}remove(e){return this.getRemote().requestRemove(this.registryId,null,e)}size(){return this.getRemote().requestSize(this.registryId)}__forwardAdd(e,t,r){return this.getRemote().requestAdd(this.registryId,t,e,r)}__forwardRemove(e,t){return this.getRemote().requestRemove(this.registryId,t,e)}__localAdd(e,t,r){if(this.localEntries.has(e)&&this.localEntries.get(e).ownerThread!==t)return!1;if(this.options.localsAreProxied&&!R.isProxy(r)&&"object"==typeof r&&(r=new Proxy(r,new m)),!this.options.allowShared&&null===t)throw new Error("Shared values are not allowed due to allowShared being set to false.");return this.localEntries.set(e,{key:e,ownerThread:t,data:r}),!0}__localGet(e){return this.localEntries.get(e)?.data}}class v{constructor(e){this.handlerLists={},this.sender=e}getHandlerList(e){let t=this.handlerLists[e];return t||(t=[],this.handlerLists[e]=t),t}addHandler(e,t){this.getHandlerList(e).splice(0,0,t)}removeHandler(e,t){let r=this.getHandlerList(e),s=r.indexOf(t);return s>-1&&(r.splice(s,1),!0)}promiseHandlerImpl(e,t,r){let s,i,n=new Promise((e,t)=>{s=e,i=t});return e.push(e=>t(e,s)),void 0!==r&&setTimeout(()=>{i("Timeout was reached: "+r)},r),n}addPromiseNonceHandler(e,t,r){return this.promiseHandlerImpl(this.getHandlerList(e),(e,r)=>{if(e.nonce==t)return r(e),!1},r)}addPromiseHandler(e,t){return this.promiseHandlerImpl(this.getHandlerList(e),(e,t)=>(t(e),!1),t)}receivePacket(e){let t=e.id,r=this.getHandlerList(t);if(r)for(let t=r.length-1;t>=0;t--)!1===(0,r[t])(e)&&r.splice(t,1)}sendPacket(e){this.sender(e)}sendPacketWithNoncePromise(e,t,r,s){let i=o.generateNonce(),n=this.addPromiseNonceHandler(r,i,s);return this.sendPacket({...t,id:e,nonce:i}),n}static cast(e){return e}}class k{getRPack(){return this.rpack}async onInit(){}async onShutdown(){}static __setInstance(e,t){void 0===e.rpack&&(e.rpack=t)}}class E{constructor(e,t,r){this.parent=e,this.remoteThreadId=t,this.messenger=r,r.addHandler("registry:add_request",this.onAdd.bind(this)),r.addHandler("registry:has_request",this.onHas.bind(this)),r.addHandler("registry:remove_request",this.onRemove.bind(this)),r.addHandler("registry:size_request",this.onSize.bind(this)),r.addHandler("registry:get_request",this.onGet.bind(this)),r.addHandler("registry:get_entry_request",this.onGetEntry.bind(this)),r.addHandler("registry:get_all_entries_request",this.onGetAllEntries.bind(this)),r.addHandler("registry:get_all_entries_by_thread_request",this.onGetAllEntriesByThread.bind(this)),r.addHandler("registry:get_all_request",this.onGetAll.bind(this))}getCurrentThread(){return this.parent.getRPack().getNetworkManager().getCurrentThreadId()}getRemote(){return this.parent.getRPack().getProxyManager().getRemote(this.remoteThreadId)}serialize(e,t){return this.parent.getRPack().getNetworkManager().serialize(this.remoteThreadId,e,t)}deserialize(e){return this.parent.getRPack().getNetworkManager().deserialize(this.remoteThreadId,e)}sendError(e,t,r){this.messenger.sendPacket({id:e,nonce:t,error:this.serialize(r)})}sendErrorRaw(e,t,r){this.sendError(e,t,new Error(r))}async onAdd(e){let t=await this.parent.getRegistry(e.registryId);if(void 0===t)return void this.sendErrorRaw("registry:add_response",e.nonce,"Unknown registry "+e.registryId);let r=e.ownerThread;if(r!==this.remoteThreadId&&this.remoteThreadId!==M.HOST_THREAD_ID)return void this.sendErrorRaw("registry:add_response",e.nonce,"Non-host threads cannot forward registry requests");let s=this.deserialize(e.value);if(t instanceof b)t.__forwardAdd(e.key,r,s).then(t=>{this.messenger.sendPacket({id:"registry:add_response",nonce:e.nonce,value:t})},t=>{this.sendError("registry:add_response",e.nonce,t)});else if(t instanceof P){let i=t.__localAdd(e.key,r,s);this.messenger.sendPacket({id:"registry:add_response",nonce:e.nonce,value:i})}else this.sendErrorRaw("registry:add_response",e.nonce,"Weird registry type: "+t.constructor.name)}async onHas(e){let t=await this.parent.getRegistry(e.registryId);if(void 0!==t)return t.has(e.key).then(t=>{this.messenger.sendPacket({id:"registry:has_response",nonce:e.nonce,value:t})},t=>{this.sendError("registry:has_response",e.nonce,t)});this.sendErrorRaw("registry:has_response",e.nonce,"Unknown registry "+e.registryId)}async onRemove(e){let t=await this.parent.getRegistry(e.registryId);if(void 0===t)return void this.sendErrorRaw("registry:remove_response",e.nonce,"Unknown registry "+e.registryId);let r=e.ownerThread;if(r===this.remoteThreadId||this.remoteThreadId===M.HOST_THREAD_ID)if(t instanceof b)t.__forwardRemove(e.key,r).then(t=>{this.messenger.sendPacket({id:"registry:remove_response",nonce:e.nonce,value:t})},t=>{this.sendError("registry:remove_response",e.nonce,t)});else if(t instanceof P){let s=t.__localRemove(e.key,r);this.messenger.sendPacket({id:"registry:remove_response",nonce:e.nonce,value:s})}else this.sendErrorRaw("registry:remove_response",e.nonce,"Weird registry type: "+t.constructor.name);else this.sendErrorRaw("registry:remove_response",e.nonce,"Non-host threads cannot forward registry requests")}async onSize(e){let t=await this.parent.getRegistry(e.registryId);if(void 0!==t)return t.size().then(t=>{this.messenger.sendPacket({id:"registry:size_response",nonce:e.nonce,value:t})},t=>{this.sendError("registry:size_response",e.nonce,t)});this.sendErrorRaw("registry:size_response",e.nonce,"Unknown registry "+e.registryId)}async onGet(e){let t=await this.parent.getRegistry(e.registryId);if(void 0!==t)return t.get(e.key).then(t=>{this.messenger.sendPacket({id:"registry:get_response",nonce:e.nonce,value:this.serialize(t,{objectMode:"registry"})})},t=>{this.sendError("registry:get_response",e.nonce,t)});this.sendErrorRaw("registry:get_response",e.nonce,"Unknown registry "+e.registryId)}async onGetEntry(e){let t=await this.parent.getRegistry(e.registryId);if(void 0!==t)return t.getEntry(e.key).then(t=>{void 0!==t?this.messenger.sendPacket({id:"registry:get_entry_response",nonce:e.nonce,value:{key:this.serialize(t.key),ownerThread:t?.ownerThread,data:this.serialize(t.key,{objectMode:"registry"})}}):this.messenger.sendPacket({id:"registry:get_entry_response",nonce:e.nonce,value:null})},t=>{this.sendError("registry:get_entry_response",e.nonce,t)});this.sendErrorRaw("registry:get_entry_response",e.nonce,"Unknown registry "+e.registryId)}async onGetAllEntries(e){let t=await this.parent.getRegistry(e.registryId);if(void 0===t)return void this.sendErrorRaw("registry:get_all_entries_response",e.nonce,"Unknown registry "+e.registryId);let r=this.getRemote(),s=t.getAllEntries(),i=r.declareLocalAsyncIterator(s);this.messenger.sendPacket({id:"registry:get_all_entries_response",nonce:e.nonce,iteratorKey:i})}async onGetAllEntriesByThread(e){let t=await this.parent.getRegistry(e.registryId);if(void 0===t)return void this.sendErrorRaw("registry:get_all_entries_by_thread_response",e.nonce,"Unknown registry "+e.registryId);let r=this.getRemote(),s=t.getAllEntriesByThread(e.ownerThread),i=r.declareLocalAsyncIterator(s);this.messenger.sendPacket({id:"registry:get_all_entries_by_thread_response",nonce:e.nonce,iteratorKey:i})}async onGetAll(e){let t=await this.parent.getRegistry(e.registryId);if(void 0===t)return void this.sendErrorRaw("registry:get_all_response",e.nonce,"Unknown registry "+e.registryId);let r=this.getRemote(),s=t.getAll(),i=r.declareLocalAsyncIterator(s);this.messenger.sendPacket({id:"registry:get_all_response",nonce:e.nonce,iteratorKey:i})}async requestAdd(e,t,r,s){let i=await this.messenger.sendPacketWithNoncePromise("registry:add_request",{registryId:e,ownerThread:t??this.getCurrentThread(),key:r,value:this.serialize(s,{objectMode:"registry"})},"registry:add_response");if(i.error)throw this.deserialize(i.error);return i.value}async requestHas(e,t){let r=await this.messenger.sendPacketWithNoncePromise("registry:has_request",{registryId:e,key:t},"registry:has_response");if(r.error)throw this.deserialize(r.error);return r.value}async requestRemove(e,t,r){let s=await this.messenger.sendPacketWithNoncePromise("registry:remove_request",{registryId:e,ownerThread:t??this.getCurrentThread(),key:r},"registry:remove_response");if(s.error)throw this.deserialize(s.error);return s.value}async requestSize(e){let t=await this.messenger.sendPacketWithNoncePromise("registry:size_request",{registryId:e},"registry:size_response");if(t.error)throw this.deserialize(t.error);return t.value}async requestGet(e,t){let r=await this.messenger.sendPacketWithNoncePromise("registry:get_request",{registryId:e,key:t},"registry:get_response");if(r.error)throw this.deserialize(r.error);if(null!=r.value)return this.deserialize(r.value)}async requestGetEntry(e,t){let r=await this.messenger.sendPacketWithNoncePromise("registry:get_entry_request",{registryId:e,key:t},"registry:get_entry_response");if(r.error)throw this.deserialize(r.error);if(null!=r.value)return{key:this.deserialize(r.value.key),ownerThread:r.value.ownerThread,data:this.deserialize(r.value.data)}}requestGetAllEntries(e){let t=this.getRemote(),s=new r(t,async()=>{const r=await this.messenger.sendPacketWithNoncePromise("registry:get_all_entries_request",{registryId:e},"registry:get_all_entries_response");if(r.error)throw this.deserialize(r.error);let i=r.iteratorKey;return t.declareRemoteIterator(i,s),i});return s}requestGetAllEntriesByThread(e,t){let s=this.getRemote(),i=new r(s,async()=>{const r=await this.messenger.sendPacketWithNoncePromise("registry:get_all_entries_by_thread_request",{registryId:e,ownerThread:t},"registry:get_all_entries_by_thread_response");if(r.error)throw this.deserialize(r.error);let n=r.iteratorKey;return s.declareRemoteIterator(n,i),n});return i}requestGetAll(e){let t=this.getRemote(),s=new r(t,async()=>{const r=await this.messenger.sendPacketWithNoncePromise("registry:get_all_request",{registryId:e},"registry:get_all_response");if(r.error)throw this.deserialize(r.error);let i=r.iteratorKey;return t.declareRemoteIterator(i,s),i});return s}}class I{static META_REGISTRY_ID="rpack:registry";static PLUGIN_REGISTRY_ID="rpack:plugin";constructor(e){this.rpack=e,this.remotes=new Map,this.metaRegistry=this.__createInternalRegistry(I.META_REGISTRY_ID,{localsAreProxied:!1,allowShared:!0})}async createRegistry(e,t){let r=new P(this,e,y.withDefaultOptions(t));if(await this.metaRegistry.add(e,r))return r;throw new Error("Failed to create registry "+e)}getRPack(){return this.rpack}createRemote(e,t){let r=new E(this,e,t);return this.remotes.set(e,r),r}getRemote(e){return this.remotes.get(e)}getRegistry(e){return this.metaRegistry.get(e)}__createInternalRegistry(e,t){let r;return r=this.rpack.isPluginThread()?new b(this,M.HOST_THREAD_ID,e,y.withPublicDefaultOptions(t)):new P(this,e,y.withDefaultOptions(t)),this.rpack.getLoadPromise().then(()=>{this.metaRegistry.__localAdd(e,null,r)}),r}__deserializeRegistry(e,t,r){if(this.metaRegistry instanceof P||this.metaRegistry instanceof b){let s=this.metaRegistry.__localGet(e);if(void 0!==s)return s;let i=new b(this,t,e,r);return this.metaRegistry.__localAdd(e,t,i),i}throw new Error("Weird registry type: "+this.metaRegistry.constructor.name)}}(f||(f={})).isSubclass=function(e,t){return t.prototype.isPrototypeOf(e.prototype)};const x=f;class M{static HOST_THREAD_ID="host";constructor(e,t,r){this.rpack=e,this.wellKnownMap=new Map,this.wellKnownReverseMap=new Map,this.mapWellKnown("RPack",e),this.mapWellKnown("NetworkManager",e.getNetworkManager()),this.mapWellKnown("ProxyManager",e.getProxyManager()),this.mapWellKnown("RegistryManager",e.getRegistryManager()),this.plugin=null,this.pluginRegistry=e.getRegistryManager().__createInternalRegistry(I.PLUGIN_REGISTRY_ID,{}),this.threadId=t,void 0===r?this.threads=new Map:this.hostMessenger=r}mapWellKnown(e,t){this.wellKnownMap.set(t,{type:"well_known",kind:e}),this.wellKnownReverseMap.set(e,t)}async __initPlugin(e){if(null!==this.plugin)throw new Error("Cannot initialize a plugin twice");let t=await import(e);if(!("default"in t))throw new Error("Failed to import plugin "+e+": no default export");let r=t.default;if("function"!=typeof r)throw new Error("Failed to import plugin "+e+": default export is not a class");if(r.length>0)throw new Error("Failed to import plugin "+e+": default export's constructor expects arguments (should be empty)");if(!x.isSubclass(r,k))throw new Error("Failed to import plugin "+e+": default export is not a subclass of RPPlugin");this.plugin=new r,k.__setInstance(this.plugin,this.rpack),await this.plugin.onInit();let s=e.replace(/\.\/(\S+)\.js/g,"$1");await this.pluginRegistry.add(s,this.plugin),this.hostMessenger.addHandler("thread:shutdown_request",async e=>{await this.plugin.onShutdown(),this.hostMessenger.sendPacket({id:"thread:shutdown_response",nonce:e.nonce})})}getRPack(){return this.rpack}getHostMessenger(){return this.hostMessenger}getCurrentThreadId(){return this.threadId}getPlugin(e){return this.pluginRegistry.get(e)}getPluginRegistry(){return this.pluginRegistry}__initRemotes(e,t){this.rpack.getProxyManager().createRemote(e,v.cast(t)),this.rpack.getRegistryManager().createRemote(e,v.cast(t))}async __createThread(e){if(!this.threads)throw new Error("Cannot create a Worker from a Worker!");let t=o.generateNonce();for(;this.threads.has(t);)t=o.generateNonce();console.debug("Starting new thread "+t);let r=await this.rpack.getPlatform().createPluginThread(t,e);this.threads.set(t,r);let s=r.getMessenger(),i=null;for(let r=0;r<6;r++)try{console.debug("Waiting for thread "+t);let r=o.generateNonce();s.sendPacket({id:"thread:hello_request",nonce:r,threadId:t,scriptUrl:e}),await s.addPromiseNonceHandler("thread:hello_response",r),this.__initRemotes(t,v.cast(s)),console.debug("Thread "+t+" started"),i=r;break}catch{console.debug("Thread "+t+" timed out. Trying again...")}if(null===i)throw console.debug("Thread "+t+" failed to start, aborting"),await r.terminate(),this.threads.delete(t),new Error("Thread "+t+" failed to start");return await s.addPromiseNonceHandler("thread:plugin_load",i),console.debug("Plugin loaded in thread "+t),t}ensureJSONInner(e,t,r,s){if("string"==typeof t||"number"==typeof t||"boolean"==typeof t||null==t)return!0;if("object"==typeof t){if(Array.isArray(t)){for(let i=0;i<t.length;i++)if(!this.ensureJSONInner(e,t[i],r,s+"["+i+"]"))return!1;return!0}if(Object.getPrototypeOf(t)===Object.prototype){for(let i in t)if(!this.ensureJSONInner(e,t[i],r,s+"."+i))return!1;return!0}}if(r)throw new TypeError("Failed to validate object "+e+" as JSON: root"+s+" is not a JSON-like object");return!1}ensureJSON(e,t){return this.ensureJSONInner(e,e,t??!1)}getFunctionNames(e){if(R.isProxy(e))return R.getFunctions(e);let t=[],r=Object.getPrototypeOf(e);for(;void 0!==r&&r!==Object.prototype;)t.push(...Object.getOwnPropertyNames(r)),r=Object.getPrototypeOf(r);let s=t.indexOf("constructor");s>-1&&t.splice(s,1);for(let r=t.length-1;r>=0;r--)"function"!=typeof e[t[r]]&&t.splice(r,1);return t}serialize(e,t,r){if(void 0===t)return{type:"undefined"};if(!R.isProxy(t)&&("string"==typeof t||"number"==typeof t||"boolean"==typeof t||null==t||Object.getPrototypeOf(t)===Object.prototype&&this.ensureJSON(t,!1)))return{type:"json",value:t};if(t instanceof P||t instanceof b)return{type:"registry",registryId:t.getRegistryId(),options:t.getOptions()};if(t instanceof Error)return{type:"error",errorType:t.name,name:t.name,message:t.message,stack:t.stack};if("function"==typeof t)return{type:"function",functionKey:this.rpack.getProxyManager().getRemote(e).declareFunction(t)};if(this.wellKnownMap.has(t))return this.wellKnownMap.get(t);if(null===t)throw new Error("Null past the null checK?");if("registry"==r?.objectMode){let r=this.rpack.getProxyManager().getRemote(e).declareLocalObject(t),s={},i=this.getFunctionNames(t);for(let r of Object.keys(t))s[r]=this.serialize(e,t[r]);return{type:"registry_entry",objectKey:r,typeName:t.constructor.name,props:s,functions:i,iterable:Symbol.iterator in t||Symbol.asyncIterator in t}}{let r=this.rpack.getProxyManager().getRemote(e).declareLocalObject(t),s=Object.keys(t),i=this.getFunctionNames(t);return{type:"object",objectKey:r,typeName:t.constructor.name,props:s,functions:i,iterable:Symbol.iterator in t||Symbol.asyncIterator in t}}}deserialize(e,t){let r=this.rpack.getProxyManager().getRemote(e),s=t.type;switch(t.type){case"undefined":return;case"json":return t.value;case"registry":return this.rpack.getRegistryManager().__deserializeRegistry(t.registryId,e,t.options);case"registry_entry":return new Proxy({},R.fromRegistryEntry(r,t));case"object":return new Proxy({},R.fromObject(r,t));case"function":return(...e)=>r.requestRemoteFunction(t.functionKey,e);case"well_known":return this.wellKnownReverseMap.get(t.kind);case"error":let i;switch(t.errorType){case"Error":i=new Error;break;case"EvalError":i=new EvalError;break;case"RangeError":i=new RangeError;break;case"ReferenceError":i=new ReferenceError;break;case"SyntaxError":i=new SyntaxError;break;case"TypeError":i=new TypeError;break;case"URIError":i=new URIError}return i.name=t.name,i.message=t.message,i.stack=t.stack,i;default:throw new Error("Failed to deserialize unknown type: "+s)}}}class S{constructor(e,t){this.threadId=e,this.messenger=t}getThreadId(){return this.threadId}getMessenger(){return this.messenger}}class T{constructor(e){this.id=e}}class A{constructor(e,t,r){this.supplier=e,this.completeHandler=t,this.errorHandler=r,this.lastBatch=null,this.lastIndex=-1}[Symbol.asyncIterator](){return this}async next(){if(this.result)return this.result;null==this.lastBatch&&(this.lastBatch=await this.supplier(),this.lastIndex=0);let e=this.lastBatch.values[this.lastIndex];if(this.lastIndex++,this.lastIndex==this.lastBatch.values.length){let e=this.lastBatch;if(this.lastBatch=null,e.done)return this.result={done:!0,value:void 0},this.result}return{done:!1,value:e}}async return(e){return await this.completeHandler(e),this.result={value:this.result,done:!0},this.result}async throw(){return await this.errorHandler(),this.result={value:void 0,done:!0},this.result}}class j{constructor(e,t,r,s){this.rpackChannel="release",this.rpackVersion="0.1.2-5eab4e2",this.rpackRepository="https://github.com/rpack-dev/rpack-dev",this.implementationName=e,this.implementationChannel=t,this.implementationVersion=r,this.implementationRepository=s}getRPackChannel(){return this.rpackChannel}getRPackVersion(){return this.rpackVersion}getRPackRepository(){return this.rpackRepository}getImplementationName(){return this.implementationName}getImplementationChannel(){return this.implementationChannel}getImplementationVersion(){return this.implementationVersion}getImplementationRepository(){return this.implementationRepository}}class O{static platform=null;static platformLoadPromise=new i;static initPlatform(e){if(null!==this.platform)throw new Error("Platform already initialized");this.platform=e,this.platformLoadPromise.resolve(e)}static async createInstance(e){if(e&&void 0!==this.instance)return this.instance;let t=await this.platformLoadPromise.getPromise(),r=await t.createRPackInstance(e=>new O(e));return e&&(this.instance=r),r}static getInstance(){return this.instance}constructor(e){this.pluginThread=e.pluginThread,this.loadPromise=e.loadPromise,this.platform=e.platform,this.version=e.version,this.proxyManager=new h(this),this.registryManager=new I(this),this.networkManager=new M(this,e.threadId,e.hostMessenger)}getLoadPromise(){return this.loadPromise}getPlatform(){return this.platform}getVersion(){return this.version}getRegistryManager(){return this.registryManager}getProxyManager(){return this.proxyManager}getNetworkManager(){return this.networkManager}isPluginThread(){return this.pluginThread}getPlugin(e){return this.getNetworkManager().getPlugin(e)}}return t})());
@@ -18,17 +18,38 @@ declare class RPack {
18
18
  private readonly pluginThread;
19
19
  private readonly loadPromise;
20
20
  private readonly platform;
21
+ private readonly version;
21
22
  private readonly proxyManager;
22
23
  private readonly registryManager;
23
24
  private readonly networkManager;
24
25
  private constructor();
26
+ /**
27
+ * Returns a promise that completes when this RPack instance has fully loaded.
28
+ * Note that this Promise resolves before any plugins are loaded.
29
+ * @return a Promise
30
+ */
25
31
  getLoadPromise(): Promise<void>;
32
+ /**
33
+ * Returns the platform instance used to create this RPack instance.
34
+ * @return the platform instance
35
+ */
36
+ getPlatform(): RPPlatform;
37
+ /**
38
+ * Returns a class that contains version information about rPack and its platform implementation.
39
+ * @return an RPVersion instance
40
+ */
41
+ getVersion(): RPVersion;
26
42
  getRegistryManager(): RegistryManager;
27
43
  getProxyManager(): ProxyManager;
28
44
  getNetworkManager(): NetworkManager;
29
45
  isPluginThread(): boolean;
30
- getPlugin<T extends RPPlugin>(key: string): Promise<RegistryDataFiltered<T>>;
31
- getPlatform(): RPPlatform;
46
+ /**
47
+ * Shorthand for getNetworkManager().getPlugin().
48
+ *
49
+ * @param key the plugin key
50
+ * @return a Promise that will resolve with the plugin instance, or `undefined` if the plugin cannot be found
51
+ */
52
+ getPlugin<T extends RPPlugin>(key: string): Promise<RegistryDataFiltered<T> | undefined>;
32
53
  }
33
54
  export declare abstract class PluginThread {
34
55
  private readonly threadId;
@@ -194,7 +215,7 @@ export declare class NetworkManager {
194
215
  getRPack(): RPack;
195
216
  getHostMessenger(): Messenger<H2WPackets, W2HPackets> | undefined;
196
217
  getCurrentThreadId(): string;
197
- getPlugin<T extends RPPlugin>(key: string): Promise<RegistryDataFiltered<T>>;
218
+ getPlugin<T extends RPPlugin>(key: string): Promise<RegistryDataFiltered<T> | undefined>;
198
219
  getPluginRegistry(): Registry<RPPlugin, string>;
199
220
  __initRemotes(threadId: string, messenger: Messenger<H2WPackets | W2HPackets, H2WPackets | W2HPackets>): void;
200
221
  __createThread(scriptUrl: string): Promise<string>;
@@ -241,6 +262,23 @@ export declare class RPPlugin {
241
262
  */
242
263
  static __setInstance(plugin: RPPlugin, rpack: RPack): void;
243
264
  }
265
+ export declare class RPVersion {
266
+ private readonly rpackChannel;
267
+ private readonly rpackVersion;
268
+ private readonly rpackRepository;
269
+ private readonly implementationName;
270
+ private readonly implementationChannel;
271
+ private readonly implementationVersion;
272
+ private readonly implementationRepository;
273
+ constructor(implementationName: string, implementationChannel: string, implementationVersion: string, implementationRepository: string);
274
+ getRPackChannel(): string;
275
+ getRPackVersion(): string;
276
+ getRPackRepository(): string;
277
+ getImplementationName(): string;
278
+ getImplementationChannel(): string;
279
+ getImplementationVersion(): string;
280
+ getImplementationRepository(): string;
281
+ }
244
282
  export declare class RegistryManager {
245
283
  private static readonly META_REGISTRY_ID;
246
284
  static readonly PLUGIN_REGISTRY_ID = "rpack:plugin";
@@ -1046,6 +1084,7 @@ export type RPackConstructorOptions = {
1046
1084
  platform: RPPlatform;
1047
1085
  threadId: string;
1048
1086
  hostMessenger?: Messenger<H2WPackets, W2HPackets>;
1087
+ version: RPVersion;
1049
1088
  };
1050
1089
  export type RegistryDataFiltered<Data> = Data extends Serializable ? Data : {
1051
1090
  readonly [Key in keyof Data]: Data[Key] extends Serializable ? Data[Key] : Data[Key] extends (...args: any) => Promise<any> ? Data[Key] : Data[Key] extends (...args: infer P) => infer R ? (...args: P) => Promise<R> : never;
package/package.json CHANGED
@@ -1,7 +1,12 @@
1
1
  {
2
2
  "name": "@rpack-dev/core",
3
- "version": "0.1.2-4752725",
3
+ "version": "0.1.2-5eab4e2",
4
4
  "description": "",
5
+ "license": "LGPL-3.0-or-later",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "https://github.com/rpack-dev/rpack-dev"
9
+ },
5
10
  "main": "dist/rpack-core.bundle.js",
6
11
  "module": "dist/rpack-core.bundle.js",
7
12
  "types": "dist/rpack-core.d.ts",
@@ -27,6 +32,7 @@
27
32
  "@babel/preset-react": "^7.24.1",
28
33
  "@babel/preset-typescript": "^7.24.1",
29
34
  "@types/jasmine": "^4.3.1",
35
+ "@types/node": "^24.0.13",
30
36
  "@types/svg-sprite-loader": "^3.9.9",
31
37
  "babel-loader": "^9.1.3",
32
38
  "bundle-declarations-webpack-plugin": "^6.0.0",