mirror of
				https://github.com/MontFerret/ferret.git
				synced 2025-10-30 23:37:40 +02:00 
			
		
		
		
	Moved html drivers outside of standard library
This commit is contained in:
		| @@ -1,13 +1,13 @@ | ||||
| package driver | ||||
| package html | ||||
| 
 | ||||
| import ( | ||||
| 	"context" | ||||
| 	"fmt" | ||||
| 	"github.com/MontFerret/ferret/pkg/html/dynamic" | ||||
| 	"github.com/MontFerret/ferret/pkg/html/static" | ||||
| 	"github.com/MontFerret/ferret/pkg/runtime/core" | ||||
| 	"github.com/MontFerret/ferret/pkg/runtime/env" | ||||
| 	"github.com/MontFerret/ferret/pkg/runtime/values" | ||||
| 	"github.com/MontFerret/ferret/pkg/stdlib/html/driver/dynamic" | ||||
| 	"github.com/MontFerret/ferret/pkg/stdlib/html/driver/static" | ||||
| ) | ||||
| 
 | ||||
| type Name string | ||||
| @@ -3,21 +3,20 @@ package dynamic | ||||
| import ( | ||||
| 	"context" | ||||
| 	"fmt" | ||||
| 	"hash/fnv" | ||||
| 	"sync" | ||||
| 	"time" | ||||
| 
 | ||||
| 	"github.com/MontFerret/ferret/pkg/html/dynamic/eval" | ||||
| 	"github.com/MontFerret/ferret/pkg/html/dynamic/events" | ||||
| 	"github.com/MontFerret/ferret/pkg/runtime/core" | ||||
| 	"github.com/MontFerret/ferret/pkg/runtime/logging" | ||||
| 	"github.com/MontFerret/ferret/pkg/runtime/values" | ||||
| 	"github.com/MontFerret/ferret/pkg/stdlib/html/driver/dynamic/eval" | ||||
| 	"github.com/MontFerret/ferret/pkg/stdlib/html/driver/dynamic/events" | ||||
| 	"github.com/mafredri/cdp" | ||||
| 	"github.com/mafredri/cdp/protocol/dom" | ||||
| 	"github.com/mafredri/cdp/protocol/page" | ||||
| 	"github.com/mafredri/cdp/rpcc" | ||||
| 	"github.com/pkg/errors" | ||||
| 	"github.com/rs/zerolog" | ||||
| 	"hash/fnv" | ||||
| 	"sync" | ||||
| 	"time" | ||||
| ) | ||||
| 
 | ||||
| const BlankPageURL = "about:blank" | ||||
| @@ -4,11 +4,11 @@ import ( | ||||
| 	"bytes" | ||||
| 	"context" | ||||
| 	"encoding/json" | ||||
| 	"github.com/MontFerret/ferret/pkg/html/common" | ||||
| 	"github.com/MontFerret/ferret/pkg/html/dynamic/eval" | ||||
| 	"github.com/MontFerret/ferret/pkg/html/dynamic/events" | ||||
| 	"github.com/MontFerret/ferret/pkg/runtime/core" | ||||
| 	"github.com/MontFerret/ferret/pkg/runtime/values" | ||||
| 	"github.com/MontFerret/ferret/pkg/stdlib/html/driver/common" | ||||
| 	"github.com/MontFerret/ferret/pkg/stdlib/html/driver/dynamic/eval" | ||||
| 	"github.com/MontFerret/ferret/pkg/stdlib/html/driver/dynamic/events" | ||||
| 	"github.com/PuerkitoBio/goquery" | ||||
| 	"github.com/mafredri/cdp" | ||||
| 	"github.com/mafredri/cdp/protocol/dom" | ||||
| @@ -3,8 +3,8 @@ package events | ||||
| import ( | ||||
| 	"context" | ||||
| 	"fmt" | ||||
| 	"github.com/MontFerret/ferret/pkg/html/dynamic/eval" | ||||
| 	"github.com/MontFerret/ferret/pkg/runtime/values" | ||||
| 	"github.com/MontFerret/ferret/pkg/stdlib/html/driver/dynamic/eval" | ||||
| 	"github.com/mafredri/cdp" | ||||
| 	"github.com/mafredri/cdp/protocol/dom" | ||||
| 	"github.com/mafredri/cdp/protocol/runtime" | ||||
| @@ -1,9 +1,9 @@ | ||||
| package events | ||||
| 
 | ||||
| import ( | ||||
| 	"github.com/MontFerret/ferret/pkg/html/dynamic/eval" | ||||
| 	"github.com/MontFerret/ferret/pkg/runtime/core" | ||||
| 	"github.com/MontFerret/ferret/pkg/runtime/values" | ||||
| 	"github.com/MontFerret/ferret/pkg/stdlib/html/driver/dynamic/eval" | ||||
| 	"github.com/mafredri/cdp" | ||||
| 	"time" | ||||
| ) | ||||
| @@ -2,9 +2,9 @@ package dynamic | ||||
| 
 | ||||
| import ( | ||||
| 	"context" | ||||
| 	"github.com/MontFerret/ferret/pkg/html/common" | ||||
| 	"github.com/MontFerret/ferret/pkg/html/dynamic/events" | ||||
| 	"github.com/MontFerret/ferret/pkg/runtime/values" | ||||
| 	"github.com/MontFerret/ferret/pkg/stdlib/html/driver/common" | ||||
| 	"github.com/MontFerret/ferret/pkg/stdlib/html/driver/dynamic/events" | ||||
| 	"github.com/mafredri/cdp" | ||||
| 	"github.com/mafredri/cdp/protocol/dom" | ||||
| 	"github.com/mafredri/cdp/protocol/page" | ||||
| @@ -2,7 +2,7 @@ package static_test | ||||
| 
 | ||||
| import ( | ||||
| 	"bytes" | ||||
| 	"github.com/MontFerret/ferret/pkg/stdlib/html/driver/static" | ||||
| 	"github.com/MontFerret/ferret/pkg/html/static" | ||||
| 	"github.com/PuerkitoBio/goquery" | ||||
| 	. "github.com/smartystreets/goconvey/convey" | ||||
| 	"testing" | ||||
| @@ -2,9 +2,9 @@ package static | ||||
| 
 | ||||
| import ( | ||||
| 	"encoding/json" | ||||
| 	"github.com/MontFerret/ferret/pkg/html/common" | ||||
| 	"github.com/MontFerret/ferret/pkg/runtime/core" | ||||
| 	"github.com/MontFerret/ferret/pkg/runtime/values" | ||||
| 	"github.com/MontFerret/ferret/pkg/stdlib/html/driver/common" | ||||
| 	"github.com/PuerkitoBio/goquery" | ||||
| 	"hash/fnv" | ||||
| ) | ||||
| @@ -2,7 +2,7 @@ package static_test | ||||
| 
 | ||||
| import ( | ||||
| 	"bytes" | ||||
| 	"github.com/MontFerret/ferret/pkg/stdlib/html/driver/static" | ||||
| 	"github.com/MontFerret/ferret/pkg/html/static" | ||||
| 	"github.com/PuerkitoBio/goquery" | ||||
| 	. "github.com/smartystreets/goconvey/convey" | ||||
| 	"testing" | ||||
| @@ -2,9 +2,9 @@ package runtime | ||||
|  | ||||
| import ( | ||||
| 	"context" | ||||
| 	"github.com/MontFerret/ferret/pkg/html" | ||||
| 	"github.com/MontFerret/ferret/pkg/runtime/core" | ||||
| 	"github.com/MontFerret/ferret/pkg/runtime/values" | ||||
| 	"github.com/MontFerret/ferret/pkg/stdlib/html/driver" | ||||
| ) | ||||
|  | ||||
| type Program struct { | ||||
| @@ -40,9 +40,8 @@ func (p *Program) Run(ctx context.Context, setters ...Option) ([]byte, error) { | ||||
| 	} | ||||
|  | ||||
| 	ctx = opts.withContext(ctx) | ||||
| 	// TODO: Decouple from STDLIB | ||||
| 	ctx = driver.WithDynamicDriver(ctx) | ||||
| 	ctx = driver.WithStaticDriver(ctx) | ||||
| 	ctx = html.WithDynamicDriver(ctx) | ||||
| 	ctx = html.WithStaticDriver(ctx) | ||||
|  | ||||
| 	out, err := p.body.Exec(ctx, scope) | ||||
|  | ||||
|   | ||||
| @@ -1,11 +1,11 @@ | ||||
| package html | ||||
|  | ||||
| import ( | ||||
| 	"fmt" | ||||
| 	"context" | ||||
| 	"fmt" | ||||
|  | ||||
| 	"github.com/MontFerret/ferret/pkg/html/dynamic" | ||||
| 	"github.com/MontFerret/ferret/pkg/runtime/values" | ||||
| 	"github.com/MontFerret/ferret/pkg/stdlib/html/driver/dynamic" | ||||
|  | ||||
| 	"github.com/MontFerret/ferret/pkg/runtime/core" | ||||
| ) | ||||
| @@ -79,9 +79,9 @@ func Screenshot(ctx context.Context, args ...core.Value) (core.Value, error) { | ||||
| 			} | ||||
| 			if !dynamic.IsScreenshotFormatValid(format.String()) { | ||||
| 				return values.None, core.Error( | ||||
| 					core.ErrInvalidArgument,  | ||||
| 					core.ErrInvalidArgument, | ||||
| 					fmt.Sprintf("format is not valid, expected jpeg or png, but got %s", format.String())) | ||||
| 			}  | ||||
| 			} | ||||
| 			screenshotParams.Format = dynamic.ScreenshotFormat(format.String()) | ||||
| 		} | ||||
| 		x, found := params.Get("x") | ||||
|   | ||||
| @@ -2,9 +2,9 @@ package html | ||||
|  | ||||
| import ( | ||||
| 	"context" | ||||
| 	"github.com/MontFerret/ferret/pkg/html/dynamic" | ||||
| 	"github.com/MontFerret/ferret/pkg/runtime/core" | ||||
| 	"github.com/MontFerret/ferret/pkg/runtime/values" | ||||
| 	"github.com/MontFerret/ferret/pkg/stdlib/html/driver/dynamic" | ||||
| ) | ||||
|  | ||||
| /* | ||||
|   | ||||
| @@ -2,9 +2,9 @@ package html | ||||
|  | ||||
| import ( | ||||
| 	"context" | ||||
| 	"github.com/MontFerret/ferret/pkg/html/dynamic" | ||||
| 	"github.com/MontFerret/ferret/pkg/runtime/core" | ||||
| 	"github.com/MontFerret/ferret/pkg/runtime/values" | ||||
| 	"github.com/MontFerret/ferret/pkg/stdlib/html/driver/dynamic" | ||||
| ) | ||||
|  | ||||
| /* | ||||
|   | ||||
| @@ -2,9 +2,9 @@ package html | ||||
|  | ||||
| import ( | ||||
| 	"context" | ||||
| 	"github.com/MontFerret/ferret/pkg/html" | ||||
| 	"github.com/MontFerret/ferret/pkg/runtime/core" | ||||
| 	"github.com/MontFerret/ferret/pkg/runtime/values" | ||||
| 	"github.com/MontFerret/ferret/pkg/stdlib/html/driver" | ||||
| ) | ||||
|  | ||||
| /* | ||||
| @@ -37,12 +37,12 @@ func Document(ctx context.Context, args ...core.Value) (core.Value, error) { | ||||
| 		dynamic = args[1].(values.Boolean) | ||||
| 	} | ||||
|  | ||||
| 	var drv driver.Driver | ||||
| 	var drv html.Driver | ||||
|  | ||||
| 	if !dynamic { | ||||
| 		drv, err = driver.FromContext(ctx, driver.Static) | ||||
| 		drv, err = html.FromContext(ctx, html.Static) | ||||
| 	} else { | ||||
| 		drv, err = driver.FromContext(ctx, driver.Dynamic) | ||||
| 		drv, err = html.FromContext(ctx, html.Dynamic) | ||||
| 	} | ||||
|  | ||||
| 	if err != nil { | ||||
|   | ||||
| @@ -2,10 +2,10 @@ package html | ||||
|  | ||||
| import ( | ||||
| 	"context" | ||||
| 	"github.com/MontFerret/ferret/pkg/html" | ||||
| 	"github.com/MontFerret/ferret/pkg/html/static" | ||||
| 	"github.com/MontFerret/ferret/pkg/runtime/core" | ||||
| 	"github.com/MontFerret/ferret/pkg/runtime/values" | ||||
| 	"github.com/MontFerret/ferret/pkg/stdlib/html/driver" | ||||
| 	"github.com/MontFerret/ferret/pkg/stdlib/html/driver/static" | ||||
| ) | ||||
|  | ||||
| /* | ||||
| @@ -27,7 +27,7 @@ func DocumentParse(ctx context.Context, args ...core.Value) (core.Value, error) | ||||
| 		return values.None, err | ||||
| 	} | ||||
|  | ||||
| 	drv, err := driver.FromContext(ctx, driver.Static) | ||||
| 	drv, err := html.FromContext(ctx, html.Static) | ||||
|  | ||||
| 	if err != nil { | ||||
| 		return values.None, err | ||||
|   | ||||
| @@ -2,9 +2,9 @@ package html | ||||
|  | ||||
| import ( | ||||
| 	"context" | ||||
| 	"github.com/MontFerret/ferret/pkg/html/dynamic" | ||||
| 	"github.com/MontFerret/ferret/pkg/runtime/core" | ||||
| 	"github.com/MontFerret/ferret/pkg/runtime/values" | ||||
| 	"github.com/MontFerret/ferret/pkg/stdlib/html/driver/dynamic" | ||||
| ) | ||||
|  | ||||
| /* | ||||
|   | ||||
| @@ -2,9 +2,9 @@ package html | ||||
|  | ||||
| import ( | ||||
| 	"context" | ||||
| 	"github.com/MontFerret/ferret/pkg/html/dynamic" | ||||
| 	"github.com/MontFerret/ferret/pkg/runtime/core" | ||||
| 	"github.com/MontFerret/ferret/pkg/runtime/values" | ||||
| 	"github.com/MontFerret/ferret/pkg/stdlib/html/driver/dynamic" | ||||
| ) | ||||
|  | ||||
| /* | ||||
|   | ||||
| @@ -2,9 +2,9 @@ package html | ||||
|  | ||||
| import ( | ||||
| 	"context" | ||||
| 	"github.com/MontFerret/ferret/pkg/html/dynamic" | ||||
| 	"github.com/MontFerret/ferret/pkg/runtime/core" | ||||
| 	"github.com/MontFerret/ferret/pkg/runtime/values" | ||||
| 	"github.com/MontFerret/ferret/pkg/stdlib/html/driver/dynamic" | ||||
| ) | ||||
|  | ||||
| /* | ||||
|   | ||||
| @@ -2,9 +2,9 @@ package html | ||||
|  | ||||
| import ( | ||||
| 	"context" | ||||
| 	"github.com/MontFerret/ferret/pkg/html/dynamic" | ||||
| 	"github.com/MontFerret/ferret/pkg/runtime/core" | ||||
| 	"github.com/MontFerret/ferret/pkg/runtime/values" | ||||
| 	"github.com/MontFerret/ferret/pkg/stdlib/html/driver/dynamic" | ||||
| ) | ||||
|  | ||||
| /* | ||||
|   | ||||
| @@ -2,9 +2,9 @@ package html | ||||
|  | ||||
| import ( | ||||
| 	"context" | ||||
| 	"github.com/MontFerret/ferret/pkg/html/dynamic" | ||||
| 	"github.com/MontFerret/ferret/pkg/runtime/core" | ||||
| 	"github.com/MontFerret/ferret/pkg/runtime/values" | ||||
| 	"github.com/MontFerret/ferret/pkg/stdlib/html/driver/dynamic" | ||||
| ) | ||||
|  | ||||
| /* | ||||
|   | ||||
| @@ -2,9 +2,9 @@ package html | ||||
|  | ||||
| import ( | ||||
| 	"context" | ||||
| 	"github.com/MontFerret/ferret/pkg/html/dynamic" | ||||
| 	"github.com/MontFerret/ferret/pkg/runtime/core" | ||||
| 	"github.com/MontFerret/ferret/pkg/runtime/values" | ||||
| 	"github.com/MontFerret/ferret/pkg/stdlib/html/driver/dynamic" | ||||
| ) | ||||
|  | ||||
| /* | ||||
|   | ||||
		Reference in New Issue
	
	Block a user