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.
package/dist/gyos.esm.js CHANGED
@@ -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
  */
@@ -6054,8 +6054,9 @@ function mountScopeInternal(el, definition) {
6054
6054
  if (typeof definition === 'object') {
6055
6055
  instance = makeReactive(definition);
6056
6056
  }
6057
- // Create component context (needs instance for $watch)
6058
- const context = createContext(el, instance);
6057
+ // Factories receive context before their reactive instance exists. Resolve it
6058
+ // when an observer is registered so captured context also works in onMount.
6059
+ const context = createContext(el, () => instance);
6059
6060
  // If function component, call it now with context
6060
6061
  if (typeof definition === 'function' && !instance) {
6061
6062
  const factoryResult = definition(context);
@@ -6112,7 +6113,7 @@ function mountScopeInternal(el, definition) {
6112
6113
  /**
6113
6114
  * Create component context
6114
6115
  */
6115
- function createContext(el, instance) {
6116
+ function createContext(el, getInstance) {
6116
6117
  const refs = {};
6117
6118
  const events = new Map();
6118
6119
  // Find all refs within this scope only
@@ -6160,6 +6161,7 @@ function createContext(el, instance) {
6160
6161
  },
6161
6162
  $watch: (key, handler, options = {}) => {
6162
6163
  // Watch a reactive property for changes (supports nested paths like 'xxx.count')
6164
+ const instance = getInstance();
6163
6165
  if (!instance) {
6164
6166
  DEBUG() && console.warn('[Component] $watch called before instance created');
6165
6167
  return () => { };
@@ -6226,6 +6228,7 @@ function createContext(el, instance) {
6226
6228
  },
6227
6229
  $effect: (fn) => {
6228
6230
  // Shorthand for effect with auto cleanup on unmount
6231
+ const instance = getInstance();
6229
6232
  if (!instance) {
6230
6233
  DEBUG() && console.warn('[Component] $effect called before instance created');
6231
6234
  return () => { };
@@ -8966,7 +8969,7 @@ const Gyos = {
8966
8969
  portalCreate,
8967
8970
  portalDestroy,
8968
8971
  setCspNonce,
8969
- version: '0.5.2'
8972
+ version: '0.5.3'
8970
8973
  };
8971
8974
 
8972
8975
  setExpressionRuntime(standardExpressionRuntime);