vfsjs-test 1.0.10 → 1.0.12
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 +35 -54
- package/package.json +1 -1
- package/vfsjs.js +25 -36
package/main.js
CHANGED
|
@@ -1,69 +1,50 @@
|
|
|
1
|
-
// main.js -
|
|
1
|
+
// main.js - Developer Workspace API
|
|
2
2
|
|
|
3
3
|
window.vfs = {
|
|
4
4
|
add(filename, contentString, customMime = null) {
|
|
5
5
|
return window._vfsKernel.write(filename, contentString, customMime);
|
|
6
6
|
},
|
|
7
|
-
delete(filename) {
|
|
8
|
-
|
|
9
|
-
},
|
|
10
|
-
clear() {
|
|
11
|
-
return window._vfsKernel.wipe();
|
|
12
|
-
}
|
|
7
|
+
delete(filename) { return window._vfsKernel.remove(filename); },
|
|
8
|
+
clear() { return window._vfsKernel.wipe(); }
|
|
13
9
|
};
|
|
14
10
|
|
|
15
11
|
async function startDeveloperWorkspace() {
|
|
16
|
-
//
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
background: linear-gradient(-45deg, #ff007f, #7f00ff, #00bfff, #00ff7f, #ffea00, #ff007f) !important;
|
|
25
|
-
background-size: 400% 400% !important;
|
|
26
|
-
animation: rainbowShift 12s ease infinite !important;
|
|
27
|
-
color: #ffffff !important;
|
|
28
|
-
text-shadow: 1px 1px 3px rgba(0,0,0,0.8);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
/* Make the title text pop */
|
|
32
|
-
h2 {
|
|
33
|
-
color: #ffffff !important;
|
|
34
|
-
text-shadow: 0 0 10px rgba(255,255,255,0.6), 0 0 20px rgba(0,255,255,0.4);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
/* Style the log box to look like a dark synthwave terminal */
|
|
38
|
-
#status {
|
|
39
|
-
background: rgba(10, 10, 25, 0.85) !important;
|
|
40
|
-
border: 2px solid #ff007f !important;
|
|
41
|
-
border-radius: 8px;
|
|
42
|
-
box-shadow: 0 0 15px rgba(255, 0, 127, 0.4), inset 0 0 10px rgba(0, 0, 0, 0.9) !important;
|
|
43
|
-
color: #00ffcc !important;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
/* Bold tags inside the logs get a neon highlight */
|
|
47
|
-
#status b {
|
|
48
|
-
color: #ffea00 !important;
|
|
49
|
-
text-shadow: 0 0 5px rgba(255,234,0,0.5);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
/* Keyframes to smoothly move the background gradients */
|
|
53
|
-
@keyframes rainbowShift {
|
|
54
|
-
0% { background-position: 0% 50%; }
|
|
55
|
-
50% { background-position: 100% 50%; }
|
|
56
|
-
100% { background-position: 0% 50%; }
|
|
57
|
-
}
|
|
58
|
-
`, 'text/css');
|
|
12
|
+
// 1. Add standard CSS rules directly
|
|
13
|
+
vfs.add('live_theme.css', `
|
|
14
|
+
html, body { margin: 0; padding: 40px; height: 100%; overflow: hidden; font-family: monospace; background: #020617; color: #38bdf8; }
|
|
15
|
+
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; }
|
|
16
|
+
@keyframes rainbowShift { 0% { background-position: 0% 50%; } 50% { background-position: 100% 50%; } 100% { background-position: 0% 50%; } }
|
|
17
|
+
`, 'text/css');
|
|
18
|
+
|
|
19
|
+
// 2. Add traditional JavaScript code
|
|
59
20
|
vfs.add('index.js', `
|
|
60
|
-
console.log("
|
|
61
|
-
const statusEl = document.getElementById('status');
|
|
62
|
-
if (statusEl) statusEl.innerHTML += "<br>> <span style='color: #22c55e;'>Virtual asset code running live!</span>";
|
|
21
|
+
console.log("Normal layout execution script loaded smoothly!");
|
|
63
22
|
`, 'text/javascript');
|
|
23
|
+
|
|
24
|
+
// 3. Add the main index entry file using native, normal markup tags!
|
|
25
|
+
vfs.add('workspace.html', `
|
|
26
|
+
<!DOCTYPE html>
|
|
27
|
+
<html>
|
|
28
|
+
<head>
|
|
29
|
+
<meta charset="UTF-8">
|
|
30
|
+
<link rel="stylesheet" href="live_theme.css?vfs=true">
|
|
31
|
+
</head>
|
|
32
|
+
<body>
|
|
33
|
+
<h2>Infrared Seamless Virtual Environment</h2>
|
|
34
|
+
<p>This layout runs seamlessly inside an entirely virtual context.</p>
|
|
35
|
+
<script src="index.js?vfs=true"></script>
|
|
36
|
+
</body>
|
|
37
|
+
</html>
|
|
38
|
+
`, 'text/html');
|
|
39
|
+
|
|
40
|
+
// 4. Point the auto-generated viewport to the entry path!
|
|
41
|
+
const viewport = document.getElementById('canvas-viewport');
|
|
42
|
+
if (viewport) {
|
|
43
|
+
viewport.src = 'workspace.html?vfs=true';
|
|
44
|
+
}
|
|
64
45
|
}
|
|
65
46
|
|
|
66
|
-
//
|
|
47
|
+
// Automatically bootstrap when document structure is verified
|
|
67
48
|
document.addEventListener('DOMContentLoaded', async () => {
|
|
68
49
|
const ready = await window._vfsKernel.init();
|
|
69
50
|
if (ready) {
|
package/package.json
CHANGED
package/vfsjs.js
CHANGED
|
@@ -1,24 +1,40 @@
|
|
|
1
|
-
// vfsjs.js -
|
|
1
|
+
// vfsjs.js - Automated Infrastructure Engine Core
|
|
2
2
|
(function() {
|
|
3
3
|
const encoder = new TextEncoder();
|
|
4
|
-
const display = document.getElementById('status');
|
|
5
|
-
let injectedNodes = []; // Tracks dynamically mounted elements
|
|
6
4
|
|
|
7
5
|
const engineCore = {
|
|
8
|
-
// Automatically registers and activates the Service Worker thread
|
|
9
6
|
async init() {
|
|
10
7
|
try {
|
|
8
|
+
// 1. Core Service Worker Registration
|
|
11
9
|
await navigator.serviceWorker.register('./sw.js');
|
|
12
|
-
if (display) display.innerHTML += "<br>> Service worker synchronized.";
|
|
13
|
-
|
|
14
10
|
if (!navigator.serviceWorker.controller) {
|
|
15
|
-
if (display) display.innerHTML += "<br>> Securing worker routing links...";
|
|
16
11
|
await new Promise(r => navigator.serviceWorker.addEventListener('controllerchange', r, { once: true }));
|
|
17
12
|
}
|
|
18
|
-
|
|
13
|
+
|
|
14
|
+
// 2. AUTOMATION UPGRADE: Enforce full-screen layout constraints on the main window
|
|
15
|
+
Object.assign(document.documentElement.style, { width: '100%', height: '100%', overflow: 'hidden', margin: '0', padding: '0' });
|
|
16
|
+
Object.assign(document.body.style, { width: '100%', height: '100%', overflow: 'hidden', margin: '0', padding: '0', background: '#020617' });
|
|
17
|
+
|
|
18
|
+
// 3. AUTOMATION UPGRADE: Create and mount the seamless borderless canvas iframe
|
|
19
|
+
const iframe = document.createElement('iframe');
|
|
20
|
+
iframe.id = 'canvas-viewport';
|
|
21
|
+
iframe.setAttribute('scrolling', 'no');
|
|
22
|
+
Object.assign(iframe.style, {
|
|
23
|
+
position: 'absolute',
|
|
24
|
+
top: '0',
|
|
25
|
+
left: '0',
|
|
26
|
+
width: '100%',
|
|
27
|
+
height: '100%',
|
|
28
|
+
border: 'none',
|
|
29
|
+
margin: '0',
|
|
30
|
+
padding: '0',
|
|
31
|
+
zIndex: '999999'
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
document.body.appendChild(iframe);
|
|
19
35
|
return true;
|
|
20
36
|
} catch (err) {
|
|
21
|
-
|
|
37
|
+
console.error("VFS Kernel Boot Failure:", err);
|
|
22
38
|
return false;
|
|
23
39
|
}
|
|
24
40
|
},
|
|
@@ -31,46 +47,19 @@
|
|
|
31
47
|
content: encoder.encode(contentString),
|
|
32
48
|
mime: customMime
|
|
33
49
|
});
|
|
34
|
-
if (display) display.innerHTML += `<br>> Core Write: <b>${filename}</b>`;
|
|
35
50
|
return true;
|
|
36
51
|
},
|
|
37
52
|
|
|
38
53
|
remove(filename) {
|
|
39
54
|
if (!navigator.serviceWorker.controller) return false;
|
|
40
55
|
navigator.serviceWorker.controller.postMessage({ type: 'VFS_DELETE', filename: filename });
|
|
41
|
-
if (display) display.innerHTML += `<br>> Core Remove: <span style="color: #ef4444;">${filename}</span>`;
|
|
42
56
|
return true;
|
|
43
57
|
},
|
|
44
58
|
|
|
45
59
|
wipe() {
|
|
46
60
|
if (!navigator.serviceWorker.controller) return false;
|
|
47
61
|
navigator.serviceWorker.controller.postMessage({ type: 'VFS_CLEAR' });
|
|
48
|
-
if (display) display.innerHTML += `<br>><span style="color: #f59e0b;"> Core Clear: Matrix flushed.</span>`;
|
|
49
62
|
return true;
|
|
50
|
-
},
|
|
51
|
-
|
|
52
|
-
// Dynamically injects virtual assets into the browser frame safely
|
|
53
|
-
mount(filename, type) {
|
|
54
|
-
if (type === 'css') {
|
|
55
|
-
const el = document.createElement('link');
|
|
56
|
-
el.rel = 'stylesheet';
|
|
57
|
-
el.href = filename;
|
|
58
|
-
document.head.appendChild(el);
|
|
59
|
-
injectedNodes.push(el);
|
|
60
|
-
} else if (type === 'js') {
|
|
61
|
-
const el = document.createElement('script');
|
|
62
|
-
el.src = filename;
|
|
63
|
-
document.body.appendChild(el);
|
|
64
|
-
injectedNodes.push(el);
|
|
65
|
-
}
|
|
66
|
-
if (display) display.innerHTML += `<br>> Frame Hooked: Loaded [${filename}]`;
|
|
67
|
-
},
|
|
68
|
-
|
|
69
|
-
// Pulls all injected elements back out of the DOM frame
|
|
70
|
-
unmount() {
|
|
71
|
-
injectedNodes.forEach(node => node.remove());
|
|
72
|
-
injectedNodes = [];
|
|
73
|
-
if (display) display.innerHTML += `<br>><span style="color: #f43f5e;"> Frame Unhooked: Virtual nodes detached.</span>`;
|
|
74
63
|
}
|
|
75
64
|
};
|
|
76
65
|
|