diff --git a/.gitattributes b/.gitattributes index 6828588eaa2fad3843e9e02dc6b26ed4a7c89387..445799fb7ceaed86142025e8c137cea17586e2ff 100644 --- a/.gitattributes +++ b/.gitattributes @@ -35,3 +35,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text *tfevents* filter=lfs diff=lfs merge=lfs -text node_modules/.bin/esbuild filter=lfs diff=lfs merge=lfs -text node_modules/@esbuild/linux-x64/bin/esbuild filter=lfs diff=lfs merge=lfs -text +node_modules/@mapbox/vector-tile/test/fixtures/14-8801-5371.vector.pbf filter=lfs diff=lfs merge=lfs -text diff --git a/node_modules/@huggingface/tasks/src/tasks/fill-mask/spec/input.json b/node_modules/@huggingface/tasks/src/tasks/fill-mask/spec/input.json new file mode 100644 index 0000000000000000000000000000000000000000..a2ebaf13e16212e29df8ec3c552071fca7d6078c --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/fill-mask/spec/input.json @@ -0,0 +1,37 @@ +{ + "$id": "/inference/schemas/fill-mask/input.json", + "$schema": "http://json-schema.org/draft-06/schema#", + "description": "Inputs for Fill Mask inference", + "title": "FillMaskInput", + "type": "object", + "properties": { + "inputs": { + "description": "The text with masked tokens", + "type": "string" + }, + "parameters": { + "description": "Additional inference parameters for Fill Mask", + "$ref": "#/$defs/FillMaskParameters" + } + }, + "$defs": { + "FillMaskParameters": { + "title": "FillMaskParameters", + "type": "object", + "properties": { + "top_k": { + "type": "integer", + "description": "When passed, overrides the number of predictions to return." + }, + "targets": { + "description": "When passed, the model will limit the scores to the passed targets instead of looking up in the whole vocabulary. If the provided targets are not in the model vocab, they will be tokenized and the first resulting token will be used (with a warning, and that might be slower).", + "type": "array", + "items": { + "type": "string" + } + } + } + } + }, + "required": ["inputs"] +} diff --git a/node_modules/@huggingface/tasks/src/tasks/fill-mask/spec/output.json b/node_modules/@huggingface/tasks/src/tasks/fill-mask/spec/output.json new file mode 100644 index 0000000000000000000000000000000000000000..0b613382e781cf0405c76df5c1f9f5091da6b196 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/fill-mask/spec/output.json @@ -0,0 +1,29 @@ +{ + "$id": "/inference/schemas/fill-mask/output.json", + "$schema": "http://json-schema.org/draft-06/schema#", + "description": "Outputs of inference for the Fill Mask task", + "title": "FillMaskOutput", + "type": "array", + "items": { + "type": "object", + "properties": { + "sequence": { + "type": "string", + "description": "The corresponding input with the mask token prediction." + }, + "score": { + "type": "number", + "description": "The corresponding probability" + }, + "token": { + "type": "integer", + "description": "The predicted token id (to replace the masked one)." + }, + "token_str": { + "type": "string", + "description": "The predicted token (to replace the masked one)." + } + }, + "required": ["sequence", "score", "token", "tokenStr"] + } +} diff --git a/node_modules/@huggingface/tasks/src/tasks/image-classification/about.md b/node_modules/@huggingface/tasks/src/tasks/image-classification/about.md new file mode 100644 index 0000000000000000000000000000000000000000..6d2b445fa62b8fcd88fb738820e0c18e327460be --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/image-classification/about.md @@ -0,0 +1,50 @@ +## Use Cases + +Image classification models can be used when we are not interested in specific instances of objects with location information or their shape. + +### Keyword Classification + +Image classification models are used widely in stock photography to assign each image a keyword. + +### Image Search + +Models trained in image classification can improve user experience by organizing and categorizing photo galleries on the phone or in the cloud, on multiple keywords or tags. + +## Inference + +With the `transformers` library, you can use the `image-classification` pipeline to infer with image classification models. You can initialize the pipeline with a model id from the Hub. If you do not provide a model id it will initialize with [google/vit-base-patch16-224](https://huggingface.co/google/vit-base-patch16-224) by default. When calling the pipeline you just need to specify a path, http link or an image loaded in PIL. You can also provide a `top_k` parameter which determines how many results it should return. + +```python +from transformers import pipeline +clf = pipeline("image-classification") +clf("path_to_a_cat_image") + +[{'label': 'tabby cat', 'score': 0.731}, +... +] +``` + +You can use [huggingface.js](https://github.com/huggingface/huggingface.js) to classify images using models on Hugging Face Hub. + +```javascript +import { InferenceClient } from "@huggingface/inference"; + +const inference = new InferenceClient(HF_TOKEN); +await inference.imageClassification({ + data: await (await fetch("https://picsum.photos/300/300")).blob(), + model: "microsoft/resnet-50", +}); +``` + +## Useful Resources + +- [Let's Play Pictionary with Machine Learning!](https://www.youtube.com/watch?v=LS9Y2wDVI0k) +- [Fine-Tune ViT for Image Classification with 🤗Transformers](https://huggingface.co/blog/fine-tune-vit) +- [Walkthrough of Computer Vision Ecosystem in Hugging Face - CV Study Group](https://www.youtube.com/watch?v=oL-xmufhZM8) +- [Computer Vision Study Group: Swin Transformer](https://www.youtube.com/watch?v=Ngikt-K1Ecc) +- [Computer Vision Study Group: Masked Autoencoders Paper Walkthrough](https://www.youtube.com/watch?v=Ngikt-K1Ecc) +- [Image classification task guide](https://huggingface.co/docs/transformers/tasks/image_classification) + +### Creating your own image classifier in just a few minutes + +With [HuggingPics](https://github.com/nateraw/huggingpics), you can fine-tune Vision Transformers for anything using images found on the web. This project downloads images of classes defined by you, trains a model, and pushes it to the Hub. You even get to try out the model directly with a working widget in the browser, ready to be shared with all your friends! diff --git a/node_modules/@huggingface/tasks/src/tasks/image-classification/data.ts b/node_modules/@huggingface/tasks/src/tasks/image-classification/data.ts new file mode 100644 index 0000000000000000000000000000000000000000..acdb201e3286a7aa3a73f1a77010e4f735696353 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/image-classification/data.ts @@ -0,0 +1,87 @@ +import type { TaskDataCustom } from "../index.js"; + +const taskData: TaskDataCustom = { + datasets: [ + { + // TODO write proper description + description: "Benchmark dataset used for image classification with images that belong to 100 classes.", + id: "cifar100", + }, + { + // TODO write proper description + description: "Dataset consisting of images of garments.", + id: "fashion_mnist", + }, + ], + demo: { + inputs: [ + { + filename: "image-classification-input.jpeg", + type: "img", + }, + ], + outputs: [ + { + type: "chart", + data: [ + { + label: "Egyptian cat", + score: 0.514, + }, + { + label: "Tabby cat", + score: 0.193, + }, + { + label: "Tiger cat", + score: 0.068, + }, + ], + }, + ], + }, + metrics: [ + { + description: "", + id: "accuracy", + }, + { + description: "", + id: "recall", + }, + { + description: "", + id: "precision", + }, + { + description: "", + id: "f1", + }, + ], + models: [ + { + description: "A strong image classification model.", + id: "google/vit-base-patch16-224", + }, + { + description: "A robust image classification model.", + id: "facebook/deit-base-distilled-patch16-224", + }, + { + description: "A strong image classification model.", + id: "facebook/convnext-large-224", + }, + ], + spaces: [ + { + description: "A leaderboard to evaluate different image classification models.", + id: "timm/leaderboard", + }, + ], + summary: + "Image classification is the task of assigning a label or class to an entire image. Images are expected to have only one class for each image. Image classification models take an image as input and return a prediction about which class the image belongs to.", + widgetModels: ["google/vit-base-patch16-224"], + youtubeId: "tjAIM7BOYhw", +}; + +export default taskData; diff --git a/node_modules/@huggingface/tasks/src/tasks/image-classification/inference.ts b/node_modules/@huggingface/tasks/src/tasks/image-classification/inference.ts new file mode 100644 index 0000000000000000000000000000000000000000..923fbfec0e7568e07918d9c650fc4dec73837b99 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/image-classification/inference.ts @@ -0,0 +1,53 @@ +/** + * Inference code generated from the JSON schema spec in ./spec + * + * Using src/scripts/inference-codegen + */ +/** + * Inputs for Image Classification inference + */ +export interface ImageClassificationInput { + /** + * The input image data as a base64-encoded string. If no `parameters` are provided, you can + * also provide the image data as a raw bytes payload. + */ + inputs: Blob; + /** + * Additional inference parameters for Image Classification + */ + parameters?: ImageClassificationParameters; + [property: string]: unknown; +} +/** + * Additional inference parameters for Image Classification + */ +export interface ImageClassificationParameters { + /** + * The function to apply to the model outputs in order to retrieve the scores. + */ + function_to_apply?: ClassificationOutputTransform; + /** + * When specified, limits the output to the top K most probable classes. + */ + top_k?: number; + [property: string]: unknown; +} +/** + * The function to apply to the model outputs in order to retrieve the scores. + */ +export type ClassificationOutputTransform = "sigmoid" | "softmax" | "none"; +export type ImageClassificationOutput = ImageClassificationOutputElement[]; +/** + * Outputs of inference for the Image Classification task + */ +export interface ImageClassificationOutputElement { + /** + * The predicted class label. + */ + label: string; + /** + * The corresponding probability. + */ + score: number; + [property: string]: unknown; +} diff --git a/node_modules/@huggingface/tasks/src/tasks/image-classification/spec/input.json b/node_modules/@huggingface/tasks/src/tasks/image-classification/spec/input.json new file mode 100644 index 0000000000000000000000000000000000000000..4942226d2963287bb4fad878b8856d37e0dde36f --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/image-classification/spec/input.json @@ -0,0 +1,36 @@ +{ + "$id": "/inference/schemas/image-classification/input.json", + "$schema": "http://json-schema.org/draft-06/schema#", + "description": "Inputs for Image Classification inference", + "title": "ImageClassificationInput", + "type": "object", + "properties": { + "inputs": { + "type": "string", + "description": "The input image data as a base64-encoded string. If no `parameters` are provided, you can also provide the image data as a raw bytes payload.", + "comment": "type=binary" + }, + "parameters": { + "description": "Additional inference parameters for Image Classification", + "$ref": "#/$defs/ImageClassificationParameters" + } + }, + "$defs": { + "ImageClassificationParameters": { + "title": "ImageClassificationParameters", + "type": "object", + "properties": { + "function_to_apply": { + "title": "ImageClassificationOutputTransform", + "$ref": "/inference/schemas/common-definitions.json#/definitions/ClassificationOutputTransform", + "description": "The function to apply to the model outputs in order to retrieve the scores." + }, + "top_k": { + "type": "integer", + "description": "When specified, limits the output to the top K most probable classes." + } + } + } + }, + "required": ["inputs"] +} diff --git a/node_modules/@huggingface/tasks/src/tasks/image-classification/spec/output.json b/node_modules/@huggingface/tasks/src/tasks/image-classification/spec/output.json new file mode 100644 index 0000000000000000000000000000000000000000..3ababaf63d47baf941b1f290891367ce2f43794f --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/image-classification/spec/output.json @@ -0,0 +1,11 @@ +{ + "$id": "/inference/schemas/image-classification/output.json", + "$schema": "http://json-schema.org/draft-06/schema#", + "description": "Outputs of inference for the Image Classification task", + "title": "ImageClassificationOutput", + "type": "array", + "items": { + "type": "object", + "$ref": "/inference/schemas/common-definitions.json#/definitions/ClassificationOutput" + } +} diff --git a/node_modules/@huggingface/tasks/src/tasks/image-feature-extraction/about.md b/node_modules/@huggingface/tasks/src/tasks/image-feature-extraction/about.md new file mode 100644 index 0000000000000000000000000000000000000000..9a968b106d527b16556f907c09e6cf67c610f7eb --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/image-feature-extraction/about.md @@ -0,0 +1,23 @@ +## Use Cases + +### Transfer Learning + +Models trained on a specific dataset can learn features about the data. For instance, a model trained on a car classification dataset learns to recognize edges and curves on a very high level and car-specific features on a low level. This information can be transferred to a new model that is going to be trained on classifying trucks. This process of extracting features and transferring to another model is called transfer learning. + +### Similarity + +Features extracted from models contain semantically meaningful information about the world. These features can be used to detect the similarity between two images. Assume there are two images: a photo of a stray cat in a street setting and a photo of a cat at home. These images both contain cats, and the features will contain the information that there's a cat in the image. Thus, comparing the features of a stray cat photo to the features of a domestic cat photo will result in higher similarity compared to any other image that doesn't contain any cats. + +## Inference + +```python +import torch +from transformers import pipeline + +pipe = pipeline(task="image-feature-extraction", model_name="google/vit-base-patch16-384", framework="pt", pool=True) +pipe("https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/cats.png") + +feature_extractor(text,return_tensors = "pt")[0].numpy().mean(axis=0) + +'[[[0.21236686408519745, 1.0919708013534546, 0.8512550592422485, ...]]]' +``` diff --git a/node_modules/@huggingface/tasks/src/tasks/image-feature-extraction/data.ts b/node_modules/@huggingface/tasks/src/tasks/image-feature-extraction/data.ts new file mode 100644 index 0000000000000000000000000000000000000000..d2565dec61e6b089fe5f62bd97f4abe36e008943 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/image-feature-extraction/data.ts @@ -0,0 +1,64 @@ +import type { TaskDataCustom } from "../index.js"; + +const taskData: TaskDataCustom = { + datasets: [ + { + description: + "ImageNet-1K is a image classification dataset in which images are used to train image-feature-extraction models.", + id: "imagenet-1k", + }, + ], + demo: { + inputs: [ + { + filename: "mask-generation-input.png", + type: "img", + }, + ], + outputs: [ + { + table: [ + ["Dimension 1", "Dimension 2", "Dimension 3"], + ["0.21236686408519745", "1.0919708013534546", "0.8512550592422485"], + ["0.809657871723175", "-0.18544459342956543", "-0.7851548194885254"], + ["1.3103108406066895", "-0.2479034662246704", "-0.9107287526130676"], + ["1.8536205291748047", "-0.36419737339019775", "0.09717650711536407"], + ], + type: "tabular", + }, + ], + }, + metrics: [], + models: [ + { + description: "A powerful image feature extraction model.", + id: "timm/vit_large_patch14_dinov2.lvd142m", + }, + { + description: "A strong image feature extraction model.", + id: "nvidia/MambaVision-T-1K", + }, + { + description: "A robust image feature extraction model.", + id: "facebook/dino-vitb16", + }, + { + description: "Cutting-edge image feature extraction model.", + id: "apple/aimv2-large-patch14-336-distilled", + }, + { + description: "Strong image feature extraction model that can be used on images and documents.", + id: "OpenGVLab/InternViT-6B-448px-V1-2", + }, + ], + spaces: [ + { + description: "A leaderboard to evaluate different image-feature-extraction models on classification performances", + id: "timm/leaderboard", + }, + ], + summary: "Image feature extraction is the task of extracting features learnt in a computer vision model.", + widgetModels: [], +}; + +export default taskData; diff --git a/node_modules/@huggingface/tasks/src/tasks/image-segmentation/about.md b/node_modules/@huggingface/tasks/src/tasks/image-segmentation/about.md new file mode 100644 index 0000000000000000000000000000000000000000..18af58ad8628bd12e4c16f9f3f17667fe1821414 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/image-segmentation/about.md @@ -0,0 +1,63 @@ +## Use Cases + +### Autonomous Driving + +Segmentation models are used to identify road patterns such as lanes and obstacles for safer driving. + +### Background Removal + +Image Segmentation models are used in cameras to erase the background of certain objects and apply filters to them. + +### Medical Imaging + +Image Segmentation models are used to distinguish organs or tissues, improving medical imaging workflows. Models are used to segment dental instances, analyze X-Ray scans or even segment cells for pathological diagnosis. This [dataset](https://github.com/v7labs/covid-19-xray-dataset) contains images of lungs of healthy patients and patients with COVID-19 segmented with masks. Another [segmentation dataset](https://ivdm3seg.weebly.com/data.html) contains segmented MRI data of the lower spine to analyze the effect of spaceflight simulation. + +## Task Variants + +### Semantic Segmentation + +Semantic Segmentation is the task of segmenting parts of an image that belong to the same class. Semantic Segmentation models make predictions for each pixel and return the probabilities of the classes for each pixel. These models are evaluated on Mean Intersection Over Union (Mean IoU). + +### Instance Segmentation + +Instance Segmentation is the variant of Image Segmentation where every distinct object is segmented, instead of one segment per class. + +### Panoptic Segmentation + +Panoptic Segmentation is the Image Segmentation task that segments the image both by instance and by class, assigning each pixel a different instance of the class. + +## Inference + +You can infer with Image Segmentation models using the `image-segmentation` pipeline. You need to install [timm](https://github.com/rwightman/pytorch-image-models) first. + +```python +!pip install timm +model = pipeline("image-segmentation") +model("cat.png") +#[{'label': 'cat', +# 'mask': mask_code, +# 'score': 0.999} +# ...] +``` + +You can use [huggingface.js](https://github.com/huggingface/huggingface.js) to infer image segmentation models on Hugging Face Hub. + +```javascript +import { InferenceClient } from "@huggingface/inference"; + +const inference = new InferenceClient(HF_TOKEN); +await inference.imageSegmentation({ + data: await (await fetch("https://picsum.photos/300/300")).blob(), + model: "facebook/mask2former-swin-base-coco-panoptic", +}); +``` + +## Useful Resources + +Would you like to learn more about image segmentation? Great! Here you can find some curated resources that you may find helpful! + +- [Fine-Tune a Semantic Segmentation Model with a Custom Dataset](https://huggingface.co/blog/fine-tune-segformer) +- [Walkthrough of Computer Vision Ecosystem in Hugging Face - CV Study Group](https://www.youtube.com/watch?v=oL-xmufhZM8) +- [A Guide on Universal Image Segmentation with Mask2Former and OneFormer](https://huggingface.co/blog/mask2former) +- [Zero-shot image segmentation with CLIPSeg](https://huggingface.co/blog/clipseg-zero-shot) +- [Semantic segmentation task guide](https://huggingface.co/docs/transformers/tasks/semantic_segmentation) diff --git a/node_modules/@huggingface/tasks/src/tasks/image-segmentation/data.ts b/node_modules/@huggingface/tasks/src/tasks/image-segmentation/data.ts new file mode 100644 index 0000000000000000000000000000000000000000..c34481f9acf7c67ecd9cf6700a4858de83340c98 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/image-segmentation/data.ts @@ -0,0 +1,99 @@ +import type { TaskDataCustom } from "../index.js"; + +const taskData: TaskDataCustom = { + datasets: [ + { + description: "Scene segmentation dataset.", + id: "scene_parse_150", + }, + ], + demo: { + inputs: [ + { + filename: "image-segmentation-input.jpeg", + type: "img", + }, + ], + outputs: [ + { + filename: "image-segmentation-output.png", + type: "img", + }, + ], + }, + metrics: [ + { + description: + "Average Precision (AP) is the Area Under the PR Curve (AUC-PR). It is calculated for each semantic class separately", + id: "Average Precision", + }, + { + description: "Mean Average Precision (mAP) is the overall average of the AP values", + id: "Mean Average Precision", + }, + { + description: + "Intersection over Union (IoU) is the overlap of segmentation masks. Mean IoU is the average of the IoU of all semantic classes", + id: "Mean Intersection over Union", + }, + { + description: "APα is the Average Precision at the IoU threshold of a α value, for example, AP50 and AP75", + id: "APα", + }, + ], + models: [ + { + // TO DO: write description + description: "Solid panoptic segmentation model trained on COCO.", + id: "tue-mps/coco_panoptic_eomt_large_640", + }, + { + description: "Background removal model.", + id: "briaai/RMBG-1.4", + }, + { + description: "A multipurpose image segmentation model for high resolution images.", + id: "ZhengPeng7/BiRefNet", + }, + { + description: "Powerful human-centric image segmentation model.", + id: "facebook/sapiens-seg-1b", + }, + { + description: "Panoptic segmentation model trained on the COCO (common objects) dataset.", + id: "facebook/mask2former-swin-large-coco-panoptic", + }, + ], + spaces: [ + { + description: "A semantic segmentation application that can predict unseen instances out of the box.", + id: "facebook/ov-seg", + }, + { + description: "One of the strongest segmentation applications.", + id: "jbrinkma/segment-anything", + }, + { + description: "A human-centric segmentation model.", + id: "facebook/sapiens-pose", + }, + { + description: "An instance segmentation application to predict neuronal cell types from microscopy images.", + id: "rashmi/sartorius-cell-instance-segmentation", + }, + { + description: "An application that segments videos.", + id: "ArtGAN/Segment-Anything-Video", + }, + { + description: "An panoptic segmentation application built for outdoor environments.", + id: "segments/panoptic-segment-anything", + }, + ], + summary: + "Image Segmentation divides an image into segments where each pixel in the image is mapped to an object. This task has multiple variants such as instance segmentation, panoptic segmentation and semantic segmentation.", + widgetModels: ["nvidia/segformer-b0-finetuned-ade-512-512"], + youtubeId: "dKE8SIt9C-w", +}; + +export default taskData; diff --git a/node_modules/@huggingface/tasks/src/tasks/image-segmentation/inference.ts b/node_modules/@huggingface/tasks/src/tasks/image-segmentation/inference.ts new file mode 100644 index 0000000000000000000000000000000000000000..72db730745c3ce37b2bfe38f211c5620c9feb8f8 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/image-segmentation/inference.ts @@ -0,0 +1,67 @@ +/** + * Inference code generated from the JSON schema spec in ./spec + * + * Using src/scripts/inference-codegen + */ +/** + * Inputs for Image Segmentation inference + */ +export interface ImageSegmentationInput { + /** + * The input image data as a base64-encoded string. If no `parameters` are provided, you can + * also provide the image data as a raw bytes payload. + */ + inputs: Blob; + /** + * Additional inference parameters for Image Segmentation + */ + parameters?: ImageSegmentationParameters; + [property: string]: unknown; +} +/** + * Additional inference parameters for Image Segmentation + */ +export interface ImageSegmentationParameters { + /** + * Threshold to use when turning the predicted masks into binary values. + */ + mask_threshold?: number; + /** + * Mask overlap threshold to eliminate small, disconnected segments. + */ + overlap_mask_area_threshold?: number; + /** + * Segmentation task to be performed, depending on model capabilities. + */ + subtask?: ImageSegmentationSubtask; + /** + * Probability threshold to filter out predicted masks. + */ + threshold?: number; + [property: string]: unknown; +} +/** + * Segmentation task to be performed, depending on model capabilities. + */ +export type ImageSegmentationSubtask = "instance" | "panoptic" | "semantic"; +export type ImageSegmentationOutput = ImageSegmentationOutputElement[]; +/** + * Outputs of inference for the Image Segmentation task + * + * A predicted mask / segment + */ +export interface ImageSegmentationOutputElement { + /** + * The label of the predicted segment. + */ + label: string; + /** + * The corresponding mask as a black-and-white image (base64-encoded). + */ + mask: string; + /** + * The score or confidence degree the model has. + */ + score?: number; + [property: string]: unknown; +} diff --git a/node_modules/@huggingface/tasks/src/tasks/image-segmentation/spec/input.json b/node_modules/@huggingface/tasks/src/tasks/image-segmentation/spec/input.json new file mode 100644 index 0000000000000000000000000000000000000000..afc40ad2db5c70d8234cfa8063be31669e9a4b7b --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/image-segmentation/spec/input.json @@ -0,0 +1,45 @@ +{ + "$id": "/inference/schemas/image-segmentation/input.json", + "$schema": "http://json-schema.org/draft-06/schema#", + "description": "Inputs for Image Segmentation inference", + "title": "ImageSegmentationInput", + "type": "object", + "properties": { + "inputs": { + "type": "string", + "description": "The input image data as a base64-encoded string. If no `parameters` are provided, you can also provide the image data as a raw bytes payload.", + "comment": "type=binary" + }, + "parameters": { + "description": "Additional inference parameters for Image Segmentation", + "$ref": "#/$defs/ImageSegmentationParameters" + } + }, + "$defs": { + "ImageSegmentationParameters": { + "title": "ImageSegmentationParameters", + "type": "object", + "properties": { + "mask_threshold": { + "type": "number", + "description": "Threshold to use when turning the predicted masks into binary values." + }, + "overlap_mask_area_threshold": { + "type": "number", + "description": "Mask overlap threshold to eliminate small, disconnected segments." + }, + "subtask": { + "title": "ImageSegmentationSubtask", + "type": "string", + "description": "Segmentation task to be performed, depending on model capabilities.", + "enum": ["instance", "panoptic", "semantic"] + }, + "threshold": { + "type": "number", + "description": "Probability threshold to filter out predicted masks." + } + } + } + }, + "required": ["inputs"] +} diff --git a/node_modules/@huggingface/tasks/src/tasks/image-segmentation/spec/output.json b/node_modules/@huggingface/tasks/src/tasks/image-segmentation/spec/output.json new file mode 100644 index 0000000000000000000000000000000000000000..6fa5b0d8e83ad97a63f6dc2da6588ccc5bd58097 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/image-segmentation/spec/output.json @@ -0,0 +1,26 @@ +{ + "$id": "/inference/schemas/image-segmentation/output.json", + "$schema": "http://json-schema.org/draft-06/schema#", + "description": "Outputs of inference for the Image Segmentation task", + "title": "ImageSegmentationOutput", + "type": "array", + "items": { + "description": "A predicted mask / segment", + "type": "object", + "properties": { + "label": { + "type": "string", + "description": "The label of the predicted segment." + }, + "mask": { + "type": "string", + "description": "The corresponding mask as a black-and-white image (base64-encoded)." + }, + "score": { + "type": "number", + "description": "The score or confidence degree the model has." + } + }, + "required": ["label", "mask"] + } +} diff --git a/node_modules/@huggingface/tasks/src/tasks/image-text-to-image/about.md b/node_modules/@huggingface/tasks/src/tasks/image-text-to-image/about.md new file mode 100644 index 0000000000000000000000000000000000000000..c05a81fceaa340b66faf52732d1f4926a4e803e4 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/image-text-to-image/about.md @@ -0,0 +1,73 @@ +## Use Cases + +### Instruction-based Image Editing + +Image-text-to-image models can be used to edit images based on natural language instructions. For example, you can provide an image of a summer landscape and the instruction "Make it winter, add snow" to generate a winter version of the same scene. + +### Style Transfer + +These models can apply artistic styles or transformations to images based on text descriptions. For instance, you can transform a photo into a painting style by providing prompts like "Make it look like a Van Gogh painting" or "Convert to watercolor style." + +### Image Variations + +Generate variations of an existing image by providing different text prompts. This is useful for creative workflows where you want to explore different versions of the same image with specific modifications. + +### Guided Image Generation + +Use a reference image along with text prompts to guide the generation process. This allows for more controlled image generation compared to text-to-image models alone, as the reference image provides structural guidance. + +### Image Inpainting and Outpainting + +Fill in missing or masked parts of an image based on text descriptions, or extend an image beyond its original boundaries with text-guided generation. + +## Task Variants + +### Instruction-based Editing + +Models that follow natural language instructions to edit images, which can perform complex edits like object removal, color changes, and compositional modifications. + +### Reference-guided Generation + +Models that use a reference image to guide the generation process while incorporating text prompts to control specific attributes or modifications. + +### Conditional Image-to-Image + +Models that perform specific transformations based on text conditions, such as changing weather conditions, time of day, or seasonal variations. + +## Inference + +You can use the Diffusers library to interact with image-text-to-image models. + +```python +import torch +from diffusers import Flux2Pipeline +from diffusers.utils import load_image + +repo_id = "black-forest-labs/FLUX.2-dev" +device = "cuda:0" +torch_dtype = torch.bfloat16 + +pipe = Flux2Pipeline.from_pretrained( + repo_id, torch_dtype=torch_dtype +) +pipe.enable_model_cpu_offload() #no need to do cpu offload for >80G VRAM carts like H200, B200, etc. and do a `pipe.to(device)` instead + +prompt = "Realistic macro photograph of a hermit crab using a soda can as its shell, partially emerging from the can, captured with sharp detail and natural colors, on a sunlit beach with soft shadows and a shallow depth of field, with blurred ocean waves in the background. The can has the text `BFL Diffusers` on it and it has a color gradient that start with #FF5733 at the top and transitions to #33FF57 at the bottom." + +#cat_image = load_image("https://huggingface.co/spaces/zerogpu-aoti/FLUX.1-Kontext-Dev-fp8-dynamic/resolve/main/cat.png") +image = pipe( + prompt=prompt, + #image=[cat_image] #multi-image input + generator=torch.Generator(device=device).manual_seed(42), + num_inference_steps=50, + guidance_scale=4, +).images[0] + +image.save("flux2_output.png") +``` + +## Useful Resources + +- [FLUX.2 Model Card](https://huggingface.co/black-forest-labs/FLUX.2-dev) +- [Diffusers documentation on Image-to-Image](https://huggingface.co/docs/diffusers/using-diffusers/img2img) +- [ControlNet for Conditional Image Generation](https://huggingface.co/docs/diffusers/using-diffusers/controlnet) diff --git a/node_modules/@huggingface/tasks/src/tasks/image-text-to-image/data.ts b/node_modules/@huggingface/tasks/src/tasks/image-text-to-image/data.ts new file mode 100644 index 0000000000000000000000000000000000000000..f45410e91cddf0bca75166f449d8b4c17317281d --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/image-text-to-image/data.ts @@ -0,0 +1,54 @@ +import type { TaskDataCustom } from "../index.js"; + +const taskData: TaskDataCustom = { + datasets: [], + demo: { + inputs: [ + { + filename: "image-text-to-image-input.jpeg", + type: "img", + }, + { + label: "Input", + content: "A city above clouds, pastel colors, Victorian style", + type: "text", + }, + ], + outputs: [ + { + filename: "image-text-to-image-output.png", + type: "img", + }, + ], + }, + metrics: [ + { + description: + "The Fréchet Inception Distance (FID) calculates the distance between distributions between synthetic and real samples. A lower FID score indicates better similarity between the distributions of real and generated images.", + id: "FID", + }, + { + description: + "CLIP Score measures the similarity between the generated image and the text prompt using CLIP embeddings. A higher score indicates better alignment with the text prompt.", + id: "CLIP", + }, + ], + models: [ + { + description: "A powerful model for image-text-to-image generation.", + id: "black-forest-labs/FLUX.2-dev", + }, + ], + spaces: [ + { + description: "An application for image-text-to-image generation.", + id: "black-forest-labs/FLUX.2-dev", + }, + ], + summary: + "Image-text-to-image models take an image and a text prompt as input and generate a new image based on the reference image and text instructions. These models are useful for image editing, style transfer, image variations, and guided image generation tasks.", + widgetModels: ["black-forest-labs/FLUX.2-dev"], + youtubeId: undefined, +}; + +export default taskData; diff --git a/node_modules/@huggingface/tasks/src/tasks/image-text-to-image/inference.ts b/node_modules/@huggingface/tasks/src/tasks/image-text-to-image/inference.ts new file mode 100644 index 0000000000000000000000000000000000000000..549b0f4118b8c142a22adfdb950d8947c4d3c4be --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/image-text-to-image/inference.ts @@ -0,0 +1,75 @@ +/** + * Inference code generated from the JSON schema spec in ./spec + * + * Using src/scripts/inference-codegen + */ +/** + * Inputs for Image Text To Image inference. Either inputs (image) or prompt (in parameters) + * must be provided, or both. + */ +export interface ImageTextToImageInput { + /** + * The input image data as a base64-encoded string. If no `parameters` are provided, you can + * also provide the image data as a raw bytes payload. Either this or prompt must be + * provided. + */ + inputs?: Blob; + /** + * Additional inference parameters for Image Text To Image + */ + parameters?: ImageTextToImageParameters; + [property: string]: unknown; +} +/** + * Additional inference parameters for Image Text To Image + */ +export interface ImageTextToImageParameters { + /** + * For diffusion models. A higher guidance scale value encourages the model to generate + * images closely linked to the text prompt at the expense of lower image quality. + */ + guidance_scale?: number; + /** + * One prompt to guide what NOT to include in image generation. + */ + negative_prompt?: string; + /** + * For diffusion models. The number of denoising steps. More denoising steps usually lead to + * a higher quality image at the expense of slower inference. + */ + num_inference_steps?: number; + /** + * The text prompt to guide the image generation. Either this or inputs (image) must be + * provided. + */ + prompt?: string; + /** + * Seed for the random number generator. + */ + seed?: number; + /** + * The size in pixels of the output image. This parameter is only supported by some + * providers and for specific models. It will be ignored when unsupported. + */ + target_size?: TargetSize; + [property: string]: unknown; +} +/** + * The size in pixels of the output image. This parameter is only supported by some + * providers and for specific models. It will be ignored when unsupported. + */ +export interface TargetSize { + height: number; + width: number; + [property: string]: unknown; +} +/** + * Outputs of inference for the Image Text To Image task + */ +export interface ImageTextToImageOutput { + /** + * The generated image returned as raw bytes in the payload. + */ + image: unknown; + [property: string]: unknown; +} diff --git a/node_modules/@huggingface/tasks/src/tasks/image-text-to-image/spec/input.json b/node_modules/@huggingface/tasks/src/tasks/image-text-to-image/spec/input.json new file mode 100644 index 0000000000000000000000000000000000000000..259353e337d7db9d6b479eb7e5f91f7df8364e2c --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/image-text-to-image/spec/input.json @@ -0,0 +1,59 @@ +{ + "$id": "/inference/schemas/image-text-to-image/input.json", + "$schema": "http://json-schema.org/draft-06/schema#", + "description": "Inputs for Image Text To Image inference. Either inputs (image) or prompt (in parameters) must be provided, or both.", + "title": "ImageTextToImageInput", + "type": "object", + "properties": { + "inputs": { + "type": "string", + "description": "The input image data as a base64-encoded string. If no `parameters` are provided, you can also provide the image data as a raw bytes payload. Either this or prompt must be provided.", + "comment": "type=binary" + }, + "parameters": { + "description": "Additional inference parameters for Image Text To Image", + "$ref": "#/$defs/ImageTextToImageParameters" + } + }, + "$defs": { + "ImageTextToImageParameters": { + "title": "ImageTextToImageParameters", + "type": "object", + "properties": { + "prompt": { + "type": "string", + "description": "The text prompt to guide the image generation. Either this or inputs (image) must be provided." + }, + "guidance_scale": { + "type": "number", + "description": "For diffusion models. A higher guidance scale value encourages the model to generate images closely linked to the text prompt at the expense of lower image quality." + }, + "negative_prompt": { + "type": "string", + "description": "One prompt to guide what NOT to include in image generation." + }, + "num_inference_steps": { + "type": "integer", + "description": "For diffusion models. The number of denoising steps. More denoising steps usually lead to a higher quality image at the expense of slower inference." + }, + "target_size": { + "type": "object", + "description": "The size in pixels of the output image. This parameter is only supported by some providers and for specific models. It will be ignored when unsupported.", + "properties": { + "width": { + "type": "integer" + }, + "height": { + "type": "integer" + } + }, + "required": ["width", "height"] + }, + "seed": { + "type": "integer", + "description": "Seed for the random number generator." + } + } + } + } +} diff --git a/node_modules/@huggingface/tasks/src/tasks/image-text-to-image/spec/output.json b/node_modules/@huggingface/tasks/src/tasks/image-text-to-image/spec/output.json new file mode 100644 index 0000000000000000000000000000000000000000..f5b782b6253ee6b9f35f1f4acc2d6513d03ce135 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/image-text-to-image/spec/output.json @@ -0,0 +1,13 @@ +{ + "$id": "/inference/schemas/image-text-to-image/output.json", + "$schema": "http://json-schema.org/draft-06/schema#", + "description": "Outputs of inference for the Image Text To Image task", + "title": "ImageTextToImageOutput", + "type": "object", + "properties": { + "image": { + "description": "The generated image returned as raw bytes in the payload." + } + }, + "required": ["image"] +} diff --git a/node_modules/@huggingface/tasks/src/tasks/image-text-to-text/about.md b/node_modules/@huggingface/tasks/src/tasks/image-text-to-text/about.md new file mode 100644 index 0000000000000000000000000000000000000000..8595509bb4cc7f85bf3a7d91d668e79e3e41367c --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/image-text-to-text/about.md @@ -0,0 +1,94 @@ +## Different Types of Vision Language Models + +Vision language models come in three types: + +- **Base:** Pre-trained models that can be fine-tuned. A good example of base models is the [PaliGemma models family](https://huggingface.co/models?sort=trending&search=google%2Fpaligemma-3b-pt) by Google. +- **Instruction:** Base models fine-tuned on instruction datasets. A good example of instruction fine-tuned models is [idefics2-8b](https://huggingface.co/HuggingFaceM4/idefics2-8b). +- **Chatty/Conversational:** Base models fine-tuned on conversation datasets. A good example of chatty models is [deepseek-vl-7b-chat](https://huggingface.co/deepseek-ai/deepseek-vl-7b-chat). + +![VLM uses](https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/blog/vlm/visual.jpg) + +## Use Cases + +### Multimodal Dialogue + +Vision language models can be used as multimodal assistants, keeping context about the conversation and keeping the image to have multiple-turn dialogues. + +### Zero-shot Object Detection, Image Segmentation and Localization + +Some vision language models can detect or segment a set of objects or describe the positions or relative positions of the objects. For example, one could prompt such a model to ask if one object is behind another. Such a model can also output bounding box coordination or segmentation masks directly in the text output, unlike the traditional models explicitly trained on only object detection or image segmentation. + +### Visual Question Answering + +Vision language models trained on image-text pairs can be used for visual question answering and generating captions for images. + +### Document Question Answering and Retrieval + +Documents often consist of different layouts, charts, tables, images, and more. Vision language models trained on formatted documents can extract information from them. This is an OCR-free approach; the inputs skip OCR, and documents are directly fed to vision language models. To find the relevant documents to be fed, models like [ColPali](https://huggingface.co/blog/manu/colpali) are used. An example workflow can be found [here](https://github.com/merveenoyan/smol-vision/blob/main/ColPali_%2B_Qwen2_VL.ipynb). + +### Image Recognition with Instructions + +Vision language models can recognize images through descriptions. When given detailed descriptions of specific entities, it can classify the entities in an image. + +### Computer Use + +Image-text-to-text models can be used to control computers with agentic workflows. Models like [ShowUI](https://huggingface.co/showlab/ShowUI-2B) and [OmniParser](https://huggingface.co/microsoft/OmniParser) are used to parse screenshots to later take actions on the computer autonomously. + +## Inference + +You can use the Transformers library to interact with [vision-language models](https://huggingface.co/models?pipeline_tag=image-text-to-text&transformers). Specifically, `pipeline` makes it easy to infer models. + +Initialize the pipeline first. + +```python +from transformers import pipeline + +pipe = pipeline("image-text-to-text", model="llava-hf/llava-interleave-qwen-0.5b-hf") +``` + +The model's built-in chat template will be used to format the conversational input. We can pass the image as an URL in the `content` part of the user message: + +```python +messages = [ + { + "role": "user", + "content": [ + { + "type": "image", + "image": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/bee.jpg", + }, + {"type": "text", "text": "Describe this image."}, + ], + } + ] + +``` + +We can now directly pass in the messages to the pipeline to infer. The `return_full_text` flag is used to return the full prompt in the response, including the user input. Here we pass `False` to only return the generated text. + +```python +outputs = pipe(text=messages, max_new_tokens=60, return_full_text=False) + +outputs[0]["generated_text"] +# The image captures a moment of tranquility in nature. At the center of the frame, a pink flower with a yellow center is in full bloom. The flower is surrounded by a cluster of red flowers, their vibrant color contrasting with the pink of the flower. \n\nA black and yellow bee is per +``` + +You can also use the Inference API to test image-text-to-text models. You need to use a [Hugging Face token](https://huggingface.co/settings/tokens) for authentication. + +```bash +curl https://router.huggingface.co/hf-inference/models/meta-llama/Llama-3.2-11B-Vision-Instruct \ + -X POST \ + -d '{"messages": [{"role": "user","content": [{"type": "image"}, {"type": "text", "text": "Can you describe the image?"}]}]}' \ + -H "Content-Type: application/json" \ + -H "Authorization: Bearer hf_***" +``` + +## Useful Resources + +- [Vision Language Models (Better, Faster, Stronger)](https://huggingface.co/blog/vlms-2025) +- [Vision Language Models Explained](https://huggingface.co/blog/vlms) +- [Welcome PaliGemma 2 – New vision language models by Google](https://huggingface.co/blog/paligemma2) +- [SmolVLM - small yet mighty Vision Language Model](https://huggingface.co/blog/smolvlm) +- [Multimodal RAG using ColPali and Qwen2-VL](https://github.com/merveenoyan/smol-vision/blob/main/ColPali_%2B_Qwen2_VL.ipynb) +- [Preference Optimization for Vision Language Models with TRL](https://huggingface.co/blog/dpo_vlm) +- [Image-text-to-text task guide](https://huggingface.co/docs/transformers/tasks/image_text_to_text) diff --git a/node_modules/@huggingface/tasks/src/tasks/image-text-to-text/data.ts b/node_modules/@huggingface/tasks/src/tasks/image-text-to-text/data.ts new file mode 100644 index 0000000000000000000000000000000000000000..c1fbaed2dcf9c1fe15621f494e0814370ab281b6 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/image-text-to-text/data.ts @@ -0,0 +1,86 @@ +import type { TaskDataCustom } from "../index.js"; + +const taskData: TaskDataCustom = { + datasets: [ + { + description: "Instructions composed of image and text.", + id: "liuhaotian/LLaVA-Instruct-150K", + }, + { + description: "Collection of image-text pairs on scientific topics.", + id: "DAMO-NLP-SG/multimodal_textbook", + }, + { + description: "A collection of datasets made for model fine-tuning.", + id: "HuggingFaceM4/the_cauldron", + }, + { + description: "Screenshots of websites with their HTML/CSS codes.", + id: "HuggingFaceM4/WebSight", + }, + ], + demo: { + inputs: [ + { + filename: "image-text-to-text-input.png", + type: "img", + }, + { + label: "Text Prompt", + content: "Describe the position of the bee in detail.", + type: "text", + }, + ], + outputs: [ + { + label: "Answer", + content: + "The bee is sitting on a pink flower, surrounded by other flowers. The bee is positioned in the center of the flower, with its head and front legs sticking out.", + type: "text", + }, + ], + }, + metrics: [], + models: [ + { + description: "Small and efficient yet powerful vision language model.", + id: "HuggingFaceTB/SmolVLM-Instruct", + }, + { + description: "Cutting-edge reasoning vision language model.", + id: "zai-org/GLM-4.5V", + }, + { + description: "Cutting-edge small vision language model to convert documents to text.", + id: "rednote-hilab/dots.ocr", + }, + { + description: "Small yet powerful model.", + id: "Qwen/Qwen2.5-VL-3B-Instruct", + }, + { + description: "Image-text-to-text model with agentic capabilities.", + id: "microsoft/Magma-8B", + }, + ], + spaces: [ + { + description: "Leaderboard to evaluate vision language models.", + id: "opencompass/open_vlm_leaderboard", + }, + { + description: "An application that compares object detection capabilities of different vision language models.", + id: "sergiopaniego/vlm_object_understanding", + }, + { + description: "An application to compare different OCR models.", + id: "prithivMLmods/Multimodal-OCR", + }, + ], + summary: + "Image-text-to-text models take in an image and text prompt and output text. These models are also called vision-language models, or VLMs. The difference from image-to-text models is that these models take an additional text input, not restricting the model to certain use cases like image captioning, and may also be trained to accept a conversation as input.", + widgetModels: ["zai-org/GLM-4.5V"], + youtubeId: "IoGaGfU1CIg", +}; + +export default taskData; diff --git a/node_modules/@huggingface/tasks/src/tasks/image-text-to-video/about.md b/node_modules/@huggingface/tasks/src/tasks/image-text-to-video/about.md new file mode 100644 index 0000000000000000000000000000000000000000..0119b6a5171c4b236778b70863ef8df81bf18408 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/image-text-to-video/about.md @@ -0,0 +1,71 @@ +## Use Cases + +### Image Animation + +Image-text-to-video models can be used to animate still images based on text descriptions. For example, you can provide a landscape photo and the instruction "A camera pan from left to right" to create a video with camera movement. + +### Dynamic Content Creation + +Transform images into video by adding motion, transformations, or effects described in text prompts. This is useful for creating engaging social media content, presentations, or marketing materials. + +### Guided Video Generation + +Use a reference image with text prompts to guide the video generation process. This provides more control over the visual style and composition compared to text-to-video models alone. + +### Story Visualization + +Create video sequences from storyboards or concept art by providing scene descriptions. This can help filmmakers and animators visualize scenes before production. + +### Motion Control + +Generate videos with specific camera movements, object motions, or scene transitions by combining reference images with detailed motion descriptions. + +## Task Variants + +### Image-to-Video with Motion Control + +Models that generate videos from images while following specific motion instructions, such as camera movements, object animations, or scene dynamics. + +### Reference-guided Video Generation + +Models that use a reference image to guide the visual style and composition of the generated video while incorporating text prompts for motion and transformation control. + +### Conditional Video Synthesis + +Models that perform specific video transformations based on text conditions, such as adding weather effects, time-of-day changes, or environmental animations. + +## Inference + +You can use the Diffusers library to interact with image-text-to-video models. Here's example snippet to use `LTXImageToVideoPipeline`. + +```python +import torch +from diffusers import LTXImageToVideoPipeline +from diffusers.utils import export_to_video, load_image + +pipe = LTXImageToVideoPipeline.from_pretrained("Lightricks/LTX-Video", torch_dtype=torch.bfloat16) +pipe.to("cuda") + +image = load_image( + "https://huggingface.co/datasets/a-r-r-o-w/tiny-meme-dataset-captioned/resolve/main/images/8.png" +) +prompt = "A young girl stands calmly in the foreground, looking directly at the camera, as a house fire rages in the background. Flames engulf the structure, with smoke billowing into the air. Firefighters in protective gear rush to the scene, a fire truck labeled '38' visible behind them. The girl's neutral expression contrasts sharply with the chaos of the fire, creating a poignant and emotionally charged scene." +negative_prompt = "worst quality, inconsistent motion, blurry, jittery, distorted" + +video = pipe( + image=image, + prompt=prompt, + negative_prompt=negative_prompt, + width=704, + height=480, + num_frames=161, + num_inference_steps=50, +).frames[0] +export_to_video(video, "output.mp4", fps=24) +``` + +## Useful Resources + +- [LTX-Video Model Card](https://huggingface.co/Lightricks/LTX-Video) +- [Text-to-Video: The Task, Challenges and the Current State](https://huggingface.co/blog/text-to-video) +- [Diffusers documentation on Video Generation](https://huggingface.co/docs/diffusers/using-diffusers/text-img2vid) diff --git a/node_modules/@huggingface/tasks/src/tasks/image-text-to-video/data.ts b/node_modules/@huggingface/tasks/src/tasks/image-text-to-video/data.ts new file mode 100644 index 0000000000000000000000000000000000000000..ded013562dad10c8043ee4108d2f5a6ad9c006a4 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/image-text-to-video/data.ts @@ -0,0 +1,54 @@ +import type { TaskDataCustom } from "../index.js"; + +const taskData: TaskDataCustom = { + datasets: [], + demo: { + inputs: [ + { + filename: "image-text-to-video-input.jpg", + type: "img", + }, + { + label: "Input", + content: "Darth Vader is surfing on the waves.", + type: "text", + }, + ], + outputs: [ + { + filename: "image-text-to-video-output.gif", + type: "img", + }, + ], + }, + metrics: [ + { + description: + "Frechet Video Distance uses a model that captures coherence for changes in frames and the quality of each frame. A smaller score indicates better video generation.", + id: "fvd", + }, + { + description: + "CLIPSIM measures similarity between video frames and text using an image-text similarity model. A higher score indicates better video generation.", + id: "clipsim", + }, + ], + models: [ + { + description: "A powerful model for image-text-to-video generation.", + id: "Lightricks/LTX-Video", + }, + ], + spaces: [ + { + description: "An application for image-text-to-video generation.", + id: "Lightricks/ltx-video-distilled", + }, + ], + summary: + "Image-text-to-video models take an reference image and a text instructions as and generate a video based on them. These models are useful for animating still images, creating dynamic content from static references, and generating videos with specific motion or transformation guidance.", + widgetModels: ["Lightricks/LTX-Video"], + youtubeId: undefined, +}; + +export default taskData; diff --git a/node_modules/@huggingface/tasks/src/tasks/image-text-to-video/inference.ts b/node_modules/@huggingface/tasks/src/tasks/image-text-to-video/inference.ts new file mode 100644 index 0000000000000000000000000000000000000000..ad048a7bc955b04fe119fd09461190eb4aa2a3df --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/image-text-to-video/inference.ts @@ -0,0 +1,77 @@ +/** + * Inference code generated from the JSON schema spec in ./spec + * + * Using src/scripts/inference-codegen + */ +/** + * Inputs for Image Text To Video inference. Either inputs (image) or prompt (in parameters) + * must be provided, or both. + */ +export interface ImageTextToVideoInput { + /** + * The input image data as a base64-encoded string. If no `parameters` are provided, you can + * also provide the image data as a raw bytes payload. Either this or prompt must be + * provided. + */ + inputs?: Blob; + /** + * Additional inference parameters for Image Text To Video + */ + parameters?: ImageTextToVideoParameters; + [property: string]: unknown; +} +/** + * Additional inference parameters for Image Text To Video + */ +export interface ImageTextToVideoParameters { + /** + * For diffusion models. A higher guidance scale value encourages the model to generate + * videos closely linked to the text prompt at the expense of lower image quality. + */ + guidance_scale?: number; + /** + * One prompt to guide what NOT to include in video generation. + */ + negative_prompt?: string; + /** + * The num_frames parameter determines how many video frames are generated. + */ + num_frames?: number; + /** + * The number of denoising steps. More denoising steps usually lead to a higher quality + * video at the expense of slower inference. + */ + num_inference_steps?: number; + /** + * The text prompt to guide the video generation. Either this or inputs (image) must be + * provided. + */ + prompt?: string; + /** + * Seed for the random number generator. + */ + seed?: number; + /** + * The size in pixel of the output video frames. + */ + target_size?: TargetSize; + [property: string]: unknown; +} +/** + * The size in pixel of the output video frames. + */ +export interface TargetSize { + height: number; + width: number; + [property: string]: unknown; +} +/** + * Outputs of inference for the Image Text To Video task + */ +export interface ImageTextToVideoOutput { + /** + * The generated video returned as raw bytes in the payload. + */ + video: unknown; + [property: string]: unknown; +} diff --git a/node_modules/@huggingface/tasks/src/tasks/image-text-to-video/spec/input.json b/node_modules/@huggingface/tasks/src/tasks/image-text-to-video/spec/input.json new file mode 100644 index 0000000000000000000000000000000000000000..3874073e48c9ac50c1ecd9c45c60fae9ac9a71f9 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/image-text-to-video/spec/input.json @@ -0,0 +1,63 @@ +{ + "$id": "/inference/schemas/image-text-to-video/input.json", + "$schema": "http://json-schema.org/draft-06/schema#", + "description": "Inputs for Image Text To Video inference. Either inputs (image) or prompt (in parameters) must be provided, or both.", + "title": "ImageTextToVideoInput", + "type": "object", + "properties": { + "inputs": { + "type": "string", + "description": "The input image data as a base64-encoded string. If no `parameters` are provided, you can also provide the image data as a raw bytes payload. Either this or prompt must be provided.", + "comment": "type=binary" + }, + "parameters": { + "description": "Additional inference parameters for Image Text To Video", + "$ref": "#/$defs/ImageTextToVideoParameters" + } + }, + "$defs": { + "ImageTextToVideoParameters": { + "title": "ImageTextToVideoParameters", + "type": "object", + "properties": { + "prompt": { + "type": "string", + "description": "The text prompt to guide the video generation. Either this or inputs (image) must be provided." + }, + "guidance_scale": { + "type": "number", + "description": "For diffusion models. A higher guidance scale value encourages the model to generate videos closely linked to the text prompt at the expense of lower image quality." + }, + "negative_prompt": { + "type": "string", + "description": "One prompt to guide what NOT to include in video generation." + }, + "num_inference_steps": { + "type": "integer", + "description": "The number of denoising steps. More denoising steps usually lead to a higher quality video at the expense of slower inference." + }, + "num_frames": { + "type": "number", + "description": "The num_frames parameter determines how many video frames are generated." + }, + "target_size": { + "type": "object", + "description": "The size in pixel of the output video frames.", + "properties": { + "width": { + "type": "integer" + }, + "height": { + "type": "integer" + } + }, + "required": ["width", "height"] + }, + "seed": { + "type": "integer", + "description": "Seed for the random number generator." + } + } + } + } +} diff --git a/node_modules/@huggingface/tasks/src/tasks/image-text-to-video/spec/output.json b/node_modules/@huggingface/tasks/src/tasks/image-text-to-video/spec/output.json new file mode 100644 index 0000000000000000000000000000000000000000..26a08e9be533d6a0770be2a6d084bc7941cd0f16 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/image-text-to-video/spec/output.json @@ -0,0 +1,13 @@ +{ + "$id": "/inference/schemas/image-text-to-video/output.json", + "$schema": "http://json-schema.org/draft-06/schema#", + "description": "Outputs of inference for the Image Text To Video task", + "title": "ImageTextToVideoOutput", + "type": "object", + "properties": { + "video": { + "description": "The generated video returned as raw bytes in the payload." + } + }, + "required": ["video"] +} diff --git a/node_modules/@huggingface/tasks/src/tasks/image-to-3d/about.md b/node_modules/@huggingface/tasks/src/tasks/image-to-3d/about.md new file mode 100644 index 0000000000000000000000000000000000000000..dca8e4708190708275de87ebf0b52aa2dc7f99c3 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/image-to-3d/about.md @@ -0,0 +1,62 @@ +## Use Cases + +Image-to-3D models can be used in a wide variety of applications that require 3D, such as games, animation, design, architecture, engineering, marketing, and more. + +![Image-to-3D Thumbnail](https://huggingface.co/datasets/huggingfacejs/tasks/resolve/main/image-to-3d/image-to-3d-thumbnail.png) + +### Generating Meshes + +Meshes are the standard representation of 3D in industry. + +### Generating Gaussian Splats + +[Gaussian Splatting](https://huggingface.co/blog/gaussian-splatting) is a rendering technique that represents scenes as fuzzy points. + +### Inference + +Inference for this task typically leverages the [Diffusers](https://huggingface.co/docs/diffusers/index) library for inference, using [Custom Pipelines](https://huggingface.co/docs/diffusers/v0.6.0/en/using-diffusers/custom_pipelines). + +These are unstandardized and depend on the model. More details can be found in each model repository. + +```python +import torch +import requests +import numpy as np +from io import BytesIO +from diffusers import DiffusionPipeline +from PIL import Image + +pipeline = DiffusionPipeline.from_pretrained( + "dylanebert/LGM-full", + custom_pipeline="dylanebert/LGM-full", + torch_dtype=torch.float16, + trust_remote_code=True, +).to("cuda") + +input_url = "https://huggingface.co/datasets/dylanebert/iso3d/resolve/main/jpg@512/a_cat_statue.jpg" +input_image = Image.open(BytesIO(requests.get(input_url).content)) +input_image = np.array(input_image, dtype=np.float32) / 255.0 +result = pipeline("", input_image) +result_path = "/tmp/output.ply" +pipeline.save_ply(result, result_path) +``` + +In the code above, we: + +1. Import the necessary libraries +2. Load the `LGM-full` model and custom pipeline +3. Load and preprocess the input image +4. Run the pipeline on the input image +5. Save the output to a file + +### Output Formats + +Meshes can be in `.obj`, `.glb`, `.stl`, or `.gltf` format. Other formats are allowed, but won't be rendered in the gradio [Model3D](https://www.gradio.app/docs/gradio/model3d) component. + +Splats can be in `.ply` or `.splat` format. They can be rendered in the gradio [Model3D](https://www.gradio.app/docs/gradio/model3d) component using the [gsplat.js](https://github.com/huggingface/gsplat.js) library. + +## Useful Resources + +- [ML for 3D Course](https://huggingface.co/learn/ml-for-3d-course) +- [3D Arena Leaderboard](https://huggingface.co/spaces/dylanebert/3d-arena) +- [gsplat.js](https://github.com/huggingface/gsplat.js) diff --git a/node_modules/@huggingface/tasks/src/tasks/image-to-3d/data.ts b/node_modules/@huggingface/tasks/src/tasks/image-to-3d/data.ts new file mode 100644 index 0000000000000000000000000000000000000000..61e8e50c758ec13b640e989bc355d6fe0f76d542 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/image-to-3d/data.ts @@ -0,0 +1,75 @@ +import type { TaskDataCustom } from "../index.js"; + +const taskData: TaskDataCustom = { + datasets: [ + { + description: "A large dataset of over 10 million 3D objects.", + id: "allenai/objaverse-xl", + }, + { + description: "A dataset of isolated object images for evaluating image-to-3D models.", + id: "dylanebert/iso3d", + }, + ], + demo: { + inputs: [ + { + filename: "image-to-3d-image-input.png", + type: "img", + }, + ], + outputs: [ + { + label: "Result", + content: "image-to-3d-3d-output-filename.glb", + type: "text", + }, + ], + }, + metrics: [], + models: [ + { + description: "Fast image-to-3D mesh model by Tencent.", + id: "TencentARC/InstantMesh", + }, + { + description: "3D world generation model.", + id: "tencent/HunyuanWorld-1", + }, + { + description: "A scaled up image-to-3D mesh model derived from TripoSR.", + id: "hwjiang/Real3D", + }, + { + description: "Consistent image-to-3d generation model.", + id: "stabilityai/stable-point-aware-3d", + }, + ], + spaces: [ + { + description: "Leaderboard to evaluate image-to-3D models.", + id: "dylanebert/3d-arena", + }, + { + description: "Image-to-3D demo with mesh outputs.", + id: "TencentARC/InstantMesh", + }, + { + description: "Image-to-3D demo.", + id: "stabilityai/stable-point-aware-3d", + }, + { + description: "Image-to-3D demo with mesh outputs.", + id: "hwjiang/Real3D", + }, + { + description: "Image-to-3D demo with splat outputs.", + id: "dylanebert/LGM-mini", + }, + ], + summary: "Image-to-3D models take in image input and produce 3D output.", + widgetModels: [], + youtubeId: "", +}; + +export default taskData; diff --git a/node_modules/@huggingface/tasks/src/tasks/image-to-image/about.md b/node_modules/@huggingface/tasks/src/tasks/image-to-image/about.md new file mode 100644 index 0000000000000000000000000000000000000000..b2e8b69131670c64ed5ea377418c5903dcafcbd7 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/image-to-image/about.md @@ -0,0 +1,129 @@ +Image-to-image pipelines can also be used in text-to-image tasks, to provide visual guidance to the text-guided generation process. + +## Use Cases + +### Image inpainting + +Image inpainting is widely used during photography editing to remove unwanted objects, such as poles, wires, or sensor dust. + +### Image colorization + +Old or black and white images can be brought up to life using an image colorization model. + +### Super Resolution + +Super-resolution models increase the resolution of an image, allowing for higher-quality viewing and printing. + +## Inference + +You can use pipelines for image-to-image in 🧨diffusers library to easily use image-to-image models. See an example for `StableDiffusionImg2ImgPipeline` below. + +```python +import torch +from diffusers import AutoPipelineForImage2Image +from diffusers.utils import make_image_grid, load_image + +pipeline = AutoPipelineForImage2Image.from_pretrained( + "stabilityai/stable-diffusion-xl-refiner-1.0", torch_dtype=torch.float16, variant="fp16", use_safetensors=True +) + +# this helps us to reduce memory usage- since SDXL is a bit heavy, this could help by +# offloading the model to CPU w/o hurting performance. +pipeline.enable_model_cpu_offload() + +# prepare image +url = "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/img2img-sdxl-init.png" +init_image = load_image(url) + +prompt = "Astronaut in a jungle, cold color palette, muted colors, detailed, 8k" + +# pass prompt and image to pipeline +image = pipeline(prompt, image=init_image, strength=0.5).images[0] +make_image_grid([init_image, image], rows=1, cols=2) +``` + +You can use [huggingface.js](https://github.com/huggingface/huggingface.js) to infer image-to-image models on Hugging Face Hub. + +```javascript +import { InferenceClient } from "@huggingface/inference"; + +const inference = new InferenceClient(HF_TOKEN); +await inference.imageToImage({ + data: await (await fetch("image")).blob(), + model: "timbrooks/instruct-pix2pix", + parameters: { + prompt: "Deblur this image", + }, +}); +``` + +## Uses Cases for Text Guided Image Generation + +### Style Transfer + +One of the most popular use cases of image-to-image is style transfer. With style transfer models: + +- a regular photo can be transformed into a variety of artistic styles or genres, such as a watercolor painting, a comic book illustration and more. +- new images can be generated using a text prompt, in the style of a reference input image. + +See 🧨diffusers example for style transfer with `AutoPipelineForText2Image` below. + +```python +from diffusers import AutoPipelineForText2Image +from diffusers.utils import load_image +import torch + +# load pipeline +pipeline = AutoPipelineForText2Image.from_pretrained("stabilityai/stable-diffusion-xl-base-1.0", torch_dtype=torch.float16).to("cuda") +pipeline.load_ip_adapter("h94/IP-Adapter", subfolder="sdxl_models", weight_name="ip-adapter_sdxl.bin") + +# set the adapter and scales - this is a component that lets us add the style control from an image to the text-to-image model +scale = { + "down": {"block_2": [0.0, 1.0]}, + "up": {"block_0": [0.0, 1.0, 0.0]}, +} +pipeline.set_ip_adapter_scale(scale) + +style_image = load_image("https://huggingface.co/datasets/huggingface/documentation-images/resolve/0052a70beed5bf71b92610a43a52df6d286cd5f3/diffusers/rabbit.jpg") + +generator = torch.Generator(device="cpu").manual_seed(26) +image = pipeline( + prompt="a cat, masterpiece, best quality, high quality", + ip_adapter_image=style_image, + negative_prompt="text, watermark, lowres, low quality, worst quality, deformed, glitch, low contrast, noisy, saturation, blurry", + guidance_scale=5, + num_inference_steps=30, + generator=generator, +).images[0] +image +``` + +### ControlNet + +Controlling the outputs of diffusion models only with a text prompt is a challenging problem. ControlNet is a neural network model that provides image-based control to diffusion models. Control images can be edges or other landmarks extracted from a source image. +![Examples](https://huggingface.co/datasets/optimum/documentation-images/resolve/main/neuron/models/12-sdxl-text2img-controlnet.png) + +## Pix2Pix + +Pix2Pix is a popular model used for image-to-image translation tasks. It is based on a conditional-GAN (generative adversarial network) where instead of a noise vector a 2D image is given as input. More information about Pix2Pix can be retrieved from this [link](https://phillipi.github.io/pix2pix/) where the associated paper and the GitHub repository can be found. + +The images below show some examples extracted from the Pix2Pix paper. This model can be applied to various use cases. It is capable of relatively simpler things, e.g., converting a grayscale image to its colored version. But more importantly, it can generate realistic pictures from rough sketches (can be seen in the purse example) or from painting-like images (can be seen in the street and facade examples below). + +![Examples](https://huggingface.co/datasets/huggingfacejs/tasks/resolve/main/image-to-image/pix2pix_examples.jpg) + +## Useful Resources + +- [Image-to-image guide with diffusers](https://huggingface.co/docs/diffusers/using-diffusers/img2img) +- Image inpainting: [inpainting with 🧨diffusers](https://huggingface.co/docs/diffusers/main/en/using-diffusers/inpaint#inpainting), [demo](https://huggingface.co/spaces/linoyts/Qwen-Image-Edit-Inpaint) +- Colorization: [demo](https://huggingface.co/spaces/modelscope/old_photo_restoration) +- Super resolution: [image upscaling with 🧨diffusers](https://huggingface.co/docs/diffusers/main/en/api/pipelines/stable_diffusion/upscale#super-resolution), [demo](https://huggingface.co/spaces/radames/Enhance-This-HiDiffusion-SDXL) +- [Style transfer and layout control with diffusers 🧨](https://huggingface.co/docs/diffusers/main/en/using-diffusers/ip_adapter#style--layout-control) +- [Train your ControlNet with diffusers 🧨](https://huggingface.co/blog/train-your-controlnet) +- [Ultra fast ControlNet with 🧨 Diffusers](https://huggingface.co/blog/controlnet) +- [List of ControlNets trained in the community JAX Diffusers sprint](https://huggingface.co/spaces/jax-diffusers-event/leaderboard) + +## References + +[1] P. Isola, J. -Y. Zhu, T. Zhou and A. A. Efros, "Image-to-Image Translation with Conditional Adversarial Networks," 2017 IEEE Conference on Computer Vision and Pattern Recognition (CVPR), 2017, pp. 5967-5976, doi: 10.1109/CVPR.2017.632. + +This page was made possible thanks to the efforts of [Paul Gafton](https://github.com/Paul92) and [Osman Alenbey](https://huggingface.co/osman93). diff --git a/node_modules/@huggingface/tasks/src/tasks/image-to-image/data.ts b/node_modules/@huggingface/tasks/src/tasks/image-to-image/data.ts new file mode 100644 index 0000000000000000000000000000000000000000..d0da0241e23d8b66032f395b04c9190f5dc2942a --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/image-to-image/data.ts @@ -0,0 +1,96 @@ +import type { TaskDataCustom } from "../index.js"; + +const taskData: TaskDataCustom = { + datasets: [ + { + description: "Synthetic dataset, for image relighting", + id: "VIDIT", + }, + { + description: "Multiple images of celebrities, used for facial expression translation", + id: "huggan/CelebA-faces", + }, + { + description: "12M image-caption pairs.", + id: "Spawning/PD12M", + }, + ], + demo: { + inputs: [ + { + filename: "image-to-image-input.jpeg", + type: "img", + }, + ], + outputs: [ + { + filename: "image-to-image-output.png", + type: "img", + }, + ], + }, + isPlaceholder: false, + metrics: [ + { + description: + "Peak Signal to Noise Ratio (PSNR) is an approximation of the human perception, considering the ratio of the absolute intensity with respect to the variations. Measured in dB, a high value indicates a high fidelity.", + id: "PSNR", + }, + { + description: + "Structural Similarity Index (SSIM) is a perceptual metric which compares the luminance, contrast and structure of two images. The values of SSIM range between -1 and 1, and higher values indicate closer resemblance to the original image.", + id: "SSIM", + }, + { + description: + "Inception Score (IS) is an analysis of the labels predicted by an image classification model when presented with a sample of the generated images.", + id: "IS", + }, + ], + models: [ + { + description: "An image-to-image model to improve image resolution.", + id: "fal/AuraSR-v2", + }, + { + description: "Powerful image editing model.", + id: "black-forest-labs/FLUX.1-Kontext-dev", + }, + { + description: "Virtual try-on model.", + id: "yisol/IDM-VTON", + }, + { + description: "Image re-lighting model.", + id: "kontext-community/relighting-kontext-dev-lora-v3", + }, + { + description: "Strong model for inpainting and outpainting.", + id: "black-forest-labs/FLUX.1-Fill-dev", + }, + { + description: "Strong model for image editing using depth maps.", + id: "black-forest-labs/FLUX.1-Depth-dev-lora", + }, + ], + spaces: [ + { + description: "Image editing application.", + id: "black-forest-labs/FLUX.1-Kontext-Dev", + }, + { + description: "Image relighting application.", + id: "lllyasviel/iclight-v2-vary", + }, + { + description: "An application for image upscaling.", + id: "jasperai/Flux.1-dev-Controlnet-Upscaler", + }, + ], + summary: + "Image-to-image is the task of transforming an input image through a variety of possible manipulations and enhancements, such as super-resolution, image inpainting, colorization, and more.", + widgetModels: ["Qwen/Qwen-Image"], + youtubeId: "", +}; + +export default taskData; diff --git a/node_modules/@huggingface/tasks/src/tasks/image-to-image/inference.ts b/node_modules/@huggingface/tasks/src/tasks/image-to-image/inference.ts new file mode 100644 index 0000000000000000000000000000000000000000..0a681093ca15521e9c8a51bf1db042f094fff27f --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/image-to-image/inference.ts @@ -0,0 +1,68 @@ +/** + * Inference code generated from the JSON schema spec in ./spec + * + * Using src/scripts/inference-codegen + */ +/** + * Inputs for Image To Image inference + */ +export interface ImageToImageInput { + /** + * The input image data as a base64-encoded string. If no `parameters` are provided, you can + * also provide the image data as a raw bytes payload. + */ + inputs: Blob; + /** + * Additional inference parameters for Image To Image + */ + parameters?: ImageToImageParameters; + [property: string]: unknown; +} +/** + * Additional inference parameters for Image To Image + */ +export interface ImageToImageParameters { + /** + * For diffusion models. A higher guidance scale value encourages the model to generate + * images closely linked to the text prompt at the expense of lower image quality. + */ + guidance_scale?: number; + /** + * One prompt to guide what NOT to include in image generation. + */ + negative_prompt?: string; + /** + * For diffusion models. The number of denoising steps. More denoising steps usually lead to + * a higher quality image at the expense of slower inference. + */ + num_inference_steps?: number; + /** + * The text prompt to guide the image generation. + */ + prompt?: string; + /** + * The size in pixels of the output image. This parameter is only supported by some + * providers and for specific models. It will be ignored when unsupported. + */ + target_size?: TargetSize; + [property: string]: unknown; +} +/** + * The size in pixels of the output image. This parameter is only supported by some + * providers and for specific models. It will be ignored when unsupported. + */ +export interface TargetSize { + height: number; + width: number; + [property: string]: unknown; +} +/** + * Outputs of inference for the Image To Image task + */ +export interface ImageToImageOutput { + /** + * The output image returned as raw bytes in the payload. + */ + image?: unknown; + [property: string]: unknown; +} diff --git a/node_modules/@huggingface/tasks/src/tasks/image-to-image/spec/input.json b/node_modules/@huggingface/tasks/src/tasks/image-to-image/spec/input.json new file mode 100644 index 0000000000000000000000000000000000000000..49e8695c444db86328688df6df2119bfa1838587 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/image-to-image/spec/input.json @@ -0,0 +1,56 @@ +{ + "$id": "/inference/schemas/image-to-image/input.json", + "$schema": "http://json-schema.org/draft-06/schema#", + "description": "Inputs for Image To Image inference", + "title": "ImageToImageInput", + "type": "object", + "properties": { + "inputs": { + "type": "string", + "description": "The input image data as a base64-encoded string. If no `parameters` are provided, you can also provide the image data as a raw bytes payload.", + "comment": "type=binary" + }, + "parameters": { + "description": "Additional inference parameters for Image To Image", + "$ref": "#/$defs/ImageToImageParameters" + } + }, + "$defs": { + "ImageToImageParameters": { + "title": "ImageToImageParameters", + "type": "object", + "properties": { + "prompt": { + "type": "string", + "description": "The text prompt to guide the image generation." + }, + "guidance_scale": { + "type": "number", + "description": "For diffusion models. A higher guidance scale value encourages the model to generate images closely linked to the text prompt at the expense of lower image quality." + }, + "negative_prompt": { + "type": "string", + "description": "One prompt to guide what NOT to include in image generation." + }, + "num_inference_steps": { + "type": "integer", + "description": "For diffusion models. The number of denoising steps. More denoising steps usually lead to a higher quality image at the expense of slower inference." + }, + "target_size": { + "type": "object", + "description": "The size in pixels of the output image. This parameter is only supported by some providers and for specific models. It will be ignored when unsupported.", + "properties": { + "width": { + "type": "integer" + }, + "height": { + "type": "integer" + } + }, + "required": ["width", "height"] + } + } + } + }, + "required": ["inputs"] +} diff --git a/node_modules/@huggingface/tasks/src/tasks/image-to-image/spec/output.json b/node_modules/@huggingface/tasks/src/tasks/image-to-image/spec/output.json new file mode 100644 index 0000000000000000000000000000000000000000..043544e7516fb38688967c0acf6dff933d3da64a --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/image-to-image/spec/output.json @@ -0,0 +1,12 @@ +{ + "$id": "/inference/schemas/image-to-image/output.json", + "$schema": "http://json-schema.org/draft-06/schema#", + "description": "Outputs of inference for the Image To Image task", + "title": "ImageToImageOutput", + "type": "object", + "properties": { + "image": { + "description": "The output image returned as raw bytes in the payload." + } + } +} diff --git a/node_modules/@huggingface/tasks/src/tasks/image-to-text/about.md b/node_modules/@huggingface/tasks/src/tasks/image-to-text/about.md new file mode 100644 index 0000000000000000000000000000000000000000..403dbdc41de67241bfab8f6535f3977e5a7a570e --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/image-to-text/about.md @@ -0,0 +1,61 @@ +## Use Cases + +### Image Captioning + +Image Captioning is the process of generating textual description of an image. +This can help the visually impaired people to understand what's happening in their surroundings. + +### Optical Character Recognition (OCR) + +OCR models convert the text present in an image, e.g. a scanned document, to text. + +## Inference + +### Image Captioning + +You can use the 🤗 Transformers library's `image-to-text` pipeline to generate caption for the Image input. + +```python +from transformers import pipeline + +captioner = pipeline("image-to-text", model="Salesforce/blip-image-captioning-base") +captioner("https://huggingface.co/datasets/Narsil/image_dummy/resolve/main/parrots.png") +## [{'generated_text': 'two birds are standing next to each other '}] +``` + +### OCR + +This code snippet uses Microsoft’s TrOCR, an encoder-decoder model consisting of an image Transformer encoder and a text Transformer decoder for state-of-the-art optical character recognition (OCR) on single-text line images. + +```python +from transformers import TrOCRProcessor, VisionEncoderDecoderModel + +processor = TrOCRProcessor.from_pretrained('microsoft/trocr-base-handwritten') +model = VisionEncoderDecoderModel.from_pretrained('microsoft/trocr-base-handwritten') +pixel_values = processor(images="image.jpeg", return_tensors="pt").pixel_values + +generated_ids = model.generate(pixel_values) +generated_text = processor.batch_decode(generated_ids, skip_special_tokens=True)[0] + +``` + +You can use [huggingface.js](https://github.com/huggingface/huggingface.js) to infer image-to-text models on Hugging Face Hub. + +```javascript +import { InferenceClient } from "@huggingface/inference"; + +const inference = new InferenceClient(HF_TOKEN); +await inference.imageToText({ + data: await (await fetch("https://picsum.photos/300/300")).blob(), + model: "Salesforce/blip-image-captioning-base", +}); +``` + +## Useful Resources + +- [Image Captioning](https://huggingface.co/docs/transformers/main/en/tasks/image_captioning) +- [Image Captioning Use Case](https://blog.google/outreach-initiatives/accessibility/get-image-descriptions/) +- [Train Image Captioning model on your dataset](https://github.com/NielsRogge/Transformers-Tutorials/blob/master/GIT/Fine_tune_GIT_on_an_image_captioning_dataset.ipynb) +- [Train OCR model on your dataset ](https://github.com/NielsRogge/Transformers-Tutorials/tree/master/TrOCR) + +This page was made possible thanks to efforts of [Sukesh Perla](https://huggingface.co/hitchhiker3010) and [Johannes Kolbe](https://huggingface.co/johko). diff --git a/node_modules/@huggingface/tasks/src/tasks/image-to-text/data.ts b/node_modules/@huggingface/tasks/src/tasks/image-to-text/data.ts new file mode 100644 index 0000000000000000000000000000000000000000..2cda2e765f97fed36231bc8607febb7e483350bc --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/image-to-text/data.ts @@ -0,0 +1,62 @@ +import type { TaskDataCustom } from "../index.js"; + +const taskData: TaskDataCustom = { + datasets: [ + { + // TODO write proper description + description: "Dataset from 12M image-text of Reddit", + id: "red_caps", + }, + { + // TODO write proper description + description: "Dataset from 3.3M images of Google", + id: "datasets/conceptual_captions", + }, + ], + demo: { + inputs: [ + { + filename: "savanna.jpg", + type: "img", + }, + ], + outputs: [ + { + label: "Detailed description", + content: "a herd of giraffes and zebras grazing in a field", + type: "text", + }, + ], + }, + metrics: [], + models: [ + { + description: "Strong OCR model.", + id: "allenai/olmOCR-7B-0725", + }, + { + description: "Powerful image captioning model.", + id: "fancyfeast/llama-joycaption-beta-one-hf-llava", + }, + ], + spaces: [ + { + description: "SVG generator app from images.", + id: "multimodalart/OmniSVG-3B", + }, + { + description: "An application that converts documents to markdown.", + id: "numind/NuMarkdown-8B-Thinking", + }, + { + description: "An application that can caption images.", + id: "fancyfeast/joy-caption-beta-one", + }, + ], + summary: + "Image to text models output a text from a given image. Image captioning or optical character recognition can be considered as the most common applications of image to text.", + widgetModels: ["Salesforce/blip-image-captioning-large"], + youtubeId: "", +}; + +export default taskData; diff --git a/node_modules/@huggingface/tasks/src/tasks/image-to-text/inference.ts b/node_modules/@huggingface/tasks/src/tasks/image-to-text/inference.ts new file mode 100644 index 0000000000000000000000000000000000000000..5c6bbe30c13bee2064c1e897c29a5945de8f7738 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/image-to-text/inference.ts @@ -0,0 +1,134 @@ +/** + * Inference code generated from the JSON schema spec in ./spec + * + * Using src/scripts/inference-codegen + */ +/** + * Inputs for Image To Text inference + */ +export interface ImageToTextInput { + /** + * The input image data + */ + inputs: Blob; + /** + * Additional inference parameters for Image To Text + */ + parameters?: ImageToTextParameters; + [property: string]: unknown; +} +/** + * Additional inference parameters for Image To Text + */ +export interface ImageToTextParameters { + /** + * Parametrization of the text generation process + */ + generation_parameters?: GenerationParameters; + /** + * The amount of maximum tokens to generate. + */ + max_new_tokens?: number; + [property: string]: unknown; +} +/** + * Parametrization of the text generation process + */ +export interface GenerationParameters { + /** + * Whether to use sampling instead of greedy decoding when generating new tokens. + */ + do_sample?: boolean; + /** + * Controls the stopping condition for beam-based methods. + */ + early_stopping?: EarlyStoppingUnion; + /** + * If set to float strictly between 0 and 1, only tokens with a conditional probability + * greater than epsilon_cutoff will be sampled. In the paper, suggested values range from + * 3e-4 to 9e-4, depending on the size of the model. See [Truncation Sampling as Language + * Model Desmoothing](https://hf.co/papers/2210.15191) for more details. + */ + epsilon_cutoff?: number; + /** + * Eta sampling is a hybrid of locally typical sampling and epsilon sampling. If set to + * float strictly between 0 and 1, a token is only considered if it is greater than either + * eta_cutoff or sqrt(eta_cutoff) * exp(-entropy(softmax(next_token_logits))). The latter + * term is intuitively the expected next token probability, scaled by sqrt(eta_cutoff). In + * the paper, suggested values range from 3e-4 to 2e-3, depending on the size of the model. + * See [Truncation Sampling as Language Model Desmoothing](https://hf.co/papers/2210.15191) + * for more details. + */ + eta_cutoff?: number; + /** + * The maximum length (in tokens) of the generated text, including the input. + */ + max_length?: number; + /** + * The maximum number of tokens to generate. Takes precedence over max_length. + */ + max_new_tokens?: number; + /** + * The minimum length (in tokens) of the generated text, including the input. + */ + min_length?: number; + /** + * The minimum number of tokens to generate. Takes precedence over min_length. + */ + min_new_tokens?: number; + /** + * Number of groups to divide num_beams into in order to ensure diversity among different + * groups of beams. See [this paper](https://hf.co/papers/1610.02424) for more details. + */ + num_beam_groups?: number; + /** + * Number of beams to use for beam search. + */ + num_beams?: number; + /** + * The value balances the model confidence and the degeneration penalty in contrastive + * search decoding. + */ + penalty_alpha?: number; + /** + * The value used to modulate the next token probabilities. + */ + temperature?: number; + /** + * The number of highest probability vocabulary tokens to keep for top-k-filtering. + */ + top_k?: number; + /** + * If set to float < 1, only the smallest set of most probable tokens with probabilities + * that add up to top_p or higher are kept for generation. + */ + top_p?: number; + /** + * Local typicality measures how similar the conditional probability of predicting a target + * token next is to the expected conditional probability of predicting a random token next, + * given the partial text already generated. If set to float < 1, the smallest set of the + * most locally typical tokens with probabilities that add up to typical_p or higher are + * kept for generation. See [this paper](https://hf.co/papers/2202.00666) for more details. + */ + typical_p?: number; + /** + * Whether the model should use the past last key/values attentions to speed up decoding + */ + use_cache?: boolean; + [property: string]: unknown; +} +/** + * Controls the stopping condition for beam-based methods. + */ +export type EarlyStoppingUnion = boolean | "never"; +/** + * Outputs of inference for the Image To Text task + */ +export interface ImageToTextOutput { + generatedText: unknown; + /** + * The generated text. + */ + generated_text?: string; + [property: string]: unknown; +} diff --git a/node_modules/@huggingface/tasks/src/tasks/image-to-text/spec/input.json b/node_modules/@huggingface/tasks/src/tasks/image-to-text/spec/input.json new file mode 100644 index 0000000000000000000000000000000000000000..26915b34a7511c7a0da959cb83382bd2bbba6efc --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/image-to-text/spec/input.json @@ -0,0 +1,34 @@ +{ + "$id": "/inference/schemas/image-to-text/input.json", + "$schema": "http://json-schema.org/draft-06/schema#", + "description": "Inputs for Image To Text inference", + "title": "ImageToTextInput", + "type": "object", + "properties": { + "inputs": { + "description": "The input image data", + "comment": "type=binary" + }, + "parameters": { + "description": "Additional inference parameters for Image To Text", + "$ref": "#/$defs/ImageToTextParameters" + } + }, + "$defs": { + "ImageToTextParameters": { + "title": "ImageToTextParameters", + "type": "object", + "properties": { + "max_new_tokens": { + "type": "integer", + "description": "The amount of maximum tokens to generate." + }, + "generation_parameters": { + "description": "Parametrization of the text generation process", + "$ref": "/inference/schemas/common-definitions.json#/definitions/GenerationParameters" + } + } + } + }, + "required": ["inputs"] +} diff --git a/node_modules/@huggingface/tasks/src/tasks/image-to-text/spec/output.json b/node_modules/@huggingface/tasks/src/tasks/image-to-text/spec/output.json new file mode 100644 index 0000000000000000000000000000000000000000..388c3456f4e7f50b0c7b133725a2d951f152cb01 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/image-to-text/spec/output.json @@ -0,0 +1,14 @@ +{ + "$id": "/inference/schemas/image-to-text/output.json", + "$schema": "http://json-schema.org/draft-06/schema#", + "description": "Outputs of inference for the Image To Text task", + "title": "ImageToTextOutput", + "type": "object", + "properties": { + "generated_text": { + "type": "string", + "description": "The generated text." + } + }, + "required": ["generatedText"] +} diff --git a/node_modules/@huggingface/tasks/src/tasks/image-to-video/about.md b/node_modules/@huggingface/tasks/src/tasks/image-to-video/about.md new file mode 100644 index 0000000000000000000000000000000000000000..1b32dde6e61a0f96fb1372b3eaa31301eef1ade5 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/image-to-video/about.md @@ -0,0 +1,51 @@ +## Use Cases + +Image-to-video models transform a static image into a video sequence. This can be used for a variety of creative and practical applications. + +### Animated Images + +Bring still photos to life by adding subtle motion or creating short animated clips. This is great for social media content or dynamic presentations. + +### Storytelling from a Single Frame + +Expand on the narrative of an image by generating a short video that imagines what happened before or after the moment captured in the photo. + +### Video Generation with Visual Consistency + +Use an input image as a strong visual anchor to guide the generation of a video, ensuring that the style, characters, or objects in the video remain consistent with the source image. + +### Controllable Motion + +Image-to-video models can be used to specify the direction or intensity of motion or camera control, giving more fine-grained control over the generated animation. + +## Inference + +Running the model Wan 2.1 T2V 1.3B with diffusers + +```py +import torch +from diffusers import AutoencoderKLWan, WanPipeline +from diffusers.utils import export_to_video + +model_id = "Wan-AI/Wan2.1-T2V-1.3B-Diffusers" +vae = AutoencoderKLWan.from_pretrained(model_id, subfolder="vae", torch_dtype=torch.float32) +pipe = WanPipeline.from_pretrained(model_id, vae=vae, torch_dtype=torch.bfloat16) +pipe.to("cuda") + +prompt = "A cat walks on the grass, realistic" +negative_prompt = "Bright tones, overexposed, static, blurred details, subtitles, style, works, paintings, images, static, overall gray, worst quality, low quality, JPEG compression residue, ugly, incomplete, extra fingers, poorly drawn hands, poorly drawn faces, deformed, disfigured, misshapen limbs, fused fingers, still picture, messy background, three legs, many people in the background, walking backwards" + +output = pipe( + prompt=prompt, + negative_prompt=negative_prompt, + height=480, + width=832, + num_frames=81, + guidance_scale=5.0 +).frames[0] +export_to_video(output, "output.mp4", fps=15) +``` + +## Useful Resources + +To train image-to-video LoRAs check out [finetrainers](https://github.com/a-r-r-o-w/finetrainers) and [musubi trainer](https://github.com/kohya-ss/musubi-tuner). diff --git a/node_modules/@huggingface/tasks/src/tasks/image-to-video/data.ts b/node_modules/@huggingface/tasks/src/tasks/image-to-video/data.ts new file mode 100644 index 0000000000000000000000000000000000000000..66ee4c1162ae40ea6caab24ee98eb7844d805414 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/image-to-video/data.ts @@ -0,0 +1,126 @@ +import type { TaskDataCustom } from "../index.js"; + +const taskData: TaskDataCustom = { + datasets: [ + { + description: "A benchmark dataset for reference image controlled video generation.", + id: "ali-vilab/VACE-Benchmark", + }, + { + description: "A dataset of video generation style preferences.", + id: "Rapidata/sora-video-generation-style-likert-scoring", + }, + { + description: "A dataset with videos and captions throughout the videos.", + id: "BestWishYsh/ChronoMagic", + }, + ], + demo: { + inputs: [ + { + filename: "image-to-video-input.jpg", + type: "img", + }, + { + label: "Optional Text Prompt", + content: "This penguin is dancing", + type: "text", + }, + ], + outputs: [ + { + filename: "image-to-video-output.gif", + type: "img", + }, + ], + }, + metrics: [ + { + description: + "Fréchet Video Distance (FVD) measures the perceptual similarity between the distributions of generated videos and a set of real videos, assessing overall visual quality and temporal coherence of the video generated from an input image.", + id: "fvd", + }, + { + description: + "CLIP Score measures the semantic similarity between a textual prompt (if provided alongside the input image) and the generated video frames. It evaluates how well the video's generated content and motion align with the textual description, conditioned on the initial image.", + id: "clip_score", + }, + { + description: + "First Frame Fidelity, often measured using LPIPS (Learned Perceptual Image Patch Similarity), PSNR, or SSIM, quantifies how closely the first frame of the generated video matches the input conditioning image.", + id: "lpips", + }, + { + description: + "Identity Preservation Score measures the consistency of identity (e.g., a person's face or a specific object's characteristics) between the input image and throughout the generated video frames, often calculated using features from specialized models like face recognition (e.g., ArcFace) or re-identification models.", + id: "identity_preservation", + }, + { + description: + "Motion Score evaluates the quality, realism, and temporal consistency of motion in the video generated from a static image. This can be based on optical flow analysis (e.g., smoothness, magnitude), consistency of object trajectories, or specific motion plausibility assessments.", + id: "motion_score", + }, + ], + models: [ + { + description: "LTX-Video, a 13B parameter model for high quality video generation", + id: "Lightricks/LTX-Video-0.9.7-dev", + }, + { + description: "A 14B parameter model for reference image controlled video generation", + id: "Wan-AI/Wan2.1-VACE-14B", + }, + { + description: "An image-to-video generation model using FramePack F1 methodology with Hunyuan-DiT architecture", + id: "lllyasviel/FramePack_F1_I2V_HY_20250503", + }, + { + description: "A distilled version of the LTX-Video-0.9.7-dev model for faster inference", + id: "Lightricks/LTX-Video-0.9.7-distilled", + }, + { + description: "An image-to-video generation model by Skywork AI, 14B parameters, producing 720p videos.", + id: "Skywork/SkyReels-V2-I2V-14B-720P", + }, + { + description: "Image-to-video variant of Tencent's HunyuanVideo.", + id: "tencent/HunyuanVideo-I2V", + }, + { + description: "A 14B parameter model for 720p image-to-video generation by Wan-AI.", + id: "Wan-AI/Wan2.1-I2V-14B-720P", + }, + { + description: "A Diffusers version of the Wan2.1-I2V-14B-720P model for 720p image-to-video generation.", + id: "Wan-AI/Wan2.1-I2V-14B-720P-Diffusers", + }, + ], + spaces: [ + { + description: "An application to generate videos fast.", + id: "Lightricks/ltx-video-distilled", + }, + { + description: "Generate videos with the FramePack-F1", + id: "linoyts/FramePack-F1", + }, + { + description: "Generate videos with the FramePack", + id: "lisonallen/framepack-i2v", + }, + { + description: "Wan2.1 with CausVid LoRA", + id: "multimodalart/wan2-1-fast", + }, + { + description: "A demo for Stable Video Diffusion", + id: "multimodalart/stable-video-diffusion", + }, + ], + summary: + "Image-to-video models take a still image as input and generate a video. These models can be guided by text prompts to influence the content and style of the output video.", + widgetModels: [], + youtubeId: undefined, +}; + +export default taskData; diff --git a/node_modules/@huggingface/tasks/src/tasks/image-to-video/inference.ts b/node_modules/@huggingface/tasks/src/tasks/image-to-video/inference.ts new file mode 100644 index 0000000000000000000000000000000000000000..6b218eb05854db516320eabe19d7c33d70c0ec2c --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/image-to-video/inference.ts @@ -0,0 +1,74 @@ +/** + * Inference code generated from the JSON schema spec in ./spec + * + * Using src/scripts/inference-codegen + */ +/** + * Inputs for Image To Video inference + */ +export interface ImageToVideoInput { + /** + * The input image data as a base64-encoded string. If no `parameters` are provided, you can + * also provide the image data as a raw bytes payload. + */ + inputs: Blob; + /** + * Additional inference parameters for Image To Video + */ + parameters?: ImageToVideoParameters; + [property: string]: unknown; +} +/** + * Additional inference parameters for Image To Video + */ +export interface ImageToVideoParameters { + /** + * For diffusion models. A higher guidance scale value encourages the model to generate + * videos closely linked to the text prompt at the expense of lower image quality. + */ + guidance_scale?: number; + /** + * One prompt to guide what NOT to include in video generation. + */ + negative_prompt?: string; + /** + * The num_frames parameter determines how many video frames are generated. + */ + num_frames?: number; + /** + * The number of denoising steps. More denoising steps usually lead to a higher quality + * video at the expense of slower inference. + */ + num_inference_steps?: number; + /** + * The text prompt to guide the video generation. + */ + prompt?: string; + /** + * Seed for the random number generator. + */ + seed?: number; + /** + * The size in pixel of the output video frames. + */ + target_size?: TargetSize; + [property: string]: unknown; +} +/** + * The size in pixel of the output video frames. + */ +export interface TargetSize { + height: number; + width: number; + [property: string]: unknown; +} +/** + * Outputs of inference for the Image To Video task + */ +export interface ImageToVideoOutput { + /** + * The generated video returned as raw bytes in the payload. + */ + video: unknown; + [property: string]: unknown; +} diff --git a/node_modules/@huggingface/tasks/src/tasks/image-to-video/spec/input.json b/node_modules/@huggingface/tasks/src/tasks/image-to-video/spec/input.json new file mode 100644 index 0000000000000000000000000000000000000000..05178a700883087bda21ded761744f60c3d0c4d0 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/image-to-video/spec/input.json @@ -0,0 +1,64 @@ +{ + "$id": "/inference/schemas/image-to-video/input.json", + "$schema": "http://json-schema.org/draft-06/schema#", + "description": "Inputs for Image To Video inference", + "title": "ImageToVideoInput", + "type": "object", + "properties": { + "inputs": { + "type": "string", + "description": "The input image data as a base64-encoded string. If no `parameters` are provided, you can also provide the image data as a raw bytes payload.", + "comment": "type=binary" + }, + "parameters": { + "description": "Additional inference parameters for Image To Video", + "$ref": "#/$defs/ImageToVideoParameters" + } + }, + "$defs": { + "ImageToVideoParameters": { + "title": "ImageToVideoParameters", + "type": "object", + "properties": { + "prompt": { + "type": "string", + "description": "The text prompt to guide the video generation." + }, + "guidance_scale": { + "type": "number", + "description": "For diffusion models. A higher guidance scale value encourages the model to generate videos closely linked to the text prompt at the expense of lower image quality." + }, + "negative_prompt": { + "type": "string", + "description": "One prompt to guide what NOT to include in video generation." + }, + "num_inference_steps": { + "type": "integer", + "description": "The number of denoising steps. More denoising steps usually lead to a higher quality video at the expense of slower inference." + }, + "num_frames": { + "type": "number", + "description": "The num_frames parameter determines how many video frames are generated." + }, + "target_size": { + "type": "object", + "description": "The size in pixel of the output video frames.", + "properties": { + "width": { + "type": "integer" + }, + "height": { + "type": "integer" + } + }, + "required": ["width", "height"] + }, + "seed": { + "type": "integer", + "description": "Seed for the random number generator." + } + } + } + }, + "required": ["inputs"] +} diff --git a/node_modules/@huggingface/tasks/src/tasks/image-to-video/spec/output.json b/node_modules/@huggingface/tasks/src/tasks/image-to-video/spec/output.json new file mode 100644 index 0000000000000000000000000000000000000000..ecd27522c3cdc4313fbc1b1a47239f6a9cd4f0f0 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/image-to-video/spec/output.json @@ -0,0 +1,13 @@ +{ + "$id": "/inference/schemas/image-to-video/output.json", + "$schema": "http://json-schema.org/draft-06/schema#", + "description": "Outputs of inference for the Image To Video task", + "title": "ImageToVideoOutput", + "type": "object", + "properties": { + "video": { + "description": "The generated video returned as raw bytes in the payload." + } + }, + "required": ["video"] +} diff --git a/node_modules/@huggingface/tasks/src/tasks/index.ts b/node_modules/@huggingface/tasks/src/tasks/index.ts new file mode 100644 index 0000000000000000000000000000000000000000..5d1c0284bc76ce1d1f722358d30834423458d7e6 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/index.ts @@ -0,0 +1,341 @@ +import type { PipelineType } from "../pipelines.js"; +import { PIPELINE_DATA } from "../pipelines.js"; + +import anyToAny from "./any-to-any/data.js"; +import audioClassification from "./audio-classification/data.js"; +import audioTextToText from "./audio-text-to-text/data.js"; +import audioToAudio from "./audio-to-audio/data.js"; +import automaticSpeechRecognition from "./automatic-speech-recognition/data.js"; +import documentQuestionAnswering from "./document-question-answering/data.js"; +import featureExtraction from "./feature-extraction/data.js"; +import fillMask from "./fill-mask/data.js"; +import imageClassification from "./image-classification/data.js"; +import imageFeatureExtraction from "./image-feature-extraction/data.js"; +import imageToImage from "./image-to-image/data.js"; +import imageToText from "./image-to-text/data.js"; +import imageTextToText from "./image-text-to-text/data.js"; +import imageTextToImage from "./image-text-to-image/data.js"; +import imageTextToVideo from "./image-text-to-video/data.js"; +import imageSegmentation from "./image-segmentation/data.js"; +import imageToVideo from "./image-to-video/data.js"; +import maskGeneration from "./mask-generation/data.js"; +import objectDetection from "./object-detection/data.js"; +import depthEstimation from "./depth-estimation/data.js"; +import placeholder from "./placeholder/data.js"; +import reinforcementLearning from "./reinforcement-learning/data.js"; +import questionAnswering from "./question-answering/data.js"; +import sentenceSimilarity from "./sentence-similarity/data.js"; +import summarization from "./summarization/data.js"; +import tableQuestionAnswering from "./table-question-answering/data.js"; +import tabularClassification from "./tabular-classification/data.js"; +import tabularRegression from "./tabular-regression/data.js"; +import textToImage from "./text-to-image/data.js"; +import textToSpeech from "./text-to-speech/data.js"; +import tokenClassification from "./token-classification/data.js"; +import translation from "./translation/data.js"; +import textClassification from "./text-classification/data.js"; +import textGeneration from "./text-generation/data.js"; +import textRanking from "./text-ranking/data.js"; +import textToVideo from "./text-to-video/data.js"; +import unconditionalImageGeneration from "./unconditional-image-generation/data.js"; +import videoClassification from "./video-classification/data.js"; +import visualDocumentRetrieval from "./visual-document-retrieval/data.js"; +import visualQuestionAnswering from "./visual-question-answering/data.js"; +import zeroShotClassification from "./zero-shot-classification/data.js"; +import zeroShotImageClassification from "./zero-shot-image-classification/data.js"; +import zeroShotObjectDetection from "./zero-shot-object-detection/data.js"; +import imageTo3D from "./image-to-3d/data.js"; +import textTo3D from "./text-to-3d/data.js"; +import keypointDetection from "./keypoint-detection/data.js"; +import videoTextToText from "./video-text-to-text/data.js"; +import videoToVideo from "./video-to-video/data.js"; + +export type * from "./audio-classification/inference.js"; +export type * from "./automatic-speech-recognition/inference.js"; +export type { + ChatCompletionInput, + ChatCompletionInputMessage, + ChatCompletionInputMessageChunkType, + ChatCompletionOutput, + ChatCompletionOutputComplete, + ChatCompletionOutputMessage, + ChatCompletionStreamOutput, + ChatCompletionStreamOutputChoice, + ChatCompletionStreamOutputDelta, +} from "./chat-completion/inference.js"; +export type * from "./document-question-answering/inference.js"; +export type * from "./feature-extraction/inference.js"; +export type * from "./fill-mask/inference.js"; +export type { + ImageClassificationInput, + ImageClassificationOutput, + ImageClassificationOutputElement, + ImageClassificationParameters, +} from "./image-classification/inference.js"; +export type * from "./image-to-image/inference.js"; +export type { ImageToTextInput, ImageToTextOutput, ImageToTextParameters } from "./image-to-text/inference.js"; +export type * from "./image-segmentation/inference.js"; +export type { ImageToVideoInput, ImageToVideoOutput, ImageToVideoParameters } from "./image-to-video/inference.js"; +export type { + ImageTextToImageInput, + ImageTextToImageOutput, + ImageTextToImageParameters, +} from "./image-text-to-image/inference.js"; +export type { + ImageTextToVideoInput, + ImageTextToVideoOutput, + ImageTextToVideoParameters, +} from "./image-text-to-video/inference.js"; +export type * from "./object-detection/inference.js"; +export type * from "./depth-estimation/inference.js"; +export type * from "./question-answering/inference.js"; +export type * from "./sentence-similarity/inference.js"; +export type * from "./summarization/inference.js"; +export type * from "./table-question-answering/inference.js"; +export type { TextToImageInput, TextToImageOutput, TextToImageParameters } from "./text-to-image/inference.js"; +export type { TextToVideoParameters, TextToVideoOutput, TextToVideoInput } from "./text-to-video/inference.js"; +export type { TextToSpeechParameters, TextToSpeechInput, TextToSpeechOutput } from "./text-to-speech/inference.js"; +export type * from "./token-classification/inference.js"; +export type { TranslationInput, TranslationOutput } from "./translation/inference.js"; +export type { + ClassificationOutputTransform, + TextClassificationInput, + TextClassificationOutput, + TextClassificationOutputElement, + TextClassificationParameters, +} from "./text-classification/inference.js"; +export type { + TextGenerationOutputFinishReason, + TextGenerationOutputPrefillToken, + TextGenerationInput, + TextGenerationOutput, + TextGenerationOutputDetails, + TextGenerationInputGenerateParameters, + TextGenerationOutputBestOfSequence, + TextGenerationOutputToken, + TextGenerationStreamOutputStreamDetails, + TextGenerationStreamOutput, +} from "./text-generation/inference.js"; +export type * from "./video-classification/inference.js"; +export type * from "./visual-question-answering/inference.js"; +export type * from "./zero-shot-classification/inference.js"; +export type * from "./zero-shot-image-classification/inference.js"; +export type { + BoundingBox, + ZeroShotObjectDetectionInput, + ZeroShotObjectDetectionOutput, + ZeroShotObjectDetectionOutputElement, +} from "./zero-shot-object-detection/inference.js"; + +import type { ModelLibraryKey } from "../model-libraries.js"; +/** + * Model libraries compatible with each ML task + */ +export const TASKS_MODEL_LIBRARIES: Record = { + "audio-classification": ["speechbrain", "transformers", "transformers.js"], + "audio-to-audio": ["asteroid", "fairseq", "speechbrain"], + "automatic-speech-recognition": ["espnet", "nemo", "speechbrain", "transformers", "transformers.js"], + "audio-text-to-text": ["transformers"], + "depth-estimation": ["transformers", "transformers.js"], + "document-question-answering": ["transformers", "transformers.js"], + "feature-extraction": ["sentence-transformers", "transformers", "transformers.js"], + "fill-mask": ["transformers", "transformers.js"], + "graph-ml": ["transformers"], + "image-classification": ["keras", "timm", "transformers", "transformers.js"], + "image-feature-extraction": ["timm", "transformers"], + "image-segmentation": ["transformers", "transformers.js"], + "image-text-to-text": ["transformers"], + "image-text-to-image": ["diffusers"], + "image-text-to-video": ["diffusers"], + "image-to-image": ["diffusers", "transformers", "transformers.js"], + "image-to-text": ["transformers", "transformers.js"], + "image-to-video": ["diffusers"], + "keypoint-detection": ["transformers"], + "video-classification": ["transformers"], + "mask-generation": ["transformers"], + "multiple-choice": ["transformers"], + "object-detection": ["transformers", "transformers.js", "ultralytics"], + other: [], + "question-answering": ["adapter-transformers", "allennlp", "transformers", "transformers.js"], + robotics: [], + "reinforcement-learning": ["transformers", "stable-baselines3", "ml-agents", "sample-factory"], + "sentence-similarity": ["sentence-transformers", "spacy", "transformers.js"], + summarization: ["transformers", "transformers.js"], + "table-question-answering": ["transformers"], + "table-to-text": ["transformers"], + "tabular-classification": ["sklearn"], + "tabular-regression": ["sklearn"], + "tabular-to-text": ["transformers"], + "text-classification": ["adapter-transformers", "setfit", "spacy", "transformers", "transformers.js"], + "text-generation": ["transformers", "transformers.js"], + "text-ranking": ["sentence-transformers", "transformers"], + "text-retrieval": [], + "text-to-image": ["diffusers"], + "text-to-speech": ["espnet", "tensorflowtts", "transformers", "transformers.js"], + "text-to-audio": ["transformers", "transformers.js"], + "text-to-video": ["diffusers"], + "time-series-forecasting": [], + "token-classification": [ + "adapter-transformers", + "flair", + "spacy", + "span-marker", + "stanza", + "transformers", + "transformers.js", + ], + translation: ["transformers", "transformers.js"], + "unconditional-image-generation": ["diffusers"], + "video-text-to-text": ["transformers"], + "visual-question-answering": ["transformers", "transformers.js"], + "voice-activity-detection": [], + "zero-shot-classification": ["transformers", "transformers.js"], + "zero-shot-image-classification": ["transformers", "transformers.js"], + "zero-shot-object-detection": ["transformers", "transformers.js"], + "text-to-3d": ["diffusers"], + "image-to-3d": ["diffusers"], + "any-to-any": ["transformers"], + "visual-document-retrieval": ["transformers"], + "video-to-video": ["diffusers"], +}; + +/** + * Return the whole TaskData object for a certain task. + * If the partialTaskData argument is left undefined, + * the default placeholder data will be used. + */ +function getData(type: PipelineType, partialTaskData: TaskDataCustom = placeholder): TaskData { + return { + ...partialTaskData, + id: type, + label: PIPELINE_DATA[type].name, + libraries: TASKS_MODEL_LIBRARIES[type], + }; +} + +// To make comparisons easier, task order is the same as in const.ts +// Tasks set to undefined won't have an associated task page. +// Tasks that call getData() without the second argument will +// have a "placeholder" page. +export const TASKS_DATA: Record = { + "any-to-any": getData("any-to-any", anyToAny), + "audio-classification": getData("audio-classification", audioClassification), + "audio-to-audio": getData("audio-to-audio", audioToAudio), + "audio-text-to-text": getData("audio-text-to-text", audioTextToText), + "automatic-speech-recognition": getData("automatic-speech-recognition", automaticSpeechRecognition), + "depth-estimation": getData("depth-estimation", depthEstimation), + "document-question-answering": getData("document-question-answering", documentQuestionAnswering), + "visual-document-retrieval": getData("visual-document-retrieval", visualDocumentRetrieval), + "feature-extraction": getData("feature-extraction", featureExtraction), + "fill-mask": getData("fill-mask", fillMask), + "graph-ml": undefined, + "image-classification": getData("image-classification", imageClassification), + "image-feature-extraction": getData("image-feature-extraction", imageFeatureExtraction), + "image-segmentation": getData("image-segmentation", imageSegmentation), + "image-to-image": getData("image-to-image", imageToImage), + "image-text-to-text": getData("image-text-to-text", imageTextToText), + "image-text-to-image": getData("image-text-to-image", imageTextToImage), + "image-text-to-video": getData("image-text-to-video", imageTextToVideo), + "image-to-text": getData("image-to-text", imageToText), + "image-to-video": getData("image-to-video", imageToVideo), + "keypoint-detection": getData("keypoint-detection", keypointDetection), + "mask-generation": getData("mask-generation", maskGeneration), + "multiple-choice": undefined, + "object-detection": getData("object-detection", objectDetection), + "video-classification": getData("video-classification", videoClassification), + other: undefined, + "question-answering": getData("question-answering", questionAnswering), + "reinforcement-learning": getData("reinforcement-learning", reinforcementLearning), + robotics: undefined, + "sentence-similarity": getData("sentence-similarity", sentenceSimilarity), + summarization: getData("summarization", summarization), + "table-question-answering": getData("table-question-answering", tableQuestionAnswering), + "table-to-text": undefined, + "tabular-classification": getData("tabular-classification", tabularClassification), + "tabular-regression": getData("tabular-regression", tabularRegression), + "tabular-to-text": undefined, + "text-classification": getData("text-classification", textClassification), + "text-generation": getData("text-generation", textGeneration), + "text-ranking": getData("text-ranking", textRanking), + "text-retrieval": undefined, + "text-to-image": getData("text-to-image", textToImage), + "text-to-speech": getData("text-to-speech", textToSpeech), + "text-to-audio": undefined, + "text-to-video": getData("text-to-video", textToVideo), + "time-series-forecasting": undefined, + "token-classification": getData("token-classification", tokenClassification), + translation: getData("translation", translation), + "unconditional-image-generation": getData("unconditional-image-generation", unconditionalImageGeneration), + "video-text-to-text": getData("video-text-to-text", videoTextToText), + "video-to-video": getData("video-to-video", videoToVideo), + "visual-question-answering": getData("visual-question-answering", visualQuestionAnswering), + "voice-activity-detection": undefined, + "zero-shot-classification": getData("zero-shot-classification", zeroShotClassification), + "zero-shot-image-classification": getData("zero-shot-image-classification", zeroShotImageClassification), + "zero-shot-object-detection": getData("zero-shot-object-detection", zeroShotObjectDetection), + "text-to-3d": getData("text-to-3d", textTo3D), + "image-to-3d": getData("image-to-3d", imageTo3D), +} as const; + +export interface ExampleRepo { + description: string; + id: string; +} + +export type TaskDemoEntry = + | { + filename: string; + type: "audio"; + } + | { + data: Array<{ + label: string; + score: number; + }>; + type: "chart"; + } + | { + filename: string; + type: "img"; + } + | { + table: string[][]; + type: "tabular"; + } + | { + content: string; + label: string; + type: "text"; + } + | { + text: string; + tokens: Array<{ + end: number; + start: number; + type: string; + }>; + type: "text-with-tokens"; + }; + +export interface TaskDemo { + inputs: TaskDemoEntry[]; + outputs: TaskDemoEntry[]; +} + +export interface TaskData { + datasets: ExampleRepo[]; + demo: TaskDemo; + id: PipelineType; + canonicalId?: PipelineType; + isPlaceholder?: boolean; + label: string; + libraries: ModelLibraryKey[]; + metrics: ExampleRepo[]; + models: ExampleRepo[]; + spaces: ExampleRepo[]; + summary: string; + widgetModels: string[]; + youtubeId?: string; +} + +export type TaskDataCustom = Omit; diff --git a/node_modules/@huggingface/tasks/src/tasks/keypoint-detection/about.md b/node_modules/@huggingface/tasks/src/tasks/keypoint-detection/about.md new file mode 100644 index 0000000000000000000000000000000000000000..3758fdd831d23163ea1974842faf1330c7748c0a --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/keypoint-detection/about.md @@ -0,0 +1,57 @@ +## Task Variants + +### Pose Estimation + +Pose estimation is the process of determining the position and orientation of an object or a camera in a 3D space. It is a fundamental task in computer vision and is widely used in various applications such as robotics, augmented reality, and 3D reconstruction. + +## Use Cases for Keypoint Detection + +### Facial Landmark Estimation + +Keypoint detection models can be used to estimate the position of facial landmarks. Facial landmarks are points on the face such as the corners of the mouth, the outer corners of the eyes, and the tip of the nose. These landmarks can be used for a variety of applications, such as facial expression recognition, 3D face reconstruction, and cinematic animation. + +### Fitness Tracking + +Keypoint detection models can be used to track the movement of the human body, e.g. position of the joints in a 3D space. This can be used for a variety of applications, such as fitness tracking, sports analysis or virtual reality applications. + +## Inference Code + +Below you can find an example of how to use a keypoint detection model and how to visualize the results. + +```python +from transformers import AutoImageProcessor, SuperPointForKeypointDetection +import torch +import matplotlib.pyplot as plt +from PIL import Image +import requests + +url_image = "http://images.cocodataset.org/val2017/000000039769.jpg" +image = Image.open(requests.get(url_image_1, stream=True).raw) + +# initialize the model and processor +processor = AutoImageProcessor.from_pretrained("magic-leap-community/superpoint") +model = SuperPointForKeypointDetection.from_pretrained("magic-leap-community/superpoint") + +# infer +inputs = processor(image, return_tensors="pt").to(model.device, model.dtype) +outputs = model(**inputs) + +# postprocess +image_sizes = [(image.size[1], image.size[0])] +outputs = processor.post_process_keypoint_detection(model_outputs, image_sizes) +keypoints = outputs[0]["keypoints"].detach().numpy() +scores = outputs[0]["scores"].detach().numpy() +image_width, image_height = image.size + +# plot +plt.axis('off') +plt.imshow(image) +plt.scatter( + keypoints[:, 0], + keypoints[:, 1], + s=scores * 100, + c='cyan', + alpha=0.4 +) +plt.show() +``` diff --git a/node_modules/@huggingface/tasks/src/tasks/keypoint-detection/data.ts b/node_modules/@huggingface/tasks/src/tasks/keypoint-detection/data.ts new file mode 100644 index 0000000000000000000000000000000000000000..5d6e3d6c25825ecf75ac60a9fe681940cc30a13a --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/keypoint-detection/data.ts @@ -0,0 +1,58 @@ +import type { TaskDataCustom } from "../index.js"; + +const taskData: TaskDataCustom = { + datasets: [ + { + description: "A dataset of hand keypoints of over 500k examples.", + id: "Vincent-luo/hagrid-mediapipe-hands", + }, + ], + demo: { + inputs: [ + { + filename: "keypoint-detection-input.png", + type: "img", + }, + ], + outputs: [ + { + filename: "keypoint-detection-output.png", + type: "img", + }, + ], + }, + metrics: [], + models: [ + { + description: "A robust keypoint detection model.", + id: "magic-leap-community/superpoint", + }, + { + description: "A robust keypoint matching model.", + id: "magic-leap-community/superglue_outdoor", + }, + { + description: "Strong keypoint detection model used to detect human pose.", + id: "qualcomm/RTMPose-Body2d", + }, + { + description: "Powerful keypoint matching model.", + id: "ETH-CVG/lightglue_disk", + }, + ], + spaces: [ + { + description: "An application that detects hand keypoints in real-time.", + id: "datasciencedojo/Hand-Keypoint-Detection-Realtime", + }, + { + description: "An application for keypoint detection and matching.", + id: "ETH-CVG/LightGlue", + }, + ], + summary: "Keypoint detection is the task of identifying meaningful distinctive points or features in an image.", + widgetModels: [], + youtubeId: "", +}; + +export default taskData; diff --git a/node_modules/@huggingface/tasks/src/tasks/mask-generation/about.md b/node_modules/@huggingface/tasks/src/tasks/mask-generation/about.md new file mode 100644 index 0000000000000000000000000000000000000000..2fa3a65d22a4be467172062f324248023bc7360a --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/mask-generation/about.md @@ -0,0 +1,75 @@ +## Use Cases + +### Filtering an Image + +When filtering for an image, the generated masks might serve as an initial filter to eliminate irrelevant information. For instance, when monitoring vegetation in satellite imaging, mask generation models identify green spots, highlighting the relevant region of the image. + +### Masked Image Modelling + +Generating masks can facilitate learning, especially in semi or unsupervised learning. For example, the [BEiT model](https://huggingface.co/docs/transformers/model_doc/beit) uses image-mask patches in the pre-training. + +### Human-in-the-loop Computer Vision Applications + +For applications where humans are in the loop, masks highlight certain regions of images for humans to validate. + +### Medical Imaging + +Mask generation models are used in medical imaging to aid in segmenting and analyzing specific regions. + +### Autonomous Vehicles + +Mask generation models are used to create segments and masks for obstacles and other objects in view. + +This page was made possible thanks to the efforts of [Raj Aryan](https://huggingface.co/thatrajaryan) and other contributors. + +## Task Variants + +### Segmentation + +Image Segmentation divides an image into segments where each pixel is mapped to an object. This task has multiple variants, such as instance segmentation, panoptic segmentation, and semantic segmentation. You can learn more about segmentation on its [task page](https://huggingface.co/tasks/image-segmentation). + +## Inference + +Mask generation models often work in two modes: segment everything or prompt mode. +The example below works in segment-everything-mode, where many masks will be returned. + +```python +from transformers import pipeline + +generator = pipeline("mask-generation", model="Zigeng/SlimSAM-uniform-50", points_per_batch=64, device="cuda") +image_url = "https://huggingface.co/ybelkada/segment-anything/resolve/main/assets/car.png" +outputs = generator(image_url) +outputs["masks"] +# array of multiple binary masks returned for each generated mask +``` + +Prompt mode takes in three types of prompts: + +- **Point prompt:** The user can select a point on the image, and a meaningful segment around the point will be returned. +- **Box prompt:** The user can draw a box on the image, and a meaningful segment within the box will be returned. +- **Text prompt:** The user can input a text, and the objects of that type will be segmented. Note that this capability has not yet been released and has only been explored in research. + +Below you can see how to use an input-point prompt. It also demonstrates direct model inference without the `pipeline` abstraction. The input prompt here is a nested list where the outermost list is the batch size (`1`), then the number of points (also `1` in this example), and the innermost list contains the actual coordinates of the point (`[450, 600]`). + +```python +from transformers import SamModel, SamProcessor +from PIL import Image +import requests + +model = SamModel.from_pretrained("Zigeng/SlimSAM-uniform-50").to("cuda") +processor = SamProcessor.from_pretrained("Zigeng/SlimSAM-uniform-50") + +raw_image = Image.open(requests.get(image_url, stream=True).raw).convert("RGB") +# pointing to the car window +input_points = [[[450, 600]]] +inputs = processor(raw_image, input_points=input_points, return_tensors="pt").to("cuda") +outputs = model(**inputs) +masks = processor.post_process_masks(outputs.pred_masks.cpu(), inputs["original_sizes"].cpu(), inputs["reshaped_input_sizes"].cpu()) +scores = outputs.iou_scores +``` + +## Useful Resources + +Would you like to learn more about mask generation? Great! Here you can find some curated resources that you may find helpful! + +- [Segment anything model](https://huggingface.co/docs/transformers/main/model_doc/sam) diff --git a/node_modules/@huggingface/tasks/src/tasks/mask-generation/data.ts b/node_modules/@huggingface/tasks/src/tasks/mask-generation/data.ts new file mode 100644 index 0000000000000000000000000000000000000000..cc18380dbe2f37b4ad6d2587dd7b102d6fbef5f3 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/mask-generation/data.ts @@ -0,0 +1,69 @@ +import type { TaskDataCustom } from "../index.js"; + +const taskData: TaskDataCustom = { + datasets: [ + { + description: "Widely used benchmark dataset for multiple Vision tasks.", + id: "merve/coco2017", + }, + { + description: "Medical Imaging dataset of the Human Brain for segmentation and mask generating tasks", + id: "rocky93/BraTS_segmentation", + }, + ], + demo: { + inputs: [ + { + filename: "mask-generation-input.png", + type: "img", + }, + ], + outputs: [ + { + filename: "mask-generation-output.png", + type: "img", + }, + ], + }, + metrics: [ + { + description: "IoU is used to measure the overlap between predicted mask and the ground truth mask.", + id: "Intersection over Union (IoU)", + }, + ], + models: [ + { + description: "Small yet powerful mask generation model.", + id: "Zigeng/SlimSAM-uniform-50", + }, + { + description: "Very strong mask generation model.", + id: "facebook/sam2-hiera-large", + }, + ], + spaces: [ + { + description: + "An application that combines a mask generation model with a zero-shot object detection model for text-guided image segmentation.", + id: "merve/OWLSAM2", + }, + { + description: "An application that compares the performance of a large and a small mask generation model.", + id: "merve/slimsam", + }, + { + description: "An application based on an improved mask generation model.", + id: "SkalskiP/segment-anything-model-2", + }, + { + description: "An application to remove objects from videos using mask generation models.", + id: "SkalskiP/SAM_and_ProPainter", + }, + ], + summary: + "Mask generation is the task of generating masks that identify a specific object or region of interest in a given image. Masks are often used in segmentation tasks, where they provide a precise way to isolate the object of interest for further processing or analysis.", + widgetModels: [], + youtubeId: "", +}; + +export default taskData; diff --git a/node_modules/@huggingface/tasks/src/tasks/object-detection/about.md b/node_modules/@huggingface/tasks/src/tasks/object-detection/about.md new file mode 100644 index 0000000000000000000000000000000000000000..4dda21224f937a27a5f56d40ee877ff03eaf1d09 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/object-detection/about.md @@ -0,0 +1,37 @@ +## Use Cases + +### Autonomous Driving + +Object Detection is widely used in computer vision for autonomous driving. Self-driving cars use Object Detection models to detect pedestrians, bicycles, traffic lights and road signs to decide which step to take. + +### Object Tracking in Matches + +Object Detection models are widely used in sports where the ball or a player is tracked for monitoring and refereeing during matches. + +### Image Search + +Object Detection models are widely used in image search. Smartphones use Object Detection models to detect entities (such as specific places or objects) and allow the user to search for the entity on the Internet. + +### Object Counting + +Object Detection models are used to count instances of objects in a given image, this can include counting the objects in warehouses or stores, or counting the number of visitors in a store. They are also used to manage crowds at events to prevent disasters. + +## Inference + +You can infer with Object Detection models through the `object-detection` pipeline. When calling the pipeline you just need to specify a path or http link to an image. + +```python +model = pipeline("object-detection") + +model("path_to_cat_image") + +# [{'label': 'blanket', +# 'mask': mask_string, +# 'score': 0.917}, +#...] +``` + +# Useful Resources + +- [Walkthrough of Computer Vision Ecosystem in Hugging Face - CV Study Group](https://www.youtube.com/watch?v=oL-xmufhZM8) +- [Object detection task guide](https://huggingface.co/docs/transformers/tasks/object_detection) diff --git a/node_modules/@huggingface/tasks/src/tasks/object-detection/data.ts b/node_modules/@huggingface/tasks/src/tasks/object-detection/data.ts new file mode 100644 index 0000000000000000000000000000000000000000..3b962813340e659b93a3574844bcb3c11f070846 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/object-detection/data.ts @@ -0,0 +1,90 @@ +import type { TaskDataCustom } from "../index.js"; + +const taskData: TaskDataCustom = { + datasets: [ + { + description: "Widely used benchmark dataset for multiple vision tasks.", + id: "merve/coco2017", + }, + { + description: "Multi-task computer vision benchmark.", + id: "merve/pascal-voc", + }, + ], + demo: { + inputs: [ + { + filename: "object-detection-input.jpg", + type: "img", + }, + ], + outputs: [ + { + filename: "object-detection-output.jpg", + type: "img", + }, + ], + }, + metrics: [ + { + description: + "The Average Precision (AP) metric is the Area Under the PR Curve (AUC-PR). It is calculated for each class separately", + id: "Average Precision", + }, + { + description: "The Mean Average Precision (mAP) metric is the overall average of the AP values", + id: "Mean Average Precision", + }, + { + description: + "The APα metric is the Average Precision at the IoU threshold of a α value, for example, AP50 and AP75", + id: "APα", + }, + ], + models: [ + { + description: "Solid object detection model pre-trained on the COCO 2017 dataset.", + id: "facebook/detr-resnet-50", + }, + { + description: "Accurate object detection model.", + id: "IDEA-Research/dab-detr-resnet-50", + }, + { + description: "Fast and accurate object detection model.", + id: "PekingU/rtdetr_v2_r50vd", + }, + { + description: "Object detection model for low-lying objects.", + id: "StephanST/WALDO30", + }, + ], + spaces: [ + { + description: "Real-time object detection demo.", + id: "Roboflow/RF-DETR", + }, + { + description: "An application that contains various object detection models to try from.", + id: "Gradio-Blocks/Object-Detection-With-DETR-and-YOLOS", + }, + { + description: "A cutting-edge object detection application.", + id: "sunsmarterjieleaf/yolov12", + }, + { + description: "An object tracking, segmentation and inpainting application.", + id: "VIPLab/Track-Anything", + }, + { + description: "Very fast object tracking application based on object detection.", + id: "merve/RT-DETR-tracking-coco", + }, + ], + summary: + "Object Detection models allow users to identify objects of certain defined classes. Object detection models receive an image as input and output the images with bounding boxes and labels on detected objects.", + widgetModels: ["facebook/detr-resnet-50"], + youtubeId: "WdAeKSOpxhw", +}; + +export default taskData; diff --git a/node_modules/@huggingface/tasks/src/tasks/object-detection/inference.ts b/node_modules/@huggingface/tasks/src/tasks/object-detection/inference.ts new file mode 100644 index 0000000000000000000000000000000000000000..58f330e681686e98f84dab3bb6cccffde197c79b --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/object-detection/inference.ts @@ -0,0 +1,73 @@ +/** + * Inference code generated from the JSON schema spec in ./spec + * + * Using src/scripts/inference-codegen + */ +/** + * Inputs for Object Detection inference + */ +export interface ObjectDetectionInput { + /** + * The input image data as a base64-encoded string. If no `parameters` are provided, you can + * also provide the image data as a raw bytes payload. + */ + inputs: Blob; + /** + * Additional inference parameters for Object Detection + */ + parameters?: ObjectDetectionParameters; + [property: string]: unknown; +} +/** + * Additional inference parameters for Object Detection + */ +export interface ObjectDetectionParameters { + /** + * The probability necessary to make a prediction. + */ + threshold?: number; + [property: string]: unknown; +} +/** + * The predicted bounding box. Coordinates are relative to the top left corner of the input + * image. + */ +export interface BoundingBox { + /** + * The x-coordinate of the bottom-right corner of the bounding box. + */ + xmax: number; + /** + * The x-coordinate of the top-left corner of the bounding box. + */ + xmin: number; + /** + * The y-coordinate of the bottom-right corner of the bounding box. + */ + ymax: number; + /** + * The y-coordinate of the top-left corner of the bounding box. + */ + ymin: number; + [property: string]: unknown; +} +export type ObjectDetectionOutput = ObjectDetectionOutputElement[]; +/** + * Outputs of inference for the Object Detection task + */ +export interface ObjectDetectionOutputElement { + /** + * The predicted bounding box. Coordinates are relative to the top left corner of the input + * image. + */ + box: BoundingBox; + /** + * The predicted label for the bounding box. + */ + label: string; + /** + * The associated score / probability. + */ + score: number; + [property: string]: unknown; +} diff --git a/node_modules/@huggingface/tasks/src/tasks/object-detection/spec/input.json b/node_modules/@huggingface/tasks/src/tasks/object-detection/spec/input.json new file mode 100644 index 0000000000000000000000000000000000000000..55df78f56bc0130af7b952de88be400ae62d9d98 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/object-detection/spec/input.json @@ -0,0 +1,31 @@ +{ + "$id": "/inference/schemas/object-detection/input.json", + "$schema": "http://json-schema.org/draft-06/schema#", + "description": "Inputs for Object Detection inference", + "title": "ObjectDetectionInput", + "type": "object", + "properties": { + "inputs": { + "type": "string", + "description": "The input image data as a base64-encoded string. If no `parameters` are provided, you can also provide the image data as a raw bytes payload.", + "comment": "type=binary" + }, + "parameters": { + "description": "Additional inference parameters for Object Detection", + "$ref": "#/$defs/ObjectDetectionParameters" + } + }, + "$defs": { + "ObjectDetectionParameters": { + "title": "ObjectDetectionParameters", + "type": "object", + "properties": { + "threshold": { + "type": "number", + "description": "The probability necessary to make a prediction." + } + } + } + }, + "required": ["inputs"] +} diff --git a/node_modules/@huggingface/tasks/src/tasks/object-detection/spec/output.json b/node_modules/@huggingface/tasks/src/tasks/object-detection/spec/output.json new file mode 100644 index 0000000000000000000000000000000000000000..8d91f1078f664fff39eff78d0ff4bba00d9a0a79 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/object-detection/spec/output.json @@ -0,0 +1,50 @@ +{ + "$id": "/inference/schemas/object-detection/output.json", + "$schema": "http://json-schema.org/draft-06/schema#", + "description": "Outputs of inference for the Object Detection task", + "title": "ObjectDetectionOutput", + "type": "array", + "items": { + "type": "object", + "properties": { + "label": { + "type": "string", + "description": "The predicted label for the bounding box." + }, + "score": { + "type": "number", + "description": "The associated score / probability." + }, + "box": { + "$ref": "#/$defs/BoundingBox", + "description": "The predicted bounding box. Coordinates are relative to the top left corner of the input image." + } + }, + "required": ["box", "label", "score"] + }, + "$defs": { + "BoundingBox": { + "type": "object", + "title": "BoundingBox", + "properties": { + "xmin": { + "type": "integer", + "description": "The x-coordinate of the top-left corner of the bounding box." + }, + "xmax": { + "type": "integer", + "description": "The x-coordinate of the bottom-right corner of the bounding box." + }, + "ymin": { + "type": "integer", + "description": "The y-coordinate of the top-left corner of the bounding box." + }, + "ymax": { + "type": "integer", + "description": "The y-coordinate of the bottom-right corner of the bounding box." + } + }, + "required": ["xmin", "xmax", "ymin", "ymax"] + } + } +} diff --git a/node_modules/@huggingface/tasks/src/tasks/placeholder/about.md b/node_modules/@huggingface/tasks/src/tasks/placeholder/about.md new file mode 100644 index 0000000000000000000000000000000000000000..fdb45584410dcd07e530607d469140038ede6b25 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/placeholder/about.md @@ -0,0 +1,15 @@ +## Use Cases + +You can contribute this area with common use cases of the task! + +## Task Variants + +This place can be filled with variants of this task if there's any. + +## Inference + +This section should have useful information about how to pull a model from Hugging Face Hub that is a part of a library specialized in a task and use it. + +## Useful Resources + +In this area, you can insert useful resources about how to train or use a model for this task. diff --git a/node_modules/@huggingface/tasks/src/tasks/placeholder/data.ts b/node_modules/@huggingface/tasks/src/tasks/placeholder/data.ts new file mode 100644 index 0000000000000000000000000000000000000000..c103e16a889e42b08a4987fb91a3c962cb1afb02 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/placeholder/data.ts @@ -0,0 +1,21 @@ +import type { TaskDataCustom } from "../index.js"; + +const taskData: TaskDataCustom = { + datasets: [], + demo: { + inputs: [], + outputs: [], + }, + isPlaceholder: true, + metrics: [], + models: [], + spaces: [], + summary: "", + widgetModels: [], + youtubeId: undefined, + /// If this is a subtask, link to the most general task ID + /// (eg, text-generation is the canonical ID of text-simplification) + canonicalId: undefined, +}; + +export default taskData; diff --git a/node_modules/@huggingface/tasks/src/tasks/placeholder/spec/input.json b/node_modules/@huggingface/tasks/src/tasks/placeholder/spec/input.json new file mode 100644 index 0000000000000000000000000000000000000000..aab9dd1525b387db8aaaf2ef07d75ab355143d8d --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/placeholder/spec/input.json @@ -0,0 +1,34 @@ +{ + "$id": "/inference/schemas//input.json", + "$schema": "http://json-schema.org/draft-06/schema#", + "description": "Inputs for inference", + "title": "PlaceholderInput", + "type": "object", + "properties": { + "inputs": { + "description": "TODO: describe the input here. This must be model & framework agnostic.", + "type": "string" + }, + "parameters": { + "description": "TODO: describe additional parameters here.", + "$ref": "#/$defs/Parameters" + } + }, + "$defs": { + "Parameters": { + "title": "Parameters", + "type": "object", + "properties": { + "dummy_parameter_name": { + "type": "boolean", + "description": "TODO: describe the parameter here" + }, + "dummy_parameter_name2": { + "type": "integer", + "description": "TODO: describe the parameter here" + } + } + } + }, + "required": ["inputs"] +} diff --git a/node_modules/@huggingface/tasks/src/tasks/placeholder/spec/output.json b/node_modules/@huggingface/tasks/src/tasks/placeholder/spec/output.json new file mode 100644 index 0000000000000000000000000000000000000000..a71a1ae149704cb6317fd35a539be343c454ef81 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/placeholder/spec/output.json @@ -0,0 +1,17 @@ +{ + "$id": "/inference/schemas//output.json", + "$schema": "http://json-schema.org/draft-06/schema#", + "description": "Outputs for inference", + "title": "PlaceholderOutput", + "type": "array", + "items": { + "type": "object", + "properties": { + "meaningful_output_name": { + "type": "string", + "description": "TODO: Describe what is outputted by the inference here" + } + }, + "required": ["meaningfulOutputName"] + } +} diff --git a/node_modules/@huggingface/tasks/src/tasks/question-answering/about.md b/node_modules/@huggingface/tasks/src/tasks/question-answering/about.md new file mode 100644 index 0000000000000000000000000000000000000000..d5934ee80c7ca32c53726ef5b9e715af54a0b5d6 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/question-answering/about.md @@ -0,0 +1,56 @@ +## Use Cases + +### Frequently Asked Questions + +You can use Question Answering (QA) models to automate the response to frequently asked questions by using a knowledge base (documents) as context. Answers to customer questions can be drawn from those documents. + +⚡⚡ If you’d like to save inference time, you can first use [passage ranking models](/tasks/sentence-similarity) to see which document might contain the answer to the question and iterate over that document with the QA model instead. + +## Task Variants +There are different QA variants based on the inputs and outputs: + +- **Extractive QA:** The model **extracts** the answer from a context. The context here could be a provided text, a table or even HTML! This is usually solved with BERT-like models. +- **Open Generative QA:** The model **generates** free text directly based on the context. You can learn more about the Text Generation task in [its page](/tasks/text-generation). +- **Closed Generative QA:** In this case, no context is provided. The answer is completely generated by a model. + +The schema above illustrates extractive, open book QA. The model takes a context and the question and extracts the answer from the given context. + +You can also differentiate QA models depending on whether they are open-domain or closed-domain. Open-domain models are not restricted to a specific domain, while closed-domain models are restricted to a specific domain (e.g. legal, medical documents). + +## Inference + +You can infer with QA models with the 🤗 Transformers library using the `question-answering` pipeline. If no model checkpoint is given, the pipeline will be initialized with `distilbert-base-cased-distilled-squad`. This pipeline takes a question and a context from which the answer will be extracted and returned. + +```python +from transformers import pipeline + +qa_model = pipeline("question-answering") +question = "Where do I live?" +context = "My name is Merve and I live in İstanbul." +qa_model(question = question, context = context) +## {'answer': 'İstanbul', 'end': 39, 'score': 0.953, 'start': 31} +``` + +## Useful Resources + +Would you like to learn more about QA? Awesome! Here are some curated resources that you may find helpful! + +- [Course Chapter on Question Answering](https://huggingface.co/course/chapter7/7?fw=pt) +- [Question Answering Workshop](https://www.youtube.com/watch?v=Ihgk8kGLpIE&ab_channel=HuggingFace) +- [How to Build an Open-Domain Question Answering System?](https://lilianweng.github.io/lil-log/2020/10/29/open-domain-question-answering.html) +- [Blog Post: ELI5 A Model for Open Domain Long Form Question Answering](https://yjernite.github.io/lfqa.html) + +### Notebooks + +- [PyTorch](https://github.com/huggingface/notebooks/blob/master/examples/question_answering.ipynb) +- [TensorFlow](https://github.com/huggingface/notebooks/blob/main/examples/question_answering-tf.ipynb) + +### Scripts for training + +- [PyTorch](https://github.com/huggingface/transformers/tree/main/examples/pytorch/question-answering) +- [TensorFlow](https://github.com/huggingface/transformers/tree/main/examples/tensorflow/question-answering) +- [Flax](https://github.com/huggingface/transformers/tree/main/examples/flax/question-answering) + +### Documentation + +- [Question answering task guide](https://huggingface.co/docs/transformers/tasks/question_answering) diff --git a/node_modules/@huggingface/tasks/src/tasks/question-answering/data.ts b/node_modules/@huggingface/tasks/src/tasks/question-answering/data.ts new file mode 100644 index 0000000000000000000000000000000000000000..cf75dd3d7b9748e6670fef59497dd0feea6d4a6b --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/question-answering/data.ts @@ -0,0 +1,75 @@ +import type { TaskDataCustom } from "../index.js"; + +const taskData: TaskDataCustom = { + datasets: [ + { + // TODO write proper description + description: "A famous question answering dataset based on English articles from Wikipedia.", + id: "squad_v2", + }, + { + // TODO write proper description + description: "A dataset of aggregated anonymized actual queries issued to the Google search engine.", + id: "natural_questions", + }, + ], + demo: { + inputs: [ + { + label: "Question", + content: "Which name is also used to describe the Amazon rainforest in English?", + type: "text", + }, + { + label: "Context", + content: "The Amazon rainforest, also known in English as Amazonia or the Amazon Jungle", + type: "text", + }, + ], + outputs: [ + { + label: "Answer", + content: "Amazonia", + type: "text", + }, + ], + }, + metrics: [ + { + description: + "Exact Match is a metric based on the strict character match of the predicted answer and the right answer. For answers predicted correctly, the Exact Match will be 1. Even if only one character is different, Exact Match will be 0", + id: "exact-match", + }, + { + description: + " The F1-Score metric is useful if we value both false positives and false negatives equally. The F1-Score is calculated on each word in the predicted sequence against the correct answer", + id: "f1", + }, + ], + models: [ + { + description: "A robust baseline model for most question answering domains.", + id: "deepset/roberta-base-squad2", + }, + { + description: "Small yet robust model that can answer questions.", + id: "distilbert/distilbert-base-cased-distilled-squad", + }, + { + description: "A special model that can answer questions from tables.", + id: "google/tapas-base-finetuned-wtq", + }, + ], + spaces: [ + { + description: "An application that can answer a long question from Wikipedia.", + id: "deepset/wikipedia-assistant", + }, + ], + summary: + "Question Answering models can retrieve the answer to a question from a given text, which is useful for searching for an answer in a document. Some question answering models can generate answers without context!", + widgetModels: ["deepset/roberta-base-squad2"], + youtubeId: "ajPx5LwJD-I", +}; + +export default taskData; diff --git a/node_modules/@huggingface/tasks/src/tasks/question-answering/inference.ts b/node_modules/@huggingface/tasks/src/tasks/question-answering/inference.ts new file mode 100644 index 0000000000000000000000000000000000000000..bd478276bdd8e9c8473aa73d562a32845a93a968 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/question-answering/inference.ts @@ -0,0 +1,97 @@ +/** + * Inference code generated from the JSON schema spec in ./spec + * + * Using src/scripts/inference-codegen + */ +/** + * Inputs for Question Answering inference + */ +export interface QuestionAnsweringInput { + /** + * One (context, question) pair to answer + */ + inputs: QuestionAnsweringInputData; + /** + * Additional inference parameters for Question Answering + */ + parameters?: QuestionAnsweringParameters; + [property: string]: unknown; +} +/** + * One (context, question) pair to answer + */ +export interface QuestionAnsweringInputData { + /** + * The context to be used for answering the question + */ + context: string; + /** + * The question to be answered + */ + question: string; + [property: string]: unknown; +} +/** + * Additional inference parameters for Question Answering + */ +export interface QuestionAnsweringParameters { + /** + * Attempts to align the answer to real words. Improves quality on space separated + * languages. Might hurt on non-space-separated languages (like Japanese or Chinese) + */ + align_to_words?: boolean; + /** + * If the context is too long to fit with the question for the model, it will be split in + * several chunks with some overlap. This argument controls the size of that overlap. + */ + doc_stride?: number; + /** + * Whether to accept impossible as an answer. + */ + handle_impossible_answer?: boolean; + /** + * The maximum length of predicted answers (e.g., only answers with a shorter length are + * considered). + */ + max_answer_len?: number; + /** + * The maximum length of the question after tokenization. It will be truncated if needed. + */ + max_question_len?: number; + /** + * The maximum length of the total sentence (context + question) in tokens of each chunk + * passed to the model. The context will be split in several chunks (using docStride as + * overlap) if needed. + */ + max_seq_len?: number; + /** + * The number of answers to return (will be chosen by order of likelihood). Note that we + * return less than topk answers if there are not enough options available within the + * context. + */ + top_k?: number; + [property: string]: unknown; +} +export type QuestionAnsweringOutput = QuestionAnsweringOutputElement[]; +/** + * Outputs of inference for the Question Answering task + */ +export interface QuestionAnsweringOutputElement { + /** + * The answer to the question. + */ + answer: string; + /** + * The character position in the input where the answer ends. + */ + end: number; + /** + * The probability associated to the answer. + */ + score: number; + /** + * The character position in the input where the answer begins. + */ + start: number; + [property: string]: unknown; +} diff --git a/node_modules/@huggingface/tasks/src/tasks/question-answering/spec/input.json b/node_modules/@huggingface/tasks/src/tasks/question-answering/spec/input.json new file mode 100644 index 0000000000000000000000000000000000000000..266b329df3c3d27637bab119a70cf9394b77a16f --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/question-answering/spec/input.json @@ -0,0 +1,66 @@ +{ + "$id": "/inference/schemas/question-answering/input.json", + "$schema": "http://json-schema.org/draft-06/schema#", + "description": "Inputs for Question Answering inference", + "title": "QuestionAnsweringInput", + "type": "object", + "properties": { + "inputs": { + "title": "QuestionAnsweringInputData", + "description": "One (context, question) pair to answer", + "type": "object", + "properties": { + "context": { + "type": "string", + "description": "The context to be used for answering the question" + }, + "question": { + "type": "string", + "description": "The question to be answered" + } + }, + "required": ["question", "context"] + }, + "parameters": { + "description": "Additional inference parameters for Question Answering", + "$ref": "#/$defs/QuestionAnsweringParameters" + } + }, + "$defs": { + "QuestionAnsweringParameters": { + "title": "QuestionAnsweringParameters", + "type": "object", + "properties": { + "top_k": { + "type": "integer", + "description": "The number of answers to return (will be chosen by order of likelihood). Note that we return less than topk answers if there are not enough options available within the context." + }, + "doc_stride": { + "type": "integer", + "description": "If the context is too long to fit with the question for the model, it will be split in several chunks with some overlap. This argument controls the size of that overlap." + }, + "max_answer_len": { + "type": "integer", + "description": "The maximum length of predicted answers (e.g., only answers with a shorter length are considered)." + }, + "max_seq_len": { + "type": "integer", + "description": "The maximum length of the total sentence (context + question) in tokens of each chunk passed to the model. The context will be split in several chunks (using docStride as overlap) if needed." + }, + "max_question_len": { + "type": "integer", + "description": "The maximum length of the question after tokenization. It will be truncated if needed." + }, + "handle_impossible_answer": { + "type": "boolean", + "description": "Whether to accept impossible as an answer." + }, + "align_to_words": { + "type": "boolean", + "description": "Attempts to align the answer to real words. Improves quality on space separated languages. Might hurt on non-space-separated languages (like Japanese or Chinese)" + } + } + } + }, + "required": ["inputs"] +} diff --git a/node_modules/@huggingface/tasks/src/tasks/question-answering/spec/output.json b/node_modules/@huggingface/tasks/src/tasks/question-answering/spec/output.json new file mode 100644 index 0000000000000000000000000000000000000000..9da8f988ad21668db65d18e22cb105a0da96a63d --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/question-answering/spec/output.json @@ -0,0 +1,29 @@ +{ + "$id": "/inference/schemas/question-answering/output.json", + "$schema": "http://json-schema.org/draft-06/schema#", + "title": "QuestionAnsweringOutput", + "description": "Outputs of inference for the Question Answering task", + "type": "array", + "items": { + "type": "object", + "properties": { + "answer": { + "type": "string", + "description": "The answer to the question." + }, + "score": { + "type": "number", + "description": "The probability associated to the answer." + }, + "start": { + "type": "integer", + "description": "The character position in the input where the answer begins." + }, + "end": { + "type": "integer", + "description": "The character position in the input where the answer ends." + } + }, + "required": ["answer", "score", "start", "end"] + } +} diff --git a/node_modules/@huggingface/tasks/src/tasks/reinforcement-learning/about.md b/node_modules/@huggingface/tasks/src/tasks/reinforcement-learning/about.md new file mode 100644 index 0000000000000000000000000000000000000000..286fba9296b04b6389e3bcbb20bf7770f1bc982c --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/reinforcement-learning/about.md @@ -0,0 +1,167 @@ +## Use Cases + +### Gaming + +Reinforcement learning is known for its application to video games. Since the games provide a safe environment for the agent to be trained in the sense that it is perfectly defined and controllable, this makes them perfect candidates for experimentation and will help a lot to learn about the capabilities and limitations of various RL algorithms. + +There are many videos on the Internet where a game-playing reinforcement learning agent starts with a terrible gaming strategy due to random initialization of its settings, but over iterations, the agent gets better and better with each episode of the training. This [paper](https://arxiv.org/abs/1912.10944) mainly investigates the performance of RL in popular games such as Minecraft or Dota2. The agent's performance can exceed a human player's, although there are still some challenges mainly related to efficiency in constructing the gaming policy of the reinforcement learning agent. + +### Trading and Finance + +Reinforcement learning is the science to train computers to make decisions and thus has a novel use in trading and finance. All time-series models are helpful in predicting prices, volume and future sales of a product or a stock. Reinforcement based automated agents can decide to sell, buy or hold a stock. It shifts the impact of AI in this field to real time decision making rather than just prediction of prices. The glossary given below will clear some parameters to as to how we can train a model to take these decisions. + +## Task Variants + +### Model Based RL + +In model based reinforcement learning techniques intend to create a model of the environment, learn the state transition probabilities and the reward function, to find the optimal action. Some typical examples for model based reinforcement learning algorithms are dynamic programming, value iteration and policy iteration. + +### Model Free RL + +In model free reinforcement learning, agent decides on optimal actions based on its experience in the environment and the reward it collects from it. This is one of the most commonly used algorithms beneficial in complex environments, where modeling of state transition probabilities and reward functions are difficult. Some of the examples of model free reinforcement learning are SARSA, Q-Learning, actor-critic and proximal policy optimization (PPO) algorithms. + +## Glossary + + + +**Agent:** The learner and the decision maker. + +**Environment:** The part of the world the agent interacts, comprising everything outside the agent. + +Observations and states are the information our agent gets from the environment. In the case of a video game, it can be a frame (a screenshot). In the case of the trading agent, it can be the value of a certain stock. + +**State:** Complete description of the state of the environment with no hidden information. + +**Observation:** Partial description of the state, in a partially observed environment. + +**Action:** The decision taken by the agent. + +**Reward:** The numerical feedback signal that the agent receives from the environment based on the chosen action. + +**Return:** Cumulative Reward. In the simplest case, the return is the sum of the rewards. + +**Episode:** For some applications there is a natural notion of final time step. In this case, there is a starting point and an ending point (a terminal state). This creates an episode: a list of States, Actions, Rewards, and new States. For instance, think about Chess: an episode begins at the initial board position and ends when the game is over. + +**Policy:** The Policy is the brain of the Agent, it’s the function that tells what action to take given the state. So it defines the agent’s behavior at a given time. Reinforcement learning methods specify how the agent’s policy is changed as a result of its experience. + +## Inference + +Inference in reinforcement learning differs from other modalities, in which there's a model and test data. In reinforcement learning, once you have trained an agent in an environment, you try to run the trained agent for additional steps to get the average reward. + +A typical training cycle consists of gathering experience from the environment, training the agent, and running the agent on a test environment to obtain average reward. Below there's a snippet on how you can interact with the environment using the `gymnasium` library, train an agent using `stable-baselines3`, evaluate the agent on test environment and infer actions from the trained agent. + +```python +# Here we are running 20 episodes of CartPole-v1 environment, taking random actions +import gymnasium as gym + +env = gym.make("CartPole-v1") +observation, info = env.reset() + +for _ in range(20): + action = env.action_space.sample() # samples random action from action sample space + + # the agent takes the action + observation, reward, terminated, truncated, info = env.step(action) + + +# if the agent reaches terminal state, we reset the environment +if terminated or truncated: + + print("Environment is reset") + observation = env.reset() + +env.close() +``` + +Below snippet shows how to train a PPO model on LunarLander-v2 environment using `stable-baselines3` library and saving the model + +```python +from stable_baselines3 import PPO + +# initialize the environment + +env = gym.make("LunarLander-v2") + +# initialize the model + +model = PPO(policy = "MlpPolicy", + env = env, + n_steps = 1024, + batch_size = 64, + n_epochs = 4, + verbose = 1) + +# train the model for 1000 time steps +model.learn(total_timesteps = 1000) + +# Saving the model in desired directory +model_name = "PPO-LunarLander-v2" +model.save(model_name) +``` + +Below code shows how to evaluate an agent trained using `stable-baselines3` + +```python +# Loading a saved model and evaluating the model for 10 episodes +from stable_baselines3.common.evaluation import evaluate_policy +from stable_baselines3 import PPO + + +env = gym.make("LunarLander-v2") +# Loading the saved model +model = PPO.load("PPO-LunarLander-v2",env=env) + +# Initializing the evaluation environment +eval_env = gym.make("LunarLander-v2") + +# Running the trained agent on eval_env for 10 time steps and getting the mean reward +mean_reward, std_reward = evaluate_policy(model, eval_env, n_eval_episodes = 10, + deterministic=True) + +print(f"mean_reward={mean_reward:.2f} +/- {std_reward}") +``` + +Below code snippet shows how to infer actions from an agent trained using `stable-baselines3` + +```python +from stable_baselines3.common.evaluation import evaluate_policy +from stable_baselines3 import PPO + +# Loading the saved model +model = PPO.load("PPO-LunarLander-v2",env=env) + +# Getting the environment from the trained agent +env = model.get_env() + +obs = env.reset() +for i in range(1000): + # getting action predictions from the trained agent + action, _states = model.predict(obs, deterministic=True) + + # taking the predicted action in the environment to observe next state and rewards + obs, rewards, dones, info = env.step(action) +``` + +For more information, you can check out the documentations of the respective libraries. + +[Gymnasium Documentation](https://gymnasium.farama.org/) +[Stable Baselines Documentation](https://stable-baselines3.readthedocs.io/en/master/) + +## Useful Resources + +Would you like to learn more about the topic? Awesome! Here you can find some curated resources that you may find helpful! + +- [HuggingFace Deep Reinforcement Learning Class](https://github.com/huggingface/deep-rl-class) +- [Introduction to Deep Reinforcement Learning](https://huggingface.co/blog/deep-rl-intro) +- [Stable Baselines Integration with HuggingFace](https://huggingface.co/blog/sb3) +- Learn how reinforcement learning is used in conversational agents in this blog: [Illustrating Reinforcement Learning from Human Feedback (RLHF)](https://huggingface.co/blog/rlhf) +- [Reinforcement Learning from Human Feedback From Zero to ChatGPT](https://www.youtube.com/watch?v=EAd4oQtEJOM) +- [Guide on Multi-Agent Competition Systems](https://huggingface.co/blog/aivsai) + +### Notebooks + +- [Train a Deep Reinforcement Learning lander agent to land correctly on the Moon 🌕 using Stable-Baselines3](https://github.com/huggingface/deep-rl-class/blob/main/notebooks/unit1/unit1.ipynb) +- [Introduction to Unity MLAgents](https://github.com/huggingface/deep-rl-class/blob/main/notebooks/unit5/unit5.ipynb) +- [Training Decision Transformers with 🤗 transformers](https://github.com/huggingface/blog/blob/main/notebooks/101_train-decision-transformers.ipynb) + +This page was made possible thanks to the efforts of [Ram Ananth](https://huggingface.co/RamAnanth1), [Emilio Lehoucq](https://huggingface.co/emiliol), [Sagar Mathpal](https://huggingface.co/sagarmathpal) and [Osman Alenbey](https://huggingface.co/osman93). diff --git a/node_modules/@huggingface/tasks/src/tasks/reinforcement-learning/data.ts b/node_modules/@huggingface/tasks/src/tasks/reinforcement-learning/data.ts new file mode 100644 index 0000000000000000000000000000000000000000..231ecabda2c346cc1a681ac6f99f585086d202b7 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/reinforcement-learning/data.ts @@ -0,0 +1,75 @@ +import type { TaskDataCustom } from "../index.js"; + +const taskData: TaskDataCustom = { + datasets: [ + { + description: "A curation of widely used datasets for Data Driven Deep Reinforcement Learning (D4RL)", + id: "edbeeching/decision_transformer_gym_replay", + }, + ], + demo: { + inputs: [ + { + label: "State", + content: "Red traffic light, pedestrians are about to pass.", + type: "text", + }, + ], + outputs: [ + { + label: "Action", + content: "Stop the car.", + type: "text", + }, + { + label: "Next State", + content: "Yellow light, pedestrians have crossed.", + type: "text", + }, + ], + }, + metrics: [ + { + description: + "Accumulated reward across all time steps discounted by a factor that ranges between 0 and 1 and determines how much the agent optimizes for future relative to immediate rewards. Measures how good is the policy ultimately found by a given algorithm considering uncertainty over the future.", + id: "Discounted Total Reward", + }, + { + description: + "Average return obtained after running the policy for a certain number of evaluation episodes. As opposed to total reward, mean reward considers how much reward a given algorithm receives while learning.", + id: "Mean Reward", + }, + { + description: + "Measures how good a given algorithm is after a predefined time. Some algorithms may be guaranteed to converge to optimal behavior across many time steps. However, an agent that reaches an acceptable level of optimality after a given time horizon may be preferable to one that ultimately reaches optimality but takes a long time.", + id: "Level of Performance After Some Time", + }, + ], + models: [ + { + description: "A Reinforcement Learning model trained on expert data from the Gym Hopper environment", + + id: "edbeeching/decision-transformer-gym-hopper-expert", + }, + { + description: "A PPO agent playing seals/CartPole-v0 using the stable-baselines3 library and the RL Zoo.", + id: "HumanCompatibleAI/ppo-seals-CartPole-v0", + }, + ], + spaces: [ + { + description: "An application for a cute puppy agent learning to catch a stick.", + id: "ThomasSimonini/Huggy", + }, + { + description: "An application to play Snowball Fight with a reinforcement learning agent.", + id: "ThomasSimonini/SnowballFight", + }, + ], + summary: + "Reinforcement learning is the computational approach of learning from action by interacting with an environment through trial and error and receiving rewards (negative or positive) as feedback", + widgetModels: [], + youtubeId: "q0BiUn5LiBc", +}; + +export default taskData; diff --git a/node_modules/@huggingface/tasks/src/tasks/sentence-similarity/about.md b/node_modules/@huggingface/tasks/src/tasks/sentence-similarity/about.md new file mode 100644 index 0000000000000000000000000000000000000000..160d35d8185f68ab0da5f09093495cb0896ea7d6 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/sentence-similarity/about.md @@ -0,0 +1,97 @@ +## Use Cases 🔍 + +### Information Retrieval + +You can extract information from documents using Sentence Similarity models. The first step is to rank documents using Passage Ranking models. You can then get to the top ranked document and search it with Sentence Similarity models by selecting the sentence that has the most similarity to the input query. + +## The Sentence Transformers library + +The [Sentence Transformers](https://www.sbert.net/) library is very powerful for calculating embeddings of sentences, paragraphs, and entire documents. An embedding is just a vector representation of a text and is useful for finding how similar two texts are. + +You can find and use [thousands of Sentence Transformers](https://huggingface.co/models?library=sentence-transformers&sort=downloads) models from the Hub by directly using the library, playing with the widgets in the browser or using Inference Endpoints. + +## Task Variants + +### Passage Ranking + +Passage Ranking is the task of ranking documents based on their relevance to a given query. The task is evaluated on Mean Reciprocal Rank. These models take one query and multiple documents and return ranked documents according to the relevancy to the query. 📄 + +You can infer with Passage Ranking models using [Inference Endpoints](https://huggingface.co/inference-endpoints). The Passage Ranking model inputs are a query for which we look for relevancy in the documents and the documents we want to search. The model will return scores according to the relevancy of these documents for the query. + +```python +import json +import requests + +API_URL = "https://router.huggingface.co/hf-inference/models/sentence-transformers/msmarco-distilbert-base-tas-b" +headers = {"Authorization": f"Bearer {api_token}"} + +def query(payload): + response = requests.post(API_URL, headers=headers, json=payload) + return response.json() + +data = query( + { + "inputs": { + "source_sentence": "That is a happy person", + "sentences": [ + "That is a happy dog", + "That is a very happy person", + "Today is a sunny day" + ] + } + } +## [0.853, 0.981, 0.655] +``` + +### Semantic Textual Similarity + +Semantic Textual Similarity is the task of evaluating how similar two texts are in terms of meaning. These models take a source sentence and a list of sentences in which we will look for similarities and will return a list of similarity scores. The benchmark dataset is the [Semantic Textual Similarity Benchmark](http://ixa2.si.ehu.eus/stswiki/index.php/STSbenchmark). The task is evaluated on Pearson’s Rank Correlation. + +```python +import json +import requests + +API_URL = "https://router.huggingface.co/hf-inference/models/sentence-transformers/all-MiniLM-L6-v2" +headers = {"Authorization": f"Bearer {api_token}"} + +def query(payload): + response = requests.post(API_URL, headers=headers, json=payload) + return response.json() + +data = query( + { + "inputs": { + "source_sentence": "I'm very happy", + "sentences":["I'm filled with happiness", "I'm happy"] + } + }) + +## [0.605, 0.894] +``` + +You can also infer with the models in the Hub using Sentence Transformer models. + +```python +pip install -U sentence-transformers + +from sentence_transformers import SentenceTransformer, util +sentences = ["I'm happy", "I'm full of happiness"] + +model = SentenceTransformer('sentence-transformers/all-MiniLM-L6-v2') + +# Compute embedding for both lists +embedding_1 = model.encode(sentences[0], convert_to_tensor=True) +embedding_2 = model.encode(sentences[1], convert_to_tensor=True) + +util.pytorch_cos_sim(embedding_1, embedding_2) +## tensor([[0.6003]]) +``` + +## Useful Resources + +Would you like to learn more about Sentence Transformers and Sentence Similarity? Awesome! Here you can find some curated resources that you may find helpful! + +- [Sentence Transformers Documentation](https://www.sbert.net/) +- [Sentence Transformers in the Hub](https://huggingface.co/blog/sentence-transformers-in-the-hub) +- [Building a Playlist Generator with Sentence Transformers](https://huggingface.co/blog/playlist-generator) +- [Getting Started With Embeddings](https://huggingface.co/blog/getting-started-with-embeddings) diff --git a/node_modules/@huggingface/tasks/src/tasks/sentence-similarity/data.ts b/node_modules/@huggingface/tasks/src/tasks/sentence-similarity/data.ts new file mode 100644 index 0000000000000000000000000000000000000000..4cad5c918cac065bb6c73ff29e30ce1f1fec02c3 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/sentence-similarity/data.ts @@ -0,0 +1,105 @@ +import type { TaskDataCustom } from "../index.js"; + +const taskData: TaskDataCustom = { + datasets: [ + { + description: "Bing queries with relevant passages from various web sources.", + id: "microsoft/ms_marco", + }, + ], + demo: { + inputs: [ + { + label: "Source sentence", + content: "Machine learning is so easy.", + type: "text", + }, + { + label: "Sentences to compare to", + content: "Deep learning is so straightforward.", + type: "text", + }, + { + label: "", + content: "This is so difficult, like rocket science.", + type: "text", + }, + { + label: "", + content: "I can't believe how much I struggled with this.", + type: "text", + }, + ], + outputs: [ + { + type: "chart", + data: [ + { + label: "Deep learning is so straightforward.", + score: 0.623, + }, + { + label: "This is so difficult, like rocket science.", + score: 0.413, + }, + { + label: "I can't believe how much I struggled with this.", + score: 0.256, + }, + ], + }, + ], + }, + metrics: [ + { + description: + "Reciprocal Rank is a measure used to rank the relevancy of documents given a set of documents. Reciprocal Rank is the reciprocal of the rank of the document retrieved, meaning, if the rank is 3, the Reciprocal Rank is 0.33. If the rank is 1, the Reciprocal Rank is 1", + id: "Mean Reciprocal Rank", + }, + { + description: + "The similarity of the embeddings is evaluated mainly on cosine similarity. It is calculated as the cosine of the angle between two vectors. It is particularly useful when your texts are not the same length", + id: "Cosine Similarity", + }, + ], + models: [ + { + description: + "This model works well for sentences and paragraphs and can be used for clustering/grouping and semantic searches.", + id: "sentence-transformers/all-mpnet-base-v2", + }, + { + description: "A multilingual robust sentence similarity model.", + id: "BAAI/bge-m3", + }, + { + description: "A robust sentence similarity model.", + id: "HIT-TMG/KaLM-embedding-multilingual-mini-instruct-v1.5", + }, + ], + spaces: [ + { + description: "An application that leverages sentence similarity to answer questions from YouTube videos.", + id: "Gradio-Blocks/Ask_Questions_To_YouTube_Videos", + }, + { + description: + "An application that retrieves relevant PubMed abstracts for a given online article which can be used as further references.", + id: "Gradio-Blocks/pubmed-abstract-retriever", + }, + { + description: "An application that leverages sentence similarity to summarize text.", + id: "nickmuchi/article-text-summarizer", + }, + { + description: "A guide that explains how Sentence Transformers can be used for semantic search.", + id: "sentence-transformers/Sentence_Transformers_for_semantic_search", + }, + ], + summary: + "Sentence Similarity is the task of determining how similar two texts are. Sentence similarity models convert input texts into vectors (embeddings) that capture semantic information and calculate how close (similar) they are between them. This task is particularly useful for information retrieval and clustering/grouping.", + widgetModels: ["sentence-transformers/all-MiniLM-L6-v2"], + youtubeId: "VCZq5AkbNEU", +}; + +export default taskData; diff --git a/node_modules/@huggingface/tasks/src/tasks/sentence-similarity/inference.ts b/node_modules/@huggingface/tasks/src/tasks/sentence-similarity/inference.ts new file mode 100644 index 0000000000000000000000000000000000000000..c589124bdfa372c8974d177032485a3054d3cb94 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/sentence-similarity/inference.ts @@ -0,0 +1,31 @@ +/** + * Inference code generated from the JSON schema spec in ./spec + * + * Using src/scripts/inference-codegen + */ +export type SentenceSimilarityOutput = number[]; +/** + * Inputs for Sentence similarity inference + */ +export interface SentenceSimilarityInput { + inputs: SentenceSimilarityInputData; + /** + * Additional inference parameters for Sentence Similarity + */ + parameters?: { + [key: string]: unknown; + }; + [property: string]: unknown; +} +export interface SentenceSimilarityInputData { + /** + * A list of strings which will be compared against the source_sentence. + */ + sentences: string[]; + /** + * The string that you wish to compare the other strings with. This can be a phrase, + * sentence, or longer passage, depending on the model being used. + */ + source_sentence: string; + [property: string]: unknown; +} diff --git a/node_modules/@huggingface/tasks/src/tasks/sentence-similarity/spec/input.json b/node_modules/@huggingface/tasks/src/tasks/sentence-similarity/spec/input.json new file mode 100644 index 0000000000000000000000000000000000000000..d724af588d3f57d9535e8f7e81a5e24d34e750d3 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/sentence-similarity/spec/input.json @@ -0,0 +1,39 @@ +{ + "$id": "/inference/schemas/sentence-similarity/input.json", + "$schema": "http://json-schema.org/draft-06/schema#", + "description": "Inputs for Sentence similarity inference", + "title": "SentenceSimilarityInput", + "type": "object", + "properties": { + "inputs": { + "title": "SentenceSimilarityInputData", + "type": "object", + "properties": { + "source_sentence": { + "description": "The string that you wish to compare the other strings with. This can be a phrase, sentence, or longer passage, depending on the model being used.", + "type": "string" + }, + "sentences": { + "type": "array", + "description": "A list of strings which will be compared against the source_sentence.", + "items": { + "type": "string" + } + } + }, + "required": ["source_sentence", "sentences"] + }, + "parameters": { + "description": "Additional inference parameters for Sentence Similarity", + "$ref": "#/$defs/SentenceSimilarityParameters" + } + }, + "$defs": { + "SentenceSimilarityParameters": { + "title": "SentenceSimilarityParameters", + "type": "object", + "properties": {} + } + }, + "required": ["inputs"] +} diff --git a/node_modules/@huggingface/tasks/src/tasks/sentence-similarity/spec/output.json b/node_modules/@huggingface/tasks/src/tasks/sentence-similarity/spec/output.json new file mode 100644 index 0000000000000000000000000000000000000000..ca13d98bd5f55bd581e99c8cc4d970b9b7735512 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/sentence-similarity/spec/output.json @@ -0,0 +1,12 @@ +{ + "$id": "/inference/schemas/sentence-similarity/output.json", + "$schema": "http://json-schema.org/draft-06/schema#", + "title": "SentenceSimilarityOutput", + "description": "Outputs of inference for the Sentence Similarity task", + "type": "array", + "items": { + "description": "The associated similarity score for each of the given sentences", + "type": "number", + "title": "SentenceSimilarityScore" + } +} diff --git a/node_modules/@huggingface/tasks/src/tasks/summarization/about.md b/node_modules/@huggingface/tasks/src/tasks/summarization/about.md new file mode 100644 index 0000000000000000000000000000000000000000..44c8d2a4a0e12aaf91562977f447edf214d894c6 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/summarization/about.md @@ -0,0 +1,58 @@ +## Use Cases + +### Research Paper Summarization 🧐 + +Research papers can be summarized to allow researchers to spend less time selecting which articles to read. There are several approaches you can take for a task like this: + +1. Use an existing extractive summarization model on the Hub to do inference. +2. Pick an existing language model trained for academic papers. This model can then be trained in a process called fine-tuning so it can solve the summarization task. +3. Use a sequence-to-sequence model like [T5](https://huggingface.co/docs/transformers/model_doc/t5) for abstractive text summarization. + +## Inference + +You can use the 🤗 Transformers library `summarization` pipeline to infer with existing Summarization models. If no model name is provided the pipeline will be initialized with [sshleifer/distilbart-cnn-12-6](https://huggingface.co/sshleifer/distilbart-cnn-12-6). + +```python +from transformers import pipeline + +classifier = pipeline("summarization") +classifier("Paris is the capital and most populous city of France, with an estimated population of 2,175,601 residents as of 2018, in an area of more than 105 square kilometres (41 square miles). The City of Paris is the centre and seat of government of the region and province of Île-de-France, or Paris Region, which has an estimated population of 12,174,880, or about 18 percent of the population of France as of 2017.") +## [{ "summary_text": " Paris is the capital and most populous city of France..." }] +``` + +You can use [huggingface.js](https://github.com/huggingface/huggingface.js) to infer summarization models on Hugging Face Hub. + +```javascript +import { InferenceClient } from "@huggingface/inference"; + +const inference = new InferenceClient(HF_TOKEN); +const inputs = + "Paris is the capital and most populous city of France, with an estimated population of 2,175,601 residents as of 2018, in an area of more than 105 square kilometres (41 square miles). The City of Paris is the centre and seat of government of the region and province of Île-de-France, or Paris Region, which has an estimated population of 12,174,880, or about 18 percent of the population of France as of 2017."; + +await inference.summarization({ + model: "sshleifer/distilbart-cnn-12-6", + inputs, +}); +``` + +## Useful Resources + +Would you like to learn more about the topic? Awesome! Here you can find some curated resources that you may find helpful! + +- [Course Chapter on Summarization](https://huggingface.co/course/chapter7/5?fw=pt) +- [Distributed Training: Train BART/T5 for Summarization using 🤗 Transformers and Amazon SageMaker](https://huggingface.co/blog/sagemaker-distributed-training-seq2seq) + +### Notebooks + +- [PyTorch](https://github.com/huggingface/notebooks/blob/master/examples/summarization.ipynb) +- [TensorFlow](https://github.com/huggingface/notebooks/blob/master/examples/summarization-tf.ipynb) + +### Scripts for training + +- [PyTorch](https://github.com/huggingface/transformers/tree/main/examples/pytorch/summarization) +- [TensorFlow](https://github.com/huggingface/transformers/tree/main/examples/tensorflow/summarization) +- [Flax](https://github.com/huggingface/transformers/tree/main/examples/flax/summarization) + +### Documentation + +- [Summarization task guide](https://huggingface.co/docs/transformers/tasks/summarization) diff --git a/node_modules/@huggingface/tasks/src/tasks/summarization/data.ts b/node_modules/@huggingface/tasks/src/tasks/summarization/data.ts new file mode 100644 index 0000000000000000000000000000000000000000..744503ece07e487fb1463bb6f764cb64a6633a05 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/summarization/data.ts @@ -0,0 +1,76 @@ +import type { TaskDataCustom } from "../index.js"; + +const taskData: TaskDataCustom = { + canonicalId: "text-generation", + datasets: [ + { + description: + "News articles in five different languages along with their summaries. Widely used for benchmarking multilingual summarization models.", + id: "mlsum", + }, + { + description: "English conversations and their summaries. Useful for benchmarking conversational agents.", + id: "samsum", + }, + ], + demo: { + inputs: [ + { + label: "Input", + content: + "The tower is 324 metres (1,063 ft) tall, about the same height as an 81-storey building, and the tallest structure in Paris. Its base is square, measuring 125 metres (410 ft) on each side. It was the first structure to reach a height of 300 metres. Excluding transmitters, the Eiffel Tower is the second tallest free-standing structure in France after the Millau Viaduct.", + type: "text", + }, + ], + outputs: [ + { + label: "Output", + content: + "The tower is 324 metres (1,063 ft) tall, about the same height as an 81-storey building. It was the first structure to reach a height of 300 metres.", + type: "text", + }, + ], + }, + metrics: [ + { + description: + "The generated sequence is compared against its summary, and the overlap of tokens are counted. ROUGE-N refers to overlap of N subsequent tokens, ROUGE-1 refers to overlap of single tokens and ROUGE-2 is the overlap of two subsequent tokens.", + id: "rouge", + }, + ], + models: [ + { + description: + "A strong summarization model trained on English news articles. Excels at generating factual summaries.", + id: "facebook/bart-large-cnn", + }, + { + description: "A summarization model trained on medical articles.", + id: "Falconsai/medical_summarization", + }, + ], + spaces: [ + { + description: "An application that can summarize long paragraphs.", + id: "pszemraj/summarize-long-text", + }, + { + description: "A much needed summarization application for terms and conditions.", + id: "ml6team/distilbart-tos-summarizer-tosdr", + }, + { + description: "An application that summarizes long documents.", + id: "pszemraj/document-summarization", + }, + { + description: "An application that can detect errors in abstractive summarization.", + id: "ml6team/post-processing-summarization", + }, + ], + summary: + "Summarization is the task of producing a shorter version of a document while preserving its important information. Some models can extract text from the original input, while other models can generate entirely new text.", + widgetModels: ["facebook/bart-large-cnn"], + youtubeId: "yHnr5Dk2zCI", +}; + +export default taskData; diff --git a/node_modules/@huggingface/tasks/src/tasks/summarization/inference.ts b/node_modules/@huggingface/tasks/src/tasks/summarization/inference.ts new file mode 100644 index 0000000000000000000000000000000000000000..ed28c5632f713eda38f6c4b669c5843c5845e073 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/summarization/inference.ts @@ -0,0 +1,53 @@ +/** + * Inference code generated from the JSON schema spec in ./spec + * + * Using src/scripts/inference-codegen + */ +/** + * Inputs for Summarization inference + */ +export interface SummarizationInput { + /** + * The input text to summarize. + */ + inputs: string; + /** + * Additional inference parameters for summarization. + */ + parameters?: SummarizationParameters; + [property: string]: unknown; +} +/** + * Additional inference parameters for summarization. + */ +export interface SummarizationParameters { + /** + * Whether to clean up the potential extra spaces in the text output. + */ + clean_up_tokenization_spaces?: boolean; + /** + * Additional parametrization of the text generation algorithm. + */ + generate_parameters?: { + [key: string]: unknown; + }; + /** + * The truncation strategy to use. + */ + truncation?: SummarizationTruncationStrategy; + [property: string]: unknown; +} +/** + * The truncation strategy to use. + */ +export type SummarizationTruncationStrategy = "do_not_truncate" | "longest_first" | "only_first" | "only_second"; +/** + * Outputs of inference for the Summarization task + */ +export interface SummarizationOutput { + /** + * The summarized text. + */ + summary_text: string; + [property: string]: unknown; +} diff --git a/node_modules/@huggingface/tasks/src/tasks/summarization/spec/input.json b/node_modules/@huggingface/tasks/src/tasks/summarization/spec/input.json new file mode 100644 index 0000000000000000000000000000000000000000..c2d7aebaf578bab13eff197aea6d51dff2bb5d4a --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/summarization/spec/input.json @@ -0,0 +1,41 @@ +{ + "$id": "/inference/schemas/summarization/input.json", + "$schema": "http://json-schema.org/draft-06/schema#", + "description": "Inputs for Summarization inference", + "title": "SummarizationInput", + "type": "object", + "properties": { + "inputs": { + "description": "The input text to summarize.", + "type": "string" + }, + "parameters": { + "description": "Additional inference parameters for summarization.", + "$ref": "#/$defs/SummarizationParameters" + } + }, + "$defs": { + "SummarizationParameters": { + "title": "SummarizationParameters", + "type": "object", + "properties": { + "clean_up_tokenization_spaces": { + "type": "boolean", + "description": "Whether to clean up the potential extra spaces in the text output." + }, + "truncation": { + "title": "SummarizationTruncationStrategy", + "type": "string", + "description": "The truncation strategy to use.", + "enum": ["do_not_truncate", "longest_first", "only_first", "only_second"] + }, + "generate_parameters": { + "title": "generateParameters", + "type": "object", + "description": "Additional parametrization of the text generation algorithm." + } + } + } + }, + "required": ["inputs"] +} diff --git a/node_modules/@huggingface/tasks/src/tasks/summarization/spec/output.json b/node_modules/@huggingface/tasks/src/tasks/summarization/spec/output.json new file mode 100644 index 0000000000000000000000000000000000000000..dfa307b642213451b0aa7e8b88d1bfdaf6f77598 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/summarization/spec/output.json @@ -0,0 +1,14 @@ +{ + "$id": "/inference/schemas/summarization/output.json", + "$schema": "http://json-schema.org/draft-06/schema#", + "description": "Outputs of inference for the Summarization task", + "title": "SummarizationOutput", + "type": "object", + "properties": { + "summary_text": { + "type": "string", + "description": "The summarized text." + } + }, + "required": ["summary_text"] +} diff --git a/node_modules/@huggingface/tasks/src/tasks/table-question-answering/about.md b/node_modules/@huggingface/tasks/src/tasks/table-question-answering/about.md new file mode 100644 index 0000000000000000000000000000000000000000..62cdb44ad25d94249ea6c4953a054b60c4021057 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/table-question-answering/about.md @@ -0,0 +1,43 @@ +## Use Cases + +### SQL execution + +You can use the Table Question Answering models to simulate SQL execution by inputting a table. + +### Table Question Answering + +Table Question Answering models are capable of answering questions based on a table. + +## Task Variants + +This place can be filled with variants of this task if there's any. + +## Inference + +You can infer with TableQA models using the 🤗 Transformers library. + +```python +from transformers import pipeline +import pandas as pd + +# prepare table + question +data = {"Actors": ["Brad Pitt", "Leonardo Di Caprio", "George Clooney"], "Number of movies": ["87", "53", "69"]} +table = pd.DataFrame.from_dict(data) +question = "how many movies does Leonardo Di Caprio have?" + +# pipeline model +# Note: you must to install torch-scatter first. +tqa = pipeline(task="table-question-answering", model="google/tapas-large-finetuned-wtq") + +# result + +print(tqa(table=table, query=question)['cells'][0]) +#53 + +``` + +## Useful Resources + +In this area, you can insert useful resources about how to train or use a model for this task. + +This task page is complete thanks to the efforts of [Hao Kim Tieu](https://huggingface.co/haotieu). 🦸 diff --git a/node_modules/@huggingface/tasks/src/tasks/table-question-answering/data.ts b/node_modules/@huggingface/tasks/src/tasks/table-question-answering/data.ts new file mode 100644 index 0000000000000000000000000000000000000000..b5f161a4ca80310e591d20d96ea53d33ffe49d10 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/table-question-answering/data.ts @@ -0,0 +1,59 @@ +import type { TaskDataCustom } from "../index.js"; + +const taskData: TaskDataCustom = { + datasets: [ + { + description: + "The WikiTableQuestions dataset is a large-scale dataset for the task of question answering on semi-structured tables.", + id: "wikitablequestions", + }, + { + description: + "WikiSQL is a dataset of 80654 hand-annotated examples of questions and SQL queries distributed across 24241 tables from Wikipedia.", + id: "wikisql", + }, + ], + demo: { + inputs: [ + { + table: [ + ["Rank", "Name", "No.of reigns", "Combined days"], + ["1", "lou Thesz", "3", "3749"], + ["2", "Ric Flair", "8", "3103"], + ["3", "Harley Race", "7", "1799"], + ], + type: "tabular", + }, + + { label: "Question", content: "What is the number of reigns for Harley Race?", type: "text" }, + ], + outputs: [{ label: "Result", content: "7", type: "text" }], + }, + metrics: [ + { + description: "Checks whether the predicted answer(s) is the same as the ground-truth answer(s).", + id: "Denotation Accuracy", + }, + ], + models: [ + { + description: + "A table question answering model that is capable of neural SQL execution, i.e., employ TAPEX to execute a SQL query on a given table.", + id: "microsoft/tapex-base", + }, + { + description: "A robust table question answering model.", + id: "google/tapas-base-finetuned-wtq", + }, + ], + spaces: [ + { + description: "An application that answers questions based on table CSV files.", + id: "katanaml/table-query", + }, + ], + summary: "Table Question Answering (Table QA) is the answering a question about an information on a given table.", + widgetModels: ["google/tapas-base-finetuned-wtq"], +}; + +export default taskData; diff --git a/node_modules/@huggingface/tasks/src/tasks/table-question-answering/inference.ts b/node_modules/@huggingface/tasks/src/tasks/table-question-answering/inference.ts new file mode 100644 index 0000000000000000000000000000000000000000..18339e033180ad689aae33ccc671cc14c157f0b8 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/table-question-answering/inference.ts @@ -0,0 +1,83 @@ +/** + * Inference code generated from the JSON schema spec in ./spec + * + * Using src/scripts/inference-codegen + */ +/** + * Inputs for Table Question Answering inference + */ +export interface TableQuestionAnsweringInput { + /** + * One (table, question) pair to answer + */ + inputs: TableQuestionAnsweringInputData; + /** + * Additional inference parameters for Table Question Answering + */ + parameters?: TableQuestionAnsweringParameters; + [property: string]: unknown; +} +/** + * One (table, question) pair to answer + */ +export interface TableQuestionAnsweringInputData { + /** + * The question to be answered about the table + */ + question: string; + /** + * The table to serve as context for the questions + */ + table: { + [key: string]: string[]; + }; + [property: string]: unknown; +} +/** + * Additional inference parameters for Table Question Answering + */ +export interface TableQuestionAnsweringParameters { + /** + * Activates and controls padding. + */ + padding?: Padding; + /** + * Whether to do inference sequentially or as a batch. Batching is faster, but models like + * SQA require the inference to be done sequentially to extract relations within sequences, + * given their conversational nature. + */ + sequential?: boolean; + /** + * Activates and controls truncation. + */ + truncation?: boolean; + [property: string]: unknown; +} +/** + * Activates and controls padding. + */ +export type Padding = "do_not_pad" | "longest" | "max_length"; +export type TableQuestionAnsweringOutput = TableQuestionAnsweringOutputElement[]; +/** + * Outputs of inference for the Table Question Answering task + */ +export interface TableQuestionAnsweringOutputElement { + /** + * If the model has an aggregator, this returns the aggregator. + */ + aggregator?: string; + /** + * The answer of the question given the table. If there is an aggregator, the answer will be + * preceded by `AGGREGATOR >`. + */ + answer: string; + /** + * List of strings made up of the answer cell values. + */ + cells: string[]; + /** + * Coordinates of the cells of the answers. + */ + coordinates: Array; + [property: string]: unknown; +} diff --git a/node_modules/@huggingface/tasks/src/tasks/table-question-answering/spec/input.json b/node_modules/@huggingface/tasks/src/tasks/table-question-answering/spec/input.json new file mode 100644 index 0000000000000000000000000000000000000000..67cc18eae986d8d392c4b5842cf9ecd7aec4309c --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/table-question-answering/spec/input.json @@ -0,0 +1,60 @@ +{ + "$id": "/inference/schemas/table-question-answering/input.json", + "$schema": "http://json-schema.org/draft-06/schema#", + "description": "Inputs for Table Question Answering inference", + "title": "TableQuestionAnsweringInput", + "type": "object", + "properties": { + "inputs": { + "description": "One (table, question) pair to answer", + "title": "TableQuestionAnsweringInputData", + "type": "object", + "properties": { + "table": { + "description": "The table to serve as context for the questions", + "type": "object", + "additionalProperties": { + "type": "array", + "items": { + "type": "string" + } + } + }, + "question": { + "description": "The question to be answered about the table", + "type": "string" + } + }, + "required": ["table", "question"] + }, + "parameters": { + "description": "Additional inference parameters for Table Question Answering", + "$ref": "#/$defs/TableQuestionAnsweringParameters" + } + }, + "$defs": { + "TableQuestionAnsweringParameters": { + "title": "TableQuestionAnsweringParameters", + "type": "object", + "properties": { + "padding": { + "type": "string", + "default": "do_not_pad", + "description": "Activates and controls padding.", + "enum": ["do_not_pad", "longest", "max_length"] + }, + "sequential": { + "type": "boolean", + "default": "false", + "description": "Whether to do inference sequentially or as a batch. Batching is faster, but models like SQA require the inference to be done sequentially to extract relations within sequences, given their conversational nature." + }, + "truncation": { + "type": "boolean", + "default": "false", + "description": "Activates and controls truncation." + } + } + } + }, + "required": ["inputs"] +} diff --git a/node_modules/@huggingface/tasks/src/tasks/table-question-answering/spec/output.json b/node_modules/@huggingface/tasks/src/tasks/table-question-answering/spec/output.json new file mode 100644 index 0000000000000000000000000000000000000000..9b43026ea12299dc83110c99d3983841a8d30c6e --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/table-question-answering/spec/output.json @@ -0,0 +1,40 @@ +{ + "$id": "/inference/schemas/table-question-answering/output.json", + "$schema": "http://json-schema.org/draft-06/schema#", + "description": "Outputs of inference for the Table Question Answering task", + "title": "TableQuestionAnsweringOutput", + "type": "array", + "items": { + "type": "object", + "properties": { + "answer": { + "type": "string", + "description": "The answer of the question given the table. If there is an aggregator, the answer will be preceded by `AGGREGATOR >`." + }, + "coordinates": { + "type": "array", + "description": "Coordinates of the cells of the answers.", + "items": { + "type": "array", + "items": { + "type": "integer" + }, + "minLength": 2, + "maxLength": 2 + } + }, + "cells": { + "type": "array", + "description": "List of strings made up of the answer cell values.", + "items": { + "type": "string" + } + }, + "aggregator": { + "type": "string", + "description": "If the model has an aggregator, this returns the aggregator." + } + }, + "required": ["answer", "cells", "coordinates"] + } +} diff --git a/node_modules/@huggingface/tasks/src/tasks/tabular-classification/about.md b/node_modules/@huggingface/tasks/src/tasks/tabular-classification/about.md new file mode 100644 index 0000000000000000000000000000000000000000..d46a48976c894b8a5d99dda14a893261c49e6d41 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/tabular-classification/about.md @@ -0,0 +1,65 @@ +## About the Task + +Tabular classification is the task of assigning a label or class given a limited number of attributes. For example, the input can be data related to a customer (balance of the customer, the time being a customer, or more) and the output can be whether the customer will churn from the service or not. +There are three types of categorical variables: + +- Binary variables: Variables that can take two values, like yes or no, open or closed. The task of predicting binary variables is called binary classification. +- Ordinal variables: Variables with a ranking relationship, e.g., good, insignificant, and bad product reviews. The task of predicting ordinal variables is called ordinal classification. +- Nominal variables: Variables with no ranking relationship among them, e.g., predicting an animal from their weight and height, where categories are cat, dog, or bird. The task of predicting nominal variables is called multinomial classification. + +## Use Cases + +### Fraud Detection +Tabular classification models can be used in detecting fraudulent credit card transactions, where the features could be the amount of the transaction and the account balance, and the target to predict could be whether the transaction is fraudulent or not. This is an example of binary classification. + +### Churn Prediction +Tabular classification models can be used in predicting customer churn in telecommunication. An example dataset for the task is hosted [here](https://huggingface.co/datasets/scikit-learn/churn-prediction). + +# Model Hosting and Inference + +You can use [skops](https://skops.readthedocs.io/) for model hosting and inference on the Hugging Face Hub. This library is built to improve production workflows of various libraries that are used to train tabular models, including [sklearn](https://scikit-learn.org/stable/) and [xgboost](https://xgboost.readthedocs.io/en/stable/). Using `skops` you can: + +- Easily use Inference Endpoints +- Build neat UIs with one line of code, +- Programmatically create model cards, +- Securely serialize your scikit-learn model. (See limitations of using pickle [here](https://huggingface.co/docs/hub/security-pickle).) + +You can push your model as follows: + +```python +from skops import hub_utils +# initialize a repository with a trained model +local_repo = "/path_to_new_repo" +hub_utils.init(model, dst=local_repo) +# push to Hub! +hub_utils.push("username/my-awesome-model", source=local_repo) +``` + +Once the model is pushed, you can infer easily. + +```python +import skops.hub_utils as hub_utils +import pandas as pd +data = pd.DataFrame(your_data) +# Load the model from the Hub +res = hub_utils.get_model_output("username/my-awesome-model", data) +``` + +You can launch a UI for your model with only one line of code! + +```python +import gradio as gr +gr.Interface.load("huggingface/username/my-awesome-model").launch() +``` + +## Useful Resources + +- Check out the [scikit-learn organization](https://huggingface.co/scikit-learn) to learn more about different algorithms used for this task. +- [Skops documentation](https://skops.readthedocs.io/en/latest/) +- [Skops announcement blog](https://huggingface.co/blog/skops) +- [Notebook: Persisting your scikit-learn model using skops](https://www.kaggle.com/code/unofficialmerve/persisting-your-scikit-learn-model-using-skops) +- Check out [interactive sklearn examples](https://huggingface.co/sklearn-docs) built with ❤️ using Gradio. + +### Training your own model in just a few seconds + +We have built a [baseline trainer](https://huggingface.co/spaces/scikit-learn/baseline-trainer) application to which you can drag and drop your dataset. It will train a baseline and push it to your Hugging Face Hub profile with a model card containing information about the model. diff --git a/node_modules/@huggingface/tasks/src/tasks/tabular-classification/data.ts b/node_modules/@huggingface/tasks/src/tasks/tabular-classification/data.ts new file mode 100644 index 0000000000000000000000000000000000000000..80dbe57d20a127d16e3ddecaeae5afe5e888cde1 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/tabular-classification/data.ts @@ -0,0 +1,68 @@ +import type { TaskDataCustom } from "../index.js"; + +const taskData: TaskDataCustom = { + datasets: [ + { + description: "A comprehensive curation of datasets covering all benchmarks.", + id: "inria-soda/tabular-benchmark", + }, + ], + demo: { + inputs: [ + { + table: [ + ["Glucose", "Blood Pressure ", "Skin Thickness", "Insulin", "BMI"], + ["148", "72", "35", "0", "33.6"], + ["150", "50", "30", "0", "35.1"], + ["141", "60", "29", "1", "39.2"], + ], + type: "tabular", + }, + ], + outputs: [ + { + table: [["Diabetes"], ["1"], ["1"], ["0"]], + type: "tabular", + }, + ], + }, + metrics: [ + { + description: "", + id: "accuracy", + }, + { + description: "", + id: "recall", + }, + { + description: "", + id: "precision", + }, + { + description: "", + id: "f1", + }, + ], + models: [ + { + description: "Breast cancer prediction model based on decision trees.", + id: "scikit-learn/cancer-prediction-trees", + }, + ], + spaces: [ + { + description: "An application that can predict defective products on a production line.", + id: "scikit-learn/tabular-playground", + }, + { + description: "An application that compares various tabular classification techniques on different datasets.", + id: "scikit-learn/classification", + }, + ], + summary: "Tabular classification is the task of classifying a target category (a group) based on set of attributes.", + widgetModels: ["scikit-learn/tabular-playground"], + youtubeId: "", +}; + +export default taskData; diff --git a/node_modules/@huggingface/tasks/src/tasks/tabular-regression/about.md b/node_modules/@huggingface/tasks/src/tasks/tabular-regression/about.md new file mode 100644 index 0000000000000000000000000000000000000000..4a6d9d302cc484c9b8b642d8bdba4e4f626a2e13 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/tabular-regression/about.md @@ -0,0 +1,86 @@ +## About the Task + +Tabular regression is the task of predicting a numerical value given a set of attributes/features. _Tabular_ meaning that data is stored in a table (like an excel sheet), and each sample is contained in its own row. The features used to predict our target can be both numerical and categorical. However, including categorical features often requires additional preprocessing/feature engineering (a few models do accept categorical features directly, like [CatBoost](https://catboost.ai/)). An example of tabular regression would be predicting the weight of a fish given its' species and length. + +## Use Cases + +### Sales Prediction: a Use Case for Predicting a Continuous Target Variable + +Here the objective is to predict a continuous variable based on a set of input variable(s). For example, predicting `sales` of an ice cream shop based on `temperature` of weather and `duration of hours` shop was open. Here we can build a regression model with `temperature` and `duration of hours` as input variable and `sales` as target variable. + +### Missing Value Imputation for Other Tabular Tasks +In real-world applications, due to human error or other reasons, some of the input values can be missing or there might not be any recorded data. Considering the example above, say the shopkeeper's watch was broken and they forgot to calculate the `hours` for which the shop was open. This will lead to a missing value in their dataset. In this case, missing values could be replaced it with zero, or average hours for which the shop is kept open. Another approach we can try is to use `temperature` and `sales` variables to predict the `hours` variable here. + +## Model Training + +A simple regression model can be created using `sklearn` as follows: + +```python +#set the input features +X = data[["Feature 1", "Feature 2", "Feature 3"]] +#set the target variable +y = data["Target Variable"] +#initialize the model +model = LinearRegression() +#Fit the model +model.fit(X, y) +``` + +# Model Hosting and Inference + +You can use [skops](https://skops.readthedocs.io/) for model hosting and inference on the Hugging Face Hub. This library is built to improve production workflows of various libraries that are used to train tabular models, including [sklearn](https://scikit-learn.org/stable/) and [xgboost](https://xgboost.readthedocs.io/en/stable/). Using `skops` you can: + +- Easily use Inference Endpoints, +- Build neat UIs with one line of code, +- Programmatically create model cards, +- Securely serialize your models. (See limitations of using pickle [here](https://huggingface.co/docs/hub/security-pickle).) + +You can push your model as follows: + +```python +from skops import hub_utils +# initialize a repository with a trained model +local_repo = "/path_to_new_repo" +hub_utils.init(model, dst=local_repo) +# push to Hub! +hub_utils.push("username/my-awesome-model", source=local_repo) +``` + +Once the model is pushed, you can infer easily. + +```python +import skops.hub_utils as hub_utils +import pandas as pd +data = pd.DataFrame(your_data) +# Load the model from the Hub +res = hub_utils.get_model_output("username/my-awesome-model", data) +``` + +You can launch a UI for your model with only one line of code! + +```python +import gradio as gr +gr.Interface.load("huggingface/username/my-awesome-model").launch() +``` + +## Useful Resources + +- [Skops documentation](https://skops.readthedocs.io/en/stable/index.html) + +- Check out [interactive sklearn examples](https://huggingface.co/sklearn-docs) built with ❤️ using Gradio. +- [Notebook: Persisting your scikit-learn model using skops](https://www.kaggle.com/code/unofficialmerve/persisting-your-scikit-learn-model-using-skops) + +- For starting with tabular regression: + - Doing [Exploratory Data Analysis](https://neptune.ai/blog/exploratory-data-analysis-for-tabular-data) for tabular data. + - The data considered here consists of details of Olympic athletes and medal results from Athens 1896 to Rio 2016. + - Here you can learn more about how to explore and analyse the data and visualize them in order to get a better understanding of dataset. + - Building your [first ML model](https://www.kaggle.com/code/dansbecker/your-first-machine-learning-model). + +- Intermediate level tutorials on tabular regression: + - [A Short Chronology of Deep Learning for Tabular Data](https://sebastianraschka.com/blog/2022/deep-learning-for-tabular-data.html) by Sebastian Raschka. + +### Training your own model in just a few seconds + +We have built a [baseline trainer](https://huggingface.co/spaces/scikit-learn/baseline-trainer) application to which you can drag and drop your dataset. It will train a baseline and push it to your Hugging Face Hub profile with a model card containing information about the model. + +This page was made possible thanks to efforts of [Brenden Connors](https://huggingface.co/brendenc) and [Ayush Bihani](https://huggingface.co/hsuyab). diff --git a/node_modules/@huggingface/tasks/src/tasks/tabular-regression/data.ts b/node_modules/@huggingface/tasks/src/tasks/tabular-regression/data.ts new file mode 100644 index 0000000000000000000000000000000000000000..c4c0b6d018687d90a46654c90e8c3e5c9773816a --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/tabular-regression/data.ts @@ -0,0 +1,57 @@ +import type { TaskDataCustom } from "../index.js"; + +const taskData: TaskDataCustom = { + datasets: [ + { + description: "A comprehensive curation of datasets covering all benchmarks.", + id: "inria-soda/tabular-benchmark", + }, + ], + demo: { + inputs: [ + { + table: [ + ["Car Name", "Horsepower", "Weight"], + ["ford torino", "140", "3,449"], + ["amc hornet", "97", "2,774"], + ["toyota corolla", "65", "1,773"], + ], + type: "tabular", + }, + ], + outputs: [ + { + table: [["MPG (miles per gallon)"], ["17"], ["18"], ["31"]], + type: "tabular", + }, + ], + }, + metrics: [ + { + description: "", + id: "mse", + }, + { + description: + "Coefficient of determination (or R-squared) is a measure of how well the model fits the data. Higher R-squared is considered a better fit.", + id: "r-squared", + }, + ], + models: [ + { + description: "Fish weight prediction based on length measurements and species.", + id: "scikit-learn/Fish-Weight", + }, + ], + spaces: [ + { + description: "An application that can predict weight of a fish based on set of attributes.", + id: "scikit-learn/fish-weight-prediction", + }, + ], + summary: "Tabular regression is the task of predicting a numerical value given a set of attributes.", + widgetModels: ["scikit-learn/Fish-Weight"], + youtubeId: "", +}; + +export default taskData; diff --git a/node_modules/@huggingface/tasks/src/tasks/text-classification/about.md b/node_modules/@huggingface/tasks/src/tasks/text-classification/about.md new file mode 100644 index 0000000000000000000000000000000000000000..dc0bfdf4709bb7a6b06529b2a6e18a1099738d14 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/text-classification/about.md @@ -0,0 +1,173 @@ +## Use Cases + +### Sentiment Analysis on Customer Reviews + +You can track the sentiments of your customers from the product reviews using sentiment analysis models. This can help understand churn and retention by grouping reviews by sentiment, to later analyze the text and make strategic decisions based on this knowledge. + +## Task Variants + +### Natural Language Inference (NLI) + +In NLI the model determines the relationship between two given texts. Concretely, the model takes a premise and a hypothesis and returns a class that can either be: + +- **entailment**, which means the hypothesis is true. +- **contraction**, which means the hypothesis is false. +- **neutral**, which means there's no relation between the hypothesis and the premise. + +The benchmark dataset for this task is GLUE (General Language Understanding Evaluation). NLI models have different variants, such as Multi-Genre NLI, Question NLI and Winograd NLI. + +### Multi-Genre NLI (MNLI) + +MNLI is used for general NLI. Here are som examples: + +``` +Example 1: + Premise: A man inspects the uniform of a figure in some East Asian country. + Hypothesis: The man is sleeping. + Label: Contradiction + +Example 2: + Premise: Soccer game with multiple males playing. + Hypothesis: Some men are playing a sport. + Label: Entailment +``` + +#### Inference + +You can use the 🤗 Transformers library `text-classification` pipeline to infer with NLI models. + +```python +from transformers import pipeline + +classifier = pipeline("text-classification", model = "roberta-large-mnli") +classifier("A soccer game with multiple males playing. Some men are playing a sport.") +## [{'label': 'ENTAILMENT', 'score': 0.98}] +``` + +### Question Natural Language Inference (QNLI) + +QNLI is the task of determining if the answer to a certain question can be found in a given document. If the answer can be found the label is “entailment”. If the answer cannot be found the label is “not entailment". + +``` +Question: What percentage of marine life died during the extinction? +Sentence: It is also known as the “Great Dying” because it is considered the largest mass extinction in the Earth’s history. +Label: not entailment + +Question: Who was the London Weekend Television’s Managing Director? +Sentence: The managing director of London Weekend Television (LWT), Greg Dyke, met with the representatives of the "big five" football clubs in England in 1990. +Label: entailment +``` + +#### Inference + +You can use the 🤗 Transformers library `text-classification` pipeline to infer with QNLI models. The model returns the label and the confidence. + +```python +from transformers import pipeline + +classifier = pipeline("text-classification", model = "cross-encoder/qnli-electra-base") +classifier("Where is the capital of France?, Paris is the capital of France.") +## [{'label': 'entailment', 'score': 0.997}] +``` + +### Sentiment Analysis + +In Sentiment Analysis, the classes can be polarities like positive, negative, neutral, or sentiments such as happiness or anger. + +#### Inference + +You can use the 🤗 Transformers library with the `sentiment-analysis` pipeline to infer with Sentiment Analysis models. The model returns the label with the score. + +```python +from transformers import pipeline + +classifier = pipeline("sentiment-analysis") +classifier("I loved Star Wars so much!") +## [{'label': 'POSITIVE', 'score': 0.99} +``` + +### Quora Question Pairs + +Quora Question Pairs models assess whether two provided questions are paraphrases of each other. The model takes two questions and returns a binary value, with 0 being mapped to “not paraphrase” and 1 to “paraphrase". The benchmark dataset is [Quora Question Pairs](https://huggingface.co/datasets/glue/viewer/qqp/test) inside the [GLUE benchmark](https://huggingface.co/datasets/glue). The dataset consists of question pairs and their labels. + +``` +Question1: “How can I increase the speed of my internet connection while using a VPN?” +Question2: How can Internet speed be increased by hacking through DNS? +Label: Not paraphrase + +Question1: “What can make Physics easy to learn?” +Question2: “How can you make physics easy to learn?” +Label: Paraphrase +``` + +#### Inference + +You can use the 🤗 Transformers library `text-classification` pipeline to infer with QQPI models. + +```python +from transformers import pipeline + +classifier = pipeline("text-classification", model = "textattack/bert-base-uncased-QQP") +classifier("Which city is the capital of France?, Where is the capital of France?") +## [{'label': 'paraphrase', 'score': 0.998}] +``` + +You can use [huggingface.js](https://github.com/huggingface/huggingface.js) to infer text classification models on Hugging Face Hub. + +```javascript +import { InferenceClient } from "@huggingface/inference"; + +const inference = new InferenceClient(HF_TOKEN); +await inference.conversational({ + model: "distilbert-base-uncased-finetuned-sst-2-english", + inputs: "I love this movie!", +}); +``` + +### Grammatical Correctness + +Linguistic Acceptability is the task of assessing the grammatical acceptability of a sentence. The classes in this task are “acceptable” and “unacceptable”. The benchmark dataset used for this task is [Corpus of Linguistic Acceptability (CoLA)](https://huggingface.co/datasets/glue/viewer/cola/test). The dataset consists of texts and their labels. + +``` +Example: Books were sent to each other by the students. +Label: Unacceptable + +Example: She voted for herself. +Label: Acceptable. +``` + +#### Inference + +```python +from transformers import pipeline + +classifier = pipeline("text-classification", model = "textattack/distilbert-base-uncased-CoLA") +classifier("I will walk to home when I went through the bus.") +## [{'label': 'unacceptable', 'score': 0.95}] +``` + +## Useful Resources + +Would you like to learn more about the topic? Awesome! Here you can find some curated resources that you may find helpful! + +- [SetFitABSA: Few-Shot Aspect Based Sentiment Analysis using SetFit](https://huggingface.co/blog/setfit-absa) +- [Course Chapter on Fine-tuning a Text Classification Model](https://huggingface.co/course/chapter3/1?fw=pt) +- [Getting Started with Sentiment Analysis using Python](https://huggingface.co/blog/sentiment-analysis-python) +- [Sentiment Analysis on Encrypted Data with Homomorphic Encryption](https://huggingface.co/blog/sentiment-analysis-fhe) +- [Leveraging Hugging Face for complex text classification use cases](https://huggingface.co/blog/classification-use-cases) + +### Notebooks + +- [PyTorch](https://github.com/huggingface/notebooks/blob/master/examples/text_classification.ipynb) +- [TensorFlow](https://github.com/huggingface/notebooks/blob/master/examples/text_classification-tf.ipynb) +- [Flax](https://github.com/huggingface/notebooks/blob/master/examples/text_classification_flax.ipynb) + +### Scripts for training + +- [PyTorch](https://github.com/huggingface/transformers/tree/main/examples/pytorch/text-classification) +- [TensorFlow](https://github.com/huggingface/transformers/tree/main/examples/tensorflow/text-classification) +- [Flax](https://github.com/huggingface/transformers/tree/main/examples/flax/text-classification) + +### Documentation + +- [Text classification task guide](https://huggingface.co/docs/transformers/tasks/sequence_classification) diff --git a/node_modules/@huggingface/tasks/src/tasks/text-classification/data.ts b/node_modules/@huggingface/tasks/src/tasks/text-classification/data.ts new file mode 100644 index 0000000000000000000000000000000000000000..5ba1506e9bc6379d2226a64f5cdd24e2c629d881 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/text-classification/data.ts @@ -0,0 +1,103 @@ +import type { TaskDataCustom } from "../index.js"; + +const taskData: TaskDataCustom = { + datasets: [ + { + description: "A widely used dataset used to benchmark multiple variants of text classification.", + id: "nyu-mll/glue", + }, + { + description: "A text classification dataset used to benchmark natural language inference models", + id: "stanfordnlp/snli", + }, + ], + demo: { + inputs: [ + { + label: "Input", + content: "I love Hugging Face!", + type: "text", + }, + ], + outputs: [ + { + type: "chart", + data: [ + { + label: "POSITIVE", + score: 0.9, + }, + { + label: "NEUTRAL", + score: 0.1, + }, + { + label: "NEGATIVE", + score: 0.0, + }, + ], + }, + ], + }, + metrics: [ + { + description: "", + id: "accuracy", + }, + { + description: "", + id: "recall", + }, + { + description: "", + id: "precision", + }, + { + description: + "The F1 metric is the harmonic mean of the precision and recall. It can be calculated as: F1 = 2 * (precision * recall) / (precision + recall)", + id: "f1", + }, + ], + models: [ + { + description: "A robust model trained for sentiment analysis.", + id: "distilbert/distilbert-base-uncased-finetuned-sst-2-english", + }, + { + description: "A sentiment analysis model specialized in financial sentiment.", + id: "ProsusAI/finbert", + }, + { + description: "A sentiment analysis model specialized in analyzing tweets.", + id: "cardiffnlp/twitter-roberta-base-sentiment-latest", + }, + { + description: "A model that can classify languages.", + id: "papluca/xlm-roberta-base-language-detection", + }, + { + description: "A model that can classify text generation attacks.", + id: "meta-llama/Prompt-Guard-86M", + }, + ], + spaces: [ + { + description: "An application that can classify financial sentiment.", + id: "IoannisTr/Tech_Stocks_Trading_Assistant", + }, + { + description: "A dashboard that contains various text classification tasks.", + id: "miesnerjacob/Multi-task-NLP", + }, + { + description: "An application that analyzes user reviews in healthcare.", + id: "spacy/healthsea-demo", + }, + ], + summary: + "Text Classification is the task of assigning a label or class to a given text. Some use cases are sentiment analysis, natural language inference, and assessing grammatical correctness.", + widgetModels: ["distilbert/distilbert-base-uncased-finetuned-sst-2-english"], + youtubeId: "leNG9fN9FQU", +}; + +export default taskData; diff --git a/node_modules/@huggingface/tasks/src/tasks/text-classification/inference.ts b/node_modules/@huggingface/tasks/src/tasks/text-classification/inference.ts new file mode 100644 index 0000000000000000000000000000000000000000..84d6a80fe35f1257534d89aff2ed66101cdfc50a --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/text-classification/inference.ts @@ -0,0 +1,52 @@ +/** + * Inference code generated from the JSON schema spec in ./spec + * + * Using src/scripts/inference-codegen + */ +/** + * Inputs for Text Classification inference + */ +export interface TextClassificationInput { + /** + * The text to classify + */ + inputs: string; + /** + * Additional inference parameters for Text Classification + */ + parameters?: TextClassificationParameters; + [property: string]: unknown; +} +/** + * Additional inference parameters for Text Classification + */ +export interface TextClassificationParameters { + /** + * The function to apply to the model outputs in order to retrieve the scores. + */ + function_to_apply?: ClassificationOutputTransform; + /** + * When specified, limits the output to the top K most probable classes. + */ + top_k?: number; + [property: string]: unknown; +} +/** + * The function to apply to the model outputs in order to retrieve the scores. + */ +export type ClassificationOutputTransform = "sigmoid" | "softmax" | "none"; +export type TextClassificationOutput = TextClassificationOutputElement[]; +/** + * Outputs of inference for the Text Classification task + */ +export interface TextClassificationOutputElement { + /** + * The predicted class label. + */ + label: string; + /** + * The corresponding probability. + */ + score: number; + [property: string]: unknown; +} diff --git a/node_modules/@huggingface/tasks/src/tasks/text-classification/spec/input.json b/node_modules/@huggingface/tasks/src/tasks/text-classification/spec/input.json new file mode 100644 index 0000000000000000000000000000000000000000..468f865dd598af5a8ee581f7a1b8245770d65662 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/text-classification/spec/input.json @@ -0,0 +1,35 @@ +{ + "$id": "/inference/schemas/text-classification/input.json", + "$schema": "http://json-schema.org/draft-06/schema#", + "description": "Inputs for Text Classification inference", + "title": "TextClassificationInput", + "type": "object", + "properties": { + "inputs": { + "description": "The text to classify", + "type": "string" + }, + "parameters": { + "description": "Additional inference parameters for Text Classification", + "$ref": "#/$defs/TextClassificationParameters" + } + }, + "$defs": { + "TextClassificationParameters": { + "title": "TextClassificationParameters", + "type": "object", + "properties": { + "function_to_apply": { + "title": "TextClassificationOutputTransform", + "$ref": "/inference/schemas/common-definitions.json#/definitions/ClassificationOutputTransform", + "description": "The function to apply to the model outputs in order to retrieve the scores." + }, + "top_k": { + "type": "integer", + "description": "When specified, limits the output to the top K most probable classes." + } + } + } + }, + "required": ["inputs"] +} diff --git a/node_modules/@huggingface/tasks/src/tasks/text-classification/spec/output.json b/node_modules/@huggingface/tasks/src/tasks/text-classification/spec/output.json new file mode 100644 index 0000000000000000000000000000000000000000..2bf3def357d3cfd65e9ca7f4f2fdc191ded633db --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/text-classification/spec/output.json @@ -0,0 +1,11 @@ +{ + "$id": "/inference/schemas/text-classification/output.json", + "$schema": "http://json-schema.org/draft-06/schema#", + "description": "Outputs of inference for the Text Classification task", + "title": "TextClassificationOutput", + "type": "array", + "items": { + "type": "object", + "$ref": "/inference/schemas/common-definitions.json#/definitions/ClassificationOutput" + } +} diff --git a/node_modules/@huggingface/tasks/src/tasks/text-generation/about.md b/node_modules/@huggingface/tasks/src/tasks/text-generation/about.md new file mode 100644 index 0000000000000000000000000000000000000000..ee8cdeadcff207f6c1b7e5c1faa8d6cbf3ab4023 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/text-generation/about.md @@ -0,0 +1,154 @@ +This task covers guides on both [text-generation](https://huggingface.co/models?pipeline_tag=text-generation&sort=downloads) and [text-to-text generation](https://huggingface.co/models?other=text2text-generation&sort=downloads) models. Popular large language models that are used for chats or following instructions are also covered in this task. You can find the list of selected open-source large language models [here](https://huggingface.co/spaces/open-llm-leaderboard/open_llm_leaderboard), ranked by their performance scores. + +## Use Cases + +### Instruction Models + +A model trained for text generation can be later adapted to follow instructions. You can try some of the most powerful instruction-tuned open-access models like Mixtral 8x7B, Cohere Command R+, and Meta Llama3 70B [at Hugging Chat](https://huggingface.co/chat). + +### Code Generation + +A Text Generation model, also known as a causal language model, can be trained on code from scratch to help the programmers in their repetitive coding tasks. One of the most popular open-source models for code generation is StarCoder, which can generate code in 80+ languages. You can try it [here](https://huggingface.co/spaces/bigcode/bigcode-playground). + +### Stories Generation + +A story generation model can receive an input like "Once upon a time" and proceed to create a story-like text based on those first words. You can try [this application](https://huggingface.co/spaces/mosaicml/mpt-7b-storywriter) which contains a model trained on story generation, by MosaicML. + +If your generative model training data is different than your use case, you can train a causal language model from scratch. Learn how to do it in the free transformers [course](https://huggingface.co/course/chapter7/6?fw=pt)! + +## Task Variants + +### Completion Generation Models + +A popular variant of Text Generation models predicts the next word given a bunch of words. Word by word a longer text is formed that results in for example: + +- Given an incomplete sentence, complete it. +- Continue a story given the first sentences. +- Provided a code description, generate the code. + +The most popular models for this task are GPT-based models, [Mistral](mistralai/Mistral-7B-v0.1) or [Llama series](https://huggingface.co/meta-llama/Llama-2-7b-chat-hf). These models are trained on data that has no labels, so you just need plain text to train your own model. You can train text generation models to generate a wide variety of documents, from code to stories. + +### Text-to-Text Generation Models + +These models are trained to learn the mapping between a pair of texts (e.g. translation from one language to another). The most popular variants of these models are [NLLB](facebook/nllb-200-distilled-600M), [FLAN-T5](https://huggingface.co/google/flan-t5-xxl), and [BART](https://huggingface.co/docs/transformers/model_doc/bart). Text-to-Text models are trained with multi-tasking capabilities, they can accomplish a wide range of tasks, including summarization, translation, and text classification. + +## Language Model Variants + +When it comes to text generation, the underlying language model can come in several types: + +- **Base models:** refers to plain language models like [Mistral 7B](https://huggingface.co/mistralai/Mistral-7B-v0.3) and [Meta Llama-3-70b](https://huggingface.co/meta-llama/Meta-Llama-3-70B). These models are good for fine-tuning and few-shot prompting. + +- **Instruction-trained models:** these models are trained in a multi-task manner to follow a broad range of instructions like "Write me a recipe for chocolate cake". Models like [Qwen 2 7B](https://huggingface.co/Qwen/Qwen2-7B-Instruct), [Yi 1.5 34B Chat](https://huggingface.co/01-ai/Yi-1.5-34B-Chat), and [Meta Llama 70B Instruct](https://huggingface.co/meta-llama/Meta-Llama-3-70B-Instruct) are examples of instruction-trained models. In general, instruction-trained models will produce better responses to instructions than base models. + +- **Human feedback models:** these models extend base and instruction-trained models by incorporating human feedback that rates the quality of the generated text according to criteria like [helpfulness, honesty, and harmlessness](https://arxiv.org/abs/2112.00861). The human feedback is then combined with an optimization technique like reinforcement learning to align the original model to be closer with human preferences. The overall methodology is often called [Reinforcement Learning from Human Feedback](https://huggingface.co/blog/rlhf), or RLHF for short. [Zephyr ORPO 141B A35B](https://huggingface.co/HuggingFaceH4/zephyr-orpo-141b-A35b-v0.1) is an open-source model aligned through human feedback. + +## Text Generation from Image and Text + +There are language models that can input both text and image and output text, called vision language models. [IDEFICS 2](https://huggingface.co/HuggingFaceM4/idefics2-8b) and [MiniCPM Llama3 V](https://huggingface.co/openbmb/MiniCPM-Llama3-V-2_5) are good examples. They accept the same generation parameters as other language models. However, since they also take images as input, you have to use them with the `image-to-text` pipeline. You can find more information about this in the [image-to-text task page](https://huggingface.co/tasks/image-to-text). + +## Inference + +You can use the 🤗 Transformers library `text-generation` pipeline to do inference with Text Generation models. It takes an incomplete text and returns multiple outputs with which the text can be completed. + +```python +from transformers import pipeline +generator = pipeline('text-generation', model = 'HuggingFaceH4/zephyr-7b-beta') +generator("Hello, I'm a language model", max_length = 30, num_return_sequences=3) +## [{'generated_text': "Hello, I'm a language modeler. So while writing this, when I went out to meet my wife or come home she told me that my"}, +## {'generated_text': "Hello, I'm a language modeler. I write and maintain software in Python. I love to code, and that includes coding things that require writing"}, ... +``` + +[Text-to-Text generation models](https://huggingface.co/models?other=text2text-generation&sort=downloads) have a separate pipeline called `text2text-generation`. This pipeline takes an input containing the sentence including the task and returns the output of the accomplished task. + +```python +from transformers import pipeline + +text2text_generator = pipeline("text2text-generation") +text2text_generator("question: What is 42 ? context: 42 is the answer to life, the universe and everything") +[{'generated_text': 'the answer to life, the universe and everything'}] + +text2text_generator("translate from English to French: I'm very happy") +[{'generated_text': 'Je suis très heureux'}] +``` + +You can use [huggingface.js](https://github.com/huggingface/huggingface.js) to infer text classification models on Hugging Face Hub. + +```javascript +import { InferenceClient } from "@huggingface/inference"; + +const inference = new InferenceClient(HF_TOKEN); +await inference.conversational({ + model: "distilbert-base-uncased-finetuned-sst-2-english", + inputs: "I love this movie!", +}); +``` + +## Text Generation Inference + +[Text Generation Inference (TGI)](https://github.com/huggingface/text-generation-inference) is an open-source toolkit for serving LLMs tackling challenges such as response time. TGI powers inference solutions like [Inference Endpoints](https://huggingface.co/inference-endpoints) and [Hugging Chat](https://huggingface.co/chat/), as well as multiple community projects. You can use it to deploy any supported open-source large language model of your choice. + +## ChatUI Spaces + +Hugging Face Spaces includes templates to easily deploy your own instance of a specific application. [ChatUI](https://github.com/huggingface/chat-ui) is an open-source interface that enables serving conversational interface for large language models and can be deployed with few clicks at Spaces. TGI powers these Spaces under the hood for faster inference. Thanks to the template, you can deploy your own instance based on a large language model with only a few clicks and customize it. Learn more about it [here](https://huggingface.co/docs/hub/spaces-sdks-docker-chatui) and create your large language model instance [here](https://huggingface.co/new-space?template=huggingchat/chat-ui-template). + +![ChatUI](https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/blog/os_llms/docker_chat.png) + +## Useful Resources + +Would you like to learn more about the topic? Awesome! Here you can find some curated resources that you may find helpful! + +### Tools within Hugging Face Ecosystem + +- You can use [PEFT](https://github.com/huggingface/peft) to adapt large language models in efficient way. +- [ChatUI](https://github.com/huggingface/chat-ui) is the open-source interface to conversate with Large Language Models. +- [text-generation-inference](https://github.com/huggingface/text-generation-inference) +- [HuggingChat](https://huggingface.co/chat/) is a chat interface powered by Hugging Face to chat with powerful models like Meta Llama 3 70B, Mixtral 8x7B, etc. + +### Documentation + +- [PEFT documentation](https://huggingface.co/docs/peft/index) +- [ChatUI Docker Spaces](https://huggingface.co/docs/hub/spaces-sdks-docker-chatui) +- [Causal language modeling task guide](https://huggingface.co/docs/transformers/tasks/language_modeling) +- [Text generation strategies](https://huggingface.co/docs/transformers/generation_strategies) +- [Course chapter on training a causal language model from scratch](https://huggingface.co/course/chapter7/6?fw=pt) + +### Model Inference & Deployment + +- [Optimizing your LLM in production](https://huggingface.co/blog/optimize-llm) +- [Open-Source Text Generation & LLM Ecosystem at Hugging Face](https://huggingface.co/blog/os-llms) +- [Introducing RWKV - An RNN with the advantages of a transformer](https://huggingface.co/blog/rwkv) +- [Llama 2 is at Hugging Face](https://huggingface.co/blog/llama2) +- [Guiding Text Generation with Constrained Beam Search in 🤗 Transformers](https://huggingface.co/blog/constrained-beam-search) +- [Code generation with Hugging Face](https://huggingface.co/spaces/codeparrot/code-generation-models) +- [Assisted Generation: a new direction toward low-latency text generation](https://huggingface.co/blog/assisted-generation) +- [How to generate text: using different decoding methods for language generation with Transformers](https://huggingface.co/blog/how-to-generate) +- [Faster Text Generation with TensorFlow and XLA](https://huggingface.co/blog/tf-xla-generate) + +### Model Fine-tuning/Training + +- [Non-engineers guide: Train a LLaMA 2 chatbot](https://huggingface.co/blog/Llama2-for-non-engineers) +- [Training CodeParrot 🦜 from Scratch](https://huggingface.co/blog/codeparrot) +- [Creating a Coding Assistant with StarCoder](https://huggingface.co/blog/starchat-alpha) + +### Advanced Concepts Explained Simply + +- [Mixture of Experts Explained](https://huggingface.co/blog/moe) + +### Advanced Fine-tuning/Training Recipes + +- [Fine-tuning Llama 2 70B using PyTorch FSDP](https://huggingface.co/blog/ram-efficient-pytorch-fsdp) +- [The N Implementation Details of RLHF with PPO](https://huggingface.co/blog/the_n_implementation_details_of_rlhf_with_ppo) +- [Preference Tuning LLMs with Direct Preference Optimization Methods](https://huggingface.co/blog/pref-tuning) +- [Fine-tune Llama 2 with DPO](https://huggingface.co/blog/dpo-trl) + +### Notebooks + +- [Training a CLM in Flax](https://github.com/huggingface/notebooks/blob/master/examples/causal_language_modeling_flax.ipynb) +- [Training a CLM in TensorFlow](https://github.com/huggingface/notebooks/blob/master/examples/language_modeling_from_scratch-tf.ipynb) +- [Training a CLM in PyTorch](https://github.com/huggingface/notebooks/blob/master/examples/language_modeling_from_scratch.ipynb) + +### Scripts for training + +- [Training a CLM in PyTorch](https://github.com/huggingface/transformers/tree/main/examples/pytorch/language-modeling) +- [Training a CLM in TensorFlow](https://github.com/huggingface/transformers/tree/main/examples/tensorflow/language-modeling) +- [Text Generation in PyTorch](https://github.com/huggingface/transformers/tree/main/examples/pytorch/text-generation) diff --git a/node_modules/@huggingface/tasks/src/tasks/text-generation/data.ts b/node_modules/@huggingface/tasks/src/tasks/text-generation/data.ts new file mode 100644 index 0000000000000000000000000000000000000000..a43fb437027db6b2b73e985342945ee17d10f058 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/text-generation/data.ts @@ -0,0 +1,130 @@ +import type { TaskDataCustom } from "../index.js"; + +const taskData: TaskDataCustom = { + datasets: [ + { + description: "Multilingual dataset used to evaluate text generation models.", + id: "CohereForAI/Global-MMLU", + }, + { + description: "High quality multilingual data used to train text-generation models.", + id: "HuggingFaceFW/fineweb-2", + }, + { + description: "Truly open-source, curated and cleaned dialogue dataset.", + id: "HuggingFaceH4/ultrachat_200k", + }, + { + description: "A reasoning dataset.", + id: "open-r1/OpenThoughts-114k-math", + }, + { + description: "A multilingual instruction dataset with preference ratings on responses.", + id: "allenai/tulu-3-sft-mixture", + }, + { + description: "A large synthetic dataset for alignment of text generation models.", + id: "HuggingFaceTB/smoltalk", + }, + { + description: "A dataset made for training text generation models solving math questions.", + id: "HuggingFaceTB/finemath", + }, + ], + demo: { + inputs: [ + { + label: "Input", + content: "Once upon a time,", + type: "text", + }, + ], + outputs: [ + { + label: "Output", + content: + "Once upon a time, we knew that our ancestors were on the verge of extinction. The great explorers and poets of the Old World, from Alexander the Great to Chaucer, are dead and gone. A good many of our ancient explorers and poets have", + type: "text", + }, + ], + }, + metrics: [ + { + description: + "Cross Entropy is a metric that calculates the difference between two probability distributions. Each probability distribution is the distribution of predicted words", + id: "Cross Entropy", + }, + { + description: + "The Perplexity metric is the exponential of the cross-entropy loss. It evaluates the probabilities assigned to the next word by the model. Lower perplexity indicates better performance", + id: "Perplexity", + }, + ], + models: [ + { description: "A text-generation model trained to follow instructions.", id: "google/gemma-2-2b-it" }, + { + description: "Powerful text generation model for coding.", + id: "Qwen/Qwen3-Coder-480B-A35B-Instruct", + }, + { + description: "Great text generation model with top-notch tool calling capabilities.", + id: "openai/gpt-oss-120b", + }, + { + description: "Powerful text generation model.", + id: "zai-org/GLM-4.5", + }, + { + description: "A powerful small model with reasoning capabilities.", + id: "Qwen/Qwen3-4B-Thinking-2507", + }, + { + description: "Strong conversational model that supports very long instructions.", + id: "Qwen/Qwen2.5-7B-Instruct-1M", + }, + { + description: "Text generation model used to write code.", + id: "Qwen/Qwen2.5-Coder-32B-Instruct", + }, + { + description: "Powerful reasoning based open large language model.", + id: "deepseek-ai/DeepSeek-R1", + }, + ], + spaces: [ + { + description: "An application that writes and executes code from text instructions and supports many models.", + id: "akhaliq/anycoder", + }, + { + description: "An application that builds websites from natural language prompts.", + id: "enzostvs/deepsite", + }, + { + description: "A leaderboard for comparing chain-of-thought performance of models.", + id: "logikon/open_cot_leaderboard", + }, + { + description: "An text generation based application based on a very powerful LLaMA2 model.", + id: "ysharma/Explore_llamav2_with_TGI", + }, + { + description: "An text generation based application to converse with Zephyr model.", + id: "HuggingFaceH4/zephyr-chat", + }, + { + description: "A leaderboard that ranks text generation models based on blind votes from people.", + id: "lmsys/chatbot-arena-leaderboard", + }, + { + description: "An chatbot to converse with a very powerful text generation model.", + id: "mlabonne/phixtral-chat", + }, + ], + summary: + "Generating text is the task of generating new text given another text. These models can, for example, fill in incomplete text or paraphrase.", + widgetModels: ["mistralai/Mistral-Nemo-Instruct-2407"], + youtubeId: "e9gNEAlsOvU", +}; + +export default taskData; diff --git a/node_modules/@huggingface/tasks/src/tasks/text-generation/inference.ts b/node_modules/@huggingface/tasks/src/tasks/text-generation/inference.ts new file mode 100644 index 0000000000000000000000000000000000000000..f77c1a60505f1a1a961b36d9d9aaea2e39454b7c --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/text-generation/inference.ts @@ -0,0 +1,187 @@ +/** + * Inference code generated from the JSON schema spec in ./spec + * + * Using src/scripts/inference-codegen + */ +/** + * Text Generation Input. + * + * Auto-generated from TGI specs. + * For more details, check out + * https://github.com/huggingface/huggingface.js/blob/main/packages/tasks/scripts/inference-tgi-import.ts. + */ +export interface TextGenerationInput { + inputs: string; + parameters?: TextGenerationInputGenerateParameters; + stream?: boolean; + [property: string]: unknown; +} +export interface TextGenerationInputGenerateParameters { + /** + * Lora adapter id + */ + adapter_id?: string; + /** + * Generate best_of sequences and return the one if the highest token logprobs. + */ + best_of?: number; + /** + * Whether to return decoder input token logprobs and ids. + */ + decoder_input_details?: boolean; + /** + * Whether to return generation details. + */ + details?: boolean; + /** + * Activate logits sampling. + */ + do_sample?: boolean; + /** + * The parameter for frequency penalty. 1.0 means no penalty + * Penalize new tokens based on their existing frequency in the text so far, + * decreasing the model's likelihood to repeat the same line verbatim. + */ + frequency_penalty?: number; + grammar?: TextGenerationInputGrammarType; + /** + * Maximum number of tokens to generate. + */ + max_new_tokens?: number; + /** + * The parameter for repetition penalty. 1.0 means no penalty. + * See [this paper](https://arxiv.org/pdf/1909.05858.pdf) for more details. + */ + repetition_penalty?: number; + /** + * Whether to prepend the prompt to the generated text + */ + return_full_text?: boolean; + /** + * Random sampling seed. + */ + seed?: number; + /** + * Stop generating tokens if a member of `stop` is generated. + */ + stop?: string[]; + /** + * The value used to module the logits distribution. + */ + temperature?: number; + /** + * The number of highest probability vocabulary tokens to keep for top-k-filtering. + */ + top_k?: number; + /** + * The number of highest probability vocabulary tokens to keep for top-n-filtering. + */ + top_n_tokens?: number; + /** + * Top-p value for nucleus sampling. + */ + top_p?: number; + /** + * Truncate inputs tokens to the given size. + */ + truncate?: number; + /** + * Typical Decoding mass + * See [Typical Decoding for Natural Language Generation](https://arxiv.org/abs/2202.00666) + * for more information. + */ + typical_p?: number; + /** + * Watermarking with [A Watermark for Large Language + * Models](https://arxiv.org/abs/2301.10226). + */ + watermark?: boolean; + [property: string]: unknown; +} +export interface TextGenerationInputGrammarType { + type: Type; + /** + * A string that represents a [JSON Schema](https://json-schema.org/). + * + * JSON Schema is a declarative language that allows to annotate JSON documents + * with types and descriptions. + */ + value: unknown; + [property: string]: unknown; +} +export type Type = "json" | "regex" | "json_schema"; +/** + * Text Generation Output. + * + * Auto-generated from TGI specs. + * For more details, check out + * https://github.com/huggingface/huggingface.js/blob/main/packages/tasks/scripts/inference-tgi-import.ts. + */ +export interface TextGenerationOutput { + details?: TextGenerationOutputDetails; + generated_text: string; + [property: string]: unknown; +} +export interface TextGenerationOutputDetails { + best_of_sequences?: TextGenerationOutputBestOfSequence[]; + finish_reason: TextGenerationOutputFinishReason; + generated_tokens: number; + prefill: TextGenerationOutputPrefillToken[]; + seed?: number; + tokens: TextGenerationOutputToken[]; + top_tokens?: Array; + [property: string]: unknown; +} +export interface TextGenerationOutputBestOfSequence { + finish_reason: TextGenerationOutputFinishReason; + generated_text: string; + generated_tokens: number; + prefill: TextGenerationOutputPrefillToken[]; + seed?: number; + tokens: TextGenerationOutputToken[]; + top_tokens?: Array; + [property: string]: unknown; +} +export type TextGenerationOutputFinishReason = "length" | "eos_token" | "stop_sequence"; +export interface TextGenerationOutputPrefillToken { + id: number; + logprob: number; + text: string; + [property: string]: unknown; +} +export interface TextGenerationOutputToken { + id: number; + logprob: number; + special: boolean; + text: string; + [property: string]: unknown; +} +/** + * Text Generation Stream Output. + * + * Auto-generated from TGI specs. + * For more details, check out + * https://github.com/huggingface/huggingface.js/blob/main/packages/tasks/scripts/inference-tgi-import.ts. + */ +export interface TextGenerationStreamOutput { + details?: TextGenerationStreamOutputStreamDetails; + generated_text?: string; + index: number; + token: TextGenerationStreamOutputToken; + top_tokens?: TextGenerationStreamOutputToken[]; + [property: string]: unknown; +} +export interface TextGenerationStreamOutputStreamDetails { + finish_reason: TextGenerationOutputFinishReason; + generated_tokens: number; + input_length: number; + seed?: number; + [property: string]: unknown; +} +export interface TextGenerationStreamOutputToken { + id: number; + logprob: number; + special: boolean; + text: string; + [property: string]: unknown; +} diff --git a/node_modules/@huggingface/tasks/src/tasks/text-generation/spec/input.json b/node_modules/@huggingface/tasks/src/tasks/text-generation/spec/input.json new file mode 100644 index 0000000000000000000000000000000000000000..e734be1d5074605ba8525b1216ac214a259ca7cf --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/text-generation/spec/input.json @@ -0,0 +1,247 @@ +{ + "$id": "/inference/schemas/text-generation/input.json", + "$schema": "http://json-schema.org/draft-06/schema#", + "description": "Text Generation Input.\n\nAuto-generated from TGI specs.\nFor more details, check out https://github.com/huggingface/huggingface.js/blob/main/packages/tasks/scripts/inference-tgi-import.ts.", + "title": "TextGenerationInput", + "type": "object", + "required": ["inputs"], + "properties": { + "inputs": { + "type": "string", + "example": "My name is Olivier and I" + }, + "parameters": { + "$ref": "#/$defs/TextGenerationInputGenerateParameters" + }, + "stream": { + "type": "boolean", + "default": "false" + } + }, + "$defs": { + "TextGenerationInputGenerateParameters": { + "type": "object", + "properties": { + "adapter_id": { + "type": "string", + "description": "Lora adapter id", + "default": "null", + "example": "null", + "nullable": true + }, + "best_of": { + "type": "integer", + "description": "Generate best_of sequences and return the one if the highest token logprobs.", + "default": "null", + "example": 1, + "nullable": true, + "minimum": 0, + "exclusiveMinimum": 0 + }, + "decoder_input_details": { + "type": "boolean", + "description": "Whether to return decoder input token logprobs and ids.", + "default": "false" + }, + "details": { + "type": "boolean", + "description": "Whether to return generation details.", + "default": "true" + }, + "do_sample": { + "type": "boolean", + "description": "Activate logits sampling.", + "default": "false", + "example": true + }, + "frequency_penalty": { + "type": "number", + "format": "float", + "description": "The parameter for frequency penalty. 1.0 means no penalty\nPenalize new tokens based on their existing frequency in the text so far,\ndecreasing the model's likelihood to repeat the same line verbatim.", + "default": "null", + "example": 0.1, + "nullable": true, + "exclusiveMinimum": -2 + }, + "grammar": { + "allOf": [ + { + "$ref": "#/$defs/TextGenerationInputGrammarType" + } + ], + "default": "null", + "nullable": true + }, + "max_new_tokens": { + "type": "integer", + "format": "int32", + "description": "Maximum number of tokens to generate.", + "default": "1024", + "example": "20", + "nullable": true, + "minimum": 0 + }, + "repetition_penalty": { + "type": "number", + "format": "float", + "description": "The parameter for repetition penalty. 1.0 means no penalty.\nSee [this paper](https://arxiv.org/pdf/1909.05858.pdf) for more details.", + "default": "null", + "example": 1.03, + "nullable": true, + "exclusiveMinimum": 0 + }, + "return_full_text": { + "type": "boolean", + "description": "Whether to prepend the prompt to the generated text", + "default": "null", + "example": false, + "nullable": true + }, + "seed": { + "type": "integer", + "format": "int64", + "description": "Random sampling seed.", + "default": "null", + "example": "null", + "nullable": true, + "minimum": 0, + "exclusiveMinimum": 0 + }, + "stop": { + "type": "array", + "items": { + "type": "string" + }, + "description": "Stop generating tokens if a member of `stop` is generated.", + "example": ["photographer"], + "maxItems": 4 + }, + "temperature": { + "type": "number", + "format": "float", + "description": "The value used to module the logits distribution.", + "default": "null", + "example": 0.5, + "nullable": true, + "exclusiveMinimum": 0 + }, + "top_k": { + "type": "integer", + "format": "int32", + "description": "The number of highest probability vocabulary tokens to keep for top-k-filtering.", + "default": "null", + "example": 10, + "nullable": true, + "exclusiveMinimum": 0 + }, + "top_n_tokens": { + "type": "integer", + "format": "int32", + "description": "The number of highest probability vocabulary tokens to keep for top-n-filtering.", + "default": "null", + "example": 5, + "nullable": true, + "minimum": 0, + "exclusiveMinimum": 0 + }, + "top_p": { + "type": "number", + "format": "float", + "description": "Top-p value for nucleus sampling.", + "default": "null", + "example": 0.95, + "nullable": true, + "maximum": 1, + "exclusiveMinimum": 0 + }, + "truncate": { + "type": "integer", + "description": "Truncate inputs tokens to the given size.", + "default": "null", + "example": "null", + "nullable": true, + "minimum": 0 + }, + "typical_p": { + "type": "number", + "format": "float", + "description": "Typical Decoding mass\nSee [Typical Decoding for Natural Language Generation](https://arxiv.org/abs/2202.00666) for more information.", + "default": "null", + "example": 0.95, + "nullable": true, + "maximum": 1, + "exclusiveMinimum": 0 + }, + "watermark": { + "type": "boolean", + "description": "Watermarking with [A Watermark for Large Language Models](https://arxiv.org/abs/2301.10226).", + "default": "false", + "example": true + } + }, + "title": "TextGenerationInputGenerateParameters" + }, + "TextGenerationInputGrammarType": { + "oneOf": [ + { + "type": "object", + "required": ["type", "value"], + "properties": { + "type": { + "type": "string", + "enum": ["json"] + }, + "value": { + "description": "A string that represents a [JSON Schema](https://json-schema.org/).\n\nJSON Schema is a declarative language that allows to annotate JSON documents\nwith types and descriptions." + } + } + }, + { + "type": "object", + "required": ["type", "value"], + "properties": { + "type": { + "type": "string", + "enum": ["regex"] + }, + "value": { + "type": "string" + } + } + }, + { + "type": "object", + "required": ["type", "value"], + "properties": { + "type": { + "type": "string", + "enum": ["json_schema"] + }, + "value": { + "$ref": "#/$defs/TextGenerationInputJsonSchemaConfig" + } + } + } + ], + "discriminator": { + "propertyName": "type" + }, + "title": "TextGenerationInputGrammarType" + }, + "TextGenerationInputJsonSchemaConfig": { + "type": "object", + "required": ["schema"], + "properties": { + "name": { + "type": "string", + "description": "Optional name identifier for the schema", + "nullable": true + }, + "schema": { + "description": "The actual JSON schema definition" + } + }, + "title": "TextGenerationInputJsonSchemaConfig" + } + } +} diff --git a/node_modules/@huggingface/tasks/src/tasks/text-generation/spec/output.json b/node_modules/@huggingface/tasks/src/tasks/text-generation/spec/output.json new file mode 100644 index 0000000000000000000000000000000000000000..cb6ef3f99694ae4ed5eb6a05b8f3ea18e1da8a60 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/text-generation/spec/output.json @@ -0,0 +1,179 @@ +{ + "$id": "/inference/schemas/text-generation/output.json", + "$schema": "http://json-schema.org/draft-06/schema#", + "description": "Text Generation Output.\n\nAuto-generated from TGI specs.\nFor more details, check out https://github.com/huggingface/huggingface.js/blob/main/packages/tasks/scripts/inference-tgi-import.ts.", + "title": "TextGenerationOutput", + "type": "object", + "required": ["generated_text"], + "properties": { + "details": { + "allOf": [ + { + "$ref": "#/$defs/TextGenerationOutputDetails" + } + ], + "nullable": true + }, + "generated_text": { + "type": "string", + "example": "test" + } + }, + "$defs": { + "TextGenerationOutputDetails": { + "type": "object", + "required": ["finish_reason", "generated_tokens", "prefill", "tokens"], + "properties": { + "best_of_sequences": { + "type": "array", + "items": { + "$ref": "#/$defs/TextGenerationOutputBestOfSequence" + }, + "nullable": true + }, + "finish_reason": { + "$ref": "#/$defs/TextGenerationOutputFinishReason" + }, + "generated_tokens": { + "type": "integer", + "format": "int32", + "example": 1, + "minimum": 0 + }, + "prefill": { + "type": "array", + "items": { + "$ref": "#/$defs/TextGenerationOutputPrefillToken" + } + }, + "seed": { + "type": "integer", + "format": "int64", + "example": 42, + "nullable": true, + "minimum": 0 + }, + "tokens": { + "type": "array", + "items": { + "$ref": "#/$defs/TextGenerationOutputToken" + } + }, + "top_tokens": { + "type": "array", + "items": { + "type": "array", + "items": { + "$ref": "#/$defs/TextGenerationOutputToken" + } + } + } + }, + "title": "TextGenerationOutputDetails" + }, + "TextGenerationOutputBestOfSequence": { + "type": "object", + "required": ["generated_text", "finish_reason", "generated_tokens", "prefill", "tokens"], + "properties": { + "finish_reason": { + "$ref": "#/$defs/TextGenerationOutputFinishReason" + }, + "generated_text": { + "type": "string", + "example": "test" + }, + "generated_tokens": { + "type": "integer", + "format": "int32", + "example": 1, + "minimum": 0 + }, + "prefill": { + "type": "array", + "items": { + "$ref": "#/$defs/TextGenerationOutputPrefillToken" + } + }, + "seed": { + "type": "integer", + "format": "int64", + "example": 42, + "nullable": true, + "minimum": 0 + }, + "tokens": { + "type": "array", + "items": { + "$ref": "#/$defs/TextGenerationOutputToken" + } + }, + "top_tokens": { + "type": "array", + "items": { + "type": "array", + "items": { + "$ref": "#/$defs/TextGenerationOutputToken" + } + } + } + }, + "title": "TextGenerationOutputBestOfSequence" + }, + "TextGenerationOutputFinishReason": { + "type": "string", + "enum": ["length", "eos_token", "stop_sequence"], + "example": "Length", + "title": "TextGenerationOutputFinishReason" + }, + "TextGenerationOutputPrefillToken": { + "type": "object", + "required": ["id", "text", "logprob"], + "properties": { + "id": { + "type": "integer", + "format": "int32", + "example": 0, + "minimum": 0 + }, + "logprob": { + "type": "number", + "format": "float", + "example": -0.34, + "nullable": true + }, + "text": { + "type": "string", + "example": "test" + } + }, + "title": "TextGenerationOutputPrefillToken" + }, + "TextGenerationOutputToken": { + "type": "object", + "required": ["id", "text", "logprob", "special"], + "properties": { + "id": { + "type": "integer", + "format": "int32", + "example": 0, + "minimum": 0 + }, + "logprob": { + "type": "number", + "format": "float", + "example": -0.34, + "nullable": true + }, + "special": { + "type": "boolean", + "example": "false" + }, + "text": { + "type": "string", + "example": "test" + } + }, + "title": "TextGenerationOutputToken" + } + } +} diff --git a/node_modules/@huggingface/tasks/src/tasks/text-generation/spec/stream_output.json b/node_modules/@huggingface/tasks/src/tasks/text-generation/spec/stream_output.json new file mode 100644 index 0000000000000000000000000000000000000000..fc566c6fe003eb445269af3668a941b403eb3549 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/text-generation/spec/stream_output.json @@ -0,0 +1,103 @@ +{ + "$id": "/inference/schemas/text-generation/stream_output.json", + "$schema": "http://json-schema.org/draft-06/schema#", + "description": "Text Generation Stream Output.\n\nAuto-generated from TGI specs.\nFor more details, check out https://github.com/huggingface/huggingface.js/blob/main/packages/tasks/scripts/inference-tgi-import.ts.", + "title": "TextGenerationStreamOutput", + "type": "object", + "required": ["index", "token"], + "properties": { + "details": { + "allOf": [ + { + "$ref": "#/$defs/TextGenerationStreamOutputStreamDetails" + } + ], + "default": "null", + "nullable": true + }, + "generated_text": { + "type": "string", + "default": "null", + "example": "test", + "nullable": true + }, + "index": { + "type": "integer", + "format": "int32", + "minimum": 0 + }, + "token": { + "$ref": "#/$defs/TextGenerationStreamOutputToken" + }, + "top_tokens": { + "type": "array", + "items": { + "$ref": "#/$defs/TextGenerationStreamOutputToken" + } + } + }, + "$defs": { + "TextGenerationStreamOutputStreamDetails": { + "type": "object", + "required": ["finish_reason", "generated_tokens", "input_length"], + "properties": { + "finish_reason": { + "$ref": "#/$defs/TextGenerationStreamOutputFinishReason" + }, + "generated_tokens": { + "type": "integer", + "format": "int32", + "example": 1, + "minimum": 0 + }, + "input_length": { + "type": "integer", + "format": "int32", + "example": 1, + "minimum": 0 + }, + "seed": { + "type": "integer", + "format": "int64", + "example": 42, + "nullable": true, + "minimum": 0 + } + }, + "title": "TextGenerationStreamOutputStreamDetails" + }, + "TextGenerationStreamOutputFinishReason": { + "type": "string", + "enum": ["length", "eos_token", "stop_sequence"], + "example": "Length", + "title": "TextGenerationStreamOutputFinishReason" + }, + "TextGenerationStreamOutputToken": { + "type": "object", + "required": ["id", "text", "logprob", "special"], + "properties": { + "id": { + "type": "integer", + "format": "int32", + "example": 0, + "minimum": 0 + }, + "logprob": { + "type": "number", + "format": "float", + "example": -0.34, + "nullable": true + }, + "special": { + "type": "boolean", + "example": "false" + }, + "text": { + "type": "string", + "example": "test" + } + }, + "title": "TextGenerationStreamOutputToken" + } + } +} diff --git a/node_modules/@huggingface/tasks/src/tasks/text-ranking/about.md b/node_modules/@huggingface/tasks/src/tasks/text-ranking/about.md new file mode 100644 index 0000000000000000000000000000000000000000..cd5986c5de759601815701bdb2cfb507d62e40ae --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/text-ranking/about.md @@ -0,0 +1,74 @@ +## Use Cases 🔍 + +### Information Retrieval + +You can improve Information Retrieval search stacks by applying a Text Ranking model as a Reranker in the common "[Retrieve and Rerank pipeline](https://sbert.net/examples/applications/retrieve_rerank/README.html)". First, you can use a [Sentence Similarity](https://huggingface.co/tasks/sentence-similarity) or [Feature Extraction](https://huggingface.co/tasks/feature-extraction) model as a Retriever to find the (for example) 100 most relevant documents for a query. Afterwards, you can rerank each of these 100 documents with a Text Ranking model to select an updated top 10. Often times, this results in improved retrieval performance than only using a Retriever model. + +## The Sentence Transformers library + +The [Sentence Transformers](https://www.sbert.net/) library is very powerful for using and training both Sentence Transformer (a.k.a. embedding or retriever) models as well as Cross Encoder (a.k.a. reranker) models. + +You can find and use [Sentence Transformers](https://huggingface.co/models?library=sentence-transformers&sort=downloads) models from the Hub by directly using the library, playing with the widgets in the browser or using Inference Endpoints. + +## Task Variants + +### Passage Ranking + +Passage Ranking is the task of ranking documents based on their relevance to a given query. The task is evaluated on Normalized Discounted Cumulative Gain, Mean Reciprocal Rank, or Mean Average Precision. These models take one query and multiple documents and return ranked documents according to the relevancy to the query. 📄 + +You can use it via the [Sentence Transformers library](https://sbert.net/docs/cross_encoder/usage/usage.html) like so: + +```python +from sentence_transformers import CrossEncoder + +# 1. Load a pre-trained CrossEncoder model +model = CrossEncoder("cross-encoder/ms-marco-MiniLM-L6-v2") + +query = "How many people live in Berlin?" +passages = [ + "Berlin had a population of 3,520,031 registered inhabitants in an area of 891.82 square kilometers.", + "Berlin is well known for its museums.", + "In 2014, the city state Berlin had 37,368 live births (+6.6%), a record number since 1991.", + "The urban area of Berlin comprised about 4.1 million people in 2014, making it the seventh most populous urban area in the European Union.", + "The city of Paris had a population of 2,165,423 people within its administrative city limits as of January 1, 2019", + "An estimated 300,000-420,000 Muslims reside in Berlin, making up about 8-11 percent of the population.", + "Berlin is subdivided into 12 boroughs or districts (Bezirke).", + "In 2015, the total labour force in Berlin was 1.85 million.", + "In 2013 around 600,000 Berliners were registered in one of the more than 2,300 sport and fitness clubs.", + "Berlin has a yearly total of about 135 million day visitors, which puts it in third place among the most-visited city destinations in the European Union.", +] + +# 2a. Either: predict scores for all pairs of sentences involved in the query +scores = model.predict([(query, passage) for passage in passages]) +# => [ 8.607138 -4.320077 7.5978117 8.915804 -4.237982 8.2359 0.33119553 3.4510403 6.352979 5.416662 ] + +# 2b. Or rank a list of passages for a query +ranks = model.rank(query, passages, return_documents=True) + +# Print the reranked passages +print("Query:", query) +for rank in ranks: + print(f"- #{rank['corpus_id']} ({rank['score']:.2f}): {rank['text']}") +""" +Query: How many people live in Berlin? +- #3 (8.92): The urban area of Berlin comprised about 4.1 million people in 2014, making it the seventh most populous urban area in the European Union. +- #0 (8.61): Berlin had a population of 3,520,031 registered inhabitants in an area of 891.82 square kilometers. +- #5 (8.24): An estimated 300,000-420,000 Muslims reside in Berlin, making up about 8-11 percent of the population. +- #2 (7.60): In 2014, the city state Berlin had 37,368 live births (+6.6%), a record number since 1991. +- #8 (6.35): In 2013 around 600,000 Berliners were registered in one of the more than 2,300 sport and fitness clubs. +- #9 (5.42): Berlin has a yearly total of about 135 million day visitors, which puts it in third place among the most-visited city destinations in the European Union. +- #7 (3.45): In 2015, the total labour force in Berlin was 1.85 million. +- #6 (0.33): Berlin is subdivided into 12 boroughs or districts (Bezirke). +- #4 (-4.24): The city of Paris had a population of 2,165,423 people within its administrative city limits as of January 1, 2019 +- #1 (-4.32): Berlin is well known for its museums. +""" +``` + +Rerankers often outperform [Sentence Similarity](https://huggingface.co/tasks/sentence-similarity) or [Feature Extraction](https://huggingface.co/tasks/feature-extraction) models, but they're too slow to rank a query against all documents. This is why they're commonly used to perform a final reranking of the top documents from a retriever: you can get the efficiency of a retriever model with the performance of a reranker. + +## Useful Resources + +Would you like to learn more about Text Ranking? Here is a curated resource that you may find helpful! + +- [Sentence Transformers > Cross Encoder Documentation](https://www.sbert.net/docs/cross_encoder/usage/usage.html) +- [Sentence Transformers > Usage > Retrieve & Re-Rank](https://www.sbert.net/examples/applications/retrieve_rerank/README.html) diff --git a/node_modules/@huggingface/tasks/src/tasks/text-ranking/data.ts b/node_modules/@huggingface/tasks/src/tasks/text-ranking/data.ts new file mode 100644 index 0000000000000000000000000000000000000000..265adc88fe6e78763410f79289440d872e036dfd --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/text-ranking/data.ts @@ -0,0 +1,91 @@ +import type { TaskDataCustom } from "../index.js"; + +const taskData: TaskDataCustom = { + datasets: [ + { + description: "Bing queries with relevant passages from various web sources.", + id: "microsoft/ms_marco", + }, + ], + demo: { + inputs: [ + { + label: "Source sentence", + content: "Machine learning is so easy.", + type: "text", + }, + { + label: "Sentences to compare to", + content: "Deep learning is so straightforward.", + type: "text", + }, + { + label: "", + content: "This is so difficult, like rocket science.", + type: "text", + }, + { + label: "", + content: "I can't believe how much I struggled with this.", + type: "text", + }, + ], + outputs: [ + { + type: "chart", + data: [ + { + label: "Deep learning is so straightforward.", + score: 2.2006407, + }, + { + label: "This is so difficult, like rocket science.", + score: -6.2634873, + }, + { + label: "I can't believe how much I struggled with this.", + score: -10.251488, + }, + ], + }, + ], + }, + metrics: [ + { + description: + "Discounted Cumulative Gain (DCG) measures the gain, or usefulness, of search results discounted by their position. The normalization is done by dividing the DCG by the ideal DCG, which is the DCG of the perfect ranking.", + id: "Normalized Discounted Cumulative Gain", + }, + { + description: + "Reciprocal Rank is a measure used to rank the relevancy of documents given a set of documents. Reciprocal Rank is the reciprocal of the rank of the document retrieved, meaning, if the rank is 3, the Reciprocal Rank is 0.33. If the rank is 1, the Reciprocal Rank is 1", + id: "Mean Reciprocal Rank", + }, + { + description: + "Mean Average Precision (mAP) is the overall average of the Average Precision (AP) values, where AP is the Area Under the PR Curve (AUC-PR)", + id: "Mean Average Precision", + }, + ], + models: [ + { + description: "An extremely efficient text ranking model trained on a web search dataset.", + id: "cross-encoder/ms-marco-MiniLM-L6-v2", + }, + { + description: "A strong multilingual text reranker model.", + id: "Alibaba-NLP/gte-multilingual-reranker-base", + }, + { + description: "An efficient text ranking model that punches above its weight.", + id: "Alibaba-NLP/gte-reranker-modernbert-base", + }, + ], + spaces: [], + summary: + "Text Ranking is the task of ranking a set of texts based on their relevance to a query. Text ranking models are trained on large datasets of queries and relevant documents to learn how to rank documents based on their relevance to the query. This task is particularly useful for search engines and information retrieval systems.", + widgetModels: ["cross-encoder/ms-marco-MiniLM-L6-v2"], + youtubeId: "", +}; + +export default taskData; diff --git a/node_modules/@huggingface/tasks/src/tasks/text-to-3d/about.md b/node_modules/@huggingface/tasks/src/tasks/text-to-3d/about.md new file mode 100644 index 0000000000000000000000000000000000000000..9f76ba3e4ddee504215bf676dc9bc28926c98fef --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/text-to-3d/about.md @@ -0,0 +1,62 @@ +## Use Cases + +Text-to-3D models can be used in a wide variety of applications that require 3D, such as games, animation, design, architecture, engineering, marketing, and more. + +![Text-to-3D Thumbnail](https://huggingface.co/datasets/huggingfacejs/tasks/resolve/main/text-to-3d/text-to-3d-thumbnail.png) + +This task is similar to the [image-to-3d](https://huggingface.co/tasks/image-to-3d) task, but takes text input instead of image input. In practice, this is often equivalent to a combination of [text-to-image](https://huggingface.co/tasks/text-to-image) and [image-to-3d](https://huggingface.co/tasks/image-to-3d). That is, the text is first converted to an image, then the image is converted to 3D. + +### Generating Meshes + +Meshes are the standard representation of 3D in industry. + +### Generating Gaussian Splats + +[Gaussian Splatting](https://huggingface.co/blog/gaussian-splatting) is a rendering technique that represents scenes as fuzzy points. + +### Inference + +Inference for this task typically leverages the [Diffusers](https://huggingface.co/docs/diffusers/index) library for inference, using [Custom Pipelines](https://huggingface.co/docs/diffusers/v0.6.0/en/using-diffusers/custom_pipelines). + +These are unstandardized and depend on the model. More details can be found in each model repository. + +```python +import torch +import requests +import numpy as np +from io import BytesIO +from diffusers import DiffusionPipeline +from PIL import Image + +pipeline = DiffusionPipeline.from_pretrained( + "dylanebert/LGM-full", + custom_pipeline="dylanebert/LGM-full", + torch_dtype=torch.float16, + trust_remote_code=True, +).to("cuda") + +input_prompt = "a cat statue" +result = pipeline(input_prompt, None) +result_path = "/tmp/output.ply" +pipeline.save_ply(result, result_path) +``` + +In the code above, we: + +1. Import the necessary libraries +2. Load the `LGM-full` model and custom pipeline +3. Define the input prompt +4. Run the pipeline on the input prompt +5. Save the output to a file + +### Output Formats + +Meshes can be in `.obj`, `.glb`, `.stl`, or `.gltf` format. Other formats are allowed, but won't be rendered in the gradio [Model3D](https://www.gradio.app/docs/gradio/model3d) component. + +Splats can be in `.ply` or `.splat` format. They can be rendered in the gradio [Model3D](https://www.gradio.app/docs/gradio/model3d) component using the [gsplat.js](https://github.com/huggingface/gsplat.js) library. + +## Useful Resources + +- [ML for 3D Course](https://huggingface.co/learn/ml-for-3d-course) +- [3D Arena Leaderboard](https://huggingface.co/spaces/dylanebert/3d-arena) +- [gsplat.js](https://github.com/huggingface/gsplat.js) diff --git a/node_modules/@huggingface/tasks/src/tasks/text-to-3d/data.ts b/node_modules/@huggingface/tasks/src/tasks/text-to-3d/data.ts new file mode 100644 index 0000000000000000000000000000000000000000..30f3aefc49bc00b9ec37b6ee18bc520d82b88b20 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/text-to-3d/data.ts @@ -0,0 +1,56 @@ +import type { TaskDataCustom } from "../index.js"; + +const taskData: TaskDataCustom = { + datasets: [ + { + description: "A large dataset of over 10 million 3D objects.", + id: "allenai/objaverse-xl", + }, + { + description: "Descriptive captions for 3D objects in Objaverse.", + id: "tiange/Cap3D", + }, + ], + demo: { + inputs: [ + { + label: "Prompt", + content: "a cat statue", + type: "text", + }, + ], + outputs: [ + { + label: "Result", + content: "text-to-3d-3d-output-filename.glb", + type: "text", + }, + ], + }, + metrics: [], + models: [ + { + description: "Text-to-3D mesh model by OpenAI", + id: "openai/shap-e", + }, + { + description: "Generative 3D gaussian splatting model.", + id: "ashawkey/LGM", + }, + ], + spaces: [ + { + description: "Text-to-3D demo with mesh outputs.", + id: "hysts/Shap-E", + }, + { + description: "Text/image-to-3D demo with splat outputs.", + id: "ashawkey/LGM", + }, + ], + summary: "Text-to-3D models take in text input and produce 3D output.", + widgetModels: [], + youtubeId: "", +}; + +export default taskData; diff --git a/node_modules/@huggingface/tasks/src/tasks/text-to-audio/inference.ts b/node_modules/@huggingface/tasks/src/tasks/text-to-audio/inference.ts new file mode 100644 index 0000000000000000000000000000000000000000..4a4101944814a62d082edbd1e1aaa14cac389e09 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/text-to-audio/inference.ts @@ -0,0 +1,133 @@ +/** + * Outputs of inference for the Text To Audio task + */ +export interface TextToAudioOutput { + /** + * The generated audio waveform. + */ + audio: Blob; + /** + * The sampling rate of the generated audio waveform. + */ + sampling_rate: number; + [property: string]: unknown; +} +/** + * Inference code generated from the JSON schema spec in ./spec + * + * Using src/scripts/inference-codegen + */ +/** + * Inputs for Text To Audio inference + */ +export interface TextToAudioInput { + /** + * The input text data + */ + inputs: string; + /** + * Additional inference parameters for Text To Audio + */ + parameters?: TextToAudioParameters; + [property: string]: unknown; +} +/** + * Additional inference parameters for Text To Audio + */ +export interface TextToAudioParameters { + /** + * Parametrization of the text generation process + */ + generation_parameters?: GenerationParameters; + [property: string]: unknown; +} +/** + * Parametrization of the text generation process + */ +export interface GenerationParameters { + /** + * Whether to use sampling instead of greedy decoding when generating new tokens. + */ + do_sample?: boolean; + /** + * Controls the stopping condition for beam-based methods. + */ + early_stopping?: EarlyStoppingUnion; + /** + * If set to float strictly between 0 and 1, only tokens with a conditional probability + * greater than epsilon_cutoff will be sampled. In the paper, suggested values range from + * 3e-4 to 9e-4, depending on the size of the model. See [Truncation Sampling as Language + * Model Desmoothing](https://hf.co/papers/2210.15191) for more details. + */ + epsilon_cutoff?: number; + /** + * Eta sampling is a hybrid of locally typical sampling and epsilon sampling. If set to + * float strictly between 0 and 1, a token is only considered if it is greater than either + * eta_cutoff or sqrt(eta_cutoff) * exp(-entropy(softmax(next_token_logits))). The latter + * term is intuitively the expected next token probability, scaled by sqrt(eta_cutoff). In + * the paper, suggested values range from 3e-4 to 2e-3, depending on the size of the model. + * See [Truncation Sampling as Language Model Desmoothing](https://hf.co/papers/2210.15191) + * for more details. + */ + eta_cutoff?: number; + /** + * The maximum length (in tokens) of the generated text, including the input. + */ + max_length?: number; + /** + * The maximum number of tokens to generate. Takes precedence over max_length. + */ + max_new_tokens?: number; + /** + * The minimum length (in tokens) of the generated text, including the input. + */ + min_length?: number; + /** + * The minimum number of tokens to generate. Takes precedence over min_length. + */ + min_new_tokens?: number; + /** + * Number of groups to divide num_beams into in order to ensure diversity among different + * groups of beams. See [this paper](https://hf.co/papers/1610.02424) for more details. + */ + num_beam_groups?: number; + /** + * Number of beams to use for beam search. + */ + num_beams?: number; + /** + * The value balances the model confidence and the degeneration penalty in contrastive + * search decoding. + */ + penalty_alpha?: number; + /** + * The value used to modulate the next token probabilities. + */ + temperature?: number; + /** + * The number of highest probability vocabulary tokens to keep for top-k-filtering. + */ + top_k?: number; + /** + * If set to float < 1, only the smallest set of most probable tokens with probabilities + * that add up to top_p or higher are kept for generation. + */ + top_p?: number; + /** + * Local typicality measures how similar the conditional probability of predicting a target + * token next is to the expected conditional probability of predicting a random token next, + * given the partial text already generated. If set to float < 1, the smallest set of the + * most locally typical tokens with probabilities that add up to typical_p or higher are + * kept for generation. See [this paper](https://hf.co/papers/2202.00666) for more details. + */ + typical_p?: number; + /** + * Whether the model should use the past last key/values attentions to speed up decoding + */ + use_cache?: boolean; + [property: string]: unknown; +} +/** + * Controls the stopping condition for beam-based methods. + */ +export type EarlyStoppingUnion = boolean | "never"; diff --git a/node_modules/@huggingface/tasks/src/tasks/text-to-audio/spec/input.json b/node_modules/@huggingface/tasks/src/tasks/text-to-audio/spec/input.json new file mode 100644 index 0000000000000000000000000000000000000000..a836c53d56e71e2117ed9e6909744461e23cfe17 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/text-to-audio/spec/input.json @@ -0,0 +1,30 @@ +{ + "$id": "/inference/schemas/text-to-audio/input.json", + "$schema": "http://json-schema.org/draft-06/schema#", + "description": "Inputs for Text To Audio inference", + "title": "TextToAudioInput", + "type": "object", + "properties": { + "inputs": { + "description": "The input text data", + "type": "string" + }, + "parameters": { + "description": "Additional inference parameters for Text To Audio", + "$ref": "#/$defs/TextToAudioParameters" + } + }, + "$defs": { + "TextToAudioParameters": { + "title": "TextToAudioParameters", + "type": "object", + "properties": { + "generation_parameters": { + "description": "Parametrization of the text generation process", + "$ref": "/inference/schemas/common-definitions.json#/definitions/GenerationParameters" + } + } + } + }, + "required": ["inputs"] +} diff --git a/node_modules/@huggingface/tasks/src/tasks/text-to-audio/spec/output.json b/node_modules/@huggingface/tasks/src/tasks/text-to-audio/spec/output.json new file mode 100644 index 0000000000000000000000000000000000000000..8d39db79c1b8bdf1ee4ab42c2a977fd9bde03eb7 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/text-to-audio/spec/output.json @@ -0,0 +1,18 @@ +{ + "$id": "/inference/schemas/text-to-audio/output.json", + "$schema": "http://json-schema.org/draft-06/schema#", + "description": "Outputs of inference for the Text To Audio task", + "title": "TextToAudioOutput", + "type": "object", + "properties": { + "audio": { + "description": "The generated audio waveform.", + "comment": "type=binary" + }, + "sampling_rate": { + "type": "number", + "description": "The sampling rate of the generated audio waveform." + } + }, + "required": ["audio", "sampling_rate"] +} diff --git a/node_modules/@huggingface/tasks/src/tasks/text-to-image/about.md b/node_modules/@huggingface/tasks/src/tasks/text-to-image/about.md new file mode 100644 index 0000000000000000000000000000000000000000..9cb11798ece00cde3707664cfcc27d8a9c04c530 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/text-to-image/about.md @@ -0,0 +1,96 @@ +## Use Cases + +### Data Generation + +Businesses can generate data for their use cases by inputting text and getting image outputs. + +### Immersive Conversational Chatbots + +Chatbots can be made more immersive if they provide contextual images based on the input provided by the user. + +### Creative Ideas for Fashion Industry + +Different patterns can be generated to obtain unique pieces of fashion. Text-to-image models make creations easier for designers to conceptualize their design before actually implementing it. + +### Architecture Industry + +Architects can utilise the models to construct an environment based out on the requirements of the floor plan. This can also include the furniture that has to be placed in that environment. + +## Task Variants + +### Image Editing + +Image editing with text-to-image models involves modifying an image following edit instructions provided in a text prompt. + +- **Synthetic image editing**: Adjusting images that were initially created using an input prompt while preserving the overall meaning or context of the original image. + + ![Examples](https://huggingface.co/datasets/diffusers/diffusers-images-docs/resolve/main/edit_p2p.png) + _Figure taken from ["InstructPix2Pix: Learning to Follow Image Editing Instructions"](https://www.timothybrooks.com/instruct-pix2pix)_ + +- **Real image editing**: Similar to synthetic image editing, except we're using real photos/images. This task is usually more complex. + + ![Examples](https://huggingface.co/datasets/diffusers/diffusers-images-docs/resolve/main/pix2pix.jpeg) + _Figure taken from ["Prompt-to-Prompt Image Editing with Cross-Attention Control"](https://prompt-to-prompt.github.io)_ + +### Personalization + +Personalization refers to techniques used to customize text-to-image models. We introduce new subjects or concepts to the model, which the model can then generate when we refer to them with a text prompt. + +For example, you can use these techniques to generate images of your dog in imaginary settings, after you have taught the model using a few reference images of the subject (or just one in some cases). Teaching the model a new concept can be achieved through fine-tuning, or by using training-free techniques. + +## Inference + +You can use diffusers pipelines to infer with `text-to-image` models. + +```python +from diffusers import StableDiffusionPipeline, EulerDiscreteScheduler + +model_id = "stabilityai/stable-diffusion-2" +scheduler = EulerDiscreteScheduler.from_pretrained(model_id, subfolder="scheduler") +pipe = StableDiffusionPipeline.from_pretrained(model_id, scheduler=scheduler, torch_dtype=torch.float16) +pipe = pipe.to("cuda") + +prompt = "a photo of an astronaut riding a horse on mars" +image = pipe(prompt).images[0] +``` + +You can use [huggingface.js](https://github.com/huggingface/huggingface.js) to infer text-to-image models on Hugging Face Hub. + +```javascript +import { InferenceClient } from "@huggingface/inference"; + +const inference = new InferenceClient(HF_TOKEN); +await inference.textToImage({ + model: "stabilityai/stable-diffusion-2", + inputs: "award winning high resolution photo of a giant tortoise/((ladybird)) hybrid, [trending on artstation]", + parameters: { + negative_prompt: "blurry", + }, +}); +``` + +## Useful Resources + +### Model Inference + +- [Hugging Face Diffusion Models Course](https://github.com/huggingface/diffusion-models-class) +- [Getting Started with Diffusers](https://huggingface.co/docs/diffusers/index) +- [Text-to-Image Generation](https://huggingface.co/docs/diffusers/using-diffusers/conditional_image_generation) +- [Using Stable Diffusion with Core ML on Apple Silicon](https://huggingface.co/blog/diffusers-coreml) +- [A guide on Vector Quantized Diffusion](https://huggingface.co/blog/vq-diffusion) +- [🧨 Stable Diffusion in JAX/Flax](https://huggingface.co/blog/stable_diffusion_jax) +- [Running IF with 🧨 diffusers on a Free Tier Google Colab](https://huggingface.co/blog/if) +- [Introducing Würstchen: Fast Diffusion for Image Generation](https://huggingface.co/blog/wuerstchen) +- [Efficient Controllable Generation for SDXL with T2I-Adapters](https://huggingface.co/blog/t2i-sdxl-adapters) +- [Welcome aMUSEd: Efficient Text-to-Image Generation](https://huggingface.co/blog/amused) +- Image Editing Demos: [LEDITS++](https://huggingface.co/spaces/editing-images/leditsplusplus), [Turbo Edit](https://huggingface.co/spaces/turboedit/turbo_edit), [InstructPix2Pix](https://huggingface.co/spaces/timbrooks/instruct-pix2pix), [CosXL](https://huggingface.co/spaces/multimodalart/cosxl) +- Training free Personalization Demos: [Face-to-All](https://huggingface.co/spaces/multimodalart/face-to-all), [InstantStyle](https://huggingface.co/spaces/InstantX/InstantStyle), [RB-modulation](https://huggingface.co/spaces/fffiloni/RB-Modulation), [Photomaker v2](https://huggingface.co/spaces/TencentARC/PhotoMaker-V2) + +### Model Fine-tuning + +- [Finetune Stable Diffusion Models with DDPO via TRL](https://huggingface.co/blog/pref-tuning) +- [LoRA training scripts of the world, unite!](https://huggingface.co/blog/sdxl_lora_advanced_script) +- [Using LoRA for Efficient Stable Diffusion Fine-Tuning](https://huggingface.co/blog/lora) +- LoRA fine tuning Spaces: [FLUX.1 finetuning](https://huggingface.co/spaces/autotrain-projects/train-flux-lora-ease), [SDXL finetuning](https://huggingface.co/spaces/multimodalart/lora-ease) + +This page was made possible thanks to the efforts of [Ishan Dutta](https://huggingface.co/ishandutta), [Enrique Elias Ubaldo](https://huggingface.co/herrius) and [Oğuz Akif](https://huggingface.co/oguzakif). diff --git a/node_modules/@huggingface/tasks/src/tasks/text-to-image/data.ts b/node_modules/@huggingface/tasks/src/tasks/text-to-image/data.ts new file mode 100644 index 0000000000000000000000000000000000000000..2a1fcc80992c86ff61a9f7736ec0155554ab8ebf --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/text-to-image/data.ts @@ -0,0 +1,104 @@ +import type { TaskDataCustom } from "../index.js"; + +const taskData: TaskDataCustom = { + datasets: [ + { + description: "RedCaps is a large-scale dataset of 12M image-text pairs collected from Reddit.", + id: "red_caps", + }, + { + description: "Conceptual Captions is a dataset consisting of ~3.3M images annotated with captions.", + id: "conceptual_captions", + }, + { + description: "12M image-caption pairs.", + id: "Spawning/PD12M", + }, + ], + demo: { + inputs: [ + { + label: "Input", + content: "A city above clouds, pastel colors, Victorian style", + type: "text", + }, + ], + outputs: [ + { + filename: "image.jpeg", + type: "img", + }, + ], + }, + metrics: [ + { + description: + "The Inception Score (IS) measure assesses diversity and meaningfulness. It uses a generated image sample to predict its label. A higher score signifies more diverse and meaningful images.", + id: "IS", + }, + { + description: + "The Fréchet Inception Distance (FID) calculates the distance between distributions between synthetic and real samples. A lower FID score indicates better similarity between the distributions of real and generated images.", + id: "FID", + }, + { + description: + "R-precision assesses how the generated image aligns with the provided text description. It uses the generated images as queries to retrieve relevant text descriptions. The top 'r' relevant descriptions are selected and used to calculate R-precision as r/R, where 'R' is the number of ground truth descriptions associated with the generated images. A higher R-precision value indicates a better model.", + id: "R-Precision", + }, + ], + models: [ + { + description: "One of the most powerful image generation models that can generate realistic outputs.", + id: "black-forest-labs/FLUX.1-Krea-dev", + }, + { + description: "A powerful image generation model.", + id: "Qwen/Qwen-Image", + }, + { + description: "Powerful and fast image generation model.", + id: "ByteDance/SDXL-Lightning", + }, + { + description: "A powerful text-to-image model.", + id: "ByteDance/Hyper-SD", + }, + ], + spaces: [ + { + description: "A powerful text-to-image application.", + id: "stabilityai/stable-diffusion-3-medium", + }, + { + description: "A text-to-image application to generate comics.", + id: "jbilcke-hf/ai-comic-factory", + }, + { + description: "An application to match multiple custom image generation models.", + id: "multimodalart/flux-lora-lab", + }, + { + description: "A powerful yet very fast image generation application.", + id: "latent-consistency/lcm-lora-for-sdxl", + }, + { + description: "A gallery to explore various text-to-image models.", + id: "multimodalart/LoraTheExplorer", + }, + { + description: "An application for `text-to-image`, `image-to-image` and image inpainting.", + id: "ArtGAN/Stable-Diffusion-ControlNet-WebUI", + }, + { + description: "An application to generate realistic images given photos of a person and a prompt.", + id: "InstantX/InstantID", + }, + ], + summary: + "Text-to-image is the task of generating images from input text. These pipelines can also be used to modify and edit images based on text prompts.", + widgetModels: ["black-forest-labs/FLUX.1-dev"], + youtubeId: "", +}; + +export default taskData; diff --git a/node_modules/@huggingface/tasks/src/tasks/text-to-image/inference.ts b/node_modules/@huggingface/tasks/src/tasks/text-to-image/inference.ts new file mode 100644 index 0000000000000000000000000000000000000000..5bdc8a34036010c2d1764570cd2b81e9999205c6 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/text-to-image/inference.ts @@ -0,0 +1,65 @@ +/** + * Inference code generated from the JSON schema spec in ./spec + * + * Using src/scripts/inference-codegen + */ +/** + * Inputs for Text To Image inference + */ +export interface TextToImageInput { + /** + * The input text data (sometimes called "prompt") + */ + inputs: string; + /** + * Additional inference parameters for Text To Image + */ + parameters?: TextToImageParameters; + [property: string]: unknown; +} +/** + * Additional inference parameters for Text To Image + */ +export interface TextToImageParameters { + /** + * A higher guidance scale value encourages the model to generate images closely linked to + * the text prompt, but values too high may cause saturation and other artifacts. + */ + guidance_scale?: number; + /** + * The height in pixels of the output image + */ + height?: number; + /** + * One prompt to guide what NOT to include in image generation. + */ + negative_prompt?: string; + /** + * The number of denoising steps. More denoising steps usually lead to a higher quality + * image at the expense of slower inference. + */ + num_inference_steps?: number; + /** + * Override the scheduler with a compatible one. + */ + scheduler?: string; + /** + * Seed for the random number generator. + */ + seed?: number; + /** + * The width in pixels of the output image + */ + width?: number; + [property: string]: unknown; +} +/** + * Outputs of inference for the Text To Image task + */ +export interface TextToImageOutput { + /** + * The generated image returned as raw bytes in the payload. + */ + image: unknown; + [property: string]: unknown; +} diff --git a/node_modules/@huggingface/tasks/src/tasks/text-to-image/spec/input.json b/node_modules/@huggingface/tasks/src/tasks/text-to-image/spec/input.json new file mode 100644 index 0000000000000000000000000000000000000000..f94e0bbc3ea7fa723bfaab85be1c4d65385e2c7b --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/text-to-image/spec/input.json @@ -0,0 +1,54 @@ +{ + "$id": "/inference/schemas/text-to-image/input.json", + "$schema": "http://json-schema.org/draft-06/schema#", + "description": "Inputs for Text To Image inference", + "title": "TextToImageInput", + "type": "object", + "properties": { + "inputs": { + "description": "The input text data (sometimes called \"prompt\")", + "type": "string" + }, + "parameters": { + "description": "Additional inference parameters for Text To Image", + "$ref": "#/$defs/TextToImageParameters" + } + }, + "$defs": { + "TextToImageParameters": { + "title": "TextToImageParameters", + "type": "object", + "properties": { + "guidance_scale": { + "type": "number", + "description": "A higher guidance scale value encourages the model to generate images closely linked to the text prompt, but values too high may cause saturation and other artifacts." + }, + "negative_prompt": { + "type": "string", + "description": "One prompt to guide what NOT to include in image generation." + }, + "num_inference_steps": { + "type": "integer", + "description": "The number of denoising steps. More denoising steps usually lead to a higher quality image at the expense of slower inference." + }, + "width": { + "type": "integer", + "description": "The width in pixels of the output image" + }, + "height": { + "type": "integer", + "description": "The height in pixels of the output image" + }, + "scheduler": { + "type": "string", + "description": "Override the scheduler with a compatible one." + }, + "seed": { + "type": "integer", + "description": "Seed for the random number generator." + } + } + } + }, + "required": ["inputs"] +} diff --git a/node_modules/@huggingface/tasks/src/tasks/text-to-image/spec/output.json b/node_modules/@huggingface/tasks/src/tasks/text-to-image/spec/output.json new file mode 100644 index 0000000000000000000000000000000000000000..f90a1eee18655cc5febb99cba38a3d784994261d --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/text-to-image/spec/output.json @@ -0,0 +1,13 @@ +{ + "$id": "/inference/schemas/text-to-image/output.json", + "$schema": "http://json-schema.org/draft-06/schema#", + "description": "Outputs of inference for the Text To Image task", + "title": "TextToImageOutput", + "type": "object", + "properties": { + "image": { + "description": "The generated image returned as raw bytes in the payload." + } + }, + "required": ["image"] +} diff --git a/node_modules/@huggingface/tasks/src/tasks/text-to-speech/about.md b/node_modules/@huggingface/tasks/src/tasks/text-to-speech/about.md new file mode 100644 index 0000000000000000000000000000000000000000..c241d63df680c9c8e8cf9ae12763f611a58e3789 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/text-to-speech/about.md @@ -0,0 +1,63 @@ +## Use Cases + +Text-to-Speech (TTS) models can be used in any speech-enabled application that requires converting text to speech imitating human voice. + +### Voice Assistants + +TTS models are used to create voice assistants on smart devices. These models are a better alternative compared to concatenative methods where the assistant is built by recording sounds and mapping them, since the outputs in TTS models contain elements in natural speech such as emphasis. + +### Announcement Systems + +TTS models are widely used in airport and public transportation announcement systems to convert the announcement of a given text into speech. + +## Inference Endpoints + +The Hub contains over [1500 TTS models](https://huggingface.co/models?pipeline_tag=text-to-speech&sort=downloads) that you can use right away by trying out the widgets directly in the browser or calling the models as a service using Inference Endpoints. Here is a simple code snippet to get you started: + +```python +import json +import requests + +headers = {"Authorization": f"Bearer {API_TOKEN}"} +API_URL = "https://router.huggingface.co/hf-inference/models/microsoft/speecht5_tts" + +def query(payload): + response = requests.post(API_URL, headers=headers, json=payload) + return response + +output = query({"text_inputs": "Max is the best doggo."}) +``` + +You can also use libraries such as [espnet](https://huggingface.co/models?library=espnet&pipeline_tag=text-to-speech&sort=downloads) or [transformers](https://huggingface.co/models?pipeline_tag=text-to-speech&library=transformers&sort=trending) if you want to handle the Inference directly. + +## Direct Inference + +Now, you can also use the Text-to-Speech pipeline in Transformers to synthesise high quality voice. + +```python +from transformers import pipeline + +synthesizer = pipeline("text-to-speech", "suno/bark") + +synthesizer("Look I am generating speech in three lines of code!") +``` + +You can use [huggingface.js](https://github.com/huggingface/huggingface.js) to infer summarization models on Hugging Face Hub. + +```javascript +import { InferenceClient } from "@huggingface/inference"; + +const inference = new InferenceClient(HF_TOKEN); +await inference.textToSpeech({ + model: "facebook/mms-tts", + inputs: "text to generate speech from", +}); +``` + +## Useful Resources + +- [Hugging Face Audio Course](https://huggingface.co/learn/audio-course/chapter6/introduction) +- [ML for Audio Study Group - Text to Speech Deep Dive](https://www.youtube.com/watch?v=aLBedWj-5CQ) +- [Speech Synthesis, Recognition, and More With SpeechT5](https://huggingface.co/blog/speecht5) +- [Optimizing a Text-To-Speech model using 🤗 Transformers](https://huggingface.co/blog/optimizing-bark) +- [Train your own TTS models with Parler-TTS](https://github.com/huggingface/parler-tts) diff --git a/node_modules/@huggingface/tasks/src/tasks/text-to-speech/data.ts b/node_modules/@huggingface/tasks/src/tasks/text-to-speech/data.ts new file mode 100644 index 0000000000000000000000000000000000000000..d85cd1e24adf3484c43273850a9ca2431b755032 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/text-to-speech/data.ts @@ -0,0 +1,86 @@ +import type { TaskDataCustom } from "../index.js"; + +const taskData: TaskDataCustom = { + canonicalId: "text-to-audio", + datasets: [ + { + description: "10K hours of multi-speaker English dataset.", + id: "parler-tts/mls_eng_10k", + }, + { + description: "Multi-speaker English dataset.", + id: "mythicinfinity/libritts_r", + }, + { + description: "Multi-lingual dataset.", + id: "facebook/multilingual_librispeech", + }, + ], + demo: { + inputs: [ + { + label: "Input", + content: "I love audio models on the Hub!", + type: "text", + }, + ], + outputs: [ + { + filename: "audio.wav", + type: "audio", + }, + ], + }, + metrics: [ + { + description: "The Mel Cepstral Distortion (MCD) metric is used to calculate the quality of generated speech.", + id: "mel cepstral distortion", + }, + ], + models: [ + { + description: "Small yet powerful TTS model.", + id: "KittenML/kitten-tts-nano-0.1", + }, + { + description: "Bleeding edge TTS model.", + id: "ResembleAI/chatterbox", + }, + { + description: "A massively multi-lingual TTS model.", + id: "fishaudio/fish-speech-1.5", + }, + { + description: "A text-to-dialogue model.", + id: "nari-labs/Dia-1.6B-0626", + }, + ], + spaces: [ + { + description: "An application for generate high quality speech in different languages.", + id: "hexgrad/Kokoro-TTS", + }, + { + description: "A multilingual text-to-speech application.", + id: "fishaudio/fish-speech-1", + }, + { + description: "Performant TTS application.", + id: "ResembleAI/Chatterbox", + }, + { + description: "An application to compare different TTS models.", + id: "TTS-AGI/TTS-Arena-V2", + }, + { + description: "An application that generates podcast episodes.", + id: "ngxson/kokoro-podcast-generator", + }, + ], + summary: + "Text-to-Speech (TTS) is the task of generating natural sounding speech given text input. TTS models can be extended to have a single model that generates speech for multiple speakers and multiple languages.", + widgetModels: ["suno/bark"], + youtubeId: "NW62DpzJ274", +}; + +export default taskData; diff --git a/node_modules/@huggingface/tasks/src/tasks/text-to-speech/inference.ts b/node_modules/@huggingface/tasks/src/tasks/text-to-speech/inference.ts new file mode 100644 index 0000000000000000000000000000000000000000..4515de301a8b4dc044b0d7a7f45f3729e4f4662f --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/text-to-speech/inference.ts @@ -0,0 +1,133 @@ +/** + * Outputs of inference for the Text To Speech task + */ +export interface TextToSpeechOutput { + /** + * The generated audio + */ + audio: Blob; + /** + * The sampling rate of the generated audio waveform. + */ + sampling_rate?: number; + [property: string]: unknown; +} +/** + * Inference code generated from the JSON schema spec in ./spec + * + * Using src/scripts/inference-codegen + */ +/** + * Inputs for Text To Speech inference + */ +export interface TextToSpeechInput { + /** + * The input text data + */ + inputs: string; + /** + * Additional inference parameters for Text To Speech + */ + parameters?: TextToSpeechParameters; + [property: string]: unknown; +} +/** + * Additional inference parameters for Text To Speech + */ +export interface TextToSpeechParameters { + /** + * Parametrization of the text generation process + */ + generation_parameters?: GenerationParameters; + [property: string]: unknown; +} +/** + * Parametrization of the text generation process + */ +export interface GenerationParameters { + /** + * Whether to use sampling instead of greedy decoding when generating new tokens. + */ + do_sample?: boolean; + /** + * Controls the stopping condition for beam-based methods. + */ + early_stopping?: EarlyStoppingUnion; + /** + * If set to float strictly between 0 and 1, only tokens with a conditional probability + * greater than epsilon_cutoff will be sampled. In the paper, suggested values range from + * 3e-4 to 9e-4, depending on the size of the model. See [Truncation Sampling as Language + * Model Desmoothing](https://hf.co/papers/2210.15191) for more details. + */ + epsilon_cutoff?: number; + /** + * Eta sampling is a hybrid of locally typical sampling and epsilon sampling. If set to + * float strictly between 0 and 1, a token is only considered if it is greater than either + * eta_cutoff or sqrt(eta_cutoff) * exp(-entropy(softmax(next_token_logits))). The latter + * term is intuitively the expected next token probability, scaled by sqrt(eta_cutoff). In + * the paper, suggested values range from 3e-4 to 2e-3, depending on the size of the model. + * See [Truncation Sampling as Language Model Desmoothing](https://hf.co/papers/2210.15191) + * for more details. + */ + eta_cutoff?: number; + /** + * The maximum length (in tokens) of the generated text, including the input. + */ + max_length?: number; + /** + * The maximum number of tokens to generate. Takes precedence over max_length. + */ + max_new_tokens?: number; + /** + * The minimum length (in tokens) of the generated text, including the input. + */ + min_length?: number; + /** + * The minimum number of tokens to generate. Takes precedence over min_length. + */ + min_new_tokens?: number; + /** + * Number of groups to divide num_beams into in order to ensure diversity among different + * groups of beams. See [this paper](https://hf.co/papers/1610.02424) for more details. + */ + num_beam_groups?: number; + /** + * Number of beams to use for beam search. + */ + num_beams?: number; + /** + * The value balances the model confidence and the degeneration penalty in contrastive + * search decoding. + */ + penalty_alpha?: number; + /** + * The value used to modulate the next token probabilities. + */ + temperature?: number; + /** + * The number of highest probability vocabulary tokens to keep for top-k-filtering. + */ + top_k?: number; + /** + * If set to float < 1, only the smallest set of most probable tokens with probabilities + * that add up to top_p or higher are kept for generation. + */ + top_p?: number; + /** + * Local typicality measures how similar the conditional probability of predicting a target + * token next is to the expected conditional probability of predicting a random token next, + * given the partial text already generated. If set to float < 1, the smallest set of the + * most locally typical tokens with probabilities that add up to typical_p or higher are + * kept for generation. See [this paper](https://hf.co/papers/2202.00666) for more details. + */ + typical_p?: number; + /** + * Whether the model should use the past last key/values attentions to speed up decoding + */ + use_cache?: boolean; + [property: string]: unknown; +} +/** + * Controls the stopping condition for beam-based methods. + */ +export type EarlyStoppingUnion = boolean | "never"; diff --git a/node_modules/@huggingface/tasks/src/tasks/text-to-speech/spec/input.json b/node_modules/@huggingface/tasks/src/tasks/text-to-speech/spec/input.json new file mode 100644 index 0000000000000000000000000000000000000000..a643f2d7c7e659ff79e02f3c77334031b38a36d1 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/text-to-speech/spec/input.json @@ -0,0 +1,30 @@ +{ + "$id": "/inference/schemas/text-to-speech/input.json", + "$schema": "http://json-schema.org/draft-06/schema#", + "description": "Inputs for Text To Speech inference", + "title": "TextToSpeechInput", + "type": "object", + "properties": { + "inputs": { + "description": "The input text data", + "type": "string" + }, + "parameters": { + "description": "Additional inference parameters for Text To Speech", + "$ref": "#/$defs/TextToSpeechParameters" + } + }, + "$defs": { + "TextToSpeechParameters": { + "title": "TextToSpeechParameters", + "type": "object", + "properties": { + "generation_parameters": { + "description": "Parametrization of the text generation process", + "$ref": "/inference/schemas/common-definitions.json#/definitions/GenerationParameters" + } + } + } + }, + "required": ["inputs"] +} diff --git a/node_modules/@huggingface/tasks/src/tasks/text-to-speech/spec/output.json b/node_modules/@huggingface/tasks/src/tasks/text-to-speech/spec/output.json new file mode 100644 index 0000000000000000000000000000000000000000..4836ed246fa23f7f83b64f6522695f1adb399c83 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/text-to-speech/spec/output.json @@ -0,0 +1,18 @@ +{ + "$id": "/inference/schemas/text-to-speech/output.json", + "$schema": "http://json-schema.org/draft-06/schema#", + "description": "Outputs of inference for the Text To Speech task", + "title": "TextToSpeechOutput", + "type": "object", + "properties": { + "audio": { + "description": "The generated audio", + "comment": "type=binary" + }, + "sampling_rate": { + "type": "number", + "description": "The sampling rate of the generated audio waveform." + } + }, + "required": ["audio"] +} diff --git a/node_modules/@huggingface/tasks/src/tasks/text-to-video/about.md b/node_modules/@huggingface/tasks/src/tasks/text-to-video/about.md new file mode 100644 index 0000000000000000000000000000000000000000..898d638c264aa8219cdc3a71d1a4562de0d084b8 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/text-to-video/about.md @@ -0,0 +1,41 @@ +## Use Cases + +### Script-based Video Generation + +Text-to-video models can be used to create short-form video content from a provided text script. These models can be used to create engaging and informative marketing videos. For example, a company could use a text-to-video model to create a video that explains how their product works. + +### Content format conversion + +Text-to-video models can be used to generate videos from long-form text, including blog posts, articles, and text files. Text-to-video models can be used to create educational videos that are more engaging and interactive. An example of this is creating a video that explains a complex concept from an article. + +### Voice-overs and Speech + +Text-to-video models can be used to create an AI newscaster to deliver daily news, or for a film-maker to create a short film or a music video. + +## Task Variants +Text-to-video models have different variants based on inputs and outputs. + +### Text-to-video Editing + +One text-to-video task is generating text-based video style and local attribute editing. Text-to-video editing models can make it easier to perform tasks like cropping, stabilization, color correction, resizing and audio editing consistently. + +### Text-to-video Search + +Text-to-video search is the task of retrieving videos that are relevant to a given text query. This can be challenging, as videos are a complex medium that can contain a lot of information. By using semantic analysis to extract the meaning of the text query, visual analysis to extract features from the videos, such as the objects and actions that are present in the video, and temporal analysis to categorize relationships between the objects and actions in the video, we can determine which videos are most likely to be relevant to the text query. + +### Text-driven Video Prediction + +Text-driven video prediction is the task of generating a video sequence from a text description. Text description can be anything from a simple sentence to a detailed story. The goal of this task is to generate a video that is both visually realistic and semantically consistent with the text description. + +### Video Translation + +Text-to-video translation models can translate videos from one language to another or allow to query the multilingual text-video model with non-English sentences. This can be useful for people who want to watch videos in a language that they don't understand, especially when multi-lingual captions are available for training. + +## Inference +Contribute an inference snippet for text-to-video here! + +## Useful Resources + +In this area, you can insert useful resources about how to train or use a model for this task. + +- [Text-to-Video: The Task, Challenges and the Current State](https://huggingface.co/blog/text-to-video) diff --git a/node_modules/@huggingface/tasks/src/tasks/text-to-video/data.ts b/node_modules/@huggingface/tasks/src/tasks/text-to-video/data.ts new file mode 100644 index 0000000000000000000000000000000000000000..334146ba81e64ff378de65a09da14fddd0ae5fd4 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/text-to-video/data.ts @@ -0,0 +1,106 @@ +import type { TaskDataCustom } from "../index.js"; + +const taskData: TaskDataCustom = { + datasets: [ + { + description: "Microsoft Research Video to Text is a large-scale dataset for open domain video captioning", + id: "iejMac/CLIP-MSR-VTT", + }, + { + description: "UCF101 Human Actions dataset consists of 13,320 video clips from YouTube, with 101 classes.", + id: "quchenyuan/UCF101-ZIP", + }, + { + description: "A high-quality dataset for human action recognition in YouTube videos.", + id: "nateraw/kinetics", + }, + { + description: "A dataset of video clips of humans performing pre-defined basic actions with everyday objects.", + id: "HuggingFaceM4/something_something_v2", + }, + { + description: + "This dataset consists of text-video pairs and contains noisy samples with irrelevant video descriptions", + id: "HuggingFaceM4/webvid", + }, + { + description: "A dataset of short Flickr videos for the temporal localization of events with descriptions.", + id: "iejMac/CLIP-DiDeMo", + }, + ], + demo: { + inputs: [ + { + label: "Input", + content: "Darth Vader is surfing on the waves.", + type: "text", + }, + ], + outputs: [ + { + filename: "text-to-video-output.gif", + type: "img", + }, + ], + }, + metrics: [ + { + description: + "Inception Score uses an image classification model that predicts class labels and evaluates how distinct and diverse the images are. A higher score indicates better video generation.", + id: "is", + }, + { + description: + "Frechet Inception Distance uses an image classification model to obtain image embeddings. The metric compares mean and standard deviation of the embeddings of real and generated images. A smaller score indicates better video generation.", + id: "fid", + }, + { + description: + "Frechet Video Distance uses a model that captures coherence for changes in frames and the quality of each frame. A smaller score indicates better video generation.", + id: "fvd", + }, + { + description: + "CLIPSIM measures similarity between video frames and text using an image-text similarity model. A higher score indicates better video generation.", + id: "clipsim", + }, + ], + models: [ + { + description: "A strong model for consistent video generation.", + id: "tencent/HunyuanVideo", + }, + { + description: "A text-to-video model with high fidelity motion and strong prompt adherence.", + id: "Lightricks/LTX-Video", + }, + { + description: "A text-to-video model focusing on physics-aware applications like robotics.", + id: "nvidia/Cosmos-1.0-Diffusion-7B-Text2World", + }, + { + description: "Very fast model for video generation.", + id: "Lightricks/LTX-Video-0.9.8-13B-distilled", + }, + ], + spaces: [ + { + description: "An application that generates video from text.", + id: "VideoCrafter/VideoCrafter", + }, + { + description: "Consistent video generation application.", + id: "Wan-AI/Wan2.1", + }, + { + description: "A cutting edge video generation application.", + id: "Pyramid-Flow/pyramid-flow", + }, + ], + summary: + "Text-to-video models can be used in any application that requires generating consistent sequence of images from text. ", + widgetModels: ["Wan-AI/Wan2.2-TI2V-5B"], + youtubeId: undefined, +}; + +export default taskData; diff --git a/node_modules/@huggingface/tasks/src/tasks/text-to-video/inference.ts b/node_modules/@huggingface/tasks/src/tasks/text-to-video/inference.ts new file mode 100644 index 0000000000000000000000000000000000000000..0859ba524fb18b54bad8fc660190552f6a02cee0 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/text-to-video/inference.ts @@ -0,0 +1,57 @@ +/** + * Inference code generated from the JSON schema spec in ./spec + * + * Using src/scripts/inference-codegen + */ +/** + * Inputs for Text To Video inference + */ +export interface TextToVideoInput { + /** + * The input text data (sometimes called "prompt") + */ + inputs: string; + /** + * Additional inference parameters for Text To Video + */ + parameters?: TextToVideoParameters; + [property: string]: unknown; +} +/** + * Additional inference parameters for Text To Video + */ +export interface TextToVideoParameters { + /** + * A higher guidance scale value encourages the model to generate videos closely linked to + * the text prompt, but values too high may cause saturation and other artifacts. + */ + guidance_scale?: number; + /** + * One or several prompt to guide what NOT to include in video generation. + */ + negative_prompt?: string[]; + /** + * The num_frames parameter determines how many video frames are generated. + */ + num_frames?: number; + /** + * The number of denoising steps. More denoising steps usually lead to a higher quality + * video at the expense of slower inference. + */ + num_inference_steps?: number; + /** + * Seed for the random number generator. + */ + seed?: number; + [property: string]: unknown; +} +/** + * Outputs of inference for the Text To Video task + */ +export interface TextToVideoOutput { + /** + * The generated video returned as raw bytes in the payload. + */ + video: unknown; + [property: string]: unknown; +} diff --git a/node_modules/@huggingface/tasks/src/tasks/text-to-video/spec/input.json b/node_modules/@huggingface/tasks/src/tasks/text-to-video/spec/input.json new file mode 100644 index 0000000000000000000000000000000000000000..077c988b60715c97657f9db2674e85fac4ba0272 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/text-to-video/spec/input.json @@ -0,0 +1,49 @@ +{ + "$id": "/inference/schemas/text-to-video/input.json", + "$schema": "http://json-schema.org/draft-06/schema#", + "description": "Inputs for Text To Video inference", + "title": "TextToVideoInput", + "type": "object", + "properties": { + "inputs": { + "description": "The input text data (sometimes called \"prompt\")", + "type": "string" + }, + "parameters": { + "description": "Additional inference parameters for Text To Video", + "$ref": "#/$defs/TextToVideoParameters" + } + }, + "$defs": { + "TextToVideoParameters": { + "title": "TextToVideoParameters", + "type": "object", + "properties": { + "num_frames": { + "type": "number", + "description": "The num_frames parameter determines how many video frames are generated." + }, + "guidance_scale": { + "type": "number", + "description": "A higher guidance scale value encourages the model to generate videos closely linked to the text prompt, but values too high may cause saturation and other artifacts." + }, + "negative_prompt": { + "type": "array", + "items": { + "type": "string" + }, + "description": "One or several prompt to guide what NOT to include in video generation." + }, + "num_inference_steps": { + "type": "integer", + "description": "The number of denoising steps. More denoising steps usually lead to a higher quality video at the expense of slower inference." + }, + "seed": { + "type": "integer", + "description": "Seed for the random number generator." + } + } + } + }, + "required": ["inputs"] +} diff --git a/node_modules/@huggingface/tasks/src/tasks/text-to-video/spec/output.json b/node_modules/@huggingface/tasks/src/tasks/text-to-video/spec/output.json new file mode 100644 index 0000000000000000000000000000000000000000..1a2c006dbc60d8f9d1e0db0afd3ef01e78d9221a --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/text-to-video/spec/output.json @@ -0,0 +1,13 @@ +{ + "$id": "/inference/schemas/text-to-video/output.json", + "$schema": "http://json-schema.org/draft-06/schema#", + "description": "Outputs of inference for the Text To Video task", + "title": "TextToVideoOutput", + "type": "object", + "properties": { + "video": { + "description": "The generated video returned as raw bytes in the payload." + } + }, + "required": ["video"] +} diff --git a/node_modules/@huggingface/tasks/src/tasks/token-classification/about.md b/node_modules/@huggingface/tasks/src/tasks/token-classification/about.md new file mode 100644 index 0000000000000000000000000000000000000000..9b0701385b5793f32bdafd890c476a4efb99b509 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/token-classification/about.md @@ -0,0 +1,76 @@ +## Use Cases + +### Information Extraction from Invoices + +You can extract entities of interest from invoices automatically using Named Entity Recognition (NER) models. Invoices can be read with Optical Character Recognition models and the output can be used to do inference with NER models. In this way, important information such as date, company name, and other named entities can be extracted. + +## Task Variants + +### Named Entity Recognition (NER) + +NER is the task of recognizing named entities in a text. These entities can be the names of people, locations, or organizations. The task is formulated as labeling each token with a class for each named entity and a class named "0" for tokens that do not contain any entities. The input for this task is text and the output is the annotated text with named entities. + +#### Inference + +You can use the 🤗 Transformers library `ner` pipeline to infer with NER models. + +```python +from transformers import pipeline + +classifier = pipeline("ner") +classifier("Hello I'm Omar and I live in Zürich.") +``` + +### Part-of-Speech (PoS) Tagging +In PoS tagging, the model recognizes parts of speech, such as nouns, pronouns, adjectives, or verbs, in a given text. The task is formulated as labeling each word with a part of the speech. + +#### Inference + +You can use the 🤗 Transformers library `token-classification` pipeline with a POS tagging model of your choice. The model will return a json with PoS tags for each token. + +```python +from transformers import pipeline + +classifier = pipeline("token-classification", model = "vblagoje/bert-english-uncased-finetuned-pos") +classifier("Hello I'm Omar and I live in Zürich.") +``` + +This is not limited to transformers! You can also use other libraries such as Stanza, spaCy, and Flair to do inference! Here is an example using a canonical [spaCy](https://hf.co/blog/spacy) model. + +```python +!pip install https://huggingface.co/spacy/en_core_web_sm/resolve/main/en_core_web_sm-any-py3-none-any.whl + +import en_core_web_sm + +nlp = en_core_web_sm.load() +doc = nlp("I'm Omar and I live in Zürich.") +for token in doc: + print(token.text, token.pos_, token.dep_, token.ent_type_) + +## I PRON nsubj +## 'm AUX ROOT +## Omar PROPN attr PERSON +### ... +``` + +## Useful Resources + +Would you like to learn more about token classification? Great! Here you can find some curated resources that you may find helpful! + +- [Course Chapter on Token Classification](https://huggingface.co/course/chapter7/2?fw=pt) +- [Blog post: Welcome spaCy to the Hugging Face Hub](https://huggingface.co/blog/spacy) + +### Notebooks + +- [PyTorch](https://github.com/huggingface/notebooks/blob/master/examples/token_classification.ipynb) +- [TensorFlow](https://github.com/huggingface/notebooks/blob/master/examples/token_classification-tf.ipynb) + +### Scripts for training + +- [PyTorch](https://github.com/huggingface/transformers/tree/main/examples/pytorch/token-classification) +- [TensorFlow](https://github.com/huggingface/transformers/tree/main/examples/tensorflow) +- [Flax](https://github.com/huggingface/transformers/tree/main/examples/flax/token-classification) + +### Documentation + +- [Token classification task guide](https://huggingface.co/docs/transformers/tasks/token_classification) diff --git a/node_modules/@huggingface/tasks/src/tasks/token-classification/data.ts b/node_modules/@huggingface/tasks/src/tasks/token-classification/data.ts new file mode 100644 index 0000000000000000000000000000000000000000..2ecce1bcc9e5537f092066ad9488fbd525fe1286 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/token-classification/data.ts @@ -0,0 +1,92 @@ +import type { TaskDataCustom } from "../index.js"; + +const taskData: TaskDataCustom = { + datasets: [ + { + description: "A widely used dataset useful to benchmark named entity recognition models.", + id: "eriktks/conll2003", + }, + { + description: + "A multilingual dataset of Wikipedia articles annotated for named entity recognition in over 150 different languages.", + id: "unimelb-nlp/wikiann", + }, + ], + demo: { + inputs: [ + { + label: "Input", + content: "My name is Omar and I live in Zürich.", + type: "text", + }, + ], + outputs: [ + { + text: "My name is Omar and I live in Zürich.", + tokens: [ + { + type: "PERSON", + start: 11, + end: 15, + }, + { + type: "GPE", + start: 30, + end: 36, + }, + ], + type: "text-with-tokens", + }, + ], + }, + metrics: [ + { + description: "", + id: "accuracy", + }, + { + description: "", + id: "recall", + }, + { + description: "", + id: "precision", + }, + { + description: "", + id: "f1", + }, + ], + models: [ + { + description: + "A robust performance model to identify people, locations, organizations and names of miscellaneous entities.", + id: "dslim/bert-base-NER", + }, + { + description: "A strong model to identify people, locations, organizations and names in multiple languages.", + id: "FacebookAI/xlm-roberta-large-finetuned-conll03-english", + }, + { + description: "A token classification model specialized on medical entity recognition.", + id: "blaze999/Medical-NER", + }, + { + description: "Flair models are typically the state of the art in named entity recognition tasks.", + id: "flair/ner-english", + }, + ], + spaces: [ + { + description: + "An application that can recognizes entities, extracts noun chunks and recognizes various linguistic features of each token.", + id: "spacy/gradio_pipeline_visualizer", + }, + ], + summary: + "Token classification is a natural language understanding task in which a label is assigned to some tokens in a text. Some popular token classification subtasks are Named Entity Recognition (NER) and Part-of-Speech (PoS) tagging. NER models could be trained to identify specific entities in a text, such as dates, individuals and places; and PoS tagging would identify, for example, which words in a text are verbs, nouns, and punctuation marks.", + widgetModels: ["FacebookAI/xlm-roberta-large-finetuned-conll03-english"], + youtubeId: "wVHdVlPScxA", +}; + +export default taskData; diff --git a/node_modules/@huggingface/tasks/src/tasks/token-classification/inference.ts b/node_modules/@huggingface/tasks/src/tasks/token-classification/inference.ts new file mode 100644 index 0000000000000000000000000000000000000000..09f899c6b039a8f78f313c02e25b55a791e7e3c6 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/token-classification/inference.ts @@ -0,0 +1,83 @@ +/** + * Inference code generated from the JSON schema spec in ./spec + * + * Using src/scripts/inference-codegen + */ +/** + * Inputs for Token Classification inference + */ +export interface TokenClassificationInput { + /** + * The input text data + */ + inputs: string; + /** + * Additional inference parameters for Token Classification + */ + parameters?: TokenClassificationParameters; + [property: string]: unknown; +} +/** + * Additional inference parameters for Token Classification + */ +export interface TokenClassificationParameters { + /** + * The strategy used to fuse tokens based on model predictions + */ + aggregation_strategy?: TokenClassificationAggregationStrategy; + /** + * A list of labels to ignore + */ + ignore_labels?: string[]; + /** + * The number of overlapping tokens between chunks when splitting the input text. + */ + stride?: number; + [property: string]: unknown; +} +/** + * Do not aggregate tokens + * + * Group consecutive tokens with the same label in a single entity. + * + * Similar to "simple", also preserves word integrity (use the label predicted for the first + * token in a word). + * + * Similar to "simple", also preserves word integrity (uses the label with the highest + * score, averaged across the word's tokens). + * + * Similar to "simple", also preserves word integrity (uses the label with the highest score + * across the word's tokens). + */ +export type TokenClassificationAggregationStrategy = "none" | "simple" | "first" | "average" | "max"; +export type TokenClassificationOutput = TokenClassificationOutputElement[]; +/** + * Outputs of inference for the Token Classification task + */ +export interface TokenClassificationOutputElement { + /** + * The character position in the input where this group ends. + */ + end: number; + /** + * The predicted label for a single token + */ + entity?: string; + /** + * The predicted label for a group of one or more tokens + */ + entity_group?: string; + /** + * The associated score / probability + */ + score: number; + /** + * The character position in the input where this group begins. + */ + start: number; + /** + * The corresponding text + */ + word: string; + [property: string]: unknown; +} diff --git a/node_modules/@huggingface/tasks/src/tasks/token-classification/spec/input.json b/node_modules/@huggingface/tasks/src/tasks/token-classification/spec/input.json new file mode 100644 index 0000000000000000000000000000000000000000..1176f3dd9a4a903dd41737bbd6dc088483285407 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/token-classification/spec/input.json @@ -0,0 +1,64 @@ +{ + "$id": "/inference/schemas/token-classification/input.json", + "$schema": "http://json-schema.org/draft-06/schema#", + "description": "Inputs for Token Classification inference", + "title": "TokenClassificationInput", + "type": "object", + "properties": { + "inputs": { + "description": "The input text data", + "type": "string" + }, + "parameters": { + "description": "Additional inference parameters for Token Classification", + "$ref": "#/$defs/TokenClassificationParameters" + } + }, + "$defs": { + "TokenClassificationParameters": { + "title": "TokenClassificationParameters", + "type": "object", + "properties": { + "ignore_labels": { + "type": "array", + "items": { + "type": "string" + }, + "description": "A list of labels to ignore" + }, + "stride": { + "type": "integer", + "description": "The number of overlapping tokens between chunks when splitting the input text." + }, + "aggregation_strategy": { + "title": "TokenClassificationAggregationStrategy", + "type": "string", + "description": "The strategy used to fuse tokens based on model predictions", + "oneOf": [ + { + "const": "none", + "description": "Do not aggregate tokens" + }, + { + "const": "simple", + "description": "Group consecutive tokens with the same label in a single entity." + }, + { + "const": "first", + "description": "Similar to \"simple\", also preserves word integrity (use the label predicted for the first token in a word)." + }, + { + "const": "average", + "description": "Similar to \"simple\", also preserves word integrity (uses the label with the highest score, averaged across the word's tokens)." + }, + { + "const": "max", + "description": "Similar to \"simple\", also preserves word integrity (uses the label with the highest score across the word's tokens)." + } + ] + } + } + } + }, + "required": ["inputs"] +} diff --git a/node_modules/@huggingface/tasks/src/tasks/token-classification/spec/output.json b/node_modules/@huggingface/tasks/src/tasks/token-classification/spec/output.json new file mode 100644 index 0000000000000000000000000000000000000000..649a871b7b42b527b6a7f1c28fe86f5bfc085b25 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/token-classification/spec/output.json @@ -0,0 +1,37 @@ +{ + "$id": "/inference/schemas/token-classification/output.json", + "$schema": "http://json-schema.org/draft-06/schema#", + "description": "Outputs of inference for the Token Classification task", + "title": "TokenClassificationOutput", + "type": "array", + "items": { + "type": "object", + "properties": { + "entity_group": { + "type": "string", + "description": "The predicted label for a group of one or more tokens" + }, + "entity": { + "type": "string", + "description": "The predicted label for a single token" + }, + "score": { + "type": "number", + "description": "The associated score / probability" + }, + "word": { + "type": "string", + "description": "The corresponding text" + }, + "start": { + "type": "integer", + "description": "The character position in the input where this group begins." + }, + "end": { + "type": "integer", + "description": "The character position in the input where this group ends." + } + }, + "required": ["score", "word", "start", "end"] + } +} diff --git a/node_modules/@huggingface/tasks/src/tasks/translation/about.md b/node_modules/@huggingface/tasks/src/tasks/translation/about.md new file mode 100644 index 0000000000000000000000000000000000000000..f4806687a5cbebba9dce19f0053b33bd349e3a82 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/translation/about.md @@ -0,0 +1,65 @@ +## Use Cases + +You can find over a thousand Translation models on the Hub, but sometimes you might not find a model for the language pair you are interested in. When this happen, you can use a pretrained multilingual Translation model like [mBART](https://huggingface.co/facebook/mbart-large-cc25) and further train it on your own data in a process called fine-tuning. + +### Multilingual conversational agents + +Translation models can be used to build conversational agents across different languages. This can be done in two ways. + +- **Translate the dataset to a new language.** You can translate a dataset of intents (inputs) and responses to the target language. You can then train a new intent classification model with this new dataset. This allows you to proofread responses in the target language and have better control of the chatbot's outputs. + +* **Translate the input and output of the agent.** You can use a Translation model in user inputs so that the chatbot can process it. You can then translate the output of the chatbot into the language of the user. This approach might be less reliable as the chatbot will generate responses that were not defined before. + +## Inference + +You can use the 🤗 Transformers library with the `translation_xx_to_yy` pattern where xx is the source language code and yy is the target language code. The default model for the pipeline is [t5-base](https://huggingface.co/t5-base) which under the hood adds a task prefix indicating the task itself, e.g. “translate: English to French”. + +```python +from transformers import pipeline +en_fr_translator = pipeline("translation_en_to_fr") +en_fr_translator("How old are you?") +## [{'translation_text': ' quel âge êtes-vous?'}] +``` + +If you’d like to use a specific model checkpoint that is from one specific language to another, you can also directly use the `translation` pipeline. + +```python +from transformers import pipeline + +model_checkpoint = "Helsinki-NLP/opus-mt-en-fr" +translator = pipeline("translation", model=model_checkpoint) +translator("How are you?") +# [{'translation_text': 'Comment allez-vous ?'}] +``` + +You can use [huggingface.js](https://github.com/huggingface/huggingface.js) to infer translation models on Hugging Face Hub. + +```javascript +import { InferenceClient } from "@huggingface/inference"; + +const inference = new InferenceClient(HF_TOKEN); +await inference.translation({ + model: "t5-base", + inputs: "My name is Wolfgang and I live in Berlin", +}); +``` + +## Useful Resources + +Would you like to learn more about Translation? Great! Here you can find some curated resources that you may find helpful! + +- [Course Chapter on Translation](https://huggingface.co/course/chapter7/4?fw=pt) + +### Notebooks + +- [PyTorch](https://github.com/huggingface/notebooks/blob/master/examples/translation.ipynb) +- [TensorFlow](https://github.com/huggingface/notebooks/blob/master/examples/translation-tf.ipynb) + +### Scripts for training + +- [PyTorch](https://github.com/huggingface/transformers/tree/main/examples/pytorch/translation) +- [TensorFlow](https://github.com/huggingface/transformers/tree/main/examples/tensorflow/translation) + +### Documentation + +- [Translation task guide](https://huggingface.co/docs/transformers/tasks/translation) diff --git a/node_modules/@huggingface/tasks/src/tasks/translation/data.ts b/node_modules/@huggingface/tasks/src/tasks/translation/data.ts new file mode 100644 index 0000000000000000000000000000000000000000..1f7cb112c2a694464765858cd92bdc89280a0451 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/translation/data.ts @@ -0,0 +1,70 @@ +import type { TaskDataCustom } from "../index.js"; + +const taskData: TaskDataCustom = { + canonicalId: "text-generation", + datasets: [ + { + description: "A dataset of copyright-free books translated into 16 different languages.", + id: "Helsinki-NLP/opus_books", + }, + { + description: + "An example of translation between programming languages. This dataset consists of functions in Java and C#.", + id: "google/code_x_glue_cc_code_to_code_trans", + }, + ], + demo: { + inputs: [ + { + label: "Input", + content: "My name is Omar and I live in Zürich.", + type: "text", + }, + ], + outputs: [ + { + label: "Output", + content: "Mein Name ist Omar und ich wohne in Zürich.", + type: "text", + }, + ], + }, + metrics: [ + { + description: + "BLEU score is calculated by counting the number of shared single or subsequent tokens between the generated sequence and the reference. Subsequent n tokens are called “n-grams”. Unigram refers to a single token while bi-gram refers to token pairs and n-grams refer to n subsequent tokens. The score ranges from 0 to 1, where 1 means the translation perfectly matched and 0 did not match at all", + id: "bleu", + }, + { + description: "", + id: "sacrebleu", + }, + ], + models: [ + { + description: + "Very powerful model that can translate many languages between each other, especially low-resource languages.", + id: "facebook/nllb-200-1.3B", + }, + { + description: + "A general-purpose Transformer that can be used to translate from English to German, French, or Romanian.", + id: "google-t5/t5-base", + }, + ], + spaces: [ + { + description: "An application that can translate between 100 languages.", + id: "Iker/Translate-100-languages", + }, + { + description: "An application that can translate between many languages.", + id: "Geonmo/nllb-translation-demo", + }, + ], + summary: "Translation is the task of converting text from one language to another.", + widgetModels: ["facebook/mbart-large-50-many-to-many-mmt"], + youtubeId: "1JvfrvZgi6c", +}; + +export default taskData; diff --git a/node_modules/@huggingface/tasks/src/tasks/translation/inference.ts b/node_modules/@huggingface/tasks/src/tasks/translation/inference.ts new file mode 100644 index 0000000000000000000000000000000000000000..caa875033056ebed2ecbfeb6382e28d5bb8211f4 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/translation/inference.ts @@ -0,0 +1,63 @@ +/** + * Inference code generated from the JSON schema spec in ./spec + * + * Using src/scripts/inference-codegen + */ +/** + * Inputs for Translation inference + */ +export interface TranslationInput { + /** + * The text to translate. + */ + inputs: string; + /** + * Additional inference parameters for Translation + */ + parameters?: TranslationParameters; + [property: string]: unknown; +} +/** + * Additional inference parameters for Translation + */ +export interface TranslationParameters { + /** + * Whether to clean up the potential extra spaces in the text output. + */ + clean_up_tokenization_spaces?: boolean; + /** + * Additional parametrization of the text generation algorithm. + */ + generate_parameters?: { + [key: string]: unknown; + }; + /** + * The source language of the text. Required for models that can translate from multiple + * languages. + */ + src_lang?: string; + /** + * Target language to translate to. Required for models that can translate to multiple + * languages. + */ + tgt_lang?: string; + /** + * The truncation strategy to use. + */ + truncation?: TranslationTruncationStrategy; + [property: string]: unknown; +} +/** + * The truncation strategy to use. + */ +export type TranslationTruncationStrategy = "do_not_truncate" | "longest_first" | "only_first" | "only_second"; +/** + * Outputs of inference for the Translation task + */ +export interface TranslationOutput { + /** + * The translated text. + */ + translation_text: string; + [property: string]: unknown; +} diff --git a/node_modules/@huggingface/tasks/src/tasks/translation/spec/input.json b/node_modules/@huggingface/tasks/src/tasks/translation/spec/input.json new file mode 100644 index 0000000000000000000000000000000000000000..8f0a6fc6f936d37f129dfb7998e6abd9671930e0 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/translation/spec/input.json @@ -0,0 +1,49 @@ +{ + "$id": "/inference/schemas/translation/input.json", + "$schema": "http://json-schema.org/draft-06/schema#", + "description": "Inputs for Translation inference", + "title": "TranslationInput", + "type": "object", + "properties": { + "inputs": { + "description": "The text to translate.", + "type": "string" + }, + "parameters": { + "description": "Additional inference parameters for Translation", + "$ref": "#/$defs/TranslationParameters" + } + }, + "$defs": { + "TranslationParameters": { + "title": "TranslationParameters", + "type": "object", + "properties": { + "src_lang": { + "type": "string", + "description": "The source language of the text. Required for models that can translate from multiple languages." + }, + "tgt_lang": { + "type": "string", + "description": "Target language to translate to. Required for models that can translate to multiple languages." + }, + "clean_up_tokenization_spaces": { + "type": "boolean", + "description": "Whether to clean up the potential extra spaces in the text output." + }, + "truncation": { + "title": "TranslationTruncationStrategy", + "type": "string", + "description": "The truncation strategy to use.", + "enum": ["do_not_truncate", "longest_first", "only_first", "only_second"] + }, + "generate_parameters": { + "title": "generateParameters", + "type": "object", + "description": "Additional parametrization of the text generation algorithm." + } + } + } + }, + "required": ["inputs"] +} diff --git a/node_modules/@huggingface/tasks/src/tasks/translation/spec/output.json b/node_modules/@huggingface/tasks/src/tasks/translation/spec/output.json new file mode 100644 index 0000000000000000000000000000000000000000..976c3641eb32a07865d2efc921242ade895da3c0 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/translation/spec/output.json @@ -0,0 +1,14 @@ +{ + "$id": "/inference/schemas/translation/output.json", + "$schema": "http://json-schema.org/draft-06/schema#", + "description": "Outputs of inference for the Translation task", + "title": "TranslationOutput", + "type": "object", + "properties": { + "translation_text": { + "type": "string", + "description": "The translated text." + } + }, + "required": ["translation_text"] +} diff --git a/node_modules/@huggingface/tasks/src/tasks/unconditional-image-generation/about.md b/node_modules/@huggingface/tasks/src/tasks/unconditional-image-generation/about.md new file mode 100644 index 0000000000000000000000000000000000000000..e5a9585528ae0afd0bc779d0d8628ceca167376e --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/unconditional-image-generation/about.md @@ -0,0 +1,50 @@ +## About the Task + +Unconditional image generation is the task of generating new images without any specific input. The main goal of this is to create novel, original images that are not based on existing images. +This can be used for a variety of applications, such as creating new artistic images, improving image recognition algorithms, or generating photorealistic images for virtual reality environments. + +Unconditional image generation models usually start with a _seed_ that generates a _random noise vector_. The model will then use this vector to create an output image similar to the images used for training the model. + +An example of unconditional image generation would be generating the image of a face on a model trained with the [CelebA dataset](https://huggingface.co/datasets/huggan/CelebA-HQ) or [generating a butterfly](https://huggingface.co/spaces/huggan/butterfly-gan) on a model trained with the [Smithsonian Butterflies dataset](https://huggingface.co/datasets/ceyda/smithsonian_butterflies). + +[Generative adversarial networks](https://en.wikipedia.org/wiki/Generative_adversarial_network) and [Diffusion](https://huggingface.co/docs/diffusers/index) are common architectures for this task. + +## Use Cases + +Unconditional image generation can be used for a variety of applications. + +### Artistic Expression + +Unconditional image generation can be used to create novel, original artwork that is not based on any existing images. This can be used to explore new creative possibilities and produce unique, imaginative images. + +### Data Augmentation + +Unconditional image generation models can be used to generate new images to improve the performance of image recognition algorithms. This makes algorithms more robust and able to handle a broader range of images. + +### Virtual Reality + +Unconditional image generation models can be used to create photorealistic images that can be used in virtual reality environments. This makes the VR experience more immersive and realistic. + +### Medical Imaging + +Unconditional image generation models can generate new medical images, such as CT or MRI scans, that can be used to train and evaluate medical imaging algorithms. This can improve the accuracy and reliability of these algorithms. + +### Industrial Design + +Unconditional image generation models can generate new designs for products, such as clothing or furniture, that are not based on any existing designs. This way, designers can explore new creative possibilities and produce unique, innovative designs. + +## Model Hosting and Inference + +This section should have useful information about Model Hosting and Inference + +## Useful Resources + +- [Hugging Face Diffusion Models Course](https://github.com/huggingface/diffusion-models-class) +- [Getting Started with Diffusers](https://huggingface.co/docs/diffusers/index) +- [Unconditional Image Generation Training](https://huggingface.co/docs/diffusers/training/unconditional_training) + +### Training your own model in just a few seconds + +In this area, you can insert useful information about training the model + +This page was made possible thanks to the efforts of [Someet Sahoo](https://huggingface.co/Someet24) and [Juan Carlos Piñeros](https://huggingface.co/juancopi81). diff --git a/node_modules/@huggingface/tasks/src/tasks/unconditional-image-generation/data.ts b/node_modules/@huggingface/tasks/src/tasks/unconditional-image-generation/data.ts new file mode 100644 index 0000000000000000000000000000000000000000..fcd66648eff68ecd77ab1c1a93528c7f305dab1b --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/unconditional-image-generation/data.ts @@ -0,0 +1,72 @@ +import type { TaskDataCustom } from "../index.js"; + +const taskData: TaskDataCustom = { + datasets: [ + { + description: + "The CIFAR-100 dataset consists of 60000 32x32 colour images in 100 classes, with 600 images per class.", + id: "cifar100", + }, + { + description: "Multiple images of celebrities, used for facial expression translation.", + id: "CelebA", + }, + ], + demo: { + inputs: [ + { + label: "Seed", + content: "42", + type: "text", + }, + { + label: "Number of images to generate:", + content: "4", + type: "text", + }, + ], + outputs: [ + { + filename: "unconditional-image-generation-output.jpeg", + type: "img", + }, + ], + }, + metrics: [ + { + description: + "The inception score (IS) evaluates the quality of generated images. It measures the diversity of the generated images (the model predictions are evenly distributed across all possible labels) and their 'distinction' or 'sharpness' (the model confidently predicts a single label for each image).", + id: "Inception score (IS)", + }, + { + description: + "The Fréchet Inception Distance (FID) evaluates the quality of images created by a generative model by calculating the distance between feature vectors for real and generated images.", + id: "Frećhet Inception Distance (FID)", + }, + ], + models: [ + { + description: + "High-quality image generation model trained on the CIFAR-10 dataset. It synthesizes images of the ten classes presented in the dataset using diffusion probabilistic models, a class of latent variable models inspired by considerations from nonequilibrium thermodynamics.", + id: "google/ddpm-cifar10-32", + }, + { + description: + "High-quality image generation model trained on the 256x256 CelebA-HQ dataset. It synthesizes images of faces using diffusion probabilistic models, a class of latent variable models inspired by considerations from nonequilibrium thermodynamics.", + id: "google/ddpm-celebahq-256", + }, + ], + spaces: [ + { + description: "An application that can generate realistic faces.", + id: "CompVis/celeba-latent-diffusion", + }, + ], + summary: + "Unconditional image generation is the task of generating images with no condition in any context (like a prompt text or another image). Once trained, the model will create images that resemble its training data distribution.", + widgetModels: [""], + // TODO: Add related video + youtubeId: "", +}; + +export default taskData; diff --git a/node_modules/@huggingface/tasks/src/tasks/video-classification/about.md b/node_modules/@huggingface/tasks/src/tasks/video-classification/about.md new file mode 100644 index 0000000000000000000000000000000000000000..0436a873d3989f5c54fbff555fbfc573d3bd43b9 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/video-classification/about.md @@ -0,0 +1,37 @@ +## Use Cases + +Video classification models can be used to categorize what a video is all about. + +### Activity Recognition + +Video classification models are used to perform activity recognition which is useful for fitness applications. Activity recognition is also helpful for vision-impaired individuals especially when they're commuting. + +### Video Search + +Models trained in video classification can improve user experience by organizing and categorizing video galleries on the phone or in the cloud, on multiple keywords or tags. + +## Inference + +Below you can find code for inferring with a pre-trained video classification model. + +```python +from transformers import pipeline + +pipe = pipeline(task = "video-classification", model="nateraw/videomae-base-finetuned-ucf101-subset") +pipe("https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/transformers/basketball.avi?download=true") + +#[{'score': 0.90, 'label': 'BasketballDunk'}, +# {'score': 0.02, 'label': 'BalanceBeam'}, +# ... ] +``` + +## Useful Resources + +- [Developing a simple video classification model](https://keras.io/examples/vision/video_classification) +- [Video classification with Transformers](https://keras.io/examples/vision/video_transformers) +- [Building a video archive](https://www.youtube.com/watch?v=_IeS1m8r6SY) +- [Video classification task guide](https://huggingface.co/docs/transformers/tasks/video_classification) + +### Creating your own video classifier in minutes + +- [Fine-tuning tutorial notebook (PyTorch)](https://colab.research.google.com/github/huggingface/notebooks/blob/main/examples/video_classification.ipynb) diff --git a/node_modules/@huggingface/tasks/src/tasks/video-classification/data.ts b/node_modules/@huggingface/tasks/src/tasks/video-classification/data.ts new file mode 100644 index 0000000000000000000000000000000000000000..1e5abbce9cb324cd1f1a573e7b8a5a4184fd93ff --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/video-classification/data.ts @@ -0,0 +1,84 @@ +import type { TaskDataCustom } from "../index.js"; + +const taskData: TaskDataCustom = { + datasets: [ + { + // TODO write proper description + description: "Benchmark dataset used for video classification with videos that belong to 400 classes.", + id: "kinetics400", + }, + ], + demo: { + inputs: [ + { + filename: "video-classification-input.gif", + type: "img", + }, + ], + outputs: [ + { + type: "chart", + data: [ + { + label: "Playing Guitar", + score: 0.514, + }, + { + label: "Playing Tennis", + score: 0.193, + }, + { + label: "Cooking", + score: 0.068, + }, + ], + }, + ], + }, + metrics: [ + { + description: "", + id: "accuracy", + }, + { + description: "", + id: "recall", + }, + { + description: "", + id: "precision", + }, + { + description: "", + id: "f1", + }, + ], + models: [ + { + // TO DO: write description + description: "Strong Video Classification model trained on the Kinetics 400 dataset.", + id: "google/vivit-b-16x2-kinetics400", + }, + { + // TO DO: write description + description: "Strong Video Classification model trained on the Kinetics 400 dataset.", + id: "microsoft/xclip-base-patch32", + }, + ], + spaces: [ + { + description: "An application that classifies video at different timestamps.", + id: "nateraw/lavila", + }, + { + description: "An application that classifies video.", + id: "fcakyon/video-classification", + }, + ], + summary: + "Video classification is the task of assigning a label or class to an entire video. Videos are expected to have only one class for each video. Video classification models take a video as input and return a prediction about which class the video belongs to.", + widgetModels: [], + youtubeId: "", +}; + +export default taskData; diff --git a/node_modules/@huggingface/tasks/src/tasks/video-classification/inference.ts b/node_modules/@huggingface/tasks/src/tasks/video-classification/inference.ts new file mode 100644 index 0000000000000000000000000000000000000000..5c937d9c180d5022695b1f3eb00568bb45b417e9 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/video-classification/inference.ts @@ -0,0 +1,60 @@ +/** + * Inference code generated from the JSON schema spec in ./spec + * + * Using src/scripts/inference-codegen + */ +/** + * Inputs for Video Classification inference + */ +export interface VideoClassificationInput { + /** + * The input video data + */ + inputs: unknown; + /** + * Additional inference parameters for Video Classification + */ + parameters?: VideoClassificationParameters; + [property: string]: unknown; +} +/** + * Additional inference parameters for Video Classification + */ +export interface VideoClassificationParameters { + /** + * The sampling rate used to select frames from the video. + */ + frame_sampling_rate?: number; + /** + * The function to apply to the model outputs in order to retrieve the scores. + */ + function_to_apply?: ClassificationOutputTransform; + /** + * The number of sampled frames to consider for classification. + */ + num_frames?: number; + /** + * When specified, limits the output to the top K most probable classes. + */ + top_k?: number; + [property: string]: unknown; +} +/** + * The function to apply to the model outputs in order to retrieve the scores. + */ +export type ClassificationOutputTransform = "sigmoid" | "softmax" | "none"; +export type VideoClassificationOutput = VideoClassificationOutputElement[]; +/** + * Outputs of inference for the Video Classification task + */ +export interface VideoClassificationOutputElement { + /** + * The predicted class label. + */ + label: string; + /** + * The corresponding probability. + */ + score: number; + [property: string]: unknown; +} diff --git a/node_modules/@huggingface/tasks/src/tasks/video-classification/spec/input.json b/node_modules/@huggingface/tasks/src/tasks/video-classification/spec/input.json new file mode 100644 index 0000000000000000000000000000000000000000..277950e59d0834c788935ba0e5ab1b4dbc6a2525 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/video-classification/spec/input.json @@ -0,0 +1,42 @@ +{ + "$id": "/inference/schemas/video-classification/input.json", + "$schema": "http://json-schema.org/draft-06/schema#", + "description": "Inputs for Video Classification inference", + "title": "VideoClassificationInput", + "type": "object", + "properties": { + "inputs": { + "description": "The input video data" + }, + "parameters": { + "description": "Additional inference parameters for Video Classification", + "$ref": "#/$defs/VideoClassificationParameters" + } + }, + "$defs": { + "VideoClassificationParameters": { + "title": "VideoClassificationParameters", + "type": "object", + "properties": { + "function_to_apply": { + "title": "TextClassificationOutputTransform", + "$ref": "/inference/schemas/common-definitions.json#/definitions/ClassificationOutputTransform", + "description": "The function to apply to the model outputs in order to retrieve the scores." + }, + "num_frames": { + "type": "integer", + "description": "The number of sampled frames to consider for classification." + }, + "frame_sampling_rate": { + "type": "integer", + "description": "The sampling rate used to select frames from the video." + }, + "top_k": { + "type": "integer", + "description": "When specified, limits the output to the top K most probable classes." + } + } + } + }, + "required": ["inputs"] +} diff --git a/node_modules/@huggingface/tasks/src/tasks/video-classification/spec/output.json b/node_modules/@huggingface/tasks/src/tasks/video-classification/spec/output.json new file mode 100644 index 0000000000000000000000000000000000000000..4c24f5d577717994e0b4a8e329a7e063a967cb10 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/video-classification/spec/output.json @@ -0,0 +1,10 @@ +{ + "$id": "/inference/schemas/video-classification/output.json", + "$schema": "http://json-schema.org/draft-06/schema#", + "description": "Outputs of inference for the Video Classification task", + "title": "VideoClassificationOutput", + "type": "array", + "items": { + "$ref": "/inference/schemas/common-definitions.json#/definitions/ClassificationOutput" + } +} diff --git a/node_modules/@huggingface/tasks/src/tasks/video-text-to-text/about.md b/node_modules/@huggingface/tasks/src/tasks/video-text-to-text/about.md new file mode 100644 index 0000000000000000000000000000000000000000..2d9af88d36a9e15b64e11623e25ecb2f3b20649f --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/video-text-to-text/about.md @@ -0,0 +1,98 @@ +Most of the video language models can take in videos, multiple videos, images and multiple images. Some of these models can also take interleaved inputs, which can have images and videos inside the text, where you can refer to the input images and input videos within the text prompt. + +## Different Types of Video Language Models + +Video language models come in three types: + +- **Base:** Pre-trained models that can be fine-tuned. +- **Instruction:** Base models fine-tuned on video-instruction pairs and answers. +- **Chatty/Conversational:** Base models fine-tuned on video conversation datasets. + +## Use Cases + +### Video Question Answering + +Video language models trained on video-question-answer pairs can be used for video question answering and generating captions for videos. + +### Video Chat + +Video language models can be used to have a dialogue about a video. + +### Video Recognition with Instructions + +Video language models can recognize images through descriptions. When given detailed descriptions of specific entities, they can classify the entities in a video. + +## Inference + +You can use the Transformers library to interact with video-language models. +Below we load [a video language model](https://huggingface.co/llava-hf/LLaVA-NeXT-Video-7B-hf), write a simple utility to sample videos, use chat template to format the text prompt, process the video and the text prompt and infer. To run the snippet below, please install [OpenCV](https://pypi.org/project/opencv-python/) by running `pip install opencv-python`. + +```python +import uuid +import requests +import cv2 +import torch +from transformers import LlavaNextVideoProcessor, LlavaNextVideoForConditionalGeneration + +device = "cuda" if torch.cuda.is_available() else "cpu" +model_id = "llava-hf/LLaVA-NeXT-Video-7B-hf" + +model = LlavaNextVideoForConditionalGeneration.from_pretrained( + model_id, + torch_dtype=torch.float16, + low_cpu_mem_usage=True, +).to(device) + +processor = LlavaNextVideoProcessor.from_pretrained(model_id) + +def sample_frames(url, num_frames): + response = requests.get(url) + path_id = str(uuid.uuid4()) + + path = f"./{path_id}.mp4" + + with open(path, "wb") as f: + f.write(response.content) + + video = cv2.VideoCapture(path) + total_frames = int(video.get(cv2.CAP_PROP_FRAME_COUNT)) + interval = total_frames // num_frames + frames = [] + for i in range(total_frames): + ret, frame = video.read() + if not ret: + continue + if i % interval == 0: + pil_img = Image.fromarray(cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)) + frames.append(pil_img) + video.release() + return frames + +conversation = [ + { + + "role": "user", + "content": [ + {"type": "text", "text": "Why is this video funny?"}, + {"type": "video"}, + ], + }, +] + +prompt = processor.apply_chat_template(conversation, add_generation_prompt=True) + +video_url = "https://huggingface.co/spaces/merve/llava-interleave/resolve/main/cats_1.mp4" +video = sample_frames(video, 8) + +inputs = processor(text=prompt, videos=video, padding=True, return_tensors="pt").to(model.device) + +output = model.generate(**inputs, max_new_tokens=100, do_sample=False) +print(processor.decode(output[0][2:], skip_special_tokens=True)) + +# Why is this video funny? ASSISTANT: The humor in this video comes from the cat's facial expression and body language. The cat appears to be making a funny face, with its eyes squinted and mouth open, which can be interpreted as a playful or mischievous expression. Cats often make such faces when they are in a good mood or are playful, and this can be amusing to people who are familiar with their behavior. The combination of the cat's expression and the close- + +``` + +## Useful Resources + +- [Transformers task guide on video-text-to-text](https://huggingface.co/docs/transformers/tasks/video_text_to_text) diff --git a/node_modules/@huggingface/tasks/src/tasks/video-text-to-text/data.ts b/node_modules/@huggingface/tasks/src/tasks/video-text-to-text/data.ts new file mode 100644 index 0000000000000000000000000000000000000000..75e6908efe3b103345e5ffb2aaf647a2e9ccc880 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/video-text-to-text/data.ts @@ -0,0 +1,74 @@ +import type { TaskDataCustom } from "../index.js"; + +const taskData: TaskDataCustom = { + datasets: [ + { + description: "Multiple-choice questions and answers about videos.", + id: "lmms-lab/Video-MME", + }, + { + description: "A dataset of instructions and question-answer pairs about videos.", + id: "lmms-lab/VideoChatGPT", + }, + { + description: "Large video understanding dataset.", + id: "HuggingFaceFV/finevideo", + }, + ], + demo: { + inputs: [ + { + filename: "video-text-to-text-input.gif", + type: "img", + }, + { + label: "Text Prompt", + content: "What is happening in this video?", + type: "text", + }, + ], + outputs: [ + { + label: "Answer", + content: + "The video shows a series of images showing a fountain with water jets and a variety of colorful flowers and butterflies in the background.", + type: "text", + }, + ], + }, + metrics: [], + models: [ + { + description: "A robust video-text-to-text model.", + id: "Vision-CAIR/LongVU_Qwen2_7B", + }, + { + description: "Strong video-text-to-text model with reasoning capabilities.", + id: "GoodiesHere/Apollo-LMMs-Apollo-7B-t32", + }, + { + description: "Strong video-text-to-text model.", + id: "HuggingFaceTB/SmolVLM2-2.2B-Instruct", + }, + ], + spaces: [ + { + description: "An application to chat with a video-text-to-text model.", + id: "llava-hf/video-llava", + }, + { + description: "A leaderboard for various video-text-to-text models.", + id: "opencompass/openvlm_video_leaderboard", + }, + { + description: "An application to generate highlights from a video.", + id: "HuggingFaceTB/SmolVLM2-HighlightGenerator", + }, + ], + summary: + "Video-text-to-text models take in a video and a text prompt and output text. These models are also called video-language models.", + widgetModels: [""], + youtubeId: "", +}; + +export default taskData; diff --git a/node_modules/@huggingface/tasks/src/tasks/video-to-video/about.md b/node_modules/@huggingface/tasks/src/tasks/video-to-video/about.md new file mode 100644 index 0000000000000000000000000000000000000000..9846262a8d7edfebe9d5ab69802a05b68e33c125 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/video-to-video/about.md @@ -0,0 +1,86 @@ +## Use Cases + +### Video Style Transfer + +Apply artistic or cinematic styles to a video while preserving motion and structure. For example, convert real footage into anime, painting, or film-like visuals. + +### Frame Interpolation + +Generate intermediate frames to make videos smoother or convert 30 FPS videos to 60 FPS. This improves motion flow and enables realistic slow-motion playback. + +### Video Super-Resolution + +Enhance low-resolution videos into high-definition outputs with preserved detail and sharpness. Ideal for restoring old footage or improving video quality. + +### Motion Transfer + +Transfer the motion from a source video to another subject while maintaining identity and environment. This enables realistic animation or gesture replication. + +### Video Editing & Synthesis + +Add, remove, or modify objects in videos while keeping lighting and motion consistent. Perfect for visual effects, object replacement, and content-aware editing. + +### Temporal Modification + +Change a video’s overall time or environmental conditions, such as day to night or summer to winter. These models preserve motion dynamics and lighting continuity. + +### Virtual Try-on + +Simulate clothing changes or outfit fitting in videos while keeping the person’s motion and identity intact. Useful for digital fashion and e-commerce applications. + +## Inference + +Below is an example demonstrating how to use [Lucy-Edit-Dev](https://huggingface.co/decart-ai/Lucy-Edit-Dev) to perform video costume editing, changing a character’s clothing while maintaining identity and motion consistency. Lucy-Edit-Dev is trained on paired video edits, captioned videos, and extended image–text datasets. + +```python +!pip install torch diffusers + +import torch +from PIL import Image + +from diffusers import AutoencoderKLWan, LucyEditPipeline +from diffusers.utils import export_to_video, load_video + + +url = "https://d2drjpuinn46lb.cloudfront.net/painter_original_edit.mp4" +prompt = "Change the apron and blouse to a classic clown costume: satin polka-dot jumpsuit in bright primary colors, ruffled white collar, oversized pom-pom buttons, white gloves, oversized red shoes, red foam nose; soft window light from left, eye-level medium shot, natural folds and fabric highlights." +negative_prompt = "" +num_frames = 81 +height = 480 +width = 832 + +def convert_video(video: List[Image.Image]) -> List[Image.Image]: + video = load_video(url)[:num_frames] + video = [video[i].resize((width, height)) for i in range(num_frames)] + return video + +video = load_video(url, convert_method=convert_video) + +model_id = "decart-ai/Lucy-Edit-Dev" +vae = AutoencoderKLWan.from_pretrained(model_id, subfolder="vae", torch_dtype=torch.float32) +pipe = LucyEditPipeline.from_pretrained(model_id, vae=vae, torch_dtype=torch.bfloat16) +pipe.to("cuda") + +output = pipe( + prompt=prompt, + video=video, + negative_prompt=negative_prompt, + height=480, + width=832, + num_frames=81, + guidance_scale=5.0 +).frames[0] + +export_to_video(output, "output.mp4", fps=24) +``` + +For more inference examples, check out the model cards on Hugging Face, where you can try the provided example code. + +## Useful Resources + +You can read more about the datasets, model architectures, and open-source implementations in the following repositories: + +- [Lumen](https://github.com/Kunbyte-AI/Lumen) - Official implementation of Lumen for text-guided video editing. +- [VIRES](https://github.com/suimuc/VIRES) - Implementation for sketch- and text-guided video instance repainting. +- [ECCV2022-RIFE: Video Frame Interpolation](https://github.com/hzwer/ECCV2022-RIFE) - Real-time video frame interpolation via intermediate flow estimation. +- [StableVSR: Enhancing Perceptual Quality in Video](https://github.com/claudiom4sir/StableVSR) - Super-resolution method to enhance perceptual video quality. diff --git a/node_modules/@huggingface/tasks/src/tasks/video-to-video/data.ts b/node_modules/@huggingface/tasks/src/tasks/video-to-video/data.ts new file mode 100644 index 0000000000000000000000000000000000000000..3bd172b2d1c59247ad61380601f84a69f745c46f --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/video-to-video/data.ts @@ -0,0 +1,67 @@ +import type { TaskDataCustom } from "../index.js"; + +const taskData: TaskDataCustom = { + datasets: [ + { + description: "Dataset with detailed annotations for training and benchmarking video instance editing.", + id: "suimu/VIRESET", + }, + { + description: "Dataset to evaluate models on long video generation and understanding.", + id: "zhangsh2001/LongV-EVAL", + }, + { + description: "Collection of 104 demo videos from the SeedVR/SeedVR2 series showcasing model outputs.", + id: "Iceclear/SeedVR_VideoDemos", + }, + ], + demo: { + inputs: [ + { + filename: "input.gif", + type: "img", + }, + ], + outputs: [ + { + filename: "output.gif", + type: "img", + }, + ], + }, + metrics: [], + models: [ + { + description: "Model for editing outfits, character, and scenery in videos.", + id: "decart-ai/Lucy-Edit-Dev", + }, + { + description: "Framework that uses 3D mesh proxies for precise, consistent video editing.", + id: "LeoLau/Shape-for-Motion", + }, + { + description: "Model for generating physics-aware videos from input videos and control conditions.", + id: "nvidia/Cosmos-Transfer2.5-2B", + }, + { + description: "A model to upscale videos at input, designed for seamless use with ComfyUI.", + id: "numz/SeedVR2_comfyUI", + }, + ], + spaces: [ + { + description: "Interactive demo space for Lucy-Edit-Dev video editing.", + id: "decart-ai/lucy-edit-dev", + }, + { + description: "Demo space for SeedVR2-3B showcasing video upscaling and restoration.", + id: "ByteDance-Seed/SeedVR2-3B", + }, + ], + summary: + "Video-to-video models take one or more videos as input and generate new videos as output. They can enhance quality, interpolate frames, modify styles, or create new motion dynamics, enabling creative applications, video production, and research.", + widgetModels: [], + youtubeId: "", +}; + +export default taskData; diff --git a/node_modules/@huggingface/tasks/src/tasks/visual-document-retrieval/about.md b/node_modules/@huggingface/tasks/src/tasks/visual-document-retrieval/about.md new file mode 100644 index 0000000000000000000000000000000000000000..97635b411d28583b306eb6cb53bb46e72a814655 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/visual-document-retrieval/about.md @@ -0,0 +1,54 @@ +## Use Cases + +### Multimodal Document Retrieval + +Visual document retrieval models can be used to retrieve relevant documents when given a text query. One needs to index the documents first, which is a one-time operation. After indexing is done, the retrieval model takes in a text query (question) and number `k` of documents to return, and the model returns the top-k most relevant documents for the query. The index can be used repetitively for inference. + +### Multimodal Retrieval Augmented Generation (RAG) + +Multimodal RAG is the task of generating answers from documents (texts or images) when given a text query and a bunch of documents. These documents and the text query can be fed to [a vision language model](https://huggingface.co/tasks/image-text-to-text) to get the actual answer. + +## Inference + +You can use transformers to infer visual document retrieval models. To calculate similarity between images and text, simply process both separately and pass each processed input through the model. The model outputs can then be passed to calculate similarity scores. + +```python +import torch +from PIL import Image +from transformers import ColPaliForRetrieval, ColPaliProcessor + +device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu") + +model = ColPaliForRetrieval.from_pretrained( + "vidore/colpali-v1.2-hf", + torch_dtype=torch.bfloat16, +).to(device) + +processor = ColPaliProcessor.from_pretrained("vidore/colpali-v1.2-hf") + +# Your inputs (replace dummy images with screenshots of your documents) +images = [ + Image.new("RGB", (32, 32), color="white"), + Image.new("RGB", (16, 16), color="black"), +] +queries = [ + "What is the organizational structure for our R&D department?", + "Can you provide a breakdown of last year’s financial performance?", +] + +# Process the image and text +batch_images = processor(images=images).to(device) +batch_queries = processor(text=queries).to(device) + +with torch.no_grad(): + image_embeddings = model(**batch_images).embeddings + query_embeddings = model(**batch_queries).embeddings + +# Score the queries against the images +scores = processor.score_retrieval(query_embeddings, image_embeddings) +``` + +## Useful Resources + +- [Multimodal Retrieval Augmented Generation using ColPali and Qwen2VL](https://github.com/merveenoyan/smol-vision/blob/main/ColPali_%2B_Qwen2_VL.ipynb) +- [Fine-tuning ColPali for Multimodal Retrieval Augmented Generation](https://github.com/merveenoyan/smol-vision/blob/main/Finetune_ColPali.ipynb) diff --git a/node_modules/@huggingface/tasks/src/tasks/visual-document-retrieval/data.ts b/node_modules/@huggingface/tasks/src/tasks/visual-document-retrieval/data.ts new file mode 100644 index 0000000000000000000000000000000000000000..a6a8aceb5255c49b7c7b2ec74b391030ec244b4e --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/visual-document-retrieval/data.ts @@ -0,0 +1,76 @@ +import type { TaskDataCustom } from "../index.js"; + +const taskData: TaskDataCustom = { + datasets: [ + { + description: "A large dataset used to train visual document retrieval models.", + id: "vidore/colpali_train_set", + }, + ], + demo: { + inputs: [ + { + filename: "input.png", + type: "img", + }, + { + label: "Question", + content: "Is the model in this paper the fastest for inference?", + type: "text", + }, + ], + outputs: [ + { + type: "chart", + data: [ + { + label: "Page 10", + score: 0.7, + }, + { + label: "Page 11", + score: 0.06, + }, + { + label: "Page 9", + score: 0.003, + }, + ], + }, + ], + }, + isPlaceholder: false, + metrics: [ + { + description: "NDCG@k scores ranked recommendation lists for top-k results. 0 is the worst, 1 is the best.", + id: "Normalized Discounted Cumulative Gain at K", + }, + ], + models: [ + { + description: "Very accurate visual document retrieval model for multilingual queries and documents.", + id: "vidore/colqwen2-v1.0", + }, + { + description: + "Very fast and efficient visual document retrieval model that can also take in other modalities like audio.", + id: "Tevatron/OmniEmbed-v0.1", + }, + ], + spaces: [ + { + description: "A leaderboard of visual document retrieval models.", + id: "vidore/vidore-leaderboard", + }, + { + description: "Visual retrieval augmented generation demo based on ColQwen2 model.", + id: "vidore/visual-rag-tool", + }, + ], + summary: + "Visual document retrieval is the task of searching for relevant image-based documents, such as PDFs. These models take a text query and multiple documents as input and return the top-most relevant documents and relevancy scores as output.", + widgetModels: [""], + youtubeId: "", +}; + +export default taskData; diff --git a/node_modules/@huggingface/tasks/src/tasks/visual-question-answering/about.md b/node_modules/@huggingface/tasks/src/tasks/visual-question-answering/about.md new file mode 100644 index 0000000000000000000000000000000000000000..7f96e1679b8a5b46042f5c6e2eb533e80749160f --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/visual-question-answering/about.md @@ -0,0 +1,48 @@ +## Use Cases + +### Aid the Visually Impaired Persons + +VQA models can be used to reduce visual barriers for visually impaired individuals by allowing them to get information about images from the web and the real world. + +### Education + +VQA models can be used to improve experiences at museums by allowing observers to directly ask questions they interested in. + +### Improved Image Retrieval + +Visual question answering models can be used to retrieve images with specific characteristics. For example, the user can ask "Is there a dog?" to find all images with dogs from a set of images. + +### Video Search + +Specific snippets/timestamps of a video can be retrieved based on search queries. For example, the user can ask "At which part of the video does the guitar appear?" and get a specific timestamp range from the whole video. + +## Task Variants + +### Video Question Answering + +Video Question Answering aims to answer questions asked about the content of a video. + +## Inference + +You can infer with Visual Question Answering models using the `vqa` (or `visual-question-answering`) pipeline. This pipeline requires [the Python Image Library (PIL)](https://pillow.readthedocs.io/en/stable/) to process images. You can install it with (`pip install pillow`). + +```python +from PIL import Image +from transformers import pipeline + +vqa_pipeline = pipeline("visual-question-answering") + +image = Image.open("elephant.jpeg") +question = "Is there an elephant?" + +vqa_pipeline(image, question, top_k=1) +#[{'score': 0.9998154044151306, 'answer': 'yes'}] +``` + +## Useful Resources + +- [An introduction to Visual Question Answering - AllenAI](https://blog.allenai.org/vanilla-vqa-adcaaaa94336) +- [Multi Modal Framework (MMF) - Meta Research](https://mmf.sh/docs/getting_started/video_overview/) + +The contents of this page are contributed by [ +Bharat Raghunathan](https://huggingface.co/bharat-raghunathan) and [Jose Londono Botero](https://huggingface.co/jlondonobo). diff --git a/node_modules/@huggingface/tasks/src/tasks/visual-question-answering/data.ts b/node_modules/@huggingface/tasks/src/tasks/visual-question-answering/data.ts new file mode 100644 index 0000000000000000000000000000000000000000..51de32a80d53a733265e3ebb40358d3efeb02d82 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/visual-question-answering/data.ts @@ -0,0 +1,97 @@ +import type { TaskDataCustom } from "../index.js"; + +const taskData: TaskDataCustom = { + datasets: [ + { + description: "A widely used dataset containing questions (with answers) about images.", + id: "Graphcore/vqa", + }, + { + description: "A dataset to benchmark visual reasoning based on text in images.", + id: "facebook/textvqa", + }, + ], + demo: { + inputs: [ + { + filename: "elephant.jpeg", + type: "img", + }, + { + label: "Question", + content: "What is in this image?", + type: "text", + }, + ], + outputs: [ + { + type: "chart", + data: [ + { + label: "elephant", + score: 0.97, + }, + { + label: "elephants", + score: 0.06, + }, + { + label: "animal", + score: 0.003, + }, + ], + }, + ], + }, + isPlaceholder: false, + metrics: [ + { + description: "", + id: "accuracy", + }, + { + description: + "Measures how much a predicted answer differs from the ground truth based on the difference in their semantic meaning.", + id: "wu-palmer similarity", + }, + ], + models: [ + { + description: "A visual question answering model trained to convert charts and plots to text.", + id: "google/deplot", + }, + { + description: + "A visual question answering model trained for mathematical reasoning and chart derendering from images.", + id: "google/matcha-base", + }, + { + description: "A strong visual question answering that answers questions from book covers.", + id: "google/pix2struct-ocrvqa-large", + }, + ], + spaces: [ + { + description: "An application that compares visual question answering models across different tasks.", + id: "merve/pix2struct", + }, + { + description: "An application that can answer questions based on images.", + id: "nielsr/vilt-vqa", + }, + { + description: "An application that can caption images and answer questions about a given image. ", + id: "Salesforce/BLIP", + }, + { + description: "An application that can caption images and answer questions about a given image. ", + id: "vumichien/Img2Prompt", + }, + ], + summary: + "Visual Question Answering is the task of answering open-ended questions based on an image. They output natural language responses to natural language questions.", + widgetModels: ["dandelin/vilt-b32-finetuned-vqa"], + youtubeId: "", +}; + +export default taskData; diff --git a/node_modules/@huggingface/tasks/src/tasks/visual-question-answering/inference.ts b/node_modules/@huggingface/tasks/src/tasks/visual-question-answering/inference.ts new file mode 100644 index 0000000000000000000000000000000000000000..3eb292c62d8c7aa03e540af836e7a65d0c21fe0d --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/visual-question-answering/inference.ts @@ -0,0 +1,60 @@ +/** + * Inference code generated from the JSON schema spec in ./spec + * + * Using src/scripts/inference-codegen + */ +/** + * Inputs for Visual Question Answering inference + */ +export interface VisualQuestionAnsweringInput { + /** + * One (image, question) pair to answer + */ + inputs: VisualQuestionAnsweringInputData; + /** + * Additional inference parameters for Visual Question Answering + */ + parameters?: VisualQuestionAnsweringParameters; + [property: string]: unknown; +} +/** + * One (image, question) pair to answer + */ +export interface VisualQuestionAnsweringInputData { + /** + * The image. + */ + image: unknown; + /** + * The question to answer based on the image. + */ + question: string; + [property: string]: unknown; +} +/** + * Additional inference parameters for Visual Question Answering + */ +export interface VisualQuestionAnsweringParameters { + /** + * The number of answers to return (will be chosen by order of likelihood). Note that we + * return less than topk answers if there are not enough options available within the + * context. + */ + top_k?: number; + [property: string]: unknown; +} +export type VisualQuestionAnsweringOutput = VisualQuestionAnsweringOutputElement[]; +/** + * Outputs of inference for the Visual Question Answering task + */ +export interface VisualQuestionAnsweringOutputElement { + /** + * The answer to the question + */ + answer?: string; + /** + * The associated score / probability + */ + score: number; + [property: string]: unknown; +} diff --git a/node_modules/@huggingface/tasks/src/tasks/visual-question-answering/spec/input.json b/node_modules/@huggingface/tasks/src/tasks/visual-question-answering/spec/input.json new file mode 100644 index 0000000000000000000000000000000000000000..d51f35c37992cef2147b35a263f2281cab1b3ea0 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/visual-question-answering/spec/input.json @@ -0,0 +1,42 @@ +{ + "$id": "/inference/schemas/visual-question-answering/input.json", + "$schema": "http://json-schema.org/draft-06/schema#", + "description": "Inputs for Visual Question Answering inference", + "title": "VisualQuestionAnsweringInput", + "type": "object", + "properties": { + "inputs": { + "description": "One (image, question) pair to answer", + "type": "object", + "title": "VisualQuestionAnsweringInputData", + "properties": { + "image": { + "description": "The image.", + "comment": "type=binary" + }, + "question": { + "description": "The question to answer based on the image.", + "type": "string" + } + }, + "required": ["question", "image"] + }, + "parameters": { + "description": "Additional inference parameters for Visual Question Answering", + "$ref": "#/$defs/VisualQuestionAnsweringParameters" + } + }, + "$defs": { + "VisualQuestionAnsweringParameters": { + "title": "VisualQuestionAnsweringParameters", + "type": "object", + "properties": { + "top_k": { + "type": "integer", + "description": "The number of answers to return (will be chosen by order of likelihood). Note that we return less than topk answers if there are not enough options available within the context." + } + } + } + }, + "required": ["inputs"] +} diff --git a/node_modules/@huggingface/tasks/src/tasks/visual-question-answering/spec/output.json b/node_modules/@huggingface/tasks/src/tasks/visual-question-answering/spec/output.json new file mode 100644 index 0000000000000000000000000000000000000000..2233951410bc63e7a6ee1b827c4ee385690e3877 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/visual-question-answering/spec/output.json @@ -0,0 +1,21 @@ +{ + "$id": "/inference/schemas/visual-question-answering/output.json", + "$schema": "http://json-schema.org/draft-06/schema#", + "description": "Outputs of inference for the Visual Question Answering task", + "title": "VisualQuestionAnsweringOutput", + "type": "array", + "items": { + "type": "object", + "properties": { + "answer": { + "type": "string", + "description": "The answer to the question" + }, + "score": { + "type": "number", + "description": "The associated score / probability" + } + }, + "required": ["score"] + } +} diff --git a/node_modules/@huggingface/tasks/src/tasks/zero-shot-classification/about.md b/node_modules/@huggingface/tasks/src/tasks/zero-shot-classification/about.md new file mode 100644 index 0000000000000000000000000000000000000000..9b7ff3c48c931d3355c76aed20b891fe8f57c54b --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/zero-shot-classification/about.md @@ -0,0 +1,40 @@ +## About the Task + +Zero Shot Classification is the task of predicting a class that wasn't seen by the model during training. This method, which leverages a pre-trained language model, can be thought of as an instance of [transfer learning](https://www.youtube.com/watch?v=BqqfQnyjmgg) which generally refers to using a model trained for one task in a different application than what it was originally trained for. This is particularly useful for situations where the amount of labeled data is small. + +In zero shot classification, we provide the model with a prompt and a sequence of text that describes what we want our model to do, in natural language. Zero-shot classification excludes any examples of the desired task being completed. This differs from single or few-shot classification, as these tasks include a single or a few examples of the selected task. + +Zero, single and few-shot classification seem to be an emergent feature of large language models. This feature seems to come about around model sizes of +100M parameters. The effectiveness of a model at a zero, single or few-shot task seems to scale with model size, meaning that larger models (models with more trainable parameters or layers) generally do better at this task. + +Here is an example of a zero-shot prompt for classifying the sentiment of a sequence of text: + +``` +Classify the following input text into one of the following three categories: [positive, negative, neutral] + +Input Text: Hugging Face is awesome for making all of these +state of the art models available! +Sentiment: positive + +``` + +One great example of this task with a nice off-the-shelf model is available at the widget of this page, where the user can input a sequence of text and candidate labels to the model. This is a _word level_ example of zero shot classification, more elaborate and lengthy generations are available with larger models. Testing these models out and getting a feel for prompt engineering is the best way to learn how to use them. + +## Inference + +You can use the 🤗 Transformers library zero-shot-classification pipeline to infer with zero shot text classification models. + +```python +from transformers import pipeline + +pipe = pipeline(model="facebook/bart-large-mnli") +pipe("I have a problem with my iphone that needs to be resolved asap!", + candidate_labels=["urgent", "not urgent", "phone", "tablet", "computer"], +) +# output +>>> {'sequence': 'I have a problem with my iphone that needs to be resolved asap!!', 'labels': ['urgent', 'phone', 'computer', 'not urgent', 'tablet'], 'scores': [0.504, 0.479, 0.013, 0.003, 0.002]} +``` + +## Useful Resources + +- [Zero Shot Learning](https://joeddav.github.io/blog/2020/05/29/ZSL.html) +- [Hugging Face on Transfer Learning](https://huggingface.co/course/en/chapter1/4?fw=pt#transfer-learning) diff --git a/node_modules/@huggingface/tasks/src/tasks/zero-shot-classification/data.ts b/node_modules/@huggingface/tasks/src/tasks/zero-shot-classification/data.ts new file mode 100644 index 0000000000000000000000000000000000000000..cbd0ceda5f77e2e880bb41aa7602f8f15820ad0a --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/zero-shot-classification/data.ts @@ -0,0 +1,74 @@ +import type { TaskDataCustom } from "../index.js"; + +const taskData: TaskDataCustom = { + datasets: [ + { + description: "A widely used dataset used to benchmark multiple variants of text classification.", + id: "nyu-mll/glue", + }, + { + description: + "The Multi-Genre Natural Language Inference (MultiNLI) corpus is a crowd-sourced collection of 433k sentence pairs annotated with textual entailment information.", + id: "nyu-mll/multi_nli", + }, + { + description: + "FEVER is a publicly available dataset for fact extraction and verification against textual sources.", + id: "fever/fever", + }, + ], + demo: { + inputs: [ + { + label: "Text Input", + content: "Dune is the best movie ever.", + type: "text", + }, + { + label: "Candidate Labels", + content: "CINEMA, ART, MUSIC", + type: "text", + }, + ], + outputs: [ + { + type: "chart", + data: [ + { + label: "CINEMA", + score: 0.9, + }, + { + label: "ART", + score: 0.1, + }, + { + label: "MUSIC", + score: 0.0, + }, + ], + }, + ], + }, + metrics: [], + models: [ + { + description: "Powerful zero-shot text classification model.", + id: "facebook/bart-large-mnli", + }, + { + description: "Cutting-edge zero-shot multilingual text classification model.", + id: "MoritzLaurer/ModernBERT-large-zeroshot-v2.0", + }, + { + description: "Zero-shot text classification model that can be used for topic and sentiment classification.", + id: "knowledgator/gliclass-modern-base-v2.0-init", + }, + ], + spaces: [], + summary: + "Zero-shot text classification is a task in natural language processing where a model is trained on a set of labeled examples but is then able to classify new examples from previously unseen classes.", + widgetModels: ["facebook/bart-large-mnli"], +}; + +export default taskData; diff --git a/node_modules/@huggingface/tasks/src/tasks/zero-shot-classification/inference.ts b/node_modules/@huggingface/tasks/src/tasks/zero-shot-classification/inference.ts new file mode 100644 index 0000000000000000000000000000000000000000..aaae36f62661d9fd51dd4f6d4956aacc31d3a03a --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/zero-shot-classification/inference.ts @@ -0,0 +1,55 @@ +/** + * Inference code generated from the JSON schema spec in ./spec + * + * Using src/scripts/inference-codegen + */ +/** + * Inputs for Zero Shot Classification inference + */ +export interface ZeroShotClassificationInput { + /** + * The text to classify + */ + inputs: string; + /** + * Additional inference parameters for Zero Shot Classification + */ + parameters: ZeroShotClassificationParameters; + [property: string]: unknown; +} +/** + * Additional inference parameters for Zero Shot Classification + */ +export interface ZeroShotClassificationParameters { + /** + * The set of possible class labels to classify the text into. + */ + candidate_labels: string[]; + /** + * The sentence used in conjunction with `candidate_labels` to attempt the text + * classification by replacing the placeholder with the candidate labels. + */ + hypothesis_template?: string; + /** + * Whether multiple candidate labels can be true. If false, the scores are normalized such + * that the sum of the label likelihoods for each sequence is 1. If true, the labels are + * considered independent and probabilities are normalized for each candidate. + */ + multi_label?: boolean; + [property: string]: unknown; +} +export type ZeroShotClassificationOutput = ZeroShotClassificationOutputElement[]; +/** + * Outputs of inference for the Zero Shot Classification task + */ +export interface ZeroShotClassificationOutputElement { + /** + * The predicted class label. + */ + label: string; + /** + * The corresponding probability. + */ + score: number; + [property: string]: unknown; +} diff --git a/node_modules/@huggingface/tasks/src/tasks/zero-shot-classification/spec/input.json b/node_modules/@huggingface/tasks/src/tasks/zero-shot-classification/spec/input.json new file mode 100644 index 0000000000000000000000000000000000000000..c919eac7ed262d6b744dbf06acab124c3989aae2 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/zero-shot-classification/spec/input.json @@ -0,0 +1,42 @@ +{ + "$id": "/inference/schemas/zero-shot-classification/input.json", + "$schema": "http://json-schema.org/draft-06/schema#", + "description": "Inputs for Zero Shot Classification inference", + "title": "ZeroShotClassificationInput", + "type": "object", + "properties": { + "inputs": { + "description": "The text to classify", + "type": "string" + }, + "parameters": { + "description": "Additional inference parameters for Zero Shot Classification", + "$ref": "#/$defs/ZeroShotClassificationParameters" + } + }, + "$defs": { + "ZeroShotClassificationParameters": { + "title": "ZeroShotClassificationParameters", + "type": "object", + "properties": { + "candidate_labels": { + "type": "array", + "description": "The set of possible class labels to classify the text into.", + "items": { + "type": "string" + } + }, + "hypothesis_template": { + "type": "string", + "description": "The sentence used in conjunction with `candidate_labels` to attempt the text classification by replacing the placeholder with the candidate labels." + }, + "multi_label": { + "type": "boolean", + "description": "Whether multiple candidate labels can be true. If false, the scores are normalized such that the sum of the label likelihoods for each sequence is 1. If true, the labels are considered independent and probabilities are normalized for each candidate." + } + }, + "required": ["candidate_labels"] + } + }, + "required": ["inputs", "parameters"] +} diff --git a/node_modules/@huggingface/tasks/src/tasks/zero-shot-classification/spec/output.json b/node_modules/@huggingface/tasks/src/tasks/zero-shot-classification/spec/output.json new file mode 100644 index 0000000000000000000000000000000000000000..1b5ac0cc378da256645aef340709d0543482c522 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/zero-shot-classification/spec/output.json @@ -0,0 +1,11 @@ +{ + "$id": "/inference/schemas/zero-shot-classification/output.json", + "$schema": "http://json-schema.org/draft-06/schema#", + "description": "Outputs of inference for the Zero Shot Classification task", + "title": "ZeroShotClassificationOutput", + "type": "array", + "items": { + "type": "object", + "$ref": "/inference/schemas/common-definitions.json#/definitions/ClassificationOutput" + } +} diff --git a/node_modules/@huggingface/tasks/src/tasks/zero-shot-image-classification/about.md b/node_modules/@huggingface/tasks/src/tasks/zero-shot-image-classification/about.md new file mode 100644 index 0000000000000000000000000000000000000000..9cf273b299be7828ea2c75fd0da6f50d65c50029 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/zero-shot-image-classification/about.md @@ -0,0 +1,75 @@ +## About the Task + +Zero-shot image classification is a computer vision task to classify images into one of several classes, without any prior training or knowledge of the classes. + +Zero shot image classification works by transferring knowledge learnt during training of one model, to classify novel classes that was not present in the training data. So this is a variation of [transfer learning](https://www.youtube.com/watch?v=BqqfQnyjmgg). For instance, a model trained to differentiate cars from airplanes can be used to classify images of ships. + +The data in this learning paradigm consists of + +- Seen data - images and their corresponding labels +- Unseen data - only labels and no images +- Auxiliary information - additional information given to the model during training connecting the unseen and seen data. This can be in the form of textual description or word embeddings. + +## Use Cases + +### Image Retrieval + +Zero-shot learning resolves several challenges in image retrieval systems. For example, with the rapid growth of categories on the web, it is challenging to index images based on unseen categories. With zero-shot learning we can associate unseen categories to images by exploiting attributes to model the relationships among visual features and labels. + +### Action Recognition + +Action recognition is the task of identifying when a person in an image/video is performing a given action from a set of actions. If all the possible actions are not known beforehand, conventional deep learning models fail. With zero-shot learning, for a given domain of a set of actions, we can create a mapping connecting low-level features and a semantic description of auxiliary data to classify unknown classes of actions. + +## Task Variants + +You can contribute variants of this task [here](https://github.com/huggingface/hub-docs/blob/main/tasks/src/zero-shot-image-classification/about.md). + +## Inference + +The model can be loaded with the zero-shot-image-classification pipeline like so: + +```python +from transformers import pipeline +# More models in the model hub. +model_name = "openai/clip-vit-large-patch14-336" +classifier = pipeline("zero-shot-image-classification", model = model_name) +``` + +You can then use this pipeline to classify images into any of the class names you specify. You can specify more than two class labels too. + +```python +image_to_classify = "path_to_cat_and_dog_image.jpeg" +labels_for_classification = ["cat and dog", + "lion and cheetah", + "rabbit and lion"] +scores = classifier(image_to_classify, + candidate_labels = labels_for_classification) +``` + +The classifier would return a list of dictionaries after the inference which is stored in the variable `scores` in the code snippet above. Variable `scores` would look as follows: + +```python +[{'score': 0.9950482249259949, 'label': 'cat and dog'}, +{'score': 0.004863627254962921, 'label': 'rabbit and lion'}, +{'score': 8.816882473183796e-05, 'label': 'lion and cheetah'}] +``` + +The dictionary at the zeroth index of the list will contain the label with the highest score. + +```python +print(f"The highest score is {scores[0]['score']:.3f} for the label {scores[0]['label']}") +``` + +The output from the print statement above would look as follows: + +``` +The highest probability is 0.995 for the label cat and dog +``` + +## Useful Resources + +- [Zero-shot image classification task guide](https://huggingface.co/docs/transformers/tasks/zero_shot_image_classification). +- [Image-text Similarity Search](https://huggingface.co/learn/cookbook/faiss_with_hf_datasets_and_clip) + +This page was made possible thanks to the efforts of [Shamima Hossain](https://huggingface.co/Shamima), [Haider Zaidi +](https://huggingface.co/chefhaider) and [Paarth Bhatnagar](https://huggingface.co/Paarth). diff --git a/node_modules/@huggingface/tasks/src/tasks/zero-shot-image-classification/data.ts b/node_modules/@huggingface/tasks/src/tasks/zero-shot-image-classification/data.ts new file mode 100644 index 0000000000000000000000000000000000000000..ae87eb4fa0fae8d42fca404ff15531f3417ea62c --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/zero-shot-image-classification/data.ts @@ -0,0 +1,88 @@ +import type { TaskDataCustom } from "../index.js"; + +const taskData: TaskDataCustom = { + datasets: [ + { + // TODO write proper description + description: "", + id: "", + }, + ], + demo: { + inputs: [ + { + filename: "image-classification-input.jpeg", + type: "img", + }, + { + label: "Classes", + content: "cat, dog, bird", + type: "text", + }, + ], + outputs: [ + { + type: "chart", + data: [ + { + label: "Cat", + score: 0.664, + }, + { + label: "Dog", + score: 0.329, + }, + { + label: "Bird", + score: 0.008, + }, + ], + }, + ], + }, + metrics: [ + { + description: "Computes the number of times the correct label appears in top K labels predicted", + id: "top-K accuracy", + }, + ], + models: [ + { + description: "Multilingual image classification model for 80 languages.", + id: "visheratin/mexma-siglip", + }, + { + description: "Strong zero-shot image classification model.", + id: "google/siglip2-base-patch16-224", + }, + { + description: "Robust zero-shot image classification model.", + id: "intfloat/mmE5-mllama-11b-instruct", + }, + { + description: "Powerful zero-shot image classification model supporting 94 languages.", + id: "jinaai/jina-clip-v2", + }, + { + description: "Strong image classification model for biomedical domain.", + id: "microsoft/BiomedCLIP-PubMedBERT_256-vit_base_patch16_224", + }, + ], + spaces: [ + { + description: + "An application that leverages zero-shot image classification to find best captions to generate an image. ", + id: "pharma/CLIP-Interrogator", + }, + { + description: "An application to compare different zero-shot image classification models. ", + id: "merve/compare_clip_siglip", + }, + ], + summary: + "Zero-shot image classification is the task of classifying previously unseen classes during training of a model.", + widgetModels: ["google/siglip-so400m-patch14-224"], + youtubeId: "", +}; + +export default taskData; diff --git a/node_modules/@huggingface/tasks/src/tasks/zero-shot-image-classification/inference.ts b/node_modules/@huggingface/tasks/src/tasks/zero-shot-image-classification/inference.ts new file mode 100644 index 0000000000000000000000000000000000000000..a700bb4f30eb515c393aea91a2808c82e7e54388 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/zero-shot-image-classification/inference.ts @@ -0,0 +1,49 @@ +/** + * Inference code generated from the JSON schema spec in ./spec + * + * Using src/scripts/inference-codegen + */ +/** + * Inputs for Zero Shot Image Classification inference + */ +export interface ZeroShotImageClassificationInput { + /** + * The input image data to classify as a base64-encoded string. + */ + inputs: Blob; + /** + * Additional inference parameters for Zero Shot Image Classification + */ + parameters: ZeroShotImageClassificationParameters; + [property: string]: unknown; +} +/** + * Additional inference parameters for Zero Shot Image Classification + */ +export interface ZeroShotImageClassificationParameters { + /** + * The candidate labels for this image + */ + candidate_labels: string[]; + /** + * The sentence used in conjunction with `candidate_labels` to attempt the image + * classification by replacing the placeholder with the candidate labels. + */ + hypothesis_template?: string; + [property: string]: unknown; +} +export type ZeroShotImageClassificationOutput = ZeroShotImageClassificationOutputElement[]; +/** + * Outputs of inference for the Zero Shot Image Classification task + */ +export interface ZeroShotImageClassificationOutputElement { + /** + * The predicted class label. + */ + label: string; + /** + * The corresponding probability. + */ + score: number; + [property: string]: unknown; +} diff --git a/node_modules/@huggingface/tasks/src/tasks/zero-shot-image-classification/spec/input.json b/node_modules/@huggingface/tasks/src/tasks/zero-shot-image-classification/spec/input.json new file mode 100644 index 0000000000000000000000000000000000000000..7c3c413436c6354cca1ddd2bd6b516309ac3fa72 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/zero-shot-image-classification/spec/input.json @@ -0,0 +1,39 @@ +{ + "$id": "/inference/schemas/zero-shot-image-classification/input.json", + "$schema": "http://json-schema.org/draft-06/schema#", + "description": "Inputs for Zero Shot Image Classification inference", + "title": "ZeroShotImageClassificationInput", + "type": "object", + "properties": { + "inputs": { + "type": "string", + "description": "The input image data to classify as a base64-encoded string.", + "comment": "type=binary" + }, + "parameters": { + "description": "Additional inference parameters for Zero Shot Image Classification", + "$ref": "#/$defs/ZeroShotImageClassificationParameters" + } + }, + "$defs": { + "ZeroShotImageClassificationParameters": { + "title": "ZeroShotImageClassificationParameters", + "type": "object", + "properties": { + "candidate_labels": { + "description": "The candidate labels for this image", + "type": "array", + "items": { + "type": "string" + } + }, + "hypothesis_template": { + "type": "string", + "description": "The sentence used in conjunction with `candidate_labels` to attempt the image classification by replacing the placeholder with the candidate labels." + } + }, + "required": ["candidate_labels"] + } + }, + "required": ["inputs", "parameters"] +} diff --git a/node_modules/@huggingface/tasks/src/tasks/zero-shot-image-classification/spec/output.json b/node_modules/@huggingface/tasks/src/tasks/zero-shot-image-classification/spec/output.json new file mode 100644 index 0000000000000000000000000000000000000000..6b795fbdbae8b566845fb424f30a7d7908609358 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/zero-shot-image-classification/spec/output.json @@ -0,0 +1,10 @@ +{ + "$id": "/inference/schemas/zero-shot-image-classification/output.json", + "$schema": "http://json-schema.org/draft-06/schema#", + "description": "Outputs of inference for the Zero Shot Image Classification task", + "title": "ZeroShotImageClassificationOutput", + "type": "array", + "items": { + "$ref": "/inference/schemas/common-definitions.json#/definitions/ClassificationOutput" + } +} diff --git a/node_modules/@huggingface/tasks/src/tasks/zero-shot-object-detection/about.md b/node_modules/@huggingface/tasks/src/tasks/zero-shot-object-detection/about.md new file mode 100644 index 0000000000000000000000000000000000000000..46c4bf7c169fc3664b89d6b1243b47d9b4cdc7aa --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/zero-shot-object-detection/about.md @@ -0,0 +1,45 @@ +## Use Cases + +Zero-shot object detection models can be used in any object detection application where the detection involves text queries for objects of interest. + +### Object Search + +Zero-shot object detection models can be used in image search. Smartphones, for example, use zero-shot object detection models to detect entities (such as specific places or objects) and allow the user to search for the entity on the internet. + +### Object Counting + +Zero-shot object detection models are used to count instances of objects in a given image. This can include counting the objects in warehouses or stores or the number of visitors in a store. They are also used to manage crowds at events to prevent disasters. + +### Object Tracking + +Zero-shot object detectors can track objects in videos. + +## Inference + +You can infer with zero-shot object detection models through the `zero-shot-object-detection` pipeline. When calling the pipeline, you just need to specify a path or HTTP link to an image and the candidate labels. + +```python +from transformers import pipeline +from PIL import Image + +image = Image.open("my-image.png").convert("RGB") + +detector = pipeline(model="google/owlvit-base-patch32", task="zero-shot-object-detection") + +predictions = detector( + image, + candidate_labels=["a photo of a cat", "a photo of a dog"], +) + +# [{'score': 0.95, +# 'label': 'a photo of a cat', +# 'box': {'xmin': 180, 'ymin': 71, 'xmax': 271, 'ymax': 178}}, +# ... +# ] +``` + +# Useful Resources + +- [Zero-shot object detection task guide](https://huggingface.co/docs/transformers/tasks/zero_shot_object_detection) + +This page was made possible thanks to the efforts of [Victor Guichard](https://huggingface.co/VictorGuichard) diff --git a/node_modules/@huggingface/tasks/src/tasks/zero-shot-object-detection/data.ts b/node_modules/@huggingface/tasks/src/tasks/zero-shot-object-detection/data.ts new file mode 100644 index 0000000000000000000000000000000000000000..705bbdeceaa10a04dd1f9232881b0a263ad0219a --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/zero-shot-object-detection/data.ts @@ -0,0 +1,67 @@ +import type { TaskDataCustom } from "../index.js"; + +const taskData: TaskDataCustom = { + datasets: [], + demo: { + inputs: [ + { + filename: "zero-shot-object-detection-input.jpg", + type: "img", + }, + { + label: "Classes", + content: "cat, dog, bird", + type: "text", + }, + ], + outputs: [ + { + filename: "zero-shot-object-detection-output.jpg", + type: "img", + }, + ], + }, + metrics: [ + { + description: + "The Average Precision (AP) metric is the Area Under the PR Curve (AUC-PR). It is calculated for each class separately", + id: "Average Precision", + }, + { + description: "The Mean Average Precision (mAP) metric is the overall average of the AP values", + id: "Mean Average Precision", + }, + { + description: + "The APα metric is the Average Precision at the IoU threshold of a α value, for example, AP50 and AP75", + id: "APα", + }, + ], + models: [ + { + description: "Solid zero-shot object detection model.", + id: "openmmlab-community/mm_grounding_dino_large_all", + }, + { + description: "Cutting-edge zero-shot object detection model.", + id: "fushh7/LLMDet", + }, + ], + spaces: [ + { + description: "A demo to compare different zero-shot object detection models per output and latency.", + id: "ariG23498/zero-shot-od", + }, + { + description: + "A demo that combines a zero-shot object detection and mask generation model for zero-shot segmentation.", + id: "merve/OWLSAM", + }, + ], + summary: + "Zero-shot object detection is a computer vision task to detect objects and their classes in images, without any prior training or knowledge of the classes. Zero-shot object detection models receive an image as input, as well as a list of candidate classes, and output the bounding boxes and labels where the objects have been detected.", + widgetModels: [], + youtubeId: "", +}; + +export default taskData; diff --git a/node_modules/@huggingface/tasks/src/tasks/zero-shot-object-detection/inference.ts b/node_modules/@huggingface/tasks/src/tasks/zero-shot-object-detection/inference.ts new file mode 100644 index 0000000000000000000000000000000000000000..e5ae3eb1ac8a5f6832ed098d9e80ecb2f21b41eb --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/zero-shot-object-detection/inference.ts @@ -0,0 +1,60 @@ +/** + * Inference code generated from the JSON schema spec in ./spec + * + * Using src/scripts/inference-codegen + */ +/** + * Inputs for Zero Shot Object Detection inference + */ +export interface ZeroShotObjectDetectionInput { + /** + * The input image data as a base64-encoded string. + */ + inputs: Blob; + /** + * Additional inference parameters for Zero Shot Object Detection + */ + parameters: ZeroShotObjectDetectionParameters; + [property: string]: unknown; +} +/** + * Additional inference parameters for Zero Shot Object Detection + */ +export interface ZeroShotObjectDetectionParameters { + /** + * The candidate labels for this image + */ + candidate_labels: string[]; + [property: string]: unknown; +} +/** + * The predicted bounding box. Coordinates are relative to the top left corner of the input + * image. + */ +export interface BoundingBox { + xmax: number; + xmin: number; + ymax: number; + ymin: number; + [property: string]: unknown; +} +export type ZeroShotObjectDetectionOutput = ZeroShotObjectDetectionOutputElement[]; +/** + * Outputs of inference for the Zero Shot Object Detection task + */ +export interface ZeroShotObjectDetectionOutputElement { + /** + * The predicted bounding box. Coordinates are relative to the top left corner of the input + * image. + */ + box: BoundingBox; + /** + * A candidate label + */ + label: string; + /** + * The associated score / probability + */ + score: number; + [property: string]: unknown; +} diff --git a/node_modules/@huggingface/tasks/src/tasks/zero-shot-object-detection/spec/input.json b/node_modules/@huggingface/tasks/src/tasks/zero-shot-object-detection/spec/input.json new file mode 100644 index 0000000000000000000000000000000000000000..7e6264dee50a44b8e93a261ed96a3bb4c4f0a37d --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/zero-shot-object-detection/spec/input.json @@ -0,0 +1,35 @@ +{ + "$id": "/inference/schemas/zero-shot-object-detection/input.json", + "$schema": "http://json-schema.org/draft-06/schema#", + "description": "Inputs for Zero Shot Object Detection inference", + "title": "ZeroShotObjectDetectionInput", + "type": "object", + "properties": { + "inputs": { + "description": "The input image data as a base64-encoded string.", + "type": "string", + "comment": "type=binary" + }, + "parameters": { + "description": "Additional inference parameters for Zero Shot Object Detection", + "$ref": "#/$defs/ZeroShotObjectDetectionParameters" + } + }, + "$defs": { + "ZeroShotObjectDetectionParameters": { + "title": "ZeroShotObjectDetectionParameters", + "type": "object", + "properties": { + "candidate_labels": { + "description": "The candidate labels for this image", + "type": "array", + "items": { + "type": "string" + } + } + }, + "required": ["candidate_labels"] + } + }, + "required": ["inputs", "parameters"] +} diff --git a/node_modules/@huggingface/tasks/src/tasks/zero-shot-object-detection/spec/output.json b/node_modules/@huggingface/tasks/src/tasks/zero-shot-object-detection/spec/output.json new file mode 100644 index 0000000000000000000000000000000000000000..8afa6052769f617ae365348d4d560ee43095ae4a --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tasks/zero-shot-object-detection/spec/output.json @@ -0,0 +1,47 @@ +{ + "$id": "/inference/schemas/zero-shot-object-detection/output.json", + "$schema": "http://json-schema.org/draft-06/schema#", + "description": "Outputs of inference for the Zero Shot Object Detection task", + "title": "ZeroShotObjectDetectionOutput", + "type": "array", + "items": { + "type": "object", + "title": "ZeroShotObjectDetectionOutputElement", + "properties": { + "label": { + "type": "string", + "description": "A candidate label" + }, + "score": { + "type": "number", + "description": "The associated score / probability" + }, + "box": { + "$ref": "#/$defs/BoundingBox", + "description": "The predicted bounding box. Coordinates are relative to the top left corner of the input image." + } + }, + "required": ["box", "label", "score"] + }, + "$defs": { + "BoundingBox": { + "title": "BoundingBox", + "type": "object", + "properties": { + "xmin": { + "type": "integer" + }, + "xmax": { + "type": "integer" + }, + "ymin": { + "type": "integer" + }, + "ymax": { + "type": "integer" + } + }, + "required": ["xmin", "xmax", "ymin", "ymax"] + } + } +} diff --git a/node_modules/@huggingface/tasks/src/tokenizer-data.ts b/node_modules/@huggingface/tasks/src/tokenizer-data.ts new file mode 100644 index 0000000000000000000000000000000000000000..6be41e8f60df763bf854feea8ca8ed689794a609 --- /dev/null +++ b/node_modules/@huggingface/tasks/src/tokenizer-data.ts @@ -0,0 +1,32 @@ +export const SPECIAL_TOKENS_ATTRIBUTES = [ + "bos_token", + "eos_token", + "unk_token", + "sep_token", + "pad_token", + "cls_token", + "mask_token", + // additional_special_tokens (TODO) +] as const; + +/** + * Public interface for a tokenizer's special tokens mapping + */ +export interface AddedToken { + __type: "AddedToken"; + content?: string; + lstrip?: boolean; + normalized?: boolean; + rstrip?: boolean; + single_word?: boolean; +} +export type SpecialTokensMap = { + [key in (typeof SPECIAL_TOKENS_ATTRIBUTES)[number]]?: string | AddedToken | null; +}; +/** + * Public interface for tokenizer config + */ +export interface TokenizerConfig extends SpecialTokensMap { + use_default_system_prompt?: boolean; + chat_template?: string | Array<{ name: string; template: string }>; +} diff --git a/node_modules/@huggingface/tasks/src/widget-example.ts b/node_modules/@huggingface/tasks/src/widget-example.ts new file mode 100644 index 0000000000000000000000000000000000000000..2f60cd76bc9e314f037acca747af2c5c1d3cf35c --- /dev/null +++ b/node_modules/@huggingface/tasks/src/widget-example.ts @@ -0,0 +1,128 @@ +/** + * See default-widget-inputs.ts for the default widget inputs, this files only contains the types + */ + +import type { ChatCompletionInputMessage } from "./tasks/index.js"; + +type TableData = Record; + +//#region outputs +export type WidgetExampleOutputLabels = Array<{ label: string; score: number }>; +export interface WidgetExampleOutputAnswerScore { + answer: string; + score: number; +} +export interface WidgetExampleOutputText { + text: string; +} +export interface WidgetExampleOutputUrl { + url: string; +} + +export type WidgetExampleOutput = + | WidgetExampleOutputLabels + | WidgetExampleOutputAnswerScore + | WidgetExampleOutputText + | WidgetExampleOutputUrl; +//#endregion + +export interface WidgetExampleBase { + example_title?: string; + group?: string; + /** + * Potential overrides to API parameters for this specific example + * (takes precedences over the model card metadata's inference.parameters) + */ + parameters?: { + /// token-classification + aggregation_strategy?: string; + /// text-generation + top_k?: number; + top_p?: number; + temperature?: number; + max_new_tokens?: number; + do_sample?: boolean; + /// text-to-image + negative_prompt?: string; + guidance_scale?: number; + num_inference_steps?: number; + }; + /** + * Optional output + */ + output?: TOutput; +} + +export interface WidgetExampleChatInput extends WidgetExampleBase { + messages: ChatCompletionInputMessage[]; +} + +export interface WidgetExampleTextInput extends WidgetExampleBase { + text: string; +} + +export interface WidgetExampleTextAndContextInput< + TOutput = WidgetExampleOutput, +> extends WidgetExampleTextInput { + context: string; +} + +export interface WidgetExampleTextAndTableInput extends WidgetExampleTextInput { + table: TableData; +} + +export interface WidgetExampleAssetInput extends WidgetExampleBase { + src: string; +} +export interface WidgetExampleAssetAndPromptInput< + TOutput = WidgetExampleOutput, +> extends WidgetExampleAssetInput { + prompt: string; +} + +export type WidgetExampleAssetAndTextInput = WidgetExampleAssetInput & + WidgetExampleTextInput; + +export type WidgetExampleAssetAndZeroShotInput = WidgetExampleAssetInput & + WidgetExampleZeroShotTextInput; + +export interface WidgetExampleStructuredDataInput extends WidgetExampleBase { + structured_data: TableData; +} + +export interface WidgetExampleTableDataInput extends WidgetExampleBase { + table: TableData; +} + +export interface WidgetExampleZeroShotTextInput extends WidgetExampleTextInput { + text: string; + candidate_labels: string; + multi_class: boolean; +} + +export interface WidgetExampleSentenceSimilarityInput< + TOutput = WidgetExampleOutput, +> extends WidgetExampleBase { + source_sentence: string; + sentences: string[]; +} + +//#endregion + +export type WidgetExample = + | WidgetExampleChatInput + | WidgetExampleTextInput + | WidgetExampleTextAndContextInput + | WidgetExampleTextAndTableInput + | WidgetExampleAssetInput + | WidgetExampleAssetAndPromptInput + | WidgetExampleAssetAndTextInput + | WidgetExampleAssetAndZeroShotInput + | WidgetExampleStructuredDataInput + | WidgetExampleTableDataInput + | WidgetExampleZeroShotTextInput + | WidgetExampleSentenceSimilarityInput; + +type KeysOfUnion = T extends unknown ? keyof T : never; + +export type WidgetExampleAttribute = KeysOfUnion; diff --git a/node_modules/@huggingface/tasks/tsconfig.json b/node_modules/@huggingface/tasks/tsconfig.json new file mode 100644 index 0000000000000000000000000000000000000000..3e3c571e5e55e7e4df25af4ea1e4565e19969231 --- /dev/null +++ b/node_modules/@huggingface/tasks/tsconfig.json @@ -0,0 +1,20 @@ +{ + "compilerOptions": { + "allowSyntheticDefaultImports": true, + "lib": ["ES2022", "DOM"], + "module": "NodeNext", + "target": "ESNext", + "moduleResolution": "nodenext", + "forceConsistentCasingInFileNames": true, + "strict": true, + "noImplicitAny": true, + "strictNullChecks": true, + "skipLibCheck": true, + "noImplicitOverride": true, + "outDir": "./dist", + "declaration": true, + "declarationMap": true + }, + "include": ["src"], + "exclude": ["dist"] +} diff --git a/node_modules/@jridgewell/gen-mapping/LICENSE b/node_modules/@jridgewell/gen-mapping/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..1f6ce94c11912496b96298630d84753dbf593a7d --- /dev/null +++ b/node_modules/@jridgewell/gen-mapping/LICENSE @@ -0,0 +1,19 @@ +Copyright 2024 Justin Ridgewell + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/node_modules/@jridgewell/gen-mapping/README.md b/node_modules/@jridgewell/gen-mapping/README.md new file mode 100644 index 0000000000000000000000000000000000000000..93692b10655a33f4bb4f37c28a576edf83b0c8e2 --- /dev/null +++ b/node_modules/@jridgewell/gen-mapping/README.md @@ -0,0 +1,227 @@ +# @jridgewell/gen-mapping + +> Generate source maps + +`gen-mapping` allows you to generate a source map during transpilation or minification. +With a source map, you're able to trace the original location in the source file, either in Chrome's +DevTools or using a library like [`@jridgewell/trace-mapping`][trace-mapping]. + +You may already be familiar with the [`source-map`][source-map] package's `SourceMapGenerator`. This +provides the same `addMapping` and `setSourceContent` API. + +## Installation + +```sh +npm install @jridgewell/gen-mapping +``` + +## Usage + +```typescript +import { GenMapping, addMapping, setSourceContent, toEncodedMap, toDecodedMap } from '@jridgewell/gen-mapping'; + +const map = new GenMapping({ + file: 'output.js', + sourceRoot: 'https://example.com/', +}); + +setSourceContent(map, 'input.js', `function foo() {}`); + +addMapping(map, { + // Lines start at line 1, columns at column 0. + generated: { line: 1, column: 0 }, + source: 'input.js', + original: { line: 1, column: 0 }, +}); + +addMapping(map, { + generated: { line: 1, column: 9 }, + source: 'input.js', + original: { line: 1, column: 9 }, + name: 'foo', +}); + +assert.deepEqual(toDecodedMap(map), { + version: 3, + file: 'output.js', + names: ['foo'], + sourceRoot: 'https://example.com/', + sources: ['input.js'], + sourcesContent: ['function foo() {}'], + mappings: [ + [ [0, 0, 0, 0], [9, 0, 0, 9, 0] ] + ], +}); + +assert.deepEqual(toEncodedMap(map), { + version: 3, + file: 'output.js', + names: ['foo'], + sourceRoot: 'https://example.com/', + sources: ['input.js'], + sourcesContent: ['function foo() {}'], + mappings: 'AAAA,SAASA', +}); +``` + +### Smaller Sourcemaps + +Not everything needs to be added to a sourcemap, and needless markings can cause signficantly +larger file sizes. `gen-mapping` exposes `maybeAddSegment`/`maybeAddMapping` APIs that will +intelligently determine if this marking adds useful information. If not, the marking will be +skipped. + +```typescript +import { maybeAddMapping } from '@jridgewell/gen-mapping'; + +const map = new GenMapping(); + +// Adding a sourceless marking at the beginning of a line isn't useful. +maybeAddMapping(map, { + generated: { line: 1, column: 0 }, +}); + +// Adding a new source marking is useful. +maybeAddMapping(map, { + generated: { line: 1, column: 0 }, + source: 'input.js', + original: { line: 1, column: 0 }, +}); + +// But adding another marking pointing to the exact same original location isn't, even if the +// generated column changed. +maybeAddMapping(map, { + generated: { line: 1, column: 9 }, + source: 'input.js', + original: { line: 1, column: 0 }, +}); + +assert.deepEqual(toEncodedMap(map), { + version: 3, + names: [], + sources: ['input.js'], + sourcesContent: [null], + mappings: 'AAAA', +}); +``` + +## Benchmarks + +``` +node v18.0.0 + +amp.js.map +Memory Usage: +gen-mapping: addSegment 5852872 bytes +gen-mapping: addMapping 7716042 bytes +source-map-js 6143250 bytes +source-map-0.6.1 6124102 bytes +source-map-0.8.0 6121173 bytes +Smallest memory usage is gen-mapping: addSegment + +Adding speed: +gen-mapping: addSegment x 441 ops/sec ±2.07% (90 runs sampled) +gen-mapping: addMapping x 350 ops/sec ±2.40% (86 runs sampled) +source-map-js: addMapping x 169 ops/sec ±2.42% (80 runs sampled) +source-map-0.6.1: addMapping x 167 ops/sec ±2.56% (80 runs sampled) +source-map-0.8.0: addMapping x 168 ops/sec ±2.52% (80 runs sampled) +Fastest is gen-mapping: addSegment + +Generate speed: +gen-mapping: decoded output x 150,824,370 ops/sec ±0.07% (102 runs sampled) +gen-mapping: encoded output x 663 ops/sec ±0.22% (98 runs sampled) +source-map-js: encoded output x 197 ops/sec ±0.45% (84 runs sampled) +source-map-0.6.1: encoded output x 198 ops/sec ±0.33% (85 runs sampled) +source-map-0.8.0: encoded output x 197 ops/sec ±0.06% (93 runs sampled) +Fastest is gen-mapping: decoded output + + +*** + + +babel.min.js.map +Memory Usage: +gen-mapping: addSegment 37578063 bytes +gen-mapping: addMapping 37212897 bytes +source-map-js 47638527 bytes +source-map-0.6.1 47690503 bytes +source-map-0.8.0 47470188 bytes +Smallest memory usage is gen-mapping: addMapping + +Adding speed: +gen-mapping: addSegment x 31.05 ops/sec ±8.31% (43 runs sampled) +gen-mapping: addMapping x 29.83 ops/sec ±7.36% (51 runs sampled) +source-map-js: addMapping x 20.73 ops/sec ±6.22% (38 runs sampled) +source-map-0.6.1: addMapping x 20.03 ops/sec ±10.51% (38 runs sampled) +source-map-0.8.0: addMapping x 19.30 ops/sec ±8.27% (37 runs sampled) +Fastest is gen-mapping: addSegment + +Generate speed: +gen-mapping: decoded output x 381,379,234 ops/sec ±0.29% (96 runs sampled) +gen-mapping: encoded output x 95.15 ops/sec ±2.98% (72 runs sampled) +source-map-js: encoded output x 15.20 ops/sec ±7.41% (33 runs sampled) +source-map-0.6.1: encoded output x 16.36 ops/sec ±10.46% (31 runs sampled) +source-map-0.8.0: encoded output x 16.06 ops/sec ±6.45% (31 runs sampled) +Fastest is gen-mapping: decoded output + + +*** + + +preact.js.map +Memory Usage: +gen-mapping: addSegment 416247 bytes +gen-mapping: addMapping 419824 bytes +source-map-js 1024619 bytes +source-map-0.6.1 1146004 bytes +source-map-0.8.0 1113250 bytes +Smallest memory usage is gen-mapping: addSegment + +Adding speed: +gen-mapping: addSegment x 13,755 ops/sec ±0.15% (98 runs sampled) +gen-mapping: addMapping x 13,013 ops/sec ±0.11% (101 runs sampled) +source-map-js: addMapping x 4,564 ops/sec ±0.21% (98 runs sampled) +source-map-0.6.1: addMapping x 4,562 ops/sec ±0.11% (99 runs sampled) +source-map-0.8.0: addMapping x 4,593 ops/sec ±0.11% (100 runs sampled) +Fastest is gen-mapping: addSegment + +Generate speed: +gen-mapping: decoded output x 379,864,020 ops/sec ±0.23% (93 runs sampled) +gen-mapping: encoded output x 14,368 ops/sec ±4.07% (82 runs sampled) +source-map-js: encoded output x 5,261 ops/sec ±0.21% (99 runs sampled) +source-map-0.6.1: encoded output x 5,124 ops/sec ±0.58% (99 runs sampled) +source-map-0.8.0: encoded output x 5,434 ops/sec ±0.33% (96 runs sampled) +Fastest is gen-mapping: decoded output + + +*** + + +react.js.map +Memory Usage: +gen-mapping: addSegment 975096 bytes +gen-mapping: addMapping 1102981 bytes +source-map-js 2918836 bytes +source-map-0.6.1 2885435 bytes +source-map-0.8.0 2874336 bytes +Smallest memory usage is gen-mapping: addSegment + +Adding speed: +gen-mapping: addSegment x 4,772 ops/sec ±0.15% (100 runs sampled) +gen-mapping: addMapping x 4,456 ops/sec ±0.13% (97 runs sampled) +source-map-js: addMapping x 1,618 ops/sec ±0.24% (97 runs sampled) +source-map-0.6.1: addMapping x 1,622 ops/sec ±0.12% (99 runs sampled) +source-map-0.8.0: addMapping x 1,631 ops/sec ±0.12% (100 runs sampled) +Fastest is gen-mapping: addSegment + +Generate speed: +gen-mapping: decoded output x 379,107,695 ops/sec ±0.07% (99 runs sampled) +gen-mapping: encoded output x 5,421 ops/sec ±1.60% (89 runs sampled) +source-map-js: encoded output x 2,113 ops/sec ±1.81% (98 runs sampled) +source-map-0.6.1: encoded output x 2,126 ops/sec ±0.10% (100 runs sampled) +source-map-0.8.0: encoded output x 2,176 ops/sec ±0.39% (98 runs sampled) +Fastest is gen-mapping: decoded output +``` + +[source-map]: https://www.npmjs.com/package/source-map +[trace-mapping]: https://github.com/jridgewell/sourcemaps/tree/main/packages/trace-mapping diff --git a/node_modules/@jridgewell/gen-mapping/dist/gen-mapping.mjs b/node_modules/@jridgewell/gen-mapping/dist/gen-mapping.mjs new file mode 100644 index 0000000000000000000000000000000000000000..bbb0cacc5a77ef06b4a9921fe075914135d80f0f --- /dev/null +++ b/node_modules/@jridgewell/gen-mapping/dist/gen-mapping.mjs @@ -0,0 +1,292 @@ +// src/set-array.ts +var SetArray = class { + constructor() { + this._indexes = { __proto__: null }; + this.array = []; + } +}; +function cast(set) { + return set; +} +function get(setarr, key) { + return cast(setarr)._indexes[key]; +} +function put(setarr, key) { + const index = get(setarr, key); + if (index !== void 0) return index; + const { array, _indexes: indexes } = cast(setarr); + const length = array.push(key); + return indexes[key] = length - 1; +} +function remove(setarr, key) { + const index = get(setarr, key); + if (index === void 0) return; + const { array, _indexes: indexes } = cast(setarr); + for (let i = index + 1; i < array.length; i++) { + const k = array[i]; + array[i - 1] = k; + indexes[k]--; + } + indexes[key] = void 0; + array.pop(); +} + +// src/gen-mapping.ts +import { + encode +} from "@jridgewell/sourcemap-codec"; +import { TraceMap, decodedMappings } from "@jridgewell/trace-mapping"; + +// src/sourcemap-segment.ts +var COLUMN = 0; +var SOURCES_INDEX = 1; +var SOURCE_LINE = 2; +var SOURCE_COLUMN = 3; +var NAMES_INDEX = 4; + +// src/gen-mapping.ts +var NO_NAME = -1; +var GenMapping = class { + constructor({ file, sourceRoot } = {}) { + this._names = new SetArray(); + this._sources = new SetArray(); + this._sourcesContent = []; + this._mappings = []; + this.file = file; + this.sourceRoot = sourceRoot; + this._ignoreList = new SetArray(); + } +}; +function cast2(map) { + return map; +} +function addSegment(map, genLine, genColumn, source, sourceLine, sourceColumn, name, content) { + return addSegmentInternal( + false, + map, + genLine, + genColumn, + source, + sourceLine, + sourceColumn, + name, + content + ); +} +function addMapping(map, mapping) { + return addMappingInternal(false, map, mapping); +} +var maybeAddSegment = (map, genLine, genColumn, source, sourceLine, sourceColumn, name, content) => { + return addSegmentInternal( + true, + map, + genLine, + genColumn, + source, + sourceLine, + sourceColumn, + name, + content + ); +}; +var maybeAddMapping = (map, mapping) => { + return addMappingInternal(true, map, mapping); +}; +function setSourceContent(map, source, content) { + const { + _sources: sources, + _sourcesContent: sourcesContent + // _originalScopes: originalScopes, + } = cast2(map); + const index = put(sources, source); + sourcesContent[index] = content; +} +function setIgnore(map, source, ignore = true) { + const { + _sources: sources, + _sourcesContent: sourcesContent, + _ignoreList: ignoreList + // _originalScopes: originalScopes, + } = cast2(map); + const index = put(sources, source); + if (index === sourcesContent.length) sourcesContent[index] = null; + if (ignore) put(ignoreList, index); + else remove(ignoreList, index); +} +function toDecodedMap(map) { + const { + _mappings: mappings, + _sources: sources, + _sourcesContent: sourcesContent, + _names: names, + _ignoreList: ignoreList + // _originalScopes: originalScopes, + // _generatedRanges: generatedRanges, + } = cast2(map); + removeEmptyFinalLines(mappings); + return { + version: 3, + file: map.file || void 0, + names: names.array, + sourceRoot: map.sourceRoot || void 0, + sources: sources.array, + sourcesContent, + mappings, + // originalScopes, + // generatedRanges, + ignoreList: ignoreList.array + }; +} +function toEncodedMap(map) { + const decoded = toDecodedMap(map); + return Object.assign({}, decoded, { + // originalScopes: decoded.originalScopes.map((os) => encodeOriginalScopes(os)), + // generatedRanges: encodeGeneratedRanges(decoded.generatedRanges as GeneratedRange[]), + mappings: encode(decoded.mappings) + }); +} +function fromMap(input) { + const map = new TraceMap(input); + const gen = new GenMapping({ file: map.file, sourceRoot: map.sourceRoot }); + putAll(cast2(gen)._names, map.names); + putAll(cast2(gen)._sources, map.sources); + cast2(gen)._sourcesContent = map.sourcesContent || map.sources.map(() => null); + cast2(gen)._mappings = decodedMappings(map); + if (map.ignoreList) putAll(cast2(gen)._ignoreList, map.ignoreList); + return gen; +} +function allMappings(map) { + const out = []; + const { _mappings: mappings, _sources: sources, _names: names } = cast2(map); + for (let i = 0; i < mappings.length; i++) { + const line = mappings[i]; + for (let j = 0; j < line.length; j++) { + const seg = line[j]; + const generated = { line: i + 1, column: seg[COLUMN] }; + let source = void 0; + let original = void 0; + let name = void 0; + if (seg.length !== 1) { + source = sources.array[seg[SOURCES_INDEX]]; + original = { line: seg[SOURCE_LINE] + 1, column: seg[SOURCE_COLUMN] }; + if (seg.length === 5) name = names.array[seg[NAMES_INDEX]]; + } + out.push({ generated, source, original, name }); + } + } + return out; +} +function addSegmentInternal(skipable, map, genLine, genColumn, source, sourceLine, sourceColumn, name, content) { + const { + _mappings: mappings, + _sources: sources, + _sourcesContent: sourcesContent, + _names: names + // _originalScopes: originalScopes, + } = cast2(map); + const line = getIndex(mappings, genLine); + const index = getColumnIndex(line, genColumn); + if (!source) { + if (skipable && skipSourceless(line, index)) return; + return insert(line, index, [genColumn]); + } + assert(sourceLine); + assert(sourceColumn); + const sourcesIndex = put(sources, source); + const namesIndex = name ? put(names, name) : NO_NAME; + if (sourcesIndex === sourcesContent.length) sourcesContent[sourcesIndex] = content != null ? content : null; + if (skipable && skipSource(line, index, sourcesIndex, sourceLine, sourceColumn, namesIndex)) { + return; + } + return insert( + line, + index, + name ? [genColumn, sourcesIndex, sourceLine, sourceColumn, namesIndex] : [genColumn, sourcesIndex, sourceLine, sourceColumn] + ); +} +function assert(_val) { +} +function getIndex(arr, index) { + for (let i = arr.length; i <= index; i++) { + arr[i] = []; + } + return arr[index]; +} +function getColumnIndex(line, genColumn) { + let index = line.length; + for (let i = index - 1; i >= 0; index = i--) { + const current = line[i]; + if (genColumn >= current[COLUMN]) break; + } + return index; +} +function insert(array, index, value) { + for (let i = array.length; i > index; i--) { + array[i] = array[i - 1]; + } + array[index] = value; +} +function removeEmptyFinalLines(mappings) { + const { length } = mappings; + let len = length; + for (let i = len - 1; i >= 0; len = i, i--) { + if (mappings[i].length > 0) break; + } + if (len < length) mappings.length = len; +} +function putAll(setarr, array) { + for (let i = 0; i < array.length; i++) put(setarr, array[i]); +} +function skipSourceless(line, index) { + if (index === 0) return true; + const prev = line[index - 1]; + return prev.length === 1; +} +function skipSource(line, index, sourcesIndex, sourceLine, sourceColumn, namesIndex) { + if (index === 0) return false; + const prev = line[index - 1]; + if (prev.length === 1) return false; + return sourcesIndex === prev[SOURCES_INDEX] && sourceLine === prev[SOURCE_LINE] && sourceColumn === prev[SOURCE_COLUMN] && namesIndex === (prev.length === 5 ? prev[NAMES_INDEX] : NO_NAME); +} +function addMappingInternal(skipable, map, mapping) { + const { generated, source, original, name, content } = mapping; + if (!source) { + return addSegmentInternal( + skipable, + map, + generated.line - 1, + generated.column, + null, + null, + null, + null, + null + ); + } + assert(original); + return addSegmentInternal( + skipable, + map, + generated.line - 1, + generated.column, + source, + original.line - 1, + original.column, + name, + content + ); +} +export { + GenMapping, + addMapping, + addSegment, + allMappings, + fromMap, + maybeAddMapping, + maybeAddSegment, + setIgnore, + setSourceContent, + toDecodedMap, + toEncodedMap +}; +//# sourceMappingURL=gen-mapping.mjs.map diff --git a/node_modules/@jridgewell/gen-mapping/dist/gen-mapping.mjs.map b/node_modules/@jridgewell/gen-mapping/dist/gen-mapping.mjs.map new file mode 100644 index 0000000000000000000000000000000000000000..4e37e457b383d40504afea5419ff2b20afd0eb85 --- /dev/null +++ b/node_modules/@jridgewell/gen-mapping/dist/gen-mapping.mjs.map @@ -0,0 +1,6 @@ +{ + "version": 3, + "sources": ["../src/set-array.ts", "../src/gen-mapping.ts", "../src/sourcemap-segment.ts"], + "mappings": ";AAUO,IAAM,WAAN,MAAoC;AAAA,EAIzC,cAAc;AACZ,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e,KAAK,WAAW,KAC/B,iBAAiB,KAAK,aAAa,KACnC,gBAAgB,KAAK,WAAW,IAAI,KAAK,WAAW,IAAI;AAE5D;AAEA,SAAS,mBACP,UACA,KACA,SAOA;AACA,QAAM,EAAE,WAAW,QAAQ,UAAU,MAAM,QAAQ,IAAI;AACvD,MAAI,CAAC,QAAQ;AACX,WAAO;AAAA,MACL;AAAA,MACA;AAAA,MACA,UAAU,OAAO;AAAA,MACjB,UAAU;AAAA,MACV;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF;AACA,SAAY,QAAQ;AACpB,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA,UAAU,OAAO;AAAA,IACjB,UAAU;AAAA,IACV;AAAA,IACA,SAAS,OAAO;AAAA,IAChB,SAAS;AAAA,IACT;AAAA,IACA;AAAA,EACF;AACF;", + "names": ["cast"] +} diff --git a/node_modules/@jridgewell/gen-mapping/dist/gen-mapping.umd.js b/node_modules/@jridgewell/gen-mapping/dist/gen-mapping.umd.js new file mode 100644 index 0000000000000000000000000000000000000000..cb84af55fb03a9f4c966be7f375a4a151bb8c6c2 --- /dev/null +++ b/node_modules/@jridgewell/gen-mapping/dist/gen-mapping.umd.js @@ -0,0 +1,358 @@ +(function (global, factory) { + if (typeof exports === 'object' && typeof module !== 'undefined') { + factory(module, require('@jridgewell/sourcemap-codec'), require('@jridgewell/trace-mapping')); + module.exports = def(module); + } else if (typeof define === 'function' && define.amd) { + define(['module', '@jridgewell/sourcemap-codec', '@jridgewell/trace-mapping'], function(mod) { + factory.apply(this, arguments); + mod.exports = def(mod); + }); + } else { + const mod = { exports: {} }; + factory(mod, global.sourcemapCodec, global.traceMapping); + global = typeof globalThis !== 'undefined' ? globalThis : global || self; + global.genMapping = def(mod); + } + function def(m) { return 'default' in m.exports ? m.exports.default : m.exports; } +})(this, (function (module, require_sourcemapCodec, require_traceMapping) { +"use strict"; +var __create = Object.create; +var __defProp = Object.defineProperty; +var __getOwnPropDesc = Object.getOwnPropertyDescriptor; +var __getOwnPropNames = Object.getOwnPropertyNames; +var __getProtoOf = Object.getPrototypeOf; +var __hasOwnProp = Object.prototype.hasOwnProperty; +var __commonJS = (cb, mod) => function __require() { + return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports; +}; +var __export = (target, all) => { + for (var name in all) + __defProp(target, name, { get: all[name], enumerable: true }); +}; +var __copyProps = (to, from, except, desc) => { + if (from && typeof from === "object" || typeof from === "function") { + for (let key of __getOwnPropNames(from)) + if (!__hasOwnProp.call(to, key) && key !== except) + __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); + } + return to; +}; +var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( + // If the importer is in node compatibility mode or this is not an ESM + // file that has been converted to a CommonJS file using a Babel- + // compatible transform (i.e. "__esModule" has not been set), then set + // "default" to the CommonJS "module.exports" for node compatibility. + isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, + mod +)); +var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); + +// umd:@jridgewell/sourcemap-codec +var require_sourcemap_codec = __commonJS({ + "umd:@jridgewell/sourcemap-codec"(exports, module2) { + module2.exports = require_sourcemapCodec; + } +}); + +// umd:@jridgewell/trace-mapping +var require_trace_mapping = __commonJS({ + "umd:@jridgewell/trace-mapping"(exports, module2) { + module2.exports = require_traceMapping; + } +}); + +// src/gen-mapping.ts +var gen_mapping_exports = {}; +__export(gen_mapping_exports, { + GenMapping: () => GenMapping, + addMapping: () => addMapping, + addSegment: () => addSegment, + allMappings: () => allMappings, + fromMap: () => fromMap, + maybeAddMapping: () => maybeAddMapping, + maybeAddSegment: () => maybeAddSegment, + setIgnore: () => setIgnore, + setSourceContent: () => setSourceContent, + toDecodedMap: () => toDecodedMap, + toEncodedMap: () => toEncodedMap +}); +module.exports = __toCommonJS(gen_mapping_exports); + +// src/set-array.ts +var SetArray = class { + constructor() { + this._indexes = { __proto__: null }; + this.array = []; + } +}; +function cast(set) { + return set; +} +function get(setarr, key) { + return cast(setarr)._indexes[key]; +} +function put(setarr, key) { + const index = get(setarr, key); + if (index !== void 0) return index; + const { array, _indexes: indexes } = cast(setarr); + const length = array.push(key); + return indexes[key] = length - 1; +} +function remove(setarr, key) { + const index = get(setarr, key); + if (index === void 0) return; + const { array, _indexes: indexes } = cast(setarr); + for (let i = index + 1; i < array.length; i++) { + const k = array[i]; + array[i - 1] = k; + indexes[k]--; + } + indexes[key] = void 0; + array.pop(); +} + +// src/gen-mapping.ts +var import_sourcemap_codec = __toESM(require_sourcemap_codec()); +var import_trace_mapping = __toESM(require_trace_mapping()); + +// src/sourcemap-segment.ts +var COLUMN = 0; +var SOURCES_INDEX = 1; +var SOURCE_LINE = 2; +var SOURCE_COLUMN = 3; +var NAMES_INDEX = 4; + +// src/gen-mapping.ts +var NO_NAME = -1; +var GenMapping = class { + constructor({ file, sourceRoot } = {}) { + this._names = new SetArray(); + this._sources = new SetArray(); + this._sourcesContent = []; + this._mappings = []; + this.file = file; + this.sourceRoot = sourceRoot; + this._ignoreList = new SetArray(); + } +}; +function cast2(map) { + return map; +} +function addSegment(map, genLine, genColumn, source, sourceLine, sourceColumn, name, content) { + return addSegmentInternal( + false, + map, + genLine, + genColumn, + source, + sourceLine, + sourceColumn, + name, + content + ); +} +function addMapping(map, mapping) { + return addMappingInternal(false, map, mapping); +} +var maybeAddSegment = (map, genLine, genColumn, source, sourceLine, sourceColumn, name, content) => { + return addSegmentInternal( + true, + map, + genLine, + genColumn, + source, + sourceLine, + sourceColumn, + name, + content + ); +}; +var maybeAddMapping = (map, mapping) => { + return addMappingInternal(true, map, mapping); +}; +function setSourceContent(map, source, content) { + const { + _sources: sources, + _sourcesContent: sourcesContent + // _originalScopes: originalScopes, + } = cast2(map); + const index = put(sources, source); + sourcesContent[index] = content; +} +function setIgnore(map, source, ignore = true) { + const { + _sources: sources, + _sourcesContent: sourcesContent, + _ignoreList: ignoreList + // _originalScopes: originalScopes, + } = cast2(map); + const index = put(sources, source); + if (index === sourcesContent.length) sourcesContent[index] = null; + if (ignore) put(ignoreList, index); + else remove(ignoreList, index); +} +function toDecodedMap(map) { + const { + _mappings: mappings, + _sources: sources, + _sourcesContent: sourcesContent, + _names: names, + _ignoreList: ignoreList + // _originalScopes: originalScopes, + // _generatedRanges: generatedRanges, + } = cast2(map); + removeEmptyFinalLines(mappings); + return { + version: 3, + file: map.file || void 0, + names: names.array, + sourceRoot: map.sourceRoot || void 0, + sources: sources.array, + sourcesContent, + mappings, + // originalScopes, + // generatedRanges, + ignoreList: ignoreList.array + }; +} +function toEncodedMap(map) { + const decoded = toDecodedMap(map); + return Object.assign({}, decoded, { + // originalScopes: decoded.originalScopes.map((os) => encodeOriginalScopes(os)), + // generatedRanges: encodeGeneratedRanges(decoded.generatedRanges as GeneratedRange[]), + mappings: (0, import_sourcemap_codec.encode)(decoded.mappings) + }); +} +function fromMap(input) { + const map = new import_trace_mapping.TraceMap(input); + const gen = new GenMapping({ file: map.file, sourceRoot: map.sourceRoot }); + putAll(cast2(gen)._names, map.names); + putAll(cast2(gen)._sources, map.sources); + cast2(gen)._sourcesContent = map.sourcesContent || map.sources.map(() => null); + cast2(gen)._mappings = (0, import_trace_mapping.decodedMappings)(map); + if (map.ignoreList) putAll(cast2(gen)._ignoreList, map.ignoreList); + return gen; +} +function allMappings(map) { + const out = []; + const { _mappings: mappings, _sources: sources, _names: names } = cast2(map); + for (let i = 0; i < mappings.length; i++) { + const line = mappings[i]; + for (let j = 0; j < line.length; j++) { + const seg = line[j]; + const generated = { line: i + 1, column: seg[COLUMN] }; + let source = void 0; + let original = void 0; + let name = void 0; + if (seg.length !== 1) { + source = sources.array[seg[SOURCES_INDEX]]; + original = { line: seg[SOURCE_LINE] + 1, column: seg[SOURCE_COLUMN] }; + if (seg.length === 5) name = names.array[seg[NAMES_INDEX]]; + } + out.push({ generated, source, original, name }); + } + } + return out; +} +function addSegmentInternal(skipable, map, genLine, genColumn, source, sourceLine, sourceColumn, name, content) { + const { + _mappings: mappings, + _sources: sources, + _sourcesContent: sourcesContent, + _names: names + // _originalScopes: originalScopes, + } = cast2(map); + const line = getIndex(mappings, genLine); + const index = getColumnIndex(line, genColumn); + if (!source) { + if (skipable && skipSourceless(line, index)) return; + return insert(line, index, [genColumn]); + } + assert(sourceLine); + assert(sourceColumn); + const sourcesIndex = put(sources, source); + const namesIndex = name ? put(names, name) : NO_NAME; + if (sourcesIndex === sourcesContent.length) sourcesContent[sourcesIndex] = content != null ? content : null; + if (skipable && skipSource(line, index, sourcesIndex, sourceLine, sourceColumn, namesIndex)) { + return; + } + return insert( + line, + index, + name ? [genColumn, sourcesIndex, sourceLine, sourceColumn, namesIndex] : [genColumn, sourcesIndex, sourceLine, sourceColumn] + ); +} +function assert(_val) { +} +function getIndex(arr, index) { + for (let i = arr.length; i <= index; i++) { + arr[i] = []; + } + return arr[index]; +} +function getColumnIndex(line, genColumn) { + let index = line.length; + for (let i = index - 1; i >= 0; index = i--) { + const current = line[i]; + if (genColumn >= current[COLUMN]) break; + } + return index; +} +function insert(array, index, value) { + for (let i = array.length; i > index; i--) { + array[i] = array[i - 1]; + } + array[index] = value; +} +function removeEmptyFinalLines(mappings) { + const { length } = mappings; + let len = length; + for (let i = len - 1; i >= 0; len = i, i--) { + if (mappings[i].length > 0) break; + } + if (len < length) mappings.length = len; +} +function putAll(setarr, array) { + for (let i = 0; i < array.length; i++) put(setarr, array[i]); +} +function skipSourceless(line, index) { + if (index === 0) return true; + const prev = line[index - 1]; + return prev.length === 1; +} +function skipSource(line, index, sourcesIndex, sourceLine, sourceColumn, namesIndex) { + if (index === 0) return false; + const prev = line[index - 1]; + if (prev.length === 1) return false; + return sourcesIndex === prev[SOURCES_INDEX] && sourceLine === prev[SOURCE_LINE] && sourceColumn === prev[SOURCE_COLUMN] && namesIndex === (prev.length === 5 ? prev[NAMES_INDEX] : NO_NAME); +} +function addMappingInternal(skipable, map, mapping) { + const { generated, source, original, name, content } = mapping; + if (!source) { + return addSegmentInternal( + skipable, + map, + generated.line - 1, + generated.column, + null, + null, + null, + null, + null + ); + } + assert(original); + return addSegmentInternal( + skipable, + map, + generated.line - 1, + generated.column, + source, + original.line - 1, + original.column, + name, + content + ); +} +})); +//# sourceMappingURL=gen-mapping.umd.js.map diff --git a/node_modules/@jridgewell/gen-mapping/dist/gen-mapping.umd.js.map b/node_modules/@jridgewell/gen-mapping/dist/gen-mapping.umd.js.map new file mode 100644 index 0000000000000000000000000000000000000000..b13750bf67818b051645f7c332594e3cf7786375 --- /dev/null +++ b/node_modules/@jridgewell/gen-mapping/dist/gen-mapping.umd.js.map @@ -0,0 +1,6 @@ +{ + "version": 3, + "sources": ["umd:@jridgewell/sourcemap-codec", "umd:@jridgewell/trace-mapping", "../src/gen-mapping.ts", "../src/set-array.ts", "../src/sourcemap-segment.ts"], + "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA,6CAAAA,SAAA;AAAA,IAAAA,QAAO,UAAU;AAAA;AAAA;;;ACAjB;AAAA,2CAAAC,SAAA;AAAA,IAAAA,QAAO,UAAU;AAAA;AAAA;;;ACAjB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACUO,IAAM,WAAN,MAAoC;AAAA,EAIzC,cAAc;AACZ,SAAK,WAAW,EAAE,WAAW,KAAK;AAClC,SAAK,QAAQ,CAAC;AAAA,EAChB;AACF;AAWA,SAAS,KAAoB,KAAgC;AAC3D,SAAO;AACT;AAKO,SAAS,IAAmB,QAAqB,KAA4B;AAClF,SAAO,KAAK,MAAM,EAAE,SAAS,GAAG;AAClC;AAMO,SAAS,IAAmB,QAAqB,KAAgB;AAEtE,QAAM,QAAQ,IAAI,QAAQ,GAAG;AA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;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF;AACA,SAAY,QAAQ;AACpB,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA,UAAU,OAAO;AAAA,IACjB,UAAU;AAAA,IACV;AAAA,IACA,SAAS,OAAO;AAAA,IAChB,SAAS;AAAA,IACT;AAAA,IACA;AAAA,EACF;AACF;", + "names": ["module", "module", "cast"] +} diff --git a/node_modules/@jridgewell/gen-mapping/dist/types/gen-mapping.d.ts b/node_modules/@jridgewell/gen-mapping/dist/types/gen-mapping.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..9ba936e82bcf799e9d42bdb5ecd3ef11e978189e --- /dev/null +++ b/node_modules/@jridgewell/gen-mapping/dist/types/gen-mapping.d.ts @@ -0,0 +1,88 @@ +import type { SourceMapInput } from '@jridgewell/trace-mapping'; +import type { DecodedSourceMap, EncodedSourceMap, Pos, Mapping } from './types'; +export type { DecodedSourceMap, EncodedSourceMap, Mapping }; +export type Options = { + file?: string | null; + sourceRoot?: string | null; +}; +/** + * Provides the state to generate a sourcemap. + */ +export declare class GenMapping { + private _names; + private _sources; + private _sourcesContent; + private _mappings; + private _ignoreList; + file: string | null | undefined; + sourceRoot: string | null | undefined; + constructor({ file, sourceRoot }?: Options); +} +/** + * A low-level API to associate a generated position with an original source position. Line and + * column here are 0-based, unlike `addMapping`. + */ +export declare function addSegment(map: GenMapping, genLine: number, genColumn: number, source?: null, sourceLine?: null, sourceColumn?: null, name?: null, content?: null): void; +export declare function addSegment(map: GenMapping, genLine: number, genColumn: number, source: string, sourceLine: number, sourceColumn: number, name?: null, content?: string | null): void; +export declare function addSegment(map: GenMapping, genLine: number, genColumn: number, source: string, sourceLine: number, sourceColumn: number, name: string, content?: string | null): void; +/** + * A high-level API to associate a generated position with an original source position. Line is + * 1-based, but column is 0-based, due to legacy behavior in `source-map` library. + */ +export declare function addMapping(map: GenMapping, mapping: { + generated: Pos; + source?: null; + original?: null; + name?: null; + content?: null; +}): void; +export declare function addMapping(map: GenMapping, mapping: { + generated: Pos; + source: string; + original: Pos; + name?: null; + content?: string | null; +}): void; +export declare function addMapping(map: GenMapping, mapping: { + generated: Pos; + source: string; + original: Pos; + name: string; + content?: string | null; +}): void; +/** + * Same as `addSegment`, but will only add the segment if it generates useful information in the + * resulting map. This only works correctly if segments are added **in order**, meaning you should + * not add a segment with a lower generated line/column than one that came before. + */ +export declare const maybeAddSegment: typeof addSegment; +/** + * Same as `addMapping`, but will only add the mapping if it generates useful information in the + * resulting map. This only works correctly if mappings are added **in order**, meaning you should + * not add a mapping with a lower generated line/column than one that came before. + */ +export declare const maybeAddMapping: typeof addMapping; +/** + * Adds/removes the content of the source file to the source map. + */ +export declare function setSourceContent(map: GenMapping, source: string, content: string | null): void; +export declare function setIgnore(map: GenMapping, source: string, ignore?: boolean): void; +/** + * Returns a sourcemap object (with decoded mappings) suitable for passing to a library that expects + * a sourcemap, or to JSON.stringify. + */ +export declare function toDecodedMap(map: GenMapping): DecodedSourceMap; +/** + * Returns a sourcemap object (with encoded mappings) suitable for passing to a library that expects + * a sourcemap, or to JSON.stringify. + */ +export declare function toEncodedMap(map: GenMapping): EncodedSourceMap; +/** + * Constructs a new GenMapping, using the already present mappings of the input. + */ +export declare function fromMap(input: SourceMapInput): GenMapping; +/** + * Returns an array of high-level mapping objects for every recorded segment, which could then be + * passed to the `source-map` library. + */ +export declare function allMappings(map: GenMapping): Mapping[]; diff --git a/node_modules/@jridgewell/gen-mapping/dist/types/set-array.d.ts b/node_modules/@jridgewell/gen-mapping/dist/types/set-array.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..6ed43543e9c70b62a90af8dfe05c9e470532e083 --- /dev/null +++ b/node_modules/@jridgewell/gen-mapping/dist/types/set-array.d.ts @@ -0,0 +1,32 @@ +type Key = string | number | symbol; +/** + * SetArray acts like a `Set` (allowing only one occurrence of a string `key`), but provides the + * index of the `key` in the backing array. + * + * This is designed to allow synchronizing a second array with the contents of the backing array, + * like how in a sourcemap `sourcesContent[i]` is the source content associated with `source[i]`, + * and there are never duplicates. + */ +export declare class SetArray { + private _indexes; + array: readonly T[]; + constructor(); +} +/** + * Gets the index associated with `key` in the backing array, if it is already present. + */ +export declare function get(setarr: SetArray, key: T): number | undefined; +/** + * Puts `key` into the backing array, if it is not already present. Returns + * the index of the `key` in the backing array. + */ +export declare function put(setarr: SetArray, key: T): number; +/** + * Pops the last added item out of the SetArray. + */ +export declare function pop(setarr: SetArray): void; +/** + * Removes the key, if it exists in the set. + */ +export declare function remove(setarr: SetArray, key: T): void; +export {}; diff --git a/node_modules/@jridgewell/gen-mapping/dist/types/sourcemap-segment.d.ts b/node_modules/@jridgewell/gen-mapping/dist/types/sourcemap-segment.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..aa19fb5e72da1d12d3484c44b13daa608cece5ba --- /dev/null +++ b/node_modules/@jridgewell/gen-mapping/dist/types/sourcemap-segment.d.ts @@ -0,0 +1,12 @@ +type GeneratedColumn = number; +type SourcesIndex = number; +type SourceLine = number; +type SourceColumn = number; +type NamesIndex = number; +export type SourceMapSegment = [GeneratedColumn] | [GeneratedColumn, SourcesIndex, SourceLine, SourceColumn] | [GeneratedColumn, SourcesIndex, SourceLine, SourceColumn, NamesIndex]; +export declare const COLUMN = 0; +export declare const SOURCES_INDEX = 1; +export declare const SOURCE_LINE = 2; +export declare const SOURCE_COLUMN = 3; +export declare const NAMES_INDEX = 4; +export {}; diff --git a/node_modules/@jridgewell/gen-mapping/dist/types/types.d.ts b/node_modules/@jridgewell/gen-mapping/dist/types/types.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..8eb90fb47477b1e82336ff79f6caaab4722b38d7 --- /dev/null +++ b/node_modules/@jridgewell/gen-mapping/dist/types/types.d.ts @@ -0,0 +1,43 @@ +import type { SourceMapSegment } from './sourcemap-segment'; +export interface SourceMapV3 { + file?: string | null; + names: readonly string[]; + sourceRoot?: string; + sources: readonly (string | null)[]; + sourcesContent?: readonly (string | null)[]; + version: 3; + ignoreList?: readonly number[]; +} +export interface EncodedSourceMap extends SourceMapV3 { + mappings: string; +} +export interface DecodedSourceMap extends SourceMapV3 { + mappings: readonly SourceMapSegment[][]; +} +export interface Pos { + line: number; + column: number; +} +export interface OriginalPos extends Pos { + source: string; +} +export interface BindingExpressionRange { + start: Pos; + expression: string; +} +export type Mapping = { + generated: Pos; + source: undefined; + original: undefined; + name: undefined; +} | { + generated: Pos; + source: string; + original: Pos; + name: string; +} | { + generated: Pos; + source: string; + original: Pos; + name: undefined; +}; diff --git a/node_modules/@jridgewell/gen-mapping/package.json b/node_modules/@jridgewell/gen-mapping/package.json new file mode 100644 index 0000000000000000000000000000000000000000..036f9b799d93aca59d80244410216583eda2d97b --- /dev/null +++ b/node_modules/@jridgewell/gen-mapping/package.json @@ -0,0 +1,67 @@ +{ + "name": "@jridgewell/gen-mapping", + "version": "0.3.13", + "description": "Generate source maps", + "keywords": [ + "source", + "map" + ], + "main": "dist/gen-mapping.umd.js", + "module": "dist/gen-mapping.mjs", + "types": "types/gen-mapping.d.cts", + "files": [ + "dist", + "src", + "types" + ], + "exports": { + ".": [ + { + "import": { + "types": "./types/gen-mapping.d.mts", + "default": "./dist/gen-mapping.mjs" + }, + "default": { + "types": "./types/gen-mapping.d.cts", + "default": "./dist/gen-mapping.umd.js" + } + }, + "./dist/gen-mapping.umd.js" + ], + "./package.json": "./package.json" + }, + "scripts": { + "benchmark": "run-s build:code benchmark:*", + "benchmark:install": "cd benchmark && npm install", + "benchmark:only": "node --expose-gc benchmark/index.js", + "build": "run-s -n build:code build:types", + "build:code": "node ../../esbuild.mjs gen-mapping.ts", + "build:types": "run-s build:types:force build:types:emit build:types:mts", + "build:types:force": "rimraf tsconfig.build.tsbuildinfo", + "build:types:emit": "tsc --project tsconfig.build.json", + "build:types:mts": "node ../../mts-types.mjs", + "clean": "run-s -n clean:code clean:types", + "clean:code": "tsc --build --clean tsconfig.build.json", + "clean:types": "rimraf dist types", + "test": "run-s -n test:types test:only test:format", + "test:format": "prettier --check '{src,test}/**/*.ts'", + "test:only": "mocha", + "test:types": "eslint '{src,test}/**/*.ts'", + "lint": "run-s -n lint:types lint:format", + "lint:format": "npm run test:format -- --write", + "lint:types": "npm run test:types -- --fix", + "prepublishOnly": "npm run-s -n build test" + }, + "homepage": "https://github.com/jridgewell/sourcemaps/tree/main/packages/gen-mapping", + "repository": { + "type": "git", + "url": "git+https://github.com/jridgewell/sourcemaps.git", + "directory": "packages/gen-mapping" + }, + "author": "Justin Ridgewell ", + "license": "MIT", + "dependencies": { + "@jridgewell/sourcemap-codec": "^1.5.0", + "@jridgewell/trace-mapping": "^0.3.24" + } +} diff --git a/node_modules/@jridgewell/gen-mapping/src/gen-mapping.ts b/node_modules/@jridgewell/gen-mapping/src/gen-mapping.ts new file mode 100644 index 0000000000000000000000000000000000000000..ecc878c5755eea6e252d31475e3c0f87817140e0 --- /dev/null +++ b/node_modules/@jridgewell/gen-mapping/src/gen-mapping.ts @@ -0,0 +1,614 @@ +import { SetArray, put, remove } from './set-array'; +import { + encode, + // encodeGeneratedRanges, + // encodeOriginalScopes +} from '@jridgewell/sourcemap-codec'; +import { TraceMap, decodedMappings } from '@jridgewell/trace-mapping'; + +import { + COLUMN, + SOURCES_INDEX, + SOURCE_LINE, + SOURCE_COLUMN, + NAMES_INDEX, +} from './sourcemap-segment'; + +import type { SourceMapInput } from '@jridgewell/trace-mapping'; +// import type { OriginalScope, GeneratedRange } from '@jridgewell/sourcemap-codec'; +import type { SourceMapSegment } from './sourcemap-segment'; +import type { + DecodedSourceMap, + EncodedSourceMap, + Pos, + Mapping, + // BindingExpressionRange, + // OriginalPos, + // OriginalScopeInfo, + // GeneratedRangeInfo, +} from './types'; + +export type { DecodedSourceMap, EncodedSourceMap, Mapping }; + +export type Options = { + file?: string | null; + sourceRoot?: string | null; +}; + +const NO_NAME = -1; + +/** + * Provides the state to generate a sourcemap. + */ +export class GenMapping { + declare private _names: SetArray; + declare private _sources: SetArray; + declare private _sourcesContent: (string | null)[]; + declare private _mappings: SourceMapSegment[][]; + // private declare _originalScopes: OriginalScope[][]; + // private declare _generatedRanges: GeneratedRange[]; + declare private _ignoreList: SetArray; + declare file: string | null | undefined; + declare sourceRoot: string | null | undefined; + + constructor({ file, sourceRoot }: Options = {}) { + this._names = new SetArray(); + this._sources = new SetArray(); + this._sourcesContent = []; + this._mappings = []; + // this._originalScopes = []; + // this._generatedRanges = []; + this.file = file; + this.sourceRoot = sourceRoot; + this._ignoreList = new SetArray(); + } +} + +interface PublicMap { + _names: GenMapping['_names']; + _sources: GenMapping['_sources']; + _sourcesContent: GenMapping['_sourcesContent']; + _mappings: GenMapping['_mappings']; + // _originalScopes: GenMapping['_originalScopes']; + // _generatedRanges: GenMapping['_generatedRanges']; + _ignoreList: GenMapping['_ignoreList']; +} + +/** + * Typescript doesn't allow friend access to private fields, so this just casts the map into a type + * with public access modifiers. + */ +function cast(map: unknown): PublicMap { + return map as any; +} + +/** + * A low-level API to associate a generated position with an original source position. Line and + * column here are 0-based, unlike `addMapping`. + */ +export function addSegment( + map: GenMapping, + genLine: number, + genColumn: number, + source?: null, + sourceLine?: null, + sourceColumn?: null, + name?: null, + content?: null, +): void; +export function addSegment( + map: GenMapping, + genLine: number, + genColumn: number, + source: string, + sourceLine: number, + sourceColumn: number, + name?: null, + content?: string | null, +): void; +export function addSegment( + map: GenMapping, + genLine: number, + genColumn: number, + source: string, + sourceLine: number, + sourceColumn: number, + name: string, + content?: string | null, +): void; +export function addSegment( + map: GenMapping, + genLine: number, + genColumn: number, + source?: string | null, + sourceLine?: number | null, + sourceColumn?: number | null, + name?: string | null, + content?: string | null, +): void { + return addSegmentInternal( + false, + map, + genLine, + genColumn, + source, + sourceLine, + sourceColumn, + name, + content, + ); +} + +/** + * A high-level API to associate a generated position with an original source position. Line is + * 1-based, but column is 0-based, due to legacy behavior in `source-map` library. + */ +export function addMapping( + map: GenMapping, + mapping: { + generated: Pos; + source?: null; + original?: null; + name?: null; + content?: null; + }, +): void; +export function addMapping( + map: GenMapping, + mapping: { + generated: Pos; + source: string; + original: Pos; + name?: null; + content?: string | null; + }, +): void; +export function addMapping( + map: GenMapping, + mapping: { + generated: Pos; + source: string; + original: Pos; + name: string; + content?: string | null; + }, +): void; +export function addMapping( + map: GenMapping, + mapping: { + generated: Pos; + source?: string | null; + original?: Pos | null; + name?: string | null; + content?: string | null; + }, +): void { + return addMappingInternal(false, map, mapping as Parameters[2]); +} + +/** + * Same as `addSegment`, but will only add the segment if it generates useful information in the + * resulting map. This only works correctly if segments are added **in order**, meaning you should + * not add a segment with a lower generated line/column than one that came before. + */ +export const maybeAddSegment: typeof addSegment = ( + map, + genLine, + genColumn, + source, + sourceLine, + sourceColumn, + name, + content, +) => { + return addSegmentInternal( + true, + map, + genLine, + genColumn, + source, + sourceLine, + sourceColumn, + name, + content, + ); +}; + +/** + * Same as `addMapping`, but will only add the mapping if it generates useful information in the + * resulting map. This only works correctly if mappings are added **in order**, meaning you should + * not add a mapping with a lower generated line/column than one that came before. + */ +export const maybeAddMapping: typeof addMapping = (map, mapping) => { + return addMappingInternal(true, map, mapping as Parameters[2]); +}; + +/** + * Adds/removes the content of the source file to the source map. + */ +export function setSourceContent(map: GenMapping, source: string, content: string | null): void { + const { + _sources: sources, + _sourcesContent: sourcesContent, + // _originalScopes: originalScopes, + } = cast(map); + const index = put(sources, source); + sourcesContent[index] = content; + // if (index === originalScopes.length) originalScopes[index] = []; +} + +export function setIgnore(map: GenMapping, source: string, ignore = true) { + const { + _sources: sources, + _sourcesContent: sourcesContent, + _ignoreList: ignoreList, + // _originalScopes: originalScopes, + } = cast(map); + const index = put(sources, source); + if (index === sourcesContent.length) sourcesContent[index] = null; + // if (index === originalScopes.length) originalScopes[index] = []; + if (ignore) put(ignoreList, index); + else remove(ignoreList, index); +} + +/** + * Returns a sourcemap object (with decoded mappings) suitable for passing to a library that expects + * a sourcemap, or to JSON.stringify. + */ +export function toDecodedMap(map: GenMapping): DecodedSourceMap { + const { + _mappings: mappings, + _sources: sources, + _sourcesContent: sourcesContent, + _names: names, + _ignoreList: ignoreList, + // _originalScopes: originalScopes, + // _generatedRanges: generatedRanges, + } = cast(map); + removeEmptyFinalLines(mappings); + + return { + version: 3, + file: map.file || undefined, + names: names.array, + sourceRoot: map.sourceRoot || undefined, + sources: sources.array, + sourcesContent, + mappings, + // originalScopes, + // generatedRanges, + ignoreList: ignoreList.array, + }; +} + +/** + * Returns a sourcemap object (with encoded mappings) suitable for passing to a library that expects + * a sourcemap, or to JSON.stringify. + */ +export function toEncodedMap(map: GenMapping): EncodedSourceMap { + const decoded = toDecodedMap(map); + return Object.assign({}, decoded, { + // originalScopes: decoded.originalScopes.map((os) => encodeOriginalScopes(os)), + // generatedRanges: encodeGeneratedRanges(decoded.generatedRanges as GeneratedRange[]), + mappings: encode(decoded.mappings as SourceMapSegment[][]), + }); +} + +/** + * Constructs a new GenMapping, using the already present mappings of the input. + */ +export function fromMap(input: SourceMapInput): GenMapping { + const map = new TraceMap(input); + const gen = new GenMapping({ file: map.file, sourceRoot: map.sourceRoot }); + + putAll(cast(gen)._names, map.names); + putAll(cast(gen)._sources, map.sources as string[]); + cast(gen)._sourcesContent = map.sourcesContent || map.sources.map(() => null); + cast(gen)._mappings = decodedMappings(map) as GenMapping['_mappings']; + // TODO: implement originalScopes/generatedRanges + if (map.ignoreList) putAll(cast(gen)._ignoreList, map.ignoreList); + + return gen; +} + +/** + * Returns an array of high-level mapping objects for every recorded segment, which could then be + * passed to the `source-map` library. + */ +export function allMappings(map: GenMapping): Mapping[] { + const out: Mapping[] = []; + const { _mappings: mappings, _sources: sources, _names: names } = cast(map); + + for (let i = 0; i < mappings.length; i++) { + const line = mappings[i]; + for (let j = 0; j < line.length; j++) { + const seg = line[j]; + + const generated = { line: i + 1, column: seg[COLUMN] }; + let source: string | undefined = undefined; + let original: Pos | undefined = undefined; + let name: string | undefined = undefined; + + if (seg.length !== 1) { + source = sources.array[seg[SOURCES_INDEX]]; + original = { line: seg[SOURCE_LINE] + 1, column: seg[SOURCE_COLUMN] }; + + if (seg.length === 5) name = names.array[seg[NAMES_INDEX]]; + } + + out.push({ generated, source, original, name } as Mapping); + } + } + + return out; +} + +// This split declaration is only so that terser can elminiate the static initialization block. +function addSegmentInternal( + skipable: boolean, + map: GenMapping, + genLine: number, + genColumn: number, + source: S, + sourceLine: S extends string ? number : null | undefined, + sourceColumn: S extends string ? number : null | undefined, + name: S extends string ? string | null | undefined : null | undefined, + content: S extends string ? string | null | undefined : null | undefined, +): void { + const { + _mappings: mappings, + _sources: sources, + _sourcesContent: sourcesContent, + _names: names, + // _originalScopes: originalScopes, + } = cast(map); + const line = getIndex(mappings, genLine); + const index = getColumnIndex(line, genColumn); + + if (!source) { + if (skipable && skipSourceless(line, index)) return; + return insert(line, index, [genColumn]); + } + + // Sigh, TypeScript can't figure out sourceLine and sourceColumn aren't nullish if source + // isn't nullish. + assert(sourceLine); + assert(sourceColumn); + + const sourcesIndex = put(sources, source); + const namesIndex = name ? put(names, name) : NO_NAME; + if (sourcesIndex === sourcesContent.length) sourcesContent[sourcesIndex] = content ?? null; + // if (sourcesIndex === originalScopes.length) originalScopes[sourcesIndex] = []; + + if (skipable && skipSource(line, index, sourcesIndex, sourceLine, sourceColumn, namesIndex)) { + return; + } + + return insert( + line, + index, + name + ? [genColumn, sourcesIndex, sourceLine, sourceColumn, namesIndex] + : [genColumn, sourcesIndex, sourceLine, sourceColumn], + ); +} + +function assert(_val: unknown): asserts _val is T { + // noop. +} + +function getIndex(arr: T[][], index: number): T[] { + for (let i = arr.length; i <= index; i++) { + arr[i] = []; + } + return arr[index]; +} + +function getColumnIndex(line: SourceMapSegment[], genColumn: number): number { + let index = line.length; + for (let i = index - 1; i >= 0; index = i--) { + const current = line[i]; + if (genColumn >= current[COLUMN]) break; + } + return index; +} + +function insert(array: T[], index: number, value: T) { + for (let i = array.length; i > index; i--) { + array[i] = array[i - 1]; + } + array[index] = value; +} + +function removeEmptyFinalLines(mappings: SourceMapSegment[][]) { + const { length } = mappings; + let len = length; + for (let i = len - 1; i >= 0; len = i, i--) { + if (mappings[i].length > 0) break; + } + if (len < length) mappings.length = len; +} + +function putAll(setarr: SetArray, array: T[]) { + for (let i = 0; i < array.length; i++) put(setarr, array[i]); +} + +function skipSourceless(line: SourceMapSegment[], index: number): boolean { + // The start of a line is already sourceless, so adding a sourceless segment to the beginning + // doesn't generate any useful information. + if (index === 0) return true; + + const prev = line[index - 1]; + // If the previous segment is also sourceless, then adding another sourceless segment doesn't + // genrate any new information. Else, this segment will end the source/named segment and point to + // a sourceless position, which is useful. + return prev.length === 1; +} + +function skipSource( + line: SourceMapSegment[], + index: number, + sourcesIndex: number, + sourceLine: number, + sourceColumn: number, + namesIndex: number, +): boolean { + // A source/named segment at the start of a line gives position at that genColumn + if (index === 0) return false; + + const prev = line[index - 1]; + + // If the previous segment is sourceless, then we're transitioning to a source. + if (prev.length === 1) return false; + + // If the previous segment maps to the exact same source position, then this segment doesn't + // provide any new position information. + return ( + sourcesIndex === prev[SOURCES_INDEX] && + sourceLine === prev[SOURCE_LINE] && + sourceColumn === prev[SOURCE_COLUMN] && + namesIndex === (prev.length === 5 ? prev[NAMES_INDEX] : NO_NAME) + ); +} + +function addMappingInternal( + skipable: boolean, + map: GenMapping, + mapping: { + generated: Pos; + source: S; + original: S extends string ? Pos : null | undefined; + name: S extends string ? string | null | undefined : null | undefined; + content: S extends string ? string | null | undefined : null | undefined; + }, +) { + const { generated, source, original, name, content } = mapping; + if (!source) { + return addSegmentInternal( + skipable, + map, + generated.line - 1, + generated.column, + null, + null, + null, + null, + null, + ); + } + assert(original); + return addSegmentInternal( + skipable, + map, + generated.line - 1, + generated.column, + source as string, + original.line - 1, + original.column, + name, + content, + ); +} + +/* +export function addOriginalScope( + map: GenMapping, + data: { + start: Pos; + end: Pos; + source: string; + kind: string; + name?: string; + variables?: string[]; + }, +): OriginalScopeInfo { + const { start, end, source, kind, name, variables } = data; + const { + _sources: sources, + _sourcesContent: sourcesContent, + _originalScopes: originalScopes, + _names: names, + } = cast(map); + const index = put(sources, source); + if (index === sourcesContent.length) sourcesContent[index] = null; + if (index === originalScopes.length) originalScopes[index] = []; + + const kindIndex = put(names, kind); + const scope: OriginalScope = name + ? [start.line - 1, start.column, end.line - 1, end.column, kindIndex, put(names, name)] + : [start.line - 1, start.column, end.line - 1, end.column, kindIndex]; + if (variables) { + scope.vars = variables.map((v) => put(names, v)); + } + const len = originalScopes[index].push(scope); + return [index, len - 1, variables]; +} +*/ + +// Generated Ranges +/* +export function addGeneratedRange( + map: GenMapping, + data: { + start: Pos; + isScope: boolean; + originalScope?: OriginalScopeInfo; + callsite?: OriginalPos; + }, +): GeneratedRangeInfo { + const { start, isScope, originalScope, callsite } = data; + const { + _originalScopes: originalScopes, + _sources: sources, + _sourcesContent: sourcesContent, + _generatedRanges: generatedRanges, + } = cast(map); + + const range: GeneratedRange = [ + start.line - 1, + start.column, + 0, + 0, + originalScope ? originalScope[0] : -1, + originalScope ? originalScope[1] : -1, + ]; + if (originalScope?.[2]) { + range.bindings = originalScope[2].map(() => [[-1]]); + } + if (callsite) { + const index = put(sources, callsite.source); + if (index === sourcesContent.length) sourcesContent[index] = null; + if (index === originalScopes.length) originalScopes[index] = []; + range.callsite = [index, callsite.line - 1, callsite.column]; + } + if (isScope) range.isScope = true; + generatedRanges.push(range); + + return [range, originalScope?.[2]]; +} + +export function setEndPosition(range: GeneratedRangeInfo, pos: Pos) { + range[0][2] = pos.line - 1; + range[0][3] = pos.column; +} + +export function addBinding( + map: GenMapping, + range: GeneratedRangeInfo, + variable: string, + expression: string | BindingExpressionRange, +) { + const { _names: names } = cast(map); + const bindings = (range[0].bindings ||= []); + const vars = range[1]; + + const index = vars!.indexOf(variable); + const binding = getIndex(bindings, index); + + if (typeof expression === 'string') binding[0] = [put(names, expression)]; + else { + const { start } = expression; + binding.push([put(names, expression.expression), start.line - 1, start.column]); + } +} +*/ diff --git a/node_modules/@jridgewell/gen-mapping/src/set-array.ts b/node_modules/@jridgewell/gen-mapping/src/set-array.ts new file mode 100644 index 0000000000000000000000000000000000000000..a2a73a5229e176a34a4bb418bd1189999731b7a1 --- /dev/null +++ b/node_modules/@jridgewell/gen-mapping/src/set-array.ts @@ -0,0 +1,82 @@ +type Key = string | number | symbol; + +/** + * SetArray acts like a `Set` (allowing only one occurrence of a string `key`), but provides the + * index of the `key` in the backing array. + * + * This is designed to allow synchronizing a second array with the contents of the backing array, + * like how in a sourcemap `sourcesContent[i]` is the source content associated with `source[i]`, + * and there are never duplicates. + */ +export class SetArray { + declare private _indexes: Record; + declare array: readonly T[]; + + constructor() { + this._indexes = { __proto__: null } as any; + this.array = []; + } +} + +interface PublicSet { + array: T[]; + _indexes: SetArray['_indexes']; +} + +/** + * Typescript doesn't allow friend access to private fields, so this just casts the set into a type + * with public access modifiers. + */ +function cast(set: SetArray): PublicSet { + return set as any; +} + +/** + * Gets the index associated with `key` in the backing array, if it is already present. + */ +export function get(setarr: SetArray, key: T): number | undefined { + return cast(setarr)._indexes[key]; +} + +/** + * Puts `key` into the backing array, if it is not already present. Returns + * the index of the `key` in the backing array. + */ +export function put(setarr: SetArray, key: T): number { + // The key may or may not be present. If it is present, it's a number. + const index = get(setarr, key); + if (index !== undefined) return index; + + const { array, _indexes: indexes } = cast(setarr); + + const length = array.push(key); + return (indexes[key] = length - 1); +} + +/** + * Pops the last added item out of the SetArray. + */ +export function pop(setarr: SetArray): void { + const { array, _indexes: indexes } = cast(setarr); + if (array.length === 0) return; + + const last = array.pop()!; + indexes[last] = undefined; +} + +/** + * Removes the key, if it exists in the set. + */ +export function remove(setarr: SetArray, key: T): void { + const index = get(setarr, key); + if (index === undefined) return; + + const { array, _indexes: indexes } = cast(setarr); + for (let i = index + 1; i < array.length; i++) { + const k = array[i]; + array[i - 1] = k; + indexes[k]!--; + } + indexes[key] = undefined; + array.pop(); +} diff --git a/node_modules/@jridgewell/gen-mapping/src/sourcemap-segment.ts b/node_modules/@jridgewell/gen-mapping/src/sourcemap-segment.ts new file mode 100644 index 0000000000000000000000000000000000000000..fb296dd30234bc61899000bbcc706e71765264c8 --- /dev/null +++ b/node_modules/@jridgewell/gen-mapping/src/sourcemap-segment.ts @@ -0,0 +1,16 @@ +type GeneratedColumn = number; +type SourcesIndex = number; +type SourceLine = number; +type SourceColumn = number; +type NamesIndex = number; + +export type SourceMapSegment = + | [GeneratedColumn] + | [GeneratedColumn, SourcesIndex, SourceLine, SourceColumn] + | [GeneratedColumn, SourcesIndex, SourceLine, SourceColumn, NamesIndex]; + +export const COLUMN = 0; +export const SOURCES_INDEX = 1; +export const SOURCE_LINE = 2; +export const SOURCE_COLUMN = 3; +export const NAMES_INDEX = 4; diff --git a/node_modules/@jridgewell/gen-mapping/src/types.ts b/node_modules/@jridgewell/gen-mapping/src/types.ts new file mode 100644 index 0000000000000000000000000000000000000000..b087f706a0394e6f8921e92a9c005c3c6ac13de0 --- /dev/null +++ b/node_modules/@jridgewell/gen-mapping/src/types.ts @@ -0,0 +1,61 @@ +// import type { GeneratedRange, OriginalScope } from '@jridgewell/sourcemap-codec'; +import type { SourceMapSegment } from './sourcemap-segment'; + +export interface SourceMapV3 { + file?: string | null; + names: readonly string[]; + sourceRoot?: string; + sources: readonly (string | null)[]; + sourcesContent?: readonly (string | null)[]; + version: 3; + ignoreList?: readonly number[]; +} + +export interface EncodedSourceMap extends SourceMapV3 { + mappings: string; + // originalScopes: string[]; + // generatedRanges: string; +} + +export interface DecodedSourceMap extends SourceMapV3 { + mappings: readonly SourceMapSegment[][]; + // originalScopes: readonly OriginalScope[][]; + // generatedRanges: readonly GeneratedRange[]; +} + +export interface Pos { + line: number; // 1-based + column: number; // 0-based +} + +export interface OriginalPos extends Pos { + source: string; +} + +export interface BindingExpressionRange { + start: Pos; + expression: string; +} + +// export type OriginalScopeInfo = [number, number, string[] | undefined]; +// export type GeneratedRangeInfo = [GeneratedRange, string[] | undefined]; + +export type Mapping = + | { + generated: Pos; + source: undefined; + original: undefined; + name: undefined; + } + | { + generated: Pos; + source: string; + original: Pos; + name: string; + } + | { + generated: Pos; + source: string; + original: Pos; + name: undefined; + }; diff --git a/node_modules/@jridgewell/gen-mapping/types/gen-mapping.d.cts b/node_modules/@jridgewell/gen-mapping/types/gen-mapping.d.cts new file mode 100644 index 0000000000000000000000000000000000000000..7618d8572b325324ccde88eb0a046a0bed73626e --- /dev/null +++ b/node_modules/@jridgewell/gen-mapping/types/gen-mapping.d.cts @@ -0,0 +1,89 @@ +import type { SourceMapInput } from '@jridgewell/trace-mapping'; +import type { DecodedSourceMap, EncodedSourceMap, Pos, Mapping } from './types.cts'; +export type { DecodedSourceMap, EncodedSourceMap, Mapping }; +export type Options = { + file?: string | null; + sourceRoot?: string | null; +}; +/** + * Provides the state to generate a sourcemap. + */ +export declare class GenMapping { + private _names; + private _sources; + private _sourcesContent; + private _mappings; + private _ignoreList; + file: string | null | undefined; + sourceRoot: string | null | undefined; + constructor({ file, sourceRoot }?: Options); +} +/** + * A low-level API to associate a generated position with an original source position. Line and + * column here are 0-based, unlike `addMapping`. + */ +export declare function addSegment(map: GenMapping, genLine: number, genColumn: number, source?: null, sourceLine?: null, sourceColumn?: null, name?: null, content?: null): void; +export declare function addSegment(map: GenMapping, genLine: number, genColumn: number, source: string, sourceLine: number, sourceColumn: number, name?: null, content?: string | null): void; +export declare function addSegment(map: GenMapping, genLine: number, genColumn: number, source: string, sourceLine: number, sourceColumn: number, name: string, content?: string | null): void; +/** + * A high-level API to associate a generated position with an original source position. Line is + * 1-based, but column is 0-based, due to legacy behavior in `source-map` library. + */ +export declare function addMapping(map: GenMapping, mapping: { + generated: Pos; + source?: null; + original?: null; + name?: null; + content?: null; +}): void; +export declare function addMapping(map: GenMapping, mapping: { + generated: Pos; + source: string; + original: Pos; + name?: null; + content?: string | null; +}): void; +export declare function addMapping(map: GenMapping, mapping: { + generated: Pos; + source: string; + original: Pos; + name: string; + content?: string | null; +}): void; +/** + * Same as `addSegment`, but will only add the segment if it generates useful information in the + * resulting map. This only works correctly if segments are added **in order**, meaning you should + * not add a segment with a lower generated line/column than one that came before. + */ +export declare const maybeAddSegment: typeof addSegment; +/** + * Same as `addMapping`, but will only add the mapping if it generates useful information in the + * resulting map. This only works correctly if mappings are added **in order**, meaning you should + * not add a mapping with a lower generated line/column than one that came before. + */ +export declare const maybeAddMapping: typeof addMapping; +/** + * Adds/removes the content of the source file to the source map. + */ +export declare function setSourceContent(map: GenMapping, source: string, content: string | null): void; +export declare function setIgnore(map: GenMapping, source: string, ignore?: boolean): void; +/** + * Returns a sourcemap object (with decoded mappings) suitable for passing to a library that expects + * a sourcemap, or to JSON.stringify. + */ +export declare function toDecodedMap(map: GenMapping): DecodedSourceMap; +/** + * Returns a sourcemap object (with encoded mappings) suitable for passing to a library that expects + * a sourcemap, or to JSON.stringify. + */ +export declare function toEncodedMap(map: GenMapping): EncodedSourceMap; +/** + * Constructs a new GenMapping, using the already present mappings of the input. + */ +export declare function fromMap(input: SourceMapInput): GenMapping; +/** + * Returns an array of high-level mapping objects for every recorded segment, which could then be + * passed to the `source-map` library. + */ +export declare function allMappings(map: GenMapping): Mapping[]; +//# sourceMappingURL=gen-mapping.d.ts.map \ No newline at end of file diff --git a/node_modules/@jridgewell/gen-mapping/types/gen-mapping.d.cts.map b/node_modules/@jridgewell/gen-mapping/types/gen-mapping.d.cts.map new file mode 100644 index 0000000000000000000000000000000000000000..8a2b1835336445da0c96f2785ce5b8625a3af4c7 --- /dev/null +++ b/node_modules/@jridgewell/gen-mapping/types/gen-mapping.d.cts.map @@ -0,0 +1 @@ +{"version":3,"file":"gen-mapping.d.ts","sourceRoot":"","sources":["../src/gen-mapping.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAGhE,OAAO,KAAK,EACV,gBAAgB,EAChB,gBAAgB,EAChB,GAAG,EACH,OAAO,EAKR,MAAM,SAAS,CAAC;AAEjB,YAAY,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,OAAO,EAAE,C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AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,UAAU,GAAG,gBAAgB,CAO9D;AAED;;GAEG;AACH,wBAAgB,OAAO,CAAC,KAAK,EAAE,cAAc,GAAG,UAAU,CAYzD;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,UAAU,GAAG,OAAO,EAAE,CA0BtD"} \ No newline at end of file diff --git a/node_modules/@jridgewell/gen-mapping/types/gen-mapping.d.mts b/node_modules/@jridgewell/gen-mapping/types/gen-mapping.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..bbc0d89cfd861c2c66cdb2458956c013bd59508e --- /dev/null +++ b/node_modules/@jridgewell/gen-mapping/types/gen-mapping.d.mts @@ -0,0 +1,89 @@ +import type { SourceMapInput } from '@jridgewell/trace-mapping'; +import type { DecodedSourceMap, EncodedSourceMap, Pos, Mapping } from './types.mts'; +export type { DecodedSourceMap, EncodedSourceMap, Mapping }; +export type Options = { + file?: string | null; + sourceRoot?: string | null; +}; +/** + * Provides the state to generate a sourcemap. + */ +export declare class GenMapping { + private _names; + private _sources; + private _sourcesContent; + private _mappings; + private _ignoreList; + file: string | null | undefined; + sourceRoot: string | null | undefined; + constructor({ file, sourceRoot }?: Options); +} +/** + * A low-level API to associate a generated position with an original source position. Line and + * column here are 0-based, unlike `addMapping`. + */ +export declare function addSegment(map: GenMapping, genLine: number, genColumn: number, source?: null, sourceLine?: null, sourceColumn?: null, name?: null, content?: null): void; +export declare function addSegment(map: GenMapping, genLine: number, genColumn: number, source: string, sourceLine: number, sourceColumn: number, name?: null, content?: string | null): void; +export declare function addSegment(map: GenMapping, genLine: number, genColumn: number, source: string, sourceLine: number, sourceColumn: number, name: string, content?: string | null): void; +/** + * A high-level API to associate a generated position with an original source position. Line is + * 1-based, but column is 0-based, due to legacy behavior in `source-map` library. + */ +export declare function addMapping(map: GenMapping, mapping: { + generated: Pos; + source?: null; + original?: null; + name?: null; + content?: null; +}): void; +export declare function addMapping(map: GenMapping, mapping: { + generated: Pos; + source: string; + original: Pos; + name?: null; + content?: string | null; +}): void; +export declare function addMapping(map: GenMapping, mapping: { + generated: Pos; + source: string; + original: Pos; + name: string; + content?: string | null; +}): void; +/** + * Same as `addSegment`, but will only add the segment if it generates useful information in the + * resulting map. This only works correctly if segments are added **in order**, meaning you should + * not add a segment with a lower generated line/column than one that came before. + */ +export declare const maybeAddSegment: typeof addSegment; +/** + * Same as `addMapping`, but will only add the mapping if it generates useful information in the + * resulting map. This only works correctly if mappings are added **in order**, meaning you should + * not add a mapping with a lower generated line/column than one that came before. + */ +export declare const maybeAddMapping: typeof addMapping; +/** + * Adds/removes the content of the source file to the source map. + */ +export declare function setSourceContent(map: GenMapping, source: string, content: string | null): void; +export declare function setIgnore(map: GenMapping, source: string, ignore?: boolean): void; +/** + * Returns a sourcemap object (with decoded mappings) suitable for passing to a library that expects + * a sourcemap, or to JSON.stringify. + */ +export declare function toDecodedMap(map: GenMapping): DecodedSourceMap; +/** + * Returns a sourcemap object (with encoded mappings) suitable for passing to a library that expects + * a sourcemap, or to JSON.stringify. + */ +export declare function toEncodedMap(map: GenMapping): EncodedSourceMap; +/** + * Constructs a new GenMapping, using the already present mappings of the input. + */ +export declare function fromMap(input: SourceMapInput): GenMapping; +/** + * Returns an array of high-level mapping objects for every recorded segment, which could then be + * passed to the `source-map` library. + */ +export declare function allMappings(map: GenMapping): Mapping[]; +//# sourceMappingURL=gen-mapping.d.ts.map \ No newline at end of file diff --git a/node_modules/@jridgewell/gen-mapping/types/gen-mapping.d.mts.map b/node_modules/@jridgewell/gen-mapping/types/gen-mapping.d.mts.map new file mode 100644 index 0000000000000000000000000000000000000000..8a2b1835336445da0c96f2785ce5b8625a3af4c7 --- /dev/null +++ b/node_modules/@jridgewell/gen-mapping/types/gen-mapping.d.mts.map @@ -0,0 +1 @@ +{"version":3,"file":"gen-mapping.d.ts","sourceRoot":"","sources":["../src/gen-mapping.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,cAAc,EAAE,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gB,SAAS,CAAC,GAAG,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,UAAO,QAYvE;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,UAAU,GAAG,gBAAgB,CAwB9D;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,UAAU,GAAG,gBAAgB,CAO9D;AAED;;GAEG;AACH,wBAAgB,OAAO,CAAC,KAAK,EAAE,cAAc,GAAG,UAAU,CAYzD;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,UAAU,GAAG,OAAO,EAAE,CA0BtD"} \ No newline at end of file diff --git a/node_modules/@jridgewell/gen-mapping/types/set-array.d.cts b/node_modules/@jridgewell/gen-mapping/types/set-array.d.cts new file mode 100644 index 0000000000000000000000000000000000000000..5d8cda35a7e698625549fc38e9d89a6c7e89fadf --- /dev/null +++ b/node_modules/@jridgewell/gen-mapping/types/set-array.d.cts @@ -0,0 +1,33 @@ +type Key = string | number | symbol; +/** + * SetArray acts like a `Set` (allowing only one occurrence of a string `key`), but provides the + * index of the `key` in the backing array. + * + * This is designed to allow synchronizing a second array with the contents of the backing array, + * like how in a sourcemap `sourcesContent[i]` is the source content associated with `source[i]`, + * and there are never duplicates. + */ +export declare class SetArray { + private _indexes; + array: readonly T[]; + constructor(); +} +/** + * Gets the index associated with `key` in the backing array, if it is already present. + */ +export declare function get(setarr: SetArray, key: T): number | undefined; +/** + * Puts `key` into the backing array, if it is not already present. Returns + * the index of the `key` in the backing array. + */ +export declare function put(setarr: SetArray, key: T): number; +/** + * Pops the last added item out of the SetArray. + */ +export declare function pop(setarr: SetArray): void; +/** + * Removes the key, if it exists in the set. + */ +export declare function remove(setarr: SetArray, key: T): void; +export {}; +//# sourceMappingURL=set-array.d.ts.map \ No newline at end of file diff --git a/node_modules/@jridgewell/gen-mapping/types/set-array.d.cts.map b/node_modules/@jridgewell/gen-mapping/types/set-array.d.cts.map new file mode 100644 index 0000000000000000000000000000000000000000..c52b8bcee0042015be193c19481001d8e8fbd01f --- /dev/null +++ b/node_modules/@jridgewell/gen-mapping/types/set-array.d.cts.map @@ -0,0 +1 @@ +{"version":3,"file":"set-array.d.ts","sourceRoot":"","sources":["../src/set-array.ts"],"names":[],"mappings":"AAAA,KAAK,GAAG,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC;AAEpC;;;;;;;GAOG;AACH,qBAAa,QAAQ,CAAC,CAAC,SAAS,GAAG,GAAG,GAAG;IACvC,QAAgB,QAAQ,CAAgC;IAChD,KAAK,EAAE,SAAS,CAAC,EAAE,CAAC;;CAM7B;AAeD;;GAEG;AACH,wBAAgB,GAAG,CAAC,CAAC,SAAS,GAAG,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,GAAG,MAAM,GAAG,SAAS,CAElF;AAED;;;GAGG;AACH,wBAAgB,GAAG,CAAC,CAAC,SAAS,GAAG,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,GAAG,MAAM,CAStE;AAED;;GAEG;AACH,wBAAgB,GAAG,CAAC,CAAC,SAAS,GAAG,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC,GAAG,IAAI,CAM5D;AAED;;GAEG;AACH,wBAAgB,MAAM,CAAC,CAAC,SAAS,GAAG,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,GAAG,IAAI,CAYvE"} \ No newline at end of file diff --git a/node_modules/@jridgewell/gen-mapping/types/set-array.d.mts b/node_modules/@jridgewell/gen-mapping/types/set-array.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..5d8cda35a7e698625549fc38e9d89a6c7e89fadf --- /dev/null +++ b/node_modules/@jridgewell/gen-mapping/types/set-array.d.mts @@ -0,0 +1,33 @@ +type Key = string | number | symbol; +/** + * SetArray acts like a `Set` (allowing only one occurrence of a string `key`), but provides the + * index of the `key` in the backing array. + * + * This is designed to allow synchronizing a second array with the contents of the backing array, + * like how in a sourcemap `sourcesContent[i]` is the source content associated with `source[i]`, + * and there are never duplicates. + */ +export declare class SetArray { + private _indexes; + array: readonly T[]; + constructor(); +} +/** + * Gets the index associated with `key` in the backing array, if it is already present. + */ +export declare function get(setarr: SetArray, key: T): number | undefined; +/** + * Puts `key` into the backing array, if it is not already present. Returns + * the index of the `key` in the backing array. + */ +export declare function put(setarr: SetArray, key: T): number; +/** + * Pops the last added item out of the SetArray. + */ +export declare function pop(setarr: SetArray): void; +/** + * Removes the key, if it exists in the set. + */ +export declare function remove(setarr: SetArray, key: T): void; +export {}; +//# sourceMappingURL=set-array.d.ts.map \ No newline at end of file diff --git a/node_modules/@jridgewell/gen-mapping/types/set-array.d.mts.map b/node_modules/@jridgewell/gen-mapping/types/set-array.d.mts.map new file mode 100644 index 0000000000000000000000000000000000000000..c52b8bcee0042015be193c19481001d8e8fbd01f --- /dev/null +++ b/node_modules/@jridgewell/gen-mapping/types/set-array.d.mts.map @@ -0,0 +1 @@ +{"version":3,"file":"set-array.d.ts","sourceRoot":"","sources":["../src/set-array.ts"],"names":[],"mappings":"AAAA,KAAK,GAAG,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC;AAEpC;;;;;;;GAOG;AACH,qBAAa,QAAQ,CAAC,CAAC,SAAS,GAAG,GAAG,GAAG;IACvC,QAAgB,QAAQ,CAAgC;IAChD,KAAK,EAAE,SAAS,CAAC,EAAE,CAAC;;CAM7B;AAeD;;GAEG;AACH,wBAAgB,GAAG,CAAC,CAAC,SAAS,GAAG,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,GAAG,MAAM,GAAG,SAAS,CAElF;AAED;;;GAGG;AACH,wBAAgB,GAAG,CAAC,CAAC,SAAS,GAAG,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,GAAG,MAAM,CAStE;AAED;;GAEG;AACH,wBAAgB,GAAG,CAAC,CAAC,SAAS,GAAG,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC,GAAG,IAAI,CAM5D;AAED;;GAEG;AACH,wBAAgB,MAAM,CAAC,CAAC,SAAS,GAAG,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,GAAG,IAAI,CAYvE"} \ No newline at end of file diff --git a/node_modules/@jridgewell/gen-mapping/types/sourcemap-segment.d.cts b/node_modules/@jridgewell/gen-mapping/types/sourcemap-segment.d.cts new file mode 100644 index 0000000000000000000000000000000000000000..68862952d54b0caba765fcd7c04f64bed329756d --- /dev/null +++ b/node_modules/@jridgewell/gen-mapping/types/sourcemap-segment.d.cts @@ -0,0 +1,13 @@ +type GeneratedColumn = number; +type SourcesIndex = number; +type SourceLine = number; +type SourceColumn = number; +type NamesIndex = number; +export type SourceMapSegment = [GeneratedColumn] | [GeneratedColumn, SourcesIndex, SourceLine, SourceColumn] | [GeneratedColumn, SourcesIndex, SourceLine, SourceColumn, NamesIndex]; +export declare const COLUMN = 0; +export declare const SOURCES_INDEX = 1; +export declare const SOURCE_LINE = 2; +export declare const SOURCE_COLUMN = 3; +export declare const NAMES_INDEX = 4; +export {}; +//# sourceMappingURL=sourcemap-segment.d.ts.map \ No newline at end of file diff --git a/node_modules/@jridgewell/gen-mapping/types/sourcemap-segment.d.cts.map b/node_modules/@jridgewell/gen-mapping/types/sourcemap-segment.d.cts.map new file mode 100644 index 0000000000000000000000000000000000000000..23cdc45288829ff39c538527202d24649c8a78ff --- /dev/null +++ b/node_modules/@jridgewell/gen-mapping/types/sourcemap-segment.d.cts.map @@ -0,0 +1 @@ +{"version":3,"file":"sourcemap-segment.d.ts","sourceRoot":"","sources":["../src/sourcemap-segment.ts"],"names":[],"mappings":"AAAA,KAAK,eAAe,GAAG,MAAM,CAAC;AAC9B,KAAK,YAAY,GAAG,MAAM,CAAC;AAC3B,KAAK,UAAU,GAAG,MAAM,CAAC;AACzB,KAAK,YAAY,GAAG,MAAM,CAAC;AAC3B,KAAK,UAAU,GAAG,MAAM,CAAC;AAEzB,MAAM,MAAM,gBAAgB,GACxB,CAAC,eAAe,CAAC,GACjB,CAAC,eAAe,EAAE,YAAY,EAAE,UAAU,EAAE,YAAY,CAAC,GACzD,CAAC,eAAe,EAAE,YAAY,EAAE,UAAU,EAAE,YAAY,EAAE,UAAU,CAAC,CAAC;AAE1E,eAAO,MAAM,MAAM,IAAI,CAAC;AACxB,eAAO,MAAM,aAAa,IAAI,CAAC;AAC/B,eAAO,MAAM,WAAW,IAAI,CAAC;AAC7B,eAAO,MAAM,aAAa,IAAI,CAAC;AAC/B,eAAO,MAAM,WAAW,IAAI,CAAC"} \ No newline at end of file diff --git a/node_modules/@jridgewell/gen-mapping/types/sourcemap-segment.d.mts b/node_modules/@jridgewell/gen-mapping/types/sourcemap-segment.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..68862952d54b0caba765fcd7c04f64bed329756d --- /dev/null +++ b/node_modules/@jridgewell/gen-mapping/types/sourcemap-segment.d.mts @@ -0,0 +1,13 @@ +type GeneratedColumn = number; +type SourcesIndex = number; +type SourceLine = number; +type SourceColumn = number; +type NamesIndex = number; +export type SourceMapSegment = [GeneratedColumn] | [GeneratedColumn, SourcesIndex, SourceLine, SourceColumn] | [GeneratedColumn, SourcesIndex, SourceLine, SourceColumn, NamesIndex]; +export declare const COLUMN = 0; +export declare const SOURCES_INDEX = 1; +export declare const SOURCE_LINE = 2; +export declare const SOURCE_COLUMN = 3; +export declare const NAMES_INDEX = 4; +export {}; +//# sourceMappingURL=sourcemap-segment.d.ts.map \ No newline at end of file diff --git a/node_modules/@jridgewell/gen-mapping/types/sourcemap-segment.d.mts.map b/node_modules/@jridgewell/gen-mapping/types/sourcemap-segment.d.mts.map new file mode 100644 index 0000000000000000000000000000000000000000..23cdc45288829ff39c538527202d24649c8a78ff --- /dev/null +++ b/node_modules/@jridgewell/gen-mapping/types/sourcemap-segment.d.mts.map @@ -0,0 +1 @@ +{"version":3,"file":"sourcemap-segment.d.ts","sourceRoot":"","sources":["../src/sourcemap-segment.ts"],"names":[],"mappings":"AAAA,KAAK,eAAe,GAAG,MAAM,CAAC;AAC9B,KAAK,YAAY,GAAG,MAAM,CAAC;AAC3B,KAAK,UAAU,GAAG,MAAM,CAAC;AACzB,KAAK,YAAY,GAAG,MAAM,CAAC;AAC3B,KAAK,UAAU,GAAG,MAAM,CAAC;AAEzB,MAAM,MAAM,gBAAgB,GACxB,CAAC,eAAe,CAAC,GACjB,CAAC,eAAe,EAAE,YAAY,EAAE,UAAU,EAAE,YAAY,CAAC,GACzD,CAAC,eAAe,EAAE,YAAY,EAAE,UAAU,EAAE,YAAY,EAAE,UAAU,CAAC,CAAC;AAE1E,eAAO,MAAM,MAAM,IAAI,CAAC;AACxB,eAAO,MAAM,aAAa,IAAI,CAAC;AAC/B,eAAO,MAAM,WAAW,IAAI,CAAC;AAC7B,eAAO,MAAM,aAAa,IAAI,CAAC;AAC/B,eAAO,MAAM,WAAW,IAAI,CAAC"} \ No newline at end of file diff --git a/node_modules/@jridgewell/gen-mapping/types/types.d.cts b/node_modules/@jridgewell/gen-mapping/types/types.d.cts new file mode 100644 index 0000000000000000000000000000000000000000..58da00a9fb250d52be96d60c70ee7ccdd1cd0deb --- /dev/null +++ b/node_modules/@jridgewell/gen-mapping/types/types.d.cts @@ -0,0 +1,44 @@ +import type { SourceMapSegment } from './sourcemap-segment.cts'; +export interface SourceMapV3 { + file?: string | null; + names: readonly string[]; + sourceRoot?: string; + sources: readonly (string | null)[]; + sourcesContent?: readonly (string | null)[]; + version: 3; + ignoreList?: readonly number[]; +} +export interface EncodedSourceMap extends SourceMapV3 { + mappings: string; +} +export interface DecodedSourceMap extends SourceMapV3 { + mappings: readonly SourceMapSegment[][]; +} +export interface Pos { + line: number; + column: number; +} +export interface OriginalPos extends Pos { + source: string; +} +export interface BindingExpressionRange { + start: Pos; + expression: string; +} +export type Mapping = { + generated: Pos; + source: undefined; + original: undefined; + name: undefined; +} | { + generated: Pos; + source: string; + original: Pos; + name: string; +} | { + generated: Pos; + source: string; + original: Pos; + name: undefined; +}; +//# sourceMappingURL=types.d.ts.map \ No newline at end of file diff --git a/node_modules/@jridgewell/gen-mapping/types/types.d.cts.map b/node_modules/@jridgewell/gen-mapping/types/types.d.cts.map new file mode 100644 index 0000000000000000000000000000000000000000..159e734d5f994f5ed32fcdc1640096994dc12d72 --- /dev/null +++ b/node_modules/@jridgewell/gen-mapping/types/types.d.cts.map @@ -0,0 +1 @@ +{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAE5D,MAAM,WAAW,WAAW;IAC1B,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;IACzB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,SAAS,CAAC,MAAM,GAAG,IAAI,CAAC,EAAE,CAAC;IACpC,cAAc,CAAC,EAAE,SAAS,CAAC,MAAM,GAAG,IAAI,CAAC,EAAE,CAAC;IAC5C,OAAO,EAAE,CAAC,CAAC;IACX,UAAU,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CAChC;AAED,MAAM,WAAW,gBAAiB,SAAQ,WAAW;IACnD,QAAQ,EAAE,MAAM,CAAC;CAGlB;AAED,MAAM,WAAW,gBAAiB,SAAQ,WAAW;IACnD,QAAQ,EAAE,SAAS,gBAAgB,EAAE,EAAE,CAAC;CAGzC;AAED,MAAM,WAAW,GAAG;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,WAAY,SAAQ,GAAG;IACtC,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,sBAAsB;IACrC,KAAK,EAAE,GAAG,CAAC;IACX,UAAU,EAAE,MAAM,CAAC;CACpB;AAKD,MAAM,MAAM,OAAO,GACf;IACE,SAAS,EAAE,GAAG,CAAC;IACf,MAAM,EAAE,SAAS,CAAC;IAClB,QAAQ,EAAE,SAAS,CAAC;IACpB,IAAI,EAAE,SAAS,CAAC;CACjB,GACD;IACE,SAAS,EAAE,GAAG,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,GAAG,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;CACd,GACD;IACE,SAAS,EAAE,GAAG,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,GAAG,CAAC;IACd,IAAI,EAAE,SAAS,CAAC;CACjB,CAAC"} \ No newline at end of file diff --git a/node_modules/@jridgewell/gen-mapping/types/types.d.mts b/node_modules/@jridgewell/gen-mapping/types/types.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..e9837ebe53aa653a2a295e60069813f47e456fc3 --- /dev/null +++ b/node_modules/@jridgewell/gen-mapping/types/types.d.mts @@ -0,0 +1,44 @@ +import type { SourceMapSegment } from './sourcemap-segment.mts'; +export interface SourceMapV3 { + file?: string | null; + names: readonly string[]; + sourceRoot?: string; + sources: readonly (string | null)[]; + sourcesContent?: readonly (string | null)[]; + version: 3; + ignoreList?: readonly number[]; +} +export interface EncodedSourceMap extends SourceMapV3 { + mappings: string; +} +export interface DecodedSourceMap extends SourceMapV3 { + mappings: readonly SourceMapSegment[][]; +} +export interface Pos { + line: number; + column: number; +} +export interface OriginalPos extends Pos { + source: string; +} +export interface BindingExpressionRange { + start: Pos; + expression: string; +} +export type Mapping = { + generated: Pos; + source: undefined; + original: undefined; + name: undefined; +} | { + generated: Pos; + source: string; + original: Pos; + name: string; +} | { + generated: Pos; + source: string; + original: Pos; + name: undefined; +}; +//# sourceMappingURL=types.d.ts.map \ No newline at end of file diff --git a/node_modules/@jridgewell/gen-mapping/types/types.d.mts.map b/node_modules/@jridgewell/gen-mapping/types/types.d.mts.map new file mode 100644 index 0000000000000000000000000000000000000000..159e734d5f994f5ed32fcdc1640096994dc12d72 --- /dev/null +++ b/node_modules/@jridgewell/gen-mapping/types/types.d.mts.map @@ -0,0 +1 @@ +{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAE5D,MAAM,WAAW,WAAW;IAC1B,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;IACzB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,SAAS,CAAC,MAAM,GAAG,IAAI,CAAC,EAAE,CAAC;IACpC,cAAc,CAAC,EAAE,SAAS,CAAC,MAAM,GAAG,IAAI,CAAC,EAAE,CAAC;IAC5C,OAAO,EAAE,CAAC,CAAC;IACX,UAAU,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CAChC;AAED,MAAM,WAAW,gBAAiB,SAAQ,WAAW;IACnD,QAAQ,EAAE,MAAM,CAAC;CAGlB;AAED,MAAM,WAAW,gBAAiB,SAAQ,WAAW;IACnD,QAAQ,EAAE,SAAS,gBAAgB,EAAE,EAAE,CAAC;CAGzC;AAED,MAAM,WAAW,GAAG;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,WAAY,SAAQ,GAAG;IACtC,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,sBAAsB;IACrC,KAAK,EAAE,GAAG,CAAC;IACX,UAAU,EAAE,MAAM,CAAC;CACpB;AAKD,MAAM,MAAM,OAAO,GACf;IACE,SAAS,EAAE,GAAG,CAAC;IACf,MAAM,EAAE,SAAS,CAAC;IAClB,QAAQ,EAAE,SAAS,CAAC;IACpB,IAAI,EAAE,SAAS,CAAC;CACjB,GACD;IACE,SAAS,EAAE,GAAG,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,GAAG,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;CACd,GACD;IACE,SAAS,EAAE,GAAG,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,GAAG,CAAC;IACd,IAAI,EAAE,SAAS,CAAC;CACjB,CAAC"} \ No newline at end of file diff --git a/node_modules/@jridgewell/remapping/LICENSE b/node_modules/@jridgewell/remapping/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..1f6ce94c11912496b96298630d84753dbf593a7d --- /dev/null +++ b/node_modules/@jridgewell/remapping/LICENSE @@ -0,0 +1,19 @@ +Copyright 2024 Justin Ridgewell + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/node_modules/@jridgewell/remapping/README.md b/node_modules/@jridgewell/remapping/README.md new file mode 100644 index 0000000000000000000000000000000000000000..6d092d7eaad3a73a8f094a63b7fe85fe714ef9eb --- /dev/null +++ b/node_modules/@jridgewell/remapping/README.md @@ -0,0 +1,218 @@ +# @jridgewell/remapping + +> Remap sequential sourcemaps through transformations to point at the original source code + +Remapping allows you to take the sourcemaps generated through transforming your code and "remap" +them to the original source locations. Think "my minified code, transformed with babel and bundled +with webpack", all pointing to the correct location in your original source code. + +With remapping, none of your source code transformations need to be aware of the input's sourcemap, +they only need to generate an output sourcemap. This greatly simplifies building custom +transformations (think a find-and-replace). + +## Installation + +```sh +npm install @jridgewell/remapping +``` + +## Usage + +```typescript +function remapping( + map: SourceMap | SourceMap[], + loader: (file: string, ctx: LoaderContext) => (SourceMap | null | undefined), + options?: { excludeContent: boolean, decodedMappings: boolean } +): SourceMap; + +// LoaderContext gives the loader the importing sourcemap, tree depth, the ability to override the +// "source" location (where child sources are resolved relative to, or the location of original +// source), and the ability to override the "content" of an original source for inclusion in the +// output sourcemap. +type LoaderContext = { + readonly importer: string; + readonly depth: number; + source: string; + content: string | null | undefined; +} +``` + +`remapping` takes the final output sourcemap, and a `loader` function. For every source file pointer +in the sourcemap, the `loader` will be called with the resolved path. If the path itself represents +a transformed file (it has a sourcmap associated with it), then the `loader` should return that +sourcemap. If not, the path will be treated as an original, untransformed source code. + +```js +// Babel transformed "helloworld.js" into "transformed.js" +const transformedMap = JSON.stringify({ + file: 'transformed.js', + // 1st column of 2nd line of output file translates into the 1st source + // file, line 3, column 2 + mappings: ';CAEE', + sources: ['helloworld.js'], + version: 3, +}); + +// Uglify minified "transformed.js" into "transformed.min.js" +const minifiedTransformedMap = JSON.stringify({ + file: 'transformed.min.js', + // 0th column of 1st line of output file translates into the 1st source + // file, line 2, column 1. + mappings: 'AACC', + names: [], + sources: ['transformed.js'], + version: 3, +}); + +const remapped = remapping( + minifiedTransformedMap, + (file, ctx) => { + + // The "transformed.js" file is an transformed file. + if (file === 'transformed.js') { + // The root importer is empty. + console.assert(ctx.importer === ''); + // The depth in the sourcemap tree we're currently loading. + // The root `minifiedTransformedMap` is depth 0, and its source children are depth 1, etc. + console.assert(ctx.depth === 1); + + return transformedMap; + } + + // Loader will be called to load transformedMap's source file pointers as well. + console.assert(file === 'helloworld.js'); + // `transformed.js`'s sourcemap points into `helloworld.js`. + console.assert(ctx.importer === 'transformed.js'); + // This is a source child of `transformed`, which is a source child of `minifiedTransformedMap`. + console.assert(ctx.depth === 2); + return null; + } +); + +console.log(remapped); +// { +// file: 'transpiled.min.js', +// mappings: 'AAEE', +// sources: ['helloworld.js'], +// version: 3, +// }; +``` + +In this example, `loader` will be called twice: + +1. `"transformed.js"`, the first source file pointer in the `minifiedTransformedMap`. We return the + associated sourcemap for it (its a transformed file, after all) so that sourcemap locations can + be traced through it into the source files it represents. +2. `"helloworld.js"`, our original, unmodified source code. This file does not have a sourcemap, so + we return `null`. + +The `remapped` sourcemap now points from `transformed.min.js` into locations in `helloworld.js`. If +you were to read the `mappings`, it says "0th column of the first line output line points to the 1st +column of the 2nd line of the file `helloworld.js`". + +### Multiple transformations of a file + +As a convenience, if you have multiple single-source transformations of a file, you may pass an +array of sourcemap files in the order of most-recent transformation sourcemap first. Note that this +changes the `importer` and `depth` of each call to our loader. So our above example could have been +written as: + +```js +const remapped = remapping( + [minifiedTransformedMap, transformedMap], + () => null +); + +console.log(remapped); +// { +// file: 'transpiled.min.js', +// mappings: 'AAEE', +// sources: ['helloworld.js'], +// version: 3, +// }; +``` + +### Advanced control of the loading graph + +#### `source` + +The `source` property can overridden to any value to change the location of the current load. Eg, +for an original source file, it allows us to change the location to the original source regardless +of what the sourcemap source entry says. And for transformed files, it allows us to change the +relative resolving location for child sources of the loaded sourcemap. + +```js +const remapped = remapping( + minifiedTransformedMap, + (file, ctx) => { + + if (file === 'transformed.js') { + // We pretend the transformed.js file actually exists in the 'src/' directory. When the nested + // source files are loaded, they will now be relative to `src/`. + ctx.source = 'src/transformed.js'; + return transformedMap; + } + + console.assert(file === 'src/helloworld.js'); + // We could futher change the source of this original file, eg, to be inside a nested directory + // itself. This will be reflected in the remapped sourcemap. + ctx.source = 'src/nested/transformed.js'; + return null; + } +); + +console.log(remapped); +// { +// …, +// sources: ['src/nested/helloworld.js'], +// }; +``` + + +#### `content` + +The `content` property can be overridden when we encounter an original source file. Eg, this allows +you to manually provide the source content of the original file regardless of whether the +`sourcesContent` field is present in the parent sourcemap. It can also be set to `null` to remove +the source content. + +```js +const remapped = remapping( + minifiedTransformedMap, + (file, ctx) => { + + if (file === 'transformed.js') { + // transformedMap does not include a `sourcesContent` field, so usually the remapped sourcemap + // would not include any `sourcesContent` values. + return transformedMap; + } + + console.assert(file === 'helloworld.js'); + // We can read the file to provide the source content. + ctx.content = fs.readFileSync(file, 'utf8'); + return null; + } +); + +console.log(remapped); +// { +// …, +// sourcesContent: [ +// 'console.log("Hello world!")', +// ], +// }; +``` + +### Options + +#### excludeContent + +By default, `excludeContent` is `false`. Passing `{ excludeContent: true }` will exclude the +`sourcesContent` field from the returned sourcemap. This is mainly useful when you want to reduce +the size out the sourcemap. + +#### decodedMappings + +By default, `decodedMappings` is `false`. Passing `{ decodedMappings: true }` will leave the +`mappings` field in a [decoded state](https://github.com/rich-harris/sourcemap-codec) instead of +encoding into a VLQ string. diff --git a/node_modules/@jridgewell/remapping/dist/remapping.mjs b/node_modules/@jridgewell/remapping/dist/remapping.mjs new file mode 100644 index 0000000000000000000000000000000000000000..8b7009c049e3188f5fda149852d3e17fd5de4009 --- /dev/null +++ b/node_modules/@jridgewell/remapping/dist/remapping.mjs @@ -0,0 +1,144 @@ +// src/build-source-map-tree.ts +import { TraceMap } from "@jridgewell/trace-mapping"; + +// src/source-map-tree.ts +import { GenMapping, maybeAddSegment, setIgnore, setSourceContent } from "@jridgewell/gen-mapping"; +import { traceSegment, decodedMappings } from "@jridgewell/trace-mapping"; +var SOURCELESS_MAPPING = /* @__PURE__ */ SegmentObject("", -1, -1, "", null, false); +var EMPTY_SOURCES = []; +function SegmentObject(source, line, column, name, content, ignore) { + return { source, line, column, name, content, ignore }; +} +function Source(map, sources, source, content, ignore) { + return { + map, + sources, + source, + content, + ignore + }; +} +function MapSource(map, sources) { + return Source(map, sources, "", null, false); +} +function OriginalSource(source, content, ignore) { + return Source(null, EMPTY_SOURCES, source, content, ignore); +} +function traceMappings(tree) { + const gen = new GenMapping({ file: tree.map.file }); + const { sources: rootSources, map } = tree; + const rootNames = map.names; + const rootMappings = decodedMappings(map); + for (let i = 0; i < rootMappings.length; i++) { + const segments = rootMappings[i]; + for (let j = 0; j < segments.length; j++) { + const segment = segments[j]; + const genCol = segment[0]; + let traced = SOURCELESS_MAPPING; + if (segment.length !== 1) { + const source2 = rootSources[segment[1]]; + traced = originalPositionFor( + source2, + segment[2], + segment[3], + segment.length === 5 ? rootNames[segment[4]] : "" + ); + if (traced == null) continue; + } + const { column, line, name, content, source, ignore } = traced; + maybeAddSegment(gen, i, genCol, source, line, column, name); + if (source && content != null) setSourceContent(gen, source, content); + if (ignore) setIgnore(gen, source, true); + } + } + return gen; +} +function originalPositionFor(source, line, column, name) { + if (!source.map) { + return SegmentObject(source.source, line, column, name, source.content, source.ignore); + } + const segment = traceSegment(source.map, line, column); + if (segment == null) return null; + if (segment.length === 1) return SOURCELESS_MAPPING; + return originalPositionFor( + source.sources[segment[1]], + segment[2], + segment[3], + segment.length === 5 ? source.map.names[segment[4]] : name + ); +} + +// src/build-source-map-tree.ts +function asArray(value) { + if (Array.isArray(value)) return value; + return [value]; +} +function buildSourceMapTree(input, loader) { + const maps = asArray(input).map((m) => new TraceMap(m, "")); + const map = maps.pop(); + for (let i = 0; i < maps.length; i++) { + if (maps[i].sources.length > 1) { + throw new Error( + `Transformation map ${i} must have exactly one source file. +Did you specify these with the most recent transformation maps first?` + ); + } + } + let tree = build(map, loader, "", 0); + for (let i = maps.length - 1; i >= 0; i--) { + tree = MapSource(maps[i], [tree]); + } + return tree; +} +function build(map, loader, importer, importerDepth) { + const { resolvedSources, sourcesContent, ignoreList } = map; + const depth = importerDepth + 1; + const children = resolvedSources.map((sourceFile, i) => { + const ctx = { + importer, + depth, + source: sourceFile || "", + content: void 0, + ignore: void 0 + }; + const sourceMap = loader(ctx.source, ctx); + const { source, content, ignore } = ctx; + if (sourceMap) return build(new TraceMap(sourceMap, source), loader, source, depth); + const sourceContent = content !== void 0 ? content : sourcesContent ? sourcesContent[i] : null; + const ignored = ignore !== void 0 ? ignore : ignoreList ? ignoreList.includes(i) : false; + return OriginalSource(source, sourceContent, ignored); + }); + return MapSource(map, children); +} + +// src/source-map.ts +import { toDecodedMap, toEncodedMap } from "@jridgewell/gen-mapping"; +var SourceMap = class { + constructor(map, options) { + const out = options.decodedMappings ? toDecodedMap(map) : toEncodedMap(map); + this.version = out.version; + this.file = out.file; + this.mappings = out.mappings; + this.names = out.names; + this.ignoreList = out.ignoreList; + this.sourceRoot = out.sourceRoot; + this.sources = out.sources; + if (!options.excludeContent) { + this.sourcesContent = out.sourcesContent; + } + } + toString() { + return JSON.stringify(this); + } +}; + +// src/remapping.ts +function remapping(input, loader, options) { + const opts = typeof options === "object" ? options : { excludeContent: !!options, decodedMappings: false }; + const tree = buildSourceMapTree(input, loader); + return new SourceMap(traceMappings(tree), opts); +} +export { + remapping as default +}; +//# sourceMappingURL=remapping.mjs.map diff --git a/node_modules/@jridgewell/remapping/dist/remapping.mjs.map b/node_modules/@jridgewell/remapping/dist/remapping.mjs.map new file mode 100644 index 0000000000000000000000000000000000000000..66801e6d1c7566a5873a127112df792aac35347d --- /dev/null +++ b/node_modules/@jridgewell/remapping/dist/remapping.mjs.map @@ -0,0 +1,6 @@ +{ + "version": 3, + "sources": ["../src/build-source-map-tree.ts", "../src/source-map-tree.ts", "../src/source-map.ts", "../src/remapping.ts"], + "mappings": ";AAAA,SAAS,gBAAgB;;;ACAzB,SAAS,YAAY,iBAAiB,WAAW,wBAAwB;AACzE,SAAS,cAAc,uBAAuB;AA+B9C,IAAM,qBAAqC,8BAAc,IAAI,IAAI,IAAI,IAAI,MAAM,KAAK;AACpF,IAAM,gBAA2B,CAAC;AAElC,SAAS,cACP,QACA,MACA,QACA,MACA,SACA,QACwB;AACxB,SAAO,EAAE,QAAQ,MAAM,QAAQ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;AAChD;", + "names": ["source"] +} diff --git a/node_modules/@jridgewell/remapping/dist/remapping.umd.js b/node_modules/@jridgewell/remapping/dist/remapping.umd.js new file mode 100644 index 0000000000000000000000000000000000000000..077eb4d5dc61564539a2f580533940f4f5ad7e23 --- /dev/null +++ b/node_modules/@jridgewell/remapping/dist/remapping.umd.js @@ -0,0 +1,212 @@ +(function (global, factory) { + if (typeof exports === 'object' && typeof module !== 'undefined') { + factory(module, require('@jridgewell/gen-mapping'), require('@jridgewell/trace-mapping')); + module.exports = def(module); + } else if (typeof define === 'function' && define.amd) { + define(['module', '@jridgewell/gen-mapping', '@jridgewell/trace-mapping'], function(mod) { + factory.apply(this, arguments); + mod.exports = def(mod); + }); + } else { + const mod = { exports: {} }; + factory(mod, global.genMapping, global.traceMapping); + global = typeof globalThis !== 'undefined' ? globalThis : global || self; + global.remapping = def(mod); + } + function def(m) { return 'default' in m.exports ? m.exports.default : m.exports; } +})(this, (function (module, require_genMapping, require_traceMapping) { +"use strict"; +var __create = Object.create; +var __defProp = Object.defineProperty; +var __getOwnPropDesc = Object.getOwnPropertyDescriptor; +var __getOwnPropNames = Object.getOwnPropertyNames; +var __getProtoOf = Object.getPrototypeOf; +var __hasOwnProp = Object.prototype.hasOwnProperty; +var __commonJS = (cb, mod) => function __require() { + return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports; +}; +var __export = (target, all) => { + for (var name in all) + __defProp(target, name, { get: all[name], enumerable: true }); +}; +var __copyProps = (to, from, except, desc) => { + if (from && typeof from === "object" || typeof from === "function") { + for (let key of __getOwnPropNames(from)) + if (!__hasOwnProp.call(to, key) && key !== except) + __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); + } + return to; +}; +var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( + // If the importer is in node compatibility mode or this is not an ESM + // file that has been converted to a CommonJS file using a Babel- + // compatible transform (i.e. "__esModule" has not been set), then set + // "default" to the CommonJS "module.exports" for node compatibility. + isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, + mod +)); +var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); + +// umd:@jridgewell/trace-mapping +var require_trace_mapping = __commonJS({ + "umd:@jridgewell/trace-mapping"(exports, module2) { + module2.exports = require_traceMapping; + } +}); + +// umd:@jridgewell/gen-mapping +var require_gen_mapping = __commonJS({ + "umd:@jridgewell/gen-mapping"(exports, module2) { + module2.exports = require_genMapping; + } +}); + +// src/remapping.ts +var remapping_exports = {}; +__export(remapping_exports, { + default: () => remapping +}); +module.exports = __toCommonJS(remapping_exports); + +// src/build-source-map-tree.ts +var import_trace_mapping2 = __toESM(require_trace_mapping()); + +// src/source-map-tree.ts +var import_gen_mapping = __toESM(require_gen_mapping()); +var import_trace_mapping = __toESM(require_trace_mapping()); +var SOURCELESS_MAPPING = /* @__PURE__ */ SegmentObject("", -1, -1, "", null, false); +var EMPTY_SOURCES = []; +function SegmentObject(source, line, column, name, content, ignore) { + return { source, line, column, name, content, ignore }; +} +function Source(map, sources, source, content, ignore) { + return { + map, + sources, + source, + content, + ignore + }; +} +function MapSource(map, sources) { + return Source(map, sources, "", null, false); +} +function OriginalSource(source, content, ignore) { + return Source(null, EMPTY_SOURCES, source, content, ignore); +} +function traceMappings(tree) { + const gen = new import_gen_mapping.GenMapping({ file: tree.map.file }); + const { sources: rootSources, map } = tree; + const rootNames = map.names; + const rootMappings = (0, import_trace_mapping.decodedMappings)(map); + for (let i = 0; i < rootMappings.length; i++) { + const segments = rootMappings[i]; + for (let j = 0; j < segments.length; j++) { + const segment = segments[j]; + const genCol = segment[0]; + let traced = SOURCELESS_MAPPING; + if (segment.length !== 1) { + const source2 = rootSources[segment[1]]; + traced = originalPositionFor( + source2, + segment[2], + segment[3], + segment.length === 5 ? rootNames[segment[4]] : "" + ); + if (traced == null) continue; + } + const { column, line, name, content, source, ignore } = traced; + (0, import_gen_mapping.maybeAddSegment)(gen, i, genCol, source, line, column, name); + if (source && content != null) (0, import_gen_mapping.setSourceContent)(gen, source, content); + if (ignore) (0, import_gen_mapping.setIgnore)(gen, source, true); + } + } + return gen; +} +function originalPositionFor(source, line, column, name) { + if (!source.map) { + return SegmentObject(source.source, line, column, name, source.content, source.ignore); + } + const segment = (0, import_trace_mapping.traceSegment)(source.map, line, column); + if (segment == null) return null; + if (segment.length === 1) return SOURCELESS_MAPPING; + return originalPositionFor( + source.sources[segment[1]], + segment[2], + segment[3], + segment.length === 5 ? source.map.names[segment[4]] : name + ); +} + +// src/build-source-map-tree.ts +function asArray(value) { + if (Array.isArray(value)) return value; + return [value]; +} +function buildSourceMapTree(input, loader) { + const maps = asArray(input).map((m) => new import_trace_mapping2.TraceMap(m, "")); + const map = maps.pop(); + for (let i = 0; i < maps.length; i++) { + if (maps[i].sources.length > 1) { + throw new Error( + `Transformation map ${i} must have exactly one source file. +Did you specify these with the most recent transformation maps first?` + ); + } + } + let tree = build(map, loader, "", 0); + for (let i = maps.length - 1; i >= 0; i--) { + tree = MapSource(maps[i], [tree]); + } + return tree; +} +function build(map, loader, importer, importerDepth) { + const { resolvedSources, sourcesContent, ignoreList } = map; + const depth = importerDepth + 1; + const children = resolvedSources.map((sourceFile, i) => { + const ctx = { + importer, + depth, + source: sourceFile || "", + content: void 0, + ignore: void 0 + }; + const sourceMap = loader(ctx.source, ctx); + const { source, content, ignore } = ctx; + if (sourceMap) return build(new import_trace_mapping2.TraceMap(sourceMap, source), loader, source, depth); + const sourceContent = content !== void 0 ? content : sourcesContent ? sourcesContent[i] : null; + const ignored = ignore !== void 0 ? ignore : ignoreList ? ignoreList.includes(i) : false; + return OriginalSource(source, sourceContent, ignored); + }); + return MapSource(map, children); +} + +// src/source-map.ts +var import_gen_mapping2 = __toESM(require_gen_mapping()); +var SourceMap = class { + constructor(map, options) { + const out = options.decodedMappings ? (0, import_gen_mapping2.toDecodedMap)(map) : (0, import_gen_mapping2.toEncodedMap)(map); + this.version = out.version; + this.file = out.file; + this.mappings = out.mappings; + this.names = out.names; + this.ignoreList = out.ignoreList; + this.sourceRoot = out.sourceRoot; + this.sources = out.sources; + if (!options.excludeContent) { + this.sourcesContent = out.sourcesContent; + } + } + toString() { + return JSON.stringify(this); + } +}; + +// src/remapping.ts +function remapping(input, loader, options) { + const opts = typeof options === "object" ? options : { excludeContent: !!options, decodedMappings: false }; + const tree = buildSourceMapTree(input, loader); + return new SourceMap(traceMappings(tree), opts); +} +})); +//# sourceMappingURL=remapping.umd.js.map diff --git a/node_modules/@jridgewell/remapping/dist/remapping.umd.js.map b/node_modules/@jridgewell/remapping/dist/remapping.umd.js.map new file mode 100644 index 0000000000000000000000000000000000000000..d5e0786411414c3565f1914751a7a1c0073153eb --- /dev/null +++ b/node_modules/@jridgewell/remapping/dist/remapping.umd.js.map @@ -0,0 +1,6 @@ +{ + "version": 3, + "sources": ["umd:@jridgewell/trace-mapping", "umd:@jridgewell/gen-mapping", "../src/remapping.ts", "../src/build-source-map-tree.ts", "../src/source-map-tree.ts", "../src/source-map.ts"], + "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA,2CAAAA,SAAA;AAAA,IAAAA,QAAO,UAAU;AAAA;AAAA;;;ACAjB;AAAA,yCAAAC,SAAA;AAAA,IAAAA,QAAO,UAAU;AAAA;AAAA;;;ACAjB;AAAA;AAAA;AAAA;AAAA;;;ACAA,IAAAC,wBAAyB;;;ACAzB,yBAAyE;AACzE,2BAA8C;AA+B9C,IAAM,qBAAqC,8BAAc,IAAI,IAAI,IAAI,IAAI,MAAM,KAAK;AACpF,IAAM,gBAA2B,CAAC;AAElC,SAAS,cACP,QACA,MACA,QACA,MACA,SACA,QACwB;AACxB,SAAO,EAAE,QAAQ,MAAM,QAAQ,MAAM,SAAS,OAAO;AACvD;AAgBA,SAAS,OACP,KACA,SACA,QACA,SACA,QACS;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ules/@jridgewell/remapping/package.json b/node_modules/@jridgewell/remapping/package.json new file mode 100644 index 0000000000000000000000000000000000000000..ed00441ea559a1546bd16b7915e2e9fe6e7708bb --- /dev/null +++ b/node_modules/@jridgewell/remapping/package.json @@ -0,0 +1,71 @@ +{ + "name": "@jridgewell/remapping", + "version": "2.3.5", + "description": "Remap sequential sourcemaps through transformations to point at the original source code", + "keywords": [ + "source", + "map", + "remap" + ], + "main": "dist/remapping.umd.js", + "module": "dist/remapping.mjs", + "types": "types/remapping.d.cts", + "files": [ + "dist", + "src", + "types" + ], + "exports": { + ".": [ + { + "import": { + "types": "./types/remapping.d.mts", + "default": "./dist/remapping.mjs" + }, + "default": { + "types": "./types/remapping.d.cts", + "default": "./dist/remapping.umd.js" + } + }, + "./dist/remapping.umd.js" + ], + "./package.json": "./package.json" + }, + "scripts": { + "benchmark": "run-s build:code benchmark:*", + "benchmark:install": "cd benchmark && npm install", + "benchmark:only": "node --expose-gc benchmark/index.js", + "build": "run-s -n build:code build:types", + "build:code": "node ../../esbuild.mjs remapping.ts", + "build:types": "run-s build:types:force build:types:emit build:types:mts", + "build:types:force": "rimraf tsconfig.build.tsbuildinfo", + "build:types:emit": "tsc --project tsconfig.build.json", + "build:types:mts": "node ../../mts-types.mjs", + "clean": "run-s -n clean:code clean:types", + "clean:code": "tsc --build --clean tsconfig.build.json", + "clean:types": "rimraf dist types", + "test": "run-s -n test:types test:only test:format", + "test:format": "prettier --check '{src,test}/**/*.ts'", + "test:only": "mocha", + "test:types": "eslint '{src,test}/**/*.ts'", + "lint": "run-s -n lint:types lint:format", + "lint:format": "npm run test:format -- --write", + "lint:types": "npm run test:types -- --fix", + "prepublishOnly": "npm run-s -n build test" + }, + "homepage": "https://github.com/jridgewell/sourcemaps/tree/main/packages/remapping", + "repository": { + "type": "git", + "url": "git+https://github.com/jridgewell/sourcemaps.git", + "directory": "packages/remapping" + }, + "author": "Justin Ridgewell ", + "license": "MIT", + "dependencies": { + "@jridgewell/gen-mapping": "^0.3.5", + "@jridgewell/trace-mapping": "^0.3.24" + }, + "devDependencies": { + "source-map": "0.6.1" + } +} diff --git a/node_modules/@jridgewell/remapping/src/build-source-map-tree.ts b/node_modules/@jridgewell/remapping/src/build-source-map-tree.ts new file mode 100644 index 0000000000000000000000000000000000000000..3e0262bd7c981be3b510203ea08841ea1a47fc89 --- /dev/null +++ b/node_modules/@jridgewell/remapping/src/build-source-map-tree.ts @@ -0,0 +1,89 @@ +import { TraceMap } from '@jridgewell/trace-mapping'; + +import { OriginalSource, MapSource } from './source-map-tree'; + +import type { Sources, MapSource as MapSourceType } from './source-map-tree'; +import type { SourceMapInput, SourceMapLoader, LoaderContext } from './types'; + +function asArray(value: T | T[]): T[] { + if (Array.isArray(value)) return value; + return [value]; +} + +/** + * Recursively builds a tree structure out of sourcemap files, with each node + * being either an `OriginalSource` "leaf" or a `SourceMapTree` composed of + * `OriginalSource`s and `SourceMapTree`s. + * + * Every sourcemap is composed of a collection of source files and mappings + * into locations of those source files. When we generate a `SourceMapTree` for + * the sourcemap, we attempt to load each source file's own sourcemap. If it + * does not have an associated sourcemap, it is considered an original, + * unmodified source file. + */ +export default function buildSourceMapTree( + input: SourceMapInput | SourceMapInput[], + loader: SourceMapLoader, +): MapSourceType { + const maps = asArray(input).map((m) => new TraceMap(m, '')); + const map = maps.pop()!; + + for (let i = 0; i < maps.length; i++) { + if (maps[i].sources.length > 1) { + throw new Error( + `Transformation map ${i} must have exactly one source file.\n` + + 'Did you specify these with the most recent transformation maps first?', + ); + } + } + + let tree = build(map, loader, '', 0); + for (let i = maps.length - 1; i >= 0; i--) { + tree = MapSource(maps[i], [tree]); + } + return tree; +} + +function build( + map: TraceMap, + loader: SourceMapLoader, + importer: string, + importerDepth: number, +): MapSourceType { + const { resolvedSources, sourcesContent, ignoreList } = map; + + const depth = importerDepth + 1; + const children = resolvedSources.map((sourceFile: string | null, i: number): Sources => { + // The loading context gives the loader more information about why this file is being loaded + // (eg, from which importer). It also allows the loader to override the location of the loaded + // sourcemap/original source, or to override the content in the sourcesContent field if it's + // an unmodified source file. + const ctx: LoaderContext = { + importer, + depth, + source: sourceFile || '', + content: undefined, + ignore: undefined, + }; + + // Use the provided loader callback to retrieve the file's sourcemap. + // TODO: We should eventually support async loading of sourcemap files. + const sourceMap = loader(ctx.source, ctx); + + const { source, content, ignore } = ctx; + + // If there is a sourcemap, then we need to recurse into it to load its source files. + if (sourceMap) return build(new TraceMap(sourceMap, source), loader, source, depth); + + // Else, it's an unmodified source file. + // The contents of this unmodified source file can be overridden via the loader context, + // allowing it to be explicitly null or a string. If it remains undefined, we fall back to + // the importing sourcemap's `sourcesContent` field. + const sourceContent = + content !== undefined ? content : sourcesContent ? sourcesContent[i] : null; + const ignored = ignore !== undefined ? ignore : ignoreList ? ignoreList.includes(i) : false; + return OriginalSource(source, sourceContent, ignored); + }); + + return MapSource(map, children); +} diff --git a/node_modules/@jridgewell/remapping/src/remapping.ts b/node_modules/@jridgewell/remapping/src/remapping.ts new file mode 100644 index 0000000000000000000000000000000000000000..c0f8b0ded2debe99b5f94b84ba7ce76dc04dafac --- /dev/null +++ b/node_modules/@jridgewell/remapping/src/remapping.ts @@ -0,0 +1,42 @@ +import buildSourceMapTree from './build-source-map-tree'; +import { traceMappings } from './source-map-tree'; +import SourceMap from './source-map'; + +import type { SourceMapInput, SourceMapLoader, Options } from './types'; +export type { + SourceMapSegment, + EncodedSourceMap, + EncodedSourceMap as RawSourceMap, + DecodedSourceMap, + SourceMapInput, + SourceMapLoader, + LoaderContext, + Options, +} from './types'; +export type { SourceMap }; + +/** + * Traces through all the mappings in the root sourcemap, through the sources + * (and their sourcemaps), all the way back to the original source location. + * + * `loader` will be called every time we encounter a source file. If it returns + * a sourcemap, we will recurse into that sourcemap to continue the trace. If + * it returns a falsey value, that source file is treated as an original, + * unmodified source file. + * + * Pass `excludeContent` to exclude any self-containing source file content + * from the output sourcemap. + * + * Pass `decodedMappings` to receive a SourceMap with decoded (instead of + * VLQ encoded) mappings. + */ +export default function remapping( + input: SourceMapInput | SourceMapInput[], + loader: SourceMapLoader, + options?: boolean | Options, +): SourceMap { + const opts = + typeof options === 'object' ? options : { excludeContent: !!options, decodedMappings: false }; + const tree = buildSourceMapTree(input, loader); + return new SourceMap(traceMappings(tree), opts); +} diff --git a/node_modules/@jridgewell/remapping/src/source-map-tree.ts b/node_modules/@jridgewell/remapping/src/source-map-tree.ts new file mode 100644 index 0000000000000000000000000000000000000000..935240f913436d8ad8c0a2befedeb270f820dad0 --- /dev/null +++ b/node_modules/@jridgewell/remapping/src/source-map-tree.ts @@ -0,0 +1,172 @@ +import { GenMapping, maybeAddSegment, setIgnore, setSourceContent } from '@jridgewell/gen-mapping'; +import { traceSegment, decodedMappings } from '@jridgewell/trace-mapping'; + +import type { TraceMap } from '@jridgewell/trace-mapping'; + +export type SourceMapSegmentObject = { + column: number; + line: number; + name: string; + source: string; + content: string | null; + ignore: boolean; +}; + +export type OriginalSource = { + map: null; + sources: Sources[]; + source: string; + content: string | null; + ignore: boolean; +}; + +export type MapSource = { + map: TraceMap; + sources: Sources[]; + source: string; + content: null; + ignore: false; +}; + +export type Sources = OriginalSource | MapSource; + +const SOURCELESS_MAPPING = /* #__PURE__ */ SegmentObject('', -1, -1, '', null, false); +const EMPTY_SOURCES: Sources[] = []; + +function SegmentObject( + source: string, + line: number, + column: number, + name: string, + content: string | null, + ignore: boolean, +): SourceMapSegmentObject { + return { source, line, column, name, content, ignore }; +} + +function Source( + map: TraceMap, + sources: Sources[], + source: '', + content: null, + ignore: false, +): MapSource; +function Source( + map: null, + sources: Sources[], + source: string, + content: string | null, + ignore: boolean, +): OriginalSource; +function Source( + map: TraceMap | null, + sources: Sources[], + source: string | '', + content: string | null, + ignore: boolean, +): Sources { + return { + map, + sources, + source, + content, + ignore, + } as any; +} + +/** + * MapSource represents a single sourcemap, with the ability to trace mappings into its child nodes + * (which may themselves be SourceMapTrees). + */ +export function MapSource(map: TraceMap, sources: Sources[]): MapSource { + return Source(map, sources, '', null, false); +} + +/** + * A "leaf" node in the sourcemap tree, representing an original, unmodified source file. Recursive + * segment tracing ends at the `OriginalSource`. + */ +export function OriginalSource( + source: string, + content: string | null, + ignore: boolean, +): OriginalSource { + return Source(null, EMPTY_SOURCES, source, content, ignore); +} + +/** + * traceMappings is only called on the root level SourceMapTree, and begins the process of + * resolving each mapping in terms of the original source files. + */ +export function traceMappings(tree: MapSource): GenMapping { + // TODO: Eventually support sourceRoot, which has to be removed because the sources are already + // fully resolved. We'll need to make sources relative to the sourceRoot before adding them. + const gen = new GenMapping({ file: tree.map.file }); + const { sources: rootSources, map } = tree; + const rootNames = map.names; + const rootMappings = decodedMappings(map); + + for (let i = 0; i < rootMappings.length; i++) { + const segments = rootMappings[i]; + + for (let j = 0; j < segments.length; j++) { + const segment = segments[j]; + const genCol = segment[0]; + let traced: SourceMapSegmentObject | null = SOURCELESS_MAPPING; + + // 1-length segments only move the current generated column, there's no source information + // to gather from it. + if (segment.length !== 1) { + const source = rootSources[segment[1]]; + traced = originalPositionFor( + source, + segment[2], + segment[3], + segment.length === 5 ? rootNames[segment[4]] : '', + ); + + // If the trace is invalid, then the trace ran into a sourcemap that doesn't contain a + // respective segment into an original source. + if (traced == null) continue; + } + + const { column, line, name, content, source, ignore } = traced; + + maybeAddSegment(gen, i, genCol, source, line, column, name); + if (source && content != null) setSourceContent(gen, source, content); + if (ignore) setIgnore(gen, source, true); + } + } + + return gen; +} + +/** + * originalPositionFor is only called on children SourceMapTrees. It recurses down into its own + * child SourceMapTrees, until we find the original source map. + */ +export function originalPositionFor( + source: Sources, + line: number, + column: number, + name: string, +): SourceMapSegmentObject | null { + if (!source.map) { + return SegmentObject(source.source, line, column, name, source.content, source.ignore); + } + + const segment = traceSegment(source.map, line, column); + + // If we couldn't find a segment, then this doesn't exist in the sourcemap. + if (segment == null) return null; + // 1-length segments only move the current generated column, there's no source information + // to gather from it. + if (segment.length === 1) return SOURCELESS_MAPPING; + + return originalPositionFor( + source.sources[segment[1]], + segment[2], + segment[3], + segment.length === 5 ? source.map.names[segment[4]] : name, + ); +} diff --git a/node_modules/@jridgewell/remapping/src/source-map.ts b/node_modules/@jridgewell/remapping/src/source-map.ts new file mode 100644 index 0000000000000000000000000000000000000000..5156086f210f4b7264601aa83a6639d9b076b284 --- /dev/null +++ b/node_modules/@jridgewell/remapping/src/source-map.ts @@ -0,0 +1,38 @@ +import { toDecodedMap, toEncodedMap } from '@jridgewell/gen-mapping'; + +import type { GenMapping } from '@jridgewell/gen-mapping'; +import type { DecodedSourceMap, EncodedSourceMap, Options } from './types'; + +/** + * A SourceMap v3 compatible sourcemap, which only includes fields that were + * provided to it. + */ +export default class SourceMap { + declare file?: string | null; + declare mappings: EncodedSourceMap['mappings'] | DecodedSourceMap['mappings']; + declare sourceRoot?: string; + declare names: string[]; + declare sources: (string | null)[]; + declare sourcesContent?: (string | null)[]; + declare version: 3; + declare ignoreList: number[] | undefined; + + constructor(map: GenMapping, options: Options) { + const out = options.decodedMappings ? toDecodedMap(map) : toEncodedMap(map); + this.version = out.version; // SourceMap spec says this should be first. + this.file = out.file; + this.mappings = out.mappings as SourceMap['mappings']; + this.names = out.names as SourceMap['names']; + this.ignoreList = out.ignoreList as SourceMap['ignoreList']; + this.sourceRoot = out.sourceRoot; + + this.sources = out.sources as SourceMap['sources']; + if (!options.excludeContent) { + this.sourcesContent = out.sourcesContent as SourceMap['sourcesContent']; + } + } + + toString(): string { + return JSON.stringify(this); + } +} diff --git a/node_modules/@jridgewell/remapping/src/types.ts b/node_modules/@jridgewell/remapping/src/types.ts new file mode 100644 index 0000000000000000000000000000000000000000..384961d20d5f6933d9c7f47fc753e934a6cbebc8 --- /dev/null +++ b/node_modules/@jridgewell/remapping/src/types.ts @@ -0,0 +1,27 @@ +import type { SourceMapInput } from '@jridgewell/trace-mapping'; + +export type { + SourceMapSegment, + DecodedSourceMap, + EncodedSourceMap, +} from '@jridgewell/trace-mapping'; + +export type { SourceMapInput }; + +export type LoaderContext = { + readonly importer: string; + readonly depth: number; + source: string; + content: string | null | undefined; + ignore: boolean | undefined; +}; + +export type SourceMapLoader = ( + file: string, + ctx: LoaderContext, +) => SourceMapInput | null | undefined | void; + +export type Options = { + excludeContent?: boolean; + decodedMappings?: boolean; +}; diff --git a/node_modules/@jridgewell/remapping/types/build-source-map-tree.d.cts b/node_modules/@jridgewell/remapping/types/build-source-map-tree.d.cts new file mode 100644 index 0000000000000000000000000000000000000000..e089aeaab3a0fba9c7d264f0f65eff992180e036 --- /dev/null +++ b/node_modules/@jridgewell/remapping/types/build-source-map-tree.d.cts @@ -0,0 +1,15 @@ +import type { MapSource as MapSourceType } from './source-map-tree.cts'; +import type { SourceMapInput, SourceMapLoader } from './types.cts'; +/** + * Recursively builds a tree structure out of sourcemap files, with each node + * being either an `OriginalSource` "leaf" or a `SourceMapTree` composed of + * `OriginalSource`s and `SourceMapTree`s. + * + * Every sourcemap is composed of a collection of source files and mappings + * into locations of those source files. When we generate a `SourceMapTree` for + * the sourcemap, we attempt to load each source file's own sourcemap. If it + * does not have an associated sourcemap, it is considered an original, + * unmodified source file. + */ +export = function buildSourceMapTree(input: SourceMapInput | SourceMapInput[], loader: SourceMapLoader): MapSourceType; +//# sourceMappingURL=build-source-map-tree.d.ts.map \ No newline at end of file diff --git a/node_modules/@jridgewell/remapping/types/build-source-map-tree.d.cts.map b/node_modules/@jridgewell/remapping/types/build-source-map-tree.d.cts.map new file mode 100644 index 0000000000000000000000000000000000000000..38e4290dbeacd537e9c3dc783c6848dfe441e5e3 --- /dev/null +++ b/node_modules/@jridgewell/remapping/types/build-source-map-tree.d.cts.map @@ -0,0 +1 @@ +{"version":3,"file":"build-source-map-tree.d.ts","sourceRoot":"","sources":["../src/build-source-map-tree.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAW,SAAS,IAAI,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAC7E,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAiB,MAAM,SAAS,CAAC;AAO9E;;;;;;;;;;GAUG;AACH,MAAM,CAAC,OAAO,UAAU,kBAAkB,CACxC,KAAK,EAAE,cAAc,GAAG,cAAc,EAAE,EACxC,MAAM,EAAE,eAAe,GACtB,aAAa,CAkBf"} \ No newline at end of file diff --git a/node_modules/@jridgewell/remapping/types/build-source-map-tree.d.mts b/node_modules/@jridgewell/remapping/types/build-source-map-tree.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..746ac5f730888a0ca6c071ec975b64291537ee57 --- /dev/null +++ b/node_modules/@jridgewell/remapping/types/build-source-map-tree.d.mts @@ -0,0 +1,15 @@ +import type { MapSource as MapSourceType } from './source-map-tree.mts'; +import type { SourceMapInput, SourceMapLoader } from './types.mts'; +/** + * Recursively builds a tree structure out of sourcemap files, with each node + * being either an `OriginalSource` "leaf" or a `SourceMapTree` composed of + * `OriginalSource`s and `SourceMapTree`s. + * + * Every sourcemap is composed of a collection of source files and mappings + * into locations of those source files. When we generate a `SourceMapTree` for + * the sourcemap, we attempt to load each source file's own sourcemap. If it + * does not have an associated sourcemap, it is considered an original, + * unmodified source file. + */ +export default function buildSourceMapTree(input: SourceMapInput | SourceMapInput[], loader: SourceMapLoader): MapSourceType; +//# sourceMappingURL=build-source-map-tree.d.ts.map \ No newline at end of file diff --git a/node_modules/@jridgewell/remapping/types/build-source-map-tree.d.mts.map b/node_modules/@jridgewell/remapping/types/build-source-map-tree.d.mts.map new file mode 100644 index 0000000000000000000000000000000000000000..38e4290dbeacd537e9c3dc783c6848dfe441e5e3 --- /dev/null +++ b/node_modules/@jridgewell/remapping/types/build-source-map-tree.d.mts.map @@ -0,0 +1 @@ +{"version":3,"file":"build-source-map-tree.d.ts","sourceRoot":"","sources":["../src/build-source-map-tree.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAW,SAAS,IAAI,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAC7E,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAiB,MAAM,SAAS,CAAC;AAO9E;;;;;;;;;;GAUG;AACH,MAAM,CAAC,OAAO,UAAU,kBAAkB,CACxC,KAAK,EAAE,cAAc,GAAG,cAAc,EAAE,EACxC,MAAM,EAAE,eAAe,GACtB,aAAa,CAkBf"} \ No newline at end of file diff --git a/node_modules/@jridgewell/remapping/types/remapping.d.cts b/node_modules/@jridgewell/remapping/types/remapping.d.cts new file mode 100644 index 0000000000000000000000000000000000000000..2022784752343ea9079b466504b00f93026e4f93 --- /dev/null +++ b/node_modules/@jridgewell/remapping/types/remapping.d.cts @@ -0,0 +1,21 @@ +import SourceMap from './source-map.cts'; +import type { SourceMapInput, SourceMapLoader, Options } from './types.cts'; +export type { SourceMapSegment, EncodedSourceMap, EncodedSourceMap as RawSourceMap, DecodedSourceMap, SourceMapInput, SourceMapLoader, LoaderContext, Options, } from './types.cts'; +export type { SourceMap }; +/** + * Traces through all the mappings in the root sourcemap, through the sources + * (and their sourcemaps), all the way back to the original source location. + * + * `loader` will be called every time we encounter a source file. If it returns + * a sourcemap, we will recurse into that sourcemap to continue the trace. If + * it returns a falsey value, that source file is treated as an original, + * unmodified source file. + * + * Pass `excludeContent` to exclude any self-containing source file content + * from the output sourcemap. + * + * Pass `decodedMappings` to receive a SourceMap with decoded (instead of + * VLQ encoded) mappings. + */ +export = function remapping(input: SourceMapInput | SourceMapInput[], loader: SourceMapLoader, options?: boolean | Options): SourceMap; +//# sourceMappingURL=remapping.d.ts.map \ No newline at end of file diff --git a/node_modules/@jridgewell/remapping/types/remapping.d.cts.map b/node_modules/@jridgewell/remapping/types/remapping.d.cts.map new file mode 100644 index 0000000000000000000000000000000000000000..9f2fd0efd61b77ee14bd4aa44f5e597e1b8ffcdf --- /dev/null +++ b/node_modules/@jridgewell/remapping/types/remapping.d.cts.map @@ -0,0 +1 @@ +{"version":3,"file":"remapping.d.ts","sourceRoot":"","sources":["../src/remapping.ts"],"names":[],"mappings":"AAEA,OAAO,SAAS,MAAM,cAAc,CAAC;AAErC,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AACxE,YAAY,EACV,gBAAgB,EAChB,gBAAgB,EAChB,gBAAgB,IAAI,YAAY,EAChC,gBAAgB,EAChB,cAAc,EACd,eAAe,EACf,aAAa,EACb,OAAO,GACR,MAAM,SAAS,CAAC;AACjB,YAAY,EAAE,SAAS,EAAE,CAAC;AAE1B;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,OAAO,UAAU,SAAS,CAC/B,KAAK,EAAE,cAAc,GAAG,cAAc,EAAE,EACxC,MAAM,EAAE,eAAe,EACvB,OAAO,CAAC,EAAE,OAAO,GAAG,OAAO,GAC1B,SAAS,CAKX"} \ No newline at end of file diff --git a/node_modules/@jridgewell/remapping/types/remapping.d.mts b/node_modules/@jridgewell/remapping/types/remapping.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..95c406698754b2f70d5040ff33c1a332ac18e266 --- /dev/null +++ b/node_modules/@jridgewell/remapping/types/remapping.d.mts @@ -0,0 +1,21 @@ +import SourceMap from './source-map.mts'; +import type { SourceMapInput, SourceMapLoader, Options } from './types.mts'; +export type { SourceMapSegment, EncodedSourceMap, EncodedSourceMap as RawSourceMap, DecodedSourceMap, SourceMapInput, SourceMapLoader, LoaderContext, Options, } from './types.mts'; +export type { SourceMap }; +/** + * Traces through all the mappings in the root sourcemap, through the sources + * (and their sourcemaps), all the way back to the original source location. + * + * `loader` will be called every time we encounter a source file. If it returns + * a sourcemap, we will recurse into that sourcemap to continue the trace. If + * it returns a falsey value, that source file is treated as an original, + * unmodified source file. + * + * Pass `excludeContent` to exclude any self-containing source file content + * from the output sourcemap. + * + * Pass `decodedMappings` to receive a SourceMap with decoded (instead of + * VLQ encoded) mappings. + */ +export default function remapping(input: SourceMapInput | SourceMapInput[], loader: SourceMapLoader, options?: boolean | Options): SourceMap; +//# sourceMappingURL=remapping.d.ts.map \ No newline at end of file diff --git a/node_modules/@jridgewell/remapping/types/remapping.d.mts.map b/node_modules/@jridgewell/remapping/types/remapping.d.mts.map new file mode 100644 index 0000000000000000000000000000000000000000..9f2fd0efd61b77ee14bd4aa44f5e597e1b8ffcdf --- /dev/null +++ b/node_modules/@jridgewell/remapping/types/remapping.d.mts.map @@ -0,0 +1 @@ +{"version":3,"file":"remapping.d.ts","sourceRoot":"","sources":["../src/remapping.ts"],"names":[],"mappings":"AAEA,OAAO,SAAS,MAAM,cAAc,CAAC;AAErC,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AACxE,YAAY,EACV,gBAAgB,EAChB,gBAAgB,EAChB,gBAAgB,IAAI,YAAY,EAChC,gBAAgB,EAChB,cAAc,EACd,eAAe,EACf,aAAa,EACb,OAAO,GACR,MAAM,SAAS,CAAC;AACjB,YAAY,EAAE,SAAS,EAAE,CAAC;AAE1B;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,OAAO,UAAU,SAAS,CAC/B,KAAK,EAAE,cAAc,GAAG,cAAc,EAAE,EACxC,MAAM,EAAE,eAAe,EACvB,OAAO,CAAC,EAAE,OAAO,GAAG,OAAO,GAC1B,SAAS,CAKX"} \ No newline at end of file diff --git a/node_modules/@jridgewell/remapping/types/source-map-tree.d.cts b/node_modules/@jridgewell/remapping/types/source-map-tree.d.cts new file mode 100644 index 0000000000000000000000000000000000000000..440f65b8c2d471b558ac0700f04265c796fe0664 --- /dev/null +++ b/node_modules/@jridgewell/remapping/types/source-map-tree.d.cts @@ -0,0 +1,46 @@ +import { GenMapping } from '@jridgewell/gen-mapping'; +import type { TraceMap } from '@jridgewell/trace-mapping'; +export type SourceMapSegmentObject = { + column: number; + line: number; + name: string; + source: string; + content: string | null; + ignore: boolean; +}; +export type OriginalSource = { + map: null; + sources: Sources[]; + source: string; + content: string | null; + ignore: boolean; +}; +export type MapSource = { + map: TraceMap; + sources: Sources[]; + source: string; + content: null; + ignore: false; +}; +export type Sources = OriginalSource | MapSource; +/** + * MapSource represents a single sourcemap, with the ability to trace mappings into its child nodes + * (which may themselves be SourceMapTrees). + */ +export declare function MapSource(map: TraceMap, sources: Sources[]): MapSource; +/** + * A "leaf" node in the sourcemap tree, representing an original, unmodified source file. Recursive + * segment tracing ends at the `OriginalSource`. + */ +export declare function OriginalSource(source: string, content: string | null, ignore: boolean): OriginalSource; +/** + * traceMappings is only called on the root level SourceMapTree, and begins the process of + * resolving each mapping in terms of the original source files. + */ +export declare function traceMappings(tree: MapSource): GenMapping; +/** + * originalPositionFor is only called on children SourceMapTrees. It recurses down into its own + * child SourceMapTrees, until we find the original source map. + */ +export declare function originalPositionFor(source: Sources, line: number, column: number, name: string): SourceMapSegmentObject | null; +//# sourceMappingURL=source-map-tree.d.ts.map \ No newline at end of file diff --git a/node_modules/@jridgewell/remapping/types/source-map-tree.d.cts.map b/node_modules/@jridgewell/remapping/types/source-map-tree.d.cts.map new file mode 100644 index 0000000000000000000000000000000000000000..e7cbfb9563f40b30775b981a4cb06376a97796e1 --- /dev/null +++ b/node_modules/@jridgewell/remapping/types/source-map-tree.d.cts.map @@ -0,0 +1 @@ +{"version":3,"file":"source-map-tree.d.ts","sourceRoot":"","sources":["../src/source-map-tree.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAgD,MAAM,yBAAyB,CAAC;AAGnG,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAE1D,MAAM,MAAM,sBAAsB,GAAG;IACnC,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,MAAM,EAAE,OAAO,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG;IAC3B,GAAG,EAAE,IAAI,CAAC;IACV,OAAO,EAAE,OAAO,EAAE,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,MAAM,EAAE,OAAO,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,SAAS,GAAG;IACtB,GAAG,EAAE,QAAQ,CAAC;IACd,OAAO,EAAE,OAAO,EAAE,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,IAAI,CAAC;IACd,MAAM,EAAE,KAAK,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,OAAO,GAAG,cAAc,GAAG,SAAS,CAAC;AA8CjD;;;GAGG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,SAAS,CAEtE;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAC5B,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,MAAM,GAAG,IAAI,EACtB,MAAM,EAAE,OAAO,GACd,cAAc,CAEhB;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,SAAS,GAAG,UAAU,CAyCzD;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,OAAO,EACf,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,GACX,sBAAsB,GAAG,IAAI,CAmB/B"} \ No newline at end of file diff --git a/node_modules/@jridgewell/remapping/types/source-map-tree.d.mts b/node_modules/@jridgewell/remapping/types/source-map-tree.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..440f65b8c2d471b558ac0700f04265c796fe0664 --- /dev/null +++ b/node_modules/@jridgewell/remapping/types/source-map-tree.d.mts @@ -0,0 +1,46 @@ +import { GenMapping } from '@jridgewell/gen-mapping'; +import type { TraceMap } from '@jridgewell/trace-mapping'; +export type SourceMapSegmentObject = { + column: number; + line: number; + name: string; + source: string; + content: string | null; + ignore: boolean; +}; +export type OriginalSource = { + map: null; + sources: Sources[]; + source: string; + content: string | null; + ignore: boolean; +}; +export type MapSource = { + map: TraceMap; + sources: Sources[]; + source: string; + content: null; + ignore: false; +}; +export type Sources = OriginalSource | MapSource; +/** + * MapSource represents a single sourcemap, with the ability to trace mappings into its child nodes + * (which may themselves be SourceMapTrees). + */ +export declare function MapSource(map: TraceMap, sources: Sources[]): MapSource; +/** + * A "leaf" node in the sourcemap tree, representing an original, unmodified source file. Recursive + * segment tracing ends at the `OriginalSource`. + */ +export declare function OriginalSource(source: string, content: string | null, ignore: boolean): OriginalSource; +/** + * traceMappings is only called on the root level SourceMapTree, and begins the process of + * resolving each mapping in terms of the original source files. + */ +export declare function traceMappings(tree: MapSource): GenMapping; +/** + * originalPositionFor is only called on children SourceMapTrees. It recurses down into its own + * child SourceMapTrees, until we find the original source map. + */ +export declare function originalPositionFor(source: Sources, line: number, column: number, name: string): SourceMapSegmentObject | null; +//# sourceMappingURL=source-map-tree.d.ts.map \ No newline at end of file diff --git a/node_modules/@jridgewell/remapping/types/source-map-tree.d.mts.map b/node_modules/@jridgewell/remapping/types/source-map-tree.d.mts.map new file mode 100644 index 0000000000000000000000000000000000000000..e7cbfb9563f40b30775b981a4cb06376a97796e1 --- /dev/null +++ b/node_modules/@jridgewell/remapping/types/source-map-tree.d.mts.map @@ -0,0 +1 @@ +{"version":3,"file":"source-map-tree.d.ts","sourceRoot":"","sources":["../src/source-map-tree.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAgD,MAAM,yBAAyB,CAAC;AAGnG,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAE1D,MAAM,MAAM,sBAAsB,GAAG;IACnC,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,MAAM,EAAE,OAAO,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG;IAC3B,GAAG,EAAE,IAAI,CAAC;IACV,OAAO,EAAE,OAAO,EAAE,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,MAAM,EAAE,OAAO,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,SAAS,GAAG;IACtB,GAAG,EAAE,QAAQ,CAAC;IACd,OAAO,EAAE,OAAO,EAAE,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,IAAI,CAAC;IACd,MAAM,EAAE,KAAK,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,OAAO,GAAG,cAAc,GAAG,SAAS,CAAC;AA8CjD;;;GAGG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,SAAS,CAEtE;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAC5B,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,MAAM,GAAG,IAAI,EACtB,MAAM,EAAE,OAAO,GACd,cAAc,CAEhB;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,SAAS,GAAG,UAAU,CAyCzD;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,OAAO,EACf,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,GACX,sBAAsB,GAAG,IAAI,CAmB/B"} \ No newline at end of file diff --git a/node_modules/@jridgewell/remapping/types/source-map.d.cts b/node_modules/@jridgewell/remapping/types/source-map.d.cts new file mode 100644 index 0000000000000000000000000000000000000000..fdb7eedeb3b3f01125d66832f345e31d1f77d786 --- /dev/null +++ b/node_modules/@jridgewell/remapping/types/source-map.d.cts @@ -0,0 +1,19 @@ +import type { GenMapping } from '@jridgewell/gen-mapping'; +import type { DecodedSourceMap, EncodedSourceMap, Options } from './types.cts'; +/** + * A SourceMap v3 compatible sourcemap, which only includes fields that were + * provided to it. + */ +export = class SourceMap { + file?: string | null; + mappings: EncodedSourceMap['mappings'] | DecodedSourceMap['mappings']; + sourceRoot?: string; + names: string[]; + sources: (string | null)[]; + sourcesContent?: (string | null)[]; + version: 3; + ignoreList: number[] | undefined; + constructor(map: GenMapping, options: Options); + toString(): string; +} +//# sourceMappingURL=source-map.d.ts.map \ No newline at end of file diff --git a/node_modules/@jridgewell/remapping/types/source-map.d.cts.map b/node_modules/@jridgewell/remapping/types/source-map.d.cts.map new file mode 100644 index 0000000000000000000000000000000000000000..593daf8e0abaffe983e2c1166b3e8180d9649644 --- /dev/null +++ b/node_modules/@jridgewell/remapping/types/source-map.d.cts.map @@ -0,0 +1 @@ +{"version":3,"file":"source-map.d.ts","sourceRoot":"","sources":["../src/source-map.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,KAAK,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAE3E;;;GAGG;AACH,MAAM,CAAC,OAAO,OAAO,SAAS;IACpB,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,QAAQ,EAAE,gBAAgB,CAAC,UAAU,CAAC,GAAG,gBAAgB,CAAC,UAAU,CAAC,CAAC;IACtE,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,OAAO,EAAE,CAAC,MAAM,GAAG,IAAI,CAAC,EAAE,CAAC;IAC3B,cAAc,CAAC,EAAE,CAAC,MAAM,GAAG,IAAI,CAAC,EAAE,CAAC;IACnC,OAAO,EAAE,CAAC,CAAC;IACX,UAAU,EAAE,MAAM,EAAE,GAAG,SAAS,CAAC;gBAE7B,GAAG,EAAE,UAAU,EAAE,OAAO,EAAE,OAAO;IAe7C,QAAQ,IAAI,MAAM;CAGnB"} \ No newline at end of file diff --git a/node_modules/@jridgewell/remapping/types/source-map.d.mts b/node_modules/@jridgewell/remapping/types/source-map.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..52ebba2f72b103271db863d1f667105bb65163b3 --- /dev/null +++ b/node_modules/@jridgewell/remapping/types/source-map.d.mts @@ -0,0 +1,19 @@ +import type { GenMapping } from '@jridgewell/gen-mapping'; +import type { DecodedSourceMap, EncodedSourceMap, Options } from './types.mts'; +/** + * A SourceMap v3 compatible sourcemap, which only includes fields that were + * provided to it. + */ +export default class SourceMap { + file?: string | null; + mappings: EncodedSourceMap['mappings'] | DecodedSourceMap['mappings']; + sourceRoot?: string; + names: string[]; + sources: (string | null)[]; + sourcesContent?: (string | null)[]; + version: 3; + ignoreList: number[] | undefined; + constructor(map: GenMapping, options: Options); + toString(): string; +} +//# sourceMappingURL=source-map.d.ts.map \ No newline at end of file diff --git a/node_modules/@jridgewell/remapping/types/source-map.d.mts.map b/node_modules/@jridgewell/remapping/types/source-map.d.mts.map new file mode 100644 index 0000000000000000000000000000000000000000..593daf8e0abaffe983e2c1166b3e8180d9649644 --- /dev/null +++ b/node_modules/@jridgewell/remapping/types/source-map.d.mts.map @@ -0,0 +1 @@ +{"version":3,"file":"source-map.d.ts","sourceRoot":"","sources":["../src/source-map.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,KAAK,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAE3E;;;GAGG;AACH,MAAM,CAAC,OAAO,OAAO,SAAS;IACpB,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,QAAQ,EAAE,gBAAgB,CAAC,UAAU,CAAC,GAAG,gBAAgB,CAAC,UAAU,CAAC,CAAC;IACtE,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,OAAO,EAAE,CAAC,MAAM,GAAG,IAAI,CAAC,EAAE,CAAC;IAC3B,cAAc,CAAC,EAAE,CAAC,MAAM,GAAG,IAAI,CAAC,EAAE,CAAC;IACnC,OAAO,EAAE,CAAC,CAAC;IACX,UAAU,EAAE,MAAM,EAAE,GAAG,SAAS,CAAC;gBAE7B,GAAG,EAAE,UAAU,EAAE,OAAO,EAAE,OAAO;IAe7C,QAAQ,IAAI,MAAM;CAGnB"} \ No newline at end of file diff --git a/node_modules/@jridgewell/remapping/types/types.d.cts b/node_modules/@jridgewell/remapping/types/types.d.cts new file mode 100644 index 0000000000000000000000000000000000000000..eeb320f847682b723d15ea336d35f8c3109faa75 --- /dev/null +++ b/node_modules/@jridgewell/remapping/types/types.d.cts @@ -0,0 +1,16 @@ +import type { SourceMapInput } from '@jridgewell/trace-mapping'; +export type { SourceMapSegment, DecodedSourceMap, EncodedSourceMap, } from '@jridgewell/trace-mapping'; +export type { SourceMapInput }; +export type LoaderContext = { + readonly importer: string; + readonly depth: number; + source: string; + content: string | null | undefined; + ignore: boolean | undefined; +}; +export type SourceMapLoader = (file: string, ctx: LoaderContext) => SourceMapInput | null | undefined | void; +export type Options = { + excludeContent?: boolean; + decodedMappings?: boolean; +}; +//# sourceMappingURL=types.d.ts.map \ No newline at end of file diff --git a/node_modules/@jridgewell/remapping/types/types.d.cts.map b/node_modules/@jridgewell/remapping/types/types.d.cts.map new file mode 100644 index 0000000000000000000000000000000000000000..4f8647e4c9c5d4075fd48dd86a5fe1028fa7ad65 --- /dev/null +++ b/node_modules/@jridgewell/remapping/types/types.d.cts.map @@ -0,0 +1 @@ +{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAEhE,YAAY,EACV,gBAAgB,EAChB,gBAAgB,EAChB,gBAAgB,GACjB,MAAM,2BAA2B,CAAC;AAEnC,YAAY,EAAE,cAAc,EAAE,CAAC;AAE/B,MAAM,MAAM,aAAa,GAAG;IAC1B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IACnC,MAAM,EAAE,OAAO,GAAG,SAAS,CAAC;CAC7B,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG,CAC5B,IAAI,EAAE,MAAM,EACZ,GAAG,EAAE,aAAa,KACf,cAAc,GAAG,IAAI,GAAG,SAAS,GAAG,IAAI,CAAC;AAE9C,MAAM,MAAM,OAAO,GAAG;IACpB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B,CAAC"} \ No newline at end of file diff --git a/node_modules/@jridgewell/remapping/types/types.d.mts b/node_modules/@jridgewell/remapping/types/types.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..eeb320f847682b723d15ea336d35f8c3109faa75 --- /dev/null +++ b/node_modules/@jridgewell/remapping/types/types.d.mts @@ -0,0 +1,16 @@ +import type { SourceMapInput } from '@jridgewell/trace-mapping'; +export type { SourceMapSegment, DecodedSourceMap, EncodedSourceMap, } from '@jridgewell/trace-mapping'; +export type { SourceMapInput }; +export type LoaderContext = { + readonly importer: string; + readonly depth: number; + source: string; + content: string | null | undefined; + ignore: boolean | undefined; +}; +export type SourceMapLoader = (file: string, ctx: LoaderContext) => SourceMapInput | null | undefined | void; +export type Options = { + excludeContent?: boolean; + decodedMappings?: boolean; +}; +//# sourceMappingURL=types.d.ts.map \ No newline at end of file diff --git a/node_modules/@jridgewell/remapping/types/types.d.mts.map b/node_modules/@jridgewell/remapping/types/types.d.mts.map new file mode 100644 index 0000000000000000000000000000000000000000..4f8647e4c9c5d4075fd48dd86a5fe1028fa7ad65 --- /dev/null +++ b/node_modules/@jridgewell/remapping/types/types.d.mts.map @@ -0,0 +1 @@ +{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAEhE,YAAY,EACV,gBAAgB,EAChB,gBAAgB,EAChB,gBAAgB,GACjB,MAAM,2BAA2B,CAAC;AAEnC,YAAY,EAAE,cAAc,EAAE,CAAC;AAE/B,MAAM,MAAM,aAAa,GAAG;IAC1B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IACnC,MAAM,EAAE,OAAO,GAAG,SAAS,CAAC;CAC7B,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG,CAC5B,IAAI,EAAE,MAAM,EACZ,GAAG,EAAE,aAAa,KACf,cAAc,GAAG,IAAI,GAAG,SAAS,GAAG,IAAI,CAAC;AAE9C,MAAM,MAAM,OAAO,GAAG;IACpB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B,CAAC"} \ No newline at end of file diff --git a/node_modules/@jridgewell/resolve-uri/LICENSE b/node_modules/@jridgewell/resolve-uri/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..0a81b2ade1c77efc8ed0e73172efd07ea1c73539 --- /dev/null +++ b/node_modules/@jridgewell/resolve-uri/LICENSE @@ -0,0 +1,19 @@ +Copyright 2019 Justin Ridgewell + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/node_modules/@jridgewell/resolve-uri/README.md b/node_modules/@jridgewell/resolve-uri/README.md new file mode 100644 index 0000000000000000000000000000000000000000..2fe70df77ec8e109faf2bc857e9893d486ad9eb1 --- /dev/null +++ b/node_modules/@jridgewell/resolve-uri/README.md @@ -0,0 +1,40 @@ +# @jridgewell/resolve-uri + +> Resolve a URI relative to an optional base URI + +Resolve any combination of absolute URIs, protocol-realtive URIs, absolute paths, or relative paths. + +## Installation + +```sh +npm install @jridgewell/resolve-uri +``` + +## Usage + +```typescript +function resolve(input: string, base?: string): string; +``` + +```js +import resolve from '@jridgewell/resolve-uri'; + +resolve('foo', 'https://example.com'); // => 'https://example.com/foo' +``` + +| Input | Base | Resolution | Explanation | +|-----------------------|-------------------------|--------------------------------|--------------------------------------------------------------| +| `https://example.com` | _any_ | `https://example.com/` | Input is normalized only | +| `//example.com` | `https://base.com/` | `https://example.com/` | Input inherits the base's protocol | +| `//example.com` | _rest_ | `//example.com/` | Input is normalized only | +| `/example` | `https://base.com/` | `https://base.com/example` | Input inherits the base's origin | +| `/example` | `//base.com/` | `//base.com/example` | Input inherits the base's host and remains protocol relative | +| `/example` | _rest_ | `/example` | Input is normalized only | +| `example` | `https://base.com/dir/` | `https://base.com/dir/example` | Input is joined with the base | +| `example` | `https://base.com/file` | `https://base.com/example` | Input is joined with the base without its file | +| `example` | `//base.com/dir/` | `//base.com/dir/example` | Input is joined with the base's last directory | +| `example` | `//base.com/file` | `//base.com/example` | Input is joined with the base without its file | +| `example` | `/base/dir/` | `/base/dir/example` | Input is joined with the base's last directory | +| `example` | `/base/file` | `/base/example` | Input is joined with the base without its file | +| `example` | `base/dir/` | `base/dir/example` | Input is joined with the base's last directory | +| `example` | `base/file` | `base/example` | Input is joined with the base without its file | diff --git a/node_modules/@jridgewell/resolve-uri/dist/resolve-uri.mjs b/node_modules/@jridgewell/resolve-uri/dist/resolve-uri.mjs new file mode 100644 index 0000000000000000000000000000000000000000..e958e8817081205d26fc8b1298cae205420e3936 --- /dev/null +++ b/node_modules/@jridgewell/resolve-uri/dist/resolve-uri.mjs @@ -0,0 +1,232 @@ +// Matches the scheme of a URL, eg "http://" +const schemeRegex = /^[\w+.-]+:\/\//; +/** + * Matches the parts of a URL: + * 1. Scheme, including ":", guaranteed. + * 2. User/password, including "@", optional. + * 3. Host, guaranteed. + * 4. Port, including ":", optional. + * 5. Path, including "/", optional. + * 6. Query, including "?", optional. + * 7. Hash, including "#", optional. + */ +const urlRegex = /^([\w+.-]+:)\/\/([^@/#?]*@)?([^:/#?]*)(:\d+)?(\/[^#?]*)?(\?[^#]*)?(#.*)?/; +/** + * File URLs are weird. They dont' need the regular `//` in the scheme, they may or may not start + * with a leading `/`, they can have a domain (but only if they don't start with a Windows drive). + * + * 1. Host, optional. + * 2. Path, which may include "/", guaranteed. + * 3. Query, including "?", optional. + * 4. Hash, including "#", optional. + */ +const fileRegex = /^file:(?:\/\/((?![a-z]:)[^/#?]*)?)?(\/?[^#?]*)(\?[^#]*)?(#.*)?/i; +function isAbsoluteUrl(input) { + return schemeRegex.test(input); +} +function isSchemeRelativeUrl(input) { + return input.startsWith('//'); +} +function isAbsolutePath(input) { + return input.startsWith('/'); +} +function isFileUrl(input) { + return input.startsWith('file:'); +} +function isRelative(input) { + return /^[.?#]/.test(input); +} +function parseAbsoluteUrl(input) { + const match = urlRegex.exec(input); + return makeUrl(match[1], match[2] || '', match[3], match[4] || '', match[5] || '/', match[6] || '', match[7] || ''); +} +function parseFileUrl(input) { + const match = fileRegex.exec(input); + const path = match[2]; + return makeUrl('file:', '', match[1] || '', '', isAbsolutePath(path) ? path : '/' + path, match[3] || '', match[4] || ''); +} +function makeUrl(scheme, user, host, port, path, query, hash) { + return { + scheme, + user, + host, + port, + path, + query, + hash, + type: 7 /* Absolute */, + }; +} +function parseUrl(input) { + if (isSchemeRelativeUrl(input)) { + const url = parseAbsoluteUrl('http:' + input); + url.scheme = ''; + url.type = 6 /* SchemeRelative */; + return url; + } + if (isAbsolutePath(input)) { + const url = parseAbsoluteUrl('http://foo.com' + input); + url.scheme = ''; + url.host = ''; + url.type = 5 /* AbsolutePath */; + return url; + } + if (isFileUrl(input)) + return parseFileUrl(input); + if (isAbsoluteUrl(input)) + return parseAbsoluteUrl(input); + const url = parseAbsoluteUrl('http://foo.com/' + input); + url.scheme = ''; + url.host = ''; + url.type = input + ? input.startsWith('?') + ? 3 /* Query */ + : input.startsWith('#') + ? 2 /* Hash */ + : 4 /* RelativePath */ + : 1 /* Empty */; + return url; +} +function stripPathFilename(path) { + // If a path ends with a parent directory "..", then it's a relative path with excess parent + // paths. It's not a file, so we can't strip it. + if (path.endsWith('/..')) + return path; + const index = path.lastIndexOf('/'); + return path.slice(0, index + 1); +} +function mergePaths(url, base) { + normalizePath(base, base.type); + // If the path is just a "/", then it was an empty path to begin with (remember, we're a relative + // path). + if (url.path === '/') { + url.path = base.path; + } + else { + // Resolution happens relative to the base path's directory, not the file. + url.path = stripPathFilename(base.path) + url.path; + } +} +/** + * The path can have empty directories "//", unneeded parents "foo/..", or current directory + * "foo/.". We need to normalize to a standard representation. + */ +function normalizePath(url, type) { + const rel = type <= 4 /* RelativePath */; + const pieces = url.path.split('/'); + // We need to preserve the first piece always, so that we output a leading slash. The item at + // pieces[0] is an empty string. + let pointer = 1; + // Positive is the number of real directories we've output, used for popping a parent directory. + // Eg, "foo/bar/.." will have a positive 2, and we can decrement to be left with just "foo". + let positive = 0; + // We need to keep a trailing slash if we encounter an empty directory (eg, splitting "foo/" will + // generate `["foo", ""]` pieces). And, if we pop a parent directory. But once we encounter a + // real directory, we won't need to append, unless the other conditions happen again. + let addTrailingSlash = false; + for (let i = 1; i < pieces.length; i++) { + const piece = pieces[i]; + // An empty directory, could be a trailing slash, or just a double "//" in the path. + if (!piece) { + addTrailingSlash = true; + continue; + } + // If we encounter a real directory, then we don't need to append anymore. + addTrailingSlash = false; + // A current directory, which we can always drop. + if (piece === '.') + continue; + // A parent directory, we need to see if there are any real directories we can pop. Else, we + // have an excess of parents, and we'll need to keep the "..". + if (piece === '..') { + if (positive) { + addTrailingSlash = true; + positive--; + pointer--; + } + else if (rel) { + // If we're in a relativePath, then we need to keep the excess parents. Else, in an absolute + // URL, protocol relative URL, or an absolute path, we don't need to keep excess. + pieces[pointer++] = piece; + } + continue; + } + // We've encountered a real directory. Move it to the next insertion pointer, which accounts for + // any popped or dropped directories. + pieces[pointer++] = piece; + positive++; + } + let path = ''; + for (let i = 1; i < pointer; i++) { + path += '/' + pieces[i]; + } + if (!path || (addTrailingSlash && !path.endsWith('/..'))) { + path += '/'; + } + url.path = path; +} +/** + * Attempts to resolve `input` URL/path relative to `base`. + */ +function resolve(input, base) { + if (!input && !base) + return ''; + const url = parseUrl(input); + let inputType = url.type; + if (base && inputType !== 7 /* Absolute */) { + const baseUrl = parseUrl(base); + const baseType = baseUrl.type; + switch (inputType) { + case 1 /* Empty */: + url.hash = baseUrl.hash; + // fall through + case 2 /* Hash */: + url.query = baseUrl.query; + // fall through + case 3 /* Query */: + case 4 /* RelativePath */: + mergePaths(url, baseUrl); + // fall through + case 5 /* AbsolutePath */: + // The host, user, and port are joined, you can't copy one without the others. + url.user = baseUrl.user; + url.host = baseUrl.host; + url.port = baseUrl.port; + // fall through + case 6 /* SchemeRelative */: + // The input doesn't have a schema at least, so we need to copy at least that over. + url.scheme = baseUrl.scheme; + } + if (baseType > inputType) + inputType = baseType; + } + normalizePath(url, inputType); + const queryHash = url.query + url.hash; + switch (inputType) { + // This is impossible, because of the empty checks at the start of the function. + // case UrlType.Empty: + case 2 /* Hash */: + case 3 /* Query */: + return queryHash; + case 4 /* RelativePath */: { + // The first char is always a "/", and we need it to be relative. + const path = url.path.slice(1); + if (!path) + return queryHash || '.'; + if (isRelative(base || input) && !isRelative(path)) { + // If base started with a leading ".", or there is no base and input started with a ".", + // then we need to ensure that the relative path starts with a ".". We don't know if + // relative starts with a "..", though, so check before prepending. + return './' + path + queryHash; + } + return path + queryHash; + } + case 5 /* AbsolutePath */: + return url.path + queryHash; + default: + return url.scheme + '//' + url.user + url.host + url.port + url.path + queryHash; + } +} + +export { resolve as default }; +//# sourceMappingURL=resolve-uri.mjs.map diff --git a/node_modules/@jridgewell/resolve-uri/dist/resolve-uri.mjs.map b/node_modules/@jridgewell/resolve-uri/dist/resolve-uri.mjs.map new file mode 100644 index 0000000000000000000000000000000000000000..1de97d011e53986c4497437eec6b649a51611fdf --- /dev/null +++ b/node_modules/@jridgewell/resolve-uri/dist/resolve-uri.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"resolve-uri.mjs","sources":["../src/resolve-uri.ts"],"sourcesContent":["// Matches the scheme of a URL, eg \"http://\"\nconst schemeRegex = /^[\\w+.-]+:\\/\\//;\n\n/**\n * Matches the parts of a URL:\n * 1. Scheme, including \":\", guaranteed.\n * 2. User/password, including \"@\", optional.\n * 3. Host, guaranteed.\n * 4. Port, including \":\", optional.\n * 5. Path, including \"/\", optional.\n * 6. Query, including \"?\", optional.\n * 7. Hash, including \"#\", optional.\n */\nconst urlRegex = /^([\\w+.-]+:)\\/\\/([^@/#?]*@)?([^:/#?]*)(:\\d+)?(\\/[^#?]*)?(\\?[^#]*)?(#.*)?/;\n\n/**\n * File URLs are weird. They dont' need the regular `//` in the scheme, they may or may not start\n * with a leading `/`, they can have a domain (but only if they don't start with a Windows drive).\n *\n * 1. Host, optional.\n * 2. Path, which may include \"/\", guaranteed.\n * 3. Query, including \"?\", optional.\n * 4. Hash, including \"#\", optional.\n */\nconst fileRegex = /^file:(?:\\/\\/((?![a-z]:)[^/#?]*)?)?(\\/?[^#?]*)(\\?[^#]*)?(#.*)?/i;\n\ntype Url = {\n scheme: string;\n user: string;\n host: string;\n port: string;\n path: string;\n query: string;\n hash: string;\n type: UrlType;\n};\n\nconst enum UrlType {\n Empty = 1,\n Hash = 2,\n Query = 3,\n RelativePath = 4,\n AbsolutePath = 5,\n SchemeRelative = 6,\n Absolute = 7,\n}\n\nfunction isAbsoluteUrl(input: string): boolean {\n return schemeRegex.test(input);\n}\n\nfunction isSchemeRelativeUrl(input: string): boolean {\n return input.startsWith('//');\n}\n\nfunction isAbsolutePath(input: string): boolean {\n return input.startsWith('/');\n}\n\nfunction isFileUrl(input: string): boolean {\n return input.startsWith('file:');\n}\n\nfunction isRelative(input: string): boolean {\n return /^[.?#]/.test(input);\n}\n\nfunction parseAbsoluteUrl(input: string): Url {\n const match = urlRegex.exec(input)!;\n return makeUrl(\n match[1],\n match[2] || '',\n match[3],\n match[4] || '',\n match[5] || '/',\n match[6] || '',\n match[7] || '',\n );\n}\n\nfunction parseFileUrl(input: string): Url {\n const match = fileRegex.exec(input)!;\n const path = match[2];\n return makeUrl(\n 'file:',\n '',\n match[1] || '',\n '',\n isAbsolutePath(path) ? path : '/' + path,\n match[3] || '',\n match[4] || '',\n );\n}\n\nfunction makeUrl(\n scheme: string,\n user: string,\n host: string,\n port: string,\n path: string,\n query: string,\n hash: string,\n): Url {\n return {\n scheme,\n user,\n host,\n port,\n path,\n query,\n hash,\n type: UrlType.Absolute,\n };\n}\n\nfunction parseUrl(input: string): Url {\n if (isSchemeRelativeUrl(input)) {\n const url = parseAbsoluteUrl('http:' + input);\n url.scheme = '';\n url.type = UrlType.SchemeRelative;\n return url;\n }\n\n if (isAbsolutePath(input)) {\n const url = parseAbsoluteUrl('http://foo.com' + input);\n url.scheme = '';\n url.host = '';\n url.type = UrlType.AbsolutePath;\n return url;\n }\n\n if (isFileUrl(input)) return parseFileUrl(input);\n\n if (isAbsoluteUrl(input)) return parseAbsoluteUrl(input);\n\n const url = parseAbsoluteUrl('http://foo.com/' + input);\n url.scheme = '';\n url.host = '';\n url.type = input\n ? input.startsWith('?')\n ? UrlType.Query\n : input.startsWith('#')\n ? UrlType.Hash\n : UrlType.RelativePath\n : UrlType.Empty;\n return url;\n}\n\nfunction stripPathFilename(path: string): string {\n // If a path ends with a parent directory \"..\", then it's a relative path with excess parent\n // paths. It's not a file, so we can't strip it.\n if (path.endsWith('/..')) return path;\n const index = path.lastIndexOf('/');\n return path.slice(0, index + 1);\n}\n\nfunction mergePaths(url: Url, base: Url) {\n normalizePath(base, base.type);\n\n // If the path is just a \"/\", then it was an empty path to begin with (remember, we're a relative\n // path).\n if (url.path === '/') {\n url.path = base.path;\n } else {\n // Resolution happens relative to the base path's directory, not the file.\n url.path = stripPathFilename(base.path) + url.path;\n }\n}\n\n/**\n * The path can have empty directories \"//\", unneeded parents \"foo/..\", or current directory\n * \"foo/.\". We need to normalize to a standard representation.\n */\nfunction normalizePath(url: Url, type: UrlType) {\n const rel = type <= UrlType.RelativePath;\n const pieces = url.path.split('/');\n\n // We need to preserve the first piece always, so that we output a leading slash. The item at\n // pieces[0] is an empty string.\n let pointer = 1;\n\n // Positive is the number of real directories we've output, used for popping a parent directory.\n // Eg, \"foo/bar/..\" will have a positive 2, and we can decrement to be left with just \"foo\".\n let positive = 0;\n\n // We need to keep a trailing slash if we encounter an empty directory (eg, splitting \"foo/\" will\n // generate `[\"foo\", \"\"]` pieces). And, if we pop a parent directory. But once we encounter a\n // real directory, we won't need to append, unless the other conditions happen again.\n let addTrailingSlash = false;\n\n for (let i = 1; i < pieces.length; i++) {\n const piece = pieces[i];\n\n // An empty directory, could be a trailing slash, or just a double \"//\" in the path.\n if (!piece) {\n addTrailingSlash = true;\n continue;\n }\n\n // If we encounter a real directory, then we don't need to append anymore.\n addTrailingSlash = false;\n\n // A current directory, which we can always drop.\n if (piece === '.') continue;\n\n // A parent directory, we need to see if there are any real directories we can pop. Else, we\n // have an excess of parents, and we'll need to keep the \"..\".\n if (piece === '..') {\n if (positive) {\n addTrailingSlash = true;\n positive--;\n pointer--;\n } else if (rel) {\n // If we're in a relativePath, then we need to keep the excess parents. Else, in an absolute\n // URL, protocol relative URL, or an absolute path, we don't need to keep excess.\n pieces[pointer++] = piece;\n }\n continue;\n }\n\n // We've encountered a real directory. Move it to the next insertion pointer, which accounts for\n // any popped or dropped directories.\n pieces[pointer++] = piece;\n positive++;\n }\n\n let path = '';\n for (let i = 1; i < pointer; i++) {\n path += '/' + pieces[i];\n }\n if (!path || (addTrailingSlash && !path.endsWith('/..'))) {\n path += '/';\n }\n url.path = path;\n}\n\n/**\n * Attempts to resolve `input` URL/path relative to `base`.\n */\nexport default function resolve(input: string, base: string | undefined): string {\n if (!input && !base) return '';\n\n const url = parseUrl(input);\n let inputType = url.type;\n\n if (base && inputType !== UrlType.Absolute) {\n const baseUrl = parseUrl(base);\n const baseType = baseUrl.type;\n\n switch (inputType) {\n case UrlType.Empty:\n url.hash = baseUrl.hash;\n // fall through\n\n case UrlType.Hash:\n url.query = baseUrl.query;\n // fall through\n\n case UrlType.Query:\n case UrlType.RelativePath:\n mergePaths(url, baseUrl);\n // fall through\n\n case UrlType.AbsolutePath:\n // The host, user, and port are joined, you can't copy one without the others.\n url.user = baseUrl.user;\n url.host = baseUrl.host;\n url.port = baseUrl.port;\n // fall through\n\n case UrlType.SchemeRelative:\n // The input doesn't have a schema at least, so we need to copy at least that over.\n url.scheme = baseUrl.scheme;\n }\n if (baseType > inputType) inputType = baseType;\n }\n\n normalizePath(url, inputType);\n\n const queryHash = url.query + url.hash;\n switch (inputType) {\n // This is impossible, because of the empty checks at the start of the function.\n // case UrlType.Empty:\n\n case UrlType.Hash:\n case UrlType.Query:\n return queryHash;\n\n case UrlType.RelativePath: {\n // The first char is always a \"/\", and we need it to be relative.\n const path = url.path.slice(1);\n\n if (!path) return queryHash || '.';\n\n if (isRelative(base || input) && !isRelative(path)) {\n // If base started with a leading \".\", or there is no base and input started with a \".\",\n // then we need to ensure that the relative path starts with a \".\". We don't know if\n // relative starts with a \"..\", though, so check before prepending.\n return './' + path + queryHash;\n }\n\n return path + queryHash;\n }\n\n case UrlType.AbsolutePath:\n return url.path + queryHash;\n\n default:\n return url.scheme + '//' + url.user + url.host + url.port + url.path + queryHash;\n }\n}\n"],"names":[],"mappings":"AAAA;AACA,MAAM,WAAW,GAAG,gBAAgB,CAAC;AAErC;;;;;;;;;;AAUA,MAAM,QAAQ,GAAG,0EAA0E,CAAC;AAE5F;;;;;;;;;AASA,MAAM,SAAS,GAAG,iEAAiE,CAAC;AAuBpF,SAAS,aAAa,CAAC,KAAa;IAClC,OAAO,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AACjC,CAAC;AAED,SAAS,mBAAmB,CAAC,KAAa;IACxC,OAAO,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;AAChC,CAAC;AAED,SAAS,cAAc,CAAC,KAAa;IACnC,OAAO,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;AAC/B,CAAC;AAED,SAAS,SAAS,CAAC,KAAa;IAC9B,OAAO,KAAK,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;AACnC,CAAC;AAED,SAAS,UAAU,CAAC,KAAa;IAC/B,OAAO,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AAC9B,CAAC;AAED,SAAS,gBAAgB,CAAC,KAAa;IACrC,MAAM,KAAK,GAAG,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAE,CAAC;IACpC,OAAO,OAAO,CACZ,KAAK,CAAC,CAAC,CAAC,EACR,KAAK,CAAC,CAAC,CAAC,IAAI,EAAE,EACd,KAAK,CAAC,CAAC,CAAC,EACR,KAAK,CAAC,CAAC,CAAC,IAAI,EAAE,EACd,KAAK,CAAC,CAAC,CAAC,IAAI,GAAG,EACf,KAAK,CAAC,CAAC,CAAC,IAAI,EAAE,EACd,KAAK,CAAC,CAAC,CAAC,IAAI,EAAE,CACf,CAAC;AACJ,CAAC;AAED,SAAS,YAAY,CAAC,KAAa;IACjC,MAAM,KA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AC;SACzB;QAED;YACE,OAAO,GAAG,CAAC,IAAI,GAAG,SAAS,CAAC;QAE9B;YACE,OAAO,GAAG,CAAC,MAAM,GAAG,IAAI,GAAG,GAAG,CAAC,IAAI,GAAG,GAAG,CAAC,IAAI,GAAG,GAAG,CAAC,IAAI,GAAG,GAAG,CAAC,IAAI,GAAG,SAAS,CAAC;KACpF;AACH;;;;"} \ No newline at end of file diff --git a/node_modules/@jridgewell/resolve-uri/dist/resolve-uri.umd.js b/node_modules/@jridgewell/resolve-uri/dist/resolve-uri.umd.js new file mode 100644 index 0000000000000000000000000000000000000000..a783049b0136da9128af243b699229e0870aa390 --- /dev/null +++ b/node_modules/@jridgewell/resolve-uri/dist/resolve-uri.umd.js @@ -0,0 +1,240 @@ +(function (global, factory) { + typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : + typeof define === 'function' && define.amd ? define(factory) : + (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.resolveURI = factory()); +})(this, (function () { 'use strict'; + + // Matches the scheme of a URL, eg "http://" + const schemeRegex = /^[\w+.-]+:\/\//; + /** + * Matches the parts of a URL: + * 1. Scheme, including ":", guaranteed. + * 2. User/password, including "@", optional. + * 3. Host, guaranteed. + * 4. Port, including ":", optional. + * 5. Path, including "/", optional. + * 6. Query, including "?", optional. + * 7. Hash, including "#", optional. + */ + const urlRegex = /^([\w+.-]+:)\/\/([^@/#?]*@)?([^:/#?]*)(:\d+)?(\/[^#?]*)?(\?[^#]*)?(#.*)?/; + /** + * File URLs are weird. They dont' need the regular `//` in the scheme, they may or may not start + * with a leading `/`, they can have a domain (but only if they don't start with a Windows drive). + * + * 1. Host, optional. + * 2. Path, which may include "/", guaranteed. + * 3. Query, including "?", optional. + * 4. Hash, including "#", optional. + */ + const fileRegex = /^file:(?:\/\/((?![a-z]:)[^/#?]*)?)?(\/?[^#?]*)(\?[^#]*)?(#.*)?/i; + function isAbsoluteUrl(input) { + return schemeRegex.test(input); + } + function isSchemeRelativeUrl(input) { + return input.startsWith('//'); + } + function isAbsolutePath(input) { + return input.startsWith('/'); + } + function isFileUrl(input) { + return input.startsWith('file:'); + } + function isRelative(input) { + return /^[.?#]/.test(input); + } + function parseAbsoluteUrl(input) { + const match = urlRegex.exec(input); + return makeUrl(match[1], match[2] || '', match[3], match[4] || '', match[5] || '/', match[6] || '', match[7] || ''); + } + function parseFileUrl(input) { + const match = fileRegex.exec(input); + const path = match[2]; + return makeUrl('file:', '', match[1] || '', '', isAbsolutePath(path) ? path : '/' + path, match[3] || '', match[4] || ''); + } + function makeUrl(scheme, user, host, port, path, query, hash) { + return { + scheme, + user, + host, + port, + path, + query, + hash, + type: 7 /* Absolute */, + }; + } + function parseUrl(input) { + if (isSchemeRelativeUrl(input)) { + const url = parseAbsoluteUrl('http:' + input); + url.scheme = ''; + url.type = 6 /* SchemeRelative */; + return url; + } + if (isAbsolutePath(input)) { + const url = parseAbsoluteUrl('http://foo.com' + input); + url.scheme = ''; + url.host = ''; + url.type = 5 /* AbsolutePath */; + return url; + } + if (isFileUrl(input)) + return parseFileUrl(input); + if (isAbsoluteUrl(input)) + return parseAbsoluteUrl(input); + const url = parseAbsoluteUrl('http://foo.com/' + input); + url.scheme = ''; + url.host = ''; + url.type = input + ? input.startsWith('?') + ? 3 /* Query */ + : input.startsWith('#') + ? 2 /* Hash */ + : 4 /* RelativePath */ + : 1 /* Empty */; + return url; + } + function stripPathFilename(path) { + // If a path ends with a parent directory "..", then it's a relative path with excess parent + // paths. It's not a file, so we can't strip it. + if (path.endsWith('/..')) + return path; + const index = path.lastIndexOf('/'); + return path.slice(0, index + 1); + } + function mergePaths(url, base) { + normalizePath(base, base.type); + // If the path is just a "/", then it was an empty path to begin with (remember, we're a relative + // path). + if (url.path === '/') { + url.path = base.path; + } + else { + // Resolution happens relative to the base path's directory, not the file. + url.path = stripPathFilename(base.path) + url.path; + } + } + /** + * The path can have empty directories "//", unneeded parents "foo/..", or current directory + * "foo/.". We need to normalize to a standard representation. + */ + function normalizePath(url, type) { + const rel = type <= 4 /* RelativePath */; + const pieces = url.path.split('/'); + // We need to preserve the first piece always, so that we output a leading slash. The item at + // pieces[0] is an empty string. + let pointer = 1; + // Positive is the number of real directories we've output, used for popping a parent directory. + // Eg, "foo/bar/.." will have a positive 2, and we can decrement to be left with just "foo". + let positive = 0; + // We need to keep a trailing slash if we encounter an empty directory (eg, splitting "foo/" will + // generate `["foo", ""]` pieces). And, if we pop a parent directory. But once we encounter a + // real directory, we won't need to append, unless the other conditions happen again. + let addTrailingSlash = false; + for (let i = 1; i < pieces.length; i++) { + const piece = pieces[i]; + // An empty directory, could be a trailing slash, or just a double "//" in the path. + if (!piece) { + addTrailingSlash = true; + continue; + } + // If we encounter a real directory, then we don't need to append anymore. + addTrailingSlash = false; + // A current directory, which we can always drop. + if (piece === '.') + continue; + // A parent directory, we need to see if there are any real directories we can pop. Else, we + // have an excess of parents, and we'll need to keep the "..". + if (piece === '..') { + if (positive) { + addTrailingSlash = true; + positive--; + pointer--; + } + else if (rel) { + // If we're in a relativePath, then we need to keep the excess parents. Else, in an absolute + // URL, protocol relative URL, or an absolute path, we don't need to keep excess. + pieces[pointer++] = piece; + } + continue; + } + // We've encountered a real directory. Move it to the next insertion pointer, which accounts for + // any popped or dropped directories. + pieces[pointer++] = piece; + positive++; + } + let path = ''; + for (let i = 1; i < pointer; i++) { + path += '/' + pieces[i]; + } + if (!path || (addTrailingSlash && !path.endsWith('/..'))) { + path += '/'; + } + url.path = path; + } + /** + * Attempts to resolve `input` URL/path relative to `base`. + */ + function resolve(input, base) { + if (!input && !base) + return ''; + const url = parseUrl(input); + let inputType = url.type; + if (base && inputType !== 7 /* Absolute */) { + const baseUrl = parseUrl(base); + const baseType = baseUrl.type; + switch (inputType) { + case 1 /* Empty */: + url.hash = baseUrl.hash; + // fall through + case 2 /* Hash */: + url.query = baseUrl.query; + // fall through + case 3 /* Query */: + case 4 /* RelativePath */: + mergePaths(url, baseUrl); + // fall through + case 5 /* AbsolutePath */: + // The host, user, and port are joined, you can't copy one without the others. + url.user = baseUrl.user; + url.host = baseUrl.host; + url.port = baseUrl.port; + // fall through + case 6 /* SchemeRelative */: + // The input doesn't have a schema at least, so we need to copy at least that over. + url.scheme = baseUrl.scheme; + } + if (baseType > inputType) + inputType = baseType; + } + normalizePath(url, inputType); + const queryHash = url.query + url.hash; + switch (inputType) { + // This is impossible, because of the empty checks at the start of the function. + // case UrlType.Empty: + case 2 /* Hash */: + case 3 /* Query */: + return queryHash; + case 4 /* RelativePath */: { + // The first char is always a "/", and we need it to be relative. + const path = url.path.slice(1); + if (!path) + return queryHash || '.'; + if (isRelative(base || input) && !isRelative(path)) { + // If base started with a leading ".", or there is no base and input started with a ".", + // then we need to ensure that the relative path starts with a ".". We don't know if + // relative starts with a "..", though, so check before prepending. + return './' + path + queryHash; + } + return path + queryHash; + } + case 5 /* AbsolutePath */: + return url.path + queryHash; + default: + return url.scheme + '//' + url.user + url.host + url.port + url.path + queryHash; + } + } + + return resolve; + +})); +//# sourceMappingURL=resolve-uri.umd.js.map diff --git a/node_modules/@jridgewell/resolve-uri/dist/resolve-uri.umd.js.map b/node_modules/@jridgewell/resolve-uri/dist/resolve-uri.umd.js.map new file mode 100644 index 0000000000000000000000000000000000000000..70a37f21da35cad5db599004fb8ca601f3dfa57b --- /dev/null +++ b/node_modules/@jridgewell/resolve-uri/dist/resolve-uri.umd.js.map @@ -0,0 +1 @@ +{"version":3,"file":"resolve-uri.umd.js","sources":["../src/resolve-uri.ts"],"sourcesContent":["// Matches the scheme of a URL, eg \"http://\"\nconst schemeRegex = /^[\\w+.-]+:\\/\\//;\n\n/**\n * Matches the parts of a URL:\n * 1. Scheme, including \":\", guaranteed.\n * 2. User/password, including \"@\", optional.\n * 3. Host, guaranteed.\n * 4. Port, including \":\", optional.\n * 5. Path, including \"/\", optional.\n * 6. Query, including \"?\", optional.\n * 7. Hash, including \"#\", optional.\n */\nconst urlRegex = /^([\\w+.-]+:)\\/\\/([^@/#?]*@)?([^:/#?]*)(:\\d+)?(\\/[^#?]*)?(\\?[^#]*)?(#.*)?/;\n\n/**\n * File URLs are weird. They dont' need the regular `//` in the scheme, they may or may not start\n * with a leading `/`, they can have a domain (but only if they don't start with a Windows drive).\n *\n * 1. Host, optional.\n * 2. Path, which may include \"/\", guaranteed.\n * 3. Query, including \"?\", optional.\n * 4. Hash, including \"#\", optional.\n */\nconst fileRegex = /^file:(?:\\/\\/((?![a-z]:)[^/#?]*)?)?(\\/?[^#?]*)(\\?[^#]*)?(#.*)?/i;\n\ntype Url = {\n scheme: string;\n user: string;\n host: string;\n port: string;\n path: string;\n query: string;\n hash: string;\n type: UrlType;\n};\n\nconst enum UrlType {\n Empty = 1,\n Hash = 2,\n Query = 3,\n RelativePath = 4,\n AbsolutePath = 5,\n SchemeRelative = 6,\n Absolute = 7,\n}\n\nfunction isAbsoluteUrl(input: string): boolean {\n return schemeRegex.test(input);\n}\n\nfunction isSchemeRelativeUrl(input: string): boolean {\n return input.startsWith('//');\n}\n\nfunction isAbsolutePath(input: string): boolean {\n return input.startsWith('/');\n}\n\nfunction isFileUrl(input: string): boolean {\n return input.startsWith('file:');\n}\n\nfunction isRelative(input: string): boolean {\n return /^[.?#]/.test(input);\n}\n\nfunction parseAbsoluteUrl(input: string): Url {\n const match = urlRegex.exec(input)!;\n return makeUrl(\n match[1],\n match[2] || '',\n match[3],\n match[4] || '',\n match[5] || '/',\n match[6] || '',\n match[7] || '',\n );\n}\n\nfunction parseFileUrl(input: string): Url {\n const match = fileRegex.exec(input)!;\n const path = match[2];\n return makeUrl(\n 'file:',\n '',\n match[1] || '',\n '',\n isAbsolutePath(path) ? path : '/' + path,\n match[3] || '',\n match[4] || '',\n );\n}\n\nfunction makeUrl(\n scheme: string,\n user: string,\n host: string,\n port: string,\n path: string,\n query: string,\n hash: string,\n): Url {\n return {\n scheme,\n user,\n host,\n port,\n path,\n query,\n hash,\n type: UrlType.Absolute,\n };\n}\n\nfunction parseUrl(input: string): Url {\n if (isSchemeRelativeUrl(input)) {\n const url = parseAbsoluteUrl('http:' + input);\n url.scheme = '';\n url.type = UrlType.SchemeRelative;\n return url;\n }\n\n if (isAbsolutePath(input)) {\n const url = parseAbsoluteUrl('http://foo.com' + input);\n url.scheme = '';\n url.host = '';\n url.type = UrlType.AbsolutePath;\n return url;\n }\n\n if (isFileUrl(input)) return parseFileUrl(input);\n\n if (isAbsoluteUrl(input)) return parseAbsoluteUrl(input);\n\n const url = parseAbsoluteUrl('http://foo.com/' + input);\n url.scheme = '';\n url.host = '';\n url.type = input\n ? input.startsWith('?')\n ? UrlType.Query\n : input.startsWith('#')\n ? UrlType.Hash\n : UrlType.RelativePath\n : UrlType.Empty;\n return url;\n}\n\nfunction stripPathFilename(path: string): string {\n // If a path ends with a parent directory \"..\", then it's a relative path with excess parent\n // paths. It's not a file, so we can't strip it.\n if (path.endsWith('/..')) return path;\n const index = path.lastIndexOf('/');\n return path.slice(0, index + 1);\n}\n\nfunction mergePaths(url: Url, base: Url) {\n normalizePath(base, base.type);\n\n // If the path is just a \"/\", then it was an empty path to begin with (remember, we're a relative\n // path).\n if (url.path === '/') {\n url.path = base.path;\n } else {\n // Resolution happens relative to the base path's directory, not the file.\n url.path = stripPathFilename(base.path) + url.path;\n }\n}\n\n/**\n * The path can have empty directories \"//\", unneeded parents \"foo/..\", or current directory\n * \"foo/.\". We need to normalize to a standard representation.\n */\nfunction normalizePath(url: Url, type: UrlType) {\n const rel = type <= UrlType.RelativePath;\n const pieces = url.path.split('/');\n\n // We need to preserve the first piece always, so that we output a leading slash. The item at\n // pieces[0] is an empty string.\n let pointer = 1;\n\n // Positive is the number of real directories we've output, used for popping a parent directory.\n // Eg, \"foo/bar/..\" will have a positive 2, and we can decrement to be left with just \"foo\".\n let positive = 0;\n\n // We need to keep a trailing slash if we encounter an empty directory (eg, splitting \"foo/\" will\n // generate `[\"foo\", \"\"]` pieces). And, if we pop a parent directory. But once we encounter a\n // real directory, we won't need to append, unless the other conditions happen again.\n let addTrailingSlash = false;\n\n for (let i = 1; i < pieces.length; i++) {\n const piece = pieces[i];\n\n // An empty directory, could be a trailing slash, or just a double \"//\" in the path.\n if (!piece) {\n addTrailingSlash = true;\n continue;\n }\n\n // If we encounter a real directory, then we don't need to append anymore.\n addTrailingSlash = false;\n\n // A current directory, which we can always drop.\n if (piece === '.') continue;\n\n // A parent directory, we need to see if there are any real directories we can pop. Else, we\n // have an excess of parents, and we'll need to keep the \"..\".\n if (piece === '..') {\n if (positive) {\n addTrailingSlash = true;\n positive--;\n pointer--;\n } else if (rel) {\n // If we're in a relativePath, then we need to keep the excess parents. Else, in an absolute\n // URL, protocol relative URL, or an absolute path, we don't need to keep excess.\n pieces[pointer++] = piece;\n }\n continue;\n }\n\n // We've encountered a real directory. Move it to the next insertion pointer, which accounts for\n // any popped or dropped directories.\n pieces[pointer++] = piece;\n positive++;\n }\n\n let path = '';\n for (let i = 1; i < pointer; i++) {\n path += '/' + pieces[i];\n }\n if (!path || (addTrailingSlash && !path.endsWith('/..'))) {\n path += '/';\n }\n url.path = path;\n}\n\n/**\n * Attempts to resolve `input` URL/path relative to `base`.\n */\nexport default function resolve(input: string, base: string | undefined): string {\n if (!input && !base) return '';\n\n const url = parseUrl(input);\n let inputType = url.type;\n\n if (base && inputType !== UrlType.Absolute) {\n const baseUrl = parseUrl(base);\n const baseType = baseUrl.type;\n\n switch (inputType) {\n case UrlType.Empty:\n url.hash = baseUrl.hash;\n // fall through\n\n case UrlType.Hash:\n url.query = baseUrl.query;\n // fall through\n\n case UrlType.Query:\n case UrlType.RelativePath:\n mergePaths(url, baseUrl);\n // fall through\n\n case UrlType.AbsolutePath:\n // The host, user, and port are joined, you can't copy one without the others.\n url.user = baseUrl.user;\n url.host = baseUrl.host;\n url.port = baseUrl.port;\n // fall through\n\n case UrlType.SchemeRelative:\n // The input doesn't have a schema at least, so we need to copy at least that over.\n url.scheme = baseUrl.scheme;\n }\n if (baseType > inputType) inputType = baseType;\n }\n\n normalizePath(url, inputType);\n\n const queryHash = url.query + url.hash;\n switch (inputType) {\n // This is impossible, because of the empty checks at the start of the function.\n // case UrlType.Empty:\n\n case UrlType.Hash:\n case UrlType.Query:\n return queryHash;\n\n case UrlType.RelativePath: {\n // The first char is always a \"/\", and we need it to be relative.\n const path = url.path.slice(1);\n\n if (!path) return queryHash || '.';\n\n if (isRelative(base || input) && !isRelative(path)) {\n // If base started with a leading \".\", or there is no base and input started with a \".\",\n // then we need to ensure that the relative path starts with a \".\". We don't know if\n // relative starts with a \"..\", though, so check before prepending.\n return './' + path + queryHash;\n }\n\n return path + queryHash;\n }\n\n case UrlType.AbsolutePath:\n return url.path + queryHash;\n\n default:\n return url.scheme + '//' + url.user + url.host + url.port + url.path + queryHash;\n }\n}\n"],"names":[],"mappings":";;;;;;IAAA;IACA,MAAM,WAAW,GAAG,gBAAgB,CAAC;IAErC;;;;;;;;;;IAUA,MAAM,QAAQ,GAAG,0EAA0E,CAAC;IAE5F;;;;;;;;;IASA,MAAM,SAAS,GAAG,iEAAiE,CAAC;IAuBpF,SAAS,aAAa,CAAC,KAAa;QAClC,OAAO,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACjC,CAAC;IAED,SAAS,mBAAmB,CAAC,KAAa;QACxC,OAAO,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;IAChC,CAAC;IAED,SAAS,cAAc,CAAC,KAAa;QACnC,OAAO,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;IAC/B,CAAC;IAED,SAAS,SAAS,CAAC,KAAa;QAC9B,OAAO,KAAK,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;IACnC,CAAC;IAED,SAAS,UAAU,CAAC,KAAa;QAC/B,OAAO,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC9B,CAAC;IAED,SAAS,gBAAgB,CAAC,KAAa;QACrC,MAAM,KAAK,GAAG,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAE,CAAC;QACpC,OAAO,OAAO,CACZ,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;YAEnB,2BAA2B;;gBAEzB,MAAM,IAAI,GAAG,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;gBAE/B,IAAI,CAAC,IAAI;oBAAE,OAAO,SAAS,IAAI,GAAG,CAAC;gBAEnC,IAAI,UAAU,CAAC,IAAI,IAAI,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE;;;;oBAIlD,OAAO,IAAI,GAAG,IAAI,GAAG,SAAS,CAAC;iBAChC;gBAED,OAAO,IAAI,GAAG,SAAS,CAAC;aACzB;YAED;gBACE,OAAO,GAAG,CAAC,IAAI,GAAG,SAAS,CAAC;YAE9B;gBACE,OAAO,GAAG,CAAC,MAAM,GAAG,IAAI,GAAG,GAAG,CAAC,IAAI,GAAG,GAAG,CAAC,IAAI,GAAG,GAAG,CAAC,IAAI,GAAG,GAAG,CAAC,IAAI,GAAG,SAAS,CAAC;SACpF;IACH;;;;;;;;"} \ No newline at end of file diff --git a/node_modules/@jridgewell/resolve-uri/dist/types/resolve-uri.d.ts b/node_modules/@jridgewell/resolve-uri/dist/types/resolve-uri.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..b7f0b3b2d7d2eba98141e8b346328b1ff6d6118c --- /dev/null +++ b/node_modules/@jridgewell/resolve-uri/dist/types/resolve-uri.d.ts @@ -0,0 +1,4 @@ +/** + * Attempts to resolve `input` URL/path relative to `base`. + */ +export default function resolve(input: string, base: string | undefined): string; diff --git a/node_modules/@jridgewell/resolve-uri/package.json b/node_modules/@jridgewell/resolve-uri/package.json new file mode 100644 index 0000000000000000000000000000000000000000..02a4c5187e7ca726d36ff24dda674400b1c3f846 --- /dev/null +++ b/node_modules/@jridgewell/resolve-uri/package.json @@ -0,0 +1,69 @@ +{ + "name": "@jridgewell/resolve-uri", + "version": "3.1.2", + "description": "Resolve a URI relative to an optional base URI", + "keywords": [ + "resolve", + "uri", + "url", + "path" + ], + "author": "Justin Ridgewell ", + "license": "MIT", + "repository": "https://github.com/jridgewell/resolve-uri", + "main": "dist/resolve-uri.umd.js", + "module": "dist/resolve-uri.mjs", + "types": "dist/types/resolve-uri.d.ts", + "exports": { + ".": [ + { + "types": "./dist/types/resolve-uri.d.ts", + "browser": "./dist/resolve-uri.umd.js", + "require": "./dist/resolve-uri.umd.js", + "import": "./dist/resolve-uri.mjs" + }, + "./dist/resolve-uri.umd.js" + ], + "./package.json": "./package.json" + }, + "files": [ + "dist" + ], + "engines": { + "node": ">=6.0.0" + }, + "scripts": { + "prebuild": "rm -rf dist", + "build": "run-s -n build:*", + "build:rollup": "rollup -c rollup.config.js", + "build:ts": "tsc --project tsconfig.build.json", + "lint": "run-s -n lint:*", + "lint:prettier": "npm run test:lint:prettier -- --write", + "lint:ts": "npm run test:lint:ts -- --fix", + "pretest": "run-s build:rollup", + "test": "run-s -n test:lint test:only", + "test:debug": "mocha --inspect-brk", + "test:lint": "run-s -n test:lint:*", + "test:lint:prettier": "prettier --check '{src,test}/**/*.ts'", + "test:lint:ts": "eslint '{src,test}/**/*.ts'", + "test:only": "mocha", + "test:coverage": "c8 mocha", + "test:watch": "mocha --watch", + "prepublishOnly": "npm run preversion", + "preversion": "run-s test build" + }, + "devDependencies": { + "@jridgewell/resolve-uri-latest": "npm:@jridgewell/resolve-uri@*", + "@rollup/plugin-typescript": "8.3.0", + "@typescript-eslint/eslint-plugin": "5.10.0", + "@typescript-eslint/parser": "5.10.0", + "c8": "7.11.0", + "eslint": "8.7.0", + "eslint-config-prettier": "8.3.0", + "mocha": "9.2.0", + "npm-run-all": "4.1.5", + "prettier": "2.5.1", + "rollup": "2.66.0", + "typescript": "4.5.5" + } +} diff --git a/node_modules/@jridgewell/sourcemap-codec/LICENSE b/node_modules/@jridgewell/sourcemap-codec/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..1f6ce94c11912496b96298630d84753dbf593a7d --- /dev/null +++ b/node_modules/@jridgewell/sourcemap-codec/LICENSE @@ -0,0 +1,19 @@ +Copyright 2024 Justin Ridgewell + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/node_modules/@jridgewell/sourcemap-codec/README.md b/node_modules/@jridgewell/sourcemap-codec/README.md new file mode 100644 index 0000000000000000000000000000000000000000..b3e0708bf93737649c24aefc0cf216f23905908e --- /dev/null +++ b/node_modules/@jridgewell/sourcemap-codec/README.md @@ -0,0 +1,264 @@ +# @jridgewell/sourcemap-codec + +Encode/decode the `mappings` property of a [sourcemap](https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit). + + +## Why? + +Sourcemaps are difficult to generate and manipulate, because the `mappings` property – the part that actually links the generated code back to the original source – is encoded using an obscure method called [Variable-length quantity](https://en.wikipedia.org/wiki/Variable-length_quantity). On top of that, each segment in the mapping contains offsets rather than absolute indices, which means that you can't look at a segment in isolation – you have to understand the whole sourcemap. + +This package makes the process slightly easier. + + +## Installation + +```bash +npm install @jridgewell/sourcemap-codec +``` + + +## Usage + +```js +import { encode, decode } from '@jridgewell/sourcemap-codec'; + +var decoded = decode( ';EAEEA,EAAE,EAAC,CAAE;ECQY,UACC' ); + +assert.deepEqual( decoded, [ + // the first line (of the generated code) has no mappings, + // as shown by the starting semi-colon (which separates lines) + [], + + // the second line contains four (comma-separated) segments + [ + // segments are encoded as you'd expect: + // [ generatedCodeColumn, sourceIndex, sourceCodeLine, sourceCodeColumn, nameIndex ] + + // i.e. the first segment begins at column 2, and maps back to the second column + // of the second line (both zero-based) of the 0th source, and uses the 0th + // name in the `map.names` array + [ 2, 0, 2, 2, 0 ], + + // the remaining segments are 4-length rather than 5-length, + // because they don't map a name + [ 4, 0, 2, 4 ], + [ 6, 0, 2, 5 ], + [ 7, 0, 2, 7 ] + ], + + // the final line contains two segments + [ + [ 2, 1, 10, 19 ], + [ 12, 1, 11, 20 ] + ] +]); + +var encoded = encode( decoded ); +assert.equal( encoded, ';EAEEA,EAAE,EAAC,CAAE;ECQY,UACC' ); +``` + +## Benchmarks + +``` +node v20.10.0 + +amp.js.map - 45120 segments + +Decode Memory Usage: +local code 5815135 bytes +@jridgewell/sourcemap-codec 1.4.15 5868160 bytes +sourcemap-codec 5492584 bytes +source-map-0.6.1 13569984 bytes +source-map-0.8.0 6390584 bytes +chrome dev tools 8011136 bytes +Smallest memory usage is sourcemap-codec + +Decode speed: +decode: local code x 492 ops/sec ±1.22% (90 runs sampled) +decode: @jridgewell/sourcemap-codec 1.4.15 x 499 ops/sec ±1.16% (89 runs sampled) +decode: sourcemap-codec x 376 ops/sec ±1.66% (89 runs sampled) +decode: source-map-0.6.1 x 34.99 ops/sec ±0.94% (48 runs sampled) +decode: source-map-0.8.0 x 351 ops/sec ±0.07% (95 runs sampled) +chrome dev tools x 165 ops/sec ±0.91% (86 runs sampled) +Fastest is decode: @jridgewell/sourcemap-codec 1.4.15 + +Encode Memory Usage: +local code 444248 bytes +@jridgewell/sourcemap-codec 1.4.15 623024 bytes +sourcemap-codec 8696280 bytes +source-map-0.6.1 8745176 bytes +source-map-0.8.0 8736624 bytes +Smallest memory usage is local code + +Encode speed: +encode: local code x 796 ops/sec ±0.11% (97 runs sampled) +encode: @jridgewell/sourcemap-codec 1.4.15 x 795 ops/sec ±0.25% (98 runs sampled) +encode: sourcemap-codec x 231 ops/sec ±0.83% (86 runs sampled) +encode: source-map-0.6.1 x 166 ops/sec ±0.57% (86 runs sampled) +encode: source-map-0.8.0 x 203 ops/sec ±0.45% (88 runs sampled) +Fastest is encode: local code,encode: @jridgewell/sourcemap-codec 1.4.15 + + +*** + + +babel.min.js.map - 347793 segments + +Decode Memory Usage: +local code 35424960 bytes +@jridgewell/sourcemap-codec 1.4.15 35424696 bytes +sourcemap-codec 36033464 bytes +source-map-0.6.1 62253704 bytes +source-map-0.8.0 43843920 bytes +chrome dev tools 45111400 bytes +Smallest memory usage is @jridgewell/sourcemap-codec 1.4.15 + +Decode speed: +decode: local code x 38.18 ops/sec ±5.44% (52 runs sampled) +decode: @jridgewell/sourcemap-codec 1.4.15 x 38.36 ops/sec ±5.02% (52 runs sampled) +decode: sourcemap-codec x 34.05 ops/sec ±4.45% (47 runs sampled) +decode: source-map-0.6.1 x 4.31 ops/sec ±2.76% (15 runs sampled) +decode: source-map-0.8.0 x 55.60 ops/sec ±0.13% (73 runs sampled) +chrome dev tools x 16.94 ops/sec ±3.78% (46 runs sampled) +Fastest is decode: source-map-0.8.0 + +Encode Memory Usage: +local code 2606016 bytes +@jridgewell/sourcemap-codec 1.4.15 2626440 bytes +sourcemap-codec 21152576 bytes +source-map-0.6.1 25023928 bytes +source-map-0.8.0 25256448 bytes +Smallest memory usage is local code + +Encode speed: +encode: local code x 127 ops/sec ±0.18% (83 runs sampled) +encode: @jridgewell/sourcemap-codec 1.4.15 x 128 ops/sec ±0.26% (83 runs sampled) +encode: sourcemap-codec x 29.31 ops/sec ±2.55% (53 runs sampled) +encode: source-map-0.6.1 x 18.85 ops/sec ±3.19% (36 runs sampled) +encode: source-map-0.8.0 x 19.34 ops/sec ±1.97% (36 runs sampled) +Fastest is encode: @jridgewell/sourcemap-codec 1.4.15 + + +*** + + +preact.js.map - 1992 segments + +Decode Memory Usage: +local code 261696 bytes +@jridgewell/sourcemap-codec 1.4.15 244296 bytes +sourcemap-codec 302816 bytes +source-map-0.6.1 939176 bytes +source-map-0.8.0 336 bytes +chrome dev tools 587368 bytes +Smallest memory usage is source-map-0.8.0 + +Decode speed: +decode: local code x 17,782 ops/sec ±0.32% (97 runs sampled) +decode: @jridgewell/sourcemap-codec 1.4.15 x 17,863 ops/sec ±0.40% (100 runs sampled) +decode: sourcemap-codec x 12,453 ops/sec ±0.27% (101 runs sampled) +decode: source-map-0.6.1 x 1,288 ops/sec ±1.05% (96 runs sampled) +decode: source-map-0.8.0 x 9,289 ops/sec ±0.27% (101 runs sampled) +chrome dev tools x 4,769 ops/sec ±0.18% (100 runs sampled) +Fastest is decode: @jridgewell/sourcemap-codec 1.4.15 + +Encode Memory Usage: +local code 262944 bytes +@jridgewell/sourcemap-codec 1.4.15 25544 bytes +sourcemap-codec 323048 bytes +source-map-0.6.1 507808 bytes +source-map-0.8.0 507480 bytes +Smallest memory usage is @jridgewell/sourcemap-codec 1.4.15 + +Encode speed: +encode: local code x 24,207 ops/sec ±0.79% (95 runs sampled) +encode: @jridgewell/sourcemap-codec 1.4.15 x 24,288 ops/sec ±0.48% (96 runs sampled) +encode: sourcemap-codec x 6,761 ops/sec ±0.21% (100 runs sampled) +encode: source-map-0.6.1 x 5,374 ops/sec ±0.17% (99 runs sampled) +encode: source-map-0.8.0 x 5,633 ops/sec ±0.32% (99 runs sampled) +Fastest is encode: @jridgewell/sourcemap-codec 1.4.15,encode: local code + + +*** + + +react.js.map - 5726 segments + +Decode Memory Usage: +local code 678816 bytes +@jridgewell/sourcemap-codec 1.4.15 678816 bytes +sourcemap-codec 816400 bytes +source-map-0.6.1 2288864 bytes +source-map-0.8.0 721360 bytes +chrome dev tools 1012512 bytes +Smallest memory usage is local code + +Decode speed: +decode: local code x 6,178 ops/sec ±0.19% (98 runs sampled) +decode: @jridgewell/sourcemap-codec 1.4.15 x 6,261 ops/sec ±0.22% (100 runs sampled) +decode: sourcemap-codec x 4,472 ops/sec ±0.90% (99 runs sampled) +decode: source-map-0.6.1 x 449 ops/sec ±0.31% (95 runs sampled) +decode: source-map-0.8.0 x 3,219 ops/sec ±0.13% (100 runs sampled) +chrome dev tools x 1,743 ops/sec ±0.20% (99 runs sampled) +Fastest is decode: @jridgewell/sourcemap-codec 1.4.15 + +Encode Memory Usage: +local code 140960 bytes +@jridgewell/sourcemap-codec 1.4.15 159808 bytes +sourcemap-codec 969304 bytes +source-map-0.6.1 930520 bytes +source-map-0.8.0 930248 bytes +Smallest memory usage is local code + +Encode speed: +encode: local code x 8,013 ops/sec ±0.19% (100 runs sampled) +encode: @jridgewell/sourcemap-codec 1.4.15 x 7,989 ops/sec ±0.20% (101 runs sampled) +encode: sourcemap-codec x 2,472 ops/sec ±0.21% (99 runs sampled) +encode: source-map-0.6.1 x 2,200 ops/sec ±0.17% (99 runs sampled) +encode: source-map-0.8.0 x 2,220 ops/sec ±0.37% (99 runs sampled) +Fastest is encode: local code + + +*** + + +vscode.map - 2141001 segments + +Decode Memory Usage: +local code 198955264 bytes +@jridgewell/sourcemap-codec 1.4.15 199175352 bytes +sourcemap-codec 199102688 bytes +source-map-0.6.1 386323432 bytes +source-map-0.8.0 244116432 bytes +chrome dev tools 293734280 bytes +Smallest memory usage is local code + +Decode speed: +decode: local code x 3.90 ops/sec ±22.21% (15 runs sampled) +decode: @jridgewell/sourcemap-codec 1.4.15 x 3.95 ops/sec ±23.53% (15 runs sampled) +decode: sourcemap-codec x 3.82 ops/sec ±17.94% (14 runs sampled) +decode: source-map-0.6.1 x 0.61 ops/sec ±7.81% (6 runs sampled) +decode: source-map-0.8.0 x 9.54 ops/sec ±0.28% (28 runs sampled) +chrome dev tools x 2.18 ops/sec ±10.58% (10 runs sampled) +Fastest is decode: source-map-0.8.0 + +Encode Memory Usage: +local code 13509880 bytes +@jridgewell/sourcemap-codec 1.4.15 13537648 bytes +sourcemap-codec 32540104 bytes +source-map-0.6.1 127531040 bytes +source-map-0.8.0 127535312 bytes +Smallest memory usage is local code + +Encode speed: +encode: local code x 20.10 ops/sec ±0.19% (38 runs sampled) +encode: @jridgewell/sourcemap-codec 1.4.15 x 20.26 ops/sec ±0.32% (38 runs sampled) +encode: sourcemap-codec x 5.44 ops/sec ±1.64% (18 runs sampled) +encode: source-map-0.6.1 x 2.30 ops/sec ±4.79% (10 runs sampled) +encode: source-map-0.8.0 x 2.46 ops/sec ±6.53% (10 runs sampled) +Fastest is encode: @jridgewell/sourcemap-codec 1.4.15 +``` + +# License + +MIT diff --git a/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.mjs b/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.mjs new file mode 100644 index 0000000000000000000000000000000000000000..532bab39f010d1ce7988e3ae3f7e23a28d5a43a5 --- /dev/null +++ b/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.mjs @@ -0,0 +1,423 @@ +// src/vlq.ts +var comma = ",".charCodeAt(0); +var semicolon = ";".charCodeAt(0); +var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; +var intToChar = new Uint8Array(64); +var charToInt = new Uint8Array(128); +for (let i = 0; i < chars.length; i++) { + const c = chars.charCodeAt(i); + intToChar[i] = c; + charToInt[c] = i; +} +function decodeInteger(reader, relative) { + let value = 0; + let shift = 0; + let integer = 0; + do { + const c = reader.next(); + integer = charToInt[c]; + value |= (integer & 31) << shift; + shift += 5; + } while (integer & 32); + const shouldNegate = value & 1; + value >>>= 1; + if (shouldNegate) { + value = -2147483648 | -value; + } + return relative + value; +} +function encodeInteger(builder, num, relative) { + let delta = num - relative; + delta = delta < 0 ? -delta << 1 | 1 : delta << 1; + do { + let clamped = delta & 31; + delta >>>= 5; + if (delta > 0) clamped |= 32; + builder.write(intToChar[clamped]); + } while (delta > 0); + return num; +} +function hasMoreVlq(reader, max) { + if (reader.pos >= max) return false; + return reader.peek() !== comma; +} + +// src/strings.ts +var bufLength = 1024 * 16; +var td = typeof TextDecoder !== "undefined" ? /* @__PURE__ */ new TextDecoder() : typeof Buffer !== "undefined" ? { + decode(buf) { + const out = Buffer.from(buf.buffer, buf.byteOffset, buf.byteLength); + return out.toString(); + } +} : { + decode(buf) { + let out = ""; + for (let i = 0; i < buf.length; i++) { + out += String.fromCharCode(buf[i]); + } + return out; + } +}; +var StringWriter = class { + constructor() { + this.pos = 0; + this.out = ""; + this.buffer = new Uint8Array(bufLength); + } + write(v) { + const { buffer } = this; + buffer[this.pos++] = v; + if (this.pos === bufLength) { + this.out += td.decode(buffer); + this.pos = 0; + } + } + flush() { + const { buffer, out, pos } = this; + return pos > 0 ? out + td.decode(buffer.subarray(0, pos)) : out; + } +}; +var StringReader = class { + constructor(buffer) { + this.pos = 0; + this.buffer = buffer; + } + next() { + return this.buffer.charCodeAt(this.pos++); + } + peek() { + return this.buffer.charCodeAt(this.pos); + } + indexOf(char) { + const { buffer, pos } = this; + const idx = buffer.indexOf(char, pos); + return idx === -1 ? buffer.length : idx; + } +}; + +// src/scopes.ts +var EMPTY = []; +function decodeOriginalScopes(input) { + const { length } = input; + const reader = new StringReader(input); + const scopes = []; + const stack = []; + let line = 0; + for (; reader.pos < length; reader.pos++) { + line = decodeInteger(reader, line); + const column = decodeInteger(reader, 0); + if (!hasMoreVlq(reader, length)) { + const last = stack.pop(); + last[2] = line; + last[3] = column; + continue; + } + const kind = decodeInteger(reader, 0); + const fields = decodeInteger(reader, 0); + const hasName = fields & 1; + const scope = hasName ? [line, column, 0, 0, kind, decodeInteger(reader, 0)] : [line, column, 0, 0, kind]; + let vars = EMPTY; + if (hasMoreVlq(reader, length)) { + vars = []; + do { + const varsIndex = decodeInteger(reader, 0); + vars.push(varsIndex); + } while (hasMoreVlq(reader, length)); + } + scope.vars = vars; + scopes.push(scope); + stack.push(scope); + } + return scopes; +} +function encodeOriginalScopes(scopes) { + const writer = new StringWriter(); + for (let i = 0; i < scopes.length; ) { + i = _encodeOriginalScopes(scopes, i, writer, [0]); + } + return writer.flush(); +} +function _encodeOriginalScopes(scopes, index, writer, state) { + const scope = scopes[index]; + const { 0: startLine, 1: startColumn, 2: endLine, 3: endColumn, 4: kind, vars } = scope; + if (index > 0) writer.write(comma); + state[0] = encodeInteger(writer, startLine, state[0]); + encodeInteger(writer, startColumn, 0); + encodeInteger(writer, kind, 0); + const fields = scope.length === 6 ? 1 : 0; + encodeInteger(writer, fields, 0); + if (scope.length === 6) encodeInteger(writer, scope[5], 0); + for (const v of vars) { + encodeInteger(writer, v, 0); + } + for (index++; index < scopes.length; ) { + const next = scopes[index]; + const { 0: l, 1: c } = next; + if (l > endLine || l === endLine && c >= endColumn) { + break; + } + index = _encodeOriginalScopes(scopes, index, writer, state); + } + writer.write(comma); + state[0] = encodeInteger(writer, endLine, state[0]); + encodeInteger(writer, endColumn, 0); + return index; +} +function decodeGeneratedRanges(input) { + const { length } = input; + const reader = new StringReader(input); + const ranges = []; + const stack = []; + let genLine = 0; + let definitionSourcesIndex = 0; + let definitionScopeIndex = 0; + let callsiteSourcesIndex = 0; + let callsiteLine = 0; + let callsiteColumn = 0; + let bindingLine = 0; + let bindingColumn = 0; + do { + const semi = reader.indexOf(";"); + let genColumn = 0; + for (; reader.pos < semi; reader.pos++) { + genColumn = decodeInteger(reader, genColumn); + if (!hasMoreVlq(reader, semi)) { + const last = stack.pop(); + last[2] = genLine; + last[3] = genColumn; + continue; + } + const fields = decodeInteger(reader, 0); + const hasDefinition = fields & 1; + const hasCallsite = fields & 2; + const hasScope = fields & 4; + let callsite = null; + let bindings = EMPTY; + let range; + if (hasDefinition) { + const defSourcesIndex = decodeInteger(reader, definitionSourcesIndex); + definitionScopeIndex = decodeInteger( + reader, + definitionSourcesIndex === defSourcesIndex ? definitionScopeIndex : 0 + ); + definitionSourcesIndex = defSourcesIndex; + range = [genLine, genColumn, 0, 0, defSourcesIndex, definitionScopeIndex]; + } else { + range = [genLine, genColumn, 0, 0]; + } + range.isScope = !!hasScope; + if (hasCallsite) { + const prevCsi = callsiteSourcesIndex; + const prevLine = callsiteLine; + callsiteSourcesIndex = decodeInteger(reader, callsiteSourcesIndex); + const sameSource = prevCsi === callsiteSourcesIndex; + callsiteLine = decodeInteger(reader, sameSource ? callsiteLine : 0); + callsiteColumn = decodeInteger( + reader, + sameSource && prevLine === callsiteLine ? callsiteColumn : 0 + ); + callsite = [callsiteSourcesIndex, callsiteLine, callsiteColumn]; + } + range.callsite = callsite; + if (hasMoreVlq(reader, semi)) { + bindings = []; + do { + bindingLine = genLine; + bindingColumn = genColumn; + const expressionsCount = decodeInteger(reader, 0); + let expressionRanges; + if (expressionsCount < -1) { + expressionRanges = [[decodeInteger(reader, 0)]]; + for (let i = -1; i > expressionsCount; i--) { + const prevBl = bindingLine; + bindingLine = decodeInteger(reader, bindingLine); + bindingColumn = decodeInteger(reader, bindingLine === prevBl ? bindingColumn : 0); + const expression = decodeInteger(reader, 0); + expressionRanges.push([expression, bindingLine, bindingColumn]); + } + } else { + expressionRanges = [[expressionsCount]]; + } + bindings.push(expressionRanges); + } while (hasMoreVlq(reader, semi)); + } + range.bindings = bindings; + ranges.push(range); + stack.push(range); + } + genLine++; + reader.pos = semi + 1; + } while (reader.pos < length); + return ranges; +} +function encodeGeneratedRanges(ranges) { + if (ranges.length === 0) return ""; + const writer = new StringWriter(); + for (let i = 0; i < ranges.length; ) { + i = _encodeGeneratedRanges(ranges, i, writer, [0, 0, 0, 0, 0, 0, 0]); + } + return writer.flush(); +} +function _encodeGeneratedRanges(ranges, index, writer, state) { + const range = ranges[index]; + const { + 0: startLine, + 1: startColumn, + 2: endLine, + 3: endColumn, + isScope, + callsite, + bindings + } = range; + if (state[0] < startLine) { + catchupLine(writer, state[0], startLine); + state[0] = startLine; + state[1] = 0; + } else if (index > 0) { + writer.write(comma); + } + state[1] = encodeInteger(writer, range[1], state[1]); + const fields = (range.length === 6 ? 1 : 0) | (callsite ? 2 : 0) | (isScope ? 4 : 0); + encodeInteger(writer, fields, 0); + if (range.length === 6) { + const { 4: sourcesIndex, 5: scopesIndex } = range; + if (sourcesIndex !== state[2]) { + state[3] = 0; + } + state[2] = encodeInteger(writer, sourcesIndex, state[2]); + state[3] = encodeInteger(writer, scopesIndex, state[3]); + } + if (callsite) { + const { 0: sourcesIndex, 1: callLine, 2: callColumn } = range.callsite; + if (sourcesIndex !== state[4]) { + state[5] = 0; + state[6] = 0; + } else if (callLine !== state[5]) { + state[6] = 0; + } + state[4] = encodeInteger(writer, sourcesIndex, state[4]); + state[5] = encodeInteger(writer, callLine, state[5]); + state[6] = encodeInteger(writer, callColumn, state[6]); + } + if (bindings) { + for (const binding of bindings) { + if (binding.length > 1) encodeInteger(writer, -binding.length, 0); + const expression = binding[0][0]; + encodeInteger(writer, expression, 0); + let bindingStartLine = startLine; + let bindingStartColumn = startColumn; + for (let i = 1; i < binding.length; i++) { + const expRange = binding[i]; + bindingStartLine = encodeInteger(writer, expRange[1], bindingStartLine); + bindingStartColumn = encodeInteger(writer, expRange[2], bindingStartColumn); + encodeInteger(writer, expRange[0], 0); + } + } + } + for (index++; index < ranges.length; ) { + const next = ranges[index]; + const { 0: l, 1: c } = next; + if (l > endLine || l === endLine && c >= endColumn) { + break; + } + index = _encodeGeneratedRanges(ranges, index, writer, state); + } + if (state[0] < endLine) { + catchupLine(writer, state[0], endLine); + state[0] = endLine; + state[1] = 0; + } else { + writer.write(comma); + } + state[1] = encodeInteger(writer, endColumn, state[1]); + return index; +} +function catchupLine(writer, lastLine, line) { + do { + writer.write(semicolon); + } while (++lastLine < line); +} + +// src/sourcemap-codec.ts +function decode(mappings) { + const { length } = mappings; + const reader = new StringReader(mappings); + const decoded = []; + let genColumn = 0; + let sourcesIndex = 0; + let sourceLine = 0; + let sourceColumn = 0; + let namesIndex = 0; + do { + const semi = reader.indexOf(";"); + const line = []; + let sorted = true; + let lastCol = 0; + genColumn = 0; + while (reader.pos < semi) { + let seg; + genColumn = decodeInteger(reader, genColumn); + if (genColumn < lastCol) sorted = false; + lastCol = genColumn; + if (hasMoreVlq(reader, semi)) { + sourcesIndex = decodeInteger(reader, sourcesIndex); + sourceLine = decodeInteger(reader, sourceLine); + sourceColumn = decodeInteger(reader, sourceColumn); + if (hasMoreVlq(reader, semi)) { + namesIndex = decodeInteger(reader, namesIndex); + seg = [genColumn, sourcesIndex, sourceLine, sourceColumn, namesIndex]; + } else { + seg = [genColumn, sourcesIndex, sourceLine, sourceColumn]; + } + } else { + seg = [genColumn]; + } + line.push(seg); + reader.pos++; + } + if (!sorted) sort(line); + decoded.push(line); + reader.pos = semi + 1; + } while (reader.pos <= length); + return decoded; +} +function sort(line) { + line.sort(sortComparator); +} +function sortComparator(a, b) { + return a[0] - b[0]; +} +function encode(decoded) { + const writer = new StringWriter(); + let sourcesIndex = 0; + let sourceLine = 0; + let sourceColumn = 0; + let namesIndex = 0; + for (let i = 0; i < decoded.length; i++) { + const line = decoded[i]; + if (i > 0) writer.write(semicolon); + if (line.length === 0) continue; + let genColumn = 0; + for (let j = 0; j < line.length; j++) { + const segment = line[j]; + if (j > 0) writer.write(comma); + genColumn = encodeInteger(writer, segment[0], genColumn); + if (segment.length === 1) continue; + sourcesIndex = encodeInteger(writer, segment[1], sourcesIndex); + sourceLine = encodeInteger(writer, segment[2], sourceLine); + sourceColumn = encodeInteger(writer, segment[3], sourceColumn); + if (segment.length === 4) continue; + namesIndex = encodeInteger(writer, segment[4], namesIndex); + } + } + return writer.flush(); +} +export { + decode, + decodeGeneratedRanges, + decodeOriginalScopes, + encode, + encodeGeneratedRanges, + encodeOriginalScopes +}; +//# sourceMappingURL=sourcemap-codec.mjs.map diff --git a/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.mjs.map b/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.mjs.map new file mode 100644 index 0000000000000000000000000000000000000000..c276844b25973802e167a1da9521f7b54f058b72 --- /dev/null +++ b/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.mjs.map @@ -0,0 +1,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AAa,cAAc,QAAQ,QAAQ,CAAC,GAAG,UAAU;AACzD,qBAAe,cAAc,QAAQ,QAAQ,CAAC,GAAG,YAAY;AAE7D,UAAI,QAAQ,WAAW,EAAG;AAC1B,mBAAa,cAAc,QAAQ,QAAQ,CAAC,GAAG,UAAU;AAAA,IAC3D;AAAA,EACF;AAEA,SAAO,OAAO,MAAM;AACtB;", + "names": [] +} diff --git a/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.umd.js b/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.umd.js new file mode 100644 index 0000000000000000000000000000000000000000..2d8e459f3e2f952d02a62b795bab39252a81d481 --- /dev/null +++ b/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.umd.js @@ -0,0 +1,464 @@ +(function (global, factory) { + if (typeof exports === 'object' && typeof module !== 'undefined') { + factory(module); + module.exports = def(module); + } else if (typeof define === 'function' && define.amd) { + define(['module'], function(mod) { + factory.apply(this, arguments); + mod.exports = def(mod); + }); + } else { + const mod = { exports: {} }; + factory(mod); + global = typeof globalThis !== 'undefined' ? globalThis : global || self; + global.sourcemapCodec = def(mod); + } + function def(m) { return 'default' in m.exports ? m.exports.default : m.exports; } +})(this, (function (module) { +"use strict"; +var __defProp = Object.defineProperty; +var __getOwnPropDesc = Object.getOwnPropertyDescriptor; +var __getOwnPropNames = Object.getOwnPropertyNames; +var __hasOwnProp = Object.prototype.hasOwnProperty; +var __export = (target, all) => { + for (var name in all) + __defProp(target, name, { get: all[name], enumerable: true }); +}; +var __copyProps = (to, from, except, desc) => { + if (from && typeof from === "object" || typeof from === "function") { + for (let key of __getOwnPropNames(from)) + if (!__hasOwnProp.call(to, key) && key !== except) + __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); + } + return to; +}; +var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); + +// src/sourcemap-codec.ts +var sourcemap_codec_exports = {}; +__export(sourcemap_codec_exports, { + decode: () => decode, + decodeGeneratedRanges: () => decodeGeneratedRanges, + decodeOriginalScopes: () => decodeOriginalScopes, + encode: () => encode, + encodeGeneratedRanges: () => encodeGeneratedRanges, + encodeOriginalScopes: () => encodeOriginalScopes +}); +module.exports = __toCommonJS(sourcemap_codec_exports); + +// src/vlq.ts +var comma = ",".charCodeAt(0); +var semicolon = ";".charCodeAt(0); +var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; +var intToChar = new Uint8Array(64); +var charToInt = new Uint8Array(128); +for (let i = 0; i < chars.length; i++) { + const c = chars.charCodeAt(i); + intToChar[i] = c; + charToInt[c] = i; +} +function decodeInteger(reader, relative) { + let value = 0; + let shift = 0; + let integer = 0; + do { + const c = reader.next(); + integer = charToInt[c]; + value |= (integer & 31) << shift; + shift += 5; + } while (integer & 32); + const shouldNegate = value & 1; + value >>>= 1; + if (shouldNegate) { + value = -2147483648 | -value; + } + return relative + value; +} +function encodeInteger(builder, num, relative) { + let delta = num - relative; + delta = delta < 0 ? -delta << 1 | 1 : delta << 1; + do { + let clamped = delta & 31; + delta >>>= 5; + if (delta > 0) clamped |= 32; + builder.write(intToChar[clamped]); + } while (delta > 0); + return num; +} +function hasMoreVlq(reader, max) { + if (reader.pos >= max) return false; + return reader.peek() !== comma; +} + +// src/strings.ts +var bufLength = 1024 * 16; +var td = typeof TextDecoder !== "undefined" ? /* @__PURE__ */ new TextDecoder() : typeof Buffer !== "undefined" ? { + decode(buf) { + const out = Buffer.from(buf.buffer, buf.byteOffset, buf.byteLength); + return out.toString(); + } +} : { + decode(buf) { + let out = ""; + for (let i = 0; i < buf.length; i++) { + out += String.fromCharCode(buf[i]); + } + return out; + } +}; +var StringWriter = class { + constructor() { + this.pos = 0; + this.out = ""; + this.buffer = new Uint8Array(bufLength); + } + write(v) { + const { buffer } = this; + buffer[this.pos++] = v; + if (this.pos === bufLength) { + this.out += td.decode(buffer); + this.pos = 0; + } + } + flush() { + const { buffer, out, pos } = this; + return pos > 0 ? out + td.decode(buffer.subarray(0, pos)) : out; + } +}; +var StringReader = class { + constructor(buffer) { + this.pos = 0; + this.buffer = buffer; + } + next() { + return this.buffer.charCodeAt(this.pos++); + } + peek() { + return this.buffer.charCodeAt(this.pos); + } + indexOf(char) { + const { buffer, pos } = this; + const idx = buffer.indexOf(char, pos); + return idx === -1 ? buffer.length : idx; + } +}; + +// src/scopes.ts +var EMPTY = []; +function decodeOriginalScopes(input) { + const { length } = input; + const reader = new StringReader(input); + const scopes = []; + const stack = []; + let line = 0; + for (; reader.pos < length; reader.pos++) { + line = decodeInteger(reader, line); + const column = decodeInteger(reader, 0); + if (!hasMoreVlq(reader, length)) { + const last = stack.pop(); + last[2] = line; + last[3] = column; + continue; + } + const kind = decodeInteger(reader, 0); + const fields = decodeInteger(reader, 0); + const hasName = fields & 1; + const scope = hasName ? [line, column, 0, 0, kind, decodeInteger(reader, 0)] : [line, column, 0, 0, kind]; + let vars = EMPTY; + if (hasMoreVlq(reader, length)) { + vars = []; + do { + const varsIndex = decodeInteger(reader, 0); + vars.push(varsIndex); + } while (hasMoreVlq(reader, length)); + } + scope.vars = vars; + scopes.push(scope); + stack.push(scope); + } + return scopes; +} +function encodeOriginalScopes(scopes) { + const writer = new StringWriter(); + for (let i = 0; i < scopes.length; ) { + i = _encodeOriginalScopes(scopes, i, writer, [0]); + } + return writer.flush(); +} +function _encodeOriginalScopes(scopes, index, writer, state) { + const scope = scopes[index]; + const { 0: startLine, 1: startColumn, 2: endLine, 3: endColumn, 4: kind, vars } = scope; + if (index > 0) writer.write(comma); + state[0] = encodeInteger(writer, startLine, state[0]); + encodeInteger(writer, startColumn, 0); + encodeInteger(writer, kind, 0); + const fields = scope.length === 6 ? 1 : 0; + encodeInteger(writer, fields, 0); + if (scope.length === 6) encodeInteger(writer, scope[5], 0); + for (const v of vars) { + encodeInteger(writer, v, 0); + } + for (index++; index < scopes.length; ) { + const next = scopes[index]; + const { 0: l, 1: c } = next; + if (l > endLine || l === endLine && c >= endColumn) { + break; + } + index = _encodeOriginalScopes(scopes, index, writer, state); + } + writer.write(comma); + state[0] = encodeInteger(writer, endLine, state[0]); + encodeInteger(writer, endColumn, 0); + return index; +} +function decodeGeneratedRanges(input) { + const { length } = input; + const reader = new StringReader(input); + const ranges = []; + const stack = []; + let genLine = 0; + let definitionSourcesIndex = 0; + let definitionScopeIndex = 0; + let callsiteSourcesIndex = 0; + let callsiteLine = 0; + let callsiteColumn = 0; + let bindingLine = 0; + let bindingColumn = 0; + do { + const semi = reader.indexOf(";"); + let genColumn = 0; + for (; reader.pos < semi; reader.pos++) { + genColumn = decodeInteger(reader, genColumn); + if (!hasMoreVlq(reader, semi)) { + const last = stack.pop(); + last[2] = genLine; + last[3] = genColumn; + continue; + } + const fields = decodeInteger(reader, 0); + const hasDefinition = fields & 1; + const hasCallsite = fields & 2; + const hasScope = fields & 4; + let callsite = null; + let bindings = EMPTY; + let range; + if (hasDefinition) { + const defSourcesIndex = decodeInteger(reader, definitionSourcesIndex); + definitionScopeIndex = decodeInteger( + reader, + definitionSourcesIndex === defSourcesIndex ? definitionScopeIndex : 0 + ); + definitionSourcesIndex = defSourcesIndex; + range = [genLine, genColumn, 0, 0, defSourcesIndex, definitionScopeIndex]; + } else { + range = [genLine, genColumn, 0, 0]; + } + range.isScope = !!hasScope; + if (hasCallsite) { + const prevCsi = callsiteSourcesIndex; + const prevLine = callsiteLine; + callsiteSourcesIndex = decodeInteger(reader, callsiteSourcesIndex); + const sameSource = prevCsi === callsiteSourcesIndex; + callsiteLine = decodeInteger(reader, sameSource ? callsiteLine : 0); + callsiteColumn = decodeInteger( + reader, + sameSource && prevLine === callsiteLine ? callsiteColumn : 0 + ); + callsite = [callsiteSourcesIndex, callsiteLine, callsiteColumn]; + } + range.callsite = callsite; + if (hasMoreVlq(reader, semi)) { + bindings = []; + do { + bindingLine = genLine; + bindingColumn = genColumn; + const expressionsCount = decodeInteger(reader, 0); + let expressionRanges; + if (expressionsCount < -1) { + expressionRanges = [[decodeInteger(reader, 0)]]; + for (let i = -1; i > expressionsCount; i--) { + const prevBl = bindingLine; + bindingLine = decodeInteger(reader, bindingLine); + bindingColumn = decodeInteger(reader, bindingLine === prevBl ? bindingColumn : 0); + const expression = decodeInteger(reader, 0); + expressionRanges.push([expression, bindingLine, bindingColumn]); + } + } else { + expressionRanges = [[expressionsCount]]; + } + bindings.push(expressionRanges); + } while (hasMoreVlq(reader, semi)); + } + range.bindings = bindings; + ranges.push(range); + stack.push(range); + } + genLine++; + reader.pos = semi + 1; + } while (reader.pos < length); + return ranges; +} +function encodeGeneratedRanges(ranges) { + if (ranges.length === 0) return ""; + const writer = new StringWriter(); + for (let i = 0; i < ranges.length; ) { + i = _encodeGeneratedRanges(ranges, i, writer, [0, 0, 0, 0, 0, 0, 0]); + } + return writer.flush(); +} +function _encodeGeneratedRanges(ranges, index, writer, state) { + const range = ranges[index]; + const { + 0: startLine, + 1: startColumn, + 2: endLine, + 3: endColumn, + isScope, + callsite, + bindings + } = range; + if (state[0] < startLine) { + catchupLine(writer, state[0], startLine); + state[0] = startLine; + state[1] = 0; + } else if (index > 0) { + writer.write(comma); + } + state[1] = encodeInteger(writer, range[1], state[1]); + const fields = (range.length === 6 ? 1 : 0) | (callsite ? 2 : 0) | (isScope ? 4 : 0); + encodeInteger(writer, fields, 0); + if (range.length === 6) { + const { 4: sourcesIndex, 5: scopesIndex } = range; + if (sourcesIndex !== state[2]) { + state[3] = 0; + } + state[2] = encodeInteger(writer, sourcesIndex, state[2]); + state[3] = encodeInteger(writer, scopesIndex, state[3]); + } + if (callsite) { + const { 0: sourcesIndex, 1: callLine, 2: callColumn } = range.callsite; + if (sourcesIndex !== state[4]) { + state[5] = 0; + state[6] = 0; + } else if (callLine !== state[5]) { + state[6] = 0; + } + state[4] = encodeInteger(writer, sourcesIndex, state[4]); + state[5] = encodeInteger(writer, callLine, state[5]); + state[6] = encodeInteger(writer, callColumn, state[6]); + } + if (bindings) { + for (const binding of bindings) { + if (binding.length > 1) encodeInteger(writer, -binding.length, 0); + const expression = binding[0][0]; + encodeInteger(writer, expression, 0); + let bindingStartLine = startLine; + let bindingStartColumn = startColumn; + for (let i = 1; i < binding.length; i++) { + const expRange = binding[i]; + bindingStartLine = encodeInteger(writer, expRange[1], bindingStartLine); + bindingStartColumn = encodeInteger(writer, expRange[2], bindingStartColumn); + encodeInteger(writer, expRange[0], 0); + } + } + } + for (index++; index < ranges.length; ) { + const next = ranges[index]; + const { 0: l, 1: c } = next; + if (l > endLine || l === endLine && c >= endColumn) { + break; + } + index = _encodeGeneratedRanges(ranges, index, writer, state); + } + if (state[0] < endLine) { + catchupLine(writer, state[0], endLine); + state[0] = endLine; + state[1] = 0; + } else { + writer.write(comma); + } + state[1] = encodeInteger(writer, endColumn, state[1]); + return index; +} +function catchupLine(writer, lastLine, line) { + do { + writer.write(semicolon); + } while (++lastLine < line); +} + +// src/sourcemap-codec.ts +function decode(mappings) { + const { length } = mappings; + const reader = new StringReader(mappings); + const decoded = []; + let genColumn = 0; + let sourcesIndex = 0; + let sourceLine = 0; + let sourceColumn = 0; + let namesIndex = 0; + do { + const semi = reader.indexOf(";"); + const line = []; + let sorted = true; + let lastCol = 0; + genColumn = 0; + while (reader.pos < semi) { + let seg; + genColumn = decodeInteger(reader, genColumn); + if (genColumn < lastCol) sorted = false; + lastCol = genColumn; + if (hasMoreVlq(reader, semi)) { + sourcesIndex = decodeInteger(reader, sourcesIndex); + sourceLine = decodeInteger(reader, sourceLine); + sourceColumn = decodeInteger(reader, sourceColumn); + if (hasMoreVlq(reader, semi)) { + namesIndex = decodeInteger(reader, namesIndex); + seg = [genColumn, sourcesIndex, sourceLine, sourceColumn, namesIndex]; + } else { + seg = [genColumn, sourcesIndex, sourceLine, sourceColumn]; + } + } else { + seg = [genColumn]; + } + line.push(seg); + reader.pos++; + } + if (!sorted) sort(line); + decoded.push(line); + reader.pos = semi + 1; + } while (reader.pos <= length); + return decoded; +} +function sort(line) { + line.sort(sortComparator); +} +function sortComparator(a, b) { + return a[0] - b[0]; +} +function encode(decoded) { + const writer = new StringWriter(); + let sourcesIndex = 0; + let sourceLine = 0; + let sourceColumn = 0; + let namesIndex = 0; + for (let i = 0; i < decoded.length; i++) { + const line = decoded[i]; + if (i > 0) writer.write(semicolon); + if (line.length === 0) continue; + let genColumn = 0; + for (let j = 0; j < line.length; j++) { + const segment = line[j]; + if (j > 0) writer.write(comma); + genColumn = encodeInteger(writer, segment[0], genColumn); + if (segment.length === 1) continue; + sourcesIndex = encodeInteger(writer, segment[1], sourcesIndex); + sourceLine = encodeInteger(writer, segment[2], sourceLine); + sourceColumn = encodeInteger(writer, segment[3], sourceColumn); + if (segment.length === 4) continue; + namesIndex = encodeInteger(writer, segment[4], namesIndex); + } + } + return writer.flush(); +} +})); +//# sourceMappingURL=sourcemap-codec.umd.js.map diff --git a/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.umd.js.map b/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.umd.js.map new file mode 100644 index 0000000000000000000000000000000000000000..abc18d286e183092e99784dedb2651c3a551c20d --- /dev/null +++ b/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.umd.js.map @@ -0,0 +1,6 @@ +{ + "version": 3, + "sources": ["../src/sourcemap-codec.ts", "../src/vlq.ts", "../src/strings.ts", "../src/scopes.ts"], + "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACEO,IAAM,QAAQ,IAAI,WAAW,CAAC;AAC9B,IAAM,YAAY,IAAI,WAAW,CAAC;AAEzC,IAAM,QAAQ;AACd,IAAM,YAAY,IAAI,WAAW,EAAE;AACnC,IAAM,YAAY,IAAI,WAAW,GAAG;AAEpC,SAAS,IAAI,GAAG,IAAI,MAAM,QAAQ,KAAK;AACrC,QAAM,IAAI,MAAM,WAAW,CAAC;AAC5B,YAAU,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GAAG;AACb,aAAO;AAAA,IACT;AAEA,QAAI,CAAC,OAAQ,MAAK,IAAI;AACtB,YAAQ,KAAK,IAAI;AACjB,WAAO,MAAM,OAAO;AAAA,EACtB,SAAS,OAAO,OAAO;AAEvB,SAAO;AACT;AAEA,SAAS,KAAK,MAA0B;AACtC,OAAK,KAAK,cAAc;AAC1B;AAEA,SAAS,eAAe,GAAqB,GAA6B;AACxE,SAAO,EAAE,CAAC,IAAI,EAAE,CAAC;AACnB;AAIO,SAAS,OAAO,SAA8C;AACnE,QAAM,SAAS,IAAI,aAAa;AAChC,MAAI,eAAe;AACnB,MAAI,aAAa;AACjB,MAAI,eAAe;AACnB,MAAI,aAAa;AAEjB,WAAS,IAAI,GAAG,IAAI,QAAQ,QAAQ,KAAK;AACvC,UAAM,OAAO,QAAQ,CAAC;AACtB,QAAI,IAAI,EAAG,QAAO,MAAM,SAAS;AACjC,QAAI,KAAK,WAAW,EAAG;AAEvB,QAAI,YAAY;AAEhB,aAAS,IAAI,GAAG,IAAI,KAAK,QAAQ,KAAK;AACpC,YAAM,UAAU,KAAK,CAAC;AACtB,UAAI,IAAI,EAAG,QAAO,MAAM,KAAK;AAE7B,kBAAY,cAAc,QAAQ,QAAQ,CAAC,GAAG,SAAS;AAEvD,UAAI,QAAQ,WAAW,EAAG;AAC1B,qBAAe,cAAc,QAAQ,QAAQ,CAAC,GAAG,YAAY;AAC7D,mBAAa,cAAc,QAAQ,QAAQ,CAAC,GAAG,UAAU;AACzD,qBAAe,cAAc,QAAQ,QAAQ,CAAC,GAAG,YAAY;AAE7D,UAAI,QAAQ,WAAW,EAAG;AAC1B,mBAAa,cAAc,QAAQ,QAAQ,CAAC,GAAG,UAAU;AAAA,IAC3D;AAAA,EACF;AAEA,SAAO,OAAO,MAAM;AACtB;", + "names": [] +} diff --git a/node_modules/@jridgewell/sourcemap-codec/package.json b/node_modules/@jridgewell/sourcemap-codec/package.json new file mode 100644 index 0000000000000000000000000000000000000000..da551376440ae3d77c4159d2385403459a4f447f --- /dev/null +++ b/node_modules/@jridgewell/sourcemap-codec/package.json @@ -0,0 +1,63 @@ +{ + "name": "@jridgewell/sourcemap-codec", + "version": "1.5.5", + "description": "Encode/decode sourcemap mappings", + "keywords": [ + "sourcemap", + "vlq" + ], + "main": "dist/sourcemap-codec.umd.js", + "module": "dist/sourcemap-codec.mjs", + "types": "types/sourcemap-codec.d.cts", + "files": [ + "dist", + "src", + "types" + ], + "exports": { + ".": [ + { + "import": { + "types": "./types/sourcemap-codec.d.mts", + "default": "./dist/sourcemap-codec.mjs" + }, + "default": { + "types": "./types/sourcemap-codec.d.cts", + "default": "./dist/sourcemap-codec.umd.js" + } + }, + "./dist/sourcemap-codec.umd.js" + ], + "./package.json": "./package.json" + }, + "scripts": { + "benchmark": "run-s build:code benchmark:*", + "benchmark:install": "cd benchmark && npm install", + "benchmark:only": "node --expose-gc benchmark/index.js", + "build": "run-s -n build:code build:types", + "build:code": "node ../../esbuild.mjs sourcemap-codec.ts", + "build:types": "run-s build:types:force build:types:emit build:types:mts", + "build:types:force": "rimraf tsconfig.build.tsbuildinfo", + "build:types:emit": "tsc --project tsconfig.build.json", + "build:types:mts": "node ../../mts-types.mjs", + "clean": "run-s -n clean:code clean:types", + "clean:code": "tsc --build --clean tsconfig.build.json", + "clean:types": "rimraf dist types", + "test": "run-s -n test:types test:only test:format", + "test:format": "prettier --check '{src,test}/**/*.ts'", + "test:only": "mocha", + "test:types": "eslint '{src,test}/**/*.ts'", + "lint": "run-s -n lint:types lint:format", + "lint:format": "npm run test:format -- --write", + "lint:types": "npm run test:types -- --fix", + "prepublishOnly": "npm run-s -n build test" + }, + "homepage": "https://github.com/jridgewell/sourcemaps/tree/main/packages/sourcemap-codec", + "repository": { + "type": "git", + "url": "git+https://github.com/jridgewell/sourcemaps.git", + "directory": "packages/sourcemap-codec" + }, + "author": "Justin Ridgewell ", + "license": "MIT" +} diff --git a/node_modules/@jridgewell/sourcemap-codec/src/scopes.ts b/node_modules/@jridgewell/sourcemap-codec/src/scopes.ts new file mode 100644 index 0000000000000000000000000000000000000000..d194c2f0a66567fdc42e7d4bddc79a5e5d1ad005 --- /dev/null +++ b/node_modules/@jridgewell/sourcemap-codec/src/scopes.ts @@ -0,0 +1,345 @@ +import { StringReader, StringWriter } from './strings'; +import { comma, decodeInteger, encodeInteger, hasMoreVlq, semicolon } from './vlq'; + +const EMPTY: any[] = []; + +type Line = number; +type Column = number; +type Kind = number; +type Name = number; +type Var = number; +type SourcesIndex = number; +type ScopesIndex = number; + +type Mix = (A & O) | (B & O); + +export type OriginalScope = Mix< + [Line, Column, Line, Column, Kind], + [Line, Column, Line, Column, Kind, Name], + { vars: Var[] } +>; + +export type GeneratedRange = Mix< + [Line, Column, Line, Column], + [Line, Column, Line, Column, SourcesIndex, ScopesIndex], + { + callsite: CallSite | null; + bindings: Binding[]; + isScope: boolean; + } +>; +export type CallSite = [SourcesIndex, Line, Column]; +type Binding = BindingExpressionRange[]; +export type BindingExpressionRange = [Name] | [Name, Line, Column]; + +export function decodeOriginalScopes(input: string): OriginalScope[] { + const { length } = input; + const reader = new StringReader(input); + const scopes: OriginalScope[] = []; + const stack: OriginalScope[] = []; + let line = 0; + + for (; reader.pos < length; reader.pos++) { + line = decodeInteger(reader, line); + const column = decodeInteger(reader, 0); + + if (!hasMoreVlq(reader, length)) { + const last = stack.pop()!; + last[2] = line; + last[3] = column; + continue; + } + + const kind = decodeInteger(reader, 0); + const fields = decodeInteger(reader, 0); + const hasName = fields & 0b0001; + + const scope: OriginalScope = ( + hasName ? [line, column, 0, 0, kind, decodeInteger(reader, 0)] : [line, column, 0, 0, kind] + ) as OriginalScope; + + let vars: Var[] = EMPTY; + if (hasMoreVlq(reader, length)) { + vars = []; + do { + const varsIndex = decodeInteger(reader, 0); + vars.push(varsIndex); + } while (hasMoreVlq(reader, length)); + } + scope.vars = vars; + + scopes.push(scope); + stack.push(scope); + } + + return scopes; +} + +export function encodeOriginalScopes(scopes: OriginalScope[]): string { + const writer = new StringWriter(); + + for (let i = 0; i < scopes.length; ) { + i = _encodeOriginalScopes(scopes, i, writer, [0]); + } + + return writer.flush(); +} + +function _encodeOriginalScopes( + scopes: OriginalScope[], + index: number, + writer: StringWriter, + state: [ + number, // GenColumn + ], +): number { + const scope = scopes[index]; + const { 0: startLine, 1: startColumn, 2: endLine, 3: endColumn, 4: kind, vars } = scope; + + if (index > 0) writer.write(comma); + + state[0] = encodeInteger(writer, startLine, state[0]); + encodeInteger(writer, startColumn, 0); + encodeInteger(writer, kind, 0); + + const fields = scope.length === 6 ? 0b0001 : 0; + encodeInteger(writer, fields, 0); + if (scope.length === 6) encodeInteger(writer, scope[5], 0); + + for (const v of vars) { + encodeInteger(writer, v, 0); + } + + for (index++; index < scopes.length; ) { + const next = scopes[index]; + const { 0: l, 1: c } = next; + if (l > endLine || (l === endLine && c >= endColumn)) { + break; + } + index = _encodeOriginalScopes(scopes, index, writer, state); + } + + writer.write(comma); + state[0] = encodeInteger(writer, endLine, state[0]); + encodeInteger(writer, endColumn, 0); + + return index; +} + +export function decodeGeneratedRanges(input: string): GeneratedRange[] { + const { length } = input; + const reader = new StringReader(input); + const ranges: GeneratedRange[] = []; + const stack: GeneratedRange[] = []; + + let genLine = 0; + let definitionSourcesIndex = 0; + let definitionScopeIndex = 0; + let callsiteSourcesIndex = 0; + let callsiteLine = 0; + let callsiteColumn = 0; + let bindingLine = 0; + let bindingColumn = 0; + + do { + const semi = reader.indexOf(';'); + let genColumn = 0; + + for (; reader.pos < semi; reader.pos++) { + genColumn = decodeInteger(reader, genColumn); + + if (!hasMoreVlq(reader, semi)) { + const last = stack.pop()!; + last[2] = genLine; + last[3] = genColumn; + continue; + } + + const fields = decodeInteger(reader, 0); + const hasDefinition = fields & 0b0001; + const hasCallsite = fields & 0b0010; + const hasScope = fields & 0b0100; + + let callsite: CallSite | null = null; + let bindings: Binding[] = EMPTY; + let range: GeneratedRange; + if (hasDefinition) { + const defSourcesIndex = decodeInteger(reader, definitionSourcesIndex); + definitionScopeIndex = decodeInteger( + reader, + definitionSourcesIndex === defSourcesIndex ? definitionScopeIndex : 0, + ); + + definitionSourcesIndex = defSourcesIndex; + range = [genLine, genColumn, 0, 0, defSourcesIndex, definitionScopeIndex] as GeneratedRange; + } else { + range = [genLine, genColumn, 0, 0] as GeneratedRange; + } + + range.isScope = !!hasScope; + + if (hasCallsite) { + const prevCsi = callsiteSourcesIndex; + const prevLine = callsiteLine; + callsiteSourcesIndex = decodeInteger(reader, callsiteSourcesIndex); + const sameSource = prevCsi === callsiteSourcesIndex; + callsiteLine = decodeInteger(reader, sameSource ? callsiteLine : 0); + callsiteColumn = decodeInteger( + reader, + sameSource && prevLine === callsiteLine ? callsiteColumn : 0, + ); + + callsite = [callsiteSourcesIndex, callsiteLine, callsiteColumn]; + } + range.callsite = callsite; + + if (hasMoreVlq(reader, semi)) { + bindings = []; + do { + bindingLine = genLine; + bindingColumn = genColumn; + const expressionsCount = decodeInteger(reader, 0); + let expressionRanges: BindingExpressionRange[]; + if (expressionsCount < -1) { + expressionRanges = [[decodeInteger(reader, 0)]]; + for (let i = -1; i > expressionsCount; i--) { + const prevBl = bindingLine; + bindingLine = decodeInteger(reader, bindingLine); + bindingColumn = decodeInteger(reader, bindingLine === prevBl ? bindingColumn : 0); + const expression = decodeInteger(reader, 0); + expressionRanges.push([expression, bindingLine, bindingColumn]); + } + } else { + expressionRanges = [[expressionsCount]]; + } + bindings.push(expressionRanges); + } while (hasMoreVlq(reader, semi)); + } + range.bindings = bindings; + + ranges.push(range); + stack.push(range); + } + + genLine++; + reader.pos = semi + 1; + } while (reader.pos < length); + + return ranges; +} + +export function encodeGeneratedRanges(ranges: GeneratedRange[]): string { + if (ranges.length === 0) return ''; + + const writer = new StringWriter(); + + for (let i = 0; i < ranges.length; ) { + i = _encodeGeneratedRanges(ranges, i, writer, [0, 0, 0, 0, 0, 0, 0]); + } + + return writer.flush(); +} + +function _encodeGeneratedRanges( + ranges: GeneratedRange[], + index: number, + writer: StringWriter, + state: [ + number, // GenLine + number, // GenColumn + number, // DefSourcesIndex + number, // DefScopesIndex + number, // CallSourcesIndex + number, // CallLine + number, // CallColumn + ], +): number { + const range = ranges[index]; + const { + 0: startLine, + 1: startColumn, + 2: endLine, + 3: endColumn, + isScope, + callsite, + bindings, + } = range; + + if (state[0] < startLine) { + catchupLine(writer, state[0], startLine); + state[0] = startLine; + state[1] = 0; + } else if (index > 0) { + writer.write(comma); + } + + state[1] = encodeInteger(writer, range[1], state[1]); + + const fields = + (range.length === 6 ? 0b0001 : 0) | (callsite ? 0b0010 : 0) | (isScope ? 0b0100 : 0); + encodeInteger(writer, fields, 0); + + if (range.length === 6) { + const { 4: sourcesIndex, 5: scopesIndex } = range; + if (sourcesIndex !== state[2]) { + state[3] = 0; + } + state[2] = encodeInteger(writer, sourcesIndex, state[2]); + state[3] = encodeInteger(writer, scopesIndex, state[3]); + } + + if (callsite) { + const { 0: sourcesIndex, 1: callLine, 2: callColumn } = range.callsite!; + if (sourcesIndex !== state[4]) { + state[5] = 0; + state[6] = 0; + } else if (callLine !== state[5]) { + state[6] = 0; + } + state[4] = encodeInteger(writer, sourcesIndex, state[4]); + state[5] = encodeInteger(writer, callLine, state[5]); + state[6] = encodeInteger(writer, callColumn, state[6]); + } + + if (bindings) { + for (const binding of bindings) { + if (binding.length > 1) encodeInteger(writer, -binding.length, 0); + const expression = binding[0][0]; + encodeInteger(writer, expression, 0); + let bindingStartLine = startLine; + let bindingStartColumn = startColumn; + for (let i = 1; i < binding.length; i++) { + const expRange = binding[i]; + bindingStartLine = encodeInteger(writer, expRange[1]!, bindingStartLine); + bindingStartColumn = encodeInteger(writer, expRange[2]!, bindingStartColumn); + encodeInteger(writer, expRange[0]!, 0); + } + } + } + + for (index++; index < ranges.length; ) { + const next = ranges[index]; + const { 0: l, 1: c } = next; + if (l > endLine || (l === endLine && c >= endColumn)) { + break; + } + index = _encodeGeneratedRanges(ranges, index, writer, state); + } + + if (state[0] < endLine) { + catchupLine(writer, state[0], endLine); + state[0] = endLine; + state[1] = 0; + } else { + writer.write(comma); + } + state[1] = encodeInteger(writer, endColumn, state[1]); + + return index; +} + +function catchupLine(writer: StringWriter, lastLine: number, line: number) { + do { + writer.write(semicolon); + } while (++lastLine < line); +} diff --git a/node_modules/@jridgewell/sourcemap-codec/src/sourcemap-codec.ts b/node_modules/@jridgewell/sourcemap-codec/src/sourcemap-codec.ts new file mode 100644 index 0000000000000000000000000000000000000000..a81f894dc1f18937c58978ee1351b6e70bbc8c86 --- /dev/null +++ b/node_modules/@jridgewell/sourcemap-codec/src/sourcemap-codec.ts @@ -0,0 +1,111 @@ +import { comma, decodeInteger, encodeInteger, hasMoreVlq, semicolon } from './vlq'; +import { StringWriter, StringReader } from './strings'; + +export { + decodeOriginalScopes, + encodeOriginalScopes, + decodeGeneratedRanges, + encodeGeneratedRanges, +} from './scopes'; +export type { OriginalScope, GeneratedRange, CallSite, BindingExpressionRange } from './scopes'; + +export type SourceMapSegment = + | [number] + | [number, number, number, number] + | [number, number, number, number, number]; +export type SourceMapLine = SourceMapSegment[]; +export type SourceMapMappings = SourceMapLine[]; + +export function decode(mappings: string): SourceMapMappings { + const { length } = mappings; + const reader = new StringReader(mappings); + const decoded: SourceMapMappings = []; + let genColumn = 0; + let sourcesIndex = 0; + let sourceLine = 0; + let sourceColumn = 0; + let namesIndex = 0; + + do { + const semi = reader.indexOf(';'); + const line: SourceMapLine = []; + let sorted = true; + let lastCol = 0; + genColumn = 0; + + while (reader.pos < semi) { + let seg: SourceMapSegment; + + genColumn = decodeInteger(reader, genColumn); + if (genColumn < lastCol) sorted = false; + lastCol = genColumn; + + if (hasMoreVlq(reader, semi)) { + sourcesIndex = decodeInteger(reader, sourcesIndex); + sourceLine = decodeInteger(reader, sourceLine); + sourceColumn = decodeInteger(reader, sourceColumn); + + if (hasMoreVlq(reader, semi)) { + namesIndex = decodeInteger(reader, namesIndex); + seg = [genColumn, sourcesIndex, sourceLine, sourceColumn, namesIndex]; + } else { + seg = [genColumn, sourcesIndex, sourceLine, sourceColumn]; + } + } else { + seg = [genColumn]; + } + + line.push(seg); + reader.pos++; + } + + if (!sorted) sort(line); + decoded.push(line); + reader.pos = semi + 1; + } while (reader.pos <= length); + + return decoded; +} + +function sort(line: SourceMapSegment[]) { + line.sort(sortComparator); +} + +function sortComparator(a: SourceMapSegment, b: SourceMapSegment): number { + return a[0] - b[0]; +} + +export function encode(decoded: SourceMapMappings): string; +export function encode(decoded: Readonly): string; +export function encode(decoded: Readonly): string { + const writer = new StringWriter(); + let sourcesIndex = 0; + let sourceLine = 0; + let sourceColumn = 0; + let namesIndex = 0; + + for (let i = 0; i < decoded.length; i++) { + const line = decoded[i]; + if (i > 0) writer.write(semicolon); + if (line.length === 0) continue; + + let genColumn = 0; + + for (let j = 0; j < line.length; j++) { + const segment = line[j]; + if (j > 0) writer.write(comma); + + genColumn = encodeInteger(writer, segment[0], genColumn); + + if (segment.length === 1) continue; + sourcesIndex = encodeInteger(writer, segment[1], sourcesIndex); + sourceLine = encodeInteger(writer, segment[2], sourceLine); + sourceColumn = encodeInteger(writer, segment[3], sourceColumn); + + if (segment.length === 4) continue; + namesIndex = encodeInteger(writer, segment[4], namesIndex); + } + } + + return writer.flush(); +} diff --git a/node_modules/@jridgewell/sourcemap-codec/src/strings.ts b/node_modules/@jridgewell/sourcemap-codec/src/strings.ts new file mode 100644 index 0000000000000000000000000000000000000000..d1619650ea773450fe1febaf6a1354c4022f04b6 --- /dev/null +++ b/node_modules/@jridgewell/sourcemap-codec/src/strings.ts @@ -0,0 +1,65 @@ +const bufLength = 1024 * 16; + +// Provide a fallback for older environments. +const td = + typeof TextDecoder !== 'undefined' + ? /* #__PURE__ */ new TextDecoder() + : typeof Buffer !== 'undefined' + ? { + decode(buf: Uint8Array): string { + const out = Buffer.from(buf.buffer, buf.byteOffset, buf.byteLength); + return out.toString(); + }, + } + : { + decode(buf: Uint8Array): string { + let out = ''; + for (let i = 0; i < buf.length; i++) { + out += String.fromCharCode(buf[i]); + } + return out; + }, + }; + +export class StringWriter { + pos = 0; + private out = ''; + private buffer = new Uint8Array(bufLength); + + write(v: number): void { + const { buffer } = this; + buffer[this.pos++] = v; + if (this.pos === bufLength) { + this.out += td.decode(buffer); + this.pos = 0; + } + } + + flush(): string { + const { buffer, out, pos } = this; + return pos > 0 ? out + td.decode(buffer.subarray(0, pos)) : out; + } +} + +export class StringReader { + pos = 0; + declare private buffer: string; + + constructor(buffer: string) { + this.buffer = buffer; + } + + next(): number { + return this.buffer.charCodeAt(this.pos++); + } + + peek(): number { + return this.buffer.charCodeAt(this.pos); + } + + indexOf(char: string): number { + const { buffer, pos } = this; + const idx = buffer.indexOf(char, pos); + return idx === -1 ? buffer.length : idx; + } +} diff --git a/node_modules/@jridgewell/sourcemap-codec/src/vlq.ts b/node_modules/@jridgewell/sourcemap-codec/src/vlq.ts new file mode 100644 index 0000000000000000000000000000000000000000..a42c681511bbec0faecd9aeb9e6e7d5dbea0e391 --- /dev/null +++ b/node_modules/@jridgewell/sourcemap-codec/src/vlq.ts @@ -0,0 +1,55 @@ +import type { StringReader, StringWriter } from './strings'; + +export const comma = ','.charCodeAt(0); +export const semicolon = ';'.charCodeAt(0); + +const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'; +const intToChar = new Uint8Array(64); // 64 possible chars. +const charToInt = new Uint8Array(128); // z is 122 in ASCII + +for (let i = 0; i < chars.length; i++) { + const c = chars.charCodeAt(i); + intToChar[i] = c; + charToInt[c] = i; +} + +export function decodeInteger(reader: StringReader, relative: number): number { + let value = 0; + let shift = 0; + let integer = 0; + + do { + const c = reader.next(); + integer = charToInt[c]; + value |= (integer & 31) << shift; + shift += 5; + } while (integer & 32); + + const shouldNegate = value & 1; + value >>>= 1; + + if (shouldNegate) { + value = -0x80000000 | -value; + } + + return relative + value; +} + +export function encodeInteger(builder: StringWriter, num: number, relative: number): number { + let delta = num - relative; + + delta = delta < 0 ? (-delta << 1) | 1 : delta << 1; + do { + let clamped = delta & 0b011111; + delta >>>= 5; + if (delta > 0) clamped |= 0b100000; + builder.write(intToChar[clamped]); + } while (delta > 0); + + return num; +} + +export function hasMoreVlq(reader: StringReader, max: number) { + if (reader.pos >= max) return false; + return reader.peek() !== comma; +} diff --git a/node_modules/@jridgewell/sourcemap-codec/types/scopes.d.cts b/node_modules/@jridgewell/sourcemap-codec/types/scopes.d.cts new file mode 100644 index 0000000000000000000000000000000000000000..c583c7560dece416257b832315f89fa58f32c782 --- /dev/null +++ b/node_modules/@jridgewell/sourcemap-codec/types/scopes.d.cts @@ -0,0 +1,50 @@ +type Line = number; +type Column = number; +type Kind = number; +type Name = number; +type Var = number; +type SourcesIndex = number; +type ScopesIndex = number; +type Mix = (A & O) | (B & O); +export type OriginalScope = Mix<[ + Line, + Column, + Line, + Column, + Kind +], [ + Line, + Column, + Line, + Column, + Kind, + Name +], { + vars: Var[]; +}>; +export type GeneratedRange = Mix<[ + Line, + Column, + Line, + Column +], [ + Line, + Column, + Line, + Column, + SourcesIndex, + ScopesIndex +], { + callsite: CallSite | null; + bindings: Binding[]; + isScope: boolean; +}>; +export type CallSite = [SourcesIndex, Line, Column]; +type Binding = BindingExpressionRange[]; +export type BindingExpressionRange = [Name] | [Name, Line, Column]; +export declare function decodeOriginalScopes(input: string): OriginalScope[]; +export declare function encodeOriginalScopes(scopes: OriginalScope[]): string; +export declare function decodeGeneratedRanges(input: string): GeneratedRange[]; +export declare function encodeGeneratedRanges(ranges: GeneratedRange[]): string; +export {}; +//# sourceMappingURL=scopes.d.ts.map \ No newline at end of file diff --git a/node_modules/@jridgewell/sourcemap-codec/types/scopes.d.cts.map b/node_modules/@jridgewell/sourcemap-codec/types/scopes.d.cts.map new file mode 100644 index 0000000000000000000000000000000000000000..630e6477b73f115c0f660fe2b50b8acb36b54a61 --- /dev/null +++ b/node_modules/@jridgewell/sourcemap-codec/types/scopes.d.cts.map @@ -0,0 +1 @@ +{"version":3,"file":"scopes.d.ts","sourceRoot":"","sources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oBAAoB,CAAC,KAAK,EAAE,MAAM,GAAG,aAAa,EAAE,CAyCnE;AAED,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,aAAa,EAAE,GAAG,MAAM,CAQpE;AA2CD,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,MAAM,GAAG,cAAc,EAAE,CAoGrE;AAED,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,cAAc,EAAE,GAAG,MAAM,CAUtE"} \ No newline at end of file diff --git a/node_modules/@jridgewell/sourcemap-codec/types/scopes.d.mts b/node_modules/@jridgewell/sourcemap-codec/types/scopes.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..c583c7560dece416257b832315f89fa58f32c782 --- /dev/null +++ b/node_modules/@jridgewell/sourcemap-codec/types/scopes.d.mts @@ -0,0 +1,50 @@ +type Line = number; +type Column = number; +type Kind = number; +type Name = number; +type Var = number; +type SourcesIndex = number; +type ScopesIndex = number; +type Mix = (A & O) | (B & O); +export type OriginalScope = Mix<[ + Line, + Column, + Line, + Column, + Kind +], [ + Line, + Column, + Line, + Column, + Kind, + Name +], { + vars: Var[]; +}>; +export type GeneratedRange = Mix<[ + Line, + Column, + Line, + Column +], [ + Line, + Column, + Line, + Column, + SourcesIndex, + ScopesIndex +], { + callsite: CallSite | null; + bindings: Binding[]; + isScope: boolean; +}>; +export type CallSite = [SourcesIndex, Line, Column]; +type Binding = BindingExpressionRange[]; +export type BindingExpressionRange = [Name] | [Name, Line, Column]; +export declare function decodeOriginalScopes(input: string): OriginalScope[]; +export declare function encodeOriginalScopes(scopes: OriginalScope[]): string; +export declare function decodeGeneratedRanges(input: string): GeneratedRange[]; +export declare function encodeGeneratedRanges(ranges: GeneratedRange[]): string; +export {}; +//# sourceMappingURL=scopes.d.ts.map \ No newline at end of file diff --git a/node_modules/@jridgewell/sourcemap-codec/types/scopes.d.mts.map b/node_modules/@jridgewell/sourcemap-codec/types/scopes.d.mts.map new file mode 100644 index 0000000000000000000000000000000000000000..630e6477b73f115c0f660fe2b50b8acb36b54a61 --- /dev/null +++ b/node_modules/@jridgewell/sourcemap-codec/types/scopes.d.mts.map @@ -0,0 +1 @@ +{"version":3,"file":"scopes.d.ts","sourceRoot":"","sources":["../src/scopes.ts"],"names":[],"mappings":"AAKA,KAAK,IAAI,GAAG,MAAM,CAAC;AACnB,KAAK,MAAM,GAAG,MAAM,CAAC;AACrB,KAAK,IAAI,GAAG,MAAM,CAAC;AACnB,KAAK,IAAI,GAAG,MAAM,CAAC;AACnB,KAAK,GAAG,GAAG,MAAM,CAAC;AAClB,KAAK,YAAY,GAAG,MAAM,CAAC;AAC3B,KAAK,WAAW,GAAG,MAAM,CAAC;AAE1B,KAAK,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;AAEtC,MAAM,MAAM,aAAa,GAAG,GAAG,CAC7B;IAAC,IAAI;IAAE,MAAM;IAAE,IAAI;IAAE,MAAM;IAAE,IAAI;CAAC,EAClC;IAAC,IAAI;IAAE,MAAM;IAAE,IAAI;IAAE,MAAM;IAAE,IAAI;IAAE,IAAI;CAAC,EACxC;IAAE,IAAI,EAAE,GAAG,EAAE,CAAA;CAAE,CAChB,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG,GAAG,CAC9B;IAAC,IAAI;IAAE,MAAM;IAAE,IAAI;IAAE,MAAM;CAAC,EAC5B;IAAC,IAAI;IAAE,MAAM;IAAE,IAAI;IAAE,MAAM;IAAE,YAAY;IAAE,WAAW;CAAC,EACvD;IACE,QAAQ,EAAE,QAAQ,GAAG,IAAI,CAAC;IAC1B,QAAQ,EAAE,OAAO,EAAE,CAAC;IACpB,OAAO,EAAE,OAAO,CAAC;CAClB,CACF,CAAC;AACF,MAAM,MAAM,QAAQ,GAAG,CAAC,YAAY,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;AACpD,KAAK,OAAO,GAAG,sBAAsB,EAAE,CAAC;AACxC,MAAM,MAAM,sBAAsB,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;AAEnE,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM,GAAG,aAAa,EAAE,CAyCnE;AAED,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,aAAa,EAAE,GAAG,MAAM,CAQpE;AA2CD,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,MAAM,GAAG,cAAc,EAAE,CAoGrE;AAED,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,cAAc,EAAE,GAAG,MAAM,CAUtE"} \ No newline at end of file diff --git a/node_modules/@jridgewell/sourcemap-codec/types/sourcemap-codec.d.cts b/node_modules/@jridgewell/sourcemap-codec/types/sourcemap-codec.d.cts new file mode 100644 index 0000000000000000000000000000000000000000..5f35e22fbd820a22774712e8ee9a143198181570 --- /dev/null +++ b/node_modules/@jridgewell/sourcemap-codec/types/sourcemap-codec.d.cts @@ -0,0 +1,9 @@ +export { decodeOriginalScopes, encodeOriginalScopes, decodeGeneratedRanges, encodeGeneratedRanges, } from './scopes.cts'; +export type { OriginalScope, GeneratedRange, CallSite, BindingExpressionRange } from './scopes.cts'; +export type SourceMapSegment = [number] | [number, number, number, number] | [number, number, number, number, number]; +export type SourceMapLine = SourceMapSegment[]; +export type SourceMapMappings = SourceMapLine[]; +export declare function decode(mappings: string): SourceMapMappings; +export declare function encode(decoded: SourceMapMappings): string; +export declare function encode(decoded: Readonly): string; +//# sourceMappingURL=sourcemap-codec.d.ts.map \ No newline at end of file diff --git a/node_modules/@jridgewell/sourcemap-codec/types/sourcemap-codec.d.cts.map b/node_modules/@jridgewell/sourcemap-codec/types/sourcemap-codec.d.cts.map new file mode 100644 index 0000000000000000000000000000000000000000..7123d5208334960664abfaae0e5b663819462c0b --- /dev/null +++ b/node_modules/@jridgewell/sourcemap-codec/types/sourcemap-codec.d.cts.map @@ -0,0 +1 @@ +{"version":3,"file":"sourcemap-codec.d.ts","sourceRoot":"","sources":["../src/sourcemap-codec.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,oBAAoB,EACpB,oBAAoB,EACpB,qBAAqB,EACrB,qBAAqB,GACtB,MAAM,UAAU,CAAC;AAClB,YAAY,EAAE,aAAa,EAAE,cAAc,EAAE,QAAQ,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAC;AAEhG,MAAM,MAAM,gBAAgB,GACxB,CAAC,MAAM,CAAC,GACR,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,GAChC,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;AAC7C,MAAM,MAAM,aAAa,GAAG,gBAAgB,EAAE,CAAC;AAC/C,MAAM,MAAM,iBAAiB,GAAG,aAAa,EAAE,CAAC;AAEhD,wBAAgB,MAAM,CAAC,QAAQ,EAAE,MAAM,GAAG,iBAAiB,CAiD1D;AAUD,wBAAgB,MAAM,CAAC,OAAO,EAAE,iBAAiB,GAAG,MAAM,CAAC;AAC3D,wBAAgB,MAAM,CAAC,OAAO,EAAE,QAAQ,CAAC,iBAAiB,CAAC,GAAG,MAAM,CAAC"} \ No newline at end of file diff --git a/node_modules/@jridgewell/sourcemap-codec/types/sourcemap-codec.d.mts b/node_modules/@jridgewell/sourcemap-codec/types/sourcemap-codec.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..199fb9f534fe625d4c18c27c2b79e2309708279c --- /dev/null +++ b/node_modules/@jridgewell/sourcemap-codec/types/sourcemap-codec.d.mts @@ -0,0 +1,9 @@ +export { decodeOriginalScopes, encodeOriginalScopes, decodeGeneratedRanges, encodeGeneratedRanges, } from './scopes.mts'; +export type { OriginalScope, GeneratedRange, CallSite, BindingExpressionRange } from './scopes.mts'; +export type SourceMapSegment = [number] | [number, number, number, number] | [number, number, number, number, number]; +export type SourceMapLine = SourceMapSegment[]; +export type SourceMapMappings = SourceMapLine[]; +export declare function decode(mappings: string): SourceMapMappings; +export declare function encode(decoded: SourceMapMappings): string; +export declare function encode(decoded: Readonly): string; +//# sourceMappingURL=sourcemap-codec.d.ts.map \ No newline at end of file diff --git a/node_modules/@jridgewell/sourcemap-codec/types/sourcemap-codec.d.mts.map b/node_modules/@jridgewell/sourcemap-codec/types/sourcemap-codec.d.mts.map new file mode 100644 index 0000000000000000000000000000000000000000..7123d5208334960664abfaae0e5b663819462c0b --- /dev/null +++ b/node_modules/@jridgewell/sourcemap-codec/types/sourcemap-codec.d.mts.map @@ -0,0 +1 @@ +{"version":3,"file":"sourcemap-codec.d.ts","sourceRoot":"","sources":["../src/sourcemap-codec.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,oBAAoB,EACpB,oBAAoB,EACpB,qBAAqB,EACrB,qBAAqB,GACtB,MAAM,UAAU,CAAC;AAClB,YAAY,EAAE,aAAa,EAAE,cAAc,EAAE,QAAQ,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAC;AAEhG,MAAM,MAAM,gBAAgB,GACxB,CAAC,MAAM,CAAC,GACR,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,GAChC,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;AAC7C,MAAM,MAAM,aAAa,GAAG,gBAAgB,EAAE,CAAC;AAC/C,MAAM,MAAM,iBAAiB,GAAG,aAAa,EAAE,CAAC;AAEhD,wBAAgB,MAAM,CAAC,QAAQ,EAAE,MAAM,GAAG,iBAAiB,CAiD1D;AAUD,wBAAgB,MAAM,CAAC,OAAO,EAAE,iBAAiB,GAAG,MAAM,CAAC;AAC3D,wBAAgB,MAAM,CAAC,OAAO,EAAE,QAAQ,CAAC,iBAAiB,CAAC,GAAG,MAAM,CAAC"} \ No newline at end of file diff --git a/node_modules/@jridgewell/sourcemap-codec/types/strings.d.cts b/node_modules/@jridgewell/sourcemap-codec/types/strings.d.cts new file mode 100644 index 0000000000000000000000000000000000000000..62faceb3de9c90532158206c1ab55ee35ac24a89 --- /dev/null +++ b/node_modules/@jridgewell/sourcemap-codec/types/strings.d.cts @@ -0,0 +1,16 @@ +export declare class StringWriter { + pos: number; + private out; + private buffer; + write(v: number): void; + flush(): string; +} +export declare class StringReader { + pos: number; + private buffer; + constructor(buffer: string); + next(): number; + peek(): number; + indexOf(char: string): number; +} +//# sourceMappingURL=strings.d.ts.map \ No newline at end of file diff --git a/node_modules/@jridgewell/sourcemap-codec/types/strings.d.cts.map b/node_modules/@jridgewell/sourcemap-codec/types/strings.d.cts.map new file mode 100644 index 0000000000000000000000000000000000000000..d3602da4257449b6145da1bcaf14314073d6f31a --- /dev/null +++ b/node_modules/@jridgewell/sourcemap-codec/types/strings.d.cts.map @@ -0,0 +1 @@ +{"version":3,"file":"strings.d.ts","sourceRoot":"","sources":["../src/strings.ts"],"names":[],"mappings":"AAuBA,qBAAa,YAAY;IACvB,GAAG,SAAK;IACR,OAAO,CAAC,GAAG,CAAM;IACjB,OAAO,CAAC,MAAM,CAA6B;IAE3C,KAAK,CAAC,CAAC,EAAE,MAAM,GAAG,IAAI;IAStB,KAAK,IAAI,MAAM;CAIhB;AAED,qBAAa,YAAY;IACvB,GAAG,SAAK;IACR,QAAgB,MAAM,CAAS;gBAEnB,MAAM,EAAE,MAAM;IAI1B,IAAI,IAAI,MAAM;IAId,IAAI,IAAI,MAAM;IAId,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;CAK9B"} \ No newline at end of file diff --git a/node_modules/@jridgewell/sourcemap-codec/types/strings.d.mts b/node_modules/@jridgewell/sourcemap-codec/types/strings.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..62faceb3de9c90532158206c1ab55ee35ac24a89 --- /dev/null +++ b/node_modules/@jridgewell/sourcemap-codec/types/strings.d.mts @@ -0,0 +1,16 @@ +export declare class StringWriter { + pos: number; + private out; + private buffer; + write(v: number): void; + flush(): string; +} +export declare class StringReader { + pos: number; + private buffer; + constructor(buffer: string); + next(): number; + peek(): number; + indexOf(char: string): number; +} +//# sourceMappingURL=strings.d.ts.map \ No newline at end of file diff --git a/node_modules/@jridgewell/sourcemap-codec/types/strings.d.mts.map b/node_modules/@jridgewell/sourcemap-codec/types/strings.d.mts.map new file mode 100644 index 0000000000000000000000000000000000000000..d3602da4257449b6145da1bcaf14314073d6f31a --- /dev/null +++ b/node_modules/@jridgewell/sourcemap-codec/types/strings.d.mts.map @@ -0,0 +1 @@ +{"version":3,"file":"strings.d.ts","sourceRoot":"","sources":["../src/strings.ts"],"names":[],"mappings":"AAuBA,qBAAa,YAAY;IACvB,GAAG,SAAK;IACR,OAAO,CAAC,GAAG,CAAM;IACjB,OAAO,CAAC,MAAM,CAA6B;IAE3C,KAAK,CAAC,CAAC,EAAE,MAAM,GAAG,IAAI;IAStB,KAAK,IAAI,MAAM;CAIhB;AAED,qBAAa,YAAY;IACvB,GAAG,SAAK;IACR,QAAgB,MAAM,CAAS;gBAEnB,MAAM,EAAE,MAAM;IAI1B,IAAI,IAAI,MAAM;IAId,IAAI,IAAI,MAAM;IAId,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;CAK9B"} \ No newline at end of file diff --git a/node_modules/@jridgewell/sourcemap-codec/types/vlq.d.cts b/node_modules/@jridgewell/sourcemap-codec/types/vlq.d.cts new file mode 100644 index 0000000000000000000000000000000000000000..dbd6602d1876df8089ce52b3309b340d1a088555 --- /dev/null +++ b/node_modules/@jridgewell/sourcemap-codec/types/vlq.d.cts @@ -0,0 +1,7 @@ +import type { StringReader, StringWriter } from './strings.cts'; +export declare const comma: number; +export declare const semicolon: number; +export declare function decodeInteger(reader: StringReader, relative: number): number; +export declare function encodeInteger(builder: StringWriter, num: number, relative: number): number; +export declare function hasMoreVlq(reader: StringReader, max: number): boolean; +//# sourceMappingURL=vlq.d.ts.map \ No newline at end of file diff --git a/node_modules/@jridgewell/sourcemap-codec/types/vlq.d.cts.map b/node_modules/@jridgewell/sourcemap-codec/types/vlq.d.cts.map new file mode 100644 index 0000000000000000000000000000000000000000..6fdc356977cc89df14692e21863ed6724b63a0fc --- /dev/null +++ b/node_modules/@jridgewell/sourcemap-codec/types/vlq.d.cts.map @@ -0,0 +1 @@ +{"version":3,"file":"vlq.d.ts","sourceRoot":"","sources":["../src/vlq.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAE5D,eAAO,MAAM,KAAK,QAAoB,CAAC;AACvC,eAAO,MAAM,SAAS,QAAoB,CAAC;AAY3C,wBAAgB,aAAa,CAAC,MAAM,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAoB5E;AAED,wBAAgB,aAAa,CAAC,OAAO,EAAE,YAAY,EAAE,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAY1F;AAED,wBAAgB,UAAU,CAAC,MAAM,EAAE,YAAY,EAAE,GAAG,EAAE,MAAM,WAG3D"} \ No newline at end of file diff --git a/node_modules/@jridgewell/sourcemap-codec/types/vlq.d.mts b/node_modules/@jridgewell/sourcemap-codec/types/vlq.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..2c739bc9fedb038a659a85726a98af7c5f32c5da --- /dev/null +++ b/node_modules/@jridgewell/sourcemap-codec/types/vlq.d.mts @@ -0,0 +1,7 @@ +import type { StringReader, StringWriter } from './strings.mts'; +export declare const comma: number; +export declare const semicolon: number; +export declare function decodeInteger(reader: StringReader, relative: number): number; +export declare function encodeInteger(builder: StringWriter, num: number, relative: number): number; +export declare function hasMoreVlq(reader: StringReader, max: number): boolean; +//# sourceMappingURL=vlq.d.ts.map \ No newline at end of file diff --git a/node_modules/@jridgewell/sourcemap-codec/types/vlq.d.mts.map b/node_modules/@jridgewell/sourcemap-codec/types/vlq.d.mts.map new file mode 100644 index 0000000000000000000000000000000000000000..6fdc356977cc89df14692e21863ed6724b63a0fc --- /dev/null +++ b/node_modules/@jridgewell/sourcemap-codec/types/vlq.d.mts.map @@ -0,0 +1 @@ +{"version":3,"file":"vlq.d.ts","sourceRoot":"","sources":["../src/vlq.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAE5D,eAAO,MAAM,KAAK,QAAoB,CAAC;AACvC,eAAO,MAAM,SAAS,QAAoB,CAAC;AAY3C,wBAAgB,aAAa,CAAC,MAAM,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAoB5E;AAED,wBAAgB,aAAa,CAAC,OAAO,EAAE,YAAY,EAAE,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAY1F;AAED,wBAAgB,UAAU,CAAC,MAAM,EAAE,YAAY,EAAE,GAAG,EAAE,MAAM,WAG3D"} \ No newline at end of file diff --git a/node_modules/@jridgewell/trace-mapping/LICENSE b/node_modules/@jridgewell/trace-mapping/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..1f6ce94c11912496b96298630d84753dbf593a7d --- /dev/null +++ b/node_modules/@jridgewell/trace-mapping/LICENSE @@ -0,0 +1,19 @@ +Copyright 2024 Justin Ridgewell + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/node_modules/@jridgewell/trace-mapping/README.md b/node_modules/@jridgewell/trace-mapping/README.md new file mode 100644 index 0000000000000000000000000000000000000000..9fc0ed09cedeb0eea388b5d2b891b87886830776 --- /dev/null +++ b/node_modules/@jridgewell/trace-mapping/README.md @@ -0,0 +1,348 @@ +# @jridgewell/trace-mapping + +> Trace the original position through a source map + +`trace-mapping` allows you to take the line and column of an output file and trace it to the +original location in the source file through a source map. + +You may already be familiar with the [`source-map`][source-map] package's `SourceMapConsumer`. This +provides the same `originalPositionFor` and `generatedPositionFor` API, without requiring WASM. + +## Installation + +```sh +npm install @jridgewell/trace-mapping +``` + +## Usage + +```typescript +import { + TraceMap, + originalPositionFor, + generatedPositionFor, + sourceContentFor, + isIgnored, +} from '@jridgewell/trace-mapping'; + +const tracer = new TraceMap({ + version: 3, + sources: ['input.js'], + sourcesContent: ['content of input.js'], + names: ['foo'], + mappings: 'KAyCIA', + ignoreList: [], +}); + +// Lines start at line 1, columns at column 0. +const traced = originalPositionFor(tracer, { line: 1, column: 5 }); +assert.deepEqual(traced, { + source: 'input.js', + line: 42, + column: 4, + name: 'foo', +}); + +const content = sourceContentFor(tracer, traced.source); +assert.strictEqual(content, 'content for input.js'); + +const generated = generatedPositionFor(tracer, { + source: 'input.js', + line: 42, + column: 4, +}); +assert.deepEqual(generated, { + line: 1, + column: 5, +}); + +const ignored = isIgnored(tracer, 'input.js'); +assert.equal(ignored, false); +``` + +We also provide a lower level API to get the actual segment that matches our line and column. Unlike +`originalPositionFor`, `traceSegment` uses a 0-base for `line`: + +```typescript +import { traceSegment } from '@jridgewell/trace-mapping'; + +// line is 0-base. +const traced = traceSegment(tracer, /* line */ 0, /* column */ 5); + +// Segments are [outputColumn, sourcesIndex, sourceLine, sourceColumn, namesIndex] +// Again, line is 0-base and so is sourceLine +assert.deepEqual(traced, [5, 0, 41, 4, 0]); +``` + +### SectionedSourceMaps + +The sourcemap spec defines a special `sections` field that's designed to handle concatenation of +output code with associated sourcemaps. This type of sourcemap is rarely used (no major build tool +produces it), but if you are hand coding a concatenation you may need it. We provide an `AnyMap` +helper that can receive either a regular sourcemap or a `SectionedSourceMap` and returns a +`TraceMap` instance: + +```typescript +import { AnyMap } from '@jridgewell/trace-mapping'; +const fooOutput = 'foo'; +const barOutput = 'bar'; +const output = [fooOutput, barOutput].join('\n'); + +const sectioned = new AnyMap({ + version: 3, + sections: [ + { + // 0-base line and column + offset: { line: 0, column: 0 }, + // fooOutput's sourcemap + map: { + version: 3, + sources: ['foo.js'], + names: ['foo'], + mappings: 'AAAAA', + }, + }, + { + // barOutput's sourcemap will not affect the first line, only the second + offset: { line: 1, column: 0 }, + map: { + version: 3, + sources: ['bar.js'], + names: ['bar'], + mappings: 'AAAAA', + }, + }, + ], +}); + +const traced = originalPositionFor(sectioned, { + line: 2, + column: 0, +}); + +assert.deepEqual(traced, { + source: 'bar.js', + line: 1, + column: 0, + name: 'bar', +}); +``` + +## Benchmarks + +``` +node v20.10.0 + +amp.js.map - 45120 segments + +Memory Usage: +trace-mapping decoded 414164 bytes +trace-mapping encoded 6274352 bytes +source-map-js 10968904 bytes +source-map-0.6.1 17587160 bytes +source-map-0.8.0 8812155 bytes +Chrome dev tools 8672912 bytes +Smallest memory usage is trace-mapping decoded + +Init speed: +trace-mapping: decoded JSON input x 205 ops/sec ±0.19% (88 runs sampled) +trace-mapping: encoded JSON input x 405 ops/sec ±1.47% (88 runs sampled) +trace-mapping: decoded Object input x 4,645 ops/sec ±0.15% (98 runs sampled) +trace-mapping: encoded Object input x 458 ops/sec ±1.63% (91 runs sampled) +source-map-js: encoded Object input x 75.48 ops/sec ±1.64% (67 runs sampled) +source-map-0.6.1: encoded Object input x 39.37 ops/sec ±1.44% (53 runs sampled) +Chrome dev tools: encoded Object input x 150 ops/sec ±1.76% (79 runs sampled) +Fastest is trace-mapping: decoded Object input + +Trace speed (random): +trace-mapping: decoded originalPositionFor x 44,946 ops/sec ±0.16% (99 runs sampled) +trace-mapping: encoded originalPositionFor x 37,995 ops/sec ±1.81% (89 runs sampled) +source-map-js: encoded originalPositionFor x 9,230 ops/sec ±1.36% (93 runs sampled) +source-map-0.6.1: encoded originalPositionFor x 8,057 ops/sec ±0.84% (96 runs sampled) +source-map-0.8.0: encoded originalPositionFor x 28,198 ops/sec ±1.12% (91 runs sampled) +Chrome dev tools: encoded originalPositionFor x 46,276 ops/sec ±1.35% (95 runs sampled) +Fastest is Chrome dev tools: encoded originalPositionFor + +Trace speed (ascending): +trace-mapping: decoded originalPositionFor x 204,406 ops/sec ±0.19% (97 runs sampled) +trace-mapping: encoded originalPositionFor x 196,695 ops/sec ±0.24% (99 runs sampled) +source-map-js: encoded originalPositionFor x 11,948 ops/sec ±0.94% (99 runs sampled) +source-map-0.6.1: encoded originalPositionFor x 10,730 ops/sec ±0.36% (100 runs sampled) +source-map-0.8.0: encoded originalPositionFor x 51,427 ops/sec ±0.21% (98 runs sampled) +Chrome dev tools: encoded originalPositionFor x 162,615 ops/sec ±0.18% (98 runs sampled) +Fastest is trace-mapping: decoded originalPositionFor + + +*** + + +babel.min.js.map - 347793 segments + +Memory Usage: +trace-mapping decoded 18504 bytes +trace-mapping encoded 35428008 bytes +source-map-js 51676808 bytes +source-map-0.6.1 63367136 bytes +source-map-0.8.0 43158400 bytes +Chrome dev tools 50721552 bytes +Smallest memory usage is trace-mapping decoded + +Init speed: +trace-mapping: decoded JSON input x 17.82 ops/sec ±6.35% (35 runs sampled) +trace-mapping: encoded JSON input x 31.57 ops/sec ±7.50% (43 runs sampled) +trace-mapping: decoded Object input x 867 ops/sec ±0.74% (94 runs sampled) +trace-mapping: encoded Object input x 33.83 ops/sec ±7.66% (46 runs sampled) +source-map-js: encoded Object input x 6.58 ops/sec ±3.31% (20 runs sampled) +source-map-0.6.1: encoded Object input x 4.23 ops/sec ±3.43% (15 runs sampled) +Chrome dev tools: encoded Object input x 22.14 ops/sec ±3.79% (41 runs sampled) +Fastest is trace-mapping: decoded Object input + +Trace speed (random): +trace-mapping: decoded originalPositionFor x 78,234 ops/sec ±1.48% (29 runs sampled) +trace-mapping: encoded originalPositionFor x 60,761 ops/sec ±1.35% (21 runs sampled) +source-map-js: encoded originalPositionFor x 51,448 ops/sec ±2.17% (89 runs sampled) +source-map-0.6.1: encoded originalPositionFor x 47,221 ops/sec ±1.99% (15 runs sampled) +source-map-0.8.0: encoded originalPositionFor x 84,002 ops/sec ±1.45% (27 runs sampled) +Chrome dev tools: encoded originalPositionFor x 106,457 ops/sec ±1.38% (37 runs sampled) +Fastest is Chrome dev tools: encoded originalPositionFor + +Trace speed (ascending): +trace-mapping: decoded originalPositionFor x 930,943 ops/sec ±0.25% (99 runs sampled) +trace-mapping: encoded originalPositionFor x 843,545 ops/sec ±0.34% (97 runs sampled) +source-map-js: encoded originalPositionFor x 114,510 ops/sec ±1.37% (36 runs sampled) +source-map-0.6.1: encoded originalPositionFor x 87,412 ops/sec ±0.72% (92 runs sampled) +source-map-0.8.0: encoded originalPositionFor x 197,709 ops/sec ±0.89% (59 runs sampled) +Chrome dev tools: encoded originalPositionFor x 688,983 ops/sec ±0.33% (98 runs sampled) +Fastest is trace-mapping: decoded originalPositionFor + + +*** + + +preact.js.map - 1992 segments + +Memory Usage: +trace-mapping decoded 33136 bytes +trace-mapping encoded 254240 bytes +source-map-js 837488 bytes +source-map-0.6.1 961928 bytes +source-map-0.8.0 54384 bytes +Chrome dev tools 709680 bytes +Smallest memory usage is trace-mapping decoded + +Init speed: +trace-mapping: decoded JSON input x 3,709 ops/sec ±0.13% (99 runs sampled) +trace-mapping: encoded JSON input x 6,447 ops/sec ±0.22% (101 runs sampled) +trace-mapping: decoded Object input x 83,062 ops/sec ±0.23% (100 runs sampled) +trace-mapping: encoded Object input x 14,980 ops/sec ±0.28% (100 runs sampled) +source-map-js: encoded Object input x 2,544 ops/sec ±0.16% (99 runs sampled) +source-map-0.6.1: encoded Object input x 1,221 ops/sec ±0.37% (97 runs sampled) +Chrome dev tools: encoded Object input x 4,241 ops/sec ±0.39% (93 runs sampled) +Fastest is trace-mapping: decoded Object input + +Trace speed (random): +trace-mapping: decoded originalPositionFor x 91,028 ops/sec ±0.14% (94 runs sampled) +trace-mapping: encoded originalPositionFor x 84,348 ops/sec ±0.26% (98 runs sampled) +source-map-js: encoded originalPositionFor x 26,998 ops/sec ±0.23% (98 runs sampled) +source-map-0.6.1: encoded originalPositionFor x 18,049 ops/sec ±0.26% (100 runs sampled) +source-map-0.8.0: encoded originalPositionFor x 41,916 ops/sec ±0.28% (98 runs sampled) +Chrome dev tools: encoded originalPositionFor x 88,616 ops/sec ±0.14% (98 runs sampled) +Fastest is trace-mapping: decoded originalPositionFor + +Trace speed (ascending): +trace-mapping: decoded originalPositionFor x 319,960 ops/sec ±0.16% (100 runs sampled) +trace-mapping: encoded originalPositionFor x 302,153 ops/sec ±0.18% (100 runs sampled) +source-map-js: encoded originalPositionFor x 35,574 ops/sec ±0.19% (100 runs sampled) +source-map-0.6.1: encoded originalPositionFor x 19,943 ops/sec ±0.12% (101 runs sampled) +source-map-0.8.0: encoded originalPositionFor x 54,648 ops/sec ±0.20% (99 runs sampled) +Chrome dev tools: encoded originalPositionFor x 278,319 ops/sec ±0.17% (102 runs sampled) +Fastest is trace-mapping: decoded originalPositionFor + + +*** + + +react.js.map - 5726 segments + +Memory Usage: +trace-mapping decoded 10872 bytes +trace-mapping encoded 681512 bytes +source-map-js 2563944 bytes +source-map-0.6.1 2150864 bytes +source-map-0.8.0 88680 bytes +Chrome dev tools 1149576 bytes +Smallest memory usage is trace-mapping decoded + +Init speed: +trace-mapping: decoded JSON input x 1,887 ops/sec ±0.28% (99 runs sampled) +trace-mapping: encoded JSON input x 4,749 ops/sec ±0.48% (97 runs sampled) +trace-mapping: decoded Object input x 74,236 ops/sec ±0.11% (99 runs sampled) +trace-mapping: encoded Object input x 5,752 ops/sec ±0.38% (100 runs sampled) +source-map-js: encoded Object input x 806 ops/sec ±0.19% (97 runs sampled) +source-map-0.6.1: encoded Object input x 418 ops/sec ±0.33% (94 runs sampled) +Chrome dev tools: encoded Object input x 1,524 ops/sec ±0.57% (92 runs sampled) +Fastest is trace-mapping: decoded Object input + +Trace speed (random): +trace-mapping: decoded originalPositionFor x 620,201 ops/sec ±0.33% (96 runs sampled) +trace-mapping: encoded originalPositionFor x 579,548 ops/sec ±0.35% (97 runs sampled) +source-map-js: encoded originalPositionFor x 230,983 ops/sec ±0.62% (54 runs sampled) +source-map-0.6.1: encoded originalPositionFor x 158,145 ops/sec ±0.80% (46 runs sampled) +source-map-0.8.0: encoded originalPositionFor x 343,801 ops/sec ±0.55% (96 runs sampled) +Chrome dev tools: encoded originalPositionFor x 659,649 ops/sec ±0.49% (98 runs sampled) +Fastest is Chrome dev tools: encoded originalPositionFor + +Trace speed (ascending): +trace-mapping: decoded originalPositionFor x 2,368,079 ops/sec ±0.32% (98 runs sampled) +trace-mapping: encoded originalPositionFor x 2,134,039 ops/sec ±2.72% (87 runs sampled) +source-map-js: encoded originalPositionFor x 290,120 ops/sec ±2.49% (82 runs sampled) +source-map-0.6.1: encoded originalPositionFor x 187,613 ops/sec ±0.86% (49 runs sampled) +source-map-0.8.0: encoded originalPositionFor x 479,569 ops/sec ±0.65% (96 runs sampled) +Chrome dev tools: encoded originalPositionFor x 2,048,414 ops/sec ±0.24% (98 runs sampled) +Fastest is trace-mapping: decoded originalPositionFor + + +*** + + +vscode.map - 2141001 segments + +Memory Usage: +trace-mapping decoded 5206584 bytes +trace-mapping encoded 208370336 bytes +source-map-js 278493008 bytes +source-map-0.6.1 391564048 bytes +source-map-0.8.0 257508787 bytes +Chrome dev tools 291053000 bytes +Smallest memory usage is trace-mapping decoded + +Init speed: +trace-mapping: decoded JSON input x 1.63 ops/sec ±33.88% (9 runs sampled) +trace-mapping: encoded JSON input x 3.29 ops/sec ±36.13% (13 runs sampled) +trace-mapping: decoded Object input x 103 ops/sec ±0.93% (77 runs sampled) +trace-mapping: encoded Object input x 5.42 ops/sec ±28.54% (19 runs sampled) +source-map-js: encoded Object input x 1.07 ops/sec ±13.84% (7 runs sampled) +source-map-0.6.1: encoded Object input x 0.60 ops/sec ±2.43% (6 runs sampled) +Chrome dev tools: encoded Object input x 2.61 ops/sec ±22.00% (11 runs sampled) +Fastest is trace-mapping: decoded Object input + +Trace speed (random): +trace-mapping: decoded originalPositionFor x 257,019 ops/sec ±0.97% (93 runs sampled) +trace-mapping: encoded originalPositionFor x 179,163 ops/sec ±0.83% (92 runs sampled) +source-map-js: encoded originalPositionFor x 73,337 ops/sec ±1.35% (87 runs sampled) +source-map-0.6.1: encoded originalPositionFor x 38,797 ops/sec ±1.66% (88 runs sampled) +source-map-0.8.0: encoded originalPositionFor x 107,758 ops/sec ±1.94% (45 runs sampled) +Chrome dev tools: encoded originalPositionFor x 188,550 ops/sec ±1.85% (79 runs sampled) +Fastest is trace-mapping: decoded originalPositionFor + +Trace speed (ascending): +trace-mapping: decoded originalPositionFor x 447,621 ops/sec ±3.64% (94 runs sampled) +trace-mapping: encoded originalPositionFor x 323,698 ops/sec ±5.20% (88 runs sampled) +source-map-js: encoded originalPositionFor x 78,387 ops/sec ±1.69% (89 runs sampled) +source-map-0.6.1: encoded originalPositionFor x 41,016 ops/sec ±3.01% (25 runs sampled) +source-map-0.8.0: encoded originalPositionFor x 124,204 ops/sec ±0.90% (92 runs sampled) +Chrome dev tools: encoded originalPositionFor x 230,087 ops/sec ±2.61% (93 runs sampled) +Fastest is trace-mapping: decoded originalPositionFor +``` + +[source-map]: https://www.npmjs.com/package/source-map diff --git a/node_modules/@jridgewell/trace-mapping/dist/trace-mapping.mjs b/node_modules/@jridgewell/trace-mapping/dist/trace-mapping.mjs new file mode 100644 index 0000000000000000000000000000000000000000..73a95c77d0329af0dcabf21caaa14a49956d0cbd --- /dev/null +++ b/node_modules/@jridgewell/trace-mapping/dist/trace-mapping.mjs @@ -0,0 +1,493 @@ +// src/trace-mapping.ts +import { encode, decode } from "@jridgewell/sourcemap-codec"; + +// src/resolve.ts +import resolveUri from "@jridgewell/resolve-uri"; + +// src/strip-filename.ts +function stripFilename(path) { + if (!path) return ""; + const index = path.lastIndexOf("/"); + return path.slice(0, index + 1); +} + +// src/resolve.ts +function resolver(mapUrl, sourceRoot) { + const from = stripFilename(mapUrl); + const prefix = sourceRoot ? sourceRoot + "/" : ""; + return (source) => resolveUri(prefix + (source || ""), from); +} + +// src/sourcemap-segment.ts +var COLUMN = 0; +var SOURCES_INDEX = 1; +var SOURCE_LINE = 2; +var SOURCE_COLUMN = 3; +var NAMES_INDEX = 4; +var REV_GENERATED_LINE = 1; +var REV_GENERATED_COLUMN = 2; + +// src/sort.ts +function maybeSort(mappings, owned) { + const unsortedIndex = nextUnsortedSegmentLine(mappings, 0); + if (unsortedIndex === mappings.length) return mappings; + if (!owned) mappings = mappings.slice(); + for (let i = unsortedIndex; i < mappings.length; i = nextUnsortedSegmentLine(mappings, i + 1)) { + mappings[i] = sortSegments(mappings[i], owned); + } + return mappings; +} +function nextUnsortedSegmentLine(mappings, start) { + for (let i = start; i < mappings.length; i++) { + if (!isSorted(mappings[i])) return i; + } + return mappings.length; +} +function isSorted(line) { + for (let j = 1; j < line.length; j++) { + if (line[j][COLUMN] < line[j - 1][COLUMN]) { + return false; + } + } + return true; +} +function sortSegments(line, owned) { + if (!owned) line = line.slice(); + return line.sort(sortComparator); +} +function sortComparator(a, b) { + return a[COLUMN] - b[COLUMN]; +} + +// src/by-source.ts +function buildBySources(decoded, memos) { + const sources = memos.map(() => []); + for (let i = 0; i < decoded.length; i++) { + const line = decoded[i]; + for (let j = 0; j < line.length; j++) { + const seg = line[j]; + if (seg.length === 1) continue; + const sourceIndex2 = seg[SOURCES_INDEX]; + const sourceLine = seg[SOURCE_LINE]; + const sourceColumn = seg[SOURCE_COLUMN]; + const source = sources[sourceIndex2]; + const segs = source[sourceLine] || (source[sourceLine] = []); + segs.push([sourceColumn, i, seg[COLUMN]]); + } + } + for (let i = 0; i < sources.length; i++) { + const source = sources[i]; + for (let j = 0; j < source.length; j++) { + const line = source[j]; + if (line) line.sort(sortComparator); + } + } + return sources; +} + +// src/binary-search.ts +var found = false; +function binarySearch(haystack, needle, low, high) { + while (low <= high) { + const mid = low + (high - low >> 1); + const cmp = haystack[mid][COLUMN] - needle; + if (cmp === 0) { + found = true; + return mid; + } + if (cmp < 0) { + low = mid + 1; + } else { + high = mid - 1; + } + } + found = false; + return low - 1; +} +function upperBound(haystack, needle, index) { + for (let i = index + 1; i < haystack.length; index = i++) { + if (haystack[i][COLUMN] !== needle) break; + } + return index; +} +function lowerBound(haystack, needle, index) { + for (let i = index - 1; i >= 0; index = i--) { + if (haystack[i][COLUMN] !== needle) break; + } + return index; +} +function memoizedState() { + return { + lastKey: -1, + lastNeedle: -1, + lastIndex: -1 + }; +} +function memoizedBinarySearch(haystack, needle, state, key) { + const { lastKey, lastNeedle, lastIndex } = state; + let low = 0; + let high = haystack.length - 1; + if (key === lastKey) { + if (needle === lastNeedle) { + found = lastIndex !== -1 && haystack[lastIndex][COLUMN] === needle; + return lastIndex; + } + if (needle >= lastNeedle) { + low = lastIndex === -1 ? 0 : lastIndex; + } else { + high = lastIndex; + } + } + state.lastKey = key; + state.lastNeedle = needle; + return state.lastIndex = binarySearch(haystack, needle, low, high); +} + +// src/types.ts +function parse(map) { + return typeof map === "string" ? JSON.parse(map) : map; +} + +// src/flatten-map.ts +var FlattenMap = function(map, mapUrl) { + const parsed = parse(map); + if (!("sections" in parsed)) { + return new TraceMap(parsed, mapUrl); + } + const mappings = []; + const sources = []; + const sourcesContent = []; + const names = []; + const ignoreList = []; + recurse( + parsed, + mapUrl, + mappings, + sources, + sourcesContent, + names, + ignoreList, + 0, + 0, + Infinity, + Infinity + ); + const joined = { + version: 3, + file: parsed.file, + names, + sources, + sourcesContent, + mappings, + ignoreList + }; + return presortedDecodedMap(joined); +}; +function recurse(input, mapUrl, mappings, sources, sourcesContent, names, ignoreList, lineOffset, columnOffset, stopLine, stopColumn) { + const { sections } = input; + for (let i = 0; i < sections.length; i++) { + const { map, offset } = sections[i]; + let sl = stopLine; + let sc = stopColumn; + if (i + 1 < sections.length) { + const nextOffset = sections[i + 1].offset; + sl = Math.min(stopLine, lineOffset + nextOffset.line); + if (sl === stopLine) { + sc = Math.min(stopColumn, columnOffset + nextOffset.column); + } else if (sl < stopLine) { + sc = columnOffset + nextOffset.column; + } + } + addSection( + map, + mapUrl, + mappings, + sources, + sourcesContent, + names, + ignoreList, + lineOffset + offset.line, + columnOffset + offset.column, + sl, + sc + ); + } +} +function addSection(input, mapUrl, mappings, sources, sourcesContent, names, ignoreList, lineOffset, columnOffset, stopLine, stopColumn) { + const parsed = parse(input); + if ("sections" in parsed) return recurse(...arguments); + const map = new TraceMap(parsed, mapUrl); + const sourcesOffset = sources.length; + const namesOffset = names.length; + const decoded = decodedMappings(map); + const { resolvedSources, sourcesContent: contents, ignoreList: ignores } = map; + append(sources, resolvedSources); + append(names, map.names); + if (contents) append(sourcesContent, contents); + else for (let i = 0; i < resolvedSources.length; i++) sourcesContent.push(null); + if (ignores) for (let i = 0; i < ignores.length; i++) ignoreList.push(ignores[i] + sourcesOffset); + for (let i = 0; i < decoded.length; i++) { + const lineI = lineOffset + i; + if (lineI > stopLine) return; + const out = getLine(mappings, lineI); + const cOffset = i === 0 ? columnOffset : 0; + const line = decoded[i]; + for (let j = 0; j < line.length; j++) { + const seg = line[j]; + const column = cOffset + seg[COLUMN]; + if (lineI === stopLine && column >= stopColumn) return; + if (seg.length === 1) { + out.push([column]); + continue; + } + const sourcesIndex = sourcesOffset + seg[SOURCES_INDEX]; + const sourceLine = seg[SOURCE_LINE]; + const sourceColumn = seg[SOURCE_COLUMN]; + out.push( + seg.length === 4 ? [column, sourcesIndex, sourceLine, sourceColumn] : [column, sourcesIndex, sourceLine, sourceColumn, namesOffset + seg[NAMES_INDEX]] + ); + } + } +} +function append(arr, other) { + for (let i = 0; i < other.length; i++) arr.push(other[i]); +} +function getLine(arr, index) { + for (let i = arr.length; i <= index; i++) arr[i] = []; + return arr[index]; +} + +// src/trace-mapping.ts +var LINE_GTR_ZERO = "`line` must be greater than 0 (lines start at line 1)"; +var COL_GTR_EQ_ZERO = "`column` must be greater than or equal to 0 (columns start at column 0)"; +var LEAST_UPPER_BOUND = -1; +var GREATEST_LOWER_BOUND = 1; +var TraceMap = class { + constructor(map, mapUrl) { + const isString = typeof map === "string"; + if (!isString && map._decodedMemo) return map; + const parsed = parse(map); + const { version, file, names, sourceRoot, sources, sourcesContent } = parsed; + this.version = version; + this.file = file; + this.names = names || []; + this.sourceRoot = sourceRoot; + this.sources = sources; + this.sourcesContent = sourcesContent; + this.ignoreList = parsed.ignoreList || parsed.x_google_ignoreList || void 0; + const resolve = resolver(mapUrl, sourceRoot); + this.resolvedSources = sources.map(resolve); + const { mappings } = parsed; + if (typeof mappings === "string") { + this._encoded = mappings; + this._decoded = void 0; + } else if (Array.isArray(mappings)) { + this._encoded = void 0; + this._decoded = maybeSort(mappings, isString); + } else if (parsed.sections) { + throw new Error(`TraceMap passed sectioned source map, please use FlattenMap export instead`); + } else { + throw new Error(`invalid source map: ${JSON.stringify(parsed)}`); + } + this._decodedMemo = memoizedState(); + this._bySources = void 0; + this._bySourceMemos = void 0; + } +}; +function cast(map) { + return map; +} +function encodedMappings(map) { + var _a, _b; + return (_b = (_a = cast(map))._encoded) != null ? _b : _a._encoded = encode(cast(map)._decoded); +} +function decodedMappings(map) { + var _a; + return (_a = cast(map))._decoded || (_a._decoded = decode(cast(map)._encoded)); +} +function traceSegment(map, line, column) { + const decoded = decodedMappings(map); + if (line >= decoded.length) return null; + const segments = decoded[line]; + const index = traceSegmentInternal( + segments, + cast(map)._decodedMemo, + line, + column, + GREATEST_LOWER_BOUND + ); + return index === -1 ? null : segments[index]; +} +function originalPositionFor(map, needle) { + let { line, column, bias } = needle; + line--; + if (line < 0) throw new Error(LINE_GTR_ZERO); + if (column < 0) throw new Error(COL_GTR_EQ_ZERO); + const decoded = decodedMappings(map); + if (line >= decoded.length) return OMapping(null, null, null, null); + const segments = decoded[line]; + const index = traceSegmentInternal( + segments, + cast(map)._decodedMemo, + line, + column, + bias || GREATEST_LOWER_BOUND + ); + if (index === -1) return OMapping(null, null, null, null); + const segment = segments[index]; + if (segment.length === 1) return OMapping(null, null, null, null); + const { names, resolvedSources } = map; + return OMapping( + resolvedSources[segment[SOURCES_INDEX]], + segment[SOURCE_LINE] + 1, + segment[SOURCE_COLUMN], + segment.length === 5 ? names[segment[NAMES_INDEX]] : null + ); +} +function generatedPositionFor(map, needle) { + const { source, line, column, bias } = needle; + return generatedPosition(map, source, line, column, bias || GREATEST_LOWER_BOUND, false); +} +function allGeneratedPositionsFor(map, needle) { + const { source, line, column, bias } = needle; + return generatedPosition(map, source, line, column, bias || LEAST_UPPER_BOUND, true); +} +function eachMapping(map, cb) { + const decoded = decodedMappings(map); + const { names, resolvedSources } = map; + for (let i = 0; i < decoded.length; i++) { + const line = decoded[i]; + for (let j = 0; j < line.length; j++) { + const seg = line[j]; + const generatedLine = i + 1; + const generatedColumn = seg[0]; + let source = null; + let originalLine = null; + let originalColumn = null; + let name = null; + if (seg.length !== 1) { + source = resolvedSources[seg[1]]; + originalLine = seg[2] + 1; + originalColumn = seg[3]; + } + if (seg.length === 5) name = names[seg[4]]; + cb({ + generatedLine, + generatedColumn, + source, + originalLine, + originalColumn, + name + }); + } + } +} +function sourceIndex(map, source) { + const { sources, resolvedSources } = map; + let index = sources.indexOf(source); + if (index === -1) index = resolvedSources.indexOf(source); + return index; +} +function sourceContentFor(map, source) { + const { sourcesContent } = map; + if (sourcesContent == null) return null; + const index = sourceIndex(map, source); + return index === -1 ? null : sourcesContent[index]; +} +function isIgnored(map, source) { + const { ignoreList } = map; + if (ignoreList == null) return false; + const index = sourceIndex(map, source); + return index === -1 ? false : ignoreList.includes(index); +} +function presortedDecodedMap(map, mapUrl) { + const tracer = new TraceMap(clone(map, []), mapUrl); + cast(tracer)._decoded = map.mappings; + return tracer; +} +function decodedMap(map) { + return clone(map, decodedMappings(map)); +} +function encodedMap(map) { + return clone(map, encodedMappings(map)); +} +function clone(map, mappings) { + return { + version: map.version, + file: map.file, + names: map.names, + sourceRoot: map.sourceRoot, + sources: map.sources, + sourcesContent: map.sourcesContent, + mappings, + ignoreList: map.ignoreList || map.x_google_ignoreList + }; +} +function OMapping(source, line, column, name) { + return { source, line, column, name }; +} +function GMapping(line, column) { + return { line, column }; +} +function traceSegmentInternal(segments, memo, line, column, bias) { + let index = memoizedBinarySearch(segments, column, memo, line); + if (found) { + index = (bias === LEAST_UPPER_BOUND ? upperBound : lowerBound)(segments, column, index); + } else if (bias === LEAST_UPPER_BOUND) index++; + if (index === -1 || index === segments.length) return -1; + return index; +} +function sliceGeneratedPositions(segments, memo, line, column, bias) { + let min = traceSegmentInternal(segments, memo, line, column, GREATEST_LOWER_BOUND); + if (!found && bias === LEAST_UPPER_BOUND) min++; + if (min === -1 || min === segments.length) return []; + const matchedColumn = found ? column : segments[min][COLUMN]; + if (!found) min = lowerBound(segments, matchedColumn, min); + const max = upperBound(segments, matchedColumn, min); + const result = []; + for (; min <= max; min++) { + const segment = segments[min]; + result.push(GMapping(segment[REV_GENERATED_LINE] + 1, segment[REV_GENERATED_COLUMN])); + } + return result; +} +function generatedPosition(map, source, line, column, bias, all) { + var _a, _b; + line--; + if (line < 0) throw new Error(LINE_GTR_ZERO); + if (column < 0) throw new Error(COL_GTR_EQ_ZERO); + const { sources, resolvedSources } = map; + let sourceIndex2 = sources.indexOf(source); + if (sourceIndex2 === -1) sourceIndex2 = resolvedSources.indexOf(source); + if (sourceIndex2 === -1) return all ? [] : GMapping(null, null); + const bySourceMemos = (_a = cast(map))._bySourceMemos || (_a._bySourceMemos = sources.map(memoizedState)); + const generated = (_b = cast(map))._bySources || (_b._bySources = buildBySources(decodedMappings(map), bySourceMemos)); + const segments = generated[sourceIndex2][line]; + if (segments == null) return all ? [] : GMapping(null, null); + const memo = bySourceMemos[sourceIndex2]; + if (all) return sliceGeneratedPositions(segments, memo, line, column, bias); + const index = traceSegmentInternal(segments, memo, line, column, bias); + if (index === -1) return GMapping(null, null); + const segment = segments[index]; + return GMapping(segment[REV_GENERATED_LINE] + 1, segment[REV_GENERATED_COLUMN]); +} +export { + FlattenMap as AnyMap, + FlattenMap, + GREATEST_LOWER_BOUND, + LEAST_UPPER_BOUND, + TraceMap, + allGeneratedPositionsFor, + decodedMap, + decodedMappings, + eachMapping, + encodedMap, + encodedMappings, + generatedPositionFor, + isIgnored, + originalPositionFor, + presortedDecodedMap, + sourceContentFor, + traceSegment +}; +//# sourceMappingURL=trace-mapping.mjs.map diff --git a/node_modules/@jridgewell/trace-mapping/dist/trace-mapping.mjs.map b/node_modules/@jridgewell/trace-mapping/dist/trace-mapping.mjs.map new file mode 100644 index 0000000000000000000000000000000000000000..a78958143be1bbc8f203e6efe48e41663e9ce534 --- /dev/null +++ b/node_modules/@jridgewell/trace-mapping/dist/trace-mapping.mjs.map @@ -0,0 +1,6 @@ +{ + "version": 3, + "sources": ["../src/trace-mapping.ts", "../src/resolve.ts", "../src/strip-filename.ts", "../src/sourcemap-segment.ts", "../src/sort.ts", "../src/by-source.ts", "../src/binary-search.ts", "../src/types.ts", "../src/flatten-map.ts"], + "mappings": ";AAAA,SAAS,QAAQ,cAAc;;;ACA/B,OAAO,gBAAgB;;;ACGR,SAAR,cAA+B,MAAyC;AAC7E,MAAI,CAAC,KAAM,QAAO;AAClB,QAAM,QAAQ,KAAK,YAAY,GAAG;AAClC,SAAO,KAAK,MAAM,GAAG,QAAQ,CAAC;AAChC;;;ADHe,SAAR,SACL,QACA,YACS;AACT,QAAM,OAAO,cAAc,MAAM;AAIjC,QAAM,SAAS,aAAa,aAAa,MAAM;AAE/C,SAAO,CAAC,WAAW,WAAW,UAAU,UAAU,KAAK,IAAI;AAC7D;;;AEAO,IAAM,SAAS;AACf,IAAM,gBAAgB;AACtB,IAAM,cAAc;AACp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AU,SAAS,KAAK;AAC9B,SAAO,SAAS,QAAQ,kBAAkB,IAAI,GAAG,QAAQ,oBAAoB,CAAC;AAChF;", + "names": ["sourceIndex", "sourceIndex"] +} diff --git a/node_modules/@jridgewell/trace-mapping/dist/trace-mapping.umd.js b/node_modules/@jridgewell/trace-mapping/dist/trace-mapping.umd.js new file mode 100644 index 0000000000000000000000000000000000000000..0387ae38c67017175d2441333ff49781ca5094fa --- /dev/null +++ b/node_modules/@jridgewell/trace-mapping/dist/trace-mapping.umd.js @@ -0,0 +1,559 @@ +(function (global, factory) { + if (typeof exports === 'object' && typeof module !== 'undefined') { + factory(module, require('@jridgewell/resolve-uri'), require('@jridgewell/sourcemap-codec')); + module.exports = def(module); + } else if (typeof define === 'function' && define.amd) { + define(['module', '@jridgewell/resolve-uri', '@jridgewell/sourcemap-codec'], function(mod) { + factory.apply(this, arguments); + mod.exports = def(mod); + }); + } else { + const mod = { exports: {} }; + factory(mod, global.resolveURI, global.sourcemapCodec); + global = typeof globalThis !== 'undefined' ? globalThis : global || self; + global.traceMapping = def(mod); + } + function def(m) { return 'default' in m.exports ? m.exports.default : m.exports; } +})(this, (function (module, require_resolveURI, require_sourcemapCodec) { +"use strict"; +var __create = Object.create; +var __defProp = Object.defineProperty; +var __getOwnPropDesc = Object.getOwnPropertyDescriptor; +var __getOwnPropNames = Object.getOwnPropertyNames; +var __getProtoOf = Object.getPrototypeOf; +var __hasOwnProp = Object.prototype.hasOwnProperty; +var __commonJS = (cb, mod) => function __require() { + return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports; +}; +var __export = (target, all) => { + for (var name in all) + __defProp(target, name, { get: all[name], enumerable: true }); +}; +var __copyProps = (to, from, except, desc) => { + if (from && typeof from === "object" || typeof from === "function") { + for (let key of __getOwnPropNames(from)) + if (!__hasOwnProp.call(to, key) && key !== except) + __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); + } + return to; +}; +var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( + // If the importer is in node compatibility mode or this is not an ESM + // file that has been converted to a CommonJS file using a Babel- + // compatible transform (i.e. "__esModule" has not been set), then set + // "default" to the CommonJS "module.exports" for node compatibility. + isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, + mod +)); +var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); + +// umd:@jridgewell/sourcemap-codec +var require_sourcemap_codec = __commonJS({ + "umd:@jridgewell/sourcemap-codec"(exports, module2) { + module2.exports = require_sourcemapCodec; + } +}); + +// umd:@jridgewell/resolve-uri +var require_resolve_uri = __commonJS({ + "umd:@jridgewell/resolve-uri"(exports, module2) { + module2.exports = require_resolveURI; + } +}); + +// src/trace-mapping.ts +var trace_mapping_exports = {}; +__export(trace_mapping_exports, { + AnyMap: () => FlattenMap, + FlattenMap: () => FlattenMap, + GREATEST_LOWER_BOUND: () => GREATEST_LOWER_BOUND, + LEAST_UPPER_BOUND: () => LEAST_UPPER_BOUND, + TraceMap: () => TraceMap, + allGeneratedPositionsFor: () => allGeneratedPositionsFor, + decodedMap: () => decodedMap, + decodedMappings: () => decodedMappings, + eachMapping: () => eachMapping, + encodedMap: () => encodedMap, + encodedMappings: () => encodedMappings, + generatedPositionFor: () => generatedPositionFor, + isIgnored: () => isIgnored, + originalPositionFor: () => originalPositionFor, + presortedDecodedMap: () => presortedDecodedMap, + sourceContentFor: () => sourceContentFor, + traceSegment: () => traceSegment +}); +module.exports = __toCommonJS(trace_mapping_exports); +var import_sourcemap_codec = __toESM(require_sourcemap_codec()); + +// src/resolve.ts +var import_resolve_uri = __toESM(require_resolve_uri()); + +// src/strip-filename.ts +function stripFilename(path) { + if (!path) return ""; + const index = path.lastIndexOf("/"); + return path.slice(0, index + 1); +} + +// src/resolve.ts +function resolver(mapUrl, sourceRoot) { + const from = stripFilename(mapUrl); + const prefix = sourceRoot ? sourceRoot + "/" : ""; + return (source) => (0, import_resolve_uri.default)(prefix + (source || ""), from); +} + +// src/sourcemap-segment.ts +var COLUMN = 0; +var SOURCES_INDEX = 1; +var SOURCE_LINE = 2; +var SOURCE_COLUMN = 3; +var NAMES_INDEX = 4; +var REV_GENERATED_LINE = 1; +var REV_GENERATED_COLUMN = 2; + +// src/sort.ts +function maybeSort(mappings, owned) { + const unsortedIndex = nextUnsortedSegmentLine(mappings, 0); + if (unsortedIndex === mappings.length) return mappings; + if (!owned) mappings = mappings.slice(); + for (let i = unsortedIndex; i < mappings.length; i = nextUnsortedSegmentLine(mappings, i + 1)) { + mappings[i] = sortSegments(mappings[i], owned); + } + return mappings; +} +function nextUnsortedSegmentLine(mappings, start) { + for (let i = start; i < mappings.length; i++) { + if (!isSorted(mappings[i])) return i; + } + return mappings.length; +} +function isSorted(line) { + for (let j = 1; j < line.length; j++) { + if (line[j][COLUMN] < line[j - 1][COLUMN]) { + return false; + } + } + return true; +} +function sortSegments(line, owned) { + if (!owned) line = line.slice(); + return line.sort(sortComparator); +} +function sortComparator(a, b) { + return a[COLUMN] - b[COLUMN]; +} + +// src/by-source.ts +function buildBySources(decoded, memos) { + const sources = memos.map(() => []); + for (let i = 0; i < decoded.length; i++) { + const line = decoded[i]; + for (let j = 0; j < line.length; j++) { + const seg = line[j]; + if (seg.length === 1) continue; + const sourceIndex2 = seg[SOURCES_INDEX]; + const sourceLine = seg[SOURCE_LINE]; + const sourceColumn = seg[SOURCE_COLUMN]; + const source = sources[sourceIndex2]; + const segs = source[sourceLine] || (source[sourceLine] = []); + segs.push([sourceColumn, i, seg[COLUMN]]); + } + } + for (let i = 0; i < sources.length; i++) { + const source = sources[i]; + for (let j = 0; j < source.length; j++) { + const line = source[j]; + if (line) line.sort(sortComparator); + } + } + return sources; +} + +// src/binary-search.ts +var found = false; +function binarySearch(haystack, needle, low, high) { + while (low <= high) { + const mid = low + (high - low >> 1); + const cmp = haystack[mid][COLUMN] - needle; + if (cmp === 0) { + found = true; + return mid; + } + if (cmp < 0) { + low = mid + 1; + } else { + high = mid - 1; + } + } + found = false; + return low - 1; +} +function upperBound(haystack, needle, index) { + for (let i = index + 1; i < haystack.length; index = i++) { + if (haystack[i][COLUMN] !== needle) break; + } + return index; +} +function lowerBound(haystack, needle, index) { + for (let i = index - 1; i >= 0; index = i--) { + if (haystack[i][COLUMN] !== needle) break; + } + return index; +} +function memoizedState() { + return { + lastKey: -1, + lastNeedle: -1, + lastIndex: -1 + }; +} +function memoizedBinarySearch(haystack, needle, state, key) { + const { lastKey, lastNeedle, lastIndex } = state; + let low = 0; + let high = haystack.length - 1; + if (key === lastKey) { + if (needle === lastNeedle) { + found = lastIndex !== -1 && haystack[lastIndex][COLUMN] === needle; + return lastIndex; + } + if (needle >= lastNeedle) { + low = lastIndex === -1 ? 0 : lastIndex; + } else { + high = lastIndex; + } + } + state.lastKey = key; + state.lastNeedle = needle; + return state.lastIndex = binarySearch(haystack, needle, low, high); +} + +// src/types.ts +function parse(map) { + return typeof map === "string" ? JSON.parse(map) : map; +} + +// src/flatten-map.ts +var FlattenMap = function(map, mapUrl) { + const parsed = parse(map); + if (!("sections" in parsed)) { + return new TraceMap(parsed, mapUrl); + } + const mappings = []; + const sources = []; + const sourcesContent = []; + const names = []; + const ignoreList = []; + recurse( + parsed, + mapUrl, + mappings, + sources, + sourcesContent, + names, + ignoreList, + 0, + 0, + Infinity, + Infinity + ); + const joined = { + version: 3, + file: parsed.file, + names, + sources, + sourcesContent, + mappings, + ignoreList + }; + return presortedDecodedMap(joined); +}; +function recurse(input, mapUrl, mappings, sources, sourcesContent, names, ignoreList, lineOffset, columnOffset, stopLine, stopColumn) { + const { sections } = input; + for (let i = 0; i < sections.length; i++) { + const { map, offset } = sections[i]; + let sl = stopLine; + let sc = stopColumn; + if (i + 1 < sections.length) { + const nextOffset = sections[i + 1].offset; + sl = Math.min(stopLine, lineOffset + nextOffset.line); + if (sl === stopLine) { + sc = Math.min(stopColumn, columnOffset + nextOffset.column); + } else if (sl < stopLine) { + sc = columnOffset + nextOffset.column; + } + } + addSection( + map, + mapUrl, + mappings, + sources, + sourcesContent, + names, + ignoreList, + lineOffset + offset.line, + columnOffset + offset.column, + sl, + sc + ); + } +} +function addSection(input, mapUrl, mappings, sources, sourcesContent, names, ignoreList, lineOffset, columnOffset, stopLine, stopColumn) { + const parsed = parse(input); + if ("sections" in parsed) return recurse(...arguments); + const map = new TraceMap(parsed, mapUrl); + const sourcesOffset = sources.length; + const namesOffset = names.length; + const decoded = decodedMappings(map); + const { resolvedSources, sourcesContent: contents, ignoreList: ignores } = map; + append(sources, resolvedSources); + append(names, map.names); + if (contents) append(sourcesContent, contents); + else for (let i = 0; i < resolvedSources.length; i++) sourcesContent.push(null); + if (ignores) for (let i = 0; i < ignores.length; i++) ignoreList.push(ignores[i] + sourcesOffset); + for (let i = 0; i < decoded.length; i++) { + const lineI = lineOffset + i; + if (lineI > stopLine) return; + const out = getLine(mappings, lineI); + const cOffset = i === 0 ? columnOffset : 0; + const line = decoded[i]; + for (let j = 0; j < line.length; j++) { + const seg = line[j]; + const column = cOffset + seg[COLUMN]; + if (lineI === stopLine && column >= stopColumn) return; + if (seg.length === 1) { + out.push([column]); + continue; + } + const sourcesIndex = sourcesOffset + seg[SOURCES_INDEX]; + const sourceLine = seg[SOURCE_LINE]; + const sourceColumn = seg[SOURCE_COLUMN]; + out.push( + seg.length === 4 ? [column, sourcesIndex, sourceLine, sourceColumn] : [column, sourcesIndex, sourceLine, sourceColumn, namesOffset + seg[NAMES_INDEX]] + ); + } + } +} +function append(arr, other) { + for (let i = 0; i < other.length; i++) arr.push(other[i]); +} +function getLine(arr, index) { + for (let i = arr.length; i <= index; i++) arr[i] = []; + return arr[index]; +} + +// src/trace-mapping.ts +var LINE_GTR_ZERO = "`line` must be greater than 0 (lines start at line 1)"; +var COL_GTR_EQ_ZERO = "`column` must be greater than or equal to 0 (columns start at column 0)"; +var LEAST_UPPER_BOUND = -1; +var GREATEST_LOWER_BOUND = 1; +var TraceMap = class { + constructor(map, mapUrl) { + const isString = typeof map === "string"; + if (!isString && map._decodedMemo) return map; + const parsed = parse(map); + const { version, file, names, sourceRoot, sources, sourcesContent } = parsed; + this.version = version; + this.file = file; + this.names = names || []; + this.sourceRoot = sourceRoot; + this.sources = sources; + this.sourcesContent = sourcesContent; + this.ignoreList = parsed.ignoreList || parsed.x_google_ignoreList || void 0; + const resolve = resolver(mapUrl, sourceRoot); + this.resolvedSources = sources.map(resolve); + const { mappings } = parsed; + if (typeof mappings === "string") { + this._encoded = mappings; + this._decoded = void 0; + } else if (Array.isArray(mappings)) { + this._encoded = void 0; + this._decoded = maybeSort(mappings, isString); + } else if (parsed.sections) { + throw new Error(`TraceMap passed sectioned source map, please use FlattenMap export instead`); + } else { + throw new Error(`invalid source map: ${JSON.stringify(parsed)}`); + } + this._decodedMemo = memoizedState(); + this._bySources = void 0; + this._bySourceMemos = void 0; + } +}; +function cast(map) { + return map; +} +function encodedMappings(map) { + var _a, _b; + return (_b = (_a = cast(map))._encoded) != null ? _b : _a._encoded = (0, import_sourcemap_codec.encode)(cast(map)._decoded); +} +function decodedMappings(map) { + var _a; + return (_a = cast(map))._decoded || (_a._decoded = (0, import_sourcemap_codec.decode)(cast(map)._encoded)); +} +function traceSegment(map, line, column) { + const decoded = decodedMappings(map); + if (line >= decoded.length) return null; + const segments = decoded[line]; + const index = traceSegmentInternal( + segments, + cast(map)._decodedMemo, + line, + column, + GREATEST_LOWER_BOUND + ); + return index === -1 ? null : segments[index]; +} +function originalPositionFor(map, needle) { + let { line, column, bias } = needle; + line--; + if (line < 0) throw new Error(LINE_GTR_ZERO); + if (column < 0) throw new Error(COL_GTR_EQ_ZERO); + const decoded = decodedMappings(map); + if (line >= decoded.length) return OMapping(null, null, null, null); + const segments = decoded[line]; + const index = traceSegmentInternal( + segments, + cast(map)._decodedMemo, + line, + column, + bias || GREATEST_LOWER_BOUND + ); + if (index === -1) return OMapping(null, null, null, null); + const segment = segments[index]; + if (segment.length === 1) return OMapping(null, null, null, null); + const { names, resolvedSources } = map; + return OMapping( + resolvedSources[segment[SOURCES_INDEX]], + segment[SOURCE_LINE] + 1, + segment[SOURCE_COLUMN], + segment.length === 5 ? names[segment[NAMES_INDEX]] : null + ); +} +function generatedPositionFor(map, needle) { + const { source, line, column, bias } = needle; + return generatedPosition(map, source, line, column, bias || GREATEST_LOWER_BOUND, false); +} +function allGeneratedPositionsFor(map, needle) { + const { source, line, column, bias } = needle; + return generatedPosition(map, source, line, column, bias || LEAST_UPPER_BOUND, true); +} +function eachMapping(map, cb) { + const decoded = decodedMappings(map); + const { names, resolvedSources } = map; + for (let i = 0; i < decoded.length; i++) { + const line = decoded[i]; + for (let j = 0; j < line.length; j++) { + const seg = line[j]; + const generatedLine = i + 1; + const generatedColumn = seg[0]; + let source = null; + let originalLine = null; + let originalColumn = null; + let name = null; + if (seg.length !== 1) { + source = resolvedSources[seg[1]]; + originalLine = seg[2] + 1; + originalColumn = seg[3]; + } + if (seg.length === 5) name = names[seg[4]]; + cb({ + generatedLine, + generatedColumn, + source, + originalLine, + originalColumn, + name + }); + } + } +} +function sourceIndex(map, source) { + const { sources, resolvedSources } = map; + let index = sources.indexOf(source); + if (index === -1) index = resolvedSources.indexOf(source); + return index; +} +function sourceContentFor(map, source) { + const { sourcesContent } = map; + if (sourcesContent == null) return null; + const index = sourceIndex(map, source); + return index === -1 ? null : sourcesContent[index]; +} +function isIgnored(map, source) { + const { ignoreList } = map; + if (ignoreList == null) return false; + const index = sourceIndex(map, source); + return index === -1 ? false : ignoreList.includes(index); +} +function presortedDecodedMap(map, mapUrl) { + const tracer = new TraceMap(clone(map, []), mapUrl); + cast(tracer)._decoded = map.mappings; + return tracer; +} +function decodedMap(map) { + return clone(map, decodedMappings(map)); +} +function encodedMap(map) { + return clone(map, encodedMappings(map)); +} +function clone(map, mappings) { + return { + version: map.version, + file: map.file, + names: map.names, + sourceRoot: map.sourceRoot, + sources: map.sources, + sourcesContent: map.sourcesContent, + mappings, + ignoreList: map.ignoreList || map.x_google_ignoreList + }; +} +function OMapping(source, line, column, name) { + return { source, line, column, name }; +} +function GMapping(line, column) { + return { line, column }; +} +function traceSegmentInternal(segments, memo, line, column, bias) { + let index = memoizedBinarySearch(segments, column, memo, line); + if (found) { + index = (bias === LEAST_UPPER_BOUND ? upperBound : lowerBound)(segments, column, index); + } else if (bias === LEAST_UPPER_BOUND) index++; + if (index === -1 || index === segments.length) return -1; + return index; +} +function sliceGeneratedPositions(segments, memo, line, column, bias) { + let min = traceSegmentInternal(segments, memo, line, column, GREATEST_LOWER_BOUND); + if (!found && bias === LEAST_UPPER_BOUND) min++; + if (min === -1 || min === segments.length) return []; + const matchedColumn = found ? column : segments[min][COLUMN]; + if (!found) min = lowerBound(segments, matchedColumn, min); + const max = upperBound(segments, matchedColumn, min); + const result = []; + for (; min <= max; min++) { + const segment = segments[min]; + result.push(GMapping(segment[REV_GENERATED_LINE] + 1, segment[REV_GENERATED_COLUMN])); + } + return result; +} +function generatedPosition(map, source, line, column, bias, all) { + var _a, _b; + line--; + if (line < 0) throw new Error(LINE_GTR_ZERO); + if (column < 0) throw new Error(COL_GTR_EQ_ZERO); + const { sources, resolvedSources } = map; + let sourceIndex2 = sources.indexOf(source); + if (sourceIndex2 === -1) sourceIndex2 = resolvedSources.indexOf(source); + if (sourceIndex2 === -1) return all ? [] : GMapping(null, null); + const bySourceMemos = (_a = cast(map))._bySourceMemos || (_a._bySourceMemos = sources.map(memoizedState)); + const generated = (_b = cast(map))._bySources || (_b._bySources = buildBySources(decodedMappings(map), bySourceMemos)); + const segments = generated[sourceIndex2][line]; + if (segments == null) return all ? [] : GMapping(null, null); + const memo = bySourceMemos[sourceIndex2]; + if (all) return sliceGeneratedPositions(segments, memo, line, column, bias); + const index = traceSegmentInternal(segments, memo, line, column, bias); + if (index === -1) return GMapping(null, null); + const segment = segments[index]; + return GMapping(segment[REV_GENERATED_LINE] + 1, segment[REV_GENERATED_COLUMN]); +} +})); +//# sourceMappingURL=trace-mapping.umd.js.map diff --git a/node_modules/@jridgewell/trace-mapping/dist/trace-mapping.umd.js.map b/node_modules/@jridgewell/trace-mapping/dist/trace-mapping.umd.js.map new file mode 100644 index 0000000000000000000000000000000000000000..68b0c775d6a8c2d06f07fc5d1d5dd7d86c564b8b --- /dev/null +++ b/node_modules/@jridgewell/trace-mapping/dist/trace-mapping.umd.js.map @@ -0,0 +1,6 @@ +{ + "version": 3, + "sources": ["umd:@jridgewell/sourcemap-codec", "umd:@jridgewell/resolve-uri", "../src/trace-mapping.ts", "../src/resolve.ts", "../src/strip-filename.ts", "../src/sourcemap-segment.ts", "../src/sort.ts", "../src/by-source.ts", "../src/binary-search.ts", "../src/types.ts", "../src/flatten-map.ts"], + "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA,6CAAAA,SAAA;AAAA,IAAAA,QAAO,UAAU;AAAA;AAAA;;;ACAjB;AAAA,yCAAAC,SAAA;AAAA,IAAAA,QAAO,UAAU;AAAA;AAAA;;;ACAjB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,6BAA+B;;;ACA/B,yBAAuB;;;ACGR,SAAR,cAA+B,MAAyC;AAC7E,MAAI,CAAC,KAAM,QAAO;AAClB,QAAM,QAAQ,KAAK,YAAY,GAAG;AAClC,SAAO,KAAK,MAAM,GAAG,QAAQ,CAAC;AAChC;;;ADHe,SAAR,SACL,QACA,YACS;AACT,QAAM,OAAO,cAAc,MAAM;AAIjC,QAAM,SAAS,aAAa,aAAa,MAAM;AAE/C,SAAO,CAAC,eAAW,mBAAAC,SAAW,UAAU,UAAU,KAAK,IAAI;AAC7D;;;AEAO,IAAM,SAAS;AACf,IAAM,gBAAgB;AACtB,IAAM,cAAc;AACpB,IAAM,gBAAgB;AACtB,IAAM,cAAc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AS,QAAQ,kBAAkB,IAAI,GAAG,QAAQ,oBAAoB,CAAC;AAChF;", + "names": ["module", "module", "resolveUri", "sourceIndex", "sourceIndex"] +} diff --git a/node_modules/@jridgewell/trace-mapping/package.json b/node_modules/@jridgewell/trace-mapping/package.json new file mode 100644 index 0000000000000000000000000000000000000000..9d3a1c08e5d4c0316371ed16f966c353ab34e790 --- /dev/null +++ b/node_modules/@jridgewell/trace-mapping/package.json @@ -0,0 +1,67 @@ +{ + "name": "@jridgewell/trace-mapping", + "version": "0.3.31", + "description": "Trace the original position through a source map", + "keywords": [ + "source", + "map" + ], + "main": "dist/trace-mapping.umd.js", + "module": "dist/trace-mapping.mjs", + "types": "types/trace-mapping.d.cts", + "files": [ + "dist", + "src", + "types" + ], + "exports": { + ".": [ + { + "import": { + "types": "./types/trace-mapping.d.mts", + "default": "./dist/trace-mapping.mjs" + }, + "default": { + "types": "./types/trace-mapping.d.cts", + "default": "./dist/trace-mapping.umd.js" + } + }, + "./dist/trace-mapping.umd.js" + ], + "./package.json": "./package.json" + }, + "scripts": { + "benchmark": "run-s build:code benchmark:*", + "benchmark:install": "cd benchmark && npm install", + "benchmark:only": "node --expose-gc benchmark/index.mjs", + "build": "run-s -n build:code build:types", + "build:code": "node ../../esbuild.mjs trace-mapping.ts", + "build:types": "run-s build:types:force build:types:emit build:types:mts", + "build:types:force": "rimraf tsconfig.build.tsbuildinfo", + "build:types:emit": "tsc --project tsconfig.build.json", + "build:types:mts": "node ../../mts-types.mjs", + "clean": "run-s -n clean:code clean:types", + "clean:code": "tsc --build --clean tsconfig.build.json", + "clean:types": "rimraf dist types", + "test": "run-s -n test:types test:only test:format", + "test:format": "prettier --check '{src,test}/**/*.ts'", + "test:only": "mocha", + "test:types": "eslint '{src,test}/**/*.ts'", + "lint": "run-s -n lint:types lint:format", + "lint:format": "npm run test:format -- --write", + "lint:types": "npm run test:types -- --fix", + "prepublishOnly": "npm run-s -n build test" + }, + "homepage": "https://github.com/jridgewell/sourcemaps/tree/main/packages/trace-mapping", + "repository": { + "type": "git", + "url": "git+https://github.com/jridgewell/sourcemaps.git", + "directory": "packages/trace-mapping" + }, + "author": "Justin Ridgewell ", + "license": "MIT", + "dependencies": { + "@jridgewell/resolve-uri": "^3.1.0", + "@jridgewell/sourcemap-codec": "^1.4.14" + } +} diff --git a/node_modules/@jridgewell/trace-mapping/src/binary-search.ts b/node_modules/@jridgewell/trace-mapping/src/binary-search.ts new file mode 100644 index 0000000000000000000000000000000000000000..c1144ad1cdcdf6dcdfbfe3fed3f4daeeb2b1bd8d --- /dev/null +++ b/node_modules/@jridgewell/trace-mapping/src/binary-search.ts @@ -0,0 +1,115 @@ +import type { SourceMapSegment, ReverseSegment } from './sourcemap-segment'; +import { COLUMN } from './sourcemap-segment'; + +export type MemoState = { + lastKey: number; + lastNeedle: number; + lastIndex: number; +}; + +export let found = false; + +/** + * A binary search implementation that returns the index if a match is found. + * If no match is found, then the left-index (the index associated with the item that comes just + * before the desired index) is returned. To maintain proper sort order, a splice would happen at + * the next index: + * + * ```js + * const array = [1, 3]; + * const needle = 2; + * const index = binarySearch(array, needle, (item, needle) => item - needle); + * + * assert.equal(index, 0); + * array.splice(index + 1, 0, needle); + * assert.deepEqual(array, [1, 2, 3]); + * ``` + */ +export function binarySearch( + haystack: SourceMapSegment[] | ReverseSegment[], + needle: number, + low: number, + high: number, +): number { + while (low <= high) { + const mid = low + ((high - low) >> 1); + const cmp = haystack[mid][COLUMN] - needle; + + if (cmp === 0) { + found = true; + return mid; + } + + if (cmp < 0) { + low = mid + 1; + } else { + high = mid - 1; + } + } + + found = false; + return low - 1; +} + +export function upperBound( + haystack: SourceMapSegment[] | ReverseSegment[], + needle: number, + index: number, +): number { + for (let i = index + 1; i < haystack.length; index = i++) { + if (haystack[i][COLUMN] !== needle) break; + } + return index; +} + +export function lowerBound( + haystack: SourceMapSegment[] | ReverseSegment[], + needle: number, + index: number, +): number { + for (let i = index - 1; i >= 0; index = i--) { + if (haystack[i][COLUMN] !== needle) break; + } + return index; +} + +export function memoizedState(): MemoState { + return { + lastKey: -1, + lastNeedle: -1, + lastIndex: -1, + }; +} + +/** + * This overly complicated beast is just to record the last tested line/column and the resulting + * index, allowing us to skip a few tests if mappings are monotonically increasing. + */ +export function memoizedBinarySearch( + haystack: SourceMapSegment[] | ReverseSegment[], + needle: number, + state: MemoState, + key: number, +): number { + const { lastKey, lastNeedle, lastIndex } = state; + + let low = 0; + let high = haystack.length - 1; + if (key === lastKey) { + if (needle === lastNeedle) { + found = lastIndex !== -1 && haystack[lastIndex][COLUMN] === needle; + return lastIndex; + } + + if (needle >= lastNeedle) { + // lastIndex may be -1 if the previous needle was not found. + low = lastIndex === -1 ? 0 : lastIndex; + } else { + high = lastIndex; + } + } + state.lastKey = key; + state.lastNeedle = needle; + + return (state.lastIndex = binarySearch(haystack, needle, low, high)); +} diff --git a/node_modules/@jridgewell/trace-mapping/src/by-source.ts b/node_modules/@jridgewell/trace-mapping/src/by-source.ts new file mode 100644 index 0000000000000000000000000000000000000000..1da6af05cae200e2c4df1322a08910d0c5082e37 --- /dev/null +++ b/node_modules/@jridgewell/trace-mapping/src/by-source.ts @@ -0,0 +1,41 @@ +import { COLUMN, SOURCES_INDEX, SOURCE_LINE, SOURCE_COLUMN } from './sourcemap-segment'; +import { sortComparator } from './sort'; + +import type { ReverseSegment, SourceMapSegment } from './sourcemap-segment'; + +export type Source = ReverseSegment[][]; + +// Rebuilds the original source files, with mappings that are ordered by source line/column instead +// of generated line/column. +export default function buildBySources( + decoded: readonly SourceMapSegment[][], + memos: unknown[], +): Source[] { + const sources: Source[] = memos.map(() => []); + + for (let i = 0; i < decoded.length; i++) { + const line = decoded[i]; + for (let j = 0; j < line.length; j++) { + const seg = line[j]; + if (seg.length === 1) continue; + + const sourceIndex = seg[SOURCES_INDEX]; + const sourceLine = seg[SOURCE_LINE]; + const sourceColumn = seg[SOURCE_COLUMN]; + + const source = sources[sourceIndex]; + const segs = (source[sourceLine] ||= []); + segs.push([sourceColumn, i, seg[COLUMN]]); + } + } + + for (let i = 0; i < sources.length; i++) { + const source = sources[i]; + for (let j = 0; j < source.length; j++) { + const line = source[j]; + if (line) line.sort(sortComparator); + } + } + + return sources; +} diff --git a/node_modules/@jridgewell/trace-mapping/src/flatten-map.ts b/node_modules/@jridgewell/trace-mapping/src/flatten-map.ts new file mode 100644 index 0000000000000000000000000000000000000000..61ac40caabeb70e1759bf67e0582d01240120713 --- /dev/null +++ b/node_modules/@jridgewell/trace-mapping/src/flatten-map.ts @@ -0,0 +1,192 @@ +import { TraceMap, presortedDecodedMap, decodedMappings } from './trace-mapping'; +import { + COLUMN, + SOURCES_INDEX, + SOURCE_LINE, + SOURCE_COLUMN, + NAMES_INDEX, +} from './sourcemap-segment'; +import { parse } from './types'; + +import type { + DecodedSourceMap, + DecodedSourceMapXInput, + EncodedSourceMapXInput, + SectionedSourceMapXInput, + SectionedSourceMapInput, + SectionXInput, + Ro, +} from './types'; +import type { SourceMapSegment } from './sourcemap-segment'; + +type FlattenMap = { + new (map: Ro, mapUrl?: string | null): TraceMap; + (map: Ro, mapUrl?: string | null): TraceMap; +}; + +export const FlattenMap: FlattenMap = function (map, mapUrl) { + const parsed = parse(map as SectionedSourceMapInput); + + if (!('sections' in parsed)) { + return new TraceMap(parsed as DecodedSourceMapXInput | EncodedSourceMapXInput, mapUrl); + } + + const mappings: SourceMapSegment[][] = []; + const sources: string[] = []; + const sourcesContent: (string | null)[] = []; + const names: string[] = []; + const ignoreList: number[] = []; + + recurse( + parsed, + mapUrl, + mappings, + sources, + sourcesContent, + names, + ignoreList, + 0, + 0, + Infinity, + Infinity, + ); + + const joined: DecodedSourceMap = { + version: 3, + file: parsed.file, + names, + sources, + sourcesContent, + mappings, + ignoreList, + }; + + return presortedDecodedMap(joined); +} as FlattenMap; + +function recurse( + input: SectionedSourceMapXInput, + mapUrl: string | null | undefined, + mappings: SourceMapSegment[][], + sources: string[], + sourcesContent: (string | null)[], + names: string[], + ignoreList: number[], + lineOffset: number, + columnOffset: number, + stopLine: number, + stopColumn: number, +) { + const { sections } = input; + for (let i = 0; i < sections.length; i++) { + const { map, offset } = sections[i]; + + let sl = stopLine; + let sc = stopColumn; + if (i + 1 < sections.length) { + const nextOffset = sections[i + 1].offset; + sl = Math.min(stopLine, lineOffset + nextOffset.line); + + if (sl === stopLine) { + sc = Math.min(stopColumn, columnOffset + nextOffset.column); + } else if (sl < stopLine) { + sc = columnOffset + nextOffset.column; + } + } + + addSection( + map, + mapUrl, + mappings, + sources, + sourcesContent, + names, + ignoreList, + lineOffset + offset.line, + columnOffset + offset.column, + sl, + sc, + ); + } +} + +function addSection( + input: SectionXInput['map'], + mapUrl: string | null | undefined, + mappings: SourceMapSegment[][], + sources: string[], + sourcesContent: (string | null)[], + names: string[], + ignoreList: number[], + lineOffset: number, + columnOffset: number, + stopLine: number, + stopColumn: number, +) { + const parsed = parse(input); + if ('sections' in parsed) return recurse(...(arguments as unknown as Parameters)); + + const map = new TraceMap(parsed, mapUrl); + const sourcesOffset = sources.length; + const namesOffset = names.length; + const decoded = decodedMappings(map); + const { resolvedSources, sourcesContent: contents, ignoreList: ignores } = map; + + append(sources, resolvedSources); + append(names, map.names); + + if (contents) append(sourcesContent, contents); + else for (let i = 0; i < resolvedSources.length; i++) sourcesContent.push(null); + + if (ignores) for (let i = 0; i < ignores.length; i++) ignoreList.push(ignores[i] + sourcesOffset); + + for (let i = 0; i < decoded.length; i++) { + const lineI = lineOffset + i; + + // We can only add so many lines before we step into the range that the next section's map + // controls. When we get to the last line, then we'll start checking the segments to see if + // they've crossed into the column range. But it may not have any columns that overstep, so we + // still need to check that we don't overstep lines, too. + if (lineI > stopLine) return; + + // The out line may already exist in mappings (if we're continuing the line started by a + // previous section). Or, we may have jumped ahead several lines to start this section. + const out = getLine(mappings, lineI); + // On the 0th loop, the section's column offset shifts us forward. On all other lines (since the + // map can be multiple lines), it doesn't. + const cOffset = i === 0 ? columnOffset : 0; + + const line = decoded[i]; + for (let j = 0; j < line.length; j++) { + const seg = line[j]; + const column = cOffset + seg[COLUMN]; + + // If this segment steps into the column range that the next section's map controls, we need + // to stop early. + if (lineI === stopLine && column >= stopColumn) return; + + if (seg.length === 1) { + out.push([column]); + continue; + } + + const sourcesIndex = sourcesOffset + seg[SOURCES_INDEX]; + const sourceLine = seg[SOURCE_LINE]; + const sourceColumn = seg[SOURCE_COLUMN]; + out.push( + seg.length === 4 + ? [column, sourcesIndex, sourceLine, sourceColumn] + : [column, sourcesIndex, sourceLine, sourceColumn, namesOffset + seg[NAMES_INDEX]], + ); + } + } +} + +function append(arr: T[], other: T[]) { + for (let i = 0; i < other.length; i++) arr.push(other[i]); +} + +function getLine(arr: T[][], index: number): T[] { + for (let i = arr.length; i <= index; i++) arr[i] = []; + return arr[index]; +} diff --git a/node_modules/@jridgewell/trace-mapping/src/resolve.ts b/node_modules/@jridgewell/trace-mapping/src/resolve.ts new file mode 100644 index 0000000000000000000000000000000000000000..30bfa3b226f8990dc650a372d0fa8300b9521a56 --- /dev/null +++ b/node_modules/@jridgewell/trace-mapping/src/resolve.ts @@ -0,0 +1,16 @@ +import resolveUri from '@jridgewell/resolve-uri'; +import stripFilename from './strip-filename'; + +type Resolve = (source: string | null) => string; +export default function resolver( + mapUrl: string | null | undefined, + sourceRoot: string | undefined, +): Resolve { + const from = stripFilename(mapUrl); + // The sourceRoot is always treated as a directory, if it's not empty. + // https://github.com/mozilla/source-map/blob/8cb3ee57/lib/util.js#L327 + // https://github.com/chromium/chromium/blob/da4adbb3/third_party/blink/renderer/devtools/front_end/sdk/SourceMap.js#L400-L401 + const prefix = sourceRoot ? sourceRoot + '/' : ''; + + return (source) => resolveUri(prefix + (source || ''), from); +} diff --git a/node_modules/@jridgewell/trace-mapping/src/sort.ts b/node_modules/@jridgewell/trace-mapping/src/sort.ts new file mode 100644 index 0000000000000000000000000000000000000000..5d016cb78cfca482b736ec06d25f334d2ab849ff --- /dev/null +++ b/node_modules/@jridgewell/trace-mapping/src/sort.ts @@ -0,0 +1,45 @@ +import { COLUMN } from './sourcemap-segment'; + +import type { ReverseSegment, SourceMapSegment } from './sourcemap-segment'; + +export default function maybeSort( + mappings: SourceMapSegment[][], + owned: boolean, +): SourceMapSegment[][] { + const unsortedIndex = nextUnsortedSegmentLine(mappings, 0); + if (unsortedIndex === mappings.length) return mappings; + + // If we own the array (meaning we parsed it from JSON), then we're free to directly mutate it. If + // not, we do not want to modify the consumer's input array. + if (!owned) mappings = mappings.slice(); + + for (let i = unsortedIndex; i < mappings.length; i = nextUnsortedSegmentLine(mappings, i + 1)) { + mappings[i] = sortSegments(mappings[i], owned); + } + return mappings; +} + +function nextUnsortedSegmentLine(mappings: SourceMapSegment[][], start: number): number { + for (let i = start; i < mappings.length; i++) { + if (!isSorted(mappings[i])) return i; + } + return mappings.length; +} + +function isSorted(line: SourceMapSegment[]): boolean { + for (let j = 1; j < line.length; j++) { + if (line[j][COLUMN] < line[j - 1][COLUMN]) { + return false; + } + } + return true; +} + +function sortSegments(line: SourceMapSegment[], owned: boolean): SourceMapSegment[] { + if (!owned) line = line.slice(); + return line.sort(sortComparator); +} + +export function sortComparator(a: T, b: T): number { + return a[COLUMN] - b[COLUMN]; +} diff --git a/node_modules/@jridgewell/trace-mapping/src/sourcemap-segment.ts b/node_modules/@jridgewell/trace-mapping/src/sourcemap-segment.ts new file mode 100644 index 0000000000000000000000000000000000000000..94f1b6ab0d675ecdf00cd0416bcb228cba1ba604 --- /dev/null +++ b/node_modules/@jridgewell/trace-mapping/src/sourcemap-segment.ts @@ -0,0 +1,23 @@ +type GeneratedColumn = number; +type SourcesIndex = number; +type SourceLine = number; +type SourceColumn = number; +type NamesIndex = number; + +type GeneratedLine = number; + +export type SourceMapSegment = + | [GeneratedColumn] + | [GeneratedColumn, SourcesIndex, SourceLine, SourceColumn] + | [GeneratedColumn, SourcesIndex, SourceLine, SourceColumn, NamesIndex]; + +export type ReverseSegment = [SourceColumn, GeneratedLine, GeneratedColumn]; + +export const COLUMN = 0; +export const SOURCES_INDEX = 1; +export const SOURCE_LINE = 2; +export const SOURCE_COLUMN = 3; +export const NAMES_INDEX = 4; + +export const REV_GENERATED_LINE = 1; +export const REV_GENERATED_COLUMN = 2; diff --git a/node_modules/@jridgewell/trace-mapping/src/strip-filename.ts b/node_modules/@jridgewell/trace-mapping/src/strip-filename.ts new file mode 100644 index 0000000000000000000000000000000000000000..2c889800e196e1728b8f4e6c50dd686b5f874376 --- /dev/null +++ b/node_modules/@jridgewell/trace-mapping/src/strip-filename.ts @@ -0,0 +1,8 @@ +/** + * Removes everything after the last "/", but leaves the slash. + */ +export default function stripFilename(path: string | undefined | null): string { + if (!path) return ''; + const index = path.lastIndexOf('/'); + return path.slice(0, index + 1); +} diff --git a/node_modules/@jridgewell/trace-mapping/src/trace-mapping.ts b/node_modules/@jridgewell/trace-mapping/src/trace-mapping.ts new file mode 100644 index 0000000000000000000000000000000000000000..0b793d5bb342398516285157e8ed5bc09aef306d --- /dev/null +++ b/node_modules/@jridgewell/trace-mapping/src/trace-mapping.ts @@ -0,0 +1,502 @@ +import { encode, decode } from '@jridgewell/sourcemap-codec'; + +import resolver from './resolve'; +import maybeSort from './sort'; +import buildBySources from './by-source'; +import { + memoizedState, + memoizedBinarySearch, + upperBound, + lowerBound, + found as bsFound, +} from './binary-search'; +import { + COLUMN, + SOURCES_INDEX, + SOURCE_LINE, + SOURCE_COLUMN, + NAMES_INDEX, + REV_GENERATED_LINE, + REV_GENERATED_COLUMN, +} from './sourcemap-segment'; +import { parse } from './types'; + +import type { SourceMapSegment, ReverseSegment } from './sourcemap-segment'; +import type { + SourceMapV3, + DecodedSourceMap, + EncodedSourceMap, + InvalidOriginalMapping, + OriginalMapping, + InvalidGeneratedMapping, + GeneratedMapping, + SourceMapInput, + Needle, + SourceNeedle, + SourceMap, + EachMapping, + Bias, + XInput, + SectionedSourceMap, + Ro, +} from './types'; +import type { Source } from './by-source'; +import type { MemoState } from './binary-search'; + +export type { SourceMapSegment } from './sourcemap-segment'; +export type { + SourceMap, + DecodedSourceMap, + EncodedSourceMap, + Section, + SectionedSourceMap, + SourceMapV3, + Bias, + EachMapping, + GeneratedMapping, + InvalidGeneratedMapping, + InvalidOriginalMapping, + Needle, + OriginalMapping, + OriginalMapping as Mapping, + SectionedSourceMapInput, + SourceMapInput, + SourceNeedle, + XInput, + EncodedSourceMapXInput, + DecodedSourceMapXInput, + SectionedSourceMapXInput, + SectionXInput, +} from './types'; + +interface PublicMap { + _encoded: TraceMap['_encoded']; + _decoded: TraceMap['_decoded']; + _decodedMemo: TraceMap['_decodedMemo']; + _bySources: TraceMap['_bySources']; + _bySourceMemos: TraceMap['_bySourceMemos']; +} + +const LINE_GTR_ZERO = '`line` must be greater than 0 (lines start at line 1)'; +const COL_GTR_EQ_ZERO = '`column` must be greater than or equal to 0 (columns start at column 0)'; + +export const LEAST_UPPER_BOUND = -1; +export const GREATEST_LOWER_BOUND = 1; + +export { FlattenMap, FlattenMap as AnyMap } from './flatten-map'; + +export class TraceMap implements SourceMap { + declare version: SourceMapV3['version']; + declare file: SourceMapV3['file']; + declare names: SourceMapV3['names']; + declare sourceRoot: SourceMapV3['sourceRoot']; + declare sources: SourceMapV3['sources']; + declare sourcesContent: SourceMapV3['sourcesContent']; + declare ignoreList: SourceMapV3['ignoreList']; + + declare resolvedSources: string[]; + declare private _encoded: string | undefined; + + declare private _decoded: SourceMapSegment[][] | undefined; + declare private _decodedMemo: MemoState; + + declare private _bySources: Source[] | undefined; + declare private _bySourceMemos: MemoState[] | undefined; + + constructor(map: Ro, mapUrl?: string | null) { + const isString = typeof map === 'string'; + if (!isString && (map as unknown as { _decodedMemo: any })._decodedMemo) return map as TraceMap; + + const parsed = parse(map as Exclude); + + const { version, file, names, sourceRoot, sources, sourcesContent } = parsed; + this.version = version; + this.file = file; + this.names = names || []; + this.sourceRoot = sourceRoot; + this.sources = sources; + this.sourcesContent = sourcesContent; + this.ignoreList = parsed.ignoreList || (parsed as XInput).x_google_ignoreList || undefined; + + const resolve = resolver(mapUrl, sourceRoot); + this.resolvedSources = sources.map(resolve); + + const { mappings } = parsed; + if (typeof mappings === 'string') { + this._encoded = mappings; + this._decoded = undefined; + } else if (Array.isArray(mappings)) { + this._encoded = undefined; + this._decoded = maybeSort(mappings, isString); + } else if ((parsed as unknown as SectionedSourceMap).sections) { + throw new Error(`TraceMap passed sectioned source map, please use FlattenMap export instead`); + } else { + throw new Error(`invalid source map: ${JSON.stringify(parsed)}`); + } + + this._decodedMemo = memoizedState(); + this._bySources = undefined; + this._bySourceMemos = undefined; + } +} + +/** + * Typescript doesn't allow friend access to private fields, so this just casts the map into a type + * with public access modifiers. + */ +function cast(map: unknown): PublicMap { + return map as any; +} + +/** + * Returns the encoded (VLQ string) form of the SourceMap's mappings field. + */ +export function encodedMappings(map: TraceMap): EncodedSourceMap['mappings'] { + return (cast(map)._encoded ??= encode(cast(map)._decoded!)); +} + +/** + * Returns the decoded (array of lines of segments) form of the SourceMap's mappings field. + */ +export function decodedMappings(map: TraceMap): Readonly { + return (cast(map)._decoded ||= decode(cast(map)._encoded!)); +} + +/** + * A low-level API to find the segment associated with a generated line/column (think, from a + * stack trace). Line and column here are 0-based, unlike `originalPositionFor`. + */ +export function traceSegment( + map: TraceMap, + line: number, + column: number, +): Readonly | null { + const decoded = decodedMappings(map); + + // It's common for parent source maps to have pointers to lines that have no + // mapping (like a "//# sourceMappingURL=") at the end of the child file. + if (line >= decoded.length) return null; + + const segments = decoded[line]; + const index = traceSegmentInternal( + segments, + cast(map)._decodedMemo, + line, + column, + GREATEST_LOWER_BOUND, + ); + + return index === -1 ? null : segments[index]; +} + +/** + * A higher-level API to find the source/line/column associated with a generated line/column + * (think, from a stack trace). Line is 1-based, but column is 0-based, due to legacy behavior in + * `source-map` library. + */ +export function originalPositionFor( + map: TraceMap, + needle: Needle, +): OriginalMapping | InvalidOriginalMapping { + let { line, column, bias } = needle; + line--; + if (line < 0) throw new Error(LINE_GTR_ZERO); + if (column < 0) throw new Error(COL_GTR_EQ_ZERO); + + const decoded = decodedMappings(map); + + // It's common for parent source maps to have pointers to lines that have no + // mapping (like a "//# sourceMappingURL=") at the end of the child file. + if (line >= decoded.length) return OMapping(null, null, null, null); + + const segments = decoded[line]; + const index = traceSegmentInternal( + segments, + cast(map)._decodedMemo, + line, + column, + bias || GREATEST_LOWER_BOUND, + ); + + if (index === -1) return OMapping(null, null, null, null); + + const segment = segments[index]; + if (segment.length === 1) return OMapping(null, null, null, null); + + const { names, resolvedSources } = map; + return OMapping( + resolvedSources[segment[SOURCES_INDEX]], + segment[SOURCE_LINE] + 1, + segment[SOURCE_COLUMN], + segment.length === 5 ? names[segment[NAMES_INDEX]] : null, + ); +} + +/** + * Finds the generated line/column position of the provided source/line/column source position. + */ +export function generatedPositionFor( + map: TraceMap, + needle: SourceNeedle, +): GeneratedMapping | InvalidGeneratedMapping { + const { source, line, column, bias } = needle; + return generatedPosition(map, source, line, column, bias || GREATEST_LOWER_BOUND, false); +} + +/** + * Finds all generated line/column positions of the provided source/line/column source position. + */ +export function allGeneratedPositionsFor(map: TraceMap, needle: SourceNeedle): GeneratedMapping[] { + const { source, line, column, bias } = needle; + // SourceMapConsumer uses LEAST_UPPER_BOUND for some reason, so we follow suit. + return generatedPosition(map, source, line, column, bias || LEAST_UPPER_BOUND, true); +} + +/** + * Iterates each mapping in generated position order. + */ +export function eachMapping(map: TraceMap, cb: (mapping: EachMapping) => void): void { + const decoded = decodedMappings(map); + const { names, resolvedSources } = map; + + for (let i = 0; i < decoded.length; i++) { + const line = decoded[i]; + for (let j = 0; j < line.length; j++) { + const seg = line[j]; + + const generatedLine = i + 1; + const generatedColumn = seg[0]; + let source = null; + let originalLine = null; + let originalColumn = null; + let name = null; + if (seg.length !== 1) { + source = resolvedSources[seg[1]]; + originalLine = seg[2] + 1; + originalColumn = seg[3]; + } + if (seg.length === 5) name = names[seg[4]]; + + cb({ + generatedLine, + generatedColumn, + source, + originalLine, + originalColumn, + name, + } as EachMapping); + } + } +} + +function sourceIndex(map: TraceMap, source: string): number { + const { sources, resolvedSources } = map; + let index = sources.indexOf(source); + if (index === -1) index = resolvedSources.indexOf(source); + return index; +} + +/** + * Retrieves the source content for a particular source, if its found. Returns null if not. + */ +export function sourceContentFor(map: TraceMap, source: string): string | null { + const { sourcesContent } = map; + if (sourcesContent == null) return null; + const index = sourceIndex(map, source); + return index === -1 ? null : sourcesContent[index]; +} + +/** + * Determines if the source is marked to ignore by the source map. + */ +export function isIgnored(map: TraceMap, source: string): boolean { + const { ignoreList } = map; + if (ignoreList == null) return false; + const index = sourceIndex(map, source); + return index === -1 ? false : ignoreList.includes(index); +} + +/** + * A helper that skips sorting of the input map's mappings array, which can be expensive for larger + * maps. + */ +export function presortedDecodedMap(map: DecodedSourceMap, mapUrl?: string): TraceMap { + const tracer = new TraceMap(clone(map, []), mapUrl); + cast(tracer)._decoded = map.mappings; + return tracer; +} + +/** + * Returns a sourcemap object (with decoded mappings) suitable for passing to a library that expects + * a sourcemap, or to JSON.stringify. + */ +export function decodedMap( + map: TraceMap, +): Omit & { mappings: readonly SourceMapSegment[][] } { + return clone(map, decodedMappings(map)); +} + +/** + * Returns a sourcemap object (with encoded mappings) suitable for passing to a library that expects + * a sourcemap, or to JSON.stringify. + */ +export function encodedMap(map: TraceMap): EncodedSourceMap { + return clone(map, encodedMappings(map)); +} + +function clone( + map: TraceMap | DecodedSourceMap, + mappings: T, +): T extends string ? EncodedSourceMap : DecodedSourceMap { + return { + version: map.version, + file: map.file, + names: map.names, + sourceRoot: map.sourceRoot, + sources: map.sources, + sourcesContent: map.sourcesContent, + mappings, + ignoreList: map.ignoreList || (map as XInput).x_google_ignoreList, + } as any; +} + +function OMapping(source: null, line: null, column: null, name: null): InvalidOriginalMapping; +function OMapping( + source: string, + line: number, + column: number, + name: string | null, +): OriginalMapping; +function OMapping( + source: string | null, + line: number | null, + column: number | null, + name: string | null, +): OriginalMapping | InvalidOriginalMapping { + return { source, line, column, name } as any; +} + +function GMapping(line: null, column: null): InvalidGeneratedMapping; +function GMapping(line: number, column: number): GeneratedMapping; +function GMapping( + line: number | null, + column: number | null, +): GeneratedMapping | InvalidGeneratedMapping { + return { line, column } as any; +} + +function traceSegmentInternal( + segments: SourceMapSegment[], + memo: MemoState, + line: number, + column: number, + bias: Bias, +): number; +function traceSegmentInternal( + segments: ReverseSegment[], + memo: MemoState, + line: number, + column: number, + bias: Bias, +): number; +function traceSegmentInternal( + segments: SourceMapSegment[] | ReverseSegment[], + memo: MemoState, + line: number, + column: number, + bias: Bias, +): number { + let index = memoizedBinarySearch(segments, column, memo, line); + if (bsFound) { + index = (bias === LEAST_UPPER_BOUND ? upperBound : lowerBound)(segments, column, index); + } else if (bias === LEAST_UPPER_BOUND) index++; + + if (index === -1 || index === segments.length) return -1; + return index; +} + +function sliceGeneratedPositions( + segments: ReverseSegment[], + memo: MemoState, + line: number, + column: number, + bias: Bias, +): GeneratedMapping[] { + let min = traceSegmentInternal(segments, memo, line, column, GREATEST_LOWER_BOUND); + + // We ignored the bias when tracing the segment so that we're guarnateed to find the first (in + // insertion order) segment that matched. Even if we did respect the bias when tracing, we would + // still need to call `lowerBound()` to find the first segment, which is slower than just looking + // for the GREATEST_LOWER_BOUND to begin with. The only difference that matters for us is when the + // binary search didn't match, in which case GREATEST_LOWER_BOUND just needs to increment to + // match LEAST_UPPER_BOUND. + if (!bsFound && bias === LEAST_UPPER_BOUND) min++; + + if (min === -1 || min === segments.length) return []; + + // We may have found the segment that started at an earlier column. If this is the case, then we + // need to slice all generated segments that match _that_ column, because all such segments span + // to our desired column. + const matchedColumn = bsFound ? column : segments[min][COLUMN]; + + // The binary search is not guaranteed to find the lower bound when a match wasn't found. + if (!bsFound) min = lowerBound(segments, matchedColumn, min); + const max = upperBound(segments, matchedColumn, min); + + const result = []; + for (; min <= max; min++) { + const segment = segments[min]; + result.push(GMapping(segment[REV_GENERATED_LINE] + 1, segment[REV_GENERATED_COLUMN])); + } + return result; +} + +function generatedPosition( + map: TraceMap, + source: string, + line: number, + column: number, + bias: Bias, + all: false, +): GeneratedMapping | InvalidGeneratedMapping; +function generatedPosition( + map: TraceMap, + source: string, + line: number, + column: number, + bias: Bias, + all: true, +): GeneratedMapping[]; +function generatedPosition( + map: TraceMap, + source: string, + line: number, + column: number, + bias: Bias, + all: boolean, +): GeneratedMapping | InvalidGeneratedMapping | GeneratedMapping[] { + line--; + if (line < 0) throw new Error(LINE_GTR_ZERO); + if (column < 0) throw new Error(COL_GTR_EQ_ZERO); + + const { sources, resolvedSources } = map; + let sourceIndex = sources.indexOf(source); + if (sourceIndex === -1) sourceIndex = resolvedSources.indexOf(source); + if (sourceIndex === -1) return all ? [] : GMapping(null, null); + + const bySourceMemos = (cast(map)._bySourceMemos ||= sources.map(memoizedState)); + const generated = (cast(map)._bySources ||= buildBySources(decodedMappings(map), bySourceMemos)); + + const segments = generated[sourceIndex][line]; + if (segments == null) return all ? [] : GMapping(null, null); + + const memo = bySourceMemos[sourceIndex]; + + if (all) return sliceGeneratedPositions(segments, memo, line, column, bias); + + const index = traceSegmentInternal(segments, memo, line, column, bias); + if (index === -1) return GMapping(null, null); + + const segment = segments[index]; + return GMapping(segment[REV_GENERATED_LINE] + 1, segment[REV_GENERATED_COLUMN]); +} diff --git a/node_modules/@jridgewell/trace-mapping/src/types.ts b/node_modules/@jridgewell/trace-mapping/src/types.ts new file mode 100644 index 0000000000000000000000000000000000000000..730a61fb5ca1e2a389b6bff8dc773828a0372421 --- /dev/null +++ b/node_modules/@jridgewell/trace-mapping/src/types.ts @@ -0,0 +1,114 @@ +import type { SourceMapSegment } from './sourcemap-segment'; +import type { GREATEST_LOWER_BOUND, LEAST_UPPER_BOUND, TraceMap } from './trace-mapping'; + +export interface SourceMapV3 { + file?: string | null; + names: string[]; + sourceRoot?: string; + sources: (string | null)[]; + sourcesContent?: (string | null)[]; + version: 3; + ignoreList?: number[]; +} + +export interface EncodedSourceMap extends SourceMapV3 { + mappings: string; +} + +export interface DecodedSourceMap extends SourceMapV3 { + mappings: SourceMapSegment[][]; +} + +export interface Section { + offset: { line: number; column: number }; + map: EncodedSourceMap | DecodedSourceMap | SectionedSourceMap; +} + +export interface SectionedSourceMap { + file?: string | null; + sections: Section[]; + version: 3; +} + +export type OriginalMapping = { + source: string | null; + line: number; + column: number; + name: string | null; +}; + +export type InvalidOriginalMapping = { + source: null; + line: null; + column: null; + name: null; +}; + +export type GeneratedMapping = { + line: number; + column: number; +}; +export type InvalidGeneratedMapping = { + line: null; + column: null; +}; + +export type Bias = typeof GREATEST_LOWER_BOUND | typeof LEAST_UPPER_BOUND; + +export type XInput = { x_google_ignoreList?: SourceMapV3['ignoreList'] }; +export type EncodedSourceMapXInput = EncodedSourceMap & XInput; +export type DecodedSourceMapXInput = DecodedSourceMap & XInput; +export type SectionedSourceMapXInput = Omit & { + sections: SectionXInput[]; +}; +export type SectionXInput = Omit & { + map: SectionedSourceMapInput; +}; + +export type SourceMapInput = string | EncodedSourceMapXInput | DecodedSourceMapXInput | TraceMap; +export type SectionedSourceMapInput = SourceMapInput | SectionedSourceMapXInput; + +export type Needle = { line: number; column: number; bias?: Bias }; +export type SourceNeedle = { source: string; line: number; column: number; bias?: Bias }; + +export type EachMapping = + | { + generatedLine: number; + generatedColumn: number; + source: null; + originalLine: null; + originalColumn: null; + name: null; + } + | { + generatedLine: number; + generatedColumn: number; + source: string | null; + originalLine: number; + originalColumn: number; + name: string | null; + }; + +export abstract class SourceMap { + declare version: SourceMapV3['version']; + declare file: SourceMapV3['file']; + declare names: SourceMapV3['names']; + declare sourceRoot: SourceMapV3['sourceRoot']; + declare sources: SourceMapV3['sources']; + declare sourcesContent: SourceMapV3['sourcesContent']; + declare resolvedSources: SourceMapV3['sources']; + declare ignoreList: SourceMapV3['ignoreList']; +} + +export type Ro = + T extends Array + ? V[] | Readonly | RoArray | Readonly> + : T extends object + ? T | Readonly | RoObject | Readonly> + : T; +type RoArray = Ro[]; +type RoObject = { [K in keyof T]: T[K] | Ro }; + +export function parse(map: T): Exclude { + return typeof map === 'string' ? JSON.parse(map) : (map as Exclude); +} diff --git a/node_modules/@jridgewell/trace-mapping/types/binary-search.d.cts b/node_modules/@jridgewell/trace-mapping/types/binary-search.d.cts new file mode 100644 index 0000000000000000000000000000000000000000..b7bb85c913b38b846273813e77c3c9aecbcaa3cd --- /dev/null +++ b/node_modules/@jridgewell/trace-mapping/types/binary-search.d.cts @@ -0,0 +1,33 @@ +import type { SourceMapSegment, ReverseSegment } from './sourcemap-segment.cts'; +export type MemoState = { + lastKey: number; + lastNeedle: number; + lastIndex: number; +}; +export declare let found: boolean; +/** + * A binary search implementation that returns the index if a match is found. + * If no match is found, then the left-index (the index associated with the item that comes just + * before the desired index) is returned. To maintain proper sort order, a splice would happen at + * the next index: + * + * ```js + * const array = [1, 3]; + * const needle = 2; + * const index = binarySearch(array, needle, (item, needle) => item - needle); + * + * assert.equal(index, 0); + * array.splice(index + 1, 0, needle); + * assert.deepEqual(array, [1, 2, 3]); + * ``` + */ +export declare function binarySearch(haystack: SourceMapSegment[] | ReverseSegment[], needle: number, low: number, high: number): number; +export declare function upperBound(haystack: SourceMapSegment[] | ReverseSegment[], needle: number, index: number): number; +export declare function lowerBound(haystack: SourceMapSegment[] | ReverseSegment[], needle: number, index: number): number; +export declare function memoizedState(): MemoState; +/** + * This overly complicated beast is just to record the last tested line/column and the resulting + * index, allowing us to skip a few tests if mappings are monotonically increasing. + */ +export declare function memoizedBinarySearch(haystack: SourceMapSegment[] | ReverseSegment[], needle: number, state: MemoState, key: number): number; +//# sourceMappingURL=binary-search.d.ts.map \ No newline at end of file diff --git a/node_modules/@jridgewell/trace-mapping/types/binary-search.d.cts.map b/node_modules/@jridgewell/trace-mapping/types/binary-search.d.cts.map new file mode 100644 index 0000000000000000000000000000000000000000..648e84c1e7a5c587e300fe348389c500fa2af2c6 --- /dev/null +++ b/node_modules/@jridgewell/trace-mapping/types/binary-search.d.cts.map @@ -0,0 +1 @@ +{"version":3,"file":"binary-search.d.ts","sourceRoot":"","sources":["../src/binary-search.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAG5E,MAAM,MAAM,SAAS,GAAG;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,eAAO,IAAI,KAAK,SAAQ,CAAC;AAEzB;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,YAAY,CAC1B,QAAQ,EAAE,gBAAgB,EAAE,GAAG,cAAc,EAAE,EAC/C,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,MAAM,GACX,MAAM,CAmBR;AAED,wBAAgB,UAAU,CACxB,QAAQ,EAAE,gBAAgB,EAAE,GAAG,cAAc,EAAE,EAC/C,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,GACZ,MAAM,CAKR;AAED,wBAAgB,UAAU,CACxB,QAAQ,EAAE,gBAAgB,EAAE,GAAG,cAAc,EAAE,EAC/C,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,GACZ,MAAM,CAKR;AAED,wBAAgB,aAAa,IAAI,SAAS,CAMzC;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAClC,QAAQ,EAAE,gBAAgB,EAAE,GAAG,cAAc,EAAE,EAC/C,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,SAAS,EAChB,GAAG,EAAE,MAAM,GACV,MAAM,CAsBR"} \ No newline at end of file diff --git a/node_modules/@jridgewell/trace-mapping/types/binary-search.d.mts b/node_modules/@jridgewell/trace-mapping/types/binary-search.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..19e1e6b9eb4e26e90df2e4bc21d1e27ae149d132 --- /dev/null +++ b/node_modules/@jridgewell/trace-mapping/types/binary-search.d.mts @@ -0,0 +1,33 @@ +import type { SourceMapSegment, ReverseSegment } from './sourcemap-segment.mts'; +export type MemoState = { + lastKey: number; + lastNeedle: number; + lastIndex: number; +}; +export declare let found: boolean; +/** + * A binary search implementation that returns the index if a match is found. + * If no match is found, then the left-index (the index associated with the item that comes just + * before the desired index) is returned. To maintain proper sort order, a splice would happen at + * the next index: + * + * ```js + * const array = [1, 3]; + * const needle = 2; + * const index = binarySearch(array, needle, (item, needle) => item - needle); + * + * assert.equal(index, 0); + * array.splice(index + 1, 0, needle); + * assert.deepEqual(array, [1, 2, 3]); + * ``` + */ +export declare function binarySearch(haystack: SourceMapSegment[] | ReverseSegment[], needle: number, low: number, high: number): number; +export declare function upperBound(haystack: SourceMapSegment[] | ReverseSegment[], needle: number, index: number): number; +export declare function lowerBound(haystack: SourceMapSegment[] | ReverseSegment[], needle: number, index: number): number; +export declare function memoizedState(): MemoState; +/** + * This overly complicated beast is just to record the last tested line/column and the resulting + * index, allowing us to skip a few tests if mappings are monotonically increasing. + */ +export declare function memoizedBinarySearch(haystack: SourceMapSegment[] | ReverseSegment[], needle: number, state: MemoState, key: number): number; +//# sourceMappingURL=binary-search.d.ts.map \ No newline at end of file diff --git a/node_modules/@jridgewell/trace-mapping/types/binary-search.d.mts.map b/node_modules/@jridgewell/trace-mapping/types/binary-search.d.mts.map new file mode 100644 index 0000000000000000000000000000000000000000..648e84c1e7a5c587e300fe348389c500fa2af2c6 --- /dev/null +++ b/node_modules/@jridgewell/trace-mapping/types/binary-search.d.mts.map @@ -0,0 +1 @@ +{"version":3,"file":"binary-search.d.ts","sourceRoot":"","sources":["../src/binary-search.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAG5E,MAAM,MAAM,SAAS,GAAG;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,eAAO,IAAI,KAAK,SAAQ,CAAC;AAEzB;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,YAAY,CAC1B,QAAQ,EAAE,gBAAgB,EAAE,GAAG,cAAc,EAAE,EAC/C,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,MAAM,GACX,MAAM,CAmBR;AAED,wBAAgB,UAAU,CACxB,QAAQ,EAAE,gBAAgB,EAAE,GAAG,cAAc,EAAE,EAC/C,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,GACZ,MAAM,CAKR;AAED,wBAAgB,UAAU,CACxB,QAAQ,EAAE,gBAAgB,EAAE,GAAG,cAAc,EAAE,EAC/C,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,GACZ,MAAM,CAKR;AAED,wBAAgB,aAAa,IAAI,SAAS,CAMzC;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAClC,QAAQ,EAAE,gBAAgB,EAAE,GAAG,cAAc,EAAE,EAC/C,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,SAAS,EAChB,GAAG,EAAE,MAAM,GACV,MAAM,CAsBR"} \ No newline at end of file diff --git a/node_modules/@jridgewell/trace-mapping/types/by-source.d.cts b/node_modules/@jridgewell/trace-mapping/types/by-source.d.cts new file mode 100644 index 0000000000000000000000000000000000000000..da496939c7c9d357a14710fcf16254e54e129c17 --- /dev/null +++ b/node_modules/@jridgewell/trace-mapping/types/by-source.d.cts @@ -0,0 +1,4 @@ +import type { ReverseSegment, SourceMapSegment } from './sourcemap-segment.cts'; +export type Source = ReverseSegment[][]; +export = function buildBySources(decoded: readonly SourceMapSegment[][], memos: unknown[]): Source[]; +//# sourceMappingURL=by-source.d.ts.map \ No newline at end of file diff --git a/node_modules/@jridgewell/trace-mapping/types/by-source.d.cts.map b/node_modules/@jridgewell/trace-mapping/types/by-source.d.cts.map new file mode 100644 index 0000000000000000000000000000000000000000..32d2a7a1a941010c0b0315b458ba23d53d839b35 --- /dev/null +++ b/node_modules/@jridgewell/trace-mapping/types/by-source.d.cts.map @@ -0,0 +1 @@ +{"version":3,"file":"by-source.d.ts","sourceRoot":"","sources":["../src/by-source.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAE5E,MAAM,MAAM,MAAM,GAAG,cAAc,EAAE,EAAE,CAAC;AAIxC,MAAM,CAAC,OAAO,UAAU,cAAc,CACpC,OAAO,EAAE,SAAS,gBAAgB,EAAE,EAAE,EACtC,KAAK,EAAE,OAAO,EAAE,GACf,MAAM,EAAE,CA4BV"} \ No newline at end of file diff --git a/node_modules/@jridgewell/trace-mapping/types/by-source.d.mts b/node_modules/@jridgewell/trace-mapping/types/by-source.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..f36104955fbc695200a077cb96bc6019ec73c7c0 --- /dev/null +++ b/node_modules/@jridgewell/trace-mapping/types/by-source.d.mts @@ -0,0 +1,4 @@ +import type { ReverseSegment, SourceMapSegment } from './sourcemap-segment.mts'; +export type Source = ReverseSegment[][]; +export default function buildBySources(decoded: readonly SourceMapSegment[][], memos: unknown[]): Source[]; +//# sourceMappingURL=by-source.d.ts.map \ No newline at end of file diff --git a/node_modules/@jridgewell/trace-mapping/types/by-source.d.mts.map b/node_modules/@jridgewell/trace-mapping/types/by-source.d.mts.map new file mode 100644 index 0000000000000000000000000000000000000000..32d2a7a1a941010c0b0315b458ba23d53d839b35 --- /dev/null +++ b/node_modules/@jridgewell/trace-mapping/types/by-source.d.mts.map @@ -0,0 +1 @@ +{"version":3,"file":"by-source.d.ts","sourceRoot":"","sources":["../src/by-source.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAE5E,MAAM,MAAM,MAAM,GAAG,cAAc,EAAE,EAAE,CAAC;AAIxC,MAAM,CAAC,OAAO,UAAU,cAAc,CACpC,OAAO,EAAE,SAAS,gBAAgB,EAAE,EAAE,EACtC,KAAK,EAAE,OAAO,EAAE,GACf,MAAM,EAAE,CA4BV"} \ No newline at end of file diff --git a/node_modules/@jridgewell/trace-mapping/types/flatten-map.d.cts b/node_modules/@jridgewell/trace-mapping/types/flatten-map.d.cts new file mode 100644 index 0000000000000000000000000000000000000000..433d849b7c4a8cec8c2dc50013b26b2ebd5f61ad --- /dev/null +++ b/node_modules/@jridgewell/trace-mapping/types/flatten-map.d.cts @@ -0,0 +1,9 @@ +import { TraceMap } from './trace-mapping.cts'; +import type { SectionedSourceMapInput, Ro } from './types.cts'; +type FlattenMap = { + new (map: Ro, mapUrl?: string | null): TraceMap; + (map: Ro, mapUrl?: string | null): TraceMap; +}; +export declare const FlattenMap: FlattenMap; +export {}; +//# sourceMappingURL=flatten-map.d.ts.map \ No newline at end of file diff --git a/node_modules/@jridgewell/trace-mapping/types/flatten-map.d.cts.map b/node_modules/@jridgewell/trace-mapping/types/flatten-map.d.cts.map new file mode 100644 index 0000000000000000000000000000000000000000..994b208adfdb40a78e7b788b3bb039ca5da41031 --- /dev/null +++ b/node_modules/@jridgewell/trace-mapping/types/flatten-map.d.cts.map @@ -0,0 +1 @@ +{"version":3,"file":"flatten-map.d.ts","sourceRoot":"","sources":["../src/flatten-map.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAwC,MAAM,iBAAiB,CAAC;AAUjF,OAAO,KAAK,EAKV,uBAAuB,EAEvB,EAAE,EACH,MAAM,SAAS,CAAC;AAGjB,KAAK,UAAU,GAAG;IAChB,KAAK,GAAG,EAAE,EAAE,CAAC,uBAAuB,CAAC,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,QAAQ,CAAC;IACzE,CAAC,GAAG,EAAE,EAAE,CAAC,uBAAuB,CAAC,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,QAAQ,CAAC;CACtE,CAAC;AAEF,eAAO,MAAM,UAAU,EAAE,UAsCV,CAAC"} \ No newline at end of file diff --git a/node_modules/@jridgewell/trace-mapping/types/flatten-map.d.mts b/node_modules/@jridgewell/trace-mapping/types/flatten-map.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..444a1bed55f5210de610d9dd8360ce9c8db37f10 --- /dev/null +++ b/node_modules/@jridgewell/trace-mapping/types/flatten-map.d.mts @@ -0,0 +1,9 @@ +import { TraceMap } from './trace-mapping.mts'; +import type { SectionedSourceMapInput, Ro } from './types.mts'; +type FlattenMap = { + new (map: Ro, mapUrl?: string | null): TraceMap; + (map: Ro, mapUrl?: string | null): TraceMap; +}; +export declare const FlattenMap: FlattenMap; +export {}; +//# sourceMappingURL=flatten-map.d.ts.map \ No newline at end of file diff --git a/node_modules/@jridgewell/trace-mapping/types/flatten-map.d.mts.map b/node_modules/@jridgewell/trace-mapping/types/flatten-map.d.mts.map new file mode 100644 index 0000000000000000000000000000000000000000..994b208adfdb40a78e7b788b3bb039ca5da41031 --- /dev/null +++ b/node_modules/@jridgewell/trace-mapping/types/flatten-map.d.mts.map @@ -0,0 +1 @@ +{"version":3,"file":"flatten-map.d.ts","sourceRoot":"","sources":["../src/flatten-map.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAwC,MAAM,iBAAiB,CAAC;AAUjF,OAAO,KAAK,EAKV,uBAAuB,EAEvB,EAAE,EACH,MAAM,SAAS,CAAC;AAGjB,KAAK,UAAU,GAAG;IAChB,KAAK,GAAG,EAAE,EAAE,CAAC,uBAAuB,CAAC,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,QAAQ,CAAC;IACzE,CAAC,GAAG,EAAE,EAAE,CAAC,uBAAuB,CAAC,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,QAAQ,CAAC;CACtE,CAAC;AAEF,eAAO,MAAM,UAAU,EAAE,UAsCV,CAAC"} \ No newline at end of file diff --git a/node_modules/@jridgewell/trace-mapping/types/resolve.d.cts b/node_modules/@jridgewell/trace-mapping/types/resolve.d.cts new file mode 100644 index 0000000000000000000000000000000000000000..62aeedb5b381de715b75ad8d15553fae994ee079 --- /dev/null +++ b/node_modules/@jridgewell/trace-mapping/types/resolve.d.cts @@ -0,0 +1,4 @@ +type Resolve = (source: string | null) => string; +export = function resolver(mapUrl: string | null | undefined, sourceRoot: string | undefined): Resolve; +export {}; +//# sourceMappingURL=resolve.d.ts.map \ No newline at end of file diff --git a/node_modules/@jridgewell/trace-mapping/types/resolve.d.cts.map b/node_modules/@jridgewell/trace-mapping/types/resolve.d.cts.map new file mode 100644 index 0000000000000000000000000000000000000000..9f155ace7bab5ceb34974af9ea919c4760c4e9a4 --- /dev/null +++ b/node_modules/@jridgewell/trace-mapping/types/resolve.d.cts.map @@ -0,0 +1 @@ +{"version":3,"file":"resolve.d.ts","sourceRoot":"","sources":["../src/resolve.ts"],"names":[],"mappings":"AAGA,KAAK,OAAO,GAAG,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,KAAK,MAAM,CAAC;AACjD,MAAM,CAAC,OAAO,UAAU,QAAQ,CAC9B,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EACjC,UAAU,EAAE,MAAM,GAAG,SAAS,GAC7B,OAAO,CAQT"} \ No newline at end of file diff --git a/node_modules/@jridgewell/trace-mapping/types/resolve.d.mts b/node_modules/@jridgewell/trace-mapping/types/resolve.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..e2798a19ccb20ab2d94ffa7a8bd1bab03303fe69 --- /dev/null +++ b/node_modules/@jridgewell/trace-mapping/types/resolve.d.mts @@ -0,0 +1,4 @@ +type Resolve = (source: string | null) => string; +export default function resolver(mapUrl: string | null | undefined, sourceRoot: string | undefined): Resolve; +export {}; +//# sourceMappingURL=resolve.d.ts.map \ No newline at end of file diff --git a/node_modules/@jridgewell/trace-mapping/types/resolve.d.mts.map b/node_modules/@jridgewell/trace-mapping/types/resolve.d.mts.map new file mode 100644 index 0000000000000000000000000000000000000000..9f155ace7bab5ceb34974af9ea919c4760c4e9a4 --- /dev/null +++ b/node_modules/@jridgewell/trace-mapping/types/resolve.d.mts.map @@ -0,0 +1 @@ +{"version":3,"file":"resolve.d.ts","sourceRoot":"","sources":["../src/resolve.ts"],"names":[],"mappings":"AAGA,KAAK,OAAO,GAAG,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,KAAK,MAAM,CAAC;AACjD,MAAM,CAAC,OAAO,UAAU,QAAQ,CAC9B,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EACjC,UAAU,EAAE,MAAM,GAAG,SAAS,GAC7B,OAAO,CAQT"} \ No newline at end of file diff --git a/node_modules/@jridgewell/trace-mapping/types/sort.d.cts b/node_modules/@jridgewell/trace-mapping/types/sort.d.cts new file mode 100644 index 0000000000000000000000000000000000000000..aa14c129008da878cf9443414951b8a9c2d0799f --- /dev/null +++ b/node_modules/@jridgewell/trace-mapping/types/sort.d.cts @@ -0,0 +1,4 @@ +import type { ReverseSegment, SourceMapSegment } from './sourcemap-segment.cts'; +export = function maybeSort(mappings: SourceMapSegment[][], owned: boolean): SourceMapSegment[][]; +export declare function sortComparator(a: T, b: T): number; +//# sourceMappingURL=sort.d.ts.map \ No newline at end of file diff --git a/node_modules/@jridgewell/trace-mapping/types/sort.d.cts.map b/node_modules/@jridgewell/trace-mapping/types/sort.d.cts.map new file mode 100644 index 0000000000000000000000000000000000000000..48b8e67418d400b7c68921231f0028b2cee0652a --- /dev/null +++ b/node_modules/@jridgewell/trace-mapping/types/sort.d.cts.map @@ -0,0 +1 @@ +{"version":3,"file":"sort.d.ts","sourceRoot":"","sources":["../src/sort.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAE5E,MAAM,CAAC,OAAO,UAAU,SAAS,CAC/B,QAAQ,EAAE,gBAAgB,EAAE,EAAE,EAC9B,KAAK,EAAE,OAAO,GACb,gBAAgB,EAAE,EAAE,CAYtB;AAuBD,wBAAgB,cAAc,CAAC,CAAC,SAAS,gBAAgB,GAAG,cAAc,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,GAAG,MAAM,CAE9F"} \ No newline at end of file diff --git a/node_modules/@jridgewell/trace-mapping/types/sort.d.mts b/node_modules/@jridgewell/trace-mapping/types/sort.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..c5b94e64fd5595680120201212a03e905ebeb4c3 --- /dev/null +++ b/node_modules/@jridgewell/trace-mapping/types/sort.d.mts @@ -0,0 +1,4 @@ +import type { ReverseSegment, SourceMapSegment } from './sourcemap-segment.mts'; +export default function maybeSort(mappings: SourceMapSegment[][], owned: boolean): SourceMapSegment[][]; +export declare function sortComparator(a: T, b: T): number; +//# sourceMappingURL=sort.d.ts.map \ No newline at end of file diff --git a/node_modules/@jridgewell/trace-mapping/types/sort.d.mts.map b/node_modules/@jridgewell/trace-mapping/types/sort.d.mts.map new file mode 100644 index 0000000000000000000000000000000000000000..48b8e67418d400b7c68921231f0028b2cee0652a --- /dev/null +++ b/node_modules/@jridgewell/trace-mapping/types/sort.d.mts.map @@ -0,0 +1 @@ +{"version":3,"file":"sort.d.ts","sourceRoot":"","sources":["../src/sort.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAE5E,MAAM,CAAC,OAAO,UAAU,SAAS,CAC/B,QAAQ,EAAE,gBAAgB,EAAE,EAAE,EAC9B,KAAK,EAAE,OAAO,GACb,gBAAgB,EAAE,EAAE,CAYtB;AAuBD,wBAAgB,cAAc,CAAC,CAAC,SAAS,gBAAgB,GAAG,cAAc,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,GAAG,MAAM,CAE9F"} \ No newline at end of file diff --git a/node_modules/@jridgewell/trace-mapping/types/sourcemap-segment.d.cts b/node_modules/@jridgewell/trace-mapping/types/sourcemap-segment.d.cts new file mode 100644 index 0000000000000000000000000000000000000000..8d3cabc13032461848e6bcef75d702402517991f --- /dev/null +++ b/node_modules/@jridgewell/trace-mapping/types/sourcemap-segment.d.cts @@ -0,0 +1,17 @@ +type GeneratedColumn = number; +type SourcesIndex = number; +type SourceLine = number; +type SourceColumn = number; +type NamesIndex = number; +type GeneratedLine = number; +export type SourceMapSegment = [GeneratedColumn] | [GeneratedColumn, SourcesIndex, SourceLine, SourceColumn] | [GeneratedColumn, SourcesIndex, SourceLine, SourceColumn, NamesIndex]; +export type ReverseSegment = [SourceColumn, GeneratedLine, GeneratedColumn]; +export declare const COLUMN = 0; +export declare const SOURCES_INDEX = 1; +export declare const SOURCE_LINE = 2; +export declare const SOURCE_COLUMN = 3; +export declare const NAMES_INDEX = 4; +export declare const REV_GENERATED_LINE = 1; +export declare const REV_GENERATED_COLUMN = 2; +export {}; +//# sourceMappingURL=sourcemap-segment.d.ts.map \ No newline at end of file diff --git a/node_modules/@jridgewell/trace-mapping/types/sourcemap-segment.d.cts.map b/node_modules/@jridgewell/trace-mapping/types/sourcemap-segment.d.cts.map new file mode 100644 index 0000000000000000000000000000000000000000..0c94a4610db499464df13dfe8456019983053a56 --- /dev/null +++ b/node_modules/@jridgewell/trace-mapping/types/sourcemap-segment.d.cts.map @@ -0,0 +1 @@ +{"version":3,"file":"sourcemap-segment.d.ts","sourceRoot":"","sources":["../src/sourcemap-segment.ts"],"names":[],"mappings":"AAAA,KAAK,eAAe,GAAG,MAAM,CAAC;AAC9B,KAAK,YAAY,GAAG,MAAM,CAAC;AAC3B,KAAK,UAAU,GAAG,MAAM,CAAC;AACzB,KAAK,YAAY,GAAG,MAAM,CAAC;AAC3B,KAAK,UAAU,GAAG,MAAM,CAAC;AAEzB,KAAK,aAAa,GAAG,MAAM,CAAC;AAE5B,MAAM,MAAM,gBAAgB,GACxB,CAAC,eAAe,CAAC,GACjB,CAAC,eAAe,EAAE,YAAY,EAAE,UAAU,EAAE,YAAY,CAAC,GACzD,CAAC,eAAe,EAAE,YAAY,EAAE,UAAU,EAAE,YAAY,EAAE,UAAU,CAAC,CAAC;AAE1E,MAAM,MAAM,cAAc,GAAG,CAAC,YAAY,EAAE,aAAa,EAAE,eAAe,CAAC,CAAC;AAE5E,eAAO,MAAM,MAAM,IAAI,CAAC;AACxB,eAAO,MAAM,aAAa,IAAI,CAAC;AAC/B,eAAO,MAAM,WAAW,IAAI,CAAC;AAC7B,eAAO,MAAM,aAAa,IAAI,CAAC;AAC/B,eAAO,MAAM,WAAW,IAAI,CAAC;AAE7B,eAAO,MAAM,kBAAkB,IAAI,CAAC;AACpC,eAAO,MAAM,oBAAoB,IAAI,CAAC"} \ No newline at end of file diff --git a/node_modules/@jridgewell/trace-mapping/types/sourcemap-segment.d.mts b/node_modules/@jridgewell/trace-mapping/types/sourcemap-segment.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..8d3cabc13032461848e6bcef75d702402517991f --- /dev/null +++ b/node_modules/@jridgewell/trace-mapping/types/sourcemap-segment.d.mts @@ -0,0 +1,17 @@ +type GeneratedColumn = number; +type SourcesIndex = number; +type SourceLine = number; +type SourceColumn = number; +type NamesIndex = number; +type GeneratedLine = number; +export type SourceMapSegment = [GeneratedColumn] | [GeneratedColumn, SourcesIndex, SourceLine, SourceColumn] | [GeneratedColumn, SourcesIndex, SourceLine, SourceColumn, NamesIndex]; +export type ReverseSegment = [SourceColumn, GeneratedLine, GeneratedColumn]; +export declare const COLUMN = 0; +export declare const SOURCES_INDEX = 1; +export declare const SOURCE_LINE = 2; +export declare const SOURCE_COLUMN = 3; +export declare const NAMES_INDEX = 4; +export declare const REV_GENERATED_LINE = 1; +export declare const REV_GENERATED_COLUMN = 2; +export {}; +//# sourceMappingURL=sourcemap-segment.d.ts.map \ No newline at end of file diff --git a/node_modules/@jridgewell/trace-mapping/types/sourcemap-segment.d.mts.map b/node_modules/@jridgewell/trace-mapping/types/sourcemap-segment.d.mts.map new file mode 100644 index 0000000000000000000000000000000000000000..0c94a4610db499464df13dfe8456019983053a56 --- /dev/null +++ b/node_modules/@jridgewell/trace-mapping/types/sourcemap-segment.d.mts.map @@ -0,0 +1 @@ +{"version":3,"file":"sourcemap-segment.d.ts","sourceRoot":"","sources":["../src/sourcemap-segment.ts"],"names":[],"mappings":"AAAA,KAAK,eAAe,GAAG,MAAM,CAAC;AAC9B,KAAK,YAAY,GAAG,MAAM,CAAC;AAC3B,KAAK,UAAU,GAAG,MAAM,CAAC;AACzB,KAAK,YAAY,GAAG,MAAM,CAAC;AAC3B,KAAK,UAAU,GAAG,MAAM,CAAC;AAEzB,KAAK,aAAa,GAAG,MAAM,CAAC;AAE5B,MAAM,MAAM,gBAAgB,GACxB,CAAC,eAAe,CAAC,GACjB,CAAC,eAAe,EAAE,YAAY,EAAE,UAAU,EAAE,YAAY,CAAC,GACzD,CAAC,eAAe,EAAE,YAAY,EAAE,UAAU,EAAE,YAAY,EAAE,UAAU,CAAC,CAAC;AAE1E,MAAM,MAAM,cAAc,GAAG,CAAC,YAAY,EAAE,aAAa,EAAE,eAAe,CAAC,CAAC;AAE5E,eAAO,MAAM,MAAM,IAAI,CAAC;AACxB,eAAO,MAAM,aAAa,IAAI,CAAC;AAC/B,eAAO,MAAM,WAAW,IAAI,CAAC;AAC7B,eAAO,MAAM,aAAa,IAAI,CAAC;AAC/B,eAAO,MAAM,WAAW,IAAI,CAAC;AAE7B,eAAO,MAAM,kBAAkB,IAAI,CAAC;AACpC,eAAO,MAAM,oBAAoB,IAAI,CAAC"} \ No newline at end of file diff --git a/node_modules/@jridgewell/trace-mapping/types/strip-filename.d.cts b/node_modules/@jridgewell/trace-mapping/types/strip-filename.d.cts new file mode 100644 index 0000000000000000000000000000000000000000..8b3c0e9b9b8b4d94280c825ec48f41b4db0310a2 --- /dev/null +++ b/node_modules/@jridgewell/trace-mapping/types/strip-filename.d.cts @@ -0,0 +1,5 @@ +/** + * Removes everything after the last "/", but leaves the slash. + */ +export = function stripFilename(path: string | undefined | null): string; +//# sourceMappingURL=strip-filename.d.ts.map \ No newline at end of file diff --git a/node_modules/@jridgewell/trace-mapping/types/strip-filename.d.cts.map b/node_modules/@jridgewell/trace-mapping/types/strip-filename.d.cts.map new file mode 100644 index 0000000000000000000000000000000000000000..17a25da0d4301a031587b6098f8a21f987b909f9 --- /dev/null +++ b/node_modules/@jridgewell/trace-mapping/types/strip-filename.d.cts.map @@ -0,0 +1 @@ +{"version":3,"file":"strip-filename.d.ts","sourceRoot":"","sources":["../src/strip-filename.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAC,OAAO,UAAU,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,GAAG,MAAM,CAI7E"} \ No newline at end of file diff --git a/node_modules/@jridgewell/trace-mapping/types/strip-filename.d.mts b/node_modules/@jridgewell/trace-mapping/types/strip-filename.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..cbbaee0db3016c0532f2b10e6acc31ee28c8a48f --- /dev/null +++ b/node_modules/@jridgewell/trace-mapping/types/strip-filename.d.mts @@ -0,0 +1,5 @@ +/** + * Removes everything after the last "/", but leaves the slash. + */ +export default function stripFilename(path: string | undefined | null): string; +//# sourceMappingURL=strip-filename.d.ts.map \ No newline at end of file diff --git a/node_modules/@jridgewell/trace-mapping/types/strip-filename.d.mts.map b/node_modules/@jridgewell/trace-mapping/types/strip-filename.d.mts.map new file mode 100644 index 0000000000000000000000000000000000000000..17a25da0d4301a031587b6098f8a21f987b909f9 --- /dev/null +++ b/node_modules/@jridgewell/trace-mapping/types/strip-filename.d.mts.map @@ -0,0 +1 @@ +{"version":3,"file":"strip-filename.d.ts","sourceRoot":"","sources":["../src/strip-filename.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAC,OAAO,UAAU,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,GAAG,MAAM,CAI7E"} \ No newline at end of file diff --git a/node_modules/@jridgewell/trace-mapping/types/trace-mapping.d.cts b/node_modules/@jridgewell/trace-mapping/types/trace-mapping.d.cts new file mode 100644 index 0000000000000000000000000000000000000000..a40f305476fd50c93d8209b43a09cba84f4bc68d --- /dev/null +++ b/node_modules/@jridgewell/trace-mapping/types/trace-mapping.d.cts @@ -0,0 +1,80 @@ +import type { SourceMapSegment } from './sourcemap-segment.cts'; +import type { SourceMapV3, DecodedSourceMap, EncodedSourceMap, InvalidOriginalMapping, OriginalMapping, InvalidGeneratedMapping, GeneratedMapping, SourceMapInput, Needle, SourceNeedle, SourceMap, EachMapping, Ro } from './types.cts'; +export type { SourceMapSegment } from './sourcemap-segment.cts'; +export type { SourceMap, DecodedSourceMap, EncodedSourceMap, Section, SectionedSourceMap, SourceMapV3, Bias, EachMapping, GeneratedMapping, InvalidGeneratedMapping, InvalidOriginalMapping, Needle, OriginalMapping, OriginalMapping as Mapping, SectionedSourceMapInput, SourceMapInput, SourceNeedle, XInput, EncodedSourceMapXInput, DecodedSourceMapXInput, SectionedSourceMapXInput, SectionXInput, } from './types.cts'; +export declare const LEAST_UPPER_BOUND = -1; +export declare const GREATEST_LOWER_BOUND = 1; +export { FlattenMap, FlattenMap as AnyMap } from './flatten-map.cts'; +export declare class TraceMap implements SourceMap { + version: SourceMapV3['version']; + file: SourceMapV3['file']; + names: SourceMapV3['names']; + sourceRoot: SourceMapV3['sourceRoot']; + sources: SourceMapV3['sources']; + sourcesContent: SourceMapV3['sourcesContent']; + ignoreList: SourceMapV3['ignoreList']; + resolvedSources: string[]; + private _encoded; + private _decoded; + private _decodedMemo; + private _bySources; + private _bySourceMemos; + constructor(map: Ro, mapUrl?: string | null); +} +/** + * Returns the encoded (VLQ string) form of the SourceMap's mappings field. + */ +export declare function encodedMappings(map: TraceMap): EncodedSourceMap['mappings']; +/** + * Returns the decoded (array of lines of segments) form of the SourceMap's mappings field. + */ +export declare function decodedMappings(map: TraceMap): Readonly; +/** + * A low-level API to find the segment associated with a generated line/column (think, from a + * stack trace). Line and column here are 0-based, unlike `originalPositionFor`. + */ +export declare function traceSegment(map: TraceMap, line: number, column: number): Readonly | null; +/** + * A higher-level API to find the source/line/column associated with a generated line/column + * (think, from a stack trace). Line is 1-based, but column is 0-based, due to legacy behavior in + * `source-map` library. + */ +export declare function originalPositionFor(map: TraceMap, needle: Needle): OriginalMapping | InvalidOriginalMapping; +/** + * Finds the generated line/column position of the provided source/line/column source position. + */ +export declare function generatedPositionFor(map: TraceMap, needle: SourceNeedle): GeneratedMapping | InvalidGeneratedMapping; +/** + * Finds all generated line/column positions of the provided source/line/column source position. + */ +export declare function allGeneratedPositionsFor(map: TraceMap, needle: SourceNeedle): GeneratedMapping[]; +/** + * Iterates each mapping in generated position order. + */ +export declare function eachMapping(map: TraceMap, cb: (mapping: EachMapping) => void): void; +/** + * Retrieves the source content for a particular source, if its found. Returns null if not. + */ +export declare function sourceContentFor(map: TraceMap, source: string): string | null; +/** + * Determines if the source is marked to ignore by the source map. + */ +export declare function isIgnored(map: TraceMap, source: string): boolean; +/** + * A helper that skips sorting of the input map's mappings array, which can be expensive for larger + * maps. + */ +export declare function presortedDecodedMap(map: DecodedSourceMap, mapUrl?: string): TraceMap; +/** + * Returns a sourcemap object (with decoded mappings) suitable for passing to a library that expects + * a sourcemap, or to JSON.stringify. + */ +export declare function decodedMap(map: TraceMap): Omit & { + mappings: readonly SourceMapSegment[][]; +}; +/** + * Returns a sourcemap object (with encoded mappings) suitable for passing to a library that expects + * a sourcemap, or to JSON.stringify. + */ +export declare function encodedMap(map: TraceMap): EncodedSourceMap; +//# sourceMappingURL=trace-mapping.d.ts.map \ No newline at end of file diff --git a/node_modules/@jridgewell/trace-mapping/types/trace-mapping.d.cts.map b/node_modules/@jridgewell/trace-mapping/types/trace-mapping.d.cts.map new file mode 100644 index 0000000000000000000000000000000000000000..b5a874c05a941f0f90a77a747f6ff27bd97200be --- /dev/null +++ b/node_modules/@jridgewell/trace-mapping/types/trace-mapping.d.cts.map @@ -0,0 +1 @@ +{"version":3,"file":"trace-mapping.d.ts","sourceRoot":"","sources":["../src/trace-mapping.ts"],"names":[],"mappings":"AAuBA,OAAO,KAAK,EAAE,gBAAgB,EAAkB,MAAM,qBAAqB,CAAC;AAC5E,OAAO,KAAK,EACV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,EAAE,gBAAgB,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,QAAQ,CAIpF;AAED;;;GAGG;AACH,wBAAgB,UAAU,CACxB,GAAG,EAAE,QAAQ,GACZ,IAAI,CAAC,gBAAgB,EAAE,UAAU,CAAC,GAAG;IAAE,QAAQ,EAAE,SAAS,gBAAgB,EAAE,EAAE,CAAA;CAAE,CAElF;AAED;;;GAGG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,QAAQ,GAAG,gBAAgB,CAE1D"} \ No newline at end of file diff --git a/node_modules/@jridgewell/trace-mapping/types/trace-mapping.d.mts b/node_modules/@jridgewell/trace-mapping/types/trace-mapping.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..bc2ff0f10ada49589f151943d011f212852abd81 --- /dev/null +++ b/node_modules/@jridgewell/trace-mapping/types/trace-mapping.d.mts @@ -0,0 +1,80 @@ +import type { SourceMapSegment } from './sourcemap-segment.mts'; +import type { SourceMapV3, DecodedSourceMap, EncodedSourceMap, InvalidOriginalMapping, OriginalMapping, InvalidGeneratedMapping, GeneratedMapping, SourceMapInput, Needle, SourceNeedle, SourceMap, EachMapping, Ro } from './types.mts'; +export type { SourceMapSegment } from './sourcemap-segment.mts'; +export type { SourceMap, DecodedSourceMap, EncodedSourceMap, Section, SectionedSourceMap, SourceMapV3, Bias, EachMapping, GeneratedMapping, InvalidGeneratedMapping, InvalidOriginalMapping, Needle, OriginalMapping, OriginalMapping as Mapping, SectionedSourceMapInput, SourceMapInput, SourceNeedle, XInput, EncodedSourceMapXInput, DecodedSourceMapXInput, SectionedSourceMapXInput, SectionXInput, } from './types.mts'; +export declare const LEAST_UPPER_BOUND = -1; +export declare const GREATEST_LOWER_BOUND = 1; +export { FlattenMap, FlattenMap as AnyMap } from './flatten-map.mts'; +export declare class TraceMap implements SourceMap { + version: SourceMapV3['version']; + file: SourceMapV3['file']; + names: SourceMapV3['names']; + sourceRoot: SourceMapV3['sourceRoot']; + sources: SourceMapV3['sources']; + sourcesContent: SourceMapV3['sourcesContent']; + ignoreList: SourceMapV3['ignoreList']; + resolvedSources: string[]; + private _encoded; + private _decoded; + private _decodedMemo; + private _bySources; + private _bySourceMemos; + constructor(map: Ro, mapUrl?: string | null); +} +/** + * Returns the encoded (VLQ string) form of the SourceMap's mappings field. + */ +export declare function encodedMappings(map: TraceMap): EncodedSourceMap['mappings']; +/** + * Returns the decoded (array of lines of segments) form of the SourceMap's mappings field. + */ +export declare function decodedMappings(map: TraceMap): Readonly; +/** + * A low-level API to find the segment associated with a generated line/column (think, from a + * stack trace). Line and column here are 0-based, unlike `originalPositionFor`. + */ +export declare function traceSegment(map: TraceMap, line: number, column: number): Readonly | null; +/** + * A higher-level API to find the source/line/column associated with a generated line/column + * (think, from a stack trace). Line is 1-based, but column is 0-based, due to legacy behavior in + * `source-map` library. + */ +export declare function originalPositionFor(map: TraceMap, needle: Needle): OriginalMapping | InvalidOriginalMapping; +/** + * Finds the generated line/column position of the provided source/line/column source position. + */ +export declare function generatedPositionFor(map: TraceMap, needle: SourceNeedle): GeneratedMapping | InvalidGeneratedMapping; +/** + * Finds all generated line/column positions of the provided source/line/column source position. + */ +export declare function allGeneratedPositionsFor(map: TraceMap, needle: SourceNeedle): GeneratedMapping[]; +/** + * Iterates each mapping in generated position order. + */ +export declare function eachMapping(map: TraceMap, cb: (mapping: EachMapping) => void): void; +/** + * Retrieves the source content for a particular source, if its found. Returns null if not. + */ +export declare function sourceContentFor(map: TraceMap, source: string): string | null; +/** + * Determines if the source is marked to ignore by the source map. + */ +export declare function isIgnored(map: TraceMap, source: string): boolean; +/** + * A helper that skips sorting of the input map's mappings array, which can be expensive for larger + * maps. + */ +export declare function presortedDecodedMap(map: DecodedSourceMap, mapUrl?: string): TraceMap; +/** + * Returns a sourcemap object (with decoded mappings) suitable for passing to a library that expects + * a sourcemap, or to JSON.stringify. + */ +export declare function decodedMap(map: TraceMap): Omit & { + mappings: readonly SourceMapSegment[][]; +}; +/** + * Returns a sourcemap object (with encoded mappings) suitable for passing to a library that expects + * a sourcemap, or to JSON.stringify. + */ +export declare function encodedMap(map: TraceMap): EncodedSourceMap; +//# sourceMappingURL=trace-mapping.d.ts.map \ No newline at end of file diff --git a/node_modules/@jridgewell/trace-mapping/types/trace-mapping.d.mts.map b/node_modules/@jridgewell/trace-mapping/types/trace-mapping.d.mts.map new file mode 100644 index 0000000000000000000000000000000000000000..b5a874c05a941f0f90a77a747f6ff27bd97200be --- /dev/null +++ b/node_modules/@jridgewell/trace-mapping/types/trace-mapping.d.mts.map @@ -0,0 +1 @@ +{"version":3,"file":"trace-mapping.d.ts","sourceRoot":"","sources":["../src/trace-mapping.ts"],"names":[],"mappings":"AAuBA,OAAO,KAAK,EAAE,gBAAgB,EAAkB,MAAM,qBAAqB,CAAC;AAC5E,OAAO,KAAK,EACV,WAAW,EACX,gBAAgB,EAChB,gBAAgB,EAChB,sBAAsB,EACtB,eAAe,EACf,uBAAuB,EACvB,gBAAgB,EAChB,cAAc,EACd,MAAM,EACN,YAAY,EACZ,SAAS,EACT,WAAW,EAIX,EAAE,EACH,MAAM,SAAS,CAAC;AAIjB,YAAY,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAC5D,YAAY,EACV,SAAS,EACT,gBAAgB,EAChB,gBAAgB,EAChB,OAAO,EACP,kBAAkB,EAClB,WAAW,EACX,IAAI,EACJ,WAAW,EACX,gBAAgB,EAChB,uBAAuB,EACvB,sBAAsB,EACtB,MAAM,EACN,eAAe,EACf,eAAe,IAAI,OAAO,EAC1B,uBAAuB,EACvB,cAAc,EACd,YAAY,EACZ,MAAM,EACN,sBAAsB,EACtB,sBAAsB,EACtB,wBAAwB,EACxB,aAAa,GACd,MAAM,SAAS,CAAC;AAajB,eAAO,MAAM,iBAAiB,KAAK,CAAC;AACpC,eAAO,MAAM,oBAAoB,IAAI,CAAC;AAEtC,OAAO,EAAE,UAAU,EAAE,UAAU,IAAI,MAAM,EAAE,MAAM,eAAe,CAAC;AAEjE,qBAAa,QAAS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AED;;GAEG;AACH,wBAAgB,wBAAwB,CAAC,GAAG,EAAE,QAAQ,EAAE,MAAM,EAAE,YAAY,GAAG,gBAAgB,EAAE,CAIhG;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,OAAO,EAAE,WAAW,KAAK,IAAI,GAAG,IAAI,CAgCnF;AASD;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAK7E;AAED;;GAEG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAKhE;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,gBAAgB,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,QAAQ,CAIpF;AAED;;;GAGG;AACH,wBAAgB,UAAU,CACxB,GAAG,EAAE,QAAQ,GACZ,IAAI,CAAC,gBAAgB,EAAE,UAAU,CAAC,GAAG;IAAE,QAAQ,EAAE,SAAS,gBAAgB,EAAE,EAAE,CAAA;CAAE,CAElF;AAED;;;GAGG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,QAAQ,GAAG,gBAAgB,CAE1D"} \ No newline at end of file diff --git a/node_modules/@jridgewell/trace-mapping/types/types.d.cts b/node_modules/@jridgewell/trace-mapping/types/types.d.cts new file mode 100644 index 0000000000000000000000000000000000000000..729c2c3218138386b9ac9e462ed46b2503c2407d --- /dev/null +++ b/node_modules/@jridgewell/trace-mapping/types/types.d.cts @@ -0,0 +1,107 @@ +import type { SourceMapSegment } from './sourcemap-segment.cts'; +import type { GREATEST_LOWER_BOUND, LEAST_UPPER_BOUND, TraceMap } from './trace-mapping.cts'; +export interface SourceMapV3 { + file?: string | null; + names: string[]; + sourceRoot?: string; + sources: (string | null)[]; + sourcesContent?: (string | null)[]; + version: 3; + ignoreList?: number[]; +} +export interface EncodedSourceMap extends SourceMapV3 { + mappings: string; +} +export interface DecodedSourceMap extends SourceMapV3 { + mappings: SourceMapSegment[][]; +} +export interface Section { + offset: { + line: number; + column: number; + }; + map: EncodedSourceMap | DecodedSourceMap | SectionedSourceMap; +} +export interface SectionedSourceMap { + file?: string | null; + sections: Section[]; + version: 3; +} +export type OriginalMapping = { + source: string | null; + line: number; + column: number; + name: string | null; +}; +export type InvalidOriginalMapping = { + source: null; + line: null; + column: null; + name: null; +}; +export type GeneratedMapping = { + line: number; + column: number; +}; +export type InvalidGeneratedMapping = { + line: null; + column: null; +}; +export type Bias = typeof GREATEST_LOWER_BOUND | typeof LEAST_UPPER_BOUND; +export type XInput = { + x_google_ignoreList?: SourceMapV3['ignoreList']; +}; +export type EncodedSourceMapXInput = EncodedSourceMap & XInput; +export type DecodedSourceMapXInput = DecodedSourceMap & XInput; +export type SectionedSourceMapXInput = Omit & { + sections: SectionXInput[]; +}; +export type SectionXInput = Omit & { + map: SectionedSourceMapInput; +}; +export type SourceMapInput = string | EncodedSourceMapXInput | DecodedSourceMapXInput | TraceMap; +export type SectionedSourceMapInput = SourceMapInput | SectionedSourceMapXInput; +export type Needle = { + line: number; + column: number; + bias?: Bias; +}; +export type SourceNeedle = { + source: string; + line: number; + column: number; + bias?: Bias; +}; +export type EachMapping = { + generatedLine: number; + generatedColumn: number; + source: null; + originalLine: null; + originalColumn: null; + name: null; +} | { + generatedLine: number; + generatedColumn: number; + source: string | null; + originalLine: number; + originalColumn: number; + name: string | null; +}; +export declare abstract class SourceMap { + version: SourceMapV3['version']; + file: SourceMapV3['file']; + names: SourceMapV3['names']; + sourceRoot: SourceMapV3['sourceRoot']; + sources: SourceMapV3['sources']; + sourcesContent: SourceMapV3['sourcesContent']; + resolvedSources: SourceMapV3['sources']; + ignoreList: SourceMapV3['ignoreList']; +} +export type Ro = T extends Array ? V[] | Readonly | RoArray | Readonly> : T extends object ? T | Readonly | RoObject | Readonly> : T; +type RoArray = Ro[]; +type RoObject = { + [K in keyof T]: T[K] | Ro; +}; +export declare function parse(map: T): Exclude; +export {}; +//# sourceMappingURL=types.d.ts.map \ No newline at end of file diff --git a/node_modules/@jridgewell/trace-mapping/types/types.d.cts.map b/node_modules/@jridgewell/trace-mapping/types/types.d.cts.map new file mode 100644 index 0000000000000000000000000000000000000000..922478396d1e658b7b43c40a4e461bf1d3e327fd --- /dev/null +++ b/node_modules/@jridgewell/trace-mapping/types/types.d.cts.map @@ -0,0 +1 @@ +{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,KAAK,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAEzF,MAAM,WAAW,WAAW;IAC1B,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,CAAC,MAAM,GAAG,IAAI,CAAC,EAAE,CAAC;IAC3B,cAAc,CAAC,EAAE,CAAC,MAAM,GAAG,IAAI,CAAC,EAAE,CAAC;IACnC,OAAO,EAAE,CAAC,CAAC;IACX,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;CACvB;AAED,MAAM,WAAW,gBAAiB,SAAQ,WAAW;IACnD,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,gBAAiB,SAAQ,WAAW;IACnD,QAAQ,EAAE,gBAAgB,EAAE,EAAE,CAAC;CAChC;AAED,MAAM,WAAW,OAAO;IACtB,MAAM,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IACzC,GAAG,EAAE,gBAAgB,GAAG,gBAAgB,GAAG,kBAAkB,CAAC;CAC/D;AAED,MAAM,WAAW,kBA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IACxC,UAAU,EAAE,WAAW,CAAC,YAAY,CAAC,CAAC;CAC/C;AAED,MAAM,MAAM,EAAE,CAAC,CAAC,IACd,CAAC,SAAS,KAAK,CAAC,MAAM,CAAC,CAAC,GACpB,CAAC,EAAE,GAAG,QAAQ,CAAC,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,GAAG,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,GACvD,CAAC,SAAS,MAAM,GACd,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,GAAG,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,GACrD,CAAC,CAAC;AACV,KAAK,OAAO,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;AAC1B,KAAK,QAAQ,CAAC,CAAC,IAAI;KAAG,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CAAE,CAAC;AAEvD,wBAAgB,KAAK,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,GAAG,OAAO,CAAC,CAAC,EAAE,MAAM,CAAC,CAEnD"} \ No newline at end of file diff --git a/node_modules/@jridgewell/trace-mapping/types/types.d.mts b/node_modules/@jridgewell/trace-mapping/types/types.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..a26d1866b4832bbce021f14bdcd28af6eb5db464 --- /dev/null +++ b/node_modules/@jridgewell/trace-mapping/types/types.d.mts @@ -0,0 +1,107 @@ +import type { SourceMapSegment } from './sourcemap-segment.mts'; +import type { GREATEST_LOWER_BOUND, LEAST_UPPER_BOUND, TraceMap } from './trace-mapping.mts'; +export interface SourceMapV3 { + file?: string | null; + names: string[]; + sourceRoot?: string; + sources: (string | null)[]; + sourcesContent?: (string | null)[]; + version: 3; + ignoreList?: number[]; +} +export interface EncodedSourceMap extends SourceMapV3 { + mappings: string; +} +export interface DecodedSourceMap extends SourceMapV3 { + mappings: SourceMapSegment[][]; +} +export interface Section { + offset: { + line: number; + column: number; + }; + map: EncodedSourceMap | DecodedSourceMap | SectionedSourceMap; +} +export interface SectionedSourceMap { + file?: string | null; + sections: Section[]; + version: 3; +} +export type OriginalMapping = { + source: string | null; + line: number; + column: number; + name: string | null; +}; +export type InvalidOriginalMapping = { + source: null; + line: null; + column: null; + name: null; +}; +export type GeneratedMapping = { + line: number; + column: number; +}; +export type InvalidGeneratedMapping = { + line: null; + column: null; +}; +export type Bias = typeof GREATEST_LOWER_BOUND | typeof LEAST_UPPER_BOUND; +export type XInput = { + x_google_ignoreList?: SourceMapV3['ignoreList']; +}; +export type EncodedSourceMapXInput = EncodedSourceMap & XInput; +export type DecodedSourceMapXInput = DecodedSourceMap & XInput; +export type SectionedSourceMapXInput = Omit & { + sections: SectionXInput[]; +}; +export type SectionXInput = Omit & { + map: SectionedSourceMapInput; +}; +export type SourceMapInput = string | EncodedSourceMapXInput | DecodedSourceMapXInput | TraceMap; +export type SectionedSourceMapInput = SourceMapInput | SectionedSourceMapXInput; +export type Needle = { + line: number; + column: number; + bias?: Bias; +}; +export type SourceNeedle = { + source: string; + line: number; + column: number; + bias?: Bias; +}; +export type EachMapping = { + generatedLine: number; + generatedColumn: number; + source: null; + originalLine: null; + originalColumn: null; + name: null; +} | { + generatedLine: number; + generatedColumn: number; + source: string | null; + originalLine: number; + originalColumn: number; + name: string | null; +}; +export declare abstract class SourceMap { + version: SourceMapV3['version']; + file: SourceMapV3['file']; + names: SourceMapV3['names']; + sourceRoot: SourceMapV3['sourceRoot']; + sources: SourceMapV3['sources']; + sourcesContent: SourceMapV3['sourcesContent']; + resolvedSources: SourceMapV3['sources']; + ignoreList: SourceMapV3['ignoreList']; +} +export type Ro = T extends Array ? V[] | Readonly | RoArray | Readonly> : T extends object ? T | Readonly | RoObject | Readonly> : T; +type RoArray = Ro[]; +type RoObject = { + [K in keyof T]: T[K] | Ro; +}; +export declare function parse(map: T): Exclude; +export {}; +//# sourceMappingURL=types.d.ts.map \ No newline at end of file diff --git a/node_modules/@jridgewell/trace-mapping/types/types.d.mts.map b/node_modules/@jridgewell/trace-mapping/types/types.d.mts.map new file mode 100644 index 0000000000000000000000000000000000000000..922478396d1e658b7b43c40a4e461bf1d3e327fd --- /dev/null +++ b/node_modules/@jridgewell/trace-mapping/types/types.d.mts.map @@ -0,0 +1 @@ +{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,KAAK,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAEzF,MAAM,WAAW,WAAW;IAC1B,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,CAAC,MAAM,GAAG,IAAI,CAAC,EAAE,CAAC;IAC3B,cAAc,CAAC,EAAE,CAAC,MAAM,GAAG,IAAI,CAAC,EAAE,CAAC;IACnC,OAAO,EAAE,CAAC,CAAC;IACX,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;CACvB;AAED,MAAM,WAAW,gBAAiB,SAAQ,WAAW;IACnD,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,gBAAiB,SAAQ,WAAW;IACnD,QAAQ,EAAE,gBAAgB,EAAE,EAAE,CAAC;CAChC;AAED,MAAM,WAAW,OAAO;IACtB,MAAM,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IACzC,GAAG,EAAE,gBAAgB,GAAG,gBAAgB,GAAG,kBAAkB,CAAC;CAC/D;AAED,MAAM,WAAW,kBAAkB;IACjC,IAAI,CAAC,EAAE,MAAM,GAAG,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,CAAC;CAC/C;AAED,MAAM,MAAM,EAAE,CAAC,CAAC,IACd,CAAC,SAAS,KAAK,CAAC,MAAM,CAAC,CAAC,GACpB,CAAC,EAAE,GAAG,QAAQ,CAAC,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,GAAG,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,GACvD,CAAC,SAAS,MAAM,GACd,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,GAAG,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,GACrD,CAAC,CAAC;AACV,KAAK,OAAO,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;AAC1B,KAAK,QAAQ,CAAC,CAAC,IAAI;KAAG,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CAAE,CAAC;AAEvD,wBAAgB,KAAK,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,GAAG,OAAO,CAAC,CAAC,EAAE,MAAM,CAAC,CAEnD"} \ No newline at end of file diff --git a/node_modules/@mapbox/geojson-rewind/LICENSE.txt b/node_modules/@mapbox/geojson-rewind/LICENSE.txt new file mode 100644 index 0000000000000000000000000000000000000000..707b7910f0c9fea85374a4e5d0394ac56eaf1623 --- /dev/null +++ b/node_modules/@mapbox/geojson-rewind/LICENSE.txt @@ -0,0 +1,13 @@ +Copyright (c) 2020, Mapbox + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted, provided that the above +copyright notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH +REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND +FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, +INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM +LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR +OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +PERFORMANCE OF THIS SOFTWARE. diff --git a/node_modules/@mapbox/geojson-rewind/README.md b/node_modules/@mapbox/geojson-rewind/README.md new file mode 100644 index 0000000000000000000000000000000000000000..3cbba71891f3dfeeefa33e3a5d30a7500c7f10e3 --- /dev/null +++ b/node_modules/@mapbox/geojson-rewind/README.md @@ -0,0 +1,32 @@ +[![Build Status](https://travis-ci.org/mapbox/geojson-rewind.png)](https://travis-ci.org/mapbox/geojson-rewind) + +# geojson-rewind + +The [GeoJSON](https://tools.ietf.org/html/rfc7946) specification is [picky about winding order](https://tools.ietf.org/html/rfc7946#section-3.1.6). + +This helps you generate compliant Polygon and MultiPolygon geometries. Furthermore it lets you use [Canvas](http://www.bit-101.com/blog/?p=3702) and other drawing libraries's default behavior to color the interior rings of Polygon and MultiPolygon features. + +## Usage + +As NPM module: + + npm install --save @mapbox/geojson-rewind + +As a console utility: + + # install + npm install -g @mapbox/geojson-rewind + # use + geojson-rewind foo.geojson + +As a browser library: [geojson-rewind.js](https://bundle.run/geojson-rewind) + +## API + +`rewind(geojson, clockwise)` + +Given a GeoJSON FeatureCollection, Feature, or Geometry, return a version +with inner and outer rings of different winding orders. + +If `clockwise` is `true`, the outer ring is clockwise, otherwise +it is counterclockwise. diff --git a/node_modules/@mapbox/geojson-rewind/geojson-rewind b/node_modules/@mapbox/geojson-rewind/geojson-rewind new file mode 100644 index 0000000000000000000000000000000000000000..d3352a1662c38955ecb61a8e94aa45ad830d0f2f --- /dev/null +++ b/node_modules/@mapbox/geojson-rewind/geojson-rewind @@ -0,0 +1,33 @@ +#!/usr/bin/env node + +var rewind = require('./'), + getStream = require('get-stream'), + fs = require('fs'), + argv = require('minimist')(process.argv.slice(2), { + boolean: 'clockwise' + }); + +const help = ` +usage: + + geojson-rewind < foo.geojson > foo.geojson + geojson-rewind foo.geojson > bar.geojson + +options: + + --clockwise + + if specified, set outer ring to clockwise + and inner rings to counterclockwise`.trim(); + +if (process.stdin.isTTY && !argv._[0]) { + console.log(help); + process.exit(1); +} + +getStream(argv._.length ? fs.createReadStream(argv._[0]) : process.stdin) + .then(convert); + +function convert(data) { + process.stdout.write(JSON.stringify(rewind(JSON.parse(data), argv.clockwise))); +} diff --git a/node_modules/@mapbox/geojson-rewind/index.js b/node_modules/@mapbox/geojson-rewind/index.js new file mode 100644 index 0000000000000000000000000000000000000000..a0e31e9dd78b84b75e87ef13575fee9991006157 --- /dev/null +++ b/node_modules/@mapbox/geojson-rewind/index.js @@ -0,0 +1,44 @@ + +module.exports = rewind; + +function rewind(gj, outer) { + var type = gj && gj.type, i; + + if (type === 'FeatureCollection') { + for (i = 0; i < gj.features.length; i++) rewind(gj.features[i], outer); + + } else if (type === 'GeometryCollection') { + for (i = 0; i < gj.geometries.length; i++) rewind(gj.geometries[i], outer); + + } else if (type === 'Feature') { + rewind(gj.geometry, outer); + + } else if (type === 'Polygon') { + rewindRings(gj.coordinates, outer); + + } else if (type === 'MultiPolygon') { + for (i = 0; i < gj.coordinates.length; i++) rewindRings(gj.coordinates[i], outer); + } + + return gj; +} + +function rewindRings(rings, outer) { + if (rings.length === 0) return; + + rewindRing(rings[0], outer); + for (var i = 1; i < rings.length; i++) { + rewindRing(rings[i], !outer); + } +} + +function rewindRing(ring, dir) { + var area = 0, err = 0; + for (var i = 0, len = ring.length, j = len - 1; i < len; j = i++) { + var k = (ring[i][0] - ring[j][0]) * (ring[j][1] + ring[i][1]); + var m = area + k; + err += Math.abs(area) >= Math.abs(k) ? area - m + k : k - m + area; + area = m; + } + if (area + err >= 0 !== !!dir) ring.reverse(); +} diff --git a/node_modules/@mapbox/geojson-rewind/package.json b/node_modules/@mapbox/geojson-rewind/package.json new file mode 100644 index 0000000000000000000000000000000000000000..b64cf8f7b490dfd05efb856bbe3675b28e977c9b --- /dev/null +++ b/node_modules/@mapbox/geojson-rewind/package.json @@ -0,0 +1,41 @@ +{ + "name": "@mapbox/geojson-rewind", + "version": "0.5.2", + "description": "enforce winding order for geojson", + "main": "index.js", + "bin": "geojson-rewind", + "directories": { + "test": "test" + }, + "scripts": { + "test": "tape test/rewind.js" + }, + "files": [ + "index.js", + "geojson-rewind" + ], + "repository": { + "type": "git", + "url": "git://github.com/mapbox/geojson-rewind.git" + }, + "keywords": [ + "geojson", + "winding", + "order", + "rendering", + "coordinates" + ], + "author": "Tom MacWright", + "license": "ISC", + "bugs": { + "url": "https://github.com/mapbox/geojson-rewind/issues" + }, + "homepage": "https://github.com/mapbox/geojson-rewind", + "dependencies": { + "get-stream": "^6.0.1", + "minimist": "^1.2.6" + }, + "devDependencies": { + "tape": "^5.5.3" + } +} diff --git a/node_modules/@mapbox/geojson-types/.flowconfig b/node_modules/@mapbox/geojson-types/.flowconfig new file mode 100644 index 0000000000000000000000000000000000000000..8ede2d1fbb9226ac7603b1b6a1bc581afeb68509 --- /dev/null +++ b/node_modules/@mapbox/geojson-types/.flowconfig @@ -0,0 +1,17 @@ +[ignore] +.*/jsonlint-lines/.* + +[include] + +[libs] + +[lints] + +[options] + +[strict] +nonstrict-import +unclear-type +unsafe-getters-setters +untyped-import +untyped-type-import diff --git a/node_modules/@mapbox/geojson-types/LICENSE b/node_modules/@mapbox/geojson-types/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..b039a712877a2bf4d16006c98db818cb9186bed0 --- /dev/null +++ b/node_modules/@mapbox/geojson-types/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2018 Mapbox + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/node_modules/@mapbox/geojson-types/README.md b/node_modules/@mapbox/geojson-types/README.md new file mode 100644 index 0000000000000000000000000000000000000000..8c3baa1a784df94eaef66fd3303de48f0afc43ab --- /dev/null +++ b/node_modules/@mapbox/geojson-types/README.md @@ -0,0 +1,41 @@ +# geojson-types + +Flow type declarations for [GeoJSON](https://tools.ietf.org/html/rfc7946). + + +## Install + +``` +npm install @mapbox/geojson-types +``` + +## Use + +```js +// @flow + +import type { + GeoJSONFeatureCollection, + GeoJSONFeature, + + // specific geometries + GeoJSONPoint, + GeoJSONLineString, + GeoJSONPolygon, + GeoJSONMultiPoint, + GeoJSONMultiLineString, + GeoJSONMultiPolygon, + + // any geometry + GeoJSONGeometry, + + // any feature collection, feature, or geometry + GeoJSON, +} from '@mapbox/geojson-types'; + +function doSomething(data: GeoJSON) { + // ... +} +``` + + diff --git a/node_modules/@mapbox/geojson-types/fixtures/invalid/feature-invalid-id.js.flow b/node_modules/@mapbox/geojson-types/fixtures/invalid/feature-invalid-id.js.flow new file mode 100644 index 0000000000000000000000000000000000000000..c1c1d01692d0fd6fc2f3499c85808d04b79fbce1 --- /dev/null +++ b/node_modules/@mapbox/geojson-types/fixtures/invalid/feature-invalid-id.js.flow @@ -0,0 +1,13 @@ +// @flow strict + +import type { + GeoJSONFeature +} from '../../index'; + +const wrongIdType: GeoJSONFeature = { + type: 'Feature', + geometry: null, + properties: {}, + id: [] +}; + diff --git a/node_modules/@mapbox/geojson-types/fixtures/invalid/feature-invalid-type.js.flow b/node_modules/@mapbox/geojson-types/fixtures/invalid/feature-invalid-type.js.flow new file mode 100644 index 0000000000000000000000000000000000000000..901edf6100c78f31cec498817eb5127bb378e04f --- /dev/null +++ b/node_modules/@mapbox/geojson-types/fixtures/invalid/feature-invalid-type.js.flow @@ -0,0 +1,12 @@ +// @flow strict + +import type { + GeoJSONFeature +} from '../../index'; + +const wrongType: GeoJSONFeature = { + type: 'NotFeature', + geometry: null, + properties: {} +}; + diff --git a/node_modules/@mapbox/geojson-types/fixtures/invalid/feature-no-properties.js.flow b/node_modules/@mapbox/geojson-types/fixtures/invalid/feature-no-properties.js.flow new file mode 100644 index 0000000000000000000000000000000000000000..6e5e891a97b5d72350e084b7840e31426ab8b8b2 --- /dev/null +++ b/node_modules/@mapbox/geojson-types/fixtures/invalid/feature-no-properties.js.flow @@ -0,0 +1,10 @@ +// @flow strict + +import type { + GeoJSONFeature +} from '../../index'; + +const noProperties: GeoJSONFeature = { + type: 'Feature', + geometry: null +}; diff --git a/node_modules/@mapbox/geojson-types/fixtures/invalid/geometry-invalid-type.js.flow b/node_modules/@mapbox/geojson-types/fixtures/invalid/geometry-invalid-type.js.flow new file mode 100644 index 0000000000000000000000000000000000000000..ab3b6206fc2ae7872fbda4c655db84ae542e7f8c --- /dev/null +++ b/node_modules/@mapbox/geojson-types/fixtures/invalid/geometry-invalid-type.js.flow @@ -0,0 +1,11 @@ +// @flow strict + +import type { + GeoJSONGeometry +} from '../../index'; + +const wrongType: GeoJSONGeometry = { + type: 'Invalid Geometry Type', + coordinates: [] +}; + diff --git a/node_modules/@mapbox/geojson-types/fixtures/invalid/linestring-invalid-coordinates-1.js.flow b/node_modules/@mapbox/geojson-types/fixtures/invalid/linestring-invalid-coordinates-1.js.flow new file mode 100644 index 0000000000000000000000000000000000000000..788561136fcc2050f67e2a879ddfd689fe16aa03 --- /dev/null +++ b/node_modules/@mapbox/geojson-types/fixtures/invalid/linestring-invalid-coordinates-1.js.flow @@ -0,0 +1,11 @@ +// @flow strict + +import type { + GeoJSONGeometry +} from '../../index'; + +const wrongType: GeoJSONGeometry = { + type: 'LineString', + coordinates: [0, 0] +}; + diff --git a/node_modules/@mapbox/geojson-types/fixtures/invalid/linestring-invalid-coordinates-2.js.flow b/node_modules/@mapbox/geojson-types/fixtures/invalid/linestring-invalid-coordinates-2.js.flow new file mode 100644 index 0000000000000000000000000000000000000000..d8ef16860c4c2fe935f956aea79354c7df6f326e --- /dev/null +++ b/node_modules/@mapbox/geojson-types/fixtures/invalid/linestring-invalid-coordinates-2.js.flow @@ -0,0 +1,11 @@ +// @flow strict + +import type { + GeoJSONGeometry +} from '../../index'; + +const wrongType: GeoJSONGeometry = { + type: 'LineString', + coordinates: [[[0, 0], [1, 2]]] +}; + diff --git a/node_modules/@mapbox/geojson-types/fixtures/invalid/multilinestring-invalid-coordinates-1.js.flow b/node_modules/@mapbox/geojson-types/fixtures/invalid/multilinestring-invalid-coordinates-1.js.flow new file mode 100644 index 0000000000000000000000000000000000000000..acba73856c11e6c312e500b116c9d4e3fcae2cd2 --- /dev/null +++ b/node_modules/@mapbox/geojson-types/fixtures/invalid/multilinestring-invalid-coordinates-1.js.flow @@ -0,0 +1,11 @@ +// @flow strict + +import type { + GeoJSONGeometry +} from '../../index'; + +const wrongType: GeoJSONGeometry = { + type: 'MultiLineString', + coordinates: [[0, 0], [0, 0]] +}; + diff --git a/node_modules/@mapbox/geojson-types/fixtures/invalid/multilinestring-invalid-coordinates-2.js.flow b/node_modules/@mapbox/geojson-types/fixtures/invalid/multilinestring-invalid-coordinates-2.js.flow new file mode 100644 index 0000000000000000000000000000000000000000..5149162f126994cf37755336380deae4f3b9f2ee --- /dev/null +++ b/node_modules/@mapbox/geojson-types/fixtures/invalid/multilinestring-invalid-coordinates-2.js.flow @@ -0,0 +1,11 @@ +// @flow strict + +import type { + GeoJSONGeometry +} from '../../index'; + +const wrongType: GeoJSONGeometry = { + type: 'MultiLineString', + coordinates: [[[[0, 0], [1, 1]]]] +}; + diff --git a/node_modules/@mapbox/geojson-types/fixtures/invalid/multipoint-invalid-coordinates-1.js.flow b/node_modules/@mapbox/geojson-types/fixtures/invalid/multipoint-invalid-coordinates-1.js.flow new file mode 100644 index 0000000000000000000000000000000000000000..f4cdaae16d4eda0e416aca665863bda408e40a12 --- /dev/null +++ b/node_modules/@mapbox/geojson-types/fixtures/invalid/multipoint-invalid-coordinates-1.js.flow @@ -0,0 +1,11 @@ +// @flow strict + +import type { + GeoJSONGeometry +} from '../../index'; + +const wrongType: GeoJSONGeometry = { + type: 'MultiPoint', + coordinates: [0, 0] +}; + diff --git a/node_modules/@mapbox/geojson-types/fixtures/invalid/multipoint-invalid-coordinates-2.js.flow b/node_modules/@mapbox/geojson-types/fixtures/invalid/multipoint-invalid-coordinates-2.js.flow new file mode 100644 index 0000000000000000000000000000000000000000..883a309850482aceb2b19706c3eabf68102ae76e --- /dev/null +++ b/node_modules/@mapbox/geojson-types/fixtures/invalid/multipoint-invalid-coordinates-2.js.flow @@ -0,0 +1,11 @@ +// @flow strict + +import type { + GeoJSONGeometry +} from '../../index'; + +const wrongType: GeoJSONGeometry = { + type: 'MultiPoint', + coordinates: [[[0, 0], [1, 1]]] +}; + diff --git a/node_modules/@mapbox/geojson-types/fixtures/invalid/multipolygon-invalid-coordinates-1.js.flow b/node_modules/@mapbox/geojson-types/fixtures/invalid/multipolygon-invalid-coordinates-1.js.flow new file mode 100644 index 0000000000000000000000000000000000000000..2fa0afe5ef47fc82d5ec23426f7390a4bc22c70a --- /dev/null +++ b/node_modules/@mapbox/geojson-types/fixtures/invalid/multipolygon-invalid-coordinates-1.js.flow @@ -0,0 +1,11 @@ +// @flow strict + +import type { + GeoJSONGeometry +} from '../../index'; + +const wrongType: GeoJSONGeometry = { + type: 'MultiPolygon', + coordinates: [[[0, 0], [1, 2]]] +}; + diff --git a/node_modules/@mapbox/geojson-types/fixtures/invalid/multipolygon-invalid-coordinates-2.js.flow b/node_modules/@mapbox/geojson-types/fixtures/invalid/multipolygon-invalid-coordinates-2.js.flow new file mode 100644 index 0000000000000000000000000000000000000000..ba91e5b6b8656b92de70e9e5d67dd2071068852f --- /dev/null +++ b/node_modules/@mapbox/geojson-types/fixtures/invalid/multipolygon-invalid-coordinates-2.js.flow @@ -0,0 +1,11 @@ +// @flow strict + +import type { + GeoJSONGeometry +} from '../../index'; + +const wrongType: GeoJSONGeometry = { + type: 'Point', + coordinates: [[[[[0, 0], [1, 2]]]]] +}; + diff --git a/node_modules/@mapbox/geojson-types/fixtures/invalid/point-invalid-coordinates-1.js.flow b/node_modules/@mapbox/geojson-types/fixtures/invalid/point-invalid-coordinates-1.js.flow new file mode 100644 index 0000000000000000000000000000000000000000..f10ea3b3a5a038fdeb86462476125b8cebe1d316 --- /dev/null +++ b/node_modules/@mapbox/geojson-types/fixtures/invalid/point-invalid-coordinates-1.js.flow @@ -0,0 +1,11 @@ +// @flow strict + +import type { + GeoJSONGeometry +} from '../../index'; + +const wrongType: GeoJSONGeometry = { + type: 'Point', + coordinates: [] +}; + diff --git a/node_modules/@mapbox/geojson-types/fixtures/invalid/point-invalid-coordinates-2.js.flow b/node_modules/@mapbox/geojson-types/fixtures/invalid/point-invalid-coordinates-2.js.flow new file mode 100644 index 0000000000000000000000000000000000000000..e8304da2978096a7291047125e2ca9498c054fff --- /dev/null +++ b/node_modules/@mapbox/geojson-types/fixtures/invalid/point-invalid-coordinates-2.js.flow @@ -0,0 +1,11 @@ +// @flow strict + +import type { + GeoJSONGeometry +} from '../../index'; + +const wrongType: GeoJSONGeometry = { + type: 'Point', + coordinates: [[0, 0], [1, 1]] +}; + diff --git a/node_modules/@mapbox/geojson-types/fixtures/invalid/polygon-invalid-coordinates-1.js.flow b/node_modules/@mapbox/geojson-types/fixtures/invalid/polygon-invalid-coordinates-1.js.flow new file mode 100644 index 0000000000000000000000000000000000000000..d9116cb2ceeba6699d3d33aa30560bd3ad654e1c --- /dev/null +++ b/node_modules/@mapbox/geojson-types/fixtures/invalid/polygon-invalid-coordinates-1.js.flow @@ -0,0 +1,11 @@ +// @flow strict + +import type { + GeoJSONGeometry +} from '../../index'; + +const wrongType: GeoJSONGeometry = { + type: 'Polygon', + coordinates: [[[[0, 0], [0, 0]]]] +}; + diff --git a/node_modules/@mapbox/geojson-types/fixtures/invalid/polygon-invalid-coordinates-2.js.flow b/node_modules/@mapbox/geojson-types/fixtures/invalid/polygon-invalid-coordinates-2.js.flow new file mode 100644 index 0000000000000000000000000000000000000000..a1412ff2ae4b4100a14068e4f2238d8b6f3f9a7e --- /dev/null +++ b/node_modules/@mapbox/geojson-types/fixtures/invalid/polygon-invalid-coordinates-2.js.flow @@ -0,0 +1,11 @@ +// @flow strict + +import type { + GeoJSONGeometry +} from '../../index'; + +const wrongType: GeoJSONGeometry = { + type: 'Polygon', + coordinates: [[0, 0], [0, 0]] +}; + diff --git a/node_modules/@mapbox/geojson-types/fixtures/valid/feature-collection.js.flow b/node_modules/@mapbox/geojson-types/fixtures/valid/feature-collection.js.flow new file mode 100644 index 0000000000000000000000000000000000000000..9fb419ad4315e044532e607b0fdc586a725e2524 --- /dev/null +++ b/node_modules/@mapbox/geojson-types/fixtures/valid/feature-collection.js.flow @@ -0,0 +1,22 @@ +// @flow + +import type { + GeoJSONFeatureCollection +} from '../../index'; + +const collection: GeoJSONFeatureCollection = { + type: "FeatureCollection", + features: [ + { + type: "Feature", + properties: {}, + geometry: { + "type": "Point", + "coordinates": [ + 100, + 0 + ] + } + } + ] +}; diff --git a/node_modules/@mapbox/geojson-types/fixtures/valid/feature.js.flow b/node_modules/@mapbox/geojson-types/fixtures/valid/feature.js.flow new file mode 100644 index 0000000000000000000000000000000000000000..a0a481d65a6efaa9972891f1f73c6a28810a1764 --- /dev/null +++ b/node_modules/@mapbox/geojson-types/fixtures/valid/feature.js.flow @@ -0,0 +1,38 @@ +// @flow +import type { + GeoJSONFeature +} from '../../index'; + +const geom = { + "type": "Point", + "coordinates": [ + 100, + 0 + ] +} + +const feature: GeoJSONFeature = { + id: 1, + type: "Feature", + properties: { + "number": 1, + "boolean": false, + "string": "hello", + "object": { "x": 1 }, + "array": [ 1, "a", false, null ], + "null": null + }, + geometry: geom +}; + +const nullGeometry: GeoJSONFeature = { + type: "Feature", + properties: {}, + geometry: null +}; + +const nullProperties: GeoJSONFeature = { + type: "Feature", + properties: null, + geometry: null +} diff --git a/node_modules/@mapbox/geojson-types/fixtures/valid/geometrycollection-xyz.js.flow b/node_modules/@mapbox/geojson-types/fixtures/valid/geometrycollection-xyz.js.flow new file mode 100644 index 0000000000000000000000000000000000000000..543152c02a4346e118b799a5a6df2ceaab2f976c --- /dev/null +++ b/node_modules/@mapbox/geojson-types/fixtures/valid/geometrycollection-xyz.js.flow @@ -0,0 +1,33 @@ +// @flow +import type { + GeoJSONGeometry +} from '../../index'; + +const geojson: GeoJSONGeometry = { + "type": "GeometryCollection", + "geometries": [ + { + "type": "Point", + "coordinates": [ + 100, + 0, + 3 + ] + }, + { + "type": "LineString", + "coordinates": [ + [ + 101, + 0, + 5 + ], + [ + 102, + 1, + 8 + ] + ] + } + ] +} diff --git a/node_modules/@mapbox/geojson-types/fixtures/valid/geometrycollection.js.flow b/node_modules/@mapbox/geojson-types/fixtures/valid/geometrycollection.js.flow new file mode 100644 index 0000000000000000000000000000000000000000..7d6d49283b179344344a7c73f2b9d0792eec3db0 --- /dev/null +++ b/node_modules/@mapbox/geojson-types/fixtures/valid/geometrycollection.js.flow @@ -0,0 +1,30 @@ +// @flow +import type { + GeoJSONGeometry +} from '../../index'; + +const geojson: GeoJSONGeometry = { + "type": "GeometryCollection", + "geometries": [ + { + "type": "Point", + "coordinates": [ + 100, + 0 + ] + }, + { + "type": "LineString", + "coordinates": [ + [ + 101, + 0 + ], + [ + 102, + 1 + ] + ] + } + ] +} diff --git a/node_modules/@mapbox/geojson-types/fixtures/valid/multilinestring-xyz.js.flow b/node_modules/@mapbox/geojson-types/fixtures/valid/multilinestring-xyz.js.flow new file mode 100644 index 0000000000000000000000000000000000000000..255fa5492ea77a919b71b2058acebdae35f6b34c --- /dev/null +++ b/node_modules/@mapbox/geojson-types/fixtures/valid/multilinestring-xyz.js.flow @@ -0,0 +1,34 @@ +// @flow +import type { + GeoJSONGeometry +} from '../../index'; + +const geojson: GeoJSONGeometry = { + "type": "MultiLineString", + "coordinates": [ + [ + [ + 100, + 0, + 5.2 + ], + [ + 101, + 1, + 8.1 + ] + ], + [ + [ + 102, + 2, + 2.3 + ], + [ + 103, + 3, + 7.4 + ] + ] + ] +} diff --git a/node_modules/@mapbox/geojson-types/fixtures/valid/multilinestring.js.flow b/node_modules/@mapbox/geojson-types/fixtures/valid/multilinestring.js.flow new file mode 100644 index 0000000000000000000000000000000000000000..22f7d7c7b3b036a4561b6b26138d334767460f39 --- /dev/null +++ b/node_modules/@mapbox/geojson-types/fixtures/valid/multilinestring.js.flow @@ -0,0 +1,30 @@ +// @flow +import type { + GeoJSONGeometry +} from '../../index'; + +const geojson: GeoJSONGeometry = { + "type": "MultiLineString", + "coordinates": [ + [ + [ + 100, + 0 + ], + [ + 101, + 1 + ] + ], + [ + [ + 102, + 2 + ], + [ + 103, + 3 + ] + ] + ] +} diff --git a/node_modules/@mapbox/geojson-types/fixtures/valid/multipoint-xyz.js.flow b/node_modules/@mapbox/geojson-types/fixtures/valid/multipoint-xyz.js.flow new file mode 100644 index 0000000000000000000000000000000000000000..7dbee19b35aa90cbca774059b7a2b83cf3b96920 --- /dev/null +++ b/node_modules/@mapbox/geojson-types/fixtures/valid/multipoint-xyz.js.flow @@ -0,0 +1,20 @@ +// @flow +import type { + GeoJSONGeometry +} from '../../index'; + +const geojson: GeoJSONGeometry = { + "type": "MultiPoint", + "coordinates": [ + [ + 100, + 0, + 1 + ], + [ + 101, + 1, + 2 + ] + ] +} diff --git a/node_modules/@mapbox/geojson-types/fixtures/valid/multipoint.js.flow b/node_modules/@mapbox/geojson-types/fixtures/valid/multipoint.js.flow new file mode 100644 index 0000000000000000000000000000000000000000..9908f32a7d124a5af3ef953ed73230677ace0b91 --- /dev/null +++ b/node_modules/@mapbox/geojson-types/fixtures/valid/multipoint.js.flow @@ -0,0 +1,18 @@ +// @flow +import type { + GeoJSONGeometry +} from '../../index'; + +const geojson: GeoJSONGeometry = { + "type": "MultiPoint", + "coordinates": [ + [ + 100, + 0 + ], + [ + 101, + 1 + ] + ] +} diff --git a/node_modules/@mapbox/geojson-types/fixtures/valid/multipolygon-xyz.js.flow b/node_modules/@mapbox/geojson-types/fixtures/valid/multipolygon-xyz.js.flow new file mode 100644 index 0000000000000000000000000000000000000000..06c5990692a6d88950d87d27e51125e786b48f78 --- /dev/null +++ b/node_modules/@mapbox/geojson-types/fixtures/valid/multipolygon-xyz.js.flow @@ -0,0 +1,95 @@ +// @flow +import type { + GeoJSONGeometry +} from '../../index'; + +const geojson: GeoJSONGeometry = { + "type": "MultiPolygon", + "coordinates": [ + [ + [ + [ + 102, + 2, + 1 + ], + [ + 103, + 2, + 1 + ], + [ + 103, + 3, + 1 + ], + [ + 102, + 3, + 1 + ], + [ + 102, + 2, + 1 + ] + ] + ], + [ + [ + [ + 100, + 0, + 2 + ], + [ + 101, + 0, + 2 + ], + [ + 101, + 1, + 2 + ], + [ + 100, + 1, + 2 + ], + [ + 100, + 0, + 2 + ] + ], + [ + [ + 100.2, + 0.2, + 3 + ], + [ + 100.8, + 0.2, + 3 + ], + [ + 100.8, + 0.8, + 3 + ], + [ + 100.2, + 0.8, + 3 + ], + [ + 100.2, + 0.2, + 3 + ] + ] + ] + ] +} diff --git a/node_modules/@mapbox/geojson-types/fixtures/valid/multipolygon.js.flow b/node_modules/@mapbox/geojson-types/fixtures/valid/multipolygon.js.flow new file mode 100644 index 0000000000000000000000000000000000000000..d91e2b6cbab40b0ae169bdf8b7bbea1702a0e074 --- /dev/null +++ b/node_modules/@mapbox/geojson-types/fixtures/valid/multipolygon.js.flow @@ -0,0 +1,80 @@ +// @flow +import type { + GeoJSONGeometry +} from '../../index'; + +const geojson: GeoJSONGeometry = { + "type": "MultiPolygon", + "coordinates": [ + [ + [ + [ + 102, + 2 + ], + [ + 103, + 2 + ], + [ + 103, + 3 + ], + [ + 102, + 3 + ], + [ + 102, + 2 + ] + ] + ], + [ + [ + [ + 100, + 0 + ], + [ + 101, + 0 + ], + [ + 101, + 1 + ], + [ + 100, + 1 + ], + [ + 100, + 0 + ] + ], + [ + [ + 100.2, + 0.2 + ], + [ + 100.8, + 0.2 + ], + [ + 100.8, + 0.8 + ], + [ + 100.2, + 0.8 + ], + [ + 100.2, + 0.2 + ] + ] + ] + ] +} diff --git a/node_modules/@mapbox/geojson-types/fixtures/valid/point-xyz.js.flow b/node_modules/@mapbox/geojson-types/fixtures/valid/point-xyz.js.flow new file mode 100644 index 0000000000000000000000000000000000000000..667d4508ac12714a6417da118a13083f81c0e3f4 --- /dev/null +++ b/node_modules/@mapbox/geojson-types/fixtures/valid/point-xyz.js.flow @@ -0,0 +1,13 @@ +// @flow +import type { + GeoJSONGeometry +} from '../../index'; + +const geojson: GeoJSONGeometry = { + "type": "Point", + "coordinates": [ + 100, + 0, + 1 + ] +} diff --git a/node_modules/@mapbox/geojson-types/fixtures/valid/point.js.flow b/node_modules/@mapbox/geojson-types/fixtures/valid/point.js.flow new file mode 100644 index 0000000000000000000000000000000000000000..db7985f9355b0a0e08aeeee5f82a38734161859d --- /dev/null +++ b/node_modules/@mapbox/geojson-types/fixtures/valid/point.js.flow @@ -0,0 +1,12 @@ +// @flow +import type { + GeoJSONGeometry +} from '../../index'; + +const geojson: GeoJSONGeometry = { + "type": "Point", + "coordinates": [ + 100, + 0 + ] +} diff --git a/node_modules/@mapbox/geojson-types/fixtures/valid/polygon-xyz.js.flow b/node_modules/@mapbox/geojson-types/fixtures/valid/polygon-xyz.js.flow new file mode 100644 index 0000000000000000000000000000000000000000..c67ada49967a5a29466ff5857b8387cd96d5140f --- /dev/null +++ b/node_modules/@mapbox/geojson-types/fixtures/valid/polygon-xyz.js.flow @@ -0,0 +1,36 @@ +// @flow +import type { + GeoJSONGeometry +} from '../../index'; + +const geojson: GeoJSONGeometry = { + "type": "Polygon", + "coordinates": [ + [ + [ + 100, + 0, + 1 + ], + [ + 101, + 0 + ], + [ + 101, + 1, + 1 + ], + [ + 100, + 1, + 1 + ], + [ + 100, + 0, + 1 + ] + ] + ] +} diff --git a/node_modules/@mapbox/geojson-types/fixtures/valid/polygon.js.flow b/node_modules/@mapbox/geojson-types/fixtures/valid/polygon.js.flow new file mode 100644 index 0000000000000000000000000000000000000000..29bb3adc070d9ac6d6ce994a8e9aacaa469b8390 --- /dev/null +++ b/node_modules/@mapbox/geojson-types/fixtures/valid/polygon.js.flow @@ -0,0 +1,32 @@ +// @flow +import type { + GeoJSONGeometry +} from '../../index'; + +const geojson: GeoJSONGeometry = { + "type": "Polygon", + "coordinates": [ + [ + [ + 100, + 0 + ], + [ + 101, + 0 + ], + [ + 101, + 1 + ], + [ + 100, + 1 + ], + [ + 100, + 0 + ] + ] + ] +} diff --git a/node_modules/@mapbox/geojson-types/generate-fixtures.js b/node_modules/@mapbox/geojson-types/generate-fixtures.js new file mode 100644 index 0000000000000000000000000000000000000000..24045b2359ec1e0964a7d7540550cbb73f124ff8 --- /dev/null +++ b/node_modules/@mapbox/geojson-types/generate-fixtures.js @@ -0,0 +1,13 @@ +const fs = require('fs'); +const fixtures = require('@mapbox/geojson-fixtures'); + +for (let key in fixtures.geometry) { + fs.writeFileSync(`${__dirname}/fixtures/valid/${key}.js.flow`, `// @flow +// This file was generated by generate-fixtures.js. Do not edit! +import type { + GeoJSONGeometry +} from '../../index'; + +const geojson: GeoJSONGeometry = ${JSON.stringify(fixtures.geometry[key], null, 2)} +`); +} diff --git a/node_modules/@mapbox/geojson-types/index.js b/node_modules/@mapbox/geojson-types/index.js new file mode 100644 index 0000000000000000000000000000000000000000..4fffae8e5291298618664a340a47bfc4574d698d --- /dev/null +++ b/node_modules/@mapbox/geojson-types/index.js @@ -0,0 +1,41 @@ +// @flow strict + +type GeoJSONPosition = [number, number] | [number, number, number]; +type Geometry = { type: T, coordinates: C } + +export type GeoJSONPoint = Geometry< 'Point', GeoJSONPosition>; +export type GeoJSONMultiPoint = Geometry<'MultiPoint', Array>; + +export type GeoJSONLineString = Geometry< 'LineString', Array>; +export type GeoJSONMultiLineString = Geometry<'MultiLineString', Array>>; + +export type GeoJSONPolygon = Geometry< 'Polygon', Array>>; +export type GeoJSONMultiPolygon = Geometry<'MultiPolygon', Array>>>; + +export type GeoJSONGeometry = + | GeoJSONPoint + | GeoJSONMultiPoint + | GeoJSONLineString + | GeoJSONMultiLineString + | GeoJSONPolygon + | GeoJSONMultiPolygon + | GeoJSONGeometryCollection; + +export type GeoJSONGeometryCollection = { + type: 'GeometryCollection', + geometries: Array +}; + +export type GeoJSONFeature = { + type: 'Feature', + geometry: ?GeoJSONGeometry, + properties: ?{}, + id?: number | string +}; + +export type GeoJSONFeatureCollection = { + type: 'FeatureCollection', + features: Array +}; + +export type GeoJSON = GeoJSONGeometry | GeoJSONFeature | GeoJSONFeatureCollection; diff --git a/node_modules/@mapbox/geojson-types/package.json b/node_modules/@mapbox/geojson-types/package.json new file mode 100644 index 0000000000000000000000000000000000000000..86237a4d09a054a7534d023e08e33f3902ca0c2b --- /dev/null +++ b/node_modules/@mapbox/geojson-types/package.json @@ -0,0 +1,17 @@ +{ + "name": "@mapbox/geojson-types", + "version": "1.0.2", + "description": "", + "main": "index.js", + "scripts": { + "test": "tape test.js" + }, + "keywords": [], + "author": "", + "license": "ISC", + "devDependencies": { + "@mapbox/geojson-fixtures": "^1.0.0", + "flow-bin": "^0.77.0", + "tape": "^4.9.1" + } +} diff --git a/node_modules/@mapbox/geojson-types/test.js b/node_modules/@mapbox/geojson-types/test.js new file mode 100644 index 0000000000000000000000000000000000000000..09a1298eca338f16cbdebc7612ca9337079c7449 --- /dev/null +++ b/node_modules/@mapbox/geojson-types/test.js @@ -0,0 +1,25 @@ +const fs = require('fs'); +const tape = require('tape'); +const exec = require('child_process').exec; + +tape('valid', (t) => { + exec(`npx flow focus-check ${__dirname}/fixtures/valid/*.js.flow`, (err) => { + t.error(err); + t.end(); + }); +}); + +tape('invalid', (t) => { + const fixtures = fs.readdirSync(`${__dirname}/fixtures/invalid`); + for (const file of fixtures) { + t.test(file, (t) => { + exec(`npx flow focus-check ${__dirname}/fixtures/invalid/${file}`, (err) => { + t.ok(err, 'nonzero exit for invalid fixture'); + t.end(); + }); + }); + } + + t.end(); +}); + diff --git a/node_modules/@mapbox/jsonlint-lines-primitives/.npmignore b/node_modules/@mapbox/jsonlint-lines-primitives/.npmignore new file mode 100644 index 0000000000000000000000000000000000000000..3c3629e647f5ddf82548912e337bea9826b434af --- /dev/null +++ b/node_modules/@mapbox/jsonlint-lines-primitives/.npmignore @@ -0,0 +1 @@ +node_modules diff --git a/node_modules/@mapbox/jsonlint-lines-primitives/Makefile b/node_modules/@mapbox/jsonlint-lines-primitives/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..6660a8ed79d6471b191706ae0adebfb5381859f8 --- /dev/null +++ b/node_modules/@mapbox/jsonlint-lines-primitives/Makefile @@ -0,0 +1,17 @@ + +all: build test site + +build: + ./node_modules/jison/lib/cli.js src/jsonlint.y src/jsonlint.l + mv jsonlint.js lib/jsonlint.js + node scripts/bundle.js | ./node_modules/uglify-js/bin/uglifyjs > web/jsonlint.js + +site: + cp web/jsonlint.js ../jsonlint-pages/jsonlint.js + +deploy: site + cd ../jsonlint-pages && git commit -a -m 'deploy site updates' && git push origin gh-pages + +test: lib/jsonlint.js test/all-tests.js + node test/all-tests.js + diff --git a/node_modules/@mapbox/jsonlint-lines-primitives/README.md b/node_modules/@mapbox/jsonlint-lines-primitives/README.md new file mode 100644 index 0000000000000000000000000000000000000000..eb75347cba4ebe7b01411e727897e2d7e39b5f7a --- /dev/null +++ b/node_modules/@mapbox/jsonlint-lines-primitives/README.md @@ -0,0 +1,7 @@ +JSON Lint +========= + +A fork of the `lines-primitive` branch of [tmcw/jsonlint](https://github.com/tmcw/jsonlint), which is a fork of [zaach/jsonlint](https://github.com/zaach/jsonlint) that adds line number annotations to the parsed JSON. + +This fork is used by Mapbox GL JS, specifically for providing helpful error messages when validating Mapbox GL style JSON documents. + diff --git a/node_modules/@mapbox/jsonlint-lines-primitives/lib/formatter.js b/node_modules/@mapbox/jsonlint-lines-primitives/lib/formatter.js new file mode 100644 index 0000000000000000000000000000000000000000..e6e27265acc83936a332942822506c11efb3b8aa --- /dev/null +++ b/node_modules/@mapbox/jsonlint-lines-primitives/lib/formatter.js @@ -0,0 +1,92 @@ +#!/usr/bin/env node + +/** + * Manual formatter taken straight from https://github.com/umbrae/jsonlintdotcom +**/ + +/*jslint white: true, devel: true, onevar: true, browser: true, undef: true, nomen: true, regexp: true, plusplus: false, bitwise: true, newcap: true, maxerr: 50, indent: 4 */ + +/** + * jsl.format - Provide json reformatting in a character-by-character approach, so that even invalid JSON may be reformatted (to the best of its ability). + * +**/ +var formatter = (function () { + + function repeat(s, count) { + return new Array(count + 1).join(s); + } + + function formatJson(json, indentChars) { + var i = 0, + il = 0, + tab = (typeof indentChars !== "undefined") ? indentChars : " ", + newJson = "", + indentLevel = 0, + inString = false, + currentChar = null; + + for (i = 0, il = json.length; i < il; i += 1) { + currentChar = json.charAt(i); + + switch (currentChar) { + case '{': + case '[': + if (!inString) { + newJson += currentChar + "\n" + repeat(tab, indentLevel + 1); + indentLevel += 1; + } else { + newJson += currentChar; + } + break; + case '}': + case ']': + if (!inString) { + indentLevel -= 1; + newJson += "\n" + repeat(tab, indentLevel) + currentChar; + } else { + newJson += currentChar; + } + break; + case ',': + if (!inString) { + newJson += ",\n" + repeat(tab, indentLevel); + } else { + newJson += currentChar; + } + break; + case ':': + if (!inString) { + newJson += ": "; + } else { + newJson += currentChar; + } + break; + case ' ': + case "\n": + case "\t": + if (inString) { + newJson += currentChar; + } + break; + case '"': + if (i > 0 && json.charAt(i - 1) !== '\\') { + inString = !inString; + } + newJson += currentChar; + break; + default: + newJson += currentChar; + break; + } + } + + return newJson; + } + + return { "formatJson": formatJson }; + +}()); + +if (typeof require !== 'undefined' && typeof exports !== 'undefined') { + exports.formatter = formatter; +} \ No newline at end of file diff --git a/node_modules/@mapbox/jsonlint-lines-primitives/lib/jsonlint.js b/node_modules/@mapbox/jsonlint-lines-primitives/lib/jsonlint.js new file mode 100644 index 0000000000000000000000000000000000000000..7800de7580b0b19b129f6837aee363c8ac75d6aa --- /dev/null +++ b/node_modules/@mapbox/jsonlint-lines-primitives/lib/jsonlint.js @@ -0,0 +1,681 @@ +/* parser generated by jison 0.4.15 */ +/* + Returns a Parser object of the following structure: + + Parser: { + yy: {} + } + + Parser.prototype: { + yy: {}, + trace: function(), + symbols_: {associative list: name ==> number}, + terminals_: {associative list: number ==> name}, + productions_: [...], + performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate, $$, _$), + table: [...], + defaultActions: {...}, + parseError: function(str, hash), + parse: function(input), + + lexer: { + EOF: 1, + parseError: function(str, hash), + setInput: function(input), + input: function(), + unput: function(str), + more: function(), + less: function(n), + pastInput: function(), + upcomingInput: function(), + showPosition: function(), + test_match: function(regex_match_array, rule_index), + next: function(), + lex: function(), + begin: function(condition), + popState: function(), + _currentRules: function(), + topState: function(), + pushState: function(condition), + + options: { + ranges: boolean (optional: true ==> token location info will include a .range[] member) + flex: boolean (optional: true ==> flex-like lexing behaviour where the rules are tested exhaustively to find the longest match) + backtrack_lexer: boolean (optional: true ==> lexer regexes are tested in order and for each matching regex the action code is invoked; the lexer terminates the scan when a token is returned by the action code) + }, + + performAction: function(yy, yy_, $avoiding_name_collisions, YY_START), + rules: [...], + conditions: {associative list: name ==> set}, + } + } + + + token location info (@$, _$, etc.): { + first_line: n, + last_line: n, + first_column: n, + last_column: n, + range: [start_number, end_number] (where the numbers are indexes into the input string, regular zero-based) + } + + + the parseError function receives a 'hash' object with these members for lexer and parser errors: { + text: (matched text) + token: (the produced terminal token, if any) + line: (yylineno) + } + while parser (grammar) errors will also provide these members, i.e. parser errors deliver a superset of attributes: { + loc: (yylloc) + expected: (string describing the set of expected tokens) + recoverable: (boolean: TRUE when the parser has a error recovery rule available for this particular error) + } +*/ +var parser = (function(){ +var o=function(k,v,o,l){for(o=o||{},l=k.length;l--;o[k[l]]=v);return o},$V0=[1,12],$V1=[1,13],$V2=[1,9],$V3=[1,10],$V4=[1,11],$V5=[1,14],$V6=[1,15],$V7=[14,18,22,24],$V8=[18,22],$V9=[22,24]; +var parser = {trace: function trace() { }, +yy: {}, +symbols_: {"error":2,"JSONString":3,"STRING":4,"JSONNumber":5,"NUMBER":6,"JSONNullLiteral":7,"NULL":8,"JSONBooleanLiteral":9,"TRUE":10,"FALSE":11,"JSONText":12,"JSONValue":13,"EOF":14,"JSONObject":15,"JSONArray":16,"{":17,"}":18,"JSONMemberList":19,"JSONMember":20,":":21,",":22,"[":23,"]":24,"JSONElementList":25,"$accept":0,"$end":1}, +terminals_: {2:"error",4:"STRING",6:"NUMBER",8:"NULL",10:"TRUE",11:"FALSE",14:"EOF",17:"{",18:"}",21:":",22:",",23:"[",24:"]"}, +productions_: [0,[3,1],[5,1],[7,1],[9,1],[9,1],[12,2],[13,1],[13,1],[13,1],[13,1],[13,1],[13,1],[15,2],[15,3],[20,3],[19,1],[19,3],[16,2],[16,3],[25,1],[25,3]], +performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate /* action[1] */, $$ /* vstack */, _$ /* lstack */) { +/* this == yyval */ + +var $0 = $$.length - 1; +switch (yystate) { +case 1: + // replace escaped characters with actual character + this.$ = new String(yytext.replace(/\\(\\|")/g, "$"+"1") + .replace(/\\n/g,'\n') + .replace(/\\r/g,'\r') + .replace(/\\t/g,'\t') + .replace(/\\v/g,'\v') + .replace(/\\f/g,'\f') + .replace(/\\b/g,'\b')); + this.$.__line__ = this._$.first_line; + +break; +case 2: + + this.$ = new Number(yytext); + this.$.__line__ = this._$.first_line; + +break; +case 3: + + this.$ = null; + +break; +case 4: + + this.$ = new Boolean(true); + this.$.__line__ = this._$.first_line; + +break; +case 5: + + this.$ = new Boolean(false); + this.$.__line__ = this._$.first_line; + +break; +case 6: +return this.$ = $$[$0-1]; +break; +case 13: +this.$ = {}; Object.defineProperty(this.$, '__line__', { + value: this._$.first_line, + enumerable: false + }) +break; +case 14: case 19: +this.$ = $$[$0-1]; Object.defineProperty(this.$, '__line__', { + value: this._$.first_line, + enumerable: false + }) +break; +case 15: +this.$ = [$$[$0-2], $$[$0]]; +break; +case 16: +this.$ = {}; this.$[$$[$0][0]] = $$[$0][1]; +break; +case 17: +this.$ = $$[$0-2]; $$[$0-2][$$[$0][0]] = $$[$0][1]; +break; +case 18: +this.$ = []; Object.defineProperty(this.$, '__line__', { + value: this._$.first_line, + enumerable: false + }) +break; +case 20: +this.$ = [$$[$0]]; +break; +case 21: +this.$ = $$[$0-2]; $$[$0-2].push($$[$0]); +break; +} +}, +table: [{3:5,4:$V0,5:6,6:$V1,7:3,8:$V2,9:4,10:$V3,11:$V4,12:1,13:2,15:7,16:8,17:$V5,23:$V6},{1:[3]},{14:[1,16]},o($V7,[2,7]),o($V7,[2,8]),o($V7,[2,9]),o($V7,[2,10]),o($V7,[2,11]),o($V7,[2,12]),o($V7,[2,3]),o($V7,[2,4]),o($V7,[2,5]),o([14,18,21,22,24],[2,1]),o($V7,[2,2]),{3:20,4:$V0,18:[1,17],19:18,20:19},{3:5,4:$V0,5:6,6:$V1,7:3,8:$V2,9:4,10:$V3,11:$V4,13:23,15:7,16:8,17:$V5,23:$V6,24:[1,21],25:22},{1:[2,6]},o($V7,[2,13]),{18:[1,24],22:[1,25]},o($V8,[2,16]),{21:[1,26]},o($V7,[2,18]),{22:[1,28],24:[1,27]},o($V9,[2,20]),o($V7,[2,14]),{3:20,4:$V0,20:29},{3:5,4:$V0,5:6,6:$V1,7:3,8:$V2,9:4,10:$V3,11:$V4,13:30,15:7,16:8,17:$V5,23:$V6},o($V7,[2,19]),{3:5,4:$V0,5:6,6:$V1,7:3,8:$V2,9:4,10:$V3,11:$V4,13:31,15:7,16:8,17:$V5,23:$V6},o($V8,[2,17]),o($V8,[2,15]),o($V9,[2,21])], +defaultActions: {16:[2,6]}, +parseError: function parseError(str, hash) { + if (hash.recoverable) { + this.trace(str); + } else { + throw new Error(str); + } +}, +parse: function parse(input) { + var self = this, stack = [0], tstack = [], vstack = [null], lstack = [], table = this.table, yytext = '', yylineno = 0, yyleng = 0, recovering = 0, TERROR = 2, EOF = 1; + var args = lstack.slice.call(arguments, 1); + var lexer = Object.create(this.lexer); + var sharedState = { yy: {} }; + for (var k in this.yy) { + if (Object.prototype.hasOwnProperty.call(this.yy, k)) { + sharedState.yy[k] = this.yy[k]; + } + } + lexer.setInput(input, sharedState.yy); + sharedState.yy.lexer = lexer; + sharedState.yy.parser = this; + if (typeof lexer.yylloc == 'undefined') { + lexer.yylloc = {}; + } + var yyloc = lexer.yylloc; + lstack.push(yyloc); + var ranges = lexer.options && lexer.options.ranges; + if (typeof sharedState.yy.parseError === 'function') { + this.parseError = sharedState.yy.parseError; + } else { + this.parseError = Object.getPrototypeOf(this).parseError; + } + function popStack(n) { + stack.length = stack.length - 2 * n; + vstack.length = vstack.length - n; + lstack.length = lstack.length - n; + } + _token_stack: + function lex() { + var token; + token = lexer.lex() || EOF; + if (typeof token !== 'number') { + token = self.symbols_[token] || token; + } + return token; + } + var symbol, preErrorSymbol, state, action, a, r, yyval = {}, p, len, newState, expected; + while (true) { + state = stack[stack.length - 1]; + if (this.defaultActions[state]) { + action = this.defaultActions[state]; + } else { + if (symbol === null || typeof symbol == 'undefined') { + symbol = lex(); + } + action = table[state] && table[state][symbol]; + } + if (typeof action === 'undefined' || !action.length || !action[0]) { + var errStr = ''; + expected = []; + for (p in table[state]) { + if (this.terminals_[p] && p > TERROR) { + expected.push('\'' + this.terminals_[p] + '\''); + } + } + if (lexer.showPosition) { + errStr = 'Parse error on line ' + (yylineno + 1) + ':\n' + lexer.showPosition() + '\nExpecting ' + expected.join(', ') + ', got \'' + (this.terminals_[symbol] || symbol) + '\''; + } else { + errStr = 'Parse error on line ' + (yylineno + 1) + ': Unexpected ' + (symbol == EOF ? 'end of input' : '\'' + (this.terminals_[symbol] || symbol) + '\''); + } + this.parseError(errStr, { + text: lexer.match, + token: this.terminals_[symbol] || symbol, + line: lexer.yylineno, + loc: yyloc, + expected: expected + }); + } + if (action[0] instanceof Array && action.length > 1) { + throw new Error('Parse Error: multiple actions possible at state: ' + state + ', token: ' + symbol); + } + switch (action[0]) { + case 1: + stack.push(symbol); + vstack.push(lexer.yytext); + lstack.push(lexer.yylloc); + stack.push(action[1]); + symbol = null; + if (!preErrorSymbol) { + yyleng = lexer.yyleng; + yytext = lexer.yytext; + yylineno = lexer.yylineno; + yyloc = lexer.yylloc; + if (recovering > 0) { + recovering--; + } + } else { + symbol = preErrorSymbol; + preErrorSymbol = null; + } + break; + case 2: + len = this.productions_[action[1]][1]; + yyval.$ = vstack[vstack.length - len]; + yyval._$ = { + first_line: lstack[lstack.length - (len || 1)].first_line, + last_line: lstack[lstack.length - 1].last_line, + first_column: lstack[lstack.length - (len || 1)].first_column, + last_column: lstack[lstack.length - 1].last_column + }; + if (ranges) { + yyval._$.range = [ + lstack[lstack.length - (len || 1)].range[0], + lstack[lstack.length - 1].range[1] + ]; + } + r = this.performAction.apply(yyval, [ + yytext, + yyleng, + yylineno, + sharedState.yy, + action[1], + vstack, + lstack + ].concat(args)); + if (typeof r !== 'undefined') { + return r; + } + if (len) { + stack = stack.slice(0, -1 * len * 2); + vstack = vstack.slice(0, -1 * len); + lstack = lstack.slice(0, -1 * len); + } + stack.push(this.productions_[action[1]][0]); + vstack.push(yyval.$); + lstack.push(yyval._$); + newState = table[stack[stack.length - 2]][stack[stack.length - 1]]; + stack.push(newState); + break; + case 3: + return true; + } + } + return true; +}}; +/* generated by jison-lex 0.3.4 */ +var lexer = (function(){ +var lexer = ({ + +EOF:1, + +parseError:function parseError(str, hash) { + if (this.yy.parser) { + this.yy.parser.parseError(str, hash); + } else { + throw new Error(str); + } + }, + +// resets the lexer, sets new input +setInput:function (input, yy) { + this.yy = yy || this.yy || {}; + this._input = input; + this._more = this._backtrack = this.done = false; + this.yylineno = this.yyleng = 0; + this.yytext = this.matched = this.match = ''; + this.conditionStack = ['INITIAL']; + this.yylloc = { + first_line: 1, + first_column: 0, + last_line: 1, + last_column: 0 + }; + if (this.options.ranges) { + this.yylloc.range = [0,0]; + } + this.offset = 0; + return this; + }, + +// consumes and returns one char from the input +input:function () { + var ch = this._input[0]; + this.yytext += ch; + this.yyleng++; + this.offset++; + this.match += ch; + this.matched += ch; + var lines = ch.match(/(?:\r\n?|\n).*/g); + if (lines) { + this.yylineno++; + this.yylloc.last_line++; + } else { + this.yylloc.last_column++; + } + if (this.options.ranges) { + this.yylloc.range[1]++; + } + + this._input = this._input.slice(1); + return ch; + }, + +// unshifts one char (or a string) into the input +unput:function (ch) { + var len = ch.length; + var lines = ch.split(/(?:\r\n?|\n)/g); + + this._input = ch + this._input; + this.yytext = this.yytext.substr(0, this.yytext.length - len); + //this.yyleng -= len; + this.offset -= len; + var oldLines = this.match.split(/(?:\r\n?|\n)/g); + this.match = this.match.substr(0, this.match.length - 1); + this.matched = this.matched.substr(0, this.matched.length - 1); + + if (lines.length - 1) { + this.yylineno -= lines.length - 1; + } + var r = this.yylloc.range; + + this.yylloc = { + first_line: this.yylloc.first_line, + last_line: this.yylineno + 1, + first_column: this.yylloc.first_column, + last_column: lines ? + (lines.length === oldLines.length ? this.yylloc.first_column : 0) + + oldLines[oldLines.length - lines.length].length - lines[0].length : + this.yylloc.first_column - len + }; + + if (this.options.ranges) { + this.yylloc.range = [r[0], r[0] + this.yyleng - len]; + } + this.yyleng = this.yytext.length; + return this; + }, + +// When called from action, caches matched text and appends it on next action +more:function () { + this._more = true; + return this; + }, + +// When called from action, signals the lexer that this rule fails to match the input, so the next matching rule (regex) should be tested instead. +reject:function () { + if (this.options.backtrack_lexer) { + this._backtrack = true; + } else { + return this.parseError('Lexical error on line ' + (this.yylineno + 1) + '. You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n' + this.showPosition(), { + text: "", + token: null, + line: this.yylineno + }); + + } + return this; + }, + +// retain first n characters of the match +less:function (n) { + this.unput(this.match.slice(n)); + }, + +// displays already matched input, i.e. for error messages +pastInput:function () { + var past = this.matched.substr(0, this.matched.length - this.match.length); + return (past.length > 20 ? '...':'') + past.substr(-20).replace(/\n/g, ""); + }, + +// displays upcoming input, i.e. for error messages +upcomingInput:function () { + var next = this.match; + if (next.length < 20) { + next += this._input.substr(0, 20-next.length); + } + return (next.substr(0,20) + (next.length > 20 ? '...' : '')).replace(/\n/g, ""); + }, + +// displays the character position where the lexing error occurred, i.e. for error messages +showPosition:function () { + var pre = this.pastInput(); + var c = new Array(pre.length + 1).join("-"); + return pre + this.upcomingInput() + "\n" + c + "^"; + }, + +// test the lexed token: return FALSE when not a match, otherwise return token +test_match:function (match, indexed_rule) { + var token, + lines, + backup; + + if (this.options.backtrack_lexer) { + // save context + backup = { + yylineno: this.yylineno, + yylloc: { + first_line: this.yylloc.first_line, + last_line: this.last_line, + first_column: this.yylloc.first_column, + last_column: this.yylloc.last_column + }, + yytext: this.yytext, + match: this.match, + matches: this.matches, + matched: this.matched, + yyleng: this.yyleng, + offset: this.offset, + _more: this._more, + _input: this._input, + yy: this.yy, + conditionStack: this.conditionStack.slice(0), + done: this.done + }; + if (this.options.ranges) { + backup.yylloc.range = this.yylloc.range.slice(0); + } + } + + lines = match[0].match(/(?:\r\n?|\n).*/g); + if (lines) { + this.yylineno += lines.length; + } + this.yylloc = { + first_line: this.yylloc.last_line, + last_line: this.yylineno + 1, + first_column: this.yylloc.last_column, + last_column: lines ? + lines[lines.length - 1].length - lines[lines.length - 1].match(/\r?\n?/)[0].length : + this.yylloc.last_column + match[0].length + }; + this.yytext += match[0]; + this.match += match[0]; + this.matches = match; + this.yyleng = this.yytext.length; + if (this.options.ranges) { + this.yylloc.range = [this.offset, this.offset += this.yyleng]; + } + this._more = false; + this._backtrack = false; + this._input = this._input.slice(match[0].length); + this.matched += match[0]; + token = this.performAction.call(this, this.yy, this, indexed_rule, this.conditionStack[this.conditionStack.length - 1]); + if (this.done && this._input) { + this.done = false; + } + if (token) { + return token; + } else if (this._backtrack) { + // recover context + for (var k in backup) { + this[k] = backup[k]; + } + return false; // rule action called reject() implying the next rule should be tested instead. + } + return false; + }, + +// return next match in input +next:function () { + if (this.done) { + return this.EOF; + } + if (!this._input) { + this.done = true; + } + + var token, + match, + tempMatch, + index; + if (!this._more) { + this.yytext = ''; + this.match = ''; + } + var rules = this._currentRules(); + for (var i = 0; i < rules.length; i++) { + tempMatch = this._input.match(this.rules[rules[i]]); + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + if (this.options.backtrack_lexer) { + token = this.test_match(tempMatch, rules[i]); + if (token !== false) { + return token; + } else if (this._backtrack) { + match = false; + continue; // rule action called reject() implying a rule MISmatch. + } else { + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } + } else if (!this.options.flex) { + break; + } + } + } + if (match) { + token = this.test_match(match, rules[index]); + if (token !== false) { + return token; + } + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } + if (this._input === "") { + return this.EOF; + } else { + return this.parseError('Lexical error on line ' + (this.yylineno + 1) + '. Unrecognized text.\n' + this.showPosition(), { + text: "", + token: null, + line: this.yylineno + }); + } + }, + +// return next match that has a token +lex:function lex() { + var r = this.next(); + if (r) { + return r; + } else { + return this.lex(); + } + }, + +// activates a new lexer condition state (pushes the new lexer condition state onto the condition stack) +begin:function begin(condition) { + this.conditionStack.push(condition); + }, + +// pop the previously active lexer condition state off the condition stack +popState:function popState() { + var n = this.conditionStack.length - 1; + if (n > 0) { + return this.conditionStack.pop(); + } else { + return this.conditionStack[0]; + } + }, + +// produce the lexer rule set which is active for the currently active lexer condition state +_currentRules:function _currentRules() { + if (this.conditionStack.length && this.conditionStack[this.conditionStack.length - 1]) { + return this.conditions[this.conditionStack[this.conditionStack.length - 1]].rules; + } else { + return this.conditions["INITIAL"].rules; + } + }, + +// return the currently active lexer condition state; when an index argument is provided it produces the N-th previous condition state, if available +topState:function topState(n) { + n = this.conditionStack.length - 1 - Math.abs(n || 0); + if (n >= 0) { + return this.conditionStack[n]; + } else { + return "INITIAL"; + } + }, + +// alias for begin(condition) +pushState:function pushState(condition) { + this.begin(condition); + }, + +// return the number of states currently on the stack +stateStackSize:function stateStackSize() { + return this.conditionStack.length; + }, +options: {}, +performAction: function anonymous(yy,yy_,$avoiding_name_collisions,YY_START) { +var YYSTATE=YY_START; +switch($avoiding_name_collisions) { +case 0:/* skip whitespace */ +break; +case 1:return 6 +break; +case 2:yy_.yytext = yy_.yytext.substr(1,yy_.yyleng-2); return 4 +break; +case 3:return 17 +break; +case 4:return 18 +break; +case 5:return 23 +break; +case 6:return 24 +break; +case 7:return 22 +break; +case 8:return 21 +break; +case 9:return 10 +break; +case 10:return 11 +break; +case 11:return 8 +break; +case 12:return 14 +break; +case 13:return 'INVALID' +break; +} +}, +rules: [/^(?:\s+)/,/^(?:(-?([0-9]|[1-9][0-9]+))(\.[0-9]+)?([eE][-+]?[0-9]+)?\b)/,/^(?:"(?:\\[\\"bfnrt/]|\\u[a-fA-F0-9]{4}|[^\\\0-\x09\x0a-\x1f"])*")/,/^(?:\{)/,/^(?:\})/,/^(?:\[)/,/^(?:\])/,/^(?:,)/,/^(?::)/,/^(?:true\b)/,/^(?:false\b)/,/^(?:null\b)/,/^(?:$)/,/^(?:.)/], +conditions: {"INITIAL":{"rules":[0,1,2,3,4,5,6,7,8,9,10,11,12,13],"inclusive":true}} +}); +return lexer; +})(); +parser.lexer = lexer; +function Parser () { + this.yy = {}; +} +Parser.prototype = parser;parser.Parser = Parser; +return new Parser; +})(); + + +if (typeof require !== 'undefined' && typeof exports !== 'undefined') { +exports.parser = parser; +exports.Parser = parser.Parser; +exports.parse = function () { return parser.parse.apply(parser, arguments); }; +} diff --git a/node_modules/@mapbox/jsonlint-lines-primitives/package.json b/node_modules/@mapbox/jsonlint-lines-primitives/package.json new file mode 100644 index 0000000000000000000000000000000000000000..4a98576c4aebbb28f710f1a22386d67a42ce1764 --- /dev/null +++ b/node_modules/@mapbox/jsonlint-lines-primitives/package.json @@ -0,0 +1,34 @@ +{ + "author": "Zach Carter (http://zaa.ch)", + "name": "@mapbox/jsonlint-lines-primitives", + "description": "Validate JSON", + "keywords": [ + "json", + "validation", + "lint", + "jsonlint" + ], + "version": "2.0.2", + "preferGlobal": true, + "repository": { + "type": "git", + "url": "git://github.com/mapbox/jsonlint.git" + }, + "bugs": { + "url": "http://github.com/mapbox/jsonlint/issues" + }, + "main": "lib/jsonlint.js", + "engines": { + "node": ">= 0.6" + }, + "dependencies": {}, + "devDependencies": { + "test": "*", + "jison": "*", + "uglify-js": "*" + }, + "scripts": { + "test": "node test/all-tests.js" + }, + "optionalDependencies": {} +} diff --git a/node_modules/@mapbox/jsonlint-lines-primitives/scripts/bundle.js b/node_modules/@mapbox/jsonlint-lines-primitives/scripts/bundle.js new file mode 100644 index 0000000000000000000000000000000000000000..c8e542d7e232f350271085b4393f4e7fa88a4b17 --- /dev/null +++ b/node_modules/@mapbox/jsonlint-lines-primitives/scripts/bundle.js @@ -0,0 +1,8 @@ +var fs = require('fs'); + +var source = "var jsonlint = (function(){var require=true,module=false;var exports={};" + + fs.readFileSync(__dirname+'/../lib/jsonlint.js', 'utf8') + + "return exports;})()"; + +console.log(source); + diff --git a/node_modules/@mapbox/jsonlint-lines-primitives/src/jsonlint.l b/node_modules/@mapbox/jsonlint-lines-primitives/src/jsonlint.l new file mode 100644 index 0000000000000000000000000000000000000000..35491e11baa13dabdeadef793c18a50275e34eda --- /dev/null +++ b/node_modules/@mapbox/jsonlint-lines-primitives/src/jsonlint.l @@ -0,0 +1,24 @@ +int "-"?([0-9]|[1-9][0-9]+) +exp [eE][-+]?[0-9]+ +frac "."[0-9]+ + +%% +\s+ /* skip whitespace */ + +{int}{frac}?{exp}?\b return 'NUMBER' +\"(?:'\\'[\\"bfnrt/]|'\\u'[a-fA-F0-9]{4}|[^\\\0-\x09\x0a-\x1f"])*\" yytext = yytext.substr(1,yyleng-2); return 'STRING' + +"{" return '{' +"}" return '}' +"[" return '[' +"]" return ']' +"," return ',' +":" return ':' +"true" return 'TRUE' +"false" return 'FALSE' +"null" return 'NULL' +<> return 'EOF' +. return 'INVALID' + +%% + diff --git a/node_modules/@mapbox/jsonlint-lines-primitives/src/jsonlint.y b/node_modules/@mapbox/jsonlint-lines-primitives/src/jsonlint.y new file mode 100644 index 0000000000000000000000000000000000000000..09a171f12efad92ad9436161dd58c378f89e07bd --- /dev/null +++ b/node_modules/@mapbox/jsonlint-lines-primitives/src/jsonlint.y @@ -0,0 +1,110 @@ +%start JSONText + +/* + ECMA-262 5th Edition, 15.12.1 The JSON Grammar. +*/ + + +%% + +JSONString + : STRING + { // replace escaped characters with actual character + $$ = new String(yytext.replace(/\\(\\|")/g, "$"+"1") + .replace(/\\n/g,'\n') + .replace(/\\r/g,'\r') + .replace(/\\t/g,'\t') + .replace(/\\v/g,'\v') + .replace(/\\f/g,'\f') + .replace(/\\b/g,'\b')); + $$.__line__ = @$.first_line; + } + ; + +JSONNumber + : NUMBER + { + $$ = new Number(yytext); + $$.__line__ = @$.first_line; + } + ; + +JSONNullLiteral + : NULL + { + $$ = null; + } + ; + +JSONBooleanLiteral + : TRUE + { + $$ = new Boolean(true); + $$.__line__ = @$.first_line; + } + | FALSE + { + $$ = new Boolean(false); + $$.__line__ = @$.first_line; + } + ; + +JSONText + : JSONValue EOF + {return $$ = $1;} + ; + +JSONValue + : JSONNullLiteral + | JSONBooleanLiteral + | JSONString + | JSONNumber + | JSONObject + | JSONArray + ; + +JSONObject + : '{' '}' + {$$ = {}; Object.defineProperty($$, '__line__', { + value: @$.first_line, + enumerable: false + })} + | '{' JSONMemberList '}' + {$$ = $2; Object.defineProperty($$, '__line__', { + value: @$.first_line, + enumerable: false + })} + ; + +JSONMember + : JSONString ':' JSONValue + {$$ = [$1, $3];} + ; + +JSONMemberList + : JSONMember + {{$$ = {}; $$[$1[0]] = $1[1];}} + | JSONMemberList ',' JSONMember + {$$ = $1; $1[$3[0]] = $3[1];} + ; + +JSONArray + : '[' ']' + {$$ = []; Object.defineProperty($$, '__line__', { + value: @$.first_line, + enumerable: false + })} + | '[' JSONElementList ']' + {$$ = $2; Object.defineProperty($$, '__line__', { + value: @$.first_line, + enumerable: false + })} + ; + +JSONElementList + : JSONValue + {$$ = [$1];} + | JSONElementList ',' JSONValue + {$$ = $1; $1.push($3);} + ; + diff --git a/node_modules/@mapbox/jsonlint-lines-primitives/test/all-tests.js b/node_modules/@mapbox/jsonlint-lines-primitives/test/all-tests.js new file mode 100644 index 0000000000000000000000000000000000000000..276f372880779336a6321611b46100cf411bfe1e --- /dev/null +++ b/node_modules/@mapbox/jsonlint-lines-primitives/test/all-tests.js @@ -0,0 +1,210 @@ +var fs = require("fs"), + assert = require("assert"), + parser = require("../lib/jsonlint").parser; + +exports["test string with line break"] = function () { + var json = '{"foo": "bar\nbar"}'; + assert["throws"](function () {parser.parse(json)}, "should throw error"); +}; + +exports["test string literal"] = function () { + var json = '"foo"'; + assert.equal(parser.parse(json), "foo"); + assert.equal(parser.parse(json).__line__, 1); +}; + +exports["test number literal"] = function () { + var json = '1234'; + assert.equal(parser.parse(json), 1234); + assert.equal(parser.parse(json).__line__, 1); +}; + +exports["test null literal"] = function () { + var json = 'null'; + assert.equal(parser.parse(json), null); +}; + +exports["test boolean literal"] = function () { + var json = 'true'; + assert.equal(parser.parse(json), true); + assert.equal(parser.parse(json).__line__, 1); +}; + +exports["test unclosed array"] = function () { + var json = fs.readFileSync(__dirname + "/fails/2.json").toString(); + assert["throws"](function () {parser.parse(json)}, "should throw error"); +}; + +exports["test unquotedkey keys must be quoted"] = function () { + var json = fs.readFileSync(__dirname + "/fails/3.json").toString(); + assert["throws"](function () {parser.parse(json)}, "should throw error"); +}; + +exports["test extra comma"] = function () { + var json = fs.readFileSync(__dirname + "/fails/4.json").toString(); + assert["throws"](function () {parser.parse(json)}, "should throw error"); +}; + +exports["test double extra comma"] = function () { + var json = fs.readFileSync(__dirname + "/fails/5.json").toString(); + assert["throws"](function () {parser.parse(json)}, "should throw error"); +}; + +exports["test missing value"] = function () { + var json = fs.readFileSync(__dirname + "/fails/6.json").toString(); + assert["throws"](function () {parser.parse(json)}, "should throw error"); +}; + +exports["test comma after the close"] = function () { + var json = fs.readFileSync(__dirname + "/fails/7.json").toString(); + assert["throws"](function () {parser.parse(json)}, "should throw error"); +}; + +exports["test extra close"] = function () { + var json = fs.readFileSync(__dirname + "/fails/8.json").toString(); + assert["throws"](function () {parser.parse(json)}, "should throw error"); +}; + +exports["test extra comma after value"] = function () { + var json = fs.readFileSync(__dirname + "/fails/9.json").toString(); + assert["throws"](function () {parser.parse(json)}, "should throw error"); +}; + +exports["test extra value after close with misplaced quotes"] = function () { + var json = fs.readFileSync(__dirname + "/fails/10.json").toString(); + assert["throws"](function () {parser.parse(json)}, "should throw error"); +}; + +exports["test illegal expression addition"] = function () { + var json = fs.readFileSync(__dirname + "/fails/11.json").toString(); + assert["throws"](function () {parser.parse(json)}, "should throw error"); +}; + +exports["test illegal invocation of alert"] = function () { + var json = fs.readFileSync(__dirname + "/fails/12.json").toString(); + assert["throws"](function () {parser.parse(json)}, "should throw error"); +}; + +exports["test numbers cannot have leading zeroes"] = function () { + var json = fs.readFileSync(__dirname + "/fails/13.json").toString(); + assert["throws"](function () {parser.parse(json)}, "should throw error"); +}; + +exports["test numbers cannot be hex"] = function () { + var json = fs.readFileSync(__dirname + "/fails/14.json").toString(); + assert["throws"](function () {parser.parse(json)}, "should throw error"); +}; + +exports["test illegal backslash escape \\0"] = function () { + var json = fs.readFileSync(__dirname + "/fails/15.json").toString(); + assert["throws"](function () {parser.parse(json)}, "should throw error"); +}; + +exports["test unquoted text"] = function () { + var json = fs.readFileSync(__dirname + "/fails/16.json").toString(); + assert["throws"](function () {parser.parse(json)}, "should throw error"); +}; + +exports["test illegal backslash escape \\x"] = function () { + var json = fs.readFileSync(__dirname + "/fails/17.json").toString(); + assert["throws"](function () {parser.parse(json)}, "should throw error"); +}; + +exports["test missing colon"] = function () { + var json = fs.readFileSync(__dirname + "/fails/19.json") + assert["throws"](function () {parser.parse(json)}, "should throw error"); +}; + +exports["test double colon"] = function () { + var json = fs.readFileSync(__dirname + "/fails/20.json").toString(); + assert["throws"](function () {parser.parse(json)}, "should throw error"); +}; + +exports["test comma instead of colon"] = function () { + var json = fs.readFileSync(__dirname + "/fails/21.json").toString(); + assert["throws"](function () {parser.parse(json)}, "should throw error"); +}; + +exports["test colon instead of comma"] = function () { + var json = fs.readFileSync(__dirname + "/fails/22.json").toString(); + assert["throws"](function () {parser.parse(json)}, "should throw error"); +}; + +exports["test bad raw value"] = function () { + var json = fs.readFileSync(__dirname + "/fails/23.json").toString(); + assert["throws"](function () {parser.parse(json)}, "should throw error"); +}; + +exports["test single quotes"] = function () { + var json = fs.readFileSync(__dirname + "/fails/24.json").toString(); + assert["throws"](function () {parser.parse(json)}, "should throw error"); +}; + +exports["test tab character in string"] = function () { + var json = fs.readFileSync(__dirname + "/fails/25.json").toString(); + assert["throws"](function () {parser.parse(json)}, "should throw error"); +}; + +exports["test tab character in string 2"] = function () { + var json = fs.readFileSync(__dirname + "/fails/26.json").toString(); + assert["throws"](function () {parser.parse(json)}, "should throw error"); +}; + +exports["test line break in string"] = function () { + var json = fs.readFileSync(__dirname + "/fails/27.json").toString(); + assert["throws"](function () {parser.parse(json)}, "should throw error"); +}; + +exports["test line break in string in array"] = function () { + var json = fs.readFileSync(__dirname + "/fails/28.json").toString(); + assert["throws"](function () {parser.parse(json)}, "should throw error"); +}; + +exports["test 0e"] = function () { + var json = fs.readFileSync(__dirname + "/fails/29.json").toString(); + assert["throws"](function () {parser.parse(json)}, "should throw error"); +}; + +exports["test 0e+"] = function () { + var json = fs.readFileSync(__dirname + "/fails/30.json").toString(); + assert["throws"](function () {parser.parse(json)}, "should throw error"); +}; + +exports["test 0e+ 1"] = function () { + var json = fs.readFileSync(__dirname + "/fails/31.json").toString(); + assert["throws"](function () {parser.parse(json)}, "should throw error"); +}; + +exports["test comma instead of closing brace"] = function () { + var json = fs.readFileSync(__dirname + "/fails/32.json").toString(); + assert["throws"](function () {parser.parse(json)}, "should throw error"); +}; + +exports["test bracket mismatch"] = function () { + var json = fs.readFileSync(__dirname + "/fails/33.json").toString(); + assert["throws"](function () {parser.parse(json)}, "should throw error"); +} + +exports["test extra brace"] = function () { + var json = fs.readFileSync(__dirname + "/fails/34.json").toString(); + assert["throws"](function () {parser.parse(json)}, "should throw error"); +} + +exports["test pass-1"] = function () { + var json = fs.readFileSync(__dirname + "/passes/1.json").toString(); + assert.doesNotThrow(function () {parser.parse(json)}, "should pass"); +} + +exports["test pass-2"] = function () { + var json = fs.readFileSync(__dirname + "/passes/2.json").toString(); + assert.doesNotThrow(function () {parser.parse(json)}, "should pass"); +} + +exports["test pass-3"] = function () { + var json = fs.readFileSync(__dirname + "/passes/3.json").toString(); + assert.doesNotThrow(function () {parser.parse(json)}, "should pass"); +} + +if (require.main === module) { + require("test").run(exports); +} diff --git a/node_modules/@mapbox/jsonlint-lines-primitives/test/fails/10.json b/node_modules/@mapbox/jsonlint-lines-primitives/test/fails/10.json new file mode 100644 index 0000000000000000000000000000000000000000..5d8c0047bd522dfa9fbc642051ed76bd3162d936 --- /dev/null +++ b/node_modules/@mapbox/jsonlint-lines-primitives/test/fails/10.json @@ -0,0 +1 @@ +{"Extra value after close": true} "misplaced quoted value" \ No newline at end of file diff --git a/node_modules/@mapbox/jsonlint-lines-primitives/test/fails/11.json b/node_modules/@mapbox/jsonlint-lines-primitives/test/fails/11.json new file mode 100644 index 0000000000000000000000000000000000000000..76eb95b4583c8ee74eee3bdc25e1db69e1aaf4bb --- /dev/null +++ b/node_modules/@mapbox/jsonlint-lines-primitives/test/fails/11.json @@ -0,0 +1 @@ +{"Illegal expression": 1 + 2} \ No newline at end of file diff --git a/node_modules/@mapbox/jsonlint-lines-primitives/test/fails/12.json b/node_modules/@mapbox/jsonlint-lines-primitives/test/fails/12.json new file mode 100644 index 0000000000000000000000000000000000000000..77580a4522d8c79245851e72a3644a0709b3d28c --- /dev/null +++ b/node_modules/@mapbox/jsonlint-lines-primitives/test/fails/12.json @@ -0,0 +1 @@ +{"Illegal invocation": alert()} \ No newline at end of file diff --git a/node_modules/@mapbox/jsonlint-lines-primitives/test/fails/13.json b/node_modules/@mapbox/jsonlint-lines-primitives/test/fails/13.json new file mode 100644 index 0000000000000000000000000000000000000000..379406b59bdb943f145afea98ff1bbc45d43ff45 --- /dev/null +++ b/node_modules/@mapbox/jsonlint-lines-primitives/test/fails/13.json @@ -0,0 +1 @@ +{"Numbers cannot have leading zeroes": 013} \ No newline at end of file diff --git a/node_modules/@mapbox/jsonlint-lines-primitives/test/fails/14.json b/node_modules/@mapbox/jsonlint-lines-primitives/test/fails/14.json new file mode 100644 index 0000000000000000000000000000000000000000..0ed366b38a34f551c25735bdcb9282d27beae026 --- /dev/null +++ b/node_modules/@mapbox/jsonlint-lines-primitives/test/fails/14.json @@ -0,0 +1 @@ +{"Numbers cannot be hex": 0x14} \ No newline at end of file diff --git a/node_modules/@mapbox/jsonlint-lines-primitives/test/fails/15.json b/node_modules/@mapbox/jsonlint-lines-primitives/test/fails/15.json new file mode 100644 index 0000000000000000000000000000000000000000..fc8376b605da69dda23f3fcdd9816dcbf2e736cc --- /dev/null +++ b/node_modules/@mapbox/jsonlint-lines-primitives/test/fails/15.json @@ -0,0 +1 @@ +["Illegal backslash escape: \x15"] \ No newline at end of file diff --git a/node_modules/@mapbox/jsonlint-lines-primitives/test/fails/16.json b/node_modules/@mapbox/jsonlint-lines-primitives/test/fails/16.json new file mode 100644 index 0000000000000000000000000000000000000000..3fe21d4b532498c8b90872ef571c6867f45e645f --- /dev/null +++ b/node_modules/@mapbox/jsonlint-lines-primitives/test/fails/16.json @@ -0,0 +1 @@ +[\naked] \ No newline at end of file diff --git a/node_modules/@mapbox/jsonlint-lines-primitives/test/fails/17.json b/node_modules/@mapbox/jsonlint-lines-primitives/test/fails/17.json new file mode 100644 index 0000000000000000000000000000000000000000..62b9214aeda6d74a72ebeceedf0aae3609f1c638 --- /dev/null +++ b/node_modules/@mapbox/jsonlint-lines-primitives/test/fails/17.json @@ -0,0 +1 @@ +["Illegal backslash escape: \017"] \ No newline at end of file diff --git a/node_modules/@mapbox/jsonlint-lines-primitives/test/fails/19.json b/node_modules/@mapbox/jsonlint-lines-primitives/test/fails/19.json new file mode 100644 index 0000000000000000000000000000000000000000..3b9c46fa9a296c9d8c35ce4a6592d8bb7ffe748a --- /dev/null +++ b/node_modules/@mapbox/jsonlint-lines-primitives/test/fails/19.json @@ -0,0 +1 @@ +{"Missing colon" null} \ No newline at end of file diff --git a/node_modules/@mapbox/jsonlint-lines-primitives/test/fails/2.json b/node_modules/@mapbox/jsonlint-lines-primitives/test/fails/2.json new file mode 100644 index 0000000000000000000000000000000000000000..6b7c11e5a56537f81e651980359c62e263f7399f --- /dev/null +++ b/node_modules/@mapbox/jsonlint-lines-primitives/test/fails/2.json @@ -0,0 +1 @@ +["Unclosed array" \ No newline at end of file diff --git a/node_modules/@mapbox/jsonlint-lines-primitives/test/fails/20.json b/node_modules/@mapbox/jsonlint-lines-primitives/test/fails/20.json new file mode 100644 index 0000000000000000000000000000000000000000..27c1af3e72ee37bbf64ccd7b77c5bad8cdea1557 --- /dev/null +++ b/node_modules/@mapbox/jsonlint-lines-primitives/test/fails/20.json @@ -0,0 +1 @@ +{"Double colon":: null} \ No newline at end of file diff --git a/node_modules/@mapbox/jsonlint-lines-primitives/test/fails/21.json b/node_modules/@mapbox/jsonlint-lines-primitives/test/fails/21.json new file mode 100644 index 0000000000000000000000000000000000000000..62474573b2160adefc3dc669b39200ea659d6e59 --- /dev/null +++ b/node_modules/@mapbox/jsonlint-lines-primitives/test/fails/21.json @@ -0,0 +1 @@ +{"Comma instead of colon", null} \ No newline at end of file diff --git a/node_modules/@mapbox/jsonlint-lines-primitives/test/fails/22.json b/node_modules/@mapbox/jsonlint-lines-primitives/test/fails/22.json new file mode 100644 index 0000000000000000000000000000000000000000..a7752581bcf7f3b901aef052a2df541c1285b6c2 --- /dev/null +++ b/node_modules/@mapbox/jsonlint-lines-primitives/test/fails/22.json @@ -0,0 +1 @@ +["Colon instead of comma": false] \ No newline at end of file diff --git a/node_modules/@mapbox/jsonlint-lines-primitives/test/fails/23.json b/node_modules/@mapbox/jsonlint-lines-primitives/test/fails/23.json new file mode 100644 index 0000000000000000000000000000000000000000..494add1ca190e12acd1c8e34ac819a6316c927bc --- /dev/null +++ b/node_modules/@mapbox/jsonlint-lines-primitives/test/fails/23.json @@ -0,0 +1 @@ +["Bad value", truth] \ No newline at end of file diff --git a/node_modules/@mapbox/jsonlint-lines-primitives/test/fails/24.json b/node_modules/@mapbox/jsonlint-lines-primitives/test/fails/24.json new file mode 100644 index 0000000000000000000000000000000000000000..caff239bfc36297da08828095105bb497b8aef2a --- /dev/null +++ b/node_modules/@mapbox/jsonlint-lines-primitives/test/fails/24.json @@ -0,0 +1 @@ +['single quote'] \ No newline at end of file diff --git a/node_modules/@mapbox/jsonlint-lines-primitives/test/fails/25.json b/node_modules/@mapbox/jsonlint-lines-primitives/test/fails/25.json new file mode 100644 index 0000000000000000000000000000000000000000..8b7ad23e010314591d914519996c28483b5dadc8 --- /dev/null +++ b/node_modules/@mapbox/jsonlint-lines-primitives/test/fails/25.json @@ -0,0 +1 @@ +[" tab character in string "] \ No newline at end of file diff --git a/node_modules/@mapbox/jsonlint-lines-primitives/test/fails/26.json b/node_modules/@mapbox/jsonlint-lines-primitives/test/fails/26.json new file mode 100644 index 0000000000000000000000000000000000000000..845d26a6a54398c49cd492e6836c0d1987f554e4 --- /dev/null +++ b/node_modules/@mapbox/jsonlint-lines-primitives/test/fails/26.json @@ -0,0 +1 @@ +["tab\ character\ in\ string\ "] \ No newline at end of file diff --git a/node_modules/@mapbox/jsonlint-lines-primitives/test/fails/27.json b/node_modules/@mapbox/jsonlint-lines-primitives/test/fails/27.json new file mode 100644 index 0000000000000000000000000000000000000000..6b01a2ca4a97ec36604771dcc3175bbcda865d85 --- /dev/null +++ b/node_modules/@mapbox/jsonlint-lines-primitives/test/fails/27.json @@ -0,0 +1,2 @@ +["line +break"] \ No newline at end of file diff --git a/node_modules/@mapbox/jsonlint-lines-primitives/test/fails/28.json b/node_modules/@mapbox/jsonlint-lines-primitives/test/fails/28.json new file mode 100644 index 0000000000000000000000000000000000000000..621a0101c664a619457d16f1107a677c911481b4 --- /dev/null +++ b/node_modules/@mapbox/jsonlint-lines-primitives/test/fails/28.json @@ -0,0 +1,2 @@ +["line\ +break"] \ No newline at end of file diff --git a/node_modules/@mapbox/jsonlint-lines-primitives/test/fails/29.json b/node_modules/@mapbox/jsonlint-lines-primitives/test/fails/29.json new file mode 100644 index 0000000000000000000000000000000000000000..47ec421bb6242648e80b2b465049acbae1e6e44a --- /dev/null +++ b/node_modules/@mapbox/jsonlint-lines-primitives/test/fails/29.json @@ -0,0 +1 @@ +[0e] \ No newline at end of file diff --git a/node_modules/@mapbox/jsonlint-lines-primitives/test/fails/3.json b/node_modules/@mapbox/jsonlint-lines-primitives/test/fails/3.json new file mode 100644 index 0000000000000000000000000000000000000000..168c81eb78537ea4006ea0a46b67851d9995564d --- /dev/null +++ b/node_modules/@mapbox/jsonlint-lines-primitives/test/fails/3.json @@ -0,0 +1 @@ +{unquoted_key: "keys must be quoted"} \ No newline at end of file diff --git a/node_modules/@mapbox/jsonlint-lines-primitives/test/fails/30.json b/node_modules/@mapbox/jsonlint-lines-primitives/test/fails/30.json new file mode 100644 index 0000000000000000000000000000000000000000..8ab0bc4b8b2c73b616a45931d05720555a2f7762 --- /dev/null +++ b/node_modules/@mapbox/jsonlint-lines-primitives/test/fails/30.json @@ -0,0 +1 @@ +[0e+] \ No newline at end of file diff --git a/node_modules/@mapbox/jsonlint-lines-primitives/test/fails/31.json b/node_modules/@mapbox/jsonlint-lines-primitives/test/fails/31.json new file mode 100644 index 0000000000000000000000000000000000000000..1cce602b518fc6e7f164a58cc710def27e64b8a5 --- /dev/null +++ b/node_modules/@mapbox/jsonlint-lines-primitives/test/fails/31.json @@ -0,0 +1 @@ +[0e+-1] \ No newline at end of file diff --git a/node_modules/@mapbox/jsonlint-lines-primitives/test/fails/32.json b/node_modules/@mapbox/jsonlint-lines-primitives/test/fails/32.json new file mode 100644 index 0000000000000000000000000000000000000000..45cba7396ff7462dd6de005c32fd2a95c5318e5f --- /dev/null +++ b/node_modules/@mapbox/jsonlint-lines-primitives/test/fails/32.json @@ -0,0 +1 @@ +{"Comma instead if closing brace": true, \ No newline at end of file diff --git a/node_modules/@mapbox/jsonlint-lines-primitives/test/fails/33.json b/node_modules/@mapbox/jsonlint-lines-primitives/test/fails/33.json new file mode 100644 index 0000000000000000000000000000000000000000..ca5eb19dc97f5ca363ff33a4c3644ad28e612679 --- /dev/null +++ b/node_modules/@mapbox/jsonlint-lines-primitives/test/fails/33.json @@ -0,0 +1 @@ +["mismatch"} \ No newline at end of file diff --git a/node_modules/@mapbox/jsonlint-lines-primitives/test/fails/34.json b/node_modules/@mapbox/jsonlint-lines-primitives/test/fails/34.json new file mode 100644 index 0000000000000000000000000000000000000000..11ef16af64c145edb681f27e5934ad601705b228 --- /dev/null +++ b/node_modules/@mapbox/jsonlint-lines-primitives/test/fails/34.json @@ -0,0 +1 @@ +{"extra brace": 1}} diff --git a/node_modules/@mapbox/jsonlint-lines-primitives/test/fails/4.json b/node_modules/@mapbox/jsonlint-lines-primitives/test/fails/4.json new file mode 100644 index 0000000000000000000000000000000000000000..9de168bf34e2e368d044bccc099d44b02316de66 --- /dev/null +++ b/node_modules/@mapbox/jsonlint-lines-primitives/test/fails/4.json @@ -0,0 +1 @@ +["extra comma",] \ No newline at end of file diff --git a/node_modules/@mapbox/jsonlint-lines-primitives/test/fails/5.json b/node_modules/@mapbox/jsonlint-lines-primitives/test/fails/5.json new file mode 100644 index 0000000000000000000000000000000000000000..ddf3ce3d2409467011ec7545551d5d078bce1bfd --- /dev/null +++ b/node_modules/@mapbox/jsonlint-lines-primitives/test/fails/5.json @@ -0,0 +1 @@ +["double extra comma",,] \ No newline at end of file diff --git a/node_modules/@mapbox/jsonlint-lines-primitives/test/fails/6.json b/node_modules/@mapbox/jsonlint-lines-primitives/test/fails/6.json new file mode 100644 index 0000000000000000000000000000000000000000..ed91580e1b1c15194a9a758f1b231575074722db --- /dev/null +++ b/node_modules/@mapbox/jsonlint-lines-primitives/test/fails/6.json @@ -0,0 +1 @@ +[ , "<-- missing value"] \ No newline at end of file diff --git a/node_modules/@mapbox/jsonlint-lines-primitives/test/fails/7.json b/node_modules/@mapbox/jsonlint-lines-primitives/test/fails/7.json new file mode 100644 index 0000000000000000000000000000000000000000..8a96af3e4ee6c7fffd8da641dedcd750a5cc4d9d --- /dev/null +++ b/node_modules/@mapbox/jsonlint-lines-primitives/test/fails/7.json @@ -0,0 +1 @@ +["Comma after the close"], \ No newline at end of file diff --git a/node_modules/@mapbox/jsonlint-lines-primitives/test/fails/8.json b/node_modules/@mapbox/jsonlint-lines-primitives/test/fails/8.json new file mode 100644 index 0000000000000000000000000000000000000000..b28479c6ecb21a801d6988b9ea39a4eb00a64702 --- /dev/null +++ b/node_modules/@mapbox/jsonlint-lines-primitives/test/fails/8.json @@ -0,0 +1 @@ +["Extra close"]] \ No newline at end of file diff --git a/node_modules/@mapbox/jsonlint-lines-primitives/test/fails/9.json b/node_modules/@mapbox/jsonlint-lines-primitives/test/fails/9.json new file mode 100644 index 0000000000000000000000000000000000000000..5815574f363e58cf91578e909ef4dabb402a75de --- /dev/null +++ b/node_modules/@mapbox/jsonlint-lines-primitives/test/fails/9.json @@ -0,0 +1 @@ +{"Extra comma": true,} \ No newline at end of file diff --git a/node_modules/@mapbox/jsonlint-lines-primitives/test/passes/1.json b/node_modules/@mapbox/jsonlint-lines-primitives/test/passes/1.json new file mode 100644 index 0000000000000000000000000000000000000000..70e26854369282e625e75b302782f581e610f2b3 --- /dev/null +++ b/node_modules/@mapbox/jsonlint-lines-primitives/test/passes/1.json @@ -0,0 +1,58 @@ +[ + "JSON Test Pattern pass1", + {"object with 1 member":["array with 1 element"]}, + {}, + [], + -42, + true, + false, + null, + { + "integer": 1234567890, + "real": -9876.543210, + "e": 0.123456789e-12, + "E": 1.234567890E+34, + "": 23456789012E66, + "zero": 0, + "one": 1, + "space": " ", + "quote": "\"", + "backslash": "\\", + "controls": "\b\f\n\r\t", + "slash": "/ & \/", + "alpha": "abcdefghijklmnopqrstuvwyz", + "ALPHA": "ABCDEFGHIJKLMNOPQRSTUVWYZ", + "digit": "0123456789", + "0123456789": "digit", + "special": "`1~!@#$%^&*()_+-={':[,]}|;.?", + "hex": "\u0123\u4567\u89AB\uCDEF\uabcd\uef4A", + "true": true, + "false": false, + "null": null, + "array":[ ], + "object":{ }, + "address": "50 St. James Street", + "url": "http://www.JSON.org/", + "comment": "// /* */": " ", + " s p a c e d " :[1,2 , 3 + +, + +4 , 5 , 6 ,7 ],"compact":[1,2,3,4,5,6,7], + "jsontext": "{\"object with 1 member\":[\"array with 1 element\"]}", + "quotes": "" \u0022 %22 0x22 034 "", + "\/\\\"\uCAFE\uBABE\uAB98\uFCDE\ubcda\uef4A\b\f\n\r\t`1~!@#$%^&*()_+-=[]{}|;:',./<>?" +: "A key can be any string" + }, + 0.5 ,98.6 +, +99.44 +, + +1066, +1e1, +0.1e1, +1e-1, +1e00,2e+00,2e-00 +,"rosebud"] \ No newline at end of file diff --git a/node_modules/@mapbox/jsonlint-lines-primitives/test/passes/2.json b/node_modules/@mapbox/jsonlint-lines-primitives/test/passes/2.json new file mode 100644 index 0000000000000000000000000000000000000000..d3c63c7ad845e4cedd0c70d13102b38c51ec197a --- /dev/null +++ b/node_modules/@mapbox/jsonlint-lines-primitives/test/passes/2.json @@ -0,0 +1 @@ +[[[[[[[[[[[[[[[[[[["Not too deep"]]]]]]]]]]]]]]]]]]] \ No newline at end of file diff --git a/node_modules/@mapbox/jsonlint-lines-primitives/test/passes/3.json b/node_modules/@mapbox/jsonlint-lines-primitives/test/passes/3.json new file mode 100644 index 0000000000000000000000000000000000000000..4528d51f1ac615e7e11dbb1321dc99187705f0d8 --- /dev/null +++ b/node_modules/@mapbox/jsonlint-lines-primitives/test/passes/3.json @@ -0,0 +1,6 @@ +{ + "JSON Test Pattern pass3": { + "The outermost value": "must be an object or array.", + "In this test": "It is an object." + } +} diff --git a/node_modules/@mapbox/jsonlint-lines-primitives/web/json2.js b/node_modules/@mapbox/jsonlint-lines-primitives/web/json2.js new file mode 100644 index 0000000000000000000000000000000000000000..7044c6de7e2e279172ffbb1e6d29d4f950c20806 --- /dev/null +++ b/node_modules/@mapbox/jsonlint-lines-primitives/web/json2.js @@ -0,0 +1,334 @@ + +/*jslint evil: true, strict: false */ + +/*members "", "\b", "\t", "\n", "\f", "\r", "\"", JSON, "\\", apply, + call, charCodeAt, getUTCDate, getUTCFullYear, getUTCHours, + getUTCMinutes, getUTCMonth, getUTCSeconds, hasOwnProperty, join, + lastIndex, length, parse, prototype, push, replace, slice, stringify, + test, toJSON, toString, valueOf +*/ + + +// Create a JSON object only if one does not already exist. We create the +// methods in a closure to avoid creating global variables. + +if (!this.JSON) { + this.JSON = {}; +} + +(function () { + + function f(n) { + // Format integers to have at least two digits. + return n < 10 ? '0' + n : n; + } + + if (typeof Date.prototype.toJSON !== 'function') { + + Date.prototype.toJSON = function (key) { + + return isFinite(this.valueOf()) ? + this.getUTCFullYear() + '-' + + f(this.getUTCMonth() + 1) + '-' + + f(this.getUTCDate()) + 'T' + + f(this.getUTCHours()) + ':' + + f(this.getUTCMinutes()) + ':' + + f(this.getUTCSeconds()) + 'Z' : null; + }; + + String.prototype.toJSON = + Number.prototype.toJSON = + Boolean.prototype.toJSON = function (key) { + return this.valueOf(); + }; + } + + var cx = /[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g, + escapable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g, + gap, + indent, + meta = { // table of character substitutions + '\b': '\\b', + '\t': '\\t', + '\n': '\\n', + '\f': '\\f', + '\r': '\\r', + '"' : '\\"', + '\\': '\\\\' + }, + rep; + + + function quote(string) { + +// If the string contains no control characters, no quote characters, and no +// backslash characters, then we can safely slap some quotes around it. +// Otherwise we must also replace the offending characters with safe escape +// sequences. + + escapable.lastIndex = 0; + return escapable.test(string) ? + '"' + string.replace(escapable, function (a) { + var c = meta[a]; + return typeof c === 'string' ? c : + '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4); + }) + '"' : + '"' + string + '"'; + } + + + function str(key, holder) { + +// Produce a string from holder[key]. + + var i, // The loop counter. + k, // The member key. + v, // The member value. + length, + mind = gap, + partial, + value = holder[key]; + +// If the value has a toJSON method, call it to obtain a replacement value. + + if (value && typeof value === 'object' && + typeof value.toJSON === 'function') { + value = value.toJSON(key); + } + +// If we were called with a replacer function, then call the replacer to +// obtain a replacement value. + + if (typeof rep === 'function') { + value = rep.call(holder, key, value); + } + +// What happens next depends on the value's type. + + switch (typeof value) { + case 'string': + return quote(value); + + case 'number': + +// JSON numbers must be finite. Encode non-finite numbers as null. + + return isFinite(value) ? String(value) : 'null'; + + case 'boolean': + case 'null': + +// If the value is a boolean or null, convert it to a string. Note: +// typeof null does not produce 'null'. The case is included here in +// the remote chance that this gets fixed someday. + + return String(value); + +// If the type is 'object', we might be dealing with an object or an array or +// null. + + case 'object': + +// Due to a specification blunder in ECMAScript, typeof null is 'object', +// so watch out for that case. + + if (!value) { + return 'null'; + } + +// Make an array to hold the partial results of stringifying this object value. + + gap += indent; + partial = []; + +// Is the value an array? + + if (Object.prototype.toString.apply(value) === '[object Array]') { + +// The value is an array. Stringify every element. Use null as a placeholder +// for non-JSON values. + + length = value.length; + for (i = 0; i < length; i += 1) { + partial[i] = str(i, value) || 'null'; + } + +// Join all of the elements together, separated with commas, and wrap them in +// brackets. + + v = partial.length === 0 ? '[]' : + gap ? '[\n' + gap + + partial.join(',\n' + gap) + '\n' + + mind + ']' : + '[' + partial.join(',') + ']'; + gap = mind; + return v; + } + +// If the replacer is an array, use it to select the members to be stringified. + + if (rep && typeof rep === 'object') { + length = rep.length; + for (i = 0; i < length; i += 1) { + k = rep[i]; + if (typeof k === 'string') { + v = str(k, value); + if (v) { + partial.push(quote(k) + (gap ? ': ' : ':') + v); + } + } + } + } else { + +// Otherwise, iterate through all of the keys in the object. + + for (k in value) { + if (Object.hasOwnProperty.call(value, k)) { + v = str(k, value); + if (v) { + partial.push(quote(k) + (gap ? ': ' : ':') + v); + } + } + } + } + +// Join all of the member texts together, separated with commas, +// and wrap them in braces. + + v = partial.length === 0 ? '{}' : + gap ? '{\n' + gap + partial.join(',\n' + gap) + '\n' + + mind + '}' : '{' + partial.join(',') + '}'; + gap = mind; + return v; + } + } + +// If the JSON object does not yet have a stringify method, give it one. + + if (typeof JSON.stringify !== 'function') { + JSON.stringify = function (value, replacer, space) { + +// The stringify method takes a value and an optional replacer, and an optional +// space parameter, and returns a JSON text. The replacer can be a function +// that can replace values, or an array of strings that will select the keys. +// A default replacer method can be provided. Use of the space parameter can +// produce text that is more easily readable. + + var i; + gap = ''; + indent = ''; + +// If the space parameter is a number, make an indent string containing that +// many spaces. + + if (typeof space === 'number') { + for (i = 0; i < space; i += 1) { + indent += ' '; + } + +// If the space parameter is a string, it will be used as the indent string. + + } else if (typeof space === 'string') { + indent = space; + } + +// If there is a replacer, it must be a function or an array. +// Otherwise, throw an error. + + rep = replacer; + if (replacer && typeof replacer !== 'function' && + (typeof replacer !== 'object' || + typeof replacer.length !== 'number')) { + throw new Error('JSON.stringify'); + } + +// Make a fake root object containing our value under the key of ''. +// Return the result of stringifying the value. + + return str('', {'': value}); + }; + } + + +// If the JSON object does not yet have a parse method, give it one. + + if (typeof JSON.parse !== 'function') { + JSON.parse = function (text, reviver) { + +// The parse method takes a text and an optional reviver function, and returns +// a JavaScript value if the text is a valid JSON text. + + var j; + + function walk(holder, key) { + +// The walk method is used to recursively walk the resulting structure so +// that modifications can be made. + + var k, v, value = holder[key]; + if (value && typeof value === 'object') { + for (k in value) { + if (Object.hasOwnProperty.call(value, k)) { + v = walk(value, k); + if (v !== undefined) { + value[k] = v; + } else { + delete value[k]; + } + } + } + } + return reviver.call(holder, key, value); + } + + +// Parsing happens in four stages. In the first stage, we replace certain +// Unicode characters with escape sequences. JavaScript handles many characters +// incorrectly, either silently deleting them, or treating them as line endings. + + cx.lastIndex = 0; + if (cx.test(text)) { + text = text.replace(cx, function (a) { + return '\\u' + + ('0000' + a.charCodeAt(0).toString(16)).slice(-4); + }); + } + +// In the second stage, we run the text against regular expressions that look +// for non-JSON patterns. We are especially concerned with '()' and 'new' +// because they can cause invocation, and '=' because it can cause mutation. +// But just to be safe, we want to reject all unexpected forms. + +// We split the second stage into 4 regexp operations in order to work around +// crippling inefficiencies in IE's and Safari's regexp engines. First we +// replace the JSON backslash pairs with '@' (a non-JSON character). Second, we +// replace all simple value tokens with ']' characters. Third, we delete all +// open brackets that follow a colon or comma or that begin the text. Finally, +// we look to see that the remaining characters are only whitespace or ']' or +// ',' or ':' or '{' or '}'. If that is so, then the text is safe for eval. + + if (/^[\],:{}\s]*$/. +test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, '@'). +replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, ']'). +replace(/(?:^|:|,)(?:\s*\[)+/g, ''))) { + +// In the third stage we use the eval function to compile the text into a +// JavaScript structure. The '{' operator is subject to a syntactic ambiguity +// in JavaScript: it can begin a block or an object literal. We wrap the text +// in parens to eliminate the ambiguity. + + j = eval('(' + text + ')'); + +// In the optional fourth stage, we recursively walk the new structure, passing +// each name/value pair to a reviver function for possible transformation. + + return typeof reviver === 'function' ? + walk({'': j}, '') : j; + } + +// If the text is not JSON parseable, then a SyntaxError is thrown. + + throw new SyntaxError('JSON.parse'); + }; + } +}()); diff --git a/node_modules/@mapbox/jsonlint-lines-primitives/web/jsonlint.html b/node_modules/@mapbox/jsonlint-lines-primitives/web/jsonlint.html new file mode 100644 index 0000000000000000000000000000000000000000..b0880660c7384e55b7d7f8c2790cd1939cd16d66 --- /dev/null +++ b/node_modules/@mapbox/jsonlint-lines-primitives/web/jsonlint.html @@ -0,0 +1,59 @@ + + + + + JSON Lint + + + + + + +

JSON Lint

+

A pure JavaScript version of the service provided at jsonlint.com.

+ +

+ + +

+

Results

+

+  

project on github

+ + diff --git a/node_modules/@mapbox/jsonlint-lines-primitives/web/jsonlint.js b/node_modules/@mapbox/jsonlint-lines-primitives/web/jsonlint.js new file mode 100644 index 0000000000000000000000000000000000000000..0766e623fd073d3dcd5ffeb0aa1efd2dab134fe2 --- /dev/null +++ b/node_modules/@mapbox/jsonlint-lines-primitives/web/jsonlint.js @@ -0,0 +1 @@ +var jsonlint=function(){var require=true,module=false;var exports={};var parser=function(){var o=function(k,v,o,l){for(o=o||{},l=k.length;l--;o[k[l]]=v);return o},$V0=[1,12],$V1=[1,13],$V2=[1,9],$V3=[1,10],$V4=[1,11],$V5=[1,14],$V6=[1,15],$V7=[14,18,22,24],$V8=[18,22],$V9=[22,24];var parser={trace:function trace(){},yy:{},symbols_:{error:2,JSONString:3,STRING:4,JSONNumber:5,NUMBER:6,JSONNullLiteral:7,NULL:8,JSONBooleanLiteral:9,TRUE:10,FALSE:11,JSONText:12,JSONValue:13,EOF:14,JSONObject:15,JSONArray:16,"{":17,"}":18,JSONMemberList:19,JSONMember:20,":":21,",":22,"[":23,"]":24,JSONElementList:25,$accept:0,$end:1},terminals_:{2:"error",4:"STRING",6:"NUMBER",8:"NULL",10:"TRUE",11:"FALSE",14:"EOF",17:"{",18:"}",21:":",22:",",23:"[",24:"]"},productions_:[0,[3,1],[5,1],[7,1],[9,1],[9,1],[12,2],[13,1],[13,1],[13,1],[13,1],[13,1],[13,1],[15,2],[15,3],[20,3],[19,1],[19,3],[16,2],[16,3],[25,1],[25,3]],performAction:function anonymous(yytext,yyleng,yylineno,yy,yystate,$$,_$){var $0=$$.length-1;switch(yystate){case 1:this.$=new String(yytext.replace(/\\(\\|")/g,"$"+"1").replace(/\\n/g,"\n").replace(/\\r/g,"\r").replace(/\\t/g," ").replace(/\\v/g," ").replace(/\\f/g,"\f").replace(/\\b/g,"\b"));this.$.__line__=this._$.first_line;break;case 2:this.$=new Number(yytext);this.$.__line__=this._$.first_line;break;case 3:this.$=null;break;case 4:this.$=new Boolean(true);this.$.__line__=this._$.first_line;break;case 5:this.$=new Boolean(false);this.$.__line__=this._$.first_line;break;case 6:return this.$=$$[$0-1];break;case 13:this.$={};Object.defineProperty(this.$,"__line__",{value:this._$.first_line,enumerable:false});break;case 14:case 19:this.$=$$[$0-1];Object.defineProperty(this.$,"__line__",{value:this._$.first_line,enumerable:false});break;case 15:this.$=[$$[$0-2],$$[$0]];break;case 16:this.$={};this.$[$$[$0][0]]=$$[$0][1];break;case 17:this.$=$$[$0-2];$$[$0-2][$$[$0][0]]=$$[$0][1];break;case 18:this.$=[];Object.defineProperty(this.$,"__line__",{value:this._$.first_line,enumerable:false});break;case 20:this.$=[$$[$0]];break;case 21:this.$=$$[$0-2];$$[$0-2].push($$[$0]);break}},table:[{3:5,4:$V0,5:6,6:$V1,7:3,8:$V2,9:4,10:$V3,11:$V4,12:1,13:2,15:7,16:8,17:$V5,23:$V6},{1:[3]},{14:[1,16]},o($V7,[2,7]),o($V7,[2,8]),o($V7,[2,9]),o($V7,[2,10]),o($V7,[2,11]),o($V7,[2,12]),o($V7,[2,3]),o($V7,[2,4]),o($V7,[2,5]),o([14,18,21,22,24],[2,1]),o($V7,[2,2]),{3:20,4:$V0,18:[1,17],19:18,20:19},{3:5,4:$V0,5:6,6:$V1,7:3,8:$V2,9:4,10:$V3,11:$V4,13:23,15:7,16:8,17:$V5,23:$V6,24:[1,21],25:22},{1:[2,6]},o($V7,[2,13]),{18:[1,24],22:[1,25]},o($V8,[2,16]),{21:[1,26]},o($V7,[2,18]),{22:[1,28],24:[1,27]},o($V9,[2,20]),o($V7,[2,14]),{3:20,4:$V0,20:29},{3:5,4:$V0,5:6,6:$V1,7:3,8:$V2,9:4,10:$V3,11:$V4,13:30,15:7,16:8,17:$V5,23:$V6},o($V7,[2,19]),{3:5,4:$V0,5:6,6:$V1,7:3,8:$V2,9:4,10:$V3,11:$V4,13:31,15:7,16:8,17:$V5,23:$V6},o($V8,[2,17]),o($V8,[2,15]),o($V9,[2,21])],defaultActions:{16:[2,6]},parseError:function parseError(str,hash){if(hash.recoverable){this.trace(str)}else{throw new Error(str)}},parse:function parse(input){var self=this,stack=[0],tstack=[],vstack=[null],lstack=[],table=this.table,yytext="",yylineno=0,yyleng=0,recovering=0,TERROR=2,EOF=1;var args=lstack.slice.call(arguments,1);var lexer=Object.create(this.lexer);var sharedState={yy:{}};for(var k in this.yy){if(Object.prototype.hasOwnProperty.call(this.yy,k)){sharedState.yy[k]=this.yy[k]}}lexer.setInput(input,sharedState.yy);sharedState.yy.lexer=lexer;sharedState.yy.parser=this;if(typeof lexer.yylloc=="undefined"){lexer.yylloc={}}var yyloc=lexer.yylloc;lstack.push(yyloc);var ranges=lexer.options&&lexer.options.ranges;if(typeof sharedState.yy.parseError==="function"){this.parseError=sharedState.yy.parseError}else{this.parseError=Object.getPrototypeOf(this).parseError}function popStack(n){stack.length=stack.length-2*n;vstack.length=vstack.length-n;lstack.length=lstack.length-n}_token_stack:function lex(){var token;token=lexer.lex()||EOF;if(typeof token!=="number"){token=self.symbols_[token]||token}return token}var symbol,preErrorSymbol,state,action,a,r,yyval={},p,len,newState,expected;while(true){state=stack[stack.length-1];if(this.defaultActions[state]){action=this.defaultActions[state]}else{if(symbol===null||typeof symbol=="undefined"){symbol=lex()}action=table[state]&&table[state][symbol]}if(typeof action==="undefined"||!action.length||!action[0]){var errStr="";expected=[];for(p in table[state]){if(this.terminals_[p]&&p>TERROR){expected.push("'"+this.terminals_[p]+"'")}}if(lexer.showPosition){errStr="Parse error on line "+(yylineno+1)+":\n"+lexer.showPosition()+"\nExpecting "+expected.join(", ")+", got '"+(this.terminals_[symbol]||symbol)+"'"}else{errStr="Parse error on line "+(yylineno+1)+": Unexpected "+(symbol==EOF?"end of input":"'"+(this.terminals_[symbol]||symbol)+"'")}this.parseError(errStr,{text:lexer.match,token:this.terminals_[symbol]||symbol,line:lexer.yylineno,loc:yyloc,expected:expected})}if(action[0]instanceof Array&&action.length>1){throw new Error("Parse Error: multiple actions possible at state: "+state+", token: "+symbol)}switch(action[0]){case 1:stack.push(symbol);vstack.push(lexer.yytext);lstack.push(lexer.yylloc);stack.push(action[1]);symbol=null;if(!preErrorSymbol){yyleng=lexer.yyleng;yytext=lexer.yytext;yylineno=lexer.yylineno;yyloc=lexer.yylloc;if(recovering>0){recovering--}}else{symbol=preErrorSymbol;preErrorSymbol=null}break;case 2:len=this.productions_[action[1]][1];yyval.$=vstack[vstack.length-len];yyval._$={first_line:lstack[lstack.length-(len||1)].first_line,last_line:lstack[lstack.length-1].last_line,first_column:lstack[lstack.length-(len||1)].first_column,last_column:lstack[lstack.length-1].last_column};if(ranges){yyval._$.range=[lstack[lstack.length-(len||1)].range[0],lstack[lstack.length-1].range[1]]}r=this.performAction.apply(yyval,[yytext,yyleng,yylineno,sharedState.yy,action[1],vstack,lstack].concat(args));if(typeof r!=="undefined"){return r}if(len){stack=stack.slice(0,-1*len*2);vstack=vstack.slice(0,-1*len);lstack=lstack.slice(0,-1*len)}stack.push(this.productions_[action[1]][0]);vstack.push(yyval.$);lstack.push(yyval._$);newState=table[stack[stack.length-2]][stack[stack.length-1]];stack.push(newState);break;case 3:return true}}return true}};var lexer=function(){var lexer={EOF:1,parseError:function parseError(str,hash){if(this.yy.parser){this.yy.parser.parseError(str,hash)}else{throw new Error(str)}},setInput:function(input,yy){this.yy=yy||this.yy||{};this._input=input;this._more=this._backtrack=this.done=false;this.yylineno=this.yyleng=0;this.yytext=this.matched=this.match="";this.conditionStack=["INITIAL"];this.yylloc={first_line:1,first_column:0,last_line:1,last_column:0};if(this.options.ranges){this.yylloc.range=[0,0]}this.offset=0;return this},input:function(){var ch=this._input[0];this.yytext+=ch;this.yyleng++;this.offset++;this.match+=ch;this.matched+=ch;var lines=ch.match(/(?:\r\n?|\n).*/g);if(lines){this.yylineno++;this.yylloc.last_line++}else{this.yylloc.last_column++}if(this.options.ranges){this.yylloc.range[1]++}this._input=this._input.slice(1);return ch},unput:function(ch){var len=ch.length;var lines=ch.split(/(?:\r\n?|\n)/g);this._input=ch+this._input;this.yytext=this.yytext.substr(0,this.yytext.length-len);this.offset-=len;var oldLines=this.match.split(/(?:\r\n?|\n)/g);this.match=this.match.substr(0,this.match.length-1);this.matched=this.matched.substr(0,this.matched.length-1);if(lines.length-1){this.yylineno-=lines.length-1}var r=this.yylloc.range;this.yylloc={first_line:this.yylloc.first_line,last_line:this.yylineno+1,first_column:this.yylloc.first_column,last_column:lines?(lines.length===oldLines.length?this.yylloc.first_column:0)+oldLines[oldLines.length-lines.length].length-lines[0].length:this.yylloc.first_column-len};if(this.options.ranges){this.yylloc.range=[r[0],r[0]+this.yyleng-len]}this.yyleng=this.yytext.length;return this},more:function(){this._more=true;return this},reject:function(){if(this.options.backtrack_lexer){this._backtrack=true}else{return this.parseError("Lexical error on line "+(this.yylineno+1)+". You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})}return this},less:function(n){this.unput(this.match.slice(n))},pastInput:function(){var past=this.matched.substr(0,this.matched.length-this.match.length);return(past.length>20?"...":"")+past.substr(-20).replace(/\n/g,"")},upcomingInput:function(){var next=this.match;if(next.length<20){next+=this._input.substr(0,20-next.length)}return(next.substr(0,20)+(next.length>20?"...":"")).replace(/\n/g,"")},showPosition:function(){var pre=this.pastInput();var c=new Array(pre.length+1).join("-");return pre+this.upcomingInput()+"\n"+c+"^"},test_match:function(match,indexed_rule){var token,lines,backup;if(this.options.backtrack_lexer){backup={yylineno:this.yylineno,yylloc:{first_line:this.yylloc.first_line,last_line:this.last_line,first_column:this.yylloc.first_column,last_column:this.yylloc.last_column},yytext:this.yytext,match:this.match,matches:this.matches,matched:this.matched,yyleng:this.yyleng,offset:this.offset,_more:this._more,_input:this._input,yy:this.yy,conditionStack:this.conditionStack.slice(0),done:this.done};if(this.options.ranges){backup.yylloc.range=this.yylloc.range.slice(0)}}lines=match[0].match(/(?:\r\n?|\n).*/g);if(lines){this.yylineno+=lines.length}this.yylloc={first_line:this.yylloc.last_line,last_line:this.yylineno+1,first_column:this.yylloc.last_column,last_column:lines?lines[lines.length-1].length-lines[lines.length-1].match(/\r?\n?/)[0].length:this.yylloc.last_column+match[0].length};this.yytext+=match[0];this.match+=match[0];this.matches=match;this.yyleng=this.yytext.length;if(this.options.ranges){this.yylloc.range=[this.offset,this.offset+=this.yyleng]}this._more=false;this._backtrack=false;this._input=this._input.slice(match[0].length);this.matched+=match[0];token=this.performAction.call(this,this.yy,this,indexed_rule,this.conditionStack[this.conditionStack.length-1]);if(this.done&&this._input){this.done=false}if(token){return token}else if(this._backtrack){for(var k in backup){this[k]=backup[k]}return false}return false},next:function(){if(this.done){return this.EOF}if(!this._input){this.done=true}var token,match,tempMatch,index;if(!this._more){this.yytext="";this.match=""}var rules=this._currentRules();for(var i=0;imatch[0].length)){match=tempMatch;index=i;if(this.options.backtrack_lexer){token=this.test_match(tempMatch,rules[i]);if(token!==false){return token}else if(this._backtrack){match=false;continue}else{return false}}else if(!this.options.flex){break}}}if(match){token=this.test_match(match,rules[index]);if(token!==false){return token}return false}if(this._input===""){return this.EOF}else{return this.parseError("Lexical error on line "+(this.yylineno+1)+". Unrecognized text.\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})}},lex:function lex(){var r=this.next();if(r){return r}else{return this.lex()}},begin:function begin(condition){this.conditionStack.push(condition)},popState:function popState(){var n=this.conditionStack.length-1;if(n>0){return this.conditionStack.pop()}else{return this.conditionStack[0]}},_currentRules:function _currentRules(){if(this.conditionStack.length&&this.conditionStack[this.conditionStack.length-1]){return this.conditions[this.conditionStack[this.conditionStack.length-1]].rules}else{return this.conditions["INITIAL"].rules}},topState:function topState(n){n=this.conditionStack.length-1-Math.abs(n||0);if(n>=0){return this.conditionStack[n]}else{return"INITIAL"}},pushState:function pushState(condition){this.begin(condition)},stateStackSize:function stateStackSize(){return this.conditionStack.length},options:{},performAction:function anonymous(yy,yy_,$avoiding_name_collisions,YY_START){var YYSTATE=YY_START;switch($avoiding_name_collisions){case 0:break;case 1:return 6;break;case 2:yy_.yytext=yy_.yytext.substr(1,yy_.yyleng-2);return 4;break;case 3:return 17;break;case 4:return 18;break;case 5:return 23;break;case 6:return 24;break;case 7:return 22;break;case 8:return 21;break;case 9:return 10;break;case 10:return 11;break;case 11:return 8;break;case 12:return 14;break;case 13:return"INVALID";break}},rules:[/^(?:\s+)/,/^(?:(-?([0-9]|[1-9][0-9]+))(\.[0-9]+)?([eE][-+]?[0-9]+)?\b)/,/^(?:"(?:\\[\\"bfnrt/]|\\u[a-fA-F0-9]{4}|[^\\\0-\x09\x0a-\x1f"])*")/,/^(?:\{)/,/^(?:\})/,/^(?:\[)/,/^(?:\])/,/^(?:,)/,/^(?::)/,/^(?:true\b)/,/^(?:false\b)/,/^(?:null\b)/,/^(?:$)/,/^(?:.)/],conditions:{INITIAL:{rules:[0,1,2,3,4,5,6,7,8,9,10,11,12,13],inclusive:true}}};return lexer}();parser.lexer=lexer;function Parser(){this.yy={}}Parser.prototype=parser;parser.Parser=Parser;return new Parser}();if(typeof require!=="undefined"&&typeof exports!=="undefined"){exports.parser=parser;exports.Parser=parser.Parser;exports.parse=function(){return parser.parse.apply(parser,arguments)};exports.main=function commonjsMain(args){if(!args[1]){console.log("Usage: "+args[0]+" FILE");process.exit(1)}var source=require("fs").readFileSync(require("path").normalize(args[1]),"utf8");return exports.parser.parse(source)};if(typeof module!=="undefined"&&require.main===module){exports.main(process.argv.slice(1))}}return exports}(); \ No newline at end of file diff --git a/node_modules/@mapbox/mapbox-gl-supported/.eslintrc b/node_modules/@mapbox/mapbox-gl-supported/.eslintrc new file mode 100644 index 0000000000000000000000000000000000000000..426351675db21c9615466bdf8d27da91096c139a --- /dev/null +++ b/node_modules/@mapbox/mapbox-gl-supported/.eslintrc @@ -0,0 +1,17 @@ +{ + "extends": "mourner", + "rules": { + "object-curly-spacing": 0, + "key-spacing": 0, + "array-bracket-spacing": 0, + "space-before-function-paren": 0, + "quotes": 0, + "no-eq-null": 0, + "consistent-return": 0, + "global-require": 0, + "block-scoped-var": 2 + }, + "env": { + "browser": true + } +} diff --git a/node_modules/@mapbox/mapbox-gl-supported/CONTRIBUTING.md b/node_modules/@mapbox/mapbox-gl-supported/CONTRIBUTING.md new file mode 100644 index 0000000000000000000000000000000000000000..dd6ad7f1e2608bc8c9a88bd7ed4bed54dbc2499c --- /dev/null +++ b/node_modules/@mapbox/mapbox-gl-supported/CONTRIBUTING.md @@ -0,0 +1,6 @@ +# Deploying a new release + + - `npm test` + - `npm version {patch|minor|major}` + - `git push --follow-tags` + - `aws s3 cp --acl public-read index.js s3://mapbox-gl-js/plugins/mapbox-gl-supported/v$(node --print --eval "require('./package.json').version")/mapbox-gl-supported.js` diff --git a/node_modules/@mapbox/mapbox-gl-supported/LICENSE.txt b/node_modules/@mapbox/mapbox-gl-supported/LICENSE.txt new file mode 100644 index 0000000000000000000000000000000000000000..03483177d84dec658454eb6478bf3f27fe284470 --- /dev/null +++ b/node_modules/@mapbox/mapbox-gl-supported/LICENSE.txt @@ -0,0 +1,30 @@ + +BSD 3-Clause License + +Copyright (c) 2017, Mapbox +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +* Neither the name of the copyright holder nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/node_modules/@mapbox/mapbox-gl-supported/README.md b/node_modules/@mapbox/mapbox-gl-supported/README.md new file mode 100644 index 0000000000000000000000000000000000000000..7102e35b2b0534c9d8a659a5e27dff84cb430d9f --- /dev/null +++ b/node_modules/@mapbox/mapbox-gl-supported/README.md @@ -0,0 +1,30 @@ +# Mapbox GL JS Supported + +This library determines if a browser supports [Mapbox GL JS](http://github.com/mapbox/mapbox-gl-js). + +## Testing Your Browser + +You may test your browser [here](http://mapbox.github.io/mapbox-gl-supported). + +## Using Mapbox GL JS Supported with a ` + +``` + +## Using Mapbox GL JS Supported with [Browserify](http://browserify.org/) + +```bash +npm install --save @mapbox/mapbox-gl-supported +``` + +```js +var isSupported = require('@mapbox/mapbox-gl-supported')(); +``` diff --git a/node_modules/@mapbox/mapbox-gl-supported/diagnostics.html b/node_modules/@mapbox/mapbox-gl-supported/diagnostics.html new file mode 100644 index 0000000000000000000000000000000000000000..e878f4e7068cec990ae92903f50fb8eac9c9179b --- /dev/null +++ b/node_modules/@mapbox/mapbox-gl-supported/diagnostics.html @@ -0,0 +1,165 @@ + + + + + + + + + + + + +

Map instantiation diagnostics

+
+ + + + + + +

Support detection diagnostics

+ + + + + + + + + +
Detection methodContext typefailIfMajorPerformanceCaveatResultErrors
+ + + + + +

WebGL diagnostics

+ + + + + + + + + diff --git a/node_modules/@mapbox/mapbox-gl-supported/index.html b/node_modules/@mapbox/mapbox-gl-supported/index.html new file mode 100644 index 0000000000000000000000000000000000000000..2486fe17a65741955787b471adfbea4c06c802f1 --- /dev/null +++ b/node_modules/@mapbox/mapbox-gl-supported/index.html @@ -0,0 +1,52 @@ + + + + + + + + + + + +

Mapbox GL JS is

+

...

+

+ + + + + + diff --git a/node_modules/@mapbox/mapbox-gl-supported/index.js b/node_modules/@mapbox/mapbox-gl-supported/index.js new file mode 100644 index 0000000000000000000000000000000000000000..8957b209a629110b78b3d7b0ded58c610092f59d --- /dev/null +++ b/node_modules/@mapbox/mapbox-gl-supported/index.js @@ -0,0 +1,189 @@ +'use strict'; + +if (typeof module !== 'undefined' && module.exports) { + module.exports = isSupported; +} else if (window) { + window.mapboxgl = window.mapboxgl || {}; + window.mapboxgl.supported = isSupported; + window.mapboxgl.notSupportedReason = notSupportedReason; +} + +/** + * Test whether the current browser supports Mapbox GL JS + * @param {Object} options + * @param {boolean} [options.failIfMajorPerformanceCaveat=false] Return `false` + * if the performance of Mapbox GL JS would be dramatically worse than + * expected (i.e. a software renderer is would be used) + * @return {boolean} + */ +function isSupported(options) { + return !notSupportedReason(options); +} + +function notSupportedReason(options) { + if (!isBrowser()) return 'not a browser'; + if (!isArraySupported()) return 'insufficent Array support'; + if (!isFunctionSupported()) return 'insufficient Function support'; + if (!isObjectSupported()) return 'insufficient Object support'; + if (!isJSONSupported()) return 'insufficient JSON support'; + if (!isWorkerSupported()) return 'insufficient worker support'; + if (!isUint8ClampedArraySupported()) return 'insufficient Uint8ClampedArray support'; + if (!isArrayBufferSupported()) return 'insufficient ArrayBuffer support'; + if (!isCanvasGetImageDataSupported()) return 'insufficient Canvas/getImageData support'; + if (!isWebGLSupportedCached(options && options.failIfMajorPerformanceCaveat)) return 'insufficient WebGL support'; +} + +function isBrowser() { + return typeof window !== 'undefined' && typeof document !== 'undefined'; +} + +function isArraySupported() { + return ( + Array.prototype && + Array.prototype.every && + Array.prototype.filter && + Array.prototype.forEach && + Array.prototype.indexOf && + Array.prototype.lastIndexOf && + Array.prototype.map && + Array.prototype.some && + Array.prototype.reduce && + Array.prototype.reduceRight && + Array.isArray + ); +} + +function isFunctionSupported() { + return Function.prototype && Function.prototype.bind; +} + +function isObjectSupported() { + return ( + Object.keys && + Object.create && + Object.getPrototypeOf && + Object.getOwnPropertyNames && + Object.isSealed && + Object.isFrozen && + Object.isExtensible && + Object.getOwnPropertyDescriptor && + Object.defineProperty && + Object.defineProperties && + Object.seal && + Object.freeze && + Object.preventExtensions + ); +} + +function isJSONSupported() { + return 'JSON' in window && 'parse' in JSON && 'stringify' in JSON; +} + +function isWorkerSupported() { + if (!('Worker' in window && 'Blob' in window && 'URL' in window)) { + return false; + } + + var blob = new Blob([''], { type: 'text/javascript' }); + var workerURL = URL.createObjectURL(blob); + var supported; + var worker; + + try { + worker = new Worker(workerURL); + supported = true; + } catch (e) { + supported = false; + } + + if (worker) { + worker.terminate(); + } + URL.revokeObjectURL(workerURL); + + return supported; +} + +// IE11 only supports `Uint8ClampedArray` as of version +// [KB2929437](https://support.microsoft.com/en-us/kb/2929437) +function isUint8ClampedArraySupported() { + return 'Uint8ClampedArray' in window; +} + +// https://github.com/mapbox/mapbox-gl-supported/issues/19 +function isArrayBufferSupported() { + return ArrayBuffer.isView; +} + +// Some browsers or browser extensions block access to canvas data to prevent fingerprinting. +// Mapbox GL uses this API to load sprites and images in general. +function isCanvasGetImageDataSupported() { + const canvas = document.createElement('canvas'); + canvas.width = canvas.height = 1; + const context = canvas.getContext('2d'); + if (!context) { + return false; + } + const imageData = context.getImageData(0, 0, 1, 1); + return imageData && imageData.width === canvas.width; +} + +var isWebGLSupportedCache = {}; +function isWebGLSupportedCached(failIfMajorPerformanceCaveat) { + + if (isWebGLSupportedCache[failIfMajorPerformanceCaveat] === undefined) { + isWebGLSupportedCache[failIfMajorPerformanceCaveat] = isWebGLSupported(failIfMajorPerformanceCaveat); + } + + return isWebGLSupportedCache[failIfMajorPerformanceCaveat]; +} + +isSupported.webGLContextAttributes = { + antialias: false, + alpha: true, + stencil: true, + depth: true +}; + +function getWebGLContext(failIfMajorPerformanceCaveat) { + var canvas = document.createElement('canvas'); + + var attributes = Object.create(isSupported.webGLContextAttributes); + attributes.failIfMajorPerformanceCaveat = failIfMajorPerformanceCaveat; + + if (canvas.probablySupportsContext) { + return ( + canvas.probablySupportsContext('webgl', attributes) || + canvas.probablySupportsContext('experimental-webgl', attributes) + ); + + } else if (canvas.supportsContext) { + return ( + canvas.supportsContext('webgl', attributes) || + canvas.supportsContext('experimental-webgl', attributes) + ); + + } else { + return ( + canvas.getContext('webgl', attributes) || + canvas.getContext('experimental-webgl', attributes) + ); + } +} + +function isWebGLSupported(failIfMajorPerformanceCaveat) { + const gl = getWebGLContext(failIfMajorPerformanceCaveat); + if (!gl) { + return false; + } + + // Try compiling a shader and get its compile status. Some browsers like Brave block this API + // to prevent fingerprinting. Unfortunately, this also means that Mapbox GL won't work. + const shader = gl.createShader(gl.VERTEX_SHADER); + if (!shader || gl.isContextLost()) { + return false; + } + gl.shaderSource(shader, 'void main() {}'); + gl.compileShader(shader); + return gl.getShaderParameter(shader, gl.COMPILE_STATUS) === true; +} diff --git a/node_modules/@mapbox/mapbox-gl-supported/package.json b/node_modules/@mapbox/mapbox-gl-supported/package.json new file mode 100644 index 0000000000000000000000000000000000000000..e48869a2e3b63dc472a37d1449e0f3e7f42dbaf4 --- /dev/null +++ b/node_modules/@mapbox/mapbox-gl-supported/package.json @@ -0,0 +1,28 @@ +{ + "name": "@mapbox/mapbox-gl-supported", + "version": "1.5.0", + "description": "A library to determine if a browser supports Mapbox GL JS", + "main": "index.js", + "scripts": { + "test": "eslint index.js", + "build": "mkdir -p dist && uglifyjs index.js -c -m -o dist/mapbox-gl-supported.js" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/mapbox/mapbox-gl-supported.git" + }, + "license": "BSD-3-Clause", + "bugs": { + "url": "https://github.com/mapbox/mapbox-gl-supported/issues" + }, + "homepage": "https://github.com/mapbox/mapbox-gl-supported#readme", + "devDependencies": { + "browserify": "^16.2.3", + "eslint": "^2.8.0", + "eslint-config-mourner": "^2.0.1", + "uglify-js": "^2.4.24" + }, + "peerDependencies": { + "mapbox-gl": ">=0.32.1 <2.0.0" + } +} diff --git a/node_modules/@mapbox/point-geometry/.travis.yml b/node_modules/@mapbox/point-geometry/.travis.yml new file mode 100644 index 0000000000000000000000000000000000000000..83c838f0f4f6447d815e25b244deab3c71c8f76c --- /dev/null +++ b/node_modules/@mapbox/point-geometry/.travis.yml @@ -0,0 +1,8 @@ +language: node_js +node_js: + - "0.10" +before_install: + - npm install -g npm@~1.4.6 +script: + - npm test + - npm run cov diff --git a/node_modules/@mapbox/point-geometry/HISTORY.md b/node_modules/@mapbox/point-geometry/HISTORY.md new file mode 100644 index 0000000000000000000000000000000000000000..9e97108ba179f49a8bcf06238be99db01486272d --- /dev/null +++ b/node_modules/@mapbox/point-geometry/HISTORY.md @@ -0,0 +1,5 @@ +## 0.1.0 + +* Adds [rotateAround](https://github.com/mapbox/point-geometry/pull/5) and + [multByPoint](https://github.com/mapbox/point-geometry/pull/7) and divByPoint + methods. diff --git a/node_modules/@mapbox/point-geometry/LICENSE b/node_modules/@mapbox/point-geometry/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..745f3e4dadeea5a9336665f9c756e6f56a0926c9 --- /dev/null +++ b/node_modules/@mapbox/point-geometry/LICENSE @@ -0,0 +1,13 @@ +Copyright (c) 2015, Mapbox <> + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted, provided that the above +copyright notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. diff --git a/node_modules/@mapbox/point-geometry/README.md b/node_modules/@mapbox/point-geometry/README.md new file mode 100644 index 0000000000000000000000000000000000000000..e2541b44ebba55832f1453ffbb6395ae3a92bef9 --- /dev/null +++ b/node_modules/@mapbox/point-geometry/README.md @@ -0,0 +1,364 @@ +# point-geometry + +[![build status](https://secure.travis-ci.org/mapbox/point-geometry.png)](http://travis-ci.org/mapbox/point-geometry) [![Coverage Status](https://coveralls.io/repos/mapbox/point-geometry/badge.svg?branch=master)](https://coveralls.io/r/mapbox/point-geometry?branch=master) + +a point geometry with transforms + + +### `Point(x, y)` + +A standalone point geometry with useful accessor, comparison, and +modification methods. + + +### Parameters + +| parameter | type | description | +| --------- | ------ | -------------------------------------------------------------------------------------- | +| `x` | Number | the x-coordinate. this could be longitude or screen pixels, or any other sort of unit. | +| `y` | Number | the y-coordinate. this could be latitude or screen pixels, or any other sort of unit. | + + +### Example + +```js +var point = new Point(-77, 38); +``` + + +### `clone` + +Clone this point, returning a new point that can be modified +without affecting the old one. + + +**Returns** `Point`, the clone + + +### `add(p)` + +Add this point's x & y coordinates to another point, +yielding a new point. + +### Parameters + +| parameter | type | description | +| --------- | ----- | --------------- | +| `p` | Point | the other point | + + + +**Returns** `Point`, output point + + +### `sub(p)` + +Subtract this point's x & y coordinates to from point, +yielding a new point. + +### Parameters + +| parameter | type | description | +| --------- | ----- | --------------- | +| `p` | Point | the other point | + + + +**Returns** `Point`, output point + + +### `multByPoint(p)` + +Multiply this point's x & y coordinates by point, +yielding a new point. + +### Parameters + +| parameter | type | description | +| --------- | ----- | --------------- | +| `p` | Point | the other point | + + + +**Returns** `Point`, output point + + +### `divByPoint(p)` + +Divide this point's x & y coordinates by point, +yielding a new point. + +### Parameters + +| parameter | type | description | +| --------- | ----- | --------------- | +| `p` | Point | the other point | + + + +**Returns** `Point`, output point + + +### `mult(k)` + +Multiply this point's x & y coordinates by a factor, +yielding a new point. + +### Parameters + +| parameter | type | description | +| --------- | ----- | ----------- | +| `k` | Point | factor | + + + +**Returns** `Point`, output point + + +### `div(k)` + +Divide this point's x & y coordinates by a factor, +yielding a new point. + +### Parameters + +| parameter | type | description | +| --------- | ----- | ----------- | +| `k` | Point | factor | + + + +**Returns** `Point`, output point + + +### `rotate(a)` + +Rotate this point around the 0, 0 origin by an angle a, +given in radians + +### Parameters + +| parameter | type | description | +| --------- | ------ | ---------------------------------- | +| `a` | Number | angle to rotate around, in radians | + + + +**Returns** `Point`, output point + + +### `rotateAround(a, p)` + +Rotate this point around p point by an angle a, +given in radians + +### Parameters + +| parameter | type | description | +| --------- | ------ | ---------------------------------- | +| `a` | Number | angle to rotate around, in radians | +| `p` | Point | Point to rotate around | + + + +**Returns** `Point`, output point + + +### `matMult(m)` + +Multiply this point by a 4x1 transformation matrix + +### Parameters + +| parameter | type | description | +| --------- | ----------------- | --------------------- | +| `m` | Array\.\ | transformation matrix | + + + +**Returns** `Point`, output point + + +### `unit` + +Calculate this point but as a unit vector from 0, 0, meaning +that the distance from the resulting point to the 0, 0 +coordinate will be equal to 1 and the angle from the resulting +point to the 0, 0 coordinate will be the same as before. + + +**Returns** `Point`, unit vector point + + +### `perp` + +Compute a perpendicular point, where the new y coordinate +is the old x coordinate and the new x coordinate is the old y +coordinate multiplied by -1 + + +**Returns** `Point`, perpendicular point + + +### `round` + +Return a version of this point with the x & y coordinates +rounded to integers. + + +**Returns** `Point`, rounded point + + +### `mag` + +Return the magitude of this point: this is the Euclidean +distance from the 0, 0 coordinate to this point's x and y +coordinates. + + +**Returns** `Number`, magnitude + + +### `equals(other)` + +Judge whether this point is equal to another point, returning +true or false. + +### Parameters + +| parameter | type | description | +| --------- | ----- | --------------- | +| `other` | Point | the other point | + + + +**Returns** `boolean`, whether the points are equal + + +### `dist(p)` + +Calculate the distance from this point to another point + +### Parameters + +| parameter | type | description | +| --------- | ----- | --------------- | +| `p` | Point | the other point | + + + +**Returns** `Number`, distance + + +### `distSqr(p)` + +Calculate the distance from this point to another point, +without the square root step. Useful if you're comparing +relative distances. + +### Parameters + +| parameter | type | description | +| --------- | ----- | --------------- | +| `p` | Point | the other point | + + + +**Returns** `Number`, distance + + +### `angle` + +Get the angle from the 0, 0 coordinate to this point, in radians +coordinates. + + +**Returns** `Number`, angle + + +### `angleTo(b)` + +Get the angle from this point to another point, in radians + +### Parameters + +| parameter | type | description | +| --------- | ----- | --------------- | +| `b` | Point | the other point | + + + +**Returns** `Number`, angle + + +### `angleWith(b)` + +Get the angle between this point and another point, in radians + +### Parameters + +| parameter | type | description | +| --------- | ----- | --------------- | +| `b` | Point | the other point | + + + +**Returns** `Number`, angle + + +### `angleWithSep(x, y)` + +Find the angle of the two vectors, solving the formula for +the cross product a x b = |a||b|sin(θ) for θ. + +### Parameters + +| parameter | type | description | +| --------- | ------ | ---------------- | +| `x` | Number | the x-coordinate | +| `y` | Number | the y-coordinate | + + + +**Returns** `Number`, the angle in radians + + +### `convert(a)` + +Construct a point from an array if necessary, otherwise if the input +is already a Point, or an unknown type, return it unchanged + +### Parameters + +| parameter | type | description | +| --------- | ------------------------ | ----------------------- | +| `a` | Array\.\\,Point | any kind of input value | + + +### Example + +```js +// this +var point = Point.convert([0, 1]); +// is equivalent to +var point = new Point(0, 1); +``` + + +**Returns** `Point`, constructed point, or passed-through value. + +## Installation + +Requires [nodejs](http://nodejs.org/). + +```sh +$ npm install point-geometry +``` + +## Tests + +```sh +$ npm test +``` + + diff --git a/node_modules/@mapbox/point-geometry/index.js b/node_modules/@mapbox/point-geometry/index.js new file mode 100644 index 0000000000000000000000000000000000000000..5f21f840171deba8d78eaa01643d3d055e0c7ef6 --- /dev/null +++ b/node_modules/@mapbox/point-geometry/index.js @@ -0,0 +1,312 @@ +'use strict'; + +module.exports = Point; + +/** + * A standalone point geometry with useful accessor, comparison, and + * modification methods. + * + * @class Point + * @param {Number} x the x-coordinate. this could be longitude or screen + * pixels, or any other sort of unit. + * @param {Number} y the y-coordinate. this could be latitude or screen + * pixels, or any other sort of unit. + * @example + * var point = new Point(-77, 38); + */ +function Point(x, y) { + this.x = x; + this.y = y; +} + +Point.prototype = { + + /** + * Clone this point, returning a new point that can be modified + * without affecting the old one. + * @return {Point} the clone + */ + clone: function() { return new Point(this.x, this.y); }, + + /** + * Add this point's x & y coordinates to another point, + * yielding a new point. + * @param {Point} p the other point + * @return {Point} output point + */ + add: function(p) { return this.clone()._add(p); }, + + /** + * Subtract this point's x & y coordinates to from point, + * yielding a new point. + * @param {Point} p the other point + * @return {Point} output point + */ + sub: function(p) { return this.clone()._sub(p); }, + + /** + * Multiply this point's x & y coordinates by point, + * yielding a new point. + * @param {Point} p the other point + * @return {Point} output point + */ + multByPoint: function(p) { return this.clone()._multByPoint(p); }, + + /** + * Divide this point's x & y coordinates by point, + * yielding a new point. + * @param {Point} p the other point + * @return {Point} output point + */ + divByPoint: function(p) { return this.clone()._divByPoint(p); }, + + /** + * Multiply this point's x & y coordinates by a factor, + * yielding a new point. + * @param {Point} k factor + * @return {Point} output point + */ + mult: function(k) { return this.clone()._mult(k); }, + + /** + * Divide this point's x & y coordinates by a factor, + * yielding a new point. + * @param {Point} k factor + * @return {Point} output point + */ + div: function(k) { return this.clone()._div(k); }, + + /** + * Rotate this point around the 0, 0 origin by an angle a, + * given in radians + * @param {Number} a angle to rotate around, in radians + * @return {Point} output point + */ + rotate: function(a) { return this.clone()._rotate(a); }, + + /** + * Rotate this point around p point by an angle a, + * given in radians + * @param {Number} a angle to rotate around, in radians + * @param {Point} p Point to rotate around + * @return {Point} output point + */ + rotateAround: function(a,p) { return this.clone()._rotateAround(a,p); }, + + /** + * Multiply this point by a 4x1 transformation matrix + * @param {Array} m transformation matrix + * @return {Point} output point + */ + matMult: function(m) { return this.clone()._matMult(m); }, + + /** + * Calculate this point but as a unit vector from 0, 0, meaning + * that the distance from the resulting point to the 0, 0 + * coordinate will be equal to 1 and the angle from the resulting + * point to the 0, 0 coordinate will be the same as before. + * @return {Point} unit vector point + */ + unit: function() { return this.clone()._unit(); }, + + /** + * Compute a perpendicular point, where the new y coordinate + * is the old x coordinate and the new x coordinate is the old y + * coordinate multiplied by -1 + * @return {Point} perpendicular point + */ + perp: function() { return this.clone()._perp(); }, + + /** + * Return a version of this point with the x & y coordinates + * rounded to integers. + * @return {Point} rounded point + */ + round: function() { return this.clone()._round(); }, + + /** + * Return the magitude of this point: this is the Euclidean + * distance from the 0, 0 coordinate to this point's x and y + * coordinates. + * @return {Number} magnitude + */ + mag: function() { + return Math.sqrt(this.x * this.x + this.y * this.y); + }, + + /** + * Judge whether this point is equal to another point, returning + * true or false. + * @param {Point} other the other point + * @return {boolean} whether the points are equal + */ + equals: function(other) { + return this.x === other.x && + this.y === other.y; + }, + + /** + * Calculate the distance from this point to another point + * @param {Point} p the other point + * @return {Number} distance + */ + dist: function(p) { + return Math.sqrt(this.distSqr(p)); + }, + + /** + * Calculate the distance from this point to another point, + * without the square root step. Useful if you're comparing + * relative distances. + * @param {Point} p the other point + * @return {Number} distance + */ + distSqr: function(p) { + var dx = p.x - this.x, + dy = p.y - this.y; + return dx * dx + dy * dy; + }, + + /** + * Get the angle from the 0, 0 coordinate to this point, in radians + * coordinates. + * @return {Number} angle + */ + angle: function() { + return Math.atan2(this.y, this.x); + }, + + /** + * Get the angle from this point to another point, in radians + * @param {Point} b the other point + * @return {Number} angle + */ + angleTo: function(b) { + return Math.atan2(this.y - b.y, this.x - b.x); + }, + + /** + * Get the angle between this point and another point, in radians + * @param {Point} b the other point + * @return {Number} angle + */ + angleWith: function(b) { + return this.angleWithSep(b.x, b.y); + }, + + /* + * Find the angle of the two vectors, solving the formula for + * the cross product a x b = |a||b|sin(θ) for θ. + * @param {Number} x the x-coordinate + * @param {Number} y the y-coordinate + * @return {Number} the angle in radians + */ + angleWithSep: function(x, y) { + return Math.atan2( + this.x * y - this.y * x, + this.x * x + this.y * y); + }, + + _matMult: function(m) { + var x = m[0] * this.x + m[1] * this.y, + y = m[2] * this.x + m[3] * this.y; + this.x = x; + this.y = y; + return this; + }, + + _add: function(p) { + this.x += p.x; + this.y += p.y; + return this; + }, + + _sub: function(p) { + this.x -= p.x; + this.y -= p.y; + return this; + }, + + _mult: function(k) { + this.x *= k; + this.y *= k; + return this; + }, + + _div: function(k) { + this.x /= k; + this.y /= k; + return this; + }, + + _multByPoint: function(p) { + this.x *= p.x; + this.y *= p.y; + return this; + }, + + _divByPoint: function(p) { + this.x /= p.x; + this.y /= p.y; + return this; + }, + + _unit: function() { + this._div(this.mag()); + return this; + }, + + _perp: function() { + var y = this.y; + this.y = this.x; + this.x = -y; + return this; + }, + + _rotate: function(angle) { + var cos = Math.cos(angle), + sin = Math.sin(angle), + x = cos * this.x - sin * this.y, + y = sin * this.x + cos * this.y; + this.x = x; + this.y = y; + return this; + }, + + _rotateAround: function(angle, p) { + var cos = Math.cos(angle), + sin = Math.sin(angle), + x = p.x + cos * (this.x - p.x) - sin * (this.y - p.y), + y = p.y + sin * (this.x - p.x) + cos * (this.y - p.y); + this.x = x; + this.y = y; + return this; + }, + + _round: function() { + this.x = Math.round(this.x); + this.y = Math.round(this.y); + return this; + } +}; + +/** + * Construct a point from an array if necessary, otherwise if the input + * is already a Point, or an unknown type, return it unchanged + * @param {Array|Point|*} a any kind of input value + * @return {Point} constructed point, or passed-through value. + * @example + * // this + * var point = Point.convert([0, 1]); + * // is equivalent to + * var point = new Point(0, 1); + */ +Point.convert = function (a) { + if (a instanceof Point) { + return a; + } + if (Array.isArray(a)) { + return new Point(a[0], a[1]); + } + return a; +}; diff --git a/node_modules/@mapbox/point-geometry/package.json b/node_modules/@mapbox/point-geometry/package.json new file mode 100644 index 0000000000000000000000000000000000000000..6872312070d5fb212937b3427b838631d538b58d --- /dev/null +++ b/node_modules/@mapbox/point-geometry/package.json @@ -0,0 +1,33 @@ +{ + "name": "@mapbox/point-geometry", + "version": "0.1.0", + "description": "a point geometry with transforms", + "main": "index.js", + "scripts": { + "test": "tape test.js", + "doc": "dox -r < index.js | doxme --readme > README.md", + "cov": "istanbul cover test.js && coveralls < ./coverage/lcov.info" + }, + "repository": { + "type": "git", + "url": "git@github.com:mapbox/point-geometry.git" + }, + "keywords": [ + "point", + "geometry", + "primitive" + ], + "author": "Tom MacWright", + "license": "ISC", + "bugs": { + "url": "https://github.com/mapbox/point-geometry/issues" + }, + "homepage": "https://github.com/mapbox/point-geometry", + "devDependencies": { + "coveralls": "~2.10.1", + "dox": "^0.6.1", + "doxme": "^1.8.2", + "istanbul": "~0.2.11", + "tape": "~2.13.3" + } +} diff --git a/node_modules/@mapbox/point-geometry/test.js b/node_modules/@mapbox/point-geometry/test.js new file mode 100644 index 0000000000000000000000000000000000000000..90cefc79913463ef8a6a7d3530f7965d19f2b118 --- /dev/null +++ b/node_modules/@mapbox/point-geometry/test.js @@ -0,0 +1,139 @@ +'use strict'; +var test = require('tape').test; + +var Point = require('./'); + +test('Point', function(t) { + t.test('.convert', function(t) { + t.equal(Point.convert(new Point(20, 30)).equals(new Point(20, 30)), true); + t.equal(Point.convert([20, 30]).equals(new Point(20, 30)), true); + t.equal(Point.convert('somestring'), 'somestring'); + t.end(); + }); + t.test('vector operations', function(t) { + t.test('#mag', function(t) { + t.test('gets the magnitude of a vector', function() { + t.equal(new Point(0, 2).mag(), 2); + t.equal(new Point(0, 0).mag(), 0); + t.equal(new Point(10, 0).mag(), 10); + t.end(); + }); + }); + t.test('#unit', function(t) { + t.test('calculates the unit vector', function() { + t.deepEqual(new Point(0, 1000).unit(), new Point(0, 1)); + t.end(); + }); + }); + t.test('#equals', function(t) { + t.equals((new Point(0, 0).equals(new Point(0, 0))), true, 'equal'); + t.equals((new Point(0, 0).equals(new Point(0, 10))), false, 'not equal'); + t.end(); + }); + t.test('#dist', function(t) { + t.equals((new Point(0, 10).dist(new Point(0, 0))), 10); + t.equals((new Point(Math.sqrt(2), Math.sqrt(2)).dist(new Point(0, 0))), 2); + t.equals((new Point(0, 0).dist(new Point(0, 0))), 0); + t.end(); + }); + t.test('#mult', function(t) { + t.equals((new Point(0, 0).mult(5)).equals(new Point(0, 0)), true); + t.equals((new Point(0, 1).mult(5)).equals(new Point(0, 5)), true); + t.equals((new Point(1, 1).mult(5)).equals(new Point(5, 5)), true); + t.end(); + }); + t.test('#div', function(t) { + t.equals((new Point(0, 0).div(5)).equals(new Point(0, 0)), true); + t.equals((new Point(0, 1).div(5)).equals(new Point(0, 1/5)), true); + t.equals((new Point(1, 1).div(5)).equals(new Point(1/5, 1/5)), true); + t.end(); + }); + t.test('#multByPoint', function(t) { + t.equals((new Point(0, 0).multByPoint(new Point(5,5))).equals(new Point(0, 0)), true); + t.equals((new Point(0, 1).multByPoint(new Point(5,5))).equals(new Point(0, 5)), true); + t.equals((new Point(1, 1).multByPoint(new Point(4,5))).equals(new Point(4, 5)), true); + t.end(); + }); + t.test('#divByPoint', function(t) { + t.equals((new Point(0, 0).divByPoint(new Point(5,5))).equals(new Point(0, 0)), true); + t.equals((new Point(0, 1).divByPoint(new Point(5,5))).equals(new Point(0, 1/5)), true); + t.equals((new Point(1, 1).divByPoint(new Point(4,5))).equals(new Point(1/4, 1/5)), true); + t.end(); + }); + t.test('#rotate', function(t) { + t.equals((new Point(0, 0).rotate(0)).equals(new Point(0, 0)), true); + t.deepEquals((new Point(0, 1).rotate(Math.PI/2)).round(), new Point(-1, 0)); + t.deepEquals((new Point(0, 1).rotate(Math.PI)).round(), new Point(0, -1)); + t.end(); + }); + t.test('#rotateAround', function(t) { + t.deepEquals((new Point(2, 3).rotateAround(Math.PI/2, new Point(2,2))).round(), new Point(1, 2)); + t.deepEquals((new Point(2, 3).rotateAround(Math.PI, new Point(2,2))).round(), new Point(2, 1)); + t.end(); + }); + t.test('#round', function(t) { + t.equals((new Point(0, 0).round()).equals(new Point(0, 0)), true); + t.equals((new Point(0, 0.5).round()).equals(new Point(0, 1)), true); + t.equals((new Point(0.2, 0.2).round()).equals(new Point(0, 0)), true); + t.end(); + }); + t.test('#angle', function(t) { + t.equals((new Point(0, 0).angle()), 0); + t.equals((new Point(10, 10).angle()), Math.PI / 4); + t.equals((new Point(0, 10).angle()), Math.PI / 2); + t.equals((new Point(10, 0).angle()), 0); + t.end(); + }); + t.test('#angleTo', function(t) { + var b = new Point(0, 0); + t.equals((new Point(0, 0).angleTo(b)), 0); + t.equals((new Point(10, 10).angleTo(b)), Math.PI / 4); + t.equals((new Point(0, 10).angleTo(b)), Math.PI / 2); + t.equals((new Point(10, 0).angleTo(b)), 0); + t.end(); + }); + t.test('#angleWith', function(t) { + var b = new Point(0, 0); + t.equals((new Point(0, 0).angleWith(b)), 0); + t.equals((new Point(10, 10).angleWith(b)), 0); + t.equals((new Point(0, 10).angleWith(b)), 0); + t.equals((new Point(10, 0).angleWith(b)), 0); + t.end(); + }); + t.test('#angleWithSep', function(t) { + t.equals((new Point(0, 0).angleWithSep(0, 0)), 0); + t.equals((new Point(10, 10).angleWithSep(0, 0)), 0); + t.equals((new Point(0, 10).angleWithSep(0, 0)), 0); + t.equals((new Point(10, 0).angleWithSep(0, 0)), 0); + t.end(); + }); + t.test('#matMult', function(t) { + t.equals((new Point(0, 0).matMult([0, 0, 0, 0])).equals(new Point(0, 0)), true); + t.deepEquals((new Point(1, 1).matMult([0, 0, 0, 0])), new Point(0, 0)); + t.deepEquals((new Point(1, 1).matMult([1, 0, 1, 0])), new Point(1, 1)); + t.deepEquals((new Point(1, 1).matMult([1, 0, 0, 0])), new Point(1, 0)); + t.deepEquals((new Point(1, 1).matMult([0, 0, 1, 0])), new Point(0, 1)); + t.deepEquals((new Point(1, 1).matMult([0, 0, 1, 2])), new Point(0, 3)); + t.deepEquals((new Point(1, 1).matMult([1, 1, 1, 1])), new Point(2, 2)); + t.end(); + }); + t.test('#perp', function(t) { + t.test('calculates a vector perpendicular to the given vector', function() { + t.deepEqual(new Point(0, 1000).perp(), new Point(-1000, 0)); + t.end(); + }); + }); + t.test('#add', function(t) { + t.test('adds two vectors', function() { + t.deepEqual(new Point(0, 0).add(new Point(10, 10)), new Point(10, 10)); + t.end(); + }); + }); + t.test('#sub', function(t) { + t.test('adds subtracts a vector from another', function() { + t.deepEqual(new Point(0, 0).sub(new Point(10, 10)), new Point(-10, -10)); + t.end(); + }); + }); + }); +}); diff --git a/node_modules/@mapbox/tiny-sdf/LICENSE.txt b/node_modules/@mapbox/tiny-sdf/LICENSE.txt new file mode 100644 index 0000000000000000000000000000000000000000..94c832c064c2e8aaadaafbb03c4e632f027d1045 --- /dev/null +++ b/node_modules/@mapbox/tiny-sdf/LICENSE.txt @@ -0,0 +1,7 @@ +Copyright © 2016-2021 Mapbox, Inc. +This code available under the terms of the BSD 2-Clause license. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: +1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/node_modules/@mapbox/tiny-sdf/README.md b/node_modules/@mapbox/tiny-sdf/README.md new file mode 100644 index 0000000000000000000000000000000000000000..3abbd39ff64ecea96890d0fe894722f106d4f4e5 --- /dev/null +++ b/node_modules/@mapbox/tiny-sdf/README.md @@ -0,0 +1,40 @@ +# TinySDF + +TinySDF is a tiny and fast JavaScript library for generating SDF (signed distance field) +from system fonts on the browser using Canvas 2D and +[Felzenszwalb/Huttenlocher distance transform](https://cs.brown.edu/~pff/papers/dt-final.pdf). +This is very useful for [rendering text with WebGL](https://www.mapbox.com/blog/text-signed-distance-fields/). + +This implementation is based directly on the algorithm published in the Felzenszwalb/Huttenlocher paper, and is not a port of the existing C++ implementation provided by the paper's authors. + +Demo: http://mapbox.github.io/tiny-sdf/ + +## Usage +Create a TinySDF for drawing SDFs based on font parameters: + +```js +var fontsize = 24; // Font size in pixels +var buffer = 3; // Whitespace buffer around a glyph in pixels +var radius = 8; // How many pixels around the glyph shape to use for encoding distance +var cutoff = 0.25 // How much of the radius (relative) is used for the inside part the glyph + +var fontFamily = 'sans-serif'; // css font-family +var fontWeight = 'normal'; // css font-weight +var tinySDFGenerator = new TinySDF(fontsize, buffer, radius, cutoff, fontFamily, fontWeight); + +var oneSDF = tinySDFGenerator.draw('泽'); +// returns a Uint8ClampedArray array of alpha values (0–255) for a size x size square grid + +// To generate glyphs with variable advances (e.g. non-ideographic glyphs), +// use `drawWithMetrics` +var sdfWithMetrics = tinySDFGenerator.drawWithMetrics('A'); +// sdfWithMetrics.data is the same as in `draw`, except the size may be clipped to fit the glyph +// sdfWithMetrics.metrics contains: +// top: Maximum ascent of glyph from alphabetic baseline +// left: Currently hardwired to 0 (actual glyph differences are encoded in the rasterization) +// width: Width of rasterized portion of glyph +// height +// advance: Layout advance +// sdfWidth: Width of the returned bitmap, usually but not always width + 2 * buffer +// sdfHeight +``` diff --git a/node_modules/@mapbox/tiny-sdf/debug.html b/node_modules/@mapbox/tiny-sdf/debug.html new file mode 100644 index 0000000000000000000000000000000000000000..342ac41573114107a21e9b5e9bcf1854b2871560 --- /dev/null +++ b/node_modules/@mapbox/tiny-sdf/debug.html @@ -0,0 +1,99 @@ + + + +SDF test + + + + + + + + + diff --git a/node_modules/@mapbox/tiny-sdf/index.html b/node_modules/@mapbox/tiny-sdf/index.html new file mode 100644 index 0000000000000000000000000000000000000000..aab394e1b11c0acc615597d39d21b860ea927b80 --- /dev/null +++ b/node_modules/@mapbox/tiny-sdf/index.html @@ -0,0 +1,315 @@ + + + +SDF test + + + + + +
+

TinySDF demo

+

+ + +

+ +

+

+ + + + +

+ +
+ + + + + + + + + + + diff --git a/node_modules/@mapbox/tiny-sdf/index.js b/node_modules/@mapbox/tiny-sdf/index.js new file mode 100644 index 0000000000000000000000000000000000000000..8ba4a569a60cb4da44a4de6a03f3faf9948153ab --- /dev/null +++ b/node_modules/@mapbox/tiny-sdf/index.js @@ -0,0 +1,192 @@ +'use strict'; + +module.exports = TinySDF; +module.exports.default = TinySDF; + +var INF = 1e20; + +function TinySDF(fontSize, buffer, radius, cutoff, fontFamily, fontWeight) { + this.fontSize = fontSize || 24; + this.buffer = buffer === undefined ? 3 : buffer; + this.cutoff = cutoff || 0.25; + this.fontFamily = fontFamily || 'sans-serif'; + this.fontWeight = fontWeight || 'normal'; + this.radius = radius || 8; + + // For backwards compatibility, we honor the implicit contract that the + // size of the returned bitmap will be fontSize + buffer * 2 + var size = this.size = this.fontSize + this.buffer * 2; + // Glyphs may be slightly larger than their fontSize. The canvas already + // has buffer space, but create extra buffer space in the output grid for the + // "halo" to extend into (if metric extraction is enabled) + var gridSize = size + this.buffer * 2; + + this.canvas = document.createElement('canvas'); + this.canvas.width = this.canvas.height = size; + + this.ctx = this.canvas.getContext('2d'); + this.ctx.font = this.fontWeight + ' ' + this.fontSize + 'px ' + this.fontFamily; + + this.ctx.textAlign = 'left'; // Necessary so that RTL text doesn't have different alignment + this.ctx.fillStyle = 'black'; + + // temporary arrays for the distance transform + this.gridOuter = new Float64Array(gridSize * gridSize); + this.gridInner = new Float64Array(gridSize * gridSize); + this.f = new Float64Array(gridSize); + this.z = new Float64Array(gridSize + 1); + this.v = new Uint16Array(gridSize); + + this.useMetrics = this.ctx.measureText('A').actualBoundingBoxLeft !== undefined; + + // hack around https://bugzilla.mozilla.org/show_bug.cgi?id=737852 + this.middle = Math.round((size / 2) * (navigator.userAgent.indexOf('Gecko/') >= 0 ? 1.2 : 1)); +} + +function prepareGrids(imgData, width, height, glyphWidth, glyphHeight, gridOuter, gridInner) { + // Initialize grids outside the glyph range to alpha 0 + gridOuter.fill(INF, 0, width * height); + gridInner.fill(0, 0, width * height); + + var offset = (width - glyphWidth) / 2; // This is zero if we're not extracting metrics + + for (var y = 0; y < glyphHeight; y++) { + for (var x = 0; x < glyphWidth; x++) { + var j = (y + offset) * width + x + offset; + var a = imgData.data[4 * (y * glyphWidth + x) + 3] / 255; // alpha value + if (a === 1) { + gridOuter[j] = 0; + gridInner[j] = INF; + } else if (a === 0) { + gridOuter[j] = INF; + gridInner[j] = 0; + } else { + var b = Math.max(0, 0.5 - a); + var c = Math.max(0, a - 0.5); + gridOuter[j] = b * b; + gridInner[j] = c * c; + } + } + } +} + +function extractAlpha(alphaChannel, width, height, gridOuter, gridInner, radius, cutoff) { + for (var i = 0; i < width * height; i++) { + var d = Math.sqrt(gridOuter[i]) - Math.sqrt(gridInner[i]); + alphaChannel[i] = Math.round(255 - 255 * (d / radius + cutoff)); + } +} + +TinySDF.prototype._draw = function (char, getMetrics) { + var textMetrics = this.ctx.measureText(char); + // Older browsers only expose the glyph width + // This is enough for basic layout with all glyphs using the same fixed size + var advance = textMetrics.width; + + var doubleBuffer = 2 * this.buffer; + var width, glyphWidth, height, glyphHeight, top; + + var imgTop, imgLeft, baselinePosition; + // If the browser supports bounding box metrics, we can generate a smaller + // SDF. This is a significant performance win. + if (getMetrics && this.useMetrics) { + // The integer/pixel part of the top alignment is encoded in metrics.top + // The remainder is implicitly encoded in the rasterization + top = Math.floor(textMetrics.actualBoundingBoxAscent); + baselinePosition = this.buffer + Math.ceil(textMetrics.actualBoundingBoxAscent); + imgTop = this.buffer; + imgLeft = this.buffer; + + // If the glyph overflows the canvas size, it will be clipped at the + // bottom/right + glyphWidth = Math.min(this.size, + Math.ceil(textMetrics.actualBoundingBoxRight - textMetrics.actualBoundingBoxLeft)); + glyphHeight = Math.min(this.size - imgTop, + Math.ceil(textMetrics.actualBoundingBoxAscent + textMetrics.actualBoundingBoxDescent)); + + width = glyphWidth + doubleBuffer; + height = glyphHeight + doubleBuffer; + this.ctx.textBaseline = 'alphabetic'; + } else { + width = glyphWidth = this.size; + height = glyphHeight = this.size; + // 19 points is an approximation of the "cap height" ascent from alphabetic + // baseline (even though actual drawing is from middle baseline, we can + // use the approximation because every glyph fills the em box) + top = 19 * this.fontSize / 24; + imgTop = imgLeft = 0; + baselinePosition = this.middle; + this.ctx.textBaseline = 'middle'; + } + + var imgData; + if (glyphWidth && glyphHeight) { + this.ctx.clearRect(imgLeft, imgTop, glyphWidth, glyphHeight); + this.ctx.fillText(char, this.buffer, baselinePosition); + imgData = this.ctx.getImageData(imgLeft, imgTop, glyphWidth, glyphHeight); + } + + var alphaChannel = new Uint8ClampedArray(width * height); + + prepareGrids(imgData, width, height, glyphWidth, glyphHeight, this.gridOuter, this.gridInner); + + edt(this.gridOuter, width, height, this.f, this.v, this.z); + edt(this.gridInner, width, height, this.f, this.v, this.z); + + extractAlpha(alphaChannel, width, height, this.gridOuter, this.gridInner, this.radius, this.cutoff); + + return { + data: alphaChannel, + metrics: { + width: glyphWidth, + height: glyphHeight, + sdfWidth: width, + sdfHeight: height, + top: top, + left: 0, + advance: advance + } + }; +}; + +TinySDF.prototype.draw = function (char) { + return this._draw(char, false).data; +}; + +TinySDF.prototype.drawWithMetrics = function (char) { + return this._draw(char, true); +}; + +// 2D Euclidean squared distance transform by Felzenszwalb & Huttenlocher https://cs.brown.edu/~pff/papers/dt-final.pdf +function edt(data, width, height, f, v, z) { + for (var x = 0; x < width; x++) edt1d(data, x, width, height, f, v, z); + for (var y = 0; y < height; y++) edt1d(data, y * width, 1, width, f, v, z); +} + +// 1D squared distance transform +function edt1d(grid, offset, stride, length, f, v, z) { + var q, k, s, r; + v[0] = 0; + z[0] = -INF; + z[1] = INF; + + for (q = 0; q < length; q++) f[q] = grid[offset + q * stride]; + + for (q = 1, k = 0, s = 0; q < length; q++) { + do { + r = v[k]; + s = (f[q] - f[r] + q * q - r * r) / (q - r) / 2; + } while (s <= z[k] && --k > -1); + + k++; + v[k] = q; + z[k] = s; + z[k + 1] = INF; + } + + for (q = 0, k = 0; q < length; q++) { + while (z[k + 1] < q) k++; + r = v[k]; + grid[offset + q * stride] = f[r] + (q - r) * (q - r); + } +} diff --git a/node_modules/@mapbox/tiny-sdf/package.json b/node_modules/@mapbox/tiny-sdf/package.json new file mode 100644 index 0000000000000000000000000000000000000000..dda6e2569086bce00231c44f732fbe75142689ff --- /dev/null +++ b/node_modules/@mapbox/tiny-sdf/package.json @@ -0,0 +1,34 @@ +{ + "name": "@mapbox/tiny-sdf", + "version": "1.2.5", + "description": "Browser-side SDF font generator", + "main": "index.js", + "scripts": { + "test": "eslint index.js" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/mapbox/tiny-sdf.git" + }, + "keywords": [ + "sdf", + "signed distance fields", + "font", + "canvas", + "text", + "distance transform" + ], + "author": "Vladimir Agafonkin", + "license": "BSD-2-Clause", + "bugs": { + "url": "https://github.com/mapbox/tiny-sdf/issues" + }, + "homepage": "https://github.com/mapbox/tiny-sdf#readme", + "devDependencies": { + "eslint": "^7.0.0", + "eslint-config-mourner": "^2.0.1" + }, + "eslintConfig": { + "extends": "mourner" + } +} diff --git a/node_modules/@mapbox/unitbezier/.travis.yml b/node_modules/@mapbox/unitbezier/.travis.yml new file mode 100644 index 0000000000000000000000000000000000000000..20fd86b6a5bee335c75b4efea34312ff7f3a039e --- /dev/null +++ b/node_modules/@mapbox/unitbezier/.travis.yml @@ -0,0 +1,3 @@ +language: node_js +node_js: + - 0.10 diff --git a/node_modules/@mapbox/unitbezier/README.md b/node_modules/@mapbox/unitbezier/README.md new file mode 100644 index 0000000000000000000000000000000000000000..9a3bb4e92b3c133ee35bb56318f6d394c5f18e40 --- /dev/null +++ b/node_modules/@mapbox/unitbezier/README.md @@ -0,0 +1,23 @@ +[![Build Status](https://travis-ci.org/mapbox/unitbezier.svg)](https://travis-ci.org/mapbox/unitbezier) + +# unitbezier + +Unit bezier interpolation function: a port to JavaScript from Webkit: + +http://svn.webkit.org/repository/webkit/trunk/Source/WebCore/platform/graphics/UnitBezier.h + +## api + +### new UnitBezier(p1x, p1y, p2x, p2y) + +Initialize a new bezier curve given the points + +### bezier.sampleCurveX(t) + +### bezier.sampleCurveY(t) + +### bezier.sampleCurveDerivativeX(t) + +### bezier.solveCurveX(t) + +### bezier.solve(x, epsilon) diff --git a/node_modules/@mapbox/unitbezier/index.js b/node_modules/@mapbox/unitbezier/index.js new file mode 100644 index 0000000000000000000000000000000000000000..ecdbce023a60668ca6b92079f96e744a28ac5e92 --- /dev/null +++ b/node_modules/@mapbox/unitbezier/index.js @@ -0,0 +1,105 @@ +/* + * Copyright (C) 2008 Apple Inc. All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * Ported from Webkit + * http://svn.webkit.org/repository/webkit/trunk/Source/WebCore/platform/graphics/UnitBezier.h + */ + +module.exports = UnitBezier; + +function UnitBezier(p1x, p1y, p2x, p2y) { + // Calculate the polynomial coefficients, implicit first and last control points are (0,0) and (1,1). + this.cx = 3.0 * p1x; + this.bx = 3.0 * (p2x - p1x) - this.cx; + this.ax = 1.0 - this.cx - this.bx; + + this.cy = 3.0 * p1y; + this.by = 3.0 * (p2y - p1y) - this.cy; + this.ay = 1.0 - this.cy - this.by; + + this.p1x = p1x; + this.p1y = p2y; + this.p2x = p2x; + this.p2y = p2y; +} + +UnitBezier.prototype.sampleCurveX = function(t) { + // `ax t^3 + bx t^2 + cx t' expanded using Horner's rule. + return ((this.ax * t + this.bx) * t + this.cx) * t; +}; + +UnitBezier.prototype.sampleCurveY = function(t) { + return ((this.ay * t + this.by) * t + this.cy) * t; +}; + +UnitBezier.prototype.sampleCurveDerivativeX = function(t) { + return (3.0 * this.ax * t + 2.0 * this.bx) * t + this.cx; +}; + +UnitBezier.prototype.solveCurveX = function(x, epsilon) { + if (typeof epsilon === 'undefined') epsilon = 1e-6; + + var t0, t1, t2, x2, i; + + // First try a few iterations of Newton's method -- normally very fast. + for (t2 = x, i = 0; i < 8; i++) { + + x2 = this.sampleCurveX(t2) - x; + if (Math.abs(x2) < epsilon) return t2; + + var d2 = this.sampleCurveDerivativeX(t2); + if (Math.abs(d2) < 1e-6) break; + + t2 = t2 - x2 / d2; + } + + // Fall back to the bisection method for reliability. + t0 = 0.0; + t1 = 1.0; + t2 = x; + + if (t2 < t0) return t0; + if (t2 > t1) return t1; + + while (t0 < t1) { + + x2 = this.sampleCurveX(t2); + if (Math.abs(x2 - x) < epsilon) return t2; + + if (x > x2) { + t0 = t2; + } else { + t1 = t2; + } + + t2 = (t1 - t0) * 0.5 + t0; + } + + // Failure. + return t2; +}; + +UnitBezier.prototype.solve = function(x, epsilon) { + return this.sampleCurveY(this.solveCurveX(x, epsilon)); +}; diff --git a/node_modules/@mapbox/unitbezier/package.json b/node_modules/@mapbox/unitbezier/package.json new file mode 100644 index 0000000000000000000000000000000000000000..3028103f1a7fd6ca7410c373e1aadb41b7979a9f --- /dev/null +++ b/node_modules/@mapbox/unitbezier/package.json @@ -0,0 +1,34 @@ +{ + "name": "@mapbox/unitbezier", + "version": "0.0.0", + "description": "unit bezier curve interpolation", + "main": "index.js", + "scripts": { + "test": "tap --coverage test/*.js" + }, + "repository": { + "type": "git", + "url": "git@github.com:mapbox/unitbezier.git" + }, + "keywords": [ + "unit", + "bezier", + "interpolation", + "webkit" + ], + "author": "", + "license": "BSD-2-Clause", + "bugs": { + "url": "https://github.com/mapbox/unitbezier/issues" + }, + "homepage": "https://github.com/mapbox/unitbezier", + "devDependencies": { + "cz-conventional-changelog": "1.2.0", + "tap": "~9.0.3" + }, + "config": { + "commitizen": { + "path": "./node_modules/cz-conventional-changelog" + } + } +} diff --git a/node_modules/@mapbox/unitbezier/test/unitbezier.js b/node_modules/@mapbox/unitbezier/test/unitbezier.js new file mode 100644 index 0000000000000000000000000000000000000000..75db049ac733333290b0e9d675ec70c40aa22e00 --- /dev/null +++ b/node_modules/@mapbox/unitbezier/test/unitbezier.js @@ -0,0 +1,16 @@ +var test = require('tap').test, + UnitBezier = require('../'); + +test('unit bezier', function(t) { + var u = new UnitBezier(0, 0, 1, 1); + t.equal(u.sampleCurveY(1), 1, 'sampleCurveY'); + t.equal(u.sampleCurveX(1), 1, 'sampleCurveX'); + t.equal(u.sampleCurveDerivativeX(0.1), 0.54, 'sampleCurveDerivativeX'); + t.equal(u.solveCurveX(0), 0, 'solveCurveX'); + t.equal(u.solveCurveX(1), 1, 'solveCurveX'); + t.equal(u.solveCurveX(1.25552, 1.e-8), 1, 'solveCurveX'); + t.equal(u.solveCurveX(1, 1e-8), 1, 'solveCurveX'); + t.equal(u.solveCurveX(0.5), 0.5, 'solveCurveX'); + t.equal(u.solve(0.5), 0.5, 'solve'); + t.end(); +}); diff --git a/node_modules/@mapbox/vector-tile/.eslintrc b/node_modules/@mapbox/vector-tile/.eslintrc new file mode 100644 index 0000000000000000000000000000000000000000..2ede22687d4ce4408aa846aa7f1986ea92a59ca8 --- /dev/null +++ b/node_modules/@mapbox/vector-tile/.eslintrc @@ -0,0 +1,3 @@ +{ + "extends": "eslint-config-unstyled" +} \ No newline at end of file diff --git a/node_modules/@mapbox/vector-tile/.travis.yml b/node_modules/@mapbox/vector-tile/.travis.yml new file mode 100644 index 0000000000000000000000000000000000000000..f5627428f8648024e9846fa26ce0d9ab8cfc4647 --- /dev/null +++ b/node_modules/@mapbox/vector-tile/.travis.yml @@ -0,0 +1,7 @@ +language: node_js +sudo: false +node_js: + - 4 +script: + - npm test + - npm run cov diff --git a/node_modules/@mapbox/vector-tile/CHANGELOG.md b/node_modules/@mapbox/vector-tile/CHANGELOG.md new file mode 100644 index 0000000000000000000000000000000000000000..0ac071ba72b240bd82faa3e1de3ad61303242beb --- /dev/null +++ b/node_modules/@mapbox/vector-tile/CHANGELOG.md @@ -0,0 +1,41 @@ +## vector-tile-js changelog + +### 1.3.1 (2017-03-02) + +- Fix bug causing infinite loop when parsing ClosePath command (#61) h/t @sanjin-saric +- Pin node-mapnik dependency to `~3.6.0` (#62, see also https://github.com/mapnik/node-mapnik/issues/848) + +### 1.3.0 (2016-07-18) + +- Added "id" property to VectorTileFeature (#43) + +### 1.2.1 (2016-05-18) + +- Fixed geometry structure of MultiPoints, Polygons, and MultiPolygons in toGeoJSON() + +### 1.2.0 (2015-12-10) + +- Added "id" property to toGeoJSON() output + +### 1.1.3 (2015-06-15) + +- Workaround for https://github.com/mapbox/mapnik-vector-tile/issues/90 + +### 1.1.2 (2015-03-05) + +- Fixed decoding of negative values in feature properties + +### 1.1.1 (2015-02-25) + +- Remove sphericalmercator dependency +- Correctly handle MultiPoint and MultiLineString features in toGeoJSON() + +### 1.1.0 (2015-02-21) + +- Added VectorTileFeature#toGeoJSON() + +### 1.0.0 (2014-12-26) + +### 0.0.1 (2014-04-13) + +- Initial release diff --git a/node_modules/@mapbox/vector-tile/LICENSE.txt b/node_modules/@mapbox/vector-tile/LICENSE.txt new file mode 100644 index 0000000000000000000000000000000000000000..a3473509bd7f7b8d39d992ff4731db245ebc0cbc --- /dev/null +++ b/node_modules/@mapbox/vector-tile/LICENSE.txt @@ -0,0 +1,28 @@ +Copyright (c) 2014, Mapbox + + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Mapbox nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/node_modules/@mapbox/vector-tile/README.md b/node_modules/@mapbox/vector-tile/README.md new file mode 100644 index 0000000000000000000000000000000000000000..66b897d57c8d96e0a82c8a935e85eba343d37383 --- /dev/null +++ b/node_modules/@mapbox/vector-tile/README.md @@ -0,0 +1,104 @@ +# vector-tile + +[![build status](https://secure.travis-ci.org/mapbox/vector-tile-js.svg)](http://travis-ci.org/mapbox/vector-tile-js) [![Coverage Status](https://coveralls.io/repos/mapbox/vector-tile-js/badge.svg)](https://coveralls.io/r/mapbox/vector-tile-js) + +This library reads [Mapbox Vector Tiles](https://github.com/mapbox/vector-tile-spec) and allows access to the layers and features. + +## Example + +```js +var VectorTile = require('@mapbox/vector-tile').VectorTile; +var Protobuf = require('pbf'); + +var tile = new VectorTile(new Protobuf(data)); + +// Contains a map of all layers +tile.layers; + +var landuse = tile.layers.landuse; + +// Amount of features in this layer +landuse.length; + +// Returns the first feature +landuse.feature(0); +``` + +Vector tiles contained in [serialtiles-spec](https://github.com/mapbox/serialtiles-spec) +are gzip-encoded, so a complete example of parsing them with the native +zlib module would be: + +```js +var VectorTile = require('vector-tile').VectorTile; +var Protobuf = require('pbf'); +var zlib = require('zlib'); + +zlib.gunzip(data, function(err, buffer) { + var tile = new VectorTile(new Protobuf(buffer)); +}); +``` + +## Depends + + - Node.js v0.10.x or v0.8.x + + +## Install + +To install: + + npm install @mapbox/vector-tile + + +## API Reference + + +### VectorTile + +An object that parses vector tile data and makes it readable. + +#### Constructor + +- **new VectorTile(protobuf[, end])** — + parses the vector tile data contained in the given [Protobuf](https://github.com/mapbox/pbf) object, + saving resulting layers in the created object as a `layers` property. Optionally accepts end index. + +#### Properties + +- **layers** (Object) — an object containing parsed layers in the form of `{: , ...}`, +where each layer is a `VectorTileLayer` object. + + +### VectorTileLayer + +An object that contains the data for a single vector tile layer. + +#### Properties + +- **version** (`Number`, default: `1`) +- **name** (`String) `— layer name +- **extent** (`Number`, default: `4096`) — tile extent size +- **length** (`Number`) — number of features in the layer + +#### Methods + +- **feature(i)** — get a feature (`VectorTileFeature`) by the given index from the layer. + + +### VectorTileFeature + +An object that contains the data for a single feature. + +#### Properties + +- **type** (`Number`) — type of the feature (also see `VectorTileFeature.types`) +- **extent** (`Number`) — feature extent size +- **id** (`Number`) — feature identifier, if present +- **properties** (`Object`) — object literal with feature properties + +#### Methods + +- **loadGeometry()** — parses feature geometry and returns an array of + [Point](https://github.com/mapbox/point-geometry) arrays (with each point having `x` and `y` properties) +- **bbox()** — calculates and returns the bounding box of the feature in the form `[x1, y1, x2, y2]` +- **toGeoJSON(x, y, z)** — returns a GeoJSON representation of the feature. (`x`, `y`, and `z` refer to the containing tile's index.) diff --git a/node_modules/@mapbox/vector-tile/fixtures.js b/node_modules/@mapbox/vector-tile/fixtures.js new file mode 100644 index 0000000000000000000000000000000000000000..a14d4f59a2a388a15f84537749e32dfe33877ae2 --- /dev/null +++ b/node_modules/@mapbox/vector-tile/fixtures.js @@ -0,0 +1,157 @@ +var mapnik = require('mapnik'); +var path = require('path'); +var fs = require('fs'); + +mapnik.register_datasource(path.join(mapnik.settings.paths.input_plugins, 'geojson.input')); + +var fixtures = { + "zero-point": { + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "geometry": { + "type": "MultiPoint", + "coordinates": [] + }, + "properties": {} + } + ] + }, + "zero-line": { + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "geometry": { + "type": "MultiLineString", + "coordinates": [] + }, + "properties": {} + } + ] + }, + "zero-polygon": { + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "geometry": { + "type": "MultiPolygon", + "coordinates": [] + }, + "properties": {} + } + ] + }, + "singleton-multi-point": { + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "geometry": { + "type": "MultiPoint", + "coordinates": [[1, 2]] + }, + "properties": {} + } + ] + }, + "singleton-multi-line": { + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "geometry": { + "type": "MultiLineString", + "coordinates": [[[1, 2], [3, 4]]] + }, + "properties": {} + } + ] + }, + "singleton-multi-polygon": { + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "geometry": { + "type": "MultiPolygon", + "coordinates": [[[[0, 0], [1, 0], [1, 1], [0, 0]]]] + }, + "properties": {} + } + ] + }, + "multi-point": { + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "geometry": { + "type": "MultiPoint", + "coordinates": [[1, 2], [3, 4]] + }, + "properties": {} + } + ] + }, + "multi-line": { + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "geometry": { + "type": "MultiLineString", + "coordinates": [[[1, 2], [3, 4]], [[5, 6], [7, 8]]] + }, + "properties": {} + } + ] + }, + "multi-polygon": { + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "geometry": { + "type": "MultiPolygon", + "coordinates": [[[[0, 0], [1, 0], [1, 1], [0, 0]]], [[[0, 0], [-1, 0], [-1, -1], [0, 0]]]] + }, + "properties": {} + } + ] + }, + "polygon-with-inner": { + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "geometry": { + "type": "Polygon", + "coordinates": [[[-2, 2], [2, 2], [2, -2], [-2, -2], [-2, 2]], [[-1, 1], [1, 1], [1, -1], [-1, -1], [-1, 1]]] + }, + "properties": {} + } + ] + }, + "stacked-multipolygon": { + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "geometry": { + "type": "MultiPolygon", + "coordinates": [[[[-2, 2], [2, 2], [2, -2], [-2, -2], [-2, 2]]], [[[-1, 1], [1, 1], [1, -1], [-1, -1], [-1, 1]]]] + }, + "properties": {} + } + ] + } +} + +for (var fixture in fixtures) { + var vtile = new mapnik.VectorTile(0, 0, 0); + vtile.addGeoJSON(JSON.stringify(fixtures[fixture]), "geojson"); + fs.writeFileSync('./test/fixtures/' + fixture + '.pbf', vtile.getData()); +} diff --git a/node_modules/@mapbox/vector-tile/index.js b/node_modules/@mapbox/vector-tile/index.js new file mode 100644 index 0000000000000000000000000000000000000000..8938a55f5125b38c06c00c909af18977f9fd518c --- /dev/null +++ b/node_modules/@mapbox/vector-tile/index.js @@ -0,0 +1,3 @@ +module.exports.VectorTile = require('./lib/vectortile.js'); +module.exports.VectorTileFeature = require('./lib/vectortilefeature.js'); +module.exports.VectorTileLayer = require('./lib/vectortilelayer.js'); diff --git a/node_modules/@mapbox/vector-tile/lib/vectortile.js b/node_modules/@mapbox/vector-tile/lib/vectortile.js new file mode 100644 index 0000000000000000000000000000000000000000..360a5698d7ed8314ceebe235b49e66d0b84e479d --- /dev/null +++ b/node_modules/@mapbox/vector-tile/lib/vectortile.js @@ -0,0 +1,17 @@ +'use strict'; + +var VectorTileLayer = require('./vectortilelayer'); + +module.exports = VectorTile; + +function VectorTile(pbf, end) { + this.layers = pbf.readFields(readTile, {}, end); +} + +function readTile(tag, layers, pbf) { + if (tag === 3) { + var layer = new VectorTileLayer(pbf, pbf.readVarint() + pbf.pos); + if (layer.length) layers[layer.name] = layer; + } +} + diff --git a/node_modules/@mapbox/vector-tile/lib/vectortilefeature.js b/node_modules/@mapbox/vector-tile/lib/vectortilefeature.js new file mode 100644 index 0000000000000000000000000000000000000000..b9880a1386a6f664e1ac0ce3d9d195ce1f67381d --- /dev/null +++ b/node_modules/@mapbox/vector-tile/lib/vectortilefeature.js @@ -0,0 +1,233 @@ +'use strict'; + +var Point = require('@mapbox/point-geometry'); + +module.exports = VectorTileFeature; + +function VectorTileFeature(pbf, end, extent, keys, values) { + // Public + this.properties = {}; + this.extent = extent; + this.type = 0; + + // Private + this._pbf = pbf; + this._geometry = -1; + this._keys = keys; + this._values = values; + + pbf.readFields(readFeature, this, end); +} + +function readFeature(tag, feature, pbf) { + if (tag == 1) feature.id = pbf.readVarint(); + else if (tag == 2) readTag(pbf, feature); + else if (tag == 3) feature.type = pbf.readVarint(); + else if (tag == 4) feature._geometry = pbf.pos; +} + +function readTag(pbf, feature) { + var end = pbf.readVarint() + pbf.pos; + + while (pbf.pos < end) { + var key = feature._keys[pbf.readVarint()], + value = feature._values[pbf.readVarint()]; + feature.properties[key] = value; + } +} + +VectorTileFeature.types = ['Unknown', 'Point', 'LineString', 'Polygon']; + +VectorTileFeature.prototype.loadGeometry = function() { + var pbf = this._pbf; + pbf.pos = this._geometry; + + var end = pbf.readVarint() + pbf.pos, + cmd = 1, + length = 0, + x = 0, + y = 0, + lines = [], + line; + + while (pbf.pos < end) { + if (length <= 0) { + var cmdLen = pbf.readVarint(); + cmd = cmdLen & 0x7; + length = cmdLen >> 3; + } + + length--; + + if (cmd === 1 || cmd === 2) { + x += pbf.readSVarint(); + y += pbf.readSVarint(); + + if (cmd === 1) { // moveTo + if (line) lines.push(line); + line = []; + } + + line.push(new Point(x, y)); + + } else if (cmd === 7) { + + // Workaround for https://github.com/mapbox/mapnik-vector-tile/issues/90 + if (line) { + line.push(line[0].clone()); // closePolygon + } + + } else { + throw new Error('unknown command ' + cmd); + } + } + + if (line) lines.push(line); + + return lines; +}; + +VectorTileFeature.prototype.bbox = function() { + var pbf = this._pbf; + pbf.pos = this._geometry; + + var end = pbf.readVarint() + pbf.pos, + cmd = 1, + length = 0, + x = 0, + y = 0, + x1 = Infinity, + x2 = -Infinity, + y1 = Infinity, + y2 = -Infinity; + + while (pbf.pos < end) { + if (length <= 0) { + var cmdLen = pbf.readVarint(); + cmd = cmdLen & 0x7; + length = cmdLen >> 3; + } + + length--; + + if (cmd === 1 || cmd === 2) { + x += pbf.readSVarint(); + y += pbf.readSVarint(); + if (x < x1) x1 = x; + if (x > x2) x2 = x; + if (y < y1) y1 = y; + if (y > y2) y2 = y; + + } else if (cmd !== 7) { + throw new Error('unknown command ' + cmd); + } + } + + return [x1, y1, x2, y2]; +}; + +VectorTileFeature.prototype.toGeoJSON = function(x, y, z) { + var size = this.extent * Math.pow(2, z), + x0 = this.extent * x, + y0 = this.extent * y, + coords = this.loadGeometry(), + type = VectorTileFeature.types[this.type], + i, j; + + function project(line) { + for (var j = 0; j < line.length; j++) { + var p = line[j], y2 = 180 - (p.y + y0) * 360 / size; + line[j] = [ + (p.x + x0) * 360 / size - 180, + 360 / Math.PI * Math.atan(Math.exp(y2 * Math.PI / 180)) - 90 + ]; + } + } + + switch (this.type) { + case 1: + var points = []; + for (i = 0; i < coords.length; i++) { + points[i] = coords[i][0]; + } + coords = points; + project(coords); + break; + + case 2: + for (i = 0; i < coords.length; i++) { + project(coords[i]); + } + break; + + case 3: + coords = classifyRings(coords); + for (i = 0; i < coords.length; i++) { + for (j = 0; j < coords[i].length; j++) { + project(coords[i][j]); + } + } + break; + } + + if (coords.length === 1) { + coords = coords[0]; + } else { + type = 'Multi' + type; + } + + var result = { + type: "Feature", + geometry: { + type: type, + coordinates: coords + }, + properties: this.properties + }; + + if ('id' in this) { + result.id = this.id; + } + + return result; +}; + +// classifies an array of rings into polygons with outer rings and holes + +function classifyRings(rings) { + var len = rings.length; + + if (len <= 1) return [rings]; + + var polygons = [], + polygon, + ccw; + + for (var i = 0; i < len; i++) { + var area = signedArea(rings[i]); + if (area === 0) continue; + + if (ccw === undefined) ccw = area < 0; + + if (ccw === area < 0) { + if (polygon) polygons.push(polygon); + polygon = [rings[i]]; + + } else { + polygon.push(rings[i]); + } + } + if (polygon) polygons.push(polygon); + + return polygons; +} + +function signedArea(ring) { + var sum = 0; + for (var i = 0, len = ring.length, j = len - 1, p1, p2; i < len; j = i++) { + p1 = ring[i]; + p2 = ring[j]; + sum += (p2.x - p1.x) * (p1.y + p2.y); + } + return sum; +} diff --git a/node_modules/@mapbox/vector-tile/lib/vectortilelayer.js b/node_modules/@mapbox/vector-tile/lib/vectortilelayer.js new file mode 100644 index 0000000000000000000000000000000000000000..07a9e418511e8bf48fd0c8abd13826a5d28b81e9 --- /dev/null +++ b/node_modules/@mapbox/vector-tile/lib/vectortilelayer.js @@ -0,0 +1,61 @@ +'use strict'; + +var VectorTileFeature = require('./vectortilefeature.js'); + +module.exports = VectorTileLayer; + +function VectorTileLayer(pbf, end) { + // Public + this.version = 1; + this.name = null; + this.extent = 4096; + this.length = 0; + + // Private + this._pbf = pbf; + this._keys = []; + this._values = []; + this._features = []; + + pbf.readFields(readLayer, this, end); + + this.length = this._features.length; +} + +function readLayer(tag, layer, pbf) { + if (tag === 15) layer.version = pbf.readVarint(); + else if (tag === 1) layer.name = pbf.readString(); + else if (tag === 5) layer.extent = pbf.readVarint(); + else if (tag === 2) layer._features.push(pbf.pos); + else if (tag === 3) layer._keys.push(pbf.readString()); + else if (tag === 4) layer._values.push(readValueMessage(pbf)); +} + +function readValueMessage(pbf) { + var value = null, + end = pbf.readVarint() + pbf.pos; + + while (pbf.pos < end) { + var tag = pbf.readVarint() >> 3; + + value = tag === 1 ? pbf.readString() : + tag === 2 ? pbf.readFloat() : + tag === 3 ? pbf.readDouble() : + tag === 4 ? pbf.readVarint64() : + tag === 5 ? pbf.readVarint() : + tag === 6 ? pbf.readSVarint() : + tag === 7 ? pbf.readBoolean() : null; + } + + return value; +} + +// return feature `i` from this layer as a `VectorTileFeature` +VectorTileLayer.prototype.feature = function(i) { + if (i < 0 || i >= this._features.length) throw new Error('feature index out of bounds'); + + this._pbf.pos = this._features[i]; + + var end = this._pbf.readVarint() + this._pbf.pos; + return new VectorTileFeature(this._pbf, end, this.extent, this._keys, this._values); +}; diff --git a/node_modules/@mapbox/vector-tile/package.json b/node_modules/@mapbox/vector-tile/package.json new file mode 100644 index 0000000000000000000000000000000000000000..9f0f370fefecc6c64170be344e3203136aeadab7 --- /dev/null +++ b/node_modules/@mapbox/vector-tile/package.json @@ -0,0 +1,33 @@ +{ + "name": "@mapbox/vector-tile", + "description": "Parses vector tiles", + "repository": "https://github.com/mapbox/vector-tile-js.git", + "version": "1.3.1", + "license": "BSD-3-Clause", + "main": "index.js", + "dependencies": { + "@mapbox/point-geometry": "~0.1.0" + }, + "devDependencies": { + "benchmark": "^1.0.0", + "coveralls": "~2.11.2", + "istanbul": "~0.3.6", + "mapnik": "~3.6.0", + "jshint": "^2.6.3", + "pbf": "^1.3.2", + "tape": "~3.5.0", + "eslint": "~1.00.0", + "eslint-config-unstyled": "^1.1.0" + }, + "jshintConfig": { + "trailing": true, + "undef": true, + "unused": true, + "indent": 4, + "node": true + }, + "scripts": { + "test": "eslint lib index.js && jshint lib && tape test/parse.test.js", + "cov": "istanbul cover ./node_modules/.bin/tape test/parse.test.js && coveralls < ./coverage/lcov.info" + } +} diff --git a/node_modules/@mapbox/vector-tile/proto/vector_tile.proto b/node_modules/@mapbox/vector-tile/proto/vector_tile.proto new file mode 100644 index 0000000000000000000000000000000000000000..3a489c38574dbf8000ce41f08764670a5127d100 --- /dev/null +++ b/node_modules/@mapbox/vector-tile/proto/vector_tile.proto @@ -0,0 +1,88 @@ +// Protocol Version 1 + +message tile { + enum GeomType { + Unknown = 0; + Point = 1; + LineString = 2; + Polygon = 3; + } + + // Variant type encoding + message value { + // Exactly one of these values may be present in a valid message + optional string string_value = 1; + optional float float_value = 2; + optional double double_value = 3; + optional int64 int_value = 4; + optional uint64 uint_value = 5; + optional sint64 sint_value = 6; + optional bool bool_value = 7; + + extensions 8 to max; + } + + message feature { + optional uint64 id = 1; + + // Tags of this feature. Even numbered values refer to the nth + // value in the keys list on the tile message, odd numbered + // values refer to the nth value in the values list on the tile + // message. + repeated uint32 tags = 2 [ packed = true ]; + + // The type of geometry stored in this feature. + optional GeomType type = 3 [ default = Unknown ]; + + // Contains a stream of commands and parameters (vertices). The + // repeat count is shifted to the left by 3 bits. This means + // that the command has 3 bits (0-7). The repeat count + // indicates how often this command is to be repeated. Defined + // commands are: + // - MoveTo: 1 (2 parameters follow) + // - LineTo: 2 (2 parameters follow) + // - ClosePath: 7 (no parameters follow) + // + // Ex.: MoveTo(3, 6), LineTo(8, 12), LineTo(20, 34), ClosePath + // Encoded as: [ 9 3 6 18 5 6 12 22 15 ] + // == command type 7 (ClosePath), length 1 + // ===== relative LineTo(+12, +22) == LineTo(20, 34) + // === relative LineTo(+5, +6) == LineTo(8, 12) + // == [00010 010] = command type 2 (LineTo), length 2 + // === relative MoveTo(+3, +6) + // == [00001 001] = command type 1 (MoveTo), length 1 + // Commands are encoded as uint32 varints, vertex parameters are + // encoded as sint32 varints (zigzag). Vertex parameters are + // also encoded as deltas to the previous position. The original + // position is (0,0) + repeated uint32 geometry = 4 [ packed = true ]; + } + + message layer { + // Any compliant implementation must first read the version + // number encoded in this message and choose the correct + // implementation for this version number before proceeding to + // decode other parts of this message. + required uint32 version = 15 [ default = 1 ]; + + required string name = 1; + + // The actual features in this tile. + repeated feature features = 2; + + // Dictionary encoding for keys + repeated string keys = 3; + + // Dictionary encoding for values + repeated value values = 4; + + // The bounding box in this tile spans from 0..4095 units + optional uint32 extent = 5 [ default = 4096 ]; + + extensions 16 to max; + } + + repeated layer layers = 3; + + extensions 16 to 8191; +} diff --git a/node_modules/@mapbox/vector-tile/test/bench.js b/node_modules/@mapbox/vector-tile/test/bench.js new file mode 100644 index 0000000000000000000000000000000000000000..f7e593be9ce445b8ebb39beda1d89897e590f27c --- /dev/null +++ b/node_modules/@mapbox/vector-tile/test/bench.js @@ -0,0 +1,36 @@ +var Pbf = require('pbf'), + VectorTile = require('..').VectorTile, + Benchmark = require('benchmark'), + fs = require('fs'); + +var suite = new Benchmark.Suite(), + data = fs.readFileSync(__dirname + '/fixtures/14-8801-5371.vector.Pbf'); + +readTile(); // output any errors before running the suite +readTile(true); + +suite +.add('read tile with geometries', function() { + readTile(true); +}) +.add('read tile without geometries', function() { + readTile(); +}) +.on('cycle', function(event) { + console.log(String(event.target)); +}) +.run(); + + +function readTile(loadGeom, loadPacked) { + var buf = new Pbf(data), + vt = new VectorTile(buf); + + for (var id in vt.layers) { + var layer = vt.layers[id]; + for (var i = 0; i < layer.length; i++) { + var feature = layer.feature(i); + if (loadGeom) feature.loadGeometry(); + } + } +} diff --git a/node_modules/@mapbox/vector-tile/test/fixtures/12-1143-1497.vector.pbf b/node_modules/@mapbox/vector-tile/test/fixtures/12-1143-1497.vector.pbf new file mode 100644 index 0000000000000000000000000000000000000000..80bbb2780e20ca0fc80ff05288656f5427219f0b Binary files /dev/null and b/node_modules/@mapbox/vector-tile/test/fixtures/12-1143-1497.vector.pbf differ diff --git a/node_modules/@mapbox/vector-tile/test/fixtures/14-8801-5371.vector.pbf b/node_modules/@mapbox/vector-tile/test/fixtures/14-8801-5371.vector.pbf new file mode 100644 index 0000000000000000000000000000000000000000..87811b07ba89ae0db391cc372c273476ad150bd9 --- /dev/null +++ b/node_modules/@mapbox/vector-tile/test/fixtures/14-8801-5371.vector.pbf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:02cf1d0154ff59d8c559d041e3b41297f5e260d925fc5e49ad00743478a12d60 +size 182636 diff --git a/node_modules/@mapbox/vector-tile/test/fixtures/lots-of-tags.vector.pbf b/node_modules/@mapbox/vector-tile/test/fixtures/lots-of-tags.vector.pbf new file mode 100644 index 0000000000000000000000000000000000000000..281b8624bf466e53bad6a46d15f6e25ff0829ccc Binary files /dev/null and b/node_modules/@mapbox/vector-tile/test/fixtures/lots-of-tags.vector.pbf differ diff --git a/node_modules/@mapbox/vector-tile/test/fixtures/multi-line.pbf b/node_modules/@mapbox/vector-tile/test/fixtures/multi-line.pbf new file mode 100644 index 0000000000000000000000000000000000000000..a00081602db6e01da14d82203e21bdf92f6f9891 --- /dev/null +++ b/node_modules/@mapbox/vector-tile/test/fixtures/multi-line.pbf @@ -0,0 +1,4 @@ +$x +geojson(€ " – Ò +.- .+ +.- \ No newline at end of file diff --git a/node_modules/@mapbox/vector-tile/test/fixtures/multi-point.pbf b/node_modules/@mapbox/vector-tile/test/fixtures/multi-point.pbf new file mode 100644 index 0000000000000000000000000000000000000000..f49d513b06278637c9fd7068a16bf1ad9d1664ed --- /dev/null +++ b/node_modules/@mapbox/vector-tile/test/fixtures/multi-point.pbf @@ -0,0 +1,2 @@ +x +geojson(€  "– Ò.- \ No newline at end of file diff --git a/node_modules/@mapbox/vector-tile/test/fixtures/multi-polygon.pbf b/node_modules/@mapbox/vector-tile/test/fixtures/multi-polygon.pbf new file mode 100644 index 0000000000000000000000000000000000000000..0d81bd6bc93eda42b44d369cd2c5e79ae476f04a Binary files /dev/null and b/node_modules/@mapbox/vector-tile/test/fixtures/multi-polygon.pbf differ diff --git a/node_modules/@mapbox/vector-tile/test/fixtures/multipolygon-with-closepath.pbf b/node_modules/@mapbox/vector-tile/test/fixtures/multipolygon-with-closepath.pbf new file mode 100644 index 0000000000000000000000000000000000000000..40bb2dceeb5f4780063421011874ca48e55f36db Binary files /dev/null and b/node_modules/@mapbox/vector-tile/test/fixtures/multipolygon-with-closepath.pbf differ diff --git a/node_modules/@mapbox/vector-tile/test/fixtures/multipolygon.pbf b/node_modules/@mapbox/vector-tile/test/fixtures/multipolygon.pbf new file mode 100644 index 0000000000000000000000000000000000000000..171c073b1da39d4f83079e9de804ba1c60e468fb Binary files /dev/null and b/node_modules/@mapbox/vector-tile/test/fixtures/multipolygon.pbf differ diff --git a/node_modules/@mapbox/vector-tile/test/fixtures/polygon-with-inner.pbf b/node_modules/@mapbox/vector-tile/test/fixtures/polygon-with-inner.pbf new file mode 100644 index 0000000000000000000000000000000000000000..5550fd82465e9cf274df0eb6cd532cd2ee685cea Binary files /dev/null and b/node_modules/@mapbox/vector-tile/test/fixtures/polygon-with-inner.pbf differ diff --git a/node_modules/@mapbox/vector-tile/test/fixtures/singleton-multi-line.pbf b/node_modules/@mapbox/vector-tile/test/fixtures/singleton-multi-line.pbf new file mode 100644 index 0000000000000000000000000000000000000000..86235274999f4d003e1380932d96cc2f8bedc6a8 --- /dev/null +++ b/node_modules/@mapbox/vector-tile/test/fixtures/singleton-multi-line.pbf @@ -0,0 +1,3 @@ +x +geojson(€ " – Ò +.- \ No newline at end of file diff --git a/node_modules/@mapbox/vector-tile/test/fixtures/singleton-multi-point.pbf b/node_modules/@mapbox/vector-tile/test/fixtures/singleton-multi-point.pbf new file mode 100644 index 0000000000000000000000000000000000000000..1e08de9610ffcd892c46ef1fb87290ce2f24193e --- /dev/null +++ b/node_modules/@mapbox/vector-tile/test/fixtures/singleton-multi-point.pbf @@ -0,0 +1,2 @@ +x +geojson(€  " – Ò \ No newline at end of file diff --git a/node_modules/@mapbox/vector-tile/test/fixtures/singleton-multi-polygon.pbf b/node_modules/@mapbox/vector-tile/test/fixtures/singleton-multi-polygon.pbf new file mode 100644 index 0000000000000000000000000000000000000000..a48ff0c7c267ed3de1c40b537382a794d9398165 Binary files /dev/null and b/node_modules/@mapbox/vector-tile/test/fixtures/singleton-multi-polygon.pbf differ diff --git a/node_modules/@mapbox/vector-tile/test/fixtures/stacked-multipolygon.pbf b/node_modules/@mapbox/vector-tile/test/fixtures/stacked-multipolygon.pbf new file mode 100644 index 0000000000000000000000000000000000000000..e039c4cbbb938fd4e771eb2f98dff659273e6561 Binary files /dev/null and b/node_modules/@mapbox/vector-tile/test/fixtures/stacked-multipolygon.pbf differ diff --git a/node_modules/@mapbox/vector-tile/test/fixtures/zero-line.pbf b/node_modules/@mapbox/vector-tile/test/fixtures/zero-line.pbf new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/node_modules/@mapbox/vector-tile/test/fixtures/zero-point.pbf b/node_modules/@mapbox/vector-tile/test/fixtures/zero-point.pbf new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/node_modules/@mapbox/vector-tile/test/fixtures/zero-polygon.pbf b/node_modules/@mapbox/vector-tile/test/fixtures/zero-polygon.pbf new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/node_modules/@mapbox/vector-tile/test/parse.test.js b/node_modules/@mapbox/vector-tile/test/parse.test.js new file mode 100644 index 0000000000000000000000000000000000000000..156bedbe5d484107ce63c834118ec617196ba4db --- /dev/null +++ b/node_modules/@mapbox/vector-tile/test/parse.test.js @@ -0,0 +1,225 @@ +var test = require('tape'), + fs = require('fs'), + Protobuf = require('pbf'), + VectorTile = require('..').VectorTile, + VectorTileLayer = require('..').VectorTileLayer, + VectorTileFeature = require('..').VectorTileFeature; + +function approximateDeepEqual(a, b, epsilon) { + epsilon = epsilon || 1e-6; + + if (typeof a !== typeof b) + return false; + if (typeof a === 'number') + return Math.abs(a - b) < epsilon; + if (a === null || typeof a !== 'object') + return a === b; + + var ka = Object.keys(a); + var kb = Object.keys(b); + + if (ka.length != kb.length) + return false; + + ka.sort(); + kb.sort(); + + for (var i = 0; i < ka.length; i++) + if (ka[i] != kb[i] || !approximateDeepEqual(a[ka[i]], b[ka[i]], epsilon)) + return false; + + return true; +} + +test('parsing vector tiles', function(t) { + var data = fs.readFileSync(__dirname + '/fixtures/14-8801-5371.vector.pbf'); + + t.test('should have all layers', function(t) { + var tile = new VectorTile(new Protobuf(data)); + + t.deepEqual(Object.keys(tile.layers), [ + 'landuse', 'waterway', 'water', 'barrier_line', 'building', + 'landuse_overlay', 'tunnel', 'road', 'bridge', 'place_label', + 'water_label', 'poi_label', 'road_label', 'waterway_label' ]); + + t.end(); + }); + + t.test('should extract the tags of a feature', function(t) { + var tile = new VectorTile(new Protobuf(data)); + + t.equal(tile.layers.poi_label.length, 558); + + var park = tile.layers.poi_label.feature(11); + + t.deepEqual(park.bbox(), [ 3898, 1731, 3898, 1731 ]); + + t.throws(function() { + var park = tile.layers.poi_label.feature(1e9); + }, 'throws on reading a feature out of bounds'); + + t.equal(park.id, 3000003150561); + + t.equal(park.properties.name, 'Mauerpark'); + t.equal(park.properties.type, 'Park'); + + // Check point geometry + t.deepEqual(park.loadGeometry(), [ [ { x: 3898, y: 1731 } ] ]); + + // Check line geometry + t.deepEqual(tile.layers.road.feature(656).loadGeometry(), [ [ { x: 1988, y: 306 }, { x: 1808, y: 321 }, { x: 1506, y: 347 } ] ]); + t.end(); + }); + + t.test('changing first point of a polygon should not change last point', function(t) { + var tile = new VectorTile(new Protobuf(data)); + + var building = tile.layers.building.feature(0).loadGeometry(); + t.deepEqual(building, [ [ { x: 2039, y: -32 }, { x: 2035, y: -31 }, { x: 2032, y: -31 }, { x: 2032, y: -32 }, { x: 2039, y: -32 } ] ]); + building[0][0].x = 1; + building[0][0].y = 2; + building[0][1].x = 3; + building[0][1].y = 4; + t.deepEqual(building, [ [ { x: 1, y: 2 }, { x: 3, y: 4 }, { x: 2032, y: -31 }, { x: 2032, y: -32 }, { x: 2039, y: -32 } ] ]); + t.end(); + }); + + t.test('toGeoJSON', function(t) { + var tile = new VectorTile(new Protobuf(data)); + + t.ok(approximateDeepEqual(tile.layers.poi_label.feature(11).toGeoJSON(8801, 5371, 14), { + type: 'Feature', + id: 3000003150561, + properties: { + localrank: 1, + maki: 'park', + name: 'Mauerpark', + name_de: 'Mauerpark', + name_en: 'Mauerpark', + name_es: 'Mauerpark', + name_fr: 'Mauerpark', + osm_id: 3000003150561, + ref: '', + scalerank: 2, + type: 'Park' + }, + geometry: { + type: 'Point', + coordinates: [13.402258157730103, 52.54398925380624] + } + })); + + t.ok(approximateDeepEqual(tile.layers.bridge.feature(0).toGeoJSON(8801, 5371, 14), { + type: 'Feature', + id: 238162948, + properties: { + class: 'service', + oneway: 0, + osm_id: 238162948, + type: 'service' + }, + geometry: { + type: 'LineString', + coordinates: [[13.399457931518555, 52.546334844036416], [13.399441838264465, 52.546504478525016]] + } + })); + + t.ok(approximateDeepEqual(tile.layers.building.feature(0).toGeoJSON(8801, 5371, 14), { + type: 'Feature', + id: 1000267229912, + properties: { + osm_id: 1000267229912 + }, + geometry: { + type: 'Polygon', + coordinates: [[[13.392285704612732, 52.54974045706258], [13.392264246940613, 52.549737195107554], + [13.392248153686523, 52.549737195107554], [13.392248153686523, 52.54974045706258], + [13.392285704612732, 52.54974045706258]]] + } + })); + + function geoJSONFromFixture(name) { + var tile = new VectorTile(new Protobuf(fs.readFileSync(__dirname + '/fixtures/' + name + '.pbf'))); + return tile.layers.geojson.feature(0).toGeoJSON(0, 0, 0); + } + + // https://github.com/mapbox/vector-tile-spec/issues/30 + t.ok(approximateDeepEqual(geoJSONFromFixture("singleton-multi-point").geometry, { + type: 'Point', + coordinates: [1, 2] + }, 1e-1)); + t.ok(approximateDeepEqual(geoJSONFromFixture("singleton-multi-line").geometry, { + type: 'LineString', + coordinates: [[1, 2], [3, 4]] + }, 1e-1)); + t.ok(approximateDeepEqual(geoJSONFromFixture("singleton-multi-polygon").geometry, { + type: 'Polygon', + coordinates: [[[1, 0], [0, 0], [1, 1], [1, 0]]] + }, 1e-1)); + + t.ok(approximateDeepEqual(geoJSONFromFixture("multi-point").geometry, { + type: 'MultiPoint', + coordinates: [[1, 2], [3, 4]] + }, 1e-1)); + t.ok(approximateDeepEqual(geoJSONFromFixture("multi-line").geometry, { + type: 'MultiLineString', + coordinates: [[[1, 2], [3, 4]], [[5, 6], [7, 8]]] + }, 1e-1)); + t.ok(approximateDeepEqual(geoJSONFromFixture("multi-polygon").geometry, { + type: 'MultiPolygon', + coordinates: [[[[1, 0], [0, 0], [1, 1], [1, 0]]], [[[-1, -1], [-1, 0], [0, 0], [-1, -1]]]] + }, 1e-1)); + + // https://github.com/mapbox/vector-tile-js/issues/32 + t.ok(approximateDeepEqual(geoJSONFromFixture("polygon-with-inner").geometry, { + type: 'Polygon', + coordinates: [[[2, -2], [-2, -2], [-2, 2], [2, 2], [2, -2]], [[-1, 1], [-1, -1], [1, -1], [1, 1], [-1, 1]]] + }, 1e-1)); + t.ok(approximateDeepEqual(geoJSONFromFixture("stacked-multipolygon").geometry, { + type: 'MultiPolygon', + coordinates: [[[[2, -2], [-2, -2], [-2, 2], [2, 2], [2, -2]]], [[[1, -1], [-1, -1], [-1, 1], [1, 1], [1, -1]]]] + }, 1e-1)); + + t.end(); + }) +}); + +test('VectorTileLayer', function(t) { + var emptyLayer = new VectorTileLayer(new Protobuf(new Buffer([]))); + t.ok(emptyLayer, 'can be created with no values'); + t.end(); +}); + +test('VectorTileFeature', function(t) { + var emptyFeature = new VectorTileFeature(new Protobuf(new Buffer([]))); + t.ok(emptyFeature, 'can be created with no values'); + t.ok(Array.isArray(VectorTileFeature.types)); + t.deepEqual(VectorTileFeature.types, ['Unknown', 'Point', 'LineString', 'Polygon']); + t.end(); +}); + +test('https://github.com/mapbox/vector-tile-js/issues/15', function(t) { + var data = fs.readFileSync(__dirname + '/fixtures/lots-of-tags.vector.pbf'); + var tile = new VectorTile(new Protobuf(data)); + t.ok(tile.layers["stuttgart-rails"].feature(0)); + t.end(); +}); + +test('https://github.com/mapbox/mapbox-gl-js/issues/1019', function(t) { + var data = fs.readFileSync(__dirname + '/fixtures/12-1143-1497.vector.pbf'); + var tile = new VectorTile(new Protobuf(data)); + t.ok(tile.layers["water"].feature(1).loadGeometry()); + t.end(); +}); + +test('https://github.com/mapbox/vector-tile-js/issues/60', function(t) { + var data = fs.readFileSync(__dirname + '/fixtures/multipolygon-with-closepath.pbf'); + var tile = new VectorTile(new Protobuf(data)); + for (var id in tile.layers) { + var layer = tile.layers[id]; + for (var i = 0; i < layer.length; i++) { + layer.feature(i).loadGeometry(); + } + } + t.end(); +}); diff --git a/node_modules/@mapbox/whoots-js/CHANGELOG.md b/node_modules/@mapbox/whoots-js/CHANGELOG.md new file mode 100644 index 0000000000000000000000000000000000000000..9e422a711bf074433aac5351f55ceab306e4f73f --- /dev/null +++ b/node_modules/@mapbox/whoots-js/CHANGELOG.md @@ -0,0 +1,28 @@ +_Breaking changes, which may affect downstream projects are marked with a_ :warning: + +## 3.1.0 +##### 2018-Jul-12 +* Replace legacy Rollup `jsnext:main` with now standard `module` ([#74]) +* :warning: Drop support for Node 4 + +[#74]: https://github.com/mapbox/whoots-js/issues/74 + +## 3.0.0 +##### 2017-Feb-13 +* :warning: whoots-js is now a scoped package under the @mapbox namespace + +## 2.1.0 +##### Jul 15, 2016 +* Release as ES6 module alongside UMD build, add `jsnext:main` to `package.json` + +## 2.0.0 +##### Jun 1, 2016 +* :warning: Refactor for a classless API + +## 1.1.0 +##### May 23, 2016 +* Make getTileBbox and getMercCoords public + +## 1.0.0 +##### May 23, 2016 +* Initial release diff --git a/node_modules/@mapbox/whoots-js/LICENSE.md b/node_modules/@mapbox/whoots-js/LICENSE.md new file mode 100644 index 0000000000000000000000000000000000000000..6f4f868bbc92108cca26dcb3ba22f46b568a2090 --- /dev/null +++ b/node_modules/@mapbox/whoots-js/LICENSE.md @@ -0,0 +1,15 @@ +ISC License + +Copyright (c) 2017, Mapbox + +Permission to use, copy, modify, and/or distribute this software for any purpose +with or without fee is hereby granted, provided that the above copyright notice +and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH +REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND +FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, +INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS +OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER +TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF +THIS SOFTWARE. diff --git a/node_modules/@mapbox/whoots-js/README.md b/node_modules/@mapbox/whoots-js/README.md new file mode 100644 index 0000000000000000000000000000000000000000..cc600398d2edf78c762cfa280aa1d7da71dcffca --- /dev/null +++ b/node_modules/@mapbox/whoots-js/README.md @@ -0,0 +1,53 @@ +[![npm version](https://badge.fury.io/js/%40mapbox%2Fwhoots-js.svg)](https://badge.fury.io/js/%40mapbox%2Fwhoots-js) +[![Build Status](https://secure.travis-ci.org/mapbox/whoots-js.svg)](http://travis-ci.org/mapbox/whoots-js) +[![Coverage Status](https://coveralls.io/repos/github/mapbox/whoots-js/badge.svg?branch=master)](https://coveralls.io/github/mapbox/whoots-js?branch=master) + + +## whoots-js + +Request tiles from WMS servers that support EPSG:3857. + +This project is a JavaScript port of https://github.com/timwaters/whoots by Tim Waters. + + +### What is it? + +Given a `z/x/y` tile coordinate like `19/154308/197167`, `whoots-js` can request imagery from an EPSG:3857 supporting WMS server like this: + +``` +http://geodata.state.nj.us/imagerywms/Natural2015? + bbox=-8242663.382160267,4966572.349857613,-8242586.945131982,4966648.786885899 + &format=image/png&service=WMS&version=1.1.1&request=GetMap&srs=EPSG:3857 + &width=256&height=256&layers=Natural2015 +``` + + +### Usage + +```js +var WhooTS = require('@mapbox/whoots-js'); + +// Get an image url for a given tile coordinate +var baseUrl = 'http://geodata.state.nj.us/imagerywms/Natural2015'; +var layer = 'Natural2015'; +var url = WhooTS.getURL(baseUrl, layer, 154308, 197167, 19); +``` + + +### Server + +This project includes a sample redirecting wms proxy server in `server.js`. + +`npm run server` will start a local server on port 8080 that redirects tile requests. + +Valid tile requests look like: + +``` +http://localhost:8080/tms/{z}/{x}/{y}/{layer}/{endpoint} +http://localhost:8080/tms/19/154308/197167/Natural2015/http://geodata.state.nj.us/imagerywms/Natural2015 +``` + + +### Documentation + +Complete API documentation is here: http://mapbox.github.io/whoots-js/ diff --git a/node_modules/@mapbox/whoots-js/index.js b/node_modules/@mapbox/whoots-js/index.js new file mode 100644 index 0000000000000000000000000000000000000000..c8e3dd2d46bc334aa8abed94c03298819fd50b3d --- /dev/null +++ b/node_modules/@mapbox/whoots-js/index.js @@ -0,0 +1,88 @@ +(function (global, factory) { +typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : +typeof define === 'function' && define.amd ? define(['exports'], factory) : +(factory((global.WhooTS = {}))); +}(this, (function (exports) { +/** + * getURL + * + * @param {String} baseUrl Base url of the WMS server + * @param {String} layer Layer name + * @param {Number} x Tile coordinate x + * @param {Number} y Tile coordinate y + * @param {Number} z Tile zoom + * @param {Object} [options] + * @param {String} [options.format='image/png'] + * @param {String} [options.service='WMS'] + * @param {String} [options.version='1.1.1'] + * @param {String} [options.request='GetMap'] + * @param {String} [options.srs='EPSG:3857'] + * @param {Number} [options.width='256'] + * @param {Number} [options.height='256'] + * @returns {String} url + * @example + * var baseUrl = 'http://geodata.state.nj.us/imagerywms/Natural2015'; + * var layer = 'Natural2015'; + * var url = whoots.getURL(baseUrl, layer, 154308, 197167, 19); + */ +function getURL(baseUrl, layer, x, y, z, options) { + options = options || {}; + + var url = baseUrl + '?' + [ + 'bbox=' + getTileBBox(x, y, z), + 'format=' + (options.format || 'image/png'), + 'service=' + (options.service || 'WMS'), + 'version=' + (options.version || '1.1.1'), + 'request=' + (options.request || 'GetMap'), + 'srs=' + (options.srs || 'EPSG:3857'), + 'width=' + (options.width || 256), + 'height=' + (options.height || 256), + 'layers=' + layer + ].join('&'); + + return url; +} + + +/** + * getTileBBox + * + * @param {Number} x Tile coordinate x + * @param {Number} y Tile coordinate y + * @param {Number} z Tile zoom + * @returns {String} String of the bounding box + */ +function getTileBBox(x, y, z) { + // for Google/OSM tile scheme we need to alter the y + y = (Math.pow(2, z) - y - 1); + + var min = getMercCoords(x * 256, y * 256, z), + max = getMercCoords((x + 1) * 256, (y + 1) * 256, z); + + return min[0] + ',' + min[1] + ',' + max[0] + ',' + max[1]; +} + + +/** + * getMercCoords + * + * @param {Number} x Pixel coordinate x + * @param {Number} y Pixel coordinate y + * @param {Number} z Tile zoom + * @returns {Array} [x, y] + */ +function getMercCoords(x, y, z) { + var resolution = (2 * Math.PI * 6378137 / 256) / Math.pow(2, z), + merc_x = (x * resolution - 2 * Math.PI * 6378137 / 2.0), + merc_y = (y * resolution - 2 * Math.PI * 6378137 / 2.0); + + return [merc_x, merc_y]; +} + +exports.getURL = getURL; +exports.getTileBBox = getTileBBox; +exports.getMercCoords = getMercCoords; + +Object.defineProperty(exports, '__esModule', { value: true }); + +}))); diff --git a/node_modules/@mapbox/whoots-js/index.mjs b/node_modules/@mapbox/whoots-js/index.mjs new file mode 100644 index 0000000000000000000000000000000000000000..b2a5c755503ce5db13a1c5b3f36cdb9e667e43fa --- /dev/null +++ b/node_modules/@mapbox/whoots-js/index.mjs @@ -0,0 +1,78 @@ +export { getURL, getTileBBox, getMercCoords }; + + +/** + * getURL + * + * @param {String} baseUrl Base url of the WMS server + * @param {String} layer Layer name + * @param {Number} x Tile coordinate x + * @param {Number} y Tile coordinate y + * @param {Number} z Tile zoom + * @param {Object} [options] + * @param {String} [options.format='image/png'] + * @param {String} [options.service='WMS'] + * @param {String} [options.version='1.1.1'] + * @param {String} [options.request='GetMap'] + * @param {String} [options.srs='EPSG:3857'] + * @param {Number} [options.width='256'] + * @param {Number} [options.height='256'] + * @returns {String} url + * @example + * var baseUrl = 'http://geodata.state.nj.us/imagerywms/Natural2015'; + * var layer = 'Natural2015'; + * var url = whoots.getURL(baseUrl, layer, 154308, 197167, 19); + */ +function getURL(baseUrl, layer, x, y, z, options) { + options = options || {}; + + var url = baseUrl + '?' + [ + 'bbox=' + getTileBBox(x, y, z), + 'format=' + (options.format || 'image/png'), + 'service=' + (options.service || 'WMS'), + 'version=' + (options.version || '1.1.1'), + 'request=' + (options.request || 'GetMap'), + 'srs=' + (options.srs || 'EPSG:3857'), + 'width=' + (options.width || 256), + 'height=' + (options.height || 256), + 'layers=' + layer + ].join('&'); + + return url; +} + + +/** + * getTileBBox + * + * @param {Number} x Tile coordinate x + * @param {Number} y Tile coordinate y + * @param {Number} z Tile zoom + * @returns {String} String of the bounding box + */ +function getTileBBox(x, y, z) { + // for Google/OSM tile scheme we need to alter the y + y = (Math.pow(2, z) - y - 1); + + var min = getMercCoords(x * 256, y * 256, z), + max = getMercCoords((x + 1) * 256, (y + 1) * 256, z); + + return min[0] + ',' + min[1] + ',' + max[0] + ',' + max[1]; +} + + +/** + * getMercCoords + * + * @param {Number} x Pixel coordinate x + * @param {Number} y Pixel coordinate y + * @param {Number} z Tile zoom + * @returns {Array} [x, y] + */ +function getMercCoords(x, y, z) { + var resolution = (2 * Math.PI * 6378137 / 256) / Math.pow(2, z), + merc_x = (x * resolution - 2 * Math.PI * 6378137 / 2.0), + merc_y = (y * resolution - 2 * Math.PI * 6378137 / 2.0); + + return [merc_x, merc_y]; +} diff --git a/node_modules/@mapbox/whoots-js/package.json b/node_modules/@mapbox/whoots-js/package.json new file mode 100644 index 0000000000000000000000000000000000000000..385b67cba6357d2e4de5503eb7185200af6db500 --- /dev/null +++ b/node_modules/@mapbox/whoots-js/package.json @@ -0,0 +1,33 @@ +{ + "name": "@mapbox/whoots-js", + "description": "Request tiles from WMS servers that support EPSG:3857", + "version": "3.1.0", + "main": "index.js", + "module": "index.mjs", + "license": "ISC", + "author": "Bryan Housel ", + "repository": "mapbox/whoots-js", + "keywords": [ + "WMS", + "tiles", + "EPSG:3857" + ], + "dependencies": {}, + "devDependencies": { + "coveralls": "^3.0.0", + "documentation": "4.0.0-beta5", + "eslint": "^5.0.0", + "rollup": "0.60.0", + "tap": "^12.0.0" + }, + "engines": { + "node": ">=6.0.0" + }, + "scripts": { + "build": "rollup -f umd -n WhooTS index.mjs --no-indent --no-strict -o index.js", + "docs": "documentation build index.mjs --lint --github --format html --output docs/", + "lint": "eslint index.mjs server.js test", + "start": "node server.js", + "test": "npm run lint && npm run build && tap --cov test/*.js" + } +} diff --git a/node_modules/@mapbox/whoots-js/server.js b/node_modules/@mapbox/whoots-js/server.js new file mode 100644 index 0000000000000000000000000000000000000000..3fe4cd002578e813448eab829ec7c823729ebe21 --- /dev/null +++ b/node_modules/@mapbox/whoots-js/server.js @@ -0,0 +1,40 @@ +'use strict'; + +var WhooTS = require('./'); +var http = require('http'); +var url = require('url'); + +var PORT = 8080; + +// valid requests look like: +// http://localhost:8080/tms/{z}/{x}/{y}/{layer}/{baseUrl} +// http://localhost:8080/tms/19/154308/197167/Natural2015/http://geodata.state.nj.us/imagerywms/Natural2015 +function handleRequest(request, response) { + var pathname = url.parse(request.url, true).pathname; + var params = pathname.split('/'); + + if (params.length > 6 && params[1].toLowerCase() === 'tms') { + var z = +params[2], + x = +params[3], + y = +params[4], + layer = params[5], + baseUrl = pathname.replace(params.slice(0,6).join('/') + '/', ''); + + if (!isNaN(z) && !isNaN(x) && !isNaN(y) && layer && url.parse(baseUrl).protocol) { + response.writeHead(302, { 'Location': WhooTS.getURL(baseUrl, layer, x, y, z) }); + response.end('Redirect'); + return; + } + } + + response.statusCode = '404'; + response.end('Not Found'); +} + + +var server = http.createServer(handleRequest); +server.listen(PORT, function() { + /* eslint-disable no-console */ + console.log('Server listening on: http://localhost:%s', PORT); + /* eslint-enable no-console */ +}); diff --git a/node_modules/@playwright/test/LICENSE b/node_modules/@playwright/test/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..df112373eb2e23e459bf93ec412be1764dc5a38b --- /dev/null +++ b/node_modules/@playwright/test/LICENSE @@ -0,0 +1,202 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Portions Copyright (c) Microsoft Corporation. + Portions Copyright 2017 Google Inc. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/node_modules/@playwright/test/NOTICE b/node_modules/@playwright/test/NOTICE new file mode 100644 index 0000000000000000000000000000000000000000..814ec1696f7ad36c1b524fb6adeef14b4b367fec --- /dev/null +++ b/node_modules/@playwright/test/NOTICE @@ -0,0 +1,5 @@ +Playwright +Copyright (c) Microsoft Corporation + +This software contains code derived from the Puppeteer project (https://github.com/puppeteer/puppeteer), +available under the Apache 2.0 license (https://github.com/puppeteer/puppeteer/blob/master/LICENSE). diff --git a/node_modules/@playwright/test/README.md b/node_modules/@playwright/test/README.md new file mode 100644 index 0000000000000000000000000000000000000000..8b6bd945d0767e2895821cbbe40240f9fc1e857a --- /dev/null +++ b/node_modules/@playwright/test/README.md @@ -0,0 +1,168 @@ +# 🎭 Playwright + +[![npm version](https://img.shields.io/npm/v/playwright.svg)](https://www.npmjs.com/package/playwright) [![Chromium version](https://img.shields.io/badge/chromium-145.0.7632.6-blue.svg?logo=google-chrome)](https://www.chromium.org/Home) [![Firefox version](https://img.shields.io/badge/firefox-146.0.1-blue.svg?logo=firefoxbrowser)](https://www.mozilla.org/en-US/firefox/new/) [![WebKit version](https://img.shields.io/badge/webkit-26.0-blue.svg?logo=safari)](https://webkit.org/) [![Join Discord](https://img.shields.io/badge/join-discord-informational)](https://aka.ms/playwright/discord) + +## [Documentation](https://playwright.dev) | [API reference](https://playwright.dev/docs/api/class-playwright) + +Playwright is a framework for Web Testing and Automation. It allows testing [Chromium](https://www.chromium.org/Home), [Firefox](https://www.mozilla.org/en-US/firefox/new/) and [WebKit](https://webkit.org/) with a single API. Playwright is built to enable cross-browser web automation that is **ever-green**, **capable**, **reliable**, and **fast**. + +| | Linux | macOS | Windows | +| :--- | :---: | :---: | :---: | +| Chromium 145.0.7632.6 | :white_check_mark: | :white_check_mark: | :white_check_mark: | +| WebKit 26.0 | :white_check_mark: | :white_check_mark: | :white_check_mark: | +| Firefox 146.0.1 | :white_check_mark: | :white_check_mark: | :white_check_mark: | + +Headless execution is supported for all browsers on all platforms. Check out [system requirements](https://playwright.dev/docs/intro#system-requirements) for details. + +Looking for Playwright for [Python](https://playwright.dev/python/docs/intro), [.NET](https://playwright.dev/dotnet/docs/intro), or [Java](https://playwright.dev/java/docs/intro)? + +## Installation + +Playwright has its own test runner for end-to-end tests, we call it Playwright Test. + +### Using init command + +The easiest way to get started with Playwright Test is to run the init command. + +```Shell +# Run from your project's root directory +npm init playwright@latest +# Or create a new project +npm init playwright@latest new-project +``` + +This will create a configuration file, optionally add examples, a GitHub Action workflow and a first test example.spec.ts. You can now jump directly to writing assertions section. + +### Manually + +Add dependency and install browsers. + +```Shell +npm i -D @playwright/test +# install supported browsers +npx playwright install +``` + +You can optionally install only selected browsers, see [install browsers](https://playwright.dev/docs/cli#install-browsers) for more details. Or you can install no browsers at all and use existing [browser channels](https://playwright.dev/docs/browsers). + +* [Getting started](https://playwright.dev/docs/intro) +* [API reference](https://playwright.dev/docs/api/class-playwright) + +## Capabilities + +### Resilient • No flaky tests + +**Auto-wait**. Playwright waits for elements to be actionable prior to performing actions. It also has a rich set of introspection events. The combination of the two eliminates the need for artificial timeouts - a primary cause of flaky tests. + +**Web-first assertions**. Playwright assertions are created specifically for the dynamic web. Checks are automatically retried until the necessary conditions are met. + +**Tracing**. Configure test retry strategy, capture execution trace, videos and screenshots to eliminate flakes. + +### No trade-offs • No limits + +Browsers run web content belonging to different origins in different processes. Playwright is aligned with the architecture of the modern browsers and runs tests out-of-process. This makes Playwright free of the typical in-process test runner limitations. + +**Multiple everything**. Test scenarios that span multiple tabs, multiple origins and multiple users. Create scenarios with different contexts for different users and run them against your server, all in one test. + +**Trusted events**. Hover elements, interact with dynamic controls and produce trusted events. Playwright uses real browser input pipeline indistinguishable from the real user. + +Test frames, pierce Shadow DOM. Playwright selectors pierce shadow DOM and allow entering frames seamlessly. + +### Full isolation • Fast execution + +**Browser contexts**. Playwright creates a browser context for each test. Browser context is equivalent to a brand new browser profile. This delivers full test isolation with zero overhead. Creating a new browser context only takes a handful of milliseconds. + +**Log in once**. Save the authentication state of the context and reuse it in all the tests. This bypasses repetitive log-in operations in each test, yet delivers full isolation of independent tests. + +### Powerful Tooling + +**[Codegen](https://playwright.dev/docs/codegen)**. Generate tests by recording your actions. Save them into any language. + +**[Playwright inspector](https://playwright.dev/docs/inspector)**. Inspect page, generate selectors, step through the test execution, see click points and explore execution logs. + +**[Trace Viewer](https://playwright.dev/docs/trace-viewer)**. Capture all the information to investigate the test failure. Playwright trace contains test execution screencast, live DOM snapshots, action explorer, test source and many more. + +Looking for Playwright for [TypeScript](https://playwright.dev/docs/intro), [JavaScript](https://playwright.dev/docs/intro), [Python](https://playwright.dev/python/docs/intro), [.NET](https://playwright.dev/dotnet/docs/intro), or [Java](https://playwright.dev/java/docs/intro)? + +## Examples + +To learn how to run these Playwright Test examples, check out our [getting started docs](https://playwright.dev/docs/intro). + +#### Page screenshot + +This code snippet navigates to Playwright homepage and saves a screenshot. + +```TypeScript +import { test } from '@playwright/test'; + +test('Page Screenshot', async ({ page }) => { + await page.goto('https://playwright.dev/'); + await page.screenshot({ path: `example.png` }); +}); +``` + +#### Mobile and geolocation + +This snippet emulates Mobile Safari on a device at given geolocation, navigates to maps.google.com, performs the action and takes a screenshot. + +```TypeScript +import { test, devices } from '@playwright/test'; + +test.use({ + ...devices['iPhone 13 Pro'], + locale: 'en-US', + geolocation: { longitude: 12.492507, latitude: 41.889938 }, + permissions: ['geolocation'], +}) + +test('Mobile and geolocation', async ({ page }) => { + await page.goto('https://maps.google.com'); + await page.getByText('Your location').click(); + await page.waitForRequest(/.*preview\/pwa/); + await page.screenshot({ path: 'colosseum-iphone.png' }); +}); +``` + +#### Evaluate in browser context + +This code snippet navigates to example.com, and executes a script in the page context. + +```TypeScript +import { test } from '@playwright/test'; + +test('Evaluate in browser context', async ({ page }) => { + await page.goto('https://www.example.com/'); + const dimensions = await page.evaluate(() => { + return { + width: document.documentElement.clientWidth, + height: document.documentElement.clientHeight, + deviceScaleFactor: window.devicePixelRatio + } + }); + console.log(dimensions); +}); +``` + +#### Intercept network requests + +This code snippet sets up request routing for a page to log all network requests. + +```TypeScript +import { test } from '@playwright/test'; + +test('Intercept network requests', async ({ page }) => { + // Log and continue all network requests + await page.route('**', route => { + console.log(route.request().url()); + route.continue(); + }); + await page.goto('http://todomvc.com'); +}); +``` + +## Resources + +* [Documentation](https://playwright.dev) +* [API reference](https://playwright.dev/docs/api/class-playwright/) +* [Contribution guide](CONTRIBUTING.md) +* [Changelog](https://github.com/microsoft/playwright/releases) diff --git a/node_modules/@playwright/test/cli.js b/node_modules/@playwright/test/cli.js new file mode 100644 index 0000000000000000000000000000000000000000..e42facb076f4b05f009186346d05d39c2d9b784d --- /dev/null +++ b/node_modules/@playwright/test/cli.js @@ -0,0 +1,19 @@ +#!/usr/bin/env node +/** + * Copyright (c) Microsoft Corporation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +const { program } = require('playwright/lib/program'); +program.parse(process.argv); diff --git a/node_modules/@playwright/test/index.d.ts b/node_modules/@playwright/test/index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..8d99c91500c65b4b9d762b900dedf5e6000cf257 --- /dev/null +++ b/node_modules/@playwright/test/index.d.ts @@ -0,0 +1,18 @@ +/** + * Copyright (c) Microsoft Corporation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export * from 'playwright/test'; +export { default } from 'playwright/test'; diff --git a/node_modules/@playwright/test/index.js b/node_modules/@playwright/test/index.js new file mode 100644 index 0000000000000000000000000000000000000000..8536f063904ffa04a91240061ce1cf2c4c855b79 --- /dev/null +++ b/node_modules/@playwright/test/index.js @@ -0,0 +1,17 @@ +/** + * Copyright (c) Microsoft Corporation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +module.exports = require('playwright/test'); diff --git a/node_modules/@playwright/test/index.mjs b/node_modules/@playwright/test/index.mjs new file mode 100644 index 0000000000000000000000000000000000000000..8d99c91500c65b4b9d762b900dedf5e6000cf257 --- /dev/null +++ b/node_modules/@playwright/test/index.mjs @@ -0,0 +1,18 @@ +/** + * Copyright (c) Microsoft Corporation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export * from 'playwright/test'; +export { default } from 'playwright/test'; diff --git a/node_modules/@playwright/test/package.json b/node_modules/@playwright/test/package.json new file mode 100644 index 0000000000000000000000000000000000000000..56748d924bbe4c363c8b2620a086edf321cf8ddc --- /dev/null +++ b/node_modules/@playwright/test/package.json @@ -0,0 +1,35 @@ +{ + "name": "@playwright/test", + "version": "1.58.2", + "description": "A high-level API to automate web browsers", + "repository": { + "type": "git", + "url": "git+https://github.com/microsoft/playwright.git" + }, + "homepage": "https://playwright.dev", + "engines": { + "node": ">=18" + }, + "author": { + "name": "Microsoft Corporation" + }, + "license": "Apache-2.0", + "exports": { + ".": { + "types": "./index.d.ts", + "import": "./index.mjs", + "require": "./index.js", + "default": "./index.js" + }, + "./cli": "./cli.js", + "./package.json": "./package.json", + "./reporter": "./reporter.js" + }, + "bin": { + "playwright": "cli.js" + }, + "scripts": {}, + "dependencies": { + "playwright": "1.58.2" + } +} diff --git a/node_modules/@playwright/test/reporter.d.ts b/node_modules/@playwright/test/reporter.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..806d13fb09e73f0dc1f4e129a2889b9e6bac3a8d --- /dev/null +++ b/node_modules/@playwright/test/reporter.d.ts @@ -0,0 +1,17 @@ +/** + * Copyright (c) Microsoft Corporation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export * from 'playwright/types/testReporter'; diff --git a/node_modules/@playwright/test/reporter.js b/node_modules/@playwright/test/reporter.js new file mode 100644 index 0000000000000000000000000000000000000000..485e880a66229eb7290fd274e35b8acf4a4a8ecd --- /dev/null +++ b/node_modules/@playwright/test/reporter.js @@ -0,0 +1,17 @@ +/** + * Copyright (c) Microsoft Corporation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// We only export types in reporter.d.ts. diff --git a/node_modules/@playwright/test/reporter.mjs b/node_modules/@playwright/test/reporter.mjs new file mode 100644 index 0000000000000000000000000000000000000000..485e880a66229eb7290fd274e35b8acf4a4a8ecd --- /dev/null +++ b/node_modules/@playwright/test/reporter.mjs @@ -0,0 +1,17 @@ +/** + * Copyright (c) Microsoft Corporation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// We only export types in reporter.d.ts. diff --git a/node_modules/@plotly/d3/.gitattributes b/node_modules/@plotly/d3/.gitattributes new file mode 100644 index 0000000000000000000000000000000000000000..eab783da7bee07c25483e21746d6b9a076b82474 --- /dev/null +++ b/node_modules/@plotly/d3/.gitattributes @@ -0,0 +1 @@ +d3.js -diff merge=ours diff --git a/node_modules/@plotly/d3/.npmignore b/node_modules/@plotly/d3/.npmignore new file mode 100644 index 0000000000000000000000000000000000000000..23b0df14ba38fd2028e1ff54b3f8b784ad9def7b --- /dev/null +++ b/node_modules/@plotly/d3/.npmignore @@ -0,0 +1,6 @@ +examples/ +test/ +lib/ +.DS_Store +_site +d3.zip diff --git a/node_modules/@plotly/d3/.spmignore b/node_modules/@plotly/d3/.spmignore new file mode 100644 index 0000000000000000000000000000000000000000..0a67304196fed93b0e5c0109319971bd0c6b34b8 --- /dev/null +++ b/node_modules/@plotly/d3/.spmignore @@ -0,0 +1,4 @@ +bin +lib +src +test diff --git a/node_modules/@plotly/d3/CONTRIBUTING.md b/node_modules/@plotly/d3/CONTRIBUTING.md new file mode 100644 index 0000000000000000000000000000000000000000..89a33e2da0b92672db460ea4ae032a9a5be77dad --- /dev/null +++ b/node_modules/@plotly/d3/CONTRIBUTING.md @@ -0,0 +1,27 @@ +# Contributing + +**Important:** these GitHub issues are for *bug reports and feature requests only*. Please use [StackOverflow](http://stackoverflow.com/questions/tagged/d3.js) or the [d3-js Google group](https://groups.google.com/d/forum/d3-js) for general help. + +If you’re looking for ways to contribute, please [peruse open issues](https://github.com/mbostock/d3/issues?milestone=&page=1&state=open). The icebox is a good place to find ideas that are not currently in development. If you already have an idea, please check past issues to see whether your idea or a similar one was previously discussed. + +Before submitting a pull request, consider implementing a live example first, say using [bl.ocks.org](http://bl.ocks.org). Real-world use cases go a long way to demonstrating the usefulness of a proposed feature. The more complex a feature’s implementation, the more usefulness it should provide. Share your demo using the #d3js tag on Twitter or by sending it to the [d3-js Google group](https://groups.google.com/d/forum/d3-js). + +If your proposed feature does not involve changing core functionality, consider submitting it instead as a [D3 plugin](https://github.com/d3/d3-plugins). New core features should be for general use, whereas plugins are suitable for more specialized use cases. When in doubt, it’s easier to start with a plugin before “graduating” to core. + +To contribute new documentation or add examples to the gallery, just [edit the Wiki](https://github.com/mbostock/d3/wiki)! + +## How to Submit a Pull Request + +1. Click the “Fork” button to create your personal fork of the D3 repository. + +2. After cloning your fork of the D3 repository in the terminal, run `npm install` to install D3’s dependencies. + +3. Create a new branch for your new feature. For example: `git checkout -b my-awesome-feature`. A dedicated branch for your pull request means you can develop multiple features at the same time, and ensures that your pull request is stable even if you later decide to develop an unrelated feature. + +4. The `d3.js` file is built from source files in the `src` directory. _Do not edit `d3.js` directly._ Instead, edit the source files, and then run `make` to build the generated files. + +5. Use `make test` to run tests and verify your changes. If you are adding a new feature, you should add new tests! If you are changing existing functionality, make sure the existing tests run, or update them as appropriate. + +6. Sign D3’s [Individual Contributor License Agreement](https://docs.google.com/forms/d/1CzjdBKtDuA8WeuFJinadx956xLQ4Xriv7-oDvXnZMaI/viewform). Unless you are submitting a trivial patch (such as fixing a typo), this form is needed to verify that you are able to contribute. + +7. Submit your pull request, and good luck! diff --git a/node_modules/@plotly/d3/LICENSE b/node_modules/@plotly/d3/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..ff3f2e5419a8598122736e5b6d88245795fe439b --- /dev/null +++ b/node_modules/@plotly/d3/LICENSE @@ -0,0 +1,26 @@ +Copyright (c) 2010-2016, Michael Bostock +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +* The name Michael Bostock may not be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL MICHAEL BOSTOCK BE LIABLE FOR ANY DIRECT, +INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, +EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/node_modules/@plotly/d3/README.md b/node_modules/@plotly/d3/README.md new file mode 100644 index 0000000000000000000000000000000000000000..33e97bf18e041f6a8b0c374a53ea25606717e1f7 --- /dev/null +++ b/node_modules/@plotly/d3/README.md @@ -0,0 +1,13 @@ +# Data-Driven Documents + + + +**D3.js** is a JavaScript library for manipulating documents based on data. **D3** helps you bring data to life using HTML, SVG, and CSS. **D3** emphasizes web standards and combines powerful visualization components with a data-driven approach to DOM manipulation, giving you the full capabilities of modern browsers without tying yourself to a proprietary framework. + +Want to learn more? [See the wiki.](https://github.com/mbostock/d3/wiki) + +For examples, [see the gallery](https://github.com/mbostock/d3/wiki/Gallery) and [mbostock’s bl.ocks](http://bl.ocks.org/mbostock). + +## Good News, Everyone! + +The next major release of D3, 4.0, is coming! See the [4.0 development branch](https://github.com/mbostock/d3/tree/4) and read the [new API reference](https://github.com/mbostock/d3/blob/4/README.md) to get ready. diff --git a/node_modules/@plotly/d3/bin/meteor b/node_modules/@plotly/d3/bin/meteor new file mode 100644 index 0000000000000000000000000000000000000000..478705160dbe43f36872a1a5b67e672bcb8cf000 --- /dev/null +++ b/node_modules/@plotly/d3/bin/meteor @@ -0,0 +1,20 @@ +#!/usr/bin/env node + +var fs = require("fs"), + package = require("../package.json"); + +console.log( + "// Package metadata for Meteor.js.\n" + + "\n" + + "Package.describe({\n" + + " name: \"d3js:d3\", // http://atmospherejs.com/d3js/d3\n" + + " summary: \"D3 (official): " + package.description + "\",\n" + + " version: \"" + package.version + "\",\n" + + " git: \"https://github.com/mbostock/d3.git\"\n" + + "});\n" + + "\n" + + "Package.onUse(function(api) {\n" + + " api.versionsFrom([\"METEOR@1.0\"]);\n" + + " api.addFiles(\"d3.js\", \"client\");\n" + + "});" +); diff --git a/node_modules/@plotly/d3/bin/start b/node_modules/@plotly/d3/bin/start new file mode 100644 index 0000000000000000000000000000000000000000..9b046fc937f8f481c35fdd42317d7088d48f18b3 --- /dev/null +++ b/node_modules/@plotly/d3/bin/start @@ -0,0 +1,3 @@ +#!/usr/bin/env node + +console.log("!function(){\n var d3 = {version: " + JSON.stringify(require("../package.json").version) + "}; // semver"); diff --git a/node_modules/@plotly/d3/bin/uglify b/node_modules/@plotly/d3/bin/uglify new file mode 100644 index 0000000000000000000000000000000000000000..6defe2f5b1734593ee0d80494262a8598f9cbc63 --- /dev/null +++ b/node_modules/@plotly/d3/bin/uglify @@ -0,0 +1,34 @@ +#!/usr/bin/env node + +var fs = require("fs"), + uglify = require("uglify-js"); + +var filename = process.argv[2], + toplevel = uglify.parse(fs.readFileSync(filename, "utf8"), {filename: filename}), + output = uglify.OutputStream({ascii_only: true}), + compressor = uglify.Compressor(true), + warn = uglify.AST_Node.warn; + +uglify.AST_Node.warn = function(s, o) { + if (o.msg === "Accidental global?" && o.name === "d3" && o.line === 1 && !o.col) return; + warn.apply(this, arguments); +}; + +toplevel.figure_out_scope(); +toplevel.scope_warnings({ + undeclared: false, + unreferenced: false, + assign_to_global: true, + func_arguments: false, + nested_defuns: false, + eval: false +}); + +toplevel = toplevel.transform(compressor); + +toplevel.figure_out_scope(); +toplevel.compute_char_frequency(true); +toplevel.mangle_names(true); +toplevel.print(output); + +process.stdout.write(output.get()); diff --git a/node_modules/@plotly/d3/composer.json b/node_modules/@plotly/d3/composer.json new file mode 100644 index 0000000000000000000000000000000000000000..c5a50f219ee37428c12ab9f14b3cd3266eb39989 --- /dev/null +++ b/node_modules/@plotly/d3/composer.json @@ -0,0 +1,26 @@ +{ + "name": "mbostock/d3", + "description": "A JavaScript visualization library for HTML and SVG.", + "keywords": [ + "dom", + "w3c", + "visualization", + "svg", + "animation", + "canvas" + ], + "homepage": "http://d3js.org/", + "license": "BSD-3-Clause", + "authors": [ + { + "name": "Mike Bostock", + "homepage": "http://bost.ocks.org/mike" + } + ], + "support": { + "issues": "https://github.com/mbostock/d3/issues", + "wiki": "https://github.com/mbostock/d3/wiki", + "API": "https://github.com/mbostock/d3/wiki/API-Reference", + "source": "https://github.com/mbostock/d3" + } +} diff --git a/node_modules/@plotly/d3/d3.js b/node_modules/@plotly/d3/d3.js new file mode 100644 index 0000000000000000000000000000000000000000..204e9349566ba5baafc5c48c618c1dd055f1b46f --- /dev/null +++ b/node_modules/@plotly/d3/d3.js @@ -0,0 +1,6827 @@ +!function() { + var d3 = { + version: "3.8.0" + }; + var d3_arraySlice = [].slice, d3_array = function(list) { + return d3_arraySlice.call(list); + }; + var d3_document = self.document; + function d3_documentElement(node) { + return node && (node.ownerDocument || node.document || node).documentElement; + } + function d3_window(node) { + return node && (node.ownerDocument && node.ownerDocument.defaultView || node.document && node || node.defaultView); + } + if (d3_document) { + try { + d3_array(d3_document.documentElement.childNodes)[0].nodeType; + } catch (e) { + d3_array = function(list) { + var i = list.length, array = new Array(i); + while (i--) array[i] = list[i]; + return array; + }; + } + } + if (!Date.now) Date.now = function() { + return +new Date(); + }; + if (d3_document) { + try { + d3_document.createElement("DIV").style.setProperty("opacity", 0, ""); + } catch (error) { + var d3_element_prototype = this.Element.prototype, d3_element_setAttribute = d3_element_prototype.setAttribute, d3_element_setAttributeNS = d3_element_prototype.setAttributeNS, d3_style_prototype = this.CSSStyleDeclaration.prototype, d3_style_setProperty = d3_style_prototype.setProperty; + d3_element_prototype.setAttribute = function(name, value) { + d3_element_setAttribute.call(this, name, value + ""); + }; + d3_element_prototype.setAttributeNS = function(space, local, value) { + d3_element_setAttributeNS.call(this, space, local, value + ""); + }; + d3_style_prototype.setProperty = function(name, value, priority) { + d3_style_setProperty.call(this, name, value + "", priority); + }; + } + } + d3.ascending = d3_ascending; + function d3_ascending(a, b) { + return a < b ? -1 : a > b ? 1 : a >= b ? 0 : NaN; + } + d3.descending = function(a, b) { + return b < a ? -1 : b > a ? 1 : b >= a ? 0 : NaN; + }; + d3.min = function(array, f) { + var i = -1, n = array.length, a, b; + if (arguments.length === 1) { + while (++i < n) if ((b = array[i]) != null && b >= b) { + a = b; + break; + } + while (++i < n) if ((b = array[i]) != null && a > b) a = b; + } else { + while (++i < n) if ((b = f.call(array, array[i], i)) != null && b >= b) { + a = b; + break; + } + while (++i < n) if ((b = f.call(array, array[i], i)) != null && a > b) a = b; + } + return a; + }; + d3.max = function(array, f) { + var i = -1, n = array.length, a, b; + if (arguments.length === 1) { + while (++i < n) if ((b = array[i]) != null && b >= b) { + a = b; + break; + } + while (++i < n) if ((b = array[i]) != null && b > a) a = b; + } else { + while (++i < n) if ((b = f.call(array, array[i], i)) != null && b >= b) { + a = b; + break; + } + while (++i < n) if ((b = f.call(array, array[i], i)) != null && b > a) a = b; + } + return a; + }; + d3.extent = function(array, f) { + var i = -1, n = array.length, a, b, c; + if (arguments.length === 1) { + while (++i < n) if ((b = array[i]) != null && b >= b) { + a = c = b; + break; + } + while (++i < n) if ((b = array[i]) != null) { + if (a > b) a = b; + if (c < b) c = b; + } + } else { + while (++i < n) if ((b = f.call(array, array[i], i)) != null && b >= b) { + a = c = b; + break; + } + while (++i < n) if ((b = f.call(array, array[i], i)) != null) { + if (a > b) a = b; + if (c < b) c = b; + } + } + return [ a, c ]; + }; + function d3_number(x) { + return x === null ? NaN : +x; + } + function d3_numeric(x) { + return !isNaN(x); + } + d3.sum = function(array, f) { + var s = 0, n = array.length, a, i = -1; + if (arguments.length === 1) { + while (++i < n) if (d3_numeric(a = +array[i])) s += a; + } else { + while (++i < n) if (d3_numeric(a = +f.call(array, array[i], i))) s += a; + } + return s; + }; + d3.mean = function(array, f) { + var s = 0, n = array.length, a, i = -1, j = n; + if (arguments.length === 1) { + while (++i < n) if (d3_numeric(a = d3_number(array[i]))) s += a; else --j; + } else { + while (++i < n) if (d3_numeric(a = d3_number(f.call(array, array[i], i)))) s += a; else --j; + } + if (j) return s / j; + }; + d3.quantile = function(values, p) { + var H = (values.length - 1) * p + 1, h = Math.floor(H), v = +values[h - 1], e = H - h; + return e ? v + e * (values[h] - v) : v; + }; + d3.median = function(array, f) { + var numbers = [], n = array.length, a, i = -1; + if (arguments.length === 1) { + while (++i < n) if (d3_numeric(a = d3_number(array[i]))) numbers.push(a); + } else { + while (++i < n) if (d3_numeric(a = d3_number(f.call(array, array[i], i)))) numbers.push(a); + } + if (numbers.length) return d3.quantile(numbers.sort(d3_ascending), .5); + }; + d3.variance = function(array, f) { + var n = array.length, m = 0, a, d, s = 0, i = -1, j = 0; + if (arguments.length === 1) { + while (++i < n) { + if (d3_numeric(a = d3_number(array[i]))) { + d = a - m; + m += d / ++j; + s += d * (a - m); + } + } + } else { + while (++i < n) { + if (d3_numeric(a = d3_number(f.call(array, array[i], i)))) { + d = a - m; + m += d / ++j; + s += d * (a - m); + } + } + } + if (j > 1) return s / (j - 1); + }; + d3.deviation = function() { + var v = d3.variance.apply(this, arguments); + return v ? Math.sqrt(v) : v; + }; + function d3_bisector(compare) { + return { + left: function(a, x, lo, hi) { + if (arguments.length < 3) lo = 0; + if (arguments.length < 4) hi = a.length; + while (lo < hi) { + var mid = lo + hi >>> 1; + if (compare(a[mid], x) < 0) lo = mid + 1; else hi = mid; + } + return lo; + }, + right: function(a, x, lo, hi) { + if (arguments.length < 3) lo = 0; + if (arguments.length < 4) hi = a.length; + while (lo < hi) { + var mid = lo + hi >>> 1; + if (compare(a[mid], x) > 0) hi = mid; else lo = mid + 1; + } + return lo; + } + }; + } + var d3_bisect = d3_bisector(d3_ascending); + d3.bisectLeft = d3_bisect.left; + d3.bisect = d3.bisectRight = d3_bisect.right; + d3.bisector = function(f) { + return d3_bisector(f.length === 1 ? function(d, x) { + return d3_ascending(f(d), x); + } : f); + }; + d3.shuffle = function(array, i0, i1) { + if ((m = arguments.length) < 3) { + i1 = array.length; + if (m < 2) i0 = 0; + } + var m = i1 - i0, t, i; + while (m) { + i = Math.random() * m-- | 0; + t = array[m + i0], array[m + i0] = array[i + i0], array[i + i0] = t; + } + return array; + }; + d3.permute = function(array, indexes) { + var i = indexes.length, permutes = new Array(i); + while (i--) permutes[i] = array[indexes[i]]; + return permutes; + }; + d3.pairs = function(array) { + var i = 0, n = array.length - 1, p0, p1 = array[0], pairs = new Array(n < 0 ? 0 : n); + while (i < n) pairs[i] = [ p0 = p1, p1 = array[++i] ]; + return pairs; + }; + d3.transpose = function(matrix) { + if (!(n = matrix.length)) return []; + for (var i = -1, m = d3.min(matrix, d3_transposeLength), transpose = new Array(m); ++i < m; ) { + for (var j = -1, n, row = transpose[i] = new Array(n); ++j < n; ) { + row[j] = matrix[j][i]; + } + } + return transpose; + }; + function d3_transposeLength(d) { + return d.length; + } + d3.zip = function() { + return d3.transpose(arguments); + }; + d3.keys = function(map) { + var keys = []; + for (var key in map) keys.push(key); + return keys; + }; + d3.values = function(map) { + var values = []; + for (var key in map) values.push(map[key]); + return values; + }; + d3.entries = function(map) { + var entries = []; + for (var key in map) entries.push({ + key: key, + value: map[key] + }); + return entries; + }; + d3.merge = function(arrays) { + var n = arrays.length, m, i = -1, j = 0, merged, array; + while (++i < n) j += arrays[i].length; + merged = new Array(j); + while (--n >= 0) { + array = arrays[n]; + m = array.length; + while (--m >= 0) { + merged[--j] = array[m]; + } + } + return merged; + }; + var abs = Math.abs; + d3.range = function(start, stop, step) { + if (arguments.length < 3) { + step = 1; + if (arguments.length < 2) { + stop = start; + start = 0; + } + } + if ((stop - start) / step === Infinity) throw new Error("infinite range"); + var range = [], k = d3_range_integerScale(abs(step)), i = -1, j; + start *= k, stop *= k, step *= k; + if (step < 0) while ((j = start + step * ++i) > stop) range.push(j / k); else while ((j = start + step * ++i) < stop) range.push(j / k); + return range; + }; + function d3_range_integerScale(x) { + var k = 1; + while (x * k % 1) k *= 10; + return k; + } + function d3_class(ctor, properties) { + for (var key in properties) { + Object.defineProperty(ctor.prototype, key, { + value: properties[key], + enumerable: false + }); + } + } + d3.map = function(object, f) { + var map = new d3_Map(); + if (object instanceof d3_Map) { + object.forEach(function(key, value) { + map.set(key, value); + }); + } else if (Array.isArray(object)) { + var i = -1, n = object.length, o; + if (arguments.length === 1) while (++i < n) map.set(i, object[i]); else while (++i < n) map.set(f.call(object, o = object[i], i), o); + } else { + for (var key in object) map.set(key, object[key]); + } + return map; + }; + function d3_Map() { + this._ = Object.create(null); + } + var d3_map_proto = "__proto__", d3_map_zero = "\x00"; + d3_class(d3_Map, { + has: d3_map_has, + get: function(key) { + return this._[d3_map_escape(key)]; + }, + set: function(key, value) { + return this._[d3_map_escape(key)] = value; + }, + remove: d3_map_remove, + keys: d3_map_keys, + values: function() { + var values = []; + for (var key in this._) values.push(this._[key]); + return values; + }, + entries: function() { + var entries = []; + for (var key in this._) entries.push({ + key: d3_map_unescape(key), + value: this._[key] + }); + return entries; + }, + size: d3_map_size, + empty: d3_map_empty, + forEach: function(f) { + for (var key in this._) f.call(this, d3_map_unescape(key), this._[key]); + } + }); + function d3_map_escape(key) { + return (key += "") === d3_map_proto || key[0] === d3_map_zero ? d3_map_zero + key : key; + } + function d3_map_unescape(key) { + return (key += "")[0] === d3_map_zero ? key.slice(1) : key; + } + function d3_map_has(key) { + return d3_map_escape(key) in this._; + } + function d3_map_remove(key) { + return (key = d3_map_escape(key)) in this._ && delete this._[key]; + } + function d3_map_keys() { + var keys = []; + for (var key in this._) keys.push(d3_map_unescape(key)); + return keys; + } + function d3_map_size() { + var size = 0; + for (var key in this._) ++size; + return size; + } + function d3_map_empty() { + for (var key in this._) return false; + return true; + } + d3.nest = function() { + var nest = {}, keys = [], sortKeys = [], sortValues, rollup; + function map(mapType, array, depth) { + if (depth >= keys.length) return rollup ? rollup.call(nest, array) : sortValues ? array.sort(sortValues) : array; + var i = -1, n = array.length, key = keys[depth++], keyValue, object, setter, valuesByKey = new d3_Map(), values; + while (++i < n) { + if (values = valuesByKey.get(keyValue = key(object = array[i]))) { + values.push(object); + } else { + valuesByKey.set(keyValue, [ object ]); + } + } + if (mapType) { + object = mapType(); + setter = function(keyValue, values) { + object.set(keyValue, map(mapType, values, depth)); + }; + } else { + object = {}; + setter = function(keyValue, values) { + object[keyValue] = map(mapType, values, depth); + }; + } + valuesByKey.forEach(setter); + return object; + } + function entries(map, depth) { + if (depth >= keys.length) return map; + var array = [], sortKey = sortKeys[depth++]; + map.forEach(function(key, keyMap) { + array.push({ + key: key, + values: entries(keyMap, depth) + }); + }); + return sortKey ? array.sort(function(a, b) { + return sortKey(a.key, b.key); + }) : array; + } + nest.map = function(array, mapType) { + return map(mapType, array, 0); + }; + nest.entries = function(array) { + return entries(map(d3.map, array, 0), 0); + }; + nest.key = function(d) { + keys.push(d); + return nest; + }; + nest.sortKeys = function(order) { + sortKeys[keys.length - 1] = order; + return nest; + }; + nest.sortValues = function(order) { + sortValues = order; + return nest; + }; + nest.rollup = function(f) { + rollup = f; + return nest; + }; + return nest; + }; + d3.set = function(array) { + var set = new d3_Set(); + if (array) for (var i = 0, n = array.length; i < n; ++i) set.add(array[i]); + return set; + }; + function d3_Set() { + this._ = Object.create(null); + } + d3_class(d3_Set, { + has: d3_map_has, + add: function(key) { + this._[d3_map_escape(key += "")] = true; + return key; + }, + remove: d3_map_remove, + values: d3_map_keys, + size: d3_map_size, + empty: d3_map_empty, + forEach: function(f) { + for (var key in this._) f.call(this, d3_map_unescape(key)); + } + }); + d3.behavior = {}; + function d3_identity(d) { + return d; + } + d3.rebind = function(target, source) { + var i = 1, n = arguments.length, method; + while (++i < n) target[method = arguments[i]] = d3_rebind(target, source, source[method]); + return target; + }; + function d3_rebind(target, source, method) { + return function() { + var value = method.apply(source, arguments); + return value === source ? target : value; + }; + } + function d3_vendorSymbol(object, name) { + if (name in object) return name; + name = name.charAt(0).toUpperCase() + name.slice(1); + for (var i = 0, n = d3_vendorPrefixes.length; i < n; ++i) { + var prefixName = d3_vendorPrefixes[i] + name; + if (prefixName in object) return prefixName; + } + } + var d3_vendorPrefixes = [ "webkit", "ms", "moz", "Moz", "o", "O" ]; + function d3_noop() {} + d3.dispatch = function() { + var dispatch = new d3_dispatch(), i = -1, n = arguments.length; + while (++i < n) dispatch[arguments[i]] = d3_dispatch_event(dispatch); + return dispatch; + }; + function d3_dispatch() {} + d3_dispatch.prototype.on = function(type, listener) { + var i = type.indexOf("."), name = ""; + if (i >= 0) { + name = type.slice(i + 1); + type = type.slice(0, i); + } + if (type) return arguments.length < 2 ? this[type].on(name) : this[type].on(name, listener); + if (arguments.length === 2) { + if (listener == null) for (type in this) { + if (this.hasOwnProperty(type)) this[type].on(name, null); + } + return this; + } + }; + function d3_dispatch_event(dispatch) { + var listeners = [], listenerByName = new d3_Map(); + function event() { + var z = listeners, i = -1, n = z.length, l; + while (++i < n) if (l = z[i].on) l.apply(this, arguments); + return dispatch; + } + event.on = function(name, listener) { + var l = listenerByName.get(name), i; + if (arguments.length < 2) return l && l.on; + if (l) { + l.on = null; + listeners = listeners.slice(0, i = listeners.indexOf(l)).concat(listeners.slice(i + 1)); + listenerByName.remove(name); + } + if (listener) listeners.push(listenerByName.set(name, { + on: listener + })); + return dispatch; + }; + return event; + } + d3.event = null; + function d3_eventPreventDefault() { + d3.event.preventDefault(); + } + function d3_eventSource() { + var e = d3.event, s; + while (s = e.sourceEvent) e = s; + return e; + } + function d3_eventDispatch(target) { + var dispatch = new d3_dispatch(), i = 0, n = arguments.length; + while (++i < n) dispatch[arguments[i]] = d3_dispatch_event(dispatch); + dispatch.of = function(thiz, argumentz) { + return function(e1) { + try { + var e0 = e1.sourceEvent = d3.event; + e1.target = target; + d3.event = e1; + dispatch[e1.type].apply(thiz, argumentz); + } finally { + d3.event = e0; + } + }; + }; + return dispatch; + } + d3.requote = function(s) { + return s.replace(d3_requote_re, "\\$&"); + }; + var d3_requote_re = /[\\\^\$\*\+\?\|\[\]\(\)\.\{\}]/g; + var d3_subclass = {}.__proto__ ? function(object, prototype) { + object.__proto__ = prototype; + } : function(object, prototype) { + for (var property in prototype) object[property] = prototype[property]; + }; + function d3_selection(groups) { + d3_subclass(groups, d3_selectionPrototype); + return groups; + } + var d3_select = function(s, n) { + return n.querySelector(s); + }, d3_selectAll = function(s, n) { + return n.querySelectorAll(s); + }, d3_selectMatches = function(n, s) { + var d3_selectMatcher = n.matches || n[d3_vendorSymbol(n, "matchesSelector")]; + d3_selectMatches = function(n, s) { + return d3_selectMatcher.call(n, s); + }; + return d3_selectMatches(n, s); + }; + if (typeof Sizzle === "function") { + d3_select = function(s, n) { + return Sizzle(s, n)[0] || null; + }; + d3_selectAll = Sizzle; + d3_selectMatches = Sizzle.matchesSelector; + } + d3.selection = function() { + return d3.select(d3_document.documentElement); + }; + var d3_selectionPrototype = d3.selection.prototype = []; + d3_selectionPrototype.select = function(selector) { + var subgroups = [], subgroup, subnode, group, node; + selector = d3_selection_selector(selector); + for (var j = -1, m = this.length; ++j < m; ) { + subgroups.push(subgroup = []); + subgroup.parentNode = (group = this[j]).parentNode; + for (var i = -1, n = group.length; ++i < n; ) { + if (node = group[i]) { + subgroup.push(subnode = selector.call(node, node.__data__, i, j)); + if (subnode && "__data__" in node) subnode.__data__ = node.__data__; + } else { + subgroup.push(null); + } + } + } + return d3_selection(subgroups); + }; + function d3_selection_selector(selector) { + return typeof selector === "function" ? selector : function() { + return d3_select(selector, this); + }; + } + d3_selectionPrototype.selectAll = function(selector) { + var subgroups = [], subgroup, node; + selector = d3_selection_selectorAll(selector); + for (var j = -1, m = this.length; ++j < m; ) { + for (var group = this[j], i = -1, n = group.length; ++i < n; ) { + if (node = group[i]) { + subgroups.push(subgroup = d3_array(selector.call(node, node.__data__, i, j))); + subgroup.parentNode = node; + } + } + } + return d3_selection(subgroups); + }; + function d3_selection_selectorAll(selector) { + return typeof selector === "function" ? selector : function() { + return d3_selectAll(selector, this); + }; + } + var d3_nsXhtml = "http://www.w3.org/1999/xhtml"; + var d3_nsPrefix = { + svg: "http://www.w3.org/2000/svg", + xhtml: d3_nsXhtml, + xlink: "http://www.w3.org/1999/xlink", + xml: "http://www.w3.org/XML/1998/namespace", + xmlns: "http://www.w3.org/2000/xmlns/" + }; + d3.ns = { + prefix: d3_nsPrefix, + qualify: function(name) { + var i = name.indexOf(":"), prefix = name; + if (i >= 0 && (prefix = name.slice(0, i)) !== "xmlns") name = name.slice(i + 1); + return d3_nsPrefix.hasOwnProperty(prefix) ? { + space: d3_nsPrefix[prefix], + local: name + } : name; + } + }; + d3_selectionPrototype.attr = function(name, value) { + if (arguments.length < 2) { + if (typeof name === "string") { + var node = this.node(); + name = d3.ns.qualify(name); + return name.local ? node.getAttributeNS(name.space, name.local) : node.getAttribute(name); + } + for (value in name) this.each(d3_selection_attr(value, name[value])); + return this; + } + return this.each(d3_selection_attr(name, value)); + }; + function d3_selection_attr(name, value) { + name = d3.ns.qualify(name); + function attrNull() { + this.removeAttribute(name); + } + function attrNullNS() { + this.removeAttributeNS(name.space, name.local); + } + function attrConstant() { + this.setAttribute(name, value); + } + function attrConstantNS() { + this.setAttributeNS(name.space, name.local, value); + } + function attrFunction() { + var x = value.apply(this, arguments); + if (x == null) this.removeAttribute(name); else this.setAttribute(name, x); + } + function attrFunctionNS() { + var x = value.apply(this, arguments); + if (x == null) this.removeAttributeNS(name.space, name.local); else this.setAttributeNS(name.space, name.local, x); + } + return value == null ? name.local ? attrNullNS : attrNull : typeof value === "function" ? name.local ? attrFunctionNS : attrFunction : name.local ? attrConstantNS : attrConstant; + } + function d3_collapse(s) { + return s.trim().replace(/\s+/g, " "); + } + d3_selectionPrototype.classed = function(name, value) { + if (arguments.length < 2) { + if (typeof name === "string") { + var node = this.node(), n = (name = d3_selection_classes(name)).length, i = -1; + if (value = node.classList) { + while (++i < n) if (!value.contains(name[i])) return false; + } else { + value = node.getAttribute("class"); + while (++i < n) if (!d3_selection_classedRe(name[i]).test(value)) return false; + } + return true; + } + for (value in name) this.each(d3_selection_classed(value, name[value])); + return this; + } + return this.each(d3_selection_classed(name, value)); + }; + function d3_selection_classedRe(name) { + return new RegExp("(?:^|\\s+)" + d3.requote(name) + "(?:\\s+|$)", "g"); + } + function d3_selection_classes(name) { + return (name + "").trim().split(/^|\s+/); + } + function d3_selection_classed(name, value) { + name = d3_selection_classes(name).map(d3_selection_classedName); + var n = name.length; + function classedConstant() { + var i = -1; + while (++i < n) name[i](this, value); + } + function classedFunction() { + var i = -1, x = value.apply(this, arguments); + while (++i < n) name[i](this, x); + } + return typeof value === "function" ? classedFunction : classedConstant; + } + function d3_selection_classedName(name) { + var re = d3_selection_classedRe(name); + return function(node, value) { + if (c = node.classList) return value ? c.add(name) : c.remove(name); + var c = node.getAttribute("class") || ""; + if (value) { + re.lastIndex = 0; + if (!re.test(c)) node.setAttribute("class", d3_collapse(c + " " + name)); + } else { + node.setAttribute("class", d3_collapse(c.replace(re, " "))); + } + }; + } + d3_selectionPrototype.style = function(name, value, priority) { + var n = arguments.length; + if (n < 3) { + if (typeof name !== "string") { + if (n < 2) value = ""; + for (priority in name) this.each(d3_selection_style(priority, name[priority], value)); + return this; + } + if (n < 2) { + var node = this.node(); + return d3_window(node).getComputedStyle(node, null).getPropertyValue(name); + } + priority = ""; + } + return this.each(d3_selection_style(name, value, priority)); + }; + function d3_selection_style(name, value, priority) { + function styleNull() { + this.style.removeProperty(name); + } + function styleConstant() { + this.style.setProperty(name, value, priority); + } + function styleFunction() { + var x = value.apply(this, arguments); + if (x == null) this.style.removeProperty(name); else this.style.setProperty(name, x, priority); + } + return value == null ? styleNull : typeof value === "function" ? styleFunction : styleConstant; + } + d3_selectionPrototype.property = function(name, value) { + if (arguments.length < 2) { + if (typeof name === "string") return this.node()[name]; + for (value in name) this.each(d3_selection_property(value, name[value])); + return this; + } + return this.each(d3_selection_property(name, value)); + }; + function d3_selection_property(name, value) { + function propertyNull() { + delete this[name]; + } + function propertyConstant() { + this[name] = value; + } + function propertyFunction() { + var x = value.apply(this, arguments); + if (x == null) delete this[name]; else this[name] = x; + } + return value == null ? propertyNull : typeof value === "function" ? propertyFunction : propertyConstant; + } + d3_selectionPrototype.text = function(value) { + return arguments.length ? this.each(typeof value === "function" ? function() { + var v = value.apply(this, arguments); + this.textContent = v == null ? "" : v; + } : value == null ? function() { + this.textContent = ""; + } : function() { + this.textContent = value; + }) : this.node().textContent; + }; + d3_selectionPrototype.html = function(value) { + return arguments.length ? this.each(typeof value === "function" ? function() { + var v = value.apply(this, arguments); + this.innerHTML = v == null ? "" : v; + } : value == null ? function() { + this.innerHTML = ""; + } : function() { + this.innerHTML = value; + }) : this.node().innerHTML; + }; + d3_selectionPrototype.append = function(name) { + name = d3_selection_creator(name); + return this.select(function() { + return this.appendChild(name.apply(this, arguments)); + }); + }; + function d3_selection_creator(name) { + function create() { + var document = this.ownerDocument, namespace = this.namespaceURI; + return namespace === d3_nsXhtml && document.documentElement.namespaceURI === d3_nsXhtml ? document.createElement(name) : document.createElementNS(namespace, name); + } + function createNS() { + return this.ownerDocument.createElementNS(name.space, name.local); + } + return typeof name === "function" ? name : (name = d3.ns.qualify(name)).local ? createNS : create; + } + d3_selectionPrototype.insert = function(name, before) { + name = d3_selection_creator(name); + before = d3_selection_selector(before); + return this.select(function() { + return this.insertBefore(name.apply(this, arguments), before.apply(this, arguments) || null); + }); + }; + d3_selectionPrototype.remove = function() { + return this.each(d3_selectionRemove); + }; + function d3_selectionRemove() { + var parent = this.parentNode; + if (parent) parent.removeChild(this); + } + d3_selectionPrototype.data = function(value, key) { + var i = -1, n = this.length, group, node; + if (!arguments.length) { + value = new Array(n = (group = this[0]).length); + while (++i < n) { + if (node = group[i]) { + value[i] = node.__data__; + } + } + return value; + } + function bind(group, groupData) { + var i, n = group.length, m = groupData.length, n0 = Math.min(n, m), updateNodes = new Array(m), enterNodes = new Array(m), exitNodes = new Array(n), node, nodeData; + if (key) { + var nodeByKeyValue = new d3_Map(), keyValues = new Array(n), keyValue; + for (i = -1; ++i < n; ) { + if (node = group[i]) { + if (nodeByKeyValue.has(keyValue = key.call(node, node.__data__, i))) { + exitNodes[i] = node; + } else { + nodeByKeyValue.set(keyValue, node); + } + keyValues[i] = keyValue; + } + } + for (i = -1; ++i < m; ) { + if (!(node = nodeByKeyValue.get(keyValue = key.call(groupData, nodeData = groupData[i], i)))) { + enterNodes[i] = d3_selection_dataNode(nodeData); + } else if (node !== true) { + updateNodes[i] = node; + node.__data__ = nodeData; + } + nodeByKeyValue.set(keyValue, true); + } + for (i = -1; ++i < n; ) { + if (i in keyValues && nodeByKeyValue.get(keyValues[i]) !== true) { + exitNodes[i] = group[i]; + } + } + } else { + for (i = -1; ++i < n0; ) { + node = group[i]; + nodeData = groupData[i]; + if (node) { + node.__data__ = nodeData; + updateNodes[i] = node; + } else { + enterNodes[i] = d3_selection_dataNode(nodeData); + } + } + for (;i < m; ++i) { + enterNodes[i] = d3_selection_dataNode(groupData[i]); + } + for (;i < n; ++i) { + exitNodes[i] = group[i]; + } + } + enterNodes.update = updateNodes; + enterNodes.parentNode = updateNodes.parentNode = exitNodes.parentNode = group.parentNode; + enter.push(enterNodes); + update.push(updateNodes); + exit.push(exitNodes); + } + var enter = d3_selection_enter([]), update = d3_selection([]), exit = d3_selection([]); + if (typeof value === "function") { + while (++i < n) { + bind(group = this[i], value.call(group, group.parentNode.__data__, i)); + } + } else { + while (++i < n) { + bind(group = this[i], value); + } + } + update.enter = function() { + return enter; + }; + update.exit = function() { + return exit; + }; + return update; + }; + function d3_selection_dataNode(data) { + return { + __data__: data + }; + } + d3_selectionPrototype.datum = function(value) { + return arguments.length ? this.property("__data__", value) : this.property("__data__"); + }; + d3_selectionPrototype.filter = function(filter) { + var subgroups = [], subgroup, group, node; + if (typeof filter !== "function") filter = d3_selection_filter(filter); + for (var j = 0, m = this.length; j < m; j++) { + subgroups.push(subgroup = []); + subgroup.parentNode = (group = this[j]).parentNode; + for (var i = 0, n = group.length; i < n; i++) { + if ((node = group[i]) && filter.call(node, node.__data__, i, j)) { + subgroup.push(node); + } + } + } + return d3_selection(subgroups); + }; + function d3_selection_filter(selector) { + return function() { + return d3_selectMatches(this, selector); + }; + } + d3_selectionPrototype.order = function() { + for (var j = -1, m = this.length; ++j < m; ) { + for (var group = this[j], i = group.length - 1, next = group[i], node; --i >= 0; ) { + if (node = group[i]) { + if (next && next !== node.nextSibling) next.parentNode.insertBefore(node, next); + next = node; + } + } + } + return this; + }; + d3_selectionPrototype.sort = function(comparator) { + comparator = d3_selection_sortComparator.apply(this, arguments); + for (var j = -1, m = this.length; ++j < m; ) this[j].sort(comparator); + return this.order(); + }; + function d3_selection_sortComparator(comparator) { + if (!arguments.length) comparator = d3_ascending; + return function(a, b) { + return a && b ? comparator(a.__data__, b.__data__) : !a - !b; + }; + } + d3_selectionPrototype.each = function(callback) { + return d3_selection_each(this, function(node, i, j) { + callback.call(node, node.__data__, i, j); + }); + }; + function d3_selection_each(groups, callback) { + for (var j = 0, m = groups.length; j < m; j++) { + for (var group = groups[j], i = 0, n = group.length, node; i < n; i++) { + if (node = group[i]) callback(node, i, j); + } + } + return groups; + } + d3_selectionPrototype.call = function(callback) { + var args = d3_array(arguments); + callback.apply(args[0] = this, args); + return this; + }; + d3_selectionPrototype.empty = function() { + return !this.node(); + }; + d3_selectionPrototype.node = function() { + for (var j = 0, m = this.length; j < m; j++) { + for (var group = this[j], i = 0, n = group.length; i < n; i++) { + var node = group[i]; + if (node) return node; + } + } + return null; + }; + d3_selectionPrototype.size = function() { + var n = 0; + d3_selection_each(this, function() { + ++n; + }); + return n; + }; + function d3_selection_enter(selection) { + d3_subclass(selection, d3_selection_enterPrototype); + return selection; + } + var d3_selection_enterPrototype = []; + d3.selection.enter = d3_selection_enter; + d3.selection.enter.prototype = d3_selection_enterPrototype; + d3_selection_enterPrototype.append = d3_selectionPrototype.append; + d3_selection_enterPrototype.empty = d3_selectionPrototype.empty; + d3_selection_enterPrototype.node = d3_selectionPrototype.node; + d3_selection_enterPrototype.call = d3_selectionPrototype.call; + d3_selection_enterPrototype.size = d3_selectionPrototype.size; + d3_selection_enterPrototype.select = function(selector) { + var subgroups = [], subgroup, subnode, upgroup, group, node; + for (var j = -1, m = this.length; ++j < m; ) { + upgroup = (group = this[j]).update; + subgroups.push(subgroup = []); + subgroup.parentNode = group.parentNode; + for (var i = -1, n = group.length; ++i < n; ) { + if (node = group[i]) { + subgroup.push(upgroup[i] = subnode = selector.call(group.parentNode, node.__data__, i, j)); + subnode.__data__ = node.__data__; + } else { + subgroup.push(null); + } + } + } + return d3_selection(subgroups); + }; + d3_selection_enterPrototype.insert = function(name, before) { + if (arguments.length < 2) before = d3_selection_enterInsertBefore(this); + return d3_selectionPrototype.insert.call(this, name, before); + }; + function d3_selection_enterInsertBefore(enter) { + var i0, j0; + return function(d, i, j) { + var group = enter[j].update, n = group.length, node; + if (j != j0) j0 = j, i0 = 0; + if (i >= i0) i0 = i + 1; + while (!(node = group[i0]) && ++i0 < n) ; + return node; + }; + } + d3.select = function(node) { + var group; + if (typeof node === "string") { + group = [ d3_select(node, d3_document) ]; + group.parentNode = d3_document.documentElement; + } else { + group = [ node ]; + group.parentNode = d3_documentElement(node); + } + return d3_selection([ group ]); + }; + d3.selectAll = function(nodes) { + var group; + if (typeof nodes === "string") { + group = d3_array(d3_selectAll(nodes, d3_document)); + group.parentNode = d3_document.documentElement; + } else { + group = d3_array(nodes); + group.parentNode = null; + } + return d3_selection([ group ]); + }; + d3_selectionPrototype.on = function(type, listener, capture) { + var n = arguments.length; + if (n < 3) { + if (typeof type !== "string") { + if (n < 2) listener = false; + for (capture in type) this.each(d3_selection_on(capture, type[capture], listener)); + return this; + } + if (n < 2) return (n = this.node()["__on" + type]) && n._; + capture = false; + } + return this.each(d3_selection_on(type, listener, capture)); + }; + function d3_selection_on(type, listener, capture) { + var name = "__on" + type, i = type.indexOf("."), wrap = d3_selection_onListener; + if (i > 0) type = type.slice(0, i); + var filter = d3_selection_onFilters.get(type); + if (filter) type = filter, wrap = d3_selection_onFilter; + function onRemove() { + var l = this[name]; + if (l) { + this.removeEventListener(type, l, l.$); + delete this[name]; + } + } + function onAdd() { + var l = wrap(listener, d3_array(arguments)); + onRemove.call(this); + this.addEventListener(type, this[name] = l, l.$ = capture); + l._ = listener; + } + function removeAll() { + var re = new RegExp("^__on([^.]+)" + d3.requote(type) + "$"), match; + for (var name in this) { + if (match = name.match(re)) { + var l = this[name]; + this.removeEventListener(match[1], l, l.$); + delete this[name]; + } + } + } + return i ? listener ? onAdd : onRemove : listener ? d3_noop : removeAll; + } + var d3_selection_onFilters = d3.map({ + mouseenter: "mouseover", + mouseleave: "mouseout" + }); + if (d3_document) { + d3_selection_onFilters.forEach(function(k) { + if ("on" + k in d3_document) d3_selection_onFilters.remove(k); + }); + } + function d3_selection_onListener(listener, argumentz) { + return function(e) { + var o = d3.event; + d3.event = e; + argumentz[0] = this.__data__; + try { + listener.apply(this, argumentz); + } finally { + d3.event = o; + } + }; + } + function d3_selection_onFilter(listener, argumentz) { + var l = d3_selection_onListener(listener, argumentz); + return function(e) { + var target = this, related = e.relatedTarget; + if (!related || related !== target && !(related.compareDocumentPosition(target) & 8)) { + l.call(target, e); + } + }; + } + var d3_event_dragSelect, d3_event_dragId = 0; + function d3_event_dragSuppress(node) { + var name = ".dragsuppress-" + ++d3_event_dragId, click = "click" + name, w = d3.select(d3_window(node)).on("touchmove" + name, d3_eventPreventDefault).on("dragstart" + name, d3_eventPreventDefault).on("selectstart" + name, d3_eventPreventDefault); + if (d3_event_dragSelect == null) { + d3_event_dragSelect = "onselectstart" in node ? false : d3_vendorSymbol(node.style, "userSelect"); + } + if (d3_event_dragSelect) { + var style = d3_documentElement(node).style, select = style[d3_event_dragSelect]; + style[d3_event_dragSelect] = "none"; + } + return function(suppressClick) { + w.on(name, null); + if (d3_event_dragSelect) style[d3_event_dragSelect] = select; + if (suppressClick) { + var off = function() { + w.on(click, null); + }; + w.on(click, function() { + d3_eventPreventDefault(); + off(); + }, true); + setTimeout(off, 0); + } + }; + } + d3.mouse = function(container) { + return d3_mousePoint(container, d3_eventSource()); + }; + var d3_mouse_bug44083 = this.navigator && /WebKit/.test(this.navigator.userAgent) ? -1 : 0; + function d3_mousePoint(container, e) { + if (e.changedTouches) e = e.changedTouches[0]; + var svg = container.ownerSVGElement || container; + if (svg.createSVGPoint) { + var point = svg.createSVGPoint(); + if (d3_mouse_bug44083 < 0) { + var window = d3_window(container); + if (window.scrollX || window.scrollY) { + svg = d3.select("body").append("svg").style({ + position: "absolute", + top: 0, + left: 0, + margin: 0, + padding: 0, + border: "none" + }, "important"); + var ctm = svg[0][0].getScreenCTM(); + d3_mouse_bug44083 = !(ctm.f || ctm.e); + svg.remove(); + } + } + if (d3_mouse_bug44083) point.x = e.pageX, point.y = e.pageY; else point.x = e.clientX, + point.y = e.clientY; + point = point.matrixTransform(container.getScreenCTM().inverse()); + return [ point.x, point.y ]; + } + var rect = container.getBoundingClientRect(); + return [ e.clientX - rect.left - container.clientLeft, e.clientY - rect.top - container.clientTop ]; + } + d3.touch = function(container, touches, identifier) { + if (arguments.length < 3) identifier = touches, touches = d3_eventSource().changedTouches; + if (touches) for (var i = 0, n = touches.length, touch; i < n; ++i) { + if ((touch = touches[i]).identifier === identifier) { + return d3_mousePoint(container, touch); + } + } + }; + d3.behavior.drag = function() { + var event = d3_eventDispatch(drag, "drag", "dragstart", "dragend"), origin = null, mousedown = dragstart(d3_noop, d3.mouse, d3_window, "mousemove", "mouseup"), touchstart = dragstart(d3_behavior_dragTouchId, d3.touch, d3_identity, "touchmove", "touchend"); + function drag() { + this.on("mousedown.drag", mousedown).on("touchstart.drag", touchstart); + } + function dragstart(id, position, subject, move, end) { + return function() { + var that = this, target = d3.event.target.correspondingElement || d3.event.target, parent = that.parentNode, dispatch = event.of(that, arguments), dragged = 0, dragId = id(), dragName = ".drag" + (dragId == null ? "" : "-" + dragId), dragOffset, dragSubject = d3.select(subject(target)).on(move + dragName, moved).on(end + dragName, ended), dragRestore = d3_event_dragSuppress(target), position0 = position(parent, dragId); + if (origin) { + dragOffset = origin.apply(that, arguments); + dragOffset = [ dragOffset.x - position0[0], dragOffset.y - position0[1] ]; + } else { + dragOffset = [ 0, 0 ]; + } + dispatch({ + type: "dragstart" + }); + function moved() { + var position1 = position(parent, dragId), dx, dy; + if (!position1) return; + dx = position1[0] - position0[0]; + dy = position1[1] - position0[1]; + dragged |= dx | dy; + position0 = position1; + dispatch({ + type: "drag", + x: position1[0] + dragOffset[0], + y: position1[1] + dragOffset[1], + dx: dx, + dy: dy + }); + } + function ended() { + if (!position(parent, dragId)) return; + dragSubject.on(move + dragName, null).on(end + dragName, null); + dragRestore(dragged); + dispatch({ + type: "dragend" + }); + } + }; + } + drag.origin = function(x) { + if (!arguments.length) return origin; + origin = x; + return drag; + }; + return d3.rebind(drag, event, "on"); + }; + function d3_behavior_dragTouchId() { + return d3.event.changedTouches[0].identifier; + } + d3.touches = function(container, touches) { + if (arguments.length < 2) touches = d3_eventSource().touches; + return touches ? d3_array(touches).map(function(touch) { + var point = d3_mousePoint(container, touch); + point.identifier = touch.identifier; + return point; + }) : []; + }; + var ε = 1e-6, ε2 = ε * ε, π = Math.PI, τ = 2 * π, τε = τ - ε, halfπ = π / 2, d3_radians = π / 180, d3_degrees = 180 / π; + function d3_sgn(x) { + return x > 0 ? 1 : x < 0 ? -1 : 0; + } + function d3_cross2d(a, b, c) { + return (b[0] - a[0]) * (c[1] - a[1]) - (b[1] - a[1]) * (c[0] - a[0]); + } + function d3_acos(x) { + return x > 1 ? 0 : x < -1 ? π : Math.acos(x); + } + function d3_asin(x) { + return x > 1 ? halfπ : x < -1 ? -halfπ : Math.asin(x); + } + function d3_sinh(x) { + return ((x = Math.exp(x)) - 1 / x) / 2; + } + function d3_cosh(x) { + return ((x = Math.exp(x)) + 1 / x) / 2; + } + function d3_tanh(x) { + return ((x = Math.exp(2 * x)) - 1) / (x + 1); + } + function d3_haversin(x) { + return (x = Math.sin(x / 2)) * x; + } + var ρ = Math.SQRT2, ρ2 = 2, ρ4 = 4; + d3.interpolateZoom = function(p0, p1) { + var ux0 = p0[0], uy0 = p0[1], w0 = p0[2], ux1 = p1[0], uy1 = p1[1], w1 = p1[2], dx = ux1 - ux0, dy = uy1 - uy0, d2 = dx * dx + dy * dy, i, S; + if (d2 < ε2) { + S = Math.log(w1 / w0) / ρ; + i = function(t) { + return [ ux0 + t * dx, uy0 + t * dy, w0 * Math.exp(ρ * t * S) ]; + }; + } else { + var d1 = Math.sqrt(d2), b0 = (w1 * w1 - w0 * w0 + ρ4 * d2) / (2 * w0 * ρ2 * d1), b1 = (w1 * w1 - w0 * w0 - ρ4 * d2) / (2 * w1 * ρ2 * d1), r0 = Math.log(Math.sqrt(b0 * b0 + 1) - b0), r1 = Math.log(Math.sqrt(b1 * b1 + 1) - b1); + S = (r1 - r0) / ρ; + i = function(t) { + var s = t * S, coshr0 = d3_cosh(r0), u = w0 / (ρ2 * d1) * (coshr0 * d3_tanh(ρ * s + r0) - d3_sinh(r0)); + return [ ux0 + u * dx, uy0 + u * dy, w0 * coshr0 / d3_cosh(ρ * s + r0) ]; + }; + } + i.duration = S * 1e3; + return i; + }; + d3.behavior.zoom = function() { + var view = { + x: 0, + y: 0, + k: 1 + }, translate0, center0, center, size = [ 960, 500 ], scaleExtent = d3_behavior_zoomInfinity, duration = 250, zooming = 0, mousedown = "mousedown.zoom", mousemove = "mousemove.zoom", mouseup = "mouseup.zoom", mousewheelTimer, touchstart = "touchstart.zoom", touchtime, event = d3_eventDispatch(zoom, "zoomstart", "zoom", "zoomend"), x0, x1, y0, y1; + if (!d3_behavior_zoomWheel) { + d3_behavior_zoomWheel = "onwheel" in d3_document ? (d3_behavior_zoomDelta = function() { + return -d3.event.deltaY * (d3.event.deltaMode ? 120 : 1); + }, "wheel") : "onmousewheel" in d3_document ? (d3_behavior_zoomDelta = function() { + return d3.event.wheelDelta; + }, "mousewheel") : (d3_behavior_zoomDelta = function() { + return -d3.event.detail; + }, "MozMousePixelScroll"); + } + function zoom(g) { + g.on(mousedown, mousedowned).on(d3_behavior_zoomWheel + ".zoom", mousewheeled).on("dblclick.zoom", dblclicked).on(touchstart, touchstarted); + } + zoom.event = function(g) { + g.each(function() { + var dispatch = event.of(this, arguments), view1 = view; + if (d3_transitionInheritId) { + d3.select(this).transition().each("start.zoom", function() { + view = this.__chart__ || { + x: 0, + y: 0, + k: 1 + }; + zoomstarted(dispatch); + }).tween("zoom:zoom", function() { + var dx = size[0], dy = size[1], cx = center0 ? center0[0] : dx / 2, cy = center0 ? center0[1] : dy / 2, i = d3.interpolateZoom([ (cx - view.x) / view.k, (cy - view.y) / view.k, dx / view.k ], [ (cx - view1.x) / view1.k, (cy - view1.y) / view1.k, dx / view1.k ]); + return function(t) { + var l = i(t), k = dx / l[2]; + this.__chart__ = view = { + x: cx - l[0] * k, + y: cy - l[1] * k, + k: k + }; + zoomed(dispatch); + }; + }).each("interrupt.zoom", function() { + zoomended(dispatch); + }).each("end.zoom", function() { + zoomended(dispatch); + }); + } else { + this.__chart__ = view; + zoomstarted(dispatch); + zoomed(dispatch); + zoomended(dispatch); + } + }); + }; + zoom.translate = function(_) { + if (!arguments.length) return [ view.x, view.y ]; + view = { + x: +_[0], + y: +_[1], + k: view.k + }; + rescale(); + return zoom; + }; + zoom.scale = function(_) { + if (!arguments.length) return view.k; + view = { + x: view.x, + y: view.y, + k: null + }; + scaleTo(+_); + rescale(); + return zoom; + }; + zoom.scaleExtent = function(_) { + if (!arguments.length) return scaleExtent; + scaleExtent = _ == null ? d3_behavior_zoomInfinity : [ +_[0], +_[1] ]; + return zoom; + }; + zoom.center = function(_) { + if (!arguments.length) return center; + center = _ && [ +_[0], +_[1] ]; + return zoom; + }; + zoom.size = function(_) { + if (!arguments.length) return size; + size = _ && [ +_[0], +_[1] ]; + return zoom; + }; + zoom.duration = function(_) { + if (!arguments.length) return duration; + duration = +_; + return zoom; + }; + zoom.x = function(z) { + if (!arguments.length) return x1; + x1 = z; + x0 = z.copy(); + view = { + x: 0, + y: 0, + k: 1 + }; + return zoom; + }; + zoom.y = function(z) { + if (!arguments.length) return y1; + y1 = z; + y0 = z.copy(); + view = { + x: 0, + y: 0, + k: 1 + }; + return zoom; + }; + function location(p) { + return [ (p[0] - view.x) / view.k, (p[1] - view.y) / view.k ]; + } + function point(l) { + return [ l[0] * view.k + view.x, l[1] * view.k + view.y ]; + } + function scaleTo(s) { + view.k = Math.max(scaleExtent[0], Math.min(scaleExtent[1], s)); + } + function translateTo(p, l) { + l = point(l); + view.x += p[0] - l[0]; + view.y += p[1] - l[1]; + } + function zoomTo(that, p, l, k) { + that.__chart__ = { + x: view.x, + y: view.y, + k: view.k + }; + scaleTo(Math.pow(2, k)); + translateTo(center0 = p, l); + that = d3.select(that); + if (duration > 0) that = that.transition().duration(duration); + that.call(zoom.event); + } + function rescale() { + if (x1) x1.domain(x0.range().map(function(x) { + return (x - view.x) / view.k; + }).map(x0.invert)); + if (y1) y1.domain(y0.range().map(function(y) { + return (y - view.y) / view.k; + }).map(y0.invert)); + } + function zoomstarted(dispatch) { + if (!zooming++) dispatch({ + type: "zoomstart" + }); + } + function zoomed(dispatch) { + rescale(); + dispatch({ + type: "zoom", + scale: view.k, + translate: [ view.x, view.y ] + }); + } + function zoomended(dispatch) { + if (!--zooming) dispatch({ + type: "zoomend" + }), center0 = null; + } + function mousedowned() { + var that = this, dispatch = event.of(that, arguments), dragged = 0, subject = d3.select(d3_window(that)).on(mousemove, moved).on(mouseup, ended), location0 = location(d3.mouse(that)), dragRestore = d3_event_dragSuppress(that); + d3_selection_interrupt.call(that); + zoomstarted(dispatch); + function moved() { + dragged = 1; + translateTo(d3.mouse(that), location0); + zoomed(dispatch); + } + function ended() { + subject.on(mousemove, null).on(mouseup, null); + dragRestore(dragged); + zoomended(dispatch); + } + } + function touchstarted() { + var that = this, dispatch = event.of(that, arguments), locations0 = {}, distance0 = 0, scale0, zoomName = ".zoom-" + d3.event.changedTouches[0].identifier, touchmove = "touchmove" + zoomName, touchend = "touchend" + zoomName, targets = [], subject = d3.select(that), dragRestore = d3_event_dragSuppress(that); + started(); + zoomstarted(dispatch); + subject.on(mousedown, null).on(touchstart, started); + function relocate() { + var touches = d3.touches(that); + scale0 = view.k; + touches.forEach(function(t) { + if (t.identifier in locations0) locations0[t.identifier] = location(t); + }); + return touches; + } + function started() { + var target = d3.event.target; + d3.select(target).on(touchmove, moved).on(touchend, ended); + targets.push(target); + var changed = d3.event.changedTouches; + for (var i = 0, n = changed.length; i < n; ++i) { + locations0[changed[i].identifier] = null; + } + var touches = relocate(), now = Date.now(); + if (touches.length === 1) { + if (now - touchtime < 500) { + var p = touches[0]; + zoomTo(that, p, locations0[p.identifier], Math.floor(Math.log(view.k) / Math.LN2) + 1); + d3_eventPreventDefault(); + } + touchtime = now; + } else if (touches.length > 1) { + var p = touches[0], q = touches[1], dx = p[0] - q[0], dy = p[1] - q[1]; + distance0 = dx * dx + dy * dy; + } + } + function moved() { + var touches = d3.touches(that), p0, l0, p1, l1; + d3_selection_interrupt.call(that); + for (var i = 0, n = touches.length; i < n; ++i, l1 = null) { + p1 = touches[i]; + if (l1 = locations0[p1.identifier]) { + if (l0) break; + p0 = p1, l0 = l1; + } + } + if (l1) { + var distance1 = (distance1 = p1[0] - p0[0]) * distance1 + (distance1 = p1[1] - p0[1]) * distance1, scale1 = distance0 && Math.sqrt(distance1 / distance0); + p0 = [ (p0[0] + p1[0]) / 2, (p0[1] + p1[1]) / 2 ]; + l0 = [ (l0[0] + l1[0]) / 2, (l0[1] + l1[1]) / 2 ]; + scaleTo(scale1 * scale0); + } + touchtime = null; + translateTo(p0, l0); + zoomed(dispatch); + } + function ended() { + if (d3.event.touches.length) { + var changed = d3.event.changedTouches; + for (var i = 0, n = changed.length; i < n; ++i) { + delete locations0[changed[i].identifier]; + } + for (var identifier in locations0) { + return void relocate(); + } + } + d3.selectAll(targets).on(zoomName, null); + subject.on(mousedown, mousedowned).on(touchstart, touchstarted); + dragRestore(); + zoomended(dispatch); + } + } + function mousewheeled() { + var dispatch = event.of(this, arguments); + if (mousewheelTimer) clearTimeout(mousewheelTimer); else d3_selection_interrupt.call(this), + translate0 = location(center0 = center || d3.mouse(this)), zoomstarted(dispatch); + mousewheelTimer = setTimeout(function() { + mousewheelTimer = null; + zoomended(dispatch); + }, 50); + d3_eventPreventDefault(); + scaleTo(Math.pow(2, d3_behavior_zoomDelta() * .002) * view.k); + translateTo(center0, translate0); + zoomed(dispatch); + } + function dblclicked() { + var p = d3.mouse(this), k = Math.log(view.k) / Math.LN2; + zoomTo(this, p, location(p), d3.event.shiftKey ? Math.ceil(k) - 1 : Math.floor(k) + 1); + } + return d3.rebind(zoom, event, "on"); + }; + var d3_behavior_zoomInfinity = [ 0, Infinity ], d3_behavior_zoomDelta, d3_behavior_zoomWheel; + d3.color = d3_color; + function d3_color() {} + d3_color.prototype.toString = function() { + return this.rgb() + ""; + }; + d3.hsl = d3_hsl; + function d3_hsl(h, s, l) { + return this instanceof d3_hsl ? void (this.h = +h, this.s = +s, this.l = +l) : arguments.length < 2 ? h instanceof d3_hsl ? new d3_hsl(h.h, h.s, h.l) : d3_rgb_parse("" + h, d3_rgb_hsl, d3_hsl) : new d3_hsl(h, s, l); + } + var d3_hslPrototype = d3_hsl.prototype = new d3_color(); + d3_hslPrototype.brighter = function(k) { + k = Math.pow(.7, arguments.length ? k : 1); + return new d3_hsl(this.h, this.s, this.l / k); + }; + d3_hslPrototype.darker = function(k) { + k = Math.pow(.7, arguments.length ? k : 1); + return new d3_hsl(this.h, this.s, k * this.l); + }; + d3_hslPrototype.rgb = function() { + return d3_hsl_rgb(this.h, this.s, this.l); + }; + function d3_hsl_rgb(h, s, l) { + var m1, m2; + h = isNaN(h) ? 0 : (h %= 360) < 0 ? h + 360 : h; + s = isNaN(s) ? 0 : s < 0 ? 0 : s > 1 ? 1 : s; + l = l < 0 ? 0 : l > 1 ? 1 : l; + m2 = l <= .5 ? l * (1 + s) : l + s - l * s; + m1 = 2 * l - m2; + function v(h) { + if (h > 360) h -= 360; else if (h < 0) h += 360; + if (h < 60) return m1 + (m2 - m1) * h / 60; + if (h < 180) return m2; + if (h < 240) return m1 + (m2 - m1) * (240 - h) / 60; + return m1; + } + function vv(h) { + return Math.round(v(h) * 255); + } + return new d3_rgb(vv(h + 120), vv(h), vv(h - 120)); + } + d3.hcl = d3_hcl; + function d3_hcl(h, c, l) { + return this instanceof d3_hcl ? void (this.h = +h, this.c = +c, this.l = +l) : arguments.length < 2 ? h instanceof d3_hcl ? new d3_hcl(h.h, h.c, h.l) : h instanceof d3_lab ? d3_lab_hcl(h.l, h.a, h.b) : d3_lab_hcl((h = d3_rgb_lab((h = d3.rgb(h)).r, h.g, h.b)).l, h.a, h.b) : new d3_hcl(h, c, l); + } + var d3_hclPrototype = d3_hcl.prototype = new d3_color(); + d3_hclPrototype.brighter = function(k) { + return new d3_hcl(this.h, this.c, Math.min(100, this.l + d3_lab_K * (arguments.length ? k : 1))); + }; + d3_hclPrototype.darker = function(k) { + return new d3_hcl(this.h, this.c, Math.max(0, this.l - d3_lab_K * (arguments.length ? k : 1))); + }; + d3_hclPrototype.rgb = function() { + return d3_hcl_lab(this.h, this.c, this.l).rgb(); + }; + function d3_hcl_lab(h, c, l) { + if (isNaN(h)) h = 0; + if (isNaN(c)) c = 0; + return new d3_lab(l, Math.cos(h *= d3_radians) * c, Math.sin(h) * c); + } + d3.lab = d3_lab; + function d3_lab(l, a, b) { + return this instanceof d3_lab ? void (this.l = +l, this.a = +a, this.b = +b) : arguments.length < 2 ? l instanceof d3_lab ? new d3_lab(l.l, l.a, l.b) : l instanceof d3_hcl ? d3_hcl_lab(l.h, l.c, l.l) : d3_rgb_lab((l = d3_rgb(l)).r, l.g, l.b) : new d3_lab(l, a, b); + } + var d3_lab_K = 18; + var d3_lab_X = .95047, d3_lab_Y = 1, d3_lab_Z = 1.08883; + var d3_labPrototype = d3_lab.prototype = new d3_color(); + d3_labPrototype.brighter = function(k) { + return new d3_lab(Math.min(100, this.l + d3_lab_K * (arguments.length ? k : 1)), this.a, this.b); + }; + d3_labPrototype.darker = function(k) { + return new d3_lab(Math.max(0, this.l - d3_lab_K * (arguments.length ? k : 1)), this.a, this.b); + }; + d3_labPrototype.rgb = function() { + return d3_lab_rgb(this.l, this.a, this.b); + }; + function d3_lab_rgb(l, a, b) { + var y = (l + 16) / 116, x = y + a / 500, z = y - b / 200; + x = d3_lab_xyz(x) * d3_lab_X; + y = d3_lab_xyz(y) * d3_lab_Y; + z = d3_lab_xyz(z) * d3_lab_Z; + return new d3_rgb(d3_xyz_rgb(3.2404542 * x - 1.5371385 * y - .4985314 * z), d3_xyz_rgb(-.969266 * x + 1.8760108 * y + .041556 * z), d3_xyz_rgb(.0556434 * x - .2040259 * y + 1.0572252 * z)); + } + function d3_lab_hcl(l, a, b) { + return l > 0 ? new d3_hcl(Math.atan2(b, a) * d3_degrees, Math.sqrt(a * a + b * b), l) : new d3_hcl(NaN, NaN, l); + } + function d3_lab_xyz(x) { + return x > .206893034 ? x * x * x : (x - 4 / 29) / 7.787037; + } + function d3_xyz_lab(x) { + return x > .008856 ? Math.pow(x, 1 / 3) : 7.787037 * x + 4 / 29; + } + function d3_xyz_rgb(r) { + return Math.round(255 * (r <= .00304 ? 12.92 * r : 1.055 * Math.pow(r, 1 / 2.4) - .055)); + } + d3.rgb = d3_rgb; + function d3_rgb(r, g, b) { + return this instanceof d3_rgb ? void (this.r = ~~r, this.g = ~~g, this.b = ~~b) : arguments.length < 2 ? r instanceof d3_rgb ? new d3_rgb(r.r, r.g, r.b) : d3_rgb_parse("" + r, d3_rgb, d3_hsl_rgb) : new d3_rgb(r, g, b); + } + function d3_rgbNumber(value) { + return new d3_rgb(value >> 16, value >> 8 & 255, value & 255); + } + function d3_rgbString(value) { + return d3_rgbNumber(value) + ""; + } + var d3_rgbPrototype = d3_rgb.prototype = new d3_color(); + d3_rgbPrototype.brighter = function(k) { + k = Math.pow(.7, arguments.length ? k : 1); + var r = this.r, g = this.g, b = this.b, i = 30; + if (!r && !g && !b) return new d3_rgb(i, i, i); + if (r && r < i) r = i; + if (g && g < i) g = i; + if (b && b < i) b = i; + return new d3_rgb(Math.min(255, r / k), Math.min(255, g / k), Math.min(255, b / k)); + }; + d3_rgbPrototype.darker = function(k) { + k = Math.pow(.7, arguments.length ? k : 1); + return new d3_rgb(k * this.r, k * this.g, k * this.b); + }; + d3_rgbPrototype.hsl = function() { + return d3_rgb_hsl(this.r, this.g, this.b); + }; + d3_rgbPrototype.toString = function() { + return "#" + d3_rgb_hex(this.r) + d3_rgb_hex(this.g) + d3_rgb_hex(this.b); + }; + function d3_rgb_hex(v) { + return v < 16 ? "0" + Math.max(0, v).toString(16) : Math.min(255, v).toString(16); + } + function d3_rgb_parse(format, rgb, hsl) { + var r = 0, g = 0, b = 0, m1, m2, color; + m1 = /([a-z]+)\((.*)\)/.exec(format = format.toLowerCase()); + if (m1) { + m2 = m1[2].split(","); + switch (m1[1]) { + case "hsl": + { + return hsl(parseFloat(m2[0]), parseFloat(m2[1]) / 100, parseFloat(m2[2]) / 100); + } + + case "rgb": + { + return rgb(d3_rgb_parseNumber(m2[0]), d3_rgb_parseNumber(m2[1]), d3_rgb_parseNumber(m2[2])); + } + } + } + if (color = d3_rgb_names.get(format)) { + return rgb(color.r, color.g, color.b); + } + if (format != null && format.charAt(0) === "#" && !isNaN(color = parseInt(format.slice(1), 16))) { + if (format.length === 4) { + r = (color & 3840) >> 4; + r = r >> 4 | r; + g = color & 240; + g = g >> 4 | g; + b = color & 15; + b = b << 4 | b; + } else if (format.length === 7) { + r = (color & 16711680) >> 16; + g = (color & 65280) >> 8; + b = color & 255; + } + } + return rgb(r, g, b); + } + function d3_rgb_hsl(r, g, b) { + var min = Math.min(r /= 255, g /= 255, b /= 255), max = Math.max(r, g, b), d = max - min, h, s, l = (max + min) / 2; + if (d) { + s = l < .5 ? d / (max + min) : d / (2 - max - min); + if (r == max) h = (g - b) / d + (g < b ? 6 : 0); else if (g == max) h = (b - r) / d + 2; else h = (r - g) / d + 4; + h *= 60; + } else { + h = NaN; + s = l > 0 && l < 1 ? 0 : h; + } + return new d3_hsl(h, s, l); + } + function d3_rgb_lab(r, g, b) { + r = d3_rgb_xyz(r); + g = d3_rgb_xyz(g); + b = d3_rgb_xyz(b); + var x = d3_xyz_lab((.4124564 * r + .3575761 * g + .1804375 * b) / d3_lab_X), y = d3_xyz_lab((.2126729 * r + .7151522 * g + .072175 * b) / d3_lab_Y), z = d3_xyz_lab((.0193339 * r + .119192 * g + .9503041 * b) / d3_lab_Z); + return d3_lab(116 * y - 16, 500 * (x - y), 200 * (y - z)); + } + function d3_rgb_xyz(r) { + return (r /= 255) <= .04045 ? r / 12.92 : Math.pow((r + .055) / 1.055, 2.4); + } + function d3_rgb_parseNumber(c) { + var f = parseFloat(c); + return c.charAt(c.length - 1) === "%" ? Math.round(f * 2.55) : f; + } + var d3_rgb_names = d3.map({ + aliceblue: 15792383, + antiquewhite: 16444375, + aqua: 65535, + aquamarine: 8388564, + azure: 15794175, + beige: 16119260, + bisque: 16770244, + black: 0, + blanchedalmond: 16772045, + blue: 255, + blueviolet: 9055202, + brown: 10824234, + burlywood: 14596231, + cadetblue: 6266528, + chartreuse: 8388352, + chocolate: 13789470, + coral: 16744272, + cornflowerblue: 6591981, + cornsilk: 16775388, + crimson: 14423100, + cyan: 65535, + darkblue: 139, + darkcyan: 35723, + darkgoldenrod: 12092939, + darkgray: 11119017, + darkgreen: 25600, + darkgrey: 11119017, + darkkhaki: 12433259, + darkmagenta: 9109643, + darkolivegreen: 5597999, + darkorange: 16747520, + darkorchid: 10040012, + darkred: 9109504, + darksalmon: 15308410, + darkseagreen: 9419919, + darkslateblue: 4734347, + darkslategray: 3100495, + darkslategrey: 3100495, + darkturquoise: 52945, + darkviolet: 9699539, + deeppink: 16716947, + deepskyblue: 49151, + dimgray: 6908265, + dimgrey: 6908265, + dodgerblue: 2003199, + firebrick: 11674146, + floralwhite: 16775920, + forestgreen: 2263842, + fuchsia: 16711935, + gainsboro: 14474460, + ghostwhite: 16316671, + gold: 16766720, + goldenrod: 14329120, + gray: 8421504, + green: 32768, + greenyellow: 11403055, + grey: 8421504, + honeydew: 15794160, + hotpink: 16738740, + indianred: 13458524, + indigo: 4915330, + ivory: 16777200, + khaki: 15787660, + lavender: 15132410, + lavenderblush: 16773365, + lawngreen: 8190976, + lemonchiffon: 16775885, + lightblue: 11393254, + lightcoral: 15761536, + lightcyan: 14745599, + lightgoldenrodyellow: 16448210, + lightgray: 13882323, + lightgreen: 9498256, + lightgrey: 13882323, + lightpink: 16758465, + lightsalmon: 16752762, + lightseagreen: 2142890, + lightskyblue: 8900346, + lightslategray: 7833753, + lightslategrey: 7833753, + lightsteelblue: 11584734, + lightyellow: 16777184, + lime: 65280, + limegreen: 3329330, + linen: 16445670, + magenta: 16711935, + maroon: 8388608, + mediumaquamarine: 6737322, + mediumblue: 205, + mediumorchid: 12211667, + mediumpurple: 9662683, + mediumseagreen: 3978097, + mediumslateblue: 8087790, + mediumspringgreen: 64154, + mediumturquoise: 4772300, + mediumvioletred: 13047173, + midnightblue: 1644912, + mintcream: 16121850, + mistyrose: 16770273, + moccasin: 16770229, + navajowhite: 16768685, + navy: 128, + oldlace: 16643558, + olive: 8421376, + olivedrab: 7048739, + orange: 16753920, + orangered: 16729344, + orchid: 14315734, + palegoldenrod: 15657130, + palegreen: 10025880, + paleturquoise: 11529966, + palevioletred: 14381203, + papayawhip: 16773077, + peachpuff: 16767673, + peru: 13468991, + pink: 16761035, + plum: 14524637, + powderblue: 11591910, + purple: 8388736, + rebeccapurple: 6697881, + red: 16711680, + rosybrown: 12357519, + royalblue: 4286945, + saddlebrown: 9127187, + salmon: 16416882, + sandybrown: 16032864, + seagreen: 3050327, + seashell: 16774638, + sienna: 10506797, + silver: 12632256, + skyblue: 8900331, + slateblue: 6970061, + slategray: 7372944, + slategrey: 7372944, + snow: 16775930, + springgreen: 65407, + steelblue: 4620980, + tan: 13808780, + teal: 32896, + thistle: 14204888, + tomato: 16737095, + turquoise: 4251856, + violet: 15631086, + wheat: 16113331, + white: 16777215, + whitesmoke: 16119285, + yellow: 16776960, + yellowgreen: 10145074 + }); + d3_rgb_names.forEach(function(key, value) { + d3_rgb_names.set(key, d3_rgbNumber(value)); + }); + function d3_functor(v) { + return typeof v === "function" ? v : function() { + return v; + }; + } + d3.functor = d3_functor; + d3.xhr = d3_xhrType(d3_identity); + function d3_xhrType(response) { + return function(url, mimeType, callback) { + if (arguments.length === 2 && typeof mimeType === "function") callback = mimeType, + mimeType = null; + return d3_xhr(url, mimeType, response, callback); + }; + } + function d3_xhr(url, mimeType, response, callback) { + var xhr = {}, dispatch = d3.dispatch("beforesend", "progress", "load", "error"), headers = {}, request = new XMLHttpRequest(), responseType = null; + if (self.XDomainRequest && !("withCredentials" in request) && /^(http(s)?:)?\/\//.test(url)) request = new XDomainRequest(); + "onload" in request ? request.onload = request.onerror = respond : request.onreadystatechange = function() { + request.readyState > 3 && respond(); + }; + function respond() { + var status = request.status, result; + if (!status && d3_xhrHasResponse(request) || status >= 200 && status < 300 || status === 304) { + try { + result = response.call(xhr, request); + } catch (e) { + dispatch.error.call(xhr, e); + return; + } + dispatch.load.call(xhr, result); + } else { + dispatch.error.call(xhr, request); + } + } + request.onprogress = function(event) { + var o = d3.event; + d3.event = event; + try { + dispatch.progress.call(xhr, request); + } finally { + d3.event = o; + } + }; + xhr.header = function(name, value) { + name = (name + "").toLowerCase(); + if (arguments.length < 2) return headers[name]; + if (value == null) delete headers[name]; else headers[name] = value + ""; + return xhr; + }; + xhr.mimeType = function(value) { + if (!arguments.length) return mimeType; + mimeType = value == null ? null : value + ""; + return xhr; + }; + xhr.responseType = function(value) { + if (!arguments.length) return responseType; + responseType = value; + return xhr; + }; + xhr.response = function(value) { + response = value; + return xhr; + }; + [ "get", "post" ].forEach(function(method) { + xhr[method] = function() { + return xhr.send.apply(xhr, [ method ].concat(d3_array(arguments))); + }; + }); + xhr.send = function(method, data, callback) { + if (arguments.length === 2 && typeof data === "function") callback = data, data = null; + request.open(method, url, true); + if (mimeType != null && !("accept" in headers)) headers["accept"] = mimeType + ",*/*"; + if (request.setRequestHeader) for (var name in headers) request.setRequestHeader(name, headers[name]); + if (mimeType != null && request.overrideMimeType) request.overrideMimeType(mimeType); + if (responseType != null) request.responseType = responseType; + if (callback != null) xhr.on("error", callback).on("load", function(request) { + callback(null, request); + }); + dispatch.beforesend.call(xhr, request); + request.send(data == null ? null : data); + return xhr; + }; + xhr.abort = function() { + request.abort(); + return xhr; + }; + d3.rebind(xhr, dispatch, "on"); + return callback == null ? xhr : xhr.get(d3_xhr_fixCallback(callback)); + } + function d3_xhr_fixCallback(callback) { + return callback.length === 1 ? function(error, request) { + callback(error == null ? request : null); + } : callback; + } + function d3_xhrHasResponse(request) { + var type = request.responseType; + return type && type !== "text" ? request.response : request.responseText; + } + d3.dsv = function(delimiter, mimeType) { + var reFormat = new RegExp('["' + delimiter + "\n]"), delimiterCode = delimiter.charCodeAt(0); + function dsv(url, row, callback) { + if (arguments.length < 3) callback = row, row = null; + var xhr = d3_xhr(url, mimeType, row == null ? response : typedResponse(row), callback); + xhr.row = function(_) { + return arguments.length ? xhr.response((row = _) == null ? response : typedResponse(_)) : row; + }; + return xhr; + } + function response(request) { + return dsv.parse(request.responseText); + } + function typedResponse(f) { + return function(request) { + return dsv.parse(request.responseText, f); + }; + } + dsv.parse = function(text, f) { + var o; + return dsv.parseRows(text, function(row, i) { + if (o) return o(row, i - 1); + var a = function(d) { + var obj = {}; + var len = row.length; + for (var k = 0; k < len; ++k) { + obj[row[k]] = d[k]; + } + return obj; + }; + o = f ? function(row, i) { + return f(a(row), i); + } : a; + }); + }; + dsv.parseRows = function(text, f) { + var EOL = {}, EOF = {}, rows = [], N = text.length, I = 0, n = 0, t, eol; + function token() { + if (I >= N) return EOF; + if (eol) return eol = false, EOL; + var j = I; + if (text.charCodeAt(j) === 34) { + var i = j; + while (i++ < N) { + if (text.charCodeAt(i) === 34) { + if (text.charCodeAt(i + 1) !== 34) break; + ++i; + } + } + I = i + 2; + var c = text.charCodeAt(i + 1); + if (c === 13) { + eol = true; + if (text.charCodeAt(i + 2) === 10) ++I; + } else if (c === 10) { + eol = true; + } + return text.slice(j + 1, i).replace(/""/g, '"'); + } + while (I < N) { + var c = text.charCodeAt(I++), k = 1; + if (c === 10) eol = true; else if (c === 13) { + eol = true; + if (text.charCodeAt(I) === 10) ++I, ++k; + } else if (c !== delimiterCode) continue; + return text.slice(j, I - k); + } + return text.slice(j); + } + while ((t = token()) !== EOF) { + var a = []; + while (t !== EOL && t !== EOF) { + a.push(t); + t = token(); + } + if (f && (a = f(a, n++)) == null) continue; + rows.push(a); + } + return rows; + }; + dsv.format = function(rows) { + if (Array.isArray(rows[0])) return dsv.formatRows(rows); + var fieldSet = new d3_Set(), fields = []; + rows.forEach(function(row) { + for (var field in row) { + if (!fieldSet.has(field)) { + fields.push(fieldSet.add(field)); + } + } + }); + return [ fields.map(formatValue).join(delimiter) ].concat(rows.map(function(row) { + return fields.map(function(field) { + return formatValue(row[field]); + }).join(delimiter); + })).join("\n"); + }; + dsv.formatRows = function(rows) { + return rows.map(formatRow).join("\n"); + }; + function formatRow(row) { + return row.map(formatValue).join(delimiter); + } + function formatValue(text) { + return reFormat.test(text) ? '"' + text.replace(/\"/g, '""') + '"' : text; + } + return dsv; + }; + d3.csv = d3.dsv(",", "text/csv"); + d3.tsv = d3.dsv(" ", "text/tab-separated-values"); + var d3_timer_queueHead, d3_timer_queueTail, d3_timer_interval, d3_timer_timeout, d3_timer_frame = this[d3_vendorSymbol(this, "requestAnimationFrame")] || function(callback) { + setTimeout(callback, 17); + }; + d3.timer = function() { + d3_timer.apply(this, arguments); + }; + function d3_timer(callback, delay, then) { + var n = arguments.length; + if (n < 2) delay = 0; + if (n < 3) then = Date.now(); + var time = then + delay, timer = { + c: callback, + t: time, + n: null + }; + if (d3_timer_queueTail) d3_timer_queueTail.n = timer; else d3_timer_queueHead = timer; + d3_timer_queueTail = timer; + if (!d3_timer_interval) { + d3_timer_timeout = clearTimeout(d3_timer_timeout); + d3_timer_interval = 1; + d3_timer_frame(d3_timer_step); + } + return timer; + } + function d3_timer_step() { + var now = d3_timer_mark(), delay = d3_timer_sweep() - now; + if (delay > 24) { + if (isFinite(delay)) { + clearTimeout(d3_timer_timeout); + d3_timer_timeout = setTimeout(d3_timer_step, delay); + } + d3_timer_interval = 0; + } else { + d3_timer_interval = 1; + d3_timer_frame(d3_timer_step); + } + } + d3.timer.flush = function() { + d3_timer_mark(); + d3_timer_sweep(); + }; + function d3_timer_mark() { + var now = Date.now(), timer = d3_timer_queueHead; + while (timer) { + if (now >= timer.t && timer.c(now - timer.t)) timer.c = null; + timer = timer.n; + } + return now; + } + function d3_timer_sweep() { + var t0, t1 = d3_timer_queueHead, time = Infinity; + while (t1) { + if (t1.c) { + if (t1.t < time) time = t1.t; + t1 = (t0 = t1).n; + } else { + t1 = t0 ? t0.n = t1.n : d3_timer_queueHead = t1.n; + } + } + d3_timer_queueTail = t0; + return time; + } + d3.round = function(x, n) { + return n ? Math.round(x * (n = Math.pow(10, n))) / n : Math.round(x); + }; + d3.geom = {}; + function d3_geom_pointX(d) { + return d[0]; + } + function d3_geom_pointY(d) { + return d[1]; + } + d3.geom.hull = function(vertices) { + var x = d3_geom_pointX, y = d3_geom_pointY; + if (arguments.length) return hull(vertices); + function hull(data) { + if (data.length < 3) return []; + var fx = d3_functor(x), fy = d3_functor(y), i, n = data.length, points = [], flippedPoints = []; + for (i = 0; i < n; i++) { + points.push([ +fx.call(this, data[i], i), +fy.call(this, data[i], i), i ]); + } + points.sort(d3_geom_hullOrder); + for (i = 0; i < n; i++) flippedPoints.push([ points[i][0], -points[i][1] ]); + var upper = d3_geom_hullUpper(points), lower = d3_geom_hullUpper(flippedPoints); + var skipLeft = lower[0] === upper[0], skipRight = lower[lower.length - 1] === upper[upper.length - 1], polygon = []; + for (i = upper.length - 1; i >= 0; --i) polygon.push(data[points[upper[i]][2]]); + for (i = +skipLeft; i < lower.length - skipRight; ++i) polygon.push(data[points[lower[i]][2]]); + return polygon; + } + hull.x = function(_) { + return arguments.length ? (x = _, hull) : x; + }; + hull.y = function(_) { + return arguments.length ? (y = _, hull) : y; + }; + return hull; + }; + function d3_geom_hullUpper(points) { + var n = points.length, hull = [ 0, 1 ], hs = 2; + for (var i = 2; i < n; i++) { + while (hs > 1 && d3_cross2d(points[hull[hs - 2]], points[hull[hs - 1]], points[i]) <= 0) --hs; + hull[hs++] = i; + } + return hull.slice(0, hs); + } + function d3_geom_hullOrder(a, b) { + return a[0] - b[0] || a[1] - b[1]; + } + d3.geom.polygon = function(coordinates) { + d3_subclass(coordinates, d3_geom_polygonPrototype); + return coordinates; + }; + var d3_geom_polygonPrototype = d3.geom.polygon.prototype = []; + d3_geom_polygonPrototype.area = function() { + var i = -1, n = this.length, a, b = this[n - 1], area = 0; + while (++i < n) { + a = b; + b = this[i]; + area += a[1] * b[0] - a[0] * b[1]; + } + return area * .5; + }; + d3_geom_polygonPrototype.centroid = function(k) { + var i = -1, n = this.length, x = 0, y = 0, a, b = this[n - 1], c; + if (!arguments.length) k = -1 / (6 * this.area()); + while (++i < n) { + a = b; + b = this[i]; + c = a[0] * b[1] - b[0] * a[1]; + x += (a[0] + b[0]) * c; + y += (a[1] + b[1]) * c; + } + return [ x * k, y * k ]; + }; + d3_geom_polygonPrototype.clip = function(subject) { + var input, closed = d3_geom_polygonClosed(subject), i = -1, n = this.length - d3_geom_polygonClosed(this), j, m, a = this[n - 1], b, c, d; + while (++i < n) { + input = subject.slice(); + subject.length = 0; + b = this[i]; + c = input[(m = input.length - closed) - 1]; + j = -1; + while (++j < m) { + d = input[j]; + if (d3_geom_polygonInside(d, a, b)) { + if (!d3_geom_polygonInside(c, a, b)) { + subject.push(d3_geom_polygonIntersect(c, d, a, b)); + } + subject.push(d); + } else if (d3_geom_polygonInside(c, a, b)) { + subject.push(d3_geom_polygonIntersect(c, d, a, b)); + } + c = d; + } + if (closed) subject.push(subject[0]); + a = b; + } + return subject; + }; + function d3_geom_polygonInside(p, a, b) { + return (b[0] - a[0]) * (p[1] - a[1]) < (b[1] - a[1]) * (p[0] - a[0]); + } + function d3_geom_polygonIntersect(c, d, a, b) { + var x1 = c[0], x3 = a[0], x21 = d[0] - x1, x43 = b[0] - x3, y1 = c[1], y3 = a[1], y21 = d[1] - y1, y43 = b[1] - y3, ua = (x43 * (y1 - y3) - y43 * (x1 - x3)) / (y43 * x21 - x43 * y21); + return [ x1 + ua * x21, y1 + ua * y21 ]; + } + function d3_geom_polygonClosed(coordinates) { + var a = coordinates[0], b = coordinates[coordinates.length - 1]; + return !(a[0] - b[0] || a[1] - b[1]); + } + var d3_geom_voronoiEdges, d3_geom_voronoiCells, d3_geom_voronoiBeaches, d3_geom_voronoiBeachPool = [], d3_geom_voronoiFirstCircle, d3_geom_voronoiCircles, d3_geom_voronoiCirclePool = []; + function d3_geom_voronoiBeach() { + d3_geom_voronoiRedBlackNode(this); + this.edge = this.site = this.circle = null; + } + function d3_geom_voronoiCreateBeach(site) { + var beach = d3_geom_voronoiBeachPool.pop() || new d3_geom_voronoiBeach(); + beach.site = site; + return beach; + } + function d3_geom_voronoiDetachBeach(beach) { + d3_geom_voronoiDetachCircle(beach); + d3_geom_voronoiBeaches.remove(beach); + d3_geom_voronoiBeachPool.push(beach); + d3_geom_voronoiRedBlackNode(beach); + } + function d3_geom_voronoiRemoveBeach(beach) { + var circle = beach.circle, x = circle.x, y = circle.cy, vertex = { + x: x, + y: y + }, previous = beach.P, next = beach.N, disappearing = [ beach ]; + d3_geom_voronoiDetachBeach(beach); + var lArc = previous; + while (lArc.circle && abs(x - lArc.circle.x) < ε && abs(y - lArc.circle.cy) < ε) { + previous = lArc.P; + disappearing.unshift(lArc); + d3_geom_voronoiDetachBeach(lArc); + lArc = previous; + } + disappearing.unshift(lArc); + d3_geom_voronoiDetachCircle(lArc); + var rArc = next; + while (rArc.circle && abs(x - rArc.circle.x) < ε && abs(y - rArc.circle.cy) < ε) { + next = rArc.N; + disappearing.push(rArc); + d3_geom_voronoiDetachBeach(rArc); + rArc = next; + } + disappearing.push(rArc); + d3_geom_voronoiDetachCircle(rArc); + var nArcs = disappearing.length, iArc; + for (iArc = 1; iArc < nArcs; ++iArc) { + rArc = disappearing[iArc]; + lArc = disappearing[iArc - 1]; + d3_geom_voronoiSetEdgeEnd(rArc.edge, lArc.site, rArc.site, vertex); + } + lArc = disappearing[0]; + rArc = disappearing[nArcs - 1]; + rArc.edge = d3_geom_voronoiCreateEdge(lArc.site, rArc.site, null, vertex); + d3_geom_voronoiAttachCircle(lArc); + d3_geom_voronoiAttachCircle(rArc); + } + function d3_geom_voronoiAddBeach(site) { + var x = site.x, directrix = site.y, lArc, rArc, dxl, dxr, node = d3_geom_voronoiBeaches._; + while (node) { + dxl = d3_geom_voronoiLeftBreakPoint(node, directrix) - x; + if (dxl > ε) node = node.L; else { + dxr = x - d3_geom_voronoiRightBreakPoint(node, directrix); + if (dxr > ε) { + if (!node.R) { + lArc = node; + break; + } + node = node.R; + } else { + if (dxl > -ε) { + lArc = node.P; + rArc = node; + } else if (dxr > -ε) { + lArc = node; + rArc = node.N; + } else { + lArc = rArc = node; + } + break; + } + } + } + var newArc = d3_geom_voronoiCreateBeach(site); + d3_geom_voronoiBeaches.insert(lArc, newArc); + if (!lArc && !rArc) return; + if (lArc === rArc) { + d3_geom_voronoiDetachCircle(lArc); + rArc = d3_geom_voronoiCreateBeach(lArc.site); + d3_geom_voronoiBeaches.insert(newArc, rArc); + newArc.edge = rArc.edge = d3_geom_voronoiCreateEdge(lArc.site, newArc.site); + d3_geom_voronoiAttachCircle(lArc); + d3_geom_voronoiAttachCircle(rArc); + return; + } + if (!rArc) { + newArc.edge = d3_geom_voronoiCreateEdge(lArc.site, newArc.site); + return; + } + d3_geom_voronoiDetachCircle(lArc); + d3_geom_voronoiDetachCircle(rArc); + var lSite = lArc.site, ax = lSite.x, ay = lSite.y, bx = site.x - ax, by = site.y - ay, rSite = rArc.site, cx = rSite.x - ax, cy = rSite.y - ay, d = 2 * (bx * cy - by * cx), hb = bx * bx + by * by, hc = cx * cx + cy * cy, vertex = { + x: (cy * hb - by * hc) / d + ax, + y: (bx * hc - cx * hb) / d + ay + }; + d3_geom_voronoiSetEdgeEnd(rArc.edge, lSite, rSite, vertex); + newArc.edge = d3_geom_voronoiCreateEdge(lSite, site, null, vertex); + rArc.edge = d3_geom_voronoiCreateEdge(site, rSite, null, vertex); + d3_geom_voronoiAttachCircle(lArc); + d3_geom_voronoiAttachCircle(rArc); + } + function d3_geom_voronoiLeftBreakPoint(arc, directrix) { + var site = arc.site, rfocx = site.x, rfocy = site.y, pby2 = rfocy - directrix; + if (!pby2) return rfocx; + var lArc = arc.P; + if (!lArc) return -Infinity; + site = lArc.site; + var lfocx = site.x, lfocy = site.y, plby2 = lfocy - directrix; + if (!plby2) return lfocx; + var hl = lfocx - rfocx, aby2 = 1 / pby2 - 1 / plby2, b = hl / plby2; + if (aby2) return (-b + Math.sqrt(b * b - 2 * aby2 * (hl * hl / (-2 * plby2) - lfocy + plby2 / 2 + rfocy - pby2 / 2))) / aby2 + rfocx; + return (rfocx + lfocx) / 2; + } + function d3_geom_voronoiRightBreakPoint(arc, directrix) { + var rArc = arc.N; + if (rArc) return d3_geom_voronoiLeftBreakPoint(rArc, directrix); + var site = arc.site; + return site.y === directrix ? site.x : Infinity; + } + function d3_geom_voronoiCell(site) { + this.site = site; + this.edges = []; + } + d3_geom_voronoiCell.prototype.prepare = function() { + var halfEdges = this.edges, iHalfEdge = halfEdges.length, edge; + while (iHalfEdge--) { + edge = halfEdges[iHalfEdge].edge; + if (!edge.b || !edge.a) halfEdges.splice(iHalfEdge, 1); + } + halfEdges.sort(d3_geom_voronoiHalfEdgeOrder); + return halfEdges.length; + }; + function d3_geom_voronoiCloseCells(extent) { + var x0 = extent[0][0], x1 = extent[1][0], y0 = extent[0][1], y1 = extent[1][1], x2, y2, x3, y3, cells = d3_geom_voronoiCells, iCell = cells.length, cell, iHalfEdge, halfEdges, nHalfEdges, start, end; + while (iCell--) { + cell = cells[iCell]; + if (!cell || !cell.prepare()) continue; + halfEdges = cell.edges; + nHalfEdges = halfEdges.length; + iHalfEdge = 0; + while (iHalfEdge < nHalfEdges) { + end = halfEdges[iHalfEdge].end(), x3 = end.x, y3 = end.y; + start = halfEdges[++iHalfEdge % nHalfEdges].start(), x2 = start.x, y2 = start.y; + if (abs(x3 - x2) > ε || abs(y3 - y2) > ε) { + halfEdges.splice(iHalfEdge, 0, new d3_geom_voronoiHalfEdge(d3_geom_voronoiCreateBorderEdge(cell.site, end, abs(x3 - x0) < ε && y1 - y3 > ε ? { + x: x0, + y: abs(x2 - x0) < ε ? y2 : y1 + } : abs(y3 - y1) < ε && x1 - x3 > ε ? { + x: abs(y2 - y1) < ε ? x2 : x1, + y: y1 + } : abs(x3 - x1) < ε && y3 - y0 > ε ? { + x: x1, + y: abs(x2 - x1) < ε ? y2 : y0 + } : abs(y3 - y0) < ε && x3 - x0 > ε ? { + x: abs(y2 - y0) < ε ? x2 : x0, + y: y0 + } : null), cell.site, null)); + ++nHalfEdges; + } + } + } + } + function d3_geom_voronoiHalfEdgeOrder(a, b) { + return b.angle - a.angle; + } + function d3_geom_voronoiCircle() { + d3_geom_voronoiRedBlackNode(this); + this.x = this.y = this.arc = this.site = this.cy = null; + } + function d3_geom_voronoiAttachCircle(arc) { + var lArc = arc.P, rArc = arc.N; + if (!lArc || !rArc) return; + var lSite = lArc.site, cSite = arc.site, rSite = rArc.site; + if (lSite === rSite) return; + var bx = cSite.x, by = cSite.y, ax = lSite.x - bx, ay = lSite.y - by, cx = rSite.x - bx, cy = rSite.y - by; + var d = 2 * (ax * cy - ay * cx); + if (d >= -ε2) return; + var ha = ax * ax + ay * ay, hc = cx * cx + cy * cy, x = (cy * ha - ay * hc) / d, y = (ax * hc - cx * ha) / d, cy = y + by; + var circle = d3_geom_voronoiCirclePool.pop() || new d3_geom_voronoiCircle(); + circle.arc = arc; + circle.site = cSite; + circle.x = x + bx; + circle.y = cy + Math.sqrt(x * x + y * y); + circle.cy = cy; + arc.circle = circle; + var before = null, node = d3_geom_voronoiCircles._; + while (node) { + if (circle.y < node.y || circle.y === node.y && circle.x <= node.x) { + if (node.L) node = node.L; else { + before = node.P; + break; + } + } else { + if (node.R) node = node.R; else { + before = node; + break; + } + } + } + d3_geom_voronoiCircles.insert(before, circle); + if (!before) d3_geom_voronoiFirstCircle = circle; + } + function d3_geom_voronoiDetachCircle(arc) { + var circle = arc.circle; + if (circle) { + if (!circle.P) d3_geom_voronoiFirstCircle = circle.N; + d3_geom_voronoiCircles.remove(circle); + d3_geom_voronoiCirclePool.push(circle); + d3_geom_voronoiRedBlackNode(circle); + arc.circle = null; + } + } + function d3_geom_clipLine(x0, y0, x1, y1) { + return function(line) { + var a = line.a, b = line.b, ax = a.x, ay = a.y, bx = b.x, by = b.y, t0 = 0, t1 = 1, dx = bx - ax, dy = by - ay, r; + r = x0 - ax; + if (!dx && r > 0) return; + r /= dx; + if (dx < 0) { + if (r < t0) return; + if (r < t1) t1 = r; + } else if (dx > 0) { + if (r > t1) return; + if (r > t0) t0 = r; + } + r = x1 - ax; + if (!dx && r < 0) return; + r /= dx; + if (dx < 0) { + if (r > t1) return; + if (r > t0) t0 = r; + } else if (dx > 0) { + if (r < t0) return; + if (r < t1) t1 = r; + } + r = y0 - ay; + if (!dy && r > 0) return; + r /= dy; + if (dy < 0) { + if (r < t0) return; + if (r < t1) t1 = r; + } else if (dy > 0) { + if (r > t1) return; + if (r > t0) t0 = r; + } + r = y1 - ay; + if (!dy && r < 0) return; + r /= dy; + if (dy < 0) { + if (r > t1) return; + if (r > t0) t0 = r; + } else if (dy > 0) { + if (r < t0) return; + if (r < t1) t1 = r; + } + if (t0 > 0) line.a = { + x: ax + t0 * dx, + y: ay + t0 * dy + }; + if (t1 < 1) line.b = { + x: ax + t1 * dx, + y: ay + t1 * dy + }; + return line; + }; + } + function d3_geom_voronoiClipEdges(extent) { + var edges = d3_geom_voronoiEdges, clip = d3_geom_clipLine(extent[0][0], extent[0][1], extent[1][0], extent[1][1]), i = edges.length, e; + while (i--) { + e = edges[i]; + if (!d3_geom_voronoiConnectEdge(e, extent) || !clip(e) || abs(e.a.x - e.b.x) < ε && abs(e.a.y - e.b.y) < ε) { + e.a = e.b = null; + edges.splice(i, 1); + } + } + } + function d3_geom_voronoiConnectEdge(edge, extent) { + var vb = edge.b; + if (vb) return true; + var va = edge.a, x0 = extent[0][0], x1 = extent[1][0], y0 = extent[0][1], y1 = extent[1][1], lSite = edge.l, rSite = edge.r, lx = lSite.x, ly = lSite.y, rx = rSite.x, ry = rSite.y, fx = (lx + rx) / 2, fy = (ly + ry) / 2, fm, fb; + if (ry === ly) { + if (fx < x0 || fx >= x1) return; + if (lx > rx) { + if (!va) va = { + x: fx, + y: y0 + }; else if (va.y >= y1) return; + vb = { + x: fx, + y: y1 + }; + } else { + if (!va) va = { + x: fx, + y: y1 + }; else if (va.y < y0) return; + vb = { + x: fx, + y: y0 + }; + } + } else { + fm = (lx - rx) / (ry - ly); + fb = fy - fm * fx; + if (fm < -1 || fm > 1) { + if (lx > rx) { + if (!va) va = { + x: (y0 - fb) / fm, + y: y0 + }; else if (va.y >= y1) return; + vb = { + x: (y1 - fb) / fm, + y: y1 + }; + } else { + if (!va) va = { + x: (y1 - fb) / fm, + y: y1 + }; else if (va.y < y0) return; + vb = { + x: (y0 - fb) / fm, + y: y0 + }; + } + } else { + if (ly < ry) { + if (!va) va = { + x: x0, + y: fm * x0 + fb + }; else if (va.x >= x1) return; + vb = { + x: x1, + y: fm * x1 + fb + }; + } else { + if (!va) va = { + x: x1, + y: fm * x1 + fb + }; else if (va.x < x0) return; + vb = { + x: x0, + y: fm * x0 + fb + }; + } + } + } + edge.a = va; + edge.b = vb; + return true; + } + function d3_geom_voronoiEdge(lSite, rSite) { + this.l = lSite; + this.r = rSite; + this.a = this.b = null; + } + function d3_geom_voronoiCreateEdge(lSite, rSite, va, vb) { + var edge = new d3_geom_voronoiEdge(lSite, rSite); + d3_geom_voronoiEdges.push(edge); + if (va) d3_geom_voronoiSetEdgeEnd(edge, lSite, rSite, va); + if (vb) d3_geom_voronoiSetEdgeEnd(edge, rSite, lSite, vb); + d3_geom_voronoiCells[lSite.i].edges.push(new d3_geom_voronoiHalfEdge(edge, lSite, rSite)); + d3_geom_voronoiCells[rSite.i].edges.push(new d3_geom_voronoiHalfEdge(edge, rSite, lSite)); + return edge; + } + function d3_geom_voronoiCreateBorderEdge(lSite, va, vb) { + var edge = new d3_geom_voronoiEdge(lSite, null); + edge.a = va; + edge.b = vb; + d3_geom_voronoiEdges.push(edge); + return edge; + } + function d3_geom_voronoiSetEdgeEnd(edge, lSite, rSite, vertex) { + if (!edge.a && !edge.b) { + edge.a = vertex; + edge.l = lSite; + edge.r = rSite; + } else if (edge.l === rSite) { + edge.b = vertex; + } else { + edge.a = vertex; + } + } + function d3_geom_voronoiHalfEdge(edge, lSite, rSite) { + var va = edge.a, vb = edge.b; + this.edge = edge; + this.site = lSite; + this.angle = rSite ? Math.atan2(rSite.y - lSite.y, rSite.x - lSite.x) : edge.l === lSite ? Math.atan2(vb.x - va.x, va.y - vb.y) : Math.atan2(va.x - vb.x, vb.y - va.y); + } + d3_geom_voronoiHalfEdge.prototype = { + start: function() { + return this.edge.l === this.site ? this.edge.a : this.edge.b; + }, + end: function() { + return this.edge.l === this.site ? this.edge.b : this.edge.a; + } + }; + function d3_geom_voronoiRedBlackTree() { + this._ = null; + } + function d3_geom_voronoiRedBlackNode(node) { + node.U = node.C = node.L = node.R = node.P = node.N = null; + } + d3_geom_voronoiRedBlackTree.prototype = { + insert: function(after, node) { + var parent, grandpa, uncle; + if (after) { + node.P = after; + node.N = after.N; + if (after.N) after.N.P = node; + after.N = node; + if (after.R) { + after = after.R; + while (after.L) after = after.L; + after.L = node; + } else { + after.R = node; + } + parent = after; + } else if (this._) { + after = d3_geom_voronoiRedBlackFirst(this._); + node.P = null; + node.N = after; + after.P = after.L = node; + parent = after; + } else { + node.P = node.N = null; + this._ = node; + parent = null; + } + node.L = node.R = null; + node.U = parent; + node.C = true; + after = node; + while (parent && parent.C) { + grandpa = parent.U; + if (parent === grandpa.L) { + uncle = grandpa.R; + if (uncle && uncle.C) { + parent.C = uncle.C = false; + grandpa.C = true; + after = grandpa; + } else { + if (after === parent.R) { + d3_geom_voronoiRedBlackRotateLeft(this, parent); + after = parent; + parent = after.U; + } + parent.C = false; + grandpa.C = true; + d3_geom_voronoiRedBlackRotateRight(this, grandpa); + } + } else { + uncle = grandpa.L; + if (uncle && uncle.C) { + parent.C = uncle.C = false; + grandpa.C = true; + after = grandpa; + } else { + if (after === parent.L) { + d3_geom_voronoiRedBlackRotateRight(this, parent); + after = parent; + parent = after.U; + } + parent.C = false; + grandpa.C = true; + d3_geom_voronoiRedBlackRotateLeft(this, grandpa); + } + } + parent = after.U; + } + this._.C = false; + }, + remove: function(node) { + if (node.N) node.N.P = node.P; + if (node.P) node.P.N = node.N; + node.N = node.P = null; + var parent = node.U, sibling, left = node.L, right = node.R, next, red; + if (!left) next = right; else if (!right) next = left; else next = d3_geom_voronoiRedBlackFirst(right); + if (parent) { + if (parent.L === node) parent.L = next; else parent.R = next; + } else { + this._ = next; + } + if (left && right) { + red = next.C; + next.C = node.C; + next.L = left; + left.U = next; + if (next !== right) { + parent = next.U; + next.U = node.U; + node = next.R; + parent.L = node; + next.R = right; + right.U = next; + } else { + next.U = parent; + parent = next; + node = next.R; + } + } else { + red = node.C; + node = next; + } + if (node) node.U = parent; + if (red) return; + if (node && node.C) { + node.C = false; + return; + } + do { + if (node === this._) break; + if (node === parent.L) { + sibling = parent.R; + if (sibling.C) { + sibling.C = false; + parent.C = true; + d3_geom_voronoiRedBlackRotateLeft(this, parent); + sibling = parent.R; + } + if (sibling.L && sibling.L.C || sibling.R && sibling.R.C) { + if (!sibling.R || !sibling.R.C) { + sibling.L.C = false; + sibling.C = true; + d3_geom_voronoiRedBlackRotateRight(this, sibling); + sibling = parent.R; + } + sibling.C = parent.C; + parent.C = sibling.R.C = false; + d3_geom_voronoiRedBlackRotateLeft(this, parent); + node = this._; + break; + } + } else { + sibling = parent.L; + if (sibling.C) { + sibling.C = false; + parent.C = true; + d3_geom_voronoiRedBlackRotateRight(this, parent); + sibling = parent.L; + } + if (sibling.L && sibling.L.C || sibling.R && sibling.R.C) { + if (!sibling.L || !sibling.L.C) { + sibling.R.C = false; + sibling.C = true; + d3_geom_voronoiRedBlackRotateLeft(this, sibling); + sibling = parent.L; + } + sibling.C = parent.C; + parent.C = sibling.L.C = false; + d3_geom_voronoiRedBlackRotateRight(this, parent); + node = this._; + break; + } + } + sibling.C = true; + node = parent; + parent = parent.U; + } while (!node.C); + if (node) node.C = false; + } + }; + function d3_geom_voronoiRedBlackRotateLeft(tree, node) { + var p = node, q = node.R, parent = p.U; + if (parent) { + if (parent.L === p) parent.L = q; else parent.R = q; + } else { + tree._ = q; + } + q.U = parent; + p.U = q; + p.R = q.L; + if (p.R) p.R.U = p; + q.L = p; + } + function d3_geom_voronoiRedBlackRotateRight(tree, node) { + var p = node, q = node.L, parent = p.U; + if (parent) { + if (parent.L === p) parent.L = q; else parent.R = q; + } else { + tree._ = q; + } + q.U = parent; + p.U = q; + p.L = q.R; + if (p.L) p.L.U = p; + q.R = p; + } + function d3_geom_voronoiRedBlackFirst(node) { + while (node.L) node = node.L; + return node; + } + function d3_geom_voronoi(sites, bbox) { + var site = sites.sort(d3_geom_voronoiVertexOrder).pop(), x0, y0, circle; + d3_geom_voronoiEdges = []; + d3_geom_voronoiCells = new Array(sites.length); + d3_geom_voronoiBeaches = new d3_geom_voronoiRedBlackTree(); + d3_geom_voronoiCircles = new d3_geom_voronoiRedBlackTree(); + while (true) { + circle = d3_geom_voronoiFirstCircle; + if (site && (!circle || site.y < circle.y || site.y === circle.y && site.x < circle.x)) { + if (site.x !== x0 || site.y !== y0) { + d3_geom_voronoiCells[site.i] = new d3_geom_voronoiCell(site); + d3_geom_voronoiAddBeach(site); + x0 = site.x, y0 = site.y; + } + site = sites.pop(); + } else if (circle) { + d3_geom_voronoiRemoveBeach(circle.arc); + } else { + break; + } + } + if (bbox) d3_geom_voronoiClipEdges(bbox), d3_geom_voronoiCloseCells(bbox); + var diagram = { + cells: d3_geom_voronoiCells, + edges: d3_geom_voronoiEdges + }; + d3_geom_voronoiBeaches = d3_geom_voronoiCircles = d3_geom_voronoiEdges = d3_geom_voronoiCells = null; + return diagram; + } + function d3_geom_voronoiVertexOrder(a, b) { + return b.y - a.y || b.x - a.x; + } + d3.geom.voronoi = function(points) { + var x = d3_geom_pointX, y = d3_geom_pointY, fx = x, fy = y, clipExtent = d3_geom_voronoiClipExtent; + if (points) return voronoi(points); + function voronoi(data) { + var polygons = new Array(data.length), x0 = clipExtent[0][0], y0 = clipExtent[0][1], x1 = clipExtent[1][0], y1 = clipExtent[1][1]; + d3_geom_voronoi(sites(data), clipExtent).cells.forEach(function(cell, i) { + var edges = cell.edges, site = cell.site, polygon = polygons[i] = edges.length ? edges.map(function(e) { + var s = e.start(); + return [ s.x, s.y ]; + }) : site.x >= x0 && site.x <= x1 && site.y >= y0 && site.y <= y1 ? [ [ x0, y1 ], [ x1, y1 ], [ x1, y0 ], [ x0, y0 ] ] : []; + polygon.point = data[i]; + }); + return polygons; + } + function sites(data) { + return data.map(function(d, i) { + return { + x: Math.round(fx(d, i) / ε) * ε, + y: Math.round(fy(d, i) / ε) * ε, + i: i + }; + }); + } + voronoi.links = function(data) { + return d3_geom_voronoi(sites(data)).edges.filter(function(edge) { + return edge.l && edge.r; + }).map(function(edge) { + return { + source: data[edge.l.i], + target: data[edge.r.i] + }; + }); + }; + voronoi.triangles = function(data) { + var triangles = []; + d3_geom_voronoi(sites(data)).cells.forEach(function(cell, i) { + var site = cell.site, edges = cell.edges.sort(d3_geom_voronoiHalfEdgeOrder), j = -1, m = edges.length, e0, s0, e1 = edges[m - 1].edge, s1 = e1.l === site ? e1.r : e1.l; + while (++j < m) { + e0 = e1; + s0 = s1; + e1 = edges[j].edge; + s1 = e1.l === site ? e1.r : e1.l; + if (i < s0.i && i < s1.i && d3_geom_voronoiTriangleArea(site, s0, s1) < 0) { + triangles.push([ data[i], data[s0.i], data[s1.i] ]); + } + } + }); + return triangles; + }; + voronoi.x = function(_) { + return arguments.length ? (fx = d3_functor(x = _), voronoi) : x; + }; + voronoi.y = function(_) { + return arguments.length ? (fy = d3_functor(y = _), voronoi) : y; + }; + voronoi.clipExtent = function(_) { + if (!arguments.length) return clipExtent === d3_geom_voronoiClipExtent ? null : clipExtent; + clipExtent = _ == null ? d3_geom_voronoiClipExtent : _; + return voronoi; + }; + voronoi.size = function(_) { + if (!arguments.length) return clipExtent === d3_geom_voronoiClipExtent ? null : clipExtent && clipExtent[1]; + return voronoi.clipExtent(_ && [ [ 0, 0 ], _ ]); + }; + return voronoi; + }; + var d3_geom_voronoiClipExtent = [ [ -1e6, -1e6 ], [ 1e6, 1e6 ] ]; + function d3_geom_voronoiTriangleArea(a, b, c) { + return (a.x - c.x) * (b.y - a.y) - (a.x - b.x) * (c.y - a.y); + } + d3.geom.delaunay = function(vertices) { + return d3.geom.voronoi().triangles(vertices); + }; + d3.geom.quadtree = function(points, x1, y1, x2, y2) { + var x = d3_geom_pointX, y = d3_geom_pointY, compat; + if (compat = arguments.length) { + x = d3_geom_quadtreeCompatX; + y = d3_geom_quadtreeCompatY; + if (compat === 3) { + y2 = y1; + x2 = x1; + y1 = x1 = 0; + } + return quadtree(points); + } + function quadtree(data) { + var d, fx = d3_functor(x), fy = d3_functor(y), xs, ys, i, n, x1_, y1_, x2_, y2_; + if (x1 != null) { + x1_ = x1, y1_ = y1, x2_ = x2, y2_ = y2; + } else { + x2_ = y2_ = -(x1_ = y1_ = Infinity); + xs = [], ys = []; + n = data.length; + if (compat) for (i = 0; i < n; ++i) { + d = data[i]; + if (d.x < x1_) x1_ = d.x; + if (d.y < y1_) y1_ = d.y; + if (d.x > x2_) x2_ = d.x; + if (d.y > y2_) y2_ = d.y; + xs.push(d.x); + ys.push(d.y); + } else for (i = 0; i < n; ++i) { + var x_ = +fx(d = data[i], i), y_ = +fy(d, i); + if (x_ < x1_) x1_ = x_; + if (y_ < y1_) y1_ = y_; + if (x_ > x2_) x2_ = x_; + if (y_ > y2_) y2_ = y_; + xs.push(x_); + ys.push(y_); + } + } + var dx = x2_ - x1_, dy = y2_ - y1_; + if (dx > dy) y2_ = y1_ + dx; else x2_ = x1_ + dy; + function insert(n, d, x, y, x1, y1, x2, y2) { + if (isNaN(x) || isNaN(y)) return; + if (n.leaf) { + var nx = n.x, ny = n.y; + if (nx != null) { + if (abs(nx - x) + abs(ny - y) < .01) { + insertChild(n, d, x, y, x1, y1, x2, y2); + } else { + var nPoint = n.point; + n.x = n.y = n.point = null; + insertChild(n, nPoint, nx, ny, x1, y1, x2, y2); + insertChild(n, d, x, y, x1, y1, x2, y2); + } + } else { + n.x = x, n.y = y, n.point = d; + } + } else { + insertChild(n, d, x, y, x1, y1, x2, y2); + } + } + function insertChild(n, d, x, y, x1, y1, x2, y2) { + var xm = (x1 + x2) * .5, ym = (y1 + y2) * .5, right = x >= xm, below = y >= ym, i = below << 1 | right; + n.leaf = false; + n = n.nodes[i] || (n.nodes[i] = d3_geom_quadtreeNode()); + if (right) x1 = xm; else x2 = xm; + if (below) y1 = ym; else y2 = ym; + insert(n, d, x, y, x1, y1, x2, y2); + } + var root = d3_geom_quadtreeNode(); + root.add = function(d) { + insert(root, d, +fx(d, ++i), +fy(d, i), x1_, y1_, x2_, y2_); + }; + root.visit = function(f) { + d3_geom_quadtreeVisit(f, root, x1_, y1_, x2_, y2_); + }; + root.find = function(point) { + return d3_geom_quadtreeFind(root, point[0], point[1], x1_, y1_, x2_, y2_); + }; + i = -1; + if (x1 == null) { + while (++i < n) { + insert(root, data[i], xs[i], ys[i], x1_, y1_, x2_, y2_); + } + --i; + } else data.forEach(root.add); + xs = ys = data = d = null; + return root; + } + quadtree.x = function(_) { + return arguments.length ? (x = _, quadtree) : x; + }; + quadtree.y = function(_) { + return arguments.length ? (y = _, quadtree) : y; + }; + quadtree.extent = function(_) { + if (!arguments.length) return x1 == null ? null : [ [ x1, y1 ], [ x2, y2 ] ]; + if (_ == null) x1 = y1 = x2 = y2 = null; else x1 = +_[0][0], y1 = +_[0][1], x2 = +_[1][0], + y2 = +_[1][1]; + return quadtree; + }; + quadtree.size = function(_) { + if (!arguments.length) return x1 == null ? null : [ x2 - x1, y2 - y1 ]; + if (_ == null) x1 = y1 = x2 = y2 = null; else x1 = y1 = 0, x2 = +_[0], y2 = +_[1]; + return quadtree; + }; + return quadtree; + }; + function d3_geom_quadtreeCompatX(d) { + return d.x; + } + function d3_geom_quadtreeCompatY(d) { + return d.y; + } + function d3_geom_quadtreeNode() { + return { + leaf: true, + nodes: [], + point: null, + x: null, + y: null + }; + } + function d3_geom_quadtreeVisit(f, node, x1, y1, x2, y2) { + if (!f(node, x1, y1, x2, y2)) { + var sx = (x1 + x2) * .5, sy = (y1 + y2) * .5, children = node.nodes; + if (children[0]) d3_geom_quadtreeVisit(f, children[0], x1, y1, sx, sy); + if (children[1]) d3_geom_quadtreeVisit(f, children[1], sx, y1, x2, sy); + if (children[2]) d3_geom_quadtreeVisit(f, children[2], x1, sy, sx, y2); + if (children[3]) d3_geom_quadtreeVisit(f, children[3], sx, sy, x2, y2); + } + } + function d3_geom_quadtreeFind(root, x, y, x0, y0, x3, y3) { + var minDistance2 = Infinity, closestPoint; + (function find(node, x1, y1, x2, y2) { + if (x1 > x3 || y1 > y3 || x2 < x0 || y2 < y0) return; + if (point = node.point) { + var point, dx = x - node.x, dy = y - node.y, distance2 = dx * dx + dy * dy; + if (distance2 < minDistance2) { + var distance = Math.sqrt(minDistance2 = distance2); + x0 = x - distance, y0 = y - distance; + x3 = x + distance, y3 = y + distance; + closestPoint = point; + } + } + var children = node.nodes, xm = (x1 + x2) * .5, ym = (y1 + y2) * .5, right = x >= xm, below = y >= ym; + for (var i = below << 1 | right, j = i + 4; i < j; ++i) { + if (node = children[i & 3]) switch (i & 3) { + case 0: + find(node, x1, y1, xm, ym); + break; + + case 1: + find(node, xm, y1, x2, ym); + break; + + case 2: + find(node, x1, ym, xm, y2); + break; + + case 3: + find(node, xm, ym, x2, y2); + break; + } + } + })(root, x0, y0, x3, y3); + return closestPoint; + } + d3.interpolateRgb = d3_interpolateRgb; + function d3_interpolateRgb(a, b) { + a = d3.rgb(a); + b = d3.rgb(b); + var ar = a.r, ag = a.g, ab = a.b, br = b.r - ar, bg = b.g - ag, bb = b.b - ab; + return function(t) { + return "#" + d3_rgb_hex(Math.round(ar + br * t)) + d3_rgb_hex(Math.round(ag + bg * t)) + d3_rgb_hex(Math.round(ab + bb * t)); + }; + } + d3.interpolateObject = d3_interpolateObject; + function d3_interpolateObject(a, b) { + var i = {}, c = {}, k; + for (k in a) { + if (k in b) { + i[k] = d3_interpolate(a[k], b[k]); + } else { + c[k] = a[k]; + } + } + for (k in b) { + if (!(k in a)) { + c[k] = b[k]; + } + } + return function(t) { + for (k in i) c[k] = i[k](t); + return c; + }; + } + d3.interpolateNumber = d3_interpolateNumber; + function d3_interpolateNumber(a, b) { + a = +a, b = +b; + return function(t) { + return a * (1 - t) + b * t; + }; + } + d3.interpolateString = d3_interpolateString; + function d3_interpolateString(a, b) { + var bi = d3_interpolate_numberA.lastIndex = d3_interpolate_numberB.lastIndex = 0, am, bm, bs, i = -1, s = [], q = []; + a = a + "", b = b + ""; + while ((am = d3_interpolate_numberA.exec(a)) && (bm = d3_interpolate_numberB.exec(b))) { + if ((bs = bm.index) > bi) { + bs = b.slice(bi, bs); + if (s[i]) s[i] += bs; else s[++i] = bs; + } + if ((am = am[0]) === (bm = bm[0])) { + if (s[i]) s[i] += bm; else s[++i] = bm; + } else { + s[++i] = null; + q.push({ + i: i, + x: d3_interpolateNumber(am, bm) + }); + } + bi = d3_interpolate_numberB.lastIndex; + } + if (bi < b.length) { + bs = b.slice(bi); + if (s[i]) s[i] += bs; else s[++i] = bs; + } + return s.length < 2 ? q[0] ? (b = q[0].x, function(t) { + return b(t) + ""; + }) : function() { + return b; + } : (b = q.length, function(t) { + for (var i = 0, o; i < b; ++i) s[(o = q[i]).i] = o.x(t); + return s.join(""); + }); + } + var d3_interpolate_numberA = /[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g, d3_interpolate_numberB = new RegExp(d3_interpolate_numberA.source, "g"); + d3.interpolate = d3_interpolate; + function d3_interpolate(a, b) { + var i = d3.interpolators.length, f; + while (--i >= 0 && !(f = d3.interpolators[i](a, b))) ; + return f; + } + d3.interpolators = [ function(a, b) { + var t = typeof b; + return (t === "string" ? d3_rgb_names.has(b.toLowerCase()) || /^(#|rgb\(|hsl\()/i.test(b) ? d3_interpolateRgb : d3_interpolateString : b instanceof d3_color ? d3_interpolateRgb : Array.isArray(b) ? d3_interpolateArray : t === "object" && isNaN(b) ? d3_interpolateObject : d3_interpolateNumber)(a, b); + } ]; + d3.interpolateArray = d3_interpolateArray; + function d3_interpolateArray(a, b) { + var x = [], c = [], na = a.length, nb = b.length, n0 = Math.min(a.length, b.length), i; + for (i = 0; i < n0; ++i) x.push(d3_interpolate(a[i], b[i])); + for (;i < na; ++i) c[i] = a[i]; + for (;i < nb; ++i) c[i] = b[i]; + return function(t) { + for (i = 0; i < n0; ++i) c[i] = x[i](t); + return c; + }; + } + var d3_ease_default = function() { + return d3_identity; + }; + var d3_ease = d3.map({ + linear: d3_ease_default, + poly: d3_ease_poly, + quad: function() { + return d3_ease_quad; + }, + cubic: function() { + return d3_ease_cubic; + }, + sin: function() { + return d3_ease_sin; + }, + exp: function() { + return d3_ease_exp; + }, + circle: function() { + return d3_ease_circle; + }, + elastic: d3_ease_elastic, + back: d3_ease_back, + bounce: function() { + return d3_ease_bounce; + } + }); + var d3_ease_mode = d3.map({ + "in": d3_identity, + out: d3_ease_reverse, + "in-out": d3_ease_reflect, + "out-in": function(f) { + return d3_ease_reflect(d3_ease_reverse(f)); + } + }); + d3.ease = function(name) { + var i = name.indexOf("-"), t = i >= 0 ? name.slice(0, i) : name, m = i >= 0 ? name.slice(i + 1) : "in"; + t = d3_ease.get(t) || d3_ease_default; + m = d3_ease_mode.get(m) || d3_identity; + return d3_ease_clamp(m(t.apply(null, d3_arraySlice.call(arguments, 1)))); + }; + function d3_ease_clamp(f) { + return function(t) { + return t <= 0 ? 0 : t >= 1 ? 1 : f(t); + }; + } + function d3_ease_reverse(f) { + return function(t) { + return 1 - f(1 - t); + }; + } + function d3_ease_reflect(f) { + return function(t) { + return .5 * (t < .5 ? f(2 * t) : 2 - f(2 - 2 * t)); + }; + } + function d3_ease_quad(t) { + return t * t; + } + function d3_ease_cubic(t) { + return t * t * t; + } + function d3_ease_cubicInOut(t) { + if (t <= 0) return 0; + if (t >= 1) return 1; + var t2 = t * t, t3 = t2 * t; + return 4 * (t < .5 ? t3 : 3 * (t - t2) + t3 - .75); + } + function d3_ease_poly(e) { + return function(t) { + return Math.pow(t, e); + }; + } + function d3_ease_sin(t) { + return 1 - Math.cos(t * halfπ); + } + function d3_ease_exp(t) { + return Math.pow(2, 10 * (t - 1)); + } + function d3_ease_circle(t) { + return 1 - Math.sqrt(1 - t * t); + } + function d3_ease_elastic(a, p) { + var s; + if (arguments.length < 2) p = .45; + if (arguments.length) s = p / τ * Math.asin(1 / a); else a = 1, s = p / 4; + return function(t) { + return 1 + a * Math.pow(2, -10 * t) * Math.sin((t - s) * τ / p); + }; + } + function d3_ease_back(s) { + if (!s) s = 1.70158; + return function(t) { + return t * t * ((s + 1) * t - s); + }; + } + function d3_ease_bounce(t) { + return t < 1 / 2.75 ? 7.5625 * t * t : t < 2 / 2.75 ? 7.5625 * (t -= 1.5 / 2.75) * t + .75 : t < 2.5 / 2.75 ? 7.5625 * (t -= 2.25 / 2.75) * t + .9375 : 7.5625 * (t -= 2.625 / 2.75) * t + .984375; + } + d3.interpolateHcl = d3_interpolateHcl; + function d3_interpolateHcl(a, b) { + a = d3.hcl(a); + b = d3.hcl(b); + var ah = a.h, ac = a.c, al = a.l, bh = b.h - ah, bc = b.c - ac, bl = b.l - al; + if (isNaN(bc)) bc = 0, ac = isNaN(ac) ? b.c : ac; + if (isNaN(bh)) bh = 0, ah = isNaN(ah) ? b.h : ah; else if (bh > 180) bh -= 360; else if (bh < -180) bh += 360; + return function(t) { + return d3_hcl_lab(ah + bh * t, ac + bc * t, al + bl * t) + ""; + }; + } + d3.interpolateHsl = d3_interpolateHsl; + function d3_interpolateHsl(a, b) { + a = d3.hsl(a); + b = d3.hsl(b); + var ah = a.h, as = a.s, al = a.l, bh = b.h - ah, bs = b.s - as, bl = b.l - al; + if (isNaN(bs)) bs = 0, as = isNaN(as) ? b.s : as; + if (isNaN(bh)) bh = 0, ah = isNaN(ah) ? b.h : ah; else if (bh > 180) bh -= 360; else if (bh < -180) bh += 360; + return function(t) { + return d3_hsl_rgb(ah + bh * t, as + bs * t, al + bl * t) + ""; + }; + } + d3.interpolateLab = d3_interpolateLab; + function d3_interpolateLab(a, b) { + a = d3.lab(a); + b = d3.lab(b); + var al = a.l, aa = a.a, ab = a.b, bl = b.l - al, ba = b.a - aa, bb = b.b - ab; + return function(t) { + return d3_lab_rgb(al + bl * t, aa + ba * t, ab + bb * t) + ""; + }; + } + d3.interpolateRound = d3_interpolateRound; + function d3_interpolateRound(a, b) { + b -= a; + return function(t) { + return Math.round(a + b * t); + }; + } + d3.transform = function(string) { + var g = d3_document.createElementNS(d3.ns.prefix.svg, "g"); + return (d3.transform = function(string) { + if (string != null) { + g.setAttribute("transform", string); + var t = g.transform.baseVal.consolidate(); + } + return new d3_transform(t ? t.matrix : d3_transformIdentity); + })(string); + }; + function d3_transform(m) { + var r0 = [ m.a, m.b ], r1 = [ m.c, m.d ], kx = d3_transformNormalize(r0), kz = d3_transformDot(r0, r1), ky = d3_transformNormalize(d3_transformCombine(r1, r0, -kz)) || 0; + if (r0[0] * r1[1] < r1[0] * r0[1]) { + r0[0] *= -1; + r0[1] *= -1; + kx *= -1; + kz *= -1; + } + this.rotate = (kx ? Math.atan2(r0[1], r0[0]) : Math.atan2(-r1[0], r1[1])) * d3_degrees; + this.translate = [ m.e, m.f ]; + this.scale = [ kx, ky ]; + this.skew = ky ? Math.atan2(kz, ky) * d3_degrees : 0; + } + d3_transform.prototype.toString = function() { + return "translate(" + this.translate + ")rotate(" + this.rotate + ")skewX(" + this.skew + ")scale(" + this.scale + ")"; + }; + function d3_transformDot(a, b) { + return a[0] * b[0] + a[1] * b[1]; + } + function d3_transformNormalize(a) { + var k = Math.sqrt(d3_transformDot(a, a)); + if (k) { + a[0] /= k; + a[1] /= k; + } + return k; + } + function d3_transformCombine(a, b, k) { + a[0] += k * b[0]; + a[1] += k * b[1]; + return a; + } + var d3_transformIdentity = { + a: 1, + b: 0, + c: 0, + d: 1, + e: 0, + f: 0 + }; + d3.interpolateTransform = d3_interpolateTransform; + function d3_interpolateTransformPop(s) { + return s.length ? s.pop() + "," : ""; + } + function d3_interpolateTranslate(ta, tb, s, q) { + if (ta[0] !== tb[0] || ta[1] !== tb[1]) { + var i = s.push("translate(", null, ",", null, ")"); + q.push({ + i: i - 4, + x: d3_interpolateNumber(ta[0], tb[0]) + }, { + i: i - 2, + x: d3_interpolateNumber(ta[1], tb[1]) + }); + } else if (tb[0] || tb[1]) { + s.push("translate(" + tb + ")"); + } + } + function d3_interpolateRotate(ra, rb, s, q) { + if (ra !== rb) { + if (ra - rb > 180) rb += 360; else if (rb - ra > 180) ra += 360; + q.push({ + i: s.push(d3_interpolateTransformPop(s) + "rotate(", null, ")") - 2, + x: d3_interpolateNumber(ra, rb) + }); + } else if (rb) { + s.push(d3_interpolateTransformPop(s) + "rotate(" + rb + ")"); + } + } + function d3_interpolateSkew(wa, wb, s, q) { + if (wa !== wb) { + q.push({ + i: s.push(d3_interpolateTransformPop(s) + "skewX(", null, ")") - 2, + x: d3_interpolateNumber(wa, wb) + }); + } else if (wb) { + s.push(d3_interpolateTransformPop(s) + "skewX(" + wb + ")"); + } + } + function d3_interpolateScale(ka, kb, s, q) { + if (ka[0] !== kb[0] || ka[1] !== kb[1]) { + var i = s.push(d3_interpolateTransformPop(s) + "scale(", null, ",", null, ")"); + q.push({ + i: i - 4, + x: d3_interpolateNumber(ka[0], kb[0]) + }, { + i: i - 2, + x: d3_interpolateNumber(ka[1], kb[1]) + }); + } else if (kb[0] !== 1 || kb[1] !== 1) { + s.push(d3_interpolateTransformPop(s) + "scale(" + kb + ")"); + } + } + function d3_interpolateTransform(a, b) { + var s = [], q = []; + a = d3.transform(a), b = d3.transform(b); + d3_interpolateTranslate(a.translate, b.translate, s, q); + d3_interpolateRotate(a.rotate, b.rotate, s, q); + d3_interpolateSkew(a.skew, b.skew, s, q); + d3_interpolateScale(a.scale, b.scale, s, q); + a = b = null; + return function(t) { + var i = -1, n = q.length, o; + while (++i < n) s[(o = q[i]).i] = o.x(t); + return s.join(""); + }; + } + function d3_uninterpolateNumber(a, b) { + b = (b -= a = +a) || 1 / b; + return function(x) { + return (x - a) / b; + }; + } + function d3_uninterpolateClamp(a, b) { + b = (b -= a = +a) || 1 / b; + return function(x) { + return Math.max(0, Math.min(1, (x - a) / b)); + }; + } + d3.layout = {}; + d3.layout.bundle = function() { + return function(links) { + var paths = [], i = -1, n = links.length; + while (++i < n) paths.push(d3_layout_bundlePath(links[i])); + return paths; + }; + }; + function d3_layout_bundlePath(link) { + var start = link.source, end = link.target, lca = d3_layout_bundleLeastCommonAncestor(start, end), points = [ start ]; + while (start !== lca) { + start = start.parent; + points.push(start); + } + var k = points.length; + while (end !== lca) { + points.splice(k, 0, end); + end = end.parent; + } + return points; + } + function d3_layout_bundleAncestors(node) { + var ancestors = [], parent = node.parent; + while (parent != null) { + ancestors.push(node); + node = parent; + parent = parent.parent; + } + ancestors.push(node); + return ancestors; + } + function d3_layout_bundleLeastCommonAncestor(a, b) { + if (a === b) return a; + var aNodes = d3_layout_bundleAncestors(a), bNodes = d3_layout_bundleAncestors(b), aNode = aNodes.pop(), bNode = bNodes.pop(), sharedNode = null; + while (aNode === bNode) { + sharedNode = aNode; + aNode = aNodes.pop(); + bNode = bNodes.pop(); + } + return sharedNode; + } + d3.layout.chord = function() { + var chord = {}, chords, groups, matrix, n, padding = 0, sortGroups, sortSubgroups, sortChords; + function relayout() { + var subgroups = {}, groupSums = [], groupIndex = d3.range(n), subgroupIndex = [], k, x, x0, i, j; + chords = []; + groups = []; + k = 0, i = -1; + while (++i < n) { + x = 0, j = -1; + while (++j < n) { + x += matrix[i][j]; + } + groupSums.push(x); + subgroupIndex.push(d3.range(n)); + k += x; + } + if (sortGroups) { + groupIndex.sort(function(a, b) { + return sortGroups(groupSums[a], groupSums[b]); + }); + } + if (sortSubgroups) { + subgroupIndex.forEach(function(d, i) { + d.sort(function(a, b) { + return sortSubgroups(matrix[i][a], matrix[i][b]); + }); + }); + } + k = (τ - padding * n) / k; + x = 0, i = -1; + while (++i < n) { + x0 = x, j = -1; + while (++j < n) { + var di = groupIndex[i], dj = subgroupIndex[di][j], v = matrix[di][dj], a0 = x, a1 = x += v * k; + subgroups[di + "-" + dj] = { + index: di, + subindex: dj, + startAngle: a0, + endAngle: a1, + value: v + }; + } + groups[di] = { + index: di, + startAngle: x0, + endAngle: x, + value: groupSums[di] + }; + x += padding; + } + i = -1; + while (++i < n) { + j = i - 1; + while (++j < n) { + var source = subgroups[i + "-" + j], target = subgroups[j + "-" + i]; + if (source.value || target.value) { + chords.push(source.value < target.value ? { + source: target, + target: source + } : { + source: source, + target: target + }); + } + } + } + if (sortChords) resort(); + } + function resort() { + chords.sort(function(a, b) { + return sortChords((a.source.value + a.target.value) / 2, (b.source.value + b.target.value) / 2); + }); + } + chord.matrix = function(x) { + if (!arguments.length) return matrix; + n = (matrix = x) && matrix.length; + chords = groups = null; + return chord; + }; + chord.padding = function(x) { + if (!arguments.length) return padding; + padding = x; + chords = groups = null; + return chord; + }; + chord.sortGroups = function(x) { + if (!arguments.length) return sortGroups; + sortGroups = x; + chords = groups = null; + return chord; + }; + chord.sortSubgroups = function(x) { + if (!arguments.length) return sortSubgroups; + sortSubgroups = x; + chords = null; + return chord; + }; + chord.sortChords = function(x) { + if (!arguments.length) return sortChords; + sortChords = x; + if (chords) resort(); + return chord; + }; + chord.chords = function() { + if (!chords) relayout(); + return chords; + }; + chord.groups = function() { + if (!groups) relayout(); + return groups; + }; + return chord; + }; + d3.layout.force = function() { + var force = {}, event = d3.dispatch("start", "tick", "end"), timer, size = [ 1, 1 ], drag, alpha, friction = .9, linkDistance = d3_layout_forceLinkDistance, linkStrength = d3_layout_forceLinkStrength, charge = -30, chargeDistance2 = d3_layout_forceChargeDistance2, gravity = .1, theta2 = .64, nodes = [], links = [], distances, strengths, charges; + function repulse(node) { + return function(quad, x1, _, x2) { + if (quad.point !== node) { + var dx = quad.cx - node.x, dy = quad.cy - node.y, dw = x2 - x1, dn = dx * dx + dy * dy; + if (dw * dw / theta2 < dn) { + if (dn < chargeDistance2) { + var k = quad.charge / dn; + node.px -= dx * k; + node.py -= dy * k; + } + return true; + } + if (quad.point && dn && dn < chargeDistance2) { + var k = quad.pointCharge / dn; + node.px -= dx * k; + node.py -= dy * k; + } + } + return !quad.charge; + }; + } + force.tick = function() { + if ((alpha *= .99) < .005) { + timer = null; + event.end({ + type: "end", + alpha: alpha = 0 + }); + return true; + } + var n = nodes.length, m = links.length, q, i, o, s, t, l, k, x, y; + for (i = 0; i < m; ++i) { + o = links[i]; + s = o.source; + t = o.target; + x = t.x - s.x; + y = t.y - s.y; + if (l = x * x + y * y) { + l = alpha * strengths[i] * ((l = Math.sqrt(l)) - distances[i]) / l; + x *= l; + y *= l; + t.x -= x * (k = s.weight + t.weight ? s.weight / (s.weight + t.weight) : .5); + t.y -= y * k; + s.x += x * (k = 1 - k); + s.y += y * k; + } + } + if (k = alpha * gravity) { + x = size[0] / 2; + y = size[1] / 2; + i = -1; + if (k) while (++i < n) { + o = nodes[i]; + o.x += (x - o.x) * k; + o.y += (y - o.y) * k; + } + } + if (charge) { + d3_layout_forceAccumulate(q = d3.geom.quadtree(nodes), alpha, charges); + i = -1; + while (++i < n) { + if (!(o = nodes[i]).fixed) { + q.visit(repulse(o)); + } + } + } + i = -1; + while (++i < n) { + o = nodes[i]; + if (o.fixed) { + o.x = o.px; + o.y = o.py; + } else { + o.x -= (o.px - (o.px = o.x)) * friction; + o.y -= (o.py - (o.py = o.y)) * friction; + } + } + event.tick({ + type: "tick", + alpha: alpha + }); + }; + force.nodes = function(x) { + if (!arguments.length) return nodes; + nodes = x; + return force; + }; + force.links = function(x) { + if (!arguments.length) return links; + links = x; + return force; + }; + force.size = function(x) { + if (!arguments.length) return size; + size = x; + return force; + }; + force.linkDistance = function(x) { + if (!arguments.length) return linkDistance; + linkDistance = typeof x === "function" ? x : +x; + return force; + }; + force.distance = force.linkDistance; + force.linkStrength = function(x) { + if (!arguments.length) return linkStrength; + linkStrength = typeof x === "function" ? x : +x; + return force; + }; + force.friction = function(x) { + if (!arguments.length) return friction; + friction = +x; + return force; + }; + force.charge = function(x) { + if (!arguments.length) return charge; + charge = typeof x === "function" ? x : +x; + return force; + }; + force.chargeDistance = function(x) { + if (!arguments.length) return Math.sqrt(chargeDistance2); + chargeDistance2 = x * x; + return force; + }; + force.gravity = function(x) { + if (!arguments.length) return gravity; + gravity = +x; + return force; + }; + force.theta = function(x) { + if (!arguments.length) return Math.sqrt(theta2); + theta2 = x * x; + return force; + }; + force.alpha = function(x) { + if (!arguments.length) return alpha; + x = +x; + if (alpha) { + if (x > 0) { + alpha = x; + } else { + timer.c = null, timer.t = NaN, timer = null; + event.end({ + type: "end", + alpha: alpha = 0 + }); + } + } else if (x > 0) { + event.start({ + type: "start", + alpha: alpha = x + }); + timer = d3_timer(force.tick); + } + return force; + }; + force.start = function() { + var i, n = nodes.length, m = links.length, w = size[0], h = size[1], neighbors, o; + for (i = 0; i < n; ++i) { + (o = nodes[i]).index = i; + o.weight = 0; + } + for (i = 0; i < m; ++i) { + o = links[i]; + if (typeof o.source == "number") o.source = nodes[o.source]; + if (typeof o.target == "number") o.target = nodes[o.target]; + ++o.source.weight; + ++o.target.weight; + } + for (i = 0; i < n; ++i) { + o = nodes[i]; + if (isNaN(o.x)) o.x = position("x", w); + if (isNaN(o.y)) o.y = position("y", h); + if (isNaN(o.px)) o.px = o.x; + if (isNaN(o.py)) o.py = o.y; + } + distances = []; + if (typeof linkDistance === "function") for (i = 0; i < m; ++i) distances[i] = +linkDistance.call(this, links[i], i); else for (i = 0; i < m; ++i) distances[i] = linkDistance; + strengths = []; + if (typeof linkStrength === "function") for (i = 0; i < m; ++i) strengths[i] = +linkStrength.call(this, links[i], i); else for (i = 0; i < m; ++i) strengths[i] = linkStrength; + charges = []; + if (typeof charge === "function") for (i = 0; i < n; ++i) charges[i] = +charge.call(this, nodes[i], i); else for (i = 0; i < n; ++i) charges[i] = charge; + function position(dimension, size) { + if (!neighbors) { + neighbors = new Array(n); + for (j = 0; j < n; ++j) { + neighbors[j] = []; + } + for (j = 0; j < m; ++j) { + var o = links[j]; + neighbors[o.source.index].push(o.target); + neighbors[o.target.index].push(o.source); + } + } + var candidates = neighbors[i], j = -1, l = candidates.length, x; + while (++j < l) if (!isNaN(x = candidates[j][dimension])) return x; + return Math.random() * size; + } + return force.resume(); + }; + force.resume = function() { + return force.alpha(.1); + }; + force.stop = function() { + return force.alpha(0); + }; + force.drag = function() { + if (!drag) drag = d3.behavior.drag().origin(d3_identity).on("dragstart.force", d3_layout_forceDragstart).on("drag.force", dragmove).on("dragend.force", d3_layout_forceDragend); + if (!arguments.length) return drag; + this.on("mouseover.force", d3_layout_forceMouseover).on("mouseout.force", d3_layout_forceMouseout).call(drag); + }; + function dragmove(d) { + d.px = d3.event.x, d.py = d3.event.y; + force.resume(); + } + return d3.rebind(force, event, "on"); + }; + function d3_layout_forceDragstart(d) { + d.fixed |= 2; + } + function d3_layout_forceDragend(d) { + d.fixed &= ~6; + } + function d3_layout_forceMouseover(d) { + d.fixed |= 4; + d.px = d.x, d.py = d.y; + } + function d3_layout_forceMouseout(d) { + d.fixed &= ~4; + } + function d3_layout_forceAccumulate(quad, alpha, charges) { + var cx = 0, cy = 0; + quad.charge = 0; + if (!quad.leaf) { + var nodes = quad.nodes, n = nodes.length, i = -1, c; + while (++i < n) { + c = nodes[i]; + if (c == null) continue; + d3_layout_forceAccumulate(c, alpha, charges); + quad.charge += c.charge; + cx += c.charge * c.cx; + cy += c.charge * c.cy; + } + } + if (quad.point) { + if (!quad.leaf) { + quad.point.x += Math.random() - .5; + quad.point.y += Math.random() - .5; + } + var k = alpha * charges[quad.point.index]; + quad.charge += quad.pointCharge = k; + cx += k * quad.point.x; + cy += k * quad.point.y; + } + quad.cx = cx / quad.charge; + quad.cy = cy / quad.charge; + } + var d3_layout_forceLinkDistance = 20, d3_layout_forceLinkStrength = 1, d3_layout_forceChargeDistance2 = Infinity; + d3.layout.hierarchy = function() { + var sort = d3_layout_hierarchySort, children = d3_layout_hierarchyChildren, value = d3_layout_hierarchyValue; + function hierarchy(root) { + var stack = [ root ], nodes = [], node; + root.depth = 0; + while ((node = stack.pop()) != null) { + nodes.push(node); + if ((childs = children.call(hierarchy, node, node.depth)) && (n = childs.length)) { + var n, childs, child; + while (--n >= 0) { + stack.push(child = childs[n]); + child.parent = node; + child.depth = node.depth + 1; + } + if (value) node.value = 0; + node.children = childs; + } else { + if (value) node.value = +value.call(hierarchy, node, node.depth) || 0; + delete node.children; + } + } + d3_layout_hierarchyVisitAfter(root, function(node) { + var childs, parent; + if (sort && (childs = node.children)) childs.sort(sort); + if (value && (parent = node.parent)) parent.value += node.value; + }); + return nodes; + } + hierarchy.sort = function(x) { + if (!arguments.length) return sort; + sort = x; + return hierarchy; + }; + hierarchy.children = function(x) { + if (!arguments.length) return children; + children = x; + return hierarchy; + }; + hierarchy.value = function(x) { + if (!arguments.length) return value; + value = x; + return hierarchy; + }; + hierarchy.revalue = function(root) { + if (value) { + d3_layout_hierarchyVisitBefore(root, function(node) { + if (node.children) node.value = 0; + }); + d3_layout_hierarchyVisitAfter(root, function(node) { + var parent; + if (!node.children) node.value = +value.call(hierarchy, node, node.depth) || 0; + if (parent = node.parent) parent.value += node.value; + }); + } + return root; + }; + return hierarchy; + }; + function d3_layout_hierarchyRebind(object, hierarchy) { + d3.rebind(object, hierarchy, "sort", "children", "value"); + object.nodes = object; + object.links = d3_layout_hierarchyLinks; + return object; + } + function d3_layout_hierarchyVisitBefore(node, callback) { + var nodes = [ node ]; + while ((node = nodes.pop()) != null) { + callback(node); + if ((children = node.children) && (n = children.length)) { + var n, children; + while (--n >= 0) nodes.push(children[n]); + } + } + } + function d3_layout_hierarchyVisitAfter(node, callback) { + var nodes = [ node ], nodes2 = []; + while ((node = nodes.pop()) != null) { + nodes2.push(node); + if ((children = node.children) && (n = children.length)) { + var i = -1, n, children; + while (++i < n) nodes.push(children[i]); + } + } + while ((node = nodes2.pop()) != null) { + callback(node); + } + } + function d3_layout_hierarchyChildren(d) { + return d.children; + } + function d3_layout_hierarchyValue(d) { + return d.value; + } + function d3_layout_hierarchySort(a, b) { + return b.value - a.value; + } + function d3_layout_hierarchyLinks(nodes) { + return d3.merge(nodes.map(function(parent) { + return (parent.children || []).map(function(child) { + return { + source: parent, + target: child + }; + }); + })); + } + d3.layout.partition = function() { + var hierarchy = d3.layout.hierarchy(), size = [ 1, 1 ]; + function position(node, x, dx, dy) { + var children = node.children; + node.x = x; + node.y = node.depth * dy; + node.dx = dx; + node.dy = dy; + if (children && (n = children.length)) { + var i = -1, n, c, d; + dx = node.value ? dx / node.value : 0; + while (++i < n) { + position(c = children[i], x, d = c.value * dx, dy); + x += d; + } + } + } + function depth(node) { + var children = node.children, d = 0; + if (children && (n = children.length)) { + var i = -1, n; + while (++i < n) d = Math.max(d, depth(children[i])); + } + return 1 + d; + } + function partition(d, i) { + var nodes = hierarchy.call(this, d, i); + position(nodes[0], 0, size[0], size[1] / depth(nodes[0])); + return nodes; + } + partition.size = function(x) { + if (!arguments.length) return size; + size = x; + return partition; + }; + return d3_layout_hierarchyRebind(partition, hierarchy); + }; + d3.layout.pie = function() { + var value = Number, sort = d3_layout_pieSortByValue, startAngle = 0, endAngle = τ, padAngle = 0; + function pie(data) { + var n = data.length, values = data.map(function(d, i) { + return +value.call(pie, d, i); + }), a = +(typeof startAngle === "function" ? startAngle.apply(this, arguments) : startAngle), da = (typeof endAngle === "function" ? endAngle.apply(this, arguments) : endAngle) - a, p = Math.min(Math.abs(da) / n, +(typeof padAngle === "function" ? padAngle.apply(this, arguments) : padAngle)), pa = p * (da < 0 ? -1 : 1), sum = d3.sum(values), k = sum ? (da - n * pa) / sum : 0, index = d3.range(n), arcs = [], v; + if (sort != null) index.sort(sort === d3_layout_pieSortByValue ? function(i, j) { + return values[j] - values[i]; + } : function(i, j) { + return sort(data[i], data[j]); + }); + index.forEach(function(i) { + arcs[i] = { + data: data[i], + value: v = values[i], + startAngle: a, + endAngle: a += v * k + pa, + padAngle: p + }; + }); + return arcs; + } + pie.value = function(_) { + if (!arguments.length) return value; + value = _; + return pie; + }; + pie.sort = function(_) { + if (!arguments.length) return sort; + sort = _; + return pie; + }; + pie.startAngle = function(_) { + if (!arguments.length) return startAngle; + startAngle = _; + return pie; + }; + pie.endAngle = function(_) { + if (!arguments.length) return endAngle; + endAngle = _; + return pie; + }; + pie.padAngle = function(_) { + if (!arguments.length) return padAngle; + padAngle = _; + return pie; + }; + return pie; + }; + var d3_layout_pieSortByValue = {}; + d3.layout.stack = function() { + var values = d3_identity, order = d3_layout_stackOrderDefault, offset = d3_layout_stackOffsetZero, out = d3_layout_stackOut, x = d3_layout_stackX, y = d3_layout_stackY; + function stack(data, index) { + if (!(n = data.length)) return data; + var series = data.map(function(d, i) { + return values.call(stack, d, i); + }); + var points = series.map(function(d) { + return d.map(function(v, i) { + return [ x.call(stack, v, i), y.call(stack, v, i) ]; + }); + }); + var orders = order.call(stack, points, index); + series = d3.permute(series, orders); + points = d3.permute(points, orders); + var offsets = offset.call(stack, points, index); + var m = series[0].length, n, i, j, o; + for (j = 0; j < m; ++j) { + out.call(stack, series[0][j], o = offsets[j], points[0][j][1]); + for (i = 1; i < n; ++i) { + out.call(stack, series[i][j], o += points[i - 1][j][1], points[i][j][1]); + } + } + return data; + } + stack.values = function(x) { + if (!arguments.length) return values; + values = x; + return stack; + }; + stack.order = function(x) { + if (!arguments.length) return order; + order = typeof x === "function" ? x : d3_layout_stackOrders.get(x) || d3_layout_stackOrderDefault; + return stack; + }; + stack.offset = function(x) { + if (!arguments.length) return offset; + offset = typeof x === "function" ? x : d3_layout_stackOffsets.get(x) || d3_layout_stackOffsetZero; + return stack; + }; + stack.x = function(z) { + if (!arguments.length) return x; + x = z; + return stack; + }; + stack.y = function(z) { + if (!arguments.length) return y; + y = z; + return stack; + }; + stack.out = function(z) { + if (!arguments.length) return out; + out = z; + return stack; + }; + return stack; + }; + function d3_layout_stackX(d) { + return d.x; + } + function d3_layout_stackY(d) { + return d.y; + } + function d3_layout_stackOut(d, y0, y) { + d.y0 = y0; + d.y = y; + } + var d3_layout_stackOrders = d3.map({ + "inside-out": function(data) { + var n = data.length, i, j, max = data.map(d3_layout_stackMaxIndex), sums = data.map(d3_layout_stackReduceSum), index = d3.range(n).sort(function(a, b) { + return max[a] - max[b]; + }), top = 0, bottom = 0, tops = [], bottoms = []; + for (i = 0; i < n; ++i) { + j = index[i]; + if (top < bottom) { + top += sums[j]; + tops.push(j); + } else { + bottom += sums[j]; + bottoms.push(j); + } + } + return bottoms.reverse().concat(tops); + }, + reverse: function(data) { + return d3.range(data.length).reverse(); + }, + "default": d3_layout_stackOrderDefault + }); + var d3_layout_stackOffsets = d3.map({ + silhouette: function(data) { + var n = data.length, m = data[0].length, sums = [], max = 0, i, j, o, y0 = []; + for (j = 0; j < m; ++j) { + for (i = 0, o = 0; i < n; i++) o += data[i][j][1]; + if (o > max) max = o; + sums.push(o); + } + for (j = 0; j < m; ++j) { + y0[j] = (max - sums[j]) / 2; + } + return y0; + }, + wiggle: function(data) { + var n = data.length, x = data[0], m = x.length, i, j, k, s1, s2, s3, dx, o, o0, y0 = []; + y0[0] = o = o0 = 0; + for (j = 1; j < m; ++j) { + for (i = 0, s1 = 0; i < n; ++i) s1 += data[i][j][1]; + for (i = 0, s2 = 0, dx = x[j][0] - x[j - 1][0]; i < n; ++i) { + for (k = 0, s3 = (data[i][j][1] - data[i][j - 1][1]) / (2 * dx); k < i; ++k) { + s3 += (data[k][j][1] - data[k][j - 1][1]) / dx; + } + s2 += s3 * data[i][j][1]; + } + y0[j] = o -= s1 ? s2 / s1 * dx : 0; + if (o < o0) o0 = o; + } + for (j = 0; j < m; ++j) y0[j] -= o0; + return y0; + }, + expand: function(data) { + var n = data.length, m = data[0].length, k = 1 / n, i, j, o, y0 = []; + for (j = 0; j < m; ++j) { + for (i = 0, o = 0; i < n; i++) o += data[i][j][1]; + if (o) for (i = 0; i < n; i++) data[i][j][1] /= o; else for (i = 0; i < n; i++) data[i][j][1] = k; + } + for (j = 0; j < m; ++j) y0[j] = 0; + return y0; + }, + zero: d3_layout_stackOffsetZero + }); + function d3_layout_stackOrderDefault(data) { + return d3.range(data.length); + } + function d3_layout_stackOffsetZero(data) { + var j = -1, m = data[0].length, y0 = []; + while (++j < m) y0[j] = 0; + return y0; + } + function d3_layout_stackMaxIndex(array) { + var i = 1, j = 0, v = array[0][1], k, n = array.length; + for (;i < n; ++i) { + if ((k = array[i][1]) > v) { + j = i; + v = k; + } + } + return j; + } + function d3_layout_stackReduceSum(d) { + return d.reduce(d3_layout_stackSum, 0); + } + function d3_layout_stackSum(p, d) { + return p + d[1]; + } + d3.layout.histogram = function() { + var frequency = true, valuer = Number, ranger = d3_layout_histogramRange, binner = d3_layout_histogramBinSturges; + function histogram(data, i) { + var bins = [], values = data.map(valuer, this), range = ranger.call(this, values, i), thresholds = binner.call(this, range, values, i), bin, i = -1, n = values.length, m = thresholds.length - 1, k = frequency ? 1 : 1 / n, x; + while (++i < m) { + bin = bins[i] = []; + bin.dx = thresholds[i + 1] - (bin.x = thresholds[i]); + bin.y = 0; + } + if (m > 0) { + i = -1; + while (++i < n) { + x = values[i]; + if (x >= range[0] && x <= range[1]) { + bin = bins[d3.bisect(thresholds, x, 1, m) - 1]; + bin.y += k; + bin.push(data[i]); + } + } + } + return bins; + } + histogram.value = function(x) { + if (!arguments.length) return valuer; + valuer = x; + return histogram; + }; + histogram.range = function(x) { + if (!arguments.length) return ranger; + ranger = d3_functor(x); + return histogram; + }; + histogram.bins = function(x) { + if (!arguments.length) return binner; + binner = typeof x === "number" ? function(range) { + return d3_layout_histogramBinFixed(range, x); + } : d3_functor(x); + return histogram; + }; + histogram.frequency = function(x) { + if (!arguments.length) return frequency; + frequency = !!x; + return histogram; + }; + return histogram; + }; + function d3_layout_histogramBinSturges(range, values) { + return d3_layout_histogramBinFixed(range, Math.ceil(Math.log(values.length) / Math.LN2 + 1)); + } + function d3_layout_histogramBinFixed(range, n) { + var x = -1, b = +range[0], m = (range[1] - b) / n, f = []; + while (++x <= n) f[x] = m * x + b; + return f; + } + function d3_layout_histogramRange(values) { + return [ d3.min(values), d3.max(values) ]; + } + d3.layout.pack = function() { + var hierarchy = d3.layout.hierarchy().sort(d3_layout_packSort), padding = 0, size = [ 1, 1 ], radius; + function pack(d, i) { + var nodes = hierarchy.call(this, d, i), root = nodes[0], w = size[0], h = size[1], r = radius == null ? Math.sqrt : typeof radius === "function" ? radius : function() { + return radius; + }; + root.x = root.y = 0; + d3_layout_hierarchyVisitAfter(root, function(d) { + d.r = +r(d.value); + }); + d3_layout_hierarchyVisitAfter(root, d3_layout_packSiblings); + if (padding) { + var dr = padding * (radius ? 1 : Math.max(2 * root.r / w, 2 * root.r / h)) / 2; + d3_layout_hierarchyVisitAfter(root, function(d) { + d.r += dr; + }); + d3_layout_hierarchyVisitAfter(root, d3_layout_packSiblings); + d3_layout_hierarchyVisitAfter(root, function(d) { + d.r -= dr; + }); + } + d3_layout_packTransform(root, w / 2, h / 2, radius ? 1 : 1 / Math.max(2 * root.r / w, 2 * root.r / h)); + return nodes; + } + pack.size = function(_) { + if (!arguments.length) return size; + size = _; + return pack; + }; + pack.radius = function(_) { + if (!arguments.length) return radius; + radius = _ == null || typeof _ === "function" ? _ : +_; + return pack; + }; + pack.padding = function(_) { + if (!arguments.length) return padding; + padding = +_; + return pack; + }; + return d3_layout_hierarchyRebind(pack, hierarchy); + }; + function d3_layout_packSort(a, b) { + return a.value - b.value; + } + function d3_layout_packInsert(a, b) { + var c = a._pack_next; + a._pack_next = b; + b._pack_prev = a; + b._pack_next = c; + c._pack_prev = b; + } + function d3_layout_packSplice(a, b) { + a._pack_next = b; + b._pack_prev = a; + } + function d3_layout_packIntersects(a, b) { + var dx = b.x - a.x, dy = b.y - a.y, dr = a.r + b.r; + return .999 * dr * dr > dx * dx + dy * dy; + } + function d3_layout_packSiblings(node) { + if (!(nodes = node.children) || !(n = nodes.length)) return; + var nodes, xMin = Infinity, xMax = -Infinity, yMin = Infinity, yMax = -Infinity, a, b, c, i, j, k, n; + function bound(node) { + xMin = Math.min(node.x - node.r, xMin); + xMax = Math.max(node.x + node.r, xMax); + yMin = Math.min(node.y - node.r, yMin); + yMax = Math.max(node.y + node.r, yMax); + } + nodes.forEach(d3_layout_packLink); + a = nodes[0]; + a.x = -a.r; + a.y = 0; + bound(a); + if (n > 1) { + b = nodes[1]; + b.x = b.r; + b.y = 0; + bound(b); + if (n > 2) { + c = nodes[2]; + d3_layout_packPlace(a, b, c); + bound(c); + d3_layout_packInsert(a, c); + a._pack_prev = c; + d3_layout_packInsert(c, b); + b = a._pack_next; + for (i = 3; i < n; i++) { + d3_layout_packPlace(a, b, c = nodes[i]); + var isect = 0, s1 = 1, s2 = 1; + for (j = b._pack_next; j !== b; j = j._pack_next, s1++) { + if (d3_layout_packIntersects(j, c)) { + isect = 1; + break; + } + } + if (isect == 1) { + for (k = a._pack_prev; k !== j._pack_prev; k = k._pack_prev, s2++) { + if (d3_layout_packIntersects(k, c)) { + break; + } + } + } + if (isect) { + if (s1 < s2 || s1 == s2 && b.r < a.r) d3_layout_packSplice(a, b = j); else d3_layout_packSplice(a = k, b); + i--; + } else { + d3_layout_packInsert(a, c); + b = c; + bound(c); + } + } + } + } + var cx = (xMin + xMax) / 2, cy = (yMin + yMax) / 2, cr = 0; + for (i = 0; i < n; i++) { + c = nodes[i]; + c.x -= cx; + c.y -= cy; + cr = Math.max(cr, c.r + Math.sqrt(c.x * c.x + c.y * c.y)); + } + node.r = cr; + nodes.forEach(d3_layout_packUnlink); + } + function d3_layout_packLink(node) { + node._pack_next = node._pack_prev = node; + } + function d3_layout_packUnlink(node) { + delete node._pack_next; + delete node._pack_prev; + } + function d3_layout_packTransform(node, x, y, k) { + var children = node.children; + node.x = x += k * node.x; + node.y = y += k * node.y; + node.r *= k; + if (children) { + var i = -1, n = children.length; + while (++i < n) d3_layout_packTransform(children[i], x, y, k); + } + } + function d3_layout_packPlace(a, b, c) { + var db = a.r + c.r, dx = b.x - a.x, dy = b.y - a.y; + if (db && (dx || dy)) { + var da = b.r + c.r, dc = dx * dx + dy * dy; + da *= da; + db *= db; + var x = .5 + (db - da) / (2 * dc), y = Math.sqrt(Math.max(0, 2 * da * (db + dc) - (db -= dc) * db - da * da)) / (2 * dc); + c.x = a.x + x * dx + y * dy; + c.y = a.y + x * dy - y * dx; + } else { + c.x = a.x + db; + c.y = a.y; + } + } + d3.layout.tree = function() { + var hierarchy = d3.layout.hierarchy().sort(null).value(null), separation = d3_layout_treeSeparation, size = [ 1, 1 ], nodeSize = null; + function tree(d, i) { + var nodes = hierarchy.call(this, d, i), root0 = nodes[0], root1 = wrapTree(root0); + d3_layout_hierarchyVisitAfter(root1, firstWalk), root1.parent.m = -root1.z; + d3_layout_hierarchyVisitBefore(root1, secondWalk); + if (nodeSize) d3_layout_hierarchyVisitBefore(root0, sizeNode); else { + var left = root0, right = root0, bottom = root0; + d3_layout_hierarchyVisitBefore(root0, function(node) { + if (node.x < left.x) left = node; + if (node.x > right.x) right = node; + if (node.depth > bottom.depth) bottom = node; + }); + var tx = separation(left, right) / 2 - left.x, kx = size[0] / (right.x + separation(right, left) / 2 + tx), ky = size[1] / (bottom.depth || 1); + d3_layout_hierarchyVisitBefore(root0, function(node) { + node.x = (node.x + tx) * kx; + node.y = node.depth * ky; + }); + } + return nodes; + } + function wrapTree(root0) { + var root1 = { + A: null, + children: [ root0 ] + }, queue = [ root1 ], node1; + while ((node1 = queue.pop()) != null) { + for (var children = node1.children, child, i = 0, n = children.length; i < n; ++i) { + queue.push((children[i] = child = { + _: children[i], + parent: node1, + children: (child = children[i].children) && child.slice() || [], + A: null, + a: null, + z: 0, + m: 0, + c: 0, + s: 0, + t: null, + i: i + }).a = child); + } + } + return root1.children[0]; + } + function firstWalk(v) { + var children = v.children, siblings = v.parent.children, w = v.i ? siblings[v.i - 1] : null; + if (children.length) { + d3_layout_treeShift(v); + var midpoint = (children[0].z + children[children.length - 1].z) / 2; + if (w) { + v.z = w.z + separation(v._, w._); + v.m = v.z - midpoint; + } else { + v.z = midpoint; + } + } else if (w) { + v.z = w.z + separation(v._, w._); + } + v.parent.A = apportion(v, w, v.parent.A || siblings[0]); + } + function secondWalk(v) { + v._.x = v.z + v.parent.m; + v.m += v.parent.m; + } + function apportion(v, w, ancestor) { + if (w) { + var vip = v, vop = v, vim = w, vom = vip.parent.children[0], sip = vip.m, sop = vop.m, sim = vim.m, som = vom.m, shift; + while (vim = d3_layout_treeRight(vim), vip = d3_layout_treeLeft(vip), vim && vip) { + vom = d3_layout_treeLeft(vom); + vop = d3_layout_treeRight(vop); + vop.a = v; + shift = vim.z + sim - vip.z - sip + separation(vim._, vip._); + if (shift > 0) { + d3_layout_treeMove(d3_layout_treeAncestor(vim, v, ancestor), v, shift); + sip += shift; + sop += shift; + } + sim += vim.m; + sip += vip.m; + som += vom.m; + sop += vop.m; + } + if (vim && !d3_layout_treeRight(vop)) { + vop.t = vim; + vop.m += sim - sop; + } + if (vip && !d3_layout_treeLeft(vom)) { + vom.t = vip; + vom.m += sip - som; + ancestor = v; + } + } + return ancestor; + } + function sizeNode(node) { + node.x *= size[0]; + node.y = node.depth * size[1]; + } + tree.separation = function(x) { + if (!arguments.length) return separation; + separation = x; + return tree; + }; + tree.size = function(x) { + if (!arguments.length) return nodeSize ? null : size; + nodeSize = (size = x) == null ? sizeNode : null; + return tree; + }; + tree.nodeSize = function(x) { + if (!arguments.length) return nodeSize ? size : null; + nodeSize = (size = x) == null ? null : sizeNode; + return tree; + }; + return d3_layout_hierarchyRebind(tree, hierarchy); + }; + function d3_layout_treeSeparation(a, b) { + return a.parent == b.parent ? 1 : 2; + } + function d3_layout_treeLeft(v) { + var children = v.children; + return children.length ? children[0] : v.t; + } + function d3_layout_treeRight(v) { + var children = v.children, n; + return (n = children.length) ? children[n - 1] : v.t; + } + function d3_layout_treeMove(wm, wp, shift) { + var change = shift / (wp.i - wm.i); + wp.c -= change; + wp.s += shift; + wm.c += change; + wp.z += shift; + wp.m += shift; + } + function d3_layout_treeShift(v) { + var shift = 0, change = 0, children = v.children, i = children.length, w; + while (--i >= 0) { + w = children[i]; + w.z += shift; + w.m += shift; + shift += w.s + (change += w.c); + } + } + function d3_layout_treeAncestor(vim, v, ancestor) { + return vim.a.parent === v.parent ? vim.a : ancestor; + } + d3.layout.cluster = function() { + var hierarchy = d3.layout.hierarchy().sort(null).value(null), separation = d3_layout_treeSeparation, size = [ 1, 1 ], nodeSize = false; + function cluster(d, i) { + var nodes = hierarchy.call(this, d, i), root = nodes[0], previousNode, x = 0; + d3_layout_hierarchyVisitAfter(root, function(node) { + var children = node.children; + if (children && children.length) { + node.x = d3_layout_clusterX(children); + node.y = d3_layout_clusterY(children); + } else { + node.x = previousNode ? x += separation(node, previousNode) : 0; + node.y = 0; + previousNode = node; + } + }); + var left = d3_layout_clusterLeft(root), right = d3_layout_clusterRight(root), x0 = left.x - separation(left, right) / 2, x1 = right.x + separation(right, left) / 2; + d3_layout_hierarchyVisitAfter(root, nodeSize ? function(node) { + node.x = (node.x - root.x) * size[0]; + node.y = (root.y - node.y) * size[1]; + } : function(node) { + node.x = (node.x - x0) / (x1 - x0) * size[0]; + node.y = (1 - (root.y ? node.y / root.y : 1)) * size[1]; + }); + return nodes; + } + cluster.separation = function(x) { + if (!arguments.length) return separation; + separation = x; + return cluster; + }; + cluster.size = function(x) { + if (!arguments.length) return nodeSize ? null : size; + nodeSize = (size = x) == null; + return cluster; + }; + cluster.nodeSize = function(x) { + if (!arguments.length) return nodeSize ? size : null; + nodeSize = (size = x) != null; + return cluster; + }; + return d3_layout_hierarchyRebind(cluster, hierarchy); + }; + function d3_layout_clusterY(children) { + return 1 + d3.max(children, function(child) { + return child.y; + }); + } + function d3_layout_clusterX(children) { + return children.reduce(function(x, child) { + return x + child.x; + }, 0) / children.length; + } + function d3_layout_clusterLeft(node) { + var children = node.children; + return children && children.length ? d3_layout_clusterLeft(children[0]) : node; + } + function d3_layout_clusterRight(node) { + var children = node.children, n; + return children && (n = children.length) ? d3_layout_clusterRight(children[n - 1]) : node; + } + d3.layout.treemap = function() { + var hierarchy = d3.layout.hierarchy(), round = Math.round, size = [ 1, 1 ], padding = null, pad = d3_layout_treemapPadNull, sticky = false, stickies, mode = "squarify", ratio = .5 * (1 + Math.sqrt(5)); + function scale(children, k) { + var i = -1, n = children.length, child, area; + while (++i < n) { + area = (child = children[i]).value * (k < 0 ? 0 : k); + child.area = isNaN(area) || area <= 0 ? 0 : area; + } + } + function squarify(node) { + var children = node.children; + if (children && children.length) { + var rect = pad(node), row = [], remaining = children.slice(), child, best = Infinity, score, u = mode === "slice" ? rect.dx : mode === "dice" ? rect.dy : mode === "slice-dice" ? node.depth & 1 ? rect.dy : rect.dx : Math.min(rect.dx, rect.dy), n; + scale(remaining, rect.dx * rect.dy / node.value); + row.area = 0; + while ((n = remaining.length) > 0) { + row.push(child = remaining[n - 1]); + row.area += child.area; + if (mode !== "squarify" || (score = worst(row, u)) <= best) { + remaining.pop(); + best = score; + } else { + row.area -= row.pop().area; + position(row, u, rect, false); + u = Math.min(rect.dx, rect.dy); + row.length = row.area = 0; + best = Infinity; + } + } + if (row.length) { + position(row, u, rect, true); + row.length = row.area = 0; + } + children.forEach(squarify); + } + } + function stickify(node) { + var children = node.children; + if (children && children.length) { + var rect = pad(node), remaining = children.slice(), child, row = []; + scale(remaining, rect.dx * rect.dy / node.value); + row.area = 0; + while (child = remaining.pop()) { + row.push(child); + row.area += child.area; + if (child.z != null) { + position(row, child.z ? rect.dx : rect.dy, rect, !remaining.length); + row.length = row.area = 0; + } + } + children.forEach(stickify); + } + } + function worst(row, u) { + var s = row.area, r, rmax = 0, rmin = Infinity, i = -1, n = row.length; + while (++i < n) { + if (!(r = row[i].area)) continue; + if (r < rmin) rmin = r; + if (r > rmax) rmax = r; + } + s *= s; + u *= u; + return s ? Math.max(u * rmax * ratio / s, s / (u * rmin * ratio)) : Infinity; + } + function position(row, u, rect, flush) { + var i = -1, n = row.length, x = rect.x, y = rect.y, v = u ? round(row.area / u) : 0, o; + if (u == rect.dx) { + if (flush || v > rect.dy) v = rect.dy; + while (++i < n) { + o = row[i]; + o.x = x; + o.y = y; + o.dy = v; + x += o.dx = Math.min(rect.x + rect.dx - x, v ? round(o.area / v) : 0); + } + o.z = true; + o.dx += rect.x + rect.dx - x; + rect.y += v; + rect.dy -= v; + } else { + if (flush || v > rect.dx) v = rect.dx; + while (++i < n) { + o = row[i]; + o.x = x; + o.y = y; + o.dx = v; + y += o.dy = Math.min(rect.y + rect.dy - y, v ? round(o.area / v) : 0); + } + o.z = false; + o.dy += rect.y + rect.dy - y; + rect.x += v; + rect.dx -= v; + } + } + function treemap(d) { + var nodes = stickies || hierarchy(d), root = nodes[0]; + root.x = root.y = 0; + if (root.value) root.dx = size[0], root.dy = size[1]; else root.dx = root.dy = 0; + if (stickies) hierarchy.revalue(root); + scale([ root ], root.dx * root.dy / root.value); + (stickies ? stickify : squarify)(root); + if (sticky) stickies = nodes; + return nodes; + } + treemap.size = function(x) { + if (!arguments.length) return size; + size = x; + return treemap; + }; + treemap.padding = function(x) { + if (!arguments.length) return padding; + function padFunction(node) { + var p = x.call(treemap, node, node.depth); + return p == null ? d3_layout_treemapPadNull(node) : d3_layout_treemapPad(node, typeof p === "number" ? [ p, p, p, p ] : p); + } + function padConstant(node) { + return d3_layout_treemapPad(node, x); + } + var type; + pad = (padding = x) == null ? d3_layout_treemapPadNull : (type = typeof x) === "function" ? padFunction : type === "number" ? (x = [ x, x, x, x ], + padConstant) : padConstant; + return treemap; + }; + treemap.round = function(x) { + if (!arguments.length) return round != Number; + round = x ? Math.round : Number; + return treemap; + }; + treemap.sticky = function(x) { + if (!arguments.length) return sticky; + sticky = x; + stickies = null; + return treemap; + }; + treemap.ratio = function(x) { + if (!arguments.length) return ratio; + ratio = x; + return treemap; + }; + treemap.mode = function(x) { + if (!arguments.length) return mode; + mode = x + ""; + return treemap; + }; + return d3_layout_hierarchyRebind(treemap, hierarchy); + }; + function d3_layout_treemapPadNull(node) { + return { + x: node.x, + y: node.y, + dx: node.dx, + dy: node.dy + }; + } + function d3_layout_treemapPad(node, padding) { + var x = node.x + padding[3], y = node.y + padding[0], dx = node.dx - padding[1] - padding[3], dy = node.dy - padding[0] - padding[2]; + if (dx < 0) { + x += dx / 2; + dx = 0; + } + if (dy < 0) { + y += dy / 2; + dy = 0; + } + return { + x: x, + y: y, + dx: dx, + dy: dy + }; + } + d3.random = { + normal: function(µ, σ) { + var n = arguments.length; + if (n < 2) σ = 1; + if (n < 1) µ = 0; + return function() { + var x, y, r; + do { + x = Math.random() * 2 - 1; + y = Math.random() * 2 - 1; + r = x * x + y * y; + } while (!r || r > 1); + return µ + σ * x * Math.sqrt(-2 * Math.log(r) / r); + }; + }, + logNormal: function() { + var random = d3.random.normal.apply(d3, arguments); + return function() { + return Math.exp(random()); + }; + }, + bates: function(m) { + var random = d3.random.irwinHall(m); + return function() { + return random() / m; + }; + }, + irwinHall: function(m) { + return function() { + for (var s = 0, j = 0; j < m; j++) s += Math.random(); + return s; + }; + } + }; + d3.scale = {}; + function d3_scaleExtent(domain) { + var start = domain[0], stop = domain[domain.length - 1]; + return start < stop ? [ start, stop ] : [ stop, start ]; + } + function d3_scaleRange(scale) { + return scale.rangeExtent ? scale.rangeExtent() : d3_scaleExtent(scale.range()); + } + function d3_scale_bilinear(domain, range, uninterpolate, interpolate) { + var u = uninterpolate(domain[0], domain[1]), i = interpolate(range[0], range[1]); + return function(x) { + return i(u(x)); + }; + } + function d3_scale_nice(domain, nice) { + var i0 = 0, i1 = domain.length - 1, x0 = domain[i0], x1 = domain[i1], dx; + if (x1 < x0) { + dx = i0, i0 = i1, i1 = dx; + dx = x0, x0 = x1, x1 = dx; + } + domain[i0] = nice.floor(x0); + domain[i1] = nice.ceil(x1); + return domain; + } + function d3_scale_niceStep(step) { + return step ? { + floor: function(x) { + return Math.floor(x / step) * step; + }, + ceil: function(x) { + return Math.ceil(x / step) * step; + } + } : d3_scale_niceIdentity; + } + var d3_scale_niceIdentity = { + floor: d3_identity, + ceil: d3_identity + }; + function d3_scale_polylinear(domain, range, uninterpolate, interpolate) { + var u = [], i = [], j = 0, k = Math.min(domain.length, range.length) - 1; + if (domain[k] < domain[0]) { + domain = domain.slice().reverse(); + range = range.slice().reverse(); + } + while (++j <= k) { + u.push(uninterpolate(domain[j - 1], domain[j])); + i.push(interpolate(range[j - 1], range[j])); + } + return function(x) { + var j = d3.bisect(domain, x, 1, k) - 1; + return i[j](u[j](x)); + }; + } + d3.scale.linear = function() { + return d3_scale_linear([ 0, 1 ], [ 0, 1 ], d3_interpolate, false); + }; + function d3_scale_linear(domain, range, interpolate, clamp) { + var output, input; + function rescale() { + var linear = Math.min(domain.length, range.length) > 2 ? d3_scale_polylinear : d3_scale_bilinear, uninterpolate = clamp ? d3_uninterpolateClamp : d3_uninterpolateNumber; + output = linear(domain, range, uninterpolate, interpolate); + input = linear(range, domain, uninterpolate, d3_interpolate); + return scale; + } + function scale(x) { + return output(x); + } + scale.invert = function(y) { + return input(y); + }; + scale.domain = function(x) { + if (!arguments.length) return domain; + domain = x.map(Number); + return rescale(); + }; + scale.range = function(x) { + if (!arguments.length) return range; + range = x; + return rescale(); + }; + scale.rangeRound = function(x) { + return scale.range(x).interpolate(d3_interpolateRound); + }; + scale.clamp = function(x) { + if (!arguments.length) return clamp; + clamp = x; + return rescale(); + }; + scale.interpolate = function(x) { + if (!arguments.length) return interpolate; + interpolate = x; + return rescale(); + }; + scale.ticks = function(m) { + return d3_scale_linearTicks(domain, m); + }; + scale.tickFormat = function(m, format) { + return d3_scale_linearTickFormat(domain, m, format); + }; + scale.nice = function(m) { + d3_scale_linearNice(domain, m); + return rescale(); + }; + scale.copy = function() { + return d3_scale_linear(domain, range, interpolate, clamp); + }; + return rescale(); + } + function d3_scale_linearRebind(scale, linear) { + return d3.rebind(scale, linear, "range", "rangeRound", "interpolate", "clamp"); + } + function d3_scale_linearNice(domain, m) { + d3_scale_nice(domain, d3_scale_niceStep(d3_scale_linearTickRange(domain, m)[2])); + d3_scale_nice(domain, d3_scale_niceStep(d3_scale_linearTickRange(domain, m)[2])); + return domain; + } + function d3_scale_linearTickRange(domain, m) { + if (m == null) m = 10; + var extent = d3_scaleExtent(domain), span = extent[1] - extent[0], step = Math.pow(10, Math.floor(Math.log(span / m) / Math.LN10)), err = m / span * step; + if (err <= .15) step *= 10; else if (err <= .35) step *= 5; else if (err <= .75) step *= 2; + extent[0] = Math.ceil(extent[0] / step) * step; + extent[1] = Math.floor(extent[1] / step) * step + step * .5; + extent[2] = step; + return extent; + } + function d3_scale_linearTicks(domain, m) { + return d3.range.apply(d3, d3_scale_linearTickRange(domain, m)); + } + var d3_scale_linearFormatSignificant = { + s: 1, + g: 1, + p: 1, + r: 1, + e: 1 + }; + function d3_scale_linearPrecision(value) { + return -Math.floor(Math.log(value) / Math.LN10 + .01); + } + function d3_scale_linearFormatPrecision(type, range) { + var p = d3_scale_linearPrecision(range[2]); + return type in d3_scale_linearFormatSignificant ? Math.abs(p - d3_scale_linearPrecision(Math.max(abs(range[0]), abs(range[1])))) + +(type !== "e") : p - (type === "%") * 2; + } + d3.scale.log = function() { + return d3_scale_log(d3.scale.linear().domain([ 0, 1 ]), 10, true, [ 1, 10 ]); + }; + function d3_scale_log(linear, base, positive, domain) { + function log(x) { + return (positive ? Math.log(x < 0 ? 0 : x) : -Math.log(x > 0 ? 0 : -x)) / Math.log(base); + } + function pow(x) { + return positive ? Math.pow(base, x) : -Math.pow(base, -x); + } + function scale(x) { + return linear(log(x)); + } + scale.invert = function(x) { + return pow(linear.invert(x)); + }; + scale.domain = function(x) { + if (!arguments.length) return domain; + positive = x[0] >= 0; + linear.domain((domain = x.map(Number)).map(log)); + return scale; + }; + scale.base = function(_) { + if (!arguments.length) return base; + base = +_; + linear.domain(domain.map(log)); + return scale; + }; + scale.nice = function() { + var niced = d3_scale_nice(domain.map(log), positive ? Math : d3_scale_logNiceNegative); + linear.domain(niced); + domain = niced.map(pow); + return scale; + }; + scale.ticks = function() { + var extent = d3_scaleExtent(domain), ticks = [], u = extent[0], v = extent[1], i = Math.floor(log(u)), j = Math.ceil(log(v)), n = base % 1 ? 2 : base; + if (isFinite(j - i)) { + if (positive) { + for (;i < j; i++) for (var k = 1; k < n; k++) ticks.push(pow(i) * k); + ticks.push(pow(i)); + } else { + ticks.push(pow(i)); + for (;i++ < j; ) for (var k = n - 1; k > 0; k--) ticks.push(pow(i) * k); + } + for (i = 0; ticks[i] < u; i++) {} + for (j = ticks.length; ticks[j - 1] > v; j--) {} + ticks = ticks.slice(i, j); + } + return ticks; + }; + scale.copy = function() { + return d3_scale_log(linear.copy(), base, positive, domain); + }; + return d3_scale_linearRebind(scale, linear); + } + var d3_scale_logNiceNegative = { + floor: function(x) { + return -Math.ceil(-x); + }, + ceil: function(x) { + return -Math.floor(-x); + } + }; + d3.scale.pow = function() { + return d3_scale_pow(d3.scale.linear(), 1, [ 0, 1 ]); + }; + function d3_scale_pow(linear, exponent, domain) { + var powp = d3_scale_powPow(exponent), powb = d3_scale_powPow(1 / exponent); + function scale(x) { + return linear(powp(x)); + } + scale.invert = function(x) { + return powb(linear.invert(x)); + }; + scale.domain = function(x) { + if (!arguments.length) return domain; + linear.domain((domain = x.map(Number)).map(powp)); + return scale; + }; + scale.ticks = function(m) { + return d3_scale_linearTicks(domain, m); + }; + scale.tickFormat = function(m, format) { + return d3_scale_linearTickFormat(domain, m, format); + }; + scale.nice = function(m) { + return scale.domain(d3_scale_linearNice(domain, m)); + }; + scale.exponent = function(x) { + if (!arguments.length) return exponent; + powp = d3_scale_powPow(exponent = x); + powb = d3_scale_powPow(1 / exponent); + linear.domain(domain.map(powp)); + return scale; + }; + scale.copy = function() { + return d3_scale_pow(linear.copy(), exponent, domain); + }; + return d3_scale_linearRebind(scale, linear); + } + function d3_scale_powPow(e) { + return function(x) { + return x < 0 ? -Math.pow(-x, e) : Math.pow(x, e); + }; + } + d3.scale.sqrt = function() { + return d3.scale.pow().exponent(.5); + }; + d3.scale.ordinal = function() { + return d3_scale_ordinal([], { + t: "range", + a: [ [] ] + }); + }; + function d3_scale_ordinal(domain, ranger) { + var index, range, rangeBand; + function scale(x) { + return range[((index.get(x) || (ranger.t === "range" ? index.set(x, domain.push(x)) : NaN)) - 1) % range.length]; + } + function steps(start, step) { + return d3.range(domain.length).map(function(i) { + return start + step * i; + }); + } + scale.domain = function(x) { + if (!arguments.length) return domain; + domain = []; + index = new d3_Map(); + var i = -1, n = x.length, xi; + while (++i < n) if (!index.has(xi = x[i])) index.set(xi, domain.push(xi)); + return scale[ranger.t].apply(scale, ranger.a); + }; + scale.range = function(x) { + if (!arguments.length) return range; + range = x; + rangeBand = 0; + ranger = { + t: "range", + a: arguments + }; + return scale; + }; + scale.rangePoints = function(x, padding) { + if (arguments.length < 2) padding = 0; + var start = x[0], stop = x[1], step = domain.length < 2 ? (start = (start + stop) / 2, + 0) : (stop - start) / (domain.length - 1 + padding); + range = steps(start + step * padding / 2, step); + rangeBand = 0; + ranger = { + t: "rangePoints", + a: arguments + }; + return scale; + }; + scale.rangeRoundPoints = function(x, padding) { + if (arguments.length < 2) padding = 0; + var start = x[0], stop = x[1], step = domain.length < 2 ? (start = stop = Math.round((start + stop) / 2), + 0) : (stop - start) / (domain.length - 1 + padding) | 0; + range = steps(start + Math.round(step * padding / 2 + (stop - start - (domain.length - 1 + padding) * step) / 2), step); + rangeBand = 0; + ranger = { + t: "rangeRoundPoints", + a: arguments + }; + return scale; + }; + scale.rangeBands = function(x, padding, outerPadding) { + if (arguments.length < 2) padding = 0; + if (arguments.length < 3) outerPadding = padding; + var reverse = x[1] < x[0], start = x[reverse - 0], stop = x[1 - reverse], step = (stop - start) / (domain.length - padding + 2 * outerPadding); + range = steps(start + step * outerPadding, step); + if (reverse) range.reverse(); + rangeBand = step * (1 - padding); + ranger = { + t: "rangeBands", + a: arguments + }; + return scale; + }; + scale.rangeRoundBands = function(x, padding, outerPadding) { + if (arguments.length < 2) padding = 0; + if (arguments.length < 3) outerPadding = padding; + var reverse = x[1] < x[0], start = x[reverse - 0], stop = x[1 - reverse], step = Math.floor((stop - start) / (domain.length - padding + 2 * outerPadding)); + range = steps(start + Math.round((stop - start - (domain.length - padding) * step) / 2), step); + if (reverse) range.reverse(); + rangeBand = Math.round(step * (1 - padding)); + ranger = { + t: "rangeRoundBands", + a: arguments + }; + return scale; + }; + scale.rangeBand = function() { + return rangeBand; + }; + scale.rangeExtent = function() { + return d3_scaleExtent(ranger.a[0]); + }; + scale.copy = function() { + return d3_scale_ordinal(domain, ranger); + }; + return scale.domain(domain); + } + d3.scale.category10 = function() { + return d3.scale.ordinal().range(d3_category10); + }; + d3.scale.category20 = function() { + return d3.scale.ordinal().range(d3_category20); + }; + d3.scale.category20b = function() { + return d3.scale.ordinal().range(d3_category20b); + }; + d3.scale.category20c = function() { + return d3.scale.ordinal().range(d3_category20c); + }; + var d3_category10 = [ 2062260, 16744206, 2924588, 14034728, 9725885, 9197131, 14907330, 8355711, 12369186, 1556175 ].map(d3_rgbString); + var d3_category20 = [ 2062260, 11454440, 16744206, 16759672, 2924588, 10018698, 14034728, 16750742, 9725885, 12955861, 9197131, 12885140, 14907330, 16234194, 8355711, 13092807, 12369186, 14408589, 1556175, 10410725 ].map(d3_rgbString); + var d3_category20b = [ 3750777, 5395619, 7040719, 10264286, 6519097, 9216594, 11915115, 13556636, 9202993, 12426809, 15186514, 15190932, 8666169, 11356490, 14049643, 15177372, 8077683, 10834324, 13528509, 14589654 ].map(d3_rgbString); + var d3_category20c = [ 3244733, 7057110, 10406625, 13032431, 15095053, 16616764, 16625259, 16634018, 3253076, 7652470, 10607003, 13101504, 7695281, 10394312, 12369372, 14342891, 6513507, 9868950, 12434877, 14277081 ].map(d3_rgbString); + d3.scale.quantile = function() { + return d3_scale_quantile([], []); + }; + function d3_scale_quantile(domain, range) { + var thresholds; + function rescale() { + var k = 0, q = range.length; + thresholds = []; + while (++k < q) thresholds[k - 1] = d3.quantile(domain, k / q); + return scale; + } + function scale(x) { + if (!isNaN(x = +x)) return range[d3.bisect(thresholds, x)]; + } + scale.domain = function(x) { + if (!arguments.length) return domain; + domain = x.map(d3_number).filter(d3_numeric).sort(d3_ascending); + return rescale(); + }; + scale.range = function(x) { + if (!arguments.length) return range; + range = x; + return rescale(); + }; + scale.quantiles = function() { + return thresholds; + }; + scale.invertExtent = function(y) { + y = range.indexOf(y); + return y < 0 ? [ NaN, NaN ] : [ y > 0 ? thresholds[y - 1] : domain[0], y < thresholds.length ? thresholds[y] : domain[domain.length - 1] ]; + }; + scale.copy = function() { + return d3_scale_quantile(domain, range); + }; + return rescale(); + } + d3.scale.quantize = function() { + return d3_scale_quantize(0, 1, [ 0, 1 ]); + }; + function d3_scale_quantize(x0, x1, range) { + var kx, i; + function scale(x) { + return range[Math.max(0, Math.min(i, Math.floor(kx * (x - x0))))]; + } + function rescale() { + kx = range.length / (x1 - x0); + i = range.length - 1; + return scale; + } + scale.domain = function(x) { + if (!arguments.length) return [ x0, x1 ]; + x0 = +x[0]; + x1 = +x[x.length - 1]; + return rescale(); + }; + scale.range = function(x) { + if (!arguments.length) return range; + range = x; + return rescale(); + }; + scale.invertExtent = function(y) { + y = range.indexOf(y); + y = y < 0 ? NaN : y / kx + x0; + return [ y, y + 1 / kx ]; + }; + scale.copy = function() { + return d3_scale_quantize(x0, x1, range); + }; + return rescale(); + } + d3.scale.threshold = function() { + return d3_scale_threshold([ .5 ], [ 0, 1 ]); + }; + function d3_scale_threshold(domain, range) { + function scale(x) { + if (x <= x) return range[d3.bisect(domain, x)]; + } + scale.domain = function(_) { + if (!arguments.length) return domain; + domain = _; + return scale; + }; + scale.range = function(_) { + if (!arguments.length) return range; + range = _; + return scale; + }; + scale.invertExtent = function(y) { + y = range.indexOf(y); + return [ domain[y - 1], domain[y] ]; + }; + scale.copy = function() { + return d3_scale_threshold(domain, range); + }; + return scale; + } + d3.scale.identity = function() { + return d3_scale_identity([ 0, 1 ]); + }; + function d3_scale_identity(domain) { + function identity(x) { + return +x; + } + identity.invert = identity; + identity.domain = identity.range = function(x) { + if (!arguments.length) return domain; + domain = x.map(identity); + return identity; + }; + identity.ticks = function(m) { + return d3_scale_linearTicks(domain, m); + }; + identity.tickFormat = function(m, format) { + return d3_scale_linearTickFormat(domain, m, format); + }; + identity.copy = function() { + return d3_scale_identity(domain); + }; + return identity; + } + d3.svg = {}; + function d3_zero() { + return 0; + } + d3.svg.arc = function() { + var innerRadius = d3_svg_arcInnerRadius, outerRadius = d3_svg_arcOuterRadius, cornerRadius = d3_zero, padRadius = d3_svg_arcAuto, startAngle = d3_svg_arcStartAngle, endAngle = d3_svg_arcEndAngle, padAngle = d3_svg_arcPadAngle; + function arc() { + var r0 = Math.max(0, +innerRadius.apply(this, arguments)), r1 = Math.max(0, +outerRadius.apply(this, arguments)), a0 = startAngle.apply(this, arguments) - halfπ, a1 = endAngle.apply(this, arguments) - halfπ, da = Math.abs(a1 - a0), cw = a0 > a1 ? 0 : 1; + if (r1 < r0) rc = r1, r1 = r0, r0 = rc; + if (da >= τε) return circleSegment(r1, cw) + (r0 ? circleSegment(r0, 1 - cw) : "") + "Z"; + var rc, cr, rp, ap, p0 = 0, p1 = 0, x0, y0, x1, y1, x2, y2, x3, y3, path = []; + if (ap = (+padAngle.apply(this, arguments) || 0) / 2) { + rp = padRadius === d3_svg_arcAuto ? Math.sqrt(r0 * r0 + r1 * r1) : +padRadius.apply(this, arguments); + if (!cw) p1 *= -1; + if (r1) p1 = d3_asin(rp / r1 * Math.sin(ap)); + if (r0) p0 = d3_asin(rp / r0 * Math.sin(ap)); + } + if (r1) { + x0 = r1 * Math.cos(a0 + p1); + y0 = r1 * Math.sin(a0 + p1); + x1 = r1 * Math.cos(a1 - p1); + y1 = r1 * Math.sin(a1 - p1); + var l1 = Math.abs(a1 - a0 - 2 * p1) <= π ? 0 : 1; + if (p1 && d3_svg_arcSweep(x0, y0, x1, y1) === cw ^ l1) { + var h1 = (a0 + a1) / 2; + x0 = r1 * Math.cos(h1); + y0 = r1 * Math.sin(h1); + x1 = y1 = null; + } + } else { + x0 = y0 = 0; + } + if (r0) { + x2 = r0 * Math.cos(a1 - p0); + y2 = r0 * Math.sin(a1 - p0); + x3 = r0 * Math.cos(a0 + p0); + y3 = r0 * Math.sin(a0 + p0); + var l0 = Math.abs(a0 - a1 + 2 * p0) <= π ? 0 : 1; + if (p0 && d3_svg_arcSweep(x2, y2, x3, y3) === 1 - cw ^ l0) { + var h0 = (a0 + a1) / 2; + x2 = r0 * Math.cos(h0); + y2 = r0 * Math.sin(h0); + x3 = y3 = null; + } + } else { + x2 = y2 = 0; + } + if (da > ε && (rc = Math.min(Math.abs(r1 - r0) / 2, +cornerRadius.apply(this, arguments))) > .001) { + cr = r0 < r1 ^ cw ? 0 : 1; + var rc1 = rc, rc0 = rc; + if (da < π) { + var oc = x3 == null ? [ x2, y2 ] : x1 == null ? [ x0, y0 ] : d3_geom_polygonIntersect([ x0, y0 ], [ x3, y3 ], [ x1, y1 ], [ x2, y2 ]), ax = x0 - oc[0], ay = y0 - oc[1], bx = x1 - oc[0], by = y1 - oc[1], kc = 1 / Math.sin(Math.acos((ax * bx + ay * by) / (Math.sqrt(ax * ax + ay * ay) * Math.sqrt(bx * bx + by * by))) / 2), lc = Math.sqrt(oc[0] * oc[0] + oc[1] * oc[1]); + rc0 = Math.min(rc, (r0 - lc) / (kc - 1)); + rc1 = Math.min(rc, (r1 - lc) / (kc + 1)); + } + if (x1 != null) { + var t30 = d3_svg_arcCornerTangents(x3 == null ? [ x2, y2 ] : [ x3, y3 ], [ x0, y0 ], r1, rc1, cw), t12 = d3_svg_arcCornerTangents([ x1, y1 ], [ x2, y2 ], r1, rc1, cw); + if (rc === rc1) { + path.push("M", t30[0], "A", rc1, ",", rc1, " 0 0,", cr, " ", t30[1], "A", r1, ",", r1, " 0 ", 1 - cw ^ d3_svg_arcSweep(t30[1][0], t30[1][1], t12[1][0], t12[1][1]), ",", cw, " ", t12[1], "A", rc1, ",", rc1, " 0 0,", cr, " ", t12[0]); + } else { + path.push("M", t30[0], "A", rc1, ",", rc1, " 0 1,", cr, " ", t12[0]); + } + } else { + path.push("M", x0, ",", y0); + } + if (x3 != null) { + var t03 = d3_svg_arcCornerTangents([ x0, y0 ], [ x3, y3 ], r0, -rc0, cw), t21 = d3_svg_arcCornerTangents([ x2, y2 ], x1 == null ? [ x0, y0 ] : [ x1, y1 ], r0, -rc0, cw); + if (rc === rc0) { + path.push("L", t21[0], "A", rc0, ",", rc0, " 0 0,", cr, " ", t21[1], "A", r0, ",", r0, " 0 ", cw ^ d3_svg_arcSweep(t21[1][0], t21[1][1], t03[1][0], t03[1][1]), ",", 1 - cw, " ", t03[1], "A", rc0, ",", rc0, " 0 0,", cr, " ", t03[0]); + } else { + path.push("L", t21[0], "A", rc0, ",", rc0, " 0 0,", cr, " ", t03[0]); + } + } else { + path.push("L", x2, ",", y2); + } + } else { + path.push("M", x0, ",", y0); + if (x1 != null) path.push("A", r1, ",", r1, " 0 ", l1, ",", cw, " ", x1, ",", y1); + path.push("L", x2, ",", y2); + if (x3 != null) path.push("A", r0, ",", r0, " 0 ", l0, ",", 1 - cw, " ", x3, ",", y3); + } + path.push("Z"); + return path.join(""); + } + function circleSegment(r1, cw) { + return "M0," + r1 + "A" + r1 + "," + r1 + " 0 1," + cw + " 0," + -r1 + "A" + r1 + "," + r1 + " 0 1," + cw + " 0," + r1; + } + arc.innerRadius = function(v) { + if (!arguments.length) return innerRadius; + innerRadius = d3_functor(v); + return arc; + }; + arc.outerRadius = function(v) { + if (!arguments.length) return outerRadius; + outerRadius = d3_functor(v); + return arc; + }; + arc.cornerRadius = function(v) { + if (!arguments.length) return cornerRadius; + cornerRadius = d3_functor(v); + return arc; + }; + arc.padRadius = function(v) { + if (!arguments.length) return padRadius; + padRadius = v == d3_svg_arcAuto ? d3_svg_arcAuto : d3_functor(v); + return arc; + }; + arc.startAngle = function(v) { + if (!arguments.length) return startAngle; + startAngle = d3_functor(v); + return arc; + }; + arc.endAngle = function(v) { + if (!arguments.length) return endAngle; + endAngle = d3_functor(v); + return arc; + }; + arc.padAngle = function(v) { + if (!arguments.length) return padAngle; + padAngle = d3_functor(v); + return arc; + }; + arc.centroid = function() { + var r = (+innerRadius.apply(this, arguments) + +outerRadius.apply(this, arguments)) / 2, a = (+startAngle.apply(this, arguments) + +endAngle.apply(this, arguments)) / 2 - halfπ; + return [ Math.cos(a) * r, Math.sin(a) * r ]; + }; + return arc; + }; + var d3_svg_arcAuto = "auto"; + function d3_svg_arcInnerRadius(d) { + return d.innerRadius; + } + function d3_svg_arcOuterRadius(d) { + return d.outerRadius; + } + function d3_svg_arcStartAngle(d) { + return d.startAngle; + } + function d3_svg_arcEndAngle(d) { + return d.endAngle; + } + function d3_svg_arcPadAngle(d) { + return d && d.padAngle; + } + function d3_svg_arcSweep(x0, y0, x1, y1) { + return (x0 - x1) * y0 - (y0 - y1) * x0 > 0 ? 0 : 1; + } + function d3_svg_arcCornerTangents(p0, p1, r1, rc, cw) { + var x01 = p0[0] - p1[0], y01 = p0[1] - p1[1], lo = (cw ? rc : -rc) / Math.sqrt(x01 * x01 + y01 * y01), ox = lo * y01, oy = -lo * x01, x1 = p0[0] + ox, y1 = p0[1] + oy, x2 = p1[0] + ox, y2 = p1[1] + oy, x3 = (x1 + x2) / 2, y3 = (y1 + y2) / 2, dx = x2 - x1, dy = y2 - y1, d2 = dx * dx + dy * dy, r = r1 - rc, D = x1 * y2 - x2 * y1, d = (dy < 0 ? -1 : 1) * Math.sqrt(Math.max(0, r * r * d2 - D * D)), cx0 = (D * dy - dx * d) / d2, cy0 = (-D * dx - dy * d) / d2, cx1 = (D * dy + dx * d) / d2, cy1 = (-D * dx + dy * d) / d2, dx0 = cx0 - x3, dy0 = cy0 - y3, dx1 = cx1 - x3, dy1 = cy1 - y3; + if (dx0 * dx0 + dy0 * dy0 > dx1 * dx1 + dy1 * dy1) cx0 = cx1, cy0 = cy1; + return [ [ cx0 - ox, cy0 - oy ], [ cx0 * r1 / r, cy0 * r1 / r ] ]; + } + function d3_true() { + return true; + } + function d3_svg_line(projection) { + var x = d3_geom_pointX, y = d3_geom_pointY, defined = d3_true, interpolate = d3_svg_lineLinear, interpolateKey = interpolate.key, tension = .7; + function line(data) { + var segments = [], points = [], i = -1, n = data.length, d, fx = d3_functor(x), fy = d3_functor(y); + function segment() { + segments.push("M", interpolate(projection(points), tension)); + } + while (++i < n) { + if (defined.call(this, d = data[i], i)) { + points.push([ +fx.call(this, d, i), +fy.call(this, d, i) ]); + } else if (points.length) { + segment(); + points = []; + } + } + if (points.length) segment(); + return segments.length ? segments.join("") : null; + } + line.x = function(_) { + if (!arguments.length) return x; + x = _; + return line; + }; + line.y = function(_) { + if (!arguments.length) return y; + y = _; + return line; + }; + line.defined = function(_) { + if (!arguments.length) return defined; + defined = _; + return line; + }; + line.interpolate = function(_) { + if (!arguments.length) return interpolateKey; + if (typeof _ === "function") interpolateKey = interpolate = _; else interpolateKey = (interpolate = d3_svg_lineInterpolators.get(_) || d3_svg_lineLinear).key; + return line; + }; + line.tension = function(_) { + if (!arguments.length) return tension; + tension = _; + return line; + }; + return line; + } + d3.svg.line = function() { + return d3_svg_line(d3_identity); + }; + var d3_svg_lineInterpolators = d3.map({ + linear: d3_svg_lineLinear, + "linear-closed": d3_svg_lineLinearClosed, + step: d3_svg_lineStep, + "step-before": d3_svg_lineStepBefore, + "step-after": d3_svg_lineStepAfter, + basis: d3_svg_lineBasis, + "basis-open": d3_svg_lineBasisOpen, + "basis-closed": d3_svg_lineBasisClosed, + bundle: d3_svg_lineBundle, + cardinal: d3_svg_lineCardinal, + "cardinal-open": d3_svg_lineCardinalOpen, + "cardinal-closed": d3_svg_lineCardinalClosed, + monotone: d3_svg_lineMonotone + }); + d3_svg_lineInterpolators.forEach(function(key, value) { + value.key = key; + value.closed = /-closed$/.test(key); + }); + function d3_svg_lineLinear(points) { + return points.length > 1 ? points.join("L") : points + "Z"; + } + function d3_svg_lineLinearClosed(points) { + return points.join("L") + "Z"; + } + function d3_svg_lineStep(points) { + var i = 0, n = points.length, p = points[0], path = [ p[0], ",", p[1] ]; + while (++i < n) path.push("H", (p[0] + (p = points[i])[0]) / 2, "V", p[1]); + if (n > 1) path.push("H", p[0]); + return path.join(""); + } + function d3_svg_lineStepBefore(points) { + var i = 0, n = points.length, p = points[0], path = [ p[0], ",", p[1] ]; + while (++i < n) path.push("V", (p = points[i])[1], "H", p[0]); + return path.join(""); + } + function d3_svg_lineStepAfter(points) { + var i = 0, n = points.length, p = points[0], path = [ p[0], ",", p[1] ]; + while (++i < n) path.push("H", (p = points[i])[0], "V", p[1]); + return path.join(""); + } + function d3_svg_lineCardinalOpen(points, tension) { + return points.length < 4 ? d3_svg_lineLinear(points) : points[1] + d3_svg_lineHermite(points.slice(1, -1), d3_svg_lineCardinalTangents(points, tension)); + } + function d3_svg_lineCardinalClosed(points, tension) { + return points.length < 3 ? d3_svg_lineLinearClosed(points) : points[0] + d3_svg_lineHermite((points.push(points[0]), + points), d3_svg_lineCardinalTangents([ points[points.length - 2] ].concat(points, [ points[1] ]), tension)); + } + function d3_svg_lineCardinal(points, tension) { + return points.length < 3 ? d3_svg_lineLinear(points) : points[0] + d3_svg_lineHermite(points, d3_svg_lineCardinalTangents(points, tension)); + } + function d3_svg_lineHermite(points, tangents) { + if (tangents.length < 1 || points.length != tangents.length && points.length != tangents.length + 2) { + return d3_svg_lineLinear(points); + } + var quad = points.length != tangents.length, path = "", p0 = points[0], p = points[1], t0 = tangents[0], t = t0, pi = 1; + if (quad) { + path += "Q" + (p[0] - t0[0] * 2 / 3) + "," + (p[1] - t0[1] * 2 / 3) + "," + p[0] + "," + p[1]; + p0 = points[1]; + pi = 2; + } + if (tangents.length > 1) { + t = tangents[1]; + p = points[pi]; + pi++; + path += "C" + (p0[0] + t0[0]) + "," + (p0[1] + t0[1]) + "," + (p[0] - t[0]) + "," + (p[1] - t[1]) + "," + p[0] + "," + p[1]; + for (var i = 2; i < tangents.length; i++, pi++) { + p = points[pi]; + t = tangents[i]; + path += "S" + (p[0] - t[0]) + "," + (p[1] - t[1]) + "," + p[0] + "," + p[1]; + } + } + if (quad) { + var lp = points[pi]; + path += "Q" + (p[0] + t[0] * 2 / 3) + "," + (p[1] + t[1] * 2 / 3) + "," + lp[0] + "," + lp[1]; + } + return path; + } + function d3_svg_lineCardinalTangents(points, tension) { + var tangents = [], a = (1 - tension) / 2, p0, p1 = points[0], p2 = points[1], i = 1, n = points.length; + while (++i < n) { + p0 = p1; + p1 = p2; + p2 = points[i]; + tangents.push([ a * (p2[0] - p0[0]), a * (p2[1] - p0[1]) ]); + } + return tangents; + } + function d3_svg_lineBasis(points) { + if (points.length < 3) return d3_svg_lineLinear(points); + var i = 1, n = points.length, pi = points[0], x0 = pi[0], y0 = pi[1], px = [ x0, x0, x0, (pi = points[1])[0] ], py = [ y0, y0, y0, pi[1] ], path = [ x0, ",", y0, "L", d3_svg_lineDot4(d3_svg_lineBasisBezier3, px), ",", d3_svg_lineDot4(d3_svg_lineBasisBezier3, py) ]; + points.push(points[n - 1]); + while (++i <= n) { + pi = points[i]; + px.shift(); + px.push(pi[0]); + py.shift(); + py.push(pi[1]); + d3_svg_lineBasisBezier(path, px, py); + } + points.pop(); + path.push("L", pi); + return path.join(""); + } + function d3_svg_lineBasisOpen(points) { + if (points.length < 4) return d3_svg_lineLinear(points); + var path = [], i = -1, n = points.length, pi, px = [ 0 ], py = [ 0 ]; + while (++i < 3) { + pi = points[i]; + px.push(pi[0]); + py.push(pi[1]); + } + path.push(d3_svg_lineDot4(d3_svg_lineBasisBezier3, px) + "," + d3_svg_lineDot4(d3_svg_lineBasisBezier3, py)); + --i; + while (++i < n) { + pi = points[i]; + px.shift(); + px.push(pi[0]); + py.shift(); + py.push(pi[1]); + d3_svg_lineBasisBezier(path, px, py); + } + return path.join(""); + } + function d3_svg_lineBasisClosed(points) { + var path, i = -1, n = points.length, m = n + 4, pi, px = [], py = []; + while (++i < 4) { + pi = points[i % n]; + px.push(pi[0]); + py.push(pi[1]); + } + path = [ d3_svg_lineDot4(d3_svg_lineBasisBezier3, px), ",", d3_svg_lineDot4(d3_svg_lineBasisBezier3, py) ]; + --i; + while (++i < m) { + pi = points[i % n]; + px.shift(); + px.push(pi[0]); + py.shift(); + py.push(pi[1]); + d3_svg_lineBasisBezier(path, px, py); + } + return path.join(""); + } + function d3_svg_lineBundle(points, tension) { + var n = points.length - 1; + if (n) { + var x0 = points[0][0], y0 = points[0][1], dx = points[n][0] - x0, dy = points[n][1] - y0, i = -1, p, t; + while (++i <= n) { + p = points[i]; + t = i / n; + p[0] = tension * p[0] + (1 - tension) * (x0 + t * dx); + p[1] = tension * p[1] + (1 - tension) * (y0 + t * dy); + } + } + return d3_svg_lineBasis(points); + } + function d3_svg_lineDot4(a, b) { + return a[0] * b[0] + a[1] * b[1] + a[2] * b[2] + a[3] * b[3]; + } + var d3_svg_lineBasisBezier1 = [ 0, 2 / 3, 1 / 3, 0 ], d3_svg_lineBasisBezier2 = [ 0, 1 / 3, 2 / 3, 0 ], d3_svg_lineBasisBezier3 = [ 0, 1 / 6, 2 / 3, 1 / 6 ]; + function d3_svg_lineBasisBezier(path, x, y) { + path.push("C", d3_svg_lineDot4(d3_svg_lineBasisBezier1, x), ",", d3_svg_lineDot4(d3_svg_lineBasisBezier1, y), ",", d3_svg_lineDot4(d3_svg_lineBasisBezier2, x), ",", d3_svg_lineDot4(d3_svg_lineBasisBezier2, y), ",", d3_svg_lineDot4(d3_svg_lineBasisBezier3, x), ",", d3_svg_lineDot4(d3_svg_lineBasisBezier3, y)); + } + function d3_svg_lineSlope(p0, p1) { + return (p1[1] - p0[1]) / (p1[0] - p0[0]); + } + function d3_svg_lineFiniteDifferences(points) { + var i = 0, j = points.length - 1, m = [], p0 = points[0], p1 = points[1], d = m[0] = d3_svg_lineSlope(p0, p1); + while (++i < j) { + m[i] = (d + (d = d3_svg_lineSlope(p0 = p1, p1 = points[i + 1]))) / 2; + } + m[i] = d; + return m; + } + function d3_svg_lineMonotoneTangents(points) { + var tangents = [], d, a, b, s, m = d3_svg_lineFiniteDifferences(points), i = -1, j = points.length - 1; + while (++i < j) { + d = d3_svg_lineSlope(points[i], points[i + 1]); + if (abs(d) < ε) { + m[i] = m[i + 1] = 0; + } else { + a = m[i] / d; + b = m[i + 1] / d; + s = a * a + b * b; + if (s > 9) { + s = d * 3 / Math.sqrt(s); + m[i] = s * a; + m[i + 1] = s * b; + } + } + } + i = -1; + while (++i <= j) { + s = (points[Math.min(j, i + 1)][0] - points[Math.max(0, i - 1)][0]) / (6 * (1 + m[i] * m[i])); + tangents.push([ s || 0, m[i] * s || 0 ]); + } + return tangents; + } + function d3_svg_lineMonotone(points) { + return points.length < 3 ? d3_svg_lineLinear(points) : points[0] + d3_svg_lineHermite(points, d3_svg_lineMonotoneTangents(points)); + } + d3.svg.line.radial = function() { + var line = d3_svg_line(d3_svg_lineRadial); + line.radius = line.x, delete line.x; + line.angle = line.y, delete line.y; + return line; + }; + function d3_svg_lineRadial(points) { + var point, i = -1, n = points.length, r, a; + while (++i < n) { + point = points[i]; + r = point[0]; + a = point[1] - halfπ; + point[0] = r * Math.cos(a); + point[1] = r * Math.sin(a); + } + return points; + } + function d3_svg_area(projection) { + var x0 = d3_geom_pointX, x1 = d3_geom_pointX, y0 = 0, y1 = d3_geom_pointY, defined = d3_true, interpolate = d3_svg_lineLinear, interpolateKey = interpolate.key, interpolateReverse = interpolate, L = "L", tension = .7; + function area(data) { + var segments = [], points0 = [], points1 = [], i = -1, n = data.length, d, fx0 = d3_functor(x0), fy0 = d3_functor(y0), fx1 = x0 === x1 ? function() { + return x; + } : d3_functor(x1), fy1 = y0 === y1 ? function() { + return y; + } : d3_functor(y1), x, y; + function segment() { + segments.push("M", interpolate(projection(points1), tension), L, interpolateReverse(projection(points0.reverse()), tension), "Z"); + } + while (++i < n) { + if (defined.call(this, d = data[i], i)) { + points0.push([ x = +fx0.call(this, d, i), y = +fy0.call(this, d, i) ]); + points1.push([ +fx1.call(this, d, i), +fy1.call(this, d, i) ]); + } else if (points0.length) { + segment(); + points0 = []; + points1 = []; + } + } + if (points0.length) segment(); + return segments.length ? segments.join("") : null; + } + area.x = function(_) { + if (!arguments.length) return x1; + x0 = x1 = _; + return area; + }; + area.x0 = function(_) { + if (!arguments.length) return x0; + x0 = _; + return area; + }; + area.x1 = function(_) { + if (!arguments.length) return x1; + x1 = _; + return area; + }; + area.y = function(_) { + if (!arguments.length) return y1; + y0 = y1 = _; + return area; + }; + area.y0 = function(_) { + if (!arguments.length) return y0; + y0 = _; + return area; + }; + area.y1 = function(_) { + if (!arguments.length) return y1; + y1 = _; + return area; + }; + area.defined = function(_) { + if (!arguments.length) return defined; + defined = _; + return area; + }; + area.interpolate = function(_) { + if (!arguments.length) return interpolateKey; + if (typeof _ === "function") interpolateKey = interpolate = _; else interpolateKey = (interpolate = d3_svg_lineInterpolators.get(_) || d3_svg_lineLinear).key; + interpolateReverse = interpolate.reverse || interpolate; + L = interpolate.closed ? "M" : "L"; + return area; + }; + area.tension = function(_) { + if (!arguments.length) return tension; + tension = _; + return area; + }; + return area; + } + d3_svg_lineStepBefore.reverse = d3_svg_lineStepAfter; + d3_svg_lineStepAfter.reverse = d3_svg_lineStepBefore; + d3.svg.area = function() { + return d3_svg_area(d3_identity); + }; + d3.svg.area.radial = function() { + var area = d3_svg_area(d3_svg_lineRadial); + area.radius = area.x, delete area.x; + area.innerRadius = area.x0, delete area.x0; + area.outerRadius = area.x1, delete area.x1; + area.angle = area.y, delete area.y; + area.startAngle = area.y0, delete area.y0; + area.endAngle = area.y1, delete area.y1; + return area; + }; + function d3_source(d) { + return d.source; + } + function d3_target(d) { + return d.target; + } + d3.svg.chord = function() { + var source = d3_source, target = d3_target, radius = d3_svg_chordRadius, startAngle = d3_svg_arcStartAngle, endAngle = d3_svg_arcEndAngle; + function chord(d, i) { + var s = subgroup(this, source, d, i), t = subgroup(this, target, d, i); + return "M" + s.p0 + arc(s.r, s.p1, s.a1 - s.a0) + (equals(s, t) ? curve(s.r, s.p1, s.r, s.p0) : curve(s.r, s.p1, t.r, t.p0) + arc(t.r, t.p1, t.a1 - t.a0) + curve(t.r, t.p1, s.r, s.p0)) + "Z"; + } + function subgroup(self, f, d, i) { + var subgroup = f.call(self, d, i), r = radius.call(self, subgroup, i), a0 = startAngle.call(self, subgroup, i) - halfπ, a1 = endAngle.call(self, subgroup, i) - halfπ; + return { + r: r, + a0: a0, + a1: a1, + p0: [ r * Math.cos(a0), r * Math.sin(a0) ], + p1: [ r * Math.cos(a1), r * Math.sin(a1) ] + }; + } + function equals(a, b) { + return a.a0 == b.a0 && a.a1 == b.a1; + } + function arc(r, p, a) { + return "A" + r + "," + r + " 0 " + +(a > π) + ",1 " + p; + } + function curve(r0, p0, r1, p1) { + return "Q 0,0 " + p1; + } + chord.radius = function(v) { + if (!arguments.length) return radius; + radius = d3_functor(v); + return chord; + }; + chord.source = function(v) { + if (!arguments.length) return source; + source = d3_functor(v); + return chord; + }; + chord.target = function(v) { + if (!arguments.length) return target; + target = d3_functor(v); + return chord; + }; + chord.startAngle = function(v) { + if (!arguments.length) return startAngle; + startAngle = d3_functor(v); + return chord; + }; + chord.endAngle = function(v) { + if (!arguments.length) return endAngle; + endAngle = d3_functor(v); + return chord; + }; + return chord; + }; + function d3_svg_chordRadius(d) { + return d.radius; + } + d3.svg.diagonal = function() { + var source = d3_source, target = d3_target, projection = d3_svg_diagonalProjection; + function diagonal(d, i) { + var p0 = source.call(this, d, i), p3 = target.call(this, d, i), m = (p0.y + p3.y) / 2, p = [ p0, { + x: p0.x, + y: m + }, { + x: p3.x, + y: m + }, p3 ]; + p = p.map(projection); + return "M" + p[0] + "C" + p[1] + " " + p[2] + " " + p[3]; + } + diagonal.source = function(x) { + if (!arguments.length) return source; + source = d3_functor(x); + return diagonal; + }; + diagonal.target = function(x) { + if (!arguments.length) return target; + target = d3_functor(x); + return diagonal; + }; + diagonal.projection = function(x) { + if (!arguments.length) return projection; + projection = x; + return diagonal; + }; + return diagonal; + }; + function d3_svg_diagonalProjection(d) { + return [ d.x, d.y ]; + } + d3.svg.diagonal.radial = function() { + var diagonal = d3.svg.diagonal(), projection = d3_svg_diagonalProjection, projection_ = diagonal.projection; + diagonal.projection = function(x) { + return arguments.length ? projection_(d3_svg_diagonalRadialProjection(projection = x)) : projection; + }; + return diagonal; + }; + function d3_svg_diagonalRadialProjection(projection) { + return function() { + var d = projection.apply(this, arguments), r = d[0], a = d[1] - halfπ; + return [ r * Math.cos(a), r * Math.sin(a) ]; + }; + } + d3.svg.symbol = function() { + var type = d3_svg_symbolType, size = d3_svg_symbolSize; + function symbol(d, i) { + return (d3_svg_symbols.get(type.call(this, d, i)) || d3_svg_symbolCircle)(size.call(this, d, i)); + } + symbol.type = function(x) { + if (!arguments.length) return type; + type = d3_functor(x); + return symbol; + }; + symbol.size = function(x) { + if (!arguments.length) return size; + size = d3_functor(x); + return symbol; + }; + return symbol; + }; + function d3_svg_symbolSize() { + return 64; + } + function d3_svg_symbolType() { + return "circle"; + } + function d3_svg_symbolCircle(size) { + var r = Math.sqrt(size / π); + return "M0," + r + "A" + r + "," + r + " 0 1,1 0," + -r + "A" + r + "," + r + " 0 1,1 0," + r + "Z"; + } + var d3_svg_symbols = d3.map({ + circle: d3_svg_symbolCircle, + cross: function(size) { + var r = Math.sqrt(size / 5) / 2; + return "M" + -3 * r + "," + -r + "H" + -r + "V" + -3 * r + "H" + r + "V" + -r + "H" + 3 * r + "V" + r + "H" + r + "V" + 3 * r + "H" + -r + "V" + r + "H" + -3 * r + "Z"; + }, + diamond: function(size) { + var ry = Math.sqrt(size / (2 * d3_svg_symbolTan30)), rx = ry * d3_svg_symbolTan30; + return "M0," + -ry + "L" + rx + ",0" + " 0," + ry + " " + -rx + ",0" + "Z"; + }, + square: function(size) { + var r = Math.sqrt(size) / 2; + return "M" + -r + "," + -r + "L" + r + "," + -r + " " + r + "," + r + " " + -r + "," + r + "Z"; + }, + "triangle-down": function(size) { + var rx = Math.sqrt(size / d3_svg_symbolSqrt3), ry = rx * d3_svg_symbolSqrt3 / 2; + return "M0," + ry + "L" + rx + "," + -ry + " " + -rx + "," + -ry + "Z"; + }, + "triangle-up": function(size) { + var rx = Math.sqrt(size / d3_svg_symbolSqrt3), ry = rx * d3_svg_symbolSqrt3 / 2; + return "M0," + -ry + "L" + rx + "," + ry + " " + -rx + "," + ry + "Z"; + } + }); + d3.svg.symbolTypes = d3_svg_symbols.keys(); + var d3_svg_symbolSqrt3 = Math.sqrt(3), d3_svg_symbolTan30 = Math.tan(30 * d3_radians); + d3_selectionPrototype.transition = function(name) { + var id = d3_transitionInheritId || ++d3_transitionId, ns = d3_transitionNamespace(name), subgroups = [], subgroup, node, transition = d3_transitionInherit || { + time: Date.now(), + ease: d3_ease_cubicInOut, + delay: 0, + duration: 250 + }; + for (var j = -1, m = this.length; ++j < m; ) { + subgroups.push(subgroup = []); + for (var group = this[j], i = -1, n = group.length; ++i < n; ) { + if (node = group[i]) d3_transitionNode(node, i, ns, id, transition); + subgroup.push(node); + } + } + return d3_transition(subgroups, ns, id); + }; + d3_selectionPrototype.interrupt = function(name) { + return this.each(name == null ? d3_selection_interrupt : d3_selection_interruptNS(d3_transitionNamespace(name))); + }; + var d3_selection_interrupt = d3_selection_interruptNS(d3_transitionNamespace()); + function d3_selection_interruptNS(ns) { + return function() { + var lock, activeId, active; + if ((lock = this[ns]) && (active = lock[activeId = lock.active])) { + active.timer.c = null; + active.timer.t = NaN; + if (--lock.count) delete lock[activeId]; else delete this[ns]; + lock.active += .5; + active.event && active.event.interrupt.call(this, this.__data__, active.index); + } + }; + } + function d3_transition(groups, ns, id) { + d3_subclass(groups, d3_transitionPrototype); + groups.namespace = ns; + groups.id = id; + return groups; + } + var d3_transitionPrototype = [], d3_transitionId = 0, d3_transitionInheritId, d3_transitionInherit; + d3_transitionPrototype.call = d3_selectionPrototype.call; + d3_transitionPrototype.empty = d3_selectionPrototype.empty; + d3_transitionPrototype.node = d3_selectionPrototype.node; + d3_transitionPrototype.size = d3_selectionPrototype.size; + d3.transition = function(selection, name) { + return selection && selection.transition ? d3_transitionInheritId ? selection.transition(name) : selection : d3.selection().transition(selection); + }; + d3.transition.prototype = d3_transitionPrototype; + d3_transitionPrototype.select = function(selector) { + var id = this.id, ns = this.namespace, subgroups = [], subgroup, subnode, node; + selector = d3_selection_selector(selector); + for (var j = -1, m = this.length; ++j < m; ) { + subgroups.push(subgroup = []); + for (var group = this[j], i = -1, n = group.length; ++i < n; ) { + if ((node = group[i]) && (subnode = selector.call(node, node.__data__, i, j))) { + if ("__data__" in node) subnode.__data__ = node.__data__; + d3_transitionNode(subnode, i, ns, id, node[ns][id]); + subgroup.push(subnode); + } else { + subgroup.push(null); + } + } + } + return d3_transition(subgroups, ns, id); + }; + d3_transitionPrototype.selectAll = function(selector) { + var id = this.id, ns = this.namespace, subgroups = [], subgroup, subnodes, node, subnode, transition; + selector = d3_selection_selectorAll(selector); + for (var j = -1, m = this.length; ++j < m; ) { + for (var group = this[j], i = -1, n = group.length; ++i < n; ) { + if (node = group[i]) { + transition = node[ns][id]; + subnodes = selector.call(node, node.__data__, i, j); + subgroups.push(subgroup = []); + for (var k = -1, o = subnodes.length; ++k < o; ) { + if (subnode = subnodes[k]) d3_transitionNode(subnode, k, ns, id, transition); + subgroup.push(subnode); + } + } + } + } + return d3_transition(subgroups, ns, id); + }; + d3_transitionPrototype.filter = function(filter) { + var subgroups = [], subgroup, group, node; + if (typeof filter !== "function") filter = d3_selection_filter(filter); + for (var j = 0, m = this.length; j < m; j++) { + subgroups.push(subgroup = []); + for (var group = this[j], i = 0, n = group.length; i < n; i++) { + if ((node = group[i]) && filter.call(node, node.__data__, i, j)) { + subgroup.push(node); + } + } + } + return d3_transition(subgroups, this.namespace, this.id); + }; + d3_transitionPrototype.tween = function(name, tween) { + var id = this.id, ns = this.namespace; + if (arguments.length < 2) return this.node()[ns][id].tween.get(name); + return d3_selection_each(this, tween == null ? function(node) { + node[ns][id].tween.remove(name); + } : function(node) { + node[ns][id].tween.set(name, tween); + }); + }; + function d3_transition_tween(groups, name, value, tween) { + var id = groups.id, ns = groups.namespace; + return d3_selection_each(groups, typeof value === "function" ? function(node, i, j) { + node[ns][id].tween.set(name, tween(value.call(node, node.__data__, i, j))); + } : (value = tween(value), function(node) { + node[ns][id].tween.set(name, value); + })); + } + d3_transitionPrototype.attr = function(nameNS, value) { + if (arguments.length < 2) { + for (value in nameNS) this.attr(value, nameNS[value]); + return this; + } + var interpolate = nameNS == "transform" ? d3_interpolateTransform : d3_interpolate, name = d3.ns.qualify(nameNS); + function attrNull() { + this.removeAttribute(name); + } + function attrNullNS() { + this.removeAttributeNS(name.space, name.local); + } + function attrTween(b) { + return b == null ? attrNull : (b += "", function() { + var a = this.getAttribute(name), i; + return a !== b && (i = interpolate(a, b), function(t) { + this.setAttribute(name, i(t)); + }); + }); + } + function attrTweenNS(b) { + return b == null ? attrNullNS : (b += "", function() { + var a = this.getAttributeNS(name.space, name.local), i; + return a !== b && (i = interpolate(a, b), function(t) { + this.setAttributeNS(name.space, name.local, i(t)); + }); + }); + } + return d3_transition_tween(this, "attr." + nameNS, value, name.local ? attrTweenNS : attrTween); + }; + d3_transitionPrototype.attrTween = function(nameNS, tween) { + var name = d3.ns.qualify(nameNS); + function attrTween(d, i) { + var f = tween.call(this, d, i, this.getAttribute(name)); + return f && function(t) { + this.setAttribute(name, f(t)); + }; + } + function attrTweenNS(d, i) { + var f = tween.call(this, d, i, this.getAttributeNS(name.space, name.local)); + return f && function(t) { + this.setAttributeNS(name.space, name.local, f(t)); + }; + } + return this.tween("attr." + nameNS, name.local ? attrTweenNS : attrTween); + }; + d3_transitionPrototype.style = function(name, value, priority) { + var n = arguments.length; + if (n < 3) { + if (typeof name !== "string") { + if (n < 2) value = ""; + for (priority in name) this.style(priority, name[priority], value); + return this; + } + priority = ""; + } + function styleNull() { + this.style.removeProperty(name); + } + function styleString(b) { + return b == null ? styleNull : (b += "", function() { + var a = d3_window(this).getComputedStyle(this, null).getPropertyValue(name), i; + return a !== b && (i = d3_interpolate(a, b), function(t) { + this.style.setProperty(name, i(t), priority); + }); + }); + } + return d3_transition_tween(this, "style." + name, value, styleString); + }; + d3_transitionPrototype.styleTween = function(name, tween, priority) { + if (arguments.length < 3) priority = ""; + function styleTween(d, i) { + var f = tween.call(this, d, i, d3_window(this).getComputedStyle(this, null).getPropertyValue(name)); + return f && function(t) { + this.style.setProperty(name, f(t), priority); + }; + } + return this.tween("style." + name, styleTween); + }; + d3_transitionPrototype.text = function(value) { + return d3_transition_tween(this, "text", value, d3_transition_text); + }; + function d3_transition_text(b) { + if (b == null) b = ""; + return function() { + this.textContent = b; + }; + } + d3_transitionPrototype.remove = function() { + var ns = this.namespace; + return this.each("end.transition", function() { + var p; + if (this[ns].count < 2 && (p = this.parentNode)) p.removeChild(this); + }); + }; + d3_transitionPrototype.ease = function(value) { + var id = this.id, ns = this.namespace; + if (arguments.length < 1) return this.node()[ns][id].ease; + if (typeof value !== "function") value = d3.ease.apply(d3, arguments); + return d3_selection_each(this, function(node) { + node[ns][id].ease = value; + }); + }; + d3_transitionPrototype.delay = function(value) { + var id = this.id, ns = this.namespace; + if (arguments.length < 1) return this.node()[ns][id].delay; + return d3_selection_each(this, typeof value === "function" ? function(node, i, j) { + node[ns][id].delay = +value.call(node, node.__data__, i, j); + } : (value = +value, function(node) { + node[ns][id].delay = value; + })); + }; + d3_transitionPrototype.duration = function(value) { + var id = this.id, ns = this.namespace; + if (arguments.length < 1) return this.node()[ns][id].duration; + return d3_selection_each(this, typeof value === "function" ? function(node, i, j) { + node[ns][id].duration = Math.max(1, value.call(node, node.__data__, i, j)); + } : (value = Math.max(1, value), function(node) { + node[ns][id].duration = value; + })); + }; + d3_transitionPrototype.each = function(type, listener) { + var id = this.id, ns = this.namespace; + if (arguments.length < 2) { + var inherit = d3_transitionInherit, inheritId = d3_transitionInheritId; + try { + d3_transitionInheritId = id; + d3_selection_each(this, function(node, i, j) { + d3_transitionInherit = node[ns][id]; + type.call(node, node.__data__, i, j); + }); + } finally { + d3_transitionInherit = inherit; + d3_transitionInheritId = inheritId; + } + } else { + d3_selection_each(this, function(node) { + var transition = node[ns][id]; + (transition.event || (transition.event = d3.dispatch("start", "end", "interrupt"))).on(type, listener); + }); + } + return this; + }; + d3_transitionPrototype.transition = function() { + var id0 = this.id, id1 = ++d3_transitionId, ns = this.namespace, subgroups = [], subgroup, group, node, transition; + for (var j = 0, m = this.length; j < m; j++) { + subgroups.push(subgroup = []); + for (var group = this[j], i = 0, n = group.length; i < n; i++) { + if (node = group[i]) { + transition = node[ns][id0]; + d3_transitionNode(node, i, ns, id1, { + time: transition.time, + ease: transition.ease, + delay: transition.delay + transition.duration, + duration: transition.duration + }); + } + subgroup.push(node); + } + } + return d3_transition(subgroups, ns, id1); + }; + function d3_transitionNamespace(name) { + return name == null ? "__transition__" : "__transition_" + name + "__"; + } + function d3_transitionNode(node, i, ns, id, inherit) { + var lock = node[ns] || (node[ns] = { + active: 0, + count: 0 + }), transition = lock[id], time, timer, duration, ease, tweens; + function schedule(elapsed) { + var delay = transition.delay; + timer.t = delay + time; + if (delay <= elapsed) return start(elapsed - delay); + timer.c = start; + } + function start(elapsed) { + var activeId = lock.active, active = lock[activeId]; + if (active) { + active.timer.c = null; + active.timer.t = NaN; + --lock.count; + delete lock[activeId]; + active.event && active.event.interrupt.call(node, node.__data__, active.index); + } + for (var cancelId in lock) { + if (+cancelId < id) { + var cancel = lock[cancelId]; + cancel.timer.c = null; + cancel.timer.t = NaN; + --lock.count; + delete lock[cancelId]; + } + } + timer.c = tick; + d3_timer(function() { + if (timer.c && tick(elapsed || 1)) { + timer.c = null; + timer.t = NaN; + } + return 1; + }, 0, time); + lock.active = id; + transition.event && transition.event.start.call(node, node.__data__, i); + tweens = []; + transition.tween.forEach(function(key, value) { + if (value = value.call(node, node.__data__, i)) { + tweens.push(value); + } + }); + ease = transition.ease; + duration = transition.duration; + } + function tick(elapsed) { + var t = elapsed / duration, e = ease(t), n = tweens.length; + while (n > 0) { + tweens[--n].call(node, e); + } + if (t >= 1) { + transition.event && transition.event.end.call(node, node.__data__, i); + if (--lock.count) delete lock[id]; else delete node[ns]; + return 1; + } + } + if (!transition) { + time = inherit.time; + timer = d3_timer(schedule, 0, time); + transition = lock[id] = { + tween: new d3_Map(), + time: time, + timer: timer, + delay: inherit.delay, + duration: inherit.duration, + ease: inherit.ease, + index: i + }; + inherit = null; + ++lock.count; + } + } + d3.svg.axis = function() { + var scale = d3.scale.linear(), orient = d3_svg_axisDefaultOrient, innerTickSize = 6, outerTickSize = 6, tickPadding = 3, tickArguments_ = [ 10 ], tickValues = null, tickFormat_; + function axis(g) { + g.each(function() { + var g = d3.select(this); + var scale0 = this.__chart__ || scale, scale1 = this.__chart__ = scale.copy(); + var ticks = tickValues == null ? scale1.ticks ? scale1.ticks.apply(scale1, tickArguments_) : scale1.domain() : tickValues, tickFormat = tickFormat_ == null ? scale1.tickFormat ? scale1.tickFormat.apply(scale1, tickArguments_) : d3_identity : tickFormat_, tick = g.selectAll(".tick").data(ticks, scale1), tickEnter = tick.enter().insert("g", ".domain").attr("class", "tick").style("opacity", ε), tickExit = d3.transition(tick.exit()).style("opacity", ε).remove(), tickUpdate = d3.transition(tick.order()).style("opacity", 1), tickSpacing = Math.max(innerTickSize, 0) + tickPadding, tickTransform; + var range = d3_scaleRange(scale1), path = g.selectAll(".domain").data([ 0 ]), pathUpdate = (path.enter().append("path").attr("class", "domain"), + d3.transition(path)); + tickEnter.append("line"); + tickEnter.append("text"); + var lineEnter = tickEnter.select("line"), lineUpdate = tickUpdate.select("line"), text = tick.select("text").text(tickFormat), textEnter = tickEnter.select("text"), textUpdate = tickUpdate.select("text"), sign = orient === "top" || orient === "left" ? -1 : 1, x1, x2, y1, y2; + if (orient === "bottom" || orient === "top") { + tickTransform = d3_svg_axisX, x1 = "x", y1 = "y", x2 = "x2", y2 = "y2"; + text.attr("dy", sign < 0 ? "0em" : ".71em").style("text-anchor", "middle"); + pathUpdate.attr("d", "M" + range[0] + "," + sign * outerTickSize + "V0H" + range[1] + "V" + sign * outerTickSize); + } else { + tickTransform = d3_svg_axisY, x1 = "y", y1 = "x", x2 = "y2", y2 = "x2"; + text.attr("dy", ".32em").style("text-anchor", sign < 0 ? "end" : "start"); + pathUpdate.attr("d", "M" + sign * outerTickSize + "," + range[0] + "H0V" + range[1] + "H" + sign * outerTickSize); + } + lineEnter.attr(y2, sign * innerTickSize); + textEnter.attr(y1, sign * tickSpacing); + lineUpdate.attr(x2, 0).attr(y2, sign * innerTickSize); + textUpdate.attr(x1, 0).attr(y1, sign * tickSpacing); + if (scale1.rangeBand) { + var x = scale1, dx = x.rangeBand() / 2; + scale0 = scale1 = function(d) { + return x(d) + dx; + }; + } else if (scale0.rangeBand) { + scale0 = scale1; + } else { + tickExit.call(tickTransform, scale1, scale0); + } + tickEnter.call(tickTransform, scale0, scale1); + tickUpdate.call(tickTransform, scale1, scale1); + }); + } + axis.scale = function(x) { + if (!arguments.length) return scale; + scale = x; + return axis; + }; + axis.orient = function(x) { + if (!arguments.length) return orient; + orient = x in d3_svg_axisOrients ? x + "" : d3_svg_axisDefaultOrient; + return axis; + }; + axis.ticks = function() { + if (!arguments.length) return tickArguments_; + tickArguments_ = d3_array(arguments); + return axis; + }; + axis.tickValues = function(x) { + if (!arguments.length) return tickValues; + tickValues = x; + return axis; + }; + axis.tickFormat = function(x) { + if (!arguments.length) return tickFormat_; + tickFormat_ = x; + return axis; + }; + axis.tickSize = function(x) { + var n = arguments.length; + if (!n) return innerTickSize; + innerTickSize = +x; + outerTickSize = +arguments[n - 1]; + return axis; + }; + axis.innerTickSize = function(x) { + if (!arguments.length) return innerTickSize; + innerTickSize = +x; + return axis; + }; + axis.outerTickSize = function(x) { + if (!arguments.length) return outerTickSize; + outerTickSize = +x; + return axis; + }; + axis.tickPadding = function(x) { + if (!arguments.length) return tickPadding; + tickPadding = +x; + return axis; + }; + axis.tickSubdivide = function() { + return arguments.length && axis; + }; + return axis; + }; + var d3_svg_axisDefaultOrient = "bottom", d3_svg_axisOrients = { + top: 1, + right: 1, + bottom: 1, + left: 1 + }; + function d3_svg_axisX(selection, x0, x1) { + selection.attr("transform", function(d) { + var v0 = x0(d); + return "translate(" + (isFinite(v0) ? v0 : x1(d)) + ",0)"; + }); + } + function d3_svg_axisY(selection, y0, y1) { + selection.attr("transform", function(d) { + var v0 = y0(d); + return "translate(0," + (isFinite(v0) ? v0 : y1(d)) + ")"; + }); + } + d3.svg.brush = function() { + var event = d3_eventDispatch(brush, "brushstart", "brush", "brushend"), x = null, y = null, xExtent = [ 0, 0 ], yExtent = [ 0, 0 ], xExtentDomain, yExtentDomain, xClamp = true, yClamp = true, resizes = d3_svg_brushResizes[0]; + function brush(g) { + g.each(function() { + var g = d3.select(this).style("pointer-events", "all").style("-webkit-tap-highlight-color", "rgba(0,0,0,0)").on("mousedown.brush", brushstart).on("touchstart.brush", brushstart); + var background = g.selectAll(".background").data([ 0 ]); + background.enter().append("rect").attr("class", "background").style("visibility", "hidden").style("cursor", "crosshair"); + g.selectAll(".extent").data([ 0 ]).enter().append("rect").attr("class", "extent").style("cursor", "move"); + var resize = g.selectAll(".resize").data(resizes, d3_identity); + resize.exit().remove(); + resize.enter().append("g").attr("class", function(d) { + return "resize " + d; + }).style("cursor", function(d) { + return d3_svg_brushCursor[d]; + }).append("rect").attr("x", function(d) { + return /[ew]$/.test(d) ? -3 : null; + }).attr("y", function(d) { + return /^[ns]/.test(d) ? -3 : null; + }).attr("width", 6).attr("height", 6).style("visibility", "hidden"); + resize.style("display", brush.empty() ? "none" : null); + var gUpdate = d3.transition(g), backgroundUpdate = d3.transition(background), range; + if (x) { + range = d3_scaleRange(x); + backgroundUpdate.attr("x", range[0]).attr("width", range[1] - range[0]); + redrawX(gUpdate); + } + if (y) { + range = d3_scaleRange(y); + backgroundUpdate.attr("y", range[0]).attr("height", range[1] - range[0]); + redrawY(gUpdate); + } + redraw(gUpdate); + }); + } + brush.event = function(g) { + g.each(function() { + var event_ = event.of(this, arguments), extent1 = { + x: xExtent, + y: yExtent, + i: xExtentDomain, + j: yExtentDomain + }, extent0 = this.__chart__ || extent1; + this.__chart__ = extent1; + if (d3_transitionInheritId) { + d3.select(this).transition().each("start.brush", function() { + xExtentDomain = extent0.i; + yExtentDomain = extent0.j; + xExtent = extent0.x; + yExtent = extent0.y; + event_({ + type: "brushstart" + }); + }).tween("brush:brush", function() { + var xi = d3_interpolateArray(xExtent, extent1.x), yi = d3_interpolateArray(yExtent, extent1.y); + xExtentDomain = yExtentDomain = null; + return function(t) { + xExtent = extent1.x = xi(t); + yExtent = extent1.y = yi(t); + event_({ + type: "brush", + mode: "resize" + }); + }; + }).each("end.brush", function() { + xExtentDomain = extent1.i; + yExtentDomain = extent1.j; + event_({ + type: "brush", + mode: "resize" + }); + event_({ + type: "brushend" + }); + }); + } else { + event_({ + type: "brushstart" + }); + event_({ + type: "brush", + mode: "resize" + }); + event_({ + type: "brushend" + }); + } + }); + }; + function redraw(g) { + g.selectAll(".resize").attr("transform", function(d) { + return "translate(" + xExtent[+/e$/.test(d)] + "," + yExtent[+/^s/.test(d)] + ")"; + }); + } + function redrawX(g) { + g.select(".extent").attr("x", xExtent[0]); + g.selectAll(".extent,.n>rect,.s>rect").attr("width", xExtent[1] - xExtent[0]); + } + function redrawY(g) { + g.select(".extent").attr("y", yExtent[0]); + g.selectAll(".extent,.e>rect,.w>rect").attr("height", yExtent[1] - yExtent[0]); + } + function brushstart() { + var target = this, eventTarget = d3.select(d3.event.target), event_ = event.of(target, arguments), g = d3.select(target), resizing = eventTarget.datum(), resizingX = !/^(n|s)$/.test(resizing) && x, resizingY = !/^(e|w)$/.test(resizing) && y, dragging = eventTarget.classed("extent"), dragRestore = d3_event_dragSuppress(target), center, origin = d3.mouse(target), offset; + var w = d3.select(d3_window(target)).on("keydown.brush", keydown).on("keyup.brush", keyup); + if (d3.event.changedTouches) { + w.on("touchmove.brush", brushmove).on("touchend.brush", brushend); + } else { + w.on("mousemove.brush", brushmove).on("mouseup.brush", brushend); + } + g.interrupt().selectAll("*").interrupt(); + if (dragging) { + origin[0] = xExtent[0] - origin[0]; + origin[1] = yExtent[0] - origin[1]; + } else if (resizing) { + var ex = +/w$/.test(resizing), ey = +/^n/.test(resizing); + offset = [ xExtent[1 - ex] - origin[0], yExtent[1 - ey] - origin[1] ]; + origin[0] = xExtent[ex]; + origin[1] = yExtent[ey]; + } else if (d3.event.altKey) center = origin.slice(); + g.style("pointer-events", "none").selectAll(".resize").style("display", null); + d3.select("body").style("cursor", eventTarget.style("cursor")); + event_({ + type: "brushstart" + }); + brushmove(); + function keydown() { + if (d3.event.keyCode == 32) { + if (!dragging) { + center = null; + origin[0] -= xExtent[1]; + origin[1] -= yExtent[1]; + dragging = 2; + } + d3_eventPreventDefault(); + } + } + function keyup() { + if (d3.event.keyCode == 32 && dragging == 2) { + origin[0] += xExtent[1]; + origin[1] += yExtent[1]; + dragging = 0; + d3_eventPreventDefault(); + } + } + function brushmove() { + var point = d3.mouse(target), moved = false; + if (offset) { + point[0] += offset[0]; + point[1] += offset[1]; + } + if (!dragging) { + if (d3.event.altKey) { + if (!center) center = [ (xExtent[0] + xExtent[1]) / 2, (yExtent[0] + yExtent[1]) / 2 ]; + origin[0] = xExtent[+(point[0] < center[0])]; + origin[1] = yExtent[+(point[1] < center[1])]; + } else center = null; + } + if (resizingX && move1(point, x, 0)) { + redrawX(g); + moved = true; + } + if (resizingY && move1(point, y, 1)) { + redrawY(g); + moved = true; + } + if (moved) { + redraw(g); + event_({ + type: "brush", + mode: dragging ? "move" : "resize" + }); + } + } + function move1(point, scale, i) { + var range = d3_scaleRange(scale), r0 = range[0], r1 = range[1], position = origin[i], extent = i ? yExtent : xExtent, size = extent[1] - extent[0], min, max; + if (dragging) { + r0 -= position; + r1 -= size + position; + } + min = (i ? yClamp : xClamp) ? Math.max(r0, Math.min(r1, point[i])) : point[i]; + if (dragging) { + max = (min += position) + size; + } else { + if (center) position = Math.max(r0, Math.min(r1, 2 * center[i] - min)); + if (position < min) { + max = min; + min = position; + } else { + max = position; + } + } + if (extent[0] != min || extent[1] != max) { + if (i) yExtentDomain = null; else xExtentDomain = null; + extent[0] = min; + extent[1] = max; + return true; + } + } + function brushend() { + brushmove(); + g.style("pointer-events", "all").selectAll(".resize").style("display", brush.empty() ? "none" : null); + d3.select("body").style("cursor", null); + w.on("mousemove.brush", null).on("mouseup.brush", null).on("touchmove.brush", null).on("touchend.brush", null).on("keydown.brush", null).on("keyup.brush", null); + dragRestore(); + event_({ + type: "brushend" + }); + } + } + brush.x = function(z) { + if (!arguments.length) return x; + x = z; + resizes = d3_svg_brushResizes[!x << 1 | !y]; + return brush; + }; + brush.y = function(z) { + if (!arguments.length) return y; + y = z; + resizes = d3_svg_brushResizes[!x << 1 | !y]; + return brush; + }; + brush.clamp = function(z) { + if (!arguments.length) return x && y ? [ xClamp, yClamp ] : x ? xClamp : y ? yClamp : null; + if (x && y) xClamp = !!z[0], yClamp = !!z[1]; else if (x) xClamp = !!z; else if (y) yClamp = !!z; + return brush; + }; + brush.extent = function(z) { + var x0, x1, y0, y1, t; + if (!arguments.length) { + if (x) { + if (xExtentDomain) { + x0 = xExtentDomain[0], x1 = xExtentDomain[1]; + } else { + x0 = xExtent[0], x1 = xExtent[1]; + if (x.invert) x0 = x.invert(x0), x1 = x.invert(x1); + if (x1 < x0) t = x0, x0 = x1, x1 = t; + } + } + if (y) { + if (yExtentDomain) { + y0 = yExtentDomain[0], y1 = yExtentDomain[1]; + } else { + y0 = yExtent[0], y1 = yExtent[1]; + if (y.invert) y0 = y.invert(y0), y1 = y.invert(y1); + if (y1 < y0) t = y0, y0 = y1, y1 = t; + } + } + return x && y ? [ [ x0, y0 ], [ x1, y1 ] ] : x ? [ x0, x1 ] : y && [ y0, y1 ]; + } + if (x) { + x0 = z[0], x1 = z[1]; + if (y) x0 = x0[0], x1 = x1[0]; + xExtentDomain = [ x0, x1 ]; + if (x.invert) x0 = x(x0), x1 = x(x1); + if (x1 < x0) t = x0, x0 = x1, x1 = t; + if (x0 != xExtent[0] || x1 != xExtent[1]) xExtent = [ x0, x1 ]; + } + if (y) { + y0 = z[0], y1 = z[1]; + if (x) y0 = y0[1], y1 = y1[1]; + yExtentDomain = [ y0, y1 ]; + if (y.invert) y0 = y(y0), y1 = y(y1); + if (y1 < y0) t = y0, y0 = y1, y1 = t; + if (y0 != yExtent[0] || y1 != yExtent[1]) yExtent = [ y0, y1 ]; + } + return brush; + }; + brush.clear = function() { + if (!brush.empty()) { + xExtent = [ 0, 0 ], yExtent = [ 0, 0 ]; + xExtentDomain = yExtentDomain = null; + } + return brush; + }; + brush.empty = function() { + return !!x && xExtent[0] == xExtent[1] || !!y && yExtent[0] == yExtent[1]; + }; + return d3.rebind(brush, event, "on"); + }; + var d3_svg_brushCursor = { + n: "ns-resize", + e: "ew-resize", + s: "ns-resize", + w: "ew-resize", + nw: "nwse-resize", + ne: "nesw-resize", + se: "nwse-resize", + sw: "nesw-resize" + }; + var d3_svg_brushResizes = [ [ "n", "e", "s", "w", "nw", "ne", "se", "sw" ], [ "e", "w" ], [ "n", "s" ], [] ]; + d3.text = d3_xhrType(function(request) { + return request.responseText; + }); + d3.json = function(url, callback) { + return d3_xhr(url, "application/json", d3_json, callback); + }; + function d3_json(request) { + return JSON.parse(request.responseText); + } + d3.html = function(url, callback) { + return d3_xhr(url, "text/html", d3_html, callback); + }; + function d3_html(request) { + var range = d3_document.createRange(); + range.selectNode(d3_document.body); + return range.createContextualFragment(request.responseText); + } + d3.xml = d3_xhrType(function(request) { + return request.responseXML; + }); + if (typeof define === "function" && define.amd) define(d3); else if (typeof module === "object" && module.exports) module.exports = d3; else this.d3 = d3; +}.apply(self); \ No newline at end of file diff --git a/node_modules/@plotly/d3/package.js b/node_modules/@plotly/d3/package.js new file mode 100644 index 0000000000000000000000000000000000000000..1f8566bff0523616d526ae9aeefc06fe2ead480a --- /dev/null +++ b/node_modules/@plotly/d3/package.js @@ -0,0 +1,13 @@ +// Package metadata for Meteor.js. + +Package.describe({ + name: "d3js:d3", // http://atmospherejs.com/d3js/d3 + summary: "D3 (official): A JavaScript visualization library for HTML and SVG.", + version: "3.8.0", + git: "https://github.com/mbostock/d3.git" +}); + +Package.onUse(function(api) { + api.versionsFrom(["METEOR@1.0"]); + api.addFiles("d3.js", "client"); +}); diff --git a/node_modules/@plotly/d3/package.json b/node_modules/@plotly/d3/package.json new file mode 100644 index 0000000000000000000000000000000000000000..5a8c256a469f05cb8cf700a7e846f1021248e0d7 --- /dev/null +++ b/node_modules/@plotly/d3/package.json @@ -0,0 +1,65 @@ +{ + "name": "@plotly/d3", + "version": "3.8.1", + "description": "A JavaScript visualization library for HTML and SVG.", + "keywords": [ + "dom", + "w3c", + "visualization", + "svg", + "animation", + "canvas" + ], + "homepage": "http://d3js.org", + "author": { + "name": "Mike Bostock", + "url": "http://bost.ocks.org/mike" + }, + "contributors": [ + { + "name": "Jason Davies", + "url": "http://jasondavies.com" + } + ], + "repository": { + "type": "git", + "url": "https://github.com/plotly/d3.git" + }, + "main": "d3.js", + "browser": "d3.js", + "jspm": { + "main": "d3", + "shim": { + "d3": { + "exports": "d3" + } + }, + "files": [ + "d3.js" + ], + "buildConfig": { + "uglify": true + } + }, + "jam": { + "main": "d3.js", + "shim": { + "exports": "d3" + } + }, + "spm": { + "main": "d3.js" + }, + "devDependencies": { + "jsdom": "3", + "seedrandom": "2", + "smash": "0.0", + "uglify-js": "2.6.2", + "vows": "0.8" + }, + "scripts": { + "test": "vows && echo", + "build": "rm -f package.js src/start.js d3.js d3.zip && bin/start > src/start.js && bin/meteor > package.js && smash src/d3.js | uglifyjs - -b indent-level=2 -o d3.js && chmod a-w d3.js package.js && zip d3.zip LICENSE d3.js" + }, + "license": "BSD-3-Clause" +} diff --git a/node_modules/@plotly/d3/src/arrays/ascending.js b/node_modules/@plotly/d3/src/arrays/ascending.js new file mode 100644 index 0000000000000000000000000000000000000000..067c17aa60c0d873e1605711d45d3bd4916a2b93 --- /dev/null +++ b/node_modules/@plotly/d3/src/arrays/ascending.js @@ -0,0 +1,5 @@ +d3.ascending = d3_ascending; + +function d3_ascending(a, b) { + return a < b ? -1 : a > b ? 1 : a >= b ? 0 : NaN; +} diff --git a/node_modules/@plotly/d3/src/arrays/bisect.js b/node_modules/@plotly/d3/src/arrays/bisect.js new file mode 100644 index 0000000000000000000000000000000000000000..fbe3a737e9815b5c706d2d30c406df03768388a5 --- /dev/null +++ b/node_modules/@plotly/d3/src/arrays/bisect.js @@ -0,0 +1,36 @@ +import "ascending"; + +function d3_bisector(compare) { + return { + left: function(a, x, lo, hi) { + if (arguments.length < 3) lo = 0; + if (arguments.length < 4) hi = a.length; + while (lo < hi) { + var mid = lo + hi >>> 1; + if (compare(a[mid], x) < 0) lo = mid + 1; + else hi = mid; + } + return lo; + }, + right: function(a, x, lo, hi) { + if (arguments.length < 3) lo = 0; + if (arguments.length < 4) hi = a.length; + while (lo < hi) { + var mid = lo + hi >>> 1; + if (compare(a[mid], x) > 0) hi = mid; + else lo = mid + 1; + } + return lo; + } + }; +} + +var d3_bisect = d3_bisector(d3_ascending); +d3.bisectLeft = d3_bisect.left; +d3.bisect = d3.bisectRight = d3_bisect.right; + +d3.bisector = function(f) { + return d3_bisector(f.length === 1 + ? function(d, x) { return d3_ascending(f(d), x); } + : f); +}; diff --git a/node_modules/@plotly/d3/src/arrays/descending.js b/node_modules/@plotly/d3/src/arrays/descending.js new file mode 100644 index 0000000000000000000000000000000000000000..05034586ffe6ffe3516364500d616d13a13c4a27 --- /dev/null +++ b/node_modules/@plotly/d3/src/arrays/descending.js @@ -0,0 +1,3 @@ +d3.descending = function(a, b) { + return b < a ? -1 : b > a ? 1 : b >= a ? 0 : NaN; +}; diff --git a/node_modules/@plotly/d3/src/arrays/deviation.js b/node_modules/@plotly/d3/src/arrays/deviation.js new file mode 100644 index 0000000000000000000000000000000000000000..16663e3f19fb60f182a288726961c52394e3e328 --- /dev/null +++ b/node_modules/@plotly/d3/src/arrays/deviation.js @@ -0,0 +1,6 @@ +import "variance"; + +d3.deviation = function() { + var v = d3.variance.apply(this, arguments); + return v ? Math.sqrt(v) : v; +}; diff --git a/node_modules/@plotly/d3/src/arrays/entries.js b/node_modules/@plotly/d3/src/arrays/entries.js new file mode 100644 index 0000000000000000000000000000000000000000..4ce014b82bae228e0b27562f93ecc328bd0d10c7 --- /dev/null +++ b/node_modules/@plotly/d3/src/arrays/entries.js @@ -0,0 +1,5 @@ +d3.entries = function(map) { + var entries = []; + for (var key in map) entries.push({key: key, value: map[key]}); + return entries; +}; diff --git a/node_modules/@plotly/d3/src/arrays/extent.js b/node_modules/@plotly/d3/src/arrays/extent.js new file mode 100644 index 0000000000000000000000000000000000000000..7584658331af70fa15f8cfaf6e397a878dac35c0 --- /dev/null +++ b/node_modules/@plotly/d3/src/arrays/extent.js @@ -0,0 +1,21 @@ +d3.extent = function(array, f) { + var i = -1, + n = array.length, + a, + b, + c; + if (arguments.length === 1) { + while (++i < n) if ((b = array[i]) != null && b >= b) { a = c = b; break; } + while (++i < n) if ((b = array[i]) != null) { + if (a > b) a = b; + if (c < b) c = b; + } + } else { + while (++i < n) if ((b = f.call(array, array[i], i)) != null && b >= b) { a = c = b; break; } + while (++i < n) if ((b = f.call(array, array[i], i)) != null) { + if (a > b) a = b; + if (c < b) c = b; + } + } + return [a, c]; +}; diff --git a/node_modules/@plotly/d3/src/arrays/index.js b/node_modules/@plotly/d3/src/arrays/index.js new file mode 100644 index 0000000000000000000000000000000000000000..c29fb24b7e45dfabeeca33d1b3fb43d6d834bad4 --- /dev/null +++ b/node_modules/@plotly/d3/src/arrays/index.js @@ -0,0 +1,25 @@ +import "ascending"; +import "descending"; +import "min"; +import "max"; +import "extent"; +import "sum"; +import "mean"; +import "median"; +import "quantile"; +import "variance"; +import "deviation"; +import "bisect"; +import "shuffle"; +import "permute"; +import "pairs"; +import "zip"; +import "transpose"; +import "keys"; +import "values"; +import "entries"; +import "merge"; +import "range"; +import "nest"; +import "map"; +import "set"; diff --git a/node_modules/@plotly/d3/src/arrays/keys.js b/node_modules/@plotly/d3/src/arrays/keys.js new file mode 100644 index 0000000000000000000000000000000000000000..c83ec8e15688b090ec03ae70545e32226c31997c --- /dev/null +++ b/node_modules/@plotly/d3/src/arrays/keys.js @@ -0,0 +1,5 @@ +d3.keys = function(map) { + var keys = []; + for (var key in map) keys.push(key); + return keys; +}; diff --git a/node_modules/@plotly/d3/src/arrays/map.js b/node_modules/@plotly/d3/src/arrays/map.js new file mode 100644 index 0000000000000000000000000000000000000000..4ba7f3d151e26590ad20182daea1aa472bbb50e8 --- /dev/null +++ b/node_modules/@plotly/d3/src/arrays/map.js @@ -0,0 +1,84 @@ +import "../core/class"; + +d3.map = function(object, f) { + var map = new d3_Map; + if (object instanceof d3_Map) { + object.forEach(function(key, value) { map.set(key, value); }); + } else if (Array.isArray(object)) { + var i = -1, + n = object.length, + o; + if (arguments.length === 1) while (++i < n) map.set(i, object[i]); + else while (++i < n) map.set(f.call(object, o = object[i], i), o); + } else { + for (var key in object) map.set(key, object[key]); + } + return map; +}; + +function d3_Map() { + this._ = Object.create(null); +} + +var d3_map_proto = "__proto__", + d3_map_zero = "\0"; + +d3_class(d3_Map, { + has: d3_map_has, + get: function(key) { + return this._[d3_map_escape(key)]; + }, + set: function(key, value) { + return this._[d3_map_escape(key)] = value; + }, + remove: d3_map_remove, + keys: d3_map_keys, + values: function() { + var values = []; + for (var key in this._) values.push(this._[key]); + return values; + }, + entries: function() { + var entries = []; + for (var key in this._) entries.push({key: d3_map_unescape(key), value: this._[key]}); + return entries; + }, + size: d3_map_size, + empty: d3_map_empty, + forEach: function(f) { + for (var key in this._) f.call(this, d3_map_unescape(key), this._[key]); + } +}); + +function d3_map_escape(key) { + return (key += "") === d3_map_proto || key[0] === d3_map_zero ? d3_map_zero + key : key; +} + +function d3_map_unescape(key) { + return (key += "")[0] === d3_map_zero ? key.slice(1) : key; +} + +function d3_map_has(key) { + return d3_map_escape(key) in this._; +} + +function d3_map_remove(key) { + return (key = d3_map_escape(key)) in this._ && delete this._[key]; +} + +function d3_map_keys() { + var keys = []; + for (var key in this._) keys.push(d3_map_unescape(key)); + return keys; +} + +function d3_map_size() { + var size = 0; + for (var key in this._) ++size; + return size; +} + +function d3_map_empty() { + for (var key in this._) return false; + return true; +} diff --git a/node_modules/@plotly/d3/src/arrays/max.js b/node_modules/@plotly/d3/src/arrays/max.js new file mode 100644 index 0000000000000000000000000000000000000000..5aec78d42a1406160e9a4362dc9fb64b495d3178 --- /dev/null +++ b/node_modules/@plotly/d3/src/arrays/max.js @@ -0,0 +1,14 @@ +d3.max = function(array, f) { + var i = -1, + n = array.length, + a, + b; + if (arguments.length === 1) { + while (++i < n) if ((b = array[i]) != null && b >= b) { a = b; break; } + while (++i < n) if ((b = array[i]) != null && b > a) a = b; + } else { + while (++i < n) if ((b = f.call(array, array[i], i)) != null && b >= b) { a = b; break; } + while (++i < n) if ((b = f.call(array, array[i], i)) != null && b > a) a = b; + } + return a; +}; diff --git a/node_modules/@plotly/d3/src/arrays/mean.js b/node_modules/@plotly/d3/src/arrays/mean.js new file mode 100644 index 0000000000000000000000000000000000000000..ab91ae8cfe3701f9c7b6a32430a44240816f70a7 --- /dev/null +++ b/node_modules/@plotly/d3/src/arrays/mean.js @@ -0,0 +1,15 @@ +import "../math/number"; + +d3.mean = function(array, f) { + var s = 0, + n = array.length, + a, + i = -1, + j = n; + if (arguments.length === 1) { + while (++i < n) if (d3_numeric(a = d3_number(array[i]))) s += a; else --j; + } else { + while (++i < n) if (d3_numeric(a = d3_number(f.call(array, array[i], i)))) s += a; else --j; + } + if (j) return s / j; +}; diff --git a/node_modules/@plotly/d3/src/arrays/median.js b/node_modules/@plotly/d3/src/arrays/median.js new file mode 100644 index 0000000000000000000000000000000000000000..9f0308b267ca88d8947f8a932f384e32674b70c9 --- /dev/null +++ b/node_modules/@plotly/d3/src/arrays/median.js @@ -0,0 +1,16 @@ +import "../math/number"; +import "ascending"; +import "quantile"; + +d3.median = function(array, f) { + var numbers = [], + n = array.length, + a, + i = -1; + if (arguments.length === 1) { + while (++i < n) if (d3_numeric(a = d3_number(array[i]))) numbers.push(a); + } else { + while (++i < n) if (d3_numeric(a = d3_number(f.call(array, array[i], i)))) numbers.push(a); + } + if (numbers.length) return d3.quantile(numbers.sort(d3_ascending), 0.5); +}; diff --git a/node_modules/@plotly/d3/src/arrays/merge.js b/node_modules/@plotly/d3/src/arrays/merge.js new file mode 100644 index 0000000000000000000000000000000000000000..53c992dc48768a280e9f2fc4b7a685fd32775438 --- /dev/null +++ b/node_modules/@plotly/d3/src/arrays/merge.js @@ -0,0 +1,21 @@ +d3.merge = function(arrays) { + var n = arrays.length, + m, + i = -1, + j = 0, + merged, + array; + + while (++i < n) j += arrays[i].length; + merged = new Array(j); + + while (--n >= 0) { + array = arrays[n]; + m = array.length; + while (--m >= 0) { + merged[--j] = array[m]; + } + } + + return merged; +}; diff --git a/node_modules/@plotly/d3/src/arrays/min.js b/node_modules/@plotly/d3/src/arrays/min.js new file mode 100644 index 0000000000000000000000000000000000000000..c48a49d0c6b012ec5d932d6c622bdc94d9abb823 --- /dev/null +++ b/node_modules/@plotly/d3/src/arrays/min.js @@ -0,0 +1,14 @@ +d3.min = function(array, f) { + var i = -1, + n = array.length, + a, + b; + if (arguments.length === 1) { + while (++i < n) if ((b = array[i]) != null && b >= b) { a = b; break; } + while (++i < n) if ((b = array[i]) != null && a > b) a = b; + } else { + while (++i < n) if ((b = f.call(array, array[i], i)) != null && b >= b) { a = b; break; } + while (++i < n) if ((b = f.call(array, array[i], i)) != null && a > b) a = b; + } + return a; +}; diff --git a/node_modules/@plotly/d3/src/arrays/nest.js b/node_modules/@plotly/d3/src/arrays/nest.js new file mode 100644 index 0000000000000000000000000000000000000000..859add7be3349c477423584f3e48ff2efee0c0dd --- /dev/null +++ b/node_modules/@plotly/d3/src/arrays/nest.js @@ -0,0 +1,97 @@ +import "map"; + +d3.nest = function() { + var nest = {}, + keys = [], + sortKeys = [], + sortValues, + rollup; + + function map(mapType, array, depth) { + if (depth >= keys.length) return rollup + ? rollup.call(nest, array) : (sortValues + ? array.sort(sortValues) + : array); + + var i = -1, + n = array.length, + key = keys[depth++], + keyValue, + object, + setter, + valuesByKey = new d3_Map, + values; + + while (++i < n) { + if (values = valuesByKey.get(keyValue = key(object = array[i]))) { + values.push(object); + } else { + valuesByKey.set(keyValue, [object]); + } + } + + if (mapType) { + object = mapType(); + setter = function(keyValue, values) { + object.set(keyValue, map(mapType, values, depth)); + }; + } else { + object = {}; + setter = function(keyValue, values) { + object[keyValue] = map(mapType, values, depth); + }; + } + + valuesByKey.forEach(setter); + return object; + } + + function entries(map, depth) { + if (depth >= keys.length) return map; + + var array = [], + sortKey = sortKeys[depth++]; + + map.forEach(function(key, keyMap) { + array.push({key: key, values: entries(keyMap, depth)}); + }); + + return sortKey + ? array.sort(function(a, b) { return sortKey(a.key, b.key); }) + : array; + } + + nest.map = function(array, mapType) { + return map(mapType, array, 0); + }; + + nest.entries = function(array) { + return entries(map(d3.map, array, 0), 0); + }; + + nest.key = function(d) { + keys.push(d); + return nest; + }; + + // Specifies the order for the most-recently specified key. + // Note: only applies to entries. Map keys are unordered! + nest.sortKeys = function(order) { + sortKeys[keys.length - 1] = order; + return nest; + }; + + // Specifies the order for leaf values. + // Applies to both maps and entries array. + nest.sortValues = function(order) { + sortValues = order; + return nest; + }; + + nest.rollup = function(f) { + rollup = f; + return nest; + }; + + return nest; +}; diff --git a/node_modules/@plotly/d3/src/arrays/pairs.js b/node_modules/@plotly/d3/src/arrays/pairs.js new file mode 100644 index 0000000000000000000000000000000000000000..e270f957cda3453fcd168cee0baba944f4a6c574 --- /dev/null +++ b/node_modules/@plotly/d3/src/arrays/pairs.js @@ -0,0 +1,5 @@ +d3.pairs = function(array) { + var i = 0, n = array.length - 1, p0, p1 = array[0], pairs = new Array(n < 0 ? 0 : n); + while (i < n) pairs[i] = [p0 = p1, p1 = array[++i]]; + return pairs; +}; diff --git a/node_modules/@plotly/d3/src/arrays/permute.js b/node_modules/@plotly/d3/src/arrays/permute.js new file mode 100644 index 0000000000000000000000000000000000000000..f27d2c9d261fa659d853cfe27fe15c2b35fa7aa2 --- /dev/null +++ b/node_modules/@plotly/d3/src/arrays/permute.js @@ -0,0 +1,5 @@ +d3.permute = function(array, indexes) { + var i = indexes.length, permutes = new Array(i); + while (i--) permutes[i] = array[indexes[i]]; + return permutes; +}; diff --git a/node_modules/@plotly/d3/src/arrays/quantile.js b/node_modules/@plotly/d3/src/arrays/quantile.js new file mode 100644 index 0000000000000000000000000000000000000000..67fe9fd71cd314ee64a28eb1e4fbb2c7a9bd59ec --- /dev/null +++ b/node_modules/@plotly/d3/src/arrays/quantile.js @@ -0,0 +1,8 @@ +// R-7 per +d3.quantile = function(values, p) { + var H = (values.length - 1) * p + 1, + h = Math.floor(H), + v = +values[h - 1], + e = H - h; + return e ? v + e * (values[h] - v) : v; +}; diff --git a/node_modules/@plotly/d3/src/arrays/range.js b/node_modules/@plotly/d3/src/arrays/range.js new file mode 100644 index 0000000000000000000000000000000000000000..2fd6a1e6bfc3c325ffe8f63527665308800e5112 --- /dev/null +++ b/node_modules/@plotly/d3/src/arrays/range.js @@ -0,0 +1,26 @@ +import "../math/abs"; + +d3.range = function(start, stop, step) { + if (arguments.length < 3) { + step = 1; + if (arguments.length < 2) { + stop = start; + start = 0; + } + } + if ((stop - start) / step === Infinity) throw new Error("infinite range"); + var range = [], + k = d3_range_integerScale(abs(step)), + i = -1, + j; + start *= k, stop *= k, step *= k; + if (step < 0) while ((j = start + step * ++i) > stop) range.push(j / k); + else while ((j = start + step * ++i) < stop) range.push(j / k); + return range; +}; + +function d3_range_integerScale(x) { + var k = 1; + while (x * k % 1) k *= 10; + return k; +} diff --git a/node_modules/@plotly/d3/src/arrays/set.js b/node_modules/@plotly/d3/src/arrays/set.js new file mode 100644 index 0000000000000000000000000000000000000000..de4dbd426140bd83e46ff0e1833e6e600a75d814 --- /dev/null +++ b/node_modules/@plotly/d3/src/arrays/set.js @@ -0,0 +1,27 @@ +import "../core/class"; +import "map"; + +d3.set = function(array) { + var set = new d3_Set; + if (array) for (var i = 0, n = array.length; i < n; ++i) set.add(array[i]); + return set; +}; + +function d3_Set() { + this._ = Object.create(null); +} + +d3_class(d3_Set, { + has: d3_map_has, + add: function(key) { + this._[d3_map_escape(key += "")] = true; + return key; + }, + remove: d3_map_remove, + values: d3_map_keys, + size: d3_map_size, + empty: d3_map_empty, + forEach: function(f) { + for (var key in this._) f.call(this, d3_map_unescape(key)); + } +}); diff --git a/node_modules/@plotly/d3/src/arrays/shuffle.js b/node_modules/@plotly/d3/src/arrays/shuffle.js new file mode 100644 index 0000000000000000000000000000000000000000..dbe36bdd72d92c12b113656c4390bd47748fbf53 --- /dev/null +++ b/node_modules/@plotly/d3/src/arrays/shuffle.js @@ -0,0 +1,9 @@ +d3.shuffle = function(array, i0, i1) { + if ((m = arguments.length) < 3) { i1 = array.length; if (m < 2) i0 = 0; } + var m = i1 - i0, t, i; + while (m) { + i = Math.random() * m-- | 0; + t = array[m + i0], array[m + i0] = array[i + i0], array[i + i0] = t; + } + return array; +}; diff --git a/node_modules/@plotly/d3/src/arrays/sum.js b/node_modules/@plotly/d3/src/arrays/sum.js new file mode 100644 index 0000000000000000000000000000000000000000..1e179bc855859b7ac36fdc71994a17b8120dd203 --- /dev/null +++ b/node_modules/@plotly/d3/src/arrays/sum.js @@ -0,0 +1,14 @@ +import "../math/number"; + +d3.sum = function(array, f) { + var s = 0, + n = array.length, + a, + i = -1; + if (arguments.length === 1) { + while (++i < n) if (d3_numeric(a = +array[i])) s += a; // zero and null are equivalent + } else { + while (++i < n) if (d3_numeric(a = +f.call(array, array[i], i))) s += a; + } + return s; +}; diff --git a/node_modules/@plotly/d3/src/arrays/transpose.js b/node_modules/@plotly/d3/src/arrays/transpose.js new file mode 100644 index 0000000000000000000000000000000000000000..c41e8e59287b30ece9fe9c0eee4cfe22151f5a20 --- /dev/null +++ b/node_modules/@plotly/d3/src/arrays/transpose.js @@ -0,0 +1,15 @@ +import "min"; + +d3.transpose = function(matrix) { + if (!(n = matrix.length)) return []; + for (var i = -1, m = d3.min(matrix, d3_transposeLength), transpose = new Array(m); ++i < m;) { + for (var j = -1, n, row = transpose[i] = new Array(n); ++j < n;) { + row[j] = matrix[j][i]; + } + } + return transpose; +}; + +function d3_transposeLength(d) { + return d.length; +} diff --git a/node_modules/@plotly/d3/src/arrays/values.js b/node_modules/@plotly/d3/src/arrays/values.js new file mode 100644 index 0000000000000000000000000000000000000000..299d30433caa314f96d5ff835973fc751d5b4af6 --- /dev/null +++ b/node_modules/@plotly/d3/src/arrays/values.js @@ -0,0 +1,5 @@ +d3.values = function(map) { + var values = []; + for (var key in map) values.push(map[key]); + return values; +}; diff --git a/node_modules/@plotly/d3/src/arrays/variance.js b/node_modules/@plotly/d3/src/arrays/variance.js new file mode 100644 index 0000000000000000000000000000000000000000..70da168061ee6d92e7a4282aa9cfd0baced2b2d4 --- /dev/null +++ b/node_modules/@plotly/d3/src/arrays/variance.js @@ -0,0 +1,29 @@ +import "../math/number"; + +d3.variance = function(array, f) { + var n = array.length, + m = 0, + a, + d, + s = 0, + i = -1, + j = 0; + if (arguments.length === 1) { + while (++i < n) { + if (d3_numeric(a = d3_number(array[i]))) { + d = a - m; + m += d / ++j; + s += d * (a - m); + } + } + } else { + while (++i < n) { + if (d3_numeric(a = d3_number(f.call(array, array[i], i)))) { + d = a - m; + m += d / ++j; + s += d * (a - m); + } + } + } + if (j > 1) return s / (j - 1); +}; diff --git a/node_modules/@plotly/d3/src/arrays/zip.js b/node_modules/@plotly/d3/src/arrays/zip.js new file mode 100644 index 0000000000000000000000000000000000000000..502916d162a750ed18f0425675cf4af42710adc7 --- /dev/null +++ b/node_modules/@plotly/d3/src/arrays/zip.js @@ -0,0 +1,5 @@ +import "transpose"; + +d3.zip = function() { + return d3.transpose(arguments); +}; diff --git a/node_modules/@plotly/d3/src/behavior/behavior.js b/node_modules/@plotly/d3/src/behavior/behavior.js new file mode 100644 index 0000000000000000000000000000000000000000..39633b10599fa4652d68ae2505a68ad01b21c6ed --- /dev/null +++ b/node_modules/@plotly/d3/src/behavior/behavior.js @@ -0,0 +1 @@ +d3.behavior = {}; diff --git a/node_modules/@plotly/d3/src/behavior/drag.js b/node_modules/@plotly/d3/src/behavior/drag.js new file mode 100644 index 0000000000000000000000000000000000000000..93e25fbae6f7b9fbc20e0ed6dcbee9df99900ff1 --- /dev/null +++ b/node_modules/@plotly/d3/src/behavior/drag.js @@ -0,0 +1,88 @@ +import "../core/document"; +import "../core/identity"; +import "../core/rebind"; +import "../event/drag"; +import "../event/event"; +import "../event/mouse"; +import "../event/touch"; +import "behavior"; + +d3.behavior.drag = function() { + var event = d3_eventDispatch(drag, "drag", "dragstart", "dragend"), + origin = null, + mousedown = dragstart(d3_noop, d3.mouse, d3_window, "mousemove", "mouseup"), + touchstart = dragstart(d3_behavior_dragTouchId, d3.touch, d3_identity, "touchmove", "touchend"); + + function drag() { + this.on("mousedown.drag", mousedown) + .on("touchstart.drag", touchstart); + } + + function dragstart(id, position, subject, move, end) { + return function() { + var that = this, + target = d3.event.target.correspondingElement || d3.event.target, + parent = that.parentNode, + dispatch = event.of(that, arguments), + dragged = 0, + dragId = id(), + dragName = ".drag" + (dragId == null ? "" : "-" + dragId), + dragOffset, + dragSubject = d3.select(subject(target)).on(move + dragName, moved).on(end + dragName, ended), + dragRestore = d3_event_dragSuppress(target), + position0 = position(parent, dragId); + + if (origin) { + dragOffset = origin.apply(that, arguments); + dragOffset = [dragOffset.x - position0[0], dragOffset.y - position0[1]]; + } else { + dragOffset = [0, 0]; + } + + dispatch({type: "dragstart"}); + + function moved() { + var position1 = position(parent, dragId), dx, dy; + if (!position1) return; // this touch didn’t move + + dx = position1[0] - position0[0]; + dy = position1[1] - position0[1]; + dragged |= dx | dy; + position0 = position1; + + dispatch({ + type: "drag", + x: position1[0] + dragOffset[0], + y: position1[1] + dragOffset[1], + dx: dx, + dy: dy + }); + } + + function ended() { + if (!position(parent, dragId)) return; // this touch didn’t end + dragSubject.on(move + dragName, null).on(end + dragName, null); + dragRestore(dragged); + dispatch({type: "dragend"}); + } + }; + } + + drag.origin = function(x) { + if (!arguments.length) return origin; + origin = x; + return drag; + }; + + return d3.rebind(drag, event, "on"); +}; + +// While it is possible to receive a touchstart event with more than one changed +// touch, the event is only shared by touches on the same target; for new +// touches targetting different elements, multiple touchstart events are +// received even when the touches start simultaneously. Since multiple touches +// cannot move the same target to different locations concurrently without +// tearing the fabric of spacetime, we allow the first touch to win. +function d3_behavior_dragTouchId() { + return d3.event.changedTouches[0].identifier; +} diff --git a/node_modules/@plotly/d3/src/behavior/index.js b/node_modules/@plotly/d3/src/behavior/index.js new file mode 100644 index 0000000000000000000000000000000000000000..5ce09321d28f75385590be3e6ace2e229c462956 --- /dev/null +++ b/node_modules/@plotly/d3/src/behavior/index.js @@ -0,0 +1,3 @@ +import "behavior"; +import "drag"; +import "zoom"; diff --git a/node_modules/@plotly/d3/src/behavior/zoom.js b/node_modules/@plotly/d3/src/behavior/zoom.js new file mode 100644 index 0000000000000000000000000000000000000000..2169e03e34e73453e4d9cd46ea92abaebd1fc8cc --- /dev/null +++ b/node_modules/@plotly/d3/src/behavior/zoom.js @@ -0,0 +1,348 @@ +import "../core/document"; +import "../core/rebind"; +import "../event/drag"; +import "../event/event"; +import "../event/mouse"; +import "../event/touches"; +import "../selection/selection"; +import "../interpolate/zoom"; +import "behavior"; + +d3.behavior.zoom = function() { + var view = {x: 0, y: 0, k: 1}, + translate0, // translate when we started zooming (to avoid drift) + center0, // implicit desired position of translate0 after zooming + center, // explicit desired position of translate0 after zooming + size = [960, 500], // viewport size; required for zoom interpolation + scaleExtent = d3_behavior_zoomInfinity, + duration = 250, + zooming = 0, + mousedown = "mousedown.zoom", + mousemove = "mousemove.zoom", + mouseup = "mouseup.zoom", + mousewheelTimer, + touchstart = "touchstart.zoom", + touchtime, // time of last touchstart (to detect double-tap) + event = d3_eventDispatch(zoom, "zoomstart", "zoom", "zoomend"), + x0, + x1, + y0, + y1; + + // Lazily determine the DOM’s support for Wheel events. + // https://developer.mozilla.org/en-US/docs/Mozilla_event_reference/wheel + if (!d3_behavior_zoomWheel) { + d3_behavior_zoomWheel = "onwheel" in d3_document ? (d3_behavior_zoomDelta = function() { return -d3.event.deltaY * (d3.event.deltaMode ? 120 : 1); }, "wheel") + : "onmousewheel" in d3_document ? (d3_behavior_zoomDelta = function() { return d3.event.wheelDelta; }, "mousewheel") + : (d3_behavior_zoomDelta = function() { return -d3.event.detail; }, "MozMousePixelScroll"); + } + + function zoom(g) { + g .on(mousedown, mousedowned) + .on(d3_behavior_zoomWheel + ".zoom", mousewheeled) + .on("dblclick.zoom", dblclicked) + .on(touchstart, touchstarted); + } + + zoom.event = function(g) { + g.each(function() { + var dispatch = event.of(this, arguments), + view1 = view; + if (d3_transitionInheritId) { + d3.select(this).transition() + .each("start.zoom", function() { + view = this.__chart__ || {x: 0, y: 0, k: 1}; // pre-transition state + zoomstarted(dispatch); + }) + .tween("zoom:zoom", function() { + var dx = size[0], + dy = size[1], + cx = center0 ? center0[0] : dx / 2, + cy = center0 ? center0[1] : dy / 2, + i = d3.interpolateZoom( + [(cx - view.x) / view.k, (cy - view.y) / view.k, dx / view.k], + [(cx - view1.x) / view1.k, (cy - view1.y) / view1.k, dx / view1.k] + ); + return function(t) { + var l = i(t), k = dx / l[2]; + this.__chart__ = view = {x: cx - l[0] * k, y: cy - l[1] * k, k: k}; + zoomed(dispatch); + }; + }) + .each("interrupt.zoom", function() { + zoomended(dispatch); + }) + .each("end.zoom", function() { + zoomended(dispatch); + }); + } else { + this.__chart__ = view; + zoomstarted(dispatch); + zoomed(dispatch); + zoomended(dispatch); + } + }); + } + + zoom.translate = function(_) { + if (!arguments.length) return [view.x, view.y]; + view = {x: +_[0], y: +_[1], k: view.k}; // copy-on-write + rescale(); + return zoom; + }; + + zoom.scale = function(_) { + if (!arguments.length) return view.k; + view = {x: view.x, y: view.y, k: null}; // copy-on-write + scaleTo(+_); + rescale(); + return zoom; + }; + + zoom.scaleExtent = function(_) { + if (!arguments.length) return scaleExtent; + scaleExtent = _ == null ? d3_behavior_zoomInfinity : [+_[0], +_[1]]; + return zoom; + }; + + zoom.center = function(_) { + if (!arguments.length) return center; + center = _ && [+_[0], +_[1]]; + return zoom; + }; + + zoom.size = function(_) { + if (!arguments.length) return size; + size = _ && [+_[0], +_[1]]; + return zoom; + }; + + zoom.duration = function(_) { + if (!arguments.length) return duration; + duration = +_; // TODO function based on interpolateZoom distance? + return zoom; + }; + + zoom.x = function(z) { + if (!arguments.length) return x1; + x1 = z; + x0 = z.copy(); + view = {x: 0, y: 0, k: 1}; // copy-on-write + return zoom; + }; + + zoom.y = function(z) { + if (!arguments.length) return y1; + y1 = z; + y0 = z.copy(); + view = {x: 0, y: 0, k: 1}; // copy-on-write + return zoom; + }; + + function location(p) { + return [(p[0] - view.x) / view.k, (p[1] - view.y) / view.k]; + } + + function point(l) { + return [l[0] * view.k + view.x, l[1] * view.k + view.y]; + } + + function scaleTo(s) { + view.k = Math.max(scaleExtent[0], Math.min(scaleExtent[1], s)); + } + + function translateTo(p, l) { + l = point(l); + view.x += p[0] - l[0]; + view.y += p[1] - l[1]; + } + + function zoomTo(that, p, l, k) { + that.__chart__ = {x: view.x, y: view.y, k: view.k}; + + scaleTo(Math.pow(2, k)); + translateTo(center0 = p, l); + + that = d3.select(that); + if (duration > 0) that = that.transition().duration(duration); + that.call(zoom.event); + } + + function rescale() { + if (x1) x1.domain(x0.range().map(function(x) { return (x - view.x) / view.k; }).map(x0.invert)); + if (y1) y1.domain(y0.range().map(function(y) { return (y - view.y) / view.k; }).map(y0.invert)); + } + + function zoomstarted(dispatch) { + if (!zooming++) dispatch({type: "zoomstart"}); + } + + function zoomed(dispatch) { + rescale(); + dispatch({type: "zoom", scale: view.k, translate: [view.x, view.y]}); + } + + function zoomended(dispatch) { + if (!--zooming) dispatch({type: "zoomend"}), center0 = null; + } + + function mousedowned() { + var that = this, + dispatch = event.of(that, arguments), + dragged = 0, + subject = d3.select(d3_window(that)).on(mousemove, moved).on(mouseup, ended), + location0 = location(d3.mouse(that)), + dragRestore = d3_event_dragSuppress(that); + + d3_selection_interrupt.call(that); + zoomstarted(dispatch); + + function moved() { + dragged = 1; + translateTo(d3.mouse(that), location0); + zoomed(dispatch); + } + + function ended() { + subject.on(mousemove, null).on(mouseup, null); + dragRestore(dragged); + zoomended(dispatch); + } + } + + // These closures persist for as long as at least one touch is active. + function touchstarted() { + var that = this, + dispatch = event.of(that, arguments), + locations0 = {}, // touchstart locations + distance0 = 0, // distance² between initial touches + scale0, // scale when we started touching + zoomName = ".zoom-" + d3.event.changedTouches[0].identifier, + touchmove = "touchmove" + zoomName, + touchend = "touchend" + zoomName, + targets = [], + subject = d3.select(that), + dragRestore = d3_event_dragSuppress(that); + + started(); + zoomstarted(dispatch); + + // Workaround for Chrome issue 412723: the touchstart listener must be set + // after the touchmove listener. + subject.on(mousedown, null).on(touchstart, started); // prevent duplicate events + + // Updates locations of any touches in locations0. + function relocate() { + var touches = d3.touches(that); + scale0 = view.k; + touches.forEach(function(t) { + if (t.identifier in locations0) locations0[t.identifier] = location(t); + }); + return touches; + } + + // Temporarily override touchstart while gesture is active. + function started() { + + // Listen for touchmove and touchend on the target of touchstart. + var target = d3.event.target; + d3.select(target).on(touchmove, moved).on(touchend, ended); + targets.push(target); + + // Only track touches started on the same subject element. + var changed = d3.event.changedTouches; + for (var i = 0, n = changed.length; i < n; ++i) { + locations0[changed[i].identifier] = null; + } + + var touches = relocate(), + now = Date.now(); + + if (touches.length === 1) { + if (now - touchtime < 500) { // dbltap + var p = touches[0]; + zoomTo(that, p, locations0[p.identifier], Math.floor(Math.log(view.k) / Math.LN2) + 1); + d3_eventPreventDefault(); + } + touchtime = now; + } else if (touches.length > 1) { + var p = touches[0], q = touches[1], + dx = p[0] - q[0], dy = p[1] - q[1]; + distance0 = dx * dx + dy * dy; + } + } + + function moved() { + var touches = d3.touches(that), + p0, l0, + p1, l1; + + d3_selection_interrupt.call(that); + + for (var i = 0, n = touches.length; i < n; ++i, l1 = null) { + p1 = touches[i]; + if (l1 = locations0[p1.identifier]) { + if (l0) break; + p0 = p1, l0 = l1; + } + } + + if (l1) { + var distance1 = (distance1 = p1[0] - p0[0]) * distance1 + (distance1 = p1[1] - p0[1]) * distance1, + scale1 = distance0 && Math.sqrt(distance1 / distance0); + p0 = [(p0[0] + p1[0]) / 2, (p0[1] + p1[1]) / 2]; + l0 = [(l0[0] + l1[0]) / 2, (l0[1] + l1[1]) / 2]; + scaleTo(scale1 * scale0); + } + + touchtime = null; + translateTo(p0, l0); + zoomed(dispatch); + } + + function ended() { + // If there are any globally-active touches remaining, remove the ended + // touches from locations0. + if (d3.event.touches.length) { + var changed = d3.event.changedTouches; + for (var i = 0, n = changed.length; i < n; ++i) { + delete locations0[changed[i].identifier]; + } + // If locations0 is not empty, then relocate and continue listening for + // touchmove and touchend. + for (var identifier in locations0) { + return void relocate(); // locations may have detached due to rotation + } + } + // Otherwise, remove touchmove and touchend listeners. + d3.selectAll(targets).on(zoomName, null); + subject.on(mousedown, mousedowned).on(touchstart, touchstarted); + dragRestore(); + zoomended(dispatch); + } + } + + function mousewheeled() { + var dispatch = event.of(this, arguments); + if (mousewheelTimer) clearTimeout(mousewheelTimer); + else d3_selection_interrupt.call(this), translate0 = location(center0 = center || d3.mouse(this)), zoomstarted(dispatch); + mousewheelTimer = setTimeout(function() { mousewheelTimer = null; zoomended(dispatch); }, 50); + d3_eventPreventDefault(); + scaleTo(Math.pow(2, d3_behavior_zoomDelta() * 0.002) * view.k); + translateTo(center0, translate0); + zoomed(dispatch); + } + + function dblclicked() { + var p = d3.mouse(this), + k = Math.log(view.k) / Math.LN2; + + zoomTo(this, p, location(p), d3.event.shiftKey ? Math.ceil(k) - 1 : Math.floor(k) + 1); + } + + return d3.rebind(zoom, event, "on"); +}; + +var d3_behavior_zoomInfinity = [0, Infinity], // default scale extent + d3_behavior_zoomDelta, // initialized lazily + d3_behavior_zoomWheel; diff --git a/node_modules/@plotly/d3/src/color/color.js b/node_modules/@plotly/d3/src/color/color.js new file mode 100644 index 0000000000000000000000000000000000000000..5620feaf8c23bfa44c051f91481c404dd4ec9589 --- /dev/null +++ b/node_modules/@plotly/d3/src/color/color.js @@ -0,0 +1,7 @@ +d3.color = d3_color; + +function d3_color() {} + +d3_color.prototype.toString = function() { + return this.rgb() + ""; +}; diff --git a/node_modules/@plotly/d3/src/color/hcl.js b/node_modules/@plotly/d3/src/color/hcl.js new file mode 100644 index 0000000000000000000000000000000000000000..509fe3be5cce1c61c8a91e1a90841cec89a2a66c --- /dev/null +++ b/node_modules/@plotly/d3/src/color/hcl.js @@ -0,0 +1,34 @@ +import "../math/trigonometry"; +import "color"; +import "lab"; +import "rgb"; + +d3.hcl = d3_hcl; + +function d3_hcl(h, c, l) { + return this instanceof d3_hcl ? void (this.h = +h, this.c = +c, this.l = +l) + : arguments.length < 2 ? (h instanceof d3_hcl ? new d3_hcl(h.h, h.c, h.l) + : (h instanceof d3_lab ? d3_lab_hcl(h.l, h.a, h.b) + : d3_lab_hcl((h = d3_rgb_lab((h = d3.rgb(h)).r, h.g, h.b)).l, h.a, h.b))) + : new d3_hcl(h, c, l); +} + +var d3_hclPrototype = d3_hcl.prototype = new d3_color; + +d3_hclPrototype.brighter = function(k) { + return new d3_hcl(this.h, this.c, Math.min(100, this.l + d3_lab_K * (arguments.length ? k : 1))); +}; + +d3_hclPrototype.darker = function(k) { + return new d3_hcl(this.h, this.c, Math.max(0, this.l - d3_lab_K * (arguments.length ? k : 1))); +}; + +d3_hclPrototype.rgb = function() { + return d3_hcl_lab(this.h, this.c, this.l).rgb(); +}; + +function d3_hcl_lab(h, c, l) { + if (isNaN(h)) h = 0; + if (isNaN(c)) c = 0; + return new d3_lab(l, Math.cos(h *= d3_radians) * c, Math.sin(h) * c); +} diff --git a/node_modules/@plotly/d3/src/color/hsl.js b/node_modules/@plotly/d3/src/color/hsl.js new file mode 100644 index 0000000000000000000000000000000000000000..2993f06363bcfad6f4d520ebb72caf6c8fba7e83 --- /dev/null +++ b/node_modules/@plotly/d3/src/color/hsl.js @@ -0,0 +1,56 @@ +import "color"; +import "rgb"; + +d3.hsl = d3_hsl; + +function d3_hsl(h, s, l) { + return this instanceof d3_hsl ? void (this.h = +h, this.s = +s, this.l = +l) + : arguments.length < 2 ? (h instanceof d3_hsl ? new d3_hsl(h.h, h.s, h.l) + : d3_rgb_parse("" + h, d3_rgb_hsl, d3_hsl)) + : new d3_hsl(h, s, l); +} + +var d3_hslPrototype = d3_hsl.prototype = new d3_color; + +d3_hslPrototype.brighter = function(k) { + k = Math.pow(0.7, arguments.length ? k : 1); + return new d3_hsl(this.h, this.s, this.l / k); +}; + +d3_hslPrototype.darker = function(k) { + k = Math.pow(0.7, arguments.length ? k : 1); + return new d3_hsl(this.h, this.s, k * this.l); +}; + +d3_hslPrototype.rgb = function() { + return d3_hsl_rgb(this.h, this.s, this.l); +}; + +function d3_hsl_rgb(h, s, l) { + var m1, + m2; + + /* Some simple corrections for h, s and l. */ + h = isNaN(h) ? 0 : (h %= 360) < 0 ? h + 360 : h; + s = isNaN(s) ? 0 : s < 0 ? 0 : s > 1 ? 1 : s; + l = l < 0 ? 0 : l > 1 ? 1 : l; + + /* From FvD 13.37, CSS Color Module Level 3 */ + m2 = l <= 0.5 ? l * (1 + s) : l + s - l * s; + m1 = 2 * l - m2; + + function v(h) { + if (h > 360) h -= 360; + else if (h < 0) h += 360; + if (h < 60) return m1 + (m2 - m1) * h / 60; + if (h < 180) return m2; + if (h < 240) return m1 + (m2 - m1) * (240 - h) / 60; + return m1; + } + + function vv(h) { + return Math.round(v(h) * 255); + } + + return new d3_rgb(vv(h + 120), vv(h), vv(h - 120)); +} diff --git a/node_modules/@plotly/d3/src/color/index.js b/node_modules/@plotly/d3/src/color/index.js new file mode 100644 index 0000000000000000000000000000000000000000..3be3854c99d18655549a1e6ef96a19fbb7b629f3 --- /dev/null +++ b/node_modules/@plotly/d3/src/color/index.js @@ -0,0 +1,6 @@ +import "color"; +import "rgb"; +import "hsl"; +import "hcl"; +import "lab"; +import "xyz"; diff --git a/node_modules/@plotly/d3/src/color/lab.js b/node_modules/@plotly/d3/src/color/lab.js new file mode 100644 index 0000000000000000000000000000000000000000..36d8791528c14ffb244eeaeb44cc7fdc6a435aff --- /dev/null +++ b/node_modules/@plotly/d3/src/color/lab.js @@ -0,0 +1,60 @@ +import "../math/trigonometry"; +import "color"; +import "hcl"; +import "rgb"; + +d3.lab = d3_lab; + +function d3_lab(l, a, b) { + return this instanceof d3_lab ? void (this.l = +l, this.a = +a, this.b = +b) + : arguments.length < 2 ? (l instanceof d3_lab ? new d3_lab(l.l, l.a, l.b) + : (l instanceof d3_hcl ? d3_hcl_lab(l.h, l.c, l.l) + : d3_rgb_lab((l = d3_rgb(l)).r, l.g, l.b))) + : new d3_lab(l, a, b); +} + +// Corresponds roughly to RGB brighter/darker +var d3_lab_K = 18; + +// D65 standard referent +var d3_lab_X = 0.950470, + d3_lab_Y = 1, + d3_lab_Z = 1.088830; + +var d3_labPrototype = d3_lab.prototype = new d3_color; + +d3_labPrototype.brighter = function(k) { + return new d3_lab(Math.min(100, this.l + d3_lab_K * (arguments.length ? k : 1)), this.a, this.b); +}; + +d3_labPrototype.darker = function(k) { + return new d3_lab(Math.max(0, this.l - d3_lab_K * (arguments.length ? k : 1)), this.a, this.b); +}; + +d3_labPrototype.rgb = function() { + return d3_lab_rgb(this.l, this.a, this.b); +}; + +function d3_lab_rgb(l, a, b) { + var y = (l + 16) / 116, + x = y + a / 500, + z = y - b / 200; + x = d3_lab_xyz(x) * d3_lab_X; + y = d3_lab_xyz(y) * d3_lab_Y; + z = d3_lab_xyz(z) * d3_lab_Z; + return new d3_rgb( + d3_xyz_rgb( 3.2404542 * x - 1.5371385 * y - 0.4985314 * z), + d3_xyz_rgb(-0.9692660 * x + 1.8760108 * y + 0.0415560 * z), + d3_xyz_rgb( 0.0556434 * x - 0.2040259 * y + 1.0572252 * z) + ); +} + +function d3_lab_hcl(l, a, b) { + return l > 0 + ? new d3_hcl(Math.atan2(b, a) * d3_degrees, Math.sqrt(a * a + b * b), l) + : new d3_hcl(NaN, NaN, l); +} + +function d3_lab_xyz(x) { + return x > 0.206893034 ? x * x * x : (x - 4 / 29) / 7.787037; +} diff --git a/node_modules/@plotly/d3/src/color/rgb.js b/node_modules/@plotly/d3/src/color/rgb.js new file mode 100644 index 0000000000000000000000000000000000000000..bccc2d23321d0cae4c3a10498f309c506f55f598 --- /dev/null +++ b/node_modules/@plotly/d3/src/color/rgb.js @@ -0,0 +1,301 @@ +import "../arrays/map"; +import "color"; +import "hsl"; +import "lab"; +import "xyz"; + +d3.rgb = d3_rgb; + +function d3_rgb(r, g, b) { + return this instanceof d3_rgb ? void (this.r = ~~r, this.g = ~~g, this.b = ~~b) + : arguments.length < 2 ? (r instanceof d3_rgb ? new d3_rgb(r.r, r.g, r.b) + : d3_rgb_parse("" + r, d3_rgb, d3_hsl_rgb)) + : new d3_rgb(r, g, b); +} + +function d3_rgbNumber(value) { + return new d3_rgb(value >> 16, value >> 8 & 0xff, value & 0xff); +} + +function d3_rgbString(value) { + return d3_rgbNumber(value) + ""; +} + +var d3_rgbPrototype = d3_rgb.prototype = new d3_color; + +d3_rgbPrototype.brighter = function(k) { + k = Math.pow(0.7, arguments.length ? k : 1); + var r = this.r, + g = this.g, + b = this.b, + i = 30; + if (!r && !g && !b) return new d3_rgb(i, i, i); + if (r && r < i) r = i; + if (g && g < i) g = i; + if (b && b < i) b = i; + return new d3_rgb(Math.min(255, r / k), Math.min(255, g / k), Math.min(255, b / k)); +}; + +d3_rgbPrototype.darker = function(k) { + k = Math.pow(0.7, arguments.length ? k : 1); + return new d3_rgb(k * this.r, k * this.g, k * this.b); +}; + +d3_rgbPrototype.hsl = function() { + return d3_rgb_hsl(this.r, this.g, this.b); +}; + +d3_rgbPrototype.toString = function() { + return "#" + d3_rgb_hex(this.r) + d3_rgb_hex(this.g) + d3_rgb_hex(this.b); +}; + +function d3_rgb_hex(v) { + return v < 0x10 + ? "0" + Math.max(0, v).toString(16) + : Math.min(255, v).toString(16); +} + +function d3_rgb_parse(format, rgb, hsl) { + var r = 0, // red channel; int in [0, 255] + g = 0, // green channel; int in [0, 255] + b = 0, // blue channel; int in [0, 255] + m1, // CSS color specification match + m2, // CSS color specification type (e.g., rgb) + color; + + /* Handle hsl, rgb. */ + m1 = /([a-z]+)\((.*)\)/.exec(format = format.toLowerCase()); + if (m1) { + m2 = m1[2].split(","); + switch (m1[1]) { + case "hsl": { + return hsl( + parseFloat(m2[0]), // degrees + parseFloat(m2[1]) / 100, // percentage + parseFloat(m2[2]) / 100 // percentage + ); + } + case "rgb": { + return rgb( + d3_rgb_parseNumber(m2[0]), + d3_rgb_parseNumber(m2[1]), + d3_rgb_parseNumber(m2[2]) + ); + } + } + } + + /* Named colors. */ + if (color = d3_rgb_names.get(format)) { + return rgb(color.r, color.g, color.b); + } + + /* Hexadecimal colors: #rgb and #rrggbb. */ + if (format != null && format.charAt(0) === "#" && !isNaN(color = parseInt(format.slice(1), 16))) { + if (format.length === 4) { + r = (color & 0xf00) >> 4; r = (r >> 4) | r; + g = (color & 0xf0); g = (g >> 4) | g; + b = (color & 0xf); b = (b << 4) | b; + } else if (format.length === 7) { + r = (color & 0xff0000) >> 16; + g = (color & 0xff00) >> 8; + b = (color & 0xff); + } + } + + return rgb(r, g, b); +} + +function d3_rgb_hsl(r, g, b) { + var min = Math.min(r /= 255, g /= 255, b /= 255), + max = Math.max(r, g, b), + d = max - min, + h, + s, + l = (max + min) / 2; + if (d) { + s = l < 0.5 ? d / (max + min) : d / (2 - max - min); + if (r == max) h = (g - b) / d + (g < b ? 6 : 0); + else if (g == max) h = (b - r) / d + 2; + else h = (r - g) / d + 4; + h *= 60; + } else { + h = NaN; + s = l > 0 && l < 1 ? 0 : h; + } + return new d3_hsl(h, s, l); +} + +function d3_rgb_lab(r, g, b) { + r = d3_rgb_xyz(r); + g = d3_rgb_xyz(g); + b = d3_rgb_xyz(b); + var x = d3_xyz_lab((0.4124564 * r + 0.3575761 * g + 0.1804375 * b) / d3_lab_X), + y = d3_xyz_lab((0.2126729 * r + 0.7151522 * g + 0.0721750 * b) / d3_lab_Y), + z = d3_xyz_lab((0.0193339 * r + 0.1191920 * g + 0.9503041 * b) / d3_lab_Z); + return d3_lab(116 * y - 16, 500 * (x - y), 200 * (y - z)); +} + +function d3_rgb_xyz(r) { + return (r /= 255) <= 0.04045 ? r / 12.92 : Math.pow((r + 0.055) / 1.055, 2.4); +} + +function d3_rgb_parseNumber(c) { // either integer or percentage + var f = parseFloat(c); + return c.charAt(c.length - 1) === "%" ? Math.round(f * 2.55) : f; +} + +var d3_rgb_names = d3.map({ + aliceblue: 0xf0f8ff, + antiquewhite: 0xfaebd7, + aqua: 0x00ffff, + aquamarine: 0x7fffd4, + azure: 0xf0ffff, + beige: 0xf5f5dc, + bisque: 0xffe4c4, + black: 0x000000, + blanchedalmond: 0xffebcd, + blue: 0x0000ff, + blueviolet: 0x8a2be2, + brown: 0xa52a2a, + burlywood: 0xdeb887, + cadetblue: 0x5f9ea0, + chartreuse: 0x7fff00, + chocolate: 0xd2691e, + coral: 0xff7f50, + cornflowerblue: 0x6495ed, + cornsilk: 0xfff8dc, + crimson: 0xdc143c, + cyan: 0x00ffff, + darkblue: 0x00008b, + darkcyan: 0x008b8b, + darkgoldenrod: 0xb8860b, + darkgray: 0xa9a9a9, + darkgreen: 0x006400, + darkgrey: 0xa9a9a9, + darkkhaki: 0xbdb76b, + darkmagenta: 0x8b008b, + darkolivegreen: 0x556b2f, + darkorange: 0xff8c00, + darkorchid: 0x9932cc, + darkred: 0x8b0000, + darksalmon: 0xe9967a, + darkseagreen: 0x8fbc8f, + darkslateblue: 0x483d8b, + darkslategray: 0x2f4f4f, + darkslategrey: 0x2f4f4f, + darkturquoise: 0x00ced1, + darkviolet: 0x9400d3, + deeppink: 0xff1493, + deepskyblue: 0x00bfff, + dimgray: 0x696969, + dimgrey: 0x696969, + dodgerblue: 0x1e90ff, + firebrick: 0xb22222, + floralwhite: 0xfffaf0, + forestgreen: 0x228b22, + fuchsia: 0xff00ff, + gainsboro: 0xdcdcdc, + ghostwhite: 0xf8f8ff, + gold: 0xffd700, + goldenrod: 0xdaa520, + gray: 0x808080, + green: 0x008000, + greenyellow: 0xadff2f, + grey: 0x808080, + honeydew: 0xf0fff0, + hotpink: 0xff69b4, + indianred: 0xcd5c5c, + indigo: 0x4b0082, + ivory: 0xfffff0, + khaki: 0xf0e68c, + lavender: 0xe6e6fa, + lavenderblush: 0xfff0f5, + lawngreen: 0x7cfc00, + lemonchiffon: 0xfffacd, + lightblue: 0xadd8e6, + lightcoral: 0xf08080, + lightcyan: 0xe0ffff, + lightgoldenrodyellow: 0xfafad2, + lightgray: 0xd3d3d3, + lightgreen: 0x90ee90, + lightgrey: 0xd3d3d3, + lightpink: 0xffb6c1, + lightsalmon: 0xffa07a, + lightseagreen: 0x20b2aa, + lightskyblue: 0x87cefa, + lightslategray: 0x778899, + lightslategrey: 0x778899, + lightsteelblue: 0xb0c4de, + lightyellow: 0xffffe0, + lime: 0x00ff00, + limegreen: 0x32cd32, + linen: 0xfaf0e6, + magenta: 0xff00ff, + maroon: 0x800000, + mediumaquamarine: 0x66cdaa, + mediumblue: 0x0000cd, + mediumorchid: 0xba55d3, + mediumpurple: 0x9370db, + mediumseagreen: 0x3cb371, + mediumslateblue: 0x7b68ee, + mediumspringgreen: 0x00fa9a, + mediumturquoise: 0x48d1cc, + mediumvioletred: 0xc71585, + midnightblue: 0x191970, + mintcream: 0xf5fffa, + mistyrose: 0xffe4e1, + moccasin: 0xffe4b5, + navajowhite: 0xffdead, + navy: 0x000080, + oldlace: 0xfdf5e6, + olive: 0x808000, + olivedrab: 0x6b8e23, + orange: 0xffa500, + orangered: 0xff4500, + orchid: 0xda70d6, + palegoldenrod: 0xeee8aa, + palegreen: 0x98fb98, + paleturquoise: 0xafeeee, + palevioletred: 0xdb7093, + papayawhip: 0xffefd5, + peachpuff: 0xffdab9, + peru: 0xcd853f, + pink: 0xffc0cb, + plum: 0xdda0dd, + powderblue: 0xb0e0e6, + purple: 0x800080, + rebeccapurple: 0x663399, + red: 0xff0000, + rosybrown: 0xbc8f8f, + royalblue: 0x4169e1, + saddlebrown: 0x8b4513, + salmon: 0xfa8072, + sandybrown: 0xf4a460, + seagreen: 0x2e8b57, + seashell: 0xfff5ee, + sienna: 0xa0522d, + silver: 0xc0c0c0, + skyblue: 0x87ceeb, + slateblue: 0x6a5acd, + slategray: 0x708090, + slategrey: 0x708090, + snow: 0xfffafa, + springgreen: 0x00ff7f, + steelblue: 0x4682b4, + tan: 0xd2b48c, + teal: 0x008080, + thistle: 0xd8bfd8, + tomato: 0xff6347, + turquoise: 0x40e0d0, + violet: 0xee82ee, + wheat: 0xf5deb3, + white: 0xffffff, + whitesmoke: 0xf5f5f5, + yellow: 0xffff00, + yellowgreen: 0x9acd32 +}); + +d3_rgb_names.forEach(function(key, value) { + d3_rgb_names.set(key, d3_rgbNumber(value)); +}); diff --git a/node_modules/@plotly/d3/src/color/xyz.js b/node_modules/@plotly/d3/src/color/xyz.js new file mode 100644 index 0000000000000000000000000000000000000000..30e79ab412bf0557483eeb8ffe632036f22ab6f7 --- /dev/null +++ b/node_modules/@plotly/d3/src/color/xyz.js @@ -0,0 +1,7 @@ +function d3_xyz_lab(x) { + return x > 0.008856 ? Math.pow(x, 1 / 3) : 7.787037 * x + 4 / 29; +} + +function d3_xyz_rgb(r) { + return Math.round(255 * (r <= 0.00304 ? 12.92 * r : 1.055 * Math.pow(r, 1 / 2.4) - 0.055)); +} diff --git a/node_modules/@plotly/d3/src/compat/array.js b/node_modules/@plotly/d3/src/compat/array.js new file mode 100644 index 0000000000000000000000000000000000000000..d5a0ab6cb86f019f2f5e2ee1df087696875d8942 --- /dev/null +++ b/node_modules/@plotly/d3/src/compat/array.js @@ -0,0 +1,15 @@ +import "../core/array"; +import "../core/document"; + +// Redefine d3_array if the browser doesn’t support slice-based conversion. +if (d3_document) { + try { + d3_array(d3_document.documentElement.childNodes)[0].nodeType; + } catch (e) { + d3_array = function(list) { + var i = list.length, array = new Array(i); + while (i--) array[i] = list[i]; + return array; + }; + } +} diff --git a/node_modules/@plotly/d3/src/compat/date.js b/node_modules/@plotly/d3/src/compat/date.js new file mode 100644 index 0000000000000000000000000000000000000000..e682d4cb8099fa20419ef16e13addeeafc767acc --- /dev/null +++ b/node_modules/@plotly/d3/src/compat/date.js @@ -0,0 +1,3 @@ +if (!Date.now) Date.now = function() { + return +new Date; +}; diff --git a/node_modules/@plotly/d3/src/compat/index.js b/node_modules/@plotly/d3/src/compat/index.js new file mode 100644 index 0000000000000000000000000000000000000000..ec0e180e2a4ab5b59a51bb42620d355fc4eeb641 --- /dev/null +++ b/node_modules/@plotly/d3/src/compat/index.js @@ -0,0 +1,3 @@ +import "array"; +import "date"; +import "style"; diff --git a/node_modules/@plotly/d3/src/compat/style.js b/node_modules/@plotly/d3/src/compat/style.js new file mode 100644 index 0000000000000000000000000000000000000000..76563a20fe906fe74e443a2b0cdf1f19ee00322c --- /dev/null +++ b/node_modules/@plotly/d3/src/compat/style.js @@ -0,0 +1,23 @@ +import "../core/document"; + +// Redefine style.setProperty et al. if the browser doesn’t coerce arguments. +if (d3_document) { + try { + d3_document.createElement("DIV").style.setProperty("opacity", 0, ""); + } catch (error) { + var d3_element_prototype = this.Element.prototype, + d3_element_setAttribute = d3_element_prototype.setAttribute, + d3_element_setAttributeNS = d3_element_prototype.setAttributeNS, + d3_style_prototype = this.CSSStyleDeclaration.prototype, + d3_style_setProperty = d3_style_prototype.setProperty; + d3_element_prototype.setAttribute = function(name, value) { + d3_element_setAttribute.call(this, name, value + ""); + }; + d3_element_prototype.setAttributeNS = function(space, local, value) { + d3_element_setAttributeNS.call(this, space, local, value + ""); + }; + d3_style_prototype.setProperty = function(name, value, priority) { + d3_style_setProperty.call(this, name, value + "", priority); + }; + } +} diff --git a/node_modules/@plotly/d3/src/core/array.js b/node_modules/@plotly/d3/src/core/array.js new file mode 100644 index 0000000000000000000000000000000000000000..cb4fd3661b765a099c15a6662d03f7e002fa8be8 --- /dev/null +++ b/node_modules/@plotly/d3/src/core/array.js @@ -0,0 +1,2 @@ +var d3_arraySlice = [].slice, + d3_array = function(list) { return d3_arraySlice.call(list); }; // conversion for NodeLists diff --git a/node_modules/@plotly/d3/src/core/class.js b/node_modules/@plotly/d3/src/core/class.js new file mode 100644 index 0000000000000000000000000000000000000000..7f1d7439f9cebba3c65fceee3c2af3310cca8ef3 --- /dev/null +++ b/node_modules/@plotly/d3/src/core/class.js @@ -0,0 +1,8 @@ +function d3_class(ctor, properties) { + for (var key in properties) { + Object.defineProperty(ctor.prototype, key, { + value: properties[key], + enumerable: false + }); + } +} diff --git a/node_modules/@plotly/d3/src/core/document.js b/node_modules/@plotly/d3/src/core/document.js new file mode 100644 index 0000000000000000000000000000000000000000..f59a21494000dfffe831302d1326507221a8173c --- /dev/null +++ b/node_modules/@plotly/d3/src/core/document.js @@ -0,0 +1,15 @@ +var d3_document = self.document; + +function d3_documentElement(node) { + return node + && (node.ownerDocument // node is a Node + || node.document // node is a Window + || node).documentElement; // node is a Document +} + +function d3_window(node) { + return node + && ((node.ownerDocument && node.ownerDocument.defaultView) // node is a Node + || (node.document && node) // node is a Window + || node.defaultView); // node is a Document +} diff --git a/node_modules/@plotly/d3/src/core/functor.js b/node_modules/@plotly/d3/src/core/functor.js new file mode 100644 index 0000000000000000000000000000000000000000..f8b1bf7cbbd525e3983c582b71f5da7ae2ee4589 --- /dev/null +++ b/node_modules/@plotly/d3/src/core/functor.js @@ -0,0 +1,5 @@ +function d3_functor(v) { + return typeof v === "function" ? v : function() { return v; }; +} + +d3.functor = d3_functor; diff --git a/node_modules/@plotly/d3/src/core/identity.js b/node_modules/@plotly/d3/src/core/identity.js new file mode 100644 index 0000000000000000000000000000000000000000..73893f86231a56439789740ec93d51d5957f1b40 --- /dev/null +++ b/node_modules/@plotly/d3/src/core/identity.js @@ -0,0 +1,3 @@ +function d3_identity(d) { + return d; +} diff --git a/node_modules/@plotly/d3/src/core/index.js b/node_modules/@plotly/d3/src/core/index.js new file mode 100644 index 0000000000000000000000000000000000000000..f6d233e0af93589ef238b25ccbe5c2461776eb56 --- /dev/null +++ b/node_modules/@plotly/d3/src/core/index.js @@ -0,0 +1,3 @@ +import "functor"; +import "ns"; +import "rebind"; diff --git a/node_modules/@plotly/d3/src/core/noop.js b/node_modules/@plotly/d3/src/core/noop.js new file mode 100644 index 0000000000000000000000000000000000000000..35f91d114d1b3ee28ff72423a87a398adf110d55 --- /dev/null +++ b/node_modules/@plotly/d3/src/core/noop.js @@ -0,0 +1 @@ +function d3_noop() {} diff --git a/node_modules/@plotly/d3/src/core/ns.js b/node_modules/@plotly/d3/src/core/ns.js new file mode 100644 index 0000000000000000000000000000000000000000..23f476291e2c05b6d239c5982942bfdefdb83259 --- /dev/null +++ b/node_modules/@plotly/d3/src/core/ns.js @@ -0,0 +1,18 @@ +var d3_nsXhtml = "http://www.w3.org/1999/xhtml"; + +var d3_nsPrefix = { + svg: "http://www.w3.org/2000/svg", + xhtml: d3_nsXhtml, + xlink: "http://www.w3.org/1999/xlink", + xml: "http://www.w3.org/XML/1998/namespace", + xmlns: "http://www.w3.org/2000/xmlns/" +}; + +d3.ns = { + prefix: d3_nsPrefix, + qualify: function(name) { + var i = name.indexOf(":"), prefix = name; + if (i >= 0 && (prefix = name.slice(0, i)) !== "xmlns") name = name.slice(i + 1); + return d3_nsPrefix.hasOwnProperty(prefix) ? {space: d3_nsPrefix[prefix], local: name} : name; + } +}; diff --git a/node_modules/@plotly/d3/src/core/rebind.js b/node_modules/@plotly/d3/src/core/rebind.js new file mode 100644 index 0000000000000000000000000000000000000000..d61184646eee4d52f67989d84d8f4fb5af237c06 --- /dev/null +++ b/node_modules/@plotly/d3/src/core/rebind.js @@ -0,0 +1,16 @@ +// Copies a variable number of methods from source to target. +d3.rebind = function(target, source) { + var i = 1, n = arguments.length, method; + while (++i < n) target[method = arguments[i]] = d3_rebind(target, source, source[method]); + return target; +}; + +// Method is assumed to be a standard D3 getter-setter: +// If passed with no arguments, gets the value. +// If passed with arguments, sets the value and returns the target. +function d3_rebind(target, source, method) { + return function() { + var value = method.apply(source, arguments); + return value === source ? target : value; + }; +} diff --git a/node_modules/@plotly/d3/src/core/source.js b/node_modules/@plotly/d3/src/core/source.js new file mode 100644 index 0000000000000000000000000000000000000000..f56f50138f1b12c1d6a4985ca9fde0858f30ed29 --- /dev/null +++ b/node_modules/@plotly/d3/src/core/source.js @@ -0,0 +1,3 @@ +function d3_source(d) { + return d.source; +} diff --git a/node_modules/@plotly/d3/src/core/subclass.js b/node_modules/@plotly/d3/src/core/subclass.js new file mode 100644 index 0000000000000000000000000000000000000000..ea8dc856cda0b4dca7acd27d65349717c05692a7 --- /dev/null +++ b/node_modules/@plotly/d3/src/core/subclass.js @@ -0,0 +1,11 @@ +var d3_subclass = {}.__proto__? + +// Until ECMAScript supports array subclassing, prototype injection works well. +function(object, prototype) { + object.__proto__ = prototype; +}: + +// And if your browser doesn't support __proto__, we'll use direct extension. +function(object, prototype) { + for (var property in prototype) object[property] = prototype[property]; +}; diff --git a/node_modules/@plotly/d3/src/core/target.js b/node_modules/@plotly/d3/src/core/target.js new file mode 100644 index 0000000000000000000000000000000000000000..766ba7ee21267d56a6795175da7eec1570856072 --- /dev/null +++ b/node_modules/@plotly/d3/src/core/target.js @@ -0,0 +1,3 @@ +function d3_target(d) { + return d.target; +} diff --git a/node_modules/@plotly/d3/src/core/true.js b/node_modules/@plotly/d3/src/core/true.js new file mode 100644 index 0000000000000000000000000000000000000000..0900faf20833cec1cb2aae6b17596a0743ead520 --- /dev/null +++ b/node_modules/@plotly/d3/src/core/true.js @@ -0,0 +1,3 @@ +function d3_true() { + return true; +} diff --git a/node_modules/@plotly/d3/src/core/vendor.js b/node_modules/@plotly/d3/src/core/vendor.js new file mode 100644 index 0000000000000000000000000000000000000000..b92c7fe40ebe2fc82e790e30bf3d9d4878bcd805 --- /dev/null +++ b/node_modules/@plotly/d3/src/core/vendor.js @@ -0,0 +1,10 @@ +function d3_vendorSymbol(object, name) { + if (name in object) return name; + name = name.charAt(0).toUpperCase() + name.slice(1); + for (var i = 0, n = d3_vendorPrefixes.length; i < n; ++i) { + var prefixName = d3_vendorPrefixes[i] + name; + if (prefixName in object) return prefixName; + } +} + +var d3_vendorPrefixes = ["webkit", "ms", "moz", "Moz", "o", "O"]; diff --git a/node_modules/@plotly/d3/src/core/zero.js b/node_modules/@plotly/d3/src/core/zero.js new file mode 100644 index 0000000000000000000000000000000000000000..18b52afe7eb1bf1d4c60de130b4403ff87567bf6 --- /dev/null +++ b/node_modules/@plotly/d3/src/core/zero.js @@ -0,0 +1,3 @@ +function d3_zero() { + return 0; +} diff --git a/node_modules/@plotly/d3/src/d3.js b/node_modules/@plotly/d3/src/d3.js new file mode 100644 index 0000000000000000000000000000000000000000..f5524beb407c6e1bbe4b4867388bacf85aea5cce --- /dev/null +++ b/node_modules/@plotly/d3/src/d3.js @@ -0,0 +1,21 @@ +import "start"; +import "compat/"; + +import "arrays/"; +import "behavior/"; +import "color/"; +import "core/"; +import "dsv/"; +import "event/"; +import "format/"; +import "geom/"; +import "interpolate/"; +import "layout/"; +import "math/"; +import "scale/"; +import "selection/"; +import "svg/"; +import "transition/"; +import "xhr/"; + +import "end"; diff --git a/node_modules/@plotly/d3/src/dsv/csv.js b/node_modules/@plotly/d3/src/dsv/csv.js new file mode 100644 index 0000000000000000000000000000000000000000..2b6d94f68376d7ef4949840ce874693692caf5aa --- /dev/null +++ b/node_modules/@plotly/d3/src/dsv/csv.js @@ -0,0 +1,3 @@ +import "dsv"; + +d3.csv = d3.dsv(",", "text/csv"); diff --git a/node_modules/@plotly/d3/src/dsv/dsv.js b/node_modules/@plotly/d3/src/dsv/dsv.js new file mode 100644 index 0000000000000000000000000000000000000000..7c34171560bc787788f3ad1de21e6a353bf96344 --- /dev/null +++ b/node_modules/@plotly/d3/src/dsv/dsv.js @@ -0,0 +1,143 @@ +import "../arrays/set"; +import "../xhr/xhr"; + +d3.dsv = function(delimiter, mimeType) { + var reFormat = new RegExp("[\"" + delimiter + "\n]"), + delimiterCode = delimiter.charCodeAt(0); + + function dsv(url, row, callback) { + if (arguments.length < 3) callback = row, row = null; + var xhr = d3_xhr(url, mimeType, row == null ? response : typedResponse(row), callback); + + xhr.row = function(_) { + return arguments.length + ? xhr.response((row = _) == null ? response : typedResponse(_)) + : row; + }; + + return xhr; + } + + function response(request) { + return dsv.parse(request.responseText); + } + + function typedResponse(f) { + return function(request) { + return dsv.parse(request.responseText, f); + }; + } + + dsv.parse = function(text, f) { + var o; + return dsv.parseRows(text, function(row, i) { + if (o) return o(row, i - 1); + + var a = function(d) { + var obj = {}; + var len = row.length; + for(var k = 0; k < len; ++k) { + obj[row[k]] = d[k]; + } + return obj; + } + + o = f ? function(row, i) { return f(a(row), i); } : a; + }); + }; + + dsv.parseRows = function(text, f) { + var EOL = {}, // sentinel value for end-of-line + EOF = {}, // sentinel value for end-of-file + rows = [], // output rows + N = text.length, + I = 0, // current character index + n = 0, // the current line number + t, // the current token + eol; // is the current token followed by EOL? + + function token() { + if (I >= N) return EOF; // special case: end of file + if (eol) return eol = false, EOL; // special case: end of line + + // special case: quotes + var j = I; + if (text.charCodeAt(j) === 34) { + var i = j; + while (i++ < N) { + if (text.charCodeAt(i) === 34) { + if (text.charCodeAt(i + 1) !== 34) break; + ++i; + } + } + I = i + 2; + var c = text.charCodeAt(i + 1); + if (c === 13) { + eol = true; + if (text.charCodeAt(i + 2) === 10) ++I; + } else if (c === 10) { + eol = true; + } + return text.slice(j + 1, i).replace(/""/g, "\""); + } + + // common case: find next delimiter or newline + while (I < N) { + var c = text.charCodeAt(I++), k = 1; + if (c === 10) eol = true; // \n + else if (c === 13) { eol = true; if (text.charCodeAt(I) === 10) ++I, ++k; } // \r|\r\n + else if (c !== delimiterCode) continue; + return text.slice(j, I - k); + } + + // special case: last token before EOF + return text.slice(j); + } + + while ((t = token()) !== EOF) { + var a = []; + while (t !== EOL && t !== EOF) { + a.push(t); + t = token(); + } + if (f && (a = f(a, n++)) == null) continue; + rows.push(a); + } + + return rows; + }; + + dsv.format = function(rows) { + if (Array.isArray(rows[0])) return dsv.formatRows(rows); // deprecated; use formatRows + var fieldSet = new d3_Set, fields = []; + + // Compute unique fields in order of discovery. + rows.forEach(function(row) { + for (var field in row) { + if (!fieldSet.has(field)) { + fields.push(fieldSet.add(field)); + } + } + }); + + return [fields.map(formatValue).join(delimiter)].concat(rows.map(function(row) { + return fields.map(function(field) { + return formatValue(row[field]); + }).join(delimiter); + })).join("\n"); + }; + + dsv.formatRows = function(rows) { + return rows.map(formatRow).join("\n"); + }; + + function formatRow(row) { + return row.map(formatValue).join(delimiter); + } + + function formatValue(text) { + return reFormat.test(text) ? "\"" + text.replace(/\"/g, "\"\"") + "\"" : text; + } + + return dsv; +}; diff --git a/node_modules/@plotly/d3/src/dsv/index.js b/node_modules/@plotly/d3/src/dsv/index.js new file mode 100644 index 0000000000000000000000000000000000000000..b92fc3cc14e90e53dd4ba6493fa496c344e79e44 --- /dev/null +++ b/node_modules/@plotly/d3/src/dsv/index.js @@ -0,0 +1,3 @@ +import "dsv"; +import "csv"; +import "tsv"; diff --git a/node_modules/@plotly/d3/src/dsv/tsv.js b/node_modules/@plotly/d3/src/dsv/tsv.js new file mode 100644 index 0000000000000000000000000000000000000000..1783744e2ab091a832ae3f8ab627f7e832797f64 --- /dev/null +++ b/node_modules/@plotly/d3/src/dsv/tsv.js @@ -0,0 +1,3 @@ +import "dsv"; + +d3.tsv = d3.dsv("\t", "text/tab-separated-values"); diff --git a/node_modules/@plotly/d3/src/end.js b/node_modules/@plotly/d3/src/end.js new file mode 100644 index 0000000000000000000000000000000000000000..a483c48695a12de95f4a13b28b369f254157f060 --- /dev/null +++ b/node_modules/@plotly/d3/src/end.js @@ -0,0 +1,4 @@ + if (typeof define === "function" && define.amd) define(d3); + else if (typeof module === "object" && module.exports) module.exports = d3; + else this.d3 = d3; +}.apply(self); diff --git a/node_modules/@plotly/d3/src/event/dispatch.js b/node_modules/@plotly/d3/src/event/dispatch.js new file mode 100644 index 0000000000000000000000000000000000000000..9b85ccdb66c66f1872254d66217691aecfa5b029 --- /dev/null +++ b/node_modules/@plotly/d3/src/event/dispatch.js @@ -0,0 +1,69 @@ +import "../arrays/map"; + +d3.dispatch = function() { + var dispatch = new d3_dispatch, + i = -1, + n = arguments.length; + while (++i < n) dispatch[arguments[i]] = d3_dispatch_event(dispatch); + return dispatch; +}; + +function d3_dispatch() {} + +d3_dispatch.prototype.on = function(type, listener) { + var i = type.indexOf("."), + name = ""; + + // Extract optional namespace, e.g., "click.foo" + if (i >= 0) { + name = type.slice(i + 1); + type = type.slice(0, i); + } + + if (type) return arguments.length < 2 + ? this[type].on(name) + : this[type].on(name, listener); + + if (arguments.length === 2) { + if (listener == null) for (type in this) { + if (this.hasOwnProperty(type)) this[type].on(name, null); + } + return this; + } +}; + +function d3_dispatch_event(dispatch) { + var listeners = [], + listenerByName = new d3_Map; + + function event() { + var z = listeners, // defensive reference + i = -1, + n = z.length, + l; + while (++i < n) if (l = z[i].on) l.apply(this, arguments); + return dispatch; + } + + event.on = function(name, listener) { + var l = listenerByName.get(name), + i; + + // return the current listener, if any + if (arguments.length < 2) return l && l.on; + + // remove the old listener, if any (with copy-on-write) + if (l) { + l.on = null; + listeners = listeners.slice(0, i = listeners.indexOf(l)).concat(listeners.slice(i + 1)); + listenerByName.remove(name); + } + + // add the new listener, if any + if (listener) listeners.push(listenerByName.set(name, {on: listener})); + + return dispatch; + }; + + return event; +} diff --git a/node_modules/@plotly/d3/src/event/drag.js b/node_modules/@plotly/d3/src/event/drag.js new file mode 100644 index 0000000000000000000000000000000000000000..8687ccf7f562d0b8b5dca7c870d5c1a26e9bcb88 --- /dev/null +++ b/node_modules/@plotly/d3/src/event/drag.js @@ -0,0 +1,36 @@ +import "../core/document"; +import "../core/vendor"; +import "../selection/on"; + +var d3_event_dragSelect, + d3_event_dragId = 0; + +function d3_event_dragSuppress(node) { + var name = ".dragsuppress-" + ++d3_event_dragId, + click = "click" + name, + w = d3.select(d3_window(node)) + .on("touchmove" + name, d3_eventPreventDefault) + .on("dragstart" + name, d3_eventPreventDefault) + .on("selectstart" + name, d3_eventPreventDefault); + + if (d3_event_dragSelect == null) { + d3_event_dragSelect = "onselectstart" in node ? false + : d3_vendorSymbol(node.style, "userSelect"); + } + + if (d3_event_dragSelect) { + var style = d3_documentElement(node).style, + select = style[d3_event_dragSelect]; + style[d3_event_dragSelect] = "none"; + } + + return function(suppressClick) { + w.on(name, null); + if (d3_event_dragSelect) style[d3_event_dragSelect] = select; + if (suppressClick) { // suppress the next click, but only if it’s immediate + var off = function() { w.on(click, null); }; + w.on(click, function() { d3_eventPreventDefault(); off(); }, true); + setTimeout(off, 0); + } + }; +} diff --git a/node_modules/@plotly/d3/src/event/event.js b/node_modules/@plotly/d3/src/event/event.js new file mode 100644 index 0000000000000000000000000000000000000000..71e676ee9058c9f1b14d7223285019ad039f03fe --- /dev/null +++ b/node_modules/@plotly/d3/src/event/event.js @@ -0,0 +1,50 @@ +import "dispatch"; + +d3.event = null; + +function d3_eventPreventDefault() { + d3.event.preventDefault(); +} + +function d3_eventSource() { + var e = d3.event, s; + while (s = e.sourceEvent) e = s; + return e; +} + +// Like d3.dispatch, but for custom events abstracting native UI events. These +// events have a target component (such as a brush), a target element (such as +// the svg:g element containing the brush) and the standard arguments `d` (the +// target element's data) and `i` (the selection index of the target element). +function d3_eventDispatch(target) { + var dispatch = new d3_dispatch, + i = 0, + n = arguments.length; + + while (++i < n) dispatch[arguments[i]] = d3_dispatch_event(dispatch); + + // Creates a dispatch context for the specified `thiz` (typically, the target + // DOM element that received the source event) and `argumentz` (typically, the + // data `d` and index `i` of the target element). The returned function can be + // used to dispatch an event to any registered listeners; the function takes a + // single argument as input, being the event to dispatch. The event must have + // a "type" attribute which corresponds to a type registered in the + // constructor. This context will automatically populate the "sourceEvent" and + // "target" attributes of the event, as well as setting the `d3.event` global + // for the duration of the notification. + dispatch.of = function(thiz, argumentz) { + return function(e1) { + try { + var e0 = + e1.sourceEvent = d3.event; + e1.target = target; + d3.event = e1; + dispatch[e1.type].apply(thiz, argumentz); + } finally { + d3.event = e0; + } + }; + }; + + return dispatch; +} diff --git a/node_modules/@plotly/d3/src/event/index.js b/node_modules/@plotly/d3/src/event/index.js new file mode 100644 index 0000000000000000000000000000000000000000..4bb5a45b68caeb79359fa771a36a69f1a36bcd74 --- /dev/null +++ b/node_modules/@plotly/d3/src/event/index.js @@ -0,0 +1,6 @@ +import "dispatch"; +import "event"; +import "mouse"; +import "touch"; +import "touches"; +import "timer"; diff --git a/node_modules/@plotly/d3/src/event/mouse.js b/node_modules/@plotly/d3/src/event/mouse.js new file mode 100644 index 0000000000000000000000000000000000000000..a6994b93fdc9131ccbdb75df001d92325173bff1 --- /dev/null +++ b/node_modules/@plotly/d3/src/event/mouse.js @@ -0,0 +1,39 @@ +import "../core/document"; +import "event"; + +d3.mouse = function(container) { + return d3_mousePoint(container, d3_eventSource()); +}; + +// https://bugs.webkit.org/show_bug.cgi?id=44083 +var d3_mouse_bug44083 = this.navigator && /WebKit/.test(this.navigator.userAgent) ? -1 : 0; + +function d3_mousePoint(container, e) { + if (e.changedTouches) e = e.changedTouches[0]; + var svg = container.ownerSVGElement || container; + if (svg.createSVGPoint) { + var point = svg.createSVGPoint(); + if (d3_mouse_bug44083 < 0) { + var window = d3_window(container); + if (window.scrollX || window.scrollY) { + svg = d3.select("body").append("svg").style({ + position: "absolute", + top: 0, + left: 0, + margin: 0, + padding: 0, + border: "none" + }, "important"); + var ctm = svg[0][0].getScreenCTM(); + d3_mouse_bug44083 = !(ctm.f || ctm.e); + svg.remove(); + } + } + if (d3_mouse_bug44083) point.x = e.pageX, point.y = e.pageY; + else point.x = e.clientX, point.y = e.clientY; + point = point.matrixTransform(container.getScreenCTM().inverse()); + return [point.x, point.y]; + } + var rect = container.getBoundingClientRect(); + return [e.clientX - rect.left - container.clientLeft, e.clientY - rect.top - container.clientTop]; +}; diff --git a/node_modules/@plotly/d3/src/event/timer.js b/node_modules/@plotly/d3/src/event/timer.js new file mode 100644 index 0000000000000000000000000000000000000000..e6dd6ab97fc20876040e2c178c176785fa129ac5 --- /dev/null +++ b/node_modules/@plotly/d3/src/event/timer.js @@ -0,0 +1,82 @@ +import "../core/document"; +import "../core/vendor"; + +var d3_timer_queueHead, + d3_timer_queueTail, + d3_timer_interval, // is an interval (or frame) active? + d3_timer_timeout, // is a timeout active? + d3_timer_frame = this[d3_vendorSymbol(this, "requestAnimationFrame")] || function(callback) { setTimeout(callback, 17); }; + +// The timer will continue to fire until callback returns true. +d3.timer = function() { + d3_timer.apply(this, arguments); +}; + +function d3_timer(callback, delay, then) { + var n = arguments.length; + if (n < 2) delay = 0; + if (n < 3) then = Date.now(); + + // Add the callback to the tail of the queue. + var time = then + delay, timer = {c: callback, t: time, n: null}; + if (d3_timer_queueTail) d3_timer_queueTail.n = timer; + else d3_timer_queueHead = timer; + d3_timer_queueTail = timer; + + // Start animatin'! + if (!d3_timer_interval) { + d3_timer_timeout = clearTimeout(d3_timer_timeout); + d3_timer_interval = 1; + d3_timer_frame(d3_timer_step); + } + + return timer; +} + +function d3_timer_step() { + var now = d3_timer_mark(), + delay = d3_timer_sweep() - now; + if (delay > 24) { + if (isFinite(delay)) { + clearTimeout(d3_timer_timeout); + d3_timer_timeout = setTimeout(d3_timer_step, delay); + } + d3_timer_interval = 0; + } else { + d3_timer_interval = 1; + d3_timer_frame(d3_timer_step); + } +} + +d3.timer.flush = function() { + d3_timer_mark(); + d3_timer_sweep(); +}; + +function d3_timer_mark() { + var now = Date.now(), + timer = d3_timer_queueHead; + while (timer) { + if (now >= timer.t && timer.c(now - timer.t)) timer.c = null; + timer = timer.n; + } + return now; +} + +// Flush after callbacks to avoid concurrent queue modification. +// Returns the time of the earliest active timer, post-sweep. +function d3_timer_sweep() { + var t0, + t1 = d3_timer_queueHead, + time = Infinity; + while (t1) { + if (t1.c) { + if (t1.t < time) time = t1.t; + t1 = (t0 = t1).n; + } else { + t1 = t0 ? t0.n = t1.n : d3_timer_queueHead = t1.n; + } + } + d3_timer_queueTail = t0; + return time; +} diff --git a/node_modules/@plotly/d3/src/event/touch.js b/node_modules/@plotly/d3/src/event/touch.js new file mode 100644 index 0000000000000000000000000000000000000000..b9828ca2671e300350d7ef634739c32e3a855fcd --- /dev/null +++ b/node_modules/@plotly/d3/src/event/touch.js @@ -0,0 +1,11 @@ +import "event"; +import "mouse"; + +d3.touch = function(container, touches, identifier) { + if (arguments.length < 3) identifier = touches, touches = d3_eventSource().changedTouches; + if (touches) for (var i = 0, n = touches.length, touch; i < n; ++i) { + if ((touch = touches[i]).identifier === identifier) { + return d3_mousePoint(container, touch); + } + } +}; diff --git a/node_modules/@plotly/d3/src/event/touches.js b/node_modules/@plotly/d3/src/event/touches.js new file mode 100644 index 0000000000000000000000000000000000000000..a7cbaa5f91d29ea37a0033b41bf9366cb15afdc0 --- /dev/null +++ b/node_modules/@plotly/d3/src/event/touches.js @@ -0,0 +1,12 @@ +import "../core/array"; +import "event"; +import "mouse"; + +d3.touches = function(container, touches) { + if (arguments.length < 2) touches = d3_eventSource().touches; + return touches ? d3_array(touches).map(function(touch) { + var point = d3_mousePoint(container, touch); + point.identifier = touch.identifier; + return point; + }) : []; +}; diff --git a/node_modules/@plotly/d3/src/format/collapse.js b/node_modules/@plotly/d3/src/format/collapse.js new file mode 100644 index 0000000000000000000000000000000000000000..08adc3a69e755beb47b6fd28c53573c8c121763d --- /dev/null +++ b/node_modules/@plotly/d3/src/format/collapse.js @@ -0,0 +1,3 @@ +function d3_collapse(s) { + return s.trim().replace(/\s+/g, " "); +} diff --git a/node_modules/@plotly/d3/src/format/index.js b/node_modules/@plotly/d3/src/format/index.js new file mode 100644 index 0000000000000000000000000000000000000000..688fa052daf4f5afeaffbc6846d2297b8bf9ad15 --- /dev/null +++ b/node_modules/@plotly/d3/src/format/index.js @@ -0,0 +1,2 @@ +import "requote"; +import "round"; diff --git a/node_modules/@plotly/d3/src/format/requote.js b/node_modules/@plotly/d3/src/format/requote.js new file mode 100644 index 0000000000000000000000000000000000000000..99dbf15a7df497450f79cf36b4c3f18f144c5a97 --- /dev/null +++ b/node_modules/@plotly/d3/src/format/requote.js @@ -0,0 +1,5 @@ +d3.requote = function(s) { + return s.replace(d3_requote_re, "\\$&"); +}; + +var d3_requote_re = /[\\\^\$\*\+\?\|\[\]\(\)\.\{\}]/g; diff --git a/node_modules/@plotly/d3/src/format/round.js b/node_modules/@plotly/d3/src/format/round.js new file mode 100644 index 0000000000000000000000000000000000000000..44e9574295a465695e4559b724afd7eb410b9737 --- /dev/null +++ b/node_modules/@plotly/d3/src/format/round.js @@ -0,0 +1,5 @@ +d3.round = function(x, n) { + return n + ? Math.round(x * (n = Math.pow(10, n))) / n + : Math.round(x); +}; diff --git a/node_modules/@plotly/d3/src/geom/clip-line.js b/node_modules/@plotly/d3/src/geom/clip-line.js new file mode 100644 index 0000000000000000000000000000000000000000..c83c412edaf832b4f6564ee57a8677aef519a65d --- /dev/null +++ b/node_modules/@plotly/d3/src/geom/clip-line.js @@ -0,0 +1,66 @@ +import "../math/trigonometry"; + +// Liang–Barsky line clipping. +function d3_geom_clipLine(x0, y0, x1, y1) { + return function(line) { + var a = line.a, + b = line.b, + ax = a.x, + ay = a.y, + bx = b.x, + by = b.y, + t0 = 0, + t1 = 1, + dx = bx - ax, + dy = by - ay, + r; + + r = x0 - ax; + if (!dx && r > 0) return; + r /= dx; + if (dx < 0) { + if (r < t0) return; + if (r < t1) t1 = r; + } else if (dx > 0) { + if (r > t1) return; + if (r > t0) t0 = r; + } + + r = x1 - ax; + if (!dx && r < 0) return; + r /= dx; + if (dx < 0) { + if (r > t1) return; + if (r > t0) t0 = r; + } else if (dx > 0) { + if (r < t0) return; + if (r < t1) t1 = r; + } + + r = y0 - ay; + if (!dy && r > 0) return; + r /= dy; + if (dy < 0) { + if (r < t0) return; + if (r < t1) t1 = r; + } else if (dy > 0) { + if (r > t1) return; + if (r > t0) t0 = r; + } + + r = y1 - ay; + if (!dy && r < 0) return; + r /= dy; + if (dy < 0) { + if (r > t1) return; + if (r > t0) t0 = r; + } else if (dy > 0) { + if (r < t0) return; + if (r < t1) t1 = r; + } + + if (t0 > 0) line.a = {x: ax + t0 * dx, y: ay + t0 * dy}; + if (t1 < 1) line.b = {x: ax + t1 * dx, y: ay + t1 * dy}; + return line; + }; +} diff --git a/node_modules/@plotly/d3/src/geom/delaunay.js b/node_modules/@plotly/d3/src/geom/delaunay.js new file mode 100644 index 0000000000000000000000000000000000000000..0a60cd11d00c0d48862d05de9974442998043fe3 --- /dev/null +++ b/node_modules/@plotly/d3/src/geom/delaunay.js @@ -0,0 +1,6 @@ +import "geom"; + +// @deprecated; use d3.geom.voronoi triangles instead. +d3.geom.delaunay = function(vertices) { + return d3.geom.voronoi().triangles(vertices); +}; diff --git a/node_modules/@plotly/d3/src/geom/geom.js b/node_modules/@plotly/d3/src/geom/geom.js new file mode 100644 index 0000000000000000000000000000000000000000..b17c4fc30609d35d1ba69e2b64379efdff03fc66 --- /dev/null +++ b/node_modules/@plotly/d3/src/geom/geom.js @@ -0,0 +1 @@ +d3.geom = {}; diff --git a/node_modules/@plotly/d3/src/geom/hull.js b/node_modules/@plotly/d3/src/geom/hull.js new file mode 100644 index 0000000000000000000000000000000000000000..7abce151e403f22435d18a9e81daee08c3c49e17 --- /dev/null +++ b/node_modules/@plotly/d3/src/geom/hull.js @@ -0,0 +1,91 @@ +import "../core/functor"; +import "../math/trigonometry"; +import "geom"; +import "point"; + +/** + * Computes the 2D convex hull of a set of points using the monotone chain + * algorithm: + * http://en.wikibooks.org/wiki/Algorithm_Implementation/Geometry/Convex_hull/Monotone_chain) + * + * The runtime of this algorithm is O(n log n), where n is the number of input + * points. However in practice it outperforms other O(n log n) hulls. + * + * @param vertices [[x1, y1], [x2, y2], ...] + * @returns polygon [[x1, y1], [x2, y2], ...] + */ +d3.geom.hull = function(vertices) { + var x = d3_geom_pointX, + y = d3_geom_pointY; + + if (arguments.length) return hull(vertices); + + function hull(data) { + // Hull of < 3 points is not well-defined + if (data.length < 3) return []; + + var fx = d3_functor(x), + fy = d3_functor(y), + i, + n = data.length, + points = [], // of the form [[x0, y0, 0], ..., [xn, yn, n]] + flippedPoints = []; + + for (i = 0 ; i < n; i++) { + points.push([+fx.call(this, data[i], i), +fy.call(this, data[i], i), i]); + } + + // sort ascending by x-coord first, y-coord second + points.sort(d3_geom_hullOrder); + + // we flip bottommost points across y axis so we can use the upper hull routine on both + for (i = 0; i < n; i++) flippedPoints.push([points[i][0], -points[i][1]]); + + var upper = d3_geom_hullUpper(points), + lower = d3_geom_hullUpper(flippedPoints); + + // construct the polygon, removing possible duplicate endpoints + var skipLeft = lower[0] === upper[0], + skipRight = lower[lower.length - 1] === upper[upper.length - 1], + polygon = []; + + // add upper hull in r->l order + // then add lower hull in l->r order + for (i = upper.length - 1; i >= 0; --i) polygon.push(data[points[upper[i]][2]]); + for (i = +skipLeft; i < lower.length - skipRight; ++i) polygon.push(data[points[lower[i]][2]]); + + return polygon; + } + + hull.x = function(_) { + return arguments.length ? (x = _, hull) : x; + }; + + hull.y = function(_) { + return arguments.length ? (y = _, hull) : y; + }; + + return hull; +}; + +// finds the 'upper convex hull' (see wiki link above) +// assumes points arg has >=3 elements, is sorted by x, unique in y +// returns array of indices into points in left to right order +function d3_geom_hullUpper(points) { + var n = points.length, + hull = [0, 1], + hs = 2; // hull size + + for (var i = 2; i < n; i++) { + while (hs > 1 && d3_cross2d(points[hull[hs-2]], points[hull[hs-1]], points[i]) <= 0) --hs; + hull[hs++] = i; + } + + // we slice to make sure that the points we 'popped' from hull don't stay behind + return hull.slice(0, hs); +} + +// comparator for ascending sort by x-coord first, y-coord second +function d3_geom_hullOrder(a, b) { + return a[0] - b[0] || a[1] - b[1]; +} diff --git a/node_modules/@plotly/d3/src/geom/index.js b/node_modules/@plotly/d3/src/geom/index.js new file mode 100644 index 0000000000000000000000000000000000000000..9e2fb282d4c274ad7b6b59b6a1c1f4a9724aeed1 --- /dev/null +++ b/node_modules/@plotly/d3/src/geom/index.js @@ -0,0 +1,6 @@ +import "geom"; +import "hull"; +import "polygon"; +import "voronoi"; +import "delaunay"; +import "quadtree"; diff --git a/node_modules/@plotly/d3/src/geom/point.js b/node_modules/@plotly/d3/src/geom/point.js new file mode 100644 index 0000000000000000000000000000000000000000..10cfe3ebd17b0d80814816bb31c16fa2a3c41a07 --- /dev/null +++ b/node_modules/@plotly/d3/src/geom/point.js @@ -0,0 +1,7 @@ +function d3_geom_pointX(d) { + return d[0]; +} + +function d3_geom_pointY(d) { + return d[1]; +} diff --git a/node_modules/@plotly/d3/src/geom/polygon.js b/node_modules/@plotly/d3/src/geom/polygon.js new file mode 100644 index 0000000000000000000000000000000000000000..692bf8e44c56eacda374b442c1002511b94ee502 --- /dev/null +++ b/node_modules/@plotly/d3/src/geom/polygon.js @@ -0,0 +1,105 @@ +import "../core/subclass"; +import "geom"; + +d3.geom.polygon = function(coordinates) { + d3_subclass(coordinates, d3_geom_polygonPrototype); + return coordinates; +}; + +var d3_geom_polygonPrototype = d3.geom.polygon.prototype = []; + +d3_geom_polygonPrototype.area = function() { + var i = -1, + n = this.length, + a, + b = this[n - 1], + area = 0; + + while (++i < n) { + a = b; + b = this[i]; + area += a[1] * b[0] - a[0] * b[1]; + } + + return area * 0.5; +}; + +d3_geom_polygonPrototype.centroid = function(k) { + var i = -1, + n = this.length, + x = 0, + y = 0, + a, + b = this[n - 1], + c; + + if (!arguments.length) k = -1 / (6 * this.area()); + + while (++i < n) { + a = b; + b = this[i]; + c = a[0] * b[1] - b[0] * a[1]; + x += (a[0] + b[0]) * c; + y += (a[1] + b[1]) * c; + } + + return [x * k, y * k]; +}; + +// The Sutherland-Hodgman clipping algorithm. +// Note: requires the clip polygon to be counterclockwise and convex. +d3_geom_polygonPrototype.clip = function(subject) { + var input, + closed = d3_geom_polygonClosed(subject), + i = -1, + n = this.length - d3_geom_polygonClosed(this), + j, + m, + a = this[n - 1], + b, + c, + d; + + while (++i < n) { + input = subject.slice(); + subject.length = 0; + b = this[i]; + c = input[(m = input.length - closed) - 1]; + j = -1; + while (++j < m) { + d = input[j]; + if (d3_geom_polygonInside(d, a, b)) { + if (!d3_geom_polygonInside(c, a, b)) { + subject.push(d3_geom_polygonIntersect(c, d, a, b)); + } + subject.push(d); + } else if (d3_geom_polygonInside(c, a, b)) { + subject.push(d3_geom_polygonIntersect(c, d, a, b)); + } + c = d; + } + if (closed) subject.push(subject[0]); + a = b; + } + + return subject; +}; + +function d3_geom_polygonInside(p, a, b) { + return (b[0] - a[0]) * (p[1] - a[1]) < (b[1] - a[1]) * (p[0] - a[0]); +} + +// Intersect two infinite lines cd and ab. +function d3_geom_polygonIntersect(c, d, a, b) { + var x1 = c[0], x3 = a[0], x21 = d[0] - x1, x43 = b[0] - x3, + y1 = c[1], y3 = a[1], y21 = d[1] - y1, y43 = b[1] - y3, + ua = (x43 * (y1 - y3) - y43 * (x1 - x3)) / (y43 * x21 - x43 * y21); + return [x1 + ua * x21, y1 + ua * y21]; +} + +// Returns true if the polygon is closed. +function d3_geom_polygonClosed(coordinates) { + var a = coordinates[0], + b = coordinates[coordinates.length - 1]; + return !(a[0] - b[0] || a[1] - b[1]); +} diff --git a/node_modules/@plotly/d3/src/geom/quadtree.js b/node_modules/@plotly/d3/src/geom/quadtree.js new file mode 100644 index 0000000000000000000000000000000000000000..a9c3197bff5c2a1e8223bfe3f8fd7b146f0f8315 --- /dev/null +++ b/node_modules/@plotly/d3/src/geom/quadtree.js @@ -0,0 +1,243 @@ +import "../core/functor"; +import "../math/abs"; +import "geom"; +import "point"; + +d3.geom.quadtree = function(points, x1, y1, x2, y2) { + var x = d3_geom_pointX, + y = d3_geom_pointY, + compat; + + // For backwards-compatibility. + if (compat = arguments.length) { + x = d3_geom_quadtreeCompatX; + y = d3_geom_quadtreeCompatY; + if (compat === 3) { + y2 = y1; + x2 = x1; + y1 = x1 = 0; + } + return quadtree(points); + } + + function quadtree(data) { + var d, + fx = d3_functor(x), + fy = d3_functor(y), + xs, + ys, + i, + n, + x1_, + y1_, + x2_, + y2_; + + if (x1 != null) { + x1_ = x1, y1_ = y1, x2_ = x2, y2_ = y2; + } else { + // Compute bounds, and cache points temporarily. + x2_ = y2_ = -(x1_ = y1_ = Infinity); + xs = [], ys = []; + n = data.length; + if (compat) for (i = 0; i < n; ++i) { + d = data[i]; + if (d.x < x1_) x1_ = d.x; + if (d.y < y1_) y1_ = d.y; + if (d.x > x2_) x2_ = d.x; + if (d.y > y2_) y2_ = d.y; + xs.push(d.x); + ys.push(d.y); + } else for (i = 0; i < n; ++i) { + var x_ = +fx(d = data[i], i), + y_ = +fy(d, i); + if (x_ < x1_) x1_ = x_; + if (y_ < y1_) y1_ = y_; + if (x_ > x2_) x2_ = x_; + if (y_ > y2_) y2_ = y_; + xs.push(x_); + ys.push(y_); + } + } + + // Squarify the bounds. + var dx = x2_ - x1_, + dy = y2_ - y1_; + if (dx > dy) y2_ = y1_ + dx; + else x2_ = x1_ + dy; + + // Recursively inserts the specified point p at the node n or one of its + // descendants. The bounds are defined by [x1, x2] and [y1, y2]. + function insert(n, d, x, y, x1, y1, x2, y2) { + if (isNaN(x) || isNaN(y)) return; // ignore invalid points + if (n.leaf) { + var nx = n.x, + ny = n.y; + if (nx != null) { + // If the point at this leaf node is at the same position as the new + // point we are adding, we leave the point associated with the + // internal node while adding the new point to a child node. This + // avoids infinite recursion. + if ((abs(nx - x) + abs(ny - y)) < 0.01) { + insertChild(n, d, x, y, x1, y1, x2, y2); + } else { + var nPoint = n.point; + n.x = n.y = n.point = null; + insertChild(n, nPoint, nx, ny, x1, y1, x2, y2); + insertChild(n, d, x, y, x1, y1, x2, y2); + } + } else { + n.x = x, n.y = y, n.point = d; + } + } else { + insertChild(n, d, x, y, x1, y1, x2, y2); + } + } + + // Recursively inserts the specified point [x, y] into a descendant of node + // n. The bounds are defined by [x1, x2] and [y1, y2]. + function insertChild(n, d, x, y, x1, y1, x2, y2) { + // Compute the split point, and the quadrant in which to insert p. + var xm = (x1 + x2) * 0.5, + ym = (y1 + y2) * 0.5, + right = x >= xm, + below = y >= ym, + i = below << 1 | right; + + // Recursively insert into the child node. + n.leaf = false; + n = n.nodes[i] || (n.nodes[i] = d3_geom_quadtreeNode()); + + // Update the bounds as we recurse. + if (right) x1 = xm; else x2 = xm; + if (below) y1 = ym; else y2 = ym; + insert(n, d, x, y, x1, y1, x2, y2); + } + + // Create the root node. + var root = d3_geom_quadtreeNode(); + + root.add = function(d) { + insert(root, d, +fx(d, ++i), +fy(d, i), x1_, y1_, x2_, y2_); + }; + + root.visit = function(f) { + d3_geom_quadtreeVisit(f, root, x1_, y1_, x2_, y2_); + }; + + // Find the closest point to the specified point. + // TODO allow the initial search extent to be specified? + // TODO allow the initial minimum distance to be specified? + // TODO allow searching below any node? + root.find = function(point) { + return d3_geom_quadtreeFind(root, point[0], point[1], x1_, y1_, x2_, y2_); + }; + + // Insert all points. + i = -1; + if (x1 == null) { + while (++i < n) { + insert(root, data[i], xs[i], ys[i], x1_, y1_, x2_, y2_); + } + --i; // index of last insertion + } else data.forEach(root.add); + + // Discard captured fields. + xs = ys = data = d = null; + + return root; + } + + quadtree.x = function(_) { + return arguments.length ? (x = _, quadtree) : x; + }; + + quadtree.y = function(_) { + return arguments.length ? (y = _, quadtree) : y; + }; + + quadtree.extent = function(_) { + if (!arguments.length) return x1 == null ? null : [[x1, y1], [x2, y2]]; + if (_ == null) x1 = y1 = x2 = y2 = null; + else x1 = +_[0][0], y1 = +_[0][1], x2 = +_[1][0], y2 = +_[1][1]; + return quadtree; + }; + + quadtree.size = function(_) { + if (!arguments.length) return x1 == null ? null : [x2 - x1, y2 - y1]; + if (_ == null) x1 = y1 = x2 = y2 = null; + else x1 = y1 = 0, x2 = +_[0], y2 = +_[1]; + return quadtree; + }; + + return quadtree; +}; + +function d3_geom_quadtreeCompatX(d) { return d.x; } +function d3_geom_quadtreeCompatY(d) { return d.y; } + +function d3_geom_quadtreeNode() { + return { + leaf: true, + nodes: [], + point: null, + x: null, + y: null + }; +} + +function d3_geom_quadtreeVisit(f, node, x1, y1, x2, y2) { + if (!f(node, x1, y1, x2, y2)) { + var sx = (x1 + x2) * 0.5, + sy = (y1 + y2) * 0.5, + children = node.nodes; + if (children[0]) d3_geom_quadtreeVisit(f, children[0], x1, y1, sx, sy); + if (children[1]) d3_geom_quadtreeVisit(f, children[1], sx, y1, x2, sy); + if (children[2]) d3_geom_quadtreeVisit(f, children[2], x1, sy, sx, y2); + if (children[3]) d3_geom_quadtreeVisit(f, children[3], sx, sy, x2, y2); + } +} + +function d3_geom_quadtreeFind(root, x, y, x0, y0, x3, y3) { + var minDistance2 = Infinity, + closestPoint; + + (function find(node, x1, y1, x2, y2) { + + // stop searching if this cell can’t contain a closer node + if (x1 > x3 || y1 > y3 || x2 < x0 || y2 < y0) return; + + // visit this point + if (point = node.point) { + var point, + dx = x - node.x, + dy = y - node.y, + distance2 = dx * dx + dy * dy; + if (distance2 < minDistance2) { + var distance = Math.sqrt(minDistance2 = distance2); + x0 = x - distance, y0 = y - distance; + x3 = x + distance, y3 = y + distance; + closestPoint = point; + } + } + + // bisect the current node + var children = node.nodes, + xm = (x1 + x2) * 0.5, + ym = (y1 + y2) * 0.5, + right = x >= xm, + below = y >= ym; + + // visit closest cell first + for (var i = below << 1 | right, j = i + 4; i < j; ++i) { + if (node = children[i & 3]) switch (i & 3) { + case 0: find(node, x1, y1, xm, ym); break; + case 1: find(node, xm, y1, x2, ym); break; + case 2: find(node, x1, ym, xm, y2); break; + case 3: find(node, xm, ym, x2, y2); break; + } + } + })(root, x0, y0, x3, y3); + + return closestPoint; +} diff --git a/node_modules/@plotly/d3/src/geom/voronoi.js b/node_modules/@plotly/d3/src/geom/voronoi.js new file mode 100644 index 0000000000000000000000000000000000000000..53f7d793afad06d09ed033cb0478c99c97a8e0b1 --- /dev/null +++ b/node_modules/@plotly/d3/src/geom/voronoi.js @@ -0,0 +1,110 @@ +import "../core/functor"; +import "voronoi/"; +import "geom"; +import "point"; + +d3.geom.voronoi = function(points) { + var x = d3_geom_pointX, + y = d3_geom_pointY, + fx = x, + fy = y, + clipExtent = d3_geom_voronoiClipExtent; + + // @deprecated; use voronoi(data) instead. + if (points) return voronoi(points); + + function voronoi(data) { + var polygons = new Array(data.length), + x0 = clipExtent[0][0], + y0 = clipExtent[0][1], + x1 = clipExtent[1][0], + y1 = clipExtent[1][1]; + + d3_geom_voronoi(sites(data), clipExtent).cells.forEach(function(cell, i) { + var edges = cell.edges, + site = cell.site, + polygon = polygons[i] = edges.length ? edges.map(function(e) { var s = e.start(); return [s.x, s.y]; }) + : site.x >= x0 && site.x <= x1 && site.y >= y0 && site.y <= y1 ? [[x0, y1], [x1, y1], [x1, y0], [x0, y0]] + : []; + polygon.point = data[i]; + }); + + return polygons; + } + + function sites(data) { + return data.map(function(d, i) { + return { + x: Math.round(fx(d, i) / ε) * ε, + y: Math.round(fy(d, i) / ε) * ε, + i: i + }; + }); + } + + voronoi.links = function(data) { + return d3_geom_voronoi(sites(data)).edges.filter(function(edge) { + return edge.l && edge.r; + }).map(function(edge) { + return { + source: data[edge.l.i], + target: data[edge.r.i] + }; + }); + }; + + voronoi.triangles = function(data) { + var triangles = []; + + d3_geom_voronoi(sites(data)).cells.forEach(function(cell, i) { + var site = cell.site, + edges = cell.edges.sort(d3_geom_voronoiHalfEdgeOrder), + j = -1, + m = edges.length, + e0, + s0, + e1 = edges[m - 1].edge, + s1 = e1.l === site ? e1.r : e1.l; + + while (++j < m) { + e0 = e1; + s0 = s1; + e1 = edges[j].edge; + s1 = e1.l === site ? e1.r : e1.l; + if (i < s0.i && i < s1.i && d3_geom_voronoiTriangleArea(site, s0, s1) < 0) { + triangles.push([data[i], data[s0.i], data[s1.i]]); + } + } + }); + + return triangles; + }; + + voronoi.x = function(_) { + return arguments.length ? (fx = d3_functor(x = _), voronoi) : x; + }; + + voronoi.y = function(_) { + return arguments.length ? (fy = d3_functor(y = _), voronoi) : y; + }; + + voronoi.clipExtent = function(_) { + if (!arguments.length) return clipExtent === d3_geom_voronoiClipExtent ? null : clipExtent; + clipExtent = _ == null ? d3_geom_voronoiClipExtent : _; + return voronoi; + }; + + // @deprecated; use clipExtent instead. + voronoi.size = function(_) { + if (!arguments.length) return clipExtent === d3_geom_voronoiClipExtent ? null : clipExtent && clipExtent[1]; + return voronoi.clipExtent(_ && [[0, 0], _]); + }; + + return voronoi; +}; + +var d3_geom_voronoiClipExtent = [[-1e6, -1e6], [1e6, 1e6]]; + +function d3_geom_voronoiTriangleArea(a, b, c) { + return (a.x - c.x) * (b.y - a.y) - (a.x - b.x) * (c.y - a.y); +} diff --git a/node_modules/@plotly/d3/src/geom/voronoi/beach.js b/node_modules/@plotly/d3/src/geom/voronoi/beach.js new file mode 100644 index 0000000000000000000000000000000000000000..e0174679dfa76aaf511e904558da5512820c7607 --- /dev/null +++ b/node_modules/@plotly/d3/src/geom/voronoi/beach.js @@ -0,0 +1,186 @@ +import "../../math/abs"; + +function d3_geom_voronoiBeach() { + d3_geom_voronoiRedBlackNode(this); + this.edge = + this.site = + this.circle = null; +} + +function d3_geom_voronoiCreateBeach(site) { + var beach = d3_geom_voronoiBeachPool.pop() || new d3_geom_voronoiBeach; + beach.site = site; + return beach; +} + +function d3_geom_voronoiDetachBeach(beach) { + d3_geom_voronoiDetachCircle(beach); + d3_geom_voronoiBeaches.remove(beach); + d3_geom_voronoiBeachPool.push(beach); + d3_geom_voronoiRedBlackNode(beach); +} + +function d3_geom_voronoiRemoveBeach(beach) { + var circle = beach.circle, + x = circle.x, + y = circle.cy, + vertex = {x: x, y: y}, + previous = beach.P, + next = beach.N, + disappearing = [beach]; + + d3_geom_voronoiDetachBeach(beach); + + var lArc = previous; + while (lArc.circle + && abs(x - lArc.circle.x) < ε + && abs(y - lArc.circle.cy) < ε) { + previous = lArc.P; + disappearing.unshift(lArc); + d3_geom_voronoiDetachBeach(lArc); + lArc = previous; + } + + disappearing.unshift(lArc); + d3_geom_voronoiDetachCircle(lArc); + + var rArc = next; + while (rArc.circle + && abs(x - rArc.circle.x) < ε + && abs(y - rArc.circle.cy) < ε) { + next = rArc.N; + disappearing.push(rArc); + d3_geom_voronoiDetachBeach(rArc); + rArc = next; + } + + disappearing.push(rArc); + d3_geom_voronoiDetachCircle(rArc); + + var nArcs = disappearing.length, + iArc; + for (iArc = 1; iArc < nArcs; ++iArc) { + rArc = disappearing[iArc]; + lArc = disappearing[iArc - 1]; + d3_geom_voronoiSetEdgeEnd(rArc.edge, lArc.site, rArc.site, vertex); + } + + lArc = disappearing[0]; + rArc = disappearing[nArcs - 1]; + rArc.edge = d3_geom_voronoiCreateEdge(lArc.site, rArc.site, null, vertex); + + d3_geom_voronoiAttachCircle(lArc); + d3_geom_voronoiAttachCircle(rArc); +} + +function d3_geom_voronoiAddBeach(site) { + var x = site.x, + directrix = site.y, + lArc, + rArc, + dxl, + dxr, + node = d3_geom_voronoiBeaches._; + + while (node) { + dxl = d3_geom_voronoiLeftBreakPoint(node, directrix) - x; + if (dxl > ε) node = node.L; else { + dxr = x - d3_geom_voronoiRightBreakPoint(node, directrix); + if (dxr > ε) { + if (!node.R) { + lArc = node; + break; + } + node = node.R; + } else { + if (dxl > -ε) { + lArc = node.P; + rArc = node; + } else if (dxr > -ε) { + lArc = node; + rArc = node.N; + } else { + lArc = rArc = node; + } + break; + } + } + } + + var newArc = d3_geom_voronoiCreateBeach(site); + d3_geom_voronoiBeaches.insert(lArc, newArc); + + if (!lArc && !rArc) return; + + if (lArc === rArc) { + d3_geom_voronoiDetachCircle(lArc); + rArc = d3_geom_voronoiCreateBeach(lArc.site); + d3_geom_voronoiBeaches.insert(newArc, rArc); + newArc.edge = rArc.edge = d3_geom_voronoiCreateEdge(lArc.site, newArc.site); + d3_geom_voronoiAttachCircle(lArc); + d3_geom_voronoiAttachCircle(rArc); + return; + } + + if (!rArc) { // && lArc + newArc.edge = d3_geom_voronoiCreateEdge(lArc.site, newArc.site); + return; + } + + // else lArc !== rArc + d3_geom_voronoiDetachCircle(lArc); + d3_geom_voronoiDetachCircle(rArc); + + var lSite = lArc.site, + ax = lSite.x, + ay = lSite.y, + bx = site.x - ax, + by = site.y - ay, + rSite = rArc.site, + cx = rSite.x - ax, + cy = rSite.y - ay, + d = 2 * (bx * cy - by * cx), + hb = bx * bx + by * by, + hc = cx * cx + cy * cy, + vertex = {x: (cy * hb - by * hc) / d + ax, y: (bx * hc - cx * hb) / d + ay}; + + d3_geom_voronoiSetEdgeEnd(rArc.edge, lSite, rSite, vertex); + newArc.edge = d3_geom_voronoiCreateEdge(lSite, site, null, vertex); + rArc.edge = d3_geom_voronoiCreateEdge(site, rSite, null, vertex); + d3_geom_voronoiAttachCircle(lArc); + d3_geom_voronoiAttachCircle(rArc); +} + +function d3_geom_voronoiLeftBreakPoint(arc, directrix) { + var site = arc.site, + rfocx = site.x, + rfocy = site.y, + pby2 = rfocy - directrix; + + if (!pby2) return rfocx; + + var lArc = arc.P; + if (!lArc) return -Infinity; + + site = lArc.site; + var lfocx = site.x, + lfocy = site.y, + plby2 = lfocy - directrix; + + if (!plby2) return lfocx; + + var hl = lfocx - rfocx, + aby2 = 1 / pby2 - 1 / plby2, + b = hl / plby2; + + if (aby2) return (-b + Math.sqrt(b * b - 2 * aby2 * (hl * hl / (-2 * plby2) - lfocy + plby2 / 2 + rfocy - pby2 / 2))) / aby2 + rfocx; + + return (rfocx + lfocx) / 2; +} + +function d3_geom_voronoiRightBreakPoint(arc, directrix) { + var rArc = arc.N; + if (rArc) return d3_geom_voronoiLeftBreakPoint(rArc, directrix); + var site = arc.site; + return site.y === directrix ? site.x : Infinity; +} diff --git a/node_modules/@plotly/d3/src/geom/voronoi/cell.js b/node_modules/@plotly/d3/src/geom/voronoi/cell.js new file mode 100644 index 0000000000000000000000000000000000000000..8c6628d31c192c7b06f3ce67a01ce6120122971e --- /dev/null +++ b/node_modules/@plotly/d3/src/geom/voronoi/cell.js @@ -0,0 +1,64 @@ +import "../../math/abs"; + +function d3_geom_voronoiCell(site) { + this.site = site; + this.edges = []; +} + +d3_geom_voronoiCell.prototype.prepare = function() { + var halfEdges = this.edges, + iHalfEdge = halfEdges.length, + edge; + + while (iHalfEdge--) { + edge = halfEdges[iHalfEdge].edge; + if (!edge.b || !edge.a) halfEdges.splice(iHalfEdge, 1); + } + + halfEdges.sort(d3_geom_voronoiHalfEdgeOrder); + return halfEdges.length; +}; + +function d3_geom_voronoiCloseCells(extent) { + var x0 = extent[0][0], + x1 = extent[1][0], + y0 = extent[0][1], + y1 = extent[1][1], + x2, + y2, + x3, + y3, + cells = d3_geom_voronoiCells, + iCell = cells.length, + cell, + iHalfEdge, + halfEdges, + nHalfEdges, + start, + end; + + while (iCell--) { + cell = cells[iCell]; + if (!cell || !cell.prepare()) continue; + halfEdges = cell.edges; + nHalfEdges = halfEdges.length; + iHalfEdge = 0; + while (iHalfEdge < nHalfEdges) { + end = halfEdges[iHalfEdge].end(), x3 = end.x, y3 = end.y; + start = halfEdges[++iHalfEdge % nHalfEdges].start(), x2 = start.x, y2 = start.y; + if (abs(x3 - x2) > ε || abs(y3 - y2) > ε) { + halfEdges.splice(iHalfEdge, 0, new d3_geom_voronoiHalfEdge(d3_geom_voronoiCreateBorderEdge(cell.site, end, + abs(x3 - x0) < ε && y1 - y3 > ε ? {x: x0, y: abs(x2 - x0) < ε ? y2 : y1} + : abs(y3 - y1) < ε && x1 - x3 > ε ? {x: abs(y2 - y1) < ε ? x2 : x1, y: y1} + : abs(x3 - x1) < ε && y3 - y0 > ε ? {x: x1, y: abs(x2 - x1) < ε ? y2 : y0} + : abs(y3 - y0) < ε && x3 - x0 > ε ? {x: abs(y2 - y0) < ε ? x2 : x0, y: y0} + : null), cell.site, null)); + ++nHalfEdges; + } + } + } +} + +function d3_geom_voronoiHalfEdgeOrder(a, b) { + return b.angle - a.angle; +} diff --git a/node_modules/@plotly/d3/src/geom/voronoi/circle.js b/node_modules/@plotly/d3/src/geom/voronoi/circle.js new file mode 100644 index 0000000000000000000000000000000000000000..d7fb6791eb19692561fd944ca4844eb1c771fbc3 --- /dev/null +++ b/node_modules/@plotly/d3/src/geom/voronoi/circle.js @@ -0,0 +1,73 @@ +function d3_geom_voronoiCircle() { + d3_geom_voronoiRedBlackNode(this); + this.x = + this.y = + this.arc = + this.site = + this.cy = null; +} + +function d3_geom_voronoiAttachCircle(arc) { + var lArc = arc.P, + rArc = arc.N; + + if (!lArc || !rArc) return; + + var lSite = lArc.site, + cSite = arc.site, + rSite = rArc.site; + + if (lSite === rSite) return; + + var bx = cSite.x, + by = cSite.y, + ax = lSite.x - bx, + ay = lSite.y - by, + cx = rSite.x - bx, + cy = rSite.y - by; + + var d = 2 * (ax * cy - ay * cx); + if (d >= -ε2) return; + + var ha = ax * ax + ay * ay, + hc = cx * cx + cy * cy, + x = (cy * ha - ay * hc) / d, + y = (ax * hc - cx * ha) / d, + cy = y + by; + + var circle = d3_geom_voronoiCirclePool.pop() || new d3_geom_voronoiCircle; + circle.arc = arc; + circle.site = cSite; + circle.x = x + bx; + circle.y = cy + Math.sqrt(x * x + y * y); // y bottom + circle.cy = cy; + + arc.circle = circle; + + var before = null, + node = d3_geom_voronoiCircles._; + + while (node) { + if (circle.y < node.y || (circle.y === node.y && circle.x <= node.x)) { + if (node.L) node = node.L; + else { before = node.P; break; } + } else { + if (node.R) node = node.R; + else { before = node; break; } + } + } + + d3_geom_voronoiCircles.insert(before, circle); + if (!before) d3_geom_voronoiFirstCircle = circle; +} + +function d3_geom_voronoiDetachCircle(arc) { + var circle = arc.circle; + if (circle) { + if (!circle.P) d3_geom_voronoiFirstCircle = circle.N; + d3_geom_voronoiCircles.remove(circle); + d3_geom_voronoiCirclePool.push(circle); + d3_geom_voronoiRedBlackNode(circle); + arc.circle = null; + } +} diff --git a/node_modules/@plotly/d3/src/geom/voronoi/clip.js b/node_modules/@plotly/d3/src/geom/voronoi/clip.js new file mode 100644 index 0000000000000000000000000000000000000000..e145965b33d972c230d1dab3951953fff53594e7 --- /dev/null +++ b/node_modules/@plotly/d3/src/geom/voronoi/clip.js @@ -0,0 +1,80 @@ +import "../../math/abs"; +import "../clip-line"; + +function d3_geom_voronoiClipEdges(extent) { + var edges = d3_geom_voronoiEdges, + clip = d3_geom_clipLine(extent[0][0], extent[0][1], extent[1][0], extent[1][1]), + i = edges.length, + e; + while (i--) { + e = edges[i]; + if (!d3_geom_voronoiConnectEdge(e, extent) + || !clip(e) + || (abs(e.a.x - e.b.x) < ε && abs(e.a.y - e.b.y) < ε)) { + e.a = e.b = null; + edges.splice(i, 1); + } + } +} + +function d3_geom_voronoiConnectEdge(edge, extent) { + var vb = edge.b; + if (vb) return true; + + var va = edge.a, + x0 = extent[0][0], + x1 = extent[1][0], + y0 = extent[0][1], + y1 = extent[1][1], + lSite = edge.l, + rSite = edge.r, + lx = lSite.x, + ly = lSite.y, + rx = rSite.x, + ry = rSite.y, + fx = (lx + rx) / 2, + fy = (ly + ry) / 2, + fm, + fb; + + if (ry === ly) { + if (fx < x0 || fx >= x1) return; + if (lx > rx) { + if (!va) va = {x: fx, y: y0}; + else if (va.y >= y1) return; + vb = {x: fx, y: y1}; + } else { + if (!va) va = {x: fx, y: y1}; + else if (va.y < y0) return; + vb = {x: fx, y: y0}; + } + } else { + fm = (lx - rx) / (ry - ly); + fb = fy - fm * fx; + if (fm < -1 || fm > 1) { + if (lx > rx) { + if (!va) va = {x: (y0 - fb) / fm, y: y0}; + else if (va.y >= y1) return; + vb = {x: (y1 - fb) / fm, y: y1}; + } else { + if (!va) va = {x: (y1 - fb) / fm, y: y1}; + else if (va.y < y0) return; + vb = {x: (y0 - fb) / fm, y: y0}; + } + } else { + if (ly < ry) { + if (!va) va = {x: x0, y: fm * x0 + fb}; + else if (va.x >= x1) return; + vb = {x: x1, y: fm * x1 + fb}; + } else { + if (!va) va = {x: x1, y: fm * x1 + fb}; + else if (va.x < x0) return; + vb = {x: x0, y: fm * x0 + fb}; + } + } + } + + edge.a = va; + edge.b = vb; + return true; +} diff --git a/node_modules/@plotly/d3/src/geom/voronoi/edge.js b/node_modules/@plotly/d3/src/geom/voronoi/edge.js new file mode 100644 index 0000000000000000000000000000000000000000..8e5a7345426f3757c643ff395f9a536897504ff4 --- /dev/null +++ b/node_modules/@plotly/d3/src/geom/voronoi/edge.js @@ -0,0 +1,50 @@ +function d3_geom_voronoiEdge(lSite, rSite) { + this.l = lSite; + this.r = rSite; + this.a = this.b = null; // for border edges +} + +function d3_geom_voronoiCreateEdge(lSite, rSite, va, vb) { + var edge = new d3_geom_voronoiEdge(lSite, rSite); + d3_geom_voronoiEdges.push(edge); + if (va) d3_geom_voronoiSetEdgeEnd(edge, lSite, rSite, va); + if (vb) d3_geom_voronoiSetEdgeEnd(edge, rSite, lSite, vb); + d3_geom_voronoiCells[lSite.i].edges.push(new d3_geom_voronoiHalfEdge(edge, lSite, rSite)); + d3_geom_voronoiCells[rSite.i].edges.push(new d3_geom_voronoiHalfEdge(edge, rSite, lSite)); + return edge; +} + +function d3_geom_voronoiCreateBorderEdge(lSite, va, vb) { + var edge = new d3_geom_voronoiEdge(lSite, null); + edge.a = va; + edge.b = vb; + d3_geom_voronoiEdges.push(edge); + return edge; +} + +function d3_geom_voronoiSetEdgeEnd(edge, lSite, rSite, vertex) { + if (!edge.a && !edge.b) { + edge.a = vertex; + edge.l = lSite; + edge.r = rSite; + } else if (edge.l === rSite) { + edge.b = vertex; + } else { + edge.a = vertex; + } +} + +function d3_geom_voronoiHalfEdge(edge, lSite, rSite) { + var va = edge.a, + vb = edge.b; + this.edge = edge; + this.site = lSite; + this.angle = rSite ? Math.atan2(rSite.y - lSite.y, rSite.x - lSite.x) + : edge.l === lSite ? Math.atan2(vb.x - va.x, va.y - vb.y) + : Math.atan2(va.x - vb.x, vb.y - va.y); +}; + +d3_geom_voronoiHalfEdge.prototype = { + start: function() { return this.edge.l === this.site ? this.edge.a : this.edge.b; }, + end: function() { return this.edge.l === this.site ? this.edge.b : this.edge.a; } +}; diff --git a/node_modules/@plotly/d3/src/geom/voronoi/index.js b/node_modules/@plotly/d3/src/geom/voronoi/index.js new file mode 100644 index 0000000000000000000000000000000000000000..a6c01a86a607148b1f89c814a4355f6ee820527b --- /dev/null +++ b/node_modules/@plotly/d3/src/geom/voronoi/index.js @@ -0,0 +1,59 @@ +import "../../math/trigonometry"; + +var d3_geom_voronoiEdges, + d3_geom_voronoiCells, + d3_geom_voronoiBeaches, + d3_geom_voronoiBeachPool = [], + d3_geom_voronoiFirstCircle, + d3_geom_voronoiCircles, + d3_geom_voronoiCirclePool = []; + +import "beach"; +import "cell"; +import "circle"; +import "clip"; +import "edge"; +import "red-black"; + +function d3_geom_voronoi(sites, bbox) { + var site = sites.sort(d3_geom_voronoiVertexOrder).pop(), + x0, + y0, + circle; + + d3_geom_voronoiEdges = []; + d3_geom_voronoiCells = new Array(sites.length); + d3_geom_voronoiBeaches = new d3_geom_voronoiRedBlackTree; + d3_geom_voronoiCircles = new d3_geom_voronoiRedBlackTree; + + while (true) { + circle = d3_geom_voronoiFirstCircle; + if (site && (!circle || site.y < circle.y || (site.y === circle.y && site.x < circle.x))) { + if (site.x !== x0 || site.y !== y0) { + d3_geom_voronoiCells[site.i] = new d3_geom_voronoiCell(site); + d3_geom_voronoiAddBeach(site); + x0 = site.x, y0 = site.y; + } + site = sites.pop(); + } else if (circle) { + d3_geom_voronoiRemoveBeach(circle.arc); + } else { + break; + } + } + + if (bbox) d3_geom_voronoiClipEdges(bbox), d3_geom_voronoiCloseCells(bbox); + + var diagram = {cells: d3_geom_voronoiCells, edges: d3_geom_voronoiEdges}; + + d3_geom_voronoiBeaches = + d3_geom_voronoiCircles = + d3_geom_voronoiEdges = + d3_geom_voronoiCells = null; + + return diagram; +}; + +function d3_geom_voronoiVertexOrder(a, b) { + return b.y - a.y || b.x - a.x; +} diff --git a/node_modules/@plotly/d3/src/geom/voronoi/red-black.js b/node_modules/@plotly/d3/src/geom/voronoi/red-black.js new file mode 100644 index 0000000000000000000000000000000000000000..7cf6880caa4860251dd12e751675bf38824aae59 --- /dev/null +++ b/node_modules/@plotly/d3/src/geom/voronoi/red-black.js @@ -0,0 +1,235 @@ +function d3_geom_voronoiRedBlackTree() { + this._ = null; // root node +} + +function d3_geom_voronoiRedBlackNode(node) { + node.U = // parent node + node.C = // color - true for red, false for black + node.L = // left node + node.R = // right node + node.P = // previous node + node.N = null; // next node +} + +d3_geom_voronoiRedBlackTree.prototype = { + + insert: function(after, node) { + var parent, grandpa, uncle; + + if (after) { + node.P = after; + node.N = after.N; + if (after.N) after.N.P = node; + after.N = node; + if (after.R) { + after = after.R; + while (after.L) after = after.L; + after.L = node; + } else { + after.R = node; + } + parent = after; + } else if (this._) { + after = d3_geom_voronoiRedBlackFirst(this._); + node.P = null; + node.N = after; + after.P = after.L = node; + parent = after; + } else { + node.P = node.N = null; + this._ = node; + parent = null; + } + node.L = node.R = null; + node.U = parent; + node.C = true; + + after = node; + while (parent && parent.C) { + grandpa = parent.U; + if (parent === grandpa.L) { + uncle = grandpa.R; + if (uncle && uncle.C) { + parent.C = uncle.C = false; + grandpa.C = true; + after = grandpa; + } else { + if (after === parent.R) { + d3_geom_voronoiRedBlackRotateLeft(this, parent); + after = parent; + parent = after.U; + } + parent.C = false; + grandpa.C = true; + d3_geom_voronoiRedBlackRotateRight(this, grandpa); + } + } else { + uncle = grandpa.L; + if (uncle && uncle.C) { + parent.C = uncle.C = false; + grandpa.C = true; + after = grandpa; + } else { + if (after === parent.L) { + d3_geom_voronoiRedBlackRotateRight(this, parent); + after = parent; + parent = after.U; + } + parent.C = false; + grandpa.C = true; + d3_geom_voronoiRedBlackRotateLeft(this, grandpa); + } + } + parent = after.U; + } + this._.C = false; + }, + + remove: function(node) { + if (node.N) node.N.P = node.P; + if (node.P) node.P.N = node.N; + node.N = node.P = null; + + var parent = node.U, + sibling, + left = node.L, + right = node.R, + next, + red; + + if (!left) next = right; + else if (!right) next = left; + else next = d3_geom_voronoiRedBlackFirst(right); + + if (parent) { + if (parent.L === node) parent.L = next; + else parent.R = next; + } else { + this._ = next; + } + + if (left && right) { + red = next.C; + next.C = node.C; + next.L = left; + left.U = next; + if (next !== right) { + parent = next.U; + next.U = node.U; + node = next.R; + parent.L = node; + next.R = right; + right.U = next; + } else { + next.U = parent; + parent = next; + node = next.R; + } + } else { + red = node.C; + node = next; + } + + if (node) node.U = parent; + if (red) return; + if (node && node.C) { node.C = false; return; } + + do { + if (node === this._) break; + if (node === parent.L) { + sibling = parent.R; + if (sibling.C) { + sibling.C = false; + parent.C = true; + d3_geom_voronoiRedBlackRotateLeft(this, parent); + sibling = parent.R; + } + if ((sibling.L && sibling.L.C) + || (sibling.R && sibling.R.C)) { + if (!sibling.R || !sibling.R.C) { + sibling.L.C = false; + sibling.C = true; + d3_geom_voronoiRedBlackRotateRight(this, sibling); + sibling = parent.R; + } + sibling.C = parent.C; + parent.C = sibling.R.C = false; + d3_geom_voronoiRedBlackRotateLeft(this, parent); + node = this._; + break; + } + } else { + sibling = parent.L; + if (sibling.C) { + sibling.C = false; + parent.C = true; + d3_geom_voronoiRedBlackRotateRight(this, parent); + sibling = parent.L; + } + if ((sibling.L && sibling.L.C) + || (sibling.R && sibling.R.C)) { + if (!sibling.L || !sibling.L.C) { + sibling.R.C = false; + sibling.C = true; + d3_geom_voronoiRedBlackRotateLeft(this, sibling); + sibling = parent.L; + } + sibling.C = parent.C; + parent.C = sibling.L.C = false; + d3_geom_voronoiRedBlackRotateRight(this, parent); + node = this._; + break; + } + } + sibling.C = true; + node = parent; + parent = parent.U; + } while (!node.C); + + if (node) node.C = false; + } + +}; + +function d3_geom_voronoiRedBlackRotateLeft(tree, node) { + var p = node, + q = node.R, + parent = p.U; + + if (parent) { + if (parent.L === p) parent.L = q; + else parent.R = q; + } else { + tree._ = q; + } + + q.U = parent; + p.U = q; + p.R = q.L; + if (p.R) p.R.U = p; + q.L = p; +} + +function d3_geom_voronoiRedBlackRotateRight(tree, node) { + var p = node, + q = node.L, + parent = p.U; + + if (parent) { + if (parent.L === p) parent.L = q; + else parent.R = q; + } else { + tree._ = q; + } + + q.U = parent; + p.U = q; + p.L = q.R; + if (p.L) p.L.U = p; + q.R = p; +} + +function d3_geom_voronoiRedBlackFirst(node) { + while (node.L) node = node.L; + return node; +} diff --git a/node_modules/@plotly/d3/src/interpolate/array.js b/node_modules/@plotly/d3/src/interpolate/array.js new file mode 100644 index 0000000000000000000000000000000000000000..33f8f48b58fe89e13b86eadf2653d497ca160a9f --- /dev/null +++ b/node_modules/@plotly/d3/src/interpolate/array.js @@ -0,0 +1,19 @@ +import "interpolate"; + +d3.interpolateArray = d3_interpolateArray; + +function d3_interpolateArray(a, b) { + var x = [], + c = [], + na = a.length, + nb = b.length, + n0 = Math.min(a.length, b.length), + i; + for (i = 0; i < n0; ++i) x.push(d3_interpolate(a[i], b[i])); + for (; i < na; ++i) c[i] = a[i]; + for (; i < nb; ++i) c[i] = b[i]; + return function(t) { + for (i = 0; i < n0; ++i) c[i] = x[i](t); + return c; + }; +} diff --git a/node_modules/@plotly/d3/src/interpolate/ease.js b/node_modules/@plotly/d3/src/interpolate/ease.js new file mode 100644 index 0000000000000000000000000000000000000000..ae0a3c83863f520f95d028970954abb999ffd406 --- /dev/null +++ b/node_modules/@plotly/d3/src/interpolate/ease.js @@ -0,0 +1,111 @@ +import "../arrays/map"; +import "../core/array"; +import "../core/identity"; +import "../math/trigonometry"; + +var d3_ease_default = function() { return d3_identity; }; + +var d3_ease = d3.map({ + linear: d3_ease_default, + poly: d3_ease_poly, + quad: function() { return d3_ease_quad; }, + cubic: function() { return d3_ease_cubic; }, + sin: function() { return d3_ease_sin; }, + exp: function() { return d3_ease_exp; }, + circle: function() { return d3_ease_circle; }, + elastic: d3_ease_elastic, + back: d3_ease_back, + bounce: function() { return d3_ease_bounce; } +}); + +var d3_ease_mode = d3.map({ + "in": d3_identity, + "out": d3_ease_reverse, + "in-out": d3_ease_reflect, + "out-in": function(f) { return d3_ease_reflect(d3_ease_reverse(f)); } +}); + +d3.ease = function(name) { + var i = name.indexOf("-"), + t = i >= 0 ? name.slice(0, i) : name, + m = i >= 0 ? name.slice(i + 1) : "in"; + t = d3_ease.get(t) || d3_ease_default; + m = d3_ease_mode.get(m) || d3_identity; + return d3_ease_clamp(m(t.apply(null, d3_arraySlice.call(arguments, 1)))); +}; + +function d3_ease_clamp(f) { + return function(t) { + return t <= 0 ? 0 : t >= 1 ? 1 : f(t); + }; +} + +function d3_ease_reverse(f) { + return function(t) { + return 1 - f(1 - t); + }; +} + +function d3_ease_reflect(f) { + return function(t) { + return 0.5 * (t < 0.5 ? f(2 * t) : (2 - f(2 - 2 * t))); + }; +} + +function d3_ease_quad(t) { + return t * t; +} + +function d3_ease_cubic(t) { + return t * t * t; +} + +// Optimized clamp(reflect(poly(3))). +function d3_ease_cubicInOut(t) { + if (t <= 0) return 0; + if (t >= 1) return 1; + var t2 = t * t, t3 = t2 * t; + return 4 * (t < 0.5 ? t3 : 3 * (t - t2) + t3 - 0.75); +} + +function d3_ease_poly(e) { + return function(t) { + return Math.pow(t, e); + }; +} + +function d3_ease_sin(t) { + return 1 - Math.cos(t * halfπ); +} + +function d3_ease_exp(t) { + return Math.pow(2, 10 * (t - 1)); +} + +function d3_ease_circle(t) { + return 1 - Math.sqrt(1 - t * t); +} + +function d3_ease_elastic(a, p) { + var s; + if (arguments.length < 2) p = 0.45; + if (arguments.length) s = p / τ * Math.asin(1 / a); + else a = 1, s = p / 4; + return function(t) { + return 1 + a * Math.pow(2, -10 * t) * Math.sin((t - s) * τ / p); + }; +} + +function d3_ease_back(s) { + if (!s) s = 1.70158; + return function(t) { + return t * t * ((s + 1) * t - s); + }; +} + +function d3_ease_bounce(t) { + return t < 1 / 2.75 ? 7.5625 * t * t + : t < 2 / 2.75 ? 7.5625 * (t -= 1.5 / 2.75) * t + 0.75 + : t < 2.5 / 2.75 ? 7.5625 * (t -= 2.25 / 2.75) * t + 0.9375 + : 7.5625 * (t -= 2.625 / 2.75) * t + 0.984375; +} diff --git a/node_modules/@plotly/d3/src/interpolate/hcl.js b/node_modules/@plotly/d3/src/interpolate/hcl.js new file mode 100644 index 0000000000000000000000000000000000000000..4e62591bac59a8dc27614ff39546fd1c7e7b7aaa --- /dev/null +++ b/node_modules/@plotly/d3/src/interpolate/hcl.js @@ -0,0 +1,20 @@ +import "../color/hcl"; + +d3.interpolateHcl = d3_interpolateHcl; + +function d3_interpolateHcl(a, b) { + a = d3.hcl(a); + b = d3.hcl(b); + var ah = a.h, + ac = a.c, + al = a.l, + bh = b.h - ah, + bc = b.c - ac, + bl = b.l - al; + if (isNaN(bc)) bc = 0, ac = isNaN(ac) ? b.c : ac; + if (isNaN(bh)) bh = 0, ah = isNaN(ah) ? b.h : ah; + else if (bh > 180) bh -= 360; else if (bh < -180) bh += 360; // shortest path + return function(t) { + return d3_hcl_lab(ah + bh * t, ac + bc * t, al + bl * t) + ""; + }; +} diff --git a/node_modules/@plotly/d3/src/interpolate/hsl.js b/node_modules/@plotly/d3/src/interpolate/hsl.js new file mode 100644 index 0000000000000000000000000000000000000000..2b8d70f2c594f9a9a1f86b5a967329fa193089bc --- /dev/null +++ b/node_modules/@plotly/d3/src/interpolate/hsl.js @@ -0,0 +1,20 @@ +import "../color/hsl"; + +d3.interpolateHsl = d3_interpolateHsl; + +function d3_interpolateHsl(a, b) { + a = d3.hsl(a); + b = d3.hsl(b); + var ah = a.h, + as = a.s, + al = a.l, + bh = b.h - ah, + bs = b.s - as, + bl = b.l - al; + if (isNaN(bs)) bs = 0, as = isNaN(as) ? b.s : as; + if (isNaN(bh)) bh = 0, ah = isNaN(ah) ? b.h : ah; + else if (bh > 180) bh -= 360; else if (bh < -180) bh += 360; // shortest path + return function(t) { + return d3_hsl_rgb(ah + bh * t, as + bs * t, al + bl * t) + ""; + }; +} diff --git a/node_modules/@plotly/d3/src/interpolate/index.js b/node_modules/@plotly/d3/src/interpolate/index.js new file mode 100644 index 0000000000000000000000000000000000000000..ed6c5020a74d82f54603bf69fb8905d1505457d5 --- /dev/null +++ b/node_modules/@plotly/d3/src/interpolate/index.js @@ -0,0 +1,14 @@ +import "array"; +import "ease"; +import "hcl"; +import "hsl"; +import "interpolate"; +import "lab"; +import "number"; +import "object"; +import "rgb"; +import "round"; +import "string"; +import "transform"; +import "uninterpolate"; +import "zoom"; diff --git a/node_modules/@plotly/d3/src/interpolate/interpolate.js b/node_modules/@plotly/d3/src/interpolate/interpolate.js new file mode 100644 index 0000000000000000000000000000000000000000..2668e0f0d914acd71de2e2e822306b439321d82a --- /dev/null +++ b/node_modules/@plotly/d3/src/interpolate/interpolate.js @@ -0,0 +1,26 @@ +import "../color/color"; +import "../color/rgb"; +import "rgb"; +import "object"; +import "array"; +import "number"; +import "string"; + +d3.interpolate = d3_interpolate; + +function d3_interpolate(a, b) { + var i = d3.interpolators.length, f; + while (--i >= 0 && !(f = d3.interpolators[i](a, b))); + return f; +} + +d3.interpolators = [ + function(a, b) { + var t = typeof b; + return (t === "string" ? (d3_rgb_names.has(b.toLowerCase()) || /^(#|rgb\(|hsl\()/i.test(b) ? d3_interpolateRgb : d3_interpolateString) + : b instanceof d3_color ? d3_interpolateRgb + : Array.isArray(b) ? d3_interpolateArray + : t === "object" && isNaN(b) ? d3_interpolateObject + : d3_interpolateNumber)(a, b); + } +]; diff --git a/node_modules/@plotly/d3/src/interpolate/lab.js b/node_modules/@plotly/d3/src/interpolate/lab.js new file mode 100644 index 0000000000000000000000000000000000000000..6b46c044885e551faa0697aa0059928cf0dcb64c --- /dev/null +++ b/node_modules/@plotly/d3/src/interpolate/lab.js @@ -0,0 +1,17 @@ +import "../color/lab"; + +d3.interpolateLab = d3_interpolateLab; + +function d3_interpolateLab(a, b) { + a = d3.lab(a); + b = d3.lab(b); + var al = a.l, + aa = a.a, + ab = a.b, + bl = b.l - al, + ba = b.a - aa, + bb = b.b - ab; + return function(t) { + return d3_lab_rgb(al + bl * t, aa + ba * t, ab + bb * t) + ""; + }; +} diff --git a/node_modules/@plotly/d3/src/interpolate/number.js b/node_modules/@plotly/d3/src/interpolate/number.js new file mode 100644 index 0000000000000000000000000000000000000000..2f0e42adca980fed286b15045e8882dc155cedd0 --- /dev/null +++ b/node_modules/@plotly/d3/src/interpolate/number.js @@ -0,0 +1,6 @@ +d3.interpolateNumber = d3_interpolateNumber; + +function d3_interpolateNumber(a, b) { + a = +a, b = +b; + return function(t) { return a * (1 - t) + b * t; }; +} diff --git a/node_modules/@plotly/d3/src/interpolate/object.js b/node_modules/@plotly/d3/src/interpolate/object.js new file mode 100644 index 0000000000000000000000000000000000000000..a3f863af208f30e7d64cf74d5e9e81e48c3d87de --- /dev/null +++ b/node_modules/@plotly/d3/src/interpolate/object.js @@ -0,0 +1,25 @@ +import "interpolate"; + +d3.interpolateObject = d3_interpolateObject; + +function d3_interpolateObject(a, b) { + var i = {}, + c = {}, + k; + for (k in a) { + if (k in b) { + i[k] = d3_interpolate(a[k], b[k]); + } else { + c[k] = a[k]; + } + } + for (k in b) { + if (!(k in a)) { + c[k] = b[k]; + } + } + return function(t) { + for (k in i) c[k] = i[k](t); + return c; + }; +} diff --git a/node_modules/@plotly/d3/src/interpolate/rgb.js b/node_modules/@plotly/d3/src/interpolate/rgb.js new file mode 100644 index 0000000000000000000000000000000000000000..f4944d2fe6cfd796738d0f43a073b65db5825a86 --- /dev/null +++ b/node_modules/@plotly/d3/src/interpolate/rgb.js @@ -0,0 +1,20 @@ +import "../color/rgb"; + +d3.interpolateRgb = d3_interpolateRgb; + +function d3_interpolateRgb(a, b) { + a = d3.rgb(a); + b = d3.rgb(b); + var ar = a.r, + ag = a.g, + ab = a.b, + br = b.r - ar, + bg = b.g - ag, + bb = b.b - ab; + return function(t) { + return "#" + + d3_rgb_hex(Math.round(ar + br * t)) + + d3_rgb_hex(Math.round(ag + bg * t)) + + d3_rgb_hex(Math.round(ab + bb * t)); + }; +} diff --git a/node_modules/@plotly/d3/src/interpolate/round.js b/node_modules/@plotly/d3/src/interpolate/round.js new file mode 100644 index 0000000000000000000000000000000000000000..8e8797dfdf9bdbcc5609e760cb50265e64a472c9 --- /dev/null +++ b/node_modules/@plotly/d3/src/interpolate/round.js @@ -0,0 +1,6 @@ +d3.interpolateRound = d3_interpolateRound; + +function d3_interpolateRound(a, b) { + b -= a; + return function(t) { return Math.round(a + b * t); }; +} diff --git a/node_modules/@plotly/d3/src/interpolate/string.js b/node_modules/@plotly/d3/src/interpolate/string.js new file mode 100644 index 0000000000000000000000000000000000000000..3033a713abc6a7650f73c32bfdfa3a10c2e8db88 --- /dev/null +++ b/node_modules/@plotly/d3/src/interpolate/string.js @@ -0,0 +1,54 @@ +import "number"; + +d3.interpolateString = d3_interpolateString; + +function d3_interpolateString(a, b) { + var bi = d3_interpolate_numberA.lastIndex = d3_interpolate_numberB.lastIndex = 0, // scan index for next number in b + am, // current match in a + bm, // current match in b + bs, // string preceding current number in b, if any + i = -1, // index in s + s = [], // string constants and placeholders + q = []; // number interpolators + + // Coerce inputs to strings. + a = a + "", b = b + ""; + + // Interpolate pairs of numbers in a & b. + while ((am = d3_interpolate_numberA.exec(a)) + && (bm = d3_interpolate_numberB.exec(b))) { + if ((bs = bm.index) > bi) { // a string precedes the next number in b + bs = b.slice(bi, bs); + if (s[i]) s[i] += bs; // coalesce with previous string + else s[++i] = bs; + } + if ((am = am[0]) === (bm = bm[0])) { // numbers in a & b match + if (s[i]) s[i] += bm; // coalesce with previous string + else s[++i] = bm; + } else { // interpolate non-matching numbers + s[++i] = null; + q.push({i: i, x: d3_interpolateNumber(am, bm)}); + } + bi = d3_interpolate_numberB.lastIndex; + } + + // Add remains of b. + if (bi < b.length) { + bs = b.slice(bi); + if (s[i]) s[i] += bs; // coalesce with previous string + else s[++i] = bs; + } + + // Special optimization for only a single match. + // Otherwise, interpolate each of the numbers and rejoin the string. + return s.length < 2 + ? (q[0] ? (b = q[0].x, function(t) { return b(t) + ""; }) + : function() { return b; }) + : (b = q.length, function(t) { + for (var i = 0, o; i < b; ++i) s[(o = q[i]).i] = o.x(t); + return s.join(""); + }); +} + +var d3_interpolate_numberA = /[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g, + d3_interpolate_numberB = new RegExp(d3_interpolate_numberA.source, "g"); diff --git a/node_modules/@plotly/d3/src/interpolate/transform.js b/node_modules/@plotly/d3/src/interpolate/transform.js new file mode 100644 index 0000000000000000000000000000000000000000..3261ec4126e0fc26d0f943ad7ed60b802f790310 --- /dev/null +++ b/node_modules/@plotly/d3/src/interpolate/transform.js @@ -0,0 +1,59 @@ +import "../math/transform"; +import "number"; + +d3.interpolateTransform = d3_interpolateTransform; + +function d3_interpolateTransformPop(s) { + return s.length ? s.pop() + "," : ""; +} + +function d3_interpolateTranslate(ta, tb, s, q) { + if (ta[0] !== tb[0] || ta[1] !== tb[1]) { + var i = s.push("translate(", null, ",", null, ")"); + q.push({i: i - 4, x: d3_interpolateNumber(ta[0], tb[0])}, {i: i - 2, x: d3_interpolateNumber(ta[1], tb[1])}); + } else if (tb[0] || tb[1]) { + s.push("translate(" + tb + ")"); + } +} + +function d3_interpolateRotate(ra, rb, s, q) { + if (ra !== rb) { + if (ra - rb > 180) rb += 360; else if (rb - ra > 180) ra += 360; // shortest path + q.push({i: s.push(d3_interpolateTransformPop(s) + "rotate(", null, ")") - 2, x: d3_interpolateNumber(ra, rb)}); + } else if (rb) { + s.push(d3_interpolateTransformPop(s) + "rotate(" + rb + ")"); + } +} + +function d3_interpolateSkew(wa, wb, s, q) { + if (wa !== wb) { + q.push({i: s.push(d3_interpolateTransformPop(s) + "skewX(", null, ")") - 2, x: d3_interpolateNumber(wa, wb)}); + } else if (wb) { + s.push(d3_interpolateTransformPop(s) + "skewX(" + wb + ")"); + } +} + +function d3_interpolateScale(ka, kb, s, q) { + if (ka[0] !== kb[0] || ka[1] !== kb[1]) { + var i = s.push(d3_interpolateTransformPop(s) + "scale(", null, ",", null, ")"); + q.push({i: i - 4, x: d3_interpolateNumber(ka[0], kb[0])}, {i: i - 2, x: d3_interpolateNumber(ka[1], kb[1])}); + } else if (kb[0] !== 1 || kb[1] !== 1) { + s.push(d3_interpolateTransformPop(s) + "scale(" + kb + ")"); + } +} + +function d3_interpolateTransform(a, b) { + var s = [], // string constants and placeholders + q = []; // number interpolators + a = d3.transform(a), b = d3.transform(b); + d3_interpolateTranslate(a.translate, b.translate, s, q); + d3_interpolateRotate(a.rotate, b.rotate, s, q); + d3_interpolateSkew(a.skew, b.skew, s, q); + d3_interpolateScale(a.scale, b.scale, s, q); + a = b = null; // gc + return function(t) { + var i = -1, n = q.length, o; + while (++i < n) s[(o = q[i]).i] = o.x(t); + return s.join(""); + }; +} diff --git a/node_modules/@plotly/d3/src/interpolate/uninterpolate.js b/node_modules/@plotly/d3/src/interpolate/uninterpolate.js new file mode 100644 index 0000000000000000000000000000000000000000..d8c83321f9ff2b80be8b3482b90d11aa1ac636af --- /dev/null +++ b/node_modules/@plotly/d3/src/interpolate/uninterpolate.js @@ -0,0 +1,9 @@ +function d3_uninterpolateNumber(a, b) { + b = (b -= a = +a) || 1 / b; + return function(x) { return (x - a) / b; }; +} + +function d3_uninterpolateClamp(a, b) { + b = (b -= a = +a) || 1 / b; + return function(x) { return Math.max(0, Math.min(1, (x - a) / b)); }; +} diff --git a/node_modules/@plotly/d3/src/interpolate/zoom.js b/node_modules/@plotly/d3/src/interpolate/zoom.js new file mode 100644 index 0000000000000000000000000000000000000000..a42f2a7d8d822a757b266d9570e7bc9c64ae2d55 --- /dev/null +++ b/node_modules/@plotly/d3/src/interpolate/zoom.js @@ -0,0 +1,53 @@ +import "../math/trigonometry"; + +var ρ = Math.SQRT2, + ρ2 = 2, + ρ4 = 4; + +// p0 = [ux0, uy0, w0] +// p1 = [ux1, uy1, w1] +d3.interpolateZoom = function(p0, p1) { + var ux0 = p0[0], uy0 = p0[1], w0 = p0[2], + ux1 = p1[0], uy1 = p1[1], w1 = p1[2], + dx = ux1 - ux0, + dy = uy1 - uy0, + d2 = dx * dx + dy * dy, + i, + S; + + // Special case for u0 ≅ u1. + if (d2 < ε2) { + S = Math.log(w1 / w0) / ρ; + i = function(t) { + return [ + ux0 + t * dx, + uy0 + t * dy, + w0 * Math.exp(ρ * t * S) + ]; + } + } + + // General case. + else { + var d1 = Math.sqrt(d2), + b0 = (w1 * w1 - w0 * w0 + ρ4 * d2) / (2 * w0 * ρ2 * d1), + b1 = (w1 * w1 - w0 * w0 - ρ4 * d2) / (2 * w1 * ρ2 * d1), + r0 = Math.log(Math.sqrt(b0 * b0 + 1) - b0), + r1 = Math.log(Math.sqrt(b1 * b1 + 1) - b1); + S = (r1 - r0) / ρ; + i = function(t) { + var s = t * S, + coshr0 = d3_cosh(r0), + u = w0 / (ρ2 * d1) * (coshr0 * d3_tanh(ρ * s + r0) - d3_sinh(r0)); + return [ + ux0 + u * dx, + uy0 + u * dy, + w0 * coshr0 / d3_cosh(ρ * s + r0) + ]; + } + } + + i.duration = S * 1000; + + return i; +}; diff --git a/node_modules/@plotly/d3/src/layout/bundle.js b/node_modules/@plotly/d3/src/layout/bundle.js new file mode 100644 index 0000000000000000000000000000000000000000..3f3024433cd2e90cb53fbd24e483ad5a95955ecc --- /dev/null +++ b/node_modules/@plotly/d3/src/layout/bundle.js @@ -0,0 +1,59 @@ +import "layout"; + +// Implements hierarchical edge bundling using Holten's algorithm. For each +// input link, a path is computed that travels through the tree, up the parent +// hierarchy to the least common ancestor, and then back down to the destination +// node. Each path is simply an array of nodes. +d3.layout.bundle = function() { + return function(links) { + var paths = [], + i = -1, + n = links.length; + while (++i < n) paths.push(d3_layout_bundlePath(links[i])); + return paths; + }; +}; + +function d3_layout_bundlePath(link) { + var start = link.source, + end = link.target, + lca = d3_layout_bundleLeastCommonAncestor(start, end), + points = [start]; + while (start !== lca) { + start = start.parent; + points.push(start); + } + var k = points.length; + while (end !== lca) { + points.splice(k, 0, end); + end = end.parent; + } + return points; +} + +function d3_layout_bundleAncestors(node) { + var ancestors = [], + parent = node.parent; + while (parent != null) { + ancestors.push(node); + node = parent; + parent = parent.parent; + } + ancestors.push(node); + return ancestors; +} + +function d3_layout_bundleLeastCommonAncestor(a, b) { + if (a === b) return a; + var aNodes = d3_layout_bundleAncestors(a), + bNodes = d3_layout_bundleAncestors(b), + aNode = aNodes.pop(), + bNode = bNodes.pop(), + sharedNode = null; + while (aNode === bNode) { + sharedNode = aNode; + aNode = aNodes.pop(); + bNode = bNodes.pop(); + } + return sharedNode; +} diff --git a/node_modules/@plotly/d3/src/layout/chord.js b/node_modules/@plotly/d3/src/layout/chord.js new file mode 100644 index 0000000000000000000000000000000000000000..87f73c4e2dad8db8e54e3fe772409896aad1cb6d --- /dev/null +++ b/node_modules/@plotly/d3/src/layout/chord.js @@ -0,0 +1,157 @@ +import "../arrays/range"; +import "../math/trigonometry"; +import "layout"; + +d3.layout.chord = function() { + var chord = {}, + chords, + groups, + matrix, + n, + padding = 0, + sortGroups, + sortSubgroups, + sortChords; + + function relayout() { + var subgroups = {}, + groupSums = [], + groupIndex = d3.range(n), + subgroupIndex = [], + k, + x, + x0, + i, + j; + + chords = []; + groups = []; + + // Compute the sum. + k = 0, i = -1; while (++i < n) { + x = 0, j = -1; while (++j < n) { + x += matrix[i][j]; + } + groupSums.push(x); + subgroupIndex.push(d3.range(n)); + k += x; + } + + // Sort groups… + if (sortGroups) { + groupIndex.sort(function(a, b) { + return sortGroups(groupSums[a], groupSums[b]); + }); + } + + // Sort subgroups… + if (sortSubgroups) { + subgroupIndex.forEach(function(d, i) { + d.sort(function(a, b) { + return sortSubgroups(matrix[i][a], matrix[i][b]); + }); + }); + } + + // Convert the sum to scaling factor for [0, 2pi]. + // TODO Allow start and end angle to be specified. + // TODO Allow padding to be specified as percentage? + k = (τ - padding * n) / k; + + // Compute the start and end angle for each group and subgroup. + // Note: Opera has a bug reordering object literal properties! + x = 0, i = -1; while (++i < n) { + x0 = x, j = -1; while (++j < n) { + var di = groupIndex[i], + dj = subgroupIndex[di][j], + v = matrix[di][dj], + a0 = x, + a1 = x += v * k; + subgroups[di + "-" + dj] = { + index: di, + subindex: dj, + startAngle: a0, + endAngle: a1, + value: v + }; + } + groups[di] = { + index: di, + startAngle: x0, + endAngle: x, + value: groupSums[di] + }; + x += padding; + } + + // Generate chords for each (non-empty) subgroup-subgroup link. + i = -1; while (++i < n) { + j = i - 1; while (++j < n) { + var source = subgroups[i + "-" + j], + target = subgroups[j + "-" + i]; + if (source.value || target.value) { + chords.push(source.value < target.value + ? {source: target, target: source} + : {source: source, target: target}); + } + } + } + + if (sortChords) resort(); + } + + function resort() { + chords.sort(function(a, b) { + return sortChords( + (a.source.value + a.target.value) / 2, + (b.source.value + b.target.value) / 2); + }); + } + + chord.matrix = function(x) { + if (!arguments.length) return matrix; + n = (matrix = x) && matrix.length; + chords = groups = null; + return chord; + }; + + chord.padding = function(x) { + if (!arguments.length) return padding; + padding = x; + chords = groups = null; + return chord; + }; + + chord.sortGroups = function(x) { + if (!arguments.length) return sortGroups; + sortGroups = x; + chords = groups = null; + return chord; + }; + + chord.sortSubgroups = function(x) { + if (!arguments.length) return sortSubgroups; + sortSubgroups = x; + chords = null; + return chord; + }; + + chord.sortChords = function(x) { + if (!arguments.length) return sortChords; + sortChords = x; + if (chords) resort(); + return chord; + }; + + chord.chords = function() { + if (!chords) relayout(); + return chords; + }; + + chord.groups = function() { + if (!groups) relayout(); + return groups; + }; + + return chord; +}; diff --git a/node_modules/@plotly/d3/src/layout/cluster.js b/node_modules/@plotly/d3/src/layout/cluster.js new file mode 100644 index 0000000000000000000000000000000000000000..a4eec3bb25e4637420f338925d09988963eb1810 --- /dev/null +++ b/node_modules/@plotly/d3/src/layout/cluster.js @@ -0,0 +1,92 @@ +import "../arrays/max"; +import "layout"; +import "hierarchy"; +import "tree"; + +// Implements a hierarchical layout using the cluster (or dendrogram) +// algorithm. +d3.layout.cluster = function() { + var hierarchy = d3.layout.hierarchy().sort(null).value(null), + separation = d3_layout_treeSeparation, + size = [1, 1], // width, height + nodeSize = false; + + function cluster(d, i) { + var nodes = hierarchy.call(this, d, i), + root = nodes[0], + previousNode, + x = 0; + + // First walk, computing the initial x & y values. + d3_layout_hierarchyVisitAfter(root, function(node) { + var children = node.children; + if (children && children.length) { + node.x = d3_layout_clusterX(children); + node.y = d3_layout_clusterY(children); + } else { + node.x = previousNode ? x += separation(node, previousNode) : 0; + node.y = 0; + previousNode = node; + } + }); + + // Compute the left-most, right-most, and depth-most nodes for extents. + var left = d3_layout_clusterLeft(root), + right = d3_layout_clusterRight(root), + x0 = left.x - separation(left, right) / 2, + x1 = right.x + separation(right, left) / 2; + + // Second walk, normalizing x & y to the desired size. + d3_layout_hierarchyVisitAfter(root, nodeSize ? function(node) { + node.x = (node.x - root.x) * size[0]; + node.y = (root.y - node.y) * size[1]; + } : function(node) { + node.x = (node.x - x0) / (x1 - x0) * size[0]; + node.y = (1 - (root.y ? node.y / root.y : 1)) * size[1]; + }); + + return nodes; + } + + cluster.separation = function(x) { + if (!arguments.length) return separation; + separation = x; + return cluster; + }; + + cluster.size = function(x) { + if (!arguments.length) return nodeSize ? null : size; + nodeSize = (size = x) == null; + return cluster; + }; + + cluster.nodeSize = function(x) { + if (!arguments.length) return nodeSize ? size : null; + nodeSize = (size = x) != null; + return cluster; + }; + + return d3_layout_hierarchyRebind(cluster, hierarchy); +}; + +function d3_layout_clusterY(children) { + return 1 + d3.max(children, function(child) { + return child.y; + }); +} + +function d3_layout_clusterX(children) { + return children.reduce(function(x, child) { + return x + child.x; + }, 0) / children.length; +} + +function d3_layout_clusterLeft(node) { + var children = node.children; + return children && children.length ? d3_layout_clusterLeft(children[0]) : node; +} + +function d3_layout_clusterRight(node) { + var children = node.children, n; + return children && (n = children.length) ? d3_layout_clusterRight(children[n - 1]) : node; +} diff --git a/node_modules/@plotly/d3/src/layout/force.js b/node_modules/@plotly/d3/src/layout/force.js new file mode 100644 index 0000000000000000000000000000000000000000..41e5316b862e05f32579956549e59418d5a6fa93 --- /dev/null +++ b/node_modules/@plotly/d3/src/layout/force.js @@ -0,0 +1,372 @@ +import "../behavior/drag"; +import "../core/identity"; +import "../core/rebind"; +import "../event/event"; +import "../event/dispatch"; +import "../event/timer"; +import "../geom/quadtree"; +import "layout"; + +// A rudimentary force layout using Gauss-Seidel. +d3.layout.force = function() { + var force = {}, + event = d3.dispatch("start", "tick", "end"), + timer, + size = [1, 1], + drag, + alpha, + friction = 0.9, + linkDistance = d3_layout_forceLinkDistance, + linkStrength = d3_layout_forceLinkStrength, + charge = -30, + chargeDistance2 = d3_layout_forceChargeDistance2, + gravity = 0.1, + theta2 = 0.64, + nodes = [], + links = [], + distances, + strengths, + charges; + + function repulse(node) { + return function(quad, x1, _, x2) { + if (quad.point !== node) { + var dx = quad.cx - node.x, + dy = quad.cy - node.y, + dw = x2 - x1, + dn = dx * dx + dy * dy; + + /* Barnes-Hut criterion. */ + if (dw * dw / theta2 < dn) { + if (dn < chargeDistance2) { + var k = quad.charge / dn; + node.px -= dx * k; + node.py -= dy * k; + } + return true; + } + + if (quad.point && dn && dn < chargeDistance2) { + var k = quad.pointCharge / dn; + node.px -= dx * k; + node.py -= dy * k; + } + } + return !quad.charge; + }; + } + + force.tick = function() { + // simulated annealing, basically + if ((alpha *= 0.99) < 0.005) { + timer = null; + event.end({type: "end", alpha: alpha = 0}); + return true; + } + + var n = nodes.length, + m = links.length, + q, + i, // current index + o, // current object + s, // current source + t, // current target + l, // current distance + k, // current force + x, // x-distance + y; // y-distance + + // gauss-seidel relaxation for links + for (i = 0; i < m; ++i) { + o = links[i]; + s = o.source; + t = o.target; + x = t.x - s.x; + y = t.y - s.y; + if (l = (x * x + y * y)) { + l = alpha * strengths[i] * ((l = Math.sqrt(l)) - distances[i]) / l; + x *= l; + y *= l; + t.x -= x * (k = (s.weight + t.weight ? s.weight / (s.weight + t.weight) : 0.5)); + t.y -= y * k; + s.x += x * (k = 1 - k); + s.y += y * k; + } + } + + // apply gravity forces + if (k = alpha * gravity) { + x = size[0] / 2; + y = size[1] / 2; + i = -1; if (k) while (++i < n) { + o = nodes[i]; + o.x += (x - o.x) * k; + o.y += (y - o.y) * k; + } + } + + // compute quadtree center of mass and apply charge forces + if (charge) { + d3_layout_forceAccumulate(q = d3.geom.quadtree(nodes), alpha, charges); + i = -1; while (++i < n) { + if (!(o = nodes[i]).fixed) { + q.visit(repulse(o)); + } + } + } + + // position verlet integration + i = -1; while (++i < n) { + o = nodes[i]; + if (o.fixed) { + o.x = o.px; + o.y = o.py; + } else { + o.x -= (o.px - (o.px = o.x)) * friction; + o.y -= (o.py - (o.py = o.y)) * friction; + } + } + + event.tick({type: "tick", alpha: alpha}); + }; + + force.nodes = function(x) { + if (!arguments.length) return nodes; + nodes = x; + return force; + }; + + force.links = function(x) { + if (!arguments.length) return links; + links = x; + return force; + }; + + force.size = function(x) { + if (!arguments.length) return size; + size = x; + return force; + }; + + force.linkDistance = function(x) { + if (!arguments.length) return linkDistance; + linkDistance = typeof x === "function" ? x : +x; + return force; + }; + + // For backwards-compatibility. + force.distance = force.linkDistance; + + force.linkStrength = function(x) { + if (!arguments.length) return linkStrength; + linkStrength = typeof x === "function" ? x : +x; + return force; + }; + + force.friction = function(x) { + if (!arguments.length) return friction; + friction = +x; + return force; + }; + + force.charge = function(x) { + if (!arguments.length) return charge; + charge = typeof x === "function" ? x : +x; + return force; + }; + + force.chargeDistance = function(x) { + if (!arguments.length) return Math.sqrt(chargeDistance2); + chargeDistance2 = x * x; + return force; + }; + + force.gravity = function(x) { + if (!arguments.length) return gravity; + gravity = +x; + return force; + }; + + force.theta = function(x) { + if (!arguments.length) return Math.sqrt(theta2); + theta2 = x * x; + return force; + }; + + force.alpha = function(x) { + if (!arguments.length) return alpha; + + x = +x; + if (alpha) { // if we're already running + if (x > 0) { // we might keep it hot + alpha = x; + } else { // or we might stop + timer.c = null, timer.t = NaN, timer = null; + event.end({type: "end", alpha: alpha = 0}); + } + } else if (x > 0) { // otherwise, fire it up! + event.start({type: "start", alpha: alpha = x}); + timer = d3_timer(force.tick); + } + + return force; + }; + + force.start = function() { + var i, + n = nodes.length, + m = links.length, + w = size[0], + h = size[1], + neighbors, + o; + + for (i = 0; i < n; ++i) { + (o = nodes[i]).index = i; + o.weight = 0; + } + + for (i = 0; i < m; ++i) { + o = links[i]; + if (typeof o.source == "number") o.source = nodes[o.source]; + if (typeof o.target == "number") o.target = nodes[o.target]; + ++o.source.weight; + ++o.target.weight; + } + + for (i = 0; i < n; ++i) { + o = nodes[i]; + if (isNaN(o.x)) o.x = position("x", w); + if (isNaN(o.y)) o.y = position("y", h); + if (isNaN(o.px)) o.px = o.x; + if (isNaN(o.py)) o.py = o.y; + } + + distances = []; + if (typeof linkDistance === "function") for (i = 0; i < m; ++i) distances[i] = +linkDistance.call(this, links[i], i); + else for (i = 0; i < m; ++i) distances[i] = linkDistance; + + strengths = []; + if (typeof linkStrength === "function") for (i = 0; i < m; ++i) strengths[i] = +linkStrength.call(this, links[i], i); + else for (i = 0; i < m; ++i) strengths[i] = linkStrength; + + charges = []; + if (typeof charge === "function") for (i = 0; i < n; ++i) charges[i] = +charge.call(this, nodes[i], i); + else for (i = 0; i < n; ++i) charges[i] = charge; + + // inherit node position from first neighbor with defined position + // or if no such neighbors, initialize node position randomly + // initialize neighbors lazily to avoid overhead when not needed + function position(dimension, size) { + if (!neighbors) { + neighbors = new Array(n); + for (j = 0; j < n; ++j) { + neighbors[j] = []; + } + for (j = 0; j < m; ++j) { + var o = links[j]; + neighbors[o.source.index].push(o.target); + neighbors[o.target.index].push(o.source); + } + } + var candidates = neighbors[i], + j = -1, + l = candidates.length, + x; + while (++j < l) if (!isNaN(x = candidates[j][dimension])) return x; + return Math.random() * size; + } + + return force.resume(); + }; + + force.resume = function() { + return force.alpha(0.1); + }; + + force.stop = function() { + return force.alpha(0); + }; + + // use `node.call(force.drag)` to make nodes draggable + force.drag = function() { + if (!drag) drag = d3.behavior.drag() + .origin(d3_identity) + .on("dragstart.force", d3_layout_forceDragstart) + .on("drag.force", dragmove) + .on("dragend.force", d3_layout_forceDragend); + + if (!arguments.length) return drag; + + this.on("mouseover.force", d3_layout_forceMouseover) + .on("mouseout.force", d3_layout_forceMouseout) + .call(drag); + }; + + function dragmove(d) { + d.px = d3.event.x, d.py = d3.event.y; + force.resume(); // restart annealing + } + + return d3.rebind(force, event, "on"); +}; + +// The fixed property has three bits: +// Bit 1 can be set externally (e.g., d.fixed = true) and show persist. +// Bit 2 stores the dragging state, from mousedown to mouseup. +// Bit 3 stores the hover state, from mouseover to mouseout. +// Dragend is a special case: it also clears the hover state. + +function d3_layout_forceDragstart(d) { + d.fixed |= 2; // set bit 2 +} + +function d3_layout_forceDragend(d) { + d.fixed &= ~6; // unset bits 2 and 3 +} + +function d3_layout_forceMouseover(d) { + d.fixed |= 4; // set bit 3 + d.px = d.x, d.py = d.y; // set velocity to zero +} + +function d3_layout_forceMouseout(d) { + d.fixed &= ~4; // unset bit 3 +} + +function d3_layout_forceAccumulate(quad, alpha, charges) { + var cx = 0, + cy = 0; + quad.charge = 0; + if (!quad.leaf) { + var nodes = quad.nodes, + n = nodes.length, + i = -1, + c; + while (++i < n) { + c = nodes[i]; + if (c == null) continue; + d3_layout_forceAccumulate(c, alpha, charges); + quad.charge += c.charge; + cx += c.charge * c.cx; + cy += c.charge * c.cy; + } + } + if (quad.point) { + // jitter internal nodes that are coincident + if (!quad.leaf) { + quad.point.x += Math.random() - 0.5; + quad.point.y += Math.random() - 0.5; + } + var k = alpha * charges[quad.point.index]; + quad.charge += quad.pointCharge = k; + cx += k * quad.point.x; + cy += k * quad.point.y; + } + quad.cx = cx / quad.charge; + quad.cy = cy / quad.charge; +} + +var d3_layout_forceLinkDistance = 20, + d3_layout_forceLinkStrength = 1, + d3_layout_forceChargeDistance2 = Infinity; diff --git a/node_modules/@plotly/d3/src/layout/hierarchy.js b/node_modules/@plotly/d3/src/layout/hierarchy.js new file mode 100644 index 0000000000000000000000000000000000000000..3bd478011dc496b5aa0dfd08f7f67524bae8d81f --- /dev/null +++ b/node_modules/@plotly/d3/src/layout/hierarchy.js @@ -0,0 +1,136 @@ +import "../arrays/merge"; +import "../core/rebind"; +import "layout"; + +d3.layout.hierarchy = function() { + var sort = d3_layout_hierarchySort, + children = d3_layout_hierarchyChildren, + value = d3_layout_hierarchyValue; + + function hierarchy(root) { + var stack = [root], + nodes = [], + node; + + root.depth = 0; + + while ((node = stack.pop()) != null) { + nodes.push(node); + if ((childs = children.call(hierarchy, node, node.depth)) && (n = childs.length)) { + var n, childs, child; + while (--n >= 0) { + stack.push(child = childs[n]); + child.parent = node; + child.depth = node.depth + 1; + } + if (value) node.value = 0; + node.children = childs; + } else { + if (value) node.value = +value.call(hierarchy, node, node.depth) || 0; + delete node.children; + } + } + + d3_layout_hierarchyVisitAfter(root, function(node) { + var childs, parent; + if (sort && (childs = node.children)) childs.sort(sort); + if (value && (parent = node.parent)) parent.value += node.value; + }); + + return nodes; + } + + hierarchy.sort = function(x) { + if (!arguments.length) return sort; + sort = x; + return hierarchy; + }; + + hierarchy.children = function(x) { + if (!arguments.length) return children; + children = x; + return hierarchy; + }; + + hierarchy.value = function(x) { + if (!arguments.length) return value; + value = x; + return hierarchy; + }; + + // Re-evaluates the `value` property for the specified hierarchy. + hierarchy.revalue = function(root) { + if (value) { + d3_layout_hierarchyVisitBefore(root, function(node) { + if (node.children) node.value = 0; + }); + d3_layout_hierarchyVisitAfter(root, function(node) { + var parent; + if (!node.children) node.value = +value.call(hierarchy, node, node.depth) || 0; + if (parent = node.parent) parent.value += node.value; + }); + } + return root; + }; + + return hierarchy; +}; + +// A method assignment helper for hierarchy subclasses. +function d3_layout_hierarchyRebind(object, hierarchy) { + d3.rebind(object, hierarchy, "sort", "children", "value"); + + // Add an alias for nodes and links, for convenience. + object.nodes = object; + object.links = d3_layout_hierarchyLinks; + + return object; +} + +// Pre-order traversal. +function d3_layout_hierarchyVisitBefore(node, callback) { + var nodes = [node]; + while ((node = nodes.pop()) != null) { + callback(node); + if ((children = node.children) && (n = children.length)) { + var n, children; + while (--n >= 0) nodes.push(children[n]); + } + } +} + +// Post-order traversal. +function d3_layout_hierarchyVisitAfter(node, callback) { + var nodes = [node], nodes2 = []; + while ((node = nodes.pop()) != null) { + nodes2.push(node); + if ((children = node.children) && (n = children.length)) { + var i = -1, n, children; + while (++i < n) nodes.push(children[i]); + } + } + while ((node = nodes2.pop()) != null) { + callback(node); + } +} + +function d3_layout_hierarchyChildren(d) { + return d.children; +} + +function d3_layout_hierarchyValue(d) { + return d.value; +} + +function d3_layout_hierarchySort(a, b) { + return b.value - a.value; +} + +// Returns an array source+target objects for the specified nodes. +function d3_layout_hierarchyLinks(nodes) { + return d3.merge(nodes.map(function(parent) { + return (parent.children || []).map(function(child) { + return {source: parent, target: child}; + }); + })); +} diff --git a/node_modules/@plotly/d3/src/layout/histogram.js b/node_modules/@plotly/d3/src/layout/histogram.js new file mode 100644 index 0000000000000000000000000000000000000000..4105d9bb503ade949b1053760394c93b32ff8c60 --- /dev/null +++ b/node_modules/@plotly/d3/src/layout/histogram.js @@ -0,0 +1,110 @@ +import "../arrays/bisect"; +import "../arrays/min"; +import "../arrays/max"; +import "../core/functor"; +import "layout"; + +d3.layout.histogram = function() { + var frequency = true, + valuer = Number, + ranger = d3_layout_histogramRange, + binner = d3_layout_histogramBinSturges; + + function histogram(data, i) { + var bins = [], + values = data.map(valuer, this), + range = ranger.call(this, values, i), + thresholds = binner.call(this, range, values, i), + bin, + i = -1, + n = values.length, + m = thresholds.length - 1, + k = frequency ? 1 : 1 / n, + x; + + // Initialize the bins. + while (++i < m) { + bin = bins[i] = []; + bin.dx = thresholds[i + 1] - (bin.x = thresholds[i]); + bin.y = 0; + } + + // Fill the bins, ignoring values outside the range. + if (m > 0) { + i = -1; while(++i < n) { + x = values[i]; + if (x >= range[0] && x <= range[1]) { + bin = bins[d3.bisect(thresholds, x, 1, m) - 1]; + bin.y += k; + bin.push(data[i]); + } + } + } + + return bins; + } + + // Specifies how to extract a value from the associated data. The default + // value function is `Number`, which is equivalent to the identity function. + histogram.value = function(x) { + if (!arguments.length) return valuer; + valuer = x; + return histogram; + }; + + // Specifies the range of the histogram. Values outside the specified range + // will be ignored. The argument `x` may be specified either as a two-element + // array representing the minimum and maximum value of the range, or as a + // function that returns the range given the array of values and the current + // index `i`. The default range is the extent (minimum and maximum) of the + // values. + histogram.range = function(x) { + if (!arguments.length) return ranger; + ranger = d3_functor(x); + return histogram; + }; + + // Specifies how to bin values in the histogram. The argument `x` may be + // specified as a number, in which case the range of values will be split + // uniformly into the given number of bins. Or, `x` may be an array of + // threshold values, defining the bins; the specified array must contain the + // rightmost (upper) value, thus specifying n + 1 values for n bins. Or, `x` + // may be a function which is evaluated, being passed the range, the array of + // values, and the current index `i`, returning an array of thresholds. The + // default bin function will divide the values into uniform bins using + // Sturges' formula. + histogram.bins = function(x) { + if (!arguments.length) return binner; + binner = typeof x === "number" + ? function(range) { return d3_layout_histogramBinFixed(range, x); } + : d3_functor(x); + return histogram; + }; + + // Specifies whether the histogram's `y` value is a count (frequency) or a + // probability (density). The default value is true. + histogram.frequency = function(x) { + if (!arguments.length) return frequency; + frequency = !!x; + return histogram; + }; + + return histogram; +}; + +function d3_layout_histogramBinSturges(range, values) { + return d3_layout_histogramBinFixed(range, Math.ceil(Math.log(values.length) / Math.LN2 + 1)); +} + +function d3_layout_histogramBinFixed(range, n) { + var x = -1, + b = +range[0], + m = (range[1] - b) / n, + f = []; + while (++x <= n) f[x] = m * x + b; + return f; +} + +function d3_layout_histogramRange(values) { + return [d3.min(values), d3.max(values)]; +}