@fgv/ts-res-ui-components 5.1.0-2 → 5.1.0-21
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/lib/components/common/AppHeader.d.ts.map +1 -0
- package/lib/components/common/AppHeader.js.map +1 -0
- package/lib/components/common/AppLayout.d.ts.map +1 -0
- package/lib/components/common/AppLayout.js.map +1 -0
- package/lib/components/common/AppSidebar.d.ts.map +1 -0
- package/lib/components/common/AppSidebar.js.map +1 -0
- package/lib/components/common/NavigationWarningModal.d.ts.map +1 -0
- package/lib/components/common/NavigationWarningModal.js.map +1 -0
- package/lib/components/common/QualifierContextControl.d.ts.map +1 -0
- package/lib/components/common/QualifierContextControl.js.map +1 -0
- package/lib/components/common/ResolutionContextOptionsControl.d.ts.map +1 -0
- package/lib/components/common/ResolutionContextOptionsControl.js.map +1 -0
- package/lib/components/common/ResolutionResults/index.d.ts.map +1 -0
- package/lib/components/common/ResolutionResults/index.js.map +1 -0
- package/lib/components/common/ResourceListView.d.ts.map +1 -0
- package/lib/components/common/ResourceListView.js.map +1 -0
- package/lib/components/common/ResourcePickerOptionsControl.d.ts.map +1 -0
- package/lib/components/common/ResourcePickerOptionsControl.js.map +1 -0
- package/lib/components/common/ResourceTreeView.d.ts.map +1 -0
- package/lib/components/common/ResourceTreeView.js.map +1 -0
- package/lib/components/common/SourceResourceDetail/index.d.ts.map +1 -0
- package/lib/components/common/SourceResourceDetail/index.js.map +1 -0
- package/lib/components/forms/GenericQualifierTypeEditForm.d.ts.map +1 -0
- package/lib/components/forms/GenericQualifierTypeEditForm.js.map +1 -0
- package/lib/components/forms/HierarchyEditor.d.ts.map +1 -0
- package/lib/components/forms/HierarchyEditor.js.map +1 -0
- package/lib/components/forms/QualifierEditForm.d.ts.map +1 -0
- package/lib/components/forms/QualifierEditForm.js.map +1 -0
- package/lib/components/forms/QualifierTypeEditForm.d.ts.map +1 -0
- package/lib/components/forms/QualifierTypeEditForm.js.map +1 -0
- package/lib/components/forms/ResourceTypeEditForm.d.ts.map +1 -0
- package/lib/components/forms/ResourceTypeEditForm.js.map +1 -0
- package/lib/components/forms/index.d.ts.map +1 -0
- package/lib/components/forms/index.js.map +1 -0
- package/lib/components/orchestrator/ResourceOrchestrator.d.ts.map +1 -0
- package/lib/components/orchestrator/ResourceOrchestrator.js.map +1 -0
- package/lib/components/pickers/ResourcePicker/ResourceItem.d.ts.map +1 -0
- package/lib/components/pickers/ResourcePicker/ResourceItem.js.map +1 -0
- package/lib/components/pickers/ResourcePicker/ResourcePickerList.d.ts.map +1 -0
- package/lib/components/pickers/ResourcePicker/ResourcePickerList.js.map +1 -0
- package/lib/components/pickers/ResourcePicker/ResourcePickerTree.d.ts.map +1 -0
- package/lib/components/pickers/ResourcePicker/ResourcePickerTree.js.map +1 -0
- package/lib/components/pickers/ResourcePicker/index.d.ts.map +1 -0
- package/lib/components/pickers/ResourcePicker/index.js.map +1 -0
- package/lib/components/pickers/ResourcePicker/types.d.ts.map +1 -0
- package/lib/components/pickers/ResourcePicker/types.js.map +1 -0
- package/lib/components/pickers/ResourcePicker/utils/treeNavigation.d.ts.map +1 -0
- package/lib/components/pickers/ResourcePicker/utils/treeNavigation.js.map +1 -0
- package/lib/components/views/CompiledView/index.d.ts.map +1 -0
- package/lib/components/views/CompiledView/index.js.map +1 -0
- package/lib/components/views/ConfigurationView/index.d.ts.map +1 -0
- package/lib/components/views/ConfigurationView/index.js.map +1 -0
- package/lib/components/views/FilterView/index.d.ts.map +1 -0
- package/lib/components/views/FilterView/index.js.map +1 -0
- package/lib/components/views/GridView/EditableGridCell.d.ts.map +1 -0
- package/lib/components/views/GridView/EditableGridCell.js.map +1 -0
- package/lib/components/views/GridView/GridSelector.d.ts.map +1 -0
- package/lib/components/views/GridView/GridSelector.js.map +1 -0
- package/lib/components/views/GridView/MultiGridView.d.ts.map +1 -0
- package/lib/components/views/GridView/MultiGridView.js.map +1 -0
- package/lib/components/views/GridView/ResourceGrid.d.ts.map +1 -0
- package/lib/components/views/GridView/ResourceGrid.js.map +1 -0
- package/lib/components/views/GridView/SharedContextControls.d.ts.map +1 -0
- package/lib/components/views/GridView/SharedContextControls.js.map +1 -0
- package/lib/components/views/GridView/cells/BooleanCell.d.ts.map +1 -0
- package/lib/components/views/GridView/cells/BooleanCell.js.map +1 -0
- package/lib/components/views/GridView/cells/DropdownCell.d.ts.map +1 -0
- package/lib/components/views/GridView/cells/DropdownCell.js.map +1 -0
- package/lib/components/views/GridView/cells/StringCell.d.ts.map +1 -0
- package/lib/components/views/GridView/cells/StringCell.js.map +1 -0
- package/lib/components/views/GridView/cells/TriStateCell.d.ts.map +1 -0
- package/lib/components/views/GridView/cells/TriStateCell.js.map +1 -0
- package/lib/components/views/GridView/cells/index.d.ts.map +1 -0
- package/lib/components/views/GridView/cells/index.js.map +1 -0
- package/lib/components/views/GridView/index.d.ts.map +1 -0
- package/lib/components/views/GridView/index.js.map +1 -0
- package/lib/components/views/ImportView/index.d.ts.map +1 -0
- package/lib/components/views/ImportView/index.js.map +1 -0
- package/lib/components/views/MessagesWindow/index.d.ts.map +1 -0
- package/lib/components/views/MessagesWindow/index.js.map +1 -0
- package/lib/components/views/ResolutionView/EditableJsonView.d.ts.map +1 -0
- package/lib/components/views/ResolutionView/EditableJsonView.js.map +1 -0
- package/lib/components/views/ResolutionView/NewResourceModal.d.ts.map +1 -0
- package/lib/components/views/ResolutionView/NewResourceModal.js.map +1 -0
- package/lib/components/views/ResolutionView/UnifiedChangeControls.d.ts.map +1 -0
- package/lib/components/views/ResolutionView/UnifiedChangeControls.js.map +1 -0
- package/lib/components/views/ResolutionView/index.d.ts.map +1 -0
- package/lib/components/views/ResolutionView/index.js.map +1 -0
- package/lib/components/views/SourceView/index.d.ts.map +1 -0
- package/lib/components/views/SourceView/index.js.map +1 -0
- package/lib/contexts/ObservabilityContext.d.ts.map +1 -0
- package/lib/contexts/ObservabilityContext.js.map +1 -0
- package/lib/contexts/index.d.ts.map +1 -0
- package/lib/contexts/index.js.map +1 -0
- package/lib/hooks/index.d.ts.map +1 -0
- package/lib/hooks/index.js.map +1 -0
- package/lib/hooks/useConfigurationState.d.ts.map +1 -0
- package/lib/hooks/useConfigurationState.js.map +1 -0
- package/lib/hooks/useFilterState.d.ts.map +1 -0
- package/lib/hooks/useFilterState.js.map +1 -0
- package/lib/hooks/useNavigationWarning.d.ts.map +1 -0
- package/lib/hooks/useNavigationWarning.js.map +1 -0
- package/lib/hooks/useResolutionState.d.ts.map +1 -0
- package/lib/hooks/useResolutionState.js.map +1 -0
- package/lib/hooks/useResourceData.d.ts.map +1 -0
- package/lib/hooks/useResourceData.js.map +1 -0
- package/lib/hooks/useSmartObservability.d.ts.map +1 -0
- package/lib/hooks/useSmartObservability.js.map +1 -0
- package/lib/hooks/useUrlParams.d.ts.map +1 -0
- package/lib/hooks/useUrlParams.js.map +1 -0
- package/lib/hooks/useViewState.d.ts.map +1 -0
- package/lib/hooks/useViewState.js.map +1 -0
- package/lib/index.browser.d.ts.map +1 -0
- package/lib/index.browser.js.map +1 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js.map +1 -0
- package/lib/namespaces/ConfigurationTools.d.ts.map +1 -0
- package/lib/namespaces/ConfigurationTools.js.map +1 -0
- package/lib/namespaces/DownloadTools.d.ts.map +1 -0
- package/lib/namespaces/DownloadTools.js.map +1 -0
- package/lib/namespaces/FilterTools.d.ts.map +1 -0
- package/lib/namespaces/FilterTools.js.map +1 -0
- package/lib/namespaces/GridTools.d.ts.map +1 -0
- package/lib/namespaces/GridTools.js.map +1 -0
- package/lib/namespaces/ImportTools.d.ts.map +1 -0
- package/lib/namespaces/ImportTools.js.map +1 -0
- package/lib/namespaces/ObservabilityTools.d.ts.map +1 -0
- package/lib/namespaces/ObservabilityTools.js.map +1 -0
- package/lib/namespaces/PickerTools.d.ts.map +1 -0
- package/lib/namespaces/PickerTools.js.map +1 -0
- package/lib/namespaces/ResolutionTools.d.ts.map +1 -0
- package/lib/namespaces/ResolutionTools.js.map +1 -0
- package/lib/namespaces/ResourceTools.d.ts.map +1 -0
- package/lib/namespaces/ResourceTools.js.map +1 -0
- package/lib/namespaces/TsResTools.d.ts.map +1 -0
- package/lib/namespaces/TsResTools.js.map +1 -0
- package/lib/namespaces/ViewStateTools.d.ts.map +1 -0
- package/lib/namespaces/ViewStateTools.js.map +1 -0
- package/lib/namespaces/ZipTools.d.ts.map +1 -0
- package/lib/namespaces/ZipTools.js.map +1 -0
- package/lib/namespaces/index.d.ts.map +1 -0
- package/lib/namespaces/index.js.map +1 -0
- package/lib/tsdoc-metadata.json +1 -1
- package/lib/types/index.d.ts.map +1 -0
- package/lib/types/index.js.map +1 -0
- package/lib/utils/cellValidation.d.ts.map +1 -0
- package/lib/utils/cellValidation.js.map +1 -0
- package/lib/utils/configurationUtils.d.ts.map +1 -0
- package/lib/utils/configurationUtils.js.map +1 -0
- package/lib/utils/downloadHelper.d.ts.map +1 -0
- package/lib/utils/downloadHelper.js.map +1 -0
- package/lib/utils/filterResources.d.ts.map +1 -0
- package/lib/utils/filterResources.js.map +1 -0
- package/lib/utils/observability/factories.d.ts.map +1 -0
- package/lib/utils/observability/factories.js.map +1 -0
- package/lib/utils/observability/implementations.d.ts.map +1 -0
- package/lib/utils/observability/implementations.js.map +1 -0
- package/lib/utils/observability/index.d.ts.map +1 -0
- package/lib/utils/observability/index.js.map +1 -0
- package/lib/utils/observability/interfaces.d.ts.map +1 -0
- package/lib/utils/observability/interfaces.js.map +1 -0
- package/lib/utils/resolutionEditing.d.ts.map +1 -0
- package/lib/utils/resolutionEditing.js.map +1 -0
- package/lib/utils/resolutionUtils.d.ts.map +1 -0
- package/lib/utils/resolutionUtils.js.map +1 -0
- package/lib/utils/resourceSelector.d.ts.map +1 -0
- package/lib/utils/resourceSelector.js.map +1 -0
- package/lib/utils/resourceSelectors.d.ts.map +1 -0
- package/lib/utils/resourceSelectors.js.map +1 -0
- package/lib/utils/tsResIntegration.d.ts.map +1 -0
- package/lib/utils/tsResIntegration.js.map +1 -0
- package/lib/utils/zipLoader/index.d.ts.map +1 -0
- package/lib/utils/zipLoader/index.js.map +1 -0
- package/lib/utils/zipLoader/zipProcessingHelpers.d.ts.map +1 -0
- package/lib/utils/zipLoader/zipProcessingHelpers.js.map +1 -0
- package/lib/utils/zipLoader/zipUtils.d.ts.map +1 -0
- package/lib/utils/zipLoader/zipUtils.js.map +1 -0
- package/package.json +25 -23
- package/dist/ts-res-ui-components.d.ts +0 -6795
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/observability/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAUH,uCAAuC;AACvC,OAAO,EACL,iBAAiB,EACjB,cAAc,EACd,mBAAmB,EACnB,eAAe,EACf,oBAAoB,EACpB,8BAA8B,EAC9B,oBAAoB,EACpB,oBAAoB,EACrB,MAAM,mBAAmB,CAAC;AAG3B,mBAAmB;AACnB,OAAO,EACL,iCAAiC,EACjC,8BAA8B,EAC9B,8BAA8B,EAC9B,mCAAmC,EACnC,2BAA2B,EAC3B,wBAAwB,EACzB,MAAM,aAAa,CAAC","sourcesContent":["/*\n * Copyright (c) 2025 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\n// Export interfaces\nexport type {\n IUserLogger,\n IUserLogReporter,\n IObservabilityContext,\n IObservabilityPolicy\n} from './interfaces';\n\n// Export implementations and utilities\nexport {\n ConsoleUserLogger,\n NoOpUserLogger,\n ViewStateUserLogger,\n UserLogReporter,\n ObservabilityContext,\n detectObservabilityContextType,\n isViewStateConnected,\n isConsoleOnlyContext\n} from './implementations';\nexport type { ObservabilityContextType } from './implementations';\n\n// Export factories\nexport {\n createConsoleObservabilityContext,\n createNoOpObservabilityContext,\n createTestObservabilityContext,\n createViewStateObservabilityContext,\n DefaultObservabilityContext,\n TestObservabilityContext\n} from './factories';\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../../../src/utils/observability/interfaces.ts"],"names":[],"mappings":"AAsBA,OAAO,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAEvE;;;GAGG;AACH,MAAM,WAAW,oBAAoB;IACnC;;;OAGG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB;AAED;;;GAGG;AACH,MAAM,WAAW,WAAY,SAAQ,OAAO,CAAC,OAAO;IAClD;;;;;;OAMG;IACH,OAAO,CAAC,OAAO,CAAC,EAAE,OAAO,EAAE,GAAG,UAAU,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;CACnF;AAED;;;GAGG;AACH,MAAM,WAAW,gBAAiB,SAAQ,WAAW,EAAE,eAAe,CAAC,OAAO,CAAC;CAAG;AAElF;;;GAGG;AACH,MAAM,WAAW,qBAAqB;IACpC;;OAEG;IACH,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;IAE5C;;OAEG;IACH,QAAQ,CAAC,IAAI,EAAE,gBAAgB,CAAC;IAEhC;;OAEG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,oBAAoB,CAAC;CACxC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../src/utils/observability/interfaces.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG","sourcesContent":["/*\n * Copyright (c) 2025 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport type { Logging, Success, IResultReporter } from '@fgv/ts-utils';\n\n/**\n * Policy configuration for observability context behavior.\n * @public\n */\nexport interface IObservabilityPolicy {\n /**\n * If true, prevents automatic upgrade of the context (e.g., in tests).\n * Default (undefined or false) allows upgrade.\n */\n doNotUpgrade?: boolean;\n}\n\n/**\n * User logger interface that extends ILogger with success method for UI feedback.\n * @public\n */\nexport interface IUserLogger extends Logging.ILogger {\n /**\n * Logs a success message for user feedback.\n * @param message - The message to log.\n * @param parameters - The parameters to log.\n * @returns `Success` with the logged message if the level is enabled, or\n * `Success` with `undefined` if the message is suppressed.\n */\n success(message?: unknown, ...parameters: unknown[]): Success<string | undefined>;\n}\n\n/**\n * User log reporter interface that combines IUserLogger with IResultReporter.\n * @public\n */\nexport interface IUserLogReporter extends IUserLogger, IResultReporter<unknown> {}\n\n/**\n * Observability context that provides both diagnostic and user logging capabilities.\n * @public\n */\nexport interface IObservabilityContext {\n /**\n * Diagnostic logger for internal system diagnostics.\n */\n readonly diag: Logging.LogReporter<unknown>;\n\n /**\n * User logger for user-facing messages and feedback.\n */\n readonly user: IUserLogReporter;\n\n /**\n * Optional policy configuration for context behavior.\n */\n readonly policy?: IObservabilityPolicy;\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolutionEditing.d.ts","sourceRoot":"","sources":["../../src/utils/resolutionEditing.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAiB,MAAM,eAAe,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAG/D,OAAO,EAAE,mBAAmB,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAE1D,MAAM,WAAW,mBAAmB;IAClC,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,EAAE,SAAS,CAAC;IACzB,WAAW,EAAE,SAAS,CAAC;IACvB,SAAS,EAAE,IAAI,CAAC;CACjB;AAED,MAAM,WAAW,qBAAqB;IACpC,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,WAAW,EAAE,SAAS,GAAG,qBAAqB,CAuBpF;AAED;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CACl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E,IAAI,cAAc,CAAC,SAAS,EAAE,EAAE,CAAC;gBAC/B,MAAM,QAAQ,GAAG,cAAc,CAAC,KAAK,CAAC;gBAEtC,6CAA6C;gBAC7C,IAAI,QAAQ,CAAC,UAAU,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;oBACnC,QAAQ,CAAC,IAAI,CACX,YAAY,UAAU,QAAQ,QAAQ,CAAC,UAAU,CAAC,MAAM,0CAA0C,CACnG,CAAC;gBACJ,CAAC;gBAED,uDAAuD;gBACvD,sCAAsC;YACxC,CAAC;QACH,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,qCAAqC;QACvC,CAAC;IACH,CAAC;IAED,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,CAAC;AACjC,CAAC","sourcesContent":["import { Result, succeed, fail } from '@fgv/ts-utils';\nimport { ResourceJson, Resources, Runtime } from '@fgv/ts-res';\nimport { Diff } from '@fgv/ts-json';\nimport { JsonObject, isJsonObject } from '@fgv/ts-json-base';\nimport { IProcessedResources, JsonValue } from '../types';\n\nexport interface IEditedResourceInfo {\n resourceId: string;\n originalValue: JsonValue;\n editedValue: JsonValue;\n timestamp: Date;\n}\n\nexport interface IEditValidationResult {\n isValid: boolean;\n errors: string[];\n warnings: string[];\n}\n\n/**\n * Validates an edited resource JSON value\n */\nexport function validateEditedResource(editedValue: JsonValue): IEditValidationResult {\n const errors: string[] = [];\n const warnings: string[] = [];\n\n // Basic JSON validation\n if (editedValue === null || editedValue === undefined) {\n errors.push('Resource value cannot be null or undefined');\n }\n\n // Check if it's valid JSON-serializable\n try {\n JSON.stringify(editedValue);\n } catch (error) {\n errors.push(`Invalid JSON: ${error instanceof Error ? error.message : 'Unknown error'}`);\n }\n\n // Intentionally minimal validation – structural only. No circular checks.\n\n return {\n isValid: errors.length === 0,\n errors,\n warnings\n };\n}\n\n/**\n * Computes a 3-way diff between base, resolved, and edited values to create minimal delta\n * @param baseValue - The base/original value before resolution (if available)\n * @param resolvedValue - The fully resolved/composed value shown to user\n * @param editedValue - The value after user edits\n * @returns A minimal delta object with only the changes, or null if no changes\n */\nexport function computeResourceDelta(\n baseValue: JsonValue | undefined,\n resolvedValue: JsonValue,\n editedValue: JsonValue\n): Result<JsonValue> {\n // Use ts-json's three-way diff for proper delta computation\n const diffResult = Diff.jsonThreeWayDiff(resolvedValue, editedValue);\n\n if (diffResult.isFailure()) {\n // Fall back to full replacement on diff failure\n console.error('Failed to compute three-way diff:', diffResult.message);\n return succeed(editedValue);\n }\n\n const diff = diffResult.value;\n\n // If identical, no changes needed\n if (diff.identical) {\n return succeed(null);\n }\n\n // Build a proper delta that includes deletions as null values\n const delta: Record<string, JsonValue> = {};\n\n // Add all changes/additions from onlyInB\n if (diff.onlyInB !== null) {\n Object.assign(delta, diff.onlyInB);\n }\n\n // Add deletions as null values from onlyInA\n // onlyInA contains properties that existed in resolved but not in edited\n if (diff.onlyInA !== null) {\n // Add null entries for all deleted properties\n addDeletionsAsNull(diff.onlyInA, delta);\n }\n\n // If delta is empty, no changes\n if (Object.keys(delta).length === 0) {\n return succeed(null);\n }\n\n return succeed(delta);\n}\n\n/**\n * Recursively adds null values to delta for all properties in the deleted object\n */\nfunction addDeletionsAsNull(deleted: JsonValue, delta: Record<string, JsonValue>): void {\n if (isJsonObject(deleted)) {\n const deletedObj = deleted as Record<string, JsonValue>;\n for (const key in deletedObj) {\n if (deletedObj.hasOwnProperty(key)) {\n // If this key already exists in delta (from onlyInB), it means the property\n // was modified, not deleted, so don't override with null\n if (!(key in delta)) {\n delta[key] = null;\n }\n }\n }\n }\n}\n\n/**\n * Creates candidate declarations for edited resources with proper delta handling\n */\nexport function createCandidateDeclarations(\n editedResources: Map<string, { originalValue: JsonValue; editedValue: JsonValue; delta: JsonValue }>,\n currentContext: Record<string, string>\n): ResourceJson.Json.ILooseResourceCandidateDecl[] {\n const declarations: ResourceJson.Json.ILooseResourceCandidateDecl[] = [];\n\n for (const [resourceId, resourceEdit] of editedResources.entries()) {\n // Create conditions from current context (using array format)\n const conditions: ResourceJson.Json.ILooseConditionDecl[] = [];\n\n for (const [qualifierName, qualifierValue] of Object.entries(currentContext)) {\n if (qualifierValue && qualifierValue.trim() !== '') {\n conditions.push({\n qualifierName,\n operator: 'matches',\n value: qualifierValue\n });\n }\n }\n\n // Always use the delta if we have one (which should be the minimal changes)\n // The delta will be null if there are no changes, or the delta itself if there are changes\n const hasChanges = resourceEdit.delta !== null && resourceEdit.delta !== undefined;\n\n if (!hasChanges) {\n // No changes, skip this resource\n continue;\n }\n\n // Always save as partial with just the delta when we have changes\n // This ensures minimal, clean resource files\n declarations.push({\n id: resourceId,\n conditions: conditions.length > 0 ? conditions : undefined,\n json: resourceEdit.delta as JsonObject, // Always use the delta (minimal changes only)\n isPartial: true, // Always partial when saving deltas\n mergeMethod: 'augment' // Always augment to merge the delta with base\n });\n }\n\n return declarations;\n}\n\n/**\n * Converts loose resource declarations (new resources) into loose candidate declarations\n * that can be applied via ResourceManagerBuilder.clone.\n */\nexport function convertLooseResourcesToCandidateDecls(\n newResources: ReadonlyArray<ResourceJson.Json.ILooseResourceDecl>\n): ResourceJson.Json.ILooseResourceCandidateDecl[] {\n const candidates: ResourceJson.Json.ILooseResourceCandidateDecl[] = [];\n\n for (const resource of newResources) {\n const resourceTypeName = resource.resourceTypeName;\n // Skip if no candidates defined\n const childCandidates = resource.candidates ?? [];\n if (childCandidates.length === 0) {\n continue;\n }\n\n for (const c of childCandidates) {\n candidates.push({\n id: resource.id,\n json: (c.json ?? {}) as JsonObject,\n conditions: c.conditions,\n isPartial: c.isPartial ?? false,\n mergeMethod: c.mergeMethod ?? 'replace',\n resourceTypeName\n });\n }\n }\n\n return candidates;\n}\n\n/**\n * Rebuilds the resource system by applying both edit candidates and\n * new resource candidates in a single clone → compile → resolver pass.\n */\nexport async function rebuildSystemWithChanges(\n originalSystem: IProcessedResources['system'],\n options: {\n editedResources?: Map<string, { originalValue: JsonValue; editedValue: JsonValue; delta: JsonValue }>;\n newResources?: ReadonlyArray<ResourceJson.Json.ILooseResourceDecl>;\n },\n currentContext: Record<string, string>\n): Promise<Result<IProcessedResources>> {\n try {\n const editCandidates = options.editedResources\n ? createCandidateDeclarations(options.editedResources, currentContext)\n : [];\n const newResourceCandidates = options.newResources\n ? convertLooseResourcesToCandidateDecls(options.newResources)\n : [];\n\n const allCandidates: ReadonlyArray<ResourceJson.Json.ILooseResourceCandidateDecl> = [\n ...editCandidates,\n ...newResourceCandidates\n ];\n\n return originalSystem.resourceManager\n .clone({ candidates: allCandidates })\n .withErrorFormat((message: string) => `Failed to clone manager: ${message}`)\n .onSuccess((clonedManager: Resources.ResourceManagerBuilder) => {\n return clonedManager\n .getCompiledResourceCollection({ includeMetadata: true })\n .withErrorFormat((message: string) => `Failed to get compiled collection: ${message}`)\n .onSuccess((compiledCollection: ResourceJson.Compiled.ICompiledResourceCollection) => {\n return Runtime.ResourceResolver.create({\n resourceManager: clonedManager,\n qualifierTypes: originalSystem.qualifierTypes,\n contextQualifierProvider: originalSystem.contextQualifierProvider\n })\n .withErrorFormat((message) => `Failed to create resolver: ${message}`)\n .onSuccess((resolver) => {\n const resourceIds = Array.from(clonedManager.resources.keys()) as string[];\n const summary = {\n totalResources: resourceIds.length,\n resourceIds,\n errorCount: 0,\n warnings: []\n };\n\n const updatedSystem: IProcessedResources = {\n system: {\n qualifierTypes: originalSystem.qualifierTypes,\n qualifiers: originalSystem.qualifiers,\n resourceTypes: originalSystem.resourceTypes,\n resourceManager: clonedManager,\n importManager: originalSystem.importManager,\n contextQualifierProvider: originalSystem.contextQualifierProvider\n },\n compiledCollection,\n resolver,\n resourceCount: resourceIds.length,\n summary\n };\n\n return succeed(updatedSystem);\n });\n });\n });\n } catch (error) {\n return fail(\n `Failed to rebuild system with changes: ${error instanceof Error ? error.message : String(error)}`\n );\n }\n}\n\n/**\n * Rebuilds the resource system with edited candidates using deltas\n */\nexport async function rebuildSystemWithEdits(\n originalSystem: IProcessedResources['system'],\n editedResources: Map<string, { originalValue: JsonValue; editedValue: JsonValue; delta: JsonValue }>,\n currentContext: Record<string, string>\n): Promise<Result<IProcessedResources>> {\n // Delegate to the unified change application helper\n return rebuildSystemWithChanges(originalSystem, { editedResources }, currentContext);\n}\n\n/**\n * Extracts the current resolution context from resolver state\n */\nexport function extractResolutionContext(\n resolver: Runtime.ResourceResolver,\n contextValues: Record<string, string | undefined>\n): Record<string, string> {\n // Filter out empty/undefined context values\n const cleanContext: Record<string, string> = {};\n\n for (const [key, value] of Object.entries(contextValues)) {\n if (value !== undefined) {\n cleanContext[key] = value.trim();\n }\n }\n\n return cleanContext;\n}\n\n/**\n * Creates a collision detection key for tracking edit conflicts\n */\nexport function createEditCollisionKey(resourceId: string, context: Record<string, string>): string {\n const contextEntries = Object.entries(context)\n .sort(([a], [b]) => a.localeCompare(b))\n .map(([key, value]) => `${key}=${value}`)\n .join('&');\n\n return `${resourceId}?${contextEntries}`;\n}\n\n/**\n * Checks for potential edit conflicts with existing candidates\n */\nexport function checkEditConflicts(\n resourceManager: Resources.ResourceManagerBuilder | Runtime.IResourceManager,\n editedResources: Map<string, JsonValue>,\n currentContext: Record<string, string>\n): { conflicts: string[]; warnings: string[] } {\n const conflicts: string[] = [];\n const warnings: string[] = [];\n\n for (const [resourceId] of editedResources) {\n try {\n // Get the current resource to check for conflicts\n const resourceResult = resourceManager.getBuiltResource(resourceId);\n if (resourceResult.isSuccess()) {\n const resource = resourceResult.value;\n\n // Check if we're likely to create a conflict\n if (resource.candidates.length > 1) {\n warnings.push(\n `Resource ${resourceId} has ${resource.candidates.length} candidates - edits may create conflicts`\n );\n }\n\n // Could add more sophisticated conflict detection here\n // based on condition overlap analysis\n }\n } catch (error) {\n // Ignore errors in conflict checking\n }\n }\n\n return { conflicts, warnings };\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolutionUtils.d.ts","sourceRoot":"","sources":["../../src/utils/resolutionUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,E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AU,wBAAwB,CACtC,aAAiD,EACjD,oBAAwD;IAExD,OAAO,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC,KAAK,IAAI,CAAC,SAAS,CAAC,oBAAoB,CAAC,CAAC;AAChF,CAAC","sourcesContent":["import { Result, succeed, fail, MessageAggregator } from '@fgv/ts-utils';\nimport { ResourceJson, Resources, Runtime } from '@fgv/ts-res';\nimport { IProcessedResources, IResolutionResult, ICandidateInfo, IConditionEvaluationResult } from '../types';\n\n/**\n * Configuration options for resource resolution operations.\n *\n * ResolutionOptions provides control over performance and debugging features\n * during resource resolution operations. These options affect resolver creation,\n * resolution processing, and diagnostic output.\n *\n * @example\n * ```typescript\n * import { ResolutionTools } from '@fgv/ts-res-ui-components';\n *\n * // Basic resolution with default options\n * const basicResolver = ResolutionTools.createResolverWithContext(\n * processedResources,\n * { language: 'en-US', platform: 'web' }\n * );\n *\n * // Resolution with caching enabled for performance\n * const cachedResolver = ResolutionTools.createResolverWithContext(\n * processedResources,\n * { language: 'en-US', region: 'US' },\n * { enableCaching: true }\n * );\n *\n * // Resolution with debugging for troubleshooting\n * const debugResolver = ResolutionTools.createResolverWithContext(\n * processedResources,\n * { language: 'fr-CA', platform: 'mobile' },\n * { enableDebugLogging: true }\n * );\n *\n * // Full-featured resolution with both caching and debugging\n * const fullResolver = ResolutionTools.createResolverWithContext(\n * processedResources,\n * { language: 'es-MX', region: 'MX', platform: 'desktop' },\n * { enableCaching: true, enableDebugLogging: true }\n * );\n * ```\n *\n * @public\n */\nexport interface IResolutionOptions {\n /** Enable caching for improved performance during repeated resolutions */\n enableCaching?: boolean;\n /** Enable detailed console logging for debugging resolution processes */\n enableDebugLogging?: boolean;\n}\n\n// Helper function for conditional debug logging\nconst debugLog = (enableDebug: boolean, ...args: unknown[]): void => {\n if (enableDebug) {\n console.log(...args);\n }\n};\n\n/**\n * Create a resolver with context for resource resolution.\n *\n * Creates a fully configured ResourceResolver with the specified context values\n * and options. The resolver can be used to resolve resources based on the provided\n * qualification context, with optional caching and debugging features.\n *\n * @param processedResources - The processed resource system containing all resources and configuration\n * @param contextValues - Context values for qualification (e.g., language, region, platform)\n * @param options - Configuration options for resolution behavior\n * @returns A Result containing the configured ResourceResolver or an error message\n *\n * @example\n * ```typescript\n * import { ResolutionTools } from '@fgv/ts-res-ui-components';\n *\n * // Basic resolver creation for web platform\n * const webResolver = ResolutionTools.createResolverWithContext(\n * processedResources,\n * {\n * language: 'en-US',\n * platform: 'web',\n * region: 'US'\n * }\n * );\n *\n * if (webResolver.isSuccess()) {\n * const resolver = webResolver.value;\n * // Use resolver to resolve resources...\n * }\n * ```\n *\n * @example\n * ```typescript\n * // Resolver with caching for performance-critical scenarios\n * const performanceResolver = ResolutionTools.createResolverWithContext(\n * processedResources,\n * {\n * language: 'fr-CA',\n * platform: 'mobile',\n * deviceType: 'tablet'\n * },\n * { enableCaching: true }\n * );\n * ```\n *\n * @example\n * ```typescript\n * // Resolver with debugging for troubleshooting resolution issues\n * const debugResolver = ResolutionTools.createResolverWithContext(\n * processedResources,\n * {\n * language: 'es-MX',\n * region: 'MX',\n * platform: 'desktop'\n * },\n * { enableDebugLogging: true }\n * ).onSuccess((resolver) => {\n * // Debug output will show context creation and resolver setup\n * console.log('Resolver created with debug logging enabled');\n * return succeed(resolver);\n * });\n * ```\n *\n * @public\n */\nexport function createResolverWithContext(\n processedResources: IProcessedResources,\n contextValues: Record<string, string | undefined>,\n options: IResolutionOptions = {}\n): Result<Runtime.ResourceResolver> {\n const enableDebug = options.enableDebugLogging === true;\n\n debugLog(enableDebug, '=== CREATING RESOLVER WITH CONTEXT ===');\n debugLog(enableDebug, 'Context values:', contextValues);\n\n // Create context provider with filtered values (remove undefined)\n const filteredContext = Object.fromEntries(\n Object.entries(contextValues).filter(([, value]) => value !== undefined)\n ) as Record<string, string>;\n\n return Runtime.ValidatingSimpleContextQualifierProvider.create({\n qualifiers: processedResources.system.qualifiers\n })\n .withErrorFormat((e) => `Failed to create context provider: ${e}`)\n .onSuccess((contextProvider) => {\n const errors = new MessageAggregator();\n // Set context values\n for (const [qualifierName, value] of Object.entries(filteredContext)) {\n contextProvider.validating\n .set(qualifierName, value)\n .withErrorFormat((e) => `Failed to set context value ${qualifierName}=${value}: ${e}`)\n .aggregateError(errors);\n }\n\n if (errors.hasMessages) {\n return fail(`Errors setting context values: ${errors.toString()}`);\n }\n\n // Create resolver\n const resolverParams: Runtime.IResourceResolverCreateParams = {\n resourceManager: processedResources.system.resourceManager,\n qualifierTypes: processedResources.system.qualifierTypes,\n contextQualifierProvider: contextProvider\n };\n\n // Add cache metrics listener if caching is enabled\n if (options.enableCaching) {\n const metricsListener = new Runtime.ResourceResolverCacheMetricsListener(\n () => new Runtime.AggregateCacheMetrics()\n );\n resolverParams.listener = metricsListener;\n }\n\n return Runtime.ResourceResolver.create(resolverParams)\n .withErrorFormat((e) => `Failed to create resolver: ${e}`)\n .onSuccess((resolver) => {\n debugLog(enableDebug, 'Resolver created successfully');\n return succeed(resolver);\n });\n });\n}\n\n/**\n * Evaluate conditions for a specific candidate and return detailed evaluation results.\n *\n * Analyzes how each condition in a candidate's condition set evaluates against the\n * current resolution context. This provides detailed insight into why a candidate\n * matches or doesn't match, including qualification values, condition operators,\n * match scores, and match types.\n *\n * @param resolver - The configured ResourceResolver with context\n * @param candidateIndex - Zero-based index of the candidate to evaluate\n * @param compiledResource - The compiled resource containing decision information\n * @param compiledCollection - The compiled collection with condition and qualifier data\n * @returns Array of condition evaluation results showing how each condition performed\n *\n * @example\n * ```typescript\n * import { ResolutionTools } from '@fgv/ts-res-ui-components';\n *\n * // Evaluate conditions for the first candidate of a resource\n * const resolver = ResolutionTools.createResolverWithContext(\n * processedResources,\n * { language: 'en-US', platform: 'web' }\n * ).orThrow();\n *\n * const compiledResource = processedResources.compiledCollection.resources\n * .find(r => r.id === 'welcome-message');\n *\n * const evaluations = ResolutionTools.evaluateConditionsForCandidate(\n * resolver,\n * 0, // First candidate\n * compiledResource,\n * processedResources.compiledCollection\n * );\n *\n * // Analyze the results\n * evaluations.forEach(evaluation => {\n * console.log(`${evaluation.qualifierName}: ${evaluation.qualifierValue} ${evaluation.operator} ${evaluation.conditionValue}`);\n * console.log(` Matched: ${evaluation.matched}, Score: ${evaluation.score}`);\n * });\n * ```\n *\n * @example\n * ```typescript\n * // Use in resolution analysis to understand candidate selection\n * function analyzeResourceResolution(resourceId: string) {\n * const resolver = ResolutionTools.createResolverWithContext(\n * processedResources,\n * getCurrentContext()\n * ).orThrow();\n *\n * const resource = processedResources.system.resourceManager\n * .getBuiltResource(resourceId).orThrow();\n *\n * const compiledResource = processedResources.compiledCollection.resources\n * .find(r => r.id === resourceId);\n *\n * // Evaluate all candidates\n * resource.candidates.forEach((candidate, index) => {\n * const evaluations = ResolutionTools.evaluateConditionsForCandidate(\n * resolver,\n * index,\n * compiledResource,\n * processedResources.compiledCollection\n * );\n *\n * console.log(`Candidate ${index}:`);\n * evaluations.forEach(eval => {\n * console.log(` ${eval.qualifierName}: ${eval.matched ? '✓' : '✗'} (${eval.score})`);\n * });\n * });\n * }\n * ```\n *\n * @public\n */\nexport function evaluateConditionsForCandidate(\n resolver: Runtime.ResourceResolver,\n candidateIndex: number,\n compiledResource: ResourceJson.Compiled.ICompiledResource,\n compiledCollection: ResourceJson.Compiled.ICompiledResourceCollection\n): IConditionEvaluationResult[] {\n try {\n const decision = compiledCollection.decisions[compiledResource.decision];\n if (!decision || !decision.conditionSets || candidateIndex >= decision.conditionSets.length) {\n return [];\n }\n\n const conditionSetIndex = decision.conditionSets[candidateIndex];\n const conditionSet = compiledCollection.conditionSets[conditionSetIndex];\n if (!conditionSet || !conditionSet.conditions) {\n return [];\n }\n\n const evaluations: IConditionEvaluationResult[] = [];\n\n for (const conditionIndex of conditionSet.conditions) {\n const condition = compiledCollection.conditions[conditionIndex];\n if (!condition) continue;\n\n const qualifier = compiledCollection.qualifiers[condition.qualifierIndex];\n if (!qualifier) continue;\n\n // Get the qualifier value from context\n const qualifierValueResult = resolver.contextQualifierProvider.get(qualifier.name);\n const qualifierValue = qualifierValueResult.orDefault();\n\n // Get the cached condition result from resolver (if available)\n const cachedResult = resolver.conditionCache?.[conditionIndex];\n const score = cachedResult?.score || 0;\n const matchType = cachedResult?.matchType || 'noMatch';\n const matched = matchType !== 'noMatch';\n\n evaluations.push({\n qualifierName: qualifier.name,\n qualifierValue,\n conditionValue: condition.value,\n operator: condition.operator || 'matches',\n score,\n matched,\n matchType,\n scoreAsDefault: condition.scoreAsDefault,\n conditionIndex\n });\n }\n\n return evaluations;\n } catch (error) {\n console.warn('Error evaluating conditions for candidate:', error);\n return [];\n }\n}\n\n/**\n * Resolve a resource and create detailed resolution result with comprehensive analysis.\n *\n * Performs complete resource resolution including best candidate selection, all candidate\n * analysis, composed value resolution, and detailed condition evaluation for each candidate.\n * This provides the most comprehensive view of how resource resolution works for a given\n * resource and context.\n *\n * @param resolver - The configured ResourceResolver with context\n * @param resourceId - The ID of the resource to resolve\n * @param processedResources - The processed resource system\n * @param options - Configuration options for resolution behavior\n * @returns A Result containing detailed resolution information or an error\n *\n * @example\n * ```typescript\n * import { ResolutionTools } from '@fgv/ts-res-ui-components';\n *\n * // Detailed resolution of a welcome message\n * const resolver = ResolutionTools.createResolverWithContext(\n * processedResources,\n * { language: 'en-US', platform: 'web', region: 'US' }\n * ).orThrow();\n *\n * const result = ResolutionTools.resolveResourceDetailed(\n * resolver,\n * 'welcome-message',\n * processedResources\n * );\n *\n * if (result.isSuccess() && result.value.success) {\n * const resolution = result.value;\n * console.log('Best candidate:', resolution.bestCandidate);\n * console.log('Composed value:', resolution.composedValue);\n *\n * // Analyze each candidate\n * resolution.candidateDetails.forEach((candidate, index) => {\n * console.log(`Candidate ${index}: ${candidate.matched ? 'MATCHED' : 'no match'}`);\n * candidate.conditionEvaluations.forEach(eval => {\n * console.log(` ${eval.qualifierName}: ${eval.matched ? '✓' : '✗'}`);\n * });\n * });\n * }\n * ```\n *\n * @example\n * ```typescript\n * // Resolution with debugging for troubleshooting\n * const debugResult = ResolutionTools.resolveResourceDetailed(\n * resolver,\n * 'error-messages',\n * processedResources,\n * { enableDebugLogging: true }\n * );\n *\n * // Debug output will show detailed resolution steps\n * ```\n *\n * @example\n * ```typescript\n * // Use in resolution testing workflow\n * async function testResourceResolution(resourceId: string, context: Record<string, string>) {\n * const resolver = ResolutionTools.createResolverWithContext(\n * processedResources,\n * context\n * ).orThrow();\n *\n * const result = ResolutionTools.resolveResourceDetailed(\n * resolver,\n * resourceId,\n * processedResources\n * );\n *\n * if (result.isSuccess() && result.value.success) {\n * const resolution = result.value;\n *\n * return {\n * resourceId,\n * context,\n * bestValue: resolution.bestCandidate?.value,\n * composedValue: resolution.composedValue,\n * matchedCandidates: resolution.candidateDetails.filter(c => c.matched).length,\n * totalCandidates: resolution.candidateDetails.length,\n * conditionAnalysis: resolution.candidateDetails.map(c => ({\n * matched: c.matched,\n * matchType: c.matchType,\n * conditions: c.conditionEvaluations.length\n * }))\n * };\n * }\n *\n * throw new Error(`Resolution failed: ${result.value.error}`);\n * }\n * ```\n *\n * @public\n */\nexport function resolveResourceDetailed(\n resolver: Runtime.ResourceResolver,\n resourceId: string,\n processedResources: IProcessedResources,\n options: IResolutionOptions = {}\n): Result<IResolutionResult> {\n const enableDebug = options.enableDebugLogging === true;\n\n debugLog(enableDebug, '=== RESOLVING RESOURCE ===');\n debugLog(enableDebug, 'Resource ID:', resourceId);\n\n const resourceResult = processedResources.system.resourceManager.getBuiltResource(resourceId);\n if (resourceResult.isFailure()) {\n return succeed({\n success: false,\n resourceId,\n error: `Failed to get resource: ${resourceResult.message}`\n });\n }\n\n const resource = resourceResult.value;\n const compiledCollection = processedResources.compiledCollection;\n\n // Find the compiled resource for condition analysis\n const compiledResource = compiledCollection.resources.find((r) => r.id === resourceId);\n if (!compiledResource) {\n return succeed({\n success: false,\n resourceId,\n error: 'Failed to find compiled resource'\n });\n }\n\n // Resolve best candidate\n const bestResult = resolver.resolveResource(resource);\n\n // Resolve all candidates\n const allResult = resolver.resolveAllResourceCandidates(resource);\n\n // Resolve composed value\n const composedResult = resolver.resolveComposedResourceValue(resource);\n\n // Get decision resolution result\n const decisionResult = resolver.resolveDecision(resource.decision.baseDecision);\n if (decisionResult.isFailure()) {\n return succeed({\n success: false,\n resourceId,\n error: `Failed to resolve decision: ${decisionResult.message}`\n });\n }\n\n const decision = decisionResult.value;\n\n // Build detailed candidate information\n const candidateDetails: ICandidateInfo[] = [];\n const matchedCandidates = allResult.isSuccess() ? allResult.value : [];\n\n // Create lookup sets for regular and default matches\n const regularMatchIndices = new Set(decision?.success ? decision.instanceIndices : []);\n const defaultMatchIndices = new Set(decision?.success ? decision.defaultInstanceIndices : []);\n\n // Add matched candidates first\n matchedCandidates.forEach((matchedCandidate) => {\n const index = resource.candidates.findIndex(\n (candidate: Resources.ResourceCandidate) => candidate === matchedCandidate\n );\n if (index !== -1) {\n const conditionSetKey = `cs-${index}`;\n const conditionEvaluations = evaluateConditionsForCandidate(\n resolver,\n index,\n compiledResource,\n compiledCollection\n );\n\n const isDefaultMatch = defaultMatchIndices.has(index);\n const isRegularMatch = regularMatchIndices.has(index);\n\n const candidateMatchType = isRegularMatch ? 'match' : isDefaultMatch ? 'matchAsDefault' : 'noMatch';\n\n candidateDetails.push({\n candidate: resource.candidates[index],\n conditionSetKey,\n candidateIndex: index,\n matched: true,\n matchType: candidateMatchType,\n isDefaultMatch,\n conditionEvaluations\n });\n }\n });\n\n // Add non-matching candidates\n resource.candidates.forEach((candidate: Resources.ResourceCandidate, index: number) => {\n const isMatched = matchedCandidates.some((mc) => mc === candidate);\n if (!isMatched) {\n // Handle different candidate formats - IResourceCandidate doesn't have conditions\n const conditionSetKey = candidate.conditions?.toHash ? candidate.conditions.toHash() : `cs-${index}`;\n const conditionEvaluations = evaluateConditionsForCandidate(\n resolver,\n index,\n compiledResource,\n compiledCollection\n );\n\n candidateDetails.push({\n candidate,\n conditionSetKey,\n candidateIndex: index,\n matched: false,\n matchType: 'noMatch',\n isDefaultMatch: false,\n conditionEvaluations\n });\n }\n });\n\n const result: IResolutionResult = {\n success: true,\n resourceId,\n resource,\n bestCandidate: bestResult.isSuccess() ? bestResult.value : undefined,\n allCandidates: allResult.isSuccess() ? allResult.value : undefined,\n candidateDetails,\n composedValue: composedResult.isSuccess() ? composedResult.value : undefined,\n error: bestResult.isFailure() ? bestResult.message : undefined\n };\n\n debugLog(enableDebug, 'Resolution completed successfully');\n return succeed(result);\n}\n\n/**\n * Get available qualifiers from processed resources.\n *\n * Extracts all qualifier names from the compiled resource collection, providing\n * a list of qualification dimensions available for context setting and resource\n * resolution. This is useful for building dynamic UI controls and validation.\n *\n * @param processedResources - The processed resource system\n * @returns Array of qualifier names available in the system\n *\n * @example\n * ```typescript\n * import { ResolutionTools } from '@fgv/ts-res-ui-components';\n *\n * // Get all available qualifiers for UI generation\n * const availableQualifiers = ResolutionTools.getAvailableQualifiers(processedResources);\n * console.log('Available qualifiers:', availableQualifiers);\n * // Output: ['language', 'region', 'platform', 'deviceType']\n *\n * // Use to build dynamic context controls\n * const contextControls = availableQualifiers.map(qualifierName => (\n * <QualifierContextControl\n * key={qualifierName}\n * qualifierName={qualifierName}\n * value={context[qualifierName]}\n * onChange={handleContextChange}\n * />\n * ));\n * ```\n *\n * @example\n * ```typescript\n * // Validate context against available qualifiers\n * function validateResolutionContext(\n * context: Record<string, string>,\n * processedResources: IProcessedResources\n * ): string[] {\n * const availableQualifiers = ResolutionTools.getAvailableQualifiers(processedResources);\n * const errors: string[] = [];\n *\n * // Check for unknown qualifiers\n * Object.keys(context).forEach(key => {\n * if (!availableQualifiers.includes(key)) {\n * errors.push(`Unknown qualifier: ${key}`);\n * }\n * });\n *\n * return errors;\n * }\n * ```\n *\n * @example\n * ```typescript\n * // Build qualifier documentation\n * function generateQualifierDocs(processedResources: IProcessedResources) {\n * const qualifiers = ResolutionTools.getAvailableQualifiers(processedResources);\n *\n * return qualifiers.map(name => {\n * const qualifier = processedResources.system.qualifiers.validating.get(name).orThrow();\n * return {\n * name,\n * type: qualifier.type.systemType,\n * description: `Controls ${name} resolution behavior`\n * };\n * });\n * }\n * ```\n *\n * @public\n */\nexport function getAvailableQualifiers(processedResources: IProcessedResources): string[] {\n if (processedResources.compiledCollection.qualifiers) {\n return processedResources.compiledCollection.qualifiers.map(\n (q: ResourceJson.Compiled.ICompiledQualifier) => q.name\n );\n }\n return [];\n}\n\n/**\n * Check if context has any pending changes by comparing current and pending values.\n *\n * Performs a deep comparison between current context values and pending context values\n * to determine if there are unsaved changes. This is useful for UI state management\n * and preventing data loss in resolution interfaces.\n *\n * @param contextValues - The current/saved context values\n * @param pendingContextValues - The pending/unsaved context values\n * @returns True if there are pending changes, false if contexts are identical\n *\n * @example\n * ```typescript\n * import { ResolutionTools } from '@fgv/ts-res-ui-components';\n *\n * // Check for unsaved context changes in resolution UI\n * const ResolutionInterface = () => {\n * const [savedContext, setSavedContext] = useState({\n * language: 'en-US',\n * platform: 'web'\n * });\n *\n * const [pendingContext, setPendingContext] = useState(savedContext);\n *\n * const hasChanges = ResolutionTools.hasPendingContextChanges(\n * savedContext,\n * pendingContext\n * );\n *\n * const handleApplyChanges = () => {\n * if (hasChanges) {\n * setSavedContext(pendingContext);\n * // Trigger re-resolution with new context...\n * }\n * };\n *\n * return (\n * <div>\n * {hasChanges && (\n * <div className=\"warning\">\n * You have unsaved context changes.\n * <button onClick={handleApplyChanges}>Apply Changes</button>\n * </div>\n * )}\n * </div>\n * );\n * };\n * ```\n *\n * @example\n * ```typescript\n * // Prevent navigation with unsaved changes\n * function useUnsavedChangesWarning(\n * currentContext: Record<string, string | undefined>,\n * pendingContext: Record<string, string | undefined>\n * ) {\n * const hasChanges = ResolutionTools.hasPendingContextChanges(\n * currentContext,\n * pendingContext\n * );\n *\n * useEffect(() => {\n * const handleBeforeUnload = (event: BeforeUnloadEvent) => {\n * if (hasChanges) {\n * event.preventDefault();\n * event.returnValue = 'You have unsaved context changes. Are you sure you want to leave?';\n * }\n * };\n *\n * window.addEventListener('beforeunload', handleBeforeUnload);\n * return () => window.removeEventListener('beforeunload', handleBeforeUnload);\n * }, [hasChanges]);\n *\n * return hasChanges;\n * }\n * ```\n *\n * @example\n * ```typescript\n * // Context change management in resolution workflow\n * class ResolutionContextManager {\n * private savedContext: Record<string, string | undefined> = {};\n * private pendingContext: Record<string, string | undefined> = {};\n *\n * updatePendingValue(qualifier: string, value: string | undefined) {\n * this.pendingContext = { ...this.pendingContext, [qualifier]: value };\n * }\n *\n * hasPendingChanges(): boolean {\n * return ResolutionTools.hasPendingContextChanges(\n * this.savedContext,\n * this.pendingContext\n * );\n * }\n *\n * applyChanges(): boolean {\n * if (this.hasPendingChanges()) {\n * this.savedContext = { ...this.pendingContext };\n * return true; // Changes were applied\n * }\n * return false; // No changes to apply\n * }\n *\n * discardChanges(): boolean {\n * if (this.hasPendingChanges()) {\n * this.pendingContext = { ...this.savedContext };\n * return true; // Changes were discarded\n * }\n * return false; // No changes to discard\n * }\n * }\n * ```\n *\n * @public\n */\nexport function hasPendingContextChanges(\n contextValues: Record<string, string | undefined>,\n pendingContextValues: Record<string, string | undefined>\n): boolean {\n return JSON.stringify(contextValues) !== JSON.stringify(pendingContextValues);\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resourceSelector.d.ts","sourceRoot":"","sources":["../../src/utils/resourceSelector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAiB,MAAM,eAAe,CAAC;AACtD,OAAO,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAErE;;GAEG;AACH,KAAK,eAAe,GAAG,CAAC,QAAQ,EAAE,oBAAoB,EAAE,SAAS,EAAE,mBAAmB,KAAK,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC;AAE5G;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,SAAS,CAAoE;;IAarF;;;;;OAKG;IACI,gBAAgB,CAAC,IAAI,EAAE,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M,uBAAuB,GAAqB,IAAI,gBAAgB,EAAE,CAAC;AAEhF;;;;;;;GAOG;AACH,MAAM,UAAU,eAAe,CAC7B,QAA8B,EAC9B,SAA8B;IAE9B,OAAO,uBAAuB,CAAC,MAAM,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC;AAC7D,CAAC","sourcesContent":["import { Result, succeed, fail } from '@fgv/ts-utils';\nimport { IProcessedResources, GridResourceSelector } from '../types';\n\n/**\n * Handler function type for resource selector implementations.\n */\ntype SelectorHandler = (selector: GridResourceSelector, resources: IProcessedResources) => Result<string[]>;\n\n/**\n * Resource selector utility for filtering resources based on various criteria.\n * Supports built-in selector types and extensible custom selectors.\n *\n * @example\n * ```typescript\n * const selector = new ResourceSelector();\n *\n * // Use built-in selectors\n * const prefixResult = selector.select(\n * { type: 'prefix', prefix: 'user.' },\n * processedResources\n * );\n *\n * // Register and use custom selector\n * selector.registerSelector('byMetadata', (config, resources) => {\n * return succeed(resources.summary.resourceIds.filter(id =>\n * hasMetadata(id, config.key, config.value)\n * ));\n * });\n * ```\n * @public\n */\nexport class ResourceSelector {\n private _registry: Map<string, SelectorHandler> = new Map<string, SelectorHandler>();\n\n public constructor() {\n // Register built-in selectors\n this._registry.set('ids', this._selectByIds);\n this._registry.set('prefix', this._selectByPrefix);\n this._registry.set('suffix', this._selectBySuffix);\n this._registry.set('resourceTypes', this._selectByResourceTypes);\n this._registry.set('pattern', this._selectByPattern);\n this._registry.set('all', this._selectAll);\n this._registry.set('custom', this._selectCustom);\n }\n\n /**\n * Register a new selector type that can be used in grid configurations.\n *\n * @param type - Unique identifier for the selector type\n * @param handler - Function that implements the selection logic\n */\n public registerSelector(type: string, handler: SelectorHandler): void {\n this._registry.set(type, handler);\n }\n\n /**\n * Get all registered selector types (useful for debugging/tooling).\n */\n public getRegisteredTypes(): string[] {\n return Array.from(this._registry.keys());\n }\n\n /**\n * Select resources based on the provided selector configuration.\n *\n * @param selector - Resource selector configuration\n * @param resources - Processed resources to select from\n * @returns Result containing array of selected resource IDs\n */\n public select(selector: GridResourceSelector, resources: IProcessedResources): Result<string[]> {\n const handler = this._registry.get(selector.type);\n if (!handler) {\n return fail(`Unknown selector type: ${selector.type}`);\n }\n\n try {\n return handler(selector, resources);\n } catch (error) {\n return fail(`Selector error: ${error instanceof Error ? error.message : String(error)}`);\n }\n }\n\n /**\n * Select resources by explicit resource IDs.\n */\n private _selectByIds(selector: GridResourceSelector, resources: IProcessedResources): Result<string[]> {\n if (selector.type !== 'ids') {\n return fail('Selector type is not \"ids\"');\n }\n\n const availableIds = new Set(resources.summary.resourceIds);\n const selectedIds = selector.resourceIds.filter((id) => availableIds.has(id));\n\n if (selectedIds.length === 0 && selector.resourceIds.length > 0) {\n return fail(`None of the specified resource IDs were found in the resource collection`);\n }\n\n return succeed(selectedIds);\n }\n\n /**\n * Select resources with IDs starting with the specified prefix.\n */\n private _selectByPrefix(selector: GridResourceSelector, resources: IProcessedResources): Result<string[]> {\n if (selector.type !== 'prefix') {\n return fail('Selector type is not \"prefix\"');\n }\n\n if (!selector.prefix) {\n return fail('Prefix cannot be empty');\n }\n\n const matchingIds = resources.summary.resourceIds.filter((id) => id.startsWith(selector.prefix));\n return succeed(matchingIds);\n }\n\n /**\n * Select resources with IDs ending with the specified suffix.\n */\n private _selectBySuffix(selector: GridResourceSelector, resources: IProcessedResources): Result<string[]> {\n if (selector.type !== 'suffix') {\n return fail('Selector type is not \"suffix\"');\n }\n\n if (!selector.suffix) {\n return fail('Suffix cannot be empty');\n }\n\n const matchingIds = resources.summary.resourceIds.filter((id) => id.endsWith(selector.suffix));\n return succeed(matchingIds);\n }\n\n /**\n * Select resources by resource type names.\n */\n private _selectByResourceTypes(\n selector: GridResourceSelector,\n resources: IProcessedResources\n ): Result<string[]> {\n if (selector.type !== 'resourceTypes') {\n return fail('Selector type is not \"resourceTypes\"');\n }\n\n if (!selector.types || selector.types.length === 0) {\n return fail('Resource types array cannot be empty');\n }\n\n const typeSet = new Set(selector.types);\n const matchingIds: string[] = [];\n\n // Iterate through all resources and check their types\n resources.summary.resourceIds.forEach((resourceId) => {\n try {\n // Get the resource from the resolver to check its type\n const resourceResult = resources.resolver.resourceManager.getBuiltResource(resourceId);\n if (resourceResult.isSuccess()) {\n const resource = resourceResult.value;\n if (typeSet.has(resource.resourceType.key)) {\n matchingIds.push(resourceId);\n }\n }\n } catch {\n // Skip resources that can't be accessed\n }\n });\n\n return succeed(matchingIds);\n }\n\n /**\n * Select resources by simple glob pattern matching.\n * Supports * as wildcard character.\n */\n private _selectByPattern(selector: GridResourceSelector, resources: IProcessedResources): Result<string[]> {\n if (selector.type !== 'pattern') {\n return fail('Selector type is not \"pattern\"');\n }\n\n if (!selector.pattern) {\n return fail('Pattern cannot be empty');\n }\n\n try {\n // Convert glob pattern to regex\n const regexPattern = selector.pattern\n .replace(/[.+?^${}()|[\\]\\\\]/g, '\\\\$&') // Escape special regex chars\n .replace(/\\*/g, '.*'); // Convert * to .*\n\n // eslint-disable-next-line @rushstack/security/no-unsafe-regexp\n const regex = new RegExp(`^${regexPattern}$`);\n const matchingIds = resources.summary.resourceIds.filter((id) => regex.test(id));\n\n return succeed(matchingIds);\n } catch (error) {\n return fail(`Invalid pattern: ${error instanceof Error ? error.message : String(error)}`);\n }\n }\n\n /**\n * Select all available resources.\n */\n private _selectAll(__selector: GridResourceSelector, resources: IProcessedResources): Result<string[]> {\n return succeed([...resources.summary.resourceIds]);\n }\n\n /**\n * Select resources using custom selector logic.\n */\n private _selectCustom(selector: GridResourceSelector, resources: IProcessedResources): Result<string[]> {\n if (selector.type !== 'custom') {\n return fail('Selector type is not \"custom\"');\n }\n\n if (!selector.selector || !selector.selector.select) {\n return fail('Custom selector configuration is required');\n }\n\n try {\n const selectedIds = selector.selector.select(resources);\n\n // Validate that all returned IDs exist in the resource collection\n const availableIds = new Set(resources.summary.resourceIds);\n const validIds = selectedIds.filter((id: string) => availableIds.has(id));\n\n if (validIds.length !== selectedIds.length) {\n const invalidIds = selectedIds.filter((id: string) => !availableIds.has(id));\n console.warn(`Custom selector returned invalid resource IDs: ${invalidIds.join(', ')}`);\n }\n\n return succeed(validIds);\n } catch (error) {\n return fail(`Custom selector failed: ${error instanceof Error ? error.message : String(error)}`);\n }\n }\n}\n\n/**\n * Default resource selector instance for use throughout the application.\n * @public\n */\nexport const defaultResourceSelector: ResourceSelector = new ResourceSelector();\n\n/**\n * Utility function to select resources using the default selector.\n *\n * @param selector - Resource selector configuration\n * @param resources - Processed resources to select from\n * @returns Result containing array of selected resource IDs\n * @public\n */\nexport function selectResources(\n selector: GridResourceSelector,\n resources: IProcessedResources\n): Result<string[]> {\n return defaultResourceSelector.select(selector, resources);\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resourceSelectors.d.ts","sourceRoot":"","sources":["../../src/utils/resourceSelectors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,MAAM,EAAiB,MAAM,eAAe,CAAC;AAEtD;;;;;;GAMG;AAEH;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,yBAAyB,CACvC,gBAAgB,EAAE,GAAG,CAAC,MAAM,EAAE,YAAY,CAAC,IAAI,CAAC,kBAAkB,CAAC,EACnE,YAAY,EAAE,MAAM,GACnB,KAAK,CAAC;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,YAAY,CAAC,IAAI,CAAC,kBAAkB,CAAA;CAAE,CAAC,CAUvE;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,iBAAiB,CAC/B,UAAU,EAAE,MAAM,EAClB,gBAAgB,EAAE,GAAG,CAAC,MAAM,EAAE,YAAY,CAAC,IAAI,CAAC,kBAAkB,CAAC,GAClE,OAAO,CAET;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,YAAY,CAAC,cAAc,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,CAgBnE;AA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C,GAAG,CAAC,EAAE,CAAC;YACxB,MAAM,CAAC,IAAI,CAAC,gBAAgB,GAAG,qBAAqB,CAAC,CAAC;QACxD,CAAC;QAED,wBAAwB;QACxB,IAAI,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;YACvB,MAAM,CAAC,IAAI,CAAC,gBAAgB,GAAG,6BAA6B,CAAC,CAAC;QAChE,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACtB,OAAO,IAAI,CAAC,2CAA2C,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAC9E,CAAC;IAED,OAAO,OAAO,CAAC,SAAS,CAAC,CAAC;AAC5B,CAAC","sourcesContent":["import { ResourceJson } from '@fgv/ts-res';\nimport { Result, succeed, fail } from '@fgv/ts-utils';\n\n/**\n * Helper functions for working with pending resources and resource IDs.\n * These utilities provide standardized ways to work with resource identification\n * and selection patterns commonly needed by host applications.\n *\n * @public\n */\n\n/**\n * Gets pending resources filtered by resource type.\n *\n * @param pendingResources - Map of pending resources (keys are guaranteed to be full resource IDs)\n * @param resourceType - Resource type to filter by (e.g., 'json', 'string')\n * @returns Array of pending resources of the specified type\n *\n * @example\n * ```typescript\n * const jsonResources = getPendingAdditionsByType(pendingResources, 'json');\n * const languageConfigs = getPendingAdditionsByType(pendingResources, 'languageConfig');\n * ```\n *\n * @public\n */\nexport function getPendingAdditionsByType(\n pendingResources: Map<string, ResourceJson.Json.ILooseResourceDecl>,\n resourceType: string\n): Array<{ id: string; resource: ResourceJson.Json.ILooseResourceDecl }> {\n const results: Array<{ id: string; resource: ResourceJson.Json.ILooseResourceDecl }> = [];\n\n pendingResources.forEach((resource, id) => {\n if (resource.resourceTypeName === resourceType) {\n results.push({ id, resource });\n }\n });\n\n return results;\n}\n\n/**\n * Checks if a resource ID corresponds to a pending addition.\n *\n * @param resourceId - Resource ID to check (should be full resource ID)\n * @param pendingResources - Map of pending resources\n * @returns True if the resource ID exists in pending resources\n *\n * @example\n * ```typescript\n * if (isPendingAddition('platform.languages.az-AZ', pendingResources)) {\n * console.log('This is a pending resource');\n * }\n * ```\n *\n * @public\n */\nexport function isPendingAddition(\n resourceId: string,\n pendingResources: Map<string, ResourceJson.Json.ILooseResourceDecl>\n): boolean {\n return pendingResources.has(resourceId);\n}\n\n/**\n * Derives a leaf ID from a full resource ID.\n * Extracts the last segment after the final dot.\n *\n * @param fullResourceId - Full resource ID (e.g., 'platform.languages.az-AZ')\n * @returns Result containing the leaf ID (e.g., 'az-AZ') or error if invalid format\n *\n * @example\n * ```typescript\n * const leafResult = deriveLeafId('platform.languages.az-AZ');\n * if (leafResult.isSuccess()) {\n * console.log(leafResult.value); // 'az-AZ'\n * }\n *\n * const invalidResult = deriveLeafId('invalid');\n * if (invalidResult.isFailure()) {\n * console.log(invalidResult.message); // 'Resource ID must contain at least one dot'\n * }\n * ```\n *\n * @public\n */\nexport function deriveLeafId(fullResourceId: string): Result<string> {\n if (!fullResourceId || fullResourceId.trim().length === 0) {\n return fail('Resource ID cannot be empty');\n }\n\n const parts = fullResourceId.split('.');\n if (parts.length < 2) {\n return fail('Resource ID must contain at least one dot separator (e.g., \"platform.languages.az-AZ\")');\n }\n\n const leafId = parts[parts.length - 1];\n if (!leafId || leafId.trim().length === 0) {\n return fail('Leaf ID cannot be empty (resource ID cannot end with a dot)');\n }\n\n return succeed(leafId);\n}\n\n/**\n * Constructs a full resource ID from a root path and leaf ID.\n *\n * @param rootPath - Root path (e.g., 'platform.languages')\n * @param leafId - Leaf identifier (e.g., 'az-AZ')\n * @returns Result containing the full resource ID or error if invalid inputs\n *\n * @example\n * ```typescript\n * const fullIdResult = deriveFullId('platform.languages', 'az-AZ');\n * if (fullIdResult.isSuccess()) {\n * console.log(fullIdResult.value); // 'platform.languages.az-AZ'\n * }\n *\n * const invalidResult = deriveFullId('', 'az-AZ');\n * if (invalidResult.isFailure()) {\n * console.log(invalidResult.message); // 'Root path cannot be empty'\n * }\n * ```\n *\n * @public\n */\nexport function deriveFullId(rootPath: string, leafId: string): Result<string> {\n if (!rootPath || rootPath.trim().length === 0) {\n return fail('Root path cannot be empty');\n }\n\n if (!leafId || leafId.trim().length === 0) {\n return fail('Leaf ID cannot be empty');\n }\n\n // Remove leading/trailing dots from root path\n const cleanRootPath = rootPath.replace(/^\\.+|\\.+$/g, '');\n if (cleanRootPath.length === 0) {\n return fail('Root path cannot consist only of dots');\n }\n\n // Remove leading/trailing dots from leaf ID\n const cleanLeafId = leafId.replace(/^\\.+|\\.+$/g, '');\n if (cleanLeafId.length === 0) {\n return fail('Leaf ID cannot consist only of dots');\n }\n\n const fullId = `${cleanRootPath}.${cleanLeafId}`;\n return succeed(fullId);\n}\n\n/**\n * Gets all unique resource types from pending resources.\n *\n * @param pendingResources - Map of pending resources\n * @returns Array of unique resource type names\n *\n * @example\n * ```typescript\n * const types = getPendingResourceTypes(pendingResources);\n * console.log(types); // ['json', 'string', 'languageConfig']\n * ```\n *\n * @public\n */\nexport function getPendingResourceTypes(\n pendingResources: Map<string, ResourceJson.Json.ILooseResourceDecl>\n): string[] {\n const types = new Set<string>();\n\n pendingResources.forEach((resource) => {\n if (resource.resourceTypeName) {\n types.add(resource.resourceTypeName);\n }\n });\n\n return Array.from(types).sort();\n}\n\n/**\n * Gets statistics about pending resources.\n * Provides summary information useful for UI displays.\n *\n * @param pendingResources - Map of pending resources\n * @returns Statistics object with counts and breakdowns\n *\n * @example\n * ```typescript\n * const stats = getPendingResourceStats(pendingResources);\n * console.log(`${stats.totalCount} pending resources`);\n * console.log(`Types: ${Object.keys(stats.byType).join(', ')}`);\n * ```\n *\n * @public\n */\nexport function getPendingResourceStats(\n pendingResources: Map<string, ResourceJson.Json.ILooseResourceDecl>\n): {\n totalCount: number;\n byType: Record<string, number>;\n resourceIds: string[];\n} {\n const stats = {\n totalCount: pendingResources.size,\n byType: {} as Record<string, number>,\n resourceIds: Array.from(pendingResources.keys()).sort()\n };\n\n pendingResources.forEach((resource) => {\n if (resource.resourceTypeName) {\n stats.byType[resource.resourceTypeName] = (stats.byType[resource.resourceTypeName] || 0) + 1;\n }\n });\n\n return stats;\n}\n\n/**\n * Validates that all keys in a pending resources map are properly formatted as full resource IDs.\n * This is a diagnostic function to ensure the pending resource key invariant is maintained.\n *\n * @param pendingResources - Map of pending resources to validate\n * @returns Result indicating whether all keys are valid full resource IDs, or details about any issues found\n *\n * @example\n * ```typescript\n * const validation = validatePendingResourceKeys(pendingResources);\n * if (validation.isFailure()) {\n * console.error('Pending resource key validation failed:', validation.message);\n * }\n * ```\n *\n * @public\n */\nexport function validatePendingResourceKeys(\n pendingResources: Map<string, ResourceJson.Json.ILooseResourceDecl>\n): Result<void> {\n const issues: string[] = [];\n\n pendingResources.forEach((resource, key) => {\n // Check for empty keys\n if (!key || key.trim().length === 0) {\n issues.push('Found empty resource ID key');\n return;\n }\n\n // Check for temporary IDs (should not be in pending resources)\n if (key.startsWith('new-resource-')) {\n issues.push(`Found temporary ID key: ${key}`);\n }\n\n // Check for minimum structure (at least one dot)\n if (!key.includes('.')) {\n issues.push(`Resource ID '${key}' appears to be a leaf ID rather than a full resource ID`);\n }\n\n // Check for trailing dots\n if (key.endsWith('.')) {\n issues.push(`Resource ID '${key}' ends with a dot`);\n }\n\n // Check for leading dots\n if (key.startsWith('.')) {\n issues.push(`Resource ID '${key}' starts with a dot`);\n }\n\n // Check for double dots\n if (key.includes('..')) {\n issues.push(`Resource ID '${key}' contains consecutive dots`);\n }\n });\n\n if (issues.length > 0) {\n return fail(`Pending resource key validation failed: ${issues.join('; ')}`);\n }\n\n return succeed(undefined);\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tsResIntegration.d.ts","sourceRoot":"","sources":["../../src/utils/tsResIntegration.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAiB,MAAM,eAAe,CAAC;AACtD,OAAO,EAAE,QAAQ,EAA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MAOC,EACD,YAAgD;IAEhD,OAAO,MAAM,CAAC,eAAe;SAC1B,6BAA6B,CAAC,EAAE,eAAe,EAAE,IAAI,EAAE,CAAC;SACxD,SAAS,CAAC,CAAC,kBAAqE,EAAE,EAAE;QACnF,sEAAsE;QACtE,OAAO,OAAO,CAAC,gBAAgB,CAAC,MAAM,CAAC;YACrC,eAAe,EAAE,MAAM,CAAC,eAAe;YACvC,cAAc,EAAE,MAAM,CAAC,cAAc;YACrC,wBAAwB,EAAE,MAAM,CAAC,wBAAwB;SAC1D,CAAC,CAAC,SAAS,CAAC,CAAC,QAAQ,EAAE,EAAE;YACxB,iBAAiB;YACjB,MAAM,WAAW,GAAG,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,eAAe,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC,CAAC;YACxE,MAAM,OAAO,GAAG;gBACd,cAAc,EAAE,WAAW,CAAC,MAAM;gBAClC,WAAW;gBACX,UAAU,EAAE,CAAC;gBACb,QAAQ,EAAE,EAAc;aACzB,CAAC;YAEF,OAAO,OAAO,CAAC;gBACb,MAAM;gBACN,kBAAkB;gBAClB,QAAQ;gBACR,aAAa,EAAE,WAAW,CAAC,MAAM;gBACjC,OAAO;gBACP,GAAG,CAAC,YAAY,IAAI,EAAE,mBAAmB,EAAE,YAAY,EAAE,CAAC;aAC3D,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC,CAAC;SACD,eAAe,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,kCAAkC,OAAO,EAAE,CAAC,CAAC;AAC/E,CAAC;AAED,4FAA4F;AAC5F,6FAA6F","sourcesContent":["import { Result, succeed, fail } from '@fgv/ts-utils';\nimport { FileTree } from '@fgv/ts-json-base';\nimport {\n QualifierTypes,\n Qualifiers,\n ResourceTypes,\n Resources,\n Import,\n Runtime,\n ResourceJson,\n Config\n} from '@fgv/ts-res';\nimport { IExtendedProcessedResources } from '../types';\nimport * as ObservabilityTools from '../utils/observability';\n\n/**\n * Get the default system configuration from ts-res library\n */\n/** @internal */\nexport function getDefaultSystemConfiguration(): Config.Model.ISystemConfiguration {\n return Config.getPredefinedDeclaration('default').orDefault({\n // Fallback configuration if predefined default is not available\n name: 'Browser Default Configuration',\n description: 'Fallback default configuration for ts-res browser tool',\n qualifierTypes: [\n {\n name: 'language',\n systemType: 'language',\n configuration: {\n allowContextList: true\n }\n },\n {\n name: 'territory',\n systemType: 'territory',\n configuration: {\n allowContextList: false\n }\n }\n ],\n qualifiers: [\n {\n name: 'currentTerritory',\n token: 'geo',\n typeName: 'territory',\n defaultPriority: 850\n },\n {\n name: 'language',\n token: 'lang',\n typeName: 'language',\n defaultPriority: 800\n }\n ],\n resourceTypes: [\n {\n name: 'json',\n typeName: 'json'\n }\n ]\n });\n}\n\n/**\n * Create a simple context provider from qualifier values\n */\n/** @internal */\nexport function createSimpleContext(\n qualifiers: Qualifiers.IReadOnlyQualifierCollector,\n values: Record<string, string | undefined>\n): Result<Runtime.ValidatingSimpleContextQualifierProvider> {\n return Runtime.ValidatingSimpleContextQualifierProvider.create({\n qualifiers\n }).withErrorFormat((e) => `Failed to create context: ${e}`);\n}\n\n/**\n * Create ts-res system from configuration\n */\n/** @internal */\nexport function createTsResSystemFromConfig(\n systemConfig?: Config.Model.ISystemConfiguration,\n qualifierTypeFactory?: Config.IConfigInitFactory<\n QualifierTypes.Config.IAnyQualifierTypeConfig,\n QualifierTypes.QualifierType\n >,\n resourceTypeFactory?: Config.IConfigInitFactory<\n ResourceTypes.Config.IResourceTypeConfig,\n ResourceTypes.ResourceType\n >\n): Result<{\n qualifierTypes: QualifierTypes.ReadOnlyQualifierTypeCollector;\n qualifiers: Qualifiers.IReadOnlyQualifierCollector;\n resourceTypes: ResourceTypes.ReadOnlyResourceTypeCollector;\n resourceManager: Resources.ResourceManagerBuilder;\n importManager: Import.ImportManager;\n contextQualifierProvider: Runtime.ValidatingSimpleContextQualifierProvider;\n}> {\n const configToUse = systemConfig ?? getDefaultSystemConfiguration();\n\n return Config.SystemConfiguration.create(configToUse, {\n qualifierTypeFactory,\n resourceTypeFactory\n })\n .onSuccess((systemConfiguration) => {\n return Resources.ResourceManagerBuilder.create({\n qualifiers: systemConfiguration.qualifiers,\n resourceTypes: systemConfiguration.resourceTypes\n })\n .withErrorFormat((e) => `Failed to create resource manager: ${e}`)\n .onSuccess((resourceManager) => {\n return FileTree.inMemory([])\n .withErrorFormat((e) => `Failed to create in-memory FileTree: ${e}`)\n .onSuccess((emptyTree) =>\n Import.ImportManager.create({\n resources: resourceManager,\n fileTree: emptyTree\n }).withErrorFormat((e) => `Failed to create import manager: ${e}`)\n )\n .onSuccess((importManager) => {\n return Runtime.ValidatingSimpleContextQualifierProvider.create({\n qualifiers: systemConfiguration.qualifiers\n })\n .withErrorFormat((e) => `Failed to create context qualifier provider: ${e}`)\n .onSuccess((contextQualifierProvider) => {\n return succeed({\n qualifierTypes: systemConfiguration.qualifierTypes,\n qualifiers: systemConfiguration.qualifiers,\n resourceTypes: systemConfiguration.resourceTypes,\n resourceManager,\n importManager,\n contextQualifierProvider\n });\n });\n });\n });\n })\n .withErrorFormat((e) => `Failed to create ts-res system: ${e}`);\n}\n\n/**\n * Parameters for processFileTree\n */\n/** @internal */\nexport interface ICreateProcessFileTreeParams {\n fileTree: FileTree.FileTree;\n systemConfig?: Config.Model.ISystemConfiguration;\n qualifierTypeFactory?: Config.IConfigInitFactory<\n QualifierTypes.Config.IAnyQualifierTypeConfig,\n QualifierTypes.QualifierType\n >;\n resourceTypeFactory?: Config.IConfigInitFactory<\n ResourceTypes.Config.IResourceTypeConfig,\n ResourceTypes.ResourceType\n >;\n o11y?: ObservabilityTools.IObservabilityContext;\n}\n\n/**\n * Process FileTree using the ts-res system\n * Unified function that replaces both processImportedFiles and processImportedDirectory\n */\n/** @internal */\nexport function processFileTree(params: ICreateProcessFileTreeParams): Result<IExtendedProcessedResources> {\n const o11y = params.o11y ?? ObservabilityTools.DefaultObservabilityContext;\n\n return createTsResSystemFromConfig(\n params.systemConfig,\n params.qualifierTypeFactory,\n params.resourceTypeFactory\n )\n .onSuccess<IExtendedProcessedResources>((tsResSystem) => {\n return Import.ImportManager.create({\n fileTree: params.fileTree,\n resources: tsResSystem.resourceManager\n }).onSuccess((importManager) => {\n // Simply try to import from the filesystem root\n // The ImportManager will handle finding and importing all resources\n o11y.diag.info('[tsResIntegration] Starting resource import from FileTree');\n\n const importResult = importManager.importFromFileSystem('/');\n if (importResult.isFailure()) {\n o11y.diag.warn(`[tsResIntegration] Failed to import from root, trying individual files`);\n\n // If root import fails, try to import files individually\n // We'll recursively traverse the tree using the FileTree API\n let importedCount = 0;\n const failedImports: Array<{ file: string; error: string }> = [];\n\n const importDirectory = (dirPath: string): void => {\n const dirResult = params.fileTree.getDirectory(dirPath);\n if (dirResult.isSuccess()) {\n const dir = dirResult.value;\n const childrenResult = dir.getChildren();\n if (childrenResult.isSuccess()) {\n for (const child of childrenResult.value) {\n if (child.type === 'file' && child.name.endsWith('.json')) {\n o11y.diag.info(`[tsResIntegration] Importing file: ${child.absolutePath}`);\n const fileImportResult = importManager.importFromFileSystem(child.absolutePath);\n if (fileImportResult.isSuccess()) {\n importedCount++;\n o11y.diag.info(`[tsResIntegration] Successfully imported ${child.absolutePath}`);\n } else {\n o11y.diag.warn(\n `[tsResIntegration] Failed to import ${child.absolutePath}: ${fileImportResult.message}`\n );\n failedImports.push({ file: child.absolutePath, error: fileImportResult.message });\n }\n } else if (child.type === 'directory') {\n importDirectory(child.absolutePath);\n }\n }\n }\n }\n };\n\n // Start from root\n importDirectory('/');\n\n // Also try without leading slash\n if (importedCount === 0) {\n importDirectory('');\n }\n\n o11y.diag.info(`[tsResIntegration] Import complete. Imported ${importedCount} files`);\n\n if (importedCount === 0 && failedImports.length > 0) {\n // Create a summary of unique errors\n const errorSummary = new Map<string, string[]>();\n failedImports.forEach(({ file, error }) => {\n // Extract the main error (e.g., \"invalid item: role: not found\")\n const mainError = error.split('\\n')[0];\n if (!errorSummary.has(mainError)) {\n errorSummary.set(mainError, []);\n }\n errorSummary.get(mainError)!.push(file);\n });\n\n let errorMessage = `Failed to import resources. Missing qualifiers in configuration:\\n`;\n errorSummary.forEach((files, error) => {\n errorMessage += `- ${error} (${files.length} file${files.length > 1 ? 's' : ''})\\n`;\n });\n\n return fail(errorMessage);\n } else if (importedCount === 0) {\n return fail(`No resource files found in FileTree`);\n }\n } else {\n o11y.diag.info('[tsResIntegration] Successfully imported resources from root');\n }\n\n // Finalize processing\n const updatedSystem = {\n ...tsResSystem,\n importManager\n };\n const configToUse = params.systemConfig ?? getDefaultSystemConfiguration();\n return finalizeProcessing(updatedSystem, configToUse);\n });\n })\n .withErrorFormat((message) => `processFileTree failed: ${message}`);\n}\n\n/**\n * Finalizes processing and creates compiled resources\n */\nfunction finalizeProcessing(\n system: {\n qualifierTypes: QualifierTypes.ReadOnlyQualifierTypeCollector;\n qualifiers: Qualifiers.IReadOnlyQualifierCollector;\n resourceTypes: ResourceTypes.ReadOnlyResourceTypeCollector;\n resourceManager: Resources.ResourceManagerBuilder;\n importManager: Import.ImportManager;\n contextQualifierProvider: Runtime.ValidatingSimpleContextQualifierProvider;\n },\n systemConfig?: Config.Model.ISystemConfiguration\n): Result<IExtendedProcessedResources> {\n return system.resourceManager\n .getCompiledResourceCollection({ includeMetadata: true })\n .onSuccess((compiledCollection: ResourceJson.Compiled.ICompiledResourceCollection) => {\n // Create resolver directly without CompiledResourceCollection manager\n return Runtime.ResourceResolver.create({\n resourceManager: system.resourceManager,\n qualifierTypes: system.qualifierTypes,\n contextQualifierProvider: system.contextQualifierProvider\n }).onSuccess((resolver) => {\n // Create summary\n const resourceIds = Array.from(system.resourceManager.resources.keys());\n const summary = {\n totalResources: resourceIds.length,\n resourceIds,\n errorCount: 0,\n warnings: [] as string[]\n };\n\n return succeed({\n system,\n compiledCollection,\n resolver,\n resourceCount: resourceIds.length,\n summary,\n ...(systemConfig && { activeConfiguration: systemConfig })\n });\n });\n })\n .withErrorFormat((message) => `Failed to finalize processing: ${message}`);\n}\n\n// Note: convertImportedDirectoryToFileTree was removed - we work directly with FileTree now\n// Note: processImportedFiles and processImportedDirectory were replaced with processFileTree\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/zipLoader/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAGvC,OAAO,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/zipLoader/index.ts"],"names":[],"mappings":"AAAA,gDAAgD;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEvC,mEAAmE;AACnE,OAAO,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC","sourcesContent":["// Export only the utilities actually being used\nexport { isZipFile } from './zipUtils';\n\n// ZIP processing helpers for integrating with ts-res-ui-components\nexport { processZipResources, processZipLoadResult } from './zipProcessingHelpers';\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"zipProcessingHelpers.d.ts","sourceRoot":"","sources":["../../../src/utils/zipLoader/zipProcessingHelpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAQ,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAElD,OAAO,KAAK,kBAAkB,MAAM,kBAAkB,CAAC;AAEvD;;;GAGG;AACH,wBAAsB,mBAAmB,CACvC,QAAQ,EAAE,QAAQ,CAAC,QAAQ,EAC3B,MAAM,CAAC,EAAE,MAAM,CAAC,KAAK,CAAC,oBAAoB,E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H,MAAM,CAAC,KAAK,UAAU,oBAAoB,CACxC,SAGC,EACD,cAAkD,EAClD,OAAiD,kBAAkB,CAAC,2BAA2B;IAE/F,MAAM,WAAW,GAAG,cAAc,IAAI,SAAS,CAAC,MAAM,CAAC;IACvD,OAAO,mBAAmB,CAAC,SAAS,CAAC,QAAQ,EAAE,WAAW,EAAE,IAAI,CAAC,CAAC;AACpE,CAAC","sourcesContent":["import { Result, fail } from '@fgv/ts-utils';\nimport { Config } from '@fgv/ts-res';\nimport { FileTree } from '@fgv/ts-json-base';\nimport { IProcessedResources } from '../../types';\nimport { processFileTree } from '../tsResIntegration';\nimport * as ObservabilityTools from '../observability';\n\n/**\n * Helper function to process resources from ZIP data using ts-res-ui-components integration\n * @public\n */\nexport async function processZipResources(\n fileTree: FileTree.FileTree,\n config?: Config.Model.ISystemConfiguration,\n o11y: ObservabilityTools.IObservabilityContext = ObservabilityTools.DefaultObservabilityContext\n): Promise<Result<IProcessedResources>> {\n try {\n return processFileTree({ fileTree, systemConfig: config, o11y }).withErrorFormat(\n (message: string) => `Failed to process resources from FileTree: ${message}`\n );\n } catch (error) {\n return fail(`Error processing ZIP resources: ${error instanceof Error ? error.message : String(error)}`);\n }\n}\n\n/**\n * Helper function to process resources from a ZIP load result\n * @public\n */\nexport async function processZipLoadResult(\n zipResult: {\n fileTree: FileTree.FileTree;\n config?: Config.Model.ISystemConfiguration;\n },\n overrideConfig?: Config.Model.ISystemConfiguration,\n o11y: ObservabilityTools.IObservabilityContext = ObservabilityTools.DefaultObservabilityContext\n): Promise<Result<IProcessedResources>> {\n const configToUse = overrideConfig || zipResult.config;\n return processZipResources(zipResult.fileTree, configToUse, o11y);\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"zipUtils.d.ts","sourceRoot":"","sources":["../../../src/utils/zipLoader/zipUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,wBAAgB,SAAS,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAEnD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"zipUtils.js","sourceRoot":"","sources":["../../../src/utils/zipLoader/zipUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,UAAU,SAAS,CAAC,QAAgB;IACxC,OAAO,QAAQ,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;AACjD,CAAC","sourcesContent":["/**\n * Validate ZIP file extension\n * @public\n */\nexport function isZipFile(filename: string): boolean {\n return filename.toLowerCase().endsWith('.zip');\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,19 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fgv/ts-res-ui-components",
|
|
3
|
-
"version": "5.1.0-
|
|
3
|
+
"version": "5.1.0-21",
|
|
4
4
|
"description": "Reusable React components for ts-res resource visualization and management",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
7
|
-
"scripts": {
|
|
8
|
-
"build": "heft build --clean",
|
|
9
|
-
"build-docs": "typedoc --options ./config/typedoc.json",
|
|
10
|
-
"build-all": "rushx build && rushx build-docs",
|
|
11
|
-
"clean": "heft clean",
|
|
12
|
-
"test": "heft test --clean",
|
|
13
|
-
"lint": "eslint src --ext .ts,.tsx",
|
|
14
|
-
"fixlint": "eslint src --ext .ts,.tsx --fix",
|
|
15
|
-
"coverage": "jest --coverage"
|
|
16
|
-
},
|
|
17
7
|
"sideEffects": false,
|
|
18
8
|
"keywords": [
|
|
19
9
|
"typescript",
|
|
@@ -30,23 +20,21 @@
|
|
|
30
20
|
},
|
|
31
21
|
"homepage": "https://github.com/ErikFortune/fgv/tree/main/libraries/ts-res-ui-components#readme",
|
|
32
22
|
"dependencies": {
|
|
33
|
-
"@fgv/ts-res": "workspace:*",
|
|
34
|
-
"@fgv/ts-utils": "workspace:*",
|
|
35
|
-
"@fgv/ts-json": "workspace:*",
|
|
36
|
-
"@fgv/ts-json-base": "workspace:*",
|
|
37
23
|
"@heroicons/react": "~2.2.0",
|
|
38
24
|
"tslib": "^2.8.1",
|
|
39
25
|
"json-edit-react": "~1.29.0",
|
|
40
|
-
"@fgv/ts-
|
|
41
|
-
"@fgv/ts-
|
|
26
|
+
"@fgv/ts-res": "5.1.0-21",
|
|
27
|
+
"@fgv/ts-utils": "5.1.0-21",
|
|
28
|
+
"@fgv/ts-json": "5.1.0-21",
|
|
29
|
+
"@fgv/ts-json-base": "5.1.0-21",
|
|
30
|
+
"@fgv/ts-extras": "5.1.0-21",
|
|
31
|
+
"@fgv/ts-web-extras": "5.1.0-21"
|
|
42
32
|
},
|
|
43
33
|
"peerDependencies": {
|
|
44
34
|
"react": ">=18.0.0",
|
|
45
35
|
"react-dom": ">=18.0.0"
|
|
46
36
|
},
|
|
47
37
|
"devDependencies": {
|
|
48
|
-
"@fgv/heft-dual-rig": "workspace:*",
|
|
49
|
-
"@fgv/ts-utils-jest": "workspace:*",
|
|
50
38
|
"@types/react": "~19.2.8",
|
|
51
39
|
"@types/react-dom": "~19.2.3",
|
|
52
40
|
"react": "~19.2.3",
|
|
@@ -68,13 +56,17 @@
|
|
|
68
56
|
"rimraf": "^6.1.2",
|
|
69
57
|
"ts-jest": "^29.4.6",
|
|
70
58
|
"typescript": "5.9.3",
|
|
71
|
-
"@rushstack/heft": "1.2.
|
|
72
|
-
"@rushstack/heft-web-rig": "1.4.
|
|
59
|
+
"@rushstack/heft": "1.2.7",
|
|
60
|
+
"@rushstack/heft-web-rig": "1.4.3",
|
|
73
61
|
"@rushstack/eslint-config": "4.6.4",
|
|
74
62
|
"@rushstack/heft-jest-plugin": "1.2.6",
|
|
75
63
|
"@microsoft/api-documenter": "^7.28.2",
|
|
76
64
|
"@microsoft/api-extractor": "^7.55.2",
|
|
77
|
-
"@testing-library/dom": "^10.4.0"
|
|
65
|
+
"@testing-library/dom": "^10.4.0",
|
|
66
|
+
"typedoc": "~0.28.16",
|
|
67
|
+
"@fgv/heft-dual-rig": "5.1.0-21",
|
|
68
|
+
"@fgv/typedoc-compact-theme": "5.1.0-21",
|
|
69
|
+
"@fgv/ts-utils-jest": "5.1.0-21"
|
|
78
70
|
},
|
|
79
71
|
"exports": {
|
|
80
72
|
".": {
|
|
@@ -92,5 +84,15 @@
|
|
|
92
84
|
"repository": {
|
|
93
85
|
"type": "git",
|
|
94
86
|
"url": "https://github.com/ErikFortune/fgv.git"
|
|
87
|
+
},
|
|
88
|
+
"scripts": {
|
|
89
|
+
"build": "heft build --clean",
|
|
90
|
+
"build-docs": "typedoc --options ./config/typedoc.json",
|
|
91
|
+
"build-all": "rushx build && rushx build-docs",
|
|
92
|
+
"clean": "heft clean",
|
|
93
|
+
"test": "heft test --clean",
|
|
94
|
+
"lint": "eslint src --ext .ts,.tsx",
|
|
95
|
+
"fixlint": "eslint src --ext .ts,.tsx --fix",
|
|
96
|
+
"coverage": "jest --coverage"
|
|
95
97
|
}
|
|
96
|
-
}
|
|
98
|
+
}
|