gyosjs 0.1.1 → 0.1.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.
package/README.md CHANGED
@@ -33,7 +33,7 @@ GyosJS is not trying to replace a full SPA framework. If your app is primarily c
33
33
  Use the browser auto-init build when you want HTML-first usage with minimal setup.
34
34
 
35
35
  ```html
36
- <script src="https://cdn.jsdelivr.net/npm/gyosjs@0.1.1/dist/gyos.auto.min.js"></script>
36
+ <script src="https://cdn.jsdelivr.net/npm/gyosjs@0.1.2/dist/gyos.auto.min.js"></script>
37
37
  ```
38
38
 
39
39
  That build attaches `window.Gyos`, starts the router when `g-boost` exists, injects transition styles, and mounts scopes when the page is ready.
@@ -1,8 +1,8 @@
1
- import type { Scope } from '../types';
1
+ import type { ScopeDefinition } from '../types';
2
2
  /**
3
3
  * Register a scope
4
4
  */
5
- export declare function scope(name: string | HTMLElement, definition: Scope): void;
5
+ export declare function scope(name: string | HTMLElement, definition: ScopeDefinition): void;
6
6
  /**
7
7
  * Mount all scopes in the document
8
8
  */
@@ -1 +1 @@
1
- {"version":3,"file":"component.d.ts","sourceRoot":"","sources":["../../src/core/component.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAkC,MAAM,UAAU,CAAC;AAoBtE;;GAEG;AACH,wBAAgB,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,WAAW,EAAE,UAAU,EAAE,KAAK,GAAG,IAAI,CAWzE;AAWD;;GAEG;AACH,wBAAgB,QAAQ,IAAI,IAAI,CAmB/B;AAED,wBAAgB,SAAS,CAAC,EAAE,EAAE,WAAW,GAAG,IAAI,CAe/C;AAED;;GAEG;AACH,wBAAgB,KAAK,CAAC,EAAE,EAAE,WAAW,GAAG,IAAI,CAe3C"}
1
+ {"version":3,"file":"component.d.ts","sourceRoot":"","sources":["../../src/core/component.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAS,eAAe,EAAkC,MAAM,UAAU,CA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,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IACvC,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,iBAAiB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,eAAe,CAAC,EAAE,WAAW,CAAC;IAC9B,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,mBAAmB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACpC;AAgBD,UAAU,QAAQ;IACjB,IAAI,EAAE,MAAM,CAAC;CACb;AAiCD,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,GAAG,IAAI,CAEtE;AAED,wBAAgB,eAAe,CAAC,QAAQ,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,GAAG,IAAI,CAErE;AAED,wBAAgB,WAAW,CAAC,OAAO,CAAC,EAAE,aAAa,GAAG,IAAI,CA2BzD;AA8CD,iBAAS,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAarD;AAoRD,iBAAe,QAAQ,CAAC,IAAI,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC,CA2T5D;AA8JD,iBAAS,gBAAgB,IAAI,IAAI,CAsBhC;AAGD,eAAO,MAAM,YAAY;;;;;;CAMxB,CAAC"}
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * GyosJS v0.1.1
2
+ * GyosJS v0.1.2
3
3
  * (c) 2026
4
4
  * @license MIT
5
5
  */
@@ -5444,6 +5444,19 @@ function handleDefinition(el, scopeAttr) {
5444
5444
  if (!definition)
5445
5445
  definition = scopeRegistry.get(scopeAttr) || {};
5446
5446
  const autoDef = parseAutoScope(el);
5447
+ if (typeof definition === 'function') {
5448
+ const factory = definition;
5449
+ return context => {
5450
+ const instance = factory(context);
5451
+ if (!instance || typeof instance !== 'object')
5452
+ return instance;
5453
+ Object.keys(autoDef).forEach(key => {
5454
+ instance[key] = autoDef[key];
5455
+ });
5456
+ autoBindModelProp(el, instance);
5457
+ return instance;
5458
+ };
5459
+ }
5447
5460
  Object.keys(autoDef).forEach(key => {
5448
5461
  definition[key] = autoDef[key];
5449
5462
  });
@@ -5490,7 +5503,10 @@ function mountScopeInternal(el, definition) {
5490
5503
  const context = createContext(el, instance);
5491
5504
  // If function component, call it now with context
5492
5505
  if (typeof definition === 'function' && !instance) {
5493
- instance = definition(context);
5506
+ const factoryResult = definition(context);
5507
+ instance = factoryResult && typeof factoryResult === 'object'
5508
+ ? makeReactive(factoryResult)
5509
+ : factoryResult;
5494
5510
  }
5495
5511
  if (!instance || typeof instance !== 'object') {
5496
5512
  DEBUG() && console.error('[GyosJS] Invalid scope definition for element:', el);
@@ -7395,6 +7411,8 @@ async function navigate(opts) {
7395
7411
  return;
7396
7412
  }
7397
7413
  const swapMode = (opts.swapMode || opts.trigger?.getAttribute('g-swap') || 'inner').toLowerCase();
7414
+ const removeTriggerAfterCommit = opts.trigger instanceof HTMLElement
7415
+ && opts.trigger.hasAttribute('g-router-remove');
7398
7416
  const destructiveSwap = !['append', 'prepend'].includes(swapMode);
7399
7417
  const isFullOutletNavigation = target === findGlobalOutlet();
7400
7418
  const targetOutletIndex = getOutletIndex(document, target);
@@ -7619,6 +7637,10 @@ async function navigate(opts) {
7619
7637
  await performUpdate();
7620
7638
  }
7621
7639
  assertActiveNavigation(transaction);
7640
+ if (removeTriggerAfterCommit && opts.trigger instanceof HTMLElement && opts.trigger.isConnected) {
7641
+ disposeEffects(opts.trigger);
7642
+ opts.trigger.remove();
7643
+ }
7622
7644
  if (hasTargetSpinner)
7623
7645
  hideTargetSpinner(transaction.spinner);
7624
7646
  transaction.spinner = null;
@@ -7872,7 +7894,7 @@ const Gyos = {
7872
7894
  onAfterNavigate,
7873
7895
  portalCreate,
7874
7896
  portalDestroy,
7875
- version: '0.1.1'
7897
+ version: '0.1.2'
7876
7898
  };
7877
7899
 
7878
7900
  var _a, _b, _c;