Skip to content

Commit

Permalink
fix importUsed
Browse files Browse the repository at this point in the history
  • Loading branch information
alixander committed Sep 29, 2023
1 parent e56f9c0 commit f448ae1
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions d2js/js.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func jsGetObjOrder(this js.Value, args []js.Value) interface{} {
dsl := args[0].String()

g, _, err := d2compiler.Compile("", strings.NewReader(dsl), &d2compiler.CompileOptions{
UTF16: true,
UTF16Pos: true,
})
if err != nil {
ret := jsObjOrder{Error: err.Error()}
Expand Down Expand Up @@ -79,7 +79,7 @@ func jsGetRefRanges(this js.Value, args []js.Value) interface{} {
}

g, _, err := d2compiler.Compile("", strings.NewReader(dsl), &d2compiler.CompileOptions{
UTF16: true,
UTF16Pos: true,
})
var pe *d2parser.ParseError
if err != nil {
Expand Down Expand Up @@ -159,7 +159,7 @@ type detectFS struct {
importUsed bool
}

func (detectFS detectFS) Open(name string) (fs.File, error) {
func (detectFS *detectFS) Open(name string) (fs.File, error) {
detectFS.importUsed = true
return &emptyFile{}, nil
}
Expand All @@ -171,8 +171,8 @@ func jsParse(this js.Value, args []js.Value) interface{} {
detectFS := detectFS{}

g, _, err := d2compiler.Compile("", strings.NewReader(dsl), &d2compiler.CompileOptions{
UTF16: true,
FS: detectFS,
UTF16Pos: true,
FS: &detectFS,
})
// If an import was used, client side D2 cannot reliably compile
// Defer to backend compilation
Expand Down Expand Up @@ -228,7 +228,7 @@ func jsCompile(this js.Value, args []js.Value) interface{} {
script := args[0].String()

g, _, err := d2compiler.Compile("", strings.NewReader(script), &d2compiler.CompileOptions{
UTF16: true,
UTF16Pos: true,
})
var pe *d2parser.ParseError
if err != nil {
Expand Down

0 comments on commit f448ae1

Please sign in to comment.