@simpreact/simpreact 0.0.8 → 0.0.9

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 (75) hide show
  1. package/compat/core.js +101 -15
  2. package/compat/hooks.js +15 -0
  3. package/compat/index.d.ts +10 -1
  4. package/compat/renderRuntime.js +47 -12
  5. package/component/index.js +96 -94
  6. package/context/index.js +27 -17
  7. package/core/createElement.js +14 -17
  8. package/core/flags.js +31 -0
  9. package/core/hostOperations.js +5 -13
  10. package/core/index.d.ts +38 -8
  11. package/core/index.js +3 -2
  12. package/core/internal.d.ts +136 -16
  13. package/core/internal.js +8 -16
  14. package/core/lifecycleEventBus.js +35 -16
  15. package/core/memo.js +4 -1
  16. package/core/mounting.js +70 -150
  17. package/core/mountingChildren.js +11 -29
  18. package/core/patching.js +122 -181
  19. package/core/patchingChildren.js +74 -145
  20. package/core/portal.js +1 -1
  21. package/core/processStack.js +115 -45
  22. package/core/ref.js +1 -0
  23. package/core/rerender.js +20 -22
  24. package/core/runtime.js +10 -2
  25. package/core/unmounting.js +41 -49
  26. package/core/unmountingChildren.js +9 -12
  27. package/core/utils.js +38 -16
  28. package/dom/attach-element-to-dom.js +16 -8
  29. package/dom/events.js +11 -15
  30. package/dom/index.d.ts +2 -0
  31. package/dom/props/attrMaps.js +90 -0
  32. package/dom/props/controlled/select.js +8 -10
  33. package/dom/props/props.js +13 -14
  34. package/hooks/index.d.ts +3 -0
  35. package/hooks/index.js +107 -84
  36. package/package.json +10 -5
  37. package/compat/context.d.ts +0 -7
  38. package/compat/core.d.ts +0 -48
  39. package/compat/dom.d.ts +0 -10
  40. package/compat/hooks.d.ts +0 -26
  41. package/compat/jsx-runtime.d.ts +0 -10
  42. package/compat/renderRuntime.d.ts +0 -6
  43. package/core/createElement.d.ts +0 -39
  44. package/core/fragment.d.ts +0 -5
  45. package/core/hostAdapter.d.ts +0 -23
  46. package/core/hostOperations.d.ts +0 -5
  47. package/core/lifecycleEventBus.d.ts +0 -39
  48. package/core/memo.d.ts +0 -8
  49. package/core/mounting.d.ts +0 -7
  50. package/core/mountingChildren.d.ts +0 -4
  51. package/core/patching.d.ts +0 -8
  52. package/core/patchingChildren.d.ts +0 -6
  53. package/core/portal.d.ts +0 -2
  54. package/core/processStack.d.ts +0 -106
  55. package/core/ref.d.ts +0 -18
  56. package/core/rerender.d.ts +0 -4
  57. package/core/runtime.d.ts +0 -17
  58. package/core/unmounting.d.ts +0 -7
  59. package/core/unmountingChildren.d.ts +0 -4
  60. package/core/utils.d.ts +0 -11
  61. package/dom/attach-element-to-dom.d.ts +0 -5
  62. package/dom/domAdapter.d.ts +0 -3
  63. package/dom/events.d.ts +0 -27
  64. package/dom/namespace.d.ts +0 -2
  65. package/dom/props/controlled/index.d.ts +0 -7
  66. package/dom/props/controlled/input.d.ts +0 -7
  67. package/dom/props/controlled/select.d.ts +0 -6
  68. package/dom/props/controlled/textarea.d.ts +0 -6
  69. package/dom/props/dangerInnerHTML.d.ts +0 -7
  70. package/dom/props/index.d.ts +0 -1
  71. package/dom/props/props.d.ts +0 -5
  72. package/dom/props/style.d.ts +0 -1
  73. package/dom/render.d.ts +0 -8
  74. package/shared/lang.d.ts +0 -3
  75. package/shared/utils.d.ts +0 -5
package/hooks/index.js CHANGED
@@ -1,106 +1,124 @@
1
- import { rerender as _rerender, lifecycleEventBus, SIMP_ELEMENT_FLAG_FC, } from '../core/internal.js';
1
+ import { rerender as _rerender, isFC, registerLifecyclePlugin, } from '../core/internal.js';
2
2
  import { callOrGet, shallowEqual, } from '../shared/index.js';
3
- const hooksSpecificStoreByElementStore = new WeakMap();
4
- function getHooksSpecificStore(store) {
5
- let hooksSpecificStore = hooksSpecificStoreByElementStore.get(store);
3
+ const hooksSpecificStoreByElement = new WeakMap();
4
+ const currentFCByRuntime = new WeakMap();
5
+ function getHooksSpecificStore(element) {
6
+ let hooksSpecificStore = hooksSpecificStoreByElement.get(element);
6
7
  if (!hooksSpecificStore) {
7
- hooksSpecificStore = { hooksIndex: 0, hookStates: null, effectsHookStates: null, catchHandlers: null };
8
- hooksSpecificStoreByElementStore.set(store, hooksSpecificStore);
8
+ hooksSpecificStore = {
9
+ hooksIndex: 0,
10
+ expectedHooksCount: null,
11
+ hookStates: null,
12
+ effectsHookStates: null,
13
+ catchHandlers: null,
14
+ };
15
+ hooksSpecificStoreByElement.set(element, hooksSpecificStore);
9
16
  }
10
17
  return hooksSpecificStore;
11
18
  }
12
- window.__SIMP_HOOKS_SPECIFIC_STORE_BY_ELEMENT_STORE__ = hooksSpecificStoreByElementStore;
13
- lifecycleEventBus.subscribe(event => {
14
- if ((event.element.flag & SIMP_ELEMENT_FLAG_FC) === 0) {
15
- return;
16
- }
17
- let store = getHooksSpecificStore(event.element.store);
18
- switch (event.type) {
19
- case 'beforeRender': {
20
- store.hooksIndex = 0;
21
- store.catchHandlers = null;
22
- store.effectsHookStates = null;
23
- break;
19
+ registerLifecyclePlugin(bus => {
20
+ bus.subscribe(event => {
21
+ if (event.type === 'beforeRender') {
22
+ currentFCByRuntime.set(event.renderRuntime, event.element);
24
23
  }
25
- case 'afterRender': {
26
- store.hooksIndex = 0;
27
- break;
24
+ else if (event.type === 'afterRender' || event.type === 'errored') {
25
+ currentFCByRuntime.set(event.renderRuntime, null);
28
26
  }
29
- case 'mounted': {
30
- if (!store.effectsHookStates) {
31
- break;
32
- }
33
- const effects = store.effectsHookStates;
34
- store.effectsHookStates = null;
35
- for (const state of effects) {
36
- state.cleanup = state.effect() || null;
37
- }
38
- break;
27
+ if (!isFC(event.element)) {
28
+ return;
39
29
  }
40
- case 'updated': {
41
- if (!store.effectsHookStates) {
30
+ const store = getHooksSpecificStore(event.element);
31
+ switch (event.type) {
32
+ case 'beforeRender': {
33
+ store.hooksIndex = 0;
34
+ store.catchHandlers = null;
35
+ store.effectsHookStates = null;
42
36
  break;
43
37
  }
44
- const effects = store.effectsHookStates;
45
- store.effectsHookStates = null;
46
- for (const state of effects) {
47
- if (typeof state.cleanup === 'function') {
48
- state.cleanup();
38
+ case 'afterRender': {
39
+ if (store.expectedHooksCount !== null && store.hooksIndex !== store.expectedHooksCount) {
40
+ throw new Error(`Hooks called in a different order than the previous render. Expected ${store.expectedHooksCount}, got ${store.hooksIndex}.`);
49
41
  }
50
- state.cleanup = state.effect() || null;
51
- }
52
- break;
53
- }
54
- case 'unmounted': {
55
- if (!store.hookStates) {
42
+ store.expectedHooksCount = store.hooksIndex;
56
43
  break;
57
44
  }
58
- const hookStates = store.hookStates;
59
- store.hookStates = null;
60
- for (const state of hookStates) {
61
- if (state && 'cleanup' in state && typeof state.cleanup === 'function') {
62
- state.cleanup();
45
+ case 'mounted': {
46
+ if (!store.effectsHookStates) {
47
+ break;
48
+ }
49
+ const effects = store.effectsHookStates;
50
+ store.effectsHookStates = null;
51
+ for (const state of effects) {
52
+ state.cleanup = state.effect() || null;
63
53
  }
64
- }
65
- break;
66
- }
67
- case 'errored': {
68
- store.hooksIndex = 0;
69
- if (event.handled) {
70
54
  break;
71
55
  }
72
- let element = event.element;
73
- let curError = event.error;
74
- let catchers = null;
75
- while (element) {
76
- if ((element.flag & SIMP_ELEMENT_FLAG_FC) === 0) {
77
- element = element.parent;
78
- continue;
56
+ case 'updated': {
57
+ if (!store.effectsHookStates) {
58
+ break;
79
59
  }
80
- store = getHooksSpecificStore(element.store);
81
- catchers = store.catchHandlers;
82
- if (!catchers) {
83
- element = element.parent;
84
- continue;
60
+ const effects = store.effectsHookStates;
61
+ store.effectsHookStates = null;
62
+ for (const state of effects) {
63
+ if (typeof state.cleanup === 'function') {
64
+ state.cleanup();
65
+ }
66
+ state.cleanup = state.effect() || null;
67
+ }
68
+ break;
69
+ }
70
+ case 'unmounted': {
71
+ if (!store.hookStates) {
72
+ break;
85
73
  }
86
- try {
87
- for (let i = 0; i < catchers.length; i++) {
88
- catchers[i](curError);
74
+ const hookStates = store.hookStates;
75
+ store.hookStates = null;
76
+ for (const state of hookStates) {
77
+ if (state && 'cleanup' in state && typeof state.cleanup === 'function') {
78
+ state.cleanup();
89
79
  }
90
- event.handled = true;
80
+ }
81
+ break;
82
+ }
83
+ case 'errored': {
84
+ store.hooksIndex = 0;
85
+ if (event.handled) {
91
86
  break;
92
87
  }
93
- catch (error) {
94
- element = element.parent;
95
- curError = error;
88
+ let element = event.element;
89
+ let curError = event.error;
90
+ let catchers = null;
91
+ while (element) {
92
+ if (!isFC(element)) {
93
+ element = element.parent;
94
+ continue;
95
+ }
96
+ const ancestorStore = getHooksSpecificStore(element);
97
+ catchers = ancestorStore.catchHandlers;
98
+ if (!catchers) {
99
+ element = element.parent;
100
+ continue;
101
+ }
102
+ try {
103
+ for (let i = 0; i < catchers.length; i++) {
104
+ catchers[i](curError);
105
+ }
106
+ event.handled = true;
107
+ break;
108
+ }
109
+ catch (error) {
110
+ element = element.parent;
111
+ curError = error;
112
+ }
96
113
  }
114
+ break;
97
115
  }
98
116
  }
99
- }
117
+ });
100
118
  });
101
119
  export function createUseRef(renderRuntime) {
102
120
  return initialValue => {
103
- const store = getHooksSpecificStore(renderRuntime.currentRenderingFCElement.store);
121
+ const store = getHooksSpecificStore(currentFCByRuntime.get(renderRuntime));
104
122
  const hookStates = getOrCreateHookStates(store);
105
123
  if (!hookStates[store.hooksIndex]) {
106
124
  hookStates[store.hooksIndex] = { current: initialValue };
@@ -110,12 +128,12 @@ export function createUseRef(renderRuntime) {
110
128
  }
111
129
  export function createUseRerender(renderRuntime) {
112
130
  return () => {
113
- const store = getHooksSpecificStore(renderRuntime.currentRenderingFCElement.store);
131
+ const store = getHooksSpecificStore(currentFCByRuntime.get(renderRuntime));
114
132
  const hookStates = getOrCreateHookStates(store);
115
133
  if (!hookStates[store.hooksIndex]) {
116
- const elementStore = renderRuntime.currentRenderingFCElement.store;
134
+ const element = currentFCByRuntime.get(renderRuntime);
117
135
  hookStates[store.hooksIndex] = function rerender() {
118
- _rerender(elementStore, renderRuntime);
136
+ _rerender(element, renderRuntime);
119
137
  };
120
138
  }
121
139
  return hookStates[store.hooksIndex++];
@@ -123,10 +141,10 @@ export function createUseRerender(renderRuntime) {
123
141
  }
124
142
  export function createUseState(renderRuntime) {
125
143
  return (initialState => {
126
- const store = getHooksSpecificStore(renderRuntime.currentRenderingFCElement.store);
144
+ const store = getHooksSpecificStore(currentFCByRuntime.get(renderRuntime));
127
145
  const hookStates = getOrCreateHookStates(store);
128
146
  if (!hookStates[store.hooksIndex]) {
129
- const elementStore = renderRuntime.currentRenderingFCElement.store;
147
+ const element = currentFCByRuntime.get(renderRuntime);
130
148
  const state = (hookStates[store.hooksIndex] = [undefined, undefined]);
131
149
  state[0] = callOrGet(initialState);
132
150
  state[1] = function dispatch(action) {
@@ -135,7 +153,7 @@ export function createUseState(renderRuntime) {
135
153
  return;
136
154
  }
137
155
  state[0] = nextValue;
138
- _rerender(elementStore, renderRuntime);
156
+ _rerender(element, renderRuntime);
139
157
  };
140
158
  }
141
159
  return hookStates[store.hooksIndex++];
@@ -143,7 +161,7 @@ export function createUseState(renderRuntime) {
143
161
  }
144
162
  export function createUseEffect(renderRuntime) {
145
163
  return (effect, deps) => {
146
- const store = getHooksSpecificStore(renderRuntime.currentRenderingFCElement.store);
164
+ const store = getHooksSpecificStore(currentFCByRuntime.get(renderRuntime));
147
165
  const hookStates = getOrCreateHookStates(store);
148
166
  let state = hookStates[store.hooksIndex];
149
167
  if (!state) {
@@ -163,13 +181,17 @@ export function createUseEffect(renderRuntime) {
163
181
  }
164
182
  export function createUseCatch(renderRuntime) {
165
183
  return cb => {
166
- const store = getHooksSpecificStore(renderRuntime.currentRenderingFCElement.store);
184
+ const store = getHooksSpecificStore(currentFCByRuntime.get(renderRuntime));
167
185
  if (!store.catchHandlers) {
168
186
  store.catchHandlers = [];
169
187
  }
170
188
  store.catchHandlers.push(cb);
189
+ store.hooksIndex++;
171
190
  };
172
191
  }
192
+ export function areDepsEqual(nextDeps, prevDeps) {
193
+ return shallowEqual(nextDeps, prevDeps);
194
+ }
173
195
  function getOrCreateHookStates(store) {
174
196
  if (!store.hookStates) {
175
197
  store.hookStates = [];
@@ -188,4 +210,5 @@ export default {
188
210
  createUseState,
189
211
  createUseEffect,
190
212
  createUseCatch,
213
+ areDepsEqual,
191
214
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@simpreact/simpreact",
3
- "version": "0.0.8",
3
+ "version": "0.0.9",
4
4
  "description": "",
5
5
  "homepage": "https://github.com/dPaskhin/simpreact#readme",
6
6
  "main": "./core/index.js",
@@ -12,10 +12,13 @@
12
12
  "types": "./core/index.d.ts"
13
13
  },
14
14
  "./compat": {
15
- "import": "./compat/index.js"
15
+ "import": "./compat/index.js",
16
+ "types": "./compat/index.d.ts",
17
+ "default": "./compat/index.js"
16
18
  },
17
19
  "./compat/*": {
18
- "import": "./compat/index.js"
20
+ "import": "./compat/index.js",
21
+ "default": "./compat/index.js"
19
22
  },
20
23
  "./component": {
21
24
  "import": "./component/index.js",
@@ -31,11 +34,13 @@
31
34
  },
32
35
  "./jsx-runtime": {
33
36
  "import": "./jsx-runtime/index.js",
34
- "types": "./jsx-runtime/index.d.ts"
37
+ "types": "./jsx-runtime/index.d.ts",
38
+ "default": "./jsx-runtime/index.js"
35
39
  },
36
40
  "./jsx-dev-runtime": {
37
41
  "import": "./jsx-runtime/index.js",
38
- "types": "./jsx-runtime/index.d.ts"
42
+ "types": "./jsx-runtime/index.d.ts",
43
+ "default": "./jsx-runtime/index.js"
39
44
  },
40
45
  "./hooks": {
41
46
  "import": "./hooks/index.js",
@@ -1,7 +0,0 @@
1
- export declare const createContext: import("../context/index.js").CreateContext;
2
- export declare const useContext: import("../context/index.js").UseContext;
3
- declare const _default: {
4
- createContext: import("../context/index.js").CreateContext;
5
- useContext: import("../context/index.js").UseContext;
6
- };
7
- export default _default;
package/compat/core.d.ts DELETED
@@ -1,48 +0,0 @@
1
- import type { Ref, SimpElement, SimpNode } from '../core/index.js';
2
- import { createElement as _createElement, createPortal as _createPortal, Fragment as _Fragment, memo as _memo } from '../core/index.js';
3
- export declare const Children: {
4
- map(children: SimpNode, fn: (child: SimpNode, index: number) => SimpNode): SimpNode[];
5
- forEach(children: SimpNode, fn: (child: SimpNode, index: number) => void): void;
6
- count(children: SimpNode): number;
7
- toArray(children: SimpNode): SimpNode[];
8
- only(children: SimpNode): SimpElement;
9
- };
10
- export declare function cloneElement(element: SimpElement, props?: any, ...children: SimpNode[]): SimpElement;
11
- export declare function isValidElement(element: unknown): element is SimpElement;
12
- export declare function Suspense(props: {
13
- fallback: SimpNode;
14
- children: SimpNode;
15
- }): SimpNode;
16
- export declare function StrictMode(props: {
17
- children: SimpNode;
18
- }): SimpNode;
19
- export declare function forwardRef<P, T>(Component: (props: P, ref: Ref<T>) => any): (props: P) => any;
20
- export declare const Fragment: _Fragment;
21
- export declare const createElement: typeof _createElement;
22
- export declare const createPortal: typeof _createPortal;
23
- export declare const memo: typeof _memo;
24
- export declare const flushSync: (value: any) => any;
25
- export declare class Component {
26
- constructor();
27
- }
28
- declare const _default: {
29
- Children: {
30
- map(children: SimpNode, fn: (child: SimpNode, index: number) => SimpNode): SimpNode[];
31
- forEach(children: SimpNode, fn: (child: SimpNode, index: number) => void): void;
32
- count(children: SimpNode): number;
33
- toArray(children: SimpNode): SimpNode[];
34
- only(children: SimpNode): SimpElement;
35
- };
36
- cloneElement: typeof cloneElement;
37
- isValidElement: typeof isValidElement;
38
- Suspense: typeof Suspense;
39
- StrictMode: typeof StrictMode;
40
- forwardRef: typeof forwardRef;
41
- Fragment: _Fragment;
42
- createElement: typeof _createElement;
43
- createPortal: typeof _createPortal;
44
- memo: typeof _memo;
45
- flushSync: (value: any) => any;
46
- Component: typeof Component;
47
- };
48
- export default _default;
package/compat/dom.d.ts DELETED
@@ -1,10 +0,0 @@
1
- import { noop } from '../shared/index.js';
2
- export declare const hydrate: typeof noop;
3
- export declare const render: (element: import("../shared/index.js").Nullable<import("../core/createElement.js").SimpElement>, container: import("../shared/index.js").Nullable<Element | DocumentFragment>) => void;
4
- export declare const createRoot: (container: Element | DocumentFragment) => import("../dom/render.js").SimpRoot;
5
- declare const _default: {
6
- hydrate: typeof noop;
7
- render: (element: import("../shared/index.js").Nullable<import("../core/createElement.js").SimpElement>, container: import("../shared/index.js").Nullable<Element | DocumentFragment>) => void;
8
- createRoot: (container: Element | DocumentFragment) => import("../dom/render.js").SimpRoot;
9
- };
10
- export default _default;
package/compat/hooks.d.ts DELETED
@@ -1,26 +0,0 @@
1
- import { type DependencyList } from '../shared/index.js';
2
- export declare const useRerender: () => () => void;
3
- export declare const useState: import("../hooks/index.js").UseState;
4
- export declare const useEffect: (effect: import("../shared/index.js").Effect, deps?: DependencyList) => void;
5
- export declare const useLayoutEffect: (effect: import("../shared/index.js").Effect, deps?: DependencyList) => void;
6
- export declare const useInsertionEffect: (effect: import("../shared/index.js").Effect, deps?: DependencyList) => void;
7
- export declare const useRef: import("../hooks/index.js").UseRef;
8
- export declare const useCatch: (cb: (error: any) => void) => void;
9
- export declare function useSyncExternalStore<T>(subscribe: (callback: () => void) => () => void, getSnapshot: () => T): T;
10
- export declare function useReducer<R extends (state: any, action: any) => any, I>(reducer: R, initializerArg: I, initializer?: (arg: I) => ReturnType<R>): [ReturnType<R>, (action: Parameters<R>[1]) => void];
11
- export declare function useId(prefix?: string): string;
12
- export declare function useMemo<T>(factory: () => T, deps: DependencyList): T;
13
- export declare function useCallback<T>(cb: T, deps: DependencyList): T;
14
- declare const _default: {
15
- useSyncExternalStore: typeof useSyncExternalStore;
16
- useReducer: typeof useReducer;
17
- useId: typeof useId;
18
- useMemo: typeof useMemo;
19
- useCallback: typeof useCallback;
20
- useState: import("../hooks/index.js").UseState;
21
- useEffect: (effect: import("../shared/index.js").Effect, deps?: DependencyList) => void;
22
- useLayoutEffect: (effect: import("../shared/index.js").Effect, deps?: DependencyList) => void;
23
- useInsertionEffect: (effect: import("../shared/index.js").Effect, deps?: DependencyList) => void;
24
- useRef: import("../hooks/index.js").UseRef;
25
- };
26
- export default _default;
@@ -1,10 +0,0 @@
1
- import { jsx as _jsx } from '../jsx-runtime/index.js';
2
- export declare const jsx: typeof _jsx;
3
- export declare const jsxDEV: typeof _jsx;
4
- export declare const jsxs: typeof _jsx;
5
- declare const _default: {
6
- jsx: typeof _jsx;
7
- jsxDEV: typeof _jsx;
8
- jsxs: typeof _jsx;
9
- };
10
- export default _default;
@@ -1,6 +0,0 @@
1
- import type { SimpRenderRuntime } from '../core/internal.js';
2
- export declare const renderRuntime: SimpRenderRuntime;
3
- declare const _default: {
4
- renderRuntime: SimpRenderRuntime;
5
- };
6
- export default _default;
@@ -1,39 +0,0 @@
1
- import type { Nullable, SimpText } from '../shared/index.js';
2
- export type SimpNode = SimpElement | SimpText | Array<SimpNode> | boolean | null | undefined;
3
- export type Key = string | number | bigint;
4
- export type FC = (props: any) => SimpNode;
5
- export declare const SIMP_ELEMENT_FLAG_HOST = 1;
6
- export declare const SIMP_ELEMENT_FLAG_FC: number;
7
- export declare const SIMP_ELEMENT_FLAG_TEXT: number;
8
- export declare const SIMP_ELEMENT_FLAG_PORTAL: number;
9
- export declare const SIMP_ELEMENT_FLAG_FRAGMENT: number;
10
- export declare const SIMP_ELEMENT_CHILD_FLAG_EMPTY = 1;
11
- export declare const SIMP_ELEMENT_CHILD_FLAG_UNKNOWN: number;
12
- export declare const SIMP_ELEMENT_CHILD_FLAG_ELEMENT: number;
13
- export declare const SIMP_ELEMENT_CHILD_FLAG_LIST: number;
14
- export declare const SIMP_ELEMENT_CHILD_FLAG_TEXT: number;
15
- export interface SimpElementStore {
16
- latestElement: Nullable<SimpElement>;
17
- hostNamespace: Nullable<string>;
18
- forceRerender: boolean;
19
- }
20
- export interface SimpElement {
21
- flag: number;
22
- childFlag: number;
23
- parent: Nullable<SimpElement>;
24
- key: Nullable<Key>;
25
- type: Nullable<string | FC>;
26
- props: any;
27
- children: SimpNode;
28
- className: Nullable<string>;
29
- reference: unknown;
30
- store: Nullable<SimpElementStore>;
31
- context: any;
32
- ref: any;
33
- unmounted: Nullable<boolean>;
34
- index: number;
35
- }
36
- export declare function createElement(type: string | FC, props?: any, ...children: SimpNode[]): SimpElement;
37
- export declare function createTextElement(text: SimpText): SimpElement;
38
- export declare function normalizeChildren(element: SimpElement, children: SimpNode, skipIgnoredCheck: boolean): SimpElement;
39
- export declare function normalizeRoot(element: SimpElement, node: SimpNode, skipIgnoredCheck: boolean): SimpElement;
@@ -1,5 +0,0 @@
1
- import type { SimpNode } from './createElement.js';
2
- export type Fragment = (props: {
3
- children?: SimpNode;
4
- }) => SimpNode;
5
- export declare const Fragment: Fragment;
@@ -1,23 +0,0 @@
1
- import type { Maybe, Nullable } from '../shared/index.js';
2
- import type { SimpElement } from './createElement.js';
3
- import type { SimpRenderRuntime } from './runtime.js';
4
- export interface HostAdapter<HostRef = unknown, HostTextRef = unknown, NS = string> {
5
- createReference(type: string, namespace?: Maybe<NS>): HostRef;
6
- createTextReference(text: string): HostTextRef;
7
- mountProps(reference: HostRef, element: SimpElement, renderRuntime: SimpRenderRuntime, namespace?: Maybe<NS>): void;
8
- patchProps(reference: HostRef, prevElement: SimpElement, nextElement: SimpElement, renderRuntime: SimpRenderRuntime, namespace?: Maybe<NS>): void;
9
- unmountProps(reference: HostRef, element: SimpElement, renderRuntime: SimpRenderRuntime): void;
10
- setClassname(reference: HostRef, className: Maybe<string>, namespace?: Maybe<NS>): void;
11
- setTextContent(reference: HostRef, text: string, referenceHasOnlyTextElement?: boolean): void;
12
- removeChild(parent: HostRef, child: HostRef | HostTextRef): void;
13
- replaceChild(parent: HostRef, replacer: HostRef | HostTextRef, toBeReplaced: HostRef | HostTextRef): void;
14
- insertOrAppend(parent: HostRef, child: HostRef | HostTextRef, before: Nullable<HostRef | HostTextRef>): void;
15
- clearNode(reference: HostRef | HostTextRef): void;
16
- attachElementToReference(element: SimpElement, reference: HostRef | HostTextRef, renderRuntime: SimpRenderRuntime): void;
17
- detachElementFromReference(reference: HostRef | HostTextRef, renderRuntime: SimpRenderRuntime): void;
18
- getElementFromReference(reference: HostRef | HostTextRef, renderRuntime: SimpRenderRuntime): Nullable<SimpElement>;
19
- getHostNamespaces(element: SimpElement, currentNamespace: Maybe<NS>): Nullable<{
20
- self: Nullable<NS>;
21
- children: Nullable<NS>;
22
- }>;
23
- }
@@ -1,5 +0,0 @@
1
- import type { SimpElement } from './createElement.js';
2
- import { type PlaceElementFrameMeta, type ReplaceElementFrameMeta } from './processStack.js';
3
- import type { SimpRenderRuntime } from './runtime.js';
4
- export declare function _pushHostOperationPlaceElement(element: SimpElement, meta: PlaceElementFrameMeta): void;
5
- export declare function _pushHostOperationReplaceElement(element: SimpElement, renderRuntime: SimpRenderRuntime, meta: ReplaceElementFrameMeta): void;
@@ -1,39 +0,0 @@
1
- import type { SimpElement } from './createElement.js';
2
- import type { SimpRenderRuntime } from './runtime.js';
3
- export type LifecycleEvent = {
4
- type: 'beforeRender';
5
- element: SimpElement;
6
- renderRuntime: SimpRenderRuntime;
7
- } | {
8
- type: 'afterRender';
9
- element: SimpElement;
10
- renderRuntime: SimpRenderRuntime;
11
- } | {
12
- type: 'triedToRerender';
13
- element: SimpElement;
14
- renderRuntime: SimpRenderRuntime;
15
- } | {
16
- type: 'mounted';
17
- element: SimpElement;
18
- renderRuntime: SimpRenderRuntime;
19
- } | {
20
- type: 'updated';
21
- element: SimpElement;
22
- renderRuntime: SimpRenderRuntime;
23
- } | {
24
- type: 'unmounted';
25
- element: SimpElement;
26
- renderRuntime: SimpRenderRuntime;
27
- } | {
28
- type: 'errored';
29
- element: SimpElement;
30
- error: any;
31
- handled: boolean;
32
- renderRuntime: SimpRenderRuntime;
33
- };
34
- type Subscriber = (event: LifecycleEvent) => boolean | void;
35
- export declare const lifecycleEventBus: {
36
- publish(event: LifecycleEvent): void;
37
- subscribe(subscriber: Subscriber): () => void;
38
- };
39
- export {};
package/core/memo.d.ts DELETED
@@ -1,8 +0,0 @@
1
- import { shallowEqual } from '../shared/index.js';
2
- import type { FC, SimpNode } from './createElement.js';
3
- export interface MemoizedComponent {
4
- (props: any): SimpNode;
5
- _compare: (prevProps: any, nextProps: any) => boolean;
6
- }
7
- export declare function memo(Component: FC, compare?: typeof shallowEqual): MemoizedComponent;
8
- export declare function isMemo(type: any): type is MemoizedComponent;
@@ -1,7 +0,0 @@
1
- import type { Maybe, Nullable } from '../shared/index.js';
2
- import { type SimpElement } from './createElement.js';
3
- import { type MountFrame, type MountFrameMeta } from './processStack.js';
4
- import { type SimpRenderRuntime } from './runtime.js';
5
- export declare function mount(element: SimpElement, parentReference: unknown, subtreeRightBoundary: Nullable<SimpElement>, context: unknown, hostNamespace: Maybe<string>, renderRuntime: SimpRenderRuntime): void;
6
- export declare function _mount(frame: MountFrame): void;
7
- export declare function _pushMountEnterFrame(element: SimpElement, meta: MountFrameMeta): void;
@@ -1,4 +0,0 @@
1
- import { type SimpElement } from './createElement.js';
2
- import { type MountChildrenFrame, type MountChildrenFrameMeta } from './processStack.js';
3
- export declare function _pushMountChildrenFrame(parent: SimpElement, meta: MountChildrenFrameMeta): void;
4
- export declare function _mountChildren(frame: MountChildrenFrame): void;
@@ -1,8 +0,0 @@
1
- import type { Maybe, Nullable } from '../shared/index.js';
2
- import { type SimpElement } from './createElement.js';
3
- import { type PatchFrame, type PatchFrameMeta } from './processStack.js';
4
- import { type SimpRenderRuntime } from './runtime.js';
5
- export declare function patch(prevElement: SimpElement, nextElement: SimpElement, parentReference: unknown, subtreeRightBoundary: Nullable<SimpElement>, context: unknown, hostNamespace: Maybe<string>, renderRuntime: SimpRenderRuntime): void;
6
- export declare function _pushPatchEnterFrame(element: SimpElement, meta: PatchFrameMeta): void;
7
- export declare function _pushPatchExitFrame(element: SimpElement, meta: PatchFrameMeta): void;
8
- export declare function _patch(frame: PatchFrame): void;
@@ -1,6 +0,0 @@
1
- import { type SimpElement } from './createElement.js';
2
- import { type PatchChildrenFrame, type PatchChildrenFrameMeta } from './processStack.js';
3
- export declare function _pushPatchChildrenFrame(parent: SimpElement, meta: PatchChildrenFrameMeta): void;
4
- export declare function _pushPatchKeyedChildrenFrame(element: SimpElement, meta: PatchChildrenFrameMeta): void;
5
- export declare function _patchChildren(frame: PatchChildrenFrame): void;
6
- export declare function _patchKeyedChildren(frame: PatchChildrenFrame): void;
package/core/portal.d.ts DELETED
@@ -1,2 +0,0 @@
1
- import { type SimpElement, type SimpNode } from './createElement.js';
2
- export declare function createPortal(children: SimpNode, container: any): SimpElement;