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.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) {
|
@@ -308,10 +309,11 @@ up.util = (function () {
|
|
308
309
|
function some(list, tester) {
|
309
310
|
return !!findResult(list, tester);
|
310
311
|
}
|
311
|
-
function findResult(
|
312
|
+
function findResult(list, tester) {
|
312
313
|
tester = iteratee(tester);
|
313
|
-
|
314
|
-
|
314
|
+
let i = 0;
|
315
|
+
for (let item of list) {
|
316
|
+
const result = tester(item, i++);
|
315
317
|
if (result) {
|
316
318
|
return result;
|
317
319
|
}
|
@@ -320,8 +322,9 @@ up.util = (function () {
|
|
320
322
|
function every(list, tester) {
|
321
323
|
tester = iteratee(tester);
|
322
324
|
let match = true;
|
323
|
-
|
324
|
-
|
325
|
+
let i = 0;
|
326
|
+
for (let item of list) {
|
327
|
+
if (!tester(item, i++)) {
|
325
328
|
match = false;
|
326
329
|
break;
|
327
330
|
}
|
@@ -493,7 +496,7 @@ up.util = (function () {
|
|
493
496
|
function flatMap(array, block) {
|
494
497
|
return flatten(map(array, block));
|
495
498
|
}
|
496
|
-
function always(promise, callback) {
|
499
|
+
function always(promise, callback = identity) {
|
497
500
|
return promise.then(callback, callback);
|
498
501
|
}
|
499
502
|
function newDeferred() {
|
@@ -595,7 +598,7 @@ up.util = (function () {
|
|
595
598
|
Object.defineProperty(object, prop, { get });
|
596
599
|
}
|
597
600
|
function defineDelegates(object, props, targetProvider) {
|
598
|
-
|
601
|
+
for (let prop of props) {
|
599
602
|
Object.defineProperty(object, prop, {
|
600
603
|
get() {
|
601
604
|
const target = targetProvider.call(this);
|
@@ -610,7 +613,7 @@ up.util = (function () {
|
|
610
613
|
target[prop] = newValue;
|
611
614
|
}
|
612
615
|
});
|
613
|
-
}
|
616
|
+
}
|
614
617
|
}
|
615
618
|
function stringifyArg(arg) {
|
616
619
|
let string;
|
@@ -705,6 +708,14 @@ up.util = (function () {
|
|
705
708
|
};
|
706
709
|
}
|
707
710
|
}
|
711
|
+
function safeStringifyJSON(value) {
|
712
|
+
let json = JSON.stringify(value);
|
713
|
+
return escapeHighASCII(json);
|
714
|
+
}
|
715
|
+
function escapeHighASCII(string) {
|
716
|
+
let unicodeEscape = (char) => "\\u" + char.charCodeAt(0).toString(16).padStart(4, '0');
|
717
|
+
return string.replace(/[^\x00-\x7F]/g, unicodeEscape);
|
718
|
+
}
|
708
719
|
return {
|
709
720
|
parseURL,
|
710
721
|
normalizeURL,
|
@@ -800,7 +811,8 @@ up.util = (function () {
|
|
800
811
|
sprintf,
|
801
812
|
renameKeys,
|
802
813
|
negate,
|
803
|
-
memoizeMethod
|
814
|
+
memoizeMethod,
|
815
|
+
safeStringifyJSON,
|
804
816
|
};
|
805
817
|
})();
|
806
818
|
|
@@ -1159,9 +1171,17 @@ up.element = (function () {
|
|
1159
1171
|
klass = klass.replace(/:/g, '\\:');
|
1160
1172
|
return `.${klass}`;
|
1161
1173
|
}
|
1162
|
-
function
|
1174
|
+
function createBrokenDocumentFromHTML(html) {
|
1163
1175
|
return new DOMParser().parseFromString(html, 'text/html');
|
1164
1176
|
}
|
1177
|
+
function fixScriptish(scriptish) {
|
1178
|
+
let clone = document.createElement(scriptish.tagName);
|
1179
|
+
for (let { name, value } of scriptish.attributes) {
|
1180
|
+
clone.setAttribute(name, value);
|
1181
|
+
}
|
1182
|
+
clone.textContent = scriptish.innerHTML;
|
1183
|
+
scriptish.replaceWith(clone);
|
1184
|
+
}
|
1165
1185
|
function createFromHTML(html) {
|
1166
1186
|
const range = document.createRange();
|
1167
1187
|
range.setStart(document.body, 0);
|
@@ -1423,7 +1443,8 @@ up.element = (function () {
|
|
1423
1443
|
isSingleton,
|
1424
1444
|
attrSelector,
|
1425
1445
|
tagName: elementTagName,
|
1426
|
-
|
1446
|
+
createBrokenDocumentFromHTML,
|
1447
|
+
fixScriptish,
|
1427
1448
|
createFromHTML,
|
1428
1449
|
get root() { return getRoot(); },
|
1429
1450
|
paint,
|
@@ -1623,82 +1644,26 @@ up.LogConfig = class LogConfig extends up.Config {
|
|
1623
1644
|
/***/ (() => {
|
1624
1645
|
|
1625
1646
|
const u = up.util;
|
1626
|
-
up.
|
1627
|
-
constructor(
|
1628
|
-
this.config = config;
|
1647
|
+
up.FIFOCache = class FIFOCache {
|
1648
|
+
constructor({ capacity = 10, normalizeKey = u.identity } = {}) {
|
1629
1649
|
this.map = new Map();
|
1650
|
+
this.capacity = capacity;
|
1651
|
+
this.normalizeKey = normalizeKey;
|
1630
1652
|
}
|
1631
|
-
|
1632
|
-
|
1633
|
-
|
1634
|
-
maxSize() {
|
1635
|
-
return u.evalOption(this.config.size);
|
1636
|
-
}
|
1637
|
-
evictAge() {
|
1638
|
-
return u.evalOption(this.config.evictAge);
|
1639
|
-
}
|
1640
|
-
normalizeStoreKey(key) {
|
1641
|
-
return key;
|
1642
|
-
}
|
1643
|
-
isDisabled() {
|
1644
|
-
return this.maxSize() === 0 || this.evictAge() === 0;
|
1645
|
-
}
|
1646
|
-
evict() {
|
1647
|
-
this.map.clear();
|
1648
|
-
}
|
1649
|
-
records() {
|
1650
|
-
return this.map.values();
|
1651
|
-
}
|
1652
|
-
makeRoomForAnotherRecord() {
|
1653
|
-
const maxSize = this.maxSize();
|
1654
|
-
const currentSize = this.size();
|
1655
|
-
if (!maxSize || currentSize < maxSize)
|
1656
|
-
return;
|
1657
|
-
let records = Array.from(this.records());
|
1658
|
-
records.sort((a, b) => b.createdAt - a.createdAt);
|
1659
|
-
const overflow = currentSize - maxSize + 1;
|
1660
|
-
for (let i = 0; i < overflow; i++) {
|
1661
|
-
let key = records.pop().key;
|
1662
|
-
this.map.delete(key);
|
1663
|
-
}
|
1664
|
-
}
|
1665
|
-
alias(oldKey, newKey) {
|
1666
|
-
const value = this.get(oldKey);
|
1667
|
-
if (u.isDefined(value)) {
|
1668
|
-
this.set(newKey, value);
|
1669
|
-
}
|
1653
|
+
get(key) {
|
1654
|
+
key = this.normalizeKey(key);
|
1655
|
+
return this.map.get(key);
|
1670
1656
|
}
|
1671
1657
|
set(key, value) {
|
1672
|
-
if (this.
|
1673
|
-
|
1674
|
-
|
1675
|
-
key = this.normalizeStoreKey(key);
|
1676
|
-
const createdAt = new Date();
|
1677
|
-
const record = { key, value, createdAt };
|
1678
|
-
this.map.set(key, record);
|
1679
|
-
}
|
1680
|
-
remove(key) {
|
1681
|
-
key = this.normalizeStoreKey(key);
|
1682
|
-
this.map.delete(key);
|
1683
|
-
}
|
1684
|
-
isUsable(record) {
|
1685
|
-
const evictAge = this.evictAge();
|
1686
|
-
if (!evictAge)
|
1687
|
-
return true;
|
1688
|
-
const age = new Date() - record.createdAt;
|
1689
|
-
return age < evictAge;
|
1690
|
-
}
|
1691
|
-
get(key) {
|
1692
|
-
const storeKey = this.normalizeStoreKey(key);
|
1693
|
-
let record = this.map.get(storeKey);
|
1694
|
-
if (record) {
|
1695
|
-
if (this.isUsable(record)) {
|
1696
|
-
return record.value;
|
1697
|
-
}
|
1698
|
-
else {
|
1699
|
-
this.remove(key);
|
1700
|
-
}
|
1658
|
+
if (this.map.size === this.capacity) {
|
1659
|
+
let oldestKey = this.map.keys().next().value;
|
1660
|
+
this.map.delete(oldestKey);
|
1701
1661
|
}
|
1662
|
+
key = this.normalizeKey(key);
|
1663
|
+
this.map.set(key, value);
|
1664
|
+
}
|
1665
|
+
clear() {
|
1666
|
+
this.map.clear();
|
1702
1667
|
}
|
1703
1668
|
};
|
1704
1669
|
|
@@ -4098,44 +4063,6 @@ up.FragmentScrolling = class FragmentScrolling extends up.FragmentProcessor {
|
|
4098
4063
|
/* 47 */
|
4099
4064
|
/***/ (() => {
|
4100
4065
|
|
4101
|
-
const u = up.util;
|
4102
|
-
const e = up.element;
|
4103
|
-
up.HTMLWrapper = class HTMLWrapper {
|
4104
|
-
constructor(tagName) {
|
4105
|
-
this.tagName = tagName;
|
4106
|
-
const openTag = `<${this.tagName}[^>]*>`;
|
4107
|
-
const closeTag = `</${this.tagName}>`;
|
4108
|
-
const innerHTML = "(.|\\s)*?";
|
4109
|
-
this.pattern = new RegExp(openTag + innerHTML + closeTag, 'ig');
|
4110
|
-
this.attrName = `up-wrapped-${this.tagName}`;
|
4111
|
-
}
|
4112
|
-
strip(html) {
|
4113
|
-
return html.replace(this.pattern, '');
|
4114
|
-
}
|
4115
|
-
wrap(html) {
|
4116
|
-
return html.replace(this.pattern, this.wrapMatch.bind(this));
|
4117
|
-
}
|
4118
|
-
wrapMatch(match) {
|
4119
|
-
this.didWrap = true;
|
4120
|
-
return '<meta name="' + this.attrName + '" value="' + u.escapeHTML(match) + '">';
|
4121
|
-
}
|
4122
|
-
unwrap(element) {
|
4123
|
-
if (!this.didWrap) {
|
4124
|
-
return;
|
4125
|
-
}
|
4126
|
-
for (let wrappedChild of element.querySelectorAll(`meta[name='${this.attrName}']`)) {
|
4127
|
-
const originalHTML = wrappedChild.getAttribute('value');
|
4128
|
-
const restoredElement = e.createFromHTML(originalHTML);
|
4129
|
-
wrappedChild.replaceWith(restoredElement);
|
4130
|
-
}
|
4131
|
-
}
|
4132
|
-
};
|
4133
|
-
|
4134
|
-
|
4135
|
-
/***/ }),
|
4136
|
-
/* 48 */
|
4137
|
-
/***/ (() => {
|
4138
|
-
|
4139
4066
|
const e = up.element;
|
4140
4067
|
const u = up.util;
|
4141
4068
|
up.Layer = class Layer extends up.Record {
|
@@ -4349,11 +4276,14 @@ up.Layer = class Layer extends up.Record {
|
|
4349
4276
|
let focusedElement = document.activeElement;
|
4350
4277
|
return focusedElement !== document.body && this.element.contains(focusedElement);
|
4351
4278
|
}
|
4279
|
+
reset() {
|
4280
|
+
Object.assign(this, this.defaults());
|
4281
|
+
}
|
4352
4282
|
};
|
4353
4283
|
|
4354
4284
|
|
4355
4285
|
/***/ }),
|
4356
|
-
/*
|
4286
|
+
/* 48 */
|
4357
4287
|
/***/ (() => {
|
4358
4288
|
|
4359
4289
|
const e = up.element;
|
@@ -4628,7 +4558,7 @@ up.Layer.Overlay = class Overlay extends up.Layer {
|
|
4628
4558
|
|
4629
4559
|
|
4630
4560
|
/***/ }),
|
4631
|
-
/*
|
4561
|
+
/* 49 */
|
4632
4562
|
/***/ (() => {
|
4633
4563
|
|
4634
4564
|
up.Layer.OverlayWithTether = class OverlayWithTether extends up.Layer.Overlay {
|
@@ -4665,7 +4595,7 @@ up.Layer.OverlayWithTether = class OverlayWithTether extends up.Layer.Overlay {
|
|
4665
4595
|
|
4666
4596
|
|
4667
4597
|
/***/ }),
|
4668
|
-
/*
|
4598
|
+
/* 50 */
|
4669
4599
|
/***/ (() => {
|
4670
4600
|
|
4671
4601
|
var _a;
|
@@ -4703,7 +4633,7 @@ up.Layer.OverlayWithViewport = (_a = class OverlayWithViewport extends up.Layer.
|
|
4703
4633
|
|
4704
4634
|
|
4705
4635
|
/***/ }),
|
4706
|
-
/*
|
4636
|
+
/* 51 */
|
4707
4637
|
/***/ (() => {
|
4708
4638
|
|
4709
4639
|
var _a;
|
@@ -4740,9 +4670,6 @@ up.Layer.Root = (_a = class Root extends up.Layer {
|
|
4740
4670
|
cannotCloseRoot() {
|
4741
4671
|
up.fail('Cannot close the root layer');
|
4742
4672
|
}
|
4743
|
-
reset() {
|
4744
|
-
Object.assign(this, this.defaults());
|
4745
|
-
}
|
4746
4673
|
toString() {
|
4747
4674
|
return "root layer";
|
4748
4675
|
}
|
@@ -4752,7 +4679,7 @@ up.Layer.Root = (_a = class Root extends up.Layer {
|
|
4752
4679
|
|
4753
4680
|
|
4754
4681
|
/***/ }),
|
4755
|
-
/*
|
4682
|
+
/* 52 */
|
4756
4683
|
/***/ (() => {
|
4757
4684
|
|
4758
4685
|
var _a;
|
@@ -4763,7 +4690,7 @@ up.Layer.Modal = (_a = class Modal extends up.Layer.OverlayWithViewport {
|
|
4763
4690
|
|
4764
4691
|
|
4765
4692
|
/***/ }),
|
4766
|
-
/*
|
4693
|
+
/* 53 */
|
4767
4694
|
/***/ (() => {
|
4768
4695
|
|
4769
4696
|
var _a;
|
@@ -4774,7 +4701,7 @@ up.Layer.Popup = (_a = class Popup extends up.Layer.OverlayWithTether {
|
|
4774
4701
|
|
4775
4702
|
|
4776
4703
|
/***/ }),
|
4777
|
-
/*
|
4704
|
+
/* 54 */
|
4778
4705
|
/***/ (() => {
|
4779
4706
|
|
4780
4707
|
var _a;
|
@@ -4785,7 +4712,7 @@ up.Layer.Drawer = (_a = class Drawer extends up.Layer.OverlayWithViewport {
|
|
4785
4712
|
|
4786
4713
|
|
4787
4714
|
/***/ }),
|
4788
|
-
/*
|
4715
|
+
/* 55 */
|
4789
4716
|
/***/ (() => {
|
4790
4717
|
|
4791
4718
|
var _a;
|
@@ -4796,7 +4723,7 @@ up.Layer.Cover = (_a = class Cover extends up.Layer.OverlayWithViewport {
|
|
4796
4723
|
|
4797
4724
|
|
4798
4725
|
/***/ }),
|
4799
|
-
/*
|
4726
|
+
/* 56 */
|
4800
4727
|
/***/ (() => {
|
4801
4728
|
|
4802
4729
|
const u = up.util;
|
@@ -4886,7 +4813,7 @@ up.LayerLookup = class LayerLookup {
|
|
4886
4813
|
|
4887
4814
|
|
4888
4815
|
/***/ }),
|
4889
|
-
/*
|
4816
|
+
/* 57 */
|
4890
4817
|
/***/ (() => {
|
4891
4818
|
|
4892
4819
|
const u = up.util;
|
@@ -4999,7 +4926,7 @@ up.LayerStack = class LayerStack extends Array {
|
|
4999
4926
|
|
5000
4927
|
|
5001
4928
|
/***/ }),
|
5002
|
-
/*
|
4929
|
+
/* 58 */
|
5003
4930
|
/***/ (() => {
|
5004
4931
|
|
5005
4932
|
up.LinkFeedbackURLs = class LinkFeedbackURLs {
|
@@ -5030,7 +4957,7 @@ up.LinkFeedbackURLs = class LinkFeedbackURLs {
|
|
5030
4957
|
|
5031
4958
|
|
5032
4959
|
/***/ }),
|
5033
|
-
/*
|
4960
|
+
/* 59 */
|
5034
4961
|
/***/ (() => {
|
5035
4962
|
|
5036
4963
|
const u = up.util;
|
@@ -5098,7 +5025,7 @@ up.LinkPreloader = class LinkPreloader {
|
|
5098
5025
|
|
5099
5026
|
|
5100
5027
|
/***/ }),
|
5101
|
-
/*
|
5028
|
+
/* 60 */
|
5102
5029
|
/***/ (() => {
|
5103
5030
|
|
5104
5031
|
const u = up.util;
|
@@ -5194,7 +5121,7 @@ up.MotionController = class MotionController {
|
|
5194
5121
|
|
5195
5122
|
|
5196
5123
|
/***/ }),
|
5197
|
-
/*
|
5124
|
+
/* 61 */
|
5198
5125
|
/***/ (() => {
|
5199
5126
|
|
5200
5127
|
const u = up.util;
|
@@ -5286,7 +5213,7 @@ up.NonceableCallback = class NonceableCallback {
|
|
5286
5213
|
|
5287
5214
|
|
5288
5215
|
/***/ }),
|
5289
|
-
/*
|
5216
|
+
/* 62 */
|
5290
5217
|
/***/ (() => {
|
5291
5218
|
|
5292
5219
|
const u = up.util;
|
@@ -5363,7 +5290,7 @@ up.OptionsParser = class OptionsParser {
|
|
5363
5290
|
|
5364
5291
|
|
5365
5292
|
/***/ }),
|
5366
|
-
/*
|
5293
|
+
/* 63 */
|
5367
5294
|
/***/ (() => {
|
5368
5295
|
|
5369
5296
|
const e = up.element;
|
@@ -5431,7 +5358,7 @@ up.OverlayFocus = class OverlayFocus {
|
|
5431
5358
|
|
5432
5359
|
|
5433
5360
|
/***/ }),
|
5434
|
-
/*
|
5361
|
+
/* 64 */
|
5435
5362
|
/***/ (() => {
|
5436
5363
|
|
5437
5364
|
const u = up.util;
|
@@ -5662,7 +5589,7 @@ up.Params = class Params {
|
|
5662
5589
|
|
5663
5590
|
|
5664
5591
|
/***/ }),
|
5665
|
-
/*
|
5592
|
+
/* 65 */
|
5666
5593
|
/***/ (() => {
|
5667
5594
|
|
5668
5595
|
const e = up.element;
|
@@ -5712,7 +5639,7 @@ up.ProgressBar = class ProgressBar {
|
|
5712
5639
|
|
5713
5640
|
|
5714
5641
|
/***/ }),
|
5715
|
-
/*
|
5642
|
+
/* 66 */
|
5716
5643
|
/***/ (() => {
|
5717
5644
|
|
5718
5645
|
const u = up.util;
|
@@ -5836,7 +5763,7 @@ up.RenderOptions = (function () {
|
|
5836
5763
|
|
5837
5764
|
|
5838
5765
|
/***/ }),
|
5839
|
-
/*
|
5766
|
+
/* 67 */
|
5840
5767
|
/***/ (() => {
|
5841
5768
|
|
5842
5769
|
up.RenderResult = class RenderResult extends up.Record {
|
@@ -5864,7 +5791,7 @@ up.RenderResult = class RenderResult extends up.Record {
|
|
5864
5791
|
|
5865
5792
|
|
5866
5793
|
/***/ }),
|
5867
|
-
/*
|
5794
|
+
/* 68 */
|
5868
5795
|
/***/ (() => {
|
5869
5796
|
|
5870
5797
|
var _a;
|
@@ -5876,7 +5803,7 @@ up.Request = (_a = class Request extends up.Record {
|
|
5876
5803
|
if (this.wrapMethod == null) {
|
5877
5804
|
this.wrapMethod = up.network.config.wrapMethod;
|
5878
5805
|
}
|
5879
|
-
this.
|
5806
|
+
this.normalize();
|
5880
5807
|
if ((this.target || this.layer || this.origin) && !options.basic) {
|
5881
5808
|
const layerLookupOptions = { origin: this.origin };
|
5882
5809
|
this.layer = up.layer.get(this.layer, layerLookupOptions);
|
@@ -5888,6 +5815,7 @@ up.Request = (_a = class Request extends up.Record {
|
|
5888
5815
|
}
|
5889
5816
|
this.deferred = u.newDeferred();
|
5890
5817
|
this.badResponseTime ?? (this.badResponseTime = u.evalOption(up.network.config.badResponseTime, this));
|
5818
|
+
this.addAutoHeaders();
|
5891
5819
|
}
|
5892
5820
|
keys() {
|
5893
5821
|
return [
|
@@ -5899,7 +5827,6 @@ up.Request = (_a = class Request extends up.Record {
|
|
5899
5827
|
'failTarget',
|
5900
5828
|
'headers',
|
5901
5829
|
'timeout',
|
5902
|
-
'preload',
|
5903
5830
|
'background',
|
5904
5831
|
'cache',
|
5905
5832
|
'expireCache',
|
@@ -5912,11 +5839,12 @@ up.Request = (_a = class Request extends up.Record {
|
|
5912
5839
|
'failContext',
|
5913
5840
|
'origin',
|
5914
5841
|
'fragments',
|
5915
|
-
'
|
5842
|
+
'builtAt',
|
5916
5843
|
'wrapMethod',
|
5917
5844
|
'contentType',
|
5918
5845
|
'payload',
|
5919
5846
|
'onQueued',
|
5847
|
+
'onLoading',
|
5920
5848
|
'fail',
|
5921
5849
|
'abortable',
|
5922
5850
|
'badResponseTime',
|
@@ -5927,7 +5855,8 @@ up.Request = (_a = class Request extends up.Record {
|
|
5927
5855
|
state: 'new',
|
5928
5856
|
abortable: true,
|
5929
5857
|
headers: {},
|
5930
|
-
timeout: up.network.config.timeout
|
5858
|
+
timeout: up.network.config.timeout,
|
5859
|
+
builtAt: new Date(),
|
5931
5860
|
};
|
5932
5861
|
}
|
5933
5862
|
get xhr() {
|
@@ -5948,10 +5877,7 @@ up.Request = (_a = class Request extends up.Record {
|
|
5948
5877
|
get fragment() {
|
5949
5878
|
return this.fragments?.[0];
|
5950
5879
|
}
|
5951
|
-
|
5952
|
-
u.delegate(this, ['deferred', 'state', 'preload', 'expired'], () => sourceRequest);
|
5953
|
-
}
|
5954
|
-
normalizeForCaching() {
|
5880
|
+
normalize() {
|
5955
5881
|
this.method = u.normalizeMethod(this.method);
|
5956
5882
|
this.extractHashFromURL();
|
5957
5883
|
this.transferParamsToURL();
|
@@ -5998,14 +5924,26 @@ up.Request = (_a = class Request extends up.Record {
|
|
5998
5924
|
load() {
|
5999
5925
|
if (this.state !== 'new')
|
6000
5926
|
return;
|
6001
|
-
this.
|
6002
|
-
|
6003
|
-
|
6004
|
-
|
6005
|
-
|
6006
|
-
|
6007
|
-
|
6008
|
-
|
5927
|
+
if (this.emitLoad()) {
|
5928
|
+
this.state = 'loading';
|
5929
|
+
this.normalize();
|
5930
|
+
this.onLoading?.();
|
5931
|
+
this.expired = false;
|
5932
|
+
new up.Request.XHRRenderer(this).buildAndSend({
|
5933
|
+
onload: () => this.onXHRLoad(),
|
5934
|
+
onerror: () => this.onXHRError(),
|
5935
|
+
ontimeout: () => this.onXHRTimeout(),
|
5936
|
+
onabort: () => this.onXHRAbort()
|
5937
|
+
});
|
5938
|
+
return true;
|
5939
|
+
}
|
5940
|
+
else {
|
5941
|
+
this.abort({ reason: 'Prevented by event listener' });
|
5942
|
+
}
|
5943
|
+
}
|
5944
|
+
emitLoad() {
|
5945
|
+
let event = this.emit('up:request:load', { log: ['Loading %s', this.description] });
|
5946
|
+
return !event.defaultPrevented;
|
6009
5947
|
}
|
6010
5948
|
loadPage() {
|
6011
5949
|
up.network.abort();
|
@@ -6049,18 +5987,19 @@ up.Request = (_a = class Request extends up.Record {
|
|
6049
5987
|
this.emit('up:request:offline', { log: message });
|
6050
5988
|
}
|
6051
5989
|
respondWith(response) {
|
6052
|
-
|
5990
|
+
this.response = response;
|
5991
|
+
if (this.isSettled())
|
6053
5992
|
return;
|
6054
5993
|
this.state = 'loaded';
|
6055
5994
|
if (response.ok) {
|
6056
|
-
|
5995
|
+
this.deferred.resolve(response);
|
6057
5996
|
}
|
6058
5997
|
else {
|
6059
|
-
|
5998
|
+
this.deferred.reject(response);
|
6060
5999
|
}
|
6061
6000
|
}
|
6062
6001
|
isSettled() {
|
6063
|
-
return (this.state !== 'new') && (this.state !== 'loading');
|
6002
|
+
return (this.state !== 'new') && (this.state !== 'loading') && (this.state !== 'tracking');
|
6064
6003
|
}
|
6065
6004
|
csrfHeader() {
|
6066
6005
|
return up.protocol.csrfHeader();
|
@@ -6107,24 +6046,6 @@ up.Request = (_a = class Request extends up.Record {
|
|
6107
6046
|
}
|
6108
6047
|
return new up.Response(responseAttrs);
|
6109
6048
|
}
|
6110
|
-
cacheKey() {
|
6111
|
-
return JSON.stringify([
|
6112
|
-
this.method,
|
6113
|
-
this.url,
|
6114
|
-
this.params.toQuery(),
|
6115
|
-
this.metaProps()
|
6116
|
-
]);
|
6117
|
-
}
|
6118
|
-
metaProps() {
|
6119
|
-
const props = {};
|
6120
|
-
for (let key of u.evalOption(up.network.config.requestMetaKeys, this)) {
|
6121
|
-
const value = this[key];
|
6122
|
-
if (u.isGiven(value)) {
|
6123
|
-
props[key] = value;
|
6124
|
-
}
|
6125
|
-
}
|
6126
|
-
return props;
|
6127
|
-
}
|
6128
6049
|
buildEventEmitter(args) {
|
6129
6050
|
return up.EventEmitter.fromEmitArgs(args, {
|
6130
6051
|
layer: this.layer,
|
@@ -6150,9 +6071,27 @@ up.Request = (_a = class Request extends up.Record {
|
|
6150
6071
|
return u.some(subtreeElements, (subtreeElement) => subtreeElement.contains(fragment));
|
6151
6072
|
});
|
6152
6073
|
}
|
6153
|
-
get
|
6154
|
-
|
6155
|
-
|
6074
|
+
get age() {
|
6075
|
+
return new Date() - this.builtAt;
|
6076
|
+
}
|
6077
|
+
header(name) {
|
6078
|
+
return this.headers[name];
|
6079
|
+
}
|
6080
|
+
addAutoHeaders() {
|
6081
|
+
for (let key of ['target', 'failTarget', 'mode', 'failMode', 'context', 'failContext']) {
|
6082
|
+
this.addAutoHeader(up.protocol.headerize(key), this[key]);
|
6083
|
+
}
|
6084
|
+
let csrfHeader, csrfToken;
|
6085
|
+
if ((csrfHeader = this.csrfHeader()) && (csrfToken = this.csrfToken())) {
|
6086
|
+
this.addAutoHeader(csrfHeader, csrfToken);
|
6087
|
+
}
|
6088
|
+
this.addAutoHeader(up.protocol.headerize('version'), up.version);
|
6089
|
+
}
|
6090
|
+
addAutoHeader(name, value) {
|
6091
|
+
if (u.isOptions(value) || u.isArray(value)) {
|
6092
|
+
value = u.safeStringifyJSON(value);
|
6093
|
+
}
|
6094
|
+
this.headers[name] = value;
|
6156
6095
|
}
|
6157
6096
|
static tester(condition, { except } = {}) {
|
6158
6097
|
let testFn;
|
@@ -6170,8 +6109,7 @@ up.Request = (_a = class Request extends up.Record {
|
|
6170
6109
|
testFn = (_request) => condition;
|
6171
6110
|
}
|
6172
6111
|
if (except) {
|
6173
|
-
|
6174
|
-
return (request) => (request.cacheKey() !== exceptCacheKey) && testFn(request);
|
6112
|
+
return (request) => !up.cache.willHaveSameResponse(request, except) && testFn(request);
|
6175
6113
|
}
|
6176
6114
|
else {
|
6177
6115
|
return testFn;
|
@@ -6185,39 +6123,144 @@ up.Request = (_a = class Request extends up.Record {
|
|
6185
6123
|
|
6186
6124
|
|
6187
6125
|
/***/ }),
|
6188
|
-
/*
|
6126
|
+
/* 69 */
|
6189
6127
|
/***/ (() => {
|
6190
6128
|
|
6191
|
-
|
6192
|
-
up.Request.Cache = class Cache
|
6193
|
-
|
6129
|
+
const u = up.util;
|
6130
|
+
up.Request.Cache = class Cache {
|
6131
|
+
constructor() {
|
6132
|
+
this.reset();
|
6133
|
+
}
|
6134
|
+
reset() {
|
6135
|
+
this.varyInfo = {};
|
6136
|
+
this.map = new Map();
|
6137
|
+
}
|
6138
|
+
cacheKey(request) {
|
6139
|
+
let influencingHeaders = this.getPreviousInfluencingHeaders(request);
|
6140
|
+
let varyPart = u.flatMap(influencingHeaders, (headerName) => [headerName, request.header(headerName)]);
|
6141
|
+
return [request.description, ...varyPart].join(':');
|
6142
|
+
}
|
6143
|
+
getPreviousInfluencingHeaders(request) {
|
6144
|
+
var _a, _b;
|
6145
|
+
return ((_a = this.varyInfo)[_b = request.description] || (_a[_b] = new Set()));
|
6146
|
+
}
|
6147
|
+
get(request) {
|
6148
|
+
request = this.wrap(request);
|
6149
|
+
let cacheKey = this.cacheKey(request);
|
6150
|
+
let cachedRequest = this.map.get(cacheKey);
|
6151
|
+
if (cachedRequest) {
|
6152
|
+
if (this.isUsable(cachedRequest)) {
|
6153
|
+
return cachedRequest;
|
6154
|
+
}
|
6155
|
+
else {
|
6156
|
+
this.map.delete(cacheKey);
|
6157
|
+
}
|
6158
|
+
}
|
6159
|
+
}
|
6160
|
+
get capacity() {
|
6194
6161
|
return up.network.config.cacheSize;
|
6195
6162
|
}
|
6196
|
-
|
6197
|
-
return up.network.config.cacheEvictAge;
|
6163
|
+
isUsable(request) {
|
6164
|
+
return request.age < up.network.config.cacheEvictAge;
|
6165
|
+
}
|
6166
|
+
async put(request) {
|
6167
|
+
request = this.wrap(request);
|
6168
|
+
this.makeRoom();
|
6169
|
+
let cacheKey = this.updateCacheKey(request);
|
6170
|
+
this.map.set(cacheKey, request);
|
6198
6171
|
}
|
6199
|
-
|
6200
|
-
|
6172
|
+
updateCacheKey(request) {
|
6173
|
+
let oldCacheKey = this.cacheKey(request);
|
6174
|
+
let { response } = request;
|
6175
|
+
if (response) {
|
6176
|
+
this.mergePreviousHeaderNames(request, response);
|
6177
|
+
let newCacheKey = this.cacheKey(request);
|
6178
|
+
this.renameMapKey(oldCacheKey, newCacheKey);
|
6179
|
+
return newCacheKey;
|
6180
|
+
}
|
6181
|
+
else {
|
6182
|
+
return oldCacheKey;
|
6183
|
+
}
|
6184
|
+
}
|
6185
|
+
renameMapKey(oldKey, newKey) {
|
6186
|
+
if (oldKey !== newKey && this.map.has(oldKey)) {
|
6187
|
+
this.map.set(newKey, this.map.get(oldKey));
|
6188
|
+
this.map.delete(oldKey);
|
6189
|
+
}
|
6190
|
+
}
|
6191
|
+
mergePreviousHeaderNames(request, response) {
|
6192
|
+
let headersInfluencingResponse = response.ownInfluncingHeaders;
|
6193
|
+
if (headersInfluencingResponse.length) {
|
6194
|
+
let previousInfluencingHeaders = this.getPreviousInfluencingHeaders(request);
|
6195
|
+
for (let headerName of headersInfluencingResponse) {
|
6196
|
+
previousInfluencingHeaders.add(headerName);
|
6197
|
+
}
|
6198
|
+
}
|
6199
|
+
}
|
6200
|
+
alias(existingCachedRequest, newRequest) {
|
6201
|
+
existingCachedRequest = this.wrap(existingCachedRequest);
|
6202
|
+
newRequest = this.wrap(newRequest);
|
6203
|
+
this.track(existingCachedRequest, newRequest, { force: true });
|
6204
|
+
this.put(newRequest);
|
6205
|
+
return newRequest;
|
6206
|
+
}
|
6207
|
+
async track(existingRequest, newRequest, options = {}) {
|
6208
|
+
newRequest.trackedRequest = existingRequest;
|
6209
|
+
newRequest.state = 'tracking';
|
6210
|
+
let value = await u.always(existingRequest);
|
6211
|
+
if (value instanceof up.Response) {
|
6212
|
+
if (options.force || this.isCacheCompatible(existingRequest, newRequest)) {
|
6213
|
+
newRequest.fromCache = true;
|
6214
|
+
newRequest.respondWith(value);
|
6215
|
+
u.delegate(newRequest, ['expired', 'state'], () => existingRequest);
|
6216
|
+
}
|
6217
|
+
else {
|
6218
|
+
delete newRequest.trackedRequest;
|
6219
|
+
newRequest.state = 'new';
|
6220
|
+
options.onIncompatible?.(newRequest);
|
6221
|
+
}
|
6222
|
+
}
|
6223
|
+
else {
|
6224
|
+
newRequest.state = existingRequest.state;
|
6225
|
+
newRequest.deferred.reject(value);
|
6226
|
+
}
|
6227
|
+
}
|
6228
|
+
willHaveSameResponse(existingRequest, newRequest) {
|
6229
|
+
return existingRequest === newRequest || existingRequest === newRequest.trackedRequest;
|
6230
|
+
}
|
6231
|
+
delete(request) {
|
6232
|
+
request = this.wrap(request);
|
6233
|
+
let cacheKey = this.cacheKey(request);
|
6234
|
+
this.map.delete(cacheKey);
|
6201
6235
|
}
|
6202
6236
|
evict(condition = true, testerOptions) {
|
6203
|
-
this.eachMatch(condition, testerOptions, (
|
6237
|
+
this.eachMatch(condition, testerOptions, (request) => this.delete(request));
|
6204
6238
|
}
|
6205
6239
|
expire(condition = true, testerOptions) {
|
6206
|
-
this.eachMatch(condition, testerOptions, (
|
6240
|
+
this.eachMatch(condition, testerOptions, (request) => request.expired = true);
|
6241
|
+
}
|
6242
|
+
makeRoom() {
|
6243
|
+
while (this.map.size >= this.capacity) {
|
6244
|
+
let oldestKey = this.map.keys().next().value;
|
6245
|
+
this.map.delete(oldestKey);
|
6246
|
+
}
|
6207
6247
|
}
|
6208
6248
|
eachMatch(condition = true, testerOptions, fn) {
|
6209
6249
|
let tester = up.Request.tester(condition, testerOptions);
|
6210
|
-
|
6211
|
-
|
6212
|
-
|
6213
|
-
|
6214
|
-
|
6250
|
+
let results = u.filter(this.map.values(), tester);
|
6251
|
+
u.each(results, fn);
|
6252
|
+
}
|
6253
|
+
isCacheCompatible(request1, request2) {
|
6254
|
+
return this.cacheKey(request1) === this.cacheKey(request2);
|
6255
|
+
}
|
6256
|
+
wrap(requestOrOptions) {
|
6257
|
+
return u.wrapValue(up.Request, requestOrOptions);
|
6215
6258
|
}
|
6216
6259
|
};
|
6217
6260
|
|
6218
6261
|
|
6219
6262
|
/***/ }),
|
6220
|
-
/*
|
6263
|
+
/* 70 */
|
6221
6264
|
/***/ (() => {
|
6222
6265
|
|
6223
6266
|
const u = up.util;
|
@@ -6236,7 +6279,6 @@ up.Request.Queue = class Queue {
|
|
6236
6279
|
asap(request) {
|
6237
6280
|
request.runQueuedCallbacks();
|
6238
6281
|
u.always(request, responseOrError => this.onRequestSettled(request, responseOrError));
|
6239
|
-
request.queuedAt = new Date();
|
6240
6282
|
this.scheduleSlowTimer(request);
|
6241
6283
|
this.queueRequest(request);
|
6242
6284
|
u.microtask(() => this.poke());
|
@@ -6248,7 +6290,7 @@ up.Request.Queue = class Queue {
|
|
6248
6290
|
}
|
6249
6291
|
}
|
6250
6292
|
scheduleSlowTimer(request) {
|
6251
|
-
let timeUntilLate = Math.max(request.badResponseTime - request.
|
6293
|
+
let timeUntilLate = Math.max(request.badResponseTime - request.age, 0);
|
6252
6294
|
u.timer(timeUntilLate, () => this.checkLate());
|
6253
6295
|
}
|
6254
6296
|
getMaxConcurrency() {
|
@@ -6270,13 +6312,8 @@ up.Request.Queue = class Queue {
|
|
6270
6312
|
return u.remove(this.queuedRequests, request);
|
6271
6313
|
}
|
6272
6314
|
sendRequestNow(request) {
|
6273
|
-
if (request.
|
6274
|
-
request.abort({ reason: 'Prevented by event listener' });
|
6275
|
-
}
|
6276
|
-
else {
|
6277
|
-
request.normalizeForCaching();
|
6315
|
+
if (request.load()) {
|
6278
6316
|
this.currentRequests.push(request);
|
6279
|
-
request.load();
|
6280
6317
|
}
|
6281
6318
|
}
|
6282
6319
|
onRequestSettled(request, responseOrError) {
|
@@ -6325,13 +6362,13 @@ up.Request.Queue = class Queue {
|
|
6325
6362
|
isLate() {
|
6326
6363
|
const allForegroundRequests = u.reject(this.allRequests, 'background');
|
6327
6364
|
const timerTolerance = 1;
|
6328
|
-
return u.some(allForegroundRequests, request => request.
|
6365
|
+
return u.some(allForegroundRequests, (request) => request.age >= (request.badResponseTime - timerTolerance));
|
6329
6366
|
}
|
6330
6367
|
};
|
6331
6368
|
|
6332
6369
|
|
6333
6370
|
/***/ }),
|
6334
|
-
/*
|
6371
|
+
/* 71 */
|
6335
6372
|
/***/ (() => {
|
6336
6373
|
|
6337
6374
|
const u = up.util;
|
@@ -6370,7 +6407,7 @@ up.Request.FormRenderer = class FormRenderer {
|
|
6370
6407
|
|
6371
6408
|
|
6372
6409
|
/***/ }),
|
6373
|
-
/*
|
6410
|
+
/* 72 */
|
6374
6411
|
/***/ (() => {
|
6375
6412
|
|
6376
6413
|
var _a;
|
@@ -6388,21 +6425,13 @@ up.Request.XHRRenderer = (_a = class XHRRenderer {
|
|
6388
6425
|
xhr.timeout = this.request.timeout;
|
6389
6426
|
}
|
6390
6427
|
xhr.open(this.getMethod(), this.request.url);
|
6391
|
-
const metaProps = this.request.metaProps();
|
6392
|
-
for (let key in metaProps) {
|
6393
|
-
this.addHeader(xhr, up.protocol.headerize(key), metaProps[key]);
|
6394
|
-
}
|
6395
|
-
for (let header in this.request.headers) {
|
6396
|
-
this.addHeader(xhr, header, this.request.headers[header]);
|
6397
|
-
}
|
6398
|
-
let csrfHeader, csrfToken;
|
6399
|
-
if ((csrfHeader = this.request.csrfHeader()) && (csrfToken = this.request.csrfToken())) {
|
6400
|
-
this.addHeader(xhr, csrfHeader, csrfToken);
|
6401
|
-
}
|
6402
|
-
this.addHeader(xhr, up.protocol.headerize('version'), up.version);
|
6403
6428
|
let contentType = this.getContentType();
|
6404
6429
|
if (contentType) {
|
6405
|
-
|
6430
|
+
xhr.setRequestHeader('Content-Type', contentType);
|
6431
|
+
}
|
6432
|
+
for (let headerName in this.request.headers) {
|
6433
|
+
let headerValue = this.request.headers[headerName];
|
6434
|
+
xhr.setRequestHeader(headerName, headerValue);
|
6406
6435
|
}
|
6407
6436
|
Object.assign(xhr, handlers);
|
6408
6437
|
xhr.send(this.getPayload());
|
@@ -6424,12 +6453,6 @@ up.Request.XHRRenderer = (_a = class XHRRenderer {
|
|
6424
6453
|
this.finalizePayload();
|
6425
6454
|
return this.payload;
|
6426
6455
|
}
|
6427
|
-
addHeader(xhr, header, value) {
|
6428
|
-
if (u.isOptions(value) || u.isArray(value)) {
|
6429
|
-
value = JSON.stringify(value);
|
6430
|
-
}
|
6431
|
-
xhr.setRequestHeader(header, value);
|
6432
|
-
}
|
6433
6456
|
finalizePayload() {
|
6434
6457
|
this.payload = this.request.payload;
|
6435
6458
|
this.contentType = this.request.contentType;
|
@@ -6456,7 +6479,7 @@ up.Request.XHRRenderer = (_a = class XHRRenderer {
|
|
6456
6479
|
|
6457
6480
|
|
6458
6481
|
/***/ }),
|
6459
|
-
/*
|
6482
|
+
/* 73 */
|
6460
6483
|
/***/ (() => {
|
6461
6484
|
|
6462
6485
|
const u = up.util;
|
@@ -6494,6 +6517,10 @@ up.Response = class Response extends up.Record {
|
|
6494
6517
|
header(name) {
|
6495
6518
|
return this.headers[name] || this.xhr?.getResponseHeader(name);
|
6496
6519
|
}
|
6520
|
+
get ownInfluncingHeaders() {
|
6521
|
+
let influencingHeaders = up.protocol.influencingHeadersFromResponse(this);
|
6522
|
+
return u.filter(influencingHeaders, (headerName) => this.request.header(headerName));
|
6523
|
+
}
|
6497
6524
|
get contentType() {
|
6498
6525
|
return this.header('Content-Type');
|
6499
6526
|
}
|
@@ -6527,7 +6554,7 @@ up.Response = class Response extends up.Record {
|
|
6527
6554
|
|
6528
6555
|
|
6529
6556
|
/***/ }),
|
6530
|
-
/*
|
6557
|
+
/* 74 */
|
6531
6558
|
/***/ (() => {
|
6532
6559
|
|
6533
6560
|
var _a;
|
@@ -6535,12 +6562,13 @@ const u = up.util;
|
|
6535
6562
|
const e = up.element;
|
6536
6563
|
up.ResponseDoc = (_a = class ResponseDoc {
|
6537
6564
|
constructor(options) {
|
6538
|
-
this.noscriptWrapper = new up.HTMLWrapper('noscript');
|
6539
|
-
this.scriptWrapper = new up.HTMLWrapper('script');
|
6540
6565
|
this.root =
|
6541
6566
|
this.parseDocument(options) ||
|
6542
6567
|
this.parseFragment(options) ||
|
6543
6568
|
this.parseContent(options);
|
6569
|
+
if (!up.fragment.config.runScripts) {
|
6570
|
+
this.root.querySelectorAll('script').forEach((e) => e.remove());
|
6571
|
+
}
|
6544
6572
|
this.cspNonces = options.cspNonces;
|
6545
6573
|
if (options.origin) {
|
6546
6574
|
let originSelector = up.fragment.tryToTarget(options.origin);
|
@@ -6550,7 +6578,11 @@ up.ResponseDoc = (_a = class ResponseDoc {
|
|
6550
6578
|
}
|
6551
6579
|
}
|
6552
6580
|
parseDocument(options) {
|
6553
|
-
|
6581
|
+
let document = this.parse(options.document, e.createBrokenDocumentFromHTML);
|
6582
|
+
if (document) {
|
6583
|
+
this.scriptishNeedFix = true;
|
6584
|
+
return document;
|
6585
|
+
}
|
6554
6586
|
}
|
6555
6587
|
parseContent(options) {
|
6556
6588
|
let content = options.content || '';
|
@@ -6558,7 +6590,6 @@ up.ResponseDoc = (_a = class ResponseDoc {
|
|
6558
6590
|
target = u.map(up.fragment.parseTargetSteps(target), 'selector').join(',');
|
6559
6591
|
const matchingElement = e.createFromSelector(target);
|
6560
6592
|
if (u.isString(content)) {
|
6561
|
-
content = this.wrapHTML(content);
|
6562
6593
|
matchingElement.innerHTML = content;
|
6563
6594
|
}
|
6564
6595
|
else {
|
@@ -6571,7 +6602,6 @@ up.ResponseDoc = (_a = class ResponseDoc {
|
|
6571
6602
|
}
|
6572
6603
|
parse(value, parseFn = e.createFromHTML) {
|
6573
6604
|
if (u.isString(value)) {
|
6574
|
-
value = this.wrapHTML(value);
|
6575
6605
|
value = parseFn(value);
|
6576
6606
|
}
|
6577
6607
|
return value;
|
@@ -6579,18 +6609,8 @@ up.ResponseDoc = (_a = class ResponseDoc {
|
|
6579
6609
|
rootSelector() {
|
6580
6610
|
return up.fragment.toTarget(this.root);
|
6581
6611
|
}
|
6582
|
-
wrapHTML(html) {
|
6583
|
-
html = this.noscriptWrapper.wrap(html);
|
6584
|
-
if (up.fragment.config.runScripts) {
|
6585
|
-
html = this.scriptWrapper.wrap(html);
|
6586
|
-
}
|
6587
|
-
else {
|
6588
|
-
html = this.scriptWrapper.strip(html);
|
6589
|
-
}
|
6590
|
-
return html;
|
6591
|
-
}
|
6592
6612
|
getTitle() {
|
6593
|
-
return this.root.querySelector(
|
6613
|
+
return this.root.querySelector('head title')?.textContent;
|
6594
6614
|
}
|
6595
6615
|
select(selector) {
|
6596
6616
|
let finder = new up.FragmentFinder({
|
@@ -6601,9 +6621,10 @@ up.ResponseDoc = (_a = class ResponseDoc {
|
|
6601
6621
|
return finder.find();
|
6602
6622
|
}
|
6603
6623
|
finalizeElement(element) {
|
6604
|
-
this.noscriptWrapper.unwrap(element);
|
6605
6624
|
up.NonceableCallback.adoptNonces(element, this.cspNonces);
|
6606
|
-
this.
|
6625
|
+
if (this.scriptishNeedFix) {
|
6626
|
+
element.querySelectorAll('noscript, script').forEach(e.fixScriptish);
|
6627
|
+
}
|
6607
6628
|
}
|
6608
6629
|
},
|
6609
6630
|
(() => {
|
@@ -6613,7 +6634,7 @@ up.ResponseDoc = (_a = class ResponseDoc {
|
|
6613
6634
|
|
6614
6635
|
|
6615
6636
|
/***/ }),
|
6616
|
-
/*
|
6637
|
+
/* 75 */
|
6617
6638
|
/***/ (() => {
|
6618
6639
|
|
6619
6640
|
const e = up.element;
|
@@ -6707,7 +6728,7 @@ up.RevealMotion = class RevealMotion {
|
|
6707
6728
|
|
6708
6729
|
|
6709
6730
|
/***/ }),
|
6710
|
-
/*
|
6731
|
+
/* 76 */
|
6711
6732
|
/***/ (() => {
|
6712
6733
|
|
6713
6734
|
const u = up.util;
|
@@ -6748,7 +6769,7 @@ up.Selector = class Selector {
|
|
6748
6769
|
|
6749
6770
|
|
6750
6771
|
/***/ }),
|
6751
|
-
/*
|
6772
|
+
/* 77 */
|
6752
6773
|
/***/ (() => {
|
6753
6774
|
|
6754
6775
|
const u = up.util;
|
@@ -6868,7 +6889,7 @@ up.Tether = class Tether {
|
|
6868
6889
|
|
6869
6890
|
|
6870
6891
|
/***/ }),
|
6871
|
-
/*
|
6892
|
+
/* 78 */
|
6872
6893
|
/***/ (() => {
|
6873
6894
|
|
6874
6895
|
const u = up.util;
|
@@ -6948,7 +6969,7 @@ up.URLPattern = class URLPattern {
|
|
6948
6969
|
|
6949
6970
|
|
6950
6971
|
/***/ }),
|
6951
|
-
/*
|
6972
|
+
/* 79 */
|
6952
6973
|
/***/ (() => {
|
6953
6974
|
|
6954
6975
|
up.framework = (function () {
|
@@ -7032,7 +7053,7 @@ up.boot = up.framework.boot;
|
|
7032
7053
|
|
7033
7054
|
|
7034
7055
|
/***/ }),
|
7035
|
-
/*
|
7056
|
+
/* 80 */
|
7036
7057
|
/***/ (() => {
|
7037
7058
|
|
7038
7059
|
up.event = (function () {
|
@@ -7135,7 +7156,7 @@ up.emit = up.event.emit;
|
|
7135
7156
|
|
7136
7157
|
|
7137
7158
|
/***/ }),
|
7138
|
-
/*
|
7159
|
+
/* 81 */
|
7139
7160
|
/***/ (() => {
|
7140
7161
|
|
7141
7162
|
up.protocol = (function () {
|
@@ -7151,6 +7172,9 @@ up.protocol = (function () {
|
|
7151
7172
|
return parseFn(value);
|
7152
7173
|
}
|
7153
7174
|
};
|
7175
|
+
function targetFromXHR(xhr) {
|
7176
|
+
return extractHeader(xhr, 'target');
|
7177
|
+
}
|
7154
7178
|
function parseModifyCacheValue(value) {
|
7155
7179
|
if (value === 'false') {
|
7156
7180
|
return false;
|
@@ -7171,6 +7195,9 @@ up.protocol = (function () {
|
|
7171
7195
|
function methodFromXHR(xhr) {
|
7172
7196
|
return extractHeader(xhr, 'method', u.normalizeMethod);
|
7173
7197
|
}
|
7198
|
+
function titleFromXHR(xhr) {
|
7199
|
+
return up.migrate.titleFromXHR?.(xhr) ?? extractHeader(xhr, 'title', JSON.parse);
|
7200
|
+
}
|
7174
7201
|
function eventPlansFromXHR(xhr) {
|
7175
7202
|
return extractHeader(xhr, 'events', JSON.parse);
|
7176
7203
|
}
|
@@ -7186,11 +7213,9 @@ up.protocol = (function () {
|
|
7186
7213
|
function locationFromXHR(xhr) {
|
7187
7214
|
return extractHeader(xhr, 'location') || xhr.responseURL;
|
7188
7215
|
}
|
7189
|
-
function
|
7190
|
-
|
7191
|
-
|
7192
|
-
function targetFromXHR(xhr) {
|
7193
|
-
return extractHeader(xhr, 'target');
|
7216
|
+
function influencingHeadersFromResponse(response) {
|
7217
|
+
let varyHeaderValue = response.header('Vary');
|
7218
|
+
return u.parseTokens(varyHeaderValue, { separator: 'comma' });
|
7194
7219
|
}
|
7195
7220
|
const config = new up.Config(() => ({
|
7196
7221
|
methodParam: '_method',
|
@@ -7266,12 +7291,13 @@ up.protocol = (function () {
|
|
7266
7291
|
headerize,
|
7267
7292
|
wrapMethod,
|
7268
7293
|
cspNoncesFromHeader,
|
7294
|
+
influencingHeadersFromResponse,
|
7269
7295
|
};
|
7270
7296
|
})();
|
7271
7297
|
|
7272
7298
|
|
7273
7299
|
/***/ }),
|
7274
|
-
/*
|
7300
|
+
/* 82 */
|
7275
7301
|
/***/ (() => {
|
7276
7302
|
|
7277
7303
|
up.log = (function () {
|
@@ -7357,7 +7383,7 @@ up.warn = up.log.warn;
|
|
7357
7383
|
|
7358
7384
|
|
7359
7385
|
/***/ }),
|
7360
|
-
/*
|
7386
|
+
/* 83 */
|
7361
7387
|
/***/ (() => {
|
7362
7388
|
|
7363
7389
|
up.syntax = (function () {
|
@@ -7507,7 +7533,7 @@ up.hello = up.syntax.hello;
|
|
7507
7533
|
|
7508
7534
|
|
7509
7535
|
/***/ }),
|
7510
|
-
/*
|
7536
|
+
/* 84 */
|
7511
7537
|
/***/ (() => {
|
7512
7538
|
|
7513
7539
|
up.history = (function () {
|
@@ -7576,7 +7602,7 @@ up.history = (function () {
|
|
7576
7602
|
}
|
7577
7603
|
function restoreStateOnPop(state) {
|
7578
7604
|
if (!state?.up) {
|
7579
|
-
up.puts('
|
7605
|
+
up.puts('popstate', 'Ignoring a history state not owned by Unpoly');
|
7580
7606
|
return;
|
7581
7607
|
}
|
7582
7608
|
let location = currentLocation();
|
@@ -7643,10 +7669,10 @@ up.history = (function () {
|
|
7643
7669
|
|
7644
7670
|
|
7645
7671
|
/***/ }),
|
7646
|
-
/*
|
7672
|
+
/* 85 */
|
7647
7673
|
/***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
|
7648
7674
|
|
7649
|
-
__webpack_require__(
|
7675
|
+
__webpack_require__(86);
|
7650
7676
|
const u = up.util;
|
7651
7677
|
const e = up.element;
|
7652
7678
|
up.fragment = (function () {
|
@@ -7697,7 +7723,7 @@ up.fragment = (function () {
|
|
7697
7723
|
autoRevalidate: (response) => response.expired,
|
7698
7724
|
skipResponse: defaultSkipResponse
|
7699
7725
|
}));
|
7700
|
-
u.delegate(config, 'mainTargets', () => up.layer.config.any);
|
7726
|
+
u.delegate(config, ['mainTargets'], () => up.layer.config.any);
|
7701
7727
|
function reset() {
|
7702
7728
|
config.reset();
|
7703
7729
|
}
|
@@ -8163,11 +8189,11 @@ up.destroy = up.fragment.destroy;
|
|
8163
8189
|
up.render = up.fragment.render;
|
8164
8190
|
up.navigate = up.fragment.navigate;
|
8165
8191
|
up.visit = up.fragment.visit;
|
8166
|
-
u.delegate(up, 'context', () => up.layer.current);
|
8192
|
+
u.delegate(up, ['context'], () => up.layer.current);
|
8167
8193
|
|
8168
8194
|
|
8169
8195
|
/***/ }),
|
8170
|
-
/*
|
8196
|
+
/* 86 */
|
8171
8197
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
8172
8198
|
|
8173
8199
|
"use strict";
|
@@ -8176,10 +8202,10 @@ __webpack_require__.r(__webpack_exports__);
|
|
8176
8202
|
|
8177
8203
|
|
8178
8204
|
/***/ }),
|
8179
|
-
/*
|
8205
|
+
/* 87 */
|
8180
8206
|
/***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
|
8181
8207
|
|
8182
|
-
__webpack_require__(
|
8208
|
+
__webpack_require__(88);
|
8183
8209
|
up.viewport = (function () {
|
8184
8210
|
const u = up.util;
|
8185
8211
|
const e = up.element;
|
@@ -8361,7 +8387,7 @@ up.viewport = (function () {
|
|
8361
8387
|
}
|
8362
8388
|
}
|
8363
8389
|
function newStateCache() {
|
8364
|
-
return new up.
|
8390
|
+
return new up.FIFOCache({ capacity: 30, normalizeKey: up.history.normalizeURL });
|
8365
8391
|
}
|
8366
8392
|
function parseOptions(args) {
|
8367
8393
|
const options = u.copy(u.extractOptions(args));
|
@@ -8499,7 +8525,7 @@ up.reveal = up.viewport.reveal;
|
|
8499
8525
|
|
8500
8526
|
|
8501
8527
|
/***/ }),
|
8502
|
-
/*
|
8528
|
+
/* 88 */
|
8503
8529
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
8504
8530
|
|
8505
8531
|
"use strict";
|
@@ -8508,7 +8534,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
8508
8534
|
|
8509
8535
|
|
8510
8536
|
/***/ }),
|
8511
|
-
/*
|
8537
|
+
/* 89 */
|
8512
8538
|
/***/ (() => {
|
8513
8539
|
|
8514
8540
|
up.motion = (function () {
|
@@ -8763,10 +8789,10 @@ up.animate = up.motion.animate;
|
|
8763
8789
|
|
8764
8790
|
|
8765
8791
|
/***/ }),
|
8766
|
-
/*
|
8792
|
+
/* 90 */
|
8767
8793
|
/***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
|
8768
8794
|
|
8769
|
-
__webpack_require__(
|
8795
|
+
__webpack_require__(91);
|
8770
8796
|
const u = up.util;
|
8771
8797
|
up.network = (function () {
|
8772
8798
|
const config = new up.Config(() => ({
|
@@ -8782,7 +8808,6 @@ up.network = (function () {
|
|
8782
8808
|
autoCache(request) { return request.isSafe(); },
|
8783
8809
|
expireCache(request, _response) { return !request.isSafe(); },
|
8784
8810
|
evictCache: false,
|
8785
|
-
requestMetaKeys: ['target', 'failTarget', 'mode', 'failMode', 'context', 'failContext'],
|
8786
8811
|
progressBar: true,
|
8787
8812
|
timeout: 90000,
|
8788
8813
|
}));
|
@@ -8793,14 +8818,14 @@ up.network = (function () {
|
|
8793
8818
|
abortRequests();
|
8794
8819
|
queue.reset();
|
8795
8820
|
config.reset();
|
8796
|
-
cache.
|
8821
|
+
cache.reset();
|
8797
8822
|
progressBar?.destroy();
|
8798
8823
|
progressBar = null;
|
8799
8824
|
}
|
8800
8825
|
function makeRequest(...args) {
|
8801
8826
|
const options = parseRequestOptions(args);
|
8802
8827
|
const request = new up.Request(options);
|
8803
|
-
|
8828
|
+
processRequest(request);
|
8804
8829
|
return request;
|
8805
8830
|
}
|
8806
8831
|
function parseRequestOptions(args) {
|
@@ -8811,31 +8836,31 @@ up.network = (function () {
|
|
8811
8836
|
up.migrate.handleRequestOptions?.(options);
|
8812
8837
|
return options;
|
8813
8838
|
}
|
8814
|
-
function
|
8839
|
+
function processRequest(request) {
|
8840
|
+
useCachedRequest(request) || queueRequest(request);
|
8841
|
+
}
|
8842
|
+
function useCachedRequest(newRequest) {
|
8815
8843
|
let cachedRequest;
|
8816
|
-
if (
|
8817
|
-
up.puts('up.request()', 'Re-using previous request to %s
|
8818
|
-
if (!
|
8844
|
+
if (newRequest.willCache() && (cachedRequest = cache.get(newRequest))) {
|
8845
|
+
up.puts('up.request()', 'Re-using previous request to %s', newRequest.description);
|
8846
|
+
if (!newRequest.background) {
|
8819
8847
|
queue.promoteToForeground(cachedRequest);
|
8820
8848
|
}
|
8821
|
-
|
8822
|
-
request.fromCache = true;
|
8849
|
+
cache.track(cachedRequest, newRequest, { onIncompatible: processRequest });
|
8823
8850
|
return true;
|
8824
8851
|
}
|
8825
8852
|
}
|
8826
8853
|
function queueRequest(request) {
|
8827
|
-
if (request.preload && !request.isSafe()) {
|
8828
|
-
up.fail('Will not preload request to %s', request.description);
|
8829
|
-
}
|
8830
8854
|
handleCaching(request);
|
8831
8855
|
queue.asap(request);
|
8832
8856
|
return true;
|
8833
8857
|
}
|
8834
8858
|
function handleCaching(request) {
|
8835
8859
|
if (request.willCache()) {
|
8836
|
-
cache.
|
8860
|
+
cache.put(request);
|
8861
|
+
request.onLoading = () => cache.put(request);
|
8837
8862
|
}
|
8838
|
-
|
8863
|
+
u.always(request, function (response) {
|
8839
8864
|
let expireCache = response.expireCache ?? request.expireCache ?? u.evalOption(config.expireCache, request, response);
|
8840
8865
|
if (expireCache) {
|
8841
8866
|
cache.expire(expireCache, { except: request });
|
@@ -8845,7 +8870,7 @@ up.network = (function () {
|
|
8845
8870
|
cache.evict(evictCache, { except: request });
|
8846
8871
|
}
|
8847
8872
|
if (cache.get(request)) {
|
8848
|
-
cache.
|
8873
|
+
cache.put(request);
|
8849
8874
|
}
|
8850
8875
|
if (!response.ok) {
|
8851
8876
|
cache.evict(request);
|
@@ -8910,7 +8935,7 @@ up.cache = up.network.cache;
|
|
8910
8935
|
|
8911
8936
|
|
8912
8937
|
/***/ }),
|
8913
|
-
/*
|
8938
|
+
/* 91 */
|
8914
8939
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
8915
8940
|
|
8916
8941
|
"use strict";
|
@@ -8919,10 +8944,10 @@ __webpack_require__.r(__webpack_exports__);
|
|
8919
8944
|
|
8920
8945
|
|
8921
8946
|
/***/ }),
|
8922
|
-
/*
|
8947
|
+
/* 92 */
|
8923
8948
|
/***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
|
8924
8949
|
|
8925
|
-
__webpack_require__(
|
8950
|
+
__webpack_require__(93);
|
8926
8951
|
const u = up.util;
|
8927
8952
|
const e = up.element;
|
8928
8953
|
up.layer = (function () {
|
@@ -9163,7 +9188,7 @@ up.layer = (function () {
|
|
9163
9188
|
|
9164
9189
|
|
9165
9190
|
/***/ }),
|
9166
|
-
/*
|
9191
|
+
/* 93 */
|
9167
9192
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
9168
9193
|
|
9169
9194
|
"use strict";
|
@@ -9172,10 +9197,10 @@ __webpack_require__.r(__webpack_exports__);
|
|
9172
9197
|
|
9173
9198
|
|
9174
9199
|
/***/ }),
|
9175
|
-
/*
|
9200
|
+
/* 94 */
|
9176
9201
|
/***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
|
9177
9202
|
|
9178
|
-
__webpack_require__(
|
9203
|
+
__webpack_require__(95);
|
9179
9204
|
up.link = (function () {
|
9180
9205
|
const u = up.util;
|
9181
9206
|
const e = up.element;
|
@@ -9323,8 +9348,9 @@ up.link = (function () {
|
|
9323
9348
|
}
|
9324
9349
|
function preload(link, options) {
|
9325
9350
|
link = up.fragment.get(link);
|
9326
|
-
|
9327
|
-
|
9351
|
+
let issue = preloadIssue(link);
|
9352
|
+
if (issue) {
|
9353
|
+
return Promise.reject(new up.Error(issue));
|
9328
9354
|
}
|
9329
9355
|
const guardEvent = up.event.build('up:link:preload', { log: ['Preloading link %o', link] });
|
9330
9356
|
return follow(link, {
|
@@ -9334,10 +9360,15 @@ up.link = (function () {
|
|
9334
9360
|
preload: true
|
9335
9361
|
});
|
9336
9362
|
}
|
9337
|
-
function
|
9338
|
-
|
9339
|
-
|
9363
|
+
function preloadIssue(link) {
|
9364
|
+
if (!u.evalAutoOption(config.preloadEnabled, autoPreloadEnabled, link)) {
|
9365
|
+
return 'Preloading is disabled';
|
9366
|
+
}
|
9367
|
+
else if (!isSafe(link)) {
|
9368
|
+
return 'Will not preload an unsafe link';
|
9369
|
+
}
|
9340
9370
|
}
|
9371
|
+
const autoPreloadEnabled = u.negate(up.network.shouldReduceRequests);
|
9341
9372
|
function followMethod(link, options = {}) {
|
9342
9373
|
return u.normalizeMethod(options.method || link.getAttribute('up-method') || link.getAttribute('data-method'));
|
9343
9374
|
}
|
@@ -9464,7 +9495,7 @@ up.follow = up.link.follow;
|
|
9464
9495
|
|
9465
9496
|
|
9466
9497
|
/***/ }),
|
9467
|
-
/*
|
9498
|
+
/* 95 */
|
9468
9499
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
9469
9500
|
|
9470
9501
|
"use strict";
|
@@ -9473,7 +9504,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
9473
9504
|
|
9474
9505
|
|
9475
9506
|
/***/ }),
|
9476
|
-
/*
|
9507
|
+
/* 96 */
|
9477
9508
|
/***/ (() => {
|
9478
9509
|
|
9479
9510
|
up.form = (function () {
|
@@ -9871,7 +9902,7 @@ up.validate = up.form.validate;
|
|
9871
9902
|
|
9872
9903
|
|
9873
9904
|
/***/ }),
|
9874
|
-
/*
|
9905
|
+
/* 97 */
|
9875
9906
|
/***/ (() => {
|
9876
9907
|
|
9877
9908
|
up.feedback = (function () {
|
@@ -9988,7 +10019,7 @@ up.feedback = (function () {
|
|
9988
10019
|
|
9989
10020
|
|
9990
10021
|
/***/ }),
|
9991
|
-
/*
|
10022
|
+
/* 98 */
|
9992
10023
|
/***/ (() => {
|
9993
10024
|
|
9994
10025
|
up.radio = (function () {
|
@@ -10065,7 +10096,7 @@ up.radio = (function () {
|
|
10065
10096
|
|
10066
10097
|
|
10067
10098
|
/***/ }),
|
10068
|
-
/*
|
10099
|
+
/* 99 */
|
10069
10100
|
/***/ (() => {
|
10070
10101
|
|
10071
10102
|
(function () {
|
@@ -10214,16 +10245,15 @@ __webpack_require__(82);
|
|
10214
10245
|
__webpack_require__(83);
|
10215
10246
|
__webpack_require__(84);
|
10216
10247
|
__webpack_require__(85);
|
10217
|
-
__webpack_require__(
|
10218
|
-
__webpack_require__(
|
10248
|
+
__webpack_require__(87);
|
10249
|
+
__webpack_require__(89);
|
10219
10250
|
__webpack_require__(90);
|
10220
|
-
__webpack_require__(
|
10221
|
-
__webpack_require__(
|
10222
|
-
__webpack_require__(
|
10251
|
+
__webpack_require__(92);
|
10252
|
+
__webpack_require__(94);
|
10253
|
+
__webpack_require__(96);
|
10223
10254
|
__webpack_require__(97);
|
10224
10255
|
__webpack_require__(98);
|
10225
10256
|
__webpack_require__(99);
|
10226
|
-
__webpack_require__(100);
|
10227
10257
|
up.framework.onEvaled();
|
10228
10258
|
|
10229
10259
|
})();
|