gyosjs 0.5.2 → 0.5.3

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.
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * GyosJS v0.5.2
2
+ * GyosJS v0.5.3
3
3
  * (c) 2026
4
4
  * @license MIT
5
5
  */
@@ -12671,8 +12671,9 @@ function mountScopeInternal(el, definition) {
12671
12671
  if (typeof definition === 'object') {
12672
12672
  instance = makeReactive(definition);
12673
12673
  }
12674
- // Create component context (needs instance for $watch)
12675
- const context = createContext(el, instance);
12674
+ // Factories receive context before their reactive instance exists. Resolve it
12675
+ // when an observer is registered so captured context also works in onMount.
12676
+ const context = createContext(el, () => instance);
12676
12677
  // If function component, call it now with context
12677
12678
  if (typeof definition === 'function' && !instance) {
12678
12679
  const factoryResult = definition(context);
@@ -12729,7 +12730,7 @@ function mountScopeInternal(el, definition) {
12729
12730
  /**
12730
12731
  * Create component context
12731
12732
  */
12732
- function createContext(el, instance) {
12733
+ function createContext(el, getInstance) {
12733
12734
  const refs = {};
12734
12735
  const events = new Map();
12735
12736
  // Find all refs within this scope only
@@ -12777,6 +12778,7 @@ function createContext(el, instance) {
12777
12778
  },
12778
12779
  $watch: (key, handler, options = {}) => {
12779
12780
  // Watch a reactive property for changes (supports nested paths like 'xxx.count')
12781
+ const instance = getInstance();
12780
12782
  if (!instance) {
12781
12783
  DEBUG() && console.warn('[Component] $watch called before instance created');
12782
12784
  return () => { };
@@ -12843,6 +12845,7 @@ function createContext(el, instance) {
12843
12845
  },
12844
12846
  $effect: (fn) => {
12845
12847
  // Shorthand for effect with auto cleanup on unmount
12848
+ const instance = getInstance();
12846
12849
  if (!instance) {
12847
12850
  DEBUG() && console.warn('[Component] $effect called before instance created');
12848
12851
  return () => { };
@@ -15583,7 +15586,7 @@ const Gyos = {
15583
15586
  portalCreate,
15584
15587
  portalDestroy,
15585
15588
  setCspNonce,
15586
- version: '0.5.2'
15589
+ version: '0.5.3'
15587
15590
  };
15588
15591
 
15589
15592
  setExpressionRuntime(cspExpressionRuntime);