{"_id":"@aziontech/unenv-preset","_rev":"3-cf03435c770427bf2416e75b1671f5f9","name":"@aziontech/unenv-preset","dist-tags":{"latest":"1.0.2"},"versions":{"1.0.0":{"name":"@aziontech/unenv-preset","version":"1.0.0","author":{"name":"aziontech"},"license":"MIT","_id":"@aziontech/unenv-preset@1.0.0","maintainers":[{"name":"aziontechadmin","email":"services@azion.com"}],"homepage":"https://github.com/aziontech/lib#readme","bugs":{"url":"https://github.com/aziontech/lib/issues"},"dist":{"shasum":"648f2b1759580b7de76ae8d4e3299c557d76095c","tarball":"https://registry.npmjs.org/@aziontech/unenv-preset/-/unenv-preset-1.0.0.tgz","fileCount":26,"integrity":"sha512-MtJjqbpspM3fYjJk3Kc05ge76T+AGxM5Q5AlehgBC2u8zdl0idpTJRUh7UCrCxNDuND+A/ZHBnu/oGenRdSUzg==","signatures":[{"sig":"MEUCIECfLOiW/4BJfQo7BHpGQJs6Dr9Ep8dj9B9AOltVDieGAiEA9Ocosz7ymwi8w5vjTw4X5Fa0FUiDUYS0ivQPNhkvBEk=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":52366},"main":"./dist/index.cjs","_from":"file:aziontech-unenv-preset-1.0.0.tgz","types":"./dist/index.d.ts","module":"./dist/index.mjs","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.mjs","require":"./dist/index.cjs"},"./polyfills/*":"./src/polyfills/*"},"scripts":{"lint":"eslint .","compile":"vite build","lint:fix":"eslint --fix .","prettier":"prettier --write ."},"_npmUser":{"name":"aziontechadmin","email":"services@azion.com"},"_resolved":"/tmp/f5041d8d966e8221fbcdf15159c1041f/aziontech-unenv-preset-1.0.0.tgz","_integrity":"sha512-MtJjqbpspM3fYjJk3Kc05ge76T+AGxM5Q5AlehgBC2u8zdl0idpTJRUh7UCrCxNDuND+A/ZHBnu/oGenRdSUzg==","repository":{"url":"git+https://github.com/aziontech/lib.git","type":"git","directory":"packages/unenv-preset"},"_npmVersion":"10.9.4","description":"Azion Unenv preset.","directories":{},"_nodeVersion":"22.21.1","dependencies":{"url":"^0.11.4","unenv":"^2.0.0-rc.15","accepts":"^1.3.8","base64-js":"^1.5.1","string_decoder":"^1.3.0","browserify-zlib":"^0.2.0","assert-browserify":"^2.0.0","crypto-browserify":"^3.12.1","timers-browserify":"^2.0.12"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^29.7.0","ts-jest":"^29.1.5","@types/node":"^22.13.1","@aziontech/vite-config":"^0.0.0"},"_npmOperationalInternal":{"tmp":"tmp/unenv-preset_1.0.0_1776984619670_0.14770587887800746","host":"s3://npm-registry-packages-npm-production"}},"1.0.1":{"name":"@aziontech/unenv-preset","version":"1.0.1","author":{"name":"aziontech"},"license":"MIT","_id":"@aziontech/unenv-preset@1.0.1","maintainers":[{"name":"aziontechadmin","email":"services@azion.com"}],"homepage":"https://github.com/aziontech/lib#readme","bugs":{"url":"https://github.com/aziontech/lib/issues"},"dist":{"shasum":"1ffa7325b7e25ead79c6fc4cbb227a3ba4227e26","tarball":"https://registry.npmjs.org/@aziontech/unenv-preset/-/unenv-preset-1.0.1.tgz","fileCount":27,"integrity":"sha512-O+mLDxR+syXxEbBll01dJao7Hd0xzdpva/GW0Z7lSn4I7k5Zd01YAJZKrMK2GAGFqG56EoDEKzfzoA7GPqDt6g==","signatures":[{"sig":"MEUCIQCct5lli3cfx+KUXkj6UaSz1tkqBVwkPYS+MoaFbnt25gIgNoj0k9mUnUkbnPQif3L+m8ZIu0m5CDQT7yteh3IsD8k=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@aziontech%2funenv-preset@1.0.1","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":52660},"main":"./dist/index.cjs","_from":"file:aziontech-unenv-preset-1.0.1.tgz","types":"./dist/index.d.ts","module":"./dist/index.mjs","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.mjs","require":"./dist/index.cjs"},"./polyfills/*":"./src/polyfills/*"},"scripts":{"lint":"eslint .","compile":"vite build","lint:fix":"eslint --fix .","prettier":"prettier --write ."},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:f6d0c8cc-08fc-47f3-932f-a6b63fc5853d"}},"_resolved":"/tmp/ac0e302ca2bac7f0806ca1c48419183a/aziontech-unenv-preset-1.0.1.tgz","_integrity":"sha512-O+mLDxR+syXxEbBll01dJao7Hd0xzdpva/GW0Z7lSn4I7k5Zd01YAJZKrMK2GAGFqG56EoDEKzfzoA7GPqDt6g==","repository":{"url":"git+https://github.com/aziontech/lib.git","type":"git","directory":"packages/unenv-preset"},"_npmVersion":"11.13.0","description":"Azion Unenv preset.","directories":{},"_nodeVersion":"24.16.0","dependencies":{"url":"^0.11.4","unenv":"^2.0.0-rc.15","accepts":"^1.3.8","base64-js":"^1.5.1","string_decoder":"^1.3.0","browserify-zlib":"^0.2.0","assert-browserify":"^2.0.0","crypto-browserify":"^3.12.1","timers-browserify":"^2.0.12"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^29.7.0","ts-jest":"^29.1.5","@types/node":"^22.13.1","@aziontech/vite-config":"^0.0.0"},"_npmOperationalInternal":{"tmp":"tmp/unenv-preset_1.0.1_1780668982773_0.16731798951310517","host":"s3://npm-registry-packages-npm-production"}},"1.0.2":{"name":"@aziontech/unenv-preset","version":"1.0.2","description":"Azion Unenv preset.","main":"./dist/index.cjs","module":"./dist/index.mjs","types":"./dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","require":"./dist/index.cjs","import":"./dist/index.mjs"},"./polyfills/*":"./src/polyfills/*"},"author":{"name":"aziontech"},"license":"MIT","dependencies":{"accepts":"^1.3.8","assert-browserify":"^2.0.0","browserify-zlib":"^0.2.0","base64-js":"^1.5.1","string_decoder":"^1.3.0","timers-browserify":"^2.0.12","unenv":"^2.0.0-rc.15","url":"^0.11.4"},"devDependencies":{"@types/node":"^22.13.1","jest":"^30.4.2","ts-jest":"^29.1.5","@aziontech/vite-config":"^0.0.0"},"repository":{"type":"git","url":"git+https://github.com/aziontech/lib.git","directory":"packages/unenv-preset"},"scripts":{"compile":"vite build","lint":"eslint .","lint:fix":"eslint --fix .","prettier":"prettier --write ."},"_id":"@aziontech/unenv-preset@1.0.2","bugs":{"url":"https://github.com/aziontech/lib/issues"},"homepage":"https://github.com/aziontech/lib#readme","_integrity":"sha512-fF4zWLz3r1EXu5A0qy1oH8C9dB/5XwmF7fxCcrt7OsZrJYpDq8fvEaNmQsOfswo5hfG20ip5DALuYYe9aUm4iQ==","_resolved":"/tmp/cf542dfe22f9a4593f007ae0b402bb2d/aziontech-unenv-preset-1.0.2.tgz","_from":"file:aziontech-unenv-preset-1.0.2.tgz","_nodeVersion":"24.18.0","_npmVersion":"11.16.0","dist":{"integrity":"sha512-fF4zWLz3r1EXu5A0qy1oH8C9dB/5XwmF7fxCcrt7OsZrJYpDq8fvEaNmQsOfswo5hfG20ip5DALuYYe9aUm4iQ==","shasum":"b6f816c6b3dcfbe09e6abec8233d1b1b13345cf6","tarball":"https://registry.npmjs.org/@aziontech/unenv-preset/-/unenv-preset-1.0.2.tgz","fileCount":26,"unpackedSize":50023,"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@aziontech%2funenv-preset@1.0.2","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIHa2zHybOsBONYVlRzmg95HOBQVhzD5wYcFmgzrvcxV0AiBJC2ywzuYa39ICFosXnbs8iYPXtstq9J0fVyDmMf5ghw=="}]},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:f6d0c8cc-08fc-47f3-932f-a6b63fc5853d"}},"directories":{},"maintainers":[{"name":"aziontechadmin","email":"services@azion.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/unenv-preset_1.0.2_1783518916760_0.40205746273612464"},"_hasShrinkwrap":false}},"time":{"created":"2026-04-23T22:50:19.565Z","modified":"2026-07-08T13:55:17.161Z","1.0.0":"2026-04-23T22:50:19.807Z","1.0.1":"2026-06-05T14:16:22.918Z","1.0.2":"2026-07-08T13:55:16.907Z"},"bugs":{"url":"https://github.com/aziontech/lib/issues"},"author":{"name":"aziontech"},"license":"MIT","homepage":"https://github.com/aziontech/lib#readme","repository":{"type":"git","url":"git+https://github.com/aziontech/lib.git","directory":"packages/unenv-preset"},"description":"Azion Unenv preset.","maintainers":[{"name":"aziontechadmin","email":"services@azion.com"}],"readme":"# Azion Unenv Preset\n\nA preset configuration for unenv that provides polyfills and environment compatibility for Azion Edge Runtime.\n\n## Table of Contents\n\n- [Installation](#installation)\n- [Usage](#usage)\n- [Features](#features)\n  - [Node.js Polyfills](#nodejs-polyfills)\n  - [File System Polyfills](#file-system-polyfills)\n- [API Reference](#api-reference)\n  - [getFileContent](#getfilecontent)\n  - [closeSync](#closesync)\n  - [openSync](#opensync)\n  - [statSync](#statsync)\n  - [readFileSync](#readfilesync)\n  - [readdirSync](#readdirsync)\n- [Contributing](#contributing)\n\n## Installation\n\nInstall the package using npm or yarn:\n\n```bash\nnpm install azion\n```\n\nor\n\n```bash\nyarn add azion\n```\n\n## Usage\n\nThe preset can be used with unenv to provide compatibility between Node.js and Azion Edge Runtime environments:\n\n```javascript\nimport { preset } from '@aziontech/unenv-preset';\n// Use with unenv\nexport default {\n  preset: preset,\n};\n```\n\n## Features\n\n### Node.js Polyfills\n\nThis preset provides polyfills for common Node.js APIs to ensure compatibility when running code in the Azion Edge Runtime environment. The following modules are polyfilled:\n\n- `crypto` - Complete cryptographic functionality including hashing, encryption, and UUID generation\n- `events` - Event handling through events/events.js\n- `http` - HTTP client functionality via stream-http\n- `module` - Basic module system compatibility (limited functionality)\n- `stream` - Stream implementations via stream-browserify\n- `string_decoder` - String decoding utilities\n- `url` - URL parsing and formatting\n- `util` - Utility functions\n- `timers` - Timer functions via timers-browserify\n- `vm` - Virtual Machine functionality via vm-browserify\n- `zlib` - Compression functionality via browserify-zlib\n\nExample using crypto polyfill:\n\n```javascript\nimport { createHash, randomUUID } from '@aziontech/unenv-preset/polyfills/node/crypto';\n\n// Create a hash\nconst hash = createHash('sha256');\nhash.update('some data');\nconsole.log(hash.digest('hex'));\n\n// Generate a UUID\nconst uuid = randomUUID();\n```\n\n### File System Polyfills\n\nThe preset includes comprehensive file system polyfills that mirror Node.js's `fs` module functionality. These polyfills work with an in-memory file system when running in the Edge Runtime.\n\n#### Basic File Operations\n\n```javascript\nimport { readFileSync, writeFileSync } from '@aziontech/unenv-preset/polyfills/node/fs';\n\n// Read a file\nconst content = readFileSync('/path/to/file.txt', 'utf8');\n\n// Write to a file\nwriteFileSync('/path/to/new-file.txt', 'Hello World', 'utf8');\n```\n\n#### Directory Operations\n\n```javascript\nimport { readdirSync, mkdirSync } from '@aziontech/unenv-preset/polyfills/node/fs';\n\n// List directory contents\nconst files = readdirSync('/path/to/dir');\n\n// Create a directory\nmkdirSync('/path/to/new-dir');\n```\n\n#### File Stats and Information\n\n```javascript\nimport { statSync, existsSync } from '@aziontech/unenv-preset/polyfills/node/fs';\n\n// Check if file exists\nif (existsSync('/path/to/file.txt')) {\n  // Get file stats\n  const stats = statSync('/path/to/file.txt');\n  console.log(`File size: ${stats.size}`);\n  console.log(`Is directory: ${stats.isDirectory()}`);\n  console.log(`Is file: ${stats.isFile()}`);\n}\n```\n\n#### File Descriptors\n\n```javascript\nimport { openSync, closeSync, readSync } from '@aziontech/unenv-preset/polyfills/node/fs';\n\n// Open file and get file descriptor\nconst fd = openSync('/path/to/file.txt', 'r');\n\n// Read from file descriptor\nconst buffer = Buffer.alloc(1024);\nreadSync(fd, buffer, 0, 1024, 0);\n\n// Close file descriptor\ncloseSync(fd);\n```\n\n### Global Polyfills\n\nThe preset also provides polyfills for Node.js global variables and objects:\n\n- `__dirname` - Current directory name\n- `__filename` - Current file name\n- `process` - Process information and environment (including env variables)\n- `performance` - Performance timing functionality\n- `navigator` - Browser-compatible navigator object\n\nThe preset also handles injection of these globals through the unenv configuration:\n\n```javascript\nimport { preset } from '@aziontech/unenv-preset';\n\n// Preset configuration automatically injects globals\nexport default {\n  inject: {\n    __dirname: preset.inject.__dirname,\n    __filename: preset.inject.__filename,\n    process: preset.inject.process,\n    performance: preset.inject.performance,\n    navigator: preset.inject.navigator,\n  },\n};\n```\n\n## API Reference\n\n### getFileContent\n\nDecodes file content and returns it as either a Buffer or string.\n\n**Parameters:**\n\n- `file` - The file object containing content in base64 format\n- `returnBuffer` - (Optional) Boolean to determine return type (default: true)\n  - `true` returns Buffer\n  - `false` returns string\n\n**Returns:**\n\n- `Buffer | string` - The decoded file content\n\n**Example:**\n\n```javascript\nconst fileBuffer = getFileContent(file); // returns Buffer\nconst fileString = getFileContent(file, false); // returns string\n```\n\n### closeSync\n\nSynchronously closes the file descriptor.\n\n**Parameters:**\n\n- `fd` - The file descriptor to close.\n\n**Example:**\n\n```javascript\ncloseSync(fd);\n```\n\n### openSync\n\nSynchronously opens a file.\n\n**Parameters:**\n\n- `path` - The path to the file.\n- `flags` - The opening mode (e.g., 'r', 'w').\n- `mode` - (Optional) The file mode.\n\n**Returns:**\n\n- `number` - The file descriptor.\n\n**Example:**\n\n```javascript\nconst fd = openSync('/path/to/file.txt', 'r');\n```\n\n### statSync\n\nSynchronously retrieves the `fs.Stats` for the specified path.\n\n**Parameters:**\n\n- `path` - The path to the file or directory.\n- `options` - (Optional) Options for the stat call.\n\n**Returns:**\n\n- `fs.Stats` - The stats object for the file or directory.\n\n**Example:**\n\n```javascript\nconst stats = statSync('/path/to/file.txt');\n```\n\n### readFileSync\n\nSynchronously reads the entire contents of a file.\n\n**Parameters:**\n\n- `path` - The path to the file.\n- `options` - (Optional) Options for reading the file.\n\n**Returns:**\n\n- `string | Buffer` - The contents of the file.\n\n**Example:**\n\n```javascript\nconst content = readFileSync('/path/to/file.txt', 'utf8');\n```\n\n### readdirSync\n\nSynchronously reads the contents of a directory.\n\n**Parameters:**\n\n- `path` - The path to the directory.\n- `options` - (Optional) Options for reading the directory.\n\n**Returns:**\n\n- `string[]` - An array of file names in the directory.\n\n**Example:**\n\n```javascript\nconst files = readdirSync('/path/to/dir');\n```\n\n## Contributing\n\nContributions are welcome! Please read our contributing guidelines for details on our code of conduct and the process for submitting pull requests.\n","readmeFilename":"README.md"}