Documentation ¶
Index ¶
- Variables
- func AssertFunction(v goja.Value) (goja.Callable, bool)
- func NewMemSourceCache() *memSourceCache
- func PrettifyException(err error) error
- func TagFieldNameMapper(tagName string, uncapMethods bool, fallbackToUncap bool) goja.FieldNameMapper
- func ToKebabCase(s string) string
- func WithCache(cache bool) interface{ ... }
- func WithNativeModule(path string, obj map[string]interface{}) interface{ ... }
- type Any
- type AutoExecJsxProps
- type Callable
- type EsBuildTransform
- type EsBuildTransformOptions
- type Exception
- type ExportDefault
- type Jsx
- func (j *Jsx) Exec(file string, opts ...OptionExec) (ex *ModuleExport, err error)
- func (j *Jsx) ExecCode(src []byte, opts ...OptionExec) (ex *ModuleExport, err error)
- func (j *Jsx) RegisterModule(name string, obj map[string]interface{})
- func (j *Jsx) Render(file string, props interface{}, opts ...OptionRender) (n string, err error)
- func (j *Jsx) RenderCode(code []byte, props interface{}, opts ...OptionExec) (n string, ctx *RenderCtx, err error)
- func (j *Jsx) RenderCtx(file string, props interface{}, opts ...OptionRender) (n string, ctx *RenderCtx, err error)
- type ModuleExport
- type Option
- type OptionExec
- type OptionRender
- type RenderCtx
- type RunJsOption
- type Source
- type SourceCache
- type Transformer
- type TransformerFormat
- type VDom
- type VDomOrInterface
Constants ¶
This section is empty.
Variables ¶
var StdFileSystem = stdFileSystem{}
Functions ¶
func AssertFunction ¶
AssertFunction wrap goja.AssertFunction and add prettify error message
func NewMemSourceCache ¶
func NewMemSourceCache() *memSourceCache
func PrettifyException ¶
PrettifyException make goja exceptions look more prettify.
func TagFieldNameMapper ¶
func TagFieldNameMapper(tagName string, uncapMethods bool, fallbackToUncap bool) goja.FieldNameMapper
func ToKebabCase ¶ added in v0.6.2
ToKebabCase converts a CamelCase string to a hyphen-separated lowercase string. 用于实现 /node_modules/react-dom/cjs/react-dom-server.node.development.js hyphenateStyleName github.com/gobeam/stringy 和 github.com/stoewer/go-strcase 在处理 “--color“ 都有问题。
func WithCache ¶
func WithCache(cache bool) interface { OptionExec OptionRender }
func WithNativeModule ¶
func WithNativeModule(path string, obj map[string]interface{}) interface { OptionExec OptionRender }
WithNativeModule 注意,由于有 vm 对象池公用 vm 的情况,所以只能保证同步执行的代码能正确拿到本次运行的值,如果是第一次运行导出 function 再执行的情况,可能拿到的是第二次运行指定的 Module。
Types ¶
type AutoExecJsxProps ¶
type AutoExecJsxProps interface{}
type EsBuildTransform ¶
type EsBuildTransform struct {
// contains filtered or unexported fields
}
func NewEsBuildTransform ¶
func NewEsBuildTransform(o EsBuildTransformOptions) *EsBuildTransform
func (*EsBuildTransform) Transform ¶
func (e *EsBuildTransform) Transform(filePath string, code []byte, format TransformerFormat) (out []byte, err error)
type EsBuildTransformOptions ¶
type ExportDefault ¶
type ExportDefault interface {
// contains filtered or unexported methods
}
type Jsx ¶
type Jsx struct {
// contains filtered or unexported fields
}
func (*Jsx) Exec ¶
func (j *Jsx) Exec(file string, opts ...OptionExec) (ex *ModuleExport, err error)
func (*Jsx) ExecCode ¶
func (j *Jsx) ExecCode(src []byte, opts ...OptionExec) (ex *ModuleExport, err error)
ExecCode code 需要是 ESModule 格式,如 export default () => <></>
func (*Jsx) RegisterModule ¶
func (*Jsx) Render ¶
func (j *Jsx) Render(file string, props interface{}, opts ...OptionRender) (n string, err error)
Render a component to html
func (*Jsx) RenderCode ¶
func (j *Jsx) RenderCode(code []byte, props interface{}, opts ...OptionExec) (n string, ctx *RenderCtx, err error)
RenderCode code to html
type ModuleExport ¶
type ModuleExport struct { // One of VDom, Callable, Any // VDom if WithAutoExecJsx // Callable if export a function Default ExportDefault Exports map[string]interface{} }
type Option ¶
type Option struct { SourceCache SourceCache Debug bool // enable to get more log // 最多的 vm 对象数量,指定为 1 表示只会同时有一个 vm 运行,默认为 2000 VmMaxTotal int Transformer Transformer // Fs 没办法做到每次执行代码时指定,因为 require 可能会发生在异步 function 里,fs 改变会导致加载文件错误 Fs fs.FS // default is StdFileSystem // GojaFieldNameMapper Specify the mapping of field names in go struct and js. // via: https://github.com/dop251/goja#mapping-struct-field-and-method-names GojaFieldNameMapper goja.FieldNameMapper }
type OptionExec ¶
type OptionExec interface {
// contains filtered or unexported methods
}
func WithAutoExecJsx ¶
func WithAutoExecJsx(t AutoExecJsxProps) OptionExec
func WithFileName ¶
func WithFileName(fn string) OptionExec
func WithGlobalVar ¶
func WithGlobalVar(k string, v interface{}) OptionExec
WithGlobalVar 注意,由于有 vm 对象池公用 vm 的情况,所以只能保证同步执行的代码能正确拿到本次运行的值,如果是第一次运行导出 function 再执行的情况,可能拿到的是第二次运行指定的 GlobalVar。
type OptionRender ¶
type OptionRender interface {
// contains filtered or unexported methods
}
type RenderCtx ¶
type RunJsOption ¶
type RunJsOption func(*execOptions)
type SourceCache ¶
type Transformer ¶
type Transformer interface {
Transform(filePath string, src []byte, format TransformerFormat) (out []byte, err error)
}
type TransformerFormat ¶
type TransformerFormat uint8
const ( TransformerNone TransformerFormat = 0 TransformerFormatDefault TransformerFormat = 1 TransformerFormatIIFE TransformerFormat = 2 TransformerFormatCommonJS TransformerFormat = 3 TransformerFormatESModule TransformerFormat = 4 )
type VDomOrInterface ¶
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
internal
|
|
pkg
|
|
htmlparser
Package html is an HTML5 lexer following the specifications at http://www.w3.org/TR/html5/syntax.html.
|
Package html is an HTML5 lexer following the specifications at http://www.w3.org/TR/html5/syntax.html. |
test
|
|