mnfst 0.5.291 → 0.5.292

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.
@@ -2,7 +2,7 @@
2
2
 
3
3
  (function () {
4
4
 
5
- const MANIFEST_BUILD_VERSION = '0.5.291';
5
+ const MANIFEST_BUILD_VERSION = '0.5.292';
6
6
 
7
7
  /* Manifest Data Sources - Appwrite Integration */
8
8
 
@@ -610,6 +610,102 @@ window.ManifestComponentsProcessor = {
610
610
  }
611
611
  };
612
612
 
613
+ // Components routing gate
614
+ // The router may load before or after this plugin; never capture it once.
615
+ window.ManifestComponentsRouting = (function () {
616
+ const ROUTER_SRC = /(^|\/)manifest\.router(\.min)?\.js(\?|#|$)/;
617
+ const LATE_MS = 10000;
618
+ let givenUp = false;
619
+ let settled = null;
620
+ let rerunQueued = false;
621
+
622
+ function routerScripts() {
623
+ return Array.from(document.querySelectorAll('script[src]')).filter(s => ROUTER_SRC.test(s.getAttribute('src') || ''));
624
+ }
625
+
626
+ // No router yet, but a router script is still to run
627
+ function pending() {
628
+ if (window.ManifestRouting || givenUp) return false;
629
+ return routerScripts().some(s => !s.hasAttribute('data-mnfst-loaded'));
630
+ }
631
+
632
+ // Resolves once the router has arrived or is known not to be coming
633
+ function whenSettled() {
634
+ if (!pending()) return Promise.resolve();
635
+ if (settled) return settled;
636
+ settled = new Promise(resolve => {
637
+ const watched = new WeakSet();
638
+ let done = false;
639
+ const finish = () => {
640
+ if (done) return;
641
+ done = true;
642
+ window.removeEventListener('manifest:routing-ready', check);
643
+ window.removeEventListener('load', onLoad);
644
+ settled = null;
645
+ resolve();
646
+ };
647
+ const watch = () => routerScripts().forEach(s => {
648
+ if (watched.has(s)) return;
649
+ watched.add(s);
650
+ s.addEventListener('load', check);
651
+ s.addEventListener('error', check);
652
+ });
653
+ // A failed CDN tag is swapped for the next one: re-scan a tick later
654
+ function check() { setTimeout(() => { if (pending()) watch(); else finish(); }, 0); }
655
+ // Window load waits for in-flight scripts: a router not here by then isn't coming
656
+ function onLoad() { setTimeout(() => { if (done) return; if (pending()) givenUp = true; finish(); }, 0); }
657
+ watch();
658
+ window.addEventListener('manifest:routing-ready', check);
659
+ // Inserted after load (Manifest.loadPlugin): its own load/error decides, bounded
660
+ if (document.readyState === 'complete') setTimeout(onLoad, LATE_MS);
661
+ else window.addEventListener('load', onLoad);
662
+ });
663
+ return settled;
664
+ }
665
+
666
+ // Same condition grammar as route visibility: comma list, ! negates
667
+ function matches(xRoute, path) {
668
+ const routing = window.ManifestRouting;
669
+ if (!xRoute || !routing) return true;
670
+ const conditions = xRoute.split(',').map(c => c.trim()).filter(Boolean);
671
+ const positive = conditions.filter(c => !c.startsWith('!'));
672
+ const negative = conditions.filter(c => c.startsWith('!')).map(c => c.slice(1));
673
+ if (negative.some(c => routing.matchesCondition(path, c))) return false;
674
+ return positive.length === 0 || positive.some(c => routing.matchesCondition(path, c));
675
+ }
676
+
677
+ // One swapping pass once the router settles, for every placeholder deferred meanwhile
678
+ function rerunWhenSettled() {
679
+ if (rerunQueued) return;
680
+ rerunQueued = true;
681
+ whenSettled().then(() => {
682
+ rerunQueued = false;
683
+ const swapping = window.ManifestComponentsSwapping;
684
+ return swapping && swapping.processAll().then(() => {
685
+ window.dispatchEvent(new CustomEvent('manifest:components-processed'));
686
+ });
687
+ });
688
+ }
689
+
690
+ function currentPath() {
691
+ const p = window.location.pathname;
692
+ return p === '/' ? '/' : p.replace(/^\/+|\/+$/g, '');
693
+ }
694
+
695
+ // 'swap' | 'skip' | 'defer' for a placeholder at a path
696
+ function decide(el, path) {
697
+ const xRoute = el.getAttribute('x-route');
698
+ if (!xRoute) return 'swap';
699
+ if (window.ManifestRouting) return matches(xRoute, path ?? currentPath()) ? 'swap' : 'skip';
700
+ if (!pending()) return 'swap';
701
+ rerunWhenSettled();
702
+ return 'defer';
703
+ }
704
+
705
+ return { pending, whenSettled, matches, decide };
706
+ })();
707
+
708
+
613
709
  // Components swapping
614
710
  (function () {
615
711
  // Never reset — ids must stay unique for the life of the page so overlapping
@@ -733,7 +829,7 @@ window.ManifestComponentsProcessor = {
733
829
  console.debug('[Manifest Components] skipped processAll: registry unavailable');
734
830
  return;
735
831
  }
736
- const routing = window.ManifestRouting;
832
+ const gate = window.ManifestComponentsRouting;
737
833
 
738
834
  // Use normalized path from event if provided, otherwise compute from window.location
739
835
  let normalizedPath;
@@ -750,34 +846,13 @@ window.ManifestComponentsProcessor = {
750
846
  !el.hasAttribute('data-processed')
751
847
  );
752
848
  // First pass: revert any swapped-in instances that no longer match
753
- if (routing) {
849
+ if (window.ManifestRouting) {
754
850
  for (const instanceId of Array.from(swappedInstances)) {
755
851
  const xRoute = instanceRouteMap.get(instanceId);
756
- if (!xRoute) {
757
- // No route condition means always visible, don't revert
758
- continue;
759
- }
760
- // Parse route conditions the same way as route visibility
761
- const conditions = xRoute.split(',').map(cond => cond.trim());
762
- const positiveConditions = conditions.filter(cond => !cond.startsWith('!'));
763
- const negativeConditions = conditions
764
- .filter(cond => cond.startsWith('!'))
765
- .map(cond => cond.slice(1));
766
-
767
- const hasNegativeMatch = negativeConditions.some(cond =>
768
- window.ManifestRouting.matchesCondition(normalizedPath, cond)
769
- );
770
- const hasPositiveMatch = positiveConditions.length === 0 || positiveConditions.some(cond =>
771
- window.ManifestRouting.matchesCondition(normalizedPath, cond)
772
- );
773
-
774
- const matches = hasPositiveMatch && !hasNegativeMatch;
775
- if (!matches) {
776
- this.revert(instanceId);
777
- }
852
+ if (xRoute && !gate.matches(xRoute, normalizedPath)) this.revert(instanceId);
778
853
  }
779
854
  }
780
- // Second pass: swap in any placeholders that match
855
+ // Second pass: swap in matches. Routing is read per placeholder: it may arrive mid-pass.
781
856
  for (const placeholder of placeholders) {
782
857
  const name = placeholder.tagName.toLowerCase().replace('x-', '');
783
858
  let instanceId = placeholder.getAttribute('data-component');
@@ -785,38 +860,8 @@ window.ManifestComponentsProcessor = {
785
860
  instanceId = getComponentInstanceId(name);
786
861
  placeholder.setAttribute('data-component', instanceId);
787
862
  }
788
- const xRoute = placeholder.getAttribute('x-route');
789
- if (!routing) {
790
- // No routing: always swap in
791
- await this.swapIn(placeholder);
792
- } else {
793
- // Routing present: check route using same logic as route visibility
794
- // Handle comma-separated route conditions (e.g., "/,page-1,page-2")
795
- let matches = !xRoute;
796
- if (xRoute) {
797
- const conditions = xRoute.split(',').map(cond => cond.trim());
798
- const positiveConditions = conditions.filter(cond => !cond.startsWith('!'));
799
- const negativeConditions = conditions
800
- .filter(cond => cond.startsWith('!'))
801
- .map(cond => cond.slice(1));
802
-
803
- // Check negative conditions first
804
- const hasNegativeMatch = negativeConditions.some(cond =>
805
- window.ManifestRouting.matchesCondition(normalizedPath, cond)
806
- );
807
-
808
- // Check positive conditions
809
- const hasPositiveMatch = positiveConditions.length === 0 || positiveConditions.some(cond =>
810
- window.ManifestRouting.matchesCondition(normalizedPath, cond)
811
- );
812
-
813
- matches = hasPositiveMatch && !hasNegativeMatch;
814
- }
815
-
816
- if (matches) {
817
- await this.swapIn(placeholder);
818
- }
819
- }
863
+ // 'defer' queues a re-run for when the router settles
864
+ if (gate.decide(placeholder, normalizedPath) === 'swap') await this.swapIn(placeholder);
820
865
  }
821
866
  },
822
867
  // Public entry point. Coalesces overlapping calls: while a run is active,
@@ -859,26 +904,23 @@ window.ManifestComponentsProcessor = {
859
904
  // Dispatch event when components are fully processed
860
905
  window.dispatchEvent(new CustomEvent('manifest:components-processed'));
861
906
  });
862
- // If routing is present, listen for route changes
863
- if (window.ManifestRouting) {
864
- window.addEventListener('manifest:route-change', (event) => {
865
- // Use normalized path from event detail if available
866
- const normalizedPath = event.detail?.normalizedPath || null;
867
- this.processAll(normalizedPath).then(() => {
868
- // Dispatch event when components are fully processed after route change
869
- window.dispatchEvent(new CustomEvent('manifest:components-processed'));
870
- });
907
+ // Only the router dispatches route changes, whenever it arrives
908
+ window.addEventListener('manifest:route-change', (event) => {
909
+ const normalizedPath = event.detail?.normalizedPath || null;
910
+ this.processAll(normalizedPath).then(() => {
911
+ window.dispatchEvent(new CustomEvent('manifest:components-processed'));
871
912
  });
872
- }
913
+ });
873
914
  }
874
915
  };
875
916
  })();
876
917
 
877
918
  // Components mutation observer
919
+ // Deferred placeholders are left for swapping's post-router pass.
878
920
  window.ManifestComponentsMutation = {
879
921
  async processAllPlaceholders() {
880
922
  const processor = window.ManifestComponentsProcessor;
881
- const routing = window.ManifestRouting;
923
+ const gate = window.ManifestComponentsRouting;
882
924
  if (!processor) return;
883
925
  const placeholders = Array.from(document.querySelectorAll('*')).filter(el =>
884
926
  el.tagName.toLowerCase().startsWith('x-') &&
@@ -886,56 +928,31 @@ window.ManifestComponentsMutation = {
886
928
  !el.hasAttribute('data-processed')
887
929
  );
888
930
  for (const el of placeholders) {
889
- if (routing) {
890
- // Only process if route matches
891
- const xRoute = el.getAttribute('x-route');
892
- const currentPath = window.location.pathname;
893
- const normalizedPath = currentPath === '/' ? '/' : currentPath.replace(/^\/+|\/+$/g, '');
894
- const matches = !xRoute || window.ManifestRouting.matchesCondition(normalizedPath, xRoute);
895
- if (!matches) continue;
896
- }
931
+ if (gate.decide(el) !== 'swap') continue;
897
932
  await processor.processComponent(el);
898
933
  }
899
934
  },
900
935
  initialize() {
901
936
  const processor = window.ManifestComponentsProcessor;
902
- const routing = window.ManifestRouting;
937
+ const gate = window.ManifestComponentsRouting;
903
938
  if (!processor) return;
904
939
  // Initial scan
905
940
  this.processAllPlaceholders();
941
+ const isPlaceholder = el => el.tagName.toLowerCase().startsWith('x-') &&
942
+ !el.hasAttribute('data-pre-rendered') && !el.hasAttribute('data-processed');
906
943
  // Mutation observer for new placeholders
907
944
  const observer = new MutationObserver(async mutations => {
908
945
  for (const mutation of mutations) {
909
946
  for (const node of mutation.addedNodes) {
910
- if (node.nodeType === 1 && node.tagName.toLowerCase().startsWith('x-')) {
911
- if (!node.hasAttribute('data-pre-rendered') && !node.hasAttribute('data-processed')) {
912
- if (routing) {
913
- const xRoute = node.getAttribute('x-route');
914
- const currentPath = window.location.pathname;
915
- const normalizedPath = currentPath === '/' ? '/' : currentPath.replace(/^\/+|\/+$/g, '');
916
- const matches = !xRoute || window.ManifestRouting.matchesCondition(normalizedPath, xRoute);
917
- if (!matches) continue;
918
- }
919
- await processor.processComponent(node);
920
- }
947
+ if (node.nodeType !== 1) continue;
948
+ if (isPlaceholder(node) && gate.decide(node) === 'swap') {
949
+ await processor.processComponent(node);
921
950
  }
922
951
  // Also check for any <x-*> descendants
923
- if (node.nodeType === 1) {
924
- const descendants = Array.from(node.querySelectorAll('*')).filter(el =>
925
- el.tagName.toLowerCase().startsWith('x-') &&
926
- !el.hasAttribute('data-pre-rendered') &&
927
- !el.hasAttribute('data-processed')
928
- );
929
- for (const el of descendants) {
930
- if (routing) {
931
- const xRoute = el.getAttribute('x-route');
932
- const currentPath = window.location.pathname;
933
- const normalizedPath = currentPath === '/' ? '/' : currentPath.replace(/^\/+|\/+$/g, '');
934
- const matches = !xRoute || window.ManifestRouting.matchesCondition(normalizedPath, xRoute);
935
- if (!matches) continue;
936
- }
937
- await processor.processComponent(el);
938
- }
952
+ const descendants = Array.from(node.querySelectorAll('*')).filter(isPlaceholder);
953
+ for (const el of descendants) {
954
+ if (gate.decide(el) !== 'swap') continue;
955
+ await processor.processComponent(el);
939
956
  }
940
957
  }
941
958
  }
@@ -951,7 +968,8 @@ window.ManifestComponentsMutation = {
951
968
  });
952
969
  }
953
970
  }
954
- };
971
+ };
972
+
955
973
 
956
974
  /* Manifest Components — route-level prefetch (batch on route change + on hover) */
957
975
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  (function () {
4
4
 
5
- const MANIFEST_BUILD_VERSION = '0.5.291';
5
+ const MANIFEST_BUILD_VERSION = '0.5.292';
6
6
 
7
7
  /* Manifest Data Sources - Configuration */
8
8
 
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "manifest.appwrite.auth.js": "sha384-gWLSeVPqCLMiUZB8MU7GqMg3x2yULFUsp8nTTZrPp/9Dlkix42rBn9yIimvwrHqZ",
3
- "manifest.appwrite.data.js": "sha384-Opp1tNpEDbOj0WtdFQlogBJzc2tGiwLyj7AEWJkHxcjt06VrNYWn6DCvdDbwSPt5",
3
+ "manifest.appwrite.data.js": "sha384-oNZ+lin9wI5/jzB3v244kwSp6w6xGEo0NgGe8MTzc5PjWkwNESr3nlF3HTl2doWd",
4
4
  "manifest.appwrite.presences.js": "sha384-LINPhIPTCK+rA8zd+HPUzMSEgH6Sl2vQMEyItT97bnEE2FYGYKqjXX+CWdt6nl9z",
5
5
  "manifest.bindings.js": "sha384-lPtMf8Ykaic9gNVZKq8Scia1881ZeMAyxer3WCIkUNwwrgzGBWto1OXADUwjvORF",
6
6
  "manifest.charts.js": "sha384-AFbP7mQnigy7DU1s+YE30yKTeQAKfgNazhbfSNbfd9ZpLgeulZKaPi/fAq3gJHDO",
@@ -9,9 +9,9 @@
9
9
  "manifest.color.js": "sha384-tLmmr7KwPIjznXr2tJfJtuAOV9pohdr+Ojj4L4BaOZ8WngCNOPUp27Dfz47YqU2R",
10
10
  "manifest.colorpicker.js": "sha384-P+Zx0QzhMGfku8s3yEskTte4/iXCGVX3zdhu42IGNfFcSmhOW+nqVK7w+uczWRGY",
11
11
  "manifest.combobox.js": "sha384-/lJo6vaxKjgnBSRs/dzkhK1dzGk3GBw8FISoNJZB70mwAVwu1k5veZyBXjOb4keS",
12
- "manifest.components.js": "sha384-1el5WMdgmzu/2ocaYN21OjLi/lfjllvA8aju1J3knYuOizw+XFfJU1+rvGqYW7qk",
12
+ "manifest.components.js": "sha384-3kjiDSDrxJtdtqMpWKj7pl9RYKlY/S/yn9NHtrdP8NUDZdP2kvyeaHWdZ0kP/dzB",
13
13
  "manifest.computed.js": "sha384-GYML/e81gQfN+iDbqhPUgny8bINCyL+SrbTofoGk4hlCnLLjv51mCv42JMqq+ku5",
14
- "manifest.data.js": "sha384-JvYICvCyjx/unD43o1DtkJ3nYwfgfgHHMHws4HmzZ9L90OnDGP6oNVTCQYlJ7pqC",
14
+ "manifest.data.js": "sha384-j/CI2i6V4EnD28/TKyq1fPB0E/pBpHO/emT9/0RHjiOxttaON7yc57oCclMZFxmb",
15
15
  "manifest.datepicker.js": "sha384-EzlMwvIxlla/0BuyhAEqxN0M8TGcWIWgEIg840V0akKQQK1uY648wPWMkobvtq/o",
16
16
  "manifest.defer.js": "sha384-PRp7+dCZHnnl55rX2xrHutLrQnszHo7o5o9Tq28M/yjLZPuXDzcwQNxCdvbtCYSz",
17
17
  "manifest.device.js": "sha384-YeQaS56L8IILqrQNBSeAOLwIh5DuAOrE60cYLK1+46qJtUrXlAvqGe2j5mbV4Vq7",
@@ -24,12 +24,12 @@
24
24
  "manifest.native.js": "sha384-YeQaS56L8IILqrQNBSeAOLwIh5DuAOrE60cYLK1+46qJtUrXlAvqGe2j5mbV4Vq7",
25
25
  "manifest.payments.js": "sha384-p10n6EHBWFKVW9KhI2A+RpkwqrwD068D+wvOJ7D3Gklz1MvmIlqv1lLG1R0cUqbw",
26
26
  "manifest.rich.text.js": "sha384-ZBV9jXmu2nmprEHicddRE/m7nR4RPZtVc969Jte0+EJYBcVph7itkjcgN/61PyeC",
27
- "manifest.router.js": "sha384-FgcHtfJ9OTwpo7ghsXL2ElurfVT0Q6541puTfeEIj17bGHBxlSAYtKPqk35gkkO2",
27
+ "manifest.router.js": "sha384-C+3jwRS+kxSZ0wQDtZ5NvOqcFaXrC4uevIzamHUuxgGcmtDcCRCZnMK53lFkClM9",
28
28
  "manifest.slides.js": "sha384-3uRTkyK9XPLmnxI2+igZlpi4EyPlU/7IHj5j3BZJJ2KN455vXyk99fiXV3feO/XY",
29
29
  "manifest.status.js": "sha384-ofu7nBnVIGZ1U1o2R9d2H3V8aEMPUCVbl5FO3gIToXqi0oa36fTviEdh5UU7Kitw",
30
30
  "manifest.submissions.js": "sha384-v9eS47ytAfTGIKAyVnbd0QWegucVS7yduvigqfsxxoqXmbaEoy0M2y+BiI4xeZBd",
31
31
  "manifest.svg.js": "sha384-qr/8H9+2cIhSXNbRWRtIdrDlTOxKlNJqwEefHvCYoiBNW/kKhPTFa109Orv/EBnb",
32
- "manifest.sw.js": "sha384-UUA5X6zDnljujAlIeHpFD4PEWSjaTi48STBZDS24jmrS1UvXPVuM54h0HgbHDCBl",
32
+ "manifest.sw.js": "sha384-vZlT026s96VLf4+v38pNX9fnfuANMQbGlgSYnMKWNdzRCXNwaKBgDxbrivu3SVdE",
33
33
  "manifest.tabs.js": "sha384-otU09H7jnawVKQdLAYpMCd3jx00tgyPVr42D2hLIBzN5dG4se505YesavdnMqEi1",
34
34
  "manifest.tailwind.js": "sha384-yuP3LEvWU+QVjxjkZ0YhErtC9RrGmhOmHjjFjhS9obqZbp5/KTIEnSR0CXDvHE0B",
35
35
  "manifest.toasts.js": "sha384-UpOz9fAdGeGUhL0NamBg5iPepEfIy73p9HYdcxfOQC5b7CVsl7Our0skdZzaLNcC",
@@ -13,13 +13,6 @@ function initializeRouting() {
13
13
 
14
14
  }
15
15
 
16
- // Start initialization when DOM is ready
17
- if (document.readyState === 'loading') {
18
- document.addEventListener('DOMContentLoaded', initializeRouting);
19
- } else {
20
- initializeRouting();
21
- }
22
-
23
16
  // Export main routing interface
24
17
  window.ManifestRouting = {
25
18
  initialize: initializeRouting,
@@ -89,6 +82,13 @@ window.ManifestRouting = {
89
82
  }
90
83
  };
91
84
 
85
+ // Start when DOM is ready; after the export so routing-ready listeners can read ManifestRouting
86
+ if (document.readyState === 'loading') {
87
+ document.addEventListener('DOMContentLoaded', initializeRouting);
88
+ } else {
89
+ initializeRouting();
90
+ }
91
+
92
92
 
93
93
  // Router position
94
94
 
@@ -16,7 +16,7 @@
16
16
 
17
17
  // Build stamps the published version here; unstamped (dev) falls back to the
18
18
  // registration URL's `v`, then 'dev'.
19
- const BUILD_VERSION = '0.5.291';
19
+ const BUILD_VERSION = '0.5.292';
20
20
  const CACHE_PREFIX = 'mnfst-sw:';
21
21
  const META_CACHE = CACHE_PREFIX + 'meta';
22
22
  // Sized to hold a full precache.json warm-up (PRECACHE_MAX_ENTRIES server-side)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mnfst",
3
- "version": "0.5.291",
3
+ "version": "0.5.292",
4
4
  "private": false,
5
5
  "workspaces": [
6
6
  "templates/starter",
@@ -55,6 +55,7 @@
55
55
  "test:e2e:data-paging": "node tests/e2e/data-paging.e2e.mjs",
56
56
  "test:e2e:modules": "node tests/e2e/modules.e2e.mjs",
57
57
  "test:e2e:router-xshow": "node tests/e2e/router-xshow.e2e.mjs",
58
+ "test:e2e:components-router-race": "node tests/e2e/components-router-race.e2e.mjs",
58
59
  "test:e2e:route-head": "node tests/e2e/route-head.e2e.mjs",
59
60
  "test:e2e:prerender-patch": "node tests/e2e/utilities-prerender-patch.e2e.mjs",
60
61
  "test:e2e:hidden-responsive": "node tests/e2e/utilities-hidden-responsive.e2e.mjs",