navigation

package
v0.9.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 15, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package navigation はWebGoへ現在のDocument URLを安全な値として公開する。

Index

Constants

View Source
const (
	MaxURLSize          = 8 * 1024
	MaxHistoryStateSize = 64 * 1024
)

Variables

View Source
var (
	// ErrInvalidURL はNavigation対象として扱えないURLを表す。
	ErrInvalidURL = errors.New("invalid navigation URL")
	// ErrUnavailable はBrowserにNavigation処理が接続されていないことを表す。
	ErrUnavailable = errors.New("navigation is unavailable")
)

Functions

This section is empty.

Types

type API

type API struct {
	// contains filtered or unexported fields
}

API は1つのPageに属するNavigation APIである。

func New

func New(documentURL *url.URL) *API

New はDocument URLを読み取り専用のWebGo APIへ変換する。

func NewPage

func NewPage(documentURL *url.URL, navigate func(*url.URL) error) *API

NewPage はDocument URLとBrowserのNavigation処理を結び付ける。

func (*API) Back

func (api *API) Back() error

Back は1つ前のHistory entryへの移動を要求する。

func (*API) Current

func (api *API) Current() Location

Current は現在のDocument URLの構成要素を返す。

func (*API) DispatchHashChange

func (api *API) DispatchHashChange(oldURL, newURL string)

DispatchHashChange はBrowserからhashchange相当Eventを配送する。

func (*API) DispatchPopState

func (api *API) DispatchPopState(state string)

DispatchPopState はBrowserからpopstate相当Eventを配送する。

func (*API) Forward

func (api *API) Forward() error

Forward は1つ後のHistory entryへの移動を要求する。

func (*API) Go

func (api *API) Go(delta int) error

Go はdeltaで指定したHistory entryへの移動を要求する。

func (*API) HistoryLength

func (api *API) HistoryLength() int

HistoryLength は現在Sessionのentry数を返す。

func (*API) HistoryState

func (api *API) HistoryState() string

HistoryState は現在entryのJSON stateを返す。未設定の場合は空文字列である。

func (*API) Navigate

func (api *API) Navigate(rawURL string) error

Navigate は検証・解決済みURLへのBrowser Navigationを要求する。 Network完了を待たず、commit前に検出できるErrorだけを返す。

func (*API) OnHashChange

func (api *API) OnHashChange(listener func(HashChangeEvent))

OnHashChange はfragment Navigation後に呼ばれるlistenerを登録する。

func (*API) OnPopState

func (api *API) OnPopState(listener func(PopStateEvent))

OnPopState はHistory traversal後に呼ばれるlistenerを登録する。

func (*API) PushState

func (api *API) PushState(stateJSON, rawURL string) error

PushState はJSON stateとsame-origin URLを新しいHistory entryへ追加する。

func (*API) ReplaceState

func (api *API) ReplaceState(stateJSON, rawURL string) error

ReplaceState は現在History entryのJSON stateとsame-origin URLを置換する。

func (*API) Resolve

func (api *API) Resolve(rawURL string) (Location, error)

Resolve は現在のDocument URLを基準にrawURLを解決する。

func (*API) SetPushStateHandler

func (api *API) SetPushStateHandler(handler func(string, *url.URL) error)

SetPushStateHandler はsame-document History entryの追加先を設定する。

func (*API) SetReplaceStateHandler

func (api *API) SetReplaceStateHandler(handler func(string, *url.URL) error)

SetReplaceStateHandler は現在History entryの置換先を設定する。

func (*API) SetTraversalHandler

func (api *API) SetTraversalHandler(traverse func(int) error, info func() (int, string))

SetTraversalHandler はBrowser History traversalと現在情報の取得先を設定する。

func (*API) UpdateCurrent

func (api *API) UpdateCurrent(documentURL *url.URL)

UpdateCurrent はsame-document Navigation後のDocument URLを反映する。

type HashChangeEvent

type HashChangeEvent struct {
	OldURL string
	NewURL string
}

HashChangeEvent はfragment変更前後のcredentialを含まないURLを保持する。

type Location

type Location struct {
	Href     string
	Origin   string
	Scheme   string
	Host     string
	Hostname string
	Port     string
	Path     string
	Query    string
	Fragment string
}

Location は現在のDocument URLをWebGoから参照するための不変な値である。 QueryとFragmentには先頭の?と#を含めない。

type PopStateEvent

type PopStateEvent struct {
	State string
}

PopStateEvent はHistory traversal後のWebGo Eventである。

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL