creo 0.1.0 → 0.2.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.
- package/README.md +275 -4
- package/dist/functional/lis.d.ts +11 -0
- package/dist/functional/maybe.d.ts +2 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +763 -779
- package/dist/index.js.map +16 -17
- package/dist/internal/engine.d.ts +14 -8
- package/dist/internal/internal_view.d.ts +22 -31
- package/dist/internal/orchestrator.d.ts +1 -1
- package/dist/public/primitives/primitives.d.ts +1 -1
- package/dist/public/view.d.ts +2 -6
- package/dist/render/html_render.d.ts +9 -22
- package/dist/render/json_render.d.ts +6 -4
- package/dist/render/render_interface.d.ts +6 -4
- package/dist/render/string_render.d.ts +14 -9
- package/package.json +1 -1
|
@@ -1,38 +1,29 @@
|
|
|
1
1
|
import type { Key } from "../functional/key";
|
|
2
|
-
import type {
|
|
3
|
-
import type { Engine } from "./engine";
|
|
4
|
-
import { IndexedList } from "../structures/indexed_list";
|
|
2
|
+
import type { Slot, ViewBody, ViewFn } from "../public/view";
|
|
5
3
|
import type { Maybe } from "../functional/maybe";
|
|
6
4
|
import type { Wildcard } from "./wildcard";
|
|
7
|
-
export type
|
|
5
|
+
export type BitFlags = number;
|
|
6
|
+
export declare const F_PENDING = 1;
|
|
7
|
+
export declare const F_DIRTY: number;
|
|
8
|
+
export declare const F_MOVED: number;
|
|
9
|
+
export declare const F_QUICK_RERENDER: number;
|
|
10
|
+
export declare const F_PRIMITIVE: number;
|
|
11
|
+
export declare const F_TEXT_CONTENT: number;
|
|
12
|
+
export type ViewRecord<Props = Wildcard, Api = Wildcard, RenderRef = Wildcard> = {
|
|
8
13
|
viewFn: ViewFn<Props, Api>;
|
|
14
|
+
userKey: Maybe<Key>;
|
|
9
15
|
props: Props;
|
|
10
16
|
slot: Maybe<Slot>;
|
|
11
|
-
|
|
17
|
+
body: Maybe<ViewBody<Props, Api>>;
|
|
18
|
+
sc: Maybe<ViewRecord[]>;
|
|
19
|
+
renderRef: Maybe<RenderRef>;
|
|
20
|
+
flags: BitFlags;
|
|
21
|
+
children: Maybe<ViewRecord[]>;
|
|
22
|
+
keyToView: Maybe<Map<Key, ViewRecord>>;
|
|
23
|
+
unsubscribe: Maybe<(() => void)[]>;
|
|
24
|
+
parent: Maybe<ViewRecord>;
|
|
25
|
+
/** The primitive whose .children contains the live sc items after reconcile. */
|
|
26
|
+
scHost: Maybe<ViewRecord>;
|
|
12
27
|
};
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
viewFn: ViewFn<Props, Api>;
|
|
16
|
-
engine: Engine;
|
|
17
|
-
parent: Maybe<View>;
|
|
18
|
-
userKey: Maybe<Key>;
|
|
19
|
-
renderRef: unknown;
|
|
20
|
-
props: Props;
|
|
21
|
-
slotChildren: Children;
|
|
22
|
-
body: ViewBody<Props, Api>;
|
|
23
|
-
virtualDom: Maybe<IndexedList<View>>;
|
|
24
|
-
keyToIndex: Maybe<Map<Key, number>>;
|
|
25
|
-
dirty: boolean;
|
|
26
|
-
moved: boolean;
|
|
27
|
-
quickRerender: boolean;
|
|
28
|
-
constructor(viewFn: ViewFn<Props, Api>, initialProps: Props, slot: Maybe<Slot>, engine: Engine, parent: Maybe<View>, userKey: Maybe<Key>);
|
|
29
|
-
markDirty: () => void;
|
|
30
|
-
markMove(): void;
|
|
31
|
-
shouldUpdate(nextProps: Props): boolean;
|
|
32
|
-
onMount: () => void;
|
|
33
|
-
onUpdateBefore(): void;
|
|
34
|
-
onUpdateAfter: () => void;
|
|
35
|
-
nextProps(nextProps: Props, nextSlot: Maybe<Slot>): void;
|
|
36
|
-
reconsile(): void;
|
|
37
|
-
[Symbol.dispose](): void;
|
|
38
|
-
}
|
|
28
|
+
/** Structural change: viewFn, key, or count differs. Does NOT check props. */
|
|
29
|
+
export declare function hasScStructuralChange(prev: Maybe<ViewRecord[]>, next: Maybe<ViewRecord[]>): boolean;
|
|
@@ -9,7 +9,7 @@ import type { Engine } from "../internal/engine";
|
|
|
9
9
|
*/
|
|
10
10
|
declare class Orchestrator {
|
|
11
11
|
#private;
|
|
12
|
-
setCurrentEngine(engine: Engine): void;
|
|
12
|
+
setCurrentEngine(engine: Maybe<Engine>): void;
|
|
13
13
|
currentEngine(): Maybe<Engine>;
|
|
14
14
|
}
|
|
15
15
|
export declare const orchestrator: Orchestrator;
|
|
@@ -45,7 +45,7 @@ export type HtmlAttrs = {
|
|
|
45
45
|
[attr: string]: unknown;
|
|
46
46
|
};
|
|
47
47
|
export declare function html<Attrs extends HtmlAttrs = HtmlAttrs, Events = ContainerEvents>(tag: string): PublicView<Attrs & EventHandlerProps<Events>, void>;
|
|
48
|
-
export declare
|
|
48
|
+
export declare function text(content: string | number): void;
|
|
49
49
|
export declare const div: PublicView<HtmlAttrs & EventHandlerProps<ContainerEvents>, void>;
|
|
50
50
|
export declare const span: PublicView<HtmlAttrs & EventHandlerProps<ContainerEvents>, void>;
|
|
51
51
|
export declare const section: PublicView<HtmlAttrs & EventHandlerProps<ContainerEvents>, void>;
|
package/dist/public/view.d.ts
CHANGED
|
@@ -1,26 +1,22 @@
|
|
|
1
1
|
import type { Key } from "../functional/key";
|
|
2
|
-
import type { Maybe } from "../functional/maybe";
|
|
3
2
|
import type { Use } from "./state";
|
|
4
|
-
import type { PendingView } from "../internal/internal_view";
|
|
5
3
|
import type { $primitive } from "./primitive";
|
|
6
4
|
export type ViewBody<Props, Api> = Api extends void ? {
|
|
7
5
|
render: () => void;
|
|
8
6
|
onMount?: () => void;
|
|
9
7
|
shouldUpdate?: (nextProps: Props) => boolean;
|
|
10
8
|
onUpdateBefore?: () => void;
|
|
11
|
-
|
|
9
|
+
onUpdateAfter?: () => void;
|
|
12
10
|
} : {
|
|
13
11
|
render: () => void;
|
|
14
12
|
onMount?: () => void;
|
|
15
13
|
shouldUpdate?: (nextProps: Props) => boolean;
|
|
16
14
|
onUpdateBefore?: () => void;
|
|
17
|
-
|
|
15
|
+
onUpdateAfter?: () => void;
|
|
18
16
|
api: Api;
|
|
19
17
|
};
|
|
20
18
|
/** Slot callback — passed by the caller at the call site. */
|
|
21
19
|
export type Slot = () => void;
|
|
22
|
-
/** Children — pre-collected PendingViews available inside the view. */
|
|
23
|
-
export type Children = Maybe<PendingView[]>;
|
|
24
20
|
export type ViewFn<Props, Api> = {
|
|
25
21
|
(ctx: {
|
|
26
22
|
props: () => Props;
|
|
@@ -1,35 +1,22 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ViewRecord } from "../internal/internal_view";
|
|
2
2
|
import type { IRender } from "./render_interface";
|
|
3
|
+
import type { Engine } from "../internal/engine";
|
|
3
4
|
export declare class HtmlRender implements IRender<HTMLElement | Text> {
|
|
5
|
+
#private;
|
|
4
6
|
private container;
|
|
7
|
+
engine: Engine;
|
|
5
8
|
constructor(container: HTMLElement);
|
|
6
|
-
render(view:
|
|
7
|
-
unmount(view:
|
|
8
|
-
private
|
|
9
|
-
private
|
|
10
|
-
private eventPropToCreoName;
|
|
9
|
+
render(view: ViewRecord): void;
|
|
10
|
+
unmount(view: ViewRecord): void;
|
|
11
|
+
private findParentDom;
|
|
12
|
+
private findInsertionPoint;
|
|
11
13
|
private setAttributes;
|
|
12
14
|
private diffAttributes;
|
|
13
15
|
private bindEvent;
|
|
14
16
|
private unbindEvent;
|
|
15
|
-
private mapEventData;
|
|
16
17
|
private setAttribute;
|
|
17
18
|
private removeAttribute;
|
|
18
|
-
/**
|
|
19
|
-
* Compute where a view's DOM node should be placed in its parent.
|
|
20
|
-
*
|
|
21
|
-
* Fast paths (O(1)):
|
|
22
|
-
* - Last child → endComment (composite) or null/appendChild (primitive)
|
|
23
|
-
* - Previous sibling rendered → nextSibling of prev's last DOM node
|
|
24
|
-
*
|
|
25
|
-
* Slow path (O(k)): walk backward through unrendered siblings.
|
|
26
|
-
*
|
|
27
|
-
* Composite parents always return endComment as fallback (never null),
|
|
28
|
-
* so insertBefore(node, result) is safe for all parent types.
|
|
29
|
-
*/
|
|
30
|
-
private fastInsertionPoint;
|
|
31
|
-
private getParentDomNode;
|
|
32
|
-
private moveDomNodes;
|
|
33
19
|
private getFirstDomNode;
|
|
20
|
+
private moveDomNodes;
|
|
34
21
|
private removeDomNodes;
|
|
35
22
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ViewRecord } from "../internal/internal_view";
|
|
2
2
|
import type { IRender } from "./render_interface";
|
|
3
3
|
import type { Maybe } from "../functional/maybe";
|
|
4
|
+
import type { Engine } from "../internal/engine";
|
|
4
5
|
export type JsonNode = {
|
|
5
6
|
type: string;
|
|
6
7
|
props: Record<string, unknown>;
|
|
@@ -10,8 +11,9 @@ export type JsonNode = {
|
|
|
10
11
|
export declare class JsonRender implements IRender<JsonNode> {
|
|
11
12
|
/** The root JSON node after mount. */
|
|
12
13
|
root: Maybe<JsonNode>;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
engine: Engine;
|
|
15
|
+
constructor();
|
|
16
|
+
render(view: ViewRecord): void;
|
|
17
|
+
unmount(view: ViewRecord): void;
|
|
16
18
|
private buildNode;
|
|
17
19
|
}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ViewRecord } from "../internal/internal_view";
|
|
2
|
+
import type { Engine } from "../internal/engine";
|
|
2
3
|
export interface IRender<Output> {
|
|
4
|
+
engine: Engine;
|
|
3
5
|
/** Create output if view is new (no renderRef), or update if existing. */
|
|
4
|
-
render(view:
|
|
5
|
-
/** Remove a view's output artifacts.
|
|
6
|
-
unmount(view:
|
|
6
|
+
render(view: ViewRecord): void;
|
|
7
|
+
/** Remove a view's output artifacts. */
|
|
8
|
+
unmount(view: ViewRecord): void;
|
|
7
9
|
}
|
|
@@ -1,17 +1,22 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ViewRecord } from "../internal/internal_view";
|
|
2
2
|
import type { IRender } from "./render_interface";
|
|
3
|
+
import type { Engine } from "../internal/engine";
|
|
3
4
|
/**
|
|
4
|
-
*
|
|
5
|
-
*
|
|
5
|
+
* HtmlStringRender — pull-based string renderer.
|
|
6
|
+
* render/unmount are no-ops. Call renderToString() to
|
|
6
7
|
* get the current HTML string from the VDOM.
|
|
8
|
+
*
|
|
9
|
+
* Output matches HtmlRender's DOM serialization (innerHTML).
|
|
7
10
|
*/
|
|
8
|
-
export declare class
|
|
9
|
-
private
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
export declare class HtmlStringRender implements IRender<string> {
|
|
12
|
+
private root;
|
|
13
|
+
engine: Engine;
|
|
14
|
+
render(view: ViewRecord): void;
|
|
15
|
+
unmount(_view: ViewRecord): void;
|
|
13
16
|
renderToString(): string;
|
|
14
17
|
private buildString;
|
|
15
|
-
private
|
|
18
|
+
private buildAttrs;
|
|
16
19
|
private buildChildren;
|
|
17
20
|
}
|
|
21
|
+
/** @deprecated Use HtmlStringRender instead */
|
|
22
|
+
export declare const StringRender: typeof HtmlStringRender;
|