what-core 0.7.0 → 0.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "what-core",
3
- "version": "0.7.0",
3
+ "version": "0.8.1",
4
4
  "description": "What Framework - The closest framework to vanilla JS",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
package/src/dom.js CHANGED
@@ -5,7 +5,6 @@
5
5
  import { effect, batch, untrack, signal, __DEV__, __devtools } from './reactive.js';
6
6
  import { reportError, _injectGetCurrentComponent, shallowEqual } from './components.js';
7
7
  import { _setComponentRef } from './helpers.js';
8
-
9
8
  // SVG elements that need namespace
10
9
  const SVG_ELEMENTS = new Set([
11
10
  'svg', 'path', 'circle', 'rect', 'line', 'polyline', 'polygon', 'ellipse',
package/src/guardrails.js CHANGED
@@ -150,6 +150,8 @@ const VALID_EXPORTS = new Set([
150
150
  // Scheduler
151
151
  'scheduleRead', 'scheduleWrite', 'flushScheduler', 'measure', 'mutate',
152
152
  'useScheduledEffect', 'nextFrame', 'raf', 'onResize', 'onIntersect', 'smoothScrollTo',
153
+ // Text insertion hook (for external text engines)
154
+ '_setTextInsertHook',
153
155
  // Animation
154
156
  'spring', 'tween', 'easings', 'useTransition', 'useGesture', 'useAnimatedValue',
155
157
  'createTransitionClasses', 'cssTransition',
package/src/index.js CHANGED
@@ -173,6 +173,9 @@ export {
173
173
  validateImports,
174
174
  } from './guardrails.js';
175
175
 
176
+ // Generic text insertion hook (used by external text engines like what-text)
177
+ export { _setTextInsertHook } from './render.js';
178
+
176
179
  // Agent context (global inspection API)
177
180
  export {
178
181
  installAgentContext,
package/src/render.js CHANGED
@@ -4,9 +4,19 @@
4
4
 
5
5
  import { effect, untrack, createRoot, _createItemScope, signal, __DEV__ } from './reactive.js';
6
6
  import { createDOM, disposeTree, getCurrentComponent, getComponentStack } from './dom.js';
7
-
8
7
  export { effect, untrack };
9
8
 
9
+ // --- Generic text insertion hook ---
10
+ // External text engines (e.g., what-text) register a callback here via
11
+ // _setTextInsertHook(). When null (default), zero cost — no module loaded,
12
+ // no branch taken. The hook receives (parentElement, textString) on every
13
+ // dynamic text insertion and update.
14
+ let _onTextInsert = null;
15
+
16
+ export function _setTextInsertHook(fn) {
17
+ _onTextInsert = typeof fn === 'function' ? fn : null;
18
+ }
19
+
10
20
  // --- _$createComponent(Component, props, children) ---
11
21
  // Internal compiler target for component instantiation. The compiler emits calls
12
22
  // to this function instead of h() — keeping h() out of compiled output entirely.
@@ -168,6 +178,7 @@ export function insert(parent, child, marker) {
168
178
  const m = marker || null;
169
179
  if (m) parent.insertBefore(textNode, m);
170
180
  else parent.appendChild(textNode);
181
+ if (_onTextInsert) _onTextInsert(parent, String(first));
171
182
  let current = textNode;
172
183
  let isTextFastPath = true;
173
184
  effect(() => {
@@ -177,6 +188,7 @@ export function insert(parent, child, marker) {
177
188
  // Fast path: still text — update data directly (no allocations)
178
189
  const str = String(val);
179
190
  if (textNode.data !== str) textNode.data = str;
191
+ if (_onTextInsert) _onTextInsert(parent, str);
180
192
  } else {
181
193
  // Type changed — fall back to full reconcile
182
194
  isTextFastPath = false;