@fictjs/runtime 0.0.13 → 0.0.14
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/advanced.cjs +79 -0
- package/dist/advanced.cjs.map +1 -0
- package/dist/advanced.d.cts +50 -0
- package/dist/advanced.d.ts +50 -0
- package/dist/advanced.js +79 -0
- package/dist/advanced.js.map +1 -0
- package/dist/chunk-624QY53A.cjs +45 -0
- package/dist/chunk-624QY53A.cjs.map +1 -0
- package/dist/chunk-F3AIYQB7.js +45 -0
- package/dist/chunk-F3AIYQB7.js.map +1 -0
- package/dist/chunk-GJTYOFMO.cjs +109 -0
- package/dist/chunk-GJTYOFMO.cjs.map +1 -0
- package/dist/chunk-IUZXKAAY.js +109 -0
- package/dist/chunk-IUZXKAAY.js.map +1 -0
- package/dist/chunk-PMF6MWEV.cjs +3301 -0
- package/dist/chunk-PMF6MWEV.cjs.map +1 -0
- package/dist/chunk-RY4WDS6R.js +3301 -0
- package/dist/chunk-RY4WDS6R.js.map +1 -0
- package/dist/context-B7UYnfzM.d.ts +153 -0
- package/dist/context-UXySaqI_.d.cts +153 -0
- package/dist/effect-Auji1rz9.d.cts +350 -0
- package/dist/effect-Auji1rz9.d.ts +350 -0
- package/dist/index.cjs +98 -3558
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -1358
- package/dist/index.d.ts +5 -1358
- package/dist/index.dev.js +240 -1698
- package/dist/index.dev.js.map +1 -1
- package/dist/index.js +63 -3435
- package/dist/index.js.map +1 -1
- package/dist/internal.cjs +901 -0
- package/dist/internal.cjs.map +1 -0
- package/dist/internal.d.cts +158 -0
- package/dist/internal.d.ts +158 -0
- package/dist/internal.js +901 -0
- package/dist/internal.js.map +1 -0
- package/dist/{jsx-dev-runtime.d.ts → props-CrOMYbLv.d.cts} +107 -18
- package/dist/{jsx-dev-runtime.d.cts → props-ES0Ag_Wd.d.ts} +107 -18
- package/dist/scope-DKYzWfTn.d.cts +55 -0
- package/dist/scope-S6eAzBJZ.d.ts +55 -0
- package/package.json +11 -1
- package/src/advanced.ts +101 -0
- package/src/constants.ts +3 -26
- package/src/context.ts +300 -0
- package/src/delegated-events.ts +24 -0
- package/src/index.ts +41 -112
- package/src/internal.ts +130 -0
- package/src/props.ts +48 -46
- package/src/store.ts +47 -7
- package/src/versioned-signal.ts +3 -3
- package/dist/jsx-runtime.d.cts +0 -671
- package/dist/jsx-runtime.d.ts +0 -671
package/src/constants.ts
CHANGED
|
@@ -5,6 +5,8 @@
|
|
|
5
5
|
* Borrowed from dom-expressions for comprehensive DOM support.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
+
import { DelegatedEventNames } from './delegated-events'
|
|
9
|
+
|
|
8
10
|
const isDev =
|
|
9
11
|
typeof __DEV__ !== 'undefined'
|
|
10
12
|
? __DEV__
|
|
@@ -262,32 +264,7 @@ export const $$EVENTS = '_$FICT_DELEGATE'
|
|
|
262
264
|
* Events that should use event delegation for performance
|
|
263
265
|
* These events bubble and are commonly used across many elements
|
|
264
266
|
*/
|
|
265
|
-
const delegatedEvents = isDev
|
|
266
|
-
? [
|
|
267
|
-
'beforeinput',
|
|
268
|
-
'click',
|
|
269
|
-
'dblclick',
|
|
270
|
-
'contextmenu',
|
|
271
|
-
'focusin',
|
|
272
|
-
'focusout',
|
|
273
|
-
'input',
|
|
274
|
-
'keydown',
|
|
275
|
-
'keyup',
|
|
276
|
-
'mousedown',
|
|
277
|
-
'mousemove',
|
|
278
|
-
'mouseout',
|
|
279
|
-
'mouseover',
|
|
280
|
-
'mouseup',
|
|
281
|
-
'pointerdown',
|
|
282
|
-
'pointermove',
|
|
283
|
-
'pointerout',
|
|
284
|
-
'pointerover',
|
|
285
|
-
'pointerup',
|
|
286
|
-
'touchend',
|
|
287
|
-
'touchmove',
|
|
288
|
-
'touchstart',
|
|
289
|
-
]
|
|
290
|
-
: []
|
|
267
|
+
const delegatedEvents = isDev ? DelegatedEventNames : []
|
|
291
268
|
|
|
292
269
|
export const DelegatedEvents = new Set<string>(delegatedEvents)
|
|
293
270
|
|
package/src/context.ts
ADDED
|
@@ -0,0 +1,300 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Context API for Fict
|
|
3
|
+
*
|
|
4
|
+
* Provides a way to pass data through the component tree without having to pass
|
|
5
|
+
* props down manually at every level. Context is designed for:
|
|
6
|
+
*
|
|
7
|
+
* - SSR isolation (different request = different context values)
|
|
8
|
+
* - Multi-instance support (multiple app roots with different values)
|
|
9
|
+
* - Subtree scoping (override values in specific parts of the tree)
|
|
10
|
+
*
|
|
11
|
+
* ## Design Principles
|
|
12
|
+
*
|
|
13
|
+
* 1. **Reuses existing RootContext hierarchy** - Uses parent chain for value lookup,
|
|
14
|
+
* consistent with handleError/handleSuspend mechanisms.
|
|
15
|
+
*
|
|
16
|
+
* 2. **Zero extra root creation overhead** - Provider doesn't create new root,
|
|
17
|
+
* only mounts value on current root.
|
|
18
|
+
*
|
|
19
|
+
* 3. **Auto-aligned with insert/suspense boundaries** - Because they create child
|
|
20
|
+
* roots that inherit parent, context values propagate correctly.
|
|
21
|
+
*
|
|
22
|
+
* ## Usage
|
|
23
|
+
*
|
|
24
|
+
* ```tsx
|
|
25
|
+
* // Create context with default value
|
|
26
|
+
* const ThemeContext = createContext<'light' | 'dark'>('light')
|
|
27
|
+
*
|
|
28
|
+
* // Provide value to subtree
|
|
29
|
+
* function App() {
|
|
30
|
+
* return (
|
|
31
|
+
* <ThemeContext.Provider value="dark">
|
|
32
|
+
* <ThemedComponent />
|
|
33
|
+
* </ThemeContext.Provider>
|
|
34
|
+
* )
|
|
35
|
+
* }
|
|
36
|
+
*
|
|
37
|
+
* // Consume value
|
|
38
|
+
* function ThemedComponent() {
|
|
39
|
+
* const theme = useContext(ThemeContext)
|
|
40
|
+
* return <div class={theme}>...</div>
|
|
41
|
+
* }
|
|
42
|
+
* ```
|
|
43
|
+
*
|
|
44
|
+
* @module
|
|
45
|
+
*/
|
|
46
|
+
|
|
47
|
+
import { createElement } from './dom'
|
|
48
|
+
import {
|
|
49
|
+
createRootContext,
|
|
50
|
+
destroyRoot,
|
|
51
|
+
flushOnMount,
|
|
52
|
+
getCurrentRoot,
|
|
53
|
+
popRoot,
|
|
54
|
+
pushRoot,
|
|
55
|
+
type RootContext,
|
|
56
|
+
} from './lifecycle'
|
|
57
|
+
import { insertNodesBefore, removeNodes, toNodeArray } from './node-ops'
|
|
58
|
+
import { createRenderEffect } from './effect'
|
|
59
|
+
import type { BaseProps, FictNode } from './types'
|
|
60
|
+
|
|
61
|
+
// ============================================================================
|
|
62
|
+
// Types
|
|
63
|
+
// ============================================================================
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Context object created by createContext.
|
|
67
|
+
* Contains the Provider component and serves as a key for context lookup.
|
|
68
|
+
*/
|
|
69
|
+
export interface Context<T> {
|
|
70
|
+
/** Unique identifier for this context */
|
|
71
|
+
readonly id: symbol
|
|
72
|
+
/** Default value when no provider is found */
|
|
73
|
+
readonly defaultValue: T
|
|
74
|
+
/** Provider component for supplying context values */
|
|
75
|
+
Provider: ContextProvider<T>
|
|
76
|
+
/** Display name for debugging */
|
|
77
|
+
displayName?: string
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Props for the Context Provider component
|
|
82
|
+
*/
|
|
83
|
+
export interface ProviderProps<T> extends BaseProps {
|
|
84
|
+
/** The value to provide to the subtree */
|
|
85
|
+
value: T
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Provider component type
|
|
90
|
+
*/
|
|
91
|
+
export type ContextProvider<T> = (props: ProviderProps<T>) => FictNode
|
|
92
|
+
|
|
93
|
+
// ============================================================================
|
|
94
|
+
// Internal Context Storage
|
|
95
|
+
// ============================================================================
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* WeakMap to store context values per RootContext.
|
|
99
|
+
* Using WeakMap ensures proper garbage collection when roots are destroyed.
|
|
100
|
+
*/
|
|
101
|
+
const contextStorage = new WeakMap<RootContext, Map<symbol, unknown>>()
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Get the context map for a root, creating it if needed
|
|
105
|
+
*/
|
|
106
|
+
function getContextMap(root: RootContext): Map<symbol, unknown> {
|
|
107
|
+
let map = contextStorage.get(root)
|
|
108
|
+
if (!map) {
|
|
109
|
+
map = new Map()
|
|
110
|
+
contextStorage.set(root, map)
|
|
111
|
+
}
|
|
112
|
+
return map
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
// ============================================================================
|
|
116
|
+
// Context API
|
|
117
|
+
// ============================================================================
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Creates a new context with the given default value.
|
|
121
|
+
*
|
|
122
|
+
* Context provides a way to pass values through the component tree without
|
|
123
|
+
* explicit props drilling. It's especially useful for:
|
|
124
|
+
*
|
|
125
|
+
* - Theme data
|
|
126
|
+
* - Locale/i18n settings
|
|
127
|
+
* - Authentication state
|
|
128
|
+
* - Feature flags
|
|
129
|
+
* - Any data that many components at different nesting levels need
|
|
130
|
+
*
|
|
131
|
+
* @param defaultValue - The value to use when no Provider is found above in the tree
|
|
132
|
+
* @returns A context object with a Provider component
|
|
133
|
+
*
|
|
134
|
+
* @example
|
|
135
|
+
* ```tsx
|
|
136
|
+
* // Create a theme context
|
|
137
|
+
* const ThemeContext = createContext<'light' | 'dark'>('light')
|
|
138
|
+
*
|
|
139
|
+
* // Use the provider
|
|
140
|
+
* function App() {
|
|
141
|
+
* return (
|
|
142
|
+
* <ThemeContext.Provider value="dark">
|
|
143
|
+
* <Content />
|
|
144
|
+
* </ThemeContext.Provider>
|
|
145
|
+
* )
|
|
146
|
+
* }
|
|
147
|
+
*
|
|
148
|
+
* // Consume the context
|
|
149
|
+
* function Content() {
|
|
150
|
+
* const theme = useContext(ThemeContext)
|
|
151
|
+
* return <div class={`theme-${theme}`}>Hello</div>
|
|
152
|
+
* }
|
|
153
|
+
* ```
|
|
154
|
+
*/
|
|
155
|
+
export function createContext<T>(defaultValue: T): Context<T> {
|
|
156
|
+
const id = Symbol('fict.context')
|
|
157
|
+
|
|
158
|
+
const context: Context<T> = {
|
|
159
|
+
id,
|
|
160
|
+
defaultValue,
|
|
161
|
+
Provider: null as unknown as ContextProvider<T>,
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
// Create the Provider component
|
|
165
|
+
context.Provider = function Provider(props: ProviderProps<T>): FictNode {
|
|
166
|
+
const hostRoot = getCurrentRoot()
|
|
167
|
+
|
|
168
|
+
// Create a child root for the provider's subtree
|
|
169
|
+
// This establishes the provider boundary - children will look up from here
|
|
170
|
+
const providerRoot = createRootContext(hostRoot)
|
|
171
|
+
|
|
172
|
+
// Store the context value on this root
|
|
173
|
+
const contextMap = getContextMap(providerRoot)
|
|
174
|
+
contextMap.set(id, props.value)
|
|
175
|
+
|
|
176
|
+
// Create DOM structure
|
|
177
|
+
const fragment = document.createDocumentFragment()
|
|
178
|
+
const marker = document.createComment('fict:ctx')
|
|
179
|
+
fragment.appendChild(marker)
|
|
180
|
+
|
|
181
|
+
let cleanup: (() => void) | undefined
|
|
182
|
+
let activeNodes: Node[] = []
|
|
183
|
+
|
|
184
|
+
const renderChildren = (children: FictNode) => {
|
|
185
|
+
// Cleanup previous render
|
|
186
|
+
if (cleanup) {
|
|
187
|
+
cleanup()
|
|
188
|
+
cleanup = undefined
|
|
189
|
+
}
|
|
190
|
+
if (activeNodes.length) {
|
|
191
|
+
removeNodes(activeNodes)
|
|
192
|
+
activeNodes = []
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
if (children == null || children === false) {
|
|
196
|
+
return
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
const prev = pushRoot(providerRoot)
|
|
200
|
+
let nodes: Node[] = []
|
|
201
|
+
try {
|
|
202
|
+
const output = createElement(children)
|
|
203
|
+
nodes = toNodeArray(output)
|
|
204
|
+
const parentNode = marker.parentNode as (ParentNode & Node) | null
|
|
205
|
+
if (parentNode) {
|
|
206
|
+
insertNodesBefore(parentNode, nodes, marker)
|
|
207
|
+
}
|
|
208
|
+
} finally {
|
|
209
|
+
popRoot(prev)
|
|
210
|
+
flushOnMount(providerRoot)
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
cleanup = () => {
|
|
214
|
+
destroyRoot(providerRoot)
|
|
215
|
+
removeNodes(nodes)
|
|
216
|
+
}
|
|
217
|
+
activeNodes = nodes
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
// Initial render
|
|
221
|
+
createRenderEffect(() => {
|
|
222
|
+
// Update context value on re-render (if value prop changes reactively)
|
|
223
|
+
contextMap.set(id, props.value)
|
|
224
|
+
renderChildren(props.children)
|
|
225
|
+
})
|
|
226
|
+
|
|
227
|
+
return fragment
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
return context
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
/**
|
|
234
|
+
* Reads the current value of a context.
|
|
235
|
+
*
|
|
236
|
+
* useContext looks up through the RootContext parent chain to find the
|
|
237
|
+
* nearest Provider for this context. If no Provider is found, returns
|
|
238
|
+
* the context's default value.
|
|
239
|
+
*
|
|
240
|
+
* @param context - The context object created by createContext
|
|
241
|
+
* @returns The current context value
|
|
242
|
+
*
|
|
243
|
+
* @example
|
|
244
|
+
* ```tsx
|
|
245
|
+
* const ThemeContext = createContext('light')
|
|
246
|
+
*
|
|
247
|
+
* function ThemedButton() {
|
|
248
|
+
* const theme = useContext(ThemeContext)
|
|
249
|
+
* return <button class={theme === 'dark' ? 'btn-dark' : 'btn-light'}>Click</button>
|
|
250
|
+
* }
|
|
251
|
+
* ```
|
|
252
|
+
*/
|
|
253
|
+
export function useContext<T>(context: Context<T>): T {
|
|
254
|
+
let root = getCurrentRoot()
|
|
255
|
+
|
|
256
|
+
// Walk up the parent chain looking for the context value
|
|
257
|
+
while (root) {
|
|
258
|
+
const contextMap = contextStorage.get(root)
|
|
259
|
+
if (contextMap && contextMap.has(context.id)) {
|
|
260
|
+
return contextMap.get(context.id) as T
|
|
261
|
+
}
|
|
262
|
+
root = root.parent
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
// No provider found, return default value
|
|
266
|
+
return context.defaultValue
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
/**
|
|
270
|
+
* Checks if a context value is currently provided in the tree.
|
|
271
|
+
*
|
|
272
|
+
* Useful for conditional behavior when a provider may or may not exist.
|
|
273
|
+
*
|
|
274
|
+
* @param context - The context object to check
|
|
275
|
+
* @returns true if a Provider exists above in the tree
|
|
276
|
+
*
|
|
277
|
+
* @example
|
|
278
|
+
* ```tsx
|
|
279
|
+
* function OptionalTheme() {
|
|
280
|
+
* if (hasContext(ThemeContext)) {
|
|
281
|
+
* const theme = useContext(ThemeContext)
|
|
282
|
+
* return <div class={theme}>Themed content</div>
|
|
283
|
+
* }
|
|
284
|
+
* return <div>Default content</div>
|
|
285
|
+
* }
|
|
286
|
+
* ```
|
|
287
|
+
*/
|
|
288
|
+
export function hasContext<T>(context: Context<T>): boolean {
|
|
289
|
+
let root = getCurrentRoot()
|
|
290
|
+
|
|
291
|
+
while (root) {
|
|
292
|
+
const contextMap = contextStorage.get(root)
|
|
293
|
+
if (contextMap && contextMap.has(context.id)) {
|
|
294
|
+
return true
|
|
295
|
+
}
|
|
296
|
+
root = root.parent
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
return false
|
|
300
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export const DelegatedEventNames = [
|
|
2
|
+
'beforeinput',
|
|
3
|
+
'click',
|
|
4
|
+
'dblclick',
|
|
5
|
+
'contextmenu',
|
|
6
|
+
'focusin',
|
|
7
|
+
'focusout',
|
|
8
|
+
'input',
|
|
9
|
+
'keydown',
|
|
10
|
+
'keyup',
|
|
11
|
+
'mousedown',
|
|
12
|
+
'mousemove',
|
|
13
|
+
'mouseout',
|
|
14
|
+
'mouseover',
|
|
15
|
+
'mouseup',
|
|
16
|
+
'pointerdown',
|
|
17
|
+
'pointermove',
|
|
18
|
+
'pointerout',
|
|
19
|
+
'pointerover',
|
|
20
|
+
'pointerup',
|
|
21
|
+
'touchend',
|
|
22
|
+
'touchmove',
|
|
23
|
+
'touchstart',
|
|
24
|
+
] as const
|
package/src/index.ts
CHANGED
|
@@ -1,38 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Fict Runtime - Public API
|
|
3
|
+
*
|
|
4
|
+
* This module exports the public API for the Fict reactive UI framework.
|
|
5
|
+
*
|
|
6
|
+
* ## Recommended Import Pattern (v1.0+)
|
|
7
|
+
*
|
|
8
|
+
* ```typescript
|
|
9
|
+
* // Core public API (most users need only this)
|
|
10
|
+
* import { createEffect, render } from '@fictjs/runtime'
|
|
11
|
+
*
|
|
12
|
+
* // Advanced APIs (power users, escape hatches)
|
|
13
|
+
* import { createSignal, createContext, createScope } from '@fictjs/runtime/advanced'
|
|
14
|
+
*
|
|
15
|
+
* // Internal APIs (compiler/library authors only)
|
|
16
|
+
* import { bindText, __fictUseSignal } from '@fictjs/runtime/internal'
|
|
17
|
+
* ```
|
|
18
|
+
*
|
|
19
|
+
* @public
|
|
20
|
+
* @packageDocumentation
|
|
21
|
+
*/
|
|
22
|
+
|
|
1
23
|
// ============================================================================
|
|
2
24
|
// Core Reactive Primitives
|
|
3
25
|
// ============================================================================
|
|
4
26
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
export {
|
|
12
|
-
|
|
13
|
-
__fictPushContext,
|
|
14
|
-
__fictPopContext,
|
|
15
|
-
__fictUseSignal,
|
|
16
|
-
__fictUseMemo,
|
|
17
|
-
__fictUseEffect,
|
|
18
|
-
__fictRender,
|
|
19
|
-
__fictResetContext,
|
|
20
|
-
} from './hooks'
|
|
21
|
-
export {
|
|
22
|
-
createVersionedSignal,
|
|
23
|
-
type VersionedSignal,
|
|
24
|
-
type VersionedSignalOptions,
|
|
25
|
-
} from './versioned-signal'
|
|
26
|
-
|
|
27
|
-
// Props helpers
|
|
28
|
-
export {
|
|
29
|
-
__fictProp,
|
|
30
|
-
__fictProp as prop,
|
|
31
|
-
__fictPropsRest,
|
|
32
|
-
mergeProps,
|
|
33
|
-
useProp,
|
|
34
|
-
createPropsProxy,
|
|
35
|
-
} from './props'
|
|
27
|
+
/**
|
|
28
|
+
* Note: createSignal is exported from ./advanced as an escape hatch.
|
|
29
|
+
* For most use cases, prefer:
|
|
30
|
+
* - $state: For component-local state (compiler-transformed, safe scoping)
|
|
31
|
+
* - $store: For cross-component shared state with deep reactivity
|
|
32
|
+
*/
|
|
33
|
+
export { createMemo, type Memo } from './memo'
|
|
34
|
+
export { createEffect, type Effect } from './effect'
|
|
36
35
|
|
|
37
36
|
// ============================================================================
|
|
38
37
|
// Lifecycle
|
|
@@ -40,7 +39,10 @@ export {
|
|
|
40
39
|
|
|
41
40
|
export { onMount, onDestroy, onCleanup, createRoot } from './lifecycle'
|
|
42
41
|
|
|
43
|
-
//
|
|
42
|
+
// ============================================================================
|
|
43
|
+
// Ref
|
|
44
|
+
// ============================================================================
|
|
45
|
+
|
|
44
46
|
export { createRef } from './ref'
|
|
45
47
|
|
|
46
48
|
// ============================================================================
|
|
@@ -48,9 +50,6 @@ export { createRef } from './ref'
|
|
|
48
50
|
// ============================================================================
|
|
49
51
|
|
|
50
52
|
export { batch, untrack } from './scheduler'
|
|
51
|
-
export { setCycleProtectionOptions } from './cycle-guard'
|
|
52
|
-
|
|
53
|
-
// Transition API for priority scheduling
|
|
54
53
|
export { startTransition, useTransition, useDeferredValue } from './scheduler'
|
|
55
54
|
|
|
56
55
|
// ============================================================================
|
|
@@ -64,71 +63,22 @@ export { Fragment } from './jsx'
|
|
|
64
63
|
// DOM Rendering
|
|
65
64
|
// ============================================================================
|
|
66
65
|
|
|
67
|
-
export { createElement, render
|
|
66
|
+
export { createElement, render } from './dom'
|
|
67
|
+
export { createPortal } from './binding'
|
|
68
68
|
export { ErrorBoundary } from './error-boundary'
|
|
69
69
|
export { Suspense, createSuspenseToken } from './suspense'
|
|
70
|
+
export { createContext, useContext, hasContext, type Context, type ProviderProps } from './context'
|
|
70
71
|
|
|
71
72
|
// ============================================================================
|
|
72
|
-
//
|
|
73
|
-
// ============================================================================
|
|
74
|
-
|
|
75
|
-
export {
|
|
76
|
-
// Core binding utilities
|
|
77
|
-
createTextBinding,
|
|
78
|
-
createChildBinding,
|
|
79
|
-
createAttributeBinding,
|
|
80
|
-
createStyleBinding,
|
|
81
|
-
createClassBinding,
|
|
82
|
-
// Low-level binding helpers (for direct DOM manipulation)
|
|
83
|
-
bindText,
|
|
84
|
-
bindAttribute,
|
|
85
|
-
bindStyle,
|
|
86
|
-
bindClass,
|
|
87
|
-
bindEvent,
|
|
88
|
-
callEventHandler,
|
|
89
|
-
bindProperty,
|
|
90
|
-
bindRef,
|
|
91
|
-
insert,
|
|
92
|
-
// Event delegation
|
|
93
|
-
delegateEvents,
|
|
94
|
-
clearDelegatedEvents,
|
|
95
|
-
addEventListener,
|
|
96
|
-
// Spread props
|
|
97
|
-
spread,
|
|
98
|
-
assign,
|
|
99
|
-
classList,
|
|
100
|
-
// Reactive detection
|
|
101
|
-
isReactive,
|
|
102
|
-
// Advanced bindings
|
|
103
|
-
createConditional,
|
|
104
|
-
createPortal,
|
|
105
|
-
createShow,
|
|
106
|
-
// Utility functions
|
|
107
|
-
unwrap,
|
|
108
|
-
} from './binding'
|
|
109
|
-
|
|
110
|
-
// Constants for DOM handling
|
|
111
|
-
export {
|
|
112
|
-
Properties,
|
|
113
|
-
ChildProperties,
|
|
114
|
-
Aliases,
|
|
115
|
-
getPropAlias,
|
|
116
|
-
BooleanAttributes,
|
|
117
|
-
SVGElements,
|
|
118
|
-
SVGNamespace,
|
|
119
|
-
DelegatedEvents,
|
|
120
|
-
UnitlessStyles,
|
|
121
|
-
} from './constants'
|
|
122
|
-
|
|
123
|
-
// Reconcile algorithm
|
|
124
|
-
export { default as reconcileArrays } from './reconcile'
|
|
73
|
+
// Props Utilities (Public)
|
|
74
|
+
// ============================================================================
|
|
75
|
+
|
|
76
|
+
export { prop, mergeProps } from './props'
|
|
125
77
|
|
|
126
78
|
// ============================================================================
|
|
127
79
|
// Types
|
|
128
80
|
// ============================================================================
|
|
129
81
|
|
|
130
|
-
export type { MaybeReactive, BindingHandle, CreateElementFn, AttributeSetter } from './binding'
|
|
131
|
-
|
|
132
82
|
export type {
|
|
133
83
|
FictNode,
|
|
134
84
|
FictVNode,
|
|
@@ -146,24 +96,3 @@ export type {
|
|
|
146
96
|
ErrorInfo,
|
|
147
97
|
SuspenseToken,
|
|
148
98
|
} from './types'
|
|
149
|
-
|
|
150
|
-
// Devtools hook (optional)
|
|
151
|
-
export { getDevtoolsHook, type FictDevtoolsHook } from './devtools'
|
|
152
|
-
|
|
153
|
-
// ============================================================================
|
|
154
|
-
// List Helpers (for compiler-generated code)
|
|
155
|
-
// ============================================================================
|
|
156
|
-
|
|
157
|
-
export {
|
|
158
|
-
// DOM manipulation primitives
|
|
159
|
-
moveNodesBefore,
|
|
160
|
-
removeNodes,
|
|
161
|
-
insertNodesBefore,
|
|
162
|
-
// High-level list binding (for compiler-generated code)
|
|
163
|
-
createKeyedList,
|
|
164
|
-
// Utilities
|
|
165
|
-
toNodeArray,
|
|
166
|
-
isNodeBetweenMarkers,
|
|
167
|
-
// Types
|
|
168
|
-
type KeyedListBinding,
|
|
169
|
-
} from './list-helpers'
|
package/src/internal.ts
ADDED
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Internal APIs for Fict Compiler
|
|
3
|
+
*
|
|
4
|
+
* This module exports internal APIs used by compiler-generated code.
|
|
5
|
+
* These APIs are NOT part of the public API and should NOT be used directly.
|
|
6
|
+
*
|
|
7
|
+
* @internal
|
|
8
|
+
* @packageDocumentation
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
// ============================================================================
|
|
12
|
+
// Core Primitives (also exported from main, but needed by compiler)
|
|
13
|
+
// ============================================================================
|
|
14
|
+
|
|
15
|
+
export { createSignal, createSelector } from './signal'
|
|
16
|
+
export { createStore, type Store } from './store'
|
|
17
|
+
export { createMemo } from './memo'
|
|
18
|
+
export { createEffect } from './effect'
|
|
19
|
+
export { Fragment } from './jsx'
|
|
20
|
+
|
|
21
|
+
// ============================================================================
|
|
22
|
+
// Hook Context Management (Compiler-generated code)
|
|
23
|
+
// ============================================================================
|
|
24
|
+
|
|
25
|
+
export {
|
|
26
|
+
__fictUseContext,
|
|
27
|
+
__fictPushContext,
|
|
28
|
+
__fictPopContext,
|
|
29
|
+
__fictUseSignal,
|
|
30
|
+
__fictUseMemo,
|
|
31
|
+
__fictUseEffect,
|
|
32
|
+
__fictRender,
|
|
33
|
+
__fictResetContext,
|
|
34
|
+
} from './hooks'
|
|
35
|
+
|
|
36
|
+
// ============================================================================
|
|
37
|
+
// Props Helpers (Compiler-generated code)
|
|
38
|
+
// ============================================================================
|
|
39
|
+
|
|
40
|
+
export { __fictProp, __fictPropsRest, createPropsProxy, mergeProps, prop } from './props'
|
|
41
|
+
|
|
42
|
+
// ============================================================================
|
|
43
|
+
// DOM Bindings (Compiler-generated code)
|
|
44
|
+
// ============================================================================
|
|
45
|
+
|
|
46
|
+
export {
|
|
47
|
+
bindText,
|
|
48
|
+
bindAttribute,
|
|
49
|
+
bindStyle,
|
|
50
|
+
bindClass,
|
|
51
|
+
bindEvent,
|
|
52
|
+
callEventHandler,
|
|
53
|
+
bindProperty,
|
|
54
|
+
bindRef,
|
|
55
|
+
insert,
|
|
56
|
+
createConditional,
|
|
57
|
+
createPortal,
|
|
58
|
+
spread,
|
|
59
|
+
assign,
|
|
60
|
+
classList,
|
|
61
|
+
isReactive,
|
|
62
|
+
unwrap,
|
|
63
|
+
} from './binding'
|
|
64
|
+
|
|
65
|
+
// ============================================================================
|
|
66
|
+
// Event Delegation (Compiler-generated code)
|
|
67
|
+
// ============================================================================
|
|
68
|
+
|
|
69
|
+
export { delegateEvents, clearDelegatedEvents, addEventListener } from './binding'
|
|
70
|
+
|
|
71
|
+
// ============================================================================
|
|
72
|
+
// List Helpers (Compiler-generated code)
|
|
73
|
+
// ============================================================================
|
|
74
|
+
|
|
75
|
+
export {
|
|
76
|
+
moveNodesBefore,
|
|
77
|
+
removeNodes,
|
|
78
|
+
insertNodesBefore,
|
|
79
|
+
createKeyedList,
|
|
80
|
+
toNodeArray,
|
|
81
|
+
isNodeBetweenMarkers,
|
|
82
|
+
type KeyedListBinding,
|
|
83
|
+
} from './list-helpers'
|
|
84
|
+
|
|
85
|
+
// ============================================================================
|
|
86
|
+
// DOM Creation (Compiler-generated code)
|
|
87
|
+
// ============================================================================
|
|
88
|
+
|
|
89
|
+
export { createElement, template } from './dom'
|
|
90
|
+
export { createRenderEffect } from './effect'
|
|
91
|
+
|
|
92
|
+
// ============================================================================
|
|
93
|
+
// Lifecycle (Compiler-generated code)
|
|
94
|
+
// ============================================================================
|
|
95
|
+
|
|
96
|
+
export { onDestroy } from './lifecycle'
|
|
97
|
+
|
|
98
|
+
// ============================================================================
|
|
99
|
+
// Scope (Compiler-generated code)
|
|
100
|
+
// ============================================================================
|
|
101
|
+
|
|
102
|
+
export { runInScope } from './scope'
|
|
103
|
+
|
|
104
|
+
// ============================================================================
|
|
105
|
+
// Constants (Compiler/Runtime shared)
|
|
106
|
+
// ============================================================================
|
|
107
|
+
|
|
108
|
+
export {
|
|
109
|
+
Properties,
|
|
110
|
+
ChildProperties,
|
|
111
|
+
Aliases,
|
|
112
|
+
getPropAlias,
|
|
113
|
+
BooleanAttributes,
|
|
114
|
+
SVGElements,
|
|
115
|
+
SVGNamespace,
|
|
116
|
+
DelegatedEvents,
|
|
117
|
+
UnitlessStyles,
|
|
118
|
+
} from './constants'
|
|
119
|
+
|
|
120
|
+
// ============================================================================
|
|
121
|
+
// Reconciliation (Internal)
|
|
122
|
+
// ============================================================================
|
|
123
|
+
|
|
124
|
+
export { default as reconcileArrays } from './reconcile'
|
|
125
|
+
|
|
126
|
+
// ============================================================================
|
|
127
|
+
// Types (Internal)
|
|
128
|
+
// ============================================================================
|
|
129
|
+
|
|
130
|
+
export type { MaybeReactive, BindingHandle, CreateElementFn, AttributeSetter } from './binding'
|