@ox-content/islands 3.1.3 → 3.1.5

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.
@@ -0,0 +1,86 @@
1
+ //#region src/types.d.ts
2
+ /**
3
+ * Island Architecture Types
4
+ *
5
+ * Framework-agnostic type definitions for the Island system.
6
+ */
7
+ /**
8
+ * Loading strategy for islands.
9
+ *
10
+ * - `eager`: Hydrate immediately on page load
11
+ * - `idle`: Hydrate when the browser is idle (requestIdleCallback)
12
+ * - `visible`: Hydrate when the element becomes visible (IntersectionObserver)
13
+ * - `media`: Hydrate when a media query matches
14
+ */
15
+ type LoadStrategy = "eager" | "idle" | "visible" | "media";
16
+ /**
17
+ * Island configuration extracted from data attributes.
18
+ */
19
+ interface IslandConfig {
20
+ /** Unique island identifier */
21
+ id: string;
22
+ /** Component name to hydrate */
23
+ component: string;
24
+ /** Loading strategy */
25
+ load: LoadStrategy;
26
+ /** Media query for 'media' load strategy */
27
+ mediaQuery?: string;
28
+ /** Component props (JSON serialized in data-ox-props) */
29
+ props: Record<string, unknown>;
30
+ /** Whether the island wrapper already contains server-rendered component HTML. */
31
+ ssr?: boolean;
32
+ }
33
+ /**
34
+ * Hydration function signature.
35
+ *
36
+ * Called when an island should be hydrated.
37
+ * Returns an optional cleanup function.
38
+ */
39
+ type HydrateFunction = (element: HTMLElement, props: Record<string, unknown>) => void | (() => void) | PromiseLike<void | (() => void)>;
40
+ /**
41
+ * Component registry mapping component names to hydrate functions.
42
+ */
43
+ type ComponentRegistry = Map<string, HydrateFunction>;
44
+ /**
45
+ * Options for initializing islands.
46
+ */
47
+ interface InitIslandsOptions {
48
+ /** Root margin for IntersectionObserver (visible strategy). Default: "200px" */
49
+ rootMargin?: string;
50
+ /** Threshold for IntersectionObserver. Default: 0 */
51
+ threshold?: number;
52
+ /** Timeout for idle callback fallback in ms. Default: 200 */
53
+ idleTimeout?: number;
54
+ /** Custom selector for finding islands. Default: "[data-ox-island]" */
55
+ selector?: string;
56
+ /** Called when an island starts hydrating */
57
+ onHydrateStart?: (element: HTMLElement, config: IslandConfig) => void;
58
+ /** Called when an island finishes hydrating */
59
+ onHydrateEnd?: (element: HTMLElement, config: IslandConfig) => void;
60
+ /** Called when hydration fails */
61
+ onHydrateError?: (element: HTMLElement, config: IslandConfig, error: Error) => void;
62
+ }
63
+ /**
64
+ * Island instance tracking.
65
+ */
66
+ interface IslandInstance {
67
+ element: HTMLElement;
68
+ config: IslandConfig;
69
+ cleanup?: () => void;
70
+ hydrating?: boolean;
71
+ hydrated: boolean;
72
+ }
73
+ /**
74
+ * Island controller returned by initIslands.
75
+ */
76
+ interface IslandController {
77
+ /** All tracked island instances */
78
+ instances: IslandInstance[];
79
+ /** Manually hydrate a specific island */
80
+ hydrate: (element: HTMLElement) => void;
81
+ /** Destroy all islands and cleanup */
82
+ destroy: () => void;
83
+ }
84
+ //#endregion
85
+ export { IslandController as a, IslandConfig as i, HydrateFunction as n, IslandInstance as o, InitIslandsOptions as r, LoadStrategy as s, ComponentRegistry as t };
86
+ //# sourceMappingURL=types.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.mts","names":[],"sources":["../src/types.ts"],"mappings":";;;;;;;;;;;;;;KAcY;;;;UAKK;;EAEf;;EAEA;;EAEA,MAAM;;EAEN;;EAEA,OAAO;;EAEP;;;;;;;;KASU,mBACV,SAAS,aACT,OAAO,kDACkB;;;;KAKf,oBAAoB,YAAY;;;;UAK3B;;EAEf;;EAEA;;EAEA;;EAEA;;EAEA,kBAAkB,SAAS,aAAa,QAAQ;;EAEhD,gBAAgB,SAAS,aAAa,QAAQ;;EAE9C,kBAAkB,SAAS,aAAa,QAAQ,cAAc,OAAO;;;;;UAMtD;EACf,SAAS;EACT,QAAQ;EACR;EACA;EACA;;;;;UAMe;;EAEf,WAAW;;EAEX,UAAU,SAAS;;EAEnB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ox-content/islands",
3
- "version": "3.1.3",
3
+ "version": "3.1.5",
4
4
  "description": "Framework-agnostic Island Architecture for ox-content",
5
5
  "keywords": [
6
6
  "framework-agnostic",
@@ -24,12 +24,34 @@
24
24
  "types": "./dist/index.d.mts",
25
25
  "exports": {
26
26
  ".": {
27
- "import": "./dist/index.mjs",
28
- "types": "./dist/index.d.mts"
27
+ "import": {
28
+ "types": "./dist/index.d.mts",
29
+ "default": "./dist/index.mjs"
30
+ },
31
+ "require": {
32
+ "types": "./dist/index.d.cts",
33
+ "default": "./dist/index.cjs"
34
+ }
29
35
  },
30
36
  "./runtime": {
31
- "import": "./dist/runtime.mjs",
32
- "types": "./dist/runtime.d.mts"
37
+ "import": {
38
+ "types": "./dist/runtime.d.mts",
39
+ "default": "./dist/runtime.mjs"
40
+ },
41
+ "require": {
42
+ "types": "./dist/runtime.d.cts",
43
+ "default": "./dist/runtime.cjs"
44
+ }
45
+ },
46
+ "./html-host": {
47
+ "import": {
48
+ "types": "./dist/html-host.d.mts",
49
+ "default": "./dist/html-host.mjs"
50
+ },
51
+ "require": {
52
+ "types": "./dist/html-host.d.cts",
53
+ "default": "./dist/html-host.cjs"
54
+ }
33
55
  }
34
56
  },
35
57
  "publishConfig": {
@@ -42,7 +64,7 @@
42
64
  "vite-plus": "0.3.0"
43
65
  },
44
66
  "scripts": {
45
- "build": "vp pack",
67
+ "build": "vp pack && node ../../tools/scripts/stabilize-public-declaration-exports.mjs @ox-content/islands",
46
68
  "dev": "vp pack --watch",
47
69
  "typecheck": "tsgo --noEmit"
48
70
  }
@@ -1,2 +0,0 @@
1
- import { n as initIslands, r as isIslandsSupported, t as createDeferredInit } from "./runtime.mjs";
2
- export { createDeferredInit, initIslands, isIslandsSupported };