From 633a26a273e79ed4449bf7cde3861c90c78ce6bf Mon Sep 17 00:00:00 2001 From: Deluan Date: Tue, 30 Dec 2025 17:29:03 -0500 Subject: [PATCH] refactor(plugins): update export wrappers to use `//go:wasmexport` for WebAssembly compatibility Signed-off-by: Deluan --- plugins/cmd/ndpgen/internal/generator_test.go | 6 +++--- .../ndpgen/internal/templates/capability.go.tmpl | 2 +- plugins/pdk/go/lifecycle/lifecycle.go | 2 +- plugins/pdk/go/metadata/metadata.go | 16 ++++++++-------- plugins/pdk/go/scheduler/scheduler.go | 2 +- plugins/pdk/go/scrobbler/scrobbler.go | 6 +++--- plugins/pdk/go/websocket/websocket.go | 8 ++++---- 7 files changed, 21 insertions(+), 21 deletions(-) diff --git a/plugins/cmd/ndpgen/internal/generator_test.go b/plugins/cmd/ndpgen/internal/generator_test.go index fe10fbc5e..c8355b014 100644 --- a/plugins/cmd/ndpgen/internal/generator_test.go +++ b/plugins/cmd/ndpgen/internal/generator_test.go @@ -752,7 +752,7 @@ type TestService interface { Expect(codeStr).To(ContainSubstring("impl.(ArtistBiographyProvider)")) // Check for export wrappers - Expect(codeStr).To(ContainSubstring("//export nd_get_artist_biography")) + Expect(codeStr).To(ContainSubstring("//go:wasmexport nd_get_artist_biography")) Expect(codeStr).To(ContainSubstring("func _NdGetArtistBiography()")) // Check for NotImplementedCode handling @@ -894,7 +894,7 @@ type TestService interface { Expect(codeStr).To(ContainSubstring("type ArtistInput struct")) // Check there are no export wrappers - Expect(codeStr).NotTo(ContainSubstring("//export")) + Expect(codeStr).NotTo(ContainSubstring("//go:wasmexport")) Expect(codeStr).NotTo(ContainSubstring("pdk.InputJSON")) }) }) @@ -941,7 +941,7 @@ type OnInitOutput struct { Expect(err).NotTo(HaveOccurred()) codeStr := string(code) - Expect(codeStr).To(ContainSubstring("//export nd_on_init")) + Expect(codeStr).To(ContainSubstring("//go:wasmexport nd_on_init")) Expect(codeStr).To(ContainSubstring("type InitProvider interface")) // Generate stub code diff --git a/plugins/cmd/ndpgen/internal/templates/capability.go.tmpl b/plugins/cmd/ndpgen/internal/templates/capability.go.tmpl index 11e424383..c90c55791 100644 --- a/plugins/cmd/ndpgen/internal/templates/capability.go.tmpl +++ b/plugins/cmd/ndpgen/internal/templates/capability.go.tmpl @@ -166,7 +166,7 @@ const NotImplementedCode int32 = -2 {{- /* Generate export wrappers */ -}} {{range .Capability.Methods}} -//export {{.ExportName}} +//go:wasmexport {{.ExportName}} func {{exportFunc .}}() int32 { if {{implVar .}} == nil { // Return standard code - host will skip this plugin gracefully diff --git a/plugins/pdk/go/lifecycle/lifecycle.go b/plugins/pdk/go/lifecycle/lifecycle.go index 271603083..7aa29901a 100644 --- a/plugins/pdk/go/lifecycle/lifecycle.go +++ b/plugins/pdk/go/lifecycle/lifecycle.go @@ -43,7 +43,7 @@ func Register(impl Lifecycle) { // The host recognizes this and skips the plugin gracefully. const NotImplementedCode int32 = -2 -//export nd_on_init +//go:wasmexport nd_on_init func _NdOnInit() int32 { if initImpl == nil { // Return standard code - host will skip this plugin gracefully diff --git a/plugins/pdk/go/metadata/metadata.go b/plugins/pdk/go/metadata/metadata.go index 94dbb0f90..d212e7106 100644 --- a/plugins/pdk/go/metadata/metadata.go +++ b/plugins/pdk/go/metadata/metadata.go @@ -234,7 +234,7 @@ func Register(impl Metadata) { // The host recognizes this and skips the plugin gracefully. const NotImplementedCode int32 = -2 -//export nd_get_artist_mbid +//go:wasmexport nd_get_artist_mbid func _NdGetArtistMbid() int32 { if artistMBIDImpl == nil { // Return standard code - host will skip this plugin gracefully @@ -261,7 +261,7 @@ func _NdGetArtistMbid() int32 { return 0 } -//export nd_get_artist_url +//go:wasmexport nd_get_artist_url func _NdGetArtistUrl() int32 { if artistURLImpl == nil { // Return standard code - host will skip this plugin gracefully @@ -288,7 +288,7 @@ func _NdGetArtistUrl() int32 { return 0 } -//export nd_get_artist_biography +//go:wasmexport nd_get_artist_biography func _NdGetArtistBiography() int32 { if artistBiographyImpl == nil { // Return standard code - host will skip this plugin gracefully @@ -315,7 +315,7 @@ func _NdGetArtistBiography() int32 { return 0 } -//export nd_get_similar_artists +//go:wasmexport nd_get_similar_artists func _NdGetSimilarArtists() int32 { if similarArtistsImpl == nil { // Return standard code - host will skip this plugin gracefully @@ -342,7 +342,7 @@ func _NdGetSimilarArtists() int32 { return 0 } -//export nd_get_artist_images +//go:wasmexport nd_get_artist_images func _NdGetArtistImages() int32 { if artistImagesImpl == nil { // Return standard code - host will skip this plugin gracefully @@ -369,7 +369,7 @@ func _NdGetArtistImages() int32 { return 0 } -//export nd_get_artist_top_songs +//go:wasmexport nd_get_artist_top_songs func _NdGetArtistTopSongs() int32 { if artistTopSongsImpl == nil { // Return standard code - host will skip this plugin gracefully @@ -396,7 +396,7 @@ func _NdGetArtistTopSongs() int32 { return 0 } -//export nd_get_album_info +//go:wasmexport nd_get_album_info func _NdGetAlbumInfo() int32 { if albumInfoImpl == nil { // Return standard code - host will skip this plugin gracefully @@ -423,7 +423,7 @@ func _NdGetAlbumInfo() int32 { return 0 } -//export nd_get_album_images +//go:wasmexport nd_get_album_images func _NdGetAlbumImages() int32 { if albumImagesImpl == nil { // Return standard code - host will skip this plugin gracefully diff --git a/plugins/pdk/go/scheduler/scheduler.go b/plugins/pdk/go/scheduler/scheduler.go index dc70f0695..690134a2b 100644 --- a/plugins/pdk/go/scheduler/scheduler.go +++ b/plugins/pdk/go/scheduler/scheduler.go @@ -52,7 +52,7 @@ func Register(impl Scheduler) { // The host recognizes this and skips the plugin gracefully. const NotImplementedCode int32 = -2 -//export nd_scheduler_callback +//go:wasmexport nd_scheduler_callback func _NdSchedulerCallback() int32 { if callbackImpl == nil { // Return standard code - host will skip this plugin gracefully diff --git a/plugins/pdk/go/scrobbler/scrobbler.go b/plugins/pdk/go/scrobbler/scrobbler.go index 4735335b7..38fdc4cd5 100644 --- a/plugins/pdk/go/scrobbler/scrobbler.go +++ b/plugins/pdk/go/scrobbler/scrobbler.go @@ -129,7 +129,7 @@ func Register(impl Scrobbler) { // The host recognizes this and skips the plugin gracefully. const NotImplementedCode int32 = -2 -//export nd_scrobbler_is_authorized +//go:wasmexport nd_scrobbler_is_authorized func _NdScrobblerIsAuthorized() int32 { if isAuthorizedImpl == nil { // Return standard code - host will skip this plugin gracefully @@ -156,7 +156,7 @@ func _NdScrobblerIsAuthorized() int32 { return 0 } -//export nd_scrobbler_now_playing +//go:wasmexport nd_scrobbler_now_playing func _NdScrobblerNowPlaying() int32 { if nowPlayingImpl == nil { // Return standard code - host will skip this plugin gracefully @@ -177,7 +177,7 @@ func _NdScrobblerNowPlaying() int32 { return 0 } -//export nd_scrobbler_scrobble +//go:wasmexport nd_scrobbler_scrobble func _NdScrobblerScrobble() int32 { if scrobbleImpl == nil { // Return standard code - host will skip this plugin gracefully diff --git a/plugins/pdk/go/websocket/websocket.go b/plugins/pdk/go/websocket/websocket.go index 741fb8ec4..6ce291915 100644 --- a/plugins/pdk/go/websocket/websocket.go +++ b/plugins/pdk/go/websocket/websocket.go @@ -102,7 +102,7 @@ func Register(impl WebSocket) { // The host recognizes this and skips the plugin gracefully. const NotImplementedCode int32 = -2 -//export nd_websocket_on_text_message +//go:wasmexport nd_websocket_on_text_message func _NdWebsocketOnTextMessage() int32 { if textMessageImpl == nil { // Return standard code - host will skip this plugin gracefully @@ -123,7 +123,7 @@ func _NdWebsocketOnTextMessage() int32 { return 0 } -//export nd_websocket_on_binary_message +//go:wasmexport nd_websocket_on_binary_message func _NdWebsocketOnBinaryMessage() int32 { if binaryMessageImpl == nil { // Return standard code - host will skip this plugin gracefully @@ -144,7 +144,7 @@ func _NdWebsocketOnBinaryMessage() int32 { return 0 } -//export nd_websocket_on_error +//go:wasmexport nd_websocket_on_error func _NdWebsocketOnError() int32 { if errorImpl == nil { // Return standard code - host will skip this plugin gracefully @@ -165,7 +165,7 @@ func _NdWebsocketOnError() int32 { return 0 } -//export nd_websocket_on_close +//go:wasmexport nd_websocket_on_close func _NdWebsocketOnClose() int32 { if closeImpl == nil { // Return standard code - host will skip this plugin gracefully