unpoly-rails 3.0.0.rc1 → 3.0.0.rc3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/assets/unpoly/unpoly-migrate.js +90 -23
- data/assets/unpoly/unpoly-migrate.min.js +1 -1
- data/assets/unpoly/unpoly.es6.js +439 -398
- data/assets/unpoly/unpoly.es6.min.js +1 -1
- data/assets/unpoly/unpoly.js +421 -397
- 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
|
|
@@ -14,13 +14,18 @@ window.up = {
|
|
14
14
|
/***/ (() => {
|
15
15
|
|
16
16
|
up.mockable = function (originalFn) {
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
17
|
+
if (window.jasmine) {
|
18
|
+
let name = originalFn.name;
|
19
|
+
let obj = { [name]: originalFn };
|
20
|
+
let mockableFn = function () {
|
21
|
+
return obj[name].apply(this, arguments);
|
22
|
+
};
|
23
|
+
mockableFn.mock = () => spyOn(obj, name);
|
24
|
+
return mockableFn;
|
25
|
+
}
|
26
|
+
else {
|
27
|
+
return originalFn;
|
28
|
+
}
|
24
29
|
};
|
25
30
|
|
26
31
|
|
@@ -106,15 +111,15 @@ up.util = (function () {
|
|
106
111
|
return block;
|
107
112
|
}
|
108
113
|
}
|
109
|
-
function map(
|
110
|
-
if (
|
114
|
+
function map(list, block) {
|
115
|
+
if (list.length === 0) {
|
111
116
|
return [];
|
112
117
|
}
|
113
118
|
block = iteratee(block);
|
114
119
|
let mapped = [];
|
115
|
-
|
116
|
-
|
117
|
-
mapped.push(block(
|
120
|
+
let i = 0;
|
121
|
+
for (let item of list) {
|
122
|
+
mapped.push(block(item, i++));
|
118
123
|
}
|
119
124
|
return mapped;
|
120
125
|
}
|
@@ -126,8 +131,9 @@ up.util = (function () {
|
|
126
131
|
return map(array, pairer).reduce(merger, {});
|
127
132
|
}
|
128
133
|
function each(array, block) {
|
129
|
-
|
130
|
-
|
134
|
+
let i = 0;
|
135
|
+
for (let item of array) {
|
136
|
+
block(item, i++);
|
131
137
|
}
|
132
138
|
}
|
133
139
|
function isNull(object) {
|
@@ -304,10 +310,11 @@ up.util = (function () {
|
|
304
310
|
function some(list, tester) {
|
305
311
|
return !!findResult(list, tester);
|
306
312
|
}
|
307
|
-
function findResult(
|
313
|
+
function findResult(list, tester) {
|
308
314
|
tester = iteratee(tester);
|
309
|
-
|
310
|
-
|
315
|
+
let i = 0;
|
316
|
+
for (let item of list) {
|
317
|
+
const result = tester(item, i++);
|
311
318
|
if (result) {
|
312
319
|
return result;
|
313
320
|
}
|
@@ -316,8 +323,9 @@ up.util = (function () {
|
|
316
323
|
function every(list, tester) {
|
317
324
|
tester = iteratee(tester);
|
318
325
|
let match = true;
|
319
|
-
|
320
|
-
|
326
|
+
let i = 0;
|
327
|
+
for (let item of list) {
|
328
|
+
if (!tester(item, i++)) {
|
321
329
|
match = false;
|
322
330
|
break;
|
323
331
|
}
|
@@ -489,7 +497,7 @@ up.util = (function () {
|
|
489
497
|
function flatMap(array, block) {
|
490
498
|
return flatten(map(array, block));
|
491
499
|
}
|
492
|
-
function always(promise, callback) {
|
500
|
+
function always(promise, callback = identity) {
|
493
501
|
return promise.then(callback, callback);
|
494
502
|
}
|
495
503
|
function newDeferred() {
|
@@ -591,7 +599,7 @@ up.util = (function () {
|
|
591
599
|
Object.defineProperty(object, prop, { get });
|
592
600
|
}
|
593
601
|
function defineDelegates(object, props, targetProvider) {
|
594
|
-
|
602
|
+
for (let prop of props) {
|
595
603
|
Object.defineProperty(object, prop, {
|
596
604
|
get() {
|
597
605
|
const target = targetProvider.call(this);
|
@@ -606,7 +614,7 @@ up.util = (function () {
|
|
606
614
|
target[prop] = newValue;
|
607
615
|
}
|
608
616
|
});
|
609
|
-
}
|
617
|
+
}
|
610
618
|
}
|
611
619
|
function stringifyArg(arg) {
|
612
620
|
let string;
|
@@ -701,6 +709,14 @@ up.util = (function () {
|
|
701
709
|
};
|
702
710
|
}
|
703
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
|
+
}
|
704
720
|
return {
|
705
721
|
parseURL,
|
706
722
|
normalizeURL,
|
@@ -796,7 +812,8 @@ up.util = (function () {
|
|
796
812
|
sprintf,
|
797
813
|
renameKeys,
|
798
814
|
negate,
|
799
|
-
memoizeMethod
|
815
|
+
memoizeMethod,
|
816
|
+
safeStringifyJSON,
|
800
817
|
};
|
801
818
|
})();
|
802
819
|
|
@@ -871,12 +888,6 @@ up.browser = (function () {
|
|
871
888
|
return value;
|
872
889
|
}
|
873
890
|
}
|
874
|
-
const getJQuery = function () {
|
875
|
-
if (!canJQuery()) {
|
876
|
-
up.fail('jQuery must be published as window.jQuery');
|
877
|
-
}
|
878
|
-
return jQuery;
|
879
|
-
};
|
880
891
|
function assertConfirmed(options) {
|
881
892
|
const confirmed = !options.confirm || window.confirm(options.confirm);
|
882
893
|
if (!confirmed) {
|
@@ -891,7 +902,6 @@ up.browser = (function () {
|
|
891
902
|
canEval,
|
892
903
|
assertConfirmed,
|
893
904
|
popCookie,
|
894
|
-
get jQuery() { return getJQuery(); },
|
895
905
|
};
|
896
906
|
})();
|
897
907
|
|
@@ -1164,9 +1174,17 @@ up.element = (function () {
|
|
1164
1174
|
klass = klass.replace(/:/g, '\\:');
|
1165
1175
|
return `.${klass}`;
|
1166
1176
|
}
|
1167
|
-
function
|
1177
|
+
function createBrokenDocumentFromHTML(html) {
|
1168
1178
|
return new DOMParser().parseFromString(html, 'text/html');
|
1169
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
|
+
}
|
1170
1188
|
function createFromHTML(html) {
|
1171
1189
|
const range = document.createRange();
|
1172
1190
|
range.setStart(document.body, 0);
|
@@ -1429,7 +1447,8 @@ up.element = (function () {
|
|
1429
1447
|
isSingleton,
|
1430
1448
|
attrSelector,
|
1431
1449
|
tagName: elementTagName,
|
1432
|
-
|
1450
|
+
createBrokenDocumentFromHTML,
|
1451
|
+
fixScriptish,
|
1433
1452
|
createFromHTML,
|
1434
1453
|
get root() { return getRoot(); },
|
1435
1454
|
paint,
|
@@ -1626,82 +1645,26 @@ up.LogConfig = class LogConfig extends up.Config {
|
|
1626
1645
|
/***/ (() => {
|
1627
1646
|
|
1628
1647
|
const u = up.util;
|
1629
|
-
up.
|
1630
|
-
constructor(
|
1631
|
-
this.config = config;
|
1648
|
+
up.FIFOCache = class FIFOCache {
|
1649
|
+
constructor({ capacity = 10, normalizeKey = u.identity } = {}) {
|
1632
1650
|
this.map = new Map();
|
1651
|
+
this.capacity = capacity;
|
1652
|
+
this.normalizeKey = normalizeKey;
|
1633
1653
|
}
|
1634
|
-
|
1635
|
-
|
1636
|
-
|
1637
|
-
maxSize() {
|
1638
|
-
return u.evalOption(this.config.size);
|
1639
|
-
}
|
1640
|
-
evictAge() {
|
1641
|
-
return u.evalOption(this.config.evictAge);
|
1642
|
-
}
|
1643
|
-
normalizeStoreKey(key) {
|
1644
|
-
return key;
|
1645
|
-
}
|
1646
|
-
isDisabled() {
|
1647
|
-
return this.maxSize() === 0 || this.evictAge() === 0;
|
1648
|
-
}
|
1649
|
-
evict() {
|
1650
|
-
this.map.clear();
|
1651
|
-
}
|
1652
|
-
records() {
|
1653
|
-
return this.map.values();
|
1654
|
-
}
|
1655
|
-
makeRoomForAnotherRecord() {
|
1656
|
-
const maxSize = this.maxSize();
|
1657
|
-
const currentSize = this.size();
|
1658
|
-
if (!maxSize || currentSize < maxSize)
|
1659
|
-
return;
|
1660
|
-
let records = Array.from(this.records());
|
1661
|
-
records.sort((a, b) => b.createdAt - a.createdAt);
|
1662
|
-
const overflow = currentSize - maxSize + 1;
|
1663
|
-
for (let i = 0; i < overflow; i++) {
|
1664
|
-
let key = records.pop().key;
|
1665
|
-
this.map.delete(key);
|
1666
|
-
}
|
1667
|
-
}
|
1668
|
-
alias(oldKey, newKey) {
|
1669
|
-
const value = this.get(oldKey);
|
1670
|
-
if (u.isDefined(value)) {
|
1671
|
-
this.set(newKey, value);
|
1672
|
-
}
|
1654
|
+
get(key) {
|
1655
|
+
key = this.normalizeKey(key);
|
1656
|
+
return this.map.get(key);
|
1673
1657
|
}
|
1674
1658
|
set(key, value) {
|
1675
|
-
if (this.
|
1676
|
-
|
1677
|
-
|
1678
|
-
key = this.normalizeStoreKey(key);
|
1679
|
-
const createdAt = new Date();
|
1680
|
-
const record = { key, value, createdAt };
|
1681
|
-
this.map.set(key, record);
|
1682
|
-
}
|
1683
|
-
remove(key) {
|
1684
|
-
key = this.normalizeStoreKey(key);
|
1685
|
-
this.map.delete(key);
|
1686
|
-
}
|
1687
|
-
isUsable(record) {
|
1688
|
-
const evictAge = this.evictAge();
|
1689
|
-
if (!evictAge)
|
1690
|
-
return true;
|
1691
|
-
const age = new Date() - record.createdAt;
|
1692
|
-
return age < evictAge;
|
1693
|
-
}
|
1694
|
-
get(key) {
|
1695
|
-
const storeKey = this.normalizeStoreKey(key);
|
1696
|
-
let record = this.map.get(storeKey);
|
1697
|
-
if (record) {
|
1698
|
-
if (this.isUsable(record)) {
|
1699
|
-
return record.value;
|
1700
|
-
}
|
1701
|
-
else {
|
1702
|
-
this.remove(key);
|
1703
|
-
}
|
1659
|
+
if (this.map.size === this.capacity) {
|
1660
|
+
let oldestKey = this.map.keys().next().value;
|
1661
|
+
this.map.delete(oldestKey);
|
1704
1662
|
}
|
1663
|
+
key = this.normalizeKey(key);
|
1664
|
+
this.map.set(key, value);
|
1665
|
+
}
|
1666
|
+
clear() {
|
1667
|
+
this.map.clear();
|
1705
1668
|
}
|
1706
1669
|
};
|
1707
1670
|
|
@@ -1876,7 +1839,7 @@ up.Change.Addition = class Addition extends up.Change {
|
|
1876
1839
|
setETag({ newElement, etag }) {
|
1877
1840
|
e.setMissingAttr(newElement, 'up-etag', etag || false);
|
1878
1841
|
}
|
1879
|
-
|
1842
|
+
setReloadAttrs(options) {
|
1880
1843
|
this.setSource(options);
|
1881
1844
|
this.setTime(options);
|
1882
1845
|
this.setETag(options);
|
@@ -2119,9 +2082,9 @@ up.Change.OpenLayer = class OpenLayer extends up.Change.Addition {
|
|
2119
2082
|
this.layer.createElements(this.content);
|
2120
2083
|
this.layer.setupHandlers();
|
2121
2084
|
this.handleHistory();
|
2122
|
-
this.
|
2085
|
+
this.setReloadAttrs({ newElement: this.content, source: this.options.source });
|
2123
2086
|
responseDoc.finalizeElement(this.content);
|
2124
|
-
up.hello(this.layer.element, {
|
2087
|
+
up.hello(this.layer.element, Object.assign(Object.assign({}, this.options), { layer: this.layer }));
|
2125
2088
|
this.handleLayerChangeRequests();
|
2126
2089
|
this.handleScroll();
|
2127
2090
|
let renderResult = new up.RenderResult({
|
@@ -2290,7 +2253,7 @@ up.Change.UpdateLayer = (_a = class UpdateLayer extends up.Change.Addition {
|
|
2290
2253
|
this.renderResult.fragments.unshift(...newFragments);
|
2291
2254
|
}
|
2292
2255
|
executeStep(step) {
|
2293
|
-
this.
|
2256
|
+
this.setReloadAttrs(step);
|
2294
2257
|
switch (step.placement) {
|
2295
2258
|
case 'swap': {
|
2296
2259
|
let keepPlan = this.findKeepPlan(step);
|
@@ -2781,18 +2744,11 @@ up.Change.FromURL = (_a = class FromURL extends up.Change {
|
|
2781
2744
|
onRequestSettledWithResponse(response) {
|
2782
2745
|
var _a;
|
2783
2746
|
this.response = response;
|
2784
|
-
|
2785
|
-
const eventProps = {
|
2786
|
-
response: this.response,
|
2787
|
-
renderOptions: this.options,
|
2788
|
-
revalidating: !!expiredResponse,
|
2789
|
-
expiredResponse,
|
2790
|
-
};
|
2791
|
-
if (up.fragment.config.skipResponse(eventProps)) {
|
2747
|
+
if (up.fragment.config.skipResponse(this.loadedEventProps())) {
|
2792
2748
|
this.skip();
|
2793
2749
|
}
|
2794
2750
|
else {
|
2795
|
-
this.request.assertEmitted('up:fragment:loaded', Object.assign(Object.assign({},
|
2751
|
+
this.request.assertEmitted('up:fragment:loaded', Object.assign(Object.assign({}, this.loadedEventProps()), { callback: this.options.onLoaded, log: ['Loaded fragment from %s', this.response.description], skip: () => this.skip() }));
|
2796
2752
|
}
|
2797
2753
|
let fail = (_a = u.evalOption(this.options.fail, this.response)) !== null && _a !== void 0 ? _a : !response.ok;
|
2798
2754
|
if (fail) {
|
@@ -2800,6 +2756,22 @@ up.Change.FromURL = (_a = class FromURL extends up.Change {
|
|
2800
2756
|
}
|
2801
2757
|
return this.updateContentFromResponse(this.options);
|
2802
2758
|
}
|
2759
|
+
compilerPassMeta() {
|
2760
|
+
return u.pick(this.loadedEventProps(), [
|
2761
|
+
'revalidating',
|
2762
|
+
'response'
|
2763
|
+
]);
|
2764
|
+
}
|
2765
|
+
loadedEventProps() {
|
2766
|
+
const { expiredResponse } = this.options;
|
2767
|
+
return {
|
2768
|
+
request: this.request,
|
2769
|
+
response: this.response,
|
2770
|
+
renderOptions: this.options,
|
2771
|
+
revalidating: !!expiredResponse,
|
2772
|
+
expiredResponse,
|
2773
|
+
};
|
2774
|
+
}
|
2803
2775
|
onRequestSettledWithError(error) {
|
2804
2776
|
if (error instanceof up.Offline) {
|
2805
2777
|
this.request.emit('up:fragment:offline', {
|
@@ -2822,6 +2794,7 @@ up.Change.FromURL = (_a = class FromURL extends up.Change {
|
|
2822
2794
|
up.puts('up.render()', 'Rendering failed response using fail-prefixed options (https://unpoly.com/failed-responses)');
|
2823
2795
|
}
|
2824
2796
|
this.augmentOptionsFromResponse(finalRenderOptions);
|
2797
|
+
finalRenderOptions.meta = this.compilerPassMeta();
|
2825
2798
|
let result = new up.Change.FromContent(finalRenderOptions).execute();
|
2826
2799
|
result.finished = this.finish(result, finalRenderOptions);
|
2827
2800
|
return result;
|
@@ -2890,6 +2863,7 @@ up.Change.FromURL = (_a = class FromURL extends up.Change {
|
|
2890
2863
|
(() => {
|
2891
2864
|
u.memoizeMethod(_a.prototype, [
|
2892
2865
|
'getRequestAttrs',
|
2866
|
+
'loadedEventProps',
|
2893
2867
|
]);
|
2894
2868
|
})(),
|
2895
2869
|
_a);
|
@@ -2901,12 +2875,14 @@ up.Change.FromURL = (_a = class FromURL extends up.Change {
|
|
2901
2875
|
|
2902
2876
|
const u = up.util;
|
2903
2877
|
up.CompilerPass = class CompilerPass {
|
2904
|
-
constructor(root, compilers, { layer, data, dataMap
|
2878
|
+
constructor(root, compilers, { layer, data, dataMap, meta }) {
|
2879
|
+
layer || (layer = up.layer.get(root) || up.layer.current);
|
2905
2880
|
this.root = root;
|
2906
2881
|
this.compilers = compilers;
|
2907
|
-
this.layer = layer
|
2882
|
+
this.layer = layer;
|
2908
2883
|
this.data = data;
|
2909
2884
|
this.dataMap = dataMap;
|
2885
|
+
this.meta = Object.assign({ layer }, meta);
|
2910
2886
|
this.errors = [];
|
2911
2887
|
}
|
2912
2888
|
run() {
|
@@ -2952,11 +2928,10 @@ up.CompilerPass = class CompilerPass {
|
|
2952
2928
|
return (_b = (_a = up.migrate).postCompile) === null || _b === void 0 ? void 0 : _b.call(_a, matches, compiler);
|
2953
2929
|
}
|
2954
2930
|
compileOneElement(compiler, element) {
|
2955
|
-
const
|
2956
|
-
const compileArgs = [elementArg];
|
2931
|
+
const compileArgs = [element];
|
2957
2932
|
if (compiler.length !== 1) {
|
2958
2933
|
const data = up.syntax.data(element);
|
2959
|
-
compileArgs.push(data);
|
2934
|
+
compileArgs.push(data, this.meta);
|
2960
2935
|
}
|
2961
2936
|
const result = this.applyCompilerFunction(compiler, element, compileArgs);
|
2962
2937
|
let destructorOrDestructors = this.destructorPresence(result);
|
@@ -2965,11 +2940,10 @@ up.CompilerPass = class CompilerPass {
|
|
2965
2940
|
}
|
2966
2941
|
}
|
2967
2942
|
compileBatch(compiler, elements) {
|
2968
|
-
const
|
2969
|
-
const compileArgs = [elementsArgs];
|
2943
|
+
const compileArgs = [elements];
|
2970
2944
|
if (compiler.length !== 1) {
|
2971
2945
|
const dataList = u.map(elements, up.syntax.data);
|
2972
|
-
compileArgs.push(dataList);
|
2946
|
+
compileArgs.push(dataList, this.meta);
|
2973
2947
|
}
|
2974
2948
|
const result = this.applyCompilerFunction(compiler, elements, compileArgs);
|
2975
2949
|
if (this.destructorPresence(result)) {
|
@@ -3275,7 +3249,6 @@ up.EventListener = class EventListener extends up.Record {
|
|
3275
3249
|
'eventType',
|
3276
3250
|
'selector',
|
3277
3251
|
'callback',
|
3278
|
-
'jQuery',
|
3279
3252
|
'guard',
|
3280
3253
|
'baseLayer',
|
3281
3254
|
'passive',
|
@@ -3323,8 +3296,7 @@ up.EventListener = class EventListener extends up.Record {
|
|
3323
3296
|
return;
|
3324
3297
|
}
|
3325
3298
|
if (element) {
|
3326
|
-
const
|
3327
|
-
const args = [event, elementArg];
|
3299
|
+
const args = [event, element];
|
3328
3300
|
const expectedArgCount = this.callback.length;
|
3329
3301
|
if (expectedArgCount !== 1 && expectedArgCount !== 2) {
|
3330
3302
|
const data = up.syntax.data(element);
|
@@ -3380,7 +3352,6 @@ up.EventListenerGroup = class EventListenerGroup extends up.Record {
|
|
3380
3352
|
'eventTypes',
|
3381
3353
|
'selector',
|
3382
3354
|
'callback',
|
3383
|
-
'jQuery',
|
3384
3355
|
'guard',
|
3385
3356
|
'baseLayer',
|
3386
3357
|
'passive',
|
@@ -4155,44 +4126,6 @@ up.FragmentScrolling = class FragmentScrolling extends up.FragmentProcessor {
|
|
4155
4126
|
/* 47 */
|
4156
4127
|
/***/ (() => {
|
4157
4128
|
|
4158
|
-
const u = up.util;
|
4159
|
-
const e = up.element;
|
4160
|
-
up.HTMLWrapper = class HTMLWrapper {
|
4161
|
-
constructor(tagName) {
|
4162
|
-
this.tagName = tagName;
|
4163
|
-
const openTag = `<${this.tagName}[^>]*>`;
|
4164
|
-
const closeTag = `</${this.tagName}>`;
|
4165
|
-
const innerHTML = "(.|\\s)*?";
|
4166
|
-
this.pattern = new RegExp(openTag + innerHTML + closeTag, 'ig');
|
4167
|
-
this.attrName = `up-wrapped-${this.tagName}`;
|
4168
|
-
}
|
4169
|
-
strip(html) {
|
4170
|
-
return html.replace(this.pattern, '');
|
4171
|
-
}
|
4172
|
-
wrap(html) {
|
4173
|
-
return html.replace(this.pattern, this.wrapMatch.bind(this));
|
4174
|
-
}
|
4175
|
-
wrapMatch(match) {
|
4176
|
-
this.didWrap = true;
|
4177
|
-
return '<meta name="' + this.attrName + '" value="' + u.escapeHTML(match) + '">';
|
4178
|
-
}
|
4179
|
-
unwrap(element) {
|
4180
|
-
if (!this.didWrap) {
|
4181
|
-
return;
|
4182
|
-
}
|
4183
|
-
for (let wrappedChild of element.querySelectorAll(`meta[name='${this.attrName}']`)) {
|
4184
|
-
const originalHTML = wrappedChild.getAttribute('value');
|
4185
|
-
const restoredElement = e.createFromHTML(originalHTML);
|
4186
|
-
wrappedChild.replaceWith(restoredElement);
|
4187
|
-
}
|
4188
|
-
}
|
4189
|
-
};
|
4190
|
-
|
4191
|
-
|
4192
|
-
/***/ }),
|
4193
|
-
/* 48 */
|
4194
|
-
/***/ (() => {
|
4195
|
-
|
4196
4129
|
const e = up.element;
|
4197
4130
|
const u = up.util;
|
4198
4131
|
up.Layer = class Layer extends up.Record {
|
@@ -4339,12 +4272,12 @@ up.Layer = class Layer extends up.Record {
|
|
4339
4272
|
return this.stack.asCurrent(this, fn);
|
4340
4273
|
}
|
4341
4274
|
updateHistory(options) {
|
4342
|
-
if (u.isString(options.title)) {
|
4343
|
-
this.title = options.title;
|
4344
|
-
}
|
4345
4275
|
if (u.isString(options.location)) {
|
4346
4276
|
this.location = options.location;
|
4347
4277
|
}
|
4278
|
+
if (u.isString(options.title)) {
|
4279
|
+
this.title = options.title;
|
4280
|
+
}
|
4348
4281
|
}
|
4349
4282
|
isHistoryVisible() {
|
4350
4283
|
return this.history && (this.isRoot() || this.parent.isHistoryVisible());
|
@@ -4377,12 +4310,14 @@ up.Layer = class Layer extends up.Record {
|
|
4377
4310
|
set location(location) {
|
4378
4311
|
const previousLocation = this.location;
|
4379
4312
|
location = up.history.normalizeURL(location);
|
4380
|
-
if (previousLocation !== location) {
|
4313
|
+
if (previousLocation !== location || this.opening) {
|
4381
4314
|
this.savedLocation = location;
|
4382
|
-
this.emit('up:layer:location:changed', { location, log: false });
|
4383
4315
|
if (this.showsLiveHistory()) {
|
4384
4316
|
up.history.push(location);
|
4385
4317
|
}
|
4318
|
+
if (!this.opening) {
|
4319
|
+
this.emit('up:layer:location:changed', { location });
|
4320
|
+
}
|
4386
4321
|
}
|
4387
4322
|
}
|
4388
4323
|
selector(part) {
|
@@ -4404,11 +4339,14 @@ up.Layer = class Layer extends up.Record {
|
|
4404
4339
|
let focusedElement = document.activeElement;
|
4405
4340
|
return focusedElement !== document.body && this.element.contains(focusedElement);
|
4406
4341
|
}
|
4342
|
+
reset() {
|
4343
|
+
Object.assign(this, this.defaults());
|
4344
|
+
}
|
4407
4345
|
};
|
4408
4346
|
|
4409
4347
|
|
4410
4348
|
/***/ }),
|
4411
|
-
/*
|
4349
|
+
/* 48 */
|
4412
4350
|
/***/ (() => {
|
4413
4351
|
|
4414
4352
|
const e = up.element;
|
@@ -4688,7 +4626,7 @@ up.Layer.Overlay = class Overlay extends up.Layer {
|
|
4688
4626
|
|
4689
4627
|
|
4690
4628
|
/***/ }),
|
4691
|
-
/*
|
4629
|
+
/* 49 */
|
4692
4630
|
/***/ (() => {
|
4693
4631
|
|
4694
4632
|
up.Layer.OverlayWithTether = class OverlayWithTether extends up.Layer.Overlay {
|
@@ -4725,7 +4663,7 @@ up.Layer.OverlayWithTether = class OverlayWithTether extends up.Layer.Overlay {
|
|
4725
4663
|
|
4726
4664
|
|
4727
4665
|
/***/ }),
|
4728
|
-
/*
|
4666
|
+
/* 50 */
|
4729
4667
|
/***/ (() => {
|
4730
4668
|
|
4731
4669
|
var _a;
|
@@ -4763,7 +4701,7 @@ up.Layer.OverlayWithViewport = (_a = class OverlayWithViewport extends up.Layer.
|
|
4763
4701
|
|
4764
4702
|
|
4765
4703
|
/***/ }),
|
4766
|
-
/*
|
4704
|
+
/* 51 */
|
4767
4705
|
/***/ (() => {
|
4768
4706
|
|
4769
4707
|
var _a;
|
@@ -4800,9 +4738,6 @@ up.Layer.Root = (_a = class Root extends up.Layer {
|
|
4800
4738
|
cannotCloseRoot() {
|
4801
4739
|
up.fail('Cannot close the root layer');
|
4802
4740
|
}
|
4803
|
-
reset() {
|
4804
|
-
Object.assign(this, this.defaults());
|
4805
|
-
}
|
4806
4741
|
toString() {
|
4807
4742
|
return "root layer";
|
4808
4743
|
}
|
@@ -4812,7 +4747,7 @@ up.Layer.Root = (_a = class Root extends up.Layer {
|
|
4812
4747
|
|
4813
4748
|
|
4814
4749
|
/***/ }),
|
4815
|
-
/*
|
4750
|
+
/* 52 */
|
4816
4751
|
/***/ (() => {
|
4817
4752
|
|
4818
4753
|
var _a;
|
@@ -4823,7 +4758,7 @@ up.Layer.Modal = (_a = class Modal extends up.Layer.OverlayWithViewport {
|
|
4823
4758
|
|
4824
4759
|
|
4825
4760
|
/***/ }),
|
4826
|
-
/*
|
4761
|
+
/* 53 */
|
4827
4762
|
/***/ (() => {
|
4828
4763
|
|
4829
4764
|
var _a;
|
@@ -4834,7 +4769,7 @@ up.Layer.Popup = (_a = class Popup extends up.Layer.OverlayWithTether {
|
|
4834
4769
|
|
4835
4770
|
|
4836
4771
|
/***/ }),
|
4837
|
-
/*
|
4772
|
+
/* 54 */
|
4838
4773
|
/***/ (() => {
|
4839
4774
|
|
4840
4775
|
var _a;
|
@@ -4845,7 +4780,7 @@ up.Layer.Drawer = (_a = class Drawer extends up.Layer.OverlayWithViewport {
|
|
4845
4780
|
|
4846
4781
|
|
4847
4782
|
/***/ }),
|
4848
|
-
/*
|
4783
|
+
/* 55 */
|
4849
4784
|
/***/ (() => {
|
4850
4785
|
|
4851
4786
|
var _a;
|
@@ -4856,7 +4791,7 @@ up.Layer.Cover = (_a = class Cover extends up.Layer.OverlayWithViewport {
|
|
4856
4791
|
|
4857
4792
|
|
4858
4793
|
/***/ }),
|
4859
|
-
/*
|
4794
|
+
/* 56 */
|
4860
4795
|
/***/ (() => {
|
4861
4796
|
|
4862
4797
|
const u = up.util;
|
@@ -4946,7 +4881,7 @@ up.LayerLookup = class LayerLookup {
|
|
4946
4881
|
|
4947
4882
|
|
4948
4883
|
/***/ }),
|
4949
|
-
/*
|
4884
|
+
/* 57 */
|
4950
4885
|
/***/ (() => {
|
4951
4886
|
|
4952
4887
|
const u = up.util;
|
@@ -5059,7 +4994,7 @@ up.LayerStack = class LayerStack extends Array {
|
|
5059
4994
|
|
5060
4995
|
|
5061
4996
|
/***/ }),
|
5062
|
-
/*
|
4997
|
+
/* 58 */
|
5063
4998
|
/***/ (() => {
|
5064
4999
|
|
5065
5000
|
up.LinkFeedbackURLs = class LinkFeedbackURLs {
|
@@ -5090,7 +5025,7 @@ up.LinkFeedbackURLs = class LinkFeedbackURLs {
|
|
5090
5025
|
|
5091
5026
|
|
5092
5027
|
/***/ }),
|
5093
|
-
/*
|
5028
|
+
/* 59 */
|
5094
5029
|
/***/ (() => {
|
5095
5030
|
|
5096
5031
|
const u = up.util;
|
@@ -5160,7 +5095,7 @@ up.LinkPreloader = class LinkPreloader {
|
|
5160
5095
|
|
5161
5096
|
|
5162
5097
|
/***/ }),
|
5163
|
-
/*
|
5098
|
+
/* 60 */
|
5164
5099
|
/***/ (function() {
|
5165
5100
|
|
5166
5101
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
@@ -5269,7 +5204,7 @@ up.MotionController = class MotionController {
|
|
5269
5204
|
|
5270
5205
|
|
5271
5206
|
/***/ }),
|
5272
|
-
/*
|
5207
|
+
/* 61 */
|
5273
5208
|
/***/ (() => {
|
5274
5209
|
|
5275
5210
|
const u = up.util;
|
@@ -5361,7 +5296,7 @@ up.NonceableCallback = class NonceableCallback {
|
|
5361
5296
|
|
5362
5297
|
|
5363
5298
|
/***/ }),
|
5364
|
-
/*
|
5299
|
+
/* 62 */
|
5365
5300
|
/***/ (() => {
|
5366
5301
|
|
5367
5302
|
const u = up.util;
|
@@ -5439,7 +5374,7 @@ up.OptionsParser = class OptionsParser {
|
|
5439
5374
|
|
5440
5375
|
|
5441
5376
|
/***/ }),
|
5442
|
-
/*
|
5377
|
+
/* 63 */
|
5443
5378
|
/***/ (() => {
|
5444
5379
|
|
5445
5380
|
const e = up.element;
|
@@ -5507,7 +5442,7 @@ up.OverlayFocus = class OverlayFocus {
|
|
5507
5442
|
|
5508
5443
|
|
5509
5444
|
/***/ }),
|
5510
|
-
/*
|
5445
|
+
/* 64 */
|
5511
5446
|
/***/ (() => {
|
5512
5447
|
|
5513
5448
|
const u = up.util;
|
@@ -5738,7 +5673,7 @@ up.Params = class Params {
|
|
5738
5673
|
|
5739
5674
|
|
5740
5675
|
/***/ }),
|
5741
|
-
/*
|
5676
|
+
/* 65 */
|
5742
5677
|
/***/ (() => {
|
5743
5678
|
|
5744
5679
|
const e = up.element;
|
@@ -5788,7 +5723,7 @@ up.ProgressBar = class ProgressBar {
|
|
5788
5723
|
|
5789
5724
|
|
5790
5725
|
/***/ }),
|
5791
|
-
/*
|
5726
|
+
/* 66 */
|
5792
5727
|
/***/ (() => {
|
5793
5728
|
|
5794
5729
|
const u = up.util;
|
@@ -5834,7 +5769,7 @@ up.RenderOptions = (function () {
|
|
5834
5769
|
'history',
|
5835
5770
|
'source',
|
5836
5771
|
'saveScroll',
|
5837
|
-
'navigate'
|
5772
|
+
'navigate',
|
5838
5773
|
]);
|
5839
5774
|
const CONTENT_KEYS = [
|
5840
5775
|
'url',
|
@@ -5905,7 +5840,7 @@ up.RenderOptions = (function () {
|
|
5905
5840
|
|
5906
5841
|
|
5907
5842
|
/***/ }),
|
5908
|
-
/*
|
5843
|
+
/* 67 */
|
5909
5844
|
/***/ (() => {
|
5910
5845
|
|
5911
5846
|
up.RenderResult = class RenderResult extends up.Record {
|
@@ -5933,7 +5868,7 @@ up.RenderResult = class RenderResult extends up.Record {
|
|
5933
5868
|
|
5934
5869
|
|
5935
5870
|
/***/ }),
|
5936
|
-
/*
|
5871
|
+
/* 68 */
|
5937
5872
|
/***/ (() => {
|
5938
5873
|
|
5939
5874
|
var _a;
|
@@ -5946,7 +5881,7 @@ up.Request = (_a = class Request extends up.Record {
|
|
5946
5881
|
if (this.wrapMethod == null) {
|
5947
5882
|
this.wrapMethod = up.network.config.wrapMethod;
|
5948
5883
|
}
|
5949
|
-
this.
|
5884
|
+
this.normalize();
|
5950
5885
|
if ((this.target || this.layer || this.origin) && !options.basic) {
|
5951
5886
|
const layerLookupOptions = { origin: this.origin };
|
5952
5887
|
this.layer = up.layer.get(this.layer, layerLookupOptions);
|
@@ -5958,6 +5893,7 @@ up.Request = (_a = class Request extends up.Record {
|
|
5958
5893
|
}
|
5959
5894
|
this.deferred = u.newDeferred();
|
5960
5895
|
(_a = this.badResponseTime) !== null && _a !== void 0 ? _a : (this.badResponseTime = u.evalOption(up.network.config.badResponseTime, this));
|
5896
|
+
this.addAutoHeaders();
|
5961
5897
|
}
|
5962
5898
|
keys() {
|
5963
5899
|
return [
|
@@ -5969,7 +5905,6 @@ up.Request = (_a = class Request extends up.Record {
|
|
5969
5905
|
'failTarget',
|
5970
5906
|
'headers',
|
5971
5907
|
'timeout',
|
5972
|
-
'preload',
|
5973
5908
|
'background',
|
5974
5909
|
'cache',
|
5975
5910
|
'expireCache',
|
@@ -5982,11 +5917,12 @@ up.Request = (_a = class Request extends up.Record {
|
|
5982
5917
|
'failContext',
|
5983
5918
|
'origin',
|
5984
5919
|
'fragments',
|
5985
|
-
'
|
5920
|
+
'builtAt',
|
5986
5921
|
'wrapMethod',
|
5987
5922
|
'contentType',
|
5988
5923
|
'payload',
|
5989
5924
|
'onQueued',
|
5925
|
+
'onLoading',
|
5990
5926
|
'fail',
|
5991
5927
|
'abortable',
|
5992
5928
|
'badResponseTime',
|
@@ -5997,7 +5933,8 @@ up.Request = (_a = class Request extends up.Record {
|
|
5997
5933
|
state: 'new',
|
5998
5934
|
abortable: true,
|
5999
5935
|
headers: {},
|
6000
|
-
timeout: up.network.config.timeout
|
5936
|
+
timeout: up.network.config.timeout,
|
5937
|
+
builtAt: new Date(),
|
6001
5938
|
};
|
6002
5939
|
}
|
6003
5940
|
get xhr() {
|
@@ -6020,10 +5957,7 @@ up.Request = (_a = class Request extends up.Record {
|
|
6020
5957
|
var _a;
|
6021
5958
|
return (_a = this.fragments) === null || _a === void 0 ? void 0 : _a[0];
|
6022
5959
|
}
|
6023
|
-
|
6024
|
-
u.delegate(this, ['deferred', 'state', 'preload', 'expired'], () => sourceRequest);
|
6025
|
-
}
|
6026
|
-
normalizeForCaching() {
|
5960
|
+
normalize() {
|
6027
5961
|
this.method = u.normalizeMethod(this.method);
|
6028
5962
|
this.extractHashFromURL();
|
6029
5963
|
this.transferParamsToURL();
|
@@ -6070,16 +6004,29 @@ up.Request = (_a = class Request extends up.Record {
|
|
6070
6004
|
(_a = this.onQueued) === null || _a === void 0 ? void 0 : _a.call(this, this);
|
6071
6005
|
}
|
6072
6006
|
load() {
|
6007
|
+
var _a;
|
6073
6008
|
if (this.state !== 'new')
|
6074
6009
|
return;
|
6075
|
-
this.
|
6076
|
-
|
6077
|
-
|
6078
|
-
|
6079
|
-
|
6080
|
-
|
6081
|
-
|
6082
|
-
|
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;
|
6083
6030
|
}
|
6084
6031
|
loadPage() {
|
6085
6032
|
up.network.abort();
|
@@ -6123,18 +6070,19 @@ up.Request = (_a = class Request extends up.Record {
|
|
6123
6070
|
this.emit('up:request:offline', { log: message });
|
6124
6071
|
}
|
6125
6072
|
respondWith(response) {
|
6126
|
-
|
6073
|
+
this.response = response;
|
6074
|
+
if (this.isSettled())
|
6127
6075
|
return;
|
6128
6076
|
this.state = 'loaded';
|
6129
6077
|
if (response.ok) {
|
6130
|
-
|
6078
|
+
this.deferred.resolve(response);
|
6131
6079
|
}
|
6132
6080
|
else {
|
6133
|
-
|
6081
|
+
this.deferred.reject(response);
|
6134
6082
|
}
|
6135
6083
|
}
|
6136
6084
|
isSettled() {
|
6137
|
-
return (this.state !== 'new') && (this.state !== 'loading');
|
6085
|
+
return (this.state !== 'new') && (this.state !== 'loading') && (this.state !== 'tracking');
|
6138
6086
|
}
|
6139
6087
|
csrfHeader() {
|
6140
6088
|
return up.protocol.csrfHeader();
|
@@ -6181,24 +6129,6 @@ up.Request = (_a = class Request extends up.Record {
|
|
6181
6129
|
}
|
6182
6130
|
return new up.Response(responseAttrs);
|
6183
6131
|
}
|
6184
|
-
cacheKey() {
|
6185
|
-
return JSON.stringify([
|
6186
|
-
this.method,
|
6187
|
-
this.url,
|
6188
|
-
this.params.toQuery(),
|
6189
|
-
this.metaProps()
|
6190
|
-
]);
|
6191
|
-
}
|
6192
|
-
metaProps() {
|
6193
|
-
const props = {};
|
6194
|
-
for (let key of u.evalOption(up.network.config.requestMetaKeys, this)) {
|
6195
|
-
const value = this[key];
|
6196
|
-
if (u.isGiven(value)) {
|
6197
|
-
props[key] = value;
|
6198
|
-
}
|
6199
|
-
}
|
6200
|
-
return props;
|
6201
|
-
}
|
6202
6132
|
buildEventEmitter(args) {
|
6203
6133
|
return up.EventEmitter.fromEmitArgs(args, {
|
6204
6134
|
layer: this.layer,
|
@@ -6224,9 +6154,27 @@ up.Request = (_a = class Request extends up.Record {
|
|
6224
6154
|
return u.some(subtreeElements, (subtreeElement) => subtreeElement.contains(fragment));
|
6225
6155
|
});
|
6226
6156
|
}
|
6227
|
-
get
|
6228
|
-
|
6229
|
-
|
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;
|
6230
6178
|
}
|
6231
6179
|
static tester(condition, { except } = {}) {
|
6232
6180
|
let testFn;
|
@@ -6244,8 +6192,7 @@ up.Request = (_a = class Request extends up.Record {
|
|
6244
6192
|
testFn = (_request) => condition;
|
6245
6193
|
}
|
6246
6194
|
if (except) {
|
6247
|
-
|
6248
|
-
return (request) => (request.cacheKey() !== exceptCacheKey) && testFn(request);
|
6195
|
+
return (request) => !up.cache.willHaveSameResponse(request, except) && testFn(request);
|
6249
6196
|
}
|
6250
6197
|
else {
|
6251
6198
|
return testFn;
|
@@ -6259,39 +6206,158 @@ up.Request = (_a = class Request extends up.Record {
|
|
6259
6206
|
|
6260
6207
|
|
6261
6208
|
/***/ }),
|
6262
|
-
/*
|
6263
|
-
/***/ (()
|
6209
|
+
/* 69 */
|
6210
|
+
/***/ (function() {
|
6264
6211
|
|
6265
|
-
|
6266
|
-
|
6267
|
-
|
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() {
|
6268
6253
|
return up.network.config.cacheSize;
|
6269
6254
|
}
|
6270
|
-
|
6271
|
-
return up.network.config.cacheEvictAge;
|
6255
|
+
isUsable(request) {
|
6256
|
+
return request.age < up.network.config.cacheEvictAge;
|
6257
|
+
}
|
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;
|
6272
6327
|
}
|
6273
|
-
|
6274
|
-
|
6328
|
+
delete(request) {
|
6329
|
+
request = this.wrap(request);
|
6330
|
+
let cacheKey = this.cacheKey(request);
|
6331
|
+
this.map.delete(cacheKey);
|
6275
6332
|
}
|
6276
6333
|
evict(condition = true, testerOptions) {
|
6277
|
-
this.eachMatch(condition, testerOptions, (
|
6334
|
+
this.eachMatch(condition, testerOptions, (request) => this.delete(request));
|
6278
6335
|
}
|
6279
6336
|
expire(condition = true, testerOptions) {
|
6280
|
-
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
|
+
}
|
6281
6344
|
}
|
6282
6345
|
eachMatch(condition = true, testerOptions, fn) {
|
6283
6346
|
let tester = up.Request.tester(condition, testerOptions);
|
6284
|
-
|
6285
|
-
|
6286
|
-
|
6287
|
-
|
6288
|
-
|
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);
|
6289
6355
|
}
|
6290
6356
|
};
|
6291
6357
|
|
6292
6358
|
|
6293
6359
|
/***/ }),
|
6294
|
-
/*
|
6360
|
+
/* 70 */
|
6295
6361
|
/***/ (() => {
|
6296
6362
|
|
6297
6363
|
const u = up.util;
|
@@ -6310,7 +6376,6 @@ up.Request.Queue = class Queue {
|
|
6310
6376
|
asap(request) {
|
6311
6377
|
request.runQueuedCallbacks();
|
6312
6378
|
u.always(request, responseOrError => this.onRequestSettled(request, responseOrError));
|
6313
|
-
request.queuedAt = new Date();
|
6314
6379
|
this.scheduleSlowTimer(request);
|
6315
6380
|
this.queueRequest(request);
|
6316
6381
|
u.microtask(() => this.poke());
|
@@ -6322,7 +6387,7 @@ up.Request.Queue = class Queue {
|
|
6322
6387
|
}
|
6323
6388
|
}
|
6324
6389
|
scheduleSlowTimer(request) {
|
6325
|
-
let timeUntilLate = Math.max(request.badResponseTime - request.
|
6390
|
+
let timeUntilLate = Math.max(request.badResponseTime - request.age, 0);
|
6326
6391
|
u.timer(timeUntilLate, () => this.checkLate());
|
6327
6392
|
}
|
6328
6393
|
getMaxConcurrency() {
|
@@ -6344,13 +6409,8 @@ up.Request.Queue = class Queue {
|
|
6344
6409
|
return u.remove(this.queuedRequests, request);
|
6345
6410
|
}
|
6346
6411
|
sendRequestNow(request) {
|
6347
|
-
if (request.
|
6348
|
-
request.abort({ reason: 'Prevented by event listener' });
|
6349
|
-
}
|
6350
|
-
else {
|
6351
|
-
request.normalizeForCaching();
|
6412
|
+
if (request.load()) {
|
6352
6413
|
this.currentRequests.push(request);
|
6353
|
-
request.load();
|
6354
6414
|
}
|
6355
6415
|
}
|
6356
6416
|
onRequestSettled(request, responseOrError) {
|
@@ -6400,13 +6460,13 @@ up.Request.Queue = class Queue {
|
|
6400
6460
|
isLate() {
|
6401
6461
|
const allForegroundRequests = u.reject(this.allRequests, 'background');
|
6402
6462
|
const timerTolerance = 1;
|
6403
|
-
return u.some(allForegroundRequests, request => request.
|
6463
|
+
return u.some(allForegroundRequests, (request) => request.age >= (request.badResponseTime - timerTolerance));
|
6404
6464
|
}
|
6405
6465
|
};
|
6406
6466
|
|
6407
6467
|
|
6408
6468
|
/***/ }),
|
6409
|
-
/*
|
6469
|
+
/* 71 */
|
6410
6470
|
/***/ (() => {
|
6411
6471
|
|
6412
6472
|
const u = up.util;
|
@@ -6445,7 +6505,7 @@ up.Request.FormRenderer = class FormRenderer {
|
|
6445
6505
|
|
6446
6506
|
|
6447
6507
|
/***/ }),
|
6448
|
-
/*
|
6508
|
+
/* 72 */
|
6449
6509
|
/***/ (() => {
|
6450
6510
|
|
6451
6511
|
var _a;
|
@@ -6463,21 +6523,13 @@ up.Request.XHRRenderer = (_a = class XHRRenderer {
|
|
6463
6523
|
xhr.timeout = this.request.timeout;
|
6464
6524
|
}
|
6465
6525
|
xhr.open(this.getMethod(), this.request.url);
|
6466
|
-
const metaProps = this.request.metaProps();
|
6467
|
-
for (let key in metaProps) {
|
6468
|
-
this.addHeader(xhr, up.protocol.headerize(key), metaProps[key]);
|
6469
|
-
}
|
6470
|
-
for (let header in this.request.headers) {
|
6471
|
-
this.addHeader(xhr, header, this.request.headers[header]);
|
6472
|
-
}
|
6473
|
-
let csrfHeader, csrfToken;
|
6474
|
-
if ((csrfHeader = this.request.csrfHeader()) && (csrfToken = this.request.csrfToken())) {
|
6475
|
-
this.addHeader(xhr, csrfHeader, csrfToken);
|
6476
|
-
}
|
6477
|
-
this.addHeader(xhr, up.protocol.headerize('version'), up.version);
|
6478
6526
|
let contentType = this.getContentType();
|
6479
6527
|
if (contentType) {
|
6480
|
-
|
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);
|
6481
6533
|
}
|
6482
6534
|
Object.assign(xhr, handlers);
|
6483
6535
|
xhr.send(this.getPayload());
|
@@ -6499,12 +6551,6 @@ up.Request.XHRRenderer = (_a = class XHRRenderer {
|
|
6499
6551
|
this.finalizePayload();
|
6500
6552
|
return this.payload;
|
6501
6553
|
}
|
6502
|
-
addHeader(xhr, header, value) {
|
6503
|
-
if (u.isOptions(value) || u.isArray(value)) {
|
6504
|
-
value = JSON.stringify(value);
|
6505
|
-
}
|
6506
|
-
xhr.setRequestHeader(header, value);
|
6507
|
-
}
|
6508
6554
|
finalizePayload() {
|
6509
6555
|
this.payload = this.request.payload;
|
6510
6556
|
this.contentType = this.request.contentType;
|
@@ -6531,7 +6577,7 @@ up.Request.XHRRenderer = (_a = class XHRRenderer {
|
|
6531
6577
|
|
6532
6578
|
|
6533
6579
|
/***/ }),
|
6534
|
-
/*
|
6580
|
+
/* 73 */
|
6535
6581
|
/***/ (() => {
|
6536
6582
|
|
6537
6583
|
const u = up.util;
|
@@ -6567,24 +6613,28 @@ up.Response = class Response extends up.Record {
|
|
6567
6613
|
var _a;
|
6568
6614
|
return !u.evalOption((_a = this.fail) !== null && _a !== void 0 ? _a : up.network.config.fail, this);
|
6569
6615
|
}
|
6570
|
-
|
6616
|
+
header(name) {
|
6571
6617
|
var _a;
|
6572
6618
|
return this.headers[name] || ((_a = this.xhr) === null || _a === void 0 ? void 0 : _a.getResponseHeader(name));
|
6573
6619
|
}
|
6620
|
+
get ownInfluncingHeaders() {
|
6621
|
+
let influencingHeaders = up.protocol.influencingHeadersFromResponse(this);
|
6622
|
+
return u.filter(influencingHeaders, (headerName) => this.request.header(headerName));
|
6623
|
+
}
|
6574
6624
|
get contentType() {
|
6575
|
-
return this.
|
6625
|
+
return this.header('Content-Type');
|
6576
6626
|
}
|
6577
6627
|
get cspNonces() {
|
6578
|
-
return up.protocol.cspNoncesFromHeader(this.
|
6628
|
+
return up.protocol.cspNoncesFromHeader(this.header('Content-Security-Policy'));
|
6579
6629
|
}
|
6580
6630
|
get lastModified() {
|
6581
|
-
let header = this.
|
6631
|
+
let header = this.header('Last-Modified');
|
6582
6632
|
if (header) {
|
6583
6633
|
return new Date(header);
|
6584
6634
|
}
|
6585
6635
|
}
|
6586
6636
|
get etag() {
|
6587
|
-
return this.
|
6637
|
+
return this.header('ETag');
|
6588
6638
|
}
|
6589
6639
|
get json() {
|
6590
6640
|
return this.parsedJSON || (this.parsedJSON = JSON.parse(this.text));
|
@@ -6594,7 +6644,8 @@ up.Response = class Response extends up.Record {
|
|
6594
6644
|
return now - this.loadedAt;
|
6595
6645
|
}
|
6596
6646
|
get expired() {
|
6597
|
-
return this.age > up.network.config.cacheExpireAge ||
|
6647
|
+
return this.age > up.network.config.cacheExpireAge ||
|
6648
|
+
this.request.expired;
|
6598
6649
|
}
|
6599
6650
|
get description() {
|
6600
6651
|
return `HTTP ${this.status} response to ${this.request.description}`;
|
@@ -6603,7 +6654,7 @@ up.Response = class Response extends up.Record {
|
|
6603
6654
|
|
6604
6655
|
|
6605
6656
|
/***/ }),
|
6606
|
-
/*
|
6657
|
+
/* 74 */
|
6607
6658
|
/***/ (() => {
|
6608
6659
|
|
6609
6660
|
var _a;
|
@@ -6611,12 +6662,13 @@ const u = up.util;
|
|
6611
6662
|
const e = up.element;
|
6612
6663
|
up.ResponseDoc = (_a = class ResponseDoc {
|
6613
6664
|
constructor(options) {
|
6614
|
-
this.noscriptWrapper = new up.HTMLWrapper('noscript');
|
6615
|
-
this.scriptWrapper = new up.HTMLWrapper('script');
|
6616
6665
|
this.root =
|
6617
6666
|
this.parseDocument(options) ||
|
6618
6667
|
this.parseFragment(options) ||
|
6619
6668
|
this.parseContent(options);
|
6669
|
+
if (!up.fragment.config.runScripts) {
|
6670
|
+
this.root.querySelectorAll('script').forEach((e) => e.remove());
|
6671
|
+
}
|
6620
6672
|
this.cspNonces = options.cspNonces;
|
6621
6673
|
if (options.origin) {
|
6622
6674
|
let originSelector = up.fragment.tryToTarget(options.origin);
|
@@ -6626,7 +6678,11 @@ up.ResponseDoc = (_a = class ResponseDoc {
|
|
6626
6678
|
}
|
6627
6679
|
}
|
6628
6680
|
parseDocument(options) {
|
6629
|
-
|
6681
|
+
let document = this.parse(options.document, e.createBrokenDocumentFromHTML);
|
6682
|
+
if (document) {
|
6683
|
+
this.scriptishNeedFix = true;
|
6684
|
+
return document;
|
6685
|
+
}
|
6630
6686
|
}
|
6631
6687
|
parseContent(options) {
|
6632
6688
|
let content = options.content || '';
|
@@ -6634,7 +6690,6 @@ up.ResponseDoc = (_a = class ResponseDoc {
|
|
6634
6690
|
target = u.map(up.fragment.parseTargetSteps(target), 'selector').join(',');
|
6635
6691
|
const matchingElement = e.createFromSelector(target);
|
6636
6692
|
if (u.isString(content)) {
|
6637
|
-
content = this.wrapHTML(content);
|
6638
6693
|
matchingElement.innerHTML = content;
|
6639
6694
|
}
|
6640
6695
|
else {
|
@@ -6647,7 +6702,6 @@ up.ResponseDoc = (_a = class ResponseDoc {
|
|
6647
6702
|
}
|
6648
6703
|
parse(value, parseFn = e.createFromHTML) {
|
6649
6704
|
if (u.isString(value)) {
|
6650
|
-
value = this.wrapHTML(value);
|
6651
6705
|
value = parseFn(value);
|
6652
6706
|
}
|
6653
6707
|
return value;
|
@@ -6655,19 +6709,9 @@ up.ResponseDoc = (_a = class ResponseDoc {
|
|
6655
6709
|
rootSelector() {
|
6656
6710
|
return up.fragment.toTarget(this.root);
|
6657
6711
|
}
|
6658
|
-
wrapHTML(html) {
|
6659
|
-
html = this.noscriptWrapper.wrap(html);
|
6660
|
-
if (up.fragment.config.runScripts) {
|
6661
|
-
html = this.scriptWrapper.wrap(html);
|
6662
|
-
}
|
6663
|
-
else {
|
6664
|
-
html = this.scriptWrapper.strip(html);
|
6665
|
-
}
|
6666
|
-
return html;
|
6667
|
-
}
|
6668
6712
|
getTitle() {
|
6669
6713
|
var _a;
|
6670
|
-
return (_a = this.root.querySelector(
|
6714
|
+
return (_a = this.root.querySelector('head title')) === null || _a === void 0 ? void 0 : _a.textContent;
|
6671
6715
|
}
|
6672
6716
|
select(selector) {
|
6673
6717
|
let finder = new up.FragmentFinder({
|
@@ -6678,9 +6722,10 @@ up.ResponseDoc = (_a = class ResponseDoc {
|
|
6678
6722
|
return finder.find();
|
6679
6723
|
}
|
6680
6724
|
finalizeElement(element) {
|
6681
|
-
this.noscriptWrapper.unwrap(element);
|
6682
6725
|
up.NonceableCallback.adoptNonces(element, this.cspNonces);
|
6683
|
-
this.
|
6726
|
+
if (this.scriptishNeedFix) {
|
6727
|
+
element.querySelectorAll('noscript, script').forEach(e.fixScriptish);
|
6728
|
+
}
|
6684
6729
|
}
|
6685
6730
|
},
|
6686
6731
|
(() => {
|
@@ -6690,7 +6735,7 @@ up.ResponseDoc = (_a = class ResponseDoc {
|
|
6690
6735
|
|
6691
6736
|
|
6692
6737
|
/***/ }),
|
6693
|
-
/*
|
6738
|
+
/* 75 */
|
6694
6739
|
/***/ (() => {
|
6695
6740
|
|
6696
6741
|
const e = up.element;
|
@@ -6785,7 +6830,7 @@ up.RevealMotion = class RevealMotion {
|
|
6785
6830
|
|
6786
6831
|
|
6787
6832
|
/***/ }),
|
6788
|
-
/*
|
6833
|
+
/* 76 */
|
6789
6834
|
/***/ (() => {
|
6790
6835
|
|
6791
6836
|
const u = up.util;
|
@@ -6826,7 +6871,7 @@ up.Selector = class Selector {
|
|
6826
6871
|
|
6827
6872
|
|
6828
6873
|
/***/ }),
|
6829
|
-
/*
|
6874
|
+
/* 77 */
|
6830
6875
|
/***/ (() => {
|
6831
6876
|
|
6832
6877
|
const u = up.util;
|
@@ -6947,7 +6992,7 @@ up.Tether = class Tether {
|
|
6947
6992
|
|
6948
6993
|
|
6949
6994
|
/***/ }),
|
6950
|
-
/*
|
6995
|
+
/* 78 */
|
6951
6996
|
/***/ (() => {
|
6952
6997
|
|
6953
6998
|
const u = up.util;
|
@@ -7028,7 +7073,7 @@ up.URLPattern = class URLPattern {
|
|
7028
7073
|
|
7029
7074
|
|
7030
7075
|
/***/ }),
|
7031
|
-
/*
|
7076
|
+
/* 79 */
|
7032
7077
|
/***/ (() => {
|
7033
7078
|
|
7034
7079
|
up.framework = (function () {
|
@@ -7046,6 +7091,7 @@ up.framework = (function () {
|
|
7046
7091
|
readyState = 'booting';
|
7047
7092
|
up.emit('up:framework:boot', { log: false });
|
7048
7093
|
readyState = 'booted';
|
7094
|
+
up.emit('up:framework:booted', { log: false });
|
7049
7095
|
}
|
7050
7096
|
else {
|
7051
7097
|
console.error("Unpoly cannot boot: %s", issue);
|
@@ -7111,7 +7157,7 @@ up.boot = up.framework.boot;
|
|
7111
7157
|
|
7112
7158
|
|
7113
7159
|
/***/ }),
|
7114
|
-
/*
|
7160
|
+
/* 80 */
|
7115
7161
|
/***/ (() => {
|
7116
7162
|
|
7117
7163
|
up.event = (function () {
|
@@ -7127,9 +7173,6 @@ up.event = (function () {
|
|
7127
7173
|
function on(...args) {
|
7128
7174
|
return buildListenerGroup(args).bind();
|
7129
7175
|
}
|
7130
|
-
function $on(...args) {
|
7131
|
-
return buildListenerGroup(args, { jQuery: true }).bind();
|
7132
|
-
}
|
7133
7176
|
function off(...args) {
|
7134
7177
|
return buildListenerGroup(args).unbind();
|
7135
7178
|
}
|
@@ -7200,7 +7243,6 @@ up.event = (function () {
|
|
7200
7243
|
on('up:framework:reset', reset);
|
7201
7244
|
return {
|
7202
7245
|
on,
|
7203
|
-
$on,
|
7204
7246
|
off,
|
7205
7247
|
build,
|
7206
7248
|
emit,
|
@@ -7213,14 +7255,12 @@ up.event = (function () {
|
|
7213
7255
|
};
|
7214
7256
|
})();
|
7215
7257
|
up.on = up.event.on;
|
7216
|
-
up.$on = up.event.$on;
|
7217
7258
|
up.off = up.event.off;
|
7218
|
-
up.$off = up.event.off;
|
7219
7259
|
up.emit = up.event.emit;
|
7220
7260
|
|
7221
7261
|
|
7222
7262
|
/***/ }),
|
7223
|
-
/*
|
7263
|
+
/* 81 */
|
7224
7264
|
/***/ (() => {
|
7225
7265
|
|
7226
7266
|
up.protocol = (function () {
|
@@ -7236,6 +7276,9 @@ up.protocol = (function () {
|
|
7236
7276
|
return parseFn(value);
|
7237
7277
|
}
|
7238
7278
|
};
|
7279
|
+
function targetFromXHR(xhr) {
|
7280
|
+
return extractHeader(xhr, 'target');
|
7281
|
+
}
|
7239
7282
|
function parseModifyCacheValue(value) {
|
7240
7283
|
if (value === 'false') {
|
7241
7284
|
return false;
|
@@ -7257,6 +7300,10 @@ up.protocol = (function () {
|
|
7257
7300
|
function methodFromXHR(xhr) {
|
7258
7301
|
return extractHeader(xhr, 'method', u.normalizeMethod);
|
7259
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
|
+
}
|
7260
7307
|
function eventPlansFromXHR(xhr) {
|
7261
7308
|
return extractHeader(xhr, 'events', JSON.parse);
|
7262
7309
|
}
|
@@ -7272,11 +7319,9 @@ up.protocol = (function () {
|
|
7272
7319
|
function locationFromXHR(xhr) {
|
7273
7320
|
return extractHeader(xhr, 'location') || xhr.responseURL;
|
7274
7321
|
}
|
7275
|
-
function
|
7276
|
-
|
7277
|
-
|
7278
|
-
function targetFromXHR(xhr) {
|
7279
|
-
return extractHeader(xhr, 'target');
|
7322
|
+
function influencingHeadersFromResponse(response) {
|
7323
|
+
let varyHeaderValue = response.header('Vary');
|
7324
|
+
return u.parseTokens(varyHeaderValue, { separator: 'comma' });
|
7280
7325
|
}
|
7281
7326
|
const config = new up.Config(() => ({
|
7282
7327
|
methodParam: '_method',
|
@@ -7352,12 +7397,13 @@ up.protocol = (function () {
|
|
7352
7397
|
headerize,
|
7353
7398
|
wrapMethod,
|
7354
7399
|
cspNoncesFromHeader,
|
7400
|
+
influencingHeadersFromResponse,
|
7355
7401
|
};
|
7356
7402
|
})();
|
7357
7403
|
|
7358
7404
|
|
7359
7405
|
/***/ }),
|
7360
|
-
/*
|
7406
|
+
/* 82 */
|
7361
7407
|
/***/ (() => {
|
7362
7408
|
|
7363
7409
|
up.log = (function () {
|
@@ -7443,7 +7489,7 @@ up.warn = up.log.warn;
|
|
7443
7489
|
|
7444
7490
|
|
7445
7491
|
/***/ }),
|
7446
|
-
/*
|
7492
|
+
/* 83 */
|
7447
7493
|
/***/ (() => {
|
7448
7494
|
|
7449
7495
|
up.syntax = (function () {
|
@@ -7467,9 +7513,6 @@ up.syntax = (function () {
|
|
7467
7513
|
const compiler = buildCompiler(args);
|
7468
7514
|
return insertCompiler(registeredCompilers, compiler);
|
7469
7515
|
}
|
7470
|
-
function registerJQueryCompiler(...args) {
|
7471
|
-
registerCompiler(...args, { jQuery: true });
|
7472
|
-
}
|
7473
7516
|
function registerMacro(...args) {
|
7474
7517
|
const macro = buildCompiler(args);
|
7475
7518
|
if (up.framework.evaling) {
|
@@ -7478,9 +7521,6 @@ up.syntax = (function () {
|
|
7478
7521
|
}
|
7479
7522
|
return insertCompiler(registeredMacros, macro);
|
7480
7523
|
}
|
7481
|
-
function registerJQueryMacro(...args) {
|
7482
|
-
registerMacro(...args, { jQuery: true });
|
7483
|
-
}
|
7484
7524
|
function detectSystemMacroPriority(macroSelector) {
|
7485
7525
|
macroSelector = u.evalOption(macroSelector);
|
7486
7526
|
for (let substr in SYSTEM_MACRO_PRIORITIES) {
|
@@ -7504,7 +7544,6 @@ up.syntax = (function () {
|
|
7504
7544
|
isDefault: up.framework.evaling,
|
7505
7545
|
priority: 0,
|
7506
7546
|
batch: false,
|
7507
|
-
jQuery: false
|
7508
7547
|
});
|
7509
7548
|
return Object.assign(callback, options);
|
7510
7549
|
}
|
@@ -7546,10 +7585,10 @@ up.syntax = (function () {
|
|
7546
7585
|
destructors.push(destructor);
|
7547
7586
|
}
|
7548
7587
|
}
|
7549
|
-
function hello(element,
|
7550
|
-
element = up.fragment.get(element);
|
7588
|
+
function hello(element, options = {}) {
|
7589
|
+
element = up.fragment.get(element, options);
|
7551
7590
|
up.puts('up.hello()', "Compiling fragment %o", element);
|
7552
|
-
compile(element,
|
7591
|
+
compile(element, options);
|
7553
7592
|
up.fragment.emitInserted(element);
|
7554
7593
|
return element;
|
7555
7594
|
}
|
@@ -7582,8 +7621,6 @@ up.syntax = (function () {
|
|
7582
7621
|
return {
|
7583
7622
|
compiler: registerCompiler,
|
7584
7623
|
macro: registerMacro,
|
7585
|
-
$compiler: registerJQueryCompiler,
|
7586
|
-
$macro: registerJQueryMacro,
|
7587
7624
|
destructor: registerDestructor,
|
7588
7625
|
hello,
|
7589
7626
|
clean,
|
@@ -7591,16 +7628,14 @@ up.syntax = (function () {
|
|
7591
7628
|
};
|
7592
7629
|
})();
|
7593
7630
|
up.compiler = up.syntax.compiler;
|
7594
|
-
up.$compiler = up.syntax.$compiler;
|
7595
7631
|
up.destructor = up.syntax.destructor;
|
7596
7632
|
up.macro = up.syntax.macro;
|
7597
|
-
up.$macro = up.syntax.$macro;
|
7598
7633
|
up.data = up.syntax.data;
|
7599
7634
|
up.hello = up.syntax.hello;
|
7600
7635
|
|
7601
7636
|
|
7602
7637
|
/***/ }),
|
7603
|
-
/*
|
7638
|
+
/* 84 */
|
7604
7639
|
/***/ (() => {
|
7605
7640
|
|
7606
7641
|
up.history = (function () {
|
@@ -7670,7 +7705,7 @@ up.history = (function () {
|
|
7670
7705
|
}
|
7671
7706
|
function restoreStateOnPop(state) {
|
7672
7707
|
if (!(state === null || state === void 0 ? void 0 : state.up)) {
|
7673
|
-
up.puts('
|
7708
|
+
up.puts('popstate', 'Ignoring a history state not owned by Unpoly');
|
7674
7709
|
return;
|
7675
7710
|
}
|
7676
7711
|
let location = currentLocation();
|
@@ -7737,10 +7772,10 @@ up.history = (function () {
|
|
7737
7772
|
|
7738
7773
|
|
7739
7774
|
/***/ }),
|
7740
|
-
/*
|
7775
|
+
/* 85 */
|
7741
7776
|
/***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
|
7742
7777
|
|
7743
|
-
__webpack_require__(
|
7778
|
+
__webpack_require__(86);
|
7744
7779
|
const u = up.util;
|
7745
7780
|
const e = up.element;
|
7746
7781
|
up.fragment = (function () {
|
@@ -7791,7 +7826,7 @@ up.fragment = (function () {
|
|
7791
7826
|
autoRevalidate: (response) => response.expired,
|
7792
7827
|
skipResponse: defaultSkipResponse
|
7793
7828
|
}));
|
7794
|
-
u.delegate(config, 'mainTargets', () => up.layer.config.any);
|
7829
|
+
u.delegate(config, ['mainTargets'], () => up.layer.config.any);
|
7795
7830
|
function reset() {
|
7796
7831
|
config.reset();
|
7797
7832
|
}
|
@@ -8258,20 +8293,20 @@ up.destroy = up.fragment.destroy;
|
|
8258
8293
|
up.render = up.fragment.render;
|
8259
8294
|
up.navigate = up.fragment.navigate;
|
8260
8295
|
up.visit = up.fragment.visit;
|
8261
|
-
u.delegate(up, 'context', () => up.layer.current);
|
8296
|
+
u.delegate(up, ['context'], () => up.layer.current);
|
8262
8297
|
|
8263
8298
|
|
8264
8299
|
/***/ }),
|
8265
|
-
/*
|
8300
|
+
/* 86 */
|
8266
8301
|
/***/ (() => {
|
8267
8302
|
|
8268
8303
|
|
8269
8304
|
|
8270
8305
|
/***/ }),
|
8271
|
-
/*
|
8306
|
+
/* 87 */
|
8272
8307
|
/***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
|
8273
8308
|
|
8274
|
-
__webpack_require__(
|
8309
|
+
__webpack_require__(88);
|
8275
8310
|
up.viewport = (function () {
|
8276
8311
|
const u = up.util;
|
8277
8312
|
const e = up.element;
|
@@ -8454,7 +8489,7 @@ up.viewport = (function () {
|
|
8454
8489
|
}
|
8455
8490
|
}
|
8456
8491
|
function newStateCache() {
|
8457
|
-
return new up.
|
8492
|
+
return new up.FIFOCache({ capacity: 30, normalizeKey: up.history.normalizeURL });
|
8458
8493
|
}
|
8459
8494
|
function parseOptions(args) {
|
8460
8495
|
const options = u.copy(u.extractOptions(args));
|
@@ -8593,13 +8628,13 @@ up.reveal = up.viewport.reveal;
|
|
8593
8628
|
|
8594
8629
|
|
8595
8630
|
/***/ }),
|
8596
|
-
/*
|
8631
|
+
/* 88 */
|
8597
8632
|
/***/ (() => {
|
8598
8633
|
|
8599
8634
|
|
8600
8635
|
|
8601
8636
|
/***/ }),
|
8602
|
-
/*
|
8637
|
+
/* 89 */
|
8603
8638
|
/***/ (function() {
|
8604
8639
|
|
8605
8640
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
@@ -8865,10 +8900,10 @@ up.animate = up.motion.animate;
|
|
8865
8900
|
|
8866
8901
|
|
8867
8902
|
/***/ }),
|
8868
|
-
/*
|
8903
|
+
/* 90 */
|
8869
8904
|
/***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
|
8870
8905
|
|
8871
|
-
__webpack_require__(
|
8906
|
+
__webpack_require__(91);
|
8872
8907
|
const u = up.util;
|
8873
8908
|
up.network = (function () {
|
8874
8909
|
const config = new up.Config(() => ({
|
@@ -8884,7 +8919,6 @@ up.network = (function () {
|
|
8884
8919
|
autoCache(request) { return request.isSafe(); },
|
8885
8920
|
expireCache(request, _response) { return !request.isSafe(); },
|
8886
8921
|
evictCache: false,
|
8887
|
-
requestMetaKeys: ['target', 'failTarget', 'mode', 'failMode', 'context', 'failContext'],
|
8888
8922
|
progressBar: true,
|
8889
8923
|
timeout: 90000,
|
8890
8924
|
}));
|
@@ -8895,14 +8929,14 @@ up.network = (function () {
|
|
8895
8929
|
abortRequests();
|
8896
8930
|
queue.reset();
|
8897
8931
|
config.reset();
|
8898
|
-
cache.
|
8932
|
+
cache.reset();
|
8899
8933
|
progressBar === null || progressBar === void 0 ? void 0 : progressBar.destroy();
|
8900
8934
|
progressBar = null;
|
8901
8935
|
}
|
8902
8936
|
function makeRequest(...args) {
|
8903
8937
|
const options = parseRequestOptions(args);
|
8904
8938
|
const request = new up.Request(options);
|
8905
|
-
|
8939
|
+
processRequest(request);
|
8906
8940
|
return request;
|
8907
8941
|
}
|
8908
8942
|
function parseRequestOptions(args) {
|
@@ -8914,31 +8948,31 @@ up.network = (function () {
|
|
8914
8948
|
(_b = (_a = up.migrate).handleRequestOptions) === null || _b === void 0 ? void 0 : _b.call(_a, options);
|
8915
8949
|
return options;
|
8916
8950
|
}
|
8917
|
-
function
|
8951
|
+
function processRequest(request) {
|
8952
|
+
useCachedRequest(request) || queueRequest(request);
|
8953
|
+
}
|
8954
|
+
function useCachedRequest(newRequest) {
|
8918
8955
|
let cachedRequest;
|
8919
|
-
if (
|
8920
|
-
up.puts('up.request()', 'Re-using previous request to %s
|
8921
|
-
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) {
|
8922
8959
|
queue.promoteToForeground(cachedRequest);
|
8923
8960
|
}
|
8924
|
-
|
8925
|
-
request.fromCache = true;
|
8961
|
+
cache.track(cachedRequest, newRequest, { onIncompatible: processRequest });
|
8926
8962
|
return true;
|
8927
8963
|
}
|
8928
8964
|
}
|
8929
8965
|
function queueRequest(request) {
|
8930
|
-
if (request.preload && !request.isSafe()) {
|
8931
|
-
up.fail('Will not preload request to %s', request.description);
|
8932
|
-
}
|
8933
8966
|
handleCaching(request);
|
8934
8967
|
queue.asap(request);
|
8935
8968
|
return true;
|
8936
8969
|
}
|
8937
8970
|
function handleCaching(request) {
|
8938
8971
|
if (request.willCache()) {
|
8939
|
-
cache.
|
8972
|
+
cache.put(request);
|
8973
|
+
request.onLoading = () => cache.put(request);
|
8940
8974
|
}
|
8941
|
-
|
8975
|
+
u.always(request, function (response) {
|
8942
8976
|
var _a, _b, _c, _d;
|
8943
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);
|
8944
8978
|
if (expireCache) {
|
@@ -8949,7 +8983,7 @@ up.network = (function () {
|
|
8949
8983
|
cache.evict(evictCache, { except: request });
|
8950
8984
|
}
|
8951
8985
|
if (cache.get(request)) {
|
8952
|
-
cache.
|
8986
|
+
cache.put(request);
|
8953
8987
|
}
|
8954
8988
|
if (!response.ok) {
|
8955
8989
|
cache.evict(request);
|
@@ -9015,13 +9049,13 @@ up.cache = up.network.cache;
|
|
9015
9049
|
|
9016
9050
|
|
9017
9051
|
/***/ }),
|
9018
|
-
/*
|
9052
|
+
/* 91 */
|
9019
9053
|
/***/ (() => {
|
9020
9054
|
|
9021
9055
|
|
9022
9056
|
|
9023
9057
|
/***/ }),
|
9024
|
-
/*
|
9058
|
+
/* 92 */
|
9025
9059
|
/***/ (function(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) {
|
9026
9060
|
|
9027
9061
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
@@ -9033,7 +9067,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
9033
9067
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
9034
9068
|
});
|
9035
9069
|
};
|
9036
|
-
__webpack_require__(
|
9070
|
+
__webpack_require__(93);
|
9037
9071
|
const u = up.util;
|
9038
9072
|
const e = up.element;
|
9039
9073
|
up.layer = (function () {
|
@@ -9160,6 +9194,7 @@ up.layer = (function () {
|
|
9160
9194
|
options.baseLayer = stack.get('current', Object.assign(Object.assign({}, options), { normalizeLayerOptions: false }));
|
9161
9195
|
}
|
9162
9196
|
function build(options, beforeNew) {
|
9197
|
+
var _a;
|
9163
9198
|
const { mode } = options;
|
9164
9199
|
const { Class } = config[mode];
|
9165
9200
|
const configs = u.reverse(modeConfigs(mode));
|
@@ -9167,6 +9202,7 @@ up.layer = (function () {
|
|
9167
9202
|
if (handleDeprecatedConfig) {
|
9168
9203
|
configs.forEach(handleDeprecatedConfig);
|
9169
9204
|
}
|
9205
|
+
(_a = options.openAnimation) !== null && _a !== void 0 ? _a : (options.openAnimation = u.pluckKey(options, 'animation'));
|
9170
9206
|
options = u.mergeDefined(...configs, { mode, stack }, options);
|
9171
9207
|
if (beforeNew) {
|
9172
9208
|
options = beforeNew(options);
|
@@ -9272,16 +9308,16 @@ up.layer = (function () {
|
|
9272
9308
|
|
9273
9309
|
|
9274
9310
|
/***/ }),
|
9275
|
-
/*
|
9311
|
+
/* 93 */
|
9276
9312
|
/***/ (() => {
|
9277
9313
|
|
9278
9314
|
|
9279
9315
|
|
9280
9316
|
/***/ }),
|
9281
|
-
/*
|
9317
|
+
/* 94 */
|
9282
9318
|
/***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
|
9283
9319
|
|
9284
|
-
__webpack_require__(
|
9320
|
+
__webpack_require__(95);
|
9285
9321
|
up.link = (function () {
|
9286
9322
|
const u = up.util;
|
9287
9323
|
const e = up.element;
|
@@ -9430,16 +9466,22 @@ up.link = (function () {
|
|
9430
9466
|
}
|
9431
9467
|
function preload(link, options) {
|
9432
9468
|
link = up.fragment.get(link);
|
9433
|
-
|
9434
|
-
|
9469
|
+
let issue = preloadIssue(link);
|
9470
|
+
if (issue) {
|
9471
|
+
return Promise.reject(new up.Error(issue));
|
9435
9472
|
}
|
9436
9473
|
const guardEvent = up.event.build('up:link:preload', { log: ['Preloading link %o', link] });
|
9437
9474
|
return follow(link, Object.assign(Object.assign({ abortable: false }, options), { guardEvent, preload: true }));
|
9438
9475
|
}
|
9439
|
-
function
|
9440
|
-
|
9441
|
-
|
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
|
+
}
|
9442
9483
|
}
|
9484
|
+
const autoPreloadEnabled = u.negate(up.network.shouldReduceRequests);
|
9443
9485
|
function followMethod(link, options = {}) {
|
9444
9486
|
return u.normalizeMethod(options.method || link.getAttribute('up-method') || link.getAttribute('data-method'));
|
9445
9487
|
}
|
@@ -9566,13 +9608,13 @@ up.follow = up.link.follow;
|
|
9566
9608
|
|
9567
9609
|
|
9568
9610
|
/***/ }),
|
9569
|
-
/*
|
9611
|
+
/* 95 */
|
9570
9612
|
/***/ (() => {
|
9571
9613
|
|
9572
9614
|
|
9573
9615
|
|
9574
9616
|
/***/ }),
|
9575
|
-
/*
|
9617
|
+
/* 96 */
|
9576
9618
|
/***/ (() => {
|
9577
9619
|
|
9578
9620
|
up.form = (function () {
|
@@ -9972,7 +10014,7 @@ up.validate = up.form.validate;
|
|
9972
10014
|
|
9973
10015
|
|
9974
10016
|
/***/ }),
|
9975
|
-
/*
|
10017
|
+
/* 97 */
|
9976
10018
|
/***/ (() => {
|
9977
10019
|
|
9978
10020
|
up.feedback = (function () {
|
@@ -10089,7 +10131,7 @@ up.feedback = (function () {
|
|
10089
10131
|
|
10090
10132
|
|
10091
10133
|
/***/ }),
|
10092
|
-
/*
|
10134
|
+
/* 98 */
|
10093
10135
|
/***/ (() => {
|
10094
10136
|
|
10095
10137
|
up.radio = (function () {
|
@@ -10167,7 +10209,7 @@ up.radio = (function () {
|
|
10167
10209
|
|
10168
10210
|
|
10169
10211
|
/***/ }),
|
10170
|
-
/*
|
10212
|
+
/* 99 */
|
10171
10213
|
/***/ (() => {
|
10172
10214
|
|
10173
10215
|
(function () {
|
@@ -10305,16 +10347,15 @@ __webpack_require__(82);
|
|
10305
10347
|
__webpack_require__(83);
|
10306
10348
|
__webpack_require__(84);
|
10307
10349
|
__webpack_require__(85);
|
10308
|
-
__webpack_require__(
|
10309
|
-
__webpack_require__(
|
10350
|
+
__webpack_require__(87);
|
10351
|
+
__webpack_require__(89);
|
10310
10352
|
__webpack_require__(90);
|
10311
|
-
__webpack_require__(
|
10312
|
-
__webpack_require__(
|
10313
|
-
__webpack_require__(
|
10353
|
+
__webpack_require__(92);
|
10354
|
+
__webpack_require__(94);
|
10355
|
+
__webpack_require__(96);
|
10314
10356
|
__webpack_require__(97);
|
10315
10357
|
__webpack_require__(98);
|
10316
10358
|
__webpack_require__(99);
|
10317
|
-
__webpack_require__(100);
|
10318
10359
|
up.framework.onEvaled();
|
10319
10360
|
|
10320
10361
|
})();
|