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/README.md CHANGED
@@ -34,7 +34,7 @@ GyosJS is not trying to replace a full SPA framework. If your app is primarily c
34
34
  Use the browser auto-init build when you want HTML-first usage with minimal setup.
35
35
 
36
36
  ```html
37
- <script src="https://cdn.jsdelivr.net/npm/gyosjs@0.5.2/dist/gyos.auto.min.js"></script>
37
+ <script src="https://cdn.jsdelivr.net/npm/gyosjs@0.5.3/dist/gyos.auto.min.js"></script>
38
38
  ```
39
39
 
40
40
  That build attaches `window.Gyos`, starts the router when `g-boost` exists, injects transition styles, and mounts scopes when the page is ready.
@@ -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
  */
@@ -6022,8 +6022,9 @@ function mountScopeInternal(el, definition) {
6022
6022
  if (typeof definition === 'object') {
6023
6023
  instance = makeReactive(definition);
6024
6024
  }
6025
- // Create component context (needs instance for $watch)
6026
- const context = createContext(el, instance);
6025
+ // Factories receive context before their reactive instance exists. Resolve it
6026
+ // when an observer is registered so captured context also works in onMount.
6027
+ const context = createContext(el, () => instance);
6027
6028
  // If function component, call it now with context
6028
6029
  if (typeof definition === 'function' && !instance) {
6029
6030
  const factoryResult = definition(context);
@@ -6080,7 +6081,7 @@ function mountScopeInternal(el, definition) {
6080
6081
  /**
6081
6082
  * Create component context
6082
6083
  */
6083
- function createContext(el, instance) {
6084
+ function createContext(el, getInstance) {
6084
6085
  const refs = {};
6085
6086
  const events = new Map();
6086
6087
  // Find all refs within this scope only
@@ -6128,6 +6129,7 @@ function createContext(el, instance) {
6128
6129
  },
6129
6130
  $watch: (key, handler, options = {}) => {
6130
6131
  // Watch a reactive property for changes (supports nested paths like 'xxx.count')
6132
+ const instance = getInstance();
6131
6133
  if (!instance) {
6132
6134
  DEBUG() && console.warn('[Component] $watch called before instance created');
6133
6135
  return () => { };
@@ -6194,6 +6196,7 @@ function createContext(el, instance) {
6194
6196
  },
6195
6197
  $effect: (fn) => {
6196
6198
  // Shorthand for effect with auto cleanup on unmount
6199
+ const instance = getInstance();
6197
6200
  if (!instance) {
6198
6201
  DEBUG() && console.warn('[Component] $effect called before instance created');
6199
6202
  return () => { };
@@ -8934,7 +8937,7 @@ const Gyos = {
8934
8937
  portalCreate,
8935
8938
  portalDestroy,
8936
8939
  setCspNonce,
8937
- version: '0.5.2'
8940
+ version: '0.5.3'
8938
8941
  };
8939
8942
 
8940
8943
  const standardExpressionRuntime = {