@greenpandastudios/aug-cli 0.19.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 +21 -0
- package/README.md +13 -0
- package/THIRD_PARTY_NOTICES.md +18 -0
- package/bin/aug.mjs +3 -0
- package/docs/api/crypto.md +351 -0
- package/docs/api/io.md +207 -0
- package/docs/api/json.md +21 -0
- package/docs/api/memory.md +109 -0
- package/docs/api/time.md +54 -0
- package/docs/api/web.md +184 -0
- package/docs/assets/benchmarks/execution.svg +2978 -0
- package/docs/assets/benchmarks/http.svg +1674 -0
- package/docs/assets/benchmarks/improvements.svg +2315 -0
- package/docs/assets/benchmarks/memory.svg +1891 -0
- package/docs/benchmark-baseline.json +1087 -0
- package/docs/benchmark-results.json +91123 -0
- package/docs/benchmarks.json +38 -0
- package/docs/compatibility.md +42 -0
- package/docs/concurrency-implementation.md +18 -0
- package/docs/diagnostics.md +97 -0
- package/docs/docker.md +35 -0
- package/docs/example-projects.json +26 -0
- package/docs/examples/approved-design/counters.md +253 -0
- package/docs/examples/approved-design/dependencies/august/0.19.0/io/contracts.md +395 -0
- package/docs/examples/approved-design/domain/app.md +165 -0
- package/docs/examples/approved-design/domain/export.md +83 -0
- package/docs/examples/approved-design/domain/models.md +80 -0
- package/docs/examples/approved-design/domain/numbers.md +248 -0
- package/docs/examples/approved-design/index.md +39 -0
- package/docs/examples/approved-design/main-yaml.md +24 -0
- package/docs/examples/approved-design/main.md +215 -0
- package/docs/examples/benchmark/index.md +33 -0
- package/docs/examples/benchmark/main-yaml.md +17 -0
- package/docs/examples/benchmark/main.md +117 -0
- package/docs/examples/cli-args/index.md +32 -0
- package/docs/examples/cli-args/main.md +107 -0
- package/docs/examples/collections/index.md +32 -0
- package/docs/examples/collections/main.md +118 -0
- package/docs/examples/collections-benchmark/index.md +34 -0
- package/docs/examples/collections-benchmark/main.md +115 -0
- package/docs/examples/cpu-benchmark/index.md +34 -0
- package/docs/examples/cpu-benchmark/main.md +90 -0
- package/docs/examples/developer-workflow/calculator.md +357 -0
- package/docs/examples/developer-workflow/dependencies/august/0.19.0/io/contracts.md +395 -0
- package/docs/examples/developer-workflow/index.md +37 -0
- package/docs/examples/developer-workflow/logging/console.md +124 -0
- package/docs/examples/developer-workflow/logging/export.md +70 -0
- package/docs/examples/developer-workflow/logging/logger.md +111 -0
- package/docs/examples/developer-workflow/main.md +172 -0
- package/docs/examples/drop/index.md +33 -0
- package/docs/examples/drop/main.md +85 -0
- package/docs/examples/drop/resource.md +95 -0
- package/docs/examples/errors/errors.md +85 -0
- package/docs/examples/errors/index.md +33 -0
- package/docs/examples/errors/main.md +92 -0
- package/docs/examples/ffi/index.md +33 -0
- package/docs/examples/ffi/main.md +75 -0
- package/docs/examples/ffi/native.md +93 -0
- package/docs/examples/generic-di/dependencies/august/0.19.0/io/contracts.md +395 -0
- package/docs/examples/generic-di/index.md +33 -0
- package/docs/examples/generic-di/main.md +111 -0
- package/docs/examples/generic-di/types.md +180 -0
- package/docs/examples/generics/index.md +33 -0
- package/docs/examples/generics/main.md +120 -0
- package/docs/examples/generics/types.md +189 -0
- package/docs/examples/hello/app/export.md +67 -0
- package/docs/examples/hello/app/greeter.md +190 -0
- package/docs/examples/hello/dependencies/august/0.19.0/io/contracts.md +395 -0
- package/docs/examples/hello/index.md +37 -0
- package/docs/examples/hello/logging/console.md +121 -0
- package/docs/examples/hello/logging/export.md +71 -0
- package/docs/examples/hello/logging/logger.md +120 -0
- package/docs/examples/hello/main.md +115 -0
- package/docs/examples/http-benchmark/index.md +35 -0
- package/docs/examples/http-benchmark/main.md +79 -0
- package/docs/examples/http-benchmark/routes.md +88 -0
- package/docs/examples/index.md +60 -0
- package/docs/examples/interceptors/app.md +250 -0
- package/docs/examples/interceptors/dependencies/august/0.19.0/io/contracts.md +395 -0
- package/docs/examples/interceptors/index.md +35 -0
- package/docs/examples/interceptors/interceptors.md +284 -0
- package/docs/examples/interceptors/logging.md +155 -0
- package/docs/examples/interceptors/main.md +162 -0
- package/docs/examples/json-benchmark/data.md +71 -0
- package/docs/examples/json-benchmark/dependencies/august/0.19.0/json/contracts.md +103 -0
- package/docs/examples/json-benchmark/index.md +35 -0
- package/docs/examples/json-benchmark/main.md +131 -0
- package/docs/examples/new-syntax/console.md +118 -0
- package/docs/examples/new-syntax/dependencies/august/0.19.0/io/contracts.md +395 -0
- package/docs/examples/new-syntax/greeter.md +145 -0
- package/docs/examples/new-syntax/index.md +36 -0
- package/docs/examples/new-syntax/logger.md +111 -0
- package/docs/examples/new-syntax/main.md +135 -0
- package/docs/examples/new-syntax/math.md +79 -0
- package/docs/examples/oidc-login/client/contracts.md +151 -0
- package/docs/examples/oidc-login/client/endpoints.md +263 -0
- package/docs/examples/oidc-login/client/export.md +107 -0
- package/docs/examples/oidc-login/client/login.md +515 -0
- package/docs/examples/oidc-login/client/logout.md +249 -0
- package/docs/examples/oidc-login/client/protocol.md +595 -0
- package/docs/examples/oidc-login/client/session.md +297 -0
- package/docs/examples/oidc-login/client/views.md +144 -0
- package/docs/examples/oidc-login/common/export.md +115 -0
- package/docs/examples/oidc-login/common/headers.md +162 -0
- package/docs/examples/oidc-login/common/keys.md +336 -0
- package/docs/examples/oidc-login/common/settings.md +116 -0
- package/docs/examples/oidc-login/common/views.md +103 -0
- package/docs/examples/oidc-login/dependencies/august/0.19.0/crypto/contracts.md +925 -0
- package/docs/examples/oidc-login/dependencies/august/0.19.0/crypto/jose.md +434 -0
- package/docs/examples/oidc-login/dependencies/august/0.19.0/json/contracts.md +103 -0
- package/docs/examples/oidc-login/dependencies/august/0.19.0/memory/store.md +374 -0
- package/docs/examples/oidc-login/dependencies/august/0.19.0/time/contracts.md +150 -0
- package/docs/examples/oidc-login/dependencies/august/0.19.0/web/contracts.md +532 -0
- package/docs/examples/oidc-login/index.md +57 -0
- package/docs/examples/oidc-login/main-yaml.md +28 -0
- package/docs/examples/oidc-login/main.md +283 -0
- package/docs/examples/oidc-login/provider/authorization.md +457 -0
- package/docs/examples/oidc-login/provider/contracts.md +267 -0
- package/docs/examples/oidc-login/provider/credentials.md +148 -0
- package/docs/examples/oidc-login/provider/discovery.md +215 -0
- package/docs/examples/oidc-login/provider/export.md +131 -0
- package/docs/examples/oidc-login/provider/token.md +364 -0
- package/docs/examples/oidc-login/provider/userinfo.md +228 -0
- package/docs/examples/oidc-login/provider/views.md +137 -0
- package/docs/examples/ownership/counter.md +140 -0
- package/docs/examples/ownership/index.md +33 -0
- package/docs/examples/ownership/main.md +90 -0
- package/docs/examples/ownership-transfer/dependencies/august/0.19.0/io/contracts.md +395 -0
- package/docs/examples/ownership-transfer/index.md +33 -0
- package/docs/examples/ownership-transfer/main.md +125 -0
- package/docs/examples/ownership-transfer/resource.md +150 -0
- package/docs/examples/packages-app/dependencies/packages/@example/aug-math/0.1.0/arithmetic.md +117 -0
- package/docs/examples/packages-app/index.md +34 -0
- package/docs/examples/packages-app/main-yaml.md +18 -0
- package/docs/examples/packages-app/main.md +80 -0
- package/docs/examples/packages-math/aug-package-json.md +24 -0
- package/docs/examples/packages-math/index.md +36 -0
- package/docs/examples/packages-math/package-json.md +25 -0
- package/docs/examples/packages-math/src/arithmetic.md +121 -0
- package/docs/examples/packages-math/src/export.md +63 -0
- package/docs/examples/startup-benchmark/index.md +34 -0
- package/docs/examples/startup-benchmark/main.md +68 -0
- package/docs/examples/visibility/counter.md +142 -0
- package/docs/examples/visibility/index.md +33 -0
- package/docs/examples/visibility/main.md +96 -0
- package/docs/examples.json +47 -0
- package/docs/getting-started.md +5 -0
- package/docs/grammar.md +136 -0
- package/docs/implementation-map.md +106 -0
- package/docs/index.md +46 -0
- package/docs/language-conformance.md +30 -0
- package/docs/language-constructs.md +1461 -0
- package/docs/language-design-audit.md +147 -0
- package/docs/maintaining-docs.md +43 -0
- package/docs/packages.md +184 -0
- package/docs/performance.md +535 -0
- package/docs/production-readiness.md +39 -0
- package/docs/reference.md +361 -0
- package/docs/release-review.md +23 -0
- package/docs/releasing.md +79 -0
- package/docs/roadmap.md +13 -0
- package/docs/specifications.md +86 -0
- package/docs/testing.md +120 -0
- package/docs/tooling.md +197 -0
- package/docs/web-implementation-plan.md +39 -0
- package/docs/web-library-gaps.md +27 -0
- package/docs/web.md +197 -0
- package/examples/approved-design/.aug-spec/august/0.19.0/io/contracts.aug +36 -0
- package/examples/approved-design/.aug-spec/august/0.19.0/io/contracts.aug.md +316 -0
- package/examples/approved-design/.aug-spec/manifest.json +14 -0
- package/examples/approved-design/counters.aug +22 -0
- package/examples/approved-design/counters.aug.md +177 -0
- package/examples/approved-design/domain/app.aug +12 -0
- package/examples/approved-design/domain/app.aug.md +97 -0
- package/examples/approved-design/domain/export.aug +5 -0
- package/examples/approved-design/domain/export.aug.md +25 -0
- package/examples/approved-design/domain/models.aug +2 -0
- package/examples/approved-design/domain/models.aug.md +30 -0
- package/examples/approved-design/domain/numbers.aug +29 -0
- package/examples/approved-design/domain/numbers.aug.md +141 -0
- package/examples/approved-design/main.aug +26 -0
- package/examples/approved-design/main.aug.md +108 -0
- package/examples/approved-design/main.yaml +8 -0
- package/examples/benchmark/.aug-spec/manifest.json +7 -0
- package/examples/benchmark/main.aug +17 -0
- package/examples/benchmark/main.aug.md +43 -0
- package/examples/benchmark/main.yaml +1 -0
- package/examples/cli-args/.aug-spec/manifest.json +7 -0
- package/examples/cli-args/main.aug +15 -0
- package/examples/cli-args/main.aug.md +38 -0
- package/examples/collections/.aug-spec/manifest.json +7 -0
- package/examples/collections/main.aug +18 -0
- package/examples/collections/main.aug.md +43 -0
- package/examples/developer-workflow/.aug-spec/august/0.19.0/io/contracts.aug +36 -0
- package/examples/developer-workflow/.aug-spec/august/0.19.0/io/contracts.aug.md +316 -0
- package/examples/developer-workflow/.aug-spec/manifest.json +13 -0
- package/examples/developer-workflow/calculator.aug +55 -0
- package/examples/developer-workflow/calculator.aug.md +228 -0
- package/examples/developer-workflow/logging/console.aug +8 -0
- package/examples/developer-workflow/logging/console.aug.md +67 -0
- package/examples/developer-workflow/logging/export.aug +2 -0
- package/examples/developer-workflow/logging/export.aug.md +19 -0
- package/examples/developer-workflow/logging/logger.aug +6 -0
- package/examples/developer-workflow/logging/logger.aug.md +57 -0
- package/examples/developer-workflow/main.aug +25 -0
- package/examples/developer-workflow/main.aug.md +79 -0
- package/examples/drop/.aug-spec/manifest.json +8 -0
- package/examples/drop/main.aug +3 -0
- package/examples/drop/main.aug.md +35 -0
- package/examples/drop/resource.aug +8 -0
- package/examples/drop/resource.aug.md +44 -0
- package/examples/errors/.aug-spec/manifest.json +8 -0
- package/examples/errors/errors.aug +6 -0
- package/examples/errors/errors.aug.md +33 -0
- package/examples/errors/main.aug +7 -0
- package/examples/errors/main.aug.md +36 -0
- package/examples/ffi/.aug-spec/manifest.json +8 -0
- package/examples/ffi/main.aug +2 -0
- package/examples/ffi/main.aug.md +27 -0
- package/examples/ffi/native.aug +6 -0
- package/examples/ffi/native.aug.md +43 -0
- package/examples/generic-di/.aug-spec/august/0.19.0/io/contracts.aug +36 -0
- package/examples/generic-di/.aug-spec/august/0.19.0/io/contracts.aug.md +316 -0
- package/examples/generic-di/.aug-spec/manifest.json +10 -0
- package/examples/generic-di/main.aug +9 -0
- package/examples/generic-di/main.aug.md +49 -0
- package/examples/generic-di/types.aug +17 -0
- package/examples/generic-di/types.aug.md +124 -0
- package/examples/generics/.aug-spec/manifest.json +8 -0
- package/examples/generics/main.aug +9 -0
- package/examples/generics/main.aug.md +58 -0
- package/examples/generics/types.aug +19 -0
- package/examples/generics/types.aug.md +132 -0
- package/examples/hello/.aug-spec/august/0.19.0/io/contracts.aug +36 -0
- package/examples/hello/.aug-spec/august/0.19.0/io/contracts.aug.md +316 -0
- package/examples/hello/.aug-spec/manifest.json +14 -0
- package/examples/hello/app/export.aug +1 -0
- package/examples/hello/app/export.aug.md +17 -0
- package/examples/hello/app/greeter.aug +22 -0
- package/examples/hello/app/greeter.aug.md +109 -0
- package/examples/hello/logging/console.aug +7 -0
- package/examples/hello/logging/console.aug.md +65 -0
- package/examples/hello/logging/export.aug +2 -0
- package/examples/hello/logging/export.aug.md +19 -0
- package/examples/hello/logging/logger.aug +9 -0
- package/examples/hello/logging/logger.aug.md +59 -0
- package/examples/hello/main.aug +9 -0
- package/examples/hello/main.aug.md +49 -0
- package/examples/interceptors/.aug-spec/august/0.19.0/io/contracts.aug +36 -0
- package/examples/interceptors/.aug-spec/august/0.19.0/io/contracts.aug.md +316 -0
- package/examples/interceptors/.aug-spec/manifest.json +12 -0
- package/examples/interceptors/app.aug +28 -0
- package/examples/interceptors/app.aug.md +162 -0
- package/examples/interceptors/interceptors.aug +40 -0
- package/examples/interceptors/interceptors.aug.md +180 -0
- package/examples/interceptors/logging.aug +12 -0
- package/examples/interceptors/logging.aug.md +96 -0
- package/examples/interceptors/main.aug +22 -0
- package/examples/interceptors/main.aug.md +76 -0
- package/examples/new-syntax/.aug-spec/august/0.19.0/io/contracts.aug +36 -0
- package/examples/new-syntax/.aug-spec/august/0.19.0/io/contracts.aug.md +316 -0
- package/examples/new-syntax/.aug-spec/manifest.json +13 -0
- package/examples/new-syntax/console.aug +7 -0
- package/examples/new-syntax/console.aug.md +63 -0
- package/examples/new-syntax/greeter.aug +10 -0
- package/examples/new-syntax/greeter.aug.md +89 -0
- package/examples/new-syntax/logger.aug +6 -0
- package/examples/new-syntax/logger.aug.md +57 -0
- package/examples/new-syntax/main.aug +12 -0
- package/examples/new-syntax/main.aug.md +64 -0
- package/examples/new-syntax/math.aug +3 -0
- package/examples/new-syntax/math.aug.md +29 -0
- package/examples/oidc-login/.aug-spec/august/0.19.0/crypto/contracts.aug +73 -0
- package/examples/oidc-login/.aug-spec/august/0.19.0/crypto/contracts.aug.md +791 -0
- package/examples/oidc-login/.aug-spec/august/0.19.0/crypto/jose.aug +68 -0
- package/examples/oidc-login/.aug-spec/august/0.19.0/crypto/jose.aug.md +266 -0
- package/examples/oidc-login/.aug-spec/august/0.19.0/json/contracts.aug +6 -0
- package/examples/oidc-login/.aug-spec/august/0.19.0/json/contracts.aug.md +55 -0
- package/examples/oidc-login/.aug-spec/august/0.19.0/memory/store.aug +45 -0
- package/examples/oidc-login/.aug-spec/august/0.19.0/memory/store.aug.md +250 -0
- package/examples/oidc-login/.aug-spec/august/0.19.0/time/contracts.aug +11 -0
- package/examples/oidc-login/.aug-spec/august/0.19.0/time/contracts.aug.md +96 -0
- package/examples/oidc-login/.aug-spec/august/0.19.0/web/contracts.aug +58 -0
- package/examples/oidc-login/.aug-spec/august/0.19.0/web/contracts.aug.md +420 -0
- package/examples/oidc-login/.aug-spec/manifest.json +40 -0
- package/examples/oidc-login/README.md +29 -0
- package/examples/oidc-login/client/contracts.aug +7 -0
- package/examples/oidc-login/client/contracts.aug.md +80 -0
- package/examples/oidc-login/client/endpoints.aug +21 -0
- package/examples/oidc-login/client/endpoints.aug.md +161 -0
- package/examples/oidc-login/client/export.aug +7 -0
- package/examples/oidc-login/client/export.aug.md +29 -0
- package/examples/oidc-login/client/login.aug +58 -0
- package/examples/oidc-login/client/login.aug.md +331 -0
- package/examples/oidc-login/client/logout.aug +18 -0
- package/examples/oidc-login/client/logout.aug.md +150 -0
- package/examples/oidc-login/client/protocol.aug +106 -0
- package/examples/oidc-login/client/protocol.aug.md +326 -0
- package/examples/oidc-login/client/session.aug +34 -0
- package/examples/oidc-login/client/session.aug.md +155 -0
- package/examples/oidc-login/client/views.aug +21 -0
- package/examples/oidc-login/client/views.aug.md +68 -0
- package/examples/oidc-login/common/export.aug +9 -0
- package/examples/oidc-login/common/export.aug.md +33 -0
- package/examples/oidc-login/common/headers.aug +11 -0
- package/examples/oidc-login/common/headers.aug.md +79 -0
- package/examples/oidc-login/common/keys.aug +37 -0
- package/examples/oidc-login/common/keys.aug.md +207 -0
- package/examples/oidc-login/common/settings.aug +4 -0
- package/examples/oidc-login/common/settings.aug.md +47 -0
- package/examples/oidc-login/common/views.aug +16 -0
- package/examples/oidc-login/common/views.aug.md +34 -0
- package/examples/oidc-login/main.aug +39 -0
- package/examples/oidc-login/main.aug.md +166 -0
- package/examples/oidc-login/main.yaml +12 -0
- package/examples/oidc-login/provider/authorization.aug +59 -0
- package/examples/oidc-login/provider/authorization.aug.md +264 -0
- package/examples/oidc-login/provider/contracts.aug +15 -0
- package/examples/oidc-login/provider/contracts.aug.md +193 -0
- package/examples/oidc-login/provider/credentials.aug +10 -0
- package/examples/oidc-login/provider/credentials.aug.md +64 -0
- package/examples/oidc-login/provider/discovery.aug +13 -0
- package/examples/oidc-login/provider/discovery.aug.md +133 -0
- package/examples/oidc-login/provider/export.aug +13 -0
- package/examples/oidc-login/provider/export.aug.md +41 -0
- package/examples/oidc-login/provider/token.aug +37 -0
- package/examples/oidc-login/provider/token.aug.md +223 -0
- package/examples/oidc-login/provider/userinfo.aug +26 -0
- package/examples/oidc-login/provider/userinfo.aug.md +104 -0
- package/examples/oidc-login/provider/views.aug +18 -0
- package/examples/oidc-login/provider/views.aug.md +63 -0
- package/examples/ownership/.aug-spec/manifest.json +8 -0
- package/examples/ownership/counter.aug +14 -0
- package/examples/ownership/counter.aug.md +85 -0
- package/examples/ownership/main.aug +4 -0
- package/examples/ownership/main.aug.md +38 -0
- package/examples/ownership-transfer/.aug-spec/august/0.19.0/io/contracts.aug +36 -0
- package/examples/ownership-transfer/.aug-spec/august/0.19.0/io/contracts.aug.md +316 -0
- package/examples/ownership-transfer/.aug-spec/manifest.json +10 -0
- package/examples/ownership-transfer/main.aug +9 -0
- package/examples/ownership-transfer/main.aug.md +63 -0
- package/examples/ownership-transfer/resource.aug +16 -0
- package/examples/ownership-transfer/resource.aug.md +89 -0
- package/examples/packages/README.md +15 -0
- package/examples/packages/app/.aug-spec/manifest.json +9 -0
- package/examples/packages/app/.aug-spec/packages/@example/aug-math/0.1.0/arithmetic.aug +9 -0
- package/examples/packages/app/.aug-spec/packages/@example/aug-math/0.1.0/arithmetic.aug.md +63 -0
- package/examples/packages/app/main.aug +2 -0
- package/examples/packages/app/main.aug.md +33 -0
- package/examples/packages/app/main.yaml +2 -0
- package/examples/packages/math/.aug-spec/manifest.json +8 -0
- package/examples/packages/math/README.md +3 -0
- package/examples/packages/math/aug-package.json +8 -0
- package/examples/packages/math/package.json +9 -0
- package/examples/packages/math/src/arithmetic.aug +8 -0
- package/examples/packages/math/src/arithmetic.aug.md +63 -0
- package/examples/packages/math/src/export.aug +1 -0
- package/examples/packages/math/src/export.aug.md +17 -0
- package/examples/visibility/.aug-spec/manifest.json +8 -0
- package/examples/visibility/counter.aug +14 -0
- package/examples/visibility/counter.aug.md +87 -0
- package/examples/visibility/main.aug +7 -0
- package/examples/visibility/main.aug.md +39 -0
- package/package.json +50 -0
- package/runtime/aug_crypto.c +121 -0
- package/runtime/aug_html.c +93 -0
- package/runtime/aug_http.c +829 -0
- package/runtime/aug_json.c +165 -0
- package/runtime/aug_runtime.c +792 -0
- package/runtime/aug_runtime.h +245 -0
- package/runtime/aug_tasks.c +172 -0
- package/runtime/aug_time.c +5 -0
- package/runtime/aug_values.c +80 -0
- package/scripts/bootstrap-native.mjs +121 -0
- package/scripts/native-dependencies.lock.json +65 -0
- package/scripts/native-home.mjs +11 -0
- package/src/actions.js +109 -0
- package/src/ast.js +19 -0
- package/src/builtins.js +93 -0
- package/src/checker.js +2896 -0
- package/src/cli.js +344 -0
- package/src/codegen.js +1159 -0
- package/src/config.js +149 -0
- package/src/continuation.js +110 -0
- package/src/di.js +24 -0
- package/src/documentation.js +27 -0
- package/src/editor.js +782 -0
- package/src/effects.js +29 -0
- package/src/fixes.js +222 -0
- package/src/formatter.js +296 -0
- package/src/freshness.js +154 -0
- package/src/help.js +212 -0
- package/src/html.js +27 -0
- package/src/http-policies.js +90 -0
- package/src/inference.js +16 -0
- package/src/interceptors.js +70 -0
- package/src/javadoc.js +67 -0
- package/src/lexer.js +199 -0
- package/src/libraries.js +31 -0
- package/src/lsp.js +180 -0
- package/src/native.js +144 -0
- package/src/navigation.js +162 -0
- package/src/openapi.js +220 -0
- package/src/ownership.js +232 -0
- package/src/package-manager.js +299 -0
- package/src/parser.js +1155 -0
- package/src/policies.js +130 -0
- package/src/project-init.js +19 -0
- package/src/project.js +292 -0
- package/src/schemas.js +62 -0
- package/src/semantic.js +255 -0
- package/src/spec.js +738 -0
- package/src/testing.js +186 -0
- package/src/types.js +10 -0
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
{
|
|
2
|
+
"format": 1,
|
|
3
|
+
"platforms": ["darwin", "linux"],
|
|
4
|
+
"dependencies": [
|
|
5
|
+
{
|
|
6
|
+
"name": "cmake",
|
|
7
|
+
"platforms": ["darwin"],
|
|
8
|
+
"version": "4.1.1",
|
|
9
|
+
"url": "https://github.com/Kitware/CMake/releases/download/v4.1.1/cmake-4.1.1-macos-universal.tar.gz",
|
|
10
|
+
"archive": "cmake.tar.gz",
|
|
11
|
+
"sha256": "3cd1da5341618645bdc85a3b99e273f29c4d48db2f545925a658db992e61f6f9"
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
"name": "gmp",
|
|
15
|
+
"version": "6.3.0",
|
|
16
|
+
"url": "https://ftp.gnu.org/gnu/gmp/gmp-6.3.0.tar.xz",
|
|
17
|
+
"archive": "gmp.tar.xz",
|
|
18
|
+
"sha256": "a3c2b80201b89e68616f4ad30bc66aee4927c3ce50e33929ca819d5c43538898"
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
"name": "nettle",
|
|
22
|
+
"version": "3.10.2",
|
|
23
|
+
"url": "https://ftp.gnu.org/gnu/nettle/nettle-3.10.2.tar.gz",
|
|
24
|
+
"archive": "nettle.tar.gz",
|
|
25
|
+
"sha256": "fe9ff51cb1f2abb5e65a6b8c10a92da0ab5ab6eaf26e7fc2b675c45f1fb519b5"
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
"name": "gnutls",
|
|
29
|
+
"version": "3.8.13",
|
|
30
|
+
"url": "https://www.gnupg.org/ftp/gcrypt/gnutls/v3.8/gnutls-3.8.13.tar.xz",
|
|
31
|
+
"archive": "gnutls.tar.xz",
|
|
32
|
+
"sha256": "ffed8ec1bf09c2426d4f14aae377de4753b53e537d685e604e99a8b16ca9c97e"
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
"name": "pkgconf",
|
|
36
|
+
"version": "2.3.0",
|
|
37
|
+
"url": "https://distfiles.ariadne.space/pkgconf/pkgconf-2.3.0.tar.xz",
|
|
38
|
+
"archive": "pkgconf.tar.xz",
|
|
39
|
+
"sha256": "3a9080ac51d03615e7c1910a0a2a8df08424892b5f13b0628a204d3fcce0ea8b"
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
"name": "libwebsockets",
|
|
43
|
+
"version": "5.0-stable",
|
|
44
|
+
"revision": "a842936f881921b6462b3328cce8e700b7a7ecd2",
|
|
45
|
+
"url": "https://codeload.github.com/warmcat/libwebsockets/tar.gz/a842936f881921b6462b3328cce8e700b7a7ecd2",
|
|
46
|
+
"archive": "libwebsockets.tar.gz",
|
|
47
|
+
"sha256": "aec47546b8b298fb10b021896873637d9bd1efcb9e0f6f165ac045f24e275cc2"
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
"name": "yyjson",
|
|
51
|
+
"version": "0.12.0",
|
|
52
|
+
"url": "https://codeload.github.com/ibireme/yyjson/tar.gz/refs/tags/0.12.0",
|
|
53
|
+
"archive": "yyjson.tar.gz",
|
|
54
|
+
"sha256": "b16246f617b2a136c78d73e5e2647c6f1de1313e46678062985bdcf1f40bb75d"
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
"name": "minicoro",
|
|
58
|
+
"version": "0.1.3",
|
|
59
|
+
"revision": "8673ca62ed938c0b436bc2a548f172865f65bf1d",
|
|
60
|
+
"url": "https://codeload.github.com/edubart/minicoro/tar.gz/8673ca62ed938c0b436bc2a548f172865f65bf1d",
|
|
61
|
+
"archive": "minicoro-0.1.3.tar.gz",
|
|
62
|
+
"sha256": "604a7b57615f7bbf38e72bad43e8f12d03b37aa8b9573f48bd056925924cc57d"
|
|
63
|
+
}
|
|
64
|
+
]
|
|
65
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { readFileSync } from 'node:fs';
|
|
2
|
+
import { homedir } from 'node:os';
|
|
3
|
+
import { join, resolve } from 'node:path';
|
|
4
|
+
|
|
5
|
+
/** Source checkouts use a local build; installations use a writable, versioned cache. */
|
|
6
|
+
export function nativeHome(compilerRoot) {
|
|
7
|
+
if (process.env.AUG_NATIVE_HOME) return resolve(process.env.AUG_NATIVE_HOME);
|
|
8
|
+
const manifest = JSON.parse(readFileSync(join(compilerRoot, 'package.json'), 'utf8'));
|
|
9
|
+
return manifest.private ? join(compilerRoot, '.aug-native') :
|
|
10
|
+
join(homedir(), '.cache', 'augscript', 'native', manifest.version, `${process.platform}-${process.arch}`);
|
|
11
|
+
}
|
package/src/actions.js
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { schemaType } from "./schemas.js";
|
|
2
|
+
/** Form transport uses the same checked record shape as the server decoder. */
|
|
3
|
+
export function actionSchema(project, type, seen = new Set()) {
|
|
4
|
+
const result = { kind: type.name, optional: !!type.optional, nullable: type.nullable };
|
|
5
|
+
if (seen.has(type.id))
|
|
6
|
+
return { ...result, kind: 'json' };
|
|
7
|
+
if (type.def?.node.kind === 'class' && type.def.node.record) {
|
|
8
|
+
const node = type.def.node, types = new Map(node.typeParams.map((name, index) => [name, type.args[index]]));
|
|
9
|
+
result.kind = 'record';
|
|
10
|
+
result.fields = Object.fromEntries(node.fields.map(field => [field.name, actionSchema(project, schemaType(project, field.type, type.def.file, types), new Set([...seen, type.id]))]));
|
|
11
|
+
}
|
|
12
|
+
return result;
|
|
13
|
+
}
|
|
14
|
+
/** Only event-to-HTTP transport runs in the browser; application handlers remain August. */
|
|
15
|
+
export const actionTransport = `(() => {
|
|
16
|
+
if (globalThis.__augActions) return;
|
|
17
|
+
globalThis.__augActions = true;
|
|
18
|
+
const own = (object,key) => Object.prototype.hasOwnProperty.call(object,key);
|
|
19
|
+
const minInt = -(1n << 63n), maxInt = (1n << 63n)-1n;
|
|
20
|
+
// Captures carry JSON text so JavaScript never rounds a native int64 token.
|
|
21
|
+
function parse(text) {
|
|
22
|
+
let at=0;
|
|
23
|
+
const space=()=>{while(/[ \\t\\r\\n]/.test(text[at]||'!'))at++;};
|
|
24
|
+
function read(depth=0) {
|
|
25
|
+
if(depth>64)throw Error('JSON nesting exceeds 64 levels');space();const start=at, token=text[at++];
|
|
26
|
+
if(token==='"') {
|
|
27
|
+
while(at<text.length) {const next=text[at++];if(next==='"')return JSON.parse(text.slice(start,at));if(next==='\\\\')at++;}
|
|
28
|
+
} else if(token==='[' || token==='{') {
|
|
29
|
+
const object=token==='{', end=object?'}':']', result=object?Object.create(null):[];
|
|
30
|
+
space();if(text[at]===end){at++;return result;}
|
|
31
|
+
while(at<text.length) {
|
|
32
|
+
if(object) {
|
|
33
|
+
space();if(text[at]!=='"')break;const name=read(depth+1);space();
|
|
34
|
+
if(text[at++]!==':'||own(result,name))break;result[name]=read(depth+1);
|
|
35
|
+
} else result.push(read(depth+1));
|
|
36
|
+
space();const next=text[at++];if(next===end)return result;if(next!==',')break;
|
|
37
|
+
}
|
|
38
|
+
} else {
|
|
39
|
+
at=start;
|
|
40
|
+
for(const [word,value] of [['true',true],['false',false],['null',null]])if(text.startsWith(word,at)){at+=word.length;return value;}
|
|
41
|
+
const number=/^-?(0|[1-9][0-9]*)([.][0-9]+)?([eE][+-]?[0-9]+)?/.exec(text.slice(at));
|
|
42
|
+
if(number) {
|
|
43
|
+
at+=number[0].length;
|
|
44
|
+
if(!number[2]&&!number[3]){const value=BigInt(number[0]);if(value>=minInt&&value<=maxInt)return value;}
|
|
45
|
+
else if(Number.isFinite(Number(number[0])))return Number(number[0]);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
throw Error('Invalid JSON value');
|
|
49
|
+
}
|
|
50
|
+
const result=read();space();if(at!==text.length)throw Error('Invalid JSON value');return result;
|
|
51
|
+
}
|
|
52
|
+
function json(value,depth=0) {
|
|
53
|
+
if(depth>64)throw Error('JSON nesting exceeds 64 levels');
|
|
54
|
+
if(typeof value==='bigint')return value.toString();
|
|
55
|
+
if(Array.isArray(value))return '['+value.map(item=>json(item,depth+1)).join(',')+']';
|
|
56
|
+
if(value!==null&&typeof value==='object')return '{'+Object.entries(value).map(([name,item])=>JSON.stringify(name)+':'+json(item,depth+1)).join(',')+'}';
|
|
57
|
+
return JSON.stringify(value);
|
|
58
|
+
}
|
|
59
|
+
function scalar(text,schema,label) {
|
|
60
|
+
if (text === 'null' && schema.nullable) return null;
|
|
61
|
+
if (schema.kind === 'string') return text;
|
|
62
|
+
if (schema.kind === 'bool') {if (text === 'true') return true;if (text === 'false') return false;}
|
|
63
|
+
if (schema.kind === 'int' || schema.kind === 'c_int') {if (/^-?(0|[1-9][0-9]*)$/.test(text)) {const value=BigInt(text), min=schema.kind==='c_int'?-(1n<<31n):minInt, max=schema.kind==='c_int'?(1n<<31n)-1n:maxInt;if(value>=min&&value<=max)return value;}}
|
|
64
|
+
if (schema.kind === 'float') {if (/^-?(0|[1-9][0-9]*)([.][0-9]+)?([eE][+-]?[0-9]+)?$/.test(text) && Number.isFinite(Number(text))) return Number(text);}
|
|
65
|
+
if (['List','Set','Tuple','Map','record','Json','json'].includes(schema.kind)) return parse(text);
|
|
66
|
+
throw Error(label + ' has an invalid ' + schema.kind + ' value');
|
|
67
|
+
}
|
|
68
|
+
function formValue(form,schema) {
|
|
69
|
+
const data = new FormData(form), value = Object.create(null), fields = schema.fields;
|
|
70
|
+
for (const [name,item] of data) {
|
|
71
|
+
if (!own(fields,name)) throw Error('Unknown form field ' + name);
|
|
72
|
+
if (own(value,name)) throw Error('Duplicate form field ' + name);
|
|
73
|
+
if (typeof item !== 'string') throw Error('File fields require an upload endpoint');
|
|
74
|
+
if (item === '' && fields[name].optional) continue;
|
|
75
|
+
value[name] = scalar(item,fields[name],name);
|
|
76
|
+
}
|
|
77
|
+
for (const [name,field] of Object.entries(fields)) if (!field.optional && !own(value,name)) throw Error('Missing form field ' + name);
|
|
78
|
+
return value;
|
|
79
|
+
}
|
|
80
|
+
function build(action,form) {
|
|
81
|
+
let path = action.route.path, body;
|
|
82
|
+
const query = new URLSearchParams(), headers = new Headers();
|
|
83
|
+
action.route.parameters.forEach((param,index) => {
|
|
84
|
+
if (!action.present[index] && !param.form) return;
|
|
85
|
+
const value = param.form ? formValue(form,param.schema) : parse(action.values[index]);
|
|
86
|
+
if (param.source === 'path') path = path.replace('{'+param.name+'}',encodeURIComponent(String(value)));
|
|
87
|
+
else if (param.source === 'query') query.append(param.name,String(value));
|
|
88
|
+
else if (param.source === 'header') headers.append(param.name,String(value));
|
|
89
|
+
else if (param.source === 'body') {body=json(value);headers.set('content-type','application/json');}
|
|
90
|
+
else if (param.source === 'form') {const encoded=new URLSearchParams();for(const [name,item] of Object.entries(value)) encoded.append(name,['List','Set','Tuple','Map','record','Json','json'].includes(param.schema.fields[name].kind)?json(item):item===null?'null':String(item));body=encoded;headers.set('content-type','application/x-www-form-urlencoded');}
|
|
91
|
+
});
|
|
92
|
+
const url = new URL(path+(query.size?'?'+query.toString():''),location.origin);
|
|
93
|
+
if(url.origin!==location.origin) throw Error('HTTP actions must use the application origin');
|
|
94
|
+
return {url,options:{method:action.route.method,headers,body,credentials:'same-origin',redirect:'follow'}};
|
|
95
|
+
}
|
|
96
|
+
async function send(event,element,form) {
|
|
97
|
+
event.preventDefault();if(element.dataset.augBusy) return;element.dataset.augBusy='true';
|
|
98
|
+
let output;
|
|
99
|
+
try {
|
|
100
|
+
const request=build(JSON.parse(element.dataset.augAction),form), response=await fetch(request.url,request.options);
|
|
101
|
+
if(!response.ok) {let message='Request failed ('+response.status+')';try {const problem=await response.json();message=problem.detail||problem.title||problem.error||message;}catch {}throw Error(message);}
|
|
102
|
+
if(response.redirected) location.assign(response.url);else location.reload();
|
|
103
|
+
} catch(error) {
|
|
104
|
+
output=document.createElement('p');output.setAttribute('role','alert');output.textContent=error.message||'Request failed';element.after(output);
|
|
105
|
+
} finally {delete element.dataset.augBusy;}
|
|
106
|
+
}
|
|
107
|
+
document.addEventListener('submit',event=>{const form=event.target;if(form.matches('form[data-aug-event="submit"]')) send(event,form,form);});
|
|
108
|
+
document.addEventListener('click',event=>{const button=event.target.closest('button[data-aug-event="click"]');if(button)send(event,button,button.form);});
|
|
109
|
+
})();`;
|
package/src/ast.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export function isStatement(item) {
|
|
2
|
+
return !['import', 'export', 'bind', 'composition', 'include', 'class', 'interface', 'interceptor', 'function', 'test'].includes(item.kind);
|
|
3
|
+
}
|
|
4
|
+
export function typeName(type) {
|
|
5
|
+
return (type.optional || type.nullable ? 'optional ' : '') + type.name + (type.args.length ? `<${type.args.map(typeName).join(',')}>` : '');
|
|
6
|
+
}
|
|
7
|
+
export function syntheticType(name, span) {
|
|
8
|
+
return { name, args: [], nullable: false, span };
|
|
9
|
+
}
|
|
10
|
+
/** Stored fields include constructor inputs and internal, purely initialized state. */
|
|
11
|
+
export function fieldsOf(node) {
|
|
12
|
+
return [...node.fields, ...(node.kind === 'class' ? node.stateFields ?? [] : [])];
|
|
13
|
+
}
|
|
14
|
+
export function initializationOf(node) {
|
|
15
|
+
return [...(node.stateFields ?? []).map(field => ({ kind: 'assign',
|
|
16
|
+
target: { kind: 'name', name: field.name, span: field.span }, value: field.initializer,
|
|
17
|
+
ownership: field.ownership === 'own' ? 'own' : 'managed', span: field.span })),
|
|
18
|
+
...(node.constructorBody ?? [])];
|
|
19
|
+
}
|
package/src/builtins.js
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
export const builtinTypes = {
|
|
2
|
+
int: { arity: 0 }, c_int: { arity: 0 }, float: { arity: 0 }, bool: { arity: 0 }, string: { arity: 0 }, void: { arity: 0 },
|
|
3
|
+
Error: { arity: 0 }, FileError: { arity: 0, error: true }, IndexError: { arity: 0, error: true }, ArithmeticError: { arity: 0, error: true }, ConversionError: { arity: 0, error: true },
|
|
4
|
+
List: { arity: 1 }, Set: { arity: 1 }, Map: { arity: 2 }, Tuple: { arity: -1 },
|
|
5
|
+
Bytes: { arity: 0 }, RsaPrivateKey: { arity: 0 }, RsaPublicKey: { arity: 0 },
|
|
6
|
+
CryptoError: { arity: 0, error: true }, JsonError: { arity: 0, error: true },
|
|
7
|
+
Json: { arity: 0 },
|
|
8
|
+
Task: { arity: 1 }, ConcurrencyError: { arity: 0, error: true },
|
|
9
|
+
HttpResponse: { arity: 1 }, HttpRequest: { arity: 0 }, Headers: { arity: 0 }, Html: { arity: 0 }, HttpAction: { arity: 0 },
|
|
10
|
+
ServerEvent: { arity: 1 }, HttpTestClient: { arity: 0 },
|
|
11
|
+
HttpError: { arity: 0, error: true },
|
|
12
|
+
Shared: { arity: 1 },
|
|
13
|
+
TimeError: { arity: 0, error: true },
|
|
14
|
+
Data: { arity: 0 },
|
|
15
|
+
};
|
|
16
|
+
export const errorNames = Object.keys(builtinTypes).filter(name => 'error' in builtinTypes[name]);
|
|
17
|
+
export const builtinType = (name) => ({ id: `builtin:${name}`, name,
|
|
18
|
+
kind: name === 'Error' || name === 'Data' ? 'interface' : errorNames.includes(name) ? 'class' : 'builtin', args: [], nullable: false });
|
|
19
|
+
export const builtinProperties = {
|
|
20
|
+
HttpResponse: [{ name: 'body', type: 'T', documentation: 'The typed response body.' },
|
|
21
|
+
{ name: 'status', type: 'int', documentation: 'HTTP response status.' }, { name: 'headers', type: 'Headers', documentation: 'Immutable response headers. Duplicate Set-Cookie values are preserved.' }],
|
|
22
|
+
HttpRequest: [{ name: 'method', type: 'string', documentation: 'The HTTP method.' }, { name: 'path', type: 'string', documentation: 'Decoded request path.' },
|
|
23
|
+
{ name: 'headers', type: 'Headers', documentation: 'Immutable request headers.' }, { name: 'body', type: 'Bytes', documentation: 'Bounded buffered request bytes.' }],
|
|
24
|
+
};
|
|
25
|
+
const length = { name: 'length', parameters: [], returns: 'int', documentation: 'Read the number of elements.', native: 'length' };
|
|
26
|
+
export const collectionOperations = {
|
|
27
|
+
HttpTestClient: [{ name: 'request', parameters: [{ label: 'method', type: 'string' }, { label: 'path', type: 'string' }, { label: 'headers', type: 'optional Headers' }, { label: 'body', type: 'optional Bytes' }], returns: 'HttpResponse<Bytes>', errors: ['HttpError'], documentation: 'Run this suite’s endpoint through native routing, typed binding, request-scoped DI, policies, and response serialization. No listening socket is opened. Streaming output is collected up to the configured response limit.', native: 'request' }],
|
|
28
|
+
HttpRequest: [{ name: 'form', parameters: [], returns: 'decoded', errors: ['HttpError'], documentation: 'Decode a form record inside a handler so protocol-specific error responses can be returned.', native: 'form' }],
|
|
29
|
+
Headers: [
|
|
30
|
+
{ name: 'with', parameters: [{ label: 'name', type: 'string' }, { label: 'value', type: 'string' }], returns: 'Headers', errors: ['HttpError'], documentation: 'Return new headers with one additional validated field. Header names ignore case; duplicate values remain separate.', native: 'with' },
|
|
31
|
+
{ name: 'get', parameters: [{ label: 'name', type: 'string' }], returns: 'optional string', documentation: 'Read the first case-insensitive header value, or null.', native: 'get' },
|
|
32
|
+
{ name: 'all', parameters: [{ label: 'name', type: 'string' }], returns: 'List<string>', documentation: 'Read every value of this header in wire order.', native: 'all' },
|
|
33
|
+
],
|
|
34
|
+
Json: [
|
|
35
|
+
{ name: 'stringify', parameters: [], returns: 'string', errors: ['JsonError'], documentation: 'Serialize this JSON value with checked UTF-8 escaping and exact int64 values.', native: 'stringify' },
|
|
36
|
+
{ name: 'get', parameters: [{ label: 'name', type: 'string' }], returns: 'optional Json', documentation: 'Read an object member. An absent member or JSON null returns null.', native: 'get' },
|
|
37
|
+
{ name: 'require', parameters: [{ label: 'name', type: 'string' }], returns: 'Json', errors: ['JsonError'], documentation: 'Read a required object member or raise JsonError.', native: 'require' },
|
|
38
|
+
{ name: 'string', parameters: [], returns: 'string', errors: ['JsonError'], documentation: 'Require a JSON string.', native: 'string' },
|
|
39
|
+
{ name: 'integer', parameters: [], returns: 'int', errors: ['JsonError'], documentation: 'Require an exact signed 64-bit JSON integer.', native: 'integer' },
|
|
40
|
+
{ name: 'boolean', parameters: [], returns: 'bool', errors: ['JsonError'], documentation: 'Require a JSON bool.', native: 'boolean' },
|
|
41
|
+
{ name: 'items', parameters: [], returns: 'List<Json>', errors: ['JsonError'], documentation: 'Read an immutable JSON array.', native: 'items' },
|
|
42
|
+
{ name: 'decode', parameters: [], returns: 'decoded', errors: ['JsonError'], documentation: 'Decode a checked record or data type: json.decode<Profile>(). Unknown fields, type mismatches, and validation errors are rejected.', native: 'decode' },
|
|
43
|
+
],
|
|
44
|
+
string: [
|
|
45
|
+
{ name: 'isToken', parameters: [{ label: 'min', type: 'int' }, { label: 'max', type: 'int' }], returns: 'bool', documentation: 'Require an ASCII RFC 3986 unreserved token with a bounded length.', native: 'is_token' },
|
|
46
|
+
{ ...length, documentation: 'Read the number of UTF-8 bytes. Unicode text is preserved losslessly.' },
|
|
47
|
+
{ name: 'bytes', parameters: [], returns: 'Bytes', documentation: 'Encode this string as immutable UTF-8 bytes.', native: 'bytes' },
|
|
48
|
+
{ name: 'split', parameters: [{ label: 'separator', type: 'string' }], returns: 'List<string>', documentation: 'Split at an exact separator, preserving empty parts.', native: 'split' },
|
|
49
|
+
{ name: 'startsWith', parameters: [{ label: 'prefix', type: 'string' }], returns: 'bool', documentation: 'Test an exact prefix.', native: 'starts_with' },
|
|
50
|
+
],
|
|
51
|
+
Bytes: [length,
|
|
52
|
+
{ name: 'text', parameters: [], returns: 'string', errors: ['ConversionError'], documentation: 'Decode UTF-8 strictly. Invalid input raises ConversionError; embedded NUL is preserved.', native: 'text' },
|
|
53
|
+
{ name: 'base64url', parameters: [], returns: 'string', documentation: 'Encode immutable bytes as unpadded RFC 4648 URL-safe base64.', native: 'base64url' },
|
|
54
|
+
],
|
|
55
|
+
List: [
|
|
56
|
+
{ name: 'append', parameters: [{ label: 'value', type: 'T' }], returns: 'void', changes: true,
|
|
57
|
+
documentation: 'Append an element with exclusive mutable access. Read-only and owned aliases cannot be stored here.', native: 'append' },
|
|
58
|
+
{ name: 'get', parameters: [{ label: 'index', type: 'int' }], returns: 'T', errors: ['IndexError'],
|
|
59
|
+
documentation: 'Read a zero-based position. An invalid index raises checked IndexError. Reference results grant reading.', native: 'get' },
|
|
60
|
+
{ name: 'at', parameters: [{ label: 'index', type: 'int' }], returns: 'optional T',
|
|
61
|
+
documentation: 'Read a zero-based position, returning null when it is absent. Narrow the result before using it.', native: 'at' }, length,
|
|
62
|
+
],
|
|
63
|
+
Set: [
|
|
64
|
+
{ name: 'add', parameters: [{ label: 'value', type: 'T' }], returns: 'void', changes: true,
|
|
65
|
+
documentation: 'Insert a unique element with exclusive mutable access.', native: 'add' },
|
|
66
|
+
{ name: 'contains', parameters: [{ label: 'value', type: 'T' }], returns: 'bool', documentation: 'Test structural or identity equality with a stored element.', native: 'contains' }, length,
|
|
67
|
+
],
|
|
68
|
+
Map: [
|
|
69
|
+
{ name: 'take', parameters: [{ label: 'key', type: 'K' }], returns: 'optional V', changes: true, documentation: 'Remove and return an entry under exclusive access. An absent key returns null.', native: 'take' },
|
|
70
|
+
{ name: 'set', parameters: [{ label: 'key', type: 'K' }, { label: 'value', type: 'V' }], returns: 'void', changes: true,
|
|
71
|
+
documentation: 'Insert or replace an entry with exclusive mutable access.', native: 'set' },
|
|
72
|
+
{ name: 'get', parameters: [{ label: 'key', type: 'K' }], returns: 'optional V', documentation: 'Read a value by key; an absent key returns null. contains distinguishes an absent key from a stored null.', native: 'get' },
|
|
73
|
+
{ name: 'contains', parameters: [{ label: 'key', type: 'K' }], returns: 'bool', documentation: 'Check for a key, including entries whose value is null.', native: 'contains' }, length,
|
|
74
|
+
],
|
|
75
|
+
Tuple: [{ name: 'get', parameters: [{ label: 'index', type: 'int' }], returns: 'position', documentation: 'Read a statically checked constant position. Prefer tuple destructuring when reading several positions.', native: 'get' }, length],
|
|
76
|
+
};
|
|
77
|
+
export function operationType(text, receiver, position) {
|
|
78
|
+
const optional = text.startsWith('optional '), name = text.replace(/^optional /, '').replace(/\?$/, '');
|
|
79
|
+
const generic = /^(\w+)<(.+)>$/.exec(name);
|
|
80
|
+
const type = generic ? { ...builtinType(generic[1]), args: generic[2].split(',').map(arg => operationType(arg.trim(), receiver)) } : name === 'position' ? receiver.args[position ?? -1] : name === 'T' || name === 'K' ? receiver.args[0] : name === 'V' ? receiver.args[1] : builtinType(name);
|
|
81
|
+
const nullable = optional || text.endsWith('?') || !!type?.nullable || !!type?.optional;
|
|
82
|
+
return { ...(type ?? builtinType('<error>')), nullable, optional: nullable || undefined };
|
|
83
|
+
}
|
|
84
|
+
export const builtinFunctions = [
|
|
85
|
+
{ name: 'exit', parameters: [{ label: 'status', type: 'int' }], returns: 'void', documentation: 'Exit from main with a status from 0 to 255 after cancellation and cleanup.', native: 'exit' },
|
|
86
|
+
{ name: 'c_int', parameters: [{ label: 'value', type: 'int' }], returns: 'c_int', errors: ['ConversionError'], documentation: 'Checked conversion to a signed 32-bit C int. Overflow raises ConversionError. AugScript int maps to int64_t at the C boundary.', native: 'to_c_int' },
|
|
87
|
+
{ name: 'int', parameters: [{ label: 'value', type: 'c_int' }], returns: 'int', documentation: 'Widen a C int to the signed 64-bit AugScript integer without loss.', native: 'to_int' },
|
|
88
|
+
{ name: 'print', parameters: [{ label: 'value', type: 'any' }], returns: 'void', documentation: 'Composition and test output. Other callables receive Console and declare uses console.write.', native: 'print' },
|
|
89
|
+
{ name: 'assert', parameters: [{ label: 'condition', type: 'bool' }], returns: 'void', documentation: 'Assert a bool in a test case or its setup. Catching an assertion failure cannot make the case pass; every case must execute an assertion.', native: 'assert' },
|
|
90
|
+
{ name: 'arguments', parameters: [], returns: 'List<string>', documentation: 'Composition arguments. Other callables receive the Arguments capability.', native: 'arguments' },
|
|
91
|
+
{ name: 'read_file', parameters: [{ label: 'path', type: 'string' }], returns: 'string', errors: ['FileError'], documentation: 'Root-only UTF-8 text input. Other callables receive FileReader. Invalid Unicode and NUL raise FileError.', native: 'read_file' },
|
|
92
|
+
{ name: 'write_file', parameters: [{ label: 'path', type: 'string' }, { label: 'content', type: 'string' }], returns: 'void', errors: ['FileError'], documentation: 'Root-only UTF-8 text output. Other callables receive FileWriter.', native: 'write_file' },
|
|
93
|
+
];
|