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.
@@ -5,7 +5,7 @@
5
5
  /***/ (() => {
6
6
 
7
7
  window.up = {
8
- version: '3.0.0-rc1'
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
- let spy;
18
- const mockableFn = function () {
19
- return (spy || originalFn).apply(null, arguments);
20
- };
21
- mockableFn.mock = () => spy = jasmine.createSpy('mockable', originalFn);
22
- document.addEventListener('up:framework:reset', () => spy = null);
23
- return mockableFn;
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(array, block) {
110
- if (array.length === 0) {
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
- for (let i = 0; i < array.length; i++) {
116
- let element = array[i];
117
- mapped.push(block(element, i));
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
- for (let i = 0; i < array.length; i++) {
130
- block(array[i], i);
134
+ let i = 0;
135
+ for (let item of array) {
136
+ block(item, i++);
131
137
  }
132
138
  }
133
139
  function isNull(object) {
@@ -303,10 +309,11 @@ up.util = (function () {
303
309
  function some(list, tester) {
304
310
  return !!findResult(list, tester);
305
311
  }
306
- function findResult(array, tester) {
312
+ function findResult(list, tester) {
307
313
  tester = iteratee(tester);
308
- for (let i = 0; i < array.length; i++) {
309
- const result = tester(array[i], i);
314
+ let i = 0;
315
+ for (let item of list) {
316
+ const result = tester(item, i++);
310
317
  if (result) {
311
318
  return result;
312
319
  }
@@ -315,8 +322,9 @@ up.util = (function () {
315
322
  function every(list, tester) {
316
323
  tester = iteratee(tester);
317
324
  let match = true;
318
- for (let i = 0; i < list.length; i++) {
319
- if (!tester(list[i], i)) {
325
+ let i = 0;
326
+ for (let item of list) {
327
+ if (!tester(item, i++)) {
320
328
  match = false;
321
329
  break;
322
330
  }
@@ -488,7 +496,7 @@ up.util = (function () {
488
496
  function flatMap(array, block) {
489
497
  return flatten(map(array, block));
490
498
  }
491
- function always(promise, callback) {
499
+ function always(promise, callback = identity) {
492
500
  return promise.then(callback, callback);
493
501
  }
494
502
  function newDeferred() {
@@ -590,7 +598,7 @@ up.util = (function () {
590
598
  Object.defineProperty(object, prop, { get });
591
599
  }
592
600
  function defineDelegates(object, props, targetProvider) {
593
- wrapList(props).forEach(function (prop) {
601
+ for (let prop of props) {
594
602
  Object.defineProperty(object, prop, {
595
603
  get() {
596
604
  const target = targetProvider.call(this);
@@ -605,7 +613,7 @@ up.util = (function () {
605
613
  target[prop] = newValue;
606
614
  }
607
615
  });
608
- });
616
+ }
609
617
  }
610
618
  function stringifyArg(arg) {
611
619
  let string;
@@ -700,6 +708,14 @@ up.util = (function () {
700
708
  };
701
709
  }
702
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
+ }
703
719
  return {
704
720
  parseURL,
705
721
  normalizeURL,
@@ -795,7 +811,8 @@ up.util = (function () {
795
811
  sprintf,
796
812
  renameKeys,
797
813
  negate,
798
- memoizeMethod
814
+ memoizeMethod,
815
+ safeStringifyJSON,
799
816
  };
800
817
  })();
801
818
 
@@ -869,12 +886,6 @@ up.browser = (function () {
869
886
  return value;
870
887
  }
871
888
  }
872
- const getJQuery = function () {
873
- if (!canJQuery()) {
874
- up.fail('jQuery must be published as window.jQuery');
875
- }
876
- return jQuery;
877
- };
878
889
  function assertConfirmed(options) {
879
890
  const confirmed = !options.confirm || window.confirm(options.confirm);
880
891
  if (!confirmed) {
@@ -889,7 +900,6 @@ up.browser = (function () {
889
900
  canEval,
890
901
  assertConfirmed,
891
902
  popCookie,
892
- get jQuery() { return getJQuery(); },
893
903
  };
894
904
  })();
895
905
 
@@ -1161,9 +1171,17 @@ up.element = (function () {
1161
1171
  klass = klass.replace(/:/g, '\\:');
1162
1172
  return `.${klass}`;
1163
1173
  }
1164
- function createDocumentFromHTML(html) {
1174
+ function createBrokenDocumentFromHTML(html) {
1165
1175
  return new DOMParser().parseFromString(html, 'text/html');
1166
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
+ }
1167
1185
  function createFromHTML(html) {
1168
1186
  const range = document.createRange();
1169
1187
  range.setStart(document.body, 0);
@@ -1425,7 +1443,8 @@ up.element = (function () {
1425
1443
  isSingleton,
1426
1444
  attrSelector,
1427
1445
  tagName: elementTagName,
1428
- createDocumentFromHTML,
1446
+ createBrokenDocumentFromHTML,
1447
+ fixScriptish,
1429
1448
  createFromHTML,
1430
1449
  get root() { return getRoot(); },
1431
1450
  paint,
@@ -1625,82 +1644,26 @@ up.LogConfig = class LogConfig extends up.Config {
1625
1644
  /***/ (() => {
1626
1645
 
1627
1646
  const u = up.util;
1628
- up.Cache = class Cache {
1629
- constructor(config = {}) {
1630
- this.config = config;
1647
+ up.FIFOCache = class FIFOCache {
1648
+ constructor({ capacity = 10, normalizeKey = u.identity } = {}) {
1631
1649
  this.map = new Map();
1650
+ this.capacity = capacity;
1651
+ this.normalizeKey = normalizeKey;
1632
1652
  }
1633
- size() {
1634
- return this.map.size;
1635
- }
1636
- maxSize() {
1637
- return u.evalOption(this.config.size);
1638
- }
1639
- evictAge() {
1640
- return u.evalOption(this.config.evictAge);
1641
- }
1642
- normalizeStoreKey(key) {
1643
- return key;
1644
- }
1645
- isDisabled() {
1646
- return this.maxSize() === 0 || this.evictAge() === 0;
1647
- }
1648
- evict() {
1649
- this.map.clear();
1650
- }
1651
- records() {
1652
- return this.map.values();
1653
- }
1654
- makeRoomForAnotherRecord() {
1655
- const maxSize = this.maxSize();
1656
- const currentSize = this.size();
1657
- if (!maxSize || currentSize < maxSize)
1658
- return;
1659
- let records = Array.from(this.records());
1660
- records.sort((a, b) => b.createdAt - a.createdAt);
1661
- const overflow = currentSize - maxSize + 1;
1662
- for (let i = 0; i < overflow; i++) {
1663
- let key = records.pop().key;
1664
- this.map.delete(key);
1665
- }
1666
- }
1667
- alias(oldKey, newKey) {
1668
- const value = this.get(oldKey);
1669
- if (u.isDefined(value)) {
1670
- this.set(newKey, value);
1671
- }
1653
+ get(key) {
1654
+ key = this.normalizeKey(key);
1655
+ return this.map.get(key);
1672
1656
  }
1673
1657
  set(key, value) {
1674
- if (this.isDisabled())
1675
- return;
1676
- this.makeRoomForAnotherRecord();
1677
- key = this.normalizeStoreKey(key);
1678
- const createdAt = new Date();
1679
- const record = { key, value, createdAt };
1680
- this.map.set(key, record);
1681
- }
1682
- remove(key) {
1683
- key = this.normalizeStoreKey(key);
1684
- this.map.delete(key);
1685
- }
1686
- isUsable(record) {
1687
- const evictAge = this.evictAge();
1688
- if (!evictAge)
1689
- return true;
1690
- const age = new Date() - record.createdAt;
1691
- return age < evictAge;
1692
- }
1693
- get(key) {
1694
- const storeKey = this.normalizeStoreKey(key);
1695
- let record = this.map.get(storeKey);
1696
- if (record) {
1697
- if (this.isUsable(record)) {
1698
- return record.value;
1699
- }
1700
- else {
1701
- this.remove(key);
1702
- }
1658
+ if (this.map.size === this.capacity) {
1659
+ let oldestKey = this.map.keys().next().value;
1660
+ this.map.delete(oldestKey);
1703
1661
  }
1662
+ key = this.normalizeKey(key);
1663
+ this.map.set(key, value);
1664
+ }
1665
+ clear() {
1666
+ this.map.clear();
1704
1667
  }
1705
1668
  };
1706
1669
 
@@ -1874,7 +1837,7 @@ up.Change.Addition = class Addition extends up.Change {
1874
1837
  setETag({ newElement, etag }) {
1875
1838
  e.setMissingAttr(newElement, 'up-etag', etag || false);
1876
1839
  }
1877
- setMeta(options) {
1840
+ setReloadAttrs(options) {
1878
1841
  this.setSource(options);
1879
1842
  this.setTime(options);
1880
1843
  this.setETag(options);
@@ -2082,9 +2045,9 @@ up.Change.OpenLayer = class OpenLayer extends up.Change.Addition {
2082
2045
  this.layer.createElements(this.content);
2083
2046
  this.layer.setupHandlers();
2084
2047
  this.handleHistory();
2085
- this.setMeta({ newElement: this.content, source: this.options.source });
2048
+ this.setReloadAttrs({ newElement: this.content, source: this.options.source });
2086
2049
  responseDoc.finalizeElement(this.content);
2087
- up.hello(this.layer.element, { layer: this.layer, origin: this.origin });
2050
+ up.hello(this.layer.element, { ...this.options, layer: this.layer });
2088
2051
  this.handleLayerChangeRequests();
2089
2052
  this.handleScroll();
2090
2053
  let renderResult = new up.RenderResult({
@@ -2244,7 +2207,7 @@ up.Change.UpdateLayer = (_a = class UpdateLayer extends up.Change.Addition {
2244
2207
  this.renderResult.fragments.unshift(...newFragments);
2245
2208
  }
2246
2209
  executeStep(step) {
2247
- this.setMeta(step);
2210
+ this.setReloadAttrs(step);
2248
2211
  switch (step.placement) {
2249
2212
  case 'swap': {
2250
2213
  let keepPlan = this.findKeepPlan(step);
@@ -2749,19 +2712,12 @@ up.Change.FromURL = (_a = class FromURL extends up.Change {
2749
2712
  }
2750
2713
  onRequestSettledWithResponse(response) {
2751
2714
  this.response = response;
2752
- const expiredResponse = this.options.expiredResponse;
2753
- const eventProps = {
2754
- response: this.response,
2755
- renderOptions: this.options,
2756
- revalidating: !!expiredResponse,
2757
- expiredResponse,
2758
- };
2759
- if (up.fragment.config.skipResponse(eventProps)) {
2715
+ if (up.fragment.config.skipResponse(this.loadedEventProps())) {
2760
2716
  this.skip();
2761
2717
  }
2762
2718
  else {
2763
2719
  this.request.assertEmitted('up:fragment:loaded', {
2764
- ...eventProps,
2720
+ ...this.loadedEventProps(),
2765
2721
  callback: this.options.onLoaded,
2766
2722
  log: ['Loaded fragment from %s', this.response.description],
2767
2723
  skip: () => this.skip()
@@ -2773,6 +2729,22 @@ up.Change.FromURL = (_a = class FromURL extends up.Change {
2773
2729
  }
2774
2730
  return this.updateContentFromResponse(this.options);
2775
2731
  }
2732
+ compilerPassMeta() {
2733
+ return u.pick(this.loadedEventProps(), [
2734
+ 'revalidating',
2735
+ 'response'
2736
+ ]);
2737
+ }
2738
+ loadedEventProps() {
2739
+ const { expiredResponse } = this.options;
2740
+ return {
2741
+ request: this.request,
2742
+ response: this.response,
2743
+ renderOptions: this.options,
2744
+ revalidating: !!expiredResponse,
2745
+ expiredResponse,
2746
+ };
2747
+ }
2776
2748
  onRequestSettledWithError(error) {
2777
2749
  if (error instanceof up.Offline) {
2778
2750
  this.request.emit('up:fragment:offline', {
@@ -2795,6 +2767,7 @@ up.Change.FromURL = (_a = class FromURL extends up.Change {
2795
2767
  up.puts('up.render()', 'Rendering failed response using fail-prefixed options (https://unpoly.com/failed-responses)');
2796
2768
  }
2797
2769
  this.augmentOptionsFromResponse(finalRenderOptions);
2770
+ finalRenderOptions.meta = this.compilerPassMeta();
2798
2771
  let result = new up.Change.FromContent(finalRenderOptions).execute();
2799
2772
  result.finished = this.finish(result, finalRenderOptions);
2800
2773
  return result;
@@ -2870,6 +2843,7 @@ up.Change.FromURL = (_a = class FromURL extends up.Change {
2870
2843
  (() => {
2871
2844
  u.memoizeMethod(_a.prototype, [
2872
2845
  'getRequestAttrs',
2846
+ 'loadedEventProps',
2873
2847
  ]);
2874
2848
  })(),
2875
2849
  _a);
@@ -2881,12 +2855,14 @@ up.Change.FromURL = (_a = class FromURL extends up.Change {
2881
2855
 
2882
2856
  const u = up.util;
2883
2857
  up.CompilerPass = class CompilerPass {
2884
- constructor(root, compilers, { layer, data, dataMap } = {}) {
2858
+ constructor(root, compilers, { layer, data, dataMap, meta }) {
2859
+ layer || (layer = up.layer.get(root) || up.layer.current);
2885
2860
  this.root = root;
2886
2861
  this.compilers = compilers;
2887
- this.layer = layer || up.layer.get(this.root) || up.layer.current;
2862
+ this.layer = layer;
2888
2863
  this.data = data;
2889
2864
  this.dataMap = dataMap;
2865
+ this.meta = { layer, ...meta };
2890
2866
  this.errors = [];
2891
2867
  }
2892
2868
  run() {
@@ -2931,11 +2907,10 @@ up.CompilerPass = class CompilerPass {
2931
2907
  return up.migrate.postCompile?.(matches, compiler);
2932
2908
  }
2933
2909
  compileOneElement(compiler, element) {
2934
- const elementArg = compiler.jQuery ? up.browser.jQuery(element) : element;
2935
- const compileArgs = [elementArg];
2910
+ const compileArgs = [element];
2936
2911
  if (compiler.length !== 1) {
2937
2912
  const data = up.syntax.data(element);
2938
- compileArgs.push(data);
2913
+ compileArgs.push(data, this.meta);
2939
2914
  }
2940
2915
  const result = this.applyCompilerFunction(compiler, element, compileArgs);
2941
2916
  let destructorOrDestructors = this.destructorPresence(result);
@@ -2944,11 +2919,10 @@ up.CompilerPass = class CompilerPass {
2944
2919
  }
2945
2920
  }
2946
2921
  compileBatch(compiler, elements) {
2947
- const elementsArgs = compiler.jQuery ? up.browser.jQuery(elements) : elements;
2948
- const compileArgs = [elementsArgs];
2922
+ const compileArgs = [elements];
2949
2923
  if (compiler.length !== 1) {
2950
2924
  const dataList = u.map(elements, up.syntax.data);
2951
- compileArgs.push(dataList);
2925
+ compileArgs.push(dataList, this.meta);
2952
2926
  }
2953
2927
  const result = this.applyCompilerFunction(compiler, elements, compileArgs);
2954
2928
  if (this.destructorPresence(result)) {
@@ -3250,7 +3224,6 @@ up.EventListener = class EventListener extends up.Record {
3250
3224
  'eventType',
3251
3225
  'selector',
3252
3226
  'callback',
3253
- 'jQuery',
3254
3227
  'guard',
3255
3228
  'baseLayer',
3256
3229
  'passive',
@@ -3297,8 +3270,7 @@ up.EventListener = class EventListener extends up.Record {
3297
3270
  return;
3298
3271
  }
3299
3272
  if (element) {
3300
- const elementArg = this.jQuery ? up.browser.jQuery(element) : element;
3301
- const args = [event, elementArg];
3273
+ const args = [event, element];
3302
3274
  const expectedArgCount = this.callback.length;
3303
3275
  if (expectedArgCount !== 1 && expectedArgCount !== 2) {
3304
3276
  const data = up.syntax.data(element);
@@ -3354,7 +3326,6 @@ up.EventListenerGroup = class EventListenerGroup extends up.Record {
3354
3326
  'eventTypes',
3355
3327
  'selector',
3356
3328
  'callback',
3357
- 'jQuery',
3358
3329
  'guard',
3359
3330
  'baseLayer',
3360
3331
  'passive',
@@ -4092,44 +4063,6 @@ up.FragmentScrolling = class FragmentScrolling extends up.FragmentProcessor {
4092
4063
  /* 47 */
4093
4064
  /***/ (() => {
4094
4065
 
4095
- const u = up.util;
4096
- const e = up.element;
4097
- up.HTMLWrapper = class HTMLWrapper {
4098
- constructor(tagName) {
4099
- this.tagName = tagName;
4100
- const openTag = `<${this.tagName}[^>]*>`;
4101
- const closeTag = `</${this.tagName}>`;
4102
- const innerHTML = "(.|\\s)*?";
4103
- this.pattern = new RegExp(openTag + innerHTML + closeTag, 'ig');
4104
- this.attrName = `up-wrapped-${this.tagName}`;
4105
- }
4106
- strip(html) {
4107
- return html.replace(this.pattern, '');
4108
- }
4109
- wrap(html) {
4110
- return html.replace(this.pattern, this.wrapMatch.bind(this));
4111
- }
4112
- wrapMatch(match) {
4113
- this.didWrap = true;
4114
- return '<meta name="' + this.attrName + '" value="' + u.escapeHTML(match) + '">';
4115
- }
4116
- unwrap(element) {
4117
- if (!this.didWrap) {
4118
- return;
4119
- }
4120
- for (let wrappedChild of element.querySelectorAll(`meta[name='${this.attrName}']`)) {
4121
- const originalHTML = wrappedChild.getAttribute('value');
4122
- const restoredElement = e.createFromHTML(originalHTML);
4123
- wrappedChild.replaceWith(restoredElement);
4124
- }
4125
- }
4126
- };
4127
-
4128
-
4129
- /***/ }),
4130
- /* 48 */
4131
- /***/ (() => {
4132
-
4133
4066
  const e = up.element;
4134
4067
  const u = up.util;
4135
4068
  up.Layer = class Layer extends up.Record {
@@ -4276,12 +4209,12 @@ up.Layer = class Layer extends up.Record {
4276
4209
  return this.stack.asCurrent(this, fn);
4277
4210
  }
4278
4211
  updateHistory(options) {
4279
- if (u.isString(options.title)) {
4280
- this.title = options.title;
4281
- }
4282
4212
  if (u.isString(options.location)) {
4283
4213
  this.location = options.location;
4284
4214
  }
4215
+ if (u.isString(options.title)) {
4216
+ this.title = options.title;
4217
+ }
4285
4218
  }
4286
4219
  isHistoryVisible() {
4287
4220
  return this.history && (this.isRoot() || this.parent.isHistoryVisible());
@@ -4314,12 +4247,14 @@ up.Layer = class Layer extends up.Record {
4314
4247
  set location(location) {
4315
4248
  const previousLocation = this.location;
4316
4249
  location = up.history.normalizeURL(location);
4317
- if (previousLocation !== location) {
4250
+ if (previousLocation !== location || this.opening) {
4318
4251
  this.savedLocation = location;
4319
- this.emit('up:layer:location:changed', { location, log: false });
4320
4252
  if (this.showsLiveHistory()) {
4321
4253
  up.history.push(location);
4322
4254
  }
4255
+ if (!this.opening) {
4256
+ this.emit('up:layer:location:changed', { location });
4257
+ }
4323
4258
  }
4324
4259
  }
4325
4260
  selector(part) {
@@ -4341,11 +4276,14 @@ up.Layer = class Layer extends up.Record {
4341
4276
  let focusedElement = document.activeElement;
4342
4277
  return focusedElement !== document.body && this.element.contains(focusedElement);
4343
4278
  }
4279
+ reset() {
4280
+ Object.assign(this, this.defaults());
4281
+ }
4344
4282
  };
4345
4283
 
4346
4284
 
4347
4285
  /***/ }),
4348
- /* 49 */
4286
+ /* 48 */
4349
4287
  /***/ (() => {
4350
4288
 
4351
4289
  const e = up.element;
@@ -4620,7 +4558,7 @@ up.Layer.Overlay = class Overlay extends up.Layer {
4620
4558
 
4621
4559
 
4622
4560
  /***/ }),
4623
- /* 50 */
4561
+ /* 49 */
4624
4562
  /***/ (() => {
4625
4563
 
4626
4564
  up.Layer.OverlayWithTether = class OverlayWithTether extends up.Layer.Overlay {
@@ -4657,7 +4595,7 @@ up.Layer.OverlayWithTether = class OverlayWithTether extends up.Layer.Overlay {
4657
4595
 
4658
4596
 
4659
4597
  /***/ }),
4660
- /* 51 */
4598
+ /* 50 */
4661
4599
  /***/ (() => {
4662
4600
 
4663
4601
  var _a;
@@ -4695,7 +4633,7 @@ up.Layer.OverlayWithViewport = (_a = class OverlayWithViewport extends up.Layer.
4695
4633
 
4696
4634
 
4697
4635
  /***/ }),
4698
- /* 52 */
4636
+ /* 51 */
4699
4637
  /***/ (() => {
4700
4638
 
4701
4639
  var _a;
@@ -4732,9 +4670,6 @@ up.Layer.Root = (_a = class Root extends up.Layer {
4732
4670
  cannotCloseRoot() {
4733
4671
  up.fail('Cannot close the root layer');
4734
4672
  }
4735
- reset() {
4736
- Object.assign(this, this.defaults());
4737
- }
4738
4673
  toString() {
4739
4674
  return "root layer";
4740
4675
  }
@@ -4744,7 +4679,7 @@ up.Layer.Root = (_a = class Root extends up.Layer {
4744
4679
 
4745
4680
 
4746
4681
  /***/ }),
4747
- /* 53 */
4682
+ /* 52 */
4748
4683
  /***/ (() => {
4749
4684
 
4750
4685
  var _a;
@@ -4755,7 +4690,7 @@ up.Layer.Modal = (_a = class Modal extends up.Layer.OverlayWithViewport {
4755
4690
 
4756
4691
 
4757
4692
  /***/ }),
4758
- /* 54 */
4693
+ /* 53 */
4759
4694
  /***/ (() => {
4760
4695
 
4761
4696
  var _a;
@@ -4766,7 +4701,7 @@ up.Layer.Popup = (_a = class Popup extends up.Layer.OverlayWithTether {
4766
4701
 
4767
4702
 
4768
4703
  /***/ }),
4769
- /* 55 */
4704
+ /* 54 */
4770
4705
  /***/ (() => {
4771
4706
 
4772
4707
  var _a;
@@ -4777,7 +4712,7 @@ up.Layer.Drawer = (_a = class Drawer extends up.Layer.OverlayWithViewport {
4777
4712
 
4778
4713
 
4779
4714
  /***/ }),
4780
- /* 56 */
4715
+ /* 55 */
4781
4716
  /***/ (() => {
4782
4717
 
4783
4718
  var _a;
@@ -4788,7 +4723,7 @@ up.Layer.Cover = (_a = class Cover extends up.Layer.OverlayWithViewport {
4788
4723
 
4789
4724
 
4790
4725
  /***/ }),
4791
- /* 57 */
4726
+ /* 56 */
4792
4727
  /***/ (() => {
4793
4728
 
4794
4729
  const u = up.util;
@@ -4878,7 +4813,7 @@ up.LayerLookup = class LayerLookup {
4878
4813
 
4879
4814
 
4880
4815
  /***/ }),
4881
- /* 58 */
4816
+ /* 57 */
4882
4817
  /***/ (() => {
4883
4818
 
4884
4819
  const u = up.util;
@@ -4991,7 +4926,7 @@ up.LayerStack = class LayerStack extends Array {
4991
4926
 
4992
4927
 
4993
4928
  /***/ }),
4994
- /* 59 */
4929
+ /* 58 */
4995
4930
  /***/ (() => {
4996
4931
 
4997
4932
  up.LinkFeedbackURLs = class LinkFeedbackURLs {
@@ -5022,7 +4957,7 @@ up.LinkFeedbackURLs = class LinkFeedbackURLs {
5022
4957
 
5023
4958
 
5024
4959
  /***/ }),
5025
- /* 60 */
4960
+ /* 59 */
5026
4961
  /***/ (() => {
5027
4962
 
5028
4963
  const u = up.util;
@@ -5090,7 +5025,7 @@ up.LinkPreloader = class LinkPreloader {
5090
5025
 
5091
5026
 
5092
5027
  /***/ }),
5093
- /* 61 */
5028
+ /* 60 */
5094
5029
  /***/ (() => {
5095
5030
 
5096
5031
  const u = up.util;
@@ -5186,7 +5121,7 @@ up.MotionController = class MotionController {
5186
5121
 
5187
5122
 
5188
5123
  /***/ }),
5189
- /* 62 */
5124
+ /* 61 */
5190
5125
  /***/ (() => {
5191
5126
 
5192
5127
  const u = up.util;
@@ -5278,7 +5213,7 @@ up.NonceableCallback = class NonceableCallback {
5278
5213
 
5279
5214
 
5280
5215
  /***/ }),
5281
- /* 63 */
5216
+ /* 62 */
5282
5217
  /***/ (() => {
5283
5218
 
5284
5219
  const u = up.util;
@@ -5355,7 +5290,7 @@ up.OptionsParser = class OptionsParser {
5355
5290
 
5356
5291
 
5357
5292
  /***/ }),
5358
- /* 64 */
5293
+ /* 63 */
5359
5294
  /***/ (() => {
5360
5295
 
5361
5296
  const e = up.element;
@@ -5423,7 +5358,7 @@ up.OverlayFocus = class OverlayFocus {
5423
5358
 
5424
5359
 
5425
5360
  /***/ }),
5426
- /* 65 */
5361
+ /* 64 */
5427
5362
  /***/ (() => {
5428
5363
 
5429
5364
  const u = up.util;
@@ -5654,7 +5589,7 @@ up.Params = class Params {
5654
5589
 
5655
5590
 
5656
5591
  /***/ }),
5657
- /* 66 */
5592
+ /* 65 */
5658
5593
  /***/ (() => {
5659
5594
 
5660
5595
  const e = up.element;
@@ -5704,7 +5639,7 @@ up.ProgressBar = class ProgressBar {
5704
5639
 
5705
5640
 
5706
5641
  /***/ }),
5707
- /* 67 */
5642
+ /* 66 */
5708
5643
  /***/ (() => {
5709
5644
 
5710
5645
  const u = up.util;
@@ -5750,7 +5685,7 @@ up.RenderOptions = (function () {
5750
5685
  'history',
5751
5686
  'source',
5752
5687
  'saveScroll',
5753
- 'navigate'
5688
+ 'navigate',
5754
5689
  ]);
5755
5690
  const CONTENT_KEYS = [
5756
5691
  'url',
@@ -5828,7 +5763,7 @@ up.RenderOptions = (function () {
5828
5763
 
5829
5764
 
5830
5765
  /***/ }),
5831
- /* 68 */
5766
+ /* 67 */
5832
5767
  /***/ (() => {
5833
5768
 
5834
5769
  up.RenderResult = class RenderResult extends up.Record {
@@ -5856,7 +5791,7 @@ up.RenderResult = class RenderResult extends up.Record {
5856
5791
 
5857
5792
 
5858
5793
  /***/ }),
5859
- /* 69 */
5794
+ /* 68 */
5860
5795
  /***/ (() => {
5861
5796
 
5862
5797
  var _a;
@@ -5868,7 +5803,7 @@ up.Request = (_a = class Request extends up.Record {
5868
5803
  if (this.wrapMethod == null) {
5869
5804
  this.wrapMethod = up.network.config.wrapMethod;
5870
5805
  }
5871
- this.normalizeForCaching();
5806
+ this.normalize();
5872
5807
  if ((this.target || this.layer || this.origin) && !options.basic) {
5873
5808
  const layerLookupOptions = { origin: this.origin };
5874
5809
  this.layer = up.layer.get(this.layer, layerLookupOptions);
@@ -5880,6 +5815,7 @@ up.Request = (_a = class Request extends up.Record {
5880
5815
  }
5881
5816
  this.deferred = u.newDeferred();
5882
5817
  this.badResponseTime ?? (this.badResponseTime = u.evalOption(up.network.config.badResponseTime, this));
5818
+ this.addAutoHeaders();
5883
5819
  }
5884
5820
  keys() {
5885
5821
  return [
@@ -5891,7 +5827,6 @@ up.Request = (_a = class Request extends up.Record {
5891
5827
  'failTarget',
5892
5828
  'headers',
5893
5829
  'timeout',
5894
- 'preload',
5895
5830
  'background',
5896
5831
  'cache',
5897
5832
  'expireCache',
@@ -5904,11 +5839,12 @@ up.Request = (_a = class Request extends up.Record {
5904
5839
  'failContext',
5905
5840
  'origin',
5906
5841
  'fragments',
5907
- 'queuedAt',
5842
+ 'builtAt',
5908
5843
  'wrapMethod',
5909
5844
  'contentType',
5910
5845
  'payload',
5911
5846
  'onQueued',
5847
+ 'onLoading',
5912
5848
  'fail',
5913
5849
  'abortable',
5914
5850
  'badResponseTime',
@@ -5919,7 +5855,8 @@ up.Request = (_a = class Request extends up.Record {
5919
5855
  state: 'new',
5920
5856
  abortable: true,
5921
5857
  headers: {},
5922
- timeout: up.network.config.timeout
5858
+ timeout: up.network.config.timeout,
5859
+ builtAt: new Date(),
5923
5860
  };
5924
5861
  }
5925
5862
  get xhr() {
@@ -5940,10 +5877,7 @@ up.Request = (_a = class Request extends up.Record {
5940
5877
  get fragment() {
5941
5878
  return this.fragments?.[0];
5942
5879
  }
5943
- followState(sourceRequest) {
5944
- u.delegate(this, ['deferred', 'state', 'preload', 'expired'], () => sourceRequest);
5945
- }
5946
- normalizeForCaching() {
5880
+ normalize() {
5947
5881
  this.method = u.normalizeMethod(this.method);
5948
5882
  this.extractHashFromURL();
5949
5883
  this.transferParamsToURL();
@@ -5990,14 +5924,26 @@ up.Request = (_a = class Request extends up.Record {
5990
5924
  load() {
5991
5925
  if (this.state !== 'new')
5992
5926
  return;
5993
- this.state = 'loading';
5994
- this.expired = false;
5995
- new up.Request.XHRRenderer(this).buildAndSend({
5996
- onload: () => this.onXHRLoad(),
5997
- onerror: () => this.onXHRError(),
5998
- ontimeout: () => this.onXHRTimeout(),
5999
- onabort: () => this.onXHRAbort()
6000
- });
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;
6001
5947
  }
6002
5948
  loadPage() {
6003
5949
  up.network.abort();
@@ -6041,18 +5987,19 @@ up.Request = (_a = class Request extends up.Record {
6041
5987
  this.emit('up:request:offline', { log: message });
6042
5988
  }
6043
5989
  respondWith(response) {
6044
- if (this.state !== 'loading')
5990
+ this.response = response;
5991
+ if (this.isSettled())
6045
5992
  return;
6046
5993
  this.state = 'loaded';
6047
5994
  if (response.ok) {
6048
- return this.deferred.resolve(response);
5995
+ this.deferred.resolve(response);
6049
5996
  }
6050
5997
  else {
6051
- return this.deferred.reject(response);
5998
+ this.deferred.reject(response);
6052
5999
  }
6053
6000
  }
6054
6001
  isSettled() {
6055
- return (this.state !== 'new') && (this.state !== 'loading');
6002
+ return (this.state !== 'new') && (this.state !== 'loading') && (this.state !== 'tracking');
6056
6003
  }
6057
6004
  csrfHeader() {
6058
6005
  return up.protocol.csrfHeader();
@@ -6099,24 +6046,6 @@ up.Request = (_a = class Request extends up.Record {
6099
6046
  }
6100
6047
  return new up.Response(responseAttrs);
6101
6048
  }
6102
- cacheKey() {
6103
- return JSON.stringify([
6104
- this.method,
6105
- this.url,
6106
- this.params.toQuery(),
6107
- this.metaProps()
6108
- ]);
6109
- }
6110
- metaProps() {
6111
- const props = {};
6112
- for (let key of u.evalOption(up.network.config.requestMetaKeys, this)) {
6113
- const value = this[key];
6114
- if (u.isGiven(value)) {
6115
- props[key] = value;
6116
- }
6117
- }
6118
- return props;
6119
- }
6120
6049
  buildEventEmitter(args) {
6121
6050
  return up.EventEmitter.fromEmitArgs(args, {
6122
6051
  layer: this.layer,
@@ -6142,9 +6071,27 @@ up.Request = (_a = class Request extends up.Record {
6142
6071
  return u.some(subtreeElements, (subtreeElement) => subtreeElement.contains(fragment));
6143
6072
  });
6144
6073
  }
6145
- get queueAge() {
6146
- const now = new Date();
6147
- return now - this.queuedAt;
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;
6148
6095
  }
6149
6096
  static tester(condition, { except } = {}) {
6150
6097
  let testFn;
@@ -6162,8 +6109,7 @@ up.Request = (_a = class Request extends up.Record {
6162
6109
  testFn = (_request) => condition;
6163
6110
  }
6164
6111
  if (except) {
6165
- let exceptCacheKey = except.cacheKey();
6166
- return (request) => (request.cacheKey() !== exceptCacheKey) && testFn(request);
6112
+ return (request) => !up.cache.willHaveSameResponse(request, except) && testFn(request);
6167
6113
  }
6168
6114
  else {
6169
6115
  return testFn;
@@ -6177,39 +6123,144 @@ up.Request = (_a = class Request extends up.Record {
6177
6123
 
6178
6124
 
6179
6125
  /***/ }),
6180
- /* 70 */
6126
+ /* 69 */
6181
6127
  /***/ (() => {
6182
6128
 
6183
- let u = up.util;
6184
- up.Request.Cache = class Cache extends up.Cache {
6185
- maxSize() {
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() {
6186
6161
  return up.network.config.cacheSize;
6187
6162
  }
6188
- evictAge() {
6189
- 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);
6171
+ }
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;
6190
6230
  }
6191
- normalizeStoreKey(request) {
6192
- return u.wrapValue(up.Request, request).cacheKey();
6231
+ delete(request) {
6232
+ request = this.wrap(request);
6233
+ let cacheKey = this.cacheKey(request);
6234
+ this.map.delete(cacheKey);
6193
6235
  }
6194
6236
  evict(condition = true, testerOptions) {
6195
- this.eachMatch(condition, testerOptions, ({ key }) => this.map.delete(key));
6237
+ this.eachMatch(condition, testerOptions, (request) => this.delete(request));
6196
6238
  }
6197
6239
  expire(condition = true, testerOptions) {
6198
- this.eachMatch(condition, testerOptions, ({ value: request }) => request.expired = true);
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
+ }
6199
6247
  }
6200
6248
  eachMatch(condition = true, testerOptions, fn) {
6201
6249
  let tester = up.Request.tester(condition, testerOptions);
6202
- for (let record of this.records()) {
6203
- if (tester(record.value)) {
6204
- fn(record);
6205
- }
6206
- }
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);
6207
6258
  }
6208
6259
  };
6209
6260
 
6210
6261
 
6211
6262
  /***/ }),
6212
- /* 71 */
6263
+ /* 70 */
6213
6264
  /***/ (() => {
6214
6265
 
6215
6266
  const u = up.util;
@@ -6228,7 +6279,6 @@ up.Request.Queue = class Queue {
6228
6279
  asap(request) {
6229
6280
  request.runQueuedCallbacks();
6230
6281
  u.always(request, responseOrError => this.onRequestSettled(request, responseOrError));
6231
- request.queuedAt = new Date();
6232
6282
  this.scheduleSlowTimer(request);
6233
6283
  this.queueRequest(request);
6234
6284
  u.microtask(() => this.poke());
@@ -6240,7 +6290,7 @@ up.Request.Queue = class Queue {
6240
6290
  }
6241
6291
  }
6242
6292
  scheduleSlowTimer(request) {
6243
- let timeUntilLate = Math.max(request.badResponseTime - request.queueAge, 0);
6293
+ let timeUntilLate = Math.max(request.badResponseTime - request.age, 0);
6244
6294
  u.timer(timeUntilLate, () => this.checkLate());
6245
6295
  }
6246
6296
  getMaxConcurrency() {
@@ -6262,13 +6312,8 @@ up.Request.Queue = class Queue {
6262
6312
  return u.remove(this.queuedRequests, request);
6263
6313
  }
6264
6314
  sendRequestNow(request) {
6265
- if (request.emit('up:request:load', { log: ['Loading %s %s', request.method, request.url] }).defaultPrevented) {
6266
- request.abort({ reason: 'Prevented by event listener' });
6267
- }
6268
- else {
6269
- request.normalizeForCaching();
6315
+ if (request.load()) {
6270
6316
  this.currentRequests.push(request);
6271
- request.load();
6272
6317
  }
6273
6318
  }
6274
6319
  onRequestSettled(request, responseOrError) {
@@ -6317,13 +6362,13 @@ up.Request.Queue = class Queue {
6317
6362
  isLate() {
6318
6363
  const allForegroundRequests = u.reject(this.allRequests, 'background');
6319
6364
  const timerTolerance = 1;
6320
- return u.some(allForegroundRequests, request => request.queueAge >= (request.badResponseTime - timerTolerance));
6365
+ return u.some(allForegroundRequests, (request) => request.age >= (request.badResponseTime - timerTolerance));
6321
6366
  }
6322
6367
  };
6323
6368
 
6324
6369
 
6325
6370
  /***/ }),
6326
- /* 72 */
6371
+ /* 71 */
6327
6372
  /***/ (() => {
6328
6373
 
6329
6374
  const u = up.util;
@@ -6362,7 +6407,7 @@ up.Request.FormRenderer = class FormRenderer {
6362
6407
 
6363
6408
 
6364
6409
  /***/ }),
6365
- /* 73 */
6410
+ /* 72 */
6366
6411
  /***/ (() => {
6367
6412
 
6368
6413
  var _a;
@@ -6380,21 +6425,13 @@ up.Request.XHRRenderer = (_a = class XHRRenderer {
6380
6425
  xhr.timeout = this.request.timeout;
6381
6426
  }
6382
6427
  xhr.open(this.getMethod(), this.request.url);
6383
- const metaProps = this.request.metaProps();
6384
- for (let key in metaProps) {
6385
- this.addHeader(xhr, up.protocol.headerize(key), metaProps[key]);
6386
- }
6387
- for (let header in this.request.headers) {
6388
- this.addHeader(xhr, header, this.request.headers[header]);
6389
- }
6390
- let csrfHeader, csrfToken;
6391
- if ((csrfHeader = this.request.csrfHeader()) && (csrfToken = this.request.csrfToken())) {
6392
- this.addHeader(xhr, csrfHeader, csrfToken);
6393
- }
6394
- this.addHeader(xhr, up.protocol.headerize('version'), up.version);
6395
6428
  let contentType = this.getContentType();
6396
6429
  if (contentType) {
6397
- this.addHeader(xhr, 'Content-Type', contentType);
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);
6398
6435
  }
6399
6436
  Object.assign(xhr, handlers);
6400
6437
  xhr.send(this.getPayload());
@@ -6416,12 +6453,6 @@ up.Request.XHRRenderer = (_a = class XHRRenderer {
6416
6453
  this.finalizePayload();
6417
6454
  return this.payload;
6418
6455
  }
6419
- addHeader(xhr, header, value) {
6420
- if (u.isOptions(value) || u.isArray(value)) {
6421
- value = JSON.stringify(value);
6422
- }
6423
- xhr.setRequestHeader(header, value);
6424
- }
6425
6456
  finalizePayload() {
6426
6457
  this.payload = this.request.payload;
6427
6458
  this.contentType = this.request.contentType;
@@ -6448,7 +6479,7 @@ up.Request.XHRRenderer = (_a = class XHRRenderer {
6448
6479
 
6449
6480
 
6450
6481
  /***/ }),
6451
- /* 74 */
6482
+ /* 73 */
6452
6483
  /***/ (() => {
6453
6484
 
6454
6485
  const u = up.util;
@@ -6483,23 +6514,27 @@ up.Response = class Response extends up.Record {
6483
6514
  get ok() {
6484
6515
  return !u.evalOption(this.fail ?? up.network.config.fail, this);
6485
6516
  }
6486
- getHeader(name) {
6517
+ header(name) {
6487
6518
  return this.headers[name] || this.xhr?.getResponseHeader(name);
6488
6519
  }
6520
+ get ownInfluncingHeaders() {
6521
+ let influencingHeaders = up.protocol.influencingHeadersFromResponse(this);
6522
+ return u.filter(influencingHeaders, (headerName) => this.request.header(headerName));
6523
+ }
6489
6524
  get contentType() {
6490
- return this.getHeader('Content-Type');
6525
+ return this.header('Content-Type');
6491
6526
  }
6492
6527
  get cspNonces() {
6493
- return up.protocol.cspNoncesFromHeader(this.getHeader('Content-Security-Policy'));
6528
+ return up.protocol.cspNoncesFromHeader(this.header('Content-Security-Policy'));
6494
6529
  }
6495
6530
  get lastModified() {
6496
- let header = this.getHeader('Last-Modified');
6531
+ let header = this.header('Last-Modified');
6497
6532
  if (header) {
6498
6533
  return new Date(header);
6499
6534
  }
6500
6535
  }
6501
6536
  get etag() {
6502
- return this.getHeader('ETag');
6537
+ return this.header('ETag');
6503
6538
  }
6504
6539
  get json() {
6505
6540
  return this.parsedJSON || (this.parsedJSON = JSON.parse(this.text));
@@ -6509,7 +6544,8 @@ up.Response = class Response extends up.Record {
6509
6544
  return now - this.loadedAt;
6510
6545
  }
6511
6546
  get expired() {
6512
- return this.age > up.network.config.cacheExpireAge || this.request.expired;
6547
+ return this.age > up.network.config.cacheExpireAge ||
6548
+ this.request.expired;
6513
6549
  }
6514
6550
  get description() {
6515
6551
  return `HTTP ${this.status} response to ${this.request.description}`;
@@ -6518,7 +6554,7 @@ up.Response = class Response extends up.Record {
6518
6554
 
6519
6555
 
6520
6556
  /***/ }),
6521
- /* 75 */
6557
+ /* 74 */
6522
6558
  /***/ (() => {
6523
6559
 
6524
6560
  var _a;
@@ -6526,12 +6562,13 @@ const u = up.util;
6526
6562
  const e = up.element;
6527
6563
  up.ResponseDoc = (_a = class ResponseDoc {
6528
6564
  constructor(options) {
6529
- this.noscriptWrapper = new up.HTMLWrapper('noscript');
6530
- this.scriptWrapper = new up.HTMLWrapper('script');
6531
6565
  this.root =
6532
6566
  this.parseDocument(options) ||
6533
6567
  this.parseFragment(options) ||
6534
6568
  this.parseContent(options);
6569
+ if (!up.fragment.config.runScripts) {
6570
+ this.root.querySelectorAll('script').forEach((e) => e.remove());
6571
+ }
6535
6572
  this.cspNonces = options.cspNonces;
6536
6573
  if (options.origin) {
6537
6574
  let originSelector = up.fragment.tryToTarget(options.origin);
@@ -6541,7 +6578,11 @@ up.ResponseDoc = (_a = class ResponseDoc {
6541
6578
  }
6542
6579
  }
6543
6580
  parseDocument(options) {
6544
- return this.parse(options.document, e.createDocumentFromHTML);
6581
+ let document = this.parse(options.document, e.createBrokenDocumentFromHTML);
6582
+ if (document) {
6583
+ this.scriptishNeedFix = true;
6584
+ return document;
6585
+ }
6545
6586
  }
6546
6587
  parseContent(options) {
6547
6588
  let content = options.content || '';
@@ -6549,7 +6590,6 @@ up.ResponseDoc = (_a = class ResponseDoc {
6549
6590
  target = u.map(up.fragment.parseTargetSteps(target), 'selector').join(',');
6550
6591
  const matchingElement = e.createFromSelector(target);
6551
6592
  if (u.isString(content)) {
6552
- content = this.wrapHTML(content);
6553
6593
  matchingElement.innerHTML = content;
6554
6594
  }
6555
6595
  else {
@@ -6562,7 +6602,6 @@ up.ResponseDoc = (_a = class ResponseDoc {
6562
6602
  }
6563
6603
  parse(value, parseFn = e.createFromHTML) {
6564
6604
  if (u.isString(value)) {
6565
- value = this.wrapHTML(value);
6566
6605
  value = parseFn(value);
6567
6606
  }
6568
6607
  return value;
@@ -6570,18 +6609,8 @@ up.ResponseDoc = (_a = class ResponseDoc {
6570
6609
  rootSelector() {
6571
6610
  return up.fragment.toTarget(this.root);
6572
6611
  }
6573
- wrapHTML(html) {
6574
- html = this.noscriptWrapper.wrap(html);
6575
- if (up.fragment.config.runScripts) {
6576
- html = this.scriptWrapper.wrap(html);
6577
- }
6578
- else {
6579
- html = this.scriptWrapper.strip(html);
6580
- }
6581
- return html;
6582
- }
6583
6612
  getTitle() {
6584
- return this.root.querySelector("head title")?.textContent;
6613
+ return this.root.querySelector('head title')?.textContent;
6585
6614
  }
6586
6615
  select(selector) {
6587
6616
  let finder = new up.FragmentFinder({
@@ -6592,9 +6621,10 @@ up.ResponseDoc = (_a = class ResponseDoc {
6592
6621
  return finder.find();
6593
6622
  }
6594
6623
  finalizeElement(element) {
6595
- this.noscriptWrapper.unwrap(element);
6596
6624
  up.NonceableCallback.adoptNonces(element, this.cspNonces);
6597
- this.scriptWrapper.unwrap(element);
6625
+ if (this.scriptishNeedFix) {
6626
+ element.querySelectorAll('noscript, script').forEach(e.fixScriptish);
6627
+ }
6598
6628
  }
6599
6629
  },
6600
6630
  (() => {
@@ -6604,7 +6634,7 @@ up.ResponseDoc = (_a = class ResponseDoc {
6604
6634
 
6605
6635
 
6606
6636
  /***/ }),
6607
- /* 76 */
6637
+ /* 75 */
6608
6638
  /***/ (() => {
6609
6639
 
6610
6640
  const e = up.element;
@@ -6698,7 +6728,7 @@ up.RevealMotion = class RevealMotion {
6698
6728
 
6699
6729
 
6700
6730
  /***/ }),
6701
- /* 77 */
6731
+ /* 76 */
6702
6732
  /***/ (() => {
6703
6733
 
6704
6734
  const u = up.util;
@@ -6739,7 +6769,7 @@ up.Selector = class Selector {
6739
6769
 
6740
6770
 
6741
6771
  /***/ }),
6742
- /* 78 */
6772
+ /* 77 */
6743
6773
  /***/ (() => {
6744
6774
 
6745
6775
  const u = up.util;
@@ -6859,7 +6889,7 @@ up.Tether = class Tether {
6859
6889
 
6860
6890
 
6861
6891
  /***/ }),
6862
- /* 79 */
6892
+ /* 78 */
6863
6893
  /***/ (() => {
6864
6894
 
6865
6895
  const u = up.util;
@@ -6939,7 +6969,7 @@ up.URLPattern = class URLPattern {
6939
6969
 
6940
6970
 
6941
6971
  /***/ }),
6942
- /* 80 */
6972
+ /* 79 */
6943
6973
  /***/ (() => {
6944
6974
 
6945
6975
  up.framework = (function () {
@@ -6957,6 +6987,7 @@ up.framework = (function () {
6957
6987
  readyState = 'booting';
6958
6988
  up.emit('up:framework:boot', { log: false });
6959
6989
  readyState = 'booted';
6990
+ up.emit('up:framework:booted', { log: false });
6960
6991
  }
6961
6992
  else {
6962
6993
  console.error("Unpoly cannot boot: %s", issue);
@@ -7022,7 +7053,7 @@ up.boot = up.framework.boot;
7022
7053
 
7023
7054
 
7024
7055
  /***/ }),
7025
- /* 81 */
7056
+ /* 80 */
7026
7057
  /***/ (() => {
7027
7058
 
7028
7059
  up.event = (function () {
@@ -7038,9 +7069,6 @@ up.event = (function () {
7038
7069
  function on(...args) {
7039
7070
  return buildListenerGroup(args).bind();
7040
7071
  }
7041
- function $on(...args) {
7042
- return buildListenerGroup(args, { jQuery: true }).bind();
7043
- }
7044
7072
  function off(...args) {
7045
7073
  return buildListenerGroup(args).unbind();
7046
7074
  }
@@ -7111,7 +7139,6 @@ up.event = (function () {
7111
7139
  on('up:framework:reset', reset);
7112
7140
  return {
7113
7141
  on,
7114
- $on,
7115
7142
  off,
7116
7143
  build,
7117
7144
  emit,
@@ -7124,14 +7151,12 @@ up.event = (function () {
7124
7151
  };
7125
7152
  })();
7126
7153
  up.on = up.event.on;
7127
- up.$on = up.event.$on;
7128
7154
  up.off = up.event.off;
7129
- up.$off = up.event.off;
7130
7155
  up.emit = up.event.emit;
7131
7156
 
7132
7157
 
7133
7158
  /***/ }),
7134
- /* 82 */
7159
+ /* 81 */
7135
7160
  /***/ (() => {
7136
7161
 
7137
7162
  up.protocol = (function () {
@@ -7147,6 +7172,9 @@ up.protocol = (function () {
7147
7172
  return parseFn(value);
7148
7173
  }
7149
7174
  };
7175
+ function targetFromXHR(xhr) {
7176
+ return extractHeader(xhr, 'target');
7177
+ }
7150
7178
  function parseModifyCacheValue(value) {
7151
7179
  if (value === 'false') {
7152
7180
  return false;
@@ -7167,6 +7195,9 @@ up.protocol = (function () {
7167
7195
  function methodFromXHR(xhr) {
7168
7196
  return extractHeader(xhr, 'method', u.normalizeMethod);
7169
7197
  }
7198
+ function titleFromXHR(xhr) {
7199
+ return up.migrate.titleFromXHR?.(xhr) ?? extractHeader(xhr, 'title', JSON.parse);
7200
+ }
7170
7201
  function eventPlansFromXHR(xhr) {
7171
7202
  return extractHeader(xhr, 'events', JSON.parse);
7172
7203
  }
@@ -7182,11 +7213,9 @@ up.protocol = (function () {
7182
7213
  function locationFromXHR(xhr) {
7183
7214
  return extractHeader(xhr, 'location') || xhr.responseURL;
7184
7215
  }
7185
- function titleFromXHR(xhr) {
7186
- return extractHeader(xhr, 'title');
7187
- }
7188
- function targetFromXHR(xhr) {
7189
- return extractHeader(xhr, 'target');
7216
+ function influencingHeadersFromResponse(response) {
7217
+ let varyHeaderValue = response.header('Vary');
7218
+ return u.parseTokens(varyHeaderValue, { separator: 'comma' });
7190
7219
  }
7191
7220
  const config = new up.Config(() => ({
7192
7221
  methodParam: '_method',
@@ -7262,12 +7291,13 @@ up.protocol = (function () {
7262
7291
  headerize,
7263
7292
  wrapMethod,
7264
7293
  cspNoncesFromHeader,
7294
+ influencingHeadersFromResponse,
7265
7295
  };
7266
7296
  })();
7267
7297
 
7268
7298
 
7269
7299
  /***/ }),
7270
- /* 83 */
7300
+ /* 82 */
7271
7301
  /***/ (() => {
7272
7302
 
7273
7303
  up.log = (function () {
@@ -7353,7 +7383,7 @@ up.warn = up.log.warn;
7353
7383
 
7354
7384
 
7355
7385
  /***/ }),
7356
- /* 84 */
7386
+ /* 83 */
7357
7387
  /***/ (() => {
7358
7388
 
7359
7389
  up.syntax = (function () {
@@ -7377,9 +7407,6 @@ up.syntax = (function () {
7377
7407
  const compiler = buildCompiler(args);
7378
7408
  return insertCompiler(registeredCompilers, compiler);
7379
7409
  }
7380
- function registerJQueryCompiler(...args) {
7381
- registerCompiler(...args, { jQuery: true });
7382
- }
7383
7410
  function registerMacro(...args) {
7384
7411
  const macro = buildCompiler(args);
7385
7412
  if (up.framework.evaling) {
@@ -7388,9 +7415,6 @@ up.syntax = (function () {
7388
7415
  }
7389
7416
  return insertCompiler(registeredMacros, macro);
7390
7417
  }
7391
- function registerJQueryMacro(...args) {
7392
- registerMacro(...args, { jQuery: true });
7393
- }
7394
7418
  function detectSystemMacroPriority(macroSelector) {
7395
7419
  macroSelector = u.evalOption(macroSelector);
7396
7420
  for (let substr in SYSTEM_MACRO_PRIORITIES) {
@@ -7414,7 +7438,6 @@ up.syntax = (function () {
7414
7438
  isDefault: up.framework.evaling,
7415
7439
  priority: 0,
7416
7440
  batch: false,
7417
- jQuery: false
7418
7441
  });
7419
7442
  return Object.assign(callback, options);
7420
7443
  }
@@ -7456,10 +7479,10 @@ up.syntax = (function () {
7456
7479
  destructors.push(destructor);
7457
7480
  }
7458
7481
  }
7459
- function hello(element, { layer, data, dataMap } = {}) {
7460
- element = up.fragment.get(element);
7482
+ function hello(element, options = {}) {
7483
+ element = up.fragment.get(element, options);
7461
7484
  up.puts('up.hello()', "Compiling fragment %o", element);
7462
- compile(element, { layer, data, dataMap });
7485
+ compile(element, options);
7463
7486
  up.fragment.emitInserted(element);
7464
7487
  return element;
7465
7488
  }
@@ -7496,8 +7519,6 @@ up.syntax = (function () {
7496
7519
  return {
7497
7520
  compiler: registerCompiler,
7498
7521
  macro: registerMacro,
7499
- $compiler: registerJQueryCompiler,
7500
- $macro: registerJQueryMacro,
7501
7522
  destructor: registerDestructor,
7502
7523
  hello,
7503
7524
  clean,
@@ -7505,16 +7526,14 @@ up.syntax = (function () {
7505
7526
  };
7506
7527
  })();
7507
7528
  up.compiler = up.syntax.compiler;
7508
- up.$compiler = up.syntax.$compiler;
7509
7529
  up.destructor = up.syntax.destructor;
7510
7530
  up.macro = up.syntax.macro;
7511
- up.$macro = up.syntax.$macro;
7512
7531
  up.data = up.syntax.data;
7513
7532
  up.hello = up.syntax.hello;
7514
7533
 
7515
7534
 
7516
7535
  /***/ }),
7517
- /* 85 */
7536
+ /* 84 */
7518
7537
  /***/ (() => {
7519
7538
 
7520
7539
  up.history = (function () {
@@ -7583,7 +7602,7 @@ up.history = (function () {
7583
7602
  }
7584
7603
  function restoreStateOnPop(state) {
7585
7604
  if (!state?.up) {
7586
- up.puts('pop', 'Ignoring a history state not owned by Unpoly');
7605
+ up.puts('popstate', 'Ignoring a history state not owned by Unpoly');
7587
7606
  return;
7588
7607
  }
7589
7608
  let location = currentLocation();
@@ -7650,10 +7669,10 @@ up.history = (function () {
7650
7669
 
7651
7670
 
7652
7671
  /***/ }),
7653
- /* 86 */
7672
+ /* 85 */
7654
7673
  /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
7655
7674
 
7656
- __webpack_require__(87);
7675
+ __webpack_require__(86);
7657
7676
  const u = up.util;
7658
7677
  const e = up.element;
7659
7678
  up.fragment = (function () {
@@ -7704,7 +7723,7 @@ up.fragment = (function () {
7704
7723
  autoRevalidate: (response) => response.expired,
7705
7724
  skipResponse: defaultSkipResponse
7706
7725
  }));
7707
- u.delegate(config, 'mainTargets', () => up.layer.config.any);
7726
+ u.delegate(config, ['mainTargets'], () => up.layer.config.any);
7708
7727
  function reset() {
7709
7728
  config.reset();
7710
7729
  }
@@ -8170,11 +8189,11 @@ up.destroy = up.fragment.destroy;
8170
8189
  up.render = up.fragment.render;
8171
8190
  up.navigate = up.fragment.navigate;
8172
8191
  up.visit = up.fragment.visit;
8173
- u.delegate(up, 'context', () => up.layer.current);
8192
+ u.delegate(up, ['context'], () => up.layer.current);
8174
8193
 
8175
8194
 
8176
8195
  /***/ }),
8177
- /* 87 */
8196
+ /* 86 */
8178
8197
  /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
8179
8198
 
8180
8199
  "use strict";
@@ -8183,10 +8202,10 @@ __webpack_require__.r(__webpack_exports__);
8183
8202
 
8184
8203
 
8185
8204
  /***/ }),
8186
- /* 88 */
8205
+ /* 87 */
8187
8206
  /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
8188
8207
 
8189
- __webpack_require__(89);
8208
+ __webpack_require__(88);
8190
8209
  up.viewport = (function () {
8191
8210
  const u = up.util;
8192
8211
  const e = up.element;
@@ -8368,7 +8387,7 @@ up.viewport = (function () {
8368
8387
  }
8369
8388
  }
8370
8389
  function newStateCache() {
8371
- return new up.Cache({ size: 30, key: up.history.normalizeURL });
8390
+ return new up.FIFOCache({ capacity: 30, normalizeKey: up.history.normalizeURL });
8372
8391
  }
8373
8392
  function parseOptions(args) {
8374
8393
  const options = u.copy(u.extractOptions(args));
@@ -8506,7 +8525,7 @@ up.reveal = up.viewport.reveal;
8506
8525
 
8507
8526
 
8508
8527
  /***/ }),
8509
- /* 89 */
8528
+ /* 88 */
8510
8529
  /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
8511
8530
 
8512
8531
  "use strict";
@@ -8515,7 +8534,7 @@ __webpack_require__.r(__webpack_exports__);
8515
8534
 
8516
8535
 
8517
8536
  /***/ }),
8518
- /* 90 */
8537
+ /* 89 */
8519
8538
  /***/ (() => {
8520
8539
 
8521
8540
  up.motion = (function () {
@@ -8770,10 +8789,10 @@ up.animate = up.motion.animate;
8770
8789
 
8771
8790
 
8772
8791
  /***/ }),
8773
- /* 91 */
8792
+ /* 90 */
8774
8793
  /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
8775
8794
 
8776
- __webpack_require__(92);
8795
+ __webpack_require__(91);
8777
8796
  const u = up.util;
8778
8797
  up.network = (function () {
8779
8798
  const config = new up.Config(() => ({
@@ -8789,7 +8808,6 @@ up.network = (function () {
8789
8808
  autoCache(request) { return request.isSafe(); },
8790
8809
  expireCache(request, _response) { return !request.isSafe(); },
8791
8810
  evictCache: false,
8792
- requestMetaKeys: ['target', 'failTarget', 'mode', 'failMode', 'context', 'failContext'],
8793
8811
  progressBar: true,
8794
8812
  timeout: 90000,
8795
8813
  }));
@@ -8800,14 +8818,14 @@ up.network = (function () {
8800
8818
  abortRequests();
8801
8819
  queue.reset();
8802
8820
  config.reset();
8803
- cache.evict();
8821
+ cache.reset();
8804
8822
  progressBar?.destroy();
8805
8823
  progressBar = null;
8806
8824
  }
8807
8825
  function makeRequest(...args) {
8808
8826
  const options = parseRequestOptions(args);
8809
8827
  const request = new up.Request(options);
8810
- useCachedRequest(request) || queueRequest(request);
8828
+ processRequest(request);
8811
8829
  return request;
8812
8830
  }
8813
8831
  function parseRequestOptions(args) {
@@ -8818,31 +8836,31 @@ up.network = (function () {
8818
8836
  up.migrate.handleRequestOptions?.(options);
8819
8837
  return options;
8820
8838
  }
8821
- function useCachedRequest(request) {
8839
+ function processRequest(request) {
8840
+ useCachedRequest(request) || queueRequest(request);
8841
+ }
8842
+ function useCachedRequest(newRequest) {
8822
8843
  let cachedRequest;
8823
- if (request.willCache() && (cachedRequest = cache.get(request))) {
8824
- up.puts('up.request()', 'Re-using previous request to %s %s', request.method, request.url);
8825
- if (!request.preload) {
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) {
8826
8847
  queue.promoteToForeground(cachedRequest);
8827
8848
  }
8828
- request.followState(cachedRequest);
8829
- request.fromCache = true;
8849
+ cache.track(cachedRequest, newRequest, { onIncompatible: processRequest });
8830
8850
  return true;
8831
8851
  }
8832
8852
  }
8833
8853
  function queueRequest(request) {
8834
- if (request.preload && !request.isSafe()) {
8835
- up.fail('Will not preload request to %s', request.description);
8836
- }
8837
8854
  handleCaching(request);
8838
8855
  queue.asap(request);
8839
8856
  return true;
8840
8857
  }
8841
8858
  function handleCaching(request) {
8842
8859
  if (request.willCache()) {
8843
- cache.set(request, request);
8860
+ cache.put(request);
8861
+ request.onLoading = () => cache.put(request);
8844
8862
  }
8845
- return u.always(request, function (response) {
8863
+ u.always(request, function (response) {
8846
8864
  let expireCache = response.expireCache ?? request.expireCache ?? u.evalOption(config.expireCache, request, response);
8847
8865
  if (expireCache) {
8848
8866
  cache.expire(expireCache, { except: request });
@@ -8852,7 +8870,7 @@ up.network = (function () {
8852
8870
  cache.evict(evictCache, { except: request });
8853
8871
  }
8854
8872
  if (cache.get(request)) {
8855
- cache.set(request, request);
8873
+ cache.put(request);
8856
8874
  }
8857
8875
  if (!response.ok) {
8858
8876
  cache.evict(request);
@@ -8917,7 +8935,7 @@ up.cache = up.network.cache;
8917
8935
 
8918
8936
 
8919
8937
  /***/ }),
8920
- /* 92 */
8938
+ /* 91 */
8921
8939
  /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
8922
8940
 
8923
8941
  "use strict";
@@ -8926,10 +8944,10 @@ __webpack_require__.r(__webpack_exports__);
8926
8944
 
8927
8945
 
8928
8946
  /***/ }),
8929
- /* 93 */
8947
+ /* 92 */
8930
8948
  /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
8931
8949
 
8932
- __webpack_require__(94);
8950
+ __webpack_require__(93);
8933
8951
  const u = up.util;
8934
8952
  const e = up.element;
8935
8953
  up.layer = (function () {
@@ -9062,6 +9080,7 @@ up.layer = (function () {
9062
9080
  if (handleDeprecatedConfig) {
9063
9081
  configs.forEach(handleDeprecatedConfig);
9064
9082
  }
9083
+ options.openAnimation ?? (options.openAnimation = u.pluckKey(options, 'animation'));
9065
9084
  options = u.mergeDefined(...configs, { mode, stack }, options);
9066
9085
  if (beforeNew) {
9067
9086
  options = beforeNew(options);
@@ -9169,7 +9188,7 @@ up.layer = (function () {
9169
9188
 
9170
9189
 
9171
9190
  /***/ }),
9172
- /* 94 */
9191
+ /* 93 */
9173
9192
  /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
9174
9193
 
9175
9194
  "use strict";
@@ -9178,10 +9197,10 @@ __webpack_require__.r(__webpack_exports__);
9178
9197
 
9179
9198
 
9180
9199
  /***/ }),
9181
- /* 95 */
9200
+ /* 94 */
9182
9201
  /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
9183
9202
 
9184
- __webpack_require__(96);
9203
+ __webpack_require__(95);
9185
9204
  up.link = (function () {
9186
9205
  const u = up.util;
9187
9206
  const e = up.element;
@@ -9329,8 +9348,9 @@ up.link = (function () {
9329
9348
  }
9330
9349
  function preload(link, options) {
9331
9350
  link = up.fragment.get(link);
9332
- if (!shouldPreload()) {
9333
- return Promise.reject(new up.Error('Link preloading is disabled'));
9351
+ let issue = preloadIssue(link);
9352
+ if (issue) {
9353
+ return Promise.reject(new up.Error(issue));
9334
9354
  }
9335
9355
  const guardEvent = up.event.build('up:link:preload', { log: ['Preloading link %o', link] });
9336
9356
  return follow(link, {
@@ -9340,10 +9360,15 @@ up.link = (function () {
9340
9360
  preload: true
9341
9361
  });
9342
9362
  }
9343
- function shouldPreload() {
9344
- let goodConnection = u.negate(up.network.shouldReduceRequests);
9345
- return u.evalAutoOption(config.preloadEnabled, goodConnection);
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
+ }
9346
9370
  }
9371
+ const autoPreloadEnabled = u.negate(up.network.shouldReduceRequests);
9347
9372
  function followMethod(link, options = {}) {
9348
9373
  return u.normalizeMethod(options.method || link.getAttribute('up-method') || link.getAttribute('data-method'));
9349
9374
  }
@@ -9470,7 +9495,7 @@ up.follow = up.link.follow;
9470
9495
 
9471
9496
 
9472
9497
  /***/ }),
9473
- /* 96 */
9498
+ /* 95 */
9474
9499
  /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
9475
9500
 
9476
9501
  "use strict";
@@ -9479,7 +9504,7 @@ __webpack_require__.r(__webpack_exports__);
9479
9504
 
9480
9505
 
9481
9506
  /***/ }),
9482
- /* 97 */
9507
+ /* 96 */
9483
9508
  /***/ (() => {
9484
9509
 
9485
9510
  up.form = (function () {
@@ -9877,7 +9902,7 @@ up.validate = up.form.validate;
9877
9902
 
9878
9903
 
9879
9904
  /***/ }),
9880
- /* 98 */
9905
+ /* 97 */
9881
9906
  /***/ (() => {
9882
9907
 
9883
9908
  up.feedback = (function () {
@@ -9994,7 +10019,7 @@ up.feedback = (function () {
9994
10019
 
9995
10020
 
9996
10021
  /***/ }),
9997
- /* 99 */
10022
+ /* 98 */
9998
10023
  /***/ (() => {
9999
10024
 
10000
10025
  up.radio = (function () {
@@ -10071,7 +10096,7 @@ up.radio = (function () {
10071
10096
 
10072
10097
 
10073
10098
  /***/ }),
10074
- /* 100 */
10099
+ /* 99 */
10075
10100
  /***/ (() => {
10076
10101
 
10077
10102
  (function () {
@@ -10220,16 +10245,15 @@ __webpack_require__(82);
10220
10245
  __webpack_require__(83);
10221
10246
  __webpack_require__(84);
10222
10247
  __webpack_require__(85);
10223
- __webpack_require__(86);
10224
- __webpack_require__(88);
10248
+ __webpack_require__(87);
10249
+ __webpack_require__(89);
10225
10250
  __webpack_require__(90);
10226
- __webpack_require__(91);
10227
- __webpack_require__(93);
10228
- __webpack_require__(95);
10251
+ __webpack_require__(92);
10252
+ __webpack_require__(94);
10253
+ __webpack_require__(96);
10229
10254
  __webpack_require__(97);
10230
10255
  __webpack_require__(98);
10231
10256
  __webpack_require__(99);
10232
- __webpack_require__(100);
10233
10257
  up.framework.onEvaled();
10234
10258
 
10235
10259
  })();