@srfnstack/fntags 1.2.4 → 1.2.6
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 +15 -8
- package/src/fntags.d.mts.map +1 -1
- package/src/fntags.mjs +30 -5
package/package.json
CHANGED
package/src/fntags.d.mts
CHANGED
|
@@ -92,6 +92,16 @@ 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
|
+
* Register a component function for HMR. Returns a stable proxy that always delegates
|
|
97
|
+
* to the latest registered implementation. When a module re-executes after HMR, the
|
|
98
|
+
* proxy's target is updated so callers holding stale import bindings get the new code.
|
|
99
|
+
*
|
|
100
|
+
* @param {string} id A stable identifier for this component (typically 'filepath:exportName')
|
|
101
|
+
* @param {Function} fn The component function
|
|
102
|
+
* @returns {Function} A stable proxy function
|
|
103
|
+
*/
|
|
104
|
+
export function registeredComponent(id: string, fn: Function): Function;
|
|
95
105
|
/**
|
|
96
106
|
* Get or create a state instance from the global HMR registry.
|
|
97
107
|
* During development with HMR, the Vite plugin rewrites fnstate() calls to use this function,
|
|
@@ -104,18 +114,15 @@ export function styled<T extends HTMLElement | SVGElement>(style: object | strin
|
|
|
104
114
|
*/
|
|
105
115
|
export function registeredState(id: string, initialValue: any, mapKey?: (v: any) => string): any;
|
|
106
116
|
/**
|
|
107
|
-
* Create an HMR-aware root mount point.
|
|
108
|
-
*
|
|
109
|
-
*
|
|
117
|
+
* Create an HMR-aware root mount point. Renders the app into the container and
|
|
118
|
+
* registers a global rerender callback so the vite plugin can trigger re-renders
|
|
119
|
+
* automatically when modules are hot-updated.
|
|
110
120
|
*
|
|
111
121
|
* @param {HTMLElement} container The DOM element to mount into
|
|
112
122
|
* @param {(()=>Node)|Node} appFn A function that returns the app's root element, or the element itself
|
|
113
|
-
* @returns {
|
|
123
|
+
* @returns {HTMLElement} The container element
|
|
114
124
|
*/
|
|
115
|
-
export function hmrRoot(container: HTMLElement, appFn: (() => Node) | Node):
|
|
116
|
-
container: HTMLElement;
|
|
117
|
-
rerender: () => void;
|
|
118
|
-
};
|
|
125
|
+
export function hmrRoot(container: HTMLElement, appFn: (() => Node) | Node): HTMLElement;
|
|
119
126
|
/**
|
|
120
127
|
* Create a compiled template function. The returned function takes a single object that contains the properties
|
|
121
128
|
* 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;;;;;;;;;GASG;AACH,oCALW,MAAM,gBACN,GAAG,eACE,GAAG,KAAK,MAAM,OAc7B;AAED;;;;;;;;GAQG;AACH,mCAJW,WAAW,SACX,CAAC,MAAI,IAAI,CAAC,GAAC,IAAI,GACb
|
|
1
|
+
{"version":3,"file":"fntags.d.mts","sourceRoot":"","sources":["fntags.mjs"],"names":[],"mappings":"AAcA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,2DALW,MAAM,eACH,CAAC,IAAI,MAAO,CAAC,OA6C1B;AA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ACC,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,30 @@ const stringifyStyle = style =>
|
|
|
913
913
|
? style
|
|
914
914
|
: Object.keys(style).map(prop => `${prop}:${style[prop]}`).join(';')
|
|
915
915
|
|
|
916
|
+
/**
|
|
917
|
+
* Register a component function for HMR. Returns a stable proxy that always delegates
|
|
918
|
+
* to the latest registered implementation. When a module re-executes after HMR, the
|
|
919
|
+
* proxy's target is updated so callers holding stale import bindings get the new code.
|
|
920
|
+
*
|
|
921
|
+
* @param {string} id A stable identifier for this component (typically 'filepath:exportName')
|
|
922
|
+
* @param {Function} fn The component function
|
|
923
|
+
* @returns {Function} A stable proxy function
|
|
924
|
+
*/
|
|
925
|
+
export function registeredComponent (id, fn) {
|
|
926
|
+
if (!globalThis.__fntags_components) {
|
|
927
|
+
globalThis.__fntags_components = new Map()
|
|
928
|
+
}
|
|
929
|
+
const reg = globalThis.__fntags_components
|
|
930
|
+
reg.set(id, fn)
|
|
931
|
+
if (!reg.has(id + '$proxy')) {
|
|
932
|
+
const proxy = function (...args) {
|
|
933
|
+
return reg.get(id).apply(this, args)
|
|
934
|
+
}
|
|
935
|
+
reg.set(id + '$proxy', proxy)
|
|
936
|
+
}
|
|
937
|
+
return reg.get(id + '$proxy')
|
|
938
|
+
}
|
|
939
|
+
|
|
916
940
|
/**
|
|
917
941
|
* Get or create a state instance from the global HMR registry.
|
|
918
942
|
* During development with HMR, the Vite plugin rewrites fnstate() calls to use this function,
|
|
@@ -937,13 +961,13 @@ export function registeredState (id, initialValue, mapKey) {
|
|
|
937
961
|
}
|
|
938
962
|
|
|
939
963
|
/**
|
|
940
|
-
* Create an HMR-aware root mount point.
|
|
941
|
-
*
|
|
942
|
-
*
|
|
964
|
+
* Create an HMR-aware root mount point. Renders the app into the container and
|
|
965
|
+
* registers a global rerender callback so the vite plugin can trigger re-renders
|
|
966
|
+
* automatically when modules are hot-updated.
|
|
943
967
|
*
|
|
944
968
|
* @param {HTMLElement} container The DOM element to mount into
|
|
945
969
|
* @param {(()=>Node)|Node} appFn A function that returns the app's root element, or the element itself
|
|
946
|
-
* @returns {
|
|
970
|
+
* @returns {HTMLElement} The container element
|
|
947
971
|
*/
|
|
948
972
|
export function hmrRoot (container, appFn) {
|
|
949
973
|
const render = () => {
|
|
@@ -952,7 +976,8 @@ export function hmrRoot (container, appFn) {
|
|
|
952
976
|
container.appendChild(renderNode(result))
|
|
953
977
|
}
|
|
954
978
|
render()
|
|
955
|
-
|
|
979
|
+
globalThis.__fntags_hmr_rerender = render
|
|
980
|
+
return container
|
|
956
981
|
}
|
|
957
982
|
|
|
958
983
|
/**
|