Compare commits

..

1 Commits
v1.5.0 ... main

Author SHA1 Message Date
AI Engineer
95f32a6304 feat: align JS exports to PascalCase and optimize optional params (by AI) 2026-06-10 11:04:58 +08:00
4 changed files with 22 additions and 14 deletions

View File

@ -1,5 +1,10 @@
# CHANGELOG
## v1.5.1 (2026-06-08)
- **JS 对齐 & 智能文档**:
- 将所有注册到 `jsmod` 的方法名统一为 PascalCase。
- **可选参数优化**: 将 `Open``password``Save``filename` 改为指针类型。配合最新的 `go/js` 引擎,生成的 `.d.ts` 定义将正确提示为可选参数 `?`,极大优化了 AI 编码体验。
## v1.1.0 (2026-05-17)
- **PDF 语义重构**: 引入全局语义分析引擎。
- **无缝流**: 彻底移除分页干扰(移除 `---``Page X` 标记),实现跨页内容自然合并。

4
go.mod
View File

@ -28,10 +28,10 @@ require (
github.com/xuri/nfp v0.0.2-0.20250530014748-2ddeb826f9a9 // indirect
go.uber.org/multierr v1.10.0 // indirect
go.uber.org/zap v1.26.0 // indirect
golang.org/x/crypto v0.51.0 // indirect
golang.org/x/crypto v0.52.0 // indirect
golang.org/x/image v0.40.0 // indirect
golang.org/x/net v0.54.0 // indirect
golang.org/x/sys v0.44.0 // indirect
golang.org/x/sys v0.45.0 // indirect
golang.org/x/text v0.37.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)

6
go.sum
View File

@ -58,14 +58,12 @@ go.uber.org/multierr v1.10.0 h1:S0h4aNzvfcFsC3dRF1jLoaov7oRaKqRGC/pUEJ2yvPQ=
go.uber.org/multierr v1.10.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y=
go.uber.org/zap v1.26.0 h1:sI7k6L95XOKS281NhVKOFCUNIvv9e0w4BF8N3u+tCRo=
go.uber.org/zap v1.26.0/go.mod h1:dtElttAiwGvoJ/vj4IwHBS/gXsEu/pZ50mUIRWuG0so=
golang.org/x/crypto v0.51.0 h1:IBPXwPfKxY7cWQZ38ZCIRPI50YLeevDLlLnyC5wRGTI=
golang.org/x/crypto v0.51.0/go.mod h1:8AdwkbraGNABw2kOX6YFPs3WM22XqI4EXEd8g+x7Oc8=
golang.org/x/crypto v0.52.0 h1:RMs7fP2rXdep0CftQlK8Uf+kibLm7qkCcradZWYz988=
golang.org/x/image v0.40.0 h1:Tw4GyDXMo+daZN1znreBRC3VayR1aLFUyUEOLUdW1a8=
golang.org/x/image v0.40.0/go.mod h1:uIc348UZMSvS5Z65CVZ7iDPaNobNFEPeJ4kbqTOszmA=
golang.org/x/net v0.54.0 h1:2zJIZAxAHV/OHCDTCOHAYehQzLfSXuf/5SoL/Dv6w/w=
golang.org/x/net v0.54.0/go.mod h1:Sj4oj8jK6XmHpBZU/zWHw3BV3abl4Kvi+Ut7cQcY+cQ=
golang.org/x/sys v0.44.0 h1:ildZl3J4uzeKP07r2F++Op7E9B29JRUy+a27EibtBTQ=
golang.org/x/sys v0.44.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw=
golang.org/x/sys v0.45.0 h1:dO4czNzziLiiXplLQgBCEpCvXQ3dnkn0SdaZSYdQ+FY=
golang.org/x/text v0.37.0 h1:Cqjiwd9eSg8e0QAkyCaQTNHFIIzWtidPahFWR83rTrc=
golang.org/x/text v0.37.0/go.mod h1:a5sjxXGs9hsn/AJVwuElvCAo9v8QYLzvavO5z2PiM38=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=

View File

@ -9,28 +9,33 @@ import (
func init() {
jsmod.Register("document", map[string]any{
"open": func(ctx context.Context, filename string, password ...string) (*jsDocument, error) {
"Open": func(ctx context.Context, filename string, password *string) (*jsDocument, error) {
p, err := file.VerifyPathForSafeMode(ctx, filename)
if err != nil {
return nil, err
}
doc, err := Open(p, password...)
var doc Document
if password != nil {
doc, err = Open(p, *password)
} else {
doc, err = Open(p)
}
if err != nil {
return nil, err
}
return &jsDocument{ctx: ctx, d: doc}, nil
},
"create": func(ctx context.Context, ext string) (*jsDocument, error) {
"Create": func(ctx context.Context, ext string) (*jsDocument, error) {
doc, err := Create(ext)
if err != nil {
return nil, err
}
return &jsDocument{ctx: ctx, d: doc}, nil
},
"newExcel": func(ctx context.Context) *jsDocument {
"NewExcel": func(ctx context.Context) *jsDocument {
return &jsDocument{ctx: ctx, d: NewExcel()}
},
"newGraph": func(ctx context.Context) *jsDocument {
"NewGraph": func(ctx context.Context) *jsDocument {
return &jsDocument{ctx: ctx, d: NewGraph()}
},
})
@ -44,10 +49,10 @@ type jsDocument struct {
func (j *jsDocument) ToJSON() string { return j.d.ToJSON() }
func (j *jsDocument) ToMarkdown() string { return j.d.ToMarkdown() }
func (j *jsDocument) Save(filename ...string) error {
func (j *jsDocument) Save(filename *string) error {
var targetPath string
if len(filename) > 0 {
p, err := file.VerifyPathForSafeMode(j.ctx, filename[0])
if filename != nil && *filename != "" {
p, err := file.VerifyPathForSafeMode(j.ctx, *filename)
if err != nil {
return err
}