aberdeen 1.12.1 → 1.14.0

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 (79) hide show
  1. package/dist/src/aberdeen.d.ts +34 -4
  2. package/dist/src/aberdeen.js +49 -21
  3. package/dist/src/aberdeen.js.map +3 -3
  4. package/dist/tests/fakedom.js +6 -6
  5. package/dist/tests/fakedom.js.map +3 -3
  6. package/dist/tests/helpers.js +6 -6
  7. package/dist/tests/helpers.js.map +3 -3
  8. package/dist-docs/Tutorial/index.html +2 -2
  9. package/dist-docs/aberdeen/A/index.html +2 -2
  10. package/dist-docs/aberdeen/CUSTOM_DUMP/index.html +7 -0
  11. package/dist-docs/aberdeen/NO_COPY/index.html +2 -4
  12. package/dist-docs/aberdeen/OPAQUE/index.html +12 -0
  13. package/dist-docs/aberdeen/PromiseProxy/index.html +5 -5
  14. package/dist-docs/aberdeen/clean/index.html +2 -2
  15. package/dist-docs/aberdeen/clone/index.html +2 -2
  16. package/dist-docs/aberdeen/copy/index.html +3 -3
  17. package/dist-docs/aberdeen/count/index.html +2 -2
  18. package/dist-docs/aberdeen/cssVars/index.html +2 -2
  19. package/dist-docs/aberdeen/darkMode/index.html +2 -2
  20. package/dist-docs/aberdeen/default/index.html +17 -5
  21. package/dist-docs/aberdeen/derive/index.html +2 -2
  22. package/dist-docs/aberdeen/disableCreateDestroy/index.html +2 -2
  23. package/dist-docs/aberdeen/dump/index.html +2 -2
  24. package/dist-docs/aberdeen/index.html +7 -5
  25. package/dist-docs/aberdeen/insertCss/index.html +2 -2
  26. package/dist-docs/aberdeen/insertGlobalCss/index.html +2 -2
  27. package/dist-docs/aberdeen/invertString/index.html +2 -2
  28. package/dist-docs/aberdeen/isEmpty/index.html +2 -2
  29. package/dist-docs/aberdeen/map/index.html +4 -4
  30. package/dist-docs/aberdeen/merge/index.html +3 -3
  31. package/dist-docs/aberdeen/mount/index.html +2 -2
  32. package/dist-docs/aberdeen/multiMap/index.html +4 -4
  33. package/dist-docs/aberdeen/onEach/index.html +2 -2
  34. package/dist-docs/aberdeen/partition/index.html +4 -4
  35. package/dist-docs/aberdeen/peek/index.html +5 -5
  36. package/dist-docs/aberdeen/proxy/index.html +2 -2
  37. package/dist-docs/aberdeen/ref/index.html +2 -2
  38. package/dist-docs/aberdeen/runQueue/index.html +2 -2
  39. package/dist-docs/aberdeen/setErrorHandler/index.html +2 -2
  40. package/dist-docs/aberdeen/setSpacingCssVars/index.html +2 -2
  41. package/dist-docs/aberdeen/unmountAll/index.html +2 -2
  42. package/dist-docs/aberdeen/unproxy/index.html +2 -2
  43. package/dist-docs/assets/aberdeen/aberdeen.d.ts +34 -4
  44. package/dist-docs/assets/aberdeen/aberdeen.js +49 -21
  45. package/dist-docs/assets/aberdeen/aberdeen.js.map +3 -3
  46. package/dist-docs/assets/navigation.js +1 -1
  47. package/dist-docs/assets/search.js +1 -1
  48. package/dist-docs/dispatcher/Dispatcher/index.html +4 -4
  49. package/dist-docs/dispatcher/MATCH_FAILED/index.html +2 -2
  50. package/dist-docs/dispatcher/MATCH_REST/index.html +2 -2
  51. package/dist-docs/dispatcher/index.html +2 -2
  52. package/dist-docs/hierarchy.html +1 -1
  53. package/dist-docs/index.html +2 -2
  54. package/dist-docs/media/CHANGELOG.md +13 -0
  55. package/dist-docs/modules.html +1 -1
  56. package/dist-docs/prediction/applyCanon/index.html +2 -2
  57. package/dist-docs/prediction/applyPrediction/index.html +2 -2
  58. package/dist-docs/prediction/index.html +2 -2
  59. package/dist-docs/route/Route/index.html +9 -9
  60. package/dist-docs/route/back/index.html +2 -2
  61. package/dist-docs/route/current/index.html +2 -2
  62. package/dist-docs/route/go/index.html +2 -2
  63. package/dist-docs/route/index.html +2 -2
  64. package/dist-docs/route/interceptLinks/index.html +2 -2
  65. package/dist-docs/route/persistScroll/index.html +2 -2
  66. package/dist-docs/route/push/index.html +2 -2
  67. package/dist-docs/route/setLog/index.html +2 -2
  68. package/dist-docs/route/up/index.html +2 -2
  69. package/dist-docs/sitemap.xml +64 -56
  70. package/dist-docs/transitions/grow/index.html +2 -2
  71. package/dist-docs/transitions/index.html +2 -2
  72. package/dist-docs/transitions/shrink/index.html +2 -2
  73. package/package.json +13 -13
  74. package/skill/aberdeen.md +123 -60
  75. package/skill/dispatcher.md +6 -6
  76. package/skill/prediction.md +3 -3
  77. package/skill/route.md +17 -17
  78. package/skill/transitions.md +3 -3
  79. package/src/aberdeen.ts +84 -26
@@ -237,11 +237,25 @@ export declare function copy<T extends object>(dst: T, dstKey: keyof T, src: T[t
237
237
  export declare function merge<T extends object>(dst: T, value: Partial<T>): boolean;
238
238
  export declare function merge<T extends object>(dst: T, dstKey: keyof T, value: Partial<T[typeof dstKey]>): boolean;
239
239
  /**
240
- * A symbol that can be added to an object to prevent it from being cloned by {@link clone} or {@link copy}.
241
- * This is useful for objects that should be shared by reference. That also mean that their contents won't
242
- * be observed for changes.
240
+ * A symbol that controls how Aberdeen handles an object in copy operations and proxy wrapping.
241
+ *
242
+ * The **presence** of this symbol (regardless of its value) prevents deep-copying: the object is
243
+ * stored and passed by reference in {@link clone} and {@link copy}.
244
+ *
245
+ * The **value** of the symbol controls proxy wrapping when the object is read from reactive state:
246
+ * - **Truthy** (e.g. `true`): the object is fully opaque — it is not wrapped in a proxy, so its
247
+ * properties are not observable. Use this for objects that break when proxied (e.g. class instances
248
+ * with internal slots, Promises) or that must be invisible to Aberdeen's reactive system.
249
+ * - **Falsy** (e.g. `false`): the object is still wrapped in a proxy, so reads on its properties
250
+ * create reactive dependencies as normal — only deep-copying is suppressed.
251
+ */
252
+ export declare const OPAQUE: unique symbol;
253
+ /**
254
+ * Use {@link OPAQUE} instead. This is an alias kept for backward compatibility.
255
+ *
256
+ * @deprecated
243
257
  */
244
- export declare const NO_COPY: unique symbol;
258
+ export declare const NO_COPY: symbol;
245
259
  /**
246
260
  * A reactive object containing CSS variable definitions.
247
261
  *
@@ -882,6 +896,20 @@ export declare function partition<IN_K extends string | number | symbol, OUT_K e
882
896
  * ```
883
897
  */
884
898
  export declare function dump<T>(data: T): T;
899
+ /**
900
+ * When set on an object or its prototype chain, {@link dump} calls this as a render function
901
+ * (with the object as `this`) instead of its default recursive rendering. When `false` this
902
+ * inhibits `dump` from rendering object properties.
903
+ *
904
+ * @example
905
+ * ```typescript
906
+ * class Color {
907
+ * constructor(public r: number, public g: number, public b: number) {}
908
+ * [CUSTOM_DUMP]() { A(`#rgb(${this.r}, ${this.g}, ${this.b})`); }
909
+ * }
910
+ * ```
911
+ */
912
+ export declare const CUSTOM_DUMP: unique symbol;
885
913
  /**
886
914
  * The main Aberdeen API. `A` is itself a callable function for building reactive DOM trees
887
915
  * (creating elements, setting attributes, adding content). All other Aberdeen functions and
@@ -904,6 +932,7 @@ declare const _default: typeof A & {
904
932
  /** {@inheritDoc copy} */ copy: typeof copy;
905
933
  /** {@inheritDoc count} */ count: typeof count;
906
934
  /** {@inheritDoc cssVars} */ cssVars: Record<string, string>;
935
+ /** {@inheritDoc CUSTOM_DUMP} */ CUSTOM_DUMP: symbol;
907
936
  /** {@inheritDoc darkMode} */ darkMode: typeof darkMode;
908
937
  /** {@inheritDoc derive} */ derive: typeof derive;
909
938
  /** {@inheritDoc disableCreateDestroy} */ disableCreateDestroy: typeof disableCreateDestroy;
@@ -916,6 +945,7 @@ declare const _default: typeof A & {
916
945
  /** {@inheritDoc merge} */ merge: typeof merge;
917
946
  /** {@inheritDoc mount} */ mount: typeof mount;
918
947
  /** {@inheritDoc multiMap} */ multiMap: typeof multiMap;
948
+ /** {@inheritDoc OPAQUE} */ OPAQUE: symbol;
919
949
  /** {@inheritDoc NO_COPY} */ NO_COPY: symbol;
920
950
  /** {@inheritDoc onEach} */ onEach: typeof onEach;
921
951
  /** {@inheritDoc partition} */ partition: typeof partition;
@@ -981,7 +981,7 @@ var setHandler = {
981
981
  };
982
982
  var proxyMap = new WeakMap;
983
983
  function optProxy(value) {
984
- if (typeof value !== "object" || !value || value[TARGET_SYMBOL] !== undefined || NO_COPY in value) {
984
+ if (typeof value !== "object" || !value || value[TARGET_SYMBOL] !== undefined || value[OPAQUE] || value instanceof Date) {
985
985
  return value;
986
986
  }
987
987
  let proxied = proxyMap.get(value);
@@ -1083,7 +1083,7 @@ function copyRecursive(dst, src, flags) {
1083
1083
  changed = true;
1084
1084
  } else if (dstValue !== srcValue) {
1085
1085
  if (typeof srcValue === "object" && srcValue !== null) {
1086
- if (typeof dstValue === "object" && dstValue !== null && srcValue.constructor === dstValue.constructor && !(NO_COPY in srcValue)) {
1086
+ if (typeof dstValue === "object" && dstValue !== null && srcValue.constructor === dstValue.constructor && !(OPAQUE in srcValue)) {
1087
1087
  changed = copyRecursive(dstValue, srcValue, flags) || changed;
1088
1088
  continue;
1089
1089
  }
@@ -1117,7 +1117,7 @@ function copyRecursive(dst, src, flags) {
1117
1117
  dstValue = EMPTY;
1118
1118
  if (dstValue !== srcValue) {
1119
1119
  if (typeof srcValue === "object" && srcValue !== null) {
1120
- if (typeof dstValue === "object" && dstValue !== null && srcValue.constructor === dstValue.constructor && !(NO_COPY in srcValue)) {
1120
+ if (typeof dstValue === "object" && dstValue !== null && srcValue.constructor === dstValue.constructor && !(OPAQUE in srcValue)) {
1121
1121
  changed = copyRecursive(dstValue, srcValue, flags) || changed;
1122
1122
  continue;
1123
1123
  }
@@ -1147,7 +1147,7 @@ function copyRecursive(dst, src, flags) {
1147
1147
  const dstValue = dst.hasOwnProperty(key) ? dst[key] : EMPTY;
1148
1148
  if (dstValue !== srcValue) {
1149
1149
  if (typeof srcValue === "object" && srcValue !== null) {
1150
- if (typeof dstValue === "object" && dstValue !== null && srcValue.constructor === dstValue.constructor && !(NO_COPY in srcValue)) {
1150
+ if (typeof dstValue === "object" && dstValue !== null && srcValue.constructor === dstValue.constructor && !(OPAQUE in srcValue)) {
1151
1151
  changed = copyRecursive(dstValue, srcValue, flags) || changed;
1152
1152
  continue;
1153
1153
  }
@@ -1179,8 +1179,9 @@ function copyRecursive(dst, src, flags) {
1179
1179
  var MERGE = 1;
1180
1180
  var COPY_SUBSCRIBE = 32;
1181
1181
  var COPY_EMIT = 64;
1182
- var NO_COPY = Symbol("NO_COPY");
1183
- Promise.prototype[NO_COPY] = true;
1182
+ var OPAQUE = Symbol("OPAQUE");
1183
+ var NO_COPY = OPAQUE;
1184
+ Promise.prototype[OPAQUE] = true;
1184
1185
  var cssVars = optProxy({});
1185
1186
  function setSpacingCssVars(base = 1, unit = "rem") {
1186
1187
  for (let i = 0;i <= 12; i++) {
@@ -1211,7 +1212,7 @@ function darkMode() {
1211
1212
  return darkModeState.value;
1212
1213
  }
1213
1214
  function cloneRecursive(src, flags) {
1214
- if (NO_COPY in src)
1215
+ if (OPAQUE in src)
1215
1216
  return src;
1216
1217
  if (flags & COPY_SUBSCRIBE)
1217
1218
  subscribe(src, ANY_SYMBOL);
@@ -1732,26 +1733,49 @@ function partition(source, func) {
1732
1733
  return out;
1733
1734
  }
1734
1735
  function dump(data) {
1736
+ const org = dumpSeen;
1737
+ dumpSeen ||= new Set;
1738
+ try {
1739
+ rawDump(data, dumpSeen);
1740
+ } finally {
1741
+ dumpSeen = org;
1742
+ }
1743
+ return data;
1744
+ }
1745
+ var dumpSeen;
1746
+ function rawDump(data, seen) {
1735
1747
  if (data && typeof data === "object") {
1736
- const name = data.constructor.name.toLowerCase() || "unknown object";
1737
- A(`#<${name}>`);
1738
- if (NO_COPY in data) {
1739
- A("# [NO_COPY]");
1740
- } else {
1741
- A("ul", () => {
1742
- onEach(data, (value, key) => {
1743
- A("li", () => {
1748
+ const name = data.constructor.name || "unknown object";
1749
+ if (seen.has(data)) {
1750
+ A(`#<${name}: circular reference>`);
1751
+ return;
1752
+ }
1753
+ seen.add(data);
1754
+ const customDump = data[CUSTOM_DUMP];
1755
+ if (customDump !== undefined) {
1756
+ if (typeof customDump === "function")
1757
+ customDump.call(data, seen);
1758
+ return;
1759
+ }
1760
+ A(`#<${name}>`, "ul", () => {
1761
+ onEach(data, (value, key) => {
1762
+ A("li", () => {
1763
+ if (!(data instanceof Array))
1744
1764
  A(`#${JSON.stringify(key)}: `);
1745
- dump(value);
1746
- });
1765
+ rawDump(value, seen);
1747
1766
  });
1748
1767
  });
1749
- }
1750
- } else if (data !== undefined) {
1768
+ });
1769
+ } else if (data === undefined) {
1770
+ A("#undefined");
1771
+ } else {
1751
1772
  A("#" + JSON.stringify(data));
1752
1773
  }
1753
- return data;
1754
1774
  }
1775
+ var CUSTOM_DUMP = Symbol("CUSTOM_DUMP");
1776
+ Date.prototype[CUSTOM_DUMP] = function() {
1777
+ A("#<Date> " + this.toISOString());
1778
+ };
1755
1779
  function internalError(code) {
1756
1780
  throw new Error(`Aberdeen internal error ${code}`);
1757
1781
  }
@@ -1809,6 +1833,7 @@ var aberdeen_default = Object.assign(A, {
1809
1833
  copy,
1810
1834
  count,
1811
1835
  cssVars,
1836
+ CUSTOM_DUMP,
1812
1837
  darkMode,
1813
1838
  derive,
1814
1839
  disableCreateDestroy,
@@ -1821,6 +1846,7 @@ var aberdeen_default = Object.assign(A, {
1821
1846
  merge,
1822
1847
  mount,
1823
1848
  multiMap,
1849
+ OPAQUE,
1824
1850
  NO_COPY,
1825
1851
  onEach,
1826
1852
  partition,
@@ -1865,11 +1891,13 @@ export {
1865
1891
  copy,
1866
1892
  clone,
1867
1893
  clean,
1894
+ OPAQUE,
1868
1895
  NO_COPY,
1869
1896
  MAP_SIZE_SYMBOL,
1870
1897
  EMPTY,
1898
+ CUSTOM_DUMP,
1871
1899
  A
1872
1900
  };
1873
1901
 
1874
- //# debugId=C25FF24CC098C9BC64756E2164756E21
1902
+ //# debugId=34A0CA77D4CA212064756E2164756E21
1875
1903
  //# sourceMappingURL=aberdeen.js.map