@pacem/pacem-core 1.0.0-bessel → 1.0.0-dirac
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.
- package/dist/browser/pacem-core.js +870 -9
- package/dist/browser/pacem-core.js.map +1 -1
- package/dist/browser/pacem-core.min.js +2 -2
- package/dist/bundle/pacem-core.min.mjs +6 -6
- package/dist/bundle/pacem-core.mjs +467 -1
- package/dist/bundle/pacem-core.mjs.map +2 -2
- package/dist/docs/pacem-core.json +40109 -0
- package/dist/esm/adapter.js +2 -1
- package/dist/esm/command.js +6 -1
- package/dist/esm/comparers.js +1 -1
- package/dist/esm/converters.js +6 -1
- package/dist/esm/decorators-next.js +1 -1
- package/dist/esm/decorators.js +94 -1
- package/dist/esm/defaults.js +2 -1
- package/dist/esm/events.js +41 -1
- package/dist/esm/eventtarget.js +11 -1
- package/dist/esm/expression.js +37 -1
- package/dist/esm/index-animations.js +1 -1
- package/dist/esm/index-behaviors.js +1 -1
- package/dist/esm/index-components.js +1 -1
- package/dist/esm/index-iife.js +1 -1
- package/dist/esm/index-logging.js +1 -1
- package/dist/esm/index-net.js +1 -1
- package/dist/esm/index-root.js +1 -1
- package/dist/esm/index-ui.js +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/logger.js +8 -1
- package/dist/esm/prefix.js +2 -1
- package/dist/esm/promise.js +11 -1
- package/dist/esm/regex.js +3 -1
- package/dist/esm/storage.js +14 -1
- package/dist/esm/template.js +2 -1
- package/dist/esm/transforms.js +53 -1
- package/dist/esm/types.js +6 -1
- package/dist/esm/utils-customelement.js +165 -6
- package/dist/esm/utils-customevent.js +27 -1
- package/dist/esm/utils.js +89 -1
- package/package.json +2 -1
- package/typings/index.d.ts +1089 -10
package/dist/esm/adapter.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @pacem/pacem-core v1.0.0-
|
|
2
|
+
* @pacem/pacem-core v1.0.0-dirac (https://js.pacem.it)
|
|
3
3
|
* Pacem (https://pacem.it)
|
|
4
4
|
* Licensed under Apache-2.0
|
|
5
5
|
*/
|
|
6
6
|
import { CustomTypedEvent } from './events';
|
|
7
|
+
/** Dispatched by an {@link Iterative} container whenever its `index` changes. */
|
|
7
8
|
export class CurrentIndexChangeEvent extends CustomTypedEvent {
|
|
8
9
|
constructor(args) {
|
|
9
10
|
super('currentindexchange', args);
|
package/dist/esm/command.js
CHANGED
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @pacem/pacem-core v1.0.0-
|
|
2
|
+
* @pacem/pacem-core v1.0.0-dirac (https://js.pacem.it)
|
|
3
3
|
* Pacem (https://pacem.it)
|
|
4
4
|
* Licensed under Apache-2.0
|
|
5
5
|
*/
|
|
6
6
|
/// <reference path="events.ts" />
|
|
7
7
|
import { CustomTypedEvent } from './events';
|
|
8
8
|
//namespace Pacem {
|
|
9
|
+
/** Event name dispatched to signal a generic, named command invocation; see {@link CommandEvent}. */
|
|
9
10
|
export const CommandEventName = 'command';
|
|
11
|
+
/**
|
|
12
|
+
* Bubbling, cancelable event representing a generic UI command (e.g. a button's `command`/`command-argument`
|
|
13
|
+
* attributes), letting ancestor elements handle named actions without wiring a dedicated listener per command.
|
|
14
|
+
*/
|
|
10
15
|
export class CommandEvent extends CustomTypedEvent {
|
|
11
16
|
constructor(args) {
|
|
12
17
|
super(CommandEventName, args, { bubbles: true, cancelable: true });
|
package/dist/esm/comparers.js
CHANGED
package/dist/esm/converters.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @pacem/pacem-core v1.0.0-
|
|
2
|
+
* @pacem/pacem-core v1.0.0-dirac (https://js.pacem.it)
|
|
3
3
|
* Pacem (https://pacem.it)
|
|
4
4
|
* Licensed under Apache-2.0
|
|
5
5
|
*/
|
|
@@ -55,6 +55,11 @@ const RectPropertyConverter = {
|
|
|
55
55
|
convert: (attr) => Rect.parse(attr),
|
|
56
56
|
convertBack: (prop) => `${prop.x || 0} ${prop.y || 0} ${prop.width || 0} ${prop.height || 0}`
|
|
57
57
|
};
|
|
58
|
+
/**
|
|
59
|
+
* Built-in {@link PropertyConverter} implementations, keyed by the type they convert to/from. Passed as
|
|
60
|
+
* the `converter` option of a {@link Watch}-decorated property (e.g. `@Watch({ converter: PropertyConverters.Number })`)
|
|
61
|
+
* to control how that property's attribute string is parsed and, on change, reflected back.
|
|
62
|
+
*/
|
|
58
63
|
export const PropertyConverters /*: { [name: string]: PropertyConverter }*/ = {
|
|
59
64
|
None: NonePropertyConverter,
|
|
60
65
|
String: StringPropertyConverter,
|
package/dist/esm/decorators.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @pacem/pacem-core v1.0.0-
|
|
2
|
+
* @pacem/pacem-core v1.0.0-dirac (https://js.pacem.it)
|
|
3
3
|
* Pacem (https://pacem.it)
|
|
4
4
|
* Licensed under Apache-2.0
|
|
5
5
|
*/
|
|
@@ -133,6 +133,31 @@ function retrieveDescendantTemplateActivationPromises(host, root) {
|
|
|
133
133
|
}
|
|
134
134
|
return promises;
|
|
135
135
|
}
|
|
136
|
+
/**
|
|
137
|
+
* Class decorator that turns a class extending `HTMLElement` (typically {@link PacemEventTarget}) into a
|
|
138
|
+
* fully-fledged Pacem custom element: it registers the tag with the custom elements registry and wraps
|
|
139
|
+
* the standard `connectedCallback`/`disconnectedCallback`/`attributeChangedCallback`/`propertyChangedCallback`
|
|
140
|
+
* lifecycle hooks (calling through to any hooks already defined on the class) so that:
|
|
141
|
+
*
|
|
142
|
+
* - `observedAttributes` is computed automatically from the class's {@link Watch}-decorated properties
|
|
143
|
+
* (in kebab-case), merged with any statically-declared `observedAttributes`.
|
|
144
|
+
* - On first connection, `config.template`/`config.templateUrl` (if provided) is fetched, parsed and
|
|
145
|
+
* injected — into a Shadow Root when `config.shadow` is `true`, otherwise as light-DOM children,
|
|
146
|
+
* splicing any pre-existing light-DOM content into a `<pacem-content>` placeholder if present.
|
|
147
|
+
* - Attribute changes are converted to property values via each watched property's {@link PropertyConverter},
|
|
148
|
+
* and dispatched as an {@link AttributeChangeEvent}.
|
|
149
|
+
* - Property changes are dispatched as a {@link PropertyChangeEvent} (unless the property's `@Watch`
|
|
150
|
+
* config sets `emit: false`) and, when `reflectBack` is enabled, written back onto the corresponding
|
|
151
|
+
* attribute via the converter's `convertBack`.
|
|
152
|
+
* - Binding expression attributes (`{{ ... }}`) are parsed and kept live: dependent properties are
|
|
153
|
+
* re-evaluated whenever one of the expression's upstream properties fires a {@link PropertyChangeEvent}.
|
|
154
|
+
* - Once the template (and all descendant templated custom elements) have finished rendering, the
|
|
155
|
+
* `cloak` attribute is removed and `viewActivatedCallback` fires — this is the right place for logic
|
|
156
|
+
* that depends on the element's full DOM (light or shadow) being in place.
|
|
157
|
+
*
|
|
158
|
+
* @param config Tag name, optional native `customElements.define` options, and optional template/templateUrl/shadow settings.
|
|
159
|
+
* @returns A class decorator to apply to the custom element's class declaration.
|
|
160
|
+
*/
|
|
136
161
|
export const CustomElement = (config) => {
|
|
137
162
|
return (target) => {
|
|
138
163
|
// might be already registered
|
|
@@ -471,6 +496,27 @@ export const CustomElement = (config) => {
|
|
|
471
496
|
// #endregion
|
|
472
497
|
// #region WATCH PROPERTIES
|
|
473
498
|
const DefaultPropertyConverter = PropertyConverters.None;
|
|
499
|
+
/**
|
|
500
|
+
* Property decorator that turns a plain class field (or accessor) into a Pacem "watched" property:
|
|
501
|
+
* a property whose changes are detected (via reference/value comparison, see {@link DefaultComparer}),
|
|
502
|
+
* optionally converted from/to its corresponding attribute string via a {@link PropertyConverter}
|
|
503
|
+
* (see {@link PropertyConverters}), and notified through `propertyChangedCallback` plus a
|
|
504
|
+
* {@link PropertyChangeEvent} (unless `config.emit` is `false`).
|
|
505
|
+
*
|
|
506
|
+
* Must be paired with the {@link CustomElement} class decorator, which is what actually reads the list
|
|
507
|
+
* of watched properties (via `WATCH_PROPS_VAR`) to compute `observedAttributes` and wire up attribute/
|
|
508
|
+
* property change plumbing — `@Watch` alone, on a class not decorated with `@CustomElement`, only sets
|
|
509
|
+
* up the getter/setter and change notification, with no attribute involvement.
|
|
510
|
+
*
|
|
511
|
+
* Array-valued properties are additionally instrumented: their mutating methods (`push`, `pop`, `splice`,
|
|
512
|
+
* `shift`, `unshift`, `copyWithin`) are patched so in-place mutations also trigger a change notification.
|
|
513
|
+
*
|
|
514
|
+
* @param config Optional behavior: `converter` (attribute↔property conversion, default `PropertyConverters.None`),
|
|
515
|
+
* `emit` (whether to dispatch a {@link PropertyChangeEvent}, default `true`), `debounce` (delay the
|
|
516
|
+
* change notification, either by a fixed number of milliseconds or `true` for one animation frame),
|
|
517
|
+
* and `reflectBack` (write the property value back onto the attribute on change, default `false`).
|
|
518
|
+
* @returns A property decorator to apply to the watched field/accessor.
|
|
519
|
+
*/
|
|
474
520
|
export function Watch(config) {
|
|
475
521
|
return (target, prop, descriptor) => {
|
|
476
522
|
var watchableProperties = GET_VAL(target.constructor, WATCH_PROPS_VAR, []);
|
|
@@ -591,6 +637,17 @@ export function Watch(config) {
|
|
|
591
637
|
}
|
|
592
638
|
};
|
|
593
639
|
}
|
|
640
|
+
/**
|
|
641
|
+
* Property decorator that turns a class field into a lazily-resolved, cached reference to a descendant
|
|
642
|
+
* element matching `selector`. Resolution happens on first read (via `shadowRoot.querySelectorAll` when
|
|
643
|
+
* available, falling back to the element itself), and only nodes whose `INSTANCE_HOST_VAR` points back
|
|
644
|
+
* at `this` are considered — this keeps the lookup scoped to the current element's own template output,
|
|
645
|
+
* skipping over descendants that belong to a nested custom element's own template. The cache is reset
|
|
646
|
+
* whenever the host element reconnects to the DOM (`connectedCallback`, see the {@link CustomElement} decorator).
|
|
647
|
+
*
|
|
648
|
+
* @param selector CSS selector identifying the child element to bind to.
|
|
649
|
+
* @returns A property decorator to apply to the view-child field (read-only; no setter is defined).
|
|
650
|
+
*/
|
|
594
651
|
export function ViewChild(selector) {
|
|
595
652
|
return (target, prop, descriptor) => {
|
|
596
653
|
const key = `${prop}_${Utils.uniqueCode()}`;
|
|
@@ -623,6 +680,15 @@ export function ViewChild(selector) {
|
|
|
623
680
|
}
|
|
624
681
|
// #endregion
|
|
625
682
|
// #region CONCURRENT/DEBOUNCE EXECUTION
|
|
683
|
+
/**
|
|
684
|
+
* Method decorator that serializes calls to an async (promise-returning) method on a per-instance basis:
|
|
685
|
+
* while an invocation is in flight, further calls are queued (their arguments buffered) instead of running
|
|
686
|
+
* concurrently, and each queued call gets its own promise that resolves/rejects once it eventually runs.
|
|
687
|
+
* Once the in-flight call settles, the oldest buffered call (if any) is dequeued and executed next.
|
|
688
|
+
* Methods that don't return a promise-like value are simply invoked synchronously with no queuing.
|
|
689
|
+
*
|
|
690
|
+
* @returns A method decorator to apply to an async instance method.
|
|
691
|
+
*/
|
|
626
692
|
export function Concurrent() {
|
|
627
693
|
function isPromiseLike(obj) {
|
|
628
694
|
return obj && typeof obj.then === 'function';
|
|
@@ -673,6 +739,15 @@ export function Concurrent() {
|
|
|
673
739
|
};
|
|
674
740
|
};
|
|
675
741
|
}
|
|
742
|
+
/**
|
|
743
|
+
* Method decorator that debounces calls to an instance method: repeated calls within the debounce window
|
|
744
|
+
* cancel the previously scheduled invocation and reschedule it, so only the last call in a rapid burst
|
|
745
|
+
* actually runs (with its own arguments), after the window elapses.
|
|
746
|
+
*
|
|
747
|
+
* @param msecs Debounce delay in milliseconds, or `true` to debounce to the next animation frame (`requestAnimationFrame`) instead of a fixed delay. Defaults to `50`.
|
|
748
|
+
* @param keyFactory Computes the per-instance timer key from the method name and call arguments; override to scope debouncing per argument (e.g. debounce separately per id) instead of per method. Defaults to a single shared key per method.
|
|
749
|
+
* @returns A method decorator to apply to the instance method to debounce.
|
|
750
|
+
*/
|
|
676
751
|
export function Debounce(msecs = 50, keyFactory = (key, ...args) => `pacem:debouncer:${key}`) {
|
|
677
752
|
return function (target /* type, actually */, key, descriptor) {
|
|
678
753
|
const originalMethod = descriptor.value;
|
|
@@ -698,6 +773,16 @@ export function Debounce(msecs = 50, keyFactory = (key, ...args) => `pacem:debou
|
|
|
698
773
|
}
|
|
699
774
|
};
|
|
700
775
|
}
|
|
776
|
+
/**
|
|
777
|
+
* Method decorator that throttles calls to an instance method: the first call in a window runs immediately;
|
|
778
|
+
* further calls arriving before the window elapses are not dropped but coalesced — only the most recent
|
|
779
|
+
* set of arguments is remembered and, once the window elapses, one trailing call runs with those arguments
|
|
780
|
+
* (mirroring a classic "leading + trailing" throttle).
|
|
781
|
+
*
|
|
782
|
+
* @param msecs Throttle window in milliseconds, or `true` to use a single animation frame (`requestAnimationFrame`) as the window. Defaults to `50`.
|
|
783
|
+
* @param keyFactory Computes the per-instance timer key from the method name and call arguments; override to scope throttling per argument instead of per method. Defaults to a single shared key per method.
|
|
784
|
+
* @returns A method decorator to apply to the instance method to throttle.
|
|
785
|
+
*/
|
|
701
786
|
export function Throttle(msecs = 50, keyFactory = (key, ...args) => `pacem:throttler:${key}`) {
|
|
702
787
|
return function (target /* type, actually */, key, descriptor) {
|
|
703
788
|
const originalMethod = descriptor.value;
|
|
@@ -747,6 +832,14 @@ class Transforms {
|
|
|
747
832
|
}
|
|
748
833
|
}
|
|
749
834
|
}
|
|
835
|
+
/**
|
|
836
|
+
* Method decorator that registers a static/instance method as a globally-named {@link TransformFunction},
|
|
837
|
+
* making it callable by name from template binding expressions (e.g. `{{ ^value | myTransform }}`).
|
|
838
|
+
* The registration is global (attached under `Utils.core`, dot-segmented by `name`), not per-instance.
|
|
839
|
+
*
|
|
840
|
+
* @param name Dot-separated registration path (e.g. `'strings.upper'`); segments before the last create/reuse nested namespaces under `Utils.core`. Defaults to the decorated method's own name when omitted.
|
|
841
|
+
* @returns A method decorator to apply to the transform function.
|
|
842
|
+
*/
|
|
750
843
|
export function Transformer(name) {
|
|
751
844
|
return function (target, key, descriptor) {
|
|
752
845
|
const method = descriptor.value;
|
package/dist/esm/defaults.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @pacem/pacem-core v1.0.0-
|
|
2
|
+
* @pacem/pacem-core v1.0.0-dirac (https://js.pacem.it)
|
|
3
3
|
* Pacem (https://pacem.it)
|
|
4
4
|
* Licensed under Apache-2.0
|
|
5
5
|
*/
|
|
6
6
|
//namespace Pacem {
|
|
7
|
+
/** Framework-wide default settings. */
|
|
7
8
|
export const Defaults = {
|
|
8
9
|
USE_SHADOW_ROOT: /*'attachShadow' in Element.prototype &&*/ false /* <- wait until html-imports */
|
|
9
10
|
};
|
package/dist/esm/events.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @pacem/pacem-core v1.0.0-
|
|
2
|
+
* @pacem/pacem-core v1.0.0-dirac (https://js.pacem.it)
|
|
3
3
|
* Pacem (https://pacem.it)
|
|
4
4
|
* Licensed under Apache-2.0
|
|
5
5
|
*/
|
|
@@ -7,7 +7,17 @@
|
|
|
7
7
|
import { Utils } from './utils';
|
|
8
8
|
import { CustomEventUtils } from './utils-customevent';
|
|
9
9
|
// namespace Pacem {
|
|
10
|
+
/**
|
|
11
|
+
* Base class for framework custom events whose `detail` payload is strongly typed as `TDetail`.
|
|
12
|
+
* Thin wrapper around the native `CustomEvent<TDetail>` that also works around an old Edge bug
|
|
13
|
+
* (see {@link CustomEventUtils.fixEdgeCustomEventSubClassInstance}) affecting `CustomEvent` subclasses.
|
|
14
|
+
*/
|
|
10
15
|
export class CustomTypedEvent extends CustomEvent /* new in TypeScript v2.7.1 -> */ {
|
|
16
|
+
/**
|
|
17
|
+
* @param type Event name.
|
|
18
|
+
* @param detail Strongly-typed payload, exposed as `event.detail`.
|
|
19
|
+
* @param eventInit Standard `CustomEvent` initialization options (`bubbles`, `cancelable`, `composed`).
|
|
20
|
+
*/
|
|
11
21
|
constructor(type, detail, eventInit) {
|
|
12
22
|
super(type, Utils.extend({ detail: detail }, eventInit || {}));
|
|
13
23
|
CustomEventUtils.fixEdgeCustomEventSubClassInstance(this, this.constructor);
|
|
@@ -26,7 +36,20 @@ function isEventInit(obj) {
|
|
|
26
36
|
return false;
|
|
27
37
|
}
|
|
28
38
|
// TODO: make inherit from CustomTypedEvent
|
|
39
|
+
/**
|
|
40
|
+
* Base class for UI-originated custom events: like {@link CustomTypedEvent}, but additionally captures
|
|
41
|
+
* the mouse/touch/keyboard modifiers and coordinates of the originating native event (when supplied),
|
|
42
|
+
* exposing them through the {@link UIEventLike} surface (`which`, `altKey`, `pageX`, `clientY`, ...).
|
|
43
|
+
* Useful for events that are re-dispatched/synthesized (e.g. drag & drop) from an original pointer or
|
|
44
|
+
* keyboard event, so that consumers can still inspect that original event's modifiers/position.
|
|
45
|
+
*/
|
|
29
46
|
export class CustomUIEvent extends CustomEvent {
|
|
47
|
+
/**
|
|
48
|
+
* @param type Event name.
|
|
49
|
+
* @param detail Either the strongly-typed payload, or (when it satisfies `CustomEventInit`, i.e. has a `detail` key) the full event-init object.
|
|
50
|
+
* @param eventInit Either standard `CustomEvent` init options, or the original native event this custom event derives from (in which case its coordinates/modifiers get captured).
|
|
51
|
+
* @param orig The original native mouse/touch/keyboard event this custom event derives from, when `eventInit` is itself the init options.
|
|
52
|
+
*/
|
|
30
53
|
constructor(type, detail, eventInit, orig) {
|
|
31
54
|
super(type, Utils.extend((isEventInit(detail || {}) ? detail : { detail: detail }), (!(eventInit instanceof Event) && eventInit) || {}));
|
|
32
55
|
const originalEvent = orig || eventInit;
|
|
@@ -79,27 +102,44 @@ export class CustomUIEvent extends CustomEvent {
|
|
|
79
102
|
return this.#coords?.screen.y;
|
|
80
103
|
}
|
|
81
104
|
}
|
|
105
|
+
/** Event name dispatched whenever an observed attribute changes; see {@link AttributeChangeEvent}. */
|
|
82
106
|
export const AttributeChangeEventName = 'attributechange';
|
|
107
|
+
/**
|
|
108
|
+
* Dispatched by elements registered with the {@link CustomElement} decorator whenever one of their
|
|
109
|
+
* observed attributes changes, mirroring the native `attributeChangedCallback` as a DOM event.
|
|
110
|
+
*/
|
|
83
111
|
export class AttributeChangeEvent extends CustomTypedEvent {
|
|
84
112
|
constructor(args) {
|
|
85
113
|
super(AttributeChangeEventName, args);
|
|
86
114
|
}
|
|
87
115
|
}
|
|
116
|
+
/** Event name dispatched whenever a `@Watch`-decorated property changes value; see {@link PropertyChangeEvent}. */
|
|
88
117
|
export const PropertyChangeEventName = 'propertychange';
|
|
118
|
+
/**
|
|
119
|
+
* Dispatched whenever a property decorated with {@link Watch} changes value (unless that decorator's
|
|
120
|
+
* `emit` option is set to `false`). This is the mechanism data-bound expressions listen to in order to
|
|
121
|
+
* re-evaluate themselves when one of their dependencies changes.
|
|
122
|
+
*/
|
|
89
123
|
export class PropertyChangeEvent extends CustomTypedEvent {
|
|
90
124
|
constructor(args) {
|
|
91
125
|
super(PropertyChangeEventName, args);
|
|
92
126
|
}
|
|
93
127
|
}
|
|
94
128
|
// #region NAVIGATING
|
|
129
|
+
/** Event name dispatched by a router *before* a navigation is committed; see {@link RouterNavigatingEvent}. Cancelable: calling `preventDefault()` aborts the navigation. */
|
|
95
130
|
export const RouterNavigatingEventName = 'navigating';
|
|
131
|
+
/** Event name dispatched by a router *after* a navigation has been committed; see {@link RouterNavigateEvent}. */
|
|
96
132
|
export const RouterNavigateEventName = 'navigate';
|
|
133
|
+
/** Dispatched by a router once it has navigated to a new `path` (not cancelable — the navigation already happened). */
|
|
97
134
|
export class RouterNavigateEvent extends CustomTypedEvent {
|
|
135
|
+
/** @param path Either the destination path alone, or the full navigation args (path, title, referrer). */
|
|
98
136
|
constructor(path) {
|
|
99
137
|
super(RouterNavigateEventName, typeof path === 'string' ? { path } : path, { cancelable: false, bubbles: false });
|
|
100
138
|
}
|
|
101
139
|
}
|
|
140
|
+
/** Dispatched by a router right before navigating to `path`; cancelable, so a listener can call `preventDefault()` to abort the navigation. */
|
|
102
141
|
export class RouterNavigatingEvent extends CustomTypedEvent {
|
|
142
|
+
/** @param path Destination path about to be navigated to. */
|
|
103
143
|
constructor(path) {
|
|
104
144
|
super(RouterNavigatingEventName, path, { cancelable: true, bubbles: false });
|
|
105
145
|
}
|
package/dist/esm/eventtarget.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @pacem/pacem-core v1.0.0-
|
|
2
|
+
* @pacem/pacem-core v1.0.0-dirac (https://js.pacem.it)
|
|
3
3
|
* Pacem (https://pacem.it)
|
|
4
4
|
* Licensed under Apache-2.0
|
|
5
5
|
*/
|
|
@@ -20,6 +20,16 @@ import { CustomElementUtils } from './utils-customelement';
|
|
|
20
20
|
import { Watch } from './decorators';
|
|
21
21
|
import { PropertyConverters } from './converters';
|
|
22
22
|
//namespace Pacem.Components {
|
|
23
|
+
/**
|
|
24
|
+
* Base class for (almost) every Pacem custom element. Extends `HTMLElement` with the framework's
|
|
25
|
+
* common lifecycle/event plumbing: `on-{event-type}` attribute handlers (see {@link emit}), a
|
|
26
|
+
* {@link disabled} property that suppresses both outgoing (`dispatchEvent`) and incoming
|
|
27
|
+
* (`emitHandler`) events, an optional {@link logger} sink, and an {@link isReady} flag toggled once
|
|
28
|
+
* `viewActivatedCallback` has fired (see the {@link CustomElement} decorator for when that happens).
|
|
29
|
+
* Concrete elements are expected to be decorated with `@CustomElement` and typically override
|
|
30
|
+
* `propertyChangedCallback`/`viewActivatedCallback`/`connectedCallback`/`disconnectedCallback`,
|
|
31
|
+
* calling `super.xxxCallback()` first/last as documented on each.
|
|
32
|
+
*/
|
|
23
33
|
export class PacemEventTarget extends HTMLElement {
|
|
24
34
|
constructor() {
|
|
25
35
|
super();
|
package/dist/esm/expression.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @pacem/pacem-core v1.0.0-
|
|
2
|
+
* @pacem/pacem-core v1.0.0-dirac (https://js.pacem.it)
|
|
3
3
|
* Pacem (https://pacem.it)
|
|
4
4
|
* Licensed under Apache-2.0
|
|
5
5
|
*/
|
|
@@ -45,32 +45,53 @@ const variablePattern = /(^|[\s\(\[\+\-\*\/!])(:host\.|\^+item[\s\.,;\)\]]|\^+it
|
|
|
45
45
|
// * ...
|
|
46
46
|
// */
|
|
47
47
|
//const purePropertyPathPattern = /^[\w\.\$]+/;
|
|
48
|
+
/**
|
|
49
|
+
* A parsed, compiled binding expression (the content of a `{{ ... }}` attribute value). Parsing
|
|
50
|
+
* (see {@link parse}) rewrites special tokens found in the source text - `:host.`, `^item`/`^^item`/...,
|
|
51
|
+
* `^index`/`^^index`/..., `#id`, `::hostProp` - into references resolvable at evaluation time, and
|
|
52
|
+
* records each of them as a {@link PropertyDependency} so the owning element can be notified (via
|
|
53
|
+
* {@link PropertyChangeEvent}) and re-evaluate the expression whenever a dependency changes - this is
|
|
54
|
+
* what powers the two-way/live data binding wired up by the {@link CustomElement} decorator.
|
|
55
|
+
* Expressions with no dependencies are flagged `independent` (effectively a constant) and can be
|
|
56
|
+
* evaluated immediately without waiting for the DOM/scope to be ready.
|
|
57
|
+
*/
|
|
48
58
|
export class Expression {
|
|
49
59
|
constructor() {
|
|
50
60
|
this._pending = false;
|
|
51
61
|
this._independent = false;
|
|
52
62
|
}
|
|
63
|
+
/** The resolved property dependencies (element + property + path) this expression re-evaluates on change. Empty for {@link independent} expressions. */
|
|
53
64
|
get dependencies() {
|
|
54
65
|
return this._dependencies;
|
|
55
66
|
}
|
|
67
|
+
/** The compiled function body used by {@link evaluate}/{@link evaluateAsync} (a `return <expr>;` statement, guarded by a try/catch). */
|
|
56
68
|
get functionBody() {
|
|
57
69
|
return this._fnBody;
|
|
58
70
|
}
|
|
71
|
+
/** The compiled function body used by {@link evaluatePlus} (a bare, non-`return`ing statement, guarded by a try/catch) - suited for expressions run for their side effects, e.g. `on-*` event handlers. */
|
|
59
72
|
get voidBody() {
|
|
60
73
|
return this._voidBody;
|
|
61
74
|
}
|
|
75
|
+
/**
|
|
76
|
+
* `true` when this expression couldn't be resolved against a scope yet (the element wasn't connected
|
|
77
|
+
* to a document/shadow-root at parse time) - a shared, inert placeholder singleton returned by
|
|
78
|
+
* {@link parse} in that case; evaluating it is a no-op. Callers should re-parse once the element is ready.
|
|
79
|
+
*/
|
|
62
80
|
get pending() {
|
|
63
81
|
return this._pending;
|
|
64
82
|
}
|
|
83
|
+
/** `true` when the expression has no dependencies (a constant) and can be evaluated immediately, without a resolved scope. */
|
|
65
84
|
get independent() {
|
|
66
85
|
return this._independent;
|
|
67
86
|
}
|
|
87
|
+
/** Evaluates the expression and returns its result, swallowing any runtime error (returning `undefined`). */
|
|
68
88
|
evaluate() {
|
|
69
89
|
if (!this._fn) {
|
|
70
90
|
this._fn = new Function('$pacem', CONTEXT_PREFIX, this._fnBody);
|
|
71
91
|
}
|
|
72
92
|
return this._fn.apply(null, [Utils.core, this._args]);
|
|
73
93
|
}
|
|
94
|
+
/** Promise-wrapped variant of {@link evaluate} (resolves synchronously with the same result - kept for call-site uniformity with genuinely async evaluation paths). */
|
|
74
95
|
evaluateAsync() {
|
|
75
96
|
const deferred = DeferPromise.defer();
|
|
76
97
|
if (!this._fn) {
|
|
@@ -79,6 +100,12 @@ export class Expression {
|
|
|
79
100
|
deferred.resolve(this._fn.apply(null, [Utils.core, this._args]));
|
|
80
101
|
return deferred.promise;
|
|
81
102
|
}
|
|
103
|
+
/**
|
|
104
|
+
* Executes the expression for its side effects (using {@link voidBody}, so no value is returned),
|
|
105
|
+
* with extra named variables merged into scope alongside the expression's own dependencies -
|
|
106
|
+
* used to expose e.g. `$event` to `on-*` event handler expressions.
|
|
107
|
+
* @param args Extra name/value pairs made available to the expression, in addition to its resolved dependencies.
|
|
108
|
+
*/
|
|
82
109
|
evaluatePlus(args = {}) {
|
|
83
110
|
if (!this._fn) {
|
|
84
111
|
let argNames = [CONTEXT_PREFIX];
|
|
@@ -103,6 +130,15 @@ export class Expression {
|
|
|
103
130
|
}
|
|
104
131
|
return Expression._pendingExpression;
|
|
105
132
|
}
|
|
133
|
+
/**
|
|
134
|
+
* Parses a binding expression's source text (the bare content of a `{{ ... }}` attribute, without the
|
|
135
|
+
* delimiters - see {@link CustomElementUtils.extractBindingAttributeExpression}) into an {@link Expression},
|
|
136
|
+
* resolving its special tokens against `element`'s scope (see {@link CustomElementUtils.findScopeContext}).
|
|
137
|
+
* Throws if the expression matches the unsafe-code guard (`new`, `window.`, `document.`, `eval(`).
|
|
138
|
+
* @param expression Bare expression source text.
|
|
139
|
+
* @param element Element the expression is bound to; provides the scope special tokens (`:host.`, `#id`, `^item`, ...) resolve against.
|
|
140
|
+
* @returns A constant expression if it has no dependencies; a shared pending placeholder if `element` isn't attached to a scope yet; otherwise a fully resolved expression.
|
|
141
|
+
*/
|
|
106
142
|
static parse(expression, element) {
|
|
107
143
|
var context = CustomElementUtils.findScopeContext(element);
|
|
108
144
|
var args = { '$this': element };
|
package/dist/esm/index-iife.js
CHANGED
package/dist/esm/index-net.js
CHANGED
package/dist/esm/index-root.js
CHANGED
package/dist/esm/index-ui.js
CHANGED
package/dist/esm/index.js
CHANGED
package/dist/esm/logger.js
CHANGED
|
@@ -1,16 +1,23 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @pacem/pacem-core v1.0.0-
|
|
2
|
+
* @pacem/pacem-core v1.0.0-dirac (https://js.pacem.it)
|
|
3
3
|
* Pacem (https://pacem.it)
|
|
4
4
|
* Licensed under Apache-2.0
|
|
5
5
|
*/
|
|
6
6
|
//namespace Pacem.Logging {
|
|
7
|
+
/** Severity levels accepted by {@link Logger.log}, and used by {@link PacemEventTarget.log}. */
|
|
7
8
|
export var LogLevel;
|
|
8
9
|
(function (LogLevel) {
|
|
10
|
+
/** Fine-grained diagnostic detail. */
|
|
9
11
|
LogLevel["Trace"] = "trace";
|
|
12
|
+
/** Development-time diagnostic detail. */
|
|
10
13
|
LogLevel["Debug"] = "debug";
|
|
14
|
+
/** Recoverable but noteworthy condition. */
|
|
11
15
|
LogLevel["Warn"] = "warn";
|
|
16
|
+
/** Unrecoverable or unexpected failure. */
|
|
12
17
|
LogLevel["Error"] = "error";
|
|
18
|
+
/** General informational message. */
|
|
13
19
|
LogLevel["Info"] = "info";
|
|
20
|
+
/** Generic/default-severity message. */
|
|
14
21
|
LogLevel["Log"] = "log";
|
|
15
22
|
})(LogLevel || (LogLevel = {}));
|
|
16
23
|
//}
|
package/dist/esm/prefix.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @pacem/pacem-core v1.0.0-
|
|
2
|
+
* @pacem/pacem-core v1.0.0-dirac (https://js.pacem.it)
|
|
3
3
|
* Pacem (https://pacem.it)
|
|
4
4
|
* Licensed under Apache-2.0
|
|
5
5
|
*/
|
|
@@ -7,5 +7,6 @@
|
|
|
7
7
|
var root;
|
|
8
8
|
/** the overall customelement prefix */
|
|
9
9
|
export const P = (root = window['Pacem'])?.Configuration?.prefix ?? 'pacem';
|
|
10
|
+
/** The prefix used for CSS custom properties and classes (e.g. `--{PCSS}-font-main`); configurable independently of the element tag prefix {@link P} via `window.Pacem.Configuration.css`, defaults to {@link P}. */
|
|
10
11
|
export const PCSS = root?.Configuration?.css ?? P;
|
|
11
12
|
//}
|
package/dist/esm/promise.js
CHANGED
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @pacem/pacem-core v1.0.0-
|
|
2
|
+
* @pacem/pacem-core v1.0.0-dirac (https://js.pacem.it)
|
|
3
3
|
* Pacem (https://pacem.it)
|
|
4
4
|
* Licensed under Apache-2.0
|
|
5
5
|
*/
|
|
6
6
|
//namespace Pacem {
|
|
7
|
+
/**
|
|
8
|
+
* A `PromiseLike<T>` whose resolution is externalized: unlike a plain `Promise`, the executor isn't
|
|
9
|
+
* passed a callback up front - instead, `resolve`/`reject` are exposed for the caller to invoke later,
|
|
10
|
+
* via the {@link defer} static factory. Useful when the completion of an operation is driven by code
|
|
11
|
+
* that doesn't naturally live inside a `Promise` executor (e.g. event callbacks, decorator plumbing).
|
|
12
|
+
*/
|
|
7
13
|
export class DeferPromise {
|
|
8
14
|
constructor() {
|
|
9
15
|
this.deferred = null;
|
|
@@ -12,6 +18,7 @@ export class DeferPromise {
|
|
|
12
18
|
me.deferred = { 'resolve': resolve, 'reject': reject, 'promise': me };
|
|
13
19
|
});
|
|
14
20
|
}
|
|
21
|
+
/** Standard `PromiseLike.then`, delegating to the underlying native `Promise`. */
|
|
15
22
|
then(onCompleted, onFailed) {
|
|
16
23
|
return this.promise.then(onCompleted, onFailed);
|
|
17
24
|
}
|
|
@@ -23,14 +30,17 @@ export class DeferPromise {
|
|
|
23
30
|
this.promise.then(callback, callback);
|
|
24
31
|
return this;
|
|
25
32
|
}
|
|
33
|
+
/** Registers a fulfillment-only callback (fluent, chainable alternative to `then(callback)`). */
|
|
26
34
|
success(callback) {
|
|
27
35
|
this.promise.then(callback, null);
|
|
28
36
|
return this;
|
|
29
37
|
}
|
|
38
|
+
/** Registers a rejection-only callback (fluent, chainable alternative to `then(null, callback)`). */
|
|
30
39
|
error(callback) {
|
|
31
40
|
this.promise.then(null, callback);
|
|
32
41
|
return this;
|
|
33
42
|
}
|
|
43
|
+
/** Creates a new deferred promise and returns its controller: `{ resolve, reject, promise }`. */
|
|
34
44
|
static defer() {
|
|
35
45
|
var q = new DeferPromise();
|
|
36
46
|
return q.deferred;
|
package/dist/esm/regex.js
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @pacem/pacem-core v1.0.0-
|
|
2
|
+
* @pacem/pacem-core v1.0.0-dirac (https://js.pacem.it)
|
|
3
3
|
* Pacem (https://pacem.it)
|
|
4
4
|
* Licensed under Apache-2.0
|
|
5
5
|
*/
|
|
6
6
|
//namespace Pacem.RegularExpressions {
|
|
7
|
+
/** A pattern that can never match any string (`/a^/`); useful as a safe no-op default for optional matcher parameters. */
|
|
7
8
|
export const EMPTY_MATCHER = /a^/;
|
|
9
|
+
/** Static regular-expression helpers. */
|
|
8
10
|
export class Regex {
|
|
9
11
|
/**
|
|
10
12
|
* Splits an input string into segments based on a matching pattern.
|
package/dist/esm/storage.js
CHANGED
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @pacem/pacem-core v1.0.0-
|
|
2
|
+
* @pacem/pacem-core v1.0.0-dirac (https://js.pacem.it)
|
|
3
3
|
* Pacem (https://pacem.it)
|
|
4
4
|
* Licensed under Apache-2.0
|
|
5
5
|
*/
|
|
6
6
|
import { Utils } from './utils';
|
|
7
7
|
//namespace Pacem {
|
|
8
8
|
const EXPIRATION_FIELD = '_exp';
|
|
9
|
+
/**
|
|
10
|
+
* JSON-serializing wrapper around `sessionStorage`/`localStorage` that transparently supports per-key
|
|
11
|
+
* expiration: values stored with a `duration` are stamped with an expiry timestamp and evicted lazily
|
|
12
|
+
* (checked on the next {@link getPropertyValue} call for that key, not via a timer). Session storage and
|
|
13
|
+
* local storage are treated as a single logical namespace - storing a key in one clears any same-named entry in the other.
|
|
14
|
+
*/
|
|
9
15
|
export class Storage {
|
|
10
16
|
_getStorage(persistent) {
|
|
11
17
|
return !!persistent ? window.localStorage : window.sessionStorage;
|
|
@@ -40,10 +46,16 @@ export class Storage {
|
|
|
40
46
|
storage = this._getStorage(!persistent);
|
|
41
47
|
storage.removeItem(name);
|
|
42
48
|
}
|
|
49
|
+
/**
|
|
50
|
+
* Retrieves a previously stored value by `name`, checking session storage first, then local storage.
|
|
51
|
+
* Returns `null` if not found, or if found but past its expiration.
|
|
52
|
+
* @param name The unique key.
|
|
53
|
+
*/
|
|
43
54
|
getPropertyValue(name) {
|
|
44
55
|
return this._parseValue(this._getStorage(false), name)
|
|
45
56
|
|| this._parseValue(this._getStorage(true), name);
|
|
46
57
|
}
|
|
58
|
+
/** Clears both session and local storage entirely. */
|
|
47
59
|
clear() {
|
|
48
60
|
var storage = this._getStorage(true);
|
|
49
61
|
storage.clear();
|
|
@@ -51,6 +63,7 @@ export class Storage {
|
|
|
51
63
|
storage.clear();
|
|
52
64
|
}
|
|
53
65
|
;
|
|
66
|
+
/** Removes a single entry by `name` from both session and local storage. */
|
|
54
67
|
removeProperty(name) {
|
|
55
68
|
var storage = this._getStorage(true);
|
|
56
69
|
storage.removeItem(name);
|