wp-typia 0.22.7 → 0.22.9

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.
@@ -1,7 +1,7 @@
1
1
  // @bun
2
2
  import {
3
3
  PROJECT_TOOLS_PACKAGE_ROOT
4
- } from "./cli-tke8twkn.js";
4
+ } from "./cli-qse6myha.js";
5
5
 
6
6
  // ../wp-typia-project-tools/src/runtime/package-versions.ts
7
7
  import fs from "fs";
@@ -54,10 +54,19 @@ function createContentFingerprint(source) {
54
54
  }
55
55
  return (hash >>> 0).toString(16);
56
56
  }
57
+ function readPackageManifestFile(packageJsonPath) {
58
+ const fileDescriptor = fs.openSync(packageJsonPath, "r");
59
+ try {
60
+ const stats = fs.fstatSync(fileDescriptor);
61
+ const source = fs.readFileSync(fileDescriptor, "utf8");
62
+ return { source, stats };
63
+ } finally {
64
+ fs.closeSync(fileDescriptor);
65
+ }
66
+ }
57
67
  function resolvePackageManifestLocation(packageJsonPath) {
58
68
  try {
59
- const stats = fs.statSync(packageJsonPath);
60
- const source = fs.readFileSync(packageJsonPath, "utf8");
69
+ const { source, stats } = readPackageManifestFile(packageJsonPath);
61
70
  return {
62
71
  cacheKey: `file:${packageJsonPath}:${stats.ino}:${stats.mtimeMs}:${stats.ctimeMs}:${stats.size}:${createContentFingerprint(source)}`,
63
72
  packageJsonPath,
@@ -175,4 +184,4 @@ function getPackageVersions() {
175
184
 
176
185
  export { DEFAULT_WORDPRESS_ABILITIES_VERSION, DEFAULT_WORDPRESS_CORE_ABILITIES_VERSION, DEFAULT_WORDPRESS_CORE_DATA_VERSION, DEFAULT_WORDPRESS_DATA_VERSION, DEFAULT_WORDPRESS_DATAVIEWS_VERSION, DEFAULT_WP_TYPIA_DATAVIEWS_VERSION, resolveManagedPackageVersionRange, getPackageVersions };
177
186
 
178
- //# debugId=C72EB21C0A53F5BC64756E2164756E21
187
+ //# debugId=5EDDE195AC44420B64756E2164756E21
@@ -0,0 +1,46 @@
1
+ // @bun
2
+ // ../wp-typia-project-tools/src/runtime/id-suggestions.ts
3
+ function normalizeCloseId(value) {
4
+ return value.trim().toLowerCase();
5
+ }
6
+ function getEditDistance(left, right) {
7
+ const previous = Array.from({ length: right.length + 1 }, (_, index) => index);
8
+ const current = new Array(right.length + 1);
9
+ for (let leftIndex = 0;leftIndex < left.length; leftIndex += 1) {
10
+ current[0] = leftIndex + 1;
11
+ for (let rightIndex = 0;rightIndex < right.length; rightIndex += 1) {
12
+ const substitutionCost = left[leftIndex] === right[rightIndex] ? 0 : 1;
13
+ current[rightIndex + 1] = Math.min(current[rightIndex] + 1, previous[rightIndex + 1] + 1, previous[rightIndex] + substitutionCost);
14
+ }
15
+ for (let index = 0;index < current.length; index += 1) {
16
+ previous[index] = current[index];
17
+ }
18
+ }
19
+ return previous[right.length];
20
+ }
21
+ function suggestCloseId(input, candidates, options = {}) {
22
+ const normalize = options.normalize ?? normalizeCloseId;
23
+ const normalizedInput = normalize(input);
24
+ if (normalizedInput.length === 0) {
25
+ return null;
26
+ }
27
+ const maxDistance = options.maxDistance ?? 2;
28
+ if (maxDistance < 0) {
29
+ return null;
30
+ }
31
+ let bestCandidate = null;
32
+ for (const candidateId of candidates) {
33
+ const distance = getEditDistance(normalizedInput, normalize(candidateId));
34
+ if (bestCandidate === null || distance < bestCandidate.distance) {
35
+ bestCandidate = {
36
+ distance,
37
+ id: candidateId
38
+ };
39
+ }
40
+ }
41
+ return bestCandidate && bestCandidate.distance <= maxDistance ? bestCandidate.id : null;
42
+ }
43
+
44
+ export { suggestCloseId };
45
+
46
+ //# debugId=7EAC7A78B56C749964756E2164756E21
@@ -7,11 +7,11 @@ import {
7
7
  import {
8
8
  getBuiltInTemplateLayerDirs,
9
9
  isOmittableBuiltInTemplateLayerDir
10
- } from "./cli-10pe4mf8.js";
10
+ } from "./cli-xw1wbxf3.js";
11
11
  import {
12
12
  isBuiltInTemplateId,
13
13
  listTemplates
14
- } from "./cli-tke8twkn.js";
14
+ } from "./cli-qse6myha.js";
15
15
  import {
16
16
  EDITOR_PLUGIN_SLOT_IDS,
17
17
  HOOKED_BLOCK_ANCHOR_PATTERN,
@@ -21,7 +21,8 @@ import {
21
21
  escapeRegex,
22
22
  readWorkspaceInventory,
23
23
  resolveEditorPluginSlotAlias
24
- } from "./cli-ta3y0hp2.js";
24
+ } from "./cli-regw5384.js";
25
+ import"./cli-cvxvcw7c.js";
25
26
  import"./cli-t73q5aqz.js";
26
27
  import"./cli-fys8vm2t.js";
27
28
  import {
@@ -1114,4 +1115,4 @@ export {
1114
1115
  getDoctorChecks
1115
1116
  };
1116
1117
 
1117
- //# debugId=3C7A7D362A24E1A964756E2164756E21
1118
+ //# debugId=C5B6D0A40DB5B07664756E2164756E21
@@ -1,11 +1,11 @@
1
1
  // @bun
2
2
  import {
3
3
  getPackageVersions
4
- } from "./cli-2hsp17nd.js";
4
+ } from "./cli-arz4rcye.js";
5
5
  import {
6
6
  discoverMigrationInitLayout
7
7
  } from "./cli-2rqf6t0b.js";
8
- import"./cli-tke8twkn.js";
8
+ import"./cli-qse6myha.js";
9
9
  import {
10
10
  quoteTsString,
11
11
  require_typescript,
@@ -13,7 +13,8 @@ import {
13
13
  snapshotWorkspaceFiles,
14
14
  toPascalCase,
15
15
  updateWorkspaceInventorySource
16
- } from "./cli-ta3y0hp2.js";
16
+ } from "./cli-regw5384.js";
17
+ import"./cli-cvxvcw7c.js";
17
18
  import"./cli-fys8vm2t.js";
18
19
  import {
19
20
  CLI_DIAGNOSTIC_CODES,
@@ -862,4 +863,4 @@ export {
862
863
  applyInitPlan
863
864
  };
864
865
 
865
- //# debugId=4F60C8DD81E9727764756E2164756E21
866
+ //# debugId=0E2AA29C775DCB7E64756E2164756E21
@@ -1,9 +1,4 @@
1
1
  // @bun
2
- // ../wp-typia-project-tools/src/runtime/template-registry.ts
3
- import fs from "fs";
4
- import path from "path";
5
- import { fileURLToPath } from "url";
6
-
7
2
  // ../wp-typia-project-tools/src/runtime/template-defaults.ts
8
3
  var BUILTIN_BLOCK_METADATA_VERSION = "0.1.0";
9
4
  var BUILTIN_TEMPLATE_METADATA_DEFAULTS = Object.freeze({
@@ -44,6 +39,9 @@ function getRemovedBuiltInTemplateMessage(templateId) {
44
39
  }
45
40
 
46
41
  // ../wp-typia-project-tools/src/runtime/template-registry.ts
42
+ import fs from "fs";
43
+ import path from "path";
44
+ import { fileURLToPath } from "url";
47
45
  var __dirname2 = path.dirname(fileURLToPath(import.meta.url));
48
46
  var PROJECT_TOOLS_PACKAGE_ROOT_ENV = "WP_TYPIA_PROJECT_TOOLS_PACKAGE_ROOT";
49
47
  var PROJECT_TOOLS_PACKAGE_NAME = "@wp-typia/project-tools";
@@ -189,4 +187,4 @@ function getTemplateSelectOptions() {
189
187
 
190
188
  export { BUILTIN_BLOCK_METADATA_VERSION, COMPOUND_CHILD_BLOCK_METADATA_DEFAULTS, getBuiltInTemplateMetadataDefaults, isRemovedBuiltInTemplateId, getRemovedBuiltInTemplateMessage, PROJECT_TOOLS_PACKAGE_ROOT, SHARED_BASE_TEMPLATE_ROOT, SHARED_COMPOUND_TEMPLATE_ROOT, SHARED_PERSISTENCE_TEMPLATE_ROOT, SHARED_PRESET_TEMPLATE_ROOT, SHARED_REST_HELPER_TEMPLATE_ROOT, SHARED_MIGRATION_UI_TEMPLATE_ROOT, SHARED_WORKSPACE_TEMPLATE_ROOT, SHARED_TEST_PRESET_TEMPLATE_ROOT, SHARED_WP_ENV_PRESET_TEMPLATE_ROOT, BUILTIN_TEMPLATE_IDS, OFFICIAL_WORKSPACE_TEMPLATE_PACKAGE, OFFICIAL_WORKSPACE_TEMPLATE_ALIAS, TEMPLATE_IDS, isBuiltInTemplateId, normalizeTemplateLookupId, getUserFacingTemplateId, listTemplates, getTemplateById, getTemplateSelectOptions };
191
189
 
192
- //# debugId=C41A77AFBA98E24E64756E2164756E21
190
+ //# debugId=8BD9AE3B3C43E68464756E2164756E21