@unicode-utils/core 0.12.0-beta.19 → 0.12.0-beta.21

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/index.d.mts CHANGED
@@ -17,6 +17,24 @@ interface GetCurrentDraftVersionOptions {
17
17
  * Each pattern must include exactly one capturing group that matches the version
18
18
  */
19
19
  patterns?: RegExp[];
20
+ /**
21
+ * Called when a version is successfully extracted
22
+ * @param {string} version - The extracted Unicode draft version.
23
+ * @returns {void}
24
+ */
25
+ onSuccess?: (version: string) => void;
26
+ /**
27
+ * Called when no version could be extracted from the response body
28
+ * @param {string} text - The fetched ReadMe response text.
29
+ * @returns {void}
30
+ */
31
+ onNotFound?: (text: string) => void;
32
+ /**
33
+ * Called only when an error is caught in the catch block
34
+ * @param {unknown} error - The caught error value.
35
+ * @returns {void}
36
+ */
37
+ onError?: (error: unknown) => void;
20
38
  }
21
39
  /**
22
40
  * Retrieves the current Unicode Standard draft version by fetching and parsing
package/dist/index.mjs CHANGED
@@ -35,7 +35,7 @@ async function getCurrentDraftVersion(options = {}) {
35
35
  /Version (\d+\.\d+(?:\.\d+)?) of the Unicode Standard/,
36
36
  /Unicode(\d+\.\d+(?:\.\d+)?)/,
37
37
  /Version (\d+\.\d+)(?!\.\d)/
38
- ] } = options;
38
+ ], onSuccess, onNotFound, onError } = options;
39
39
  try {
40
40
  const res = await fetch(url, fetchOptions);
41
41
  if (!res.ok) throw new Error("failed to fetch draft ReadMe");
@@ -43,10 +43,14 @@ async function getCurrentDraftVersion(options = {}) {
43
43
  for (const pattern of patterns) {
44
44
  const match = text.match(pattern);
45
45
  if (match == null || match[1] == null) continue;
46
- return match[1];
46
+ const version = match[1].trim();
47
+ onSuccess?.(version);
48
+ return version;
47
49
  }
50
+ onNotFound?.(text);
48
51
  return null;
49
- } catch {
52
+ } catch (err) {
53
+ onError?.(err);
50
54
  return null;
51
55
  }
52
56
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unicode-utils/core",
3
- "version": "0.12.0-beta.19",
3
+ "version": "0.12.0-beta.21",
4
4
  "description": "Utilities for working with Unicode",
5
5
  "type": "module",
6
6
  "author": {
@@ -25,8 +25,6 @@
25
25
  "./constants": "./dist/constants.mjs",
26
26
  "./package.json": "./package.json"
27
27
  },
28
- "main": "./dist/index.mjs",
29
- "module": "./dist/index.mjs",
30
28
  "types": "./dist/index.d.mts",
31
29
  "publishConfig": {
32
30
  "access": "public"
@@ -35,24 +33,24 @@
35
33
  "dist"
36
34
  ],
37
35
  "dependencies": {
38
- "@luxass/utils": "2.7.2",
36
+ "@luxass/utils": "2.7.3",
39
37
  "defu": "6.1.4",
40
- "@unicode-utils/metadata": "0.12.0-beta.19",
41
- "@unicode-utils/parser": "0.12.0-beta.19"
38
+ "@unicode-utils/metadata": "0.12.0-beta.21",
39
+ "@unicode-utils/parser": "0.12.0-beta.21"
42
40
  },
43
41
  "devDependencies": {
44
- "@luxass/eslint-config": "6.0.3",
42
+ "@luxass/eslint-config": "7.2.0",
45
43
  "@types/node": "24.9.1",
46
- "eslint": "9.39.2",
47
- "eslint-plugin-format": "1.1.0",
48
- "msw": "2.12.7",
49
- "publint": "0.3.16",
50
- "tsdown": "0.18.3",
44
+ "eslint": "10.0.0",
45
+ "eslint-plugin-format": "1.4.0",
46
+ "msw": "2.12.10",
47
+ "publint": "0.3.17",
48
+ "tsdown": "0.20.3",
51
49
  "tsx": "4.21.0",
52
50
  "typescript": "5.9.3",
53
- "vitest-package-exports": "1.1.1",
54
- "@unicode-utils-tooling/tsconfig": "0.12.0-beta.19",
55
- "@unicode-utils-tooling/tsdown-config": "0.12.0-beta.19"
51
+ "vitest-package-exports": "1.2.0",
52
+ "@unicode-utils-tooling/tsdown-config": "0.12.0-beta.21",
53
+ "@unicode-utils-tooling/tsconfig": "0.12.0-beta.21"
56
54
  },
57
55
  "scripts": {
58
56
  "build": "tsdown --tsconfig=./tsconfig.build.json",