@statorjs/stator 2.0.0 → 2.0.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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@statorjs/stator",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.2",
|
|
4
4
|
"description": "Server-canonical web framework: business logic in composable state machines, UI as a thin renderer binding machine outputs to DOM positions. Ships TypeScript source (Vite/tsx-native by design).",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -88,7 +88,7 @@
|
|
|
88
88
|
"pino-pretty": "^13.1.3",
|
|
89
89
|
"vite": "^6.0.0",
|
|
90
90
|
"vitest": "^2.1.0",
|
|
91
|
-
"@statorjs/stator": "2.0.
|
|
91
|
+
"@statorjs/stator": "2.0.2"
|
|
92
92
|
},
|
|
93
93
|
"scripts": {
|
|
94
94
|
"typecheck": "tsc --noEmit",
|
package/src/compiler/compile.ts
CHANGED
|
@@ -81,6 +81,19 @@ export function compile(source: string, opts: CompileOptions = {}): CompileResul
|
|
|
81
81
|
const script = scripts.join('\n')
|
|
82
82
|
if (script.trim()) {
|
|
83
83
|
if (analyzeScriptClasses(script).length > 0) {
|
|
84
|
+
// An island's shell renders from props — there is no frontmatter
|
|
85
|
+
// execution on this path, and silently discarding the fence produced
|
|
86
|
+
// either a dangling-identifier crash at render or dead code that
|
|
87
|
+
// looked alive. Surface it instead.
|
|
88
|
+
if (frontmatter.trim()) {
|
|
89
|
+
throw new CompileError(
|
|
90
|
+
`stator: an island file (a template with a StatorElement <script>) can't have ` +
|
|
91
|
+
`frontmatter — the fence would never run: the island's shell renders from props. ` +
|
|
92
|
+
`Move the server work into the route or component that renders this island and ` +
|
|
93
|
+
`pass the results as props.`,
|
|
94
|
+
locAt(source, 0, opts.id),
|
|
95
|
+
)
|
|
96
|
+
}
|
|
84
97
|
return compileClient(template, script, {
|
|
85
98
|
hash,
|
|
86
99
|
scopeAttr,
|
|
@@ -33,15 +33,22 @@ export interface DefineMachineConfig<
|
|
|
33
33
|
emits?: EmitsConfig<C, E>
|
|
34
34
|
context: C
|
|
35
35
|
initial: NoInfer<S>
|
|
36
|
-
/** Transitions see `helpers.reads` typed as `ReadsMap<TReads>`.
|
|
37
|
-
|
|
36
|
+
/** Transitions see `helpers.reads` typed as `ReadsMap<TReads>`.
|
|
37
|
+
*
|
|
38
|
+
* The state union S is inferred from this map's KEYS and nowhere else —
|
|
39
|
+
* every interior S position (`to:`, the machine-level `on:`) is NoInfer.
|
|
40
|
+
* Without that, `to:` string literals become competing inference
|
|
41
|
+
* candidates, and whenever they don't happen to cover every state the
|
|
42
|
+
* union silently collapses to the covered subset (surfaced by the store's
|
|
43
|
+
* cart machine when its line ops moved to machine-level `on:`). */
|
|
44
|
+
states: Record<S, StateNode<C, E, NoInfer<S>, ReadsMap<TReads>>>
|
|
38
45
|
/** Machine-level transitions: handlers that apply in ANY state, consulted only
|
|
39
46
|
* when the current state does not declare the event (a state-scoped handler
|
|
40
47
|
* always wins). The home for a completion event whose handling must not depend
|
|
41
48
|
* on an unrelated machine-wide state — e.g. a per-record save completing while
|
|
42
49
|
* the machine is busy reloading the collection. Without this, such a
|
|
43
50
|
* completion is dropped wherever the current state has no handler for it. */
|
|
44
|
-
on?: OnMap<C, E, S
|
|
51
|
+
on?: OnMap<C, E, NoInfer<S>, ReadsMap<TReads>>
|
|
45
52
|
selectors?: Sel
|
|
46
53
|
/** APP machines only: persist this machine's snapshot through the AppStore
|
|
47
54
|
* so its state survives restarts. Opt-in — caches and other
|
|
@@ -62,6 +62,7 @@ export interface GlobalHTMLAttributes {
|
|
|
62
62
|
|
|
63
63
|
/** Per-element extra attributes. Extend as components need them. */
|
|
64
64
|
export interface ElementSpecificAttributes {
|
|
65
|
+
time: { datetime?: string }
|
|
65
66
|
a: { href?: string; target?: string; rel?: string; download?: string | boolean }
|
|
66
67
|
button: {
|
|
67
68
|
type?: 'submit' | 'reset' | 'button'
|