keits 0.0.4 → 0.1.1

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 (71) hide show
  1. package/README.md +93 -79
  2. package/dist/dev/api.js +8 -3
  3. package/dist/dev/forms.js +10 -5
  4. package/dist/dev/index.js +28 -35
  5. package/dist/dev/router.js +24 -7
  6. package/dist/dev/shared/{computed-3UO-KiH1.js → computed-DrF8O8b4.js} +1 -1
  7. package/dist/dev/shared/element-Bgf6SNbW.js +21 -0
  8. package/dist/dev/shared/{graph-D6-x_CWC.js → graph-SIvYLXSv.js} +62 -3
  9. package/dist/dev/shared/hydrate-g_akkVyT.js +588 -0
  10. package/dist/dev/shared/{element-CQPqagu1.js → insert-DadcXJL8.js} +116 -86
  11. package/dist/dev/shared/mount-BtpMEhSZ.js +23 -0
  12. package/dist/dev/shared/{owner-Dmge21OW.js → owner-BuwIoI4j.js} +12 -2
  13. package/dist/dev/shared/render-context-k2uu_dM_.js +34 -0
  14. package/dist/dev/shared/render-effect-Uk9dDmuU.js +32 -0
  15. package/dist/dev/shared/{resource-CbXVATvq.js → resource-DlgzdtcG.js} +24 -33
  16. package/dist/dev/shared/{signal-BOXkY-Iv.js → signal-B3xOKbVm.js} +1 -1
  17. package/dist/dev/shared/{store-BzUN1qE5.js → store-0vEg2bQV.js} +7 -3
  18. package/dist/dev/shared/unsafe-keys-CB1P22No.js +8 -0
  19. package/dist/dev/static.js +76 -0
  20. package/dist/dev/svg.js +2 -1
  21. package/dist/dev/testing.js +236 -0
  22. package/dist/dev/vite.js +141 -0
  23. package/dist/prod/api.js +76 -71
  24. package/dist/prod/forms.js +89 -84
  25. package/dist/prod/index.js +58 -66
  26. package/dist/prod/router.js +86 -73
  27. package/dist/prod/shared/{computed-CAPpOLCY.js → computed-BjqJ6Pps.js} +1 -1
  28. package/dist/prod/shared/element-B-0tH1YW.js +15 -0
  29. package/dist/prod/shared/{graph-C_aA46c6.js → graph-CR2WKbwr.js} +107 -63
  30. package/dist/prod/shared/hydrate-DhHCtdOz.js +480 -0
  31. package/dist/prod/shared/insert-CbcOsYmu.js +192 -0
  32. package/dist/prod/shared/mount-BEAO35S_.js +18 -0
  33. package/dist/prod/shared/owner-DBi3odT4.js +67 -0
  34. package/dist/prod/shared/render-context-DF8lr1uu.js +30 -0
  35. package/dist/prod/shared/render-effect-UFDi2Pfh.js +25 -0
  36. package/dist/prod/shared/resource-Ch5tVseZ.js +91 -0
  37. package/dist/prod/shared/signal-BDMlfa0Z.js +16 -0
  38. package/dist/prod/shared/store-CvW0DbmK.js +110 -0
  39. package/dist/prod/shared/unsafe-keys-C5PMlerl.js +7 -0
  40. package/dist/prod/static.js +48 -0
  41. package/dist/prod/svg.js +3 -2
  42. package/dist/prod/testing.js +161 -0
  43. package/dist/prod/vite.js +106 -0
  44. package/dist/types/async/render-context.d.ts +10 -0
  45. package/dist/types/core/effect.d.ts +1 -0
  46. package/dist/types/core/graph.d.ts +11 -0
  47. package/dist/types/core/owner.d.ts +1 -0
  48. package/dist/types/core/unsafe-keys.d.ts +2 -0
  49. package/dist/types/dom/hooks.d.ts +4 -0
  50. package/dist/types/dom/props.d.ts +2 -0
  51. package/dist/types/dom/types.d.ts +5 -0
  52. package/dist/types/router/index.d.ts +1 -0
  53. package/dist/types/router/match.d.ts +1 -0
  54. package/dist/types/router/types.d.ts +1 -0
  55. package/dist/types/static/head.d.ts +36 -0
  56. package/dist/types/static/hydrate.d.ts +3 -0
  57. package/dist/types/static/index.d.ts +4 -0
  58. package/dist/types/static/island.d.ts +14 -0
  59. package/dist/types/static/json.d.ts +1 -0
  60. package/dist/types/static/render.d.ts +11 -0
  61. package/dist/types/static/server-dom.d.ts +100 -0
  62. package/dist/types/testing/index.d.ts +69 -0
  63. package/dist/types/vite/index.d.ts +24 -0
  64. package/package.json +35 -8
  65. package/dist/dev/shared/render-effect-kOGnLNbL.js +0 -26
  66. package/dist/prod/shared/element-DGyQ01Vs.js +0 -164
  67. package/dist/prod/shared/owner-6BFHIPR9.js +0 -59
  68. package/dist/prod/shared/render-effect-DjaUT3Cn.js +0 -23
  69. package/dist/prod/shared/resource-CNC2DBO3.js +0 -109
  70. package/dist/prod/shared/signal-DGrl3r9T.js +0 -16
  71. package/dist/prod/shared/store-Dcscpk_h.js +0 -109
@@ -0,0 +1,10 @@
1
+ import type { Owner } from "../core/graph";
2
+ export interface RenderTracker {
3
+ wait(loading: Promise<unknown>): void;
4
+ store(key: string, value: unknown, owner: Owner | null): void;
5
+ }
6
+ export declare const RenderContext: import("..").Context<RenderTracker | null>;
7
+ export declare let hydratedValue: ((key: string) => {
8
+ value: unknown;
9
+ } | undefined) | null;
10
+ export declare function setHydratedValue(lookup: typeof hydratedValue): void;
@@ -2,3 +2,4 @@ export interface EffectOptions {
2
2
  name?: string;
3
3
  }
4
4
  export declare function effect(fn: () => void, options?: EffectOptions): void;
5
+ export declare function createEffect(fn: () => void, name?: string): void;
@@ -16,6 +16,8 @@ interface OwnerFields {
16
16
  children: Owner[] | null;
17
17
  cleanups: (() => void)[] | null;
18
18
  disposed: boolean;
19
+ key?: string;
20
+ keyCount?: number;
19
21
  }
20
22
  interface ComputationFields extends OwnerFields {
21
23
  state: State;
@@ -52,12 +54,15 @@ export interface RootNode extends OwnerFields {
52
54
  owner: Owner | null;
53
55
  fn: () => void;
54
56
  }[] | null;
57
+ static?: true;
58
+ hydratable?: true;
55
59
  }
56
60
  export type Source = SignalSource | ComputedNode;
57
61
  export type Computation = EffectNode | ComputedNode;
58
62
  export type Owner = RootNode | Computation;
59
63
  export declare function track(source: Source): void;
60
64
  export declare function isTracking(): boolean;
65
+ export declare function getObserver(): Owner | null;
61
66
  export declare function notify(source: Source): void;
62
67
  export declare function updateIfNeeded(node: Computation): void;
63
68
  export declare function recompute(node: ComputedNode): void;
@@ -66,6 +71,11 @@ export declare function run<T>(node: Computation, fn: () => T): T;
66
71
  export declare function batch<T>(fn: () => T): T;
67
72
  export declare function untrack<T>(fn: () => T): T;
68
73
  export declare function adopt(node: Owner): void;
74
+ export declare function startKeys(): void;
75
+ export declare function stopKeys(): void;
76
+ export declare function nextKey(): string | null;
77
+ export declare function giveKey(node: Owner): void;
78
+ export declare function insideHydratable(from?: Owner | null): boolean;
69
79
  export declare function getOwner(): Owner | null;
70
80
  export declare function runWithOwner<T>(owner: Owner | null, fn: () => T): T;
71
81
  export declare function addCleanup(fn: () => void): boolean;
@@ -77,5 +87,6 @@ export declare function deferMounts<T>(fn: () => T): {
77
87
  export declare function dispose(node: Owner): void;
78
88
  export declare function handleError(error: unknown, owner: Owner | null): void;
79
89
  export declare function isStaticRender(): boolean;
90
+ export declare function staticRoot<T>(fn: (dispose: () => void) => T): T;
80
91
  export declare function withStaticRender<T>(fn: () => T): T;
81
92
  export {};
@@ -5,6 +5,7 @@ export interface Owner {
5
5
  export declare function getOwner(): Owner | null;
6
6
  export declare function runWithOwner<T>(owner: Owner | null, fn: () => T): T;
7
7
  export declare function createRoot<T>(fn: (dispose: () => void) => T): T;
8
+ export declare function keyedRoot<T>(key: string, hydratable: boolean, fn: (dispose: () => void) => T): T;
8
9
  export declare function onCleanup(fn: () => void): void;
9
10
  export declare function onMount(fn: () => void): void;
10
11
  export declare function catchError<T>(fn: () => T, handler: (error: unknown) => void): T | undefined;
@@ -0,0 +1,2 @@
1
+ /** Keys that reach a prototype instead of a property. Data from an API never needs them. */
2
+ export declare const UNSAFE_KEYS: Set<string>;
@@ -2,7 +2,11 @@ export interface NodeHooks {
2
2
  element(tag: string, namespace: string | null): Element;
3
3
  text(value: string): Text;
4
4
  marker(): Comment;
5
+ fragment(): DocumentFragment;
6
+ html?(markup: string): DocumentFragment;
5
7
  }
6
8
  export declare const defaultHooks: NodeHooks;
9
+ export declare function withoutClaims<T>(fn: () => T): T;
10
+ export declare function claimsPaused(): boolean;
7
11
  export declare let hooks: NodeHooks;
8
12
  export declare function setHooks(next: NodeHooks): NodeHooks;
@@ -1,3 +1,5 @@
1
1
  export declare const BLOCKED_URL = "about:invalid#keits-blocked";
2
2
  export declare function applyProps(element: Element, props: Record<string, unknown>): void;
3
3
  export declare function setProp(element: Element, key: string, value: unknown): void;
4
+ /** After keits changes the children of `parent`: if it's (in) a <select> given a `value`, select that value again. */
5
+ export declare function restoreSelectValue(parent: Node | null): void;
@@ -36,6 +36,11 @@ export type Props<E extends Element> = ElementProps<E> & AttributeProps & EventP
36
36
  style?: StyleValue | (() => StyleValue);
37
37
  ref?: (element: E) => void;
38
38
  };
39
+ /**
40
+ * Creates an element. A plain object as the first argument is read as props, so a value from outside
41
+ * that might not be a string (API data, for example) belongs after the props, or in `String(value)`:
42
+ * `$p(String(comment.body))`. See "Security" in the README.
43
+ */
39
44
  export interface ElementFactory<E extends Element> {
40
45
  (children: Child): E;
41
46
  (props?: Props<E> | null, children?: Child): E;
@@ -1,3 +1,4 @@
1
1
  export { createRouter, type RouterConfig } from "./router";
2
2
  export { browserHistory, hashHistory, memoryHistory, type HistoryLocation, type RouterHistory } from "./history";
3
3
  export type { GuardResult, LayoutProps, LinkOptions, NavigateOptions, NavigationTarget, ParamNames, Params, QueryOf, QuerySchema, QuerySpec, QueryValues, RouteDef, RouteMatch, RoutePath, Router } from "./types";
4
+ export { staticPaths } from "./match";
@@ -13,3 +13,4 @@ export declare function branchSchema(match: RouteMatch | null): QuerySchema;
13
13
  export declare function parseQuery(schema: QuerySchema, search: string): Record<string, string | number | boolean>;
14
14
  export declare function buildSearch(values: Readonly<Record<string, string | number | boolean | undefined>>): string;
15
15
  export declare function fillParams(path: string, params: Readonly<Record<string, string | number>> | undefined): string;
16
+ export declare function staticPaths(routes: readonly RouteDef[]): Promise<string[]>;
@@ -23,6 +23,7 @@ export interface RouteDef {
23
23
  readonly children?: readonly RouteDef[];
24
24
  readonly query?: QuerySchema;
25
25
  readonly guard?: (to: NavigationTarget) => GuardResult | PromiseLike<GuardResult>;
26
+ readonly paths?: () => readonly Readonly<Record<string, string | number>>[] | PromiseLike<readonly Readonly<Record<string, string | number>>[]>;
26
27
  }
27
28
  type Join<Parent extends string, Path extends string> = Path extends `/${string}` ? Path : Path extends "" ? Parent extends "" ? "/" : Parent : Parent extends "" | "/" ? `/${Path}` : `${Parent}/${Path}`;
28
29
  type OwnQuery<D> = D extends {
@@ -0,0 +1,36 @@
1
+ import type { MaybeAccessor } from "../dom/types";
2
+ type Text = MaybeAccessor<string | undefined>;
3
+ export interface HeadTags {
4
+ title?: Text;
5
+ description?: Text;
6
+ canonical?: Text;
7
+ robots?: Text;
8
+ og?: Readonly<Record<string, Text>>;
9
+ twitter?: Readonly<Record<string, Text>>;
10
+ meta?: readonly {
11
+ name?: string;
12
+ property?: string;
13
+ content: Text;
14
+ }[];
15
+ link?: readonly (Readonly<Record<string, string>> & {
16
+ rel: string;
17
+ href: string;
18
+ })[];
19
+ jsonLd?: MaybeAccessor<object | readonly object[] | undefined>;
20
+ }
21
+ export interface HeadTag {
22
+ key: string;
23
+ tag: "title" | "meta" | "link" | "script";
24
+ attrs: Record<string, string>;
25
+ text?: string;
26
+ selector: string;
27
+ }
28
+ export interface HeadRegistry {
29
+ set(token: object, tags: HeadTag[]): void;
30
+ remove(token: object): void;
31
+ winners(): Map<string, HeadTag>;
32
+ }
33
+ export declare const HeadContext: import("..").Context<HeadRegistry | null>;
34
+ export declare function head(tags: HeadTags): void;
35
+ export declare function createHeadRegistry(changed?: (winners: Map<string, HeadTag>) => void): HeadRegistry;
36
+ export {};
@@ -0,0 +1,3 @@
1
+ import type { Child } from "../dom/types";
2
+ export declare function resetHydrationData(): void;
3
+ export declare function hydrate(app: () => Child, container: Element, key?: string): () => void;
@@ -0,0 +1,4 @@
1
+ export { renderToString, type RenderOptions, type RenderResult } from "./render";
2
+ export { head, type HeadTags } from "./head";
3
+ export { hydrate } from "./hydrate";
4
+ export { hydrateIslands, island, type Island, type IslandEntry, type IslandWhen } from "./island";
@@ -0,0 +1,14 @@
1
+ import type { Child } from "../dom/types";
2
+ export type IslandWhen = "load" | "idle" | "visible";
3
+ export interface Island<P> {
4
+ (props: P): Child;
5
+ readonly island: string;
6
+ readonly component: (props: P) => Child;
7
+ }
8
+ export type IslandEntry = Island<never> | (() => PromiseLike<Island<never> | {
9
+ default: Island<never>;
10
+ }>);
11
+ export declare function island<P = void>(name: string, component: (props: P) => Child, options?: {
12
+ when?: IslandWhen;
13
+ }): Island<P>;
14
+ export declare function hydrateIslands(islands: Readonly<Record<string, IslandEntry>>, root?: ParentNode): void;
@@ -0,0 +1 @@
1
+ export declare function scriptJson(value: unknown): string;
@@ -0,0 +1,11 @@
1
+ import type { Child } from "../dom/types";
2
+ export interface RenderOptions {
3
+ timeout?: number;
4
+ hydrate?: boolean;
5
+ }
6
+ export interface RenderResult {
7
+ html: string;
8
+ head: string;
9
+ data: string;
10
+ }
11
+ export declare function renderToString(app: () => Child, options?: RenderOptions): Promise<RenderResult>;
@@ -0,0 +1,100 @@
1
+ import type { NodeHooks } from "../dom/hooks";
2
+ declare abstract class ServerNode {
3
+ abstract readonly nodeType: number;
4
+ parentNode: ServerParent | null;
5
+ previousSibling: ServerNode | null;
6
+ nextSibling: ServerNode | null;
7
+ remove(): void;
8
+ before(...nodes: (ServerNode | string)[]): void;
9
+ after(...nodes: (ServerNode | string)[]): void;
10
+ abstract get textContent(): string;
11
+ abstract print(out: string[], rawText: boolean): void;
12
+ }
13
+ declare abstract class ServerParent extends ServerNode {
14
+ firstChild: ServerNode | null;
15
+ lastChild: ServerNode | null;
16
+ insertBefore<N extends ServerNode>(node: N, before: ServerNode | null): N;
17
+ appendChild<N extends ServerNode>(node: N): N;
18
+ append(...nodes: (ServerNode | string)[]): void;
19
+ removeChild<N extends ServerNode>(node: N): N;
20
+ get textContent(): string;
21
+ set textContent(value: string);
22
+ printChildren(out: string[], rawText: boolean): void;
23
+ }
24
+ export declare class ServerFragment extends ServerParent {
25
+ readonly nodeType = 11;
26
+ print(out: string[], rawText: boolean): void;
27
+ }
28
+ export declare class ServerText extends ServerNode {
29
+ readonly nodeType = 3;
30
+ data: string;
31
+ constructor(data: string);
32
+ get textContent(): string;
33
+ print(out: string[], rawText: boolean): void;
34
+ }
35
+ export declare class ServerComment extends ServerNode {
36
+ readonly nodeType = 8;
37
+ data: string;
38
+ constructor(data: string);
39
+ get textContent(): string;
40
+ print(): void;
41
+ }
42
+ export declare class ServerRawHTML extends ServerNode {
43
+ readonly nodeType = 3;
44
+ readonly html: string;
45
+ constructor(html: string);
46
+ get textContent(): string;
47
+ print(out: string[]): void;
48
+ }
49
+ export declare const SAFE_NAME: RegExp;
50
+ export declare class ServerElement extends ServerParent {
51
+ #private;
52
+ readonly nodeType = 1;
53
+ readonly localName: string;
54
+ readonly namespaceURI: string | null;
55
+ readonly classList: ServerClassList;
56
+ readonly style: ServerStyle;
57
+ constructor(tag: string, namespace: string | null);
58
+ getAttribute(name: string): string | null;
59
+ hasAttribute(name: string): boolean;
60
+ setAttribute(name: string, value: string): void;
61
+ removeAttribute(name: string): void;
62
+ toggleAttribute(name: string, force?: boolean): boolean;
63
+ get value(): unknown;
64
+ set value(value: unknown);
65
+ get checked(): boolean;
66
+ set checked(value: boolean);
67
+ get selected(): boolean;
68
+ set selected(value: boolean);
69
+ get textContent(): string;
70
+ set textContent(value: string);
71
+ set className(value: string);
72
+ set htmlFor(value: string);
73
+ set draggable(value: boolean);
74
+ set spellcheck(value: boolean);
75
+ print(out: string[]): void;
76
+ }
77
+ export declare class ServerClassList {
78
+ #private;
79
+ constructor(element: ServerElement);
80
+ contains(name: string): boolean;
81
+ add(...names: string[]): void;
82
+ remove(...names: string[]): void;
83
+ toggle(name: string, force?: boolean): boolean;
84
+ }
85
+ export declare class ServerStyle {
86
+ #private;
87
+ constructor(element: ServerElement);
88
+ getPropertyValue(name: string): string;
89
+ setProperty(name: string, value: string): void;
90
+ removeProperty(name: string): string;
91
+ get cssText(): string;
92
+ set cssText(text: string);
93
+ get display(): string;
94
+ set display(value: string);
95
+ }
96
+ export declare function escapeText(text: string): string;
97
+ export declare function escapeAttribute(text: string): string;
98
+ export declare const serverHooks: NodeHooks;
99
+ export declare function printNode(node: Node): string;
100
+ export {};
@@ -0,0 +1,69 @@
1
+ import type { Child } from "../dom/types";
2
+ /** Queries inside one element. They throw a readable error when nothing (or more than one) matches. */
3
+ export interface Queries {
4
+ /**
5
+ * The one element whose text is `text` (the innermost, if they're nested). With `{ exact: false }`,
6
+ * a string matches any part of the text, ignoring case.
7
+ */
8
+ getByText(text: string | RegExp, options?: TextOptions): HTMLElement;
9
+ queryByText(text: string | RegExp, options?: TextOptions): HTMLElement | null;
10
+ getAllByText(text: string | RegExp, options?: TextOptions): HTMLElement[];
11
+ /** By ARIA role (explicit, or what the tag means: button, link, textbox, checkbox, heading...), and accessible name. */
12
+ getByRole(role: string, options?: {
13
+ name?: string | RegExp;
14
+ }): HTMLElement;
15
+ queryByRole(role: string, options?: {
16
+ name?: string | RegExp;
17
+ }): HTMLElement | null;
18
+ getAllByRole(role: string, options?: {
19
+ name?: string | RegExp;
20
+ }): HTMLElement[];
21
+ /** The form control a <label> (or aria-label) names. */
22
+ getByLabelText(text: string | RegExp, options?: TextOptions): HTMLElement;
23
+ /** By data-testid, for things a user can't name. */
24
+ getByTestId(id: string): HTMLElement;
25
+ }
26
+ export interface TextOptions {
27
+ /** false: a string matches any part of the text, ignoring case. Default true: the whole text. */
28
+ exact?: boolean;
29
+ }
30
+ export interface Rendered extends Queries {
31
+ /** The element the app was mounted into. */
32
+ container: HTMLElement;
33
+ /** Disposes the app and removes it (cleanup() does this for every render). */
34
+ unmount(): void;
35
+ }
36
+ /** Mounts `app` into a fresh element in the document. */
37
+ export declare function render(app: () => Child): Rendered;
38
+ /**
39
+ * Renders `app` like the server does (waiting for its data), and puts the HTML in the page the way
40
+ * a browser receives it. Then `hydrate()` makes it live, as the browser would.
41
+ */
42
+ export declare function renderOnServer(app: () => Child): Promise<{
43
+ container: HTMLElement;
44
+ html: string;
45
+ head: string;
46
+ hydrate(): Rendered;
47
+ }>;
48
+ /** Disposes everything render() and renderOnServer() made. Call it after each test: `afterEach(cleanup)`. */
49
+ export declare function cleanup(): void;
50
+ /** Waits until pending promises and timers of 0 ms have run (loaded data shows, effects settle). */
51
+ export declare function flush(): Promise<void>;
52
+ /** Acts like a user would: the events a browser fires, in its order. */
53
+ export declare const user: {
54
+ click(element: Element): void;
55
+ /** Types `text` one character at a time (an `input` event each), after the current value. */
56
+ type(element: Element, text: string): void;
57
+ /** Empties a text field. */
58
+ clear(element: Element): void;
59
+ /** Picks an option of a <select> by its value. */
60
+ select(element: Element, value: string): void;
61
+ /** Ticks or unticks a checkbox, or picks a radio. */
62
+ check(element: Element): void;
63
+ /** Leaves a field (what makes keits/forms show its error). */
64
+ blur(element: Element): void;
65
+ /** Submits a form (or the form an element is in), like pressing Enter in it. */
66
+ submit(element: Element): void;
67
+ };
68
+ /** The queries, scoped to `root`. */
69
+ export declare function within(root: Element): Queries;
@@ -0,0 +1,24 @@
1
+ import type { Plugin } from "vite";
2
+ import type { RenderResult } from "../static/render";
3
+ export interface Page {
4
+ url: string;
5
+ version?: string;
6
+ sitemap?: boolean;
7
+ }
8
+ export interface ServerEntry {
9
+ pages(): Iterable<string | Page> | Promise<Iterable<string | Page>>;
10
+ render(url: string): RenderResult | Promise<RenderResult>;
11
+ }
12
+ export interface KeitsOptions {
13
+ entry: string;
14
+ site?: string;
15
+ cacheDir?: string;
16
+ }
17
+ export interface BuildReport {
18
+ changed: string[];
19
+ removed: string[];
20
+ rendered: number;
21
+ reused: number;
22
+ }
23
+ export declare function keits(options: KeitsOptions): Plugin;
24
+ export declare function fileFor(url: string): string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "keits",
3
- "version": "0.0.4",
3
+ "version": "0.1.1",
4
4
  "description": "Fine-grained reactive TypeScript framework. Real DOM, no virtual DOM, zero dependencies.",
5
5
  "keywords": [
6
6
  "reactive",
@@ -48,6 +48,23 @@
48
48
  "types": "./dist/types/forms/index.d.ts",
49
49
  "development": "./dist/dev/forms.js",
50
50
  "default": "./dist/prod/forms.js"
51
+ },
52
+ "./static": {
53
+ "@keits/source": "./src/static/index.ts",
54
+ "types": "./dist/types/static/index.d.ts",
55
+ "development": "./dist/dev/static.js",
56
+ "default": "./dist/prod/static.js"
57
+ },
58
+ "./testing": {
59
+ "@keits/source": "./src/testing/index.ts",
60
+ "types": "./dist/types/testing/index.d.ts",
61
+ "development": "./dist/dev/testing.js",
62
+ "default": "./dist/prod/testing.js"
63
+ },
64
+ "./vite": {
65
+ "@keits/source": "./src/vite/index.ts",
66
+ "types": "./dist/types/vite/index.d.ts",
67
+ "default": "./dist/prod/vite.js"
51
68
  }
52
69
  },
53
70
  "scripts": {
@@ -56,13 +73,23 @@
56
73
  "prepublishOnly": "cd ../.. && npm run check"
57
74
  },
58
75
  "size-budget": {
59
- "dist/prod/index.js": 7168,
76
+ "dist/prod/index.js": 7680,
60
77
  "size/basic.js": 1792,
61
- "size/dom-basic.js": 3072,
62
- "size/svg-icon.js": 3328,
63
- "size/data-app.js": 5120,
64
- "size/router-app.js": 6144,
65
- "size/api-app.js": 6656,
66
- "size/forms-app.js": 6656
78
+ "size/dom-basic.js": 3456,
79
+ "size/svg-icon.js": 3456,
80
+ "size/data-app.js": 5312,
81
+ "size/router-app.js": 6400,
82
+ "size/api-app.js": 7040,
83
+ "size/forms-app.js": 6784,
84
+ "size/head.js": 4096,
85
+ "size/islands.js": 4224
86
+ },
87
+ "peerDependencies": {
88
+ "vite": ">=8"
89
+ },
90
+ "peerDependenciesMeta": {
91
+ "vite": {
92
+ "optional": true
93
+ }
67
94
  }
68
95
  }
@@ -1,26 +0,0 @@
1
- import { f as runEffect, i as batch, l as isStaticRender, r as adopt } from "./graph-D6-x_CWC.js";
2
- // src/core/effect.ts
3
- function effect(fn, options) {
4
- if (isStaticRender()) return;
5
- const node = {
6
- kind: 1,
7
- fn,
8
- state: 0,
9
- sources: [],
10
- flushId: 0,
11
- flushRuns: 0,
12
- owner: null,
13
- children: null,
14
- cleanups: null,
15
- disposed: false
16
- };
17
- if (options?.name !== void 0) node.name = options.name;
18
- adopt(node);
19
- batch(() => runEffect(node));
20
- }
21
- // src/dom/render-effect.ts
22
- function renderEffect(fn) {
23
- if (isStaticRender()) fn();
24
- else effect(fn);
25
- }
26
- export { effect as n, renderEffect as t };
@@ -1,164 +0,0 @@
1
- import { t as e } from "./render-effect-DjaUT3Cn.js";
2
- import { c as t, i as n, l as r, p as i, s as a } from "./graph-C_aA46c6.js";
3
- var o = {
4
- element: (e, t) => t === null ? document.createElement(e) : document.createElementNS(t, e),
5
- text: (e) => document.createTextNode(e),
6
- marker: () => document.createComment("")
7
- };
8
- // src/dom/insert.ts
9
- function s(e, t, n = null) {
10
- if (t != null && typeof t != "boolean") {
11
- if (typeof t == "function") return d(e, t, n);
12
- if (c(t)) for (let r of t) s(e, r, n);
13
- else typeof t == "object" ? e.insertBefore(t, n) : e.insertBefore(o.text(String(t)), n);
14
- }
15
- }
16
- function c(e) {
17
- return Array.isArray(e);
18
- }
19
- function l(e) {
20
- return e === null || typeof e != "object" && typeof e != "function";
21
- }
22
- function u(e) {
23
- return e == null || typeof e == "boolean" ? "" : String(e);
24
- }
25
- function d(t, n, r) {
26
- let i = o.text("");
27
- t.insertBefore(i, r);
28
- let a = null, c = null;
29
- e(() => {
30
- let e = n();
31
- if (a === null || c === null) {
32
- if (l(e)) {
33
- let t = u(e);
34
- i.data !== t && (i.data = t);
35
- return;
36
- }
37
- a = o.marker(), c = o.marker(), i.before(a), i.after(c), i.remove();
38
- }
39
- f(a, c), s(c.parentNode, e, c);
40
- });
41
- }
42
- function f(e, t) {
43
- let n = e.nextSibling;
44
- for (; n !== null && n !== t;) {
45
- let e = n.nextSibling;
46
- n.remove(), n = e;
47
- }
48
- }
49
- // src/dom/events.ts
50
- function p(e, t, n) {
51
- let i = n, a;
52
- if (Array.isArray(n) && ([i, a] = n), typeof i != "function") throw Error("[keits] bad handler");
53
- r() || m(e, t.slice(2), i, a);
54
- }
55
- function m(e, r, o, s) {
56
- let c = a();
57
- e.addEventListener(r, (e) => {
58
- n(() => {
59
- try {
60
- let r = i(c, () => o(e));
61
- h(r) && r.then(void 0, (e) => n(() => t(e, c)));
62
- } catch (e) {
63
- t(e, c);
64
- }
65
- });
66
- }, s);
67
- }
68
- function h(e) {
69
- return typeof e?.then == "function";
70
- }
71
- // src/dom/namespaces.ts
72
- var g = "http://www.w3.org/2000/svg", _ = /* @__PURE__ */ new Set([
73
- "innerHTML",
74
- "outerHTML",
75
- "srcdoc"
76
- ]), v = /* @__PURE__ */ new Set([
77
- "href",
78
- "src",
79
- "action",
80
- "formAction",
81
- "formaction",
82
- "poster",
83
- "cite",
84
- "data",
85
- "xlink:href"
86
- ]), y = "about:invalid#keits-blocked";
87
- function b(t, n) {
88
- for (let r in n) {
89
- let i = n[r];
90
- r !== "ref" && (r === "class" ? w(t, i) : r === "style" ? O(t, i) : r.startsWith("on") ? p(t, r, i) : typeof i == "function" ? e(() => x(t, r, i())) : x(t, r, i));
91
- }
92
- }
93
- function x(e, t, n) {
94
- if (_.has(t)) throw Error("[keits] unsafe prop");
95
- v.has(t) && typeof n == "string" && S(n) && (n = y), t in e && e.namespaceURI !== "http://www.w3.org/2000/svg" ? (e[t] = n, r() && C(e, t, n)) : n == null || n === !1 ? e.removeAttribute(t) : e.setAttribute(t, n === !0 ? "" : String(n));
96
- }
97
- function S(e) {
98
- return e.replace(/[\u0000-\u0020]/g, "").toLowerCase().startsWith("javascript");
99
- }
100
- function C(e, t, n) {
101
- t === "value" ? e.localName === "textarea" ? e.textContent = n == null ? "" : String(n) : n == null ? e.removeAttribute("value") : e.setAttribute("value", String(n)) : (t === "checked" || t === "selected") && e.toggleAttribute(t, n === !0);
102
- }
103
- function w(t, n) {
104
- if (typeof n == "function") {
105
- e(() => T(t, D(n())));
106
- return;
107
- }
108
- let r = [];
109
- E(n, r, (n, r) => {
110
- e(() => t.classList.toggle(n, r()));
111
- }), r.length > 0 && t.classList.add(...r);
112
- }
113
- function T(e, t) {
114
- t === "" ? e.removeAttribute("class") : e.setAttribute("class", t);
115
- }
116
- function E(e, t, n) {
117
- if (e) {
118
- if (typeof e == "string") for (let n of e.split(/\s+/)) n && t.push(n);
119
- else if (Array.isArray(e)) for (let r of e) E(r, t, n);
120
- else for (let [r, i] of Object.entries(e)) typeof i == "function" ? n ? n(r, i) : i() && t.push(r) : i && t.push(r);
121
- }
122
- }
123
- function D(e) {
124
- let t = [];
125
- return E(e, t), t.join(" ");
126
- }
127
- function O(t, n) {
128
- let r = t.style;
129
- if (typeof n == "function") {
130
- let t = [];
131
- e(() => {
132
- let e = n();
133
- if (typeof e == "string" || e == null) {
134
- r.cssText = e ?? "", t = [];
135
- return;
136
- }
137
- let i = Object.keys(e);
138
- for (let n of t) n in e || r.removeProperty(n);
139
- for (let t of i) A(r, t, k(e[t]));
140
- t = i;
141
- });
142
- } else if (typeof n == "string") r.cssText = n;
143
- else if (n != null) for (let [t, i] of Object.entries(n)) typeof i == "function" ? e(() => A(r, t, i())) : A(r, t, i);
144
- }
145
- function k(e) {
146
- return typeof e == "function" ? e() : e;
147
- }
148
- function A(e, t, n) {
149
- n == null || n === "" ? e.removeProperty(t) : e.setProperty(t, String(n));
150
- }
151
- // src/dom/element.ts
152
- function j(e) {
153
- return M(e, null);
154
- }
155
- function M(e, t) {
156
- return (n, r) => {
157
- let i = o.element(e, t);
158
- return N(n) ? (s(i, r), b(i, n), typeof n.ref == "function" && n.ref(i)) : n == null ? s(i, r) : s(i, n), i;
159
- };
160
- }
161
- function N(e) {
162
- return typeof e == "object" && !!e && !Array.isArray(e) && typeof e.nodeType != "number";
163
- }
164
- export { o as a, s as i, j as n, g as r, M as t };