cogsbox-state 0.5.472 → 0.5.474

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.
Files changed (46) hide show
  1. package/README.md +48 -18
  2. package/dist/CogsState.d.ts +98 -82
  3. package/dist/CogsState.d.ts.map +1 -1
  4. package/dist/CogsState.jsx +1030 -960
  5. package/dist/CogsState.jsx.map +1 -1
  6. package/dist/Components.d.ts.map +1 -1
  7. package/dist/Components.jsx +299 -219
  8. package/dist/Components.jsx.map +1 -1
  9. package/dist/PluginRunner.d.ts +10 -0
  10. package/dist/PluginRunner.d.ts.map +1 -0
  11. package/dist/PluginRunner.jsx +122 -0
  12. package/dist/PluginRunner.jsx.map +1 -0
  13. package/dist/index.d.ts +2 -0
  14. package/dist/index.d.ts.map +1 -1
  15. package/dist/index.js +33 -26
  16. package/dist/index.js.map +1 -1
  17. package/dist/pluginStore.d.ts +81 -0
  18. package/dist/pluginStore.d.ts.map +1 -0
  19. package/dist/pluginStore.js +52 -0
  20. package/dist/pluginStore.js.map +1 -0
  21. package/dist/plugins.d.ts +1323 -0
  22. package/dist/plugins.d.ts.map +1 -0
  23. package/dist/plugins.js +76 -0
  24. package/dist/plugins.js.map +1 -0
  25. package/dist/store.d.ts +50 -15
  26. package/dist/store.d.ts.map +1 -1
  27. package/dist/store.js +509 -470
  28. package/dist/store.js.map +1 -1
  29. package/dist/utility.d.ts +1 -1
  30. package/dist/utility.d.ts.map +1 -1
  31. package/dist/utility.js +12 -12
  32. package/dist/utility.js.map +1 -1
  33. package/dist/validation.d.ts +7 -0
  34. package/dist/validation.d.ts.map +1 -0
  35. package/dist/validation.js +39 -0
  36. package/dist/validation.js.map +1 -0
  37. package/package.json +13 -3
  38. package/src/CogsState.tsx +657 -457
  39. package/src/Components.tsx +291 -194
  40. package/src/PluginRunner.tsx +203 -0
  41. package/src/index.ts +2 -0
  42. package/src/pluginStore.ts +176 -0
  43. package/src/plugins.ts +544 -0
  44. package/src/store.ts +748 -493
  45. package/src/utility.ts +31 -31
  46. package/src/validation.ts +84 -0
@@ -1 +1 @@
1
- {"version":3,"file":"Components.jsx","sources":["../src/Components.tsx"],"sourcesContent":["import { FormElementParams, type FormOptsType } from './CogsState';\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} from 'react';\r\nimport {\r\n formRefStore,\r\n getGlobalStore,\r\n ValidationError,\r\n ValidationSeverity,\r\n} from './store';\r\nimport { useInView } from 'react-intersection-observer';\r\nimport { v4 as uuidv4 } from 'uuid';\r\nimport { isDeepEqual } from './utility';\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\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 const [, forceUpdate] = useState({});\r\n\r\n const stateKeyPathKey = [stateKey, ...path].join('.');\r\n useRegisterComponent(stateKey, componentId, forceUpdate);\r\n\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 const fieldSchema = typeInfo?.schema; // The actual Zod schema for this field\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 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 return () => {\r\n unsubscribe();\r\n if (debounceTimeoutRef.current) {\r\n clearTimeout(debounceTimeoutRef.current);\r\n isCurrentlyDebouncing.current = false;\r\n }\r\n };\r\n }, []);\r\n\r\n // Separate validation function that uses the field's schema\r\n const validateField = useCallback(\r\n (value: any, trigger: 'onChange' | 'onBlur') => {\r\n const rootMeta = getGlobalStore\r\n .getState()\r\n .getShadowMetadata(stateKey, []);\r\n if (!rootMeta?.features?.validationEnabled) return;\r\n\r\n const validationOptions = getInitialOptions(stateKey)?.validation;\r\n\r\n if (!validationOptions) return;\r\n\r\n const currentMeta = getShadowMetadata(stateKey, path) || {};\r\n const currentStatus = currentMeta?.validation?.status;\r\n\r\n let shouldValidate = false;\r\n let severity: 'error' | 'warning' | undefined;\r\n console.log('trigger', trigger, validationOptions);\r\n if (trigger === 'onBlur' && validationOptions.onBlur) {\r\n shouldValidate = true;\r\n severity = validationOptions.onBlur ?? 'error';\r\n } else if (trigger === 'onChange') {\r\n if (validationOptions.onChange) {\r\n shouldValidate = true;\r\n severity = validationOptions.onChange;\r\n } else if (currentStatus === 'INVALID') {\r\n shouldValidate = true;\r\n severity = 'warning';\r\n }\r\n }\r\n\r\n if (!shouldValidate) return;\r\n\r\n let validationResult: { success: boolean; message?: string } | null =\r\n null;\r\n console.log(\r\n 'shouldValidate 33',\r\n path,\r\n fieldSchema,\r\n shouldValidate,\r\n value,\r\n typeof value\r\n );\r\n if (fieldSchema && shouldValidate) {\r\n // Direct field validation using its own schema\r\n const result = fieldSchema.safeParse(value);\r\n\r\n if (!result.success) {\r\n const errors =\r\n 'issues' in result.error\r\n ? result.error.issues\r\n : (result.error as any).errors;\r\n\r\n validationResult = {\r\n success: false,\r\n message: errors[0]?.message || 'Invalid value',\r\n };\r\n } else {\r\n validationResult = { success: true };\r\n }\r\n } else {\r\n // Fallback: validate using the entire schema\r\n const zodSchema =\r\n validationOptions.zodSchemaV4 || validationOptions.zodSchemaV3;\r\n if (!zodSchema) return;\r\n\r\n // Create a test state with the new value at the correct path\r\n const fullState = getShadowValue(stateKey, []);\r\n const testState = JSON.parse(JSON.stringify(fullState)); // Deep clone\r\n\r\n // Set the value at the correct path\r\n let current = testState;\r\n for (let i = 0; i < path.length - 1; i++) {\r\n if (!current[path[i]!]) current[path[i]!] = {};\r\n current = current[path[i]!];\r\n }\r\n if (path.length > 0) {\r\n current[path[path.length - 1]!] = value;\r\n } else {\r\n // Root level update\r\n Object.assign(testState, value);\r\n }\r\n\r\n const result = zodSchema.safeParse(testState);\r\n\r\n if (!result.success) {\r\n const errors =\r\n 'issues' in result.error\r\n ? result.error.issues\r\n : (result.error as any).errors;\r\n\r\n // Find errors for this specific path\r\n const pathErrors = errors.filter((error: any) => {\r\n // Handle array paths with id: prefixes\r\n if (path.some((p) => p.startsWith('id:'))) {\r\n const parentPath = path[0]!.startsWith('id:')\r\n ? []\r\n : path.slice(0, -1);\r\n const arrayMeta = getGlobalStore\r\n .getState()\r\n .getShadowMetadata(stateKey, parentPath);\r\n\r\n if (arrayMeta?.arrayKeys) {\r\n const itemKey = path.slice(0, -1).join('.');\r\n const itemIndex = arrayMeta.arrayKeys.findIndex(\r\n (k) => k === path[path.length - 2]\r\n );\r\n const zodPath = [...parentPath, itemIndex, ...path.slice(-1)];\r\n return JSON.stringify(error.path) === JSON.stringify(zodPath);\r\n }\r\n }\r\n\r\n return JSON.stringify(error.path) === JSON.stringify(path);\r\n });\r\n\r\n if (pathErrors.length > 0) {\r\n validationResult = {\r\n success: false,\r\n message: pathErrors[0]?.message,\r\n };\r\n } else {\r\n validationResult = { success: true };\r\n }\r\n } else {\r\n validationResult = { success: true };\r\n }\r\n }\r\n\r\n // Update validation state based on result\r\n if (validationResult) {\r\n if (!validationResult.success) {\r\n setShadowMetadata(stateKey, path, {\r\n ...currentMeta,\r\n validation: {\r\n status: 'INVALID',\r\n errors: [\r\n {\r\n source: 'client' as const,\r\n message: validationResult.message!,\r\n severity: severity!,\r\n },\r\n ],\r\n lastValidated: Date.now(),\r\n validatedValue: value,\r\n },\r\n });\r\n } else {\r\n setShadowMetadata(stateKey, path, {\r\n ...currentMeta,\r\n validation: {\r\n status: 'VALID',\r\n errors: [],\r\n lastValidated: Date.now(),\r\n validatedValue: value,\r\n },\r\n });\r\n }\r\n }\r\n forceUpdate({});\r\n },\r\n [stateKey, path, fieldSchema]\r\n );\r\n\r\n const debouncedUpdate = useCallback(\r\n (newValue: any) => {\r\n // Use typeInfo to properly convert the value\r\n\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 // Fallback to old behavior if no typeInfo\r\n\r\n const currentType = typeof globalStateValue;\r\n\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 // Validate immediately on change (will only run if configured or clearing errors)\r\n validateField(newValue, 'onChange');\r\n\r\n isCurrentlyDebouncing.current = true;\r\n\r\n if (debounceTimeoutRef.current) {\r\n clearTimeout(debounceTimeoutRef.current);\r\n }\r\n\r\n const debounceTime = formOpts?.debounceTime ?? 200;\r\n\r\n // Debounce only the state update, not the validation\r\n debounceTimeoutRef.current = setTimeout(() => {\r\n isCurrentlyDebouncing.current = false;\r\n setState(newValue, path, { updateType: 'update' });\r\n }, debounceTime);\r\n },\r\n [\r\n setState,\r\n path,\r\n formOpts?.debounceTime,\r\n validateField,\r\n typeInfo,\r\n globalStateValue,\r\n ]\r\n );\r\n\r\n const handleBlur = useCallback(() => {\r\n // Commit any pending changes immediately\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, { updateType: 'update' });\r\n }\r\n\r\n // Validate on blur\r\n validateField(localValue, 'onBlur');\r\n }, [localValue, setState, path, validateField]);\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 onBlur: handleBlur,\r\n ref: formRefStore\r\n .getState()\r\n .getFormRef(stateKey + '.' + path.join('.')),\r\n };\r\n }\r\n\r\n return target[prop];\r\n },\r\n });\r\n\r\n return (\r\n <ValidationWrapper formOpts={formOpts} path={path} stateKey={stateKey}>\r\n {renderFn(stateWithInputProps)}\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"],"names":["getInitialOptions","getShadowMetadata","setShadowMetadata","getShadowValue","registerComponent","unregisterComponent","notifyPathSubscribers","subscribeToPath","getGlobalStore","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","stateKeyPathKey","typeInfo","fieldSchema","globalStateValue","localValue","setLocalValue","isCurrentlyDebouncing","debounceTimeoutRef","isDeepEqual","newValue","validateField","value","trigger","validationOptions","currentMeta","currentStatus","shouldValidate","severity","validationResult","result","zodSchema","fullState","testState","current","i","pathErrors","error","p","parentPath","arrayMeta","itemIndex","k","zodPath","debouncedUpdate","debounceTime","handleBlur","baseState","stateWithInputProps","target","prop","formRefStore","fullComponentId","useLayoutEffect","ref","loaded","setLoaded","images","loadedCount","handleImageLoad","image","IsolatedComponentWrapper"],"mapp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,QAAIE,IAAc;AAClB,UAAMC,IAAkB,MAAM;AAC5B,MAAAD,KACIA,MAAgBD,EAAO,UACzBD,EAAU,EAAI;AAAA,IAElB;AAEA,WAAAC,EAAO,QAAQ,CAACG,MAAU;AACxB,MAAIA,EAAM,WACRD,EAAA,KAEAC,EAAM,iBAAiB,QAAQD,CAAe,GAC9CC,EAAM,iBAAiB,SAASD,CAAe;AAAA,IAEnD,CAAC,GAEM,MAAM;AACX,MAAAF,EAAO,QAAQ,CAACG,MAAU;AACxB,QAAAA,EAAM,oBAAoB,QAAQD,CAAe,GACjDC,EAAM,oBAAoB,SAASD,CAAe;AAAA,MACpD,CAAC;AAAA,IACH;AAAA,EACF,GAAG,CAACL,EAAI,OAAO,CAAC,GAETC;AACT;AAIO,SAASM,GAAyB;AAAA,EACvC,UAAAtG;AAAA,EACA,MAAAD;AAAA,EACA,mBAAAwB;AAAA,EACA,UAAAC;AACF,GASG;AACD,QAAM,CAAC0B,CAAW,IAAIxB,EAAS,MAAMyB,GAAQ,GACvC,GAAG1B,CAAW,IAAIC,EAAS,EAAE,GAE7B0B,IAAkB,CAACpD,GAAU,GAAGD,CAAI,EAAE,KAAK,GAAG;AACpD,EAAAqC,EAAqBpC,GAAUkD,GAAazB,CAAW,GAEvDe,EAAU,MAAM;AACd,UAAMC,IAAc7C,EACjB,SAAA,EACA,gBAAgBwD,GAAiB,MAAM;AACtC,MAAA3B,EAAY,CAAA,CAAE;AAAA,IAChB,CAAC;AACH,WAAO,MAAMgB,EAAA;AAAA,EACf,GAAG,CAACW,CAAe,CAAC;AAEpB,QAAMoC,IAAYjE,EAAkB;AAAA,IAClC,MAAAxB;AAAA,IACA,aAAAmD;AAAA,IACA,MAAM;AAAA,EAAA,CACP;AAED,SAAO,gBAAAvC,EAAAC,GAAA,EAAG,UAAAY,EAASgE,CAAS,GAAE;AAChC;"}
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,UAA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C,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;"}
@@ -0,0 +1,10 @@
1
+ import { default as React } from 'react';
2
+
3
+ /**
4
+ * The main orchestrator component. It reads from the central pluginStore
5
+ * and renders a `PluginInstance` controller for each active plugin.
6
+ */
7
+ export declare function PluginRunner({ children }: {
8
+ children: React.ReactNode;
9
+ }): import("react/jsx-runtime").JSX.Element;
10
+ //# sourceMappingURL=PluginRunner.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PluginRunner.d.ts","sourceRoot":"","sources":["../src/PluginRunner.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA2D,MAAM,OAAO,CAAC;AAqJhF;;;GAGG;AACH,wBAAgB,YAAY,CAAC,EAAE,QAAQ,EAAE,EAAE;IAAE,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;CAAE,2CAiDvE"}
@@ -0,0 +1,122 @@
1
+ import { jsxs as D, Fragment as F, jsx as M } from "react/jsx-runtime";
2
+ import P, { useState as S, useMemo as R, useEffect as m, useRef as l, useReducer as T } from "react";
3
+ import { pluginStore as f } from "./pluginStore.js";
4
+ import { isDeepEqual as C } from "./utility.js";
5
+ import { createMetadataContext as N, toDeconstructedMethods as j } from "./plugins.js";
6
+ const { setHookResult: A, removeHookResult: H } = f.getState(), E = P.memo(
7
+ ({
8
+ stateKey: r,
9
+ plugin: e,
10
+ options: t,
11
+ stateHandler: d
12
+ }) => {
13
+ const [i, s] = S(!0), n = R(
14
+ () => N(r, e.name),
15
+ [r, e.name]
16
+ ), o = R(
17
+ () => j(d),
18
+ [d]
19
+ ), b = R(
20
+ () => ({
21
+ stateKey: r,
22
+ pluginName: e.name,
23
+ isInitialMount: i,
24
+ options: t,
25
+ ...o,
26
+ ...n
27
+ }),
28
+ [
29
+ r,
30
+ e.name,
31
+ i,
32
+ t,
33
+ o,
34
+ n
35
+ ]
36
+ ), a = e.useHook ? e.useHook(b) : void 0;
37
+ m(() => {
38
+ s(!1);
39
+ }, []), m(() => (e.useHook ? A(r, e.name, a) : H(r, e.name), () => H(r, e.name)), [r, e.name, !!e.useHook, a]);
40
+ const u = l(), [h, I] = S(!0);
41
+ m(() => {
42
+ e.transformState && (C(t, u.current) || (e.transformState({
43
+ stateKey: r,
44
+ pluginName: e.name,
45
+ options: t,
46
+ hookData: a,
47
+ isInitialTransform: h,
48
+ ...o,
49
+ ...n
50
+ }), u.current = t, I(!1)));
51
+ }, [
52
+ r,
53
+ e,
54
+ t,
55
+ a,
56
+ h,
57
+ o,
58
+ n
59
+ ]);
60
+ const k = l(a);
61
+ return k.current = a, m(() => {
62
+ if (!e.onUpdate) return;
63
+ const U = (c) => {
64
+ c.stateKey === r && e.onUpdate({
65
+ stateKey: r,
66
+ pluginName: e.name,
67
+ update: c,
68
+ path: c.path,
69
+ options: t,
70
+ hookData: k.current,
71
+ ...o,
72
+ ...n
73
+ });
74
+ };
75
+ return f.getState().subscribeToUpdates(U);
76
+ }, [r, e, t, o, n]), m(() => {
77
+ if (!e.onFormUpdate) return;
78
+ const U = (c) => {
79
+ c.stateKey === r && e.onFormUpdate({
80
+ stateKey: r,
81
+ pluginName: e.name,
82
+ path: c.path,
83
+ event: c,
84
+ // Pass the whole event through, not a transformed version
85
+ options: t,
86
+ hookData: k.current,
87
+ ...o,
88
+ ...n
89
+ });
90
+ };
91
+ return f.getState().subscribeToFormUpdates(U);
92
+ }, [r, e, t, o, n]), null;
93
+ }
94
+ );
95
+ function z({ children: r }) {
96
+ const [, e] = T((s) => s + 1, 0);
97
+ m(() => f.subscribe(e), []);
98
+ const { pluginOptions: t, stateHandlers: d, registeredPlugins: i } = f.getState();
99
+ return /* @__PURE__ */ D(F, { children: [
100
+ Array.from(t.entries()).map(([s, n]) => {
101
+ const o = d.get(s);
102
+ return o ? Array.from(n.entries()).map(([b, a]) => {
103
+ const u = i.find((h) => h.name === b);
104
+ return u ? /* @__PURE__ */ M(
105
+ E,
106
+ {
107
+ stateKey: s,
108
+ plugin: u,
109
+ options: a,
110
+ stateHandler: o
111
+ },
112
+ `${s}:${b}`
113
+ ) : null;
114
+ }) : null;
115
+ }),
116
+ r
117
+ ] });
118
+ }
119
+ export {
120
+ z as PluginRunner
121
+ };
122
+ //# sourceMappingURL=PluginRunner.jsx.map
@@ -0,0 +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,MAAM;AACd,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ACA,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;"}
package/dist/index.d.ts CHANGED
@@ -3,4 +3,6 @@ export * from './CogsStateClient.js';
3
3
  export * from './utility.js';
4
4
  export * from './TRPCValidationLink.js';
5
5
  export * from './store.js';
6
+ export * from './plugins.js';
7
+ export * from './PluginRunner.js';
6
8
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,sBAAsB,CAAC;AACrC,cAAc,cAAc,CAAC;AAC7B,cAAc,yBAAyB,CAAC;AACxC,cAAc,YAAY,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,sBAAsB,CAAC;AACrC,cAAc,cAAc,CAAC;AAC7B,cAAc,yBAAyB,CAAC;AACxC,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,mBAAmB,CAAC"}
package/dist/index.js CHANGED
@@ -1,34 +1,41 @@
1
- import { $cogsSignal as r, addStateOptions as o, createCogsState as a, createCogsStateFromSync as s, useCogsStateFn as n } from "./CogsState.jsx";
2
- import { CogsStateClient as f, config as i, useCogsConfig as c } from "./CogsStateClient.jsx";
3
- import { debounce as p, deepMerge as S, deleteNestedProperty as u, getArrayLengthDifferences as l, getArrayLengthDifferencesArray as m, getDifferences as y, getDifferencesArray as C, isArray as x, isDeepEqual as A, isFunction as D, isObject as b, transformStateFunc as F, updateNestedProperty as h } from "./utility.js";
4
- import { useCogsTrpcValidationLink as N } from "./TRPCValidationLink.js";
5
- import { buildShadowNode as P, formRefStore as j, generateId as k, getGlobalStore as q } from "./store.js";
1
+ import { $cogsSignal as r, addStateOptions as o, createCogsState as a, useCogsStateFn as n } from "./CogsState.jsx";
2
+ import { CogsStateClient as d, config as g, useCogsConfig as i } from "./CogsStateClient.jsx";
3
+ import { debounce as c, deepMerge as p, deleteNestedProperty as u, getArrayLengthDifferences as S, getArrayLengthDifferencesArray as l, getDifferences as m, getDifferencesArray as x, isArray as y, isDeepEqual as C, isFunction as h, isObject as D, transformStateFunc as A, updateNestedProperty as b } from "./utility.js";
4
+ import { useCogsTrpcValidationLink as w } from "./TRPCValidationLink.js";
5
+ import { buildShadowNode as L, generateId as M, getGlobalStore as N, shadowStateStore as k, updateShadowTypeInfo as I } from "./store.js";
6
+ import { createMetadataContext as T, createPluginContext as j, keyedSchema as q, toDeconstructedMethods as E } from "./plugins.js";
7
+ import { PluginRunner as R } from "./PluginRunner.jsx";
6
8
  export {
7
9
  r as $cogsSignal,
8
- f as CogsStateClient,
10
+ d as CogsStateClient,
11
+ R as PluginRunner,
9
12
  o as addStateOptions,
10
- P as buildShadowNode,
11
- i as config,
13
+ L as buildShadowNode,
14
+ g as config,
12
15
  a as createCogsState,
13
- s as createCogsStateFromSync,
14
- p as debounce,
15
- S as deepMerge,
16
+ T as createMetadataContext,
17
+ j as createPluginContext,
18
+ c as debounce,
19
+ p as deepMerge,
16
20
  u as deleteNestedProperty,
17
- j as formRefStore,
18
- k as generateId,
19
- l as getArrayLengthDifferences,
20
- m as getArrayLengthDifferencesArray,
21
- y as getDifferences,
22
- C as getDifferencesArray,
23
- q as getGlobalStore,
24
- x as isArray,
25
- A as isDeepEqual,
26
- D as isFunction,
27
- b as isObject,
28
- F as transformStateFunc,
29
- h as updateNestedProperty,
30
- c as useCogsConfig,
21
+ M as generateId,
22
+ S as getArrayLengthDifferences,
23
+ l as getArrayLengthDifferencesArray,
24
+ m as getDifferences,
25
+ x as getDifferencesArray,
26
+ N as getGlobalStore,
27
+ y as isArray,
28
+ C as isDeepEqual,
29
+ h as isFunction,
30
+ D as isObject,
31
+ q as keyedSchema,
32
+ k as shadowStateStore,
33
+ E as toDeconstructedMethods,
34
+ A as transformStateFunc,
35
+ b as updateNestedProperty,
36
+ I as updateShadowTypeInfo,
37
+ i as useCogsConfig,
31
38
  n as useCogsStateFn,
32
- N as useCogsTrpcValidationLink
39
+ w as useCogsTrpcValidationLink
33
40
  };
34
41
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;"}
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;"}
@@ -0,0 +1,81 @@
1
+ import { StateObject, UpdateTypeDetail } from './CogsState';
2
+ import { CogsPlugin } from './plugins';
3
+
4
+ export type ClientActivityEvent = {
5
+ stateKey: string;
6
+ path: string[];
7
+ timestamp: number;
8
+ duration?: number;
9
+ } & ({
10
+ activityType: 'focus';
11
+ details: {
12
+ cursorPosition?: number;
13
+ };
14
+ } | {
15
+ activityType: 'blur';
16
+ details: {
17
+ duration: number;
18
+ };
19
+ } | {
20
+ activityType: 'input';
21
+ details: {
22
+ value: any;
23
+ inputLength?: number;
24
+ isComposing?: boolean;
25
+ isPasting?: boolean;
26
+ keystrokeCount?: number;
27
+ };
28
+ } | {
29
+ activityType: 'select';
30
+ details: {
31
+ selectionStart: number;
32
+ selectionEnd: number;
33
+ selectedText?: string;
34
+ };
35
+ } | {
36
+ activityType: 'hover_enter';
37
+ details: {
38
+ cursorPosition?: number;
39
+ };
40
+ } | {
41
+ activityType: 'hover_exit';
42
+ details: {
43
+ duration: number;
44
+ };
45
+ } | {
46
+ activityType: 'scroll';
47
+ details: {
48
+ scrollTop: number;
49
+ scrollLeft: number;
50
+ };
51
+ } | {
52
+ activityType: 'cursor_move';
53
+ details: {
54
+ cursorPosition: number;
55
+ };
56
+ });
57
+ type PluginRegistryStore = {
58
+ stateHandlers: Map<string, StateObject<any>>;
59
+ registerStateHandler: (stateKey: string, handler: StateObject<any>) => void;
60
+ registeredPlugins: readonly CogsPlugin<any, any, any, any, any>[];
61
+ setRegisteredPlugins: (plugins: readonly CogsPlugin<any, any, any, any, any>[]) => void;
62
+ pluginOptions: Map<string, Map<string, any>>;
63
+ setPluginOptionsForState: (stateKey: string, pluginOptions: Record<string, any>) => void;
64
+ getPluginConfigsForState: (stateKey: string) => Array<{
65
+ plugin: CogsPlugin<any, any, any, any, any>;
66
+ options: any;
67
+ }>;
68
+ updateSubscribers: Set<(update: UpdateTypeDetail) => void>;
69
+ subscribeToUpdates: (callback: (update: UpdateTypeDetail) => void) => () => void;
70
+ notifyUpdate: (update: UpdateTypeDetail) => void;
71
+ formUpdateSubscribers: Set<(event: ClientActivityEvent) => void>;
72
+ subscribeToFormUpdates: (callback: (event: ClientActivityEvent) => void) => () => void;
73
+ notifyFormUpdate: (event: ClientActivityEvent) => void;
74
+ hookResults: Map<string, Map<string, any>>;
75
+ setHookResult: (stateKey: string, pluginName: string, data: any) => void;
76
+ getHookResult: (stateKey: string, pluginName: string) => any | undefined;
77
+ removeHookResult: (stateKey: string, pluginName: string) => void;
78
+ };
79
+ export declare const pluginStore: import('zustand').UseBoundStore<import('zustand').StoreApi<PluginRegistryStore>>;
80
+ export {};
81
+ //# sourceMappingURL=pluginStore.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pluginStore.d.ts","sourceRoot":"","sources":["../src/pluginStore.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAc,WAAW,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC7E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAC5C,MAAM,MAAM,mBAAmB,GAAG;IAChC,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,GAAG,CACA;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,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC;IAC3C,aAAa,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,KAAK,IAAI,CAAC;IACzE,aAAa,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,KAAK,GAAG,GAAG,SAAS,CAAC;IACzE,gBAAgB,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,KAAK,IAAI,CAAC;CAClE,CAAC;AAEF,eAAO,MAAM,WAAW,kFAqGrB,CAAC"}
@@ -0,0 +1,52 @@
1
+ import { create as l } from "zustand";
2
+ const b = l((u, o) => ({
3
+ stateHandlers: /* @__PURE__ */ new Map(),
4
+ registerStateHandler: (e, s) => u((n) => {
5
+ const t = new Map(n.stateHandlers);
6
+ return t.set(e, s), console.log("addign handler", e, s), { stateHandlers: t };
7
+ }),
8
+ registeredPlugins: [],
9
+ pluginOptions: /* @__PURE__ */ new Map(),
10
+ setRegisteredPlugins: (e) => u({ registeredPlugins: e }),
11
+ setPluginOptionsForState: (e, s) => u((n) => {
12
+ const t = new Map(n.pluginOptions), r = /* @__PURE__ */ new Map();
13
+ return Object.entries(s).forEach(([i, p]) => {
14
+ n.registeredPlugins.some((a) => a.name === i) && r.set(i, p);
15
+ }), r.size > 0 && t.set(e, r), { pluginOptions: t };
16
+ }),
17
+ getPluginConfigsForState: (e) => {
18
+ const s = o(), n = s.pluginOptions.get(e);
19
+ return n ? s.registeredPlugins.map((t) => {
20
+ const r = n.get(t.name);
21
+ return r !== void 0 ? { plugin: t, options: r } : null;
22
+ }).filter(Boolean) : [];
23
+ },
24
+ updateSubscribers: /* @__PURE__ */ new Set(),
25
+ subscribeToUpdates: (e) => (o().updateSubscribers.add(e), () => {
26
+ o().updateSubscribers.delete(e);
27
+ }),
28
+ notifyUpdate: (e) => {
29
+ o().updateSubscribers.forEach((s) => s(e));
30
+ },
31
+ formUpdateSubscribers: /* @__PURE__ */ new Set(),
32
+ subscribeToFormUpdates: (e) => (o().formUpdateSubscribers.add(e), () => {
33
+ o().formUpdateSubscribers.delete(e);
34
+ }),
35
+ notifyFormUpdate: (e) => {
36
+ o().formUpdateSubscribers.forEach((s) => s(e));
37
+ },
38
+ hookResults: /* @__PURE__ */ new Map(),
39
+ setHookResult: (e, s, n) => u((t) => {
40
+ const r = new Map(t.hookResults), i = new Map(r.get(e) ?? /* @__PURE__ */ new Map());
41
+ return n === void 0 ? i.delete(s) : i.set(s, n), i.size > 0 ? r.set(e, i) : r.delete(e), { hookResults: r };
42
+ }),
43
+ getHookResult: (e, s) => o().hookResults.get(e)?.get(s),
44
+ removeHookResult: (e, s) => u((n) => {
45
+ const t = new Map(n.hookResults), r = new Map(t.get(e) ?? /* @__PURE__ */ new Map());
46
+ return r.delete(s), r.size > 0 ? t.set(e, r) : t.delete(e), { hookResults: t };
47
+ })
48
+ }));
49
+ export {
50
+ b as pluginStore
51
+ };
52
+ //# sourceMappingURL=pluginStore.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pluginStore.js","sources":["../src/pluginStore.ts"],"sourcesContent":["import { create } from 'zustand';\r\nimport type { PluginData, StateObject, UpdateTypeDetail } from './CogsState';\r\nimport type { CogsPlugin } from './plugins';\r\nexport type ClientActivityEvent = {\r\n stateKey: string;\r\n path: string[];\r\n timestamp: number;\r\n duration?: number;\r\n} & (\r\n | { activityType: 'focus'; details: { cursorPosition?: number } }\r\n | { activityType: 'blur'; details: { duration: number } }\r\n | {\r\n activityType: 'input';\r\n details: {\r\n value: any;\r\n inputLength?: number;\r\n isComposing?: boolean;\r\n isPasting?: boolean;\r\n keystrokeCount?: number;\r\n };\r\n }\r\n | {\r\n activityType: 'select';\r\n details: {\r\n selectionStart: number;\r\n selectionEnd: number;\r\n selectedText?: string;\r\n };\r\n }\r\n | { activityType: 'hover_enter'; details: { cursorPosition?: number } }\r\n | { activityType: 'hover_exit'; details: { duration: number } }\r\n | {\r\n activityType: 'scroll';\r\n details: { scrollTop: number; scrollLeft: number };\r\n }\r\n | { activityType: 'cursor_move'; details: { cursorPosition: number } }\r\n);\r\n\r\ntype PluginRegistryStore = {\r\n stateHandlers: Map<string, StateObject<any>>; // stateKey -> handler\r\n registerStateHandler: (stateKey: string, handler: StateObject<any>) => void;\r\n registeredPlugins: readonly CogsPlugin<any, any, any, any, any>[];\r\n setRegisteredPlugins: (\r\n plugins: readonly CogsPlugin<any, any, any, any, any>[]\r\n ) => void;\r\n\r\n // Store options keyed by stateKey and pluginName\r\n pluginOptions: Map<string, Map<string, any>>; // stateKey -> pluginName -> options\r\n setPluginOptionsForState: (\r\n stateKey: string,\r\n pluginOptions: Record<string, any>\r\n ) => void;\r\n\r\n // Get all plugin configs for a specific stateKey\r\n getPluginConfigsForState: (stateKey: string) => Array<{\r\n plugin: CogsPlugin<any, any, any, any, any>;\r\n options: any;\r\n }>;\r\n updateSubscribers: Set<(update: UpdateTypeDetail) => void>;\r\n subscribeToUpdates: (\r\n callback: (update: UpdateTypeDetail) => void\r\n ) => () => void;\r\n notifyUpdate: (update: UpdateTypeDetail) => void;\r\n formUpdateSubscribers: Set<(event: ClientActivityEvent) => void>;\r\n subscribeToFormUpdates: (\r\n callback: (event: ClientActivityEvent) => void\r\n ) => () => void;\r\n notifyFormUpdate: (event: ClientActivityEvent) => void;\r\n hookResults: Map<string, Map<string, any>>; // stateKey -> pluginName -> hook\r\n setHookResult: (stateKey: string, pluginName: string, data: any) => void;\r\n getHookResult: (stateKey: string, pluginName: string) => any | undefined;\r\n removeHookResult: (stateKey: string, pluginName: string) => void;\r\n};\r\n\r\nexport const pluginStore = create<PluginRegistryStore>((set, get) => ({\r\n stateHandlers: new Map(),\r\n registerStateHandler: (stateKey, handler) =>\r\n set((state) => {\r\n const newMap = new Map(state.stateHandlers);\r\n newMap.set(stateKey, handler);\r\n console.log('addign handler', stateKey, handler);\r\n return { stateHandlers: newMap };\r\n }),\r\n registeredPlugins: [],\r\n pluginOptions: new Map(),\r\n\r\n setRegisteredPlugins: (plugins) => set({ registeredPlugins: plugins }),\r\n\r\n setPluginOptionsForState: (stateKey, pluginOptions) =>\r\n set((state) => {\r\n const newMap = new Map(state.pluginOptions);\r\n const statePluginMap = new Map();\r\n\r\n // Store each plugin's options\r\n Object.entries(pluginOptions).forEach(([pluginName, options]) => {\r\n // Only store if this is actually a registered plugin\r\n if (state.registeredPlugins.some((p) => p.name === pluginName)) {\r\n statePluginMap.set(pluginName, options);\r\n }\r\n });\r\n\r\n if (statePluginMap.size > 0) {\r\n newMap.set(stateKey, statePluginMap);\r\n }\r\n\r\n return { pluginOptions: newMap };\r\n }),\r\n\r\n getPluginConfigsForState: (stateKey) => {\r\n const state = get();\r\n const stateOptions = state.pluginOptions.get(stateKey);\r\n if (!stateOptions) return [];\r\n\r\n return state.registeredPlugins\r\n .map((plugin) => {\r\n const options = stateOptions.get(plugin.name);\r\n if (options !== undefined) {\r\n return { plugin, options };\r\n }\r\n return null;\r\n })\r\n .filter(Boolean) as Array<{\r\n plugin: CogsPlugin<any, any, any, any, any>;\r\n options: any;\r\n }>;\r\n },\r\n updateSubscribers: new Set(),\r\n subscribeToUpdates: (callback) => {\r\n const subscribers = get().updateSubscribers;\r\n subscribers.add(callback);\r\n // Return an unsubscribe function\r\n return () => {\r\n get().updateSubscribers.delete(callback);\r\n };\r\n },\r\n notifyUpdate: (update) => {\r\n // Call all registered subscribers with the update details\r\n get().updateSubscribers.forEach((callback) => callback(update));\r\n },\r\n formUpdateSubscribers: new Set(),\r\n subscribeToFormUpdates: (callback) => {\r\n const subscribers = get().formUpdateSubscribers;\r\n subscribers.add(callback);\r\n return () => {\r\n get().formUpdateSubscribers.delete(callback);\r\n };\r\n },\r\n notifyFormUpdate: (event) => {\r\n get().formUpdateSubscribers.forEach((callback) => callback(event));\r\n },\r\n hookResults: new Map(),\r\n\r\n setHookResult: (stateKey, pluginName, data) =>\r\n set((state) => {\r\n const next = new Map(state.hookResults);\r\n const byPlugin = new Map(next.get(stateKey) ?? new Map());\r\n if (data === undefined) byPlugin.delete(pluginName);\r\n else byPlugin.set(pluginName, data);\r\n if (byPlugin.size > 0) next.set(stateKey, byPlugin);\r\n else next.delete(stateKey);\r\n return { hookResults: next };\r\n }),\r\n\r\n getHookResult: (stateKey, pluginName) =>\r\n get().hookResults.get(stateKey)?.get(pluginName),\r\n\r\n removeHookResult: (stateKey, pluginName) =>\r\n set((state) => {\r\n const next = new Map(state.hookResults);\r\n const byPlugin = new Map(next.get(stateKey) ?? new Map());\r\n byPlugin.delete(pluginName);\r\n if (byPlugin.size > 0) next.set(stateKey, byPlugin);\r\n else next.delete(stateKey);\r\n return { hookResults: next };\r\n }),\r\n}));\r\n"],"names":["pluginStore","create","set","get","stateKey","handler","state","newMap","plugins","pluginOptions","statePluginMap","pluginName","options","p","stateOptions","plugin","callback","update","event","data","next","byPlugin"],"mappings":";AA0EO,MAAMA,IAAcC,EAA4B,CAACC,GAAKC,OAAS;AAAA,EACpE,mCAAmB,IAAA;AAAA,EACnB,sBAAsB,CAACC,GAAUC,MAC/BH,EAAI,CAACI,MAAU;AACb,UAAMC,IAAS,IAAI,IAAID,EAAM,aAAa;AAC1C,WAAAC,EAAO,IAAIH,GAAUC,CAAO,GAC5B,QAAQ,IAAI,kBAAkBD,GAAUC,CAAO,GACxC,EAAE,eAAeE,EAAA;AAAA,EAC1B,CAAC;AAAA,EACH,mBAAmB,CAAA;AAAA,EACnB,mCAAmB,IAAA;AAAA,EAEnB,sBAAsB,CAACC,MAAYN,EAAI,EAAE,mBAAmBM,GAAS;AAAA,EAErE,0BAA0B,CAACJ,GAAUK,MACnCP,EAAI,CAACI,MAAU;AACb,UAAMC,IAAS,IAAI,IAAID,EAAM,aAAa,GACpCI,wBAAqB,IAAA;AAG3B,kBAAO,QAAQD,CAAa,EAAE,QAAQ,CAAC,CAACE,GAAYC,CAAO,MAAM;AAE/D,MAAI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