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.
Files changed (59) hide show
  1. package/README.md +1 -1
  2. package/dist/__sw__.js +80 -84
  3. package/dist/assets/{runtime-worker-B8_LZkBX.js → runtime-worker-D8VYeuKv.js} +1448 -1121
  4. package/dist/assets/runtime-worker-D8VYeuKv.js.map +1 -0
  5. package/dist/frameworks/code-transforms.d.ts.map +1 -1
  6. package/dist/frameworks/next-config-parser.d.ts +16 -0
  7. package/dist/frameworks/next-config-parser.d.ts.map +1 -0
  8. package/dist/frameworks/next-dev-server.d.ts +6 -6
  9. package/dist/frameworks/next-dev-server.d.ts.map +1 -1
  10. package/dist/frameworks/next-html-generator.d.ts +35 -0
  11. package/dist/frameworks/next-html-generator.d.ts.map +1 -0
  12. package/dist/frameworks/next-shims.d.ts +79 -0
  13. package/dist/frameworks/next-shims.d.ts.map +1 -0
  14. package/dist/index.cjs +2895 -2454
  15. package/dist/index.cjs.map +1 -1
  16. package/dist/index.d.ts +3 -0
  17. package/dist/index.d.ts.map +1 -1
  18. package/dist/index.mjs +3208 -2782
  19. package/dist/index.mjs.map +1 -1
  20. package/dist/runtime.d.ts +20 -0
  21. package/dist/runtime.d.ts.map +1 -1
  22. package/dist/server-bridge.d.ts +2 -0
  23. package/dist/server-bridge.d.ts.map +1 -1
  24. package/dist/shims/crypto.d.ts +2 -0
  25. package/dist/shims/crypto.d.ts.map +1 -1
  26. package/dist/shims/esbuild.d.ts.map +1 -1
  27. package/dist/shims/fs.d.ts.map +1 -1
  28. package/dist/shims/http.d.ts +29 -0
  29. package/dist/shims/http.d.ts.map +1 -1
  30. package/dist/shims/path.d.ts.map +1 -1
  31. package/dist/shims/stream.d.ts.map +1 -1
  32. package/dist/shims/vfs-adapter.d.ts.map +1 -1
  33. package/dist/shims/ws.d.ts +2 -0
  34. package/dist/shims/ws.d.ts.map +1 -1
  35. package/dist/utils/binary-encoding.d.ts +13 -0
  36. package/dist/utils/binary-encoding.d.ts.map +1 -0
  37. package/dist/virtual-fs.d.ts.map +1 -1
  38. package/package.json +4 -4
  39. package/src/convex-app-demo-entry.ts +229 -35
  40. package/src/frameworks/code-transforms.ts +5 -1
  41. package/src/frameworks/next-config-parser.ts +140 -0
  42. package/src/frameworks/next-dev-server.ts +76 -1675
  43. package/src/frameworks/next-html-generator.ts +597 -0
  44. package/src/frameworks/next-shims.ts +1050 -0
  45. package/src/frameworks/tailwind-config-loader.ts +1 -1
  46. package/src/index.ts +2 -0
  47. package/src/runtime.ts +94 -15
  48. package/src/server-bridge.ts +61 -28
  49. package/src/shims/crypto.ts +13 -0
  50. package/src/shims/esbuild.ts +4 -1
  51. package/src/shims/fs.ts +9 -11
  52. package/src/shims/http.ts +309 -3
  53. package/src/shims/path.ts +6 -13
  54. package/src/shims/stream.ts +12 -26
  55. package/src/shims/vfs-adapter.ts +5 -2
  56. package/src/shims/ws.ts +92 -2
  57. package/src/utils/binary-encoding.ts +43 -0
  58. package/src/virtual-fs.ts +7 -15
  59. 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
- let binary = '';
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 = [...snapshot.files].sort((a, b) => {
203
- const aDepth = a.path.split('/').length;
204
- const bDepth = b.path.split('/').length;
205
- return aDepth - bDepth;
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
- const binary = atob(entry.content);
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
  }