@pacem/pacem-core 2.0.0-goldbach → 2.0.0-hadamard

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 (40) hide show
  1. package/dist/browser/pacem-core.js +308 -89
  2. package/dist/browser/pacem-core.js.map +1 -1
  3. package/dist/browser/pacem-core.min.js +2 -2
  4. package/dist/bundle/pacem-core.min.mjs +5 -5
  5. package/dist/bundle/pacem-core.mjs +193 -67
  6. package/dist/bundle/pacem-core.mjs.map +3 -3
  7. package/dist/docs/pacem-core.json +54 -24
  8. package/dist/esm/adapter.js +1 -1
  9. package/dist/esm/binding-parser.js +3 -3
  10. package/dist/esm/command.js +1 -1
  11. package/dist/esm/comparers.js +1 -1
  12. package/dist/esm/converters.js +1 -1
  13. package/dist/esm/decorators-next.js +1 -1
  14. package/dist/esm/decorators.js +1 -1
  15. package/dist/esm/defaults.js +1 -1
  16. package/dist/esm/events.js +1 -1
  17. package/dist/esm/eventtarget.js +1 -1
  18. package/dist/esm/expression.js +1 -1
  19. package/dist/esm/index-animations.js +1 -1
  20. package/dist/esm/index-behaviors.js +1 -1
  21. package/dist/esm/index-components.js +1 -1
  22. package/dist/esm/index-iife.js +1 -1
  23. package/dist/esm/index-logging.js +1 -1
  24. package/dist/esm/index-net.js +1 -1
  25. package/dist/esm/index-root.js +1 -1
  26. package/dist/esm/index-ui.js +1 -1
  27. package/dist/esm/index.js +1 -1
  28. package/dist/esm/logger.js +1 -1
  29. package/dist/esm/prefix.js +1 -1
  30. package/dist/esm/promise.js +1 -1
  31. package/dist/esm/regex.js +1 -1
  32. package/dist/esm/storage.js +1 -1
  33. package/dist/esm/template.js +1 -1
  34. package/dist/esm/transforms.js +1 -1
  35. package/dist/esm/types.js +1 -1
  36. package/dist/esm/utils-customelement.js +1 -1
  37. package/dist/esm/utils-customevent.js +1 -1
  38. package/dist/esm/utils.js +2 -2
  39. package/package.json +1 -1
  40. package/typings/index.d.ts +114 -20
@@ -1375,7 +1375,11 @@ declare class PacemBodyProxyElement extends PacemTransferProxyElement {
1375
1375
  protected get proxy(): HTMLElement;
1376
1376
  }
1377
1377
 
1378
- /** Wraps a {@link BroadcastChannel}, sending/receiving messages to/from other same-origin browsing contexts. */
1378
+ /**
1379
+ * Wraps a {@link BroadcastChannel}, sending/receiving messages to/from other same-origin browsing contexts.
1380
+ * @fires receive {@link CustomEvent} - when a message arrives from another channel of the same name: `detail` is the message (also in `result`).
1381
+ * @fires error {@link CustomEvent} - when an arrived message couldn't be deserialized.
1382
+ */
1379
1383
  declare class PacemBroadcastChannelProxyElement extends PacemEventTarget {
1380
1384
  #private;
1381
1385
  /** Gets or sets the message to be sent through the channel. */
@@ -1465,21 +1469,40 @@ declare abstract class PacemCrossItemsContainerElement<TItem extends PacemItemEl
1465
1469
  unregister(item: TItem): boolean;
1466
1470
  }
1467
1471
 
1468
- /** Holds an arbitrary data model, optionally persisting it to local storage and debouncing/throttling change notifications. */
1472
+ /**
1473
+ * Holds an arbitrary data model, optionally persisting it to local storage and debouncing/throttling change notifications.
1474
+ * @fires propertychange {@link PropertyChangeEvent} - when `model` changes (debounced or throttled as set by `debounce` and `throttle`).
1475
+ */
1469
1476
  declare class PacemDataElement extends PacemEventTarget {
1470
1477
  private storage;
1471
1478
  constructor(storage?: Storage_2);
1472
- /** Gets or sets the data model held by this element. */
1479
+ /** Gets or sets the data model held by this element. As an attribute, it gets evaluated as a JavaScript expression (`"0"`, `"[1, 2]"`, `"{ a: 1 }"`). */
1473
1480
  model: any;
1474
- /** Gets or sets the storage key under which `model` is persisted. */
1481
+ /** Gets or sets the storage key under which `model` is persisted (local storage): restored on load, removed when the key changes. */
1475
1482
  persistAs: string;
1476
- /** Debounces the model change */
1477
- debounce: number;
1478
- /** Throttles the model change if debounce is > 0 */
1483
+ /**
1484
+ * Gets or sets how the model change notifications get debounced: a number of milliseconds, `true` (once per
1485
+ * animation frame), or `false`/`0` (right away, the default).
1486
+ */
1487
+ debounce: number | boolean;
1488
+ /** Gets or sets whether the notifications get throttled rather than debounced (the first change of each `debounce` window is notified, the others are dropped). */
1479
1489
  throttle: boolean;
1480
- private _handle;
1481
- private _flag;
1490
+ /** Cancels the pending (debounced) notification, if any. */
1491
+ private _cancelPending;
1492
+ /** Whether a throttling window is open (changes are dropped meanwhile). */
1493
+ private _throttling;
1482
1494
  propertyChangedCallback(name: string, old: any, val: any, first?: boolean): void;
1495
+ /** Notifies a model change: right away, debounced or throttled (see {@link debounce} and {@link throttle}). */
1496
+ private _notifyModelChange;
1497
+ /** Notifies the first change of a window, and drops the others until the window closes. */
1498
+ private _throttle;
1499
+ /**
1500
+ * Runs a callback on the next animation frame, or after a delay.
1501
+ * @returns A function cancelling it.
1502
+ */
1503
+ private _schedule;
1504
+ /** Persists the model under {@link persistAs}, if set (a `null` model removes it). */
1505
+ private _persist;
1483
1506
  }
1484
1507
 
1485
1508
  /** @deprecated */
@@ -1502,6 +1525,13 @@ declare class PacemDockElement extends PacemEventTarget {
1502
1525
  /**
1503
1526
  * Pacem Drag & Drop element adapter: implements {@link DragDropper} on top of {@link PacemBehavior} to make
1504
1527
  * registered elements draggable and, optionally, sortable/droppable onto {@link dropTargets}.
1528
+ * @fires draginit {@link DragDropEvent} - on press, before anything moves: cancelable (`preventDefault()` refuses the drag).
1529
+ * @fires dragstart {@link DragDropEvent} - when the drag actually starts (the press lasted `lockTimeout`).
1530
+ * @fires drag {@link DragDropEvent} - on every move: cancelable.
1531
+ * @fires dragover {@link DragDropEvent} - when hovering one of the `dropTargets`: cancelable (`preventDefault()` refuses that target).
1532
+ * @fires dragout {@link DragDropEvent} - when leaving a drop target.
1533
+ * @fires drop {@link DragDropEvent} - on release over a drop target: `detail.target` is the target, `detail.element` the dragged element.
1534
+ * @fires dragend {@link DragDropEvent} - when it's all over (dropped or not).
1505
1535
  */
1506
1536
  declare class PacemDragDropElement extends PacemBehavior implements DragDropper {
1507
1537
  private _startHandler;
@@ -1575,7 +1605,10 @@ declare class PacemElementProxyElement extends PacemTransferProxyElement {
1575
1605
  propertyChangedCallback(name: string, old: any, val: any, first?: boolean): void;
1576
1606
  }
1577
1607
 
1578
- /** Listens for an arbitrary DOM event on a `target` element (or `window`) and re-dispatches it as its own `emit` event. */
1608
+ /**
1609
+ * Listens for an arbitrary DOM event on a `target` element (or `window`) and re-dispatches it as its own `emit` event.
1610
+ * @fires emit {@link Event} - for every `event` caught on `target`: the caught one is `originalEvent`.
1611
+ */
1579
1612
  declare class PacemEventProxyElement extends PacemEventTarget {
1580
1613
  /** Gets or sets the element (or `window`, via the special `"$window"` value) to listen on. */
1581
1614
  target: HTMLElement | Window;
@@ -1652,7 +1685,12 @@ export declare abstract class PacemEventTarget extends HTMLElement implements No
1652
1685
  protected refreshBindings(): void;
1653
1686
  }
1654
1687
 
1655
- /** Declarative wrapper around the `fetch()` API, debouncing/aborting requests as its properties change and exposing the parsed `result`. */
1688
+ /**
1689
+ * Declarative wrapper around the `fetch()` API, debouncing/aborting requests as its properties change and exposing the parsed `result`.
1690
+ * @fires success {@link CustomEvent} - when a response is OK (2xx), before its body gets parsed: `detail` is the `Response`.
1691
+ * @fires fetchresult {@link CustomEvent} - when the body got parsed (as set by `as`): `detail` is the new `result`.
1692
+ * @fires error {@link CustomEvent} - when a response is not OK: `detail` is the `Response` (network failures reject `fetch()` instead).
1693
+ */
1656
1694
  declare class PacemFetchElement extends PacemEventTarget implements Fetcher {
1657
1695
  #private;
1658
1696
  /** Gets or sets the request URL, optionally templated (e.g. `/api/{id}`) against `parameters`. */
@@ -1683,7 +1721,7 @@ declare class PacemFetchElement extends PacemEventTarget implements Fetcher {
1683
1721
  type: 'json' | 'raw';
1684
1722
  /** Gets or sets the debounce delay (in milliseconds) applied before auto-triggered fetches (default `100`). */
1685
1723
  debounce: number;
1686
- /** Gets or sets whether to throttle (rather than debounce) auto-triggered fetches. */
1724
+ /** Gets or sets whether a fetch requested while another one is in flight is skipped (it gets the ongoing request) rather than aborting it (default false). */
1687
1725
  throttle: boolean;
1688
1726
  /** Gets or sets whether to compare parameter and header single values prior to trigger a new fetch execution (default false). */
1689
1727
  diffByValues: boolean;
@@ -1699,7 +1737,13 @@ declare class PacemFetchElement extends PacemEventTarget implements Fetcher {
1699
1737
  private _acceptFetchResult;
1700
1738
  }
1701
1739
 
1702
- /** Keeps track of an undo/redo-capable history of an arbitrary state. */
1740
+ /**
1741
+ * Keeps track of an undo/redo-capable history of an arbitrary state.
1742
+ * @fires push {@link StateEvent} - when a new state got recorded: `detail` has `state`, `canUndo` and `canRedo`.
1743
+ * @fires undo {@link StateEvent} - after a step back.
1744
+ * @fires redo {@link StateEvent} - after a step forward.
1745
+ * @fires reset {@link StateEvent} - when the history got cleared (the current state stays).
1746
+ */
1703
1747
  declare class PacemHistoryElement extends PacemEventTarget {
1704
1748
  #private;
1705
1749
  /** Gets or sets the current state; assigning a new value pushes it onto the history stack. */
@@ -1826,7 +1870,10 @@ declare class PacemNumberAnimationElement extends TweenAnimationElement<number>
1826
1870
  protected tweenInterpolationCallback(time: number, progress: number): number;
1827
1871
  }
1828
1872
 
1829
- /** Tracks the browser's network connectivity (`navigator.onLine`), updating `online` on `online`/`offline` events. */
1873
+ /**
1874
+ * Tracks the browser's network connectivity (`navigator.onLine`), updating `online` on `online`/`offline` events.
1875
+ * @fires propertychange {@link PropertyChangeEvent} - when `online` changes (the connection dropped or came back).
1876
+ */
1830
1877
  declare class PacemOnlineStatusElement extends PacemEventTarget {
1831
1878
  /** @readonly Gets whether the browser currently reports itself as online. */
1832
1879
  online: boolean;
@@ -1852,6 +1899,10 @@ declare class PacemPointAnimationElement extends TweenAnimationElement<Point> {
1852
1899
 
1853
1900
  /**
1854
1901
  * Repeats its `<template>` content once per `datasource` item, keeping the rendered items in sync as the datasource changes.
1902
+ * @fires repeateritemcreate {@link RepeaterItemCreateEvent} - when an item got rendered (and is in the DOM): `detail` has its `index`, `item` and `dom`.
1903
+ * @fires repeateritemremove {@link RepeaterItemRemoveEvent} - when an item got removed (the datasource shrank).
1904
+ * @fires itemcommand {@link CustomEvent} - when an element of an item dispatches a command (e.g. a `<pacem-button command-name>`): `detail` has `commandName` and `commandArgument`.
1905
+ * @fires item{command} {@link CustomEvent} - right after `itemcommand`, named after the command (e.g. `itemdelete` for `command-name="delete"`): `detail` is the `commandArgument`.
1855
1906
  * @example
1856
1907
  * <pacem-repeater datasource="[{id:'first', items:['a','b','c']}, ...]">
1857
1908
  * <ol>
@@ -1894,6 +1945,11 @@ declare class PacemRepeaterElement extends PacemEventTarget implements Repeater
1894
1945
  /**
1895
1946
  * Pacem Rescale element adapter: implements {@link Rescaler} on top of {@link PacemBehavior}, decorating
1896
1947
  * registered elements with draggable resize handles (see {@link RescaleHandle}).
1948
+ * A move beyond the size constraints (`minWidth`, `maxWidth`, `minHeight`, `maxHeight`) is clamped to them; with
1949
+ * `keepProportions`, such a move is ignored instead (clamping one side would break the ratio).
1950
+ * @fires rescalestart {@link RescaleEvent} - when a handle gets grabbed: `detail.handle` tells which.
1951
+ * @fires rescale {@link RescaleEvent} - on every move: `detail.targetRect` is the size about to be applied; cancelable (`preventDefault()` applies nothing, e.g. to apply it your way).
1952
+ * @fires rescaleend {@link RescaleEvent} - when the handle gets released: `detail.targetRect` is the final size.
1897
1953
  */
1898
1954
  declare class PacemRescaleElement extends PacemBehavior implements Rescaler {
1899
1955
  /** Adds the resize-handle frame (see {@link RescaleHandle}) around the given element. */
@@ -1951,6 +2007,9 @@ declare class PacemResizeElement extends PacemEventTarget {
1951
2007
  /**
1952
2008
  * Pacem Rotate element adapter: implements {@link Rotator} on top of {@link PacemBehavior} to make
1953
2009
  * registered elements rotatable around a pivot point via mouse/touch drag.
2010
+ * @fires rotatestart {@link RotateEvent} - on press: cancelable (`preventDefault()` refuses the gesture).
2011
+ * @fires rotate {@link RotateEvent} - whenever the (stepped) angle changes: `detail.rotation`, in radians; cancelable (nothing gets rendered).
2012
+ * @fires rotateend {@link RotateEvent} - on release: `detail.rotation` is the final angle.
1954
2013
  */
1955
2014
  declare class PacemRotateElement extends PacemBehavior implements Rotator {
1956
2015
  /** Wires up the `mousedown`/`touchstart` listeners that arm the rotate gesture on the given element. */
@@ -1968,7 +2027,12 @@ declare class PacemRotateElement extends PacemBehavior implements Rotator {
1968
2027
  private _startHandler;
1969
2028
  }
1970
2029
 
1971
- /** Client-side router: parses/generates paths against a template and drives the browser History API. */
2030
+ /**
2031
+ * Client-side router: parses/generates paths against a template and drives the browser History API.
2032
+ * @fires propertychange {@link PropertyChangeEvent} - when `state` changes (every committed navigation).
2033
+ * @fires navigating {@link RouterNavigatingEvent} - on `window`, right before a navigation: cancelable (`preventDefault()` aborts it), `detail` is the target path.
2034
+ * @fires navigate {@link RouterNavigateEvent} - on `window`, once a navigation is committed: `detail` has `path`, `referrer` and `title`.
2035
+ */
1972
2036
  declare class PacemRouterElement extends PacemEventTarget {
1973
2037
  #private;
1974
2038
  /** Gets or sets the route template, e.g. `/{controller}/{action}/{id?}`. */
@@ -2011,9 +2075,11 @@ declare class PacemRouterElement extends PacemEventTarget {
2011
2075
  private _parseState;
2012
2076
  }
2013
2077
 
2014
- /** {@link PacemContentElement} variant that strips out `<script>` blocks (and, for `Node` content, `<script>` elements) before rendering `content`. */
2078
+ /**
2079
+ * {@link PacemContentElement} variant that renders `content` without what could run script: `<script>` elements,
2080
+ * `on*` event-handler attributes and `javascript:` URLs get removed (HTML strings are parsed, never executed, first).
2081
+ */
2015
2082
  declare class PacemSafeContentElement extends PacemContentElement {
2016
- private _sanitizeLegacy;
2017
2083
  protected sanitize(html: string | Node): string | Node;
2018
2084
  }
2019
2085
 
@@ -2030,7 +2096,13 @@ declare class PacemScrollAwareElement extends PacemEventTarget {
2030
2096
  };
2031
2097
  }
2032
2098
 
2033
- /** Registers a service worker and manages its (optional) Push API subscription. */
2099
+ /**
2100
+ * Registers a service worker and manages its (optional) Push API subscription.
2101
+ * @fires register {@link CustomEvent} - once the service worker got registered: `detail` is the `ServiceWorkerRegistration`.
2102
+ * @fires unregister {@link CustomEvent} - when a previous registration got replaced: `detail` is the old one.
2103
+ * @fires subscribe {@link CustomEvent} - when a push subscription is in place (found at start, or just made): `detail` is the `PushSubscription`.
2104
+ * @fires unsubscribe {@link CustomEvent} - when the push subscription went away: `detail` is the old `PushSubscription`.
2105
+ */
2034
2106
  declare class PacemServiceWorkerProxyElement extends PacemEventTarget {
2035
2107
  /** @readonly Gets the active service worker registration, once available. */
2036
2108
  registration: ServiceWorkerRegistration;
@@ -2053,6 +2125,8 @@ declare class PacemServiceWorkerProxyElement extends PacemEventTarget {
2053
2125
  /**
2054
2126
  * Subscribes to push notifications through the registered service worker.
2055
2127
  * @param publicKey VAPID public key (base64url or raw bytes); defaults to `publicKey`
2128
+ * @returns The subscription (`null` without a push manager, or when notifications are denied); rejects when the
2129
+ * browser refuses to subscribe (no push service, an invalid key…).
2056
2130
  */
2057
2131
  subscribe(publicKey?: string | Uint8Array<ArrayBuffer>): Promise<PushSubscription>;
2058
2132
  }
@@ -2062,7 +2136,10 @@ declare class PacemShellProxyElement extends PacemTransferProxyElement {
2062
2136
  protected get proxy(): HTMLElement;
2063
2137
  }
2064
2138
 
2065
- /** Listens for a keyboard shortcut (optionally chorded, e.g. `"ctrl+k, s"`) on a target and fires an `execute` event when matched. */
2139
+ /**
2140
+ * Listens for a keyboard shortcut (optionally chorded, e.g. `"ctrl+k, s"`) on a target and fires an `execute` event when matched.
2141
+ * @fires execute {@link Event} - when the whole combination got typed (the matching key's default action is prevented).
2142
+ */
2066
2143
  declare class PacemShortcutElement extends PacemEventTarget {
2067
2144
  /** Gets or sets the key combination to listen for (e.g. `"ctrl+s"`, or a comma-separated sequence like `"ctrl+k, s"`). */
2068
2145
  combination: string;
@@ -2132,6 +2209,11 @@ declare class PacemStyleProxyElement extends PacemEventTarget {
2132
2209
  /**
2133
2210
  * Pacem Swipe element adapter: implements {@link Swiper} on top of {@link PacemBehavior} to make
2134
2211
  * registered elements draggable along one axis, with snap points and fling/bounce-back detection.
2212
+ * @fires pan {@link SwipeEvent} - while the element follows the pointer: cancelable.
2213
+ * @fires swipe {@link SwipeEvent} - on release, once a swipe is detected (dragged past a snap, or flung): cancelable (stops the chain).
2214
+ * @fires swipe{direction} {@link SwipeEvent} - right after `swipe`, named after the direction (`swipeleft`, `swiperight`, `swipeup`, `swipedown`): cancelable.
2215
+ * @fires swipeanimationend {@link SwipeEvent} - when the element reached its snap: cancelable (`preventDefault()` keeps it there instead of returning).
2216
+ * @fires swipe{direction}animationend {@link SwipeEvent} - right after `swipeanimationend`, named after the direction.
2135
2217
  */
2136
2218
  declare class PacemSwipeElement extends PacemBehavior implements Swiper {
2137
2219
  #private;
@@ -2247,7 +2329,11 @@ declare class PacemViewportAwareElement extends PacemEventTarget {
2247
2329
  disconnectedCallback(): void;
2248
2330
  }
2249
2331
 
2250
- /** Wraps a {@link Worker}, sending/receiving messages to/from a web worker script. */
2332
+ /**
2333
+ * Wraps a {@link Worker}, sending/receiving messages to/from a web worker script.
2334
+ * @fires receive {@link CustomEvent} - when the worker posts a message back: `detail` is the message (also in `result`).
2335
+ * @fires error {@link CustomEvent} - when the worker script fails: `detail` is the error, when the browser can pass it over.
2336
+ */
2251
2337
  declare class PacemWebWorkerProxyElement extends PacemEventTarget {
2252
2338
  /** Gets or sets the message to be posted to the worker. */
2253
2339
  message: any;
@@ -2835,6 +2921,8 @@ declare type SwipeEventArgs = {
2835
2921
  position: Point;
2836
2922
  };
2837
2923
  vertical?: boolean;
2924
+ /** The snap the element is going to rest at (known on release; `0` = back home). */
2925
+ snap?: number;
2838
2926
  };
2839
2927
 
2840
2928
  /**
@@ -2857,6 +2945,12 @@ declare class SwipeEventArgsClass {
2857
2945
  get predictedDuration(): number;
2858
2946
  /** @readonly Gets the element being swiped. */
2859
2947
  get element(): HTMLElement | SVGElement;
2948
+ /**
2949
+ * @readonly Gets the snap the element is going to rest at, relative to where the gesture started: `0` means it
2950
+ * bounces back home (the release didn't make it). Known on release (`swipe`, `swipe<direction>` and the
2951
+ * animation-end events); `undefined` while panning.
2952
+ */
2953
+ get snap(): number | undefined;
2860
2954
  /** Builds a new {@link SwipeEventArgsClass} out of a plain {@link SwipeEventArgs} builder. */
2861
2955
  static fromArgs(builder: SwipeEventArgs): SwipeEventArgsClass;
2862
2956
  }