@capybara-hq/plugin-sdk 0.1.0-rc.23 → 0.1.0-rc.25

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/sandbox.js CHANGED
@@ -68,6 +68,44 @@ export function isFileSystemGoneError(e) {
68
68
  export const SANDBOX_TAG_RE = /^[a-z0-9-]{1,64}$/;
69
69
  // biome-ignore lint/suspicious/noControlCharactersInRegex: 正是要拦控制字符
70
70
  const CONTROL = /[\u0000-\u001f\u007f]/;
71
+ /** The longest project name, in UTF-16 code units. */
72
+ export const MAX_DEVICE_PROJECT_NAME_LENGTH = 64;
73
+ /** The most candidates a `scan` answers ({@link SandboxProvider.scan}). */
74
+ export const MAX_DEVICE_SCAN_RESULTS = 50;
75
+ /**
76
+ * Directory names a `scan` never enters, at any depth ({@link SandboxProvider.scan}): dependency
77
+ * trees, not projects. Every provider skips exactly these.
78
+ */
79
+ export const DEVICE_SCAN_SKIPPED_DIRS = Object.freeze(["node_modules"]);
80
+ /**
81
+ * Directory names a `scan` does not enter directly under its `base` ({@link SandboxProvider.scan}):
82
+ * the owner's macOS `Library` (app data, huge, partly privacy-protected) is not where projects
83
+ * live. Every provider skips exactly these.
84
+ */
85
+ export const DEVICE_SCAN_SKIPPED_BASE_DIRS = Object.freeze(["Library"]);
86
+ /** How far below its base a `scan` looks: the base's children and their children. */
87
+ export const MAX_DEVICE_SCAN_DEPTH = 2;
88
+ /**
89
+ * The most directories one `scan` visits (reads the entries of), its `base` included
90
+ * ({@link SandboxProvider.scan}): breadth-first, each level in code-unit order of path.
91
+ */
92
+ export const MAX_DEVICE_SCAN_DIRS = 500;
93
+ /**
94
+ * Whether `v` is a valid project name (a project's identity on its device, and a `scan`
95
+ * candidate's `suggestedName`): non-empty, at most {@link MAX_DEVICE_PROJECT_NAME_LENGTH} UTF-16
96
+ * code units, not `.` or `..`, no `/`, no control characters, and no leading or trailing
97
+ * whitespace.
98
+ */
99
+ export function isDeviceProjectName(v) {
100
+ return (typeof v === "string" &&
101
+ v !== "" &&
102
+ v !== "." &&
103
+ v !== ".." &&
104
+ v.length <= MAX_DEVICE_PROJECT_NAME_LENGTH &&
105
+ !CONTROL.test(v) &&
106
+ !v.includes("/") &&
107
+ !/^\s|\s$/.test(v));
108
+ }
71
109
  /**
72
110
  * The root-independent checks of a path inside an instance (non-empty, at most 4096 characters, no
73
111
  * control characters or backslashes, absolute, no empty or `..` segments); returns the errors,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capybara-hq/plugin-sdk",
3
- "version": "0.1.0-rc.23",
3
+ "version": "0.1.0-rc.25",
4
4
  "description": "Capybara plugin SDK: the types and pure functions plugins are written against",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {