@simpreact/simpreact 0.0.1 → 0.0.2

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 (50) hide show
  1. package/core/context.d.ts +1 -1
  2. package/core/createElement.d.ts +3 -3
  3. package/core/createElement.js +10 -5
  4. package/core/fragment.d.ts +1 -1
  5. package/core/hostAdapter.d.ts +3 -3
  6. package/core/index.d.ts +1 -1
  7. package/core/index.js +4 -4
  8. package/core/internal.d.ts +11 -11
  9. package/core/internal.js +11 -11
  10. package/core/lifecycleEventBus.d.ts +2 -2
  11. package/core/lifecycleEventBus.js +1 -1
  12. package/core/mounting.d.ts +4 -4
  13. package/core/mounting.js +12 -8
  14. package/core/patching.d.ts +4 -4
  15. package/core/patching.js +38 -8
  16. package/core/portal.d.ts +1 -1
  17. package/core/portal.js +1 -1
  18. package/core/ref.d.ts +1 -1
  19. package/core/rerender.d.ts +1 -1
  20. package/core/rerender.js +7 -1
  21. package/core/unmounting.d.ts +3 -3
  22. package/core/unmounting.js +3 -3
  23. package/dom/attach-element-to-dom.d.ts +1 -1
  24. package/dom/domAdapter.d.ts +1 -1
  25. package/dom/domAdapter.js +10 -5
  26. package/dom/events.d.ts +1 -1
  27. package/dom/events.js +1 -1
  28. package/dom/index.d.ts +2 -2
  29. package/dom/index.js +2 -2
  30. package/dom/props/controlled/index.d.ts +1 -1
  31. package/dom/props/controlled/index.js +3 -3
  32. package/dom/props/controlled/input.d.ts +1 -1
  33. package/dom/props/controlled/input.js +1 -1
  34. package/dom/props/controlled/select.d.ts +1 -1
  35. package/dom/props/controlled/select.js +2 -2
  36. package/dom/props/controlled/textarea.d.ts +1 -1
  37. package/dom/props/controlled/textarea.js +1 -1
  38. package/dom/props/dangerInnerHTML.d.ts +1 -1
  39. package/dom/props/index.d.ts +1 -1
  40. package/dom/props/index.js +1 -1
  41. package/dom/props/props.d.ts +1 -1
  42. package/dom/props/props.js +6 -6
  43. package/dom/render.d.ts +1 -1
  44. package/dom/render.js +2 -2
  45. package/hooks/index.d.ts +1 -1
  46. package/hooks/index.js +1 -1
  47. package/jsx-runtime/index.d.ts +3 -3
  48. package/package.json +2 -1
  49. package/shared/index.js +3 -3
  50. package/shared/utils.d.ts +1 -1
package/core/context.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { SimpNode } from './createElement';
1
+ import type { SimpNode } from './createElement.js';
2
2
  type Provider<T = any> = (props: {
3
3
  value: T;
4
4
  children: SimpNode;
@@ -1,6 +1,6 @@
1
- import type { Many, Maybe, Nullable, SimpText } from '../shared';
2
- import type { HostReference } from './hostAdapter';
3
- import type { SimpContextMap } from './context';
1
+ import type { Many, Maybe, Nullable, SimpText } from '../shared/index.js';
2
+ import type { HostReference } from './hostAdapter.js';
3
+ import type { SimpContextMap } from './context.js';
4
4
  export type SimpNode = SimpElement | SimpText | Array<SimpNode> | boolean | null | undefined;
5
5
  export type Key = string | number | bigint;
6
6
  export interface FunctionComponent {
@@ -1,6 +1,6 @@
1
- import { isSimpText } from '../shared';
2
- import { Fragment } from './fragment';
3
- import { isConsumer, isProvider } from './context';
1
+ import { isSimpText } from '../shared/index.js';
2
+ import { Fragment } from './fragment.js';
3
+ import { isConsumer, isProvider } from './context.js';
4
4
  export function createElement(type, props, ...children) {
5
5
  let newProps;
6
6
  let className;
@@ -52,7 +52,12 @@ export function createElement(type, props, ...children) {
52
52
  if (key) {
53
53
  element.key = key;
54
54
  }
55
- if ((definedChildren = normalizeChildren(definedChildren, false))) {
55
+ if (isSimpText(definedChildren)) {
56
+ if (definedChildren !== '') {
57
+ (newProps ||= {}).children = definedChildren.toString();
58
+ }
59
+ }
60
+ else if ((definedChildren = normalizeChildren(definedChildren, false))) {
56
61
  element.children = definedChildren;
57
62
  }
58
63
  if (newProps) {
@@ -134,7 +139,7 @@ export function createElement(type, props, ...children) {
134
139
  export function createTextElement(text) {
135
140
  return {
136
141
  flag: 'TEXT',
137
- children: text,
142
+ children: text.toString(),
138
143
  parent: null,
139
144
  };
140
145
  }
@@ -1,4 +1,4 @@
1
- import type { SimpNode } from './createElement';
1
+ import type { SimpNode } from './createElement.js';
2
2
  export type Fragment = (props: {
3
3
  children?: SimpNode;
4
4
  }) => SimpNode;
@@ -1,5 +1,5 @@
1
- import type { Maybe, Nullable } from '../shared';
2
- import type { SimpElement } from './createElement';
1
+ import type { Maybe, Nullable } from '../shared/index.js';
2
+ import type { SimpElement } from './createElement.js';
3
3
  export type HostReference = any;
4
4
  export interface HostAdapter<HostRef = any, HostTextRef = any, NS = string> {
5
5
  createReference(type: string, namespace?: Maybe<NS>): HostRef;
@@ -8,7 +8,7 @@ export interface HostAdapter<HostRef = any, HostTextRef = any, NS = string> {
8
8
  patchProps(reference: HostRef, prevElement: SimpElement, nextElement: SimpElement, namespace?: Maybe<NS>): void;
9
9
  unmountProps(reference: HostRef, element: SimpElement): void;
10
10
  setClassname(reference: HostRef, className: Maybe<string>, namespace?: Maybe<NS>): void;
11
- setTextContent(reference: HostRef, text: string): void;
11
+ setTextContent(reference: HostRef, text: string, referenceHasOnlyTextElement?: boolean): void;
12
12
  appendChild(parent: HostRef, child: HostRef | HostTextRef): void;
13
13
  removeChild(parent: HostRef, child: HostRef | HostTextRef): void;
14
14
  replaceChild(parent: HostRef, replacer: HostRef | HostTextRef, toBeReplaced: HostRef | HostTextRef): void;
package/core/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { SimpText } from '../shared';
1
+ import type { SimpText } from '../shared/index.js';
2
2
 
3
3
  export type ComponentType<P = {}> = FunctionComponent<P>;
4
4
 
package/core/index.js CHANGED
@@ -1,6 +1,6 @@
1
- import { createElement } from './createElement';
2
- import { Fragment } from './fragment';
3
- import { createContext } from './context';
4
- import { createPortal } from './portal';
1
+ import { createElement } from './createElement.js';
2
+ import { Fragment } from './fragment.js';
3
+ import { createContext } from './context.js';
4
+ import { createPortal } from './portal.js';
5
5
  export { createElement, Fragment, createContext, createPortal };
6
6
  export default { createElement, Fragment, createContext, createPortal };
@@ -1,11 +1,11 @@
1
- export * from './context';
2
- export * from './createElement';
3
- export * from './fragment';
4
- export * from './hostAdapter';
5
- export * from './lifecycleEventBus';
6
- export * from './mounting';
7
- export * from './patching';
8
- export * from './portal';
9
- export * from './ref';
10
- export * from './rerender';
11
- export * from './unmounting';
1
+ export * from './context.js';
2
+ export * from './createElement.js';
3
+ export * from './fragment.js';
4
+ export * from './hostAdapter.js';
5
+ export * from './lifecycleEventBus.js';
6
+ export * from './mounting.js';
7
+ export * from './patching.js';
8
+ export * from './portal.js';
9
+ export * from './ref.js';
10
+ export * from './rerender.js';
11
+ export * from './unmounting.js';
package/core/internal.js CHANGED
@@ -1,11 +1,11 @@
1
- export * from './context';
2
- export * from './createElement';
3
- export * from './fragment';
4
- export * from './hostAdapter';
5
- export * from './lifecycleEventBus';
6
- export * from './mounting';
7
- export * from './patching';
8
- export * from './portal';
9
- export * from './ref';
10
- export * from './rerender';
11
- export * from './unmounting';
1
+ export * from './context.js';
2
+ export * from './createElement.js';
3
+ export * from './fragment.js';
4
+ export * from './hostAdapter.js';
5
+ export * from './lifecycleEventBus.js';
6
+ export * from './mounting.js';
7
+ export * from './patching.js';
8
+ export * from './portal.js';
9
+ export * from './ref.js';
10
+ export * from './rerender.js';
11
+ export * from './unmounting.js';
@@ -1,5 +1,5 @@
1
- import { EventBus } from '../shared';
2
- import type { SimpElement } from './createElement';
1
+ import { EventBus } from '../shared/index.js';
2
+ import type { SimpElement } from './createElement.js';
3
3
  export type LifecycleEvent = {
4
4
  type: 'beforeRender';
5
5
  element: SimpElement;
@@ -1,2 +1,2 @@
1
- import { EventBus } from '../shared';
1
+ import { EventBus } from '../shared/index.js';
2
2
  export const lifecycleEventBus = new EventBus();
@@ -1,7 +1,7 @@
1
- import type { Maybe, Nullable } from '../shared';
2
- import type { HostReference } from './hostAdapter';
3
- import type { SimpElement } from './createElement';
4
- import type { SimpContextMap } from './context';
1
+ import type { Maybe, Nullable } from '../shared/index.js';
2
+ import type { HostReference } from './hostAdapter.js';
3
+ import type { SimpElement } from './createElement.js';
4
+ import type { SimpContextMap } from './context.js';
5
5
  export declare function mount(element: SimpElement, parentReference: Nullable<HostReference>, nextReference: Nullable<HostReference>, contextMap: Nullable<SimpContextMap>, hostNamespace: Maybe<string>): void;
6
6
  export declare function mountTextElement(element: SimpElement, parentReference: Nullable<HostReference>, nextReference: Nullable<HostReference>): void;
7
7
  export declare function mountHostElement(element: SimpElement, parentReference: Nullable<HostReference>, nextReference: Nullable<HostReference>, contextMap: Nullable<SimpContextMap>, hostNamespace: Maybe<string>): void;
package/core/mounting.js CHANGED
@@ -1,8 +1,8 @@
1
- import { emptyMap, emptyObject } from '../shared';
2
- import { hostAdapter } from './hostAdapter';
3
- import { createTextElement, normalizeRoot } from './createElement';
4
- import { applyRef } from './ref';
5
- import { lifecycleEventBus } from './lifecycleEventBus';
1
+ import { emptyMap, emptyObject } from '../shared/index.js';
2
+ import { hostAdapter } from './hostAdapter.js';
3
+ import { createTextElement, normalizeRoot } from './createElement.js';
4
+ import { applyRef } from './ref.js';
5
+ import { lifecycleEventBus } from './lifecycleEventBus.js';
6
6
  export function mount(element, parentReference, nextReference, contextMap, hostNamespace) {
7
7
  if (element.flag === 'TEXT') {
8
8
  mountTextElement(element, parentReference, nextReference);
@@ -37,9 +37,6 @@ export function mountHostElement(element, parentReference, nextReference, contex
37
37
  hostNamespace = hostNamespaces?.self;
38
38
  const hostReference = (element.reference = hostAdapter.createReference(element.type, hostNamespace));
39
39
  hostAdapter.attachElementToReference(element, hostReference);
40
- if (parentReference) {
41
- hostAdapter.insertOrAppend(parentReference, hostReference, nextReference);
42
- }
43
40
  // HOST element always has Maybe<Many<SimpElement>> children due to normalization process.
44
41
  const children = element.children;
45
42
  if (Array.isArray(children)) {
@@ -51,10 +48,17 @@ export function mountHostElement(element, parentReference, nextReference, contex
51
48
  }
52
49
  if (element.props) {
53
50
  hostAdapter.mountProps(hostReference, element, hostNamespace);
51
+ // HOST elements can have either children elements or string children in the props due to normalization.
52
+ if (typeof element.props.children === 'string') {
53
+ hostAdapter.setTextContent(hostReference, element.props.children);
54
+ }
54
55
  }
55
56
  if (element.className) {
56
57
  hostAdapter.setClassname(hostReference, element.className, hostNamespace);
57
58
  }
59
+ if (parentReference) {
60
+ hostAdapter.insertOrAppend(parentReference, hostReference, nextReference);
61
+ }
58
62
  applyRef(element);
59
63
  }
60
64
  export function mountFunctionalElement(element, parentReference, nextReference, contextMap, hostNamespace) {
@@ -1,7 +1,7 @@
1
- import type { Maybe, Nullable } from '../shared';
2
- import type { SimpElement } from './createElement';
3
- import type { HostReference } from './hostAdapter';
4
- import type { SimpContextMap } from './context';
1
+ import type { Maybe, Nullable } from '../shared/index.js';
2
+ import type { SimpElement } from './createElement.js';
3
+ import type { HostReference } from './hostAdapter.js';
4
+ import type { SimpContextMap } from './context.js';
5
5
  export declare function patch(prevElement: SimpElement, nextElement: SimpElement, parentReference: HostReference, nextReference: Nullable<HostReference>, contextMap: Nullable<SimpContextMap>, hostNamespace: Maybe<string>): void;
6
6
  export declare function patchPortal(prevElement: SimpElement, nextElement: SimpElement, contextMap: Nullable<SimpContextMap>): void;
7
7
  export declare function updateFunctionalComponent(element: SimpElement, parentReference: HostReference, nextReference: Nullable<HostReference>, contextMap: Nullable<SimpContextMap>, hostNamespace: Maybe<string>): void;
package/core/patching.js CHANGED
@@ -1,10 +1,10 @@
1
- import { emptyMap, emptyObject } from '../shared';
2
- import { normalizeRoot } from './createElement';
3
- import { hostAdapter } from './hostAdapter';
4
- import { clearElementHostReference, remove, unmount } from './unmounting';
5
- import { mount, mountArrayChildren } from './mounting';
6
- import { applyRef } from './ref';
7
- import { lifecycleEventBus } from './lifecycleEventBus';
1
+ import { emptyMap, emptyObject } from '../shared/index.js';
2
+ import { normalizeRoot } from './createElement.js';
3
+ import { hostAdapter } from './hostAdapter.js';
4
+ import { clearElementHostReference, remove, unmount } from './unmounting.js';
5
+ import { mount, mountArrayChildren } from './mounting.js';
6
+ import { applyRef } from './ref.js';
7
+ import { lifecycleEventBus } from './lifecycleEventBus.js';
8
8
  export function patch(prevElement, nextElement, parentReference, nextReference, contextMap, hostNamespace) {
9
9
  if (prevElement.type !== nextElement.type || prevElement.key !== nextElement.key) {
10
10
  replaceWithNewElement(prevElement, nextElement, parentReference, contextMap, hostNamespace);
@@ -51,7 +51,7 @@ function patchHostElement(prevElement, nextElement, contextMap, hostNamespace) {
51
51
  hostNamespace = hostNamespaces?.self;
52
52
  nextElement.reference = prevElement.reference;
53
53
  hostAdapter.attachElementToReference(nextElement, nextElement.reference);
54
- patchChildren(prevElement.children, nextElement.children, nextElement.reference, null, nextElement, contextMap, hostNamespaces?.children);
54
+ patchChildren(prevElement.children || prevElement.props?.children, nextElement.children || nextElement.props?.children, nextElement.reference, null, nextElement, contextMap, hostNamespaces?.children);
55
55
  hostAdapter.patchProps(nextElement.reference, prevElement, nextElement, hostNamespace);
56
56
  if (prevElement.className !== nextElement.className) {
57
57
  hostAdapter.setClassname(nextElement.reference, nextElement.className, hostNamespace);
@@ -134,6 +134,10 @@ function patchChildren(prevChildren, nextChildren, parentReference, nextReferenc
134
134
  }
135
135
  patchKeyedChildren(prevChildren, nextChildren, parentReference, nextReference, contextMap, hostNamespace);
136
136
  }
137
+ else if (typeof nextChildren === 'string') {
138
+ unmount(prevChildren);
139
+ hostAdapter.setTextContent(parentReference, nextChildren);
140
+ }
137
141
  else if (nextChildren) {
138
142
  patchKeyedChildren(prevChildren, [nextChildren], parentReference, nextReference, contextMap, hostNamespace);
139
143
  }
@@ -142,10 +146,33 @@ function patchChildren(prevChildren, nextChildren, parentReference, nextReferenc
142
146
  hostAdapter.clearNode(parentReference);
143
147
  }
144
148
  }
149
+ else if (typeof prevChildren === 'string') {
150
+ if (Array.isArray(nextChildren)) {
151
+ hostAdapter.clearNode(parentReference);
152
+ mountArrayChildren(nextChildren, parentReference, nextReference, contextMap, nextElement, hostNamespace);
153
+ }
154
+ else if (typeof nextChildren === 'string') {
155
+ if (prevChildren !== nextChildren) {
156
+ hostAdapter.setTextContent(nextElement.reference, nextChildren, true);
157
+ }
158
+ }
159
+ else if (nextChildren) {
160
+ hostAdapter.clearNode(parentReference);
161
+ nextChildren.parent = nextElement;
162
+ mount(nextChildren, parentReference, nextReference, contextMap, hostNamespace);
163
+ }
164
+ else {
165
+ hostAdapter.clearNode(parentReference);
166
+ }
167
+ }
145
168
  else if (prevChildren) {
146
169
  if (Array.isArray(nextChildren)) {
147
170
  patchKeyedChildren([prevChildren], nextChildren, parentReference, nextReference, contextMap, hostNamespace);
148
171
  }
172
+ else if (typeof nextChildren === 'string') {
173
+ unmount(prevChildren);
174
+ hostAdapter.setTextContent(parentReference, nextChildren);
175
+ }
149
176
  else if (nextChildren) {
150
177
  nextChildren.parent = nextElement;
151
178
  patch(prevChildren, nextChildren, parentReference, nextReference, contextMap, hostNamespace);
@@ -159,6 +186,9 @@ function patchChildren(prevChildren, nextChildren, parentReference, nextReferenc
159
186
  if (Array.isArray(nextChildren)) {
160
187
  mountArrayChildren(nextChildren, parentReference, nextReference, contextMap, nextElement, hostNamespace);
161
188
  }
189
+ else if (typeof nextChildren === 'string') {
190
+ hostAdapter.setTextContent(parentReference, nextChildren);
191
+ }
162
192
  else if (nextChildren) {
163
193
  nextChildren.parent = nextElement;
164
194
  mount(nextChildren, parentReference, nextReference, contextMap, hostNamespace);
package/core/portal.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import type { SimpElement, SimpNode } from './createElement';
1
+ import type { SimpElement, SimpNode } from './createElement.js';
2
2
  export declare function createPortal(children: SimpNode, container: any): SimpElement;
package/core/portal.js CHANGED
@@ -1,4 +1,4 @@
1
- import { normalizeRoot } from './createElement';
1
+ import { normalizeRoot } from './createElement.js';
2
2
  export function createPortal(children, container) {
3
3
  const element = { flag: 'PORTAL', parent: null };
4
4
  if ((children = normalizeRoot(children, false))) {
package/core/ref.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { SimpElement } from './createElement';
1
+ import type { SimpElement } from './createElement.js';
2
2
  interface RefSimpElement extends SimpElement {
3
3
  ref?: {
4
4
  value: NonNullable<Ref<unknown>>;
@@ -1,4 +1,4 @@
1
- import type { SimpElement } from './createElement';
1
+ import type { SimpElement } from './createElement.js';
2
2
  export declare function rerender(element: SimpElement): void;
3
3
  interface IRendererLocker {
4
4
  _isLocked: boolean;
package/core/rerender.js CHANGED
@@ -1,4 +1,4 @@
1
- import { findParentReferenceFromElement, updateFunctionalComponent } from './patching';
1
+ import { findParentReferenceFromElement, updateFunctionalComponent } from './patching.js';
2
2
  export function rerender(element) {
3
3
  if (element.flag !== 'FC') {
4
4
  throw new TypeError('Re-rendering is only supported for FC elements.');
@@ -33,6 +33,9 @@ export const syncRerenderLocker = {
33
33
  },
34
34
  flush() {
35
35
  this._isLocked = false;
36
+ if (this._elements.size === 0) {
37
+ return;
38
+ }
36
39
  for (const element of this._elements) {
37
40
  this._elements.delete(element);
38
41
  rerender(element.store.latestElement);
@@ -53,6 +56,9 @@ export const asyncRerenderLocker = {
53
56
  },
54
57
  flush() {
55
58
  this._isLocked = false;
59
+ if (this._elements.size === 0) {
60
+ return;
61
+ }
56
62
  queueMicrotask(() => {
57
63
  for (const element of this._elements) {
58
64
  this._elements.delete(element);
@@ -1,6 +1,6 @@
1
- import type { Many, Maybe } from '../shared';
2
- import type { SimpElement } from './createElement';
3
- import type { HostReference } from './hostAdapter';
1
+ import type { Many, Maybe } from '../shared/index.js';
2
+ import type { SimpElement } from './createElement.js';
3
+ import type { HostReference } from './hostAdapter.js';
4
4
  export declare function unmount(element: Many<SimpElement>): void;
5
5
  export declare function clearElementHostReference(element: Maybe<SimpElement>, parentHostReference: HostReference): void;
6
6
  export declare function remove(element: SimpElement, parentReference: HostReference): void;
@@ -1,6 +1,6 @@
1
- import { hostAdapter } from './hostAdapter';
2
- import { unmountRef } from './ref';
3
- import { lifecycleEventBus } from './lifecycleEventBus';
1
+ import { hostAdapter } from './hostAdapter.js';
2
+ import { unmountRef } from './ref.js';
3
+ import { lifecycleEventBus } from './lifecycleEventBus.js';
4
4
  export function unmount(element) {
5
5
  if (Array.isArray(element)) {
6
6
  for (const child of element) {
@@ -1,4 +1,4 @@
1
- import type { Nullable } from '../shared';
1
+ import type { Nullable } from '../shared/index.js';
2
2
  import type { SimpElement } from '../core/internal.js';
3
3
  export declare function attachElementToDom(element: SimpElement, dom: Node): void;
4
4
  export declare function getElementFromDom(target: Nullable<EventTarget>): Nullable<SimpElement>;
@@ -1,3 +1,3 @@
1
1
  import type { HostAdapter } from '../core/internal.js';
2
- import type { Namespace } from './namespace';
2
+ import type { Namespace } from './namespace.js';
3
3
  export declare const domAdapter: HostAdapter<HTMLElement | SVGElement, Text, Namespace>;
package/dom/domAdapter.js CHANGED
@@ -1,6 +1,6 @@
1
- import { attachElementToDom } from './attach-element-to-dom';
2
- import { mountProps, patchProps, unmountProps } from './props';
3
- import { defaultNamespace } from './namespace';
1
+ import { attachElementToDom } from './attach-element-to-dom.js';
2
+ import { mountProps, patchProps, unmountProps } from './props/index.js';
3
+ import { defaultNamespace } from './namespace.js';
4
4
  export const domAdapter = {
5
5
  createReference(type, namespace) {
6
6
  if (namespace) {
@@ -33,8 +33,13 @@ export const domAdapter = {
33
33
  reference.className = className;
34
34
  }
35
35
  },
36
- setTextContent(reference, text) {
37
- reference.textContent = text;
36
+ setTextContent(reference, text, referenceHasOnlyTextElement) {
37
+ if (referenceHasOnlyTextElement) {
38
+ reference.firstChild.nodeValue = text;
39
+ }
40
+ else {
41
+ reference.textContent = text;
42
+ }
38
43
  },
39
44
  appendChild(parent, child) {
40
45
  parent.appendChild(child);
package/dom/events.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { Nullable } from '../shared';
1
+ import type { Nullable } from '../shared/index.js';
2
2
  type DelegatedEventType = 'click' | 'dblclick' | 'mousedown' | 'mouseup' | 'mousemove' | 'pointerdown' | 'pointerup' | 'pointermove' | 'touchstart' | 'touchmove' | 'touchend' | 'keydown' | 'keyup' | 'focusin' | 'focusout';
3
3
  export declare class SyntheticEvent {
4
4
  nativeEvent: Event;
package/dom/events.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { syncRerenderLocker } from '../core/internal.js';
2
- import { getElementFromDom } from './attach-element-to-dom';
2
+ import { getElementFromDom } from './attach-element-to-dom.js';
3
3
  const eventNameByTypes = {
4
4
  click: 'onClick',
5
5
  dblclick: 'onDblClick',
package/dom/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import type { RefAttributes, SimpElement, SimpNode } from '../core';
2
- import type { Nullable } from '../shared';
1
+ import type { RefAttributes, SimpElement, SimpNode } from '../core/index.js';
2
+ import type { Nullable } from '../shared/index.js';
3
3
 
4
4
  import type { PropertiesHyphen } from 'csstype';
5
5
 
package/dom/index.js CHANGED
@@ -1,3 +1,3 @@
1
- import { createRoot, render } from './render';
2
- export { createRoot, render } from './render';
1
+ import { createRoot, render } from './render.js';
2
+ export { createRoot, render } from './render.js';
3
3
  export default { createRoot, render };
@@ -1,5 +1,5 @@
1
1
  import type { SimpElement } from '../../../core/internal.js';
2
- import type { Dict } from '../../../shared';
2
+ import type { Dict } from '../../../shared/index.js';
3
3
  export declare function isEventNameIgnored(element: SimpElement, eventName: string): boolean;
4
4
  export declare function isFormElementControlled(props: Dict): boolean;
5
5
  export declare function addControlledFormElementEventHandlers(element: SimpElement): void;
@@ -1,6 +1,6 @@
1
- import { addControlledInputEventHandlers, isEventNameIgnored as isEventNameIgnoredInput, removeControlledInputEventHandlers, syncControlledInputProps, } from './input';
2
- import { addControlledSelectEventHandlers, isEventNameIgnored as isEventNameIgnoredSelect, removeControlledSelectEventHandlers, syncControlledSelectProps, } from './select';
3
- import { addControlledTextareaEventHandlers, isEventNameIgnored as isEventNameIgnoredTextarea, removeControlledTextareaEventHandlers, syncControlledTextareaProps, } from './textarea';
1
+ import { addControlledInputEventHandlers, isEventNameIgnored as isEventNameIgnoredInput, removeControlledInputEventHandlers, syncControlledInputProps, } from './input.js';
2
+ import { addControlledSelectEventHandlers, isEventNameIgnored as isEventNameIgnoredSelect, removeControlledSelectEventHandlers, syncControlledSelectProps, } from './select.js';
3
+ import { addControlledTextareaEventHandlers, isEventNameIgnored as isEventNameIgnoredTextarea, removeControlledTextareaEventHandlers, syncControlledTextareaProps, } from './textarea.js';
4
4
  export function isEventNameIgnored(element, eventName) {
5
5
  if (element.type === 'input') {
6
6
  return isEventNameIgnoredInput(element.props, eventName);
@@ -1,5 +1,5 @@
1
1
  import type { SimpElement } from '../../../core/internal.js';
2
- import type { Dict } from '../../../shared';
2
+ import type { Dict } from '../../../shared/index.js';
3
3
  export declare function isCheckedType(type: string): boolean;
4
4
  export declare function isEventNameIgnored(props: Dict, eventName: string): boolean;
5
5
  export declare function addControlledInputEventHandlers(dom: HTMLInputElement): void;
@@ -1,5 +1,5 @@
1
1
  import { syncRerenderLocker } from '../../../core/internal.js';
2
- import { getElementFromDom } from '../../attach-element-to-dom';
2
+ import { getElementFromDom } from '../../attach-element-to-dom.js';
3
3
  export function isCheckedType(type) {
4
4
  return type === 'checkbox' || type === 'radio';
5
5
  }
@@ -1,5 +1,5 @@
1
1
  import type { SimpElement } from '../../../core/internal.js';
2
- import type { Dict } from '../../../shared';
2
+ import type { Dict } from '../../../shared/index.js';
3
3
  export declare function isEventNameIgnored(eventName: string): boolean;
4
4
  export declare function addControlledSelectEventHandlers(dom: HTMLSelectElement): void;
5
5
  export declare function removeControlledSelectEventHandlers(dom: HTMLSelectElement): void;
@@ -1,6 +1,6 @@
1
1
  import { syncRerenderLocker } from '../../../core/internal.js';
2
- import { emptyObject } from '../../../shared';
3
- import { getElementFromDom } from '../../attach-element-to-dom';
2
+ import { emptyObject } from '../../../shared/index.js';
3
+ import { getElementFromDom } from '../../attach-element-to-dom.js';
4
4
  export function isEventNameIgnored(eventName) {
5
5
  return eventName === 'onChange';
6
6
  }
@@ -1,5 +1,5 @@
1
1
  import type { SimpElement } from '../../../core/internal.js';
2
- import type { Dict } from '../../../shared';
2
+ import type { Dict } from '../../../shared/index.js';
3
3
  export declare function isEventNameIgnored(eventName: string): boolean;
4
4
  export declare function addControlledTextareaEventHandlers(dom: HTMLTextAreaElement): void;
5
5
  export declare function removeControlledTextareaEventHandlers(dom: HTMLTextAreaElement): void;
@@ -1,5 +1,5 @@
1
1
  import { syncRerenderLocker } from '../../../core/internal.js';
2
- import { getElementFromDom } from '../../attach-element-to-dom';
2
+ import { getElementFromDom } from '../../attach-element-to-dom.js';
3
3
  export function isEventNameIgnored(eventName) {
4
4
  return eventName === 'onChange' || eventName === 'onInput';
5
5
  }
@@ -1,4 +1,4 @@
1
- import type { Maybe } from '../../shared';
1
+ import type { Maybe } from '../../shared/index.js';
2
2
  import type { SimpElement } from '../../core/internal.js';
3
3
  export declare function patchDangerInnerHTML(prevValue: Maybe<{
4
4
  __html: string;
@@ -1 +1 @@
1
- export * from './props';
1
+ export * from './props.js';
@@ -1 +1 @@
1
- export * from './props';
1
+ export * from './props.js';
@@ -1,5 +1,5 @@
1
1
  import type { SimpElement } from '../../core/internal.js';
2
- import type { Namespace } from '../namespace';
2
+ import type { Namespace } from '../namespace.js';
3
3
  export declare function mountProps(dom: HTMLElement | SVGElement, element: SimpElement, namespace: Namespace): void;
4
4
  export declare function unmountProps(dom: HTMLElement | SVGElement, element: SimpElement): void;
5
5
  export declare function patchProps(dom: HTMLElement | SVGElement, prevElement: SimpElement, nextElement: SimpElement, namespace: Namespace): void;
@@ -1,9 +1,9 @@
1
- import { emptyObject } from '../../shared';
2
- import { defaultNamespace } from '../namespace';
3
- import { addControlledFormElementEventHandlers, isEventNameIgnored, isFormElementControlled, removeControlledFormElementEventHandlers, syncControlledFormElementPropsWithAttrs, } from './controlled';
4
- import { isPropNameEventName, patchEvent } from '../events';
5
- import { patchStyle } from './style';
6
- import { patchDangerInnerHTML } from './dangerInnerHTML';
1
+ import { emptyObject } from '../../shared/index.js';
2
+ import { defaultNamespace } from '../namespace.js';
3
+ import { addControlledFormElementEventHandlers, isEventNameIgnored, isFormElementControlled, removeControlledFormElementEventHandlers, syncControlledFormElementPropsWithAttrs, } from './controlled/index.js';
4
+ import { isPropNameEventName, patchEvent } from '../events.js';
5
+ import { patchStyle } from './style.js';
6
+ import { patchDangerInnerHTML } from './dangerInnerHTML.js';
7
7
  export function mountProps(dom, element, namespace) {
8
8
  if (!isFormElement(element)) {
9
9
  for (const propName in element.props) {
package/dom/render.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { type SimpElement } from '../core/internal.js';
2
- import type { Nullable } from '../shared';
2
+ import type { Nullable } from '../shared/index.js';
3
3
  export declare function render(element: Nullable<SimpElement>, container: Nullable<Element | DocumentFragment>): void;
4
4
  interface SimpRoot {
5
5
  render(element: SimpElement): void;
package/dom/render.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { asyncRerenderLocker, hostAdapter, mount, patch, provideHostAdapter, remove, } from '../core/internal.js';
2
- import { domAdapter } from './domAdapter';
3
- import { attachElementToDom, getElementFromDom } from './attach-element-to-dom';
2
+ import { domAdapter } from './domAdapter.js';
3
+ import { attachElementToDom, getElementFromDom } from './attach-element-to-dom.js';
4
4
  provideHostAdapter(domAdapter);
5
5
  export function render(element, container) {
6
6
  if (!container) {
package/hooks/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { RefObject, SimpContext } from '../core';
1
+ import type { RefObject, SimpContext } from '../core/index.js';
2
2
 
3
3
  export type Cleanup = () => void;
4
4
  export type Effect = () => void | Cleanup;
package/hooks/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { lifecycleEventBus, rerender, syncRerenderLocker } from '../core/internal.js';
2
- import { noop } from '../shared';
2
+ import { noop } from '../shared/index.js';
3
3
  let currentIndex = 0;
4
4
  // In runtime this is a nullable variable.
5
5
  let currentElement;
@@ -1,5 +1,5 @@
1
- import type { FC, Fragment as FragmentType, Key, SimpElement } from '../core';
2
- import type { Maybe } from '../shared';
1
+ import type { FC, Fragment as FragmentType, Key, SimpElement } from '../core/index.js';
2
+ import type { Maybe } from '../shared/index.js';
3
3
  import type {
4
4
  AnchorHTMLAttributes,
5
5
  AreaHTMLAttributes,
@@ -54,7 +54,7 @@ import type {
54
54
  TrackHTMLAttributes,
55
55
  VideoHTMLAttributes,
56
56
  WebViewHTMLAttributes,
57
- } from '../dom';
57
+ } from '../dom/index.js';
58
58
 
59
59
  declare function jsx<P = {}>(type: string | FC<P>, props?: P, key?: Maybe<Key>): SimpElement<P>;
60
60
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@simpreact/simpreact",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
4
4
  "description": "",
5
5
  "homepage": "https://github.com/dPaskhin/simpreact#readme",
6
6
  "main": "./core/index.js",
@@ -44,6 +44,7 @@
44
44
  "url": "git+https://github.com/dPaskhin/simpreact.git"
45
45
  },
46
46
  "sideEffects": false,
47
+ "type": "module",
47
48
  "license": "MIT",
48
49
  "author": "Dmitrii Paskhin <d.pasxin@gmail.com>",
49
50
  "dependencies": {
package/shared/index.js CHANGED
@@ -1,5 +1,5 @@
1
- import { EventBus } from './EventBus';
2
- import { emptyArray, emptyMap, emptyObject } from './lang';
3
- import { isSimpText, noop } from './utils';
1
+ import { EventBus } from './EventBus.js';
2
+ import { emptyArray, emptyMap, emptyObject } from './lang.js';
3
+ import { isSimpText, noop } from './utils.js';
4
4
  export { emptyObject, emptyMap, emptyArray, isSimpText, EventBus, noop };
5
5
  export default { isSimpText, EMPTY_MAP: emptyMap, EMPTY_ARRAY: emptyArray, EMPTY_OBJECT: emptyObject, EventBus, noop };
package/shared/utils.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- import type { SimpText } from './public';
1
+ import type { SimpText } from './public.js';
2
2
  export declare function isSimpText(value: unknown): value is SimpText;
3
3
  export declare function noop(): void;