creo 0.2.4 → 0.2.6

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.
@@ -17,16 +17,41 @@ export type InputEventData = BaseEventData & {
17
17
  checked: boolean;
18
18
  };
19
19
  export type FocusEventData = BaseEventData;
20
+ export type ScrollEventData = BaseEventData & {
21
+ scrollTop: number;
22
+ scrollLeft: number;
23
+ };
24
+ export type LoadEventData = BaseEventData;
25
+ export type ErrorEventData = BaseEventData & {
26
+ message: string;
27
+ };
28
+ export type ToggleEventData = BaseEventData & {
29
+ open: boolean;
30
+ };
31
+ export type MediaEventData = BaseEventData & {
32
+ muted: boolean;
33
+ paused: boolean;
34
+ volume: number;
35
+ currentTime: number;
36
+ duration: number;
37
+ };
20
38
  export type ContainerEvents = {
21
39
  click: (e: PointerEventData) => void;
22
40
  dblclick: (e: PointerEventData) => void;
23
41
  pointerDown: (e: PointerEventData) => void;
24
42
  pointerUp: (e: PointerEventData) => void;
25
43
  pointerMove: (e: PointerEventData) => void;
44
+ mouseEnter: (e: PointerEventData) => void;
45
+ mouseLeave: (e: PointerEventData) => void;
46
+ pointerEnter: (e: PointerEventData) => void;
47
+ pointerLeave: (e: PointerEventData) => void;
26
48
  keyDown: (e: KeyEventData) => void;
27
49
  keyUp: (e: KeyEventData) => void;
28
50
  focus: (e: FocusEventData) => void;
29
51
  blur: (e: FocusEventData) => void;
52
+ scroll: (e: ScrollEventData) => void;
53
+ load: (e: LoadEventData) => void;
54
+ error: (e: ErrorEventData) => void;
30
55
  };
31
56
  export type FormEvents = ContainerEvents & {
32
57
  input: (e: InputEventData) => void;
@@ -34,6 +59,26 @@ export type FormEvents = ContainerEvents & {
34
59
  keyDown: (e: KeyEventData) => void;
35
60
  keyUp: (e: KeyEventData) => void;
36
61
  };
62
+ export type MediaEvents = ContainerEvents & {
63
+ volumeChange: (e: MediaEventData) => void;
64
+ play: (e: MediaEventData) => void;
65
+ pause: (e: MediaEventData) => void;
66
+ ended: (e: MediaEventData) => void;
67
+ timeUpdate: (e: MediaEventData) => void;
68
+ loadedMetadata: (e: MediaEventData) => void;
69
+ loadedData: (e: MediaEventData) => void;
70
+ canPlay: (e: MediaEventData) => void;
71
+ canPlayThrough: (e: MediaEventData) => void;
72
+ durationChange: (e: MediaEventData) => void;
73
+ rateChange: (e: MediaEventData) => void;
74
+ seeking: (e: MediaEventData) => void;
75
+ seeked: (e: MediaEventData) => void;
76
+ stalled: (e: MediaEventData) => void;
77
+ waiting: (e: MediaEventData) => void;
78
+ };
79
+ export type DisclosureEvents = ContainerEvents & {
80
+ toggle: (e: ToggleEventData) => void;
81
+ };
37
82
  export type HtmlAttrs = {
38
83
  class?: string;
39
84
  id?: string;
@@ -159,14 +204,14 @@ export declare const video: PublicView<HtmlAttrs & {
159
204
  muted?: boolean;
160
205
  width?: number;
161
206
  height?: number;
162
- } & EventHandlerProps<ContainerEvents>, void>;
207
+ } & EventHandlerProps<MediaEvents>, void>;
163
208
  export declare const audio: PublicView<HtmlAttrs & {
164
209
  src?: string;
165
210
  controls?: boolean;
166
211
  autoplay?: boolean;
167
212
  loop?: boolean;
168
213
  muted?: boolean;
169
- } & EventHandlerProps<ContainerEvents>, void>;
214
+ } & EventHandlerProps<MediaEvents>, void>;
170
215
  export declare const canvas: PublicView<HtmlAttrs & {
171
216
  width?: number;
172
217
  height?: number;
@@ -177,11 +222,11 @@ export declare const source: PublicView<HtmlAttrs & {
177
222
  } & EventHandlerProps<ContainerEvents>, void>;
178
223
  export declare const details: PublicView<HtmlAttrs & {
179
224
  open?: boolean;
180
- } & EventHandlerProps<ContainerEvents>, void>;
225
+ } & EventHandlerProps<DisclosureEvents>, void>;
181
226
  export declare const summary: PublicView<HtmlAttrs & EventHandlerProps<ContainerEvents>, void>;
182
227
  export declare const dialog: PublicView<HtmlAttrs & {
183
228
  open?: boolean;
184
- } & EventHandlerProps<ContainerEvents>, void>;
229
+ } & EventHandlerProps<DisclosureEvents>, void>;
185
230
  export declare const menu: PublicView<HtmlAttrs & EventHandlerProps<ContainerEvents>, void>;
186
231
  export declare const iframe: PublicView<HtmlAttrs & {
187
232
  src?: string;
@@ -16,6 +16,12 @@ export interface Reactive<T> {
16
16
  * count.get() // read current value
17
17
  * count.set(5) // set immediately, schedule render
18
18
  * count.update(n => n + 1) // update via fn, schedule render
19
+ *
20
+ * Async updates chain: a second `update` issued while a previous async
21
+ * update is still in flight runs against the previous update's result,
22
+ * not against the snapshot at issue time. `set` cancels any pending
23
+ * chain — its value becomes authoritative and in-flight links won't
24
+ * commit afterwards.
19
25
  */
20
26
  export declare class State<T> implements Reactive<T> {
21
27
  #private;
@@ -1,18 +1,14 @@
1
1
  import type { Key } from "../functional/key";
2
2
  import type { Use } from "./state";
3
3
  import type { $primitive } from "./primitive";
4
- export type ViewBody<Props, Api> = Api extends void ? {
5
- render: () => void;
6
- onMount?: () => void;
7
- shouldUpdate?: (nextProps: Props) => boolean;
8
- onUpdateBefore?: () => void;
9
- onUpdateAfter?: () => void;
10
- } : {
4
+ type ViewBodyBase<Props> = {
11
5
  render: () => void;
12
6
  onMount?: () => void;
13
7
  shouldUpdate?: (nextProps: Props) => boolean;
14
8
  onUpdateBefore?: () => void;
15
9
  onUpdateAfter?: () => void;
10
+ };
11
+ export type ViewBody<Props, Api> = Api extends void ? ViewBodyBase<Props> : ViewBodyBase<Props> & {
16
12
  api: Api;
17
13
  };
18
14
  /** Slot callback — passed by the caller at the call site. */
@@ -8,6 +8,13 @@ export declare class HtmlRender implements IRender<HTMLElement | Text> {
8
8
  constructor(container: HTMLElement);
9
9
  render(view: ViewRecord): void;
10
10
  unmount(view: ViewRecord): void;
11
+ /**
12
+ * Re-render only when a stateful DOM property in `nextProps` actually
13
+ * differs from the live DOM. With this in place a 50-input form whose
14
+ * parent re-renders touches the DOM only for the input the user is
15
+ * actually editing.
16
+ */
17
+ shouldReassert(view: ViewRecord, nextProps: unknown): boolean;
11
18
  private findParentDom;
12
19
  private findInsertionPoint;
13
20
  private setAttributes;
@@ -6,4 +6,18 @@ export interface IRender<Output> {
6
6
  render(view: ViewRecord): void;
7
7
  /** Remove a view's output artifacts. */
8
8
  unmount(view: ViewRecord): void;
9
+ /**
10
+ * Optional: returns true if this primitive's live output may have
11
+ * drifted from `nextProps` and needs re-rendering even though
12
+ * `shallowEqual(prev, next)` reports props as unchanged.
13
+ *
14
+ * The DOM renderer uses this to detect user input that changed
15
+ * the live DOM (e.g. typing in `<input value=…>`, toggling a
16
+ * checkbox) without our state ever changing.
17
+ *
18
+ * Called only for primitives whose own props didn't change
19
+ * shallowly — engines should treat absence of this method as
20
+ * "nothing to re-assert".
21
+ */
22
+ shouldReassert?(view: ViewRecord, nextProps: unknown): boolean;
9
23
  }
@@ -18,5 +18,3 @@ export declare class HtmlStringRender implements IRender<string> {
18
18
  private buildAttrs;
19
19
  private buildChildren;
20
20
  }
21
- /** @deprecated Use HtmlStringRender instead */
22
- export declare const StringRender: typeof HtmlStringRender;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "creo",
3
- "version": "0.2.4",
3
+ "version": "0.2.6",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",
@@ -1,32 +0,0 @@
1
- import type { Wildcard } from "../internal/wildcard";
2
- type EventCallback = (...args: Wildcard[]) => void;
3
- /**
4
- * Delegate that the renderer provides to wire event subscriptions
5
- * to the actual output (DOM addEventListener, etc.).
6
- * Set on the EventHandle after the view's output is created.
7
- */
8
- export type EventDelegate = {
9
- bind(event: string, callback: EventCallback, once?: boolean): void;
10
- unbind(event: string, callback: EventCallback): void;
11
- };
12
- /**
13
- * Handle returned when calling a primitive in the render stream.
14
- * Provides on/once/off for event subscription.
15
- *
16
- * When a delegate is set (by the renderer after mount), calls are
17
- * proxied to the renderer — only events the user subscribes to
18
- * get bound. Before the delegate exists, listeners are stored and
19
- * flushed once the delegate arrives.
20
- */
21
- export declare class EventHandle<Events> {
22
- #private;
23
- on<K extends keyof Events>(event: K, callback: Events[K]): void;
24
- once<K extends keyof Events>(event: K, callback: Events[K]): void;
25
- off<K extends keyof Events>(event: K, callback: Events[K]): void;
26
- /**
27
- * Called by the renderer after the view's output is created.
28
- * Flushes any listeners that were added before the delegate existed.
29
- */
30
- setDelegate(delegate: EventDelegate): void;
31
- }
32
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1,46 +0,0 @@
1
- /**
2
- * IndexedList — linked list with O(1) identity-based lookup.
3
- *
4
- * Combines a doubly-linked list (O(1) insert/delete given a node)
5
- * with a Map<T, INode<T>> for O(1) lookup by value identity.
6
- *
7
- * All mutating operations are O(1):
8
- * push, delete, has, first, last, clear
9
- */
10
- import { type INode } from "./list";
11
- import type { Maybe } from "../functional/maybe";
12
- export declare class IndexedList<T> {
13
- #private;
14
- /** Append item to the end. No-op if already present. Returns the node. */
15
- push(item: T): INode<T>;
16
- /** Insert item at the front. No-op if already present. */
17
- unshift(item: T): void;
18
- /** Insert item after ref. No-op if item already present. */
19
- insertAfter(ref: T, item: T): void;
20
- /** Remove item. O(1). */
21
- delete(item: T): void;
22
- /** Check membership. O(1). */
23
- has(item: T): boolean;
24
- /** Number of items. */
25
- get length(): number;
26
- /** Get the first item (head). O(1). */
27
- first(): Maybe<T>;
28
- /** Get the last item (tail). O(1). */
29
- last(): Maybe<T>;
30
- /** Get the linked-list node for an item. O(1). */
31
- getNode(item: T): Maybe<INode<T>>;
32
- /** Positional access. O(n) — prefer getNode + getNext for traversal. */
33
- at(index: number): Maybe<T>;
34
- /**
35
- * Replace item at `pos`, or insert if nothing is there.
36
- * If `pos >= length`, appends to the end.
37
- * Returns the node.
38
- */
39
- upsert(pos: number, item: T): INode<T>;
40
- /** Swap two items in the list. O(1). No-op if either item is missing. */
41
- swap(a: T, b: T): void;
42
- /** Reset to empty. O(1). */
43
- clear(): void;
44
- /** Iterate values in insertion order. */
45
- [Symbol.iterator](): IterableIterator<T>;
46
- }
@@ -1,68 +0,0 @@
1
- /**
2
- * Linked list implementation
3
- */
4
- import type { Maybe } from "../functional/maybe";
5
- declare const $next: unique symbol;
6
- declare const $prev: unique symbol;
7
- declare const $owner: unique symbol;
8
- export interface INode<T> {
9
- insertNext(value: T): INode<T>;
10
- insertPrev(value: T): INode<T>;
11
- v: T;
12
- delete(): void;
13
- getNext(): Maybe<INode<T>>;
14
- getPrev(): Maybe<INode<T>>;
15
- isFirst(): boolean;
16
- isLast(): boolean;
17
- }
18
- export declare class ListNode<T> implements INode<T> {
19
- [$owner]: Maybe<IBaseContainer<T>>;
20
- [$next]: Maybe<ListNode<T>>;
21
- [$prev]: Maybe<ListNode<T>>;
22
- v: T;
23
- constructor(node: T, prev: Maybe<ListNode<T>>, next: Maybe<ListNode<T>>, list: IBaseContainer<T>);
24
- isFirst(): boolean;
25
- isLast(): boolean;
26
- delete(): void;
27
- clearFields(): void;
28
- insertNext(value: T): INode<T>;
29
- insertPrev(value: T): INode<T>;
30
- getNext(): Maybe<ListNode<T>>;
31
- getPrev(): Maybe<ListNode<T>>;
32
- getList(): Maybe<IBaseContainer<T>>;
33
- }
34
- interface IBaseContainer<T> {
35
- delete(node: INode<T>): void;
36
- insertNext(ref: INode<T>, value: T): INode<T>;
37
- insertPrev(ref: INode<T>, value: T): INode<T>;
38
- }
39
- export interface IList<T> extends Iterable<INode<T>>, IBaseContainer<T> {
40
- insertStart(value: T): INode<T>;
41
- insertEnd(value: T): INode<T>;
42
- at(n: number): Maybe<INode<T>>;
43
- first(): Maybe<INode<T>>;
44
- last(): Maybe<INode<T>>;
45
- readonly size: number;
46
- [Symbol.iterator](): IterableIterator<INode<T>>;
47
- }
48
- export declare class InternalList<T> implements IList<T> {
49
- #private;
50
- insertStart(value: T): ListNode<T>;
51
- delete(node: INode<T>): void;
52
- at(n: number): Maybe<ListNode<T>>;
53
- get size(): number;
54
- /** Reset the list to empty. O(1). */
55
- clear(): void;
56
- /** O(1) head access. */
57
- first(): Maybe<ListNode<T>>;
58
- /** O(1) tail access. */
59
- last(): Maybe<ListNode<T>>;
60
- insertEnd(value: T): ListNode<T>;
61
- insertNext(ref: INode<T>, value: T): ListNode<T>;
62
- insertPrev(ref: INode<T>, value: T): ListNode<T>;
63
- [Symbol.iterator](): Generator<ListNode<T>, void, unknown>;
64
- }
65
- export declare class List<T> extends InternalList<T> implements IList<T> {
66
- static from<T>(arrayLike: Iterable<T>): List<T>;
67
- }
68
- export {};