fusee-framework 2.7.2 → 2.7.3

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,6 +1,15 @@
1
- // ─── Framework Public API ─────────────────────────────────────────────────────
1
+ // ─── Framework Public API (core) ──────────────────────────────────────────────
2
2
  // Exports only, with no side effects, so bundlers keep just what an app uses.
3
3
  // To expose the API on globalThis instead, import 'fusee-framework/globals'.
4
+ //
5
+ // Everything else ships as its own entry point:
6
+ // fusee-framework/router createRouter, navigate, generateRoutes, guards, route signals
7
+ // fusee-framework/store defineStore and store helpers
8
+ // fusee-framework/di InjectionToken, provideGlobal, root injector
9
+ // fusee-framework/actions server actions, client side (defineAction, useAction)
10
+ // fusee-framework/plugins plugin descriptors (defineFuseePlugin, ...)
11
+ // fusee-framework/server Node: action handling, SSR helpers, manifest
12
+ // FREL, Comet and the Go SSR engine are add-ons: `fusee add frel | comet | server`.
4
13
 
5
14
  export const emit = () => console.warn('[framework] emit() can only be used inside component setup()')
6
15
 
@@ -9,14 +18,8 @@ export { defineResource } from './core/resource.js'
9
18
  export { defineComponent } from './core/component.js'
10
19
  export { defineCompiledComponent, defineAsyncComponent, onMount, onUnmount, parseSlots, provide, inject, getCurrentInstance } from './core/component-core.js'
11
20
  export { defineElement, toCustomElement, css, unsafeCSS } from './core/element.js'
12
- export { InjectionToken, provideGlobal } from './core/di.js'
13
- export { createRouter, navigate, mountOutlet, currentRoute, routeParams, routeQuery, matchedRoutes } from './router/router.js'
14
- export { generateRoutes } from './router/file-router.js'
15
21
  export { mountTemplate } from './core/compiler.js'
16
22
  export { defineComposable, assertSetupContext } from './core/composable.js'
17
- export { defineStore, resetStore, clearStores, registerStorePlugin, storeToRefs, storeToState, storeToGetters, useNestedStore, MutationType } from './core/store.js'
18
23
  export { directive } from './core/directives.js'
19
24
  export { reconcile } from './core/reconcile.js'
20
- export { defineAction, createActionProxy, useAction } from './server/actions.js'
21
25
  export { createApp } from './core/app-registry.js'
22
- export { defineCompilerPlugin, defineServerPlugin, defineDevToolsPlugin, defineRuntimeAdapter, defineFuseePlugin } from './core/plugins.js'
@@ -0,0 +1,8 @@
1
+ // fusee-framework/plugins — descriptors for compiler, server, devtools and runtime plugins.
2
+ export {
3
+ defineCompilerPlugin,
4
+ defineServerPlugin,
5
+ defineDevToolsPlugin,
6
+ defineRuntimeAdapter,
7
+ defineFuseePlugin
8
+ } from '../core/plugins.js'
@@ -0,0 +1,12 @@
1
+ // fusee-framework/store — setup stores (Pinia-style), separate from the core entry.
2
+ export {
3
+ defineStore,
4
+ resetStore,
5
+ clearStores,
6
+ registerStorePlugin,
7
+ storeToRefs,
8
+ storeToState,
9
+ storeToGetters,
10
+ useNestedStore,
11
+ MutationType
12
+ } from '../core/store.js'
@@ -1,50 +1,52 @@
1
- export interface ActionOptions {
2
- name?: string
3
- baseUrl?: string
4
- headers?: Record<string, string>
5
- }
6
-
7
- export interface UseActionOptions {
8
- onSuccess?: (data: any) => void
9
- onError?: (error: Error) => void
10
- resetOnCall?: boolean
11
- }
12
-
13
- export interface ActionReturn {
14
- execute: (...args: any[]) => Promise<any>
15
- pending: Signal<boolean>
16
- data: Signal<any>
17
- error: Signal<any>
18
- reset: () => void
19
- }
20
-
21
- export interface ActionProxy extends Function {
22
- _isAction: boolean
23
- _actionName: string
24
- }
25
-
26
- export declare function defineAction(fnOrName: Function | string, opts?: ActionOptions): ActionProxy
27
- export declare function createActionProxy(name: string, opts?: ActionOptions): ActionProxy
28
- export declare function useAction(action: ActionProxy, opts?: UseActionOptions): ActionReturn
29
-
30
- // ─── Hydration Support ─────────────────────────────────────────────────────
31
-
32
- export interface ActionHydrationOptions {
33
- staleTime?: number
34
- }
35
-
36
- export interface ActionHydrationEntry {
37
- data: any
38
- timestamp: number
39
- staleTime: number
40
- }
41
-
42
- export interface ActionHydrationSnapshot {
43
- [key: string]: ActionHydrationEntry
44
- }
45
-
46
- export declare function hydrateAction(actionName: string, data: any, opts?: ActionHydrationOptions): void
47
- export declare function getHydratedAction(actionName: string, staleTime?: number): any
48
- export declare function clearActionHydration(): void
49
- export declare function extractActionHydration(): ActionHydrationSnapshot
50
- export declare function loadActionHydration(snapshot: ActionHydrationSnapshot): void
1
+ import type { Signal } from './signal'
2
+
3
+ export interface ActionOptions {
4
+ name?: string
5
+ baseUrl?: string
6
+ headers?: Record<string, string>
7
+ }
8
+
9
+ export interface UseActionOptions {
10
+ onSuccess?: (data: any) => void
11
+ onError?: (error: Error) => void
12
+ resetOnCall?: boolean
13
+ }
14
+
15
+ export interface ActionReturn {
16
+ execute: (...args: any[]) => Promise<any>
17
+ pending: Signal<boolean>
18
+ data: Signal<any>
19
+ error: Signal<any>
20
+ reset: () => void
21
+ }
22
+
23
+ export interface ActionProxy extends Function {
24
+ _isAction: boolean
25
+ _actionName: string
26
+ }
27
+
28
+ export declare function defineAction(fnOrName: Function | string, opts?: ActionOptions): ActionProxy
29
+ export declare function createActionProxy(name: string, opts?: ActionOptions): ActionProxy
30
+ export declare function useAction(action: ActionProxy, opts?: UseActionOptions): ActionReturn
31
+
32
+ // ─── Hydration Support ─────────────────────────────────────────────────────
33
+
34
+ export interface ActionHydrationOptions {
35
+ staleTime?: number
36
+ }
37
+
38
+ export interface ActionHydrationEntry {
39
+ data: any
40
+ timestamp: number
41
+ staleTime: number
42
+ }
43
+
44
+ export interface ActionHydrationSnapshot {
45
+ [key: string]: ActionHydrationEntry
46
+ }
47
+
48
+ export declare function hydrateAction(actionName: string, data: any, opts?: ActionHydrationOptions): void
49
+ export declare function getHydratedAction(actionName: string, staleTime?: number): any
50
+ export declare function clearActionHydration(): void
51
+ export declare function extractActionHydration(): ActionHydrationSnapshot
52
+ export declare function loadActionHydration(snapshot: ActionHydrationSnapshot): void
@@ -0,0 +1,9 @@
1
+ // Typings for fusee-framework/di (framework/di/index.js).
2
+ export {
3
+ InjectionToken,
4
+ provideGlobal,
5
+ EnvironmentInjector,
6
+ rootInjector,
7
+ runInContext
8
+ } from './di'
9
+ export type { Provider, InjectOptions, Injector } from './di'
@@ -1,119 +1,113 @@
1
- import { createApp as createAppFn } from './app-registry'
2
-
3
- export * from './signal'
4
- export * from './component'
5
- export * from './element'
6
- export * from './composable'
7
- export * from './router'
8
- export * from './compiler'
9
- export * from './directives'
10
- export * from './store'
11
- export * from './event-delegation'
12
- export * from './di'
13
- export * from './reconcile'
14
- export * from './resource'
15
- export * from './actions'
16
- export * from './actions.server'
17
- export * from './plugins'
18
- export * from './app-registry'
19
- export * from '../core/comet-js/comet'
20
- export * from '../core/comet-js/comet-fusee'
21
-
22
- declare global {
23
- type Signal<T = any> = import('./signal').Signal<T>
24
- type Computed<T = any> = import('./signal').Computed<T>
25
- type SignalAccessor<T> = import('./signal').SignalAccessor<T>
26
- type Composable<T extends (...args: any[]) => any> = import('./composable').Composable<T>
27
- type DirectiveBinding<V = any> = import('./directives').DirectiveBinding<V>
28
- type DirectiveHooks<V = any> = import('./directives').DirectiveHooks<V>
29
- type DelegatedEventOptions = import('./event-delegation').DelegatedEventOptions
30
-
31
- type AppConfig = import('./app-registry').AppConfig
32
- type Plugin<Options extends any[] = any[]> = import('./app-registry').Plugin<Options>
33
- type CompilerPlugin = import('./plugins').CompilerPlugin
34
- type ServerPlugin = import('./plugins').ServerPlugin
35
- type DevToolsPlugin = import('./plugins').DevToolsPlugin
36
- type RuntimeAdapter = import('./plugins').RuntimeAdapter
37
- type FuseePlugin = import('./plugins').FuseePlugin
38
-
39
- const createApp: typeof createAppFn
40
-
41
- const defineCompilerPlugin: typeof import('./plugins').defineCompilerPlugin
42
- const defineServerPlugin: typeof import('./plugins').defineServerPlugin
43
- const defineDevToolsPlugin: typeof import('./plugins').defineDevToolsPlugin
44
- const defineRuntimeAdapter: typeof import('./plugins').defineRuntimeAdapter
45
- const defineFuseePlugin: typeof import('./plugins').defineFuseePlugin
46
-
47
- const emit: (eventName?: string, ...args: any[]) => void
48
- const signal: typeof import('./signal').signal
49
- const computed: typeof import('./signal').computed
50
- const effect: typeof import('./signal').effect
51
- const batch: typeof import('./signal').batch
52
- const untrack: typeof import('./signal').untrack
53
- const inspect: typeof import('./signal').inspect
54
- const watch: typeof import('./signal').watch
55
- const onCleanup: typeof import('./signal').onCleanup
56
- const resource: typeof import('./signal').resource
57
- const defineResource: typeof import('./resource').defineResource
58
- const createSuspense: typeof import('./signal').createSuspense
59
- const scheduleAsyncJob: typeof import('./signal').scheduleAsyncJob
60
-
61
- const defineComponent: typeof import('./component').defineComponent
62
- const defineCompiledComponent: typeof import('./component').defineCompiledComponent
63
- const defineAsyncComponent: typeof import('./component').defineAsyncComponent
64
- const onMount: typeof import('./component').onMount
65
- const onUnmount: typeof import('./component').onUnmount
66
- const parseSlots: typeof import('./component').parseSlots
67
- const provide: typeof import('./component').provide
68
- const inject: typeof import('./di').inject
69
- const getCurrentInstance: typeof import('./component').getCurrentInstance
70
-
71
- const defineElement: typeof import('./element').defineElement
72
- const toCustomElement: typeof import('./element').toCustomElement
73
- const css: typeof import('./element').css
74
- const unsafeCSS: typeof import('./element').unsafeCSS
75
-
76
- const createRouter: typeof import('./router').createRouter
77
- const navigate: typeof import('./router').navigate
78
- const mountOutlet: typeof import('./router').mountOutlet
79
- const currentRoute: typeof import('./router').currentRoute
80
- const routeParams: typeof import('./router').routeParams
81
- const routeQuery: typeof import('./router').routeQuery
82
- const matchedRoutes: typeof import('./router').matchedRoutes
83
- const routeMeta: typeof import('./router').routeMeta
84
- const beforeEach: typeof import('./router').beforeEach
85
- const afterEach: typeof import('./router').afterEach
86
- const use: typeof import('./router').use
87
- const onError: typeof import('./router').onError
88
- const generateRoutes: typeof import('./router').generateRoutes
89
-
90
- const mountTemplate: typeof import('./compiler').mountTemplate
91
- const defineComposable: typeof import('./composable').defineComposable
92
- const assertSetupContext: typeof import('./composable').assertSetupContext
93
-
94
- const defineStore: typeof import('./store').defineStore
95
- const storeToRefs: typeof import('./store').storeToRefs
96
- const storeToState: typeof import('./store').storeToState
97
- const storeToGetters: typeof import('./store').storeToGetters
98
- const useNestedStore: typeof import('./store').useNestedStore
99
- const resetStore: typeof import('./store').resetStore
100
- const clearStores: typeof import('./store').clearStores
101
- const registerStorePlugin: typeof import('./store').registerStorePlugin
102
- type StoreHook<T> = import('./store').StoreHook<T>
103
-
104
- const directive: typeof import('./directives').directive
105
- const isDelegatedEvent: typeof import('./event-delegation').isDelegatedEvent
106
- const InjectionToken: typeof import('./di').InjectionToken
107
- const provideGlobal: typeof import('./di').provideGlobal
108
- const reconcile: typeof import('./reconcile').reconcile
109
-
110
- const defineAction: typeof import('./actions').defineAction
111
- const createActionProxy: typeof import('./actions').createActionProxy
112
- const useAction: typeof import('./actions').useAction
113
- }
114
-
115
- export as namespace Fusee
116
-
117
- declare module '*.template.html' {
118
- export const render: (_ctx: any, _components: any) => any[]
1
+ import { createApp as createAppFn } from './app-registry'
2
+
3
+ // Core entry only. Router, store, DI tokens, actions and plugins have their own entries
4
+ // (fusee-framework/router, /store, /di, /actions, /plugins) with their own typings.
5
+ export * from './signal'
6
+ export * from './component'
7
+ export * from './element'
8
+ export * from './composable'
9
+ export * from './compiler'
10
+ export * from './directives'
11
+ export * from './event-delegation'
12
+ export * from './reconcile'
13
+ export * from './resource'
14
+ export * from './app-registry'
15
+
16
+ declare global {
17
+ type Signal<T = any> = import('./signal').Signal<T>
18
+ type Computed<T = any> = import('./signal').Computed<T>
19
+ type SignalAccessor<T> = import('./signal').SignalAccessor<T>
20
+ type Composable<T extends (...args: any[]) => any> = import('./composable').Composable<T>
21
+ type DirectiveBinding<V = any> = import('./directives').DirectiveBinding<V>
22
+ type DirectiveHooks<V = any> = import('./directives').DirectiveHooks<V>
23
+ type DelegatedEventOptions = import('./event-delegation').DelegatedEventOptions
24
+
25
+ type AppConfig = import('./app-registry').AppConfig
26
+ type Plugin<Options extends any[] = any[]> = import('./app-registry').Plugin<Options>
27
+ type CompilerPlugin = import('./plugins').CompilerPlugin
28
+ type ServerPlugin = import('./plugins').ServerPlugin
29
+ type DevToolsPlugin = import('./plugins').DevToolsPlugin
30
+ type RuntimeAdapter = import('./plugins').RuntimeAdapter
31
+ type FuseePlugin = import('./plugins').FuseePlugin
32
+
33
+ const createApp: typeof createAppFn
34
+
35
+ const defineCompilerPlugin: typeof import('./plugins').defineCompilerPlugin
36
+ const defineServerPlugin: typeof import('./plugins').defineServerPlugin
37
+ const defineDevToolsPlugin: typeof import('./plugins').defineDevToolsPlugin
38
+ const defineRuntimeAdapter: typeof import('./plugins').defineRuntimeAdapter
39
+ const defineFuseePlugin: typeof import('./plugins').defineFuseePlugin
40
+
41
+ const emit: (eventName?: string, ...args: any[]) => void
42
+ const signal: typeof import('./signal').signal
43
+ const computed: typeof import('./signal').computed
44
+ const effect: typeof import('./signal').effect
45
+ const batch: typeof import('./signal').batch
46
+ const untrack: typeof import('./signal').untrack
47
+ const inspect: typeof import('./signal').inspect
48
+ const watch: typeof import('./signal').watch
49
+ const onCleanup: typeof import('./signal').onCleanup
50
+ const resource: typeof import('./signal').resource
51
+ const defineResource: typeof import('./resource').defineResource
52
+ const createSuspense: typeof import('./signal').createSuspense
53
+ const scheduleAsyncJob: typeof import('./signal').scheduleAsyncJob
54
+
55
+ const defineComponent: typeof import('./component').defineComponent
56
+ const defineCompiledComponent: typeof import('./component').defineCompiledComponent
57
+ const defineAsyncComponent: typeof import('./component').defineAsyncComponent
58
+ const onMount: typeof import('./component').onMount
59
+ const onUnmount: typeof import('./component').onUnmount
60
+ const parseSlots: typeof import('./component').parseSlots
61
+ const provide: typeof import('./component').provide
62
+ const inject: typeof import('./di').inject
63
+ const getCurrentInstance: typeof import('./component').getCurrentInstance
64
+
65
+ const defineElement: typeof import('./element').defineElement
66
+ const toCustomElement: typeof import('./element').toCustomElement
67
+ const css: typeof import('./element').css
68
+ const unsafeCSS: typeof import('./element').unsafeCSS
69
+
70
+ const createRouter: typeof import('./router').createRouter
71
+ const navigate: typeof import('./router').navigate
72
+ const mountOutlet: typeof import('./router').mountOutlet
73
+ const currentRoute: typeof import('./router').currentRoute
74
+ const routeParams: typeof import('./router').routeParams
75
+ const routeQuery: typeof import('./router').routeQuery
76
+ const matchedRoutes: typeof import('./router').matchedRoutes
77
+ const routeMeta: typeof import('./router').routeMeta
78
+ const beforeEach: typeof import('./router').beforeEach
79
+ const afterEach: typeof import('./router').afterEach
80
+ const use: typeof import('./router').use
81
+ const onError: typeof import('./router').onError
82
+ const generateRoutes: typeof import('./router').generateRoutes
83
+
84
+ const mountTemplate: typeof import('./compiler').mountTemplate
85
+ const defineComposable: typeof import('./composable').defineComposable
86
+ const assertSetupContext: typeof import('./composable').assertSetupContext
87
+
88
+ const defineStore: typeof import('./store').defineStore
89
+ const storeToRefs: typeof import('./store').storeToRefs
90
+ const storeToState: typeof import('./store').storeToState
91
+ const storeToGetters: typeof import('./store').storeToGetters
92
+ const useNestedStore: typeof import('./store').useNestedStore
93
+ const resetStore: typeof import('./store').resetStore
94
+ const clearStores: typeof import('./store').clearStores
95
+ const registerStorePlugin: typeof import('./store').registerStorePlugin
96
+ type StoreHook<T> = import('./store').StoreHook<T>
97
+
98
+ const directive: typeof import('./directives').directive
99
+ const isDelegatedEvent: typeof import('./event-delegation').isDelegatedEvent
100
+ const InjectionToken: typeof import('./di').InjectionToken
101
+ const provideGlobal: typeof import('./di').provideGlobal
102
+ const reconcile: typeof import('./reconcile').reconcile
103
+
104
+ const defineAction: typeof import('./actions').defineAction
105
+ const createActionProxy: typeof import('./actions').createActionProxy
106
+ const useAction: typeof import('./actions').useAction
107
+ }
108
+
109
+ export as namespace Fusee
110
+
111
+ declare module '*.template.html' {
112
+ export const render: (_ctx: any, _components: any) => any[]
119
113
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fusee-framework",
3
- "version": "2.7.2",
3
+ "version": "2.7.3",
4
4
  "description": "Fusée - Signals-first JS Framework | Peak Performance",
5
5
  "main": "./framework/index.js",
6
6
  "types": "./framework/types/index.d.ts",
@@ -12,6 +12,8 @@
12
12
  "!framework/core/compiler-legacy/",
13
13
  "!framework/server-legacy/",
14
14
  "!framework/engine-go/",
15
+ "!framework/core/comet-js/",
16
+ "!framework/frel/",
15
17
  "framework/core/rust-compiler/pkg/fusee_compiler_bg.wasm",
16
18
  "bin/index.js",
17
19
  "bin/create-fusee-win.exe",
@@ -68,6 +70,22 @@
68
70
  "types": "./framework/types/router.d.ts",
69
71
  "import": "./framework/router/index.js"
70
72
  },
73
+ "./store": {
74
+ "types": "./framework/types/store.d.ts",
75
+ "import": "./framework/store/index.js"
76
+ },
77
+ "./di": {
78
+ "types": "./framework/types/di-entry.d.ts",
79
+ "import": "./framework/di/index.js"
80
+ },
81
+ "./actions": {
82
+ "types": "./framework/types/actions.d.ts",
83
+ "import": "./framework/actions/index.js"
84
+ },
85
+ "./plugins": {
86
+ "types": "./framework/types/plugins.d.ts",
87
+ "import": "./framework/plugins/index.js"
88
+ },
71
89
  "./runtime/ssr": {
72
90
  "import": "./framework/core/ssr.js"
73
91
  },
@@ -1,14 +0,0 @@
1
- export const config = {
2
- defaultSwap: 'innerHTML',
3
- /** Attribute prefix. Not intended to be changed at runtime in practice —
4
- * exposed mainly so tests can verify nothing is hardcoded needlessly. */
5
- attrPrefix: 'comet-',
6
- /** Class toggled on an element (or its comet-indicator target) while a request is in flight. */
7
- requestingClass: 'comet-requesting',
8
- /** Default request timeout in ms. 0 disables the timeout. */
9
- timeout: 0,
10
- /** Optional hydrator hook called on newly swapped DOM nodes: (node, detail) => void */
11
- hydrator: null,
12
- /** Optional cleanup hook called on DOM targets before they are replaced/removed: (target, swapMode) => void */
13
- cleanup: null,
14
- }
@@ -1,10 +0,0 @@
1
- export interface FuseeHydrationOptions {
2
- components?: Record<string, any>
3
- context?: Record<string, any>
4
- autoExtractState?: boolean
5
- }
6
-
7
- export declare function extractAndApplyEmbeddedState(root: Element): void
8
- export declare function hydrateFragment(node: Element, context?: Record<string, any>, components?: Record<string, any>, opts?: { autoExtractState?: boolean }): Array<() => void>
9
- export declare function cleanupFragment(target: Element): void
10
- export declare function enableFuseeHydration(options?: FuseeHydrationOptions): () => void
@@ -1,114 +0,0 @@
1
- import { setHydrator, setCleanup } from './comet.js'
2
- import { compileNode } from '../compiler.js'
3
- import { loadHydration } from '../hydration.js'
4
- import { loadSignalRegistry } from '../signal-scope.js'
5
-
6
- const nodeCleanups = new WeakMap()
7
- const activeElements = new Set()
8
-
9
- /**
10
- * Extracts and loads any embedded Fusée state payload from a node subtree.
11
- */
12
- export function extractAndApplyEmbeddedState(root) {
13
- if (!root || root.nodeType !== 1) return
14
-
15
- const scripts = []
16
- if (root.matches && (root.matches('script[data-fusee-state]') || root.id === '__FUSEE_DATA__')) {
17
- scripts.push(root)
18
- }
19
- if (root.querySelectorAll) {
20
- root.querySelectorAll('script[data-fusee-state], script#__FUSEE_DATA__').forEach(s => scripts.push(s))
21
- }
22
-
23
- for (const script of scripts) {
24
- try {
25
- let text = script.textContent.trim()
26
- if (text.startsWith('window.__FUSEE_STATE__')) {
27
- text = text.replace(/^window\.__FUSEE_STATE__\s*=\s*/, '').replace(/;$/, '')
28
- }
29
- if (text) {
30
- const payload = JSON.parse(text)
31
- if (payload.resources) loadHydration(payload.resources)
32
- if (payload.signals) loadSignalRegistry(payload.signals)
33
- }
34
- script.remove()
35
- } catch (err) {
36
- console.warn('[fusée:comet] failed to parse embedded hydration payload:', err)
37
- }
38
- }
39
- }
40
-
41
- /**
42
- * Hydrates a newly inserted DOM node with Fusée reactivity and components.
43
- */
44
- export function hydrateFragment(node, context = {}, components = {}, opts = {}) {
45
- if (!node || node.nodeType !== 1) return []
46
-
47
- if (opts.autoExtractState !== false) {
48
- extractAndApplyEmbeddedState(node)
49
- }
50
-
51
- const effects = []
52
- compileNode(node, context, components, effects)
53
-
54
- if (effects.length > 0) {
55
- nodeCleanups.set(node, effects)
56
- activeElements.add(node)
57
- }
58
-
59
- return effects
60
- }
61
-
62
- /**
63
- * Cleans up reactive effects, component instances, and subscriptions attached to a DOM subtree.
64
- */
65
- export function cleanupFragment(target) {
66
- if (!target || target.nodeType !== 1) return
67
-
68
- const toClean = []
69
- for (const el of activeElements) {
70
- if (el === target || target.contains(el)) {
71
- toClean.push(el)
72
- }
73
- }
74
-
75
- for (const el of toClean) {
76
- const cleanups = nodeCleanups.get(el)
77
- if (cleanups) {
78
- for (let i = cleanups.length - 1; i >= 0; i--) {
79
- const cleanup = cleanups[i]
80
- if (typeof cleanup === 'function') {
81
- try {
82
- cleanup()
83
- } catch (err) {
84
- console.error('[fusée:comet] error during node effect cleanup:', err)
85
- }
86
- }
87
- }
88
- nodeCleanups.delete(el)
89
- }
90
- activeElements.delete(el)
91
- }
92
- }
93
-
94
- /**
95
- * Enables automatic Fusée hydration for Comet DOM swaps.
96
- */
97
- export function enableFuseeHydration(options = {}) {
98
- const components = options.components || {}
99
- const context = options.context || {}
100
- const autoExtractState = options.autoExtractState !== false
101
-
102
- setCleanup((target) => {
103
- cleanupFragment(target)
104
- })
105
-
106
- setHydrator((node) => {
107
- hydrateFragment(node, context, components, { autoExtractState })
108
- })
109
-
110
- return function disableFuseeHydration() {
111
- setCleanup(null)
112
- setHydrator(null)
113
- }
114
- }
@@ -1,32 +0,0 @@
1
- export const ATTR = {
2
- get: 'comet-get',
3
- post: 'comet-post',
4
- put: 'comet-put',
5
- patch: 'comet-patch',
6
- delete: 'comet-delete',
7
- trigger: 'comet-trigger',
8
- target: 'comet-target',
9
- swap: 'comet-swap',
10
- vals: 'comet-vals',
11
- include: 'comet-include',
12
- pushUrl: 'comet-push-url',
13
- indicator: 'comet-indicator',
14
- confirm: 'comet-confirm',
15
- swapOob: 'comet-swap-oob',
16
- boost: 'comet-boost',
17
- }
18
-
19
- export const METHOD_ATTRS = [
20
- ['get', ATTR.get],
21
- ['post', ATTR.post],
22
- ['put', ATTR.put],
23
- ['patch', ATTR.patch],
24
- ['delete', ATTR.delete],
25
- ]
26
-
27
- export const DEFAULT_TRIGGER_BY_TAG = {
28
- FORM: 'submit',
29
- INPUT: 'change',
30
- TEXTAREA: 'change',
31
- SELECT: 'change',
32
- }