@barefootjs/client 0.1.0
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/dist/build.d.ts +56 -0
- package/dist/build.d.ts.map +1 -0
- package/dist/build.js +76 -0
- package/dist/context.d.ts +25 -0
- package/dist/context.d.ts.map +1 -0
- package/dist/csr-adapter.d.ts +26 -0
- package/dist/csr-adapter.d.ts.map +1 -0
- package/dist/forward-props.d.ts +17 -0
- package/dist/forward-props.d.ts.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +154 -0
- package/dist/reactive.d.ts +150 -0
- package/dist/reactive.d.ts.map +1 -0
- package/dist/reactive.js +215 -0
- package/dist/runtime/apply-rest-attrs.d.ts +16 -0
- package/dist/runtime/apply-rest-attrs.d.ts.map +1 -0
- package/dist/runtime/branch-slot.d.ts +22 -0
- package/dist/runtime/branch-slot.d.ts.map +1 -0
- package/dist/runtime/client-marker.d.ts +21 -0
- package/dist/runtime/client-marker.d.ts.map +1 -0
- package/dist/runtime/component.d.ts +99 -0
- package/dist/runtime/component.d.ts.map +1 -0
- package/dist/runtime/context.d.ts +40 -0
- package/dist/runtime/context.d.ts.map +1 -0
- package/dist/runtime/hydrate.d.ts +100 -0
- package/dist/runtime/hydrate.d.ts.map +1 -0
- package/dist/runtime/hydration-state.d.ts +13 -0
- package/dist/runtime/hydration-state.d.ts.map +1 -0
- package/dist/runtime/index.d.ts +27 -0
- package/dist/runtime/index.d.ts.map +1 -0
- package/dist/runtime/index.js +2093 -0
- package/dist/runtime/insert.d.ts +75 -0
- package/dist/runtime/insert.d.ts.map +1 -0
- package/dist/runtime/list.d.ts +21 -0
- package/dist/runtime/list.d.ts.map +1 -0
- package/dist/runtime/map-array.d.ts +32 -0
- package/dist/runtime/map-array.d.ts.map +1 -0
- package/dist/runtime/portal.d.ts +96 -0
- package/dist/runtime/portal.d.ts.map +1 -0
- package/dist/runtime/qsa-item.d.ts +52 -0
- package/dist/runtime/qsa-item.d.ts.map +1 -0
- package/dist/runtime/query.d.ts +86 -0
- package/dist/runtime/query.d.ts.map +1 -0
- package/dist/runtime/reconcile-elements.d.ts +44 -0
- package/dist/runtime/reconcile-elements.d.ts.map +1 -0
- package/dist/runtime/registry.d.ts +53 -0
- package/dist/runtime/registry.d.ts.map +1 -0
- package/dist/runtime/render.d.ts +35 -0
- package/dist/runtime/render.d.ts.map +1 -0
- package/dist/runtime/scope.d.ts +28 -0
- package/dist/runtime/scope.d.ts.map +1 -0
- package/dist/runtime/slot-resolver.d.ts +36 -0
- package/dist/runtime/slot-resolver.d.ts.map +1 -0
- package/dist/runtime/spread-attrs.d.ts +19 -0
- package/dist/runtime/spread-attrs.d.ts.map +1 -0
- package/dist/runtime/standalone.js +2278 -0
- package/dist/runtime/streaming.d.ts +36 -0
- package/dist/runtime/streaming.d.ts.map +1 -0
- package/dist/runtime/style.d.ts +17 -0
- package/dist/runtime/style.d.ts.map +1 -0
- package/dist/runtime/template.d.ts +39 -0
- package/dist/runtime/template.d.ts.map +1 -0
- package/dist/runtime/types.d.ts +26 -0
- package/dist/runtime/types.d.ts.map +1 -0
- package/dist/shims.d.ts +21 -0
- package/dist/shims.d.ts.map +1 -0
- package/dist/slot.d.ts +14 -0
- package/dist/slot.d.ts.map +1 -0
- package/dist/split-props.d.ts +26 -0
- package/dist/split-props.d.ts.map +1 -0
- package/dist/unwrap.d.ts +16 -0
- package/dist/unwrap.d.ts.map +1 -0
- package/package.json +71 -0
- package/src/build.ts +92 -0
- package/src/context.ts +33 -0
- package/src/csr-adapter.ts +134 -0
- package/src/forward-props.ts +43 -0
- package/src/index.ts +42 -0
- package/src/reactive.ts +411 -0
- package/src/runtime/apply-rest-attrs.ts +109 -0
- package/src/runtime/branch-slot.ts +32 -0
- package/src/runtime/client-marker.ts +46 -0
- package/src/runtime/component.ts +501 -0
- package/src/runtime/context.ts +111 -0
- package/src/runtime/hydrate.ts +311 -0
- package/src/runtime/hydration-state.ts +13 -0
- package/src/runtime/index.ts +96 -0
- package/src/runtime/insert.ts +407 -0
- package/src/runtime/list.ts +47 -0
- package/src/runtime/map-array.ts +381 -0
- package/src/runtime/portal.ts +174 -0
- package/src/runtime/qsa-item.ts +128 -0
- package/src/runtime/query.ts +632 -0
- package/src/runtime/reconcile-elements.ts +391 -0
- package/src/runtime/registry.ts +160 -0
- package/src/runtime/render.ts +105 -0
- package/src/runtime/scope.ts +46 -0
- package/src/runtime/slot-resolver.ts +66 -0
- package/src/runtime/spread-attrs.ts +88 -0
- package/src/runtime/streaming.ts +65 -0
- package/src/runtime/style.ts +27 -0
- package/src/runtime/template.ts +53 -0
- package/src/runtime/types.ts +27 -0
- package/src/shims.ts +54 -0
- package/src/slot.ts +23 -0
- package/src/split-props.ts +86 -0
- package/src/unwrap.ts +18 -0
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* BarefootJS - Conditional Insert
|
|
3
|
+
*
|
|
4
|
+
* Handle conditional DOM updates using branch configurations.
|
|
5
|
+
* SolidJS-inspired replacement for legacy cond() that properly
|
|
6
|
+
* handles event binding for both branches.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Result returned by a branch's `template()` when the template captures
|
|
10
|
+
* live DOM nodes via `__bfSlot` (#1213). `html` carries the marker-bearing
|
|
11
|
+
* HTML string; `slots[N]` is the actual `Node` referenced by the
|
|
12
|
+
* `<!--bf-slot:N-->` placeholder at the same index.
|
|
13
|
+
*/
|
|
14
|
+
export interface BranchTemplateResult {
|
|
15
|
+
html: string;
|
|
16
|
+
slots: Node[];
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Branch configuration for conditional rendering.
|
|
20
|
+
* Contains template and event binding functions for each branch.
|
|
21
|
+
*/
|
|
22
|
+
export interface BranchConfig {
|
|
23
|
+
/**
|
|
24
|
+
* HTML template function for this branch. Returns either a plain HTML
|
|
25
|
+
* string (legacy) or a `{ html, slots }` pair for templates that
|
|
26
|
+
* captured live `Node` values via `__bfSlot`.
|
|
27
|
+
*
|
|
28
|
+
* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
29
|
+
* INVARIANT — TEMPLATES RUN WITH REACTIVITY UNTRACKED.
|
|
30
|
+
* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
31
|
+
*
|
|
32
|
+
* Every call site goes through `evalBranchTemplate()` in this file,
|
|
33
|
+
* which wraps the invocation in `untrack()`. Signal reads inside
|
|
34
|
+
* the template are therefore NOT registered as effect dependencies.
|
|
35
|
+
*
|
|
36
|
+
* Consequences for authors of new branch shapes:
|
|
37
|
+
*
|
|
38
|
+
* - `template()` must produce a function of state-at-call-time only.
|
|
39
|
+
* Any reactive portion of the rendered fragment is wired up
|
|
40
|
+
* afterwards by `bindEvents()` (events + per-binding effects) and
|
|
41
|
+
* `__bfSlot` (live-Node splicing for slot-captured signals).
|
|
42
|
+
*
|
|
43
|
+
* - A template such as `() => signalA() ? '<a>' : '<b>'` is a BUG:
|
|
44
|
+
* later changes to `signalA` will not re-evaluate the template,
|
|
45
|
+
* because the read was performed without tracking. Branch
|
|
46
|
+
* selection belongs in the `conditionFn` argument of `insert()`,
|
|
47
|
+
* not inside the template body.
|
|
48
|
+
*/
|
|
49
|
+
template: () => string | BranchTemplateResult;
|
|
50
|
+
/**
|
|
51
|
+
* Bind events and reactive effects to elements within the branch.
|
|
52
|
+
* Called both during hydration (for SSR elements) and after DOM swaps.
|
|
53
|
+
* @param scope - The scope element to search within for event targets
|
|
54
|
+
* @returns Optional cleanup function, called when the branch is deactivated.
|
|
55
|
+
* Used to dispose reactive effects scoped to this branch.
|
|
56
|
+
*/
|
|
57
|
+
bindEvents: (scope: Element, opts?: {
|
|
58
|
+
isFirstRun?: boolean;
|
|
59
|
+
}) => (() => void) | void;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Handle conditional DOM updates using branch configurations.
|
|
63
|
+
*
|
|
64
|
+
* Key behaviors:
|
|
65
|
+
* - First run (hydration): Reuse SSR element, call branch.bindEvents() for current branch
|
|
66
|
+
* - Condition change: Create new element from template, call branch.bindEvents()
|
|
67
|
+
*
|
|
68
|
+
* @param scope - Component scope element
|
|
69
|
+
* @param id - Conditional slot ID (e.g., 's0')
|
|
70
|
+
* @param conditionFn - Function that returns current condition value
|
|
71
|
+
* @param whenTrue - Branch config for when condition is true
|
|
72
|
+
* @param whenFalse - Branch config for when condition is false
|
|
73
|
+
*/
|
|
74
|
+
export declare function insert(scope: Element | null, id: string, conditionFn: () => boolean, whenTrue: BranchConfig, whenFalse: BranchConfig): void;
|
|
75
|
+
//# sourceMappingURL=insert.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"insert.d.ts","sourceRoot":"","sources":["../../src/runtime/insert.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAOH;;;;;GAKG;AACH,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,IAAI,EAAE,CAAA;CACd;AAED;;;GAGG;AACH,MAAM,WAAW,YAAY;IAC3B;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;IACH,QAAQ,EAAE,MAAM,MAAM,GAAG,oBAAoB,CAAA;IAE7C;;;;;;OAMG;IACH,UAAU,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE;QAAE,UAAU,CAAC,EAAE,OAAO,CAAA;KAAE,KAAK,CAAC,MAAM,IAAI,CAAC,GAAG,IAAI,CAAA;CACrF;AAyBD;;;;;;;;;;;;GAYG;AACH,wBAAgB,MAAM,CACpB,KAAK,EAAE,OAAO,GAAG,IAAI,EACrB,EAAE,EAAE,MAAM,EACV,WAAW,EAAE,MAAM,OAAO,EAC1B,QAAQ,EAAE,YAAY,EACtB,SAAS,EAAE,YAAY,GACtB,IAAI,CAsIN"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* BarefootJS - List Reconciliation
|
|
3
|
+
*
|
|
4
|
+
* Key-based DOM reconciliation for efficient list updates.
|
|
5
|
+
* Delegates to reconcileElements for element-based rendering.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Render function type for list items.
|
|
9
|
+
* Returns an HTMLElement for each item.
|
|
10
|
+
*/
|
|
11
|
+
export type RenderItemFn<T> = (item: T, index: number) => HTMLElement;
|
|
12
|
+
/**
|
|
13
|
+
* Reconcile a list container with new items using key-based matching.
|
|
14
|
+
*
|
|
15
|
+
* @param container - The parent element containing list items
|
|
16
|
+
* @param items - Array of items to render
|
|
17
|
+
* @param getKey - Function to extract a unique key from each item (or null to use index)
|
|
18
|
+
* @param renderItem - Function to render an item as HTMLElement
|
|
19
|
+
*/
|
|
20
|
+
export declare function reconcileList<T>(container: HTMLElement | null, items: T[], getKey: ((item: T, index: number) => string) | null, renderItem: RenderItemFn<T>): void;
|
|
21
|
+
//# sourceMappingURL=list.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list.d.ts","sourceRoot":"","sources":["../../src/runtime/list.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH;;;GAGG;AACH,MAAM,MAAM,YAAY,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,KAAK,WAAW,CAAA;AAErE;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAC7B,SAAS,EAAE,WAAW,GAAG,IAAI,EAC7B,KAAK,EAAE,CAAC,EAAE,EACV,MAAM,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC,GAAG,IAAI,EACnD,UAAU,EAAE,YAAY,CAAC,CAAC,CAAC,GAC1B,IAAI,CAkBN"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* BarefootJS - Per-Item Reactive List Rendering
|
|
3
|
+
*
|
|
4
|
+
* Maps a reactive array to DOM elements with per-item scoping.
|
|
5
|
+
* Each item is rendered in its own createRoot with a per-item signal.
|
|
6
|
+
* When the array changes, same-key items UPDATE their signal instead of
|
|
7
|
+
* being disposed and recreated — fine-grained effects handle DOM updates.
|
|
8
|
+
*
|
|
9
|
+
* Unified CSR/SSR: renderItem receives an optional existing element.
|
|
10
|
+
* For SSR hydration, the existing DOM element is passed so renderItem
|
|
11
|
+
* can initialize it (initChild) instead of creating a new one (createComponent).
|
|
12
|
+
*
|
|
13
|
+
* Multi-root items (#1212): when the loop body is a JSX Fragment with two
|
|
14
|
+
* or more sibling elements, the compiler emits a `<!--bf-loop-i-->`
|
|
15
|
+
* comment before each item's roots. This module partitions the loop range
|
|
16
|
+
* by those markers so one logical item — the (startMarker, primaryEl,
|
|
17
|
+
* extras...) triple — moves, mounts, and unmounts as a single unit.
|
|
18
|
+
* Single-root loops continue to flow through the legacy path verbatim.
|
|
19
|
+
*/
|
|
20
|
+
/**
|
|
21
|
+
* Per-item scoped list rendering.
|
|
22
|
+
*
|
|
23
|
+
* @param accessor - Function returning the reactive array (signal/memo read)
|
|
24
|
+
* @param container - DOM container element
|
|
25
|
+
* @param getKey - Key extractor (null = use index). Receives plain item value.
|
|
26
|
+
* @param renderItem - Creates or initializes an HTMLElement for an item (runs in createRoot).
|
|
27
|
+
* Receives item as signal accessor: item() returns current value.
|
|
28
|
+
* When `existing` is passed, initializes the SSR-rendered element and returns it.
|
|
29
|
+
* When `existing` is undefined, creates a new element and returns it.
|
|
30
|
+
*/
|
|
31
|
+
export declare function mapArray<T>(accessor: () => T[], container: HTMLElement | null, getKey: ((item: T, index: number) => string) | null, renderItem: (item: () => T, index: number, existing?: HTMLElement) => HTMLElement, markerId?: string): void;
|
|
32
|
+
//# sourceMappingURL=map-array.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"map-array.d.ts","sourceRoot":"","sources":["../../src/runtime/map-array.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AA4LH;;;;;;;;;;GAUG;AACH,wBAAgB,QAAQ,CAAC,CAAC,EACxB,QAAQ,EAAE,MAAM,CAAC,EAAE,EACnB,SAAS,EAAE,WAAW,GAAG,IAAI,EAC7B,MAAM,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC,GAAG,IAAI,EACnD,UAAU,EAAE,CAAC,IAAI,EAAE,MAAM,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,WAAW,KAAK,WAAW,EACjF,QAAQ,CAAC,EAAE,MAAM,GAChB,IAAI,CA6JN"}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* BarefootJS - Portal Utility
|
|
3
|
+
*
|
|
4
|
+
* Client-side utility to mount elements at arbitrary DOM positions.
|
|
5
|
+
* Typically used for modals, tooltips, and other overlay UI.
|
|
6
|
+
*
|
|
7
|
+
* API inspired by React's createPortal(children, domNode).
|
|
8
|
+
*/
|
|
9
|
+
export type Portal = {
|
|
10
|
+
/** The mounted element */
|
|
11
|
+
element: HTMLElement;
|
|
12
|
+
/** Remove the mounted element from the DOM */
|
|
13
|
+
unmount: () => void;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Options for createPortal
|
|
17
|
+
*/
|
|
18
|
+
export interface PortalOptions {
|
|
19
|
+
/**
|
|
20
|
+
* The scope element that owns this portal.
|
|
21
|
+
* When provided, the portal element will have a bf-po attribute
|
|
22
|
+
* set to the scope ID, allowing find() to locate elements inside the portal.
|
|
23
|
+
*/
|
|
24
|
+
ownerScope?: Element;
|
|
25
|
+
}
|
|
26
|
+
/** Anything that can be converted to HTML string via toString() */
|
|
27
|
+
export type Renderable = {
|
|
28
|
+
toString(): string;
|
|
29
|
+
};
|
|
30
|
+
/** Valid children types for createPortal */
|
|
31
|
+
export type PortalChildren = HTMLElement | string | Renderable;
|
|
32
|
+
/**
|
|
33
|
+
* Create a portal to mount an element at a specific container
|
|
34
|
+
*
|
|
35
|
+
* Similar to React's createPortal(children, domNode), this function
|
|
36
|
+
* mounts the given element/HTML to the specified container.
|
|
37
|
+
*
|
|
38
|
+
* @param children - Element to mount (HTMLElement, HTML string, or JSX.Element)
|
|
39
|
+
* @param container - Target container element (defaults to document.body)
|
|
40
|
+
* @param options - Optional configuration including ownerScope for scope-based find()
|
|
41
|
+
* @returns Portal object with element reference and unmount method
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* // With HTML string
|
|
45
|
+
* const portal = createPortal(`
|
|
46
|
+
* <div class="modal-overlay">
|
|
47
|
+
* <div class="modal" role="dialog" aria-modal="true">
|
|
48
|
+
* Modal content
|
|
49
|
+
* </div>
|
|
50
|
+
* </div>
|
|
51
|
+
* `, document.body)
|
|
52
|
+
*
|
|
53
|
+
* // With HTMLElement
|
|
54
|
+
* const modalEl = document.createElement('div')
|
|
55
|
+
* modalEl.className = 'modal'
|
|
56
|
+
* const portal = createPortal(modalEl, document.body)
|
|
57
|
+
*
|
|
58
|
+
* // With JSX.Element (Hono)
|
|
59
|
+
* const portal = createPortal(<Modal />, document.body)
|
|
60
|
+
*
|
|
61
|
+
* // With ownerScope for scope-based element detection
|
|
62
|
+
* const portal = createPortal(modalEl, document.body, { ownerScope: scopeElement })
|
|
63
|
+
*
|
|
64
|
+
* // Access the mounted element
|
|
65
|
+
* console.log(portal.element)
|
|
66
|
+
*
|
|
67
|
+
* // Later: unmount
|
|
68
|
+
* portal.unmount()
|
|
69
|
+
*/
|
|
70
|
+
/**
|
|
71
|
+
* Check if an element is inside an SSR-rendered portal.
|
|
72
|
+
* SSR portals are marked with bf-pi attribute.
|
|
73
|
+
*
|
|
74
|
+
* @param element - Element to check
|
|
75
|
+
* @returns true if element is inside an SSR portal
|
|
76
|
+
*/
|
|
77
|
+
export declare function isSSRPortal(element: HTMLElement): boolean;
|
|
78
|
+
/**
|
|
79
|
+
* Remove a portal placeholder element (used after hydration).
|
|
80
|
+
* SSR Portal renders a <template bf-pp="..."> as a marker.
|
|
81
|
+
*
|
|
82
|
+
* @param portalId - The portal ID to find and remove
|
|
83
|
+
*/
|
|
84
|
+
/**
|
|
85
|
+
* Find a sibling slot element relative to the given element.
|
|
86
|
+
* Handles the SSR portal case where the element is inside a portal wrapper
|
|
87
|
+
* (bf-pi) instead of its original parent container.
|
|
88
|
+
*
|
|
89
|
+
* @param el - Element to search from
|
|
90
|
+
* @param slotSelector - CSS selector for the sibling slot (e.g., '[data-slot="popover-trigger"]')
|
|
91
|
+
* @returns The found element, or null
|
|
92
|
+
*/
|
|
93
|
+
export declare function findSiblingSlot(el: HTMLElement, slotSelector: string): HTMLElement | null;
|
|
94
|
+
export declare function cleanupPortalPlaceholder(portalId: string): void;
|
|
95
|
+
export declare function createPortal(children: PortalChildren, container?: HTMLElement, options?: PortalOptions): Portal;
|
|
96
|
+
//# sourceMappingURL=portal.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"portal.d.ts","sourceRoot":"","sources":["../../src/runtime/portal.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAMH,MAAM,MAAM,MAAM,GAAG;IACnB,0BAA0B;IAC1B,OAAO,EAAE,WAAW,CAAA;IACpB,8CAA8C;IAC9C,OAAO,EAAE,MAAM,IAAI,CAAA;CACpB,CAAA;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B;;;;OAIG;IACH,UAAU,CAAC,EAAE,OAAO,CAAA;CACrB;AAED,mEAAmE;AACnE,MAAM,MAAM,UAAU,GAAG;IAAE,QAAQ,IAAI,MAAM,CAAA;CAAE,CAAA;AAE/C,4CAA4C;AAC5C,MAAM,MAAM,cAAc,GAAG,WAAW,GAAG,MAAM,GAAG,UAAU,CAAA;AAE9D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAEzD;AAED;;;;;GAKG;AACH;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAAC,EAAE,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,GAAG,WAAW,GAAG,IAAI,CAiBzF;AAED,wBAAgB,wBAAwB,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAK/D;AAED,wBAAgB,YAAY,CAC1B,QAAQ,EAAE,cAAc,EACxB,SAAS,GAAE,WAA2B,EACtC,OAAO,CAAC,EAAE,aAAa,GACtB,MAAM,CAyCR"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Multi-root-aware slot lookup + child upsert for `mapArray` items whose
|
|
3
|
+
* body is a JSX Fragment with two or more sibling elements (#1212).
|
|
4
|
+
*
|
|
5
|
+
* In a single-root loop, every reactive slot inside a renderItem body is a
|
|
6
|
+
* descendant of `__el`, so plain `qsa(__el, ...)` finds it. With a
|
|
7
|
+
* multi-root Fragment item the second / third / Nth root are *siblings* of
|
|
8
|
+
* `__el` rather than descendants — `__el.querySelector(...)` will silently
|
|
9
|
+
* miss them, leaving reactive attributes / event handlers unbound, and
|
|
10
|
+
* `upsertChild(__el, ...)` will fail to find child component scope
|
|
11
|
+
* elements that live on a sibling root.
|
|
12
|
+
*
|
|
13
|
+
* The compiler emits `qsaItem` / `upsertChildItem` for these cases. Both
|
|
14
|
+
* iterate the same set of "item root elements":
|
|
15
|
+
*
|
|
16
|
+
* 1. The primary element itself.
|
|
17
|
+
* 2. Sibling roots that follow it in the DOM, until a loop boundary
|
|
18
|
+
* Comment is reached (`<!--bf-loop-i-->`, `<!--bf-loop:*-->`,
|
|
19
|
+
* `<!--bf-/loop:*-->`). These bound the item's range so a lookup
|
|
20
|
+
* cannot escape into a neighbouring item or into nodes outside the
|
|
21
|
+
* loop.
|
|
22
|
+
* 3. The CSR-only `__bfExtras` stash. During renderItem-body setup
|
|
23
|
+
* (between the template clone and the function's return), the
|
|
24
|
+
* primary and extras are still detached nodes — `__el.nextSibling`
|
|
25
|
+
* is `null` and step 2 yields nothing. Reading `__bfExtras` lets
|
|
26
|
+
* lookups reach the still-pending extras before `mapArray` inserts
|
|
27
|
+
* them into the DOM.
|
|
28
|
+
*/
|
|
29
|
+
/**
|
|
30
|
+
* Find an element matching `selector` within an item's range. Searches
|
|
31
|
+
* the primary's descendants first, then walks each root in
|
|
32
|
+
* `itemRootElements`, returning the first match.
|
|
33
|
+
*/
|
|
34
|
+
export declare function qsaItem(primaryEl: Element | null, selector: string): Element | null;
|
|
35
|
+
/**
|
|
36
|
+
* Multi-root-aware variant of `upsertChild`. Looks for the SSR scope
|
|
37
|
+
* element (or CSR placeholder) anywhere within the item's range —
|
|
38
|
+
* descendants of the primary root, sibling Fragment roots in the DOM,
|
|
39
|
+
* or the pre-insertion `__bfExtras` stash — so a child component
|
|
40
|
+
* carried by any root of a multi-root loop body is initialised
|
|
41
|
+
* correctly (#1212).
|
|
42
|
+
*
|
|
43
|
+
* Uses `qsaItem`-style search (root-or-descendant per element) so it
|
|
44
|
+
* also matches when a sibling root *is* the component scope element
|
|
45
|
+
* itself, not just a parent of it.
|
|
46
|
+
*
|
|
47
|
+
* Mirrors `upsertChild`'s #1220 collision skip: slotId-suffix candidates
|
|
48
|
+
* with a deeper `_sN_sN` shape (a synthesized child's nested scope path)
|
|
49
|
+
* are ignored so `initChild` doesn't fire on the wrong element.
|
|
50
|
+
*/
|
|
51
|
+
export declare function upsertChildItem(primaryEl: Element, name: string, slotId: string | null, props: Record<string, unknown>, key?: string | number, anchorScope?: Element | null): HTMLElement | null;
|
|
52
|
+
//# sourceMappingURL=qsa-item.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"qsa-item.d.ts","sourceRoot":"","sources":["../../src/runtime/qsa-item.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAsCH;;;;GAIG;AACH,wBAAgB,OAAO,CAAC,SAAS,EAAE,OAAO,GAAG,IAAI,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,GAAG,IAAI,CAQnF;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,eAAe,CAC7B,SAAS,EAAE,OAAO,EAClB,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,GAAG,IAAI,EACrB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC9B,GAAG,CAAC,EAAE,MAAM,GAAG,MAAM,EACrB,WAAW,CAAC,EAAE,OAAO,GAAG,IAAI,GAC3B,WAAW,GAAG,IAAI,CAwBpB"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* BarefootJS - DOM Query Helpers
|
|
3
|
+
*
|
|
4
|
+
* Scope-aware DOM query utilities for compiler-generated ClientJS.
|
|
5
|
+
* These helpers find elements within component scopes, respecting
|
|
6
|
+
* nested scope boundaries and comment-based scopes.
|
|
7
|
+
*/
|
|
8
|
+
/** CSS attribute-value escape with a fallback for environments lacking CSS.escape. */
|
|
9
|
+
export declare const cssEscape: (s: string) => string;
|
|
10
|
+
/**
|
|
11
|
+
* Find component scope element for hydration.
|
|
12
|
+
* Supports unique instance IDs (e.g., ComponentName_abc123).
|
|
13
|
+
*
|
|
14
|
+
* @param name - Component name prefix to search for
|
|
15
|
+
* @param idx - Instance index (for multiple instances)
|
|
16
|
+
* @param parent - Parent element or scope element to search within
|
|
17
|
+
* @param comment - When true, fall back to comment-based scope search (fragment roots only)
|
|
18
|
+
* @returns The scope element or null if not found
|
|
19
|
+
*/
|
|
20
|
+
export declare function findScope(name: string, idx: number, parent: Element | Document | null, comment?: boolean): Element | null;
|
|
21
|
+
/**
|
|
22
|
+
* Find an element within a scope.
|
|
23
|
+
* Enumerates candidates via candidatesInScope generator, then applies
|
|
24
|
+
* context-specific filtering (scope-aware, ignoreScope, or comment-scope).
|
|
25
|
+
* Portals are searched as a final fallback via findInPortals.
|
|
26
|
+
*
|
|
27
|
+
* @param scope - The scope element to search within
|
|
28
|
+
* @param selector - CSS selector to match
|
|
29
|
+
* @param ignoreScope - Skip scope boundary checks (for parent-owned ^-prefixed slots)
|
|
30
|
+
* @returns The matching element or null
|
|
31
|
+
*/
|
|
32
|
+
export declare function find(scope: Element | null, selector: string, ignoreScope?: boolean): Element | null;
|
|
33
|
+
/**
|
|
34
|
+
* Find an element matching a selector, checking the element itself first,
|
|
35
|
+
* then its descendants. Unlike querySelector() which only searches descendants,
|
|
36
|
+
* this also matches the root element.
|
|
37
|
+
*
|
|
38
|
+
* Used by compiler-generated code for event binding and attribute updates
|
|
39
|
+
* on loop items where the target may be the loop item's root element itself.
|
|
40
|
+
*/
|
|
41
|
+
export declare function qsa(el: Element | null, selector: string): Element | null;
|
|
42
|
+
/**
|
|
43
|
+
* `querySelector` variant that skips #1220 cross-binding candidates: any
|
|
44
|
+
* descendant whose bf-s already carries a deeper nested-slot path is
|
|
45
|
+
* ignored. Falls back to the standalone match-or-descendant semantics
|
|
46
|
+
* (mirrors `qsa`'s self-match) when no candidate qualifies.
|
|
47
|
+
*
|
|
48
|
+
* Compiler-generated static-array child-init code calls this in place of
|
|
49
|
+
* a bare `containerVar.querySelector(...)` so the filter runs even on
|
|
50
|
+
* paths that don't pass through `qsa` (#1220 review feedback).
|
|
51
|
+
*/
|
|
52
|
+
export declare function qsaChildScope(scope: Element, selector: string): Element | null;
|
|
53
|
+
/**
|
|
54
|
+
* `querySelectorAll` variant with the same #1220 filter. Returns the
|
|
55
|
+
* matching descendants in document order, with nested-slot collisions
|
|
56
|
+
* dropped so the caller's `forEach((el, idx) => …)` pairs scope
|
|
57
|
+
* elements with array items by position correctly.
|
|
58
|
+
*/
|
|
59
|
+
export declare function qsaChildScopes(scope: Element, selector: string): Element[];
|
|
60
|
+
/**
|
|
61
|
+
* Find elements within a scope by slot IDs.
|
|
62
|
+
* Used by compiler-generated code for regular slot element references.
|
|
63
|
+
* Always returns an array — callers use destructuring.
|
|
64
|
+
*
|
|
65
|
+
* For parent-owned slots (^-prefixed IDs like '^s3'), searches all descendants
|
|
66
|
+
* ignoring scope boundaries. This handles elements passed as children to child
|
|
67
|
+
* components — they are owned by the parent but rendered inside the child's scope.
|
|
68
|
+
*/
|
|
69
|
+
export declare function $(scope: Element | null, ...ids: string[]): (Element | null)[];
|
|
70
|
+
/**
|
|
71
|
+
* Find child component scope elements by slot ID or component name.
|
|
72
|
+
* - Slot ID (e.g., 's1'): uses suffix match [bf-s$="_s1"]
|
|
73
|
+
* - Component name (e.g., 'Counter'): uses prefix match [bf-s^="Counter_"]
|
|
74
|
+
* Always returns an array — callers use destructuring.
|
|
75
|
+
*/
|
|
76
|
+
export declare function $c(scope: Element | null, ...ids: string[]): (Element | null)[];
|
|
77
|
+
/**
|
|
78
|
+
* Find Text nodes for reactive text expressions marked by comment nodes.
|
|
79
|
+
* Expects marker format: <!--bf:sX-->text<!--/-->
|
|
80
|
+
* Always returns an array — callers use destructuring.
|
|
81
|
+
*
|
|
82
|
+
* Uses a single TreeWalker pass to find all markers at once,
|
|
83
|
+
* with early exit when all are found.
|
|
84
|
+
*/
|
|
85
|
+
export declare function $t(scope: Element | null, ...ids: string[]): (Text | null)[];
|
|
86
|
+
//# sourceMappingURL=query.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../../src/runtime/query.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAMH,sFAAsF;AACtF,eAAO,MAAM,SAAS,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,MAGJ,CAAA;AAqCnC;;;;;;;;;GASG;AACH,wBAAgB,SAAS,CACvB,IAAI,EAAE,MAAM,EACZ,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,OAAO,GAAG,QAAQ,GAAG,IAAI,EACjC,OAAO,CAAC,EAAE,OAAO,GAChB,OAAO,GAAG,IAAI,CAoDhB;AA6HD;;;;;;;;;;GAUG;AACH,wBAAgB,IAAI,CAClB,KAAK,EAAE,OAAO,GAAG,IAAI,EACrB,QAAQ,EAAE,MAAM,EAChB,WAAW,CAAC,EAAE,OAAO,GACpB,OAAO,GAAG,IAAI,CA2BhB;AAuBD;;;;;;;GAOG;AACH,wBAAgB,GAAG,CAAC,EAAE,EAAE,OAAO,GAAG,IAAI,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,GAAG,IAAI,CA0BxE;AA+CD;;;;;;;;;GASG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,GAAG,IAAI,CAU9E;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,EAAE,CAO1E;AAED;;;;;;;;GAQG;AACH,wBAAgB,CAAC,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI,EAAE,GAAG,GAAG,EAAE,MAAM,EAAE,GAAG,CAAC,OAAO,GAAG,IAAI,CAAC,EAAE,CAO7E;AAED;;;;;GAKG;AACH,wBAAgB,EAAE,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI,EAAE,GAAG,GAAG,EAAE,MAAM,EAAE,GAAG,CAAC,OAAO,GAAG,IAAI,CAAC,EAAE,CAE9E;AA+FD;;;;;;;GAOG;AACH,wBAAgB,EAAE,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI,EAAE,GAAG,GAAG,EAAE,MAAM,EAAE,GAAG,CAAC,IAAI,GAAG,IAAI,CAAC,EAAE,CAkC3E"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* BarefootJS - Element-based List Reconciliation
|
|
3
|
+
*
|
|
4
|
+
* Key-based DOM reconciliation for component-based list rendering.
|
|
5
|
+
* Used when renderItem returns HTMLElement (via createComponent).
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Get loop children from a container, respecting bf-loop boundary markers.
|
|
9
|
+
* When markers are present, returns only elements between them.
|
|
10
|
+
* When absent, returns all children (backward compatible).
|
|
11
|
+
* Exported for use by compiler-generated hydration code.
|
|
12
|
+
*/
|
|
13
|
+
export declare function getLoopChildren(container: HTMLElement, markerId?: string): HTMLElement[];
|
|
14
|
+
/**
|
|
15
|
+
* Like {@link getLoopChildren}, but returns every node between the loop
|
|
16
|
+
* boundary markers — Comments (per-item `<!--bf-loop-i-->` markers) and
|
|
17
|
+
* text included. The branch-clearing path needs to remove the per-item
|
|
18
|
+
* marker comments alongside elements; otherwise stale markers would
|
|
19
|
+
* accumulate when a branch swap forces mapArray to start over (#1212).
|
|
20
|
+
*/
|
|
21
|
+
export declare function getLoopNodes(container: HTMLElement, markerId?: string): Node[];
|
|
22
|
+
/**
|
|
23
|
+
* Ensure loop boundary markers exist in a container for SSR-rendered content.
|
|
24
|
+
* SSR HTML doesn't include markers, so we insert them during hydration.
|
|
25
|
+
* Uses itemCount to identify the last N children as loop items (rest are siblings).
|
|
26
|
+
*/
|
|
27
|
+
export declare function ensureLoopMarkers(container: HTMLElement, itemCount: number, markerId?: string): void;
|
|
28
|
+
/**
|
|
29
|
+
* Reconcile a list container using HTMLElement mode (for createComponent).
|
|
30
|
+
* Reuses existing elements by key, creates new elements as needed.
|
|
31
|
+
*
|
|
32
|
+
* @param container - The parent element containing list items
|
|
33
|
+
* @param items - Array of items to render
|
|
34
|
+
* @param getKey - Function to extract a unique key from each item (or null to use index)
|
|
35
|
+
* @param renderItem - Function that returns an HTMLElement for each item
|
|
36
|
+
* @param firstElement - Pre-created element for first item (avoids duplicate creation when caller already rendered item 0)
|
|
37
|
+
*/
|
|
38
|
+
export declare function reconcileElements<T>(container: HTMLElement | null, items: T[], getKey: ((item: T, index: number) => string) | null, renderItem: (item: T, index: number) => HTMLElement, firstElement?: HTMLElement, markerId?: string): void;
|
|
39
|
+
/**
|
|
40
|
+
* Sync reactive DOM state from a source element to a target element.
|
|
41
|
+
* Copies class names, replaces conditional elements, and syncs text content.
|
|
42
|
+
*/
|
|
43
|
+
export declare function syncElementState(target: HTMLElement, source: HTMLElement): void;
|
|
44
|
+
//# sourceMappingURL=reconcile-elements.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reconcile-elements.d.ts","sourceRoot":"","sources":["../../src/runtime/reconcile-elements.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAoEH;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,SAAS,EAAE,WAAW,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,WAAW,EAAE,CAMxF;AAED;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,SAAS,EAAE,WAAW,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,EAAE,CAY9E;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAgBpG;AAED;;;;;;;;;GASG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,EACjC,SAAS,EAAE,WAAW,GAAG,IAAI,EAC7B,KAAK,EAAE,CAAC,EAAE,EACV,MAAM,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC,GAAG,IAAI,EACnD,UAAU,EAAE,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,KAAK,WAAW,EACnD,YAAY,CAAC,EAAE,WAAW,EAC1B,QAAQ,CAAC,EAAE,MAAM,GAChB,IAAI,CA2JN;AAkCD;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,WAAW,GAAG,IAAI,CAiD/E"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* BarefootJS - Component Registry
|
|
3
|
+
*
|
|
4
|
+
* Component registry for parent-child communication.
|
|
5
|
+
* Each component registers its init function so parents can initialize children with props.
|
|
6
|
+
*/
|
|
7
|
+
import type { InitFn } from './types';
|
|
8
|
+
/**
|
|
9
|
+
* Register a component's init function for parent initialization.
|
|
10
|
+
* Also processes any pending child initializations for this component.
|
|
11
|
+
*
|
|
12
|
+
* @param name - Component name (e.g., 'Counter', 'AddTodoForm')
|
|
13
|
+
* @param init - Init function that takes (scope, props)
|
|
14
|
+
*/
|
|
15
|
+
export declare function registerComponent(name: string, init: InitFn): void;
|
|
16
|
+
/**
|
|
17
|
+
* Get a component's init function from the registry.
|
|
18
|
+
* Used by createComponent() to initialize dynamically created components.
|
|
19
|
+
*
|
|
20
|
+
* @param name - Component name
|
|
21
|
+
* @returns Init function or undefined if not registered
|
|
22
|
+
*/
|
|
23
|
+
export declare function getComponentInit(name: string): InitFn | undefined;
|
|
24
|
+
/**
|
|
25
|
+
* Initialize a child component with props from parent.
|
|
26
|
+
* Used by parent components to pass function props (like onAdd) to children.
|
|
27
|
+
*
|
|
28
|
+
* If the child component's script hasn't loaded yet (component not registered),
|
|
29
|
+
* queues the initialization request. When the component registers via
|
|
30
|
+
* registerComponent(), pending initializations are processed synchronously.
|
|
31
|
+
*
|
|
32
|
+
* @param name - Child component name
|
|
33
|
+
* @param childScope - The child's scope element (found by parent)
|
|
34
|
+
* @param props - Props to pass to the child (including function props)
|
|
35
|
+
*/
|
|
36
|
+
export declare function initChild(name: string, childScope: Element | null, props?: Record<string, unknown>): void;
|
|
37
|
+
/**
|
|
38
|
+
* Upsert a child component at a slot inside `parent`. Resolves the SSR vs
|
|
39
|
+
* CSR shape at runtime in one place — so the compiler doesn't need a
|
|
40
|
+
* `mode: 'csr' | 'ssr'` argument for child component emission.
|
|
41
|
+
*
|
|
42
|
+
* 1. SSR: a `[bf-h][bf-m]` element exists for this (parent,
|
|
43
|
+
* slot). Initialise it via initChild and return it.
|
|
44
|
+
* 2. CSR: a `[data-bf-ph="<slotId|name>"]` placeholder exists. Replace it
|
|
45
|
+
* with `createComponent(name, props, key)` and return the new element.
|
|
46
|
+
* 3. Neither matches (already initialised on a previous reconcile pass) —
|
|
47
|
+
* no-op, return null.
|
|
48
|
+
*
|
|
49
|
+
* The returned element is the live component scope element — callers can
|
|
50
|
+
* use it for follow-up effects (e.g. a children-textContent createEffect).
|
|
51
|
+
*/
|
|
52
|
+
export declare function upsertChild(parent: Element, name: string, slotId: string | null, props: Record<string, unknown>, key?: string | number, anchorScope?: Element | null): HTMLElement | null;
|
|
53
|
+
//# sourceMappingURL=registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/runtime/registry.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAOH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAarC;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAclE;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAEjE;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,SAAS,CACvB,IAAI,EAAE,MAAM,EACZ,UAAU,EAAE,OAAO,GAAG,IAAI,EAC1B,KAAK,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM,GAClC,IAAI,CAoCN;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,WAAW,CACzB,MAAM,EAAE,OAAO,EACf,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,GAAG,IAAI,EACrB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC9B,GAAG,CAAC,EAAE,MAAM,GAAG,MAAM,EACrB,WAAW,CAAC,EAAE,OAAO,GAAG,IAAI,GAC3B,WAAW,GAAG,IAAI,CAwBpB"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* BarefootJS - Client-Side Rendering
|
|
3
|
+
*
|
|
4
|
+
* CSR entry point for rendering components directly in the browser
|
|
5
|
+
* without server-side rendering. Tree-shakeable: SSR-only apps
|
|
6
|
+
* never import this module.
|
|
7
|
+
*/
|
|
8
|
+
import type { ComponentDef } from './types';
|
|
9
|
+
/**
|
|
10
|
+
* Render a component into a container element (CSR mode).
|
|
11
|
+
*
|
|
12
|
+
* Accepts either:
|
|
13
|
+
* - A registered component name (string) — looks up `init` and `template` from the registry
|
|
14
|
+
* (the component must be registered first by importing its `.client.js` file).
|
|
15
|
+
* - A `ComponentDef` — uses the def's `init` and `template` directly, bypassing the registry.
|
|
16
|
+
*
|
|
17
|
+
* Generates DOM from the template, mounts it into the container, and initializes it
|
|
18
|
+
* with the given props. Unlike hydrate(), no pre-rendered HTML is required; the
|
|
19
|
+
* container's content is replaced entirely.
|
|
20
|
+
*
|
|
21
|
+
* @param container - Target DOM element to render into
|
|
22
|
+
* @param nameOrDef - Registered component name or a ComponentDef
|
|
23
|
+
* @param props - Props to pass to the component
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* // By name (registry-based)
|
|
27
|
+
* await import('/static/components/Counter.client.js')
|
|
28
|
+
* render(document.getElementById('app')!, 'Counter', { initialCount: 0 })
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* // By ComponentDef (registry-free)
|
|
32
|
+
* render(container, { name: 'MyNode', init, template }, { id: 'n1' })
|
|
33
|
+
*/
|
|
34
|
+
export declare function render(container: HTMLElement, nameOrDef: string | ComponentDef, props?: Record<string, unknown>): void;
|
|
35
|
+
//# sourceMappingURL=render.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../../src/runtime/render.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAOH,OAAO,KAAK,EAAE,YAAY,EAAU,MAAM,SAAS,CAAA;AAEnD;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,MAAM,CACpB,SAAS,EAAE,WAAW,EACtB,SAAS,EAAE,MAAM,GAAG,YAAY,EAChC,KAAK,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM,GAClC,IAAI,CA4DN"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* BarefootJS - Comment Scope Registry
|
|
3
|
+
*
|
|
4
|
+
* Registry for elements that serve as scope proxies for comment-based scopes.
|
|
5
|
+
* Maps an element to its comment node and the sibling range boundary.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Information about a comment-based scope.
|
|
9
|
+
*/
|
|
10
|
+
export interface CommentScopeInfo {
|
|
11
|
+
commentNode: Comment;
|
|
12
|
+
scopeId: string;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Registry mapping elements to their comment scope info.
|
|
16
|
+
*/
|
|
17
|
+
export declare const commentScopeRegistry: WeakMap<Element, CommentScopeInfo>;
|
|
18
|
+
/**
|
|
19
|
+
* Get the scope ID for an element from the comment scope registry.
|
|
20
|
+
* Used by createPortal to resolve scope IDs for comment-based scopes.
|
|
21
|
+
*/
|
|
22
|
+
export declare function getPortalScopeId(element: Element): string | null;
|
|
23
|
+
/**
|
|
24
|
+
* Find the end boundary for a comment-based scope.
|
|
25
|
+
* The boundary is the next bf-scope: comment or the end of the parent's children.
|
|
26
|
+
*/
|
|
27
|
+
export declare function getCommentScopeBoundary(commentNode: Comment): Node | null;
|
|
28
|
+
//# sourceMappingURL=scope.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scope.d.ts","sourceRoot":"","sources":["../../src/runtime/scope.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,WAAW,EAAE,OAAO,CAAA;IACpB,OAAO,EAAE,MAAM,CAAA;CAChB;AAED;;GAEG;AACH,eAAO,MAAM,oBAAoB,oCAA2C,CAAA;AAE5E;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CAGhE;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,CAAC,WAAW,EAAE,OAAO,GAAG,IAAI,GAAG,IAAI,CAUzE"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared slot-relationship resolver: identifies the SSR scope of a child
|
|
3
|
+
* component mounted at slot `<sN>` inside its parent.
|
|
4
|
+
*
|
|
5
|
+
* Both single-root (`registry.ts::upsertChild`) and multi-root loop-body
|
|
6
|
+
* (`qsa-item.ts::upsertChildItem`) paths consume this. They differ only
|
|
7
|
+
* in whether they search a single `parent` element or walk a sequence of
|
|
8
|
+
* loop-item root elements; the lookup logic is identical.
|
|
9
|
+
*
|
|
10
|
+
* See `spec/compiler.md` "Slot identity" for the marker contract.
|
|
11
|
+
*/
|
|
12
|
+
/** Resolve the host scope id for a slot lookup. Prefers the explicit
|
|
13
|
+
* `anchorScope` because the immediate `parent` element may be a freshly-
|
|
14
|
+
* created detached fragment whose `closest()` returns null. */
|
|
15
|
+
export declare function parentScopeOf(parent: Element, anchorScope?: Element | null): string;
|
|
16
|
+
/** Build the (host, slot) metadata for a fresh component about to be
|
|
17
|
+
* mounted at `slotId`. `createComponent` stamps these onto the new
|
|
18
|
+
* element so subsequent `upsertChild` lookups can find it. `parent`
|
|
19
|
+
* defaults to the empty string when no surrounding scope is resolvable
|
|
20
|
+
* (top-level CSR mount). */
|
|
21
|
+
export declare function buildSlotInfo(parent: Element, slotId: string, anchorScope?: Element | null): {
|
|
22
|
+
parent: string;
|
|
23
|
+
mount: string;
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Find the SSR scope element for a child component at `slotId` inside
|
|
27
|
+
* `parent`. Primary lookup is `(BF_HOST, BF_AT)`; the suffix fallback
|
|
28
|
+
* covers `renderChild` paths that emit a parent-anchored `bf-s` without
|
|
29
|
+
* stamping host metadata.
|
|
30
|
+
*
|
|
31
|
+
* `selfMatch` lets the multi-root loop-body caller include the root
|
|
32
|
+
* element itself in the search (the loop-item primary may be the scope
|
|
33
|
+
* element, not just a parent of it).
|
|
34
|
+
*/
|
|
35
|
+
export declare function findSsrScopeBySlotIn(parent: Element, slotId: string, anchorScope: Element | null | undefined, selfMatch: boolean): HTMLElement | null;
|
|
36
|
+
//# sourceMappingURL=slot-resolver.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"slot-resolver.d.ts","sourceRoot":"","sources":["../../src/runtime/slot-resolver.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAKH;;gEAEgE;AAChE,wBAAgB,aAAa,CAAC,MAAM,EAAE,OAAO,EAAE,WAAW,CAAC,EAAE,OAAO,GAAG,IAAI,GAAG,MAAM,CAInF;AAED;;;;6BAI6B;AAC7B,wBAAgB,aAAa,CAC3B,MAAM,EAAE,OAAO,EACf,MAAM,EAAE,MAAM,EACd,WAAW,CAAC,EAAE,OAAO,GAAG,IAAI,GAC3B;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAEnC;AAED;;;;;;;;;GASG;AACH,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,OAAO,EACf,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,OAAO,GAAG,IAAI,GAAG,SAAS,EACvC,SAAS,EAAE,OAAO,GACjB,WAAW,GAAG,IAAI,CAapB"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* BarefootJS - Spread Attributes Helper (Template Mode)
|
|
3
|
+
*
|
|
4
|
+
* Converts an object to an HTML attribute string for use inside template literals.
|
|
5
|
+
* Unlike applyRestAttrs (which manipulates DOM elements reactively), this produces
|
|
6
|
+
* a static string for server/template rendering of computed local spreads.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Convert an object to an HTML attribute string.
|
|
10
|
+
* Aligned with applyRestAttrs conventions: skips null/undefined/false,
|
|
11
|
+
* event handlers, maps className→class and htmlFor→for. The `style`
|
|
12
|
+
* prop is routed through `styleToCss` so object literals serialize to
|
|
13
|
+
* a real CSS string (matching the reactive `applyRestAttrs` path).
|
|
14
|
+
*
|
|
15
|
+
* SVG attributes listed in `SVG_CAMEL_CASE_ATTRS` are preserved
|
|
16
|
+
* verbatim — the SVG XML spec is case-sensitive for those names.
|
|
17
|
+
*/
|
|
18
|
+
export declare function spreadAttrs(obj: Record<string, unknown>): string;
|
|
19
|
+
//# sourceMappingURL=spread-attrs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spread-attrs.d.ts","sourceRoot":"","sources":["../../src/runtime/spread-attrs.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AA+CH;;;;;;;;;GASG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAwBhE"}
|