vfsjs-test 1.0.26 → 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.
Files changed (3) hide show
  1. package/main.js +33 -16
  2. package/package.json +1 -1
  3. package/vfsjs.js +16 -18
package/main.js CHANGED
@@ -19,39 +19,56 @@ window.vfs = {
19
19
  };
20
20
 
21
21
  async function runProductionBuild() {
22
- // Seed your custom app.js code string directly into memory
22
+ // Seed app.js with single-execution target handlers
23
23
  vfs.add('app.js', `
24
24
  console.log("Application loop booted inside clean VFS space!");
25
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 });
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);
34
36
  }
37
+
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);
43
+
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
+ });
35
51
  });
36
52
  `, 'text/javascript');
37
53
 
38
- // Seed your custom style.css string directly into memory
39
54
  vfs.add('style.css', `
40
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; }
41
- h1 { color: #38bdf8; }
42
- .js-card { background: #0f172a; border: 1px solid #1e293b; padding: 25px; border-radius: 12px; max-width: 400px; margin-top: 30px; }
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); }
43
60
  .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; }
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; }
45
64
  `, 'text/css');
46
65
 
47
- // Load any third-party script assets natively
66
+ // Fetch the external engine framework dependencies natively
48
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');
49
68
 
50
- // Signal the kernel to open up the viewport
51
69
  window._vfsKernel.openViewport();
52
70
  }
53
71
 
54
- // Verification pooling check
55
72
  (function verifyKernelAvailability() {
56
73
  if (window._vfsKernel && navigator.serviceWorker && navigator.serviceWorker.controller) {
57
74
  runProductionBuild();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vfsjs-test",
3
- "version": "1.0.26",
3
+ "version": "1.0.27",
4
4
  "description": "",
5
5
  "main": "index.html",
6
6
  "scripts": {
package/vfsjs.js CHANGED
@@ -1,46 +1,47 @@
1
- // vfsjs.js - Version 10.0.0 (Automated Runtime Clean-Shell Engine)
1
+ // vfsjs.js - Version 11.0.0 (Pristine Shell 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
- console.log("%c[VFS Kernel] Automated Clean-Shell Engine Initializing...", "color: #38bdf8; font-weight: bold;");
9
+ console.log("%c[VFS Kernel] Cleaning setup artifacts and isolating scope...", "color: #34d399; font-weight: bold;");
12
10
 
13
11
  try {
14
- // 1. Boot up the Service Worker interceptor
15
12
  await navigator.serviceWorker.register('./sw.js');
16
13
  if (!navigator.serviceWorker.controller) {
17
14
  await new Promise(r => navigator.serviceWorker.addEventListener('controllerchange', r, { once: true }));
18
15
  }
19
16
 
20
- // 2. Capture the pristine physical HTML right now
21
- const nativeMarkup = `<!DOCTYPE html>\n<html>${document.documentElement.innerHTML}</html>`;
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>`;
22
26
 
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>';
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>';
26
29
 
27
- // 4. Set up pristine parent layout styling
28
30
  Object.assign(document.documentElement.style, { width: '100%', height: '100%', overflow: 'hidden', margin: '0', padding: '0' });
29
31
  Object.assign(document.body.style, { width: '100%', height: '100%', overflow: 'hidden', margin: '0', padding: '0', background: '#020617' });
30
32
 
31
- // 5. Commit the native code markup safely to the virtual memory file system
33
+ // 4. Send the sanitized native markup down to the worker
32
34
  this.write('index.html', nativeMarkup, 'text/html');
33
35
 
34
36
  return true;
35
37
  } catch (err) {
36
- console.error("VFS Critical Runtime Separation Fault:", err);
38
+ console.error("VFS Separation Fault:", err);
37
39
  return false;
38
40
  }
39
41
  },
40
42
 
41
- // Triggered by main.js once custom script/style overrides are committed
42
43
  openViewport() {
43
- console.log("[VFS Kernel] Opening sandboxed runtime viewport frame.");
44
+ console.log("[VFS Kernel] Spawning isolated rendering viewport.");
44
45
 
45
46
  const iframe = document.createElement('iframe');
46
47
  iframe.id = 'canvas-viewport';
@@ -49,8 +50,6 @@
49
50
  border: 'none', margin: '0', padding: '0', zIndex: '999999', background: '#020617'
50
51
  });
51
52
  document.body.appendChild(iframe);
52
-
53
- // Launch the iframe into the virtual file system space
54
53
  iframe.src = './index.html?vfs=true';
55
54
  },
56
55
 
@@ -77,7 +76,6 @@
77
76
 
78
77
  window._vfsKernel = engineCore;
79
78
 
80
- // Run instantly to capture the DOM structure before the browser can parse the body tags
81
79
  if (document.readyState === 'loading') {
82
80
  document.addEventListener('DOMContentLoaded', () => engineCore.init());
83
81
  } else {