@teammy/server 0.1.4 → 0.1.6
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/main.js +11646 -7952
- package/dist/native-pi-entry.js +14 -1
- package/dist/project-pi-entry.js +46 -8
- package/dist/runtime/workflows/task-bootstrap/prompt.md +2 -0
- package/dist/web/assets/{Assistant-B3h2yQF3.css → Assistant-4yZWjYm-.css} +1 -1
- package/dist/web/assets/Assistant-BNVXOHQZ.js +1 -0
- package/dist/web/assets/Dashboard-zKTK6EZD.js +1 -0
- package/dist/web/assets/Files-DI98WkdW.js +1 -0
- package/dist/web/assets/{Markdown-Bq8P_NBV.js → Markdown-D3cU0ani.js} +4 -4
- package/dist/web/assets/Materials-CK-mbNmo.css +1 -0
- package/dist/web/assets/Materials-CWptgAHz.js +6 -0
- package/dist/web/assets/Sessions-DiDwqXLI.js +1 -0
- package/dist/web/assets/WorkspaceTree-DeAA1QtV.js +1 -0
- package/dist/web/assets/{file-links-CFCIacLV.js → file-links-GfCXWkEh.js} +1 -1
- package/dist/web/assets/index-BwEl1PIa.js +66 -0
- package/dist/web/assets/{index-B-MqU_88.css → index-CTIAGUGG.css} +1 -1
- package/dist/web/downloads/teammy-skill.zip +0 -0
- package/dist/web/index.html +2 -2
- package/node_modules/@isaacs/nonrecursive-glob-match/LICENSE.md +55 -0
- package/node_modules/@isaacs/nonrecursive-glob-match/README.md +333 -0
- package/node_modules/@isaacs/nonrecursive-glob-match/dist/commonjs/index.d.ts +114 -0
- package/node_modules/@isaacs/nonrecursive-glob-match/dist/commonjs/index.d.ts.map +1 -0
- package/node_modules/@isaacs/nonrecursive-glob-match/dist/commonjs/index.js +762 -0
- package/node_modules/@isaacs/nonrecursive-glob-match/dist/commonjs/index.js.map +1 -0
- package/node_modules/@isaacs/nonrecursive-glob-match/dist/commonjs/index.min.js +3 -0
- package/node_modules/@isaacs/nonrecursive-glob-match/dist/commonjs/index.min.js.map +7 -0
- package/node_modules/@isaacs/nonrecursive-glob-match/dist/commonjs/package.json +3 -0
- package/node_modules/@isaacs/nonrecursive-glob-match/dist/commonjs/parse-class.d.ts +4 -0
- package/node_modules/@isaacs/nonrecursive-glob-match/dist/commonjs/parse-class.d.ts.map +1 -0
- package/node_modules/@isaacs/nonrecursive-glob-match/dist/commonjs/parse-class.js +142 -0
- package/node_modules/@isaacs/nonrecursive-glob-match/dist/commonjs/parse-class.js.map +1 -0
- package/node_modules/@isaacs/nonrecursive-glob-match/dist/esm/index.d.ts +114 -0
- package/node_modules/@isaacs/nonrecursive-glob-match/dist/esm/index.d.ts.map +1 -0
- package/node_modules/@isaacs/nonrecursive-glob-match/dist/esm/index.js +758 -0
- package/node_modules/@isaacs/nonrecursive-glob-match/dist/esm/index.js.map +1 -0
- package/node_modules/@isaacs/nonrecursive-glob-match/dist/esm/index.min.js +3 -0
- package/node_modules/@isaacs/nonrecursive-glob-match/dist/esm/index.min.js.map +7 -0
- package/node_modules/@isaacs/nonrecursive-glob-match/dist/esm/package.json +3 -0
- package/node_modules/@isaacs/nonrecursive-glob-match/dist/esm/parse-class.d.ts +4 -0
- package/node_modules/@isaacs/nonrecursive-glob-match/dist/esm/parse-class.d.ts.map +1 -0
- package/node_modules/@isaacs/nonrecursive-glob-match/dist/esm/parse-class.js +138 -0
- package/node_modules/@isaacs/nonrecursive-glob-match/dist/esm/parse-class.js.map +1 -0
- package/node_modules/@isaacs/nonrecursive-glob-match/package.json +56 -0
- package/node_modules/@isaacs/nonrecursive-glob-match/src/index.ts +900 -0
- package/node_modules/@isaacs/nonrecursive-glob-match/src/parse-class.ts +158 -0
- package/node_modules/@wecom/aibot-node-sdk/README.md +786 -0
- package/node_modules/@wecom/aibot-node-sdk/dist/api.d.ts +17 -0
- package/node_modules/@wecom/aibot-node-sdk/dist/client.d.ts +217 -0
- package/node_modules/@wecom/aibot-node-sdk/dist/crypto.d.ts +12 -0
- package/node_modules/@wecom/aibot-node-sdk/dist/index.cjs.js +1563 -0
- package/node_modules/@wecom/aibot-node-sdk/dist/index.cjs.js.map +1 -0
- package/node_modules/@wecom/aibot-node-sdk/dist/index.d.ts +1324 -0
- package/node_modules/@wecom/aibot-node-sdk/dist/index.esm.js +1544 -0
- package/node_modules/@wecom/aibot-node-sdk/dist/index.esm.js.map +1 -0
- package/node_modules/@wecom/aibot-node-sdk/dist/logger.d.ts +14 -0
- package/node_modules/@wecom/aibot-node-sdk/dist/message-handler.d.ts +29 -0
- package/node_modules/@wecom/aibot-node-sdk/dist/types/api.d.ts +466 -0
- package/node_modules/@wecom/aibot-node-sdk/dist/types/common.d.ts +30 -0
- package/node_modules/@wecom/aibot-node-sdk/dist/types/config.d.ts +34 -0
- package/node_modules/@wecom/aibot-node-sdk/dist/types/event.d.ts +109 -0
- package/node_modules/@wecom/aibot-node-sdk/dist/types/index.d.ts +10 -0
- package/node_modules/@wecom/aibot-node-sdk/dist/types/message.d.ts +158 -0
- package/node_modules/@wecom/aibot-node-sdk/dist/utils.d.ts +19 -0
- package/node_modules/@wecom/aibot-node-sdk/dist/wecom-crypto/index.d.ts +46 -0
- package/node_modules/@wecom/aibot-node-sdk/dist/ws.d.ts +161 -0
- package/node_modules/@wecom/aibot-node-sdk/package.json +43 -0
- package/node_modules/asynckit/LICENSE +21 -0
- package/node_modules/asynckit/README.md +233 -0
- package/node_modules/asynckit/bench.js +76 -0
- package/node_modules/asynckit/index.js +6 -0
- package/node_modules/asynckit/lib/abort.js +29 -0
- package/node_modules/asynckit/lib/async.js +34 -0
- package/node_modules/asynckit/lib/defer.js +26 -0
- package/node_modules/asynckit/lib/iterate.js +75 -0
- package/node_modules/asynckit/lib/readable_asynckit.js +91 -0
- package/node_modules/asynckit/lib/readable_parallel.js +25 -0
- package/node_modules/asynckit/lib/readable_serial.js +25 -0
- package/node_modules/asynckit/lib/readable_serial_ordered.js +29 -0
- package/node_modules/asynckit/lib/state.js +37 -0
- package/node_modules/asynckit/lib/streamify.js +141 -0
- package/node_modules/asynckit/lib/terminator.js +29 -0
- package/node_modules/asynckit/package.json +63 -0
- package/node_modules/asynckit/parallel.js +43 -0
- package/node_modules/asynckit/serial.js +17 -0
- package/node_modules/asynckit/serialOrdered.js +75 -0
- package/node_modules/asynckit/stream.js +21 -0
- package/node_modules/axios/CHANGELOG.md +1934 -0
- package/node_modules/axios/LICENSE +7 -0
- package/node_modules/axios/MIGRATION_GUIDE.md +877 -0
- package/node_modules/axios/README.md +2786 -0
- package/node_modules/axios/dist/axios.js +6460 -0
- package/node_modules/axios/dist/axios.min.js +5 -0
- package/node_modules/axios/dist/axios.min.js.map +1 -0
- package/node_modules/axios/dist/browser/axios.cjs +6509 -0
- package/node_modules/axios/dist/esm/axios.js +6530 -0
- package/node_modules/axios/dist/esm/axios.min.js +3 -0
- package/node_modules/axios/dist/esm/axios.min.js.map +1 -0
- package/node_modules/axios/dist/node/axios.cjs +7491 -0
- package/node_modules/axios/index.d.cts +785 -0
- package/node_modules/axios/index.d.ts +804 -0
- package/node_modules/axios/index.js +45 -0
- package/node_modules/axios/lib/adapters/README.md +36 -0
- package/node_modules/axios/lib/adapters/adapters.js +132 -0
- package/node_modules/axios/lib/adapters/fetch.js +749 -0
- package/node_modules/axios/lib/adapters/http.js +1609 -0
- package/node_modules/axios/lib/adapters/xhr.js +384 -0
- package/node_modules/axios/lib/axios.js +89 -0
- package/node_modules/axios/lib/cancel/CancelToken.js +135 -0
- package/node_modules/axios/lib/cancel/CanceledError.js +22 -0
- package/node_modules/axios/lib/cancel/isCancel.js +5 -0
- package/node_modules/axios/lib/core/Axios.js +361 -0
- package/node_modules/axios/lib/core/AxiosError.js +278 -0
- package/node_modules/axios/lib/core/AxiosHeaders.js +487 -0
- package/node_modules/axios/lib/core/InterceptorManager.js +182 -0
- package/node_modules/axios/lib/core/README.md +8 -0
- package/node_modules/axios/lib/core/assertParamsAcyclic.js +49 -0
- package/node_modules/axios/lib/core/buildFullPath.js +76 -0
- package/node_modules/axios/lib/core/createMultipartBody.js +37 -0
- package/node_modules/axios/lib/core/dispatchRequest.js +115 -0
- package/node_modules/axios/lib/core/mergeConfig.js +237 -0
- package/node_modules/axios/lib/core/methodList.js +17 -0
- package/node_modules/axios/lib/core/setFormDataHeaders.js +27 -0
- package/node_modules/axios/lib/core/settle.js +27 -0
- package/node_modules/axios/lib/core/transformData.js +28 -0
- package/node_modules/axios/lib/defaults/index.js +178 -0
- package/node_modules/axios/lib/defaults/transitional.js +11 -0
- package/node_modules/axios/lib/env/README.md +3 -0
- package/node_modules/axios/lib/env/classes/FormData.js +2 -0
- package/node_modules/axios/lib/env/data.js +1 -0
- package/node_modules/axios/lib/helpers/AxiosTransformStream.js +165 -0
- package/node_modules/axios/lib/helpers/AxiosURLSearchParams.js +59 -0
- package/node_modules/axios/lib/helpers/Http2Sessions.js +122 -0
- package/node_modules/axios/lib/helpers/HttpStatusCode.js +88 -0
- package/node_modules/axios/lib/helpers/README.md +7 -0
- package/node_modules/axios/lib/helpers/ZlibHeaderTransformStream.js +29 -0
- package/node_modules/axios/lib/helpers/bind.js +14 -0
- package/node_modules/axios/lib/helpers/buildURL.js +69 -0
- package/node_modules/axios/lib/helpers/callbackify.js +18 -0
- package/node_modules/axios/lib/helpers/combineURLs.js +23 -0
- package/node_modules/axios/lib/helpers/composeSignals.js +71 -0
- package/node_modules/axios/lib/helpers/cookies.js +88 -0
- package/node_modules/axios/lib/helpers/deprecatedMethod.js +31 -0
- package/node_modules/axios/lib/helpers/estimateDataURLDecodedBytes.js +193 -0
- package/node_modules/axios/lib/helpers/formDataToBlob.js +113 -0
- package/node_modules/axios/lib/helpers/formDataToJSON.js +149 -0
- package/node_modules/axios/lib/helpers/formDataToStream.js +119 -0
- package/node_modules/axios/lib/helpers/fromDataURI.js +75 -0
- package/node_modules/axios/lib/helpers/isAbsoluteURL.js +19 -0
- package/node_modules/axios/lib/helpers/isAxiosError.js +14 -0
- package/node_modules/axios/lib/helpers/isURLSameOrigin.js +11 -0
- package/node_modules/axios/lib/helpers/normalizeURLForProtocolCheck.js +24 -0
- package/node_modules/axios/lib/helpers/null.js +2 -0
- package/node_modules/axios/lib/helpers/parseHeaders.js +72 -0
- package/node_modules/axios/lib/helpers/parseProtocol.js +6 -0
- package/node_modules/axios/lib/helpers/progressEventReducer.js +54 -0
- package/node_modules/axios/lib/helpers/readBlob.js +15 -0
- package/node_modules/axios/lib/helpers/resolveConfig.js +120 -0
- package/node_modules/axios/lib/helpers/sanitizeHeaderValue.js +60 -0
- package/node_modules/axios/lib/helpers/shouldBypassProxy.js +520 -0
- package/node_modules/axios/lib/helpers/speedometer.js +55 -0
- package/node_modules/axios/lib/helpers/spread.js +28 -0
- package/node_modules/axios/lib/helpers/throttle.js +45 -0
- package/node_modules/axios/lib/helpers/toFormData.js +279 -0
- package/node_modules/axios/lib/helpers/toURLEncodedForm.js +19 -0
- package/node_modules/axios/lib/helpers/trackStream.js +89 -0
- package/node_modules/axios/lib/helpers/validator.js +112 -0
- package/node_modules/axios/lib/platform/browser/classes/Blob.js +3 -0
- package/node_modules/axios/lib/platform/browser/classes/FormData.js +3 -0
- package/node_modules/axios/lib/platform/browser/classes/URLSearchParams.js +4 -0
- package/node_modules/axios/lib/platform/browser/index.js +13 -0
- package/node_modules/axios/lib/platform/common/utils.js +52 -0
- package/node_modules/axios/lib/platform/index.js +7 -0
- package/node_modules/axios/lib/platform/node/classes/Buffer.js +11 -0
- package/node_modules/axios/lib/platform/node/classes/FormData.js +3 -0
- package/node_modules/axios/lib/platform/node/classes/URLSearchParams.js +4 -0
- package/node_modules/axios/lib/platform/node/index.js +37 -0
- package/node_modules/axios/lib/utils.js +1201 -0
- package/node_modules/axios/node_modules/agent-base/README.md +145 -0
- package/node_modules/axios/node_modules/agent-base/dist/src/index.d.ts +78 -0
- package/node_modules/axios/node_modules/agent-base/dist/src/index.js +203 -0
- package/node_modules/axios/node_modules/agent-base/dist/src/index.js.map +1 -0
- package/node_modules/axios/node_modules/agent-base/dist/src/promisify.d.ts +4 -0
- package/node_modules/axios/node_modules/agent-base/dist/src/promisify.js +18 -0
- package/node_modules/axios/node_modules/agent-base/dist/src/promisify.js.map +1 -0
- package/node_modules/axios/node_modules/agent-base/package.json +64 -0
- package/node_modules/axios/node_modules/agent-base/src/index.ts +345 -0
- package/node_modules/axios/node_modules/agent-base/src/promisify.ts +33 -0
- package/node_modules/axios/node_modules/https-proxy-agent/README.md +137 -0
- package/node_modules/axios/node_modules/https-proxy-agent/dist/agent.d.ts +30 -0
- package/node_modules/axios/node_modules/https-proxy-agent/dist/agent.js +177 -0
- package/node_modules/axios/node_modules/https-proxy-agent/dist/agent.js.map +1 -0
- package/node_modules/axios/node_modules/https-proxy-agent/dist/index.d.ts +23 -0
- package/node_modules/axios/node_modules/https-proxy-agent/dist/index.js +14 -0
- package/node_modules/axios/node_modules/https-proxy-agent/dist/index.js.map +1 -0
- package/node_modules/axios/node_modules/https-proxy-agent/dist/parse-proxy-response.d.ts +7 -0
- package/node_modules/axios/node_modules/https-proxy-agent/dist/parse-proxy-response.js +66 -0
- package/node_modules/axios/node_modules/https-proxy-agent/dist/parse-proxy-response.js.map +1 -0
- package/node_modules/axios/node_modules/https-proxy-agent/package.json +56 -0
- package/node_modules/axios/package.json +202 -0
- package/node_modules/call-bind-apply-helpers/.eslintrc +17 -0
- package/node_modules/call-bind-apply-helpers/.github/FUNDING.yml +12 -0
- package/node_modules/call-bind-apply-helpers/.nycrc +9 -0
- package/node_modules/call-bind-apply-helpers/CHANGELOG.md +30 -0
- package/node_modules/call-bind-apply-helpers/LICENSE +21 -0
- package/node_modules/call-bind-apply-helpers/README.md +62 -0
- package/node_modules/call-bind-apply-helpers/actualApply.d.ts +1 -0
- package/node_modules/call-bind-apply-helpers/actualApply.js +10 -0
- package/node_modules/call-bind-apply-helpers/applyBind.d.ts +19 -0
- package/node_modules/call-bind-apply-helpers/applyBind.js +10 -0
- package/node_modules/call-bind-apply-helpers/functionApply.d.ts +1 -0
- package/node_modules/call-bind-apply-helpers/functionApply.js +4 -0
- package/node_modules/call-bind-apply-helpers/functionCall.d.ts +1 -0
- package/node_modules/call-bind-apply-helpers/functionCall.js +4 -0
- package/node_modules/call-bind-apply-helpers/index.d.ts +64 -0
- package/node_modules/call-bind-apply-helpers/index.js +15 -0
- package/node_modules/call-bind-apply-helpers/package.json +85 -0
- package/node_modules/call-bind-apply-helpers/reflectApply.d.ts +3 -0
- package/node_modules/call-bind-apply-helpers/reflectApply.js +4 -0
- package/node_modules/call-bind-apply-helpers/test/index.js +63 -0
- package/node_modules/call-bind-apply-helpers/tsconfig.json +9 -0
- package/node_modules/combined-stream/License +19 -0
- package/node_modules/combined-stream/Readme.md +138 -0
- package/node_modules/combined-stream/lib/combined_stream.js +208 -0
- package/node_modules/combined-stream/package.json +25 -0
- package/node_modules/delayed-stream/.npmignore +1 -0
- package/node_modules/delayed-stream/License +19 -0
- package/node_modules/delayed-stream/Makefile +7 -0
- package/node_modules/delayed-stream/Readme.md +141 -0
- package/node_modules/delayed-stream/lib/delayed_stream.js +107 -0
- package/node_modules/delayed-stream/package.json +27 -0
- package/node_modules/dunder-proto/.eslintrc +5 -0
- package/node_modules/dunder-proto/.github/FUNDING.yml +12 -0
- package/node_modules/dunder-proto/.nycrc +13 -0
- package/node_modules/dunder-proto/CHANGELOG.md +24 -0
- package/node_modules/dunder-proto/LICENSE +21 -0
- package/node_modules/dunder-proto/README.md +54 -0
- package/node_modules/dunder-proto/get.d.ts +5 -0
- package/node_modules/dunder-proto/get.js +30 -0
- package/node_modules/dunder-proto/package.json +76 -0
- package/node_modules/dunder-proto/set.d.ts +5 -0
- package/node_modules/dunder-proto/set.js +35 -0
- package/node_modules/dunder-proto/test/get.js +34 -0
- package/node_modules/dunder-proto/test/index.js +4 -0
- package/node_modules/dunder-proto/test/set.js +50 -0
- package/node_modules/dunder-proto/tsconfig.json +9 -0
- package/node_modules/es-define-property/.eslintrc +13 -0
- package/node_modules/es-define-property/.github/FUNDING.yml +12 -0
- package/node_modules/es-define-property/.nycrc +9 -0
- package/node_modules/es-define-property/CHANGELOG.md +29 -0
- package/node_modules/es-define-property/LICENSE +21 -0
- package/node_modules/es-define-property/README.md +49 -0
- package/node_modules/es-define-property/index.d.ts +3 -0
- package/node_modules/es-define-property/index.js +14 -0
- package/node_modules/es-define-property/package.json +81 -0
- package/node_modules/es-define-property/test/index.js +56 -0
- package/node_modules/es-define-property/tsconfig.json +10 -0
- package/node_modules/es-errors/.eslintrc +5 -0
- package/node_modules/es-errors/.github/FUNDING.yml +12 -0
- package/node_modules/es-errors/CHANGELOG.md +40 -0
- package/node_modules/es-errors/LICENSE +21 -0
- package/node_modules/es-errors/README.md +55 -0
- package/node_modules/es-errors/eval.d.ts +3 -0
- package/node_modules/es-errors/eval.js +4 -0
- package/node_modules/es-errors/index.d.ts +3 -0
- package/node_modules/es-errors/index.js +4 -0
- package/node_modules/es-errors/package.json +80 -0
- package/node_modules/es-errors/range.d.ts +3 -0
- package/node_modules/es-errors/range.js +4 -0
- package/node_modules/es-errors/ref.d.ts +3 -0
- package/node_modules/es-errors/ref.js +4 -0
- package/node_modules/es-errors/syntax.d.ts +3 -0
- package/node_modules/es-errors/syntax.js +4 -0
- package/node_modules/es-errors/test/index.js +19 -0
- package/node_modules/es-errors/tsconfig.json +49 -0
- package/node_modules/es-errors/type.d.ts +3 -0
- package/node_modules/es-errors/type.js +4 -0
- package/node_modules/es-errors/uri.d.ts +3 -0
- package/node_modules/es-errors/uri.js +4 -0
- package/node_modules/es-object-atoms/.eslintrc +16 -0
- package/node_modules/es-object-atoms/.github/FUNDING.yml +12 -0
- package/node_modules/es-object-atoms/CHANGELOG.md +44 -0
- package/node_modules/es-object-atoms/LICENSE +21 -0
- package/node_modules/es-object-atoms/README.md +63 -0
- package/node_modules/es-object-atoms/RequireObjectCoercible.d.ts +3 -0
- package/node_modules/es-object-atoms/RequireObjectCoercible.js +11 -0
- package/node_modules/es-object-atoms/ToObject.d.ts +7 -0
- package/node_modules/es-object-atoms/ToObject.js +10 -0
- package/node_modules/es-object-atoms/index.d.ts +3 -0
- package/node_modules/es-object-atoms/index.js +4 -0
- package/node_modules/es-object-atoms/isObject.d.ts +3 -0
- package/node_modules/es-object-atoms/isObject.js +6 -0
- package/node_modules/es-object-atoms/package.json +79 -0
- package/node_modules/es-object-atoms/test/index.js +38 -0
- package/node_modules/es-object-atoms/tsconfig.json +7 -0
- package/node_modules/es-set-tostringtag/.eslintrc +13 -0
- package/node_modules/es-set-tostringtag/.nycrc +9 -0
- package/node_modules/es-set-tostringtag/CHANGELOG.md +67 -0
- package/node_modules/es-set-tostringtag/LICENSE +21 -0
- package/node_modules/es-set-tostringtag/README.md +53 -0
- package/node_modules/es-set-tostringtag/index.d.ts +10 -0
- package/node_modules/es-set-tostringtag/index.js +35 -0
- package/node_modules/es-set-tostringtag/package.json +78 -0
- package/node_modules/es-set-tostringtag/test/index.js +85 -0
- package/node_modules/es-set-tostringtag/tsconfig.json +9 -0
- package/node_modules/eventemitter3/LICENSE +21 -0
- package/node_modules/eventemitter3/README.md +85 -0
- package/node_modules/eventemitter3/dist/eventemitter3.esm.js +355 -0
- package/node_modules/eventemitter3/dist/eventemitter3.esm.min.js +1 -0
- package/node_modules/eventemitter3/dist/eventemitter3.esm.min.js.map +1 -0
- package/node_modules/eventemitter3/dist/eventemitter3.umd.js +363 -0
- package/node_modules/eventemitter3/dist/eventemitter3.umd.min.js +1 -0
- package/node_modules/eventemitter3/dist/eventemitter3.umd.min.js.map +1 -0
- package/node_modules/eventemitter3/index.d.ts +135 -0
- package/node_modules/eventemitter3/index.js +336 -0
- package/node_modules/eventemitter3/index.mjs +4 -0
- package/node_modules/eventemitter3/package.json +62 -0
- package/node_modules/follow-redirects/LICENSE +18 -0
- package/node_modules/follow-redirects/README.md +183 -0
- package/node_modules/follow-redirects/debug.js +15 -0
- package/node_modules/follow-redirects/http.js +1 -0
- package/node_modules/follow-redirects/https.js +1 -0
- package/node_modules/follow-redirects/index.js +714 -0
- package/node_modules/follow-redirects/package.json +58 -0
- package/node_modules/form-data/CHANGELOG.md +686 -0
- package/node_modules/form-data/License +19 -0
- package/node_modules/form-data/README.md +355 -0
- package/node_modules/form-data/index.d.ts +62 -0
- package/node_modules/form-data/lib/browser.js +4 -0
- package/node_modules/form-data/lib/form_data.js +506 -0
- package/node_modules/form-data/lib/populate.js +10 -0
- package/node_modules/form-data/package.json +82 -0
- package/node_modules/function-bind/.eslintrc +21 -0
- package/node_modules/function-bind/.github/FUNDING.yml +12 -0
- package/node_modules/function-bind/.github/SECURITY.md +3 -0
- package/node_modules/function-bind/.nycrc +13 -0
- package/node_modules/function-bind/CHANGELOG.md +136 -0
- package/node_modules/function-bind/LICENSE +20 -0
- package/node_modules/function-bind/README.md +46 -0
- package/node_modules/function-bind/implementation.js +84 -0
- package/node_modules/function-bind/index.js +5 -0
- package/node_modules/function-bind/package.json +87 -0
- package/node_modules/function-bind/test/.eslintrc +9 -0
- package/node_modules/function-bind/test/index.js +252 -0
- package/node_modules/get-intrinsic/.eslintrc +42 -0
- package/node_modules/get-intrinsic/.github/FUNDING.yml +12 -0
- package/node_modules/get-intrinsic/.nycrc +9 -0
- package/node_modules/get-intrinsic/CHANGELOG.md +186 -0
- package/node_modules/get-intrinsic/LICENSE +21 -0
- package/node_modules/get-intrinsic/README.md +71 -0
- package/node_modules/get-intrinsic/index.js +378 -0
- package/node_modules/get-intrinsic/package.json +97 -0
- package/node_modules/get-intrinsic/test/GetIntrinsic.js +274 -0
- package/node_modules/get-proto/.eslintrc +10 -0
- package/node_modules/get-proto/.github/FUNDING.yml +12 -0
- package/node_modules/get-proto/.nycrc +9 -0
- package/node_modules/get-proto/CHANGELOG.md +21 -0
- package/node_modules/get-proto/LICENSE +21 -0
- package/node_modules/get-proto/Object.getPrototypeOf.d.ts +5 -0
- package/node_modules/get-proto/Object.getPrototypeOf.js +6 -0
- package/node_modules/get-proto/README.md +50 -0
- package/node_modules/get-proto/Reflect.getPrototypeOf.d.ts +3 -0
- package/node_modules/get-proto/Reflect.getPrototypeOf.js +4 -0
- package/node_modules/get-proto/index.d.ts +5 -0
- package/node_modules/get-proto/index.js +27 -0
- package/node_modules/get-proto/package.json +81 -0
- package/node_modules/get-proto/test/index.js +68 -0
- package/node_modules/get-proto/tsconfig.json +9 -0
- package/node_modules/glob/README.md +388 -214
- package/node_modules/glob/dist/commonjs/glob.d.ts +20 -11
- package/node_modules/glob/dist/commonjs/glob.d.ts.map +1 -1
- package/node_modules/glob/dist/commonjs/glob.js +22 -29
- package/node_modules/glob/dist/commonjs/glob.js.map +1 -1
- package/node_modules/glob/dist/commonjs/has-magic.d.ts +1 -1
- package/node_modules/glob/dist/commonjs/has-magic.d.ts.map +1 -1
- package/node_modules/glob/dist/commonjs/has-magic.js +1 -4
- package/node_modules/glob/dist/commonjs/has-magic.js.map +1 -1
- package/node_modules/glob/dist/commonjs/ignore.d.ts +16 -4
- package/node_modules/glob/dist/commonjs/ignore.d.ts.map +1 -1
- package/node_modules/glob/dist/commonjs/ignore.js +24 -4
- package/node_modules/glob/dist/commonjs/ignore.js.map +1 -1
- package/node_modules/glob/dist/commonjs/index.d.ts +3 -2
- package/node_modules/glob/dist/commonjs/index.d.ts.map +1 -1
- package/node_modules/glob/dist/commonjs/index.js.map +1 -1
- package/node_modules/glob/dist/commonjs/index.min.js +2 -3
- package/node_modules/glob/dist/commonjs/index.min.js.map +4 -4
- package/node_modules/glob/dist/commonjs/pattern.d.ts +10 -3
- package/node_modules/glob/dist/commonjs/pattern.d.ts.map +1 -1
- package/node_modules/glob/dist/commonjs/pattern.js +27 -15
- package/node_modules/glob/dist/commonjs/pattern.js.map +1 -1
- package/node_modules/glob/dist/commonjs/processor.d.ts +23 -10
- package/node_modules/glob/dist/commonjs/processor.d.ts.map +1 -1
- package/node_modules/glob/dist/commonjs/processor.js +36 -23
- package/node_modules/glob/dist/commonjs/processor.js.map +1 -1
- package/node_modules/glob/dist/commonjs/walker.d.ts +19 -17
- package/node_modules/glob/dist/commonjs/walker.d.ts.map +1 -1
- package/node_modules/glob/dist/commonjs/walker.js +50 -35
- package/node_modules/glob/dist/commonjs/walker.js.map +1 -1
- package/node_modules/glob/dist/esm/glob.d.ts +20 -11
- package/node_modules/glob/dist/esm/glob.d.ts.map +1 -1
- package/node_modules/glob/dist/esm/glob.js +22 -29
- package/node_modules/glob/dist/esm/glob.js.map +1 -1
- package/node_modules/glob/dist/esm/has-magic.d.ts +1 -1
- package/node_modules/glob/dist/esm/has-magic.d.ts.map +1 -1
- package/node_modules/glob/dist/esm/has-magic.js +1 -4
- package/node_modules/glob/dist/esm/has-magic.js.map +1 -1
- package/node_modules/glob/dist/esm/ignore.d.ts +16 -4
- package/node_modules/glob/dist/esm/ignore.d.ts.map +1 -1
- package/node_modules/glob/dist/esm/ignore.js +25 -5
- package/node_modules/glob/dist/esm/ignore.js.map +1 -1
- package/node_modules/glob/dist/esm/index.d.ts +3 -2
- package/node_modules/glob/dist/esm/index.d.ts.map +1 -1
- package/node_modules/glob/dist/esm/index.js.map +1 -1
- package/node_modules/glob/dist/esm/index.min.js +2 -3
- package/node_modules/glob/dist/esm/index.min.js.map +4 -4
- package/node_modules/glob/dist/esm/pattern.d.ts +10 -3
- package/node_modules/glob/dist/esm/pattern.d.ts.map +1 -1
- package/node_modules/glob/dist/esm/pattern.js +27 -15
- package/node_modules/glob/dist/esm/pattern.js.map +1 -1
- package/node_modules/glob/dist/esm/processor.d.ts +23 -10
- package/node_modules/glob/dist/esm/processor.d.ts.map +1 -1
- package/node_modules/glob/dist/esm/processor.js +36 -23
- package/node_modules/glob/dist/esm/processor.js.map +1 -1
- package/node_modules/glob/dist/esm/walker.d.ts +19 -17
- package/node_modules/glob/dist/esm/walker.d.ts.map +1 -1
- package/node_modules/glob/dist/esm/walker.js +51 -36
- package/node_modules/glob/dist/esm/walker.js.map +1 -1
- package/node_modules/glob/package.json +28 -12
- package/node_modules/glob/src/glob.ts +655 -0
- package/node_modules/glob/src/has-magic.ts +23 -0
- package/node_modules/glob/src/ignore.ts +162 -0
- package/node_modules/glob/src/index.ts +225 -0
- package/node_modules/glob/src/pattern.ts +286 -0
- package/node_modules/glob/src/processor.ts +333 -0
- package/node_modules/glob/src/walker.ts +523 -0
- package/node_modules/gopd/.eslintrc +16 -0
- package/node_modules/gopd/.github/FUNDING.yml +12 -0
- package/node_modules/gopd/CHANGELOG.md +45 -0
- package/node_modules/gopd/LICENSE +21 -0
- package/node_modules/gopd/README.md +40 -0
- package/node_modules/gopd/gOPD.d.ts +1 -0
- package/node_modules/gopd/gOPD.js +4 -0
- package/node_modules/gopd/index.d.ts +5 -0
- package/node_modules/gopd/index.js +15 -0
- package/node_modules/gopd/package.json +77 -0
- package/node_modules/gopd/test/index.js +36 -0
- package/node_modules/gopd/tsconfig.json +9 -0
- package/node_modules/has-symbols/.eslintrc +11 -0
- package/node_modules/has-symbols/.github/FUNDING.yml +12 -0
- package/node_modules/has-symbols/.nycrc +9 -0
- package/node_modules/has-symbols/CHANGELOG.md +91 -0
- package/node_modules/has-symbols/LICENSE +21 -0
- package/node_modules/has-symbols/README.md +46 -0
- package/node_modules/has-symbols/index.d.ts +3 -0
- package/node_modules/has-symbols/index.js +14 -0
- package/node_modules/has-symbols/package.json +111 -0
- package/node_modules/has-symbols/shams.d.ts +3 -0
- package/node_modules/has-symbols/shams.js +45 -0
- package/node_modules/has-symbols/test/index.js +22 -0
- package/node_modules/has-symbols/test/shams/core-js.js +29 -0
- package/node_modules/has-symbols/test/shams/get-own-property-symbols.js +29 -0
- package/node_modules/has-symbols/test/tests.js +58 -0
- package/node_modules/has-symbols/tsconfig.json +10 -0
- package/node_modules/has-tostringtag/.eslintrc +5 -0
- package/node_modules/has-tostringtag/.github/FUNDING.yml +12 -0
- package/node_modules/has-tostringtag/.nycrc +13 -0
- package/node_modules/has-tostringtag/CHANGELOG.md +42 -0
- package/node_modules/has-tostringtag/LICENSE +21 -0
- package/node_modules/has-tostringtag/README.md +46 -0
- package/node_modules/has-tostringtag/index.d.ts +3 -0
- package/node_modules/has-tostringtag/index.js +8 -0
- package/node_modules/has-tostringtag/package.json +108 -0
- package/node_modules/has-tostringtag/shams.d.ts +3 -0
- package/node_modules/has-tostringtag/shams.js +8 -0
- package/node_modules/has-tostringtag/test/index.js +21 -0
- package/node_modules/has-tostringtag/test/shams/core-js.js +31 -0
- package/node_modules/has-tostringtag/test/shams/get-own-property-symbols.js +30 -0
- package/node_modules/has-tostringtag/test/tests.js +15 -0
- package/node_modules/has-tostringtag/tsconfig.json +49 -0
- package/node_modules/hasown/.github/FUNDING.yml +12 -0
- package/node_modules/hasown/.nycrc +13 -0
- package/node_modules/hasown/CHANGELOG.md +58 -0
- package/node_modules/hasown/LICENSE +21 -0
- package/node_modules/hasown/README.md +40 -0
- package/node_modules/hasown/eslint.config.mjs +6 -0
- package/node_modules/hasown/index.d.ts +3 -0
- package/node_modules/hasown/index.js +8 -0
- package/node_modules/hasown/package.json +91 -0
- package/node_modules/hasown/tsconfig.json +6 -0
- package/node_modules/math-intrinsics/.eslintrc +16 -0
- package/node_modules/math-intrinsics/.github/FUNDING.yml +12 -0
- package/node_modules/math-intrinsics/CHANGELOG.md +24 -0
- package/node_modules/math-intrinsics/LICENSE +21 -0
- package/node_modules/math-intrinsics/README.md +50 -0
- package/node_modules/math-intrinsics/abs.d.ts +1 -0
- package/node_modules/math-intrinsics/abs.js +4 -0
- package/node_modules/math-intrinsics/constants/maxArrayLength.d.ts +3 -0
- package/node_modules/math-intrinsics/constants/maxArrayLength.js +4 -0
- package/node_modules/math-intrinsics/constants/maxSafeInteger.d.ts +3 -0
- package/node_modules/math-intrinsics/constants/maxSafeInteger.js +5 -0
- package/node_modules/math-intrinsics/constants/maxValue.d.ts +3 -0
- package/node_modules/math-intrinsics/constants/maxValue.js +5 -0
- package/node_modules/math-intrinsics/floor.d.ts +1 -0
- package/node_modules/math-intrinsics/floor.js +4 -0
- package/node_modules/math-intrinsics/isFinite.d.ts +3 -0
- package/node_modules/math-intrinsics/isFinite.js +12 -0
- package/node_modules/math-intrinsics/isInteger.d.ts +3 -0
- package/node_modules/math-intrinsics/isInteger.js +16 -0
- package/node_modules/math-intrinsics/isNaN.d.ts +1 -0
- package/node_modules/math-intrinsics/isNaN.js +6 -0
- package/node_modules/math-intrinsics/isNegativeZero.d.ts +3 -0
- package/node_modules/math-intrinsics/isNegativeZero.js +6 -0
- package/node_modules/math-intrinsics/max.d.ts +1 -0
- package/node_modules/math-intrinsics/max.js +4 -0
- package/node_modules/math-intrinsics/min.d.ts +1 -0
- package/node_modules/math-intrinsics/min.js +4 -0
- package/node_modules/math-intrinsics/mod.d.ts +3 -0
- package/node_modules/math-intrinsics/mod.js +9 -0
- package/node_modules/math-intrinsics/package.json +86 -0
- package/node_modules/math-intrinsics/pow.d.ts +1 -0
- package/node_modules/math-intrinsics/pow.js +4 -0
- package/node_modules/math-intrinsics/round.d.ts +1 -0
- package/node_modules/math-intrinsics/round.js +4 -0
- package/node_modules/math-intrinsics/sign.d.ts +3 -0
- package/node_modules/math-intrinsics/sign.js +11 -0
- package/node_modules/math-intrinsics/test/index.js +192 -0
- package/node_modules/math-intrinsics/tsconfig.json +3 -0
- package/node_modules/mime-db/HISTORY.md +507 -0
- package/node_modules/mime-db/LICENSE +23 -0
- package/node_modules/mime-db/README.md +100 -0
- package/node_modules/mime-db/db.json +8519 -0
- package/node_modules/mime-db/index.js +12 -0
- package/node_modules/mime-db/package.json +60 -0
- package/node_modules/mime-types/HISTORY.md +397 -0
- package/node_modules/mime-types/LICENSE +23 -0
- package/node_modules/mime-types/README.md +113 -0
- package/node_modules/mime-types/index.js +188 -0
- package/node_modules/mime-types/package.json +44 -0
- package/node_modules/minimatch/README.md +125 -107
- package/node_modules/minimatch/dist/commonjs/index.d.ts +49 -38
- package/node_modules/minimatch/dist/commonjs/index.d.ts.map +1 -1
- package/node_modules/minimatch/dist/commonjs/index.js +782 -359
- package/node_modules/minimatch/dist/commonjs/index.js.map +1 -1
- package/node_modules/minimatch/dist/esm/index.d.ts +49 -38
- package/node_modules/minimatch/dist/esm/index.d.ts.map +1 -1
- package/node_modules/minimatch/dist/esm/index.js +781 -356
- package/node_modules/minimatch/dist/esm/index.js.map +1 -1
- package/node_modules/minimatch/package.json +5 -4
- package/node_modules/path-scurry/README.md +0 -1
- package/node_modules/path-scurry/dist/commonjs/index.d.ts +7 -0
- package/node_modules/path-scurry/dist/commonjs/index.d.ts.map +1 -1
- package/node_modules/path-scurry/dist/commonjs/index.js +59 -21
- package/node_modules/path-scurry/dist/commonjs/index.js.map +1 -1
- package/node_modules/path-scurry/dist/esm/index.d.ts +7 -0
- package/node_modules/path-scurry/dist/esm/index.d.ts.map +1 -1
- package/node_modules/path-scurry/dist/esm/index.js +42 -14
- package/node_modules/path-scurry/dist/esm/index.js.map +1 -1
- package/node_modules/path-scurry/package.json +4 -4
- package/node_modules/proxy-from-env/LICENSE +20 -0
- package/node_modules/proxy-from-env/README.md +163 -0
- package/node_modules/proxy-from-env/index.cjs +105 -0
- package/node_modules/proxy-from-env/index.js +103 -0
- package/node_modules/proxy-from-env/package.json +43 -0
- package/package.json +3 -1
- package/dist/web/assets/Assistant-DSQAdSiW.js +0 -1
- package/dist/web/assets/Dashboard-dCu2Cdxd.js +0 -1
- package/dist/web/assets/Files-cRhoWviM.js +0 -1
- package/dist/web/assets/Sessions-BxHsX1C5.js +0 -1
- package/dist/web/assets/WorkspaceTree-CD94JsaJ.js +0 -1
- package/dist/web/assets/index-BXpTaAUz.js +0 -66
- package/node_modules/minimatch/dist/commonjs/ast.d.ts +0 -22
- package/node_modules/minimatch/dist/commonjs/ast.d.ts.map +0 -1
- package/node_modules/minimatch/dist/commonjs/ast.js +0 -845
- package/node_modules/minimatch/dist/commonjs/ast.js.map +0 -1
- package/node_modules/minimatch/dist/commonjs/brace-expressions.d.ts +0 -8
- package/node_modules/minimatch/dist/commonjs/brace-expressions.d.ts.map +0 -1
- package/node_modules/minimatch/dist/commonjs/brace-expressions.js +0 -150
- package/node_modules/minimatch/dist/commonjs/brace-expressions.js.map +0 -1
- package/node_modules/minimatch/dist/esm/ast.d.ts +0 -22
- package/node_modules/minimatch/dist/esm/ast.d.ts.map +0 -1
- package/node_modules/minimatch/dist/esm/ast.js +0 -841
- package/node_modules/minimatch/dist/esm/ast.js.map +0 -1
- package/node_modules/minimatch/dist/esm/brace-expressions.d.ts +0 -8
- package/node_modules/minimatch/dist/esm/brace-expressions.d.ts.map +0 -1
- package/node_modules/minimatch/dist/esm/brace-expressions.js +0 -146
- package/node_modules/minimatch/dist/esm/brace-expressions.js.map +0 -1
|
@@ -0,0 +1,900 @@
|
|
|
1
|
+
import { type Form, parseClass } from './parse-class.js'
|
|
2
|
+
|
|
3
|
+
export type { Form }
|
|
4
|
+
|
|
5
|
+
export type MatcherOptions = {
|
|
6
|
+
/** perform a case-insensitive match */
|
|
7
|
+
nocase?: boolean
|
|
8
|
+
/** do not treat strings starting with `.` specially */
|
|
9
|
+
dot?: boolean
|
|
10
|
+
/** do not match extglobs (treat them as normal strings) */
|
|
11
|
+
noext?: boolean
|
|
12
|
+
/**
|
|
13
|
+
* normalize unicode in the pattern and the tested strings, with
|
|
14
|
+
* this form. `true` means `'NFC'`.
|
|
15
|
+
*/
|
|
16
|
+
normalize?: boolean | Form
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// parsed pattern items
|
|
20
|
+
export type Item =
|
|
21
|
+
| { t: 'lit'; ch: string }
|
|
22
|
+
| { t: 'any' | 'star' }
|
|
23
|
+
| { t: 'class'; re: RegExp }
|
|
24
|
+
| { t: 'ext'; type: string; alts: Item[][] }
|
|
25
|
+
|
|
26
|
+
// extglob syntax tokens become literals if they are not part of a
|
|
27
|
+
// closed extglob
|
|
28
|
+
export type Token =
|
|
29
|
+
Item | { t: 'open'; type: string } | { t: 'bar' } | { t: 'close' }
|
|
30
|
+
|
|
31
|
+
// state machine nodes
|
|
32
|
+
export type NegNode = { t: 'neg'; id: number; sub: Node; next: Node }
|
|
33
|
+
export type SplitNode = { t: 'split'; id: number; out: Node[] }
|
|
34
|
+
export type Node =
|
|
35
|
+
| ({ t: 'lit'; id: number; next: Node } & Lit)
|
|
36
|
+
| { t: 'any' | 'star'; id: number; next: Node }
|
|
37
|
+
| { t: 'class'; id: number; re: RegExp; next: Node }
|
|
38
|
+
| SplitNode
|
|
39
|
+
| NegNode
|
|
40
|
+
| { t: 'match'; id: number }
|
|
41
|
+
|
|
42
|
+
// the end of the pattern, or of a negated sub-pattern
|
|
43
|
+
const MATCH: Node = { t: 'match', id: 0 }
|
|
44
|
+
|
|
45
|
+
const extTypes = '!?+*@'
|
|
46
|
+
|
|
47
|
+
const lit = (ch: string): Item => ({ t: 'lit', ch })
|
|
48
|
+
|
|
49
|
+
const reEscape = (s: string) => s.replace(/[\\^$.*+?()[\]{}|/]/g, '\\$&')
|
|
50
|
+
|
|
51
|
+
// a RegExp that only matches `s`, with unicode case folding
|
|
52
|
+
const newFoldRe = (s: string) => new RegExp(`^${reEscape(s)}$`, 'iu')
|
|
53
|
+
|
|
54
|
+
// foldRe for one literal char. The same chars are in most patterns,
|
|
55
|
+
// so keep them. A RegExp without the `g` or `y` flag has no state to
|
|
56
|
+
// share.
|
|
57
|
+
const foldCache = new Map<string, RegExp>()
|
|
58
|
+
const foldRe = (ch: string) => {
|
|
59
|
+
let re = foldCache.get(ch)
|
|
60
|
+
if (!re) {
|
|
61
|
+
re = newFoldRe(ch)
|
|
62
|
+
if (foldCache.size >= 1000) foldCache.clear()
|
|
63
|
+
foldCache.set(ch, re)
|
|
64
|
+
}
|
|
65
|
+
return re
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* A literal char. With `nocase:true`, `re` folds case, and `ascii`
|
|
70
|
+
* holds its results for ASCII chars, by char code: 1 for a match,
|
|
71
|
+
* and 2 for not.
|
|
72
|
+
*/
|
|
73
|
+
export type Lit = { ch: string; re?: RegExp; ascii?: Uint8Array }
|
|
74
|
+
|
|
75
|
+
const litMatch = (l: Lit, c: string) => {
|
|
76
|
+
if (c === l.ch) return true
|
|
77
|
+
if (!l.re) return false
|
|
78
|
+
const code = c.charCodeAt(0)
|
|
79
|
+
if (code >= 128) return l.re.test(c)
|
|
80
|
+
const ascii = (l.ascii ??= new Uint8Array(128))
|
|
81
|
+
ascii[code] ||= l.re.test(c) ? 1 : 2
|
|
82
|
+
return ascii[code] === 1
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
const tokenize = (
|
|
86
|
+
p: string,
|
|
87
|
+
nocase: boolean,
|
|
88
|
+
noext: boolean,
|
|
89
|
+
form?: Form,
|
|
90
|
+
) => {
|
|
91
|
+
const toks: Token[] = []
|
|
92
|
+
for (let i = 0; i < p.length;) {
|
|
93
|
+
const c = String.fromCodePoint(p.codePointAt(i)!)
|
|
94
|
+
if (c === '\\') {
|
|
95
|
+
// a trailing \ is a literal \
|
|
96
|
+
const e = p.codePointAt(i + 1)
|
|
97
|
+
const ch = e === undefined ? c : String.fromCodePoint(e)
|
|
98
|
+
toks.push(lit(ch))
|
|
99
|
+
i += 1 + ch.length
|
|
100
|
+
continue
|
|
101
|
+
}
|
|
102
|
+
if (c === '[') {
|
|
103
|
+
const [re, consumed] = parseClass(p, i, nocase, form)
|
|
104
|
+
if (consumed) {
|
|
105
|
+
toks.push({ t: 'class', re })
|
|
106
|
+
i += consumed
|
|
107
|
+
continue
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
if (!noext && extTypes.includes(c) && p[i + 1] === '(') {
|
|
111
|
+
toks.push({ t: 'open', type: c })
|
|
112
|
+
i += 2
|
|
113
|
+
continue
|
|
114
|
+
}
|
|
115
|
+
toks.push(
|
|
116
|
+
!noext && c === '|' ? { t: 'bar' }
|
|
117
|
+
: !noext && c === ')' ? { t: 'close' }
|
|
118
|
+
: c === '*' ? { t: 'star' }
|
|
119
|
+
: c === '?' ? { t: 'any' }
|
|
120
|
+
: lit(c),
|
|
121
|
+
)
|
|
122
|
+
i += c.length
|
|
123
|
+
}
|
|
124
|
+
return toks
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
// map each open token index to the index of its close token
|
|
128
|
+
const pair = (toks: Token[]) => {
|
|
129
|
+
const pairs = new Map<number, number>()
|
|
130
|
+
const stack: number[] = []
|
|
131
|
+
toks.forEach((tok, i) => {
|
|
132
|
+
if (tok.t === 'open') stack.push(i)
|
|
133
|
+
else if (tok.t === 'close' && stack.length) pairs.set(stack.pop()!, i)
|
|
134
|
+
})
|
|
135
|
+
return pairs
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
// build the alternatives between start and end. An open token that
|
|
139
|
+
// is not closed is never inside a closed extglob, so bar and close
|
|
140
|
+
// tokens are only literal at the top level.
|
|
141
|
+
const build = (
|
|
142
|
+
toks: Token[],
|
|
143
|
+
pairs: Map<number, number>,
|
|
144
|
+
start: number,
|
|
145
|
+
end: number,
|
|
146
|
+
top: boolean,
|
|
147
|
+
): Item[][] => {
|
|
148
|
+
let seq: Item[] = []
|
|
149
|
+
const alts = [seq]
|
|
150
|
+
for (let i = start; i < end; i++) {
|
|
151
|
+
const tok = toks[i]!
|
|
152
|
+
const close = pairs.get(i)
|
|
153
|
+
if (tok.t === 'open' && close !== undefined) {
|
|
154
|
+
const sub = build(toks, pairs, i + 1, close, false)
|
|
155
|
+
seq.push({ t: 'ext', type: tok.type, alts: sub })
|
|
156
|
+
i = close
|
|
157
|
+
} else if (tok.t === 'bar' && !top) {
|
|
158
|
+
alts.push((seq = []))
|
|
159
|
+
} else if (tok.t === 'open') {
|
|
160
|
+
seq.push(lit(tok.type), lit('('))
|
|
161
|
+
} else if (tok.t === 'bar') {
|
|
162
|
+
seq.push(lit('|'))
|
|
163
|
+
} else if (tok.t === 'close') {
|
|
164
|
+
seq.push(lit(')'))
|
|
165
|
+
} else {
|
|
166
|
+
seq.push(tok)
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
return alts
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
// normalize each run of literal chars as one string, so that a char
|
|
173
|
+
// and the combining marks after it compose (or decompose) together.
|
|
174
|
+
// Syntax is already parsed, so a char that normalizes to a syntax
|
|
175
|
+
// char (such as full-width `*` in NFKC) stays a literal.
|
|
176
|
+
const normalize = (items: Item[], form: Form): Item[] => {
|
|
177
|
+
const out: Item[] = []
|
|
178
|
+
let run = ''
|
|
179
|
+
const flush = () => {
|
|
180
|
+
for (const ch of run.normalize(form)) out.push(lit(ch))
|
|
181
|
+
run = ''
|
|
182
|
+
}
|
|
183
|
+
for (const it of items) {
|
|
184
|
+
if (it.t === 'lit') {
|
|
185
|
+
run += it.ch
|
|
186
|
+
continue
|
|
187
|
+
}
|
|
188
|
+
flush()
|
|
189
|
+
out.push(
|
|
190
|
+
it.t === 'ext' ?
|
|
191
|
+
{ ...it, alts: it.alts.map(a => normalize(a, form)) }
|
|
192
|
+
: it,
|
|
193
|
+
)
|
|
194
|
+
}
|
|
195
|
+
flush()
|
|
196
|
+
return out
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
// the start node, and the number of node ids. Ids are dense, from 0
|
|
200
|
+
// for the match node.
|
|
201
|
+
const compile = (
|
|
202
|
+
items: Item[],
|
|
203
|
+
nocase: boolean,
|
|
204
|
+
): [start: Node, size: number] => {
|
|
205
|
+
let id = 1
|
|
206
|
+
const split = (out: Node[]): SplitNode => ({ t: 'split', id: id++, out })
|
|
207
|
+
const seq = (items: Item[], next: Node): Node =>
|
|
208
|
+
items.reduceRight((next, it) => item(it, next), next)
|
|
209
|
+
const item = (it: Item, next: Node): Node => {
|
|
210
|
+
switch (it.t) {
|
|
211
|
+
case 'lit':
|
|
212
|
+
const re = nocase ? foldRe(it.ch) : undefined
|
|
213
|
+
return { t: 'lit', id: id++, ch: it.ch, re, next }
|
|
214
|
+
case 'any':
|
|
215
|
+
case 'star':
|
|
216
|
+
return { t: it.t, id: id++, next }
|
|
217
|
+
case 'class':
|
|
218
|
+
return { t: 'class', id: id++, re: it.re, next }
|
|
219
|
+
}
|
|
220
|
+
const alts = (next: Node) => it.alts.map(a => seq(a, next))
|
|
221
|
+
switch (it.type) {
|
|
222
|
+
case '@':
|
|
223
|
+
return split(alts(next))
|
|
224
|
+
case '?':
|
|
225
|
+
return split([next, ...alts(next)])
|
|
226
|
+
case '!':
|
|
227
|
+
return { t: 'neg', id: id++, sub: split(alts(MATCH)), next }
|
|
228
|
+
}
|
|
229
|
+
// * and +, loop back after each match
|
|
230
|
+
const after = split([])
|
|
231
|
+
const entry = split(alts(after))
|
|
232
|
+
after.out.push(next, entry)
|
|
233
|
+
return it.type === '*' ? after : entry
|
|
234
|
+
}
|
|
235
|
+
const start = seq(items, MATCH)
|
|
236
|
+
return [start, id]
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
// one line per node, in the order that a walk from the start
|
|
240
|
+
// reaches them. Edges point to node ids. The nodes of a negated
|
|
241
|
+
// sub-pattern are indented under their negation.
|
|
242
|
+
const show = (start: Node): string => {
|
|
243
|
+
const lines: string[] = []
|
|
244
|
+
const seen = new Set<Node>()
|
|
245
|
+
const ref = (n: Node) => (n.t === 'match' ? 'match' : String(n.id))
|
|
246
|
+
const walk = (n: Node, indent: string) => {
|
|
247
|
+
if (n.t === 'match' || seen.has(n)) return
|
|
248
|
+
seen.add(n)
|
|
249
|
+
const line = (desc: string) => lines.push(`${indent}${n.id}: ${desc}`)
|
|
250
|
+
switch (n.t) {
|
|
251
|
+
case 'split':
|
|
252
|
+
line(`split -> ${n.out.map(ref).join(', ')}`)
|
|
253
|
+
for (const o of n.out) walk(o, indent)
|
|
254
|
+
return
|
|
255
|
+
case 'neg':
|
|
256
|
+
line(`!(${ref(n.sub)}) -> ${ref(n.next)}`)
|
|
257
|
+
walk(n.sub, indent + ' ')
|
|
258
|
+
return walk(n.next, indent)
|
|
259
|
+
case 'lit':
|
|
260
|
+
line(`${JSON.stringify(n.ch)} -> ${ref(n.next)}`)
|
|
261
|
+
break
|
|
262
|
+
case 'class':
|
|
263
|
+
line(`${n.re} -> ${ref(n.next)}`)
|
|
264
|
+
break
|
|
265
|
+
default:
|
|
266
|
+
line(`${n.t === 'any' ? '?' : '*'} -> ${ref(n.next)}`)
|
|
267
|
+
}
|
|
268
|
+
walk(n.next, indent)
|
|
269
|
+
}
|
|
270
|
+
walk(start, '')
|
|
271
|
+
return [`start -> ${ref(start)}`, ...lines].join('\n')
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
// A thread inside a !(...) negation. It holds the threads of the
|
|
275
|
+
// negated sub-pattern, started where the negation started. The
|
|
276
|
+
// negation matches the chars so far if the sub-pattern does not.
|
|
277
|
+
type Run = { t: 'run'; neg: NegNode; state: State }
|
|
278
|
+
|
|
279
|
+
// The threads at one position in the string. Each node thread is
|
|
280
|
+
// only kept once, and runs with the same state are only kept once,
|
|
281
|
+
// so that identical threads merge. The match node is not in
|
|
282
|
+
// `threads`, because it can not step. It sets `match` instead.
|
|
283
|
+
class State {
|
|
284
|
+
// set by the Sim, to mark the nodes that this state has
|
|
285
|
+
gen: number
|
|
286
|
+
threads: Node[] = []
|
|
287
|
+
match = false
|
|
288
|
+
runs: Run[] = []
|
|
289
|
+
// the sorted ids of the threads, with 0 for a match, once the
|
|
290
|
+
// state is done
|
|
291
|
+
ids: number[] = []
|
|
292
|
+
|
|
293
|
+
constructor(gen: number) {
|
|
294
|
+
this.gen = gen
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
// no threads, so nothing more can match
|
|
298
|
+
get dead() {
|
|
299
|
+
return !this.threads.length && !this.match && !this.runs.length
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
// true if the two states hold the same threads
|
|
304
|
+
const sameState = (a: State, b: State): boolean => {
|
|
305
|
+
if (a.ids.length !== b.ids.length) return false
|
|
306
|
+
if (a.runs.length !== b.runs.length) return false
|
|
307
|
+
if (a.ids.some((id, i) => id !== b.ids[i])) return false
|
|
308
|
+
return a.runs.every(r =>
|
|
309
|
+
b.runs.some(o => o.neg === r.neg && sameState(o.state, r.state)),
|
|
310
|
+
)
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
/**
|
|
314
|
+
* For each node id, the gen of the last state that has the node as
|
|
315
|
+
* a thread, and of the last state that walked through it. A state is
|
|
316
|
+
* built to the end before the states around it go on, and the nodes
|
|
317
|
+
* of a negated sub-pattern are only in its states (other than the
|
|
318
|
+
* match node, which is never marked). So one mark for each node is
|
|
319
|
+
* enough to know if the state being built has it. The Sims of a
|
|
320
|
+
* matcher never run at the same time, so they share one Marks.
|
|
321
|
+
*/
|
|
322
|
+
export type Marks = { has: Float64Array; seen: Float64Array; gen: number }
|
|
323
|
+
|
|
324
|
+
const marks = (size: number): Marks => ({
|
|
325
|
+
has: new Float64Array(size),
|
|
326
|
+
seen: new Float64Array(size),
|
|
327
|
+
gen: 0,
|
|
328
|
+
})
|
|
329
|
+
|
|
330
|
+
class Sim {
|
|
331
|
+
// `.` and `..` only match literal dots, even with `dot:true`
|
|
332
|
+
dots: boolean
|
|
333
|
+
// the string starts with `.`, and `dot:true` is not set
|
|
334
|
+
dotStart: boolean
|
|
335
|
+
#marks: Marks
|
|
336
|
+
|
|
337
|
+
constructor(dots: boolean, dotStart: boolean, marks: Marks) {
|
|
338
|
+
this.dots = dots
|
|
339
|
+
this.dotStart = dotStart
|
|
340
|
+
this.#marks = marks
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
state() {
|
|
344
|
+
return new State(++this.#marks.gen)
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
// sort the ids of a state, once it has all of its threads
|
|
348
|
+
done(state: State) {
|
|
349
|
+
state.ids = state.threads.map(n => n.id).sort((a, b) => a - b)
|
|
350
|
+
if (state.match) state.ids.unshift(MATCH.id)
|
|
351
|
+
return state
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
// true the first time that the state walks through the node, so
|
|
355
|
+
// that loops in the graph stop
|
|
356
|
+
#visit(state: State, node: Node) {
|
|
357
|
+
const { seen } = this.#marks
|
|
358
|
+
if (seen[node.id] === state.gen) return false
|
|
359
|
+
seen[node.id] = state.gen
|
|
360
|
+
return true
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
#addThread(state: State, node: Node) {
|
|
364
|
+
const { has } = this.#marks
|
|
365
|
+
if (has[node.id] === state.gen) return false
|
|
366
|
+
has[node.id] = state.gen
|
|
367
|
+
state.threads.push(node)
|
|
368
|
+
return true
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
// wildcards only match a leading dot if `dot:true`. In a negated
|
|
372
|
+
// sub-pattern, this does not apply, because the negation itself
|
|
373
|
+
// can not match a leading dot.
|
|
374
|
+
restricted(i: number, top: boolean) {
|
|
375
|
+
return top && (this.dots || (this.dotStart && i === 0))
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
add(state: State, node: Node, i: number, top: boolean): void {
|
|
379
|
+
switch (node.t) {
|
|
380
|
+
case 'split':
|
|
381
|
+
if (!this.#visit(state, node)) return
|
|
382
|
+
for (const o of node.out) this.add(state, o, i, top)
|
|
383
|
+
return
|
|
384
|
+
case 'neg':
|
|
385
|
+
if (!this.#visit(state, node)) return
|
|
386
|
+
const sub = this.state()
|
|
387
|
+
this.add(sub, node.sub, i, false)
|
|
388
|
+
this.done(sub)
|
|
389
|
+
return this.addRun(
|
|
390
|
+
state,
|
|
391
|
+
{ t: 'run', neg: node, state: sub },
|
|
392
|
+
i,
|
|
393
|
+
top,
|
|
394
|
+
)
|
|
395
|
+
case 'star':
|
|
396
|
+
// a * can not start a dotfile, even if it matches nothing
|
|
397
|
+
if (this.restricted(i, top)) return
|
|
398
|
+
if (this.#addThread(state, node))
|
|
399
|
+
this.add(state, node.next, i, top)
|
|
400
|
+
return
|
|
401
|
+
case 'match':
|
|
402
|
+
state.match = true
|
|
403
|
+
return
|
|
404
|
+
default:
|
|
405
|
+
this.#addThread(state, node)
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
addRun(state: State, run: Run, i: number, top: boolean) {
|
|
410
|
+
for (const r of state.runs) {
|
|
411
|
+
if (r.neg === run.neg && sameState(r.state, run.state)) return
|
|
412
|
+
}
|
|
413
|
+
state.runs.push(run)
|
|
414
|
+
if (!run.state.match) {
|
|
415
|
+
this.add(state, run.neg.next, i, top)
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
// the threads after char `c`, at index `i`
|
|
420
|
+
step(state: State, c: string, i: number, top: boolean): State {
|
|
421
|
+
const next = this.state()
|
|
422
|
+
for (const th of state.threads) {
|
|
423
|
+
switch (th.t) {
|
|
424
|
+
case 'lit':
|
|
425
|
+
if (litMatch(th, c)) {
|
|
426
|
+
this.add(next, th.next, i + 1, top)
|
|
427
|
+
}
|
|
428
|
+
break
|
|
429
|
+
case 'any':
|
|
430
|
+
if (!this.restricted(i, top)) this.add(next, th.next, i + 1, top)
|
|
431
|
+
break
|
|
432
|
+
case 'class':
|
|
433
|
+
if (!this.restricted(i, top) && th.re.test(c)) {
|
|
434
|
+
this.add(next, th.next, i + 1, top)
|
|
435
|
+
}
|
|
436
|
+
break
|
|
437
|
+
case 'star':
|
|
438
|
+
if (!this.restricted(i, top)) this.add(next, th, i + 1, top)
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
if (!this.restricted(i, top)) {
|
|
442
|
+
for (const run of state.runs) {
|
|
443
|
+
// a sub-pattern with no threads can not match again, so the
|
|
444
|
+
// run stays the same
|
|
445
|
+
if (run.state.dead) {
|
|
446
|
+
this.addRun(next, run, i + 1, top)
|
|
447
|
+
continue
|
|
448
|
+
}
|
|
449
|
+
const sub = this.step(run.state, c, i, false)
|
|
450
|
+
this.addRun(
|
|
451
|
+
next,
|
|
452
|
+
{ t: 'run', neg: run.neg, state: sub },
|
|
453
|
+
i + 1,
|
|
454
|
+
top,
|
|
455
|
+
)
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
return this.done(next)
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
// A canonical key for the threads in a state. States with the same
|
|
463
|
+
// key hold the same threads, so they match the same strings.
|
|
464
|
+
const stateKey = (state: State): string => {
|
|
465
|
+
const ids = state.ids.join()
|
|
466
|
+
if (!state.runs.length) return ids
|
|
467
|
+
const runs = state.runs.map(r => `${r.neg.id}(${stateKey(r.state)})`)
|
|
468
|
+
return `${ids}|${runs.sort().join('|')}`
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
// A cached state of the simulation, and the states that each char
|
|
472
|
+
// leads to.
|
|
473
|
+
type DState = {
|
|
474
|
+
state: State
|
|
475
|
+
match: boolean
|
|
476
|
+
// no threads, so nothing more can match
|
|
477
|
+
dead: boolean
|
|
478
|
+
// the next state for each ASCII char, by char code, and for the
|
|
479
|
+
// other chars
|
|
480
|
+
ascii?: (DState | undefined)[]
|
|
481
|
+
next: Map<string, DState>
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
// The cache can hold about this many chars of state keys and
|
|
485
|
+
// transitions. When it is full, it is cleared, so that a pattern
|
|
486
|
+
// can not use an unbounded amount of memory.
|
|
487
|
+
const DFA_BUDGET = 1 << 18
|
|
488
|
+
|
|
489
|
+
// A cache of the states that the simulation reaches, built as the
|
|
490
|
+
// matcher is used. Each char of a string is then one Map lookup,
|
|
491
|
+
// once the states that it leads to are known.
|
|
492
|
+
//
|
|
493
|
+
// The dot rules only restrict the first char of a dotfile (strings
|
|
494
|
+
// that are only `.` or `..` do not use the cache). So a dotfile
|
|
495
|
+
// starts at its own state, which takes its first step with the
|
|
496
|
+
// restriction, and every other state takes steps without it.
|
|
497
|
+
class Dfa {
|
|
498
|
+
#start: Node
|
|
499
|
+
#states = new Map<string, DState>()
|
|
500
|
+
#size = 0
|
|
501
|
+
#plain?: DState
|
|
502
|
+
#dotStart?: DState
|
|
503
|
+
#sim: Sim
|
|
504
|
+
#dotSim: Sim
|
|
505
|
+
|
|
506
|
+
constructor(start: Node, marks: Marks) {
|
|
507
|
+
this.#start = start
|
|
508
|
+
this.#sim = new Sim(false, false, marks)
|
|
509
|
+
this.#dotSim = new Sim(false, true, marks)
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
#make(state: State): DState {
|
|
513
|
+
return {
|
|
514
|
+
state,
|
|
515
|
+
match: state.match,
|
|
516
|
+
dead: state.dead,
|
|
517
|
+
next: new Map(),
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
#intern(state: State): DState {
|
|
522
|
+
const key = stateKey(state)
|
|
523
|
+
const found = this.#states.get(key)
|
|
524
|
+
if (found) return found
|
|
525
|
+
if (this.#size > DFA_BUDGET) this.#clear()
|
|
526
|
+
const d = this.#make(state)
|
|
527
|
+
this.#states.set(key, d)
|
|
528
|
+
this.#size += key.length + 1
|
|
529
|
+
return d
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
#clear() {
|
|
533
|
+
this.#states.clear()
|
|
534
|
+
this.#size = 0
|
|
535
|
+
this.#plain = undefined
|
|
536
|
+
this.#dotStart = undefined
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
start(dotStart: boolean): DState {
|
|
540
|
+
if (dotStart) {
|
|
541
|
+
if (this.#dotStart) return this.#dotStart
|
|
542
|
+
const state = this.#dotSim.state()
|
|
543
|
+
this.#dotSim.add(state, this.#start, 0, true)
|
|
544
|
+
return (this.#dotStart = this.#make(this.#dotSim.done(state)))
|
|
545
|
+
}
|
|
546
|
+
if (this.#plain) return this.#plain
|
|
547
|
+
const state = this.#sim.state()
|
|
548
|
+
this.#sim.add(state, this.#start, 0, true)
|
|
549
|
+
return (this.#plain = this.#intern(this.#sim.done(state)))
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
// the next state, after a miss in `d.ascii`
|
|
553
|
+
next(d: DState, c: string): DState {
|
|
554
|
+
const code = c.charCodeAt(0)
|
|
555
|
+
const found = code < 128 ? undefined : d.next.get(c)
|
|
556
|
+
if (found) return found
|
|
557
|
+
// the dotfile start is not in the cache, so it is never shared
|
|
558
|
+
const n =
|
|
559
|
+
d === this.#dotStart ?
|
|
560
|
+
this.#intern(this.#dotSim.step(d.state, c, 0, true))
|
|
561
|
+
: this.#intern(this.#sim.step(d.state, c, 1, true))
|
|
562
|
+
if (code < 128) {
|
|
563
|
+
if (!d.ascii) {
|
|
564
|
+
d.ascii = new Array(128)
|
|
565
|
+
this.#size += 128
|
|
566
|
+
}
|
|
567
|
+
d.ascii[code] = n
|
|
568
|
+
} else {
|
|
569
|
+
d.next.set(c, n)
|
|
570
|
+
}
|
|
571
|
+
this.#size++
|
|
572
|
+
return n
|
|
573
|
+
}
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
/**
|
|
577
|
+
* A node in a graph with no splits or negations. Such a graph is a
|
|
578
|
+
* chain of nodes that each match one char, or a `*`.
|
|
579
|
+
*/
|
|
580
|
+
export type LinearNode = Exclude<
|
|
581
|
+
Node,
|
|
582
|
+
SplitNode | NegNode | { t: 'match' }
|
|
583
|
+
>
|
|
584
|
+
|
|
585
|
+
// the nodes in order, if the graph is a single chain
|
|
586
|
+
const linear = (start: Node): LinearNode[] | undefined => {
|
|
587
|
+
const nodes: LinearNode[] = []
|
|
588
|
+
for (let n = start; n.t !== 'match'; n = n.next) {
|
|
589
|
+
if (n.t === 'split' || n.t === 'neg') return undefined
|
|
590
|
+
nodes.push(n)
|
|
591
|
+
}
|
|
592
|
+
return nodes
|
|
593
|
+
}
|
|
594
|
+
|
|
595
|
+
// Match a chain of nodes. Each node other than `*` matches exactly
|
|
596
|
+
// one char, so on a failure it is enough to go back to the last `*`
|
|
597
|
+
// and let it match one more char. This takes at most
|
|
598
|
+
// nodes.length * chars.length steps.
|
|
599
|
+
const testLinear = (
|
|
600
|
+
nodes: LinearNode[],
|
|
601
|
+
chars: ArrayLike<string>,
|
|
602
|
+
start: number,
|
|
603
|
+
end: number,
|
|
604
|
+
) => {
|
|
605
|
+
let ni = 0
|
|
606
|
+
let ci = start
|
|
607
|
+
let starNi = -1
|
|
608
|
+
let starCi = 0
|
|
609
|
+
while (ci < end) {
|
|
610
|
+
const n = nodes[ni]
|
|
611
|
+
if (n?.t === 'star') {
|
|
612
|
+
starNi = ni++
|
|
613
|
+
starCi = ci
|
|
614
|
+
continue
|
|
615
|
+
}
|
|
616
|
+
const c = chars[ci]!
|
|
617
|
+
if (
|
|
618
|
+
n &&
|
|
619
|
+
(n.t === 'any' ||
|
|
620
|
+
(n.t === 'lit' && litMatch(n, c)) ||
|
|
621
|
+
(n.t === 'class' && n.re.test(c)))
|
|
622
|
+
) {
|
|
623
|
+
ni++
|
|
624
|
+
ci++
|
|
625
|
+
continue
|
|
626
|
+
}
|
|
627
|
+
if (starNi === -1) return false
|
|
628
|
+
ni = starNi + 1
|
|
629
|
+
ci = ++starCi
|
|
630
|
+
}
|
|
631
|
+
while (nodes[ni]?.t === 'star') ni++
|
|
632
|
+
return ni === nodes.length
|
|
633
|
+
}
|
|
634
|
+
|
|
635
|
+
// The least and most chars that the items can match. These are only
|
|
636
|
+
// bounds: a negation can match a string of any length, so it counts
|
|
637
|
+
// as 0 to Infinity.
|
|
638
|
+
const lengths = (items: Item[]): [min: number, max: number] => {
|
|
639
|
+
let min = 0
|
|
640
|
+
let max = 0
|
|
641
|
+
for (const it of items) {
|
|
642
|
+
const [lo, hi] = itemLengths(it)
|
|
643
|
+
min += lo
|
|
644
|
+
max += hi
|
|
645
|
+
}
|
|
646
|
+
return [min, max]
|
|
647
|
+
}
|
|
648
|
+
|
|
649
|
+
const itemLengths = (it: Item): [min: number, max: number] => {
|
|
650
|
+
if (it.t === 'star') return [0, Infinity]
|
|
651
|
+
if (it.t !== 'ext') return [1, 1]
|
|
652
|
+
if (it.type === '!') return [0, Infinity]
|
|
653
|
+
const alts = it.alts.map(lengths)
|
|
654
|
+
const min = Math.min(...alts.map(a => a[0]))
|
|
655
|
+
const max = Math.max(...alts.map(a => a[1]))
|
|
656
|
+
// a loop of alternatives that only match the empty string is empty
|
|
657
|
+
const loop = max === 0 ? 0 : Infinity
|
|
658
|
+
return (
|
|
659
|
+
it.type === '@' ? [min, max]
|
|
660
|
+
: it.type === '?' ? [0, max]
|
|
661
|
+
: it.type === '*' ? [0, loop]
|
|
662
|
+
: [min, loop]
|
|
663
|
+
)
|
|
664
|
+
}
|
|
665
|
+
|
|
666
|
+
// true if the chars from `start` match the literals
|
|
667
|
+
const hasAffix = (
|
|
668
|
+
lits: Lit[],
|
|
669
|
+
chars: ArrayLike<string>,
|
|
670
|
+
start: number,
|
|
671
|
+
) => {
|
|
672
|
+
for (let j = 0; j < lits.length; j++) {
|
|
673
|
+
if (!litMatch(lits[j]!, chars[start + j]!)) return false
|
|
674
|
+
}
|
|
675
|
+
return true
|
|
676
|
+
}
|
|
677
|
+
|
|
678
|
+
// a `/`, or half of a surrogate pair
|
|
679
|
+
const slashOrSurrogate = /[/\ud800-\udfff]/
|
|
680
|
+
const surrogate = /[\ud800-\udfff]/
|
|
681
|
+
|
|
682
|
+
// a string can be indexed by code point, unless it has surrogate
|
|
683
|
+
// pairs
|
|
684
|
+
const codePoints = (s: string): ArrayLike<string> =>
|
|
685
|
+
surrogate.test(s) ? [...s] : s
|
|
686
|
+
|
|
687
|
+
const noSlash = (s: string) => {
|
|
688
|
+
if (s.includes('/')) {
|
|
689
|
+
throw new Error('can only match a single path portion, got: ' + s)
|
|
690
|
+
}
|
|
691
|
+
}
|
|
692
|
+
|
|
693
|
+
export class Matcher {
|
|
694
|
+
pattern: string
|
|
695
|
+
options: MatcherOptions
|
|
696
|
+
#start: Node
|
|
697
|
+
// the number of node ids
|
|
698
|
+
#size: number
|
|
699
|
+
#marks?: Marks
|
|
700
|
+
// the Sim for strings that are only `.` or `..`
|
|
701
|
+
#dotsSim?: Sim
|
|
702
|
+
// the string to compare, if the pattern has no magic. With
|
|
703
|
+
// `nocase:true`, the RegExp that folds case is made when it is
|
|
704
|
+
// first used.
|
|
705
|
+
#literal?: string
|
|
706
|
+
#literalFold = false
|
|
707
|
+
#literalRe?: RegExp
|
|
708
|
+
// the nodes between the prefix and suffix, if the graph is a
|
|
709
|
+
// single chain
|
|
710
|
+
#linear?: LinearNode[]
|
|
711
|
+
// the linear nodes are only `*` and `?`, so the length bounds and
|
|
712
|
+
// the prefix and suffix decide the match
|
|
713
|
+
#wild = false
|
|
714
|
+
// the least and most chars that a match can have
|
|
715
|
+
#min = 0
|
|
716
|
+
#max = Infinity
|
|
717
|
+
// the literals that a match must start and end with. Each one
|
|
718
|
+
// matches exactly one char, and they are distinct items in the
|
|
719
|
+
// pattern, so a string that does not have them can not match.
|
|
720
|
+
#prefix: Lit[] = []
|
|
721
|
+
#suffix: Lit[] = []
|
|
722
|
+
// the prefix and suffix as strings, if they do not fold case
|
|
723
|
+
#prefixStr?: string
|
|
724
|
+
#suffixStr?: string
|
|
725
|
+
// there is a prefix or suffix to check
|
|
726
|
+
#affix = false
|
|
727
|
+
#dfa?: Dfa
|
|
728
|
+
#form?: Form
|
|
729
|
+
|
|
730
|
+
constructor(pattern: string, options: MatcherOptions = {}) {
|
|
731
|
+
if (pattern.includes('/')) {
|
|
732
|
+
throw new Error(
|
|
733
|
+
'can only match a single path portion, got pattern: ' + pattern,
|
|
734
|
+
)
|
|
735
|
+
}
|
|
736
|
+
this.pattern = pattern
|
|
737
|
+
this.options = options
|
|
738
|
+
const { nocase = false, noext = false, normalize: n } = options
|
|
739
|
+
this.#form = n === true ? 'NFC' : n || undefined
|
|
740
|
+
// a pattern that is only an empty extglob is a literal string,
|
|
741
|
+
// except for `!()`, which matches any non-empty string
|
|
742
|
+
const literal = /^[?*+@]\(\)$/.test(pattern)
|
|
743
|
+
const toks = tokenize(pattern, nocase, noext || literal, this.#form)
|
|
744
|
+
let [items] = build(toks, pair(toks), 0, toks.length, true)
|
|
745
|
+
if (this.#form) items = normalize(items!, this.#form)
|
|
746
|
+
const [start, size] = compile(items!, nocase)
|
|
747
|
+
this.#start = start
|
|
748
|
+
this.#size = size
|
|
749
|
+
if (items!.every(it => it.t === 'lit')) {
|
|
750
|
+
this.#literal = items!.map(it => it.ch).join('')
|
|
751
|
+
this.#literalFold = nocase
|
|
752
|
+
} else {
|
|
753
|
+
const lit = (it: Item): Lit | undefined =>
|
|
754
|
+
it.t !== 'lit' ? undefined
|
|
755
|
+
: nocase ? { ch: it.ch, re: foldRe(it.ch) }
|
|
756
|
+
: { ch: it.ch }
|
|
757
|
+
for (const it of items!) {
|
|
758
|
+
const l = lit(it)
|
|
759
|
+
if (!l) break
|
|
760
|
+
this.#prefix.push(l)
|
|
761
|
+
}
|
|
762
|
+
for (let j = items!.length - 1; j >= 0; j--) {
|
|
763
|
+
const l = lit(items![j]!)
|
|
764
|
+
if (!l) break
|
|
765
|
+
this.#suffix.unshift(l)
|
|
766
|
+
}
|
|
767
|
+
this.#affix = !!(this.#prefix.length || this.#suffix.length)
|
|
768
|
+
if (!nocase) {
|
|
769
|
+
this.#prefixStr = this.#prefix.map(l => l.ch).join('')
|
|
770
|
+
this.#suffixStr = this.#suffix.map(l => l.ch).join('')
|
|
771
|
+
}
|
|
772
|
+
this.#linear = linear(this.#start)?.slice(
|
|
773
|
+
this.#prefix.length,
|
|
774
|
+
-this.#suffix.length || undefined,
|
|
775
|
+
)
|
|
776
|
+
this.#wild = !!this.#linear?.every(
|
|
777
|
+
n => n.t === 'star' || n.t === 'any',
|
|
778
|
+
)
|
|
779
|
+
const [min, max] = lengths(items!)
|
|
780
|
+
this.#min = min
|
|
781
|
+
this.#max = max
|
|
782
|
+
}
|
|
783
|
+
}
|
|
784
|
+
|
|
785
|
+
test(s: string): boolean {
|
|
786
|
+
// The `/` check uses the string as given, so with normalization it
|
|
787
|
+
// is a separate step. Otherwise, one scan finds both a `/` and the
|
|
788
|
+
// surrogate pairs that stop the string being indexed by code point.
|
|
789
|
+
if (this.#form) {
|
|
790
|
+
noSlash(s)
|
|
791
|
+
return this.#test(s.normalize(this.#form))
|
|
792
|
+
}
|
|
793
|
+
if (slashOrSurrogate.test(s)) {
|
|
794
|
+
noSlash(s)
|
|
795
|
+
return this.#test(s, [...s])
|
|
796
|
+
}
|
|
797
|
+
return this.#test(s, s)
|
|
798
|
+
}
|
|
799
|
+
|
|
800
|
+
/**
|
|
801
|
+
* The same as {@link Matcher#test}, but the string is not checked
|
|
802
|
+
* for `/` chars, so the result for a string that has one is not
|
|
803
|
+
* defined. Only use it for a string that is known to be one path
|
|
804
|
+
* portion, such as a part of a path that was split on `/`. It can
|
|
805
|
+
* be faster, because some patterns do not need to look at each char
|
|
806
|
+
* of the string.
|
|
807
|
+
*/
|
|
808
|
+
testUnchecked(s: string): boolean {
|
|
809
|
+
return this.#test(this.#form ? s.normalize(this.#form) : s)
|
|
810
|
+
}
|
|
811
|
+
|
|
812
|
+
// Test a string that has no `/`. `chars` indexes it by code point.
|
|
813
|
+
// If it is not given, it is only found if a step needs it.
|
|
814
|
+
#test(s: string, chars?: ArrayLike<string>): boolean {
|
|
815
|
+
if (this.#literal !== undefined) {
|
|
816
|
+
return this.#literalFold ?
|
|
817
|
+
(this.#literalRe ??= newFoldRe(this.#literal)).test(s)
|
|
818
|
+
: s === this.#literal
|
|
819
|
+
}
|
|
820
|
+
// the length check means that the prefix and suffix do not
|
|
821
|
+
// overlap. Without the chars, the length in code points is from
|
|
822
|
+
// half of the UTF-16 length (if each one is a surrogate pair) to
|
|
823
|
+
// all of it, which is often enough to know.
|
|
824
|
+
const min = this.#min
|
|
825
|
+
const max = this.#max
|
|
826
|
+
if (chars === undefined) {
|
|
827
|
+
const most = s.length
|
|
828
|
+
const least = (most + 1) >> 1
|
|
829
|
+
if (most < min || least > max) return false
|
|
830
|
+
if (least < min || most > max) chars = codePoints(s)
|
|
831
|
+
}
|
|
832
|
+
if (
|
|
833
|
+
chars !== undefined &&
|
|
834
|
+
(chars.length < min || chars.length > max)
|
|
835
|
+
) {
|
|
836
|
+
return false
|
|
837
|
+
}
|
|
838
|
+
const prefix = this.#prefix.length
|
|
839
|
+
if (this.#affix) {
|
|
840
|
+
if (this.#prefixStr !== undefined && this.#suffixStr !== undefined) {
|
|
841
|
+
if (
|
|
842
|
+
!s.startsWith(this.#prefixStr) ||
|
|
843
|
+
!s.endsWith(this.#suffixStr)
|
|
844
|
+
) {
|
|
845
|
+
return false
|
|
846
|
+
}
|
|
847
|
+
} else {
|
|
848
|
+
chars ??= codePoints(s)
|
|
849
|
+
const end = chars.length - this.#suffix.length
|
|
850
|
+
if (
|
|
851
|
+
!hasAffix(this.#prefix, chars, 0) ||
|
|
852
|
+
!hasAffix(this.#suffix, chars, end)
|
|
853
|
+
) {
|
|
854
|
+
return false
|
|
855
|
+
}
|
|
856
|
+
}
|
|
857
|
+
}
|
|
858
|
+
const dotStart = !this.options.dot && s.startsWith('.')
|
|
859
|
+
if (this.#linear) {
|
|
860
|
+
// `.` and `..` only match literal dots, even with `dot:true`
|
|
861
|
+
if (s === '.' || s === '..') return false
|
|
862
|
+
// only a literal can match the leading dot. A `*` can not
|
|
863
|
+
// start a dotfile, even if it matches nothing.
|
|
864
|
+
if (dotStart && !prefix) return false
|
|
865
|
+
if (this.#wild) return true
|
|
866
|
+
chars ??= codePoints(s)
|
|
867
|
+
const end = chars.length - this.#suffix.length
|
|
868
|
+
return testLinear(this.#linear, chars, prefix, end)
|
|
869
|
+
}
|
|
870
|
+
chars ??= codePoints(s)
|
|
871
|
+
if (s === '.' || s === '..') {
|
|
872
|
+
this.#marks ??= marks(this.#size)
|
|
873
|
+
const sim = (this.#dotsSim ??= new Sim(true, false, this.#marks))
|
|
874
|
+
const start = sim.state()
|
|
875
|
+
sim.add(start, this.#start, 0, true)
|
|
876
|
+
let state = sim.done(start)
|
|
877
|
+
for (let i = 0; i < chars.length; i++) {
|
|
878
|
+
state = sim.step(state, chars[i]!, i, true)
|
|
879
|
+
}
|
|
880
|
+
return state.match
|
|
881
|
+
}
|
|
882
|
+
this.#marks ??= marks(this.#size)
|
|
883
|
+
const dfa = (this.#dfa ??= new Dfa(this.#start, this.#marks))
|
|
884
|
+
let d = dfa.start(dotStart)
|
|
885
|
+
// read char codes from the string, so that a one-char string is
|
|
886
|
+
// only made for a cache miss
|
|
887
|
+
const str = chars === s
|
|
888
|
+
for (let i = 0; i < chars.length; i++) {
|
|
889
|
+
if (d.dead) return false
|
|
890
|
+
const code = str ? s.charCodeAt(i) : chars[i]!.charCodeAt(0)
|
|
891
|
+
d = d.ascii?.[code] ?? dfa.next(d, chars[i]!)
|
|
892
|
+
}
|
|
893
|
+
return d.match
|
|
894
|
+
}
|
|
895
|
+
|
|
896
|
+
/** a readable listing of the state machine */
|
|
897
|
+
toString(): string {
|
|
898
|
+
return show(this.#start)
|
|
899
|
+
}
|
|
900
|
+
}
|