@seahax/elemental 0.5.0 → 0.5.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 (101) hide show
  1. package/dist/{store.js → createStore.js} +3 -3
  2. package/dist/createStore.js.map +1 -0
  3. package/dist/{component.d.ts → defineComponent.d.ts} +6 -7
  4. package/dist/{component.js → defineComponent.js} +3 -3
  5. package/dist/defineComponent.js.map +1 -0
  6. package/dist/{router.d.ts → getRouter.d.ts} +3 -2
  7. package/dist/getRouter.js +33 -0
  8. package/dist/getRouter.js.map +1 -0
  9. package/dist/hooks/{async.d.ts → useAsync.d.ts} +1 -1
  10. package/dist/hooks/{async.js → useAsync.js} +4 -4
  11. package/dist/hooks/useAsync.js.map +1 -0
  12. package/dist/hooks/{attributes.d.ts → useAttributes.d.ts} +1 -1
  13. package/dist/hooks/useAttributes.js +37 -0
  14. package/dist/hooks/useAttributes.js.map +1 -0
  15. package/dist/hooks/useChildEffect.js +24 -0
  16. package/dist/hooks/useChildEffect.js.map +1 -0
  17. package/dist/hooks/useDisconnect.js +9 -0
  18. package/dist/hooks/useDisconnect.js.map +1 -0
  19. package/dist/hooks/{document.d.ts → useDocument.d.ts} +1 -1
  20. package/dist/hooks/useDocument.js +9 -0
  21. package/dist/hooks/useDocument.js.map +1 -0
  22. package/dist/hooks/{effect.d.ts → useEffect.d.ts} +1 -1
  23. package/dist/hooks/{effect.js → useEffect.js} +4 -4
  24. package/dist/hooks/useEffect.js.map +1 -0
  25. package/dist/hooks/useElementInternals.js +9 -0
  26. package/dist/hooks/useElementInternals.js.map +1 -0
  27. package/dist/hooks/{form.d.ts → useForm.d.ts} +1 -1
  28. package/dist/hooks/{form.js → useForm.js} +3 -3
  29. package/dist/hooks/useForm.js.map +1 -0
  30. package/dist/hooks/useHost.js +9 -0
  31. package/dist/hooks/useHost.js.map +1 -0
  32. package/dist/hooks/useInternalController.d.ts +3 -0
  33. package/dist/hooks/useInternalController.js +11 -0
  34. package/dist/hooks/useInternalController.js.map +1 -0
  35. package/dist/hooks/{parent.d.ts → useParent.d.ts} +1 -1
  36. package/dist/hooks/useParent.js +9 -0
  37. package/dist/hooks/useParent.js.map +1 -0
  38. package/dist/hooks/{ref.d.ts → useRef.d.ts} +1 -1
  39. package/dist/hooks/useRef.js +9 -0
  40. package/dist/hooks/useRef.js.map +1 -0
  41. package/dist/hooks/{route.d.ts → useRoute.d.ts} +1 -1
  42. package/dist/hooks/{route.js → useRoute.js} +6 -6
  43. package/dist/hooks/useRoute.js.map +1 -0
  44. package/dist/hooks/{store.d.ts → useStore.d.ts} +2 -2
  45. package/dist/hooks/{store.js → useStore.js} +4 -4
  46. package/dist/hooks/useStore.js.map +1 -0
  47. package/dist/html.d.ts +1 -1
  48. package/dist/html.js.map +1 -1
  49. package/dist/index.d.ts +15 -16
  50. package/dist/index.js +17 -18
  51. package/dist/internal/constants.d.ts +1 -0
  52. package/dist/internal/constants.js +6 -0
  53. package/dist/internal/constants.js.map +1 -0
  54. package/dist/internal/controllers.d.ts +2 -0
  55. package/dist/internal/controllers.js +6 -0
  56. package/dist/internal/controllers.js.map +1 -0
  57. package/dist/internal/{callbacks.js → createCallbacks.js} +2 -2
  58. package/dist/internal/createCallbacks.js.map +1 -0
  59. package/dist/internal/{controller.d.ts → createController.d.ts} +5 -5
  60. package/dist/internal/{controller.js → createController.js} +21 -20
  61. package/dist/internal/createController.js.map +1 -0
  62. package/dist/internal/getOrInsert.d.ts +4 -0
  63. package/dist/internal/getOrInsert.js +10 -0
  64. package/dist/internal/getOrInsert.js.map +1 -0
  65. package/package.json +7 -3
  66. package/dist/component.js.map +0 -1
  67. package/dist/hooks/async.js.map +0 -1
  68. package/dist/hooks/attributes.js +0 -25
  69. package/dist/hooks/attributes.js.map +0 -1
  70. package/dist/hooks/child.js +0 -14
  71. package/dist/hooks/child.js.map +0 -1
  72. package/dist/hooks/controller.d.ts +0 -3
  73. package/dist/hooks/controller.js +0 -11
  74. package/dist/hooks/controller.js.map +0 -1
  75. package/dist/hooks/disconnect.js +0 -9
  76. package/dist/hooks/disconnect.js.map +0 -1
  77. package/dist/hooks/document.js +0 -9
  78. package/dist/hooks/document.js.map +0 -1
  79. package/dist/hooks/effect.js.map +0 -1
  80. package/dist/hooks/form.js.map +0 -1
  81. package/dist/hooks/host.js +0 -9
  82. package/dist/hooks/host.js.map +0 -1
  83. package/dist/hooks/internals.js +0 -9
  84. package/dist/hooks/internals.js.map +0 -1
  85. package/dist/hooks/parent.js +0 -9
  86. package/dist/hooks/parent.js.map +0 -1
  87. package/dist/hooks/ref.js +0 -9
  88. package/dist/hooks/ref.js.map +0 -1
  89. package/dist/hooks/route.js.map +0 -1
  90. package/dist/hooks/store.js.map +0 -1
  91. package/dist/internal/callbacks.js.map +0 -1
  92. package/dist/internal/controller.js.map +0 -1
  93. package/dist/router.js +0 -35
  94. package/dist/router.js.map +0 -1
  95. package/dist/store.js.map +0 -1
  96. /package/dist/{store.d.ts → createStore.d.ts} +0 -0
  97. /package/dist/hooks/{child.d.ts → useChildEffect.d.ts} +0 -0
  98. /package/dist/hooks/{disconnect.d.ts → useDisconnect.d.ts} +0 -0
  99. /package/dist/hooks/{internals.d.ts → useElementInternals.d.ts} +0 -0
  100. /package/dist/hooks/{host.d.ts → useHost.d.ts} +0 -0
  101. /package/dist/internal/{callbacks.d.ts → createCallbacks.d.ts} +0 -0
@@ -1,5 +1,5 @@
1
- import { createCallbacks as e } from "./internal/callbacks.js";
2
- //#region src/store.ts
1
+ import { createCallbacks as e } from "./internal/createCallbacks.js";
2
+ //#region src/createStore.ts
3
3
  function t(t) {
4
4
  let n = e(), r = t;
5
5
  return {
@@ -15,4 +15,4 @@ function t(t) {
15
15
  //#endregion
16
16
  export { t as createStore };
17
17
 
18
- //# sourceMappingURL=store.js.map
18
+ //# sourceMappingURL=createStore.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createStore.js","names":[],"sources":["../src/createStore.ts"],"sourcesContent":["import { createCallbacks } from './internal/createCallbacks.ts';\n\nexport interface Store<TState> {\n state: TState;\n subscribe: (callback: (state: TState) => void) => () => void;\n}\n\n/** Create a new store containing an observable state. */\nexport function createStore<TState>(initialState: TState): Store<TState> {\n const callbacks = createCallbacks();\n let state = initialState;\n\n return {\n get state() {\n return state;\n },\n set state(newState) {\n if (newState === state) return;\n state = newState;\n callbacks.run();\n },\n subscribe: (callback) => callbacks.push(() => callback(state)),\n };\n}\n"],"mappings":";;AAQA,SAAgB,EAAoB,GAAqC;CACvE,IAAM,IAAY,GAAiB,EAC/B,IAAQ;AAEZ,QAAO;EACL,IAAI,QAAQ;AACV,UAAO;;EAET,IAAI,MAAM,GAAU;AACd,SAAa,MACjB,IAAQ,GACR,EAAU,KAAK;;EAEjB,YAAY,MAAa,EAAU,WAAW,EAAS,EAAM,CAAC;EAC/D"}
@@ -1,7 +1,6 @@
1
- import { type Ref } from './hooks/ref.ts';
2
- type SafeProps<TProps> = any extends any ? {
3
- [P in keyof TProps as P extends keyof HTMLElement ? never : P]: TProps[P];
4
- } : never;
1
+ import { type Ref } from './hooks/useRef.ts';
2
+ type UnsafeProps = 'connectedCallback' | 'connectedMoveCallback' | 'disconnectedCallback' | 'adoptedCallback' | 'formResetCallback' | 'formStateRestoreCallback' | 'formDisabledCallback';
3
+ type SafePropKeys<TProps> = Exclude<keyof TProps, keyof HTMLElement | UnsafeProps>;
5
4
  export interface ComponentConstructor<TProps extends object> {
6
5
  readonly formAssociated: boolean;
7
6
  new (): ComponentWithProps<TProps>;
@@ -15,7 +14,7 @@ export interface ComponentOptions<TProps extends object> {
15
14
  readonly formAssociated?: boolean;
16
15
  }
17
16
  export type ComponentPropDescriptors<TProps extends object> = {
18
- readonly [P in keyof SafeProps<TProps>]: ComponentPropDescriptorFactory<TProps[P]>;
17
+ readonly [P in SafePropKeys<TProps>]: ComponentPropDescriptorFactory<TProps[P]>;
19
18
  };
20
19
  export type ComponentPropDescriptorFactory<TType> = (ref: Ref<TType | undefined>, host: HTMLElement) => ComponentPropDescriptor<TType>;
21
20
  export interface ComponentPropDescriptor<T> extends Omit<PropertyDescriptor, 'value' | 'get' | 'set'> {
@@ -23,13 +22,13 @@ export interface ComponentPropDescriptor<T> extends Omit<PropertyDescriptor, 'va
23
22
  set?(value: T): void;
24
23
  }
25
24
  export type ComponentWithProps<TProps extends object> = HTMLElement & {
26
- -readonly [P in keyof SafeProps<TProps>]: TProps[P];
25
+ -readonly [P in SafePropKeys<TProps>]: TProps[P];
27
26
  };
28
27
  export type ComponentShadowRoot<TProps extends object> = Omit<ShadowRoot, 'host'> & {
29
28
  readonly host: ComponentWithProps<TProps>;
30
29
  };
31
30
  export type ComponentPropRefs<TProps extends object> = {
32
- readonly [P in keyof SafeProps<TProps>]: Ref<TProps[P] | undefined>;
31
+ readonly [P in SafePropKeys<TProps>]: Ref<TProps[P] | undefined>;
33
32
  };
34
33
  /** Define a custom `HTMLElement` that is functional and reactive. */
35
34
  export declare function defineComponent<TProps extends object = {}>(render: (shadowRoot: ComponentShadowRoot<TProps>, props: ComponentPropRefs<TProps>) => void, options?: ComponentOptions<TProps>): ComponentConstructor<TProps>;
@@ -1,5 +1,5 @@
1
- import { createController as e } from "./internal/controller.js";
2
- //#region src/component.ts
1
+ import { createController as e } from "./internal/createController.js";
2
+ //#region src/defineComponent.ts
3
3
  function t(t, { props: n, shadow: r, formAssociated: i = !1 } = {}) {
4
4
  return class extends HTMLElement {
5
5
  static formAssociated = i;
@@ -54,4 +54,4 @@ function t(t, { props: n, shadow: r, formAssociated: i = !1 } = {}) {
54
54
  //#endregion
55
55
  export { t as defineComponent };
56
56
 
57
- //# sourceMappingURL=component.js.map
57
+ //# sourceMappingURL=defineComponent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"defineComponent.js","names":["#shadow","#controller","#props"],"sources":["../src/defineComponent.ts"],"sourcesContent":["import { type Ref } from './hooks/useRef.ts';\nimport { type Controller, createController } from './internal/createController.ts';\n\ntype UnsafeProps =\n | 'connectedCallback'\n | 'connectedMoveCallback'\n | 'disconnectedCallback'\n | 'adoptedCallback'\n | 'formResetCallback'\n | 'formStateRestoreCallback'\n | 'formDisabledCallback';\n\ntype SafePropKeys<TProps> = Exclude<keyof TProps, keyof HTMLElement | UnsafeProps>;\n\nexport interface ComponentConstructor<TProps extends object> {\n readonly formAssociated: boolean;\n new (): ComponentWithProps<TProps>;\n}\n\nexport interface ComponentOptions<TProps extends object> {\n /** Shadow root attachment options. */\n readonly shadow?: Partial<ShadowRootInit>;\n /** Component custom property descriptors. */\n readonly props?: ComponentPropDescriptors<TProps>;\n /** True to mark the component as form-associated. */\n readonly formAssociated?: boolean;\n}\n\nexport type ComponentPropDescriptors<TProps extends object> = {\n readonly [P in SafePropKeys<TProps>]: ComponentPropDescriptorFactory<TProps[P]>;\n};\n\nexport type ComponentPropDescriptorFactory<TType> = (\n ref: Ref<TType | undefined>,\n host: HTMLElement,\n) => ComponentPropDescriptor<TType>;\n\nexport interface ComponentPropDescriptor<T> extends Omit<PropertyDescriptor, 'value' | 'get' | 'set'> {\n get(): T;\n set?(value: T): void;\n}\n\nexport type ComponentWithProps<TProps extends object> = HTMLElement & {\n -readonly [P in SafePropKeys<TProps>]: TProps[P];\n};\n\nexport type ComponentShadowRoot<TProps extends object> = Omit<ShadowRoot, 'host'> & {\n readonly host: ComponentWithProps<TProps>;\n};\n\nexport type ComponentPropRefs<TProps extends object> = {\n readonly [P in SafePropKeys<TProps>]: Ref<TProps[P] | undefined>;\n};\n\n/** Define a custom `HTMLElement` that is functional and reactive. */\nexport function defineComponent<TProps extends object = {}>(\n render: (shadowRoot: ComponentShadowRoot<TProps>, props: ComponentPropRefs<TProps>) => void,\n options?: ComponentOptions<TProps>,\n): ComponentConstructor<TProps>;\nexport function defineComponent(\n render: (\n shadowRoot: ComponentShadowRoot<Record<string, unknown>>,\n props: ComponentPropRefs<Record<string, unknown>>,\n ) => void,\n { props, shadow, formAssociated = false }: ComponentOptions<Record<string, unknown>> = {},\n): ComponentConstructor<{}> {\n return class extends HTMLElement {\n static readonly formAssociated = formAssociated;\n\n readonly #shadow: ComponentShadowRoot<Record<string, unknown>>;\n readonly #controller: Controller;\n readonly #props: ComponentPropRefs<Record<string, unknown>> = {};\n\n constructor() {\n super();\n\n this.#shadow = this.attachShadow({\n ...shadow,\n mode: shadow?.mode ?? 'open',\n }) as ComponentShadowRoot<Record<string, unknown>>;\n\n this.#controller = createController({\n host: this,\n formAssociated,\n render: () => render(this.#shadow, this.#props),\n attachInternals: () => super.attachInternals(),\n });\n\n if (props) {\n const propRefs: Record<string, Ref<unknown>> = this.#props;\n\n for (const [key, getDescriptor] of Object.entries(props)) {\n if (key in this) continue;\n const ref = (propRefs[key] = this.#controller.createRef<any>(undefined));\n const descriptor = getDescriptor(ref, this);\n Object.defineProperty(this, key, descriptor);\n }\n }\n\n if (formAssociated) {\n this.attachInternals();\n }\n }\n\n override attachInternals(): ElementInternals {\n return this.#controller.attachInternals();\n }\n\n protected connectedCallback(): void {\n this.#controller.connectedCallback();\n }\n\n protected connectedMoveCallback(): void {\n this.#controller.connectedMoveCallback();\n }\n\n protected disconnectedCallback(): void {\n this.#controller.disconnectedCallback();\n }\n\n protected adoptedCallback(): void {\n this.#controller.adoptedCallback();\n }\n\n protected formDisabledCallback(disabled: boolean): void {\n this.#controller.formDisabledCallback(disabled);\n }\n\n protected formResetCallback(): void {\n this.#controller.formResetCallback();\n }\n\n protected formStateRestoreCallback(state: string | File | FormData, reason: 'restore' | 'autocomplete'): void {\n this.#controller.formStateRestoreCallback(state, reason);\n }\n };\n}\n"],"mappings":";;AA2DA,SAAgB,EACd,GAIA,EAAE,UAAO,WAAQ,oBAAiB,OAAqD,EAAE,EAC/D;AAC1B,QAAO,cAAc,YAAY;EAC/B,OAAgB,iBAAiB;EAEjC;EACA;EACA,KAA8D,EAAE;EAEhE,cAAc;AAeZ,OAdA,OAAO,EAEP,MAAA,IAAe,KAAK,aAAa;IAC/B,GAAG;IACH,MAAM,GAAQ,QAAQ;IACvB,CAAC,EAEF,MAAA,IAAmB,EAAiB;IAClC,MAAM;IACN;IACA,cAAc,EAAO,MAAA,GAAc,MAAA,EAAY;IAC/C,uBAAuB,MAAM,iBAAiB;IAC/C,CAAC,EAEE,GAAO;IACT,IAAM,IAAyC,MAAA;AAE/C,SAAK,IAAM,CAAC,GAAK,MAAkB,OAAO,QAAQ,EAAM,EAAE;AACxD,SAAI,KAAO,KAAM;KAEjB,IAAM,IAAa,EAAc,EADX,KAAO,MAAA,EAAiB,UAAe,KAAA,EAAU,EACjC,KAAK;AAC3C,YAAO,eAAe,MAAM,GAAK,EAAW;;;AAIhD,GAAI,KACF,KAAK,iBAAiB;;EAI1B,kBAA6C;AAC3C,UAAO,MAAA,EAAiB,iBAAiB;;EAG3C,oBAAoC;AAClC,SAAA,EAAiB,mBAAmB;;EAGtC,wBAAwC;AACtC,SAAA,EAAiB,uBAAuB;;EAG1C,uBAAuC;AACrC,SAAA,EAAiB,sBAAsB;;EAGzC,kBAAkC;AAChC,SAAA,EAAiB,iBAAiB;;EAGpC,qBAA+B,GAAyB;AACtD,SAAA,EAAiB,qBAAqB,EAAS;;EAGjD,oBAAoC;AAClC,SAAA,EAAiB,mBAAmB;;EAGtC,yBAAmC,GAAiC,GAA0C;AAC5G,SAAA,EAAiB,yBAAyB,GAAO,EAAO"}
@@ -1,5 +1,5 @@
1
- import { type Store } from './store.ts';
2
- export interface RouterState {
1
+ import { type Store } from './createStore.ts';
2
+ interface RouterState {
3
3
  readonly pathname: string;
4
4
  readonly hash: string;
5
5
  }
@@ -9,3 +9,4 @@ export interface RouterState {
9
9
  * called (ie. a singleton).
10
10
  */
11
11
  export declare function getRouter(): Store<RouterState>;
12
+ export {};
@@ -0,0 +1,33 @@
1
+ import { createStore as e } from "./createStore.js";
2
+ //#region src/getRouter.ts
3
+ var t;
4
+ function n() {
5
+ if (t) return t;
6
+ let n = e({
7
+ pathname: window.location.pathname,
8
+ hash: window.location.hash
9
+ }), r = () => {
10
+ let e = n.state;
11
+ n.state.pathname !== window.location.pathname && (e = {
12
+ ...e,
13
+ pathname: window.location.pathname
14
+ }), n.state.hash !== window.location.hash && (e = {
15
+ ...e,
16
+ hash: window.location.hash
17
+ }), n.state = e;
18
+ };
19
+ return Object.defineProperties(history, Object.fromEntries(["pushState", "replaceState"].map((e) => {
20
+ let t = history[e].bind(history);
21
+ return [e, {
22
+ value: (...e) => {
23
+ t(...e), r();
24
+ },
25
+ enumerable: !0,
26
+ configurable: !0
27
+ }];
28
+ }))), window.addEventListener("popstate", r), t = n, t;
29
+ }
30
+ //#endregion
31
+ export { n as getRouter };
32
+
33
+ //# sourceMappingURL=getRouter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getRouter.js","names":[],"sources":["../src/getRouter.ts"],"sourcesContent":["import { createStore, type Store } from './createStore.ts';\n\ninterface RouterState {\n readonly pathname: string;\n readonly hash: string;\n}\n\nlet singleton: Store<RouterState> | undefined;\n\n/**\n * Get a router {@link Store} that is updated when the client side route (aka:\n * `History`) changes. This method returns the same store every time it is\n * called (ie. a singleton).\n */\nexport function getRouter(): Store<RouterState> {\n if (singleton) return singleton;\n\n const store = createStore<RouterState>({\n pathname: window.location.pathname,\n hash: window.location.hash,\n });\n\n const onUpdate = (): void => {\n let state = store.state;\n\n if (store.state.pathname !== window.location.pathname) {\n state = { ...state, pathname: window.location.pathname };\n }\n\n if (store.state.hash !== window.location.hash) {\n state = { ...state, hash: window.location.hash };\n }\n\n store.state = state;\n };\n\n Object.defineProperties(\n history,\n Object.fromEntries(\n (['pushState', 'replaceState'] as const).map((method: 'pushState' | 'replaceState') => {\n const original = history[method].bind(history) as History['pushState'] & History['replaceState'];\n const descriptor: PropertyDescriptor = {\n value: (...args: Parameters<typeof original>) => {\n original(...args);\n onUpdate();\n },\n enumerable: true,\n configurable: true,\n };\n\n return [method, descriptor];\n }),\n ),\n );\n\n window.addEventListener('popstate', onUpdate);\n singleton = store;\n return singleton;\n}\n"],"mappings":";;AAOA,IAAI;AAOJ,SAAgB,IAAgC;AAC9C,KAAI,EAAW,QAAO;CAEtB,IAAM,IAAQ,EAAyB;EACrC,UAAU,OAAO,SAAS;EAC1B,MAAM,OAAO,SAAS;EACvB,CAAC,EAEI,UAAuB;EAC3B,IAAI,IAAQ,EAAM;AAUlB,EARI,EAAM,MAAM,aAAa,OAAO,SAAS,aAC3C,IAAQ;GAAE,GAAG;GAAO,UAAU,OAAO,SAAS;GAAU,GAGtD,EAAM,MAAM,SAAS,OAAO,SAAS,SACvC,IAAQ;GAAE,GAAG;GAAO,MAAM,OAAO,SAAS;GAAM,GAGlD,EAAM,QAAQ;;AAwBhB,QArBA,OAAO,iBACL,SACA,OAAO,YACJ,CAAC,aAAa,eAAe,CAAW,KAAK,MAAyC;EACrF,IAAM,IAAW,QAAQ,GAAQ,KAAK,QAAQ;AAU9C,SAAO,CAAC,GAAQ;GARd,QAAQ,GAAG,MAAsC;AAE/C,IADA,EAAS,GAAG,EAAK,EACjB,GAAU;;GAEZ,YAAY;GACZ,cAAc;GAGA,CAAW;GAC3B,CACH,CACF,EAED,OAAO,iBAAiB,YAAY,EAAS,EAC7C,IAAY,GACL"}
@@ -1,4 +1,4 @@
1
- import { type ReadonlyRef, type Ref, type RefValues } from './ref.ts';
1
+ import { type ReadonlyRef, type Ref, type RefValues } from './useRef.ts';
2
2
  export interface AsyncValue<TValue> {
3
3
  readonly value: TValue | undefined;
4
4
  readonly error: unknown;
@@ -1,6 +1,6 @@
1
- import { useRef as e } from "./ref.js";
2
- import { useEffect as t } from "./effect.js";
3
- //#region src/hooks/async.ts
1
+ import { useRef as e } from "./useRef.js";
2
+ import { useEffect as t } from "./useEffect.js";
3
+ //#region src/hooks/useAsync.ts
4
4
  function n(n, r, { debounceMs: i } = {}) {
5
5
  let a = e({
6
6
  value: void 0,
@@ -29,4 +29,4 @@ function n(n, r, { debounceMs: i } = {}) {
29
29
  //#endregion
30
30
  export { n as useAsync };
31
31
 
32
- //# sourceMappingURL=async.js.map
32
+ //# sourceMappingURL=useAsync.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useAsync.js","names":[],"sources":["../../src/hooks/useAsync.ts"],"sourcesContent":["import { useEffect } from './useEffect.ts';\nimport { type ReadonlyRef, type Ref, type RefValues, useRef } from './useRef.ts';\n\nexport interface AsyncValue<TValue> {\n readonly value: TValue | undefined;\n readonly error: unknown;\n readonly isLoading: boolean;\n}\n\nexport interface AsyncOptions {\n readonly debounceMs?: number;\n}\n\n/** Use a reference (reactive state) bound to an async loader function. */\nexport function useAsync<const TDeps extends readonly ReadonlyRef<any>[], TValue>(\n deps: TDeps,\n callback: (signal: AbortSignal, ...values: RefValues<TDeps>) => Promise<TValue>,\n { debounceMs }: AsyncOptions = {},\n): Ref<AsyncValue<TValue>> {\n const ref = useRef<AsyncValue<TValue>>({ value: undefined, error: undefined, isLoading: true });\n let skipDebounce = true;\n\n useEffect(deps, () => (...values) => {\n const ac = new AbortController();\n\n Promise.race(\n skipDebounce\n ? [Promise.resolve()]\n : [\n new Promise((resolve) => setTimeout(resolve, debounceMs)),\n new Promise((resolve) => ac.signal.addEventListener('abort', resolve, { once: true })),\n ],\n )\n .then(() => {\n if (ac.signal.aborted) return;\n return callback(ac.signal, ...(values as any));\n })\n .then((value) => {\n if (ac.signal.aborted) return;\n ref.value = { isLoading: false, value, error: undefined };\n })\n .catch((error: unknown) => {\n if (ac.signal.aborted) return;\n ref.value = { isLoading: false, value: undefined, error };\n });\n\n skipDebounce = false;\n return () => ac.abort();\n });\n\n // Skip the debounce again if the component unmounts.\n useEffect([], () => () => (skipDebounce = true));\n\n return ref;\n}\n"],"mappings":";;;AAcA,SAAgB,EACd,GACA,GACA,EAAE,kBAA6B,EAAE,EACR;CACzB,IAAM,IAAM,EAA2B;EAAE,OAAO,KAAA;EAAW,OAAO,KAAA;EAAW,WAAW;EAAM,CAAC,EAC3F,IAAe;AAiCnB,QA/BA,EAAU,UAAa,GAAG,MAAW;EACnC,IAAM,IAAK,IAAI,iBAAiB;AAwBhC,SAtBA,QAAQ,KACN,IACI,CAAC,QAAQ,SAAS,CAAC,GACnB,CACE,IAAI,SAAS,MAAY,WAAW,GAAS,EAAW,CAAC,EACzD,IAAI,SAAS,MAAY,EAAG,OAAO,iBAAiB,SAAS,GAAS,EAAE,MAAM,IAAM,CAAC,CAAC,CACvF,CACN,CACE,WAAW;AACN,UAAG,OAAO,QACd,QAAO,EAAS,EAAG,QAAQ,GAAI,EAAe;IAC9C,CACD,MAAM,MAAU;AACX,KAAG,OAAO,YACd,EAAI,QAAQ;IAAE,WAAW;IAAO;IAAO,OAAO,KAAA;IAAW;IACzD,CACD,OAAO,MAAmB;AACrB,KAAG,OAAO,YACd,EAAI,QAAQ;IAAE,WAAW;IAAO,OAAO,KAAA;IAAW;IAAO;IACzD,EAEJ,IAAe,UACF,EAAG,OAAO;GACvB,EAGF,EAAU,EAAE,cAAe,IAAe,GAAM,EAEzC"}
@@ -1,4 +1,4 @@
1
- import { type Ref } from './ref.ts';
1
+ import { type Ref } from './useRef.ts';
2
2
  /** Use references (reactive state) bound to attributes. */
3
3
  export declare function useAttributes<const TNames extends string[]>(...names: TNames): {
4
4
  -readonly [P in keyof TNames]: Ref<string | null>;
@@ -0,0 +1,37 @@
1
+ import { useInternalController as e } from "./useInternalController.js";
2
+ import { useRef as t } from "./useRef.js";
3
+ import { getOrInsert as n } from "../internal/getOrInsert.js";
4
+ import { useHost as r } from "./useHost.js";
5
+ //#region src/hooks/useAttributes.ts
6
+ var i = /* @__PURE__ */ new WeakMap();
7
+ function a(...a) {
8
+ if (a.length === 0) return {};
9
+ let o = r(), s = [], c = n(i, o, (t) => {
10
+ let { onAfterRender: n, onDisconnect: r } = e(), a = /* @__PURE__ */ new Map();
11
+ return i.set(t, a), n.push(() => {
12
+ i.delete(t);
13
+ let e = new MutationObserver((e) => {
14
+ for (let { attributeName: n } of e) {
15
+ if (n == null) continue;
16
+ let e = a.get(n);
17
+ e && (e.value = t.getAttribute(n));
18
+ }
19
+ });
20
+ e.observe(t, {
21
+ attributeFilter: [...a.keys()],
22
+ attributes: !0
23
+ }), r.push(() => e.disconnect());
24
+ }), a;
25
+ });
26
+ for (let e of a) {
27
+ let r = n(c, e, (e) => t(o.getAttribute(e), (t) => {
28
+ t == null ? o.removeAttribute(e) : o.setAttribute(e, t);
29
+ }));
30
+ s.push(r);
31
+ }
32
+ return s;
33
+ }
34
+ //#endregion
35
+ export { a as useAttributes };
36
+
37
+ //# sourceMappingURL=useAttributes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useAttributes.js","names":[],"sources":["../../src/hooks/useAttributes.ts"],"sourcesContent":["import { getOrInsert } from '../internal/getOrInsert.ts';\nimport { useHost } from './useHost.ts';\nimport { useInternalController } from './useInternalController.ts';\nimport { type Ref, useRef } from './useRef.ts';\n\nconst hostRefMaps = new WeakMap<HTMLElement, Map<string, Ref<string | null>>>();\n\n/** Use references (reactive state) bound to attributes. */\nexport function useAttributes<const TNames extends string[]>(\n ...names: TNames\n): { -readonly [P in keyof TNames]: Ref<string | null> } {\n if (names.length === 0) return {} as any;\n const host = useHost();\n const refs: Ref<string | null>[] = [];\n const refMap = getOrInsert(hostRefMaps, host, (host) => {\n const { onAfterRender, onDisconnect } = useInternalController();\n const refMap = new Map<string, Ref<string | null>>();\n hostRefMaps.set(host, refMap);\n\n onAfterRender.push(() => {\n hostRefMaps.delete(host);\n\n const observer = new MutationObserver((mutation) => {\n for (const { attributeName } of mutation) {\n if (attributeName == null) continue;\n const ref = refMap.get(attributeName);\n if (ref) ref.value = host.getAttribute(attributeName);\n }\n });\n\n observer.observe(host, { attributeFilter: [...refMap.keys()], attributes: true });\n onDisconnect.push(() => observer.disconnect());\n });\n\n return refMap;\n });\n\n for (const name of names) {\n const ref = getOrInsert(refMap, name, (name) => {\n return useRef(host.getAttribute(name), (value) => {\n if (value == null) host.removeAttribute(name);\n else host.setAttribute(name, value);\n });\n });\n\n refs.push(ref);\n }\n\n return refs as any;\n}\n"],"mappings":";;;;;AAKA,IAAM,oBAAc,IAAI,SAAuD;AAG/E,SAAgB,EACd,GAAG,GACoD;AACvD,KAAI,EAAM,WAAW,EAAG,QAAO,EAAE;CACjC,IAAM,IAAO,GAAS,EAChB,IAA6B,EAAE,EAC/B,IAAS,EAAY,GAAa,IAAO,MAAS;EACtD,IAAM,EAAE,kBAAe,oBAAiB,GAAuB,EACzD,oBAAS,IAAI,KAAiC;AAkBpD,SAjBA,EAAY,IAAI,GAAM,EAAO,EAE7B,EAAc,WAAW;AACvB,KAAY,OAAO,EAAK;GAExB,IAAM,IAAW,IAAI,kBAAkB,MAAa;AAClD,SAAK,IAAM,EAAE,sBAAmB,GAAU;AACxC,SAAI,KAAiB,KAAM;KAC3B,IAAM,IAAM,EAAO,IAAI,EAAc;AACrC,KAAI,MAAK,EAAI,QAAQ,EAAK,aAAa,EAAc;;KAEvD;AAGF,GADA,EAAS,QAAQ,GAAM;IAAE,iBAAiB,CAAC,GAAG,EAAO,MAAM,CAAC;IAAE,YAAY;IAAM,CAAC,EACjF,EAAa,WAAW,EAAS,YAAY,CAAC;IAC9C,EAEK;GACP;AAEF,MAAK,IAAM,KAAQ,GAAO;EACxB,IAAM,IAAM,EAAY,GAAQ,IAAO,MAC9B,EAAO,EAAK,aAAa,EAAK,GAAG,MAAU;AAChD,GAAI,KAAS,OAAM,EAAK,gBAAgB,EAAK,GACxC,EAAK,aAAa,GAAM,EAAM;IACnC,CACF;AAEF,IAAK,KAAK,EAAI;;AAGhB,QAAO"}
@@ -0,0 +1,24 @@
1
+ import { useInternalController as e } from "./useInternalController.js";
2
+ import { useRef as t } from "./useRef.js";
3
+ import { useEffect as n } from "./useEffect.js";
4
+ import { getOrInsert as r } from "../internal/getOrInsert.js";
5
+ import { useHost as i } from "./useHost.js";
6
+ //#region src/hooks/useChildEffect.ts
7
+ var a = /* @__PURE__ */ new WeakMap();
8
+ function o(o) {
9
+ let s = i();
10
+ n([r(a, s, () => {
11
+ let { onAfterRender: n, onDisconnect: r } = e(), i = t({});
12
+ return n.push(() => {
13
+ a.delete(s);
14
+ let e = new MutationObserver(() => {
15
+ i.value = {};
16
+ });
17
+ e.observe(s, { childList: !0 }), r.push(() => e.disconnect());
18
+ }), i;
19
+ })], () => o());
20
+ }
21
+ //#endregion
22
+ export { o as useChildEffect };
23
+
24
+ //# sourceMappingURL=useChildEffect.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useChildEffect.js","names":[],"sources":["../../src/hooks/useChildEffect.ts"],"sourcesContent":["import { getOrInsert } from '../internal/getOrInsert.ts';\nimport { useEffect } from './useEffect.ts';\nimport { useHost } from './useHost.ts';\nimport { useInternalController } from './useInternalController.ts';\nimport { type Ref, useRef } from './useRef.ts';\n\nconst hostRefs = new WeakMap<HTMLElement, Ref<{}>>();\n\n/** React to child list changes (non-recursive). */\nexport function useChildEffect(callback: () => (() => void) | void): void {\n const host = useHost();\n const ref = getOrInsert(hostRefs, host, () => {\n const { onAfterRender, onDisconnect } = useInternalController();\n const ref = useRef({});\n\n onAfterRender.push(() => {\n hostRefs.delete(host);\n\n const observer = new MutationObserver(() => {\n ref.value = {};\n });\n\n observer.observe(host, { childList: true });\n onDisconnect.push(() => observer.disconnect());\n });\n\n return ref;\n });\n\n useEffect([ref], () => callback());\n}\n"],"mappings":";;;;;;AAMA,IAAM,oBAAW,IAAI,SAA+B;AAGpD,SAAgB,EAAe,GAA2C;CACxE,IAAM,IAAO,GAAS;AAmBtB,GAAU,CAlBE,EAAY,GAAU,SAAY;EAC5C,IAAM,EAAE,kBAAe,oBAAiB,GAAuB,EACzD,IAAM,EAAO,EAAE,CAAC;AAatB,SAXA,EAAc,WAAW;AACvB,KAAS,OAAO,EAAK;GAErB,IAAM,IAAW,IAAI,uBAAuB;AAC1C,MAAI,QAAQ,EAAE;KACd;AAGF,GADA,EAAS,QAAQ,GAAM,EAAE,WAAW,IAAM,CAAC,EAC3C,EAAa,WAAW,EAAS,YAAY,CAAC;IAC9C,EAEK;GAGE,CAAI,QAAQ,GAAU,CAAC"}
@@ -0,0 +1,9 @@
1
+ import { useInternalController as e } from "./useInternalController.js";
2
+ //#region src/hooks/useDisconnect.ts
3
+ function t(t) {
4
+ e().onDisconnect.push(t);
5
+ }
6
+ //#endregion
7
+ export { t as useDisconnectCallback };
8
+
9
+ //# sourceMappingURL=useDisconnect.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useDisconnect.js","names":[],"sources":["../../src/hooks/useDisconnect.ts"],"sourcesContent":["import { useInternalController } from './useInternalController.ts';\n\n/** Register a callback for disconnections. */\nexport function useDisconnectCallback(callback: () => void): void {\n useInternalController().onDisconnect.push(callback);\n}\n"],"mappings":";;AAGA,SAAgB,EAAsB,GAA4B;AAChE,IAAuB,CAAC,aAAa,KAAK,EAAS"}
@@ -1,3 +1,3 @@
1
- import type { ReadonlyRef } from './ref.ts';
1
+ import type { ReadonlyRef } from './useRef.ts';
2
2
  /** Use a reference (reactive state) bound to the owner document. */
3
3
  export declare function useDocument(): ReadonlyRef<Document>;
@@ -0,0 +1,9 @@
1
+ import { useInternalController as e } from "./useInternalController.js";
2
+ //#region src/hooks/useDocument.ts
3
+ function t() {
4
+ return e().refDocument;
5
+ }
6
+ //#endregion
7
+ export { t as useDocument };
8
+
9
+ //# sourceMappingURL=useDocument.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useDocument.js","names":[],"sources":["../../src/hooks/useDocument.ts"],"sourcesContent":["import { useInternalController } from './useInternalController.ts';\nimport type { ReadonlyRef } from './useRef.ts';\n\n/** Use a reference (reactive state) bound to the owner document. */\nexport function useDocument(): ReadonlyRef<Document> {\n return useInternalController().refDocument;\n}\n"],"mappings":";;AAIA,SAAgB,IAAqC;AACnD,QAAO,GAAuB,CAAC"}
@@ -1,3 +1,3 @@
1
- import type { ReadonlyRef, RefValues } from './ref.ts';
1
+ import type { ReadonlyRef, RefValues } from './useRef.ts';
2
2
  /** React to observable (reference) changes. */
3
3
  export declare function useEffect<const TDeps extends readonly ReadonlyRef<any>[]>(deps: TDeps, callback: (...values: RefValues<TDeps>) => (() => void) | void): void;
@@ -1,6 +1,6 @@
1
- import { useController as e } from "./controller.js";
2
- import { useDisconnectCallback as t } from "./disconnect.js";
3
- //#region src/hooks/effect.ts
1
+ import { useInternalController as e } from "./useInternalController.js";
2
+ import { useDisconnectCallback as t } from "./useDisconnect.js";
3
+ //#region src/hooks/useEffect.ts
4
4
  function n(n, r) {
5
5
  let i, a, o = () => {
6
6
  let e = i;
@@ -14,4 +14,4 @@ function n(n, r) {
14
14
  //#endregion
15
15
  export { n as useEffect };
16
16
 
17
- //# sourceMappingURL=effect.js.map
17
+ //# sourceMappingURL=useEffect.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useEffect.js","names":[],"sources":["../../src/hooks/useEffect.ts"],"sourcesContent":["import { useDisconnectCallback } from './useDisconnect.ts';\nimport { useInternalController } from './useInternalController.ts';\nimport type { ReadonlyRef, RefValues } from './useRef.ts';\n\n/** React to observable (reference) changes. */\nexport function useEffect<const TDeps extends readonly ReadonlyRef<any>[]>(\n deps: TDeps,\n callback: (...values: RefValues<TDeps>) => (() => void) | void,\n): void {\n let cleanupCallback: (() => void) | void;\n let values: any[] | undefined;\n\n const cleanup = () => {\n const callback = cleanupCallback;\n cleanupCallback = undefined;\n callback?.();\n };\n\n useInternalController().onNotify.push((): void => {\n const newValues = deps.map((dep) => dep.value);\n if (values?.length === newValues.length && values?.every((value, i) => value === newValues[i])) return;\n values = newValues;\n cleanup();\n cleanupCallback = callback(...(values as any));\n });\n\n useDisconnectCallback(cleanup);\n}\n"],"mappings":";;;AAKA,SAAgB,EACd,GACA,GACM;CACN,IAAI,GACA,GAEE,UAAgB;EACpB,IAAM,IAAW;AAEjB,EADA,IAAkB,KAAA,GAClB,KAAY;;AAWd,CARA,GAAuB,CAAC,SAAS,WAAiB;EAChD,IAAM,IAAY,EAAK,KAAK,MAAQ,EAAI,MAAM;AAC1C,KAAQ,WAAW,EAAU,UAAU,GAAQ,OAAO,GAAO,MAAM,MAAU,EAAU,GAAG,KAC9F,IAAS,GACT,GAAS,EACT,IAAkB,EAAS,GAAI,EAAe;GAC9C,EAEF,EAAsB,EAAQ"}
@@ -0,0 +1,9 @@
1
+ import { useInternalController as e } from "./useInternalController.js";
2
+ //#region src/hooks/useElementInternals.ts
3
+ function t() {
4
+ return e().attachInternals();
5
+ }
6
+ //#endregion
7
+ export { t as useElementInternals };
8
+
9
+ //# sourceMappingURL=useElementInternals.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useElementInternals.js","names":[],"sources":["../../src/hooks/useElementInternals.ts"],"sourcesContent":["import { useInternalController } from './useInternalController.ts';\n\n/** Use the element internals. */\nexport function useElementInternals(): ElementInternals {\n return useInternalController().attachInternals();\n}\n"],"mappings":";;AAGA,SAAgB,IAAwC;AACtD,QAAO,GAAuB,CAAC,iBAAiB"}
@@ -1,4 +1,4 @@
1
- import type { ReadonlyRef } from './ref.ts';
1
+ import type { ReadonlyRef } from './useRef.ts';
2
2
  /** Use a reference (reactive state) bound to the associated form. */
3
3
  export declare function useForm(): ReadonlyRef<HTMLFormElement | null>;
4
4
  /** Use a reference (reactive state) bound to the form disabled state. */
@@ -1,5 +1,5 @@
1
- import { useController as e } from "./controller.js";
2
- //#region src/hooks/form.ts
1
+ import { useInternalController as e } from "./useInternalController.js";
2
+ //#region src/hooks/useForm.ts
3
3
  function t() {
4
4
  return a().refForm;
5
5
  }
@@ -20,4 +20,4 @@ function a() {
20
20
  //#endregion
21
21
  export { t as useForm, n as useFormDisabled, r as useFormResetCallback, i as useFormRestoreCallback };
22
22
 
23
- //# sourceMappingURL=form.js.map
23
+ //# sourceMappingURL=useForm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useForm.js","names":[],"sources":["../../src/hooks/useForm.ts"],"sourcesContent":["import type { Controller } from '../internal/createController.ts';\nimport { useInternalController } from './useInternalController.ts';\nimport type { ReadonlyRef } from './useRef.ts';\n\n/** Use a reference (reactive state) bound to the associated form. */\nexport function useForm(): ReadonlyRef<HTMLFormElement | null> {\n return useInternalFormAssociatedController().refForm;\n}\n\n/** Use a reference (reactive state) bound to the form disabled state. */\nexport function useFormDisabled(): ReadonlyRef<boolean> {\n return useInternalFormAssociatedController().refDisabled;\n}\n\n/** Register a callback for form resets. */\nexport function useFormResetCallback(callback: () => void): void {\n useInternalFormAssociatedController().onReset.push(callback);\n}\n\n/** Register a callback for form restorations. */\nexport function useFormRestoreCallback(\n callback: (state: string | File | FormData, reason: 'restore' | 'autocomplete') => void,\n): void {\n useInternalFormAssociatedController().onRestore.push(callback);\n}\n\nfunction useInternalFormAssociatedController(): Controller['formAssociated'] & {} {\n const { formAssociated } = useInternalController();\n if (!formAssociated) throw new Error('form hooks must be called in a form-associated component');\n return formAssociated;\n}\n"],"mappings":";;AAKA,SAAgB,IAA+C;AAC7D,QAAO,GAAqC,CAAC;;AAI/C,SAAgB,IAAwC;AACtD,QAAO,GAAqC,CAAC;;AAI/C,SAAgB,EAAqB,GAA4B;AAC/D,IAAqC,CAAC,QAAQ,KAAK,EAAS;;AAI9D,SAAgB,EACd,GACM;AACN,IAAqC,CAAC,UAAU,KAAK,EAAS;;AAGhE,SAAS,IAAyE;CAChF,IAAM,EAAE,sBAAmB,GAAuB;AAClD,KAAI,CAAC,EAAgB,OAAU,MAAM,2DAA2D;AAChG,QAAO"}
@@ -0,0 +1,9 @@
1
+ import { useInternalController as e } from "./useInternalController.js";
2
+ //#region src/hooks/useHost.ts
3
+ function t() {
4
+ return e().host;
5
+ }
6
+ //#endregion
7
+ export { t as useHost };
8
+
9
+ //# sourceMappingURL=useHost.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useHost.js","names":[],"sources":["../../src/hooks/useHost.ts"],"sourcesContent":["import { useInternalController } from './useInternalController.ts';\n\n/** Use the component host element. */\nexport function useHost(): HTMLElement {\n return useInternalController().host;\n}\n"],"mappings":";;AAGA,SAAgB,IAAuB;AACrC,QAAO,GAAuB,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { type Controller } from '../internal/createController.ts';
2
+ /** @internal Get the controller of the currently rendering component. */
3
+ export declare function useInternalController(): Controller;
@@ -0,0 +1,11 @@
1
+ import { controllers as e } from "../internal/controllers.js";
2
+ //#region src/hooks/useInternalController.ts
3
+ function t() {
4
+ let t = e.at(-1);
5
+ if (!t) throw Error("hooks must be called by a render function");
6
+ return t;
7
+ }
8
+ //#endregion
9
+ export { t as useInternalController };
10
+
11
+ //# sourceMappingURL=useInternalController.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useInternalController.js","names":[],"sources":["../../src/hooks/useInternalController.ts"],"sourcesContent":["import { controllers } from '../internal/controllers.ts';\nimport { type Controller } from '../internal/createController.ts';\n\n/** @internal Get the controller of the currently rendering component. */\nexport function useInternalController(): Controller {\n const controller = controllers.at(-1);\n if (!controller) throw new Error('hooks must be called by a render function');\n return controller;\n}\n"],"mappings":";;AAIA,SAAgB,IAAoC;CAClD,IAAM,IAAa,EAAY,GAAG,GAAG;AACrC,KAAI,CAAC,EAAY,OAAU,MAAM,4CAA4C;AAC7E,QAAO"}
@@ -1,3 +1,3 @@
1
- import type { ReadonlyRef } from './ref.ts';
1
+ import type { ReadonlyRef } from './useRef.ts';
2
2
  /** Use a reference (reactive state) bound to the parent node. */
3
3
  export declare function useParent(): ReadonlyRef<ParentNode | null>;
@@ -0,0 +1,9 @@
1
+ import { useInternalController as e } from "./useInternalController.js";
2
+ //#region src/hooks/useParent.ts
3
+ function t() {
4
+ return e().refParent;
5
+ }
6
+ //#endregion
7
+ export { t as useParent };
8
+
9
+ //# sourceMappingURL=useParent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useParent.js","names":[],"sources":["../../src/hooks/useParent.ts"],"sourcesContent":["import { useInternalController } from './useInternalController.ts';\nimport type { ReadonlyRef } from './useRef.ts';\n\n/** Use a reference (reactive state) bound to the parent node. */\nexport function useParent(): ReadonlyRef<ParentNode | null> {\n return useInternalController().refParent;\n}\n"],"mappings":";;AAIA,SAAgB,IAA4C;AAC1D,QAAO,GAAuB,CAAC"}
@@ -1,4 +1,4 @@
1
- import type { $$ref } from '../internal/controller.ts';
1
+ import type { $$ref } from '../internal/constants.ts';
2
2
  export interface Ref<T> extends ReadonlyRef<T> {
3
3
  value: T;
4
4
  }
@@ -0,0 +1,9 @@
1
+ import { useInternalController as e } from "./useInternalController.js";
2
+ //#region src/hooks/useRef.ts
3
+ function t(t, n) {
4
+ return e().createRef(t, n);
5
+ }
6
+ //#endregion
7
+ export { t as useRef };
8
+
9
+ //# sourceMappingURL=useRef.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useRef.js","names":[],"sources":["../../src/hooks/useRef.ts"],"sourcesContent":["import type { $$ref } from '../internal/constants.ts';\nimport { useInternalController } from './useInternalController.ts';\n\nexport interface Ref<T> extends ReadonlyRef<T> {\n value: T;\n}\n\nexport interface ReadonlyRef<T> {\n /** @hidden */\n [$$ref]: unknown;\n readonly value: T;\n}\n\nexport type RefValues<T> = T extends readonly any[]\n ? { [K in keyof T]: T[K] extends ReadonlyRef<infer V> ? V : never }\n : never;\n\n/** Use a reference (reactive state) value. */\nexport function useRef<T>(initialValue: T, onChange?: (value: T) => void): Ref<T> {\n return useInternalController().createRef(initialValue, onChange);\n}\n"],"mappings":";;AAkBA,SAAgB,EAAU,GAAiB,GAAuC;AAChF,QAAO,GAAuB,CAAC,UAAU,GAAc,EAAS"}
@@ -1,4 +1,4 @@
1
- import { type Ref } from './ref.ts';
1
+ import { type Ref } from './useRef.ts';
2
2
  export interface RouteOptions {
3
3
  readonly match?: 'prefix' | 'exact' | RegExp;
4
4
  readonly source?: 'pathname' | 'hash';
@@ -1,8 +1,8 @@
1
- import { useRef as e } from "./ref.js";
2
- import { useEffect as t } from "./effect.js";
3
- import { getRouter as n } from "../router.js";
4
- import { useStore as r } from "./store.js";
5
- //#region src/hooks/route.ts
1
+ import { useRef as e } from "./useRef.js";
2
+ import { useEffect as t } from "./useEffect.js";
3
+ import { getRouter as n } from "../getRouter.js";
4
+ import { useStore as r } from "./useStore.js";
5
+ //#region src/hooks/useRoute.ts
6
6
  function i(i, { match: a = "prefix", source: o = "pathname" } = {}) {
7
7
  let s = a === "exact" ? /^$/u : a === "prefix" ? /^.*$/u : a, c = Array.isArray(i) ? i : [i], l = r(n(), (e) => e[o]), u = e(d(l.value));
8
8
  return t([l], (e) => {
@@ -16,4 +16,4 @@ function i(i, { match: a = "prefix", source: o = "pathname" } = {}) {
16
16
  //#endregion
17
17
  export { i as useRoute };
18
18
 
19
- //# sourceMappingURL=route.js.map
19
+ //# sourceMappingURL=useRoute.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useRoute.js","names":[],"sources":["../../src/hooks/useRoute.ts"],"sourcesContent":["import { getRouter } from '../getRouter.ts';\nimport { useEffect } from './useEffect.ts';\nimport { type Ref, useRef } from './useRef.ts';\nimport { useStore } from './useStore.ts';\n\nexport interface RouteOptions {\n readonly match?: 'prefix' | 'exact' | RegExp;\n readonly source?: 'pathname' | 'hash';\n}\n\nexport type RouteMatch = readonly [string, ...string[]] & { readonly groups: Record<string, string> };\n\n/** Use a reference (reactive state) bound to route matching. */\nexport function useRoute(\n path: string | readonly string[],\n { match = 'prefix', source = 'pathname' }: RouteOptions = {},\n): Ref<RouteMatch | null> {\n const matchRx = match === 'exact' ? /^$/u : match === 'prefix' ? /^.*$/u : match;\n const paths = Array.isArray(path) ? (path as readonly string[]) : [path as string];\n const refRoute = useStore(getRouter(), (state) => state[source]);\n const refMatch = useRef<RouteMatch | null>(getMatch(refRoute.value));\n\n useEffect([refRoute], (route) => {\n refMatch.value = getMatch(route);\n });\n\n return refMatch;\n\n function getMatch(route: string): RouteMatch | null {\n const prefix = paths.find((path) => route.endsWith(path)) ?? null;\n if (prefix == null) return null;\n route = route.slice(prefix.length);\n return route.match(matchRx) as RouteMatch | null;\n }\n}\n"],"mappings":";;;;;AAaA,SAAgB,EACd,GACA,EAAE,WAAQ,UAAU,YAAS,eAA6B,EAAE,EACpC;CACxB,IAAM,IAAU,MAAU,UAAU,QAAQ,MAAU,WAAW,UAAU,GACrE,IAAQ,MAAM,QAAQ,EAAK,GAAI,IAA6B,CAAC,EAAe,EAC5E,IAAW,EAAS,GAAW,GAAG,MAAU,EAAM,GAAQ,EAC1D,IAAW,EAA0B,EAAS,EAAS,MAAM,CAAC;AAMpE,QAJA,EAAU,CAAC,EAAS,GAAG,MAAU;AAC/B,IAAS,QAAQ,EAAS,EAAM;GAChC,EAEK;CAEP,SAAS,EAAS,GAAkC;EAClD,IAAM,IAAS,EAAM,MAAM,MAAS,EAAM,SAAS,EAAK,CAAC,IAAI;AAG7D,SAFI,KAAU,OAAa,QAC3B,IAAQ,EAAM,MAAM,EAAO,OAAO,EAC3B,EAAM,MAAM,EAAQ"}
@@ -1,5 +1,5 @@
1
- import type { Store } from '../store.ts';
2
- import { type ReadonlyRef, type Ref } from './ref.ts';
1
+ import type { Store } from '../createStore.ts';
2
+ import { type ReadonlyRef, type Ref } from './useRef.ts';
3
3
  /** Use a reference (reactive state) bound to a (shared) store. */
4
4
  export declare function useStore<TState, TValue = TState>(store: Store<TState>, select: (state: TState) => TValue, mutate: (store: Store<TState>, value: TValue) => void): Ref<TValue>;
5
5
  export declare function useStore<TState, TValue = TState>(store: Store<TState>, select?: (state: TState) => TValue): ReadonlyRef<TValue>;
@@ -1,6 +1,6 @@
1
- import { useRef as e } from "./ref.js";
2
- import { useEffect as t } from "./effect.js";
3
- //#region src/hooks/store.ts
1
+ import { useRef as e } from "./useRef.js";
2
+ import { useEffect as t } from "./useEffect.js";
3
+ //#region src/hooks/useStore.ts
4
4
  function n(n, r = (e) => e, i) {
5
5
  let a = e(r(n.state), i && ((e) => i(n, e)));
6
6
  return t([], () => n.subscribe((e) => a.value = r(e))), a;
@@ -8,4 +8,4 @@ function n(n, r = (e) => e, i) {
8
8
  //#endregion
9
9
  export { n as useStore };
10
10
 
11
- //# sourceMappingURL=store.js.map
11
+ //# sourceMappingURL=useStore.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useStore.js","names":[],"sources":["../../src/hooks/useStore.ts"],"sourcesContent":["import type { Store } from '../createStore.ts';\nimport { useEffect } from './useEffect.ts';\nimport { type ReadonlyRef, type Ref, useRef } from './useRef.ts';\n\n/** Use a reference (reactive state) bound to a (shared) store. */\nexport function useStore<TState, TValue = TState>(\n store: Store<TState>,\n select: (state: TState) => TValue,\n mutate: (store: Store<TState>, value: TValue) => void,\n): Ref<TValue>;\nexport function useStore<TState, TValue = TState>(\n store: Store<TState>,\n select?: (state: TState) => TValue,\n): ReadonlyRef<TValue>;\nexport function useStore<TState, TValue = TState>(\n store: Store<TState>,\n select: (state: TState) => TValue = (state) => state as unknown as TValue,\n mutate?: (store: Store<TState>, value: TValue) => void,\n): Ref<TValue> {\n const ref = useRef(select(store.state), mutate && ((value) => mutate(store, value)));\n useEffect([], () => store.subscribe((state) => (ref.value = select(state))));\n return ref;\n}\n"],"mappings":";;;AAcA,SAAgB,EACd,GACA,KAAqC,MAAU,GAC/C,GACa;CACb,IAAM,IAAM,EAAO,EAAO,EAAM,MAAM,EAAE,OAAY,MAAU,EAAO,GAAO,EAAM,EAAE;AAEpF,QADA,EAAU,EAAE,QAAQ,EAAM,WAAW,MAAW,EAAI,QAAQ,EAAO,EAAM,CAAE,CAAC,EACrE"}
package/dist/html.d.ts CHANGED
@@ -7,7 +7,7 @@ type ElementType<TElement> = TElement extends string ? TElement extends keyof Ta
7
7
  type ElementProps<TElement> = {
8
8
  readonly [P in keyof TElement & string as TElement[P] extends ((...args: any[]) => any) | null | undefined ? never : IfEquals<Record<P, TElement[P]>, Pick<TElement, P>, `:${P}`, never>]?: TElement[P];
9
9
  };
10
- type ElementAttrs<TElement> = TElement extends string | CustomElementConstructor | Element ? {} : Readonly<Record<`${Alpha}${string}`, AttrValue>>;
10
+ type ElementAttrs<TElement> = TElement extends string | CustomElementConstructor | Element ? Readonly<Record<`${Alpha}${string}`, AttrValue>> : {};
11
11
  export type HtmlConfig<TElement> = ElementAttrs<TElement> & ElementProps<ElementType<TElement>>;
12
12
  export type HtmlConfigWithKey<TElement> = {
13
13
  readonly [DATA_KEY]: string;
package/dist/html.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"html.js","names":[],"sources":["../src/html.ts"],"sourcesContent":["// prettier-ignore\ntype Alpha = 'a' | 'b' | 'c' | 'd' | 'e' | 'f' | 'g' | 'h' | 'i' | 'j' | 'k' | 'l' | 'm' | 'n' | 'o' | 'p' | 'q' | 'r' | 's' | 't' | 'u' | 'v' | 'w' | 'x' | 'y' | 'z';\ntype ChildValue = Node | HtmlDeferredElement | string | number | bigint | false | null | undefined;\ntype AttrValue = string | number | bigint | boolean | null | undefined;\ntype TagMap = HTMLElementTagNameMap & HTMLElementDeprecatedTagNameMap;\n\ntype IfEquals<T, U, Y = unknown, N = never> =\n (<G>() => G extends T ? 1 : 2) extends <G>() => G extends U ? 1 : 2 ? Y : N;\n\ntype ElementType<TElement> = TElement extends string\n ? TElement extends keyof TagMap\n ? TagMap[TElement]\n : HTMLElement\n : TElement extends CustomElementConstructor\n ? InstanceType<TElement>\n : TElement extends Element | Document | ShadowRoot\n ? TElement\n : never;\n\ntype ElementProps<TElement> = {\n readonly [P in keyof TElement & string as TElement[P] extends ((...args: any[]) => any) | null | undefined\n ? never\n : IfEquals<Record<P, TElement[P]>, Pick<TElement, P>, `:${P}`, never>]?: TElement[P];\n};\n\ntype ElementAttrs<TElement> = TElement extends string | CustomElementConstructor | Element\n ? {}\n : Readonly<Record<`${Alpha}${string}`, AttrValue>>;\n\nexport type HtmlConfig<TElement> = ElementAttrs<TElement> & ElementProps<ElementType<TElement>>;\nexport type HtmlConfigWithKey<TElement> = { readonly [DATA_KEY]: string } & HtmlConfig<TElement>;\n\nexport interface HtmlDeferredElement<TElement extends HTMLElement = HTMLElement> {\n readonly tag: string;\n readonly config: { readonly [DATA_KEY]: string } & HtmlConfig<TElement>;\n readonly children: readonly ChildValue[] | undefined;\n toElement: () => TElement;\n}\n\nconst DATA_KEY = 'data-key';\n\n/**\n * Create a deferred HTML element with a key.\n *\n * Final element creation is deferred until the element is used as a child,\n * when it can be determined if a new element should be created, or an existing\n * element with the same key and tag-name should be updated.\n */\nexport function html<const TElement extends keyof TagMap | (string & {}) | CustomElementConstructor>(\n el: TElement,\n config: HtmlConfigWithKey<TElement>,\n children?: readonly ChildValue[],\n): HtmlDeferredElement<ElementType<TElement>>;\n\n/**\n * Create or update an HTML element.\n */\nexport function html<\n TElement extends keyof TagMap | (string & {}) | CustomElementConstructor | Element | Document | ShadowRoot,\n>(el: TElement, attrs?: HtmlConfig<TElement>, children?: readonly ChildValue[]): ElementType<NoInfer<TElement>>;\nexport function html<\n TElement extends keyof TagMap | (string & {}) | CustomElementConstructor | Element | Document | ShadowRoot,\n>(el: TElement, children?: readonly ChildValue[]): ElementType<TElement>;\n\nexport function html(\n el: string | CustomElementConstructor | Element | Document | ShadowRoot,\n attrsOrChildren: readonly ChildValue[] | Readonly<Record<string, any>> = {},\n children: readonly ChildValue[] = [],\n): Node | HtmlDeferredElement {\n if (typeof el === 'function') {\n let name = customElements.getName(el);\n\n if (name == null) {\n name = `ce-${crypto.randomUUID()}`;\n customElements.define(name, el);\n }\n\n el = name;\n }\n\n let attrs: Readonly<Record<string, any>>;\n [attrs, children] = Array.isArray(attrsOrChildren)\n ? [{}, attrsOrChildren as readonly ChildValue[]]\n : [attrsOrChildren as Readonly<Record<string, any>>, children];\n\n if (typeof el === 'string') {\n return DATA_KEY in attrs\n ? {\n tag: el,\n config: attrs as HtmlDeferredElement['config'],\n children,\n toElement: () => html(document.createElement(el), attrs, children),\n }\n : html(document.createElement(el), attrs, children);\n }\n\n if ('setAttribute' in el) {\n for (const [name, rawValue] of Object.entries(attrs)) {\n if (rawValue === undefined || name.startsWith(':')) continue;\n\n if (rawValue === null || rawValue === false) {\n if (el.hasAttribute(name)) el.removeAttribute(name);\n } else {\n const value = rawValue == true ? '' : String(rawValue);\n if (el.getAttribute(name) !== value) el.setAttribute(name, value);\n }\n }\n }\n\n for (const [rawName, value] of Object.entries(attrs)) {\n if (value === undefined || !rawName.startsWith(':')) continue;\n const name = rawName.slice(1);\n if (Reflect.get(el, name) !== value) Reflect.set(el, name, value);\n }\n\n let keyElements: Map<string, Element> | undefined;\n\n el.replaceChildren(\n ...children\n .filter((child) => child != null && child !== false)\n .map((child) => {\n if (typeof child !== 'object') return document.createTextNode(String(child));\n if (child instanceof Node) return child;\n\n keyElements ??= new Map(\n [...el.children].flatMap((child) => {\n const key = child.getAttribute(DATA_KEY);\n return key == null ? [] : [[key, child] as const];\n }),\n );\n\n const key = child.config[DATA_KEY];\n const reused = keyElements.get(key);\n\n if (reused && reused.tagName.toLowerCase() === child.tag) {\n keyElements.delete(key);\n return html(reused, child.config, child.children);\n }\n\n return child.toElement();\n }),\n );\n\n return el;\n}\n"],"mappings":";AAuCA,IAAM,IAAW;AAyBjB,SAAgB,EACd,GACA,IAAyE,EAAE,EAC3E,IAAkC,EAAE,EACR;AAC5B,KAAI,OAAO,KAAO,YAAY;EAC5B,IAAI,IAAO,eAAe,QAAQ,EAAG;AAOrC,EALI,MACF,IAAO,MAAM,OAAO,YAAY,IAChC,eAAe,OAAO,GAAM,EAAG,GAGjC,IAAK;;CAGP,IAAI;AAKJ,KAJA,CAAC,GAAO,KAAY,MAAM,QAAQ,EAAgB,GAC9C,CAAC,EAAE,EAAE,EAAyC,GAC9C,CAAC,GAAkD,EAAS,EAE5D,OAAO,KAAO,SAChB,QAAO,KAAY,IACf;EACE,KAAK;EACL,QAAQ;EACR;EACA,iBAAiB,EAAK,SAAS,cAAc,EAAG,EAAE,GAAO,EAAS;EACnE,GACD,EAAK,SAAS,cAAc,EAAG,EAAE,GAAO,EAAS;AAGvD,KAAI,kBAAkB,GACpB;OAAK,IAAM,CAAC,GAAM,MAAa,OAAO,QAAQ,EAAM,CAC9C,aAAa,KAAA,KAAa,EAAK,WAAW,IAAI,EAElD,KAAI,MAAa,QAAQ,MAAa,IAChC,EAAG,aAAa,EAAK,IAAE,EAAG,gBAAgB,EAAK;OAC9C;GACL,IAAM,IAAQ,KAAY,IAAO,KAAK,OAAO,EAAS;AACtD,GAAI,EAAG,aAAa,EAAK,KAAK,KAAO,EAAG,aAAa,GAAM,EAAM;;;AAKvE,MAAK,IAAM,CAAC,GAAS,MAAU,OAAO,QAAQ,EAAM,EAAE;AACpD,MAAI,MAAU,KAAA,KAAa,CAAC,EAAQ,WAAW,IAAI,CAAE;EACrD,IAAM,IAAO,EAAQ,MAAM,EAAE;AAC7B,EAAI,QAAQ,IAAI,GAAI,EAAK,KAAK,KAAO,QAAQ,IAAI,GAAI,GAAM,EAAM;;CAGnE,IAAI;AA4BJ,QA1BA,EAAG,gBACD,GAAG,EACA,QAAQ,MAAU,KAAS,QAAQ,MAAU,GAAM,CACnD,KAAK,MAAU;AACd,MAAI,OAAO,KAAU,SAAU,QAAO,SAAS,eAAe,OAAO,EAAM,CAAC;AAC5E,MAAI,aAAiB,KAAM,QAAO;AAElC,QAAgB,IAAI,IAClB,CAAC,GAAG,EAAG,SAAS,CAAC,SAAS,MAAU;GAClC,IAAM,IAAM,EAAM,aAAa,EAAS;AACxC,UAAO,KAAO,OAAO,EAAE,GAAG,CAAC,CAAC,GAAK,EAAM,CAAU;IACjD,CACH;EAED,IAAM,IAAM,EAAM,OAAO,IACnB,IAAS,EAAY,IAAI,EAAI;AAOnC,SALI,KAAU,EAAO,QAAQ,aAAa,KAAK,EAAM,OACnD,EAAY,OAAO,EAAI,EAChB,EAAK,GAAQ,EAAM,QAAQ,EAAM,SAAS,IAG5C,EAAM,WAAW;GACxB,CACL,EAEM"}
1
+ {"version":3,"file":"html.js","names":[],"sources":["../src/html.ts"],"sourcesContent":["// prettier-ignore\ntype Alpha = 'a' | 'b' | 'c' | 'd' | 'e' | 'f' | 'g' | 'h' | 'i' | 'j' | 'k' | 'l' | 'm' | 'n' | 'o' | 'p' | 'q' | 'r' | 's' | 't' | 'u' | 'v' | 'w' | 'x' | 'y' | 'z';\ntype ChildValue = Node | HtmlDeferredElement | string | number | bigint | false | null | undefined;\ntype AttrValue = string | number | bigint | boolean | null | undefined;\ntype TagMap = HTMLElementTagNameMap & HTMLElementDeprecatedTagNameMap;\n\ntype IfEquals<T, U, Y = unknown, N = never> =\n (<G>() => G extends T ? 1 : 2) extends <G>() => G extends U ? 1 : 2 ? Y : N;\n\ntype ElementType<TElement> = TElement extends string\n ? TElement extends keyof TagMap\n ? TagMap[TElement]\n : HTMLElement\n : TElement extends CustomElementConstructor\n ? InstanceType<TElement>\n : TElement extends Element | Document | ShadowRoot\n ? TElement\n : never;\n\ntype ElementProps<TElement> = {\n readonly [P in keyof TElement & string as TElement[P] extends ((...args: any[]) => any) | null | undefined\n ? never\n : IfEquals<Record<P, TElement[P]>, Pick<TElement, P>, `:${P}`, never>]?: TElement[P];\n};\n\ntype ElementAttrs<TElement> = TElement extends string | CustomElementConstructor | Element\n ? Readonly<Record<`${Alpha}${string}`, AttrValue>>\n : {};\n\nexport type HtmlConfig<TElement> = ElementAttrs<TElement> & ElementProps<ElementType<TElement>>;\nexport type HtmlConfigWithKey<TElement> = { readonly [DATA_KEY]: string } & HtmlConfig<TElement>;\n\nexport interface HtmlDeferredElement<TElement extends HTMLElement = HTMLElement> {\n readonly tag: string;\n readonly config: { readonly [DATA_KEY]: string } & HtmlConfig<TElement>;\n readonly children: readonly ChildValue[] | undefined;\n toElement: () => TElement;\n}\n\nconst DATA_KEY = 'data-key';\n\n/**\n * Create a deferred HTML element with a key.\n *\n * Final element creation is deferred until the element is used as a child,\n * when it can be determined if a new element should be created, or an existing\n * element with the same key and tag-name should be updated.\n */\nexport function html<const TElement extends keyof TagMap | (string & {}) | CustomElementConstructor>(\n el: TElement,\n config: HtmlConfigWithKey<TElement>,\n children?: readonly ChildValue[],\n): HtmlDeferredElement<ElementType<TElement>>;\n\n/**\n * Create or update an HTML element.\n */\nexport function html<\n TElement extends keyof TagMap | (string & {}) | CustomElementConstructor | Element | Document | ShadowRoot,\n>(el: TElement, attrs?: HtmlConfig<TElement>, children?: readonly ChildValue[]): ElementType<NoInfer<TElement>>;\nexport function html<\n TElement extends keyof TagMap | (string & {}) | CustomElementConstructor | Element | Document | ShadowRoot,\n>(el: TElement, children?: readonly ChildValue[]): ElementType<TElement>;\n\nexport function html(\n el: string | CustomElementConstructor | Element | Document | ShadowRoot,\n attrsOrChildren: readonly ChildValue[] | Readonly<Record<string, any>> = {},\n children: readonly ChildValue[] = [],\n): Node | HtmlDeferredElement {\n if (typeof el === 'function') {\n let name = customElements.getName(el);\n\n if (name == null) {\n name = `ce-${crypto.randomUUID()}`;\n customElements.define(name, el);\n }\n\n el = name;\n }\n\n let attrs: Readonly<Record<string, any>>;\n [attrs, children] = Array.isArray(attrsOrChildren)\n ? [{}, attrsOrChildren as readonly ChildValue[]]\n : [attrsOrChildren as Readonly<Record<string, any>>, children];\n\n if (typeof el === 'string') {\n return DATA_KEY in attrs\n ? {\n tag: el,\n config: attrs as HtmlDeferredElement['config'],\n children,\n toElement: () => html(document.createElement(el), attrs, children),\n }\n : html(document.createElement(el), attrs, children);\n }\n\n if ('setAttribute' in el) {\n for (const [name, rawValue] of Object.entries(attrs)) {\n if (rawValue === undefined || name.startsWith(':')) continue;\n\n if (rawValue === null || rawValue === false) {\n if (el.hasAttribute(name)) el.removeAttribute(name);\n } else {\n const value = rawValue == true ? '' : String(rawValue);\n if (el.getAttribute(name) !== value) el.setAttribute(name, value);\n }\n }\n }\n\n for (const [rawName, value] of Object.entries(attrs)) {\n if (value === undefined || !rawName.startsWith(':')) continue;\n const name = rawName.slice(1);\n if (Reflect.get(el, name) !== value) Reflect.set(el, name, value);\n }\n\n let keyElements: Map<string, Element> | undefined;\n\n el.replaceChildren(\n ...children\n .filter((child) => child != null && child !== false)\n .map((child) => {\n if (typeof child !== 'object') return document.createTextNode(String(child));\n if (child instanceof Node) return child;\n\n keyElements ??= new Map(\n [...el.children].flatMap((child) => {\n const key = child.getAttribute(DATA_KEY);\n return key == null ? [] : [[key, child] as const];\n }),\n );\n\n const key = child.config[DATA_KEY];\n const reused = keyElements.get(key);\n\n if (reused && reused.tagName.toLowerCase() === child.tag) {\n keyElements.delete(key);\n return html(reused, child.config, child.children);\n }\n\n return child.toElement();\n }),\n );\n\n return el;\n}\n"],"mappings":";AAuCA,IAAM,IAAW;AAyBjB,SAAgB,EACd,GACA,IAAyE,EAAE,EAC3E,IAAkC,EAAE,EACR;AAC5B,KAAI,OAAO,KAAO,YAAY;EAC5B,IAAI,IAAO,eAAe,QAAQ,EAAG;AAOrC,EALI,MACF,IAAO,MAAM,OAAO,YAAY,IAChC,eAAe,OAAO,GAAM,EAAG,GAGjC,IAAK;;CAGP,IAAI;AAKJ,KAJA,CAAC,GAAO,KAAY,MAAM,QAAQ,EAAgB,GAC9C,CAAC,EAAE,EAAE,EAAyC,GAC9C,CAAC,GAAkD,EAAS,EAE5D,OAAO,KAAO,SAChB,QAAO,KAAY,IACf;EACE,KAAK;EACL,QAAQ;EACR;EACA,iBAAiB,EAAK,SAAS,cAAc,EAAG,EAAE,GAAO,EAAS;EACnE,GACD,EAAK,SAAS,cAAc,EAAG,EAAE,GAAO,EAAS;AAGvD,KAAI,kBAAkB,GACpB;OAAK,IAAM,CAAC,GAAM,MAAa,OAAO,QAAQ,EAAM,CAC9C,aAAa,KAAA,KAAa,EAAK,WAAW,IAAI,EAElD,KAAI,MAAa,QAAQ,MAAa,IAChC,EAAG,aAAa,EAAK,IAAE,EAAG,gBAAgB,EAAK;OAC9C;GACL,IAAM,IAAQ,KAAY,IAAO,KAAK,OAAO,EAAS;AACtD,GAAI,EAAG,aAAa,EAAK,KAAK,KAAO,EAAG,aAAa,GAAM,EAAM;;;AAKvE,MAAK,IAAM,CAAC,GAAS,MAAU,OAAO,QAAQ,EAAM,EAAE;AACpD,MAAI,MAAU,KAAA,KAAa,CAAC,EAAQ,WAAW,IAAI,CAAE;EACrD,IAAM,IAAO,EAAQ,MAAM,EAAE;AAC7B,EAAI,QAAQ,IAAI,GAAI,EAAK,KAAK,KAAO,QAAQ,IAAI,GAAI,GAAM,EAAM;;CAGnE,IAAI;AA4BJ,QA1BA,EAAG,gBACD,GAAG,EACA,QAAQ,MAAU,KAAS,QAAQ,MAAU,GAAM,CACnD,KAAK,MAAU;AACd,MAAI,OAAO,KAAU,SAAU,QAAO,SAAS,eAAe,OAAO,EAAM,CAAC;AAC5E,MAAI,aAAiB,KAAM,QAAO;AAElC,QAAgB,IAAI,IAClB,CAAC,GAAG,EAAG,SAAS,CAAC,SAAS,MAAU;GAClC,IAAM,IAAM,EAAM,aAAa,EAAS;AACxC,UAAO,KAAO,OAAO,EAAE,GAAG,CAAC,CAAC,GAAK,EAAM,CAAU;IACjD,CACH;EAED,IAAM,IAAM,EAAM,OAAO,IACnB,IAAS,EAAY,IAAI,EAAI;AAOnC,SALI,KAAU,EAAO,QAAQ,aAAa,KAAK,EAAM,OACnD,EAAY,OAAO,EAAI,EAChB,EAAK,GAAQ,EAAM,QAAQ,EAAM,SAAS,IAG5C,EAAM,WAAW;GACxB,CACL,EAEM"}
package/dist/index.d.ts CHANGED
@@ -1,18 +1,17 @@
1
- export * from './component.ts';
2
- export * from './hooks/async.ts';
3
- export * from './hooks/attributes.ts';
4
- export * from './hooks/child.ts';
5
- export * from './hooks/disconnect.ts';
6
- export * from './hooks/document.ts';
7
- export * from './hooks/effect.ts';
8
- export * from './hooks/form.ts';
9
- export * from './hooks/host.ts';
10
- export * from './hooks/internals.ts';
11
- export * from './hooks/parent.ts';
12
- export * from './hooks/ref.ts';
13
- export * from './hooks/route.ts';
14
- export * from './hooks/store.ts';
1
+ export * from './createStore.ts';
2
+ export * from './defineComponent.ts';
3
+ export * from './hooks/useAsync.ts';
4
+ export * from './hooks/useAttributes.ts';
5
+ export * from './hooks/useChildEffect.ts';
6
+ export * from './hooks/useDisconnect.ts';
7
+ export * from './hooks/useDocument.ts';
8
+ export * from './hooks/useEffect.ts';
9
+ export * from './hooks/useElementInternals.ts';
10
+ export * from './hooks/useForm.ts';
11
+ export * from './hooks/useHost.ts';
12
+ export * from './hooks/useParent.ts';
13
+ export * from './hooks/useRef.ts';
14
+ export * from './hooks/useRoute.ts';
15
+ export * from './hooks/useStore.ts';
15
16
  export * from './html.ts';
16
17
  export { html as h } from './html.ts';
17
- export * from './router.ts';
18
- export * from './store.ts';