@slopware/sloppy-darwin-x64 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,113 @@
|
|
|
1
|
+
const onceOriginal = Symbol("onceOriginal");
|
|
2
|
+
|
|
3
|
+
class EventEmitter {
|
|
4
|
+
constructor() {
|
|
5
|
+
this._events = new Map();
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
on(name, listener) {
|
|
9
|
+
if (typeof listener !== "function") {
|
|
10
|
+
throw new TypeError("EventEmitter listener must be a function.");
|
|
11
|
+
}
|
|
12
|
+
const listeners = this._events.get(name) ?? [];
|
|
13
|
+
listeners.push(listener);
|
|
14
|
+
this._events.set(name, listeners);
|
|
15
|
+
return this;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
addListener(name, listener) {
|
|
19
|
+
return this.on(name, listener);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
prependListener(name, listener) {
|
|
23
|
+
if (typeof listener !== "function") {
|
|
24
|
+
throw new TypeError("EventEmitter listener must be a function.");
|
|
25
|
+
}
|
|
26
|
+
const listeners = this._events.get(name) ?? [];
|
|
27
|
+
listeners.unshift(listener);
|
|
28
|
+
this._events.set(name, listeners);
|
|
29
|
+
return this;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
once(name, listener) {
|
|
33
|
+
if (typeof listener !== "function") {
|
|
34
|
+
throw new TypeError("EventEmitter listener must be a function.");
|
|
35
|
+
}
|
|
36
|
+
const wrapped = (...args) => {
|
|
37
|
+
this.off(name, wrapped);
|
|
38
|
+
listener(...args);
|
|
39
|
+
};
|
|
40
|
+
wrapped[onceOriginal] = listener;
|
|
41
|
+
return this.on(name, wrapped);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
off(name, listener) {
|
|
45
|
+
const listeners = this._events.get(name) ?? [];
|
|
46
|
+
this._events.set(
|
|
47
|
+
name,
|
|
48
|
+
listeners.filter((candidate) => candidate !== listener && candidate[onceOriginal] !== listener),
|
|
49
|
+
);
|
|
50
|
+
return this;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
removeListener(name, listener) {
|
|
54
|
+
return this.off(name, listener);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
emit(name, ...args) {
|
|
58
|
+
const listeners = [...(this._events.get(name) ?? [])];
|
|
59
|
+
for (const listener of listeners) {
|
|
60
|
+
listener(...args);
|
|
61
|
+
}
|
|
62
|
+
return listeners.length > 0;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
listenerCount(name) {
|
|
66
|
+
return (this._events.get(name) ?? []).length;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
removeAllListeners(name = undefined) {
|
|
70
|
+
if (name === undefined) {
|
|
71
|
+
this._events.clear();
|
|
72
|
+
} else {
|
|
73
|
+
this._events.delete(name);
|
|
74
|
+
}
|
|
75
|
+
return this;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function once(emitter, name) {
|
|
80
|
+
return new Promise((resolve) => {
|
|
81
|
+
emitter.once(name, (...args) => resolve(args));
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
async function* on(emitter, name) {
|
|
86
|
+
const queue = [];
|
|
87
|
+
let notify = undefined;
|
|
88
|
+
const listener = (...args) => {
|
|
89
|
+
queue.push(args);
|
|
90
|
+
if (notify !== undefined) {
|
|
91
|
+
notify();
|
|
92
|
+
notify = undefined;
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
emitter.on(name, listener);
|
|
96
|
+
try {
|
|
97
|
+
while (true) {
|
|
98
|
+
if (queue.length === 0) {
|
|
99
|
+
await new Promise((resolve) => {
|
|
100
|
+
notify = resolve;
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
while (queue.length > 0) {
|
|
104
|
+
yield queue.shift();
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
} finally {
|
|
108
|
+
emitter.removeListener(name, listener);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export { EventEmitter, on, once };
|
|
113
|
+
export default { EventEmitter, on, once };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export {
|
|
2
|
+
promises as default,
|
|
3
|
+
promises,
|
|
4
|
+
} from "../fs.js";
|
|
5
|
+
|
|
6
|
+
import { promises } from "../fs.js";
|
|
7
|
+
|
|
8
|
+
const {
|
|
9
|
+
access,
|
|
10
|
+
appendFile,
|
|
11
|
+
copyFile,
|
|
12
|
+
lstat,
|
|
13
|
+
mkdir,
|
|
14
|
+
mkdtemp,
|
|
15
|
+
readdir,
|
|
16
|
+
readFile,
|
|
17
|
+
readlink,
|
|
18
|
+
realpath,
|
|
19
|
+
rename,
|
|
20
|
+
rm,
|
|
21
|
+
stat,
|
|
22
|
+
symlink,
|
|
23
|
+
unlink,
|
|
24
|
+
writeFile,
|
|
25
|
+
} = promises;
|
|
26
|
+
|
|
27
|
+
export { access, appendFile, copyFile, lstat, mkdir, mkdtemp, readdir, readFile, readlink, realpath, rename, rm, stat, symlink, unlink, writeFile };
|
|
@@ -0,0 +1,280 @@
|
|
|
1
|
+
import { Directory, File } from "../fs.js";
|
|
2
|
+
import { Base64, Text } from "../codec.js";
|
|
3
|
+
|
|
4
|
+
function bytesFromBase64(value) {
|
|
5
|
+
return Base64.decode(value);
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
function toSloppyPath(path) {
|
|
9
|
+
if (typeof path !== "string") {
|
|
10
|
+
return path;
|
|
11
|
+
}
|
|
12
|
+
const normalized = path.replace(/\\/g, "/");
|
|
13
|
+
if (
|
|
14
|
+
normalized.startsWith("/") ||
|
|
15
|
+
/^[A-Za-z]:\//.test(normalized) ||
|
|
16
|
+
normalized.startsWith("./") ||
|
|
17
|
+
normalized.startsWith("../") ||
|
|
18
|
+
normalized.includes("://")
|
|
19
|
+
) {
|
|
20
|
+
return normalized;
|
|
21
|
+
}
|
|
22
|
+
return `./${normalized}`;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function normalizeEncoding(options, operation) {
|
|
26
|
+
const encoding = typeof options === "string" ? options : options?.encoding;
|
|
27
|
+
if (encoding === undefined || encoding === null) {
|
|
28
|
+
return undefined;
|
|
29
|
+
}
|
|
30
|
+
const normalized = String(encoding).toLowerCase();
|
|
31
|
+
if (normalized === "utf8" || normalized === "utf-8") {
|
|
32
|
+
return "utf8";
|
|
33
|
+
}
|
|
34
|
+
throw new TypeError(`SLOPPY_E_NODE_FS_UNSUPPORTED_ENCODING: ${operation} only supports utf8 text encoding.`);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function recursiveOption(options, operation) {
|
|
38
|
+
const recursive = options?.recursive;
|
|
39
|
+
if (recursive === undefined) {
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
42
|
+
if (typeof recursive !== "boolean") {
|
|
43
|
+
throw new TypeError(`${operation} recursive option must be a boolean.`);
|
|
44
|
+
}
|
|
45
|
+
return recursive;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function nodeStats(stat) {
|
|
49
|
+
return Object.freeze({
|
|
50
|
+
...stat,
|
|
51
|
+
isFile() {
|
|
52
|
+
return stat.kind === "file" || (stat.exists === true && stat.kind !== "directory");
|
|
53
|
+
},
|
|
54
|
+
isDirectory() {
|
|
55
|
+
return stat.kind === "directory";
|
|
56
|
+
},
|
|
57
|
+
isSymbolicLink() {
|
|
58
|
+
return stat.kind === "symlink" || stat.symlink === true;
|
|
59
|
+
},
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
async function readFilePromise(path, options = undefined) {
|
|
64
|
+
const encoding = normalizeEncoding(options, "node:fs.readFile");
|
|
65
|
+
return encoding === "utf8"
|
|
66
|
+
? File.readText(toSloppyPath(path))
|
|
67
|
+
: File.readBytes(toSloppyPath(path));
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
async function writeFilePromise(path, data, options = undefined) {
|
|
71
|
+
normalizeEncoding(options, "node:fs.writeFile");
|
|
72
|
+
if (typeof data === "string") {
|
|
73
|
+
return File.writeText(toSloppyPath(path), data);
|
|
74
|
+
}
|
|
75
|
+
return File.writeBytes(toSloppyPath(path), data);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
async function appendFilePromise(path, data, options = undefined) {
|
|
79
|
+
normalizeEncoding(options, "node:fs.appendFile");
|
|
80
|
+
if (typeof data === "string") {
|
|
81
|
+
return File.appendText(toSloppyPath(path), data);
|
|
82
|
+
}
|
|
83
|
+
return File.appendBytes(toSloppyPath(path), data);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
async function unlinkPromise(path) {
|
|
87
|
+
return File.delete(toSloppyPath(path));
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
async function copyFilePromise(fromPath, toPath) {
|
|
91
|
+
return File.copy(toSloppyPath(fromPath), toSloppyPath(toPath));
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
async function renamePromise(fromPath, toPath) {
|
|
95
|
+
return File.move(toSloppyPath(fromPath), toSloppyPath(toPath));
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
async function readlinkPromise(path) {
|
|
99
|
+
return File.readLink(toSloppyPath(path));
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
async function symlinkPromise(targetPath, linkPath, type = undefined) {
|
|
103
|
+
return File.createSymlink(toSloppyPath(targetPath), toSloppyPath(linkPath), {
|
|
104
|
+
directory: type === "dir" || type === "junction",
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
function callbackify(method, name) {
|
|
109
|
+
return (...args) => {
|
|
110
|
+
const callback = args.pop();
|
|
111
|
+
if (typeof callback !== "function") {
|
|
112
|
+
throw new TypeError(`node:fs.${name} requires a callback.`);
|
|
113
|
+
}
|
|
114
|
+
Promise.resolve()
|
|
115
|
+
.then(() => method(...args))
|
|
116
|
+
.then(
|
|
117
|
+
(value) => callback(null, value),
|
|
118
|
+
(error) => callback(error),
|
|
119
|
+
);
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
function sealedAssetMap() {
|
|
124
|
+
const map = globalThis.__sloppy_program_assets;
|
|
125
|
+
return (map && typeof map === "object") ? map : null;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
function lookupSealedAsset(path) {
|
|
129
|
+
const map = sealedAssetMap();
|
|
130
|
+
if (!map) {
|
|
131
|
+
return undefined;
|
|
132
|
+
}
|
|
133
|
+
const sloppyPath = toSloppyPath(path);
|
|
134
|
+
if (Object.prototype.hasOwnProperty.call(map, sloppyPath)) {
|
|
135
|
+
return map[sloppyPath];
|
|
136
|
+
}
|
|
137
|
+
if (typeof path === "string" && Object.prototype.hasOwnProperty.call(map, path)) {
|
|
138
|
+
return map[path];
|
|
139
|
+
}
|
|
140
|
+
const normalized = typeof path === "string"
|
|
141
|
+
? path.replace(/\\/g, "/").replace(/^(\.\/)+/, "")
|
|
142
|
+
: null;
|
|
143
|
+
if (normalized && Object.prototype.hasOwnProperty.call(map, normalized)) {
|
|
144
|
+
return map[normalized];
|
|
145
|
+
}
|
|
146
|
+
return undefined;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
function unsealedSyncError(operation, _path) {
|
|
150
|
+
return new Error(
|
|
151
|
+
`SLOPPY_E_NODE_SYNC_FS_UNSEALED: node:fs.${operation} requires the path to be a sealed package asset; the requested path was not found in the bundled asset map.`,
|
|
152
|
+
);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
function decodeSealedAssetText(entry) {
|
|
156
|
+
if (typeof entry === "string") {
|
|
157
|
+
return entry;
|
|
158
|
+
}
|
|
159
|
+
if (entry && typeof entry === "object" && typeof entry.text === "string") {
|
|
160
|
+
return entry.text;
|
|
161
|
+
}
|
|
162
|
+
if (entry && typeof entry === "object" && typeof entry.base64 === "string") {
|
|
163
|
+
const bytes = bytesFromBase64(entry.base64);
|
|
164
|
+
return Text.utf8.decode(bytes);
|
|
165
|
+
}
|
|
166
|
+
return undefined;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
function decodeSealedAssetBytes(entry) {
|
|
170
|
+
if (entry instanceof Uint8Array) {
|
|
171
|
+
return entry.slice();
|
|
172
|
+
}
|
|
173
|
+
if (entry && typeof entry === "object" && entry.bytes instanceof Uint8Array) {
|
|
174
|
+
return entry.bytes.slice();
|
|
175
|
+
}
|
|
176
|
+
if (entry && typeof entry === "object" && typeof entry.base64 === "string") {
|
|
177
|
+
return bytesFromBase64(entry.base64).slice();
|
|
178
|
+
}
|
|
179
|
+
if (typeof entry === "string") {
|
|
180
|
+
return Text.utf8.encode(entry);
|
|
181
|
+
}
|
|
182
|
+
return undefined;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
function readFileSync(path, options = undefined) {
|
|
186
|
+
const entry = lookupSealedAsset(path);
|
|
187
|
+
if (entry === undefined) {
|
|
188
|
+
throw unsealedSyncError("readFileSync", path);
|
|
189
|
+
}
|
|
190
|
+
const encoding = normalizeEncoding(options, "node:fs.readFileSync");
|
|
191
|
+
if (encoding === "utf8") {
|
|
192
|
+
const text = decodeSealedAssetText(entry);
|
|
193
|
+
if (text === undefined) {
|
|
194
|
+
throw unsealedSyncError("readFileSync", path);
|
|
195
|
+
}
|
|
196
|
+
return text;
|
|
197
|
+
}
|
|
198
|
+
const bytes = decodeSealedAssetBytes(entry);
|
|
199
|
+
if (bytes === undefined) {
|
|
200
|
+
throw unsealedSyncError("readFileSync", path);
|
|
201
|
+
}
|
|
202
|
+
return bytes.slice();
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
function existsSync(path) {
|
|
206
|
+
return lookupSealedAsset(path) !== undefined;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
function statSync(path, options = undefined) {
|
|
210
|
+
const entry = lookupSealedAsset(path);
|
|
211
|
+
if (entry === undefined) {
|
|
212
|
+
const opts = options && typeof options === "object" ? options : {};
|
|
213
|
+
if (opts.throwIfNoEntry === false) {
|
|
214
|
+
return undefined;
|
|
215
|
+
}
|
|
216
|
+
throw unsealedSyncError("statSync", path);
|
|
217
|
+
}
|
|
218
|
+
const bytes = decodeSealedAssetBytes(entry);
|
|
219
|
+
return nodeStats({
|
|
220
|
+
kind: "file",
|
|
221
|
+
exists: true,
|
|
222
|
+
size: bytes ? bytes.byteLength : 0,
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
async function unsupportedPromise(name) {
|
|
227
|
+
throw new Error(`SLOPPY_E_NODE_FS_UNSUPPORTED: node:fs.promises.${name} is not implemented by Sloppy's Node compatibility shim.`);
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
const promises = Object.freeze({
|
|
231
|
+
access: async (path) => {
|
|
232
|
+
const stat = await File.stat(toSloppyPath(path));
|
|
233
|
+
if (!stat.exists) {
|
|
234
|
+
throw new Error("SLOPPY_E_NODE_FS_ACCESS: path is not accessible.");
|
|
235
|
+
}
|
|
236
|
+
},
|
|
237
|
+
appendFile: appendFilePromise,
|
|
238
|
+
copyFile: copyFilePromise,
|
|
239
|
+
lstat: () => unsupportedPromise("lstat"),
|
|
240
|
+
mkdir: (path, options) =>
|
|
241
|
+
Directory.create(toSloppyPath(path), { recursive: recursiveOption(options, "node:fs.mkdir") }),
|
|
242
|
+
mkdtemp: () => unsupportedPromise("mkdtemp"),
|
|
243
|
+
readdir: async (path) => (await Directory.list(toSloppyPath(path))).map((entry) => entry.name),
|
|
244
|
+
readFile: readFilePromise,
|
|
245
|
+
readlink: readlinkPromise,
|
|
246
|
+
realpath: () => unsupportedPromise("realpath"),
|
|
247
|
+
rename: renamePromise,
|
|
248
|
+
rm: async (path, options = undefined) => {
|
|
249
|
+
const sloppyPath = toSloppyPath(path);
|
|
250
|
+
const stat = await File.stat(sloppyPath);
|
|
251
|
+
if (stat.kind === "directory") {
|
|
252
|
+
return Directory.delete(sloppyPath, { recursive: recursiveOption(options, "node:fs.rm") });
|
|
253
|
+
}
|
|
254
|
+
return File.delete(sloppyPath);
|
|
255
|
+
},
|
|
256
|
+
stat: async (path) => nodeStats(await File.stat(toSloppyPath(path))),
|
|
257
|
+
symlink: symlinkPromise,
|
|
258
|
+
unlink: unlinkPromise,
|
|
259
|
+
writeFile: writeFilePromise,
|
|
260
|
+
});
|
|
261
|
+
|
|
262
|
+
const access = callbackify(promises.access, "access");
|
|
263
|
+
const appendFile = callbackify(appendFilePromise, "appendFile");
|
|
264
|
+
const copyFile = callbackify(copyFilePromise, "copyFile");
|
|
265
|
+
const lstat = callbackify(promises.lstat, "lstat");
|
|
266
|
+
const mkdir = callbackify(promises.mkdir, "mkdir");
|
|
267
|
+
const mkdtemp = callbackify(promises.mkdtemp, "mkdtemp");
|
|
268
|
+
const readdir = callbackify(promises.readdir, "readdir");
|
|
269
|
+
const readFile = callbackify(readFilePromise, "readFile");
|
|
270
|
+
const readlink = callbackify(readlinkPromise, "readlink");
|
|
271
|
+
const realpath = callbackify(promises.realpath, "realpath");
|
|
272
|
+
const rename = callbackify(renamePromise, "rename");
|
|
273
|
+
const rm = callbackify(promises.rm, "rm");
|
|
274
|
+
const stat = callbackify(promises.stat, "stat");
|
|
275
|
+
const symlink = callbackify(symlinkPromise, "symlink");
|
|
276
|
+
const unlink = callbackify(unlinkPromise, "unlink");
|
|
277
|
+
const writeFile = callbackify(writeFilePromise, "writeFile");
|
|
278
|
+
|
|
279
|
+
export { access, appendFile, copyFile, existsSync, lstat, mkdir, mkdtemp, promises, readdir, readFile, readFileSync, readlink, realpath, rename, rm, stat, statSync, symlink, unlink, writeFile };
|
|
280
|
+
export default { access, appendFile, copyFile, existsSync, lstat, mkdir, mkdtemp, promises, readdir, readFile, readFileSync, readlink, realpath, rename, rm, stat, statSync, symlink, unlink, writeFile };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
function unsupported(name) {
|
|
2
|
+
return () => {
|
|
3
|
+
throw new Error(`SLOPPY_E_NODE_HTTP_UNSUPPORTED: node:http.${name} is not implemented by Sloppy's Node compatibility shim.`);
|
|
4
|
+
};
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
const request = unsupported("request");
|
|
8
|
+
const get = unsupported("get");
|
|
9
|
+
|
|
10
|
+
export { get, request };
|
|
11
|
+
export default { get, request };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
function unsupported(name) {
|
|
2
|
+
return () => {
|
|
3
|
+
throw new Error(`SLOPPY_E_NODE_HTTPS_UNSUPPORTED: node:https.${name} is not implemented by Sloppy's Node compatibility shim.`);
|
|
4
|
+
};
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
const request = unsupported("request");
|
|
8
|
+
const get = unsupported("get");
|
|
9
|
+
|
|
10
|
+
export { get, request };
|
|
11
|
+
export default { get, request };
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
const builtinModules = Object.freeze([
|
|
2
|
+
"assert",
|
|
3
|
+
"assert/strict",
|
|
4
|
+
"buffer",
|
|
5
|
+
"console",
|
|
6
|
+
"constants",
|
|
7
|
+
"crypto",
|
|
8
|
+
"diagnostics_channel",
|
|
9
|
+
"events",
|
|
10
|
+
"fs",
|
|
11
|
+
"fs/promises",
|
|
12
|
+
"http",
|
|
13
|
+
"https",
|
|
14
|
+
"module",
|
|
15
|
+
"os",
|
|
16
|
+
"path",
|
|
17
|
+
"perf_hooks",
|
|
18
|
+
"process",
|
|
19
|
+
"querystring",
|
|
20
|
+
"stream",
|
|
21
|
+
"stream/promises",
|
|
22
|
+
"string_decoder",
|
|
23
|
+
"timers",
|
|
24
|
+
"tty",
|
|
25
|
+
"url",
|
|
26
|
+
"util",
|
|
27
|
+
"zlib",
|
|
28
|
+
]);
|
|
29
|
+
|
|
30
|
+
function createRequire(source) {
|
|
31
|
+
if (typeof globalThis.__sloppy_program_create_require === "function") {
|
|
32
|
+
return globalThis.__sloppy_program_create_require(source);
|
|
33
|
+
}
|
|
34
|
+
throw new Error("SLOPPY_E_MODULE_REQUIRE_UNAVAILABLE: createRequire is only available in bundled Sloppy programs.");
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const Module = Object.freeze({ builtinModules, createRequire });
|
|
38
|
+
|
|
39
|
+
export { builtinModules, createRequire, Module };
|
|
40
|
+
export default Module;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Environment, System } from "../os.js";
|
|
2
|
+
|
|
3
|
+
const EOL = "\n";
|
|
4
|
+
|
|
5
|
+
function platform() {
|
|
6
|
+
return System?.platform ?? "sloppy";
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
function arch() {
|
|
10
|
+
return System?.arch ?? "x64";
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function tmpdir() {
|
|
14
|
+
return Environment.get?.("TMPDIR") ?? Environment.get?.("TEMP") ?? ".";
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function homedir() {
|
|
18
|
+
return Environment.get?.("HOME") ?? Environment.get?.("USERPROFILE") ?? ".";
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export { arch, EOL, homedir, platform, tmpdir };
|
|
22
|
+
export default { arch, EOL, homedir, platform, tmpdir };
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
function normalize(input) {
|
|
2
|
+
const absolute = String(input || "").startsWith("/");
|
|
3
|
+
const parts = [];
|
|
4
|
+
for (const part of String(input || "").replace(/\\/g, "/").split("/")) {
|
|
5
|
+
if (part === "" || part === ".") {
|
|
6
|
+
continue;
|
|
7
|
+
}
|
|
8
|
+
if (part === "..") {
|
|
9
|
+
if (parts.length > 0 && parts[parts.length - 1] !== "..") {
|
|
10
|
+
parts.pop();
|
|
11
|
+
} else if (!absolute) {
|
|
12
|
+
parts.push("..");
|
|
13
|
+
}
|
|
14
|
+
continue;
|
|
15
|
+
}
|
|
16
|
+
parts.push(part);
|
|
17
|
+
}
|
|
18
|
+
const joined = parts.join("/");
|
|
19
|
+
return `${absolute ? "/" : ""}${joined}` || ".";
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function join(...parts) {
|
|
23
|
+
return normalize(parts.filter((part) => part !== "").join("/"));
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function resolve(...parts) {
|
|
27
|
+
let output = "";
|
|
28
|
+
for (const part of parts) {
|
|
29
|
+
const text = String(part);
|
|
30
|
+
output = text.startsWith("/") ? text : `${output}/${text}`;
|
|
31
|
+
}
|
|
32
|
+
return normalize(output || ".");
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function basename(input, ext = "") {
|
|
36
|
+
const text = normalize(input);
|
|
37
|
+
const base = text.slice(text.lastIndexOf("/") + 1);
|
|
38
|
+
return ext && base.endsWith(ext) ? base.slice(0, -ext.length) : base;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function dirname(input) {
|
|
42
|
+
const text = normalize(input);
|
|
43
|
+
const index = text.lastIndexOf("/");
|
|
44
|
+
if (index <= 0) {
|
|
45
|
+
return text.startsWith("/") ? "/" : ".";
|
|
46
|
+
}
|
|
47
|
+
return text.slice(0, index);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function extname(input) {
|
|
51
|
+
const base = basename(input);
|
|
52
|
+
const index = base.lastIndexOf(".");
|
|
53
|
+
return index > 0 ? base.slice(index) : "";
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function isAbsolute(input) {
|
|
57
|
+
return String(input || "").startsWith("/");
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const sep = "/";
|
|
61
|
+
const delimiter = ":";
|
|
62
|
+
|
|
63
|
+
const posix = Object.freeze({
|
|
64
|
+
basename,
|
|
65
|
+
delimiter,
|
|
66
|
+
dirname,
|
|
67
|
+
extname,
|
|
68
|
+
isAbsolute,
|
|
69
|
+
join,
|
|
70
|
+
normalize,
|
|
71
|
+
resolve,
|
|
72
|
+
sep,
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
const win32 = posix;
|
|
76
|
+
|
|
77
|
+
export { basename, delimiter, dirname, extname, isAbsolute, join, normalize, posix, resolve, sep, win32 };
|
|
78
|
+
export default posix;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
const fallbackTimeOrigin = Date.now() - (
|
|
2
|
+
typeof process !== "undefined" && typeof process.uptime === "function"
|
|
3
|
+
? process.uptime() * 1000
|
|
4
|
+
: 0
|
|
5
|
+
);
|
|
6
|
+
const performance = globalThis.performance ?? Object.freeze({
|
|
7
|
+
now: () => Date.now() - fallbackTimeOrigin,
|
|
8
|
+
timeOrigin: fallbackTimeOrigin,
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
export { performance };
|
|
12
|
+
export default { performance };
|