frosty 0.0.121 → 0.0.123

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 (49) hide show
  1. package/dist/_native.d.mts +1 -1
  2. package/dist/_native.d.ts +1 -1
  3. package/dist/_native.js +2 -2
  4. package/dist/_native.mjs +2 -2
  5. package/dist/dom.d.mts +2 -2
  6. package/dist/dom.d.ts +2 -2
  7. package/dist/dom.js +3 -3
  8. package/dist/dom.mjs +3 -3
  9. package/dist/index.js +2 -2
  10. package/dist/index.mjs +4 -4
  11. package/dist/internals/{index-B3K_At0T.js → index-BTjMEx5z.js} +17 -31
  12. package/dist/internals/index-BTjMEx5z.js.map +1 -0
  13. package/dist/internals/{index-CYqgonKo.mjs → index-DH6VUOUf.mjs} +17 -31
  14. package/dist/internals/index-DH6VUOUf.mjs.map +1 -0
  15. package/dist/internals/{index-Dxb4qbGJ.d.ts → index-Dv977x8c.d.ts} +1 -2
  16. package/dist/internals/index-Dv977x8c.d.ts.map +1 -0
  17. package/dist/internals/{index-Dm4wQ4OF.d.mts → index-qu0QYcLb.d.mts} +1 -2
  18. package/dist/internals/index-qu0QYcLb.d.mts.map +1 -0
  19. package/dist/internals/{renderer-BpxETChN.js → renderer-BqLqR04e.js} +32 -13
  20. package/dist/internals/renderer-BqLqR04e.js.map +1 -0
  21. package/dist/internals/{renderer-eqt9d1wX.d.mts → renderer-COSbA8yT.d.mts} +2 -2
  22. package/dist/internals/{renderer-eqt9d1wX.d.mts.map → renderer-COSbA8yT.d.mts.map} +1 -1
  23. package/dist/internals/{renderer-tH1ZrzAE.mjs → renderer-DKLYSJcB.mjs} +3 -3
  24. package/dist/internals/{renderer-tH1ZrzAE.mjs.map → renderer-DKLYSJcB.mjs.map} +1 -1
  25. package/dist/internals/{renderer-DafY1_-y.js → renderer-DWZNtNcG.js} +3 -3
  26. package/dist/internals/{renderer-DafY1_-y.js.map → renderer-DWZNtNcG.js.map} +1 -1
  27. package/dist/internals/{renderer-DYHpS9Pb.d.ts → renderer-DcvgWb5J.d.ts} +2 -2
  28. package/dist/internals/{renderer-DYHpS9Pb.d.ts.map → renderer-DcvgWb5J.d.ts.map} +1 -1
  29. package/dist/internals/{renderer-PC8Rmcn8.mjs → renderer-gPDY5zKQ.mjs} +32 -13
  30. package/dist/internals/renderer-gPDY5zKQ.mjs.map +1 -0
  31. package/dist/internals/{sync-Bx9yYmhM.mjs → sync-DhWOC2bu.mjs} +2 -2
  32. package/dist/internals/{sync-Bx9yYmhM.mjs.map → sync-DhWOC2bu.mjs.map} +1 -1
  33. package/dist/internals/{sync-BeQSFdEN.js → sync-Dl1TH4ss.js} +2 -2
  34. package/dist/internals/{sync-BeQSFdEN.js.map → sync-Dl1TH4ss.js.map} +1 -1
  35. package/dist/server-dom.d.mts +2 -2
  36. package/dist/server-dom.d.ts +2 -2
  37. package/dist/server-dom.js +3 -3
  38. package/dist/server-dom.mjs +3 -3
  39. package/dist/web.d.mts +2 -2
  40. package/dist/web.d.ts +2 -2
  41. package/dist/web.js +4 -4
  42. package/dist/web.mjs +5 -5
  43. package/package.json +1 -1
  44. package/dist/internals/index-B3K_At0T.js.map +0 -1
  45. package/dist/internals/index-CYqgonKo.mjs.map +0 -1
  46. package/dist/internals/index-Dm4wQ4OF.d.mts.map +0 -1
  47. package/dist/internals/index-Dxb4qbGJ.d.ts.map +0 -1
  48. package/dist/internals/renderer-BpxETChN.js.map +0 -1
  49. package/dist/internals/renderer-PC8Rmcn8.mjs.map +0 -1
@@ -1,5 +1,5 @@
1
1
  import { N as NativeElementType, c as PropsType, a as ComponentNode } from './internals/common-l_tn3GdO.mjs';
2
- export { V as VNode, _ as _Renderer } from './internals/index-Dm4wQ4OF.mjs';
2
+ export { V as VNode, _ as _Renderer } from './internals/index-qu0QYcLb.mjs';
3
3
  export { u as uniqueId } from './internals/utils-BYUPY_UY.mjs';
4
4
  import '@o2ter/utils-js';
5
5
  import 'lodash';
package/dist/_native.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { N as NativeElementType, c as PropsType, a as ComponentNode } from './internals/common-l_tn3GdO.js';
2
- export { V as VNode, _ as _Renderer } from './internals/index-Dxb4qbGJ.js';
2
+ export { V as VNode, _ as _Renderer } from './internals/index-Dv977x8c.js';
3
3
  export { u as uniqueId } from './internals/utils-DkVDgsjY.js';
4
4
  import '@o2ter/utils-js';
5
5
  import 'lodash';
package/dist/_native.js CHANGED
@@ -1,8 +1,8 @@
1
1
  'use strict';
2
2
 
3
3
  var runtime = require('./internals/runtime-B6GnZi7A.js');
4
- var renderer = require('./internals/renderer-BpxETChN.js');
5
- var index = require('./internals/index-B3K_At0T.js');
4
+ var renderer = require('./internals/renderer-BqLqR04e.js');
5
+ var index = require('./internals/index-BTjMEx5z.js');
6
6
  var events = require('./internals/events-DFlIK-gk.js');
7
7
  require('lodash');
8
8
  require('nextick');
package/dist/_native.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  import { _ as _createElement } from './internals/runtime-PoXcsgok.mjs';
2
2
  export { N as NativeElementType } from './internals/runtime-PoXcsgok.mjs';
3
- export { _ as _Renderer } from './internals/renderer-PC8Rmcn8.mjs';
4
- export { u as uniqueId } from './internals/index-CYqgonKo.mjs';
3
+ export { _ as _Renderer } from './internals/renderer-gPDY5zKQ.mjs';
4
+ export { u as uniqueId } from './internals/index-DH6VUOUf.mjs';
5
5
  export { E as EventEmitter } from './internals/events-DIQH_mHX.mjs';
6
6
  import 'lodash';
7
7
  import 'nextick';
package/dist/dom.d.mts CHANGED
@@ -1,9 +1,9 @@
1
- import { _ as _DOMRenderer } from './internals/renderer-eqt9d1wX.mjs';
1
+ import { _ as _DOMRenderer } from './internals/renderer-COSbA8yT.mjs';
2
2
  import './internals/common-l_tn3GdO.mjs';
3
3
  import '@o2ter/utils-js';
4
4
  import 'lodash';
5
5
  import 'csstype';
6
- import './internals/index-Dm4wQ4OF.mjs';
6
+ import './internals/index-qu0QYcLb.mjs';
7
7
  import 'jsdom';
8
8
 
9
9
  declare class DOMRenderer extends _DOMRenderer {
package/dist/dom.d.ts CHANGED
@@ -1,9 +1,9 @@
1
- import { _ as _DOMRenderer } from './internals/renderer-DYHpS9Pb.js';
1
+ import { _ as _DOMRenderer } from './internals/renderer-DcvgWb5J.js';
2
2
  import './internals/common-l_tn3GdO.js';
3
3
  import '@o2ter/utils-js';
4
4
  import 'lodash';
5
5
  import 'csstype';
6
- import './internals/index-Dxb4qbGJ.js';
6
+ import './internals/index-Dv977x8c.js';
7
7
  import 'jsdom';
8
8
 
9
9
  declare class DOMRenderer extends _DOMRenderer {
package/dist/dom.js CHANGED
@@ -1,10 +1,10 @@
1
1
  'use strict';
2
2
 
3
- var renderer = require('./internals/renderer-DafY1_-y.js');
3
+ var renderer = require('./internals/renderer-DWZNtNcG.js');
4
4
  require('lodash');
5
5
  require('myers.js');
6
- require('./internals/renderer-BpxETChN.js');
7
- require('./internals/index-B3K_At0T.js');
6
+ require('./internals/renderer-BqLqR04e.js');
7
+ require('./internals/index-BTjMEx5z.js');
8
8
  require('./internals/runtime-B6GnZi7A.js');
9
9
  require('nextick');
10
10
  require('postcss');
package/dist/dom.mjs CHANGED
@@ -1,8 +1,8 @@
1
- import { _ as _DOMRenderer } from './internals/renderer-tH1ZrzAE.mjs';
1
+ import { _ as _DOMRenderer } from './internals/renderer-DKLYSJcB.mjs';
2
2
  import 'lodash';
3
3
  import 'myers.js';
4
- import './internals/renderer-PC8Rmcn8.mjs';
5
- import './internals/index-CYqgonKo.mjs';
4
+ import './internals/renderer-gPDY5zKQ.mjs';
5
+ import './internals/index-DH6VUOUf.mjs';
6
6
  import './internals/runtime-PoXcsgok.mjs';
7
7
  import 'nextick';
8
8
  import 'postcss';
package/dist/index.js CHANGED
@@ -1,9 +1,9 @@
1
1
  'use strict';
2
2
 
3
3
  var runtime = require('./internals/runtime-B6GnZi7A.js');
4
- var index = require('./internals/index-B3K_At0T.js');
4
+ var index = require('./internals/index-BTjMEx5z.js');
5
5
  var _ = require('lodash');
6
- var sync = require('./internals/sync-BeQSFdEN.js');
6
+ var sync = require('./internals/sync-Dl1TH4ss.js');
7
7
  require('myers.js');
8
8
  require('./jsx-runtime.js');
9
9
 
package/dist/index.mjs CHANGED
@@ -1,9 +1,9 @@
1
1
  export { C as ComponentNode, F as Fragment, c as createElement } from './internals/runtime-PoXcsgok.mjs';
2
- import { u as uniqueId, r as reconciler } from './internals/index-CYqgonKo.mjs';
3
- export { E as ErrorBoundary, P as PropsProvider, a as createContext, c as createPairs, m as mergeRefs, b as useContext } from './internals/index-CYqgonKo.mjs';
2
+ import { u as uniqueId, r as reconciler } from './internals/index-DH6VUOUf.mjs';
3
+ export { E as ErrorBoundary, P as PropsProvider, a as createContext, c as createPairs, m as mergeRefs, b as useContext } from './internals/index-DH6VUOUf.mjs';
4
4
  import _ from 'lodash';
5
- import { _ as _useMemo, u as useState, a as useEffect, b as useCallback, c as useErrorContext, d as useSyncExternalStore, e as _useEffect } from './internals/sync-Bx9yYmhM.mjs';
6
- export { R as ResourceErrors, f as useMemo, g as useRendererStorage, h as useResourceErrors } from './internals/sync-Bx9yYmhM.mjs';
5
+ import { _ as _useMemo, u as useState, a as useEffect, b as useCallback, c as useErrorContext, d as useSyncExternalStore, e as _useEffect } from './internals/sync-DhWOC2bu.mjs';
6
+ export { R as ResourceErrors, f as useMemo, g as useRendererStorage, h as useResourceErrors } from './internals/sync-DhWOC2bu.mjs';
7
7
  import 'myers.js';
8
8
  import './jsx-runtime.mjs';
9
9
 
@@ -336,10 +336,6 @@ class UpdateManager {
336
336
  /** @internal */
337
337
  _dirty = [];
338
338
  /** @internal */
339
- _remount = [];
340
- /** @internal */
341
- _removed = new Set();
342
- /** @internal */
343
339
  _refresh;
344
340
  constructor(refresh) {
345
341
  this._refresh = refresh;
@@ -356,16 +352,8 @@ class UpdateManager {
356
352
  this._setDirty(node);
357
353
  this.refresh();
358
354
  }
359
- remount(node) {
360
- if (!this._remount[node._level])
361
- this._remount[node._level] = new Set();
362
- this._remount[node._level].add(node);
363
- }
364
- removed(node) {
365
- this._removed.add(node);
366
- }
367
355
  get isDirty() {
368
- return this._dirty.some(x => !!x.size) || this._remount.some(x => !!x.size);
356
+ return this._dirty.some(x => !!x.size);
369
357
  }
370
358
  }
371
359
  class VNode {
@@ -420,7 +408,7 @@ class VNode {
420
408
  })();
421
409
  }
422
410
  /** @internal */
423
- async _render(event, renderer) {
411
+ async *_render(event, renderer) {
424
412
  try {
425
413
  const { type } = this._component;
426
414
  const props = this._resolve_props();
@@ -428,14 +416,14 @@ class VNode {
428
416
  let native = this._nativeParent;
429
417
  if (_.isString(type) || type?.prototype instanceof runtime.NativeElementType) {
430
418
  children = this._resolve_children(props.children, event);
431
- event.remount(this);
432
419
  native = this;
420
+ yield { mount: this };
433
421
  }
434
422
  else if (isContext(type)) {
435
423
  const { value } = props;
436
424
  if (!equalDeps(this._content_value, value)) {
437
425
  for (const node of this._content_listeners) {
438
- event.setDirty(node);
426
+ yield { dirty: node };
439
427
  }
440
428
  }
441
429
  this._content_value = value;
@@ -460,7 +448,7 @@ class VNode {
460
448
  }
461
449
  await Promise.all(state.tasks);
462
450
  }
463
- event.remount(this);
451
+ yield { mount: this };
464
452
  }
465
453
  else {
466
454
  throw Error(`Invalid node type ${type}`);
@@ -481,24 +469,24 @@ class VNode {
481
469
  if (!(lhs instanceof VNode) || !(rhs instanceof VNode))
482
470
  continue;
483
471
  if (lhs === rhs) {
484
- event.setDirty(lhs);
472
+ yield { dirty: lhs };
485
473
  }
486
474
  else {
487
475
  if (!equalProps(lhs._component.props, rhs._component.props))
488
- event.setDirty(lhs);
476
+ yield { dirty: lhs };
489
477
  lhs._component = rhs._component;
490
478
  }
491
479
  lhs._parent = this;
492
480
  lhs._nativeParent = native;
493
481
  lhs._level = this._level + 1;
494
482
  }
495
- for (const removed of _.flatMap(diff, x => x.remove ?? [])) {
496
- if (removed instanceof VNode) {
497
- event.removed(removed);
483
+ for (const item of _.flatMap(diff, x => x.remove ?? [])) {
484
+ if (item instanceof VNode) {
485
+ yield { removed: item };
498
486
  }
499
487
  }
500
- if (_.some(diff, x => !x.equivalent)) {
501
- this._children_updated(event);
488
+ if (_.some(diff, x => !x.equivalent) && this._nativeParent && this._nativeParent !== this) {
489
+ yield { mount: this._nativeParent };
502
490
  }
503
491
  }
504
492
  catch (error) {
@@ -516,17 +504,15 @@ class VNode {
516
504
  console.error(e);
517
505
  }
518
506
  })();
519
- this._children_updated(event);
507
+ yield { mount: this };
508
+ if (this._nativeParent && this._nativeParent !== this) {
509
+ yield { mount: this._nativeParent };
510
+ }
520
511
  }
521
512
  finally {
522
513
  reconciler._currentHookState = undefined;
523
514
  }
524
515
  }
525
- _children_updated(event) {
526
- const node = this._nativeParent;
527
- if (node && node !== this)
528
- event.remount(node);
529
- }
530
516
  _resolve_props() {
531
517
  const self = this;
532
518
  const { type, props: _props } = this._component;
@@ -610,4 +596,4 @@ exports.mergeRefs = mergeRefs;
610
596
  exports.reconciler = reconciler;
611
597
  exports.uniqueId = uniqueId;
612
598
  exports.useContext = useContext;
613
- //# sourceMappingURL=index-B3K_At0T.js.map
599
+ //# sourceMappingURL=index-BTjMEx5z.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-BTjMEx5z.js","sources":["../../../src/core/components/pairs.ts","../../../src/core/utils.ts","../../../src/core/hooks/context.ts","../../../src/core/types/props.ts","../../../src/core/types/error.ts","../../../src/core/reconciler/utils.ts","../../../src/core/reconciler/index.ts"],"sourcesContent":["//\n// pairs.ts\n//\n// The MIT License\n// Copyright (c) 2021 - 2025 O2ter Limited. All rights reserved.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n//\n\nimport _ from \"lodash\";\nimport { PropsWithChildren } from \"../types/common\";\nimport { NativeElementType } from \"../types/component\";\nimport { _createElement, _ElementType } from \"../types/runtime\";\nimport { VNode } from \"../reconciler\";\nimport { Fragment } from \"./fragment\";\n\nexport abstract class _ParentComponent extends NativeElementType {\n abstract isChildNode(child: string | VNode): boolean;\n}\n\n/**\n * Create a pair of Parent and Child components.\n * \n * @param allowTextChildren - Whether to allow text children in the Parent component.\n * @param allowedChildTypes - An array of additional allowed child component types.\n * @returns An object containing the Parent and Child components.\n */\nexport const createPairs = ({ allowTextChildren, allowedChildTypes = [] }: {\n allowTextChildren?: boolean;\n allowedChildTypes?: (_ElementType | typeof NativeElementType)[];\n} = {}) => {\n const ChildComponent = ({ children }: PropsWithChildren<{}>) => _createElement(Fragment, { children });\n class ParentComponent extends _ParentComponent {\n isChildNode(child: string | VNode) {\n if (_.isString(child)) return !!allowTextChildren;\n return child.type === ChildComponent || _.some(allowedChildTypes, x => child.type === x);\n }\n }\n return {\n Parent: ({ children }: PropsWithChildren<{}>) => _createElement(ParentComponent, { children }),\n Child: ChildComponent,\n }\n}\n","//\n// utils.ts\n//\n// The MIT License\n// Copyright (c) 2021 - 2025 O2ter Limited. All rights reserved.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n//\n\nimport _ from 'lodash';\nimport { Ref } from './types/common';\n\nexport const mergeRefs = <T>(...refs: (Ref<T> | null | undefined)[]) => (x: T) => {\n for (const ref of refs) {\n if (_.isNil(ref)) continue;\n else if (typeof ref === 'function') ref(x);\n else if (typeof ref === 'object') ref.current = x;\n else {\n console.error(`mergeRefs cannot handle Refs of type boolean, number or string, received ref ${ref}`);\n }\n }\n}\n\nlet counter = 0;\n\nexport const uniqueId = () => `${Date.now().toString(36)}${(counter++).toString(36)}${Math.random().toString(36).slice(2)}`;\n","//\n// index.ts\n//\n// The MIT License\n// Copyright (c) 2021 - 2025 O2ter Limited. All rights reserved.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n//\n\nimport _ from 'lodash';\nimport { reconciler } from '../reconciler';\nimport { ComponentType, ElementNode } from '../types/common';\n\nconst _contextDefaultValue = new WeakMap<Context<any>, any>();\n\nexport const isContext = (type: any): type is Context<any> => {\n return _contextDefaultValue.has(type as any);\n};\n\nexport type Context<Value> = ReturnType<typeof _createContext<Value>>;\nexport type ContextType<C extends Context<any>> = C extends Context<infer T> ? T : never;\n\nconst _createContext = <Value extends unknown>(defaultValue: Value) => {\n const _context: ComponentType<{\n value: Value;\n children?: ElementNode | ((value: Value) => ElementNode);\n }> = ({ value, children }) => {\n return _.isFunction(children) ? children(value) : children;\n };\n const Consumer: ComponentType<{\n children: (value: Value) => ElementNode;\n }> = ({ children }) => {\n const value = useContext(_context as Context<Value>);\n return children(value);\n };\n _contextDefaultValue.set(_context as Context<Value>, defaultValue);\n return _.assign(_context, { Consumer });\n};\n\n/**\n * Creates a new context object with an optional default value.\n *\n * A context object allows you to share a value across a component tree\n * without explicitly passing it as a prop to every level.\n *\n * @template Value - The type of the value to be stored in the context.\n * @param - The default value for the context.\n * @returns A context object that can be used to provide and consume the value.\n */\n\nexport function createContext<Value>(defaultValue: Value): Context<Value>;\nexport function createContext<Value = undefined>(): Context<Value | undefined>;\n\nexport function createContext(defaultValue?: any) {\n return _createContext(defaultValue);\n}\n\n/**\n * A hook that retrieves the current value of a context and optionally applies\n * a selector function to transform the context value. This hook ensures that the component\n * subscribes to the context and re-renders when the context value changes.\n *\n * @template T - The type of the context value.\n * @template R - The type of the transformed value returned by the selector.\n * @param context - The context object to retrieve the value from.\n * @param selector - An optional selector function to transform the context value.\n * Defaults to an identity function.\n * @returns - The current value of the context, optionally transformed by the selector.\n *\n * @throws - Throws an error if the provided context is invalid or if the hook\n * is used outside of a render function.\n *\n * @example\n * const MyContext = createContext({ user: null });\n * \n * function MyComponent() {\n * const user = useContext(MyContext, context => context.user);\n * return <div>{user ? `Hello, ${user.name}` : 'Hello, Guest'}</div>;\n * }\n */\nexport const useContext = <T, R = T>(\n context: Context<T>,\n selector: (state: T) => R = v => v as any\n) => {\n if (!isContext(context)) throw Error(`Invalid type of ${context}`);\n const state = reconciler.currentHookState;\n if (!state) throw Error('useContext must be used within a render function.');\n const node = state.resolveContextNode(context);\n if (node) {\n state.context.add(node);\n return selector(node.props.value);\n }\n return selector(_contextDefaultValue.get(context));\n};\n","//\n// props.ts\n//\n// The MIT License\n// Copyright (c) 2021 - 2025 O2ter Limited. All rights reserved.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n//\n\nimport { ComponentType, PropsWithChildren } from './common';\nimport { NativeElementType } from './component';\nimport { _ElementType, PropsType } from './runtime';\n\ntype PropsProviderProps = PropsWithChildren<{\n callback: (v: {\n type: _ElementType | typeof NativeElementType,\n props: PropsType\n }) => PropsType | undefined | null;\n}>;\n\nexport const PropsProvider: ComponentType<PropsProviderProps> = ({ children }) => {\n return children;\n}\n","//\n// error.ts\n//\n// The MIT License\n// Copyright (c) 2021 - 2025 O2ter Limited. All rights reserved.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n//\n\nimport { ComponentType, PropsWithChildren } from './common';\nimport { ComponentNode } from './component';\n\ntype ErrorBoundaryProps = PropsWithChildren<{\n silent?: boolean;\n onError?: (\n error: any,\n component: ComponentNode,\n stack: ComponentNode[],\n ) => void;\n}>;\n\nexport const ErrorBoundary: ComponentType<ErrorBoundaryProps> = ({ children }) => {\n return children;\n}\n","//\n// index.ts\n//\n// The MIT License\n// Copyright (c) 2021 - 2025 O2ter Limited. All rights reserved.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n//\n\nimport _ from 'lodash';\n\nconst _equalDeps = (lhs: any, rhs: any, stack: [any, any][]) => {\n if (lhs === rhs) return true;\n if (_.isFunction(lhs) || _.isFunction(rhs)) return false;\n\n // Check if we've already compared these objects (circular reference detection)\n const lhsIndex = _.findIndex(stack, s => s[0] === lhs);\n const rhsIndex = _.findIndex(stack, s => s[1] === rhs);\n\n // If both are in the stack at the same position, they're part of the same circular structure\n if (lhsIndex !== -1 && rhsIndex !== -1 && lhsIndex === rhsIndex) return true;\n\n // If only one is in the stack, they're not equal\n if (lhsIndex !== -1 || rhsIndex !== -1) return false;\n\n if (_.isArray(lhs) && _.isArray(rhs)) {\n if (lhs.length !== rhs.length) return false;\n const newStack: [any, any][] = [...stack, [lhs, rhs]];\n for (let i = 0; i < lhs.length; i++) {\n if (!_equalDeps(lhs[i], rhs[i], newStack)) return false;\n }\n return true;\n }\n if (_.isPlainObject(lhs) && _.isPlainObject(rhs)) {\n const lkeys = _.keys(lhs);\n const rkeys = _.keys(rhs);\n if (lkeys.length !== rkeys.length) return false;\n const newStack: [any, any][] = [...stack, [lhs, rhs]];\n for (const key of lkeys) {\n if (!_equalDeps(lhs[key], rhs[key], newStack)) return false;\n }\n return true;\n }\n return false;\n}\n\nexport const equalDeps = (lhs: any, rhs: any) => {\n return _equalDeps(lhs, rhs, []);\n}\n\nexport const equalProps = (lhs: Record<string, any>, rhs: Record<string, any>) => {\n if (lhs === rhs) return true;\n const lkeys = _.keys(lhs);\n const rkeys = _.keys(rhs);\n if (lkeys.length !== rkeys.length) return false;\n for (const key of lkeys) {\n if (_.isFunction(lhs[key]) && _.isFunction(rhs[key])) continue;\n if (!equalDeps(lhs[key], rhs[key])) return false;\n }\n return true;\n};\n","//\n// index.ts\n//\n// The MIT License\n// Copyright (c) 2021 - 2025 O2ter Limited. All rights reserved.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n//\n\nimport _ from 'lodash';\nimport { ComponentNode, NativeElementType } from '../types/component';\nimport { uniqueId } from '../utils';\nimport { Context, isContext } from '../hooks/context';\nimport { PropsProvider } from '../types/props';\nimport { ErrorBoundary } from '../types/error';\nimport { _Renderer } from '../renderer';\nimport { myersSync } from 'myers.js';\nimport { equalDeps, equalProps } from './utils';\nimport { PropsType } from '../types/runtime';\n\ntype VNodeState = {\n hook: string;\n deps: any;\n data?: any;\n mount?: () => () => void;\n};\n\nexport class UpdateManager {\n\n /** @internal */\n _dirty: Set<VNode>[] = [];\n\n /** @internal */\n private _refresh: (x: UpdateManager, force: boolean) => Promise<void>;\n\n constructor(refresh: (x: UpdateManager, force: boolean) => Promise<void>) {\n this._refresh = refresh;\n }\n\n async refresh(force: boolean = false) {\n await this._refresh(this, force);\n }\n\n _setDirty(node: VNode) {\n if (!this._dirty[node._level]) this._dirty[node._level] = new Set();\n this._dirty[node._level].add(node);\n }\n\n setDirty(node: VNode) {\n this._setDirty(node);\n this.refresh();\n }\n\n get isDirty() {\n return this._dirty.some(x => !!x.size);\n }\n}\n\nexport class VNode {\n\n /** @internal */\n _component: ComponentNode;\n\n private _id = uniqueId();\n\n private _props: PropsType = {};\n private _error?: any;\n private _children: (VNode | string)[] = [];\n\n /** @internal */\n _state?: VNodeState[];\n\n /** @internal */\n _content_listeners: Set<VNode> = new Set();\n private _content_value?: any;\n\n /** @internal */\n _context: Set<VNode> = new Set();\n\n /** @internal */\n _parent?: VNode;\n\n /** @internal */\n _nativeParent?: VNode;\n\n /** @internal */\n _level = 0;\n\n /** @internal */\n constructor(component: ComponentNode) {\n this._component = component;\n }\n\n get id() {\n return this._id;\n }\n\n get type() {\n return this._component.type;\n }\n\n get props() {\n return this._props;\n }\n\n get key() {\n return this._component.key;\n }\n\n get children() {\n return this._children;\n }\n\n get error() {\n return this._error;\n }\n\n get stack() {\n let node: VNode | undefined = this;\n return (function* () {\n while (node) {\n yield node;\n node = node._parent;\n }\n })();\n }\n\n /** @internal */\n async* _render(event: UpdateManager, renderer: _Renderer<any>) {\n try {\n const { type } = this._component;\n const props = this._resolve_props();\n let children: (VNode | string)[];\n let native = this._nativeParent;\n if (_.isString(type) || type?.prototype instanceof NativeElementType) {\n children = this._resolve_children(props.children, event);\n native = this;\n yield { mount: this };\n } else if (isContext(type)) {\n const { value } = props;\n if (!equalDeps(this._content_value, value)) {\n for (const node of this._content_listeners) {\n yield { dirty: node };\n }\n }\n this._content_value = value;\n children = this._resolve_children(type(props as any), event);\n } else if (_.isFunction(type)) {\n while (true) {\n const state = new HookState(this, event, renderer);\n reconciler._currentHookState = state;\n const rendered = type(props);\n for (const node of this._context.difference(state.context)) {\n node._content_listeners.delete(this);\n }\n for (const node of state.context.difference(this._context)) {\n node._content_listeners.add(this);\n }\n this._state = state.state;\n this._context = state.context;\n if (_.isEmpty(state.tasks)) {\n children = this._resolve_children(rendered, event);\n break;\n }\n await Promise.all(state.tasks);\n }\n yield { mount: this };\n } else {\n throw Error(`Invalid node type ${type}`);\n }\n const diff = myersSync(this._children, children, {\n compare: (lhs, rhs) => {\n if (_.isString(lhs) && _.isString(rhs)) return lhs === rhs;\n if (lhs instanceof VNode && rhs instanceof VNode) return lhs._component.equalType(rhs._component);\n return false;\n },\n });\n this._props = props;\n this._children = _.flatMap(diff, x => x.equivalent ?? x.insert ?? []);\n this._error = undefined;\n for (const [lhs, rhs] of _.zip(this._children, children)) {\n if (!(lhs instanceof VNode) || !(rhs instanceof VNode)) continue;\n if (lhs === rhs) {\n yield { dirty: lhs };\n } else {\n if (!equalProps(lhs._component.props, rhs._component.props)) yield { dirty: lhs };\n lhs._component = rhs._component;\n }\n lhs._parent = this;\n lhs._nativeParent = native;\n lhs._level = this._level + 1;\n }\n for (const item of _.flatMap(diff, x => x.remove ?? [])) {\n if (item instanceof VNode) {\n yield { removed: item };\n }\n }\n if (_.some(diff, x => !x.equivalent) && this._nativeParent && this._nativeParent !== this) {\n yield { mount: this._nativeParent };\n }\n } catch (error) {\n this._children = [];\n this._error = error;\n (async () => {\n try {\n const { onError, silent } = this._resolve_error_boundary() ?? {};\n if (!silent) console.error(error);\n if (_.isFunction(onError)) await onError(error, this._component, this.stack.map(x => x._component));\n } catch (e) {\n console.error(e);\n }\n })();\n yield { mount: this };\n if (this._nativeParent && this._nativeParent !== this) {\n yield { mount: this._nativeParent };\n }\n } finally {\n reconciler._currentHookState = undefined;\n }\n }\n\n private _resolve_props() {\n const self = this;\n const { type, props: _props } = this._component;\n if (type === PropsProvider) return _props;\n let props = { ..._props };\n for (const node of this.stack.drop(1)) {\n if (node.type === PropsProvider) {\n props = node.props.callback({ type, props });\n }\n }\n return _.mapValues(props, (v, k) => _.isFunction(v) ? function (this: any, ...args: any[]) {\n const current = self._component.props[k];\n return _.isFunction(current) ? current.call(this, ...args) : v.call(this, ...args);\n } : v);\n }\n\n private _resolve_children(child: any, event: UpdateManager): (VNode | string)[] {\n if (_.isBoolean(child) || _.isNil(child)) return [];\n if (_.isString(child)) return [child];\n if (_.isNumber(child)) return [`${child}`];\n if (child instanceof ComponentNode) return [new VNode(child)];\n if (_.isArrayLikeObject(child)) return _.flatMap(child, x => this._resolve_children(x, event));\n if (typeof child[Symbol.iterator] === 'function') return _.flatMap([...child], x => this._resolve_children(x, event));\n throw Error(`${child} are not valid as a child.`);\n }\n\n private _resolve_error_boundary() {\n return this.stack.drop(1).find(node => node.type === ErrorBoundary)?.props;\n }\n}\n\nclass HookState {\n\n node: VNode;\n event: UpdateManager;\n renderer: _Renderer<any>;\n\n state: VNodeState[] = [];\n tasks: PromiseLike<void>[] = [];\n context: Set<VNode> = new Set();\n\n constructor(\n node: VNode,\n event: UpdateManager,\n renderer: _Renderer<any>,\n ) {\n this.node = node;\n this.event = event;\n this.renderer = renderer;\n }\n\n get prevState() {\n return this.node._state;\n }\n\n get stack() {\n const [, ...stack] = this.node.stack;\n return stack;\n }\n\n setDirty() {\n this.event.setDirty(this.node);\n }\n\n resolveContextNode(context: Context<any>) {\n return this.stack.find(node => node.type === context);\n }\n}\n\nexport const reconciler = new class {\n\n /** @internal */\n _registry = new WeakMap<any, string>();\n\n /** @internal */\n _currentHookState?: HookState;\n\n get currentHookState() {\n return this._currentHookState;\n }\n};\n"],"names":["NativeElementType","_createElement","Fragment","myersSync","ComponentNode"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AASM,MAAgB,gBAAiB,SAAQA,yBAAiB,CAAA;AAE/D;AAED;;;;;;AAMG;AACI,MAAM,WAAW,GAAG,CAAC,EAAE,iBAAiB,EAAE,iBAAiB,GAAG,EAAE,EAAA,GAGnE,EAAE,KAAI;AACR,IAAA,MAAM,cAAc,GAAG,CAAC,EAAE,QAAQ,EAAyB,KAAKC,sBAAc,CAACC,gBAAQ,EAAE,EAAE,QAAQ,EAAE,CAAC;IACtG,MAAM,eAAgB,SAAQ,gBAAgB,CAAA;AAC5C,QAAA,WAAW,CAAC,KAAqB,EAAA;AAC/B,YAAA,IAAI,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC;gBAAE,OAAO,CAAC,CAAC,iBAAiB;YACjD,OAAO,KAAK,CAAC,IAAI,KAAK,cAAc,IAAI,CAAC,CAAC,IAAI,CAAC,iBAAiB,EAAE,CAAC,IAAI,KAAK,CAAC,IAAI,KAAK,CAAC,CAAC;QAC1F;AACD;IACD,OAAO;AACL,QAAA,MAAM,EAAE,CAAC,EAAE,QAAQ,EAAyB,KAAKD,sBAAc,CAAC,eAAe,EAAE,EAAE,QAAQ,EAAE,CAAC;AAC9F,QAAA,KAAK,EAAE,cAAc;KACtB;AACH;;AC1DA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAKO,MAAM,SAAS,GAAG,CAAI,GAAG,IAAmC,KAAK,CAAC,CAAI,KAAI;AAC/E,IAAA,KAAK,MAAM,GAAG,IAAI,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AC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC;IAChC;AAEA,IAAA,kBAAkB,CAAC,OAAqB,EAAA;AACtC,QAAA,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,IAAI,KAAK,OAAO,CAAC;IACvD;AACD;AAEM,MAAM,UAAU,GAAG,IAAI,MAAA;;AAG5B,IAAA,SAAS,GAAG,IAAI,OAAO,EAAe;;AAGtC,IAAA,iBAAiB;AAEjB,IAAA,IAAI,gBAAgB,GAAA;QAClB,OAAO,IAAI,CAAC,iBAAiB;IAC/B;;;;;;;;;;;;;;;;"}
@@ -334,10 +334,6 @@ class UpdateManager {
334
334
  /** @internal */
335
335
  _dirty = [];
336
336
  /** @internal */
337
- _remount = [];
338
- /** @internal */
339
- _removed = new Set();
340
- /** @internal */
341
337
  _refresh;
342
338
  constructor(refresh) {
343
339
  this._refresh = refresh;
@@ -354,16 +350,8 @@ class UpdateManager {
354
350
  this._setDirty(node);
355
351
  this.refresh();
356
352
  }
357
- remount(node) {
358
- if (!this._remount[node._level])
359
- this._remount[node._level] = new Set();
360
- this._remount[node._level].add(node);
361
- }
362
- removed(node) {
363
- this._removed.add(node);
364
- }
365
353
  get isDirty() {
366
- return this._dirty.some(x => !!x.size) || this._remount.some(x => !!x.size);
354
+ return this._dirty.some(x => !!x.size);
367
355
  }
368
356
  }
369
357
  class VNode {
@@ -418,7 +406,7 @@ class VNode {
418
406
  })();
419
407
  }
420
408
  /** @internal */
421
- async _render(event, renderer) {
409
+ async *_render(event, renderer) {
422
410
  try {
423
411
  const { type } = this._component;
424
412
  const props = this._resolve_props();
@@ -426,14 +414,14 @@ class VNode {
426
414
  let native = this._nativeParent;
427
415
  if (_.isString(type) || type?.prototype instanceof NativeElementType) {
428
416
  children = this._resolve_children(props.children, event);
429
- event.remount(this);
430
417
  native = this;
418
+ yield { mount: this };
431
419
  }
432
420
  else if (isContext(type)) {
433
421
  const { value } = props;
434
422
  if (!equalDeps(this._content_value, value)) {
435
423
  for (const node of this._content_listeners) {
436
- event.setDirty(node);
424
+ yield { dirty: node };
437
425
  }
438
426
  }
439
427
  this._content_value = value;
@@ -458,7 +446,7 @@ class VNode {
458
446
  }
459
447
  await Promise.all(state.tasks);
460
448
  }
461
- event.remount(this);
449
+ yield { mount: this };
462
450
  }
463
451
  else {
464
452
  throw Error(`Invalid node type ${type}`);
@@ -479,24 +467,24 @@ class VNode {
479
467
  if (!(lhs instanceof VNode) || !(rhs instanceof VNode))
480
468
  continue;
481
469
  if (lhs === rhs) {
482
- event.setDirty(lhs);
470
+ yield { dirty: lhs };
483
471
  }
484
472
  else {
485
473
  if (!equalProps(lhs._component.props, rhs._component.props))
486
- event.setDirty(lhs);
474
+ yield { dirty: lhs };
487
475
  lhs._component = rhs._component;
488
476
  }
489
477
  lhs._parent = this;
490
478
  lhs._nativeParent = native;
491
479
  lhs._level = this._level + 1;
492
480
  }
493
- for (const removed of _.flatMap(diff, x => x.remove ?? [])) {
494
- if (removed instanceof VNode) {
495
- event.removed(removed);
481
+ for (const item of _.flatMap(diff, x => x.remove ?? [])) {
482
+ if (item instanceof VNode) {
483
+ yield { removed: item };
496
484
  }
497
485
  }
498
- if (_.some(diff, x => !x.equivalent)) {
499
- this._children_updated(event);
486
+ if (_.some(diff, x => !x.equivalent) && this._nativeParent && this._nativeParent !== this) {
487
+ yield { mount: this._nativeParent };
500
488
  }
501
489
  }
502
490
  catch (error) {
@@ -514,17 +502,15 @@ class VNode {
514
502
  console.error(e);
515
503
  }
516
504
  })();
517
- this._children_updated(event);
505
+ yield { mount: this };
506
+ if (this._nativeParent && this._nativeParent !== this) {
507
+ yield { mount: this._nativeParent };
508
+ }
518
509
  }
519
510
  finally {
520
511
  reconciler._currentHookState = undefined;
521
512
  }
522
513
  }
523
- _children_updated(event) {
524
- const node = this._nativeParent;
525
- if (node && node !== this)
526
- event.remount(node);
527
- }
528
514
  _resolve_props() {
529
515
  const self = this;
530
516
  const { type, props: _props } = this._component;
@@ -597,4 +583,4 @@ const reconciler = new class {
597
583
  };
598
584
 
599
585
  export { ErrorBoundary as E, PropsProvider as P, UpdateManager as U, VNode as V, _ParentComponent as _, createContext as a, useContext as b, createPairs as c, equalDeps as e, mergeRefs as m, reconciler as r, uniqueId as u };
600
- //# sourceMappingURL=index-CYqgonKo.mjs.map
586
+ //# sourceMappingURL=index-DH6VUOUf.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-DH6VUOUf.mjs","sources":["../../../src/core/components/pairs.ts","../../../src/core/utils.ts","../../../src/core/hooks/context.ts","../../../src/core/types/props.ts","../../../src/core/types/error.ts","../../../src/core/reconciler/utils.ts","../../../src/core/reconciler/index.ts"],"sourcesContent":["//\n// pairs.ts\n//\n// The MIT License\n// Copyright (c) 2021 - 2025 O2ter Limited. All rights reserved.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n//\n\nimport _ from \"lodash\";\nimport { PropsWithChildren } from \"../types/common\";\nimport { NativeElementType } from \"../types/component\";\nimport { _createElement, _ElementType } from \"../types/runtime\";\nimport { VNode } from \"../reconciler\";\nimport { Fragment } from \"./fragment\";\n\nexport abstract class _ParentComponent extends NativeElementType {\n abstract isChildNode(child: string | VNode): boolean;\n}\n\n/**\n * Create a pair of Parent and Child components.\n * \n * @param allowTextChildren - Whether to allow text children in the Parent component.\n * @param allowedChildTypes - An array of additional allowed child component types.\n * @returns An object containing the Parent and Child components.\n */\nexport const createPairs = ({ allowTextChildren, allowedChildTypes = [] }: {\n allowTextChildren?: boolean;\n allowedChildTypes?: (_ElementType | typeof NativeElementType)[];\n} = {}) => {\n const ChildComponent = ({ children }: PropsWithChildren<{}>) => _createElement(Fragment, { children });\n class ParentComponent extends _ParentComponent {\n isChildNode(child: string | VNode) {\n if (_.isString(child)) return !!allowTextChildren;\n return child.type === ChildComponent || _.some(allowedChildTypes, x => child.type === x);\n }\n }\n return {\n Parent: ({ children }: PropsWithChildren<{}>) => _createElement(ParentComponent, { children }),\n Child: ChildComponent,\n }\n}\n","//\n// utils.ts\n//\n// The MIT License\n// Copyright (c) 2021 - 2025 O2ter Limited. All rights reserved.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n//\n\nimport _ from 'lodash';\nimport { Ref } from './types/common';\n\nexport const mergeRefs = <T>(...refs: (Ref<T> | null | undefined)[]) => (x: T) => {\n for (const ref of refs) {\n if (_.isNil(ref)) continue;\n else if (typeof ref === 'function') ref(x);\n else if (typeof ref === 'object') ref.current = x;\n else {\n console.error(`mergeRefs cannot handle Refs of type boolean, number or string, received ref ${ref}`);\n }\n }\n}\n\nlet counter = 0;\n\nexport const uniqueId = () => `${Date.now().toString(36)}${(counter++).toString(36)}${Math.random().toString(36).slice(2)}`;\n","//\n// index.ts\n//\n// The MIT License\n// Copyright (c) 2021 - 2025 O2ter Limited. All rights reserved.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n//\n\nimport _ from 'lodash';\nimport { reconciler } from '../reconciler';\nimport { ComponentType, ElementNode } from '../types/common';\n\nconst _contextDefaultValue = new WeakMap<Context<any>, any>();\n\nexport const isContext = (type: any): type is Context<any> => {\n return _contextDefaultValue.has(type as any);\n};\n\nexport type Context<Value> = ReturnType<typeof _createContext<Value>>;\nexport type ContextType<C extends Context<any>> = C extends Context<infer T> ? T : never;\n\nconst _createContext = <Value extends unknown>(defaultValue: Value) => {\n const _context: ComponentType<{\n value: Value;\n children?: ElementNode | ((value: Value) => ElementNode);\n }> = ({ value, children }) => {\n return _.isFunction(children) ? children(value) : children;\n };\n const Consumer: ComponentType<{\n children: (value: Value) => ElementNode;\n }> = ({ children }) => {\n const value = useContext(_context as Context<Value>);\n return children(value);\n };\n _contextDefaultValue.set(_context as Context<Value>, defaultValue);\n return _.assign(_context, { Consumer });\n};\n\n/**\n * Creates a new context object with an optional default value.\n *\n * A context object allows you to share a value across a component tree\n * without explicitly passing it as a prop to every level.\n *\n * @template Value - The type of the value to be stored in the context.\n * @param - The default value for the context.\n * @returns A context object that can be used to provide and consume the value.\n */\n\nexport function createContext<Value>(defaultValue: Value): Context<Value>;\nexport function createContext<Value = undefined>(): Context<Value | undefined>;\n\nexport function createContext(defaultValue?: any) {\n return _createContext(defaultValue);\n}\n\n/**\n * A hook that retrieves the current value of a context and optionally applies\n * a selector function to transform the context value. This hook ensures that the component\n * subscribes to the context and re-renders when the context value changes.\n *\n * @template T - The type of the context value.\n * @template R - The type of the transformed value returned by the selector.\n * @param context - The context object to retrieve the value from.\n * @param selector - An optional selector function to transform the context value.\n * Defaults to an identity function.\n * @returns - The current value of the context, optionally transformed by the selector.\n *\n * @throws - Throws an error if the provided context is invalid or if the hook\n * is used outside of a render function.\n *\n * @example\n * const MyContext = createContext({ user: null });\n * \n * function MyComponent() {\n * const user = useContext(MyContext, context => context.user);\n * return <div>{user ? `Hello, ${user.name}` : 'Hello, Guest'}</div>;\n * }\n */\nexport const useContext = <T, R = T>(\n context: Context<T>,\n selector: (state: T) => R = v => v as any\n) => {\n if (!isContext(context)) throw Error(`Invalid type of ${context}`);\n const state = reconciler.currentHookState;\n if (!state) throw Error('useContext must be used within a render function.');\n const node = state.resolveContextNode(context);\n if (node) {\n state.context.add(node);\n return selector(node.props.value);\n }\n return selector(_contextDefaultValue.get(context));\n};\n","//\n// props.ts\n//\n// The MIT License\n// Copyright (c) 2021 - 2025 O2ter Limited. All rights reserved.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n//\n\nimport { ComponentType, PropsWithChildren } from './common';\nimport { NativeElementType } from './component';\nimport { _ElementType, PropsType } from './runtime';\n\ntype PropsProviderProps = PropsWithChildren<{\n callback: (v: {\n type: _ElementType | typeof NativeElementType,\n props: PropsType\n }) => PropsType | undefined | null;\n}>;\n\nexport const PropsProvider: ComponentType<PropsProviderProps> = ({ children }) => {\n return children;\n}\n","//\n// error.ts\n//\n// The MIT License\n// Copyright (c) 2021 - 2025 O2ter Limited. All rights reserved.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n//\n\nimport { ComponentType, PropsWithChildren } from './common';\nimport { ComponentNode } from './component';\n\ntype ErrorBoundaryProps = PropsWithChildren<{\n silent?: boolean;\n onError?: (\n error: any,\n component: ComponentNode,\n stack: ComponentNode[],\n ) => void;\n}>;\n\nexport const ErrorBoundary: ComponentType<ErrorBoundaryProps> = ({ children }) => {\n return children;\n}\n","//\n// index.ts\n//\n// The MIT License\n// Copyright (c) 2021 - 2025 O2ter Limited. All rights reserved.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n//\n\nimport _ from 'lodash';\n\nconst _equalDeps = (lhs: any, rhs: any, stack: [any, any][]) => {\n if (lhs === rhs) return true;\n if (_.isFunction(lhs) || _.isFunction(rhs)) return false;\n\n // Check if we've already compared these objects (circular reference detection)\n const lhsIndex = _.findIndex(stack, s => s[0] === lhs);\n const rhsIndex = _.findIndex(stack, s => s[1] === rhs);\n\n // If both are in the stack at the same position, they're part of the same circular structure\n if (lhsIndex !== -1 && rhsIndex !== -1 && lhsIndex === rhsIndex) return true;\n\n // If only one is in the stack, they're not equal\n if (lhsIndex !== -1 || rhsIndex !== -1) return false;\n\n if (_.isArray(lhs) && _.isArray(rhs)) {\n if (lhs.length !== rhs.length) return false;\n const newStack: [any, any][] = [...stack, [lhs, rhs]];\n for (let i = 0; i < lhs.length; i++) {\n if (!_equalDeps(lhs[i], rhs[i], newStack)) return false;\n }\n return true;\n }\n if (_.isPlainObject(lhs) && _.isPlainObject(rhs)) {\n const lkeys = _.keys(lhs);\n const rkeys = _.keys(rhs);\n if (lkeys.length !== rkeys.length) return false;\n const newStack: [any, any][] = [...stack, [lhs, rhs]];\n for (const key of lkeys) {\n if (!_equalDeps(lhs[key], rhs[key], newStack)) return false;\n }\n return true;\n }\n return false;\n}\n\nexport const equalDeps = (lhs: any, rhs: any) => {\n return _equalDeps(lhs, rhs, []);\n}\n\nexport const equalProps = (lhs: Record<string, any>, rhs: Record<string, any>) => {\n if (lhs === rhs) return true;\n const lkeys = _.keys(lhs);\n const rkeys = _.keys(rhs);\n if (lkeys.length !== rkeys.length) return false;\n for (const key of lkeys) {\n if (_.isFunction(lhs[key]) && _.isFunction(rhs[key])) continue;\n if (!equalDeps(lhs[key], rhs[key])) return false;\n }\n return true;\n};\n","//\n// index.ts\n//\n// The MIT License\n// Copyright (c) 2021 - 2025 O2ter Limited. All rights reserved.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n//\n\nimport _ from 'lodash';\nimport { ComponentNode, NativeElementType } from '../types/component';\nimport { uniqueId } from '../utils';\nimport { Context, isContext } from '../hooks/context';\nimport { PropsProvider } from '../types/props';\nimport { ErrorBoundary } from '../types/error';\nimport { _Renderer } from '../renderer';\nimport { myersSync } from 'myers.js';\nimport { equalDeps, equalProps } from './utils';\nimport { PropsType } from '../types/runtime';\n\ntype VNodeState = {\n hook: string;\n deps: any;\n data?: any;\n mount?: () => () => void;\n};\n\nexport class UpdateManager {\n\n /** @internal */\n _dirty: Set<VNode>[] = [];\n\n /** @internal */\n private _refresh: (x: UpdateManager, force: boolean) => Promise<void>;\n\n constructor(refresh: (x: UpdateManager, force: boolean) => Promise<void>) {\n this._refresh = refresh;\n }\n\n async refresh(force: boolean = false) {\n await this._refresh(this, force);\n }\n\n _setDirty(node: VNode) {\n if (!this._dirty[node._level]) this._dirty[node._level] = new Set();\n this._dirty[node._level].add(node);\n }\n\n setDirty(node: VNode) {\n this._setDirty(node);\n this.refresh();\n }\n\n get isDirty() {\n return this._dirty.some(x => !!x.size);\n }\n}\n\nexport class VNode {\n\n /** @internal */\n _component: ComponentNode;\n\n private _id = uniqueId();\n\n private _props: PropsType = {};\n private _error?: any;\n private _children: (VNode | string)[] = [];\n\n /** @internal */\n _state?: VNodeState[];\n\n /** @internal */\n _content_listeners: Set<VNode> = new Set();\n private _content_value?: any;\n\n /** @internal */\n _context: Set<VNode> = new Set();\n\n /** @internal */\n _parent?: VNode;\n\n /** @internal */\n _nativeParent?: VNode;\n\n /** @internal */\n _level = 0;\n\n /** @internal */\n constructor(component: ComponentNode) {\n this._component = component;\n }\n\n get id() {\n return this._id;\n }\n\n get type() {\n return this._component.type;\n }\n\n get props() {\n return this._props;\n }\n\n get key() {\n return this._component.key;\n }\n\n get children() {\n return this._children;\n }\n\n get error() {\n return this._error;\n }\n\n get stack() {\n let node: VNode | undefined = this;\n return (function* () {\n while (node) {\n yield node;\n node = node._parent;\n }\n })();\n }\n\n /** @internal */\n async* _render(event: UpdateManager, renderer: _Renderer<any>) {\n try {\n const { type } = this._component;\n const props = this._resolve_props();\n let children: (VNode | string)[];\n let native = this._nativeParent;\n if (_.isString(type) || type?.prototype instanceof NativeElementType) {\n children = this._resolve_children(props.children, event);\n native = this;\n yield { mount: this };\n } else if (isContext(type)) {\n const { value } = props;\n if (!equalDeps(this._content_value, value)) {\n for (const node of this._content_listeners) {\n yield { dirty: node };\n }\n }\n this._content_value = value;\n children = this._resolve_children(type(props as any), event);\n } else if (_.isFunction(type)) {\n while (true) {\n const state = new HookState(this, event, renderer);\n reconciler._currentHookState = state;\n const rendered = type(props);\n for (const node of this._context.difference(state.context)) {\n node._content_listeners.delete(this);\n }\n for (const node of state.context.difference(this._context)) {\n node._content_listeners.add(this);\n }\n this._state = state.state;\n this._context = state.context;\n if (_.isEmpty(state.tasks)) {\n children = this._resolve_children(rendered, event);\n break;\n }\n await Promise.all(state.tasks);\n }\n yield { mount: this };\n } else {\n throw Error(`Invalid node type ${type}`);\n }\n const diff = myersSync(this._children, children, {\n compare: (lhs, rhs) => {\n if (_.isString(lhs) && _.isString(rhs)) return lhs === rhs;\n if (lhs instanceof VNode && rhs instanceof VNode) return lhs._component.equalType(rhs._component);\n return false;\n },\n });\n this._props = props;\n this._children = _.flatMap(diff, x => x.equivalent ?? x.insert ?? []);\n this._error = undefined;\n for (const [lhs, rhs] of _.zip(this._children, children)) {\n if (!(lhs instanceof VNode) || !(rhs instanceof VNode)) continue;\n if (lhs === rhs) {\n yield { dirty: lhs };\n } else {\n if (!equalProps(lhs._component.props, rhs._component.props)) yield { dirty: lhs };\n lhs._component = rhs._component;\n }\n lhs._parent = this;\n lhs._nativeParent = native;\n lhs._level = this._level + 1;\n }\n for (const item of _.flatMap(diff, x => x.remove ?? [])) {\n if (item instanceof VNode) {\n yield { removed: item };\n }\n }\n if (_.some(diff, x => !x.equivalent) && this._nativeParent && this._nativeParent !== this) {\n yield { mount: this._nativeParent };\n }\n } catch (error) {\n this._children = [];\n this._error = error;\n (async () => {\n try {\n const { onError, silent } = this._resolve_error_boundary() ?? {};\n if (!silent) console.error(error);\n if (_.isFunction(onError)) await onError(error, this._component, this.stack.map(x => x._component));\n } catch (e) {\n console.error(e);\n }\n })();\n yield { mount: this };\n if (this._nativeParent && this._nativeParent !== this) {\n yield { mount: this._nativeParent };\n }\n } finally {\n reconciler._currentHookState = undefined;\n }\n }\n\n private _resolve_props() {\n const self = this;\n const { type, props: _props } = this._component;\n if (type === PropsProvider) return _props;\n let props = { ..._props };\n for (const node of this.stack.drop(1)) {\n if (node.type === PropsProvider) {\n props = node.props.callback({ type, props });\n }\n }\n return _.mapValues(props, (v, k) => _.isFunction(v) ? function (this: any, ...args: any[]) {\n const current = self._component.props[k];\n return _.isFunction(current) ? current.call(this, ...args) : v.call(this, ...args);\n } : v);\n }\n\n private _resolve_children(child: any, event: UpdateManager): (VNode | string)[] {\n if (_.isBoolean(child) || _.isNil(child)) return [];\n if (_.isString(child)) return [child];\n if (_.isNumber(child)) return [`${child}`];\n if (child instanceof ComponentNode) return [new VNode(child)];\n if (_.isArrayLikeObject(child)) return _.flatMap(child, x => this._resolve_children(x, event));\n if (typeof child[Symbol.iterator] === 'function') return _.flatMap([...child], x => this._resolve_children(x, event));\n throw Error(`${child} are not valid as a child.`);\n }\n\n private _resolve_error_boundary() {\n return this.stack.drop(1).find(node => node.type === ErrorBoundary)?.props;\n }\n}\n\nclass HookState {\n\n node: VNode;\n event: UpdateManager;\n renderer: _Renderer<any>;\n\n state: VNodeState[] = [];\n tasks: PromiseLike<void>[] = [];\n context: Set<VNode> = new Set();\n\n constructor(\n node: VNode,\n event: UpdateManager,\n renderer: _Renderer<any>,\n ) {\n this.node = node;\n this.event = event;\n this.renderer = renderer;\n }\n\n get prevState() {\n return this.node._state;\n }\n\n get stack() {\n const [, ...stack] = this.node.stack;\n return stack;\n }\n\n setDirty() {\n this.event.setDirty(this.node);\n }\n\n resolveContextNode(context: Context<any>) {\n return this.stack.find(node => node.type === context);\n }\n}\n\nexport const reconciler = new class {\n\n /** @internal */\n _registry = new WeakMap<any, string>();\n\n /** @internal */\n _currentHookState?: HookState;\n\n get currentHookState() {\n return this._currentHookState;\n }\n};\n"],"names":[],"mappings":";;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AASM,MAAgB,gBAAiB,SAAQ,iBAAiB,CAAA;AAE/D;AAED;;;;;;AAMG;AACI,MAAM,WAAW,GAAG,CAAC,EAAE,iBAAiB,EAAE,iBAAiB,GAAG,EAAE,EAAA,GAGnE,EAAE,KAAI;AACR,IAAA,MAAM,cAAc,GAAG,CAAC,EAAE,QAAQ,EAAyB,KAAK,cAAc,CAAC,Q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C,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,IAAI,KAAK,aAAa,CAAC,EAAE,KAAK;IAC5E;AACD;AAED,MAAM,SAAS,CAAA;AAEb,IAAA,IAAI;AACJ,IAAA,KAAK;AACL,IAAA,QAAQ;IAER,KAAK,GAAiB,EAAE;IACxB,KAAK,GAAwB,EAAE;AAC/B,IAAA,OAAO,GAAe,IAAI,GAAG,EAAE;AAE/B,IAAA,WAAA,CACE,IAAW,EACX,KAAoB,EACpB,QAAwB,EAAA;AAExB,QAAA,IAAI,CAAC,IAAI,GAAG,IAAI;AAChB,QAAA,IAAI,CAAC,KAAK,GAAG,KAAK;AAClB,QAAA,IAAI,CAAC,QAAQ,GAAG,QAAQ;IAC1B;AAEA,IAAA,IAAI,SAAS,GAAA;AACX,QAAA,OAAO,IAAI,CAAC,IAAI,CAAC,MAAM;IACzB;AAEA,IAAA,IAAI,KAAK,GAAA;QACP,MAAM,GAAG,GAAG,KAAK,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK;AACpC,QAAA,OAAO,KAAK;IACd;IAEA,QAAQ,GAAA;QACN,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC;IAChC;AAEA,IAAA,kBAAkB,CAAC,OAAqB,EAAA;AACtC,QAAA,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,IAAI,KAAK,OAAO,CAAC;IACvD;AACD;AAEM,MAAM,UAAU,GAAG,IAAI,MAAA;;AAG5B,IAAA,SAAS,GAAG,IAAI,OAAO,EAAe;;AAGtC,IAAA,iBAAiB;AAEjB,IAAA,IAAI,gBAAgB,GAAA;QAClB,OAAO,IAAI,CAAC,iBAAiB;IAC/B;;;;;"}
@@ -32,11 +32,10 @@ declare class VNode {
32
32
  get children(): (string | VNode)[];
33
33
  get error(): any;
34
34
  get stack(): Generator<VNode, void, unknown>;
35
- private _children_updated;
36
35
  private _resolve_props;
37
36
  private _resolve_children;
38
37
  private _resolve_error_boundary;
39
38
  }
40
39
 
41
40
  export { VNode as V, _Renderer as _ };
42
- //# sourceMappingURL=index-Dxb4qbGJ.d.ts.map
41
+ //# sourceMappingURL=index-Dv977x8c.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-Dv977x8c.d.ts","sources":["../../src/core/renderer.ts","../../src/core/reconciler/index.ts"],"sourcesContent":["//\n// renderer.ts\n//\n// The MIT License\n// Copyright (c) 2021 - 2025 O2ter Limited. All rights reserved.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n//\n\nimport _ from 'lodash';\nimport { UpdateManager, VNode } from './reconciler';\nimport { ComponentNode, NativeElementType } from './types/component';\nimport { equalDeps } from './reconciler/utils';\nimport { _ParentComponent } from './components/pairs';\nimport nextick from 'nextick';\n\nexport abstract class _Renderer<T> {\n\n protected abstract _beforeUpdate(): void;\n\n protected abstract _afterUpdate(): void;\n\n protected abstract _createElement(node: VNode): T;\n\n protected abstract _updateElement(node: VNode, element: T, children: (T | string)[], force?: boolean): void;\n\n protected abstract _destroyElement(node: VNode, element: T): void;\n\n abstract get _server(): boolean;\n\n private _renderStorage = new Map<any, any>();\n\n get renderStorage() {\n return this._renderStorage;\n }\n\n private async _createRoot(\n root: T | null,\n component: ComponentNode,\n options?: {\n skipMount?: boolean;\n },\n ) {\n\n type MountState = {\n hook: string;\n deps: any;\n unmount?: () => void;\n };\n\n const elements = new Map<VNode, T>();\n const mountState = new Map<VNode, MountState[]>();\n\n const childrenDeep = function* (node: VNode): Generator<VNode> {\n for (const child of node.children) {\n if (child instanceof VNode) {\n yield child;\n yield* childrenDeep(child);\n }\n }\n };\n\n const nativeChildren = (node: VNode) => {\n const children = function* (\n node: VNode,\n filter?: (x: string | VNode) => boolean\n ): Generator<T | string> {\n for (const child of node.children) {\n if (_.isString(child)) {\n if (filter && !filter(child)) continue;\n yield child;\n } else {\n const element = elements.get(child);\n if (!filter || filter(child)) {\n if (element instanceof _ParentComponent) {\n yield* children(child, x => element.isChildNode(x));\n } else if (element) {\n yield element;\n } else {\n yield* children(child);\n }\n } else if (!element) {\n yield* children(child, filter);\n }\n }\n }\n }\n const element = elements.get(node);\n if (element instanceof _ParentComponent) {\n return children(node, x => element.isChildNode(x));\n } else {\n return children(node);\n }\n }\n\n const unmount = (nodes: Iterable<VNode>) => {\n for (const node of nodes) {\n for (const context of node._context) {\n context._content_listeners.delete(node);\n }\n const element = elements.get(node);\n if (element) {\n const state = mountState.get(node) ?? [];\n for (const { unmount } of state) {\n if (unmount) {\n try {\n unmount();\n } catch (e) {\n console.error(e);\n }\n }\n }\n try {\n this._destroyElement(node, element);\n } catch (e) {\n console.error(e);\n }\n elements.delete(node);\n }\n unmount(_.filter(node.children, x => x instanceof VNode));\n }\n };\n\n const refresh = async (event: UpdateManager, dirty: Set<VNode>[], force: boolean) => {\n\n try {\n this._beforeUpdate();\n } catch (e) {\n console.error(e);\n }\n\n const updated = new Set<VNode>();\n const mount: Set<VNode>[] = [];\n const removed = new Set<VNode>();\n\n for (const _nodes of dirty) {\n const nodes = [..._nodes || []];\n let node;\n while (node = nodes.shift()) {\n if (updated.has(node)) continue;\n for await (const {\n dirty,\n mount: _mount,\n removed: _removed,\n } of await node._render(event, this)) {\n if (dirty) nodes.push(dirty);\n else if (_mount) {\n if (!mount[_mount._level]) mount[_mount._level] = new Set();\n mount[_mount._level].add(_mount);\n } else if (_removed) removed.add(_removed);\n }\n updated.add(node);\n }\n }\n\n for (const nodes of mount.toReversed()) {\n for (const node of nodes || []) {\n if (_.isFunction(node.type) && node.type.prototype instanceof _ParentComponent) {\n let elem: any = elements?.get(node);\n if (!elem) {\n const Component = node.type as any;\n elem = new Component();\n }\n elements.set(node, elem);\n } else {\n if (_.isString(node.type) || node.type?.prototype instanceof NativeElementType) {\n const element = elements.get(node) ?? this._createElement(node);\n elements.set(node, element);\n try {\n this._updateElement(node, element, nativeChildren(node).toArray(), force);\n } catch (e) {\n console.error(e);\n }\n }\n const state: MountState[] = [];\n const prevState = mountState.get(node) ?? [];\n const curState = node._state ?? [];\n for (const i of _.range(Math.max(prevState.length, curState.length))) {\n const unmount = prevState[i]?.unmount;\n const changed = prevState[i]?.hook !== curState[i]?.hook || !equalDeps(prevState[i].deps, curState[i]?.deps);\n if (unmount && changed) {\n try {\n unmount();\n } catch (e) {\n console.error(e);\n }\n }\n state.push({\n hook: curState[i].hook,\n deps: curState[i].deps,\n unmount: options?.skipMount || !changed ? prevState[i]?.unmount : (() => {\n try {\n return curState[i].mount?.();\n } catch (e) {\n console.error(e);\n }\n })(),\n });\n }\n mountState.set(node, state);\n }\n }\n }\n\n unmount(removed);\n\n if (root) this._updateElement(\n rootNode, root,\n _.castArray(elements.get(rootNode) ?? nativeChildren(rootNode).toArray()),\n force,\n );\n\n try {\n this._afterUpdate();\n } catch (e) {\n console.error(e);\n }\n };\n\n let destroyed = false;\n let updating = false;\n const event = new UpdateManager(async (event, force) => {\n if (updating) return;\n updating = true;\n if (event.isDirty) {\n const dirty = event._dirty;\n event._dirty = [];\n await refresh(event, dirty, force);\n }\n while (event.isDirty) {\n if (destroyed) return;\n await new Promise<void>(resolve => nextick(resolve));\n const dirty = event._dirty;\n event._dirty = [];\n await refresh(event, dirty, force);\n }\n updating = false;\n });\n\n const rootNode = new VNode(component);\n event._setDirty(rootNode);\n await event.refresh(true);\n\n return {\n get root() {\n if (root) return root;\n const elems = _.castArray(elements.get(rootNode) ?? nativeChildren(rootNode).toArray());\n const nodes = _.filter(elems, x => !_.isString(x)) as T[];\n return nodes.length === 1 ? nodes[0] : nodes;\n },\n destroy: () => {\n destroyed = true;\n if (root) this._updateElement(rootNode, root, [], true);\n unmount(elements.keys());\n },\n };\n }\n\n createRoot(root?: T) {\n let state: Awaited<ReturnType<typeof this._createRoot>> | undefined;\n return {\n get root() {\n return state?.root;\n },\n mount: async (\n component: ComponentNode,\n options?: {\n skipMount?: boolean;\n },\n ) => {\n state = await this._createRoot(root ?? null, component, options);\n },\n unmount: () => {\n state?.destroy();\n state = undefined;\n },\n };\n }\n}","//\n// index.ts\n//\n// The MIT License\n// Copyright (c) 2021 - 2025 O2ter Limited. All rights reserved.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n//\n\nimport _ from 'lodash';\nimport { ComponentNode, NativeElementType } from '../types/component';\nimport { uniqueId } from '../utils';\nimport { Context, isContext } from '../hooks/context';\nimport { PropsProvider } from '../types/props';\nimport { ErrorBoundary } from '../types/error';\nimport { _Renderer } from '../renderer';\nimport { myersSync } from 'myers.js';\nimport { equalDeps, equalProps } from './utils';\nimport { PropsType } from '../types/runtime';\n\ntype VNodeState = {\n hook: string;\n deps: any;\n data?: any;\n mount?: () => () => void;\n};\n\nexport class UpdateManager {\n\n /** @internal */\n _dirty: Set<VNode>[] = [];\n\n /** @internal */\n private _refresh: (x: UpdateManager, force: boolean) => Promise<void>;\n\n constructor(refresh: (x: UpdateManager, force: boolean) => Promise<void>) {\n this._refresh = refresh;\n }\n\n async refresh(force: boolean = false) {\n await this._refresh(this, force);\n }\n\n _setDirty(node: VNode) {\n if (!this._dirty[node._level]) this._dirty[node._level] = new Set();\n this._dirty[node._level].add(node);\n }\n\n setDirty(node: VNode) {\n this._setDirty(node);\n this.refresh();\n }\n\n get isDirty() {\n return this._dirty.some(x => !!x.size);\n }\n}\n\nexport class VNode {\n\n /** @internal */\n _component: ComponentNode;\n\n private _id = uniqueId();\n\n private _props: PropsType = {};\n private _error?: any;\n private _children: (VNode | string)[] = [];\n\n /** @internal */\n _state?: VNodeState[];\n\n /** @internal */\n _content_listeners: Set<VNode> = new Set();\n private _content_value?: any;\n\n /** @internal */\n _context: Set<VNode> = new Set();\n\n /** @internal */\n _parent?: VNode;\n\n /** @internal */\n _nativeParent?: VNode;\n\n /** @internal */\n _level = 0;\n\n /** @internal */\n constructor(component: ComponentNode) {\n this._component = component;\n }\n\n get id() {\n return this._id;\n }\n\n get type() {\n return this._component.type;\n }\n\n get props() {\n return this._props;\n }\n\n get key() {\n return this._component.key;\n }\n\n get children() {\n return this._children;\n }\n\n get error() {\n return this._error;\n }\n\n get stack() {\n let node: VNode | undefined = this;\n return (function* () {\n while (node) {\n yield node;\n node = node._parent;\n }\n })();\n }\n\n /** @internal */\n async* _render(event: UpdateManager, renderer: _Renderer<any>) {\n try {\n const { type } = this._component;\n const props = this._resolve_props();\n let children: (VNode | string)[];\n let native = this._nativeParent;\n if (_.isString(type) || type?.prototype instanceof NativeElementType) {\n children = this._resolve_children(props.children, event);\n native = this;\n yield { mount: this };\n } else if (isContext(type)) {\n const { value } = props;\n if (!equalDeps(this._content_value, value)) {\n for (const node of this._content_listeners) {\n yield { dirty: node };\n }\n }\n this._content_value = value;\n children = this._resolve_children(type(props as any), event);\n } else if (_.isFunction(type)) {\n while (true) {\n const state = new HookState(this, event, renderer);\n reconciler._currentHookState = state;\n const rendered = type(props);\n for (const node of this._context.difference(state.context)) {\n node._content_listeners.delete(this);\n }\n for (const node of state.context.difference(this._context)) {\n node._content_listeners.add(this);\n }\n this._state = state.state;\n this._context = state.context;\n if (_.isEmpty(state.tasks)) {\n children = this._resolve_children(rendered, event);\n break;\n }\n await Promise.all(state.tasks);\n }\n yield { mount: this };\n } else {\n throw Error(`Invalid node type ${type}`);\n }\n const diff = myersSync(this._children, children, {\n compare: (lhs, rhs) => {\n if (_.isString(lhs) && _.isString(rhs)) return lhs === rhs;\n if (lhs instanceof VNode && rhs instanceof VNode) return lhs._component.equalType(rhs._component);\n return false;\n },\n });\n this._props = props;\n this._children = _.flatMap(diff, x => x.equivalent ?? x.insert ?? []);\n this._error = undefined;\n for (const [lhs, rhs] of _.zip(this._children, children)) {\n if (!(lhs instanceof VNode) || !(rhs instanceof VNode)) continue;\n if (lhs === rhs) {\n yield { dirty: lhs };\n } else {\n if (!equalProps(lhs._component.props, rhs._component.props)) yield { dirty: lhs };\n lhs._component = rhs._component;\n }\n lhs._parent = this;\n lhs._nativeParent = native;\n lhs._level = this._level + 1;\n }\n for (const item of _.flatMap(diff, x => x.remove ?? [])) {\n if (item instanceof VNode) {\n yield { removed: item };\n }\n }\n if (_.some(diff, x => !x.equivalent) && this._nativeParent && this._nativeParent !== this) {\n yield { mount: this._nativeParent };\n }\n } catch (error) {\n this._children = [];\n this._error = error;\n (async () => {\n try {\n const { onError, silent } = this._resolve_error_boundary() ?? {};\n if (!silent) console.error(error);\n if (_.isFunction(onError)) await onError(error, this._component, this.stack.map(x => x._component));\n } catch (e) {\n console.error(e);\n }\n })();\n yield { mount: this };\n if (this._nativeParent && this._nativeParent !== this) {\n yield { mount: this._nativeParent };\n }\n } finally {\n reconciler._currentHookState = undefined;\n }\n }\n\n private _resolve_props() {\n const self = this;\n const { type, props: _props } = this._component;\n if (type === PropsProvider) return _props;\n let props = { ..._props };\n for (const node of this.stack.drop(1)) {\n if (node.type === PropsProvider) {\n props = node.props.callback({ type, props });\n }\n }\n return _.mapValues(props, (v, k) => _.isFunction(v) ? function (this: any, ...args: any[]) {\n const current = self._component.props[k];\n return _.isFunction(current) ? current.call(this, ...args) : v.call(this, ...args);\n } : v);\n }\n\n private _resolve_children(child: any, event: UpdateManager): (VNode | string)[] {\n if (_.isBoolean(child) || _.isNil(child)) return [];\n if (_.isString(child)) return [child];\n if (_.isNumber(child)) return [`${child}`];\n if (child instanceof ComponentNode) return [new VNode(child)];\n if (_.isArrayLikeObject(child)) return _.flatMap(child, x => this._resolve_children(x, event));\n if (typeof child[Symbol.iterator] === 'function') return _.flatMap([...child], x => this._resolve_children(x, event));\n throw Error(`${child} are not valid as a child.`);\n }\n\n private _resolve_error_boundary() {\n return this.stack.drop(1).find(node => node.type === ErrorBoundary)?.props;\n }\n}\n\nclass HookState {\n\n node: VNode;\n event: UpdateManager;\n renderer: _Renderer<any>;\n\n state: VNodeState[] = [];\n tasks: PromiseLike<void>[] = [];\n context: Set<VNode> = new Set();\n\n constructor(\n node: VNode,\n event: UpdateManager,\n renderer: _Renderer<any>,\n ) {\n this.node = node;\n this.event = event;\n this.renderer = renderer;\n }\n\n get prevState() {\n return this.node._state;\n }\n\n get stack() {\n const [, ...stack] = this.node.stack;\n return stack;\n }\n\n setDirty() {\n this.event.setDirty(this.node);\n }\n\n resolveContextNode(context: Context<any>) {\n return this.stack.find(node => node.type === context);\n }\n}\n\nexport const reconciler = new class {\n\n /** @internal */\n _registry = new WeakMap<any, string>();\n\n /** @internal */\n _currentHookState?: HookState;\n\n get currentHookState() {\n return this._currentHookState;\n }\n};\n"],"names":["_____.ElementType"],"mappings":";;AAEO,uBAAA,SAAA;AACP;AACA;AACA,4CAAA,KAAA;AACA,4CAAA,KAAA;AACA,6CAAA,KAAA;AACA;AACA;AACA,yBAAA,GAAA;AACA;AACA;AACA;AACA,2BAAA,aAAA;AACA;AACA,cAAA,OAAA;AACA;AACA;AACA;;ACFO,cAAA,KAAA;AACP;AACA;AACA;AACA;AACA;AACA;AACA,uBAAA,iBAAA,GAA2CA,YAAe;AAC1D,iBAAA,SAAA;AACA;AACA,8BAAA,KAAA;AACA;AACA,iBAAA,SAAA,CAAA,KAAA;AACA;AACA;AACA;AACA;;;;"}