Skip to content

Commit 53a54f5

Browse files
authored
Merge pull request #6 from coder/brett/handle-errors-from-wasm
feat: surface errors to users
2 parents daa9bda + 73b04d8 commit 53a54f5

File tree

12 files changed

+559
-78
lines changed

12 files changed

+559
-78
lines changed

Makefile

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,17 @@
22
build-wasm: build/preview.wasm
33
mkdir -p public/build
44

5+
# TODO: remove vendoring workaround
56
build/preview.wasm: $(GO_SRC_FILES)
6-
GOOS=js GOARCH=wasm go build -C ./preview -o ../public/build/preview.wasm .
7+
cd preview && go mod vendor
8+
(find preview/vendor -name "*.go" -type f -exec sed -i 's/os\.Getwd()/"", nil/g' {} +)
9+
GOOS=js GOARCH=wasm go build -C ./preview -o ../public/build/preview.wasm
10+
rm -rf preview/vendor
11+
12+
.PHONY: gen-types
13+
gen-types: src/gen/types.ts
14+
15+
src/gen/types.ts: preview/scripts/types/main.go preview/apitypes/apitypes.go
16+
mkdir -p src/gen
17+
go run -C ./preview/scripts/types main.go > $@
18+
touch "$@"

preview/apitypes/apitypes.go

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package apitypes
2+
3+
import (
4+
"time"
5+
6+
"github.com/coder/preview"
7+
"github.com/coder/preview/types"
8+
)
9+
10+
type PreviewOutput struct {
11+
Output *preview.Output `json:"output"`
12+
Diags types.Diagnostics `json:"diags"`
13+
// ParserLogs are trivy logs that occur during parsing the
14+
// Terraform files. This is useful for debugging issues with the
15+
// invalid terraform syntax.
16+
ParserLogs []ParserLog `json:"parser_logs,omitempty"`
17+
}
18+
19+
type ParserLog struct {
20+
Time time.Time `json:"time"`
21+
Level string `json:"level"`
22+
Message string `json:"msg"`
23+
Prefix string `json:"prefix"`
24+
Module string `json:"root"`
25+
Err string `json:"err"`
26+
}
27+
28+
type NullHCLString = types.NullHCLString
29+
30+
type FriendlyDiagnostic = types.FriendlyDiagnostic

preview/go.mod

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1-
module github.com/brettkolodny/parameters-playground/preview
1+
module github.com/coder/parameters-playground/preview
22

33
go 1.24.3
44

55
require (
6+
github.com/coder/guts v1.5.0
67
github.com/coder/preview v0.0.2-0.20250528204104-320b553c3e2c
8+
github.com/hashicorp/hcl/v2 v2.23.0
79
github.com/spf13/afero v1.14.0
810
)
911

@@ -30,15 +32,20 @@ require (
3032
github.com/cespare/xxhash/v2 v2.3.0 // indirect
3133
github.com/cncf/xds/go v0.0.0-20250121191232-2f005788dc42 // indirect
3234
github.com/coder/terraform-provider-coder/v2 v2.4.2 // indirect
35+
github.com/dlclark/regexp2 v1.11.4 // indirect
36+
github.com/dop251/goja v0.0.0-20241024094426-79f3a7efcdbd // indirect
3337
github.com/envoyproxy/go-control-plane/envoy v1.32.4 // indirect
3438
github.com/envoyproxy/protoc-gen-validate v1.2.1 // indirect
3539
github.com/fatih/color v1.18.0 // indirect
40+
github.com/fatih/structtag v1.2.0 // indirect
3641
github.com/felixge/httpsnoop v1.0.4 // indirect
3742
github.com/go-jose/go-jose/v4 v4.0.5 // indirect
3843
github.com/go-logr/logr v1.4.2 // indirect
3944
github.com/go-logr/stdr v1.2.2 // indirect
45+
github.com/go-sourcemap/sourcemap v2.1.3+incompatible // indirect
4046
github.com/golang/protobuf v1.5.4 // indirect
4147
github.com/google/go-cmp v0.7.0 // indirect
48+
github.com/google/pprof v0.0.0-20240227163752-401108e1b7e7 // indirect
4249
github.com/google/s2a-go v0.1.9 // indirect
4350
github.com/google/uuid v1.6.0 // indirect
4451
github.com/googleapis/enterprise-certificate-proxy v0.3.6 // indirect
@@ -52,7 +59,6 @@ require (
5259
github.com/hashicorp/go-safetemp v1.0.0 // indirect
5360
github.com/hashicorp/go-uuid v1.0.3 // indirect
5461
github.com/hashicorp/go-version v1.7.0 // indirect
55-
github.com/hashicorp/hcl/v2 v2.23.0 // indirect
5662
github.com/hashicorp/logutils v1.0.0 // indirect
5763
github.com/hashicorp/terraform-json v0.24.0 // indirect
5864
github.com/hashicorp/terraform-plugin-go v0.26.0 // indirect

preview/go.sum

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -632,6 +632,9 @@ github.com/GoogleCloudPlatform/opentelemetry-operations-go/internal/cloudmock v0
632632
github.com/GoogleCloudPlatform/opentelemetry-operations-go/internal/resourcemapping v0.49.0 h1:GYUJLfvd++4DMuMhCFLgLXvFwofIxh/qOwoGuS/LTew=
633633
github.com/GoogleCloudPlatform/opentelemetry-operations-go/internal/resourcemapping v0.49.0/go.mod h1:wRbFgBQUVm1YXrvWKofAEmq9HNJTDphbAaJSSX01KUI=
634634
github.com/JohnCGriffin/overflow v0.0.0-20211019200055-46fa312c352c/go.mod h1:X0CRv0ky0k6m906ixxpzmDRLvX58TFUKS2eePweuyxk=
635+
github.com/Masterminds/semver v1.5.0 h1:H65muMkzWKEuNDnfl9d70GUjFniHKHRbFPGBuZ3QEww=
636+
github.com/Masterminds/semver/v3 v3.3.0 h1:B8LGeaivUe71a5qox1ICM/JLl0NqZSW5CHyL+hmvYS0=
637+
github.com/Masterminds/semver/v3 v3.3.0/go.mod h1:4V+yj/TJE1HU9XfppCwVMZq3I84lprf4nC11bSS5beM=
635638
github.com/Microsoft/go-winio v0.6.2 h1:F2VQgta7ecxGYO8k3ZZz3RS8fVIXVxONVUPlNERoyfY=
636639
github.com/Microsoft/go-winio v0.6.2/go.mod h1:yd8OoFMLzJbo9gZq8j5qaps8bJ9aShtEA8Ipt1oGCvU=
637640
github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
@@ -702,12 +705,10 @@ github.com/cncf/xds/go v0.0.0-20230105202645-06c439db220b/go.mod h1:eXthEFrGJvWH
702705
github.com/cncf/xds/go v0.0.0-20230607035331-e9ce68804cb4/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs=
703706
github.com/cncf/xds/go v0.0.0-20250121191232-2f005788dc42 h1:Om6kYQYDUk5wWbT0t0q6pvyM49i9XZAv9dDrkDA7gjk=
704707
github.com/cncf/xds/go v0.0.0-20250121191232-2f005788dc42/go.mod h1:W+zGtBO5Y1IgJhy4+A9GOqVhqLpfZi+vwmdNXUehLA8=
705-
github.com/coder/preview v0.0.1 h1:2X5McKdMOZJILTIDf7qRplXKupT+91qTJBN67XUh5cA=
706-
github.com/coder/preview v0.0.1/go.mod h1:eInDmOdSDF8cxCvapIvYkGRzmzvcvGAFL1HYqcA4g+E=
708+
github.com/coder/guts v1.5.0 h1:a94apf7xMf5jDdg1bIHzncbRiTn3+BvBZgrFSDbUnyI=
709+
github.com/coder/guts v1.5.0/go.mod h1:0Sbv5Kp83u1Nl7MIQiV2zmacJ3o02I341bkWkjWXSUQ=
707710
github.com/coder/preview v0.0.2-0.20250528204104-320b553c3e2c h1:ShixosbLEdK6/RfFI1MTAKsYOTyhUOk7jwcJ70Yp0Wg=
708711
github.com/coder/preview v0.0.2-0.20250528204104-320b553c3e2c/go.mod h1:Ltd83BrbNN7Nj+hToa6My7xTTj8FVa2xNk5589b1DJc=
709-
github.com/coder/terraform-provider-coder/v2 v2.4.0-pre1.0.20250417100258-c86bb5c3ddcd h1:FsIG6Fd0YOEK7D0Hl/CJywRA+Y6Gd5RQbSIa2L+/BmE=
710-
github.com/coder/terraform-provider-coder/v2 v2.4.0-pre1.0.20250417100258-c86bb5c3ddcd/go.mod h1:56/KdGYaA+VbwXJbTI8CA57XPfnuTxN8rjxbR34PbZw=
711712
github.com/coder/terraform-provider-coder/v2 v2.4.2 h1:41SJkgwgiA555kwQzGIQcNS3bCm12sVMUmBSa5zGr+A=
712713
github.com/coder/terraform-provider-coder/v2 v2.4.2/go.mod h1:2kaBpn5k9ZWtgKq5k4JbkVZG9DzEqR4mJSmpdshcO+s=
713714
github.com/coder/trivy v0.0.0-20250527170238-9416a59d7019 h1:MHkv/W7l9eRAN9gOG0qZ1TLRGWIIfNi92273vPAQ8Fs=
@@ -736,6 +737,8 @@ github.com/docker/go-connections v0.5.0/go.mod h1:ov60Kzw0kKElRwhNs9UlUHAE/F9Fe6
736737
github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4=
737738
github.com/docker/go-units v0.5.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk=
738739
github.com/docopt/docopt-go v0.0.0-20180111231733-ee0de3bc6815/go.mod h1:WwZ+bS3ebgob9U8Nd0kOddGdZWjyMGR8Wziv+TBNwSE=
740+
github.com/dop251/goja v0.0.0-20241024094426-79f3a7efcdbd h1:QMSNEh9uQkDjyPwu/J541GgSH+4hw+0skJDIj9HJ3mE=
741+
github.com/dop251/goja v0.0.0-20241024094426-79f3a7efcdbd/go.mod h1:MxLav0peU43GgvwVgNbLAj1s/bSGboKkhuULvq/7hx4=
739742
github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
740743
github.com/ebitengine/purego v0.8.2 h1:jPPGWs2sZ1UgOSgD2bClL0MJIqu58nOmIcBuXr62z1I=
741744
github.com/ebitengine/purego v0.8.2/go.mod h1:iIjxzd6CiRiOG0UyXP+V1+jWqUXVjPKLAI0mRfJZTmQ=
@@ -768,6 +771,8 @@ github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5Kwzbycv
768771
github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk=
769772
github.com/fatih/color v1.18.0 h1:S8gINlzdQ840/4pfAwic/ZE0djQEH3wM94VfqLTZcOM=
770773
github.com/fatih/color v1.18.0/go.mod h1:4FelSpRwEGDpQ12mAdzqdOukCy4u8WUtOY6lkT/6HfU=
774+
github.com/fatih/structtag v1.2.0 h1:/OdNE99OxoI/PqaW/SuSK9uxxT3f/tcSZgon/ssNSx4=
775+
github.com/fatih/structtag v1.2.0/go.mod h1:mBJUNpUnHmRKrKlQQlmCrh5PuhftFbNv8Ys4/aAZl94=
771776
github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2Wg=
772777
github.com/felixge/httpsnoop v1.0.4/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U=
773778
github.com/fogleman/gg v1.2.1-0.20190220221249-0403632d5b90/go.mod h1:R/bRT+9gY/C5z7JzPU0zXsXHKM4/ayA+zqcVNZzPa1k=
@@ -800,6 +805,8 @@ github.com/go-ole/go-ole v1.3.0 h1:Dt6ye7+vXGIKZ7Xtk4s6/xVdGDQynvom7xCFEdWr6uE=
800805
github.com/go-ole/go-ole v1.3.0/go.mod h1:5LS6F96DhAwUc7C+1HLexzMXY1xGRSryjyPPKW6zv78=
801806
github.com/go-pdf/fpdf v0.5.0/go.mod h1:HzcnA+A23uwogo0tp9yU+l3V+KXhiESpt1PMayhOh5M=
802807
github.com/go-pdf/fpdf v0.6.0/go.mod h1:HzcnA+A23uwogo0tp9yU+l3V+KXhiESpt1PMayhOh5M=
808+
github.com/go-sourcemap/sourcemap v2.1.3+incompatible h1:W1iEw64niKVGogNgBN3ePyLFfuisuzeidWPMPWmECqU=
809+
github.com/go-sourcemap/sourcemap v2.1.3+incompatible/go.mod h1:F8jJfvm2KbVjc5NqelyYJmf/v5J0dwNLS2mL4sNA1Jg=
803810
github.com/go-test/deep v1.0.3 h1:ZrJSEWsXzPOxaZnFteGEfooLba+ju3FYIbOrS+rQd68=
804811
github.com/go-test/deep v1.0.3/go.mod h1:wGDj63lr65AM2AQyKZd/NYHGb0R+1RLqB8NKt3aSFNA=
805812
github.com/goccy/go-json v0.9.11/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I=
@@ -893,6 +900,8 @@ github.com/google/pprof v0.0.0-20210226084205-cbba55b83ad5/go.mod h1:kpwsk12EmLe
893900
github.com/google/pprof v0.0.0-20210601050228-01bbb1931b22/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE=
894901
github.com/google/pprof v0.0.0-20210609004039-a478d1d731e9/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE=
895902
github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE=
903+
github.com/google/pprof v0.0.0-20240227163752-401108e1b7e7 h1:y3N7Bm7Y9/CtpiVkw/ZWj6lSlDF3F74SfKwfTCer72Q=
904+
github.com/google/pprof v0.0.0-20240227163752-401108e1b7e7/go.mod h1:czg5+yv1E0ZGTi6S6vVK1mke0fV+FaUhNGcd6VRS9Ik=
896905
github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
897906
github.com/google/s2a-go v0.1.9 h1:LGD7gtMgezd8a/Xak7mEWL0PjoTQFvpRudN895yqKW0=
898907
github.com/google/s2a-go v0.1.9/go.mod h1:YA0Ei2ZQL3acow2O62kdp9UlnvMmU7kA6Eutn0dXayM=
@@ -1592,8 +1601,6 @@ golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=
15921601
golang.org/x/tools v0.7.0/go.mod h1:4pg6aUX35JBAogB10C9AtvVL+qowtN4pT3CGSQex14s=
15931602
golang.org/x/tools v0.13.0/go.mod h1:HvlwmtVNQAhOuCjW7xxvovg8wbNq7LwfXh/k7wXUl58=
15941603
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk=
1595-
golang.org/x/tools v0.32.0 h1:Q7N1vhpkQv7ybVzLFtTjvQya2ewbwNDZzUgfXGqtMWU=
1596-
golang.org/x/tools v0.32.0/go.mod h1:ZxrU41P/wAbZD8EDa6dDCa6XfpkhJ7HFMjHJXfBDu8s=
15971604
golang.org/x/tools v0.33.0 h1:4qz2S3zmRxbGIhDIAgjxvFutSvH5EfnsYrRBj0UI0bc=
15981605
golang.org/x/tools v0.33.0/go.mod h1:CIJMaWEY88juyUfo7UbgPqbC8rU2OqfAV1h2Qp0oMYI=
15991606
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=

preview/main.go

Lines changed: 39 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,23 @@
33
package main
44

55
import (
6-
"bytes"
76
"context"
87
"encoding/json"
98
"fmt"
109
"io/fs"
1110
"log/slog"
1211
"path/filepath"
12+
"sync"
1313
"syscall/js"
14+
"time"
1415

1516
"github.com/hashicorp/hcl/v2"
1617
"github.com/spf13/afero"
1718

1819
"github.com/coder/preview"
1920
"github.com/coder/preview/types"
21+
22+
"github.com/coder/parameters-playground/preview/apitypes"
2023
)
2124

2225
func main() {
@@ -31,23 +34,14 @@ func main() {
3134
<-done
3235
}
3336

34-
type previewOutput struct {
35-
Output *preview.Output `json:"output"`
36-
Diags types.Diagnostics `json:"diags"`
37-
// ParserLogs are trivy logs that occur during parsing the
38-
// Terraform files. This is useful for debugging issues with the
39-
// invalid terraform syntax.
40-
ParserLogs string `json:"parser_logs,omitempty"`
41-
}
42-
4337
func tfpreview(this js.Value, p []js.Value) (output any) {
44-
var buf bytes.Buffer
38+
l := NewLogger()
4539
defer func() {
4640
// Return a panic as a diagnostic if one occurs.
4741
if r := recover(); r != nil {
48-
data, _ := json.Marshal(previewOutput{
42+
data, _ := json.Marshal(apitypes.PreviewOutput{
4943
Output: nil,
50-
ParserLogs: buf.String(),
44+
ParserLogs: l.entries,
5145
Diags: types.Diagnostics{
5246
{
5347
Severity: hcl.DiagError,
@@ -67,10 +61,8 @@ func tfpreview(this js.Value, p []js.Value) (output any) {
6761
return err
6862
}
6963

70-
logger := slog.New(slog.NewTextHandler(&buf, &slog.HandlerOptions{
71-
AddSource: false,
72-
Level: slog.LevelDebug,
73-
}))
64+
handler := slog.NewJSONHandler(l, nil)
65+
logger := slog.New(handler)
7466
pOutput, diags := preview.Preview(context.Background(), preview.Input{
7567
PlanJSONPath: "",
7668
PlanJSON: nil,
@@ -79,10 +71,10 @@ func tfpreview(this js.Value, p []js.Value) (output any) {
7971
Logger: logger,
8072
}, tf)
8173

82-
data, _ := json.Marshal(previewOutput{
74+
data, _ := json.Marshal(apitypes.PreviewOutput{
8375
Output: pOutput,
8476
Diags: types.Diagnostics(diags),
85-
ParserLogs: buf.String(),
77+
ParserLogs: l.entries,
8678
})
8779

8880
return js.ValueOf(string(data))
@@ -125,3 +117,31 @@ func loadTree(mem afero.Fs, fileTree map[string]any, path ...string) {
125117
}
126118
}
127119
}
120+
121+
type Logger struct {
122+
mu sync.Mutex
123+
entries []apitypes.ParserLog
124+
}
125+
126+
func NewLogger() *Logger {
127+
return &Logger{
128+
entries: make([]apitypes.ParserLog, 0),
129+
}
130+
}
131+
132+
func (l *Logger) Write(p []byte) (n int, err error) {
133+
var entry apitypes.ParserLog
134+
if err := json.Unmarshal(p, &entry); err != nil {
135+
entry = apitypes.ParserLog{
136+
Time: time.Now(),
137+
Level: "unknown",
138+
Message: string(p),
139+
}
140+
}
141+
142+
l.mu.Lock()
143+
l.entries = append(l.entries, entry)
144+
l.mu.Unlock()
145+
146+
return len(p), nil
147+
}

preview/scripts/types/main.go

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
package main
2+
3+
import (
4+
"fmt"
5+
"log"
6+
7+
"github.com/coder/guts"
8+
"github.com/coder/guts/bindings"
9+
"github.com/coder/guts/config"
10+
)
11+
12+
func main() {
13+
gen, err := guts.NewGolangParser()
14+
if err != nil {
15+
log.Fatalf("new convert: %v", err)
16+
}
17+
18+
err = gen.IncludeGenerate("github.com/coder/parameters-playground/preview/apitypes")
19+
if err != nil {
20+
log.Fatalf("include generate: %v", err)
21+
}
22+
23+
referencePackages := map[string]string{
24+
"github.com/coder/preview": "",
25+
"github.com/coder/preview/types": "",
26+
"github.com/hashicorp/hcl/v2": "",
27+
"github.com/hashicorp/hcl/v2/hclwrite": "",
28+
"github.com/zclconf/go-cty/cty": "",
29+
"github.com/aquasecurity/trivy/pkg/iac/terraform": "",
30+
"github.com/coder/terraform-provider-coder/v2/provider": "",
31+
"github.com/zclconf/go-cty/cty/function": ""}
32+
33+
for pkg, prefix := range referencePackages {
34+
err = gen.IncludeReference(pkg, prefix)
35+
if err != nil {
36+
log.Fatalf("include reference package %q: %v", pkg, err)
37+
}
38+
}
39+
40+
err = typeMappings(gen)
41+
if err != nil {
42+
log.Fatalf("type mappings: %v", err)
43+
}
44+
45+
ts, err := gen.ToTypescript()
46+
ts.ApplyMutations(config.ExportTypes)
47+
48+
if err != nil {
49+
log.Fatalf("to typescript: %v", err)
50+
}
51+
52+
output, err := ts.Serialize()
53+
if err != nil {
54+
log.Fatalf("serialize: %v", err)
55+
}
56+
_, _ = fmt.Println(output)
57+
}
58+
59+
func typeMappings(gen *guts.GoParser) error {
60+
gen.IncludeCustomDeclaration(config.StandardMappings())
61+
62+
gen.IncludeCustomDeclaration(map[string]guts.TypeOverride{
63+
// opt.Bool can return 'null' if unset
64+
"tailscale.com/types/opt.Bool": config.OverrideNullable(config.OverrideLiteral(bindings.KeywordBoolean)),
65+
// Replace the hcl packag's Diagnostic with preview's FriendlyDiagnostic.
66+
// This is needed because when the preview package's re-exported Diagnostic
67+
// type is marshalled it's converted into FriendlyDiagnostic.
68+
"github.com/hashicorp/hcl/v2.Diagnostic": func() bindings.ExpressionType {
69+
return bindings.Reference(bindings.Identifier{
70+
Name: "FriendlyDiagnostic",
71+
Package: nil,
72+
Prefix: "",
73+
})
74+
},
75+
"github.com/hashicorp/hcl/v2.Body": func() bindings.ExpressionType {
76+
return bindings.Reference(bindings.Identifier{
77+
Name: "unknown",
78+
Package: nil,
79+
Prefix: "",
80+
})
81+
},
82+
"github.com/coder/preview/types.HCLString": func() bindings.ExpressionType {
83+
return bindings.Reference(bindings.Identifier{
84+
Name: "NullHCLString",
85+
Package: nil,
86+
Prefix: "",
87+
})
88+
},
89+
})
90+
91+
return nil
92+
}

public/build/preview.wasm

8.36 KB
Binary file not shown.

src/Editor.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ export const Editor: FC = () => {
125125
</div>
126126

127127
{/* CODE EDITOR */}
128-
<div className="relative h-full w-full">
128+
<div className="relative h-full w-full overflow-y-scroll">
129129
<Button
130130
className="absolute top-3 right-3 z-10"
131131
variant="subtle"
@@ -134,7 +134,7 @@ export const Editor: FC = () => {
134134
>
135135
{codeCopied ? <CheckIcon /> : <CopyIcon />} Copy
136136
</Button>
137-
<div className="h-full w-full overflow-y-scroll bg-surface-secondary font-mono">
137+
<div className="h-full w-full bg-surface-secondary font-mono">
138138
<CodeEditor
139139
value={$code}
140140
onValueChange={(code) => $setCode(code)}

0 commit comments

Comments
 (0)