vfsjs-test 1.0.25 → 1.0.27
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 +70 -49
- package/package.json +1 -1
- package/vfsjs.js +24 -25
package/main.js
CHANGED
|
@@ -1,57 +1,78 @@
|
|
|
1
1
|
// main.js - Production Build Core Orchestrator
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
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
|
-
}
|
|
3
|
+
window.vfs = {
|
|
4
|
+
add(filename, contentString, customMime = null) {
|
|
5
|
+
return window._vfsKernel.write(filename, contentString, customMime);
|
|
6
|
+
},
|
|
7
|
+
async importRemote(localFilename, remoteUrl, customMime = null) {
|
|
8
|
+
try {
|
|
9
|
+
const response = await fetch(remoteUrl);
|
|
10
|
+
if (!response.ok) throw new Error(`HTTP network error: ${response.status}`);
|
|
11
|
+
const text = await response.text();
|
|
12
|
+
this.add(localFilename, text, customMime);
|
|
13
|
+
return true;
|
|
14
|
+
} catch (err) {
|
|
15
|
+
console.error(`[VFS Proxy Error]`, err);
|
|
16
|
+
return false;
|
|
25
17
|
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
async function runProductionBuild() {
|
|
22
|
+
// Seed app.js with single-execution target handlers
|
|
23
|
+
vfs.add('app.js', `
|
|
24
|
+
console.log("Application loop booted inside clean VFS space!");
|
|
25
|
+
|
|
26
|
+
// Wait for the pristine iframe DOM structure to land safely
|
|
27
|
+
document.addEventListener('DOMContentLoaded', () => {
|
|
28
|
+
// Find your native body elements or append a single action block card cleanly
|
|
29
|
+
let container = document.querySelector('.js-card');
|
|
30
|
+
|
|
31
|
+
if (!container) {
|
|
32
|
+
container = document.createElement('div');
|
|
33
|
+
container.className = 'js-card';
|
|
34
|
+
container.innerHTML = '<h3>Automated Clean Shell Live</h3><p>The parent DOM was wiped. This environment is 100% isolated.</p>';
|
|
35
|
+
document.body.appendChild(container);
|
|
36
36
|
}
|
|
37
|
-
`, 'text/javascript');
|
|
38
37
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
38
|
+
// Append exactly ONE action trigger button cleanly
|
|
39
|
+
const button = document.createElement('button');
|
|
40
|
+
button.id = 'action-btn';
|
|
41
|
+
button.innerText = 'Trigger Confetti';
|
|
42
|
+
container.appendChild(button);
|
|
44
43
|
|
|
45
|
-
|
|
44
|
+
button.addEventListener('click', () => {
|
|
45
|
+
if (typeof window.confetti === 'function') {
|
|
46
|
+
window.confetti({ particleCount: 100, spread: 70, origin: { y: 0.6 } });
|
|
47
|
+
} else {
|
|
48
|
+
console.error("Confetti script framework is loading or missing reference mapping.");
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
`, 'text/javascript');
|
|
46
53
|
|
|
47
|
-
|
|
48
|
-
|
|
54
|
+
vfs.add('style.css', `
|
|
55
|
+
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; }
|
|
56
|
+
h1 { color: #38bdf8; font-size: 2.5rem; }
|
|
57
|
+
p { color: #94a3b8; max-width: 500px; line-height: 1.6; }
|
|
58
|
+
|
|
59
|
+
.js-card { background: #0f172a; border: 1px solid #1e293b; padding: 25px; border-radius: 12px; max-width: 400px; margin-top: 20px; box-shadow: 0 4px 20px rgba(0,0,0,0.4); }
|
|
60
|
+
.js-card h3 { color: #34d399; margin-top: 0; }
|
|
61
|
+
|
|
62
|
+
button { background: #38bdf8; color: #020617; border: none; padding: 12px 24px; font-weight: 600; border-radius: 6px; cursor: pointer; margin-top: 15px; font-size: 14px; transition: background 0.15s ease; }
|
|
63
|
+
button:hover { background: #7dd3fc; }
|
|
64
|
+
`, 'text/css');
|
|
49
65
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
66
|
+
// Fetch the external engine framework dependencies natively
|
|
67
|
+
await vfs.importRemote('my-confetti-engine.js', 'https://cdn.jsdelivr.net/npm/canvas-confetti@1.9.4/dist/confetti.browser.min.js', 'text/javascript');
|
|
68
|
+
|
|
69
|
+
window._vfsKernel.openViewport();
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
(function verifyKernelAvailability() {
|
|
73
|
+
if (window._vfsKernel && navigator.serviceWorker && navigator.serviceWorker.controller) {
|
|
74
|
+
runProductionBuild();
|
|
75
|
+
} else {
|
|
76
|
+
setTimeout(verifyKernelAvailability, 15);
|
|
77
|
+
}
|
|
78
|
+
})();
|
package/package.json
CHANGED
package/vfsjs.js
CHANGED
|
@@ -1,19 +1,12 @@
|
|
|
1
|
-
// vfsjs.js - Version
|
|
1
|
+
// vfsjs.js - Version 11.0.0 (Pristine Shell Extraction Engine)
|
|
2
2
|
(function() {
|
|
3
|
-
|
|
4
|
-
if (window.self !== window.top) {
|
|
5
|
-
return;
|
|
6
|
-
}
|
|
3
|
+
if (window.self !== window.top) return;
|
|
7
4
|
|
|
8
5
|
const encoder = new TextEncoder();
|
|
9
6
|
|
|
10
7
|
const engineCore = {
|
|
11
8
|
async init() {
|
|
12
|
-
|
|
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
|
-
);
|
|
9
|
+
console.log("%c[VFS Kernel] Cleaning setup artifacts and isolating scope...", "color: #34d399; font-weight: bold;");
|
|
17
10
|
|
|
18
11
|
try {
|
|
19
12
|
await navigator.serviceWorker.register('./sw.js');
|
|
@@ -21,36 +14,42 @@
|
|
|
21
14
|
await new Promise(r => navigator.serviceWorker.addEventListener('controllerchange', r, { once: true }));
|
|
22
15
|
}
|
|
23
16
|
|
|
24
|
-
|
|
25
|
-
|
|
17
|
+
// 1. Create a live virtual DOM node to sanitize the markup
|
|
18
|
+
const parser = new DOMParser();
|
|
19
|
+
const doc = parser.parseFromString(`<!DOCTYPE html><html>${document.documentElement.innerHTML}</html>`, 'text/html');
|
|
20
|
+
|
|
21
|
+
// 2. CRITICAL CLEANUP: Strip infrastructure scripts out so they NEVER run inside the iframe
|
|
22
|
+
const structuralScripts = doc.querySelectorAll('script[src="vfsjs.js"], script[src="main.js"]');
|
|
23
|
+
structuralScripts.forEach(script => script.remove());
|
|
24
|
+
|
|
25
|
+
const nativeMarkup = `<!DOCTYPE html>\n<html>${doc.documentElement.innerHTML}</html>`;
|
|
26
|
+
|
|
27
|
+
// 3. Wipe parent frame clean to keep a blank workspace shell
|
|
28
|
+
document.documentElement.innerHTML = '<head><meta charset="UTF-8"><title>VFS Container</title></head><body></body>';
|
|
29
|
+
|
|
30
|
+
Object.assign(document.documentElement.style, { width: '100%', height: '100%', overflow: 'hidden', margin: '0', padding: '0' });
|
|
31
|
+
Object.assign(document.body.style, { width: '100%', height: '100%', overflow: 'hidden', margin: '0', padding: '0', background: '#020617' });
|
|
32
|
+
|
|
33
|
+
// 4. Send the sanitized native markup down to the worker
|
|
34
|
+
this.write('index.html', nativeMarkup, 'text/html');
|
|
26
35
|
|
|
27
|
-
console.log("[VFS Kernel] Core initialized. Communication channel open.");
|
|
28
36
|
return true;
|
|
29
37
|
} catch (err) {
|
|
30
|
-
console.error("VFS
|
|
38
|
+
console.error("VFS Separation Fault:", err);
|
|
31
39
|
return false;
|
|
32
40
|
}
|
|
33
41
|
},
|
|
34
42
|
|
|
35
43
|
openViewport() {
|
|
36
|
-
console.log("[VFS Kernel]
|
|
44
|
+
console.log("[VFS Kernel] Spawning isolated rendering viewport.");
|
|
37
45
|
|
|
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';
|
|
41
|
-
document.body.style.margin = '0';
|
|
42
|
-
document.body.style.padding = '0';
|
|
43
|
-
document.body.style.overflow = 'hidden';
|
|
44
|
-
|
|
45
46
|
const iframe = document.createElement('iframe');
|
|
46
47
|
iframe.id = 'canvas-viewport';
|
|
47
48
|
Object.assign(iframe.style, {
|
|
48
49
|
position: 'fixed', top: '0', left: '0', width: '100%', height: '100%',
|
|
49
|
-
border: 'none', margin: '0', padding: '0', zIndex: '999999',
|
|
50
|
-
background: '#020617' // Force iframe background dark before content arrives
|
|
50
|
+
border: 'none', margin: '0', padding: '0', zIndex: '999999', background: '#020617'
|
|
51
51
|
});
|
|
52
52
|
document.body.appendChild(iframe);
|
|
53
|
-
|
|
54
53
|
iframe.src = './index.html?vfs=true';
|
|
55
54
|
},
|
|
56
55
|
|