@voxgig/sdkgen-langpack 0.0.1
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/.sdk/model/target/dart.aon +63 -0
- package/.sdk/model/target/haskell.aon +72 -0
- package/.sdk/model/target/lean.aon +91 -0
- package/.sdk/src/cmp/dart/Config_dart.ts +248 -0
- package/.sdk/src/cmp/dart/EntityBase_dart.ts +34 -0
- package/.sdk/src/cmp/dart/EntityOperation_dart.ts +43 -0
- package/.sdk/src/cmp/dart/EntityTypes_dart.ts +207 -0
- package/.sdk/src/cmp/dart/Entity_dart.ts +87 -0
- package/.sdk/src/cmp/dart/Gitignore_dart.ts +34 -0
- package/.sdk/src/cmp/dart/MainEntity_dart.ts +33 -0
- package/.sdk/src/cmp/dart/Main_dart.ts +178 -0
- package/.sdk/src/cmp/dart/Package_dart.ts +82 -0
- package/.sdk/src/cmp/dart/ReadmeEntity_dart.ts +177 -0
- package/.sdk/src/cmp/dart/ReadmeExamplesTest_dart.ts +238 -0
- package/.sdk/src/cmp/dart/ReadmeExplanation_dart.ts +53 -0
- package/.sdk/src/cmp/dart/ReadmeHowto_dart.ts +152 -0
- package/.sdk/src/cmp/dart/ReadmeInstall_dart.ts +59 -0
- package/.sdk/src/cmp/dart/ReadmeIntro_dart.ts +65 -0
- package/.sdk/src/cmp/dart/ReadmeModel_dart.ts +151 -0
- package/.sdk/src/cmp/dart/ReadmeOptions_dart.ts +63 -0
- package/.sdk/src/cmp/dart/ReadmeQuick_dart.ts +225 -0
- package/.sdk/src/cmp/dart/ReadmeRef_dart.ts +397 -0
- package/.sdk/src/cmp/dart/ReadmeTopHowto_dart.ts +24 -0
- package/.sdk/src/cmp/dart/ReadmeTopQuick_dart.ts +106 -0
- package/.sdk/src/cmp/dart/ReadmeTopTest_dart.ts +78 -0
- package/.sdk/src/cmp/dart/SdkError_dart.ts +42 -0
- package/.sdk/src/cmp/dart/TestDirect_dart.ts +516 -0
- package/.sdk/src/cmp/dart/TestEntity_dart.ts +628 -0
- package/.sdk/src/cmp/dart/Test_dart.ts +138 -0
- package/.sdk/src/cmp/dart/fragment/Config.data.fragment.dart +98 -0
- package/.sdk/src/cmp/dart/fragment/Config.fragment.dart +70 -0
- package/.sdk/src/cmp/dart/fragment/Direct.test.fragment.dart +25 -0
- package/.sdk/src/cmp/dart/fragment/Entity.fragment.dart +29 -0
- package/.sdk/src/cmp/dart/fragment/Entity.test.fragment.dart +28 -0
- package/.sdk/src/cmp/dart/fragment/EntityBase.fragment.dart +302 -0
- package/.sdk/src/cmp/dart/fragment/EntityCreateOp.fragment.dart +98 -0
- package/.sdk/src/cmp/dart/fragment/EntityListOp.fragment.dart +90 -0
- package/.sdk/src/cmp/dart/fragment/EntityLoadOp.fragment.dart +102 -0
- package/.sdk/src/cmp/dart/fragment/EntityRemoveOp.fragment.dart +108 -0
- package/.sdk/src/cmp/dart/fragment/EntityUpdateOp.fragment.dart +102 -0
- package/.sdk/src/cmp/dart/fragment/Main.fragment.dart +339 -0
- package/.sdk/src/cmp/dart/fragment/SdkError.fragment.dart +26 -0
- package/.sdk/src/cmp/dart/tsconfig.json +15 -0
- package/.sdk/src/cmp/dart/utility_dart.ts +155 -0
- package/.sdk/src/cmp/haskell/Config_haskell.ts +98 -0
- package/.sdk/src/cmp/haskell/Entity_haskell.ts +13 -0
- package/.sdk/src/cmp/haskell/Gitignore_haskell.ts +27 -0
- package/.sdk/src/cmp/haskell/Main_haskell.ts +123 -0
- package/.sdk/src/cmp/haskell/Package_haskell.ts +60 -0
- package/.sdk/src/cmp/haskell/ReadmeEntity_haskell.ts +186 -0
- package/.sdk/src/cmp/haskell/ReadmeExamplesTest_haskell.ts +135 -0
- package/.sdk/src/cmp/haskell/ReadmeExplanation_haskell.ts +48 -0
- package/.sdk/src/cmp/haskell/ReadmeHowto_haskell.ts +168 -0
- package/.sdk/src/cmp/haskell/ReadmeInstall_haskell.ts +51 -0
- package/.sdk/src/cmp/haskell/ReadmeIntro_haskell.ts +67 -0
- package/.sdk/src/cmp/haskell/ReadmeModel_haskell.ts +162 -0
- package/.sdk/src/cmp/haskell/ReadmeOptions_haskell.ts +74 -0
- package/.sdk/src/cmp/haskell/ReadmeQuick_haskell.ts +241 -0
- package/.sdk/src/cmp/haskell/ReadmeRef_haskell.ts +408 -0
- package/.sdk/src/cmp/haskell/ReadmeTopHowto_haskell.ts +31 -0
- package/.sdk/src/cmp/haskell/ReadmeTopQuick_haskell.ts +104 -0
- package/.sdk/src/cmp/haskell/ReadmeTopTest_haskell.ts +80 -0
- package/.sdk/src/cmp/haskell/Test_haskell.ts +297 -0
- package/.sdk/src/cmp/haskell/tsconfig.json +15 -0
- package/.sdk/src/cmp/haskell/utility_haskell.ts +166 -0
- package/.sdk/src/cmp/lean/Config_lean.ts +93 -0
- package/.sdk/src/cmp/lean/Entity_lean.ts +9 -0
- package/.sdk/src/cmp/lean/Gitignore_lean.ts +18 -0
- package/.sdk/src/cmp/lean/Main_lean.ts +120 -0
- package/.sdk/src/cmp/lean/Package_lean.ts +93 -0
- package/.sdk/src/cmp/lean/ReadmeEntity_lean.ts +29 -0
- package/.sdk/src/cmp/lean/ReadmeExplanation_lean.ts +19 -0
- package/.sdk/src/cmp/lean/ReadmeHowto_lean.ts +25 -0
- package/.sdk/src/cmp/lean/ReadmeInstall_lean.ts +39 -0
- package/.sdk/src/cmp/lean/ReadmeIntro_lean.ts +25 -0
- package/.sdk/src/cmp/lean/ReadmeModel_lean.ts +24 -0
- package/.sdk/src/cmp/lean/ReadmeOptions_lean.ts +22 -0
- package/.sdk/src/cmp/lean/ReadmeQuick_lean.ts +50 -0
- package/.sdk/src/cmp/lean/ReadmeRef_lean.ts +40 -0
- package/.sdk/src/cmp/lean/ReadmeTopHowto_lean.ts +16 -0
- package/.sdk/src/cmp/lean/ReadmeTopQuick_lean.ts +23 -0
- package/.sdk/src/cmp/lean/ReadmeTopTest_lean.ts +19 -0
- package/.sdk/src/cmp/lean/Test_lean.ts +261 -0
- package/.sdk/src/cmp/lean/utility_lean.ts +129 -0
- package/.sdk/tm/dart/LICENSE +22 -0
- package/.sdk/tm/dart/Makefile +50 -0
- package/.sdk/tm/dart/lib/Context.dart +150 -0
- package/.sdk/tm/dart/lib/Control.dart +15 -0
- package/.sdk/tm/dart/lib/Operation.dart +31 -0
- package/.sdk/tm/dart/lib/Point.dart +51 -0
- package/.sdk/tm/dart/lib/Response.dart +32 -0
- package/.sdk/tm/dart/lib/Result.dart +39 -0
- package/.sdk/tm/dart/lib/Spec.dart +49 -0
- package/.sdk/tm/dart/lib/feature/audit/AuditFeature.dart +103 -0
- package/.sdk/tm/dart/lib/feature/base/BaseFeature.dart +76 -0
- package/.sdk/tm/dart/lib/feature/cache/CacheFeature.dart +152 -0
- package/.sdk/tm/dart/lib/feature/clienttrack/ClienttrackFeature.dart +104 -0
- package/.sdk/tm/dart/lib/feature/cost/CostFeature.dart +446 -0
- package/.sdk/tm/dart/lib/feature/debug/DebugFeature.dart +153 -0
- package/.sdk/tm/dart/lib/feature/idempotency/IdempotencyFeature.dart +92 -0
- package/.sdk/tm/dart/lib/feature/log/LogFeature.dart +85 -0
- package/.sdk/tm/dart/lib/feature/metrics/MetricsFeature.dart +103 -0
- package/.sdk/tm/dart/lib/feature/netsim/NetsimFeature.dart +186 -0
- package/.sdk/tm/dart/lib/feature/paging/PagingFeature.dart +240 -0
- package/.sdk/tm/dart/lib/feature/proxy/ProxyFeature.dart +118 -0
- package/.sdk/tm/dart/lib/feature/ratelimit/RatelimitFeature.dart +103 -0
- package/.sdk/tm/dart/lib/feature/rbac/RbacFeature.dart +121 -0
- package/.sdk/tm/dart/lib/feature/retry/RetryFeature.dart +155 -0
- package/.sdk/tm/dart/lib/feature/secrets/SecretsFeature.dart +649 -0
- package/.sdk/tm/dart/lib/feature/secrets/plugin/capability.dart +105 -0
- package/.sdk/tm/dart/lib/feature/secrets/plugin/catalog.dart +46 -0
- package/.sdk/tm/dart/lib/feature/secrets/plugin/config.dart +297 -0
- package/.sdk/tm/dart/lib/feature/secrets/plugin/depend.dart +198 -0
- package/.sdk/tm/dart/lib/feature/secrets/plugin/env.dart +144 -0
- package/.sdk/tm/dart/lib/feature/secrets/plugin/export.dart +58 -0
- package/.sdk/tm/dart/lib/feature/secrets/plugin/graph.dart +160 -0
- package/.sdk/tm/dart/lib/feature/secrets/plugin/host.dart +1067 -0
- package/.sdk/tm/dart/lib/feature/secrets/plugin/order.dart +172 -0
- package/.sdk/tm/dart/lib/feature/secrets/plugin/plugin.dart +23 -0
- package/.sdk/tm/dart/lib/feature/secrets/plugin/point.dart +117 -0
- package/.sdk/tm/dart/lib/feature/secrets/plugin/ref.dart +105 -0
- package/.sdk/tm/dart/lib/feature/secrets/plugin/resolve.dart +58 -0
- package/.sdk/tm/dart/lib/feature/secrets/plugin/types.dart +201 -0
- package/.sdk/tm/dart/lib/feature/secrets/plugin/version.dart +116 -0
- package/.sdk/tm/dart/lib/feature/secrets/sekreto/plugins/aws.dart +285 -0
- package/.sdk/tm/dart/lib/feature/secrets/sekreto/plugins/azuresecrets.dart +178 -0
- package/.sdk/tm/dart/lib/feature/secrets/sekreto/plugins/boru.dart +145 -0
- package/.sdk/tm/dart/lib/feature/secrets/sekreto/plugins/crypto.dart +194 -0
- package/.sdk/tm/dart/lib/feature/secrets/sekreto/plugins/doppler.dart +101 -0
- package/.sdk/tm/dart/lib/feature/secrets/sekreto/plugins/gcpsecrets.dart +143 -0
- package/.sdk/tm/dart/lib/feature/secrets/sekreto/plugins/hashicorp.dart +190 -0
- package/.sdk/tm/dart/lib/feature/secrets/sekreto/plugins/httpjson.dart +363 -0
- package/.sdk/tm/dart/lib/feature/secrets/sekreto/plugins/infisical.dart +149 -0
- package/.sdk/tm/dart/lib/feature/secrets/sekreto/plugins/onepassword.dart +146 -0
- package/.sdk/tm/dart/lib/feature/secrets/sekreto/plugins/secretspec.dart +116 -0
- package/.sdk/tm/dart/lib/feature/secrets/sekreto/plugins/sigv4.dart +237 -0
- package/.sdk/tm/dart/lib/feature/secrets/sekreto/src/addr.dart +138 -0
- package/.sdk/tm/dart/lib/feature/secrets/sekreto/src/json.dart +276 -0
- package/.sdk/tm/dart/lib/feature/secrets/sekreto/src/provider.dart +31 -0
- package/.sdk/tm/dart/lib/feature/secrets/sekreto/src/providers.dart +243 -0
- package/.sdk/tm/dart/lib/feature/secrets/sekreto/src/sekreto.dart +730 -0
- package/.sdk/tm/dart/lib/feature/secrets/sekreto/src/spec.dart +200 -0
- package/.sdk/tm/dart/lib/feature/secrets/sekreto/src/support.dart +217 -0
- package/.sdk/tm/dart/lib/feature/streaming/StreamingFeature.dart +97 -0
- package/.sdk/tm/dart/lib/feature/telemetry/TelemetryFeature.dart +136 -0
- package/.sdk/tm/dart/lib/feature/test/TestFeature.dart +328 -0
- package/.sdk/tm/dart/lib/feature/timeout/TimeoutFeature.dart +104 -0
- package/.sdk/tm/dart/lib/utility/CleanUtility.dart +12 -0
- package/.sdk/tm/dart/lib/utility/DoneUtility.dart +18 -0
- package/.sdk/tm/dart/lib/utility/ErrUtility.dart +46 -0
- package/.sdk/tm/dart/lib/utility/FeatureAddUtility.dart +35 -0
- package/.sdk/tm/dart/lib/utility/FeatureHookUtility.dart +20 -0
- package/.sdk/tm/dart/lib/utility/FeatureInitUtility.dart +9 -0
- package/.sdk/tm/dart/lib/utility/FetcherUtility.dart +104 -0
- package/.sdk/tm/dart/lib/utility/GraphqlUtility.dart +162 -0
- package/.sdk/tm/dart/lib/utility/MakeContextUtility.dart +6 -0
- package/.sdk/tm/dart/lib/utility/MakeErrorUtility.dart +71 -0
- package/.sdk/tm/dart/lib/utility/MakeFetchDefUtility.dart +42 -0
- package/.sdk/tm/dart/lib/utility/MakeOptionsUtility.dart +233 -0
- package/.sdk/tm/dart/lib/utility/MakePointUtility.dart +130 -0
- package/.sdk/tm/dart/lib/utility/MakeRequestUtility.dart +66 -0
- package/.sdk/tm/dart/lib/utility/MakeResponseUtility.dart +59 -0
- package/.sdk/tm/dart/lib/utility/MakeResultUtility.dart +49 -0
- package/.sdk/tm/dart/lib/utility/MakeSpecUtility.dart +77 -0
- package/.sdk/tm/dart/lib/utility/MakeUrlUtility.dart +51 -0
- package/.sdk/tm/dart/lib/utility/ParamUtility.dart +56 -0
- package/.sdk/tm/dart/lib/utility/PrepareAuthUtility.dart +46 -0
- package/.sdk/tm/dart/lib/utility/PrepareBodyUtility.dart +19 -0
- package/.sdk/tm/dart/lib/utility/PrepareHeadersUtility.dart +11 -0
- package/.sdk/tm/dart/lib/utility/PrepareMethodUtility.dart +30 -0
- package/.sdk/tm/dart/lib/utility/PrepareParamsUtility.dart +23 -0
- package/.sdk/tm/dart/lib/utility/PreparePathUtility.dart +9 -0
- package/.sdk/tm/dart/lib/utility/PrepareQueryUtility.dart +18 -0
- package/.sdk/tm/dart/lib/utility/ResultBasicUtility.dart +29 -0
- package/.sdk/tm/dart/lib/utility/ResultBodyUtility.dart +15 -0
- package/.sdk/tm/dart/lib/utility/ResultHeadersUtility.dart +18 -0
- package/.sdk/tm/dart/lib/utility/StructUtility.dart +127 -0
- package/.sdk/tm/dart/lib/utility/TransformRequestUtility.dart +28 -0
- package/.sdk/tm/dart/lib/utility/TransformResponseUtility.dart +44 -0
- package/.sdk/tm/dart/lib/utility/Utility.dart +239 -0
- package/.sdk/tm/dart/lib/utility/voxgig_struct.dart +2462 -0
- package/.sdk/tm/dart/src/feature/README.md +3 -0
- package/.sdk/tm/dart/src/feature/audit/.gitkeep +0 -0
- package/.sdk/tm/dart/src/feature/base/.gitkeep +0 -0
- package/.sdk/tm/dart/src/feature/cache/.gitkeep +0 -0
- package/.sdk/tm/dart/src/feature/clienttrack/.gitkeep +0 -0
- package/.sdk/tm/dart/src/feature/cost/.gitkeep +0 -0
- package/.sdk/tm/dart/src/feature/debug/.gitkeep +0 -0
- package/.sdk/tm/dart/src/feature/idempotency/.gitkeep +0 -0
- package/.sdk/tm/dart/src/feature/log/.gitkeep +0 -0
- package/.sdk/tm/dart/src/feature/metrics/.gitkeep +0 -0
- package/.sdk/tm/dart/src/feature/netsim/.gitkeep +0 -0
- package/.sdk/tm/dart/src/feature/paging/.gitkeep +0 -0
- package/.sdk/tm/dart/src/feature/proxy/.gitkeep +0 -0
- package/.sdk/tm/dart/src/feature/ratelimit/.gitkeep +0 -0
- package/.sdk/tm/dart/src/feature/rbac/.gitkeep +0 -0
- package/.sdk/tm/dart/src/feature/retry/.gitkeep +0 -0
- package/.sdk/tm/dart/src/feature/secrets/.gitkeep +0 -0
- package/.sdk/tm/dart/src/feature/streaming/.gitkeep +0 -0
- package/.sdk/tm/dart/src/feature/telemetry/.gitkeep +0 -0
- package/.sdk/tm/dart/src/feature/test/.gitkeep +0 -0
- package/.sdk/tm/dart/src/feature/timeout/.gitkeep +0 -0
- package/.sdk/tm/dart/test/custom_test.dart +65 -0
- package/.sdk/tm/dart/test/exists_test.dart +12 -0
- package/.sdk/tm/dart/test/feature/harness.dart +347 -0
- package/.sdk/tm/dart/test/feature/secrets/secrets_test.dart +1107 -0
- package/.sdk/tm/dart/test/feature_test.dart +1193 -0
- package/.sdk/tm/dart/test/harness.dart +153 -0
- package/.sdk/tm/dart/test/netsim_test.dart +48 -0
- package/.sdk/tm/dart/test/omni.dart +520 -0
- package/.sdk/tm/dart/test/omni_smoke_test.dart +143 -0
- package/.sdk/tm/dart/test/pipeline_test.dart +608 -0
- package/.sdk/tm/dart/test/primary_test.dart +476 -0
- package/.sdk/tm/dart/test/sdk-test-control.json +19 -0
- package/.sdk/tm/dart/test/struct_test.dart +468 -0
- package/.sdk/tm/dart/test/utility.dart +198 -0
- package/.sdk/tm/dart/test/vendor/omni/omni.dart +7 -0
- package/.sdk/tm/dart/test/vendor/omni/runner.dart +653 -0
- package/.sdk/tm/dart/test/vendor/omni/util.dart +232 -0
- package/.sdk/tm/haskell/LICENSE +21 -0
- package/.sdk/tm/haskell/Makefile +22 -0
- package/.sdk/tm/haskell/VERSION +1 -0
- package/.sdk/tm/haskell/src/SdkFeatures.hs +1440 -0
- package/.sdk/tm/haskell/src/SdkHelpers.hs +337 -0
- package/.sdk/tm/haskell/src/SdkJson.hs +111 -0
- package/.sdk/tm/haskell/src/SdkRuntime.hs +1279 -0
- package/.sdk/tm/haskell/src/SdkTypes.hs +195 -0
- package/.sdk/tm/haskell/src/VoxgigStruct.hs +2299 -0
- package/.sdk/tm/haskell/src/Vregex.hs +237 -0
- package/.sdk/tm/haskell/src/feature/README.md +5 -0
- package/.sdk/tm/haskell/src/feature/audit/.gitkeep +0 -0
- package/.sdk/tm/haskell/src/feature/base/.gitkeep +0 -0
- package/.sdk/tm/haskell/src/feature/cache/.gitkeep +0 -0
- package/.sdk/tm/haskell/src/feature/clienttrack/.gitkeep +0 -0
- package/.sdk/tm/haskell/src/feature/debug/.gitkeep +0 -0
- package/.sdk/tm/haskell/src/feature/idempotency/.gitkeep +0 -0
- package/.sdk/tm/haskell/src/feature/log/.gitkeep +0 -0
- package/.sdk/tm/haskell/src/feature/metrics/.gitkeep +0 -0
- package/.sdk/tm/haskell/src/feature/netsim/.gitkeep +0 -0
- package/.sdk/tm/haskell/src/feature/paging/.gitkeep +0 -0
- package/.sdk/tm/haskell/src/feature/proxy/.gitkeep +0 -0
- package/.sdk/tm/haskell/src/feature/ratelimit/.gitkeep +0 -0
- package/.sdk/tm/haskell/src/feature/rbac/.gitkeep +0 -0
- package/.sdk/tm/haskell/src/feature/retry/.gitkeep +0 -0
- package/.sdk/tm/haskell/src/feature/streaming/.gitkeep +0 -0
- package/.sdk/tm/haskell/src/feature/telemetry/.gitkeep +0 -0
- package/.sdk/tm/haskell/src/feature/test/.gitkeep +0 -0
- package/.sdk/tm/haskell/src/feature/timeout/.gitkeep +0 -0
- package/.sdk/tm/haskell/test/Harness.hs +281 -0
- package/.sdk/tm/haskell/test/OmniResolver.hs +252 -0
- package/.sdk/tm/haskell/test/Runner.hs +49 -0
- package/.sdk/tm/haskell/test/StructCorpus.hs +449 -0
- package/.sdk/tm/haskell/test/TCustomUtility.hs +38 -0
- package/.sdk/tm/haskell/test/TFeature.hs +794 -0
- package/.sdk/tm/haskell/test/TNetsim.hs +50 -0
- package/.sdk/tm/haskell/test/TPipeline.hs +334 -0
- package/.sdk/tm/haskell/test/TPrimaryCorpus.hs +263 -0
- package/.sdk/tm/haskell/test/TPrimaryUtility.hs +386 -0
- package/.sdk/tm/haskell/test/Testutil.hs +59 -0
- package/.sdk/tm/haskell/test/vendor/omni/Omni.hs +1147 -0
- package/.sdk/tm/lean/LICENSE +21 -0
- package/.sdk/tm/lean/Makefile +32 -0
- package/.sdk/tm/lean/VERSION +1 -0
- package/.sdk/tm/lean/src/SdkFeature.lean +171 -0
- package/.sdk/tm/lean/src/SdkFeatures.lean +787 -0
- package/.sdk/tm/lean/src/SdkJson.lean +134 -0
- package/.sdk/tm/lean/src/SdkRuntime.lean +374 -0
- package/.sdk/tm/lean/src/SdkUtility.lean +809 -0
- package/.sdk/tm/lean/src/VoxgigStruct.lean +2880 -0
- package/.sdk/tm/lean/src/Vregex.lean +412 -0
- package/.sdk/tm/lean/src/feature/README.md +5 -0
- package/.sdk/tm/lean/src/feature/audit/.gitkeep +0 -0
- package/.sdk/tm/lean/src/feature/base/.gitkeep +0 -0
- package/.sdk/tm/lean/src/feature/cache/.gitkeep +0 -0
- package/.sdk/tm/lean/src/feature/clienttrack/.gitkeep +0 -0
- package/.sdk/tm/lean/src/feature/cost/.gitkeep +0 -0
- package/.sdk/tm/lean/src/feature/debug/.gitkeep +0 -0
- package/.sdk/tm/lean/src/feature/idempotency/.gitkeep +0 -0
- package/.sdk/tm/lean/src/feature/log/.gitkeep +0 -0
- package/.sdk/tm/lean/src/feature/metrics/.gitkeep +0 -0
- package/.sdk/tm/lean/src/feature/netsim/.gitkeep +0 -0
- package/.sdk/tm/lean/src/feature/paging/.gitkeep +0 -0
- package/.sdk/tm/lean/src/feature/proxy/.gitkeep +0 -0
- package/.sdk/tm/lean/src/feature/ratelimit/.gitkeep +0 -0
- package/.sdk/tm/lean/src/feature/rbac/.gitkeep +0 -0
- package/.sdk/tm/lean/src/feature/retry/.gitkeep +0 -0
- package/.sdk/tm/lean/src/feature/streaming/.gitkeep +0 -0
- package/.sdk/tm/lean/src/feature/telemetry/.gitkeep +0 -0
- package/.sdk/tm/lean/src/feature/test/.gitkeep +0 -0
- package/.sdk/tm/lean/src/feature/timeout/.gitkeep +0 -0
- package/.sdk/tm/lean/test/OmniResolver.lean +358 -0
- package/.sdk/tm/lean/test/OmniSmoke.lean +174 -0
- package/.sdk/tm/lean/test/StructCorpus.lean +368 -0
- package/.sdk/tm/lean/test/TFeature.lean +281 -0
- package/.sdk/tm/lean/test/TPrimaryUtility.lean +227 -0
- package/.sdk/tm/lean/test/vendor/omni/Omni.lean +997 -0
- package/LICENSE +21 -0
- package/README.md +104 -0
- package/package.json +78 -0
- package/sdkgen-package.json +22 -0
|
@@ -0,0 +1,1067 @@
|
|
|
1
|
+
// VENDORED: @voxgig/plugin sdk-20260908-1556-0 (dart/lib/host.dart)
|
|
2
|
+
// Source: https://github.com/voxgig/plugin @ 48392f5e2b6d1434ee9b1a4a9a11f4480aaeb46a [tag: sdk-20260908-1556-0]
|
|
3
|
+
// License: MIT (c) voxgig - see repository LICENSE. Do not edit: resync from upstream.
|
|
4
|
+
/// The host: the lifecycle state machine (section 5), extension points
|
|
5
|
+
/// (section 6), and resource capture (section 8).
|
|
6
|
+
///
|
|
7
|
+
/// TWO RULES SHAPE EVERY METHOD BELOW.
|
|
8
|
+
///
|
|
9
|
+
/// Transitions are SEQUENTIAL (section 5.2). One at a time, in call order,
|
|
10
|
+
/// never interleaved; a transition triggered from inside a lifecycle
|
|
11
|
+
/// callback is `plugin_reentrant`. A hard rule, because it is the only way
|
|
12
|
+
/// the semantics can be identical in Go, in Ruby and in single-threaded
|
|
13
|
+
/// JavaScript.
|
|
14
|
+
///
|
|
15
|
+
/// Reconciliation is EAGER (section 18's portability budget). A transition
|
|
16
|
+
/// settles by running the state machine to a fixed point, not by suspending
|
|
17
|
+
/// on a promise. NOTHING HERE RETURNS A `Future`, and that is the decision
|
|
18
|
+
/// dart most invites you to get wrong: an `async` host would make every
|
|
19
|
+
/// transition a scheduling point, and section 5.2's "one at a time, in call
|
|
20
|
+
/// order" would become a claim about a microtask queue rather than about
|
|
21
|
+
/// the code.
|
|
22
|
+
library;
|
|
23
|
+
|
|
24
|
+
import 'types.dart' as t;
|
|
25
|
+
import 'ref.dart' as r;
|
|
26
|
+
import 'catalog.dart';
|
|
27
|
+
import 'config.dart' as config;
|
|
28
|
+
import 'capability.dart' as cap;
|
|
29
|
+
import 'depend.dart' as dep;
|
|
30
|
+
import 'export.dart' as ex;
|
|
31
|
+
import 'order.dart' as ord;
|
|
32
|
+
import 'point.dart' as pt;
|
|
33
|
+
|
|
34
|
+
/// One registered instance. The INTERNAL record: a plugin sees `Inst`.
|
|
35
|
+
class Entry {
|
|
36
|
+
final String ref;
|
|
37
|
+
final dynamic def;
|
|
38
|
+
String status;
|
|
39
|
+
int pos;
|
|
40
|
+
final int seq;
|
|
41
|
+
Map<String, dynamic> options;
|
|
42
|
+
final Map<String, dynamic> state = {};
|
|
43
|
+
dynamic order;
|
|
44
|
+
List<String> unmet = [];
|
|
45
|
+
final List<void Function()> scope = [];
|
|
46
|
+
|
|
47
|
+
/// Section 11.4's ALWAYS-RELUCTANT rebinding made concrete: the provider
|
|
48
|
+
/// ref this instance's activation actually chose, per requirement name.
|
|
49
|
+
/// Re-ranking on every question silently re-points a live consumer at any
|
|
50
|
+
/// better newcomer, and then losing the provider it was really using does
|
|
51
|
+
/// not restart it.
|
|
52
|
+
Map<String, String> selected = {};
|
|
53
|
+
|
|
54
|
+
final List<pt.Binding> bindings = [];
|
|
55
|
+
final Map<String, dynamic> exports = {};
|
|
56
|
+
final List<dynamic> provides = [];
|
|
57
|
+
Host? inner;
|
|
58
|
+
bool barred = false;
|
|
59
|
+
|
|
60
|
+
Entry(this.ref, this.def, this.status, this.pos, this.seq, this.options,
|
|
61
|
+
this.order);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/// What a definition's callbacks see. Deliberately not the internal record:
|
|
65
|
+
/// a plugin that could reach `status` could also write it.
|
|
66
|
+
class Inst {
|
|
67
|
+
final Host host;
|
|
68
|
+
final Entry _entry;
|
|
69
|
+
final String ref;
|
|
70
|
+
final String name;
|
|
71
|
+
final String tag;
|
|
72
|
+
|
|
73
|
+
Inst(this.host, this._entry)
|
|
74
|
+
: ref = _entry.ref,
|
|
75
|
+
name = r.parseRef(_entry.ref)['name'] as String,
|
|
76
|
+
tag = r.parseRef(_entry.ref)['tag'] as String;
|
|
77
|
+
|
|
78
|
+
Map<String, dynamic> get options => _entry.options;
|
|
79
|
+
Map<String, dynamic> get state => _entry.state;
|
|
80
|
+
|
|
81
|
+
/// Foreign resources the host did not hand out are registered explicitly
|
|
82
|
+
/// (section 8.3); host calls are recorded automatically.
|
|
83
|
+
///
|
|
84
|
+
/// SYMMETRIC WITH `acquire`, and it has to be: `open` counts the resources
|
|
85
|
+
/// CURRENTLY HELD, so an entry that is registered and then unwound must
|
|
86
|
+
/// leave the count where it found it.
|
|
87
|
+
void release(void Function() fn) {
|
|
88
|
+
// Section 8.3: "`inst.release` outside `activate` is
|
|
89
|
+
// `plugin_release_scope`". `intransition` is true in `define` too, and a
|
|
90
|
+
// scope entry registered there is never unwound.
|
|
91
|
+
if (host.phase != 'activate') {
|
|
92
|
+
t.fail('plugin_release_scope', 'release called outside activate');
|
|
93
|
+
}
|
|
94
|
+
var done = false;
|
|
95
|
+
_entry.scope.add(() {
|
|
96
|
+
if (done) return;
|
|
97
|
+
done = true;
|
|
98
|
+
host.open--;
|
|
99
|
+
fn();
|
|
100
|
+
});
|
|
101
|
+
host.open++;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/// The synthetic counter the driver owns, so "what is open" is data rather
|
|
105
|
+
/// than an assertion each port words differently.
|
|
106
|
+
///
|
|
107
|
+
/// Returns its own release, so a plugin can hand one back early. The scope
|
|
108
|
+
/// still holds the entry and unwinding it twice is a no-op - releasing
|
|
109
|
+
/// early must not make teardown wrong.
|
|
110
|
+
void Function() acquire() {
|
|
111
|
+
// Section 8.1: resources are "acquired during `activate` - the scope's
|
|
112
|
+
// actual job". Same reason as `release` above.
|
|
113
|
+
if (host.phase != 'activate') {
|
|
114
|
+
t.fail('plugin_release_scope', 'acquire called outside activate');
|
|
115
|
+
}
|
|
116
|
+
var done = false;
|
|
117
|
+
void rel() {
|
|
118
|
+
if (done) return;
|
|
119
|
+
done = true;
|
|
120
|
+
host.open--;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
_entry.scope.add(rel);
|
|
124
|
+
host.open++;
|
|
125
|
+
return rel;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/// Bind into a host point. Declared in `define`; the host inserts it only
|
|
129
|
+
/// after `activate` returns successfully (section 8.1), which is why a
|
|
130
|
+
/// failing activate leaves no live binding behind.
|
|
131
|
+
///
|
|
132
|
+
/// Section 12 has carried `plugin_bind_scope` - "binding declared outside
|
|
133
|
+
/// `define`" - since before anything raised it, and it was the half nobody
|
|
134
|
+
/// wrote: a binding added from `activate` went live without being part of
|
|
135
|
+
/// the loaded definition, and a deactivate/activate cycle appended it
|
|
136
|
+
/// again.
|
|
137
|
+
void bind(String point, pt.BindingFn fn, [dynamic band]) {
|
|
138
|
+
if (host.phase != 'define') {
|
|
139
|
+
t.fail('plugin_bind_scope', 'bind called outside define: $point',
|
|
140
|
+
{'ref': ref, 'point': point});
|
|
141
|
+
}
|
|
142
|
+
if (!host.hasPoint(point)) {
|
|
143
|
+
t.fail('plugin_point_unknown', 'no such point: $point', {'point': point});
|
|
144
|
+
}
|
|
145
|
+
_entry.bindings.add(pt.Binding(ref, point, fn, t.asInt(band) ?? 0));
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/// Published for other plugins and for the application (section 11).
|
|
149
|
+
void export(String key, dynamic value) => _entry.exports[key] = value;
|
|
150
|
+
|
|
151
|
+
/// What this instance can do for others (section 11.1).
|
|
152
|
+
void provides(dynamic prov) => _entry.provides.add(prov);
|
|
153
|
+
|
|
154
|
+
/// Where this binding landed (section 6.6) - the plugin-side counterpart
|
|
155
|
+
/// to a host pin. THE HOST DOES NOT POLICE THIS; it just makes the fact
|
|
156
|
+
/// available. Verification tells a plugin it was misplaced; a pin (section
|
|
157
|
+
/// 7) stops the misplacement from being expressible at all. The two are
|
|
158
|
+
/// not substitutes.
|
|
159
|
+
Map<String, dynamic> position(String point) => host.positionOf(ref, point);
|
|
160
|
+
|
|
161
|
+
/// AN INSTANCE MAY ITSELF BE A HOST (section 6.5), and THE OUTER ONE OWNS
|
|
162
|
+
/// THE INNER ONE'S LIFETIME. Registering the teardown in the instance
|
|
163
|
+
/// scope is what makes that true rather than aspirational.
|
|
164
|
+
Host nest([dynamic nestopts]) {
|
|
165
|
+
if (!host.intransition) {
|
|
166
|
+
t.fail('plugin_release_scope', 'nest called outside a lifecycle callback');
|
|
167
|
+
}
|
|
168
|
+
final inner = Host(nestopts);
|
|
169
|
+
// NOT counted: `open` must read the same before and after a nested host
|
|
170
|
+
// is created.
|
|
171
|
+
_entry.scope.add(() => inner.close());
|
|
172
|
+
_entry.inner = inner;
|
|
173
|
+
return inner;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
class Host {
|
|
178
|
+
final dynamic _opts;
|
|
179
|
+
final String _dependency;
|
|
180
|
+
|
|
181
|
+
/// Set for the duration of a bulk teardown, so `held` knows this is a
|
|
182
|
+
/// coordinated operation rather than an ad-hoc deactivation.
|
|
183
|
+
bool _coordinated = false;
|
|
184
|
+
|
|
185
|
+
final Catalog catalog;
|
|
186
|
+
final List _reserved;
|
|
187
|
+
final Map<String, dynamic> _points;
|
|
188
|
+
|
|
189
|
+
final Map<String, Entry> _inst = {};
|
|
190
|
+
final List<String> _log = [];
|
|
191
|
+
|
|
192
|
+
/// Section 14: the lifecycle event record. `seq` distinguishes ONE
|
|
193
|
+
/// INCARNATION of stripe$test from the next, which is the whole reason it
|
|
194
|
+
/// is not `pos` (section 4 rule 4).
|
|
195
|
+
final List<dynamic> _events = [];
|
|
196
|
+
int _seqn = 0;
|
|
197
|
+
int open = 0;
|
|
198
|
+
bool intransition = false;
|
|
199
|
+
|
|
200
|
+
/// WHICH callback is running, not merely that one is. Section 8.1 puts
|
|
201
|
+
/// resource capture in `activate` and 8.3 says `release` outside
|
|
202
|
+
/// `activate` is `plugin_release_scope` - and `intransition` alone cannot
|
|
203
|
+
/// tell `activate` from `define`, so it admitted an acquire in `define`
|
|
204
|
+
/// whose scope `unload` would never unwind.
|
|
205
|
+
String? phase;
|
|
206
|
+
|
|
207
|
+
Host([dynamic options])
|
|
208
|
+
: _opts = options ?? <String, dynamic>{},
|
|
209
|
+
_dependency = (t.get(options, 'dependency') ?? 'restart') as String,
|
|
210
|
+
catalog = (t.get(options, 'catalog') ?? makeCatalog()) as Catalog,
|
|
211
|
+
_reserved = (t.get(options, 'reserved') ?? []) as List,
|
|
212
|
+
_points = Map<String, dynamic>.from(
|
|
213
|
+
(t.get(options, 'points') ?? <String, dynamic>{}) as Map);
|
|
214
|
+
|
|
215
|
+
bool hasPoint(String name) => _points.containsKey(name);
|
|
216
|
+
|
|
217
|
+
// --- observation ---------------------------------------------------
|
|
218
|
+
|
|
219
|
+
/// Introspection NEVER advances the state (section 5.2). A status page
|
|
220
|
+
/// must not be a way to accidentally import twenty packages.
|
|
221
|
+
Map<String, dynamic> list() {
|
|
222
|
+
final out = <String, dynamic>{};
|
|
223
|
+
for (final ref in _refs()) {
|
|
224
|
+
out[ref] = _inst[ref]!.status;
|
|
225
|
+
}
|
|
226
|
+
return out;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
Entry? instance(dynamic ref) => _inst[r.canonRef(ref)];
|
|
230
|
+
|
|
231
|
+
List<dynamic> trace() => List<dynamic>.from(_events);
|
|
232
|
+
|
|
233
|
+
Map<String, dynamic> observable([dynamic result]) => {
|
|
234
|
+
'status': list(),
|
|
235
|
+
'open': open,
|
|
236
|
+
'log': List<String>.from(_log),
|
|
237
|
+
'result': result,
|
|
238
|
+
};
|
|
239
|
+
|
|
240
|
+
List<String> _refs() => _inst.keys.toList()..sort();
|
|
241
|
+
|
|
242
|
+
// --- the state machine ----------------------------------------------
|
|
243
|
+
|
|
244
|
+
void _guard() {
|
|
245
|
+
if (!intransition) return;
|
|
246
|
+
t.fail('plugin_reentrant',
|
|
247
|
+
'transition attempted from inside a lifecycle callback');
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
Entry _need(dynamic ref) {
|
|
251
|
+
final rf = r.canonRef(ref);
|
|
252
|
+
final entry = _inst[rf];
|
|
253
|
+
if (entry == null) {
|
|
254
|
+
t.fail('plugin_not_loaded', 'no such instance: $rf', {'ref': rf});
|
|
255
|
+
}
|
|
256
|
+
return entry;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
void _checkReserved(String ref) {
|
|
260
|
+
if (!_reserved.contains(r.refName(ref))) return;
|
|
261
|
+
t.fail('plugin_ref_reserved', 'ref is reserved by the host: $ref',
|
|
262
|
+
{'ref': ref});
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
void _run(Entry entry, String callback, String at) {
|
|
266
|
+
final fn = t.get(entry.def, callback);
|
|
267
|
+
_log.add('${entry.ref}:$at');
|
|
268
|
+
_events.add({
|
|
269
|
+
'ref': entry.ref,
|
|
270
|
+
'event': at,
|
|
271
|
+
'seq': entry.seq,
|
|
272
|
+
'status': entry.status
|
|
273
|
+
});
|
|
274
|
+
if (fn is! Function) return;
|
|
275
|
+
|
|
276
|
+
intransition = true;
|
|
277
|
+
phase = at;
|
|
278
|
+
try {
|
|
279
|
+
(fn as dynamic)(Inst(this, entry));
|
|
280
|
+
} catch (e) {
|
|
281
|
+
// Section 12: `plugin_define_failed` and its three siblings are "a
|
|
282
|
+
// callback raised; wraps the cause". AN ERROR THAT ALREADY CARRIES A
|
|
283
|
+
// CODE KEEPS IT - the code is the error's identity, and a plugin
|
|
284
|
+
// raising `store_unreachable` must not have it rewritten. Only a
|
|
285
|
+
// code-less error is wrapped.
|
|
286
|
+
if (t.codeOf(e) != '') rethrow;
|
|
287
|
+
t.fail('plugin_${at}_failed',
|
|
288
|
+
'${entry.ref} raised in $at: ${t.messageOf(e)}',
|
|
289
|
+
{'ref': entry.ref, 'cause': t.messageOf(e)});
|
|
290
|
+
} finally {
|
|
291
|
+
intransition = false;
|
|
292
|
+
phase = null;
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
/// AUTO-TAGGING IS EXPLICIT (section 4 rule 3). `declare('stripe', {'tag':
|
|
297
|
+
/// '?'})` assigns the LOWEST UNUSED POSITIVE INTEGER tag and returns the
|
|
298
|
+
/// assigned pair. Without `'?'`, a collision is an error.
|
|
299
|
+
String _autotag(String name) {
|
|
300
|
+
for (var n = 1;; n++) {
|
|
301
|
+
final cand = r.formatRef(name, '$n');
|
|
302
|
+
if (!_inst.containsKey(cand)) return cand;
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
Entry declare(dynamic ref, [dynamic spec]) {
|
|
307
|
+
spec ??= <String, dynamic>{};
|
|
308
|
+
if (t.get(spec, 'tag') == '?') {
|
|
309
|
+
ref = _autotag(r.refName(r.canonRef(ref)));
|
|
310
|
+
}
|
|
311
|
+
final rf = r.canonRef(ref);
|
|
312
|
+
if (!t.truthy(t.get(spec, 'hostowned'))) _checkReserved(rf);
|
|
313
|
+
|
|
314
|
+
final defname = (t.get(spec, 'definition') ?? r.refName(rf)) as String;
|
|
315
|
+
final definition = catalog.get(defname);
|
|
316
|
+
if (definition == null) {
|
|
317
|
+
t.fail('plugin_unknown_definition', 'not in catalog: $defname',
|
|
318
|
+
{'name': defname});
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
final existing = _inst[rf];
|
|
322
|
+
if (existing != null) {
|
|
323
|
+
// Section 4 rule 1: a pair addresses at most one instance.
|
|
324
|
+
// Re-declaring the SAME definition is the idempotent case; a different
|
|
325
|
+
// one is a duplicate, not a silent overwrite (seneca) and not an
|
|
326
|
+
// impossibility (sdkgen).
|
|
327
|
+
if (t.get(existing.def, 'name') != t.get(definition, 'name')) {
|
|
328
|
+
t.fail('plugin_ref_duplicate', 'instance already declared: $rf',
|
|
329
|
+
{'ref': rf});
|
|
330
|
+
}
|
|
331
|
+
return existing;
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
final pos = t.get(spec, 'pos');
|
|
335
|
+
final entry = Entry(
|
|
336
|
+
rf,
|
|
337
|
+
definition,
|
|
338
|
+
'declared',
|
|
339
|
+
pos == null ? _inst.length : pos as int,
|
|
340
|
+
_seqn,
|
|
341
|
+
Map<String, dynamic>.from(
|
|
342
|
+
(t.get(spec, 'options') ?? <String, dynamic>{}) as Map),
|
|
343
|
+
t.get(spec, 'order'));
|
|
344
|
+
_seqn++;
|
|
345
|
+
_inst[rf] = entry;
|
|
346
|
+
return entry;
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
/// Section 9.1: a host that reserves a name MUST still be able to declare
|
|
350
|
+
/// the instance it reserved - "The host declares those instances itself,
|
|
351
|
+
/// after the user merge, and always wins."
|
|
352
|
+
///
|
|
353
|
+
/// THE BOUNDARY IS BY METHOD, NOT BY CALLER, and that is a real limit: no
|
|
354
|
+
/// language here can tell the embedding host from a plugin holding the
|
|
355
|
+
/// same host object. What reservation protects is CONFIGURATION -
|
|
356
|
+
/// documents, overlays, `VOXGIG_PLUGIN_*`, construction options and
|
|
357
|
+
/// ordinary declare/load/options - and all of that still checks.
|
|
358
|
+
Entry hostdeclare(dynamic ref, [dynamic spec]) {
|
|
359
|
+
_guard();
|
|
360
|
+
final merged = Map<String, dynamic>.from(
|
|
361
|
+
(spec ?? <String, dynamic>{}) as Map);
|
|
362
|
+
merged['hostowned'] = true;
|
|
363
|
+
return declare(ref, merged);
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
Entry load(dynamic ref, [dynamic spec]) {
|
|
367
|
+
_guard();
|
|
368
|
+
spec ??= <String, dynamic>{};
|
|
369
|
+
final entry = declare(ref, spec);
|
|
370
|
+
if (entry.status != 'declared') return entry; // idempotent trivially
|
|
371
|
+
|
|
372
|
+
final options = t.get(spec, 'options');
|
|
373
|
+
if (options != null) {
|
|
374
|
+
entry.options = Map<String, dynamic>.from(options as Map);
|
|
375
|
+
}
|
|
376
|
+
try {
|
|
377
|
+
_run(entry, 'define', 'define');
|
|
378
|
+
} catch (_) {
|
|
379
|
+
entry.status = 'failed';
|
|
380
|
+
rethrow;
|
|
381
|
+
}
|
|
382
|
+
entry.status = 'loaded';
|
|
383
|
+
|
|
384
|
+
// AT LOAD, and before anything runs: a cycle through restart-causing
|
|
385
|
+
// requirements does not settle, and the only safe time to report a
|
|
386
|
+
// non-terminating reconcile is before it starts (section 11.3).
|
|
387
|
+
// `provides` is populated by `define`, which has just run, so this is
|
|
388
|
+
// the first moment the graph is complete.
|
|
389
|
+
try {
|
|
390
|
+
dep.checkCycle(_graphNodes());
|
|
391
|
+
} catch (_) {
|
|
392
|
+
entry.status = 'failed';
|
|
393
|
+
rethrow;
|
|
394
|
+
}
|
|
395
|
+
return entry;
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
/// The requirement graph as plain data, for the pure detector.
|
|
399
|
+
List<dep.GraphNode> _graphNodes() => _refs()
|
|
400
|
+
.map((rf) => dep.GraphNode(
|
|
401
|
+
rf,
|
|
402
|
+
_inst[rf]!.provides.map((p) => t.get(p, 'name') as String).toList(),
|
|
403
|
+
dep.requirements(_inst[rf]!.options)))
|
|
404
|
+
.toList();
|
|
405
|
+
|
|
406
|
+
Entry activate(dynamic ref) {
|
|
407
|
+
_guard();
|
|
408
|
+
final entry = _need(ref);
|
|
409
|
+
if (entry.status == 'live') return entry; // no-op returning success
|
|
410
|
+
|
|
411
|
+
if (entry.status == 'failed') {
|
|
412
|
+
t.fail('plugin_bad_state', 'instance has failed: ${entry.ref}',
|
|
413
|
+
{'ref': entry.ref});
|
|
414
|
+
}
|
|
415
|
+
// Section 9.6: `active: false` bars the instance from running, and the
|
|
416
|
+
// bar is on the INSTANCE rather than on the apply that set it. `ready`
|
|
417
|
+
// reaches this through `activate`, so one guard covers both verbs the
|
|
418
|
+
// design names.
|
|
419
|
+
if (entry.barred) {
|
|
420
|
+
t.fail('plugin_inactive',
|
|
421
|
+
'instance is barred by active: false: ${entry.ref}',
|
|
422
|
+
{'ref': entry.ref});
|
|
423
|
+
}
|
|
424
|
+
if (entry.status == 'declared') load(entry.ref);
|
|
425
|
+
|
|
426
|
+
// A declared requirement that is not live means `pending`: activation is
|
|
427
|
+
// a STANDING REQUEST, not a one-shot event.
|
|
428
|
+
final unmet = _unmetOf(entry);
|
|
429
|
+
if (unmet.isNotEmpty) {
|
|
430
|
+
entry.unmet = unmet;
|
|
431
|
+
entry.status = 'pending';
|
|
432
|
+
return entry;
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
try {
|
|
436
|
+
_run(entry, 'activate', 'activate');
|
|
437
|
+
} catch (_) {
|
|
438
|
+
// Unwind whatever the partial activation captured, in reverse.
|
|
439
|
+
_unwind(entry);
|
|
440
|
+
entry.status = 'failed';
|
|
441
|
+
rethrow;
|
|
442
|
+
}
|
|
443
|
+
// Section 11.4: THE SELECTION IS MADE HERE, once, and remembered. Every
|
|
444
|
+
// later question - the cascade, `hold`, `unmet` - reads it back rather
|
|
445
|
+
// than re-ranking, which is what "always-reluctant" means.
|
|
446
|
+
for (final req in dep.requirements(entry.options)) {
|
|
447
|
+
_chosen(entry, req, true);
|
|
448
|
+
}
|
|
449
|
+
entry.status = 'live';
|
|
450
|
+
_reconcile();
|
|
451
|
+
return entry;
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
Entry deactivate(dynamic ref) {
|
|
455
|
+
_guard();
|
|
456
|
+
final entry = _need(ref);
|
|
457
|
+
if (entry.status == 'loaded' || entry.status == 'declared') return entry;
|
|
458
|
+
|
|
459
|
+
// Section 5.2: `unload` is THE ONLY TRANSITION OUT OF `failed`.
|
|
460
|
+
if (entry.status == 'failed') {
|
|
461
|
+
t.fail('plugin_bad_state', 'instance has failed: ${entry.ref}',
|
|
462
|
+
{'ref': entry.ref});
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
if (entry.status == 'pending') {
|
|
466
|
+
// DEACTIVATING A PENDING INSTANCE RUNS NO CALLBACK (section 5.2). It
|
|
467
|
+
// never reached activate, so it holds no scope and no live bindings;
|
|
468
|
+
// running the definition's deactivate there would be teardown without
|
|
469
|
+
// matching setup, which plugins are not written to survive and which
|
|
470
|
+
// could fail an instance that had done nothing wrong. It cannot fail.
|
|
471
|
+
entry.status = 'loaded';
|
|
472
|
+
entry.unmet = [];
|
|
473
|
+
return entry;
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
_held(entry);
|
|
477
|
+
_cascade(entry, {});
|
|
478
|
+
_teardown(entry);
|
|
479
|
+
entry.status = 'loaded';
|
|
480
|
+
_reconcile();
|
|
481
|
+
return entry;
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
/// The live half of leaving `live`: the callback, then the scope.
|
|
485
|
+
void _teardown(Entry entry) {
|
|
486
|
+
try {
|
|
487
|
+
_run(entry, 'deactivate', 'deactivate');
|
|
488
|
+
} catch (_) {
|
|
489
|
+
_unwind(entry);
|
|
490
|
+
entry.status = 'failed';
|
|
491
|
+
rethrow;
|
|
492
|
+
}
|
|
493
|
+
_releaseCheck(entry, _unwind(entry));
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
void unload(dynamic ref) {
|
|
497
|
+
_guard();
|
|
498
|
+
final entry = _need(ref);
|
|
499
|
+
if (entry.status == 'live' || entry.status == 'pending') {
|
|
500
|
+
// Section 5.2: ANY failure during a transition lands the instance in
|
|
501
|
+
// `failed`, with the scope STILL FULLY UNWOUND - and the instance
|
|
502
|
+
// STAYS REGISTERED, because `failed` is a state an operator has to be
|
|
503
|
+
// able to see.
|
|
504
|
+
if (entry.status == 'live') {
|
|
505
|
+
_held(entry);
|
|
506
|
+
_cascade(entry, {});
|
|
507
|
+
_teardown(entry);
|
|
508
|
+
}
|
|
509
|
+
entry.status = 'loaded';
|
|
510
|
+
}
|
|
511
|
+
if (entry.status == 'loaded' || entry.status == 'failed') {
|
|
512
|
+
try {
|
|
513
|
+
_run(entry, 'close', 'close');
|
|
514
|
+
} finally {
|
|
515
|
+
_inst.remove(entry.ref);
|
|
516
|
+
}
|
|
517
|
+
return;
|
|
518
|
+
}
|
|
519
|
+
_inst.remove(entry.ref);
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
/// Runs the whole forward path in one call (section 5.1).
|
|
523
|
+
Entry ready(dynamic ref) {
|
|
524
|
+
_guard();
|
|
525
|
+
final rf = r.canonRef(ref);
|
|
526
|
+
if (!_inst.containsKey(rf)) declare(rf);
|
|
527
|
+
if (_inst[rf]!.status == 'declared') load(rf);
|
|
528
|
+
return activate(rf);
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
/// Bindings go live only when activation succeeds (section 8.1), so the
|
|
532
|
+
/// teardown is the exact inverse: reverse order, always.
|
|
533
|
+
///
|
|
534
|
+
/// Returns the errors the scope raised. Section 8.3: "A failing release
|
|
535
|
+
/// does not stop the rest. Every entry runs, in reverse order, whatever
|
|
536
|
+
/// any of them does; the errors are collected and raised as one
|
|
537
|
+
/// `plugin_release_failed`."
|
|
538
|
+
///
|
|
539
|
+
/// A selection belongs to ONE activation (section 11.4). Leaving `live` by
|
|
540
|
+
/// any door drops it, so the next activation ranks afresh - keeping it
|
|
541
|
+
/// would make a consumer prefer a provider it never actually ran against.
|
|
542
|
+
List<Object> _unwind(Entry entry) {
|
|
543
|
+
entry.selected = {};
|
|
544
|
+
final errors = <Object>[];
|
|
545
|
+
for (var i = entry.scope.length - 1; i >= 0; i--) {
|
|
546
|
+
try {
|
|
547
|
+
entry.scope[i]();
|
|
548
|
+
} catch (e) {
|
|
549
|
+
errors.add(e);
|
|
550
|
+
}
|
|
551
|
+
}
|
|
552
|
+
entry.scope.clear();
|
|
553
|
+
return errors;
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
/// Section 8.3: "A failed release ends the instance in `failed`, exactly
|
|
557
|
+
/// as a failed callback does (5.2) - a release that raised may have
|
|
558
|
+
/// leaked, and an instance that may be holding resources it cannot account
|
|
559
|
+
/// for must not be reactivated."
|
|
560
|
+
void _releaseCheck(Entry entry, List<Object> errors) {
|
|
561
|
+
if (errors.isEmpty) return;
|
|
562
|
+
entry.status = 'failed';
|
|
563
|
+
final causes = errors.map(t.messageOf).toList();
|
|
564
|
+
t.fail(
|
|
565
|
+
'plugin_release_failed',
|
|
566
|
+
'release failed for ${entry.ref}: ${causes.join('; ')}',
|
|
567
|
+
{'ref': entry.ref, 'cause': causes});
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
/// A REQUIREMENT IS ON A CAPABILITY, not on a ref (section 11.1). A bare
|
|
571
|
+
/// string is shorthand for `{name}`. A ref satisfies too, because a host
|
|
572
|
+
/// that genuinely needs a specific instance should not have to invent a
|
|
573
|
+
/// capability for it.
|
|
574
|
+
List<String> _unmetOf(Entry entry) => dep
|
|
575
|
+
.requirements(entry.options)
|
|
576
|
+
.where(dep.gatesActivation)
|
|
577
|
+
.where((req) => _providersOf(req).isEmpty)
|
|
578
|
+
.map((req) => t.get(req, 'name') as String)
|
|
579
|
+
.toList();
|
|
580
|
+
|
|
581
|
+
/// Section 11.4's always-reluctant selection, and the ONE place a provider
|
|
582
|
+
/// is picked for a live instance. If this instance already selected a
|
|
583
|
+
/// provider for `req` and that provider is STILL a candidate, it keeps it
|
|
584
|
+
/// - a better-ranked newcomer does not take it.
|
|
585
|
+
///
|
|
586
|
+
/// `remember` is false for the questions asked ABOUT an instance rather
|
|
587
|
+
/// than BY it: introspection must not create a binding.
|
|
588
|
+
String? _chosen(Entry entry, dynamic req, bool remember) {
|
|
589
|
+
final cands = _providersOf(req);
|
|
590
|
+
if (cands.isEmpty) return null;
|
|
591
|
+
final name = t.get(req, 'name') as String;
|
|
592
|
+
final held = entry.selected[name];
|
|
593
|
+
if (held != null && cands.any((c) => t.get(c, 'ref') == held)) return held;
|
|
594
|
+
final pick = t.get(cands[0], 'ref') as String;
|
|
595
|
+
if (remember) entry.selected[name] = pick;
|
|
596
|
+
return pick;
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
/// The instances currently SELECTED for this one's restart-causing
|
|
600
|
+
/// requirements. A BINDING IS TO AN INSTANCE, not to a capability (section
|
|
601
|
+
/// 11.1): the selected one going away restarts a `static` consumer even
|
|
602
|
+
/// though a survivor is available.
|
|
603
|
+
List<String> _boundProviders(Entry entry) {
|
|
604
|
+
final out = <String>[];
|
|
605
|
+
for (final req in dep.requirements(entry.options)) {
|
|
606
|
+
if (!dep.restartsOnLoss(req)) continue;
|
|
607
|
+
final ref = _chosen(entry, req, false);
|
|
608
|
+
if (ref != null && !out.contains(ref)) out.add(ref);
|
|
609
|
+
}
|
|
610
|
+
return out;
|
|
611
|
+
}
|
|
612
|
+
|
|
613
|
+
/// Live instances whose selected provider is `ref` and which would be
|
|
614
|
+
/// restarted by losing it.
|
|
615
|
+
List<String> _consumersOf(String ref) => _refs()
|
|
616
|
+
.where((rf) =>
|
|
617
|
+
rf != ref &&
|
|
618
|
+
_inst[rf]!.status == 'live' &&
|
|
619
|
+
_boundProviders(_inst[rf]!).contains(ref))
|
|
620
|
+
.toList();
|
|
621
|
+
|
|
622
|
+
/// Section 11.3's `hold` asks a DIFFERENT question from the cascade, and
|
|
623
|
+
/// reading it off `_consumersOf` answered the cascade's.
|
|
624
|
+
///
|
|
625
|
+
/// The cascade wants the edges that RESTART - mandatory-static and
|
|
626
|
+
/// optional-static - because a restart is what it performs. `hold` says
|
|
627
|
+
/// "deactivating a REQUIRED instance is `plugin_dependency_held`", and
|
|
628
|
+
/// required is cardinality: `gatesActivation`, not `restartsOnLoss`. The
|
|
629
|
+
/// two sets differ in both directions and each difference was a real bug.
|
|
630
|
+
///
|
|
631
|
+
/// A MANDATORY-DYNAMIC consumer was excluded, so the strictest policy let
|
|
632
|
+
/// a provider go that a live consumer could not do without - `dynamic`
|
|
633
|
+
/// promises survival of a SWAP, and under `hold` there is no swap, so the
|
|
634
|
+
/// consumer falls back to `pending`.
|
|
635
|
+
///
|
|
636
|
+
/// An OPTIONAL-STATIC consumer was included, so `hold` refused a
|
|
637
|
+
/// deactivation on behalf of an instance that had said in writing it does
|
|
638
|
+
/// not need the thing.
|
|
639
|
+
List<String> _holdersOf(String ref) => _refs().where((rf) {
|
|
640
|
+
final c = _inst[rf]!;
|
|
641
|
+
if (rf == ref || c.status != 'live') return false;
|
|
642
|
+
return dep.requirements(c.options).any((req) =>
|
|
643
|
+
dep.gatesActivation(req) && _chosen(c, req, false) == ref);
|
|
644
|
+
}).toList();
|
|
645
|
+
|
|
646
|
+
List<dynamic> _providersOf(dynamic req) {
|
|
647
|
+
final cands = <dynamic>[];
|
|
648
|
+
final name = t.get(req, 'name');
|
|
649
|
+
final want = r.canon(name);
|
|
650
|
+
for (final ref in _refs()) {
|
|
651
|
+
final target = _inst[ref]!;
|
|
652
|
+
if (target.status != 'live') continue;
|
|
653
|
+
// A ref satisfies directly.
|
|
654
|
+
if (ref == want) {
|
|
655
|
+
cands.add({
|
|
656
|
+
'ref': ref,
|
|
657
|
+
'pos': target.pos,
|
|
658
|
+
'provides': {'name': name}
|
|
659
|
+
});
|
|
660
|
+
continue;
|
|
661
|
+
}
|
|
662
|
+
for (final prov in target.provides) {
|
|
663
|
+
if (t.get(prov, 'name') == name) {
|
|
664
|
+
cands.add({'ref': ref, 'pos': target.pos, 'provides': prov});
|
|
665
|
+
}
|
|
666
|
+
}
|
|
667
|
+
}
|
|
668
|
+
return cap.resolveCapability(req, cands);
|
|
669
|
+
}
|
|
670
|
+
|
|
671
|
+
/// CONSUMERS GO DOWN FIRST, NOT AFTERWARDS (section 11.3).
|
|
672
|
+
///
|
|
673
|
+
/// The cascade is part of the provider's own deactivation and runs BEFORE
|
|
674
|
+
/// the provider's `deactivate` callback and scope unwind, so a consumer's
|
|
675
|
+
/// teardown can still call the thing it depends on - flushing a buffer to
|
|
676
|
+
/// the store it is about to lose is exactly what a `deactivate` callback
|
|
677
|
+
/// is for, and a cascade that fired after the provider was already gone
|
|
678
|
+
/// would make that impossible.
|
|
679
|
+
void _cascade(Entry provider, Map<String, bool> seen) {
|
|
680
|
+
if (seen[provider.ref] == true) return;
|
|
681
|
+
seen[provider.ref] = true;
|
|
682
|
+
|
|
683
|
+
for (final rf in _consumersOf(provider.ref)) {
|
|
684
|
+
final consumer = _inst[rf]!;
|
|
685
|
+
if (consumer.status != 'live') continue;
|
|
686
|
+
_cascade(consumer, seen); // deepest-first
|
|
687
|
+
_demote(consumer);
|
|
688
|
+
}
|
|
689
|
+
}
|
|
690
|
+
|
|
691
|
+
/// Leaving `live` for `pending` - or for `failed`, because section 5.2
|
|
692
|
+
/// says ANY failure during a transition lands the instance there. Marking
|
|
693
|
+
/// it `pending` handed it straight back to `_reconcile`, which would
|
|
694
|
+
/// activate it again the moment the provider returned.
|
|
695
|
+
void _demote(Entry entry) {
|
|
696
|
+
var bad = false;
|
|
697
|
+
try {
|
|
698
|
+
_run(entry, 'deactivate', 'deactivate');
|
|
699
|
+
} catch (_) {
|
|
700
|
+
bad = true;
|
|
701
|
+
}
|
|
702
|
+
final errors = _unwind(entry);
|
|
703
|
+
if (bad || errors.isNotEmpty) {
|
|
704
|
+
entry.status = 'failed';
|
|
705
|
+
return;
|
|
706
|
+
}
|
|
707
|
+
entry.status = 'pending';
|
|
708
|
+
entry.unmet = _unmetOf(entry);
|
|
709
|
+
}
|
|
710
|
+
|
|
711
|
+
/// The hold check is A GUARD ON AD-HOC DEACTIVATION, NOT ON COORDINATED
|
|
712
|
+
/// TEARDOWN. In a bulk operation that is removing the holders too -
|
|
713
|
+
/// `close`, or an `apply` plan whose own steps deactivate them - it is
|
|
714
|
+
/// suspended for exactly those holders, and the teardown still runs
|
|
715
|
+
/// consumers before providers.
|
|
716
|
+
void _held(Entry entry) {
|
|
717
|
+
if (_dependency != 'hold' || _coordinated) return;
|
|
718
|
+
final holders = _holdersOf(entry.ref);
|
|
719
|
+
if (holders.isEmpty) return;
|
|
720
|
+
t.fail(
|
|
721
|
+
'plugin_dependency_held',
|
|
722
|
+
'instance is required by live consumers: ${entry.ref}',
|
|
723
|
+
{'ref': entry.ref, 'holders': holders});
|
|
724
|
+
}
|
|
725
|
+
|
|
726
|
+
/// EAGER reconciliation: run to a fixed point rather than scheduling.
|
|
727
|
+
///
|
|
728
|
+
/// Two directions, and both are the reason `pending` exists. Activation is
|
|
729
|
+
/// a STANDING REQUEST, not a one-shot event.
|
|
730
|
+
void _reconcile() {
|
|
731
|
+
var moved = true;
|
|
732
|
+
var rounds = 0;
|
|
733
|
+
while (moved) {
|
|
734
|
+
moved = false;
|
|
735
|
+
rounds++;
|
|
736
|
+
if (rounds > 1000) break;
|
|
737
|
+
|
|
738
|
+
// Losses first, so a cascade settles in one pass rather than
|
|
739
|
+
// alternating with re-activations.
|
|
740
|
+
for (final rf in _refs()) {
|
|
741
|
+
final entry = _inst[rf];
|
|
742
|
+
if (entry == null || entry.status != 'live') continue;
|
|
743
|
+
// POLICY IS PER REQUIREMENT, not per instance (section 11.3). A
|
|
744
|
+
// `dynamic` requirement whose provider is gone leaves the consumer
|
|
745
|
+
// LIVE and notified.
|
|
746
|
+
final lost = dep
|
|
747
|
+
.requirements(entry.options)
|
|
748
|
+
.where(dep.gatesActivation)
|
|
749
|
+
.where((q) => _providersOf(q).isEmpty)
|
|
750
|
+
.toList();
|
|
751
|
+
if (lost.isEmpty) continue;
|
|
752
|
+
if (!lost.any(dep.restartsOnLoss)) continue;
|
|
753
|
+
_demote(entry);
|
|
754
|
+
moved = true;
|
|
755
|
+
}
|
|
756
|
+
|
|
757
|
+
for (final rf in _refs()) {
|
|
758
|
+
final entry = _inst[rf];
|
|
759
|
+
if (entry == null || entry.status != 'pending') continue;
|
|
760
|
+
if (_unmetOf(entry).isNotEmpty) continue;
|
|
761
|
+
try {
|
|
762
|
+
_run(entry, 'activate', 'activate');
|
|
763
|
+
entry.status = 'live';
|
|
764
|
+
entry.unmet = [];
|
|
765
|
+
} catch (_) {
|
|
766
|
+
_unwind(entry);
|
|
767
|
+
entry.status = 'failed';
|
|
768
|
+
}
|
|
769
|
+
moved = true;
|
|
770
|
+
}
|
|
771
|
+
}
|
|
772
|
+
}
|
|
773
|
+
|
|
774
|
+
// --- ordering --------------------------------------------------------
|
|
775
|
+
|
|
776
|
+
List<String> order([String? point]) {
|
|
777
|
+
// Sorted by declaration SEQUENCE, which is what makes the section 7
|
|
778
|
+
// sort's fall-through deterministic in a language whose maps have no
|
|
779
|
+
// meaningful order. Section 7 breaks ties by `pos`; two instances CAN
|
|
780
|
+
// share one - `declare` defaults `pos` to the registry size, so an
|
|
781
|
+
// unload followed by a fresh declare reuses a surviving instance's - and
|
|
782
|
+
// past that this was falling through to map order. `seq` is that order,
|
|
783
|
+
// made explicit.
|
|
784
|
+
final live = _inst.keys.where((rf) => _inst[rf]!.status == 'live').toList();
|
|
785
|
+
live.sort((a, b) => _inst[a]!.seq.compareTo(_inst[b]!.seq));
|
|
786
|
+
final bindings = live
|
|
787
|
+
.map((rf) => ord.OrderNode(rf, _inst[rf]!.pos, _inst[rf]!.order))
|
|
788
|
+
.toList();
|
|
789
|
+
final spec = point == null ? null : _points[point];
|
|
790
|
+
return ord.resolveOrder(bindings, spec == null ? null : t.get(spec, 'pin'));
|
|
791
|
+
}
|
|
792
|
+
|
|
793
|
+
// --- points ----------------------------------------------------------
|
|
794
|
+
|
|
795
|
+
/// Live bindings on a point, in resolved order. Recomputed on any change
|
|
796
|
+
/// to the live set (section 7) rather than cached at startup - the bug a
|
|
797
|
+
/// host discovers only when something deactivates in production.
|
|
798
|
+
List<pt.Binding> _bound(String point) {
|
|
799
|
+
final out = <pt.Binding>[];
|
|
800
|
+
for (final ref in order(point)) {
|
|
801
|
+
final entry = _inst[ref]!;
|
|
802
|
+
// The band is the INSTANCE's ordering block (section 7), stamped by
|
|
803
|
+
// the host. A plugin passing its own would be ranking itself above the
|
|
804
|
+
// order its document declared.
|
|
805
|
+
final band = t.asInt(t.get(entry.order ?? {}, 'band')) ?? 0;
|
|
806
|
+
for (final b in entry.bindings) {
|
|
807
|
+
if (b.point == point) out.add(b.withBand(band));
|
|
808
|
+
}
|
|
809
|
+
}
|
|
810
|
+
return out;
|
|
811
|
+
}
|
|
812
|
+
|
|
813
|
+
dynamic _pointSpec(String point, String want) {
|
|
814
|
+
final spec = _points[point];
|
|
815
|
+
if (spec == null) {
|
|
816
|
+
t.fail('plugin_point_unknown', 'no such point: $point', {'point': point});
|
|
817
|
+
}
|
|
818
|
+
final kind = t.get(spec, 'kind');
|
|
819
|
+
if (want == 'hook') {
|
|
820
|
+
// A point with no declared kind is a hook, which is what makes `{}`
|
|
821
|
+
// the minimal point declaration.
|
|
822
|
+
if (kind != null && kind != 'hook') {
|
|
823
|
+
t.fail('plugin_point_kind', 'point is not a hook: $point',
|
|
824
|
+
{'point': point, 'kind': kind});
|
|
825
|
+
}
|
|
826
|
+
return spec;
|
|
827
|
+
}
|
|
828
|
+
if (kind != want) {
|
|
829
|
+
t.fail('plugin_point_kind', 'point is not a $want: $point',
|
|
830
|
+
{'point': point, 'kind': kind});
|
|
831
|
+
}
|
|
832
|
+
return spec;
|
|
833
|
+
}
|
|
834
|
+
|
|
835
|
+
dynamic emit(String point, [dynamic arg]) {
|
|
836
|
+
final spec = _pointSpec(point, 'hook');
|
|
837
|
+
return pt.pointEmit(
|
|
838
|
+
_bound(point), (t.get(spec, 'mode') ?? 'emit') as String, arg);
|
|
839
|
+
}
|
|
840
|
+
|
|
841
|
+
dynamic call(String point, [dynamic arg]) {
|
|
842
|
+
final spec = _pointSpec(point, 'chain');
|
|
843
|
+
final base = t.get(spec, 'base') ?? (dynamic a) => a;
|
|
844
|
+
return pt.compose(_bound(point), base as dynamic Function(dynamic))(arg);
|
|
845
|
+
}
|
|
846
|
+
|
|
847
|
+
dynamic provider(String point, [dynamic arg]) {
|
|
848
|
+
final spec = _pointSpec(point, 'provider');
|
|
849
|
+
final pick = pt.pointProvider(_bound(point), spec);
|
|
850
|
+
if (pick.winner == null) return t.get(spec, 'default');
|
|
851
|
+
return pick.winner!.fn(null, arg);
|
|
852
|
+
}
|
|
853
|
+
|
|
854
|
+
/// The losers are VISIBLE rather than silently ignored (section 6.3).
|
|
855
|
+
List<String> shadowed(String point) {
|
|
856
|
+
final spec = _points[point];
|
|
857
|
+
if (spec == null) return [];
|
|
858
|
+
return pt.pointProvider(_bound(point), spec).shadowed;
|
|
859
|
+
}
|
|
860
|
+
|
|
861
|
+
dynamic exports(String spec) {
|
|
862
|
+
final all = <ex.Exported>[];
|
|
863
|
+
for (final ref in _refs()) {
|
|
864
|
+
final entry = _inst[ref]!;
|
|
865
|
+
// Exports of a `loaded` (not live) instance are VISIBLE (11).
|
|
866
|
+
if (entry.status == 'declared' || entry.status == 'failed') continue;
|
|
867
|
+
for (final k in t.sortedKeys(entry.exports)) {
|
|
868
|
+
all.add(ex.Exported(ref, k, entry.exports[k]));
|
|
869
|
+
}
|
|
870
|
+
}
|
|
871
|
+
return ex.resolveExport(spec, all);
|
|
872
|
+
}
|
|
873
|
+
|
|
874
|
+
/// The live providers of a capability, best-first (section 11.1).
|
|
875
|
+
List<String> capability(String name) {
|
|
876
|
+
final cands = <dynamic>[];
|
|
877
|
+
for (final ref in _refs()) {
|
|
878
|
+
final entry = _inst[ref]!;
|
|
879
|
+
if (entry.status != 'live') continue;
|
|
880
|
+
for (final prov in entry.provides) {
|
|
881
|
+
if (t.get(prov, 'name') == name) {
|
|
882
|
+
cands.add({'ref': ref, 'pos': entry.pos, 'provides': prov});
|
|
883
|
+
}
|
|
884
|
+
}
|
|
885
|
+
}
|
|
886
|
+
return cap
|
|
887
|
+
.resolveCapability({'name': name}, cands)
|
|
888
|
+
.map((c) => t.get(c, 'ref') as String)
|
|
889
|
+
.toList();
|
|
890
|
+
}
|
|
891
|
+
|
|
892
|
+
// --- documents -------------------------------------------------------
|
|
893
|
+
|
|
894
|
+
dynamic _shapeOf(String ref) {
|
|
895
|
+
final definition = catalog.get(r.refName(ref));
|
|
896
|
+
return definition == null ? null : t.get(definition, 'shape');
|
|
897
|
+
}
|
|
898
|
+
|
|
899
|
+
/// Section 9.6: "load what is missing, UNLOAD WHAT IS GONE, patch what
|
|
900
|
+
/// changed, and move activation state to match", with the stated ordering
|
|
901
|
+
/// - "deactivations and unloads first (reverse load order), then loads,
|
|
902
|
+
/// then activations in load order".
|
|
903
|
+
///
|
|
904
|
+
/// FOUR PHASES, NOT ONE INTERLEAVED LOOP. An earlier draft walked the
|
|
905
|
+
/// document once, which never looked at instances the new document had
|
|
906
|
+
/// DROPPED - so an integration removed from a config reload stayed live
|
|
907
|
+
/// with its bindings and resources.
|
|
908
|
+
void apply(dynamic doc, [dynamic profile]) {
|
|
909
|
+
_guard();
|
|
910
|
+
profile ??= t.get(_opts, 'profile');
|
|
911
|
+
final norm = config.normalizeConfig({
|
|
912
|
+
'doc': doc,
|
|
913
|
+
'profile': profile,
|
|
914
|
+
'keys': t.get(_opts, 'keys'),
|
|
915
|
+
'reserved': _reserved
|
|
916
|
+
});
|
|
917
|
+
|
|
918
|
+
final want = norm['order'] as List<String>;
|
|
919
|
+
final defaults = t.get(_opts, 'defaults') ?? {};
|
|
920
|
+
final optionsof = <String, Map<String, dynamic>>{};
|
|
921
|
+
for (final ref in want) {
|
|
922
|
+
optionsof[ref] = config.resolveOptions({
|
|
923
|
+
'ref': ref,
|
|
924
|
+
'doc': doc,
|
|
925
|
+
'profile': profile,
|
|
926
|
+
'shape': _shapeOf(ref),
|
|
927
|
+
'hostdefaults': t.get(defaults, r.refName(ref))
|
|
928
|
+
});
|
|
929
|
+
}
|
|
930
|
+
|
|
931
|
+
// Should this ref be LIVE after the apply? False for a ref the document
|
|
932
|
+
// declares lazy or inactive AND for one it does not name at all - which
|
|
933
|
+
// is what makes "unload what is gone" and "unload what was toggled off"
|
|
934
|
+
// one rule rather than two.
|
|
935
|
+
bool wantlive(String ref) {
|
|
936
|
+
final ent = t.get(norm['instance'], ref);
|
|
937
|
+
return ent != null &&
|
|
938
|
+
t.truthy(t.get(ent, 'active')) &&
|
|
939
|
+
t.get(ent, 'start') == 'eager';
|
|
940
|
+
}
|
|
941
|
+
|
|
942
|
+
// --- phase 1: deactivations and unloads, REVERSE load order ---------
|
|
943
|
+
final drop = _inst.keys
|
|
944
|
+
.where((rf) => _inst[rf]!.status != 'declared' && !wantlive(rf))
|
|
945
|
+
.toList();
|
|
946
|
+
// Highest `pos` first, ref-descending for a tie, so a consumer declared
|
|
947
|
+
// after its provider goes down first.
|
|
948
|
+
drop.sort((a, b) {
|
|
949
|
+
final pa = _inst[a]!.pos, pb = _inst[b]!.pos;
|
|
950
|
+
return pa == pb ? b.compareTo(a) : pb.compareTo(pa);
|
|
951
|
+
});
|
|
952
|
+
for (final ref in drop) {
|
|
953
|
+
unload(ref);
|
|
954
|
+
}
|
|
955
|
+
|
|
956
|
+
// --- phase 2: declare and patch EVERYTHING, in load order -----------
|
|
957
|
+
for (final ref in want) {
|
|
958
|
+
final ent = t.get(norm['instance'], ref);
|
|
959
|
+
// NO OPTIONS HERE, and the omission is the fix rather than an
|
|
960
|
+
// oversight. `declare` ADOPTS the options map it is handed as the
|
|
961
|
+
// instance's own, so passing the resolved map made target and
|
|
962
|
+
// source THE SAME MAP in the refill below - which cleared its own
|
|
963
|
+
// source and left a first-time instance with no options at all.
|
|
964
|
+
// `declare` makes its own empty map and the refill fills it, so
|
|
965
|
+
// both paths are now one path.
|
|
966
|
+
declare(ref, {
|
|
967
|
+
'order': t.get(ent, 'order'),
|
|
968
|
+
'pos': t.get(ent, 'pos')
|
|
969
|
+
});
|
|
970
|
+
final entry = _inst[ref]!;
|
|
971
|
+
// The bar is REASSERTED ON EVERY APPLY, in both directions - a
|
|
972
|
+
// document that turns the instance back on clears it, which is the
|
|
973
|
+
// whole point of a config switch.
|
|
974
|
+
entry.barred = !t.truthy(t.get(ent, 'active'));
|
|
975
|
+
// REFILL rather than REBIND. A definition's callbacks close over the
|
|
976
|
+
// options map they were handed at `define`.
|
|
977
|
+
entry.options
|
|
978
|
+
..clear()
|
|
979
|
+
..addAll(optionsof[ref]!);
|
|
980
|
+
entry.order = t.get(ent, 'order');
|
|
981
|
+
entry.pos = t.get(ent, 'pos') as int;
|
|
982
|
+
}
|
|
983
|
+
|
|
984
|
+
// --- phase 3: loads, in load order ----------------------------------
|
|
985
|
+
// ONLY THE EAGER, ACTIVE ONES: "a document of twenty lazy instances is
|
|
986
|
+
// twenty map entries and no executed code" (9.6).
|
|
987
|
+
for (final ref in want) {
|
|
988
|
+
if (wantlive(ref)) load(ref);
|
|
989
|
+
}
|
|
990
|
+
|
|
991
|
+
// --- phase 4: activations, in load order ----------------------------
|
|
992
|
+
for (final ref in want) {
|
|
993
|
+
if (wantlive(ref)) activate(ref);
|
|
994
|
+
}
|
|
995
|
+
}
|
|
996
|
+
|
|
997
|
+
void options(dynamic ref, dynamic patch) {
|
|
998
|
+
_guard();
|
|
999
|
+
final entry = _need(ref);
|
|
1000
|
+
final previous = Map<String, dynamic>.from(entry.options);
|
|
1001
|
+
final merged = Map<String, dynamic>.from(previous);
|
|
1002
|
+
if (patch != null) merged.addAll((patch as Map).cast<String, dynamic>());
|
|
1003
|
+
final resolved = config.resolveOptions({
|
|
1004
|
+
'ref': entry.ref,
|
|
1005
|
+
'shape': _shapeOf(entry.ref),
|
|
1006
|
+
'doc': <String, dynamic>{},
|
|
1007
|
+
'patch': merged
|
|
1008
|
+
});
|
|
1009
|
+
entry.options
|
|
1010
|
+
..clear()
|
|
1011
|
+
..addAll(resolved);
|
|
1012
|
+
if (entry.status != 'live') return;
|
|
1013
|
+
|
|
1014
|
+
final reconfigure = t.get(entry.def, 'reconfigure');
|
|
1015
|
+
if (reconfigure is Function) {
|
|
1016
|
+
intransition = true;
|
|
1017
|
+
try {
|
|
1018
|
+
(reconfigure as dynamic)(Inst(this, entry), entry.options, previous);
|
|
1019
|
+
} finally {
|
|
1020
|
+
intransition = false;
|
|
1021
|
+
}
|
|
1022
|
+
} else {
|
|
1023
|
+
// Always correct and sometimes expensive; `reconfigure` exists to make
|
|
1024
|
+
// the common case cheap (section 9.4).
|
|
1025
|
+
deactivate(entry.ref);
|
|
1026
|
+
activate(entry.ref);
|
|
1027
|
+
}
|
|
1028
|
+
}
|
|
1029
|
+
|
|
1030
|
+
void close() {
|
|
1031
|
+
// A bulk teardown removing the holders too, so `hold` is suspended for
|
|
1032
|
+
// exactly those holders (section 11.3) - while the consumers-first
|
|
1033
|
+
// cascade still runs, which is the half that matters.
|
|
1034
|
+
_coordinated = true;
|
|
1035
|
+
try {
|
|
1036
|
+
for (final rf in _refs().reversed) {
|
|
1037
|
+
unload(rf);
|
|
1038
|
+
}
|
|
1039
|
+
} finally {
|
|
1040
|
+
_coordinated = false;
|
|
1041
|
+
}
|
|
1042
|
+
}
|
|
1043
|
+
|
|
1044
|
+
/// The same record section 6.6 gives a plugin about itself, reachable from
|
|
1045
|
+
/// outside for the corpus.
|
|
1046
|
+
Map<String, dynamic> positionOf(dynamic ref, String point) {
|
|
1047
|
+
final entry = _inst[r.canon(ref)];
|
|
1048
|
+
if (entry == null) {
|
|
1049
|
+
t.fail('plugin_not_loaded', 'no such instance: $ref', {'ref': ref});
|
|
1050
|
+
}
|
|
1051
|
+
final ranked = order(point);
|
|
1052
|
+
final index = ranked.indexOf(entry.ref);
|
|
1053
|
+
return {
|
|
1054
|
+
'index': index,
|
|
1055
|
+
'count': ranked.length,
|
|
1056
|
+
// Section 6.2 composes b1(b2(b3(base))) with the FIRST binding
|
|
1057
|
+
// OUTERMOST, so these are not index 0 and index count-1 the other way
|
|
1058
|
+
// round.
|
|
1059
|
+
'outermost': index == 0,
|
|
1060
|
+
'innermost': index == ranked.length - 1,
|
|
1061
|
+
};
|
|
1062
|
+
}
|
|
1063
|
+
|
|
1064
|
+
void define(dynamic definition) => catalog.add(definition);
|
|
1065
|
+
}
|
|
1066
|
+
|
|
1067
|
+
Host makeHost([dynamic options]) => Host(options);
|