space-data-module-sdk 0.8.4 → 0.8.5
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/README.md +117 -20
- package/bin/space-data-module.js +263 -0
- package/docs/.nojekyll +1 -0
- package/docs/AGENTS.md +34 -0
- package/docs/architecture.svg +141 -0
- package/docs/browser-wasmedge-isomorphic.md +179 -0
- package/docs/flatsql-streaming-standard.md +341 -0
- package/docs/gpu-module-abi.md +193 -0
- package/docs/index.html +125 -0
- package/docs/isomorphic-pthreads.md +188 -0
- package/docs/isomorphic-sdn-runtime-plan.md +167 -0
- package/docs/language-runtime-matrix.md +82 -0
- package/docs/manifest-structure.svg +114 -0
- package/docs/module-bundle-runtime-plan.md +19 -0
- package/docs/module-lifecycle.svg +70 -0
- package/docs/module-publication-standard.md +540 -0
- package/docs/node-red-default-node-parity.md +88 -0
- package/docs/protocol-installation.md +196 -0
- package/docs/secrets-capability.md +152 -0
- package/docs/styles.css +288 -0
- package/docs/testing-harness.md +408 -0
- package/docs/tri-runtime-parity.md +132 -0
- package/docs/wallet-callback.html +2 -0
- package/package.json +25 -6
- package/schemas/HttpRequestAbi.fbs +41 -0
- package/schemas/HttpResponseAbi.fbs +36 -0
- package/schemas/PluginManifest.fbs +2 -1
- package/src/AGENTS.md +1 -1
- package/src/app/codec.js +548 -0
- package/src/app/index.js +6 -0
- package/src/browser.js +5 -0
- package/src/bundle/constants.js +1 -0
- package/src/bundle/index.js +15 -0
- package/src/bundle/sigdomain.js +179 -0
- package/src/bundle/signing.js +767 -0
- package/src/bundle/wasm.js +3 -2
- package/src/capabilities.js +3 -0
- package/src/compat/index.js +7 -0
- package/src/compat/sdnLegacy.js +449 -0
- package/src/compiler/compileModule.js +556 -55
- package/src/compiler/flatcSupport.js +41 -27
- package/src/compiler/index.d.ts +2 -0
- package/src/compiler/index.js +18 -0
- package/src/compiler/invokeGlue.js +1212 -183
- package/src/compiler/pthreadArtifactGuard.js +910 -0
- package/src/compiler/sdnShimGenerator.js +323 -0
- package/src/compiler/wasiThreadsToolchain.js +150 -0
- package/src/compliance/index.js +11 -1
- package/src/compliance/legacyWildcardPorts.js +228 -0
- package/src/compliance/pluginCompliance.js +1000 -96
- package/src/field-stream/index.d.ts +31 -0
- package/src/field-stream/index.js +119 -0
- package/src/flow/dependencyStreamBridge.js +234 -0
- package/src/flow/flatsqlLinkShim.js +304 -0
- package/src/flow/flowCodec.js +107 -0
- package/src/flow/flowCompiler.js +2900 -0
- package/src/flow/flowRuntimeHost.js +877 -0
- package/src/flow/index.d.ts +117 -0
- package/src/flow/index.js +31 -0
- package/src/flow/isomorphicFlowHost.js +384 -0
- package/src/flow/jsFlowRuntime.js +275 -0
- package/src/flow/normalize.js +294 -0
- package/src/flow/runtime-src/flow_runtime.cpp +1699 -0
- package/src/flow/vendor/sdn-flow/MethodRegistry.js +400 -0
- package/src/flow/vendor/sdn-flow/constants.js +39 -0
- package/src/flow/vendor/sdn-flow/index.js +29 -0
- package/src/flow/vendor/sdn-flow/normalize.js +506 -0
- package/src/flow/vendor/sdn-flow/wasmCompatibility.js +189 -0
- package/src/generated/http/cpp/HttpRequestAbi_generated.h +285 -0
- package/src/generated/http/cpp/HttpResponseAbi_generated.h +192 -0
- package/src/generated/http/sdn/http/http-header.js +53 -0
- package/src/generated/http/sdn/http/http-header.ts +67 -0
- package/src/generated/http/sdn/http/http-request.js +132 -0
- package/src/generated/http/sdn/http/http-request.ts +179 -0
- package/src/generated/http/sdn/http/http-response.js +144 -0
- package/src/generated/http/sdn/http/http-response.ts +168 -0
- package/src/generated/http/sdn/http.js +11 -0
- package/src/generated/http/sdn/http.ts +4 -0
- package/src/generated/orbpro/flow/backpressure-policy.d.ts +12 -0
- package/src/generated/orbpro/flow/backpressure-policy.d.ts.map +1 -0
- package/src/generated/orbpro/flow/backpressure-policy.js +17 -0
- package/src/generated/orbpro/flow/backpressure-policy.js.map +1 -0
- package/src/generated/orbpro/flow/backpressure-policy.ts +15 -0
- package/src/generated/orbpro/flow/flow-bundle-manifest.d.ts +142 -0
- package/src/generated/orbpro/flow/flow-bundle-manifest.d.ts.map +1 -0
- package/src/generated/orbpro/flow/flow-bundle-manifest.js +304 -0
- package/src/generated/orbpro/flow/flow-bundle-manifest.js.map +1 -0
- package/src/generated/orbpro/flow/flow-bundle-manifest.ts +399 -0
- package/src/generated/orbpro/flow/flow-edge.d.ts +113 -0
- package/src/generated/orbpro/flow/flow-edge.d.ts.map +1 -0
- package/src/generated/orbpro/flow/flow-edge.js +221 -0
- package/src/generated/orbpro/flow/flow-edge.js.map +1 -0
- package/src/generated/orbpro/flow/flow-edge.ts +292 -0
- package/src/generated/orbpro/flow/flow-node.d.ts +80 -0
- package/src/generated/orbpro/flow/flow-node.d.ts.map +1 -0
- package/src/generated/orbpro/flow/flow-node.js +158 -0
- package/src/generated/orbpro/flow/flow-node.js.map +1 -0
- package/src/generated/orbpro/flow/flow-node.ts +202 -0
- package/src/generated/orbpro/flow/flow-program.d.ts +164 -0
- package/src/generated/orbpro/flow/flow-program.d.ts.map +1 -0
- package/src/generated/orbpro/flow/flow-program.js +350 -0
- package/src/generated/orbpro/flow/flow-program.js.map +1 -0
- package/src/generated/orbpro/flow/flow-program.ts +477 -0
- package/src/generated/orbpro/flow/flow-trigger.d.ts +108 -0
- package/src/generated/orbpro/flow/flow-trigger.d.ts.map +1 -0
- package/src/generated/orbpro/flow/flow-trigger.js +207 -0
- package/src/generated/orbpro/flow/flow-trigger.js.map +1 -0
- package/src/generated/orbpro/flow/flow-trigger.ts +276 -0
- package/src/generated/orbpro/flow/node-kind.d.ts +13 -0
- package/src/generated/orbpro/flow/node-kind.d.ts.map +1 -0
- package/src/generated/orbpro/flow/node-kind.js +16 -0
- package/src/generated/orbpro/flow/node-kind.js.map +1 -0
- package/src/generated/orbpro/{invoke.ts → flow/node-kind.ts} +12 -2
- package/src/generated/orbpro/flow/plugin-version-binding.d.ts +52 -0
- package/src/generated/orbpro/flow/plugin-version-binding.d.ts.map +1 -0
- package/src/generated/orbpro/flow/plugin-version-binding.js +85 -0
- package/src/generated/orbpro/flow/plugin-version-binding.js.map +1 -0
- package/src/generated/orbpro/flow/plugin-version-binding.ts +121 -0
- package/src/generated/orbpro/flow/schema-hash-binding.d.ts +70 -0
- package/src/generated/orbpro/flow/schema-hash-binding.d.ts.map +1 -0
- package/src/generated/orbpro/flow/schema-hash-binding.js +143 -0
- package/src/generated/orbpro/flow/schema-hash-binding.js.map +1 -0
- package/src/generated/orbpro/flow/schema-hash-binding.ts +189 -0
- package/src/generated/orbpro/flow/trigger-binding.d.ts +71 -0
- package/src/generated/orbpro/flow/trigger-binding.d.ts.map +1 -0
- package/src/generated/orbpro/flow/trigger-binding.js +142 -0
- package/src/generated/orbpro/flow/trigger-binding.js.map +1 -0
- package/src/generated/orbpro/flow/trigger-binding.ts +181 -0
- package/src/generated/orbpro/flow/trigger-kind.d.ts +14 -0
- package/src/generated/orbpro/flow/trigger-kind.d.ts.map +1 -0
- package/src/generated/orbpro/flow/trigger-kind.js +17 -0
- package/src/generated/orbpro/flow/trigger-kind.js.map +1 -0
- package/src/generated/orbpro/flow/trigger-kind.ts +17 -0
- package/src/generated/orbpro/flow.d.ts +21 -0
- package/src/generated/orbpro/flow.d.ts.map +1 -0
- package/src/generated/orbpro/flow.js +23 -0
- package/src/generated/orbpro/flow.js.map +1 -0
- package/src/generated/orbpro/flow.ts +24 -0
- package/src/generated/orbpro/manifest/capability-kind.d.ts +2 -1
- package/src/generated/orbpro/manifest/capability-kind.js +1 -0
- package/src/generated/orbpro/manifest/capability-kind.ts +1 -0
- package/src/generated/orbpro/plugin/stream-invoke-request.d.ts +93 -0
- package/src/generated/orbpro/plugin/stream-invoke-request.js +160 -0
- package/src/generated/orbpro/plugin/stream-invoke-request.ts +211 -0
- package/src/generated/orbpro/plugin/stream-invoke-response.d.ts +99 -0
- package/src/generated/orbpro/plugin/stream-invoke-response.js +175 -0
- package/src/generated/orbpro/plugin/stream-invoke-response.ts +226 -0
- package/src/generated/orbpro/plugin.js +8 -0
- package/src/generated/orbpro/stream.d.ts +12 -0
- package/src/generated/orbpro/stream.js +14 -0
- package/src/generated/orbpro/stream.ts +15 -0
- package/src/generated/spacedatastandards/plg/EntryFunction.d.ts +52 -0
- package/src/generated/spacedatastandards/plg/EntryFunction.d.ts.map +1 -0
- package/src/generated/spacedatastandards/plg/EntryFunction.js +106 -0
- package/src/generated/spacedatastandards/plg/EntryFunction.ts +162 -0
- package/src/generated/spacedatastandards/plg/FlatBufferTypeRef.d.ts +90 -0
- package/src/generated/spacedatastandards/plg/FlatBufferTypeRef.d.ts.map +1 -0
- package/src/generated/spacedatastandards/plg/FlatBufferTypeRef.js +189 -0
- package/src/generated/spacedatastandards/plg/FlatBufferTypeRef.ts +270 -0
- package/src/generated/spacedatastandards/plg/PLG.d.ts +492 -0
- package/src/generated/spacedatastandards/plg/PLG.d.ts.map +1 -0
- package/src/generated/spacedatastandards/plg/PLG.js +1139 -0
- package/src/generated/spacedatastandards/plg/PLG.ts +1600 -0
- package/src/generated/spacedatastandards/plg/PLGAcceptedTypeSet.d.ts +63 -0
- package/src/generated/spacedatastandards/plg/PLGAcceptedTypeSet.d.ts.map +1 -0
- package/src/generated/spacedatastandards/plg/PLGAcceptedTypeSet.js +138 -0
- package/src/generated/spacedatastandards/plg/PLGAcceptedTypeSet.ts +189 -0
- package/src/generated/spacedatastandards/plg/PLGBuildArtifact.d.ts +41 -0
- package/src/generated/spacedatastandards/plg/PLGBuildArtifact.d.ts.map +1 -0
- package/src/generated/spacedatastandards/plg/PLGBuildArtifact.js +104 -0
- package/src/generated/spacedatastandards/plg/PLGBuildArtifact.ts +151 -0
- package/src/generated/spacedatastandards/plg/PLGFlowEdge.d.ts +68 -0
- package/src/generated/spacedatastandards/plg/PLGFlowEdge.d.ts.map +1 -0
- package/src/generated/spacedatastandards/plg/PLGFlowEdge.js +124 -0
- package/src/generated/spacedatastandards/plg/PLGFlowEdge.ts +184 -0
- package/src/generated/spacedatastandards/plg/PLGFlowEdgeContract.d.ts +58 -0
- package/src/generated/spacedatastandards/plg/PLGFlowEdgeContract.d.ts.map +1 -0
- package/src/generated/spacedatastandards/plg/PLGFlowEdgeContract.js +126 -0
- package/src/generated/spacedatastandards/plg/PLGFlowEdgeContract.ts +161 -0
- package/src/generated/spacedatastandards/plg/PLGFlowNode.d.ts +82 -0
- package/src/generated/spacedatastandards/plg/PLGFlowNode.d.ts.map +1 -0
- package/src/generated/spacedatastandards/plg/PLGFlowNode.js +164 -0
- package/src/generated/spacedatastandards/plg/PLGFlowNode.ts +244 -0
- package/src/generated/spacedatastandards/plg/PLGFlowTrigger.d.ts +55 -0
- package/src/generated/spacedatastandards/plg/PLGFlowTrigger.d.ts.map +1 -0
- package/src/generated/spacedatastandards/plg/PLGFlowTrigger.js +105 -0
- package/src/generated/spacedatastandards/plg/PLGFlowTrigger.ts +162 -0
- package/src/generated/spacedatastandards/plg/PLGFlowTriggerBinding.d.ts +42 -0
- package/src/generated/spacedatastandards/plg/PLGFlowTriggerBinding.d.ts.map +1 -0
- package/src/generated/spacedatastandards/plg/PLGFlowTriggerBinding.js +83 -0
- package/src/generated/spacedatastandards/plg/PLGFlowTriggerBinding.ts +127 -0
- package/src/generated/spacedatastandards/plg/PLGHostCapability.d.ts +36 -0
- package/src/generated/spacedatastandards/plg/PLGHostCapability.d.ts.map +1 -0
- package/src/generated/spacedatastandards/plg/PLGHostCapability.js +90 -0
- package/src/generated/spacedatastandards/plg/PLGHostCapability.ts +127 -0
- package/src/generated/spacedatastandards/plg/PLGMethodManifest.d.ts +53 -0
- package/src/generated/spacedatastandards/plg/PLGMethodManifest.d.ts.map +1 -0
- package/src/generated/spacedatastandards/plg/PLGMethodManifest.js +153 -0
- package/src/generated/spacedatastandards/plg/PLGMethodManifest.ts +210 -0
- package/src/generated/spacedatastandards/plg/PLGPortManifest.d.ts +70 -0
- package/src/generated/spacedatastandards/plg/PLGPortManifest.d.ts.map +1 -0
- package/src/generated/spacedatastandards/plg/PLGPortManifest.js +149 -0
- package/src/generated/spacedatastandards/plg/PLGPortManifest.ts +212 -0
- package/src/generated/spacedatastandards/plg/PLGProtocolSpec.d.ts +73 -0
- package/src/generated/spacedatastandards/plg/PLGProtocolSpec.d.ts.map +1 -0
- package/src/generated/spacedatastandards/plg/PLGProtocolSpec.js +199 -0
- package/src/generated/spacedatastandards/plg/PLGProtocolSpec.ts +292 -0
- package/src/generated/spacedatastandards/plg/PLGTimerSpec.d.ts +40 -0
- package/src/generated/spacedatastandards/plg/PLGTimerSpec.d.ts.map +1 -0
- package/src/generated/spacedatastandards/plg/PLGTimerSpec.js +103 -0
- package/src/generated/spacedatastandards/plg/PLGTimerSpec.ts +148 -0
- package/src/generated/spacedatastandards/plg/PluginCapability.d.ts +41 -0
- package/src/generated/spacedatastandards/plg/PluginCapability.d.ts.map +1 -0
- package/src/generated/spacedatastandards/plg/PluginCapability.js +82 -0
- package/src/generated/spacedatastandards/plg/{plugin-capability.ts → PluginCapability.ts} +55 -18
- package/src/generated/spacedatastandards/plg/PluginDependency.d.ts +42 -0
- package/src/generated/spacedatastandards/plg/PluginDependency.d.ts.map +1 -0
- package/src/generated/spacedatastandards/plg/PluginDependency.js +80 -0
- package/src/generated/spacedatastandards/plg/PluginDependency.ts +124 -0
- package/src/generated/spacedatastandards/plg/TAB.d.ts +85 -0
- package/src/generated/spacedatastandards/plg/TAB.d.ts.map +1 -0
- package/src/generated/spacedatastandards/plg/TAB.js +173 -0
- package/src/generated/spacedatastandards/plg/TAB.ts +228 -0
- package/src/generated/spacedatastandards/plg/bufferMutability.d.ts +18 -0
- package/src/generated/spacedatastandards/plg/bufferMutability.d.ts.map +1 -0
- package/src/generated/spacedatastandards/plg/bufferMutability.js +20 -0
- package/src/generated/spacedatastandards/plg/bufferMutability.ts +23 -0
- package/src/generated/spacedatastandards/plg/bufferOwnership.d.ts +18 -0
- package/src/generated/spacedatastandards/plg/bufferOwnership.d.ts.map +1 -0
- package/src/generated/spacedatastandards/plg/bufferOwnership.js +20 -0
- package/src/generated/spacedatastandards/plg/bufferOwnership.ts +23 -0
- package/src/generated/spacedatastandards/plg/drainBehavior.d.ts +20 -0
- package/src/generated/spacedatastandards/plg/drainBehavior.d.ts.map +1 -0
- package/src/generated/spacedatastandards/plg/drainBehavior.js +22 -0
- package/src/generated/spacedatastandards/plg/drainBehavior.ts +25 -0
- package/src/generated/spacedatastandards/plg/flowEdgeRoutePolicy.d.ts +10 -0
- package/src/generated/spacedatastandards/plg/flowEdgeRoutePolicy.d.ts.map +1 -0
- package/src/generated/spacedatastandards/plg/flowEdgeRoutePolicy.js +12 -0
- package/src/generated/spacedatastandards/plg/flowEdgeRoutePolicy.ts +13 -0
- package/src/generated/spacedatastandards/plg/hostCapabilityKind.d.ts +51 -0
- package/src/generated/spacedatastandards/plg/hostCapabilityKind.d.ts.map +1 -0
- package/src/generated/spacedatastandards/plg/hostCapabilityKind.js +53 -0
- package/src/generated/spacedatastandards/plg/hostCapabilityKind.ts +55 -0
- package/src/generated/spacedatastandards/plg/invokeSurfaceKind.d.ts +15 -0
- package/src/generated/spacedatastandards/plg/invokeSurfaceKind.d.ts.map +1 -0
- package/src/generated/spacedatastandards/plg/invokeSurfaceKind.js +17 -0
- package/src/generated/spacedatastandards/plg/invokeSurfaceKind.ts +19 -0
- package/src/generated/spacedatastandards/plg/main.d.ts +29 -0
- package/src/generated/spacedatastandards/plg/main.d.ts.map +1 -0
- package/src/generated/spacedatastandards/plg/main.js +30 -0
- package/src/generated/spacedatastandards/plg/main.ts +32 -0
- package/src/generated/spacedatastandards/plg/payloadWireFormat.d.ts +17 -0
- package/src/generated/spacedatastandards/plg/payloadWireFormat.d.ts.map +1 -0
- package/src/generated/spacedatastandards/plg/payloadWireFormat.js +19 -0
- package/src/generated/spacedatastandards/plg/payloadWireFormat.ts +21 -0
- package/src/generated/spacedatastandards/plg/pluginCategory.d.ts +82 -0
- package/src/generated/spacedatastandards/plg/pluginCategory.d.ts.map +1 -0
- package/src/generated/spacedatastandards/plg/pluginCategory.js +84 -0
- package/src/generated/spacedatastandards/plg/pluginCategory.ts +103 -0
- package/src/generated/spacedatastandards/plg/publicationState.d.ts +18 -0
- package/src/generated/spacedatastandards/plg/publicationState.d.ts.map +1 -0
- package/src/generated/spacedatastandards/plg/publicationState.js +20 -0
- package/src/generated/spacedatastandards/plg/purchaseTier.d.ts +18 -0
- package/src/generated/spacedatastandards/plg/purchaseTier.d.ts.map +1 -0
- package/src/generated/spacedatastandards/plg/purchaseTier.js +20 -0
- package/src/host/AGENTS.md +2 -2
- package/src/host/abi.js +53 -66
- package/src/host/browserHost.js +355 -8
- package/src/host/cpp/keyslotClient.hpp +231 -0
- package/src/host/cpp/secretsClient.hpp +583 -0
- package/src/host/hostcallWire.js +183 -0
- package/src/host/index.js +2 -0
- package/src/host/isomorphicLoader.js +44 -7
- package/src/host/nodeHost.js +227 -8
- package/src/host/sabHostcallChannel.js +206 -0
- package/src/host/timerDriver.js +203 -0
- package/src/host/wasiShim.js +41 -1
- package/src/host/wasiThreadBrowserWorker.mjs +48 -0
- package/src/host/wasiThreadHost.js +393 -0
- package/src/host/wasiThreadWorker.mjs +32 -0
- package/src/host/wasiThreadWorkerRuntime.js +93 -0
- package/src/http/index.js +339 -0
- package/src/index.d.ts +716 -10
- package/src/index.js +4 -0
- package/src/invoke/codec.js +1202 -128
- package/src/invoke/index.js +5 -1
- package/src/licensing/index.d.ts +2 -0
- package/src/licensing/index.js +2 -0
- package/src/licensing/records.js +287 -8
- package/src/manifest/codec.js +62 -14
- package/src/manifest/index.js +2 -0
- package/src/manifest/legacyToPlg.js +164 -25
- package/src/manifest/normalize.js +1 -0
- package/src/manifest/plgCodec.js +1303 -62
- package/src/manifest/typeRefs.js +162 -24
- package/src/runtime/compiledRuntimeAbi.js +47 -0
- package/src/runtime/compiledRuntimeAbi.json +33 -0
- package/src/runtime/index.d.ts +32 -0
- package/src/runtime/index.js +1 -0
- package/src/runtime-host/index.js +3 -0
- package/src/runtime-host/methodRegistry.js +55 -0
- package/src/standards/index.js +200 -56
- package/src/standards/sharedCatalog.js +16 -0
- package/src/testing/browserModuleHarness.js +604 -31
- package/src/testing/docker/wasmedge-parity.Dockerfile +39 -0
- package/src/testing/index.d.ts +151 -0
- package/src/testing/index.js +21 -0
- package/src/testing/native/wasmedge_emscripten_pthread_runner.c +25 -1
- package/src/testing/parityBrowserRunner.js +138 -0
- package/src/testing/parityHarness.js +616 -0
- package/src/testing/parityLanes.js +537 -0
- package/src/testing/processInvoke.js +29 -21
- package/src/testing/streamInvokeCodec.js +10 -175
- package/src/testing/wasmedgePin.json +6 -0
- package/src/testing/workerModuleHarness.js +242 -0
- package/src/testing/workerModuleHarnessWorker.js +176 -0
- package/src/transport/index.js +3 -0
- package/src/transport/pki.js +299 -11
- package/src/transport/records.js +16 -7
- package/src/utils/ecdsaDer.js +106 -0
- package/src/utils/wasmCrypto.js +0 -43
- package/templates/gpu-module/README.md +48 -0
- package/templates/gpu-module/include/space_data_gpu_abi.h +122 -0
- package/templates/gpu-module/manifest.json +84 -0
- package/schemas/PluginInvokeRequest.fbs +0 -18
- package/schemas/PluginInvokeResponse.fbs +0 -30
- package/schemas/spacedatastandards/PLG.fbs +0 -191
- package/src/generated/orbpro/invoke/plugin-invoke-request.d.ts +0 -51
- package/src/generated/orbpro/invoke/plugin-invoke-request.d.ts.map +0 -1
- package/src/generated/orbpro/invoke/plugin-invoke-request.js +0 -131
- package/src/generated/orbpro/invoke/plugin-invoke-request.js.map +0 -1
- package/src/generated/orbpro/invoke/plugin-invoke-request.ts +0 -173
- package/src/generated/orbpro/invoke/plugin-invoke-response.d.ts +0 -76
- package/src/generated/orbpro/invoke/plugin-invoke-response.d.ts.map +0 -1
- package/src/generated/orbpro/invoke/plugin-invoke-response.js +0 -184
- package/src/generated/orbpro/invoke/plugin-invoke-response.js.map +0 -1
- package/src/generated/orbpro/invoke/plugin-invoke-response.ts +0 -243
- package/src/generated/orbpro/invoke.d.ts +0 -3
- package/src/generated/orbpro/invoke.js +0 -5
- package/src/generated/spacedatastandards/plg/entry-function.js +0 -86
- package/src/generated/spacedatastandards/plg/entry-function.ts +0 -119
- package/src/generated/spacedatastandards/plg/index.js +0 -16
- package/src/generated/spacedatastandards/plg/index.ts +0 -11
- package/src/generated/spacedatastandards/plg/plg.js +0 -657
- package/src/generated/spacedatastandards/plg/plg.ts +0 -924
- package/src/generated/spacedatastandards/plg/plugin-capability.js +0 -66
- package/src/generated/spacedatastandards/plg/plugin-category.js +0 -15
- package/src/generated/spacedatastandards/plg/plugin-category.ts +0 -53
- package/src/generated/spacedatastandards/plg/plugin-dependency.js +0 -63
- package/src/generated/spacedatastandards/plg/plugin-dependency.ts +0 -86
- package/src/generated/spacedatastandards/plg/publication-state.js +0 -9
- package/src/generated/spacedatastandards/plg/purchase-tier.js +0 -9
- /package/src/generated/spacedatastandards/plg/{publication-state.ts → publicationState.ts} +0 -0
- /package/src/generated/spacedatastandards/plg/{purchase-tier.ts → purchaseTier.ts} +0 -0
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SharedArrayBuffer hostcall channel — the async in-WASM host bridge.
|
|
3
|
+
*
|
|
4
|
+
* Guest WASM modules issue synchronous `space_data_module_host.call`
|
|
5
|
+
* invocations, but browser host capabilities (http/ipfs/storage/pubsub/...)
|
|
6
|
+
* are async. This channel lets a guest running inside a Worker block while
|
|
7
|
+
* the async host operation resolves on the controlling thread:
|
|
8
|
+
*
|
|
9
|
+
* worker (guest thread) controlling thread (host)
|
|
10
|
+
* ───────────────────── ─────────────────────────
|
|
11
|
+
* dispatch(op, params):
|
|
12
|
+
* state ← PENDING
|
|
13
|
+
* postRequest({operation, params}) ────▶ onmessage:
|
|
14
|
+
* Atomics.wait(state == PENDING) value = await dispatch(op, params)
|
|
15
|
+
* write value envelope into SAB
|
|
16
|
+
* state ← DONE; Atomics.notify
|
|
17
|
+
* read + decode value envelope ◀────────┘
|
|
18
|
+
* return value (or throw on error status)
|
|
19
|
+
*
|
|
20
|
+
* The worker-side dispatch is synchronous, so it plugs directly into
|
|
21
|
+
* `createHostcallBridge({ dispatch })` (src/host/abi.js) — the existing
|
|
22
|
+
* envelope/error machinery is reused unchanged. `Atomics.wait` is illegal on
|
|
23
|
+
* the main thread, so the guest MUST run in a Worker (see
|
|
24
|
+
* src/testing/workerModuleHarness.js).
|
|
25
|
+
*
|
|
26
|
+
* Payloads cross the channel as hostcall value envelopes (hostcallWire.js),
|
|
27
|
+
* so binary leaves (Uint8Array) survive without base64/JSON round-trips.
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
import {
|
|
31
|
+
decodeHostcallValueEnvelope,
|
|
32
|
+
encodeHostcallValueEnvelope,
|
|
33
|
+
} from "./hostcallWire.js";
|
|
34
|
+
|
|
35
|
+
// Int32 header slots at the front of the SharedArrayBuffer.
|
|
36
|
+
const SLOT_STATE = 0;
|
|
37
|
+
const SLOT_STATUS = 1;
|
|
38
|
+
const SLOT_LENGTH = 2;
|
|
39
|
+
const HEADER_INT32S = 4; // one reserved slot keeps the data region 16-byte aligned
|
|
40
|
+
|
|
41
|
+
const STATE_IDLE = 0;
|
|
42
|
+
const STATE_PENDING = 1;
|
|
43
|
+
const STATE_DONE = 2;
|
|
44
|
+
|
|
45
|
+
export const SAB_HOSTCALL_STATUS_OK = 0;
|
|
46
|
+
export const SAB_HOSTCALL_STATUS_ERROR = 1;
|
|
47
|
+
export const SAB_HOSTCALL_DATA_OFFSET = HEADER_INT32S * 4;
|
|
48
|
+
export const DEFAULT_SAB_HOSTCALL_RESPONSE_BYTES = 4 * 1024 * 1024;
|
|
49
|
+
|
|
50
|
+
function assertSharedArrayBuffer(buffer) {
|
|
51
|
+
if (
|
|
52
|
+
typeof SharedArrayBuffer !== "function" ||
|
|
53
|
+
!(buffer instanceof SharedArrayBuffer)
|
|
54
|
+
) {
|
|
55
|
+
throw new TypeError(
|
|
56
|
+
"SAB hostcall channel requires a SharedArrayBuffer (cross-origin isolation in browsers).",
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function serializeChannelError(error, operation) {
|
|
62
|
+
return {
|
|
63
|
+
name: error?.name ?? "Error",
|
|
64
|
+
message: error?.message ?? String(error),
|
|
65
|
+
code: error?.code ?? null,
|
|
66
|
+
operation: error?.operation ?? operation ?? null,
|
|
67
|
+
capability: error?.capability ?? null,
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Allocate the shared buffer backing one hostcall channel.
|
|
73
|
+
*/
|
|
74
|
+
export function createSabHostcallBuffer(options = {}) {
|
|
75
|
+
if (typeof SharedArrayBuffer !== "function") {
|
|
76
|
+
throw new Error(
|
|
77
|
+
"SharedArrayBuffer is unavailable; the async hostcall bridge requires it " +
|
|
78
|
+
"(browsers additionally require cross-origin isolation: COOP+COEP).",
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
const maxResponseBytes = Number.isInteger(options.maxResponseBytes)
|
|
82
|
+
? options.maxResponseBytes
|
|
83
|
+
: DEFAULT_SAB_HOSTCALL_RESPONSE_BYTES;
|
|
84
|
+
if (maxResponseBytes <= 0) {
|
|
85
|
+
throw new RangeError("maxResponseBytes must be a positive integer.");
|
|
86
|
+
}
|
|
87
|
+
return new SharedArrayBuffer(SAB_HOSTCALL_DATA_OFFSET + maxResponseBytes);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Worker-side half: a synchronous dispatch(operation, params) that blocks on
|
|
92
|
+
* Atomics.wait until the controlling thread services the request.
|
|
93
|
+
*
|
|
94
|
+
* options.postRequest({ operation, params }) must deliver the request to the
|
|
95
|
+
* controlling thread (postMessage). params/results are structured values with
|
|
96
|
+
* Uint8Array leaves.
|
|
97
|
+
*/
|
|
98
|
+
export function createSabHostcallClientDispatch(options = {}) {
|
|
99
|
+
assertSharedArrayBuffer(options.buffer);
|
|
100
|
+
const postRequest = options.postRequest;
|
|
101
|
+
if (typeof postRequest !== "function") {
|
|
102
|
+
throw new TypeError(
|
|
103
|
+
"createSabHostcallClientDispatch requires a postRequest function.",
|
|
104
|
+
);
|
|
105
|
+
}
|
|
106
|
+
const timeoutMs =
|
|
107
|
+
Number.isFinite(options.timeoutMs) && options.timeoutMs > 0
|
|
108
|
+
? options.timeoutMs
|
|
109
|
+
: 120_000;
|
|
110
|
+
const header = new Int32Array(options.buffer, 0, HEADER_INT32S);
|
|
111
|
+
const capacity = options.buffer.byteLength - SAB_HOSTCALL_DATA_OFFSET;
|
|
112
|
+
|
|
113
|
+
return function sabHostcallDispatch(operation, params = null) {
|
|
114
|
+
Atomics.store(header, SLOT_STATE, STATE_PENDING);
|
|
115
|
+
postRequest({ operation, params });
|
|
116
|
+
const outcome = Atomics.wait(header, SLOT_STATE, STATE_PENDING, timeoutMs);
|
|
117
|
+
if (outcome === "timed-out") {
|
|
118
|
+
Atomics.store(header, SLOT_STATE, STATE_IDLE);
|
|
119
|
+
throw new Error(
|
|
120
|
+
`Hostcall "${operation}" timed out after ${timeoutMs}ms waiting for the controlling thread.`,
|
|
121
|
+
);
|
|
122
|
+
}
|
|
123
|
+
const status = Atomics.load(header, SLOT_STATUS);
|
|
124
|
+
const length = Atomics.load(header, SLOT_LENGTH);
|
|
125
|
+
if (length < 0 || length > capacity) {
|
|
126
|
+
Atomics.store(header, SLOT_STATE, STATE_IDLE);
|
|
127
|
+
throw new RangeError(
|
|
128
|
+
`Hostcall "${operation}" response length ${length} exceeds channel capacity ${capacity}.`,
|
|
129
|
+
);
|
|
130
|
+
}
|
|
131
|
+
// Copy out of the SAB before decoding — decode keeps subarray views.
|
|
132
|
+
const bytes = new Uint8Array(length);
|
|
133
|
+
bytes.set(new Uint8Array(options.buffer, SAB_HOSTCALL_DATA_OFFSET, length));
|
|
134
|
+
Atomics.store(header, SLOT_STATE, STATE_IDLE);
|
|
135
|
+
const value = decodeHostcallValueEnvelope(bytes);
|
|
136
|
+
if (status !== SAB_HOSTCALL_STATUS_OK) {
|
|
137
|
+
const error = new Error(
|
|
138
|
+
value?.message ?? `Hostcall "${operation}" failed on the host thread.`,
|
|
139
|
+
);
|
|
140
|
+
error.name = value?.name ?? "Error";
|
|
141
|
+
error.code = value?.code ?? null;
|
|
142
|
+
error.operation = value?.operation ?? operation;
|
|
143
|
+
error.capability = value?.capability ?? null;
|
|
144
|
+
throw error;
|
|
145
|
+
}
|
|
146
|
+
return value;
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Controlling-thread half: services one request at a time against an async
|
|
152
|
+
* dispatch (e.g. createAsyncHostDispatcher(host)) and wakes the worker.
|
|
153
|
+
*/
|
|
154
|
+
export function createSabHostcallServer(options = {}) {
|
|
155
|
+
assertSharedArrayBuffer(options.buffer);
|
|
156
|
+
const dispatch = options.dispatch;
|
|
157
|
+
if (typeof dispatch !== "function") {
|
|
158
|
+
throw new TypeError("createSabHostcallServer requires a dispatch function.");
|
|
159
|
+
}
|
|
160
|
+
const header = new Int32Array(options.buffer, 0, HEADER_INT32S);
|
|
161
|
+
const capacity = options.buffer.byteLength - SAB_HOSTCALL_DATA_OFFSET;
|
|
162
|
+
const data = new Uint8Array(options.buffer, SAB_HOSTCALL_DATA_OFFSET, capacity);
|
|
163
|
+
|
|
164
|
+
function complete(status, bytes) {
|
|
165
|
+
data.set(bytes, 0);
|
|
166
|
+
Atomics.store(header, SLOT_STATUS, status);
|
|
167
|
+
Atomics.store(header, SLOT_LENGTH, bytes.length);
|
|
168
|
+
Atomics.store(header, SLOT_STATE, STATE_DONE);
|
|
169
|
+
Atomics.notify(header, SLOT_STATE);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
async function handleRequest(request = {}) {
|
|
173
|
+
const operation = request.operation;
|
|
174
|
+
let status = SAB_HOSTCALL_STATUS_OK;
|
|
175
|
+
let value;
|
|
176
|
+
try {
|
|
177
|
+
value = await dispatch(operation, request.params ?? null);
|
|
178
|
+
if (value === undefined) value = null;
|
|
179
|
+
} catch (error) {
|
|
180
|
+
status = SAB_HOSTCALL_STATUS_ERROR;
|
|
181
|
+
value = serializeChannelError(error, operation);
|
|
182
|
+
}
|
|
183
|
+
let bytes;
|
|
184
|
+
try {
|
|
185
|
+
bytes = encodeHostcallValueEnvelope(value);
|
|
186
|
+
} catch (error) {
|
|
187
|
+
status = SAB_HOSTCALL_STATUS_ERROR;
|
|
188
|
+
bytes = encodeHostcallValueEnvelope(serializeChannelError(error, operation));
|
|
189
|
+
}
|
|
190
|
+
if (bytes.length > capacity) {
|
|
191
|
+
status = SAB_HOSTCALL_STATUS_ERROR;
|
|
192
|
+
bytes = encodeHostcallValueEnvelope(
|
|
193
|
+
serializeChannelError(
|
|
194
|
+
new RangeError(
|
|
195
|
+
`Hostcall response (${bytes.length} bytes) exceeds the channel capacity (${capacity} bytes); ` +
|
|
196
|
+
"raise maxHostcallResponseBytes on the worker harness.",
|
|
197
|
+
),
|
|
198
|
+
operation,
|
|
199
|
+
),
|
|
200
|
+
);
|
|
201
|
+
}
|
|
202
|
+
complete(status, bytes);
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
return { handleRequest };
|
|
206
|
+
}
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Browser cron/timer driver (WS6.3).
|
|
3
|
+
*
|
|
4
|
+
* The node runtime re-invokes a module's manifest TIMERS through
|
|
5
|
+
* plugin_invoke_stream on a schedule (Go plugins.Manager.scheduleCronMethods).
|
|
6
|
+
* This is the browser-side counterpart: it reads the module's TIMERS
|
|
7
|
+
* (decoded PLG manifest), schedules an interval per enabled timer, and
|
|
8
|
+
* invokes the timer's method through the harness invoke surface
|
|
9
|
+
* (createBrowserModuleHarness / createWorkerModuleHarness `invoke`, i.e.
|
|
10
|
+
* plugin_invoke_stream).
|
|
11
|
+
*
|
|
12
|
+
* const driver = createModuleTimerDriver({
|
|
13
|
+
* harness, // or invoke: (request) => Promise
|
|
14
|
+
* manifestBytes, // or timers: [...] / manifest: {...}
|
|
15
|
+
* schedules: { "starlink-pull": { intervalMs: 1000 } },
|
|
16
|
+
* });
|
|
17
|
+
* driver.start();
|
|
18
|
+
* ...
|
|
19
|
+
* driver.stop();
|
|
20
|
+
*
|
|
21
|
+
* Semantics mirror the Go manager: one schedule per timer, runs are recorded
|
|
22
|
+
* ({trigger:"scheduled"|"manual", status:"ok"|"error"}), and runs of the same
|
|
23
|
+
* timer are serialized — a tick that lands while the previous invocation is
|
|
24
|
+
* still in flight is skipped (recorded as "skipped"). Unlike the Go manager,
|
|
25
|
+
* explicit schedule overrides are trusted (clamped only by minIntervalMs,
|
|
26
|
+
* default 1s) so tests and UIs can shorten long default cadences.
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
// Import the codec leaf, not manifest/index.js — the index pulls
|
|
30
|
+
// embeddedManifest.js (node:fs) and would break browser bundles.
|
|
31
|
+
import { decodePluginManifest } from "../manifest/codec.js";
|
|
32
|
+
|
|
33
|
+
const DEFAULT_MIN_INTERVAL_MS = 1_000;
|
|
34
|
+
const DEFAULT_MAX_RUN_HISTORY = 50;
|
|
35
|
+
|
|
36
|
+
function toIntervalMs(value) {
|
|
37
|
+
if (typeof value === "bigint") return Number(value);
|
|
38
|
+
const n = Number(value ?? 0);
|
|
39
|
+
return Number.isFinite(n) ? n : 0;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function normalizeTimer(timer) {
|
|
43
|
+
const timerId = String(timer?.timerId ?? timer?.timer_id ?? "").trim();
|
|
44
|
+
const methodId = String(timer?.methodId ?? timer?.method_id ?? "").trim();
|
|
45
|
+
if (!timerId || !methodId) return null;
|
|
46
|
+
return {
|
|
47
|
+
timerId,
|
|
48
|
+
methodId,
|
|
49
|
+
defaultIntervalMs: toIntervalMs(
|
|
50
|
+
timer.defaultIntervalMs ?? timer.default_interval_ms ?? 0,
|
|
51
|
+
),
|
|
52
|
+
description: timer.description ?? "",
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function resolveTimers(options) {
|
|
57
|
+
if (Array.isArray(options.timers)) {
|
|
58
|
+
return options.timers.map(normalizeTimer).filter(Boolean);
|
|
59
|
+
}
|
|
60
|
+
const manifest =
|
|
61
|
+
options.manifest ??
|
|
62
|
+
(options.manifestBytes ? decodePluginManifest(options.manifestBytes) : null);
|
|
63
|
+
const timers = Array.isArray(manifest?.timers) ? manifest.timers : [];
|
|
64
|
+
return timers.map(normalizeTimer).filter(Boolean);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export function createModuleTimerDriver(options = {}) {
|
|
68
|
+
const invoke =
|
|
69
|
+
typeof options.invoke === "function"
|
|
70
|
+
? options.invoke
|
|
71
|
+
: typeof options.harness?.invoke === "function"
|
|
72
|
+
? (request) => options.harness.invoke(request)
|
|
73
|
+
: null;
|
|
74
|
+
if (!invoke) {
|
|
75
|
+
throw new TypeError(
|
|
76
|
+
"createModuleTimerDriver requires an invoke function or a harness with invoke().",
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
const timers = resolveTimers(options);
|
|
80
|
+
const schedules =
|
|
81
|
+
options.schedules && typeof options.schedules === "object"
|
|
82
|
+
? options.schedules
|
|
83
|
+
: {};
|
|
84
|
+
const minIntervalMs = Number.isFinite(options.minIntervalMs)
|
|
85
|
+
? Math.max(1, options.minIntervalMs)
|
|
86
|
+
: DEFAULT_MIN_INTERVAL_MS;
|
|
87
|
+
const maxRunHistory = Number.isInteger(options.maxRunHistory)
|
|
88
|
+
? options.maxRunHistory
|
|
89
|
+
: DEFAULT_MAX_RUN_HISTORY;
|
|
90
|
+
const setIntervalImpl = options.setIntervalImpl ?? globalThis.setInterval.bind(globalThis);
|
|
91
|
+
const clearIntervalImpl =
|
|
92
|
+
options.clearIntervalImpl ?? globalThis.clearInterval.bind(globalThis);
|
|
93
|
+
const now = typeof options.now === "function" ? options.now : () => Date.now();
|
|
94
|
+
const onRun = typeof options.onRun === "function" ? options.onRun : null;
|
|
95
|
+
|
|
96
|
+
const state = new Map(); // timerId -> { timer, intervalMs, enabled, handle, inFlight, runs }
|
|
97
|
+
for (const timer of timers) {
|
|
98
|
+
const override = schedules[timer.timerId] ?? {};
|
|
99
|
+
const enabled = override.enabled !== false;
|
|
100
|
+
const requested = toIntervalMs(override.intervalMs ?? timer.defaultIntervalMs);
|
|
101
|
+
const intervalMs = Math.max(minIntervalMs, requested);
|
|
102
|
+
state.set(timer.timerId, {
|
|
103
|
+
timer,
|
|
104
|
+
intervalMs,
|
|
105
|
+
enabled,
|
|
106
|
+
handle: null,
|
|
107
|
+
inFlight: false,
|
|
108
|
+
runs: [],
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
function record(entry, run) {
|
|
113
|
+
entry.runs.push(run);
|
|
114
|
+
if (entry.runs.length > maxRunHistory) {
|
|
115
|
+
entry.runs.splice(0, entry.runs.length - maxRunHistory);
|
|
116
|
+
}
|
|
117
|
+
if (onRun) onRun(run);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
async function fire(entry, trigger) {
|
|
121
|
+
if (entry.inFlight) {
|
|
122
|
+
record(entry, {
|
|
123
|
+
timerId: entry.timer.timerId,
|
|
124
|
+
methodId: entry.timer.methodId,
|
|
125
|
+
trigger,
|
|
126
|
+
status: "skipped",
|
|
127
|
+
startedAt: now(),
|
|
128
|
+
finishedAt: now(),
|
|
129
|
+
message: "previous run still in flight",
|
|
130
|
+
});
|
|
131
|
+
return null;
|
|
132
|
+
}
|
|
133
|
+
entry.inFlight = true;
|
|
134
|
+
const run = {
|
|
135
|
+
timerId: entry.timer.timerId,
|
|
136
|
+
methodId: entry.timer.methodId,
|
|
137
|
+
trigger,
|
|
138
|
+
status: "running",
|
|
139
|
+
startedAt: now(),
|
|
140
|
+
};
|
|
141
|
+
try {
|
|
142
|
+
const response = await invoke({ methodId: entry.timer.methodId, inputs: [] });
|
|
143
|
+
run.status = "ok";
|
|
144
|
+
run.finishedAt = now();
|
|
145
|
+
return response;
|
|
146
|
+
} catch (error) {
|
|
147
|
+
run.status = "error";
|
|
148
|
+
run.message = error?.message ?? String(error);
|
|
149
|
+
run.finishedAt = now();
|
|
150
|
+
return null;
|
|
151
|
+
} finally {
|
|
152
|
+
entry.inFlight = false;
|
|
153
|
+
record(entry, run);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
let started = false;
|
|
158
|
+
|
|
159
|
+
return {
|
|
160
|
+
listTimers() {
|
|
161
|
+
return [...state.values()].map((entry) => ({
|
|
162
|
+
timerId: entry.timer.timerId,
|
|
163
|
+
methodId: entry.timer.methodId,
|
|
164
|
+
description: entry.timer.description,
|
|
165
|
+
defaultIntervalMs: entry.timer.defaultIntervalMs,
|
|
166
|
+
intervalMs: entry.intervalMs,
|
|
167
|
+
enabled: entry.enabled,
|
|
168
|
+
scheduled: entry.handle !== null,
|
|
169
|
+
}));
|
|
170
|
+
},
|
|
171
|
+
runHistory(timerId) {
|
|
172
|
+
const entry = state.get(String(timerId ?? "").trim());
|
|
173
|
+
return entry ? entry.runs.map((run) => ({ ...run })) : [];
|
|
174
|
+
},
|
|
175
|
+
start() {
|
|
176
|
+
if (started) return this.listTimers();
|
|
177
|
+
started = true;
|
|
178
|
+
for (const entry of state.values()) {
|
|
179
|
+
if (!entry.enabled) continue;
|
|
180
|
+
entry.handle = setIntervalImpl(() => {
|
|
181
|
+
void fire(entry, "scheduled");
|
|
182
|
+
}, entry.intervalMs);
|
|
183
|
+
}
|
|
184
|
+
return this.listTimers();
|
|
185
|
+
},
|
|
186
|
+
async runNow(timerId) {
|
|
187
|
+
const entry = state.get(String(timerId ?? "").trim());
|
|
188
|
+
if (!entry) {
|
|
189
|
+
throw new Error(`Unknown timer: ${timerId}`);
|
|
190
|
+
}
|
|
191
|
+
return fire(entry, "manual");
|
|
192
|
+
},
|
|
193
|
+
stop() {
|
|
194
|
+
for (const entry of state.values()) {
|
|
195
|
+
if (entry.handle !== null) {
|
|
196
|
+
clearIntervalImpl(entry.handle);
|
|
197
|
+
entry.handle = null;
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
started = false;
|
|
201
|
+
},
|
|
202
|
+
};
|
|
203
|
+
}
|
package/src/host/wasiShim.js
CHANGED
|
@@ -5,10 +5,14 @@
|
|
|
5
5
|
* WASI modules (the same .wasm that runs in WasmEdge) can be instantiated
|
|
6
6
|
* directly in the browser via WebAssembly.instantiate().
|
|
7
7
|
*
|
|
8
|
-
* Covers the
|
|
8
|
+
* Covers the preview1 imports observed across SDN plugin standalone builds:
|
|
9
9
|
* clock_time_get, fd_write, fd_read, fd_close, fd_seek, fd_fdstat_get,
|
|
10
|
+
* fd_fdstat_set_flags, fd_prestat_get, fd_prestat_dir_name, path_open,
|
|
10
11
|
* environ_sizes_get, environ_get, proc_exit, args_get, args_sizes_get,
|
|
11
12
|
* random_get
|
|
13
|
+
*
|
|
14
|
+
* No filesystem is exposed: prestat/path_open report no preopened
|
|
15
|
+
* directories, so wasi-libc file APIs fail cleanly inside the guest.
|
|
12
16
|
*/
|
|
13
17
|
|
|
14
18
|
const ERRNO_SUCCESS = 0;
|
|
@@ -156,6 +160,28 @@ export function createBrowserWasiShim(options = {}) {
|
|
|
156
160
|
return ERRNO_SUCCESS;
|
|
157
161
|
}
|
|
158
162
|
|
|
163
|
+
function fd_fdstat_set_flags(fd, _flags) {
|
|
164
|
+
if (fd <= 2) return ERRNO_SUCCESS;
|
|
165
|
+
return ERRNO_BADF;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
// This browser shim exposes no ambient preopened directories. Toolchains
|
|
169
|
+
// commonly probe these preview1 calls during startup; returning BADF is
|
|
170
|
+
// the fail-closed WASI result and lets the guest continue without filesystem
|
|
171
|
+
// authority.
|
|
172
|
+
function fd_prestat_get(_fd, _bufPtr) {
|
|
173
|
+
return ERRNO_BADF;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
function fd_prestat_dir_name(_fd, _pathPtr, _pathLen) {
|
|
177
|
+
return ERRNO_BADF;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
function path_open() {
|
|
181
|
+
return ERRNO_BADF;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
|
|
159
185
|
function environ_sizes_get(countPtr, bufSizePtr) {
|
|
160
186
|
const dv = view();
|
|
161
187
|
dv.setUint32(countPtr, encodedEnvEntries.length, true);
|
|
@@ -223,6 +249,15 @@ export function createBrowserWasiShim(options = {}) {
|
|
|
223
249
|
throw new WasiExitError(code);
|
|
224
250
|
}
|
|
225
251
|
|
|
252
|
+
// wasm32-wasip1-threads (isomorphic-pthreads) modules import sched_yield —
|
|
253
|
+
// pthread spin/backoff loops call it. A cooperative no-op (yield to the
|
|
254
|
+
// engine) is the correct browser/Node semantics: real preemption is the
|
|
255
|
+
// host's job. Present on every shim so a threaded artifact instantiates
|
|
256
|
+
// (a missing import would fail instantiation for the whole module).
|
|
257
|
+
function sched_yield() {
|
|
258
|
+
return ERRNO_SUCCESS;
|
|
259
|
+
}
|
|
260
|
+
|
|
226
261
|
// --- Output helpers ---
|
|
227
262
|
|
|
228
263
|
function flushOutput() {
|
|
@@ -265,12 +300,17 @@ export function createBrowserWasiShim(options = {}) {
|
|
|
265
300
|
fd_close,
|
|
266
301
|
fd_seek,
|
|
267
302
|
fd_fdstat_get,
|
|
303
|
+
fd_fdstat_set_flags,
|
|
304
|
+
fd_prestat_get,
|
|
305
|
+
fd_prestat_dir_name,
|
|
306
|
+
path_open,
|
|
268
307
|
environ_sizes_get,
|
|
269
308
|
environ_get,
|
|
270
309
|
args_sizes_get,
|
|
271
310
|
args_get,
|
|
272
311
|
random_get,
|
|
273
312
|
proc_exit,
|
|
313
|
+
sched_yield,
|
|
274
314
|
},
|
|
275
315
|
},
|
|
276
316
|
setMemory,
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { createWasiThreadWorkerRuntime } from "./wasiThreadWorkerRuntime.js";
|
|
2
|
+
|
|
3
|
+
let wasmModule = null;
|
|
4
|
+
let memory = null;
|
|
5
|
+
let hostcallChannel = null;
|
|
6
|
+
let runtime = null;
|
|
7
|
+
|
|
8
|
+
self.onmessage = (event) => {
|
|
9
|
+
const message = event.data ?? {};
|
|
10
|
+
if (message.t === "probe") {
|
|
11
|
+
wasmModule = message.wasmModule;
|
|
12
|
+
memory = message.memory;
|
|
13
|
+
hostcallChannel = message.hostcallChannel ?? null;
|
|
14
|
+
try {
|
|
15
|
+
runtime = createWasiThreadWorkerRuntime({
|
|
16
|
+
wasmModule,
|
|
17
|
+
memory,
|
|
18
|
+
hostcallChannel,
|
|
19
|
+
});
|
|
20
|
+
runtime.instantiate();
|
|
21
|
+
self.postMessage({ t: "ready", ok: true });
|
|
22
|
+
} catch (error) {
|
|
23
|
+
runtime?.close();
|
|
24
|
+
runtime = null;
|
|
25
|
+
self.postMessage({
|
|
26
|
+
t: "ready",
|
|
27
|
+
ok: false,
|
|
28
|
+
error: String(error?.message ?? error),
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
if (message.t !== "run") return;
|
|
34
|
+
|
|
35
|
+
try {
|
|
36
|
+
const instance = runtime.instantiate();
|
|
37
|
+
instance.exports.wasi_thread_start(message.tid, message.startArg);
|
|
38
|
+
} catch (error) {
|
|
39
|
+
if (!(error && error.name === "WasiExitError")) {
|
|
40
|
+
self.postMessage({
|
|
41
|
+
t: "error",
|
|
42
|
+
tid: message.tid,
|
|
43
|
+
error: String(error?.message ?? error),
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
self.postMessage({ t: "exit", tid: message.tid });
|
|
48
|
+
};
|