@genai-fi/nanogpt 0.20.0 → 0.20.1
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/BaseTokeniser-DSg9zcYq.js +221 -0
- package/dist/DatasetBuilder-DgURD85T.js +712 -0
- package/dist/Generator.d.ts +82 -0
- package/dist/Generator.js +2 -0
- package/dist/RealDiv-DBu0FQqT.js +362 -0
- package/dist/Reshape-CABOPB9d.js +94 -0
- package/dist/Reshape-DqO3r8BC.js +17 -0
- package/dist/TeachableLLM.d.ts +70 -0
- package/dist/TeachableLLM.js +2 -0
- package/dist/Trainer.d.ts +43 -0
- package/dist/Trainer.js +2 -0
- package/dist/backend.d.ts +2 -0
- package/dist/backend.js +13 -0
- package/dist/backend_util-Cg-roD1p.js +399 -0
- package/dist/binary_op_util-CrYk9LXL.js +103 -0
- package/dist/checks/appendCache.d.ts +1 -0
- package/dist/checks/appendCache.js +55 -0
- package/dist/checks/attentionMask.d.ts +1 -0
- package/dist/checks/attentionMask.js +56 -0
- package/dist/checks/check.d.ts +9 -0
- package/dist/checks/check.js +32 -0
- package/dist/checks/gelu.d.ts +1 -0
- package/dist/checks/gelu.js +46 -0
- package/dist/checks/index.d.ts +26 -0
- package/dist/checks/index.js +28 -0
- package/dist/checks/matMulGelu.d.ts +1 -0
- package/dist/checks/matMulGelu.js +84 -0
- package/dist/checks/normRMS.d.ts +1 -0
- package/dist/checks/normRMS.js +28 -0
- package/dist/checks/normRMSGrad.d.ts +1 -0
- package/dist/checks/normRMSGrad.js +22 -0
- package/dist/checks/packUnpack.d.ts +1 -0
- package/dist/checks/packUnpack.js +46 -0
- package/dist/checks/qkv.d.ts +1 -0
- package/dist/checks/qkv.js +34 -0
- package/dist/checks/rope.d.ts +1 -0
- package/dist/checks/rope.js +30 -0
- package/dist/checks/weights.d.ts +14 -0
- package/dist/checks/weights.js +27 -0
- package/dist/chunk-BPntVaq0.js +23 -0
- package/dist/complex_util-CkazZsaH.js +60 -0
- package/dist/concat_util-CWDZCBlA.js +19 -0
- package/dist/data/docx.d.ts +2 -0
- package/dist/data/docx.js +3046 -0
- package/dist/data/pdf.d.ts +2 -0
- package/dist/data/pdf.js +17 -0
- package/dist/data/textLoader.d.ts +7 -0
- package/dist/data/textLoader.js +613 -0
- package/dist/dist-BewPQWjc.js +7572 -0
- package/dist/dist-DVmq73nz.js +8775 -0
- package/dist/dist-DXwIvKxl.js +896 -0
- package/dist/dist-VEU5mfO0.js +7545 -0
- package/dist/gelu-Bf1HW1RY.js +27 -0
- package/dist/gpgpu_math-DvLcCH6u.js +1612 -0
- package/dist/inference/types.d.ts +16 -0
- package/dist/inference/types.js +0 -0
- package/dist/kernel_funcs_utils-HiXOOx3f.js +229 -0
- package/dist/layers/BaseLayer.d.ts +44 -0
- package/dist/layers/BaseLayer.js +76 -0
- package/dist/layers/CausalSelfAttention.d.ts +39 -0
- package/dist/layers/CausalSelfAttention.js +99 -0
- package/dist/layers/LoRA.d.ts +14 -0
- package/dist/layers/LoRA.js +48 -0
- package/dist/layers/MLP.d.ts +17 -0
- package/dist/layers/MLP.js +34 -0
- package/dist/layers/PositionEmbedding.d.ts +8 -0
- package/dist/layers/PositionEmbedding.js +27 -0
- package/dist/layers/RMSNorm.d.ts +12 -0
- package/dist/layers/RMSNorm.js +20 -0
- package/dist/layers/RoPECache.d.ts +18 -0
- package/dist/layers/RoPECache.js +337 -0
- package/dist/layers/TiedEmbedding.d.ts +13 -0
- package/dist/layers/TiedEmbedding.js +32 -0
- package/dist/layers/TransformerBlock.d.ts +27 -0
- package/dist/layers/TransformerBlock.js +51 -0
- package/dist/layers/WeightStore.d.ts +20 -0
- package/dist/layers/WeightStore.js +69 -0
- package/dist/loader/load.d.ts +6 -0
- package/dist/loader/load.js +2 -0
- package/dist/loader/loadHF.d.ts +8 -0
- package/dist/loader/loadHF.js +2 -0
- package/dist/loader/loadTransformers.d.ts +4 -0
- package/dist/loader/loadTransformers.js +2 -0
- package/dist/loader/loadZipMeta.d.ts +3 -0
- package/dist/loader/loadZipMeta.js +16 -0
- package/dist/loader/newZipLoad.d.ts +3 -0
- package/dist/loader/newZipLoad.js +2 -0
- package/dist/loader/oldZipLoad.d.ts +9 -0
- package/dist/loader/oldZipLoad.js +2 -0
- package/dist/loader/save.d.ts +16 -0
- package/dist/loader/save.js +2 -0
- package/dist/loader/types.d.ts +68 -0
- package/dist/loader/types.js +0 -0
- package/dist/main-CPjeMv0G.js +13500 -0
- package/dist/main.d.ts +50 -0
- package/dist/main.js +16 -0
- package/dist/matMul16-BNfZSnNM.js +81 -0
- package/dist/matMulGelu-CPTntosE.js +162 -0
- package/dist/models/NanoGPTV1.d.ts +16 -0
- package/dist/models/NanoGPTV1.js +2 -0
- package/dist/models/NanoGPTV2.d.ts +16 -0
- package/dist/models/NanoGPTV2.js +2 -0
- package/dist/models/config.d.ts +27 -0
- package/dist/models/config.js +37 -0
- package/dist/models/factory.d.ts +3 -0
- package/dist/models/factory.js +2 -0
- package/dist/models/model.d.ts +44 -0
- package/dist/models/model.js +2 -0
- package/dist/ops/adamAdjust.d.ts +2 -0
- package/dist/ops/adamAdjust.js +18 -0
- package/dist/ops/adamMoments.d.ts +2 -0
- package/dist/ops/adamMoments.js +16 -0
- package/dist/ops/add16.d.ts +2 -0
- package/dist/ops/add16.js +12 -0
- package/dist/ops/appendCache.d.ts +2 -0
- package/dist/ops/appendCache.js +25 -0
- package/dist/ops/attentionMask.d.ts +2 -0
- package/dist/ops/attentionMask.js +16 -0
- package/dist/ops/concat16.d.ts +2 -0
- package/dist/ops/concat16.js +8 -0
- package/dist/ops/cpu/adamAdjust.d.ts +1 -0
- package/dist/ops/cpu/adamAdjust.js +16 -0
- package/dist/ops/cpu/adamMoments.d.ts +1 -0
- package/dist/ops/cpu/adamMoments.js +16 -0
- package/dist/ops/cpu/appendCache.d.ts +1 -0
- package/dist/ops/cpu/appendCache.js +65 -0
- package/dist/ops/cpu/attentionMask.d.ts +1 -0
- package/dist/ops/cpu/attentionMask.js +16 -0
- package/dist/ops/cpu/fusedSoftmax.d.ts +9 -0
- package/dist/ops/cpu/fusedSoftmax.js +22 -0
- package/dist/ops/cpu/gatherSub.d.ts +1 -0
- package/dist/ops/cpu/gatherSub.js +12 -0
- package/dist/ops/cpu/gelu.d.ts +1 -0
- package/dist/ops/cpu/gelu.js +36 -0
- package/dist/ops/cpu/matMul16.d.ts +1 -0
- package/dist/ops/cpu/matMul16.js +14 -0
- package/dist/ops/cpu/matMulGelu.d.ts +1 -0
- package/dist/ops/cpu/matMulGelu.js +41 -0
- package/dist/ops/cpu/matMulMul.d.ts +1 -0
- package/dist/ops/cpu/matMulMul.js +20 -0
- package/dist/ops/cpu/mulDropout.d.ts +1 -0
- package/dist/ops/cpu/mulDropout.js +20 -0
- package/dist/ops/cpu/normRMS.d.ts +1 -0
- package/dist/ops/cpu/normRMS.js +35 -0
- package/dist/ops/cpu/qkv.d.ts +5 -0
- package/dist/ops/cpu/qkv.js +73 -0
- package/dist/ops/cpu/rope.d.ts +6 -0
- package/dist/ops/cpu/rope.js +81 -0
- package/dist/ops/cpu/scatterSub.d.ts +1 -0
- package/dist/ops/cpu/scatterSub.js +12 -0
- package/dist/ops/dot16.d.ts +2 -0
- package/dist/ops/dot16.js +29 -0
- package/dist/ops/dropout.d.ts +2 -0
- package/dist/ops/dropout.js +11 -0
- package/dist/ops/dropout16.d.ts +2 -0
- package/dist/ops/dropout16.js +22 -0
- package/dist/ops/gatherSub.d.ts +2 -0
- package/dist/ops/gatherSub.js +13 -0
- package/dist/ops/gelu.d.ts +3 -0
- package/dist/ops/gelu.js +2 -0
- package/dist/ops/globalNorm.d.ts +2 -0
- package/dist/ops/globalNorm.js +19 -0
- package/dist/ops/grads/add16.d.ts +1 -0
- package/dist/ops/grads/add16.js +27 -0
- package/dist/ops/grads/attentionMask.d.ts +1 -0
- package/dist/ops/grads/attentionMask.js +26 -0
- package/dist/ops/grads/dropout16.d.ts +1 -0
- package/dist/ops/grads/dropout16.js +1 -0
- package/dist/ops/grads/gelu.d.ts +2 -0
- package/dist/ops/grads/gelu.js +2 -0
- package/dist/ops/grads/matMul16.d.ts +2 -0
- package/dist/ops/grads/matMul16.js +2 -0
- package/dist/ops/grads/matMulGelu.d.ts +1 -0
- package/dist/ops/grads/matMulGelu.js +22 -0
- package/dist/ops/grads/mul16.d.ts +1 -0
- package/dist/ops/grads/mul16.js +1 -0
- package/dist/ops/grads/normRMS.d.ts +3 -0
- package/dist/ops/grads/normRMS.js +37 -0
- package/dist/ops/grads/pack16.d.ts +2 -0
- package/dist/ops/grads/pack16.js +2 -0
- package/dist/ops/grads/qkv.d.ts +3 -0
- package/dist/ops/grads/qkv.js +46 -0
- package/dist/ops/grads/rope.d.ts +2 -0
- package/dist/ops/grads/rope.js +2 -0
- package/dist/ops/grads/softmax16.d.ts +2 -0
- package/dist/ops/grads/softmax16.js +23 -0
- package/dist/ops/grads/unpack16.d.ts +2 -0
- package/dist/ops/grads/unpack16.js +2 -0
- package/dist/ops/grads/utils.d.ts +4 -0
- package/dist/ops/grads/utils.js +12 -0
- package/dist/ops/log.d.ts +0 -0
- package/dist/ops/log.js +1 -0
- package/dist/ops/matMul16.d.ts +15 -0
- package/dist/ops/matMul16.js +2 -0
- package/dist/ops/matMulGelu.d.ts +3 -0
- package/dist/ops/matMulGelu.js +20 -0
- package/dist/ops/matMulMul.d.ts +2 -0
- package/dist/ops/matMulMul.js +16 -0
- package/dist/ops/mul16.d.ts +2 -0
- package/dist/ops/mul16.js +43 -0
- package/dist/ops/mulDrop.d.ts +2 -0
- package/dist/ops/mulDrop.js +15 -0
- package/dist/ops/normRMS.d.ts +2 -0
- package/dist/ops/normRMS.js +22 -0
- package/dist/ops/pack16.d.ts +2 -0
- package/dist/ops/pack16.js +2 -0
- package/dist/ops/qkv.d.ts +2 -0
- package/dist/ops/qkv.js +16 -0
- package/dist/ops/reshape16.d.ts +2 -0
- package/dist/ops/reshape16.js +33 -0
- package/dist/ops/rope.d.ts +3 -0
- package/dist/ops/rope.js +2 -0
- package/dist/ops/scatterSub.d.ts +2 -0
- package/dist/ops/scatterSub.js +13 -0
- package/dist/ops/slice16.d.ts +2 -0
- package/dist/ops/slice16.js +11 -0
- package/dist/ops/softmax16.d.ts +2 -0
- package/dist/ops/softmax16.js +9 -0
- package/dist/ops/sub16.d.ts +2 -0
- package/dist/ops/sub16.js +11 -0
- package/dist/ops/sum16.d.ts +2 -0
- package/dist/ops/sum16.js +13 -0
- package/dist/ops/transpose16.d.ts +3 -0
- package/dist/ops/transpose16.js +32 -0
- package/dist/ops/unpack16.d.ts +2 -0
- package/dist/ops/unpack16.js +2 -0
- package/dist/ops/webgl/adamAdjust.d.ts +1 -0
- package/dist/ops/webgl/adamAdjust.js +82 -0
- package/dist/ops/webgl/adamMoments.d.ts +1 -0
- package/dist/ops/webgl/adamMoments.js +44 -0
- package/dist/ops/webgl/appendCache.d.ts +1 -0
- package/dist/ops/webgl/appendCache.js +53 -0
- package/dist/ops/webgl/attentionMask.d.ts +1 -0
- package/dist/ops/webgl/attentionMask.js +64 -0
- package/dist/ops/webgl/dropout16.d.ts +1 -0
- package/dist/ops/webgl/dropout16.js +12 -0
- package/dist/ops/webgl/fusedSoftmax.d.ts +11 -0
- package/dist/ops/webgl/fusedSoftmax.js +70 -0
- package/dist/ops/webgl/gatherSub.d.ts +1 -0
- package/dist/ops/webgl/gatherSub.js +28 -0
- package/dist/ops/webgl/gelu.d.ts +2 -0
- package/dist/ops/webgl/gelu.js +48 -0
- package/dist/ops/webgl/log.d.ts +17 -0
- package/dist/ops/webgl/log.js +14 -0
- package/dist/ops/webgl/matMul16.d.ts +1 -0
- package/dist/ops/webgl/matMul16.js +37 -0
- package/dist/ops/webgl/matMulGelu.d.ts +21 -0
- package/dist/ops/webgl/matMulGelu.js +2 -0
- package/dist/ops/webgl/matMulMul.d.ts +14 -0
- package/dist/ops/webgl/matMulMul.js +24 -0
- package/dist/ops/webgl/mulDropout.d.ts +1 -0
- package/dist/ops/webgl/mulDropout.js +32 -0
- package/dist/ops/webgl/normRMS.d.ts +1 -0
- package/dist/ops/webgl/normRMS.js +114 -0
- package/dist/ops/webgl/qkv.d.ts +1 -0
- package/dist/ops/webgl/qkv.js +54 -0
- package/dist/ops/webgl/rope.d.ts +1 -0
- package/dist/ops/webgl/rope.js +72 -0
- package/dist/ops/webgl/scatterSub.d.ts +1 -0
- package/dist/ops/webgl/scatterSub.js +28 -0
- package/dist/ops/webgpu/adamAdjust.d.ts +1 -0
- package/dist/ops/webgpu/adamAdjust.js +77 -0
- package/dist/ops/webgpu/adamMoments.d.ts +1 -0
- package/dist/ops/webgpu/adamMoments.js +76 -0
- package/dist/ops/webgpu/add16.d.ts +1 -0
- package/dist/ops/webgpu/add16.js +14 -0
- package/dist/ops/webgpu/appendCache.d.ts +1 -0
- package/dist/ops/webgpu/appendCache.js +130 -0
- package/dist/ops/webgpu/attentionMask.d.ts +1 -0
- package/dist/ops/webgpu/attentionMask.js +42 -0
- package/dist/ops/webgpu/attentionMask32_program.d.ts +19 -0
- package/dist/ops/webgpu/attentionMask32_program.js +62 -0
- package/dist/ops/webgpu/clipScale.d.ts +1 -0
- package/dist/ops/webgpu/clipScale.js +45 -0
- package/dist/ops/webgpu/concat16.d.ts +19 -0
- package/dist/ops/webgpu/concat16.js +111 -0
- package/dist/ops/webgpu/dropout16.d.ts +1 -0
- package/dist/ops/webgpu/dropout16.js +59 -0
- package/dist/ops/webgpu/gatherSub.d.ts +1 -0
- package/dist/ops/webgpu/gatherSub.js +52 -0
- package/dist/ops/webgpu/gelu.d.ts +14 -0
- package/dist/ops/webgpu/gelu.js +147 -0
- package/dist/ops/webgpu/index.d.ts +0 -0
- package/dist/ops/webgpu/index.js +26 -0
- package/dist/ops/webgpu/matMul16.d.ts +1 -0
- package/dist/ops/webgpu/matMul16.js +70 -0
- package/dist/ops/webgpu/matMul16_program.d.ts +42 -0
- package/dist/ops/webgpu/matMul16_program.js +303 -0
- package/dist/ops/webgpu/mul16.d.ts +1 -0
- package/dist/ops/webgpu/mul16.js +14 -0
- package/dist/ops/webgpu/norm2.d.ts +1 -0
- package/dist/ops/webgpu/norm2.js +46 -0
- package/dist/ops/webgpu/normRMS.d.ts +1 -0
- package/dist/ops/webgpu/normRMS.js +26 -0
- package/dist/ops/webgpu/normRMS16_program.d.ts +10 -0
- package/dist/ops/webgpu/normRMS16_program.js +28 -0
- package/dist/ops/webgpu/normRMS32_program.d.ts +10 -0
- package/dist/ops/webgpu/normRMS32_program.js +28 -0
- package/dist/ops/webgpu/normRMSGrad.d.ts +1 -0
- package/dist/ops/webgpu/normRMSGrad.js +225 -0
- package/dist/ops/webgpu/pack16.d.ts +1 -0
- package/dist/ops/webgpu/pack16.js +21 -0
- package/dist/ops/webgpu/pack16_program.d.ts +19 -0
- package/dist/ops/webgpu/pack16_program.js +93 -0
- package/dist/ops/webgpu/qkv.d.ts +1 -0
- package/dist/ops/webgpu/qkv.js +64 -0
- package/dist/ops/webgpu/rope.d.ts +1 -0
- package/dist/ops/webgpu/rope.js +163 -0
- package/dist/ops/webgpu/scatterSub.d.ts +1 -0
- package/dist/ops/webgpu/scatterSub.js +53 -0
- package/dist/ops/webgpu/slice16.d.ts +7 -0
- package/dist/ops/webgpu/slice16.js +74 -0
- package/dist/ops/webgpu/softmax16.d.ts +17 -0
- package/dist/ops/webgpu/softmax16.js +18 -0
- package/dist/ops/webgpu/softmax16_program.d.ts +13 -0
- package/dist/ops/webgpu/softmax16_program.js +89 -0
- package/dist/ops/webgpu/softmax16_subgroup_program.d.ts +17 -0
- package/dist/ops/webgpu/softmax16_subgroup_program.js +70 -0
- package/dist/ops/webgpu/softmax16grad.d.ts +1 -0
- package/dist/ops/webgpu/softmax16grad.js +31 -0
- package/dist/ops/webgpu/sub16.d.ts +1 -0
- package/dist/ops/webgpu/sub16.js +14 -0
- package/dist/ops/webgpu/sum16.d.ts +1 -0
- package/dist/ops/webgpu/sum16.js +29 -0
- package/dist/ops/webgpu/transpose16.d.ts +1 -0
- package/dist/ops/webgpu/transpose16.js +37 -0
- package/dist/ops/webgpu/transpose16_program.d.ts +16 -0
- package/dist/ops/webgpu/transpose16_program.js +51 -0
- package/dist/ops/webgpu/transpose16_shared_program.d.ts +15 -0
- package/dist/ops/webgpu/transpose16_shared_program.js +79 -0
- package/dist/ops/webgpu/unpack16.d.ts +1 -0
- package/dist/ops/webgpu/unpack16.js +60 -0
- package/dist/ops/webgpu/utils/binary_op.d.ts +35 -0
- package/dist/ops/webgpu/utils/binary_op.js +141 -0
- package/dist/ops/webgpu/utils/deviceInfo.d.ts +7 -0
- package/dist/ops/webgpu/utils/deviceInfo.js +11 -0
- package/dist/ops/webgpu/utils/reductions.d.ts +43 -0
- package/dist/ops/webgpu/utils/reductions.js +263 -0
- package/dist/pack16-Ck-spx_F.js +39 -0
- package/dist/patches/webgpu_backend.d.ts +18 -0
- package/dist/patches/webgpu_backend.js +43 -0
- package/dist/patches/webgpu_base.d.ts +21 -0
- package/dist/patches/webgpu_base.js +22 -0
- package/dist/patches/webgpu_program.d.ts +36 -0
- package/dist/patches/webgpu_program.js +293 -0
- package/dist/pdf-UoDqCYzz.js +16726 -0
- package/dist/picomatch-3tUnMMbd.js +1063 -0
- package/dist/rope-CbeGlsV8.js +25 -0
- package/dist/selu_util-zkAx5doH.js +24 -0
- package/dist/shared-D1coEFea.js +1314 -0
- package/dist/shared-DOgWaqvL.js +5 -0
- package/dist/slice_util-Dgb3ANWI.js +208 -0
- package/dist/tfjs_backend-BjuQ5FqB.js +614 -0
- package/dist/tokeniser/BaseTokeniser.d.ts +33 -0
- package/dist/tokeniser/BaseTokeniser.js +2 -0
- package/dist/tokeniser/CharTokeniser.d.ts +24 -0
- package/dist/tokeniser/CharTokeniser.js +92 -0
- package/dist/tokeniser/bpe.d.ts +28 -0
- package/dist/tokeniser/bpe.js +170 -0
- package/dist/tokeniser/messages.d.ts +61 -0
- package/dist/tokeniser/messages.js +0 -0
- package/dist/tokeniser/type.d.ts +34 -0
- package/dist/tokeniser/type.js +0 -0
- package/dist/training/AdamW.d.ts +36 -0
- package/dist/training/AdamW.js +128 -0
- package/dist/training/BasicTrainer.d.ts +63 -0
- package/dist/training/BasicTrainer.js +265 -0
- package/dist/training/DatasetBuilder.d.ts +26 -0
- package/dist/training/DatasetBuilder.js +2 -0
- package/dist/training/Evaluator.d.ts +19 -0
- package/dist/training/Evaluator.js +48 -0
- package/dist/training/LRScheduler.d.ts +12 -0
- package/dist/training/LRScheduler.js +38 -0
- package/dist/training/PreTrainer.d.ts +11 -0
- package/dist/training/PreTrainer.js +22 -0
- package/dist/training/SFTTrainer.d.ts +12 -0
- package/dist/training/SFTTrainer.js +24 -0
- package/dist/training/loss.d.ts +3 -0
- package/dist/training/loss.js +19 -0
- package/dist/training/orthoGrad.d.ts +2 -0
- package/dist/training/orthoGrad.js +10 -0
- package/dist/training/sparseCrossEntropy.d.ts +7 -0
- package/dist/training/sparseCrossEntropy.js +47 -0
- package/dist/training/tasks/ConversationTask.d.ts +18 -0
- package/dist/training/tasks/ConversationTask.js +38 -0
- package/dist/training/tasks/PretrainingTask.d.ts +17 -0
- package/dist/training/tasks/PretrainingTask.js +42 -0
- package/dist/training/tasks/StartSentenceTask.d.ts +18 -0
- package/dist/training/tasks/StartSentenceTask.js +45 -0
- package/dist/training/tasks/Task.d.ts +22 -0
- package/dist/training/tasks/Task.js +55 -0
- package/dist/training/tasks/splitter.d.ts +5 -0
- package/dist/training/tasks/splitter.js +18 -0
- package/dist/training/types.d.ts +78 -0
- package/dist/training/types.js +0 -0
- package/dist/training/validation.d.ts +17 -0
- package/dist/training/validation.js +2 -0
- package/dist/utilities/arrayClose.d.ts +1 -0
- package/dist/utilities/arrayClose.js +16 -0
- package/dist/utilities/datasetID.d.ts +2 -0
- package/dist/utilities/datasetID.js +18 -0
- package/dist/utilities/dummy.d.ts +9 -0
- package/dist/utilities/dummy.js +36 -0
- package/dist/utilities/multinomialCPU.d.ts +2 -0
- package/dist/utilities/multinomialCPU.js +9 -0
- package/dist/utilities/naming.d.ts +4 -0
- package/dist/utilities/naming.js +0 -0
- package/dist/utilities/packed.d.ts +4 -0
- package/dist/utilities/packed.js +13 -0
- package/dist/utilities/parameters.d.ts +11 -0
- package/dist/utilities/parameters.js +38 -0
- package/dist/utilities/performance.d.ts +2 -0
- package/dist/utilities/performance.js +16 -0
- package/dist/utilities/profile.d.ts +17 -0
- package/dist/utilities/profile.js +33 -0
- package/dist/utilities/safetensors.d.ts +3 -0
- package/dist/utilities/safetensors.js +53 -0
- package/dist/utilities/sentences.d.ts +5 -0
- package/dist/utilities/sentences.js +32 -0
- package/dist/utilities/tokenParse.d.ts +1 -0
- package/dist/utilities/tokenParse.js +17 -0
- package/dist/utilities/topP.d.ts +1 -0
- package/dist/utilities/topP.js +12 -0
- package/dist/utilities/waitForModel.d.ts +2 -0
- package/dist/utilities/waitForModel.js +12 -0
- package/dist/utilities/weights.d.ts +12 -0
- package/dist/utilities/weights.js +40 -0
- package/dist/utilities/yielder.d.ts +1 -0
- package/dist/utilities/yielder.js +7 -0
- package/dist/webgpu-Dt7BMzWz.js +525 -0
- package/dist/webgpu_program-WOyIVMlZ.js +392 -0
- package/dist/webgpu_util-B_F3SShA.js +106 -0
- package/package.json +1 -1
|
@@ -0,0 +1,1063 @@
|
|
|
1
|
+
import { t as e } from "./chunk-BPntVaq0.js";
|
|
2
|
+
import { i as t, r as n } from "./dist-DXwIvKxl.js";
|
|
3
|
+
//#region node_modules/picomatch/lib/constants.js
|
|
4
|
+
var r = /* @__PURE__ */ e(((e, t) => {
|
|
5
|
+
var n = "\\\\/", r = `[^${n}]`, i = 0, a = "\\.", o = "\\+", s = "\\?", c = "\\/", l = "(?=.)", u = "[^/]", d = `(?:${c}|$)`, f = `(?:^|${c})`, p = `${a}{1,2}${d}`, m = {
|
|
6
|
+
DOT_LITERAL: a,
|
|
7
|
+
PLUS_LITERAL: o,
|
|
8
|
+
QMARK_LITERAL: s,
|
|
9
|
+
SLASH_LITERAL: c,
|
|
10
|
+
ONE_CHAR: l,
|
|
11
|
+
QMARK: u,
|
|
12
|
+
END_ANCHOR: d,
|
|
13
|
+
DOTS_SLASH: p,
|
|
14
|
+
NO_DOT: `(?!${a})`,
|
|
15
|
+
NO_DOTS: `(?!${f}${p})`,
|
|
16
|
+
NO_DOT_SLASH: `(?!${a}{0,1}${d})`,
|
|
17
|
+
NO_DOTS_SLASH: `(?!${p})`,
|
|
18
|
+
QMARK_NO_DOT: `[^.${c}]`,
|
|
19
|
+
STAR: `${u}*?`,
|
|
20
|
+
START_ANCHOR: f,
|
|
21
|
+
SEP: "/"
|
|
22
|
+
}, h = {
|
|
23
|
+
...m,
|
|
24
|
+
SLASH_LITERAL: `[${n}]`,
|
|
25
|
+
QMARK: r,
|
|
26
|
+
STAR: `${r}*?`,
|
|
27
|
+
DOTS_SLASH: `${a}{1,2}(?:[${n}]|$)`,
|
|
28
|
+
NO_DOT: `(?!${a})`,
|
|
29
|
+
NO_DOTS: `(?!(?:^|[${n}])${a}{1,2}(?:[${n}]|$))`,
|
|
30
|
+
NO_DOT_SLASH: `(?!${a}{0,1}(?:[${n}]|$))`,
|
|
31
|
+
NO_DOTS_SLASH: `(?!${a}{1,2}(?:[${n}]|$))`,
|
|
32
|
+
QMARK_NO_DOT: `[^.${n}]`,
|
|
33
|
+
START_ANCHOR: `(?:^|[${n}])`,
|
|
34
|
+
END_ANCHOR: `(?:[${n}]|$)`,
|
|
35
|
+
SEP: "\\"
|
|
36
|
+
};
|
|
37
|
+
t.exports = {
|
|
38
|
+
DEFAULT_MAX_EXTGLOB_RECURSION: i,
|
|
39
|
+
MAX_LENGTH: 1024 * 64,
|
|
40
|
+
POSIX_REGEX_SOURCE: {
|
|
41
|
+
__proto__: null,
|
|
42
|
+
alnum: "a-zA-Z0-9",
|
|
43
|
+
alpha: "a-zA-Z",
|
|
44
|
+
ascii: "\\x00-\\x7F",
|
|
45
|
+
blank: " \\t",
|
|
46
|
+
cntrl: "\\x00-\\x1F\\x7F",
|
|
47
|
+
digit: "0-9",
|
|
48
|
+
graph: "\\x21-\\x7E",
|
|
49
|
+
lower: "a-z",
|
|
50
|
+
print: "\\x20-\\x7E ",
|
|
51
|
+
punct: "\\-!\"#$%&'()\\*+,./:;<=>?@[\\]^_`{|}~",
|
|
52
|
+
space: " \\t\\r\\n\\v\\f",
|
|
53
|
+
upper: "A-Z",
|
|
54
|
+
word: "A-Za-z0-9_",
|
|
55
|
+
xdigit: "A-Fa-f0-9"
|
|
56
|
+
},
|
|
57
|
+
REGEX_BACKSLASH: /\\(?![*+?^${}(|)[\]])/g,
|
|
58
|
+
REGEX_NON_SPECIAL_CHARS: /^[^@![\].,$*+?^{}()|\\/]+/,
|
|
59
|
+
REGEX_SPECIAL_CHARS: /[-*+?.^${}(|)[\]]/,
|
|
60
|
+
REGEX_SPECIAL_CHARS_BACKREF: /(\\?)((\W)(\3*))/g,
|
|
61
|
+
REGEX_SPECIAL_CHARS_GLOBAL: /([-*+?.^${}(|)[\]])/g,
|
|
62
|
+
REGEX_REMOVE_BACKSLASH: /(?:\[.*?[^\\]\]|\\(?=.))/g,
|
|
63
|
+
REPLACEMENTS: {
|
|
64
|
+
__proto__: null,
|
|
65
|
+
"***": "*",
|
|
66
|
+
"**/**": "**",
|
|
67
|
+
"**/**/**": "**"
|
|
68
|
+
},
|
|
69
|
+
CHAR_0: 48,
|
|
70
|
+
CHAR_9: 57,
|
|
71
|
+
CHAR_UPPERCASE_A: 65,
|
|
72
|
+
CHAR_LOWERCASE_A: 97,
|
|
73
|
+
CHAR_UPPERCASE_Z: 90,
|
|
74
|
+
CHAR_LOWERCASE_Z: 122,
|
|
75
|
+
CHAR_LEFT_PARENTHESES: 40,
|
|
76
|
+
CHAR_RIGHT_PARENTHESES: 41,
|
|
77
|
+
CHAR_ASTERISK: 42,
|
|
78
|
+
CHAR_AMPERSAND: 38,
|
|
79
|
+
CHAR_AT: 64,
|
|
80
|
+
CHAR_BACKWARD_SLASH: 92,
|
|
81
|
+
CHAR_CARRIAGE_RETURN: 13,
|
|
82
|
+
CHAR_CIRCUMFLEX_ACCENT: 94,
|
|
83
|
+
CHAR_COLON: 58,
|
|
84
|
+
CHAR_COMMA: 44,
|
|
85
|
+
CHAR_DOT: 46,
|
|
86
|
+
CHAR_DOUBLE_QUOTE: 34,
|
|
87
|
+
CHAR_EQUAL: 61,
|
|
88
|
+
CHAR_EXCLAMATION_MARK: 33,
|
|
89
|
+
CHAR_FORM_FEED: 12,
|
|
90
|
+
CHAR_FORWARD_SLASH: 47,
|
|
91
|
+
CHAR_GRAVE_ACCENT: 96,
|
|
92
|
+
CHAR_HASH: 35,
|
|
93
|
+
CHAR_HYPHEN_MINUS: 45,
|
|
94
|
+
CHAR_LEFT_ANGLE_BRACKET: 60,
|
|
95
|
+
CHAR_LEFT_CURLY_BRACE: 123,
|
|
96
|
+
CHAR_LEFT_SQUARE_BRACKET: 91,
|
|
97
|
+
CHAR_LINE_FEED: 10,
|
|
98
|
+
CHAR_NO_BREAK_SPACE: 160,
|
|
99
|
+
CHAR_PERCENT: 37,
|
|
100
|
+
CHAR_PLUS: 43,
|
|
101
|
+
CHAR_QUESTION_MARK: 63,
|
|
102
|
+
CHAR_RIGHT_ANGLE_BRACKET: 62,
|
|
103
|
+
CHAR_RIGHT_CURLY_BRACE: 125,
|
|
104
|
+
CHAR_RIGHT_SQUARE_BRACKET: 93,
|
|
105
|
+
CHAR_SEMICOLON: 59,
|
|
106
|
+
CHAR_SINGLE_QUOTE: 39,
|
|
107
|
+
CHAR_SPACE: 32,
|
|
108
|
+
CHAR_TAB: 9,
|
|
109
|
+
CHAR_UNDERSCORE: 95,
|
|
110
|
+
CHAR_VERTICAL_LINE: 124,
|
|
111
|
+
CHAR_ZERO_WIDTH_NOBREAK_SPACE: 65279,
|
|
112
|
+
extglobChars(e) {
|
|
113
|
+
return {
|
|
114
|
+
"!": {
|
|
115
|
+
type: "negate",
|
|
116
|
+
open: "(?:(?!(?:",
|
|
117
|
+
close: `))${e.STAR})`
|
|
118
|
+
},
|
|
119
|
+
"?": {
|
|
120
|
+
type: "qmark",
|
|
121
|
+
open: "(?:",
|
|
122
|
+
close: ")?"
|
|
123
|
+
},
|
|
124
|
+
"+": {
|
|
125
|
+
type: "plus",
|
|
126
|
+
open: "(?:",
|
|
127
|
+
close: ")+"
|
|
128
|
+
},
|
|
129
|
+
"*": {
|
|
130
|
+
type: "star",
|
|
131
|
+
open: "(?:",
|
|
132
|
+
close: ")*"
|
|
133
|
+
},
|
|
134
|
+
"@": {
|
|
135
|
+
type: "at",
|
|
136
|
+
open: "(?:",
|
|
137
|
+
close: ")"
|
|
138
|
+
}
|
|
139
|
+
};
|
|
140
|
+
},
|
|
141
|
+
globChars(e) {
|
|
142
|
+
return e === !0 ? h : m;
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
})), i = /* @__PURE__ */ e(((e) => {
|
|
146
|
+
n();
|
|
147
|
+
var { REGEX_BACKSLASH: i, REGEX_REMOVE_BACKSLASH: a, REGEX_SPECIAL_CHARS: o, REGEX_SPECIAL_CHARS_GLOBAL: s } = r();
|
|
148
|
+
e.isObject = (e) => typeof e == "object" && !!e && !Array.isArray(e), e.hasRegexChars = (e) => o.test(e), e.isRegexChar = (t) => t.length === 1 && e.hasRegexChars(t), e.escapeRegex = (e) => e.replace(s, "\\$1"), e.toPosixSlashes = (e) => e.replace(i, "/"), e.isWindows = () => {
|
|
149
|
+
if (typeof navigator < "u" && navigator.platform) {
|
|
150
|
+
let e = navigator.platform.toLowerCase();
|
|
151
|
+
return e === "win32" || e === "windows";
|
|
152
|
+
}
|
|
153
|
+
return t !== void 0 && t.platform ? t.platform === "win32" : !1;
|
|
154
|
+
}, e.removeBackslashes = (e) => e.replace(a, (e) => e === "\\" ? "" : e), e.escapeLast = (t, n, r) => {
|
|
155
|
+
let i = t.lastIndexOf(n, r);
|
|
156
|
+
return i === -1 ? t : t[i - 1] === "\\" ? e.escapeLast(t, n, i - 1) : `${t.slice(0, i)}\\${t.slice(i)}`;
|
|
157
|
+
}, e.removePrefix = (e, t = {}) => {
|
|
158
|
+
let n = e;
|
|
159
|
+
return n.startsWith("./") && (n = n.slice(2), t.prefix = "./"), n;
|
|
160
|
+
}, e.wrapOutput = (e, t = {}, n = {}) => {
|
|
161
|
+
let r = `${n.contains ? "" : "^"}(?:${e})${n.contains ? "" : "$"}`;
|
|
162
|
+
return t.negated === !0 && (r = `(?:^(?!${r}).*$)`), r;
|
|
163
|
+
}, e.basename = (e, { windows: t } = {}) => {
|
|
164
|
+
let n = e.split(t ? /[\\/]/ : "/"), r = n[n.length - 1];
|
|
165
|
+
return r === "" ? n[n.length - 2] : r;
|
|
166
|
+
};
|
|
167
|
+
})), a = /* @__PURE__ */ e(((e, t) => {
|
|
168
|
+
var n = i(), { CHAR_ASTERISK: a, CHAR_AT: o, CHAR_BACKWARD_SLASH: s, CHAR_COMMA: c, CHAR_DOT: l, CHAR_EXCLAMATION_MARK: u, CHAR_FORWARD_SLASH: d, CHAR_LEFT_CURLY_BRACE: f, CHAR_LEFT_PARENTHESES: p, CHAR_LEFT_SQUARE_BRACKET: m, CHAR_PLUS: h, CHAR_QUESTION_MARK: g, CHAR_RIGHT_CURLY_BRACE: _, CHAR_RIGHT_PARENTHESES: v, CHAR_RIGHT_SQUARE_BRACKET: y } = r(), b = (e) => e === d || e === s, x = (e) => {
|
|
169
|
+
e.isPrefix !== !0 && (e.depth = e.isGlobstar ? Infinity : 1);
|
|
170
|
+
};
|
|
171
|
+
t.exports = (e, t) => {
|
|
172
|
+
let r = t || {}, i = e.length - 1, S = r.parts === !0 || r.scanToEnd === !0, C = [], w = [], T = [], E = e, D = -1, O = 0, k = 0, A = !1, j = !1, M = !1, N = !1, P = !1, F = !1, I = !1, L = !1, R = !1, z = !1, B = 0, V, H, U = {
|
|
173
|
+
value: "",
|
|
174
|
+
depth: 0,
|
|
175
|
+
isGlob: !1
|
|
176
|
+
}, W = () => D >= i, G = () => E.charCodeAt(D + 1), K = () => (V = H, E.charCodeAt(++D));
|
|
177
|
+
for (; D < i;) {
|
|
178
|
+
H = K();
|
|
179
|
+
let e;
|
|
180
|
+
if (H === s) {
|
|
181
|
+
I = U.backslashes = !0, H = K(), H === f && (F = !0);
|
|
182
|
+
continue;
|
|
183
|
+
}
|
|
184
|
+
if (F === !0 || H === f) {
|
|
185
|
+
for (B++; W() !== !0 && (H = K());) {
|
|
186
|
+
if (H === s) {
|
|
187
|
+
I = U.backslashes = !0, K();
|
|
188
|
+
continue;
|
|
189
|
+
}
|
|
190
|
+
if (H === f) {
|
|
191
|
+
B++;
|
|
192
|
+
continue;
|
|
193
|
+
}
|
|
194
|
+
if (F !== !0 && H === l && (H = K()) === l) {
|
|
195
|
+
if (A = U.isBrace = !0, M = U.isGlob = !0, z = !0, S === !0) continue;
|
|
196
|
+
break;
|
|
197
|
+
}
|
|
198
|
+
if (F !== !0 && H === c) {
|
|
199
|
+
if (A = U.isBrace = !0, M = U.isGlob = !0, z = !0, S === !0) continue;
|
|
200
|
+
break;
|
|
201
|
+
}
|
|
202
|
+
if (H === _ && (B--, B === 0)) {
|
|
203
|
+
F = !1, A = U.isBrace = !0, z = !0;
|
|
204
|
+
break;
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
if (S === !0) continue;
|
|
208
|
+
break;
|
|
209
|
+
}
|
|
210
|
+
if (H === d) {
|
|
211
|
+
if (C.push(D), w.push(U), U = {
|
|
212
|
+
value: "",
|
|
213
|
+
depth: 0,
|
|
214
|
+
isGlob: !1
|
|
215
|
+
}, z === !0) continue;
|
|
216
|
+
if (V === l && D === O + 1) {
|
|
217
|
+
O += 2;
|
|
218
|
+
continue;
|
|
219
|
+
}
|
|
220
|
+
k = D + 1;
|
|
221
|
+
continue;
|
|
222
|
+
}
|
|
223
|
+
if (r.noext !== !0 && (H === h || H === o || H === a || H === g || H === u) && G() === p) {
|
|
224
|
+
if (M = U.isGlob = !0, N = U.isExtglob = !0, z = !0, H === u && D === O && (R = !0), S === !0) {
|
|
225
|
+
for (; W() !== !0 && (H = K());) {
|
|
226
|
+
if (H === s) {
|
|
227
|
+
I = U.backslashes = !0, H = K();
|
|
228
|
+
continue;
|
|
229
|
+
}
|
|
230
|
+
if (H === v) {
|
|
231
|
+
M = U.isGlob = !0, z = !0;
|
|
232
|
+
break;
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
continue;
|
|
236
|
+
}
|
|
237
|
+
break;
|
|
238
|
+
}
|
|
239
|
+
if (H === a) {
|
|
240
|
+
if (V === a && (P = U.isGlobstar = !0), M = U.isGlob = !0, z = !0, S === !0) continue;
|
|
241
|
+
break;
|
|
242
|
+
}
|
|
243
|
+
if (H === g) {
|
|
244
|
+
if (M = U.isGlob = !0, z = !0, S === !0) continue;
|
|
245
|
+
break;
|
|
246
|
+
}
|
|
247
|
+
if (H === m) {
|
|
248
|
+
for (; W() !== !0 && (e = K());) {
|
|
249
|
+
if (e === s) {
|
|
250
|
+
I = U.backslashes = !0, K();
|
|
251
|
+
continue;
|
|
252
|
+
}
|
|
253
|
+
if (e === y) {
|
|
254
|
+
j = U.isBracket = !0, M = U.isGlob = !0, z = !0;
|
|
255
|
+
break;
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
if (S === !0) continue;
|
|
259
|
+
break;
|
|
260
|
+
}
|
|
261
|
+
if (r.nonegate !== !0 && H === u && D === O) {
|
|
262
|
+
L = U.negated = !0, O++;
|
|
263
|
+
continue;
|
|
264
|
+
}
|
|
265
|
+
if (r.noparen !== !0 && H === p) {
|
|
266
|
+
if (M = U.isGlob = !0, S === !0) {
|
|
267
|
+
for (; W() !== !0 && (H = K());) {
|
|
268
|
+
if (H === p) {
|
|
269
|
+
I = U.backslashes = !0, H = K();
|
|
270
|
+
continue;
|
|
271
|
+
}
|
|
272
|
+
if (H === v) {
|
|
273
|
+
z = !0;
|
|
274
|
+
break;
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
continue;
|
|
278
|
+
}
|
|
279
|
+
break;
|
|
280
|
+
}
|
|
281
|
+
if (M === !0) {
|
|
282
|
+
if (z = !0, S === !0) continue;
|
|
283
|
+
break;
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
r.noext === !0 && (N = !1, M = !1);
|
|
287
|
+
let q = E, J = "", Y = "";
|
|
288
|
+
O > 0 && (J = E.slice(0, O), E = E.slice(O), k -= O), q && M === !0 && k > 0 ? (q = E.slice(0, k), Y = E.slice(k)) : M === !0 ? (q = "", Y = E) : q = E, q && q !== "" && q !== "/" && q !== E && b(q.charCodeAt(q.length - 1)) && (q = q.slice(0, -1)), r.unescape === !0 && (Y &&= n.removeBackslashes(Y), q && I === !0 && (q = n.removeBackslashes(q)));
|
|
289
|
+
let X = {
|
|
290
|
+
prefix: J,
|
|
291
|
+
input: e,
|
|
292
|
+
start: O,
|
|
293
|
+
base: q,
|
|
294
|
+
glob: Y,
|
|
295
|
+
isBrace: A,
|
|
296
|
+
isBracket: j,
|
|
297
|
+
isGlob: M,
|
|
298
|
+
isExtglob: N,
|
|
299
|
+
isGlobstar: P,
|
|
300
|
+
negated: L,
|
|
301
|
+
negatedExtglob: R
|
|
302
|
+
};
|
|
303
|
+
if (r.tokens === !0 && (X.maxDepth = 0, b(H) || w.push(U), X.tokens = w), r.parts === !0 || r.tokens === !0) {
|
|
304
|
+
let t;
|
|
305
|
+
for (let n = 0; n < C.length; n++) {
|
|
306
|
+
let i = t ? t + 1 : O, a = C[n], o = e.slice(i, a);
|
|
307
|
+
r.tokens && (n === 0 && O !== 0 ? (w[n].isPrefix = !0, w[n].value = J) : w[n].value = o, x(w[n]), X.maxDepth += w[n].depth), (n !== 0 || o !== "") && T.push(o), t = a;
|
|
308
|
+
}
|
|
309
|
+
if (t && t + 1 < e.length) {
|
|
310
|
+
let n = e.slice(t + 1);
|
|
311
|
+
T.push(n), r.tokens && (w[w.length - 1].value = n, x(w[w.length - 1]), X.maxDepth += w[w.length - 1].depth);
|
|
312
|
+
}
|
|
313
|
+
X.slashes = C, X.parts = T;
|
|
314
|
+
}
|
|
315
|
+
return X;
|
|
316
|
+
};
|
|
317
|
+
})), o = /* @__PURE__ */ e(((e, t) => {
|
|
318
|
+
var n = r(), a = i(), { MAX_LENGTH: o, POSIX_REGEX_SOURCE: s, REGEX_NON_SPECIAL_CHARS: c, REGEX_SPECIAL_CHARS_BACKREF: l, REPLACEMENTS: u } = n, d = (e, t) => {
|
|
319
|
+
if (typeof t.expandRange == "function") return t.expandRange(...e, t);
|
|
320
|
+
e.sort();
|
|
321
|
+
let n = `[${e.join("-")}]`;
|
|
322
|
+
try {
|
|
323
|
+
new RegExp(n);
|
|
324
|
+
} catch {
|
|
325
|
+
return e.map((e) => a.escapeRegex(e)).join("..");
|
|
326
|
+
}
|
|
327
|
+
return n;
|
|
328
|
+
}, f = (e, t) => `Missing ${e}: "${t}" - use "\\\\${t}" to match literal characters`, p = (e) => {
|
|
329
|
+
let t = [], n = 0, r = 0, i = 0, a = "", o = !1;
|
|
330
|
+
for (let s of e) {
|
|
331
|
+
if (o === !0) {
|
|
332
|
+
a += s, o = !1;
|
|
333
|
+
continue;
|
|
334
|
+
}
|
|
335
|
+
if (s === "\\") {
|
|
336
|
+
a += s, o = !0;
|
|
337
|
+
continue;
|
|
338
|
+
}
|
|
339
|
+
if (s === "\"") {
|
|
340
|
+
i = i === 1 ? 0 : 1, a += s;
|
|
341
|
+
continue;
|
|
342
|
+
}
|
|
343
|
+
if (i === 0) {
|
|
344
|
+
if (s === "[") n++;
|
|
345
|
+
else if (s === "]" && n > 0) n--;
|
|
346
|
+
else if (n === 0) {
|
|
347
|
+
if (s === "(") r++;
|
|
348
|
+
else if (s === ")" && r > 0) r--;
|
|
349
|
+
else if (s === "|" && r === 0) {
|
|
350
|
+
t.push(a), a = "";
|
|
351
|
+
continue;
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
a += s;
|
|
356
|
+
}
|
|
357
|
+
return t.push(a), t;
|
|
358
|
+
}, m = (e) => {
|
|
359
|
+
let t = !1;
|
|
360
|
+
for (let n of e) {
|
|
361
|
+
if (t === !0) {
|
|
362
|
+
t = !1;
|
|
363
|
+
continue;
|
|
364
|
+
}
|
|
365
|
+
if (n === "\\") {
|
|
366
|
+
t = !0;
|
|
367
|
+
continue;
|
|
368
|
+
}
|
|
369
|
+
if (/[?*+@!()[\]{}]/.test(n)) return !1;
|
|
370
|
+
}
|
|
371
|
+
return !0;
|
|
372
|
+
}, h = (e) => {
|
|
373
|
+
let t = e.trim(), n = !0;
|
|
374
|
+
for (; n === !0;) n = !1, /^@\([^\\()[\]{}|]+\)$/.test(t) && (t = t.slice(2, -1), n = !0);
|
|
375
|
+
if (m(t)) return t.replace(/\\(.)/g, "$1");
|
|
376
|
+
}, g = (e) => {
|
|
377
|
+
let t = e.map(h).filter(Boolean);
|
|
378
|
+
for (let e = 0; e < t.length; e++) for (let n = e + 1; n < t.length; n++) {
|
|
379
|
+
let r = t[e], i = t[n], a = r[0];
|
|
380
|
+
if (!(!a || r !== a.repeat(r.length) || i !== a.repeat(i.length)) && (r === i || r.startsWith(i) || i.startsWith(r))) return !0;
|
|
381
|
+
}
|
|
382
|
+
return !1;
|
|
383
|
+
}, _ = (e, t = !0) => {
|
|
384
|
+
if (e[0] !== "+" && e[0] !== "*" || e[1] !== "(") return;
|
|
385
|
+
let n = 0, r = 0, i = 0, a = !1;
|
|
386
|
+
for (let o = 1; o < e.length; o++) {
|
|
387
|
+
let s = e[o];
|
|
388
|
+
if (a === !0) {
|
|
389
|
+
a = !1;
|
|
390
|
+
continue;
|
|
391
|
+
}
|
|
392
|
+
if (s === "\\") {
|
|
393
|
+
a = !0;
|
|
394
|
+
continue;
|
|
395
|
+
}
|
|
396
|
+
if (s === "\"") {
|
|
397
|
+
i = i === 1 ? 0 : 1;
|
|
398
|
+
continue;
|
|
399
|
+
}
|
|
400
|
+
if (i !== 1) {
|
|
401
|
+
if (s === "[") {
|
|
402
|
+
n++;
|
|
403
|
+
continue;
|
|
404
|
+
}
|
|
405
|
+
if (s === "]" && n > 0) {
|
|
406
|
+
n--;
|
|
407
|
+
continue;
|
|
408
|
+
}
|
|
409
|
+
if (!(n > 0)) {
|
|
410
|
+
if (s === "(") {
|
|
411
|
+
r++;
|
|
412
|
+
continue;
|
|
413
|
+
}
|
|
414
|
+
if (s === ")" && (r--, r === 0)) return t === !0 && o !== e.length - 1 ? void 0 : {
|
|
415
|
+
type: e[0],
|
|
416
|
+
body: e.slice(2, o),
|
|
417
|
+
end: o
|
|
418
|
+
};
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
}, v = (e) => {
|
|
423
|
+
let t = 0, n = [];
|
|
424
|
+
for (; t < e.length;) {
|
|
425
|
+
let r = _(e.slice(t), !1);
|
|
426
|
+
if (!r || r.type !== "*") return;
|
|
427
|
+
let i = p(r.body).map((e) => e.trim());
|
|
428
|
+
if (i.length !== 1) return;
|
|
429
|
+
let a = h(i[0]);
|
|
430
|
+
if (!a || a.length !== 1) return;
|
|
431
|
+
n.push(a), t += r.end + 1;
|
|
432
|
+
}
|
|
433
|
+
if (!(n.length < 1)) return `${n.length === 1 ? a.escapeRegex(n[0]) : `[${n.map((e) => a.escapeRegex(e)).join("")}]`}*`;
|
|
434
|
+
}, y = (e) => {
|
|
435
|
+
let t = 0, n = e.trim(), r = _(n);
|
|
436
|
+
for (; r;) t++, n = r.body.trim(), r = _(n);
|
|
437
|
+
return t;
|
|
438
|
+
}, b = (e, t) => {
|
|
439
|
+
if (t.maxExtglobRecursion === !1) return { risky: !1 };
|
|
440
|
+
let r = typeof t.maxExtglobRecursion == "number" ? t.maxExtglobRecursion : n.DEFAULT_MAX_EXTGLOB_RECURSION, i = p(e).map((e) => e.trim());
|
|
441
|
+
if (i.length > 1 && (i.some((e) => e === "") || i.some((e) => /^[*?]+$/.test(e)) || g(i))) return { risky: !0 };
|
|
442
|
+
for (let e of i) {
|
|
443
|
+
let t = v(e);
|
|
444
|
+
if (t) return {
|
|
445
|
+
risky: !0,
|
|
446
|
+
safeOutput: t
|
|
447
|
+
};
|
|
448
|
+
if (y(e) > r) return { risky: !0 };
|
|
449
|
+
}
|
|
450
|
+
return { risky: !1 };
|
|
451
|
+
}, x = (e, t) => {
|
|
452
|
+
if (typeof e != "string") throw TypeError("Expected a string");
|
|
453
|
+
e = u[e] || e;
|
|
454
|
+
let r = { ...t }, i = typeof r.maxLength == "number" ? Math.min(o, r.maxLength) : o, p = e.length;
|
|
455
|
+
if (p > i) throw SyntaxError(`Input length: ${p}, exceeds maximum allowed length: ${i}`);
|
|
456
|
+
let m = {
|
|
457
|
+
type: "bos",
|
|
458
|
+
value: "",
|
|
459
|
+
output: r.prepend || ""
|
|
460
|
+
}, h = [m], g = r.capture ? "" : "?:", _ = n.globChars(r.windows), v = n.extglobChars(_), { DOT_LITERAL: y, PLUS_LITERAL: S, SLASH_LITERAL: C, ONE_CHAR: w, DOTS_SLASH: T, NO_DOT: E, NO_DOT_SLASH: D, NO_DOTS_SLASH: O, QMARK: k, QMARK_NO_DOT: A, STAR: j, START_ANCHOR: M } = _, N = (e) => `(${g}(?:(?!${M}${e.dot ? T : y}).)*?)`, P = r.dot ? "" : E, F = r.dot ? k : A, I = r.bash === !0 ? N(r) : j;
|
|
461
|
+
r.capture && (I = `(${I})`), typeof r.noext == "boolean" && (r.noextglob = r.noext);
|
|
462
|
+
let L = {
|
|
463
|
+
input: e,
|
|
464
|
+
index: -1,
|
|
465
|
+
start: 0,
|
|
466
|
+
dot: r.dot === !0,
|
|
467
|
+
consumed: "",
|
|
468
|
+
output: "",
|
|
469
|
+
prefix: "",
|
|
470
|
+
backtrack: !1,
|
|
471
|
+
negated: !1,
|
|
472
|
+
brackets: 0,
|
|
473
|
+
braces: 0,
|
|
474
|
+
parens: 0,
|
|
475
|
+
quotes: 0,
|
|
476
|
+
globstar: !1,
|
|
477
|
+
tokens: h
|
|
478
|
+
};
|
|
479
|
+
e = a.removePrefix(e, L), p = e.length;
|
|
480
|
+
let R = [], z = [], B = [], V = m, H, U = () => L.index === p - 1, W = L.peek = (t = 1) => e[L.index + t], G = L.advance = () => e[++L.index] || "", K = () => e.slice(L.index + 1), q = (e = "", t = 0) => {
|
|
481
|
+
L.consumed += e, L.index += t;
|
|
482
|
+
}, J = (e) => {
|
|
483
|
+
L.output += e.output == null ? e.value : e.output, q(e.value);
|
|
484
|
+
}, Y = () => {
|
|
485
|
+
let e = 1;
|
|
486
|
+
for (; W() === "!" && (W(2) !== "(" || W(3) === "?");) G(), L.start++, e++;
|
|
487
|
+
return e % 2 == 0 ? !1 : (L.negated = !0, L.start++, !0);
|
|
488
|
+
}, X = (e) => {
|
|
489
|
+
L[e]++, B.push(e);
|
|
490
|
+
}, Z = (e) => {
|
|
491
|
+
L[e]--, B.pop();
|
|
492
|
+
}, Q = (e) => {
|
|
493
|
+
if (V.type === "globstar") {
|
|
494
|
+
let t = L.braces > 0 && (e.type === "comma" || e.type === "brace"), n = e.extglob === !0 || R.length && (e.type === "pipe" || e.type === "paren");
|
|
495
|
+
e.type !== "slash" && e.type !== "paren" && !t && !n && (L.output = L.output.slice(0, -V.output.length), V.type = "star", V.value = "*", V.output = I, L.output += V.output);
|
|
496
|
+
}
|
|
497
|
+
if (R.length && e.type !== "paren" && (R[R.length - 1].inner += e.value), (e.value || e.output) && J(e), V && V.type === "text" && e.type === "text") {
|
|
498
|
+
V.output = (V.output || V.value) + e.value, V.value += e.value;
|
|
499
|
+
return;
|
|
500
|
+
}
|
|
501
|
+
e.prev = V, h.push(e), V = e;
|
|
502
|
+
}, $ = (e, t) => {
|
|
503
|
+
let n = {
|
|
504
|
+
...v[t],
|
|
505
|
+
conditions: 1,
|
|
506
|
+
inner: ""
|
|
507
|
+
};
|
|
508
|
+
n.prev = V, n.parens = L.parens, n.output = L.output, n.startIndex = L.index, n.tokensIndex = h.length;
|
|
509
|
+
let i = (r.capture ? "(" : "") + n.open;
|
|
510
|
+
X("parens"), Q({
|
|
511
|
+
type: e,
|
|
512
|
+
value: t,
|
|
513
|
+
output: L.output ? "" : w
|
|
514
|
+
}), Q({
|
|
515
|
+
type: "paren",
|
|
516
|
+
extglob: !0,
|
|
517
|
+
value: G(),
|
|
518
|
+
output: i
|
|
519
|
+
}), R.push(n);
|
|
520
|
+
}, ee = (n) => {
|
|
521
|
+
let i = e.slice(n.startIndex, L.index + 1), o = b(e.slice(n.startIndex + 2, L.index), r);
|
|
522
|
+
if ((n.type === "plus" || n.type === "star") && o.risky) {
|
|
523
|
+
let e = o.safeOutput ? (n.output ? "" : w) + (r.capture ? `(${o.safeOutput})` : o.safeOutput) : void 0, t = h[n.tokensIndex];
|
|
524
|
+
t.type = "text", t.value = i, t.output = e || a.escapeRegex(i);
|
|
525
|
+
for (let e = n.tokensIndex + 1; e < h.length; e++) h[e].value = "", h[e].output = "", delete h[e].suffix;
|
|
526
|
+
L.output = n.output + t.output, L.backtrack = !0, Q({
|
|
527
|
+
type: "paren",
|
|
528
|
+
extglob: !0,
|
|
529
|
+
value: H,
|
|
530
|
+
output: ""
|
|
531
|
+
}), Z("parens");
|
|
532
|
+
return;
|
|
533
|
+
}
|
|
534
|
+
let s = n.close + (r.capture ? ")" : ""), c;
|
|
535
|
+
if (n.type === "negate") {
|
|
536
|
+
let e = I;
|
|
537
|
+
n.inner && n.inner.length > 1 && n.inner.includes("/") && (e = N(r)), (e !== I || U() || /^\)+$/.test(K())) && (s = n.close = `)$))${e}`), n.inner.includes("*") && (c = K()) && /^\.[^\\/.]+$/.test(c) && (s = n.close = `)${x(c, {
|
|
538
|
+
...t,
|
|
539
|
+
fastpaths: !1
|
|
540
|
+
}).output})${e})`), n.prev.type === "bos" && (L.negatedExtglob = !0);
|
|
541
|
+
}
|
|
542
|
+
Q({
|
|
543
|
+
type: "paren",
|
|
544
|
+
extglob: !0,
|
|
545
|
+
value: H,
|
|
546
|
+
output: s
|
|
547
|
+
}), Z("parens");
|
|
548
|
+
};
|
|
549
|
+
if (r.fastpaths !== !1 && !/(^[*!]|[/()[\]{}"])/.test(e)) {
|
|
550
|
+
let n = !1, i = e.replace(l, (e, t, r, i, a, o) => i === "\\" ? (n = !0, e) : i === "?" ? t ? t + i + (a ? k.repeat(a.length) : "") : o === 0 ? F + (a ? k.repeat(a.length) : "") : k.repeat(r.length) : i === "." ? y.repeat(r.length) : i === "*" ? t ? t + i + (a ? I : "") : I : t ? e : `\\${e}`);
|
|
551
|
+
return n === !0 && (i = r.unescape === !0 ? i.replace(/\\/g, "") : i.replace(/\\+/g, (e) => e.length % 2 == 0 ? "\\\\" : e ? "\\" : "")), i === e && r.contains === !0 ? (L.output = e, L) : (L.output = a.wrapOutput(i, L, t), L);
|
|
552
|
+
}
|
|
553
|
+
for (; !U();) {
|
|
554
|
+
if (H = G(), H === "\0") continue;
|
|
555
|
+
if (H === "\\") {
|
|
556
|
+
let e = W();
|
|
557
|
+
if (e === "/" && r.bash !== !0 || e === "." || e === ";") continue;
|
|
558
|
+
if (!e) {
|
|
559
|
+
H += "\\", Q({
|
|
560
|
+
type: "text",
|
|
561
|
+
value: H
|
|
562
|
+
});
|
|
563
|
+
continue;
|
|
564
|
+
}
|
|
565
|
+
let t = /^\\+/.exec(K()), n = 0;
|
|
566
|
+
if (t && t[0].length > 2 && (n = t[0].length, L.index += n, n % 2 != 0 && (H += "\\")), r.unescape === !0 ? H = G() : H += G(), L.brackets === 0) {
|
|
567
|
+
Q({
|
|
568
|
+
type: "text",
|
|
569
|
+
value: H
|
|
570
|
+
});
|
|
571
|
+
continue;
|
|
572
|
+
}
|
|
573
|
+
}
|
|
574
|
+
if (L.brackets > 0 && (H !== "]" || V.value === "[" || V.value === "[^")) {
|
|
575
|
+
if (r.posix !== !1 && H === ":") {
|
|
576
|
+
let e = V.value.slice(1);
|
|
577
|
+
if (e.includes("[") && (V.posix = !0, e.includes(":"))) {
|
|
578
|
+
let e = V.value.lastIndexOf("["), t = V.value.slice(0, e), n = s[V.value.slice(e + 2)];
|
|
579
|
+
if (n) {
|
|
580
|
+
V.value = t + n, L.backtrack = !0, G(), !m.output && h.indexOf(V) === 1 && (m.output = w);
|
|
581
|
+
continue;
|
|
582
|
+
}
|
|
583
|
+
}
|
|
584
|
+
}
|
|
585
|
+
(H === "[" && W() !== ":" || H === "-" && W() === "]") && (H = `\\${H}`), H === "]" && (V.value === "[" || V.value === "[^") && (H = `\\${H}`), r.posix === !0 && H === "!" && V.value === "[" && (H = "^"), V.value += H, J({ value: H });
|
|
586
|
+
continue;
|
|
587
|
+
}
|
|
588
|
+
if (L.quotes === 1 && H !== "\"") {
|
|
589
|
+
H = a.escapeRegex(H), V.value += H, J({ value: H });
|
|
590
|
+
continue;
|
|
591
|
+
}
|
|
592
|
+
if (H === "\"") {
|
|
593
|
+
L.quotes = L.quotes === 1 ? 0 : 1, r.keepQuotes === !0 && Q({
|
|
594
|
+
type: "text",
|
|
595
|
+
value: H
|
|
596
|
+
});
|
|
597
|
+
continue;
|
|
598
|
+
}
|
|
599
|
+
if (H === "(") {
|
|
600
|
+
X("parens"), Q({
|
|
601
|
+
type: "paren",
|
|
602
|
+
value: H
|
|
603
|
+
});
|
|
604
|
+
continue;
|
|
605
|
+
}
|
|
606
|
+
if (H === ")") {
|
|
607
|
+
if (L.parens === 0 && r.strictBrackets === !0) throw SyntaxError(f("opening", "("));
|
|
608
|
+
let e = R[R.length - 1];
|
|
609
|
+
if (e && L.parens === e.parens + 1) {
|
|
610
|
+
ee(R.pop());
|
|
611
|
+
continue;
|
|
612
|
+
}
|
|
613
|
+
Q({
|
|
614
|
+
type: "paren",
|
|
615
|
+
value: H,
|
|
616
|
+
output: L.parens ? ")" : "\\)"
|
|
617
|
+
}), Z("parens");
|
|
618
|
+
continue;
|
|
619
|
+
}
|
|
620
|
+
if (H === "[") {
|
|
621
|
+
if (r.nobracket === !0 || !K().includes("]")) {
|
|
622
|
+
if (r.nobracket !== !0 && r.strictBrackets === !0) throw SyntaxError(f("closing", "]"));
|
|
623
|
+
H = `\\${H}`;
|
|
624
|
+
} else X("brackets");
|
|
625
|
+
Q({
|
|
626
|
+
type: "bracket",
|
|
627
|
+
value: H
|
|
628
|
+
});
|
|
629
|
+
continue;
|
|
630
|
+
}
|
|
631
|
+
if (H === "]") {
|
|
632
|
+
if (r.nobracket === !0 || V && V.type === "bracket" && V.value.length === 1) {
|
|
633
|
+
Q({
|
|
634
|
+
type: "text",
|
|
635
|
+
value: H,
|
|
636
|
+
output: `\\${H}`
|
|
637
|
+
});
|
|
638
|
+
continue;
|
|
639
|
+
}
|
|
640
|
+
if (L.brackets === 0) {
|
|
641
|
+
if (r.strictBrackets === !0) throw SyntaxError(f("opening", "["));
|
|
642
|
+
Q({
|
|
643
|
+
type: "text",
|
|
644
|
+
value: H,
|
|
645
|
+
output: `\\${H}`
|
|
646
|
+
});
|
|
647
|
+
continue;
|
|
648
|
+
}
|
|
649
|
+
Z("brackets");
|
|
650
|
+
let e = V.value.slice(1);
|
|
651
|
+
if (V.posix !== !0 && e[0] === "^" && !e.includes("/") && (H = `/${H}`), V.value += H, J({ value: H }), r.literalBrackets === !1 || a.hasRegexChars(e)) continue;
|
|
652
|
+
let t = a.escapeRegex(V.value);
|
|
653
|
+
if (L.output = L.output.slice(0, -V.value.length), r.literalBrackets === !0) {
|
|
654
|
+
L.output += t, V.value = t;
|
|
655
|
+
continue;
|
|
656
|
+
}
|
|
657
|
+
V.value = `(${g}${t}|${V.value})`, L.output += V.value;
|
|
658
|
+
continue;
|
|
659
|
+
}
|
|
660
|
+
if (H === "{" && r.nobrace !== !0) {
|
|
661
|
+
X("braces");
|
|
662
|
+
let e = {
|
|
663
|
+
type: "brace",
|
|
664
|
+
value: H,
|
|
665
|
+
output: "(",
|
|
666
|
+
outputIndex: L.output.length,
|
|
667
|
+
tokensIndex: L.tokens.length
|
|
668
|
+
};
|
|
669
|
+
z.push(e), Q(e);
|
|
670
|
+
continue;
|
|
671
|
+
}
|
|
672
|
+
if (H === "}") {
|
|
673
|
+
let e = z[z.length - 1];
|
|
674
|
+
if (r.nobrace === !0 || !e) {
|
|
675
|
+
Q({
|
|
676
|
+
type: "text",
|
|
677
|
+
value: H,
|
|
678
|
+
output: H
|
|
679
|
+
});
|
|
680
|
+
continue;
|
|
681
|
+
}
|
|
682
|
+
let t = ")";
|
|
683
|
+
if (e.dots === !0) {
|
|
684
|
+
let e = h.slice(), n = [];
|
|
685
|
+
for (let t = e.length - 1; t >= 0 && (h.pop(), e[t].type !== "brace"); t--) e[t].type !== "dots" && n.unshift(e[t].value);
|
|
686
|
+
t = d(n, r), L.backtrack = !0;
|
|
687
|
+
}
|
|
688
|
+
if (e.comma !== !0 && e.dots !== !0) {
|
|
689
|
+
let n = L.output.slice(0, e.outputIndex), r = L.tokens.slice(e.tokensIndex);
|
|
690
|
+
e.value = e.output = "\\{", H = t = "\\}", L.output = n;
|
|
691
|
+
for (let e of r) L.output += e.output || e.value;
|
|
692
|
+
}
|
|
693
|
+
Q({
|
|
694
|
+
type: "brace",
|
|
695
|
+
value: H,
|
|
696
|
+
output: t
|
|
697
|
+
}), Z("braces"), z.pop();
|
|
698
|
+
continue;
|
|
699
|
+
}
|
|
700
|
+
if (H === "|") {
|
|
701
|
+
R.length > 0 && R[R.length - 1].conditions++, Q({
|
|
702
|
+
type: "text",
|
|
703
|
+
value: H
|
|
704
|
+
});
|
|
705
|
+
continue;
|
|
706
|
+
}
|
|
707
|
+
if (H === ",") {
|
|
708
|
+
let e = H, t = z[z.length - 1];
|
|
709
|
+
t && B[B.length - 1] === "braces" && (t.comma = !0, e = "|"), Q({
|
|
710
|
+
type: "comma",
|
|
711
|
+
value: H,
|
|
712
|
+
output: e
|
|
713
|
+
});
|
|
714
|
+
continue;
|
|
715
|
+
}
|
|
716
|
+
if (H === "/") {
|
|
717
|
+
if (V.type === "dot" && L.index === L.start + 1) {
|
|
718
|
+
L.start = L.index + 1, L.consumed = "", L.output = "", h.pop(), V = m;
|
|
719
|
+
continue;
|
|
720
|
+
}
|
|
721
|
+
Q({
|
|
722
|
+
type: "slash",
|
|
723
|
+
value: H,
|
|
724
|
+
output: C
|
|
725
|
+
});
|
|
726
|
+
continue;
|
|
727
|
+
}
|
|
728
|
+
if (H === ".") {
|
|
729
|
+
if (L.braces > 0 && V.type === "dot") {
|
|
730
|
+
V.value === "." && (V.output = y);
|
|
731
|
+
let e = z[z.length - 1];
|
|
732
|
+
V.type = "dots", V.output += H, V.value += H, e.dots = !0;
|
|
733
|
+
continue;
|
|
734
|
+
}
|
|
735
|
+
if (L.braces + L.parens === 0 && V.type !== "bos" && V.type !== "slash") {
|
|
736
|
+
Q({
|
|
737
|
+
type: "text",
|
|
738
|
+
value: H,
|
|
739
|
+
output: y
|
|
740
|
+
});
|
|
741
|
+
continue;
|
|
742
|
+
}
|
|
743
|
+
Q({
|
|
744
|
+
type: "dot",
|
|
745
|
+
value: H,
|
|
746
|
+
output: y
|
|
747
|
+
});
|
|
748
|
+
continue;
|
|
749
|
+
}
|
|
750
|
+
if (H === "?") {
|
|
751
|
+
if (!(V && V.value === "(") && r.noextglob !== !0 && W() === "(" && W(2) !== "?") {
|
|
752
|
+
$("qmark", H);
|
|
753
|
+
continue;
|
|
754
|
+
}
|
|
755
|
+
if (V && V.type === "paren") {
|
|
756
|
+
let e = W(), t = H;
|
|
757
|
+
(V.value === "(" && !/[!=<:]/.test(e) || e === "<" && !/<([!=]|\w+>)/.test(K())) && (t = `\\${H}`), Q({
|
|
758
|
+
type: "text",
|
|
759
|
+
value: H,
|
|
760
|
+
output: t
|
|
761
|
+
});
|
|
762
|
+
continue;
|
|
763
|
+
}
|
|
764
|
+
if (r.dot !== !0 && (V.type === "slash" || V.type === "bos")) {
|
|
765
|
+
Q({
|
|
766
|
+
type: "qmark",
|
|
767
|
+
value: H,
|
|
768
|
+
output: A
|
|
769
|
+
});
|
|
770
|
+
continue;
|
|
771
|
+
}
|
|
772
|
+
Q({
|
|
773
|
+
type: "qmark",
|
|
774
|
+
value: H,
|
|
775
|
+
output: k
|
|
776
|
+
});
|
|
777
|
+
continue;
|
|
778
|
+
}
|
|
779
|
+
if (H === "!") {
|
|
780
|
+
if (r.noextglob !== !0 && W() === "(" && (W(2) !== "?" || !/[!=<:]/.test(W(3)))) {
|
|
781
|
+
$("negate", H);
|
|
782
|
+
continue;
|
|
783
|
+
}
|
|
784
|
+
if (r.nonegate !== !0 && L.index === 0) {
|
|
785
|
+
Y();
|
|
786
|
+
continue;
|
|
787
|
+
}
|
|
788
|
+
}
|
|
789
|
+
if (H === "+") {
|
|
790
|
+
if (r.noextglob !== !0 && W() === "(" && W(2) !== "?") {
|
|
791
|
+
$("plus", H);
|
|
792
|
+
continue;
|
|
793
|
+
}
|
|
794
|
+
if (V && V.value === "(" || r.regex === !1) {
|
|
795
|
+
Q({
|
|
796
|
+
type: "plus",
|
|
797
|
+
value: H,
|
|
798
|
+
output: S
|
|
799
|
+
});
|
|
800
|
+
continue;
|
|
801
|
+
}
|
|
802
|
+
if (V && (V.type === "bracket" || V.type === "paren" || V.type === "brace") || L.parens > 0) {
|
|
803
|
+
Q({
|
|
804
|
+
type: "plus",
|
|
805
|
+
value: H
|
|
806
|
+
});
|
|
807
|
+
continue;
|
|
808
|
+
}
|
|
809
|
+
Q({
|
|
810
|
+
type: "plus",
|
|
811
|
+
value: S
|
|
812
|
+
});
|
|
813
|
+
continue;
|
|
814
|
+
}
|
|
815
|
+
if (H === "@") {
|
|
816
|
+
if (r.noextglob !== !0 && W() === "(" && W(2) !== "?") {
|
|
817
|
+
Q({
|
|
818
|
+
type: "at",
|
|
819
|
+
extglob: !0,
|
|
820
|
+
value: H,
|
|
821
|
+
output: ""
|
|
822
|
+
});
|
|
823
|
+
continue;
|
|
824
|
+
}
|
|
825
|
+
Q({
|
|
826
|
+
type: "text",
|
|
827
|
+
value: H
|
|
828
|
+
});
|
|
829
|
+
continue;
|
|
830
|
+
}
|
|
831
|
+
if (H !== "*") {
|
|
832
|
+
(H === "$" || H === "^") && (H = `\\${H}`);
|
|
833
|
+
let e = c.exec(K());
|
|
834
|
+
e && (H += e[0], L.index += e[0].length), Q({
|
|
835
|
+
type: "text",
|
|
836
|
+
value: H
|
|
837
|
+
});
|
|
838
|
+
continue;
|
|
839
|
+
}
|
|
840
|
+
if (V && (V.type === "globstar" || V.star === !0)) {
|
|
841
|
+
V.type = "star", V.star = !0, V.value += H, V.output = I, L.backtrack = !0, L.globstar = !0, q(H);
|
|
842
|
+
continue;
|
|
843
|
+
}
|
|
844
|
+
let t = K();
|
|
845
|
+
if (r.noextglob !== !0 && /^\([^?]/.test(t)) {
|
|
846
|
+
$("star", H);
|
|
847
|
+
continue;
|
|
848
|
+
}
|
|
849
|
+
if (V.type === "star") {
|
|
850
|
+
if (r.noglobstar === !0) {
|
|
851
|
+
q(H);
|
|
852
|
+
continue;
|
|
853
|
+
}
|
|
854
|
+
let n = V.prev, i = n.prev, a = n.type === "slash" || n.type === "bos", o = i && (i.type === "star" || i.type === "globstar");
|
|
855
|
+
if (r.bash === !0 && (!a || t[0] && t[0] !== "/")) {
|
|
856
|
+
Q({
|
|
857
|
+
type: "star",
|
|
858
|
+
value: H,
|
|
859
|
+
output: ""
|
|
860
|
+
});
|
|
861
|
+
continue;
|
|
862
|
+
}
|
|
863
|
+
let s = L.braces > 0 && (n.type === "comma" || n.type === "brace"), c = R.length && (n.type === "pipe" || n.type === "paren");
|
|
864
|
+
if (!a && n.type !== "paren" && !s && !c) {
|
|
865
|
+
Q({
|
|
866
|
+
type: "star",
|
|
867
|
+
value: H,
|
|
868
|
+
output: ""
|
|
869
|
+
});
|
|
870
|
+
continue;
|
|
871
|
+
}
|
|
872
|
+
for (; t.slice(0, 3) === "/**";) {
|
|
873
|
+
let n = e[L.index + 4];
|
|
874
|
+
if (n && n !== "/") break;
|
|
875
|
+
t = t.slice(3), q("/**", 3);
|
|
876
|
+
}
|
|
877
|
+
if (n.type === "bos" && U()) {
|
|
878
|
+
V.type = "globstar", V.value += H, V.output = N(r), L.output = V.output, L.globstar = !0, q(H);
|
|
879
|
+
continue;
|
|
880
|
+
}
|
|
881
|
+
if (n.type === "slash" && n.prev.type !== "bos" && !o && U()) {
|
|
882
|
+
L.output = L.output.slice(0, -(n.output + V.output).length), n.output = `(?:${n.output}`, V.type = "globstar", V.output = N(r) + (r.strictSlashes ? ")" : "|$)"), V.value += H, L.globstar = !0, L.output += n.output + V.output, q(H);
|
|
883
|
+
continue;
|
|
884
|
+
}
|
|
885
|
+
if (n.type === "slash" && n.prev.type !== "bos" && t[0] === "/") {
|
|
886
|
+
let e = t[1] === void 0 ? "" : "|$";
|
|
887
|
+
L.output = L.output.slice(0, -(n.output + V.output).length), n.output = `(?:${n.output}`, V.type = "globstar", V.output = `${N(r)}${C}|${C}${e})`, V.value += H, L.output += n.output + V.output, L.globstar = !0, q(H + G()), Q({
|
|
888
|
+
type: "slash",
|
|
889
|
+
value: "/",
|
|
890
|
+
output: ""
|
|
891
|
+
});
|
|
892
|
+
continue;
|
|
893
|
+
}
|
|
894
|
+
if (n.type === "bos" && t[0] === "/") {
|
|
895
|
+
V.type = "globstar", V.value += H, V.output = `(?:^|${C}|${N(r)}${C})`, L.output = V.output, L.globstar = !0, q(H + G()), Q({
|
|
896
|
+
type: "slash",
|
|
897
|
+
value: "/",
|
|
898
|
+
output: ""
|
|
899
|
+
});
|
|
900
|
+
continue;
|
|
901
|
+
}
|
|
902
|
+
L.output = L.output.slice(0, -V.output.length), V.type = "globstar", V.output = N(r), V.value += H, L.output += V.output, L.globstar = !0, q(H);
|
|
903
|
+
continue;
|
|
904
|
+
}
|
|
905
|
+
let n = {
|
|
906
|
+
type: "star",
|
|
907
|
+
value: H,
|
|
908
|
+
output: I
|
|
909
|
+
};
|
|
910
|
+
if (r.bash === !0) {
|
|
911
|
+
n.output = ".*?", (V.type === "bos" || V.type === "slash") && (n.output = P + n.output), Q(n);
|
|
912
|
+
continue;
|
|
913
|
+
}
|
|
914
|
+
if (V && (V.type === "bracket" || V.type === "paren") && r.regex === !0) {
|
|
915
|
+
n.output = H, Q(n);
|
|
916
|
+
continue;
|
|
917
|
+
}
|
|
918
|
+
(L.index === L.start || V.type === "slash" || V.type === "dot") && (V.type === "dot" ? (L.output += D, V.output += D) : r.dot === !0 ? (L.output += O, V.output += O) : (L.output += P, V.output += P), W() !== "*" && (L.output += w, V.output += w)), Q(n);
|
|
919
|
+
}
|
|
920
|
+
for (; L.brackets > 0;) {
|
|
921
|
+
if (r.strictBrackets === !0) throw SyntaxError(f("closing", "]"));
|
|
922
|
+
L.output = a.escapeLast(L.output, "["), Z("brackets");
|
|
923
|
+
}
|
|
924
|
+
for (; L.parens > 0;) {
|
|
925
|
+
if (r.strictBrackets === !0) throw SyntaxError(f("closing", ")"));
|
|
926
|
+
L.output = a.escapeLast(L.output, "("), Z("parens");
|
|
927
|
+
}
|
|
928
|
+
for (; L.braces > 0;) {
|
|
929
|
+
if (r.strictBrackets === !0) throw SyntaxError(f("closing", "}"));
|
|
930
|
+
L.output = a.escapeLast(L.output, "{"), Z("braces");
|
|
931
|
+
}
|
|
932
|
+
if (r.strictSlashes !== !0 && (V.type === "star" || V.type === "bracket") && Q({
|
|
933
|
+
type: "maybe_slash",
|
|
934
|
+
value: "",
|
|
935
|
+
output: `${C}?`
|
|
936
|
+
}), L.backtrack === !0) {
|
|
937
|
+
L.output = "";
|
|
938
|
+
for (let e of L.tokens) L.output += e.output == null ? e.value : e.output, e.suffix && (L.output += e.suffix);
|
|
939
|
+
}
|
|
940
|
+
return L;
|
|
941
|
+
};
|
|
942
|
+
x.fastpaths = (e, t) => {
|
|
943
|
+
let r = { ...t }, i = typeof r.maxLength == "number" ? Math.min(o, r.maxLength) : o, s = e.length;
|
|
944
|
+
if (s > i) throw SyntaxError(`Input length: ${s}, exceeds maximum allowed length: ${i}`);
|
|
945
|
+
e = u[e] || e;
|
|
946
|
+
let { DOT_LITERAL: c, SLASH_LITERAL: l, ONE_CHAR: d, DOTS_SLASH: f, NO_DOT: p, NO_DOTS: m, NO_DOTS_SLASH: h, STAR: g, START_ANCHOR: _ } = n.globChars(r.windows), v = r.dot ? m : p, y = r.dot ? h : p, b = r.capture ? "" : "?:", x = {
|
|
947
|
+
negated: !1,
|
|
948
|
+
prefix: ""
|
|
949
|
+
}, S = r.bash === !0 ? ".*?" : g;
|
|
950
|
+
r.capture && (S = `(${S})`);
|
|
951
|
+
let C = (e) => e.noglobstar === !0 ? S : `(${b}(?:(?!${_}${e.dot ? f : c}).)*?)`, w = (e) => {
|
|
952
|
+
switch (e) {
|
|
953
|
+
case "*": return `${v}${d}${S}`;
|
|
954
|
+
case ".*": return `${c}${d}${S}`;
|
|
955
|
+
case "*.*": return `${v}${S}${c}${d}${S}`;
|
|
956
|
+
case "*/*": return `${v}${S}${l}${d}${y}${S}`;
|
|
957
|
+
case "**": return v + C(r);
|
|
958
|
+
case "**/*": return `(?:${v}${C(r)}${l})?${y}${d}${S}`;
|
|
959
|
+
case "**/*.*": return `(?:${v}${C(r)}${l})?${y}${S}${c}${d}${S}`;
|
|
960
|
+
case "**/.*": return `(?:${v}${C(r)}${l})?${c}${d}${S}`;
|
|
961
|
+
default: {
|
|
962
|
+
let t = /^(.*?)\.(\w+)$/.exec(e);
|
|
963
|
+
if (!t) return;
|
|
964
|
+
let n = w(t[1]);
|
|
965
|
+
return n ? n + c + t[2] : void 0;
|
|
966
|
+
}
|
|
967
|
+
}
|
|
968
|
+
}, T = w(a.removePrefix(e, x));
|
|
969
|
+
return T && r.strictSlashes !== !0 && (T += `${l}?`), T;
|
|
970
|
+
}, t.exports = x;
|
|
971
|
+
})), s = /* @__PURE__ */ e(((e, t) => {
|
|
972
|
+
var n = a(), s = o(), c = i(), l = r(), u = (e) => e && typeof e == "object" && !Array.isArray(e), d = (e, t, n = !1) => {
|
|
973
|
+
if (Array.isArray(e)) {
|
|
974
|
+
let r = e.map((e) => d(e, t, n));
|
|
975
|
+
return (e) => {
|
|
976
|
+
for (let t of r) {
|
|
977
|
+
let n = t(e);
|
|
978
|
+
if (n) return n;
|
|
979
|
+
}
|
|
980
|
+
return !1;
|
|
981
|
+
};
|
|
982
|
+
}
|
|
983
|
+
let r = u(e) && e.tokens && e.input;
|
|
984
|
+
if (e === "" || typeof e != "string" && !r) throw TypeError("Expected pattern to be a non-empty string");
|
|
985
|
+
let i = t || {}, a = i.windows, o = r ? d.compileRe(e, t) : d.makeRe(e, t, !1, !0), s = o.state;
|
|
986
|
+
delete o.state;
|
|
987
|
+
let c = () => !1;
|
|
988
|
+
if (i.ignore) {
|
|
989
|
+
let e = {
|
|
990
|
+
...t,
|
|
991
|
+
ignore: null,
|
|
992
|
+
onMatch: null,
|
|
993
|
+
onResult: null
|
|
994
|
+
};
|
|
995
|
+
c = d(i.ignore, e, n);
|
|
996
|
+
}
|
|
997
|
+
let l = (n, r = !1) => {
|
|
998
|
+
let { isMatch: l, match: u, output: f } = d.test(n, o, t, {
|
|
999
|
+
glob: e,
|
|
1000
|
+
posix: a
|
|
1001
|
+
}), p = {
|
|
1002
|
+
glob: e,
|
|
1003
|
+
state: s,
|
|
1004
|
+
regex: o,
|
|
1005
|
+
posix: a,
|
|
1006
|
+
input: n,
|
|
1007
|
+
output: f,
|
|
1008
|
+
match: u,
|
|
1009
|
+
isMatch: l
|
|
1010
|
+
};
|
|
1011
|
+
return typeof i.onResult == "function" && i.onResult(p), l === !1 ? (p.isMatch = !1, r ? p : !1) : c(n) ? (typeof i.onIgnore == "function" && i.onIgnore(p), p.isMatch = !1, r ? p : !1) : (typeof i.onMatch == "function" && i.onMatch(p), r ? p : !0);
|
|
1012
|
+
};
|
|
1013
|
+
return n && (l.state = s), l;
|
|
1014
|
+
};
|
|
1015
|
+
d.test = (e, t, n, { glob: r, posix: i } = {}) => {
|
|
1016
|
+
if (typeof e != "string") throw TypeError("Expected input to be a string");
|
|
1017
|
+
if (e === "") return {
|
|
1018
|
+
isMatch: !1,
|
|
1019
|
+
output: ""
|
|
1020
|
+
};
|
|
1021
|
+
let a = n || {}, o = a.format || (i ? c.toPosixSlashes : null), s = e === r, l = s && o ? o(e) : e;
|
|
1022
|
+
return s === !1 && (l = o ? o(e) : e, s = l === r), (s === !1 || a.capture === !0) && (s = a.matchBase === !0 || a.basename === !0 ? d.matchBase(e, t, n, i) : t.exec(l)), {
|
|
1023
|
+
isMatch: !!s,
|
|
1024
|
+
match: s,
|
|
1025
|
+
output: l
|
|
1026
|
+
};
|
|
1027
|
+
}, d.matchBase = (e, t, n) => (t instanceof RegExp ? t : d.makeRe(t, n)).test(c.basename(e)), d.isMatch = (e, t, n) => d(t, n)(e), d.parse = (e, t) => Array.isArray(e) ? e.map((e) => d.parse(e, t)) : s(e, {
|
|
1028
|
+
...t,
|
|
1029
|
+
fastpaths: !1
|
|
1030
|
+
}), d.scan = (e, t) => n(e, t), d.compileRe = (e, t, n = !1, r = !1) => {
|
|
1031
|
+
if (n === !0) return e.output;
|
|
1032
|
+
let i = t || {}, a = i.contains ? "" : "^", o = i.contains ? "" : "$", s = `${a}(?:${e.output})${o}`;
|
|
1033
|
+
e && e.negated === !0 && (s = `^(?!${s}).*$`);
|
|
1034
|
+
let c = d.toRegex(s, t);
|
|
1035
|
+
return r === !0 && (c.state = e), c;
|
|
1036
|
+
}, d.makeRe = (e, t = {}, n = !1, r = !1) => {
|
|
1037
|
+
if (!e || typeof e != "string") throw TypeError("Expected a non-empty string");
|
|
1038
|
+
let i = {
|
|
1039
|
+
negated: !1,
|
|
1040
|
+
fastpaths: !0
|
|
1041
|
+
};
|
|
1042
|
+
return t.fastpaths !== !1 && (e[0] === "." || e[0] === "*") && (i.output = s.fastpaths(e, t)), i.output || (i = s(e, t)), d.compileRe(i, t, n, r);
|
|
1043
|
+
}, d.toRegex = (e, t) => {
|
|
1044
|
+
try {
|
|
1045
|
+
let n = t || {};
|
|
1046
|
+
return new RegExp(e, n.flags || (n.nocase ? "i" : ""));
|
|
1047
|
+
} catch (e) {
|
|
1048
|
+
if (t && t.debug === !0) throw e;
|
|
1049
|
+
return /$^/;
|
|
1050
|
+
}
|
|
1051
|
+
}, d.constants = l, t.exports = d;
|
|
1052
|
+
})), c = /* @__PURE__ */ e(((e, t) => {
|
|
1053
|
+
var n = s(), r = i();
|
|
1054
|
+
function a(e, t, i = !1) {
|
|
1055
|
+
return t && (t.windows === null || t.windows === void 0) && (t = {
|
|
1056
|
+
...t,
|
|
1057
|
+
windows: r.isWindows()
|
|
1058
|
+
}), n(e, t, i);
|
|
1059
|
+
}
|
|
1060
|
+
Object.assign(a, n), t.exports = a;
|
|
1061
|
+
}));
|
|
1062
|
+
//#endregion
|
|
1063
|
+
export { c as t };
|