nuclo 0.1.53 → 0.1.55

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.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/when/index.ts"],"names":[],"mappings":"AAQA,KAAK,aAAa,GAAG,OAAO,GAAG,CAAC,MAAM,OAAO,CAAC,CAAC;AAC/C,KAAK,WAAW,CAAC,QAAQ,SAAS,cAAc,GAAG,cAAc,IAC/D,OAAO,CAAC,QAAQ,CAAC,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAC;AAwL1C;;;;;;;;;;;;;GAaG;AACH,wBAAgB,kBAAkB,IAAI,IAAI,CAQzC;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,IAAI,IAAI,CAExC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,wBAAgB,IAAI,CAAC,QAAQ,SAAS,cAAc,GAAG,cAAc,EACnE,SAAS,EAAE,aAAa,EACxB,GAAG,OAAO,EAAE,WAAW,CAAC,QAAQ,CAAC,EAAE,GAClC,WAAW,CAAC,QAAQ,CAAC,CAGvB"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/when/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAE5D,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAElE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,wBAAgB,IAAI,CAAC,QAAQ,SAAS,cAAc,GAAG,cAAc,EACnE,SAAS,EAAE,aAAa,EACxB,GAAG,OAAO,EAAE,WAAW,CAAC,QAAQ,CAAC,EAAE,GAClC,WAAW,CAAC,QAAQ,CAAC,CAGvB"}
@@ -0,0 +1,6 @@
1
+ import type { WhenContent } from "./runtime";
2
+ /**
3
+ * Renders a list of content items and collects the resulting nodes.
4
+ */
5
+ export declare function renderContentItems<TTagName extends ElementTagName>(items: ReadonlyArray<WhenContent<TTagName>>, host: ExpandedElement<TTagName>, index: number, endMarker: Comment): Node[];
6
+ //# sourceMappingURL=renderer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"renderer.d.ts","sourceRoot":"","sources":["../../src/when/renderer.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AA6B7C;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,QAAQ,SAAS,cAAc,EAChE,KAAK,EAAE,aAAa,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC,EAC3C,IAAI,EAAE,eAAe,CAAC,QAAQ,CAAC,EAC/B,KAAK,EAAE,MAAM,EACb,SAAS,EAAE,OAAO,GACjB,IAAI,EAAE,CASR"}
@@ -0,0 +1,54 @@
1
+ export type WhenCondition = boolean | (() => boolean);
2
+ export type WhenContent<TTagName extends ElementTagName = ElementTagName> = NodeMod<TTagName> | NodeModFn<TTagName>;
3
+ export interface WhenGroup<TTagName extends ElementTagName = ElementTagName> {
4
+ condition: WhenCondition;
5
+ content: WhenContent<TTagName>[];
6
+ }
7
+ export interface WhenRuntime<TTagName extends ElementTagName = ElementTagName> {
8
+ startMarker: Comment;
9
+ endMarker: Comment;
10
+ host: ExpandedElement<TTagName>;
11
+ index: number;
12
+ groups: WhenGroup<TTagName>[];
13
+ elseContent: WhenContent<TTagName>[];
14
+ /**
15
+ * Tracks which branch is currently rendered:
16
+ * - null: nothing rendered yet
17
+ * - -1: else branch
18
+ * - >=0: index of groups[]
19
+ */
20
+ activeIndex: number | -1 | null;
21
+ update(): void;
22
+ }
23
+ /**
24
+ * Main render function for when/else conditionals.
25
+ * Evaluates conditions, clears old content, and renders the active branch.
26
+ */
27
+ export declare function renderWhenContent<TTagName extends ElementTagName>(runtime: WhenRuntime<TTagName>): void;
28
+ /**
29
+ * Registers a when runtime for tracking and updates
30
+ */
31
+ export declare function registerWhenRuntime<TTagName extends ElementTagName>(runtime: WhenRuntime<TTagName>): void;
32
+ /**
33
+ * Updates all active when/else conditional runtimes.
34
+ *
35
+ * Re-evaluates all conditional branches and re-renders if the active branch has changed.
36
+ * Automatically cleans up runtimes that throw errors during update.
37
+ *
38
+ * This function should be called after state changes that affect conditional expressions.
39
+ *
40
+ * @example
41
+ * ```ts
42
+ * isLoggedIn.value = true;
43
+ * updateWhenRuntimes(); // All when() conditionals re-evaluate
44
+ * ```
45
+ */
46
+ export declare function updateWhenRuntimes(): void;
47
+ /**
48
+ * Clears all active when/else conditional runtimes.
49
+ *
50
+ * This is typically used for cleanup or testing purposes.
51
+ * After calling this, no when() conditionals will be tracked for updates.
52
+ */
53
+ export declare function clearWhenRuntimes(): void;
54
+ //# sourceMappingURL=runtime.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../src/when/runtime.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,aAAa,GAAG,OAAO,GAAG,CAAC,MAAM,OAAO,CAAC,CAAC;AACtD,MAAM,MAAM,WAAW,CAAC,QAAQ,SAAS,cAAc,GAAG,cAAc,IACtE,OAAO,CAAC,QAAQ,CAAC,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAC;AAE1C,MAAM,WAAW,SAAS,CAAC,QAAQ,SAAS,cAAc,GAAG,cAAc;IACzE,SAAS,EAAE,aAAa,CAAC;IACzB,OAAO,EAAE,WAAW,CAAC,QAAQ,CAAC,EAAE,CAAC;CAClC;AAED,MAAM,WAAW,WAAW,CAAC,QAAQ,SAAS,cAAc,GAAG,cAAc;IAC3E,WAAW,EAAE,OAAO,CAAC;IACrB,SAAS,EAAE,OAAO,CAAC;IACnB,IAAI,EAAE,eAAe,CAAC,QAAQ,CAAC,CAAC;IAChC,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,SAAS,CAAC,QAAQ,CAAC,EAAE,CAAC;IAC9B,WAAW,EAAE,WAAW,CAAC,QAAQ,CAAC,EAAE,CAAC;IACrC;;;;;OAKG;IACH,WAAW,EAAE,MAAM,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC;IAChC,MAAM,IAAI,IAAI,CAAC;CAChB;AAoBD;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,SAAS,cAAc,EAC/D,OAAO,EAAE,WAAW,CAAC,QAAQ,CAAC,GAC7B,IAAI,CAoBN;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,SAAS,cAAc,EACjE,OAAO,EAAE,WAAW,CAAC,QAAQ,CAAC,GAC7B,IAAI,CAEN;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,kBAAkB,IAAI,IAAI,CAQzC;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,IAAI,IAAI,CAExC"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "nuclo",
3
3
  "private": false,
4
- "version": "0.1.53",
4
+ "version": "0.1.55",
5
5
  "type": "module",
6
6
  "main": "./dist/nuclo.cjs",
7
7
  "module": "./dist/nuclo.js",
@@ -29,15 +29,15 @@
29
29
  "@rollup/plugin-terser": "^0.4.4",
30
30
  "@rollup/plugin-typescript": "^12.3.0",
31
31
  "@types/node": "^24.10.1",
32
- "@vitest/coverage-v8": "4.0.9",
32
+ "@vitest/coverage-v8": "4.0.10",
33
33
  "eslint": "^9.39.1",
34
34
  "globals": "^16.5.0",
35
35
  "jsdom": "^27.2.0",
36
- "rollup": "^4.53.2",
36
+ "rollup": "^4.53.3",
37
37
  "tslib": "^2.8.1",
38
38
  "typescript": "^5.9.3",
39
- "typescript-eslint": "^8.46.4",
40
- "vitest": "^4.0.9"
39
+ "typescript-eslint": "^8.47.0",
40
+ "vitest": "^4.0.10"
41
41
  },
42
42
  "repository": {
43
43
  "type": "git",