fusee-framework 2.7.0 → 2.7.2
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 +98 -26
- 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 +119 -44
- 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,85 +0,0 @@
|
|
|
1
|
-
package engine
|
|
2
|
-
|
|
3
|
-
import (
|
|
4
|
-
"net/url"
|
|
5
|
-
"regexp"
|
|
6
|
-
"strings"
|
|
7
|
-
)
|
|
8
|
-
|
|
9
|
-
type paramSpec struct {
|
|
10
|
-
name string
|
|
11
|
-
catchAll bool
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
type Route struct {
|
|
15
|
-
Pattern string
|
|
16
|
-
Handler any
|
|
17
|
-
regex *regexp.Regexp
|
|
18
|
-
params []paramSpec
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
func Compile(pattern string, handler any) *Route {
|
|
22
|
-
segments := strings.Split(strings.Trim(pattern, "/"), "/")
|
|
23
|
-
var params []paramSpec
|
|
24
|
-
var body strings.Builder
|
|
25
|
-
|
|
26
|
-
for _, seg := range segments {
|
|
27
|
-
if seg == "" {
|
|
28
|
-
continue
|
|
29
|
-
}
|
|
30
|
-
switch {
|
|
31
|
-
case strings.HasPrefix(seg, "[...") && strings.HasSuffix(seg, "]"):
|
|
32
|
-
name := seg[4 : len(seg)-1]
|
|
33
|
-
params = append(params, paramSpec{name: name, catchAll: true})
|
|
34
|
-
body.WriteString(`/(.+)`)
|
|
35
|
-
case strings.HasPrefix(seg, "[") && strings.HasSuffix(seg, "]"):
|
|
36
|
-
name := seg[1 : len(seg)-1]
|
|
37
|
-
params = append(params, paramSpec{name: name})
|
|
38
|
-
body.WriteString(`/([^/]+)`)
|
|
39
|
-
default:
|
|
40
|
-
body.WriteString("/" + regexp.QuoteMeta(seg))
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
pat := body.String()
|
|
45
|
-
if pat == "" {
|
|
46
|
-
pat = "/"
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
return &Route{
|
|
50
|
-
Pattern: pattern,
|
|
51
|
-
Handler: handler,
|
|
52
|
-
regex: regexp.MustCompile("^" + pat + "/?$"),
|
|
53
|
-
params: params,
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
type Match struct {
|
|
58
|
-
Route *Route
|
|
59
|
-
Params map[string]string
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
func MatchAll(routes []*Route, path string) *Match {
|
|
63
|
-
if path == "" {
|
|
64
|
-
path = "/"
|
|
65
|
-
}
|
|
66
|
-
for _, r := range routes {
|
|
67
|
-
m := r.regex.FindStringSubmatch(path)
|
|
68
|
-
if m == nil {
|
|
69
|
-
continue
|
|
70
|
-
}
|
|
71
|
-
params := make(map[string]string, len(r.params))
|
|
72
|
-
for i, spec := range r.params {
|
|
73
|
-
raw := m[i+1]
|
|
74
|
-
if spec.catchAll {
|
|
75
|
-
params[spec.name] = raw
|
|
76
|
-
} else if decoded, err := url.QueryUnescape(raw); err == nil {
|
|
77
|
-
params[spec.name] = decoded
|
|
78
|
-
} else {
|
|
79
|
-
params[spec.name] = raw
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
return &Match{Route: r, Params: params}
|
|
83
|
-
}
|
|
84
|
-
return nil
|
|
85
|
-
}
|
|
@@ -1,317 +0,0 @@
|
|
|
1
|
-
// Package rustast contains Go types that mirror the Fusée Rust compiler's AST.
|
|
2
|
-
// These are used to deserialize the JSON produced by the `fusee-ast` binary.
|
|
3
|
-
//
|
|
4
|
-
// The Rust side uses `#[serde(tag = "type")]` on tagged-union enums, which
|
|
5
|
-
// flattens the variant fields into the same JSON object as the "type" field.
|
|
6
|
-
// Custom UnmarshalJSON implementations here exploit exactly that: peek "type",
|
|
7
|
-
// then unmarshal the whole payload into the matching struct (unknown fields
|
|
8
|
-
// like "type" itself are silently ignored by encoding/json).
|
|
9
|
-
package rustast
|
|
10
|
-
|
|
11
|
-
import (
|
|
12
|
-
"encoding/json"
|
|
13
|
-
"fmt"
|
|
14
|
-
)
|
|
15
|
-
|
|
16
|
-
type Pos struct {
|
|
17
|
-
Line int `json:"line"`
|
|
18
|
-
Col int `json:"col"`
|
|
19
|
-
Offset int `json:"offset"`
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
type Loc struct {
|
|
23
|
-
Start Pos `json:"start"`
|
|
24
|
-
End Pos `json:"end"`
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
type Expression struct {
|
|
28
|
-
Content string `json:"content"`
|
|
29
|
-
IsStatic bool `json:"is_static"`
|
|
30
|
-
IsForKey bool `json:"is_for_key"`
|
|
31
|
-
Loc Loc `json:"loc"`
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
type AttributeNode struct {
|
|
35
|
-
Name string `json:"name"`
|
|
36
|
-
Value *string `json:"value"`
|
|
37
|
-
Loc Loc `json:"loc"`
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
type BindingNode struct {
|
|
41
|
-
Name string `json:"name"`
|
|
42
|
-
Expression Expression `json:"expression"`
|
|
43
|
-
IsProp bool `json:"is_prop"`
|
|
44
|
-
Loc Loc `json:"loc"`
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
type EventNode struct {
|
|
48
|
-
Name string `json:"name"`
|
|
49
|
-
Expression Expression `json:"expression"`
|
|
50
|
-
Modifiers []string `json:"modifiers"`
|
|
51
|
-
Loc Loc `json:"loc"`
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
type ForArg struct {
|
|
55
|
-
Item string `json:"item"`
|
|
56
|
-
Source string `json:"source"`
|
|
57
|
-
Index *string `json:"index"`
|
|
58
|
-
Loc Loc `json:"loc"`
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
type DirectiveNode struct {
|
|
62
|
-
Name string `json:"name"`
|
|
63
|
-
Expression *Expression `json:"expression"`
|
|
64
|
-
Arg *ForArg `json:"arg"`
|
|
65
|
-
Loc Loc `json:"loc"`
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
type PropType string
|
|
69
|
-
|
|
70
|
-
const (
|
|
71
|
-
PropAttribute PropType = "Attribute"
|
|
72
|
-
PropBinding PropType = "Binding"
|
|
73
|
-
PropEvent PropType = "Event"
|
|
74
|
-
PropDirective PropType = "Directive"
|
|
75
|
-
)
|
|
76
|
-
|
|
77
|
-
type Prop struct {
|
|
78
|
-
Type PropType
|
|
79
|
-
Attribute *AttributeNode
|
|
80
|
-
Binding *BindingNode
|
|
81
|
-
Event *EventNode
|
|
82
|
-
Directive *DirectiveNode
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
func (p *Prop) UnmarshalJSON(data []byte) error {
|
|
86
|
-
var probe struct {
|
|
87
|
-
Type PropType `json:"type"`
|
|
88
|
-
}
|
|
89
|
-
if err := json.Unmarshal(data, &probe); err != nil {
|
|
90
|
-
return err
|
|
91
|
-
}
|
|
92
|
-
p.Type = probe.Type
|
|
93
|
-
switch probe.Type {
|
|
94
|
-
case PropAttribute:
|
|
95
|
-
p.Attribute = &AttributeNode{}
|
|
96
|
-
return json.Unmarshal(data, p.Attribute)
|
|
97
|
-
case PropBinding:
|
|
98
|
-
p.Binding = &BindingNode{}
|
|
99
|
-
return json.Unmarshal(data, p.Binding)
|
|
100
|
-
case PropEvent:
|
|
101
|
-
p.Event = &EventNode{}
|
|
102
|
-
return json.Unmarshal(data, p.Event)
|
|
103
|
-
case PropDirective:
|
|
104
|
-
p.Directive = &DirectiveNode{}
|
|
105
|
-
return json.Unmarshal(data, p.Directive)
|
|
106
|
-
default:
|
|
107
|
-
return fmt.Errorf("rustast: unknown Prop type %q", probe.Type)
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
func (p Prop) MarshalJSON() ([]byte, error) {
|
|
112
|
-
switch p.Type {
|
|
113
|
-
case PropAttribute:
|
|
114
|
-
return marshalTagged("Attribute", p.Attribute)
|
|
115
|
-
case PropBinding:
|
|
116
|
-
return marshalTagged("Binding", p.Binding)
|
|
117
|
-
case PropEvent:
|
|
118
|
-
return marshalTagged("Event", p.Event)
|
|
119
|
-
case PropDirective:
|
|
120
|
-
return marshalTagged("Directive", p.Directive)
|
|
121
|
-
default:
|
|
122
|
-
return nil, fmt.Errorf("rustast: unknown Prop type %q", p.Type)
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
func marshalTagged(typeName string, v any) ([]byte, error) {
|
|
127
|
-
inner, err := json.Marshal(v)
|
|
128
|
-
if err != nil {
|
|
129
|
-
return nil, err
|
|
130
|
-
}
|
|
131
|
-
var m map[string]json.RawMessage
|
|
132
|
-
if err := json.Unmarshal(inner, &m); err != nil {
|
|
133
|
-
return nil, err
|
|
134
|
-
}
|
|
135
|
-
m["type"] = json.RawMessage(`"` + typeName + `"`)
|
|
136
|
-
return json.Marshal(m)
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
type NodeType string
|
|
140
|
-
|
|
141
|
-
const (
|
|
142
|
-
NodeRoot NodeType = "Root"
|
|
143
|
-
NodeElement NodeType = "Element"
|
|
144
|
-
NodeComponent NodeType = "Component"
|
|
145
|
-
NodeText NodeType = "Text"
|
|
146
|
-
NodeInterpolation NodeType = "Interpolation"
|
|
147
|
-
NodeSlotOutlet NodeType = "SlotOutlet"
|
|
148
|
-
NodeSlotContent NodeType = "SlotContent"
|
|
149
|
-
NodeIf NodeType = "If"
|
|
150
|
-
)
|
|
151
|
-
|
|
152
|
-
type RootNode struct {
|
|
153
|
-
Children []*Node `json:"children"`
|
|
154
|
-
Hoisted []int `json:"hoisted"`
|
|
155
|
-
Loc Loc `json:"loc"`
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
type ElementNode struct {
|
|
159
|
-
ID int `json:"id"`
|
|
160
|
-
Tag string `json:"tag"`
|
|
161
|
-
Props []*Prop `json:"props"`
|
|
162
|
-
Children []*Node `json:"children"`
|
|
163
|
-
SelfClosing bool `json:"self_closing"`
|
|
164
|
-
IsStatic bool `json:"is_static"`
|
|
165
|
-
Hoisted bool `json:"hoisted"`
|
|
166
|
-
Loc Loc `json:"loc"`
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
type SlotEntry struct {
|
|
170
|
-
Name string
|
|
171
|
-
Children []*Node
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
func (s *SlotEntry) UnmarshalJSON(data []byte) error {
|
|
175
|
-
var tuple [2]json.RawMessage
|
|
176
|
-
if err := json.Unmarshal(data, &tuple); err != nil {
|
|
177
|
-
return fmt.Errorf("rustast: slot entry is not a 2-element array: %w", err)
|
|
178
|
-
}
|
|
179
|
-
if err := json.Unmarshal(tuple[0], &s.Name); err != nil {
|
|
180
|
-
return err
|
|
181
|
-
}
|
|
182
|
-
return json.Unmarshal(tuple[1], &s.Children)
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
func (s SlotEntry) MarshalJSON() ([]byte, error) {
|
|
186
|
-
return json.Marshal([2]any{s.Name, s.Children})
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
type ComponentNode struct {
|
|
190
|
-
ID int `json:"id"`
|
|
191
|
-
Name string `json:"name"`
|
|
192
|
-
Props []*Prop `json:"props"`
|
|
193
|
-
Slots []*SlotEntry `json:"slots"`
|
|
194
|
-
Loc Loc `json:"loc"`
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
func (c *ComponentNode) Slot(name string) []*Node {
|
|
198
|
-
for _, s := range c.Slots {
|
|
199
|
-
if s.Name == name {
|
|
200
|
-
return s.Children
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
return nil
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
type TextNode struct {
|
|
207
|
-
Content string `json:"content"`
|
|
208
|
-
IsStatic bool `json:"is_static"`
|
|
209
|
-
Loc Loc `json:"loc"`
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
type InterpolationNode struct {
|
|
213
|
-
Expression Expression `json:"expression"`
|
|
214
|
-
IsStatic bool `json:"is_static"`
|
|
215
|
-
Loc Loc `json:"loc"`
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
type SlotOutletNode struct {
|
|
219
|
-
SlotName string `json:"slot_name"`
|
|
220
|
-
Fallback []*Node `json:"fallback"`
|
|
221
|
-
Loc Loc `json:"loc"`
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
type SlotContentNode struct {
|
|
225
|
-
SlotName string `json:"slot_name"`
|
|
226
|
-
Children []*Node `json:"children"`
|
|
227
|
-
Loc Loc `json:"loc"`
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
type Branch struct {
|
|
231
|
-
Condition *Expression `json:"condition"`
|
|
232
|
-
Node *Node `json:"node"`
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
type IfNode struct {
|
|
236
|
-
Branches []Branch `json:"branches"`
|
|
237
|
-
Loc Loc `json:"loc"`
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
type Node struct {
|
|
241
|
-
Type NodeType
|
|
242
|
-
|
|
243
|
-
Root *RootNode
|
|
244
|
-
Element *ElementNode
|
|
245
|
-
Component *ComponentNode
|
|
246
|
-
Text *TextNode
|
|
247
|
-
Interpolation *InterpolationNode
|
|
248
|
-
SlotOutlet *SlotOutletNode
|
|
249
|
-
SlotContent *SlotContentNode
|
|
250
|
-
If *IfNode
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
func (n *Node) UnmarshalJSON(data []byte) error {
|
|
254
|
-
var probe struct {
|
|
255
|
-
Type NodeType `json:"type"`
|
|
256
|
-
}
|
|
257
|
-
if err := json.Unmarshal(data, &probe); err != nil {
|
|
258
|
-
return err
|
|
259
|
-
}
|
|
260
|
-
n.Type = probe.Type
|
|
261
|
-
switch probe.Type {
|
|
262
|
-
case NodeRoot:
|
|
263
|
-
n.Root = &RootNode{}
|
|
264
|
-
return json.Unmarshal(data, n.Root)
|
|
265
|
-
case NodeElement:
|
|
266
|
-
n.Element = &ElementNode{}
|
|
267
|
-
return json.Unmarshal(data, n.Element)
|
|
268
|
-
case NodeComponent:
|
|
269
|
-
n.Component = &ComponentNode{}
|
|
270
|
-
return json.Unmarshal(data, n.Component)
|
|
271
|
-
case NodeText:
|
|
272
|
-
n.Text = &TextNode{}
|
|
273
|
-
return json.Unmarshal(data, n.Text)
|
|
274
|
-
case NodeInterpolation:
|
|
275
|
-
n.Interpolation = &InterpolationNode{}
|
|
276
|
-
return json.Unmarshal(data, n.Interpolation)
|
|
277
|
-
case NodeSlotOutlet:
|
|
278
|
-
n.SlotOutlet = &SlotOutletNode{}
|
|
279
|
-
return json.Unmarshal(data, n.SlotOutlet)
|
|
280
|
-
case NodeSlotContent:
|
|
281
|
-
n.SlotContent = &SlotContentNode{}
|
|
282
|
-
return json.Unmarshal(data, n.SlotContent)
|
|
283
|
-
case NodeIf:
|
|
284
|
-
n.If = &IfNode{}
|
|
285
|
-
return json.Unmarshal(data, n.If)
|
|
286
|
-
default:
|
|
287
|
-
return fmt.Errorf("rustast: unknown Node type %q", probe.Type)
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
func (n *Node) Props() []*Prop {
|
|
292
|
-
switch n.Type {
|
|
293
|
-
case NodeElement:
|
|
294
|
-
return n.Element.Props
|
|
295
|
-
case NodeComponent:
|
|
296
|
-
return n.Component.Props
|
|
297
|
-
}
|
|
298
|
-
return nil
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
func (n *Node) FindDirective(name string) *DirectiveNode {
|
|
302
|
-
for _, p := range n.Props() {
|
|
303
|
-
if p.Type == PropDirective && p.Directive.Name == name {
|
|
304
|
-
return p.Directive
|
|
305
|
-
}
|
|
306
|
-
}
|
|
307
|
-
return nil
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
// ParseAST deserializes a fusee-ast JSON payload into a Node tree.
|
|
311
|
-
func ParseAST(data []byte) (*Node, error) {
|
|
312
|
-
var n Node
|
|
313
|
-
if err := json.Unmarshal(data, &n); err != nil {
|
|
314
|
-
return nil, fmt.Errorf("rustast: failed to parse AST JSON: %w", err)
|
|
315
|
-
}
|
|
316
|
-
return &n, nil
|
|
317
|
-
}
|
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
package engine
|
|
2
|
-
|
|
3
|
-
import (
|
|
4
|
-
"fmt"
|
|
5
|
-
"net/http"
|
|
6
|
-
)
|
|
7
|
-
|
|
8
|
-
type boundary struct {
|
|
9
|
-
id string
|
|
10
|
-
resultCh chan string
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
type BoundaryRegistry struct {
|
|
14
|
-
boundaries []*boundary
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
func NewBoundaryRegistry() *BoundaryRegistry {
|
|
18
|
-
return &BoundaryRegistry{}
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
func (b *BoundaryRegistry) RegisterBoundary(id, fallback string, work func() string) string {
|
|
22
|
-
bd := &boundary{id: id, resultCh: make(chan string, 1)}
|
|
23
|
-
b.boundaries = append(b.boundaries, bd)
|
|
24
|
-
|
|
25
|
-
go func() {
|
|
26
|
-
bd.resultCh <- work()
|
|
27
|
-
}()
|
|
28
|
-
|
|
29
|
-
return fmt.Sprintf(`<div id="%s" data-f-boundary>%s</div>`, id, fallback)
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
func renderBoundaryChunk(id, html string) string {
|
|
33
|
-
tplID := "tpl-" + id
|
|
34
|
-
return fmt.Sprintf(
|
|
35
|
-
`<template id="%s">%s</template><script>(function(){var t=document.getElementById(%q);var d=document.getElementById(%q);if(t&&d&&d.parentNode){d.replaceWith(t.content);t.remove();}var s=document.currentScript;if(s&&s.parentNode)s.parentNode.removeChild(s);})();</script>`,
|
|
36
|
-
tplID, html, tplID, id,
|
|
37
|
-
)
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
func RenderPageToStream(w http.ResponseWriter, headers http.Header, shell func(*BoundaryRegistry) string, tail func() string) error {
|
|
41
|
-
for k, vs := range headers {
|
|
42
|
-
for _, v := range vs {
|
|
43
|
-
w.Header().Add(k, v)
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
w.WriteHeader(http.StatusOK)
|
|
47
|
-
|
|
48
|
-
flusher, ok := w.(http.Flusher)
|
|
49
|
-
if !ok {
|
|
50
|
-
return fmt.Errorf("ssr: ResponseWriter does not support flushing (http.Flusher)")
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
registry := NewBoundaryRegistry()
|
|
54
|
-
shellHTML := shell(registry)
|
|
55
|
-
|
|
56
|
-
if _, err := w.Write([]byte(shellHTML)); err != nil {
|
|
57
|
-
return err
|
|
58
|
-
}
|
|
59
|
-
flusher.Flush()
|
|
60
|
-
|
|
61
|
-
if err := flushBoundariesOutOfOrder(w, flusher, registry.boundaries); err != nil {
|
|
62
|
-
return err
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
if tail != nil {
|
|
66
|
-
if _, err := w.Write([]byte(tail())); err != nil {
|
|
67
|
-
return err
|
|
68
|
-
}
|
|
69
|
-
flusher.Flush()
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
return nil
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
func flushBoundariesOutOfOrder(w http.ResponseWriter, flusher http.Flusher, boundaries []*boundary) error {
|
|
76
|
-
if len(boundaries) == 0 {
|
|
77
|
-
return nil
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
type result struct {
|
|
81
|
-
id string
|
|
82
|
-
html string
|
|
83
|
-
}
|
|
84
|
-
done := make(chan result, len(boundaries))
|
|
85
|
-
|
|
86
|
-
for _, b := range boundaries {
|
|
87
|
-
b := b
|
|
88
|
-
go func() {
|
|
89
|
-
html := <-b.resultCh
|
|
90
|
-
done <- result{id: b.id, html: html}
|
|
91
|
-
}()
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
for i := 0; i < len(boundaries); i++ {
|
|
95
|
-
r := <-done
|
|
96
|
-
if _, err := w.Write([]byte(renderBoundaryChunk(r.id, r.html))); err != nil {
|
|
97
|
-
return err
|
|
98
|
-
}
|
|
99
|
-
flusher.Flush()
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
return nil
|
|
103
|
-
}
|
|
@@ -1,139 +0,0 @@
|
|
|
1
|
-
package engine
|
|
2
|
-
|
|
3
|
-
import (
|
|
4
|
-
"compress/gzip"
|
|
5
|
-
"io"
|
|
6
|
-
"net/http"
|
|
7
|
-
"os"
|
|
8
|
-
"path/filepath"
|
|
9
|
-
"regexp"
|
|
10
|
-
"strings"
|
|
11
|
-
)
|
|
12
|
-
|
|
13
|
-
var hashedAssetRE = regexp.MustCompile(`[.\-][a-f0-9]{8,}\.[a-zA-Z0-9]+$`)
|
|
14
|
-
|
|
15
|
-
var mimeTypes = map[string]string{
|
|
16
|
-
".html": "text/html; charset=utf-8",
|
|
17
|
-
".js": "text/javascript; charset=utf-8",
|
|
18
|
-
".mjs": "text/javascript; charset=utf-8",
|
|
19
|
-
".css": "text/css; charset=utf-8",
|
|
20
|
-
".json": "application/json; charset=utf-8",
|
|
21
|
-
".svg": "image/svg+xml",
|
|
22
|
-
".png": "image/png",
|
|
23
|
-
".jpg": "image/jpeg",
|
|
24
|
-
".jpeg": "image/jpeg",
|
|
25
|
-
".gif": "image/gif",
|
|
26
|
-
".webp": "image/webp",
|
|
27
|
-
".ico": "image/x-icon",
|
|
28
|
-
".woff": "font/woff",
|
|
29
|
-
".woff2": "font/woff2",
|
|
30
|
-
".txt": "text/plain; charset=utf-8",
|
|
31
|
-
".map": "application/json; charset=utf-8",
|
|
32
|
-
".wasm": "application/wasm",
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
func contentTypeFor(path string) string {
|
|
36
|
-
if ct, ok := mimeTypes[strings.ToLower(filepath.Ext(path))]; ok {
|
|
37
|
-
return ct
|
|
38
|
-
}
|
|
39
|
-
return "application/octet-stream"
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
func cacheControlFor(path string) string {
|
|
43
|
-
if hashedAssetRE.MatchString(path) {
|
|
44
|
-
return "public, max-age=31536000, immutable"
|
|
45
|
-
}
|
|
46
|
-
return "public, max-age=0, must-revalidate"
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
func pickEncoding(acceptEncoding string) string {
|
|
50
|
-
lower := strings.ToLower(acceptEncoding)
|
|
51
|
-
if strings.Contains(lower, "br") {
|
|
52
|
-
return "br"
|
|
53
|
-
}
|
|
54
|
-
if strings.Contains(lower, "gzip") {
|
|
55
|
-
return "gzip"
|
|
56
|
-
}
|
|
57
|
-
return ""
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
func Resolve(distDir, pathname string) (path string, ok bool) {
|
|
61
|
-
if idx := strings.IndexByte(pathname, '?'); idx != -1 {
|
|
62
|
-
pathname = pathname[:idx]
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
cleanRel := filepath.Clean(strings.TrimPrefix(pathname, "/"))
|
|
66
|
-
if cleanRel == "." || cleanRel == "" {
|
|
67
|
-
return "", false
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
resolvedRoot, err := filepath.Abs(distDir)
|
|
71
|
-
if err != nil {
|
|
72
|
-
return "", false
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
// 1. Check in distDir (e.g. dist/assets/...)
|
|
76
|
-
candidate := filepath.Join(resolvedRoot, cleanRel)
|
|
77
|
-
if candidate == resolvedRoot || strings.HasPrefix(candidate, resolvedRoot+string(filepath.Separator)) {
|
|
78
|
-
if info, err := os.Stat(candidate); err == nil && !info.IsDir() {
|
|
79
|
-
return candidate, true
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
// 2. Fallback to parent project root (for /app/..., /framework/..., /fusee-logo.svg)
|
|
84
|
-
projectRoot := filepath.Dir(resolvedRoot)
|
|
85
|
-
candidateParent := filepath.Join(projectRoot, cleanRel)
|
|
86
|
-
if candidateParent == projectRoot || strings.HasPrefix(candidateParent, projectRoot+string(filepath.Separator)) {
|
|
87
|
-
if info, err := os.Stat(candidateParent); err == nil && !info.IsDir() {
|
|
88
|
-
return candidateParent, true
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
return "", false
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
func Serve(w http.ResponseWriter, r *http.Request, filePath string) error {
|
|
96
|
-
encoding := pickEncoding(r.Header.Get("Accept-Encoding"))
|
|
97
|
-
contentType := contentTypeFor(filePath)
|
|
98
|
-
cacheControl := cacheControlFor(filePath)
|
|
99
|
-
|
|
100
|
-
if encoding != "" {
|
|
101
|
-
ext := ".gz"
|
|
102
|
-
if encoding == "br" {
|
|
103
|
-
ext = ".br"
|
|
104
|
-
}
|
|
105
|
-
if f, err := os.Open(filePath + ext); err == nil {
|
|
106
|
-
defer f.Close()
|
|
107
|
-
w.Header().Set("Content-Type", contentType)
|
|
108
|
-
w.Header().Set("Cache-Control", cacheControl)
|
|
109
|
-
w.Header().Set("Content-Encoding", encoding)
|
|
110
|
-
w.Header().Set("Vary", "Accept-Encoding")
|
|
111
|
-
w.WriteHeader(http.StatusOK)
|
|
112
|
-
_, err := io.Copy(w, f)
|
|
113
|
-
return err
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
f, err := os.Open(filePath)
|
|
118
|
-
if err != nil {
|
|
119
|
-
return err
|
|
120
|
-
}
|
|
121
|
-
defer f.Close()
|
|
122
|
-
|
|
123
|
-
w.Header().Set("Content-Type", contentType)
|
|
124
|
-
w.Header().Set("Cache-Control", cacheControl)
|
|
125
|
-
|
|
126
|
-
if encoding == "gzip" {
|
|
127
|
-
w.Header().Set("Content-Encoding", "gzip")
|
|
128
|
-
w.Header().Set("Vary", "Accept-Encoding")
|
|
129
|
-
w.WriteHeader(http.StatusOK)
|
|
130
|
-
gz := gzip.NewWriter(w)
|
|
131
|
-
defer gz.Close()
|
|
132
|
-
_, err := io.Copy(gz, f)
|
|
133
|
-
return err
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
w.WriteHeader(http.StatusOK)
|
|
137
|
-
_, err = io.Copy(w, f)
|
|
138
|
-
return err
|
|
139
|
-
}
|
package/framework/node_modules/.vite/vitest/da39a3ee5e6b4b0d3255bfef95601890afd80709/results.json
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":"4.1.4","results":[[":__tests__/component-full.test.js",{"duration":129.91820000000007,"failed":false}],[":__tests__/router-dynamic.test.js",{"duration":234.65790000000015,"failed":false}],[":__tests__/core.test.js",{"duration":791.7873999999993,"failed":false}],[":__tests__/compiler.test.js",{"duration":260.6435999999994,"failed":false}],[":__tests__/signal-full.test.js",{"duration":82.13780000000042,"failed":false}],[":__tests__/actions.test.js",{"duration":110.89980000000014,"failed":false}],[":__tests__/integration.test.js",{"duration":426.259399999999,"failed":false}],[":__tests__/memory-leaks.test.js",{"duration":300.5116999999991,"failed":false}],[":__tests__/store.test.js",{"duration":94.34749999999985,"failed":false}],[":__tests__/signal.test.js",{"duration":55.624000000000706,"failed":false}],[":__tests__/hydration.test.js",{"duration":49.02929999999924,"failed":false}],[":__tests__/resource.test.js",{"duration":342.90250000000015,"failed":false}],[":__tests__/benchmark.test.js",{"duration":101.09839999999986,"failed":false}],[":__tests__/file-router.test.js",{"duration":56.23449999999957,"failed":false}],[":__tests__/async-context.test.js",{"duration":41.451100000000224,"failed":false}],[":__tests__/router-query.test.js",{"duration":63.17019999999957,"failed":false}],[":__tests__/DI_v2.test.js",{"duration":19.370700000000397,"failed":false}],[":__tests__/DI.test.js",{"duration":120.94930000000022,"failed":false}],[":__tests__/final.test.js",{"duration":73.53499999999985,"failed":false}],[":__tests__/final-phase1.test.js",{"duration":12.186300000000301,"failed":false}],[":__tests__/pipeline.test.js",{"duration":164.90560000000005,"failed":false}],[":__tests__/dispatcher.test.js",{"duration":68.17020000000048,"failed":false}]]}
|