Skip to content

Commit 9e6c7b8

Browse files
Fixed bug in binary data handling
1 parent 8145ee5 commit 9e6c7b8

File tree

9 files changed

+263
-30
lines changed

9 files changed

+263
-30
lines changed

JSDOC.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# offline-persistence-toolkit 1.2.5 #
1+
# offline-persistence-toolkit 1.2.6 #
22

33
## Introduction ##
44

README.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# offline-persistence-toolkit 1.2.5 #
1+
# offline-persistence-toolkit 1.2.6 #
22

33
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.
44

@@ -58,28 +58,28 @@ If your app uses [RequireJS](http://www.requirejs.org/ "RequireJS"), update the
5858
```javascript
5959
requirejs.config({
6060
paths: {
61-
'persist' : 'js/libs/persist/v1.2.5/min'
61+
'persist' : 'js/libs/persist/v1.2.6/min'
6262

6363
// Other path mappings here
6464
}
6565
```
66-
For Oracle JET apps, also open `appDir/src/js/main-release-paths.json` and add the `'persist' : 'js/libs/persist/v1.2.5/min'` entry to the list of paths.
66+
For Oracle JET apps, also open `appDir/src/js/main-release-paths.json` and add the `'persist' : 'js/libs/persist/v1.2.6/min'` entry to the list of paths.
6767
6868
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.
6969
70-
It is recommended to add the version number as a convention in your application build step such as `'persist' : 'js/libs/persist/v1.2.5/min'`.
70+
It is recommended to add the version number as a convention in your application build step such as `'persist' : 'js/libs/persist/v1.2.6/min'`.
7171
7272
Versions of the toolkit are also available on CDN under the latest JET release. e.g.
7373
74-
https://static.oracle.com/cdn/jet/v5.1.0/3rdparty/opt/debug
74+
https://static.oracle.com/cdn/jet/v6.2.0/3rdparty/opt/debug
7575
7676
or
7777
78-
https://static.oracle.com/cdn/jet/v5.1.0/3rdparty/opt/min
78+
https://static.oracle.com/cdn/jet/v6.2.0/3rdparty/opt/min
7979
8080
The toolkit makes heavy use of the [Promise API](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise "Promise API"). If you are targeting environments that do not support the Promise API, you will need to polyfill this feature. We recommend the [es6-promise polyfill](https://github.com/stefanpenner/es6-promise "es6-promise polyfill").
8181
82-
The toolkit does not have a dependency on a specific client-side storage solution, but does include a PouchDB adapter. If you plan to use PouchDB for your persistent store, you will need to install the following PouchDB packages (This version of the toolkit is certified with version 6.3.4 of pouchdb and requires apps to use this version):
82+
The toolkit does not have a dependency on a specific client-side storage solution, but does include a PouchDB adapter. If you plan to use PouchDB for your persistent store, you will need to install the following PouchDB packages (This version of the toolkit is certified with version 7.0.0 of pouchdb and requires apps to use this version):
8383
8484
npm install pouchdb pouchdb-find
8585
@@ -89,9 +89,9 @@ And again, if you are using RequireJS, you will need to map paths for these pack
8989

9090
requirejs.config({
9191
paths: {
92-
'pouchdb': 'js/libs/pouchdb-6.3.4',
92+
'pouchdb': 'js/libs/pouchdb-7.0.0',
9393
'pouchfind': 'js/libs/pouchdb.find',
94-
'persist' : 'js/libs/persist/v1.2.5/min'
94+
'persist' : 'js/libs/persist/v1.2.6/min'
9595

9696
// Other path mappings here
9797
}

USAGE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# offline-persistence-toolkit 1.2.5 #
1+
# offline-persistence-toolkit 1.2.6 #
22

33
# Introduction #
44

docs/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ <h3> </h3>
4343

4444

4545
<section>
46-
<article><h1>offline-persistence-toolkit 1.2.5</h1><h2>Introduction</h2><p>This document provides a reference to the offline-persistence-toolkit's JavaScript API. Links to JSDoc for each class can be found to the right.</p>
46+
<article><h1>offline-persistence-toolkit 1.2.6</h1><h2>Introduction</h2><p>This document provides a reference to the offline-persistence-toolkit's JavaScript API. Links to JSDoc for each class can be found to the right.</p>
4747
<p>The toolkit's <a href="https://github.com/oracle/offline-persistence-toolkit/" title="README">README</a> file provides an overview of the toolkit’s capabilities. Having read that document, you can find more information about how to implement a range of common and advanced use cases with the toolkit in the
4848
<a href="https://github.com/oracle/offline-persistence-toolkit/blob/master/USAGE.md" title="Usage guide">Usage guide</a>.</p>
4949
<h2>License</h2><p>Copyright (c) 2017 Oracle and/or its affiliates The Universal Permissive License (UPL), Version 1.0.</p></article>

docs/persistenceUtils.html

Lines changed: 187 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ <h5>Parameters:</h5>
238238

239239
<dt class="tag-source">Source:</dt>
240240
<dd class="tag-source"><ul class="dummy"><li>
241-
<a href="persistenceUtils.js.html">persistenceUtils.js</a>, <a href="persistenceUtils.js.html#line465">line 465</a>
241+
<a href="persistenceUtils.js.html">persistenceUtils.js</a>, <a href="persistenceUtils.js.html#line493">line 493</a>
242242
</li></ul></dd>
243243

244244

@@ -294,6 +294,186 @@ <h5>Returns:</h5>
294294

295295

296296

297+
<h4 class="name" id=".derivePayloadType"><span class="type-signature">(static) </span>derivePayloadType<span class="signature">(xhr, response)</span><span class="type-signature"> &rarr; {string}</span></h4>
298+
299+
300+
301+
302+
303+
304+
<div class="description">
305+
Derive the payload body type based on content-type from responseheader and responseType from request.
306+
</div>
307+
308+
309+
310+
311+
312+
313+
314+
315+
316+
<h5>Parameters:</h5>
317+
318+
319+
<table class="params">
320+
<thead>
321+
<tr>
322+
323+
<th>Name</th>
324+
325+
326+
<th>Type</th>
327+
328+
329+
330+
331+
332+
<th class="last">Description</th>
333+
</tr>
334+
</thead>
335+
336+
<tbody>
337+
338+
339+
<tr>
340+
341+
<td class="name"><code>xhr</code></td>
342+
343+
344+
<td class="type">
345+
346+
347+
<span class="param-type">XMLHttpRequest</span>
348+
349+
350+
351+
</td>
352+
353+
354+
355+
356+
357+
<td class="description last">request object</td>
358+
</tr>
359+
360+
361+
362+
<tr>
363+
364+
<td class="name"><code>response</code></td>
365+
366+
367+
<td class="type">
368+
369+
370+
<span class="param-type">Response</span>
371+
372+
373+
374+
</td>
375+
376+
377+
378+
379+
380+
<td class="description last">Response object</td>
381+
</tr>
382+
383+
384+
</tbody>
385+
</table>
386+
387+
388+
389+
390+
391+
392+
<dl class="details">
393+
394+
395+
396+
397+
398+
399+
400+
401+
402+
403+
404+
405+
406+
407+
408+
409+
410+
411+
412+
413+
414+
415+
416+
417+
418+
419+
<dt class="tag-source">Source:</dt>
420+
<dd class="tag-source"><ul class="dummy"><li>
421+
<a href="persistenceUtils.js.html">persistenceUtils.js</a>, <a href="persistenceUtils.js.html#line43">line 43</a>
422+
</li></ul></dd>
423+
424+
425+
426+
427+
428+
429+
430+
</dl>
431+
432+
433+
434+
435+
436+
437+
438+
439+
440+
441+
442+
443+
444+
<h5>Returns:</h5>
445+
446+
447+
<div class="param-desc">
448+
Returns payload body type, possible values are: text, blob, arraybuffer, multipart
449+
</div>
450+
451+
452+
453+
<dl>
454+
<dt>
455+
Type
456+
</dt>
457+
<dd>
458+
459+
<span class="param-type">string</span>
460+
461+
462+
</dd>
463+
</dl>
464+
465+
466+
467+
468+
469+
470+
471+
472+
473+
474+
475+
476+
297477
<h4 class="name" id=".isCachedResponse"><span class="type-signature">(static) </span>isCachedResponse<span class="signature">(response)</span><span class="type-signature"> &rarr; {boolean}</span></h4>
298478

299479

@@ -732,7 +912,7 @@ <h5>Parameters:</h5>
732912

733913
<dt class="tag-source">Source:</dt>
734914
<dd class="tag-source"><ul class="dummy"><li>
735-
<a href="persistenceUtils.js.html">persistenceUtils.js</a>, <a href="persistenceUtils.js.html#line364">line 364</a>
915+
<a href="persistenceUtils.js.html">persistenceUtils.js</a>, <a href="persistenceUtils.js.html#line392">line 392</a>
736916
</li></ul></dd>
737917

738918

@@ -889,7 +1069,7 @@ <h5>Parameters:</h5>
8891069

8901070
<dt class="tag-source">Source:</dt>
8911071
<dd class="tag-source"><ul class="dummy"><li>
892-
<a href="persistenceUtils.js.html">persistenceUtils.js</a>, <a href="persistenceUtils.js.html#line238">line 238</a>
1072+
<a href="persistenceUtils.js.html">persistenceUtils.js</a>, <a href="persistenceUtils.js.html#line266">line 266</a>
8931073
</li></ul></dd>
8941074

8951075

@@ -1046,7 +1226,7 @@ <h5>Parameters:</h5>
10461226

10471227
<dt class="tag-source">Source:</dt>
10481228
<dd class="tag-source"><ul class="dummy"><li>
1049-
<a href="persistenceUtils.js.html">persistenceUtils.js</a>, <a href="persistenceUtils.js.html#line65">line 65</a>
1229+
<a href="persistenceUtils.js.html">persistenceUtils.js</a>, <a href="persistenceUtils.js.html#line93">line 93</a>
10501230
</li></ul></dd>
10511231

10521232

@@ -1203,7 +1383,7 @@ <h5>Parameters:</h5>
12031383

12041384
<dt class="tag-source">Source:</dt>
12051385
<dd class="tag-source"><ul class="dummy"><li>
1206-
<a href="persistenceUtils.js.html">persistenceUtils.js</a>, <a href="persistenceUtils.js.html#line295">line 295</a>
1386+
<a href="persistenceUtils.js.html">persistenceUtils.js</a>, <a href="persistenceUtils.js.html#line323">line 323</a>
12071387
</li></ul></dd>
12081388

12091389

@@ -1403,7 +1583,7 @@ <h5>Parameters:</h5>
14031583

14041584
<dt class="tag-source">Source:</dt>
14051585
<dd class="tag-source"><ul class="dummy"><li>
1406-
<a href="persistenceUtils.js.html">persistenceUtils.js</a>, <a href="persistenceUtils.js.html#line209">line 209</a>
1586+
<a href="persistenceUtils.js.html">persistenceUtils.js</a>, <a href="persistenceUtils.js.html#line237">line 237</a>
14071587
</li></ul></dd>
14081588

14091589

@@ -1583,7 +1763,7 @@ <h5>Parameters:</h5>
15831763

15841764
<dt class="tag-source">Source:</dt>
15851765
<dd class="tag-source"><ul class="dummy"><li>
1586-
<a href="persistenceUtils.js.html">persistenceUtils.js</a>, <a href="persistenceUtils.js.html#line333">line 333</a>
1766+
<a href="persistenceUtils.js.html">persistenceUtils.js</a>, <a href="persistenceUtils.js.html#line361">line 361</a>
15871767
</li></ul></dd>
15881768

15891769

docs/persistenceUtils.js.html

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,34 @@ <h1 class="page-title">Source: persistenceUtils.js</h1>
6868
return response.headers.has('x-oracle-jscpt-etag-generated');
6969
};
7070

71+
/**
72+
* Derive the payload body type based on content-type from response
73+
* header and responseType from request.
74+
* @method
75+
* @name derivePayloadType
76+
* @memberof persistenceUtils
77+
* @static
78+
* @param {XMLHttpRequest} xhr request object
79+
* @param {Response} response Response object
80+
* @return {string} Returns payload body type, possible values are:
81+
* text, blob, arraybuffer, multipart
82+
*/
83+
function derivePayloadType(xhr, response) {
84+
var contentType = response.headers.get('Content-Type');
85+
var responseType = xhr.responseType;
86+
if (_isTextPayload(response.headers)) {
87+
return "text";
88+
} else if (isCachedResponse(response) || responseType === 'blob') {
89+
return "blob";
90+
} else if (contentType.indexOf('image/') !== -1 || responseType === 'arraybuffer') {
91+
return "arraybuffer";
92+
} else if (contentType.indexOf('multipart/form-data') !== -1) {
93+
return "multipart";
94+
} else {
95+
return "text";
96+
}
97+
}
98+
7199
function _isTextPayload(headers) {
72100

73101
var contentType = headers.get('Content-Type');
@@ -557,6 +585,7 @@ <h1 class="page-title">Source: persistenceUtils.js</h1>
557585
buildEndpointKey: buildEndpointKey,
558586
_cloneRequest: _cloneRequest,
559587
_cloneResponse: _cloneResponse,
588+
derivePayloadType: derivePayloadType
560589
};
561590
});
562591

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@oracle/offline-persistence-toolkit",
33
"title": "Offline Persistence Toolkit",
4-
"version": "1.2.5",
4+
"version": "1.2.6",
55
"description": "Offline Persistence Toolkit by Oracle Corp.",
66
"author": "oraclejet",
77
"license": "UPL-1.0",

0 commit comments

Comments
 (0)