@slopware/sloppy-darwin-arm64 0.1.0-alpha.0
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/LICENSE +201 -0
- package/README.md +5 -0
- package/bin/sloppy +0 -0
- package/bin/sloppyc +0 -0
- package/docs/KNOWN_LIMITATIONS.md +16 -0
- package/docs/LICENSES.md +6 -0
- package/docs/NOTICE.md +8 -0
- package/examples/README.md +140 -0
- package/examples/auth-api/README.md +20 -0
- package/examples/auth-api/app.js +61 -0
- package/examples/auth-api/appsettings.json +7 -0
- package/examples/auth-api/sloppy.json +5 -0
- package/examples/cache-basic/README.md +9 -0
- package/examples/cache-basic/app.js +32 -0
- package/examples/cache-hybrid-postgres/README.md +10 -0
- package/examples/cache-hybrid-postgres/app.js +27 -0
- package/examples/cache-output-api/README.md +10 -0
- package/examples/cache-output-api/app.js +35 -0
- package/examples/codec-base64-hex/README.md +14 -0
- package/examples/codec-base64-hex/app.js +15 -0
- package/examples/codec-checksums/README.md +15 -0
- package/examples/codec-checksums/app.js +8 -0
- package/examples/codec-compression/README.md +13 -0
- package/examples/codec-compression/app.js +9 -0
- package/examples/codec-streaming-compression/README.md +19 -0
- package/examples/codec-streaming-compression/app.js +16 -0
- package/examples/codec-text-binary/README.md +16 -0
- package/examples/codec-text-binary/app.js +17 -0
- package/examples/compiler-hello/README.md +71 -0
- package/examples/compiler-hello/app.js +7 -0
- package/examples/compiler-hello/expected/app.js +8 -0
- package/examples/compiler-hello/expected/app.js.map +53 -0
- package/examples/compiler-hello/expected/app.plan.json +229 -0
- package/examples/compiler-hello/expected/routes.slrt +0 -0
- package/examples/config-basic/README.md +13 -0
- package/examples/config-basic/app.js +13 -0
- package/examples/config-basic/appsettings.json +7 -0
- package/examples/config-secrets-redaction/README.md +9 -0
- package/examples/config-secrets-redaction/app.js +9 -0
- package/examples/config-secrets-redaction/appsettings.json +5 -0
- package/examples/config-strict-mode/README.md +7 -0
- package/examples/config-strict-mode/app.js +10 -0
- package/examples/config-strict-mode/appsettings.json +7 -0
- package/examples/configured-api/README.md +38 -0
- package/examples/configured-api/app.js +12 -0
- package/examples/configured-api/appsettings.Development.json +5 -0
- package/examples/configured-api/appsettings.json +6 -0
- package/examples/configured-api/sloppy.json +5 -0
- package/examples/core-config-secrets/README.md +10 -0
- package/examples/core-config-secrets/app.js +15 -0
- package/examples/core-fs-time-codec/README.md +9 -0
- package/examples/core-fs-time-codec/app.js +8 -0
- package/examples/core-network-time-codec/README.md +11 -0
- package/examples/core-network-time-codec/app.js +20 -0
- package/examples/core-policy-audit/README.md +7 -0
- package/examples/core-policy-audit/app.js +22 -0
- package/examples/core-process-time-codec/README.md +8 -0
- package/examples/core-process-time-codec/app.js +28 -0
- package/examples/core-worker-time/README.md +8 -0
- package/examples/core-worker-time/app.js +17 -0
- package/examples/crypto-hash-hmac/README.md +17 -0
- package/examples/crypto-hash-hmac/app.js +29 -0
- package/examples/crypto-password/README.md +21 -0
- package/examples/crypto-password/app.js +12 -0
- package/examples/crypto-random-token/README.md +16 -0
- package/examples/crypto-random-token/app.js +12 -0
- package/examples/crypto-secret-constant-time/README.md +21 -0
- package/examples/crypto-secret-constant-time/app.js +15 -0
- package/examples/data-foundation/README.md +39 -0
- package/examples/data-foundation/app.js +63 -0
- package/examples/dependency-graph/README.md +19 -0
- package/examples/dependency-graph/fixtures/graph-helper/index.js +3 -0
- package/examples/dependency-graph/fixtures/graph-helper/package.json +6 -0
- package/examples/dependency-graph/package.json +7 -0
- package/examples/dependency-graph/public/message.txt +1 -0
- package/examples/dependency-graph/sloppy.json +9 -0
- package/examples/dependency-graph/src/main.ts +8 -0
- package/examples/dogfood/README.md +23 -0
- package/examples/dogfood/dogfood.json +136 -0
- package/examples/dynamic-module-include/README.md +20 -0
- package/examples/dynamic-module-include/public/readme.txt +1 -0
- package/examples/dynamic-module-include/sloppy.json +12 -0
- package/examples/dynamic-module-include/src/main.ts +6 -0
- package/examples/dynamic-module-include/src/plugins/alpha.js +3 -0
- package/examples/dynamic-module-include/src/plugins/beta.js +3 -0
- package/examples/ergonomics/README.md +42 -0
- package/examples/ergonomics/app.js +38 -0
- package/examples/framework-controller/README.md +12 -0
- package/examples/framework-controller/app.js +31 -0
- package/examples/framework-di-services/README.md +17 -0
- package/examples/framework-di-services/app.ts +40 -0
- package/examples/framework-explicit-binding/README.md +12 -0
- package/examples/framework-explicit-binding/app.ts +34 -0
- package/examples/framework-hello/README.md +16 -0
- package/examples/framework-hello/app.ts +16 -0
- package/examples/framework-postgres-crud/README.md +73 -0
- package/examples/framework-postgres-crud/app.ts +64 -0
- package/examples/framework-sqlite-crud/README.md +52 -0
- package/examples/framework-sqlite-crud/app.ts +90 -0
- package/examples/framework-sqlite-crud/appsettings.json +11 -0
- package/examples/framework-sqlserver-crud/README.md +73 -0
- package/examples/framework-sqlserver-crud/app.ts +64 -0
- package/examples/framework-validation-errors/README.md +12 -0
- package/examples/framework-validation-errors/app.ts +16 -0
- package/examples/fs-basic/README.md +24 -0
- package/examples/fs-basic/app.js +12 -0
- package/examples/fs-roots-policy/README.md +14 -0
- package/examples/fs-roots-policy/app.js +4 -0
- package/examples/fs-streams/README.md +18 -0
- package/examples/fs-streams/app.js +11 -0
- package/examples/fs-watch/README.md +19 -0
- package/examples/fs-watch/app.js +11 -0
- package/examples/hello/README.md +63 -0
- package/examples/hello/app.js +19 -0
- package/examples/hello-minimal/README.md +51 -0
- package/examples/hello-minimal/sloppy.json +5 -0
- package/examples/hello-minimal/src/main.ts +9 -0
- package/examples/http-client-basic/README.md +11 -0
- package/examples/http-client-basic/app.js +46 -0
- package/examples/http-client-generated/README.md +22 -0
- package/examples/http-client-generated/openapi.json +45 -0
- package/examples/http-client-resilience/README.md +4 -0
- package/examples/http-client-resilience/app.js +38 -0
- package/examples/http-client-runtime-loopback/README.md +24 -0
- package/examples/http-client-testhost/README.md +4 -0
- package/examples/http-client-testhost/app.js +27 -0
- package/examples/http-client-testhost-package-mock/README.md +26 -0
- package/examples/http-client-typed/README.md +5 -0
- package/examples/http-client-typed/app.js +33 -0
- package/examples/modules-api/README.md +30 -0
- package/examples/modules-api/app.js +9 -0
- package/examples/modules-api/modules/routes.js +16 -0
- package/examples/modules-api/sloppy.json +5 -0
- package/examples/modules-basic/README.md +32 -0
- package/examples/modules-basic/app.js +41 -0
- package/examples/net-deadline-cancel/README.md +13 -0
- package/examples/net-deadline-cancel/app.js +34 -0
- package/examples/net-local-ipc/README.md +12 -0
- package/examples/net-local-ipc/app.js +46 -0
- package/examples/net-policy-strict/README.md +12 -0
- package/examples/net-policy-strict/app.js +34 -0
- package/examples/net-tcp-client/README.md +10 -0
- package/examples/net-tcp-client/app.js +23 -0
- package/examples/net-tcp-echo/README.md +11 -0
- package/examples/net-tcp-echo/app.js +45 -0
- package/examples/net-tcp-server/README.md +10 -0
- package/examples/net-tcp-server/app.js +28 -0
- package/examples/node-compat-path-events/README.md +15 -0
- package/examples/node-compat-path-events/sloppy.json +6 -0
- package/examples/node-compat-path-events/src/main.ts +15 -0
- package/examples/ops-compiler/README.md +9 -0
- package/examples/ops-compiler/app.js +26 -0
- package/examples/ops-health-metrics-management/README.md +14 -0
- package/examples/ops-health-metrics-management/app.js +24 -0
- package/examples/orm-basic/README.md +17 -0
- package/examples/orm-basic/app.js +82 -0
- package/examples/orm-cursor-export/README.md +16 -0
- package/examples/orm-cursor-export/app.js +28 -0
- package/examples/orm-migrations/README.md +14 -0
- package/examples/orm-migrations/migrations/.gitkeep +1 -0
- package/examples/orm-migrations/sloppy.json +9 -0
- package/examples/orm-migrations/src/app.ts +34 -0
- package/examples/orm-relations-includes/README.md +10 -0
- package/examples/orm-relations-includes/app.js +47 -0
- package/examples/orm-testservices/README.md +37 -0
- package/examples/orm-testservices/test.mjs +32 -0
- package/examples/os-runtime-api/README.md +11 -0
- package/examples/os-runtime-api/app.js +44 -0
- package/examples/package-zod-like/README.md +28 -0
- package/examples/package-zod-like/fixtures/zod-like/index.js +48 -0
- package/examples/package-zod-like/fixtures/zod-like/package.json +12 -0
- package/examples/package-zod-like/package.json +7 -0
- package/examples/package-zod-like/sloppy.json +6 -0
- package/examples/package-zod-like/src/main.ts +16 -0
- package/examples/postgres-basic/README.md +31 -0
- package/examples/postgres-basic/app.js +50 -0
- package/examples/prealpha-control-plane/README.md +50 -0
- package/examples/prealpha-control-plane/appsettings.Development.json +11 -0
- package/examples/prealpha-control-plane/appsettings.json +15 -0
- package/examples/prealpha-control-plane/sloppy.json +5 -0
- package/examples/prealpha-control-plane/src/db/schema.js +7 -0
- package/examples/prealpha-control-plane/src/db/seed.js +6 -0
- package/examples/prealpha-control-plane/src/main.js +21 -0
- package/examples/prealpha-control-plane/src/routes/apps.js +34 -0
- package/examples/prealpha-control-plane/src/routes/builds.js +25 -0
- package/examples/prealpha-control-plane/src/routes/deployments.js +19 -0
- package/examples/prealpha-control-plane/src/routes/diagnostics.js +11 -0
- package/examples/prealpha-control-plane/src/routes/health.js +27 -0
- package/examples/prealpha-control-plane/src/routes/projects.js +38 -0
- package/examples/prealpha-control-plane/src/services/diagnosticsSink.js +11 -0
- package/examples/prealpha-control-plane/src/services/repositories.js +9 -0
- package/examples/prealpha-control-plane/src/validation/schemas.js +6 -0
- package/examples/program-fs-process/README.md +31 -0
- package/examples/program-fs-process/sloppy.json +9 -0
- package/examples/program-fs-process/src/main.ts +27 -0
- package/examples/program-hello/README.md +32 -0
- package/examples/program-hello/main.ts +8 -0
- package/examples/program-hello/message.ts +1 -0
- package/examples/program-hello/sloppy.json +5 -0
- package/examples/rate-limit-auth/README.md +3 -0
- package/examples/rate-limit-auth/app.js +14 -0
- package/examples/rate-limit-basic/README.md +3 -0
- package/examples/rate-limit-basic/app.js +13 -0
- package/examples/rate-limit-redis/README.md +5 -0
- package/examples/rate-limit-redis/app.js +20 -0
- package/examples/rate-limit-testhost/README.md +4 -0
- package/examples/rate-limit-testhost/app.js +13 -0
- package/examples/rate-limit-websocket/README.md +3 -0
- package/examples/rate-limit-websocket/app.js +16 -0
- package/examples/realtime-auth/README.md +8 -0
- package/examples/realtime-auth/app.js +25 -0
- package/examples/realtime-auth/test.mjs +43 -0
- package/examples/realtime-chat/README.md +8 -0
- package/examples/realtime-chat/app.js +32 -0
- package/examples/realtime-chat/test.mjs +52 -0
- package/examples/realtime-dashboard/README.md +20 -0
- package/examples/realtime-dashboard/app.js +37 -0
- package/examples/realtime-presence/README.md +8 -0
- package/examples/realtime-presence/app.js +32 -0
- package/examples/realtime-presence/test.mjs +50 -0
- package/examples/realtime-testhost/README.md +8 -0
- package/examples/realtime-testhost/test.mjs +31 -0
- package/examples/redis-basic/README.md +17 -0
- package/examples/redis-basic/app.js +39 -0
- package/examples/redis-cache/README.md +14 -0
- package/examples/redis-cache/app.js +36 -0
- package/examples/redis-locks/README.md +13 -0
- package/examples/redis-locks/app.js +49 -0
- package/examples/request-context/README.md +32 -0
- package/examples/request-context/app.js +15 -0
- package/examples/sqlite-basic/README.md +52 -0
- package/examples/sqlite-basic/app.js +56 -0
- package/examples/sqlserver-basic/README.md +36 -0
- package/examples/sqlserver-basic/app.js +59 -0
- package/examples/static-files-basic/README.md +11 -0
- package/examples/static-files-basic/app.js +12 -0
- package/examples/static-files-basic/public/app.js +1 -0
- package/examples/static-files-basic/public/site.css +3 -0
- package/examples/static-files-package/README.md +12 -0
- package/examples/static-files-package/app.js +10 -0
- package/examples/static-files-package/public/index.html +2 -0
- package/examples/static-files-precompressed/README.md +12 -0
- package/examples/static-files-precompressed/app.js +11 -0
- package/examples/static-files-precompressed/public/app.js +1 -0
- package/examples/static-files-precompressed/public/app.js.br +0 -0
- package/examples/static-files-precompressed/public/app.js.gz +0 -0
- package/examples/static-files-spa/README.md +12 -0
- package/examples/static-files-spa/app.js +16 -0
- package/examples/static-files-spa/dist/assets/app.js +1 -0
- package/examples/static-files-spa/dist/index.html +4 -0
- package/examples/static-files-testhost/README.md +8 -0
- package/examples/static-files-testhost/app.js +13 -0
- package/examples/static-files-testhost/public/app.js +1 -0
- package/examples/static-files-testhost/public/app.js.gz +0 -0
- package/examples/static-files-testhost/test.mjs +38 -0
- package/examples/testhost-basic/README.md +26 -0
- package/examples/testhost-db/README.md +31 -0
- package/examples/testservices-postgres/README.md +68 -0
- package/examples/testservices-redis/README.md +71 -0
- package/examples/testservices-sqlserver/README.md +75 -0
- package/examples/time-basic/README.md +18 -0
- package/examples/time-basic/app.js +12 -0
- package/examples/time-deadline-cancellation/README.md +11 -0
- package/examples/time-deadline-cancellation/app.js +27 -0
- package/examples/time-fake-clock/README.md +14 -0
- package/examples/time-fake-clock/app.js +25 -0
- package/examples/time-interval-schedule/README.md +13 -0
- package/examples/time-interval-schedule/app.js +60 -0
- package/examples/users-api-sqlite/README.md +74 -0
- package/examples/users-api-sqlite/app.js +11 -0
- package/examples/users-api-sqlite/appsettings.Development.json +11 -0
- package/examples/users-api-sqlite/appsettings.json +11 -0
- package/examples/users-api-sqlite/modules/users.js +40 -0
- package/examples/users-api-sqlite/sloppy.json +5 -0
- package/examples/validation-errors/README.md +36 -0
- package/examples/validation-errors/app.js +14 -0
- package/examples/validation-errors/invalid-user.http +6 -0
- package/examples/validation-errors/sloppy.json +5 -0
- package/examples/web-dynamic-routes/README.md +17 -0
- package/examples/web-dynamic-routes/app.ts +27 -0
- package/examples/webhooks-basic/README.md +11 -0
- package/examples/webhooks-basic/app.js +48 -0
- package/examples/websocket-auth/README.md +8 -0
- package/examples/websocket-auth/app.js +16 -0
- package/examples/websocket-echo/README.md +9 -0
- package/examples/websocket-echo/app.js +36 -0
- package/examples/websocket-json-schema/README.md +5 -0
- package/examples/websocket-json-schema/app.js +25 -0
- package/examples/websocket-testhost/README.md +11 -0
- package/examples/websocket-testhost/test.mjs +49 -0
- package/examples/workers-background-service/README.md +7 -0
- package/examples/workers-background-service/app.js +16 -0
- package/examples/workers-js-isolate/README.md +8 -0
- package/examples/workers-js-isolate/app.js +19 -0
- package/examples/workers-js-isolate/workers/parser.ts +11 -0
- package/examples/workers-shutdown/README.md +6 -0
- package/examples/workers-shutdown/app.js +26 -0
- package/examples/workers-workerpool/README.md +6 -0
- package/examples/workers-workerpool/app.js +23 -0
- package/examples/workers-workqueue/README.md +8 -0
- package/examples/workers-workqueue/app.js +24 -0
- package/manifest.json +59 -0
- package/package.json +31 -0
- package/stdlib/sloppy/README.md +177 -0
- package/stdlib/sloppy/app.js +2142 -0
- package/stdlib/sloppy/auth.js +1813 -0
- package/stdlib/sloppy/bootstrap.manifest.json +83 -0
- package/stdlib/sloppy/cache.js +1542 -0
- package/stdlib/sloppy/codec.js +1153 -0
- package/stdlib/sloppy/config.js +61 -0
- package/stdlib/sloppy/crypto.js +312 -0
- package/stdlib/sloppy/data.js +2945 -0
- package/stdlib/sloppy/ffi.js +185 -0
- package/stdlib/sloppy/fs.js +795 -0
- package/stdlib/sloppy/health.js +603 -0
- package/stdlib/sloppy/http.js +1595 -0
- package/stdlib/sloppy/index.js +59 -0
- package/stdlib/sloppy/internal/bytes.js +31 -0
- package/stdlib/sloppy/internal/capabilities.js +155 -0
- package/stdlib/sloppy/internal/config.js +640 -0
- package/stdlib/sloppy/internal/disposable.js +31 -0
- package/stdlib/sloppy/internal/headers.js +63 -0
- package/stdlib/sloppy/internal/intrinsics.js +2 -0
- package/stdlib/sloppy/internal/json.js +20 -0
- package/stdlib/sloppy/internal/logging.js +278 -0
- package/stdlib/sloppy/internal/modules.js +405 -0
- package/stdlib/sloppy/internal/redaction.js +87 -0
- package/stdlib/sloppy/internal/routes.js +2279 -0
- package/stdlib/sloppy/internal/runtime-classic.js +19837 -0
- package/stdlib/sloppy/internal/services.js +690 -0
- package/stdlib/sloppy/internal/shared.js +32 -0
- package/stdlib/sloppy/internal/testhost-diagnostics.js +88 -0
- package/stdlib/sloppy/internal/testhost-http-server.js +238 -0
- package/stdlib/sloppy/internal/testhost-http.js +118 -0
- package/stdlib/sloppy/internal/testhost-loopback.js +50 -0
- package/stdlib/sloppy/internal/testservices-docker.js +154 -0
- package/stdlib/sloppy/internal/validation.js +117 -0
- package/stdlib/sloppy/metrics.js +427 -0
- package/stdlib/sloppy/net.js +5208 -0
- package/stdlib/sloppy/node/assert/strict.js +39 -0
- package/stdlib/sloppy/node/assert.js +228 -0
- package/stdlib/sloppy/node/buffer.js +247 -0
- package/stdlib/sloppy/node/console.js +33 -0
- package/stdlib/sloppy/node/constants.js +9 -0
- package/stdlib/sloppy/node/crypto.js +89 -0
- package/stdlib/sloppy/node/diagnostics_channel.js +41 -0
- package/stdlib/sloppy/node/events.js +113 -0
- package/stdlib/sloppy/node/fs/promises.js +27 -0
- package/stdlib/sloppy/node/fs.js +280 -0
- package/stdlib/sloppy/node/http.js +11 -0
- package/stdlib/sloppy/node/https.js +11 -0
- package/stdlib/sloppy/node/module.js +40 -0
- package/stdlib/sloppy/node/os.js +22 -0
- package/stdlib/sloppy/node/path.js +78 -0
- package/stdlib/sloppy/node/perf_hooks.js +12 -0
- package/stdlib/sloppy/node/process.js +129 -0
- package/stdlib/sloppy/node/querystring.js +21 -0
- package/stdlib/sloppy/node/stream/promises.js +3 -0
- package/stdlib/sloppy/node/stream.js +132 -0
- package/stdlib/sloppy/node/string_decoder.js +23 -0
- package/stdlib/sloppy/node/timers.js +26 -0
- package/stdlib/sloppy/node/tty.js +18 -0
- package/stdlib/sloppy/node/url.js +17 -0
- package/stdlib/sloppy/node/util.js +95 -0
- package/stdlib/sloppy/node/zlib.js +72 -0
- package/stdlib/sloppy/orm.js +2188 -0
- package/stdlib/sloppy/os.js +580 -0
- package/stdlib/sloppy/problem-details.js +29 -0
- package/stdlib/sloppy/providers/sqlite.js +26 -0
- package/stdlib/sloppy/rate-limit.js +856 -0
- package/stdlib/sloppy/realtime.js +1508 -0
- package/stdlib/sloppy/redis.js +1272 -0
- package/stdlib/sloppy/request-id.js +184 -0
- package/stdlib/sloppy/request-logging.js +101 -0
- package/stdlib/sloppy/results.js +933 -0
- package/stdlib/sloppy/schema.js +546 -0
- package/stdlib/sloppy/testing.js +4081 -0
- package/stdlib/sloppy/testservices.js +1041 -0
- package/stdlib/sloppy/time.js +894 -0
- package/stdlib/sloppy/webhooks.js +1330 -0
- package/stdlib/sloppy/workers.js +986 -0
- package/templates/api/README.md +82 -0
- package/templates/api/appsettings.Development.json +14 -0
- package/templates/api/appsettings.json +13 -0
- package/templates/api/data/.gitkeep +1 -0
- package/templates/api/gitignore +4 -0
- package/templates/api/migrations/0001_create_users.sql +1 -0
- package/templates/api/package.json +16 -0
- package/templates/api/public/hello.txt +1 -0
- package/templates/api/sloppy.json +14 -0
- package/templates/api/src/config.ts +1 -0
- package/templates/api/src/db/migrate.ts +14 -0
- package/templates/api/src/db/schema.ts +4 -0
- package/templates/api/src/db/usersRepository.ts +23 -0
- package/templates/api/src/main.ts +18 -0
- package/templates/api/src/models/user.ts +7 -0
- package/templates/api/src/routes/health.ts +20 -0
- package/templates/api/src/routes/users.ts +40 -0
- package/templates/api/src/services/usersService.ts +21 -0
- package/templates/api/tsconfig.json +15 -0
- package/templates/cli/README.md +16 -0
- package/templates/cli/gitignore +2 -0
- package/templates/cli/package.json +13 -0
- package/templates/cli/sloppy.json +6 -0
- package/templates/cli/src/commands/echo.ts +9 -0
- package/templates/cli/src/commands/inspect.ts +20 -0
- package/templates/cli/src/main.ts +50 -0
- package/templates/cli/tsconfig.json +15 -0
- package/templates/minimal-api/README.md +14 -0
- package/templates/minimal-api/gitignore +3 -0
- package/templates/minimal-api/package.json +14 -0
- package/templates/minimal-api/sloppy.json +5 -0
- package/templates/minimal-api/src/main.ts +9 -0
- package/templates/minimal-api/tsconfig.json +15 -0
- package/templates/node-compat/README.md +40 -0
- package/templates/node-compat/gitignore +2 -0
- package/templates/node-compat/package.json +11 -0
- package/templates/node-compat/sloppy.json +6 -0
- package/templates/node-compat/src/main.ts +40 -0
- package/templates/package-api/README.md +44 -0
- package/templates/package-api/fixtures/validator-lite/index.js +7 -0
- package/templates/package-api/fixtures/validator-lite/package.json +6 -0
- package/templates/package-api/gitignore +3 -0
- package/templates/package-api/package.json +17 -0
- package/templates/package-api/sloppy.json +5 -0
- package/templates/package-api/src/main.ts +10 -0
- package/templates/package-api/src/routes/health.ts +5 -0
- package/templates/package-api/src/routes/users.ts +12 -0
- package/templates/package-api/tsconfig.json +15 -0
- package/templates/program/README.md +12 -0
- package/templates/program/gitignore +1 -0
- package/templates/program/package.json +10 -0
- package/templates/program/sloppy.json +6 -0
- package/templates/program/src/main.ts +9 -0
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { Environment, Process } from "../os.js";
|
|
2
|
+
import { EventEmitter } from "./events.js";
|
|
3
|
+
|
|
4
|
+
const env = new Proxy(Object.create(null), {
|
|
5
|
+
get(target, key) {
|
|
6
|
+
if (typeof key !== "string") {
|
|
7
|
+
return undefined;
|
|
8
|
+
}
|
|
9
|
+
return Object.prototype.hasOwnProperty.call(target, key) ? target[key] : Environment.get(key);
|
|
10
|
+
},
|
|
11
|
+
has(target, key) {
|
|
12
|
+
return typeof key === "string" && (Object.prototype.hasOwnProperty.call(target, key) || Environment.has(key));
|
|
13
|
+
},
|
|
14
|
+
set(target, key, value) {
|
|
15
|
+
if (typeof key !== "string") {
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
18
|
+
target[key] = String(value);
|
|
19
|
+
return true;
|
|
20
|
+
},
|
|
21
|
+
ownKeys(target) {
|
|
22
|
+
return [...new Set([...Object.keys(target), ...(Environment.list?.() ?? [])])];
|
|
23
|
+
},
|
|
24
|
+
getOwnPropertyDescriptor(target, key) {
|
|
25
|
+
const value = typeof key === "string"
|
|
26
|
+
? (Object.prototype.hasOwnProperty.call(target, key) ? target[key] : Environment.get(key))
|
|
27
|
+
: undefined;
|
|
28
|
+
return value === undefined ? undefined : {
|
|
29
|
+
configurable: true,
|
|
30
|
+
enumerable: true,
|
|
31
|
+
value,
|
|
32
|
+
};
|
|
33
|
+
},
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
const monotonicMs = () => {
|
|
37
|
+
const bridge = globalThis.__sloppy?.time;
|
|
38
|
+
if (bridge && typeof bridge.monotonicMs === "function") {
|
|
39
|
+
return bridge.monotonicMs();
|
|
40
|
+
}
|
|
41
|
+
if (globalThis.performance && typeof globalThis.performance.now === "function") {
|
|
42
|
+
return globalThis.performance.now();
|
|
43
|
+
}
|
|
44
|
+
return Date.now();
|
|
45
|
+
};
|
|
46
|
+
const startedAt = monotonicMs();
|
|
47
|
+
const emitter = new EventEmitter();
|
|
48
|
+
const on = emitter.on.bind(emitter);
|
|
49
|
+
const off = emitter.off.bind(emitter);
|
|
50
|
+
const addListener = emitter.addListener.bind(emitter);
|
|
51
|
+
const removeListener = emitter.removeListener.bind(emitter);
|
|
52
|
+
const emit = emitter.emit.bind(emitter);
|
|
53
|
+
const once = emitter.once.bind(emitter);
|
|
54
|
+
const argv = Object.freeze(globalThis.__sloppy_program_args?.slice?.() ?? []);
|
|
55
|
+
const cwd = () => globalThis.__sloppy_program_context?.cwd ?? ".";
|
|
56
|
+
const platform = globalThis.__sloppy_runtime?.System?.platform ?? "sloppy";
|
|
57
|
+
const arch = globalThis.__sloppy_runtime?.System?.arch ?? "unknown";
|
|
58
|
+
const sloppyVersion = String(globalThis.__sloppy_runtime?.System?.version ?? "0.1.0");
|
|
59
|
+
const version = sloppyVersion.startsWith("sloppy-") ? sloppyVersion : `sloppy-${sloppyVersion}`;
|
|
60
|
+
const versions = Object.freeze({ sloppy: version.replace(/^sloppy-/, "") });
|
|
61
|
+
const release = Object.freeze({ name: "sloppy", sourceUrl: "https://github.com/RtlZeroMemory/Slop" });
|
|
62
|
+
let exitCode = undefined;
|
|
63
|
+
const nextTick = (fn, ...args) => Promise.resolve().then(() => fn(...args));
|
|
64
|
+
const exit = (code = 0) => {
|
|
65
|
+
throw new Error(`SLOPPY_E_PROCESS_EXIT_UNSUPPORTED: process.exit(${code}) is not supported.`);
|
|
66
|
+
};
|
|
67
|
+
const hrtimeNanos = () => BigInt(Math.max(0, Math.floor(monotonicMs() * 1000000)));
|
|
68
|
+
const uptime = () => Math.max(0, (monotonicMs() - startedAt) / 1000);
|
|
69
|
+
const hrtime = (previous = undefined) => {
|
|
70
|
+
const now = hrtimeNanos();
|
|
71
|
+
const seconds = Number(now / 1000000000n);
|
|
72
|
+
const nanos = Number(now % 1000000000n);
|
|
73
|
+
if (previous === undefined) {
|
|
74
|
+
return [seconds, nanos];
|
|
75
|
+
}
|
|
76
|
+
const previousNanos = BigInt(previous[0]) * 1000000000n + BigInt(previous[1]);
|
|
77
|
+
const diff = now - previousNanos;
|
|
78
|
+
return [Number(diff / 1000000000n), Number(diff % 1000000000n)];
|
|
79
|
+
};
|
|
80
|
+
hrtime.bigint = hrtimeNanos;
|
|
81
|
+
const memoryUsage = () => Object.freeze({
|
|
82
|
+
arrayBuffers: 0,
|
|
83
|
+
external: 0,
|
|
84
|
+
heapTotal: 0,
|
|
85
|
+
heapUsed: 0,
|
|
86
|
+
rss: 0,
|
|
87
|
+
});
|
|
88
|
+
const stream = (name) => Object.freeze({
|
|
89
|
+
isTTY: false,
|
|
90
|
+
write() {
|
|
91
|
+
throw new Error(`SLOPPY_E_PROCESS_STREAM_WRITE_UNSUPPORTED: process.${name}.write is not available in Sloppy's Node compatibility shim.`);
|
|
92
|
+
},
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
const process = {
|
|
96
|
+
arch,
|
|
97
|
+
argv,
|
|
98
|
+
browser: false,
|
|
99
|
+
cwd,
|
|
100
|
+
env,
|
|
101
|
+
emit,
|
|
102
|
+
exit,
|
|
103
|
+
get exitCode() {
|
|
104
|
+
return exitCode;
|
|
105
|
+
},
|
|
106
|
+
set exitCode(value) {
|
|
107
|
+
exitCode = value;
|
|
108
|
+
},
|
|
109
|
+
hrtime,
|
|
110
|
+
memoryUsage,
|
|
111
|
+
nextTick,
|
|
112
|
+
off,
|
|
113
|
+
removeListener,
|
|
114
|
+
on,
|
|
115
|
+
addListener,
|
|
116
|
+
once,
|
|
117
|
+
platform,
|
|
118
|
+
release,
|
|
119
|
+
stderr: stream("stderr"),
|
|
120
|
+
stdin: Object.freeze({ isTTY: false }),
|
|
121
|
+
stdout: stream("stdout"),
|
|
122
|
+
uptime,
|
|
123
|
+
version,
|
|
124
|
+
versions,
|
|
125
|
+
Process,
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
export { addListener, arch, argv, cwd, emit, env, exit, hrtime, memoryUsage, nextTick, off, on, once, platform, Process, release, removeListener, uptime, version, versions };
|
|
129
|
+
export default process;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
function parse(input = "") {
|
|
2
|
+
const output = Object.create(null);
|
|
3
|
+
for (const part of String(input).split("&")) {
|
|
4
|
+
if (part === "") {
|
|
5
|
+
continue;
|
|
6
|
+
}
|
|
7
|
+
const [rawKey, rawValue = ""] = part.split("=");
|
|
8
|
+
output[decodeURIComponent(rawKey.replace(/\+/g, " "))] =
|
|
9
|
+
decodeURIComponent(rawValue.replace(/\+/g, " "));
|
|
10
|
+
}
|
|
11
|
+
return output;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function stringify(value = {}) {
|
|
15
|
+
return Object.entries(value)
|
|
16
|
+
.map(([key, item]) => `${encodeURIComponent(key)}=${encodeURIComponent(String(item))}`)
|
|
17
|
+
.join("&");
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export { parse, stringify };
|
|
21
|
+
export default { parse, stringify };
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { EventEmitter } from "./events.js";
|
|
2
|
+
|
|
3
|
+
class Stream extends EventEmitter {}
|
|
4
|
+
|
|
5
|
+
class Readable extends Stream {
|
|
6
|
+
static from(iterable) {
|
|
7
|
+
const readable = new Readable();
|
|
8
|
+
readable._iterable = iterable;
|
|
9
|
+
return readable;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
async *[Symbol.asyncIterator]() {
|
|
13
|
+
for await (const chunk of this._iterable ?? []) {
|
|
14
|
+
yield chunk;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
class Writable extends Stream {
|
|
20
|
+
constructor(options = {}) {
|
|
21
|
+
super();
|
|
22
|
+
this._write = typeof options.write === "function" ? options.write : undefined;
|
|
23
|
+
this.chunks = [];
|
|
24
|
+
this._pendingWrites = new Set();
|
|
25
|
+
this._finished = Promise.resolve(this);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
_invokeWrite(chunk) {
|
|
29
|
+
return new Promise((resolve, reject) => {
|
|
30
|
+
try {
|
|
31
|
+
if (this._write) {
|
|
32
|
+
if (this._write.length >= 3) {
|
|
33
|
+
this._write(chunk, undefined, (error) => error ? reject(error) : resolve());
|
|
34
|
+
} else {
|
|
35
|
+
Promise.resolve(this._write(chunk)).then(resolve, reject);
|
|
36
|
+
}
|
|
37
|
+
} else {
|
|
38
|
+
this.chunks.push(chunk);
|
|
39
|
+
resolve();
|
|
40
|
+
}
|
|
41
|
+
} catch (error) {
|
|
42
|
+
reject(error);
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
_trackWrite(promise) {
|
|
48
|
+
const tracked = Promise.resolve(promise).finally(() => this._pendingWrites.delete(tracked));
|
|
49
|
+
this._pendingWrites.add(tracked);
|
|
50
|
+
return tracked;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
write(chunk, encodingOrCallback = undefined, callback = undefined) {
|
|
54
|
+
const done = typeof encodingOrCallback === "function" ? encodingOrCallback : callback;
|
|
55
|
+
this._trackWrite(this._invokeWrite(chunk)).then(
|
|
56
|
+
() => {
|
|
57
|
+
if (typeof done === "function") {
|
|
58
|
+
done();
|
|
59
|
+
}
|
|
60
|
+
this.emit("drain");
|
|
61
|
+
},
|
|
62
|
+
(error) => {
|
|
63
|
+
if (typeof done === "function") {
|
|
64
|
+
done(error);
|
|
65
|
+
}
|
|
66
|
+
this.emit("error", error);
|
|
67
|
+
},
|
|
68
|
+
);
|
|
69
|
+
return true;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
end(chunk = undefined, encodingOrCallback = undefined, callback = undefined) {
|
|
73
|
+
if (typeof chunk === "function") {
|
|
74
|
+
callback = chunk;
|
|
75
|
+
chunk = undefined;
|
|
76
|
+
} else if (typeof encodingOrCallback === "function") {
|
|
77
|
+
callback = encodingOrCallback;
|
|
78
|
+
}
|
|
79
|
+
if (chunk !== undefined) {
|
|
80
|
+
this.write(chunk);
|
|
81
|
+
}
|
|
82
|
+
if (typeof callback === "function") {
|
|
83
|
+
this.once("finish", callback);
|
|
84
|
+
}
|
|
85
|
+
this._finished = Promise.all([...this._pendingWrites]).then(
|
|
86
|
+
() => {
|
|
87
|
+
this.emit("finish");
|
|
88
|
+
return this;
|
|
89
|
+
},
|
|
90
|
+
(error) => {
|
|
91
|
+
this.emit("error", error);
|
|
92
|
+
throw error;
|
|
93
|
+
},
|
|
94
|
+
);
|
|
95
|
+
return this;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
get finished() {
|
|
99
|
+
return this._finished;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
class PassThrough extends Writable {
|
|
104
|
+
write(chunk, encodingOrCallback = undefined, callback = undefined) {
|
|
105
|
+
super.write(chunk, encodingOrCallback, callback);
|
|
106
|
+
this.emit("data", chunk);
|
|
107
|
+
return true;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
async function pipeline(source, destination, callback = undefined) {
|
|
112
|
+
try {
|
|
113
|
+
for await (const chunk of source) {
|
|
114
|
+
destination.write(chunk);
|
|
115
|
+
}
|
|
116
|
+
destination.end();
|
|
117
|
+
await destination.finished;
|
|
118
|
+
if (typeof callback === "function") {
|
|
119
|
+
callback();
|
|
120
|
+
}
|
|
121
|
+
return destination;
|
|
122
|
+
} catch (error) {
|
|
123
|
+
if (typeof callback === "function") {
|
|
124
|
+
callback(error);
|
|
125
|
+
return destination;
|
|
126
|
+
}
|
|
127
|
+
throw error;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
export { PassThrough, Readable, Stream, Writable, pipeline };
|
|
132
|
+
export default { PassThrough, Readable, Stream, Writable, pipeline };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Text } from "../codec.js";
|
|
2
|
+
|
|
3
|
+
class StringDecoder {
|
|
4
|
+
constructor(encoding = "utf8") {
|
|
5
|
+
const normalized = String(encoding).toLowerCase();
|
|
6
|
+
if (normalized !== "utf8" && normalized !== "utf-8") {
|
|
7
|
+
throw new TypeError("Sloppy string_decoder only supports utf8.");
|
|
8
|
+
}
|
|
9
|
+
this._decoder = Text.utf8.decoder();
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
write(buffer) {
|
|
13
|
+
return this._decoder.decode(buffer instanceof Uint8Array ? buffer : new Uint8Array(buffer), { stream: true });
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
end(buffer = undefined) {
|
|
17
|
+
const text = buffer === undefined ? "" : this.write(buffer);
|
|
18
|
+
return text + this._decoder.finish();
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export { StringDecoder };
|
|
23
|
+
export default { StringDecoder };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Time } from "../time.js";
|
|
2
|
+
|
|
3
|
+
function setTimeout(handler, delay = 0, ...args) {
|
|
4
|
+
const timer = { cancelled: false };
|
|
5
|
+
Time.delay(delay).then(() => {
|
|
6
|
+
if (!timer.cancelled) {
|
|
7
|
+
handler(...args);
|
|
8
|
+
}
|
|
9
|
+
});
|
|
10
|
+
return timer;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function clearTimeout(timer) {
|
|
14
|
+
if (timer !== null && typeof timer === "object") {
|
|
15
|
+
timer.cancelled = true;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function setImmediate(handler, ...args) {
|
|
20
|
+
return setTimeout(handler, 0, ...args);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const clearImmediate = clearTimeout;
|
|
24
|
+
|
|
25
|
+
export { clearImmediate, clearTimeout, setImmediate, setTimeout };
|
|
26
|
+
export default { clearImmediate, clearTimeout, setImmediate, setTimeout };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
function isatty() {
|
|
2
|
+
return false;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
class ReadStream {
|
|
6
|
+
constructor() {
|
|
7
|
+
this.isTTY = false;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
class WriteStream {
|
|
12
|
+
constructor() {
|
|
13
|
+
this.isTTY = false;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export { isatty, ReadStream, WriteStream };
|
|
18
|
+
export default { isatty, ReadStream, WriteStream };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
const URLCtor = globalThis.URL;
|
|
2
|
+
const URLSearchParamsCtor = globalThis.URLSearchParams;
|
|
3
|
+
|
|
4
|
+
function pathToFileURL(path) {
|
|
5
|
+
return new URLCtor(`file://${String(path).replace(/\\/g, "/")}`);
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
function fileURLToPath(url) {
|
|
9
|
+
const parsed = url instanceof URLCtor ? url : new URLCtor(String(url));
|
|
10
|
+
if (parsed.protocol !== "file:") {
|
|
11
|
+
throw new TypeError("fileURLToPath requires a file: URL.");
|
|
12
|
+
}
|
|
13
|
+
return decodeURIComponent(parsed.pathname);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export { fileURLToPath, pathToFileURL, URLCtor as URL, URLSearchParamsCtor as URLSearchParams };
|
|
17
|
+
export default { URL: URLCtor, URLSearchParams: URLSearchParamsCtor, fileURLToPath, pathToFileURL };
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
function inspect(value) {
|
|
2
|
+
if (typeof value === "string") {
|
|
3
|
+
return value;
|
|
4
|
+
}
|
|
5
|
+
if (typeof value === "function") {
|
|
6
|
+
return value.name ? `[Function: ${value.name}]` : "[Function]";
|
|
7
|
+
}
|
|
8
|
+
try {
|
|
9
|
+
return JSON.stringify(value);
|
|
10
|
+
} catch (_) {
|
|
11
|
+
return String(value);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function format(first = "", ...rest) {
|
|
16
|
+
if (typeof first !== "string") {
|
|
17
|
+
return [first, ...rest].map(inspect).join(" ");
|
|
18
|
+
}
|
|
19
|
+
let index = 0;
|
|
20
|
+
const text = first.replace(/%[sdjifoO%]/g, (token) => {
|
|
21
|
+
if (token === "%%") {
|
|
22
|
+
return "%";
|
|
23
|
+
}
|
|
24
|
+
if (index >= rest.length) {
|
|
25
|
+
return token;
|
|
26
|
+
}
|
|
27
|
+
const value = rest[index];
|
|
28
|
+
index += 1;
|
|
29
|
+
if (token === "%s") {
|
|
30
|
+
return String(value);
|
|
31
|
+
}
|
|
32
|
+
if (token === "%d") {
|
|
33
|
+
return String(Number(value));
|
|
34
|
+
}
|
|
35
|
+
if (token === "%i") {
|
|
36
|
+
return String(Number.parseInt(value, 10));
|
|
37
|
+
}
|
|
38
|
+
if (token === "%f") {
|
|
39
|
+
return String(Number.parseFloat(value));
|
|
40
|
+
}
|
|
41
|
+
if (token === "%j") {
|
|
42
|
+
try {
|
|
43
|
+
return JSON.stringify(value);
|
|
44
|
+
} catch {
|
|
45
|
+
return "[Circular]";
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return inspect(value);
|
|
49
|
+
});
|
|
50
|
+
return [text, ...rest.slice(index).map(inspect)].join(" ");
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function promisify(fn) {
|
|
54
|
+
if (typeof fn !== "function") {
|
|
55
|
+
throw new TypeError("util.promisify expects a function.");
|
|
56
|
+
}
|
|
57
|
+
return (...args) => new Promise((resolve, reject) => {
|
|
58
|
+
fn(...args, (error, value) => (error ? reject(error) : resolve(value)));
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function callbackify(fn) {
|
|
63
|
+
if (typeof fn !== "function") {
|
|
64
|
+
throw new TypeError("util.callbackify expects a function.");
|
|
65
|
+
}
|
|
66
|
+
return (...args) => {
|
|
67
|
+
const callback = args.pop();
|
|
68
|
+
Promise.resolve()
|
|
69
|
+
.then(() => fn(...args))
|
|
70
|
+
.then((value) => callback(null, value), (error) => callback(error));
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function inherits(ctor, superCtor) {
|
|
75
|
+
if (typeof ctor !== "function" || typeof superCtor !== "function") {
|
|
76
|
+
throw new TypeError("util.inherits expects constructor functions.");
|
|
77
|
+
}
|
|
78
|
+
Object.setPrototypeOf(ctor.prototype, superCtor.prototype);
|
|
79
|
+
Object.defineProperty(ctor.prototype, "constructor", {
|
|
80
|
+
configurable: true,
|
|
81
|
+
enumerable: false,
|
|
82
|
+
value: ctor,
|
|
83
|
+
writable: true,
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
const types = Object.freeze({
|
|
88
|
+
isArrayBufferView: ArrayBuffer.isView,
|
|
89
|
+
isDate: (value) => value instanceof Date,
|
|
90
|
+
isRegExp: (value) => value instanceof RegExp,
|
|
91
|
+
isUint8Array: (value) => value instanceof Uint8Array,
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
export { callbackify, format, inherits, inspect, promisify, types };
|
|
95
|
+
export default { callbackify, format, inherits, inspect, promisify, types };
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { Compression, Text } from "../codec.js";
|
|
2
|
+
|
|
3
|
+
function toBytes(value) {
|
|
4
|
+
if (typeof value === "string") {
|
|
5
|
+
return Text.utf8.encode(value);
|
|
6
|
+
}
|
|
7
|
+
if (value instanceof Uint8Array) {
|
|
8
|
+
return value;
|
|
9
|
+
}
|
|
10
|
+
if (value instanceof ArrayBuffer) {
|
|
11
|
+
return new Uint8Array(value);
|
|
12
|
+
}
|
|
13
|
+
if (ArrayBuffer.isView(value)) {
|
|
14
|
+
return new Uint8Array(value.buffer, value.byteOffset, value.byteLength);
|
|
15
|
+
}
|
|
16
|
+
throw new TypeError("Sloppy node:zlib input must be a string or bytes.");
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function callbackify(promiseFactory, callback) {
|
|
20
|
+
if (typeof callback !== "function") {
|
|
21
|
+
throw new TypeError("Sloppy node:zlib callback API requires a callback.");
|
|
22
|
+
}
|
|
23
|
+
promiseFactory().then((value) => callback(null, value), (error) => callback(error));
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function gzip(input, options, callback) {
|
|
27
|
+
if (typeof options === "function") {
|
|
28
|
+
callback = options;
|
|
29
|
+
options = undefined;
|
|
30
|
+
}
|
|
31
|
+
callbackify(() => Compression.gzip(toBytes(input), options), callback);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function gunzip(input, options, callback) {
|
|
35
|
+
if (typeof options === "function") {
|
|
36
|
+
callback = options;
|
|
37
|
+
options = undefined;
|
|
38
|
+
}
|
|
39
|
+
callbackify(() => Compression.gunzip(toBytes(input), options), callback);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function unsupportedAsync(name, input, options, callback) {
|
|
43
|
+
if (typeof options === "function") {
|
|
44
|
+
callback = options;
|
|
45
|
+
options = undefined;
|
|
46
|
+
}
|
|
47
|
+
callbackify(
|
|
48
|
+
() => Promise.reject(new Error(`SLOPPY_E_NODE_ZLIB_UNSUPPORTED: node:zlib.${name} is not implemented by Sloppy's Node compatibility shim.`)),
|
|
49
|
+
callback,
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function deflate(input, options, callback) {
|
|
54
|
+
unsupportedAsync("deflate", input, options, callback);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function inflate(input, options, callback) {
|
|
58
|
+
unsupportedAsync("inflate", input, options, callback);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function unsupportedSync(name) {
|
|
62
|
+
return () => {
|
|
63
|
+
throw new Error(`SLOPPY_E_NODE_ZLIB_SYNC_UNSUPPORTED: node:zlib.${name} is not available because Sloppy compression is async.`);
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export { deflate, gzip, gunzip, inflate };
|
|
68
|
+
export const gzipSync = unsupportedSync("gzipSync");
|
|
69
|
+
export const gunzipSync = unsupportedSync("gunzipSync");
|
|
70
|
+
export const deflateSync = unsupportedSync("deflateSync");
|
|
71
|
+
export const inflateSync = unsupportedSync("inflateSync");
|
|
72
|
+
export default { deflate, deflateSync, gzip, gzipSync, gunzip, gunzipSync, inflate, inflateSync };
|