unpoly-rails 2.7.2.1 → 2.7.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/assets/unpoly/unpoly.es6.js +270 -151
- data/lib/unpoly/rails/request_echo_headers.rb +6 -2
- data/lib/unpoly/rails/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 78ae8255389adf6764d3bb943b4b3f1e5a5d8a31bc7f2ad01799ba683be9ea56
|
4
|
+
data.tar.gz: b5c00aa016a7a178d855018db1491fa32b45316bd64457704657bf7ad2c98e59
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 30506f67b5ea32e55f66fa3a749e1aaeee0a5fbb5eb62064044288b20da573197f79aa79e6cd4a3bc542c5d9b6c0f948b57a18cc5c004cdce1fdd08b347b7109
|
7
|
+
data.tar.gz: 797a38f17df02e60213e95d68657f3f838c27a62a962eb6787d13770c38ddbd4e66018a53c62b0fc9db27a0faa6524ede38b54d1d2b306ee86899eaaf40877e7
|
data/assets/unpoly/unpoly.es6.js
CHANGED
@@ -111,15 +111,15 @@ up.util = (function () {
|
|
111
111
|
return block;
|
112
112
|
}
|
113
113
|
}
|
114
|
-
function map(
|
115
|
-
if (
|
114
|
+
function map(list, block) {
|
115
|
+
if (list.length === 0) {
|
116
116
|
return [];
|
117
117
|
}
|
118
118
|
block = iteratee(block);
|
119
119
|
let mapped = [];
|
120
|
-
|
121
|
-
|
122
|
-
mapped.push(block(
|
120
|
+
let i = 0;
|
121
|
+
for (let item of list) {
|
122
|
+
mapped.push(block(item, i++));
|
123
123
|
}
|
124
124
|
return mapped;
|
125
125
|
}
|
@@ -131,8 +131,9 @@ up.util = (function () {
|
|
131
131
|
return map(array, pairer).reduce(merger, {});
|
132
132
|
}
|
133
133
|
function each(array, block) {
|
134
|
-
|
135
|
-
|
134
|
+
let i = 0;
|
135
|
+
for (let item of array) {
|
136
|
+
block(item, i++);
|
136
137
|
}
|
137
138
|
}
|
138
139
|
function isNull(object) {
|
@@ -309,10 +310,11 @@ up.util = (function () {
|
|
309
310
|
function some(list, tester) {
|
310
311
|
return !!findResult(list, tester);
|
311
312
|
}
|
312
|
-
function findResult(
|
313
|
+
function findResult(list, tester) {
|
313
314
|
tester = iteratee(tester);
|
314
|
-
|
315
|
-
|
315
|
+
let i = 0;
|
316
|
+
for (let item of list) {
|
317
|
+
const result = tester(item, i++);
|
316
318
|
if (result) {
|
317
319
|
return result;
|
318
320
|
}
|
@@ -321,8 +323,9 @@ up.util = (function () {
|
|
321
323
|
function every(list, tester) {
|
322
324
|
tester = iteratee(tester);
|
323
325
|
let match = true;
|
324
|
-
|
325
|
-
|
326
|
+
let i = 0;
|
327
|
+
for (let item of list) {
|
328
|
+
if (!tester(item, i++)) {
|
326
329
|
match = false;
|
327
330
|
break;
|
328
331
|
}
|
@@ -706,6 +709,14 @@ up.util = (function () {
|
|
706
709
|
};
|
707
710
|
}
|
708
711
|
}
|
712
|
+
function safeStringifyJSON(value) {
|
713
|
+
let json = JSON.stringify(value);
|
714
|
+
return escapeHighASCII(json);
|
715
|
+
}
|
716
|
+
function escapeHighASCII(string) {
|
717
|
+
let unicodeEscape = (char) => "\\u" + char.charCodeAt(0).toString(16).padStart(4, '0');
|
718
|
+
return string.replace(/[^\x00-\x7F]/g, unicodeEscape);
|
719
|
+
}
|
709
720
|
return {
|
710
721
|
parseURL,
|
711
722
|
normalizeURL,
|
@@ -801,7 +812,8 @@ up.util = (function () {
|
|
801
812
|
sprintf,
|
802
813
|
renameKeys,
|
803
814
|
negate,
|
804
|
-
memoizeMethod
|
815
|
+
memoizeMethod,
|
816
|
+
safeStringifyJSON,
|
805
817
|
};
|
806
818
|
})();
|
807
819
|
|
@@ -1162,9 +1174,17 @@ up.element = (function () {
|
|
1162
1174
|
klass = klass.replace(/:/g, '\\:');
|
1163
1175
|
return `.${klass}`;
|
1164
1176
|
}
|
1165
|
-
function
|
1177
|
+
function createBrokenDocumentFromHTML(html) {
|
1166
1178
|
return new DOMParser().parseFromString(html, 'text/html');
|
1167
1179
|
}
|
1180
|
+
function fixScriptish(scriptish) {
|
1181
|
+
let clone = document.createElement(scriptish.tagName);
|
1182
|
+
for (let { name, value } of scriptish.attributes) {
|
1183
|
+
clone.setAttribute(name, value);
|
1184
|
+
}
|
1185
|
+
clone.textContent = scriptish.innerHTML;
|
1186
|
+
scriptish.replaceWith(clone);
|
1187
|
+
}
|
1168
1188
|
function createFromHTML(html) {
|
1169
1189
|
const range = document.createRange();
|
1170
1190
|
range.setStart(document.body, 0);
|
@@ -1427,7 +1447,8 @@ up.element = (function () {
|
|
1427
1447
|
isSingleton,
|
1428
1448
|
attrSelector,
|
1429
1449
|
tagName: elementTagName,
|
1430
|
-
|
1450
|
+
createBrokenDocumentFromHTML,
|
1451
|
+
fixScriptish,
|
1431
1452
|
createFromHTML,
|
1432
1453
|
get root() { return getRoot(); },
|
1433
1454
|
paint,
|
@@ -4161,44 +4182,6 @@ up.FragmentScrolling = class FragmentScrolling extends up.FragmentProcessor {
|
|
4161
4182
|
/* 47 */
|
4162
4183
|
/***/ (() => {
|
4163
4184
|
|
4164
|
-
const u = up.util;
|
4165
|
-
const e = up.element;
|
4166
|
-
up.HTMLWrapper = class HTMLWrapper {
|
4167
|
-
constructor(tagName) {
|
4168
|
-
this.tagName = tagName;
|
4169
|
-
const openTag = `<${this.tagName}[^>]*>`;
|
4170
|
-
const closeTag = `</${this.tagName}>`;
|
4171
|
-
const innerHTML = "(.|\\s)*?";
|
4172
|
-
this.pattern = new RegExp(openTag + innerHTML + closeTag, 'ig');
|
4173
|
-
this.attrName = `up-wrapped-${this.tagName}`;
|
4174
|
-
}
|
4175
|
-
strip(html) {
|
4176
|
-
return html.replace(this.pattern, '');
|
4177
|
-
}
|
4178
|
-
wrap(html) {
|
4179
|
-
return html.replace(this.pattern, this.wrapMatch.bind(this));
|
4180
|
-
}
|
4181
|
-
wrapMatch(match) {
|
4182
|
-
this.didWrap = true;
|
4183
|
-
return '<meta name="' + this.attrName + '" value="' + u.escapeHTML(match) + '">';
|
4184
|
-
}
|
4185
|
-
unwrap(element) {
|
4186
|
-
if (!this.didWrap) {
|
4187
|
-
return;
|
4188
|
-
}
|
4189
|
-
for (let wrappedChild of element.querySelectorAll(`meta[name='${this.attrName}']`)) {
|
4190
|
-
const originalHTML = wrappedChild.getAttribute('value');
|
4191
|
-
const restoredElement = e.createFromHTML(originalHTML);
|
4192
|
-
wrappedChild.replaceWith(restoredElement);
|
4193
|
-
}
|
4194
|
-
}
|
4195
|
-
};
|
4196
|
-
|
4197
|
-
|
4198
|
-
/***/ }),
|
4199
|
-
/* 48 */
|
4200
|
-
/***/ (() => {
|
4201
|
-
|
4202
4185
|
const e = up.element;
|
4203
4186
|
const u = up.util;
|
4204
4187
|
up.Layer = class Layer extends up.Record {
|
@@ -4416,7 +4399,7 @@ up.Layer = class Layer extends up.Record {
|
|
4416
4399
|
|
4417
4400
|
|
4418
4401
|
/***/ }),
|
4419
|
-
/*
|
4402
|
+
/* 48 */
|
4420
4403
|
/***/ (() => {
|
4421
4404
|
|
4422
4405
|
const e = up.element;
|
@@ -4696,7 +4679,7 @@ up.Layer.Overlay = class Overlay extends up.Layer {
|
|
4696
4679
|
|
4697
4680
|
|
4698
4681
|
/***/ }),
|
4699
|
-
/*
|
4682
|
+
/* 49 */
|
4700
4683
|
/***/ (() => {
|
4701
4684
|
|
4702
4685
|
up.Layer.OverlayWithTether = class OverlayWithTether extends up.Layer.Overlay {
|
@@ -4733,7 +4716,7 @@ up.Layer.OverlayWithTether = class OverlayWithTether extends up.Layer.Overlay {
|
|
4733
4716
|
|
4734
4717
|
|
4735
4718
|
/***/ }),
|
4736
|
-
/*
|
4719
|
+
/* 50 */
|
4737
4720
|
/***/ (() => {
|
4738
4721
|
|
4739
4722
|
var _a;
|
@@ -4771,7 +4754,7 @@ up.Layer.OverlayWithViewport = (_a = class OverlayWithViewport extends up.Layer.
|
|
4771
4754
|
|
4772
4755
|
|
4773
4756
|
/***/ }),
|
4774
|
-
/*
|
4757
|
+
/* 51 */
|
4775
4758
|
/***/ (() => {
|
4776
4759
|
|
4777
4760
|
var _a;
|
@@ -4820,7 +4803,7 @@ up.Layer.Root = (_a = class Root extends up.Layer {
|
|
4820
4803
|
|
4821
4804
|
|
4822
4805
|
/***/ }),
|
4823
|
-
/*
|
4806
|
+
/* 52 */
|
4824
4807
|
/***/ (() => {
|
4825
4808
|
|
4826
4809
|
var _a;
|
@@ -4831,7 +4814,7 @@ up.Layer.Modal = (_a = class Modal extends up.Layer.OverlayWithViewport {
|
|
4831
4814
|
|
4832
4815
|
|
4833
4816
|
/***/ }),
|
4834
|
-
/*
|
4817
|
+
/* 53 */
|
4835
4818
|
/***/ (() => {
|
4836
4819
|
|
4837
4820
|
var _a;
|
@@ -4842,7 +4825,7 @@ up.Layer.Popup = (_a = class Popup extends up.Layer.OverlayWithTether {
|
|
4842
4825
|
|
4843
4826
|
|
4844
4827
|
/***/ }),
|
4845
|
-
/*
|
4828
|
+
/* 54 */
|
4846
4829
|
/***/ (() => {
|
4847
4830
|
|
4848
4831
|
var _a;
|
@@ -4853,7 +4836,7 @@ up.Layer.Drawer = (_a = class Drawer extends up.Layer.OverlayWithViewport {
|
|
4853
4836
|
|
4854
4837
|
|
4855
4838
|
/***/ }),
|
4856
|
-
/*
|
4839
|
+
/* 55 */
|
4857
4840
|
/***/ (() => {
|
4858
4841
|
|
4859
4842
|
var _a;
|
@@ -4864,7 +4847,7 @@ up.Layer.Cover = (_a = class Cover extends up.Layer.OverlayWithViewport {
|
|
4864
4847
|
|
4865
4848
|
|
4866
4849
|
/***/ }),
|
4867
|
-
/*
|
4850
|
+
/* 56 */
|
4868
4851
|
/***/ (() => {
|
4869
4852
|
|
4870
4853
|
const u = up.util;
|
@@ -4954,7 +4937,7 @@ up.LayerLookup = class LayerLookup {
|
|
4954
4937
|
|
4955
4938
|
|
4956
4939
|
/***/ }),
|
4957
|
-
/*
|
4940
|
+
/* 57 */
|
4958
4941
|
/***/ (() => {
|
4959
4942
|
|
4960
4943
|
const u = up.util;
|
@@ -5067,7 +5050,7 @@ up.LayerStack = class LayerStack extends Array {
|
|
5067
5050
|
|
5068
5051
|
|
5069
5052
|
/***/ }),
|
5070
|
-
/*
|
5053
|
+
/* 58 */
|
5071
5054
|
/***/ (() => {
|
5072
5055
|
|
5073
5056
|
up.LinkFeedbackURLs = class LinkFeedbackURLs {
|
@@ -5098,7 +5081,7 @@ up.LinkFeedbackURLs = class LinkFeedbackURLs {
|
|
5098
5081
|
|
5099
5082
|
|
5100
5083
|
/***/ }),
|
5101
|
-
/*
|
5084
|
+
/* 59 */
|
5102
5085
|
/***/ (() => {
|
5103
5086
|
|
5104
5087
|
const u = up.util;
|
@@ -5168,7 +5151,7 @@ up.LinkPreloader = class LinkPreloader {
|
|
5168
5151
|
|
5169
5152
|
|
5170
5153
|
/***/ }),
|
5171
|
-
/*
|
5154
|
+
/* 60 */
|
5172
5155
|
/***/ (function() {
|
5173
5156
|
|
5174
5157
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
@@ -5277,7 +5260,7 @@ up.MotionController = class MotionController {
|
|
5277
5260
|
|
5278
5261
|
|
5279
5262
|
/***/ }),
|
5280
|
-
/*
|
5263
|
+
/* 61 */
|
5281
5264
|
/***/ (() => {
|
5282
5265
|
|
5283
5266
|
const u = up.util;
|
@@ -5369,7 +5352,7 @@ up.NonceableCallback = class NonceableCallback {
|
|
5369
5352
|
|
5370
5353
|
|
5371
5354
|
/***/ }),
|
5372
|
-
/*
|
5355
|
+
/* 62 */
|
5373
5356
|
/***/ (() => {
|
5374
5357
|
|
5375
5358
|
const u = up.util;
|
@@ -5447,7 +5430,7 @@ up.OptionsParser = class OptionsParser {
|
|
5447
5430
|
|
5448
5431
|
|
5449
5432
|
/***/ }),
|
5450
|
-
/*
|
5433
|
+
/* 63 */
|
5451
5434
|
/***/ (() => {
|
5452
5435
|
|
5453
5436
|
const e = up.element;
|
@@ -5515,7 +5498,7 @@ up.OverlayFocus = class OverlayFocus {
|
|
5515
5498
|
|
5516
5499
|
|
5517
5500
|
/***/ }),
|
5518
|
-
/*
|
5501
|
+
/* 64 */
|
5519
5502
|
/***/ (() => {
|
5520
5503
|
|
5521
5504
|
const u = up.util;
|
@@ -5746,7 +5729,7 @@ up.Params = class Params {
|
|
5746
5729
|
|
5747
5730
|
|
5748
5731
|
/***/ }),
|
5749
|
-
/*
|
5732
|
+
/* 65 */
|
5750
5733
|
/***/ (() => {
|
5751
5734
|
|
5752
5735
|
const e = up.element;
|
@@ -5796,7 +5779,7 @@ up.ProgressBar = class ProgressBar {
|
|
5796
5779
|
|
5797
5780
|
|
5798
5781
|
/***/ }),
|
5799
|
-
/*
|
5782
|
+
/* 66 */
|
5800
5783
|
/***/ (() => {
|
5801
5784
|
|
5802
5785
|
const u = up.util;
|
@@ -5913,7 +5896,7 @@ up.RenderOptions = (function () {
|
|
5913
5896
|
|
5914
5897
|
|
5915
5898
|
/***/ }),
|
5916
|
-
/*
|
5899
|
+
/* 67 */
|
5917
5900
|
/***/ (() => {
|
5918
5901
|
|
5919
5902
|
up.RenderResult = class RenderResult extends up.Record {
|
@@ -5941,7 +5924,7 @@ up.RenderResult = class RenderResult extends up.Record {
|
|
5941
5924
|
|
5942
5925
|
|
5943
5926
|
/***/ }),
|
5944
|
-
/*
|
5927
|
+
/* 68 */
|
5945
5928
|
/***/ (() => {
|
5946
5929
|
|
5947
5930
|
var _a;
|
@@ -5966,6 +5949,7 @@ up.Request = (_a = class Request extends up.Record {
|
|
5966
5949
|
}
|
5967
5950
|
this.deferred = u.newDeferred();
|
5968
5951
|
(_a = this.badResponseTime) !== null && _a !== void 0 ? _a : (this.badResponseTime = u.evalOption(up.network.config.badResponseTime, this));
|
5952
|
+
this.uid = u.uid();
|
5969
5953
|
}
|
5970
5954
|
keys() {
|
5971
5955
|
return [
|
@@ -6028,9 +6012,6 @@ up.Request = (_a = class Request extends up.Record {
|
|
6028
6012
|
var _a;
|
6029
6013
|
return (_a = this.fragments) === null || _a === void 0 ? void 0 : _a[0];
|
6030
6014
|
}
|
6031
|
-
followState(sourceRequest) {
|
6032
|
-
u.delegate(this, ['deferred', 'state', 'preload', 'expired'], () => sourceRequest);
|
6033
|
-
}
|
6034
6015
|
normalizeForCaching() {
|
6035
6016
|
this.method = u.normalizeMethod(this.method);
|
6036
6017
|
this.extractHashFromURL();
|
@@ -6074,10 +6055,12 @@ up.Request = (_a = class Request extends up.Record {
|
|
6074
6055
|
}
|
6075
6056
|
runQueuedCallbacks() {
|
6076
6057
|
var _a;
|
6058
|
+
this.queuedAt = new Date();
|
6077
6059
|
u.always(this, () => this.evictExpensiveAttrs());
|
6078
6060
|
(_a = this.onQueued) === null || _a === void 0 ? void 0 : _a.call(this, this);
|
6079
6061
|
}
|
6080
6062
|
load() {
|
6063
|
+
console.debug("[request] calling load() on %o", this.description);
|
6081
6064
|
if (this.state !== 'new')
|
6082
6065
|
return;
|
6083
6066
|
this.state = 'loading';
|
@@ -6131,14 +6114,18 @@ up.Request = (_a = class Request extends up.Record {
|
|
6131
6114
|
this.emit('up:request:offline', { log: message });
|
6132
6115
|
}
|
6133
6116
|
respondWith(response) {
|
6134
|
-
|
6117
|
+
this.response = response;
|
6118
|
+
console.debug("[request] respondWith() at state %o / uid %o", this.state, this.uid);
|
6119
|
+
if (this.isSettled())
|
6135
6120
|
return;
|
6136
6121
|
this.state = 'loaded';
|
6137
6122
|
if (response.ok) {
|
6138
|
-
|
6123
|
+
console.debug("[request] fulfilling deferred of %o with response", this.uid);
|
6124
|
+
this.deferred.resolve(response);
|
6139
6125
|
}
|
6140
6126
|
else {
|
6141
|
-
|
6127
|
+
console.debug("[request] rejecting deferred of %o with response", this.uid);
|
6128
|
+
this.deferred.reject(response);
|
6142
6129
|
}
|
6143
6130
|
}
|
6144
6131
|
isSettled() {
|
@@ -6189,24 +6176,6 @@ up.Request = (_a = class Request extends up.Record {
|
|
6189
6176
|
}
|
6190
6177
|
return new up.Response(responseAttrs);
|
6191
6178
|
}
|
6192
|
-
cacheKey() {
|
6193
|
-
return JSON.stringify([
|
6194
|
-
this.method,
|
6195
|
-
this.url,
|
6196
|
-
this.params.toQuery(),
|
6197
|
-
this.metaProps()
|
6198
|
-
]);
|
6199
|
-
}
|
6200
|
-
metaProps() {
|
6201
|
-
const props = {};
|
6202
|
-
for (let key of u.evalOption(up.network.config.requestMetaKeys, this)) {
|
6203
|
-
const value = this[key];
|
6204
|
-
if (u.isGiven(value)) {
|
6205
|
-
props[key] = value;
|
6206
|
-
}
|
6207
|
-
}
|
6208
|
-
return props;
|
6209
|
-
}
|
6210
6179
|
buildEventEmitter(args) {
|
6211
6180
|
return up.EventEmitter.fromEmitArgs(args, {
|
6212
6181
|
layer: this.layer,
|
@@ -6236,6 +6205,9 @@ up.Request = (_a = class Request extends up.Record {
|
|
6236
6205
|
const now = new Date();
|
6237
6206
|
return now - this.queuedAt;
|
6238
6207
|
}
|
6208
|
+
header(name) {
|
6209
|
+
return this.headers[name];
|
6210
|
+
}
|
6239
6211
|
static tester(condition, { except } = {}) {
|
6240
6212
|
let testFn;
|
6241
6213
|
if (u.isFunction(condition)) {
|
@@ -6252,8 +6224,7 @@ up.Request = (_a = class Request extends up.Record {
|
|
6252
6224
|
testFn = (_request) => condition;
|
6253
6225
|
}
|
6254
6226
|
if (except) {
|
6255
|
-
|
6256
|
-
return (request) => (request.cacheKey() !== exceptCacheKey) && testFn(request);
|
6227
|
+
return (request) => !up.cache.isCacheCompatible(except, request) && testFn(request);
|
6257
6228
|
}
|
6258
6229
|
else {
|
6259
6230
|
return testFn;
|
@@ -6267,7 +6238,7 @@ up.Request = (_a = class Request extends up.Record {
|
|
6267
6238
|
|
6268
6239
|
|
6269
6240
|
/***/ }),
|
6270
|
-
/*
|
6241
|
+
/* 69 */
|
6271
6242
|
/***/ (() => {
|
6272
6243
|
|
6273
6244
|
let u = up.util;
|
@@ -6298,6 +6269,151 @@ up.Request.Cache = class Cache extends up.Cache {
|
|
6298
6269
|
};
|
6299
6270
|
|
6300
6271
|
|
6272
|
+
/***/ }),
|
6273
|
+
/* 70 */
|
6274
|
+
/***/ (function() {
|
6275
|
+
|
6276
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
6277
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
6278
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
6279
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
6280
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
6281
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
6282
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
6283
|
+
});
|
6284
|
+
};
|
6285
|
+
const u = up.util;
|
6286
|
+
up.Request.Cache3 = class Cache3 {
|
6287
|
+
constructor() {
|
6288
|
+
this.reset();
|
6289
|
+
}
|
6290
|
+
reset() {
|
6291
|
+
this.varyInfo = {};
|
6292
|
+
this.map = new Map();
|
6293
|
+
}
|
6294
|
+
cacheKey(request) {
|
6295
|
+
let varyHeaderNames = this.getPreviousVaryHeaderNames(request);
|
6296
|
+
let varyPart = u.flatMap(varyHeaderNames, (headerName) => [headerName, request.header(headerName)]);
|
6297
|
+
return [request.description, ...varyPart].join(':');
|
6298
|
+
}
|
6299
|
+
getPreviousVaryHeaderNames(request) {
|
6300
|
+
var _a, _b;
|
6301
|
+
return ((_a = this.varyInfo)[_b = request.description] || (_a[_b] = new Set()));
|
6302
|
+
}
|
6303
|
+
get(request) {
|
6304
|
+
console.debug("[cache] get() called with %o", request.description);
|
6305
|
+
let cacheKey = this.cacheKey(request);
|
6306
|
+
let cachedRequest = this.map.get(cacheKey);
|
6307
|
+
console.debug("[cache] cache hit is %o", cachedRequest);
|
6308
|
+
if (cachedRequest) {
|
6309
|
+
if (this.isUsable(cachedRequest)) {
|
6310
|
+
return cachedRequest;
|
6311
|
+
}
|
6312
|
+
else {
|
6313
|
+
this.map.delete(cacheKey);
|
6314
|
+
}
|
6315
|
+
}
|
6316
|
+
}
|
6317
|
+
get maxSize() {
|
6318
|
+
return up.network.config.cacheSize;
|
6319
|
+
}
|
6320
|
+
isUsable(request) {
|
6321
|
+
const evictAge = up.network.config.cacheEvictAge;
|
6322
|
+
const age = new Date() - request.queuedAt;
|
6323
|
+
return age < evictAge;
|
6324
|
+
}
|
6325
|
+
put(request) {
|
6326
|
+
return __awaiter(this, void 0, void 0, function* () {
|
6327
|
+
console.debug("[cache] put() called for %o", request.description);
|
6328
|
+
this.makeRoom();
|
6329
|
+
let cacheKey = this.updateCacheKey(request);
|
6330
|
+
this.map.set(cacheKey, request);
|
6331
|
+
});
|
6332
|
+
}
|
6333
|
+
updateCacheKey(request) {
|
6334
|
+
let oldCacheKey = this.cacheKey(request);
|
6335
|
+
let { response } = request;
|
6336
|
+
if (response) {
|
6337
|
+
this.mergePreviousHeaderNames(request, response);
|
6338
|
+
let newCacheKey = this.cacheKey(request);
|
6339
|
+
this.renameMapKey(oldCacheKey, newCacheKey);
|
6340
|
+
return newCacheKey;
|
6341
|
+
}
|
6342
|
+
else {
|
6343
|
+
return oldCacheKey;
|
6344
|
+
}
|
6345
|
+
}
|
6346
|
+
renameMapKey(oldKey, newKey) {
|
6347
|
+
if (this.map.has(oldKey)) {
|
6348
|
+
this.map.set(newKey, this.map.get(oldKey));
|
6349
|
+
this.map.delete(oldKey);
|
6350
|
+
}
|
6351
|
+
}
|
6352
|
+
mergePreviousHeaderNames(request, response) {
|
6353
|
+
let responseVaryHeaderNames = response.ownVaryHeaderNames;
|
6354
|
+
if (responseVaryHeaderNames.length) {
|
6355
|
+
let previousVaryHeaderNames = this.getPreviousVaryHeaderNames(request);
|
6356
|
+
for (let varyHeaderName of responseVaryHeaderNames) {
|
6357
|
+
previousVaryHeaderNames.add(varyHeaderName);
|
6358
|
+
}
|
6359
|
+
}
|
6360
|
+
}
|
6361
|
+
alias(existingCachedRequest, newRequest) {
|
6362
|
+
this.connect(existingCachedRequest, newRequest, { force: true });
|
6363
|
+
this.put(newRequest);
|
6364
|
+
}
|
6365
|
+
connect(existingCachedRequest, newRequest, options = {}) {
|
6366
|
+
var _a;
|
6367
|
+
return __awaiter(this, void 0, void 0, function* () {
|
6368
|
+
let value = yield u.always(existingCachedRequest);
|
6369
|
+
if (value instanceof up.Response) {
|
6370
|
+
console.debug("[cache] connect settles to response %o", value.text);
|
6371
|
+
if (options.force || this.isCacheCompatible(existingCachedRequest, newRequest)) {
|
6372
|
+
console.debug("[cache] they are compatible");
|
6373
|
+
newRequest.fromCache = true;
|
6374
|
+
newRequest.respondWith(value);
|
6375
|
+
u.delegate(newRequest, ['expired', 'state'], () => existingCachedRequest);
|
6376
|
+
}
|
6377
|
+
else {
|
6378
|
+
console.debug("[cache] they are incompatible");
|
6379
|
+
(_a = options.onIncompatible) === null || _a === void 0 ? void 0 : _a.call(options, newRequest);
|
6380
|
+
}
|
6381
|
+
}
|
6382
|
+
else {
|
6383
|
+
newRequest.deferred.reject(value);
|
6384
|
+
}
|
6385
|
+
});
|
6386
|
+
}
|
6387
|
+
delete(request) {
|
6388
|
+
let cacheKey = this.cacheKey(request);
|
6389
|
+
this.map.delete(cacheKey);
|
6390
|
+
}
|
6391
|
+
evict(condition = true, testerOptions) {
|
6392
|
+
this.eachMatch(condition, testerOptions, (request) => this.delete(request));
|
6393
|
+
}
|
6394
|
+
expire(condition = true, testerOptions) {
|
6395
|
+
this.eachMatch(condition, testerOptions, (request) => request.expired = true);
|
6396
|
+
}
|
6397
|
+
makeRoom() {
|
6398
|
+
if (this.maxSize === 0) {
|
6399
|
+
throw "Disabling the cache with maxSize 0 is no longer supported. Use up.network.config.autoCache = false instead.";
|
6400
|
+
}
|
6401
|
+
while (this.map.size >= this.maxSize) {
|
6402
|
+
let oldestKey = this.map.keys().next().value;
|
6403
|
+
this.map.delete(oldestKey);
|
6404
|
+
}
|
6405
|
+
}
|
6406
|
+
eachMatch(condition = true, testerOptions, fn) {
|
6407
|
+
let tester = up.Request.tester(condition, testerOptions);
|
6408
|
+
let results = u.filter(this.map.values(), tester);
|
6409
|
+
u.each(results, fn);
|
6410
|
+
}
|
6411
|
+
isCacheCompatible(request1, request2) {
|
6412
|
+
return this.cacheKey(request1) === this.cacheKey(request2);
|
6413
|
+
}
|
6414
|
+
};
|
6415
|
+
|
6416
|
+
|
6301
6417
|
/***/ }),
|
6302
6418
|
/* 71 */
|
6303
6419
|
/***/ (() => {
|
@@ -6318,7 +6434,6 @@ up.Request.Queue = class Queue {
|
|
6318
6434
|
asap(request) {
|
6319
6435
|
request.runQueuedCallbacks();
|
6320
6436
|
u.always(request, responseOrError => this.onRequestSettled(request, responseOrError));
|
6321
|
-
request.queuedAt = new Date();
|
6322
6437
|
this.scheduleSlowTimer(request);
|
6323
6438
|
this.queueRequest(request);
|
6324
6439
|
u.microtask(() => this.poke());
|
@@ -6471,12 +6586,8 @@ up.Request.XHRRenderer = (_a = class XHRRenderer {
|
|
6471
6586
|
xhr.timeout = this.request.timeout;
|
6472
6587
|
}
|
6473
6588
|
xhr.open(this.getMethod(), this.request.url);
|
6474
|
-
|
6475
|
-
|
6476
|
-
this.addHeader(xhr, up.protocol.headerize(key), metaProps[key]);
|
6477
|
-
}
|
6478
|
-
for (let header in this.request.headers) {
|
6479
|
-
this.addHeader(xhr, header, this.request.headers[header]);
|
6589
|
+
for (let key of ['target', 'failTarget', 'mode', 'failMode', 'context', 'failContext']) {
|
6590
|
+
this.addHeader(xhr, up.protocol.headerize(key), this.request[key]);
|
6480
6591
|
}
|
6481
6592
|
let csrfHeader, csrfToken;
|
6482
6593
|
if ((csrfHeader = this.request.csrfHeader()) && (csrfToken = this.request.csrfToken())) {
|
@@ -6487,6 +6598,10 @@ up.Request.XHRRenderer = (_a = class XHRRenderer {
|
|
6487
6598
|
if (contentType) {
|
6488
6599
|
this.addHeader(xhr, 'Content-Type', contentType);
|
6489
6600
|
}
|
6601
|
+
for (let headerName in this.request.headers) {
|
6602
|
+
let headerValue = this.request.headers[headerName];
|
6603
|
+
xhr.setRequestHeader(headerName, headerValue);
|
6604
|
+
}
|
6490
6605
|
Object.assign(xhr, handlers);
|
6491
6606
|
xhr.send(this.getPayload());
|
6492
6607
|
}
|
@@ -6507,11 +6622,11 @@ up.Request.XHRRenderer = (_a = class XHRRenderer {
|
|
6507
6622
|
this.finalizePayload();
|
6508
6623
|
return this.payload;
|
6509
6624
|
}
|
6510
|
-
addHeader(xhr,
|
6625
|
+
addHeader(xhr, name, value) {
|
6511
6626
|
if (u.isOptions(value) || u.isArray(value)) {
|
6512
|
-
value =
|
6627
|
+
value = u.safeStringifyJSON(value);
|
6513
6628
|
}
|
6514
|
-
|
6629
|
+
this.request.headers[name] = value;
|
6515
6630
|
}
|
6516
6631
|
finalizePayload() {
|
6517
6632
|
this.payload = this.request.payload;
|
@@ -6579,6 +6694,11 @@ up.Response = class Response extends up.Record {
|
|
6579
6694
|
var _a;
|
6580
6695
|
return this.headers[name] || ((_a = this.xhr) === null || _a === void 0 ? void 0 : _a.getResponseHeader(name));
|
6581
6696
|
}
|
6697
|
+
get ownVaryHeaderNames() {
|
6698
|
+
let varyHeaderValue = this.header('Vary');
|
6699
|
+
let varyHeaderNames = u.parseTokens(varyHeaderValue, { separator: 'comma' });
|
6700
|
+
return u.filter(varyHeaderNames, (headerName) => this.request.header(headerName));
|
6701
|
+
}
|
6582
6702
|
get contentType() {
|
6583
6703
|
return this.header('Content-Type');
|
6584
6704
|
}
|
@@ -6620,12 +6740,13 @@ const u = up.util;
|
|
6620
6740
|
const e = up.element;
|
6621
6741
|
up.ResponseDoc = (_a = class ResponseDoc {
|
6622
6742
|
constructor(options) {
|
6623
|
-
this.noscriptWrapper = new up.HTMLWrapper('noscript');
|
6624
|
-
this.scriptWrapper = new up.HTMLWrapper('script');
|
6625
6743
|
this.root =
|
6626
6744
|
this.parseDocument(options) ||
|
6627
6745
|
this.parseFragment(options) ||
|
6628
6746
|
this.parseContent(options);
|
6747
|
+
if (!up.fragment.config.runScripts) {
|
6748
|
+
this.root.querySelectorAll('script').forEach((e) => e.remove());
|
6749
|
+
}
|
6629
6750
|
this.cspNonces = options.cspNonces;
|
6630
6751
|
if (options.origin) {
|
6631
6752
|
let originSelector = up.fragment.tryToTarget(options.origin);
|
@@ -6635,7 +6756,11 @@ up.ResponseDoc = (_a = class ResponseDoc {
|
|
6635
6756
|
}
|
6636
6757
|
}
|
6637
6758
|
parseDocument(options) {
|
6638
|
-
|
6759
|
+
let document = this.parse(options.document, e.createBrokenDocumentFromHTML);
|
6760
|
+
if (document) {
|
6761
|
+
this.scriptishNeedFix = true;
|
6762
|
+
return document;
|
6763
|
+
}
|
6639
6764
|
}
|
6640
6765
|
parseContent(options) {
|
6641
6766
|
let content = options.content || '';
|
@@ -6643,7 +6768,6 @@ up.ResponseDoc = (_a = class ResponseDoc {
|
|
6643
6768
|
target = u.map(up.fragment.parseTargetSteps(target), 'selector').join(',');
|
6644
6769
|
const matchingElement = e.createFromSelector(target);
|
6645
6770
|
if (u.isString(content)) {
|
6646
|
-
content = this.wrapHTML(content);
|
6647
6771
|
matchingElement.innerHTML = content;
|
6648
6772
|
}
|
6649
6773
|
else {
|
@@ -6656,7 +6780,6 @@ up.ResponseDoc = (_a = class ResponseDoc {
|
|
6656
6780
|
}
|
6657
6781
|
parse(value, parseFn = e.createFromHTML) {
|
6658
6782
|
if (u.isString(value)) {
|
6659
|
-
value = this.wrapHTML(value);
|
6660
6783
|
value = parseFn(value);
|
6661
6784
|
}
|
6662
6785
|
return value;
|
@@ -6664,19 +6787,9 @@ up.ResponseDoc = (_a = class ResponseDoc {
|
|
6664
6787
|
rootSelector() {
|
6665
6788
|
return up.fragment.toTarget(this.root);
|
6666
6789
|
}
|
6667
|
-
wrapHTML(html) {
|
6668
|
-
html = this.noscriptWrapper.wrap(html);
|
6669
|
-
if (up.fragment.config.runScripts) {
|
6670
|
-
html = this.scriptWrapper.wrap(html);
|
6671
|
-
}
|
6672
|
-
else {
|
6673
|
-
html = this.scriptWrapper.strip(html);
|
6674
|
-
}
|
6675
|
-
return html;
|
6676
|
-
}
|
6677
6790
|
getTitle() {
|
6678
6791
|
var _a;
|
6679
|
-
return (_a = this.root.querySelector(
|
6792
|
+
return (_a = this.root.querySelector('head title')) === null || _a === void 0 ? void 0 : _a.textContent;
|
6680
6793
|
}
|
6681
6794
|
select(selector) {
|
6682
6795
|
let finder = new up.FragmentFinder({
|
@@ -6687,9 +6800,10 @@ up.ResponseDoc = (_a = class ResponseDoc {
|
|
6687
6800
|
return finder.find();
|
6688
6801
|
}
|
6689
6802
|
finalizeElement(element) {
|
6690
|
-
this.noscriptWrapper.unwrap(element);
|
6691
6803
|
up.NonceableCallback.adoptNonces(element, this.cspNonces);
|
6692
|
-
this.
|
6804
|
+
if (this.scriptishNeedFix) {
|
6805
|
+
element.querySelectorAll('noscript, script').forEach(e.fixScriptish);
|
6806
|
+
}
|
6693
6807
|
}
|
6694
6808
|
},
|
6695
6809
|
(() => {
|
@@ -7277,7 +7391,8 @@ up.protocol = (function () {
|
|
7277
7391
|
return extractHeader(xhr, 'location') || xhr.responseURL;
|
7278
7392
|
}
|
7279
7393
|
function titleFromXHR(xhr) {
|
7280
|
-
|
7394
|
+
var _a, _b, _c;
|
7395
|
+
return (_c = (_b = (_a = up.migrate).titleFromXHR) === null || _b === void 0 ? void 0 : _b.call(_a, xhr)) !== null && _c !== void 0 ? _c : extractHeader(xhr, 'title', JSON.parse);
|
7281
7396
|
}
|
7282
7397
|
function targetFromXHR(xhr) {
|
7283
7398
|
return extractHeader(xhr, 'target');
|
@@ -8877,25 +8992,24 @@ up.network = (function () {
|
|
8877
8992
|
autoCache(request) { return request.isSafe(); },
|
8878
8993
|
expireCache(request, _response) { return !request.isSafe(); },
|
8879
8994
|
evictCache: false,
|
8880
|
-
requestMetaKeys: ['target', 'failTarget', 'mode', 'failMode', 'context', 'failContext'],
|
8881
8995
|
progressBar: true,
|
8882
8996
|
timeout: 90000,
|
8883
8997
|
}));
|
8884
8998
|
const queue = new up.Request.Queue();
|
8885
|
-
const cache = new up.Request.
|
8999
|
+
const cache = new up.Request.Cache3();
|
8886
9000
|
let progressBar = null;
|
8887
9001
|
function reset() {
|
8888
9002
|
abortRequests();
|
8889
9003
|
queue.reset();
|
8890
9004
|
config.reset();
|
8891
|
-
cache.
|
9005
|
+
cache.reset();
|
8892
9006
|
progressBar === null || progressBar === void 0 ? void 0 : progressBar.destroy();
|
8893
9007
|
progressBar = null;
|
8894
9008
|
}
|
8895
9009
|
function makeRequest(...args) {
|
8896
9010
|
const options = parseRequestOptions(args);
|
8897
9011
|
const request = new up.Request(options);
|
8898
|
-
|
9012
|
+
processRequest(request);
|
8899
9013
|
return request;
|
8900
9014
|
}
|
8901
9015
|
function parseRequestOptions(args) {
|
@@ -8907,31 +9021,30 @@ up.network = (function () {
|
|
8907
9021
|
(_b = (_a = up.migrate).handleRequestOptions) === null || _b === void 0 ? void 0 : _b.call(_a, options);
|
8908
9022
|
return options;
|
8909
9023
|
}
|
8910
|
-
function
|
9024
|
+
function processRequest(request) {
|
9025
|
+
useCachedRequest(request) || queueRequest(request);
|
9026
|
+
}
|
9027
|
+
function useCachedRequest(newRequest) {
|
8911
9028
|
let cachedRequest;
|
8912
|
-
if (
|
8913
|
-
up.puts('up.request()', 'Re-using previous request to %s %s',
|
8914
|
-
if (!
|
9029
|
+
if (newRequest.willCache() && (cachedRequest = cache.get(newRequest))) {
|
9030
|
+
up.puts('up.request()', 'Re-using previous request to %s %s', newRequest.method, newRequest.url);
|
9031
|
+
if (!newRequest.background) {
|
8915
9032
|
queue.promoteToForeground(cachedRequest);
|
8916
9033
|
}
|
8917
|
-
|
8918
|
-
request.fromCache = true;
|
9034
|
+
cache.connect(cachedRequest, newRequest, { onIncompatible: processRequest });
|
8919
9035
|
return true;
|
8920
9036
|
}
|
8921
9037
|
}
|
8922
9038
|
function queueRequest(request) {
|
8923
|
-
if (request.preload && !request.isSafe()) {
|
8924
|
-
up.fail('Will not preload request to %s', request.description);
|
8925
|
-
}
|
8926
9039
|
handleCaching(request);
|
8927
9040
|
queue.asap(request);
|
8928
9041
|
return true;
|
8929
9042
|
}
|
8930
9043
|
function handleCaching(request) {
|
8931
9044
|
if (request.willCache()) {
|
8932
|
-
cache.
|
9045
|
+
cache.put(request);
|
8933
9046
|
}
|
8934
|
-
|
9047
|
+
u.always(request, function (response) {
|
8935
9048
|
var _a, _b, _c, _d;
|
8936
9049
|
let expireCache = (_b = (_a = response.expireCache) !== null && _a !== void 0 ? _a : request.expireCache) !== null && _b !== void 0 ? _b : u.evalOption(config.expireCache, request, response);
|
8937
9050
|
if (expireCache) {
|
@@ -8942,7 +9055,7 @@ up.network = (function () {
|
|
8942
9055
|
cache.evict(evictCache, { except: request });
|
8943
9056
|
}
|
8944
9057
|
if (cache.get(request)) {
|
8945
|
-
cache.
|
9058
|
+
cache.put(request);
|
8946
9059
|
}
|
8947
9060
|
if (!response.ok) {
|
8948
9061
|
cache.evict(request);
|
@@ -9425,16 +9538,22 @@ up.link = (function () {
|
|
9425
9538
|
}
|
9426
9539
|
function preload(link, options) {
|
9427
9540
|
link = up.fragment.get(link);
|
9428
|
-
|
9429
|
-
|
9541
|
+
let issue = preloadIssue(link);
|
9542
|
+
if (issue) {
|
9543
|
+
return Promise.reject(new up.Error(issue));
|
9430
9544
|
}
|
9431
9545
|
const guardEvent = up.event.build('up:link:preload', { log: ['Preloading link %o', link] });
|
9432
9546
|
return follow(link, Object.assign(Object.assign({ abortable: false }, options), { guardEvent, preload: true }));
|
9433
9547
|
}
|
9434
|
-
function
|
9435
|
-
|
9436
|
-
|
9548
|
+
function preloadIssue(link) {
|
9549
|
+
if (!u.evalAutoOption(config.preloadEnabled, autoPreloadEnabled, link)) {
|
9550
|
+
return 'Preloading is disabled';
|
9551
|
+
}
|
9552
|
+
else if (!isSafe(link)) {
|
9553
|
+
return 'Will not preload an unsafe link';
|
9554
|
+
}
|
9437
9555
|
}
|
9556
|
+
const autoPreloadEnabled = u.negate(up.network.shouldReduceRequests);
|
9438
9557
|
function followMethod(link, options = {}) {
|
9439
9558
|
return u.normalizeMethod(options.method || link.getAttribute('up-method') || link.getAttribute('data-method'));
|
9440
9559
|
}
|
@@ -18,9 +18,13 @@ module Unpoly
|
|
18
18
|
end
|
19
19
|
|
20
20
|
private
|
21
|
-
|
21
|
+
|
22
22
|
def set_up_request_echo_headers
|
23
|
-
|
23
|
+
request_url_without_up_params = up.request_url_without_up_params
|
24
|
+
unless request_url_without_up_params == request.original_url
|
25
|
+
response.headers['X-Up-Location'] = up.request_url_without_up_params
|
26
|
+
end
|
27
|
+
|
24
28
|
response.headers['X-Up-Method'] = request.method
|
25
29
|
end
|
26
30
|
|
data/lib/unpoly/rails/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: unpoly-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.7.2.
|
4
|
+
version: 2.7.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Henning Koch
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-03-
|
11
|
+
date: 2023-03-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: railties
|