Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@oracle/offline-persistence-toolkit

Package Overview
Dependencies
Maintainers
5
Versions
39
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@oracle/offline-persistence-toolkit - npm Package Compare versions

Comparing version 1.4.7 to 1.4.8

dist/debug/offline-persistence-toolkit-arraystore-1.4.8.js

12

dist/debug/bundles-config.js

@@ -5,3 +5,3 @@ (function(){

{
'persist/offline-persistence-toolkit-core-1.4.7': [
'persist/offline-persistence-toolkit-core-1.4.8': [
'persist/persistenceUtils',

@@ -18,3 +18,3 @@ 'persist/impl/logger',

],
'persist/offline-persistence-toolkit-pouchdbstore-1.4.7': [
'persist/offline-persistence-toolkit-pouchdbstore-1.4.8': [
'persist/PersistenceStore',

@@ -28,3 +28,3 @@ 'persist/impl/storageUtils',

],
'persist/offline-persistence-toolkit-arraystore-1.4.7': [
'persist/offline-persistence-toolkit-arraystore-1.4.8': [
'persist/PersistenceStore',

@@ -37,3 +37,3 @@ 'persist/impl/storageUtils',

],
'persist/offline-persistence-toolkit-localstore-1.4.7': [
'persist/offline-persistence-toolkit-localstore-1.4.8': [
'persist/PersistenceStore',

@@ -46,3 +46,3 @@ 'persist/impl/storageUtils',

],
'persist/offline-persistence-toolkit-filesystemstore-1.4.7': [
'persist/offline-persistence-toolkit-filesystemstore-1.4.8': [
'persist/impl/storageUtils',

@@ -53,3 +53,3 @@ 'persist/impl/keyValuePersistenceStore',

],
'persist/offline-persistence-toolkit-responseproxy-1.4.7': [
'persist/offline-persistence-toolkit-responseproxy-1.4.8': [
'persist/fetchStrategies',

@@ -56,0 +56,0 @@ 'persist/cacheStrategies',

@@ -75,2 +75,3 @@ /**

PersistenceManager.prototype.init = function () {
logger.log("Offline Persistence Toolkit PersistenceManager: Initilizing");
_replaceBrowserApis(this);

@@ -305,2 +306,3 @@ _addBrowserEventListeners(this);

// just call regular fetch.
var requestObj = request
if (_isBrowserContext()) {

@@ -317,5 +319,5 @@ // store the last Request object on the PersistenceManager so that we

if (request._browserRequest) {
request = request._browserRequest;
requestObj = request._browserRequest;
}
self._browserFetchFunc.call(window, request).then(function (response) {
self._browserFetchFunc.call(window, requestObj).then(function (response) {
resolve(response);

@@ -329,5 +331,5 @@ }, function (error) {

if (request._browserRequest) {
request = request._browserRequest;
requestObj = request._browserRequest;
}
return fetch(request);
return fetch(requestObj);
}

@@ -414,2 +416,3 @@ };

if (_isSafari()) {
logger.log("Offline Persistence Toolkit PersistenceManager: Replacing Safari Browser APIs");
// using self to refer to both the "window" and the "self" context

@@ -675,5 +678,41 @@ // of serviceworker

var self = this;
this._browserRequest = new persistenceManager._browserRequestConstructor(input, init);
this._input = input;
this._init = init;
// create two variables to house the input and init vars
var requestInput = input;
var requestInit = init;
logger.log("Offline Persistence Toolkit persistenceRequest: Create New Request");
// Check if the input is a Request object
if (input._input){
logger.log("Offline Persistence Toolkit persistenceRequest: Input is a PersistenceRequest");
// we replace the user inputs with a copy of the previous request object's input and init vars
requestInput = input._input;
requestInit = Object.assign({}, input._init);
// if there are any init's for for this request, then those must also be carried over to
// the requestInit overwriting any previous entries
for (var key in init) {
if (init.hasOwnProperty(key)) {
requestInit[key]= init[key];
}
}
// the headers and body must be checked for formData instance
// if it has both exist, then the headers.get("Content-Type") must be replace
// to preserve formData Boundary
if (input.headers &&
requestInit &&
requestInit.body &&
requestInit.body instanceof FormData) {
// check to see if the header exist before adding, if it does only replace content-type
if (requestInit.headers){
var contentType = input.headers.get("Content-Type")
requestInit.headers.set("Content-Type",contentType );
} else {
// else replace whole header
requestInit.headers = input.headers;
}
}
}
this._browserRequest = new persistenceManager._browserRequestConstructor(requestInput, requestInit);
this._input = requestInput;
this._init = requestInit;
var requestDefineProperty = function (requestProperty) {

@@ -719,9 +758,11 @@ var propDescriptors = Object.getOwnPropertyDescriptor(self._browserRequest, requestProperty);

this.arrayBuffer = function () {
logger.log("Offline Persistence Toolkit persistenceRequest: Called arrayBuffer()");
var self = this;
try {
if (this._init &&
this._init.body) {
if (!(this._init.body instanceof FormData)) {
return this._browserRequest.arrayBuffer();
if (self._init &&
self._init.body) {
if (!(self._init.body instanceof FormData)) {
return self._browserRequest.arrayBuffer();
} else {
return _formDataToString(this._init.body, this._boundary).then(function (formDataText) {
return _formDataToString(self._init.body, self._boundary).then(function (formDataText) {
var formDataArrayBuffer = _strToArrayBuffer(formDataText);

@@ -732,3 +773,3 @@ return formDataArrayBuffer;

}
return this._browserRequest.arrayBuffer();
return self._browserRequest.arrayBuffer();
} catch (e) {

@@ -740,11 +781,13 @@ return Promise.reject(e);

this.blob = function () {
logger.log("Offline Persistence Toolkit persistenceRequest: Called blob()");
var self = this;
try {
if (this._init &&
this._init.body) {
if (!(this._init.body instanceof FormData)) {
return this._browserRequest.blob();
if (self._init &&
self._init.body) {
if (!(self._init.body instanceof FormData)) {
return self._browserRequest.blob();
} else {
return _formDataToString(this._init.body, this._boundary).then(function (formDataText) {
return _formDataToString(self._init.body, self._boundary).then(function (formDataText) {
var formDataBlob = new Blob([formDataText],
{ type: this.headers.get("Content-Type") });
{ type: self.headers.get("Content-Type") });
return formDataBlob;

@@ -754,3 +797,3 @@ })

}
return this._browserRequest.blob();
return self._browserRequest.blob();
} catch (e) {

@@ -762,12 +805,14 @@ return Promise.reject(e);

this.formData = function () {
logger.log("Offline Persistence Toolkit persistenceRequest: Called formData()");
var self = this;
try {
if (this._init &&
this._init.body) {
if (!(this._init.body instanceof FormData)) {
return this._browserRequest.formData();
if (self._init &&
self._init.body) {
if (!(self._init.body instanceof FormData)) {
return self._browserRequest.formData();
} else {
return Promise.resolve(this._init.body);
return Promise.resolve(self._init.body);
}
}
return this._browserRequest.formData();
return self._browserRequest.formData();
} catch (e) {

@@ -779,7 +824,9 @@ return Promise.reject(e);

this.json = function () {
logger.log("Offline Persistence Toolkit persistenceRequest: Called json()");
var self = this;
try {
if (this._init &&
this._init.body) {
if (!(this._init.body instanceof FormData)) {
return this._browserRequest.json();
if (self._init &&
self._init.body) {
if (!(self._init.body instanceof FormData)) {
return self._browserRequest.json();
} else {

@@ -789,3 +836,3 @@ return Promise.reject(new SyntaxError("Unexpected number in JSON at position 1"));

}
return this._browserRequest.json();
return self._browserRequest.json();
} catch (e) {

@@ -797,12 +844,14 @@ return Promise.reject(e);

this.text = function () {
logger.log("Offline Persistence Toolkit persistenceRequest: Called text()");
var self = this;
try {
if (this._init &&
this._init.body) {
if (!(this._init.body instanceof FormData)) {
return this._browserRequest.text();
if (self._init &&
self._init.body) {
if (!(self._init.body instanceof FormData)) {
return self._browserRequest.text();
} else {
return _formDataToString(this._init.body, this._boundary);
return _formDataToString(self._init.body, self._boundary);
}
}
return this._browserRequest.text();
return self._browserRequest.text();
} catch (e) {

@@ -814,17 +863,25 @@ return Promise.reject(e);

this.clone = function () {
if (this.headers &&
this._init &&
this._init.body &&
this._init.body instanceof FormData) {
this._init.headers = this.headers;
logger.log("Offline Persistence Toolkit persistenceRequest: Called clone()");
var self = this;
if (self.headers &&
self._init &&
self._init.body &&
self._init.body instanceof FormData) {
self._init.headers = self.headers;
}
var clonedRequest = new PersistenceRequest(this._input, this._init);
clonedRequest._browserRequest = this._browserRequest.clone();
var clonedRequest = new PersistenceRequest(self._input, self._init);
clonedRequest._browserRequest = self._browserRequest.clone();
return clonedRequest;
}
this.toString = function () {
logger.log("Offline Persistence Toolkit persistenceRequest:requestToString()");
if (this._input.url){
return this._input.url;
} else {
return this._input;
}
}
};
return PersistenceRequest;
};
// this is the minimal wrapper version of fetch which we replace the serviceworker

@@ -892,2 +949,3 @@ // version with. We only do this in Safari's serviceworker context to unwrap our

}
logger.log("Offline Persistence Toolkit serviceWorkerFetch:"+request.url);
if (request._browserRequest) {

@@ -894,0 +952,0 @@ request = request._browserRequest;

@@ -1,1 +0,1 @@

!function(){requirejs.config({bundles:{"persist/offline-persistence-toolkit-core-1.4.7":["persist/persistenceUtils","persist/impl/logger","persist/impl/PersistenceXMLHttpRequest","persist/persistenceStoreManager","persist/impl/defaultCacheHandler","persist/impl/PersistenceSyncManager","persist/impl/OfflineCache","persist/impl/offlineCacheManager","persist/impl/fetch","persist/persistenceManager"],"persist/offline-persistence-toolkit-pouchdbstore-1.4.7":["persist/PersistenceStore","persist/impl/storageUtils","persist/pouchdb-browser-7.0.0","persist/impl/pouchDBPersistenceStore","persist/pouchDBPersistenceStoreFactory","persist/configurablePouchDBStoreFactory","persist/persistenceStoreFactory"],"persist/offline-persistence-toolkit-arraystore-1.4.7":["persist/PersistenceStore","persist/impl/storageUtils","persist/impl/keyValuePersistenceStore","persist/impl/arrayPersistenceStore","persist/arrayPersistenceStoreFactory","persist/persistenceStoreFactory"],"persist/offline-persistence-toolkit-localstore-1.4.7":["persist/PersistenceStore","persist/impl/storageUtils","persist/impl/keyValuePersistenceStore","persist/impl/localPersistenceStore","persist/localPersistenceStoreFactory","persist/persistenceStoreFactory"],"persist/offline-persistence-toolkit-filesystemstore-1.4.7":["persist/impl/storageUtils","persist/impl/keyValuePersistenceStore","persist/impl/fileSystemPersistenceStore","persist/fileSystemPersistenceStoreFactory"],"persist/offline-persistence-toolkit-responseproxy-1.4.7":["persist/fetchStrategies","persist/cacheStrategies","persist/defaultResponseProxy","persist/simpleJsonShredding","persist/oracleRestJsonShredding","persist/simpleBinaryDataShredding","persist/queryHandlers"]}})}();
!function(){requirejs.config({bundles:{"persist/offline-persistence-toolkit-core-1.4.8":["persist/persistenceUtils","persist/impl/logger","persist/impl/PersistenceXMLHttpRequest","persist/persistenceStoreManager","persist/impl/defaultCacheHandler","persist/impl/PersistenceSyncManager","persist/impl/OfflineCache","persist/impl/offlineCacheManager","persist/impl/fetch","persist/persistenceManager"],"persist/offline-persistence-toolkit-pouchdbstore-1.4.8":["persist/PersistenceStore","persist/impl/storageUtils","persist/pouchdb-browser-7.0.0","persist/impl/pouchDBPersistenceStore","persist/pouchDBPersistenceStoreFactory","persist/configurablePouchDBStoreFactory","persist/persistenceStoreFactory"],"persist/offline-persistence-toolkit-arraystore-1.4.8":["persist/PersistenceStore","persist/impl/storageUtils","persist/impl/keyValuePersistenceStore","persist/impl/arrayPersistenceStore","persist/arrayPersistenceStoreFactory","persist/persistenceStoreFactory"],"persist/offline-persistence-toolkit-localstore-1.4.8":["persist/PersistenceStore","persist/impl/storageUtils","persist/impl/keyValuePersistenceStore","persist/impl/localPersistenceStore","persist/localPersistenceStoreFactory","persist/persistenceStoreFactory"],"persist/offline-persistence-toolkit-filesystemstore-1.4.8":["persist/impl/storageUtils","persist/impl/keyValuePersistenceStore","persist/impl/fileSystemPersistenceStore","persist/fileSystemPersistenceStoreFactory"],"persist/offline-persistence-toolkit-responseproxy-1.4.8":["persist/fetchStrategies","persist/cacheStrategies","persist/defaultResponseProxy","persist/simpleJsonShredding","persist/oracleRestJsonShredding","persist/simpleBinaryDataShredding","persist/queryHandlers"]}})}();

@@ -1,1 +0,1 @@

define(["./impl/PersistenceXMLHttpRequest","./impl/PersistenceSyncManager","./impl/offlineCacheManager","./impl/logger","./impl/fetch"],function(a,b,c,d){"use strict";function e(){Object.defineProperty(this,"_registrations",{value:[],writable:!0}),Object.defineProperty(this,"_eventListeners",{value:[],writable:!0}),Object.defineProperty(this,"_forceOffline",{value:!1,writable:!0}),Object.defineProperty(this,"_isOffline",{value:!1,writable:!0}),Object.defineProperty(this,"_cache",{value:null,writable:!0}),Object.defineProperty(this,"_persistenceSyncManager",{value:new b(this.isOnline.bind(this),this.browserFetch.bind(this),this.getCache.bind(this))})}function f(a){var b=a;g()&&!b._addedBrowserEventListeners&&(d.log("Offline Persistence Toolkit PersistenceManager: Adding browser event listeners"),window.addEventListener("offline",function(a){b._isOffline=!0},!1),window.addEventListener("online",function(a){b._isOffline=!1},!1),b._addedBrowserEventListeners=!0)}function g(){return"undefined"!=typeof window&&null!=window}function h(a,b,c){var e,f,g,h,i=null,j=a._registrations,k=null!=j?j.length:0;for(e=0;e<k;e++)if(g=j[e],null!=c.request.url.match(g.scope)){for(h=g._eventListeners.length,f=0;f<h;f++)if(g._eventListeners[f].type==b)if("fetch"==b)null===i&&c._setPromiseCallbacks instanceof Function&&(i=new Promise(function(a,b){c._setPromiseCallbacks(a,b)})),d.log("Offline Persistence Toolkit PersistenceManager: Calling fetch event listener"),g._eventListeners[f].listener(c);else if(d.log("Offline Persistence Toolkit PersistenceManager: Calling event listener"),!1===g._eventListeners[f].listener(c))return!1;if(null!=i)return i}return!0}function i(a){a._cache=c.open("systemCache")}function j(b){p()&&(Object.defineProperty(b,"_browserRequestConstructor",{value:self.Request,writable:!1}),Object.defineProperty(b,"_persistenceRequestConstructor",{value:n(b),writable:!1}),self.Request=b._persistenceRequestConstructor,g()||(Object.defineProperty(b,"_browserFetchFunc",{value:self.fetch,writable:!1}),self.fetch=o(b))),!g()||b._browserFetchFunc||b._browserXMLHttpRequest||(d.log("Offline Persistence Toolkit PersistenceManager: Replacing browser APIs"),Object.defineProperty(b,"_browserFetchFunc",{value:window.fetch,writable:!1}),Object.defineProperty(b,"_browserXMLHttpRequest",{value:window.XMLHttpRequest,writable:!1}),window.fetch=m(b),window.XMLHttpRequest=function(){return null!=b._browserFetchRequest?new b._browserXMLHttpRequest:new a(b._browserXMLHttpRequest)})}function k(a,b){var c=a,d=c._registrations.indexOf(b);return d>-1&&(c._registrations.splice(d,1),!0)}function l(a,b){Object.defineProperty(this,"scope",{value:a,enumerable:!0}),Object.defineProperty(this,"_persistenceManager",{value:b}),Object.defineProperty(this,"_eventListeners",{value:[],writable:!0})}function m(a){function b(a){Object.defineProperty(this,"isReload",{value:!1,enumerable:!0}),Object.defineProperty(this,"clientId",{value:null,enumerable:!0}),Object.defineProperty(this,"client",{value:null,enumerable:!0}),Object.defineProperty(this,"request",{value:a,enumerable:!0}),Object.defineProperty(this,"_resolveCallback",{value:null,writable:!0}),Object.defineProperty(this,"_rejectCallback",{value:null,writable:!0})}return b.prototype.respondWith=function(a){var b=this;if(a instanceof Promise)a.then(function(a){b._resolveCallback(a)},function(a){b._rejectCallback(a)});else if("function"==typeof a){var c=a();b._resolveCallback(c)}},b.prototype._setPromiseCallbacks=function(a,b){this._resolveCallback=a,this._rejectCallback=b},function(c,d){var e;return e=Request.prototype.isPrototypeOf(c)&&!d?c:new Request(c,d),a.getRegistration(e.url).then(function(c){if(null!=c){var d=new b(e),f=h(a,"fetch",d);if(null!=f&&f instanceof Promise)return f}return a.browserFetch(e)})}}function n(a){function b(c,d){var e=this;this._browserRequest=new a._browserRequestConstructor(c,d),this._input=c,this._init=d;var f;for(f in this._browserRequest)"body"!=f&&"function"==typeof this._browserRequest[f]||function(a){var b=Object.getOwnPropertyDescriptor(e._browserRequest,a);b&&(b.writable||b.set)?Object.defineProperty(e,a,{get:function(){return e._browserRequest[a]},set:function(b){e._browserRequest[a]=b},enumerable:!0}):Object.defineProperty(e,a,{get:function(){return e._browserRequest[a]},enumerable:!0})}(f);var g=this.headers.get("Content-Type");null!=g&&g.indexOf("boundary=")>-1&&g.indexOf("form-data")>-1&&(g=g.split("boundary="),this._boundary="--"+g[g.length-1]),this.arrayBuffer=function(){try{return this._init&&this._init.body&&this._init.body instanceof FormData?s(this._init.body,this._boundary).then(function(a){return q(a)}):this._browserRequest.arrayBuffer()}catch(a){return Promise.reject(a)}},this.blob=function(){try{return this._init&&this._init.body&&this._init.body instanceof FormData?s(this._init.body,this._boundary).then(function(a){return new Blob([a],{type:this.headers.get("Content-Type")})}):this._browserRequest.blob()}catch(a){return Promise.reject(a)}},this.formData=function(){try{return this._init&&this._init.body&&this._init.body instanceof FormData?Promise.resolve(this._init.body):this._browserRequest.formData()}catch(a){return Promise.reject(a)}},this.json=function(){try{return this._init&&this._init.body&&this._init.body instanceof FormData?Promise.reject(new SyntaxError("Unexpected number in JSON at position 1")):this._browserRequest.json()}catch(a){return Promise.reject(a)}},this.text=function(){try{return this._init&&this._init.body&&this._init.body instanceof FormData?s(this._init.body,this._boundary):this._browserRequest.text()}catch(a){return Promise.reject(a)}},this.clone=function(){this.headers&&this._init&&this._init.body&&this._init.body instanceof FormData&&(this._init.headers=this.headers);var a=new b(this._input,this._init);return a._browserRequest=this._browserRequest.clone(),a}}return b}function o(a){function b(a){Object.defineProperty(this,"isReload",{value:!1,enumerable:!0}),Object.defineProperty(this,"clientId",{value:null,enumerable:!0}),Object.defineProperty(this,"client",{value:null,enumerable:!0}),Object.defineProperty(this,"request",{value:a,enumerable:!0}),Object.defineProperty(this,"_resolveCallback",{value:null,writable:!0}),Object.defineProperty(this,"_rejectCallback",{value:null,writable:!0})}return b.prototype.respondWith=function(a){var b=this;if(a instanceof Promise)a.then(function(a){b._resolveCallback(a)},function(a){b._rejectCallback(a)});else if("function"==typeof a){var c=a();b._resolveCallback(c)}},b.prototype._setPromiseCallbacks=function(a,b){this._resolveCallback=a,this._rejectCallback=b},function(b,c){var d;return d=Request.prototype.isPrototypeOf(b)&&!c?b:new Request(b,c),d._browserRequest&&(d=d._browserRequest),new Promise(function(b,c){a._browserFetchFunc.call(self,d).then(function(a){b(a)},function(a){c(a)})})}}function p(){var a=/^((?!chrome|android).)*safari/i.test(navigator.userAgent),b=/\((iPad|iPhone)/i.test(navigator.userAgent);return a||b}function q(a){return(new TextEncoder).encode(a).buffer}function r(a,b,c){return new Promise(function(d,e){var f;switch(a.constructor.name){case"File":var g=new FileReader;g.onload=function(e){f='\r\nContent-Disposition: form-data; name="'+b.toString()+'"; filename="'+a.name+'"\r\nContent-Type: '+a.type+"\r\n\r\n"+e.target.result+"\r\n"+c,d(f)},g.onerror=function(){g.abort(),e(new DOMException("Problem parsing input file."))},g.readAsText(a);break;case"String":f='\r\nContent-Disposition: form-data; name="'+b+'"\r\n\r\n'+a+"\r\n"+c,d(f);break;default:f='\r\nContent-Disposition: form-data; name="'+b.toString()+'"\r\n\r\n'+a.toString()+"\r\n"+c,d(f)}})}function s(a,b){return new Promise(function(c,d){var e=[],f=b;a.forEach(function(a,c){e.push(r(a,c,b))}),Promise.all(e).then(function(a){a.forEach(function(a){f+=a}),f+="--",c(f)}).catch(function(a){d(a)})})}return e.prototype.init=function(){return j(this),f(this),i(this),Promise.resolve()},e.prototype.forceOffline=function(a){d.log("Offline Persistence Toolkit PersistenceManager: forceOffline is called with value: "+a),this._forceOffline=a},e.prototype.getCache=function(){return this._cache},e.prototype.isOnline=function(){var a=navigator.onLine;return navigator.network&&navigator.network.connection&&navigator.network.connection.type==Connection.NONE&&(a=!1,d.log("Offline Persistence Toolkit PersistenceManager: Cordova network info plugin is returning online value: "+a)),a&&!this._isOffline&&!this._forceOffline},e.prototype.register=function(a){a=a||{};var b=new l(a.scope,this);return this._registrations.push(b),Promise.resolve(b)},e.prototype.getRegistration=function(a){var b,c,d=this._registrations.length;for(b=0;b<d;b++)if(c=this._registrations[b],a.match(c.scope))return Promise.resolve(c);return Promise.resolve()},e.prototype.getRegistrations=function(){return Promise.resolve(this._registrations.slice())},e.prototype.getSyncManager=function(){return this._persistenceSyncManager},e.prototype.browserFetch=function(a){var b=this;return d.log("Offline Persistence Toolkit PersistenceManager: browserFetch() for Request with url: "+a.url),g()?(Object.defineProperty(this,"_browserFetchRequest",{value:a,writable:!0}),new Promise(function(c,e){d.log("Offline Persistence Toolkit PersistenceManager: Calling browser fetch function for Request with url: "+a.url),a._browserRequest&&(a=a._browserRequest),b._browserFetchFunc.call(window,a).then(function(a){c(a)},function(a){e(a)}),b._browserFetchRequest=null})):(a._browserRequest&&(a=a._browserRequest),fetch(a))},l.prototype.addEventListener=function(a,b){this._eventListeners.push({type:a.toLowerCase(),listener:b})},l.prototype.unregister=function(){return Promise.resolve(k(this._persistenceManager,this))},new e});
define(["./impl/PersistenceXMLHttpRequest","./impl/PersistenceSyncManager","./impl/offlineCacheManager","./impl/logger","./impl/fetch"],function(a,b,c,d){"use strict";function e(){Object.defineProperty(this,"_registrations",{value:[],writable:!0}),Object.defineProperty(this,"_eventListeners",{value:[],writable:!0}),Object.defineProperty(this,"_forceOffline",{value:!1,writable:!0}),Object.defineProperty(this,"_isOffline",{value:!1,writable:!0}),Object.defineProperty(this,"_cache",{value:null,writable:!0}),Object.defineProperty(this,"_persistenceSyncManager",{value:new b(this.isOnline.bind(this),this.browserFetch.bind(this),this.getCache.bind(this))})}function f(a){var b=a;g()&&!b._addedBrowserEventListeners&&(d.log("Offline Persistence Toolkit PersistenceManager: Adding browser event listeners"),window.addEventListener("offline",function(a){b._isOffline=!0},!1),window.addEventListener("online",function(a){b._isOffline=!1},!1),b._addedBrowserEventListeners=!0)}function g(){return"undefined"!=typeof window&&null!=window}function h(a,b,c){var e,f,g,h,i=null,j=a._registrations,k=null!=j?j.length:0;for(e=0;e<k;e++)if(g=j[e],null!=c.request.url.match(g.scope)){for(h=g._eventListeners.length,f=0;f<h;f++)if(g._eventListeners[f].type==b)if("fetch"==b)null===i&&c._setPromiseCallbacks instanceof Function&&(i=new Promise(function(a,b){c._setPromiseCallbacks(a,b)})),d.log("Offline Persistence Toolkit PersistenceManager: Calling fetch event listener"),g._eventListeners[f].listener(c);else if(d.log("Offline Persistence Toolkit PersistenceManager: Calling event listener"),!1===g._eventListeners[f].listener(c))return!1;if(null!=i)return i}return!0}function i(a){a._cache=c.open("systemCache")}function j(b){p()&&(d.log("Offline Persistence Toolkit PersistenceManager: Replacing Safari Browser APIs"),Object.defineProperty(b,"_browserRequestConstructor",{value:self.Request,writable:!1}),Object.defineProperty(b,"_persistenceRequestConstructor",{value:n(b),writable:!1}),self.Request=b._persistenceRequestConstructor,g()||(Object.defineProperty(b,"_browserFetchFunc",{value:self.fetch,writable:!1}),self.fetch=o(b))),!g()||b._browserFetchFunc||b._browserXMLHttpRequest||(d.log("Offline Persistence Toolkit PersistenceManager: Replacing browser APIs"),Object.defineProperty(b,"_browserFetchFunc",{value:window.fetch,writable:!1}),Object.defineProperty(b,"_browserXMLHttpRequest",{value:window.XMLHttpRequest,writable:!1}),window.fetch=m(b),window.XMLHttpRequest=function(){return null!=b._browserFetchRequest?new b._browserXMLHttpRequest:new a(b._browserXMLHttpRequest)})}function k(a,b){var c=a,d=c._registrations.indexOf(b);return d>-1&&(c._registrations.splice(d,1),!0)}function l(a,b){Object.defineProperty(this,"scope",{value:a,enumerable:!0}),Object.defineProperty(this,"_persistenceManager",{value:b}),Object.defineProperty(this,"_eventListeners",{value:[],writable:!0})}function m(a){function b(a){Object.defineProperty(this,"isReload",{value:!1,enumerable:!0}),Object.defineProperty(this,"clientId",{value:null,enumerable:!0}),Object.defineProperty(this,"client",{value:null,enumerable:!0}),Object.defineProperty(this,"request",{value:a,enumerable:!0}),Object.defineProperty(this,"_resolveCallback",{value:null,writable:!0}),Object.defineProperty(this,"_rejectCallback",{value:null,writable:!0})}return b.prototype.respondWith=function(a){var b=this;if(a instanceof Promise)a.then(function(a){b._resolveCallback(a)},function(a){b._rejectCallback(a)});else if("function"==typeof a){var c=a();b._resolveCallback(c)}},b.prototype._setPromiseCallbacks=function(a,b){this._resolveCallback=a,this._rejectCallback=b},function(c,d){var e;return e=Request.prototype.isPrototypeOf(c)&&!d?c:new Request(c,d),a.getRegistration(e.url).then(function(c){if(null!=c){var d=new b(e),f=h(a,"fetch",d);if(null!=f&&f instanceof Promise)return f}return a.browserFetch(e)})}}function n(a){function b(c,e){var f=this,g=c,h=e;if(d.log("Offline Persistence Toolkit persistenceRequest: Create New Request"),c._input){d.log("Offline Persistence Toolkit persistenceRequest: Input is a PersistenceRequest"),g=c._input,h=Object.assign({},c._init);for(var i in e)e.hasOwnProperty(i)&&(h[i]=e[i]);if(c.headers&&h&&h.body&&h.body instanceof FormData)if(h.headers){var j=c.headers.get("Content-Type");h.headers.set("Content-Type",j)}else h.headers=c.headers}this._browserRequest=new a._browserRequestConstructor(g,h),this._input=g,this._init=h;var k;for(k in this._browserRequest)"body"!=k&&"function"==typeof this._browserRequest[k]||function(a){var b=Object.getOwnPropertyDescriptor(f._browserRequest,a);b&&(b.writable||b.set)?Object.defineProperty(f,a,{get:function(){return f._browserRequest[a]},set:function(b){f._browserRequest[a]=b},enumerable:!0}):Object.defineProperty(f,a,{get:function(){return f._browserRequest[a]},enumerable:!0})}(k);var l=this.headers.get("Content-Type");null!=l&&l.indexOf("boundary=")>-1&&l.indexOf("form-data")>-1&&(l=l.split("boundary="),this._boundary="--"+l[l.length-1]),this.arrayBuffer=function(){d.log("Offline Persistence Toolkit persistenceRequest: Called arrayBuffer()");var a=this;try{return a._init&&a._init.body&&a._init.body instanceof FormData?s(a._init.body,a._boundary).then(function(a){return q(a)}):a._browserRequest.arrayBuffer()}catch(a){return Promise.reject(a)}},this.blob=function(){d.log("Offline Persistence Toolkit persistenceRequest: Called blob()");var a=this;try{return a._init&&a._init.body&&a._init.body instanceof FormData?s(a._init.body,a._boundary).then(function(b){return new Blob([b],{type:a.headers.get("Content-Type")})}):a._browserRequest.blob()}catch(a){return Promise.reject(a)}},this.formData=function(){d.log("Offline Persistence Toolkit persistenceRequest: Called formData()");var a=this;try{return a._init&&a._init.body&&a._init.body instanceof FormData?Promise.resolve(a._init.body):a._browserRequest.formData()}catch(a){return Promise.reject(a)}},this.json=function(){d.log("Offline Persistence Toolkit persistenceRequest: Called json()");var a=this;try{return a._init&&a._init.body&&a._init.body instanceof FormData?Promise.reject(new SyntaxError("Unexpected number in JSON at position 1")):a._browserRequest.json()}catch(a){return Promise.reject(a)}},this.text=function(){d.log("Offline Persistence Toolkit persistenceRequest: Called text()");var a=this;try{return a._init&&a._init.body&&a._init.body instanceof FormData?s(a._init.body,a._boundary):a._browserRequest.text()}catch(a){return Promise.reject(a)}},this.clone=function(){d.log("Offline Persistence Toolkit persistenceRequest: Called clone()");var a=this;a.headers&&a._init&&a._init.body&&a._init.body instanceof FormData&&(a._init.headers=a.headers);var c=new b(a._input,a._init);return c._browserRequest=a._browserRequest.clone(),c},this.toString=function(){return d.log("Offline Persistence Toolkit persistenceRequest:requestToString()"),this._input.url?this._input.url:this._input}}return b}function o(a){function b(a){Object.defineProperty(this,"isReload",{value:!1,enumerable:!0}),Object.defineProperty(this,"clientId",{value:null,enumerable:!0}),Object.defineProperty(this,"client",{value:null,enumerable:!0}),Object.defineProperty(this,"request",{value:a,enumerable:!0}),Object.defineProperty(this,"_resolveCallback",{value:null,writable:!0}),Object.defineProperty(this,"_rejectCallback",{value:null,writable:!0})}return b.prototype.respondWith=function(a){var b=this;if(a instanceof Promise)a.then(function(a){b._resolveCallback(a)},function(a){b._rejectCallback(a)});else if("function"==typeof a){var c=a();b._resolveCallback(c)}},b.prototype._setPromiseCallbacks=function(a,b){this._resolveCallback=a,this._rejectCallback=b},function(b,c){var e;return e=Request.prototype.isPrototypeOf(b)&&!c?b:new Request(b,c),d.log("Offline Persistence Toolkit serviceWorkerFetch:"+e.url),e._browserRequest&&(e=e._browserRequest),new Promise(function(b,c){a._browserFetchFunc.call(self,e).then(function(a){b(a)},function(a){c(a)})})}}function p(){var a=/^((?!chrome|android).)*safari/i.test(navigator.userAgent),b=/\((iPad|iPhone)/i.test(navigator.userAgent);return a||b}function q(a){return(new TextEncoder).encode(a).buffer}function r(a,b,c){return new Promise(function(d,e){var f;switch(a.constructor.name){case"File":var g=new FileReader;g.onload=function(e){f='\r\nContent-Disposition: form-data; name="'+b.toString()+'"; filename="'+a.name+'"\r\nContent-Type: '+a.type+"\r\n\r\n"+e.target.result+"\r\n"+c,d(f)},g.onerror=function(){g.abort(),e(new DOMException("Problem parsing input file."))},g.readAsText(a);break;case"String":f='\r\nContent-Disposition: form-data; name="'+b+'"\r\n\r\n'+a+"\r\n"+c,d(f);break;default:f='\r\nContent-Disposition: form-data; name="'+b.toString()+'"\r\n\r\n'+a.toString()+"\r\n"+c,d(f)}})}function s(a,b){return new Promise(function(c,d){var e=[],f=b;a.forEach(function(a,c){e.push(r(a,c,b))}),Promise.all(e).then(function(a){a.forEach(function(a){f+=a}),f+="--",c(f)}).catch(function(a){d(a)})})}return e.prototype.init=function(){return d.log("Offline Persistence Toolkit PersistenceManager: Initilizing"),j(this),f(this),i(this),Promise.resolve()},e.prototype.forceOffline=function(a){d.log("Offline Persistence Toolkit PersistenceManager: forceOffline is called with value: "+a),this._forceOffline=a},e.prototype.getCache=function(){return this._cache},e.prototype.isOnline=function(){var a=navigator.onLine;return navigator.network&&navigator.network.connection&&navigator.network.connection.type==Connection.NONE&&(a=!1,d.log("Offline Persistence Toolkit PersistenceManager: Cordova network info plugin is returning online value: "+a)),a&&!this._isOffline&&!this._forceOffline},e.prototype.register=function(a){a=a||{};var b=new l(a.scope,this);return this._registrations.push(b),Promise.resolve(b)},e.prototype.getRegistration=function(a){var b,c,d=this._registrations.length;for(b=0;b<d;b++)if(c=this._registrations[b],a.match(c.scope))return Promise.resolve(c);return Promise.resolve()},e.prototype.getRegistrations=function(){return Promise.resolve(this._registrations.slice())},e.prototype.getSyncManager=function(){return this._persistenceSyncManager},e.prototype.browserFetch=function(a){var b=this;d.log("Offline Persistence Toolkit PersistenceManager: browserFetch() for Request with url: "+a.url);var c=a;return g()?(Object.defineProperty(this,"_browserFetchRequest",{value:a,writable:!0}),new Promise(function(e,f){d.log("Offline Persistence Toolkit PersistenceManager: Calling browser fetch function for Request with url: "+a.url),a._browserRequest&&(c=a._browserRequest),b._browserFetchFunc.call(window,c).then(function(a){e(a)},function(a){f(a)}),b._browserFetchRequest=null})):(a._browserRequest&&(c=a._browserRequest),fetch(c))},l.prototype.addEventListener=function(a,b){this._eventListeners.push({type:a.toLowerCase(),listener:b})},l.prototype.unregister=function(){return Promise.resolve(k(this._persistenceManager,this))},new e});
{
"name": "@oracle/offline-persistence-toolkit",
"title": "Offline Persistence Toolkit",
"version": "1.4.7",
"version": "1.4.8",
"description": "Offline Persistence Toolkit by Oracle Corp.",

@@ -6,0 +6,0 @@ "author": "oraclejet",

@@ -1,2 +0,2 @@

# offline-persistence-toolkit 1.4.7 #
# offline-persistence-toolkit 1.4.8 #

@@ -61,3 +61,3 @@ offline-persistence-toolkit is a client-side JavaScript library that provides caching and offline support at the HTTP request layer. This support is transparent to the user and is done through the Fetch API and an XHR adapter. HTTP requests made while the client device is offline are captured for replay when connection to the server is restored. Additional capabilities include a persistent storage layer, synchronization manager, binary data support and various configuration APIs for customizing the default behavior. This framework can be used in both ServiceWorker and non-ServiceWorker contexts within web and hybrid mobile apps.

paths: {
'persist' : 'js/libs/persist/v1.4.7/min'
'persist' : 'js/libs/persist/v1.4.8/min'

@@ -67,7 +67,7 @@ // Other path mappings here

```
For Oracle JET apps, also open `appDir/src/js/main-release-paths.json` and add the `'persist' : 'js/libs/persist/v1.4.7/min'` entry to the list of paths.
For Oracle JET apps, also open `appDir/src/js/main-release-paths.json` and add the `'persist' : 'js/libs/persist/v1.4.8/min'` entry to the list of paths.
You can choose the name of the paths prefix. That is, you can use a different value to the ‘persist’ value shown in the examples.
It is recommended to add the version number as a convention in your application build step such as `'persist' : 'js/libs/persist/v1.4.7/min'`.
It is recommended to add the version number as a convention in your application build step such as `'persist' : 'js/libs/persist/v1.4.8/min'`.

@@ -96,3 +96,3 @@ Versions of the toolkit are also available on CDN under the latest JET release. e.g.

'pouchfind': 'js/libs/pouchdb.find',
'persist' : 'js/libs/persist/v1.4.7/min'
'persist' : 'js/libs/persist/v1.4.8/min'

@@ -99,0 +99,0 @@ // Other path mappings here

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc