gyosjs 0.1.0 → 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.0/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.0
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);
@@ -7212,6 +7228,11 @@ function waitForNavigation(promise, signal) {
7212
7228
  });
7213
7229
  });
7214
7230
  }
7231
+ function consumeViewTransitionRejection(promise) {
7232
+ // Chrome rejects these when a newer transition skips the current one. The
7233
+ // update callback remains the navigation source of truth and is awaited below.
7234
+ void promise?.catch(() => undefined);
7235
+ }
7215
7236
  function runNavigationHooks(callbacks, url) {
7216
7237
  callbacks.forEach(callback => {
7217
7238
  try {
@@ -7390,6 +7411,8 @@ async function navigate(opts) {
7390
7411
  return;
7391
7412
  }
7392
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');
7393
7416
  const destructiveSwap = !['append', 'prepend'].includes(swapMode);
7394
7417
  const isFullOutletNavigation = target === findGlobalOutlet();
7395
7418
  const targetOutletIndex = getOutletIndex(document, target);
@@ -7604,6 +7627,8 @@ async function navigate(opts) {
7604
7627
  // Apply view transition if available
7605
7628
  if (document.startViewTransition) {
7606
7629
  const transition = document.startViewTransition(() => performUpdate());
7630
+ consumeViewTransitionRejection(transition?.ready);
7631
+ consumeViewTransitionRejection(transition?.finished);
7607
7632
  if (transition?.updateCallbackDone) {
7608
7633
  await transition.updateCallbackDone;
7609
7634
  }
@@ -7612,6 +7637,10 @@ async function navigate(opts) {
7612
7637
  await performUpdate();
7613
7638
  }
7614
7639
  assertActiveNavigation(transaction);
7640
+ if (removeTriggerAfterCommit && opts.trigger instanceof HTMLElement && opts.trigger.isConnected) {
7641
+ disposeEffects(opts.trigger);
7642
+ opts.trigger.remove();
7643
+ }
7615
7644
  if (hasTargetSpinner)
7616
7645
  hideTargetSpinner(transaction.spinner);
7617
7646
  transaction.spinner = null;
@@ -7865,7 +7894,7 @@ const Gyos = {
7865
7894
  onAfterNavigate,
7866
7895
  portalCreate,
7867
7896
  portalDestroy,
7868
- version: '0.1.0'
7897
+ version: '0.1.2'
7869
7898
  };
7870
7899
 
7871
7900
  var _a, _b, _c;