fusee-framework 2.7.0 → 2.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +56 -2
- package/bin/create-fusee-linux +0 -0
- package/bin/create-fusee-mac-arm64 +0 -0
- package/bin/create-fusee-mac-intel +0 -0
- package/bin/create-fusee-win.exe +0 -0
- package/framework/auto-import-preset.js +20 -12
- package/framework/auto-imports.d.ts +68 -39
- package/framework/core/compiler.js +310 -310
- package/framework/core/component-core.js +445 -0
- package/framework/core/component.js +11 -440
- package/framework/core/composable.js +29 -29
- package/framework/core/h.js +588 -557
- package/framework/core/jsx-helpers.js +11 -2
- package/framework/core/jsx-runtime.js +73 -73
- package/framework/core/rust-compiler/pkg/fusee_compiler_bg.wasm +0 -0
- package/framework/core/store.js +333 -333
- package/framework/globals.js +42 -0
- package/framework/index.js +22 -55
- package/framework/router/file-router.js +184 -184
- package/framework/server/actions.js +183 -183
- package/framework/server/generate-manifest.js +3 -3
- package/framework/types/component.d.ts +97 -86
- package/framework/types/index.d.ts +118 -117
- package/package.json +83 -80
- package/framework/core/rust-compiler/Cargo.toml +0 -31
- package/framework/core/rust-compiler/README.md +0 -69
- package/framework/core/rust-compiler/pkg/README.md +0 -69
- package/framework/core/rust-compiler/pkg/fusee_compiler.d.ts +0 -6
- package/framework/core/rust-compiler/pkg/fusee_compiler.js +0 -9
- package/framework/core/rust-compiler/pkg/fusee_compiler_bg.js +0 -137
- package/framework/core/rust-compiler/pkg/fusee_compiler_bg.wasm.d.ts +0 -11
- package/framework/core/rust-compiler/pkg/package.json +0 -18
- package/framework/core/rust-compiler/src/ast.rs +0 -274
- package/framework/core/rust-compiler/src/errors.rs +0 -204
- package/framework/core/rust-compiler/src/generator.rs +0 -583
- package/framework/core/rust-compiler/src/lexer.rs +0 -414
- package/framework/core/rust-compiler/src/lib.rs +0 -87
- package/framework/core/rust-compiler/src/main_compiler.rs +0 -165
- package/framework/core/rust-compiler/src/parser.rs +0 -516
- package/framework/core/rust-compiler/src/ssr_generator.rs +0 -688
- package/framework/core/rust-compiler/src/transformer.rs +0 -562
- package/framework/core/rust-compiler/src/utils.rs +0 -10
- package/framework/engine-go/actions.go +0 -112
- package/framework/engine-go/cmd/server/main.go +0 -233
- package/framework/engine-go/comet/comet.go +0 -41
- package/framework/engine-go/comet/fragment.go +0 -51
- package/framework/engine-go/dispatcher.go +0 -120
- package/framework/engine-go/elements.go +0 -248
- package/framework/engine-go/evalexpr/evalexpr.go +0 -733
- package/framework/engine-go/go.mod +0 -3
- package/framework/engine-go/hydration.go +0 -43
- package/framework/engine-go/load-helpers.go +0 -29
- package/framework/engine-go/manifest.go +0 -41
- package/framework/engine-go/reactive.go +0 -123
- package/framework/engine-go/render.go +0 -635
- package/framework/engine-go/reqcontext.go +0 -48
- package/framework/engine-go/router.go +0 -85
- package/framework/engine-go/rustast/rustast.go +0 -317
- package/framework/engine-go/ssr.go +0 -103
- package/framework/engine-go/static-assets.go +0 -139
- package/framework/node_modules/.vite/vitest/da39a3ee5e6b4b0d3255bfef95601890afd80709/results.json +0 -1
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
package engine
|
|
2
|
-
|
|
3
|
-
import (
|
|
4
|
-
"context"
|
|
5
|
-
"encoding/json"
|
|
6
|
-
"fmt"
|
|
7
|
-
)
|
|
8
|
-
|
|
9
|
-
type Payload struct {
|
|
10
|
-
Resources map[string]map[string]any `json:"resources"`
|
|
11
|
-
Signals map[string][]any `json:"signals"`
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
func RenderDehydrationScript(resources map[string]map[string]any, signals map[string][]any) (string, error) {
|
|
15
|
-
if resources == nil {
|
|
16
|
-
resources = map[string]map[string]any{}
|
|
17
|
-
}
|
|
18
|
-
if signals == nil {
|
|
19
|
-
signals = map[string][]any{}
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
payload := Payload{Resources: resources, Signals: signals}
|
|
23
|
-
raw, err := json.Marshal(payload)
|
|
24
|
-
if err != nil {
|
|
25
|
-
return "", fmt.Errorf("hydration: failed to serialize state: %w", err)
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
return fmt.Sprintf(`<script id="__FUSEE_DATA__">window.__FUSEE_STATE__ = %s;</script>`, raw), nil
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
func BuildFromContext(ctx context.Context) (string, error) {
|
|
32
|
-
var resources map[string]map[string]any
|
|
33
|
-
if rc := From(ctx); rc != nil {
|
|
34
|
-
resources = rc.ResourceCache
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
var signals map[string][]any
|
|
38
|
-
if reg := RegistryFrom(ctx); reg != nil {
|
|
39
|
-
signals = reg.Snapshot()
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
return RenderDehydrationScript(resources, signals)
|
|
43
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
package engine
|
|
2
|
-
|
|
3
|
-
import "fmt"
|
|
4
|
-
|
|
5
|
-
type RouteRedirect struct {
|
|
6
|
-
Status int
|
|
7
|
-
Location string
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
func (e *RouteRedirect) Error() string {
|
|
11
|
-
return fmt.Sprintf("redirect(%d) to %s", e.Status, e.Location)
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
type RouteHTTPError struct {
|
|
15
|
-
Status int
|
|
16
|
-
Message string
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
func (e *RouteHTTPError) Error() string {
|
|
20
|
-
return e.Message
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
func Redirect(status int, location string) error {
|
|
24
|
-
return &RouteRedirect{Status: status, Location: location}
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
func HTTPError(status int, message string) error {
|
|
28
|
-
return &RouteHTTPError{Status: status, Message: message}
|
|
29
|
-
}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
package engine
|
|
2
|
-
|
|
3
|
-
import (
|
|
4
|
-
"encoding/json"
|
|
5
|
-
"fmt"
|
|
6
|
-
"os"
|
|
7
|
-
|
|
8
|
-
"fusee/rustast"
|
|
9
|
-
)
|
|
10
|
-
|
|
11
|
-
type ManifestRoute struct {
|
|
12
|
-
Pattern string `json:"pattern"`
|
|
13
|
-
FilePath string `json:"filePath"`
|
|
14
|
-
Title string `json:"title"`
|
|
15
|
-
AST *rustast.Node `json:"ast"`
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
type Manifest struct {
|
|
19
|
-
Version string `json:"version"`
|
|
20
|
-
Routes []*ManifestRoute `json:"routes"`
|
|
21
|
-
Elements []*Element `json:"elements"`
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
// ElementRegistry returns the manifest's custom elements, ready for RenderWithElements.
|
|
25
|
-
func (m *Manifest) ElementRegistry() ElementRegistry {
|
|
26
|
-
return NewElementRegistry(m.Elements)
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
func LoadManifest(manifestPath string) (*Manifest, error) {
|
|
30
|
-
data, err := os.ReadFile(manifestPath)
|
|
31
|
-
if err != nil {
|
|
32
|
-
return nil, fmt.Errorf("failed to read manifest: %w", err)
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
var manifest Manifest
|
|
36
|
-
if err := json.Unmarshal(data, &manifest); err != nil {
|
|
37
|
-
return nil, fmt.Errorf("failed to unmarshal manifest: %w", err)
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
return &manifest, nil
|
|
41
|
-
}
|
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
package engine
|
|
2
|
-
|
|
3
|
-
import (
|
|
4
|
-
"context"
|
|
5
|
-
"encoding/json"
|
|
6
|
-
"sync"
|
|
7
|
-
)
|
|
8
|
-
|
|
9
|
-
type registryKey struct{}
|
|
10
|
-
type frameKey struct{}
|
|
11
|
-
type frame struct {
|
|
12
|
-
scopeID string
|
|
13
|
-
index int
|
|
14
|
-
}
|
|
15
|
-
type Registry struct {
|
|
16
|
-
mu sync.Mutex
|
|
17
|
-
data map[string][]any
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
func NewRegistry() *Registry {
|
|
21
|
-
return &Registry{data: make(map[string][]any)}
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
func WithRegistry(ctx context.Context, reg *Registry) context.Context {
|
|
25
|
-
return context.WithValue(ctx, registryKey{}, reg)
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
func registryFrom(ctx context.Context) *Registry {
|
|
29
|
-
reg, _ := ctx.Value(registryKey{}).(*Registry)
|
|
30
|
-
return reg
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
func RegistryFrom(ctx context.Context) *Registry {
|
|
34
|
-
return registryFrom(ctx)
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
func (r *Registry) Snapshot() map[string][]any {
|
|
38
|
-
r.mu.Lock()
|
|
39
|
-
defer r.mu.Unlock()
|
|
40
|
-
out := make(map[string][]any, len(r.data))
|
|
41
|
-
for k, v := range r.data {
|
|
42
|
-
cp := make([]any, len(v))
|
|
43
|
-
copy(cp, v)
|
|
44
|
-
out[k] = cp
|
|
45
|
-
}
|
|
46
|
-
return out
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
func (r *Registry) Load(snapshot map[string][]any) {
|
|
50
|
-
r.mu.Lock()
|
|
51
|
-
defer r.mu.Unlock()
|
|
52
|
-
for k, v := range snapshot {
|
|
53
|
-
r.data[k] = v
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
func WithScope(ctx context.Context, scopeID string, fn func(ctx context.Context)) {
|
|
58
|
-
f := &frame{scopeID: scopeID, index: 0}
|
|
59
|
-
fn(context.WithValue(ctx, frameKey{}, f))
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
func currentFrame(ctx context.Context) *frame {
|
|
63
|
-
f, _ := ctx.Value(frameKey{}).(*frame)
|
|
64
|
-
return f
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
type Signal[T any] struct {
|
|
68
|
-
mu sync.Mutex
|
|
69
|
-
value T
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
func (s *Signal[T]) Get() T {
|
|
73
|
-
s.mu.Lock()
|
|
74
|
-
defer s.mu.Unlock()
|
|
75
|
-
return s.value
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
func (s *Signal[T]) Set(v T) {
|
|
79
|
-
s.mu.Lock()
|
|
80
|
-
defer s.mu.Unlock()
|
|
81
|
-
s.value = v
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
func NewSignal[T any](ctx context.Context, initial T) *Signal[T] {
|
|
85
|
-
f := currentFrame(ctx)
|
|
86
|
-
if f == nil {
|
|
87
|
-
return &Signal[T]{value: initial}
|
|
88
|
-
}
|
|
89
|
-
reg := registryFrom(ctx)
|
|
90
|
-
if reg == nil {
|
|
91
|
-
return &Signal[T]{value: initial}
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
reg.mu.Lock()
|
|
95
|
-
defer reg.mu.Unlock()
|
|
96
|
-
|
|
97
|
-
idx := f.index
|
|
98
|
-
f.index++
|
|
99
|
-
|
|
100
|
-
list := reg.data[f.scopeID]
|
|
101
|
-
if idx < len(list) && list[idx] != nil {
|
|
102
|
-
var hydrated T
|
|
103
|
-
if err := reDecode(list[idx], &hydrated); err == nil {
|
|
104
|
-
return &Signal[T]{value: hydrated}
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
for len(list) <= idx {
|
|
109
|
-
list = append(list, nil)
|
|
110
|
-
}
|
|
111
|
-
list[idx] = initial
|
|
112
|
-
reg.data[f.scopeID] = list
|
|
113
|
-
|
|
114
|
-
return &Signal[T]{value: initial}
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
func reDecode(v any, out any) error {
|
|
118
|
-
b, err := json.Marshal(v)
|
|
119
|
-
if err != nil {
|
|
120
|
-
return err
|
|
121
|
-
}
|
|
122
|
-
return json.Unmarshal(b, out)
|
|
123
|
-
}
|