unpoly-rails 3.0.0.rc2 → 3.0.0.rc3
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-migrate.js +46 -13
- data/assets/unpoly/unpoly-migrate.min.js +1 -1
- data/assets/unpoly/unpoly.es6.js +373 -327
- data/assets/unpoly/unpoly.es6.min.js +1 -1
- data/assets/unpoly/unpoly.js +356 -326
- data/assets/unpoly/unpoly.min.js +1 -1
- data/lib/unpoly/rails/change/field.rb +4 -4
- data/lib/unpoly/rails/change/layer.rb +3 -3
- data/lib/unpoly/rails/change.rb +1 -1
- data/lib/unpoly/rails/request_echo_headers.rb +6 -2
- data/lib/unpoly/rails/util.rb +25 -0
- data/lib/unpoly/rails/version.rb +1 -1
- data/lib/unpoly-rails.rb +1 -0
- metadata +3 -2
data/assets/unpoly/unpoly.es6.js
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
/***/ (() => {
|
6
6
|
|
7
7
|
window.up = {
|
8
|
-
version: '3.0.0-
|
8
|
+
version: '3.0.0-rc3'
|
9
9
|
};
|
10
10
|
|
11
11
|
|
@@ -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
|
}
|
@@ -494,7 +497,7 @@ up.util = (function () {
|
|
494
497
|
function flatMap(array, block) {
|
495
498
|
return flatten(map(array, block));
|
496
499
|
}
|
497
|
-
function always(promise, callback) {
|
500
|
+
function always(promise, callback = identity) {
|
498
501
|
return promise.then(callback, callback);
|
499
502
|
}
|
500
503
|
function newDeferred() {
|
@@ -596,7 +599,7 @@ up.util = (function () {
|
|
596
599
|
Object.defineProperty(object, prop, { get });
|
597
600
|
}
|
598
601
|
function defineDelegates(object, props, targetProvider) {
|
599
|
-
|
602
|
+
for (let prop of props) {
|
600
603
|
Object.defineProperty(object, prop, {
|
601
604
|
get() {
|
602
605
|
const target = targetProvider.call(this);
|
@@ -611,7 +614,7 @@ up.util = (function () {
|
|
611
614
|
target[prop] = newValue;
|
612
615
|
}
|
613
616
|
});
|
614
|
-
}
|
617
|
+
}
|
615
618
|
}
|
616
619
|
function stringifyArg(arg) {
|
617
620
|
let string;
|
@@ -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,
|
@@ -1624,82 +1645,26 @@ up.LogConfig = class LogConfig extends up.Config {
|
|
1624
1645
|
/***/ (() => {
|
1625
1646
|
|
1626
1647
|
const u = up.util;
|
1627
|
-
up.
|
1628
|
-
constructor(
|
1629
|
-
this.config = config;
|
1648
|
+
up.FIFOCache = class FIFOCache {
|
1649
|
+
constructor({ capacity = 10, normalizeKey = u.identity } = {}) {
|
1630
1650
|
this.map = new Map();
|
1651
|
+
this.capacity = capacity;
|
1652
|
+
this.normalizeKey = normalizeKey;
|
1631
1653
|
}
|
1632
|
-
|
1633
|
-
|
1634
|
-
|
1635
|
-
maxSize() {
|
1636
|
-
return u.evalOption(this.config.size);
|
1637
|
-
}
|
1638
|
-
evictAge() {
|
1639
|
-
return u.evalOption(this.config.evictAge);
|
1640
|
-
}
|
1641
|
-
normalizeStoreKey(key) {
|
1642
|
-
return key;
|
1643
|
-
}
|
1644
|
-
isDisabled() {
|
1645
|
-
return this.maxSize() === 0 || this.evictAge() === 0;
|
1646
|
-
}
|
1647
|
-
evict() {
|
1648
|
-
this.map.clear();
|
1649
|
-
}
|
1650
|
-
records() {
|
1651
|
-
return this.map.values();
|
1652
|
-
}
|
1653
|
-
makeRoomForAnotherRecord() {
|
1654
|
-
const maxSize = this.maxSize();
|
1655
|
-
const currentSize = this.size();
|
1656
|
-
if (!maxSize || currentSize < maxSize)
|
1657
|
-
return;
|
1658
|
-
let records = Array.from(this.records());
|
1659
|
-
records.sort((a, b) => b.createdAt - a.createdAt);
|
1660
|
-
const overflow = currentSize - maxSize + 1;
|
1661
|
-
for (let i = 0; i < overflow; i++) {
|
1662
|
-
let key = records.pop().key;
|
1663
|
-
this.map.delete(key);
|
1664
|
-
}
|
1665
|
-
}
|
1666
|
-
alias(oldKey, newKey) {
|
1667
|
-
const value = this.get(oldKey);
|
1668
|
-
if (u.isDefined(value)) {
|
1669
|
-
this.set(newKey, value);
|
1670
|
-
}
|
1654
|
+
get(key) {
|
1655
|
+
key = this.normalizeKey(key);
|
1656
|
+
return this.map.get(key);
|
1671
1657
|
}
|
1672
1658
|
set(key, value) {
|
1673
|
-
if (this.
|
1674
|
-
|
1675
|
-
|
1676
|
-
key = this.normalizeStoreKey(key);
|
1677
|
-
const createdAt = new Date();
|
1678
|
-
const record = { key, value, createdAt };
|
1679
|
-
this.map.set(key, record);
|
1680
|
-
}
|
1681
|
-
remove(key) {
|
1682
|
-
key = this.normalizeStoreKey(key);
|
1683
|
-
this.map.delete(key);
|
1684
|
-
}
|
1685
|
-
isUsable(record) {
|
1686
|
-
const evictAge = this.evictAge();
|
1687
|
-
if (!evictAge)
|
1688
|
-
return true;
|
1689
|
-
const age = new Date() - record.createdAt;
|
1690
|
-
return age < evictAge;
|
1691
|
-
}
|
1692
|
-
get(key) {
|
1693
|
-
const storeKey = this.normalizeStoreKey(key);
|
1694
|
-
let record = this.map.get(storeKey);
|
1695
|
-
if (record) {
|
1696
|
-
if (this.isUsable(record)) {
|
1697
|
-
return record.value;
|
1698
|
-
}
|
1699
|
-
else {
|
1700
|
-
this.remove(key);
|
1701
|
-
}
|
1659
|
+
if (this.map.size === this.capacity) {
|
1660
|
+
let oldestKey = this.map.keys().next().value;
|
1661
|
+
this.map.delete(oldestKey);
|
1702
1662
|
}
|
1663
|
+
key = this.normalizeKey(key);
|
1664
|
+
this.map.set(key, value);
|
1665
|
+
}
|
1666
|
+
clear() {
|
1667
|
+
this.map.clear();
|
1703
1668
|
}
|
1704
1669
|
};
|
1705
1670
|
|
@@ -4161,44 +4126,6 @@ up.FragmentScrolling = class FragmentScrolling extends up.FragmentProcessor {
|
|
4161
4126
|
/* 47 */
|
4162
4127
|
/***/ (() => {
|
4163
4128
|
|
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
4129
|
const e = up.element;
|
4203
4130
|
const u = up.util;
|
4204
4131
|
up.Layer = class Layer extends up.Record {
|
@@ -4412,11 +4339,14 @@ up.Layer = class Layer extends up.Record {
|
|
4412
4339
|
let focusedElement = document.activeElement;
|
4413
4340
|
return focusedElement !== document.body && this.element.contains(focusedElement);
|
4414
4341
|
}
|
4342
|
+
reset() {
|
4343
|
+
Object.assign(this, this.defaults());
|
4344
|
+
}
|
4415
4345
|
};
|
4416
4346
|
|
4417
4347
|
|
4418
4348
|
/***/ }),
|
4419
|
-
/*
|
4349
|
+
/* 48 */
|
4420
4350
|
/***/ (() => {
|
4421
4351
|
|
4422
4352
|
const e = up.element;
|
@@ -4696,7 +4626,7 @@ up.Layer.Overlay = class Overlay extends up.Layer {
|
|
4696
4626
|
|
4697
4627
|
|
4698
4628
|
/***/ }),
|
4699
|
-
/*
|
4629
|
+
/* 49 */
|
4700
4630
|
/***/ (() => {
|
4701
4631
|
|
4702
4632
|
up.Layer.OverlayWithTether = class OverlayWithTether extends up.Layer.Overlay {
|
@@ -4733,7 +4663,7 @@ up.Layer.OverlayWithTether = class OverlayWithTether extends up.Layer.Overlay {
|
|
4733
4663
|
|
4734
4664
|
|
4735
4665
|
/***/ }),
|
4736
|
-
/*
|
4666
|
+
/* 50 */
|
4737
4667
|
/***/ (() => {
|
4738
4668
|
|
4739
4669
|
var _a;
|
@@ -4771,7 +4701,7 @@ up.Layer.OverlayWithViewport = (_a = class OverlayWithViewport extends up.Layer.
|
|
4771
4701
|
|
4772
4702
|
|
4773
4703
|
/***/ }),
|
4774
|
-
/*
|
4704
|
+
/* 51 */
|
4775
4705
|
/***/ (() => {
|
4776
4706
|
|
4777
4707
|
var _a;
|
@@ -4808,9 +4738,6 @@ up.Layer.Root = (_a = class Root extends up.Layer {
|
|
4808
4738
|
cannotCloseRoot() {
|
4809
4739
|
up.fail('Cannot close the root layer');
|
4810
4740
|
}
|
4811
|
-
reset() {
|
4812
|
-
Object.assign(this, this.defaults());
|
4813
|
-
}
|
4814
4741
|
toString() {
|
4815
4742
|
return "root layer";
|
4816
4743
|
}
|
@@ -4820,7 +4747,7 @@ up.Layer.Root = (_a = class Root extends up.Layer {
|
|
4820
4747
|
|
4821
4748
|
|
4822
4749
|
/***/ }),
|
4823
|
-
/*
|
4750
|
+
/* 52 */
|
4824
4751
|
/***/ (() => {
|
4825
4752
|
|
4826
4753
|
var _a;
|
@@ -4831,7 +4758,7 @@ up.Layer.Modal = (_a = class Modal extends up.Layer.OverlayWithViewport {
|
|
4831
4758
|
|
4832
4759
|
|
4833
4760
|
/***/ }),
|
4834
|
-
/*
|
4761
|
+
/* 53 */
|
4835
4762
|
/***/ (() => {
|
4836
4763
|
|
4837
4764
|
var _a;
|
@@ -4842,7 +4769,7 @@ up.Layer.Popup = (_a = class Popup extends up.Layer.OverlayWithTether {
|
|
4842
4769
|
|
4843
4770
|
|
4844
4771
|
/***/ }),
|
4845
|
-
/*
|
4772
|
+
/* 54 */
|
4846
4773
|
/***/ (() => {
|
4847
4774
|
|
4848
4775
|
var _a;
|
@@ -4853,7 +4780,7 @@ up.Layer.Drawer = (_a = class Drawer extends up.Layer.OverlayWithViewport {
|
|
4853
4780
|
|
4854
4781
|
|
4855
4782
|
/***/ }),
|
4856
|
-
/*
|
4783
|
+
/* 55 */
|
4857
4784
|
/***/ (() => {
|
4858
4785
|
|
4859
4786
|
var _a;
|
@@ -4864,7 +4791,7 @@ up.Layer.Cover = (_a = class Cover extends up.Layer.OverlayWithViewport {
|
|
4864
4791
|
|
4865
4792
|
|
4866
4793
|
/***/ }),
|
4867
|
-
/*
|
4794
|
+
/* 56 */
|
4868
4795
|
/***/ (() => {
|
4869
4796
|
|
4870
4797
|
const u = up.util;
|
@@ -4954,7 +4881,7 @@ up.LayerLookup = class LayerLookup {
|
|
4954
4881
|
|
4955
4882
|
|
4956
4883
|
/***/ }),
|
4957
|
-
/*
|
4884
|
+
/* 57 */
|
4958
4885
|
/***/ (() => {
|
4959
4886
|
|
4960
4887
|
const u = up.util;
|
@@ -5067,7 +4994,7 @@ up.LayerStack = class LayerStack extends Array {
|
|
5067
4994
|
|
5068
4995
|
|
5069
4996
|
/***/ }),
|
5070
|
-
/*
|
4997
|
+
/* 58 */
|
5071
4998
|
/***/ (() => {
|
5072
4999
|
|
5073
5000
|
up.LinkFeedbackURLs = class LinkFeedbackURLs {
|
@@ -5098,7 +5025,7 @@ up.LinkFeedbackURLs = class LinkFeedbackURLs {
|
|
5098
5025
|
|
5099
5026
|
|
5100
5027
|
/***/ }),
|
5101
|
-
/*
|
5028
|
+
/* 59 */
|
5102
5029
|
/***/ (() => {
|
5103
5030
|
|
5104
5031
|
const u = up.util;
|
@@ -5168,7 +5095,7 @@ up.LinkPreloader = class LinkPreloader {
|
|
5168
5095
|
|
5169
5096
|
|
5170
5097
|
/***/ }),
|
5171
|
-
/*
|
5098
|
+
/* 60 */
|
5172
5099
|
/***/ (function() {
|
5173
5100
|
|
5174
5101
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
@@ -5277,7 +5204,7 @@ up.MotionController = class MotionController {
|
|
5277
5204
|
|
5278
5205
|
|
5279
5206
|
/***/ }),
|
5280
|
-
/*
|
5207
|
+
/* 61 */
|
5281
5208
|
/***/ (() => {
|
5282
5209
|
|
5283
5210
|
const u = up.util;
|
@@ -5369,7 +5296,7 @@ up.NonceableCallback = class NonceableCallback {
|
|
5369
5296
|
|
5370
5297
|
|
5371
5298
|
/***/ }),
|
5372
|
-
/*
|
5299
|
+
/* 62 */
|
5373
5300
|
/***/ (() => {
|
5374
5301
|
|
5375
5302
|
const u = up.util;
|
@@ -5447,7 +5374,7 @@ up.OptionsParser = class OptionsParser {
|
|
5447
5374
|
|
5448
5375
|
|
5449
5376
|
/***/ }),
|
5450
|
-
/*
|
5377
|
+
/* 63 */
|
5451
5378
|
/***/ (() => {
|
5452
5379
|
|
5453
5380
|
const e = up.element;
|
@@ -5515,7 +5442,7 @@ up.OverlayFocus = class OverlayFocus {
|
|
5515
5442
|
|
5516
5443
|
|
5517
5444
|
/***/ }),
|
5518
|
-
/*
|
5445
|
+
/* 64 */
|
5519
5446
|
/***/ (() => {
|
5520
5447
|
|
5521
5448
|
const u = up.util;
|
@@ -5746,7 +5673,7 @@ up.Params = class Params {
|
|
5746
5673
|
|
5747
5674
|
|
5748
5675
|
/***/ }),
|
5749
|
-
/*
|
5676
|
+
/* 65 */
|
5750
5677
|
/***/ (() => {
|
5751
5678
|
|
5752
5679
|
const e = up.element;
|
@@ -5796,7 +5723,7 @@ up.ProgressBar = class ProgressBar {
|
|
5796
5723
|
|
5797
5724
|
|
5798
5725
|
/***/ }),
|
5799
|
-
/*
|
5726
|
+
/* 66 */
|
5800
5727
|
/***/ (() => {
|
5801
5728
|
|
5802
5729
|
const u = up.util;
|
@@ -5913,7 +5840,7 @@ up.RenderOptions = (function () {
|
|
5913
5840
|
|
5914
5841
|
|
5915
5842
|
/***/ }),
|
5916
|
-
/*
|
5843
|
+
/* 67 */
|
5917
5844
|
/***/ (() => {
|
5918
5845
|
|
5919
5846
|
up.RenderResult = class RenderResult extends up.Record {
|
@@ -5941,7 +5868,7 @@ up.RenderResult = class RenderResult extends up.Record {
|
|
5941
5868
|
|
5942
5869
|
|
5943
5870
|
/***/ }),
|
5944
|
-
/*
|
5871
|
+
/* 68 */
|
5945
5872
|
/***/ (() => {
|
5946
5873
|
|
5947
5874
|
var _a;
|
@@ -5954,7 +5881,7 @@ up.Request = (_a = class Request extends up.Record {
|
|
5954
5881
|
if (this.wrapMethod == null) {
|
5955
5882
|
this.wrapMethod = up.network.config.wrapMethod;
|
5956
5883
|
}
|
5957
|
-
this.
|
5884
|
+
this.normalize();
|
5958
5885
|
if ((this.target || this.layer || this.origin) && !options.basic) {
|
5959
5886
|
const layerLookupOptions = { origin: this.origin };
|
5960
5887
|
this.layer = up.layer.get(this.layer, layerLookupOptions);
|
@@ -5966,6 +5893,7 @@ up.Request = (_a = class Request extends up.Record {
|
|
5966
5893
|
}
|
5967
5894
|
this.deferred = u.newDeferred();
|
5968
5895
|
(_a = this.badResponseTime) !== null && _a !== void 0 ? _a : (this.badResponseTime = u.evalOption(up.network.config.badResponseTime, this));
|
5896
|
+
this.addAutoHeaders();
|
5969
5897
|
}
|
5970
5898
|
keys() {
|
5971
5899
|
return [
|
@@ -5977,7 +5905,6 @@ up.Request = (_a = class Request extends up.Record {
|
|
5977
5905
|
'failTarget',
|
5978
5906
|
'headers',
|
5979
5907
|
'timeout',
|
5980
|
-
'preload',
|
5981
5908
|
'background',
|
5982
5909
|
'cache',
|
5983
5910
|
'expireCache',
|
@@ -5990,11 +5917,12 @@ up.Request = (_a = class Request extends up.Record {
|
|
5990
5917
|
'failContext',
|
5991
5918
|
'origin',
|
5992
5919
|
'fragments',
|
5993
|
-
'
|
5920
|
+
'builtAt',
|
5994
5921
|
'wrapMethod',
|
5995
5922
|
'contentType',
|
5996
5923
|
'payload',
|
5997
5924
|
'onQueued',
|
5925
|
+
'onLoading',
|
5998
5926
|
'fail',
|
5999
5927
|
'abortable',
|
6000
5928
|
'badResponseTime',
|
@@ -6005,7 +5933,8 @@ up.Request = (_a = class Request extends up.Record {
|
|
6005
5933
|
state: 'new',
|
6006
5934
|
abortable: true,
|
6007
5935
|
headers: {},
|
6008
|
-
timeout: up.network.config.timeout
|
5936
|
+
timeout: up.network.config.timeout,
|
5937
|
+
builtAt: new Date(),
|
6009
5938
|
};
|
6010
5939
|
}
|
6011
5940
|
get xhr() {
|
@@ -6028,10 +5957,7 @@ up.Request = (_a = class Request extends up.Record {
|
|
6028
5957
|
var _a;
|
6029
5958
|
return (_a = this.fragments) === null || _a === void 0 ? void 0 : _a[0];
|
6030
5959
|
}
|
6031
|
-
|
6032
|
-
u.delegate(this, ['deferred', 'state', 'preload', 'expired'], () => sourceRequest);
|
6033
|
-
}
|
6034
|
-
normalizeForCaching() {
|
5960
|
+
normalize() {
|
6035
5961
|
this.method = u.normalizeMethod(this.method);
|
6036
5962
|
this.extractHashFromURL();
|
6037
5963
|
this.transferParamsToURL();
|
@@ -6078,16 +6004,29 @@ up.Request = (_a = class Request extends up.Record {
|
|
6078
6004
|
(_a = this.onQueued) === null || _a === void 0 ? void 0 : _a.call(this, this);
|
6079
6005
|
}
|
6080
6006
|
load() {
|
6007
|
+
var _a;
|
6081
6008
|
if (this.state !== 'new')
|
6082
6009
|
return;
|
6083
|
-
this.
|
6084
|
-
|
6085
|
-
|
6086
|
-
|
6087
|
-
|
6088
|
-
|
6089
|
-
|
6090
|
-
|
6010
|
+
if (this.emitLoad()) {
|
6011
|
+
this.state = 'loading';
|
6012
|
+
this.normalize();
|
6013
|
+
(_a = this.onLoading) === null || _a === void 0 ? void 0 : _a.call(this);
|
6014
|
+
this.expired = false;
|
6015
|
+
new up.Request.XHRRenderer(this).buildAndSend({
|
6016
|
+
onload: () => this.onXHRLoad(),
|
6017
|
+
onerror: () => this.onXHRError(),
|
6018
|
+
ontimeout: () => this.onXHRTimeout(),
|
6019
|
+
onabort: () => this.onXHRAbort()
|
6020
|
+
});
|
6021
|
+
return true;
|
6022
|
+
}
|
6023
|
+
else {
|
6024
|
+
this.abort({ reason: 'Prevented by event listener' });
|
6025
|
+
}
|
6026
|
+
}
|
6027
|
+
emitLoad() {
|
6028
|
+
let event = this.emit('up:request:load', { log: ['Loading %s', this.description] });
|
6029
|
+
return !event.defaultPrevented;
|
6091
6030
|
}
|
6092
6031
|
loadPage() {
|
6093
6032
|
up.network.abort();
|
@@ -6131,18 +6070,19 @@ up.Request = (_a = class Request extends up.Record {
|
|
6131
6070
|
this.emit('up:request:offline', { log: message });
|
6132
6071
|
}
|
6133
6072
|
respondWith(response) {
|
6134
|
-
|
6073
|
+
this.response = response;
|
6074
|
+
if (this.isSettled())
|
6135
6075
|
return;
|
6136
6076
|
this.state = 'loaded';
|
6137
6077
|
if (response.ok) {
|
6138
|
-
|
6078
|
+
this.deferred.resolve(response);
|
6139
6079
|
}
|
6140
6080
|
else {
|
6141
|
-
|
6081
|
+
this.deferred.reject(response);
|
6142
6082
|
}
|
6143
6083
|
}
|
6144
6084
|
isSettled() {
|
6145
|
-
return (this.state !== 'new') && (this.state !== 'loading');
|
6085
|
+
return (this.state !== 'new') && (this.state !== 'loading') && (this.state !== 'tracking');
|
6146
6086
|
}
|
6147
6087
|
csrfHeader() {
|
6148
6088
|
return up.protocol.csrfHeader();
|
@@ -6189,24 +6129,6 @@ up.Request = (_a = class Request extends up.Record {
|
|
6189
6129
|
}
|
6190
6130
|
return new up.Response(responseAttrs);
|
6191
6131
|
}
|
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
6132
|
buildEventEmitter(args) {
|
6211
6133
|
return up.EventEmitter.fromEmitArgs(args, {
|
6212
6134
|
layer: this.layer,
|
@@ -6232,9 +6154,27 @@ up.Request = (_a = class Request extends up.Record {
|
|
6232
6154
|
return u.some(subtreeElements, (subtreeElement) => subtreeElement.contains(fragment));
|
6233
6155
|
});
|
6234
6156
|
}
|
6235
|
-
get
|
6236
|
-
|
6237
|
-
|
6157
|
+
get age() {
|
6158
|
+
return new Date() - this.builtAt;
|
6159
|
+
}
|
6160
|
+
header(name) {
|
6161
|
+
return this.headers[name];
|
6162
|
+
}
|
6163
|
+
addAutoHeaders() {
|
6164
|
+
for (let key of ['target', 'failTarget', 'mode', 'failMode', 'context', 'failContext']) {
|
6165
|
+
this.addAutoHeader(up.protocol.headerize(key), this[key]);
|
6166
|
+
}
|
6167
|
+
let csrfHeader, csrfToken;
|
6168
|
+
if ((csrfHeader = this.csrfHeader()) && (csrfToken = this.csrfToken())) {
|
6169
|
+
this.addAutoHeader(csrfHeader, csrfToken);
|
6170
|
+
}
|
6171
|
+
this.addAutoHeader(up.protocol.headerize('version'), up.version);
|
6172
|
+
}
|
6173
|
+
addAutoHeader(name, value) {
|
6174
|
+
if (u.isOptions(value) || u.isArray(value)) {
|
6175
|
+
value = u.safeStringifyJSON(value);
|
6176
|
+
}
|
6177
|
+
this.headers[name] = value;
|
6238
6178
|
}
|
6239
6179
|
static tester(condition, { except } = {}) {
|
6240
6180
|
let testFn;
|
@@ -6252,8 +6192,7 @@ up.Request = (_a = class Request extends up.Record {
|
|
6252
6192
|
testFn = (_request) => condition;
|
6253
6193
|
}
|
6254
6194
|
if (except) {
|
6255
|
-
|
6256
|
-
return (request) => (request.cacheKey() !== exceptCacheKey) && testFn(request);
|
6195
|
+
return (request) => !up.cache.willHaveSameResponse(request, except) && testFn(request);
|
6257
6196
|
}
|
6258
6197
|
else {
|
6259
6198
|
return testFn;
|
@@ -6267,39 +6206,158 @@ up.Request = (_a = class Request extends up.Record {
|
|
6267
6206
|
|
6268
6207
|
|
6269
6208
|
/***/ }),
|
6270
|
-
/*
|
6271
|
-
/***/ (()
|
6209
|
+
/* 69 */
|
6210
|
+
/***/ (function() {
|
6272
6211
|
|
6273
|
-
|
6274
|
-
|
6275
|
-
|
6212
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
6213
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
6214
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
6215
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
6216
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
6217
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
6218
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
6219
|
+
});
|
6220
|
+
};
|
6221
|
+
const u = up.util;
|
6222
|
+
up.Request.Cache = class Cache {
|
6223
|
+
constructor() {
|
6224
|
+
this.reset();
|
6225
|
+
}
|
6226
|
+
reset() {
|
6227
|
+
this.varyInfo = {};
|
6228
|
+
this.map = new Map();
|
6229
|
+
}
|
6230
|
+
cacheKey(request) {
|
6231
|
+
let influencingHeaders = this.getPreviousInfluencingHeaders(request);
|
6232
|
+
let varyPart = u.flatMap(influencingHeaders, (headerName) => [headerName, request.header(headerName)]);
|
6233
|
+
return [request.description, ...varyPart].join(':');
|
6234
|
+
}
|
6235
|
+
getPreviousInfluencingHeaders(request) {
|
6236
|
+
var _a, _b;
|
6237
|
+
return ((_a = this.varyInfo)[_b = request.description] || (_a[_b] = new Set()));
|
6238
|
+
}
|
6239
|
+
get(request) {
|
6240
|
+
request = this.wrap(request);
|
6241
|
+
let cacheKey = this.cacheKey(request);
|
6242
|
+
let cachedRequest = this.map.get(cacheKey);
|
6243
|
+
if (cachedRequest) {
|
6244
|
+
if (this.isUsable(cachedRequest)) {
|
6245
|
+
return cachedRequest;
|
6246
|
+
}
|
6247
|
+
else {
|
6248
|
+
this.map.delete(cacheKey);
|
6249
|
+
}
|
6250
|
+
}
|
6251
|
+
}
|
6252
|
+
get capacity() {
|
6276
6253
|
return up.network.config.cacheSize;
|
6277
6254
|
}
|
6278
|
-
|
6279
|
-
return up.network.config.cacheEvictAge;
|
6255
|
+
isUsable(request) {
|
6256
|
+
return request.age < up.network.config.cacheEvictAge;
|
6280
6257
|
}
|
6281
|
-
|
6282
|
-
return
|
6258
|
+
put(request) {
|
6259
|
+
return __awaiter(this, void 0, void 0, function* () {
|
6260
|
+
request = this.wrap(request);
|
6261
|
+
this.makeRoom();
|
6262
|
+
let cacheKey = this.updateCacheKey(request);
|
6263
|
+
this.map.set(cacheKey, request);
|
6264
|
+
});
|
6265
|
+
}
|
6266
|
+
updateCacheKey(request) {
|
6267
|
+
let oldCacheKey = this.cacheKey(request);
|
6268
|
+
let { response } = request;
|
6269
|
+
if (response) {
|
6270
|
+
this.mergePreviousHeaderNames(request, response);
|
6271
|
+
let newCacheKey = this.cacheKey(request);
|
6272
|
+
this.renameMapKey(oldCacheKey, newCacheKey);
|
6273
|
+
return newCacheKey;
|
6274
|
+
}
|
6275
|
+
else {
|
6276
|
+
return oldCacheKey;
|
6277
|
+
}
|
6278
|
+
}
|
6279
|
+
renameMapKey(oldKey, newKey) {
|
6280
|
+
if (oldKey !== newKey && this.map.has(oldKey)) {
|
6281
|
+
this.map.set(newKey, this.map.get(oldKey));
|
6282
|
+
this.map.delete(oldKey);
|
6283
|
+
}
|
6284
|
+
}
|
6285
|
+
mergePreviousHeaderNames(request, response) {
|
6286
|
+
let headersInfluencingResponse = response.ownInfluncingHeaders;
|
6287
|
+
if (headersInfluencingResponse.length) {
|
6288
|
+
let previousInfluencingHeaders = this.getPreviousInfluencingHeaders(request);
|
6289
|
+
for (let headerName of headersInfluencingResponse) {
|
6290
|
+
previousInfluencingHeaders.add(headerName);
|
6291
|
+
}
|
6292
|
+
}
|
6293
|
+
}
|
6294
|
+
alias(existingCachedRequest, newRequest) {
|
6295
|
+
existingCachedRequest = this.wrap(existingCachedRequest);
|
6296
|
+
newRequest = this.wrap(newRequest);
|
6297
|
+
this.track(existingCachedRequest, newRequest, { force: true });
|
6298
|
+
this.put(newRequest);
|
6299
|
+
return newRequest;
|
6300
|
+
}
|
6301
|
+
track(existingRequest, newRequest, options = {}) {
|
6302
|
+
var _a;
|
6303
|
+
return __awaiter(this, void 0, void 0, function* () {
|
6304
|
+
newRequest.trackedRequest = existingRequest;
|
6305
|
+
newRequest.state = 'tracking';
|
6306
|
+
let value = yield u.always(existingRequest);
|
6307
|
+
if (value instanceof up.Response) {
|
6308
|
+
if (options.force || this.isCacheCompatible(existingRequest, newRequest)) {
|
6309
|
+
newRequest.fromCache = true;
|
6310
|
+
newRequest.respondWith(value);
|
6311
|
+
u.delegate(newRequest, ['expired', 'state'], () => existingRequest);
|
6312
|
+
}
|
6313
|
+
else {
|
6314
|
+
delete newRequest.trackedRequest;
|
6315
|
+
newRequest.state = 'new';
|
6316
|
+
(_a = options.onIncompatible) === null || _a === void 0 ? void 0 : _a.call(options, newRequest);
|
6317
|
+
}
|
6318
|
+
}
|
6319
|
+
else {
|
6320
|
+
newRequest.state = existingRequest.state;
|
6321
|
+
newRequest.deferred.reject(value);
|
6322
|
+
}
|
6323
|
+
});
|
6324
|
+
}
|
6325
|
+
willHaveSameResponse(existingRequest, newRequest) {
|
6326
|
+
return existingRequest === newRequest || existingRequest === newRequest.trackedRequest;
|
6327
|
+
}
|
6328
|
+
delete(request) {
|
6329
|
+
request = this.wrap(request);
|
6330
|
+
let cacheKey = this.cacheKey(request);
|
6331
|
+
this.map.delete(cacheKey);
|
6283
6332
|
}
|
6284
6333
|
evict(condition = true, testerOptions) {
|
6285
|
-
this.eachMatch(condition, testerOptions, (
|
6334
|
+
this.eachMatch(condition, testerOptions, (request) => this.delete(request));
|
6286
6335
|
}
|
6287
6336
|
expire(condition = true, testerOptions) {
|
6288
|
-
this.eachMatch(condition, testerOptions, (
|
6337
|
+
this.eachMatch(condition, testerOptions, (request) => request.expired = true);
|
6338
|
+
}
|
6339
|
+
makeRoom() {
|
6340
|
+
while (this.map.size >= this.capacity) {
|
6341
|
+
let oldestKey = this.map.keys().next().value;
|
6342
|
+
this.map.delete(oldestKey);
|
6343
|
+
}
|
6289
6344
|
}
|
6290
6345
|
eachMatch(condition = true, testerOptions, fn) {
|
6291
6346
|
let tester = up.Request.tester(condition, testerOptions);
|
6292
|
-
|
6293
|
-
|
6294
|
-
|
6295
|
-
|
6296
|
-
|
6347
|
+
let results = u.filter(this.map.values(), tester);
|
6348
|
+
u.each(results, fn);
|
6349
|
+
}
|
6350
|
+
isCacheCompatible(request1, request2) {
|
6351
|
+
return this.cacheKey(request1) === this.cacheKey(request2);
|
6352
|
+
}
|
6353
|
+
wrap(requestOrOptions) {
|
6354
|
+
return u.wrapValue(up.Request, requestOrOptions);
|
6297
6355
|
}
|
6298
6356
|
};
|
6299
6357
|
|
6300
6358
|
|
6301
6359
|
/***/ }),
|
6302
|
-
/*
|
6360
|
+
/* 70 */
|
6303
6361
|
/***/ (() => {
|
6304
6362
|
|
6305
6363
|
const u = up.util;
|
@@ -6318,7 +6376,6 @@ up.Request.Queue = class Queue {
|
|
6318
6376
|
asap(request) {
|
6319
6377
|
request.runQueuedCallbacks();
|
6320
6378
|
u.always(request, responseOrError => this.onRequestSettled(request, responseOrError));
|
6321
|
-
request.queuedAt = new Date();
|
6322
6379
|
this.scheduleSlowTimer(request);
|
6323
6380
|
this.queueRequest(request);
|
6324
6381
|
u.microtask(() => this.poke());
|
@@ -6330,7 +6387,7 @@ up.Request.Queue = class Queue {
|
|
6330
6387
|
}
|
6331
6388
|
}
|
6332
6389
|
scheduleSlowTimer(request) {
|
6333
|
-
let timeUntilLate = Math.max(request.badResponseTime - request.
|
6390
|
+
let timeUntilLate = Math.max(request.badResponseTime - request.age, 0);
|
6334
6391
|
u.timer(timeUntilLate, () => this.checkLate());
|
6335
6392
|
}
|
6336
6393
|
getMaxConcurrency() {
|
@@ -6352,13 +6409,8 @@ up.Request.Queue = class Queue {
|
|
6352
6409
|
return u.remove(this.queuedRequests, request);
|
6353
6410
|
}
|
6354
6411
|
sendRequestNow(request) {
|
6355
|
-
if (request.
|
6356
|
-
request.abort({ reason: 'Prevented by event listener' });
|
6357
|
-
}
|
6358
|
-
else {
|
6359
|
-
request.normalizeForCaching();
|
6412
|
+
if (request.load()) {
|
6360
6413
|
this.currentRequests.push(request);
|
6361
|
-
request.load();
|
6362
6414
|
}
|
6363
6415
|
}
|
6364
6416
|
onRequestSettled(request, responseOrError) {
|
@@ -6408,13 +6460,13 @@ up.Request.Queue = class Queue {
|
|
6408
6460
|
isLate() {
|
6409
6461
|
const allForegroundRequests = u.reject(this.allRequests, 'background');
|
6410
6462
|
const timerTolerance = 1;
|
6411
|
-
return u.some(allForegroundRequests, request => request.
|
6463
|
+
return u.some(allForegroundRequests, (request) => request.age >= (request.badResponseTime - timerTolerance));
|
6412
6464
|
}
|
6413
6465
|
};
|
6414
6466
|
|
6415
6467
|
|
6416
6468
|
/***/ }),
|
6417
|
-
/*
|
6469
|
+
/* 71 */
|
6418
6470
|
/***/ (() => {
|
6419
6471
|
|
6420
6472
|
const u = up.util;
|
@@ -6453,7 +6505,7 @@ up.Request.FormRenderer = class FormRenderer {
|
|
6453
6505
|
|
6454
6506
|
|
6455
6507
|
/***/ }),
|
6456
|
-
/*
|
6508
|
+
/* 72 */
|
6457
6509
|
/***/ (() => {
|
6458
6510
|
|
6459
6511
|
var _a;
|
@@ -6471,21 +6523,13 @@ up.Request.XHRRenderer = (_a = class XHRRenderer {
|
|
6471
6523
|
xhr.timeout = this.request.timeout;
|
6472
6524
|
}
|
6473
6525
|
xhr.open(this.getMethod(), this.request.url);
|
6474
|
-
const metaProps = this.request.metaProps();
|
6475
|
-
for (let key in metaProps) {
|
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]);
|
6480
|
-
}
|
6481
|
-
let csrfHeader, csrfToken;
|
6482
|
-
if ((csrfHeader = this.request.csrfHeader()) && (csrfToken = this.request.csrfToken())) {
|
6483
|
-
this.addHeader(xhr, csrfHeader, csrfToken);
|
6484
|
-
}
|
6485
|
-
this.addHeader(xhr, up.protocol.headerize('version'), up.version);
|
6486
6526
|
let contentType = this.getContentType();
|
6487
6527
|
if (contentType) {
|
6488
|
-
|
6528
|
+
xhr.setRequestHeader('Content-Type', contentType);
|
6529
|
+
}
|
6530
|
+
for (let headerName in this.request.headers) {
|
6531
|
+
let headerValue = this.request.headers[headerName];
|
6532
|
+
xhr.setRequestHeader(headerName, headerValue);
|
6489
6533
|
}
|
6490
6534
|
Object.assign(xhr, handlers);
|
6491
6535
|
xhr.send(this.getPayload());
|
@@ -6507,12 +6551,6 @@ up.Request.XHRRenderer = (_a = class XHRRenderer {
|
|
6507
6551
|
this.finalizePayload();
|
6508
6552
|
return this.payload;
|
6509
6553
|
}
|
6510
|
-
addHeader(xhr, header, value) {
|
6511
|
-
if (u.isOptions(value) || u.isArray(value)) {
|
6512
|
-
value = JSON.stringify(value);
|
6513
|
-
}
|
6514
|
-
xhr.setRequestHeader(header, value);
|
6515
|
-
}
|
6516
6554
|
finalizePayload() {
|
6517
6555
|
this.payload = this.request.payload;
|
6518
6556
|
this.contentType = this.request.contentType;
|
@@ -6539,7 +6577,7 @@ up.Request.XHRRenderer = (_a = class XHRRenderer {
|
|
6539
6577
|
|
6540
6578
|
|
6541
6579
|
/***/ }),
|
6542
|
-
/*
|
6580
|
+
/* 73 */
|
6543
6581
|
/***/ (() => {
|
6544
6582
|
|
6545
6583
|
const u = up.util;
|
@@ -6579,6 +6617,10 @@ up.Response = class Response extends up.Record {
|
|
6579
6617
|
var _a;
|
6580
6618
|
return this.headers[name] || ((_a = this.xhr) === null || _a === void 0 ? void 0 : _a.getResponseHeader(name));
|
6581
6619
|
}
|
6620
|
+
get ownInfluncingHeaders() {
|
6621
|
+
let influencingHeaders = up.protocol.influencingHeadersFromResponse(this);
|
6622
|
+
return u.filter(influencingHeaders, (headerName) => this.request.header(headerName));
|
6623
|
+
}
|
6582
6624
|
get contentType() {
|
6583
6625
|
return this.header('Content-Type');
|
6584
6626
|
}
|
@@ -6612,7 +6654,7 @@ up.Response = class Response extends up.Record {
|
|
6612
6654
|
|
6613
6655
|
|
6614
6656
|
/***/ }),
|
6615
|
-
/*
|
6657
|
+
/* 74 */
|
6616
6658
|
/***/ (() => {
|
6617
6659
|
|
6618
6660
|
var _a;
|
@@ -6620,12 +6662,13 @@ const u = up.util;
|
|
6620
6662
|
const e = up.element;
|
6621
6663
|
up.ResponseDoc = (_a = class ResponseDoc {
|
6622
6664
|
constructor(options) {
|
6623
|
-
this.noscriptWrapper = new up.HTMLWrapper('noscript');
|
6624
|
-
this.scriptWrapper = new up.HTMLWrapper('script');
|
6625
6665
|
this.root =
|
6626
6666
|
this.parseDocument(options) ||
|
6627
6667
|
this.parseFragment(options) ||
|
6628
6668
|
this.parseContent(options);
|
6669
|
+
if (!up.fragment.config.runScripts) {
|
6670
|
+
this.root.querySelectorAll('script').forEach((e) => e.remove());
|
6671
|
+
}
|
6629
6672
|
this.cspNonces = options.cspNonces;
|
6630
6673
|
if (options.origin) {
|
6631
6674
|
let originSelector = up.fragment.tryToTarget(options.origin);
|
@@ -6635,7 +6678,11 @@ up.ResponseDoc = (_a = class ResponseDoc {
|
|
6635
6678
|
}
|
6636
6679
|
}
|
6637
6680
|
parseDocument(options) {
|
6638
|
-
|
6681
|
+
let document = this.parse(options.document, e.createBrokenDocumentFromHTML);
|
6682
|
+
if (document) {
|
6683
|
+
this.scriptishNeedFix = true;
|
6684
|
+
return document;
|
6685
|
+
}
|
6639
6686
|
}
|
6640
6687
|
parseContent(options) {
|
6641
6688
|
let content = options.content || '';
|
@@ -6643,7 +6690,6 @@ up.ResponseDoc = (_a = class ResponseDoc {
|
|
6643
6690
|
target = u.map(up.fragment.parseTargetSteps(target), 'selector').join(',');
|
6644
6691
|
const matchingElement = e.createFromSelector(target);
|
6645
6692
|
if (u.isString(content)) {
|
6646
|
-
content = this.wrapHTML(content);
|
6647
6693
|
matchingElement.innerHTML = content;
|
6648
6694
|
}
|
6649
6695
|
else {
|
@@ -6656,7 +6702,6 @@ up.ResponseDoc = (_a = class ResponseDoc {
|
|
6656
6702
|
}
|
6657
6703
|
parse(value, parseFn = e.createFromHTML) {
|
6658
6704
|
if (u.isString(value)) {
|
6659
|
-
value = this.wrapHTML(value);
|
6660
6705
|
value = parseFn(value);
|
6661
6706
|
}
|
6662
6707
|
return value;
|
@@ -6664,19 +6709,9 @@ up.ResponseDoc = (_a = class ResponseDoc {
|
|
6664
6709
|
rootSelector() {
|
6665
6710
|
return up.fragment.toTarget(this.root);
|
6666
6711
|
}
|
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
6712
|
getTitle() {
|
6678
6713
|
var _a;
|
6679
|
-
return (_a = this.root.querySelector(
|
6714
|
+
return (_a = this.root.querySelector('head title')) === null || _a === void 0 ? void 0 : _a.textContent;
|
6680
6715
|
}
|
6681
6716
|
select(selector) {
|
6682
6717
|
let finder = new up.FragmentFinder({
|
@@ -6687,9 +6722,10 @@ up.ResponseDoc = (_a = class ResponseDoc {
|
|
6687
6722
|
return finder.find();
|
6688
6723
|
}
|
6689
6724
|
finalizeElement(element) {
|
6690
|
-
this.noscriptWrapper.unwrap(element);
|
6691
6725
|
up.NonceableCallback.adoptNonces(element, this.cspNonces);
|
6692
|
-
this.
|
6726
|
+
if (this.scriptishNeedFix) {
|
6727
|
+
element.querySelectorAll('noscript, script').forEach(e.fixScriptish);
|
6728
|
+
}
|
6693
6729
|
}
|
6694
6730
|
},
|
6695
6731
|
(() => {
|
@@ -6699,7 +6735,7 @@ up.ResponseDoc = (_a = class ResponseDoc {
|
|
6699
6735
|
|
6700
6736
|
|
6701
6737
|
/***/ }),
|
6702
|
-
/*
|
6738
|
+
/* 75 */
|
6703
6739
|
/***/ (() => {
|
6704
6740
|
|
6705
6741
|
const e = up.element;
|
@@ -6794,7 +6830,7 @@ up.RevealMotion = class RevealMotion {
|
|
6794
6830
|
|
6795
6831
|
|
6796
6832
|
/***/ }),
|
6797
|
-
/*
|
6833
|
+
/* 76 */
|
6798
6834
|
/***/ (() => {
|
6799
6835
|
|
6800
6836
|
const u = up.util;
|
@@ -6835,7 +6871,7 @@ up.Selector = class Selector {
|
|
6835
6871
|
|
6836
6872
|
|
6837
6873
|
/***/ }),
|
6838
|
-
/*
|
6874
|
+
/* 77 */
|
6839
6875
|
/***/ (() => {
|
6840
6876
|
|
6841
6877
|
const u = up.util;
|
@@ -6956,7 +6992,7 @@ up.Tether = class Tether {
|
|
6956
6992
|
|
6957
6993
|
|
6958
6994
|
/***/ }),
|
6959
|
-
/*
|
6995
|
+
/* 78 */
|
6960
6996
|
/***/ (() => {
|
6961
6997
|
|
6962
6998
|
const u = up.util;
|
@@ -7037,7 +7073,7 @@ up.URLPattern = class URLPattern {
|
|
7037
7073
|
|
7038
7074
|
|
7039
7075
|
/***/ }),
|
7040
|
-
/*
|
7076
|
+
/* 79 */
|
7041
7077
|
/***/ (() => {
|
7042
7078
|
|
7043
7079
|
up.framework = (function () {
|
@@ -7121,7 +7157,7 @@ up.boot = up.framework.boot;
|
|
7121
7157
|
|
7122
7158
|
|
7123
7159
|
/***/ }),
|
7124
|
-
/*
|
7160
|
+
/* 80 */
|
7125
7161
|
/***/ (() => {
|
7126
7162
|
|
7127
7163
|
up.event = (function () {
|
@@ -7224,7 +7260,7 @@ up.emit = up.event.emit;
|
|
7224
7260
|
|
7225
7261
|
|
7226
7262
|
/***/ }),
|
7227
|
-
/*
|
7263
|
+
/* 81 */
|
7228
7264
|
/***/ (() => {
|
7229
7265
|
|
7230
7266
|
up.protocol = (function () {
|
@@ -7240,6 +7276,9 @@ up.protocol = (function () {
|
|
7240
7276
|
return parseFn(value);
|
7241
7277
|
}
|
7242
7278
|
};
|
7279
|
+
function targetFromXHR(xhr) {
|
7280
|
+
return extractHeader(xhr, 'target');
|
7281
|
+
}
|
7243
7282
|
function parseModifyCacheValue(value) {
|
7244
7283
|
if (value === 'false') {
|
7245
7284
|
return false;
|
@@ -7261,6 +7300,10 @@ up.protocol = (function () {
|
|
7261
7300
|
function methodFromXHR(xhr) {
|
7262
7301
|
return extractHeader(xhr, 'method', u.normalizeMethod);
|
7263
7302
|
}
|
7303
|
+
function titleFromXHR(xhr) {
|
7304
|
+
var _a, _b, _c;
|
7305
|
+
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);
|
7306
|
+
}
|
7264
7307
|
function eventPlansFromXHR(xhr) {
|
7265
7308
|
return extractHeader(xhr, 'events', JSON.parse);
|
7266
7309
|
}
|
@@ -7276,11 +7319,9 @@ up.protocol = (function () {
|
|
7276
7319
|
function locationFromXHR(xhr) {
|
7277
7320
|
return extractHeader(xhr, 'location') || xhr.responseURL;
|
7278
7321
|
}
|
7279
|
-
function
|
7280
|
-
|
7281
|
-
|
7282
|
-
function targetFromXHR(xhr) {
|
7283
|
-
return extractHeader(xhr, 'target');
|
7322
|
+
function influencingHeadersFromResponse(response) {
|
7323
|
+
let varyHeaderValue = response.header('Vary');
|
7324
|
+
return u.parseTokens(varyHeaderValue, { separator: 'comma' });
|
7284
7325
|
}
|
7285
7326
|
const config = new up.Config(() => ({
|
7286
7327
|
methodParam: '_method',
|
@@ -7356,12 +7397,13 @@ up.protocol = (function () {
|
|
7356
7397
|
headerize,
|
7357
7398
|
wrapMethod,
|
7358
7399
|
cspNoncesFromHeader,
|
7400
|
+
influencingHeadersFromResponse,
|
7359
7401
|
};
|
7360
7402
|
})();
|
7361
7403
|
|
7362
7404
|
|
7363
7405
|
/***/ }),
|
7364
|
-
/*
|
7406
|
+
/* 82 */
|
7365
7407
|
/***/ (() => {
|
7366
7408
|
|
7367
7409
|
up.log = (function () {
|
@@ -7447,7 +7489,7 @@ up.warn = up.log.warn;
|
|
7447
7489
|
|
7448
7490
|
|
7449
7491
|
/***/ }),
|
7450
|
-
/*
|
7492
|
+
/* 83 */
|
7451
7493
|
/***/ (() => {
|
7452
7494
|
|
7453
7495
|
up.syntax = (function () {
|
@@ -7593,7 +7635,7 @@ up.hello = up.syntax.hello;
|
|
7593
7635
|
|
7594
7636
|
|
7595
7637
|
/***/ }),
|
7596
|
-
/*
|
7638
|
+
/* 84 */
|
7597
7639
|
/***/ (() => {
|
7598
7640
|
|
7599
7641
|
up.history = (function () {
|
@@ -7663,7 +7705,7 @@ up.history = (function () {
|
|
7663
7705
|
}
|
7664
7706
|
function restoreStateOnPop(state) {
|
7665
7707
|
if (!(state === null || state === void 0 ? void 0 : state.up)) {
|
7666
|
-
up.puts('
|
7708
|
+
up.puts('popstate', 'Ignoring a history state not owned by Unpoly');
|
7667
7709
|
return;
|
7668
7710
|
}
|
7669
7711
|
let location = currentLocation();
|
@@ -7730,10 +7772,10 @@ up.history = (function () {
|
|
7730
7772
|
|
7731
7773
|
|
7732
7774
|
/***/ }),
|
7733
|
-
/*
|
7775
|
+
/* 85 */
|
7734
7776
|
/***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
|
7735
7777
|
|
7736
|
-
__webpack_require__(
|
7778
|
+
__webpack_require__(86);
|
7737
7779
|
const u = up.util;
|
7738
7780
|
const e = up.element;
|
7739
7781
|
up.fragment = (function () {
|
@@ -7784,7 +7826,7 @@ up.fragment = (function () {
|
|
7784
7826
|
autoRevalidate: (response) => response.expired,
|
7785
7827
|
skipResponse: defaultSkipResponse
|
7786
7828
|
}));
|
7787
|
-
u.delegate(config, 'mainTargets', () => up.layer.config.any);
|
7829
|
+
u.delegate(config, ['mainTargets'], () => up.layer.config.any);
|
7788
7830
|
function reset() {
|
7789
7831
|
config.reset();
|
7790
7832
|
}
|
@@ -8251,20 +8293,20 @@ up.destroy = up.fragment.destroy;
|
|
8251
8293
|
up.render = up.fragment.render;
|
8252
8294
|
up.navigate = up.fragment.navigate;
|
8253
8295
|
up.visit = up.fragment.visit;
|
8254
|
-
u.delegate(up, 'context', () => up.layer.current);
|
8296
|
+
u.delegate(up, ['context'], () => up.layer.current);
|
8255
8297
|
|
8256
8298
|
|
8257
8299
|
/***/ }),
|
8258
|
-
/*
|
8300
|
+
/* 86 */
|
8259
8301
|
/***/ (() => {
|
8260
8302
|
|
8261
8303
|
|
8262
8304
|
|
8263
8305
|
/***/ }),
|
8264
|
-
/*
|
8306
|
+
/* 87 */
|
8265
8307
|
/***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
|
8266
8308
|
|
8267
|
-
__webpack_require__(
|
8309
|
+
__webpack_require__(88);
|
8268
8310
|
up.viewport = (function () {
|
8269
8311
|
const u = up.util;
|
8270
8312
|
const e = up.element;
|
@@ -8447,7 +8489,7 @@ up.viewport = (function () {
|
|
8447
8489
|
}
|
8448
8490
|
}
|
8449
8491
|
function newStateCache() {
|
8450
|
-
return new up.
|
8492
|
+
return new up.FIFOCache({ capacity: 30, normalizeKey: up.history.normalizeURL });
|
8451
8493
|
}
|
8452
8494
|
function parseOptions(args) {
|
8453
8495
|
const options = u.copy(u.extractOptions(args));
|
@@ -8586,13 +8628,13 @@ up.reveal = up.viewport.reveal;
|
|
8586
8628
|
|
8587
8629
|
|
8588
8630
|
/***/ }),
|
8589
|
-
/*
|
8631
|
+
/* 88 */
|
8590
8632
|
/***/ (() => {
|
8591
8633
|
|
8592
8634
|
|
8593
8635
|
|
8594
8636
|
/***/ }),
|
8595
|
-
/*
|
8637
|
+
/* 89 */
|
8596
8638
|
/***/ (function() {
|
8597
8639
|
|
8598
8640
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
@@ -8858,10 +8900,10 @@ up.animate = up.motion.animate;
|
|
8858
8900
|
|
8859
8901
|
|
8860
8902
|
/***/ }),
|
8861
|
-
/*
|
8903
|
+
/* 90 */
|
8862
8904
|
/***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
|
8863
8905
|
|
8864
|
-
__webpack_require__(
|
8906
|
+
__webpack_require__(91);
|
8865
8907
|
const u = up.util;
|
8866
8908
|
up.network = (function () {
|
8867
8909
|
const config = new up.Config(() => ({
|
@@ -8877,7 +8919,6 @@ up.network = (function () {
|
|
8877
8919
|
autoCache(request) { return request.isSafe(); },
|
8878
8920
|
expireCache(request, _response) { return !request.isSafe(); },
|
8879
8921
|
evictCache: false,
|
8880
|
-
requestMetaKeys: ['target', 'failTarget', 'mode', 'failMode', 'context', 'failContext'],
|
8881
8922
|
progressBar: true,
|
8882
8923
|
timeout: 90000,
|
8883
8924
|
}));
|
@@ -8888,14 +8929,14 @@ up.network = (function () {
|
|
8888
8929
|
abortRequests();
|
8889
8930
|
queue.reset();
|
8890
8931
|
config.reset();
|
8891
|
-
cache.
|
8932
|
+
cache.reset();
|
8892
8933
|
progressBar === null || progressBar === void 0 ? void 0 : progressBar.destroy();
|
8893
8934
|
progressBar = null;
|
8894
8935
|
}
|
8895
8936
|
function makeRequest(...args) {
|
8896
8937
|
const options = parseRequestOptions(args);
|
8897
8938
|
const request = new up.Request(options);
|
8898
|
-
|
8939
|
+
processRequest(request);
|
8899
8940
|
return request;
|
8900
8941
|
}
|
8901
8942
|
function parseRequestOptions(args) {
|
@@ -8907,31 +8948,31 @@ up.network = (function () {
|
|
8907
8948
|
(_b = (_a = up.migrate).handleRequestOptions) === null || _b === void 0 ? void 0 : _b.call(_a, options);
|
8908
8949
|
return options;
|
8909
8950
|
}
|
8910
|
-
function
|
8951
|
+
function processRequest(request) {
|
8952
|
+
useCachedRequest(request) || queueRequest(request);
|
8953
|
+
}
|
8954
|
+
function useCachedRequest(newRequest) {
|
8911
8955
|
let cachedRequest;
|
8912
|
-
if (
|
8913
|
-
up.puts('up.request()', 'Re-using previous request to %s
|
8914
|
-
if (!
|
8956
|
+
if (newRequest.willCache() && (cachedRequest = cache.get(newRequest))) {
|
8957
|
+
up.puts('up.request()', 'Re-using previous request to %s', newRequest.description);
|
8958
|
+
if (!newRequest.background) {
|
8915
8959
|
queue.promoteToForeground(cachedRequest);
|
8916
8960
|
}
|
8917
|
-
|
8918
|
-
request.fromCache = true;
|
8961
|
+
cache.track(cachedRequest, newRequest, { onIncompatible: processRequest });
|
8919
8962
|
return true;
|
8920
8963
|
}
|
8921
8964
|
}
|
8922
8965
|
function queueRequest(request) {
|
8923
|
-
if (request.preload && !request.isSafe()) {
|
8924
|
-
up.fail('Will not preload request to %s', request.description);
|
8925
|
-
}
|
8926
8966
|
handleCaching(request);
|
8927
8967
|
queue.asap(request);
|
8928
8968
|
return true;
|
8929
8969
|
}
|
8930
8970
|
function handleCaching(request) {
|
8931
8971
|
if (request.willCache()) {
|
8932
|
-
cache.
|
8972
|
+
cache.put(request);
|
8973
|
+
request.onLoading = () => cache.put(request);
|
8933
8974
|
}
|
8934
|
-
|
8975
|
+
u.always(request, function (response) {
|
8935
8976
|
var _a, _b, _c, _d;
|
8936
8977
|
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
8978
|
if (expireCache) {
|
@@ -8942,7 +8983,7 @@ up.network = (function () {
|
|
8942
8983
|
cache.evict(evictCache, { except: request });
|
8943
8984
|
}
|
8944
8985
|
if (cache.get(request)) {
|
8945
|
-
cache.
|
8986
|
+
cache.put(request);
|
8946
8987
|
}
|
8947
8988
|
if (!response.ok) {
|
8948
8989
|
cache.evict(request);
|
@@ -9008,13 +9049,13 @@ up.cache = up.network.cache;
|
|
9008
9049
|
|
9009
9050
|
|
9010
9051
|
/***/ }),
|
9011
|
-
/*
|
9052
|
+
/* 91 */
|
9012
9053
|
/***/ (() => {
|
9013
9054
|
|
9014
9055
|
|
9015
9056
|
|
9016
9057
|
/***/ }),
|
9017
|
-
/*
|
9058
|
+
/* 92 */
|
9018
9059
|
/***/ (function(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) {
|
9019
9060
|
|
9020
9061
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
@@ -9026,7 +9067,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
9026
9067
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
9027
9068
|
});
|
9028
9069
|
};
|
9029
|
-
__webpack_require__(
|
9070
|
+
__webpack_require__(93);
|
9030
9071
|
const u = up.util;
|
9031
9072
|
const e = up.element;
|
9032
9073
|
up.layer = (function () {
|
@@ -9267,16 +9308,16 @@ up.layer = (function () {
|
|
9267
9308
|
|
9268
9309
|
|
9269
9310
|
/***/ }),
|
9270
|
-
/*
|
9311
|
+
/* 93 */
|
9271
9312
|
/***/ (() => {
|
9272
9313
|
|
9273
9314
|
|
9274
9315
|
|
9275
9316
|
/***/ }),
|
9276
|
-
/*
|
9317
|
+
/* 94 */
|
9277
9318
|
/***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
|
9278
9319
|
|
9279
|
-
__webpack_require__(
|
9320
|
+
__webpack_require__(95);
|
9280
9321
|
up.link = (function () {
|
9281
9322
|
const u = up.util;
|
9282
9323
|
const e = up.element;
|
@@ -9425,16 +9466,22 @@ up.link = (function () {
|
|
9425
9466
|
}
|
9426
9467
|
function preload(link, options) {
|
9427
9468
|
link = up.fragment.get(link);
|
9428
|
-
|
9429
|
-
|
9469
|
+
let issue = preloadIssue(link);
|
9470
|
+
if (issue) {
|
9471
|
+
return Promise.reject(new up.Error(issue));
|
9430
9472
|
}
|
9431
9473
|
const guardEvent = up.event.build('up:link:preload', { log: ['Preloading link %o', link] });
|
9432
9474
|
return follow(link, Object.assign(Object.assign({ abortable: false }, options), { guardEvent, preload: true }));
|
9433
9475
|
}
|
9434
|
-
function
|
9435
|
-
|
9436
|
-
|
9476
|
+
function preloadIssue(link) {
|
9477
|
+
if (!u.evalAutoOption(config.preloadEnabled, autoPreloadEnabled, link)) {
|
9478
|
+
return 'Preloading is disabled';
|
9479
|
+
}
|
9480
|
+
else if (!isSafe(link)) {
|
9481
|
+
return 'Will not preload an unsafe link';
|
9482
|
+
}
|
9437
9483
|
}
|
9484
|
+
const autoPreloadEnabled = u.negate(up.network.shouldReduceRequests);
|
9438
9485
|
function followMethod(link, options = {}) {
|
9439
9486
|
return u.normalizeMethod(options.method || link.getAttribute('up-method') || link.getAttribute('data-method'));
|
9440
9487
|
}
|
@@ -9561,13 +9608,13 @@ up.follow = up.link.follow;
|
|
9561
9608
|
|
9562
9609
|
|
9563
9610
|
/***/ }),
|
9564
|
-
/*
|
9611
|
+
/* 95 */
|
9565
9612
|
/***/ (() => {
|
9566
9613
|
|
9567
9614
|
|
9568
9615
|
|
9569
9616
|
/***/ }),
|
9570
|
-
/*
|
9617
|
+
/* 96 */
|
9571
9618
|
/***/ (() => {
|
9572
9619
|
|
9573
9620
|
up.form = (function () {
|
@@ -9967,7 +10014,7 @@ up.validate = up.form.validate;
|
|
9967
10014
|
|
9968
10015
|
|
9969
10016
|
/***/ }),
|
9970
|
-
/*
|
10017
|
+
/* 97 */
|
9971
10018
|
/***/ (() => {
|
9972
10019
|
|
9973
10020
|
up.feedback = (function () {
|
@@ -10084,7 +10131,7 @@ up.feedback = (function () {
|
|
10084
10131
|
|
10085
10132
|
|
10086
10133
|
/***/ }),
|
10087
|
-
/*
|
10134
|
+
/* 98 */
|
10088
10135
|
/***/ (() => {
|
10089
10136
|
|
10090
10137
|
up.radio = (function () {
|
@@ -10162,7 +10209,7 @@ up.radio = (function () {
|
|
10162
10209
|
|
10163
10210
|
|
10164
10211
|
/***/ }),
|
10165
|
-
/*
|
10212
|
+
/* 99 */
|
10166
10213
|
/***/ (() => {
|
10167
10214
|
|
10168
10215
|
(function () {
|
@@ -10300,16 +10347,15 @@ __webpack_require__(82);
|
|
10300
10347
|
__webpack_require__(83);
|
10301
10348
|
__webpack_require__(84);
|
10302
10349
|
__webpack_require__(85);
|
10303
|
-
__webpack_require__(
|
10304
|
-
__webpack_require__(
|
10350
|
+
__webpack_require__(87);
|
10351
|
+
__webpack_require__(89);
|
10305
10352
|
__webpack_require__(90);
|
10306
|
-
__webpack_require__(
|
10307
|
-
__webpack_require__(
|
10308
|
-
__webpack_require__(
|
10353
|
+
__webpack_require__(92);
|
10354
|
+
__webpack_require__(94);
|
10355
|
+
__webpack_require__(96);
|
10309
10356
|
__webpack_require__(97);
|
10310
10357
|
__webpack_require__(98);
|
10311
10358
|
__webpack_require__(99);
|
10312
|
-
__webpack_require__(100);
|
10313
10359
|
up.framework.onEvaled();
|
10314
10360
|
|
10315
10361
|
})();
|