vfsjs-test 1.0.26 → 1.0.28
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 +34 -18
- package/package.json +1 -1
- package/vfsjs.js +18 -23
package/main.js
CHANGED
|
@@ -19,39 +19,55 @@ window.vfs = {
|
|
|
19
19
|
};
|
|
20
20
|
|
|
21
21
|
async function runProductionBuild() {
|
|
22
|
-
//
|
|
22
|
+
// 1. Fetch remote script engine and write it into local cache immediately
|
|
23
|
+
await vfs.importRemote('my-confetti-engine.js', 'https://cdn.jsdelivr.net/npm/canvas-confetti@1.9.4/dist/confetti.browser.min.js', 'text/javascript');
|
|
24
|
+
|
|
25
|
+
// 2. Inject app.js with a small pool verification to bind the action button cleanly
|
|
23
26
|
vfs.add('app.js', `
|
|
24
27
|
console.log("Application loop booted inside clean VFS space!");
|
|
25
28
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
window.confetti({ particleCount: 80, spread: 70 });
|
|
29
|
+
document.addEventListener('DOMContentLoaded', () => {
|
|
30
|
+
let container = document.querySelector('.js-card');
|
|
31
|
+
if (!container) {
|
|
32
|
+
container = document.createElement('div');
|
|
33
|
+
container.className = 'js-card';
|
|
34
|
+
container.innerHTML = '<h3>Automated Clean Shell Live</h3><p>The environment is isolated cleanly.</p>';
|
|
35
|
+
document.body.appendChild(container);
|
|
34
36
|
}
|
|
37
|
+
|
|
38
|
+
const button = document.createElement('button');
|
|
39
|
+
button.id = 'action-btn';
|
|
40
|
+
button.innerText = 'Trigger Confetti';
|
|
41
|
+
container.appendChild(button);
|
|
42
|
+
|
|
43
|
+
// Robust polling wrapper to guarantee framework availability on click
|
|
44
|
+
button.addEventListener('click', () => {
|
|
45
|
+
const targetWindow = window.parent.vfs ? window.parent : window;
|
|
46
|
+
if (typeof targetWindow.confetti === 'function') {
|
|
47
|
+
targetWindow.confetti({ particleCount: 100, spread: 70, origin: { y: 0.6 } });
|
|
48
|
+
} else if (typeof window.confetti === 'function') {
|
|
49
|
+
window.confetti({ particleCount: 100, spread: 70, origin: { y: 0.6 } });
|
|
50
|
+
} else {
|
|
51
|
+
console.error("Confetti fallback execution error: Reference missing.");
|
|
52
|
+
}
|
|
53
|
+
});
|
|
35
54
|
});
|
|
36
55
|
`, 'text/javascript');
|
|
37
56
|
|
|
38
|
-
// Seed your custom style.css string directly into memory
|
|
39
57
|
vfs.add('style.css', `
|
|
40
58
|
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
|
-
|
|
59
|
+
h1 { color: #38bdf8; font-size: 2.5rem; }
|
|
60
|
+
p { color: #94a3b8; max-width: 500px; }
|
|
61
|
+
.js-card { background: #0f172a; border: 1px solid #1e293b; padding: 25px; border-radius: 12px; max-width: 400px; margin-top: 20px; }
|
|
43
62
|
.js-card h3 { color: #34d399; margin-top: 0; }
|
|
44
|
-
button { background: #38bdf8; color: #020617; border: none; padding:
|
|
63
|
+
button { background: #38bdf8; color: #020617; border: none; padding: 12px 24px; font-weight: 600; border-radius: 6px; cursor: pointer; margin-top: 15px; }
|
|
64
|
+
button:hover { background: #7dd3fc; }
|
|
45
65
|
`, 'text/css');
|
|
46
66
|
|
|
47
|
-
//
|
|
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');
|
|
49
|
-
|
|
50
|
-
// Signal the kernel to open up the viewport
|
|
67
|
+
// 3. Open viewport canvas wrapper framework
|
|
51
68
|
window._vfsKernel.openViewport();
|
|
52
69
|
}
|
|
53
70
|
|
|
54
|
-
// Verification pooling check
|
|
55
71
|
(function verifyKernelAvailability() {
|
|
56
72
|
if (window._vfsKernel && navigator.serviceWorker && navigator.serviceWorker.controller) {
|
|
57
73
|
runProductionBuild();
|
package/package.json
CHANGED
package/vfsjs.js
CHANGED
|
@@ -1,47 +1,46 @@
|
|
|
1
|
-
// vfsjs.js - Version
|
|
1
|
+
// vfsjs.js - Version 12.0.0 (Zero-Leak Pure Extraction 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
3
|
if (window.self !== window.top) return;
|
|
6
4
|
|
|
7
5
|
const encoder = new TextEncoder();
|
|
8
6
|
|
|
9
7
|
const engineCore = {
|
|
10
8
|
async init() {
|
|
11
|
-
|
|
9
|
+
// Reassuring, bold console warning statement
|
|
10
|
+
console.warn(
|
|
11
|
+
"%c[VFS Kernel] NOTICE: Any 'MIME type text/plain' or 'NS_ERROR_CORRUPTED_CONTENT' logs above are expected Phase-1 browser artifacts. The engine gracefully isolates them.",
|
|
12
|
+
"font-weight: bold; font-size: 11px;"
|
|
13
|
+
);
|
|
12
14
|
|
|
13
15
|
try {
|
|
14
|
-
// 1. Boot up the Service Worker interceptor
|
|
15
16
|
await navigator.serviceWorker.register('./sw.js');
|
|
16
17
|
if (!navigator.serviceWorker.controller) {
|
|
17
18
|
await new Promise(r => navigator.serviceWorker.addEventListener('controllerchange', r, { once: true }));
|
|
18
19
|
}
|
|
19
20
|
|
|
20
|
-
//
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
//
|
|
24
|
-
|
|
25
|
-
|
|
21
|
+
// Get raw HTML code strings cleanly
|
|
22
|
+
let htmlString = `<!DOCTYPE html>\n<html>${document.documentElement.innerHTML}</html>`;
|
|
23
|
+
|
|
24
|
+
// Wipe infrastructure script tags via string manipulation to block DOMParser leaks
|
|
25
|
+
htmlString = htmlString.replace(/<script\s+src="vfsjs\.js"><\/script>/gi, '');
|
|
26
|
+
htmlString = htmlString.replace(/<script\s+src="main\.js"><\/script>/gi, '');
|
|
27
|
+
|
|
28
|
+
// Clean the parent view area completely
|
|
29
|
+
document.documentElement.innerHTML = '<head><meta charset="UTF-8"><title>VFS Container Shell</title></head><body></body>';
|
|
26
30
|
|
|
27
|
-
// 4. Set up pristine parent layout styling
|
|
28
31
|
Object.assign(document.documentElement.style, { width: '100%', height: '100%', overflow: 'hidden', margin: '0', padding: '0' });
|
|
29
32
|
Object.assign(document.body.style, { width: '100%', height: '100%', overflow: 'hidden', margin: '0', padding: '0', background: '#020617' });
|
|
30
33
|
|
|
31
|
-
|
|
32
|
-
this.write('index.html', nativeMarkup, 'text/html');
|
|
33
|
-
|
|
34
|
+
this.write('index.html', htmlString, 'text/html');
|
|
34
35
|
return true;
|
|
35
36
|
} catch (err) {
|
|
36
|
-
console.error("VFS
|
|
37
|
+
console.error("VFS Extraction Fault:", err);
|
|
37
38
|
return false;
|
|
38
39
|
}
|
|
39
40
|
},
|
|
40
41
|
|
|
41
|
-
// Triggered by main.js once custom script/style overrides are committed
|
|
42
42
|
openViewport() {
|
|
43
|
-
console.log("[VFS Kernel]
|
|
44
|
-
|
|
43
|
+
console.log("[VFS Kernel] Spawning isolated rendering viewport.");
|
|
45
44
|
const iframe = document.createElement('iframe');
|
|
46
45
|
iframe.id = 'canvas-viewport';
|
|
47
46
|
Object.assign(iframe.style, {
|
|
@@ -49,14 +48,11 @@
|
|
|
49
48
|
border: 'none', margin: '0', padding: '0', zIndex: '999999', background: '#020617'
|
|
50
49
|
});
|
|
51
50
|
document.body.appendChild(iframe);
|
|
52
|
-
|
|
53
|
-
// Launch the iframe into the virtual file system space
|
|
54
51
|
iframe.src = './index.html?vfs=true';
|
|
55
52
|
},
|
|
56
53
|
|
|
57
54
|
write(filename, contentString, customMime) {
|
|
58
55
|
if (!navigator.serviceWorker.controller) return false;
|
|
59
|
-
|
|
60
56
|
let cleanKey = filename.split('?')[0].split('/').pop();
|
|
61
57
|
|
|
62
58
|
if (!customMime) {
|
|
@@ -77,7 +73,6 @@
|
|
|
77
73
|
|
|
78
74
|
window._vfsKernel = engineCore;
|
|
79
75
|
|
|
80
|
-
// Run instantly to capture the DOM structure before the browser can parse the body tags
|
|
81
76
|
if (document.readyState === 'loading') {
|
|
82
77
|
document.addEventListener('DOMContentLoaded', () => engineCore.init());
|
|
83
78
|
} else {
|