mnfst 0.5.99 → 0.5.100
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/lib/manifest.integrity.json +1 -1
- package/lib/manifest.js +41 -0
- package/package.json +1 -1
|
@@ -22,5 +22,5 @@
|
|
|
22
22
|
"manifest.tooltips.js": "sha384-Hhip5ZN66xhDw3m0XBrKLKLpcVRz3Z9RszPKqo6xvFF0mrUgQBVZ+mZjZsXgOOjS",
|
|
23
23
|
"manifest.url.parameters.js": "sha384-FIufiClqDx1rJpU/QUc9z/D43qClQ6Qm8rBahipbJl9BDHUvhrOsUDegmTWW7Tuf",
|
|
24
24
|
"manifest.utilities.js": "sha384-x07Pfi4UxK9tbdcOZgZ5jkveseT1xBUTFtO08ORcokCH64FHsUceoiAICAsRJMle",
|
|
25
|
-
"manifest.js": "sha384-
|
|
25
|
+
"manifest.js": "sha384-AaKRNJvva7ik7bhCXdE5Ic/PYL4mbxJv2hStF+xNaZfBfSiETMuVPtRlPVjgury3"
|
|
26
26
|
}
|
package/lib/manifest.js
CHANGED
|
@@ -491,6 +491,41 @@
|
|
|
491
491
|
];
|
|
492
492
|
const manifestUrl = (document.querySelector('link[rel="manifest"]')?.getAttribute('href')) || '/manifest.json';
|
|
493
493
|
|
|
494
|
+
// Substitute ${VAR} placeholders against window.env in every string
|
|
495
|
+
// value of the parsed manifest, in place. Called once before the
|
|
496
|
+
// manifest is cached on window so every downstream consumer
|
|
497
|
+
// (auth, data, components, etc.) sees resolved values. Inlined in
|
|
498
|
+
// the loader rather than borrowed from the data plugin because the
|
|
499
|
+
// data plugin's script may not have finished executing yet at the
|
|
500
|
+
// point we cache the manifest. window.env is populated by either
|
|
501
|
+
// the mnfst-run dev server (which reads .env at startup) or a
|
|
502
|
+
// developer-supplied <script>window.env = {…}</script> block.
|
|
503
|
+
const interpolateManifestEnv = (obj) => {
|
|
504
|
+
if (obj === null || typeof obj !== 'object') return;
|
|
505
|
+
const subst = (str) => str.replace(/\$\{([^}]+)\}/g, (m, name) => {
|
|
506
|
+
if (typeof window !== 'undefined' && window.env && window.env[name] !== undefined) {
|
|
507
|
+
return window.env[name];
|
|
508
|
+
}
|
|
509
|
+
return m;
|
|
510
|
+
});
|
|
511
|
+
const walk = (o) => {
|
|
512
|
+
if (Array.isArray(o)) {
|
|
513
|
+
for (let i = 0; i < o.length; i++) {
|
|
514
|
+
const v = o[i];
|
|
515
|
+
if (typeof v === 'string') o[i] = subst(v);
|
|
516
|
+
else if (v && typeof v === 'object') walk(v);
|
|
517
|
+
}
|
|
518
|
+
} else {
|
|
519
|
+
for (const k of Object.keys(o)) {
|
|
520
|
+
const v = o[k];
|
|
521
|
+
if (typeof v === 'string') o[k] = subst(v);
|
|
522
|
+
else if (v && typeof v === 'object') walk(v);
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
};
|
|
526
|
+
walk(obj);
|
|
527
|
+
};
|
|
528
|
+
|
|
494
529
|
const loadPlugins = async () => {
|
|
495
530
|
let manifest = null;
|
|
496
531
|
let pluginsToLoad = config.plugins;
|
|
@@ -521,6 +556,12 @@
|
|
|
521
556
|
manifest = await manifestPromise;
|
|
522
557
|
}
|
|
523
558
|
if (manifest && typeof window !== 'undefined') {
|
|
559
|
+
// Resolve ${VAR} placeholders once, here, before any
|
|
560
|
+
// downstream plugin reads the cached manifest. Plugins like
|
|
561
|
+
// appwrite-auth read window.__manifestLoaded directly and
|
|
562
|
+
// would otherwise see literal `${APPWRITE_DEV_KEY}` strings
|
|
563
|
+
// even when window.env is populated.
|
|
564
|
+
interpolateManifestEnv(manifest);
|
|
524
565
|
window.__manifestLoaded = manifest;
|
|
525
566
|
if (window.ManifestComponentsRegistry) {
|
|
526
567
|
window.ManifestComponentsRegistry.manifest = manifest;
|