Documentation
¶
Overview ¶
Package miniprogram is NSGo's mini program backend, for WeChat, QQ, Alipay and Douyin alike: the engine and the app run in WebAssembly in the mini program's logic layer, each batch becomes operations its runtime applies to a tree of plain objects and hands the render layer with setData, and one recursive component draws each view at its frame. Text is measured on an offscreen canvas and broken into lines here (text.go), canvases are drawn on one and shown as pictures, and taps, touches, scrolls and edits come back as events (mount.go, touch.go).
The runtime (cmd/nsgo/miniprogram) starts the module with Go's wasm_exec.js in a global object of its own, nsgoMP being the bridge: what it calls in Go, Go sets on it, and what Go calls it provides, the platform's APIs (api) among them, as WeChat's whichever platform it is.
Index ¶
- func Run(app engine.App, opts Options)
- type Measurer
- type Options
- type TextEngine
- type TextLayout
- func (l *TextLayout) Attachment(i int) (driver.Bounds, bool)
- func (l *TextLayout) CaretRect(c driver.Caret) (driver.Bounds, bool)
- func (l *TextLayout) HitTest(p driver.Point) driver.Caret
- func (l *TextLayout) RangeRects(start, end int, out []driver.Bounds) []driver.Bounds
- func (*TextLayout) Release()
- func (l *TextLayout) TextLines() []driver.TextLine
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Measurer ¶
type Measurer interface {
// Width is the advance of text in font, a CSS font shorthand.
Width(font, text string) float64
}
Measurer measures text in the host's fonts.
type Options ¶
type Options struct {
// ID names the app's entries in the mini program's storage.
ID string
// Appearance is the appearance the app starts in.
Appearance driver.Appearance
}
Options configure the app.
type TextEngine ¶
type TextEngine struct {
// contains filtered or unexported fields
}
TextEngine is driver.TextEngine over a Measurer.
func NewTextEngine ¶
func NewTextEngine(m Measurer) *TextEngine
NewTextEngine returns an engine measuring with m.
func (*TextEngine) Prepare ¶
func (e *TextEngine) Prepare(t *driver.AttributedText) driver.PreparedText
Prepare implements driver.TextEngine.
type TextLayout ¶
type TextLayout struct {
// contains filtered or unexported fields
}
TextLayout is the text laid out at its final size: what the render layer draws.
func (*TextLayout) Attachment ¶
func (l *TextLayout) Attachment(i int) (driver.Bounds, bool)
Attachment implements core.AttachmentLayout.
func (*TextLayout) HitTest ¶
func (l *TextLayout) HitTest(p driver.Point) driver.Caret
HitTest implements driver.TextHitTester.
func (*TextLayout) RangeRects ¶
RangeRects implements driver.TextHitTester.
func (*TextLayout) TextLines ¶
func (l *TextLayout) TextLines() []driver.TextLine
TextLines implements core.LineLayout.