@webrecorder/wombat 3.8.14 → 3.9.1
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/.github/workflows/make-draft-release.yaml +30 -0
- package/dist/wombat.js +1 -1
- package/dist/wombatWorkers.js +1 -1
- package/package.json +2 -2
- package/src/customStorage.js +6 -7
- package/src/listeners.js +4 -4
- package/src/wombat.js +341 -187
- package/src/wombatWorkers.js +88 -9
package/dist/wombatWorkers.js
CHANGED
|
@@ -18,4 +18,4 @@ GNU Affero General Public License for more details.
|
|
|
18
18
|
You should have received a copy of the GNU Affero General Public License
|
|
19
19
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
20
20
|
*/
|
|
21
|
-
function e(t){if(!(this instanceof e))return new e(t);this.info=t,this.initImportScriptsRewrite(),this.initHTTPOverrides(),this.initClientApisOverride(),this.initCacheApisOverride()}e.prototype.noRewrite=function(e){return!e||0===e.indexOf("blob:")||0===e.indexOf("javascript:")||0===e.indexOf("data:")||0===e.indexOf(this.info.prefix)},e.prototype.isRelURL=function(e){return 0===e.indexOf("/")||!e.startsWith("http:")&&!e.startsWith("https:")},e.prototype.maybeResolveURL=function(e,t){if(!t)return e;try{return new URL(e,t).href}catch(e){}return e},e.prototype.ensureURL=function(e,t){if(!e)return e;var r;switch(typeof e){case"string":r=e;break;case"object":r=e.toString();break;default:return null}return this.noRewrite(r)?null:this.isRelURL(r)?this.maybeResolveURL(r,t):0===r.indexOf(self.location.origin)?this.maybeResolveURL(r.slice(self.location.origin.length),t):r},e.prototype.rewriteURL=function(e){var t=this.ensureURL(e,this.info.originalURL);return t?this.
|
|
21
|
+
function e(t){if(!(this instanceof e))return new e(t);this.info=t,this.prefixMod=this.info.prefix+this.info.mod+"/",this.initImportScriptsRewrite(),this.initHTTPOverrides(),this.initClientApisOverride(),this.initCacheApisOverride(),this.initSelfOverrides()}e.prototype.noRewrite=function(e){return!e||0===e.indexOf("blob:")||0===e.indexOf("javascript:")||0===e.indexOf("data:")||0===e.indexOf(this.info.prefix)},e.prototype.isRelURL=function(e){return 0===e.indexOf("/")||!e.startsWith("http:")&&!e.startsWith("https:")},e.prototype.maybeResolveURL=function(e,t){if(!t)return e;try{return new URL(e,t).href}catch(e){}return e},e.prototype.ensureURL=function(e,t){if(!e)return e;var r;switch(typeof e){case"string":r=e;break;case"object":r=e.toString();break;default:return null}return this.noRewrite(r)?null:this.isRelURL(r)?this.maybeResolveURL(r,t):0===r.indexOf(self.location.origin)?this.maybeResolveURL(r.slice(self.location.origin.length),t):r},e.prototype.rewriteURL=function(e){var t=this.ensureURL(e,this.info.originalURL);return t?this.prefixMod?this.prefixMod+t:t:e},e.prototype.extractOriginalURL=function(e){return e&&e.startsWith(this.prefixMod)?e.slice(this.prefixMod.length):e},e.prototype.rewriteClientWindowURL=function(e,t){var r=this.ensureURL(e,t?t.url:this.info.originalURL);return r?this.info.prefix?this.info.prefix+"mp_/"+r:r:e},e.prototype.rewriteWSURL=function(e){if(!e)return e;var t=typeof e,r=e;if("object"===t)r=e.toString();else if("string"!==t)return e;if(!r)return r;var i="https://",o=0===this.info.prefix.indexOf(i);return this.info.prefix.replace(o?i:"http://",o?"wss://":"ws://")+"ws_/"+r},e.prototype.rewriteArgs=function(e){for(var t=new Array(e.length),r=0;r<t.length;r++)t[r]=this.rewriteURL(e[r]);return t},e.prototype.rewriteFetchApi=function(e){var t=e;switch(typeof e){case"string":t=this.rewriteURL(e);break;case"object":if(e.url){var r=this.rewriteURL(e.url);r!==e.url&&(t=new Request(r,e))}else e.href&&(t=this.rewriteURL(e.href))}return t},e.prototype.rewriteCacheApi=function(e){var t=e;return"string"==typeof e&&(t=this.rewriteURL(e)),t},e.prototype.initImportScriptsRewrite=function(){if(self.importScripts){var e=this,t=self.importScripts;self.importScripts=function(){var r=e.rewriteArgs(arguments);return t.apply(this,r)}}},e.prototype.initSelfOverrides=function(){var e=this;self._WB_wombat_location=new Proxy(self.location,{get:(t,r,i)=>"href"===r?e.extractOriginalURL(t[r]):t[r]}),self.____wb_rewrite_import__=function(t,r){return r&&t?r=new URL(r,t).href:t&&void 0===r&&(r=t),import(e.rewriteURL(r))};var t=function(e){return this.__WB_source=e,this};try{self.Object.defineProperty(self.Object.prototype,"__WB_pmw",{get:function(){return t},set:function(){},configurable:!0,enumerable:!1})}catch(e){}self.Object.defineProperty(self.Object.prototype,"_____WB$wombat$check$this$function_____",{configutable:!1,enumerable:!1,value:function(e){try{return e&&e._WB_wombat_obj_proxy?e._WB_wombat_obj_proxy:e}catch(t){return e}}})},e.prototype.initHTTPOverrides=function(){var e,t,r,i=this;if(self.XMLHttpRequest&&self.XMLHttpRequest.prototype&&self.XMLHttpRequest.prototype.open){var o=self.XMLHttpRequest.prototype.open;self.XMLHttpRequest.prototype.open=function(e,t,r,n,s){var p=i.rewriteURL(t),f=!0;null==r||r||(f=!1),o.call(this,e,p,f,n,s),-1===p.indexOf("data:")&&this.setRequestHeader("X-Pywb-Requested-With","XMLHttpRequest")}}if(null!=self.fetch){var n=self.fetch;self.fetch=function(e,t){var r=i.rewriteFetchApi(e),o=t||{};return o.credentials="include",n.call(this,r,o)}}if(self.Request&&self.Request.prototype){var s=self.Request;self.Request=(e=self.Request,function(t,r){var o=r||{},n=i.rewriteFetchApi(t);return o.credentials="include",new e(n,o)}),self.Request.prototype=s.prototype}if(self.Response&&self.Response.prototype){var p=self.Response.prototype.redirect;self.Response.prototype.redirect=function(e,t){var r=i.rewriteURL(e);return p.call(this,r,t)}}if(self.EventSource&&self.EventSource.prototype){var f=self.EventSource;self.EventSource=(t=self.EventSource,function(e,r){var o=e;return null!=e&&(o=i.rewriteURL(e)),new t(o,r)}),self.EventSource.prototype=f.prototype,Object.defineProperty(self.EventSource.prototype,"constructor",{value:self.EventSource})}if(self.WebSocket&&self.WebSocket.prototype){var l=self.WebSocket;self.WebSocket=(r=self.WebSocket,function(e,t){var o=e;return null!=e&&(o=i.rewriteWSURL(e)),new r(o,t)}),self.WebSocket.prototype=l.prototype,Object.defineProperty(self.WebSocket.prototype,"constructor",{value:self.WebSocket})}},e.prototype.initClientApisOverride=function(){var e=this;if(self.Clients&&self.Clients.prototype&&self.Clients.prototype.openWindow){var t=self.Clients.prototype.openWindow;self.Clients.prototype.openWindow=function(r){var i=e.rewriteClientWindowURL(r);return t.call(this,i)}}if(self.WindowClient&&self.WindowClient.prototype&&self.WindowClient.prototype.navigate){var r=self.WindowClient.prototype.navigate;self.WindowClient.prototype.navigate=function(t){var i=e.rewriteClientWindowURL(t,this);return r.call(this,i)}}},e.prototype.initCacheApisOverride=function(){var e=this;if(self.CacheStorage&&self.CacheStorage.prototype&&self.CacheStorage.prototype.match){var t=self.CacheStorage.prototype.match;self.CacheStorage.prototype.match=function(r,i){var o=e.rewriteCacheApi(r);return t.call(this,o,i)}}if(self.Cache&&self.Cache.prototype){if(self.Cache.prototype.match){var r=self.Cache.prototype.match;self.Cache.prototype.match=function(t,i){var o=e.rewriteCacheApi(t);return r.call(this,o,i)}}if(self.Cache.prototype.matchAll){var i=self.Cache.prototype.matchAll;self.Cache.prototype.matchAll=function(t,r){var o=e.rewriteCacheApi(t);return i.call(this,o,r)}}if(self.Cache.prototype.add){var o=self.Cache.prototype.add;self.Cache.prototype.add=function(t,r){var i=e.rewriteCacheApi(t);return o.call(this,i,r)}}if(self.Cache.prototype.addAll){var n=self.Cache.prototype.addAll;self.Cache.prototype.addAll=function(t){var r=t;if(Array.isArray(t)){r=new Array(t.length);for(var i=0;i<t.length;i++)r[i]=e.rewriteCacheApi(t[i])}return n.call(this,r)}}if(self.Cache.prototype.put){var s=self.Cache.prototype.put;self.Cache.prototype.put=function(t,r){var i=e.rewriteCacheApi(t);return s.call(this,i,r)}}if(self.Cache.prototype.delete){var p=self.Cache.prototype.delete;self.Cache.prototype.delete=function(t,r){var i=e.rewriteCacheApi(t);return p.call(this,i,r)}}if(self.Cache.prototype.keys){var f=self.Cache.prototype.keys;self.Cache.prototype.keys=function(t,r){var i=e.rewriteCacheApi(t);return f.call(this,i,r)}}}},self.WBWombat=e;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webrecorder/wombat",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.9.1",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"license": "AGPL-3.0-or-later",
|
|
6
6
|
"author": "Ilya Kreymer, Webrecorder Software",
|
|
@@ -65,6 +65,6 @@
|
|
|
65
65
|
"*/**/fs-extra": "~8.1.0"
|
|
66
66
|
},
|
|
67
67
|
"dependencies": {
|
|
68
|
-
"warcio": "^2.4.
|
|
68
|
+
"warcio": "^2.4.7"
|
|
69
69
|
}
|
|
70
70
|
}
|
package/src/customStorage.js
CHANGED
|
@@ -56,10 +56,13 @@ function storageProxyHandler() {
|
|
|
56
56
|
return proto;
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
-
if (
|
|
59
|
+
if (
|
|
60
|
+
proto.hasOwnProperty(prop) ||
|
|
61
|
+
(proto.__proto__ && proto.__proto__.hasOwnProperty(prop))
|
|
62
|
+
) {
|
|
60
63
|
var res = target[prop];
|
|
61
64
|
|
|
62
|
-
if (typeof
|
|
65
|
+
if (typeof res === 'function') {
|
|
63
66
|
res = res.bind(target);
|
|
64
67
|
}
|
|
65
68
|
|
|
@@ -79,7 +82,7 @@ function storageProxyHandler() {
|
|
|
79
82
|
return true;
|
|
80
83
|
}
|
|
81
84
|
};
|
|
82
|
-
}
|
|
85
|
+
}
|
|
83
86
|
|
|
84
87
|
export function createStorage(wombat, type, initData) {
|
|
85
88
|
var storage = new Storage(wombat, type, initData);
|
|
@@ -136,7 +139,6 @@ Storage.prototype.removeItem = function removeItem(name) {
|
|
|
136
139
|
return undefined;
|
|
137
140
|
};
|
|
138
141
|
|
|
139
|
-
|
|
140
142
|
/**
|
|
141
143
|
* When invoked, will empty all keys out of the storage
|
|
142
144
|
* @return {undefined}
|
|
@@ -198,7 +200,6 @@ Storage.prototype.valueOf = function valueOf() {
|
|
|
198
200
|
return this[WOMBAT].$wbwindow[this[TYPE]];
|
|
199
201
|
};
|
|
200
202
|
|
|
201
|
-
|
|
202
203
|
/**
|
|
203
204
|
* An override of toString to return '[object Storage]'
|
|
204
205
|
**/
|
|
@@ -206,8 +207,6 @@ Storage.prototype.toString = function() {
|
|
|
206
207
|
return '[object Storage]';
|
|
207
208
|
};
|
|
208
209
|
|
|
209
|
-
|
|
210
|
-
|
|
211
210
|
// the length getter is on the prototype (__proto__ modern browsers)
|
|
212
211
|
Object.defineProperty(Storage.prototype, 'length', {
|
|
213
212
|
enumerable: false,
|
package/src/listeners.js
CHANGED
|
@@ -25,12 +25,12 @@ export function wrapEventListener(origListener, obj, wombat) {
|
|
|
25
25
|
var origListenerFunc;
|
|
26
26
|
|
|
27
27
|
// if a function, just use that
|
|
28
|
-
if (typeof
|
|
28
|
+
if (typeof origListener === 'function') {
|
|
29
29
|
origListenerFunc = origListener;
|
|
30
|
-
|
|
31
|
-
} else if (typeof
|
|
30
|
+
// if an EventHandler object, use its handleEvent() bound method
|
|
31
|
+
} else if (typeof origListener === 'object') {
|
|
32
32
|
origListenerFunc = origListener.handleEvent.bind(origListener);
|
|
33
|
-
|
|
33
|
+
// else do nothing!
|
|
34
34
|
} else {
|
|
35
35
|
origListenerFunc = function() {};
|
|
36
36
|
}
|