@cossistant/react 0.0.28 → 0.0.29
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 +1 -1
- package/api.d.ts +1 -1
- package/api.d.ts.map +1 -1
- package/checks.d.ts +1 -1
- package/checks.d.ts.map +1 -1
- package/clsx.d.ts +1 -1
- package/clsx.d.ts.map +1 -1
- package/coerce.d.ts +1 -1
- package/coerce.d.ts.map +1 -1
- package/conversation.d.ts +3 -3
- package/core.d.ts +1 -1
- package/core.d.ts.map +1 -1
- package/errors.d.ts +12 -3
- package/errors.d.ts.map +1 -1
- package/errors2.d.ts +1 -1
- package/errors2.d.ts.map +1 -1
- package/hooks/index.d.ts +2 -2
- package/hooks/private/use-grouped-messages.d.ts +8 -5
- package/hooks/private/use-grouped-messages.d.ts.map +1 -1
- package/hooks/private/use-grouped-messages.js +44 -11
- package/hooks/private/use-grouped-messages.js.map +1 -1
- package/hooks/use-conversation-seen.js +1 -1
- package/hooks/use-conversation-seen.js.map +1 -1
- package/hooks/use-conversation-timeline.d.ts.map +1 -1
- package/hooks/use-conversation-timeline.js +1 -3
- package/hooks/use-conversation-timeline.js.map +1 -1
- package/index.d.ts +2 -2
- package/json-schema.d.ts +70 -0
- package/json-schema.d.ts.map +1 -0
- package/openapi30.d.ts +1 -1
- package/openapi30.d.ts.map +1 -1
- package/openapi31.d.ts +1 -1
- package/openapi31.d.ts.map +1 -1
- package/package.json +3 -3
- package/parse.d.ts +1 -1
- package/parse.d.ts.map +1 -1
- package/primitives/avatar/fallback.d.ts.map +1 -1
- package/primitives/avatar/fallback.js +1 -1
- package/primitives/avatar/fallback.js.map +1 -1
- package/primitives/avatar/image.d.ts +1 -1
- package/primitives/day-separator.d.ts +76 -0
- package/primitives/day-separator.d.ts.map +1 -0
- package/primitives/day-separator.js +111 -0
- package/primitives/day-separator.js.map +1 -0
- package/primitives/index.d.ts +3 -2
- package/primitives/index.js +6 -1
- package/primitives/index.parts.d.ts +2 -1
- package/primitives/index.parts.js +2 -1
- package/primitives/multimodal-input.d.ts +2 -2
- package/primitives/multimodal-input.d.ts.map +1 -1
- package/primitives/timeline-item-group.d.ts.map +1 -1
- package/primitives/timeline-item-group.js +1 -1
- package/primitives/timeline-item-group.js.map +1 -1
- package/primitives/timeline-item.js +1 -1
- package/primitives/timeline-item.js.map +1 -1
- package/realtime/support-provider.js +4 -0
- package/realtime/support-provider.js.map +1 -1
- package/realtime-events.d.ts +127 -3
- package/realtime-events.d.ts.map +1 -1
- package/registries.d.ts +1 -1
- package/registries.d.ts.map +1 -1
- package/schemas.d.ts +305 -7
- package/schemas.d.ts.map +1 -1
- package/schemas2.d.ts +29 -4
- package/schemas2.d.ts.map +1 -1
- package/schemas3.d.ts +1 -1
- package/specification-extension.d.ts +1 -1
- package/specification-extension.d.ts.map +1 -1
- package/standard-schema.d.ts +83 -21
- package/standard-schema.d.ts.map +1 -1
- package/support/components/button.d.ts +1 -1
- package/support/components/conversation-timeline.d.ts +5 -0
- package/support/components/conversation-timeline.d.ts.map +1 -1
- package/support/components/conversation-timeline.js +22 -2
- package/support/components/conversation-timeline.js.map +1 -1
- package/support/text/index.d.ts +1 -1
- package/support/text/index.d.ts.map +1 -1
- package/support/text/index.js.map +1 -1
- package/to-json-schema.d.ts +96 -0
- package/to-json-schema.d.ts.map +1 -0
- package/util.d.ts +6 -2
- package/util.d.ts.map +1 -1
- package/utils/use-render-element.d.ts.map +1 -1
- package/utils/use-render-element.js +18 -3
- package/utils/use-render-element.js.map +1 -1
- package/versions.d.ts +2 -2
- package/versions.d.ts.map +1 -1
- package/zod-extensions.d.ts +1 -1
- package/zod-extensions.d.ts.map +1 -1
package/standard-schema.d.ts
CHANGED
|
@@ -1,30 +1,55 @@
|
|
|
1
|
-
//#region ../../node_modules/zod/v4/core/standard-schema.d.cts
|
|
2
|
-
/** The Standard
|
|
3
|
-
interface
|
|
4
|
-
/** The Standard
|
|
5
|
-
readonly "~standard":
|
|
1
|
+
//#region ../../node_modules/.bun/zod@4.2.1/node_modules/zod/v4/core/standard-schema.d.cts
|
|
2
|
+
/** The Standard interface. */
|
|
3
|
+
interface StandardTypedV1<Input = unknown, Output = Input> {
|
|
4
|
+
/** The Standard properties. */
|
|
5
|
+
readonly "~standard": StandardTypedV1.Props<Input, Output>;
|
|
6
6
|
}
|
|
7
|
-
declare namespace
|
|
8
|
-
/** The Standard
|
|
7
|
+
declare namespace StandardTypedV1 {
|
|
8
|
+
/** The Standard properties interface. */
|
|
9
9
|
interface Props<Input = unknown, Output = Input> {
|
|
10
10
|
/** The version number of the standard. */
|
|
11
11
|
readonly version: 1;
|
|
12
12
|
/** The vendor name of the schema library. */
|
|
13
13
|
readonly vendor: string;
|
|
14
|
-
/** Validates unknown input values. */
|
|
15
|
-
readonly validate: (value: unknown) => Result<Output> | Promise<Result<Output>>;
|
|
16
14
|
/** Inferred types associated with the schema. */
|
|
17
15
|
readonly types?: Types<Input, Output> | undefined;
|
|
18
16
|
}
|
|
17
|
+
/** The Standard types interface. */
|
|
18
|
+
interface Types<Input = unknown, Output = Input> {
|
|
19
|
+
/** The input type of the schema. */
|
|
20
|
+
readonly input: Input;
|
|
21
|
+
/** The output type of the schema. */
|
|
22
|
+
readonly output: Output;
|
|
23
|
+
}
|
|
24
|
+
/** Infers the input type of a Standard. */
|
|
25
|
+
type InferInput<Schema extends StandardTypedV1> = NonNullable<Schema["~standard"]["types"]>["input"];
|
|
26
|
+
/** Infers the output type of a Standard. */
|
|
27
|
+
type InferOutput<Schema extends StandardTypedV1> = NonNullable<Schema["~standard"]["types"]>["output"];
|
|
28
|
+
}
|
|
29
|
+
/** The Standard Schema interface. */
|
|
30
|
+
interface StandardSchemaV1<Input = unknown, Output = Input> {
|
|
31
|
+
/** The Standard Schema properties. */
|
|
32
|
+
readonly "~standard": StandardSchemaV1.Props<Input, Output>;
|
|
33
|
+
}
|
|
34
|
+
declare namespace StandardSchemaV1 {
|
|
35
|
+
/** The Standard Schema properties interface. */
|
|
36
|
+
interface Props<Input = unknown, Output = Input> extends StandardTypedV1.Props<Input, Output> {
|
|
37
|
+
/** Validates unknown input values. */
|
|
38
|
+
readonly validate: (value: unknown, options?: StandardSchemaV1.Options | undefined) => Result<Output> | Promise<Result<Output>>;
|
|
39
|
+
}
|
|
19
40
|
/** The result interface of the validate function. */
|
|
20
41
|
type Result<Output> = SuccessResult<Output> | FailureResult;
|
|
21
42
|
/** The result interface if validation succeeds. */
|
|
22
43
|
interface SuccessResult<Output> {
|
|
23
44
|
/** The typed output value. */
|
|
24
45
|
readonly value: Output;
|
|
25
|
-
/** The
|
|
46
|
+
/** The absence of issues indicates success. */
|
|
26
47
|
readonly issues?: undefined;
|
|
27
48
|
}
|
|
49
|
+
interface Options {
|
|
50
|
+
/** Implicit support for additional vendor-specific parameters, if needed. */
|
|
51
|
+
readonly libraryOptions?: Record<string, unknown> | undefined;
|
|
52
|
+
}
|
|
28
53
|
/** The result interface if validation fails. */
|
|
29
54
|
interface FailureResult {
|
|
30
55
|
/** The issues of failed validation. */
|
|
@@ -42,18 +67,55 @@ declare namespace StandardSchemaV1 {
|
|
|
42
67
|
/** The key representing a path segment. */
|
|
43
68
|
readonly key: PropertyKey;
|
|
44
69
|
}
|
|
45
|
-
/** The Standard
|
|
46
|
-
interface Types<Input = unknown, Output = Input> {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
70
|
+
/** The Standard types interface. */
|
|
71
|
+
interface Types<Input = unknown, Output = Input> extends StandardTypedV1.Types<Input, Output> {}
|
|
72
|
+
/** Infers the input type of a Standard. */
|
|
73
|
+
type InferInput<Schema extends StandardTypedV1> = StandardTypedV1.InferInput<Schema>;
|
|
74
|
+
/** Infers the output type of a Standard. */
|
|
75
|
+
type InferOutput<Schema extends StandardTypedV1> = StandardTypedV1.InferOutput<Schema>;
|
|
76
|
+
}
|
|
77
|
+
/** The Standard JSON Schema interface. */
|
|
78
|
+
interface StandardJSONSchemaV1<Input = unknown, Output = Input> {
|
|
79
|
+
/** The Standard JSON Schema properties. */
|
|
80
|
+
readonly "~standard": StandardJSONSchemaV1.Props<Input, Output>;
|
|
81
|
+
}
|
|
82
|
+
declare namespace StandardJSONSchemaV1 {
|
|
83
|
+
/** The Standard JSON Schema properties interface. */
|
|
84
|
+
interface Props<Input = unknown, Output = Input> extends StandardTypedV1.Props<Input, Output> {
|
|
85
|
+
/** Methods for generating the input/output JSON Schema. */
|
|
86
|
+
readonly jsonSchema: Converter;
|
|
87
|
+
}
|
|
88
|
+
/** The Standard JSON Schema converter interface. */
|
|
89
|
+
interface Converter {
|
|
90
|
+
/** Converts the input type to JSON Schema. May throw if conversion is not supported. */
|
|
91
|
+
readonly input: (options: StandardJSONSchemaV1.Options) => Record<string, unknown>;
|
|
92
|
+
/** Converts the output type to JSON Schema. May throw if conversion is not supported. */
|
|
93
|
+
readonly output: (options: StandardJSONSchemaV1.Options) => Record<string, unknown>;
|
|
94
|
+
}
|
|
95
|
+
/** The target version of the generated JSON Schema.
|
|
96
|
+
*
|
|
97
|
+
* It is *strongly recommended* that implementers support `"draft-2020-12"` and `"draft-07"`, as they are both in wide use.
|
|
98
|
+
*
|
|
99
|
+
* The `"openapi-3.0"` target is intended as a standardized specifier for OpenAPI 3.0 which is a superset of JSON Schema `"draft-04"`.
|
|
100
|
+
*
|
|
101
|
+
* All other targets can be implemented on a best-effort basis. Libraries should throw if they don't support a specified target.
|
|
102
|
+
*/
|
|
103
|
+
type Target = "draft-2020-12" | "draft-07" | "openapi-3.0" | ({} & string);
|
|
104
|
+
/** The options for the input/output methods. */
|
|
105
|
+
interface Options {
|
|
106
|
+
/** Specifies the target version of the generated JSON Schema. Support for all versions is on a best-effort basis. If a given version is not supported, the library should throw. */
|
|
107
|
+
readonly target: Target;
|
|
108
|
+
/** Implicit support for additional vendor-specific parameters, if needed. */
|
|
109
|
+
readonly libraryOptions?: Record<string, unknown> | undefined;
|
|
51
110
|
}
|
|
52
|
-
/**
|
|
53
|
-
|
|
54
|
-
/** Infers the
|
|
55
|
-
type
|
|
111
|
+
/** The Standard types interface. */
|
|
112
|
+
interface Types<Input = unknown, Output = Input> extends StandardTypedV1.Types<Input, Output> {}
|
|
113
|
+
/** Infers the input type of a Standard. */
|
|
114
|
+
type InferInput<Schema extends StandardTypedV1> = StandardTypedV1.InferInput<Schema>;
|
|
115
|
+
/** Infers the output type of a Standard. */
|
|
116
|
+
type InferOutput<Schema extends StandardTypedV1> = StandardTypedV1.InferOutput<Schema>;
|
|
56
117
|
}
|
|
118
|
+
interface StandardSchemaWithJSONProps<Input = unknown, Output = Input> extends StandardSchemaV1.Props<Input, Output>, StandardJSONSchemaV1.Props<Input, Output> {}
|
|
57
119
|
//#endregion
|
|
58
|
-
export { StandardSchemaV1 };
|
|
120
|
+
export { StandardSchemaV1, StandardSchemaWithJSONProps };
|
|
59
121
|
//# sourceMappingURL=standard-schema.d.ts.map
|
package/standard-schema.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"standard-schema.d.ts","names":["StandardSchemaV1","Input","Output","Props","Schema","Result","Promise","Types","SuccessResult","FailureResult","Issue","ReadonlyArray","PropertyKey","PathSegment","NonNullable"],"sources":["../../../node_modules/zod/v4/core/standard-schema.d.cts"],"sourcesContent":["/** The Standard Schema interface. */\nexport interface StandardSchemaV1<Input = unknown, Output = Input> {\n /** The Standard Schema properties. */\n readonly \"~standard\": StandardSchemaV1.Props<Input, Output>;\n}\nexport declare namespace StandardSchemaV1 {\n /** The Standard Schema properties interface. */\n interface Props<Input = unknown, Output = Input> {\n /** The version number of the standard. */\n readonly version: 1;\n /** The vendor name of the schema library. */\n readonly vendor: string;\n /** Validates unknown input values. */\n readonly validate: (value: unknown) => Result<Output> | Promise<Result<Output>>;\n /** Inferred types associated with the schema. */\n readonly types?: Types<Input, Output> | undefined;\n }\n /** The result interface of the validate function. */\n type Result<Output> = SuccessResult<Output> | FailureResult;\n /** The result interface if validation succeeds. */\n interface SuccessResult<Output> {\n /** The typed output value. */\n readonly value: Output;\n /** The non-existent issues. */\n readonly issues?: undefined;\n }\n /** The result interface if validation fails. */\n interface FailureResult {\n /** The issues of failed validation. */\n readonly issues: ReadonlyArray<Issue>;\n }\n /** The issue interface of the failure output. */\n interface Issue {\n /** The error message of the issue. */\n readonly message: string;\n /** The path of the issue, if any. */\n readonly path?: ReadonlyArray<PropertyKey | PathSegment> | undefined;\n }\n /** The path segment interface of the issue. */\n interface PathSegment {\n /** The key representing a path segment. */\n readonly key: PropertyKey;\n }\n /** The Standard Schema types interface. */\n interface Types<Input = unknown, Output = Input> {\n /** The input type of the schema. */\n readonly input: Input;\n /** The output type of the schema. */\n readonly output: Output;\n }\n /** Infers the input type of a Standard Schema. */\n type InferInput<Schema extends StandardSchemaV1> = NonNullable<Schema[\"~standard\"][\"types\"]>[\"input\"];\n /** Infers the output type of a Standard Schema. */\n type InferOutput<Schema extends StandardSchemaV1> = NonNullable<Schema[\"~standard\"][\"types\"]>[\"output\"];\n}\n"],"x_google_ignoreList":[0],"mappings":";;AACiBA,UAAAA,gBAAgBC,CAAAA,QAAAC,OAAA,EAAA,SAA2BD,KAA3B,CAAA,CAAA;EAA2BA;EAEXA,SAAAA,WAAAA,EAAvBD,gBAAAA,CAAiBG,KAAMF,CAAAA,KAAAA,EAAOC,MAAPD,CAAAA;;AAAvBD,kBAEDA,gBAAAA,CAFkBG;EAAK;EAEvBH,UAAAA,KAAAA,CAAAA,QAAgB,OAAAC,EAAAA,SAEKA,KAFLG,CAAAA,CAAAA;IAEKH;IAMQC,SAAAA,OAAAA,EAAAA,CAAAA;IAAPG;IAAgCH,SAAAA,MAAAA,EAAAA,MAAAA;IAAPG;IAARC,SAAAA,QAAAA,EAAAA,CAAAA,KAAAA,EAAAA,OAAAA,EAAAA,GAAjBD,MAAiBC,CAAVJ,MAAUI,CAAAA,GAAAA,OAAAA,CAAQD,MAARC,CAAeJ,MAAfI,CAAAA,CAAAA;IAEjCL;IAAOC,SAAAA,KAAAA,CAAAA,EAAbK,KAAaL,CAAPD,KAAOC,EAAAA,MAAAA,CAAAA,GAAAA,SAAAA;EAAbK;EAGeL;EAAdM,KAAAA,MAAAA,CAAAA,MAAAA,CAAAA,GAAAA,aAAAA,CAAcN,MAAdM,CAAAA,GAAwBC,aAAxBD;EAAwBC;EAI1BP,UAAAA,aAAAA,CAAAA,MAAAA,CAAAA,CAAAA;IAOeQ;IAAdC,SAAAA,KAAAA,EAPDT,MAOCS;IAOaC;IAAcC,SAAAA,MAAAA,CAAAA,EAAAA,SAAAA;EAA5BF;EAKFC;EAGwBX,UAAAA,aAAAA,CAAAA;IAEtBA;IAECC,SAAAA,MAAAA,EAnBAS,aAmBAT,CAnBcQ,KAmBdR,CAAAA;EAGUF;EAAgCI;EAAZU,UAAAA,KAAAA,CAAAA;IAEnBd;IAAgCI,SAAAA,OAAAA,EAAAA,MAAAA;IAAZU;IAAW,SAAA,IAAA,CAAA,EAjB3CH,aAiB2C,CAjB7BC,WAiB6B,GAjBfC,WAiBe,CAAA,GAAA,SAAA;;;;;kBAZ7CD;;;4CAGwBX;;oBAEtBA;;qBAECC;;;iCAGUF,oBAAoBc,YAAYV;;kCAE/BJ,oBAAoBc,YAAYV"}
|
|
1
|
+
{"version":3,"file":"standard-schema.d.ts","names":["StandardTypedV1","Input","Output","Props","Schema","Types","NonNullable","StandardSchemaV1","Options","Result","Promise","SuccessResult","FailureResult","Record","Issue","ReadonlyArray","PropertyKey","PathSegment","InferInput","InferOutput","StandardJSONSchemaV1","Converter","Target","StandardSchemaWithJSONProps","StandardSchemaWithJSON"],"sources":["../../../node_modules/.bun/zod@4.2.1/node_modules/zod/v4/core/standard-schema.d.cts"],"sourcesContent":["/** The Standard interface. */\nexport interface StandardTypedV1<Input = unknown, Output = Input> {\n /** The Standard properties. */\n readonly \"~standard\": StandardTypedV1.Props<Input, Output>;\n}\nexport declare namespace StandardTypedV1 {\n /** The Standard properties interface. */\n interface Props<Input = unknown, Output = Input> {\n /** The version number of the standard. */\n readonly version: 1;\n /** The vendor name of the schema library. */\n readonly vendor: string;\n /** Inferred types associated with the schema. */\n readonly types?: Types<Input, Output> | undefined;\n }\n /** The Standard types interface. */\n interface Types<Input = unknown, Output = Input> {\n /** The input type of the schema. */\n readonly input: Input;\n /** The output type of the schema. */\n readonly output: Output;\n }\n /** Infers the input type of a Standard. */\n type InferInput<Schema extends StandardTypedV1> = NonNullable<Schema[\"~standard\"][\"types\"]>[\"input\"];\n /** Infers the output type of a Standard. */\n type InferOutput<Schema extends StandardTypedV1> = NonNullable<Schema[\"~standard\"][\"types\"]>[\"output\"];\n}\n/** The Standard Schema interface. */\nexport interface StandardSchemaV1<Input = unknown, Output = Input> {\n /** The Standard Schema properties. */\n readonly \"~standard\": StandardSchemaV1.Props<Input, Output>;\n}\nexport declare namespace StandardSchemaV1 {\n /** The Standard Schema properties interface. */\n interface Props<Input = unknown, Output = Input> extends StandardTypedV1.Props<Input, Output> {\n /** Validates unknown input values. */\n readonly validate: (value: unknown, options?: StandardSchemaV1.Options | undefined) => Result<Output> | Promise<Result<Output>>;\n }\n /** The result interface of the validate function. */\n type Result<Output> = SuccessResult<Output> | FailureResult;\n /** The result interface if validation succeeds. */\n interface SuccessResult<Output> {\n /** The typed output value. */\n readonly value: Output;\n /** The absence of issues indicates success. */\n readonly issues?: undefined;\n }\n interface Options {\n /** Implicit support for additional vendor-specific parameters, if needed. */\n readonly libraryOptions?: Record<string, unknown> | undefined;\n }\n /** The result interface if validation fails. */\n interface FailureResult {\n /** The issues of failed validation. */\n readonly issues: ReadonlyArray<Issue>;\n }\n /** The issue interface of the failure output. */\n interface Issue {\n /** The error message of the issue. */\n readonly message: string;\n /** The path of the issue, if any. */\n readonly path?: ReadonlyArray<PropertyKey | PathSegment> | undefined;\n }\n /** The path segment interface of the issue. */\n interface PathSegment {\n /** The key representing a path segment. */\n readonly key: PropertyKey;\n }\n /** The Standard types interface. */\n interface Types<Input = unknown, Output = Input> extends StandardTypedV1.Types<Input, Output> {\n }\n /** Infers the input type of a Standard. */\n type InferInput<Schema extends StandardTypedV1> = StandardTypedV1.InferInput<Schema>;\n /** Infers the output type of a Standard. */\n type InferOutput<Schema extends StandardTypedV1> = StandardTypedV1.InferOutput<Schema>;\n}\n/** The Standard JSON Schema interface. */\nexport interface StandardJSONSchemaV1<Input = unknown, Output = Input> {\n /** The Standard JSON Schema properties. */\n readonly \"~standard\": StandardJSONSchemaV1.Props<Input, Output>;\n}\nexport declare namespace StandardJSONSchemaV1 {\n /** The Standard JSON Schema properties interface. */\n interface Props<Input = unknown, Output = Input> extends StandardTypedV1.Props<Input, Output> {\n /** Methods for generating the input/output JSON Schema. */\n readonly jsonSchema: Converter;\n }\n /** The Standard JSON Schema converter interface. */\n interface Converter {\n /** Converts the input type to JSON Schema. May throw if conversion is not supported. */\n readonly input: (options: StandardJSONSchemaV1.Options) => Record<string, unknown>;\n /** Converts the output type to JSON Schema. May throw if conversion is not supported. */\n readonly output: (options: StandardJSONSchemaV1.Options) => Record<string, unknown>;\n }\n /** The target version of the generated JSON Schema.\n *\n * It is *strongly recommended* that implementers support `\"draft-2020-12\"` and `\"draft-07\"`, as they are both in wide use.\n *\n * The `\"openapi-3.0\"` target is intended as a standardized specifier for OpenAPI 3.0 which is a superset of JSON Schema `\"draft-04\"`.\n *\n * All other targets can be implemented on a best-effort basis. Libraries should throw if they don't support a specified target.\n */\n type Target = \"draft-2020-12\" | \"draft-07\" | \"openapi-3.0\" | ({} & string);\n /** The options for the input/output methods. */\n interface Options {\n /** Specifies the target version of the generated JSON Schema. Support for all versions is on a best-effort basis. If a given version is not supported, the library should throw. */\n readonly target: Target;\n /** Implicit support for additional vendor-specific parameters, if needed. */\n readonly libraryOptions?: Record<string, unknown> | undefined;\n }\n /** The Standard types interface. */\n interface Types<Input = unknown, Output = Input> extends StandardTypedV1.Types<Input, Output> {\n }\n /** Infers the input type of a Standard. */\n type InferInput<Schema extends StandardTypedV1> = StandardTypedV1.InferInput<Schema>;\n /** Infers the output type of a Standard. */\n type InferOutput<Schema extends StandardTypedV1> = StandardTypedV1.InferOutput<Schema>;\n}\nexport interface StandardSchemaWithJSONProps<Input = unknown, Output = Input> extends StandardSchemaV1.Props<Input, Output>, StandardJSONSchemaV1.Props<Input, Output> {\n}\n/**\n * An interface that combines StandardJSONSchema and StandardSchema.\n */\nexport interface StandardSchemaWithJSON<Input = unknown, Output = Input> {\n \"~standard\": StandardSchemaWithJSONProps<Input, Output>;\n}\n"],"x_google_ignoreList":[0],"mappings":";;AACiBA,UAAAA,eAAeC,CAAAA,QAAAC,OAAA,EAAA,SAA2BD,KAA3B,CAAA,CAAA;EAA2BA;EAEXA,SAAAA,WAAAA,EAAtBD,eAAAA,CAAgBG,KAAMF,CAAAA,KAAAA,EAAOC,MAAPD,CAAAA;;AAAtBD,kBAEDA,eAAAA,CAFiBG;EAAK;EAEtBH,UAAAA,KAAAA,CAAAA,QAAe,OAAAC,EAAAC,SAEMD,KAFNG,CAAAA,CAAAA;IAEMH;IAMfA,SAAAA,OAAAA,EAAAA,CAAAA;IAAOC;IAAbG,SAAAA,MAAAA,EAAAA,MAAAA;IAGqBJ;IAEtBA,SAAAA,KAAAA,CAAAA,EALCI,KAKDJ,CALOA,KAKPA,EALcC,MAKdD,CAAAA,GAAAA,SAAAA;EAECC;EAGUF;EAA+BI,UAAAA,KAAAA,CAAAA,QAAAA,OAAAA,EAAAA,SAPpBH,KAOoBG,CAAAA,CAAAA;IAAZE;IAElBN,SAAAA,KAAAA,EAPZC,KAOYD;IAA+BI;IAAZE,SAAAA,MAAAA,EAL9BJ,MAK8BI;EAAW;EAGjDC;EAA2CN,KAAAA,UAAAA,CAAAA,eALzBD,eAKyBC,CAAAA,GALNK,WAKML,CALMG,MAKNH,CAAAA,WAAAA,CAAAA,CAAAA,OAAAA,CAAAA,CAAAA,CAAAA,OAAAA,CAAAA;EAEXA;EAAOC,KAAAA,WAAAA,CAAAA,eALpBF,eAKoBE,CAAAA,GALDI,WAKCJ,CALWE,MAKXF,CAAAA,WAAA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KAAAA,EAAAA,CAAAA,OAAAA,EA5BiBH,oBAAAA,CAAqBZ,OA4BX,EAAA,GA5BuBK,MA4BvB,CAAA,MAAA,EAAA,OAAA,CAAA;IAA2BZ;IAAsCA,SAAAA,MAAAA,EAAAA,CAAAA,OAAAA,EA1B1EmB,oBAAAA,CAAqBZ,OA0BqDP,EAAAA,GA1BzCY,MA0ByCZ,CAAAA,MAAAA,EAAAA,OAAAA,CAAAA;EAAOC;EAAoCD;;;;;;;;;;;;qBAZ/HqB;;8BAEST;;;4CAGYZ,eAAeD,eAAAA,CAAgBK,MAAMJ,OAAOC;;iCAGvDF,mBAAmBA,eAAAA,CAAgBkB,WAAWd;;kCAE7CJ,mBAAmBA,eAAAA,CAAgBmB,YAAYf;;UAElEmB,sDAAsDtB,eAAeM,gBAAAA,CAAiBJ,MAAMF,OAAOC,SAASkB,oBAAAA,CAAqBjB,MAAMF,OAAOC"}
|
|
@@ -4,7 +4,7 @@ import * as class_variance_authority_dist_types0 from "class-variance-authority/
|
|
|
4
4
|
|
|
5
5
|
//#region src/support/components/button.d.ts
|
|
6
6
|
declare const coButtonVariants: (props?: ({
|
|
7
|
-
variant?: "
|
|
7
|
+
variant?: "tab" | "default" | "secondary" | "ghost" | "outline" | "tab-selected" | null | undefined;
|
|
8
8
|
size?: "default" | "large" | "icon" | null | undefined;
|
|
9
9
|
} & class_variance_authority_dist_types0.ClassProp) | undefined) => string;
|
|
10
10
|
type CossistantButtonProps = React$1.ComponentProps<"button"> & VariantProps<typeof coButtonVariants>;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { TimelineItem } from "../../timeline-item.js";
|
|
2
|
+
import { DaySeparatorItem } from "../../hooks/private/use-grouped-messages.js";
|
|
2
3
|
import React from "react";
|
|
3
4
|
import { AvailableAIAgent, AvailableHumanAgent } from "@cossistant/types";
|
|
4
5
|
|
|
@@ -19,6 +20,10 @@ type ConversationTimelineProps = {
|
|
|
19
20
|
availableHumanAgents: AvailableHumanAgent[];
|
|
20
21
|
currentVisitorId?: string;
|
|
21
22
|
tools?: ConversationTimelineTools;
|
|
23
|
+
renderDaySeparator?: (props: {
|
|
24
|
+
item: DaySeparatorItem;
|
|
25
|
+
formatDate: (date: Date) => string;
|
|
26
|
+
}) => React.ReactNode;
|
|
22
27
|
};
|
|
23
28
|
declare const ConversationTimelineList: React.FC<ConversationTimelineProps>;
|
|
24
29
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"conversation-timeline.d.ts","names":[],"sources":["../../../src/support/components/conversation-timeline.tsx"],"sourcesContent":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"conversation-timeline.d.ts","names":[],"sources":["../../../src/support/components/conversation-timeline.tsx"],"sourcesContent":[],"mappings":";;;;;;KAyCY,6BAAA;QACL;EADK,cAAA,EAAA,MAAA;AAKZ,CAAA;AAIY,KAJA,kCAAA,GAMX;EAGW,SAAA,EARA,KAAA,CAAM,aAQmB,CARL,6BAQK,CAAA;CAE7B;AAEY,KATR,yBAAA,GAA4B,MASpB,CAAA,MAAA,EAPnB,kCAOmB,CAAA;AACG,KALX,yBAAA,GAKW;EAEd,cAAA,EAAA,MAAA;EAED,KAAA,EAPA,YAOA,EAAA;EACa,SAAA,CAAA,EAAA,MAAA;EACd,iBAAM,EAPO,gBAOP,EAAA;EAAS,oBAAA,EANC,mBAMD,EAAA;EAGT,gBAAA,CAAA,EAAA,MAAA;UAPJ;;UAED;uBACa;QACd,KAAA,CAAM;;cAGA,0BAA0B,KAAA,CAAM,GAAG"}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { cn } from "../utils/index.js";
|
|
2
2
|
import { TypingIndicator } from "./typing-indicator.js";
|
|
3
3
|
import { ConversationTimeline, ConversationTimelineContainer } from "../../primitives/conversation-timeline.js";
|
|
4
|
+
import { DaySeparator, DaySeparatorLabel, DaySeparatorLine, defaultFormatDate } from "../../primitives/day-separator.js";
|
|
4
5
|
import { useTypingSound } from "../../hooks/use-typing-sound.js";
|
|
5
6
|
import { useConversationTimeline } from "../../hooks/use-conversation-timeline.js";
|
|
6
7
|
import { ConversationEvent } from "./conversation-event.js";
|
|
7
8
|
import { TimelineMessageGroup } from "./timeline-message-group.js";
|
|
8
9
|
import { useCallback, useMemo } from "react";
|
|
9
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
10
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
10
11
|
|
|
11
12
|
//#region src/support/components/conversation-timeline.tsx
|
|
12
13
|
function extractEventPart(item) {
|
|
@@ -15,7 +16,7 @@ function extractEventPart(item) {
|
|
|
15
16
|
}
|
|
16
17
|
const EMPTY_SEEN_BY_IDS = Object.freeze([]);
|
|
17
18
|
const EMPTY_SEEN_BY_NAMES = Object.freeze([]);
|
|
18
|
-
const ConversationTimelineList = ({ conversationId, items: timelineItems, className, availableAIAgents = [], availableHumanAgents = [], currentVisitorId, tools }) => {
|
|
19
|
+
const ConversationTimelineList = ({ conversationId, items: timelineItems, className, availableAIAgents = [], availableHumanAgents = [], currentVisitorId, tools, renderDaySeparator }) => {
|
|
19
20
|
const timeline = useConversationTimeline({
|
|
20
21
|
conversationId,
|
|
21
22
|
items: timelineItems,
|
|
@@ -56,6 +57,25 @@ const ConversationTimelineList = ({ conversationId, items: timelineItems, classN
|
|
|
56
57
|
children: /* @__PURE__ */ jsxs(ConversationTimelineContainer, {
|
|
57
58
|
className: "flex min-h-full w-full flex-col gap-5",
|
|
58
59
|
children: [timeline.groupedMessages.items.map((item, index) => {
|
|
60
|
+
if (item.type === "day_separator") {
|
|
61
|
+
if (renderDaySeparator) return /* @__PURE__ */ jsx("div", { children: renderDaySeparator({
|
|
62
|
+
item,
|
|
63
|
+
formatDate: defaultFormatDate
|
|
64
|
+
}) }, `day-separator-${item.dateString}`);
|
|
65
|
+
return /* @__PURE__ */ jsx(DaySeparator, {
|
|
66
|
+
className: "flex items-center justify-center py-2",
|
|
67
|
+
date: item.date,
|
|
68
|
+
dateString: item.dateString,
|
|
69
|
+
children: ({ formattedDate }) => /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
70
|
+
/* @__PURE__ */ jsx(DaySeparatorLine, { className: "flex-1 border-gray-200 border-t dark:border-gray-700" }),
|
|
71
|
+
/* @__PURE__ */ jsx(DaySeparatorLabel, {
|
|
72
|
+
className: "px-3 text-gray-500 text-xs dark:text-gray-400",
|
|
73
|
+
formattedDate
|
|
74
|
+
}),
|
|
75
|
+
/* @__PURE__ */ jsx(DaySeparatorLine, { className: "flex-1 border-gray-200 border-t dark:border-gray-700" })
|
|
76
|
+
] })
|
|
77
|
+
}, `day-separator-${item.dateString}`);
|
|
78
|
+
}
|
|
59
79
|
if (item.type === "timeline_event") {
|
|
60
80
|
const eventPart = extractEventPart(item.item);
|
|
61
81
|
if (!eventPart) return null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"conversation-timeline.js","names":["EMPTY_SEEN_BY_IDS: readonly string[]","EMPTY_SEEN_BY_NAMES: readonly string[]","ConversationTimelineList: React.FC<ConversationTimelineProps>","names: string[]","PrimitiveConversationTimeline"],"sources":["../../../src/support/components/conversation-timeline.tsx"],"sourcesContent":["import type { AvailableAIAgent, AvailableHumanAgent } from \"@cossistant/types\";\nimport type {\n\tTimelineItem,\n\tTimelinePartEvent,\n} from \"@cossistant/types/api/timeline-item\";\nimport type React from \"react\";\nimport { useCallback, useMemo } from \"react\";\nimport { useConversationTimeline } from \"../../hooks/use-conversation-timeline\";\nimport { useTypingSound } from \"../../hooks/use-typing-sound\";\nimport {\n\tConversationTimelineContainer,\n\tConversationTimeline as PrimitiveConversationTimeline,\n} from \"../../primitives/conversation-timeline\";\nimport { cn } from \"../utils\";\nimport { ConversationEvent } from \"./conversation-event\";\nimport { TimelineMessageGroup } from \"./timeline-message-group\";\nimport { TypingIndicator, type TypingParticipant } from \"./typing-indicator\";\n\n// Helper to extract event part from timeline item\nfunction extractEventPart(item: TimelineItem): TimelinePartEvent | null {\n\tif (item.type !== \"event\") {\n\t\treturn null;\n\t}\n\n\tconst eventPart = item.parts.find(\n\t\t(part): part is TimelinePartEvent => part.type === \"event\"\n\t);\n\n\treturn eventPart || null;\n}\n\nconst EMPTY_SEEN_BY_IDS: readonly string[] = Object.freeze([]);\nconst EMPTY_SEEN_BY_NAMES: readonly string[] = Object.freeze([]);\n\nexport type ConversationTimelineToolProps = {\n\titem: TimelineItem;\n\tconversationId: string;\n};\n\nexport type ConversationTimelineToolDefinition = {\n\tcomponent: React.ComponentType<ConversationTimelineToolProps>;\n};\n\nexport type ConversationTimelineTools = Record<\n\tstring,\n\tConversationTimelineToolDefinition\n>;\n\nexport type ConversationTimelineProps = {\n\tconversationId: string;\n\titems: TimelineItem[];\n\tclassName?: string;\n\tavailableAIAgents: AvailableAIAgent[];\n\tavailableHumanAgents: AvailableHumanAgent[];\n\tcurrentVisitorId?: string;\n\ttools?: ConversationTimelineTools;\n};\n\nexport const ConversationTimelineList: React.FC<ConversationTimelineProps> = ({\n\tconversationId,\n\titems: timelineItems,\n\tclassName,\n\tavailableAIAgents = [],\n\tavailableHumanAgents = [],\n\tcurrentVisitorId,\n\ttools,\n}) => {\n\tconst timeline = useConversationTimeline({\n\t\tconversationId,\n\t\titems: timelineItems,\n\t\tcurrentVisitorId,\n\t});\n\n\tconst typingIndicatorParticipants = useMemo(\n\t\t() =>\n\t\t\ttimeline.typingParticipants.map<TypingParticipant>((participant) => ({\n\t\t\t\tid: participant.id,\n\t\t\t\ttype: participant.type,\n\t\t\t})),\n\t\t[timeline.typingParticipants]\n\t);\n\n\t// Play typing sound when someone is typing\n\tuseTypingSound(typingIndicatorParticipants.length > 0, {\n\t\tvolume: 1,\n\t\tplaybackRate: 1.3,\n\t});\n\n\tconst seenNameLookup = useMemo(() => {\n\t\tconst map = new Map<string, string>();\n\n\t\tfor (const agent of availableHumanAgents) {\n\t\t\tif (agent.name) {\n\t\t\t\tmap.set(agent.id, agent.name);\n\t\t\t}\n\t\t}\n\n\t\tfor (const agent of availableAIAgents) {\n\t\t\tif (agent.name) {\n\t\t\t\tmap.set(agent.id, agent.name);\n\t\t\t}\n\t\t}\n\n\t\treturn map;\n\t}, [availableHumanAgents, availableAIAgents]);\n\n\tconst getSeenByNames = useCallback(\n\t\t(ids: readonly string[] = EMPTY_SEEN_BY_IDS): readonly string[] => {\n\t\t\tif (ids.length === 0 || seenNameLookup.size === 0) {\n\t\t\t\treturn EMPTY_SEEN_BY_NAMES;\n\t\t\t}\n\n\t\t\tconst uniqueNames = new Set<string>();\n\t\t\tconst names: string[] = [];\n\n\t\t\tfor (const id of ids) {\n\t\t\t\tconst name = seenNameLookup.get(id);\n\t\t\t\tif (!name || uniqueNames.has(name)) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tuniqueNames.add(name);\n\t\t\t\tnames.push(name);\n\t\t\t}\n\n\t\t\tif (names.length === 0) {\n\t\t\t\treturn EMPTY_SEEN_BY_NAMES;\n\t\t\t}\n\n\t\t\treturn Object.freeze(names);\n\t\t},\n\t\t[seenNameLookup]\n\t);\n\n\treturn (\n\t\t<PrimitiveConversationTimeline\n\t\t\tautoScroll={true}\n\t\t\tclassName={cn(\n\t\t\t\t\"overflow-y-scroll px-3 py-6\",\n\t\t\t\t\"co-scrollbar-thin\",\n\t\t\t\t\"h-full w-full\",\n\t\t\t\tclassName\n\t\t\t)}\n\t\t\tid=\"conversation-timeline\"\n\t\t\titems={timelineItems}\n\t\t>\n\t\t\t<ConversationTimelineContainer className=\"flex min-h-full w-full flex-col gap-5\">\n\t\t\t\t{timeline.groupedMessages.items.map((item, index) => {\n\t\t\t\t\tif (item.type === \"timeline_event\") {\n\t\t\t\t\t\t// Extract event data from parts\n\t\t\t\t\t\tconst eventPart = extractEventPart(item.item);\n\n\t\t\t\t\t\t// Only render if we have valid event data\n\t\t\t\t\t\tif (!eventPart) {\n\t\t\t\t\t\t\treturn null;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t<ConversationEvent\n\t\t\t\t\t\t\t\tavailableAIAgents={availableAIAgents}\n\t\t\t\t\t\t\t\tavailableHumanAgents={availableHumanAgents}\n\t\t\t\t\t\t\t\tcreatedAt={item.item.createdAt}\n\t\t\t\t\t\t\t\tevent={eventPart}\n\t\t\t\t\t\t\t\tkey={item.item.id ?? `timeline-event-${item.item.createdAt}`}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\tif (item.type === \"timeline_tool\") {\n\t\t\t\t\t\tconst toolName = item.tool ?? item.item.tool ?? item.item.type;\n\t\t\t\t\t\tconst toolDefinition = toolName ? tools?.[toolName] : undefined;\n\n\t\t\t\t\t\tif (!toolDefinition) {\n\t\t\t\t\t\t\treturn null;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst ToolComponent = toolDefinition.component;\n\n\t\t\t\t\t\tconst toolKey =\n\t\t\t\t\t\t\titem.item.id ?? `${toolName}-${item.item.createdAt}-${index}`;\n\n\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t<ToolComponent\n\t\t\t\t\t\t\t\tconversationId={conversationId}\n\t\t\t\t\t\t\t\titem={item.item}\n\t\t\t\t\t\t\t\tkey={toolKey}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\t// Only show seen indicator on the LAST message group sent by the visitor\n\t\t\t\t\tconst isLastVisitorGroup =\n\t\t\t\t\t\tindex === timeline.lastVisitorMessageGroupIndex;\n\t\t\t\t\tconst seenByIds =\n\t\t\t\t\t\tisLastVisitorGroup && item.lastMessageId\n\t\t\t\t\t\t\t? timeline.groupedMessages.getMessageSeenBy(item.lastMessageId)\n\t\t\t\t\t\t\t: EMPTY_SEEN_BY_IDS;\n\t\t\t\t\tconst seenByNames =\n\t\t\t\t\t\tseenByIds.length > 0\n\t\t\t\t\t\t\t? getSeenByNames(seenByIds)\n\t\t\t\t\t\t\t: EMPTY_SEEN_BY_NAMES;\n\n\t\t\t\t\t// Use first timeline item ID as stable key\n\t\t\t\t\tconst groupKey =\n\t\t\t\t\t\titem.lastMessageId ??\n\t\t\t\t\t\titem.items?.[0]?.id ??\n\t\t\t\t\t\t`group-${item.items?.[0]?.createdAt ?? index}`;\n\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<TimelineMessageGroup\n\t\t\t\t\t\t\tavailableAIAgents={availableAIAgents}\n\t\t\t\t\t\t\tavailableHumanAgents={availableHumanAgents}\n\t\t\t\t\t\t\tcurrentVisitorId={currentVisitorId}\n\t\t\t\t\t\t\titems={item.items || []}\n\t\t\t\t\t\t\tkey={groupKey}\n\t\t\t\t\t\t\tseenByIds={seenByIds}\n\t\t\t\t\t\t\tseenByNames={seenByNames}\n\t\t\t\t\t\t/>\n\t\t\t\t\t);\n\t\t\t\t})}\n\t\t\t\t<div className=\"h-6 w-full\">\n\t\t\t\t\t{typingIndicatorParticipants.length > 0 ? (\n\t\t\t\t\t\t<TypingIndicator\n\t\t\t\t\t\t\tavailableAIAgents={availableAIAgents}\n\t\t\t\t\t\t\tavailableHumanAgents={availableHumanAgents}\n\t\t\t\t\t\t\tclassName=\"mt-2\"\n\t\t\t\t\t\t\tparticipants={typingIndicatorParticipants}\n\t\t\t\t\t\t/>\n\t\t\t\t\t) : null}\n\t\t\t\t</div>\n\t\t\t</ConversationTimelineContainer>\n\t\t</PrimitiveConversationTimeline>\n\t);\n};\n"],"mappings":";;;;;;;;;;;AAmBA,SAAS,iBAAiB,MAA8C;AACvE,KAAI,KAAK,SAAS,QACjB,QAAO;AAOR,QAJkB,KAAK,MAAM,MAC3B,SAAoC,KAAK,SAAS,QACnD,IAEmB;;AAGrB,MAAMA,oBAAuC,OAAO,OAAO,EAAE,CAAC;AAC9D,MAAMC,sBAAyC,OAAO,OAAO,EAAE,CAAC;AA0BhE,MAAaC,4BAAiE,EAC7E,gBACA,OAAO,eACP,WACA,oBAAoB,EAAE,EACtB,uBAAuB,EAAE,EACzB,kBACA,YACK;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AAC;MACmB;MACG;MACtB,WAAW,KAAK,KAAK;MACrB,OAAO;QACF,KAAK,KAAK,MAAM,kBAAkB,KAAK,KAAK,YAChD;;AAIJ,QAAI,KAAK,SAAS,iBAAiB;KAClC,MAAM,WAAW,KAAK,QAAQ,KAAK,KAAK,QAAQ,KAAK,KAAK;KAC1D,MAAM,iBAAiB,WAAW,QAAQ,YAAY;AAEtD,SAAI,CAAC,eACJ,QAAO;KAGR,MAAM,gBAAgB,eAAe;KAErC,MAAM,UACL,KAAK,KAAK,MAAM,GAAG,SAAS,GAAG,KAAK,KAAK,UAAU,GAAG;AAEvD,YACC,oBAAC;MACgB;MAChB,MAAM,KAAK;QACN,QACJ;;IAOJ,MAAM,YADL,UAAU,SAAS,gCAEG,KAAK,gBACxB,SAAS,gBAAgB,iBAAiB,KAAK,cAAc,GAC7D;IACJ,MAAM,cACL,UAAU,SAAS,IAChB,eAAe,UAAU,GACzB;IAGJ,MAAM,WACL,KAAK,iBACL,KAAK,QAAQ,IAAI,MACjB,SAAS,KAAK,QAAQ,IAAI,aAAa;AAExC,WACC,oBAAC;KACmB;KACG;KACJ;KAClB,OAAO,KAAK,SAAS,EAAE;KAEZ;KACE;OAFR,SAGJ;KAEF,EACF,oBAAC;IAAI,WAAU;cACb,4BAA4B,SAAS,IACrC,oBAAC;KACmB;KACG;KACtB,WAAU;KACV,cAAc;MACb,GACC;KACC;IACyB;GACD"}
|
|
1
|
+
{"version":3,"file":"conversation-timeline.js","names":["EMPTY_SEEN_BY_IDS: readonly string[]","EMPTY_SEEN_BY_NAMES: readonly string[]","ConversationTimelineList: React.FC<ConversationTimelineProps>","names: string[]","PrimitiveConversationTimeline"],"sources":["../../../src/support/components/conversation-timeline.tsx"],"sourcesContent":["import type { AvailableAIAgent, AvailableHumanAgent } from \"@cossistant/types\";\nimport type {\n\tTimelineItem,\n\tTimelinePartEvent,\n} from \"@cossistant/types/api/timeline-item\";\nimport type React from \"react\";\nimport { useCallback, useMemo } from \"react\";\nimport type { DaySeparatorItem } from \"../../hooks/private/use-grouped-messages\";\nimport { useConversationTimeline } from \"../../hooks/use-conversation-timeline\";\nimport { useTypingSound } from \"../../hooks/use-typing-sound\";\nimport {\n\tConversationTimelineContainer,\n\tConversationTimeline as PrimitiveConversationTimeline,\n} from \"../../primitives/conversation-timeline\";\nimport {\n\tDaySeparator,\n\tDaySeparatorLabel,\n\tDaySeparatorLine,\n\tdefaultFormatDate,\n} from \"../../primitives/day-separator\";\nimport { cn } from \"../utils\";\nimport { ConversationEvent } from \"./conversation-event\";\nimport { TimelineMessageGroup } from \"./timeline-message-group\";\nimport { TypingIndicator, type TypingParticipant } from \"./typing-indicator\";\n\n// Helper to extract event part from timeline item\nfunction extractEventPart(item: TimelineItem): TimelinePartEvent | null {\n\tif (item.type !== \"event\") {\n\t\treturn null;\n\t}\n\n\tconst eventPart = item.parts.find(\n\t\t(part): part is TimelinePartEvent => part.type === \"event\"\n\t);\n\n\treturn eventPart || null;\n}\n\nconst EMPTY_SEEN_BY_IDS: readonly string[] = Object.freeze([]);\nconst EMPTY_SEEN_BY_NAMES: readonly string[] = Object.freeze([]);\n\nexport type ConversationTimelineToolProps = {\n\titem: TimelineItem;\n\tconversationId: string;\n};\n\nexport type ConversationTimelineToolDefinition = {\n\tcomponent: React.ComponentType<ConversationTimelineToolProps>;\n};\n\nexport type ConversationTimelineTools = Record<\n\tstring,\n\tConversationTimelineToolDefinition\n>;\n\nexport type ConversationTimelineProps = {\n\tconversationId: string;\n\titems: TimelineItem[];\n\tclassName?: string;\n\tavailableAIAgents: AvailableAIAgent[];\n\tavailableHumanAgents: AvailableHumanAgent[];\n\tcurrentVisitorId?: string;\n\ttools?: ConversationTimelineTools;\n\trenderDaySeparator?: (props: {\n\t\titem: DaySeparatorItem;\n\t\tformatDate: (date: Date) => string;\n\t}) => React.ReactNode;\n};\n\nexport const ConversationTimelineList: React.FC<ConversationTimelineProps> = ({\n\tconversationId,\n\titems: timelineItems,\n\tclassName,\n\tavailableAIAgents = [],\n\tavailableHumanAgents = [],\n\tcurrentVisitorId,\n\ttools,\n\trenderDaySeparator,\n}) => {\n\tconst timeline = useConversationTimeline({\n\t\tconversationId,\n\t\titems: timelineItems,\n\t\tcurrentVisitorId,\n\t});\n\n\tconst typingIndicatorParticipants = useMemo(\n\t\t() =>\n\t\t\ttimeline.typingParticipants.map<TypingParticipant>((participant) => ({\n\t\t\t\tid: participant.id,\n\t\t\t\ttype: participant.type,\n\t\t\t})),\n\t\t[timeline.typingParticipants]\n\t);\n\n\t// Play typing sound when someone is typing\n\tuseTypingSound(typingIndicatorParticipants.length > 0, {\n\t\tvolume: 1,\n\t\tplaybackRate: 1.3,\n\t});\n\n\tconst seenNameLookup = useMemo(() => {\n\t\tconst map = new Map<string, string>();\n\n\t\tfor (const agent of availableHumanAgents) {\n\t\t\tif (agent.name) {\n\t\t\t\tmap.set(agent.id, agent.name);\n\t\t\t}\n\t\t}\n\n\t\tfor (const agent of availableAIAgents) {\n\t\t\tif (agent.name) {\n\t\t\t\tmap.set(agent.id, agent.name);\n\t\t\t}\n\t\t}\n\n\t\treturn map;\n\t}, [availableHumanAgents, availableAIAgents]);\n\n\tconst getSeenByNames = useCallback(\n\t\t(ids: readonly string[] = EMPTY_SEEN_BY_IDS): readonly string[] => {\n\t\t\tif (ids.length === 0 || seenNameLookup.size === 0) {\n\t\t\t\treturn EMPTY_SEEN_BY_NAMES;\n\t\t\t}\n\n\t\t\tconst uniqueNames = new Set<string>();\n\t\t\tconst names: string[] = [];\n\n\t\t\tfor (const id of ids) {\n\t\t\t\tconst name = seenNameLookup.get(id);\n\t\t\t\tif (!name || uniqueNames.has(name)) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tuniqueNames.add(name);\n\t\t\t\tnames.push(name);\n\t\t\t}\n\n\t\t\tif (names.length === 0) {\n\t\t\t\treturn EMPTY_SEEN_BY_NAMES;\n\t\t\t}\n\n\t\t\treturn Object.freeze(names);\n\t\t},\n\t\t[seenNameLookup]\n\t);\n\n\treturn (\n\t\t<PrimitiveConversationTimeline\n\t\t\tautoScroll={true}\n\t\t\tclassName={cn(\n\t\t\t\t\"overflow-y-scroll px-3 py-6\",\n\t\t\t\t\"co-scrollbar-thin\",\n\t\t\t\t\"h-full w-full\",\n\t\t\t\tclassName\n\t\t\t)}\n\t\t\tid=\"conversation-timeline\"\n\t\t\titems={timelineItems}\n\t\t>\n\t\t\t<ConversationTimelineContainer className=\"flex min-h-full w-full flex-col gap-5\">\n\t\t\t\t{timeline.groupedMessages.items.map((item, index) => {\n\t\t\t\t\tif (item.type === \"day_separator\") {\n\t\t\t\t\t\t// Render day separator - allow custom rendering via prop\n\t\t\t\t\t\tif (renderDaySeparator) {\n\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t<div key={`day-separator-${item.dateString}`}>\n\t\t\t\t\t\t\t\t\t{renderDaySeparator({\n\t\t\t\t\t\t\t\t\t\titem,\n\t\t\t\t\t\t\t\t\t\tformatDate: defaultFormatDate,\n\t\t\t\t\t\t\t\t\t})}\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// Default day separator using the primitive\n\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t<DaySeparator\n\t\t\t\t\t\t\t\tclassName=\"flex items-center justify-center py-2\"\n\t\t\t\t\t\t\t\tdate={item.date}\n\t\t\t\t\t\t\t\tdateString={item.dateString}\n\t\t\t\t\t\t\t\tkey={`day-separator-${item.dateString}`}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{({ formattedDate }) => (\n\t\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t\t<DaySeparatorLine className=\"flex-1 border-gray-200 border-t dark:border-gray-700\" />\n\t\t\t\t\t\t\t\t\t\t<DaySeparatorLabel\n\t\t\t\t\t\t\t\t\t\t\tclassName=\"px-3 text-gray-500 text-xs dark:text-gray-400\"\n\t\t\t\t\t\t\t\t\t\t\tformattedDate={formattedDate}\n\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t<DaySeparatorLine className=\"flex-1 border-gray-200 border-t dark:border-gray-700\" />\n\t\t\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\t</DaySeparator>\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\tif (item.type === \"timeline_event\") {\n\t\t\t\t\t\t// Extract event data from parts\n\t\t\t\t\t\tconst eventPart = extractEventPart(item.item);\n\n\t\t\t\t\t\t// Only render if we have valid event data\n\t\t\t\t\t\tif (!eventPart) {\n\t\t\t\t\t\t\treturn null;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t<ConversationEvent\n\t\t\t\t\t\t\t\tavailableAIAgents={availableAIAgents}\n\t\t\t\t\t\t\t\tavailableHumanAgents={availableHumanAgents}\n\t\t\t\t\t\t\t\tcreatedAt={item.item.createdAt}\n\t\t\t\t\t\t\t\tevent={eventPart}\n\t\t\t\t\t\t\t\tkey={item.item.id ?? `timeline-event-${item.item.createdAt}`}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\tif (item.type === \"timeline_tool\") {\n\t\t\t\t\t\tconst toolName = item.tool ?? item.item.tool ?? item.item.type;\n\t\t\t\t\t\tconst toolDefinition = toolName ? tools?.[toolName] : undefined;\n\n\t\t\t\t\t\tif (!toolDefinition) {\n\t\t\t\t\t\t\treturn null;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst ToolComponent = toolDefinition.component;\n\n\t\t\t\t\t\tconst toolKey =\n\t\t\t\t\t\t\titem.item.id ?? `${toolName}-${item.item.createdAt}-${index}`;\n\n\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t<ToolComponent\n\t\t\t\t\t\t\t\tconversationId={conversationId}\n\t\t\t\t\t\t\t\titem={item.item}\n\t\t\t\t\t\t\t\tkey={toolKey}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\t// Only show seen indicator on the LAST message group sent by the visitor\n\t\t\t\t\tconst isLastVisitorGroup =\n\t\t\t\t\t\tindex === timeline.lastVisitorMessageGroupIndex;\n\t\t\t\t\tconst seenByIds =\n\t\t\t\t\t\tisLastVisitorGroup && item.lastMessageId\n\t\t\t\t\t\t\t? timeline.groupedMessages.getMessageSeenBy(item.lastMessageId)\n\t\t\t\t\t\t\t: EMPTY_SEEN_BY_IDS;\n\t\t\t\t\tconst seenByNames =\n\t\t\t\t\t\tseenByIds.length > 0\n\t\t\t\t\t\t\t? getSeenByNames(seenByIds)\n\t\t\t\t\t\t\t: EMPTY_SEEN_BY_NAMES;\n\n\t\t\t\t\t// Use first timeline item ID as stable key\n\t\t\t\t\tconst groupKey =\n\t\t\t\t\t\titem.lastMessageId ??\n\t\t\t\t\t\titem.items?.[0]?.id ??\n\t\t\t\t\t\t`group-${item.items?.[0]?.createdAt ?? index}`;\n\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<TimelineMessageGroup\n\t\t\t\t\t\t\tavailableAIAgents={availableAIAgents}\n\t\t\t\t\t\t\tavailableHumanAgents={availableHumanAgents}\n\t\t\t\t\t\t\tcurrentVisitorId={currentVisitorId}\n\t\t\t\t\t\t\titems={item.items || []}\n\t\t\t\t\t\t\tkey={groupKey}\n\t\t\t\t\t\t\tseenByIds={seenByIds}\n\t\t\t\t\t\t\tseenByNames={seenByNames}\n\t\t\t\t\t\t/>\n\t\t\t\t\t);\n\t\t\t\t})}\n\t\t\t\t<div className=\"h-6 w-full\">\n\t\t\t\t\t{typingIndicatorParticipants.length > 0 ? (\n\t\t\t\t\t\t<TypingIndicator\n\t\t\t\t\t\t\tavailableAIAgents={availableAIAgents}\n\t\t\t\t\t\t\tavailableHumanAgents={availableHumanAgents}\n\t\t\t\t\t\t\tclassName=\"mt-2\"\n\t\t\t\t\t\t\tparticipants={typingIndicatorParticipants}\n\t\t\t\t\t\t/>\n\t\t\t\t\t) : null}\n\t\t\t\t</div>\n\t\t\t</ConversationTimelineContainer>\n\t\t</PrimitiveConversationTimeline>\n\t);\n};\n"],"mappings":";;;;;;;;;;;;AA0BA,SAAS,iBAAiB,MAA8C;AACvE,KAAI,KAAK,SAAS,QACjB,QAAO;AAOR,QAJkB,KAAK,MAAM,MAC3B,SAAoC,KAAK,SAAS,QACnD,IAEmB;;AAGrB,MAAMA,oBAAuC,OAAO,OAAO,EAAE,CAAC;AAC9D,MAAMC,sBAAyC,OAAO,OAAO,EAAE,CAAC;AA8BhE,MAAaC,4BAAiE,EAC7E,gBACA,OAAO,eACP,WACA,oBAAoB,EAAE,EACtB,uBAAuB,EAAE,EACzB,kBACA,OACA,yBACK;CACL,MAAM,WAAW,wBAAwB;EACxC;EACA,OAAO;EACP;EACA,CAAC;CAEF,MAAM,8BAA8B,cAElC,SAAS,mBAAmB,KAAwB,iBAAiB;EACpE,IAAI,YAAY;EAChB,MAAM,YAAY;EAClB,EAAE,EACJ,CAAC,SAAS,mBAAmB,CAC7B;AAGD,gBAAe,4BAA4B,SAAS,GAAG;EACtD,QAAQ;EACR,cAAc;EACd,CAAC;CAEF,MAAM,iBAAiB,cAAc;EACpC,MAAM,sBAAM,IAAI,KAAqB;AAErC,OAAK,MAAM,SAAS,qBACnB,KAAI,MAAM,KACT,KAAI,IAAI,MAAM,IAAI,MAAM,KAAK;AAI/B,OAAK,MAAM,SAAS,kBACnB,KAAI,MAAM,KACT,KAAI,IAAI,MAAM,IAAI,MAAM,KAAK;AAI/B,SAAO;IACL,CAAC,sBAAsB,kBAAkB,CAAC;CAE7C,MAAM,iBAAiB,aACrB,MAAyB,sBAAyC;AAClE,MAAI,IAAI,WAAW,KAAK,eAAe,SAAS,EAC/C,QAAO;EAGR,MAAM,8BAAc,IAAI,KAAa;EACrC,MAAMC,QAAkB,EAAE;AAE1B,OAAK,MAAM,MAAM,KAAK;GACrB,MAA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C,oBAAC;MACgB;MAChB,MAAM,KAAK;QACN,QACJ;;IAOJ,MAAM,YADL,UAAU,SAAS,gCAEG,KAAK,gBACxB,SAAS,gBAAgB,iBAAiB,KAAK,cAAc,GAC7D;IACJ,MAAM,cACL,UAAU,SAAS,IAChB,eAAe,UAAU,GACzB;IAGJ,MAAM,WACL,KAAK,iBACL,KAAK,QAAQ,IAAI,MACjB,SAAS,KAAK,QAAQ,IAAI,aAAa;AAExC,WACC,oBAAC;KACmB;KACG;KACJ;KAClB,OAAO,KAAK,SAAS,EAAE;KAEZ;KACE;OAFR,SAGJ;KAEF,EACF,oBAAC;IAAI,WAAU;cACb,4BAA4B,SAAS,IACrC,oBAAC;KACmB;KACG;KACtB,WAAU;KACV,cAAc;MACb,GACC;KACC;IACyB;GACD"}
|
package/support/text/index.d.ts
CHANGED
|
@@ -41,7 +41,7 @@ type TextProps<K extends SupportTextKey, As extends keyof React.JSX.IntrinsicEle
|
|
|
41
41
|
* rendered HTML element.
|
|
42
42
|
*/
|
|
43
43
|
declare const Text: <K extends SupportTextKey, As extends keyof React.JSX.IntrinsicElements = "span">(props: TextProps<K, As> & {
|
|
44
|
-
ref?: React.
|
|
44
|
+
ref?: React.Ref<Element>;
|
|
45
45
|
}) => React.ReactElement | null;
|
|
46
46
|
//#endregion
|
|
47
47
|
export { type SupportLocale, type SupportTextContentOverrides, type SupportTextKey, SupportTextProvider, type SupportTextVariables, Text, useSupportText };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../../../src/support/text/index.tsx"],"sourcesContent":[],"mappings":";;;;AAewB,KASnB,wBAAA,CAAA,eAAwB,MAAA,GAAyB,aAAzB,CAAA,GAAA;EAAyB,QAAA,EAC3C,KAAA,CAAM,SADqC;EAC3C,MAAM,CAAA,EACP,MADO;EACP,OAAA,CAAA,EACC,2BADD,CAC6B,MAD7B,CAAA;CAC6B;;;AAWvC;;;AAEC,iBAFe,mBAEf,CAAA,eAAA,M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M,YAnCP,GAAA,IAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../../src/support/text/index.tsx"],"sourcesContent":["/** biome-ignore-all lint/correctness/useExhaustiveDependencies: dependencies are intentionally managed */\n/** biome-ignore-all lint/correctness/noChildrenProp: children prop is needed for React.createElement */\nimport React from \"react\";\n\nimport { useSupport } from \"../../provider\";\nimport {\n\ttype SupportLocale,\n\ttype SupportTextContentOverrides,\n\ttype SupportTextContext,\n\ttype SupportTextDefinitions,\n\ttype SupportTextKey,\n\ttype SupportTextProviderValue,\n\ttype SupportTextResolvedFormatter,\n\ttype SupportTextVariables,\n\tsupportTextDefinitions,\n} from \"./locales/keys\";\nimport {\n\tbuildLocaleChain,\n\tcreateTextUtils,\n\tevaluateMessage,\n\tnormalizeOverrides,\n\tresolveMessage,\n} from \"./runtime\";\n\ntype SupportTextProviderProps<Locale extends string = SupportLocale> = {\n\tchildren: React.ReactNode;\n\tlocale?: Locale;\n\tcontent?: SupportTextContentOverrides<Locale>;\n};\n\nconst SupportTextRuntimeContext =\n\tReact.createContext<SupportTextProviderValue | null>(null);\n\n/**\n * Supplies localized copy and formatting helpers for the support widget. The\n * provider merges bundled locale strings with optional runtime overrides and\n * exposes a formatter that understands visitor/website context.\n */\nexport function SupportTextProvider<Locale extends string = SupportLocale>({\n\tchildren,\n\tlocale,\n\tcontent,\n}: SupportTextProviderProps<Locale>): React.ReactElement {\n\tconst { website, availableHumanAgents, availableAIAgents, visitor } =\n\t\tuseSupport();\n\tconst [isHydrated, setIsHydrated] = React.useState(false);\n\n\tReact.useEffect(() => {\n\t\tsetIsHydrated(true);\n\t}, []);\n\n\tconst localeChain = React.useMemo(\n\t\t() => buildLocaleChain([locale, visitor?.locale]),\n\t\t[locale, visitor?.locale]\n\t);\n\n\tconst normalizedOverrides = React.useMemo(\n\t\t() => normalizeOverrides(content),\n\t\t[content]\n\t);\n\n\tconst utils = React.useMemo(\n\t\t() => createTextUtils(localeChain[0] ?? \"en\", isHydrated),\n\t\t[localeChain, isHydrated]\n\t);\n\n\tconst textContext = React.useMemo<SupportTextContext>(\n\t\t() => ({\n\t\t\twebsite,\n\t\t\tvisitor: visitor ?? null,\n\t\t\thumanAgents: availableHumanAgents,\n\t\t\taiAgents: availableAIAgents,\n\t\t}),\n\t\t[website, visitor, availableHumanAgents, availableAIAgents]\n\t);\n\n\tconst format = ((key: SupportTextKey, variables?: unknown) => {\n\t\tconst definition = supportTextDefinitions[key];\n\t\tconst requiresVariables =\n\t\t\tdefinition.variables !== undefined &&\n\t\t\t!(\"optional\" in definition && definition.optional === true);\n\n\t\tif (requiresVariables && variables === undefined) {\n\t\t\tthrow new Error(`Missing variables for text key \"${key}\".`);\n\t\t}\n\n\t\tconst resolved = resolveMessage(key, localeChain, normalizedOverrides);\n\t\treturn evaluateMessage(\n\t\t\tkey,\n\t\t\tresolved,\n\t\t\tvariables as SupportTextVariables<typeof key>,\n\t\t\ttextContext,\n\t\t\tutils\n\t\t);\n\t}) as SupportTextResolvedFormatter;\n\n\tconst value = React.useMemo<SupportTextProviderValue>(\n\t\t() => ({\n\t\t\tformat,\n\t\t\tlocale: localeChain[0] ?? \"en\",\n\t\t}),\n\t\t[localeChain, normalizedOverrides, textContext, utils]\n\t);\n\n\treturn (\n\t\t<SupportTextRuntimeContext.Provider value={value}>\n\t\t\t{children}\n\t\t</SupportTextRuntimeContext.Provider>\n\t);\n}\n\n/**\n * Returns the active text formatter for the support widget. Throws if used\n * outside of `SupportTextProvider` to help catch integration mistakes.\n */\nexport function useSupportText(): SupportTextResolvedFormatter {\n\tconst context = React.useContext(SupportTextRuntimeContext);\n\tif (!context) {\n\t\tthrow new Error(\"useSupportText must be used within SupportTextProvider\");\n\t}\n\n\treturn context.format;\n}\n\ntype OptionalVariablesProp<K extends SupportTextKey> =\n\tSupportTextDefinitions[K][\"variables\"] extends undefined\n\t\t? { variables?: undefined }\n\t\t: \"optional\" extends keyof SupportTextDefinitions[K]\n\t\t\t? SupportTextDefinitions[K][\"optional\"] extends true\n\t\t\t\t? { variables?: SupportTextVariables<K> }\n\t\t\t\t: { variables: SupportTextVariables<K> }\n\t\t\t: { variables: SupportTextVariables<K> };\n\ntype TextProps<\n\tK extends SupportTextKey,\n\tAs extends keyof React.JSX.IntrinsicElements = \"span\",\n> = OptionalVariablesProp<K> & {\n\ttextKey: K;\n\tas?: As;\n} & Omit<React.ComponentPropsWithoutRef<As>, \"children\">;\n\nfunction TextInner<\n\tK extends SupportTextKey,\n\tAs extends keyof React.JSX.IntrinsicElements = \"span\",\n>(
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../src/support/text/index.tsx"],"sourcesContent":["/** biome-ignore-all lint/correctness/useExhaustiveDependencies: dependencies are intentionally managed */\n/** biome-ignore-all lint/correctness/noChildrenProp: children prop is needed for React.createElement */\nimport React from \"react\";\n\nimport { useSupport } from \"../../provider\";\nimport {\n\ttype SupportLocale,\n\ttype SupportTextContentOverrides,\n\ttype SupportTextContext,\n\ttype SupportTextDefinitions,\n\ttype SupportTextKey,\n\ttype SupportTextProviderValue,\n\ttype SupportTextResolvedFormatter,\n\ttype SupportTextVariables,\n\tsupportTextDefinitions,\n} from \"./locales/keys\";\nimport {\n\tbuildLocaleChain,\n\tcreateTextUtils,\n\tevaluateMessage,\n\tnormalizeOverrides,\n\tresolveMessage,\n} from \"./runtime\";\n\ntype SupportTextProviderProps<Locale extends string = SupportLocale> = {\n\tchildren: React.ReactNode;\n\tlocale?: Locale;\n\tcontent?: SupportTextContentOverrides<Locale>;\n};\n\nconst SupportTextRuntimeContext =\n\tReact.createContext<SupportTextProviderValue | null>(null);\n\n/**\n * Supplies localized copy and formatting helpers for the support widget. The\n * provider merges bundled locale strings with optional runtime overrides and\n * exposes a formatter that understands visitor/website context.\n */\nexport function SupportTextProvider<Locale extends string = SupportLocale>({\n\tchildren,\n\tlocale,\n\tcontent,\n}: SupportTextProviderProps<Locale>): React.ReactElement {\n\tconst { website, availableHumanAgents, availableAIAgents, visitor } =\n\t\tuseSupport();\n\tconst [isHydrated, setIsHydrated] = React.useState(false);\n\n\tReact.useEffect(() => {\n\t\tsetIsHydrated(true);\n\t}, []);\n\n\tconst localeChain = React.useMemo(\n\t\t() => buildLocaleChain([locale, visitor?.locale]),\n\t\t[locale, visitor?.locale]\n\t);\n\n\tconst normalizedOverrides = React.useMemo(\n\t\t() => normalizeOverrides(content),\n\t\t[content]\n\t);\n\n\tconst utils = React.useMemo(\n\t\t() => createTextUtils(localeChain[0] ?? \"en\", isHydrated),\n\t\t[localeChain, isHydrated]\n\t);\n\n\tconst textContext = React.useMemo<SupportTextContext>(\n\t\t() => ({\n\t\t\twebsite,\n\t\t\tvisitor: visitor ?? null,\n\t\t\thumanAgents: availableHumanAgents,\n\t\t\taiAgents: availableAIAgents,\n\t\t}),\n\t\t[website, visitor, availableHumanAgents, availableAIAgents]\n\t);\n\n\tconst format = ((key: SupportTextKey, variables?: unknown) => {\n\t\tconst definition = supportTextDefinitions[key];\n\t\tconst requiresVariables =\n\t\t\tdefinition.variables !== undefined &&\n\t\t\t!(\"optional\" in definition && definition.optional === true);\n\n\t\tif (requiresVariables && variables === undefined) {\n\t\t\tthrow new Error(`Missing variables for text key \"${key}\".`);\n\t\t}\n\n\t\tconst resolved = resolveMessage(key, localeChain, normalizedOverrides);\n\t\treturn evaluateMessage(\n\t\t\tkey,\n\t\t\tresolved,\n\t\t\tvariables as SupportTextVariables<typeof key>,\n\t\t\ttextContext,\n\t\t\tutils\n\t\t);\n\t}) as SupportTextResolvedFormatter;\n\n\tconst value = React.useMemo<SupportTextProviderValue>(\n\t\t() => ({\n\t\t\tformat,\n\t\t\tlocale: localeChain[0] ?? \"en\",\n\t\t}),\n\t\t[localeChain, normalizedOverrides, textContext, utils]\n\t);\n\n\treturn (\n\t\t<SupportTextRuntimeContext.Provider value={value}>\n\t\t\t{children}\n\t\t</SupportTextRuntimeContext.Provider>\n\t);\n}\n\n/**\n * Returns the active text formatter for the support widget. Throws if used\n * outside of `SupportTextProvider` to help catch integration mistakes.\n */\nexport function useSupportText(): SupportTextResolvedFormatter {\n\tconst context = React.useContext(SupportTextRuntimeContext);\n\tif (!context) {\n\t\tthrow new Error(\"useSupportText must be used within SupportTextProvider\");\n\t}\n\n\treturn context.format;\n}\n\ntype OptionalVariablesProp<K extends SupportTextKey> =\n\tSupportTextDefinitions[K][\"variables\"] extends undefined\n\t\t? { variables?: undefined }\n\t\t: \"optional\" extends keyof SupportTextDefinitions[K]\n\t\t\t? SupportTextDefinitions[K][\"optional\"] extends true\n\t\t\t\t? { variables?: SupportTextVariables<K> }\n\t\t\t\t: { variables: SupportTextVariables<K> }\n\t\t\t: { variables: SupportTextVariables<K> };\n\ntype TextProps<\n\tK extends SupportTextKey,\n\tAs extends keyof React.JSX.IntrinsicElements = \"span\",\n> = OptionalVariablesProp<K> & {\n\ttextKey: K;\n\tas?: As;\n} & Omit<React.ComponentPropsWithoutRef<As>, \"children\">;\n\nfunction TextInner<\n\tK extends SupportTextKey,\n\tAs extends keyof React.JSX.IntrinsicElements = \"span\",\n>(props: Omit<TextProps<K, As>, \"ref\">, forwardedRef: React.Ref<Element>) {\n\tconst { textKey, variables, as, ...rest } = props as TextProps<K, As>;\n\tconst format = useSupportText();\n\tconst Component = (as ?? \"span\") as As;\n\tconst content =\n\t\tvariables !== undefined\n\t\t\t? format(textKey, variables as SupportTextVariables<K>)\n\t\t\t: format(textKey);\n\n\treturn React.createElement(Component, {\n\t\t...rest,\n\t\tref: forwardedRef,\n\t\t\"data-key-name\": textKey,\n\t\tchildren: content,\n\t});\n}\n\n/**\n * Convenience component that renders localized support copy via the\n * `SupportTextProvider` context while still allowing callers to customize the\n * rendered HTML element.\n */\nexport const Text = React.forwardRef(TextInner) as <\n\tK extends SupportTextKey,\n\tAs extends keyof React.JSX.IntrinsicElements = \"span\",\n>(\n\tprops: TextProps<K, As> & { ref?: React.Ref<Element> }\n) => React.ReactElement | null;\n\n(Text as { displayName?: string }).displayName = \"SupportText\";\n\nexport type {\n\tSupportLocale,\n\tSupportTextContentOverrides,\n\tSupportTextKey,\n\tSupportTextVariables,\n} from \"./locales/keys\";\n"],"mappings":";;;;;;;;;AA8BA,MAAM,4BACL,MAAM,cAA+C,KAAK;;;;;;AAO3D,SAAgB,oBAA2D,EAC1E,UACA,QACA,WACwD;CACxD,MAAM,EAAE,SAAS,sBAAsB,mBAAmB,YACzD,YAAY;CACb,MAAM,CAAC,YAAY,iBAAiB,MAAM,SAAS,MAAM;AAEzD,OAAM,gBAAgB;AACrB,gBAAc,KAAK;IACjB,EAAE,CAAC;CAEN,MAAM,cAAc,MAAM,cACnB,iBAAiB,CAAC,QAAQ,SAAS,OAAO,CAAC,EACjD,CAAC,QAAQ,SAAS,OAAO,CACzB;CAED,MAAM,sBAAsB,MAAM,cAC3B,mBAAmB,QAAQ,EACjC,CAAC,QAAQ,CACT;CAED,MAAM,QAAQ,MAAM,cACb,gBAAgB,YAAY,MAAM,MAAM,WAAW,EACzD,CAAC,aAAa,WAAW,CACzB;CAED,MAAM,cAAc,MAAM,eAClB;EACN;EACA,SAAS,WAAW;EACpB,aAAa;EACb,UAAU;EACV,GACD;EAAC;EAAS;EAAS;EAAsB;EAAkB,CAC3D;CAED,MAAM,WAAW,KAAqB,cAAwB;EAC7D,MAAM,aAAa,uBAAuB;AAK1C,MAHC,WAAW,cAAc,UACzB,EAAE,cAAc,cAAc,WAAW,aAAa,SAE9B,cAAc,OACtC,OAAM,IAAI,MAAM,mCAAmC,IAAI,IAAI;AAI5D,SAAO,gBACN,KAFgB,eAAe,KAAK,aAAa,oBAAoB,EAIrE,WACA,aACA,MACA;;CAGF,MAAM,QAAQ,MAAM,eACZ;EACN;EACA,QAAQ,YAAY,MAAM;EAC1B,GACD;EAAC;EAAa;EAAqB;EAAa;EAAM,CACtD;AAED,QACC,oBAAC,0BAA0B;EAAgB;EACzC;GACmC;;;;;;AAQvC,SAAgB,iBAA+C;CAC9D,MAAM,UAAU,MAAM,WAAW,0BAA0B;AAC3D,KAAI,CAAC,QACJ,OAAM,IAAI,MAAM,yDAAyD;AAG1E,QAAO,QAAQ;;AAoBhB,SAAS,UAGP,OAAsC,cAAkC;CACzE,MAAM,EAAE,SAAS,WAAW,GAAI,GAAG,SAAS;CAC5C,MAAM,SAAS,gBAAgB;CAC/B,MAAM,YAAa,MAAM;CACzB,MAAM,UACL,cAAc,SACX,OAAO,SAAS,UAAqC,GACrD,OAAO,QAAQ;AAEnB,QAAO,MAAM,cAAc,WAAW;EACrC,GAAG;EACH,KAAK;EACL,iBAAiB;EACjB,UAAU;EACV,CAAC;;;;;;;AAQH,MAAa,OAAO,MAAM,WAAW,UAAU;AAO/C,AAAC,KAAkC,cAAc"}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { BaseSchema } from "./json-schema.js";
|
|
2
|
+
import { StandardSchemaWithJSONProps } from "./standard-schema.js";
|
|
3
|
+
import { $ZodRegistry } from "./registries.js";
|
|
4
|
+
import { $ZodType, $ZodTypes } from "./schemas.js";
|
|
5
|
+
import { input, output } from "./core.js";
|
|
6
|
+
|
|
7
|
+
//#region ../../node_modules/.bun/zod@4.2.1/node_modules/zod/v4/core/to-json-schema.d.cts
|
|
8
|
+
type Processor<T extends $ZodType = $ZodType> = (schema: T, ctx: ToJSONSchemaContext, json: BaseSchema, params: ProcessParams) => void;
|
|
9
|
+
interface JSONSchemaGeneratorParams {
|
|
10
|
+
processors: Record<string, Processor>;
|
|
11
|
+
/** A registry used to look up metadata for each schema. Any schema with an `id` property will be extracted as a $def.
|
|
12
|
+
* @default globalRegistry */
|
|
13
|
+
metadata?: $ZodRegistry<Record<string, any>>;
|
|
14
|
+
/** The JSON Schema version to target.
|
|
15
|
+
* - `"draft-2020-12"` — Default. JSON Schema Draft 2020-12
|
|
16
|
+
* - `"draft-07"` — JSON Schema Draft 7
|
|
17
|
+
* - `"draft-04"` — JSON Schema Draft 4
|
|
18
|
+
* - `"openapi-3.0"` — OpenAPI 3.0 Schema Object */
|
|
19
|
+
target?: "draft-04" | "draft-07" | "draft-2020-12" | "openapi-3.0" | ({} & string) | undefined;
|
|
20
|
+
/** How to handle unrepresentable types.
|
|
21
|
+
* - `"throw"` — Default. Unrepresentable types throw an error
|
|
22
|
+
* - `"any"` — Unrepresentable types become `{}` */
|
|
23
|
+
unrepresentable?: "throw" | "any";
|
|
24
|
+
/** Arbitrary custom logic that can be used to modify the generated JSON Schema. */
|
|
25
|
+
override?: (ctx: {
|
|
26
|
+
zodSchema: $ZodTypes;
|
|
27
|
+
jsonSchema: BaseSchema;
|
|
28
|
+
path: (string | number)[];
|
|
29
|
+
}) => void;
|
|
30
|
+
/** Whether to extract the `"input"` or `"output"` type. Relevant to transforms, defaults, coerced primitives, etc.
|
|
31
|
+
* - `"output"` — Default. Convert the output schema.
|
|
32
|
+
* - `"input"` — Convert the input schema. */
|
|
33
|
+
io?: "input" | "output";
|
|
34
|
+
cycles?: "ref" | "throw";
|
|
35
|
+
reused?: "ref" | "inline";
|
|
36
|
+
external?: {
|
|
37
|
+
registry: $ZodRegistry<{
|
|
38
|
+
id?: string | undefined;
|
|
39
|
+
}>;
|
|
40
|
+
uri?: ((id: string) => string) | undefined;
|
|
41
|
+
defs: Record<string, BaseSchema>;
|
|
42
|
+
} | undefined;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Parameters for the toJSONSchema function.
|
|
46
|
+
*/
|
|
47
|
+
type ToJSONSchemaParams = Omit<JSONSchemaGeneratorParams, "processors" | "external">;
|
|
48
|
+
interface ProcessParams {
|
|
49
|
+
schemaPath: $ZodType[];
|
|
50
|
+
path: (string | number)[];
|
|
51
|
+
}
|
|
52
|
+
interface Seen {
|
|
53
|
+
/** JSON Schema result for this Zod schema */
|
|
54
|
+
schema: BaseSchema;
|
|
55
|
+
/** A cached version of the schema that doesn't get overwritten during ref resolution */
|
|
56
|
+
def?: BaseSchema;
|
|
57
|
+
defId?: string | undefined;
|
|
58
|
+
/** Number of times this schema was encountered during traversal */
|
|
59
|
+
count: number;
|
|
60
|
+
/** Cycle path */
|
|
61
|
+
cycle?: (string | number)[] | undefined;
|
|
62
|
+
isParent?: boolean | undefined;
|
|
63
|
+
ref?: $ZodType | undefined | null;
|
|
64
|
+
/** JSON Schema property path for this schema */
|
|
65
|
+
path?: (string | number)[] | undefined;
|
|
66
|
+
}
|
|
67
|
+
interface ToJSONSchemaContext {
|
|
68
|
+
processors: Record<string, Processor>;
|
|
69
|
+
metadataRegistry: $ZodRegistry<Record<string, any>>;
|
|
70
|
+
target: "draft-04" | "draft-07" | "draft-2020-12" | "openapi-3.0" | ({} & string);
|
|
71
|
+
unrepresentable: "throw" | "any";
|
|
72
|
+
override: (ctx: {
|
|
73
|
+
zodSchema: $ZodType;
|
|
74
|
+
jsonSchema: BaseSchema;
|
|
75
|
+
path: (string | number)[];
|
|
76
|
+
}) => void;
|
|
77
|
+
io: "input" | "output";
|
|
78
|
+
counter: number;
|
|
79
|
+
seen: Map<$ZodType, Seen>;
|
|
80
|
+
cycles: "ref" | "throw";
|
|
81
|
+
reused: "ref" | "inline";
|
|
82
|
+
external?: {
|
|
83
|
+
registry: $ZodRegistry<{
|
|
84
|
+
id?: string | undefined;
|
|
85
|
+
}>;
|
|
86
|
+
uri?: ((id: string) => string) | undefined;
|
|
87
|
+
defs: Record<string, BaseSchema>;
|
|
88
|
+
} | undefined;
|
|
89
|
+
}
|
|
90
|
+
type ZodStandardSchemaWithJSON<T> = StandardSchemaWithJSONProps<input<T>, output<T>>;
|
|
91
|
+
interface ZodStandardJSONSchemaPayload<T> extends BaseSchema {
|
|
92
|
+
"~standard": ZodStandardSchemaWithJSON<T>;
|
|
93
|
+
}
|
|
94
|
+
//#endregion
|
|
95
|
+
export { ProcessParams, ToJSONSchemaContext, ToJSONSchemaParams, ZodStandardJSONSchemaPayload };
|
|
96
|
+
//# sourceMappingURL=to-json-schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"to-json-schema.d.ts","names":["core","JSONSchema","$ZodRegistry","schemas","StandardJSONSchemaV1","StandardSchemaWithJSONProps","Processor","T","$ZodType","ToJSONSchemaContext","BaseSchema","ProcessParams","JSONSchemaGeneratorParams","Record","$ZodTypes","ToJSONSchemaParams","Omit","RegistryToJSONSchemaParams","Seen","Map","initializeContext","process","extractDefs","finalize","ZodStandardJSONSchemaPayload","ZodStandardSchemaWithJSON","input","output","createToJSONSchemaMethod","StandardJSONSchemaMethodParams","Parameters","createStandardJSONSchemaMethod"],"sources":["../../../node_modules/.bun/zod@4.2.1/node_modules/zod/v4/core/to-json-schema.d.cts"],"sourcesContent":["import type * as core from \"../core/index.cjs\";\nimport type * as JSONSchema from \"./json-schema.cjs\";\nimport { type $ZodRegistry } from \"./registries.cjs\";\nimport type * as schemas from \"./schemas.cjs\";\nimport type { StandardJSONSchemaV1, StandardSchemaWithJSONProps } from \"./standard-schema.cjs\";\nexport type Processor<T extends schemas.$ZodType = schemas.$ZodType> = (schema: T, ctx: ToJSONSchemaContext, json: JSONSchema.BaseSchema, params: ProcessParams) => void;\nexport interface JSONSchemaGeneratorParams {\n processors: Record<string, Processor>;\n /** A registry used to look up metadata for each schema. Any schema with an `id` property will be extracted as a $def.\n * @default globalRegistry */\n metadata?: $ZodRegistry<Record<string, any>>;\n /** The JSON Schema version to target.\n * - `\"draft-2020-12\"` — Default. JSON Schema Draft 2020-12\n * - `\"draft-07\"` — JSON Schema Draft 7\n * - `\"draft-04\"` — JSON Schema Draft 4\n * - `\"openapi-3.0\"` — OpenAPI 3.0 Schema Object */\n target?: \"draft-04\" | \"draft-07\" | \"draft-2020-12\" | \"openapi-3.0\" | ({} & string) | undefined;\n /** How to handle unrepresentable types.\n * - `\"throw\"` — Default. Unrepresentable types throw an error\n * - `\"any\"` — Unrepresentable types become `{}` */\n unrepresentable?: \"throw\" | \"any\";\n /** Arbitrary custom logic that can be used to modify the generated JSON Schema. */\n override?: (ctx: {\n zodSchema: schemas.$ZodTypes;\n jsonSchema: JSONSchema.BaseSchema;\n path: (string | number)[];\n }) => void;\n /** Whether to extract the `\"input\"` or `\"output\"` type. Relevant to transforms, defaults, coerced primitives, etc.\n * - `\"output\"` — Default. Convert the output schema.\n * - `\"input\"` — Convert the input schema. */\n io?: \"input\" | \"output\";\n cycles?: \"ref\" | \"throw\";\n reused?: \"ref\" | \"inline\";\n external?: {\n registry: $ZodRegistry<{\n id?: string | undefined;\n }>;\n uri?: ((id: string) => string) | undefined;\n defs: Record<string, JSONSchema.BaseSchema>;\n } | undefined;\n}\n/**\n * Parameters for the toJSONSchema function.\n */\nexport type ToJSONSchemaParams = Omit<JSONSchemaGeneratorParams, \"processors\" | \"external\">;\n/**\n * Parameters for the toJSONSchema function when passing a registry.\n */\nexport interface RegistryToJSONSchemaParams extends ToJSONSchemaParams {\n uri?: (id: string) => string;\n}\nexport interface ProcessParams {\n schemaPath: schemas.$ZodType[];\n path: (string | number)[];\n}\nexport interface Seen {\n /** JSON Schema result for this Zod schema */\n schema: JSONSchema.BaseSchema;\n /** A cached version of the schema that doesn't get overwritten during ref resolution */\n def?: JSONSchema.BaseSchema;\n defId?: string | undefined;\n /** Number of times this schema was encountered during traversal */\n count: number;\n /** Cycle path */\n cycle?: (string | number)[] | undefined;\n isParent?: boolean | undefined;\n ref?: schemas.$ZodType | undefined | null;\n /** JSON Schema property path for this schema */\n path?: (string | number)[] | undefined;\n}\nexport interface ToJSONSchemaContext {\n processors: Record<string, Processor>;\n metadataRegistry: $ZodRegistry<Record<string, any>>;\n target: \"draft-04\" | \"draft-07\" | \"draft-2020-12\" | \"openapi-3.0\" | ({} & string);\n unrepresentable: \"throw\" | \"any\";\n override: (ctx: {\n zodSchema: schemas.$ZodType;\n jsonSchema: JSONSchema.BaseSchema;\n path: (string | number)[];\n }) => void;\n io: \"input\" | \"output\";\n counter: number;\n seen: Map<schemas.$ZodType, Seen>;\n cycles: \"ref\" | \"throw\";\n reused: \"ref\" | \"inline\";\n external?: {\n registry: $ZodRegistry<{\n id?: string | undefined;\n }>;\n uri?: ((id: string) => string) | undefined;\n defs: Record<string, JSONSchema.BaseSchema>;\n } | undefined;\n}\nexport declare function initializeContext(params: JSONSchemaGeneratorParams): ToJSONSchemaContext;\nexport declare function process<T extends schemas.$ZodType>(schema: T, ctx: ToJSONSchemaContext, _params?: ProcessParams): JSONSchema.BaseSchema;\nexport declare function extractDefs<T extends schemas.$ZodType>(ctx: ToJSONSchemaContext, schema: T): void;\nexport declare function finalize<T extends schemas.$ZodType>(ctx: ToJSONSchemaContext, schema: T): ZodStandardJSONSchemaPayload<T>;\nexport type ZodStandardSchemaWithJSON<T> = StandardSchemaWithJSONProps<core.input<T>, core.output<T>>;\nexport interface ZodStandardJSONSchemaPayload<T> extends JSONSchema.BaseSchema {\n \"~standard\": ZodStandardSchemaWithJSON<T>;\n}\n/**\n * Creates a toJSONSchema method for a schema instance.\n * This encapsulates the logic of initializing context, processing, extracting defs, and finalizing.\n */\nexport declare const createToJSONSchemaMethod: <T extends schemas.$ZodType>(schema: T, processors?: Record<string, Processor>) => (params?: ToJSONSchemaParams) => ZodStandardJSONSchemaPayload<T>;\n/**\n * Creates a toJSONSchema method for a schema instance.\n * This encapsulates the logic of initializing context, processing, extracting defs, and finalizing.\n */\ntype StandardJSONSchemaMethodParams = Parameters<StandardJSONSchemaV1[\"~standard\"][\"jsonSchema\"][\"input\"]>[0];\nexport declare const createStandardJSONSchemaMethod: <T extends schemas.$ZodType>(schema: T, io: \"input\" | \"output\") => (params?: StandardJSONSchemaMethodParams) => JSONSchema.BaseSchema;\nexport {};\n"],"x_google_ignoreList":[0],"mappings":";;;;;;;KAKYM,oBAAoBH,WAAmBA,qBAA6BI,QAAQE,2BAA2BR,oBAA+BU;UACjIC,yBAAAA;EADLN,UAAAA,EAEIO,MAFK,CAAA,MAAAN,EAEUD,SAFV,CAAA;EAAWH;;EAAgDI,QAAAA,CAAAA,EAKjEL,YALiEK,CAKpDM,MALoDN,CAAAA,MAAAA,EAAAA,GAAAA,CAAAA,CA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AAAA,EAzC7CA,UAyC6CA;EAAqB;QAvCpEA;;;;;;;QAOAE;;;;UAIOM,mBAAAA;cACDI,eAAeP;oBACTJ,aAAaW;;;;eAIhBV;gBACCF;;;;;QAKVkB,IAAIhB,UAAkBe;;;;cAIdhB;;;;UAIJW,eAAeZ;;;KAOjBwB,+BAA+BpB,4BAA4BL,MAAWO,IAAIP,OAAYO;UACjFiB,wCAAwCvB;eACxCwB,0BAA0BlB"}
|
package/util.d.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
import { SomeType } from "./schemas.js";
|
|
2
|
+
|
|
3
|
+
//#region ../../node_modules/.bun/zod@4.2.1/node_modules/zod/v4/core/util.d.cts
|
|
2
4
|
|
|
3
5
|
type JWTAlgorithm = "HS256" | "HS384" | "HS512" | "RS256" | "RS384" | "RS512" | "ES256" | "ES384" | "ES512" | "PS256" | "PS384" | "PS512" | "EdDSA" | (string & {});
|
|
6
|
+
type MimeTypes = "application/json" | "application/xml" | "application/x-www-form-urlencoded" | "application/javascript" | "application/pdf" | "application/zip" | "application/vnd.ms-excel" | "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" | "application/msword" | "application/vnd.openxmlformats-officedocument.wordprocessingml.document" | "application/vnd.ms-powerpoint" | "application/vnd.openxmlformats-officedocument.presentationml.presentation" | "application/octet-stream" | "application/graphql" | "text/html" | "text/plain" | "text/css" | "text/javascript" | "text/csv" | "image/png" | "image/jpeg" | "image/gif" | "image/svg+xml" | "image/webp" | "audio/mpeg" | "audio/ogg" | "audio/wav" | "audio/webm" | "video/mp4" | "video/webm" | "video/ogg" | "font/woff" | "font/woff2" | "font/ttf" | "font/otf" | "multipart/form-data" | (string & {});
|
|
4
7
|
type IsAny<T> = 0 extends 1 & T ? true : false;
|
|
5
8
|
type Omit<T, K$1 extends keyof T> = Pick<T, Exclude<keyof T, K$1>>;
|
|
6
9
|
type MakePartial<T, K$1 extends keyof T> = Omit<T, K$1> & InexactPartial<Pick<T, K$1>>;
|
|
@@ -19,6 +22,7 @@ type Identity<T> = T;
|
|
|
19
22
|
type Flatten<T> = Identity<{ [k in keyof T]: T[k] }>;
|
|
20
23
|
type Prettify<T> = { [K in keyof T]: T[K] } & {};
|
|
21
24
|
type Extend<A extends SomeObject, B extends SomeObject> = Flatten<keyof A & keyof B extends never ? A & B : { [K in keyof A as K extends keyof B ? never : K]: A[K] } & { [K in keyof B]: B[K] }>;
|
|
25
|
+
type TupleItems = ReadonlyArray<SomeType>;
|
|
22
26
|
type AnyFunc = (...args: any[]) => any;
|
|
23
27
|
type MaybeAsync<T> = T | Promise<T>;
|
|
24
28
|
type EnumValue = string | number;
|
|
@@ -37,5 +41,5 @@ declare abstract class Class {
|
|
|
37
41
|
constructor(..._args: any[]);
|
|
38
42
|
}
|
|
39
43
|
//#endregion
|
|
40
|
-
export { AnyFunc, Class, EmptyToNever, EnumLike, Extend, Flatten, HasLength, IsAny, JWTAlgorithm, Literal, LoosePartial, MakePartial, MakeReadonly, Mask, MaybeAsync, NoUndefined, Numeric, Prettify, Primitive, PrimitiveSet, PropValues, ToEnum };
|
|
44
|
+
export { AnyFunc, Class, EmptyToNever, EnumLike, Extend, Flatten, HasLength, IsAny, JWTAlgorithm, Literal, LoosePartial, MakePartial, MakeReadonly, Mask, MaybeAsync, MimeTypes, NoUndefined, Numeric, Prettify, Primitive, PrimitiveSet, PropValues, ToEnum, TupleItems };
|
|
41
45
|
//# sourceMappingURL=util.d.ts.map
|