@arisutalk/character-spec 0.0.14 → 0.0.16
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/dist/types/v0/utils.d.ts.map +1 -1
- package/dist/v0/Character/Assets.d.ts +2 -2
- package/dist/v0/Character/Character.d.ts +1 -1
- package/dist/v0/Character/Message.d.ts +2 -2
- package/dist/v0/utils.d.ts +2 -2
- package/dist/v0/utils.js +17 -12
- package/dist/v0/utils.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/types/v0/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;;;;;;GAQG;AACH,eAAO,MAAM,cAAc,UAGzB,CAAC;AAEH;;;GAGG;AACH,eAAO,MAAM,gBAAgB,+
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/types/v0/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;;;;;;GAQG;AACH,eAAO,MAAM,cAAc,UAGzB,CAAC;AAEH;;;GAGG;AACH,eAAO,MAAM,gBAAgB,+DAYvB,CAAC;AAEP;;;GAGG;AACH,eAAO,MAAM,UAAU,gGAUjB,CAAC;AACP;;;;;;;;GAQG;AACH,wBAAgB,MAAM,CAClB,KAAK,CAAC,GAAG,SAAS;IACd,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CAC1B,EACH,GAAG,EAAE,MAAM,GAAG,IACJ,GAAG,GAAG,EAAE,aAGnB;AAED;;GAEG;AACH,eAAO,MAAM,eAAe,UAGyB,CAAC"}
|
|
@@ -12,7 +12,7 @@ export type AssetEntity = {
|
|
|
12
12
|
/** The name of the asset. Used as the file name. Should be unique. */
|
|
13
13
|
name: string;
|
|
14
14
|
/** The data of the asset. */
|
|
15
|
-
data: string | Uint8Array
|
|
15
|
+
data: string | Uint8Array<ArrayBuffer>;
|
|
16
16
|
};
|
|
17
17
|
|
|
18
18
|
/**
|
|
@@ -38,7 +38,7 @@ export type AssetsSetting = {
|
|
|
38
38
|
/** The name of the asset. Used as the file name. Should be unique. */
|
|
39
39
|
name: string;
|
|
40
40
|
/** The data of the asset. */
|
|
41
|
-
data: string | Uint8Array
|
|
41
|
+
data: string | Uint8Array<ArrayBuffer>;
|
|
42
42
|
}[];
|
|
43
43
|
};
|
|
44
44
|
|
|
@@ -23,7 +23,7 @@ export type Message = {
|
|
|
23
23
|
/** The file content is stored in the separated storage. */
|
|
24
24
|
type: "file";
|
|
25
25
|
/** The file content. */
|
|
26
|
-
data: string | Uint8Array
|
|
26
|
+
data: string | Uint8Array<ArrayBuffer>;
|
|
27
27
|
/** MIME type of the file. */
|
|
28
28
|
mimeType: string;
|
|
29
29
|
};
|
|
@@ -36,7 +36,7 @@ export type Message = {
|
|
|
36
36
|
/** The name of the asset. Used as the file name. Should be unique. */
|
|
37
37
|
name: string;
|
|
38
38
|
/** The data of the asset. */
|
|
39
|
-
data: string | Uint8Array
|
|
39
|
+
data: string | Uint8Array<ArrayBuffer>;
|
|
40
40
|
}[];
|
|
41
41
|
};
|
|
42
42
|
|
package/dist/v0/utils.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ import { z, type ZodType } from "zod";
|
|
|
7
7
|
* Represents a file, either as a URL or as binary data (Uint8Array).
|
|
8
8
|
* @type {string | Uint8Array}
|
|
9
9
|
*/
|
|
10
|
-
export type FileType = string | Uint8Array
|
|
10
|
+
export type FileType = string | Uint8Array<ArrayBuffer>;
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* Represents a file, either as a URL or as binary data (Uint8Array).
|
|
@@ -41,7 +41,7 @@ export declare const ImageURLSchema: z.ZodURL;
|
|
|
41
41
|
/**
|
|
42
42
|
* The binary data of the file. Used for local assets.
|
|
43
43
|
*/
|
|
44
|
-
export type Uint8ArrayType = Uint8Array
|
|
44
|
+
export type Uint8ArrayType = Uint8Array<ArrayBuffer>;
|
|
45
45
|
|
|
46
46
|
/**
|
|
47
47
|
* The binary data of the file. Used for local assets.
|
package/dist/v0/utils.js
CHANGED
|
@@ -1,27 +1,32 @@
|
|
|
1
1
|
import { z as e } from "zod";
|
|
2
|
-
const
|
|
2
|
+
const n = e.url().meta({
|
|
3
3
|
description: "URL of an image. `local:` for browser storage (OpFS), otherwise a fetchable URL. While it can be `data:` URL for base64 encoded images, it's not recommended."
|
|
4
|
-
}),
|
|
4
|
+
}), i = e.instanceof(Uint8Array).refine(
|
|
5
|
+
(r) => r.buffer instanceof ArrayBuffer,
|
|
6
|
+
{
|
|
7
|
+
message: "Uint8Array must be backed by an ArrayBuffer, not SharedArrayBuffer"
|
|
8
|
+
}
|
|
9
|
+
).meta({
|
|
5
10
|
description: "The binary data of the file. Used for local assets.",
|
|
6
|
-
tsType: "Uint8Array"
|
|
11
|
+
tsType: "Uint8Array<ArrayBuffer>"
|
|
7
12
|
}), s = e.union([
|
|
8
13
|
// URL Asset
|
|
9
|
-
|
|
10
|
-
|
|
14
|
+
n,
|
|
15
|
+
i
|
|
11
16
|
]).meta({
|
|
12
17
|
description: `Represents a file, either as a URL or as binary data (Uint8Array).
|
|
13
18
|
@type {string | Uint8Array}
|
|
14
19
|
`
|
|
15
20
|
});
|
|
16
|
-
function
|
|
17
|
-
return (t) => new Set(t.map((a) => a[
|
|
21
|
+
function f(r) {
|
|
22
|
+
return (t) => new Set(t.map((a) => a[r])).size === t.length;
|
|
18
23
|
}
|
|
19
|
-
const
|
|
24
|
+
const c = e.int().min(1).meta({ description: "Positive integer (>= 1)" });
|
|
20
25
|
export {
|
|
21
26
|
s as FileSchema,
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
27
|
+
n as ImageURLSchema,
|
|
28
|
+
i as Uint8ArraySchema,
|
|
29
|
+
c as positiveInteger,
|
|
30
|
+
f as unique
|
|
26
31
|
};
|
|
27
32
|
//# sourceMappingURL=utils.js.map
|
package/dist/v0/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sources":["../../src/types/v0/utils.ts"],"sourcesContent":["import { z } from \"zod\";\n\n/**\n * This type is used to represent the URL of an image.\n * It is used to validate the URL of an image.\n * This should only be used in exported character. When importing the character, it should be converted to `local:`.\n * If its protocol is `local:`, it means the image is stored in the browser, usually OpFS.\n * Otherwise, it should be a valid URL which can be fetched in browser.\n * Don't use `data:` URL for large images, as it can bloat the character spec size.\n *\n */\nexport const ImageURLSchema = z.url().meta({\n description:\n \"URL of an image. `local:` for browser storage (OpFS), otherwise a fetchable URL. While it can be `data:` URL for base64 encoded images, it's not recommended.\",\n});\n\n/**\n * Binary data represented as Uint8Array.\n * Useful for local file assets.\n */\nexport const Uint8ArraySchema = z.instanceof(Uint8Array).meta({\n
|
|
1
|
+
{"version":3,"file":"utils.js","sources":["../../src/types/v0/utils.ts"],"sourcesContent":["import { z } from \"zod\";\n\n/**\n * This type is used to represent the URL of an image.\n * It is used to validate the URL of an image.\n * This should only be used in exported character. When importing the character, it should be converted to `local:`.\n * If its protocol is `local:`, it means the image is stored in the browser, usually OpFS.\n * Otherwise, it should be a valid URL which can be fetched in browser.\n * Don't use `data:` URL for large images, as it can bloat the character spec size.\n *\n */\nexport const ImageURLSchema = z.url().meta({\n description:\n \"URL of an image. `local:` for browser storage (OpFS), otherwise a fetchable URL. While it can be `data:` URL for base64 encoded images, it's not recommended.\",\n});\n\n/**\n * Binary data represented as Uint8Array.\n * Useful for local file assets.\n */\nexport const Uint8ArraySchema = z\n .instanceof(Uint8Array)\n .refine(\n (v): v is Uint8Array<ArrayBuffer> => v.buffer instanceof ArrayBuffer,\n {\n message:\n \"Uint8Array must be backed by an ArrayBuffer, not SharedArrayBuffer\",\n },\n )\n .meta({\n description: \"The binary data of the file. Used for local assets.\",\n tsType: \"Uint8Array<ArrayBuffer>\",\n });\n\n/**\n * Represents a file, either as a URL or as binary data (Uint8Array).\n * Used for file assets.\n */\nexport const FileSchema = z\n .union([\n // URL Asset\n ImageURLSchema,\n Uint8ArraySchema,\n ])\n .meta({\n description:\n \"Represents a file, either as a URL or as binary data (Uint8Array).\\n\" +\n \"@type {string | Uint8Array}\\n\",\n });\n/**\n * Custom validator to ensure all objects in the array have unique values for a specific key.\n * @param key The key to check for uniqueness. It should be a string key of the object.\n * @returns A predicate function for `z.refine`.\n * @example\n * ```ts\n * const schema = z.array(z.object({ name: z.string() })).refine(unique(\"name\"), { message: \"Not unique\" });\n * ```\n */\nexport function unique<\n const ARR extends {\n [key: string]: unknown;\n },\n>(key: keyof ARR) {\n return (i: ARR[]) => {\n return new Set(i.map((j) => j[key])).size === i.length;\n };\n}\n\n/**\n * Zod custom schema to ensure the value is a positive integer.\n */\nexport const positiveInteger = z\n .int()\n .min(1)\n .meta({ description: \"Positive integer (>= 1)\" });\n"],"names":["ImageURLSchema","z","Uint8ArraySchema","v","FileSchema","unique","key","i","j","positiveInteger"],"mappings":";AAWO,MAAMA,IAAiBC,EAAE,IAAA,EAAM,KAAK;AAAA,EACvC,aACI;AACR,CAAC,GAMYC,IAAmBD,EAC3B,WAAW,UAAU,EACrB;AAAA,EACG,CAACE,MAAoCA,EAAE,kBAAkB;AAAA,EACzD;AAAA,IACI,SACI;AAAA,EAAA;AAEZ,EACC,KAAK;AAAA,EACF,aAAa;AAAA,EACb,QAAQ;AACZ,CAAC,GAMQC,IAAaH,EACrB,MAAM;AAAA;AAAA,EAEHD;AAAA,EACAE;AACJ,CAAC,EACA,KAAK;AAAA,EACF,aACI;AAAA;AAAA;AAER,CAAC;AAUE,SAASG,EAIdC,GAAgB;AACd,SAAO,CAACC,MACG,IAAI,IAAIA,EAAE,IAAI,CAACC,MAAMA,EAAEF,CAAG,CAAC,CAAC,EAAE,SAASC,EAAE;AAExD;AAKO,MAAME,IAAkBR,EAC1B,IAAA,EACA,IAAI,CAAC,EACL,KAAK,EAAE,aAAa,0BAAA,CAA2B;"}
|