@coherent.js/core 1.0.0-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (116) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +130 -0
  3. package/dist/coherent.d.ts +472 -0
  4. package/dist/coherent.d.ts.map +1 -0
  5. package/dist/coherent.js +590 -0
  6. package/dist/coherent.js.map +1 -0
  7. package/dist/components/component-system.d.ts +1138 -0
  8. package/dist/components/component-system.d.ts.map +1 -0
  9. package/dist/components/component-system.js +2220 -0
  10. package/dist/components/component-system.js.map +1 -0
  11. package/dist/components/lifecycle.d.ts +212 -0
  12. package/dist/components/lifecycle.d.ts.map +1 -0
  13. package/dist/components/lifecycle.js +525 -0
  14. package/dist/components/lifecycle.js.map +1 -0
  15. package/dist/core/html-utils.d.ts +14 -0
  16. package/dist/core/html-utils.d.ts.map +1 -0
  17. package/dist/core/html-utils.js +166 -0
  18. package/dist/core/html-utils.js.map +1 -0
  19. package/dist/core/object-factory.d.ts +38 -0
  20. package/dist/core/object-factory.d.ts.map +1 -0
  21. package/dist/core/object-factory.js +63 -0
  22. package/dist/core/object-factory.js.map +1 -0
  23. package/dist/core/object-utils.d.ts +77 -0
  24. package/dist/core/object-utils.d.ts.map +1 -0
  25. package/dist/core/object-utils.js +502 -0
  26. package/dist/core/object-utils.js.map +1 -0
  27. package/dist/dev/dev-tools.d.ts +194 -0
  28. package/dist/dev/dev-tools.d.ts.map +1 -0
  29. package/dist/dev/dev-tools.js +846 -0
  30. package/dist/dev/dev-tools.js.map +1 -0
  31. package/dist/forms/validation.d.ts +271 -0
  32. package/dist/forms/validation.d.ts.map +1 -0
  33. package/dist/forms/validation.js +573 -0
  34. package/dist/forms/validation.js.map +1 -0
  35. package/dist/index.cjs +5281 -0
  36. package/dist/index.cjs.map +7 -0
  37. package/dist/index.js +5204 -0
  38. package/dist/index.js.map +7 -0
  39. package/dist/performance/bundle-optimizer.d.ts +95 -0
  40. package/dist/performance/bundle-optimizer.d.ts.map +1 -0
  41. package/dist/performance/bundle-optimizer.js +192 -0
  42. package/dist/performance/bundle-optimizer.js.map +1 -0
  43. package/dist/performance/cache-manager.d.ts +107 -0
  44. package/dist/performance/cache-manager.d.ts.map +1 -0
  45. package/dist/performance/cache-manager.js +314 -0
  46. package/dist/performance/cache-manager.js.map +1 -0
  47. package/dist/performance/component-cache.d.ts +120 -0
  48. package/dist/performance/component-cache.d.ts.map +1 -0
  49. package/dist/performance/component-cache.js +364 -0
  50. package/dist/performance/component-cache.js.map +1 -0
  51. package/dist/performance/monitor.d.ts +189 -0
  52. package/dist/performance/monitor.d.ts.map +1 -0
  53. package/dist/performance/monitor.js +347 -0
  54. package/dist/performance/monitor.js.map +1 -0
  55. package/dist/rendering/base-renderer.d.ts +140 -0
  56. package/dist/rendering/base-renderer.d.ts.map +1 -0
  57. package/dist/rendering/base-renderer.js +409 -0
  58. package/dist/rendering/base-renderer.js.map +1 -0
  59. package/dist/rendering/css-manager.d.ts +73 -0
  60. package/dist/rendering/css-manager.d.ts.map +1 -0
  61. package/dist/rendering/css-manager.js +176 -0
  62. package/dist/rendering/css-manager.js.map +1 -0
  63. package/dist/rendering/dom-renderer.d.ts +62 -0
  64. package/dist/rendering/dom-renderer.d.ts.map +1 -0
  65. package/dist/rendering/dom-renderer.js +252 -0
  66. package/dist/rendering/dom-renderer.js.map +1 -0
  67. package/dist/rendering/html-renderer.d.ts +67 -0
  68. package/dist/rendering/html-renderer.d.ts.map +1 -0
  69. package/dist/rendering/html-renderer.js +444 -0
  70. package/dist/rendering/html-renderer.js.map +1 -0
  71. package/dist/rendering/renderer-config.d.ts +282 -0
  72. package/dist/rendering/renderer-config.d.ts.map +1 -0
  73. package/dist/rendering/renderer-config.js +144 -0
  74. package/dist/rendering/renderer-config.js.map +1 -0
  75. package/dist/rendering/streaming-renderer.d.ts +117 -0
  76. package/dist/rendering/streaming-renderer.d.ts.map +1 -0
  77. package/dist/rendering/streaming-renderer.js +326 -0
  78. package/dist/rendering/streaming-renderer.js.map +1 -0
  79. package/dist/rendering/vdom-diff.d.ts +47 -0
  80. package/dist/rendering/vdom-diff.d.ts.map +1 -0
  81. package/dist/rendering/vdom-diff.js +416 -0
  82. package/dist/rendering/vdom-diff.js.map +1 -0
  83. package/dist/routing/router.d.ts +241 -0
  84. package/dist/routing/router.d.ts.map +1 -0
  85. package/dist/routing/router.js +648 -0
  86. package/dist/routing/router.js.map +1 -0
  87. package/dist/state/reactive-state.d.ts +166 -0
  88. package/dist/state/reactive-state.d.ts.map +1 -0
  89. package/dist/state/reactive-state.js +546 -0
  90. package/dist/state/reactive-state.js.map +1 -0
  91. package/dist/state/state-manager.d.ts +45 -0
  92. package/dist/state/state-manager.d.ts.map +1 -0
  93. package/dist/state/state-manager.js +151 -0
  94. package/dist/state/state-manager.js.map +1 -0
  95. package/dist/types/constants.d.ts +8 -0
  96. package/dist/types/constants.d.ts.map +1 -0
  97. package/dist/types/constants.js +36 -0
  98. package/dist/types/constants.js.map +1 -0
  99. package/dist/utils/dependency-utils.d.ts +43 -0
  100. package/dist/utils/dependency-utils.d.ts.map +1 -0
  101. package/dist/utils/dependency-utils.js +105 -0
  102. package/dist/utils/dependency-utils.js.map +1 -0
  103. package/dist/utils/error-handler.d.ts +148 -0
  104. package/dist/utils/error-handler.d.ts.map +1 -0
  105. package/dist/utils/error-handler.js +468 -0
  106. package/dist/utils/error-handler.js.map +1 -0
  107. package/dist/utils/normalization.d.ts +3 -0
  108. package/dist/utils/normalization.d.ts.map +1 -0
  109. package/dist/utils/normalization.js +24 -0
  110. package/dist/utils/normalization.js.map +1 -0
  111. package/dist/utils/validation.d.ts +10 -0
  112. package/dist/utils/validation.d.ts.map +1 -0
  113. package/dist/utils/validation.js +32 -0
  114. package/dist/utils/validation.js.map +1 -0
  115. package/package.json +44 -0
  116. package/types/index.d.ts +734 -0
@@ -0,0 +1,166 @@
1
+ /**
2
+ * HTML-specific utility functions
3
+ */
4
+ export function escapeHtml(text) {
5
+ if (typeof text !== 'string')
6
+ return text;
7
+ return text
8
+ .replace(/&/g, '&')
9
+ .replace(/</g, '&lt;')
10
+ .replace(/>/g, '&gt;')
11
+ .replace(/"/g, '&quot;')
12
+ .replace(/'/g, '&#39;');
13
+ }
14
+ export function unescapeHtml(text) {
15
+ if (typeof text !== 'string')
16
+ return text;
17
+ return text
18
+ .replace(/&quot;/g, '"')
19
+ .replace(/&#39;/g, "'")
20
+ .replace(/&gt;/g, '>')
21
+ .replace(/&lt;/g, '<')
22
+ .replace(/&amp;/g, '&');
23
+ }
24
+ export function isVoidElement(tagName) {
25
+ // Ensure tagName is a string before processing
26
+ if (typeof tagName !== 'string') {
27
+ return false;
28
+ }
29
+ const voidElements = new Set([
30
+ 'area',
31
+ 'base',
32
+ 'br',
33
+ 'col',
34
+ 'embed',
35
+ 'hr',
36
+ 'img',
37
+ 'input',
38
+ 'link',
39
+ 'meta',
40
+ 'param',
41
+ 'source',
42
+ 'track',
43
+ 'wbr',
44
+ ]);
45
+ return voidElements.has(tagName.toLowerCase());
46
+ }
47
+ export function formatAttributes(_props) {
48
+ let formatted = '';
49
+ for (const key in _props) {
50
+ if (props.hasOwnProperty(key)) {
51
+ let value = props[key];
52
+ // Convert className to class for HTML output
53
+ const attributeName = key === 'className' ? 'class' : key;
54
+ // Handle function values - for event handlers, use data-action attributes
55
+ if (typeof value === 'function') {
56
+ // Check if this is an event handler (starts with 'on')
57
+ if (attributeName.startsWith('on')) {
58
+ // For event handlers, create a unique action identifier
59
+ const actionId = `__coherent_action_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;
60
+ const DEBUG = (typeof process !== 'undefined' && process && process.env && (process.env.COHERENT_DEBUG === '1' || process.env.NODE_ENV === 'development'))
61
+ || (typeof window !== 'undefined' && window && window.COHERENT_DEBUG === true);
62
+ // Store the function in a global registry that will be available during hydration
63
+ // Check if we're in Node.js or browser environment
64
+ if (typeof global !== 'undefined') {
65
+ // Server-side, store in global for hydration
66
+ if (!global.__coherentActionRegistry) {
67
+ global.__coherentActionRegistry = {};
68
+ if (DEBUG)
69
+ console.log('Initialized global action registry');
70
+ }
71
+ global.__coherentActionRegistry[actionId] = value;
72
+ if (DEBUG)
73
+ console.log(`Added action ${actionId} to global registry, total: ${Object.keys(global.__coherentActionRegistry).length}`);
74
+ if (DEBUG)
75
+ console.log(`Global registry keys: ${Object.keys(global.__coherentActionRegistry).join(', ')}`);
76
+ // Log the global object to see if it's being reset
77
+ if (DEBUG) {
78
+ if (typeof global.__coherentActionRegistryLog === 'undefined') {
79
+ global.__coherentActionRegistryLog = [];
80
+ }
81
+ global.__coherentActionRegistryLog.push({
82
+ action: 'add',
83
+ actionId: actionId,
84
+ timestamp: Date.now(),
85
+ registrySize: Object.keys(global.__coherentActionRegistry).length
86
+ });
87
+ }
88
+ }
89
+ else if (typeof window !== 'undefined') {
90
+ // Browser-side, store in window
91
+ if (!window.__coherentActionRegistry) {
92
+ window.__coherentActionRegistry = {};
93
+ if (DEBUG)
94
+ console.log('Initialized window action registry');
95
+ }
96
+ window.__coherentActionRegistry[actionId] = value;
97
+ if (DEBUG)
98
+ console.log(`Added action ${actionId} to window registry, total: ${Object.keys(window.__coherentActionRegistry).length}`);
99
+ if (DEBUG)
100
+ console.log(`Window registry keys: ${Object.keys(window.__coherentActionRegistry).join(', ')}`);
101
+ }
102
+ // Use data-action and data-event attributes instead of inline JS
103
+ const eventType = attributeName.substring(2); // Remove 'on' prefix
104
+ formatted += ` data-action="${actionId}" data-event="${eventType}"`;
105
+ continue; // Skip normal processing
106
+ }
107
+ else {
108
+ // For other function attributes, call them to get the value
109
+ try {
110
+ value = value();
111
+ }
112
+ catch (error) {
113
+ console.warn(`Error executing function for attribute '${key}':`, {
114
+ error: error.message,
115
+ stack: error.stack,
116
+ attributeKey: key,
117
+ });
118
+ // Consider different fallback strategies based on attribute type
119
+ value = '';
120
+ }
121
+ }
122
+ }
123
+ if (value === true) {
124
+ formatted += ` ${attributeName}`;
125
+ }
126
+ else if (value !== false && value !== null && value !== undefined) {
127
+ formatted += ` ${attributeName}="${escapeHtml(String(value))}"`;
128
+ }
129
+ }
130
+ }
131
+ return formatted.trim();
132
+ }
133
+ export function minifyHtml(html, options = {}) {
134
+ if (!options.minify)
135
+ return html;
136
+ return (html
137
+ // Remove comments
138
+ .replace(/<!--[\s\S]*?-->/g, '')
139
+ // Remove extra whitespace
140
+ .replace(/\s+/g, ' ')
141
+ // Remove whitespace around tags
142
+ .replace(/>\s+</g, '><')
143
+ // Remove leading/trailing whitespace
144
+ .trim());
145
+ }
146
+ /**
147
+ * HTML Void Elements - elements that cannot have children
148
+ * These elements are self-closing and don't need closing tags
149
+ */
150
+ export const voidElements = new Set([
151
+ 'area',
152
+ 'base',
153
+ 'br',
154
+ 'col',
155
+ 'embed',
156
+ 'hr',
157
+ 'img',
158
+ 'input',
159
+ 'link',
160
+ 'meta',
161
+ 'param',
162
+ 'source',
163
+ 'track',
164
+ 'wbr',
165
+ ]);
166
+ //# sourceMappingURL=html-utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"html-utils.js","sourceRoot":"","sources":["../../../../src/core/html-utils.js"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,UAAU,UAAU,CAAC,IAAI;IAC7B,IAAI,OAAO,IAAI,KAAK,QAAQ;QAAE,OAAO,IAAI,CAAC;IAE1C,OAAO,IAAI;SACR,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC;SACtB,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC;SACrB,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC;SACrB,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC;SACvB,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;AAC5B,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,IAAI;IAC/B,IAAI,OAAO,IAAI,KAAK,QAAQ;QAAE,OAAO,IAAI,CAAC;IAE1C,OAAO,IAAI;SACR,OAAO,CAAC,SAAS,EAAE,GAAG,CAAC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 @@
1
+ /**
2
+ * Creates a Coherent object with the specified tag and properties
3
+ * @param {string} tag - HTML tag name
4
+ * @param {Object} [props={}] - Properties object
5
+ * @returns {Object} Coherent object with element structure
6
+ * @throws {Error} When invalid HTML element is provided
7
+ */
8
+ export function createElement(tag: string, props?: Object): Object;
9
+ /**
10
+ * Creates a text node
11
+ * @param {string} text - Text content
12
+ * @returns {Object} Coherent text object
13
+ */
14
+ export function createTextNode(text: string): Object;
15
+ export namespace h {
16
+ function div(props: any): Object;
17
+ function span(props: any): Object;
18
+ function p(props: any): Object;
19
+ function h1(props: any): Object;
20
+ function h2(props: any): Object;
21
+ function h3(props: any): Object;
22
+ function h4(props: any): Object;
23
+ function h5(props: any): Object;
24
+ function h6(props: any): Object;
25
+ function a(props: any): Object;
26
+ function img(props: any): Object;
27
+ function button(props: any): Object;
28
+ function input(props: any): Object;
29
+ function form(props: any): Object;
30
+ function ul(props: any): Object;
31
+ function ol(props: any): Object;
32
+ function li(props: any): Object;
33
+ function table(props: any): Object;
34
+ function tr(props: any): Object;
35
+ function td(props: any): Object;
36
+ function th(props: any): Object;
37
+ }
38
+ //# sourceMappingURL=object-factory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"object-factory.d.ts","sourceRoot":"","sources":["../../../../src/core/object-factory.js"],"names":[],"mappings":"AAOA;;;;;;GAMG;AACH,mCALW,MAAM,UACN,MAAM,GACJ,MAAM,CAiBlB;AAED;;;;GAIG;AACH,qCAHW,MAAM,GACJ,MAAM,CAOlB;;IAMQ,iCAAsC;IACrC,kCAAuC;IAC1C,+BAAoC;IACnC,gCAAqC;IACrC,gCAAqC;IACrC,gCAAqC;IACrC,gCAAqC;IACrC,gCAAqC;IACrC,gCAAqC;IACtC,+BAAoC;IAClC,iCAAsC;IACnC,oCAAyC;IAC1C,mCAAwC;IACzC,kCAAuC;IACzC,gCAAqC;IACrC,gCAAqC;IACrC,gCAAqC;IAClC,mCAAwC;IAC3C,gCAAqC;IACrC,gCAAqC;IACrC,gCAAqC"}
@@ -0,0 +1,63 @@
1
+ /**
2
+ * Object Factory for Coherent.js
3
+ * @fileoverview Creates Coherent objects with HTML elements and text nodes
4
+ */
5
+ import { HTML_ELEMENTS, CoherentTypes } from '../types/constants.js';
6
+ /**
7
+ * Creates a Coherent object with the specified tag and properties
8
+ * @param {string} tag - HTML tag name
9
+ * @param {Object} [props={}] - Properties object
10
+ * @returns {Object} Coherent object with element structure
11
+ * @throws {Error} When invalid HTML element is provided
12
+ */
13
+ export function createElement(tag, props = {}) {
14
+ if (!HTML_ELEMENTS.has(tag)) {
15
+ throw new Error(`Invalid HTML element: ${tag}`);
16
+ }
17
+ // Create the coherent object structure
18
+ const coherentObj = {
19
+ [tag]: {
20
+ ...props,
21
+ _type: CoherentTypes.ELEMENT
22
+ }
23
+ };
24
+ return coherentObj;
25
+ }
26
+ /**
27
+ * Creates a text node
28
+ * @param {string} text - Text content
29
+ * @returns {Object} Coherent text object
30
+ */
31
+ export function createTextNode(text) {
32
+ return {
33
+ text: String(text),
34
+ _type: CoherentTypes.OBJECT
35
+ };
36
+ }
37
+ /**
38
+ * Helper function to create common elements
39
+ */
40
+ export const h = {
41
+ div: (_props) => createElement('div', _props),
42
+ span: (_props) => createElement('span', _props),
43
+ p: (_props) => createElement('p', _props),
44
+ h1: (_props) => createElement('h1', _props),
45
+ h2: (_props) => createElement('h2', _props),
46
+ h3: (_props) => createElement('h3', _props),
47
+ h4: (_props) => createElement('h4', _props),
48
+ h5: (_props) => createElement('h5', _props),
49
+ h6: (_props) => createElement('h6', _props),
50
+ a: (_props) => createElement('a', _props),
51
+ img: (_props) => createElement('img', _props),
52
+ button: (_props) => createElement('button', _props),
53
+ input: (_props) => createElement('input', _props),
54
+ form: (_props) => createElement('form', _props),
55
+ ul: (_props) => createElement('ul', _props),
56
+ ol: (_props) => createElement('ol', _props),
57
+ li: (_props) => createElement('li', _props),
58
+ table: (_props) => createElement('table', _props),
59
+ tr: (_props) => createElement('tr', _props),
60
+ td: (_props) => createElement('td', _props),
61
+ th: (_props) => createElement('th', _props)
62
+ };
63
+ //# sourceMappingURL=object-factory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"object-factory.js","sourceRoot":"","sources":["../../../../src/core/object-factory.js"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAErE;;;;;;GAMG;AACH,MAAM,UAAU,aAAa,CAAC,GAAG,EAAE,KAAK,GAAG,EAAE;IACzC,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;QAC1B,MAAM,IAAI,KAAK,CAAC,yBAAyB,GAAG,EAAE,CAAC,CAAC;IACpD,CAAC;IAED,uCAAuC;IACvC,MAAM,WAAW,GAAG;QAChB,CAAC,GAAG,CAAC,EAAE;YACH,GAAG,KAAK;YACR,KAAK,EAAE,aAAa,CAAC,OAAO;SAC/B;KACJ,CAAC;IAEF,OAAO,WAAW,CAAC;AACvB,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,cAAc,CAAC,IAAI;IAC/B,OAAO;QACH,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC;QAClB,KAAK,EAAE,aAAa,CAAC,MAAM;KAC9B,CAAC;AACN,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,CAAC,GAAG;IACb,GAAG,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,aAAa,CAAC,KAAK,EAAE,KAAK,CAAC;IAC3C,IAAI,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,aAAa,CAAC,MAAM,EAAE,KAAK,CAAC;IAC7C,CAAC,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,aAAa,CAAC,GAAG,EAAE,KAAK,CAAC;IACvC,EAAE,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,aAAa,CAAC,IAAI,EAAE,KAAK,CAAC;IACzC,EAAE,EAAE,CAAC,KAAK,EAAE,EAAE,CA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AAE,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,aAAa,CAAC,IAAI,EAAE,KAAK,CAAC;IACzC,EAAE,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,aAAa,CAAC,IAAI,EAAE,KAAK,CAAC;CAC5C,CAAC"}
@@ -0,0 +1,77 @@
1
+ /**
2
+ * Core Object Utilities for Coherent.js
3
+ * Handles object validation, manipulation, and analysis
4
+ */
5
+ /**
6
+ * Deep clone an object with optimizations for common patterns
7
+ * Handles circular references, functions, dates, regex, and more
8
+ */
9
+ export function deepClone(obj: any, seen?: WeakMap<object, any>): any;
10
+ /**
11
+ * Shallow clone optimized for Coherent objects
12
+ * Much faster than deep clone when you only need one level
13
+ */
14
+ export function shallowClone(obj: any): any;
15
+ /**
16
+ * Smart clone that chooses between shallow and deep based on structure
17
+ * Optimized for Coherent component patterns
18
+ */
19
+ export function smartClone(obj: any, maxDepth?: number, currentDepth?: number): any;
20
+ /**
21
+ * Clone with performance monitoring
22
+ * Useful for debugging clone performance in development
23
+ */
24
+ export function monitoredClone(obj: any, options?: {}): any;
25
+ /**
26
+ * Validate that a component structure is valid for rendering
27
+ */
28
+ export function validateComponent(component: any, path?: string): boolean;
29
+ /**
30
+ * Check if an object follows Coherent.js object syntax
31
+ */
32
+ export function isCoherentObject(obj: any): boolean;
33
+ /**
34
+ * Extract props from a Coherent object
35
+ */
36
+ export function extractProps(coherentObj: any): {};
37
+ /**
38
+ * Check if a component has children
39
+ */
40
+ export function hasChildren(component: any): boolean;
41
+ /**
42
+ * Normalize children to a consistent array format
43
+ */
44
+ export function normalizeChildren(children: any): any[];
45
+ /**
46
+ * Get children from a component's props
47
+ */
48
+ export function getChildren(props: any): any[];
49
+ /**
50
+ * Merge props objects with conflict resolution
51
+ */
52
+ export function mergeProps(base?: {}, override?: {}): {};
53
+ /**
54
+ * Get nested value from object using dot notation
55
+ */
56
+ export function getNestedValue(obj: any, path: any): any;
57
+ /**
58
+ * Set nested value in object using dot notation
59
+ */
60
+ export function setNestedValue(obj: any, path: any, value: any): any;
61
+ /**
62
+ * Compare two components for equality (useful for optimization)
63
+ */
64
+ export function isEqual(a: any, b: any, maxDepth?: number, currentDepth?: number): any;
65
+ /**
66
+ * Create a frozen (immutable) version of a component
67
+ */
68
+ export function freeze(obj: any): any;
69
+ /**
70
+ * Check if component tree contains circular references
71
+ */
72
+ export function hasCircularReferences(obj: any, seen?: WeakSet<object>): boolean;
73
+ /**
74
+ * Get memory footprint estimate of a component tree
75
+ */
76
+ export function getMemoryFootprint(obj: any, visited?: WeakSet<object>): number;
77
+ //# sourceMappingURL=object-utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"object-utils.d.ts","sourceRoot":"","sources":["../../../../src/core/object-utils.js"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;GAGG;AACH,sEA+GC;AAED;;;GAGG;AACH,4CAmBC;AAED;;;GAGG;AACH,oFAiDC;AAmBD;;;GAGG;AACH,4DA8BC;AAID;;GAEG;AACH,0EAsDC;AAED;;GAEG;AACH,oDAoBC;AAED;;GAEG;AACH,mDAkBC;AAED;;GAEG;AACH,qDAoBC;AAED;;GAEG;AACH,wDAUC;AAED;;GAEG;AACH,+CAUC;AAED;;GAEG;AACH,yDAsBC;AAED;;GAEG;AACH,yDAQC;AAED;;GAEG;AACH,qEAiBC;AAED;;GAEG;AACH,uFAiCC;AAED;;GAEG;AACH,sCAaC;AAED;;GAEG;AACH,iFAgBC;AAED;;GAEG;AACH,gFA8BC"}