@tschk/moonshine-astro 0.4.4 → 0.4.80

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 CHANGED
@@ -14,10 +14,23 @@ This requirement does not apply to the signal-only `@tschk/moonshine` core entry
14
14
  import { fromMoonshineSignal, crepusRenderer } from "@tschk/moonshine-astro";
15
15
  ```
16
16
 
17
- | Entry | Provides |
18
- | ------------ | ---------------------------------------------- |
19
- | `.` | Native signal bridges and lazy native renderer |
20
- | `./compiler` | Legacy Astro compiler re-exports |
17
+ | Entry | Provides |
18
+ | --------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
19
+ | `.` | Native signal bridges, lazy native renderer, and host-free runtime helpers |
20
+ | `./actions` | Independent Astro Actions (`defineAction`, `ActionError`, `ActionInputError`, `getActionContext`, `serializeActionResult`, `deserializeActionResult`, `z`) |
21
+ | `./assets` | Independent Astro Assets (`Image`, `Picture`, `getImage`, `getImageSync`, `inferImageDimensions`, `inferRemoteSize`, `configureAssets`) |
22
+ | `./compiler` | Legacy Astro compiler re-exports |
23
+ | `./config` | Independent Astro configuration (`defineConfig`, `mergeConfig`, `validateConfig`, `passthroughImageService`, `sharpImageService`, `squooshImageService`, `envField`) |
24
+ | `./container` | Independent Astro Container API (`AstroContainer`, `experimental_AstroContainer`, `renderToString`, `renderToResponse`, `insertPageRoute`) |
25
+ | `./content` | Independent Content Collections & Live Content Layer (`defineCollection`, `getCollection`, `getEntry`, `getEntries`, `glob`, `file`, `reference`, `render`, `z`) |
26
+ | `./context` | Independent `AstroCookies`, `AstroSession`, `AstroSlots`, `createAstroGlobal`, `withAstroContext`, `useAstro`, `recordAstroActionResult`, `clearAstroSessions` |
27
+ | `./env` | Independent `astro:env` schema validation (`envField`, `validateEnv`, `getSecret`, `setEnvSource`) |
28
+ | `./i18n` | Independent `astro:i18n` locale routing (`getRelativeLocaleUrl`, `getAbsoluteLocaleUrl`, `redirectToDefaultLocale`, `i18nMiddleware`) |
29
+ | `./loaders` | Independent `astro/loaders` Content Layer loaders (`glob`, `file`, `parseFrontmatter`, `parseSimpleYaml`, `parseSimpleToml`, `parseSimpleCsv`, `matchGlobPattern`) |
30
+ | `./middleware` | Independent `astro:middleware` (`defineMiddleware`, `sequence`, `createContext`, `trySerializeLocals`) |
31
+ | `./routing` | Independent static path pagination & endpoint types (`paginate`, `createPaginate`, `Page`, `GetStaticPaths`, `InferGetStaticParamsType`, `APIRoute`) |
32
+ | `./ssr` | Independent synchronous Astro source factories (`sourceComponent`, `sourceServerIsland`, `sourceSlot`, `sourceHasSlot`, `sourceRenderSlot`), and `useAstro` / `withAstroContext` re-exports |
33
+ | `./transitions` | Independent View Transitions & prefetching (`ClientRouter`, `ViewTransitions`, `fade`, `slide`, `none`, `navigate`, `swapFunctions`, `prefetch`, `init`) |
21
34
 
22
35
  `crepusRenderer` preserves its compatibility name but renders native server
23
36
  factories, escaped metadata, API JSON and SPA shells. Install
@@ -31,6 +44,162 @@ called, so signal bridge consumers do not load server rendering.
31
44
  Legacy entries require their optional host peers: `astro`. They cannot be
32
45
  aliased over arbitrary host-compiled output to remove the host.
33
46
 
34
- The compiler entry still requires Astro. Native rendering expects compiled Moonshine server factories; it does not execute Astro frontmatter or implement the Astro compiler result shapes.
35
- Source parsing and compilation belong to Crepuscularity; these root runtime
36
- changes do not establish full Astro source support.
47
+ The compiler entry still requires Astro. The independent `/ssr` entry supplies
48
+ factories for Crepuscularity-authored server modules; it does not implement
49
+ Astro's compiled component ABI. It preserves HTML attributes, normalizes
50
+ `class:list` and style objects, escapes ordinary children and keeps component
51
+ props independent of any host runtime.
52
+
53
+ Local Crepuscularity integration now lowers fenced `.astro` frontmatter into
54
+ per-render synchronous factories, including typed `Props`, `Astro.props`, static
55
+ imports, imported children, conditionals and simple maps. This compiler work is
56
+ not yet published. Scriptless entry files retain the older scope-based template
57
+ path. Parsing and lowering stay in Crepuscularity.
58
+
59
+ This remains a bounded source slice: top-level await, dynamic imports,
60
+ client directives, script/style blocks, runtime exports, async children, and
61
+ unsupported Astro globals (such as `Astro.glob`) are rejected. Hydration and arbitrary
62
+ host-compiled output are unsupported. Use the legacy compiler explicitly for
63
+ applications requiring the full Astro compiler contract.
64
+
65
+ Run the authored-source regression with an explicitly supplied local compiler:
66
+
67
+ ```sh
68
+ MOONSHINE_CREPUS_COMPILER=/absolute/path/to/crepus bun test packages/adapter-astro/test/standalone.test.ts
69
+ ```
70
+
71
+ It checks prop/interpolation capture, deferred component setup, short-circuit
72
+ values, optional maps, slots and component prop identity in isolated Bun and Node
73
+ consumers. Without the variable,
74
+ that compiler integration case is explicitly skipped; runtime cases still run.
75
+
76
+ The local authored compiler retains whitespace in `pre`/`textarea`, including
77
+ nested elements and expression boundaries, and keeps same-line root sibling
78
+ separators. These factories serialize initial newlines using literal HTML rules;
79
+ the browser consumes the first newline after `pre`/`textarea`. Ordinary native
80
+ DOM factories keep their existing textarea property-value behavior.
81
+
82
+ Conditional and mapped markup retains text punctuation, including apostrophes,
83
+ colons, question marks and operator-like text. Nested template substitutions
84
+ work in child and attribute expressions, while quoted attribute braces stay literal.
85
+ Authored regex/division boundaries use Crepuscularity's existing JavaScript
86
+ parser, including nested templates, attributes and JavaScript groups. Astro
87
+ void tags stay in the markup frontend; no host runtime or parser enters the SDK.
88
+ Namespace/directive attributes, generic `Props`, and map callbacks with
89
+ index/destructuring/block bodies are not yet supported. These parser limits remain work in Crepuscularity.
90
+
91
+ Local component prop spreads now preserve ordinary JavaScript override order,
92
+ getter evaluation and own string/symbol keys. Forwarding `Astro.props` works
93
+ through imported components; ordinary `children`/`slots` props remain separate
94
+ from projected slots. Spread `class:list` normalizes against the final `class`
95
+ after overrides. Nullish spreads contribute no props. Slot outlet spreads remain
96
+ rejected. Compiler lowering is local and unpublished.
97
+
98
+ Local intrinsic spreads use ordered attribute segments rather than merged props.
99
+ Own enumerable string getters run once, in order, with coercion before the next
100
+ getter/expression; inherited and symbol keys are ignored. Function values stringify
101
+ without invocation. Literal and dynamic boolean values retain their separate
102
+ rules. Repeated attributes (including spread classes) remain separate; HTML parsing
103
+ keeps the first. Authored `class` plus `class:list` combines at the directive position.
104
+ The opt-in `/ssr` compiler helpers are `sourceAttribute`, `sourceSpread` and
105
+ `sourceElement`; ordinary no-spread factories retain their existing path.
106
+
107
+ Moonshine retains its server constraints: event attributes are filtered, invalid
108
+ names throw, script/style elements and spread directives/namespaces reject.
109
+ These differ from Astro's more permissive spread handling. Nullish spreads are
110
+ empty; string/array index keys fail attribute-name validation. Raw-content-looking
111
+ names remain escaped ordinary attributes, not HTML injection instructions.
112
+
113
+ An authored fixture passes three fresh SSR requests in Bun and minified Node,
114
+ plus Chromium parsing, input editing and form reset with no client script. Six
115
+ parsed cases match actual Astro 7.4.0 attribute helpers, with event filtering
116
+ recorded separately. The reference uses compiler 4.0.0 segment output and runtime
117
+ helpers separately, not a complete host compilation/rendering comparison. The
118
+ fixture is 5,860 gzip bytes; an ordinary no-spread control stays 12,844 raw bytes
119
+ and changes from 4,902 to 4,903 gzip bytes. No host bundle or speed claim.
120
+
121
+ Without prop spreads, combined `class` and `class:list` use the existing helper.
122
+ The ordinary class evaluates first at the directive position. Empty HTML classes
123
+ are omitted. Component factories omit an empty normalized class-list prop while
124
+ retaining an explicitly supplied empty ordinary `class` prop.
125
+
126
+ Local authored slot lowering now supports default and nonempty literal named
127
+ slots, grouping of same-name children, named `<Fragment slot="...">` (including
128
+ `<Fragment set:html={...} />` and `<Fragment set:text={...} />`), `is:raw` literal
129
+ curlies in authored templates, and forwarding through imported layouts. An explicit
130
+ empty slot suppresses fallback; whitespace-only ordinary component content supplies
131
+ no slot. Projected HTML loses the marker, while projected components retain their
132
+ ordinary `slot` prop. Dynamic/empty outlet names and misplaced markers reject
133
+ explicitly. `Astro.slots.has(name)` and synchronous `Astro.slots.render(name, args?)`
134
+ (with optional callback argument arrays via `sourceRenderSlot`) are supported in
135
+ frontmatter and template expressions; bare `Astro.slots` bag access, method extraction,
136
+ computed/optional access and unrelated Astro globals remain unsupported.
137
+
138
+ Local source now supports ordinary `Astro.slots.has(nameExpression)` and
139
+ synchronous `Astro.slots.render(nameExpression, argsExpression?)` calls in
140
+ frontmatter and template expressions (usable with or without `await`), including
141
+ dynamic strings, parameterized slot callbacks, and nested `Astro.props` reads. For example:
142
+
143
+ ```astro
144
+ ---
145
+ interface Props { lookup?: string }
146
+ const present = Astro.slots.has(Astro.props.lookup ?? "head");
147
+ ---
148
+ <section data-present={String(present)}><slot name="head">fallback</slot></section>
149
+ ```
150
+
151
+ Presence uses the existing native own-slot protocol: an explicitly empty supplied
152
+ slot counts, missing/inherited names do not. The query never renders content or
153
+ reads its value. It works without a slot outlet; an unused child that would throw
154
+ stays unevaluated. Shadowed local `Astro` bindings remain ordinary JavaScript.
155
+ Native own-slot behavior differs from Astro's inherited-name and reserved-member
156
+ quirks; it does not implement the host Slots instance ABI.
157
+
158
+ The real Astro 7.4.0 Slots class and @astrojs/compiler 4.0.0 were checked separately
159
+ for presence values and emitted slot shapes. Six native source cases pass
160
+ repeated fresh Bun/minified Node SSR, with dynamic argument evaluation once and
161
+ no Astro/React/parser WASM in the runtime graph. Both source/declaration type
162
+ lanes pass. The native fixture is 5,592 gzip bytes; there is no full host bundle
163
+ or timing comparison. A no-slot control bundle is byte-identical before/after
164
+ the helper addition. Compiler changes remain local and unpublished.
165
+
166
+ Generated calls use the compiler-facing `sourceComponent` / `sourceSlot` /
167
+ `sourceHasSlot` / `sourceRenderSlot` contract. Slot values stay outside ordinary props, including `children` and
168
+ `slots`. Props and template interpolations capture when the parent constructs
169
+ its template; component frontmatter runs during serialization, once per
170
+ invocation. Unused slot content stays lazy, repeated outlets render it again,
171
+ and fallback interpolations capture eagerly while fallback components defer.
172
+ Deferred content retains its caller's native SSR owner. Construct these helpers
173
+ inside `renderToString(() => ...)`; ordinary public `h` invocation is unchanged.
174
+ This compiler integration is local and unpublished. The companion runtime
175
+ helpers are available in SDK 0.4.22. This is not Astro's compiled component ABI;
176
+ async rendering, hydration and full slot/source coverage remain incomplete.
177
+
178
+ Local `.astro` compilation also rewrites `astro:actions`, `astro:assets`,
179
+ `astro:content`, `astro:schema`, `astro/zod`, `astro:env` (`astro:env/client`,
180
+ `astro:env/server`, `astro:env/setup`), `astro:i18n`, `astro:middleware`,
181
+ `astro:prefetch`, `astro:transitions` (`astro:transitions/client`),
182
+ `astro/config`, and `astro/loaders` imports onto `@tschk/moonshine-astro/*`,
183
+ lowers `<Astro.self>` and `Astro.self` to recursive component factory
184
+ references, lowers Astro 5 `<Component server:defer>` Server Islands (with
185
+ `<slot name="fallback">` / `slot="fallback"`) to `sourceServerIsland` in
186
+ `@tschk/moonshine-astro/ssr` (supporting both eager synchronous SSR and deferred
187
+ `<astro-server-island>` placeholder shells resolved via
188
+ `astro.resolveServerIsland(id)` / `astro.resolveAllServerIslands(html)` when
189
+ `deferServerIslands: true` is set on `withAstroContext`), and lowers
190
+ `Astro.url`, `Astro.request`, `Astro.params`, `Astro.locals`, `Astro.cookies`,
191
+ `Astro.session`, `Astro.site`, `Astro.generator`, `Astro.clientAddress`,
192
+ `Astro.response`, `Astro.originPathname`, `Astro.routePattern`,
193
+ `Astro.isPrerendered`, `Astro.preferredLocale`, `Astro.preferredLocaleList`,
194
+ `Astro.currentLocale`, `Astro.redirect`, `Astro.rewrite`, `Astro.callAction`,
195
+ and `Astro.getActionResult` in frontmatter and template expressions to
196
+ `useAstro()` from `@tschk/moonshine-astro/ssr`.
197
+ On HTML elements, `define:vars={{ ... }}` and `transition:name` merge into
198
+ `style` via `mergeDefineVars` (`defineStyleVars`), while `transition:animate`,
199
+ `transition:persist`, and `transition:persist-props` lower to
200
+ `data-astro-transition-scope`, `data-astro-transition-persist`, and
201
+ `data-astro-transition-persist-props` via `transitionAnimateValue`,
202
+ `transitionPersistValue`, and `transitionPersistPropsValue`.
203
+ `<Image>` and `<Picture>` in `@tschk/moonshine-astro/assets` and `<ClientRouter>`
204
+ / `<ViewTransitions>` in `@tschk/moonshine-astro/transitions` render synchronous
205
+ server HTML without Astro host packages.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tschk/moonshine-astro",
3
- "version": "0.4.4",
3
+ "version": "0.4.80",
4
4
  "description": "Native signal bridges and rendering with optional legacy astro entries",
5
5
  "license": "ISC",
6
6
  "type": "module",
@@ -8,18 +8,31 @@
8
8
  "types": "./src/index.ts",
9
9
  "exports": {
10
10
  ".": "./src/index.ts",
11
- "./compiler": "./src/compiler.ts"
11
+ "./actions": "./src/actions.ts",
12
+ "./assets": "./src/assets.ts",
13
+ "./compiler": "./src/compiler.ts",
14
+ "./config": "./src/config.ts",
15
+ "./container": "./src/container.ts",
16
+ "./content": "./src/content.ts",
17
+ "./context": "./src/context.ts",
18
+ "./env": "./src/env.ts",
19
+ "./i18n": "./src/i18n.ts",
20
+ "./loaders": "./src/loaders.ts",
21
+ "./middleware": "./src/middleware.ts",
22
+ "./routing": "./src/routing.ts",
23
+ "./ssr": "./src/ssr.ts",
24
+ "./transitions": "./src/transitions.ts"
12
25
  },
13
26
  "dependencies": {
14
- "@tschk/moonshine": "^0.4.4",
15
- "@tschk/moonshine-dom": "^0.4.4"
27
+ "@tschk/moonshine": "^0.4.80",
28
+ "@tschk/moonshine-dom": "^0.4.80"
16
29
  },
17
30
  "devDependencies": {
18
31
  "typescript": "7.0.2"
19
32
  },
20
33
  "peerDependencies": {
21
34
  "astro": ">=4",
22
- "@tschk/moonshine-framework": "^0.4.4"
35
+ "@tschk/moonshine-framework": "^0.4.80"
23
36
  },
24
37
  "peerDependenciesMeta": {
25
38
  "astro": {