@srfnstack/fntags 1.2.3 → 1.2.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.
- package/package.json +1 -1
- package/src/fntags.d.mts +21 -0
- package/src/fntags.d.mts.map +1 -1
- package/src/fntags.mjs +43 -0
package/package.json
CHANGED
package/src/fntags.d.mts
CHANGED
|
@@ -92,6 +92,27 @@ export function getAttrs(children: any): object;
|
|
|
92
92
|
* @return {T} The styled element
|
|
93
93
|
*/
|
|
94
94
|
export function styled<T extends HTMLElement | SVGElement>(style: object | string, tag: string, children: object[] | Node[]): T;
|
|
95
|
+
/**
|
|
96
|
+
* Get or create a state instance from the global HMR registry.
|
|
97
|
+
* During development with HMR, the Vite plugin rewrites fnstate() calls to use this function,
|
|
98
|
+
* ensuring state instances survive module reloads.
|
|
99
|
+
*
|
|
100
|
+
* @param {string} id A stable identifier for this state instance (typically 'filepath:varName')
|
|
101
|
+
* @param {any} initialValue The initial value, used only when creating a new state
|
|
102
|
+
* @param {((v: any) => string)?} [mapKey] Optional key function, used only when creating a new state
|
|
103
|
+
* @returns {FnState} The state instance from the registry
|
|
104
|
+
*/
|
|
105
|
+
export function registeredState(id: string, initialValue: any, mapKey?: (v: any) => string): any;
|
|
106
|
+
/**
|
|
107
|
+
* Create an HMR-aware root mount point. Renders the app into the container and
|
|
108
|
+
* registers a global rerender callback so the vite plugin can trigger re-renders
|
|
109
|
+
* automatically when modules are hot-updated.
|
|
110
|
+
*
|
|
111
|
+
* @param {HTMLElement} container The DOM element to mount into
|
|
112
|
+
* @param {(()=>Node)|Node} appFn A function that returns the app's root element, or the element itself
|
|
113
|
+
* @returns {HTMLElement} The container element
|
|
114
|
+
*/
|
|
115
|
+
export function hmrRoot(container: HTMLElement, appFn: (() => Node) | Node): HTMLElement;
|
|
95
116
|
/**
|
|
96
117
|
* Create a compiled template function. The returned function takes a single object that contains the properties
|
|
97
118
|
* defined in the template.
|
package/src/fntags.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fntags.d.mts","sourceRoot":"","sources":["fntags.mjs"],"names":[],"mappings":"AAcA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,2DALW,MAAM,eACH,CAAC,IAAI,MAAO,CAAC,OA6C1B;AAUD;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH;;;GAGG;AAEH;;;;;;;;;;GAUG;AACH,iEAPgB,GAAG,cAqIlB;AAqfD;;;;GAIG;AACH,iCAHW,GAAG,GACD,IAAI,CAuBhB;AAqFD;;;;GAIG;AACH,6BAHW,GAAG,GACD,OAAO,CAInB;AAED;;;;GAIG;AACH,mCAHW,GAAG,GACF,MAAM,CAIjB;AAED;;;;;;;;;;GAUG;AACH,kEALW,MAAM,GAAC,MAAM,OACb,MAAM,YACN,MAAM,EAAE,GAAC,IAAI,EAAE,KAezB;AAOD;;;;;;;;;;;;;;;GAeG;AACH,qDAJkB,IAAI,iBACH,IAAI,CA+DtB;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"fntags.d.mts","sourceRoot":"","sources":["fntags.mjs"],"names":[],"mappings":"AAcA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,2DALW,MAAM,eACH,CAAC,IAAI,MAAO,CAAC,OA6C1B;AAUD;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH;;;GAGG;AAEH;;;;;;;;;;GAUG;AACH,iEAPgB,GAAG,cAqIlB;AAqfD;;;;GAIG;AACH,iCAHW,GAAG,GACD,IAAI,CAuBhB;AAqFD;;;;GAIG;AACH,6BAHW,GAAG,GACD,OAAO,CAInB;AAED;;;;GAIG;AACH,mCAHW,GAAG,GACF,MAAM,CAIjB;AAED;;;;;;;;;;GAUG;AACH,kEALW,MAAM,GAAC,MAAM,OACb,MAAM,YACN,MAAM,EAAE,GAAC,IAAI,EAAE,KAezB;AAOD;;;;;;;;;GASG;AACH,oCALW,MAAM,gBACN,GAAG,eACE,GAAG,KAAK,MAAM,OAc7B;AAED;;;;;;;;GAQG;AACH,mCAJW,WAAW,SACX,CAAC,MAAI,IAAI,CAAC,GAAC,IAAI,GACb,WAAW,CAWvB;AAED;;;;;;;;;;;;;;;GAeG;AACH,qDAJkB,IAAI,iBACH,IAAI,CA+DtB;;;;;;;;;kCAl7BmC,CAAC,YAAY,CAAC,KAAG,CAAC,IAAI,GAAC,GAAG,CAAC,KAAG,IAAI;;;;;;2BAE/C,CAAC,MAAI,CAAC,IAAI,GAAC,GAAG,CAAC,CAAC,GAAC,GAAG,GAAC,IAAI,gCAAkC,CAAC,IAAI,GAAC,GAAG,CAAC,KAAG,IAAI;;;;;qBAG9E,MAAM,KAAG,IAAI;;;;sCAEI,CAAC,YAAY,CAAC,KAAG,CAAC,MAAM,GAAC,GAAG,CAAC,KAAG,GAAG;;;;mCACvC,CAAC,YAAY,CAAC,KAAG,MAAM,KAAK,MAAM;;;;yCAC7B,GAAG,KAAG,CAAC,IAAI,GAAC,GAAG,CAAC,KAAG,IAAI;;;;+CACrB,GAAG,KAAG,CAAC,MAAM,GAAC,GAAG,CAAC,KAAG,GAAG;;;;;;kBAC7C,GAAG,KAAG,IAAI;;;;cAGhB,MAAK,GAAG;;;;;qBACC,CAAC,KAAG,IAAI;;;;;;oBAEV,MAAM,KAAG,GAAG;;;;oBAGZ,MAAM,SAAS,GAAG,mBAAmB,OAAO,KAAG,IAAI;;;;uCAClC,CAAC,YAAY,CAAC,KAAG,IAAI,KAAK,IAAI;;;;eACtD,OAAO;;;;;sDAKqB,CAAC,KAAG,CAAC"}
|
package/src/fntags.mjs
CHANGED
|
@@ -913,6 +913,49 @@ const stringifyStyle = style =>
|
|
|
913
913
|
? style
|
|
914
914
|
: Object.keys(style).map(prop => `${prop}:${style[prop]}`).join(';')
|
|
915
915
|
|
|
916
|
+
/**
|
|
917
|
+
* Get or create a state instance from the global HMR registry.
|
|
918
|
+
* During development with HMR, the Vite plugin rewrites fnstate() calls to use this function,
|
|
919
|
+
* ensuring state instances survive module reloads.
|
|
920
|
+
*
|
|
921
|
+
* @param {string} id A stable identifier for this state instance (typically 'filepath:varName')
|
|
922
|
+
* @param {any} initialValue The initial value, used only when creating a new state
|
|
923
|
+
* @param {((v: any) => string)?} [mapKey] Optional key function, used only when creating a new state
|
|
924
|
+
* @returns {FnState} The state instance from the registry
|
|
925
|
+
*/
|
|
926
|
+
export function registeredState (id, initialValue, mapKey) {
|
|
927
|
+
if (!globalThis.__fntags_registry) {
|
|
928
|
+
globalThis.__fntags_registry = new Map()
|
|
929
|
+
}
|
|
930
|
+
const registry = globalThis.__fntags_registry
|
|
931
|
+
if (registry.has(id)) {
|
|
932
|
+
return registry.get(id)
|
|
933
|
+
}
|
|
934
|
+
const state = fnstate(initialValue, mapKey)
|
|
935
|
+
registry.set(id, state)
|
|
936
|
+
return state
|
|
937
|
+
}
|
|
938
|
+
|
|
939
|
+
/**
|
|
940
|
+
* Create an HMR-aware root mount point. Renders the app into the container and
|
|
941
|
+
* registers a global rerender callback so the vite plugin can trigger re-renders
|
|
942
|
+
* automatically when modules are hot-updated.
|
|
943
|
+
*
|
|
944
|
+
* @param {HTMLElement} container The DOM element to mount into
|
|
945
|
+
* @param {(()=>Node)|Node} appFn A function that returns the app's root element, or the element itself
|
|
946
|
+
* @returns {HTMLElement} The container element
|
|
947
|
+
*/
|
|
948
|
+
export function hmrRoot (container, appFn) {
|
|
949
|
+
const render = () => {
|
|
950
|
+
container.innerHTML = ''
|
|
951
|
+
const result = typeof appFn === 'function' ? appFn() : appFn
|
|
952
|
+
container.appendChild(renderNode(result))
|
|
953
|
+
}
|
|
954
|
+
render()
|
|
955
|
+
globalThis.__fntags_hmr_rerender = render
|
|
956
|
+
return container
|
|
957
|
+
}
|
|
958
|
+
|
|
916
959
|
/**
|
|
917
960
|
* Create a compiled template function. The returned function takes a single object that contains the properties
|
|
918
961
|
* defined in the template.
|