vfsjs-test 1.0.24 → 1.0.25
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/main.js +49 -43
- package/package.json +1 -1
- package/vfsjs.js +17 -8
package/main.js
CHANGED
|
@@ -1,51 +1,57 @@
|
|
|
1
1
|
// main.js - Production Build Core Orchestrator
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
3
|
+
// SECURITY SHIELD: Do not execute orchestrations inside the iframe viewport container
|
|
4
|
+
if (window.self !== window.top) {
|
|
5
|
+
// Hide the uncompiled natively authored markup inside the frame until VFS style loads
|
|
6
|
+
document.addEventListener('DOMContentLoaded', () => {
|
|
7
|
+
document.documentElement.style.visibility = 'hidden';
|
|
8
|
+
});
|
|
9
|
+
} else {
|
|
10
|
+
window.vfs = {
|
|
11
|
+
add(filename, contentString, customMime = null) {
|
|
12
|
+
return window._vfsKernel.write(filename, contentString, customMime);
|
|
13
|
+
},
|
|
14
|
+
async importRemote(localFilename, remoteUrl, customMime = null) {
|
|
15
|
+
try {
|
|
16
|
+
const response = await fetch(remoteUrl);
|
|
17
|
+
if (!response.ok) throw new Error(`HTTP network error: ${response.status}`);
|
|
18
|
+
const text = await response.text();
|
|
19
|
+
this.add(localFilename, text, customMime);
|
|
20
|
+
return true;
|
|
21
|
+
} catch (err) {
|
|
22
|
+
console.error(`[VFS Proxy Error]`, err);
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
17
25
|
}
|
|
18
|
-
}
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
async function runProductionBuild() {
|
|
22
|
-
// 1. Seed assets safely into the worker environment
|
|
23
|
-
vfs.add('app.js', `
|
|
24
|
-
console.log("Application loop booted inside clean VFS space!");
|
|
25
|
-
if (typeof window.confetti === 'function') {
|
|
26
|
-
setInterval(() => {
|
|
27
|
-
window.confetti({ particleCount: 50, spread: 60 });
|
|
28
|
-
}, 2500);
|
|
29
|
-
}
|
|
30
|
-
`, 'text/javascript');
|
|
26
|
+
};
|
|
31
27
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
28
|
+
async function runProductionBuild() {
|
|
29
|
+
// Seed files exactly ONCE
|
|
30
|
+
vfs.add('app.js', `
|
|
31
|
+
console.log("Application loop booted inside clean VFS space!");
|
|
32
|
+
if (typeof window.confetti === 'function') {
|
|
33
|
+
setInterval(() => {
|
|
34
|
+
window.confetti({ particleCount: 50, spread: 60 });
|
|
35
|
+
}, 2500);
|
|
36
|
+
}
|
|
37
|
+
`, 'text/javascript');
|
|
36
38
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
+
vfs.add('style.css', `
|
|
40
|
+
html, body { background: #020617 !important; color: #f8fafc !important; font-family: monospace !important; visibility: visible !important; }
|
|
41
|
+
body { text-align: center; padding: 50px; }
|
|
42
|
+
h2 { color: #38bdf8; }
|
|
43
|
+
`, 'text/css');
|
|
39
44
|
|
|
40
|
-
|
|
41
|
-
window._vfsKernel.openViewport();
|
|
42
|
-
}
|
|
45
|
+
await vfs.importRemote('my-confetti-engine.js', 'https://cdn.jsdelivr.net/npm/canvas-confetti@1.9.4/dist/confetti.browser.min.js', 'text/javascript');
|
|
43
46
|
|
|
44
|
-
|
|
45
|
-
(function verifyKernelAvailability() {
|
|
46
|
-
if (window._vfsKernel && navigator.serviceWorker && navigator.serviceWorker.controller) {
|
|
47
|
-
runProductionBuild();
|
|
48
|
-
} else {
|
|
49
|
-
setTimeout(verifyKernelAvailability, 15);
|
|
47
|
+
window._vfsKernel.openViewport();
|
|
50
48
|
}
|
|
51
|
-
|
|
49
|
+
|
|
50
|
+
(function verifyKernelAvailability() {
|
|
51
|
+
if (window._vfsKernel && navigator.serviceWorker && navigator.serviceWorker.controller) {
|
|
52
|
+
runProductionBuild();
|
|
53
|
+
} else {
|
|
54
|
+
setTimeout(verifyKernelAvailability, 15);
|
|
55
|
+
}
|
|
56
|
+
})();
|
|
57
|
+
}
|
package/package.json
CHANGED
package/vfsjs.js
CHANGED
|
@@ -1,17 +1,26 @@
|
|
|
1
|
-
// vfsjs.js - Version
|
|
1
|
+
// vfsjs.js - Version 8.0.0 (Anti-Recursion Production Engine)
|
|
2
2
|
(function() {
|
|
3
|
+
// SECURITY SHIELD: If this is running inside the iframe, KILL EXECUTION IMMEDIATELY.
|
|
4
|
+
if (window.self !== window.top) {
|
|
5
|
+
return;
|
|
6
|
+
}
|
|
7
|
+
|
|
3
8
|
const encoder = new TextEncoder();
|
|
4
9
|
|
|
5
10
|
const engineCore = {
|
|
6
11
|
async init() {
|
|
12
|
+
// Reassuring Console Explanation Message
|
|
13
|
+
console.log(
|
|
14
|
+
"%c[VFS Kernel] NOTICE: Any 'MIME type text/plain' or 'NS_ERROR_CORRUPTED_CONTENT' errors appearing above this line are completely normal Phase-1 browser artifacts. The VFS engine gracefully abandons those uninstalled network requests and handles them safely in memory.",
|
|
15
|
+
"color: #38bdf8; font-weight: bold; background: #0f172a; padding: 4px 8px; border-radius: 4px;"
|
|
16
|
+
);
|
|
17
|
+
|
|
7
18
|
try {
|
|
8
|
-
// 1. Boot up the background network interception thread
|
|
9
19
|
await navigator.serviceWorker.register('./sw.js');
|
|
10
20
|
if (!navigator.serviceWorker.controller) {
|
|
11
21
|
await new Promise(r => navigator.serviceWorker.addEventListener('controllerchange', r, { once: true }));
|
|
12
22
|
}
|
|
13
23
|
|
|
14
|
-
// 2. Capture layout markup cleanly before UI shift
|
|
15
24
|
const rawHtml = document.documentElement.innerHTML;
|
|
16
25
|
this.write('index.html', `<!DOCTYPE html>\n<html>${rawHtml}</html>`, 'text/html');
|
|
17
26
|
|
|
@@ -23,25 +32,25 @@
|
|
|
23
32
|
}
|
|
24
33
|
},
|
|
25
34
|
|
|
26
|
-
// Called dynamically by main.js after your cache writes complete
|
|
27
35
|
openViewport() {
|
|
28
36
|
console.log("[VFS Kernel] Deploying canvas sandboxed frame wrapper.");
|
|
29
37
|
|
|
30
|
-
//
|
|
38
|
+
// FLASH FIX: Give the main body a dark background instantly so there is no bright/unstyled flash
|
|
39
|
+
document.documentElement.style.background = '#020617';
|
|
40
|
+
document.body.style.background = '#020617';
|
|
31
41
|
document.body.style.margin = '0';
|
|
32
42
|
document.body.style.padding = '0';
|
|
33
43
|
document.body.style.overflow = 'hidden';
|
|
34
|
-
document.body.style.background = '#020617';
|
|
35
44
|
|
|
36
45
|
const iframe = document.createElement('iframe');
|
|
37
46
|
iframe.id = 'canvas-viewport';
|
|
38
47
|
Object.assign(iframe.style, {
|
|
39
48
|
position: 'fixed', top: '0', left: '0', width: '100%', height: '100%',
|
|
40
|
-
border: 'none', margin: '0', padding: '0', zIndex: '999999'
|
|
49
|
+
border: 'none', margin: '0', padding: '0', zIndex: '999999',
|
|
50
|
+
background: '#020617' // Force iframe background dark before content arrives
|
|
41
51
|
});
|
|
42
52
|
document.body.appendChild(iframe);
|
|
43
53
|
|
|
44
|
-
// Force execution routing directly inside our Service Worker scope zone
|
|
45
54
|
iframe.src = './index.html?vfs=true';
|
|
46
55
|
},
|
|
47
56
|
|