almostnode 0.2.7 → 0.2.8
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/README.md +1 -1
- package/dist/__sw__.js +80 -84
- package/dist/assets/{runtime-worker-B8_LZkBX.js → runtime-worker-D8VYeuKv.js} +1448 -1121
- package/dist/assets/runtime-worker-D8VYeuKv.js.map +1 -0
- package/dist/frameworks/code-transforms.d.ts.map +1 -1
- package/dist/frameworks/next-config-parser.d.ts +16 -0
- package/dist/frameworks/next-config-parser.d.ts.map +1 -0
- package/dist/frameworks/next-dev-server.d.ts +6 -6
- package/dist/frameworks/next-dev-server.d.ts.map +1 -1
- package/dist/frameworks/next-html-generator.d.ts +35 -0
- package/dist/frameworks/next-html-generator.d.ts.map +1 -0
- package/dist/frameworks/next-shims.d.ts +79 -0
- package/dist/frameworks/next-shims.d.ts.map +1 -0
- package/dist/index.cjs +2895 -2454
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +3208 -2782
- package/dist/index.mjs.map +1 -1
- package/dist/runtime.d.ts +20 -0
- package/dist/runtime.d.ts.map +1 -1
- package/dist/server-bridge.d.ts +2 -0
- package/dist/server-bridge.d.ts.map +1 -1
- package/dist/shims/crypto.d.ts +2 -0
- package/dist/shims/crypto.d.ts.map +1 -1
- package/dist/shims/esbuild.d.ts.map +1 -1
- package/dist/shims/fs.d.ts.map +1 -1
- package/dist/shims/http.d.ts +29 -0
- package/dist/shims/http.d.ts.map +1 -1
- package/dist/shims/path.d.ts.map +1 -1
- package/dist/shims/stream.d.ts.map +1 -1
- package/dist/shims/vfs-adapter.d.ts.map +1 -1
- package/dist/shims/ws.d.ts +2 -0
- package/dist/shims/ws.d.ts.map +1 -1
- package/dist/utils/binary-encoding.d.ts +13 -0
- package/dist/utils/binary-encoding.d.ts.map +1 -0
- package/dist/virtual-fs.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/convex-app-demo-entry.ts +229 -35
- package/src/frameworks/code-transforms.ts +5 -1
- package/src/frameworks/next-config-parser.ts +140 -0
- package/src/frameworks/next-dev-server.ts +76 -1675
- package/src/frameworks/next-html-generator.ts +597 -0
- package/src/frameworks/next-shims.ts +1050 -0
- package/src/frameworks/tailwind-config-loader.ts +1 -1
- package/src/index.ts +2 -0
- package/src/runtime.ts +94 -15
- package/src/server-bridge.ts +61 -28
- package/src/shims/crypto.ts +13 -0
- package/src/shims/esbuild.ts +4 -1
- package/src/shims/fs.ts +9 -11
- package/src/shims/http.ts +309 -3
- package/src/shims/path.ts +6 -13
- package/src/shims/stream.ts +12 -26
- package/src/shims/vfs-adapter.ts +5 -2
- package/src/shims/ws.ts +92 -2
- package/src/utils/binary-encoding.ts +43 -0
- package/src/virtual-fs.ts +7 -15
- package/dist/assets/runtime-worker-B8_LZkBX.js.map +0 -1
package/src/virtual-fs.ts
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
import type { VFSSnapshot, VFSFileEntry } from './runtime-interface';
|
|
6
|
+
import { uint8ToBase64, base64ToUint8 } from './utils/binary-encoding';
|
|
6
7
|
|
|
7
8
|
export interface FSNode {
|
|
8
9
|
type: 'file' | 'directory';
|
|
@@ -174,11 +175,7 @@ export class VirtualFS {
|
|
|
174
175
|
// Encode binary content as base64
|
|
175
176
|
let content = '';
|
|
176
177
|
if (node.content && node.content.length > 0) {
|
|
177
|
-
|
|
178
|
-
for (let i = 0; i < node.content.length; i++) {
|
|
179
|
-
binary += String.fromCharCode(node.content[i]);
|
|
180
|
-
}
|
|
181
|
-
content = btoa(binary);
|
|
178
|
+
content = uint8ToBase64(node.content);
|
|
182
179
|
}
|
|
183
180
|
files.push({ path, type: 'file', content });
|
|
184
181
|
} else if (node.type === 'directory') {
|
|
@@ -199,11 +196,10 @@ export class VirtualFS {
|
|
|
199
196
|
const vfs = new VirtualFS();
|
|
200
197
|
|
|
201
198
|
// Sort entries to ensure directories are created before their contents
|
|
202
|
-
const sortedFiles =
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
});
|
|
199
|
+
const sortedFiles = snapshot.files
|
|
200
|
+
.map((entry, i) => ({ entry, depth: entry.path.split('/').length, i }))
|
|
201
|
+
.sort((a, b) => a.depth - b.depth || a.i - b.i)
|
|
202
|
+
.map(x => x.entry);
|
|
207
203
|
|
|
208
204
|
for (const entry of sortedFiles) {
|
|
209
205
|
if (entry.path === '/') continue; // Skip root
|
|
@@ -214,11 +210,7 @@ export class VirtualFS {
|
|
|
214
210
|
// Decode base64 content
|
|
215
211
|
let content: Uint8Array;
|
|
216
212
|
if (entry.content) {
|
|
217
|
-
|
|
218
|
-
content = new Uint8Array(binary.length);
|
|
219
|
-
for (let i = 0; i < binary.length; i++) {
|
|
220
|
-
content[i] = binary.charCodeAt(i);
|
|
221
|
-
}
|
|
213
|
+
content = base64ToUint8(entry.content);
|
|
222
214
|
} else {
|
|
223
215
|
content = new Uint8Array(0);
|
|
224
216
|
}
|