vfsjs-test 1.0.14 → 1.0.16

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 +59 -22
  2. package/package.json +1 -1
  3. package/vfsjs.js +5 -17
package/main.js CHANGED
@@ -1,59 +1,96 @@
1
- // main.js - Standardized Developer Environment Bootstrapper
1
+ // main.js - Production Developer Environment Layout
2
2
 
3
3
  window.vfs = {
4
+ // Write local strings straight to memory mapping keyspaces
4
5
  add(filename, contentString, customMime = null) {
5
6
  return window._vfsKernel.write(filename, contentString, customMime);
7
+ },
8
+
9
+ // Remote Proxy Asset Grabber (Requires target destination to support CORS)
10
+ async importRemote(localFilename, remoteUrl, customMime = null) {
11
+ try {
12
+ console.log(`[VFS Proxy] Pulling remote source stream: ${remoteUrl}`);
13
+ const response = await fetch(remoteUrl);
14
+ if (!response.ok) throw new Error(`HTTP network fault code: ${response.status}`);
15
+
16
+ const remoteTextContent = await response.text();
17
+ this.add(localFilename, remoteTextContent, customMime);
18
+ return true;
19
+ } catch (err) {
20
+ console.error(`[VFS Proxy Error] Could not map ${localFilename}:`, err);
21
+ return false;
22
+ }
6
23
  }
7
24
  };
8
25
 
9
26
  async function startDeveloperWorkspace() {
10
- // 1. Developer creates a perfectly normal index.html layout!
27
+ // 1. Target a real, open-source library on CDNJS (Canvas Confetti)
28
+ const remoteLibraryUrl = 'https://cdnjs.cloudflare.com/ajax/libs/canvas-confetti/1.9.3/confetti.min.js';
29
+
30
+ // 2. Map the remote asset to a virtual file named "my-confetti-engine.js"
31
+ const importSuccess = await vfs.importRemote('my-confetti-engine.js', remoteLibraryUrl, 'text/javascript');
32
+
33
+ if (!importSuccess) {
34
+ console.error("Failed to fetch library from CDNJS.");
35
+ return;
36
+ }
37
+
38
+ // 3. Create the standard HTML layout referencing the newly mapped virtual file
11
39
  vfs.add('index.html', `
12
40
  <!DOCTYPE html>
13
41
  <html>
14
42
  <head>
15
43
  <meta charset="UTF-8">
16
- <title>My Normal Project</title>
44
+ <title>CDNJS Virtualization Demo</title>
17
45
  <link rel="stylesheet" href="live_theme.css?vfs=true">
18
46
  </head>
19
47
  <body>
20
- <h1>Infrared Seamless Workspace</h1>
21
- <p>Writing standard file structures entirely in memory.</p>
48
+ <h2>CDNJS Virtualization Success!</h2>
49
+ <p>The confetti script was loaded out of memory as a local same-origin asset.</p>
22
50
 
51
+ <script src="my-confetti-engine.js?vfs=true"></script>
23
52
  <script src="index.js?vfs=true"></script>
24
53
  </body>
25
54
  </html>
26
55
  `, 'text/html');
27
56
 
28
- // 2. Developer maps standard styling files
57
+ // 4. Standard Background Theme Layout
29
58
  vfs.add('live_theme.css', `
30
- html, body { margin: 0; padding: 40px; font-family: monospace; }
31
- body { background: linear-gradient(-45deg, #ff007f, #7f00ff, #00bfff, #00ff7f, #ffea00, #ff007f) !important; background-size: 400% 400% !important; animation: rainbowShift 12s ease infinite !important; color: #ffffff !important; }
32
- @keyframes rainbowShift { 0% { background-position: 0% 50%; } 50% { background-position: 100% 50%; } 100% { background-position: 0% 50%; } }
59
+ html, body { margin: 0; padding: 40px; height: 100%; font-family: monospace; background: #020617; color: #f8fafc; text-align: center; }
60
+ body { background: linear-gradient(-45deg, #1e1b4b, #311042, #0f172a) !important; color: #ffffff !important; }
61
+ h2 { color: #38bdf8; text-shadow: 0 0 10px rgba(56, 189, 248, 0.4); }
33
62
  `, 'text/css');
34
63
 
35
- // 3. Developer maps the text spin script we built
64
+ // 5. Execution Script: Call the global function initialized by the CDNJS script
36
65
  vfs.add('index.js', `
37
- console.log("Flawless execution!");
38
- const styleNode = document.createElement('style');
39
- styleNode.innerHTML = '@keyframes spin { 0% { transform:rotate(0deg); } 100% { transform:rotate(360deg); } } .spin { display: inline-block; animation: spin 4s linear infinite; }';
40
- document.head.appendChild(styleNode);
41
-
42
- const p = document.querySelector('p');
43
- if (p) {
44
- p.innerHTML = p.innerText.split(' ').map(w => \`<span class="spin">\${w}</span>\`).join(' ');
66
+ console.log("Launcher script running. Invoking confetti...");
67
+
68
+ // Ensure the library attached itself to the virtual window context safely
69
+ if (typeof window.confetti === 'function') {
70
+ // Fire an endless burst of celebratory confetti particles!
71
+ setInterval(() => {
72
+ window.confetti({
73
+ particleCount: 50,
74
+ spread: 60,
75
+ origin: { y: 0.6 }
76
+ });
77
+ }, 1500);
78
+ } else {
79
+ console.error("Confetti engine not found in virtual window global scope.");
45
80
  }
46
81
  `, 'text/javascript');
47
82
 
48
- // 4. Fire up the viewport! Pointing to "./?vfs=true" forces the Service Worker
49
- // to step in and serve our VIRTUAL index.html instead of the physical server one.
83
+ // 6. Point the fullscreen viewport to the directory root
50
84
  const viewport = document.getElementById('canvas-viewport');
51
85
  if (viewport) {
52
86
  viewport.src = './?vfs=true';
53
87
  }
54
88
  }
55
89
 
90
+ // Global invocation hook listener
56
91
  document.addEventListener('DOMContentLoaded', async () => {
57
- const ready = await window._vfsKernel.init();
58
- if (ready) startDeveloperWorkspace();
92
+ const isReady = await window._vfsKernel.init();
93
+ if (isReady) {
94
+ startDeveloperWorkspace();
95
+ }
59
96
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vfsjs-test",
3
- "version": "1.0.14",
3
+ "version": "1.0.16",
4
4
  "description": "",
5
5
  "main": "index.html",
6
6
  "scripts": {
package/vfsjs.js CHANGED
@@ -1,21 +1,21 @@
1
- // vfsjs.js - Automated Infrastructure Engine Core
1
+ // vfsjs.js - Version 1.2.0 Automated Unified Kernel
2
2
  (function() {
3
3
  const encoder = new TextEncoder();
4
4
 
5
5
  const engineCore = {
6
6
  async init() {
7
7
  try {
8
- // 1. Core Service Worker Registration
8
+ // 1. Establish background proxy thread interception
9
9
  await navigator.serviceWorker.register('./sw.js');
10
10
  if (!navigator.serviceWorker.controller) {
11
11
  await new Promise(r => navigator.serviceWorker.addEventListener('controllerchange', r, { once: true }));
12
12
  }
13
13
 
14
- // 2. AUTOMATION UPGRADE: Enforce full-screen layout constraints on the main window
14
+ // 2. Structural Reset: Enforce full-screen boundary constraints on main window
15
15
  Object.assign(document.documentElement.style, { width: '100%', height: '100%', overflow: 'hidden', margin: '0', padding: '0' });
16
16
  Object.assign(document.body.style, { width: '100%', height: '100%', overflow: 'hidden', margin: '0', padding: '0', background: '#020617' });
17
17
 
18
- // 3. AUTOMATION UPGRADE: Create and mount the seamless borderless canvas iframe
18
+ // 3. Viewport Ingestion: Spawn the seamless full-window workspace canvas iframe
19
19
  const iframe = document.createElement('iframe');
20
20
  iframe.id = 'canvas-viewport';
21
21
  iframe.setAttribute('scrolling', 'no');
@@ -34,7 +34,7 @@
34
34
  document.body.appendChild(iframe);
35
35
  return true;
36
36
  } catch (err) {
37
- console.error("VFS Kernel Boot Failure:", err);
37
+ console.error("VFS Static Initialization Failure:", err);
38
38
  return false;
39
39
  }
40
40
  },
@@ -48,18 +48,6 @@
48
48
  mime: customMime
49
49
  });
50
50
  return true;
51
- },
52
-
53
- remove(filename) {
54
- if (!navigator.serviceWorker.controller) return false;
55
- navigator.serviceWorker.controller.postMessage({ type: 'VFS_DELETE', filename: filename });
56
- return true;
57
- },
58
-
59
- wipe() {
60
- if (!navigator.serviceWorker.controller) return false;
61
- navigator.serviceWorker.controller.postMessage({ type: 'VFS_CLEAR' });
62
- return true;
63
51
  }
64
52
  };
65
53