@constela/start 1.8.27 → 1.9.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 +120 -1
- package/package.json +7 -7
package/README.md
CHANGED
|
@@ -300,6 +300,71 @@ However, these words are allowed inside string literals:
|
|
|
300
300
|
<PropsTable items={[{ description: "operations that require one" }]} />
|
|
301
301
|
```
|
|
302
302
|
|
|
303
|
+
## Islands Architecture
|
|
304
|
+
|
|
305
|
+
Define interactive islands for partial hydration:
|
|
306
|
+
|
|
307
|
+
```json
|
|
308
|
+
{
|
|
309
|
+
"view": {
|
|
310
|
+
"kind": "element",
|
|
311
|
+
"tag": "div",
|
|
312
|
+
"children": [
|
|
313
|
+
{
|
|
314
|
+
"kind": "island",
|
|
315
|
+
"id": "interactive-counter",
|
|
316
|
+
"strategy": "visible",
|
|
317
|
+
"strategyOptions": { "threshold": 0.5 },
|
|
318
|
+
"content": {
|
|
319
|
+
"kind": "element",
|
|
320
|
+
"tag": "button",
|
|
321
|
+
"props": { "onClick": { "event": "click", "action": "increment" } },
|
|
322
|
+
"children": [{ "kind": "text", "value": { "expr": "state", "name": "count" } }]
|
|
323
|
+
},
|
|
324
|
+
"state": {
|
|
325
|
+
"count": { "type": "number", "initial": 0 }
|
|
326
|
+
},
|
|
327
|
+
"actions": [
|
|
328
|
+
{
|
|
329
|
+
"name": "increment",
|
|
330
|
+
"steps": [{ "do": "update", "target": "count", "operation": "increment" }]
|
|
331
|
+
}
|
|
332
|
+
]
|
|
333
|
+
}
|
|
334
|
+
]
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
```
|
|
338
|
+
|
|
339
|
+
**Hydration Strategies:**
|
|
340
|
+
|
|
341
|
+
| Strategy | When to Hydrate | Use Case |
|
|
342
|
+
|----------|-----------------|----------|
|
|
343
|
+
| `load` | Immediately | Critical interactive elements |
|
|
344
|
+
| `idle` | Browser idle | Non-urgent interactions |
|
|
345
|
+
| `visible` | In viewport | Below-the-fold content |
|
|
346
|
+
| `interaction` | User interaction | Lazy-loaded widgets |
|
|
347
|
+
| `media` | Media query match | Responsive components |
|
|
348
|
+
| `never` | Never | Static content only |
|
|
349
|
+
|
|
350
|
+
**Build Optimization:**
|
|
351
|
+
|
|
352
|
+
Islands are automatically code-split during build:
|
|
353
|
+
|
|
354
|
+
```bash
|
|
355
|
+
npx constela build --islands
|
|
356
|
+
```
|
|
357
|
+
|
|
358
|
+
Output structure:
|
|
359
|
+
|
|
360
|
+
```
|
|
361
|
+
dist/
|
|
362
|
+
_islands/
|
|
363
|
+
interactive-counter.js # Island-specific bundle
|
|
364
|
+
chart-widget.js
|
|
365
|
+
client.js # Main client bundle
|
|
366
|
+
```
|
|
367
|
+
|
|
303
368
|
## Configuration
|
|
304
369
|
|
|
305
370
|
Create `constela.config.json`:
|
|
@@ -308,7 +373,15 @@ Create `constela.config.json`:
|
|
|
308
373
|
{
|
|
309
374
|
"adapter": "node",
|
|
310
375
|
"css": "src/styles/globals.css",
|
|
311
|
-
"layoutsDir": "src/layouts"
|
|
376
|
+
"layoutsDir": "src/layouts",
|
|
377
|
+
"islands": {
|
|
378
|
+
"enabled": true,
|
|
379
|
+
"defaultStrategy": "visible"
|
|
380
|
+
},
|
|
381
|
+
"streaming": {
|
|
382
|
+
"enabled": true,
|
|
383
|
+
"flushStrategy": "batched"
|
|
384
|
+
}
|
|
312
385
|
}
|
|
313
386
|
```
|
|
314
387
|
|
|
@@ -385,17 +458,63 @@ export default async (ctx, next) => {
|
|
|
385
458
|
|
|
386
459
|
### Edge Adapters
|
|
387
460
|
|
|
461
|
+
Deploy to any edge platform with streaming support:
|
|
462
|
+
|
|
388
463
|
```typescript
|
|
389
464
|
import { createAdapter } from '@constela/start';
|
|
390
465
|
|
|
391
466
|
const adapter = createAdapter({
|
|
392
467
|
platform: 'cloudflare',
|
|
393
468
|
routes: scannedRoutes,
|
|
469
|
+
streaming: true,
|
|
394
470
|
});
|
|
395
471
|
|
|
396
472
|
export default { fetch: adapter.fetch };
|
|
397
473
|
```
|
|
398
474
|
|
|
475
|
+
**Platform-specific adapters:**
|
|
476
|
+
|
|
477
|
+
```typescript
|
|
478
|
+
// Cloudflare Workers
|
|
479
|
+
import { cloudflareAdapter } from '@constela/start/adapters/cloudflare';
|
|
480
|
+
|
|
481
|
+
export default {
|
|
482
|
+
fetch: cloudflareAdapter({
|
|
483
|
+
routes: scannedRoutes,
|
|
484
|
+
streaming: true,
|
|
485
|
+
}),
|
|
486
|
+
};
|
|
487
|
+
|
|
488
|
+
// Vercel Edge
|
|
489
|
+
import { vercelAdapter } from '@constela/start/adapters/vercel';
|
|
490
|
+
|
|
491
|
+
export const config = { runtime: 'edge' };
|
|
492
|
+
export default vercelAdapter({ routes: scannedRoutes, streaming: true });
|
|
493
|
+
|
|
494
|
+
// Deno Deploy
|
|
495
|
+
import { denoAdapter } from '@constela/start/adapters/deno';
|
|
496
|
+
|
|
497
|
+
Deno.serve(denoAdapter({ routes: scannedRoutes, streaming: true }));
|
|
498
|
+
|
|
499
|
+
// Node.js
|
|
500
|
+
import { nodeAdapter } from '@constela/start/adapters/node';
|
|
501
|
+
import { createServer } from 'http';
|
|
502
|
+
|
|
503
|
+
const handler = nodeAdapter({ routes: scannedRoutes, streaming: true });
|
|
504
|
+
createServer(handler).listen(3000);
|
|
505
|
+
```
|
|
506
|
+
|
|
507
|
+
**Streaming Response:**
|
|
508
|
+
|
|
509
|
+
All adapters support streaming HTML responses:
|
|
510
|
+
|
|
511
|
+
```typescript
|
|
512
|
+
// Returns ReadableStream<Uint8Array> for streaming
|
|
513
|
+
const response = await adapter.fetch(request);
|
|
514
|
+
// Content-Type: text/html; charset=utf-8
|
|
515
|
+
// Transfer-Encoding: chunked
|
|
516
|
+
```
|
|
517
|
+
|
|
399
518
|
## License
|
|
400
519
|
|
|
401
520
|
MIT
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@constela/start",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.9.1",
|
|
4
4
|
"description": "Meta-framework for Constela applications",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -44,12 +44,12 @@
|
|
|
44
44
|
"@tailwindcss/postcss": "^4.0.0",
|
|
45
45
|
"tailwindcss": "^4.0.0",
|
|
46
46
|
"ws": "^8.18.0",
|
|
47
|
-
"@constela/
|
|
48
|
-
"@constela/core": "0.
|
|
49
|
-
"@constela/
|
|
50
|
-
"@constela/server": "
|
|
51
|
-
"@constela/
|
|
52
|
-
"@constela/
|
|
47
|
+
"@constela/ai": "2.0.1",
|
|
48
|
+
"@constela/core": "0.17.1",
|
|
49
|
+
"@constela/router": "19.0.0",
|
|
50
|
+
"@constela/server": "13.0.0",
|
|
51
|
+
"@constela/runtime": "1.0.1",
|
|
52
|
+
"@constela/compiler": "0.15.1"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
55
|
"@types/ws": "^8.5.0",
|