peachsim 0.1.2438 → 0.1.2439

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.
Files changed (175) hide show
  1. package/README.md +30 -98
  2. package/cli/app-catalog.ts +4 -73
  3. package/cli/catalog/content.ts +1 -1
  4. package/cli/cloud-box-artifact.ts +26 -39
  5. package/cli/cloud-client.ts +69 -117
  6. package/cli/cloud-session.ts +2 -9
  7. package/cli/commands/box.ts +6 -6
  8. package/cli/commands/control.ts +4 -11
  9. package/cli/commands/flow.ts +5 -9
  10. package/cli/commands/kotlin.ts +2 -1
  11. package/cli/commands/platform.ts +21 -39
  12. package/cli/commands/record-three.ts +1 -1
  13. package/cli/commands/shell-url.ts +29 -23
  14. package/cli/dev-build-freshness.ts +4 -3
  15. package/cli/native-input.ts +2 -2
  16. package/cli/outbound-endpoints.ts +20 -45
  17. package/cli/remote-project-bundle.ts +8 -14
  18. package/cli/remote-simulators.ts +1 -1
  19. package/cli/send-to-box.ts +2 -1
  20. package/detox/jest-preset.cjs +1 -1
  21. package/detox/jest-transform.cjs +40 -2
  22. package/dist-lib/agent-daemon-client.cjs +34 -24
  23. package/dist-lib/agent-events.cjs +1 -1
  24. package/dist-lib/attached-projects.cjs +19 -17
  25. package/dist-lib/auth/shared-session.cjs +18 -16
  26. package/dist-lib/backend-origin.cjs +1 -1
  27. package/dist-lib/beta.cjs +1 -1
  28. package/dist-lib/beta.mjs +2 -1
  29. package/dist-lib/bridge-constants.cjs +1 -1
  30. package/dist-lib/bridge-contract-input.cjs +1 -1
  31. package/dist-lib/bridge-contract-input.mjs +20 -583
  32. package/dist-lib/bridge-contract.cjs +1 -1
  33. package/dist-lib/bridge-contract.mjs +17 -99
  34. package/dist-lib/bundle-channel.cjs +8718 -5552
  35. package/dist-lib/capture-contract.cjs +1 -1
  36. package/dist-lib/capture-contract.mjs +13 -363
  37. package/dist-lib/cloud-contract.cjs +1 -1
  38. package/dist-lib/cloud-contract.mjs +34 -155
  39. package/dist-lib/cloud-test-args.cjs +1 -1
  40. package/dist-lib/cloud-test-args.mjs +2 -1
  41. package/dist-lib/cloud.cjs +1 -1
  42. package/dist-lib/cloud.mjs +26 -155
  43. package/dist-lib/config.cjs +1 -4
  44. package/dist-lib/config.mjs +11 -30
  45. package/dist-lib/detox/index.cjs +2554 -230
  46. package/dist-lib/detox/jest-preset.cjs +1 -1
  47. package/dist-lib/detox/jest-transform.cjs +40 -2
  48. package/dist-lib/dev-bundle-resolution.cjs +1 -1
  49. package/dist-lib/esm-chunks/acorn-FGE4PYDJ.mjs +50 -0
  50. package/dist-lib/esm-chunks/chunk-2EUHEBIJ.mjs +664 -0
  51. package/dist-lib/esm-chunks/chunk-2NPABFPN.mjs +5719 -0
  52. package/dist-lib/esm-chunks/chunk-4ZFNH7TU.mjs +10 -0
  53. package/dist-lib/esm-chunks/chunk-5T4XBUJP.mjs +1353 -0
  54. package/dist-lib/esm-chunks/chunk-6VY6HTJC.mjs +18951 -0
  55. package/dist-lib/esm-chunks/chunk-7HANEMO4.mjs +188 -0
  56. package/dist-lib/esm-chunks/chunk-C3WBGYP6.mjs +186 -0
  57. package/dist-lib/esm-chunks/chunk-CVGDRROP.mjs +57 -0
  58. package/dist-lib/esm-chunks/chunk-DADGQELM.mjs +375 -0
  59. package/dist-lib/esm-chunks/chunk-DEGYKHN7.mjs +12 -0
  60. package/dist-lib/esm-chunks/chunk-HIDNO3RP.mjs +10992 -0
  61. package/dist-lib/esm-chunks/chunk-HSADZOVN.mjs +30 -0
  62. package/dist-lib/esm-chunks/chunk-IWJUYJQO.mjs +42 -0
  63. package/dist-lib/esm-chunks/chunk-JCKI3VZ6.mjs +10 -0
  64. package/dist-lib/esm-chunks/chunk-KSQ5KM5Y.mjs +17 -0
  65. package/dist-lib/esm-chunks/chunk-KVTIDLBK.mjs +598 -0
  66. package/dist-lib/esm-chunks/chunk-MIQSRBVU.mjs +10 -0
  67. package/dist-lib/esm-chunks/chunk-YB27R6JG.mjs +115 -0
  68. package/dist-lib/esm-chunks/metro-layout-parser-MVUAXRUJ.mjs +58 -0
  69. package/dist-lib/expo-swift-bundle.cjs +7856 -4707
  70. package/dist-lib/expo-swift-metadata.cjs +1 -1
  71. package/dist-lib/expo-swift-metadata.mjs +16 -165
  72. package/dist-lib/home-paths.cjs +1 -1
  73. package/dist-lib/host/bridge-host.cjs +15658 -11404
  74. package/dist-lib/host/fetch-proxy-handler.cjs +3927 -342
  75. package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
  76. package/dist-lib/host/fetch-proxy-overrides.mjs +2 -1
  77. package/dist-lib/host/replacement-module-handler.cjs +4 -4
  78. package/dist-lib/host/websocket-proxy.cjs +1 -1
  79. package/dist-lib/index.cjs +9145 -32150
  80. package/dist-lib/jump-to-source-babel.cjs +1 -1
  81. package/dist-lib/jump-to-source-native.cjs +2 -2
  82. package/dist-lib/kotlin-host.cjs +260 -253
  83. package/dist-lib/menu.cjs +1 -1
  84. package/dist-lib/menu.mjs +5 -13
  85. package/dist-lib/metro-fingerprint-registry.cjs +1 -1
  86. package/dist-lib/metro-fingerprint-registry.mjs +5 -6
  87. package/dist-lib/metro-production-bundle.cjs +22 -3
  88. package/dist-lib/metro-production-bundle.mjs +26 -92
  89. package/dist-lib/native-app-identity-project.cjs +663 -451
  90. package/dist-lib/native-app-identity-project.mjs +509 -2318
  91. package/dist-lib/native-app-identity.cjs +1 -1
  92. package/dist-lib/native-app-identity.mjs +27 -1340
  93. package/dist-lib/native-firebase-metadata.cjs +1 -1
  94. package/dist-lib/native-firebase-metadata.mjs +5 -18
  95. package/dist-lib/pdfium-raster.cjs +1 -1
  96. package/dist-lib/pdfium-raster.mjs +2 -1
  97. package/dist-lib/plist.cjs +2 -2
  98. package/dist-lib/plist.mjs +5 -7
  99. package/dist-lib/profiles.cjs +2 -1
  100. package/dist-lib/public-brand.cjs +1 -1
  101. package/dist-lib/public-origins-lib-esm.json +246 -187
  102. package/dist-lib/public-origins-lib-static.json +1 -1
  103. package/dist-lib/public-origins-lib.json +1059 -1238
  104. package/dist-lib/react-native-host-modules.cjs +1 -1
  105. package/dist-lib/react-native-host-modules.mjs +2 -1
  106. package/dist-lib/reap-browser.cjs +18 -7
  107. package/dist-lib/scripts/dev-server-scanner.cjs +6 -230
  108. package/dist-lib/sdk.cjs +1 -1
  109. package/dist-lib/sdk.mjs +22 -78
  110. package/dist-lib/skills.cjs +21657 -17374
  111. package/dist-lib/swift-compile.cjs +1343 -1318
  112. package/dist-lib/swift-compile.mjs +68 -19013
  113. package/dist-lib/swift-package.cjs +1 -1
  114. package/dist-lib/swift-package.mjs +35 -630
  115. package/dist-lib/swift-submit.cjs +1 -1
  116. package/dist-lib/swift-submit.mjs +9 -24
  117. package/dist-lib/swift-toolchain.cjs +1 -1
  118. package/dist-lib/swift.cjs +1 -1
  119. package/dist-lib/vendor/@peculiar/x509.cjs +18061 -0
  120. package/dist-lib/vendor/acorn.cjs +5699 -0
  121. package/dist-lib/vendor/bplist-parser.cjs +1589 -0
  122. package/dist-lib/vendor/ignore.cjs +455 -0
  123. package/dist-lib/vendor/magic-string.cjs +1693 -0
  124. package/dist-lib/vendor/plist.cjs +10978 -0
  125. package/dist-lib/vendor/smol-toml.cjs +768 -0
  126. package/dist-lib/vendor/stream-json.cjs +1997 -0
  127. package/dist-lib/vendor/sucrase/dist/index.js.cjs +23593 -0
  128. package/dist-lib/vendor/sucrase/dist/parser/index.js.cjs +15750 -0
  129. package/dist-lib/vendor/sucrase/dist/parser/tokenizer/index.js.cjs +11316 -0
  130. package/dist-lib/vendor/sucrase/dist/parser/tokenizer/types.js.cjs +482 -0
  131. package/dist-lib/vendor/sucrase.cjs +23593 -0
  132. package/dist-lib/vendor/terser.cjs +36874 -0
  133. package/dist-lib/vendor/valibot.cjs +6253 -0
  134. package/dist-lib/vendor/zod.cjs +23262 -0
  135. package/dist-lib/worklet-executable.cjs +3 -3
  136. package/dist-lib/worklet-executable.mjs +11 -16
  137. package/dist-types/packages/peach-engine/src/config.d.ts +1 -1
  138. package/kotlin/fork/NOTICE +3 -0
  139. package/kotlin/sdk.tar.gz +0 -0
  140. package/kotlin/toolchain.json +6 -6
  141. package/package.json +17 -121
  142. package/runtime-companion.json +1 -1
  143. package/scripts/dev-server-scanner.ts +13 -223
  144. package/src/android-autolinking.ts +2 -2
  145. package/src/bundle-channel.mjs +3 -15
  146. package/src/cloud-contract.ts +3 -4
  147. package/src/config.ts +0 -5
  148. package/src/host/bridge-host.ts +19 -1
  149. package/src/host/server-scan-handler.ts +1 -9
  150. package/src/index.ts +0 -2
  151. package/src/kotlin-host.ts +1 -2
  152. package/src/kotlinDiscoveryContract.ts +1 -0
  153. package/src/metro-production-bundle.ts +28 -6
  154. package/src/native-seam-manifest.ts +0 -13
  155. package/src/one-native-app-catalog.ts +8 -27
  156. package/src/one-native-app-config.ts +95 -0
  157. package/src/one-native-source.ts +250 -0
  158. package/src/one-widget-metadata.ts +45 -126
  159. package/src/oneWidgetContract.ts +80 -117
  160. package/src/serverDiscoveryContract.ts +0 -1
  161. package/src/simulator-route.ts +8 -0
  162. package/src/vite-plugin.ts +2 -2
  163. package/src/xcode-project.ts +1 -1
  164. package/dist-lib/metro.cjs +0 -27984
  165. package/dist-lib/vite-swift.cjs +0 -43376
  166. package/dist-lib/vite.cjs +0 -21456
  167. package/src/androidAutolinkingContract.ts +0 -48
  168. package/src/androidRootModuleContract.ts +0 -39
  169. package/src/dev-server-open.ts +0 -92
  170. package/src/metro-plugin.ts +0 -578
  171. package/src/one-widget-discovery.ts +0 -23
  172. package/src/swift-vite-lifetime.ts +0 -42
  173. package/src/vite-plugin-one.ts +0 -746
  174. package/src/vite-plugin-swift.ts +0 -225
  175. package/src/vite.d.ts +0 -10
@@ -0,0 +1,455 @@
1
+ /*! peach v0.1.2439 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
2
+ let __sootsim_import_meta_url = '', __sootsim_import_meta_dirname = '', __sootsim_import_meta_filename = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; __sootsim_import_meta_dirname = __dirname; __sootsim_import_meta_filename = __filename; } catch {}
3
+
4
+ // ../../node_modules/ignore/index.js
5
+ function makeArray(subject) {
6
+ return Array.isArray(subject) ? subject : [subject];
7
+ }
8
+ var UNDEFINED = void 0;
9
+ var EMPTY = "";
10
+ var SPACE = " ";
11
+ var ESCAPE = "\\";
12
+ var REGEX_TEST_BLANK_LINE = /^\s+$/;
13
+ var REGEX_INVALID_TRAILING_BACKSLASH = /(?:[^\\]|^)\\$/;
14
+ var REGEX_REPLACE_LEADING_EXCAPED_EXCLAMATION = /^\\!/;
15
+ var REGEX_REPLACE_LEADING_EXCAPED_HASH = /^\\#/;
16
+ var REGEX_SPLITALL_CRLF = /\r?\n/g;
17
+ var REGEX_TEST_INVALID_PATH = /^\.{0,2}\/|^\.{1,2}$/;
18
+ var REGEX_TEST_TRAILING_SLASH = /\/$/;
19
+ var SLASH = "/";
20
+ var TMP_KEY_IGNORE = "node-ignore";
21
+ if (typeof Symbol !== "undefined") {
22
+ TMP_KEY_IGNORE = Symbol.for("node-ignore");
23
+ }
24
+ var KEY_IGNORE = TMP_KEY_IGNORE;
25
+ var define = (object, key, value) => {
26
+ Object.defineProperty(object, key, { value });
27
+ return value;
28
+ };
29
+ var REGEX_REGEXP_RANGE = /([0-z])-([0-z])/g;
30
+ var RETURN_FALSE = () => false;
31
+ var sanitizeRange = (range) => range.replace(
32
+ REGEX_REGEXP_RANGE,
33
+ (match, from, to) => from.charCodeAt(0) <= to.charCodeAt(0) ? match : EMPTY
34
+ );
35
+ var cleanRangeBackSlash = (slashes) => {
36
+ const { length } = slashes;
37
+ return slashes.slice(0, length - length % 2);
38
+ };
39
+ var REPLACERS = [
40
+ [
41
+ // Remove BOM
42
+ // TODO:
43
+ // Other similar zero-width characters?
44
+ /^\uFEFF/,
45
+ () => EMPTY
46
+ ],
47
+ // > Trailing spaces are ignored unless they are quoted with backslash ("\")
48
+ [
49
+ // (a\ ) -> (a )
50
+ // (a ) -> (a)
51
+ // (a ) -> (a)
52
+ // (a \ ) -> (a )
53
+ /((?:\\\\)*?)(\\?\s+)$/,
54
+ (_, m1, m2) => m1 + (m2.indexOf("\\") === 0 ? SPACE : EMPTY)
55
+ ],
56
+ // Replace (\ ) with ' '
57
+ // (\ ) -> ' '
58
+ // (\\ ) -> '\\ '
59
+ // (\\\ ) -> '\\ '
60
+ [
61
+ /(\\+?)\s/g,
62
+ (_, m1) => {
63
+ const { length } = m1;
64
+ return m1.slice(0, length - length % 2) + SPACE;
65
+ }
66
+ ],
67
+ // Escape metacharacters
68
+ // which is written down by users but means special for regular expressions.
69
+ // > There are 12 characters with special meanings:
70
+ // > - the backslash \,
71
+ // > - the caret ^,
72
+ // > - the dollar sign $,
73
+ // > - the period or dot .,
74
+ // > - the vertical bar or pipe symbol |,
75
+ // > - the question mark ?,
76
+ // > - the asterisk or star *,
77
+ // > - the plus sign +,
78
+ // > - the opening parenthesis (,
79
+ // > - the closing parenthesis ),
80
+ // > - and the opening square bracket [,
81
+ // > - the opening curly brace {,
82
+ // > These special characters are often called "metacharacters".
83
+ [
84
+ /[\\$.|*+(){^]/g,
85
+ (match) => `\\${match}`
86
+ ],
87
+ [
88
+ // > a question mark (?) matches a single character
89
+ /(?!\\)\?/g,
90
+ () => "[^/]"
91
+ ],
92
+ // leading slash
93
+ [
94
+ // > A leading slash matches the beginning of the pathname.
95
+ // > For example, "/*.c" matches "cat-file.c" but not "mozilla-sha1/sha1.c".
96
+ // A leading slash matches the beginning of the pathname
97
+ /^\//,
98
+ () => "^"
99
+ ],
100
+ // replace special metacharacter slash after the leading slash
101
+ [
102
+ /\//g,
103
+ () => "\\/"
104
+ ],
105
+ [
106
+ // > A leading "**" followed by a slash means match in all directories.
107
+ // > For example, "**/foo" matches file or directory "foo" anywhere,
108
+ // > the same as pattern "foo".
109
+ // > "**/foo/bar" matches file or directory "bar" anywhere that is directly
110
+ // > under directory "foo".
111
+ // Notice that the '*'s have been replaced as '\\*'
112
+ /^\^*\\\*\\\*\\\//,
113
+ // '**/foo' <-> 'foo'
114
+ () => "^(?:.*\\/)?"
115
+ ],
116
+ // starting
117
+ [
118
+ // there will be no leading '/'
119
+ // (which has been replaced by section "leading slash")
120
+ // If starts with '**', adding a '^' to the regular expression also works
121
+ /^(?=[^^])/,
122
+ function startingReplacer() {
123
+ return !/\/(?!$)/.test(this) ? "(?:^|\\/)" : "^";
124
+ }
125
+ ],
126
+ // two globstars
127
+ [
128
+ // Use lookahead assertions so that we could match more than one `'/**'`
129
+ /\\\/\\\*\\\*(?=\\\/|$)/g,
130
+ // Zero, one or several directories
131
+ // should not use '*', or it will be replaced by the next replacer
132
+ // Check if it is not the last `'/**'`
133
+ (_, index, str) => index + 6 < str.length ? "(?:\\/[^\\/]+)*" : "\\/.+"
134
+ ],
135
+ // normal intermediate wildcards
136
+ [
137
+ // Never replace escaped '*'
138
+ // ignore rule '\*' will match the path '*'
139
+ // 'abc.*/' -> go
140
+ // 'abc.*' -> skip this rule,
141
+ // coz trailing single wildcard will be handed by [trailing wildcard]
142
+ /(^|[^\\]+)(\\\*)+(?=.+)/g,
143
+ // '*.js' matches '.js'
144
+ // '*.js' doesn't match 'abc'
145
+ (_, p1, p2) => {
146
+ const unescaped = p2.replace(/\\\*/g, "[^\\/]*");
147
+ return p1 + unescaped;
148
+ }
149
+ ],
150
+ [
151
+ // unescape, revert step 3 except for back slash
152
+ // For example, if a user escape a '\\*',
153
+ // after step 3, the result will be '\\\\\\*'
154
+ /\\\\\\(?=[$.|*+(){^])/g,
155
+ () => ESCAPE
156
+ ],
157
+ [
158
+ // '\\\\' -> '\\'
159
+ /\\\\/g,
160
+ () => ESCAPE
161
+ ],
162
+ [
163
+ // > The range notation, e.g. [a-zA-Z],
164
+ // > can be used to match one of the characters in a range.
165
+ // `\` is escaped by step 3
166
+ /(\\)?\[([^\]/]*?)(\\*)($|\])/g,
167
+ (match, leadEscape, range, endEscape, close) => leadEscape === ESCAPE ? `\\[${range}${cleanRangeBackSlash(endEscape)}${close}` : close === "]" ? endEscape.length % 2 === 0 ? `[${sanitizeRange(range)}${endEscape}]` : "[]" : "[]"
168
+ ],
169
+ // ending
170
+ [
171
+ // 'js' will not match 'js.'
172
+ // 'ab' will not match 'abc'
173
+ /(?:[^*])$/,
174
+ // WTF!
175
+ // https://git-scm.com/docs/gitignore
176
+ // changes in [2.22.1](https://git-scm.com/docs/gitignore/2.22.1)
177
+ // which re-fixes #24, #38
178
+ // > If there is a separator at the end of the pattern then the pattern
179
+ // > will only match directories, otherwise the pattern can match both
180
+ // > files and directories.
181
+ // 'js*' will not match 'a.js'
182
+ // 'js/' will not match 'a.js'
183
+ // 'js' will match 'a.js' and 'a.js/'
184
+ (match) => /\/$/.test(match) ? `${match}$` : `${match}(?=$|\\/$)`
185
+ ]
186
+ ];
187
+ var REGEX_REPLACE_TRAILING_WILDCARD = /(^|\\\/)?\\\*$/;
188
+ var MODE_IGNORE = "regex";
189
+ var MODE_CHECK_IGNORE = "checkRegex";
190
+ var UNDERSCORE = "_";
191
+ var TRAILING_WILD_CARD_REPLACERS = {
192
+ [MODE_IGNORE](_, p1) {
193
+ const prefix = p1 ? `${p1}[^/]+` : "[^/]*";
194
+ return `${prefix}(?=$|\\/$)`;
195
+ },
196
+ [MODE_CHECK_IGNORE](_, p1) {
197
+ const prefix = p1 ? `${p1}[^/]*` : "[^/]*";
198
+ return `${prefix}(?=$|\\/$)`;
199
+ }
200
+ };
201
+ var makeRegexPrefix = (pattern) => REPLACERS.reduce(
202
+ (prev, [matcher, replacer]) => prev.replace(matcher, replacer.bind(pattern)),
203
+ pattern
204
+ );
205
+ var isString = (subject) => typeof subject === "string";
206
+ var checkPattern = (pattern) => pattern && isString(pattern) && !REGEX_TEST_BLANK_LINE.test(pattern) && !REGEX_INVALID_TRAILING_BACKSLASH.test(pattern) && pattern.indexOf("#") !== 0;
207
+ var splitPattern = (pattern) => pattern.split(REGEX_SPLITALL_CRLF).filter(Boolean);
208
+ var IgnoreRule = class {
209
+ constructor(pattern, mark, body, ignoreCase, negative, prefix) {
210
+ this.pattern = pattern;
211
+ this.mark = mark;
212
+ this.negative = negative;
213
+ define(this, "body", body);
214
+ define(this, "ignoreCase", ignoreCase);
215
+ define(this, "regexPrefix", prefix);
216
+ }
217
+ get regex() {
218
+ const key = UNDERSCORE + MODE_IGNORE;
219
+ if (this[key]) {
220
+ return this[key];
221
+ }
222
+ return this._make(MODE_IGNORE, key);
223
+ }
224
+ get checkRegex() {
225
+ const key = UNDERSCORE + MODE_CHECK_IGNORE;
226
+ if (this[key]) {
227
+ return this[key];
228
+ }
229
+ return this._make(MODE_CHECK_IGNORE, key);
230
+ }
231
+ _make(mode, key) {
232
+ const str = this.regexPrefix.replace(
233
+ REGEX_REPLACE_TRAILING_WILDCARD,
234
+ // It does not need to bind pattern
235
+ TRAILING_WILD_CARD_REPLACERS[mode]
236
+ );
237
+ const regex = this.ignoreCase ? new RegExp(str, "i") : new RegExp(str);
238
+ return define(this, key, regex);
239
+ }
240
+ };
241
+ var createRule = ({
242
+ pattern,
243
+ mark
244
+ }, ignoreCase) => {
245
+ let negative = false;
246
+ let body = pattern;
247
+ if (body.indexOf("!") === 0) {
248
+ negative = true;
249
+ body = body.substr(1);
250
+ }
251
+ body = body.replace(REGEX_REPLACE_LEADING_EXCAPED_EXCLAMATION, "!").replace(REGEX_REPLACE_LEADING_EXCAPED_HASH, "#");
252
+ const regexPrefix = makeRegexPrefix(body);
253
+ return new IgnoreRule(
254
+ pattern,
255
+ mark,
256
+ body,
257
+ ignoreCase,
258
+ negative,
259
+ regexPrefix
260
+ );
261
+ };
262
+ var RuleManager = class {
263
+ constructor(ignoreCase) {
264
+ this._ignoreCase = ignoreCase;
265
+ this._rules = [];
266
+ }
267
+ _add(pattern) {
268
+ if (pattern && pattern[KEY_IGNORE]) {
269
+ this._rules = this._rules.concat(pattern._rules._rules);
270
+ this._added = true;
271
+ return;
272
+ }
273
+ if (isString(pattern)) {
274
+ pattern = {
275
+ pattern
276
+ };
277
+ }
278
+ if (checkPattern(pattern.pattern)) {
279
+ const rule = createRule(pattern, this._ignoreCase);
280
+ this._added = true;
281
+ this._rules.push(rule);
282
+ }
283
+ }
284
+ // @param {Array<string> | string | Ignore} pattern
285
+ add(pattern) {
286
+ this._added = false;
287
+ makeArray(
288
+ isString(pattern) ? splitPattern(pattern) : pattern
289
+ ).forEach(this._add, this);
290
+ return this._added;
291
+ }
292
+ // Test one single path without recursively checking parent directories
293
+ //
294
+ // - checkUnignored `boolean` whether should check if the path is unignored,
295
+ // setting `checkUnignored` to `false` could reduce additional
296
+ // path matching.
297
+ // - check `string` either `MODE_IGNORE` or `MODE_CHECK_IGNORE`
298
+ // @returns {TestResult} true if a file is ignored
299
+ test(path, checkUnignored, mode) {
300
+ let ignored = false;
301
+ let unignored = false;
302
+ let matchedRule;
303
+ this._rules.forEach((rule) => {
304
+ const { negative } = rule;
305
+ if (unignored === negative && ignored !== unignored || negative && !ignored && !unignored && !checkUnignored) {
306
+ return;
307
+ }
308
+ const matched = rule[mode].test(path);
309
+ if (!matched) {
310
+ return;
311
+ }
312
+ ignored = !negative;
313
+ unignored = negative;
314
+ matchedRule = negative ? UNDEFINED : rule;
315
+ });
316
+ const ret = {
317
+ ignored,
318
+ unignored
319
+ };
320
+ if (matchedRule) {
321
+ ret.rule = matchedRule;
322
+ }
323
+ return ret;
324
+ }
325
+ };
326
+ var throwError = (message, Ctor) => {
327
+ throw new Ctor(message);
328
+ };
329
+ var checkPath = (path, originalPath, doThrow) => {
330
+ if (!isString(path)) {
331
+ return doThrow(
332
+ `path must be a string, but got \`${originalPath}\``,
333
+ TypeError
334
+ );
335
+ }
336
+ if (!path) {
337
+ return doThrow(`path must not be empty`, TypeError);
338
+ }
339
+ if (checkPath.isNotRelative(path)) {
340
+ const r = "`path.relative()`d";
341
+ return doThrow(
342
+ `path should be a ${r} string, but got "${originalPath}"`,
343
+ RangeError
344
+ );
345
+ }
346
+ return true;
347
+ };
348
+ var isNotRelative = (path) => REGEX_TEST_INVALID_PATH.test(path);
349
+ checkPath.isNotRelative = isNotRelative;
350
+ checkPath.convert = (p) => p;
351
+ var Ignore = class {
352
+ constructor({
353
+ ignorecase = true,
354
+ ignoreCase = ignorecase,
355
+ allowRelativePaths = false
356
+ } = {}) {
357
+ define(this, KEY_IGNORE, true);
358
+ this._rules = new RuleManager(ignoreCase);
359
+ this._strictPathCheck = !allowRelativePaths;
360
+ this._initCache();
361
+ }
362
+ _initCache() {
363
+ this._ignoreCache = /* @__PURE__ */ Object.create(null);
364
+ this._testCache = /* @__PURE__ */ Object.create(null);
365
+ }
366
+ add(pattern) {
367
+ if (this._rules.add(pattern)) {
368
+ this._initCache();
369
+ }
370
+ return this;
371
+ }
372
+ // legacy
373
+ addPattern(pattern) {
374
+ return this.add(pattern);
375
+ }
376
+ // @returns {TestResult}
377
+ _test(originalPath, cache, checkUnignored, slices) {
378
+ const path = originalPath && checkPath.convert(originalPath);
379
+ checkPath(
380
+ path,
381
+ originalPath,
382
+ this._strictPathCheck ? throwError : RETURN_FALSE
383
+ );
384
+ return this._t(path, cache, checkUnignored, slices);
385
+ }
386
+ checkIgnore(path) {
387
+ if (!REGEX_TEST_TRAILING_SLASH.test(path)) {
388
+ return this.test(path);
389
+ }
390
+ const slices = path.split(SLASH).filter(Boolean);
391
+ slices.pop();
392
+ if (slices.length) {
393
+ const parent = this._t(
394
+ slices.join(SLASH) + SLASH,
395
+ this._testCache,
396
+ true,
397
+ slices
398
+ );
399
+ if (parent.ignored) {
400
+ return parent;
401
+ }
402
+ }
403
+ return this._rules.test(path, false, MODE_CHECK_IGNORE);
404
+ }
405
+ _t(path, cache, checkUnignored, slices) {
406
+ if (path in cache) {
407
+ return cache[path];
408
+ }
409
+ if (!slices) {
410
+ slices = path.split(SLASH).filter(Boolean);
411
+ }
412
+ slices.pop();
413
+ if (!slices.length) {
414
+ return cache[path] = this._rules.test(path, checkUnignored, MODE_IGNORE);
415
+ }
416
+ const parent = this._t(
417
+ slices.join(SLASH) + SLASH,
418
+ cache,
419
+ checkUnignored,
420
+ slices
421
+ );
422
+ return cache[path] = parent.ignored ? parent : this._rules.test(path, checkUnignored, MODE_IGNORE);
423
+ }
424
+ ignores(path) {
425
+ return this._test(path, this._ignoreCache, false).ignored;
426
+ }
427
+ createFilter() {
428
+ return (path) => !this.ignores(path);
429
+ }
430
+ filter(paths) {
431
+ return makeArray(paths).filter(this.createFilter());
432
+ }
433
+ // @returns {TestResult}
434
+ test(path) {
435
+ return this._test(path, this._testCache, true);
436
+ }
437
+ };
438
+ var factory = (options) => new Ignore(options);
439
+ var isPathValid = (path) => checkPath(path && checkPath.convert(path), path, RETURN_FALSE);
440
+ var setupWindows = () => {
441
+ const makePosix = (str) => /^\\\\\?\\/.test(str) || /["<>|\u0000-\u001F]+/u.test(str) ? str : str.replace(/\\/g, "/");
442
+ checkPath.convert = makePosix;
443
+ const REGEX_TEST_WINDOWS_PATH_ABSOLUTE = /^[a-z]:\//i;
444
+ checkPath.isNotRelative = (path) => REGEX_TEST_WINDOWS_PATH_ABSOLUTE.test(path) || isNotRelative(path);
445
+ };
446
+ if (
447
+ // Detect `process` so that it can run in browsers.
448
+ typeof process !== "undefined" && process.platform === "win32"
449
+ ) {
450
+ setupWindows();
451
+ }
452
+ module.exports = factory;
453
+ factory.default = factory;
454
+ module.exports.isPathValid = isPathValid;
455
+ define(module.exports, Symbol.for("setupWindows"), setupWindows);