vfsjs-test 1.0.24 → 1.0.26
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 +21 -11
- package/package.json +1 -1
- package/vfsjs.js +27 -17
package/main.js
CHANGED
|
@@ -19,29 +19,39 @@ window.vfs = {
|
|
|
19
19
|
};
|
|
20
20
|
|
|
21
21
|
async function runProductionBuild() {
|
|
22
|
-
//
|
|
22
|
+
// Seed your custom app.js code string directly into memory
|
|
23
23
|
vfs.add('app.js', `
|
|
24
24
|
console.log("Application loop booted inside clean VFS space!");
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
25
|
+
|
|
26
|
+
const container = document.createElement('div');
|
|
27
|
+
container.className = 'js-card';
|
|
28
|
+
container.innerHTML = '<h3>Automated Clean Shell Live</h3><p>The parent DOM was wiped. This environment is 100% isolated.</p><button id="action-btn">Trigger Confetti</button>';
|
|
29
|
+
document.body.appendChild(container);
|
|
30
|
+
|
|
31
|
+
document.getElementById('action-btn').addEventListener('click', () => {
|
|
32
|
+
if (typeof window.confetti === 'function') {
|
|
33
|
+
window.confetti({ particleCount: 80, spread: 70 });
|
|
34
|
+
}
|
|
35
|
+
});
|
|
30
36
|
`, 'text/javascript');
|
|
31
37
|
|
|
38
|
+
// Seed your custom style.css string directly into memory
|
|
32
39
|
vfs.add('style.css', `
|
|
33
|
-
body { background:
|
|
34
|
-
|
|
40
|
+
body { background: #020617; color: #f8fafc; font-family: system-ui, sans-serif; text-align: center; padding: 50px; display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 80vh; margin: 0; }
|
|
41
|
+
h1 { color: #38bdf8; }
|
|
42
|
+
.js-card { background: #0f172a; border: 1px solid #1e293b; padding: 25px; border-radius: 12px; max-width: 400px; margin-top: 30px; }
|
|
43
|
+
.js-card h3 { color: #34d399; margin-top: 0; }
|
|
44
|
+
button { background: #38bdf8; color: #020617; border: none; padding: 10px 20px; font-weight: 600; border-radius: 6px; cursor: pointer; margin-top: 10px; }
|
|
35
45
|
`, 'text/css');
|
|
36
46
|
|
|
37
|
-
//
|
|
47
|
+
// Load any third-party script assets natively
|
|
38
48
|
await vfs.importRemote('my-confetti-engine.js', 'https://cdn.jsdelivr.net/npm/canvas-confetti@1.9.4/dist/confetti.browser.min.js', 'text/javascript');
|
|
39
49
|
|
|
40
|
-
//
|
|
50
|
+
// Signal the kernel to open up the viewport
|
|
41
51
|
window._vfsKernel.openViewport();
|
|
42
52
|
}
|
|
43
53
|
|
|
44
|
-
// Verification
|
|
54
|
+
// Verification pooling check
|
|
45
55
|
(function verifyKernelAvailability() {
|
|
46
56
|
if (window._vfsKernel && navigator.serviceWorker && navigator.serviceWorker.controller) {
|
|
47
57
|
runProductionBuild();
|
package/package.json
CHANGED
package/vfsjs.js
CHANGED
|
@@ -1,47 +1,56 @@
|
|
|
1
|
-
// vfsjs.js - Version
|
|
1
|
+
// vfsjs.js - Version 10.0.0 (Automated Runtime Clean-Shell Engine)
|
|
2
2
|
(function() {
|
|
3
|
+
// SECURITY SHIELD: If we are inside the iframe, do absolutely nothing.
|
|
4
|
+
// The iframe will read the pristine virtual files from the Service Worker.
|
|
5
|
+
if (window.self !== window.top) return;
|
|
6
|
+
|
|
3
7
|
const encoder = new TextEncoder();
|
|
4
8
|
|
|
5
9
|
const engineCore = {
|
|
6
10
|
async init() {
|
|
11
|
+
console.log("%c[VFS Kernel] Automated Clean-Shell Engine Initializing...", "color: #38bdf8; font-weight: bold;");
|
|
12
|
+
|
|
7
13
|
try {
|
|
8
|
-
// 1. Boot up the
|
|
14
|
+
// 1. Boot up the Service Worker interceptor
|
|
9
15
|
await navigator.serviceWorker.register('./sw.js');
|
|
10
16
|
if (!navigator.serviceWorker.controller) {
|
|
11
17
|
await new Promise(r => navigator.serviceWorker.addEventListener('controllerchange', r, { once: true }));
|
|
12
18
|
}
|
|
13
19
|
|
|
14
|
-
// 2. Capture
|
|
15
|
-
const
|
|
16
|
-
|
|
20
|
+
// 2. Capture the pristine physical HTML right now
|
|
21
|
+
const nativeMarkup = `<!DOCTYPE html>\n<html>${document.documentElement.innerHTML}</html>`;
|
|
22
|
+
|
|
23
|
+
// 3. AUTOMATED CLEAN SHELL: Wipe the parent DOM instantly!
|
|
24
|
+
// This kills all pending network requests for style.css or app.js in the parent.
|
|
25
|
+
document.documentElement.innerHTML = '<head><meta charset="UTF-8"><title>VFS Runtime Canvas</title></head><body></body>';
|
|
26
|
+
|
|
27
|
+
// 4. Set up pristine parent layout styling
|
|
28
|
+
Object.assign(document.documentElement.style, { width: '100%', height: '100%', overflow: 'hidden', margin: '0', padding: '0' });
|
|
29
|
+
Object.assign(document.body.style, { width: '100%', height: '100%', overflow: 'hidden', margin: '0', padding: '0', background: '#020617' });
|
|
30
|
+
|
|
31
|
+
// 5. Commit the native code markup safely to the virtual memory file system
|
|
32
|
+
this.write('index.html', nativeMarkup, 'text/html');
|
|
17
33
|
|
|
18
|
-
console.log("[VFS Kernel] Core initialized. Communication channel open.");
|
|
19
34
|
return true;
|
|
20
35
|
} catch (err) {
|
|
21
|
-
console.error("VFS
|
|
36
|
+
console.error("VFS Critical Runtime Separation Fault:", err);
|
|
22
37
|
return false;
|
|
23
38
|
}
|
|
24
39
|
},
|
|
25
40
|
|
|
26
|
-
//
|
|
41
|
+
// Triggered by main.js once custom script/style overrides are committed
|
|
27
42
|
openViewport() {
|
|
28
|
-
console.log("[VFS Kernel]
|
|
43
|
+
console.log("[VFS Kernel] Opening sandboxed runtime viewport frame.");
|
|
29
44
|
|
|
30
|
-
// Re-enforce main window shell structures cleanly
|
|
31
|
-
document.body.style.margin = '0';
|
|
32
|
-
document.body.style.padding = '0';
|
|
33
|
-
document.body.style.overflow = 'hidden';
|
|
34
|
-
document.body.style.background = '#020617';
|
|
35
|
-
|
|
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', background: '#020617'
|
|
41
50
|
});
|
|
42
51
|
document.body.appendChild(iframe);
|
|
43
52
|
|
|
44
|
-
//
|
|
53
|
+
// Launch the iframe into the virtual file system space
|
|
45
54
|
iframe.src = './index.html?vfs=true';
|
|
46
55
|
},
|
|
47
56
|
|
|
@@ -68,6 +77,7 @@
|
|
|
68
77
|
|
|
69
78
|
window._vfsKernel = engineCore;
|
|
70
79
|
|
|
80
|
+
// Run instantly to capture the DOM structure before the browser can parse the body tags
|
|
71
81
|
if (document.readyState === 'loading') {
|
|
72
82
|
document.addEventListener('DOMContentLoaded', () => engineCore.init());
|
|
73
83
|
} else {
|