unpoly-rails 2.7.2.2 → 3.0.0.rc1

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-rc2'
8
+ version: '3.0.0-rc1'
9
9
  };
10
10
 
11
11
 
@@ -14,18 +14,13 @@ window.up = {
14
14
  /***/ (() => {
15
15
 
16
16
  up.mockable = function (originalFn) {
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
- }
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;
29
24
  };
30
25
 
31
26
 
@@ -111,15 +106,15 @@ up.util = (function () {
111
106
  return block;
112
107
  }
113
108
  }
114
- function map(list, block) {
115
- if (list.length === 0) {
109
+ function map(array, block) {
110
+ if (array.length === 0) {
116
111
  return [];
117
112
  }
118
113
  block = iteratee(block);
119
114
  let mapped = [];
120
- let i = 0;
121
- for (let item of list) {
122
- mapped.push(block(item, i++));
115
+ for (let i = 0; i < array.length; i++) {
116
+ let element = array[i];
117
+ mapped.push(block(element, i));
123
118
  }
124
119
  return mapped;
125
120
  }
@@ -131,9 +126,8 @@ up.util = (function () {
131
126
  return map(array, pairer).reduce(merger, {});
132
127
  }
133
128
  function each(array, block) {
134
- let i = 0;
135
- for (let item of array) {
136
- block(item, i++);
129
+ for (let i = 0; i < array.length; i++) {
130
+ block(array[i], i);
137
131
  }
138
132
  }
139
133
  function isNull(object) {
@@ -310,11 +304,10 @@ up.util = (function () {
310
304
  function some(list, tester) {
311
305
  return !!findResult(list, tester);
312
306
  }
313
- function findResult(list, tester) {
307
+ function findResult(array, tester) {
314
308
  tester = iteratee(tester);
315
- let i = 0;
316
- for (let item of list) {
317
- const result = tester(item, i++);
309
+ for (let i = 0; i < array.length; i++) {
310
+ const result = tester(array[i], i);
318
311
  if (result) {
319
312
  return result;
320
313
  }
@@ -323,9 +316,8 @@ up.util = (function () {
323
316
  function every(list, tester) {
324
317
  tester = iteratee(tester);
325
318
  let match = true;
326
- let i = 0;
327
- for (let item of list) {
328
- if (!tester(item, i++)) {
319
+ for (let i = 0; i < list.length; i++) {
320
+ if (!tester(list[i], i)) {
329
321
  match = false;
330
322
  break;
331
323
  }
@@ -709,14 +701,6 @@ up.util = (function () {
709
701
  };
710
702
  }
711
703
  }
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
- }
720
704
  return {
721
705
  parseURL,
722
706
  normalizeURL,
@@ -812,8 +796,7 @@ up.util = (function () {
812
796
  sprintf,
813
797
  renameKeys,
814
798
  negate,
815
- memoizeMethod,
816
- safeStringifyJSON,
799
+ memoizeMethod
817
800
  };
818
801
  })();
819
802
 
@@ -888,6 +871,12 @@ up.browser = (function () {
888
871
  return value;
889
872
  }
890
873
  }
874
+ const getJQuery = function () {
875
+ if (!canJQuery()) {
876
+ up.fail('jQuery must be published as window.jQuery');
877
+ }
878
+ return jQuery;
879
+ };
891
880
  function assertConfirmed(options) {
892
881
  const confirmed = !options.confirm || window.confirm(options.confirm);
893
882
  if (!confirmed) {
@@ -902,6 +891,7 @@ up.browser = (function () {
902
891
  canEval,
903
892
  assertConfirmed,
904
893
  popCookie,
894
+ get jQuery() { return getJQuery(); },
905
895
  };
906
896
  })();
907
897
 
@@ -1174,17 +1164,9 @@ up.element = (function () {
1174
1164
  klass = klass.replace(/:/g, '\\:');
1175
1165
  return `.${klass}`;
1176
1166
  }
1177
- function createBrokenDocumentFromHTML(html) {
1167
+ function createDocumentFromHTML(html) {
1178
1168
  return new DOMParser().parseFromString(html, 'text/html');
1179
1169
  }
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
- }
1188
1170
  function createFromHTML(html) {
1189
1171
  const range = document.createRange();
1190
1172
  range.setStart(document.body, 0);
@@ -1447,8 +1429,7 @@ up.element = (function () {
1447
1429
  isSingleton,
1448
1430
  attrSelector,
1449
1431
  tagName: elementTagName,
1450
- createBrokenDocumentFromHTML,
1451
- fixScriptish,
1432
+ createDocumentFromHTML,
1452
1433
  createFromHTML,
1453
1434
  get root() { return getRoot(); },
1454
1435
  paint,
@@ -1895,7 +1876,7 @@ up.Change.Addition = class Addition extends up.Change {
1895
1876
  setETag({ newElement, etag }) {
1896
1877
  e.setMissingAttr(newElement, 'up-etag', etag || false);
1897
1878
  }
1898
- setReloadAttrs(options) {
1879
+ setMeta(options) {
1899
1880
  this.setSource(options);
1900
1881
  this.setTime(options);
1901
1882
  this.setETag(options);
@@ -2138,9 +2119,9 @@ up.Change.OpenLayer = class OpenLayer extends up.Change.Addition {
2138
2119
  this.layer.createElements(this.content);
2139
2120
  this.layer.setupHandlers();
2140
2121
  this.handleHistory();
2141
- this.setReloadAttrs({ newElement: this.content, source: this.options.source });
2122
+ this.setMeta({ newElement: this.content, source: this.options.source });
2142
2123
  responseDoc.finalizeElement(this.content);
2143
- up.hello(this.layer.element, Object.assign(Object.assign({}, this.options), { layer: this.layer }));
2124
+ up.hello(this.layer.element, { layer: this.layer, origin: this.origin });
2144
2125
  this.handleLayerChangeRequests();
2145
2126
  this.handleScroll();
2146
2127
  let renderResult = new up.RenderResult({
@@ -2309,7 +2290,7 @@ up.Change.UpdateLayer = (_a = class UpdateLayer extends up.Change.Addition {
2309
2290
  this.renderResult.fragments.unshift(...newFragments);
2310
2291
  }
2311
2292
  executeStep(step) {
2312
- this.setReloadAttrs(step);
2293
+ this.setMeta(step);
2313
2294
  switch (step.placement) {
2314
2295
  case 'swap': {
2315
2296
  let keepPlan = this.findKeepPlan(step);
@@ -2800,11 +2781,18 @@ up.Change.FromURL = (_a = class FromURL extends up.Change {
2800
2781
  onRequestSettledWithResponse(response) {
2801
2782
  var _a;
2802
2783
  this.response = response;
2803
- if (up.fragment.config.skipResponse(this.loadedEventProps())) {
2784
+ const expiredResponse = this.options.expiredResponse;
2785
+ const eventProps = {
2786
+ response: this.response,
2787
+ renderOptions: this.options,
2788
+ revalidating: !!expiredResponse,
2789
+ expiredResponse,
2790
+ };
2791
+ if (up.fragment.config.skipResponse(eventProps)) {
2804
2792
  this.skip();
2805
2793
  }
2806
2794
  else {
2807
- 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() }));
2795
+ this.request.assertEmitted('up:fragment:loaded', Object.assign(Object.assign({}, eventProps), { callback: this.options.onLoaded, log: ['Loaded fragment from %s', this.response.description], skip: () => this.skip() }));
2808
2796
  }
2809
2797
  let fail = (_a = u.evalOption(this.options.fail, this.response)) !== null && _a !== void 0 ? _a : !response.ok;
2810
2798
  if (fail) {
@@ -2812,22 +2800,6 @@ up.Change.FromURL = (_a = class FromURL extends up.Change {
2812
2800
  }
2813
2801
  return this.updateContentFromResponse(this.options);
2814
2802
  }
2815
- compilerPassMeta() {
2816
- return u.pick(this.loadedEventProps(), [
2817
- 'revalidating',
2818
- 'response'
2819
- ]);
2820
- }
2821
- loadedEventProps() {
2822
- const { expiredResponse } = this.options;
2823
- return {
2824
- request: this.request,
2825
- response: this.response,
2826
- renderOptions: this.options,
2827
- revalidating: !!expiredResponse,
2828
- expiredResponse,
2829
- };
2830
- }
2831
2803
  onRequestSettledWithError(error) {
2832
2804
  if (error instanceof up.Offline) {
2833
2805
  this.request.emit('up:fragment:offline', {
@@ -2850,7 +2822,6 @@ up.Change.FromURL = (_a = class FromURL extends up.Change {
2850
2822
  up.puts('up.render()', 'Rendering failed response using fail-prefixed options (https://unpoly.com/failed-responses)');
2851
2823
  }
2852
2824
  this.augmentOptionsFromResponse(finalRenderOptions);
2853
- finalRenderOptions.meta = this.compilerPassMeta();
2854
2825
  let result = new up.Change.FromContent(finalRenderOptions).execute();
2855
2826
  result.finished = this.finish(result, finalRenderOptions);
2856
2827
  return result;
@@ -2919,7 +2890,6 @@ up.Change.FromURL = (_a = class FromURL extends up.Change {
2919
2890
  (() => {
2920
2891
  u.memoizeMethod(_a.prototype, [
2921
2892
  'getRequestAttrs',
2922
- 'loadedEventProps',
2923
2893
  ]);
2924
2894
  })(),
2925
2895
  _a);
@@ -2931,14 +2901,12 @@ up.Change.FromURL = (_a = class FromURL extends up.Change {
2931
2901
 
2932
2902
  const u = up.util;
2933
2903
  up.CompilerPass = class CompilerPass {
2934
- constructor(root, compilers, { layer, data, dataMap, meta }) {
2935
- layer || (layer = up.layer.get(root) || up.layer.current);
2904
+ constructor(root, compilers, { layer, data, dataMap } = {}) {
2936
2905
  this.root = root;
2937
2906
  this.compilers = compilers;
2938
- this.layer = layer;
2907
+ this.layer = layer || up.layer.get(this.root) || up.layer.current;
2939
2908
  this.data = data;
2940
2909
  this.dataMap = dataMap;
2941
- this.meta = Object.assign({ layer }, meta);
2942
2910
  this.errors = [];
2943
2911
  }
2944
2912
  run() {
@@ -2984,10 +2952,11 @@ up.CompilerPass = class CompilerPass {
2984
2952
  return (_b = (_a = up.migrate).postCompile) === null || _b === void 0 ? void 0 : _b.call(_a, matches, compiler);
2985
2953
  }
2986
2954
  compileOneElement(compiler, element) {
2987
- const compileArgs = [element];
2955
+ const elementArg = compiler.jQuery ? up.browser.jQuery(element) : element;
2956
+ const compileArgs = [elementArg];
2988
2957
  if (compiler.length !== 1) {
2989
2958
  const data = up.syntax.data(element);
2990
- compileArgs.push(data, this.meta);
2959
+ compileArgs.push(data);
2991
2960
  }
2992
2961
  const result = this.applyCompilerFunction(compiler, element, compileArgs);
2993
2962
  let destructorOrDestructors = this.destructorPresence(result);
@@ -2996,10 +2965,11 @@ up.CompilerPass = class CompilerPass {
2996
2965
  }
2997
2966
  }
2998
2967
  compileBatch(compiler, elements) {
2999
- const compileArgs = [elements];
2968
+ const elementsArgs = compiler.jQuery ? up.browser.jQuery(elements) : elements;
2969
+ const compileArgs = [elementsArgs];
3000
2970
  if (compiler.length !== 1) {
3001
2971
  const dataList = u.map(elements, up.syntax.data);
3002
- compileArgs.push(dataList, this.meta);
2972
+ compileArgs.push(dataList);
3003
2973
  }
3004
2974
  const result = this.applyCompilerFunction(compiler, elements, compileArgs);
3005
2975
  if (this.destructorPresence(result)) {
@@ -3305,6 +3275,7 @@ up.EventListener = class EventListener extends up.Record {
3305
3275
  'eventType',
3306
3276
  'selector',
3307
3277
  'callback',
3278
+ 'jQuery',
3308
3279
  'guard',
3309
3280
  'baseLayer',
3310
3281
  'passive',
@@ -3352,7 +3323,8 @@ up.EventListener = class EventListener extends up.Record {
3352
3323
  return;
3353
3324
  }
3354
3325
  if (element) {
3355
- const args = [event, element];
3326
+ const elementArg = this.jQuery ? up.browser.jQuery(element) : element;
3327
+ const args = [event, elementArg];
3356
3328
  const expectedArgCount = this.callback.length;
3357
3329
  if (expectedArgCount !== 1 && expectedArgCount !== 2) {
3358
3330
  const data = up.syntax.data(element);
@@ -3408,6 +3380,7 @@ up.EventListenerGroup = class EventListenerGroup extends up.Record {
3408
3380
  'eventTypes',
3409
3381
  'selector',
3410
3382
  'callback',
3383
+ 'jQuery',
3411
3384
  'guard',
3412
3385
  'baseLayer',
3413
3386
  'passive',
@@ -4182,6 +4155,44 @@ up.FragmentScrolling = class FragmentScrolling extends up.FragmentProcessor {
4182
4155
  /* 47 */
4183
4156
  /***/ (() => {
4184
4157
 
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
+
4185
4196
  const e = up.element;
4186
4197
  const u = up.util;
4187
4198
  up.Layer = class Layer extends up.Record {
@@ -4328,12 +4339,12 @@ up.Layer = class Layer extends up.Record {
4328
4339
  return this.stack.asCurrent(this, fn);
4329
4340
  }
4330
4341
  updateHistory(options) {
4331
- if (u.isString(options.location)) {
4332
- this.location = options.location;
4333
- }
4334
4342
  if (u.isString(options.title)) {
4335
4343
  this.title = options.title;
4336
4344
  }
4345
+ if (u.isString(options.location)) {
4346
+ this.location = options.location;
4347
+ }
4337
4348
  }
4338
4349
  isHistoryVisible() {
4339
4350
  return this.history && (this.isRoot() || this.parent.isHistoryVisible());
@@ -4366,14 +4377,12 @@ up.Layer = class Layer extends up.Record {
4366
4377
  set location(location) {
4367
4378
  const previousLocation = this.location;
4368
4379
  location = up.history.normalizeURL(location);
4369
- if (previousLocation !== location || this.opening) {
4380
+ if (previousLocation !== location) {
4370
4381
  this.savedLocation = location;
4382
+ this.emit('up:layer:location:changed', { location, log: false });
4371
4383
  if (this.showsLiveHistory()) {
4372
4384
  up.history.push(location);
4373
4385
  }
4374
- if (!this.opening) {
4375
- this.emit('up:layer:location:changed', { location });
4376
- }
4377
4386
  }
4378
4387
  }
4379
4388
  selector(part) {
@@ -4399,7 +4408,7 @@ up.Layer = class Layer extends up.Record {
4399
4408
 
4400
4409
 
4401
4410
  /***/ }),
4402
- /* 48 */
4411
+ /* 49 */
4403
4412
  /***/ (() => {
4404
4413
 
4405
4414
  const e = up.element;
@@ -4679,7 +4688,7 @@ up.Layer.Overlay = class Overlay extends up.Layer {
4679
4688
 
4680
4689
 
4681
4690
  /***/ }),
4682
- /* 49 */
4691
+ /* 50 */
4683
4692
  /***/ (() => {
4684
4693
 
4685
4694
  up.Layer.OverlayWithTether = class OverlayWithTether extends up.Layer.Overlay {
@@ -4716,7 +4725,7 @@ up.Layer.OverlayWithTether = class OverlayWithTether extends up.Layer.Overlay {
4716
4725
 
4717
4726
 
4718
4727
  /***/ }),
4719
- /* 50 */
4728
+ /* 51 */
4720
4729
  /***/ (() => {
4721
4730
 
4722
4731
  var _a;
@@ -4754,7 +4763,7 @@ up.Layer.OverlayWithViewport = (_a = class OverlayWithViewport extends up.Layer.
4754
4763
 
4755
4764
 
4756
4765
  /***/ }),
4757
- /* 51 */
4766
+ /* 52 */
4758
4767
  /***/ (() => {
4759
4768
 
4760
4769
  var _a;
@@ -4803,7 +4812,7 @@ up.Layer.Root = (_a = class Root extends up.Layer {
4803
4812
 
4804
4813
 
4805
4814
  /***/ }),
4806
- /* 52 */
4815
+ /* 53 */
4807
4816
  /***/ (() => {
4808
4817
 
4809
4818
  var _a;
@@ -4814,7 +4823,7 @@ up.Layer.Modal = (_a = class Modal extends up.Layer.OverlayWithViewport {
4814
4823
 
4815
4824
 
4816
4825
  /***/ }),
4817
- /* 53 */
4826
+ /* 54 */
4818
4827
  /***/ (() => {
4819
4828
 
4820
4829
  var _a;
@@ -4825,7 +4834,7 @@ up.Layer.Popup = (_a = class Popup extends up.Layer.OverlayWithTether {
4825
4834
 
4826
4835
 
4827
4836
  /***/ }),
4828
- /* 54 */
4837
+ /* 55 */
4829
4838
  /***/ (() => {
4830
4839
 
4831
4840
  var _a;
@@ -4836,7 +4845,7 @@ up.Layer.Drawer = (_a = class Drawer extends up.Layer.OverlayWithViewport {
4836
4845
 
4837
4846
 
4838
4847
  /***/ }),
4839
- /* 55 */
4848
+ /* 56 */
4840
4849
  /***/ (() => {
4841
4850
 
4842
4851
  var _a;
@@ -4847,7 +4856,7 @@ up.Layer.Cover = (_a = class Cover extends up.Layer.OverlayWithViewport {
4847
4856
 
4848
4857
 
4849
4858
  /***/ }),
4850
- /* 56 */
4859
+ /* 57 */
4851
4860
  /***/ (() => {
4852
4861
 
4853
4862
  const u = up.util;
@@ -4937,7 +4946,7 @@ up.LayerLookup = class LayerLookup {
4937
4946
 
4938
4947
 
4939
4948
  /***/ }),
4940
- /* 57 */
4949
+ /* 58 */
4941
4950
  /***/ (() => {
4942
4951
 
4943
4952
  const u = up.util;
@@ -5050,7 +5059,7 @@ up.LayerStack = class LayerStack extends Array {
5050
5059
 
5051
5060
 
5052
5061
  /***/ }),
5053
- /* 58 */
5062
+ /* 59 */
5054
5063
  /***/ (() => {
5055
5064
 
5056
5065
  up.LinkFeedbackURLs = class LinkFeedbackURLs {
@@ -5081,7 +5090,7 @@ up.LinkFeedbackURLs = class LinkFeedbackURLs {
5081
5090
 
5082
5091
 
5083
5092
  /***/ }),
5084
- /* 59 */
5093
+ /* 60 */
5085
5094
  /***/ (() => {
5086
5095
 
5087
5096
  const u = up.util;
@@ -5151,7 +5160,7 @@ up.LinkPreloader = class LinkPreloader {
5151
5160
 
5152
5161
 
5153
5162
  /***/ }),
5154
- /* 60 */
5163
+ /* 61 */
5155
5164
  /***/ (function() {
5156
5165
 
5157
5166
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
@@ -5260,7 +5269,7 @@ up.MotionController = class MotionController {
5260
5269
 
5261
5270
 
5262
5271
  /***/ }),
5263
- /* 61 */
5272
+ /* 62 */
5264
5273
  /***/ (() => {
5265
5274
 
5266
5275
  const u = up.util;
@@ -5352,7 +5361,7 @@ up.NonceableCallback = class NonceableCallback {
5352
5361
 
5353
5362
 
5354
5363
  /***/ }),
5355
- /* 62 */
5364
+ /* 63 */
5356
5365
  /***/ (() => {
5357
5366
 
5358
5367
  const u = up.util;
@@ -5430,7 +5439,7 @@ up.OptionsParser = class OptionsParser {
5430
5439
 
5431
5440
 
5432
5441
  /***/ }),
5433
- /* 63 */
5442
+ /* 64 */
5434
5443
  /***/ (() => {
5435
5444
 
5436
5445
  const e = up.element;
@@ -5498,7 +5507,7 @@ up.OverlayFocus = class OverlayFocus {
5498
5507
 
5499
5508
 
5500
5509
  /***/ }),
5501
- /* 64 */
5510
+ /* 65 */
5502
5511
  /***/ (() => {
5503
5512
 
5504
5513
  const u = up.util;
@@ -5729,7 +5738,7 @@ up.Params = class Params {
5729
5738
 
5730
5739
 
5731
5740
  /***/ }),
5732
- /* 65 */
5741
+ /* 66 */
5733
5742
  /***/ (() => {
5734
5743
 
5735
5744
  const e = up.element;
@@ -5779,7 +5788,7 @@ up.ProgressBar = class ProgressBar {
5779
5788
 
5780
5789
 
5781
5790
  /***/ }),
5782
- /* 66 */
5791
+ /* 67 */
5783
5792
  /***/ (() => {
5784
5793
 
5785
5794
  const u = up.util;
@@ -5825,7 +5834,7 @@ up.RenderOptions = (function () {
5825
5834
  'history',
5826
5835
  'source',
5827
5836
  'saveScroll',
5828
- 'navigate',
5837
+ 'navigate'
5829
5838
  ]);
5830
5839
  const CONTENT_KEYS = [
5831
5840
  'url',
@@ -5896,7 +5905,7 @@ up.RenderOptions = (function () {
5896
5905
 
5897
5906
 
5898
5907
  /***/ }),
5899
- /* 67 */
5908
+ /* 68 */
5900
5909
  /***/ (() => {
5901
5910
 
5902
5911
  up.RenderResult = class RenderResult extends up.Record {
@@ -5924,7 +5933,7 @@ up.RenderResult = class RenderResult extends up.Record {
5924
5933
 
5925
5934
 
5926
5935
  /***/ }),
5927
- /* 68 */
5936
+ /* 69 */
5928
5937
  /***/ (() => {
5929
5938
 
5930
5939
  var _a;
@@ -5949,7 +5958,6 @@ up.Request = (_a = class Request extends up.Record {
5949
5958
  }
5950
5959
  this.deferred = u.newDeferred();
5951
5960
  (_a = this.badResponseTime) !== null && _a !== void 0 ? _a : (this.badResponseTime = u.evalOption(up.network.config.badResponseTime, this));
5952
- this.uid = u.uid();
5953
5961
  }
5954
5962
  keys() {
5955
5963
  return [
@@ -6012,6 +6020,9 @@ up.Request = (_a = class Request extends up.Record {
6012
6020
  var _a;
6013
6021
  return (_a = this.fragments) === null || _a === void 0 ? void 0 : _a[0];
6014
6022
  }
6023
+ followState(sourceRequest) {
6024
+ u.delegate(this, ['deferred', 'state', 'preload', 'expired'], () => sourceRequest);
6025
+ }
6015
6026
  normalizeForCaching() {
6016
6027
  this.method = u.normalizeMethod(this.method);
6017
6028
  this.extractHashFromURL();
@@ -6055,12 +6066,10 @@ up.Request = (_a = class Request extends up.Record {
6055
6066
  }
6056
6067
  runQueuedCallbacks() {
6057
6068
  var _a;
6058
- this.queuedAt = new Date();
6059
6069
  u.always(this, () => this.evictExpensiveAttrs());
6060
6070
  (_a = this.onQueued) === null || _a === void 0 ? void 0 : _a.call(this, this);
6061
6071
  }
6062
6072
  load() {
6063
- console.debug("[request] calling load() on %o", this.description);
6064
6073
  if (this.state !== 'new')
6065
6074
  return;
6066
6075
  this.state = 'loading';
@@ -6114,18 +6123,14 @@ up.Request = (_a = class Request extends up.Record {
6114
6123
  this.emit('up:request:offline', { log: message });
6115
6124
  }
6116
6125
  respondWith(response) {
6117
- this.response = response;
6118
- console.debug("[request] respondWith() at state %o / uid %o", this.state, this.uid);
6119
- if (this.isSettled())
6126
+ if (this.state !== 'loading')
6120
6127
  return;
6121
6128
  this.state = 'loaded';
6122
6129
  if (response.ok) {
6123
- console.debug("[request] fulfilling deferred of %o with response", this.uid);
6124
- this.deferred.resolve(response);
6130
+ return this.deferred.resolve(response);
6125
6131
  }
6126
6132
  else {
6127
- console.debug("[request] rejecting deferred of %o with response", this.uid);
6128
- this.deferred.reject(response);
6133
+ return this.deferred.reject(response);
6129
6134
  }
6130
6135
  }
6131
6136
  isSettled() {
@@ -6176,6 +6181,24 @@ up.Request = (_a = class Request extends up.Record {
6176
6181
  }
6177
6182
  return new up.Response(responseAttrs);
6178
6183
  }
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
+ }
6179
6202
  buildEventEmitter(args) {
6180
6203
  return up.EventEmitter.fromEmitArgs(args, {
6181
6204
  layer: this.layer,
@@ -6205,9 +6228,6 @@ up.Request = (_a = class Request extends up.Record {
6205
6228
  const now = new Date();
6206
6229
  return now - this.queuedAt;
6207
6230
  }
6208
- header(name) {
6209
- return this.headers[name];
6210
- }
6211
6231
  static tester(condition, { except } = {}) {
6212
6232
  let testFn;
6213
6233
  if (u.isFunction(condition)) {
@@ -6224,7 +6244,8 @@ up.Request = (_a = class Request extends up.Record {
6224
6244
  testFn = (_request) => condition;
6225
6245
  }
6226
6246
  if (except) {
6227
- return (request) => !up.cache.isCacheCompatible(except, request) && testFn(request);
6247
+ let exceptCacheKey = except.cacheKey();
6248
+ return (request) => (request.cacheKey() !== exceptCacheKey) && testFn(request);
6228
6249
  }
6229
6250
  else {
6230
6251
  return testFn;
@@ -6238,7 +6259,7 @@ up.Request = (_a = class Request extends up.Record {
6238
6259
 
6239
6260
 
6240
6261
  /***/ }),
6241
- /* 69 */
6262
+ /* 70 */
6242
6263
  /***/ (() => {
6243
6264
 
6244
6265
  let u = up.util;
@@ -6269,151 +6290,6 @@ up.Request.Cache = class Cache extends up.Cache {
6269
6290
  };
6270
6291
 
6271
6292
 
6272
- /***/ }),
6273
- /* 70 */
6274
- /***/ (function() {
6275
-
6276
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
6277
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
6278
- return new (P || (P = Promise))(function (resolve, reject) {
6279
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6280
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6281
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
6282
- step((generator = generator.apply(thisArg, _arguments || [])).next());
6283
- });
6284
- };
6285
- const u = up.util;
6286
- up.Request.Cache3 = class Cache3 {
6287
- constructor() {
6288
- this.reset();
6289
- }
6290
- reset() {
6291
- this.varyInfo = {};
6292
- this.map = new Map();
6293
- }
6294
- cacheKey(request) {
6295
- let varyHeaderNames = this.getPreviousVaryHeaderNames(request);
6296
- let varyPart = u.flatMap(varyHeaderNames, (headerName) => [headerName, request.header(headerName)]);
6297
- return [request.description, ...varyPart].join(':');
6298
- }
6299
- getPreviousVaryHeaderNames(request) {
6300
- var _a, _b;
6301
- return ((_a = this.varyInfo)[_b = request.description] || (_a[_b] = new Set()));
6302
- }
6303
- get(request) {
6304
- console.debug("[cache] get() called with %o", request.description);
6305
- let cacheKey = this.cacheKey(request);
6306
- let cachedRequest = this.map.get(cacheKey);
6307
- console.debug("[cache] cache hit is %o", cachedRequest);
6308
- if (cachedRequest) {
6309
- if (this.isUsable(cachedRequest)) {
6310
- return cachedRequest;
6311
- }
6312
- else {
6313
- this.map.delete(cacheKey);
6314
- }
6315
- }
6316
- }
6317
- get maxSize() {
6318
- return up.network.config.cacheSize;
6319
- }
6320
- isUsable(request) {
6321
- const evictAge = up.network.config.cacheEvictAge;
6322
- const age = new Date() - request.queuedAt;
6323
- return age < evictAge;
6324
- }
6325
- put(request) {
6326
- return __awaiter(this, void 0, void 0, function* () {
6327
- console.debug("[cache] put() called for %o", request.description);
6328
- this.makeRoom();
6329
- let cacheKey = this.updateCacheKey(request);
6330
- this.map.set(cacheKey, request);
6331
- });
6332
- }
6333
- updateCacheKey(request) {
6334
- let oldCacheKey = this.cacheKey(request);
6335
- let { response } = request;
6336
- if (response) {
6337
- this.mergePreviousHeaderNames(request, response);
6338
- let newCacheKey = this.cacheKey(request);
6339
- this.renameMapKey(oldCacheKey, newCacheKey);
6340
- return newCacheKey;
6341
- }
6342
- else {
6343
- return oldCacheKey;
6344
- }
6345
- }
6346
- renameMapKey(oldKey, newKey) {
6347
- if (this.map.has(oldKey)) {
6348
- this.map.set(newKey, this.map.get(oldKey));
6349
- this.map.delete(oldKey);
6350
- }
6351
- }
6352
- mergePreviousHeaderNames(request, response) {
6353
- let responseVaryHeaderNames = response.ownVaryHeaderNames;
6354
- if (responseVaryHeaderNames.length) {
6355
- let previousVaryHeaderNames = this.getPreviousVaryHeaderNames(request);
6356
- for (let varyHeaderName of responseVaryHeaderNames) {
6357
- previousVaryHeaderNames.add(varyHeaderName);
6358
- }
6359
- }
6360
- }
6361
- alias(existingCachedRequest, newRequest) {
6362
- this.connect(existingCachedRequest, newRequest, { force: true });
6363
- this.put(newRequest);
6364
- }
6365
- connect(existingCachedRequest, newRequest, options = {}) {
6366
- var _a;
6367
- return __awaiter(this, void 0, void 0, function* () {
6368
- let value = yield u.always(existingCachedRequest);
6369
- if (value instanceof up.Response) {
6370
- console.debug("[cache] connect settles to response %o", value.text);
6371
- if (options.force || this.isCacheCompatible(existingCachedRequest, newRequest)) {
6372
- console.debug("[cache] they are compatible");
6373
- newRequest.fromCache = true;
6374
- newRequest.respondWith(value);
6375
- u.delegate(newRequest, ['expired', 'state'], () => existingCachedRequest);
6376
- }
6377
- else {
6378
- console.debug("[cache] they are incompatible");
6379
- (_a = options.onIncompatible) === null || _a === void 0 ? void 0 : _a.call(options, newRequest);
6380
- }
6381
- }
6382
- else {
6383
- newRequest.deferred.reject(value);
6384
- }
6385
- });
6386
- }
6387
- delete(request) {
6388
- let cacheKey = this.cacheKey(request);
6389
- this.map.delete(cacheKey);
6390
- }
6391
- evict(condition = true, testerOptions) {
6392
- this.eachMatch(condition, testerOptions, (request) => this.delete(request));
6393
- }
6394
- expire(condition = true, testerOptions) {
6395
- this.eachMatch(condition, testerOptions, (request) => request.expired = true);
6396
- }
6397
- makeRoom() {
6398
- if (this.maxSize === 0) {
6399
- throw "Disabling the cache with maxSize 0 is no longer supported. Use up.network.config.autoCache = false instead.";
6400
- }
6401
- while (this.map.size >= this.maxSize) {
6402
- let oldestKey = this.map.keys().next().value;
6403
- this.map.delete(oldestKey);
6404
- }
6405
- }
6406
- eachMatch(condition = true, testerOptions, fn) {
6407
- let tester = up.Request.tester(condition, testerOptions);
6408
- let results = u.filter(this.map.values(), tester);
6409
- u.each(results, fn);
6410
- }
6411
- isCacheCompatible(request1, request2) {
6412
- return this.cacheKey(request1) === this.cacheKey(request2);
6413
- }
6414
- };
6415
-
6416
-
6417
6293
  /***/ }),
6418
6294
  /* 71 */
6419
6295
  /***/ (() => {
@@ -6434,6 +6310,7 @@ up.Request.Queue = class Queue {
6434
6310
  asap(request) {
6435
6311
  request.runQueuedCallbacks();
6436
6312
  u.always(request, responseOrError => this.onRequestSettled(request, responseOrError));
6313
+ request.queuedAt = new Date();
6437
6314
  this.scheduleSlowTimer(request);
6438
6315
  this.queueRequest(request);
6439
6316
  u.microtask(() => this.poke());
@@ -6586,8 +6463,12 @@ up.Request.XHRRenderer = (_a = class XHRRenderer {
6586
6463
  xhr.timeout = this.request.timeout;
6587
6464
  }
6588
6465
  xhr.open(this.getMethod(), this.request.url);
6589
- for (let key of ['target', 'failTarget', 'mode', 'failMode', 'context', 'failContext']) {
6590
- this.addHeader(xhr, up.protocol.headerize(key), this.request[key]);
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]);
6591
6472
  }
6592
6473
  let csrfHeader, csrfToken;
6593
6474
  if ((csrfHeader = this.request.csrfHeader()) && (csrfToken = this.request.csrfToken())) {
@@ -6598,10 +6479,6 @@ up.Request.XHRRenderer = (_a = class XHRRenderer {
6598
6479
  if (contentType) {
6599
6480
  this.addHeader(xhr, 'Content-Type', contentType);
6600
6481
  }
6601
- for (let headerName in this.request.headers) {
6602
- let headerValue = this.request.headers[headerName];
6603
- xhr.setRequestHeader(headerName, headerValue);
6604
- }
6605
6482
  Object.assign(xhr, handlers);
6606
6483
  xhr.send(this.getPayload());
6607
6484
  }
@@ -6622,11 +6499,11 @@ up.Request.XHRRenderer = (_a = class XHRRenderer {
6622
6499
  this.finalizePayload();
6623
6500
  return this.payload;
6624
6501
  }
6625
- addHeader(xhr, name, value) {
6502
+ addHeader(xhr, header, value) {
6626
6503
  if (u.isOptions(value) || u.isArray(value)) {
6627
- value = u.safeStringifyJSON(value);
6504
+ value = JSON.stringify(value);
6628
6505
  }
6629
- this.request.headers[name] = value;
6506
+ xhr.setRequestHeader(header, value);
6630
6507
  }
6631
6508
  finalizePayload() {
6632
6509
  this.payload = this.request.payload;
@@ -6690,29 +6567,24 @@ up.Response = class Response extends up.Record {
6690
6567
  var _a;
6691
6568
  return !u.evalOption((_a = this.fail) !== null && _a !== void 0 ? _a : up.network.config.fail, this);
6692
6569
  }
6693
- header(name) {
6570
+ getHeader(name) {
6694
6571
  var _a;
6695
6572
  return this.headers[name] || ((_a = this.xhr) === null || _a === void 0 ? void 0 : _a.getResponseHeader(name));
6696
6573
  }
6697
- get ownVaryHeaderNames() {
6698
- let varyHeaderValue = this.header('Vary');
6699
- let varyHeaderNames = u.parseTokens(varyHeaderValue, { separator: 'comma' });
6700
- return u.filter(varyHeaderNames, (headerName) => this.request.header(headerName));
6701
- }
6702
6574
  get contentType() {
6703
- return this.header('Content-Type');
6575
+ return this.getHeader('Content-Type');
6704
6576
  }
6705
6577
  get cspNonces() {
6706
- return up.protocol.cspNoncesFromHeader(this.header('Content-Security-Policy'));
6578
+ return up.protocol.cspNoncesFromHeader(this.getHeader('Content-Security-Policy'));
6707
6579
  }
6708
6580
  get lastModified() {
6709
- let header = this.header('Last-Modified');
6581
+ let header = this.getHeader('Last-Modified');
6710
6582
  if (header) {
6711
6583
  return new Date(header);
6712
6584
  }
6713
6585
  }
6714
6586
  get etag() {
6715
- return this.header('ETag');
6587
+ return this.getHeader('ETag');
6716
6588
  }
6717
6589
  get json() {
6718
6590
  return this.parsedJSON || (this.parsedJSON = JSON.parse(this.text));
@@ -6722,8 +6594,7 @@ up.Response = class Response extends up.Record {
6722
6594
  return now - this.loadedAt;
6723
6595
  }
6724
6596
  get expired() {
6725
- return this.age > up.network.config.cacheExpireAge ||
6726
- this.request.expired;
6597
+ return this.age > up.network.config.cacheExpireAge || this.request.expired;
6727
6598
  }
6728
6599
  get description() {
6729
6600
  return `HTTP ${this.status} response to ${this.request.description}`;
@@ -6740,13 +6611,12 @@ const u = up.util;
6740
6611
  const e = up.element;
6741
6612
  up.ResponseDoc = (_a = class ResponseDoc {
6742
6613
  constructor(options) {
6614
+ this.noscriptWrapper = new up.HTMLWrapper('noscript');
6615
+ this.scriptWrapper = new up.HTMLWrapper('script');
6743
6616
  this.root =
6744
6617
  this.parseDocument(options) ||
6745
6618
  this.parseFragment(options) ||
6746
6619
  this.parseContent(options);
6747
- if (!up.fragment.config.runScripts) {
6748
- this.root.querySelectorAll('script').forEach((e) => e.remove());
6749
- }
6750
6620
  this.cspNonces = options.cspNonces;
6751
6621
  if (options.origin) {
6752
6622
  let originSelector = up.fragment.tryToTarget(options.origin);
@@ -6756,11 +6626,7 @@ up.ResponseDoc = (_a = class ResponseDoc {
6756
6626
  }
6757
6627
  }
6758
6628
  parseDocument(options) {
6759
- let document = this.parse(options.document, e.createBrokenDocumentFromHTML);
6760
- if (document) {
6761
- this.scriptishNeedFix = true;
6762
- return document;
6763
- }
6629
+ return this.parse(options.document, e.createDocumentFromHTML);
6764
6630
  }
6765
6631
  parseContent(options) {
6766
6632
  let content = options.content || '';
@@ -6768,6 +6634,7 @@ up.ResponseDoc = (_a = class ResponseDoc {
6768
6634
  target = u.map(up.fragment.parseTargetSteps(target), 'selector').join(',');
6769
6635
  const matchingElement = e.createFromSelector(target);
6770
6636
  if (u.isString(content)) {
6637
+ content = this.wrapHTML(content);
6771
6638
  matchingElement.innerHTML = content;
6772
6639
  }
6773
6640
  else {
@@ -6780,6 +6647,7 @@ up.ResponseDoc = (_a = class ResponseDoc {
6780
6647
  }
6781
6648
  parse(value, parseFn = e.createFromHTML) {
6782
6649
  if (u.isString(value)) {
6650
+ value = this.wrapHTML(value);
6783
6651
  value = parseFn(value);
6784
6652
  }
6785
6653
  return value;
@@ -6787,9 +6655,19 @@ up.ResponseDoc = (_a = class ResponseDoc {
6787
6655
  rootSelector() {
6788
6656
  return up.fragment.toTarget(this.root);
6789
6657
  }
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
+ }
6790
6668
  getTitle() {
6791
6669
  var _a;
6792
- return (_a = this.root.querySelector('head title')) === null || _a === void 0 ? void 0 : _a.textContent;
6670
+ return (_a = this.root.querySelector("head title")) === null || _a === void 0 ? void 0 : _a.textContent;
6793
6671
  }
6794
6672
  select(selector) {
6795
6673
  let finder = new up.FragmentFinder({
@@ -6800,10 +6678,9 @@ up.ResponseDoc = (_a = class ResponseDoc {
6800
6678
  return finder.find();
6801
6679
  }
6802
6680
  finalizeElement(element) {
6681
+ this.noscriptWrapper.unwrap(element);
6803
6682
  up.NonceableCallback.adoptNonces(element, this.cspNonces);
6804
- if (this.scriptishNeedFix) {
6805
- element.querySelectorAll('noscript, script').forEach(e.fixScriptish);
6806
- }
6683
+ this.scriptWrapper.unwrap(element);
6807
6684
  }
6808
6685
  },
6809
6686
  (() => {
@@ -7169,7 +7046,6 @@ up.framework = (function () {
7169
7046
  readyState = 'booting';
7170
7047
  up.emit('up:framework:boot', { log: false });
7171
7048
  readyState = 'booted';
7172
- up.emit('up:framework:booted', { log: false });
7173
7049
  }
7174
7050
  else {
7175
7051
  console.error("Unpoly cannot boot: %s", issue);
@@ -7251,6 +7127,9 @@ up.event = (function () {
7251
7127
  function on(...args) {
7252
7128
  return buildListenerGroup(args).bind();
7253
7129
  }
7130
+ function $on(...args) {
7131
+ return buildListenerGroup(args, { jQuery: true }).bind();
7132
+ }
7254
7133
  function off(...args) {
7255
7134
  return buildListenerGroup(args).unbind();
7256
7135
  }
@@ -7321,6 +7200,7 @@ up.event = (function () {
7321
7200
  on('up:framework:reset', reset);
7322
7201
  return {
7323
7202
  on,
7203
+ $on,
7324
7204
  off,
7325
7205
  build,
7326
7206
  emit,
@@ -7333,7 +7213,9 @@ up.event = (function () {
7333
7213
  };
7334
7214
  })();
7335
7215
  up.on = up.event.on;
7216
+ up.$on = up.event.$on;
7336
7217
  up.off = up.event.off;
7218
+ up.$off = up.event.off;
7337
7219
  up.emit = up.event.emit;
7338
7220
 
7339
7221
 
@@ -7391,8 +7273,7 @@ up.protocol = (function () {
7391
7273
  return extractHeader(xhr, 'location') || xhr.responseURL;
7392
7274
  }
7393
7275
  function titleFromXHR(xhr) {
7394
- var _a, _b, _c;
7395
- return (_c = (_b = (_a = up.migrate).titleFromXHR) === null || _b === void 0 ? void 0 : _b.call(_a, xhr)) !== null && _c !== void 0 ? _c : extractHeader(xhr, 'title', JSON.parse);
7276
+ return extractHeader(xhr, 'title');
7396
7277
  }
7397
7278
  function targetFromXHR(xhr) {
7398
7279
  return extractHeader(xhr, 'target');
@@ -7586,6 +7467,9 @@ up.syntax = (function () {
7586
7467
  const compiler = buildCompiler(args);
7587
7468
  return insertCompiler(registeredCompilers, compiler);
7588
7469
  }
7470
+ function registerJQueryCompiler(...args) {
7471
+ registerCompiler(...args, { jQuery: true });
7472
+ }
7589
7473
  function registerMacro(...args) {
7590
7474
  const macro = buildCompiler(args);
7591
7475
  if (up.framework.evaling) {
@@ -7594,6 +7478,9 @@ up.syntax = (function () {
7594
7478
  }
7595
7479
  return insertCompiler(registeredMacros, macro);
7596
7480
  }
7481
+ function registerJQueryMacro(...args) {
7482
+ registerMacro(...args, { jQuery: true });
7483
+ }
7597
7484
  function detectSystemMacroPriority(macroSelector) {
7598
7485
  macroSelector = u.evalOption(macroSelector);
7599
7486
  for (let substr in SYSTEM_MACRO_PRIORITIES) {
@@ -7617,6 +7504,7 @@ up.syntax = (function () {
7617
7504
  isDefault: up.framework.evaling,
7618
7505
  priority: 0,
7619
7506
  batch: false,
7507
+ jQuery: false
7620
7508
  });
7621
7509
  return Object.assign(callback, options);
7622
7510
  }
@@ -7658,10 +7546,10 @@ up.syntax = (function () {
7658
7546
  destructors.push(destructor);
7659
7547
  }
7660
7548
  }
7661
- function hello(element, options = {}) {
7662
- element = up.fragment.get(element, options);
7549
+ function hello(element, { layer, data, dataMap } = {}) {
7550
+ element = up.fragment.get(element);
7663
7551
  up.puts('up.hello()', "Compiling fragment %o", element);
7664
- compile(element, options);
7552
+ compile(element, { layer, data, dataMap });
7665
7553
  up.fragment.emitInserted(element);
7666
7554
  return element;
7667
7555
  }
@@ -7694,6 +7582,8 @@ up.syntax = (function () {
7694
7582
  return {
7695
7583
  compiler: registerCompiler,
7696
7584
  macro: registerMacro,
7585
+ $compiler: registerJQueryCompiler,
7586
+ $macro: registerJQueryMacro,
7697
7587
  destructor: registerDestructor,
7698
7588
  hello,
7699
7589
  clean,
@@ -7701,8 +7591,10 @@ up.syntax = (function () {
7701
7591
  };
7702
7592
  })();
7703
7593
  up.compiler = up.syntax.compiler;
7594
+ up.$compiler = up.syntax.$compiler;
7704
7595
  up.destructor = up.syntax.destructor;
7705
7596
  up.macro = up.syntax.macro;
7597
+ up.$macro = up.syntax.$macro;
7706
7598
  up.data = up.syntax.data;
7707
7599
  up.hello = up.syntax.hello;
7708
7600
 
@@ -8992,24 +8884,25 @@ up.network = (function () {
8992
8884
  autoCache(request) { return request.isSafe(); },
8993
8885
  expireCache(request, _response) { return !request.isSafe(); },
8994
8886
  evictCache: false,
8887
+ requestMetaKeys: ['target', 'failTarget', 'mode', 'failMode', 'context', 'failContext'],
8995
8888
  progressBar: true,
8996
8889
  timeout: 90000,
8997
8890
  }));
8998
8891
  const queue = new up.Request.Queue();
8999
- const cache = new up.Request.Cache3();
8892
+ const cache = new up.Request.Cache();
9000
8893
  let progressBar = null;
9001
8894
  function reset() {
9002
8895
  abortRequests();
9003
8896
  queue.reset();
9004
8897
  config.reset();
9005
- cache.reset();
8898
+ cache.evict();
9006
8899
  progressBar === null || progressBar === void 0 ? void 0 : progressBar.destroy();
9007
8900
  progressBar = null;
9008
8901
  }
9009
8902
  function makeRequest(...args) {
9010
8903
  const options = parseRequestOptions(args);
9011
8904
  const request = new up.Request(options);
9012
- processRequest(request);
8905
+ useCachedRequest(request) || queueRequest(request);
9013
8906
  return request;
9014
8907
  }
9015
8908
  function parseRequestOptions(args) {
@@ -9021,30 +8914,31 @@ up.network = (function () {
9021
8914
  (_b = (_a = up.migrate).handleRequestOptions) === null || _b === void 0 ? void 0 : _b.call(_a, options);
9022
8915
  return options;
9023
8916
  }
9024
- function processRequest(request) {
9025
- useCachedRequest(request) || queueRequest(request);
9026
- }
9027
- function useCachedRequest(newRequest) {
8917
+ function useCachedRequest(request) {
9028
8918
  let cachedRequest;
9029
- if (newRequest.willCache() && (cachedRequest = cache.get(newRequest))) {
9030
- up.puts('up.request()', 'Re-using previous request to %s %s', newRequest.method, newRequest.url);
9031
- if (!newRequest.background) {
8919
+ if (request.willCache() && (cachedRequest = cache.get(request))) {
8920
+ up.puts('up.request()', 'Re-using previous request to %s %s', request.method, request.url);
8921
+ if (!request.preload) {
9032
8922
  queue.promoteToForeground(cachedRequest);
9033
8923
  }
9034
- cache.connect(cachedRequest, newRequest, { onIncompatible: processRequest });
8924
+ request.followState(cachedRequest);
8925
+ request.fromCache = true;
9035
8926
  return true;
9036
8927
  }
9037
8928
  }
9038
8929
  function queueRequest(request) {
8930
+ if (request.preload && !request.isSafe()) {
8931
+ up.fail('Will not preload request to %s', request.description);
8932
+ }
9039
8933
  handleCaching(request);
9040
8934
  queue.asap(request);
9041
8935
  return true;
9042
8936
  }
9043
8937
  function handleCaching(request) {
9044
8938
  if (request.willCache()) {
9045
- cache.put(request);
8939
+ cache.set(request, request);
9046
8940
  }
9047
- u.always(request, function (response) {
8941
+ return u.always(request, function (response) {
9048
8942
  var _a, _b, _c, _d;
9049
8943
  let expireCache = (_b = (_a = response.expireCache) !== null && _a !== void 0 ? _a : request.expireCache) !== null && _b !== void 0 ? _b : u.evalOption(config.expireCache, request, response);
9050
8944
  if (expireCache) {
@@ -9055,7 +8949,7 @@ up.network = (function () {
9055
8949
  cache.evict(evictCache, { except: request });
9056
8950
  }
9057
8951
  if (cache.get(request)) {
9058
- cache.put(request);
8952
+ cache.set(request, request);
9059
8953
  }
9060
8954
  if (!response.ok) {
9061
8955
  cache.evict(request);
@@ -9266,7 +9160,6 @@ up.layer = (function () {
9266
9160
  options.baseLayer = stack.get('current', Object.assign(Object.assign({}, options), { normalizeLayerOptions: false }));
9267
9161
  }
9268
9162
  function build(options, beforeNew) {
9269
- var _a;
9270
9163
  const { mode } = options;
9271
9164
  const { Class } = config[mode];
9272
9165
  const configs = u.reverse(modeConfigs(mode));
@@ -9274,7 +9167,6 @@ up.layer = (function () {
9274
9167
  if (handleDeprecatedConfig) {
9275
9168
  configs.forEach(handleDeprecatedConfig);
9276
9169
  }
9277
- (_a = options.openAnimation) !== null && _a !== void 0 ? _a : (options.openAnimation = u.pluckKey(options, 'animation'));
9278
9170
  options = u.mergeDefined(...configs, { mode, stack }, options);
9279
9171
  if (beforeNew) {
9280
9172
  options = beforeNew(options);
@@ -9538,22 +9430,16 @@ up.link = (function () {
9538
9430
  }
9539
9431
  function preload(link, options) {
9540
9432
  link = up.fragment.get(link);
9541
- let issue = preloadIssue(link);
9542
- if (issue) {
9543
- return Promise.reject(new up.Error(issue));
9433
+ if (!shouldPreload()) {
9434
+ return Promise.reject(new up.Error('Link preloading is disabled'));
9544
9435
  }
9545
9436
  const guardEvent = up.event.build('up:link:preload', { log: ['Preloading link %o', link] });
9546
9437
  return follow(link, Object.assign(Object.assign({ abortable: false }, options), { guardEvent, preload: true }));
9547
9438
  }
9548
- function preloadIssue(link) {
9549
- if (!u.evalAutoOption(config.preloadEnabled, autoPreloadEnabled, link)) {
9550
- return 'Preloading is disabled';
9551
- }
9552
- else if (!isSafe(link)) {
9553
- return 'Will not preload an unsafe link';
9554
- }
9439
+ function shouldPreload() {
9440
+ let goodConnection = u.negate(up.network.shouldReduceRequests);
9441
+ return u.evalAutoOption(config.preloadEnabled, goodConnection);
9555
9442
  }
9556
- const autoPreloadEnabled = u.negate(up.network.shouldReduceRequests);
9557
9443
  function followMethod(link, options = {}) {
9558
9444
  return u.normalizeMethod(options.method || link.getAttribute('up-method') || link.getAttribute('data-method'));
9559
9445
  }