@khairold/xml-render 0.1.3 → 0.2.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/README.md +29 -5
- package/dist/index.d.ts +0 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/parser.d.ts +2 -86
- package/dist/parser.d.ts.map +1 -1
- package/dist/parser.js +135 -80
- package/dist/parser.js.map +1 -1
- package/dist/react/ErrorBoundary.d.ts +2 -15
- package/dist/react/ErrorBoundary.d.ts.map +1 -1
- package/dist/react/ErrorBoundary.js +18 -43
- package/dist/react/ErrorBoundary.js.map +1 -1
- package/dist/react/XmlRender.d.ts +4 -2
- package/dist/react/XmlRender.d.ts.map +1 -1
- package/dist/react/XmlRender.js +4 -28
- package/dist/react/XmlRender.js.map +1 -1
- package/dist/react/catalog.d.ts +2 -77
- package/dist/react/catalog.d.ts.map +1 -1
- package/dist/react/catalog.js +3 -34
- package/dist/react/catalog.js.map +1 -1
- package/dist/react/context.d.ts +2 -47
- package/dist/react/context.d.ts.map +1 -1
- package/dist/react/context.js +2 -44
- package/dist/react/context.js.map +1 -1
- package/dist/react-native/ErrorBoundary.d.ts +2 -15
- package/dist/react-native/ErrorBoundary.d.ts.map +1 -1
- package/dist/react-native/ErrorBoundary.js +9 -34
- package/dist/react-native/ErrorBoundary.js.map +1 -1
- package/dist/react-native/XmlRender.d.ts +4 -2
- package/dist/react-native/XmlRender.d.ts.map +1 -1
- package/dist/react-native/XmlRender.js +4 -28
- package/dist/react-native/XmlRender.js.map +1 -1
- package/dist/react-native/catalog.d.ts +2 -77
- package/dist/react-native/catalog.d.ts.map +1 -1
- package/dist/react-native/catalog.js +3 -34
- package/dist/react-native/catalog.js.map +1 -1
- package/dist/react-native/context.d.ts +2 -47
- package/dist/react-native/context.d.ts.map +1 -1
- package/dist/react-native/context.js +2 -44
- package/dist/react-native/context.js.map +1 -1
- package/dist/registry.d.ts +2 -51
- package/dist/registry.d.ts.map +1 -1
- package/dist/registry.js.map +1 -1
- package/dist/shared/ErrorBoundary.d.ts +43 -0
- package/dist/shared/ErrorBoundary.d.ts.map +1 -0
- package/dist/shared/ErrorBoundary.js +38 -0
- package/dist/shared/ErrorBoundary.js.map +1 -0
- package/dist/shared/catalog.d.ts +79 -0
- package/dist/shared/catalog.d.ts.map +1 -0
- package/dist/shared/catalog.js +32 -0
- package/dist/shared/catalog.js.map +1 -0
- package/dist/shared/context.d.ts +42 -0
- package/dist/shared/context.d.ts.map +1 -0
- package/dist/shared/context.js +39 -0
- package/dist/shared/context.js.map +1 -0
- package/dist/shared/renderSegment.d.ts +26 -0
- package/dist/shared/renderSegment.d.ts.map +1 -0
- package/dist/shared/renderSegment.js +30 -0
- package/dist/shared/renderSegment.js.map +1 -0
- package/dist/types.d.ts +32 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/package.json +3 -3
|
@@ -1,72 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Component Catalog for React Native XML Renderer
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
* The catalog ensures that each registered tag type has a corresponding
|
|
6
|
-
* renderer component with properly typed props.
|
|
7
|
-
*/
|
|
8
|
-
import type { ComponentType } from "react";
|
|
9
|
-
import type { TagDefinitions, Registry } from "../registry";
|
|
10
|
-
import type { ParsedSegment } from "../parser";
|
|
11
|
-
/**
|
|
12
|
-
* Props passed to segment renderer components
|
|
13
|
-
*/
|
|
14
|
-
export interface SegmentProps<TDefs extends TagDefinitions, TType extends keyof TDefs | "text"> {
|
|
15
|
-
/** The segment being rendered */
|
|
16
|
-
segment: ParsedSegment<TDefs, TType>;
|
|
17
|
-
/** Index of this segment in the segments array */
|
|
18
|
-
index: number;
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Props for the text segment renderer
|
|
22
|
-
*/
|
|
23
|
-
export interface TextSegmentProps<TDefs extends TagDefinitions> {
|
|
24
|
-
segment: ParsedSegment<TDefs, "text">;
|
|
25
|
-
index: number;
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* A component that renders a specific segment type
|
|
29
|
-
*/
|
|
30
|
-
export type SegmentRenderer<TDefs extends TagDefinitions, TType extends keyof TDefs> = ComponentType<SegmentProps<TDefs, TType>>;
|
|
31
|
-
/**
|
|
32
|
-
* A component that renders text segments
|
|
33
|
-
*/
|
|
34
|
-
export type TextRenderer<TDefs extends TagDefinitions> = ComponentType<TextSegmentProps<TDefs>>;
|
|
35
|
-
/**
|
|
36
|
-
* Component definitions for the catalog - maps tag names to renderers
|
|
37
|
-
*/
|
|
38
|
-
export type CatalogComponents<TDefs extends TagDefinitions> = {
|
|
39
|
-
[K in keyof TDefs]: SegmentRenderer<TDefs, K>;
|
|
40
|
-
};
|
|
41
|
-
/**
|
|
42
|
-
* The catalog interface returned by createCatalog
|
|
43
|
-
*/
|
|
44
|
-
export interface Catalog<TDefs extends TagDefinitions> {
|
|
45
|
-
/** Get the renderer component for a specific segment type */
|
|
46
|
-
getRenderer<K extends keyof TDefs>(type: K): SegmentRenderer<TDefs, K> | undefined;
|
|
47
|
-
/** Get the text segment renderer */
|
|
48
|
-
getTextRenderer(): TextRenderer<TDefs> | undefined;
|
|
49
|
-
/** Check if a renderer exists for a segment type */
|
|
50
|
-
hasRenderer(type: keyof TDefs | "text"): boolean;
|
|
51
|
-
/** The registry this catalog is based on */
|
|
52
|
-
readonly registry: Registry<TDefs>;
|
|
53
|
-
/** All registered component renderers */
|
|
54
|
-
readonly components: Readonly<Partial<CatalogComponents<TDefs>>>;
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* Options for creating a catalog
|
|
58
|
-
*/
|
|
59
|
-
export interface CatalogOptions<TDefs extends TagDefinitions> {
|
|
60
|
-
/** Component renderers for each tag type */
|
|
61
|
-
components: Partial<CatalogComponents<TDefs>>;
|
|
62
|
-
/** Optional text segment renderer (default renders plain text in a Text component) */
|
|
63
|
-
textRenderer?: TextRenderer<TDefs>;
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* Create a component catalog for rendering XML segments in React Native.
|
|
67
|
-
*
|
|
68
|
-
* The catalog maps registered tag types to React Native components that render them.
|
|
69
|
-
* TypeScript ensures that component props match the tag's attribute schema.
|
|
4
|
+
* Re-exports the shared catalog implementation.
|
|
70
5
|
*
|
|
71
6
|
* @example
|
|
72
7
|
* ```tsx
|
|
@@ -81,20 +16,10 @@ export interface CatalogOptions<TDefs extends TagDefinitions> {
|
|
|
81
16
|
* <Text>{segment.content}</Text>
|
|
82
17
|
* </View>
|
|
83
18
|
* ),
|
|
84
|
-
* chart: ({ segment }) => (
|
|
85
|
-
* <ChartComponent
|
|
86
|
-
* type={segment.attributes?.type}
|
|
87
|
-
* data={segment.content}
|
|
88
|
-
* />
|
|
89
|
-
* ),
|
|
90
19
|
* },
|
|
91
20
|
* textRenderer: ({ segment }) => <Text>{segment.content}</Text>,
|
|
92
21
|
* });
|
|
93
22
|
* ```
|
|
94
|
-
*
|
|
95
|
-
* @param registry - The tag registry defining valid segment types
|
|
96
|
-
* @param options - Component renderers and optional text renderer
|
|
97
|
-
* @returns A catalog instance for use with XmlRenderProvider
|
|
98
23
|
*/
|
|
99
|
-
export
|
|
24
|
+
export { createCatalog, type Catalog, type CatalogOptions, type CatalogComponents, type SegmentProps, type SegmentRenderer, type TextRenderer, type TextSegmentProps, } from "../shared/catalog";
|
|
100
25
|
//# sourceMappingURL=catalog.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"catalog.d.ts","sourceRoot":"","sources":["../../src/react-native/catalog.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"catalog.d.ts","sourceRoot":"","sources":["../../src/react-native/catalog.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,OAAO,EACL,aAAa,EACb,KAAK,OAAO,EACZ,KAAK,cAAc,EACnB,KAAK,iBAAiB,EACtB,KAAK,YAAY,EACjB,KAAK,eAAe,EACpB,KAAK,YAAY,EACjB,KAAK,gBAAgB,GACtB,MAAM,mBAAmB,CAAC"}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Component Catalog for React Native XML Renderer
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
* TypeScript ensures that component props match the tag's attribute schema.
|
|
4
|
+
* Re-exports the shared catalog implementation.
|
|
6
5
|
*
|
|
7
6
|
* @example
|
|
8
7
|
* ```tsx
|
|
@@ -17,40 +16,10 @@
|
|
|
17
16
|
* <Text>{segment.content}</Text>
|
|
18
17
|
* </View>
|
|
19
18
|
* ),
|
|
20
|
-
* chart: ({ segment }) => (
|
|
21
|
-
* <ChartComponent
|
|
22
|
-
* type={segment.attributes?.type}
|
|
23
|
-
* data={segment.content}
|
|
24
|
-
* />
|
|
25
|
-
* ),
|
|
26
19
|
* },
|
|
27
20
|
* textRenderer: ({ segment }) => <Text>{segment.content}</Text>,
|
|
28
21
|
* });
|
|
29
22
|
* ```
|
|
30
|
-
*
|
|
31
|
-
* @param registry - The tag registry defining valid segment types
|
|
32
|
-
* @param options - Component renderers and optional text renderer
|
|
33
|
-
* @returns A catalog instance for use with XmlRenderProvider
|
|
34
23
|
*/
|
|
35
|
-
export
|
|
36
|
-
const { components, textRenderer } = options;
|
|
37
|
-
const frozenComponents = Object.freeze({ ...components });
|
|
38
|
-
const catalog = {
|
|
39
|
-
registry,
|
|
40
|
-
components: frozenComponents,
|
|
41
|
-
getRenderer(type) {
|
|
42
|
-
return frozenComponents[type];
|
|
43
|
-
},
|
|
44
|
-
getTextRenderer() {
|
|
45
|
-
return textRenderer;
|
|
46
|
-
},
|
|
47
|
-
hasRenderer(type) {
|
|
48
|
-
if (type === "text") {
|
|
49
|
-
return textRenderer !== undefined;
|
|
50
|
-
}
|
|
51
|
-
return type in frozenComponents;
|
|
52
|
-
},
|
|
53
|
-
};
|
|
54
|
-
return Object.freeze(catalog);
|
|
55
|
-
}
|
|
24
|
+
export { createCatalog, } from "../shared/catalog";
|
|
56
25
|
//# sourceMappingURL=catalog.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"catalog.js","sourceRoot":"","sources":["../../src/react-native/catalog.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"catalog.js","sourceRoot":"","sources":["../../src/react-native/catalog.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,OAAO,EACL,aAAa,GAQd,MAAM,mBAAmB,CAAC"}
|
|
@@ -1,32 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* React Native Context for XML Render
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
* This allows XmlRender components to access the catalog without prop drilling.
|
|
6
|
-
*/
|
|
7
|
-
import React, { type ReactNode } from "react";
|
|
8
|
-
import type { TagDefinitions } from "../registry";
|
|
9
|
-
import type { Catalog } from "./catalog";
|
|
10
|
-
/**
|
|
11
|
-
* Context value type containing the catalog
|
|
12
|
-
*/
|
|
13
|
-
interface XmlRenderContextValue<TDefs extends TagDefinitions> {
|
|
14
|
-
catalog: Catalog<TDefs>;
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* Props for XmlRenderProvider
|
|
18
|
-
*/
|
|
19
|
-
export interface XmlRenderProviderProps<TDefs extends TagDefinitions> {
|
|
20
|
-
/** The component catalog to provide to the tree */
|
|
21
|
-
catalog: Catalog<TDefs>;
|
|
22
|
-
/** Child components that can use XmlRender */
|
|
23
|
-
children: ReactNode;
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* Provider component that makes the catalog available to XmlRender components.
|
|
27
|
-
*
|
|
28
|
-
* Wrap your application or component tree with this provider to enable
|
|
29
|
-
* XML segment rendering in React Native.
|
|
4
|
+
* Re-exports the shared context implementation.
|
|
30
5
|
*
|
|
31
6
|
* @example
|
|
32
7
|
* ```tsx
|
|
@@ -42,25 +17,5 @@ export interface XmlRenderProviderProps<TDefs extends TagDefinitions> {
|
|
|
42
17
|
* }
|
|
43
18
|
* ```
|
|
44
19
|
*/
|
|
45
|
-
export
|
|
46
|
-
/**
|
|
47
|
-
* Hook to access the XML render catalog from context.
|
|
48
|
-
*
|
|
49
|
-
* Must be used within an XmlRenderProvider.
|
|
50
|
-
*
|
|
51
|
-
* @throws Error if used outside of XmlRenderProvider
|
|
52
|
-
* @returns The current catalog from context
|
|
53
|
-
*
|
|
54
|
-
* @example
|
|
55
|
-
* ```tsx
|
|
56
|
-
* import { useXmlRenderContext } from '@khairold/xml-render/react-native';
|
|
57
|
-
*
|
|
58
|
-
* function CustomRenderer() {
|
|
59
|
-
* const { catalog } = useXmlRenderContext();
|
|
60
|
-
* // Use catalog to look up renderers...
|
|
61
|
-
* }
|
|
62
|
-
* ```
|
|
63
|
-
*/
|
|
64
|
-
export declare function useXmlRenderContext<TDefs extends TagDefinitions = TagDefinitions>(): XmlRenderContextValue<TDefs>;
|
|
65
|
-
export {};
|
|
20
|
+
export { XmlRenderProvider, useXmlRenderContext, type XmlRenderProviderProps, } from "../shared/context";
|
|
66
21
|
//# sourceMappingURL=context.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/react-native/context.tsx"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/react-native/context.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,OAAO,EACL,iBAAiB,EACjB,mBAAmB,EACnB,KAAK,sBAAsB,GAC5B,MAAM,mBAAmB,CAAC"}
|
|
@@ -1,20 +1,7 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
1
|
/**
|
|
3
2
|
* React Native Context for XML Render
|
|
4
3
|
*
|
|
5
|
-
*
|
|
6
|
-
* This allows XmlRender components to access the catalog without prop drilling.
|
|
7
|
-
*/
|
|
8
|
-
import { createContext, useContext } from "react";
|
|
9
|
-
/**
|
|
10
|
-
* Internal context - stores catalog as unknown, typed at provider/consumer level
|
|
11
|
-
*/
|
|
12
|
-
const XmlRenderContext = createContext(null);
|
|
13
|
-
/**
|
|
14
|
-
* Provider component that makes the catalog available to XmlRender components.
|
|
15
|
-
*
|
|
16
|
-
* Wrap your application or component tree with this provider to enable
|
|
17
|
-
* XML segment rendering in React Native.
|
|
4
|
+
* Re-exports the shared context implementation.
|
|
18
5
|
*
|
|
19
6
|
* @example
|
|
20
7
|
* ```tsx
|
|
@@ -30,34 +17,5 @@ const XmlRenderContext = createContext(null);
|
|
|
30
17
|
* }
|
|
31
18
|
* ```
|
|
32
19
|
*/
|
|
33
|
-
export
|
|
34
|
-
const value = { catalog };
|
|
35
|
-
return (_jsx(XmlRenderContext.Provider, { value: value, children: children }));
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Hook to access the XML render catalog from context.
|
|
39
|
-
*
|
|
40
|
-
* Must be used within an XmlRenderProvider.
|
|
41
|
-
*
|
|
42
|
-
* @throws Error if used outside of XmlRenderProvider
|
|
43
|
-
* @returns The current catalog from context
|
|
44
|
-
*
|
|
45
|
-
* @example
|
|
46
|
-
* ```tsx
|
|
47
|
-
* import { useXmlRenderContext } from '@khairold/xml-render/react-native';
|
|
48
|
-
*
|
|
49
|
-
* function CustomRenderer() {
|
|
50
|
-
* const { catalog } = useXmlRenderContext();
|
|
51
|
-
* // Use catalog to look up renderers...
|
|
52
|
-
* }
|
|
53
|
-
* ```
|
|
54
|
-
*/
|
|
55
|
-
export function useXmlRenderContext() {
|
|
56
|
-
const context = useContext(XmlRenderContext);
|
|
57
|
-
if (!context) {
|
|
58
|
-
throw new Error("useXmlRenderContext must be used within an XmlRenderProvider");
|
|
59
|
-
}
|
|
60
|
-
// Cast the internal unknown catalog back to the typed version
|
|
61
|
-
return { catalog: context.catalog };
|
|
62
|
-
}
|
|
20
|
+
export { XmlRenderProvider, useXmlRenderContext, } from "../shared/context";
|
|
63
21
|
//# sourceMappingURL=context.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../src/react-native/context.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../src/react-native/context.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,OAAO,EACL,iBAAiB,EACjB,mBAAmB,GAEpB,MAAM,mBAAmB,CAAC"}
|
package/dist/registry.d.ts
CHANGED
|
@@ -4,57 +4,8 @@
|
|
|
4
4
|
* Creates an immutable registry of XML tag definitions with Zod schema validation.
|
|
5
5
|
* TypeScript infers attribute types directly from the Zod schemas.
|
|
6
6
|
*/
|
|
7
|
-
import type {
|
|
8
|
-
|
|
9
|
-
* Definition for a single XML tag in the registry
|
|
10
|
-
*/
|
|
11
|
-
export interface TagDefinition<TSchema extends ZodType = ZodType> {
|
|
12
|
-
/** Zod schema for validating and typing tag attributes */
|
|
13
|
-
schema: TSchema;
|
|
14
|
-
/** Whether the tag contains inner content (default: true) */
|
|
15
|
-
hasContent?: boolean;
|
|
16
|
-
/** Whether the tag is self-closing like <image /> (default: false) */
|
|
17
|
-
selfClosing?: boolean;
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Input type for createRegistry - a record of tag names to definitions
|
|
21
|
-
*/
|
|
22
|
-
export type TagDefinitions = Record<string, TagDefinition>;
|
|
23
|
-
/**
|
|
24
|
-
* Infer the attribute type from a TagDefinition's Zod schema
|
|
25
|
-
*/
|
|
26
|
-
export type InferAttributes<T extends TagDefinition> = ZodInfer<T["schema"]>;
|
|
27
|
-
/**
|
|
28
|
-
* Safe parse result type for validateAttributes
|
|
29
|
-
*/
|
|
30
|
-
export type SafeParseResult<T> = {
|
|
31
|
-
success: true;
|
|
32
|
-
data: T;
|
|
33
|
-
} | {
|
|
34
|
-
success: false;
|
|
35
|
-
error: unknown;
|
|
36
|
-
};
|
|
37
|
-
/**
|
|
38
|
-
* The immutable registry type returned by createRegistry
|
|
39
|
-
*/
|
|
40
|
-
export interface Registry<TDefs extends TagDefinitions> {
|
|
41
|
-
/** Get all registered tag names */
|
|
42
|
-
readonly tagNames: ReadonlyArray<keyof TDefs & string>;
|
|
43
|
-
/** Get the definition for a specific tag */
|
|
44
|
-
getTag<K extends keyof TDefs>(name: K): Readonly<TDefs[K]> | undefined;
|
|
45
|
-
/** Check if a tag name is registered */
|
|
46
|
-
hasTag(name: string): name is keyof TDefs & string;
|
|
47
|
-
/** Get the Zod schema for a tag's attributes */
|
|
48
|
-
getSchema<K extends keyof TDefs>(name: K): TDefs[K]["schema"] | undefined;
|
|
49
|
-
/** Validate attributes for a tag using its Zod schema */
|
|
50
|
-
validateAttributes<K extends keyof TDefs>(name: K, attributes: unknown): SafeParseResult<InferAttributes<TDefs[K]>>;
|
|
51
|
-
/** Check if a tag is self-closing */
|
|
52
|
-
isSelfClosing<K extends keyof TDefs>(name: K): boolean;
|
|
53
|
-
/** Check if a tag has content */
|
|
54
|
-
hasContent<K extends keyof TDefs>(name: K): boolean;
|
|
55
|
-
/** The raw definitions (frozen) */
|
|
56
|
-
readonly definitions: Readonly<TDefs>;
|
|
57
|
-
}
|
|
7
|
+
import type { TagDefinitions, Registry } from "./types";
|
|
8
|
+
export type { TagDefinition, TagDefinitions, InferAttributes, SafeParseResult, Registry, } from "./types";
|
|
58
9
|
/**
|
|
59
10
|
* Create an immutable tag registry from tag definitions.
|
|
60
11
|
*
|
package/dist/registry.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../src/registry.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../src/registry.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,EAEV,cAAc,EAGd,QAAQ,EACT,MAAM,SAAS,CAAC;AAGjB,YAAY,EACV,aAAa,EACb,cAAc,EACd,eAAe,EACf,eAAe,EACf,QAAQ,GACT,MAAM,SAAS,CAAC;AAEjB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,wBAAgB,cAAc,CAAC,KAAK,SAAS,cAAc,EACzD,WAAW,EAAE,KAAK,GACjB,QAAQ,CAAC,KAAK,CAAC,CAsEjB"}
|
package/dist/registry.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../src/registry.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../src/registry.ts"],"names":[],"mappings":"AAuBA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,MAAM,UAAU,cAAc,CAC5B,WAAkB;IAElB,wDAAwD;IACxD,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,CAC9B,MAAM,CAAC,WAAW,CAChB,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,GAAG,CAAC,EAAE,EAAE,CAAC;QAC/C,IAAI;QACJ,MAAM,CAAC,MAAM,CAAC;YACZ,GAAG,GAAG;YACN,UAAU,EAAE,GAAG,CAAC,UAAU,IAAI,IAAI;YAClC,WAAW,EAAE,GAAG,CAAC,WAAW,IAAI,KAAK;SACtC,CAAC;KACH,CAAC,CACH,CACiB,CAAC;IAErB,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAErD,CAAC;IAEF,MAAM,UAAU,GAAG,IAAI,GAAG,CAAC,QAAQ,CAAC,CAAC;IAErC,MAAM,QAAQ,GAAoB;QAChC,QAAQ;QACR,WAAW,EAAE,UAAU;QAEvB,MAAM,CAAwB,IAAO;YACnC,OAAO,UAAU,CAAC,IAAI,CAAC,CAAC;QAC1B,CAAC;QAED,MAAM,CAAC,IAAY;YACjB,OAAO,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QAC9B,CAAC;QAED,SAAS,CAAwB,IAAO;YACtC,OAAO,UAAU,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;QAClC,CAAC;QAED,kBAAkB,CAChB,IAAO,EACP,UAAmB;YAEnB,MAAM,MAAM,GAAG,UAAU,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;YACxC,IAAI,CAAC,MAAM,EAAE,CAAC;gBACZ,OAAO;oBACL,OAAO,EAAE,KAAK;oBACd,KAAK,EAAE,IAAI,KAAK,CAAC,gBAAgB,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC;iBACjD,CAAC;YACJ,CAAC;YACD,+CAA+C;YAC/C,MAAM,MAAM,GAAG,MAAM,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;YAC5C,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;gBACnB,OAAO;oBACL,OAAO,EAAE,IAAI;oBACb,IAAI,EAAE,MAAM,CAAC,IAAiC;iBAC/C,CAAC;YACJ,CAAC;YACD,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,CAAC;QACjD,CAAC;QAED,aAAa,CAAwB,IAAO;YAC1C,OAAO,UAAU,CAAC,IAAI,CAAC,EAAE,WAAW,IAAI,KAAK,CAAC;QAChD,CAAC;QAED,UAAU,CAAwB,IAAO;YACvC,OAAO,UAAU,CAAC,IAAI,CAAC,EAAE,UAAU,IAAI,IAAI,CAAC;QAC9C,CAAC;KACF,CAAC;IAEF,6BAA6B;IAC7B,OAAO,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;AACjC,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared ErrorBoundary base class
|
|
3
|
+
*
|
|
4
|
+
* Catches render errors in segment components and delegates
|
|
5
|
+
* error UI rendering to platform-specific implementations.
|
|
6
|
+
*/
|
|
7
|
+
import { Component, type ReactNode, type ErrorInfo } from "react";
|
|
8
|
+
/**
|
|
9
|
+
* Props for the base ErrorBoundary component
|
|
10
|
+
*/
|
|
11
|
+
export interface ErrorBoundaryBaseProps {
|
|
12
|
+
/** The child components to render */
|
|
13
|
+
children: ReactNode;
|
|
14
|
+
/** The segment type being rendered (for error messages) */
|
|
15
|
+
segmentType: string;
|
|
16
|
+
/** Optional custom fallback renderer */
|
|
17
|
+
fallback?: (error: Error, segmentType: string) => ReactNode;
|
|
18
|
+
/** Platform-specific renderer for development error UI */
|
|
19
|
+
renderDevError: (error: Error, segmentType: string) => ReactNode;
|
|
20
|
+
/** Platform-specific renderer for production fallback UI */
|
|
21
|
+
renderProdFallback: () => ReactNode;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* State for the ErrorBoundary component
|
|
25
|
+
*/
|
|
26
|
+
interface ErrorBoundaryState {
|
|
27
|
+
hasError: boolean;
|
|
28
|
+
error: Error | null;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Base error boundary class with shared logic.
|
|
32
|
+
*
|
|
33
|
+
* Platform-specific error rendering is injected via renderDevError
|
|
34
|
+
* and renderProdFallback props.
|
|
35
|
+
*/
|
|
36
|
+
export declare class ErrorBoundaryBase extends Component<ErrorBoundaryBaseProps, ErrorBoundaryState> {
|
|
37
|
+
constructor(props: ErrorBoundaryBaseProps);
|
|
38
|
+
static getDerivedStateFromError(error: Error): ErrorBoundaryState;
|
|
39
|
+
componentDidCatch(error: Error, errorInfo: ErrorInfo): void;
|
|
40
|
+
render(): ReactNode;
|
|
41
|
+
}
|
|
42
|
+
export {};
|
|
43
|
+
//# sourceMappingURL=ErrorBoundary.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ErrorBoundary.d.ts","sourceRoot":"","sources":["../../src/shared/ErrorBoundary.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,SAAS,EAAE,KAAK,SAAS,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAElE;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC,qCAAqC;IACrC,QAAQ,EAAE,SAAS,CAAC;IACpB,2DAA2D;IAC3D,WAAW,EAAE,MAAM,CAAC;IACpB,wCAAwC;IACxC,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,KAAK,SAAS,CAAC;IAC5D,0DAA0D;IAC1D,cAAc,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,KAAK,SAAS,CAAC;IACjE,4DAA4D;IAC5D,kBAAkB,EAAE,MAAM,SAAS,CAAC;CACrC;AAED;;GAEG;AACH,UAAU,kBAAkB;IAC1B,QAAQ,EAAE,OAAO,CAAC;IAClB,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;CACrB;AAED;;;;;GAKG;AACH,qBAAa,iBAAkB,SAAQ,SAAS,CAC9C,sBAAsB,EACtB,kBAAkB,CACnB;gBACa,KAAK,EAAE,sBAAsB;IAKzC,MAAM,CAAC,wBAAwB,CAAC,KAAK,EAAE,KAAK,GAAG,kBAAkB;IAIjE,iBAAiB,CAAC,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,SAAS,GAAG,IAAI;IAQ3D,MAAM,IAAI,SAAS;CAepB"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared ErrorBoundary base class
|
|
3
|
+
*
|
|
4
|
+
* Catches render errors in segment components and delegates
|
|
5
|
+
* error UI rendering to platform-specific implementations.
|
|
6
|
+
*/
|
|
7
|
+
import { Component } from "react";
|
|
8
|
+
/**
|
|
9
|
+
* Base error boundary class with shared logic.
|
|
10
|
+
*
|
|
11
|
+
* Platform-specific error rendering is injected via renderDevError
|
|
12
|
+
* and renderProdFallback props.
|
|
13
|
+
*/
|
|
14
|
+
export class ErrorBoundaryBase extends Component {
|
|
15
|
+
constructor(props) {
|
|
16
|
+
super(props);
|
|
17
|
+
this.state = { hasError: false, error: null };
|
|
18
|
+
}
|
|
19
|
+
static getDerivedStateFromError(error) {
|
|
20
|
+
return { hasError: true, error };
|
|
21
|
+
}
|
|
22
|
+
componentDidCatch(error, errorInfo) {
|
|
23
|
+
console.error(`XmlRender ErrorBoundary: Failed to render segment type "${this.props.segmentType}"`, error, errorInfo.componentStack);
|
|
24
|
+
}
|
|
25
|
+
render() {
|
|
26
|
+
if (this.state.hasError && this.state.error) {
|
|
27
|
+
if (this.props.fallback) {
|
|
28
|
+
return this.props.fallback(this.state.error, this.props.segmentType);
|
|
29
|
+
}
|
|
30
|
+
if (process.env.NODE_ENV === "development") {
|
|
31
|
+
return this.props.renderDevError(this.state.error, this.props.segmentType);
|
|
32
|
+
}
|
|
33
|
+
return this.props.renderProdFallback();
|
|
34
|
+
}
|
|
35
|
+
return this.props.children;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=ErrorBoundary.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ErrorBoundary.js","sourceRoot":"","sources":["../../src/shared/ErrorBoundary.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,SAAS,EAAkC,MAAM,OAAO,CAAC;AA0BlE;;;;;GAKG;AACH,MAAM,OAAO,iBAAkB,SAAQ,SAGtC;IACC,YAAY,KAA6B;QACvC,KAAK,CAAC,KAAK,CAAC,CAAC;QACb,IAAI,CAAC,KAAK,GAAG,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;IAChD,CAAC;IAED,MAAM,CAAC,wBAAwB,CAAC,KAAY;QAC1C,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;IACnC,CAAC;IAED,iBAAiB,CAAC,KAAY,EAAE,SAAoB;QAClD,OAAO,CAAC,KAAK,CACX,2DAA2D,IAAI,CAAC,KAAK,CAAC,WAAW,GAAG,EACpF,KAAK,EACL,SAAS,CAAC,cAAc,CACzB,CAAC;IACJ,CAAC;IAED,MAAM;QACJ,IAAI,IAAI,CAAC,KAAK,CAAC,QAAQ,IAAI,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;YAC5C,IAAI,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC;gBACxB,OAAO,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;YACvE,CAAC;YAED,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,aAAa,EAAE,CAAC;gBAC3C,OAAO,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;YAC7E,CAAC;YAED,OAAO,IAAI,CAAC,KAAK,CAAC,kBAAkB,EAAE,CAAC;QACzC,CAAC;QAED,OAAO,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC;IAC7B,CAAC;CACF"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Component Catalog (Shared)
|
|
3
|
+
*
|
|
4
|
+
* Creates a type-safe mapping from segment types to React/React Native components.
|
|
5
|
+
* The catalog ensures that each registered tag type has a corresponding
|
|
6
|
+
* renderer component with properly typed props.
|
|
7
|
+
*/
|
|
8
|
+
import type { ComponentType } from "react";
|
|
9
|
+
import type { TagDefinitions, Registry } from "../registry";
|
|
10
|
+
import type { ParsedSegment } from "../parser";
|
|
11
|
+
/**
|
|
12
|
+
* Props passed to segment renderer components
|
|
13
|
+
*/
|
|
14
|
+
export interface SegmentProps<TDefs extends TagDefinitions, TType extends keyof TDefs | "text"> {
|
|
15
|
+
/** The segment being rendered */
|
|
16
|
+
segment: ParsedSegment<TDefs, TType>;
|
|
17
|
+
/** Index of this segment in the segments array */
|
|
18
|
+
index: number;
|
|
19
|
+
/** Whether this segment is still streaming (true for partial segments) */
|
|
20
|
+
streaming?: boolean;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Props for the text segment renderer
|
|
24
|
+
*/
|
|
25
|
+
export interface TextSegmentProps<TDefs extends TagDefinitions> {
|
|
26
|
+
segment: ParsedSegment<TDefs, "text">;
|
|
27
|
+
index: number;
|
|
28
|
+
streaming?: boolean;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* A component that renders a specific segment type
|
|
32
|
+
*/
|
|
33
|
+
export type SegmentRenderer<TDefs extends TagDefinitions, TType extends keyof TDefs> = ComponentType<SegmentProps<TDefs, TType>>;
|
|
34
|
+
/**
|
|
35
|
+
* A component that renders text segments
|
|
36
|
+
*/
|
|
37
|
+
export type TextRenderer<TDefs extends TagDefinitions> = ComponentType<TextSegmentProps<TDefs>>;
|
|
38
|
+
/**
|
|
39
|
+
* Component definitions for the catalog - maps tag names to renderers
|
|
40
|
+
*/
|
|
41
|
+
export type CatalogComponents<TDefs extends TagDefinitions> = {
|
|
42
|
+
[K in keyof TDefs]: SegmentRenderer<TDefs, K>;
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* The catalog interface returned by createCatalog
|
|
46
|
+
*/
|
|
47
|
+
export interface Catalog<TDefs extends TagDefinitions> {
|
|
48
|
+
/** Get the renderer component for a specific segment type */
|
|
49
|
+
getRenderer<K extends keyof TDefs>(type: K): SegmentRenderer<TDefs, K> | undefined;
|
|
50
|
+
/** Get the text segment renderer */
|
|
51
|
+
getTextRenderer(): TextRenderer<TDefs> | undefined;
|
|
52
|
+
/** Check if a renderer exists for a segment type */
|
|
53
|
+
hasRenderer(type: keyof TDefs | "text"): boolean;
|
|
54
|
+
/** The registry this catalog is based on */
|
|
55
|
+
readonly registry: Registry<TDefs>;
|
|
56
|
+
/** All registered component renderers */
|
|
57
|
+
readonly components: Readonly<Partial<CatalogComponents<TDefs>>>;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Options for creating a catalog
|
|
61
|
+
*/
|
|
62
|
+
export interface CatalogOptions<TDefs extends TagDefinitions> {
|
|
63
|
+
/** Component renderers for each tag type */
|
|
64
|
+
components: Partial<CatalogComponents<TDefs>>;
|
|
65
|
+
/** Optional text segment renderer */
|
|
66
|
+
textRenderer?: TextRenderer<TDefs>;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Create a component catalog for rendering XML segments.
|
|
70
|
+
*
|
|
71
|
+
* The catalog maps registered tag types to renderer components.
|
|
72
|
+
* TypeScript ensures that component props match the tag's attribute schema.
|
|
73
|
+
*
|
|
74
|
+
* @param registry - The tag registry defining valid segment types
|
|
75
|
+
* @param options - Component renderers and optional text renderer
|
|
76
|
+
* @returns A catalog instance for use with XmlRenderProvider
|
|
77
|
+
*/
|
|
78
|
+
export declare function createCatalog<TDefs extends TagDefinitions>(registry: Registry<TDefs>, options: CatalogOptions<TDefs>): Catalog<TDefs>;
|
|
79
|
+
//# sourceMappingURL=catalog.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"catalog.d.ts","sourceRoot":"","sources":["../../src/shared/catalog.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAC3C,OAAO,KAAK,EACV,cAAc,EACd,QAAQ,EACT,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAE/C;;GAEG;AACH,MAAM,WAAW,YAAY,CAC3B,KAAK,SAAS,cAAc,EAC5B,KAAK,SAAS,MAAM,KAAK,GAAG,MAAM;IAElC,iCAAiC;IACjC,OAAO,EAAE,aAAa,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;IACrC,kDAAkD;IAClD,KAAK,EAAE,MAAM,CAAC;IACd,0EAA0E;IAC1E,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB,CAAC,KAAK,SAAS,cAAc;IAC5D,OAAO,EAAE,aAAa,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IACtC,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED;;GAEG;AACH,MAAM,MAAM,eAAe,CACzB,KAAK,SAAS,cAAc,EAC5B,KAAK,SAAS,MAAM,KAAK,IACvB,aAAa,CAAC,YAAY,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC;AAE9C;;GAEG;AACH,MAAM,MAAM,YAAY,CAAC,KAAK,SAAS,cAAc,IAAI,aAAa,CACpE,gBAAgB,CAAC,KAAK,CAAC,CACxB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,iBAAiB,CAAC,KAAK,SAAS,cAAc,IAAI;KAC3D,CAAC,IAAI,MAAM,KAAK,GAAG,eAAe,CAAC,KAAK,EAAE,CAAC,CAAC;CAC9C,CAAC;AAEF;;GAEG;AACH,MAAM,WAAW,OAAO,CAAC,KAAK,SAAS,cAAc;IACnD,6DAA6D;IAC7D,WAAW,CAAC,CAAC,SAAS,MAAM,KAAK,EAAE,IAAI,EAAE,CAAC,GAAG,eAAe,CAAC,KAAK,EAAE,CAAC,CAAC,GAAG,SAAS,CAAC;IAEnF,oCAAoC;IACpC,eAAe,IAAI,YAAY,CAAC,KAAK,CAAC,GAAG,SAAS,CAAC;IAEnD,oDAAoD;IACpD,WAAW,CAAC,IAAI,EAAE,MAAM,KAAK,GAAG,MAAM,GAAG,OAAO,CAAC;IAEjD,4CAA4C;IAC5C,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC,KAAK,CAAC,CAAC;IAEnC,yCAAyC;IACzC,QAAQ,CAAC,UAAU,EAAE,QAAQ,CAAC,OAAO,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;CAClE;AAED;;GAEG;AACH,MAAM,WAAW,cAAc,CAAC,KAAK,SAAS,cAAc;IAC1D,4CAA4C;IAC5C,UAAU,EAAE,OAAO,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC,CAAC;IAC9C,qCAAqC;IACrC,YAAY,CAAC,EAAE,YAAY,CAAC,KAAK,CAAC,CAAC;CACpC;AAED;;;;;;;;;GASG;AACH,wBAAgB,aAAa,CAAC,KAAK,SAAS,cAAc,EACxD,QAAQ,EAAE,QAAQ,CAAC,KAAK,CAAC,EACzB,OAAO,EAAE,cAAc,CAAC,KAAK,CAAC,GAC7B,OAAO,CAAC,KAAK,CAAC,CA4BhB"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Create a component catalog for rendering XML segments.
|
|
3
|
+
*
|
|
4
|
+
* The catalog maps registered tag types to renderer components.
|
|
5
|
+
* TypeScript ensures that component props match the tag's attribute schema.
|
|
6
|
+
*
|
|
7
|
+
* @param registry - The tag registry defining valid segment types
|
|
8
|
+
* @param options - Component renderers and optional text renderer
|
|
9
|
+
* @returns A catalog instance for use with XmlRenderProvider
|
|
10
|
+
*/
|
|
11
|
+
export function createCatalog(registry, options) {
|
|
12
|
+
const { components, textRenderer } = options;
|
|
13
|
+
const frozenComponents = Object.freeze({ ...components });
|
|
14
|
+
const catalog = {
|
|
15
|
+
registry,
|
|
16
|
+
components: frozenComponents,
|
|
17
|
+
getRenderer(type) {
|
|
18
|
+
return frozenComponents[type];
|
|
19
|
+
},
|
|
20
|
+
getTextRenderer() {
|
|
21
|
+
return textRenderer;
|
|
22
|
+
},
|
|
23
|
+
hasRenderer(type) {
|
|
24
|
+
if (type === "text") {
|
|
25
|
+
return textRenderer !== undefined;
|
|
26
|
+
}
|
|
27
|
+
return type in frozenComponents;
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
return Object.freeze(catalog);
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=catalog.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"catalog.js","sourceRoot":"","sources":["../../src/shared/catalog.ts"],"names":[],"mappings":"AA0FA;;;;;;;;;GASG;AACH,MAAM,UAAU,aAAa,CAC3B,QAAyB,EACzB,OAA8B;IAE9B,MAAM,EAAE,UAAU,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC;IAE7C,MAAM,gBAAgB,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,GAAG,UAAU,EAAE,CAEvD,CAAC;IAEF,MAAM,OAAO,GAAmB;QAC9B,QAAQ;QACR,UAAU,EAAE,gBAAgB;QAE5B,WAAW,CAAwB,IAAO;YACxC,OAAO,gBAAgB,CAAC,IAAI,CAA0C,CAAC;QACzE,CAAC;QAED,eAAe;YACb,OAAO,YAAY,CAAC;QACtB,CAAC;QAED,WAAW,CAAC,IAA0B;YACpC,IAAI,IAAI,KAAK,MAAM,EAAE,CAAC;gBACpB,OAAO,YAAY,KAAK,SAAS,CAAC;YACpC,CAAC;YACD,OAAO,IAAI,IAAI,gBAAgB,CAAC;QAClC,CAAC;KACF,CAAC;IAEF,OAAO,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;AAChC,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* React Context for XML Render (Shared)
|
|
3
|
+
*
|
|
4
|
+
* Provides the component catalog to the render tree via React Context.
|
|
5
|
+
* This allows XmlRender components to access the catalog without prop drilling.
|
|
6
|
+
*/
|
|
7
|
+
import React, { type ReactNode } from "react";
|
|
8
|
+
import type { TagDefinitions } from "../registry";
|
|
9
|
+
import type { Catalog } from "./catalog";
|
|
10
|
+
/**
|
|
11
|
+
* Context value type containing the catalog
|
|
12
|
+
*/
|
|
13
|
+
interface XmlRenderContextValue<TDefs extends TagDefinitions> {
|
|
14
|
+
catalog: Catalog<TDefs>;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Props for XmlRenderProvider
|
|
18
|
+
*/
|
|
19
|
+
export interface XmlRenderProviderProps<TDefs extends TagDefinitions> {
|
|
20
|
+
/** The component catalog to provide to the tree */
|
|
21
|
+
catalog: Catalog<TDefs>;
|
|
22
|
+
/** Child components that can use XmlRender */
|
|
23
|
+
children: ReactNode;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Provider component that makes the catalog available to XmlRender components.
|
|
27
|
+
*
|
|
28
|
+
* Wrap your application or component tree with this provider to enable
|
|
29
|
+
* XML segment rendering.
|
|
30
|
+
*/
|
|
31
|
+
export declare function XmlRenderProvider<TDefs extends TagDefinitions>({ catalog, children, }: XmlRenderProviderProps<TDefs>): React.ReactElement;
|
|
32
|
+
/**
|
|
33
|
+
* Hook to access the XML render catalog from context.
|
|
34
|
+
*
|
|
35
|
+
* Must be used within an XmlRenderProvider.
|
|
36
|
+
*
|
|
37
|
+
* @throws Error if used outside of XmlRenderProvider
|
|
38
|
+
* @returns The current catalog from context
|
|
39
|
+
*/
|
|
40
|
+
export declare function useXmlRenderContext<TDefs extends TagDefinitions = TagDefinitions>(): XmlRenderContextValue<TDefs>;
|
|
41
|
+
export {};
|
|
42
|
+
//# sourceMappingURL=context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/shared/context.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,EAAE,EAA6B,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AACzE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEzC;;GAEG;AACH,UAAU,qBAAqB,CAAC,KAAK,SAAS,cAAc;IAC1D,OAAO,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC;CACzB;AAeD;;GAEG;AACH,MAAM,WAAW,sBAAsB,CAAC,KAAK,SAAS,cAAc;IAClE,mDAAmD;IACnD,OAAO,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC;IACxB,8CAA8C;IAC9C,QAAQ,EAAE,SAAS,CAAC;CACrB;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,SAAS,cAAc,EAAE,EAC9D,OAAO,EACP,QAAQ,GACT,EAAE,sBAAsB,CAAC,KAAK,CAAC,GAAG,KAAK,CAAC,YAAY,CAQpD;AAED;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CACjC,KAAK,SAAS,cAAc,GAAG,cAAc,KAC1C,qBAAqB,CAAC,KAAK,CAAC,CAWhC"}
|