diff --git a/scripts/update-unicode-properties.ts b/scripts/update-unicode-properties.ts index 54f0d84..acb2fa6 100644 --- a/scripts/update-unicode-properties.ts +++ b/scripts/update-unicode-properties.ts @@ -54,6 +54,7 @@ const DATA_SOURCES = [ binProperties: "#table-binary-unicode-properties", gcValues: getLatestUnicodeGeneralCategoryValues, scValues: getLatestUnicodeScriptValues, + binPropertiesOfStrings: "#table-binary-unicode-properties-of-strings", }, ] const FILE_PATH = "src/unicode/properties.ts" @@ -63,6 +64,7 @@ type Datum = { binProperties: string[] gcValues: string[] scValues: string[] + binPropertiesOfStrings: string[] } // Main @@ -72,12 +74,14 @@ type Datum = { binProperties: new Set(), gcValues: new Set(), scValues: new Set(), + binPropertiesOfStrings: new Set(), } for (const { binProperties, gcValues, scValues, + binPropertiesOfStrings, url, version, } of DATA_SOURCES) { @@ -86,6 +90,7 @@ type Datum = { binProperties: [], gcValues: [], scValues: [], + binPropertiesOfStrings: [], } data[version] = datum @@ -120,6 +125,13 @@ type Datum = { scValues, existing.scValues, ) + if (binPropertiesOfStrings) { + datum.binPropertiesOfStrings = await collectValues( + window, + binPropertiesOfStrings, + existing.binPropertiesOfStrings, + ) + } logger.log("Done") } @@ -140,6 +152,9 @@ const scValueSets = new DataSet(${Object.values(data) const binPropertySets = new DataSet(${Object.values(data) .map((d) => makeDataCode(d.binProperties)) .join(",")}) +const binPropertyOfStringsSets = new DataSet(${Object.values(data) + .map((d) => makeDataCode(d.binPropertiesOfStrings)) + .join(",")}) export function isValidUnicodeProperty(version: number, name: string, value: string): boolean { if (gcNameSet.has(name)) { @@ -169,6 +184,19 @@ export function isValidLoneUnicodeProperty(version: number, value: string): bool .filter(Boolean) .join(" || ")} } + +export function isValidLoneUnicodePropertyOfString(version: number, value: string): boolean { + return ${Object.entries(data) + .map(([version, { binPropertiesOfStrings }]) => + makeVerificationCode( + version, + "binPropertyOfStringsSets", + binPropertiesOfStrings, + ), + ) + .filter(Boolean) + .join(" || ")} +} ` logger.log("Formatting code...") diff --git a/src/unicode/index.ts b/src/unicode/index.ts index 48b19a7..fb6e95b 100644 --- a/src/unicode/index.ts +++ b/src/unicode/index.ts @@ -2,6 +2,7 @@ export { isIdContinue, isIdStart } from "./ids" export { isValidLoneUnicodeProperty, isValidUnicodeProperty, + isValidLoneUnicodePropertyOfString, } from "./properties" export const NULL = 0x00 diff --git a/src/unicode/properties-of-strings.ts b/src/unicode/properties-of-strings.ts deleted file mode 100644 index edd4ddd..0000000 --- a/src/unicode/properties-of-strings.ts +++ /dev/null @@ -1,16 +0,0 @@ -const binPropertyOfStringSets = new Set([ - "Basic_Emoji", - "Emoji_Keycap_Sequence", - "RGI_Emoji_Modifier_Sequence", - "RGI_Emoji_Flag_Sequence", - "RGI_Emoji_Tag_Sequence", - "RGI_Emoji_ZWJ_Sequence", - "RGI_Emoji", -]) - -export function isValidLoneUnicodePropertyOfString( - version: number, - value: string, -): boolean { - return version >= 2024 && binPropertyOfStringSets.has(value) -} diff --git a/src/unicode/properties.ts b/src/unicode/properties.ts index 119c7d4..d049114 100644 --- a/src/unicode/properties.ts +++ b/src/unicode/properties.ts @@ -119,6 +119,15 @@ const binPropertySets = new DataSet( "", "", ) +const binPropertyOfStringsSets = new DataSet( + "", + "", + "", + "", + "", + "", + "Basic_Emoji Emoji_Keycap_Sequence RGI_Emoji RGI_Emoji_Flag_Sequence RGI_Emoji_Modifier_Sequence RGI_Emoji_Tag_Sequence RGI_Emoji_ZWJ_Sequence", +) export function isValidUnicodeProperty( version: number, @@ -151,3 +160,10 @@ export function isValidLoneUnicodeProperty( (version >= 2021 && binPropertySets.es2021.has(value)) ) } + +export function isValidLoneUnicodePropertyOfString( + version: number, + value: string, +): boolean { + return version >= 2024 && binPropertyOfStringsSets.es2024.has(value) +} diff --git a/src/validator.ts b/src/validator.ts index 2c1b684..7e19ba8 100644 --- a/src/validator.ts +++ b/src/validator.ts @@ -73,6 +73,7 @@ import { isTrailSurrogate, isValidLoneUnicodeProperty, isValidUnicodeProperty, + isValidLoneUnicodePropertyOfString, isValidUnicode, AMPERSAND, NUMBER_SIGN, @@ -83,7 +84,6 @@ import { TILDE, LATIN_SMALL_LETTER_Q, } from "./unicode" -import { isValidLoneUnicodePropertyOfString } from "./unicode/properties-of-strings" // ^ $ \ . * + ? ( ) [ ] { } | const SYNTAX_CHARACTER = new Set([