@metamask/snaps-sdk
Version:
A library containing the core functionality for building MetaMask Snaps
1 lines • 1.37 kB
Source Map (JSON)
{"version":3,"file":"component.cjs","sourceRoot":"","sources":["../../src/ui/component.ts"],"names":[],"mappings":";;;AAAA,uDAA2C;AAC3C,2CAA+C;AAE/C,uDAA+C;AAG/C;;;;;;GAMG;AACH,SAAgB,WAAW,CAAC,KAAc;IACxC,OAAO,IAAA,gBAAE,EAAC,KAAK,EAAE,4BAAe,CAAC,CAAC;AACpC,CAAC;AAFD,kCAEC;AAED;;;;;;GAMG;AACH,SAAgB,iBAAiB,CAAC,KAAc;IAC9C,IAAA,oBAAY,EAAC,KAAK,EAAE,4BAAe,EAAE,mBAAmB,CAAC,CAAC;AAC5D,CAAC;AAFD,8CAEC","sourcesContent":["import { is } from '@metamask/superstruct';\nimport { assertStruct } from '@metamask/utils';\n\nimport { ComponentStruct } from './components';\nimport type { Component } from './components';\n\n/**\n * Check if the given value is a {@link Component}. This performs recursive\n * validation of the component's children (if any).\n *\n * @param value - The value to check.\n * @returns `true` if the value is a {@link Component}, `false` otherwise.\n */\nexport function isComponent(value: unknown): value is Component {\n return is(value, ComponentStruct);\n}\n\n/**\n * Assert that the given value is a {@link Component}. This performs recursive\n * validation of the component's children (if any).\n *\n * @param value - The value to check.\n * @throws If the value is not a {@link Component}.\n */\nexport function assertIsComponent(value: unknown): asserts value is Component {\n assertStruct(value, ComponentStruct, 'Invalid component');\n}\n"]}