@ultrst-armada/kloks 1.26.3 → 1.26.4
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 +39 -0
- package/index.d.ts +16 -10
- package/index.js +3 -0
- package/package.json +60 -7
- package/packages/audio-midi/dist/{audioClipEngine-BOT33JKI.js → audioClipEngine-LKZRWTJ3.js} +2 -2
- package/packages/audio-midi/dist/{audioInputManager-BLDGGLAR.js → audioInputManager-5BNHLOJM.js} +1 -1
- package/packages/audio-midi/dist/{chunk-N55BWOC6.js → chunk-M4JFGTHE.js} +1 -1
- package/packages/audio-midi/dist/{chunk-3GRGELA4.js → chunk-OUOFTYHY.js} +50 -11
- package/packages/audio-midi/dist/engine/audio/entities/AudioEffects/functionalities/Compressor/manifest.json +7 -0
- package/packages/audio-midi/dist/engine/audio/entities/AudioEffects/functionalities/Delay/manifest.json +7 -0
- package/packages/audio-midi/dist/engine/audio/entities/AudioEffects/functionalities/Equalizer/manifest.json +7 -0
- package/packages/audio-midi/dist/engine/audio/entities/AudioEffects/functionalities/Limiter/manifest.json +7 -0
- package/packages/audio-midi/dist/engine/audio/entities/AudioEffects/functionalities/MultibandCompressor/manifest.json +7 -0
- package/packages/audio-midi/dist/engine/audio/entities/AudioEffects/functionalities/Reverb/manifest.json +7 -0
- package/packages/audio-midi/dist/engine/audio/entities/AudioEffects/functionalities/Saturation/manifest.json +7 -0
- package/packages/audio-midi/dist/index.d.ts +10 -1
- package/packages/audio-midi/dist/index.js +36 -20
- package/packages/audio-midi/package.json +8 -0
- package/packages/backend/dist/ai-models/index.js +2 -2
- package/packages/backend/dist/ai-routing/index.js +3 -3
- package/packages/backend/dist/api/BaseApiRoute.d.ts +1 -1
- package/packages/backend/dist/api/index.js +1 -1
- package/packages/backend/dist/auth/CanonicalAuthClient.d.ts +6 -6
- package/packages/backend/dist/auth/index.js +2 -1
- package/packages/backend/dist/chunk-2Y2EXYDK.js +0 -0
- package/packages/backend/dist/{chunk-3S2NSIFA.js → chunk-3FZSYSJC.js} +16 -10
- package/packages/backend/dist/chunk-5F5V7NAG.js +54 -0
- package/packages/backend/dist/{chunk-WAQDOIGQ.js → chunk-BVXGUHLZ.js} +1 -1
- package/packages/backend/dist/chunk-DAG2L4RN.js +0 -0
- package/packages/backend/dist/{chunk-KPZQUA7R.js → chunk-G7PPVOFP.js} +16 -53
- package/packages/backend/dist/{chunk-GKQ42CYW.js → chunk-H6ET362U.js} +3 -3
- package/packages/backend/dist/chunk-HUY4272L.js +69 -0
- package/packages/backend/dist/chunk-JQKKMUCT.js +0 -0
- package/packages/backend/dist/{chunk-PT6J6UEU.js → chunk-LMAU62ZG.js} +4 -4
- package/packages/backend/dist/{chunk-EDKCP5CQ.js → chunk-MZK362U4.js} +16 -16
- package/packages/backend/dist/{chunk-U4UI6KK4.js → chunk-NGEB3CF5.js} +3 -35
- package/packages/backend/dist/{chunk-3VWBZEMG.js → chunk-NTKUQVCQ.js} +4 -5
- package/packages/backend/dist/chunk-NY2SQOXI.js +34 -0
- package/packages/backend/dist/{chunk-JOTDEFRG.js → chunk-OXEP3AP6.js} +5 -4
- package/packages/backend/dist/chunk-RABSY2JU.js +0 -0
- package/packages/backend/dist/{chunk-GWCLYVJT.js → chunk-RFPGUJAZ.js} +9 -9
- package/packages/backend/dist/{chunk-TWCEVES2.js → chunk-WC6EPW3A.js} +1 -1
- package/packages/backend/dist/{chunk-FU6TYLI2.js → chunk-Y5ENDXU2.js} +72 -129
- package/packages/backend/dist/{chunk-EO5VUYYU.js → chunk-Y7ZE6D5H.js} +4 -4
- package/packages/backend/dist/{chunk-RCCQ7IRM.js → chunk-ZBNSK26X.js} +2 -2
- package/packages/backend/dist/control-plane/AuditLogger.d.ts +1 -1
- package/packages/backend/dist/control-plane/ControlPlaneManager.d.ts +1 -1
- package/packages/backend/dist/control-plane/index.js +1 -1
- package/packages/backend/dist/core/dynamicRouteResolver.d.ts +1 -1
- package/packages/backend/dist/core/routesCore.d.ts +1 -1
- package/packages/backend/dist/core/vercelTransformer.d.ts +1 -1
- package/packages/backend/dist/core/workspaceCore.d.ts +2 -2
- package/packages/backend/dist/data/BaseDataProvider.d.ts +1 -1
- package/packages/backend/dist/development/index.js +30 -17
- package/packages/backend/dist/development/playwrightInspectionService.js +1 -2
- package/packages/backend/dist/development/webContainerService.js +1 -2
- package/packages/backend/dist/index.d.ts +4 -24
- package/packages/backend/dist/index.js +12 -4655
- package/packages/backend/dist/krnl-ai-services.d.ts +9 -9
- package/packages/backend/dist/krnl-ai-services.js +5 -6
- package/packages/backend/dist/krnl-services.js +8 -7
- package/packages/backend/dist/node.d.ts +28 -0
- package/packages/backend/dist/node.js +4754 -0
- package/packages/backend/dist/resourceEngine/BaseResourceFetcher.d.ts +3 -3
- package/packages/backend/dist/resourceEngine/CloudflareResourceFetcher.d.ts +3 -3
- package/packages/backend/dist/resourceEngine/ResourceFetcherRegistry.d.ts +5 -5
- package/packages/backend/dist/resourceEngine/VercelResourceFetcher.d.ts +3 -3
- package/packages/backend/dist/resourceEngine/adapters/CloudflareResourceAdapter.d.ts +2 -2
- package/packages/backend/dist/resourceEngine/adapters/VercelResourceAdapter.d.ts +2 -2
- package/packages/backend/dist/resourceEngine/calculator/UniversalResourceCalculator.d.ts +1 -1
- package/packages/backend/dist/resourceEngine/calculator/types.d.ts +1 -1
- package/packages/backend/dist/resourceEngine/index.d.ts +6 -6
- package/packages/backend/dist/resourceEngine/types/depm/entities.d.ts +2 -2
- package/packages/backend/dist/resourceEngine/types.d.ts +1 -1
- package/packages/backend/dist/resourceEngine/weightEngine/helpers.d.ts +1 -1
- package/packages/backend/dist/resourceEngine/weightEngine/index.d.ts +2 -2
- package/packages/backend/dist/resourceEngine/weightEngine/weightEngine.d.ts +1 -1
- package/packages/backend/dist/resourceEngine/weightEngine.d.ts +1 -1
- package/packages/backend/dist/server/services/assetPoolService/assetPoolService.d.ts +3 -3
- package/packages/backend/dist/server/services/projectService/projectService.d.ts +3 -3
- package/packages/backend/dist/services/index.d.ts +2 -10
- package/packages/backend/dist/services/index.js +1 -37
- package/packages/backend/dist/services/node.d.ts +10 -0
- package/packages/backend/dist/services/node.js +38 -0
- package/packages/backend/dist/srkl/index.js +1 -1
- package/packages/backend/dist/storage/BaseStorageAdapter.d.ts +1 -1
- package/packages/backend/dist/storage/S3Adapter.d.ts +5 -0
- package/packages/backend/dist/storage/googleDriveSdk.d.ts +1 -7
- package/packages/backend/dist/storage/index.d.ts +1 -10
- package/packages/backend/dist/storage/index.js +5 -40
- package/packages/backend/dist/storage/node.d.ts +14 -0
- package/packages/backend/dist/storage/node.js +66 -0
- package/packages/backend/dist/workspace/WorkspaceCloneSyncEngine.d.ts +1 -1
- package/packages/backend/dist/workspace/index.d.ts +1 -5
- package/packages/backend/dist/workspace/index.js +4 -24
- package/packages/backend/dist/workspace/node.d.ts +8 -0
- package/packages/backend/dist/workspace/node.js +30 -0
- package/packages/backend/package.json +35 -3
- package/packages/functions/dist/base-DDYO-DzM.d.ts +64 -0
- package/packages/functions/dist/base.d.ts +1 -0
- package/packages/functions/dist/base.js +6 -0
- package/packages/functions/dist/chunk-6EHIZHO4.js +555 -0
- package/packages/functions/dist/chunk-Z4LM5TOJ.js +114 -0
- package/packages/functions/dist/index.d.ts +4 -373
- package/packages/functions/dist/index.js +53 -1693
- package/packages/functions/dist/node.d.ts +110 -0
- package/packages/functions/dist/node.js +442 -0
- package/packages/functions/dist/portable.d.ts +207 -0
- package/packages/functions/dist/portable.js +94 -0
- package/packages/functions/package.json +23 -1
- package/packages/{functions/dist/chunk-K6H7T3EP.js → services/dist/chunk-P54QSKOQ.js} +1 -3
- package/packages/{state-graph/dist/dist-es-TLPJYZTE.js → services/dist/dist-es-2P6LFFZL.js} +1 -1
- package/packages/{state-graph/dist/dist-es-5IACWOIO.js → services/dist/dist-es-OZCE67MW.js} +1 -1
- package/packages/services/dist/{dist-es-3DGJJFOU.js → dist-es-RUJB3ALN.js} +3 -3
- package/packages/{state-graph/dist/dist-es-QZ6GKMM7.js → services/dist/dist-es-SSJGP5AI.js} +4 -4
- package/packages/services/dist/{loadSso-M3ZIZDGO.js → loadSso-3PZYFUB7.js} +1 -1
- package/packages/{functions/dist/signin-YXALFRYB.js → services/dist/signin-WYPGSXHF.js} +1 -1
- package/packages/{state-graph/dist/sso-oidc-NXFKRL6O.js → services/dist/sso-oidc-PQMIMLJU.js} +1 -1
- package/packages/{state-graph/dist/sts-MICPT37B.js → services/dist/sts-Z7LR3AZH.js} +1 -1
- package/packages/state-graph/dist/browser.d.ts +8 -18
- package/packages/state-graph/dist/browser.js +334 -23
- package/packages/state-graph/dist/browser.test.d.ts +1 -0
- package/packages/state-graph/dist/{chunk-KG6QYS26.js → chunk-5KP74NMF.js} +80 -80
- package/packages/state-graph/dist/{chunk-4UVGXFEM.js → chunk-LVULR5M4.js} +1 -1
- package/packages/state-graph/dist/{chunk-S22PMERU.js → chunk-OXUDG6HE.js} +1 -1
- package/packages/state-graph/dist/{chunk-2CQQGFMF.js → chunk-UKTICGGV.js} +2616 -432
- package/packages/state-graph/dist/domain/index.js +2 -3
- package/packages/state-graph/dist/engine/AudioConcepts.d.ts +1 -1
- package/packages/state-graph/dist/engine/GraphConcepts.d.ts +1 -1
- package/packages/state-graph/dist/engine/core/archetypes/audioArchetypes.d.ts +1 -1
- package/packages/state-graph/dist/engine/core/archetypes/effectArchetypes.d.ts +1 -1
- package/packages/state-graph/dist/engine/core/archetypes/primitiveArchetypes.d.ts +1 -1
- package/packages/state-graph/dist/engine/core/archetypes/routingArchetypes.d.ts +1 -1
- package/packages/state-graph/dist/engine/core/archetypes/triggerModuleArchetypes.d.ts +1 -1
- package/packages/state-graph/dist/engine/core/assets/containerSprites.d.ts +1 -1
- package/packages/state-graph/dist/engine/core/assets/effectSprites.d.ts +1 -1
- package/packages/state-graph/dist/engine/core/assets/primitiveSprites.d.ts +1 -1
- package/packages/state-graph/dist/engine/core/assets/routingSprites.d.ts +1 -1
- package/packages/state-graph/dist/engine/core/canonicalIo/CanonicalAudioInputEndpoint.d.ts +1 -1
- package/packages/state-graph/dist/engine/core/canonicalIo/CanonicalMidiInputEndpoint.d.ts +1 -1
- package/packages/state-graph/dist/engine/core/canonicalIo/topLevelIoRegistry.d.ts +6 -6
- package/packages/state-graph/dist/engine/core/canonicalIo/types.d.ts +1 -1
- package/packages/state-graph/dist/engine/core/graphDataService.d.ts +1 -1
- package/packages/state-graph/dist/engine/core/hierarchy/index.d.ts +11 -11
- package/packages/state-graph/dist/engine/core/hierarchy/nodes/GraphNodeParent.d.ts +3 -3
- package/packages/state-graph/dist/engine/core/hierarchy/nodes/GraphNodeTypes.d.ts +1 -1
- package/packages/state-graph/dist/engine/core/hierarchy/sockets/GraphSocketParent.d.ts +2 -2
- package/packages/state-graph/dist/engine/core/hierarchy/sockets/GraphSocketTypes.d.ts +1 -1
- package/packages/state-graph/dist/engine/core/hierarchy/ui/UIElementBase.d.ts +3 -3
- package/packages/state-graph/dist/engine/core/hierarchy/wires/GraphWireParent.d.ts +2 -2
- package/packages/state-graph/dist/engine/core/hierarchy/wires/GraphWireTypes.d.ts +1 -1
- package/packages/state-graph/dist/engine/core/nodeArchetypeRegistry.d.ts +1 -1
- package/packages/state-graph/dist/engine/core/socketRegistry/containersSockets.d.ts +1 -1
- package/packages/state-graph/dist/engine/core/socketRegistry/customRegistry.d.ts +1 -1
- package/packages/state-graph/dist/engine/core/socketRegistry/landmarksSockets.d.ts +1 -1
- package/packages/state-graph/dist/engine/core/socketRegistry/primitivesSockets.d.ts +1 -1
- package/packages/state-graph/dist/engine/core/socketRegistry/processorsSockets.d.ts +1 -1
- package/packages/state-graph/dist/engine/core/sockets/arrangementControlSockets.d.ts +1 -1
- package/packages/state-graph/dist/engine/core/sockets/audioSockets.d.ts +1 -1
- package/packages/state-graph/dist/engine/core/sockets/folderButtonSockets.d.ts +1 -1
- package/packages/state-graph/dist/engine/core/sockets/moduleSockets.d.ts +1 -1
- package/packages/state-graph/dist/engine/core/sockets/playbackSockets.d.ts +1 -1
- package/packages/state-graph/dist/engine/core/sockets/primitiveSockets.d.ts +1 -1
- package/packages/state-graph/dist/engine/core/sockets/routingSockets.d.ts +1 -1
- package/packages/state-graph/dist/engine/core/sockets/samplerSockets.d.ts +1 -1
- package/packages/state-graph/dist/engine/core/sockets/stripSockets.d.ts +1 -1
- package/packages/state-graph/dist/engine/functions/arrangementFactory.d.ts +1 -1
- package/packages/state-graph/dist/engine/functions/codeNodeParser/codeNodeParser.d.ts +2 -2
- package/packages/state-graph/dist/engine/functions/codeNodeParser/helpers.d.ts +1 -1
- package/packages/state-graph/dist/engine/functions/connection/portMatching.d.ts +1 -1
- package/packages/state-graph/dist/engine/functions/connection/signalCompatibility/helpers.d.ts +1 -1
- package/packages/state-graph/dist/engine/functions/connection/signalCompatibility/signalCompatibility.d.ts +1 -1
- package/packages/state-graph/dist/engine/functions/connection/signalCompatibility.d.ts +1 -1
- package/packages/state-graph/dist/engine/functions/connection/wireValidation.d.ts +1 -1
- package/packages/state-graph/dist/engine/functions/containerClipSync.d.ts +1 -1
- package/packages/state-graph/dist/engine/functions/containerFactory/containerFactory.d.ts +1 -1
- package/packages/state-graph/dist/engine/functions/effectLogic.d.ts +1 -1
- package/packages/state-graph/dist/engine/functions/graphManager/graphManager.d.ts +1 -1
- package/packages/state-graph/dist/engine/functions/graphManager.d.ts +1 -1
- package/packages/state-graph/dist/engine/functions/nodeFactory/nodeFactory.d.ts +8 -8
- package/packages/state-graph/dist/engine/functions/nodeFactory.d.ts +2 -2
- package/packages/state-graph/dist/engine/functions/signalTable/audioMidiSignals.d.ts +1 -1
- package/packages/state-graph/dist/engine/functions/signalTable/canonicalEffectsTable.d.ts +1 -1
- package/packages/state-graph/dist/engine/functions/signalTable/dataSignals.d.ts +1 -1
- package/packages/state-graph/dist/engine/functions/socketCompatibilitySpawner/helpers.d.ts +1 -1
- package/packages/state-graph/dist/engine/functions/socketCompatibilitySpawner/socketCompatibilitySpawner.d.ts +1 -1
- package/packages/state-graph/dist/engine/functions/socketCompatibilitySpawner.d.ts +1 -1
- package/packages/state-graph/dist/engine/functions/spawnNodeFactory.d.ts +1 -1
- package/packages/state-graph/dist/engine/predictive/predictiveGraphEngine/helpers.d.ts +1 -1
- package/packages/state-graph/dist/engine/predictive/predictiveGraphEngine.d.ts +2 -2
- package/packages/state-graph/dist/engine/types/auth.d.ts +1 -1
- package/packages/state-graph/dist/engine/types/hardwareBus.d.ts +1 -1
- package/packages/state-graph/dist/engine/types/legacyTypes.d.ts +1 -1
- package/packages/state-graph/dist/engine/types/nodesArrangement.d.ts +2 -2
- package/packages/state-graph/dist/engine/types/nodesAudio.d.ts +5 -5
- package/packages/state-graph/dist/engine/types/nodesControl.d.ts +2 -2
- package/packages/state-graph/dist/engine/types/nodesPlayback.d.ts +2 -2
- package/packages/state-graph/dist/engine/types/nodesPrimitives.d.ts +6 -6
- package/packages/state-graph/dist/engine/types/nodesRouting.d.ts +2 -2
- package/packages/state-graph/dist/engine/types/sceneData.d.ts +2 -2
- package/packages/state-graph/dist/engine/types/sceneState.d.ts +4 -4
- package/packages/state-graph/dist/engine/types/signals.d.ts +2 -2
- package/packages/state-graph/dist/engine/types/stripsTypes.d.ts +2 -2
- package/packages/state-graph/dist/index.js +110 -2850
- package/packages/state-graph/dist/rules/index.js +0 -1
- package/packages/state-graph/dist/spatial/index.js +0 -1
- package/packages/state-graph/dist/state/index.js +0 -1
- package/packages/state-graph/dist/store/CommandApi.d.ts +2 -2
- package/packages/state-graph/dist/store/index.js +2 -3
- package/packages/state-graph/package.json +7 -2
- package/scripts/normalize-package-declarations.mjs +63 -0
- package/packages/backend/dist/chunk-SXDYW3QA.js +0 -579
- package/packages/functions/dist/bowser-F6LIZBYW.js +0 -2821
- package/packages/functions/dist/chunk-34KJBG4F.js +0 -357
- package/packages/functions/dist/chunk-EAQYK3U2.js +0 -41
- package/packages/functions/dist/chunk-IOAPEUC7.js +0 -3424
- package/packages/functions/dist/chunk-J64ZDIIX.js +0 -2753
- package/packages/functions/dist/chunk-N3MSTUJN.js +0 -4785
- package/packages/functions/dist/chunk-VP26OHBN.js +0 -480
- package/packages/functions/dist/chunk-VRLVLNLG.js +0 -1727
- package/packages/functions/dist/dist-TKZ5TDRN.js +0 -1124
- package/packages/functions/dist/dist-W7ZJS3LZ.js +0 -899
- package/packages/functions/dist/dist-es-3DGJJFOU.js +0 -338
- package/packages/functions/dist/dist-es-5IACWOIO.js +0 -69
- package/packages/functions/dist/dist-es-BWLDIBIA.js +0 -47
- package/packages/functions/dist/dist-es-DO3F4OBN.js +0 -377
- package/packages/functions/dist/dist-es-NN7AKU7P.js +0 -175
- package/packages/functions/dist/dist-es-QZ6GKMM7.js +0 -220
- package/packages/functions/dist/dist-es-R3VEGXOP.js +0 -87
- package/packages/functions/dist/dist-es-TLPJYZTE.js +0 -294
- package/packages/functions/dist/event-streams-DRE6QVD6.js +0 -940
- package/packages/functions/dist/loadSso-M3ZIZDGO.js +0 -586
- package/packages/functions/dist/multipart-parser-YYFFJ4QD.js +0 -371
- package/packages/functions/dist/src-2QCYQXYH.js +0 -1396
- package/packages/functions/dist/sso-oidc-NXFKRL6O.js +0 -847
- package/packages/functions/dist/sts-MICPT37B.js +0 -1253
- package/packages/functions/dist/transformers.node-R6VHTGC2.js +0 -43879
- package/packages/services/dist/chunk-K6H7T3EP.js +0 -1991
- package/packages/services/dist/dist-es-5IACWOIO.js +0 -69
- package/packages/services/dist/dist-es-QZ6GKMM7.js +0 -220
- package/packages/services/dist/dist-es-TLPJYZTE.js +0 -294
- package/packages/services/dist/signin-YXALFRYB.js +0 -831
- package/packages/services/dist/sso-oidc-NXFKRL6O.js +0 -847
- package/packages/services/dist/sts-MICPT37B.js +0 -1253
- package/packages/state-graph/dist/bowser-F6LIZBYW.js +0 -2821
- package/packages/state-graph/dist/chunk-34KJBG4F.js +0 -357
- package/packages/state-graph/dist/chunk-EAQYK3U2.js +0 -41
- package/packages/state-graph/dist/chunk-IOAPEUC7.js +0 -3424
- package/packages/state-graph/dist/chunk-J64ZDIIX.js +0 -2753
- package/packages/state-graph/dist/chunk-K6H7T3EP.js +0 -1991
- package/packages/state-graph/dist/chunk-N3MSTUJN.js +0 -4785
- package/packages/state-graph/dist/chunk-VP26OHBN.js +0 -480
- package/packages/state-graph/dist/chunk-VRLVLNLG.js +0 -1727
- package/packages/state-graph/dist/dist-TKZ5TDRN.js +0 -1124
- package/packages/state-graph/dist/dist-W7ZJS3LZ.js +0 -899
- package/packages/state-graph/dist/dist-es-3DGJJFOU.js +0 -338
- package/packages/state-graph/dist/dist-es-BWLDIBIA.js +0 -47
- package/packages/state-graph/dist/dist-es-DO3F4OBN.js +0 -377
- package/packages/state-graph/dist/dist-es-NN7AKU7P.js +0 -175
- package/packages/state-graph/dist/dist-es-R3VEGXOP.js +0 -87
- package/packages/state-graph/dist/event-streams-DRE6QVD6.js +0 -940
- package/packages/state-graph/dist/loadSso-M3ZIZDGO.js +0 -586
- package/packages/state-graph/dist/multipart-parser-YYFFJ4QD.js +0 -371
- package/packages/state-graph/dist/signin-YXALFRYB.js +0 -831
- package/packages/state-graph/dist/src-2QCYQXYH.js +0 -1396
- package/packages/state-graph/dist/transformers.node-R6VHTGC2.js +0 -43879
- package/packages/backend/dist/{chunk-LMWXONZG.js → chunk-EREYT3WJ.js} +3 -3
|
@@ -1,14 +1,21 @@
|
|
|
1
1
|
import {
|
|
2
|
+
ALL_GRAPH_TYPES,
|
|
2
3
|
ArrangementNodeModel,
|
|
4
|
+
AudioBusDriver,
|
|
5
|
+
AudioConcepts,
|
|
3
6
|
AudioMonoSocket,
|
|
4
7
|
AudioMonoWire,
|
|
5
8
|
AudioPacketSocket,
|
|
6
9
|
AudioPacketWire,
|
|
7
10
|
AudioStereoSocket,
|
|
8
11
|
AudioStereoWire,
|
|
12
|
+
BufferConcepts,
|
|
9
13
|
CANONICAL_EFFECTS_TABLE,
|
|
10
14
|
CANONICAL_SIGNAL_TYPES,
|
|
15
|
+
COLOR_PALETTES,
|
|
11
16
|
COORD_SCALE,
|
|
17
|
+
CanonicalAudioInputEndpoint,
|
|
18
|
+
CanonicalMidiInputEndpoint,
|
|
12
19
|
CodeNodeModel,
|
|
13
20
|
ComponentSocket,
|
|
14
21
|
ComponentWire,
|
|
@@ -24,8 +31,11 @@ import {
|
|
|
24
31
|
DEFAULT_WORKSPACE_GRAPHS,
|
|
25
32
|
DataProcessingNodeParent,
|
|
26
33
|
EffectNodeModel,
|
|
34
|
+
GM_DRUM_NOTES,
|
|
35
|
+
GRAPH_TYPE_DEFINITIONS,
|
|
27
36
|
GraphBridgeNode,
|
|
28
37
|
GraphConcepts,
|
|
38
|
+
GraphDataService,
|
|
29
39
|
GraphEntityParent,
|
|
30
40
|
GraphNodeParent,
|
|
31
41
|
GraphSocketParent,
|
|
@@ -38,6 +48,7 @@ import {
|
|
|
38
48
|
MidiStreamWire,
|
|
39
49
|
ModuleNodeModel,
|
|
40
50
|
NodeAssetRegistry,
|
|
51
|
+
PRESET_SCALES,
|
|
41
52
|
PrimitiveNodeModel,
|
|
42
53
|
PrimitiveSocket,
|
|
43
54
|
PrimitiveWire,
|
|
@@ -65,22 +76,39 @@ import {
|
|
|
65
76
|
RoutingNodeParent,
|
|
66
77
|
SIGNAL_TYPES,
|
|
67
78
|
SPAWN_ELEVATIONS,
|
|
79
|
+
STORAGE_KEY,
|
|
68
80
|
SignalGeneratorNodeParent,
|
|
69
81
|
StripNodeModel,
|
|
82
|
+
TopLevelIoRegistry,
|
|
70
83
|
TriggerNodeModel,
|
|
71
84
|
TriggerSocket,
|
|
72
85
|
TriggerWire,
|
|
86
|
+
UIConcepts,
|
|
73
87
|
UIElementBase,
|
|
74
88
|
WorkspaceGraphRegistry,
|
|
89
|
+
acquireAudioInputStream,
|
|
90
|
+
addNamedMidiProfile,
|
|
75
91
|
areSignalTypesCompatibleForEffect,
|
|
76
92
|
areSignalsCompatible,
|
|
93
|
+
calculateAudioMeterLevel,
|
|
77
94
|
calculateConstrainedSocketOffset,
|
|
95
|
+
calculateNextQuantizeBeat,
|
|
96
|
+
calculateNodePerformance,
|
|
97
|
+
canvasToScreen,
|
|
98
|
+
clampZoom,
|
|
78
99
|
computePredictiveGraph,
|
|
100
|
+
configureActivePaletteResolver,
|
|
101
|
+
configureCanonicalMidiBridge,
|
|
102
|
+
configureControlDispatcher,
|
|
103
|
+
configureNodePerformanceTracker,
|
|
79
104
|
configureSolidifyExecution,
|
|
80
105
|
consolidateNodesIntoGroup,
|
|
81
106
|
consolidateNodesIntoModule,
|
|
82
107
|
constrainSocketNudge,
|
|
83
108
|
constrainSocketOffset,
|
|
109
|
+
controlDispatcher,
|
|
110
|
+
convertPhysicalInputToStreamHandle,
|
|
111
|
+
convertPhysicalOutputToStreamHandle,
|
|
84
112
|
convertProjectToGraphDefinition,
|
|
85
113
|
createArrangementNode,
|
|
86
114
|
createAudioPadsNode,
|
|
@@ -117,40 +145,83 @@ import {
|
|
|
117
145
|
createTrackForSignalType,
|
|
118
146
|
createTriggerNode,
|
|
119
147
|
createUniversalWire,
|
|
148
|
+
createVirtualMidiDevice,
|
|
120
149
|
createWireInstance,
|
|
150
|
+
dbToLinear,
|
|
151
|
+
deleteNamedMidiProfile,
|
|
152
|
+
deleteVirtualMidiDevice,
|
|
153
|
+
deriveSubgraphHandlesFromGraph,
|
|
121
154
|
describeSvgArc,
|
|
155
|
+
encodeFloat32ToWavBase64,
|
|
156
|
+
enumerateSystemAudioDevices,
|
|
122
157
|
evaluateWireSignalCompatibility,
|
|
123
158
|
executeCodeNodeScript,
|
|
124
159
|
executeSceneGraphSpawningSequence,
|
|
160
|
+
extractSamplesFromConnectedContainers,
|
|
125
161
|
findCompatibleSocketPair,
|
|
126
162
|
findSocketByPortOrIndex,
|
|
127
163
|
findSourceNode,
|
|
128
164
|
findTargetContainer,
|
|
129
165
|
findTargetNode,
|
|
166
|
+
fitToView,
|
|
167
|
+
formatBeatToBarBeat,
|
|
168
|
+
formatQuantizeDivisionLabel,
|
|
130
169
|
generateCodeNodeSockets,
|
|
170
|
+
generateWavBase64FromWaveform,
|
|
171
|
+
getActiveEffectsForNode,
|
|
172
|
+
getActiveEffectsForNodeWires,
|
|
173
|
+
getActiveEffectsForWire,
|
|
174
|
+
getActivePalette,
|
|
131
175
|
getAllNodeArchetypes,
|
|
176
|
+
getAllProjectSockets,
|
|
177
|
+
getCanonicalMidiBridge,
|
|
178
|
+
getCenterPanForNode,
|
|
132
179
|
getCompatibleNodesForSocket,
|
|
180
|
+
getComponentSocketConstraint,
|
|
181
|
+
getCustomMidiName,
|
|
182
|
+
getCustomMidiNames,
|
|
183
|
+
getDefaultActiveFractions,
|
|
184
|
+
getDefaultActiveSteps,
|
|
185
|
+
getDefaultPadMidiNote,
|
|
133
186
|
getDistanceToWireSegment,
|
|
187
|
+
getDivisionBeatLength,
|
|
134
188
|
getEffectsAffectingWire,
|
|
189
|
+
getGraphTypeDefinition,
|
|
190
|
+
getNamedMidiProfiles,
|
|
135
191
|
getNodeAcceptedInputSignals,
|
|
136
192
|
getNodeDimensions,
|
|
137
193
|
getNodeInputSignalType,
|
|
138
194
|
getNodeOutputSignalType,
|
|
139
195
|
getNodeSockets,
|
|
140
196
|
getNodeSpawnElevation,
|
|
197
|
+
getNodesInSelection,
|
|
198
|
+
getResolvedMidiDevices,
|
|
141
199
|
getSolidifySynthEngine,
|
|
200
|
+
getTooltipPlacementClasses,
|
|
201
|
+
getTopologicalDependencyOrder,
|
|
202
|
+
getTriggerStepDuration,
|
|
203
|
+
getVirtualMidiDevices,
|
|
142
204
|
getWiresAffectedByEffect,
|
|
143
205
|
ingestContainerIntoArrangement,
|
|
144
206
|
initializeCoreArchetypes,
|
|
145
207
|
initializeMagneticRules,
|
|
146
208
|
initializeQwnsrMagneticRules,
|
|
209
|
+
instantiateSubgraphNode,
|
|
147
210
|
instantiateSubgraphSpaceNode,
|
|
148
211
|
isGraphImportable,
|
|
212
|
+
isNodeInCenterDeadZone,
|
|
149
213
|
isSignalCompatibleWithTrack,
|
|
150
214
|
isWireAffectedByEffect,
|
|
215
|
+
linearToDb,
|
|
151
216
|
lintJavaScriptCode,
|
|
217
|
+
loadStoredConfig,
|
|
152
218
|
mapSpaceNodeToBridgeNode,
|
|
153
219
|
materializePredictiveGhostBatch,
|
|
220
|
+
midiToFreq,
|
|
221
|
+
midiToFrequency,
|
|
222
|
+
midiToNoteName,
|
|
223
|
+
noteNameToMidi,
|
|
224
|
+
parseBufferedNumber,
|
|
154
225
|
parseCodeNodeIO,
|
|
155
226
|
polarToCartesian,
|
|
156
227
|
projectNodeToGroundSurface,
|
|
@@ -160,13 +231,28 @@ import {
|
|
|
160
231
|
registerQwnsrPaletteResolver,
|
|
161
232
|
repairAndNormalizeGraph,
|
|
162
233
|
resolveSocketDetails,
|
|
234
|
+
resolveTooltipDirection,
|
|
235
|
+
saveCustomMidiNames,
|
|
236
|
+
saveNamedMidiProfiles,
|
|
237
|
+
saveStoredConfig,
|
|
238
|
+
saveVirtualMidiDevices,
|
|
239
|
+
screenToCanvas,
|
|
240
|
+
setCustomMidiName,
|
|
241
|
+
shouldTriggerFireAtClock,
|
|
242
|
+
stopAudioMediaStream,
|
|
163
243
|
syncConnectedContainersToArrangement,
|
|
244
|
+
toggleNodeSocketExposure,
|
|
245
|
+
topLevelIoRegistry,
|
|
164
246
|
transpileCodeNodeScript,
|
|
165
247
|
unregisterCustomNodeSockets,
|
|
166
248
|
unregisterNodeArchetype,
|
|
249
|
+
updateNamedMidiProfile,
|
|
250
|
+
validateComponentSocketConnection,
|
|
251
|
+
validateGraphImport,
|
|
167
252
|
validateProjectGraph,
|
|
168
|
-
validateUniversalConnection
|
|
169
|
-
|
|
253
|
+
validateUniversalConnection,
|
|
254
|
+
zoomAtPoint
|
|
255
|
+
} from "./chunk-UKTICGGV.js";
|
|
170
256
|
import {
|
|
171
257
|
BaseHandle,
|
|
172
258
|
DataHandle,
|
|
@@ -174,23 +260,8 @@ import {
|
|
|
174
260
|
SubgraphNode,
|
|
175
261
|
ViewHandle,
|
|
176
262
|
instantiateSubgraph
|
|
177
|
-
} from "./chunk-
|
|
263
|
+
} from "./chunk-OXUDG6HE.js";
|
|
178
264
|
import "./chunk-RHRXPY2U.js";
|
|
179
|
-
import {
|
|
180
|
-
AttractionEngine,
|
|
181
|
-
GhostInferenceEngine,
|
|
182
|
-
GhostLayoutResolver,
|
|
183
|
-
GhostTracePathBuilder,
|
|
184
|
-
calculateSocketCoordinates,
|
|
185
|
-
getBeamPoints,
|
|
186
|
-
useMagneticTraces
|
|
187
|
-
} from "./chunk-JXDJZSFW.js";
|
|
188
|
-
import {
|
|
189
|
-
ConnectionRuleStore,
|
|
190
|
-
HandleTypeRegistry,
|
|
191
|
-
WireTypeRegistry,
|
|
192
|
-
initializeDefaultGraphRules
|
|
193
|
-
} from "./chunk-TZOL3RN7.js";
|
|
194
265
|
import {
|
|
195
266
|
LifecycleCycleError,
|
|
196
267
|
LifecycleGraph,
|
|
@@ -204,7 +275,7 @@ import {
|
|
|
204
275
|
CommandApi,
|
|
205
276
|
GhostStore,
|
|
206
277
|
GraphStore
|
|
207
|
-
} from "./chunk-
|
|
278
|
+
} from "./chunk-LVULR5M4.js";
|
|
208
279
|
import {
|
|
209
280
|
BaseGraph,
|
|
210
281
|
BaseNode,
|
|
@@ -213,7 +284,22 @@ import {
|
|
|
213
284
|
CustomNode,
|
|
214
285
|
CustomViewWindow,
|
|
215
286
|
DEFAULT_GRAPH_SETTINGS
|
|
216
|
-
} from "./chunk-
|
|
287
|
+
} from "./chunk-5KP74NMF.js";
|
|
288
|
+
import {
|
|
289
|
+
AttractionEngine,
|
|
290
|
+
GhostInferenceEngine,
|
|
291
|
+
GhostLayoutResolver,
|
|
292
|
+
GhostTracePathBuilder,
|
|
293
|
+
calculateSocketCoordinates,
|
|
294
|
+
getBeamPoints,
|
|
295
|
+
useMagneticTraces
|
|
296
|
+
} from "./chunk-JXDJZSFW.js";
|
|
297
|
+
import {
|
|
298
|
+
ConnectionRuleStore,
|
|
299
|
+
HandleTypeRegistry,
|
|
300
|
+
WireTypeRegistry,
|
|
301
|
+
initializeDefaultGraphRules
|
|
302
|
+
} from "./chunk-TZOL3RN7.js";
|
|
217
303
|
import {
|
|
218
304
|
AutoSolidify,
|
|
219
305
|
SpatialEngine,
|
|
@@ -227,2838 +313,12 @@ import {
|
|
|
227
313
|
import {
|
|
228
314
|
CompatibilityMatrix
|
|
229
315
|
} from "./chunk-ISFNY7EZ.js";
|
|
230
|
-
import "./chunk-EAQYK3U2.js";
|
|
231
|
-
|
|
232
|
-
// ../../node_modules/.pnpm/@ultrst-armada+krnl@1.0.9_@types+node@22.20.5/node_modules/@ultrst-armada/krnl/packages/core/dist/index.js
|
|
233
|
-
import { randomUUID } from "crypto";
|
|
234
|
-
|
|
235
|
-
// ../../node_modules/.pnpm/@dinilmusick+gutts@1.6.0_@types+node@22.20.5/node_modules/@dinilmusick/gutts/dist/api/define-api.js
|
|
236
|
-
function defineApi(definition) {
|
|
237
|
-
const properties = Object.fromEntries(definition.parameters.map((parameter) => [
|
|
238
|
-
parameter.name,
|
|
239
|
-
{
|
|
240
|
-
...parameter.schema,
|
|
241
|
-
description: parameter.description
|
|
242
|
-
}
|
|
243
|
-
]));
|
|
244
|
-
return Object.freeze({
|
|
245
|
-
...definition,
|
|
246
|
-
inputSchema: {
|
|
247
|
-
type: "object",
|
|
248
|
-
description: `Arguments for ${definition.name}.`,
|
|
249
|
-
properties,
|
|
250
|
-
required: definition.parameters.filter((parameter) => parameter.required).map((parameter) => parameter.name),
|
|
251
|
-
additionalProperties: false
|
|
252
|
-
}
|
|
253
|
-
});
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
// ../../node_modules/.pnpm/@dinilmusick+gutts@1.6.0_@types+node@22.20.5/node_modules/@dinilmusick/gutts/dist/api/array-apis.js
|
|
257
|
-
var array = { type: "array" };
|
|
258
|
-
var integer = { type: "integer" };
|
|
259
|
-
var arrayApis = [
|
|
260
|
-
defineApi({ id: "gutts.arrays.compact", name: "compact", category: "arrays", description: "Removes null and undefined values from an array while preserving the remaining values and their order.", parameters: [{ name: "values", description: "The array whose nullish elements should be removed.", required: true, schema: array }], output: { type: "array", description: "The array without null or undefined elements." }, semantics: { deterministic: true, pure: true, sideEffects: false } }),
|
|
261
|
-
defineApi({ id: "gutts.arrays.unique", name: "unique", category: "arrays", description: "Removes duplicate values from an array while preserving the first occurrence of each value.", parameters: [{ name: "values", description: "The array from which duplicate values should be removed.", required: true, schema: array }], output: { type: "array", description: "The array containing only the first occurrence of each value." }, semantics: { deterministic: true, pure: true, sideEffects: false } }),
|
|
262
|
-
defineApi({ id: "gutts.arrays.chunk", name: "chunk", category: "arrays", description: "Splits an array into consecutive subarrays of the requested maximum size.", parameters: [{ name: "values", description: "The array to split into chunks.", required: true, schema: array }, { name: "size", description: "The positive integer maximum number of elements in each chunk.", required: true, schema: integer }], output: { type: "array", items: array, description: "An array of consecutive subarrays." }, semantics: { deterministic: true, pure: true, sideEffects: false }, errors: ["Throws RangeError when size is not a positive integer."] }),
|
|
263
|
-
defineApi({ id: "gutts.arrays.flatten", name: "flatten", category: "arrays", description: "Flattens one level of nested arrays into a single array.", parameters: [{ name: "values", description: "The array containing values or one-level nested arrays.", required: true, schema: array }], output: { type: "array", description: "The flattened array." }, semantics: { deterministic: true, pure: true, sideEffects: false } }),
|
|
264
|
-
defineApi({ id: "gutts.arrays.last", name: "last", category: "arrays", description: "Returns the final element of an array, or undefined when the array is empty.", parameters: [{ name: "values", description: "The array whose final element should be returned.", required: true, schema: array }], output: { description: "The final array element, or undefined for an empty array." }, semantics: { deterministic: true, pure: true, sideEffects: false } })
|
|
265
|
-
];
|
|
266
|
-
|
|
267
|
-
// ../../node_modules/.pnpm/@dinilmusick+gutts@1.6.0_@types+node@22.20.5/node_modules/@dinilmusick/gutts/dist/api/json-apis.js
|
|
268
|
-
var json = { type: "object", description: "A JSON-compatible value." };
|
|
269
|
-
var jsonApis = [
|
|
270
|
-
defineApi({ id: "gutts.json.isJsonValue", name: "isJsonValue", category: "json", description: "Checks whether an unknown value can be represented as a finite JSON value.", parameters: [{ name: "value", description: "The value to validate as JSON-compatible data.", required: true, schema: {} }], output: { type: "boolean", description: "True when the value is a valid JSON value." }, semantics: { deterministic: true, pure: true, sideEffects: false } }),
|
|
271
|
-
defineApi({ id: "gutts.json.parseJson", name: "parseJson", category: "json", description: "Parses a JSON text string into a JSON-compatible value.", parameters: [{ name: "text", description: "The JSON document to parse.", required: true, schema: { type: "string" } }], output: json, semantics: { deterministic: true, pure: true, sideEffects: false }, errors: ["Throws SyntaxError when text is not valid JSON."] }),
|
|
272
|
-
defineApi({ id: "gutts.json.tryParseJson", name: "tryParseJson", category: "json", description: "Attempts to parse JSON text and returns undefined instead of throwing when parsing fails.", parameters: [{ name: "text", description: "The JSON document to parse.", required: true, schema: { type: "string" } }], output: { description: "The parsed JSON value, or undefined when parsing fails." }, semantics: { deterministic: true, pure: true, sideEffects: false } }),
|
|
273
|
-
defineApi({ id: "gutts.json.stringifyJson", name: "stringifyJson", category: "json", description: "Serializes a JSON-compatible value into JSON text, optionally using indentation.", parameters: [{ name: "value", description: "The JSON-compatible value to serialize.", required: true, schema: {} }, { name: "space", description: "Optional number of indentation spaces to use in the serialized output.", required: false, schema: { type: "number" } }], output: { type: "string", description: "The serialized JSON text." }, semantics: { deterministic: true, pure: true, sideEffects: false }, errors: ["Throws TypeError when the value cannot be serialized as JSON."] })
|
|
274
|
-
];
|
|
275
|
-
|
|
276
|
-
// ../../node_modules/.pnpm/@dinilmusick+gutts@1.6.0_@types+node@22.20.5/node_modules/@dinilmusick/gutts/dist/api/number-apis.js
|
|
277
|
-
var numberApis = [
|
|
278
|
-
defineApi({ id: "gutts.numbers.clamp", name: "clamp", category: "numbers", description: "Restricts a numeric value to an inclusive minimum and maximum range.", parameters: [{ name: "value", description: "The numeric value to constrain.", required: true, schema: { type: "number" } }, { name: "min", description: "The inclusive lower bound.", required: true, schema: { type: "number" } }, { name: "max", description: "The inclusive upper bound.", required: true, schema: { type: "number" } }], output: { type: "number", description: "The value constrained to the inclusive range." }, semantics: { deterministic: true, pure: true, sideEffects: false }, errors: ["Throws RangeError when min exceeds max."] }),
|
|
279
|
-
defineApi({ id: "gutts.numbers.inRange", name: "inRange", category: "numbers", description: "Checks whether a numeric value falls within the configured range.", parameters: [{ name: "value", description: "The numeric value to test.", required: true, schema: { type: "number" } }, { name: "min", description: "The lower range boundary.", required: true, schema: { type: "number" } }, { name: "max", description: "The upper range boundary.", required: true, schema: { type: "number" } }], output: { type: "boolean", description: "Whether the value is inside the range." }, semantics: { deterministic: true, pure: true, sideEffects: false }, errors: ["Throws RangeError when min exceeds max."] }),
|
|
280
|
-
defineApi({ id: "gutts.numbers.roundTo", name: "roundTo", category: "numbers", description: "Rounds a number to a specified non-negative number of decimal places.", parameters: [{ name: "value", description: "The number to round.", required: true, schema: { type: "number" } }, { name: "decimals", description: "The non-negative integer number of decimal places.", required: false, schema: { type: "integer" } }], output: { type: "number", description: "The rounded number." }, semantics: { deterministic: true, pure: true, sideEffects: false }, errors: ["Throws RangeError when decimals is negative or not an integer."] }),
|
|
281
|
-
defineApi({ id: "gutts.numbers.isFiniteNumber", name: "isFiniteNumber", category: "numbers", description: "Checks whether a value is a JavaScript number and is finite.", parameters: [{ name: "value", description: "The value to test.", required: true, schema: {} }], output: { type: "boolean", description: "True only for finite JavaScript numbers." }, semantics: { deterministic: true, pure: true, sideEffects: false } }),
|
|
282
|
-
defineApi({ id: "gutts.numbers.sum", name: "sum", category: "numbers", description: "Adds all numbers in an array and returns their total.", parameters: [{ name: "values", description: "The numeric values to add.", required: true, schema: { type: "array", items: { type: "number" } } }], output: { type: "number", description: "The sum of all input numbers." }, semantics: { deterministic: true, pure: true, sideEffects: false } })
|
|
283
|
-
];
|
|
284
|
-
|
|
285
|
-
// ../../node_modules/.pnpm/@dinilmusick+gutts@1.6.0_@types+node@22.20.5/node_modules/@dinilmusick/gutts/dist/api/object-apis.js
|
|
286
|
-
var objectApis = [
|
|
287
|
-
defineApi({ id: "gutts.objects.hasOwn", name: "hasOwn", category: "objects", description: "Checks whether an object contains a requested property.", parameters: [{ name: "value", description: "The object to inspect.", required: true, schema: { type: "object" } }, { name: "key", description: "The property key to look for.", required: true, schema: { type: "string" } }], output: { type: "boolean" }, semantics: { deterministic: true, pure: true, sideEffects: false } }),
|
|
288
|
-
defineApi({ id: "gutts.objects.pick", name: "pick", category: "objects", description: "Creates an object containing only requested properties.", parameters: [{ name: "value", description: "The source object.", required: true, schema: { type: "object" } }, { name: "keys", description: "The property keys to retain.", required: true, schema: { type: "array", items: { type: "string" } } }], output: { type: "object" }, semantics: { deterministic: true, pure: true, sideEffects: false } }),
|
|
289
|
-
defineApi({ id: "gutts.objects.omit", name: "omit", category: "objects", description: "Creates an object without requested properties.", parameters: [{ name: "value", description: "The source object.", required: true, schema: { type: "object" } }, { name: "keys", description: "The property keys to remove.", required: true, schema: { type: "array", items: { type: "string" } } }], output: { type: "object" }, semantics: { deterministic: true, pure: true, sideEffects: false } }),
|
|
290
|
-
defineApi({ id: "gutts.objects.isPlainObject", name: "isPlainObject", category: "objects", description: "Checks whether a value is a plain JavaScript object.", parameters: [{ name: "value", description: "The value to classify.", required: true, schema: {} }], output: { type: "boolean" }, semantics: { deterministic: true, pure: true, sideEffects: false } })
|
|
291
|
-
];
|
|
292
|
-
|
|
293
|
-
// ../../node_modules/.pnpm/@dinilmusick+gutts@1.6.0_@types+node@22.20.5/node_modules/@dinilmusick/gutts/dist/api/string-apis.js
|
|
294
|
-
var string = { type: "string" };
|
|
295
|
-
var stringApis = [
|
|
296
|
-
defineApi({ id: "gutts.strings.isBlank", name: "isBlank", category: "strings", description: "Checks whether a string contains no non-whitespace characters.", parameters: [{ name: "value", description: "The string to inspect.", required: true, schema: string }], output: { type: "boolean" }, semantics: { deterministic: true, pure: true, sideEffects: false } }),
|
|
297
|
-
defineApi({ id: "gutts.strings.isNonBlank", name: "isNonBlank", category: "strings", description: "Checks whether a string contains at least one non-whitespace character.", parameters: [{ name: "value", description: "The string to inspect.", required: true, schema: string }], output: { type: "boolean" }, semantics: { deterministic: true, pure: true, sideEffects: false } }),
|
|
298
|
-
defineApi({ id: "gutts.strings.isEmail", name: "isEmail", category: "strings", description: "Checks whether a string conforms to the email-address validation rules used by GutTS.", parameters: [{ name: "value", description: "The string to validate as an email address.", required: true, schema: string }], output: { type: "boolean" }, semantics: { deterministic: true, pure: true, sideEffects: false } }),
|
|
299
|
-
defineApi({ id: "gutts.strings.startsWithAny", name: "startsWithAny", category: "strings", description: "Checks whether a string starts with at least one supplied prefix.", parameters: [{ name: "value", description: "The string to inspect.", required: true, schema: string }, { name: "prefixes", description: "The prefixes to test.", required: true, schema: { type: "array", items: string } }], output: { type: "boolean" }, semantics: { deterministic: true, pure: true, sideEffects: false } }),
|
|
300
|
-
defineApi({ id: "gutts.strings.endsWithAny", name: "endsWithAny", category: "strings", description: "Checks whether a string ends with at least one supplied suffix.", parameters: [{ name: "value", description: "The string to inspect.", required: true, schema: string }, { name: "suffixes", description: "The suffixes to test.", required: true, schema: { type: "array", items: string } }], output: { type: "boolean" }, semantics: { deterministic: true, pure: true, sideEffects: false } }),
|
|
301
|
-
defineApi({ id: "gutts.strings.capitalize", name: "capitalize", category: "strings", description: "Capitalizes a string using the library's existing capitalization behavior.", parameters: [{ name: "value", description: "The string to capitalize.", required: true, schema: string }], output: { type: "string" }, semantics: { deterministic: true, pure: true, sideEffects: false } }),
|
|
302
|
-
defineApi({ id: "gutts.strings.camelCase", name: "camelCase", category: "strings", description: "Converts a string into lower camel case.", parameters: [{ name: "value", description: "The string to convert.", required: true, schema: string }], output: { type: "string" }, semantics: { deterministic: true, pure: true, sideEffects: false } }),
|
|
303
|
-
defineApi({ id: "gutts.strings.kebabCase", name: "kebabCase", category: "strings", description: "Converts a string into lower kebab case.", parameters: [{ name: "value", description: "The string to convert.", required: true, schema: string }], output: { type: "string" }, semantics: { deterministic: true, pure: true, sideEffects: false } }),
|
|
304
|
-
defineApi({ id: "gutts.strings.snakeCase", name: "snakeCase", category: "strings", description: "Converts a string into lower snake case.", parameters: [{ name: "value", description: "The string to convert.", required: true, schema: string }], output: { type: "string" }, semantics: { deterministic: true, pure: true, sideEffects: false } }),
|
|
305
|
-
defineApi({ id: "gutts.strings.truncate", name: "truncate", category: "strings", description: "Shortens a string to a maximum length and appends a suffix when truncation is required.", parameters: [{ name: "value", description: "The string to shorten.", required: true, schema: string }, { name: "maxLength", description: "The non-negative maximum output length.", required: true, schema: { type: "number" } }, { name: "suffix", description: "The suffix used when truncation occurs.", required: false, schema: string }], output: { type: "string" }, semantics: { deterministic: true, pure: true, sideEffects: false }, errors: ["Throws RangeError when maxLength is negative."] }),
|
|
306
|
-
defineApi({ id: "gutts.strings.truncateWords", name: "truncateWords", category: "strings", description: "Shortens a string to a maximum number of words and appends a suffix when truncation is required.", parameters: [{ name: "value", description: "The string to shorten.", required: true, schema: string }, { name: "maxWords", description: "The non-negative maximum number of words.", required: true, schema: { type: "number" } }, { name: "suffix", description: "The suffix used when truncation occurs.", required: false, schema: string }], output: { type: "string" }, semantics: { deterministic: true, pure: true, sideEffects: false }, errors: ["Throws RangeError when maxWords is negative."] })
|
|
307
|
-
];
|
|
308
|
-
|
|
309
|
-
// ../../node_modules/.pnpm/@dinilmusick+gutts@1.6.0_@types+node@22.20.5/node_modules/@dinilmusick/gutts/dist/api/url-apis.js
|
|
310
|
-
var string2 = { type: "string" };
|
|
311
|
-
var urlApis = [
|
|
312
|
-
defineApi({ id: "gutts.urls.isUrl", name: "isUrl", category: "urls", description: "Checks whether a string can be parsed as a URL by the standard URL constructor.", parameters: [{ name: "value", description: "The string to validate.", required: true, schema: string2 }], output: { type: "boolean" }, semantics: { deterministic: true, pure: true, sideEffects: false } }),
|
|
313
|
-
defineApi({ id: "gutts.urls.joinUrl", name: "joinUrl", category: "urls", description: "Joins a base URL-like string and path segments using single separators.", parameters: [{ name: "base", description: "The base URL or path.", required: true, schema: string2 }, { name: "parts", description: "The path segments to append.", required: true, schema: { type: "array", items: string2 } }], output: { type: "string" }, semantics: { deterministic: true, pure: true, sideEffects: false } }),
|
|
314
|
-
defineApi({ id: "gutts.urls.getQueryParam", name: "getQueryParam", category: "urls", description: "Reads one query-string parameter from a URL.", parameters: [{ name: "url", description: "The URL to inspect.", required: true, schema: string2 }, { name: "key", description: "The query parameter name.", required: true, schema: string2 }], output: { type: "string", description: "The value, or null when absent." }, semantics: { deterministic: true, pure: true, sideEffects: false } }),
|
|
315
|
-
defineApi({ id: "gutts.urls.setQueryParam", name: "setQueryParam", category: "urls", description: "Returns a URL with one query-string parameter set to the supplied value.", parameters: [{ name: "url", description: "The URL to modify.", required: true, schema: string2 }, { name: "key", description: "The query parameter name.", required: true, schema: string2 }, { name: "value", description: "The query parameter value.", required: true, schema: string2 }], output: { type: "string" }, semantics: { deterministic: true, pure: true, sideEffects: false }, errors: ["Throws when url cannot be parsed as a URL."] })
|
|
316
|
-
];
|
|
317
|
-
|
|
318
|
-
// ../../node_modules/.pnpm/@dinilmusick+gutts@1.6.0_@types+node@22.20.5/node_modules/@dinilmusick/gutts/dist/models/needle3/index.js
|
|
319
|
-
var needle3Metadata = {
|
|
320
|
-
id: "model.cactus-needle3",
|
|
321
|
-
name: "Needle 3",
|
|
322
|
-
provider: "Cactus Compute",
|
|
323
|
-
version: "3",
|
|
324
|
-
description: "Tiny structured inference model for tool selection, argument extraction, classification, and embeddings.",
|
|
325
|
-
examples: ["select a tool", "extract fields", "classify an intent"],
|
|
326
|
-
avoidWhen: "Avoid for open-ended long-form generation or complex multi-step reasoning.",
|
|
327
|
-
whenToUse: "Use when natural language must be mapped to a small tool set or structured schema.",
|
|
328
|
-
size: { min: 8, max: 29, unit: "MB", qualifier: "range" },
|
|
329
|
-
capabilities: ["tool-selection", "argument-extraction", "classification", "structured-output", "embeddings"],
|
|
330
|
-
input: "Natural-language text with optional tools or extraction schema",
|
|
331
|
-
output: "Structured JSON or embedding vector",
|
|
332
|
-
runtime: "Cactus Needle runtime adapter",
|
|
333
|
-
modelUri: "Cactus-Compute/needle3"
|
|
334
|
-
};
|
|
335
|
-
var needle3CompleteApi = defineApi({
|
|
336
|
-
id: "model.cactus-needle3.complete",
|
|
337
|
-
name: "Needle3.complete",
|
|
338
|
-
category: "models",
|
|
339
|
-
description: "Select tools or extract structured data from natural-language input.",
|
|
340
|
-
parameters: [
|
|
341
|
-
{ name: "prompt", description: "Natural-language input.", required: true, schema: { type: "string" } },
|
|
342
|
-
{ name: "tools", description: "Optional tool definitions.", required: false, schema: { type: "array" } },
|
|
343
|
-
{ name: "schema", description: "Optional extraction schema.", required: false, schema: { type: "object" } }
|
|
344
|
-
],
|
|
345
|
-
output: { type: "object", description: "Structured model result." },
|
|
346
|
-
semantics: { deterministic: false, pure: false, sideEffects: false }
|
|
347
|
-
});
|
|
348
|
-
|
|
349
|
-
// ../../node_modules/.pnpm/@dinilmusick+gutts@1.6.0_@types+node@22.20.5/node_modules/@dinilmusick/gutts/dist/models/runtimes/ettin-head.js
|
|
350
|
-
import fs from "fs";
|
|
351
|
-
import path from "path";
|
|
352
|
-
import os from "os";
|
|
353
|
-
|
|
354
|
-
// ../../node_modules/.pnpm/@dinilmusick+gutts@1.6.0_@types+node@22.20.5/node_modules/@dinilmusick/gutts/dist/models/smollm2/index.js
|
|
355
|
-
var smolLM2Metadata = {
|
|
356
|
-
id: "model.smollm2-135m-instruct",
|
|
357
|
-
name: "SmolLM2-135M-Instruct",
|
|
358
|
-
provider: "Hugging Face",
|
|
359
|
-
version: "135M",
|
|
360
|
-
description: "Compact instruction-tuned language model for general text generation.",
|
|
361
|
-
examples: ["summarize text", "rewrite text", "draft a short response"],
|
|
362
|
-
avoidWhen: "Avoid for high-stakes reasoning, broad factual knowledge, or tasks requiring large context.",
|
|
363
|
-
whenToUse: "Use for short general-purpose text generation when a local model is preferred.",
|
|
364
|
-
size: { value: 105, unit: "MB", qualifier: "artifact" },
|
|
365
|
-
capabilities: ["text-generation", "instruction-following"],
|
|
366
|
-
input: "Natural-language prompt",
|
|
367
|
-
output: "Generated natural-language text",
|
|
368
|
-
runtime: "ModelRuntime adapter",
|
|
369
|
-
modelUri: "HuggingFaceTB/SmolLM2-135M-Instruct",
|
|
370
|
-
license: "Apache-2.0"
|
|
371
|
-
};
|
|
372
|
-
var smolLM2GenerateApi = defineApi({
|
|
373
|
-
id: "model.smollm2-135m-instruct.generate",
|
|
374
|
-
name: "SmolLM2-135M-Instruct.generate",
|
|
375
|
-
category: "models",
|
|
376
|
-
description: "Generate natural-language text with SmolLM2-135M-Instruct.",
|
|
377
|
-
parameters: [
|
|
378
|
-
{ name: "prompt", description: "Prompt supplied to the model.", required: true, schema: { type: "string" } },
|
|
379
|
-
{ name: "maxNewTokens", description: "Maximum number of new tokens.", required: false, schema: { type: "number" } }
|
|
380
|
-
],
|
|
381
|
-
output: { type: "string", description: "Generated natural-language text." },
|
|
382
|
-
semantics: { deterministic: false, pure: false, sideEffects: false },
|
|
383
|
-
errors: ["Model load failure", "Inference failure"]
|
|
384
|
-
});
|
|
385
|
-
|
|
386
|
-
// ../../node_modules/.pnpm/@dinilmusick+gutts@1.6.0_@types+node@22.20.5/node_modules/@dinilmusick/gutts/dist/models/whistle/index.js
|
|
387
|
-
var whistleMetadata = {
|
|
388
|
-
id: "model.cactus-whistle",
|
|
389
|
-
name: "Whistle",
|
|
390
|
-
provider: "Cactus Compute",
|
|
391
|
-
version: "1",
|
|
392
|
-
description: "Compact CPU speech-recognition model for on-device transcription.",
|
|
393
|
-
examples: ["transcribe a voice note", "transcribe a command"],
|
|
394
|
-
avoidWhen: "Avoid when audio understanding beyond transcription is required.",
|
|
395
|
-
whenToUse: "Use for local speech-to-text when low resource use and privacy matter.",
|
|
396
|
-
size: { value: 16.9, unit: "MB", qualifier: "artifact" },
|
|
397
|
-
capabilities: ["speech-to-text", "on-device", "cpu"],
|
|
398
|
-
input: "Audio bytes",
|
|
399
|
-
output: "Transcribed natural-language text",
|
|
400
|
-
runtime: "Cactus Needle runtime adapter",
|
|
401
|
-
modelUri: "Cactus-Compute/whistle"
|
|
402
|
-
};
|
|
403
|
-
var whistleTranscribeApi = defineApi({
|
|
404
|
-
id: "model.cactus-whistle.transcribe",
|
|
405
|
-
name: "Whistle.transcribe",
|
|
406
|
-
category: "models",
|
|
407
|
-
description: "Transcribe speech audio into natural-language text.",
|
|
408
|
-
parameters: [
|
|
409
|
-
{ name: "audio", description: "Audio bytes supplied to the speech model.", required: true, schema: { type: "string" } },
|
|
410
|
-
{ name: "language", description: "Optional language identifier.", required: false, schema: { type: "string" } }
|
|
411
|
-
],
|
|
412
|
-
output: { type: "string", description: "Transcribed text." },
|
|
413
|
-
semantics: { deterministic: true, pure: false, sideEffects: false }
|
|
414
|
-
});
|
|
415
|
-
|
|
416
|
-
// ../../node_modules/.pnpm/@dinilmusick+gutts@1.6.0_@types+node@22.20.5/node_modules/@dinilmusick/gutts/dist/models/ettin/index.js
|
|
417
|
-
var defineEttin = (id2, name, parameters, description) => ({
|
|
418
|
-
id: id2,
|
|
419
|
-
name,
|
|
420
|
-
provider: "Hugging Face",
|
|
421
|
-
version: String(parameters),
|
|
422
|
-
description,
|
|
423
|
-
examples: ["rank search results", "order retrieved documents by relevance"],
|
|
424
|
-
whenToUse: "Use for cross-encoder reranking when candidate texts must be sorted by semantic relevance.",
|
|
425
|
-
avoidWhen: "Avoid for text generation, embeddings, or transcription.",
|
|
426
|
-
size: { value: parameters * 1e6, unit: "parameters", qualifier: "parameters" },
|
|
427
|
-
capabilities: ["reranking", "relevance-scoring"],
|
|
428
|
-
input: "Query and candidate texts",
|
|
429
|
-
output: "Candidate relevance scores",
|
|
430
|
-
runtime: "ModelRuntime adapter",
|
|
431
|
-
modelUri: `cross-encoder/ettin-reranker-${parameters}m-v1`,
|
|
432
|
-
license: "Apache-2.0"
|
|
433
|
-
});
|
|
434
|
-
var ettinReranker17MMetadata = defineEttin("model.ettin-reranker-17m", "Ettin-Reranker-17M", 17, "Very small relevance model for ranking candidate text.");
|
|
435
|
-
var ettinReranker32MMetadata = defineEttin("model.ettin-reranker-32m", "Ettin-Reranker-32M", 32, "Small relevance model for ranking candidate text.");
|
|
436
|
-
var ettinReranker68MMetadata = defineEttin("model.ettin-reranker-68m", "Ettin-Reranker-68M", 68, "Compact relevance model for higher-quality candidate ranking.");
|
|
437
|
-
var ettinReranker150MMetadata = defineEttin("model.ettin-reranker-150m", "Ettin-Reranker-150M", 150, "Larger compact relevance model for candidate ranking.");
|
|
438
|
-
var ettinRerankApi = defineApi({
|
|
439
|
-
id: "model.ettin-reranker.rerank",
|
|
440
|
-
name: "EttinReranker.rerank",
|
|
441
|
-
category: "models",
|
|
442
|
-
description: "Rank candidate texts by relevance to a query.",
|
|
443
|
-
parameters: [
|
|
444
|
-
{ name: "query", description: "Query text.", required: true, schema: { type: "string" } },
|
|
445
|
-
{ name: "candidates", description: "Candidate texts to rank.", required: true, schema: { type: "array", items: { type: "string" } } }
|
|
446
|
-
],
|
|
447
|
-
output: { type: "array", description: "Relevance scores in candidate order.", items: { type: "number" } },
|
|
448
|
-
semantics: { deterministic: true, pure: false, sideEffects: false }
|
|
449
|
-
});
|
|
450
|
-
|
|
451
|
-
// ../../node_modules/.pnpm/@dinilmusick+gutts@1.6.0_@types+node@22.20.5/node_modules/@dinilmusick/gutts/dist/models/minilm/index.js
|
|
452
|
-
var miniLML6Metadata = {
|
|
453
|
-
id: "model.minilm-l6-v2",
|
|
454
|
-
name: "MiniLM-L6-v2",
|
|
455
|
-
provider: "Sentence Transformers",
|
|
456
|
-
version: "L6-v2",
|
|
457
|
-
description: "Compact sentence embedding model for semantic similarity.",
|
|
458
|
-
examples: ["compare two texts", "match a query to a short description"],
|
|
459
|
-
avoidWhen: "Avoid when generation, extraction, or tool calling is required.",
|
|
460
|
-
whenToUse: "Use for lightweight semantic similarity and embedding-based matching.",
|
|
461
|
-
size: { value: 227e5, unit: "parameters", qualifier: "parameters" },
|
|
462
|
-
capabilities: ["embeddings", "semantic-similarity"],
|
|
463
|
-
input: "Two text strings",
|
|
464
|
-
output: "Similarity score",
|
|
465
|
-
runtime: "ModelRuntime adapter",
|
|
466
|
-
modelUri: "sentence-transformers/all-MiniLM-L6-v2",
|
|
467
|
-
license: "Apache-2.0"
|
|
468
|
-
};
|
|
469
|
-
var miniLMSimilarityApi = defineApi({
|
|
470
|
-
id: "model.minilm-l6-v2.similarity",
|
|
471
|
-
name: "MiniLM-L6-v2.similarity",
|
|
472
|
-
category: "models",
|
|
473
|
-
description: "Compute semantic similarity between two texts.",
|
|
474
|
-
parameters: [
|
|
475
|
-
{ name: "left", description: "First text.", required: true, schema: { type: "string" } },
|
|
476
|
-
{ name: "right", description: "Second text.", required: true, schema: { type: "string" } }
|
|
477
|
-
],
|
|
478
|
-
output: { type: "number", description: "Semantic similarity score." },
|
|
479
|
-
semantics: { deterministic: true, pure: false, sideEffects: false }
|
|
480
|
-
});
|
|
481
|
-
|
|
482
|
-
// ../../node_modules/.pnpm/@dinilmusick+gutts@1.6.0_@types+node@22.20.5/node_modules/@dinilmusick/gutts/dist/api/api-registry.js
|
|
483
|
-
var guttsApiDefinitions = Object.freeze([
|
|
484
|
-
...arrayApis,
|
|
485
|
-
...jsonApis,
|
|
486
|
-
...numberApis,
|
|
487
|
-
...objectApis,
|
|
488
|
-
...stringApis,
|
|
489
|
-
...urlApis,
|
|
490
|
-
smolLM2GenerateApi,
|
|
491
|
-
needle3CompleteApi,
|
|
492
|
-
whistleTranscribeApi,
|
|
493
|
-
ettinRerankApi,
|
|
494
|
-
miniLMSimilarityApi
|
|
495
|
-
]);
|
|
496
|
-
var guttsApiById = Object.freeze(Object.fromEntries(guttsApiDefinitions.map((api) => [api.id, api])));
|
|
497
|
-
|
|
498
|
-
// ../../node_modules/.pnpm/@dinilmusick+gutts@1.6.0_@types+node@22.20.5/node_modules/@dinilmusick/gutts/dist/api/fod-node-provider.js
|
|
499
|
-
var schemaType = (schema) => String(schema?.type ?? "any");
|
|
500
|
-
function guttsApiToFodNode(api) {
|
|
501
|
-
return {
|
|
502
|
-
type: `gutts/${api.id}`,
|
|
503
|
-
label: api.name,
|
|
504
|
-
description: api.description,
|
|
505
|
-
category: "gutts",
|
|
506
|
-
group: api.category,
|
|
507
|
-
inputs: api.parameters.map((parameter) => ({ id: parameter.name, name: parameter.name, direction: "input", dataType: schemaType(parameter.schema), required: parameter.required, description: parameter.description, schema: parameter.schema })),
|
|
508
|
-
outputs: [{ id: "result", name: "result", direction: "output", dataType: schemaType(api.output), ...api.output.description ? { description: api.output.description } : {}, schema: api.output }],
|
|
509
|
-
metadata: { apiId: api.id, package: "@dinilmusick/gutts", semantics: api.semantics }
|
|
510
|
-
};
|
|
511
|
-
}
|
|
512
|
-
var guttsFodNodeDefinitions = Object.freeze(guttsApiDefinitions.map(guttsApiToFodNode));
|
|
513
|
-
|
|
514
|
-
// ../../node_modules/.pnpm/@dinilmusick+gutts@1.6.0_@types+node@22.20.5/node_modules/@dinilmusick/gutts/dist/models/model-registry.js
|
|
515
|
-
var guttsModelDefinitions = Object.freeze([
|
|
516
|
-
smolLM2Metadata,
|
|
517
|
-
needle3Metadata,
|
|
518
|
-
whistleMetadata,
|
|
519
|
-
ettinReranker17MMetadata,
|
|
520
|
-
ettinReranker32MMetadata,
|
|
521
|
-
ettinReranker68MMetadata,
|
|
522
|
-
ettinReranker150MMetadata,
|
|
523
|
-
miniLML6Metadata
|
|
524
|
-
]);
|
|
525
|
-
var guttsModelById = Object.freeze(Object.fromEntries(guttsModelDefinitions.map((model) => [model.id, model])));
|
|
526
|
-
|
|
527
|
-
// ../../node_modules/.pnpm/@ultrst-armada+krnl@1.0.9_@types+node@22.20.5/node_modules/@ultrst-armada/krnl/packages/core/dist/index.js
|
|
528
|
-
var ServiceStateStore = class {
|
|
529
|
-
state;
|
|
530
|
-
listeners = /* @__PURE__ */ new Set();
|
|
531
|
-
constructor(initialState) {
|
|
532
|
-
this.state = { ...initialState };
|
|
533
|
-
}
|
|
534
|
-
getState() {
|
|
535
|
-
return Object.freeze({ ...this.state });
|
|
536
|
-
}
|
|
537
|
-
setState(mutation) {
|
|
538
|
-
this.state = { ...this.state, ...mutation };
|
|
539
|
-
const snapshot = this.getState();
|
|
540
|
-
for (const listener of this.listeners) {
|
|
541
|
-
listener(snapshot, mutation);
|
|
542
|
-
}
|
|
543
|
-
}
|
|
544
|
-
subscribe(listener) {
|
|
545
|
-
this.listeners.add(listener);
|
|
546
|
-
return () => {
|
|
547
|
-
this.listeners.delete(listener);
|
|
548
|
-
};
|
|
549
|
-
}
|
|
550
|
-
reset(newState) {
|
|
551
|
-
this.state = { ...newState || {} };
|
|
552
|
-
}
|
|
553
|
-
};
|
|
554
|
-
var TRANSITIONS = {
|
|
555
|
-
uninitialized: ["initializing"],
|
|
556
|
-
initializing: ["ready", "uninitialized"],
|
|
557
|
-
ready: ["starting"],
|
|
558
|
-
starting: ["running", "ready"],
|
|
559
|
-
running: ["stopping"],
|
|
560
|
-
stopping: ["stopped", "running"],
|
|
561
|
-
stopped: ["starting"]
|
|
562
|
-
};
|
|
563
|
-
var LifecycleManager = class {
|
|
564
|
-
status = "uninitialized";
|
|
565
|
-
getStatus() {
|
|
566
|
-
return this.status;
|
|
567
|
-
}
|
|
568
|
-
canTransitionTo(next) {
|
|
569
|
-
return TRANSITIONS[this.status].includes(next);
|
|
570
|
-
}
|
|
571
|
-
transitionTo(next) {
|
|
572
|
-
if (!this.canTransitionTo(next)) {
|
|
573
|
-
throw new Error("[Lifecycle] Invalid transition '" + this.status + "' -> '" + next + "'.");
|
|
574
|
-
}
|
|
575
|
-
this.status = next;
|
|
576
|
-
}
|
|
577
|
-
setStatus(next) {
|
|
578
|
-
this.transitionTo(next);
|
|
579
|
-
}
|
|
580
|
-
assertRunning(serviceName) {
|
|
581
|
-
if (this.status !== "running") {
|
|
582
|
-
throw new Error(
|
|
583
|
-
"[Service:" + serviceName + "] Cannot invoke operation while status is '" + this.status + "' (expected 'running')."
|
|
584
|
-
);
|
|
585
|
-
}
|
|
586
|
-
}
|
|
587
|
-
};
|
|
588
|
-
var runtimeProcess = typeof globalThis !== "undefined" ? globalThis.process : void 0;
|
|
589
|
-
var runtimePerformance = typeof globalThis !== "undefined" ? globalThis.performance : void 0;
|
|
590
|
-
function telemetryNow() {
|
|
591
|
-
return runtimePerformance?.now ? runtimePerformance.now() : Date.now();
|
|
592
|
-
}
|
|
593
|
-
function sampleResources() {
|
|
594
|
-
const memory = runtimeProcess?.memoryUsage?.();
|
|
595
|
-
const cpu = runtimeProcess?.cpuUsage?.();
|
|
596
|
-
const eventLoop = runtimePerformance?.eventLoopUtilization?.();
|
|
597
|
-
return {
|
|
598
|
-
cpuUserMicros: cpu?.user,
|
|
599
|
-
cpuSystemMicros: cpu?.system,
|
|
600
|
-
heapUsedBytes: memory?.heapUsed,
|
|
601
|
-
heapTotalBytes: memory?.heapTotal,
|
|
602
|
-
rssBytes: memory?.rss,
|
|
603
|
-
externalBytes: memory?.external,
|
|
604
|
-
arrayBuffersBytes: memory?.arrayBuffers,
|
|
605
|
-
eventLoopUtilization: eventLoop?.utilization,
|
|
606
|
-
scope: memory || cpu || eventLoop ? "process" : "runtime"
|
|
607
|
-
};
|
|
608
|
-
}
|
|
609
|
-
function deltaResources(start, end) {
|
|
610
|
-
const delta = (a, b) => a === void 0 || b === void 0 ? void 0 : b - a;
|
|
611
|
-
return {
|
|
612
|
-
cpuUserMicros: delta(start.cpuUserMicros, end.cpuUserMicros),
|
|
613
|
-
cpuSystemMicros: delta(start.cpuSystemMicros, end.cpuSystemMicros),
|
|
614
|
-
heapUsedBytes: delta(start.heapUsedBytes, end.heapUsedBytes),
|
|
615
|
-
heapTotalBytes: delta(start.heapTotalBytes, end.heapTotalBytes),
|
|
616
|
-
rssBytes: delta(start.rssBytes, end.rssBytes),
|
|
617
|
-
externalBytes: delta(start.externalBytes, end.externalBytes),
|
|
618
|
-
arrayBuffersBytes: delta(start.arrayBuffersBytes, end.arrayBuffersBytes),
|
|
619
|
-
eventLoopUtilization: delta(start.eventLoopUtilization, end.eventLoopUtilization),
|
|
620
|
-
scope: start.scope
|
|
621
|
-
};
|
|
622
|
-
}
|
|
623
|
-
var id = (prefix) => `${prefix}_${randomUUID()}`;
|
|
624
|
-
function percentiles(values) {
|
|
625
|
-
if (!values.length) return { min: 0, mean: 0, p50: 0, p90: 0, p95: 0, p99: 0, max: 0 };
|
|
626
|
-
const sorted = [...values].sort((a, b) => a - b);
|
|
627
|
-
const pick2 = (p) => sorted[Math.min(sorted.length - 1, Math.floor((sorted.length - 1) * p))];
|
|
628
|
-
return {
|
|
629
|
-
min: sorted[0],
|
|
630
|
-
mean: sorted.reduce((sum2, value) => sum2 + value, 0) / sorted.length,
|
|
631
|
-
p50: pick2(0.5),
|
|
632
|
-
p90: pick2(0.9),
|
|
633
|
-
p95: pick2(0.95),
|
|
634
|
-
p99: pick2(0.99),
|
|
635
|
-
max: sorted[sorted.length - 1]
|
|
636
|
-
};
|
|
637
|
-
}
|
|
638
|
-
var TelemetryController = class {
|
|
639
|
-
constructor(serviceId, options = {}) {
|
|
640
|
-
this.serviceId = serviceId;
|
|
641
|
-
this.mode = options.mode ?? "off";
|
|
642
|
-
this.maxSamples = Math.max(1, options.maxSamples ?? 2048);
|
|
643
|
-
this.maxRecentInvocations = Math.max(1, options.maxRecentInvocations ?? 100);
|
|
644
|
-
}
|
|
645
|
-
serviceId;
|
|
646
|
-
mode;
|
|
647
|
-
maxSamples;
|
|
648
|
-
maxRecentInvocations;
|
|
649
|
-
samples = [];
|
|
650
|
-
active = /* @__PURE__ */ new Map();
|
|
651
|
-
totalInvocationCount = 0;
|
|
652
|
-
totalSuccessCount = 0;
|
|
653
|
-
totalErrorCount = 0;
|
|
654
|
-
lastInvocationAt;
|
|
655
|
-
enable(mode = "standard") {
|
|
656
|
-
this.mode = mode;
|
|
657
|
-
}
|
|
658
|
-
disable() {
|
|
659
|
-
this.mode = "off";
|
|
660
|
-
this.active.clear();
|
|
661
|
-
}
|
|
662
|
-
setMode(mode) {
|
|
663
|
-
this.mode = mode;
|
|
664
|
-
if (mode === "off") this.active.clear();
|
|
665
|
-
}
|
|
666
|
-
getMode() {
|
|
667
|
-
return this.mode;
|
|
668
|
-
}
|
|
669
|
-
status() {
|
|
670
|
-
return {
|
|
671
|
-
enabled: this.mode !== "off",
|
|
672
|
-
mode: this.mode,
|
|
673
|
-
serviceId: this.serviceId,
|
|
674
|
-
invocationCount: this.totalInvocationCount,
|
|
675
|
-
activeInvocations: this.active.size,
|
|
676
|
-
lastInvocationAt: this.lastInvocationAt
|
|
677
|
-
};
|
|
678
|
-
}
|
|
679
|
-
begin(target, kind, correlationId, parentSpanId) {
|
|
680
|
-
if (this.mode === "off") {
|
|
681
|
-
return {
|
|
682
|
-
invocationId: "",
|
|
683
|
-
traceId: "",
|
|
684
|
-
spanId: "",
|
|
685
|
-
parentSpanId,
|
|
686
|
-
end: () => void 0
|
|
687
|
-
};
|
|
688
|
-
}
|
|
689
|
-
const invocationId = id("inv");
|
|
690
|
-
const spanId = id("span");
|
|
691
|
-
const traceId = parentSpanId ? this.findTraceId(parentSpanId) ?? id("trace") : id("trace");
|
|
692
|
-
const active = {
|
|
693
|
-
invocationId,
|
|
694
|
-
traceId,
|
|
695
|
-
spanId,
|
|
696
|
-
parentSpanId,
|
|
697
|
-
serviceId: this.serviceId,
|
|
698
|
-
target,
|
|
699
|
-
kind,
|
|
700
|
-
correlationId,
|
|
701
|
-
startedAt: telemetryNow(),
|
|
702
|
-
resourcesStart: this.mode === "standard" ? void 0 : sampleResources()
|
|
703
|
-
};
|
|
704
|
-
this.active.set(invocationId, active);
|
|
705
|
-
return {
|
|
706
|
-
invocationId,
|
|
707
|
-
traceId,
|
|
708
|
-
spanId,
|
|
709
|
-
parentSpanId,
|
|
710
|
-
end: (error) => this.finish(active, error)
|
|
711
|
-
};
|
|
712
|
-
}
|
|
713
|
-
reset() {
|
|
714
|
-
this.samples.length = 0;
|
|
715
|
-
this.active.clear();
|
|
716
|
-
this.totalInvocationCount = 0;
|
|
717
|
-
this.totalSuccessCount = 0;
|
|
718
|
-
this.totalErrorCount = 0;
|
|
719
|
-
this.lastInvocationAt = void 0;
|
|
720
|
-
}
|
|
721
|
-
snapshot() {
|
|
722
|
-
const invocations = this.samples.slice();
|
|
723
|
-
const durations = invocations.map((item) => item.durationMs);
|
|
724
|
-
const targetMap = /* @__PURE__ */ new Map();
|
|
725
|
-
for (const invocation of invocations) {
|
|
726
|
-
const key = `${invocation.kind}:${invocation.target}`;
|
|
727
|
-
const group = targetMap.get(key) ?? [];
|
|
728
|
-
group.push(invocation);
|
|
729
|
-
targetMap.set(key, group);
|
|
730
|
-
}
|
|
731
|
-
const targets = [...targetMap.values()].map((group) => ({
|
|
732
|
-
target: group[0].target,
|
|
733
|
-
kind: group[0].kind,
|
|
734
|
-
count: group.length,
|
|
735
|
-
successCount: group.filter((item) => item.status === "completed").length,
|
|
736
|
-
errorCount: group.filter((item) => item.status === "failed").length,
|
|
737
|
-
durationMs: percentiles(group.map((item) => item.durationMs)),
|
|
738
|
-
lastInvocationAt: group[group.length - 1]?.completedAt
|
|
739
|
-
}));
|
|
740
|
-
return {
|
|
741
|
-
serviceId: this.serviceId,
|
|
742
|
-
mode: this.mode,
|
|
743
|
-
capturedAt: Date.now(),
|
|
744
|
-
status: this.status(),
|
|
745
|
-
totals: {
|
|
746
|
-
invocationCount: this.totalInvocationCount,
|
|
747
|
-
successCount: this.totalSuccessCount,
|
|
748
|
-
errorCount: this.totalErrorCount,
|
|
749
|
-
durationMs: percentiles(durations)
|
|
750
|
-
},
|
|
751
|
-
targets,
|
|
752
|
-
activeInvocations: this.active.size,
|
|
753
|
-
recentInvocations: invocations.slice(-this.maxRecentInvocations)
|
|
754
|
-
};
|
|
755
|
-
}
|
|
756
|
-
functionality(name) {
|
|
757
|
-
return this.snapshot().targets.find((target) => target.kind === "functionality" && target.target === name);
|
|
758
|
-
}
|
|
759
|
-
functionalities() {
|
|
760
|
-
return this.snapshot().targets.filter((target) => target.kind === "functionality");
|
|
761
|
-
}
|
|
762
|
-
findTraceId(parentSpanId) {
|
|
763
|
-
for (let index = this.samples.length - 1; index >= 0; index -= 1) {
|
|
764
|
-
if (this.samples[index].spanId === parentSpanId) return this.samples[index].traceId;
|
|
765
|
-
}
|
|
766
|
-
for (const active of this.active.values()) {
|
|
767
|
-
if (active.spanId === parentSpanId) return active.traceId;
|
|
768
|
-
}
|
|
769
|
-
return void 0;
|
|
770
|
-
}
|
|
771
|
-
finish(active, error) {
|
|
772
|
-
if (!this.active.delete(active.invocationId)) return;
|
|
773
|
-
const completedAt = telemetryNow();
|
|
774
|
-
const resourcesEnd = this.mode === "standard" ? void 0 : sampleResources();
|
|
775
|
-
const invocation = {
|
|
776
|
-
invocationId: active.invocationId,
|
|
777
|
-
traceId: active.traceId,
|
|
778
|
-
spanId: active.spanId,
|
|
779
|
-
parentSpanId: active.parentSpanId,
|
|
780
|
-
serviceId: active.serviceId,
|
|
781
|
-
target: active.target,
|
|
782
|
-
kind: active.kind,
|
|
783
|
-
correlationId: active.correlationId,
|
|
784
|
-
startedAt: active.startedAt,
|
|
785
|
-
completedAt,
|
|
786
|
-
durationMs: Math.max(0, completedAt - active.startedAt),
|
|
787
|
-
status: error === void 0 ? "completed" : "failed",
|
|
788
|
-
error: error === void 0 ? void 0 : {
|
|
789
|
-
name: error instanceof Error ? error.name : "Error",
|
|
790
|
-
message: error instanceof Error ? error.message : String(error)
|
|
791
|
-
},
|
|
792
|
-
resources: active.resourcesStart && resourcesEnd ? { start: active.resourcesStart, end: resourcesEnd, delta: deltaResources(active.resourcesStart, resourcesEnd) } : void 0
|
|
793
|
-
};
|
|
794
|
-
this.samples.push(invocation);
|
|
795
|
-
this.totalInvocationCount += 1;
|
|
796
|
-
if (invocation.status === "completed") this.totalSuccessCount += 1;
|
|
797
|
-
else this.totalErrorCount += 1;
|
|
798
|
-
if (this.samples.length > this.maxSamples) this.samples.splice(0, this.samples.length - this.maxSamples);
|
|
799
|
-
this.lastInvocationAt = Date.now();
|
|
800
|
-
}
|
|
801
|
-
};
|
|
802
|
-
var ServiceInstance = class {
|
|
803
|
-
constructor(definition) {
|
|
804
|
-
this.definition = definition;
|
|
805
|
-
this.id = definition.id;
|
|
806
|
-
this.name = definition.name;
|
|
807
|
-
this.version = definition.version;
|
|
808
|
-
this.telemetry = new TelemetryController(this.id);
|
|
809
|
-
this.lifecycle = new LifecycleManager();
|
|
810
|
-
if (definition.state) {
|
|
811
|
-
this.stateStore = new ServiceStateStore(definition.state.initial);
|
|
812
|
-
}
|
|
813
|
-
}
|
|
814
|
-
definition;
|
|
815
|
-
id;
|
|
816
|
-
name;
|
|
817
|
-
version;
|
|
818
|
-
telemetry;
|
|
819
|
-
stateStore;
|
|
820
|
-
lifecycle;
|
|
821
|
-
initialized = false;
|
|
822
|
-
disposed = false;
|
|
823
|
-
getDefinition() {
|
|
824
|
-
return this.definition;
|
|
825
|
-
}
|
|
826
|
-
getStatus() {
|
|
827
|
-
return this.lifecycle.getStatus();
|
|
828
|
-
}
|
|
829
|
-
async start() {
|
|
830
|
-
if (this.disposed) throw new Error("[Service:" + this.name + "] Cannot start a disposed service.");
|
|
831
|
-
const current = this.lifecycle.getStatus();
|
|
832
|
-
if (current === "running") return;
|
|
833
|
-
if (current === "initializing" || current === "starting" || current === "stopping") {
|
|
834
|
-
throw new Error("[Service:" + this.name + "] Cannot start while status is '" + current + "'.");
|
|
835
|
-
}
|
|
836
|
-
if (!this.initialized) {
|
|
837
|
-
this.lifecycle.transitionTo("initializing");
|
|
838
|
-
try {
|
|
839
|
-
await this.definition.lifecycle?.onInit?.();
|
|
840
|
-
this.initialized = true;
|
|
841
|
-
this.lifecycle.transitionTo("ready");
|
|
842
|
-
} catch (error) {
|
|
843
|
-
this.lifecycle.transitionTo("uninitialized");
|
|
844
|
-
throw error;
|
|
845
|
-
}
|
|
846
|
-
}
|
|
847
|
-
this.lifecycle.transitionTo("starting");
|
|
848
|
-
try {
|
|
849
|
-
await this.definition.lifecycle?.onStart?.();
|
|
850
|
-
this.lifecycle.transitionTo("running");
|
|
851
|
-
} catch (error) {
|
|
852
|
-
this.lifecycle.transitionTo("ready");
|
|
853
|
-
throw error;
|
|
854
|
-
}
|
|
855
|
-
}
|
|
856
|
-
async stop() {
|
|
857
|
-
const current = this.lifecycle.getStatus();
|
|
858
|
-
if (current === "stopped") return;
|
|
859
|
-
if (current !== "running") {
|
|
860
|
-
throw new Error("[Service:" + this.name + "] Cannot stop while status is '" + current + "'.");
|
|
861
|
-
}
|
|
862
|
-
this.lifecycle.transitionTo("stopping");
|
|
863
|
-
try {
|
|
864
|
-
await this.definition.lifecycle?.onStop?.();
|
|
865
|
-
this.lifecycle.transitionTo("stopped");
|
|
866
|
-
} catch (error) {
|
|
867
|
-
this.lifecycle.transitionTo("running");
|
|
868
|
-
throw error;
|
|
869
|
-
}
|
|
870
|
-
}
|
|
871
|
-
async dispose() {
|
|
872
|
-
if (this.disposed) return;
|
|
873
|
-
if (this.lifecycle.getStatus() === "running") await this.stop();
|
|
874
|
-
await this.definition.lifecycle?.onDispose?.();
|
|
875
|
-
this.disposed = true;
|
|
876
|
-
}
|
|
877
|
-
async call(op, input, ctx = {}) {
|
|
878
|
-
this.lifecycle.assertRunning(this.name);
|
|
879
|
-
const operation = this.definition.operations[op];
|
|
880
|
-
if (!operation) {
|
|
881
|
-
throw new Error("[Service:" + this.name + "] Operation '" + op + "' not found.");
|
|
882
|
-
}
|
|
883
|
-
if (ctx.metadata?.__krnlTelemetryInternal === true) {
|
|
884
|
-
return await operation.handler(input, ctx);
|
|
885
|
-
}
|
|
886
|
-
const parentSpanId = typeof ctx.metadata?.__krnlTelemetryParentSpanId === "string" ? ctx.metadata.__krnlTelemetryParentSpanId : void 0;
|
|
887
|
-
const handle = this.telemetry.begin(op, "service", ctx.correlationId, parentSpanId);
|
|
888
|
-
try {
|
|
889
|
-
const output = await operation.handler(input, ctx);
|
|
890
|
-
handle.end();
|
|
891
|
-
return output;
|
|
892
|
-
} catch (error) {
|
|
893
|
-
handle.end(error);
|
|
894
|
-
throw error;
|
|
895
|
-
}
|
|
896
|
-
}
|
|
897
|
-
getState() {
|
|
898
|
-
return this.stateStore?.getState() ?? Object.freeze({});
|
|
899
|
-
}
|
|
900
|
-
setState(mutation) {
|
|
901
|
-
if (!this.stateStore) {
|
|
902
|
-
this.stateStore = new ServiceStateStore({ ...mutation });
|
|
903
|
-
return;
|
|
904
|
-
}
|
|
905
|
-
this.stateStore.setState(mutation);
|
|
906
|
-
}
|
|
907
|
-
};
|
|
908
|
-
function assertRecord(value, field) {
|
|
909
|
-
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
910
|
-
throw new Error("[KrnlTS] Invalid service definition: '" + field + "' must be an object.");
|
|
911
|
-
}
|
|
912
|
-
}
|
|
913
|
-
function assertNonEmptyString(value, field) {
|
|
914
|
-
if (typeof value !== "string" || value.trim().length === 0) {
|
|
915
|
-
throw new Error("[KrnlTS] Invalid service definition: '" + field + "' must be a non-empty string.");
|
|
916
|
-
}
|
|
917
|
-
}
|
|
918
|
-
function validateServiceDefinition(definition) {
|
|
919
|
-
if (!definition || typeof definition !== "object") {
|
|
920
|
-
throw new Error("[KrnlTS] Invalid service definition: expected an object.");
|
|
921
|
-
}
|
|
922
|
-
assertNonEmptyString(definition.id, "id");
|
|
923
|
-
assertNonEmptyString(definition.name, "name");
|
|
924
|
-
assertNonEmptyString(definition.version, "version");
|
|
925
|
-
if (!definition.operations || typeof definition.operations !== "object") {
|
|
926
|
-
throw new Error("[Service:" + definition.name + "] Invalid operations: expected an object.");
|
|
927
|
-
}
|
|
928
|
-
for (const [key, operation] of Object.entries(definition.operations)) {
|
|
929
|
-
if (!operation || typeof operation !== "object") {
|
|
930
|
-
throw new Error("[Service:" + definition.name + "] Invalid operation '" + key + "'.");
|
|
931
|
-
}
|
|
932
|
-
assertNonEmptyString(operation.id, "operations." + key + ".id");
|
|
933
|
-
assertNonEmptyString(operation.name, "operations." + key + ".name");
|
|
934
|
-
if (operation.inputSchema !== void 0) assertRecord(operation.inputSchema, "operations." + key + ".inputSchema");
|
|
935
|
-
if (operation.outputSchema !== void 0) assertRecord(operation.outputSchema, "operations." + key + ".outputSchema");
|
|
936
|
-
if (typeof operation.handler !== "function") {
|
|
937
|
-
throw new Error("[Service:" + definition.name + "] Operation '" + key + "' must define a handler.");
|
|
938
|
-
}
|
|
939
|
-
}
|
|
940
|
-
for (const [key, schema] of Object.entries(definition.inputs ?? {})) assertRecord(schema, "inputs." + key);
|
|
941
|
-
for (const [key, schema] of Object.entries(definition.outputs ?? {})) assertRecord(schema, "outputs." + key);
|
|
942
|
-
if (definition.state?.schema !== void 0) assertRecord(definition.state.schema, "state.schema");
|
|
943
|
-
for (const capability of definition.capabilities ?? []) {
|
|
944
|
-
assertNonEmptyString(capability.id, "capability.id");
|
|
945
|
-
assertNonEmptyString(capability.name, "capability.name");
|
|
946
|
-
if (!Array.isArray(capability.protocols)) {
|
|
947
|
-
throw new Error("[Service:" + definition.name + "] Capability '" + capability.name + "' protocols must be an array.");
|
|
948
|
-
}
|
|
949
|
-
}
|
|
950
|
-
for (const dependency of definition.dependencies ?? []) {
|
|
951
|
-
assertNonEmptyString(dependency.serviceId, "dependency.serviceId");
|
|
952
|
-
}
|
|
953
|
-
return definition;
|
|
954
|
-
}
|
|
955
|
-
function createServiceDefinition(definition) {
|
|
956
|
-
return validateServiceDefinition(definition);
|
|
957
|
-
}
|
|
958
|
-
function createService(definition) {
|
|
959
|
-
return new ServiceInstance(validateServiceDefinition(definition));
|
|
960
|
-
}
|
|
961
|
-
var asyncHooks = globalThis.process?.getBuiltinModule?.("node:async_hooks");
|
|
962
|
-
|
|
963
|
-
// src/Viewport.ts
|
|
964
|
-
function screenToCanvas(clientX, clientY, viewport) {
|
|
965
|
-
return {
|
|
966
|
-
x: (clientX - viewport.panX) / viewport.zoom,
|
|
967
|
-
y: (clientY - viewport.panY) / viewport.zoom
|
|
968
|
-
};
|
|
969
|
-
}
|
|
970
|
-
function canvasToScreen(canvasX, canvasY, viewport) {
|
|
971
|
-
return {
|
|
972
|
-
x: canvasX * viewport.zoom + viewport.panX,
|
|
973
|
-
y: canvasY * viewport.zoom + viewport.panY
|
|
974
|
-
};
|
|
975
|
-
}
|
|
976
|
-
function zoomAtPoint(mouseX, mouseY, delta, viewport, config = {}) {
|
|
977
|
-
const currentZoom = viewport.zoom;
|
|
978
|
-
let newZoom = currentZoom + delta;
|
|
979
|
-
newZoom = clampZoom(newZoom, config);
|
|
980
|
-
const graphX = (mouseX - viewport.panX) / currentZoom;
|
|
981
|
-
const graphY = (mouseY - viewport.panY) / currentZoom;
|
|
982
|
-
const panX = mouseX - graphX * newZoom;
|
|
983
|
-
const panY = mouseY - graphY * newZoom;
|
|
984
|
-
return { zoom: newZoom, panX, panY };
|
|
985
|
-
}
|
|
986
|
-
function clampZoom(zoom, config = {}) {
|
|
987
|
-
const minZoom = config.minZoom ?? 0.25;
|
|
988
|
-
const maxZoom = config.maxZoom ?? 2.5;
|
|
989
|
-
return Math.max(minZoom, Math.min(maxZoom, zoom));
|
|
990
|
-
}
|
|
991
|
-
function fitToView(nodes, containerWidth, containerHeight, padding = 50) {
|
|
992
|
-
if (nodes.length === 0) {
|
|
993
|
-
return { panX: containerWidth / 2, panY: containerHeight / 2, zoom: 1 };
|
|
994
|
-
}
|
|
995
|
-
let minX = Infinity, minY = Infinity;
|
|
996
|
-
let maxX = -Infinity, maxY = -Infinity;
|
|
997
|
-
for (const node of nodes) {
|
|
998
|
-
minX = Math.min(minX, node.position.x);
|
|
999
|
-
minY = Math.min(minY, node.position.y);
|
|
1000
|
-
const width = node.width ?? 150;
|
|
1001
|
-
const height = node.height ?? 100;
|
|
1002
|
-
maxX = Math.max(maxX, node.position.x + width);
|
|
1003
|
-
maxY = Math.max(maxY, node.position.y + height);
|
|
1004
|
-
}
|
|
1005
|
-
const graphWidth = maxX - minX;
|
|
1006
|
-
const graphHeight = maxY - minY;
|
|
1007
|
-
const zoomX = (containerWidth - padding * 2) / graphWidth;
|
|
1008
|
-
const zoomY = (containerHeight - padding * 2) / graphHeight;
|
|
1009
|
-
const targetZoom = Math.min(zoomX, zoomY, 1);
|
|
1010
|
-
const panX = (containerWidth - graphWidth * targetZoom) / 2 - minX * targetZoom;
|
|
1011
|
-
const panY = (containerHeight - graphHeight * targetZoom) / 2 - minY * targetZoom;
|
|
1012
|
-
return { zoom: targetZoom, panX, panY };
|
|
1013
|
-
}
|
|
1014
|
-
function isNodeInCenterDeadZone(node, viewport, containerWidth, containerHeight, deadZoneRatio = 0.35) {
|
|
1015
|
-
const centerX = containerWidth / 2;
|
|
1016
|
-
const centerY = containerHeight / 2;
|
|
1017
|
-
const nodeW = node.width ?? 130;
|
|
1018
|
-
const nodeH = node.height ?? 130;
|
|
1019
|
-
const nodeCenterX = node.position.x + nodeW / 2;
|
|
1020
|
-
const nodeCenterY = node.position.y + nodeH / 2;
|
|
1021
|
-
const screenNodeX = nodeCenterX * viewport.zoom + viewport.panX;
|
|
1022
|
-
const screenNodeY = nodeCenterY * viewport.zoom + viewport.panY;
|
|
1023
|
-
const dist = Math.hypot(screenNodeX - centerX, screenNodeY - centerY);
|
|
1024
|
-
const deadZoneRadius = Math.min(containerWidth, containerHeight) * deadZoneRatio;
|
|
1025
|
-
return dist <= deadZoneRadius;
|
|
1026
|
-
}
|
|
1027
|
-
function getCenterPanForNode(node, viewport, containerWidth, containerHeight) {
|
|
1028
|
-
const centerX = containerWidth / 2;
|
|
1029
|
-
const centerY = containerHeight / 2;
|
|
1030
|
-
const nodeW = node.width ?? 130;
|
|
1031
|
-
const nodeH = node.height ?? 130;
|
|
1032
|
-
const nodeCenterX = node.position.x + nodeW / 2;
|
|
1033
|
-
const nodeCenterY = node.position.y + nodeH / 2;
|
|
1034
|
-
return {
|
|
1035
|
-
panX: Math.round(centerX - nodeCenterX * viewport.zoom),
|
|
1036
|
-
panY: Math.round(centerY - nodeCenterY * viewport.zoom)
|
|
1037
|
-
};
|
|
1038
|
-
}
|
|
1039
|
-
|
|
1040
|
-
// src/BoxSelection.ts
|
|
1041
|
-
function getNodesInSelection(startX, startY, endX, endY, nodes, viewport) {
|
|
1042
|
-
const canvasStartX = (startX - viewport.panX) / viewport.zoom;
|
|
1043
|
-
const canvasStartY = (startY - viewport.panY) / viewport.zoom;
|
|
1044
|
-
const canvasEndX = (endX - viewport.panX) / viewport.zoom;
|
|
1045
|
-
const canvasEndY = (endY - viewport.panY) / viewport.zoom;
|
|
1046
|
-
const minX = Math.min(canvasStartX, canvasEndX);
|
|
1047
|
-
const maxX = Math.max(canvasStartX, canvasEndX);
|
|
1048
|
-
const minY = Math.min(canvasStartY, canvasEndY);
|
|
1049
|
-
const maxY = Math.max(canvasStartY, canvasEndY);
|
|
1050
|
-
return nodes.filter((node) => {
|
|
1051
|
-
const nodeWidth = node.width ?? 150;
|
|
1052
|
-
const nodeHeight = node.height ?? 100;
|
|
1053
|
-
const intersectX = node.position.x < maxX && node.position.x + nodeWidth > minX;
|
|
1054
|
-
const intersectY = node.position.y < maxY && node.position.y + nodeHeight > minY;
|
|
1055
|
-
return intersectX && intersectY;
|
|
1056
|
-
}).map((node) => node.id);
|
|
1057
|
-
}
|
|
1058
|
-
|
|
1059
|
-
// src/engine/AudioConcepts.ts
|
|
1060
|
-
function getDivisionBeatLength(division) {
|
|
1061
|
-
switch (division) {
|
|
1062
|
-
case "none":
|
|
1063
|
-
return 0;
|
|
1064
|
-
case "1/16":
|
|
1065
|
-
return 0.25;
|
|
1066
|
-
case "1/8":
|
|
1067
|
-
return 0.5;
|
|
1068
|
-
case "1/4":
|
|
1069
|
-
return 1;
|
|
1070
|
-
case "1/2":
|
|
1071
|
-
return 2;
|
|
1072
|
-
case "1_bar":
|
|
1073
|
-
return 4;
|
|
1074
|
-
case "2_bars":
|
|
1075
|
-
return 8;
|
|
1076
|
-
case "4_bars":
|
|
1077
|
-
return 16;
|
|
1078
|
-
default:
|
|
1079
|
-
return 4;
|
|
1080
|
-
}
|
|
1081
|
-
}
|
|
1082
|
-
function calculateNextQuantizeBeat(currentBeat, division, beatsPerBar = 4) {
|
|
1083
|
-
const divBeats = getDivisionBeatLength(division);
|
|
1084
|
-
if (divBeats <= 0) {
|
|
1085
|
-
return currentBeat;
|
|
1086
|
-
}
|
|
1087
|
-
const epsilon = 1e-3;
|
|
1088
|
-
const nextDivisionIndex = Math.floor((currentBeat + epsilon) / divBeats) + 1;
|
|
1089
|
-
return nextDivisionIndex * divBeats;
|
|
1090
|
-
}
|
|
1091
|
-
function formatBeatToBarBeat(beat, beatsPerBar = 4) {
|
|
1092
|
-
const safeBeat = Math.max(0, beat);
|
|
1093
|
-
const bar = Math.floor(safeBeat / beatsPerBar) + 1;
|
|
1094
|
-
const beatInBar = safeBeat % beatsPerBar + 1;
|
|
1095
|
-
return `Bar ${bar}, Beat ${beatInBar.toFixed(1)}`;
|
|
1096
|
-
}
|
|
1097
|
-
function formatQuantizeDivisionLabel(division) {
|
|
1098
|
-
switch (division) {
|
|
1099
|
-
case "none":
|
|
1100
|
-
return "Off (Instant)";
|
|
1101
|
-
case "1/16":
|
|
1102
|
-
return "1/16 (16th Note)";
|
|
1103
|
-
case "1/8":
|
|
1104
|
-
return "1/8 (8th Note)";
|
|
1105
|
-
case "1/4":
|
|
1106
|
-
return "1/4 (1 Beat)";
|
|
1107
|
-
case "1/2":
|
|
1108
|
-
return "1/2 (2 Beats)";
|
|
1109
|
-
case "1_bar":
|
|
1110
|
-
return "1 Bar (Downbeat)";
|
|
1111
|
-
case "2_bars":
|
|
1112
|
-
return "2 Bars";
|
|
1113
|
-
case "4_bars":
|
|
1114
|
-
return "4 Bars";
|
|
1115
|
-
default:
|
|
1116
|
-
return "1 Bar";
|
|
1117
|
-
}
|
|
1118
|
-
}
|
|
1119
|
-
function linearToDb(gain) {
|
|
1120
|
-
if (gain <= 1e-4) return -96;
|
|
1121
|
-
return 20 * Math.log10(gain);
|
|
1122
|
-
}
|
|
1123
|
-
function dbToLinear(db) {
|
|
1124
|
-
return Math.pow(10, db / 20);
|
|
1125
|
-
}
|
|
1126
|
-
function midiToFrequency(note) {
|
|
1127
|
-
return 440 * Math.pow(2, (note - 69) / 12);
|
|
1128
|
-
}
|
|
1129
|
-
var AudioConcepts = {
|
|
1130
|
-
getDivisionBeatLength,
|
|
1131
|
-
calculateNextQuantizeBeat,
|
|
1132
|
-
formatBeatToBarBeat,
|
|
1133
|
-
formatQuantizeDivisionLabel,
|
|
1134
|
-
linearToDb,
|
|
1135
|
-
dbToLinear,
|
|
1136
|
-
midiToFrequency
|
|
1137
|
-
};
|
|
1138
|
-
|
|
1139
|
-
// src/engine/BufferConcepts.ts
|
|
1140
|
-
var BufferConcepts = {
|
|
1141
|
-
/**
|
|
1142
|
-
* Calculates current rolling cycle metrics, progress, and tolerance target cycle index.
|
|
1143
|
-
*/
|
|
1144
|
-
calculateCycleMetrics(currentBeat, bufferBars = 4, beatsPerBar = 4, tolBeforeBeats = 2, tolAfterBeats = 2) {
|
|
1145
|
-
const bufferBeats = bufferBars * beatsPerBar;
|
|
1146
|
-
const currentCycleIndex = Math.floor(currentBeat / bufferBeats);
|
|
1147
|
-
const beatInCurrentCycle = currentBeat % bufferBeats;
|
|
1148
|
-
const cycleProgress = Math.min(1, Math.max(0, beatInCurrentCycle / bufferBeats));
|
|
1149
|
-
const isInPostToleranceZone = beatInCurrentCycle <= tolAfterBeats && currentCycleIndex > 0;
|
|
1150
|
-
const isInPreToleranceZone = beatInCurrentCycle >= bufferBeats - tolBeforeBeats;
|
|
1151
|
-
let targetedCycleIndex = currentCycleIndex;
|
|
1152
|
-
if (isInPostToleranceZone) {
|
|
1153
|
-
targetedCycleIndex = currentCycleIndex - 1;
|
|
1154
|
-
}
|
|
1155
|
-
return {
|
|
1156
|
-
bufferBeats,
|
|
1157
|
-
bufferBars,
|
|
1158
|
-
currentCycleIndex,
|
|
1159
|
-
beatInCurrentCycle,
|
|
1160
|
-
cycleProgress,
|
|
1161
|
-
isInPostToleranceZone,
|
|
1162
|
-
isInPreToleranceZone,
|
|
1163
|
-
targetedCycleIndex
|
|
1164
|
-
};
|
|
1165
|
-
},
|
|
1166
|
-
/**
|
|
1167
|
-
* Derives cycle start and end beat boundaries for a given cycle index.
|
|
1168
|
-
*/
|
|
1169
|
-
getCycleBoundaries(cycleIndex, bufferBars = 4, beatsPerBar = 4) {
|
|
1170
|
-
const bufferBeats = bufferBars * beatsPerBar;
|
|
1171
|
-
const startBeat = cycleIndex * bufferBeats;
|
|
1172
|
-
const endBeat = startBeat + bufferBeats;
|
|
1173
|
-
return { startBeat, endBeat };
|
|
1174
|
-
}
|
|
1175
|
-
};
|
|
1176
|
-
|
|
1177
|
-
// src/engine/UIConcepts.ts
|
|
1178
|
-
var activePaletteResolver = () => ({
|
|
1179
|
-
id: "black_and_gold",
|
|
1180
|
-
name: "Black & Gold",
|
|
1181
|
-
backgroundPrimary: "#0a0a0d",
|
|
1182
|
-
accentPrimary: "#f59e0b"
|
|
1183
|
-
});
|
|
1184
|
-
function configureActivePaletteResolver(resolver) {
|
|
1185
|
-
activePaletteResolver = resolver;
|
|
1186
|
-
}
|
|
1187
|
-
function getActivePalette() {
|
|
1188
|
-
return activePaletteResolver();
|
|
1189
|
-
}
|
|
1190
|
-
function resolveTooltipDirection(preferred = "bottom", elementRect, topThreshold = 80) {
|
|
1191
|
-
if (elementRect && elementRect.top < topThreshold) {
|
|
1192
|
-
return "bottom";
|
|
1193
|
-
}
|
|
1194
|
-
return preferred;
|
|
1195
|
-
}
|
|
1196
|
-
function getTooltipPlacementClasses(direction) {
|
|
1197
|
-
switch (direction) {
|
|
1198
|
-
case "top":
|
|
1199
|
-
return "bottom-full mb-1.5 left-1/2 -translate-x-1/2";
|
|
1200
|
-
case "bottom":
|
|
1201
|
-
return "top-full mt-1.5 left-1/2 -translate-x-1/2";
|
|
1202
|
-
case "left":
|
|
1203
|
-
return "right-full mr-1.5 top-1/2 -translate-y-1/2";
|
|
1204
|
-
case "right":
|
|
1205
|
-
return "left-full ml-1.5 top-1/2 -translate-y-1/2";
|
|
1206
|
-
default:
|
|
1207
|
-
return "top-full mt-1.5 left-1/2 -translate-x-1/2";
|
|
1208
|
-
}
|
|
1209
|
-
}
|
|
1210
|
-
function parseBufferedNumber(raw, min, max, fallback) {
|
|
1211
|
-
const trimmed = raw.trim();
|
|
1212
|
-
if (trimmed === "") return fallback;
|
|
1213
|
-
const num = Number(trimmed);
|
|
1214
|
-
if (isNaN(num)) return fallback;
|
|
1215
|
-
return Math.max(min, Math.min(max, num));
|
|
1216
|
-
}
|
|
1217
|
-
var UIConcepts = {
|
|
1218
|
-
resolveTooltipDirection,
|
|
1219
|
-
getTooltipPlacementClasses,
|
|
1220
|
-
parseBufferedNumber,
|
|
1221
|
-
getActivePalette,
|
|
1222
|
-
glows: {
|
|
1223
|
-
amber: "shadow-[0_0_12px_rgba(245,158,11,0.35)]",
|
|
1224
|
-
sky: "shadow-[0_0_12px_rgba(14,165,233,0.35)]",
|
|
1225
|
-
emerald: "shadow-[0_0_12px_rgba(16,185,129,0.35)]",
|
|
1226
|
-
rose: "shadow-[0_0_12px_rgba(244,63,94,0.35)]",
|
|
1227
|
-
cyan: "shadow-[0_0_12px_rgba(6,182,212,0.35)]",
|
|
1228
|
-
purple: "shadow-[0_0_12px_rgba(168,85,247,0.35)]"
|
|
1229
|
-
}
|
|
1230
|
-
};
|
|
1231
|
-
|
|
1232
|
-
// src/engine/core/exposedSocketsManager.ts
|
|
1233
|
-
function getAllProjectSockets(nodes) {
|
|
1234
|
-
const allInputs = [];
|
|
1235
|
-
const allOutputs = [];
|
|
1236
|
-
const exposedList = [];
|
|
1237
|
-
nodes.forEach((node) => {
|
|
1238
|
-
const nodeExposedRefs = node.exposedSockets || [];
|
|
1239
|
-
const exposedSocketIdSet = new Set(nodeExposedRefs.map((r) => `${r.socketId}_${r.direction}`));
|
|
1240
|
-
const { inputs, outputs } = getNodeSockets(node);
|
|
1241
|
-
inputs.forEach((sock, idx) => {
|
|
1242
|
-
const isExposed = exposedSocketIdSet.has(`${sock.socketId}_input`);
|
|
1243
|
-
const ref = {
|
|
1244
|
-
id: `${node.id}_${sock.socketId}_in`,
|
|
1245
|
-
nodeId: node.id,
|
|
1246
|
-
nodeName: node.name || node.label || "Node",
|
|
1247
|
-
nodeType: node.type,
|
|
1248
|
-
socketId: sock.socketId,
|
|
1249
|
-
socketIndex: idx,
|
|
1250
|
-
label: sock.label || sock.socketId,
|
|
1251
|
-
direction: "input",
|
|
1252
|
-
signalType: sock.signalType || "trigger",
|
|
1253
|
-
medium: sock.medium,
|
|
1254
|
-
dataType: sock.dataType,
|
|
1255
|
-
isExposed
|
|
1256
|
-
};
|
|
1257
|
-
allInputs.push(ref);
|
|
1258
|
-
if (isExposed) exposedList.push(ref);
|
|
1259
|
-
});
|
|
1260
|
-
outputs.forEach((sock, idx) => {
|
|
1261
|
-
const isExposed = exposedSocketIdSet.has(`${sock.socketId}_output`);
|
|
1262
|
-
const ref = {
|
|
1263
|
-
id: `${node.id}_${sock.socketId}_out`,
|
|
1264
|
-
nodeId: node.id,
|
|
1265
|
-
nodeName: node.name || node.label || "Node",
|
|
1266
|
-
nodeType: node.type,
|
|
1267
|
-
socketId: sock.socketId,
|
|
1268
|
-
socketIndex: idx,
|
|
1269
|
-
label: sock.label || sock.socketId,
|
|
1270
|
-
direction: "output",
|
|
1271
|
-
signalType: sock.signalType || "trigger",
|
|
1272
|
-
medium: sock.medium,
|
|
1273
|
-
dataType: sock.dataType,
|
|
1274
|
-
isExposed
|
|
1275
|
-
};
|
|
1276
|
-
allOutputs.push(ref);
|
|
1277
|
-
if (isExposed) exposedList.push(ref);
|
|
1278
|
-
});
|
|
1279
|
-
});
|
|
1280
|
-
return {
|
|
1281
|
-
inputs: allInputs,
|
|
1282
|
-
outputs: allOutputs,
|
|
1283
|
-
exposedList
|
|
1284
|
-
};
|
|
1285
|
-
}
|
|
1286
|
-
function toggleNodeSocketExposure(nodes, nodeId, socketId, direction) {
|
|
1287
|
-
return nodes.map((node) => {
|
|
1288
|
-
if (node.id !== nodeId) return node;
|
|
1289
|
-
const currentExposed = node.exposedSockets || [];
|
|
1290
|
-
const existsIndex = currentExposed.findIndex(
|
|
1291
|
-
(r) => r.socketId === socketId && r.direction === direction
|
|
1292
|
-
);
|
|
1293
|
-
let updatedExposed;
|
|
1294
|
-
if (existsIndex >= 0) {
|
|
1295
|
-
updatedExposed = currentExposed.filter((_, idx) => idx !== existsIndex);
|
|
1296
|
-
} else {
|
|
1297
|
-
const { inputs, outputs } = getNodeSockets(node);
|
|
1298
|
-
const pool = direction === "input" ? inputs : outputs;
|
|
1299
|
-
const sockDef = pool.find((s) => s.socketId === socketId) || pool[0];
|
|
1300
|
-
const newRef = {
|
|
1301
|
-
id: `${node.id}_${socketId}_${direction}`,
|
|
1302
|
-
nodeId: node.id,
|
|
1303
|
-
nodeName: node.name || node.label || "Node",
|
|
1304
|
-
nodeType: node.type,
|
|
1305
|
-
socketId,
|
|
1306
|
-
socketIndex: sockDef?.socketIndex ?? 0,
|
|
1307
|
-
label: sockDef?.label || socketId,
|
|
1308
|
-
direction,
|
|
1309
|
-
signalType: sockDef?.signalType || "trigger",
|
|
1310
|
-
medium: sockDef?.medium,
|
|
1311
|
-
dataType: sockDef?.dataType,
|
|
1312
|
-
isExposed: true
|
|
1313
|
-
};
|
|
1314
|
-
updatedExposed = [...currentExposed, newRef];
|
|
1315
|
-
}
|
|
1316
|
-
return {
|
|
1317
|
-
...node,
|
|
1318
|
-
exposedSockets: updatedExposed
|
|
1319
|
-
};
|
|
1320
|
-
});
|
|
1321
|
-
}
|
|
1322
|
-
|
|
1323
|
-
// src/engine/core/subgraphIoTransform.ts
|
|
1324
|
-
function convertPhysicalInputToStreamHandle(channel, index) {
|
|
1325
|
-
let medium = "audio_stereo";
|
|
1326
|
-
let signalType = "audio_stereo";
|
|
1327
|
-
if (channel.type === "trigger" || channel.signalType === "trigger" || channel.signalType === "trigger_stream") {
|
|
1328
|
-
medium = "trigger";
|
|
1329
|
-
signalType = "trigger_stream";
|
|
1330
|
-
} else if (channel.type === "audio") {
|
|
1331
|
-
const isMono = channel.signalType === "audio_mono" || channel.audioFormat === "mono";
|
|
1332
|
-
medium = isMono ? "audio_mono" : "audio_stereo";
|
|
1333
|
-
signalType = isMono ? "audio_mono" : "audio_stereo";
|
|
1334
|
-
} else if (channel.type === "midi") {
|
|
1335
|
-
medium = "midi";
|
|
1336
|
-
signalType = "midi_stream";
|
|
1337
|
-
} else if (channel.type === "osc" || channel.signalType === "curve" || channel.signalType === "curve_stream") {
|
|
1338
|
-
medium = "curve";
|
|
1339
|
-
signalType = "curve_stream";
|
|
1340
|
-
} else {
|
|
1341
|
-
medium = "data";
|
|
1342
|
-
signalType = channel.signalType || "data";
|
|
1343
|
-
}
|
|
1344
|
-
const formatLabel = channel.type === "audio" ? medium === "audio_mono" ? "Mono" : "Stereo" : "";
|
|
1345
|
-
const typeLabel = channel.type === "audio" ? `Audio ${formatLabel}`.trim() : channel.type.toUpperCase();
|
|
1346
|
-
return {
|
|
1347
|
-
id: `sub-in-${channel.id || channel.sourceId || index}`,
|
|
1348
|
-
name: channel.name || `${typeLabel} Stream In`,
|
|
1349
|
-
direction: "input",
|
|
1350
|
-
polarity: "input",
|
|
1351
|
-
type: channel.type,
|
|
1352
|
-
signalType,
|
|
1353
|
-
medium,
|
|
1354
|
-
variant: "stream",
|
|
1355
|
-
// Enforced STREAM variant rule
|
|
1356
|
-
dataType: "stream",
|
|
1357
|
-
audioFormat: channel.audioFormat || (medium === "audio_mono" ? "mono" : "stereo"),
|
|
1358
|
-
color: channel.color || (channel.type === "audio" ? "#38bdf8" : channel.type === "midi" ? "#ec4899" : "#eab308"),
|
|
1359
|
-
sourceChannelId: channel.id,
|
|
1360
|
-
socketIndex: index
|
|
1361
|
-
};
|
|
1362
|
-
}
|
|
1363
|
-
function convertPhysicalOutputToStreamHandle(channel, index) {
|
|
1364
|
-
let medium = "audio_stereo";
|
|
1365
|
-
let signalType = "audio_stereo";
|
|
1366
|
-
if (channel.type === "trigger" || channel.signalType === "trigger" || channel.signalType === "trigger_stream") {
|
|
1367
|
-
medium = "trigger";
|
|
1368
|
-
signalType = "trigger_stream";
|
|
1369
|
-
} else if (channel.type === "audio") {
|
|
1370
|
-
const isMono = channel.signalType === "audio_mono" || channel.audioFormat === "mono";
|
|
1371
|
-
medium = isMono ? "audio_mono" : "audio_stereo";
|
|
1372
|
-
signalType = isMono ? "audio_mono" : "audio_stereo";
|
|
1373
|
-
} else if (channel.type === "midi") {
|
|
1374
|
-
medium = "midi";
|
|
1375
|
-
signalType = "midi_stream";
|
|
1376
|
-
} else if (channel.type === "osc" || channel.signalType === "curve" || channel.signalType === "curve_stream") {
|
|
1377
|
-
medium = "curve";
|
|
1378
|
-
signalType = "curve_stream";
|
|
1379
|
-
} else {
|
|
1380
|
-
medium = "data";
|
|
1381
|
-
signalType = channel.signalType || "data";
|
|
1382
|
-
}
|
|
1383
|
-
const formatLabel = channel.type === "audio" ? medium === "audio_mono" ? "Mono" : "Stereo" : "";
|
|
1384
|
-
const typeLabel = channel.type === "audio" ? `Audio ${formatLabel}`.trim() : channel.type.toUpperCase();
|
|
1385
|
-
return {
|
|
1386
|
-
id: `sub-out-${channel.id || channel.sourceId || index}`,
|
|
1387
|
-
name: channel.name || `${typeLabel} Stream Out`,
|
|
1388
|
-
direction: "output",
|
|
1389
|
-
polarity: "output",
|
|
1390
|
-
type: channel.type,
|
|
1391
|
-
signalType,
|
|
1392
|
-
medium,
|
|
1393
|
-
variant: "stream",
|
|
1394
|
-
// Enforced STREAM variant rule
|
|
1395
|
-
dataType: "stream",
|
|
1396
|
-
audioFormat: channel.audioFormat || (medium === "audio_mono" ? "mono" : "stereo"),
|
|
1397
|
-
color: channel.color || (channel.type === "audio" ? "#10b981" : channel.type === "midi" ? "#ec4899" : "#eab308"),
|
|
1398
|
-
sourceChannelId: channel.id,
|
|
1399
|
-
socketIndex: index
|
|
1400
|
-
};
|
|
1401
|
-
}
|
|
1402
|
-
function deriveSubgraphHandlesFromGraph(graphDefinition) {
|
|
1403
|
-
const ioConfig = graphDefinition?.mapIoConfig || createDefaultMapIoConfig();
|
|
1404
|
-
const physicalInputs = ioConfig.inputs || [];
|
|
1405
|
-
const physicalOutputs = ioConfig.outputs || [];
|
|
1406
|
-
const inputHandles = physicalInputs.map((input, idx) => convertPhysicalInputToStreamHandle(input, idx));
|
|
1407
|
-
const outputHandles = physicalOutputs.map((output, idx) => convertPhysicalOutputToStreamHandle(output, idx));
|
|
1408
|
-
return {
|
|
1409
|
-
inputHandles,
|
|
1410
|
-
outputHandles
|
|
1411
|
-
};
|
|
1412
|
-
}
|
|
1413
|
-
function instantiateSubgraphNode(graphDefinition, nodeIndex, position = [0, 0, 0]) {
|
|
1414
|
-
const { inputHandles, outputHandles } = deriveSubgraphHandlesFromGraph(graphDefinition);
|
|
1415
|
-
return {
|
|
1416
|
-
id: `subgraph-${graphDefinition.id}-${Date.now()}-${Math.random().toString(36).substring(2, 6)}`,
|
|
1417
|
-
type: "subgraph",
|
|
1418
|
-
name: graphDefinition.name || "Subgraph Node",
|
|
1419
|
-
position,
|
|
1420
|
-
color: "#8b5cf6",
|
|
1421
|
-
// Violet Subgraph theme color
|
|
1422
|
-
radius: 1.8,
|
|
1423
|
-
label: `Graph: ${graphDefinition.name || graphDefinition.id}`,
|
|
1424
|
-
active: true,
|
|
1425
|
-
graphId: graphDefinition.id,
|
|
1426
|
-
graphName: graphDefinition.name || "Invoked Graph",
|
|
1427
|
-
graphType: graphDefinition.type || "custom",
|
|
1428
|
-
customTypeTag: graphDefinition.customTypeTag,
|
|
1429
|
-
inputHandles,
|
|
1430
|
-
outputHandles,
|
|
1431
|
-
innerGraphDefinition: graphDefinition
|
|
1432
|
-
};
|
|
1433
|
-
}
|
|
1434
|
-
|
|
1435
|
-
// src/engine/core/graphDataService.ts
|
|
1436
|
-
var GraphDataService = class {
|
|
1437
|
-
/**
|
|
1438
|
-
* Fetches enriched node payloads with pluggable 2D sprite descriptors.
|
|
1439
|
-
*/
|
|
1440
|
-
static getEnrichedNodes(nodes, connections) {
|
|
1441
|
-
return nodes.map((node) => {
|
|
1442
|
-
const inCount = connections.filter((c) => c.toNodeId === node.id).length;
|
|
1443
|
-
const outCount = connections.filter((c) => c.fromNodeId === node.id).length;
|
|
1444
|
-
const sprite2D = NodeAssetRegistry.get2DSpriteSetting(node);
|
|
1445
|
-
return {
|
|
1446
|
-
node,
|
|
1447
|
-
sprite2D,
|
|
1448
|
-
connectedInputCount: inCount,
|
|
1449
|
-
connectedOutputCount: outCount
|
|
1450
|
-
};
|
|
1451
|
-
});
|
|
1452
|
-
}
|
|
1453
|
-
/**
|
|
1454
|
-
* Resolves 2D canvas coordinates from 3D world coordinates.
|
|
1455
|
-
* In 3D space: [X, Y (elevation), Z (depth)] -> In 2D plane: [X, Z] mapped to screen (x, y).
|
|
1456
|
-
*/
|
|
1457
|
-
static worldToCanvasCoords(worldPos, pan, zoom, center, worldScale = 40) {
|
|
1458
|
-
const screenX = center.cx + (worldPos[0] * worldScale + pan.x) * zoom;
|
|
1459
|
-
const screenY = center.cy + (worldPos[2] * worldScale + pan.y) * zoom;
|
|
1460
|
-
return { x: screenX, y: screenY };
|
|
1461
|
-
}
|
|
1462
|
-
/**
|
|
1463
|
-
* Resolves 3D world coordinates from 2D screen click coordinates.
|
|
1464
|
-
*/
|
|
1465
|
-
static canvasToWorldCoords(screenPos, pan, zoom, center, worldScale = 40) {
|
|
1466
|
-
const worldX = (screenPos.x - center.cx) / (worldScale * zoom) - pan.x / worldScale;
|
|
1467
|
-
const worldZ = (screenPos.y - center.cy) / (worldScale * zoom) - pan.y / worldScale;
|
|
1468
|
-
return [worldX, 0, worldZ];
|
|
1469
|
-
}
|
|
1470
|
-
/**
|
|
1471
|
-
* Creates a standardized snapshot of the active graph.
|
|
1472
|
-
*/
|
|
1473
|
-
static createGraphSnapshot(nodes, connections) {
|
|
1474
|
-
const validation = validateProjectGraph(nodes, connections);
|
|
1475
|
-
return {
|
|
1476
|
-
nodes: nodes.map((n) => projectNodeToGroundSurface(n)),
|
|
1477
|
-
connections,
|
|
1478
|
-
meta: {
|
|
1479
|
-
nodeCount: nodes.length,
|
|
1480
|
-
wireCount: connections.length,
|
|
1481
|
-
isValid: validation.isValid,
|
|
1482
|
-
timestamp: Date.now()
|
|
1483
|
-
}
|
|
1484
|
-
};
|
|
1485
|
-
}
|
|
1486
|
-
};
|
|
1487
|
-
|
|
1488
|
-
// src/engine/core/graphDependencyValidator.ts
|
|
1489
|
-
function validateGraphImport(existingGraphs, targetGraphId, candidateImportId) {
|
|
1490
|
-
if (targetGraphId === candidateImportId) {
|
|
1491
|
-
return {
|
|
1492
|
-
valid: false,
|
|
1493
|
-
error: `Circular dependency: A graph package cannot import itself ('${targetGraphId}').`,
|
|
1494
|
-
cycleChain: [targetGraphId, targetGraphId]
|
|
1495
|
-
};
|
|
1496
|
-
}
|
|
1497
|
-
const target = existingGraphs[targetGraphId];
|
|
1498
|
-
if (target?.importedGraphIds?.includes(candidateImportId)) {
|
|
1499
|
-
return {
|
|
1500
|
-
valid: false,
|
|
1501
|
-
error: `Graph '${target.name || targetGraphId}' already imports '${candidateImportId}'.`
|
|
1502
|
-
};
|
|
1503
|
-
}
|
|
1504
|
-
const adj = /* @__PURE__ */ new Map();
|
|
1505
|
-
for (const [id2, graph] of Object.entries(existingGraphs)) {
|
|
1506
|
-
const list = Array.isArray(graph.importedGraphIds) ? [...graph.importedGraphIds] : [];
|
|
1507
|
-
adj.set(id2, list);
|
|
1508
|
-
}
|
|
1509
|
-
if (!adj.has(targetGraphId)) adj.set(targetGraphId, []);
|
|
1510
|
-
if (!adj.has(candidateImportId)) adj.set(candidateImportId, []);
|
|
1511
|
-
adj.get(targetGraphId).push(candidateImportId);
|
|
1512
|
-
const visited = /* @__PURE__ */ new Set();
|
|
1513
|
-
const recursionStack = /* @__PURE__ */ new Set();
|
|
1514
|
-
const currentPath = [];
|
|
1515
|
-
function detectCycle(current) {
|
|
1516
|
-
visited.add(current);
|
|
1517
|
-
recursionStack.add(current);
|
|
1518
|
-
currentPath.push(current);
|
|
1519
|
-
const neighbors = adj.get(current) || [];
|
|
1520
|
-
for (const neighbor of neighbors) {
|
|
1521
|
-
if (!visited.has(neighbor)) {
|
|
1522
|
-
const cycle = detectCycle(neighbor);
|
|
1523
|
-
if (cycle) return cycle;
|
|
1524
|
-
} else if (recursionStack.has(neighbor)) {
|
|
1525
|
-
const cycleStartIndex = currentPath.indexOf(neighbor);
|
|
1526
|
-
const cyclePath = [...currentPath.slice(cycleStartIndex), neighbor];
|
|
1527
|
-
return cyclePath;
|
|
1528
|
-
}
|
|
1529
|
-
}
|
|
1530
|
-
currentPath.pop();
|
|
1531
|
-
recursionStack.delete(current);
|
|
1532
|
-
return null;
|
|
1533
|
-
}
|
|
1534
|
-
for (const node of adj.keys()) {
|
|
1535
|
-
if (!visited.has(node)) {
|
|
1536
|
-
currentPath.length = 0;
|
|
1537
|
-
const cycle = detectCycle(node);
|
|
1538
|
-
if (cycle) {
|
|
1539
|
-
const names = cycle.map((id2) => existingGraphs[id2]?.name || id2);
|
|
1540
|
-
return {
|
|
1541
|
-
valid: false,
|
|
1542
|
-
error: `Circular dependency detected: ${names.join(" \u2794 ")}`,
|
|
1543
|
-
cycleChain: cycle
|
|
1544
|
-
};
|
|
1545
|
-
}
|
|
1546
|
-
}
|
|
1547
|
-
}
|
|
1548
|
-
return { valid: true };
|
|
1549
|
-
}
|
|
1550
|
-
function getTopologicalDependencyOrder(existingGraphs, rootGraphId) {
|
|
1551
|
-
const result = [];
|
|
1552
|
-
const visited = /* @__PURE__ */ new Set();
|
|
1553
|
-
function dfs(currentId) {
|
|
1554
|
-
if (visited.has(currentId)) return;
|
|
1555
|
-
visited.add(currentId);
|
|
1556
|
-
const graph = existingGraphs[currentId];
|
|
1557
|
-
if (graph?.importedGraphIds) {
|
|
1558
|
-
for (const impId of graph.importedGraphIds) {
|
|
1559
|
-
dfs(impId);
|
|
1560
|
-
}
|
|
1561
|
-
}
|
|
1562
|
-
result.push(currentId);
|
|
1563
|
-
}
|
|
1564
|
-
dfs(rootGraphId);
|
|
1565
|
-
return result;
|
|
1566
|
-
}
|
|
1567
|
-
|
|
1568
|
-
// src/engine/core/graphTypeSystem.ts
|
|
1569
|
-
var GRAPH_TYPE_DEFINITIONS = {
|
|
1570
|
-
intro_motif: {
|
|
1571
|
-
id: "intro_motif",
|
|
1572
|
-
label: "Intro / Motif",
|
|
1573
|
-
category: "Composition",
|
|
1574
|
-
description: "Hook, thematic motif, melodic ostinato, or musical intro sequence",
|
|
1575
|
-
badgeColor: "#38bdf8",
|
|
1576
|
-
badgeBg: "rgba(56, 189, 248, 0.15)",
|
|
1577
|
-
borderColor: "#0284c7",
|
|
1578
|
-
iconName: "Sparkles",
|
|
1579
|
-
defaultBpm: 120,
|
|
1580
|
-
recommendedNodes: ["trigger", "container", "effect"]
|
|
1581
|
-
},
|
|
1582
|
-
arrangement: {
|
|
1583
|
-
id: "arrangement",
|
|
1584
|
-
label: "Arrangement",
|
|
1585
|
-
category: "Composition",
|
|
1586
|
-
description: "Timeline-ordered multitrack arrangement and structured song form sections",
|
|
1587
|
-
badgeColor: "#a855f7",
|
|
1588
|
-
badgeBg: "rgba(168, 85, 247, 0.15)",
|
|
1589
|
-
borderColor: "#7e22ce",
|
|
1590
|
-
iconName: "Layers",
|
|
1591
|
-
defaultBpm: 120,
|
|
1592
|
-
recommendedNodes: ["arrangement", "container", "effect", "input_strip", "output_strip"]
|
|
1593
|
-
},
|
|
1594
|
-
song: {
|
|
1595
|
-
id: "song",
|
|
1596
|
-
label: "Song",
|
|
1597
|
-
category: "Composition",
|
|
1598
|
-
description: "Complete musical work combining multiple motifs, verses, choruses, and stems",
|
|
1599
|
-
badgeColor: "#f59e0b",
|
|
1600
|
-
badgeBg: "rgba(245, 158, 11, 0.15)",
|
|
1601
|
-
borderColor: "#b45309",
|
|
1602
|
-
iconName: "Music",
|
|
1603
|
-
defaultBpm: 124,
|
|
1604
|
-
recommendedNodes: ["arrangement", "container", "module", "output_strip"]
|
|
1605
|
-
},
|
|
1606
|
-
performance: {
|
|
1607
|
-
id: "performance",
|
|
1608
|
-
label: "Performance",
|
|
1609
|
-
category: "Performance",
|
|
1610
|
-
description: "Live interactive matrix with mapped MIDI/OSC controls, pads, and real-time triggers",
|
|
1611
|
-
badgeColor: "#10b981",
|
|
1612
|
-
badgeBg: "rgba(16, 185, 129, 0.15)",
|
|
1613
|
-
borderColor: "#047857",
|
|
1614
|
-
iconName: "Activity",
|
|
1615
|
-
defaultBpm: 128,
|
|
1616
|
-
recommendedNodes: ["control", "audio_pads", "button", "trigger", "effect"]
|
|
1617
|
-
},
|
|
1618
|
-
synth_patch: {
|
|
1619
|
-
id: "synth_patch",
|
|
1620
|
-
label: "Synth Patch / Sound Design",
|
|
1621
|
-
category: "Sound Design",
|
|
1622
|
-
description: "Self-contained modular synthesizer patch or acoustic instrument instrument package",
|
|
1623
|
-
badgeColor: "#ec4899",
|
|
1624
|
-
badgeBg: "rgba(236, 72, 153, 0.15)",
|
|
1625
|
-
borderColor: "#be185d",
|
|
1626
|
-
iconName: "Radio",
|
|
1627
|
-
defaultBpm: 120,
|
|
1628
|
-
recommendedNodes: ["container", "effect", "combiner", "converter"]
|
|
1629
|
-
},
|
|
1630
|
-
fx_chain: {
|
|
1631
|
-
id: "fx_chain",
|
|
1632
|
-
label: "Audio FX Chain",
|
|
1633
|
-
category: "Sound Design",
|
|
1634
|
-
description: "Chained processing rack with EQ, dynamics, delay, modulation, and spatial reverb",
|
|
1635
|
-
badgeColor: "#06b6d4",
|
|
1636
|
-
badgeBg: "rgba(6, 182, 212, 0.15)",
|
|
1637
|
-
borderColor: "#0e7490",
|
|
1638
|
-
iconName: "Sliders",
|
|
1639
|
-
defaultBpm: 120,
|
|
1640
|
-
recommendedNodes: ["effect", "combiner", "multiplexer"]
|
|
1641
|
-
},
|
|
1642
|
-
rhythm_beat: {
|
|
1643
|
-
id: "rhythm_beat",
|
|
1644
|
-
label: "Rhythm / Beat Grid",
|
|
1645
|
-
category: "Composition",
|
|
1646
|
-
description: "Euclidean pulse generator, drum sample matrix, and rhythmic trigger sequencer",
|
|
1647
|
-
badgeColor: "#f97316",
|
|
1648
|
-
badgeBg: "rgba(249, 115, 22, 0.15)",
|
|
1649
|
-
borderColor: "#c2410c",
|
|
1650
|
-
iconName: "Grid",
|
|
1651
|
-
defaultBpm: 130,
|
|
1652
|
-
recommendedNodes: ["trigger", "audio_pads", "container"]
|
|
1653
|
-
},
|
|
1654
|
-
generative: {
|
|
1655
|
-
id: "generative",
|
|
1656
|
-
label: "Generative Algorithmic",
|
|
1657
|
-
category: "Experimental",
|
|
1658
|
-
description: "Algorithmic procedural music generator utilizing code nodes and probabilistic rules",
|
|
1659
|
-
badgeColor: "#8b5cf6",
|
|
1660
|
-
badgeBg: "rgba(139, 92, 246, 0.15)",
|
|
1661
|
-
borderColor: "#6d28d9",
|
|
1662
|
-
iconName: "Code",
|
|
1663
|
-
defaultBpm: 110,
|
|
1664
|
-
recommendedNodes: ["code", "trigger", "primitive_number", "primitive_object"]
|
|
1665
|
-
},
|
|
1666
|
-
live_set: {
|
|
1667
|
-
id: "live_set",
|
|
1668
|
-
label: "Live Set / Session",
|
|
1669
|
-
category: "Performance",
|
|
1670
|
-
description: "Master live session setup integrating multiple imported song packages and cue strips",
|
|
1671
|
-
badgeColor: "#e11d48",
|
|
1672
|
-
badgeBg: "rgba(225, 29, 72, 0.15)",
|
|
1673
|
-
borderColor: "#9f1239",
|
|
1674
|
-
iconName: "PlayCircle",
|
|
1675
|
-
defaultBpm: 126,
|
|
1676
|
-
recommendedNodes: ["input_strip", "output_strip", "control", "arrangement"]
|
|
1677
|
-
},
|
|
1678
|
-
utility_macro: {
|
|
1679
|
-
id: "utility_macro",
|
|
1680
|
-
label: "Utility / Macro",
|
|
1681
|
-
category: "Utility",
|
|
1682
|
-
description: "Signal multiplexers, stereo/mono converters, math routers, and bus utilities",
|
|
1683
|
-
badgeColor: "#64748b",
|
|
1684
|
-
badgeBg: "rgba(100, 116, 139, 0.15)",
|
|
1685
|
-
borderColor: "#475569",
|
|
1686
|
-
iconName: "Cpu",
|
|
1687
|
-
defaultBpm: 120,
|
|
1688
|
-
recommendedNodes: ["converter", "combiner", "multiplexer", "primitive_string"]
|
|
1689
|
-
},
|
|
1690
|
-
custom: {
|
|
1691
|
-
id: "custom",
|
|
1692
|
-
label: "Custom / Experimental",
|
|
1693
|
-
category: "Experimental",
|
|
1694
|
-
description: "Freeform experimental node package with custom user-defined metadata tag",
|
|
1695
|
-
badgeColor: "#14b8a6",
|
|
1696
|
-
badgeBg: "rgba(20, 184, 166, 0.15)",
|
|
1697
|
-
borderColor: "#0f766e",
|
|
1698
|
-
iconName: "Box",
|
|
1699
|
-
defaultBpm: 120,
|
|
1700
|
-
recommendedNodes: ["container", "trigger", "effect", "module"]
|
|
1701
|
-
}
|
|
1702
|
-
};
|
|
1703
|
-
var ALL_GRAPH_TYPES = Object.keys(GRAPH_TYPE_DEFINITIONS);
|
|
1704
|
-
function getGraphTypeDefinition(type) {
|
|
1705
|
-
if (type && type in GRAPH_TYPE_DEFINITIONS) {
|
|
1706
|
-
return GRAPH_TYPE_DEFINITIONS[type];
|
|
1707
|
-
}
|
|
1708
|
-
return GRAPH_TYPE_DEFINITIONS.custom;
|
|
1709
|
-
}
|
|
1710
|
-
|
|
1711
|
-
// src/engine/core/controlDispatcher.ts
|
|
1712
|
-
var configuredControlEngines = {};
|
|
1713
|
-
function configureControlDispatcher(engines) {
|
|
1714
|
-
configuredControlEngines = { ...configuredControlEngines, ...engines };
|
|
1715
|
-
if (engines.synthEngine) {
|
|
1716
|
-
globalThis.__KLOKS_SYNTH_ENGINE__ = engines.synthEngine;
|
|
1717
|
-
globalThis.__QWNSR_SYNTH_ENGINE__ = engines.synthEngine;
|
|
1718
|
-
}
|
|
1719
|
-
}
|
|
1720
|
-
var synthEngine = new Proxy(
|
|
1721
|
-
{},
|
|
1722
|
-
{
|
|
1723
|
-
get(_target, prop) {
|
|
1724
|
-
const globalEngine = configuredControlEngines.synthEngine || globalThis.__KLOKS_SYNTH_ENGINE__ || globalThis.__QWNSR_SYNTH_ENGINE__;
|
|
1725
|
-
if (globalEngine && typeof globalEngine[prop] === "function") {
|
|
1726
|
-
return globalEngine[prop].bind(globalEngine);
|
|
1727
|
-
}
|
|
1728
|
-
return () => true;
|
|
1729
|
-
}
|
|
1730
|
-
}
|
|
1731
|
-
);
|
|
1732
|
-
var ControlDispatcher = class {
|
|
1733
|
-
feedbackListeners = /* @__PURE__ */ new Set();
|
|
1734
|
-
addFeedbackListener(fn) {
|
|
1735
|
-
this.feedbackListeners.add(fn);
|
|
1736
|
-
return () => this.feedbackListeners.delete(fn);
|
|
1737
|
-
}
|
|
1738
|
-
/**
|
|
1739
|
-
* Main dispatch entry point called whenever a user interacts with a ControlElement.
|
|
1740
|
-
* Modulations affect graph node parameters and exposed socket targets.
|
|
1741
|
-
* External hardware transmissions are strictly restricted to the Output Strip.
|
|
1742
|
-
*/
|
|
1743
|
-
dispatchElementPayload(element, value, context) {
|
|
1744
|
-
const binding = element.binding;
|
|
1745
|
-
const now = Date.now();
|
|
1746
|
-
let summary = `Updated ${element.label} = ${JSON.stringify(value)}`;
|
|
1747
|
-
if (!binding) {
|
|
1748
|
-
const fb = {
|
|
1749
|
-
timestamp: now,
|
|
1750
|
-
elementId: element.id,
|
|
1751
|
-
payloadType: "none",
|
|
1752
|
-
summary
|
|
1753
|
-
};
|
|
1754
|
-
this.notifyFeedback(fb);
|
|
1755
|
-
return fb;
|
|
1756
|
-
}
|
|
1757
|
-
const { payloadType, synthParam, targetNodeId } = binding;
|
|
1758
|
-
if (payloadType === "synth_param" && synthParam) {
|
|
1759
|
-
const numVal = typeof value === "number" ? value : parseFloat(String(value)) || 0;
|
|
1760
|
-
switch (synthParam) {
|
|
1761
|
-
case "cutoff":
|
|
1762
|
-
synthEngine.setMasterFilterCutoff?.(numVal);
|
|
1763
|
-
summary = `Synth Cutoff set to ${Math.round(numVal)} Hz`;
|
|
1764
|
-
break;
|
|
1765
|
-
case "resonance":
|
|
1766
|
-
synthEngine.setMasterFilterResonance?.(numVal);
|
|
1767
|
-
summary = `Synth Resonance set to ${numVal.toFixed(1)}`;
|
|
1768
|
-
break;
|
|
1769
|
-
case "bpm":
|
|
1770
|
-
summary = `Transport BPM set to ${Math.round(numVal)}`;
|
|
1771
|
-
break;
|
|
1772
|
-
case "volume":
|
|
1773
|
-
case "masterVolume":
|
|
1774
|
-
synthEngine.setMasterVolume(Math.max(0, Math.min(2, numVal / 100)));
|
|
1775
|
-
summary = `Master Volume set to ${Math.round(numVal)}%`;
|
|
1776
|
-
break;
|
|
1777
|
-
default:
|
|
1778
|
-
summary = `Modulated ${synthParam} \u2794 ${numVal}`;
|
|
1779
|
-
break;
|
|
1780
|
-
}
|
|
1781
|
-
} else if (payloadType === "trigger_pulse") {
|
|
1782
|
-
if (targetNodeId && context.onTriggerNode) {
|
|
1783
|
-
context.onTriggerNode(targetNodeId);
|
|
1784
|
-
summary = `Trigger pulse sent to node [${targetNodeId}]`;
|
|
1785
|
-
} else {
|
|
1786
|
-
synthEngine.playAuditionTestPulse();
|
|
1787
|
-
summary = `Master Trigger pulse fired`;
|
|
1788
|
-
}
|
|
1789
|
-
} else if (payloadType === "midi_cc") {
|
|
1790
|
-
const channel = binding.midiChannel || 1;
|
|
1791
|
-
const ccNum = binding.midiCC ?? 1;
|
|
1792
|
-
const ccVal = typeof value === "number" ? Math.round(value) : value ? 127 : 0;
|
|
1793
|
-
summary = `MIDI CC #${ccNum} (Ch ${channel}) = ${ccVal}`;
|
|
1794
|
-
} else if (payloadType === "midi_note") {
|
|
1795
|
-
const channel = binding.midiChannel || 1;
|
|
1796
|
-
const note = binding.midiNote || 60;
|
|
1797
|
-
const vel = binding.midiVelocity || (typeof value === "number" ? Math.round(value) : 100);
|
|
1798
|
-
summary = `MIDI Note #${note} (Ch ${channel}) Vel ${vel}`;
|
|
1799
|
-
} else if (payloadType === "curve_value") {
|
|
1800
|
-
if (Array.isArray(value)) {
|
|
1801
|
-
summary = `XY Orbit = [${value[0].toFixed(2)}, ${value[1].toFixed(2)}]`;
|
|
1802
|
-
} else {
|
|
1803
|
-
summary = `CV Modulation = ${value}`;
|
|
1804
|
-
}
|
|
1805
|
-
} else if (payloadType === "raw_json" || payloadType === "custom_string") {
|
|
1806
|
-
let templated = binding.dynamicTemplate || String(binding.staticPayload || "");
|
|
1807
|
-
templated = templated.replace(/\{value\}/g, String(value));
|
|
1808
|
-
summary = `Custom Payload: ${templated}`;
|
|
1809
|
-
}
|
|
1810
|
-
const feedback = {
|
|
1811
|
-
timestamp: now,
|
|
1812
|
-
elementId: element.id,
|
|
1813
|
-
payloadType,
|
|
1814
|
-
summary
|
|
1815
|
-
};
|
|
1816
|
-
this.notifyFeedback(feedback);
|
|
1817
|
-
return feedback;
|
|
1818
|
-
}
|
|
1819
|
-
notifyFeedback(fb) {
|
|
1820
|
-
this.feedbackListeners.forEach((fn) => fn(fb));
|
|
1821
|
-
}
|
|
1822
|
-
};
|
|
1823
|
-
var controlDispatcher = new ControlDispatcher();
|
|
1824
|
-
|
|
1825
|
-
// src/engine/functions/musicTheory.ts
|
|
1826
|
-
var NOTE_NAMES = ["C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B"];
|
|
1827
|
-
function midiToNoteName(midi) {
|
|
1828
|
-
const octave = Math.floor(midi / 12) - 1;
|
|
1829
|
-
const noteIndex = midi % 12;
|
|
1830
|
-
return `${NOTE_NAMES[noteIndex]}${octave}`;
|
|
1831
|
-
}
|
|
1832
|
-
function midiToFreq(midi) {
|
|
1833
|
-
return 440 * Math.pow(2, (midi - 69) / 12);
|
|
1834
|
-
}
|
|
1835
|
-
function noteNameToMidi(name) {
|
|
1836
|
-
const match = name.match(/^([A-G]#?)(-?\d+)$/);
|
|
1837
|
-
if (!match) return 60;
|
|
1838
|
-
const noteIndex = NOTE_NAMES.indexOf(match[1]);
|
|
1839
|
-
const octave = parseInt(match[2], 10);
|
|
1840
|
-
return (octave + 1) * 12 + noteIndex;
|
|
1841
|
-
}
|
|
1842
|
-
var PRESET_SCALES = {
|
|
1843
|
-
"Major Pentatonic": [0, 2, 4, 7, 9],
|
|
1844
|
-
"Minor Pentatonic": [0, 3, 5, 7, 10],
|
|
1845
|
-
"Cosmic Lydian": [0, 2, 4, 6, 7, 9, 11],
|
|
1846
|
-
"Dorian Myst": [0, 2, 3, 5, 7, 9, 10],
|
|
1847
|
-
"Aeolian Dark": [0, 2, 3, 5, 7, 8, 10],
|
|
1848
|
-
"Chromatic Universe": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]
|
|
1849
|
-
};
|
|
1850
|
-
var COLOR_PALETTES = [
|
|
1851
|
-
"#f59e0b",
|
|
1852
|
-
// Amber / Gold Star
|
|
1853
|
-
"#38bdf8",
|
|
1854
|
-
// Celestial Sky
|
|
1855
|
-
"#c084fc",
|
|
1856
|
-
// Nebula Violet
|
|
1857
|
-
"#f43f5e",
|
|
1858
|
-
// Quasar Crimson
|
|
1859
|
-
"#34d399",
|
|
1860
|
-
// Aurora Emerald
|
|
1861
|
-
"#fb7185",
|
|
1862
|
-
// Coral Supernova
|
|
1863
|
-
"#a78bfa",
|
|
1864
|
-
// Pulsar Indigo
|
|
1865
|
-
"#2dd4bf"
|
|
1866
|
-
// Cyan Comet
|
|
1867
|
-
];
|
|
1868
|
-
|
|
1869
|
-
// src/engine/core/canonicalIo/types.ts
|
|
1870
|
-
function calculateAudioMeterLevel(peak, rms, gain = 1) {
|
|
1871
|
-
if (peak <= 5e-4 && rms <= 5e-4) {
|
|
1872
|
-
return 0;
|
|
1873
|
-
}
|
|
1874
|
-
const raw = peak * 0.75 + rms * 0.25;
|
|
1875
|
-
return Math.min(1, Math.max(0, raw * 1.5 * gain));
|
|
1876
|
-
}
|
|
1877
|
-
|
|
1878
|
-
// src/engine/core/canonicalIo/CanonicalAudioInputEndpoint.ts
|
|
1879
|
-
var CanonicalAudioInputEndpoint = class {
|
|
1880
|
-
id;
|
|
1881
|
-
name;
|
|
1882
|
-
channel;
|
|
1883
|
-
gain = 1;
|
|
1884
|
-
isMuted = false;
|
|
1885
|
-
connected = true;
|
|
1886
|
-
level = 0;
|
|
1887
|
-
peak = 0;
|
|
1888
|
-
rms = 0;
|
|
1889
|
-
sampleCount = 0;
|
|
1890
|
-
noiseFloor = 0;
|
|
1891
|
-
audioNode = null;
|
|
1892
|
-
analyser = null;
|
|
1893
|
-
cachedTimeData = null;
|
|
1894
|
-
cachedFreqData = null;
|
|
1895
|
-
listeners = /* @__PURE__ */ new Set();
|
|
1896
|
-
constructor(id2, name, channel = 1) {
|
|
1897
|
-
this.id = id2;
|
|
1898
|
-
this.name = name;
|
|
1899
|
-
this.channel = channel;
|
|
1900
|
-
}
|
|
1901
|
-
subscribe(fn) {
|
|
1902
|
-
this.listeners.add(fn);
|
|
1903
|
-
fn(this.getState());
|
|
1904
|
-
return () => this.listeners.delete(fn);
|
|
1905
|
-
}
|
|
1906
|
-
getState() {
|
|
1907
|
-
return {
|
|
1908
|
-
id: this.id,
|
|
1909
|
-
name: this.name,
|
|
1910
|
-
channel: this.channel,
|
|
1911
|
-
gain: this.gain,
|
|
1912
|
-
isMuted: this.isMuted,
|
|
1913
|
-
connected: this.connected,
|
|
1914
|
-
level: this.level,
|
|
1915
|
-
peak: this.peak,
|
|
1916
|
-
rms: this.rms,
|
|
1917
|
-
sampleCount: this.sampleCount,
|
|
1918
|
-
noiseFloor: this.noiseFloor
|
|
1919
|
-
};
|
|
1920
|
-
}
|
|
1921
|
-
processAudioBuffer(buffer) {
|
|
1922
|
-
if (!this.connected || this.isMuted) {
|
|
1923
|
-
this.peak = 0;
|
|
1924
|
-
this.rms = 0;
|
|
1925
|
-
this.level = 0;
|
|
1926
|
-
this.sampleCount = buffer.length;
|
|
1927
|
-
this.notify();
|
|
1928
|
-
return;
|
|
1929
|
-
}
|
|
1930
|
-
this.sampleCount = buffer.length;
|
|
1931
|
-
if (this.sampleCount === 0) {
|
|
1932
|
-
this.peak = 0;
|
|
1933
|
-
this.rms = 0;
|
|
1934
|
-
this.level = this.noiseFloor;
|
|
1935
|
-
this.notify();
|
|
1936
|
-
return;
|
|
1937
|
-
}
|
|
1938
|
-
let peak = 0;
|
|
1939
|
-
let sumSq = 0;
|
|
1940
|
-
for (let i = 0; i < buffer.length; i++) {
|
|
1941
|
-
const abs = Math.abs(buffer[i]);
|
|
1942
|
-
if (abs > peak) peak = abs;
|
|
1943
|
-
sumSq += abs * abs;
|
|
1944
|
-
}
|
|
1945
|
-
const rms = Math.sqrt(sumSq / buffer.length);
|
|
1946
|
-
this.peak = peak;
|
|
1947
|
-
this.rms = rms;
|
|
1948
|
-
this.level = calculateAudioMeterLevel(peak, rms, this.gain);
|
|
1949
|
-
this.notify();
|
|
1950
|
-
}
|
|
1951
|
-
sampleFromAnalyser() {
|
|
1952
|
-
if (!this.connected || this.isMuted) {
|
|
1953
|
-
this.level = 0;
|
|
1954
|
-
this.peak = 0;
|
|
1955
|
-
this.rms = 0;
|
|
1956
|
-
this.notify();
|
|
1957
|
-
return;
|
|
1958
|
-
}
|
|
1959
|
-
if (!this.analyser) {
|
|
1960
|
-
this.level = 0;
|
|
1961
|
-
return;
|
|
1962
|
-
}
|
|
1963
|
-
try {
|
|
1964
|
-
if (typeof this.analyser.getFloatTimeDomainData === "function") {
|
|
1965
|
-
const fftSize = this.analyser.fftSize || 64;
|
|
1966
|
-
if (!this.cachedTimeData || this.cachedTimeData.length !== fftSize) {
|
|
1967
|
-
this.cachedTimeData = new Float32Array(fftSize);
|
|
1968
|
-
}
|
|
1969
|
-
this.analyser.getFloatTimeDomainData(this.cachedTimeData);
|
|
1970
|
-
this.processAudioBuffer(this.cachedTimeData);
|
|
1971
|
-
} else {
|
|
1972
|
-
const binCount = this.analyser.frequencyBinCount || 32;
|
|
1973
|
-
if (!this.cachedFreqData || this.cachedFreqData.length !== binCount) {
|
|
1974
|
-
this.cachedFreqData = new Uint8Array(binCount);
|
|
1975
|
-
}
|
|
1976
|
-
this.analyser.getByteFrequencyData(this.cachedFreqData);
|
|
1977
|
-
let maxVal = 0;
|
|
1978
|
-
let sum2 = 0;
|
|
1979
|
-
for (let i = 0; i < this.cachedFreqData.length; i++) {
|
|
1980
|
-
const v = this.cachedFreqData[i];
|
|
1981
|
-
if (v > maxVal) maxVal = v;
|
|
1982
|
-
sum2 += v;
|
|
1983
|
-
}
|
|
1984
|
-
this.sampleCount = this.cachedFreqData.length;
|
|
1985
|
-
if (maxVal === 0) {
|
|
1986
|
-
this.peak = 0;
|
|
1987
|
-
this.rms = 0;
|
|
1988
|
-
this.level = this.noiseFloor;
|
|
1989
|
-
} else {
|
|
1990
|
-
const maxNorm = maxVal / 255;
|
|
1991
|
-
const avgNorm = sum2 / this.cachedFreqData.length / 255;
|
|
1992
|
-
this.peak = maxNorm;
|
|
1993
|
-
this.rms = avgNorm;
|
|
1994
|
-
this.level = calculateAudioMeterLevel(maxNorm, avgNorm, this.gain);
|
|
1995
|
-
}
|
|
1996
|
-
this.notify();
|
|
1997
|
-
}
|
|
1998
|
-
} catch {
|
|
1999
|
-
this.level = this.noiseFloor;
|
|
2000
|
-
this.notify();
|
|
2001
|
-
}
|
|
2002
|
-
}
|
|
2003
|
-
setConnected(connected) {
|
|
2004
|
-
this.connected = connected;
|
|
2005
|
-
if (!connected) {
|
|
2006
|
-
this.level = 0;
|
|
2007
|
-
this.peak = 0;
|
|
2008
|
-
this.rms = 0;
|
|
2009
|
-
}
|
|
2010
|
-
this.notify();
|
|
2011
|
-
}
|
|
2012
|
-
setGain(gain) {
|
|
2013
|
-
this.gain = gain;
|
|
2014
|
-
this.level = calculateAudioMeterLevel(this.peak, this.rms, this.gain);
|
|
2015
|
-
this.notify();
|
|
2016
|
-
}
|
|
2017
|
-
setMuted(muted) {
|
|
2018
|
-
this.isMuted = muted;
|
|
2019
|
-
if (muted) {
|
|
2020
|
-
this.level = 0;
|
|
2021
|
-
} else {
|
|
2022
|
-
this.level = calculateAudioMeterLevel(this.peak, this.rms, this.gain);
|
|
2023
|
-
}
|
|
2024
|
-
this.notify();
|
|
2025
|
-
}
|
|
2026
|
-
notify() {
|
|
2027
|
-
const state = this.getState();
|
|
2028
|
-
this.listeners.forEach((fn) => fn(state));
|
|
2029
|
-
}
|
|
2030
|
-
};
|
|
2031
|
-
|
|
2032
|
-
// src/engine/core/canonicalIo/CanonicalMidiInputEndpoint.ts
|
|
2033
|
-
var CanonicalMidiInputEndpoint = class {
|
|
2034
|
-
id;
|
|
2035
|
-
name;
|
|
2036
|
-
connected = true;
|
|
2037
|
-
active = false;
|
|
2038
|
-
currentNote = null;
|
|
2039
|
-
currentNoteName = null;
|
|
2040
|
-
velocity = 0;
|
|
2041
|
-
activeNotes = /* @__PURE__ */ new Set();
|
|
2042
|
-
lastEventTimestamp = 0;
|
|
2043
|
-
noteHistory = [];
|
|
2044
|
-
listeners = /* @__PURE__ */ new Set();
|
|
2045
|
-
eventListeners = /* @__PURE__ */ new Set();
|
|
2046
|
-
constructor(id2, name) {
|
|
2047
|
-
this.id = id2;
|
|
2048
|
-
this.name = name;
|
|
2049
|
-
}
|
|
2050
|
-
subscribe(fn) {
|
|
2051
|
-
this.listeners.add(fn);
|
|
2052
|
-
fn(this.getState());
|
|
2053
|
-
return () => this.listeners.delete(fn);
|
|
2054
|
-
}
|
|
2055
|
-
addEventListener(fn) {
|
|
2056
|
-
this.eventListeners.add(fn);
|
|
2057
|
-
return () => this.eventListeners.delete(fn);
|
|
2058
|
-
}
|
|
2059
|
-
getState() {
|
|
2060
|
-
return {
|
|
2061
|
-
id: this.id,
|
|
2062
|
-
name: this.name,
|
|
2063
|
-
connected: this.connected,
|
|
2064
|
-
active: this.active,
|
|
2065
|
-
currentNote: this.currentNote,
|
|
2066
|
-
currentNoteName: this.currentNoteName,
|
|
2067
|
-
velocity: this.velocity,
|
|
2068
|
-
activeNotes: new Set(this.activeNotes),
|
|
2069
|
-
lastEventTimestamp: this.lastEventTimestamp
|
|
2070
|
-
};
|
|
2071
|
-
}
|
|
2072
|
-
handleMidiEvent(evt) {
|
|
2073
|
-
if (!this.connected) return;
|
|
2074
|
-
this.lastEventTimestamp = evt.timestamp || Date.now();
|
|
2075
|
-
if (evt.type === "noteon" && (evt.velocity ?? 0) > 0) {
|
|
2076
|
-
this.activeNotes.add(evt.note);
|
|
2077
|
-
this.noteHistory = this.noteHistory.filter((n) => n !== evt.note);
|
|
2078
|
-
this.noteHistory.push(evt.note);
|
|
2079
|
-
this.currentNote = evt.note;
|
|
2080
|
-
this.currentNoteName = evt.noteName || midiToNoteName(evt.note);
|
|
2081
|
-
this.velocity = evt.velocity ?? 0.8;
|
|
2082
|
-
this.active = true;
|
|
2083
|
-
} else if (evt.type === "noteoff" || evt.type === "noteon" && (evt.velocity ?? 0) === 0) {
|
|
2084
|
-
this.activeNotes.delete(evt.note);
|
|
2085
|
-
this.noteHistory = this.noteHistory.filter((n) => n !== evt.note);
|
|
2086
|
-
if (this.activeNotes.size > 0) {
|
|
2087
|
-
const lastRemaining = this.noteHistory[this.noteHistory.length - 1];
|
|
2088
|
-
this.currentNote = lastRemaining;
|
|
2089
|
-
this.currentNoteName = midiToNoteName(lastRemaining);
|
|
2090
|
-
this.active = true;
|
|
2091
|
-
} else {
|
|
2092
|
-
this.active = false;
|
|
2093
|
-
this.currentNote = null;
|
|
2094
|
-
this.currentNoteName = null;
|
|
2095
|
-
this.velocity = 0;
|
|
2096
|
-
}
|
|
2097
|
-
}
|
|
2098
|
-
this.notify();
|
|
2099
|
-
this.eventListeners.forEach((fn) => fn(evt));
|
|
2100
|
-
}
|
|
2101
|
-
setConnected(connected) {
|
|
2102
|
-
this.connected = connected;
|
|
2103
|
-
if (!connected) {
|
|
2104
|
-
this.active = false;
|
|
2105
|
-
this.currentNote = null;
|
|
2106
|
-
this.currentNoteName = null;
|
|
2107
|
-
this.velocity = 0;
|
|
2108
|
-
this.activeNotes.clear();
|
|
2109
|
-
this.noteHistory = [];
|
|
2110
|
-
}
|
|
2111
|
-
this.notify();
|
|
2112
|
-
}
|
|
2113
|
-
notify() {
|
|
2114
|
-
const state = this.getState();
|
|
2115
|
-
this.listeners.forEach((fn) => fn(state));
|
|
2116
|
-
}
|
|
2117
|
-
};
|
|
2118
|
-
var canonicalMidiBridgeRef = null;
|
|
2119
|
-
function configureCanonicalMidiBridge(midiManagerInstance) {
|
|
2120
|
-
canonicalMidiBridgeRef = midiManagerInstance;
|
|
2121
|
-
globalThis.__KLOKS_MIDI_MANAGER__ = midiManagerInstance;
|
|
2122
|
-
}
|
|
2123
|
-
function getCanonicalMidiBridge() {
|
|
2124
|
-
return canonicalMidiBridgeRef || globalThis.__KLOKS_MIDI_MANAGER__;
|
|
2125
|
-
}
|
|
2126
|
-
|
|
2127
|
-
// src/engine/core/canonicalIo/topLevelIoRegistry.ts
|
|
2128
|
-
var TopLevelIoRegistry = class {
|
|
2129
|
-
audioEndpoints = /* @__PURE__ */ new Map();
|
|
2130
|
-
midiEndpoints = /* @__PURE__ */ new Map();
|
|
2131
|
-
registryListeners = /* @__PURE__ */ new Set();
|
|
2132
|
-
debugTraceLog = [];
|
|
2133
|
-
constructor() {
|
|
2134
|
-
this.initDefaultEndpoints();
|
|
2135
|
-
}
|
|
2136
|
-
initDefaultEndpoints() {
|
|
2137
|
-
this.getOrCreateAudioEndpoint("bus-in-1", "Physical Audio In 1", 1);
|
|
2138
|
-
this.getOrCreateAudioEndpoint("bus-in-2", "Physical Audio In 2", 2);
|
|
2139
|
-
this.getOrCreateMidiEndpoint("midi-profile-1", "Main Stage Synth / Keyboard");
|
|
2140
|
-
this.getOrCreateMidiEndpoint("midi-profile-2", "External MIDI Controller / Pads");
|
|
2141
|
-
this.getOrCreateMidiEndpoint("virtual-keyboard", "Virtual MIDI Keyboard");
|
|
2142
|
-
this.getOrCreateMidiEndpoint("all", "All Physical MIDI Inputs (Omni)");
|
|
2143
|
-
}
|
|
2144
|
-
subscribeRegistry(fn) {
|
|
2145
|
-
this.registryListeners.add(fn);
|
|
2146
|
-
return () => this.registryListeners.delete(fn);
|
|
2147
|
-
}
|
|
2148
|
-
notifyRegistry() {
|
|
2149
|
-
this.registryListeners.forEach((fn) => fn());
|
|
2150
|
-
}
|
|
2151
|
-
getOrCreateAudioEndpoint(id2, name, channel = 1) {
|
|
2152
|
-
let ep = this.audioEndpoints.get(id2);
|
|
2153
|
-
if (!ep) {
|
|
2154
|
-
ep = new CanonicalAudioInputEndpoint(id2, name, channel);
|
|
2155
|
-
this.audioEndpoints.set(id2, ep);
|
|
2156
|
-
this.notifyRegistry();
|
|
2157
|
-
}
|
|
2158
|
-
return ep;
|
|
2159
|
-
}
|
|
2160
|
-
getAudioEndpoint(id2) {
|
|
2161
|
-
return this.audioEndpoints.get(id2);
|
|
2162
|
-
}
|
|
2163
|
-
getAllAudioEndpoints() {
|
|
2164
|
-
return Array.from(this.audioEndpoints.values());
|
|
2165
|
-
}
|
|
2166
|
-
getOrCreateMidiEndpoint(id2, name) {
|
|
2167
|
-
let ep = this.midiEndpoints.get(id2);
|
|
2168
|
-
if (!ep) {
|
|
2169
|
-
ep = new CanonicalMidiInputEndpoint(id2, name);
|
|
2170
|
-
this.midiEndpoints.set(id2, ep);
|
|
2171
|
-
this.notifyRegistry();
|
|
2172
|
-
}
|
|
2173
|
-
return ep;
|
|
2174
|
-
}
|
|
2175
|
-
getMidiEndpoint(id2) {
|
|
2176
|
-
return this.midiEndpoints.get(id2);
|
|
2177
|
-
}
|
|
2178
|
-
getAllMidiEndpoints() {
|
|
2179
|
-
return Array.from(this.midiEndpoints.values());
|
|
2180
|
-
}
|
|
2181
|
-
/**
|
|
2182
|
-
* Dispatches a canonical MIDI event from device adapter into matching endpoints.
|
|
2183
|
-
*/
|
|
2184
|
-
dispatchMidiEvent(evt) {
|
|
2185
|
-
const devId = evt.deviceId || "virtual-keyboard";
|
|
2186
|
-
const directEp = this.midiEndpoints.get(devId);
|
|
2187
|
-
if (directEp) {
|
|
2188
|
-
directEp.handleMidiEvent(evt);
|
|
2189
|
-
}
|
|
2190
|
-
this.midiEndpoints.forEach((ep) => {
|
|
2191
|
-
if (ep.id === devId) return;
|
|
2192
|
-
if (ep.id === "all" || ep.id.startsWith("midi-profile-")) {
|
|
2193
|
-
ep.handleMidiEvent(evt);
|
|
2194
|
-
}
|
|
2195
|
-
});
|
|
2196
|
-
this.logTrace("MIDI", "EVENT_PARSED", {
|
|
2197
|
-
type: evt.type,
|
|
2198
|
-
note: evt.note,
|
|
2199
|
-
noteName: evt.noteName,
|
|
2200
|
-
velocity: evt.velocity,
|
|
2201
|
-
deviceId: devId
|
|
2202
|
-
});
|
|
2203
|
-
}
|
|
2204
|
-
logTrace(category, stage, data, assertionsPassed = true) {
|
|
2205
|
-
const entry = {
|
|
2206
|
-
category,
|
|
2207
|
-
stage,
|
|
2208
|
-
timestamp: performance.now ? performance.now() : Date.now(),
|
|
2209
|
-
data,
|
|
2210
|
-
assertionsPassed
|
|
2211
|
-
};
|
|
2212
|
-
this.debugTraceLog.push(entry);
|
|
2213
|
-
if (this.debugTraceLog.length > 500) {
|
|
2214
|
-
this.debugTraceLog.shift();
|
|
2215
|
-
}
|
|
2216
|
-
}
|
|
2217
|
-
clearTraceLog() {
|
|
2218
|
-
this.debugTraceLog = [];
|
|
2219
|
-
}
|
|
2220
|
-
};
|
|
2221
|
-
var topLevelIoRegistry = new TopLevelIoRegistry();
|
|
2222
|
-
|
|
2223
|
-
// src/engine/core/l2_drivers/audioBusDriver.ts
|
|
2224
|
-
var AudioBusDriver = class {
|
|
2225
|
-
channelSplitter = null;
|
|
2226
|
-
channelAnalysers = /* @__PURE__ */ new Map();
|
|
2227
|
-
namedAnalyserMap = /* @__PURE__ */ new Map();
|
|
2228
|
-
namedGainMap = /* @__PURE__ */ new Map();
|
|
2229
|
-
activeMonitorGains = /* @__PURE__ */ new Map();
|
|
2230
|
-
sharedAnalyserBuffer = new Uint8Array(64);
|
|
2231
|
-
setupSplitter(ctx, sourceNode, channelCount) {
|
|
2232
|
-
const splitCount = Math.min(32, Math.max(2, channelCount));
|
|
2233
|
-
try {
|
|
2234
|
-
this.channelSplitter = ctx.createChannelSplitter(splitCount);
|
|
2235
|
-
sourceNode.connect(this.channelSplitter);
|
|
2236
|
-
this.channelAnalysers.clear();
|
|
2237
|
-
for (let i = 0; i < splitCount; i++) {
|
|
2238
|
-
const analyser = ctx.createAnalyser();
|
|
2239
|
-
analyser.fftSize = 64;
|
|
2240
|
-
this.channelSplitter.connect(analyser, i);
|
|
2241
|
-
this.channelAnalysers.set(i + 1, analyser);
|
|
2242
|
-
}
|
|
2243
|
-
return this.channelSplitter;
|
|
2244
|
-
} catch (e) {
|
|
2245
|
-
console.warn("Could not set up multi-channel splitter:", e);
|
|
2246
|
-
return null;
|
|
2247
|
-
}
|
|
2248
|
-
}
|
|
2249
|
-
setupNamedAnalysers(ctx, inputs) {
|
|
2250
|
-
this.namedAnalyserMap.clear();
|
|
2251
|
-
this.namedGainMap.clear();
|
|
2252
|
-
if (!this.channelSplitter) return;
|
|
2253
|
-
inputs.forEach((input) => {
|
|
2254
|
-
if (input.busType !== "input" || !this.channelSplitter) return;
|
|
2255
|
-
const analyser = ctx.createAnalyser();
|
|
2256
|
-
analyser.fftSize = 64;
|
|
2257
|
-
const gain = ctx.createGain();
|
|
2258
|
-
const rawGain = input.gain ?? 1;
|
|
2259
|
-
const safeGain = typeof rawGain === "number" && isFinite(rawGain) ? rawGain : 1;
|
|
2260
|
-
gain.gain.value = input.isMuted ? 0 : safeGain;
|
|
2261
|
-
const ch = input.channel ?? 1;
|
|
2262
|
-
let targetOutputIndex = 0;
|
|
2263
|
-
if (ch > 0 && ch <= 32) {
|
|
2264
|
-
targetOutputIndex = ch - 1;
|
|
2265
|
-
} else if (ch > 100) {
|
|
2266
|
-
targetOutputIndex = Math.floor(ch / 100) - 1;
|
|
2267
|
-
}
|
|
2268
|
-
try {
|
|
2269
|
-
this.channelSplitter.connect(gain, targetOutputIndex);
|
|
2270
|
-
gain.connect(analyser);
|
|
2271
|
-
this.namedAnalyserMap.set(input.id, analyser);
|
|
2272
|
-
this.namedGainMap.set(input.id, gain);
|
|
2273
|
-
} catch (e) {
|
|
2274
|
-
console.warn(`Could not connect bus ${input.name} to channel output ${targetOutputIndex}:`, e);
|
|
2275
|
-
}
|
|
2276
|
-
});
|
|
2277
|
-
}
|
|
2278
|
-
getChannelLevel(channelNum) {
|
|
2279
|
-
const analyser = this.channelAnalysers.get(channelNum);
|
|
2280
|
-
if (!analyser) return 0;
|
|
2281
|
-
return this.readAnalyserLevel(analyser);
|
|
2282
|
-
}
|
|
2283
|
-
getNamedBusLevel(busId, fallbackChannelNum) {
|
|
2284
|
-
const analyser = this.namedAnalyserMap.get(busId);
|
|
2285
|
-
if (analyser) {
|
|
2286
|
-
return this.readAnalyserLevel(analyser);
|
|
2287
|
-
}
|
|
2288
|
-
return this.getChannelLevel(fallbackChannelNum);
|
|
2289
|
-
}
|
|
2290
|
-
readAnalyserLevel(analyser) {
|
|
2291
|
-
const binCount = analyser.frequencyBinCount || 32;
|
|
2292
|
-
if (this.sharedAnalyserBuffer.length !== binCount) {
|
|
2293
|
-
this.sharedAnalyserBuffer = new Uint8Array(binCount);
|
|
2294
|
-
}
|
|
2295
|
-
const data = this.sharedAnalyserBuffer;
|
|
2296
|
-
analyser.getByteFrequencyData(data);
|
|
2297
|
-
let sum2 = 0;
|
|
2298
|
-
let maxVal = 0;
|
|
2299
|
-
for (let i = 0; i < data.length; i++) {
|
|
2300
|
-
const v = data[i];
|
|
2301
|
-
sum2 += v;
|
|
2302
|
-
if (v > maxVal) maxVal = v;
|
|
2303
|
-
}
|
|
2304
|
-
if (maxVal === 0) return 0;
|
|
2305
|
-
const maxNorm = maxVal / 255;
|
|
2306
|
-
const avgNorm = sum2 / data.length / 255;
|
|
2307
|
-
return Math.min(1, (maxNorm * 0.75 + avgNorm * 0.25) * 1.8);
|
|
2308
|
-
}
|
|
2309
|
-
updateMonitoring(ctx, masterGainNode, nodes, _connections, isNodeConnectedToOutput) {
|
|
2310
|
-
if (!this.channelSplitter) return;
|
|
2311
|
-
this.activeMonitorGains.forEach((gain, id2) => {
|
|
2312
|
-
try {
|
|
2313
|
-
gain.disconnect();
|
|
2314
|
-
} catch {
|
|
2315
|
-
}
|
|
2316
|
-
this.activeMonitorGains.delete(id2);
|
|
2317
|
-
});
|
|
2318
|
-
}
|
|
2319
|
-
cleanup() {
|
|
2320
|
-
this.activeMonitorGains.forEach((g) => {
|
|
2321
|
-
try {
|
|
2322
|
-
g.disconnect();
|
|
2323
|
-
} catch {
|
|
2324
|
-
}
|
|
2325
|
-
});
|
|
2326
|
-
this.activeMonitorGains.clear();
|
|
2327
|
-
this.namedAnalyserMap.clear();
|
|
2328
|
-
this.namedGainMap.clear();
|
|
2329
|
-
this.channelAnalysers.clear();
|
|
2330
|
-
this.channelSplitter = null;
|
|
2331
|
-
}
|
|
2332
|
-
};
|
|
2333
|
-
|
|
2334
|
-
// src/engine/core/l2_drivers/audioDeviceDriver.ts
|
|
2335
|
-
var STORAGE_KEY = "celestial_connections_config";
|
|
2336
|
-
function loadStoredConfig(defaultInputs, defaultDevId = "default", defaultOutId = "default") {
|
|
2337
|
-
try {
|
|
2338
|
-
const stored = localStorage.getItem(STORAGE_KEY);
|
|
2339
|
-
if (stored) {
|
|
2340
|
-
const parsed = JSON.parse(stored);
|
|
2341
|
-
return {
|
|
2342
|
-
selectedAudioDeviceId: parsed.selectedAudioDeviceId || defaultDevId,
|
|
2343
|
-
selectedAudioOutputDeviceId: parsed.selectedAudioOutputDeviceId || defaultOutId,
|
|
2344
|
-
namedAudioInputs: Array.isArray(parsed.namedAudioInputs) && parsed.namedAudioInputs.length > 0 ? parsed.namedAudioInputs.map((bus) => ({
|
|
2345
|
-
...bus,
|
|
2346
|
-
busType: bus.busType || (bus.outputChannels ? "output" : "input")
|
|
2347
|
-
})) : defaultInputs,
|
|
2348
|
-
selectedMidiDeviceId: null,
|
|
2349
|
-
midiConfigs: {}
|
|
2350
|
-
};
|
|
2351
|
-
}
|
|
2352
|
-
} catch (e) {
|
|
2353
|
-
console.warn("Could not read connections config from storage:", e);
|
|
2354
|
-
}
|
|
2355
|
-
return {
|
|
2356
|
-
selectedAudioDeviceId: defaultDevId,
|
|
2357
|
-
selectedAudioOutputDeviceId: defaultOutId,
|
|
2358
|
-
namedAudioInputs: defaultInputs,
|
|
2359
|
-
selectedMidiDeviceId: null,
|
|
2360
|
-
midiConfigs: {}
|
|
2361
|
-
};
|
|
2362
|
-
}
|
|
2363
|
-
function saveStoredConfig(config) {
|
|
2364
|
-
try {
|
|
2365
|
-
localStorage.setItem(STORAGE_KEY, JSON.stringify(config));
|
|
2366
|
-
} catch (e) {
|
|
2367
|
-
console.warn("Could not save connections config:", e);
|
|
2368
|
-
}
|
|
2369
|
-
}
|
|
2370
|
-
async function enumerateSystemAudioDevices() {
|
|
2371
|
-
if (typeof navigator === "undefined" || !navigator.mediaDevices?.enumerateDevices) {
|
|
2372
|
-
return {
|
|
2373
|
-
inputs: [
|
|
2374
|
-
{ deviceId: "default", label: "Default System Audio Input", groupId: "", kind: "audioinput" }
|
|
2375
|
-
],
|
|
2376
|
-
outputs: [
|
|
2377
|
-
{ deviceId: "default", label: "Default System Audio Output", groupId: "", kind: "audiooutput" }
|
|
2378
|
-
]
|
|
2379
|
-
};
|
|
2380
|
-
}
|
|
2381
|
-
try {
|
|
2382
|
-
const devices = await navigator.mediaDevices.enumerateDevices();
|
|
2383
|
-
const inputs = devices.filter((d) => d.kind === "audioinput").map((d, index) => ({
|
|
2384
|
-
deviceId: d.deviceId || `audioinput-${index}`,
|
|
2385
|
-
label: d.label || (index === 0 ? "Default Audio Input / Mic" : `Hardware Audio Input ${index + 1}`),
|
|
2386
|
-
groupId: d.groupId || "",
|
|
2387
|
-
kind: "audioinput"
|
|
2388
|
-
}));
|
|
2389
|
-
const rawOutputs = devices.filter((d) => d.kind === "audiooutput").map((d, index) => ({
|
|
2390
|
-
deviceId: d.deviceId || `audiooutput-${index}`,
|
|
2391
|
-
label: d.label || (index === 0 ? "Default System Audio Output" : `Hardware Audio Output ${index + 1}`),
|
|
2392
|
-
groupId: d.groupId || "",
|
|
2393
|
-
kind: "audiooutput"
|
|
2394
|
-
}));
|
|
2395
|
-
if (inputs.length === 0) {
|
|
2396
|
-
inputs.push({ deviceId: "default", label: "Default System Audio Input / Interface", groupId: "", kind: "audioinput" });
|
|
2397
|
-
}
|
|
2398
|
-
const outputs = [...rawOutputs];
|
|
2399
|
-
inputs.forEach((input) => {
|
|
2400
|
-
if (!input.label) return;
|
|
2401
|
-
const isNotGeneric = !input.label.toLowerCase().startsWith("default") && !input.label.toLowerCase().startsWith("hardware audio input");
|
|
2402
|
-
if (isNotGeneric) {
|
|
2403
|
-
const alreadyInOutputs = outputs.some(
|
|
2404
|
-
(o) => o.groupId === input.groupId || o.label.toLowerCase().includes(input.label.toLowerCase().replace(/input|mic/i, "").trim())
|
|
2405
|
-
);
|
|
2406
|
-
if (!alreadyInOutputs) {
|
|
2407
|
-
outputs.push({
|
|
2408
|
-
deviceId: input.deviceId,
|
|
2409
|
-
label: `${input.label} (Hardware Outputs / Monitors)`,
|
|
2410
|
-
groupId: input.groupId,
|
|
2411
|
-
kind: "audiooutput",
|
|
2412
|
-
isAutoPaired: true
|
|
2413
|
-
});
|
|
2414
|
-
}
|
|
2415
|
-
}
|
|
2416
|
-
});
|
|
2417
|
-
if (outputs.length === 0) {
|
|
2418
|
-
outputs.push(
|
|
2419
|
-
{ deviceId: "default", label: "Default System Audio Output (Speakers / Headphones)", groupId: "", kind: "audiooutput" },
|
|
2420
|
-
{ deviceId: "communications", label: "Communications Audio Output", groupId: "", kind: "audiooutput" }
|
|
2421
|
-
);
|
|
2422
|
-
}
|
|
2423
|
-
return { inputs, outputs };
|
|
2424
|
-
} catch (e) {
|
|
2425
|
-
console.warn("Failed to enumerate audio devices:", e);
|
|
2426
|
-
return {
|
|
2427
|
-
inputs: [
|
|
2428
|
-
{ deviceId: "default", label: "Default Audio Input", groupId: "", kind: "audioinput" }
|
|
2429
|
-
],
|
|
2430
|
-
outputs: [
|
|
2431
|
-
{ deviceId: "default", label: "Default Audio Output", groupId: "", kind: "audiooutput" }
|
|
2432
|
-
]
|
|
2433
|
-
};
|
|
2434
|
-
}
|
|
2435
|
-
}
|
|
2436
|
-
|
|
2437
|
-
// src/engine/core/l2_drivers/audioStreamDriver.ts
|
|
2438
|
-
async function acquireAudioInputStream(targetDeviceId) {
|
|
2439
|
-
if (typeof window === "undefined" || !navigator.mediaDevices?.getUserMedia) {
|
|
2440
|
-
return null;
|
|
2441
|
-
}
|
|
2442
|
-
const constraints = {
|
|
2443
|
-
audio: {
|
|
2444
|
-
...targetDeviceId && targetDeviceId !== "default" ? { deviceId: { exact: targetDeviceId } } : {},
|
|
2445
|
-
echoCancellation: false,
|
|
2446
|
-
noiseSuppression: false,
|
|
2447
|
-
autoGainControl: false,
|
|
2448
|
-
channelCount: { ideal: 32 }
|
|
2449
|
-
},
|
|
2450
|
-
video: false
|
|
2451
|
-
};
|
|
2452
|
-
const mediaStream = await navigator.mediaDevices.getUserMedia(constraints);
|
|
2453
|
-
let detectedTrackChannelCount = 2;
|
|
2454
|
-
const track = mediaStream.getAudioTracks()[0];
|
|
2455
|
-
if (track) {
|
|
2456
|
-
const settings = track.getSettings();
|
|
2457
|
-
const capabilities = track.getCapabilities ? track.getCapabilities() : {};
|
|
2458
|
-
const count = settings.channelCount || capabilities?.channelCount?.max || 2;
|
|
2459
|
-
detectedTrackChannelCount = Math.max(2, count);
|
|
2460
|
-
}
|
|
2461
|
-
return { mediaStream, detectedTrackChannelCount };
|
|
2462
|
-
}
|
|
2463
|
-
function stopAudioMediaStream(stream) {
|
|
2464
|
-
if (stream) {
|
|
2465
|
-
stream.getTracks().forEach((t) => t.stop());
|
|
2466
|
-
}
|
|
2467
|
-
}
|
|
2468
|
-
|
|
2469
|
-
// src/engine/functions/componentSocketRegistry.ts
|
|
2470
|
-
function getComponentSocketConstraint(targetNode, targetPort) {
|
|
2471
|
-
if (targetNode.type === "combiner" || targetNode.type === "multiplexer") {
|
|
2472
|
-
const sigType = targetNode.signalType;
|
|
2473
|
-
if (sigType === "component") {
|
|
2474
|
-
return {
|
|
2475
|
-
allowedNodeTypes: ["container"],
|
|
2476
|
-
allowedContainerTypes: ["audio"],
|
|
2477
|
-
description: "Component Combiner/Multiplexer ONLY accepts Audio Container nodes"
|
|
2478
|
-
};
|
|
2479
|
-
}
|
|
2480
|
-
}
|
|
2481
|
-
if (targetNode.type === "module") {
|
|
2482
|
-
if (targetPort && targetPort.includes("comp")) {
|
|
2483
|
-
return {
|
|
2484
|
-
allowedNodeTypes: ["container"],
|
|
2485
|
-
allowedContainerTypes: ["audio"],
|
|
2486
|
-
description: "Component input socket accepts Audio Container components"
|
|
2487
|
-
};
|
|
2488
|
-
}
|
|
2489
|
-
}
|
|
2490
|
-
return null;
|
|
2491
|
-
}
|
|
2492
|
-
function validateComponentSocketConnection(fromNode, constraint) {
|
|
2493
|
-
if (!constraint.allowedNodeTypes.includes(fromNode.type)) {
|
|
2494
|
-
return {
|
|
2495
|
-
isValid: false,
|
|
2496
|
-
reason: `Socket Constraint Rejection: Target requires node of type [${constraint.allowedNodeTypes.join(
|
|
2497
|
-
", "
|
|
2498
|
-
)}], but source is '${fromNode.type}'`
|
|
2499
|
-
};
|
|
2500
|
-
}
|
|
2501
|
-
if (fromNode.type === "container") {
|
|
2502
|
-
const cNode = fromNode;
|
|
2503
|
-
const cType = cNode.containerType;
|
|
2504
|
-
if (constraint.allowedContainerTypes && !constraint.allowedContainerTypes.includes(cType)) {
|
|
2505
|
-
return {
|
|
2506
|
-
isValid: false,
|
|
2507
|
-
reason: `Socket Constraint Rejection: Target requires container of type [${constraint.allowedContainerTypes.join(
|
|
2508
|
-
", "
|
|
2509
|
-
)}], but source is '${cType}' container`
|
|
2510
|
-
};
|
|
2511
|
-
}
|
|
2512
|
-
if (cType === "audio" && constraint.allowedAudioFormats) {
|
|
2513
|
-
const srcFormat = cNode.audioFormat || "mono";
|
|
2514
|
-
if (!constraint.allowedAudioFormats.includes(srcFormat)) {
|
|
2515
|
-
return {
|
|
2516
|
-
isValid: false,
|
|
2517
|
-
reason: `Socket Constraint Rejection: Stereo Sampler only accepts Stereo Audio Containers (source is '${srcFormat}')`
|
|
2518
|
-
};
|
|
2519
|
-
}
|
|
2520
|
-
}
|
|
2521
|
-
}
|
|
2522
|
-
return { isValid: true };
|
|
2523
|
-
}
|
|
2524
|
-
|
|
2525
|
-
// src/engine/functions/effectLogic.ts
|
|
2526
|
-
function getActiveEffectsForWire(conn, allNodes) {
|
|
2527
|
-
return getEffectsAffectingWire(conn, allNodes);
|
|
2528
|
-
}
|
|
2529
|
-
function getActiveEffectsForNodeWires(sourceNodeId, connections, allNodes) {
|
|
2530
|
-
const outgoing = connections.filter((c) => c.fromNodeId === sourceNodeId);
|
|
2531
|
-
return outgoing.map((conn) => ({
|
|
2532
|
-
connection: conn,
|
|
2533
|
-
effects: getEffectsAffectingWire(conn, allNodes)
|
|
2534
|
-
}));
|
|
2535
|
-
}
|
|
2536
|
-
function getActiveEffectsForNode(target, allNodes, connections = []) {
|
|
2537
|
-
const relevantConns = connections.filter(
|
|
2538
|
-
(c) => c.fromNodeId === target.id || c.toNodeId === target.id
|
|
2539
|
-
);
|
|
2540
|
-
const effectsMap = /* @__PURE__ */ new Map();
|
|
2541
|
-
relevantConns.forEach((conn) => {
|
|
2542
|
-
const effs = getEffectsAffectingWire(conn, allNodes);
|
|
2543
|
-
effs.forEach((e) => effectsMap.set(e.id, e));
|
|
2544
|
-
});
|
|
2545
|
-
return Array.from(effectsMap.values());
|
|
2546
|
-
}
|
|
2547
|
-
|
|
2548
|
-
// src/engine/functions/triggerLogic.ts
|
|
2549
|
-
function getTriggerStepDuration(node) {
|
|
2550
|
-
const mode = node.divisionMode || "every_beat";
|
|
2551
|
-
const divisions = Math.max(2, Math.min(64, node.divisionsPerBeat || 4));
|
|
2552
|
-
switch (mode) {
|
|
2553
|
-
case "every_bar":
|
|
2554
|
-
return { stepDuration: 4, totalSteps: 1, divisionsPerBeat: 1 };
|
|
2555
|
-
case "every_beat":
|
|
2556
|
-
return { stepDuration: 1, totalSteps: 4, divisionsPerBeat: 1 };
|
|
2557
|
-
case "divisions":
|
|
2558
|
-
return {
|
|
2559
|
-
stepDuration: 1 / divisions,
|
|
2560
|
-
totalSteps: 4 * divisions,
|
|
2561
|
-
divisionsPerBeat: divisions
|
|
2562
|
-
};
|
|
2563
|
-
case "4_4":
|
|
2564
|
-
return { stepDuration: 1, totalSteps: 4, divisionsPerBeat: 1 };
|
|
2565
|
-
case "2_4":
|
|
2566
|
-
return { stepDuration: 1, totalSteps: 2, divisionsPerBeat: 1 };
|
|
2567
|
-
case "16th":
|
|
2568
|
-
return { stepDuration: 0.25, totalSteps: 16, divisionsPerBeat: 4 };
|
|
2569
|
-
case "32nd":
|
|
2570
|
-
return { stepDuration: 0.125, totalSteps: 16, divisionsPerBeat: 8 };
|
|
2571
|
-
case "64th":
|
|
2572
|
-
return { stepDuration: 0.0625, totalSteps: 16, divisionsPerBeat: 16 };
|
|
2573
|
-
case "selected_beats":
|
|
2574
|
-
return { stepDuration: node.intervalBeats || 1, totalSteps: node.stepsPerCycle || 4, divisionsPerBeat: 1 };
|
|
2575
|
-
case "custom":
|
|
2576
|
-
return {
|
|
2577
|
-
stepDuration: 1 / divisions,
|
|
2578
|
-
totalSteps: 4 * divisions,
|
|
2579
|
-
divisionsPerBeat: divisions
|
|
2580
|
-
};
|
|
2581
|
-
default:
|
|
2582
|
-
return { stepDuration: node.intervalBeats || 1, totalSteps: 4, divisionsPerBeat: 1 };
|
|
2583
|
-
}
|
|
2584
|
-
}
|
|
2585
|
-
function shouldTriggerFireAtClock(node, prevBeat, currBeat) {
|
|
2586
|
-
if (!node.active) return false;
|
|
2587
|
-
const isFractions = node.triggerType === "beat_fractions" || node.divisionMode === "divisions" || node.divisionMode === "custom";
|
|
2588
|
-
if (isFractions) {
|
|
2589
|
-
const divs = Math.max(2, Math.min(64, node.divisionsPerBeat || 64));
|
|
2590
|
-
const stepDuration = 1 / divs;
|
|
2591
|
-
const prevStep2 = Math.floor(prevBeat / stepDuration);
|
|
2592
|
-
const currStep2 = Math.floor(currBeat / stepDuration);
|
|
2593
|
-
if (currStep2 <= prevStep2) return false;
|
|
2594
|
-
const fractionIndex = (currStep2 % divs + divs) % divs;
|
|
2595
|
-
if (node.activeFractions && node.activeFractions.length > 0) {
|
|
2596
|
-
const fracIndex = fractionIndex % node.activeFractions.length;
|
|
2597
|
-
return !!node.activeFractions[fracIndex];
|
|
2598
|
-
}
|
|
2599
|
-
return true;
|
|
2600
|
-
}
|
|
2601
|
-
const mode = node.divisionMode || "every_beat";
|
|
2602
|
-
if (mode === "every_bar") {
|
|
2603
|
-
const prevBar = Math.floor(prevBeat / 4);
|
|
2604
|
-
const currBar = Math.floor(currBeat / 4);
|
|
2605
|
-
return currBar > prevBar;
|
|
2606
|
-
}
|
|
2607
|
-
const prevStep = Math.floor(prevBeat);
|
|
2608
|
-
const currStep = Math.floor(currBeat);
|
|
2609
|
-
if (currStep <= prevStep) return false;
|
|
2610
|
-
const beatIndex = (currStep % 4 + 4) % 4;
|
|
2611
|
-
if (node.activeSteps && node.activeSteps.length > 0) {
|
|
2612
|
-
const maskIndex = beatIndex % node.activeSteps.length;
|
|
2613
|
-
return !!node.activeSteps[maskIndex];
|
|
2614
|
-
}
|
|
2615
|
-
return true;
|
|
2616
|
-
}
|
|
2617
|
-
function getDefaultActiveSteps(mode, totalSteps) {
|
|
2618
|
-
switch (mode) {
|
|
2619
|
-
case "every_bar":
|
|
2620
|
-
return [true];
|
|
2621
|
-
case "every_beat":
|
|
2622
|
-
return [true, true, true, true];
|
|
2623
|
-
case "divisions":
|
|
2624
|
-
return [true, true, true, true];
|
|
2625
|
-
default:
|
|
2626
|
-
return Array(totalSteps).fill(true);
|
|
2627
|
-
}
|
|
2628
|
-
}
|
|
2629
|
-
function getDefaultActiveFractions(divisions) {
|
|
2630
|
-
return Array(divisions).fill(true);
|
|
2631
|
-
}
|
|
2632
|
-
|
|
2633
|
-
// src/engine/functions/clientWavEncoder.ts
|
|
2634
|
-
function encodeFloat32ToWavBase64(sampleRate, numChannels, channelData) {
|
|
2635
|
-
const numSamples = channelData[0].length;
|
|
2636
|
-
const bytesPerSample = 2;
|
|
2637
|
-
const blockAlign = numChannels * bytesPerSample;
|
|
2638
|
-
const byteRate = sampleRate * blockAlign;
|
|
2639
|
-
const dataSize = numSamples * blockAlign;
|
|
2640
|
-
const arrayBuffer = new ArrayBuffer(44 + dataSize);
|
|
2641
|
-
const view = new DataView(arrayBuffer);
|
|
2642
|
-
function writeString(offset2, string3) {
|
|
2643
|
-
for (let i = 0; i < string3.length; i++) {
|
|
2644
|
-
view.setUint8(offset2 + i, string3.charCodeAt(i));
|
|
2645
|
-
}
|
|
2646
|
-
}
|
|
2647
|
-
writeString(0, "RIFF");
|
|
2648
|
-
view.setUint32(4, 36 + dataSize, true);
|
|
2649
|
-
writeString(8, "WAVE");
|
|
2650
|
-
writeString(12, "fmt ");
|
|
2651
|
-
view.setUint32(16, 16, true);
|
|
2652
|
-
view.setUint16(20, 1, true);
|
|
2653
|
-
view.setUint16(22, numChannels, true);
|
|
2654
|
-
view.setUint32(24, sampleRate, true);
|
|
2655
|
-
view.setUint32(28, byteRate, true);
|
|
2656
|
-
view.setUint16(32, blockAlign, true);
|
|
2657
|
-
view.setUint16(34, 16, true);
|
|
2658
|
-
writeString(36, "data");
|
|
2659
|
-
view.setUint32(40, dataSize, true);
|
|
2660
|
-
let offset = 44;
|
|
2661
|
-
for (let i = 0; i < numSamples; i++) {
|
|
2662
|
-
for (let ch = 0; ch < numChannels; ch++) {
|
|
2663
|
-
const sample = Math.max(-1, Math.min(1, channelData[ch][i] || 0));
|
|
2664
|
-
const intSample = sample < 0 ? sample * 32768 : sample * 32767;
|
|
2665
|
-
view.setInt16(offset, Math.floor(intSample), true);
|
|
2666
|
-
offset += 2;
|
|
2667
|
-
}
|
|
2668
|
-
}
|
|
2669
|
-
const bytes = new Uint8Array(arrayBuffer);
|
|
2670
|
-
let binary = "";
|
|
2671
|
-
const chunkSize = 8192;
|
|
2672
|
-
for (let i = 0; i < bytes.length; i += chunkSize) {
|
|
2673
|
-
const chunk2 = bytes.subarray(i, i + chunkSize);
|
|
2674
|
-
binary += String.fromCharCode.apply(null, Array.from(chunk2));
|
|
2675
|
-
}
|
|
2676
|
-
return btoa(binary);
|
|
2677
|
-
}
|
|
2678
|
-
function generateWavBase64FromWaveform(peaks, durationSec = 2, isMono = false) {
|
|
2679
|
-
const sampleRate = 44100;
|
|
2680
|
-
const numSamples = Math.floor(sampleRate * durationSec);
|
|
2681
|
-
const numChannels = isMono ? 1 : 2;
|
|
2682
|
-
const chL = new Float32Array(numSamples);
|
|
2683
|
-
const chR = isMono ? chL : new Float32Array(numSamples);
|
|
2684
|
-
const peaksLen = peaks.length || 32;
|
|
2685
|
-
for (let i = 0; i < numSamples; i++) {
|
|
2686
|
-
const progress = i / numSamples;
|
|
2687
|
-
const peakIdx = Math.min(peaksLen - 1, Math.floor(progress * peaksLen));
|
|
2688
|
-
const amp = Math.max(0.05, Math.min(1, peaks[peakIdx] || 0.3));
|
|
2689
|
-
const t = i / sampleRate;
|
|
2690
|
-
const freq = 120 + Math.sin(progress * Math.PI) * 40;
|
|
2691
|
-
const val = Math.sin(2 * Math.PI * freq * t) * amp * Math.exp(-progress * 1.5);
|
|
2692
|
-
chL[i] = val;
|
|
2693
|
-
if (!isMono) {
|
|
2694
|
-
chR[i] = val * (0.9 + Math.sin(t * 5) * 0.1);
|
|
2695
|
-
}
|
|
2696
|
-
}
|
|
2697
|
-
return encodeFloat32ToWavBase64(sampleRate, numChannels, isMono ? [chL] : [chL, chR]);
|
|
2698
|
-
}
|
|
2699
|
-
|
|
2700
|
-
// src/engine/functions/sampleContainerExtractor.ts
|
|
2701
|
-
var GM_DRUM_NOTES = [
|
|
2702
|
-
36,
|
|
2703
|
-
// C1: Bass Drum 1
|
|
2704
|
-
38,
|
|
2705
|
-
// D1: Acoustic Snare
|
|
2706
|
-
42,
|
|
2707
|
-
// F#1: Closed Hi-Hat
|
|
2708
|
-
46,
|
|
2709
|
-
// A#1: Open Hi-Hat
|
|
2710
|
-
37,
|
|
2711
|
-
// C#1: Side Stick
|
|
2712
|
-
39,
|
|
2713
|
-
// D#1: Hand Clap
|
|
2714
|
-
41,
|
|
2715
|
-
// F1: Low Floor Tom
|
|
2716
|
-
43,
|
|
2717
|
-
// G1: High Floor Tom
|
|
2718
|
-
45,
|
|
2719
|
-
// A1: Low Tom
|
|
2720
|
-
47,
|
|
2721
|
-
// B1: Low-Mid Tom
|
|
2722
|
-
48,
|
|
2723
|
-
// C2: High-Mid Tom
|
|
2724
|
-
50,
|
|
2725
|
-
// D2: High Tom
|
|
2726
|
-
49,
|
|
2727
|
-
// C#2: Crash Cymbal 1
|
|
2728
|
-
51,
|
|
2729
|
-
// D#2: Ride Cymbal 1
|
|
2730
|
-
52,
|
|
2731
|
-
// E2: Chinese Cymbal
|
|
2732
|
-
53
|
|
2733
|
-
// F2: Ride Bell
|
|
2734
|
-
];
|
|
2735
|
-
function getDefaultPadMidiNote(index) {
|
|
2736
|
-
if (index < GM_DRUM_NOTES.length) {
|
|
2737
|
-
return GM_DRUM_NOTES[index];
|
|
2738
|
-
}
|
|
2739
|
-
return 36 + index % 48;
|
|
2740
|
-
}
|
|
2741
|
-
function extractSamplesFromConnectedContainers(targetNodeId, connections = [], allNodes = []) {
|
|
2742
|
-
const relevantConns = connections.filter(
|
|
2743
|
-
(c) => c.toNodeId === targetNodeId && (c.toPort === "store_in" || c.toPort === "packet_in" || c.toSocketId === "store_in" || c.toSocketId === "packet_in" || c.signalType === "audio_packet" || c.toSocketIndex === 0)
|
|
2744
|
-
);
|
|
2745
|
-
const connectedContainerIds = new Set(relevantConns.map((c) => c.fromNodeId));
|
|
2746
|
-
const connectedContainers = allNodes.filter(
|
|
2747
|
-
(n) => n.type === "container" && n.containerType === "audio" && connectedContainerIds.has(n.id)
|
|
2748
|
-
);
|
|
2749
|
-
const samples = [];
|
|
2750
|
-
connectedContainers.forEach((container) => {
|
|
2751
|
-
const containerFormat = container.audioFormat === "mono" ? "mono" : "stereo";
|
|
2752
|
-
if (container.audioTrack) {
|
|
2753
|
-
const clip = container.audioTrack;
|
|
2754
|
-
const clipId = clip.id || `clip-${container.id}`;
|
|
2755
|
-
samples.push({
|
|
2756
|
-
id: `${container.id}_${clipId}`,
|
|
2757
|
-
clipId,
|
|
2758
|
-
name: clip.name || container.name || "Audio Container",
|
|
2759
|
-
containerId: container.id,
|
|
2760
|
-
containerName: container.name || "Audio Container",
|
|
2761
|
-
audioFormat: containerFormat,
|
|
2762
|
-
sampleType: clip.sampleType || "kick",
|
|
2763
|
-
customAudioUrl: clip.customAudioUrl,
|
|
2764
|
-
waveformData: clip.waveformData,
|
|
2765
|
-
audioTrack: {
|
|
2766
|
-
...clip,
|
|
2767
|
-
id: clipId,
|
|
2768
|
-
name: clip.name || container.name || "Audio Container"
|
|
2769
|
-
}
|
|
2770
|
-
});
|
|
2771
|
-
}
|
|
2772
|
-
});
|
|
2773
|
-
return { samples, connectedContainers };
|
|
2774
|
-
}
|
|
2775
|
-
|
|
2776
|
-
// src/engine/functions/midiDeviceRegistry.ts
|
|
2777
|
-
var CUSTOM_NAMES_KEY = "celestial_midi_custom_names";
|
|
2778
|
-
var VIRTUAL_DEVS_KEY = "celestial_midi_virtual_devices";
|
|
2779
|
-
var NAMED_PROFILES_KEY = "celestial_midi_named_profiles";
|
|
2780
|
-
var DEFAULT_NAMED_MIDI_PROFILES = [
|
|
2781
|
-
{
|
|
2782
|
-
id: "midi-profile-1",
|
|
2783
|
-
name: "Main Stage Synth / Keyboard",
|
|
2784
|
-
sourceDeviceId: "virtual-keyboard",
|
|
2785
|
-
channel: 0,
|
|
2786
|
-
color: "#38bdf8",
|
|
2787
|
-
enabled: true
|
|
2788
|
-
},
|
|
2789
|
-
{
|
|
2790
|
-
id: "midi-profile-2",
|
|
2791
|
-
name: "External MIDI Controller / Pads",
|
|
2792
|
-
sourceDeviceId: "all",
|
|
2793
|
-
channel: 1,
|
|
2794
|
-
color: "#f59e0b",
|
|
2795
|
-
enabled: true
|
|
2796
|
-
}
|
|
2797
|
-
];
|
|
2798
|
-
function getCustomMidiNames() {
|
|
2799
|
-
if (typeof window === "undefined") return {};
|
|
2800
|
-
try {
|
|
2801
|
-
const raw = localStorage.getItem(CUSTOM_NAMES_KEY);
|
|
2802
|
-
return raw ? JSON.parse(raw) : {};
|
|
2803
|
-
} catch {
|
|
2804
|
-
return {};
|
|
2805
|
-
}
|
|
2806
|
-
}
|
|
2807
|
-
function saveCustomMidiNames(names) {
|
|
2808
|
-
if (typeof window === "undefined") return;
|
|
2809
|
-
localStorage.setItem(CUSTOM_NAMES_KEY, JSON.stringify(names));
|
|
2810
|
-
}
|
|
2811
|
-
function getCustomMidiName(id2) {
|
|
2812
|
-
return getCustomMidiNames()[id2];
|
|
2813
|
-
}
|
|
2814
|
-
function setCustomMidiName(id2, name) {
|
|
2815
|
-
const current = getCustomMidiNames();
|
|
2816
|
-
if (!name.trim()) {
|
|
2817
|
-
delete current[id2];
|
|
2818
|
-
} else {
|
|
2819
|
-
current[id2] = name.trim();
|
|
2820
|
-
}
|
|
2821
|
-
saveCustomMidiNames(current);
|
|
2822
|
-
}
|
|
2823
|
-
function getVirtualMidiDevices() {
|
|
2824
|
-
if (typeof window === "undefined") return [];
|
|
2825
|
-
try {
|
|
2826
|
-
const raw = localStorage.getItem(VIRTUAL_DEVS_KEY);
|
|
2827
|
-
return raw ? JSON.parse(raw) : [];
|
|
2828
|
-
} catch {
|
|
2829
|
-
return [];
|
|
2830
|
-
}
|
|
2831
|
-
}
|
|
2832
|
-
function saveVirtualMidiDevices(devices) {
|
|
2833
|
-
if (typeof window === "undefined") return;
|
|
2834
|
-
localStorage.setItem(VIRTUAL_DEVS_KEY, JSON.stringify(devices));
|
|
2835
|
-
}
|
|
2836
|
-
function createVirtualMidiDevice(name) {
|
|
2837
|
-
const devices = getVirtualMidiDevices();
|
|
2838
|
-
const newDevice = {
|
|
2839
|
-
id: `virtual-midi-dev-${Date.now()}`,
|
|
2840
|
-
name: name.trim() || `Virtual MIDI Port ${devices.length + 1}`,
|
|
2841
|
-
manufacturer: "Celestial Studio (Virtual)",
|
|
2842
|
-
state: "connected"
|
|
2843
|
-
};
|
|
2844
|
-
devices.push(newDevice);
|
|
2845
|
-
saveVirtualMidiDevices(devices);
|
|
2846
|
-
return newDevice;
|
|
2847
|
-
}
|
|
2848
|
-
function deleteVirtualMidiDevice(id2) {
|
|
2849
|
-
const devices = getVirtualMidiDevices();
|
|
2850
|
-
const filtered = devices.filter((d) => d.id !== id2);
|
|
2851
|
-
saveVirtualMidiDevices(filtered);
|
|
2852
|
-
}
|
|
2853
|
-
function getNamedMidiProfiles() {
|
|
2854
|
-
if (typeof window === "undefined") return DEFAULT_NAMED_MIDI_PROFILES;
|
|
2855
|
-
try {
|
|
2856
|
-
const raw = localStorage.getItem(NAMED_PROFILES_KEY);
|
|
2857
|
-
if (!raw) {
|
|
2858
|
-
localStorage.setItem(NAMED_PROFILES_KEY, JSON.stringify(DEFAULT_NAMED_MIDI_PROFILES));
|
|
2859
|
-
return DEFAULT_NAMED_MIDI_PROFILES;
|
|
2860
|
-
}
|
|
2861
|
-
return JSON.parse(raw);
|
|
2862
|
-
} catch {
|
|
2863
|
-
return DEFAULT_NAMED_MIDI_PROFILES;
|
|
2864
|
-
}
|
|
2865
|
-
}
|
|
2866
|
-
function saveNamedMidiProfiles(profiles) {
|
|
2867
|
-
if (typeof window === "undefined") return;
|
|
2868
|
-
localStorage.setItem(NAMED_PROFILES_KEY, JSON.stringify(profiles));
|
|
2869
|
-
}
|
|
2870
|
-
function addNamedMidiProfile(profile) {
|
|
2871
|
-
const profiles = getNamedMidiProfiles();
|
|
2872
|
-
const newProfile = {
|
|
2873
|
-
...profile,
|
|
2874
|
-
id: `midi-profile-${Date.now()}-${Math.random().toString(36).substr(2, 4)}`
|
|
2875
|
-
};
|
|
2876
|
-
profiles.push(newProfile);
|
|
2877
|
-
saveNamedMidiProfiles(profiles);
|
|
2878
|
-
return newProfile;
|
|
2879
|
-
}
|
|
2880
|
-
function updateNamedMidiProfile(updated) {
|
|
2881
|
-
const profiles = getNamedMidiProfiles();
|
|
2882
|
-
const index = profiles.findIndex((p) => p.id === updated.id);
|
|
2883
|
-
if (index !== -1) {
|
|
2884
|
-
profiles[index] = updated;
|
|
2885
|
-
saveNamedMidiProfiles(profiles);
|
|
2886
|
-
}
|
|
2887
|
-
}
|
|
2888
|
-
function deleteNamedMidiProfile(id2) {
|
|
2889
|
-
const profiles = getNamedMidiProfiles();
|
|
2890
|
-
const filtered = profiles.filter((p) => p.id !== id2);
|
|
2891
|
-
saveNamedMidiProfiles(filtered);
|
|
2892
|
-
}
|
|
2893
|
-
function getResolvedMidiDevices(physicalDevices) {
|
|
2894
|
-
const customNames = getCustomMidiNames();
|
|
2895
|
-
const virtualDevices = getVirtualMidiDevices();
|
|
2896
|
-
const namedProfiles = getNamedMidiProfiles();
|
|
2897
|
-
const builtInVirtualKeyboard = {
|
|
2898
|
-
id: "virtual-keyboard",
|
|
2899
|
-
name: "Virtual MIDI Keyboard",
|
|
2900
|
-
manufacturer: "Celestial Studio (Built-in)",
|
|
2901
|
-
state: "connected"
|
|
2902
|
-
};
|
|
2903
|
-
const profileDevs = namedProfiles.map((p) => {
|
|
2904
|
-
const chLabel = !p.channel || p.channel === 0 ? "Omni" : `Ch ${p.channel}`;
|
|
2905
|
-
return {
|
|
2906
|
-
id: p.id,
|
|
2907
|
-
name: p.name,
|
|
2908
|
-
manufacturer: `Named Profile (${chLabel})`,
|
|
2909
|
-
state: "connected"
|
|
2910
|
-
};
|
|
2911
|
-
});
|
|
2912
|
-
const rawList = [...profileDevs, builtInVirtualKeyboard, ...physicalDevices, ...virtualDevices];
|
|
2913
|
-
const seenIds = /* @__PURE__ */ new Set();
|
|
2914
|
-
const uniqueDevices = [];
|
|
2915
|
-
for (const dev of rawList) {
|
|
2916
|
-
if (dev && dev.id && !seenIds.has(dev.id)) {
|
|
2917
|
-
seenIds.add(dev.id);
|
|
2918
|
-
uniqueDevices.push(dev);
|
|
2919
|
-
}
|
|
2920
|
-
}
|
|
2921
|
-
return uniqueDevices.map((dev) => ({
|
|
2922
|
-
...dev,
|
|
2923
|
-
name: customNames[dev.id] || dev.name
|
|
2924
|
-
}));
|
|
2925
|
-
}
|
|
2926
|
-
|
|
2927
|
-
// src/engine/functions/nodePerformanceTracker.ts
|
|
2928
|
-
var configuredPerfEngines = {};
|
|
2929
|
-
function configureNodePerformanceTracker(engines) {
|
|
2930
|
-
configuredPerfEngines = { ...configuredPerfEngines, ...engines };
|
|
2931
|
-
if (engines.synthEngine) {
|
|
2932
|
-
globalThis.__KLOKS_SYNTH_ENGINE__ = engines.synthEngine;
|
|
2933
|
-
globalThis.__QWNSR_SYNTH_ENGINE__ = engines.synthEngine;
|
|
2934
|
-
}
|
|
2935
|
-
}
|
|
2936
|
-
var synthEngine2 = new Proxy(
|
|
2937
|
-
{},
|
|
2938
|
-
{
|
|
2939
|
-
get(_target, prop) {
|
|
2940
|
-
const globalEngine = configuredPerfEngines.synthEngine || globalThis.__KLOKS_SYNTH_ENGINE__ || globalThis.__QWNSR_SYNTH_ENGINE__;
|
|
2941
|
-
if (globalEngine && typeof globalEngine[prop] === "function") {
|
|
2942
|
-
return globalEngine[prop].bind(globalEngine);
|
|
2943
|
-
}
|
|
2944
|
-
return () => true;
|
|
2945
|
-
}
|
|
2946
|
-
}
|
|
2947
|
-
);
|
|
2948
|
-
var smoothedLoads = /* @__PURE__ */ new Map();
|
|
2949
|
-
function calculateNodePerformance(nodes, connections, isPlaying, bpm) {
|
|
2950
|
-
const metrics = /* @__PURE__ */ new Map();
|
|
2951
|
-
let maxLoad = -1;
|
|
2952
|
-
let maxNodeId = null;
|
|
2953
|
-
let totalDspload = 0;
|
|
2954
|
-
const outgoingMap = /* @__PURE__ */ new Map();
|
|
2955
|
-
connections.forEach((c) => {
|
|
2956
|
-
outgoingMap.set(c.fromNodeId, (outgoingMap.get(c.fromNodeId) || 0) + 1);
|
|
2957
|
-
});
|
|
2958
|
-
const now = performance.now() * 1e-3;
|
|
2959
|
-
nodes.forEach((node) => {
|
|
2960
|
-
let rawLoad = 0;
|
|
2961
|
-
let voiceCount = 0;
|
|
2962
|
-
let detailLabel = "0% DSP";
|
|
2963
|
-
let dspStatus = "IDLE";
|
|
2964
|
-
const isActive = node.active !== false && !node.isMuted;
|
|
2965
|
-
if (!isActive) {
|
|
2966
|
-
rawLoad = 0;
|
|
2967
|
-
dspStatus = "OFFLINE";
|
|
2968
|
-
detailLabel = "MUTED / OFF";
|
|
2969
|
-
} else {
|
|
2970
|
-
const isConnected = synthEngine2.isNodeConnectedToOutput(node.id);
|
|
2971
|
-
if (node.type === "container") {
|
|
2972
|
-
const cNode = node;
|
|
2973
|
-
if (!isConnected) {
|
|
2974
|
-
rawLoad = 1;
|
|
2975
|
-
detailLabel = "NO OUTPUT";
|
|
2976
|
-
dspStatus = "IDLE";
|
|
2977
|
-
} else {
|
|
2978
|
-
const cType = cNode.containerType || "midi";
|
|
2979
|
-
if (cType === "midi") {
|
|
2980
|
-
const noteCount = cNode.pattern?.notes.length || 0;
|
|
2981
|
-
const synthType = cNode.synthPreset?.synthType || "poly";
|
|
2982
|
-
const baseTypeLoad = synthType === "drums" ? 22 : synthType === "lead" ? 18 : synthType === "bass" ? 14 : 15;
|
|
2983
|
-
let fxLoad = 0;
|
|
2984
|
-
if (cNode.synthPreset?.reverb && cNode.synthPreset.reverb > 0.05) fxLoad += 12;
|
|
2985
|
-
if (cNode.synthPreset?.delay && cNode.synthPreset.delay > 0.05) fxLoad += 10;
|
|
2986
|
-
if (cNode.synthPreset?.cutoff && cNode.synthPreset.cutoff < 14e3) fxLoad += 6;
|
|
2987
|
-
voiceCount = Math.min(16, Math.max(1, Math.ceil(noteCount * 0.4)));
|
|
2988
|
-
rawLoad = baseTypeLoad + fxLoad + voiceCount * 3.5;
|
|
2989
|
-
if (isPlaying) {
|
|
2990
|
-
const pulse = (Math.sin(now * (bpm / 60) * Math.PI * 2 + node.position[0]) + 1) * 0.5;
|
|
2991
|
-
rawLoad += pulse * 18;
|
|
2992
|
-
}
|
|
2993
|
-
} else if (cType === "audio") {
|
|
2994
|
-
const track = cNode.audioTrack;
|
|
2995
|
-
voiceCount = track ? 1 : 0;
|
|
2996
|
-
rawLoad = track ? 24 : 5;
|
|
2997
|
-
if (isPlaying) {
|
|
2998
|
-
const pulse = (Math.cos(now * 8 + node.position[2]) + 1) * 0.5;
|
|
2999
|
-
rawLoad += pulse * 22;
|
|
3000
|
-
}
|
|
3001
|
-
} else if (cType === "curve") {
|
|
3002
|
-
rawLoad = 12 + (isPlaying ? Math.sin(now * 5) * 8 : 0);
|
|
3003
|
-
}
|
|
3004
|
-
}
|
|
3005
|
-
} else if (node.type === "trigger") {
|
|
3006
|
-
const tNode = node;
|
|
3007
|
-
const interval = tNode.intervalBeats || 1;
|
|
3008
|
-
const divisions = tNode.divisionsPerBeat || 1;
|
|
3009
|
-
const rateFactor = divisions > 4 ? 28 : divisions > 1 ? 18 : interval < 0.5 ? 22 : 10;
|
|
3010
|
-
const outgoingCount = outgoingMap.get(node.id) || 0;
|
|
3011
|
-
rawLoad = rateFactor + outgoingCount * 6;
|
|
3012
|
-
if (isPlaying) {
|
|
3013
|
-
const tick = (Math.sin(now * (bpm / 30)) + 1) * 0.5;
|
|
3014
|
-
rawLoad += tick * 15;
|
|
3015
|
-
}
|
|
3016
|
-
} else if (node.type === "effect") {
|
|
3017
|
-
const eNode = node;
|
|
3018
|
-
const eType = eNode.effectType;
|
|
3019
|
-
const base = eType === "repeater" ? 22 : 26;
|
|
3020
|
-
rawLoad = base;
|
|
3021
|
-
if (isPlaying) {
|
|
3022
|
-
rawLoad += (Math.sin(now * 4 + node.position[0]) + 1) * 10;
|
|
3023
|
-
}
|
|
3024
|
-
}
|
|
3025
|
-
}
|
|
3026
|
-
rawLoad = Math.min(98, Math.max(0, rawLoad));
|
|
3027
|
-
const prev = smoothedLoads.get(node.id) || rawLoad;
|
|
3028
|
-
const smoothed = prev + (rawLoad - prev) * 0.15;
|
|
3029
|
-
smoothedLoads.set(node.id, smoothed);
|
|
3030
|
-
const finalLoad = Math.round(smoothed);
|
|
3031
|
-
if (dspStatus !== "OFFLINE") {
|
|
3032
|
-
if (finalLoad > 75) dspStatus = "PEAK";
|
|
3033
|
-
else if (finalLoad > 45) dspStatus = "HIGH";
|
|
3034
|
-
else if (finalLoad > 10) dspStatus = "ACTIVE";
|
|
3035
|
-
else dspStatus = "IDLE";
|
|
3036
|
-
}
|
|
3037
|
-
detailLabel = `${finalLoad}% DSP`;
|
|
3038
|
-
if (finalLoad > maxLoad && dspStatus !== "OFFLINE") {
|
|
3039
|
-
maxLoad = finalLoad;
|
|
3040
|
-
maxNodeId = node.id;
|
|
3041
|
-
}
|
|
3042
|
-
totalDspload += finalLoad;
|
|
3043
|
-
metrics.set(node.id, {
|
|
3044
|
-
nodeId: node.id,
|
|
3045
|
-
loadPercentage: finalLoad,
|
|
3046
|
-
isMaxNode: false,
|
|
3047
|
-
voiceCount,
|
|
3048
|
-
dspStatus,
|
|
3049
|
-
detailLabel
|
|
3050
|
-
});
|
|
3051
|
-
});
|
|
3052
|
-
if (maxNodeId && metrics.has(maxNodeId)) {
|
|
3053
|
-
const item = metrics.get(maxNodeId);
|
|
3054
|
-
if (item.loadPercentage > 5) {
|
|
3055
|
-
item.isMaxNode = true;
|
|
3056
|
-
}
|
|
3057
|
-
}
|
|
3058
|
-
return { metrics, maxNodeId, totalDspload };
|
|
3059
|
-
}
|
|
3060
316
|
|
|
3061
317
|
// src/index.ts
|
|
318
|
+
import {
|
|
319
|
+
createService,
|
|
320
|
+
createServiceDefinition
|
|
321
|
+
} from "@ultrst-armada/krnl";
|
|
3062
322
|
var StateLifecycleServiceDefinition = createServiceDefinition({
|
|
3063
323
|
id: "kloks.state.lifecycle",
|
|
3064
324
|
name: "StateLifecycleService",
|