ilha 0.2.0 → 0.2.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 CHANGED
@@ -25,7 +25,7 @@ const Counter = ilha
25
25
  .render(
26
26
  ({ state }) => html`
27
27
  <div>
28
- <p>Count: ${state.count}</p>
28
+ <p>Count: ${state.count()}</p>
29
29
  <button>Increment</button>
30
30
  </div>
31
31
  `,
@@ -50,11 +50,21 @@ State is managed with signals — when a signal changes, only the affected islan
50
50
 
51
51
  ## Builder API
52
52
 
53
- Every island starts from the `ilha` builder object (or `ilha.input()` if you need typed props).
53
+ Every island starts from the `ilha` builder object (or `ilha.input<T>()` / `ilha.input(schema)` if you need typed props).
54
54
 
55
- ### `ilha.input(schema)`
55
+ ### `ilha.input<T>()` / `ilha.input(schema)`
56
56
 
57
- Declares the island's external input type using any [Standard Schema](https://standardschema.dev/) compatible validator (e.g. Zod, Valibot, ArkType).
57
+ Declares the island's external input type. Two forms:
58
+
59
+ **1. Type-only (no runtime validation):**
60
+
61
+ ```ts
62
+ const MyIsland = ilha
63
+ .input<{ name: string }>()
64
+ .render(({ input }) => `<p>Hello, ${input.name}!</p>`);
65
+ ```
66
+
67
+ **2. With a [Standard Schema](https://standardschema.dev/) validator** (Zod, Valibot, ArkType, etc.) — runs validation at render time and uses the schema's inferred output type:
58
68
 
59
69
  ```ts
60
70
  import { z } from "zod";
@@ -370,13 +380,13 @@ Async method that renders the island wrapped in a `data-ilha` hydration containe
370
380
  const html = await MyIsland.hydratable(
371
381
  { name: "Ilha" },
372
382
  {
373
- name: "my-island", // registry key for client-side activation
383
+ name: "MyIsland", // registry key for client-side activation
374
384
  as: "div", // wrapper tag (default: "div")
375
385
  snapshot: true, // embed state + derived as data-ilha-state
376
386
  skipOnMount: false, // skip onMount on hydration (default: true when snapshot)
377
387
  },
378
388
  );
379
- // → '<div data-ilha="my-island" data-ilha-props="…" data-ilha-state="…">…</div>'
389
+ // → '<div data-ilha="MyIsland" data-ilha-props="…" data-ilha-state="…">…</div>'
380
390
  ```
381
391
 
382
392
  **`snapshot` option:**
@@ -521,20 +531,6 @@ const styles = css`
521
531
 
522
532
  ---
523
533
 
524
- ### `type(coerce?)`
525
-
526
- Creates a lightweight Standard Schema validator for use with `.input()` — useful when you don't want a full validation library.
527
-
528
- ```ts
529
- import { type } from "ilha";
530
-
531
- const MyIsland = ilha
532
- .input(type((v: unknown) => v as { count: number }))
533
- .render(({ input }) => `<p>${input.count}</p>`);
534
- ```
535
-
536
- ---
537
-
538
534
  ## SSR + Hydration
539
535
 
540
536
  The recommended SSR + hydration pattern uses `.hydratable()` on the server and `ilha.mount()` on the client.
@@ -555,7 +551,7 @@ return `<!doctype html><html><body>${html}</body></html>`;
555
551
  import { mount } from "ilha";
556
552
  import { MyIsland } from "./islands";
557
553
 
558
- mount({ "my-island": MyIsland });
554
+ mount({ MyIsland });
559
555
  ```
560
556
 
561
557
  The client reads `data-ilha-state` to restore signal values from the snapshot, skipping a needless re-render and calling `.onMount()` only if `skipOnMount` is not set.
@@ -565,7 +561,7 @@ The client reads `data-ilha-state` to restore signal values from the snapshot, s
565
561
  ```
566
562
  server client
567
563
  ────────────────────────────────────── ──────────────────────────────────────────
568
- .hydratable({ count: 42 }, { mount({ "my-island": MyIsland })
564
+ .hydratable({ count: 42 }, { mount({ MyIsland })
569
565
  name: "my-island", → reads data-ilha-state
570
566
  snapshot: true → restores signals from snapshot
571
567
  }) → skips onMount (skipOnMount: true)
package/dist/index.d.ts CHANGED
@@ -182,6 +182,7 @@ interface BuilderConfig<TInput, TStateMap extends Record<string, unknown>, TDeri
182
182
  declare class IlhaBuilder<TInput extends Record<string, unknown>, TStateMap extends Record<string, unknown>, TDerivedMap extends Record<string, unknown> = Record<string, never>, TSlots extends SlotMap = Record<string, never>> {
183
183
  readonly _cfg: BuilderConfig<TInput, TStateMap, TDerivedMap, TSlots>;
184
184
  constructor(cfg: BuilderConfig<TInput, TStateMap, TDerivedMap, TSlots>);
185
+ input<T extends Record<string, unknown>>(): IlhaBuilder<T, Record<string, never>, Record<string, never>, Record<string, never>>;
185
186
  input<S extends StandardSchemaV1>(schema: S): IlhaBuilder<StandardSchemaV1.InferOutput<S> & Record<string, unknown>, Record<string, never>, Record<string, never>, Record<string, never>>;
186
187
  state<V = undefined, K extends string = string>(key: K, init?: StateInit<TInput, V> | undefined): IlhaBuilder<TInput, MergeState<TStateMap, K, V>, TDerivedMap, TSlots>;
187
188
  derived<K extends string, V>(key: K, fn: DerivedFn<TInput, TStateMap, V>): IlhaBuilder<TInput, TStateMap, TDerivedMap & Record<K, V>, TSlots>;
@@ -206,7 +207,6 @@ declare const ilha: IlhaBuilder<Record<string, unknown>, Record<string, never>,
206
207
  from: typeof ilhaFrom;
207
208
  context: typeof ilhaContext;
208
209
  };
209
- declare function type<TInput, TOutput = TInput>(coerce?: (input: TInput) => TOutput): StandardSchemaV1<TInput, TOutput>;
210
210
  declare const html: typeof ilhaHtml;
211
211
  declare const raw: typeof ilhaRaw;
212
212
  declare const css: typeof ilhaCss;
@@ -214,4 +214,4 @@ declare const mount: typeof mountAll;
214
214
  declare const from: typeof ilhaFrom;
215
215
  declare const context: typeof ilhaContext;
216
216
  //#endregion
217
- export { DerivedValue, HandlerContext, HandlerContextFor, HydratableOptions, Island, IslandDerived, IslandState, MountOptions, MountResult, OnMountContext, RawHtml, SignalAccessor, SlotAccessor, context, css, ilha as default, from, html, mount, raw, type };
217
+ export { DerivedValue, HandlerContext, HandlerContextFor, HydratableOptions, Island, IslandDerived, IslandState, MountOptions, MountResult, OnMountContext, RawHtml, SignalAccessor, SlotAccessor, context, css, ilha as default, from, html, mount, raw };
package/dist/index.js CHANGED
@@ -315,7 +315,7 @@ var IlhaBuilder = class IlhaBuilder {
315
315
  }
316
316
  input(schema) {
317
317
  return new IlhaBuilder({
318
- schema,
318
+ schema: schema ?? null,
319
319
  states: [],
320
320
  deriveds: [],
321
321
  ons: [],
@@ -843,15 +843,6 @@ const ilha = Object.assign(rootBuilder, {
843
843
  from: ilhaFrom,
844
844
  context: ilhaContext
845
845
  });
846
- function type(coerce) {
847
- return { "~standard": {
848
- version: 1,
849
- vendor: "ilha",
850
- validate(value) {
851
- return { value: coerce ? coerce(value) : value };
852
- }
853
- } };
854
- }
855
846
  const html = ilhaHtml;
856
847
  const raw = ilhaRaw;
857
848
  const css = ilhaCss;
@@ -859,4 +850,4 @@ const mount = mountAll;
859
850
  const from = ilhaFrom;
860
851
  const context = ilhaContext;
861
852
  //#endregion
862
- export { context, css, ilha as default, from, html, mount, raw, type };
853
+ export { context, css, ilha as default, from, html, mount, raw };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ilha",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "A tiny, framework-free island architecture library",
5
5
  "license": "MIT",
6
6
  "author": "Ryuz <ryuzer@proton.me>",
@@ -26,7 +26,6 @@
26
26
  "alien-signals": "3.1.2"
27
27
  },
28
28
  "devDependencies": {
29
- "docsome": "^0.0.6",
30
29
  "zod": "^4.3.6"
31
30
  }
32
31
  }