mnfst 0.5.199-next.2 → 0.5.199-next.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.
@@ -26,13 +26,14 @@ async function ensureManifest() {
26
26
  return window.__manifestLoaded;
27
27
  }
28
28
 
29
+ if (window.__manifestPromise) {
30
+ const shared = await window.__manifestPromise.catch(() => null);
31
+ if (shared) return shared;
32
+ }
29
33
  try {
30
34
  const manifestUrl = (document.querySelector('link[rel="manifest"]')?.getAttribute('href')) || '/manifest.json';
31
- const response = await fetch(manifestUrl);
32
- const manifest = await response.json();
33
- // No-loader path: resolve ${VAR} placeholders the dynamic loader would have.
34
- window.ManifestDataConfig?.interpolateManifest?.(manifest);
35
- return manifest;
35
+ window.__manifestPromise = fetch(manifestUrl).then(r => r.json()).then(m => { window.ManifestDataConfig?.interpolateManifest?.(m); return m; });
36
+ return await window.__manifestPromise;
36
37
  } catch (error) {
37
38
  return null;
38
39
  }
@@ -2,7 +2,7 @@
2
2
 
3
3
  (function () {
4
4
 
5
- const MANIFEST_BUILD_VERSION = '0.5.199-next.2';
5
+ const MANIFEST_BUILD_VERSION = '0.5.199-next.3';
6
6
 
7
7
  /* Manifest Data Sources - Appwrite Integration */
8
8
 
@@ -451,10 +451,15 @@
451
451
  function commitParticipants() { state.participants = [..._participants.values()]; rev().n++; }
452
452
  function commitTyping() { state.typing = [..._typing.values()]; rev().n++; }
453
453
 
454
- // server echo reconciles body/media/status onto the local copy
454
+ // server echo reconciles body/media/status onto the local copy; meta merges so a
455
+ // re-delivery from another source (no translation, no channel) never drops fields
455
456
  function merge(target, incoming) {
456
457
  Object.assign(target.body, incoming.body);
457
- for (const k of Object.keys(incoming)) if (k !== 'body' && k !== '_seq') target[k] = incoming[k];
458
+ for (const k of Object.keys(incoming)) {
459
+ if (k === 'body' || k === '_seq') continue;
460
+ if (k === 'meta' && target.meta && incoming.meta && typeof incoming.meta === 'object') { Object.assign(target.meta, incoming.meta); continue; }
461
+ target[k] = incoming[k];
462
+ }
458
463
  }
459
464
 
460
465
  // own echo beating the ack: claim the pending row by meta.clientId
@@ -584,7 +589,7 @@
584
589
  commit(); commitParticipants(); commitTyping();
585
590
  }
586
591
 
587
- if (P() && !isAggregate && opts.persist !== false) detach = P().attach(conversationId, { snapshot, reset, stale: () => state.stale, count: () => _msgs.length });
592
+ if (P() && !isAggregate && opts.persistWindow !== false) detach = P().attach(conversationId, { snapshot, reset, stale: () => state.stale, count: () => _msgs.length });
588
593
 
589
594
  async function open() {
590
595
  state.status = 'loading';
@@ -61,6 +61,7 @@ window.ManifestComponentsRegistry = {
61
61
  // manifest on window yet). This must be async — a synchronous XHR on
62
62
  // the main thread is deprecated and was flagged by PageSpeed.
63
63
  let manifest = window.__manifestLoaded || this.manifest;
64
+ if (!manifest && window.__manifestPromise) manifest = await window.__manifestPromise.catch(() => null);
64
65
  if (!manifest) {
65
66
  try {
66
67
  const manifestUrl = (document.querySelector('link[rel="manifest"]')?.getAttribute('href')) || '/manifest.json';
@@ -72,6 +73,7 @@ window.ManifestComponentsRegistry = {
72
73
  manifest = await res.json();
73
74
  // No-loader path: resolve ${VAR} placeholders the dynamic loader would have.
74
75
  window.ManifestDataConfig?.interpolateManifest?.(manifest);
76
+ window.__manifestPromise = Promise.resolve(manifest); // share with plugins that init after us
75
77
  } else {
76
78
  console.warn('[Manifest] Failed to load manifest.json (HTTP', res.status + ')');
77
79
  }
@@ -2,7 +2,7 @@
2
2
 
3
3
  (function () {
4
4
 
5
- const MANIFEST_BUILD_VERSION = '0.5.199-next.2';
5
+ const MANIFEST_BUILD_VERSION = '0.5.199-next.3';
6
6
 
7
7
  /* Manifest Data Sources - Configuration */
8
8
 
@@ -21,12 +21,15 @@ async function ensureManifest() {
21
21
  return window.__manifestLoaded;
22
22
  }
23
23
 
24
+ // One request per boot, shared with the loader and the other plugins (window.__manifestPromise)
25
+ if (window.__manifestPromise) {
26
+ const shared = await window.__manifestPromise.catch(() => null);
27
+ if (looksComplete(shared)) return shared;
28
+ }
24
29
  try {
25
30
  const manifestUrl = (document.querySelector('link[rel="manifest"]')?.getAttribute('href')) || '/manifest.json';
26
- const response = await fetch(manifestUrl);
27
- const manifest = await response.json();
28
- interpolateManifest(manifest);
29
- return manifest;
31
+ window.__manifestPromise = fetch(manifestUrl).then(r => r.json()).then(m => { interpolateManifest(m); return m; });
32
+ return await window.__manifestPromise;
30
33
  } catch (error) {
31
34
  console.error('[Manifest Data] Failed to load manifest:', error);
32
35
  return null;
@@ -1,17 +1,17 @@
1
1
  {
2
- "manifest.appwrite.auth.js": "sha384-Dy5NIqlV3TdKC87VYMqikQ2kZAPGdGy7wVIqcR92XYb47v+0Dn/YTPZsJdg6YhMT",
3
- "manifest.appwrite.data.js": "sha384-rBxJHvm65pKByB3p5uNmCPvm56LXOJ5BFprVuZPcEFjSbi17WBQL0q49hAXl5gxW",
2
+ "manifest.appwrite.auth.js": "sha384-HMJmRXnvdDBWyuteXL+DTxWM2llSCdjl4EDamEI7iHNAVlqeOCE4GDTm8ZHipPRj",
3
+ "manifest.appwrite.data.js": "sha384-dLQJibkJHbQh7N2j73pCWHSUl2j/O3M0W/Zuge0d7VYjUBXv0PlW55Wylhk6YEsp",
4
4
  "manifest.appwrite.presences.js": "sha384-JyVDWFT69b7Svq8J8p9tNWe2v9PZNQBY5UyhtOl1vnuHFAX0CRQ3MA9SiKq5wzNh",
5
5
  "manifest.bindings.js": "sha384-lPtMf8Ykaic9gNVZKq8Scia1881ZeMAyxer3WCIkUNwwrgzGBWto1OXADUwjvORF",
6
6
  "manifest.charts.js": "sha384-qQrjhWkIDi4oU5uQrpy8DdlMjY+gfiivBuX6mssNiFdkawgkVBvKneGgp+nd3PYJ",
7
- "manifest.chat.js": "sha384-5SEd0T5cInCswUcbAH7CuKYuzCu9nPoGOsCjSo22UVksHkxZ5OY78ZWTjeVQtR9M",
7
+ "manifest.chat.js": "sha384-mD8exNWzRhkGW07xBxLyDagykP5knEx/i0/trG47rM2n1XJJ0t3SlJSskwcFmbm6",
8
8
  "manifest.code.js": "sha384-aoQ4E26vrhNe/+tL7K0h90c8/0ies7e8oIR6Ay92he2X3dnWZ+OPcn2Dna8fmc+c",
9
9
  "manifest.color.js": "sha384-6Rv3LxyTcZNjrhtayQfqRdCx0uSZ4BiEbgEI98I62eTvp8Aw7LBIoNJ0Je1oktwL",
10
10
  "manifest.colorpicker.js": "sha384-1+ZV5Hhjf7WnGP7b71Cqa5h3BKW8UgGT5V14i8Q+aF5zH8Xxwowt/ibSUVsiIHSm",
11
11
  "manifest.combobox.js": "sha384-SN3XHumoebxcduFQqx5zt65/Cd10y8nuf9Gkco6UnsZ42sadRd+gvVLfWPdkkuPH",
12
- "manifest.components.js": "sha384-HEyeJtV20k7po8WH0LEj800MlsqgDH0vE5GTAl62SgdEhn1aJ7VfryQcA6yIi18U",
12
+ "manifest.components.js": "sha384-DLGSqCbnGkS87AWJ8GpKoAFP4nCosgC5SFSg6C10hH/nWu/MxI+0ntHlnFEfs++u",
13
13
  "manifest.computed.js": "sha384-GYML/e81gQfN+iDbqhPUgny8bINCyL+SrbTofoGk4hlCnLLjv51mCv42JMqq+ku5",
14
- "manifest.data.js": "sha384-2PDbtqCZnYLWR4enzYvj93csIQX2pC1HhFDmTGFrTb3v0IS2FzZ0cgatZ6RPR50y",
14
+ "manifest.data.js": "sha384-KV4OtKbidiW4Am0EZBdMApC4JPetFLnscK23r4L+qUoCzCL7CLjmzRPP1+vRXcCI",
15
15
  "manifest.datepicker.js": "sha384-8vTJYkLqqvgXgm1w1becuaRR/jUEpiLBjBJ6RsRbUr+ZkypvspD6EsssuDrX4SQq",
16
16
  "manifest.defer.js": "sha384-t/g++osVS3qDXeY8+gfxUtLF9o0SCQQJKNxHGpb8NkIciDvxOAvA6sFIVcM0AKeA",
17
17
  "manifest.dropdowns.js": "sha384-4HuHkBt4i8sTPUDLB9rNLli2/lWLY1tjtCLzey37gRwueG+FRLCnVH1q7ljiVvJR",
@@ -21,13 +21,13 @@
21
21
  "manifest.localization.js": "sha384-p8MRlfpjQuMar7rerGRjfdRKqIPoU/QOwVmnwN+PjhrlEZNpetYLZhqO2i5BZn9s",
22
22
  "manifest.markdown.js": "sha384-HFE2VwBRX5vhDGQ3c8XgZ10Y5ENkXxHzgX9DjmIEffqLoUDbnJYNk3TFWT9k3e+f",
23
23
  "manifest.native.js": "sha384-nIngj4CM5hV4bvQvgs8C7JmSy1UUzobsbhvDE2NH5dXqQVNW/Hiat34wHUxMqSaO",
24
- "manifest.payments.js": "sha384-QGctMZtxF0Wb2JUJbb9sJ4bFbyQvUdr9HaKs4afyaTXb7zedAAIWeB27XINMe3VZ",
24
+ "manifest.payments.js": "sha384-8pofk2zhxtapPMpwnFyTelPMrYhShNhDCE722uQh/EYFvZFuPLmSdgunqsarVQjv",
25
25
  "manifest.resize.js": "sha384-+0IsyrGP/4gZmNbD6oU8dCgEyhpBsXMm74NIenYeUGuGRWyJDurcG27xE/CA0/aA",
26
26
  "manifest.router.js": "sha384-4qmGEkRpgAo9xoQkW6+hHIhowvcyAggKB2J3Wf8tJtXp+L0hufoVAqzfhnqw4cNR",
27
27
  "manifest.slides.js": "sha384-3uRTkyK9XPLmnxI2+igZlpi4EyPlU/7IHj5j3BZJJ2KN455vXyk99fiXV3feO/XY",
28
- "manifest.status.js": "sha384-fXqDnKwldB7XRxcfEQYTm/WqLl2oP24xY2Znq8FqnFM9LQo0zrQkXszqAOksArUX",
28
+ "manifest.status.js": "sha384-nwvUSbT+gpRMqhYx6MeBYswUMH72rY92mjgxv0vrSG7Ht7l83XYpEB6fCTbXjjfK",
29
29
  "manifest.svg.js": "sha384-qr/8H9+2cIhSXNbRWRtIdrDlTOxKlNJqwEefHvCYoiBNW/kKhPTFa109Orv/EBnb",
30
- "manifest.sw.js": "sha384-lzc4R7OpLBlr8VS6OfudGQVrKdEny+1etglkfsLUQ3pX0Z3JJWagy0rl/amf5xnW",
30
+ "manifest.sw.js": "sha384-s7ZLcM3CZ8Yyt+KsC9Mc1bSgvL7JJsNfWRHBEldBOEWvrRDohTRPDWSVqXprHf3k",
31
31
  "manifest.tabs.js": "sha384-OIIcyaQnGS0eNYk4zgAFEDboNYect7THvUd9D0V6nqCeDOxQcoiqLrBEmmWVTTet",
32
32
  "manifest.tailwind.js": "sha384-r/Jvqb+Piz21jUts10BbVAJoKkShOdJRVFpywyi4HPIi/OfOJq5CtPyWAPbdkMgt",
33
33
  "manifest.text.edit.js": "sha384-1LsuOJyMCgab7W9w6DJEu5URzbadYxtq/cHtB8sN3hBFa/BHPnjdnTRbiKyM0FcC",
@@ -36,5 +36,5 @@
36
36
  "manifest.url.parameters.js": "sha384-J2aSVBOPsoqsbafHndrWLHEDpKb4AKJAoQnVmKA4gZh5P/8HHjFWHO/lkusmG84l",
37
37
  "manifest.utilities.js": "sha384-RvUXxxMLv5q6Psng6jjfK5O1xw05mV6BdLjV92zQW7Zuy3XWctl3QnF5XYNuPyYq",
38
38
  "manifest.virtual.js": "sha384-YwwmAsZNddajnAkLhBWtrK8edHMJOhD7cJkQi3qmm5o1Thg0wbtDU0dsfrCHKTIQ",
39
- "manifest.js": "sha384-jicPS2+j2BtRtkdXC8YqGOQFi/V/E9MMjJFQ8mbDult9IG2cyzwq191W+zIl137b"
39
+ "manifest.js": "sha384-uZNE076xOWVEeO51qX8XpEMh+OQZEkGd3AI0yuy4skn320IkuX1j9F1THVuOgzgf"
40
40
  }
package/lib/manifest.js CHANGED
@@ -710,6 +710,7 @@
710
710
  const devServer = !!window.__mnfstRun;
711
711
  const devOrigin = isDevHost(loc.hostname);
712
712
  let manifest = window.__manifestLoaded || null;
713
+ if (!manifest && window.__manifestPromise) manifest = await window.__manifestPromise.catch(() => null);
713
714
  if (!manifest) {
714
715
  const url = document.querySelector('link[rel="manifest"]')?.getAttribute('href') || '/manifest.json';
715
716
  manifest = await fetch(url).then(r => r.ok ? r.json() : null).catch(() => null);
@@ -829,13 +830,26 @@
829
830
  walk(obj);
830
831
  };
831
832
 
833
+ // One manifest.json request per boot: published on window the moment it starts so
834
+ // plugins that init before __manifestLoaded is set (data, auth, components) await it
835
+ // instead of fetching their own. Resolves interpolated, or null.
836
+ const shareManifestFetch = () => {
837
+ if (window.__manifestLoaded) return Promise.resolve(window.__manifestLoaded);
838
+ if (!window.__manifestPromise) {
839
+ window.__manifestPromise = fetch(manifestUrl).then(r => r.ok ? r.json() : null)
840
+ .then(m => { if (m && !m.__interpolated) { interpolateManifestEnv(m); Object.defineProperty(m, '__interpolated', { value: true, enumerable: false }); } return m; })
841
+ .catch(() => null);
842
+ }
843
+ return window.__manifestPromise;
844
+ };
845
+
832
846
  const loadPlugins = async () => {
833
847
  let manifest = null;
834
848
  let pluginsToLoad = config.plugins;
835
849
  let manifestPromise = null;
836
850
 
837
851
  if (config.deriveFromManifest) {
838
- manifest = await fetch(manifestUrl).then(r => r.ok ? r.json() : null).catch(() => null);
852
+ manifest = await shareManifestFetch();
839
853
  const corePlugins = getDefaultPluginsFromManifest(manifest);
840
854
  const appwritePlugins = detectAppwritePlugins(manifest);
841
855
  const paymentsPlugins = detectPaymentsPlugins(manifest);
@@ -846,7 +860,7 @@
846
860
  pluginsToLoad = resolveDependencies([...ALWAYS_ON, ...pluginsToLoad.filter(p => !ALWAYS_ON.includes(p))]);
847
861
  const needsManifest = config.plugins.some(p => MANIFEST_DEPENDENT_PLUGINS.includes(p));
848
862
  if (needsManifest) {
849
- manifestPromise = fetch(manifestUrl).then(r => r.ok ? r.json() : null).catch(() => null);
863
+ manifestPromise = shareManifestFetch();
850
864
  }
851
865
  // Inside a Capacitor container, ensure the native umbrella loads even on
852
866
  // the explicit data-plugins path (matches the derive-path auto-inject).
@@ -868,9 +882,7 @@
868
882
  manifest = await manifestPromise;
869
883
  }
870
884
  if (manifest && typeof window !== 'undefined') {
871
- // Resolve ${VAR} before any plugin reads the cached manifest —
872
- // appwrite-auth etc. read window.__manifestLoaded directly.
873
- interpolateManifestEnv(manifest);
885
+ // Already interpolated by shareManifestFetch; appwrite-auth etc. read window.__manifestLoaded directly.
874
886
  window.__manifestLoaded = manifest;
875
887
  if (window.ManifestComponentsRegistry) {
876
888
  window.ManifestComponentsRegistry.manifest = manifest;
@@ -21,10 +21,11 @@ function resolvedOrNull(value, fieldName) {
21
21
  async function ensureManifest() {
22
22
  if (window.ManifestComponentsRegistry?.manifest) return window.ManifestComponentsRegistry.manifest;
23
23
  if (window.__manifestLoaded) return window.__manifestLoaded;
24
+ if (window.__manifestPromise) { const shared = await window.__manifestPromise.catch(() => null); if (shared) return shared; }
24
25
  try {
25
26
  const url = document.querySelector('link[rel="manifest"]')?.getAttribute('href') || '/manifest.json';
26
- const res = await fetch(url);
27
- return await res.json();
27
+ window.__manifestPromise = fetch(url).then(r => r.json());
28
+ return await window.__manifestPromise;
28
29
  } catch (_) {
29
30
  return null;
30
31
  }
@@ -64,13 +64,14 @@
64
64
  // cache a normalized copy that omits keys they don't consume.
65
65
  async function ensureStatusManifest() {
66
66
  const cached = window.ManifestComponentsRegistry?.manifest || window.__manifestLoaded;
67
- if (cached && cached.status) return cached;
67
+ if (cached) return cached; // a loaded manifest without `status` means no status config, not a stale copy
68
+ if (window.__manifestPromise) { const shared = await window.__manifestPromise.catch(() => null); if (shared) return shared; }
68
69
  try {
69
70
  const url = document.querySelector('link[rel="manifest"]')?.getAttribute('href') || '/manifest.json';
70
- const res = await fetch(url);
71
- return await res.json();
71
+ window.__manifestPromise = fetch(url).then(r => r.json());
72
+ return await window.__manifestPromise;
72
73
  } catch (_) {
73
- return cached || null;
74
+ return null;
74
75
  }
75
76
  }
76
77
 
@@ -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.199-next.2';
19
+ const BUILD_VERSION = '0.5.199-next.3';
20
20
  const CACHE_PREFIX = 'mnfst-sw:';
21
21
  const META_CACHE = CACHE_PREFIX + 'meta';
22
22
  const SWR_CAP = 200;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mnfst",
3
- "version": "0.5.199-next.2",
3
+ "version": "0.5.199-next.3",
4
4
  "private": false,
5
5
  "workspaces": [
6
6
  "templates/starter",