@pacem/pacem 1.0.6-peano → 1.0.6-ricci

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.
Files changed (36) hide show
  1. package/dist/browser/pacem-2d.js +1 -1
  2. package/dist/browser/pacem-2d.min.js +1 -1
  3. package/dist/browser/pacem-3d.js +1 -1
  4. package/dist/browser/pacem-3d.min.js +1 -1
  5. package/dist/browser/pacem-charts.js +1 -1
  6. package/dist/browser/pacem-charts.min.js +1 -1
  7. package/dist/browser/pacem-cms.js +1 -1
  8. package/dist/browser/pacem-cms.min.js +1 -1
  9. package/dist/browser/pacem-core.js +72 -37
  10. package/dist/browser/pacem-core.js.map +1 -1
  11. package/dist/browser/pacem-core.min.js +2 -2
  12. package/dist/browser/pacem-foundation.js +1 -1
  13. package/dist/browser/pacem-foundation.min.js +1 -1
  14. package/dist/browser/pacem-fx.js +1 -1
  15. package/dist/browser/pacem-fx.min.js +1 -1
  16. package/dist/browser/pacem-logging.js +1 -1
  17. package/dist/browser/pacem-logging.min.js +1 -1
  18. package/dist/browser/pacem-maps.js +1 -1
  19. package/dist/browser/pacem-maps.min.js +1 -1
  20. package/dist/browser/pacem-media.js +1 -1
  21. package/dist/browser/pacem-media.min.js +1 -1
  22. package/dist/browser/pacem-networking.js +1 -1
  23. package/dist/browser/pacem-networking.min.js +1 -1
  24. package/dist/browser/pacem-numerical.js +1 -1
  25. package/dist/browser/pacem-numerical.min.js +1 -1
  26. package/dist/browser/pacem-plus.js +1 -1
  27. package/dist/browser/pacem-plus.min.js +1 -1
  28. package/dist/browser/pacem-scaffolding.js +1 -1
  29. package/dist/browser/pacem-scaffolding.min.js +1 -1
  30. package/dist/browser/pacem-ui.js +1 -1
  31. package/dist/browser/pacem-ui.min.js +1 -1
  32. package/dist/bundle/pacem.min.mjs +80 -80
  33. package/dist/bundle/pacem.mjs +68 -37
  34. package/dist/bundle/pacem.mjs.map +2 -2
  35. package/dist/typings/index.d.ts +3 -1
  36. package/package.json +1 -1
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @pacem/pacem v1.0.6-peano (https://js.pacem.it)
2
+ * @pacem/pacem v1.0.6-ricci (https://js.pacem.it)
3
3
  * Pacem (https://pacem.it)
4
4
  * Licensed under Apache-2.0
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @pacem/pacem v1.0.6-peano (https://js.pacem.it)
2
+ * @pacem/pacem v1.0.6-ricci (https://js.pacem.it)
3
3
  * Pacem (https://pacem.it)
4
4
  * Licensed under Apache-2.0
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @pacem/pacem v1.0.6-peano (https://js.pacem.it)
2
+ * @pacem/pacem v1.0.6-ricci (https://js.pacem.it)
3
3
  * Pacem (https://pacem.it)
4
4
  * Licensed under Apache-2.0
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @pacem/pacem v1.0.6-peano (https://js.pacem.it)
2
+ * @pacem/pacem v1.0.6-ricci (https://js.pacem.it)
3
3
  * Pacem (https://pacem.it)
4
4
  * Licensed under Apache-2.0
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @pacem/pacem v1.0.6-peano (https://js.pacem.it)
2
+ * @pacem/pacem v1.0.6-ricci (https://js.pacem.it)
3
3
  * Pacem (https://pacem.it)
4
4
  * Licensed under Apache-2.0
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @pacem/pacem v1.0.6-peano (https://js.pacem.it)
2
+ * @pacem/pacem v1.0.6-ricci (https://js.pacem.it)
3
3
  * Pacem (https://pacem.it)
4
4
  * Licensed under Apache-2.0
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @pacem/pacem v1.0.6-peano (https://js.pacem.it)
2
+ * @pacem/pacem v1.0.6-ricci (https://js.pacem.it)
3
3
  * Pacem (https://pacem.it)
4
4
  * Licensed under Apache-2.0
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @pacem/pacem v1.0.6-peano (https://js.pacem.it)
2
+ * @pacem/pacem v1.0.6-ricci (https://js.pacem.it)
3
3
  * Pacem (https://pacem.it)
4
4
  * Licensed under Apache-2.0
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @pacem/pacem v1.0.6-peano (https://js.pacem.it)
2
+ * @pacem/pacem v1.0.6-ricci (https://js.pacem.it)
3
3
  * Pacem (https://pacem.it)
4
4
  * Licensed under Apache-2.0
5
5
  */
@@ -2761,11 +2761,19 @@
2761
2761
  const FetchErrorEventName = 'error';
2762
2762
  /** Event name dispatched when a {@link Fetcher}'s request completes successfully. */
2763
2763
  const FetchSuccessEventName = 'success';
2764
+ const RESPONSEEMPTY_FLAG = 'pacem:net:response:empty';
2764
2765
  /** Static helpers for working with fetch `Response`s. */
2765
2766
  class Fetcher {
2767
+ /** @internal */
2768
+ static markAsEmpty(r) {
2769
+ CustomElementUtils.setAttachedPropertyValue(r, RESPONSEEMPTY_FLAG, true);
2770
+ }
2766
2771
  /** Tests whether a response carries no body (HTTP 204, or an explicit `Content-Length: 0`). */
2767
2772
  static isEmpty(r) {
2768
- return r.status === 204 || r.headers.get("Content-Length") === "0";
2773
+ if (r.status === 204 || r.headers.get("Content-Length") === "0") {
2774
+ return true;
2775
+ }
2776
+ return CustomElementUtils.getAttachedPropertyValue(r, RESPONSEEMPTY_FLAG) ?? false;
2769
2777
  }
2770
2778
  }
2771
2779
  //}
@@ -6116,55 +6124,82 @@
6116
6124
  this.#aborter = null;
6117
6125
  _me.fetching = false;
6118
6126
  if (r.ok) {
6119
- this.dispatchEvent(new CustomEvent(FetchSuccessEventName, { detail: r }));
6120
- const empty = Fetcher.isEmpty(r);
6121
- if (empty) {
6122
- switch (_me.as) {
6123
- case 'blob':
6124
- case 'image':
6125
- _me.result = null;
6126
- break;
6127
- case 'text':
6128
- _me.result = null;
6129
- break;
6130
- default:
6131
- _me.result = null;
6132
- break;
6133
- }
6134
- resolve(r);
6127
+ // utility functions
6128
+ const dispatchSuccess = () => {
6129
+ this.dispatchEvent(new CustomEvent(FetchSuccessEventName, { detail: r }));
6130
+ };
6131
+ const markResponseAsEmpty = () => {
6132
+ Fetcher.markAsEmpty(r);
6133
+ };
6134
+ const setResultToNull = () => {
6135
+ _me.result = null;
6136
+ };
6137
+ const definitelyEmpty = // response not mark(ed)AsEmpty yet (i.e. body not used yet). If it's empty here, then it's definitely empty, like: announced-empty!
6138
+ Fetcher.isEmpty(r);
6139
+ if (definitelyEmpty) {
6140
+ // fire right-away
6141
+ dispatchSuccess();
6142
+ setResultToNull();
6143
+ resolve(r /* body still unused */);
6135
6144
  }
6136
6145
  else {
6146
+ // might be empty in case of - for instance - IIS configured to not issue Content-Length headers even in case of empty (yet successful) responses.
6137
6147
  switch (_me.as) {
6138
6148
  case 'blob':
6139
6149
  case 'image':
6140
6150
  r.blob().then(b => {
6141
- if (_me.as === 'image') {
6142
- Utils.blobToDataURL(b).then(i => {
6143
- _me._acceptFetchResult(i);
6144
- });
6151
+ if (b.size === 0) {
6152
+ markResponseAsEmpty();
6153
+ dispatchSuccess();
6154
+ setResultToNull();
6145
6155
  }
6146
6156
  else {
6147
- _me._acceptFetchResult(b);
6157
+ dispatchSuccess();
6158
+ if (_me.as === 'image') {
6159
+ Utils.blobToDataURL(b).then(i => {
6160
+ _me._acceptFetchResult(i);
6161
+ });
6162
+ }
6163
+ else {
6164
+ _me._acceptFetchResult(b);
6165
+ }
6148
6166
  }
6167
+ }, e => {
6168
+ // success still waiting to be fired (we're in the response.ok context)
6169
+ dispatchSuccess();
6170
+ this.log(LogLevel.Warn, `Couldn't parse as ${_me.as}. ${e}`);
6171
+ }).finally(() => {
6149
6172
  resolve(r);
6150
- }, _ => {
6151
- this.log(LogLevel.Warn, `Couldn't parse a ${_me.as}. ${_}`);
6152
- resolve(null);
6153
6173
  });
6154
6174
  break;
6155
- case 'text':
6175
+ default: // text, object
6156
6176
  r.text().then(t => {
6157
- _me._acceptFetchResult(t);
6158
- resolve(r);
6159
- });
6160
- break;
6161
- default:
6162
- r.json().then(j => {
6163
- _me._acceptFetchResult(j);
6177
+ const empty = Utils.isNullOrEmpty(t.trim());
6178
+ if (empty) {
6179
+ markResponseAsEmpty();
6180
+ dispatchSuccess();
6181
+ setResultToNull();
6182
+ return;
6183
+ }
6184
+ // non-empty branch
6185
+ dispatchSuccess();
6186
+ if (_me.as === 'text') {
6187
+ _me._acceptFetchResult(t);
6188
+ }
6189
+ else {
6190
+ try {
6191
+ _me._acceptFetchResult(JSON.parse(t));
6192
+ }
6193
+ catch (e1) {
6194
+ this.log(LogLevel.Warn, `Couldn't parse as ${_me.as}. ${e1}`);
6195
+ }
6196
+ }
6197
+ }, e0 => {
6198
+ // success still waiting to be fired (we're in the response.ok context)
6199
+ dispatchSuccess();
6200
+ this.log(LogLevel.Warn, `Couldn't parse as ${_me.as}. ${e0}`);
6201
+ }).finally(() => {
6164
6202
  resolve(r);
6165
- }, _ => {
6166
- this.log(LogLevel.Warn, `Couldn't parse a ${_me.as}. ${_}`);
6167
- resolve(null);
6168
6203
  });
6169
6204
  break;
6170
6205
  }