@safe-ugc-ui/validator 0.5.0 → 0.6.0
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/LICENSE +21 -0
- package/dist/index.d.ts +5 -3
- package/dist/index.js +312 -132
- package/dist/index.js.map +1 -1
- package/package.json +7 -7
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Safe UGC UI Contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/index.d.ts
CHANGED
|
@@ -101,6 +101,7 @@ interface TraversableNode {
|
|
|
101
101
|
type: string;
|
|
102
102
|
children?: TraversableNode[] | ForLoopLike;
|
|
103
103
|
style?: Record<string, unknown>;
|
|
104
|
+
responsive?: Record<string, unknown>;
|
|
104
105
|
[key: string]: unknown;
|
|
105
106
|
}
|
|
106
107
|
interface ForLoopLike {
|
|
@@ -113,17 +114,18 @@ interface ForLoopLike {
|
|
|
113
114
|
* Return `false` to skip traversing into this node's children.
|
|
114
115
|
*/
|
|
115
116
|
type NodeVisitor = (node: TraversableNode, context: TraversalContext) => void | false;
|
|
117
|
+
type StyleResolver = (node: TraversableNode) => Record<string, unknown> | undefined;
|
|
116
118
|
/**
|
|
117
119
|
* Recursively traverse a single node and its descendants.
|
|
118
120
|
*/
|
|
119
|
-
declare function traverseNode(node: TraversableNode, context: TraversalContext, visitor: NodeVisitor): void;
|
|
121
|
+
declare function traverseNode(node: TraversableNode, context: TraversalContext, visitor: NodeVisitor, styleResolver?: StyleResolver): void;
|
|
120
122
|
/**
|
|
121
123
|
* Traverse all nodes in every view of a card.
|
|
122
124
|
*
|
|
123
125
|
* @param views - The `views` object from a UGCCard (mapping view names to root nodes).
|
|
124
126
|
* @param visitor - Called for every node in every view.
|
|
125
127
|
*/
|
|
126
|
-
declare function traverseCard(views: Record<string, unknown>, visitor: NodeVisitor): void;
|
|
128
|
+
declare function traverseCard(views: Record<string, unknown>, visitor: NodeVisitor, styleResolver?: StyleResolver): void;
|
|
127
129
|
|
|
128
130
|
/**
|
|
129
131
|
* @safe-ugc-ui/validator — Schema (Structural) Validation
|
|
@@ -360,4 +362,4 @@ declare function validate(input: unknown): ValidationResult;
|
|
|
360
362
|
*/
|
|
361
363
|
declare function validateRaw(rawJson: string): ValidationResult;
|
|
362
364
|
|
|
363
|
-
export { type NodeVisitor, type TraversableNode, type TraversalContext, type ValidationError, type ValidationErrorCode, type ValidationResult, createError, invalidResult, merge, parseCard, toResult, traverseCard, traverseNode, validResult, validate, validateLimits, validateNodes, validateRaw, validateSchema, validateSecurity, validateStyles, validateValueTypes };
|
|
365
|
+
export { type NodeVisitor, type StyleResolver, type TraversableNode, type TraversalContext, type ValidationError, type ValidationErrorCode, type ValidationResult, createError, invalidResult, merge, parseCard, toResult, traverseCard, traverseNode, validResult, validate, validateLimits, validateNodes, validateRaw, validateSchema, validateSecurity, validateStyles, validateValueTypes };
|