cogsbox-state 0.5.474 → 0.5.475-canary.1
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/README.md +11 -11
- package/dist/CogsState.d.ts +26 -17
- package/dist/CogsState.d.ts.map +1 -1
- package/dist/CogsState.jsx +383 -380
- package/dist/CogsState.jsx.map +1 -1
- package/dist/Components.d.ts.map +1 -1
- package/dist/Components.jsx +231 -225
- package/dist/Components.jsx.map +1 -1
- package/dist/PluginRunner.d.ts.map +1 -1
- package/dist/PluginRunner.jsx +82 -67
- package/dist/PluginRunner.jsx.map +1 -1
- package/dist/index.js +17 -16
- package/dist/plugins.d.ts +98 -980
- package/dist/plugins.d.ts.map +1 -1
- package/dist/plugins.js +48 -36
- package/dist/plugins.js.map +1 -1
- package/dist/store.js +168 -169
- package/dist/store.js.map +1 -1
- package/package.json +4 -3
- package/src/CogsState.tsx +234 -551
- package/src/Components.tsx +43 -34
- package/src/PluginRunner.tsx +24 -6
- package/src/plugins.ts +93 -127
- package/src/store.ts +1 -1
package/dist/Components.jsx.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Components.jsx","sources":["../src/Components.tsx"],"sourcesContent":["import {\r\n FormElementParams,\r\n StateObject,\r\n UpdateTypeDetail,\r\n type FormOptsType,\r\n} from './CogsState';\r\nimport { pluginStore } from './pluginStore';\r\nimport { createMetadataContext, toDeconstructedMethods } from './plugins';\r\nimport React, {\r\n memo,\r\n RefObject,\r\n useCallback,\r\n useEffect,\r\n useLayoutEffect,\r\n useRef,\r\n useState,\r\n useMemo,\r\n} from 'react';\r\nimport { getGlobalStore, ValidationError, ValidationSeverity } from './store';\r\nimport { useInView } from 'react-intersection-observer';\r\nimport { v4 as uuidv4 } from 'uuid';\r\nimport { isDeepEqual } from './utility';\r\nimport { runValidation } from './validation';\r\n\r\nconst {\r\n getInitialOptions,\r\n\r\n getShadowMetadata,\r\n setShadowMetadata,\r\n getShadowValue,\r\n\r\n registerComponent,\r\n unregisterComponent,\r\n\r\n notifyPathSubscribers,\r\n subscribeToPath,\r\n} = getGlobalStore.getState();\r\nconst { stateHandlers, notifyFormUpdate } = pluginStore.getState();\r\n\r\nexport type ValidationWrapperProps = {\r\n formOpts?: FormOptsType;\r\n path: string[];\r\n stateKey: string;\r\n children: React.ReactNode;\r\n};\r\n\r\nexport function ValidationWrapper({\r\n formOpts,\r\n path,\r\n stateKey,\r\n children,\r\n}: ValidationWrapperProps) {\r\n const { getInitialOptions, getShadowMetadata, getShadowValue } =\r\n getGlobalStore.getState();\r\n const thisStateOpts = getInitialOptions(stateKey!);\r\n\r\n const shadowMeta = getShadowMetadata(stateKey!, path);\r\n const validationState = shadowMeta?.validation;\r\n\r\n const status = validationState?.status || 'NOT_VALIDATED';\r\n\r\n const errors = (validationState?.errors || []).map((err) => ({\r\n ...err,\r\n path: path,\r\n })) as ValidationError[];\r\n const errorMessages = errors\r\n .filter((err) => err.severity === 'error')\r\n .map((err) => err.message);\r\n const warningMessages = errors\r\n .filter((err) => err.severity === 'warning')\r\n .map((err) => err.message);\r\n\r\n // Use first error, or first warning if no errors\r\n const message = errorMessages[0] || warningMessages[0];\r\n const primarySeverity: ValidationSeverity =\r\n errorMessages.length > 0\r\n ? 'error'\r\n : warningMessages.length > 0\r\n ? 'warning'\r\n : undefined;\r\n return (\r\n <>\r\n {thisStateOpts?.formElements?.validation &&\r\n !formOpts?.validation?.disable ? (\r\n thisStateOpts.formElements!.validation!({\r\n children: (\r\n <React.Fragment key={path.toString()}>{children}</React.Fragment>\r\n ),\r\n status, // Now passes the new ValidationStatus type\r\n message: formOpts?.validation?.hideMessage\r\n ? ''\r\n : formOpts?.validation?.message || message || '',\r\n severity: primarySeverity,\r\n hasErrors: errorMessages.length > 0,\r\n hasWarnings: warningMessages.length > 0,\r\n allErrors: errors,\r\n path: path,\r\n getData: () => getShadowValue(stateKey!, path),\r\n })\r\n ) : (\r\n <React.Fragment key={path.toString()}>{children}</React.Fragment>\r\n )}\r\n </>\r\n );\r\n}\r\nexport const MemoizedCogsItemWrapper = memo(\r\n ListItemWrapper,\r\n (prevProps, nextProps) => {\r\n // Re-render if any of these change:\r\n return (\r\n prevProps.itemPath.join('.') === nextProps.itemPath.join('.') &&\r\n prevProps.stateKey === nextProps.stateKey &&\r\n prevProps.itemComponentId === nextProps.itemComponentId &&\r\n prevProps.localIndex === nextProps.localIndex\r\n );\r\n }\r\n);\r\nexport function ListItemWrapper({\r\n stateKey,\r\n itemComponentId,\r\n itemPath,\r\n localIndex,\r\n arraySetter,\r\n rebuildStateShape,\r\n renderFn,\r\n}: {\r\n stateKey: string;\r\n itemComponentId: string;\r\n itemPath: string[];\r\n localIndex: number;\r\n arraySetter: any;\r\n\r\n rebuildStateShape: (options: {\r\n currentState: any;\r\n path: string[];\r\n componentId: string;\r\n meta?: any;\r\n }) => any;\r\n renderFn: (\r\n setter: any,\r\n index: number,\r\n\r\n arraySetter: any\r\n ) => React.ReactNode;\r\n}) {\r\n const [, forceUpdate] = useState({});\r\n const { ref: inViewRef, inView } = useInView();\r\n const elementRef = useRef<HTMLDivElement | null>(null);\r\n\r\n const imagesLoaded = useImageLoaded(elementRef);\r\n const hasReportedInitialHeight = useRef(false);\r\n const fullKey = [stateKey, ...itemPath].join('.');\r\n useRegisterComponent(stateKey, itemComponentId, forceUpdate);\r\n\r\n const setRefs = useCallback(\r\n (element: HTMLDivElement | null) => {\r\n elementRef.current = element;\r\n inViewRef(element); // This is the ref from useInView\r\n },\r\n [inViewRef]\r\n );\r\n\r\n useEffect(() => {\r\n const unsubscribe = subscribeToPath(fullKey, (e) => {\r\n forceUpdate({});\r\n });\r\n return () => unsubscribe();\r\n }, [fullKey]);\r\n useEffect(() => {\r\n if (!inView || !imagesLoaded || hasReportedInitialHeight.current) {\r\n return;\r\n }\r\n\r\n const element = elementRef.current;\r\n if (element && element.offsetHeight > 0) {\r\n hasReportedInitialHeight.current = true;\r\n const newHeight = element.offsetHeight;\r\n\r\n setShadowMetadata(stateKey, itemPath, {\r\n virtualizer: {\r\n itemHeight: newHeight,\r\n domRef: element,\r\n },\r\n });\r\n\r\n const arrayPath = itemPath.slice(0, -1);\r\n const arrayPathKey = [stateKey, ...arrayPath].join('.');\r\n notifyPathSubscribers(arrayPathKey, {\r\n type: 'ITEMHEIGHT',\r\n itemKey: itemPath.join('.'),\r\n\r\n ref: elementRef.current,\r\n });\r\n }\r\n }, [inView, imagesLoaded, stateKey, itemPath]);\r\n\r\n const itemValue = getShadowValue(stateKey, itemPath);\r\n\r\n if (itemValue === undefined) {\r\n return null;\r\n }\r\n\r\n const itemSetter = rebuildStateShape({\r\n currentState: itemValue,\r\n path: itemPath,\r\n componentId: itemComponentId,\r\n });\r\n const children = renderFn(itemSetter, localIndex, arraySetter);\r\n\r\n return <div ref={setRefs}>{children}</div>;\r\n}\r\n\r\nexport function FormElementWrapper({\r\n stateKey,\r\n path,\r\n rebuildStateShape,\r\n renderFn,\r\n formOpts,\r\n setState,\r\n}: {\r\n stateKey: string;\r\n path: string[];\r\n rebuildStateShape: (options: {\r\n path: string[];\r\n componentId: string;\r\n meta?: any;\r\n }) => any;\r\n renderFn: (params: FormElementParams<any>) => React.ReactNode;\r\n formOpts?: FormOptsType;\r\n setState: any;\r\n}) {\r\n const componentId = useRef(uuidv4()).current;\r\n\r\n const [, forceUpdate] = useState({});\r\n const formElementRef = useRef<any>(null);\r\n const stateKeyPathKey = [stateKey, ...path].join('.');\r\n useRegisterComponent(stateKey, componentId, forceUpdate);\r\n // Get the shadow node to access typeInfo and schema\r\n const shadowNode = getGlobalStore.getState().getShadowNode(stateKey, path);\r\n const typeInfo = shadowNode?._meta?.typeInfo;\r\n\r\n const globalStateValue = getShadowValue(stateKey, path);\r\n const [localValue, setLocalValue] = useState<any>(globalStateValue);\r\n const isCurrentlyDebouncing = useRef(false);\r\n const debounceTimeoutRef = useRef<NodeJS.Timeout | null>(null);\r\n\r\n // 2. Memoize the list of active form wrappers to avoid re-calculating on every render.\r\n const activeFormWrappers = useMemo(() => {\r\n return (\r\n pluginStore\r\n .getState()\r\n .getPluginConfigsForState(stateKey)\r\n // We only care about plugins that have defined a formWrapper\r\n .filter((config) => typeof config.plugin.formWrapper === 'function')\r\n );\r\n }, [stateKey]);\r\n\r\n useEffect(() => {\r\n if (\r\n !isCurrentlyDebouncing.current &&\r\n !isDeepEqual(globalStateValue, localValue)\r\n ) {\r\n setLocalValue(globalStateValue);\r\n }\r\n }, [globalStateValue]);\r\n\r\n useEffect(() => {\r\n const { getShadowMetadata, setShadowMetadata } = getGlobalStore.getState();\r\n\r\n // Initialize clientActivityState if needed\r\n const currentMeta = getShadowMetadata(stateKey, path) || {};\r\n if (!currentMeta.clientActivityState) {\r\n currentMeta.clientActivityState = { elements: new Map() };\r\n }\r\n\r\n // Detect element type from the ref\r\n const detectElementType = () => {\r\n const el = formElementRef.current;\r\n if (!el) return 'input';\r\n const tagName = el.tagName.toLowerCase();\r\n if (tagName === 'textarea') return 'textarea';\r\n if (tagName === 'select') return 'select';\r\n if (tagName === 'input') {\r\n const type = (el as HTMLInputElement).type;\r\n if (type === 'checkbox') return 'checkbox';\r\n if (type === 'radio') return 'radio';\r\n if (type === 'range') return 'range';\r\n if (type === 'file') return 'file';\r\n }\r\n return 'input';\r\n };\r\n\r\n // Add this element to the Map\r\n currentMeta.clientActivityState.elements.set(componentId, {\r\n domRef: formElementRef,\r\n elementType: detectElementType(),\r\n inputType: formElementRef.current?.type,\r\n mountedAt: Date.now(),\r\n });\r\n\r\n setShadowMetadata(stateKey, path, currentMeta);\r\n\r\n // Subscribe to path updates\r\n const unsubscribe = getGlobalStore\r\n .getState()\r\n .subscribeToPath(stateKeyPathKey, (newValue) => {\r\n if (!isCurrentlyDebouncing.current && localValue !== newValue) {\r\n forceUpdate({});\r\n }\r\n });\r\n\r\n // Cleanup\r\n return () => {\r\n unsubscribe();\r\n\r\n if (debounceTimeoutRef.current) {\r\n clearTimeout(debounceTimeoutRef.current);\r\n isCurrentlyDebouncing.current = false;\r\n }\r\n\r\n // Remove element from Map\r\n const meta = getGlobalStore.getState().getShadowMetadata(stateKey, path);\r\n if (meta?.clientActivityState?.elements) {\r\n meta.clientActivityState.elements.delete(componentId);\r\n setShadowMetadata(stateKey, path, meta);\r\n }\r\n };\r\n }, []);\r\n\r\n const debouncedUpdate = useCallback(\r\n (newValue: any) => {\r\n // Type conversion logic (keep existing)\r\n if (typeInfo) {\r\n if (typeInfo.type === 'number' && typeof newValue === 'string') {\r\n newValue =\r\n newValue === ''\r\n ? typeInfo.nullable\r\n ? null\r\n : (typeInfo.default ?? 0)\r\n : Number(newValue);\r\n } else if (\r\n typeInfo.type === 'boolean' &&\r\n typeof newValue === 'string'\r\n ) {\r\n newValue = newValue === 'true' || newValue === '1';\r\n } else if (typeInfo.type === 'date' && typeof newValue === 'string') {\r\n newValue = new Date(newValue);\r\n }\r\n } else {\r\n const currentType = typeof globalStateValue;\r\n if (currentType === 'number' && typeof newValue === 'string') {\r\n newValue = newValue === '' ? 0 : Number(newValue);\r\n }\r\n }\r\n\r\n setLocalValue(newValue);\r\n\r\n // Update input activity details\r\n const { getShadowMetadata, setShadowMetadata } =\r\n getGlobalStore.getState();\r\n const meta = getShadowMetadata(stateKey, path);\r\n if (meta?.clientActivityState?.elements?.has(componentId)) {\r\n const element = meta.clientActivityState.elements.get(componentId);\r\n if (element && element.currentActivity?.type === 'focus') {\r\n element!.currentActivity.details = {\r\n ...element!.currentActivity.details,\r\n value: newValue,\r\n previousValue:\r\n element!.currentActivity.details?.value || globalStateValue,\r\n inputLength:\r\n typeof newValue === 'string' ? newValue.length : undefined,\r\n keystrokeCount:\r\n (element!.currentActivity.details?.keystrokeCount || 0) + 1,\r\n };\r\n setShadowMetadata(stateKey, path, meta);\r\n }\r\n }\r\n const element = meta?.clientActivityState?.elements?.get(componentId);\r\n\r\n // Notify plugins\r\n notifyFormUpdate({\r\n stateKey,\r\n activityType: 'input', // Changed from 'type'\r\n path,\r\n timestamp: Date.now(),\r\n details: {\r\n value: newValue,\r\n inputLength:\r\n typeof newValue === 'string' ? newValue.length : undefined,\r\n isComposing: false, // You'd need to track this from the actual input event\r\n isPasting: false, // You'd need to track this from paste events\r\n keystrokeCount:\r\n (element?.currentActivity?.details?.keystrokeCount || 0) + 1,\r\n },\r\n });\r\n // Validation (keep existing)\r\n const virtualOperation: UpdateTypeDetail = {\r\n stateKey,\r\n path,\r\n newValue: newValue,\r\n updateType: 'update',\r\n timeStamp: Date.now(),\r\n status: 'new',\r\n oldValue: globalStateValue,\r\n };\r\n runValidation(virtualOperation, 'onChange');\r\n\r\n // Debounce state update (keep existing)\r\n isCurrentlyDebouncing.current = true;\r\n if (debounceTimeoutRef.current) {\r\n clearTimeout(debounceTimeoutRef.current);\r\n }\r\n\r\n const debounceTime = formOpts?.debounceTime ?? 200;\r\n debounceTimeoutRef.current = setTimeout(() => {\r\n isCurrentlyDebouncing.current = false;\r\n setState(newValue, path, {\r\n updateType: 'update',\r\n validationTrigger: 'onChange',\r\n });\r\n }, debounceTime);\r\n },\r\n [\r\n setState,\r\n path,\r\n formOpts?.debounceTime,\r\n typeInfo,\r\n globalStateValue,\r\n stateKey,\r\n componentId,\r\n ]\r\n );\r\n\r\n const handleFocus = useCallback(() => {\r\n const { getShadowMetadata, setShadowMetadata } = getGlobalStore.getState();\r\n\r\n // Update element's current activity\r\n const meta = getShadowMetadata(stateKey, path);\r\n if (meta?.clientActivityState?.elements?.has(componentId)) {\r\n const element = meta.clientActivityState.elements.get(componentId)!;\r\n element.currentActivity = {\r\n type: 'focus',\r\n startTime: Date.now(),\r\n details: {\r\n value: localValue,\r\n inputLength:\r\n typeof localValue === 'string' ? localValue.length : undefined,\r\n },\r\n };\r\n setShadowMetadata(stateKey, path, meta);\r\n }\r\n\r\n // Notify plugins\r\n notifyFormUpdate({\r\n stateKey,\r\n activityType: 'focus', // Changed from 'type'\r\n path,\r\n timestamp: Date.now(),\r\n details: {\r\n cursorPosition: formElementRef.current?.selectionStart,\r\n },\r\n });\r\n }, [stateKey, path, componentId, localValue]);\r\n const handleBlur = useCallback(() => {\r\n const { getShadowMetadata, setShadowMetadata } = getGlobalStore.getState();\r\n\r\n // Clear debounce if active\r\n if (debounceTimeoutRef.current) {\r\n clearTimeout(debounceTimeoutRef.current);\r\n debounceTimeoutRef.current = null;\r\n isCurrentlyDebouncing.current = false;\r\n setState(localValue, path, {\r\n updateType: 'update',\r\n validationTrigger: 'onBlur',\r\n });\r\n }\r\n\r\n // Clear element's current activity\r\n const meta = getShadowMetadata(stateKey, path);\r\n if (meta?.clientActivityState?.elements?.has(componentId)) {\r\n const element = meta.clientActivityState.elements.get(componentId)!;\r\n element.currentActivity = undefined;\r\n setShadowMetadata(stateKey, path, meta);\r\n }\r\n const focusStartTime =\r\n meta?.clientActivityState?.elements?.get(componentId)?.currentActivity\r\n ?.startTime;\r\n\r\n // Notify plugins\r\n notifyFormUpdate({\r\n stateKey,\r\n activityType: 'blur', // Changed from 'type'\r\n path,\r\n timestamp: Date.now(),\r\n duration: focusStartTime ? Date.now() - focusStartTime : undefined,\r\n details: {\r\n duration: focusStartTime ? Date.now() - focusStartTime : 0,\r\n },\r\n });\r\n\r\n // Run validation if configured\r\n const validationOptions = getInitialOptions(stateKey)?.validation;\r\n if (validationOptions?.onBlur) {\r\n const virtualOperation: UpdateTypeDetail = {\r\n stateKey,\r\n path,\r\n newValue: localValue,\r\n updateType: 'update',\r\n timeStamp: Date.now(),\r\n status: 'new',\r\n oldValue: globalStateValue,\r\n };\r\n runValidation(virtualOperation, 'onBlur');\r\n }\r\n }, [localValue, setState, path, stateKey, componentId, globalStateValue]);\r\n\r\n const baseState = rebuildStateShape({\r\n path: path,\r\n componentId: componentId,\r\n meta: undefined,\r\n });\r\n\r\n const stateWithInputProps = new Proxy(baseState, {\r\n get(target, prop) {\r\n if (prop === '$inputProps') {\r\n return {\r\n value: localValue ?? '',\r\n onChange: (e: any) => {\r\n debouncedUpdate(e.target.value);\r\n },\r\n onFocus: handleFocus,\r\n onBlur: handleBlur,\r\n ref: formElementRef,\r\n };\r\n }\r\n\r\n return target[prop];\r\n },\r\n });\r\n\r\n const initialElement = renderFn(stateWithInputProps);\r\n\r\n const wrappedElement = activeFormWrappers.reduceRight(\r\n (currentElement, config, index) => (\r\n <PluginWrapper\r\n stateKey={stateKey}\r\n path={path}\r\n pluginName={config.plugin.name}\r\n wrapperDepth={activeFormWrappers.length - 1 - index}\r\n >\r\n {currentElement}\r\n </PluginWrapper>\r\n ),\r\n initialElement\r\n );\r\n\r\n return (\r\n <ValidationWrapper formOpts={formOpts} path={path} stateKey={stateKey}>\r\n {wrappedElement}\r\n </ValidationWrapper>\r\n );\r\n}\r\nexport function useRegisterComponent(\r\n stateKey: string,\r\n componentId: string,\r\n forceUpdate: (o: object) => void\r\n) {\r\n const fullComponentId = `${stateKey}////${componentId}`;\r\n\r\n useLayoutEffect(() => {\r\n // Call the safe, centralized function to register\r\n registerComponent(stateKey, fullComponentId, {\r\n forceUpdate: () => forceUpdate({}),\r\n paths: new Set(),\r\n reactiveType: ['component'],\r\n });\r\n\r\n // The cleanup now calls the safe, centralized unregister function\r\n return () => {\r\n unregisterComponent(stateKey, fullComponentId);\r\n };\r\n }, [stateKey, fullComponentId]); // Dependencies are stable and correct\r\n}\r\n\r\nconst useImageLoaded = (ref: RefObject<HTMLElement>): boolean => {\r\n const [loaded, setLoaded] = useState(false);\r\n\r\n useLayoutEffect(() => {\r\n if (!ref.current) {\r\n setLoaded(true);\r\n return;\r\n }\r\n\r\n const images = Array.from(ref.current.querySelectorAll('img'));\r\n\r\n // If there are no images, we are \"loaded\" immediately.\r\n if (images.length === 0) {\r\n setLoaded(true);\r\n return;\r\n }\r\n\r\n let loadedCount = 0;\r\n const handleImageLoad = () => {\r\n loadedCount++;\r\n if (loadedCount === images.length) {\r\n setLoaded(true);\r\n }\r\n };\r\n\r\n images.forEach((image) => {\r\n if (image.complete) {\r\n handleImageLoad();\r\n } else {\r\n image.addEventListener('load', handleImageLoad);\r\n image.addEventListener('error', handleImageLoad);\r\n }\r\n });\r\n\r\n return () => {\r\n images.forEach((image) => {\r\n image.removeEventListener('load', handleImageLoad);\r\n image.removeEventListener('error', handleImageLoad);\r\n });\r\n };\r\n }, [ref.current]);\r\n\r\n return loaded;\r\n};\r\n// Components.tsx\r\n\r\n// Generic isolated component wrapper\r\nexport function IsolatedComponentWrapper({\r\n stateKey,\r\n path,\r\n rebuildStateShape,\r\n renderFn,\r\n}: {\r\n stateKey: string;\r\n path: string[];\r\n rebuildStateShape: (options: {\r\n path: string[];\r\n componentId: string;\r\n meta?: any;\r\n }) => any;\r\n renderFn: (state: any) => React.ReactNode;\r\n}) {\r\n const [componentId] = useState(() => uuidv4());\r\n const [, forceUpdate] = useState({});\r\n\r\n const stateKeyPathKey = [stateKey, ...path].join('.');\r\n useRegisterComponent(stateKey, componentId, forceUpdate);\r\n\r\n useEffect(() => {\r\n const unsubscribe = getGlobalStore\r\n .getState()\r\n .subscribeToPath(stateKeyPathKey, () => {\r\n forceUpdate({});\r\n });\r\n return () => unsubscribe();\r\n }, [stateKeyPathKey]);\r\n\r\n const baseState = rebuildStateShape({\r\n path: path,\r\n componentId: componentId,\r\n meta: undefined,\r\n });\r\n\r\n return <>{renderFn(baseState)}</>;\r\n}\r\n\r\n// 1. Define the MINIMAL props needed.\r\ntype PluginWrapperProps = {\r\n children: React.ReactNode;\r\n stateKey: string;\r\n path: string[];\r\n pluginName: string;\r\n wrapperDepth: number;\r\n};\r\n\r\nconst PluginWrapper = memo(function PluginWrapper({\r\n children,\r\n stateKey,\r\n path,\r\n pluginName,\r\n wrapperDepth,\r\n}: PluginWrapperProps) {\r\n const [, forceUpdate] = useState({});\r\n\r\n useEffect(() => {\r\n const fullPathKey = [stateKey, ...path].join('.');\r\n const unsubscribe = getGlobalStore\r\n .getState()\r\n .subscribeToPath(fullPathKey, () => {\r\n forceUpdate({});\r\n });\r\n return unsubscribe;\r\n }, [stateKey, path]);\r\n\r\n const plugin = pluginStore\r\n .getState()\r\n .registeredPlugins.find((p) => p.name === pluginName);\r\n\r\n const stateHandler: StateObject<any> | undefined = pluginStore\r\n .getState()\r\n .stateHandlers.get(stateKey);\r\n\r\n const typeInfo = getGlobalStore.getState().getShadowNode(stateKey, path)\r\n ?._meta?.typeInfo;\r\n\r\n const options = pluginStore\r\n .getState()\r\n .pluginOptions.get(stateKey)\r\n ?.get(pluginName);\r\n\r\n const hookData = pluginStore.getState().getHookResult(stateKey, pluginName);\r\n\r\n if (!plugin?.formWrapper || !stateHandler) {\r\n return <>{children}</>;\r\n }\r\n\r\n const metadataContext = createMetadataContext(stateKey, plugin.name);\r\n const deconstructed = toDeconstructedMethods(stateHandler);\r\n\r\n return plugin.formWrapper({\r\n element: children,\r\n path,\r\n stateKey,\r\n pluginName: plugin.name,\r\n ...deconstructed,\r\n ...metadataContext,\r\n options,\r\n hookData,\r\n fieldType: typeInfo?.type,\r\n wrapperDepth,\r\n });\r\n});\r\n"],"names":["getInitialOptions","getShadowMetadata","setShadowMetadata","getShadowValue","registerComponent","unregisterComponent","notifyPathSubscribers","subscribeToPath","getGlobalStore","stateHandlers","notifyFormUpdate","pluginStore","ValidationWrapper","formOpts","path","stateKey","children","thisStateOpts","validationState","status","errors","err","errorMessages","warningMessages","message","primarySeverity","jsx","Fragment","React","MemoizedCogsItemWrapper","memo","ListItemWrapper","prevProps","nextProps","itemComponentId","itemPath","localIndex","arraySetter","rebuildStateShape","renderFn","forceUpdate","useState","inViewRef","inView","useInView","elementRef","useRef","imagesLoaded","useImageLoaded","hasReportedInitialHeight","fullKey","useRegisterComponent","setRefs","useCallback","element","useEffect","unsubscribe","e","newHeight","arrayPath","arrayPathKey","itemValue","itemSetter","FormElementWrapper","setState","componentId","uuidv4","formElementRef","stateKeyPathKey","typeInfo","globalStateValue","localValue","setLocalValue","isCurrentlyDebouncing","debounceTimeoutRef","activeFormWrappers","useMemo","config","isDeepEqual","currentMeta","detectElementType","el","tagName","type","newValue","meta","debouncedUpdate","runValidation","debounceTime","handleFocus","handleBlur","focusStartTime","baseState","stateWithInputProps","target","prop","initialElement","wrappedElement","currentElement","index","PluginWrapper","fullComponentId","useLayoutEffect","ref","loaded","setLoaded","images","loadedCount","handleImageLoad","image","IsolatedComponentWrapper","pluginName","wrapperDepth","fullPathKey","plugin","p","stateHandler","options","hookData","metadataContext","createMetadataContext","deconstructed","toDeconstructedMethods"],"mappings":";;;;;;;;;AAwBA,MAAM;AAAA,EACJ,mBAAAA;AAAA,EAEA,mBAAAC;AAAA,EACA,mBAAAC;AAAA,EACA,gBAAAC;AAAA,EAEA,mBAAAC;AAAA,EACA,qBAAAC;AAAA,EAEA,uBAAAC;AAAA,EACA,iBAAAC;AACF,IAAIC,EAAe,SAAA,GACb,EAAE,eAAAC,IAAe,kBAAAC,MAAqBC,EAAY,SAAA;AASjD,SAASC,GAAkB;AAAA,EAChC,UAAAC;AAAA,EACA,MAAAC;AAAA,EACA,UAAAC;AAAA,EACA,UAAAC;AACF,GAA2B;AACzB,QAAM,EAAE,mBAAAhB,GAAmB,mBAAAC,GAAmB,gBAAAE,EAAAA,IAC5CK,EAAe,SAAA,GACXS,IAAgBjB,EAAkBe,CAAS,GAG3CG,IADajB,EAAkBc,GAAWD,CAAI,GAChB,YAE9BK,IAASD,GAAiB,UAAU,iBAEpCE,KAAUF,GAAiB,UAAU,CAAA,GAAI,IAAI,CAACG,OAAS;AAAA,IAC3D,GAAGA;AAAA,IACH,MAAAP;AAAA,EAAA,EACA,GACIQ,IAAgBF,EACnB,OAAO,CAACC,MAAQA,EAAI,aAAa,OAAO,EACxC,IAAI,CAACA,MAAQA,EAAI,OAAO,GACrBE,IAAkBH,EACrB,OAAO,CAACC,MAAQA,EAAI,aAAa,SAAS,EAC1C,IAAI,CAACA,MAAQA,EAAI,OAAO,GAGrBG,IAAUF,EAAc,CAAC,KAAKC,EAAgB,CAAC,GAC/CE,IACJH,EAAc,SAAS,IACnB,UACAC,EAAgB,SAAS,IACvB,YACA;AACR,SACE,gBAAAG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AAd;AAAA,EACA,UAAAD;AAAA,EACA,MAAAD;AAAA,EACA,YAAAiG;AAAA,EACA,cAAAC;AACF,GAAuB;AACrB,QAAM,GAAGxE,CAAW,IAAIC,EAAS,EAAE;AAEnC,EAAAc,EAAU,MAAM;AACd,UAAM0D,IAAc,CAAClG,GAAU,GAAGD,CAAI,EAAE,KAAK,GAAG;AAMhD,WALoBN,EACjB,SAAA,EACA,gBAAgByG,GAAa,MAAM;AAClC,MAAAzE,EAAY,CAAA,CAAE;AAAA,IAChB,CAAC;AAAA,EAEL,GAAG,CAACzB,GAAUD,CAAI,CAAC;AAEnB,QAAMoG,IAASvG,EACZ,SAAA,EACA,kBAAkB,KAAK,CAACwG,MAAMA,EAAE,SAASJ,CAAU,GAEhDK,IAA6CzG,EAChD,SAAA,EACA,cAAc,IAAII,CAAQ,GAEvBsD,IAAW7D,EAAe,SAAA,EAAW,cAAcO,GAAUD,CAAI,GACnE,OAAO,UAELuG,IAAU1G,EACb,WACA,cAAc,IAAII,CAAQ,GACzB,IAAIgG,CAAU,GAEZO,IAAW3G,EAAY,SAAA,EAAW,cAAcI,GAAUgG,CAAU;AAE1E,MAAI,CAACG,GAAQ,eAAe,CAACE;AAC3B,kCAAU,UAAApG,GAAS;AAGrB,QAAMuG,IAAkBC,EAAsBzG,GAAUmG,EAAO,IAAI,GAC7DO,IAAgBC,EAAuBN,CAAY;AAEzD,SAAOF,EAAO,YAAY;AAAA,IACxB,SAASlG;AAAA,IACT,MAAAF;AAAA,IACA,UAAAC;AAAA,IACA,YAAYmG,EAAO;AAAA,IACnB,GAAGO;AAAA,IACH,GAAGF;AAAA,IACH,SAAAF;AAAA,IACA,UAAAC;AAAA,IACA,WAAWjD,GAAU;AAAA,IACrB,cAAA2C;AAAA,EAAA,CACD;AACH,CAAC;"}
|
|
1
|
+
{"version":3,"file":"Components.jsx","sources":["../src/Components.tsx"],"sourcesContent":["import {\r\n FormElementParams,\r\n StateObject,\r\n UpdateTypeDetail,\r\n type FormOptsType,\r\n} from './CogsState';\r\nimport { pluginStore } from './pluginStore';\r\nimport {\r\n createMetadataContext,\r\n createScopedMetadataContext,\r\n toDeconstructedMethods,\r\n} from './plugins';\r\nimport React, {\r\n memo,\r\n RefObject,\r\n useCallback,\r\n useEffect,\r\n useLayoutEffect,\r\n useRef,\r\n useState,\r\n useMemo,\r\n} from 'react';\r\nimport { getGlobalStore, ValidationError, ValidationSeverity } from './store';\r\nimport { useInView } from 'react-intersection-observer';\r\nimport { v4 as uuidv4 } from 'uuid';\r\nimport { isDeepEqual } from './utility';\r\nimport { runValidation } from './validation';\r\n\r\nconst {\r\n getInitialOptions,\r\n\r\n getShadowMetadata,\r\n setShadowMetadata,\r\n getShadowValue,\r\n\r\n registerComponent,\r\n unregisterComponent,\r\n\r\n notifyPathSubscribers,\r\n subscribeToPath,\r\n} = getGlobalStore.getState();\r\nconst { stateHandlers, notifyFormUpdate } = pluginStore.getState();\r\n\r\nexport type ValidationWrapperProps = {\r\n formOpts?: FormOptsType;\r\n path: string[];\r\n stateKey: string;\r\n children: React.ReactNode;\r\n};\r\n\r\nexport function ValidationWrapper({\r\n formOpts,\r\n path,\r\n stateKey,\r\n children,\r\n}: ValidationWrapperProps) {\r\n const { getInitialOptions, getShadowMetadata, getShadowValue } =\r\n getGlobalStore.getState();\r\n const thisStateOpts = getInitialOptions(stateKey!);\r\n\r\n const shadowMeta = getShadowMetadata(stateKey!, path);\r\n const validationState = shadowMeta?.validation;\r\n\r\n const status = validationState?.status || 'NOT_VALIDATED';\r\n\r\n const errors = (validationState?.errors || []).map((err) => ({\r\n ...err,\r\n path: path,\r\n })) as ValidationError[];\r\n const errorMessages = errors\r\n .filter((err) => err.severity === 'error')\r\n .map((err) => err.message);\r\n const warningMessages = errors\r\n .filter((err) => err.severity === 'warning')\r\n .map((err) => err.message);\r\n\r\n // Use first error, or first warning if no errors\r\n const message = errorMessages[0] || warningMessages[0];\r\n const primarySeverity: ValidationSeverity =\r\n errorMessages.length > 0\r\n ? 'error'\r\n : warningMessages.length > 0\r\n ? 'warning'\r\n : undefined;\r\n const { registeredPlugins } = pluginStore.getState();\r\n const pluginsApi: any = {};\r\n\r\n // We iterate over ALL registered plugins in the app.\r\n registeredPlugins.forEach((plugin) => {\r\n // A plugin is considered \"active\" for this state key if its name\r\n // exists as a key in the options (e.g., options.syncPlugin exists).\r\n if (thisStateOpts && thisStateOpts.hasOwnProperty(plugin.name)) {\r\n const pluginName = plugin.name;\r\n\r\n // Now we can safely build the API for this active plugin.\r\n const hookData = pluginStore\r\n .getState()\r\n .getHookResult(stateKey, pluginName);\r\n\r\n const scopedMetadata = createScopedMetadataContext(\r\n stateKey,\r\n pluginName,\r\n path\r\n );\r\n\r\n pluginsApi[pluginName] = {\r\n hookData,\r\n getFieldMetaData: scopedMetadata.getFieldMetaData,\r\n setFieldMetaData: scopedMetadata.setFieldMetaData,\r\n };\r\n }\r\n });\r\n return (\r\n <>\r\n {thisStateOpts?.formElements?.validation &&\r\n !formOpts?.validation?.disable ? (\r\n thisStateOpts.formElements!.validation!({\r\n children: (\r\n <React.Fragment key={path.toString()}>{children}</React.Fragment>\r\n ),\r\n status, // Now passes the new ValidationStatus type\r\n message: formOpts?.validation?.hideMessage\r\n ? ''\r\n : formOpts?.validation?.message || message || '',\r\n severity: primarySeverity,\r\n hasErrors: errorMessages.length > 0,\r\n hasWarnings: warningMessages.length > 0,\r\n allErrors: errors,\r\n path: path,\r\n getData: () => getShadowValue(stateKey!, path),\r\n plugins: pluginsApi,\r\n })\r\n ) : (\r\n <React.Fragment key={path.toString()}>{children}</React.Fragment>\r\n )}\r\n </>\r\n );\r\n}\r\nexport const MemoizedCogsItemWrapper = memo(\r\n ListItemWrapper,\r\n (prevProps, nextProps) => {\r\n // Re-render if any of these change:\r\n return (\r\n prevProps.itemPath.join('.') === nextProps.itemPath.join('.') &&\r\n prevProps.stateKey === nextProps.stateKey &&\r\n prevProps.itemComponentId === nextProps.itemComponentId &&\r\n prevProps.localIndex === nextProps.localIndex\r\n );\r\n }\r\n);\r\nexport function ListItemWrapper({\r\n stateKey,\r\n itemComponentId,\r\n itemPath,\r\n localIndex,\r\n arraySetter,\r\n rebuildStateShape,\r\n renderFn,\r\n}: {\r\n stateKey: string;\r\n itemComponentId: string;\r\n itemPath: string[];\r\n localIndex: number;\r\n arraySetter: any;\r\n\r\n rebuildStateShape: (options: {\r\n currentState: any;\r\n path: string[];\r\n componentId: string;\r\n meta?: any;\r\n }) => any;\r\n renderFn: (\r\n setter: any,\r\n index: number,\r\n\r\n arraySetter: any\r\n ) => React.ReactNode;\r\n}) {\r\n const [, forceUpdate] = useState({});\r\n const { ref: inViewRef, inView } = useInView();\r\n const elementRef = useRef<HTMLDivElement | null>(null);\r\n\r\n const imagesLoaded = useImageLoaded(elementRef);\r\n const hasReportedInitialHeight = useRef(false);\r\n const fullKey = [stateKey, ...itemPath].join('.');\r\n useRegisterComponent(stateKey, itemComponentId, forceUpdate);\r\n\r\n const setRefs = useCallback(\r\n (element: HTMLDivElement | null) => {\r\n elementRef.current = element;\r\n inViewRef(element); // This is the ref from useInView\r\n },\r\n [inViewRef]\r\n );\r\n\r\n useEffect(() => {\r\n const unsubscribe = subscribeToPath(fullKey, (e) => {\r\n forceUpdate({});\r\n });\r\n return () => unsubscribe();\r\n }, [fullKey]);\r\n useEffect(() => {\r\n if (!inView || !imagesLoaded || hasReportedInitialHeight.current) {\r\n return;\r\n }\r\n\r\n const element = elementRef.current;\r\n if (element && element.offsetHeight > 0) {\r\n hasReportedInitialHeight.current = true;\r\n const newHeight = element.offsetHeight;\r\n\r\n setShadowMetadata(stateKey, itemPath, {\r\n virtualizer: {\r\n itemHeight: newHeight,\r\n domRef: element,\r\n },\r\n });\r\n\r\n const arrayPath = itemPath.slice(0, -1);\r\n const arrayPathKey = [stateKey, ...arrayPath].join('.');\r\n notifyPathSubscribers(arrayPathKey, {\r\n type: 'ITEMHEIGHT',\r\n itemKey: itemPath.join('.'),\r\n\r\n ref: elementRef.current,\r\n });\r\n }\r\n }, [inView, imagesLoaded, stateKey, itemPath]);\r\n\r\n const itemValue = getShadowValue(stateKey, itemPath);\r\n\r\n if (itemValue === undefined) {\r\n return null;\r\n }\r\n\r\n const itemSetter = rebuildStateShape({\r\n currentState: itemValue,\r\n path: itemPath,\r\n componentId: itemComponentId,\r\n });\r\n const children = renderFn(itemSetter, localIndex, arraySetter);\r\n\r\n return <div ref={setRefs}>{children}</div>;\r\n}\r\n\r\nexport function FormElementWrapper({\r\n stateKey,\r\n path,\r\n rebuildStateShape,\r\n renderFn,\r\n formOpts,\r\n setState,\r\n}: {\r\n stateKey: string;\r\n path: string[];\r\n rebuildStateShape: (options: {\r\n path: string[];\r\n componentId: string;\r\n meta?: any;\r\n }) => any;\r\n renderFn: (params: FormElementParams<any>) => React.ReactNode;\r\n formOpts?: FormOptsType;\r\n setState: any;\r\n}) {\r\n const componentId = useRef(uuidv4()).current;\r\n\r\n const [, forceUpdate] = useState({});\r\n const formElementRef = useRef<any>(null);\r\n const stateKeyPathKey = [stateKey, ...path].join('.');\r\n useRegisterComponent(stateKey, componentId, forceUpdate);\r\n // Get the shadow node to access typeInfo and schema\r\n const shadowNode = getGlobalStore.getState().getShadowNode(stateKey, path);\r\n const typeInfo = shadowNode?._meta?.typeInfo;\r\n\r\n const globalStateValue = getShadowValue(stateKey, path);\r\n const [localValue, setLocalValue] = useState<any>(globalStateValue);\r\n const isCurrentlyDebouncing = useRef(false);\r\n const debounceTimeoutRef = useRef<NodeJS.Timeout | null>(null);\r\n\r\n useEffect(() => {\r\n if (\r\n !isCurrentlyDebouncing.current &&\r\n !isDeepEqual(globalStateValue, localValue)\r\n ) {\r\n setLocalValue(globalStateValue);\r\n }\r\n }, [globalStateValue]);\r\n\r\n useEffect(() => {\r\n const { getShadowMetadata, setShadowMetadata } = getGlobalStore.getState();\r\n\r\n // Initialize clientActivityState if needed\r\n const currentMeta = getShadowMetadata(stateKey, path) || {};\r\n if (!currentMeta.clientActivityState) {\r\n currentMeta.clientActivityState = { elements: new Map() };\r\n }\r\n\r\n // Detect element type from the ref\r\n const detectElementType = () => {\r\n const el = formElementRef.current;\r\n if (!el) return 'input';\r\n const tagName = el.tagName.toLowerCase();\r\n if (tagName === 'textarea') return 'textarea';\r\n if (tagName === 'select') return 'select';\r\n if (tagName === 'input') {\r\n const type = (el as HTMLInputElement).type;\r\n if (type === 'checkbox') return 'checkbox';\r\n if (type === 'radio') return 'radio';\r\n if (type === 'range') return 'range';\r\n if (type === 'file') return 'file';\r\n }\r\n return 'input';\r\n };\r\n\r\n // Add this element to the Map\r\n currentMeta.clientActivityState.elements.set(componentId, {\r\n domRef: formElementRef,\r\n elementType: detectElementType(),\r\n inputType: formElementRef.current?.type,\r\n mountedAt: Date.now(),\r\n });\r\n\r\n setShadowMetadata(stateKey, path, currentMeta);\r\n\r\n // Subscribe to path updates\r\n const unsubscribe = getGlobalStore\r\n .getState()\r\n .subscribeToPath(stateKeyPathKey, (newValue) => {\r\n if (!isCurrentlyDebouncing.current && localValue !== newValue) {\r\n forceUpdate({});\r\n }\r\n });\r\n\r\n // Cleanup\r\n return () => {\r\n unsubscribe();\r\n\r\n if (debounceTimeoutRef.current) {\r\n clearTimeout(debounceTimeoutRef.current);\r\n isCurrentlyDebouncing.current = false;\r\n }\r\n\r\n // Remove element from Map\r\n const meta = getGlobalStore.getState().getShadowMetadata(stateKey, path);\r\n if (meta?.clientActivityState?.elements) {\r\n meta.clientActivityState.elements.delete(componentId);\r\n setShadowMetadata(stateKey, path, meta);\r\n }\r\n };\r\n }, []);\r\n\r\n const debouncedUpdate = useCallback(\r\n (newValue: any) => {\r\n // Type conversion logic (keep existing)\r\n if (typeInfo) {\r\n if (typeInfo.type === 'number' && typeof newValue === 'string') {\r\n newValue =\r\n newValue === ''\r\n ? typeInfo.nullable\r\n ? null\r\n : (typeInfo.default ?? 0)\r\n : Number(newValue);\r\n } else if (\r\n typeInfo.type === 'boolean' &&\r\n typeof newValue === 'string'\r\n ) {\r\n newValue = newValue === 'true' || newValue === '1';\r\n } else if (typeInfo.type === 'date' && typeof newValue === 'string') {\r\n newValue = new Date(newValue);\r\n }\r\n } else {\r\n const currentType = typeof globalStateValue;\r\n if (currentType === 'number' && typeof newValue === 'string') {\r\n newValue = newValue === '' ? 0 : Number(newValue);\r\n }\r\n }\r\n\r\n setLocalValue(newValue);\r\n\r\n // Update input activity details\r\n const { getShadowMetadata, setShadowMetadata } =\r\n getGlobalStore.getState();\r\n const meta = getShadowMetadata(stateKey, path);\r\n if (meta?.clientActivityState?.elements?.has(componentId)) {\r\n const element = meta.clientActivityState.elements.get(componentId);\r\n if (element && element.currentActivity?.type === 'focus') {\r\n element!.currentActivity.details = {\r\n ...element!.currentActivity.details,\r\n value: newValue,\r\n previousValue:\r\n element!.currentActivity.details?.value || globalStateValue,\r\n inputLength:\r\n typeof newValue === 'string' ? newValue.length : undefined,\r\n keystrokeCount:\r\n (element!.currentActivity.details?.keystrokeCount || 0) + 1,\r\n };\r\n setShadowMetadata(stateKey, path, meta);\r\n }\r\n }\r\n const element = meta?.clientActivityState?.elements?.get(componentId);\r\n\r\n // Notify plugins\r\n notifyFormUpdate({\r\n stateKey,\r\n activityType: 'input', // Changed from 'type'\r\n path,\r\n timestamp: Date.now(),\r\n details: {\r\n value: newValue,\r\n inputLength:\r\n typeof newValue === 'string' ? newValue.length : undefined,\r\n isComposing: false, // You'd need to track this from the actual input event\r\n isPasting: false, // You'd need to track this from paste events\r\n keystrokeCount:\r\n (element?.currentActivity?.details?.keystrokeCount || 0) + 1,\r\n },\r\n });\r\n // Validation (keep existing)\r\n const virtualOperation: UpdateTypeDetail = {\r\n stateKey,\r\n path,\r\n newValue: newValue,\r\n updateType: 'update',\r\n timeStamp: Date.now(),\r\n status: 'new',\r\n oldValue: globalStateValue,\r\n };\r\n runValidation(virtualOperation, 'onChange');\r\n\r\n // Debounce state update (keep existing)\r\n isCurrentlyDebouncing.current = true;\r\n if (debounceTimeoutRef.current) {\r\n clearTimeout(debounceTimeoutRef.current);\r\n }\r\n\r\n const debounceTime = formOpts?.debounceTime ?? 200;\r\n debounceTimeoutRef.current = setTimeout(() => {\r\n isCurrentlyDebouncing.current = false;\r\n setState(newValue, path, {\r\n updateType: 'update',\r\n validationTrigger: 'onChange',\r\n });\r\n }, debounceTime);\r\n },\r\n [\r\n setState,\r\n path,\r\n formOpts?.debounceTime,\r\n typeInfo,\r\n globalStateValue,\r\n stateKey,\r\n componentId,\r\n ]\r\n );\r\n\r\n const handleFocus = useCallback(() => {\r\n const { getShadowMetadata, setShadowMetadata } = getGlobalStore.getState();\r\n\r\n // Update element's current activity\r\n const meta = getShadowMetadata(stateKey, path);\r\n if (meta?.clientActivityState?.elements?.has(componentId)) {\r\n const element = meta.clientActivityState.elements.get(componentId)!;\r\n element.currentActivity = {\r\n type: 'focus',\r\n startTime: Date.now(),\r\n details: {\r\n value: localValue,\r\n inputLength:\r\n typeof localValue === 'string' ? localValue.length : undefined,\r\n },\r\n };\r\n setShadowMetadata(stateKey, path, meta);\r\n }\r\n\r\n // Notify plugins\r\n notifyFormUpdate({\r\n stateKey,\r\n activityType: 'focus', // Changed from 'type'\r\n path,\r\n timestamp: Date.now(),\r\n details: {\r\n cursorPosition: formElementRef.current?.selectionStart,\r\n },\r\n });\r\n }, [stateKey, path, componentId, localValue]);\r\n const handleBlur = useCallback(() => {\r\n const { getShadowMetadata, setShadowMetadata } = getGlobalStore.getState();\r\n\r\n // Clear debounce if active\r\n if (debounceTimeoutRef.current) {\r\n clearTimeout(debounceTimeoutRef.current);\r\n debounceTimeoutRef.current = null;\r\n isCurrentlyDebouncing.current = false;\r\n setState(localValue, path, {\r\n updateType: 'update',\r\n validationTrigger: 'onBlur',\r\n });\r\n }\r\n\r\n // Clear element's current activity\r\n const meta = getShadowMetadata(stateKey, path);\r\n if (meta?.clientActivityState?.elements?.has(componentId)) {\r\n const element = meta.clientActivityState.elements.get(componentId)!;\r\n element.currentActivity = undefined;\r\n setShadowMetadata(stateKey, path, meta);\r\n }\r\n const focusStartTime =\r\n meta?.clientActivityState?.elements?.get(componentId)?.currentActivity\r\n ?.startTime;\r\n\r\n // Notify plugins\r\n notifyFormUpdate({\r\n stateKey,\r\n activityType: 'blur', // Changed from 'type'\r\n path,\r\n timestamp: Date.now(),\r\n duration: focusStartTime ? Date.now() - focusStartTime : undefined,\r\n details: {\r\n duration: focusStartTime ? Date.now() - focusStartTime : 0,\r\n },\r\n });\r\n\r\n // Run validation if configured\r\n const validationOptions = getInitialOptions(stateKey)?.validation;\r\n if (validationOptions?.onBlur) {\r\n const virtualOperation: UpdateTypeDetail = {\r\n stateKey,\r\n path,\r\n newValue: localValue,\r\n updateType: 'update',\r\n timeStamp: Date.now(),\r\n status: 'new',\r\n oldValue: globalStateValue,\r\n };\r\n runValidation(virtualOperation, 'onBlur');\r\n }\r\n }, [localValue, setState, path, stateKey, componentId, globalStateValue]);\r\n\r\n const baseState = rebuildStateShape({\r\n path: path,\r\n componentId: componentId,\r\n meta: undefined,\r\n });\r\n\r\n const stateWithInputProps = new Proxy(baseState, {\r\n get(target, prop) {\r\n if (prop === '$inputProps') {\r\n return {\r\n value: localValue ?? '',\r\n onChange: (e: any) => {\r\n debouncedUpdate(e.target.value);\r\n },\r\n onFocus: handleFocus,\r\n onBlur: handleBlur,\r\n ref: formElementRef,\r\n };\r\n }\r\n\r\n return target[prop];\r\n },\r\n });\r\n\r\n const initialElement = renderFn(stateWithInputProps);\r\n\r\n return (\r\n <ValidationWrapper formOpts={formOpts} path={path} stateKey={stateKey}>\r\n {initialElement}\r\n </ValidationWrapper>\r\n );\r\n}\r\nexport function useRegisterComponent(\r\n stateKey: string,\r\n componentId: string,\r\n forceUpdate: (o: object) => void\r\n) {\r\n const fullComponentId = `${stateKey}////${componentId}`;\r\n\r\n useLayoutEffect(() => {\r\n // Call the safe, centralized function to register\r\n registerComponent(stateKey, fullComponentId, {\r\n forceUpdate: () => forceUpdate({}),\r\n paths: new Set(),\r\n reactiveType: ['component'],\r\n });\r\n\r\n // The cleanup now calls the safe, centralized unregister function\r\n return () => {\r\n unregisterComponent(stateKey, fullComponentId);\r\n };\r\n }, [stateKey, fullComponentId]); // Dependencies are stable and correct\r\n}\r\n\r\nconst useImageLoaded = (ref: RefObject<HTMLElement>): boolean => {\r\n const [loaded, setLoaded] = useState(false);\r\n\r\n useLayoutEffect(() => {\r\n if (!ref.current) {\r\n setLoaded(true);\r\n return;\r\n }\r\n\r\n const images = Array.from(ref.current.querySelectorAll('img'));\r\n\r\n // If there are no images, we are \"loaded\" immediately.\r\n if (images.length === 0) {\r\n setLoaded(true);\r\n return;\r\n }\r\n\r\n let loadedCount = 0;\r\n const handleImageLoad = () => {\r\n loadedCount++;\r\n if (loadedCount === images.length) {\r\n setLoaded(true);\r\n }\r\n };\r\n\r\n images.forEach((image) => {\r\n if (image.complete) {\r\n handleImageLoad();\r\n } else {\r\n image.addEventListener('load', handleImageLoad);\r\n image.addEventListener('error', handleImageLoad);\r\n }\r\n });\r\n\r\n return () => {\r\n images.forEach((image) => {\r\n image.removeEventListener('load', handleImageLoad);\r\n image.removeEventListener('error', handleImageLoad);\r\n });\r\n };\r\n }, [ref.current]);\r\n\r\n return loaded;\r\n};\r\n// Components.tsx\r\n\r\n// Generic isolated component wrapper\r\nexport function IsolatedComponentWrapper({\r\n stateKey,\r\n path,\r\n rebuildStateShape,\r\n renderFn,\r\n}: {\r\n stateKey: string;\r\n path: string[];\r\n rebuildStateShape: (options: {\r\n path: string[];\r\n componentId: string;\r\n meta?: any;\r\n }) => any;\r\n renderFn: (state: any) => React.ReactNode;\r\n}) {\r\n const [componentId] = useState(() => uuidv4());\r\n const [, forceUpdate] = useState({});\r\n\r\n const stateKeyPathKey = [stateKey, ...path].join('.');\r\n useRegisterComponent(stateKey, componentId, forceUpdate);\r\n\r\n useEffect(() => {\r\n const unsubscribe = getGlobalStore\r\n .getState()\r\n .subscribeToPath(stateKeyPathKey, () => {\r\n forceUpdate({});\r\n });\r\n return () => unsubscribe();\r\n }, [stateKeyPathKey]);\r\n\r\n const baseState = rebuildStateShape({\r\n path: path,\r\n componentId: componentId,\r\n meta: undefined,\r\n });\r\n\r\n return <>{renderFn(baseState)}</>;\r\n}\r\n\r\n// 1. Define the MINIMAL props needed.\r\ntype PluginWrapperProps = {\r\n children: React.ReactNode;\r\n stateKey: string;\r\n path: string[];\r\n pluginName: string;\r\n wrapperDepth: number;\r\n};\r\n\r\nconst PluginWrapper = memo(function PluginWrapper({\r\n children,\r\n stateKey,\r\n path,\r\n pluginName,\r\n wrapperDepth,\r\n}: PluginWrapperProps) {\r\n const [, forceUpdate] = useState({});\r\n\r\n useEffect(() => {\r\n const fullPathKey = [stateKey, ...path].join('.');\r\n const unsubscribe = getGlobalStore\r\n .getState()\r\n .subscribeToPath(fullPathKey, () => {\r\n forceUpdate({});\r\n });\r\n return unsubscribe;\r\n }, [stateKey, path]);\r\n\r\n const plugin = pluginStore\r\n .getState()\r\n .registeredPlugins.find((p) => p.name === pluginName);\r\n\r\n const stateHandler: StateObject<any> | undefined = pluginStore\r\n .getState()\r\n .stateHandlers.get(stateKey);\r\n\r\n const typeInfo = getGlobalStore.getState().getShadowNode(stateKey, path)\r\n ?._meta?.typeInfo;\r\n\r\n const options = pluginStore\r\n .getState()\r\n .pluginOptions.get(stateKey)\r\n ?.get(pluginName);\r\n\r\n const hookData = pluginStore.getState().getHookResult(stateKey, pluginName);\r\n\r\n if (!plugin?.formWrapper || !stateHandler) {\r\n return <>{children}</>;\r\n }\r\n\r\n const deconstructed = toDeconstructedMethods(stateHandler);\r\n const scopedMetadataContext = createScopedMetadataContext(\r\n stateKey,\r\n plugin.name,\r\n path\r\n );\r\n return plugin.formWrapper({\r\n element: children,\r\n path,\r\n stateKey,\r\n pluginName: plugin.name,\r\n ...deconstructed,\r\n\r\n ...scopedMetadataContext,\r\n options,\r\n hookData,\r\n fieldType: typeInfo?.type,\r\n wrapperDepth,\r\n });\r\n});\r\n"],"names":["getInitialOptions","getShadowMetadata","setShadowMetadata","getShadowValue","registerComponent","unregisterComponent","notifyPathSubscribers","subscribeToPath","getGlobalStore","stateHandlers","notifyFormUpdate","pluginStore","ValidationWrapper","formOpts","path","stateKey","children","thisStateOpts","validationState","status","errors","err","errorMessages","warningMessages","message","primarySeverity","registeredPlugins","pluginsApi","plugin","pluginName","hookData","scopedMetadata","createScopedMetadataContext","jsx","Fragment","React","MemoizedCogsItemWrapper","memo","ListItemWrapper","prevProps","nextProps","itemComponentId","itemPath","localIndex","arraySetter","rebuildStateShape","renderFn","forceUpdate","useState","inViewRef","inView","useInView","elementRef","useRef","imagesLoaded","useImageLoaded","hasReportedInitialHeight","fullKey","useRegisterComponent","setRefs","useCallback","element","useEffect","unsubscribe","e","newHeight","arrayPath","arrayPathKey","itemValue","itemSetter","FormElementWrapper","setState","componentId","uuidv4","formElementRef","stateKeyPathKey","typeInfo","globalStateValue","localValue","setLocalValue","isCurrentlyDebouncing","debounceTimeoutRef","isDeepEqual","currentMeta","detectElementType","el","tagName","type","newValue","meta","debouncedUpdate","runValidation","debounceTime","handleFocus","handleBlur","focusStartTime","baseState","stateWithInputProps","target","prop","initialElement","fullComponentId","useLayoutEffect","ref","loaded","setLoaded","images","loadedCount","handleImageLoad","image","IsolatedComponentWrapper","wrapperDepth","fullPathKey","p","stateHandler","options","deconstructed","toDeconstructedMethods","scopedMetadataContext"],"mappings":";;;;;;;;;AA4BA,MAAM;AAAA,EACJ,mBAAAA;AAAA,EAEA,mBAAAC;AAAA,EACA,mBAAAC;AAAA,EACA,gBAAAC;AAAA,EAEA,mBAAAC;AAAA,EACA,qBAAAC;AAAA,EAEA,uBAAAC;AAAA,EACA,iBAAAC;AACF,IAAIC,EAAe,SAAA,GACb,EAAE,eAAAC,IAAe,kBAAAC,MAAqBC,EAAY,SAAA;AASjD,SAASC,GAAkB;AAAA,EAChC,UAAAC;AAAA,EACA,MAAAC;AAAA,EACA,UAAAC;AAAA,EACA,UAAAC;AACF,GAA2B;AACzB,QAAM,EAAE,mBAAAhB,GAAmB,mBAAAC,GAA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AAII,CAAQ,GACzB,IAAIc,CAAU,GAEZC,IAAWnB,EAAY,SAAA,EAAW,cAAcI,GAAUc,CAAU;AAE1E,MAAI,CAACD,GAAQ,eAAe,CAACsF;AAC3B,kCAAU,UAAAlG,GAAS;AAGrB,QAAMoG,IAAgBC,EAAuBH,CAAY,GACnDI,IAAwBtF;AAAA,IAC5BjB;AAAA,IACAa,EAAO;AAAA,IACPd;AAAA,EAAA;AAEF,SAAOc,EAAO,YAAY;AAAA,IACxB,SAASZ;AAAA,IACT,MAAAF;AAAA,IACA,UAAAC;AAAA,IACA,YAAYa,EAAO;AAAA,IACnB,GAAGwF;AAAA,IAEH,GAAGE;AAAA,IACH,SAAAH;AAAA,IACA,UAAArF;AAAA,IACA,WAAW8C,GAAU;AAAA,IACrB,cAAAmC;AAAA,EAAA,CACD;AACH,CAAC;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PluginRunner.d.ts","sourceRoot":"","sources":["../src/PluginRunner.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA2D,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"PluginRunner.d.ts","sourceRoot":"","sources":["../src/PluginRunner.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA2D,MAAM,OAAO,CAAC;AAuKhF;;;GAGG;AACH,wBAAgB,YAAY,CAAC,EAAE,QAAQ,EAAE,EAAE;IAAE,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;CAAE,2CAiDvE"}
|
package/dist/PluginRunner.jsx
CHANGED
|
@@ -1,115 +1,130 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import
|
|
1
|
+
import { jsxs as F, Fragment as C, jsx as P } from "react/jsx-runtime";
|
|
2
|
+
import T, { useState as R, useMemo as M, useEffect as m, useRef as x, useReducer as N } from "react";
|
|
3
3
|
import { pluginStore as f } from "./pluginStore.js";
|
|
4
|
-
import { isDeepEqual as
|
|
5
|
-
import { createMetadataContext as
|
|
6
|
-
const { setHookResult:
|
|
4
|
+
import { isDeepEqual as j } from "./utility.js";
|
|
5
|
+
import { createMetadataContext as A, toDeconstructedMethods as E, createScopedMetadataContext as H } from "./plugins.js";
|
|
6
|
+
const { setHookResult: O, removeHookResult: I } = f.getState(), $ = T.memo(
|
|
7
7
|
({
|
|
8
8
|
stateKey: r,
|
|
9
9
|
plugin: e,
|
|
10
10
|
options: t,
|
|
11
11
|
stateHandler: d
|
|
12
12
|
}) => {
|
|
13
|
-
const [
|
|
14
|
-
() =>
|
|
13
|
+
const [b, a] = R(!0), c = M(
|
|
14
|
+
() => A(r, e.name),
|
|
15
15
|
[r, e.name]
|
|
16
|
-
), o =
|
|
17
|
-
() =>
|
|
16
|
+
), o = M(
|
|
17
|
+
() => E(d),
|
|
18
18
|
[d]
|
|
19
|
-
),
|
|
19
|
+
), i = M(
|
|
20
20
|
() => ({
|
|
21
21
|
stateKey: r,
|
|
22
22
|
pluginName: e.name,
|
|
23
|
-
isInitialMount:
|
|
23
|
+
isInitialMount: b,
|
|
24
24
|
options: t,
|
|
25
25
|
...o,
|
|
26
|
-
...
|
|
26
|
+
...c
|
|
27
27
|
}),
|
|
28
28
|
[
|
|
29
29
|
r,
|
|
30
30
|
e.name,
|
|
31
|
-
|
|
31
|
+
b,
|
|
32
32
|
t,
|
|
33
33
|
o,
|
|
34
|
-
|
|
34
|
+
c
|
|
35
35
|
]
|
|
36
|
-
),
|
|
36
|
+
), s = e.useHook ? e.useHook(i) : void 0;
|
|
37
37
|
m(() => {
|
|
38
|
-
|
|
39
|
-
}, []), m(() => (e.useHook ?
|
|
40
|
-
const u =
|
|
38
|
+
a(!1);
|
|
39
|
+
}, []), m(() => (e.useHook ? O(r, e.name, s) : I(r, e.name), () => I(r, e.name)), [r, e.name, !!e.useHook, s]);
|
|
40
|
+
const u = x(), [h, D] = R(!0);
|
|
41
41
|
m(() => {
|
|
42
|
-
e.transformState && (
|
|
42
|
+
e.transformState && (j(t, u.current) || (e.transformState({
|
|
43
43
|
stateKey: r,
|
|
44
44
|
pluginName: e.name,
|
|
45
45
|
options: t,
|
|
46
|
-
hookData:
|
|
46
|
+
hookData: s,
|
|
47
47
|
isInitialTransform: h,
|
|
48
48
|
...o,
|
|
49
|
-
...
|
|
50
|
-
}), u.current = t,
|
|
49
|
+
...c
|
|
50
|
+
}), u.current = t, D(!1)));
|
|
51
51
|
}, [
|
|
52
52
|
r,
|
|
53
53
|
e,
|
|
54
54
|
t,
|
|
55
|
-
|
|
55
|
+
s,
|
|
56
56
|
h,
|
|
57
57
|
o,
|
|
58
|
-
|
|
58
|
+
c
|
|
59
59
|
]);
|
|
60
|
-
const k =
|
|
61
|
-
return k.current =
|
|
60
|
+
const k = x(s);
|
|
61
|
+
return k.current = s, m(() => {
|
|
62
62
|
if (!e.onUpdate) return;
|
|
63
|
-
const
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
63
|
+
const S = (n) => {
|
|
64
|
+
if (n.stateKey === r) {
|
|
65
|
+
const U = H(
|
|
66
|
+
r,
|
|
67
|
+
e.name,
|
|
68
|
+
n.path
|
|
69
|
+
);
|
|
70
|
+
e.onUpdate({
|
|
71
|
+
stateKey: r,
|
|
72
|
+
pluginName: e.name,
|
|
73
|
+
update: n,
|
|
74
|
+
path: n.path,
|
|
75
|
+
options: t,
|
|
76
|
+
hookData: k.current,
|
|
77
|
+
...o,
|
|
78
|
+
...U
|
|
79
|
+
// <-- Use the new scoped context
|
|
80
|
+
});
|
|
81
|
+
}
|
|
74
82
|
};
|
|
75
|
-
return f.getState().subscribeToUpdates(
|
|
76
|
-
}, [r, e, t, o
|
|
83
|
+
return f.getState().subscribeToUpdates(S);
|
|
84
|
+
}, [r, e, t, o]), m(() => {
|
|
77
85
|
if (!e.onFormUpdate) return;
|
|
78
|
-
const
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
86
|
+
const S = (n) => {
|
|
87
|
+
if (n.stateKey === r) {
|
|
88
|
+
const U = H(
|
|
89
|
+
r,
|
|
90
|
+
e.name,
|
|
91
|
+
n.path
|
|
92
|
+
);
|
|
93
|
+
e.onFormUpdate({
|
|
94
|
+
stateKey: r,
|
|
95
|
+
pluginName: e.name,
|
|
96
|
+
path: n.path,
|
|
97
|
+
event: n,
|
|
98
|
+
options: t,
|
|
99
|
+
hookData: k.current,
|
|
100
|
+
...o,
|
|
101
|
+
...U
|
|
102
|
+
// <-- Use the new scoped context
|
|
103
|
+
});
|
|
104
|
+
}
|
|
90
105
|
};
|
|
91
|
-
return f.getState().subscribeToFormUpdates(
|
|
92
|
-
}, [r, e, t, o
|
|
106
|
+
return f.getState().subscribeToFormUpdates(S);
|
|
107
|
+
}, [r, e, t, o]), null;
|
|
93
108
|
}
|
|
94
109
|
);
|
|
95
|
-
function
|
|
96
|
-
const [, e] =
|
|
110
|
+
function J({ children: r }) {
|
|
111
|
+
const [, e] = N((a) => a + 1, 0);
|
|
97
112
|
m(() => f.subscribe(e), []);
|
|
98
|
-
const { pluginOptions: t, stateHandlers: d, registeredPlugins:
|
|
99
|
-
return /* @__PURE__ */
|
|
100
|
-
Array.from(t.entries()).map(([
|
|
101
|
-
const o = d.get(
|
|
102
|
-
return o ? Array.from(
|
|
103
|
-
const u =
|
|
104
|
-
return u ? /* @__PURE__ */
|
|
105
|
-
|
|
113
|
+
const { pluginOptions: t, stateHandlers: d, registeredPlugins: b } = f.getState();
|
|
114
|
+
return /* @__PURE__ */ F(C, { children: [
|
|
115
|
+
Array.from(t.entries()).map(([a, c]) => {
|
|
116
|
+
const o = d.get(a);
|
|
117
|
+
return o ? Array.from(c.entries()).map(([i, s]) => {
|
|
118
|
+
const u = b.find((h) => h.name === i);
|
|
119
|
+
return u ? /* @__PURE__ */ P(
|
|
120
|
+
$,
|
|
106
121
|
{
|
|
107
|
-
stateKey:
|
|
122
|
+
stateKey: a,
|
|
108
123
|
plugin: u,
|
|
109
|
-
options:
|
|
124
|
+
options: s,
|
|
110
125
|
stateHandler: o
|
|
111
126
|
},
|
|
112
|
-
`${
|
|
127
|
+
`${a}:${i}`
|
|
113
128
|
) : null;
|
|
114
129
|
}) : null;
|
|
115
130
|
}),
|
|
@@ -117,6 +132,6 @@ function z({ children: r }) {
|
|
|
117
132
|
] });
|
|
118
133
|
}
|
|
119
134
|
export {
|
|
120
|
-
|
|
135
|
+
J as PluginRunner
|
|
121
136
|
};
|
|
122
137
|
//# sourceMappingURL=PluginRunner.jsx.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PluginRunner.jsx","sources":["../src/PluginRunner.tsx"],"sourcesContent":["import React, { useEffect, useMemo, useState, useRef, useReducer } from 'react';\r\nimport { ClientActivityEvent, pluginStore } from './pluginStore';\r\nimport { isDeepEqual } from './utility';\r\nimport { createMetadataContext, toDeconstructedMethods } from './plugins';\r\nimport type { CogsPlugin } from './plugins';\r\nimport type { StateObject, UpdateTypeDetail } from './CogsState';\r\nimport { ClientActivityState, FormEventType } from './store';\r\n\r\nconst { setHookResult, removeHookResult } = pluginStore.getState();\r\n\r\nconst PluginInstance = React.memo(\r\n ({\r\n stateKey,\r\n plugin,\r\n options,\r\n stateHandler,\r\n }: {\r\n stateKey: string;\r\n plugin: CogsPlugin<any, any, any, any, any>;\r\n options: any;\r\n stateHandler: StateObject<any>;\r\n }) => {\r\n const [isInitialMount, setIsInitialMount] = useState(true);\r\n const metadataContext = useMemo(\r\n () => createMetadataContext(stateKey, plugin.name),\r\n [stateKey, plugin.name]\r\n );\r\n\r\n const deconstructed = useMemo(\r\n () => toDeconstructedMethods(stateHandler),\r\n [stateHandler]\r\n );\r\n\r\n const hookContext = useMemo(\r\n () => ({\r\n stateKey,\r\n pluginName: plugin.name,\r\n isInitialMount,\r\n options,\r\n ...deconstructed,\r\n ...metadataContext,\r\n }),\r\n [\r\n stateKey,\r\n plugin.name,\r\n isInitialMount,\r\n options,\r\n deconstructed,\r\n metadataContext,\r\n ]\r\n );\r\n\r\n const hookData = plugin.useHook ? plugin.useHook(hookContext) : undefined;\r\n\r\n useEffect(() => {\r\n setIsInitialMount(false);\r\n }, []);\r\n\r\n useEffect(() => {\r\n if (plugin.useHook) setHookResult(stateKey, plugin.name, hookData);\r\n else removeHookResult(stateKey, plugin.name);\r\n return () => removeHookResult(stateKey, plugin.name);\r\n }, [stateKey, plugin.name, !!plugin.useHook, hookData]);\r\n\r\n const lastProcessedOptionsRef = useRef<any>();\r\n const [isInitialTransform, setIsInitialTransform] = useState(true);\r\n\r\n useEffect(() => {\r\n if (plugin.transformState) {\r\n if (!isDeepEqual(options, lastProcessedOptionsRef.current)) {\r\n plugin.transformState({\r\n stateKey,\r\n pluginName: plugin.name,\r\n options,\r\n hookData,\r\n isInitialTransform,\r\n ...deconstructed,\r\n ...metadataContext,\r\n });\r\n lastProcessedOptionsRef.current = options;\r\n setIsInitialTransform(false);\r\n }\r\n }\r\n }, [\r\n stateKey,\r\n plugin,\r\n options,\r\n hookData,\r\n isInitialTransform,\r\n deconstructed,\r\n metadataContext,\r\n ]);\r\n\r\n const hookDataRef = useRef(hookData);\r\n hookDataRef.current = hookData;\r\n\r\n useEffect(() => {\r\n if (!plugin.onUpdate) return;\r\n\r\n const handleUpdate = (update: UpdateTypeDetail) => {\r\n if (update.stateKey === stateKey) {\r\n plugin.onUpdate!({\r\n stateKey,\r\n pluginName: plugin.name,\r\n update,\r\n path: update.path,\r\n options,\r\n hookData: hookDataRef.current,\r\n ...deconstructed,\r\n ...metadataContext,\r\n });\r\n }\r\n };\r\n\r\n const unsubscribe = pluginStore\r\n .getState()\r\n .subscribeToUpdates(handleUpdate);\r\n return unsubscribe;\r\n }, [stateKey, plugin, options, deconstructed, metadataContext]);\r\n\r\n useEffect(() => {\r\n if (!plugin.onFormUpdate) return;\r\n\r\n const handleFormUpdate = (\r\n event: ClientActivityEvent // Use the proper type\r\n ) => {\r\n if (event.stateKey === stateKey) {\r\n plugin.onFormUpdate!({\r\n stateKey,\r\n pluginName: plugin.name,\r\n path: event.path,\r\n event: event, // Pass the whole event through, not a transformed version\r\n options,\r\n hookData: hookDataRef.current,\r\n ...deconstructed,\r\n ...metadataContext,\r\n });\r\n }\r\n };\r\n\r\n const unsubscribe = pluginStore\r\n .getState()\r\n .subscribeToFormUpdates(handleFormUpdate);\r\n return unsubscribe;\r\n }, [stateKey, plugin, options, deconstructed, metadataContext]);\r\n\r\n return null;\r\n }\r\n);\r\n/**\r\n * The main orchestrator component. It reads from the central pluginStore\r\n * and renders a `PluginInstance` controller for each active plugin.\r\n */\r\nexport function PluginRunner({ children }: { children: React.ReactNode }) {\r\n // A simple way to force a re-render when the store changes.\r\n const [, forceUpdate] = useReducer((c) => c + 1, 0);\r\n\r\n // Subscribe to the store. When plugins or their options are added/removed,\r\n // this component will re-render to update the list of PluginInstances.\r\n useEffect(() => {\r\n const unsubscribe = pluginStore.subscribe(forceUpdate);\r\n return unsubscribe;\r\n }, []);\r\n\r\n const { pluginOptions, stateHandlers, registeredPlugins } =\r\n pluginStore.getState();\r\n\r\n return (\r\n <>\r\n {/*\r\n This declarative mapping is the core of the solution.\r\n React will now manage adding and removing `PluginInstance` components\r\n as the application state changes, ensuring hooks are handled safely.\r\n */}\r\n {Array.from(pluginOptions.entries()).map(([stateKey, pluginMap]) => {\r\n const stateHandler = stateHandlers.get(stateKey);\r\n if (!stateHandler) {\r\n return null; // Don't render a runner if the state handler isn't ready.\r\n }\r\n\r\n return Array.from(pluginMap.entries()).map(([pluginName, options]) => {\r\n const plugin = registeredPlugins.find((p) => p.name === pluginName);\r\n if (!plugin) {\r\n return null; // Don't render if the plugin is not in the registered list.\r\n }\r\n\r\n // Render a dedicated, memoized controller for this specific plugin configuration.\r\n return (\r\n <PluginInstance\r\n key={`${stateKey}:${pluginName}`}\r\n stateKey={stateKey}\r\n plugin={plugin}\r\n options={options}\r\n stateHandler={stateHandler}\r\n />\r\n );\r\n });\r\n })}\r\n\r\n {children}\r\n </>\r\n );\r\n}\r\n"],"names":["setHookResult","removeHookResult","pluginStore","PluginInstance","React","stateKey","plugin","options","stateHandler","isInitialMount","setIsInitialMount","useState","metadataContext","useMemo","createMetadataContext","deconstructed","toDeconstructedMethods","hookContext","hookData","useEffect","lastProcessedOptionsRef","useRef","isInitialTransform","setIsInitialTransform","isDeepEqual","hookDataRef","handleUpdate","update","handleFormUpdate","event","PluginRunner","children","forceUpdate","useReducer","c","pluginOptions","stateHandlers","registeredPlugins","jsxs","Fragment","pluginMap","pluginName","p","jsx"],"mappings":";;;;;AAQA,MAAM,EAAE,eAAAA,GAAe,kBAAAC,MAAqBC,EAAY,SAAA,GAElDC,IAAiBC,EAAM;AAAA,EAC3B,CAAC;AAAA,IACC,UAAAC;AAAA,IACA,QAAAC;AAAA,IACA,SAAAC;AAAA,IACA,cAAAC;AAAA,EAAA,MAMI;AACJ,UAAM,CAACC,GAAgBC,CAAiB,IAAIC,EAAS,EAAI,GACnDC,IAAkBC;AAAA,MACtB,MAAMC,EAAsBT,GAAUC,EAAO,IAAI;AAAA,MACjD,CAACD,GAAUC,EAAO,IAAI;AAAA,IAAA,GAGlBS,IAAgBF;AAAA,MACpB,MAAMG,EAAuBR,CAAY;AAAA,MACzC,CAACA,CAAY;AAAA,IAAA,GAGTS,IAAcJ;AAAA,MAClB,OAAO;AAAA,QACL,UAAAR;AAAA,QACA,YAAYC,EAAO;AAAA,QACnB,gBAAAG;AAAA,QACA,SAAAF;AAAA,QACA,GAAGQ;AAAA,QACH,GAAGH;AAAA,MAAA;AAAA,MAEL;AAAA,QACEP;AAAA,QACAC,EAAO;AAAA,QACPG;AAAA,QACAF;AAAA,QACAQ;AAAA,QACAH;AAAA,MAAA;AAAA,IACF,GAGIM,IAAWZ,EAAO,UAAUA,EAAO,QAAQW,CAAW,IAAI;AAEhE,IAAAE,EAAU,M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C;AAAA,YACA,cAAAC;AAAA,UAAA;AAAA,UAJK,GAAGH,CAAQ,IAAIoC,CAAU;AAAA,QAAA,IANzB;AAAA,MAaX,CAAC,IAnBQ;AAAA,IAoBX,CAAC;AAAA,IAEAV;AAAA,EAAA,GACH;AAEJ;"}
|
|
1
|
+
{"version":3,"file":"PluginRunner.jsx","sources":["../src/PluginRunner.tsx"],"sourcesContent":["import React, { useEffect, useMemo, useState, useRef, useReducer } from 'react';\r\nimport { ClientActivityEvent, pluginStore } from './pluginStore';\r\nimport { isDeepEqual } from './utility';\r\nimport {\r\n createMetadataContext,\r\n createScopedMetadataContext,\r\n toDeconstructedMethods,\r\n} from './plugins';\r\nimport type { CogsPlugin } from './plugins';\r\nimport type { StateObject, UpdateTypeDetail } from './CogsState';\r\nimport { ClientActivityState, FormEventType } from './store';\r\n\r\nconst { setHookResult, removeHookResult } = pluginStore.getState();\r\n\r\nconst PluginInstance = React.memo(\r\n ({\r\n stateKey,\r\n plugin,\r\n options,\r\n stateHandler,\r\n }: {\r\n stateKey: string;\r\n plugin: CogsPlugin<any, any, any, any, any>;\r\n options: any;\r\n stateHandler: StateObject<any>;\r\n }) => {\r\n const [isInitialMount, setIsInitialMount] = useState(true);\r\n const metadataContext = useMemo(\r\n () => createMetadataContext(stateKey, plugin.name),\r\n [stateKey, plugin.name]\r\n );\r\n\r\n const deconstructed = useMemo(\r\n () => toDeconstructedMethods(stateHandler),\r\n [stateHandler]\r\n );\r\n\r\n const hookContext = useMemo(\r\n () => ({\r\n stateKey,\r\n pluginName: plugin.name,\r\n isInitialMount,\r\n options,\r\n ...deconstructed,\r\n ...metadataContext,\r\n }),\r\n [\r\n stateKey,\r\n plugin.name,\r\n isInitialMount,\r\n options,\r\n deconstructed,\r\n metadataContext,\r\n ]\r\n );\r\n\r\n const hookData = plugin.useHook ? plugin.useHook(hookContext) : undefined;\r\n\r\n useEffect(() => {\r\n setIsInitialMount(false);\r\n }, []);\r\n\r\n useEffect(() => {\r\n if (plugin.useHook) setHookResult(stateKey, plugin.name, hookData);\r\n else removeHookResult(stateKey, plugin.name);\r\n return () => removeHookResult(stateKey, plugin.name);\r\n }, [stateKey, plugin.name, !!plugin.useHook, hookData]);\r\n\r\n const lastProcessedOptionsRef = useRef<any>();\r\n const [isInitialTransform, setIsInitialTransform] = useState(true);\r\n\r\n useEffect(() => {\r\n if (plugin.transformState) {\r\n if (!isDeepEqual(options, lastProcessedOptionsRef.current)) {\r\n plugin.transformState({\r\n stateKey,\r\n pluginName: plugin.name,\r\n options,\r\n hookData,\r\n isInitialTransform,\r\n ...deconstructed,\r\n ...metadataContext,\r\n });\r\n lastProcessedOptionsRef.current = options;\r\n setIsInitialTransform(false);\r\n }\r\n }\r\n }, [\r\n stateKey,\r\n plugin,\r\n options,\r\n hookData,\r\n isInitialTransform,\r\n deconstructed,\r\n metadataContext,\r\n ]);\r\n\r\n const hookDataRef = useRef(hookData);\r\n hookDataRef.current = hookData;\r\n\r\n useEffect(() => {\r\n if (!plugin.onUpdate) return;\r\n\r\n const handleUpdate = (update: UpdateTypeDetail) => {\r\n if (update.stateKey === stateKey) {\r\n // Create a new, SCOPED context for this specific path\r\n const scopedMetadata = createScopedMetadataContext(\r\n stateKey,\r\n plugin.name,\r\n update.path\r\n );\r\n\r\n plugin.onUpdate!({\r\n stateKey,\r\n pluginName: plugin.name,\r\n update,\r\n path: update.path,\r\n options,\r\n hookData: hookDataRef.current,\r\n ...deconstructed,\r\n ...scopedMetadata, // <-- Use the new scoped context\r\n });\r\n }\r\n };\r\n\r\n const unsubscribe = pluginStore\r\n .getState()\r\n .subscribeToUpdates(handleUpdate);\r\n return unsubscribe;\r\n }, [stateKey, plugin, options, deconstructed]);\r\n\r\n useEffect(() => {\r\n if (!plugin.onFormUpdate) return;\r\n\r\n const handleFormUpdate = (\r\n event: ClientActivityEvent // Use the proper type\r\n ) => {\r\n if (event.stateKey === stateKey) {\r\n // Create a new, SCOPED context for this specific path\r\n const scopedMetadata = createScopedMetadataContext(\r\n stateKey,\r\n plugin.name,\r\n event.path\r\n );\r\n\r\n plugin.onFormUpdate!({\r\n stateKey,\r\n pluginName: plugin.name,\r\n path: event.path,\r\n event: event,\r\n options,\r\n hookData: hookDataRef.current,\r\n ...deconstructed,\r\n ...scopedMetadata, // <-- Use the new scoped context\r\n });\r\n }\r\n };\r\n\r\n const unsubscribe = pluginStore\r\n .getState()\r\n .subscribeToFormUpdates(handleFormUpdate);\r\n return unsubscribe;\r\n }, [stateKey, plugin, options, deconstructed]);\r\n\r\n return null;\r\n }\r\n);\r\n/**\r\n * The main orchestrator component. It reads from the central pluginStore\r\n * and renders a `PluginInstance` controller for each active plugin.\r\n */\r\nexport function PluginRunner({ children }: { children: React.ReactNode }) {\r\n // A simple way to force a re-render when the store changes.\r\n const [, forceUpdate] = useReducer((c) => c + 1, 0);\r\n\r\n // Subscribe to the store. When plugins or their options are added/removed,\r\n // this component will re-render to update the list of PluginInstances.\r\n useEffect(() => {\r\n const unsubscribe = pluginStore.subscribe(forceUpdate);\r\n return unsubscribe;\r\n }, []);\r\n\r\n const { pluginOptions, stateHandlers, registeredPlugins } =\r\n pluginStore.getState();\r\n\r\n return (\r\n <>\r\n {/*\r\n This declarative mapping is the core of the solution.\r\n React will now manage adding and removing `PluginInstance` components\r\n as the application state changes, ensuring hooks are handled safely.\r\n */}\r\n {Array.from(pluginOptions.entries()).map(([stateKey, pluginMap]) => {\r\n const stateHandler = stateHandlers.get(stateKey);\r\n if (!stateHandler) {\r\n return null; // Don't render a runner if the state handler isn't ready.\r\n }\r\n\r\n return Array.from(pluginMap.entries()).map(([pluginName, options]) => {\r\n const plugin = registeredPlugins.find((p) => p.name === pluginName);\r\n if (!plugin) {\r\n return null; // Don't render if the plugin is not in the registered list.\r\n }\r\n\r\n // Render a dedicated, memoized controller for this specific plugin configuration.\r\n return (\r\n <PluginInstance\r\n key={`${stateKey}:${pluginName}`}\r\n stateKey={stateKey}\r\n plugin={plugin}\r\n options={options}\r\n stateHandler={stateHandler}\r\n />\r\n );\r\n });\r\n })}\r\n\r\n {children}\r\n </>\r\n );\r\n}\r\n"],"names":["setHookResult","removeHookResult","pluginStore","PluginInstance","React","stateKey","plugin","options","stateHandler","isInitialMount","setIsInitialMount","useState","metadataContext","useMemo","createMetadataContext","deconstructed","toDeconstructedMethods","hookContext","hookData","useEffect","lastProcessedOptionsRef","useRef","isInitialTransform","setIsInitialTransform","isDeepEqual","hookDataRef","handleUpdate","update","scopedMetadata","createScopedMetadataContext","handleFormUpdate","event","PluginRunner","children","forceUpdate","useReducer","c","pluginOptions","stateHandlers","registeredPlugins","jsxs","Fragment","pluginMap","pluginName","p","jsx"],"mappings":";;;;;AAYA,MAAM,EAAE,eAAAA,GAAe,kBAAAC,MAAqBC,EAAY,SAAA,GAElDC,IAAiBC,EAAM;AAAA,EAC3B,CAAC;AAAA,IACC,UAAAC;AAAA,IACA,QAAAC;AAAA,IACA,SAAAC;AAAA,IACA,cAAAC;AAAA,EAAA,MAMI;AACJ,UAAM,CAACC,GAAgBC,CAAiB,IAAIC,EAAS,EAAI,GACnDC,IAAkBC;AAAA,MACtB,MAAMC,EAAsBT,GAAUC,EAAO,IAAI;AAAA,MACjD,CAACD,GAAUC,EAAO,IAAI;AAAA,IAAA,GAGlBS,IAAgBF;AAAA,MACpB,MAAMG,EAAuBR,CAAY;AAAA,MACzC,CAACA,CAAY;AAAA,IAAA,GAGTS,IAAcJ;AAAA,MAClB,OAAO;AAAA,QACL,UAAAR;AAAA,QACA,YAAYC,EAAO;AAAA,QACnB,gBAAAG;AAAA,QACA,SAAAF;AAAA,QACA,GAAGQ;AAAA,QACH,GAAGH;AAAA,MAAA;AAAA,MAEL;AAAA,QACEP;AAAA,QACAC,EAAO;AAAA,QACPG;AAAA,QACAF;AAAA,QACAQ;AAAA,QACAH;AAAA,MAAA;AAAA,IACF,GAGIM,IAAWZ,EAAO,UAAUA,EAAO,QAAQW,CAAW,IAAI;AAEhE,IAAAE,EAAU,MAAM;AACd,MAAAT,EAAkB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AAYpC,CAAO,MAAM;AACpE,cAAMD,IAASiC,EAAkB,KAAK,CAACK,MAAMA,EAAE,SAASD,CAAU;AAClE,eAAKrC,IAMH,gBAAAuC;AAAA,UAAC1C;AAAA,UAAA;AAAA,YAEC,UAAAE;AAAA,YACA,QAAAC;AAAA,YACA,SAAAC;AAAA,YACA,cAAAC;AAAA,UAAA;AAAA,UAJK,GAAGH,CAAQ,IAAIsC,CAAU;AAAA,QAAA,IANzB;AAAA,MAaX,CAAC,IAnBQ;AAAA,IAoBX,CAAC;AAAA,IAEAV;AAAA,EAAA,GACH;AAEJ;"}
|
package/dist/index.js
CHANGED
|
@@ -1,41 +1,42 @@
|
|
|
1
1
|
import { $cogsSignal as r, addStateOptions as o, createCogsState as a, useCogsStateFn as n } from "./CogsState.jsx";
|
|
2
2
|
import { CogsStateClient as d, config as g, useCogsConfig as i } from "./CogsStateClient.jsx";
|
|
3
|
-
import { debounce as
|
|
4
|
-
import { useCogsTrpcValidationLink as
|
|
5
|
-
import { buildShadowNode as
|
|
6
|
-
import { createMetadataContext as T, createPluginContext as j,
|
|
7
|
-
import { PluginRunner as
|
|
3
|
+
import { debounce as f, deepMerge as p, deleteNestedProperty as u, getArrayLengthDifferences as S, getArrayLengthDifferencesArray as l, getDifferences as x, getDifferencesArray as C, isArray as m, isDeepEqual as y, isFunction as h, isObject as D, transformStateFunc as A, updateNestedProperty as b } from "./utility.js";
|
|
4
|
+
import { useCogsTrpcValidationLink as P } from "./TRPCValidationLink.js";
|
|
5
|
+
import { buildShadowNode as F, generateId as L, getGlobalStore as N, shadowStateStore as k, updateShadowTypeInfo as I } from "./store.js";
|
|
6
|
+
import { createMetadataContext as T, createPluginContext as j, createScopedMetadataContext as q, keyedSchema as E, toDeconstructedMethods as G } from "./plugins.js";
|
|
7
|
+
import { PluginRunner as V } from "./PluginRunner.jsx";
|
|
8
8
|
export {
|
|
9
9
|
r as $cogsSignal,
|
|
10
10
|
d as CogsStateClient,
|
|
11
|
-
|
|
11
|
+
V as PluginRunner,
|
|
12
12
|
o as addStateOptions,
|
|
13
|
-
|
|
13
|
+
F as buildShadowNode,
|
|
14
14
|
g as config,
|
|
15
15
|
a as createCogsState,
|
|
16
16
|
T as createMetadataContext,
|
|
17
17
|
j as createPluginContext,
|
|
18
|
-
|
|
18
|
+
q as createScopedMetadataContext,
|
|
19
|
+
f as debounce,
|
|
19
20
|
p as deepMerge,
|
|
20
21
|
u as deleteNestedProperty,
|
|
21
|
-
|
|
22
|
+
L as generateId,
|
|
22
23
|
S as getArrayLengthDifferences,
|
|
23
24
|
l as getArrayLengthDifferencesArray,
|
|
24
|
-
|
|
25
|
-
|
|
25
|
+
x as getDifferences,
|
|
26
|
+
C as getDifferencesArray,
|
|
26
27
|
N as getGlobalStore,
|
|
27
|
-
|
|
28
|
-
|
|
28
|
+
m as isArray,
|
|
29
|
+
y as isDeepEqual,
|
|
29
30
|
h as isFunction,
|
|
30
31
|
D as isObject,
|
|
31
|
-
|
|
32
|
+
E as keyedSchema,
|
|
32
33
|
k as shadowStateStore,
|
|
33
|
-
|
|
34
|
+
G as toDeconstructedMethods,
|
|
34
35
|
A as transformStateFunc,
|
|
35
36
|
b as updateNestedProperty,
|
|
36
37
|
I as updateShadowTypeInfo,
|
|
37
38
|
i as useCogsConfig,
|
|
38
39
|
n as useCogsStateFn,
|
|
39
|
-
|
|
40
|
+
P as useCogsTrpcValidationLink
|
|
40
41
|
};
|
|
41
42
|
//# sourceMappingURL=index.js.map
|