Text Generation
Transformers
Safetensors
GGUF
English
code
code-generation
multimodal
llama
conversational
Instructions to use mrsandip/Alfa-Code with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use mrsandip/Alfa-Code with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="mrsandip/Alfa-Code")# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("mrsandip/Alfa-Code", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- llama.cpp
How to use mrsandip/Alfa-Code with llama.cpp:
Install (macOS, Linux)
curl -LsSf https://llama.app/install.sh | sh # Start a local OpenAI-compatible server with a web UI: llama serve -hf mrsandip/Alfa-Code:Q4_0 # Run inference directly in the terminal: llama cli -hf mrsandip/Alfa-Code:Q4_0
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama serve -hf mrsandip/Alfa-Code:Q4_0 # Run inference directly in the terminal: llama cli -hf mrsandip/Alfa-Code:Q4_0
Use pre-built binary
# Download pre-built binary from: # https://github.com/ggerganov/llama.cpp/releases # Start a local OpenAI-compatible server with a web UI: ./llama-server -hf mrsandip/Alfa-Code:Q4_0 # Run inference directly in the terminal: ./llama-cli -hf mrsandip/Alfa-Code:Q4_0
Build from source code
git clone https://github.com/ggerganov/llama.cpp.git cd llama.cpp cmake -B build cmake --build build -j --target llama-server llama-cli # Start a local OpenAI-compatible server with a web UI: ./build/bin/llama-server -hf mrsandip/Alfa-Code:Q4_0 # Run inference directly in the terminal: ./build/bin/llama-cli -hf mrsandip/Alfa-Code:Q4_0
Use Docker
docker model run hf.co/mrsandip/Alfa-Code:Q4_0
- LM Studio
- Jan
- vLLM
How to use mrsandip/Alfa-Code with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "mrsandip/Alfa-Code" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "mrsandip/Alfa-Code", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/mrsandip/Alfa-Code:Q4_0
- SGLang
How to use mrsandip/Alfa-Code with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "mrsandip/Alfa-Code" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "mrsandip/Alfa-Code", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "mrsandip/Alfa-Code" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "mrsandip/Alfa-Code", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Ollama
How to use mrsandip/Alfa-Code with Ollama:
ollama run hf.co/mrsandip/Alfa-Code:Q4_0
- Unsloth Desktop
- Docker Model Runner
How to use mrsandip/Alfa-Code with Docker Model Runner:
docker model run hf.co/mrsandip/Alfa-Code:Q4_0
- Lemonade
How to use mrsandip/Alfa-Code with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull mrsandip/Alfa-Code:Q4_0
Run and chat with the model
lemonade run user.Alfa-Code-Q4_0
List all available models
lemonade list
- Atomic Chat
Update (part 4)
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- .gitattributes +8 -0
- e-commerce/node_modules/@eloqnt/config/dist/index.d.mts +57 -0
- e-commerce/node_modules/@eloqnt/config/dist/index.mjs +1 -0
- e-commerce/node_modules/@eloqnt/config/package.json +32 -0
- e-commerce/node_modules/@eloqnt/format-json/CHANGELOG.md +43 -0
- e-commerce/node_modules/@eloqnt/format-json/LICENSE +21 -0
- e-commerce/node_modules/@eloqnt/format-json/README.md +20 -0
- e-commerce/node_modules/@eloqnt/format-json/dist/index.d.mts +52 -0
- e-commerce/node_modules/@eloqnt/format-json/dist/index.mjs +2 -0
- e-commerce/node_modules/@eloqnt/format-json/package.json +35 -0
- e-commerce/node_modules/@eloqnt/format-po/CHANGELOG.md +63 -0
- e-commerce/node_modules/@eloqnt/format-po/LICENSE +21 -0
- e-commerce/node_modules/@eloqnt/format-po/README.md +20 -0
- e-commerce/node_modules/@eloqnt/format-po/dist/index.d.mts +54 -0
- e-commerce/node_modules/@eloqnt/format-po/dist/index.mjs +1 -0
- e-commerce/node_modules/@eloqnt/format-po/package.json +36 -0
- e-commerce/node_modules/@esbuild-kit/core-utils/LICENSE +21 -0
- e-commerce/node_modules/@esbuild-kit/core-utils/README.md +11 -0
- e-commerce/node_modules/@esbuild-kit/core-utils/dist/index.d.ts +32 -0
- e-commerce/node_modules/@esbuild-kit/core-utils/dist/index.js +23 -0
- e-commerce/node_modules/@esbuild-kit/core-utils/node_modules/.bin/esbuild +3 -0
- e-commerce/node_modules/@esbuild-kit/core-utils/node_modules/@esbuild/linux-x64/README.md +3 -0
- e-commerce/node_modules/@esbuild-kit/core-utils/node_modules/@esbuild/linux-x64/bin/esbuild +3 -0
- e-commerce/node_modules/@esbuild-kit/core-utils/node_modules/@esbuild/linux-x64/package.json +17 -0
- e-commerce/node_modules/@esbuild-kit/core-utils/node_modules/esbuild/LICENSE.md +21 -0
- e-commerce/node_modules/@esbuild-kit/core-utils/node_modules/esbuild/README.md +3 -0
- e-commerce/node_modules/@esbuild-kit/core-utils/node_modules/esbuild/bin/esbuild +3 -0
- e-commerce/node_modules/@esbuild-kit/core-utils/node_modules/esbuild/install.js +287 -0
- e-commerce/node_modules/@esbuild-kit/core-utils/node_modules/esbuild/lib/main.d.ts +660 -0
- e-commerce/node_modules/@esbuild-kit/core-utils/node_modules/esbuild/lib/main.js +2393 -0
- e-commerce/node_modules/@esbuild-kit/core-utils/node_modules/esbuild/package.json +42 -0
- e-commerce/node_modules/@esbuild-kit/core-utils/package.json +33 -0
- e-commerce/node_modules/@esbuild-kit/esm-loader/LICENSE +21 -0
- e-commerce/node_modules/@esbuild-kit/esm-loader/README.md +155 -0
- e-commerce/node_modules/@esbuild-kit/esm-loader/dist/index.js +12 -0
- e-commerce/node_modules/@esbuild-kit/esm-loader/package.json +31 -0
- e-commerce/node_modules/@esbuild/linux-x64/README.md +3 -0
- e-commerce/node_modules/@esbuild/linux-x64/bin/esbuild +3 -0
- e-commerce/node_modules/@esbuild/linux-x64/package.json +20 -0
- e-commerce/node_modules/@floating-ui/core/LICENSE +20 -0
- e-commerce/node_modules/@floating-ui/core/README.md +4 -0
- e-commerce/node_modules/@floating-ui/core/dist/floating-ui.core.browser.min.mjs +1 -0
- e-commerce/node_modules/@floating-ui/core/dist/floating-ui.core.browser.mjs +1164 -0
- e-commerce/node_modules/@floating-ui/core/dist/floating-ui.core.d.mts +535 -0
- e-commerce/node_modules/@floating-ui/core/dist/floating-ui.core.d.ts +535 -0
- e-commerce/node_modules/@floating-ui/core/dist/floating-ui.core.esm.js +1038 -0
- e-commerce/node_modules/@floating-ui/core/dist/floating-ui.core.mjs +1038 -0
- e-commerce/node_modules/@floating-ui/core/dist/floating-ui.core.umd.js +1183 -0
- e-commerce/node_modules/@floating-ui/core/dist/floating-ui.core.umd.min.js +1 -0
- e-commerce/node_modules/@floating-ui/core/package.json +63 -0
.gitattributes
CHANGED
|
@@ -72,3 +72,11 @@ e-commerce/.next/dev/cache/turbopack/v16.4.0-e273d5b2/00000091.sst filter=lfs di
|
|
| 72 |
e-commerce/.next/dev/cache/turbopack/v16.4.0-e273d5b2/00000092.meta filter=lfs diff=lfs merge=lfs -text
|
| 73 |
e-commerce/node_modules/.bin/esbuild filter=lfs diff=lfs merge=lfs -text
|
| 74 |
e-commerce/node_modules/@biomejs/cli-linux-x64/biome filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 72 |
e-commerce/.next/dev/cache/turbopack/v16.4.0-e273d5b2/00000092.meta filter=lfs diff=lfs merge=lfs -text
|
| 73 |
e-commerce/node_modules/.bin/esbuild filter=lfs diff=lfs merge=lfs -text
|
| 74 |
e-commerce/node_modules/@biomejs/cli-linux-x64/biome filter=lfs diff=lfs merge=lfs -text
|
| 75 |
+
e-commerce/node_modules/@esbuild/linux-x64/bin/esbuild filter=lfs diff=lfs merge=lfs -text
|
| 76 |
+
e-commerce/node_modules/@esbuild-kit/core-utils/node_modules/.bin/esbuild filter=lfs diff=lfs merge=lfs -text
|
| 77 |
+
e-commerce/node_modules/@esbuild-kit/core-utils/node_modules/@esbuild/linux-x64/bin/esbuild filter=lfs diff=lfs merge=lfs -text
|
| 78 |
+
e-commerce/node_modules/@esbuild-kit/core-utils/node_modules/esbuild/bin/esbuild filter=lfs diff=lfs merge=lfs -text
|
| 79 |
+
e-commerce/node_modules/@img/sharp-libvips-linux-x64/lib/libvips-cpp.so.8.18.7 filter=lfs diff=lfs merge=lfs -text
|
| 80 |
+
e-commerce/node_modules/@img/sharp-linux-x64/lib/sharp-linux-x64-0.35.5.node filter=lfs diff=lfs merge=lfs -text
|
| 81 |
+
e-commerce/node_modules/@next/swc-linux-x64-gnu/next-swc.linux-x64-gnu.node filter=lfs diff=lfs merge=lfs -text
|
| 82 |
+
e-commerce/node_modules/@parcel/watcher-linux-x64-glibc/watcher.node filter=lfs diff=lfs merge=lfs -text
|
e-commerce/node_modules/@eloqnt/config/dist/index.d.mts
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
//#region src/index.d.ts
|
| 2 |
+
type Locale = string;
|
| 3 |
+
type MessageReference = {
|
| 4 |
+
path: string;
|
| 5 |
+
line?: number;
|
| 6 |
+
/** Orders references that share a line. Formats don't store it. */
|
| 7 |
+
column?: number;
|
| 8 |
+
};
|
| 9 |
+
/** A single message that can be read from or written to a catalog. */
|
| 10 |
+
type Message = {
|
| 11 |
+
id: string;
|
| 12 |
+
message: string;
|
| 13 |
+
/** E.g. multiple `#.` lines in PO. Empty when the format stores none. */
|
| 14 |
+
description: Array<string>;
|
| 15 |
+
/** E.g. `#:` lines in PO. Empty when the format stores none. */
|
| 16 |
+
references: Array<MessageReference>;
|
| 17 |
+
/** The message's path through its file: numbers are array indices. */
|
| 18 |
+
segments?: Array<string | number>;
|
| 19 |
+
/** A non-text value (e.g. a boolean) that is carried as-is, never translated. */
|
| 20 |
+
verbatim?: {
|
| 21 |
+
value: unknown;
|
| 22 |
+
};
|
| 23 |
+
/** Marked by the format as no longer referenced in source code. */
|
| 24 |
+
orphan?: boolean;
|
| 25 |
+
/** Lets codec-private extras (e.g. PO flags) survive a decode/encode round-trip. */
|
| 26 |
+
[key: string]: unknown;
|
| 27 |
+
};
|
| 28 |
+
/** A codec that reads and writes one messages file per locale. */
|
| 29 |
+
type SeparateFileCodec = {
|
| 30 |
+
file?: 'separate';
|
| 31 |
+
decode(content: string, context: {
|
| 32 |
+
locale: Locale;
|
| 33 |
+
sourceLocale: Locale;
|
| 34 |
+
}): Array<Message>;
|
| 35 |
+
encode(messages: Array<Message>, context: {
|
| 36 |
+
locale: Locale;
|
| 37 |
+
sourceMessagesById: Map<string, Message>;
|
| 38 |
+
}): string;
|
| 39 |
+
};
|
| 40 |
+
/**
|
| 41 |
+
* A codec for formats that keep every locale in one file (e.g. `.xcstrings`).
|
| 42 |
+
* One instance serves one file: `decodeAll` runs before `encodeAll` whenever
|
| 43 |
+
* the file exists, so closure state is how sibling locales survive a write.
|
| 44 |
+
*/
|
| 45 |
+
type SharedFileCodec = {
|
| 46 |
+
file: 'shared';
|
| 47 |
+
decodeAll(content: string): Record<Locale, Array<Message>>;
|
| 48 |
+
/** Only changed locales are passed — others survive via closure state. */
|
| 49 |
+
encodeAll(messagesByLocale: Record<Locale, Array<Message>>, context: {
|
| 50 |
+
sourceLocale: Locale;
|
| 51 |
+
}): string;
|
| 52 |
+
};
|
| 53 |
+
type Codec = SeparateFileCodec | SharedFileCodec;
|
| 54 |
+
/** Provides type safety for a codec factory. */
|
| 55 |
+
declare function defineCodec<CodecType extends Codec>(factory: () => CodecType): () => CodecType;
|
| 56 |
+
//#endregion
|
| 57 |
+
export { defineCodec };
|
e-commerce/node_modules/@eloqnt/config/dist/index.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
function e(e){return e}export{e as defineCodec};
|
e-commerce/node_modules/@eloqnt/config/package.json
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "@eloqnt/config",
|
| 3 |
+
"version": "0.1.1",
|
| 4 |
+
"description": "Shared configuration for eloqnt",
|
| 5 |
+
"homepage": "https://cli.eloqnt.dev/docs/configuration",
|
| 6 |
+
"license": "MIT",
|
| 7 |
+
"files": [
|
| 8 |
+
"dist",
|
| 9 |
+
"!dist/**/*.map",
|
| 10 |
+
"CHANGELOG.md",
|
| 11 |
+
"LICENSE"
|
| 12 |
+
],
|
| 13 |
+
"type": "module",
|
| 14 |
+
"exports": {
|
| 15 |
+
".": {
|
| 16 |
+
"types": "./dist/index.d.mts",
|
| 17 |
+
"import": "./dist/index.mjs",
|
| 18 |
+
"default": "./dist/index.mjs"
|
| 19 |
+
}
|
| 20 |
+
},
|
| 21 |
+
"publishConfig": {
|
| 22 |
+
"access": "public"
|
| 23 |
+
},
|
| 24 |
+
"devDependencies": {
|
| 25 |
+
"@types/node": "^25.9.5",
|
| 26 |
+
"typescript": "^6.0.3",
|
| 27 |
+
"vite-plus": "^0.2.8"
|
| 28 |
+
},
|
| 29 |
+
"scripts": {
|
| 30 |
+
"build": "vp pack --minify src/index.ts"
|
| 31 |
+
}
|
| 32 |
+
}
|
e-commerce/node_modules/@eloqnt/format-json/CHANGELOG.md
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# @eloqnt/format-json
|
| 2 |
+
|
| 3 |
+
## 0.1.0
|
| 4 |
+
|
| 5 |
+
### Minor Changes
|
| 6 |
+
|
| 7 |
+
- 73ef929: Release as 0.1.0, so that a `^0.1.0` range picks up later 0.1.x releases.
|
| 8 |
+
|
| 9 |
+
### Patch Changes
|
| 10 |
+
|
| 11 |
+
- 73ef929: Depend on `@eloqnt/config` through a `^0.1.0` range, so a config patch release arrives without a release here.
|
| 12 |
+
- Updated dependencies [73ef929]
|
| 13 |
+
- @eloqnt/config@0.1.0
|
| 14 |
+
|
| 15 |
+
## 0.0.4
|
| 16 |
+
|
| 17 |
+
### Patch Changes
|
| 18 |
+
|
| 19 |
+
- 9f98b5b: Publish under the MIT license, with a `LICENSE` file in the package.
|
| 20 |
+
- Updated dependencies [9f98b5b]
|
| 21 |
+
- @eloqnt/config@0.0.3
|
| 22 |
+
|
| 23 |
+
## 0.0.3
|
| 24 |
+
|
| 25 |
+
### Patch Changes
|
| 26 |
+
|
| 27 |
+
- c29260b: Treat a blank catalog file as empty instead of failing to parse it.
|
| 28 |
+
|
| 29 |
+
## 0.0.2
|
| 30 |
+
|
| 31 |
+
### Patch Changes
|
| 32 |
+
|
| 33 |
+
- f75066f: Republish with the build output, which was missing from the initial release.
|
| 34 |
+
- Updated dependencies [f75066f]
|
| 35 |
+
- @eloqnt/config@0.0.2
|
| 36 |
+
|
| 37 |
+
## 0.0.1
|
| 38 |
+
|
| 39 |
+
### Patch Changes
|
| 40 |
+
|
| 41 |
+
- 387596a: Initial release
|
| 42 |
+
- Updated dependencies [387596a]
|
| 43 |
+
- @eloqnt/config@0.0.1
|
e-commerce/node_modules/@eloqnt/format-json/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
MIT License
|
| 2 |
+
|
| 3 |
+
Copyright (c) 2026 Jan Amann
|
| 4 |
+
|
| 5 |
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
| 6 |
+
of this software and associated documentation files (the "Software"), to deal
|
| 7 |
+
in the Software without restriction, including without limitation the rights
|
| 8 |
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
| 9 |
+
copies of the Software, and to permit persons to whom the Software is
|
| 10 |
+
furnished to do so, subject to the following conditions:
|
| 11 |
+
|
| 12 |
+
The above copyright notice and this permission notice shall be included in all
|
| 13 |
+
copies or substantial portions of the Software.
|
| 14 |
+
|
| 15 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
| 16 |
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
| 17 |
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
| 18 |
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
| 19 |
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
| 20 |
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
| 21 |
+
SOFTWARE.
|
e-commerce/node_modules/@eloqnt/format-json/README.md
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# @eloqnt/format-json
|
| 2 |
+
|
| 3 |
+
JSON messages support for [eloqnt/cli](https://cli.eloqnt.dev/docs) and [next-intl](https://next-intl.dev).
|
| 4 |
+
|
| 5 |
+
This package backs the built-in `format: 'json'` setting:
|
| 6 |
+
|
| 7 |
+
```ts
|
| 8 |
+
import {defineConfig} from '@eloqnt/cli';
|
| 9 |
+
|
| 10 |
+
export default defineConfig({
|
| 11 |
+
messages: {
|
| 12 |
+
path: './messages/{locale}',
|
| 13 |
+
locales: 'infer',
|
| 14 |
+
sourceLocale: 'en',
|
| 15 |
+
format: 'json'
|
| 16 |
+
}
|
| 17 |
+
});
|
| 18 |
+
```
|
| 19 |
+
|
| 20 |
+
See the [docs](https://cli.eloqnt.dev/docs/formats/json) for details.
|
e-commerce/node_modules/@eloqnt/format-json/dist/index.d.mts
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
//#region src/index.d.ts
|
| 2 |
+
/** A message's path through its file: numbers are array indices. */
|
| 3 |
+
type ValueSegments = Array<string | number>;
|
| 4 |
+
declare const _default: () => {
|
| 5 |
+
decode(content: string, context: {
|
| 6 |
+
locale: string;
|
| 7 |
+
sourceLocale: string;
|
| 8 |
+
}): {
|
| 9 |
+
verbatim?: {
|
| 10 |
+
value: boolean | number;
|
| 11 |
+
} | undefined;
|
| 12 |
+
id: string;
|
| 13 |
+
message: string;
|
| 14 |
+
references: never[];
|
| 15 |
+
description: never[];
|
| 16 |
+
segments: ValueSegments;
|
| 17 |
+
}[];
|
| 18 |
+
encode(messages: {
|
| 19 |
+
[key: string]: unknown;
|
| 20 |
+
id: string;
|
| 21 |
+
message: string;
|
| 22 |
+
description: Array<string>;
|
| 23 |
+
references: Array<{
|
| 24 |
+
path: string;
|
| 25 |
+
line?: number;
|
| 26 |
+
}>;
|
| 27 |
+
segments?: Array<string | number>;
|
| 28 |
+
verbatim?: {
|
| 29 |
+
value: unknown;
|
| 30 |
+
};
|
| 31 |
+
orphan?: boolean;
|
| 32 |
+
}[], context: {
|
| 33 |
+
locale: string;
|
| 34 |
+
sourceMessagesById: Map<string, {
|
| 35 |
+
[key: string]: unknown;
|
| 36 |
+
id: string;
|
| 37 |
+
message: string;
|
| 38 |
+
description: Array<string>;
|
| 39 |
+
references: Array<{
|
| 40 |
+
path: string;
|
| 41 |
+
line?: number;
|
| 42 |
+
}>;
|
| 43 |
+
segments?: Array<string | number>;
|
| 44 |
+
verbatim?: {
|
| 45 |
+
value: unknown;
|
| 46 |
+
};
|
| 47 |
+
orphan?: boolean;
|
| 48 |
+
}>;
|
| 49 |
+
}): string;
|
| 50 |
+
};
|
| 51 |
+
//#endregion
|
| 52 |
+
export { _default as default };
|
e-commerce/node_modules/@eloqnt/format-json/dist/index.mjs
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import{defineCodec as e}from"@eloqnt/config";var t=e(()=>{let e=new Map;return{decode(t,n){if(t.trim()===``)return e.set(n.locale,[]),[];let r=JSON.parse(t);if(typeof r!=`object`||!r||Array.isArray(r))throw Error(`The top level of a messages file must be an object.`);function i(e,t,n,r){return{id:e,message:t,references:[],description:[],segments:n,...r&&{verbatim:r}}}let a=[],o=[];function s(e,t){let n=Array.isArray(e)?e.map((e,t)=>[t,e]):Object.keys(e).map(t=>[t,e[t]]);if(n.length===0&&t.length>0){o.push({segments:t,value:Array.isArray(e)?[]:{}});return}for(let[e,r]of n){let n=[...t,e],c=n.join(`.`);typeof r==`string`?a.push(i(c,r,n)):typeof r==`boolean`||typeof r==`number`?a.push(i(c,JSON.stringify(r),n,{value:r})):r===null?o.push({segments:n,value:null}):s(r,n)}}return s(r,[]),e.set(n.locale,o),a},encode(t,i){function a(e){let t=e.segments;if(Array.isArray(t)&&t.every(e=>typeof e==`string`||typeof e==`number`))return t}function o(e){return typeof e.verbatim==`object`&&e.verbatim!==null||e.verbatim===!0}function s(e){return typeof e.verbatim==`object`&&e.verbatim!==null?e.verbatim.value:e.value}function c(e){let t=a(e);if(t&&t.join(`.`)===e.id)return t;let n=i.sourceMessagesById.get(e.id);if(n){let t=a(n);if(t&&t.join(`.`)===e.id)return t}return e.id.split(`.`)}function l(e,t){let n=e.references[0],r=t.references[0];if(!n||!r)return 0;let i=n.path.localeCompare(r.path,`en`);return i===0?(n.line??0)-(r.line??0):i}let u=Object.create(null);for(let e of t.toSorted(l)){let t=o(e)?s(e):e.message;n(u,c(e),t)}for(let{segments:t,value:n}of e.get(i.locale)??[])r(u,t,n);return JSON.stringify(u,null,2)+`
|
| 2 |
+
`}}});function n(e,t,n){let r=e;for(let e=0;e<t.length-1;e++){let n=t[e],i=typeof t[e+1]==`number`,a=r[n];(typeof a!=`object`||!a||Array.isArray(a)!==i)&&(a=i?[]:Object.create(null),r[n]=a),r=a}let i=t[t.length-1],a=r[i];typeof a==`object`&&a||(r[i]=n)}function r(e,t,n){let r=e;for(let e=0;e<t.length-1;e++){let n=t[e],i=r[n];if(typeof i!=`object`||!i){if(i!==void 0)return;let a=typeof t[e+1]==`number`?[]:Object.create(null);r[n]=a,r=a}else r=i}let i=t[t.length-1];r[i]===void 0&&(r[i]=n)}export{t as default};
|
e-commerce/node_modules/@eloqnt/format-json/package.json
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "@eloqnt/format-json",
|
| 3 |
+
"version": "0.1.0",
|
| 4 |
+
"description": "JSON messages support for eloqnt",
|
| 5 |
+
"homepage": "https://cli.eloqnt.dev/docs/configuration",
|
| 6 |
+
"license": "MIT",
|
| 7 |
+
"files": [
|
| 8 |
+
"dist",
|
| 9 |
+
"!dist/**/*.map",
|
| 10 |
+
"CHANGELOG.md",
|
| 11 |
+
"LICENSE"
|
| 12 |
+
],
|
| 13 |
+
"type": "module",
|
| 14 |
+
"exports": {
|
| 15 |
+
".": {
|
| 16 |
+
"types": "./dist/index.d.mts",
|
| 17 |
+
"import": "./dist/index.mjs",
|
| 18 |
+
"default": "./dist/index.mjs"
|
| 19 |
+
}
|
| 20 |
+
},
|
| 21 |
+
"publishConfig": {
|
| 22 |
+
"access": "public"
|
| 23 |
+
},
|
| 24 |
+
"dependencies": {
|
| 25 |
+
"@eloqnt/config": "^0.1.0"
|
| 26 |
+
},
|
| 27 |
+
"devDependencies": {
|
| 28 |
+
"@types/node": "^25.9.5",
|
| 29 |
+
"typescript": "^6.0.3",
|
| 30 |
+
"vite-plus": "^0.2.8"
|
| 31 |
+
},
|
| 32 |
+
"scripts": {
|
| 33 |
+
"build": "vp pack --minify src/index.ts"
|
| 34 |
+
}
|
| 35 |
+
}
|
e-commerce/node_modules/@eloqnt/format-po/CHANGELOG.md
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# @eloqnt/format-po
|
| 2 |
+
|
| 3 |
+
## 0.1.1
|
| 4 |
+
|
| 5 |
+
### Patch Changes
|
| 6 |
+
|
| 7 |
+
- 4b49621: References can carry an optional `column`, and PO files order messages that share a line by it, so their order no longer depends on the input order.
|
| 8 |
+
- Updated dependencies [4b49621]
|
| 9 |
+
- @eloqnt/config@0.1.1
|
| 10 |
+
|
| 11 |
+
## 0.1.0
|
| 12 |
+
|
| 13 |
+
### Minor Changes
|
| 14 |
+
|
| 15 |
+
- 73ef929: Release as 0.1.0, so that a `^0.1.0` range picks up later 0.1.x releases.
|
| 16 |
+
|
| 17 |
+
### Patch Changes
|
| 18 |
+
|
| 19 |
+
- 73ef929: Depend on `@eloqnt/config` through a `^0.1.0` range, so a config patch release arrives without a release here.
|
| 20 |
+
- Updated dependencies [73ef929]
|
| 21 |
+
- @eloqnt/config@0.1.0
|
| 22 |
+
|
| 23 |
+
## 0.0.6
|
| 24 |
+
|
| 25 |
+
### Patch Changes
|
| 26 |
+
|
| 27 |
+
- 9f98b5b: Publish under the MIT license, with a `LICENSE` file in the package.
|
| 28 |
+
- Updated dependencies [9f98b5b]
|
| 29 |
+
- @eloqnt/config@0.0.3
|
| 30 |
+
|
| 31 |
+
## 0.0.5
|
| 32 |
+
|
| 33 |
+
### Patch Changes
|
| 34 |
+
|
| 35 |
+
- 8d5cc87: Throw a clear error when a PO file contains an empty `msgstr` but no source locale is known, instead of decoding the entry to an empty message.
|
| 36 |
+
|
| 37 |
+
## 0.0.4
|
| 38 |
+
|
| 39 |
+
### Patch Changes
|
| 40 |
+
|
| 41 |
+
- fc5d933: Preserve a PO file's reference style and header order on write: files that carry `path:line` references keep them, and an existing `Language` header stays where it is. New files still get path-only references.
|
| 42 |
+
|
| 43 |
+
## 0.0.3
|
| 44 |
+
|
| 45 |
+
### Patch Changes
|
| 46 |
+
|
| 47 |
+
- a60870e: Treat a blank catalog file as new, so it receives the current layout instead of being read as plain gettext.
|
| 48 |
+
|
| 49 |
+
## 0.0.2
|
| 50 |
+
|
| 51 |
+
### Patch Changes
|
| 52 |
+
|
| 53 |
+
- f75066f: Republish with the build output, which was missing from the initial release.
|
| 54 |
+
- Updated dependencies [f75066f]
|
| 55 |
+
- @eloqnt/config@0.0.2
|
| 56 |
+
|
| 57 |
+
## 0.0.1
|
| 58 |
+
|
| 59 |
+
### Patch Changes
|
| 60 |
+
|
| 61 |
+
- 387596a: Initial release
|
| 62 |
+
- Updated dependencies [387596a]
|
| 63 |
+
- @eloqnt/config@0.0.1
|
e-commerce/node_modules/@eloqnt/format-po/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
MIT License
|
| 2 |
+
|
| 3 |
+
Copyright (c) 2026 Jan Amann
|
| 4 |
+
|
| 5 |
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
| 6 |
+
of this software and associated documentation files (the "Software"), to deal
|
| 7 |
+
in the Software without restriction, including without limitation the rights
|
| 8 |
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
| 9 |
+
copies of the Software, and to permit persons to whom the Software is
|
| 10 |
+
furnished to do so, subject to the following conditions:
|
| 11 |
+
|
| 12 |
+
The above copyright notice and this permission notice shall be included in all
|
| 13 |
+
copies or substantial portions of the Software.
|
| 14 |
+
|
| 15 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
| 16 |
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
| 17 |
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
| 18 |
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
| 19 |
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
| 20 |
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
| 21 |
+
SOFTWARE.
|
e-commerce/node_modules/@eloqnt/format-po/README.md
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# @eloqnt/format-po
|
| 2 |
+
|
| 3 |
+
Gettext-style PO files for [eloqnt/cli](https://cli.eloqnt.dev/docs) and [next-intl](https://next-intl.dev).
|
| 4 |
+
|
| 5 |
+
This package backs the built-in `format: 'po'` setting:
|
| 6 |
+
|
| 7 |
+
```ts
|
| 8 |
+
import {defineConfig} from '@eloqnt/cli';
|
| 9 |
+
|
| 10 |
+
export default defineConfig({
|
| 11 |
+
messages: {
|
| 12 |
+
path: './messages/{locale}',
|
| 13 |
+
locales: 'infer',
|
| 14 |
+
sourceLocale: 'en',
|
| 15 |
+
format: 'po'
|
| 16 |
+
}
|
| 17 |
+
});
|
| 18 |
+
```
|
| 19 |
+
|
| 20 |
+
See the [docs](https://cli.eloqnt.dev/docs/formats/po) for details.
|
e-commerce/node_modules/@eloqnt/format-po/dist/index.d.mts
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
//#region src/index.d.ts
|
| 2 |
+
declare const _default: () => {
|
| 3 |
+
decode(content: string, context: {
|
| 4 |
+
locale: string;
|
| 5 |
+
sourceLocale: string;
|
| 6 |
+
}): {
|
| 7 |
+
formatPoEmptySource?: string | undefined;
|
| 8 |
+
formatPoContext?: string | undefined;
|
| 9 |
+
id: string;
|
| 10 |
+
message: string;
|
| 11 |
+
description: string[];
|
| 12 |
+
references: {
|
| 13 |
+
path: string;
|
| 14 |
+
line?: number;
|
| 15 |
+
}[];
|
| 16 |
+
flags?: Array<string>;
|
| 17 |
+
}[];
|
| 18 |
+
encode(messages: {
|
| 19 |
+
[key: string]: unknown;
|
| 20 |
+
id: string;
|
| 21 |
+
message: string;
|
| 22 |
+
description: Array<string>;
|
| 23 |
+
references: Array<{
|
| 24 |
+
path: string;
|
| 25 |
+
line?: number;
|
| 26 |
+
column?: number;
|
| 27 |
+
}>;
|
| 28 |
+
segments?: Array<string | number>;
|
| 29 |
+
verbatim?: {
|
| 30 |
+
value: unknown;
|
| 31 |
+
};
|
| 32 |
+
orphan?: boolean;
|
| 33 |
+
}[], context: {
|
| 34 |
+
locale: string;
|
| 35 |
+
sourceMessagesById: Map<string, {
|
| 36 |
+
[key: string]: unknown;
|
| 37 |
+
id: string;
|
| 38 |
+
message: string;
|
| 39 |
+
description: Array<string>;
|
| 40 |
+
references: Array<{
|
| 41 |
+
path: string;
|
| 42 |
+
line?: number;
|
| 43 |
+
column?: number;
|
| 44 |
+
}>;
|
| 45 |
+
segments?: Array<string | number>;
|
| 46 |
+
verbatim?: {
|
| 47 |
+
value: unknown;
|
| 48 |
+
};
|
| 49 |
+
orphan?: boolean;
|
| 50 |
+
}>;
|
| 51 |
+
}): string;
|
| 52 |
+
};
|
| 53 |
+
//#endregion
|
| 54 |
+
export { _default as default };
|
e-commerce/node_modules/@eloqnt/format-po/dist/index.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
import{defineCodec as e}from"@eloqnt/config";import t from"po-parser";const n=`X-Message-Key`,r=`X-Crowdin-SourceKey`,i=`formatPoEmptySource`,a=`formatPoContext`,o={"Content-Type":`text/plain; charset=utf-8`,"Content-Transfer-Encoding":`8bit`,"X-Generator":`@eloqnt/format-po`};function s(e){return e?.[r]===`msgstr`?`id-msgid`:e?.[n]===`msgctxt`?`key-msgctxt`:`gettext`}function c(e){return[...new Set(e.map(e=>e.path))].map(e=>({path:e}))}var l=e(()=>{let e=new Map,l=new Map,u=new Map;return{decode(n,r){let o=t.parse(n);(o.meta||(o.messages??[]).length>0)&&(e.set(r.locale,s(o.meta)),u.set(r.locale,(o.messages??[]).some(e=>e.references?.some(e=>e.line!==void 0))));let c=e.get(r.locale)??`key-msgctxt`;return o.meta&&l.set(r.locale,o.meta),(o.messages??[]).map(e=>{let{extractedComments:t,msgctxt:n,msgid:o,msgstr:s,references:l,...u}=e,d=c===`key-msgctxt`?n??o:n?[n,o].join(`.`):o,f=c!==`id-msgid`&&s===``;if(f&&!r.sourceLocale)throw Error(`Found an empty msgstr in the "${r.locale}" messages file, but no source locale is known. An empty msgstr can mean that the translation is missing, or that it matches the source text, and only the source locale tells the two apart. Set \`sourceLocale\` in your config to the locale your source messages are written in.`);let p=f&&r.locale===r.sourceLocale;return{...u,id:d,message:p?o:s,description:t??[],references:l??[],...c===`gettext`&&n&&{[a]:n},...p&&{[i]:o}}})},encode(s,d){let f=e.get(d.locale)??`key-msgctxt`,p=l.get(d.locale)??{},m=u.get(d.locale)?e=>e:c;function h(e){let{description:t,id:n,message:r,references:o,[i]:s,[a]:c,...l}=e;if(f===`id-msgid`){let e=n.lastIndexOf(`.`),i=n.includes(`.`);return{...l,msgid:i?n.slice(e+1):n,msgstr:r,...t.length>0&&{extractedComments:t},...i&&{msgctxt:n.slice(0,e)},...m(o).length>0&&{references:m(o)}}}let u=f===`gettext`&&typeof c==`string`?c:void 0,p=d.sourceMessagesById.get(n)?.message;if(p===void 0)if(f===`gettext`)p=u?n.slice(u.length+1):n;else throw Error(`Missing source message for id "${n}" while encoding "${d.locale}".`);let h=s!==void 0&&r===s?``:r,g;return g=f===`gettext`?u??(n!==p&&n.endsWith(`.${p}`)?n.slice(0,-(p.length+1)):void 0):n===p?void 0:n,{...l,msgid:p,msgstr:h,...t.length>0&&{extractedComments:t},...g!==void 0&&{msgctxt:g},...m(o).length>0&&{references:m(o)}}}function g(e,t){let n=e.references[0],r=t.references[0];if(!n||!r)return 0;let i=n.path.localeCompare(r.path,`en`);return i===0?(n.line??0)-(r.line??0)||(n.column??0)-(r.column??0):i}let _=f===`gettext`?s:s.toSorted(g),v;if(f===`gettext`)v=`Language`in p?p:{Language:d.locale,...p};else if(f===`id-msgid`)v={Language:d.locale,...o,[r]:`msgstr`,...p};else{let{[r]:e,...t}=p;v={Language:d.locale,...o,...t,[n]:`msgctxt`}}return t.serialize({meta:v,messages:_.map(h)})}}});export{l as default};
|
e-commerce/node_modules/@eloqnt/format-po/package.json
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "@eloqnt/format-po",
|
| 3 |
+
"version": "0.1.1",
|
| 4 |
+
"description": "Gettext-style PO support for eloqnt",
|
| 5 |
+
"homepage": "https://cli.eloqnt.dev/docs/formats/po",
|
| 6 |
+
"license": "MIT",
|
| 7 |
+
"files": [
|
| 8 |
+
"dist",
|
| 9 |
+
"!dist/**/*.map",
|
| 10 |
+
"CHANGELOG.md",
|
| 11 |
+
"LICENSE"
|
| 12 |
+
],
|
| 13 |
+
"type": "module",
|
| 14 |
+
"exports": {
|
| 15 |
+
".": {
|
| 16 |
+
"types": "./dist/index.d.mts",
|
| 17 |
+
"import": "./dist/index.mjs",
|
| 18 |
+
"default": "./dist/index.mjs"
|
| 19 |
+
}
|
| 20 |
+
},
|
| 21 |
+
"publishConfig": {
|
| 22 |
+
"access": "public"
|
| 23 |
+
},
|
| 24 |
+
"dependencies": {
|
| 25 |
+
"po-parser": "^2.2.0",
|
| 26 |
+
"@eloqnt/config": "^0.1.1"
|
| 27 |
+
},
|
| 28 |
+
"devDependencies": {
|
| 29 |
+
"@types/node": "^25.9.5",
|
| 30 |
+
"typescript": "^6.0.3",
|
| 31 |
+
"vite-plus": "^0.2.8"
|
| 32 |
+
},
|
| 33 |
+
"scripts": {
|
| 34 |
+
"build": "vp pack --minify src/index.ts"
|
| 35 |
+
}
|
| 36 |
+
}
|
e-commerce/node_modules/@esbuild-kit/core-utils/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
MIT License
|
| 2 |
+
|
| 3 |
+
Copyright (c) Hiroki Osame <hiroki.osame@gmail.com>
|
| 4 |
+
|
| 5 |
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
| 6 |
+
of this software and associated documentation files (the "Software"), to deal
|
| 7 |
+
in the Software without restriction, including without limitation the rights
|
| 8 |
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
| 9 |
+
copies of the Software, and to permit persons to whom the Software is
|
| 10 |
+
furnished to do so, subject to the following conditions:
|
| 11 |
+
|
| 12 |
+
The above copyright notice and this permission notice shall be included in all
|
| 13 |
+
copies or substantial portions of the Software.
|
| 14 |
+
|
| 15 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
| 16 |
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
| 17 |
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
| 18 |
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
| 19 |
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
| 20 |
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
| 21 |
+
SOFTWARE.
|
e-commerce/node_modules/@esbuild-kit/core-utils/README.md
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# @esbuild-kit/core-utils
|
| 2 |
+
|
| 3 |
+
Core utility functions used by [@esbuild-kit/cjs-loader](https://github.com/esbuild-kit/cjs-loader) and [@esbuild-kit/esm-loader](https://github.com/esbuild-kit/esm-loader).
|
| 4 |
+
|
| 5 |
+
## Library
|
| 6 |
+
|
| 7 |
+
### esbuild
|
| 8 |
+
Transform defaults, caching, and source-map handling.
|
| 9 |
+
|
| 10 |
+
### Source map support
|
| 11 |
+
Uses [native source-map](https://nodejs.org/api/process.html#processsetsourcemapsenabledval) if available, fallsback to [source-map-support](https://www.npmjs.com/package/source-map-support).
|
e-commerce/node_modules/@esbuild-kit/core-utils/dist/index.d.ts
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { MessagePort } from 'node:worker_threads';
|
| 2 |
+
import { UrlAndMap } from 'source-map-support';
|
| 3 |
+
import { TransformOptions } from 'esbuild';
|
| 4 |
+
|
| 5 |
+
type Transformed = {
|
| 6 |
+
code: string;
|
| 7 |
+
map: RawSourceMap;
|
| 8 |
+
warnings?: unknown[];
|
| 9 |
+
};
|
| 10 |
+
|
| 11 |
+
type RawSourceMap = UrlAndMap['map'];
|
| 12 |
+
declare function installSourceMapSupport(
|
| 13 |
+
/**
|
| 14 |
+
* To support Node v20 where loaders are executed in its own thread
|
| 15 |
+
* https://nodejs.org/docs/latest-v20.x/api/esm.html#globalpreload
|
| 16 |
+
*/
|
| 17 |
+
loaderPort?: MessagePort): ({ code, map }: Transformed, filePath: string, mainThreadPort?: MessagePort) => string;
|
| 18 |
+
|
| 19 |
+
declare function transformDynamicImport(filePath: string, code: string): {
|
| 20 |
+
code: string;
|
| 21 |
+
map: any;
|
| 22 |
+
} | undefined;
|
| 23 |
+
|
| 24 |
+
declare function transformSync(code: string, filePath: string, extendOptions?: TransformOptions): Transformed;
|
| 25 |
+
declare function transform(code: string, filePath: string, extendOptions?: TransformOptions): Promise<Transformed>;
|
| 26 |
+
|
| 27 |
+
declare const resolveTsPath: (filePath: string) => string | undefined;
|
| 28 |
+
|
| 29 |
+
type Version = [number, number, number];
|
| 30 |
+
declare const compareNodeVersion: (version: Version) => number;
|
| 31 |
+
|
| 32 |
+
export { RawSourceMap, compareNodeVersion, installSourceMapSupport, resolveTsPath, transform, transformDynamicImport, transformSync };
|
e-commerce/node_modules/@esbuild-kit/core-utils/dist/index.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var $t=require("source-map-support"),Zt=require("url"),ne=require("esbuild"),Wt=require("crypto"),Vt=require("fs"),zt=require("path"),eA=require("os");function T(i){return i&&typeof i=="object"&&"default"in i?i:{default:i}}var tA=T($t),AA=T(Wt),_=T(Vt),G=T(zt),nA=T(eA);const we=process.versions.node.split(".").map(Number),xe=i=>we[0]-i[0]||we[1]-i[1]||we[2]-i[2],Ue=xe([20,0,0])>=0,rA=`
|
| 2 |
+
//# sourceMappingURL=data:application/json;base64,`;function iA(i){if("setSourceMapsEnabled"in process&&typeof Error.prepareStackTrace!="function")return process.setSourceMapsEnabled(!0),({code:r,map:s})=>r+rA+Buffer.from(JSON.stringify(s),"utf8").toString("base64");const A=new Map;return tA.default.install({environment:"node",retrieveSourceMap(r){const s=A.get(r);return s?{url:r,map:s}:null}}),Ue&&i&&i.addListener("message",({filePath:r,map:s})=>A.set(r,s)),({code:r,map:s},a,c)=>(Ue&&c?c.postMessage({filePath:a,map:s}):A.set(a,s),r)}const qe=i=>AA.default.createHash("sha1").update(i).digest("hex"),Me=",".charCodeAt(0),sA=";".charCodeAt(0),Ge="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Ye=new Uint8Array(64),_e=new Uint8Array(128);for(let i=0;i<Ge.length;i++){const e=Ge.charCodeAt(i);Ye[i]=e,_e[e]=i}const ke=typeof TextDecoder<"u"?new TextDecoder:typeof Buffer<"u"?{decode(i){return Buffer.from(i.buffer,i.byteOffset,i.byteLength).toString()}}:{decode(i){let e="";for(let A=0;A<i.length;A++)e+=String.fromCharCode(i[A]);return e}};function oA(i){const e=new Int32Array(5),A=[];let r=0;do{const s=aA(i,r),a=[];let c=!0,C=0;e[0]=0;for(let Q=r;Q<s;Q++){let g;Q=$(i,Q,e,0);const l=e[0];l<C&&(c=!1),C=l,Oe(i,Q,s)?(Q=$(i,Q,e,1),Q=$(i,Q,e,2),Q=$(i,Q,e,3),Oe(i,Q,s)?(Q=$(i,Q,e,4),g=[l,e[1],e[2],e[3],e[4]]):g=[l,e[1],e[2],e[3]]):g=[l],a.push(g)}c||cA(a),A.push(a),r=s+1}while(r<=i.length);return A}function aA(i,e){const A=i.indexOf(";",e);return A===-1?i.length:A}function $(i,e,A,r){let s=0,a=0,c=0;do{const Q=i.charCodeAt(e++);c=_e[Q],s|=(c&31)<<a,a+=5}while(c&32);const C=s&1;return s>>>=1,C&&(s=-2147483648|-s),A[r]+=s,e}function Oe(i,e,A){return e>=A?!1:i.charCodeAt(e)!==Me}function cA(i){i.sort(uA)}function uA(i,e){return i[0]-e[0]}function He(i){const e=new Int32Array(5),A=1024*16,r=A-36,s=new Uint8Array(A),a=s.subarray(0,r);let c=0,C="";for(let Q=0;Q<i.length;Q++){const g=i[Q];if(Q>0&&(c===A&&(C+=ke.decode(s),c=0),s[c++]=sA),g.length!==0){e[0]=0;for(let l=0;l<g.length;l++){const n=g[l];c>r&&(C+=ke.decode(a),s.copyWithin(0,r,c),c-=r),l>0&&(s[c++]=Me),c=Z(s,c,e,n,0),n.length!==1&&(c=Z(s,c,e,n,1),c=Z(s,c,e,n,2),c=Z(s,c,e,n,3),n.length!==4&&(c=Z(s,c,e,n,4)))}}}return C+ke.decode(s.subarray(0,c))}function Z(i,e,A,r,s){const a=r[s];let c=a-A[s];A[s]=a,c=c<0?-c<<1|1:c<<1;do{let C=c&31;c>>>=5,c>0&&(C|=32),i[e++]=Ye[C]}while(c>0);return e}class ue{constructor(e){this.bits=e instanceof ue?e.bits.slice():[]}add(e){this.bits[e>>5]|=1<<(e&31)}has(e){return!!(this.bits[e>>5]&1<<(e&31))}}class z{constructor(e,A,r){this.start=e,this.end=A,this.original=r,this.intro="",this.outro="",this.content=r,this.storeName=!1,this.edited=!1,this.previous=null,this.next=null}appendLeft(e){this.outro+=e}appendRight(e){this.intro=this.intro+e}clone(){const e=new z(this.start,this.end,this.original);return e.intro=this.intro,e.outro=this.outro,e.content=this.content,e.storeName=this.storeName,e.edited=this.edited,e}contains(e){return this.start<e&&e<this.end}eachNext(e){let A=this;for(;A;)e(A),A=A.next}eachPrevious(e){let A=this;for(;A;)e(A),A=A.previous}edit(e,A,r){return this.content=e,r||(this.intro="",this.outro=""),this.storeName=A,this.edited=!0,this}prependLeft(e){this.outro=e+this.outro}prependRight(e){this.intro=e+this.intro}split(e){const A=e-this.start,r=this.original.slice(0,A),s=this.original.slice(A);this.original=r;const a=new z(e,this.end,s);return a.outro=this.outro,this.outro="",this.end=e,this.edited?(a.edit("",!1),this.content=""):this.content=r,a.next=this.next,a.next&&(a.next.previous=a),a.previous=this,this.next=a,a}toString(){return this.intro+this.content+this.outro}trimEnd(e){if(this.outro=this.outro.replace(e,""),this.outro.length)return!0;const A=this.content.replace(e,"");if(A.length)return A!==this.content&&(this.split(this.start+A.length).edit("",void 0,!0),this.edited&&this.edit(A,this.storeName,!0)),!0;if(this.edit("",void 0,!0),this.intro=this.intro.replace(e,""),this.intro.length)return!0}trimStart(e){if(this.intro=this.intro.replace(e,""),this.intro.length)return!0;const A=this.content.replace(e,"");if(A.length){if(A!==this.content){const r=this.split(this.end-A.length);this.edited&&r.edit(A,this.storeName,!0),this.edit("",void 0,!0)}return!0}else if(this.edit("",void 0,!0),this.outro=this.outro.replace(e,""),this.outro.length)return!0}}function lA(){return typeof window<"u"&&typeof window.btoa=="function"?i=>window.btoa(unescape(encodeURIComponent(i))):typeof Buffer=="function"?i=>Buffer.from(i,"utf-8").toString("base64"):()=>{throw new Error("Unsupported environment: `window.btoa` or `Buffer` should be supported.")}}const QA=lA();class fA{constructor(e){this.version=3,this.file=e.file,this.sources=e.sources,this.sourcesContent=e.sourcesContent,this.names=e.names,this.mappings=He(e.mappings),typeof e.x_google_ignoreList<"u"&&(this.x_google_ignoreList=e.x_google_ignoreList)}toString(){return JSON.stringify(this)}toUrl(){return"data:application/json;charset=utf-8;base64,"+QA(this.toString())}}function gA(i){const e=i.split(`
|
| 3 |
+
`),A=e.filter(a=>/^\t+/.test(a)),r=e.filter(a=>/^ {2,}/.test(a));if(A.length===0&&r.length===0)return null;if(A.length>=r.length)return" ";const s=r.reduce((a,c)=>{const C=/^ +/.exec(c)[0].length;return Math.min(C,a)},1/0);return new Array(s+1).join(" ")}function hA(i,e){const A=i.split(/[/\\]/),r=e.split(/[/\\]/);for(A.pop();A[0]===r[0];)A.shift(),r.shift();if(A.length){let s=A.length;for(;s--;)A[s]=".."}return A.concat(r).join("/")}const CA=Object.prototype.toString;function BA(i){return CA.call(i)==="[object Object]"}function je(i){const e=i.split(`
|
| 4 |
+
`),A=[];for(let r=0,s=0;r<e.length;r++)A.push(s),s+=e[r].length+1;return function(s){let a=0,c=A.length;for(;a<c;){const g=a+c>>1;s<A[g]?c=g:a=g+1}const C=a-1,Q=s-A[C];return{line:C,column:Q}}}const EA=/\w/;class dA{constructor(e){this.hires=e,this.generatedCodeLine=0,this.generatedCodeColumn=0,this.raw=[],this.rawSegments=this.raw[this.generatedCodeLine]=[],this.pending=null}addEdit(e,A,r,s){if(A.length){const a=[this.generatedCodeColumn,e,r.line,r.column];s>=0&&a.push(s),this.rawSegments.push(a)}else this.pending&&this.rawSegments.push(this.pending);this.advance(A),this.pending=null}addUneditedChunk(e,A,r,s,a){let c=A.start,C=!0,Q=!1;for(;c<A.end;){if(this.hires||C||a.has(c)){const g=[this.generatedCodeColumn,e,s.line,s.column];this.hires==="boundary"?EA.test(r[c])?Q||(this.rawSegments.push(g),Q=!0):(this.rawSegments.push(g),Q=!1):this.rawSegments.push(g)}r[c]===`
|
| 5 |
+
`?(s.line+=1,s.column=0,this.generatedCodeLine+=1,this.raw[this.generatedCodeLine]=this.rawSegments=[],this.generatedCodeColumn=0,C=!0):(s.column+=1,this.generatedCodeColumn+=1,C=!1),c+=1}this.pending=null}advance(e){if(!e)return;const A=e.split(`
|
| 6 |
+
`);if(A.length>1){for(let r=0;r<A.length-1;r++)this.generatedCodeLine++,this.raw[this.generatedCodeLine]=this.rawSegments=[];this.generatedCodeColumn=0}this.generatedCodeColumn+=A[A.length-1].length}}const W=`
|
| 7 |
+
`,O={insertLeft:!1,insertRight:!1,storeName:!1};class Se{constructor(e,A={}){const r=new z(0,e.length,e);Object.defineProperties(this,{original:{writable:!0,value:e},outro:{writable:!0,value:""},intro:{writable:!0,value:""},firstChunk:{writable:!0,value:r},lastChunk:{writable:!0,value:r},lastSearchedChunk:{writable:!0,value:r},byStart:{writable:!0,value:{}},byEnd:{writable:!0,value:{}},filename:{writable:!0,value:A.filename},indentExclusionRanges:{writable:!0,value:A.indentExclusionRanges},sourcemapLocations:{writable:!0,value:new ue},storedNames:{writable:!0,value:{}},indentStr:{writable:!0,value:void 0},ignoreList:{writable:!0,value:A.ignoreList}}),this.byStart[0]=r,this.byEnd[e.length]=r}addSourcemapLocation(e){this.sourcemapLocations.add(e)}append(e){if(typeof e!="string")throw new TypeError("outro content must be a string");return this.outro+=e,this}appendLeft(e,A){if(typeof A!="string")throw new TypeError("inserted content must be a string");this._split(e);const r=this.byEnd[e];return r?r.appendLeft(A):this.intro+=A,this}appendRight(e,A){if(typeof A!="string")throw new TypeError("inserted content must be a string");this._split(e);const r=this.byStart[e];return r?r.appendRight(A):this.outro+=A,this}clone(){const e=new Se(this.original,{filename:this.filename});let A=this.firstChunk,r=e.firstChunk=e.lastSearchedChunk=A.clone();for(;A;){e.byStart[r.start]=r,e.byEnd[r.end]=r;const s=A.next,a=s&&s.clone();a&&(r.next=a,a.previous=r,r=a),A=s}return e.lastChunk=r,this.indentExclusionRanges&&(e.indentExclusionRanges=this.indentExclusionRanges.slice()),e.sourcemapLocations=new ue(this.sourcemapLocations),e.intro=this.intro,e.outro=this.outro,e}generateDecodedMap(e){e=e||{};const A=0,r=Object.keys(this.storedNames),s=new dA(e.hires),a=je(this.original);return this.intro&&s.advance(this.intro),this.firstChunk.eachNext(c=>{const C=a(c.start);c.intro.length&&s.advance(c.intro),c.edited?s.addEdit(A,c.content,C,c.storeName?r.indexOf(c.original):-1):s.addUneditedChunk(A,c,this.original,C,this.sourcemapLocations),c.outro.length&&s.advance(c.outro)}),{file:e.file?e.file.split(/[/\\]/).pop():void 0,sources:[e.source?hA(e.file||"",e.source):e.file||""],sourcesContent:e.includeContent?[this.original]:void 0,names:r,mappings:s.raw,x_google_ignoreList:this.ignoreList?[A]:void 0}}generateMap(e){return new fA(this.generateDecodedMap(e))}_ensureindentStr(){this.indentStr===void 0&&(this.indentStr=gA(this.original))}_getRawIndentString(){return this._ensureindentStr(),this.indentStr}getIndentString(){return this._ensureindentStr(),this.indentStr===null?" ":this.indentStr}indent(e,A){const r=/^[^\r\n]/gm;if(BA(e)&&(A=e,e=void 0),e===void 0&&(this._ensureindentStr(),e=this.indentStr||" "),e==="")return this;A=A||{};const s={};A.exclude&&(typeof A.exclude[0]=="number"?[A.exclude]:A.exclude).forEach(l=>{for(let n=l[0];n<l[1];n+=1)s[n]=!0});let a=A.indentStart!==!1;const c=g=>a?`${e}${g}`:(a=!0,g);this.intro=this.intro.replace(r,c);let C=0,Q=this.firstChunk;for(;Q;){const g=Q.end;if(Q.edited)s[C]||(Q.content=Q.content.replace(r,c),Q.content.length&&(a=Q.content[Q.content.length-1]===`
|
| 8 |
+
`));else for(C=Q.start;C<g;){if(!s[C]){const l=this.original[C];l===`
|
| 9 |
+
`?a=!0:l!=="\r"&&a&&(a=!1,C===Q.start||(this._splitChunk(Q,C),Q=Q.next),Q.prependRight(e))}C+=1}C=Q.end,Q=Q.next}return this.outro=this.outro.replace(r,c),this}insert(){throw new Error("magicString.insert(...) is deprecated. Use prependRight(...) or appendLeft(...)")}insertLeft(e,A){return O.insertLeft||(console.warn("magicString.insertLeft(...) is deprecated. Use magicString.appendLeft(...) instead"),O.insertLeft=!0),this.appendLeft(e,A)}insertRight(e,A){return O.insertRight||(console.warn("magicString.insertRight(...) is deprecated. Use magicString.prependRight(...) instead"),O.insertRight=!0),this.prependRight(e,A)}move(e,A,r){if(r>=e&&r<=A)throw new Error("Cannot move a selection inside itself");this._split(e),this._split(A),this._split(r);const s=this.byStart[e],a=this.byEnd[A],c=s.previous,C=a.next,Q=this.byStart[r];if(!Q&&a===this.lastChunk)return this;const g=Q?Q.previous:this.lastChunk;return c&&(c.next=C),C&&(C.previous=c),g&&(g.next=s),Q&&(Q.previous=a),s.previous||(this.firstChunk=a.next),a.next||(this.lastChunk=s.previous,this.lastChunk.next=null),s.previous=g,a.next=Q||null,g||(this.firstChunk=s),Q||(this.lastChunk=a),this}overwrite(e,A,r,s){return s=s||{},this.update(e,A,r,{...s,overwrite:!s.contentOnly})}update(e,A,r,s){if(typeof r!="string")throw new TypeError("replacement content must be a string");for(;e<0;)e+=this.original.length;for(;A<0;)A+=this.original.length;if(A>this.original.length)throw new Error("end is out of bounds");if(e===A)throw new Error("Cannot overwrite a zero-length range \u2013 use appendLeft or prependRight instead");this._split(e),this._split(A),s===!0&&(O.storeName||(console.warn("The final argument to magicString.overwrite(...) should be an options object. See https://github.com/rich-harris/magic-string"),O.storeName=!0),s={storeName:!0});const a=s!==void 0?s.storeName:!1,c=s!==void 0?s.overwrite:!1;if(a){const g=this.original.slice(e,A);Object.defineProperty(this.storedNames,g,{writable:!0,value:!0,enumerable:!0})}const C=this.byStart[e],Q=this.byEnd[A];if(C){let g=C;for(;g!==Q;){if(g.next!==this.byStart[g.end])throw new Error("Cannot overwrite across a split point");g=g.next,g.edit("",!1)}C.edit(r,a,!c)}else{const g=new z(e,A,"").edit(r,a);Q.next=g,g.previous=Q}return this}prepend(e){if(typeof e!="string")throw new TypeError("outro content must be a string");return this.intro=e+this.intro,this}prependLeft(e,A){if(typeof A!="string")throw new TypeError("inserted content must be a string");this._split(e);const r=this.byEnd[e];return r?r.prependLeft(A):this.intro=A+this.intro,this}prependRight(e,A){if(typeof A!="string")throw new TypeError("inserted content must be a string");this._split(e);const r=this.byStart[e];return r?r.prependRight(A):this.outro=A+this.outro,this}remove(e,A){for(;e<0;)e+=this.original.length;for(;A<0;)A+=this.original.length;if(e===A)return this;if(e<0||A>this.original.length)throw new Error("Character is out of bounds");if(e>A)throw new Error("end must be greater than start");this._split(e),this._split(A);let r=this.byStart[e];for(;r;)r.intro="",r.outro="",r.edit(""),r=A>r.end?this.byStart[r.end]:null;return this}lastChar(){if(this.outro.length)return this.outro[this.outro.length-1];let e=this.lastChunk;do{if(e.outro.length)return e.outro[e.outro.length-1];if(e.content.length)return e.content[e.content.length-1];if(e.intro.length)return e.intro[e.intro.length-1]}while(e=e.previous);return this.intro.length?this.intro[this.intro.length-1]:""}lastLine(){let e=this.outro.lastIndexOf(W);if(e!==-1)return this.outro.substr(e+1);let A=this.outro,r=this.lastChunk;do{if(r.outro.length>0){if(e=r.outro.lastIndexOf(W),e!==-1)return r.outro.substr(e+1)+A;A=r.outro+A}if(r.content.length>0){if(e=r.content.lastIndexOf(W),e!==-1)return r.content.substr(e+1)+A;A=r.content+A}if(r.intro.length>0){if(e=r.intro.lastIndexOf(W),e!==-1)return r.intro.substr(e+1)+A;A=r.intro+A}}while(r=r.previous);return e=this.intro.lastIndexOf(W),e!==-1?this.intro.substr(e+1)+A:this.intro+A}slice(e=0,A=this.original.length){for(;e<0;)e+=this.original.length;for(;A<0;)A+=this.original.length;let r="",s=this.firstChunk;for(;s&&(s.start>e||s.end<=e);){if(s.start<A&&s.end>=A)return r;s=s.next}if(s&&s.edited&&s.start!==e)throw new Error(`Cannot use replaced character ${e} as slice start anchor.`);const a=s;for(;s;){s.intro&&(a!==s||s.start===e)&&(r+=s.intro);const c=s.start<A&&s.end>=A;if(c&&s.edited&&s.end!==A)throw new Error(`Cannot use replaced character ${A} as slice end anchor.`);const C=a===s?e-s.start:0,Q=c?s.content.length+A-s.end:s.content.length;if(r+=s.content.slice(C,Q),s.outro&&(!c||s.end===A)&&(r+=s.outro),c)break;s=s.next}return r}snip(e,A){const r=this.clone();return r.remove(0,e),r.remove(A,r.original.length),r}_split(e){if(this.byStart[e]||this.byEnd[e])return;let A=this.lastSearchedChunk;const r=e>A.end;for(;A;){if(A.contains(e))return this._splitChunk(A,e);A=r?this.byStart[A.end]:this.byEnd[A.start]}}_splitChunk(e,A){if(e.edited&&e.content.length){const s=je(this.original)(A);throw new Error(`Cannot split a chunk that has already been edited (${s.line}:${s.column} \u2013 "${e.original}")`)}const r=e.split(A);return this.byEnd[A]=e,this.byStart[A]=r,this.byEnd[r.end]=r,e===this.lastChunk&&(this.lastChunk=r),this.lastSearchedChunk=e,!0}toString(){let e=this.intro,A=this.firstChunk;for(;A;)e+=A.toString(),A=A.next;return e+this.outro}isEmpty(){let e=this.firstChunk;do if(e.intro.length&&e.intro.trim()||e.content.length&&e.content.trim()||e.outro.length&&e.outro.trim())return!1;while(e=e.next);return!0}length(){let e=this.firstChunk,A=0;do A+=e.intro.length+e.content.length+e.outro.length;while(e=e.next);return A}trimLines(){return this.trim("[\\r\\n]")}trim(e){return this.trimStart(e).trimEnd(e)}trimEndAborted(e){const A=new RegExp((e||"\\s")+"+$");if(this.outro=this.outro.replace(A,""),this.outro.length)return!0;let r=this.lastChunk;do{const s=r.end,a=r.trimEnd(A);if(r.end!==s&&(this.lastChunk===r&&(this.lastChunk=r.next),this.byEnd[r.end]=r,this.byStart[r.next.start]=r.next,this.byEnd[r.next.end]=r.next),a)return!0;r=r.previous}while(r);return!1}trimEnd(e){return this.trimEndAborted(e),this}trimStartAborted(e){const A=new RegExp("^"+(e||"\\s")+"+");if(this.intro=this.intro.replace(A,""),this.intro.length)return!0;let r=this.firstChunk;do{const s=r.end,a=r.trimStart(A);if(r.end!==s&&(r===this.lastChunk&&(this.lastChunk=r.next),this.byEnd[r.end]=r,this.byStart[r.next.start]=r.next,this.byEnd[r.next.end]=r.next),a)return!0;r=r.next}while(r);return!1}trimStart(e){return this.trimStartAborted(e),this}hasChanged(){return this.original!==this.toString()}_replaceRegexp(e,A){function r(a,c){return typeof A=="string"?A.replace(/\$(\$|&|\d+)/g,(C,Q)=>Q==="$"?"$":Q==="&"?a[0]:+Q<a.length?a[+Q]:`$${Q}`):A(...a,a.index,c,a.groups)}function s(a,c){let C;const Q=[];for(;C=a.exec(c);)Q.push(C);return Q}if(e.global)s(e,this.original).forEach(c=>{c.index!=null&&this.overwrite(c.index,c.index+c[0].length,r(c,this.original))});else{const a=this.original.match(e);a&&a.index!=null&&this.overwrite(a.index,a.index+a[0].length,r(a,this.original))}return this}_replaceString(e,A){const{original:r}=this,s=r.indexOf(e);return s!==-1&&this.overwrite(s,s+e.length,A),this}replace(e,A){return typeof e=="string"?this._replaceString(e,A):this._replaceRegexp(e,A)}_replaceAllString(e,A){const{original:r}=this,s=e.length;for(let a=r.indexOf(e);a!==-1;a=r.indexOf(e,a+s))this.overwrite(a,a+s,A);return this}replaceAll(e,A){if(typeof e=="string")return this._replaceAllString(e,A);if(!e.global)throw new TypeError("MagicString.prototype.replaceAll called with a non-global RegExp argument");return this._replaceRegexp(e,A)}}const wA=new Uint8Array(new Uint16Array([1]).buffer)[0]===1;function Xe(i,e="@"){if(!w)return Pe.then(()=>Xe(i));const A=i.length+1,r=(w.__heap_base.value||w.__heap_base)+4*A-w.memory.buffer.byteLength;r>0&&w.memory.grow(Math.ceil(r/65536));const s=w.sa(A-1);if((wA?IA:kA)(i,new Uint16Array(w.memory.buffer,s,A)),!w.parse())throw Object.assign(new Error(`Parse error ${e}:${i.slice(0,w.e()).split(`
|
| 10 |
+
`).length}:${w.e()-i.lastIndexOf(`
|
| 11 |
+
`,w.e()-1)}`),{idx:w.e()});const a=[],c=[];for(;w.ri();){const Q=w.is(),g=w.ie(),l=w.ai(),n=w.id(),p=w.ss(),y=w.se();let k;w.ip()&&(k=C(i.slice(n===-1?Q-1:Q,n===-1?g+1:g))),a.push({n:k,s:Q,e:g,ss:p,se:y,d:n,a:l})}for(;w.re();){const Q=w.es(),g=w.ee(),l=w.els(),n=w.ele(),p=i.slice(Q,g),y=p[0],k=l<0?void 0:i.slice(l,n),N=k?k[0]:"";c.push({s:Q,e:g,ls:l,le:n,n:y==='"'||y==="'"?C(p):p,ln:N==='"'||N==="'"?C(k):k})}function C(Q){try{return(0,eval)(Q)}catch{}}return[a,c,!!w.f()]}function kA(i,e){const A=i.length;let r=0;for(;r<A;){const s=i.charCodeAt(r);e[r++]=(255&s)<<8|s>>>8}}function IA(i,e){const A=i.length;let r=0;for(;r<A;)e[r]=i.charCodeAt(r++)}let w;const Pe=WebAssembly.compile((Ie="AGFzbQEAAAABKghgAX8Bf2AEf39/fwBgAAF/YAAAYAF/AGADf39/AX9gAn9/AX9gAn9/AAMvLgABAQICAgICAgICAgICAgICAgIAAwMDBAQAAAADAAAAAAMDAAUGAAAABwAGAgUEBQFwAQEBBQMBAAEGDwJ/AUGw8gALfwBBsPIACwdwEwZtZW1vcnkCAAJzYQAAAWUAAwJpcwAEAmllAAUCc3MABgJzZQAHAmFpAAgCaWQACQJpcAAKAmVzAAsCZWUADANlbHMADQNlbGUADgJyaQAPAnJlABABZgARBXBhcnNlABILX19oZWFwX2Jhc2UDAQqpPS5oAQF/QQAgADYC9AlBACgC0AkiASAAQQF0aiIAQQA7AQBBACAAQQJqIgA2AvgJQQAgADYC/AlBAEEANgLUCUEAQQA2AuQJQQBBADYC3AlBAEEANgLYCUEAQQA2AuwJQQBBADYC4AkgAQufAQEDf0EAKALkCSEEQQBBACgC/AkiBTYC5AlBACAENgLoCUEAIAVBIGo2AvwJIARBHGpB1AkgBBsgBTYCAEEAKALICSEEQQAoAsQJIQYgBSABNgIAIAUgADYCCCAFIAIgAkECakEAIAYgA0YbIAQgA0YbNgIMIAUgAzYCFCAFQQA2AhAgBSACNgIEIAVBADYCHCAFQQAoAsQJIANGOgAYC1YBAX9BACgC7AkiBEEQakHYCSAEG0EAKAL8CSIENgIAQQAgBDYC7AlBACAEQRRqNgL8CSAEQQA2AhAgBCADNgIMIAQgAjYCCCAEIAE2AgQgBCAANgIACwgAQQAoAoAKCxUAQQAoAtwJKAIAQQAoAtAJa0EBdQseAQF/QQAoAtwJKAIEIgBBACgC0AlrQQF1QX8gABsLFQBBACgC3AkoAghBACgC0AlrQQF1Cx4B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AHIAdABlAHQAYQByAG8AbQB1AG4AYwB0AGkAbwBuAHMAcwBlAHIAdAB2AG8AeQBpAGUAZABlAGwAZQBjAG8AbgB0AGkAbgBpAG4AcwB0AGEAbgB0AHkAYgByAGUAYQByAGUAdAB1AHIAZABlAGIAdQBnAGcAZQBhAHcAYQBpAHQAaAByAHcAaABpAGwAZQBmAG8AcgBpAGYAYwBhAHQAYwBmAGkAbgBhAGwAbABlAGwAcwAAQcQJCxABAAAAAgAAAAAEAAAwOQAA",typeof Buffer<"u"?Buffer.from(Ie,"base64"):Uint8Array.from(atob(Ie),i=>i.charCodeAt(0)))).then(WebAssembly.instantiate).then(({exports:i})=>{w=i});var Ie;let D,re,pe,V=2<<19;const Te=new Uint8Array(new Uint16Array([1]).buffer)[0]===1?function(i,e){const A=i.length;let r=0;for(;r<A;)e[r]=i.charCodeAt(r++)}:function(i,e){const A=i.length;let r=0;for(;r<A;){const s=i.charCodeAt(r);e[r++]=(255&s)<<8|s>>>8}},pA="xportmportlassetaromsyncunctionssertvoyiedelecontininstantybreareturdebuggeawaithrwhileforifcatcfinallels";let b,$e,d;function bA(i,e="@"){b=i,$e=e;const A=2*b.length+(2<<18);if(A>V||!D){for(;A>V;)V*=2;re=new ArrayBuffer(V),Te(pA,new Uint16Array(re,16,105)),D=function(c,C,Q){var g=new c.Int8Array(Q),l=new c.Int16Array(Q),n=new c.Int32Array(Q),p=new c.Uint8Array(Q),y=new c.Uint16Array(Q),k=1024;function N(){var t=0,o=0,u=0,h=0,B=0,f=0,x=0;x=k,k=k+10240|0,g[795]=1,l[395]=0,l[396]=0,n[67]=n[2],g[796]=0,n[66]=0,g[794]=0,n[68]=x+2048,n[69]=x,g[797]=0,t=(n[3]|0)+-2|0,n[70]=t,o=t+(n[64]<<1)|0,n[71]=o;e:for(;;){if(u=t+2|0,n[70]=u,t>>>0>=o>>>0){f=18;break}A:do switch(l[u>>1]|0){case 9:case 10:case 11:case 12:case 13:case 32:break;case 101:{if(!(l[396]|0)&&j(u)|0&&!(J(t+4|0,16,10)|0)&&(v(),(g[795]|0)==0)){f=9;break e}else f=17;break}case 105:{j(u)|0&&!(J(t+4|0,26,10)|0)&&ee(),f=17;break}case 59:{f=17;break}case 47:switch(l[t+4>>1]|0){case 47:{he();break A}case 42:{fe(1);break A}default:{f=16;break e}}default:{f=16;break e}}while(0);(f|0)==17&&(f=0,n[67]=n[70]),t=n[70]|0,o=n[71]|0}(f|0)==9?(t=n[70]|0,n[67]=t,f=19):(f|0)==16?(g[795]=0,n[70]=t,f=19):(f|0)==18&&(g[794]|0?t=0:(t=u,f=19));do if((f|0)==19){e:for(;;){if(o=t+2|0,n[70]=o,B=o,t>>>0>=(n[71]|0)>>>0){f=82;break}A:do switch(l[o>>1]|0){case 9:case 10:case 11:case 12:case 13:case 32:break;case 101:{!(l[396]|0)&&j(o)|0&&!(J(t+4|0,16,10)|0)&&v(),f=81;break}case 105:{j(o)|0&&!(J(t+4|0,26,10)|0)&&ee(),f=81;break}case 99:{j(o)|0&&!(J(t+4|0,36,8)|0)&&X(l[t+12>>1]|0)|0&&(g[797]=1),f=81;break}case 40:{B=n[68]|0,u=l[396]|0,f=u&65535,n[B+(f<<3)>>2]=1,h=n[67]|0,l[396]=u+1<<16>>16,n[B+(f<<3)+4>>2]=h,f=81;break}case 41:{if(o=l[396]|0,!(o<<16>>16)){f=36;break e}f=o+-1<<16>>16,l[396]=f,h=l[395]|0,o=h&65535,h<<16>>16&&(n[(n[68]|0)+((f&65535)<<3)>>2]|0)==5&&(o=n[(n[69]|0)+(o+-1<<2)>>2]|0,u=o+4|0,n[u>>2]|0||(n[u>>2]=B),n[o+12>>2]=t+4,l[395]=h+-1<<16>>16),f=81;break}case 123:{f=n[67]|0,B=n[61]|0,t=f;do if((l[f>>1]|0)==41&(B|0)!=0&&(n[B+4>>2]|0)==(f|0))if(o=n[62]|0,n[61]=o,o){n[o+28>>2]=0;break}else{n[57]=0;break}while(0);B=n[68]|0,h=l[396]|0,f=h&65535,n[B+(f<<3)>>2]=g[797]|0?6:2,l[396]=h+1<<16>>16,n[B+(f<<3)+4>>2]=t,g[797]=0,f=81;break}case 125:{if(t=l[396]|0,!(t<<16>>16)){f=49;break e}B=n[68]|0,f=t+-1<<16>>16,l[396]=f,(n[B+((f&65535)<<3)>>2]|0)==4&&Je(),f=81;break}case 39:{L(39),f=81;break}case 34:{L(34),f=81;break}case 47:switch(l[t+4>>1]|0){case 47:{he();break A}case 42:{fe(1);break A}default:{t=n[67]|0,h=l[t>>1]|0;t:do if(yt(h)|0)switch(h<<16>>16){case 46:if(((l[t+-2>>1]|0)+-48&65535)<10){f=66;break t}else{f=69;break t}case 43:if((l[t+-2>>1]|0)==43){f=66;break t}else{f=69;break t}case 45:if((l[t+-2>>1]|0)==45){f=66;break t}else{f=69;break t}default:{f=69;break t}}else{switch(h<<16>>16){case 41:if(Lt(n[(n[68]|0)+(y[396]<<3)+4>>2]|0)|0){f=69;break t}else{f=66;break t}case 125:break;default:{f=66;break t}}o=n[68]|0,u=y[396]|0,!(Kt(n[o+(u<<3)+4>>2]|0)|0)&&(n[o+(u<<3)>>2]|0)!=6?f=66:f=69}while(0);t:do if((f|0)==66)if(f=0,mt(t)|0)f=69;else{switch(h<<16>>16){case 0:{f=69;break t}case 47:{if(g[796]|0){f=69;break t}break}default:}u=n[3]|0,o=h;do{if(t>>>0<=u>>>0)break;t=t+-2|0,n[67]=t,o=l[t>>1]|0}while(!(ge(o)|0));if(Ae(o)|0){do{if(t>>>0<=u>>>0)break;t=t+-2|0,n[67]=t}while(Ae(l[t>>1]|0)|0);if(Jt(t)|0){Le(),g[796]=0,f=81;break A}else t=1}else t=1}while(0);(f|0)==69&&(Le(),t=0),g[796]=t,f=81;break A}}case 96:{B=n[68]|0,h=l[396]|0,f=h&65535,n[B+(f<<3)+4>>2]=n[67],l[396]=h+1<<16>>16,n[B+(f<<3)>>2]=3,Je(),f=81;break}default:f=81}while(0);(f|0)==81&&(f=0,n[67]=n[70]),t=n[70]|0}if((f|0)==36){R(),t=0;break}else if((f|0)==49){R(),t=0;break}else if((f|0)==82){t=g[794]|0?0:(l[395]|l[396])<<16>>16==0;break}}while(0);return k=x,t|0}function v(){var t=0,o=0,u=0,h=0,B=0,f=0,x=0,M=0,Ce=0,Be=0,Ee=0,de=0,I=0,m=0;M=n[70]|0,Ce=n[63]|0,m=M+12|0,n[70]=m,u=E(1)|0,t=n[70]|0,(t|0)==(m|0)&&!(te(u)|0)||(I=3);e:do if((I|0)==3){A:do switch(u<<16>>16){case 123:{for(n[70]=t+2,t=E(1)|0,u=n[70]|0;;){if(P(t)|0?(L(t),t=(n[70]|0)+2|0,n[70]=t):(F(t)|0,t=n[70]|0),E(1)|0,t=Ne(u,t)|0,t<<16>>16==44&&(n[70]=(n[70]|0)+2,t=E(1)|0),o=u,u=n[70]|0,t<<16>>16==125){I=15;break}if((u|0)==(o|0)){I=12;break}if(u>>>0>(n[71]|0)>>>0){I=14;break}}if((I|0)==12){R();break e}else if((I|0)==14){R();break e}else if((I|0)==15){n[70]=u+2;break A}break}case 42:{n[70]=t+2,E(1)|0,m=n[70]|0,Ne(m,m)|0;break}default:{switch(g[795]=0,u<<16>>16){case 100:{switch(M=t+14|0,n[70]=M,(E(1)|0)<<16>>16){case 97:{o=n[70]|0,!(J(o+2|0,56,8)|0)&&(B=o+10|0,Ae(l[B>>1]|0)|0)&&(n[70]=B,E(0)|0,I=22);break}case 102:{I=22;break}case 99:{o=n[70]|0,!(J(o+2|0,36,8)|0)&&(h=o+10|0,m=l[h>>1]|0,X(m)|0|m<<16>>16==123)&&(n[70]=h,f=E(1)|0,f<<16>>16!=123)&&(de=f,I=31);break}default:}t:do if((I|0)==22&&(x=n[70]|0,(J(x+2|0,64,14)|0)==0)){if(u=x+16|0,o=l[u>>1]|0,!(X(o)|0))switch(o<<16>>16){case 40:case 42:break;default:break t}n[70]=u,o=E(1)|0,o<<16>>16==42&&(n[70]=(n[70]|0)+2,o=E(1)|0),o<<16>>16!=40&&(de=o,I=31)}while(0);if((I|0)==31&&(Be=n[70]|0,F(de)|0,Ee=n[70]|0,Ee>>>0>Be>>>0)){Y(t,M,Be,Ee),n[70]=(n[70]|0)+-2;break e}Y(t,M,0,0),n[70]=t+12;break e}case 97:{n[70]=t+10,E(0)|0,t=n[70]|0,I=35;break}case 102:{I=35;break}case 99:{if(!(J(t+2|0,36,8)|0)&&(o=t+10|0,ge(l[o>>1]|0)|0)){n[70]=o,m=E(1)|0,I=n[70]|0,F(m)|0,m=n[70]|0,Y(I,m,I,m),n[70]=(n[70]|0)+-2;break e}t=t+4|0,n[70]=t;break}case 108:case 118:break;default:break e}if((I|0)==35){n[70]=t+16,t=E(1)|0,t<<16>>16==42&&(n[70]=(n[70]|0)+2,t=E(1)|0),I=n[70]|0,F(t)|0,m=n[70]|0,Y(I,m,I,m),n[70]=(n[70]|0)+-2;break e}n[70]=t+6,g[795]=0,u=E(1)|0,t=n[70]|0,u=(F(u)|0|32)<<16>>16==123,h=n[70]|0,u&&(n[70]=h+2,m=E(1)|0,t=n[70]|0,F(m)|0);t:for(;o=n[70]|0,(o|0)!=(t|0);){if(Y(t,o,t,o),o=E(1)|0,u)switch(o<<16>>16){case 93:case 125:break e;default:}if(t=n[70]|0,o<<16>>16!=44){I=51;break}switch(n[70]=t+2,o=E(1)|0,t=n[70]|0,o<<16>>16){case 91:case 123:{I=51;break t}default:}F(o)|0}if((I|0)==51&&(n[70]=t+-2),!u)break e;n[70]=h+-2;break e}}while(0);if(m=(E(1)|0)<<16>>16==102,t=n[70]|0,m&&!(J(t+2|0,50,6)|0))for(n[70]=t+8,le(M,E(1)|0),t=Ce|0?Ce+16|0:232;;){if(t=n[t>>2]|0,!t)break e;n[t+12>>2]=0,n[t+8>>2]=0,t=t+16|0}n[70]=t+-2}while(0)}function ee(){var t=0,o=0,u=0,h=0,B=0,f=0;B=n[70]|0,t=B+12|0,n[70]=t;e:do switch((E(1)|0)<<16>>16){case 40:{if(o=n[68]|0,f=l[396]|0,u=f&65535,n[o+(u<<3)>>2]=5,t=n[70]|0,l[396]=f+1<<16>>16,n[o+(u<<3)+4>>2]=t,(l[n[67]>>1]|0)!=46){switch(n[70]=t+2,f=E(1)|0,Qe(B,n[70]|0,0,t),o=n[61]|0,u=n[69]|0,B=l[395]|0,l[395]=B+1<<16>>16,n[u+((B&65535)<<2)>>2]=o,f<<16>>16){case 39:{L(39);break}case 34:{L(34);break}default:{n[70]=(n[70]|0)+-2;break e}}switch(t=(n[70]|0)+2|0,n[70]=t,(E(1)|0)<<16>>16){case 44:{n[70]=(n[70]|0)+2,E(1)|0,B=n[61]|0,n[B+4>>2]=t,f=n[70]|0,n[B+16>>2]=f,g[B+24>>0]=1,n[70]=f+-2;break e}case 41:{l[396]=(l[396]|0)+-1<<16>>16,f=n[61]|0,n[f+4>>2]=t,n[f+12>>2]=(n[70]|0)+2,g[f+24>>0]=1,l[395]=(l[395]|0)+-1<<16>>16;break e}default:{n[70]=(n[70]|0)+-2;break e}}}break}case 46:{if(n[70]=(n[70]|0)+2,(E(1)|0)<<16>>16==109&&(o=n[70]|0,(J(o+2|0,44,6)|0)==0)){if(t=n[67]|0,!(ve(t)|0)&&(l[t>>1]|0)==46)break e;Qe(B,B,o+8|0,2)}break}case 42:case 39:case 34:{h=18;break}case 123:{if(t=n[70]|0,l[396]|0){n[70]=t+-2;break e}for(;!(t>>>0>=(n[71]|0)>>>0);){if(t=E(1)|0,P(t)|0)L(t);else if(t<<16>>16==125){h=33;break}t=(n[70]|0)+2|0,n[70]=t}if((h|0)==33&&(n[70]=(n[70]|0)+2),f=(E(1)|0)<<16>>16==102,t=n[70]|0,f&&J(t+2|0,50,6)|0){R();break e}if(n[70]=t+8,t=E(1)|0,P(t)|0){le(B,t);break e}else{R();break e}}default:(n[70]|0)==(t|0)?n[70]=B+10:h=18}while(0);do if((h|0)==18){if(l[396]|0){n[70]=(n[70]|0)+-2;break}for(t=n[71]|0,o=n[70]|0;;){if(o>>>0>=t>>>0){h=25;break}if(u=l[o>>1]|0,P(u)|0){h=23;break}f=o+2|0,n[70]=f,o=f}if((h|0)==23){le(B,u);break}else if((h|0)==25){R();break}}while(0)}function le(t,o){t=t|0,o=o|0;var u=0,h=0;switch(u=(n[70]|0)+2|0,o<<16>>16){case 39:{L(39),h=5;break}case 34:{L(34),h=5;break}default:R()}do if((h|0)==5){if(Qe(t,u,n[70]|0,1),n[70]=(n[70]|0)+2,o=E(0)|0,t=o<<16>>16==97,t?(u=n[70]|0,J(u+2|0,78,10)|0&&(h=11)):(u=n[70]|0,o<<16>>16==119&&(l[u+2>>1]|0)==105&&(l[u+4>>1]|0)==116&&(l[u+6>>1]|0)==104||(h=11)),(h|0)==11){n[70]=u+-2;break}if(n[70]=u+((t?6:4)<<1),(E(1)|0)<<16>>16!=123){n[70]=u;break}t=n[70]|0,o=t;e:for(;;){switch(n[70]=o+2,o=E(1)|0,o<<16>>16){case 39:{L(39),n[70]=(n[70]|0)+2,o=E(1)|0;break}case 34:{L(34),n[70]=(n[70]|0)+2,o=E(1)|0;break}default:o=F(o)|0}if(o<<16>>16!=58){h=20;break}switch(n[70]=(n[70]|0)+2,(E(1)|0)<<16>>16){case 39:{L(39);break}case 34:{L(34);break}default:{h=24;break e}}switch(n[70]=(n[70]|0)+2,(E(1)|0)<<16>>16){case 125:{h=29;break e}case 44:break;default:{h=28;break e}}if(n[70]=(n[70]|0)+2,(E(1)|0)<<16>>16==125){h=29;break}o=n[70]|0}if((h|0)==20){n[70]=u;break}else if((h|0)==24){n[70]=u;break}else if((h|0)==28){n[70]=u;break}else if((h|0)==29){h=n[61]|0,n[h+16>>2]=t,n[h+12>>2]=(n[70]|0)+2;break}}while(0)}function mt(t){t=t|0;e:do switch(l[t>>1]|0){case 100:switch(l[t+-2>>1]|0){case 105:{t=S(t+-4|0,88,2)|0;break e}case 108:{t=S(t+-4|0,92,3)|0;break e}default:{t=0;break e}}case 101:switch(l[t+-2>>1]|0){case 115:switch(l[t+-4>>1]|0){case 108:{t=H(t+-6|0,101)|0;break e}case 97:{t=H(t+-6|0,99)|0;break e}default:{t=0;break e}}case 116:{t=S(t+-4|0,98,4)|0;break e}case 117:{t=S(t+-4|0,106,6)|0;break e}default:{t=0;break e}}case 102:{if((l[t+-2>>1]|0)==111&&(l[t+-4>>1]|0)==101)switch(l[t+-6>>1]|0){case 99:{t=S(t+-8|0,118,6)|0;break e}case 112:{t=S(t+-8|0,130,2)|0;break e}default:{t=0;break e}}else t=0;break}case 107:{t=S(t+-2|0,134,4)|0;break}case 110:{t=t+-2|0,H(t,105)|0?t=1:t=S(t,142,5)|0;break}case 111:{t=H(t+-2|0,100)|0;break}case 114:{t=S(t+-2|0,152,7)|0;break}case 116:{t=S(t+-2|0,166,4)|0;break}case 119:switch(l[t+-2>>1]|0){case 101:{t=H(t+-4|0,110)|0;break e}case 111:{t=S(t+-4|0,174,3)|0;break e}default:{t=0;break e}}default:t=0}while(0);return t|0}function Je(){var t=0,o=0,u=0,h=0;o=n[71]|0,u=n[70]|0;e:for(;;){if(t=u+2|0,u>>>0>=o>>>0){o=10;break}switch(l[t>>1]|0){case 96:{o=7;break e}case 36:{if((l[u+4>>1]|0)==123){o=6;break e}break}case 92:{t=u+4|0;break}default:}u=t}(o|0)==6?(t=u+4|0,n[70]=t,o=n[68]|0,h=l[396]|0,u=h&65535,n[o+(u<<3)>>2]=4,l[396]=h+1<<16>>16,n[o+(u<<3)+4>>2]=t):(o|0)==7?(n[70]=t,u=n[68]|0,h=(l[396]|0)+-1<<16>>16,l[396]=h,(n[u+((h&65535)<<3)>>2]|0)!=3&&R()):(o|0)==10&&(n[70]=t,R())}function E(t){t=t|0;var o=0,u=0,h=0;u=n[70]|0;e:do{o=l[u>>1]|0;A:do if(o<<16>>16!=47)if(t){if(X(o)|0)break;break e}else{if(Ae(o)|0)break;break e}else switch(l[u+2>>1]|0){case 47:{he();break A}case 42:{fe(t);break A}default:{o=47;break e}}while(0);h=n[70]|0,u=h+2|0,n[70]=u}while(h>>>0<(n[71]|0)>>>0);return o|0}function L(t){t=t|0;var o=0,u=0,h=0,B=0;for(B=n[71]|0,o=n[70]|0;;){if(h=o+2|0,o>>>0>=B>>>0){o=9;break}if(u=l[h>>1]|0,u<<16>>16==t<<16>>16){o=10;break}if(u<<16>>16==92)u=o+4|0,(l[u>>1]|0)==13?(o=o+6|0,o=(l[o>>1]|0)==10?o:u):o=u;else if(Fe(u)|0){o=9;break}else o=h}(o|0)==9?(n[70]=h,R()):(o|0)==10&&(n[70]=h)}function Ne(t,o){t=t|0,o=o|0;var u=0,h=0,B=0,f=0;return u=n[70]|0,h=l[u>>1]|0,f=(t|0)==(o|0),B=f?0:t,f=f?0:o,h<<16>>16==97&&(n[70]=u+4,u=E(1)|0,t=n[70]|0,P(u)|0?(L(u),o=(n[70]|0)+2|0,n[70]=o):(F(u)|0,o=n[70]|0),h=E(1)|0,u=n[70]|0),(u|0)!=(t|0)&&Y(t,o,B,f),h|0}function Qe(t,o,u,h){t=t|0,o=o|0,u=u|0,h=h|0;var B=0,f=0;B=n[65]|0,n[65]=B+32,f=n[61]|0,n[(f|0?f+28|0:228)>>2]=B,n[62]=f,n[61]=B,n[B+8>>2]=t,(h|0)==2?t=u:t=(h|0)==1?u+2|0:0,n[B+12>>2]=t,n[B>>2]=o,n[B+4>>2]=u,n[B+16>>2]=0,n[B+20>>2]=h,g[B+24>>0]=(h|0)==1&1,n[B+28>>2]=0}function Dt(){var t=0,o=0,u=0;u=n[71]|0,o=n[70]|0;e:for(;;){if(t=o+2|0,o>>>0>=u>>>0){o=6;break}switch(l[t>>1]|0){case 13:case 10:{o=6;break e}case 93:{o=7;break e}case 92:{t=o+4|0;break}default:}o=t}return(o|0)==6?(n[70]=t,R(),t=0):(o|0)==7&&(n[70]=t,t=93),t|0}function Le(){var t=0,o=0,u=0;e:for(;;){if(t=n[70]|0,o=t+2|0,n[70]=o,t>>>0>=(n[71]|0)>>>0){u=7;break}switch(l[o>>1]|0){case 13:case 10:{u=7;break e}case 47:break e;case 91:{Dt()|0;break}case 92:{n[70]=t+4;break}default:}}(u|0)==7&&R()}function Kt(t){switch(t=t|0,l[t>>1]|0){case 62:{t=(l[t+-2>>1]|0)==61;break}case 41:case 59:{t=1;break}case 104:{t=S(t+-2|0,200,4)|0;break}case 121:{t=S(t+-2|0,208,6)|0;break}case 101:{t=S(t+-2|0,220,3)|0;break}default:t=0}return t|0}function fe(t){t=t|0;var o=0,u=0,h=0,B=0,f=0;for(B=(n[70]|0)+2|0,n[70]=B,u=n[71]|0;o=B+2|0,!(B>>>0>=u>>>0||(h=l[o>>1]|0,!t&&Fe(h)|0));){if(h<<16>>16==42&&(l[B+4>>1]|0)==47){f=8;break}B=o}(f|0)==8&&(n[70]=o,o=B+4|0),n[70]=o}function J(t,o,u){t=t|0,o=o|0,u=u|0;var h=0,B=0;e:do if(!u)t=0;else{for(;h=g[t>>0]|0,B=g[o>>0]|0,h<<24>>24==B<<24>>24;)if(u=u+-1|0,u)t=t+1|0,o=o+1|0;else{t=0;break e}t=(h&255)-(B&255)|0}while(0);return t|0}function te(t){t=t|0;e:do switch(t<<16>>16){case 38:case 37:case 33:{t=1;break}default:if((t&-8)<<16>>16==40|(t+-58&65535)<6)t=1;else{switch(t<<16>>16){case 91:case 93:case 94:{t=1;break e}default:}t=(t+-123&65535)<4}}while(0);return t|0}function yt(t){t=t|0;e:do switch(t<<16>>16){case 38:case 37:case 33:break;default:if(!((t+-58&65535)<6|(t+-40&65535)<7&t<<16>>16!=41)){switch(t<<16>>16){case 91:case 94:break e;default:}return t<<16>>16!=125&(t+-123&65535)<4|0}}while(0);return 1}function Re(t){t=t|0;var o=0;o=l[t>>1]|0;e:do if((o+-9&65535)>=5){switch(o<<16>>16){case 160:case 32:{o=1;break e}default:}if(te(o)|0)return o<<16>>16!=46|(ve(t)|0)|0;o=0}else o=1;while(0);return o|0}function St(t){t=t|0;var o=0,u=0,h=0,B=0;return u=k,k=k+16|0,h=u,n[h>>2]=0,n[64]=t,o=n[3]|0,B=o+(t<<1)|0,t=B+2|0,l[B>>1]=0,n[h>>2]=t,n[65]=t,n[57]=0,n[61]=0,n[59]=0,n[58]=0,n[63]=0,n[60]=0,k=u,o|0}function S(t,o,u){t=t|0,o=o|0,u=u|0;var h=0,B=0;return h=t+(0-u<<1)|0,B=h+2|0,t=n[3]|0,B>>>0>=t>>>0&&!(J(B,o,u<<1)|0)?(B|0)==(t|0)?t=1:t=Re(h)|0:t=0,t|0}function Y(t,o,u,h){t=t|0,o=o|0,u=u|0,h=h|0;var B=0,f=0;B=n[65]|0,n[65]=B+20,f=n[63]|0,n[(f|0?f+16|0:232)>>2]=B,n[63]=B,n[B>>2]=t,n[B+4>>2]=o,n[B+8>>2]=u,n[B+12>>2]=h,n[B+16>>2]=0}function Jt(t){switch(t=t|0,l[t>>1]|0){case 107:{t=S(t+-2|0,134,4)|0;break}case 101:{(l[t+-2>>1]|0)==117?t=S(t+-4|0,106,6)|0:t=0;break}default:t=0}return t|0}function H(t,o){t=t|0,o=o|0;var u=0;return u=n[3]|0,u>>>0<=t>>>0&&(l[t>>1]|0)==o<<16>>16?(u|0)==(t|0)?u=1:u=ge(l[t+-2>>1]|0)|0:u=0,u|0}function ge(t){t=t|0;e:do if((t+-9&65535)<5)t=1;else{switch(t<<16>>16){case 32:case 160:{t=1;break e}default:}t=t<<16>>16!=46&(te(t)|0)}while(0);return t|0}function he(){var t=0,o=0,u=0;t=n[71]|0,u=n[70]|0;e:for(;o=u+2|0,!(u>>>0>=t>>>0);)switch(l[o>>1]|0){case 13:case 10:break e;default:u=o}n[70]=o}function F(t){for(t=t|0;!(X(t)|0||te(t)|0);)if(t=(n[70]|0)+2|0,n[70]=t,t=l[t>>1]|0,!(t<<16>>16)){t=0;break}return t|0}function Nt(){var t=0;switch(t=n[(n[59]|0)+20>>2]|0,t|0){case 1:{t=-1;break}case 2:{t=-2;break}default:t=t-(n[3]|0)>>1}return t|0}function Lt(t){return t=t|0,!(S(t,180,5)|0)&&!(S(t,190,3)|0)?t=S(t,196,2)|0:t=1,t|0}function Ae(t){switch(t=t|0,t<<16>>16){case 160:case 32:case 12:case 11:case 9:{t=1;break}default:t=0}return t|0}function ve(t){return t=t|0,(l[t>>1]|0)==46&&(l[t+-2>>1]|0)==46?t=(l[t+-4>>1]|0)==46:t=0,t|0}function j(t){return t=t|0,(n[3]|0)==(t|0)?t=1:t=Re(t+-2|0)|0,t|0}function Rt(){var t=0;return t=n[(n[60]|0)+12>>2]|0,t?t=t-(n[3]|0)>>1:t=-1,t|0}function vt(){var t=0;return t=n[(n[59]|0)+12>>2]|0,t?t=t-(n[3]|0)>>1:t=-1,t|0}function Ft(){var t=0;return t=n[(n[60]|0)+8>>2]|0,t?t=t-(n[3]|0)>>1:t=-1,t|0}function xt(){var t=0;return t=n[(n[59]|0)+16>>2]|0,t?t=t-(n[3]|0)>>1:t=-1,t|0}function Ut(){var t=0;return t=n[(n[59]|0)+4>>2]|0,t?t=t-(n[3]|0)>>1:t=-1,t|0}function qt(){var t=0;return t=n[59]|0,t=n[(t|0?t+28|0:228)>>2]|0,n[59]=t,(t|0)!=0|0}function Mt(){var t=0;return t=n[60]|0,t=n[(t|0?t+16|0:232)>>2]|0,n[60]=t,(t|0)!=0|0}function R(){g[794]=1,n[66]=(n[70]|0)-(n[3]|0)>>1,n[70]=(n[71]|0)+2}function X(t){return t=t|0,(t|128)<<16>>16==160|(t+-9&65535)<5|0}function P(t){return t=t|0,t<<16>>16==39|t<<16>>16==34|0}function Gt(){return(n[(n[59]|0)+8>>2]|0)-(n[3]|0)>>1|0}function Yt(){return(n[(n[60]|0)+4>>2]|0)-(n[3]|0)>>1|0}function Fe(t){return t=t|0,t<<16>>16==13|t<<16>>16==10|0}function _t(){return(n[n[59]>>2]|0)-(n[3]|0)>>1|0}function Ot(){return(n[n[60]>>2]|0)-(n[3]|0)>>1|0}function Ht(){return p[(n[59]|0)+24>>0]|0|0}function jt(t){t=t|0,n[3]=t}function Xt(){return(g[795]|0)!=0|0}function Pt(){return n[66]|0}function Tt(t){return t=t|0,k=t+992+15&-16,992}return{su:Tt,ai:xt,e:Pt,ee:Yt,ele:Rt,els:Ft,es:Ot,f:Xt,id:Nt,ie:Ut,ip:Ht,is:_t,p:N,re:Mt,ri:qt,sa:St,se:vt,ses:jt,ss:Gt}}(typeof self<"u"?self:global,{},re),pe=D.su(V-(2<<17))}const r=b.length+1;D.ses(pe),D.sa(r-1),Te(b,new Uint16Array(re,pe,r)),D.p()||(d=D.e(),U());const s=[],a=[];for(;D.ri();){const c=D.is(),C=D.ie(),Q=D.ai(),g=D.id(),l=D.ss(),n=D.se();let p;D.ip()&&(p=be(g===-1?c:c+1,b.charCodeAt(g===-1?c-1:c))),s.push({n:p,s:c,e:C,ss:l,se:n,d:g,a:Q})}for(;D.re();){const c=D.es(),C=D.ee(),Q=D.els(),g=D.ele(),l=b.charCodeAt(c),n=Q>=0?b.charCodeAt(Q):-1;a.push({s:c,e:C,ls:Q,le:g,n:l===34||l===39?be(c+1,l):b.slice(c,C),ln:Q<0?void 0:n===34||n===39?be(Q+1,n):b.slice(Q,g)})}return[s,a,!!D.f()]}function be(i,e){d=i;let A="",r=d;for(;;){d>=b.length&&U();const s=b.charCodeAt(d);if(s===e)break;s===92?(A+=b.slice(r,d),A+=mA(),r=d):(s===8232||s===8233||Ze(s)&&U(),++d)}return A+=b.slice(r,d++),A}function mA(){let i=b.charCodeAt(++d);switch(++d,i){case 110:return`
|
| 12 |
+
`;case 114:return"\r";case 120:return String.fromCharCode(me(2));case 117:return function(){const e=b.charCodeAt(d);let A;return e===123?(++d,A=me(b.indexOf("}",d)-d),++d,A>1114111&&U()):A=me(4),A<=65535?String.fromCharCode(A):(A-=65536,String.fromCharCode(55296+(A>>10),56320+(1023&A)))}();case 116:return" ";case 98:return"\b";case 118:return"\v";case 102:return"\f";case 13:b.charCodeAt(d)===10&&++d;case 10:return"";case 56:case 57:U();default:if(i>=48&&i<=55){let e=b.substr(d-1,3).match(/^[0-7]+/)[0],A=parseInt(e,8);return A>255&&(e=e.slice(0,-1),A=parseInt(e,8)),d+=e.length-1,i=b.charCodeAt(d),e==="0"&&i!==56&&i!==57||U(),String.fromCharCode(A)}return Ze(i)?"":String.fromCharCode(i)}}function me(i){const e=d;let A=0,r=0;for(let s=0;s<i;++s,++d){let a,c=b.charCodeAt(d);if(c!==95){if(c>=97)a=c-97+10;else if(c>=65)a=c-65+10;else{if(!(c>=48&&c<=57))break;a=c-48}if(a>=16)break;r=c,A=16*A+a}else r!==95&&s!==0||U(),r=c}return r!==95&&d-e===i||U(),A}function Ze(i){return i===13||i===10}function U(){throw Object.assign(Error(`Parse error ${$e}:${b.slice(0,d).split(`
|
| 13 |
+
`).length}:${d-b.lastIndexOf(`
|
| 14 |
+
`,d-1)}`),{idx:d})}let We=!1;Pe.then(()=>{We=!0});const DA=i=>We?Xe(i):bA(i),KA=`.then((mod)=>{
|
| 15 |
+
const exports = Object.keys(mod);
|
| 16 |
+
if(
|
| 17 |
+
exports.length===1&&exports[0]==='default'&&mod.default&&mod.default.__esModule
|
| 18 |
+
){
|
| 19 |
+
return mod.default
|
| 20 |
+
}
|
| 21 |
+
return mod
|
| 22 |
+
})`.replace(/[\n\t]+/g,"");function De(i,e){if(!e.includes("import"))return;const A=DA(e)[0].filter(s=>s.d>-1);if(A.length===0)return;const r=new Se(e);for(const s of A)r.appendRight(s.se,KA);return{code:r.toString(),map:r.generateMap({source:i,hires:!0})}}function yA(i){try{const e=_.default.readFileSync(i,"utf8");return JSON.parse(e)}catch{}}const Ve=()=>Math.floor(Date.now()/1e8);class SA extends Map{cacheDirectory=G.default.join(nA.default.tmpdir(),"esbuild-kit");cacheFiles;constructor(){super(),_.default.mkdirSync(this.cacheDirectory,{recursive:!0}),this.cacheFiles=_.default.readdirSync(this.cacheDirectory).map(e=>{const[A,r]=e.split("-");return{time:Number(A),key:r,fileName:e}}),setImmediate(()=>this.expireDiskCache())}get(e){const A=super.get(e);if(A)return A;const r=this.cacheFiles.find(c=>c.key===e);if(!r)return;const s=G.default.join(this.cacheDirectory,r.fileName),a=yA(s);if(!a){_.default.promises.unlink(s).then(()=>{const c=this.cacheFiles.indexOf(r);this.cacheFiles.splice(c,1)},()=>{});return}return super.set(e,a),a}set(e,A){if(super.set(e,A),A){const r=Ve();_.default.promises.writeFile(G.default.join(this.cacheDirectory,`${r}-${e}`),JSON.stringify(A)).catch(()=>{})}return this}expireDiskCache(){const e=Ve();for(const A of this.cacheFiles)e-A.time>7&&_.default.promises.unlink(G.default.join(this.cacheDirectory,A.fileName)).catch(()=>{})}}var ie=process.env.ESBK_DISABLE_CACHE?new Map:new SA;const JA=/^[\w+.-]+:\/\//,NA=/^([\w+.-]+:)\/\/([^@/#?]*@)?([^:/#?]*)(:\d+)?(\/[^#?]*)?(\?[^#]*)?(#.*)?/,LA=/^file:(?:\/\/((?![a-z]:)[^/#?]*)?)?(\/?[^#?]*)(\?[^#]*)?(#.*)?/i;var K;(function(i){i[i.Empty=1]="Empty",i[i.Hash=2]="Hash",i[i.Query=3]="Query",i[i.RelativePath=4]="RelativePath",i[i.AbsolutePath=5]="AbsolutePath",i[i.SchemeRelative=6]="SchemeRelative",i[i.Absolute=7]="Absolute"})(K||(K={}));function RA(i){return JA.test(i)}function vA(i){return i.startsWith("//")}function ze(i){return i.startsWith("/")}function FA(i){return i.startsWith("file:")}function et(i){return/^[.?#]/.test(i)}function se(i){const e=NA.exec(i);return tt(e[1],e[2]||"",e[3],e[4]||"",e[5]||"/",e[6]||"",e[7]||"")}function xA(i){const e=LA.exec(i),A=e[2];return tt("file:","",e[1]||"","",ze(A)?A:"/"+A,e[3]||"",e[4]||"")}function tt(i,e,A,r,s,a,c){return{scheme:i,user:e,host:A,port:r,path:s,query:a,hash:c,type:K.Absolute}}function At(i){if(vA(i)){const A=se("http:"+i);return A.scheme="",A.type=K.SchemeRelative,A}if(ze(i)){const A=se("http://foo.com"+i);return A.scheme="",A.host="",A.type=K.AbsolutePath,A}if(FA(i))return xA(i);if(RA(i))return se(i);const e=se("http://foo.com/"+i);return e.scheme="",e.host="",e.type=i?i.startsWith("?")?K.Query:i.startsWith("#")?K.Hash:K.RelativePath:K.Empty,e}function UA(i){if(i.endsWith("/.."))return i;const e=i.lastIndexOf("/");return i.slice(0,e+1)}function qA(i,e){nt(e,e.type),i.path==="/"?i.path=e.path:i.path=UA(e.path)+i.path}function nt(i,e){const A=e<=K.RelativePath,r=i.path.split("/");let s=1,a=0,c=!1;for(let Q=1;Q<r.length;Q++){const g=r[Q];if(!g){c=!0;continue}if(c=!1,g!=="."){if(g===".."){a?(c=!0,a--,s--):A&&(r[s++]=g);continue}r[s++]=g,a++}}let C="";for(let Q=1;Q<s;Q++)C+="/"+r[Q];(!C||c&&!C.endsWith("/.."))&&(C+="/"),i.path=C}function MA(i,e){if(!i&&!e)return"";const A=At(i);let r=A.type;if(e&&r!==K.Absolute){const a=At(e),c=a.type;switch(r){case K.Empty:A.hash=a.hash;case K.Hash:A.query=a.query;case K.Query:case K.RelativePath:qA(A,a);case K.AbsolutePath:A.user=a.user,A.host=a.host,A.port=a.port;case K.SchemeRelative:A.scheme=a.scheme}c>r&&(r=c)}nt(A,r);const s=A.query+A.hash;switch(r){case K.Hash:case K.Query:return s;case K.RelativePath:{const a=A.path.slice(1);return a?et(e||i)&&!et(a)?"./"+a+s:a+s:s||"."}case K.AbsolutePath:return A.path+s;default:return A.scheme+"//"+A.user+A.host+A.port+A.path+s}}function rt(i,e){return e&&!e.endsWith("/")&&(e+="/"),MA(i,e)}function GA(i){if(!i)return"";const e=i.lastIndexOf("/");return i.slice(0,e+1)}const q=0;function YA(i,e){const A=it(i,0);if(A===i.length)return i;e||(i=i.slice());for(let r=A;r<i.length;r=it(i,r+1))i[r]=OA(i[r],e);return i}function it(i,e){for(let A=e;A<i.length;A++)if(!_A(i[A]))return A;return i.length}function _A(i){for(let e=1;e<i.length;e++)if(i[e][q]<i[e-1][q])return!1;return!0}function OA(i,e){return e||(i=i.slice()),i.sort(HA)}function HA(i,e){return i[q]-e[q]}let oe=!1;function jA(i,e,A,r){for(;A<=r;){const s=A+(r-A>>1),a=i[s][q]-e;if(a===0)return oe=!0,s;a<0?A=s+1:r=s-1}return oe=!1,A-1}function XA(i,e,A){for(let r=A+1;r<i.length&&i[r][q]===e;A=r++);return A}function PA(i,e,A){for(let r=A-1;r>=0&&i[r][q]===e;A=r--);return A}function TA(){return{lastKey:-1,lastNeedle:-1,lastIndex:-1}}function $A(i,e,A,r){const{lastKey:s,lastNeedle:a,lastIndex:c}=A;let C=0,Q=i.length-1;if(r===s){if(e===a)return oe=c!==-1&&i[c][q]===e,c;e>=a?C=c===-1?0:c:Q=c}return A.lastKey=r,A.lastNeedle=e,A.lastIndex=jA(i,e,C,Q)}const st=-1,ZA=1;let Ke,ot;class at{constructor(e,A){const r=typeof e=="string";if(!r&&e._decodedMemo)return e;const s=r?JSON.parse(e):e,{version:a,file:c,names:C,sourceRoot:Q,sources:g,sourcesContent:l}=s;this.version=a,this.file=c,this.names=C,this.sourceRoot=Q,this.sources=g,this.sourcesContent=l;const n=rt(Q||"",GA(A));this.resolvedSources=g.map(y=>rt(y||"",n));const{mappings:p}=s;typeof p=="string"?(this._encoded=p,this._decoded=void 0):(this._encoded=void 0,this._decoded=YA(p,r)),this._decodedMemo=TA(),this._bySources=void 0,this._bySourceMemos=void 0}}Ke=i=>i._decoded||(i._decoded=oA(i._encoded)),ot=(i,e,A)=>{const r=Ke(i);if(e>=r.length)return null;const s=r[e],a=WA(s,i._decodedMemo,e,A,ZA);return a===-1?null:s[a]};function WA(i,e,A,r,s){let a=$A(i,r,e,A);return oe?a=(s===st?XA:PA)(i,r,a):s===st&&a++,a===-1||a===i.length?-1:a}let ct,ae;class ut{constructor(){this._indexes={__proto__:null},this.array=[]}}ct=(i,e)=>i._indexes[e],ae=(i,e)=>{const A=ct(i,e);if(A!==void 0)return A;const{array:r,_indexes:s}=i;return s[e]=r.push(e)-1};const VA=0,zA=1,en=2,tn=3,An=4,lt=-1;let Qt,ft,ye,gt,ht;class nn{constructor({file:e,sourceRoot:A}={}){this._names=new ut,this._sources=new ut,this._sourcesContent=[],this._mappings=[],this.file=e,this.sourceRoot=A}}Qt=(i,e,A,r,s,a,c,C)=>ht(!0,i,e,A,r,s,a,c,C),ft=(i,e,A)=>{const{_sources:r,_sourcesContent:s}=i;s[ae(r,e)]=A},ye=i=>{const{file:e,sourceRoot:A,_mappings:r,_sources:s,_sourcesContent:a,_names:c}=i;return on(r),{version:3,file:e||void 0,names:c.array,sourceRoot:A||void 0,sources:s.array,sourcesContent:a,mappings:r}},gt=i=>{const e=ye(i);return Object.assign(Object.assign({},e),{mappings:He(e.mappings)})},ht=(i,e,A,r,s,a,c,C,Q)=>{const{_mappings:g,_sources:l,_sourcesContent:n,_names:p}=e,y=rn(g,A),k=sn(y,r);if(!s)return i&&an(y,k)?void 0:Ct(y,k,[r]);const N=ae(l,s),v=C?ae(p,C):lt;if(N===n.length&&(n[N]=Q!=null?Q:null),!(i&&cn(y,k,N,a,c,v)))return Ct(y,k,C?[r,N,a,c,v]:[r,N,a,c])};function rn(i,e){for(let A=i.length;A<=e;A++)i[A]=[];return i[e]}function sn(i,e){let A=i.length;for(let r=A-1;r>=0;A=r--){const s=i[r];if(e>=s[VA])break}return A}function Ct(i,e,A){for(let r=i.length;r>e;r--)i[r]=i[r-1];i[e]=A}function on(i){const{length:e}=i;let A=e;for(let r=A-1;r>=0&&!(i[r].length>0);A=r,r--);A<e&&(i.length=A)}function an(i,e){return e===0?!0:i[e-1].length===1}function cn(i,e,A,r,s,a){if(e===0)return!1;const c=i[e-1];return c.length===1?!1:A===c[zA]&&r===c[en]&&s===c[tn]&&a===(c.length===5?c[An]:lt)}const Bt=Et("",-1,-1,"",null),un=[];function Et(i,e,A,r,s){return{source:i,line:e,column:A,name:r,content:s}}function dt(i,e,A,r){return{map:i,sources:e,source:A,content:r}}function wt(i,e){return dt(i,e,"",null)}function ln(i,e){return dt(null,un,i,e)}function Qn(i){const e=new nn({file:i.map.file}),{sources:A,map:r}=i,s=r.names,a=Ke(r);for(let c=0;c<a.length;c++){const C=a[c];for(let Q=0;Q<C.length;Q++){const g=C[Q],l=g[0];let n=Bt;if(g.length!==1){const ee=A[g[1]];if(n=kt(ee,g[2],g[3],g.length===5?s[g[4]]:""),n==null)continue}const{column:p,line:y,name:k,content:N,source:v}=n;Qt(e,c,l,v,y,p,k),v&&N!=null&&ft(e,v,N)}}return e}function kt(i,e,A,r){if(!i.map)return Et(i.source,e,A,r,i.content);const s=ot(i.map,e,A);return s==null?null:s.length===1?Bt:kt(i.sources[s[1]],s[2],s[3],s.length===5?i.map.names[s[4]]:r)}function fn(i){return Array.isArray(i)?i:[i]}function gn(i,e){const A=fn(i).map(a=>new at(a,"")),r=A.pop();for(let a=0;a<A.length;a++)if(A[a].sources.length>1)throw new Error(`Transformation map ${a} must have exactly one source file.
|
| 23 |
+
Did you specify these with the most recent transformation maps first?`);let s=It(r,e,"",0);for(let a=A.length-1;a>=0;a--)s=wt(A[a],[s]);return s}function It(i,e,A,r){const{resolvedSources:s,sourcesContent:a}=i,c=r+1,C=s.map((Q,g)=>{const l={importer:A,depth:c,source:Q||"",content:void 0},n=e(l.source,l),{source:p,content:y}=l;if(n)return It(new at(n,p),e,p,c);const k=y!==void 0?y:a?a[g]:null;return ln(p,k)});return wt(i,C)}class hn{constructor(e,A){const r=A.decodedMappings?ye(e):gt(e);this.version=r.version,this.file=r.file,this.mappings=r.mappings,this.names=r.names,this.sourceRoot=r.sourceRoot,this.sources=r.sources,A.excludeContent||(this.sourcesContent=r.sourcesContent)}toString(){return JSON.stringify(this)}}function pt(i,e,A){const r=typeof A=="object"?A:{excludeContent:!!A,decodedMappings:!1},s=gn(i,e);return new hn(Qn(s),r)}function Cn(i,e,A){const r=[],s=[],a={code:e};for(const c of A){const C=c(i,a.code);C&&(Object.assign(a,C),r.unshift(C.map),C.warnings&&s.push(...C.warnings))}return{...a,map:pt(r,()=>null),warnings:s}}async function Bn(i,e,A){const r=[],s=[],a={code:e};for(const c of A){const C=await c(i,a.code);C&&(Object.assign(a,C),r.unshift(C.map),C.warnings&&s.push(...C.warnings))}return{...a,map:pt(r,()=>null),warnings:s}}const En=process.versions.node,bt=i=>{const e={target:`node${En}`,loader:"default",sourcemap:!0,minifyWhitespace:!0,keepNames:!0,...i};if(e.sourcefile){const{sourcefile:A}=e,r=G.default.extname(A);r?(r===".cts"||r===".mts")&&(e.sourcefile=`${A.slice(0,-3)}ts`):e.sourcefile+=".js"}return e};function dn(i,e,A){const r={};e.endsWith(".cjs")||e.endsWith(".cts")||(r["import.meta.url"]=`'${Zt.pathToFileURL(e)}'`);const s=bt({format:"cjs",sourcefile:e,define:r,banner:"(()=>{",footer:"})()",...A}),a=qe(i+JSON.stringify(s)+ne.version);let c=ie.get(a);if(c||(c=Cn(e,i,[(C,Q)=>{const g=ne.transformSync(Q,s);return s.sourcefile!==C&&(g.map=g.map.replace(JSON.stringify(s.sourcefile),JSON.stringify(C))),g},De]),ie.set(a,c)),c.warnings&&c.warnings.length>0){const{warnings:C}=c;for(const Q of C)console.log(Q)}return c}async function wn(i,e,A){const r=bt({format:"esm",sourcefile:e,...A}),s=qe(i+JSON.stringify(r)+ne.version);let a=ie.get(s);if(a||(a=await Bn(e,i,[async(c,C)=>{const Q=await ne.transform(C,r);return r.sourcefile!==c&&(Q.map=Q.map.replace(JSON.stringify(r.sourcefile),JSON.stringify(c))),Q},De]),ie.set(s,a)),a.warnings&&a.warnings.length>0){const{warnings:c}=a;for(const C of c)console.log(C)}return a}const ce=Object.create(null);ce[".js"]=".ts",ce[".cjs"]=".cts",ce[".mjs"]=".mts";const kn=i=>{const e=G.default.extname(i),[A,r]=G.default.extname(i).split("?"),s=ce[A];if(s)return i.slice(0,-e.length)+s+(r?`?${r}`:"")};exports.compareNodeVersion=xe,exports.installSourceMapSupport=iA,exports.resolveTsPath=kn,exports.transform=wn,exports.transformDynamicImport=De,exports.transformSync=dn;
|
e-commerce/node_modules/@esbuild-kit/core-utils/node_modules/.bin/esbuild
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:82afa0d18098bef823ba5b5c89bb5cfbea1a25f0721416d29a9dd7ba73fd237d
|
| 3 |
+
size 9347072
|
e-commerce/node_modules/@esbuild-kit/core-utils/node_modules/@esbuild/linux-x64/README.md
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# esbuild
|
| 2 |
+
|
| 3 |
+
This is the Linux 64-bit binary for esbuild, a JavaScript bundler and minifier. See https://github.com/evanw/esbuild for details.
|
e-commerce/node_modules/@esbuild-kit/core-utils/node_modules/@esbuild/linux-x64/bin/esbuild
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:82afa0d18098bef823ba5b5c89bb5cfbea1a25f0721416d29a9dd7ba73fd237d
|
| 3 |
+
size 9347072
|
e-commerce/node_modules/@esbuild-kit/core-utils/node_modules/@esbuild/linux-x64/package.json
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "@esbuild/linux-x64",
|
| 3 |
+
"version": "0.18.20",
|
| 4 |
+
"description": "The Linux 64-bit binary for esbuild, a JavaScript bundler.",
|
| 5 |
+
"repository": "https://github.com/evanw/esbuild",
|
| 6 |
+
"license": "MIT",
|
| 7 |
+
"preferUnplugged": true,
|
| 8 |
+
"engines": {
|
| 9 |
+
"node": ">=12"
|
| 10 |
+
},
|
| 11 |
+
"os": [
|
| 12 |
+
"linux"
|
| 13 |
+
],
|
| 14 |
+
"cpu": [
|
| 15 |
+
"x64"
|
| 16 |
+
]
|
| 17 |
+
}
|
e-commerce/node_modules/@esbuild-kit/core-utils/node_modules/esbuild/LICENSE.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
MIT License
|
| 2 |
+
|
| 3 |
+
Copyright (c) 2020 Evan Wallace
|
| 4 |
+
|
| 5 |
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
| 6 |
+
of this software and associated documentation files (the "Software"), to deal
|
| 7 |
+
in the Software without restriction, including without limitation the rights
|
| 8 |
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
| 9 |
+
copies of the Software, and to permit persons to whom the Software is
|
| 10 |
+
furnished to do so, subject to the following conditions:
|
| 11 |
+
|
| 12 |
+
The above copyright notice and this permission notice shall be included in all
|
| 13 |
+
copies or substantial portions of the Software.
|
| 14 |
+
|
| 15 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
| 16 |
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
| 17 |
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
| 18 |
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
| 19 |
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
| 20 |
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
| 21 |
+
SOFTWARE.
|
e-commerce/node_modules/@esbuild-kit/core-utils/node_modules/esbuild/README.md
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# esbuild
|
| 2 |
+
|
| 3 |
+
This is a JavaScript bundler and minifier. See https://github.com/evanw/esbuild and the [JavaScript API documentation](https://esbuild.github.io/api/) for details.
|
e-commerce/node_modules/@esbuild-kit/core-utils/node_modules/esbuild/bin/esbuild
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:82afa0d18098bef823ba5b5c89bb5cfbea1a25f0721416d29a9dd7ba73fd237d
|
| 3 |
+
size 9347072
|
e-commerce/node_modules/@esbuild-kit/core-utils/node_modules/esbuild/install.js
ADDED
|
@@ -0,0 +1,287 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";
|
| 2 |
+
var __create = Object.create;
|
| 3 |
+
var __defProp = Object.defineProperty;
|
| 4 |
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
| 5 |
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
| 6 |
+
var __getProtoOf = Object.getPrototypeOf;
|
| 7 |
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
| 8 |
+
var __copyProps = (to, from, except, desc) => {
|
| 9 |
+
if (from && typeof from === "object" || typeof from === "function") {
|
| 10 |
+
for (let key of __getOwnPropNames(from))
|
| 11 |
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
| 12 |
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
| 13 |
+
}
|
| 14 |
+
return to;
|
| 15 |
+
};
|
| 16 |
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
| 17 |
+
// If the importer is in node compatibility mode or this is not an ESM
|
| 18 |
+
// file that has been converted to a CommonJS file using a Babel-
|
| 19 |
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
| 20 |
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
| 21 |
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
| 22 |
+
mod
|
| 23 |
+
));
|
| 24 |
+
|
| 25 |
+
// lib/npm/node-platform.ts
|
| 26 |
+
var fs = require("fs");
|
| 27 |
+
var os = require("os");
|
| 28 |
+
var path = require("path");
|
| 29 |
+
var ESBUILD_BINARY_PATH = process.env.ESBUILD_BINARY_PATH || ESBUILD_BINARY_PATH;
|
| 30 |
+
var isValidBinaryPath = (x) => !!x && x !== "/usr/bin/esbuild";
|
| 31 |
+
var knownWindowsPackages = {
|
| 32 |
+
"win32 arm64 LE": "@esbuild/win32-arm64",
|
| 33 |
+
"win32 ia32 LE": "@esbuild/win32-ia32",
|
| 34 |
+
"win32 x64 LE": "@esbuild/win32-x64"
|
| 35 |
+
};
|
| 36 |
+
var knownUnixlikePackages = {
|
| 37 |
+
"android arm64 LE": "@esbuild/android-arm64",
|
| 38 |
+
"darwin arm64 LE": "@esbuild/darwin-arm64",
|
| 39 |
+
"darwin x64 LE": "@esbuild/darwin-x64",
|
| 40 |
+
"freebsd arm64 LE": "@esbuild/freebsd-arm64",
|
| 41 |
+
"freebsd x64 LE": "@esbuild/freebsd-x64",
|
| 42 |
+
"linux arm LE": "@esbuild/linux-arm",
|
| 43 |
+
"linux arm64 LE": "@esbuild/linux-arm64",
|
| 44 |
+
"linux ia32 LE": "@esbuild/linux-ia32",
|
| 45 |
+
"linux mips64el LE": "@esbuild/linux-mips64el",
|
| 46 |
+
"linux ppc64 LE": "@esbuild/linux-ppc64",
|
| 47 |
+
"linux riscv64 LE": "@esbuild/linux-riscv64",
|
| 48 |
+
"linux s390x BE": "@esbuild/linux-s390x",
|
| 49 |
+
"linux x64 LE": "@esbuild/linux-x64",
|
| 50 |
+
"linux loong64 LE": "@esbuild/linux-loong64",
|
| 51 |
+
"netbsd x64 LE": "@esbuild/netbsd-x64",
|
| 52 |
+
"openbsd x64 LE": "@esbuild/openbsd-x64",
|
| 53 |
+
"sunos x64 LE": "@esbuild/sunos-x64"
|
| 54 |
+
};
|
| 55 |
+
var knownWebAssemblyFallbackPackages = {
|
| 56 |
+
"android arm LE": "@esbuild/android-arm",
|
| 57 |
+
"android x64 LE": "@esbuild/android-x64"
|
| 58 |
+
};
|
| 59 |
+
function pkgAndSubpathForCurrentPlatform() {
|
| 60 |
+
let pkg;
|
| 61 |
+
let subpath;
|
| 62 |
+
let isWASM = false;
|
| 63 |
+
let platformKey = `${process.platform} ${os.arch()} ${os.endianness()}`;
|
| 64 |
+
if (platformKey in knownWindowsPackages) {
|
| 65 |
+
pkg = knownWindowsPackages[platformKey];
|
| 66 |
+
subpath = "esbuild.exe";
|
| 67 |
+
} else if (platformKey in knownUnixlikePackages) {
|
| 68 |
+
pkg = knownUnixlikePackages[platformKey];
|
| 69 |
+
subpath = "bin/esbuild";
|
| 70 |
+
} else if (platformKey in knownWebAssemblyFallbackPackages) {
|
| 71 |
+
pkg = knownWebAssemblyFallbackPackages[platformKey];
|
| 72 |
+
subpath = "bin/esbuild";
|
| 73 |
+
isWASM = true;
|
| 74 |
+
} else {
|
| 75 |
+
throw new Error(`Unsupported platform: ${platformKey}`);
|
| 76 |
+
}
|
| 77 |
+
return { pkg, subpath, isWASM };
|
| 78 |
+
}
|
| 79 |
+
function downloadedBinPath(pkg, subpath) {
|
| 80 |
+
const esbuildLibDir = path.dirname(require.resolve("esbuild"));
|
| 81 |
+
return path.join(esbuildLibDir, `downloaded-${pkg.replace("/", "-")}-${path.basename(subpath)}`);
|
| 82 |
+
}
|
| 83 |
+
|
| 84 |
+
// lib/npm/node-install.ts
|
| 85 |
+
var fs2 = require("fs");
|
| 86 |
+
var os2 = require("os");
|
| 87 |
+
var path2 = require("path");
|
| 88 |
+
var zlib = require("zlib");
|
| 89 |
+
var https = require("https");
|
| 90 |
+
var child_process = require("child_process");
|
| 91 |
+
var versionFromPackageJSON = require(path2.join(__dirname, "package.json")).version;
|
| 92 |
+
var toPath = path2.join(__dirname, "bin", "esbuild");
|
| 93 |
+
var isToPathJS = true;
|
| 94 |
+
function validateBinaryVersion(...command) {
|
| 95 |
+
command.push("--version");
|
| 96 |
+
let stdout;
|
| 97 |
+
try {
|
| 98 |
+
stdout = child_process.execFileSync(command.shift(), command, {
|
| 99 |
+
// Without this, this install script strangely crashes with the error
|
| 100 |
+
// "EACCES: permission denied, write" but only on Ubuntu Linux when node is
|
| 101 |
+
// installed from the Snap Store. This is not a problem when you download
|
| 102 |
+
// the official version of node. The problem appears to be that stderr
|
| 103 |
+
// (i.e. file descriptor 2) isn't writable?
|
| 104 |
+
//
|
| 105 |
+
// More info:
|
| 106 |
+
// - https://snapcraft.io/ (what the Snap Store is)
|
| 107 |
+
// - https://nodejs.org/dist/ (download the official version of node)
|
| 108 |
+
// - https://github.com/evanw/esbuild/issues/1711#issuecomment-1027554035
|
| 109 |
+
//
|
| 110 |
+
stdio: "pipe"
|
| 111 |
+
}).toString().trim();
|
| 112 |
+
} catch (err) {
|
| 113 |
+
if (os2.platform() === "darwin" && /_SecTrustEvaluateWithError/.test(err + "")) {
|
| 114 |
+
let os3 = "this version of macOS";
|
| 115 |
+
try {
|
| 116 |
+
os3 = "macOS " + child_process.execFileSync("sw_vers", ["-productVersion"]).toString().trim();
|
| 117 |
+
} catch {
|
| 118 |
+
}
|
| 119 |
+
throw new Error(`The "esbuild" package cannot be installed because ${os3} is too outdated.
|
| 120 |
+
|
| 121 |
+
The Go compiler (which esbuild relies on) no longer supports ${os3},
|
| 122 |
+
which means the "esbuild" binary executable can't be run. You can either:
|
| 123 |
+
|
| 124 |
+
* Update your version of macOS to one that the Go compiler supports
|
| 125 |
+
* Use the "esbuild-wasm" package instead of the "esbuild" package
|
| 126 |
+
* Build esbuild yourself using an older version of the Go compiler
|
| 127 |
+
`);
|
| 128 |
+
}
|
| 129 |
+
throw err;
|
| 130 |
+
}
|
| 131 |
+
if (stdout !== versionFromPackageJSON) {
|
| 132 |
+
throw new Error(`Expected ${JSON.stringify(versionFromPackageJSON)} but got ${JSON.stringify(stdout)}`);
|
| 133 |
+
}
|
| 134 |
+
}
|
| 135 |
+
function isYarn() {
|
| 136 |
+
const { npm_config_user_agent } = process.env;
|
| 137 |
+
if (npm_config_user_agent) {
|
| 138 |
+
return /\byarn\//.test(npm_config_user_agent);
|
| 139 |
+
}
|
| 140 |
+
return false;
|
| 141 |
+
}
|
| 142 |
+
function fetch(url) {
|
| 143 |
+
return new Promise((resolve, reject) => {
|
| 144 |
+
https.get(url, (res) => {
|
| 145 |
+
if ((res.statusCode === 301 || res.statusCode === 302) && res.headers.location)
|
| 146 |
+
return fetch(res.headers.location).then(resolve, reject);
|
| 147 |
+
if (res.statusCode !== 200)
|
| 148 |
+
return reject(new Error(`Server responded with ${res.statusCode}`));
|
| 149 |
+
let chunks = [];
|
| 150 |
+
res.on("data", (chunk) => chunks.push(chunk));
|
| 151 |
+
res.on("end", () => resolve(Buffer.concat(chunks)));
|
| 152 |
+
}).on("error", reject);
|
| 153 |
+
});
|
| 154 |
+
}
|
| 155 |
+
function extractFileFromTarGzip(buffer, subpath) {
|
| 156 |
+
try {
|
| 157 |
+
buffer = zlib.unzipSync(buffer);
|
| 158 |
+
} catch (err) {
|
| 159 |
+
throw new Error(`Invalid gzip data in archive: ${err && err.message || err}`);
|
| 160 |
+
}
|
| 161 |
+
let str = (i, n) => String.fromCharCode(...buffer.subarray(i, i + n)).replace(/\0.*$/, "");
|
| 162 |
+
let offset = 0;
|
| 163 |
+
subpath = `package/${subpath}`;
|
| 164 |
+
while (offset < buffer.length) {
|
| 165 |
+
let name = str(offset, 100);
|
| 166 |
+
let size = parseInt(str(offset + 124, 12), 8);
|
| 167 |
+
offset += 512;
|
| 168 |
+
if (!isNaN(size)) {
|
| 169 |
+
if (name === subpath)
|
| 170 |
+
return buffer.subarray(offset, offset + size);
|
| 171 |
+
offset += size + 511 & ~511;
|
| 172 |
+
}
|
| 173 |
+
}
|
| 174 |
+
throw new Error(`Could not find ${JSON.stringify(subpath)} in archive`);
|
| 175 |
+
}
|
| 176 |
+
function installUsingNPM(pkg, subpath, binPath) {
|
| 177 |
+
const env = { ...process.env, npm_config_global: void 0 };
|
| 178 |
+
const esbuildLibDir = path2.dirname(require.resolve("esbuild"));
|
| 179 |
+
const installDir = path2.join(esbuildLibDir, "npm-install");
|
| 180 |
+
fs2.mkdirSync(installDir);
|
| 181 |
+
try {
|
| 182 |
+
fs2.writeFileSync(path2.join(installDir, "package.json"), "{}");
|
| 183 |
+
child_process.execSync(
|
| 184 |
+
`npm install --loglevel=error --prefer-offline --no-audit --progress=false ${pkg}@${versionFromPackageJSON}`,
|
| 185 |
+
{ cwd: installDir, stdio: "pipe", env }
|
| 186 |
+
);
|
| 187 |
+
const installedBinPath = path2.join(installDir, "node_modules", pkg, subpath);
|
| 188 |
+
fs2.renameSync(installedBinPath, binPath);
|
| 189 |
+
} finally {
|
| 190 |
+
try {
|
| 191 |
+
removeRecursive(installDir);
|
| 192 |
+
} catch {
|
| 193 |
+
}
|
| 194 |
+
}
|
| 195 |
+
}
|
| 196 |
+
function removeRecursive(dir) {
|
| 197 |
+
for (const entry of fs2.readdirSync(dir)) {
|
| 198 |
+
const entryPath = path2.join(dir, entry);
|
| 199 |
+
let stats;
|
| 200 |
+
try {
|
| 201 |
+
stats = fs2.lstatSync(entryPath);
|
| 202 |
+
} catch {
|
| 203 |
+
continue;
|
| 204 |
+
}
|
| 205 |
+
if (stats.isDirectory())
|
| 206 |
+
removeRecursive(entryPath);
|
| 207 |
+
else
|
| 208 |
+
fs2.unlinkSync(entryPath);
|
| 209 |
+
}
|
| 210 |
+
fs2.rmdirSync(dir);
|
| 211 |
+
}
|
| 212 |
+
function applyManualBinaryPathOverride(overridePath) {
|
| 213 |
+
const pathString = JSON.stringify(overridePath);
|
| 214 |
+
fs2.writeFileSync(toPath, `#!/usr/bin/env node
|
| 215 |
+
require('child_process').execFileSync(${pathString}, process.argv.slice(2), { stdio: 'inherit' });
|
| 216 |
+
`);
|
| 217 |
+
const libMain = path2.join(__dirname, "lib", "main.js");
|
| 218 |
+
const code = fs2.readFileSync(libMain, "utf8");
|
| 219 |
+
fs2.writeFileSync(libMain, `var ESBUILD_BINARY_PATH = ${pathString};
|
| 220 |
+
${code}`);
|
| 221 |
+
}
|
| 222 |
+
function maybeOptimizePackage(binPath) {
|
| 223 |
+
if (os2.platform() !== "win32" && !isYarn()) {
|
| 224 |
+
const tempPath = path2.join(__dirname, "bin-esbuild");
|
| 225 |
+
try {
|
| 226 |
+
fs2.linkSync(binPath, tempPath);
|
| 227 |
+
fs2.renameSync(tempPath, toPath);
|
| 228 |
+
isToPathJS = false;
|
| 229 |
+
fs2.unlinkSync(tempPath);
|
| 230 |
+
} catch {
|
| 231 |
+
}
|
| 232 |
+
}
|
| 233 |
+
}
|
| 234 |
+
async function downloadDirectlyFromNPM(pkg, subpath, binPath) {
|
| 235 |
+
const url = `https://registry.npmjs.org/${pkg}/-/${pkg.replace("@esbuild/", "")}-${versionFromPackageJSON}.tgz`;
|
| 236 |
+
console.error(`[esbuild] Trying to download ${JSON.stringify(url)}`);
|
| 237 |
+
try {
|
| 238 |
+
fs2.writeFileSync(binPath, extractFileFromTarGzip(await fetch(url), subpath));
|
| 239 |
+
fs2.chmodSync(binPath, 493);
|
| 240 |
+
} catch (e) {
|
| 241 |
+
console.error(`[esbuild] Failed to download ${JSON.stringify(url)}: ${e && e.message || e}`);
|
| 242 |
+
throw e;
|
| 243 |
+
}
|
| 244 |
+
}
|
| 245 |
+
async function checkAndPreparePackage() {
|
| 246 |
+
if (isValidBinaryPath(ESBUILD_BINARY_PATH)) {
|
| 247 |
+
if (!fs2.existsSync(ESBUILD_BINARY_PATH)) {
|
| 248 |
+
console.warn(`[esbuild] Ignoring bad configuration: ESBUILD_BINARY_PATH=${ESBUILD_BINARY_PATH}`);
|
| 249 |
+
} else {
|
| 250 |
+
applyManualBinaryPathOverride(ESBUILD_BINARY_PATH);
|
| 251 |
+
return;
|
| 252 |
+
}
|
| 253 |
+
}
|
| 254 |
+
const { pkg, subpath } = pkgAndSubpathForCurrentPlatform();
|
| 255 |
+
let binPath;
|
| 256 |
+
try {
|
| 257 |
+
binPath = require.resolve(`${pkg}/${subpath}`);
|
| 258 |
+
} catch (e) {
|
| 259 |
+
console.error(`[esbuild] Failed to find package "${pkg}" on the file system
|
| 260 |
+
|
| 261 |
+
This can happen if you use the "--no-optional" flag. The "optionalDependencies"
|
| 262 |
+
package.json feature is used by esbuild to install the correct binary executable
|
| 263 |
+
for your current platform. This install script will now attempt to work around
|
| 264 |
+
this. If that fails, you need to remove the "--no-optional" flag to use esbuild.
|
| 265 |
+
`);
|
| 266 |
+
binPath = downloadedBinPath(pkg, subpath);
|
| 267 |
+
try {
|
| 268 |
+
console.error(`[esbuild] Trying to install package "${pkg}" using npm`);
|
| 269 |
+
installUsingNPM(pkg, subpath, binPath);
|
| 270 |
+
} catch (e2) {
|
| 271 |
+
console.error(`[esbuild] Failed to install package "${pkg}" using npm: ${e2 && e2.message || e2}`);
|
| 272 |
+
try {
|
| 273 |
+
await downloadDirectlyFromNPM(pkg, subpath, binPath);
|
| 274 |
+
} catch (e3) {
|
| 275 |
+
throw new Error(`Failed to install package "${pkg}"`);
|
| 276 |
+
}
|
| 277 |
+
}
|
| 278 |
+
}
|
| 279 |
+
maybeOptimizePackage(binPath);
|
| 280 |
+
}
|
| 281 |
+
checkAndPreparePackage().then(() => {
|
| 282 |
+
if (isToPathJS) {
|
| 283 |
+
validateBinaryVersion(process.execPath, toPath);
|
| 284 |
+
} else {
|
| 285 |
+
validateBinaryVersion(toPath);
|
| 286 |
+
}
|
| 287 |
+
});
|
e-commerce/node_modules/@esbuild-kit/core-utils/node_modules/esbuild/lib/main.d.ts
ADDED
|
@@ -0,0 +1,660 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
export type Platform = 'browser' | 'node' | 'neutral'
|
| 2 |
+
export type Format = 'iife' | 'cjs' | 'esm'
|
| 3 |
+
export type Loader = 'base64' | 'binary' | 'copy' | 'css' | 'dataurl' | 'default' | 'empty' | 'file' | 'js' | 'json' | 'jsx' | 'local-css' | 'text' | 'ts' | 'tsx'
|
| 4 |
+
export type LogLevel = 'verbose' | 'debug' | 'info' | 'warning' | 'error' | 'silent'
|
| 5 |
+
export type Charset = 'ascii' | 'utf8'
|
| 6 |
+
export type Drop = 'console' | 'debugger'
|
| 7 |
+
|
| 8 |
+
interface CommonOptions {
|
| 9 |
+
/** Documentation: https://esbuild.github.io/api/#sourcemap */
|
| 10 |
+
sourcemap?: boolean | 'linked' | 'inline' | 'external' | 'both'
|
| 11 |
+
/** Documentation: https://esbuild.github.io/api/#legal-comments */
|
| 12 |
+
legalComments?: 'none' | 'inline' | 'eof' | 'linked' | 'external'
|
| 13 |
+
/** Documentation: https://esbuild.github.io/api/#source-root */
|
| 14 |
+
sourceRoot?: string
|
| 15 |
+
/** Documentation: https://esbuild.github.io/api/#sources-content */
|
| 16 |
+
sourcesContent?: boolean
|
| 17 |
+
|
| 18 |
+
/** Documentation: https://esbuild.github.io/api/#format */
|
| 19 |
+
format?: Format
|
| 20 |
+
/** Documentation: https://esbuild.github.io/api/#global-name */
|
| 21 |
+
globalName?: string
|
| 22 |
+
/** Documentation: https://esbuild.github.io/api/#target */
|
| 23 |
+
target?: string | string[]
|
| 24 |
+
/** Documentation: https://esbuild.github.io/api/#supported */
|
| 25 |
+
supported?: Record<string, boolean>
|
| 26 |
+
/** Documentation: https://esbuild.github.io/api/#platform */
|
| 27 |
+
platform?: Platform
|
| 28 |
+
|
| 29 |
+
/** Documentation: https://esbuild.github.io/api/#mangle-props */
|
| 30 |
+
mangleProps?: RegExp
|
| 31 |
+
/** Documentation: https://esbuild.github.io/api/#mangle-props */
|
| 32 |
+
reserveProps?: RegExp
|
| 33 |
+
/** Documentation: https://esbuild.github.io/api/#mangle-props */
|
| 34 |
+
mangleQuoted?: boolean
|
| 35 |
+
/** Documentation: https://esbuild.github.io/api/#mangle-props */
|
| 36 |
+
mangleCache?: Record<string, string | false>
|
| 37 |
+
/** Documentation: https://esbuild.github.io/api/#drop */
|
| 38 |
+
drop?: Drop[]
|
| 39 |
+
/** Documentation: https://esbuild.github.io/api/#drop-labels */
|
| 40 |
+
dropLabels?: string[]
|
| 41 |
+
/** Documentation: https://esbuild.github.io/api/#minify */
|
| 42 |
+
minify?: boolean
|
| 43 |
+
/** Documentation: https://esbuild.github.io/api/#minify */
|
| 44 |
+
minifyWhitespace?: boolean
|
| 45 |
+
/** Documentation: https://esbuild.github.io/api/#minify */
|
| 46 |
+
minifyIdentifiers?: boolean
|
| 47 |
+
/** Documentation: https://esbuild.github.io/api/#minify */
|
| 48 |
+
minifySyntax?: boolean
|
| 49 |
+
/** Documentation: https://esbuild.github.io/api/#line-limit */
|
| 50 |
+
lineLimit?: number
|
| 51 |
+
/** Documentation: https://esbuild.github.io/api/#charset */
|
| 52 |
+
charset?: Charset
|
| 53 |
+
/** Documentation: https://esbuild.github.io/api/#tree-shaking */
|
| 54 |
+
treeShaking?: boolean
|
| 55 |
+
/** Documentation: https://esbuild.github.io/api/#ignore-annotations */
|
| 56 |
+
ignoreAnnotations?: boolean
|
| 57 |
+
|
| 58 |
+
/** Documentation: https://esbuild.github.io/api/#jsx */
|
| 59 |
+
jsx?: 'transform' | 'preserve' | 'automatic'
|
| 60 |
+
/** Documentation: https://esbuild.github.io/api/#jsx-factory */
|
| 61 |
+
jsxFactory?: string
|
| 62 |
+
/** Documentation: https://esbuild.github.io/api/#jsx-fragment */
|
| 63 |
+
jsxFragment?: string
|
| 64 |
+
/** Documentation: https://esbuild.github.io/api/#jsx-import-source */
|
| 65 |
+
jsxImportSource?: string
|
| 66 |
+
/** Documentation: https://esbuild.github.io/api/#jsx-development */
|
| 67 |
+
jsxDev?: boolean
|
| 68 |
+
/** Documentation: https://esbuild.github.io/api/#jsx-side-effects */
|
| 69 |
+
jsxSideEffects?: boolean
|
| 70 |
+
|
| 71 |
+
/** Documentation: https://esbuild.github.io/api/#define */
|
| 72 |
+
define?: { [key: string]: string }
|
| 73 |
+
/** Documentation: https://esbuild.github.io/api/#pure */
|
| 74 |
+
pure?: string[]
|
| 75 |
+
/** Documentation: https://esbuild.github.io/api/#keep-names */
|
| 76 |
+
keepNames?: boolean
|
| 77 |
+
|
| 78 |
+
/** Documentation: https://esbuild.github.io/api/#color */
|
| 79 |
+
color?: boolean
|
| 80 |
+
/** Documentation: https://esbuild.github.io/api/#log-level */
|
| 81 |
+
logLevel?: LogLevel
|
| 82 |
+
/** Documentation: https://esbuild.github.io/api/#log-limit */
|
| 83 |
+
logLimit?: number
|
| 84 |
+
/** Documentation: https://esbuild.github.io/api/#log-override */
|
| 85 |
+
logOverride?: Record<string, LogLevel>
|
| 86 |
+
|
| 87 |
+
/** Documentation: https://esbuild.github.io/api/#tsconfig-raw */
|
| 88 |
+
tsconfigRaw?: string | TsconfigRaw
|
| 89 |
+
}
|
| 90 |
+
|
| 91 |
+
export interface TsconfigRaw {
|
| 92 |
+
compilerOptions?: {
|
| 93 |
+
alwaysStrict?: boolean
|
| 94 |
+
baseUrl?: boolean
|
| 95 |
+
experimentalDecorators?: boolean
|
| 96 |
+
importsNotUsedAsValues?: 'remove' | 'preserve' | 'error'
|
| 97 |
+
jsx?: 'preserve' | 'react-native' | 'react' | 'react-jsx' | 'react-jsxdev'
|
| 98 |
+
jsxFactory?: string
|
| 99 |
+
jsxFragmentFactory?: string
|
| 100 |
+
jsxImportSource?: string
|
| 101 |
+
paths?: Record<string, string[]>
|
| 102 |
+
preserveValueImports?: boolean
|
| 103 |
+
strict?: boolean
|
| 104 |
+
target?: string
|
| 105 |
+
useDefineForClassFields?: boolean
|
| 106 |
+
verbatimModuleSyntax?: boolean
|
| 107 |
+
}
|
| 108 |
+
}
|
| 109 |
+
|
| 110 |
+
export interface BuildOptions extends CommonOptions {
|
| 111 |
+
/** Documentation: https://esbuild.github.io/api/#bundle */
|
| 112 |
+
bundle?: boolean
|
| 113 |
+
/** Documentation: https://esbuild.github.io/api/#splitting */
|
| 114 |
+
splitting?: boolean
|
| 115 |
+
/** Documentation: https://esbuild.github.io/api/#preserve-symlinks */
|
| 116 |
+
preserveSymlinks?: boolean
|
| 117 |
+
/** Documentation: https://esbuild.github.io/api/#outfile */
|
| 118 |
+
outfile?: string
|
| 119 |
+
/** Documentation: https://esbuild.github.io/api/#metafile */
|
| 120 |
+
metafile?: boolean
|
| 121 |
+
/** Documentation: https://esbuild.github.io/api/#outdir */
|
| 122 |
+
outdir?: string
|
| 123 |
+
/** Documentation: https://esbuild.github.io/api/#outbase */
|
| 124 |
+
outbase?: string
|
| 125 |
+
/** Documentation: https://esbuild.github.io/api/#external */
|
| 126 |
+
external?: string[]
|
| 127 |
+
/** Documentation: https://esbuild.github.io/api/#packages */
|
| 128 |
+
packages?: 'external'
|
| 129 |
+
/** Documentation: https://esbuild.github.io/api/#alias */
|
| 130 |
+
alias?: Record<string, string>
|
| 131 |
+
/** Documentation: https://esbuild.github.io/api/#loader */
|
| 132 |
+
loader?: { [ext: string]: Loader }
|
| 133 |
+
/** Documentation: https://esbuild.github.io/api/#resolve-extensions */
|
| 134 |
+
resolveExtensions?: string[]
|
| 135 |
+
/** Documentation: https://esbuild.github.io/api/#main-fields */
|
| 136 |
+
mainFields?: string[]
|
| 137 |
+
/** Documentation: https://esbuild.github.io/api/#conditions */
|
| 138 |
+
conditions?: string[]
|
| 139 |
+
/** Documentation: https://esbuild.github.io/api/#write */
|
| 140 |
+
write?: boolean
|
| 141 |
+
/** Documentation: https://esbuild.github.io/api/#allow-overwrite */
|
| 142 |
+
allowOverwrite?: boolean
|
| 143 |
+
/** Documentation: https://esbuild.github.io/api/#tsconfig */
|
| 144 |
+
tsconfig?: string
|
| 145 |
+
/** Documentation: https://esbuild.github.io/api/#out-extension */
|
| 146 |
+
outExtension?: { [ext: string]: string }
|
| 147 |
+
/** Documentation: https://esbuild.github.io/api/#public-path */
|
| 148 |
+
publicPath?: string
|
| 149 |
+
/** Documentation: https://esbuild.github.io/api/#entry-names */
|
| 150 |
+
entryNames?: string
|
| 151 |
+
/** Documentation: https://esbuild.github.io/api/#chunk-names */
|
| 152 |
+
chunkNames?: string
|
| 153 |
+
/** Documentation: https://esbuild.github.io/api/#asset-names */
|
| 154 |
+
assetNames?: string
|
| 155 |
+
/** Documentation: https://esbuild.github.io/api/#inject */
|
| 156 |
+
inject?: string[]
|
| 157 |
+
/** Documentation: https://esbuild.github.io/api/#banner */
|
| 158 |
+
banner?: { [type: string]: string }
|
| 159 |
+
/** Documentation: https://esbuild.github.io/api/#footer */
|
| 160 |
+
footer?: { [type: string]: string }
|
| 161 |
+
/** Documentation: https://esbuild.github.io/api/#entry-points */
|
| 162 |
+
entryPoints?: string[] | Record<string, string> | { in: string, out: string }[]
|
| 163 |
+
/** Documentation: https://esbuild.github.io/api/#stdin */
|
| 164 |
+
stdin?: StdinOptions
|
| 165 |
+
/** Documentation: https://esbuild.github.io/plugins/ */
|
| 166 |
+
plugins?: Plugin[]
|
| 167 |
+
/** Documentation: https://esbuild.github.io/api/#working-directory */
|
| 168 |
+
absWorkingDir?: string
|
| 169 |
+
/** Documentation: https://esbuild.github.io/api/#node-paths */
|
| 170 |
+
nodePaths?: string[]; // The "NODE_PATH" variable from Node.js
|
| 171 |
+
}
|
| 172 |
+
|
| 173 |
+
export interface StdinOptions {
|
| 174 |
+
contents: string | Uint8Array
|
| 175 |
+
resolveDir?: string
|
| 176 |
+
sourcefile?: string
|
| 177 |
+
loader?: Loader
|
| 178 |
+
}
|
| 179 |
+
|
| 180 |
+
export interface Message {
|
| 181 |
+
id: string
|
| 182 |
+
pluginName: string
|
| 183 |
+
text: string
|
| 184 |
+
location: Location | null
|
| 185 |
+
notes: Note[]
|
| 186 |
+
|
| 187 |
+
/**
|
| 188 |
+
* Optional user-specified data that is passed through unmodified. You can
|
| 189 |
+
* use this to stash the original error, for example.
|
| 190 |
+
*/
|
| 191 |
+
detail: any
|
| 192 |
+
}
|
| 193 |
+
|
| 194 |
+
export interface Note {
|
| 195 |
+
text: string
|
| 196 |
+
location: Location | null
|
| 197 |
+
}
|
| 198 |
+
|
| 199 |
+
export interface Location {
|
| 200 |
+
file: string
|
| 201 |
+
namespace: string
|
| 202 |
+
/** 1-based */
|
| 203 |
+
line: number
|
| 204 |
+
/** 0-based, in bytes */
|
| 205 |
+
column: number
|
| 206 |
+
/** in bytes */
|
| 207 |
+
length: number
|
| 208 |
+
lineText: string
|
| 209 |
+
suggestion: string
|
| 210 |
+
}
|
| 211 |
+
|
| 212 |
+
export interface OutputFile {
|
| 213 |
+
path: string
|
| 214 |
+
contents: Uint8Array
|
| 215 |
+
hash: string
|
| 216 |
+
/** "contents" as text (changes automatically with "contents") */
|
| 217 |
+
readonly text: string
|
| 218 |
+
}
|
| 219 |
+
|
| 220 |
+
export interface BuildResult<ProvidedOptions extends BuildOptions = BuildOptions> {
|
| 221 |
+
errors: Message[]
|
| 222 |
+
warnings: Message[]
|
| 223 |
+
/** Only when "write: false" */
|
| 224 |
+
outputFiles: OutputFile[] | (ProvidedOptions['write'] extends false ? never : undefined)
|
| 225 |
+
/** Only when "metafile: true" */
|
| 226 |
+
metafile: Metafile | (ProvidedOptions['metafile'] extends true ? never : undefined)
|
| 227 |
+
/** Only when "mangleCache" is present */
|
| 228 |
+
mangleCache: Record<string, string | false> | (ProvidedOptions['mangleCache'] extends Object ? never : undefined)
|
| 229 |
+
}
|
| 230 |
+
|
| 231 |
+
export interface BuildFailure extends Error {
|
| 232 |
+
errors: Message[]
|
| 233 |
+
warnings: Message[]
|
| 234 |
+
}
|
| 235 |
+
|
| 236 |
+
/** Documentation: https://esbuild.github.io/api/#serve-arguments */
|
| 237 |
+
export interface ServeOptions {
|
| 238 |
+
port?: number
|
| 239 |
+
host?: string
|
| 240 |
+
servedir?: string
|
| 241 |
+
keyfile?: string
|
| 242 |
+
certfile?: string
|
| 243 |
+
fallback?: string
|
| 244 |
+
onRequest?: (args: ServeOnRequestArgs) => void
|
| 245 |
+
}
|
| 246 |
+
|
| 247 |
+
export interface ServeOnRequestArgs {
|
| 248 |
+
remoteAddress: string
|
| 249 |
+
method: string
|
| 250 |
+
path: string
|
| 251 |
+
status: number
|
| 252 |
+
/** The time to generate the response, not to send it */
|
| 253 |
+
timeInMS: number
|
| 254 |
+
}
|
| 255 |
+
|
| 256 |
+
/** Documentation: https://esbuild.github.io/api/#serve-return-values */
|
| 257 |
+
export interface ServeResult {
|
| 258 |
+
port: number
|
| 259 |
+
host: string
|
| 260 |
+
}
|
| 261 |
+
|
| 262 |
+
export interface TransformOptions extends CommonOptions {
|
| 263 |
+
/** Documentation: https://esbuild.github.io/api/#sourcefile */
|
| 264 |
+
sourcefile?: string
|
| 265 |
+
/** Documentation: https://esbuild.github.io/api/#loader */
|
| 266 |
+
loader?: Loader
|
| 267 |
+
/** Documentation: https://esbuild.github.io/api/#banner */
|
| 268 |
+
banner?: string
|
| 269 |
+
/** Documentation: https://esbuild.github.io/api/#footer */
|
| 270 |
+
footer?: string
|
| 271 |
+
}
|
| 272 |
+
|
| 273 |
+
export interface TransformResult<ProvidedOptions extends TransformOptions = TransformOptions> {
|
| 274 |
+
code: string
|
| 275 |
+
map: string
|
| 276 |
+
warnings: Message[]
|
| 277 |
+
/** Only when "mangleCache" is present */
|
| 278 |
+
mangleCache: Record<string, string | false> | (ProvidedOptions['mangleCache'] extends Object ? never : undefined)
|
| 279 |
+
/** Only when "legalComments" is "external" */
|
| 280 |
+
legalComments: string | (ProvidedOptions['legalComments'] extends 'external' ? never : undefined)
|
| 281 |
+
}
|
| 282 |
+
|
| 283 |
+
export interface TransformFailure extends Error {
|
| 284 |
+
errors: Message[]
|
| 285 |
+
warnings: Message[]
|
| 286 |
+
}
|
| 287 |
+
|
| 288 |
+
export interface Plugin {
|
| 289 |
+
name: string
|
| 290 |
+
setup: (build: PluginBuild) => (void | Promise<void>)
|
| 291 |
+
}
|
| 292 |
+
|
| 293 |
+
export interface PluginBuild {
|
| 294 |
+
/** Documentation: https://esbuild.github.io/plugins/#build-options */
|
| 295 |
+
initialOptions: BuildOptions
|
| 296 |
+
|
| 297 |
+
/** Documentation: https://esbuild.github.io/plugins/#resolve */
|
| 298 |
+
resolve(path: string, options?: ResolveOptions): Promise<ResolveResult>
|
| 299 |
+
|
| 300 |
+
/** Documentation: https://esbuild.github.io/plugins/#on-start */
|
| 301 |
+
onStart(callback: () =>
|
| 302 |
+
(OnStartResult | null | void | Promise<OnStartResult | null | void>)): void
|
| 303 |
+
|
| 304 |
+
/** Documentation: https://esbuild.github.io/plugins/#on-end */
|
| 305 |
+
onEnd(callback: (result: BuildResult) =>
|
| 306 |
+
(OnEndResult | null | void | Promise<OnEndResult | null | void>)): void
|
| 307 |
+
|
| 308 |
+
/** Documentation: https://esbuild.github.io/plugins/#on-resolve */
|
| 309 |
+
onResolve(options: OnResolveOptions, callback: (args: OnResolveArgs) =>
|
| 310 |
+
(OnResolveResult | null | undefined | Promise<OnResolveResult | null | undefined>)): void
|
| 311 |
+
|
| 312 |
+
/** Documentation: https://esbuild.github.io/plugins/#on-load */
|
| 313 |
+
onLoad(options: OnLoadOptions, callback: (args: OnLoadArgs) =>
|
| 314 |
+
(OnLoadResult | null | undefined | Promise<OnLoadResult | null | undefined>)): void
|
| 315 |
+
|
| 316 |
+
/** Documentation: https://esbuild.github.io/plugins/#on-dispose */
|
| 317 |
+
onDispose(callback: () => void): void
|
| 318 |
+
|
| 319 |
+
// This is a full copy of the esbuild library in case you need it
|
| 320 |
+
esbuild: {
|
| 321 |
+
context: typeof context,
|
| 322 |
+
build: typeof build,
|
| 323 |
+
buildSync: typeof buildSync,
|
| 324 |
+
transform: typeof transform,
|
| 325 |
+
transformSync: typeof transformSync,
|
| 326 |
+
formatMessages: typeof formatMessages,
|
| 327 |
+
formatMessagesSync: typeof formatMessagesSync,
|
| 328 |
+
analyzeMetafile: typeof analyzeMetafile,
|
| 329 |
+
analyzeMetafileSync: typeof analyzeMetafileSync,
|
| 330 |
+
initialize: typeof initialize,
|
| 331 |
+
version: typeof version,
|
| 332 |
+
}
|
| 333 |
+
}
|
| 334 |
+
|
| 335 |
+
/** Documentation: https://esbuild.github.io/plugins/#resolve-options */
|
| 336 |
+
export interface ResolveOptions {
|
| 337 |
+
pluginName?: string
|
| 338 |
+
importer?: string
|
| 339 |
+
namespace?: string
|
| 340 |
+
resolveDir?: string
|
| 341 |
+
kind?: ImportKind
|
| 342 |
+
pluginData?: any
|
| 343 |
+
}
|
| 344 |
+
|
| 345 |
+
/** Documentation: https://esbuild.github.io/plugins/#resolve-results */
|
| 346 |
+
export interface ResolveResult {
|
| 347 |
+
errors: Message[]
|
| 348 |
+
warnings: Message[]
|
| 349 |
+
|
| 350 |
+
path: string
|
| 351 |
+
external: boolean
|
| 352 |
+
sideEffects: boolean
|
| 353 |
+
namespace: string
|
| 354 |
+
suffix: string
|
| 355 |
+
pluginData: any
|
| 356 |
+
}
|
| 357 |
+
|
| 358 |
+
export interface OnStartResult {
|
| 359 |
+
errors?: PartialMessage[]
|
| 360 |
+
warnings?: PartialMessage[]
|
| 361 |
+
}
|
| 362 |
+
|
| 363 |
+
export interface OnEndResult {
|
| 364 |
+
errors?: PartialMessage[]
|
| 365 |
+
warnings?: PartialMessage[]
|
| 366 |
+
}
|
| 367 |
+
|
| 368 |
+
/** Documentation: https://esbuild.github.io/plugins/#on-resolve-options */
|
| 369 |
+
export interface OnResolveOptions {
|
| 370 |
+
filter: RegExp
|
| 371 |
+
namespace?: string
|
| 372 |
+
}
|
| 373 |
+
|
| 374 |
+
/** Documentation: https://esbuild.github.io/plugins/#on-resolve-arguments */
|
| 375 |
+
export interface OnResolveArgs {
|
| 376 |
+
path: string
|
| 377 |
+
importer: string
|
| 378 |
+
namespace: string
|
| 379 |
+
resolveDir: string
|
| 380 |
+
kind: ImportKind
|
| 381 |
+
pluginData: any
|
| 382 |
+
}
|
| 383 |
+
|
| 384 |
+
export type ImportKind =
|
| 385 |
+
| 'entry-point'
|
| 386 |
+
|
| 387 |
+
// JS
|
| 388 |
+
| 'import-statement'
|
| 389 |
+
| 'require-call'
|
| 390 |
+
| 'dynamic-import'
|
| 391 |
+
| 'require-resolve'
|
| 392 |
+
|
| 393 |
+
// CSS
|
| 394 |
+
| 'import-rule'
|
| 395 |
+
| 'composes-from'
|
| 396 |
+
| 'url-token'
|
| 397 |
+
|
| 398 |
+
/** Documentation: https://esbuild.github.io/plugins/#on-resolve-results */
|
| 399 |
+
export interface OnResolveResult {
|
| 400 |
+
pluginName?: string
|
| 401 |
+
|
| 402 |
+
errors?: PartialMessage[]
|
| 403 |
+
warnings?: PartialMessage[]
|
| 404 |
+
|
| 405 |
+
path?: string
|
| 406 |
+
external?: boolean
|
| 407 |
+
sideEffects?: boolean
|
| 408 |
+
namespace?: string
|
| 409 |
+
suffix?: string
|
| 410 |
+
pluginData?: any
|
| 411 |
+
|
| 412 |
+
watchFiles?: string[]
|
| 413 |
+
watchDirs?: string[]
|
| 414 |
+
}
|
| 415 |
+
|
| 416 |
+
/** Documentation: https://esbuild.github.io/plugins/#on-load-options */
|
| 417 |
+
export interface OnLoadOptions {
|
| 418 |
+
filter: RegExp
|
| 419 |
+
namespace?: string
|
| 420 |
+
}
|
| 421 |
+
|
| 422 |
+
/** Documentation: https://esbuild.github.io/plugins/#on-load-arguments */
|
| 423 |
+
export interface OnLoadArgs {
|
| 424 |
+
path: string
|
| 425 |
+
namespace: string
|
| 426 |
+
suffix: string
|
| 427 |
+
pluginData: any
|
| 428 |
+
}
|
| 429 |
+
|
| 430 |
+
/** Documentation: https://esbuild.github.io/plugins/#on-load-results */
|
| 431 |
+
export interface OnLoadResult {
|
| 432 |
+
pluginName?: string
|
| 433 |
+
|
| 434 |
+
errors?: PartialMessage[]
|
| 435 |
+
warnings?: PartialMessage[]
|
| 436 |
+
|
| 437 |
+
contents?: string | Uint8Array
|
| 438 |
+
resolveDir?: string
|
| 439 |
+
loader?: Loader
|
| 440 |
+
pluginData?: any
|
| 441 |
+
|
| 442 |
+
watchFiles?: string[]
|
| 443 |
+
watchDirs?: string[]
|
| 444 |
+
}
|
| 445 |
+
|
| 446 |
+
export interface PartialMessage {
|
| 447 |
+
id?: string
|
| 448 |
+
pluginName?: string
|
| 449 |
+
text?: string
|
| 450 |
+
location?: Partial<Location> | null
|
| 451 |
+
notes?: PartialNote[]
|
| 452 |
+
detail?: any
|
| 453 |
+
}
|
| 454 |
+
|
| 455 |
+
export interface PartialNote {
|
| 456 |
+
text?: string
|
| 457 |
+
location?: Partial<Location> | null
|
| 458 |
+
}
|
| 459 |
+
|
| 460 |
+
/** Documentation: https://esbuild.github.io/api/#metafile */
|
| 461 |
+
export interface Metafile {
|
| 462 |
+
inputs: {
|
| 463 |
+
[path: string]: {
|
| 464 |
+
bytes: number
|
| 465 |
+
imports: {
|
| 466 |
+
path: string
|
| 467 |
+
kind: ImportKind
|
| 468 |
+
external?: boolean
|
| 469 |
+
original?: string
|
| 470 |
+
}[]
|
| 471 |
+
format?: 'cjs' | 'esm'
|
| 472 |
+
}
|
| 473 |
+
}
|
| 474 |
+
outputs: {
|
| 475 |
+
[path: string]: {
|
| 476 |
+
bytes: number
|
| 477 |
+
inputs: {
|
| 478 |
+
[path: string]: {
|
| 479 |
+
bytesInOutput: number
|
| 480 |
+
}
|
| 481 |
+
}
|
| 482 |
+
imports: {
|
| 483 |
+
path: string
|
| 484 |
+
kind: ImportKind | 'file-loader'
|
| 485 |
+
external?: boolean
|
| 486 |
+
}[]
|
| 487 |
+
exports: string[]
|
| 488 |
+
entryPoint?: string
|
| 489 |
+
cssBundle?: string
|
| 490 |
+
}
|
| 491 |
+
}
|
| 492 |
+
}
|
| 493 |
+
|
| 494 |
+
export interface FormatMessagesOptions {
|
| 495 |
+
kind: 'error' | 'warning'
|
| 496 |
+
color?: boolean
|
| 497 |
+
terminalWidth?: number
|
| 498 |
+
}
|
| 499 |
+
|
| 500 |
+
export interface AnalyzeMetafileOptions {
|
| 501 |
+
color?: boolean
|
| 502 |
+
verbose?: boolean
|
| 503 |
+
}
|
| 504 |
+
|
| 505 |
+
export interface WatchOptions {
|
| 506 |
+
}
|
| 507 |
+
|
| 508 |
+
export interface BuildContext<ProvidedOptions extends BuildOptions = BuildOptions> {
|
| 509 |
+
/** Documentation: https://esbuild.github.io/api/#rebuild */
|
| 510 |
+
rebuild(): Promise<BuildResult<ProvidedOptions>>
|
| 511 |
+
|
| 512 |
+
/** Documentation: https://esbuild.github.io/api/#watch */
|
| 513 |
+
watch(options?: WatchOptions): Promise<void>
|
| 514 |
+
|
| 515 |
+
/** Documentation: https://esbuild.github.io/api/#serve */
|
| 516 |
+
serve(options?: ServeOptions): Promise<ServeResult>
|
| 517 |
+
|
| 518 |
+
cancel(): Promise<void>
|
| 519 |
+
dispose(): Promise<void>
|
| 520 |
+
}
|
| 521 |
+
|
| 522 |
+
// This is a TypeScript type-level function which replaces any keys in "In"
|
| 523 |
+
// that aren't in "Out" with "never". We use this to reject properties with
|
| 524 |
+
// typos in object literals. See: https://stackoverflow.com/questions/49580725
|
| 525 |
+
type SameShape<Out, In extends Out> = In & { [Key in Exclude<keyof In, keyof Out>]: never }
|
| 526 |
+
|
| 527 |
+
/**
|
| 528 |
+
* This function invokes the "esbuild" command-line tool for you. It returns a
|
| 529 |
+
* promise that either resolves with a "BuildResult" object or rejects with a
|
| 530 |
+
* "BuildFailure" object.
|
| 531 |
+
*
|
| 532 |
+
* - Works in node: yes
|
| 533 |
+
* - Works in browser: yes
|
| 534 |
+
*
|
| 535 |
+
* Documentation: https://esbuild.github.io/api/#build
|
| 536 |
+
*/
|
| 537 |
+
export declare function build<T extends BuildOptions>(options: SameShape<BuildOptions, T>): Promise<BuildResult<T>>
|
| 538 |
+
|
| 539 |
+
/**
|
| 540 |
+
* This is the advanced long-running form of "build" that supports additional
|
| 541 |
+
* features such as watch mode and a local development server.
|
| 542 |
+
*
|
| 543 |
+
* - Works in node: yes
|
| 544 |
+
* - Works in browser: no
|
| 545 |
+
*
|
| 546 |
+
* Documentation: https://esbuild.github.io/api/#build
|
| 547 |
+
*/
|
| 548 |
+
export declare function context<T extends BuildOptions>(options: SameShape<BuildOptions, T>): Promise<BuildContext<T>>
|
| 549 |
+
|
| 550 |
+
/**
|
| 551 |
+
* This function transforms a single JavaScript file. It can be used to minify
|
| 552 |
+
* JavaScript, convert TypeScript/JSX to JavaScript, or convert newer JavaScript
|
| 553 |
+
* to older JavaScript. It returns a promise that is either resolved with a
|
| 554 |
+
* "TransformResult" object or rejected with a "TransformFailure" object.
|
| 555 |
+
*
|
| 556 |
+
* - Works in node: yes
|
| 557 |
+
* - Works in browser: yes
|
| 558 |
+
*
|
| 559 |
+
* Documentation: https://esbuild.github.io/api/#transform
|
| 560 |
+
*/
|
| 561 |
+
export declare function transform<T extends TransformOptions>(input: string | Uint8Array, options?: SameShape<TransformOptions, T>): Promise<TransformResult<T>>
|
| 562 |
+
|
| 563 |
+
/**
|
| 564 |
+
* Converts log messages to formatted message strings suitable for printing in
|
| 565 |
+
* the terminal. This allows you to reuse the built-in behavior of esbuild's
|
| 566 |
+
* log message formatter. This is a batch-oriented API for efficiency.
|
| 567 |
+
*
|
| 568 |
+
* - Works in node: yes
|
| 569 |
+
* - Works in browser: yes
|
| 570 |
+
*/
|
| 571 |
+
export declare function formatMessages(messages: PartialMessage[], options: FormatMessagesOptions): Promise<string[]>
|
| 572 |
+
|
| 573 |
+
/**
|
| 574 |
+
* Pretty-prints an analysis of the metafile JSON to a string. This is just for
|
| 575 |
+
* convenience to be able to match esbuild's pretty-printing exactly. If you want
|
| 576 |
+
* to customize it, you can just inspect the data in the metafile yourself.
|
| 577 |
+
*
|
| 578 |
+
* - Works in node: yes
|
| 579 |
+
* - Works in browser: yes
|
| 580 |
+
*
|
| 581 |
+
* Documentation: https://esbuild.github.io/api/#analyze
|
| 582 |
+
*/
|
| 583 |
+
export declare function analyzeMetafile(metafile: Metafile | string, options?: AnalyzeMetafileOptions): Promise<string>
|
| 584 |
+
|
| 585 |
+
/**
|
| 586 |
+
* A synchronous version of "build".
|
| 587 |
+
*
|
| 588 |
+
* - Works in node: yes
|
| 589 |
+
* - Works in browser: no
|
| 590 |
+
*
|
| 591 |
+
* Documentation: https://esbuild.github.io/api/#build
|
| 592 |
+
*/
|
| 593 |
+
export declare function buildSync<T extends BuildOptions>(options: SameShape<BuildOptions, T>): BuildResult<T>
|
| 594 |
+
|
| 595 |
+
/**
|
| 596 |
+
* A synchronous version of "transform".
|
| 597 |
+
*
|
| 598 |
+
* - Works in node: yes
|
| 599 |
+
* - Works in browser: no
|
| 600 |
+
*
|
| 601 |
+
* Documentation: https://esbuild.github.io/api/#transform
|
| 602 |
+
*/
|
| 603 |
+
export declare function transformSync<T extends TransformOptions>(input: string | Uint8Array, options?: SameShape<TransformOptions, T>): TransformResult<T>
|
| 604 |
+
|
| 605 |
+
/**
|
| 606 |
+
* A synchronous version of "formatMessages".
|
| 607 |
+
*
|
| 608 |
+
* - Works in node: yes
|
| 609 |
+
* - Works in browser: no
|
| 610 |
+
*/
|
| 611 |
+
export declare function formatMessagesSync(messages: PartialMessage[], options: FormatMessagesOptions): string[]
|
| 612 |
+
|
| 613 |
+
/**
|
| 614 |
+
* A synchronous version of "analyzeMetafile".
|
| 615 |
+
*
|
| 616 |
+
* - Works in node: yes
|
| 617 |
+
* - Works in browser: no
|
| 618 |
+
*
|
| 619 |
+
* Documentation: https://esbuild.github.io/api/#analyze
|
| 620 |
+
*/
|
| 621 |
+
export declare function analyzeMetafileSync(metafile: Metafile | string, options?: AnalyzeMetafileOptions): string
|
| 622 |
+
|
| 623 |
+
/**
|
| 624 |
+
* This configures the browser-based version of esbuild. It is necessary to
|
| 625 |
+
* call this first and wait for the returned promise to be resolved before
|
| 626 |
+
* making other API calls when using esbuild in the browser.
|
| 627 |
+
*
|
| 628 |
+
* - Works in node: yes
|
| 629 |
+
* - Works in browser: yes ("options" is required)
|
| 630 |
+
*
|
| 631 |
+
* Documentation: https://esbuild.github.io/api/#browser
|
| 632 |
+
*/
|
| 633 |
+
export declare function initialize(options: InitializeOptions): Promise<void>
|
| 634 |
+
|
| 635 |
+
export interface InitializeOptions {
|
| 636 |
+
/**
|
| 637 |
+
* The URL of the "esbuild.wasm" file. This must be provided when running
|
| 638 |
+
* esbuild in the browser.
|
| 639 |
+
*/
|
| 640 |
+
wasmURL?: string | URL
|
| 641 |
+
|
| 642 |
+
/**
|
| 643 |
+
* The result of calling "new WebAssembly.Module(buffer)" where "buffer"
|
| 644 |
+
* is a typed array or ArrayBuffer containing the binary code of the
|
| 645 |
+
* "esbuild.wasm" file.
|
| 646 |
+
*
|
| 647 |
+
* You can use this as an alternative to "wasmURL" for environments where it's
|
| 648 |
+
* not possible to download the WebAssembly module.
|
| 649 |
+
*/
|
| 650 |
+
wasmModule?: WebAssembly.Module
|
| 651 |
+
|
| 652 |
+
/**
|
| 653 |
+
* By default esbuild runs the WebAssembly-based browser API in a web worker
|
| 654 |
+
* to avoid blocking the UI thread. This can be disabled by setting "worker"
|
| 655 |
+
* to false.
|
| 656 |
+
*/
|
| 657 |
+
worker?: boolean
|
| 658 |
+
}
|
| 659 |
+
|
| 660 |
+
export let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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";
|
| 2 |
+
var __create = Object.create;
|
| 3 |
+
var __defProp = Object.defineProperty;
|
| 4 |
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
| 5 |
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
| 6 |
+
var __getProtoOf = Object.getPrototypeOf;
|
| 7 |
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
| 8 |
+
var __export = (target, all) => {
|
| 9 |
+
for (var name in all)
|
| 10 |
+
__defProp(target, name, { get: all[name], enumerable: true });
|
| 11 |
+
};
|
| 12 |
+
var __copyProps = (to, from, except, desc) => {
|
| 13 |
+
if (from && typeof from === "object" || typeof from === "function") {
|
| 14 |
+
for (let key of __getOwnPropNames(from))
|
| 15 |
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
| 16 |
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
| 17 |
+
}
|
| 18 |
+
return to;
|
| 19 |
+
};
|
| 20 |
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
| 21 |
+
// If the importer is in node compatibility mode or this is not an ESM
|
| 22 |
+
// file that has been converted to a CommonJS file using a Babel-
|
| 23 |
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
| 24 |
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
| 25 |
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
| 26 |
+
mod
|
| 27 |
+
));
|
| 28 |
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
| 29 |
+
|
| 30 |
+
// lib/npm/node.ts
|
| 31 |
+
var node_exports = {};
|
| 32 |
+
__export(node_exports, {
|
| 33 |
+
analyzeMetafile: () => analyzeMetafile,
|
| 34 |
+
analyzeMetafileSync: () => analyzeMetafileSync,
|
| 35 |
+
build: () => build,
|
| 36 |
+
buildSync: () => buildSync,
|
| 37 |
+
context: () => context,
|
| 38 |
+
default: () => node_default,
|
| 39 |
+
formatMessages: () => formatMessages,
|
| 40 |
+
formatMessagesSync: () => formatMessagesSync,
|
| 41 |
+
initialize: () => initialize,
|
| 42 |
+
transform: () => transform,
|
| 43 |
+
transformSync: () => transformSync,
|
| 44 |
+
version: () => version
|
| 45 |
+
});
|
| 46 |
+
module.exports = __toCommonJS(node_exports);
|
| 47 |
+
|
| 48 |
+
// lib/shared/stdio_protocol.ts
|
| 49 |
+
function encodePacket(packet) {
|
| 50 |
+
let visit = (value) => {
|
| 51 |
+
if (value === null) {
|
| 52 |
+
bb.write8(0);
|
| 53 |
+
} else if (typeof value === "boolean") {
|
| 54 |
+
bb.write8(1);
|
| 55 |
+
bb.write8(+value);
|
| 56 |
+
} else if (typeof value === "number") {
|
| 57 |
+
bb.write8(2);
|
| 58 |
+
bb.write32(value | 0);
|
| 59 |
+
} else if (typeof value === "string") {
|
| 60 |
+
bb.write8(3);
|
| 61 |
+
bb.write(encodeUTF8(value));
|
| 62 |
+
} else if (value instanceof Uint8Array) {
|
| 63 |
+
bb.write8(4);
|
| 64 |
+
bb.write(value);
|
| 65 |
+
} else if (value instanceof Array) {
|
| 66 |
+
bb.write8(5);
|
| 67 |
+
bb.write32(value.length);
|
| 68 |
+
for (let item of value) {
|
| 69 |
+
visit(item);
|
| 70 |
+
}
|
| 71 |
+
} else {
|
| 72 |
+
let keys = Object.keys(value);
|
| 73 |
+
bb.write8(6);
|
| 74 |
+
bb.write32(keys.length);
|
| 75 |
+
for (let key of keys) {
|
| 76 |
+
bb.write(encodeUTF8(key));
|
| 77 |
+
visit(value[key]);
|
| 78 |
+
}
|
| 79 |
+
}
|
| 80 |
+
};
|
| 81 |
+
let bb = new ByteBuffer();
|
| 82 |
+
bb.write32(0);
|
| 83 |
+
bb.write32(packet.id << 1 | +!packet.isRequest);
|
| 84 |
+
visit(packet.value);
|
| 85 |
+
writeUInt32LE(bb.buf, bb.len - 4, 0);
|
| 86 |
+
return bb.buf.subarray(0, bb.len);
|
| 87 |
+
}
|
| 88 |
+
function decodePacket(bytes) {
|
| 89 |
+
let visit = () => {
|
| 90 |
+
switch (bb.read8()) {
|
| 91 |
+
case 0:
|
| 92 |
+
return null;
|
| 93 |
+
case 1:
|
| 94 |
+
return !!bb.read8();
|
| 95 |
+
case 2:
|
| 96 |
+
return bb.read32();
|
| 97 |
+
case 3:
|
| 98 |
+
return decodeUTF8(bb.read());
|
| 99 |
+
case 4:
|
| 100 |
+
return bb.read();
|
| 101 |
+
case 5: {
|
| 102 |
+
let count = bb.read32();
|
| 103 |
+
let value2 = [];
|
| 104 |
+
for (let i = 0; i < count; i++) {
|
| 105 |
+
value2.push(visit());
|
| 106 |
+
}
|
| 107 |
+
return value2;
|
| 108 |
+
}
|
| 109 |
+
case 6: {
|
| 110 |
+
let count = bb.read32();
|
| 111 |
+
let value2 = {};
|
| 112 |
+
for (let i = 0; i < count; i++) {
|
| 113 |
+
value2[decodeUTF8(bb.read())] = visit();
|
| 114 |
+
}
|
| 115 |
+
return value2;
|
| 116 |
+
}
|
| 117 |
+
default:
|
| 118 |
+
throw new Error("Invalid packet");
|
| 119 |
+
}
|
| 120 |
+
};
|
| 121 |
+
let bb = new ByteBuffer(bytes);
|
| 122 |
+
let id = bb.read32();
|
| 123 |
+
let isRequest = (id & 1) === 0;
|
| 124 |
+
id >>>= 1;
|
| 125 |
+
let value = visit();
|
| 126 |
+
if (bb.ptr !== bytes.length) {
|
| 127 |
+
throw new Error("Invalid packet");
|
| 128 |
+
}
|
| 129 |
+
return { id, isRequest, value };
|
| 130 |
+
}
|
| 131 |
+
var ByteBuffer = class {
|
| 132 |
+
constructor(buf = new Uint8Array(1024)) {
|
| 133 |
+
this.buf = buf;
|
| 134 |
+
this.len = 0;
|
| 135 |
+
this.ptr = 0;
|
| 136 |
+
}
|
| 137 |
+
_write(delta) {
|
| 138 |
+
if (this.len + delta > this.buf.length) {
|
| 139 |
+
let clone = new Uint8Array((this.len + delta) * 2);
|
| 140 |
+
clone.set(this.buf);
|
| 141 |
+
this.buf = clone;
|
| 142 |
+
}
|
| 143 |
+
this.len += delta;
|
| 144 |
+
return this.len - delta;
|
| 145 |
+
}
|
| 146 |
+
write8(value) {
|
| 147 |
+
let offset = this._write(1);
|
| 148 |
+
this.buf[offset] = value;
|
| 149 |
+
}
|
| 150 |
+
write32(value) {
|
| 151 |
+
let offset = this._write(4);
|
| 152 |
+
writeUInt32LE(this.buf, value, offset);
|
| 153 |
+
}
|
| 154 |
+
write(bytes) {
|
| 155 |
+
let offset = this._write(4 + bytes.length);
|
| 156 |
+
writeUInt32LE(this.buf, bytes.length, offset);
|
| 157 |
+
this.buf.set(bytes, offset + 4);
|
| 158 |
+
}
|
| 159 |
+
_read(delta) {
|
| 160 |
+
if (this.ptr + delta > this.buf.length) {
|
| 161 |
+
throw new Error("Invalid packet");
|
| 162 |
+
}
|
| 163 |
+
this.ptr += delta;
|
| 164 |
+
return this.ptr - delta;
|
| 165 |
+
}
|
| 166 |
+
read8() {
|
| 167 |
+
return this.buf[this._read(1)];
|
| 168 |
+
}
|
| 169 |
+
read32() {
|
| 170 |
+
return readUInt32LE(this.buf, this._read(4));
|
| 171 |
+
}
|
| 172 |
+
read() {
|
| 173 |
+
let length = this.read32();
|
| 174 |
+
let bytes = new Uint8Array(length);
|
| 175 |
+
let ptr = this._read(bytes.length);
|
| 176 |
+
bytes.set(this.buf.subarray(ptr, ptr + length));
|
| 177 |
+
return bytes;
|
| 178 |
+
}
|
| 179 |
+
};
|
| 180 |
+
var encodeUTF8;
|
| 181 |
+
var decodeUTF8;
|
| 182 |
+
var encodeInvariant;
|
| 183 |
+
if (typeof TextEncoder !== "undefined" && typeof TextDecoder !== "undefined") {
|
| 184 |
+
let encoder = new TextEncoder();
|
| 185 |
+
let decoder = new TextDecoder();
|
| 186 |
+
encodeUTF8 = (text) => encoder.encode(text);
|
| 187 |
+
decodeUTF8 = (bytes) => decoder.decode(bytes);
|
| 188 |
+
encodeInvariant = 'new TextEncoder().encode("")';
|
| 189 |
+
} else if (typeof Buffer !== "undefined") {
|
| 190 |
+
encodeUTF8 = (text) => Buffer.from(text);
|
| 191 |
+
decodeUTF8 = (bytes) => {
|
| 192 |
+
let { buffer, byteOffset, byteLength } = bytes;
|
| 193 |
+
return Buffer.from(buffer, byteOffset, byteLength).toString();
|
| 194 |
+
};
|
| 195 |
+
encodeInvariant = 'Buffer.from("")';
|
| 196 |
+
} else {
|
| 197 |
+
throw new Error("No UTF-8 codec found");
|
| 198 |
+
}
|
| 199 |
+
if (!(encodeUTF8("") instanceof Uint8Array))
|
| 200 |
+
throw new Error(`Invariant violation: "${encodeInvariant} instanceof Uint8Array" is incorrectly false
|
| 201 |
+
|
| 202 |
+
This indicates that your JavaScript environment is broken. You cannot use
|
| 203 |
+
esbuild in this environment because esbuild relies on this invariant. This
|
| 204 |
+
is not a problem with esbuild. You need to fix your environment instead.
|
| 205 |
+
`);
|
| 206 |
+
function readUInt32LE(buffer, offset) {
|
| 207 |
+
return buffer[offset++] | buffer[offset++] << 8 | buffer[offset++] << 16 | buffer[offset++] << 24;
|
| 208 |
+
}
|
| 209 |
+
function writeUInt32LE(buffer, value, offset) {
|
| 210 |
+
buffer[offset++] = value;
|
| 211 |
+
buffer[offset++] = value >> 8;
|
| 212 |
+
buffer[offset++] = value >> 16;
|
| 213 |
+
buffer[offset++] = value >> 24;
|
| 214 |
+
}
|
| 215 |
+
|
| 216 |
+
// lib/shared/common.ts
|
| 217 |
+
var quote = JSON.stringify;
|
| 218 |
+
var buildLogLevelDefault = "warning";
|
| 219 |
+
var transformLogLevelDefault = "silent";
|
| 220 |
+
function validateTarget(target) {
|
| 221 |
+
validateStringValue(target, "target");
|
| 222 |
+
if (target.indexOf(",") >= 0)
|
| 223 |
+
throw new Error(`Invalid target: ${target}`);
|
| 224 |
+
return target;
|
| 225 |
+
}
|
| 226 |
+
var canBeAnything = () => null;
|
| 227 |
+
var mustBeBoolean = (value) => typeof value === "boolean" ? null : "a boolean";
|
| 228 |
+
var mustBeString = (value) => typeof value === "string" ? null : "a string";
|
| 229 |
+
var mustBeRegExp = (value) => value instanceof RegExp ? null : "a RegExp object";
|
| 230 |
+
var mustBeInteger = (value) => typeof value === "number" && value === (value | 0) ? null : "an integer";
|
| 231 |
+
var mustBeFunction = (value) => typeof value === "function" ? null : "a function";
|
| 232 |
+
var mustBeArray = (value) => Array.isArray(value) ? null : "an array";
|
| 233 |
+
var mustBeObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value) ? null : "an object";
|
| 234 |
+
var mustBeEntryPoints = (value) => typeof value === "object" && value !== null ? null : "an array or an object";
|
| 235 |
+
var mustBeWebAssemblyModule = (value) => value instanceof WebAssembly.Module ? null : "a WebAssembly.Module";
|
| 236 |
+
var mustBeObjectOrNull = (value) => typeof value === "object" && !Array.isArray(value) ? null : "an object or null";
|
| 237 |
+
var mustBeStringOrBoolean = (value) => typeof value === "string" || typeof value === "boolean" ? null : "a string or a boolean";
|
| 238 |
+
var mustBeStringOrObject = (value) => typeof value === "string" || typeof value === "object" && value !== null && !Array.isArray(value) ? null : "a string or an object";
|
| 239 |
+
var mustBeStringOrArray = (value) => typeof value === "string" || Array.isArray(value) ? null : "a string or an array";
|
| 240 |
+
var mustBeStringOrUint8Array = (value) => typeof value === "string" || value instanceof Uint8Array ? null : "a string or a Uint8Array";
|
| 241 |
+
var mustBeStringOrURL = (value) => typeof value === "string" || value instanceof URL ? null : "a string or a URL";
|
| 242 |
+
function getFlag(object, keys, key, mustBeFn) {
|
| 243 |
+
let value = object[key];
|
| 244 |
+
keys[key + ""] = true;
|
| 245 |
+
if (value === void 0)
|
| 246 |
+
return void 0;
|
| 247 |
+
let mustBe = mustBeFn(value);
|
| 248 |
+
if (mustBe !== null)
|
| 249 |
+
throw new Error(`${quote(key)} must be ${mustBe}`);
|
| 250 |
+
return value;
|
| 251 |
+
}
|
| 252 |
+
function checkForInvalidFlags(object, keys, where) {
|
| 253 |
+
for (let key in object) {
|
| 254 |
+
if (!(key in keys)) {
|
| 255 |
+
throw new Error(`Invalid option ${where}: ${quote(key)}`);
|
| 256 |
+
}
|
| 257 |
+
}
|
| 258 |
+
}
|
| 259 |
+
function validateInitializeOptions(options) {
|
| 260 |
+
let keys = /* @__PURE__ */ Object.create(null);
|
| 261 |
+
let wasmURL = getFlag(options, keys, "wasmURL", mustBeStringOrURL);
|
| 262 |
+
let wasmModule = getFlag(options, keys, "wasmModule", mustBeWebAssemblyModule);
|
| 263 |
+
let worker = getFlag(options, keys, "worker", mustBeBoolean);
|
| 264 |
+
checkForInvalidFlags(options, keys, "in initialize() call");
|
| 265 |
+
return {
|
| 266 |
+
wasmURL,
|
| 267 |
+
wasmModule,
|
| 268 |
+
worker
|
| 269 |
+
};
|
| 270 |
+
}
|
| 271 |
+
function validateMangleCache(mangleCache) {
|
| 272 |
+
let validated;
|
| 273 |
+
if (mangleCache !== void 0) {
|
| 274 |
+
validated = /* @__PURE__ */ Object.create(null);
|
| 275 |
+
for (let key in mangleCache) {
|
| 276 |
+
let value = mangleCache[key];
|
| 277 |
+
if (typeof value === "string" || value === false) {
|
| 278 |
+
validated[key] = value;
|
| 279 |
+
} else {
|
| 280 |
+
throw new Error(`Expected ${quote(key)} in mangle cache to map to either a string or false`);
|
| 281 |
+
}
|
| 282 |
+
}
|
| 283 |
+
}
|
| 284 |
+
return validated;
|
| 285 |
+
}
|
| 286 |
+
function pushLogFlags(flags, options, keys, isTTY2, logLevelDefault) {
|
| 287 |
+
let color = getFlag(options, keys, "color", mustBeBoolean);
|
| 288 |
+
let logLevel = getFlag(options, keys, "logLevel", mustBeString);
|
| 289 |
+
let logLimit = getFlag(options, keys, "logLimit", mustBeInteger);
|
| 290 |
+
if (color !== void 0)
|
| 291 |
+
flags.push(`--color=${color}`);
|
| 292 |
+
else if (isTTY2)
|
| 293 |
+
flags.push(`--color=true`);
|
| 294 |
+
flags.push(`--log-level=${logLevel || logLevelDefault}`);
|
| 295 |
+
flags.push(`--log-limit=${logLimit || 0}`);
|
| 296 |
+
}
|
| 297 |
+
function validateStringValue(value, what, key) {
|
| 298 |
+
if (typeof value !== "string") {
|
| 299 |
+
throw new Error(`Expected value for ${what}${key !== void 0 ? " " + quote(key) : ""} to be a string, got ${typeof value} instead`);
|
| 300 |
+
}
|
| 301 |
+
return value;
|
| 302 |
+
}
|
| 303 |
+
function pushCommonFlags(flags, options, keys) {
|
| 304 |
+
let legalComments = getFlag(options, keys, "legalComments", mustBeString);
|
| 305 |
+
let sourceRoot = getFlag(options, keys, "sourceRoot", mustBeString);
|
| 306 |
+
let sourcesContent = getFlag(options, keys, "sourcesContent", mustBeBoolean);
|
| 307 |
+
let target = getFlag(options, keys, "target", mustBeStringOrArray);
|
| 308 |
+
let format = getFlag(options, keys, "format", mustBeString);
|
| 309 |
+
let globalName = getFlag(options, keys, "globalName", mustBeString);
|
| 310 |
+
let mangleProps = getFlag(options, keys, "mangleProps", mustBeRegExp);
|
| 311 |
+
let reserveProps = getFlag(options, keys, "reserveProps", mustBeRegExp);
|
| 312 |
+
let mangleQuoted = getFlag(options, keys, "mangleQuoted", mustBeBoolean);
|
| 313 |
+
let minify = getFlag(options, keys, "minify", mustBeBoolean);
|
| 314 |
+
let minifySyntax = getFlag(options, keys, "minifySyntax", mustBeBoolean);
|
| 315 |
+
let minifyWhitespace = getFlag(options, keys, "minifyWhitespace", mustBeBoolean);
|
| 316 |
+
let minifyIdentifiers = getFlag(options, keys, "minifyIdentifiers", mustBeBoolean);
|
| 317 |
+
let lineLimit = getFlag(options, keys, "lineLimit", mustBeInteger);
|
| 318 |
+
let drop = getFlag(options, keys, "drop", mustBeArray);
|
| 319 |
+
let dropLabels = getFlag(options, keys, "dropLabels", mustBeArray);
|
| 320 |
+
let charset = getFlag(options, keys, "charset", mustBeString);
|
| 321 |
+
let treeShaking = getFlag(options, keys, "treeShaking", mustBeBoolean);
|
| 322 |
+
let ignoreAnnotations = getFlag(options, keys, "ignoreAnnotations", mustBeBoolean);
|
| 323 |
+
let jsx = getFlag(options, keys, "jsx", mustBeString);
|
| 324 |
+
let jsxFactory = getFlag(options, keys, "jsxFactory", mustBeString);
|
| 325 |
+
let jsxFragment = getFlag(options, keys, "jsxFragment", mustBeString);
|
| 326 |
+
let jsxImportSource = getFlag(options, keys, "jsxImportSource", mustBeString);
|
| 327 |
+
let jsxDev = getFlag(options, keys, "jsxDev", mustBeBoolean);
|
| 328 |
+
let jsxSideEffects = getFlag(options, keys, "jsxSideEffects", mustBeBoolean);
|
| 329 |
+
let define = getFlag(options, keys, "define", mustBeObject);
|
| 330 |
+
let logOverride = getFlag(options, keys, "logOverride", mustBeObject);
|
| 331 |
+
let supported = getFlag(options, keys, "supported", mustBeObject);
|
| 332 |
+
let pure = getFlag(options, keys, "pure", mustBeArray);
|
| 333 |
+
let keepNames = getFlag(options, keys, "keepNames", mustBeBoolean);
|
| 334 |
+
let platform = getFlag(options, keys, "platform", mustBeString);
|
| 335 |
+
let tsconfigRaw = getFlag(options, keys, "tsconfigRaw", mustBeStringOrObject);
|
| 336 |
+
if (legalComments)
|
| 337 |
+
flags.push(`--legal-comments=${legalComments}`);
|
| 338 |
+
if (sourceRoot !== void 0)
|
| 339 |
+
flags.push(`--source-root=${sourceRoot}`);
|
| 340 |
+
if (sourcesContent !== void 0)
|
| 341 |
+
flags.push(`--sources-content=${sourcesContent}`);
|
| 342 |
+
if (target) {
|
| 343 |
+
if (Array.isArray(target))
|
| 344 |
+
flags.push(`--target=${Array.from(target).map(validateTarget).join(",")}`);
|
| 345 |
+
else
|
| 346 |
+
flags.push(`--target=${validateTarget(target)}`);
|
| 347 |
+
}
|
| 348 |
+
if (format)
|
| 349 |
+
flags.push(`--format=${format}`);
|
| 350 |
+
if (globalName)
|
| 351 |
+
flags.push(`--global-name=${globalName}`);
|
| 352 |
+
if (platform)
|
| 353 |
+
flags.push(`--platform=${platform}`);
|
| 354 |
+
if (tsconfigRaw)
|
| 355 |
+
flags.push(`--tsconfig-raw=${typeof tsconfigRaw === "string" ? tsconfigRaw : JSON.stringify(tsconfigRaw)}`);
|
| 356 |
+
if (minify)
|
| 357 |
+
flags.push("--minify");
|
| 358 |
+
if (minifySyntax)
|
| 359 |
+
flags.push("--minify-syntax");
|
| 360 |
+
if (minifyWhitespace)
|
| 361 |
+
flags.push("--minify-whitespace");
|
| 362 |
+
if (minifyIdentifiers)
|
| 363 |
+
flags.push("--minify-identifiers");
|
| 364 |
+
if (lineLimit)
|
| 365 |
+
flags.push(`--line-limit=${lineLimit}`);
|
| 366 |
+
if (charset)
|
| 367 |
+
flags.push(`--charset=${charset}`);
|
| 368 |
+
if (treeShaking !== void 0)
|
| 369 |
+
flags.push(`--tree-shaking=${treeShaking}`);
|
| 370 |
+
if (ignoreAnnotations)
|
| 371 |
+
flags.push(`--ignore-annotations`);
|
| 372 |
+
if (drop)
|
| 373 |
+
for (let what of drop)
|
| 374 |
+
flags.push(`--drop:${validateStringValue(what, "drop")}`);
|
| 375 |
+
if (dropLabels)
|
| 376 |
+
flags.push(`--drop-labels=${Array.from(dropLabels).map((what) => validateStringValue(what, "dropLabels")).join(",")}`);
|
| 377 |
+
if (mangleProps)
|
| 378 |
+
flags.push(`--mangle-props=${mangleProps.source}`);
|
| 379 |
+
if (reserveProps)
|
| 380 |
+
flags.push(`--reserve-props=${reserveProps.source}`);
|
| 381 |
+
if (mangleQuoted !== void 0)
|
| 382 |
+
flags.push(`--mangle-quoted=${mangleQuoted}`);
|
| 383 |
+
if (jsx)
|
| 384 |
+
flags.push(`--jsx=${jsx}`);
|
| 385 |
+
if (jsxFactory)
|
| 386 |
+
flags.push(`--jsx-factory=${jsxFactory}`);
|
| 387 |
+
if (jsxFragment)
|
| 388 |
+
flags.push(`--jsx-fragment=${jsxFragment}`);
|
| 389 |
+
if (jsxImportSource)
|
| 390 |
+
flags.push(`--jsx-import-source=${jsxImportSource}`);
|
| 391 |
+
if (jsxDev)
|
| 392 |
+
flags.push(`--jsx-dev`);
|
| 393 |
+
if (jsxSideEffects)
|
| 394 |
+
flags.push(`--jsx-side-effects`);
|
| 395 |
+
if (define) {
|
| 396 |
+
for (let key in define) {
|
| 397 |
+
if (key.indexOf("=") >= 0)
|
| 398 |
+
throw new Error(`Invalid define: ${key}`);
|
| 399 |
+
flags.push(`--define:${key}=${validateStringValue(define[key], "define", key)}`);
|
| 400 |
+
}
|
| 401 |
+
}
|
| 402 |
+
if (logOverride) {
|
| 403 |
+
for (let key in logOverride) {
|
| 404 |
+
if (key.indexOf("=") >= 0)
|
| 405 |
+
throw new Error(`Invalid log override: ${key}`);
|
| 406 |
+
flags.push(`--log-override:${key}=${validateStringValue(logOverride[key], "log override", key)}`);
|
| 407 |
+
}
|
| 408 |
+
}
|
| 409 |
+
if (supported) {
|
| 410 |
+
for (let key in supported) {
|
| 411 |
+
if (key.indexOf("=") >= 0)
|
| 412 |
+
throw new Error(`Invalid supported: ${key}`);
|
| 413 |
+
const value = supported[key];
|
| 414 |
+
if (typeof value !== "boolean")
|
| 415 |
+
throw new Error(`Expected value for supported ${quote(key)} to be a boolean, got ${typeof value} instead`);
|
| 416 |
+
flags.push(`--supported:${key}=${value}`);
|
| 417 |
+
}
|
| 418 |
+
}
|
| 419 |
+
if (pure)
|
| 420 |
+
for (let fn of pure)
|
| 421 |
+
flags.push(`--pure:${validateStringValue(fn, "pure")}`);
|
| 422 |
+
if (keepNames)
|
| 423 |
+
flags.push(`--keep-names`);
|
| 424 |
+
}
|
| 425 |
+
function flagsForBuildOptions(callName, options, isTTY2, logLevelDefault, writeDefault) {
|
| 426 |
+
var _a2;
|
| 427 |
+
let flags = [];
|
| 428 |
+
let entries = [];
|
| 429 |
+
let keys = /* @__PURE__ */ Object.create(null);
|
| 430 |
+
let stdinContents = null;
|
| 431 |
+
let stdinResolveDir = null;
|
| 432 |
+
pushLogFlags(flags, options, keys, isTTY2, logLevelDefault);
|
| 433 |
+
pushCommonFlags(flags, options, keys);
|
| 434 |
+
let sourcemap = getFlag(options, keys, "sourcemap", mustBeStringOrBoolean);
|
| 435 |
+
let bundle = getFlag(options, keys, "bundle", mustBeBoolean);
|
| 436 |
+
let splitting = getFlag(options, keys, "splitting", mustBeBoolean);
|
| 437 |
+
let preserveSymlinks = getFlag(options, keys, "preserveSymlinks", mustBeBoolean);
|
| 438 |
+
let metafile = getFlag(options, keys, "metafile", mustBeBoolean);
|
| 439 |
+
let outfile = getFlag(options, keys, "outfile", mustBeString);
|
| 440 |
+
let outdir = getFlag(options, keys, "outdir", mustBeString);
|
| 441 |
+
let outbase = getFlag(options, keys, "outbase", mustBeString);
|
| 442 |
+
let tsconfig = getFlag(options, keys, "tsconfig", mustBeString);
|
| 443 |
+
let resolveExtensions = getFlag(options, keys, "resolveExtensions", mustBeArray);
|
| 444 |
+
let nodePathsInput = getFlag(options, keys, "nodePaths", mustBeArray);
|
| 445 |
+
let mainFields = getFlag(options, keys, "mainFields", mustBeArray);
|
| 446 |
+
let conditions = getFlag(options, keys, "conditions", mustBeArray);
|
| 447 |
+
let external = getFlag(options, keys, "external", mustBeArray);
|
| 448 |
+
let packages = getFlag(options, keys, "packages", mustBeString);
|
| 449 |
+
let alias = getFlag(options, keys, "alias", mustBeObject);
|
| 450 |
+
let loader = getFlag(options, keys, "loader", mustBeObject);
|
| 451 |
+
let outExtension = getFlag(options, keys, "outExtension", mustBeObject);
|
| 452 |
+
let publicPath = getFlag(options, keys, "publicPath", mustBeString);
|
| 453 |
+
let entryNames = getFlag(options, keys, "entryNames", mustBeString);
|
| 454 |
+
let chunkNames = getFlag(options, keys, "chunkNames", mustBeString);
|
| 455 |
+
let assetNames = getFlag(options, keys, "assetNames", mustBeString);
|
| 456 |
+
let inject = getFlag(options, keys, "inject", mustBeArray);
|
| 457 |
+
let banner = getFlag(options, keys, "banner", mustBeObject);
|
| 458 |
+
let footer = getFlag(options, keys, "footer", mustBeObject);
|
| 459 |
+
let entryPoints = getFlag(options, keys, "entryPoints", mustBeEntryPoints);
|
| 460 |
+
let absWorkingDir = getFlag(options, keys, "absWorkingDir", mustBeString);
|
| 461 |
+
let stdin = getFlag(options, keys, "stdin", mustBeObject);
|
| 462 |
+
let write = (_a2 = getFlag(options, keys, "write", mustBeBoolean)) != null ? _a2 : writeDefault;
|
| 463 |
+
let allowOverwrite = getFlag(options, keys, "allowOverwrite", mustBeBoolean);
|
| 464 |
+
let mangleCache = getFlag(options, keys, "mangleCache", mustBeObject);
|
| 465 |
+
keys.plugins = true;
|
| 466 |
+
checkForInvalidFlags(options, keys, `in ${callName}() call`);
|
| 467 |
+
if (sourcemap)
|
| 468 |
+
flags.push(`--sourcemap${sourcemap === true ? "" : `=${sourcemap}`}`);
|
| 469 |
+
if (bundle)
|
| 470 |
+
flags.push("--bundle");
|
| 471 |
+
if (allowOverwrite)
|
| 472 |
+
flags.push("--allow-overwrite");
|
| 473 |
+
if (splitting)
|
| 474 |
+
flags.push("--splitting");
|
| 475 |
+
if (preserveSymlinks)
|
| 476 |
+
flags.push("--preserve-symlinks");
|
| 477 |
+
if (metafile)
|
| 478 |
+
flags.push(`--metafile`);
|
| 479 |
+
if (outfile)
|
| 480 |
+
flags.push(`--outfile=${outfile}`);
|
| 481 |
+
if (outdir)
|
| 482 |
+
flags.push(`--outdir=${outdir}`);
|
| 483 |
+
if (outbase)
|
| 484 |
+
flags.push(`--outbase=${outbase}`);
|
| 485 |
+
if (tsconfig)
|
| 486 |
+
flags.push(`--tsconfig=${tsconfig}`);
|
| 487 |
+
if (packages)
|
| 488 |
+
flags.push(`--packages=${packages}`);
|
| 489 |
+
if (resolveExtensions) {
|
| 490 |
+
let values = [];
|
| 491 |
+
for (let value of resolveExtensions) {
|
| 492 |
+
validateStringValue(value, "resolve extension");
|
| 493 |
+
if (value.indexOf(",") >= 0)
|
| 494 |
+
throw new Error(`Invalid resolve extension: ${value}`);
|
| 495 |
+
values.push(value);
|
| 496 |
+
}
|
| 497 |
+
flags.push(`--resolve-extensions=${values.join(",")}`);
|
| 498 |
+
}
|
| 499 |
+
if (publicPath)
|
| 500 |
+
flags.push(`--public-path=${publicPath}`);
|
| 501 |
+
if (entryNames)
|
| 502 |
+
flags.push(`--entry-names=${entryNames}`);
|
| 503 |
+
if (chunkNames)
|
| 504 |
+
flags.push(`--chunk-names=${chunkNames}`);
|
| 505 |
+
if (assetNames)
|
| 506 |
+
flags.push(`--asset-names=${assetNames}`);
|
| 507 |
+
if (mainFields) {
|
| 508 |
+
let values = [];
|
| 509 |
+
for (let value of mainFields) {
|
| 510 |
+
validateStringValue(value, "main field");
|
| 511 |
+
if (value.indexOf(",") >= 0)
|
| 512 |
+
throw new Error(`Invalid main field: ${value}`);
|
| 513 |
+
values.push(value);
|
| 514 |
+
}
|
| 515 |
+
flags.push(`--main-fields=${values.join(",")}`);
|
| 516 |
+
}
|
| 517 |
+
if (conditions) {
|
| 518 |
+
let values = [];
|
| 519 |
+
for (let value of conditions) {
|
| 520 |
+
validateStringValue(value, "condition");
|
| 521 |
+
if (value.indexOf(",") >= 0)
|
| 522 |
+
throw new Error(`Invalid condition: ${value}`);
|
| 523 |
+
values.push(value);
|
| 524 |
+
}
|
| 525 |
+
flags.push(`--conditions=${values.join(",")}`);
|
| 526 |
+
}
|
| 527 |
+
if (external)
|
| 528 |
+
for (let name of external)
|
| 529 |
+
flags.push(`--external:${validateStringValue(name, "external")}`);
|
| 530 |
+
if (alias) {
|
| 531 |
+
for (let old in alias) {
|
| 532 |
+
if (old.indexOf("=") >= 0)
|
| 533 |
+
throw new Error(`Invalid package name in alias: ${old}`);
|
| 534 |
+
flags.push(`--alias:${old}=${validateStringValue(alias[old], "alias", old)}`);
|
| 535 |
+
}
|
| 536 |
+
}
|
| 537 |
+
if (banner) {
|
| 538 |
+
for (let type in banner) {
|
| 539 |
+
if (type.indexOf("=") >= 0)
|
| 540 |
+
throw new Error(`Invalid banner file type: ${type}`);
|
| 541 |
+
flags.push(`--banner:${type}=${validateStringValue(banner[type], "banner", type)}`);
|
| 542 |
+
}
|
| 543 |
+
}
|
| 544 |
+
if (footer) {
|
| 545 |
+
for (let type in footer) {
|
| 546 |
+
if (type.indexOf("=") >= 0)
|
| 547 |
+
throw new Error(`Invalid footer file type: ${type}`);
|
| 548 |
+
flags.push(`--footer:${type}=${validateStringValue(footer[type], "footer", type)}`);
|
| 549 |
+
}
|
| 550 |
+
}
|
| 551 |
+
if (inject)
|
| 552 |
+
for (let path3 of inject)
|
| 553 |
+
flags.push(`--inject:${validateStringValue(path3, "inject")}`);
|
| 554 |
+
if (loader) {
|
| 555 |
+
for (let ext in loader) {
|
| 556 |
+
if (ext.indexOf("=") >= 0)
|
| 557 |
+
throw new Error(`Invalid loader extension: ${ext}`);
|
| 558 |
+
flags.push(`--loader:${ext}=${validateStringValue(loader[ext], "loader", ext)}`);
|
| 559 |
+
}
|
| 560 |
+
}
|
| 561 |
+
if (outExtension) {
|
| 562 |
+
for (let ext in outExtension) {
|
| 563 |
+
if (ext.indexOf("=") >= 0)
|
| 564 |
+
throw new Error(`Invalid out extension: ${ext}`);
|
| 565 |
+
flags.push(`--out-extension:${ext}=${validateStringValue(outExtension[ext], "out extension", ext)}`);
|
| 566 |
+
}
|
| 567 |
+
}
|
| 568 |
+
if (entryPoints) {
|
| 569 |
+
if (Array.isArray(entryPoints)) {
|
| 570 |
+
for (let i = 0, n = entryPoints.length; i < n; i++) {
|
| 571 |
+
let entryPoint = entryPoints[i];
|
| 572 |
+
if (typeof entryPoint === "object" && entryPoint !== null) {
|
| 573 |
+
let entryPointKeys = /* @__PURE__ */ Object.create(null);
|
| 574 |
+
let input = getFlag(entryPoint, entryPointKeys, "in", mustBeString);
|
| 575 |
+
let output = getFlag(entryPoint, entryPointKeys, "out", mustBeString);
|
| 576 |
+
checkForInvalidFlags(entryPoint, entryPointKeys, "in entry point at index " + i);
|
| 577 |
+
if (input === void 0)
|
| 578 |
+
throw new Error('Missing property "in" for entry point at index ' + i);
|
| 579 |
+
if (output === void 0)
|
| 580 |
+
throw new Error('Missing property "out" for entry point at index ' + i);
|
| 581 |
+
entries.push([output, input]);
|
| 582 |
+
} else {
|
| 583 |
+
entries.push(["", validateStringValue(entryPoint, "entry point at index " + i)]);
|
| 584 |
+
}
|
| 585 |
+
}
|
| 586 |
+
} else {
|
| 587 |
+
for (let key in entryPoints) {
|
| 588 |
+
entries.push([key, validateStringValue(entryPoints[key], "entry point", key)]);
|
| 589 |
+
}
|
| 590 |
+
}
|
| 591 |
+
}
|
| 592 |
+
if (stdin) {
|
| 593 |
+
let stdinKeys = /* @__PURE__ */ Object.create(null);
|
| 594 |
+
let contents = getFlag(stdin, stdinKeys, "contents", mustBeStringOrUint8Array);
|
| 595 |
+
let resolveDir = getFlag(stdin, stdinKeys, "resolveDir", mustBeString);
|
| 596 |
+
let sourcefile = getFlag(stdin, stdinKeys, "sourcefile", mustBeString);
|
| 597 |
+
let loader2 = getFlag(stdin, stdinKeys, "loader", mustBeString);
|
| 598 |
+
checkForInvalidFlags(stdin, stdinKeys, 'in "stdin" object');
|
| 599 |
+
if (sourcefile)
|
| 600 |
+
flags.push(`--sourcefile=${sourcefile}`);
|
| 601 |
+
if (loader2)
|
| 602 |
+
flags.push(`--loader=${loader2}`);
|
| 603 |
+
if (resolveDir)
|
| 604 |
+
stdinResolveDir = resolveDir;
|
| 605 |
+
if (typeof contents === "string")
|
| 606 |
+
stdinContents = encodeUTF8(contents);
|
| 607 |
+
else if (contents instanceof Uint8Array)
|
| 608 |
+
stdinContents = contents;
|
| 609 |
+
}
|
| 610 |
+
let nodePaths = [];
|
| 611 |
+
if (nodePathsInput) {
|
| 612 |
+
for (let value of nodePathsInput) {
|
| 613 |
+
value += "";
|
| 614 |
+
nodePaths.push(value);
|
| 615 |
+
}
|
| 616 |
+
}
|
| 617 |
+
return {
|
| 618 |
+
entries,
|
| 619 |
+
flags,
|
| 620 |
+
write,
|
| 621 |
+
stdinContents,
|
| 622 |
+
stdinResolveDir,
|
| 623 |
+
absWorkingDir,
|
| 624 |
+
nodePaths,
|
| 625 |
+
mangleCache: validateMangleCache(mangleCache)
|
| 626 |
+
};
|
| 627 |
+
}
|
| 628 |
+
function flagsForTransformOptions(callName, options, isTTY2, logLevelDefault) {
|
| 629 |
+
let flags = [];
|
| 630 |
+
let keys = /* @__PURE__ */ Object.create(null);
|
| 631 |
+
pushLogFlags(flags, options, keys, isTTY2, logLevelDefault);
|
| 632 |
+
pushCommonFlags(flags, options, keys);
|
| 633 |
+
let sourcemap = getFlag(options, keys, "sourcemap", mustBeStringOrBoolean);
|
| 634 |
+
let sourcefile = getFlag(options, keys, "sourcefile", mustBeString);
|
| 635 |
+
let loader = getFlag(options, keys, "loader", mustBeString);
|
| 636 |
+
let banner = getFlag(options, keys, "banner", mustBeString);
|
| 637 |
+
let footer = getFlag(options, keys, "footer", mustBeString);
|
| 638 |
+
let mangleCache = getFlag(options, keys, "mangleCache", mustBeObject);
|
| 639 |
+
checkForInvalidFlags(options, keys, `in ${callName}() call`);
|
| 640 |
+
if (sourcemap)
|
| 641 |
+
flags.push(`--sourcemap=${sourcemap === true ? "external" : sourcemap}`);
|
| 642 |
+
if (sourcefile)
|
| 643 |
+
flags.push(`--sourcefile=${sourcefile}`);
|
| 644 |
+
if (loader)
|
| 645 |
+
flags.push(`--loader=${loader}`);
|
| 646 |
+
if (banner)
|
| 647 |
+
flags.push(`--banner=${banner}`);
|
| 648 |
+
if (footer)
|
| 649 |
+
flags.push(`--footer=${footer}`);
|
| 650 |
+
return {
|
| 651 |
+
flags,
|
| 652 |
+
mangleCache: validateMangleCache(mangleCache)
|
| 653 |
+
};
|
| 654 |
+
}
|
| 655 |
+
function createChannel(streamIn) {
|
| 656 |
+
const requestCallbacksByKey = {};
|
| 657 |
+
const closeData = { didClose: false, reason: "" };
|
| 658 |
+
let responseCallbacks = {};
|
| 659 |
+
let nextRequestID = 0;
|
| 660 |
+
let nextBuildKey = 0;
|
| 661 |
+
let stdout = new Uint8Array(16 * 1024);
|
| 662 |
+
let stdoutUsed = 0;
|
| 663 |
+
let readFromStdout = (chunk) => {
|
| 664 |
+
let limit = stdoutUsed + chunk.length;
|
| 665 |
+
if (limit > stdout.length) {
|
| 666 |
+
let swap = new Uint8Array(limit * 2);
|
| 667 |
+
swap.set(stdout);
|
| 668 |
+
stdout = swap;
|
| 669 |
+
}
|
| 670 |
+
stdout.set(chunk, stdoutUsed);
|
| 671 |
+
stdoutUsed += chunk.length;
|
| 672 |
+
let offset = 0;
|
| 673 |
+
while (offset + 4 <= stdoutUsed) {
|
| 674 |
+
let length = readUInt32LE(stdout, offset);
|
| 675 |
+
if (offset + 4 + length > stdoutUsed) {
|
| 676 |
+
break;
|
| 677 |
+
}
|
| 678 |
+
offset += 4;
|
| 679 |
+
handleIncomingPacket(stdout.subarray(offset, offset + length));
|
| 680 |
+
offset += length;
|
| 681 |
+
}
|
| 682 |
+
if (offset > 0) {
|
| 683 |
+
stdout.copyWithin(0, offset, stdoutUsed);
|
| 684 |
+
stdoutUsed -= offset;
|
| 685 |
+
}
|
| 686 |
+
};
|
| 687 |
+
let afterClose = (error) => {
|
| 688 |
+
closeData.didClose = true;
|
| 689 |
+
if (error)
|
| 690 |
+
closeData.reason = ": " + (error.message || error);
|
| 691 |
+
const text = "The service was stopped" + closeData.reason;
|
| 692 |
+
for (let id in responseCallbacks) {
|
| 693 |
+
responseCallbacks[id](text, null);
|
| 694 |
+
}
|
| 695 |
+
responseCallbacks = {};
|
| 696 |
+
};
|
| 697 |
+
let sendRequest = (refs, value, callback) => {
|
| 698 |
+
if (closeData.didClose)
|
| 699 |
+
return callback("The service is no longer running" + closeData.reason, null);
|
| 700 |
+
let id = nextRequestID++;
|
| 701 |
+
responseCallbacks[id] = (error, response) => {
|
| 702 |
+
try {
|
| 703 |
+
callback(error, response);
|
| 704 |
+
} finally {
|
| 705 |
+
if (refs)
|
| 706 |
+
refs.unref();
|
| 707 |
+
}
|
| 708 |
+
};
|
| 709 |
+
if (refs)
|
| 710 |
+
refs.ref();
|
| 711 |
+
streamIn.writeToStdin(encodePacket({ id, isRequest: true, value }));
|
| 712 |
+
};
|
| 713 |
+
let sendResponse = (id, value) => {
|
| 714 |
+
if (closeData.didClose)
|
| 715 |
+
throw new Error("The service is no longer running" + closeData.reason);
|
| 716 |
+
streamIn.writeToStdin(encodePacket({ id, isRequest: false, value }));
|
| 717 |
+
};
|
| 718 |
+
let handleRequest = async (id, request) => {
|
| 719 |
+
try {
|
| 720 |
+
if (request.command === "ping") {
|
| 721 |
+
sendResponse(id, {});
|
| 722 |
+
return;
|
| 723 |
+
}
|
| 724 |
+
if (typeof request.key === "number") {
|
| 725 |
+
const requestCallbacks = requestCallbacksByKey[request.key];
|
| 726 |
+
if (requestCallbacks) {
|
| 727 |
+
const callback = requestCallbacks[request.command];
|
| 728 |
+
if (callback) {
|
| 729 |
+
await callback(id, request);
|
| 730 |
+
return;
|
| 731 |
+
}
|
| 732 |
+
}
|
| 733 |
+
}
|
| 734 |
+
throw new Error(`Invalid command: ` + request.command);
|
| 735 |
+
} catch (e) {
|
| 736 |
+
const errors = [extractErrorMessageV8(e, streamIn, null, void 0, "")];
|
| 737 |
+
try {
|
| 738 |
+
sendResponse(id, { errors });
|
| 739 |
+
} catch {
|
| 740 |
+
}
|
| 741 |
+
}
|
| 742 |
+
};
|
| 743 |
+
let isFirstPacket = true;
|
| 744 |
+
let handleIncomingPacket = (bytes) => {
|
| 745 |
+
if (isFirstPacket) {
|
| 746 |
+
isFirstPacket = false;
|
| 747 |
+
let binaryVersion = String.fromCharCode(...bytes);
|
| 748 |
+
if (binaryVersion !== "0.18.20") {
|
| 749 |
+
throw new Error(`Cannot start service: Host version "${"0.18.20"}" does not match binary version ${quote(binaryVersion)}`);
|
| 750 |
+
}
|
| 751 |
+
return;
|
| 752 |
+
}
|
| 753 |
+
let packet = decodePacket(bytes);
|
| 754 |
+
if (packet.isRequest) {
|
| 755 |
+
handleRequest(packet.id, packet.value);
|
| 756 |
+
} else {
|
| 757 |
+
let callback = responseCallbacks[packet.id];
|
| 758 |
+
delete responseCallbacks[packet.id];
|
| 759 |
+
if (packet.value.error)
|
| 760 |
+
callback(packet.value.error, {});
|
| 761 |
+
else
|
| 762 |
+
callback(null, packet.value);
|
| 763 |
+
}
|
| 764 |
+
};
|
| 765 |
+
let buildOrContext = ({ callName, refs, options, isTTY: isTTY2, defaultWD: defaultWD2, callback }) => {
|
| 766 |
+
let refCount = 0;
|
| 767 |
+
const buildKey = nextBuildKey++;
|
| 768 |
+
const requestCallbacks = {};
|
| 769 |
+
const buildRefs = {
|
| 770 |
+
ref() {
|
| 771 |
+
if (++refCount === 1) {
|
| 772 |
+
if (refs)
|
| 773 |
+
refs.ref();
|
| 774 |
+
}
|
| 775 |
+
},
|
| 776 |
+
unref() {
|
| 777 |
+
if (--refCount === 0) {
|
| 778 |
+
delete requestCallbacksByKey[buildKey];
|
| 779 |
+
if (refs)
|
| 780 |
+
refs.unref();
|
| 781 |
+
}
|
| 782 |
+
}
|
| 783 |
+
};
|
| 784 |
+
requestCallbacksByKey[buildKey] = requestCallbacks;
|
| 785 |
+
buildRefs.ref();
|
| 786 |
+
buildOrContextImpl(
|
| 787 |
+
callName,
|
| 788 |
+
buildKey,
|
| 789 |
+
sendRequest,
|
| 790 |
+
sendResponse,
|
| 791 |
+
buildRefs,
|
| 792 |
+
streamIn,
|
| 793 |
+
requestCallbacks,
|
| 794 |
+
options,
|
| 795 |
+
isTTY2,
|
| 796 |
+
defaultWD2,
|
| 797 |
+
(err, res) => {
|
| 798 |
+
try {
|
| 799 |
+
callback(err, res);
|
| 800 |
+
} finally {
|
| 801 |
+
buildRefs.unref();
|
| 802 |
+
}
|
| 803 |
+
}
|
| 804 |
+
);
|
| 805 |
+
};
|
| 806 |
+
let transform2 = ({ callName, refs, input, options, isTTY: isTTY2, fs: fs3, callback }) => {
|
| 807 |
+
const details = createObjectStash();
|
| 808 |
+
let start = (inputPath) => {
|
| 809 |
+
try {
|
| 810 |
+
if (typeof input !== "string" && !(input instanceof Uint8Array))
|
| 811 |
+
throw new Error('The input to "transform" must be a string or a Uint8Array');
|
| 812 |
+
let {
|
| 813 |
+
flags,
|
| 814 |
+
mangleCache
|
| 815 |
+
} = flagsForTransformOptions(callName, options, isTTY2, transformLogLevelDefault);
|
| 816 |
+
let request = {
|
| 817 |
+
command: "transform",
|
| 818 |
+
flags,
|
| 819 |
+
inputFS: inputPath !== null,
|
| 820 |
+
input: inputPath !== null ? encodeUTF8(inputPath) : typeof input === "string" ? encodeUTF8(input) : input
|
| 821 |
+
};
|
| 822 |
+
if (mangleCache)
|
| 823 |
+
request.mangleCache = mangleCache;
|
| 824 |
+
sendRequest(refs, request, (error, response) => {
|
| 825 |
+
if (error)
|
| 826 |
+
return callback(new Error(error), null);
|
| 827 |
+
let errors = replaceDetailsInMessages(response.errors, details);
|
| 828 |
+
let warnings = replaceDetailsInMessages(response.warnings, details);
|
| 829 |
+
let outstanding = 1;
|
| 830 |
+
let next = () => {
|
| 831 |
+
if (--outstanding === 0) {
|
| 832 |
+
let result = {
|
| 833 |
+
warnings,
|
| 834 |
+
code: response.code,
|
| 835 |
+
map: response.map,
|
| 836 |
+
mangleCache: void 0,
|
| 837 |
+
legalComments: void 0
|
| 838 |
+
};
|
| 839 |
+
if ("legalComments" in response)
|
| 840 |
+
result.legalComments = response == null ? void 0 : response.legalComments;
|
| 841 |
+
if (response.mangleCache)
|
| 842 |
+
result.mangleCache = response == null ? void 0 : response.mangleCache;
|
| 843 |
+
callback(null, result);
|
| 844 |
+
}
|
| 845 |
+
};
|
| 846 |
+
if (errors.length > 0)
|
| 847 |
+
return callback(failureErrorWithLog("Transform failed", errors, warnings), null);
|
| 848 |
+
if (response.codeFS) {
|
| 849 |
+
outstanding++;
|
| 850 |
+
fs3.readFile(response.code, (err, contents) => {
|
| 851 |
+
if (err !== null) {
|
| 852 |
+
callback(err, null);
|
| 853 |
+
} else {
|
| 854 |
+
response.code = contents;
|
| 855 |
+
next();
|
| 856 |
+
}
|
| 857 |
+
});
|
| 858 |
+
}
|
| 859 |
+
if (response.mapFS) {
|
| 860 |
+
outstanding++;
|
| 861 |
+
fs3.readFile(response.map, (err, contents) => {
|
| 862 |
+
if (err !== null) {
|
| 863 |
+
callback(err, null);
|
| 864 |
+
} else {
|
| 865 |
+
response.map = contents;
|
| 866 |
+
next();
|
| 867 |
+
}
|
| 868 |
+
});
|
| 869 |
+
}
|
| 870 |
+
next();
|
| 871 |
+
});
|
| 872 |
+
} catch (e) {
|
| 873 |
+
let flags = [];
|
| 874 |
+
try {
|
| 875 |
+
pushLogFlags(flags, options, {}, isTTY2, transformLogLevelDefault);
|
| 876 |
+
} catch {
|
| 877 |
+
}
|
| 878 |
+
const error = extractErrorMessageV8(e, streamIn, details, void 0, "");
|
| 879 |
+
sendRequest(refs, { command: "error", flags, error }, () => {
|
| 880 |
+
error.detail = details.load(error.detail);
|
| 881 |
+
callback(failureErrorWithLog("Transform failed", [error], []), null);
|
| 882 |
+
});
|
| 883 |
+
}
|
| 884 |
+
};
|
| 885 |
+
if ((typeof input === "string" || input instanceof Uint8Array) && input.length > 1024 * 1024) {
|
| 886 |
+
let next = start;
|
| 887 |
+
start = () => fs3.writeFile(input, next);
|
| 888 |
+
}
|
| 889 |
+
start(null);
|
| 890 |
+
};
|
| 891 |
+
let formatMessages2 = ({ callName, refs, messages, options, callback }) => {
|
| 892 |
+
let result = sanitizeMessages(messages, "messages", null, "");
|
| 893 |
+
if (!options)
|
| 894 |
+
throw new Error(`Missing second argument in ${callName}() call`);
|
| 895 |
+
let keys = {};
|
| 896 |
+
let kind = getFlag(options, keys, "kind", mustBeString);
|
| 897 |
+
let color = getFlag(options, keys, "color", mustBeBoolean);
|
| 898 |
+
let terminalWidth = getFlag(options, keys, "terminalWidth", mustBeInteger);
|
| 899 |
+
checkForInvalidFlags(options, keys, `in ${callName}() call`);
|
| 900 |
+
if (kind === void 0)
|
| 901 |
+
throw new Error(`Missing "kind" in ${callName}() call`);
|
| 902 |
+
if (kind !== "error" && kind !== "warning")
|
| 903 |
+
throw new Error(`Expected "kind" to be "error" or "warning" in ${callName}() call`);
|
| 904 |
+
let request = {
|
| 905 |
+
command: "format-msgs",
|
| 906 |
+
messages: result,
|
| 907 |
+
isWarning: kind === "warning"
|
| 908 |
+
};
|
| 909 |
+
if (color !== void 0)
|
| 910 |
+
request.color = color;
|
| 911 |
+
if (terminalWidth !== void 0)
|
| 912 |
+
request.terminalWidth = terminalWidth;
|
| 913 |
+
sendRequest(refs, request, (error, response) => {
|
| 914 |
+
if (error)
|
| 915 |
+
return callback(new Error(error), null);
|
| 916 |
+
callback(null, response.messages);
|
| 917 |
+
});
|
| 918 |
+
};
|
| 919 |
+
let analyzeMetafile2 = ({ callName, refs, metafile, options, callback }) => {
|
| 920 |
+
if (options === void 0)
|
| 921 |
+
options = {};
|
| 922 |
+
let keys = {};
|
| 923 |
+
let color = getFlag(options, keys, "color", mustBeBoolean);
|
| 924 |
+
let verbose = getFlag(options, keys, "verbose", mustBeBoolean);
|
| 925 |
+
checkForInvalidFlags(options, keys, `in ${callName}() call`);
|
| 926 |
+
let request = {
|
| 927 |
+
command: "analyze-metafile",
|
| 928 |
+
metafile
|
| 929 |
+
};
|
| 930 |
+
if (color !== void 0)
|
| 931 |
+
request.color = color;
|
| 932 |
+
if (verbose !== void 0)
|
| 933 |
+
request.verbose = verbose;
|
| 934 |
+
sendRequest(refs, request, (error, response) => {
|
| 935 |
+
if (error)
|
| 936 |
+
return callback(new Error(error), null);
|
| 937 |
+
callback(null, response.result);
|
| 938 |
+
});
|
| 939 |
+
};
|
| 940 |
+
return {
|
| 941 |
+
readFromStdout,
|
| 942 |
+
afterClose,
|
| 943 |
+
service: {
|
| 944 |
+
buildOrContext,
|
| 945 |
+
transform: transform2,
|
| 946 |
+
formatMessages: formatMessages2,
|
| 947 |
+
analyzeMetafile: analyzeMetafile2
|
| 948 |
+
}
|
| 949 |
+
};
|
| 950 |
+
}
|
| 951 |
+
function buildOrContextImpl(callName, buildKey, sendRequest, sendResponse, refs, streamIn, requestCallbacks, options, isTTY2, defaultWD2, callback) {
|
| 952 |
+
const details = createObjectStash();
|
| 953 |
+
const isContext = callName === "context";
|
| 954 |
+
const handleError = (e, pluginName) => {
|
| 955 |
+
const flags = [];
|
| 956 |
+
try {
|
| 957 |
+
pushLogFlags(flags, options, {}, isTTY2, buildLogLevelDefault);
|
| 958 |
+
} catch {
|
| 959 |
+
}
|
| 960 |
+
const message = extractErrorMessageV8(e, streamIn, details, void 0, pluginName);
|
| 961 |
+
sendRequest(refs, { command: "error", flags, error: message }, () => {
|
| 962 |
+
message.detail = details.load(message.detail);
|
| 963 |
+
callback(failureErrorWithLog(isContext ? "Context failed" : "Build failed", [message], []), null);
|
| 964 |
+
});
|
| 965 |
+
};
|
| 966 |
+
let plugins;
|
| 967 |
+
if (typeof options === "object") {
|
| 968 |
+
const value = options.plugins;
|
| 969 |
+
if (value !== void 0) {
|
| 970 |
+
if (!Array.isArray(value))
|
| 971 |
+
return handleError(new Error(`"plugins" must be an array`), "");
|
| 972 |
+
plugins = value;
|
| 973 |
+
}
|
| 974 |
+
}
|
| 975 |
+
if (plugins && plugins.length > 0) {
|
| 976 |
+
if (streamIn.isSync)
|
| 977 |
+
return handleError(new Error("Cannot use plugins in synchronous API calls"), "");
|
| 978 |
+
handlePlugins(
|
| 979 |
+
buildKey,
|
| 980 |
+
sendRequest,
|
| 981 |
+
sendResponse,
|
| 982 |
+
refs,
|
| 983 |
+
streamIn,
|
| 984 |
+
requestCallbacks,
|
| 985 |
+
options,
|
| 986 |
+
plugins,
|
| 987 |
+
details
|
| 988 |
+
).then(
|
| 989 |
+
(result) => {
|
| 990 |
+
if (!result.ok)
|
| 991 |
+
return handleError(result.error, result.pluginName);
|
| 992 |
+
try {
|
| 993 |
+
buildOrContextContinue(result.requestPlugins, result.runOnEndCallbacks, result.scheduleOnDisposeCallbacks);
|
| 994 |
+
} catch (e) {
|
| 995 |
+
handleError(e, "");
|
| 996 |
+
}
|
| 997 |
+
},
|
| 998 |
+
(e) => handleError(e, "")
|
| 999 |
+
);
|
| 1000 |
+
return;
|
| 1001 |
+
}
|
| 1002 |
+
try {
|
| 1003 |
+
buildOrContextContinue(null, (result, done) => done([], []), () => {
|
| 1004 |
+
});
|
| 1005 |
+
} catch (e) {
|
| 1006 |
+
handleError(e, "");
|
| 1007 |
+
}
|
| 1008 |
+
function buildOrContextContinue(requestPlugins, runOnEndCallbacks, scheduleOnDisposeCallbacks) {
|
| 1009 |
+
const writeDefault = streamIn.hasFS;
|
| 1010 |
+
const {
|
| 1011 |
+
entries,
|
| 1012 |
+
flags,
|
| 1013 |
+
write,
|
| 1014 |
+
stdinContents,
|
| 1015 |
+
stdinResolveDir,
|
| 1016 |
+
absWorkingDir,
|
| 1017 |
+
nodePaths,
|
| 1018 |
+
mangleCache
|
| 1019 |
+
} = flagsForBuildOptions(callName, options, isTTY2, buildLogLevelDefault, writeDefault);
|
| 1020 |
+
if (write && !streamIn.hasFS)
|
| 1021 |
+
throw new Error(`The "write" option is unavailable in this environment`);
|
| 1022 |
+
const request = {
|
| 1023 |
+
command: "build",
|
| 1024 |
+
key: buildKey,
|
| 1025 |
+
entries,
|
| 1026 |
+
flags,
|
| 1027 |
+
write,
|
| 1028 |
+
stdinContents,
|
| 1029 |
+
stdinResolveDir,
|
| 1030 |
+
absWorkingDir: absWorkingDir || defaultWD2,
|
| 1031 |
+
nodePaths,
|
| 1032 |
+
context: isContext
|
| 1033 |
+
};
|
| 1034 |
+
if (requestPlugins)
|
| 1035 |
+
request.plugins = requestPlugins;
|
| 1036 |
+
if (mangleCache)
|
| 1037 |
+
request.mangleCache = mangleCache;
|
| 1038 |
+
const buildResponseToResult = (response, callback2) => {
|
| 1039 |
+
const result = {
|
| 1040 |
+
errors: replaceDetailsInMessages(response.errors, details),
|
| 1041 |
+
warnings: replaceDetailsInMessages(response.warnings, details),
|
| 1042 |
+
outputFiles: void 0,
|
| 1043 |
+
metafile: void 0,
|
| 1044 |
+
mangleCache: void 0
|
| 1045 |
+
};
|
| 1046 |
+
const originalErrors = result.errors.slice();
|
| 1047 |
+
const originalWarnings = result.warnings.slice();
|
| 1048 |
+
if (response.outputFiles)
|
| 1049 |
+
result.outputFiles = response.outputFiles.map(convertOutputFiles);
|
| 1050 |
+
if (response.metafile)
|
| 1051 |
+
result.metafile = JSON.parse(response.metafile);
|
| 1052 |
+
if (response.mangleCache)
|
| 1053 |
+
result.mangleCache = response.mangleCache;
|
| 1054 |
+
if (response.writeToStdout !== void 0)
|
| 1055 |
+
console.log(decodeUTF8(response.writeToStdout).replace(/\n$/, ""));
|
| 1056 |
+
runOnEndCallbacks(result, (onEndErrors, onEndWarnings) => {
|
| 1057 |
+
if (originalErrors.length > 0 || onEndErrors.length > 0) {
|
| 1058 |
+
const error = failureErrorWithLog("Build failed", originalErrors.concat(onEndErrors), originalWarnings.concat(onEndWarnings));
|
| 1059 |
+
return callback2(error, null, onEndErrors, onEndWarnings);
|
| 1060 |
+
}
|
| 1061 |
+
callback2(null, result, onEndErrors, onEndWarnings);
|
| 1062 |
+
});
|
| 1063 |
+
};
|
| 1064 |
+
let latestResultPromise;
|
| 1065 |
+
let provideLatestResult;
|
| 1066 |
+
if (isContext)
|
| 1067 |
+
requestCallbacks["on-end"] = (id, request2) => new Promise((resolve) => {
|
| 1068 |
+
buildResponseToResult(request2, (err, result, onEndErrors, onEndWarnings) => {
|
| 1069 |
+
const response = {
|
| 1070 |
+
errors: onEndErrors,
|
| 1071 |
+
warnings: onEndWarnings
|
| 1072 |
+
};
|
| 1073 |
+
if (provideLatestResult)
|
| 1074 |
+
provideLatestResult(err, result);
|
| 1075 |
+
latestResultPromise = void 0;
|
| 1076 |
+
provideLatestResult = void 0;
|
| 1077 |
+
sendResponse(id, response);
|
| 1078 |
+
resolve();
|
| 1079 |
+
});
|
| 1080 |
+
});
|
| 1081 |
+
sendRequest(refs, request, (error, response) => {
|
| 1082 |
+
if (error)
|
| 1083 |
+
return callback(new Error(error), null);
|
| 1084 |
+
if (!isContext) {
|
| 1085 |
+
return buildResponseToResult(response, (err, res) => {
|
| 1086 |
+
scheduleOnDisposeCallbacks();
|
| 1087 |
+
return callback(err, res);
|
| 1088 |
+
});
|
| 1089 |
+
}
|
| 1090 |
+
if (response.errors.length > 0) {
|
| 1091 |
+
return callback(failureErrorWithLog("Context failed", response.errors, response.warnings), null);
|
| 1092 |
+
}
|
| 1093 |
+
let didDispose = false;
|
| 1094 |
+
const result = {
|
| 1095 |
+
rebuild: () => {
|
| 1096 |
+
if (!latestResultPromise)
|
| 1097 |
+
latestResultPromise = new Promise((resolve, reject) => {
|
| 1098 |
+
let settlePromise;
|
| 1099 |
+
provideLatestResult = (err, result2) => {
|
| 1100 |
+
if (!settlePromise)
|
| 1101 |
+
settlePromise = () => err ? reject(err) : resolve(result2);
|
| 1102 |
+
};
|
| 1103 |
+
const triggerAnotherBuild = () => {
|
| 1104 |
+
const request2 = {
|
| 1105 |
+
command: "rebuild",
|
| 1106 |
+
key: buildKey
|
| 1107 |
+
};
|
| 1108 |
+
sendRequest(refs, request2, (error2, response2) => {
|
| 1109 |
+
if (error2) {
|
| 1110 |
+
reject(new Error(error2));
|
| 1111 |
+
} else if (settlePromise) {
|
| 1112 |
+
settlePromise();
|
| 1113 |
+
} else {
|
| 1114 |
+
triggerAnotherBuild();
|
| 1115 |
+
}
|
| 1116 |
+
});
|
| 1117 |
+
};
|
| 1118 |
+
triggerAnotherBuild();
|
| 1119 |
+
});
|
| 1120 |
+
return latestResultPromise;
|
| 1121 |
+
},
|
| 1122 |
+
watch: (options2 = {}) => new Promise((resolve, reject) => {
|
| 1123 |
+
if (!streamIn.hasFS)
|
| 1124 |
+
throw new Error(`Cannot use the "watch" API in this environment`);
|
| 1125 |
+
const keys = {};
|
| 1126 |
+
checkForInvalidFlags(options2, keys, `in watch() call`);
|
| 1127 |
+
const request2 = {
|
| 1128 |
+
command: "watch",
|
| 1129 |
+
key: buildKey
|
| 1130 |
+
};
|
| 1131 |
+
sendRequest(refs, request2, (error2) => {
|
| 1132 |
+
if (error2)
|
| 1133 |
+
reject(new Error(error2));
|
| 1134 |
+
else
|
| 1135 |
+
resolve(void 0);
|
| 1136 |
+
});
|
| 1137 |
+
}),
|
| 1138 |
+
serve: (options2 = {}) => new Promise((resolve, reject) => {
|
| 1139 |
+
if (!streamIn.hasFS)
|
| 1140 |
+
throw new Error(`Cannot use the "serve" API in this environment`);
|
| 1141 |
+
const keys = {};
|
| 1142 |
+
const port = getFlag(options2, keys, "port", mustBeInteger);
|
| 1143 |
+
const host = getFlag(options2, keys, "host", mustBeString);
|
| 1144 |
+
const servedir = getFlag(options2, keys, "servedir", mustBeString);
|
| 1145 |
+
const keyfile = getFlag(options2, keys, "keyfile", mustBeString);
|
| 1146 |
+
const certfile = getFlag(options2, keys, "certfile", mustBeString);
|
| 1147 |
+
const fallback = getFlag(options2, keys, "fallback", mustBeString);
|
| 1148 |
+
const onRequest = getFlag(options2, keys, "onRequest", mustBeFunction);
|
| 1149 |
+
checkForInvalidFlags(options2, keys, `in serve() call`);
|
| 1150 |
+
const request2 = {
|
| 1151 |
+
command: "serve",
|
| 1152 |
+
key: buildKey,
|
| 1153 |
+
onRequest: !!onRequest
|
| 1154 |
+
};
|
| 1155 |
+
if (port !== void 0)
|
| 1156 |
+
request2.port = port;
|
| 1157 |
+
if (host !== void 0)
|
| 1158 |
+
request2.host = host;
|
| 1159 |
+
if (servedir !== void 0)
|
| 1160 |
+
request2.servedir = servedir;
|
| 1161 |
+
if (keyfile !== void 0)
|
| 1162 |
+
request2.keyfile = keyfile;
|
| 1163 |
+
if (certfile !== void 0)
|
| 1164 |
+
request2.certfile = certfile;
|
| 1165 |
+
if (fallback !== void 0)
|
| 1166 |
+
request2.fallback = fallback;
|
| 1167 |
+
sendRequest(refs, request2, (error2, response2) => {
|
| 1168 |
+
if (error2)
|
| 1169 |
+
return reject(new Error(error2));
|
| 1170 |
+
if (onRequest) {
|
| 1171 |
+
requestCallbacks["serve-request"] = (id, request3) => {
|
| 1172 |
+
onRequest(request3.args);
|
| 1173 |
+
sendResponse(id, {});
|
| 1174 |
+
};
|
| 1175 |
+
}
|
| 1176 |
+
resolve(response2);
|
| 1177 |
+
});
|
| 1178 |
+
}),
|
| 1179 |
+
cancel: () => new Promise((resolve) => {
|
| 1180 |
+
if (didDispose)
|
| 1181 |
+
return resolve();
|
| 1182 |
+
const request2 = {
|
| 1183 |
+
command: "cancel",
|
| 1184 |
+
key: buildKey
|
| 1185 |
+
};
|
| 1186 |
+
sendRequest(refs, request2, () => {
|
| 1187 |
+
resolve();
|
| 1188 |
+
});
|
| 1189 |
+
}),
|
| 1190 |
+
dispose: () => new Promise((resolve) => {
|
| 1191 |
+
if (didDispose)
|
| 1192 |
+
return resolve();
|
| 1193 |
+
didDispose = true;
|
| 1194 |
+
const request2 = {
|
| 1195 |
+
command: "dispose",
|
| 1196 |
+
key: buildKey
|
| 1197 |
+
};
|
| 1198 |
+
sendRequest(refs, request2, () => {
|
| 1199 |
+
resolve();
|
| 1200 |
+
scheduleOnDisposeCallbacks();
|
| 1201 |
+
refs.unref();
|
| 1202 |
+
});
|
| 1203 |
+
})
|
| 1204 |
+
};
|
| 1205 |
+
refs.ref();
|
| 1206 |
+
callback(null, result);
|
| 1207 |
+
});
|
| 1208 |
+
}
|
| 1209 |
+
}
|
| 1210 |
+
var handlePlugins = async (buildKey, sendRequest, sendResponse, refs, streamIn, requestCallbacks, initialOptions, plugins, details) => {
|
| 1211 |
+
let onStartCallbacks = [];
|
| 1212 |
+
let onEndCallbacks = [];
|
| 1213 |
+
let onResolveCallbacks = {};
|
| 1214 |
+
let onLoadCallbacks = {};
|
| 1215 |
+
let onDisposeCallbacks = [];
|
| 1216 |
+
let nextCallbackID = 0;
|
| 1217 |
+
let i = 0;
|
| 1218 |
+
let requestPlugins = [];
|
| 1219 |
+
let isSetupDone = false;
|
| 1220 |
+
plugins = [...plugins];
|
| 1221 |
+
for (let item of plugins) {
|
| 1222 |
+
let keys = {};
|
| 1223 |
+
if (typeof item !== "object")
|
| 1224 |
+
throw new Error(`Plugin at index ${i} must be an object`);
|
| 1225 |
+
const name = getFlag(item, keys, "name", mustBeString);
|
| 1226 |
+
if (typeof name !== "string" || name === "")
|
| 1227 |
+
throw new Error(`Plugin at index ${i} is missing a name`);
|
| 1228 |
+
try {
|
| 1229 |
+
let setup = getFlag(item, keys, "setup", mustBeFunction);
|
| 1230 |
+
if (typeof setup !== "function")
|
| 1231 |
+
throw new Error(`Plugin is missing a setup function`);
|
| 1232 |
+
checkForInvalidFlags(item, keys, `on plugin ${quote(name)}`);
|
| 1233 |
+
let plugin = {
|
| 1234 |
+
name,
|
| 1235 |
+
onStart: false,
|
| 1236 |
+
onEnd: false,
|
| 1237 |
+
onResolve: [],
|
| 1238 |
+
onLoad: []
|
| 1239 |
+
};
|
| 1240 |
+
i++;
|
| 1241 |
+
let resolve = (path3, options = {}) => {
|
| 1242 |
+
if (!isSetupDone)
|
| 1243 |
+
throw new Error('Cannot call "resolve" before plugin setup has completed');
|
| 1244 |
+
if (typeof path3 !== "string")
|
| 1245 |
+
throw new Error(`The path to resolve must be a string`);
|
| 1246 |
+
let keys2 = /* @__PURE__ */ Object.create(null);
|
| 1247 |
+
let pluginName = getFlag(options, keys2, "pluginName", mustBeString);
|
| 1248 |
+
let importer = getFlag(options, keys2, "importer", mustBeString);
|
| 1249 |
+
let namespace = getFlag(options, keys2, "namespace", mustBeString);
|
| 1250 |
+
let resolveDir = getFlag(options, keys2, "resolveDir", mustBeString);
|
| 1251 |
+
let kind = getFlag(options, keys2, "kind", mustBeString);
|
| 1252 |
+
let pluginData = getFlag(options, keys2, "pluginData", canBeAnything);
|
| 1253 |
+
checkForInvalidFlags(options, keys2, "in resolve() call");
|
| 1254 |
+
return new Promise((resolve2, reject) => {
|
| 1255 |
+
const request = {
|
| 1256 |
+
command: "resolve",
|
| 1257 |
+
path: path3,
|
| 1258 |
+
key: buildKey,
|
| 1259 |
+
pluginName: name
|
| 1260 |
+
};
|
| 1261 |
+
if (pluginName != null)
|
| 1262 |
+
request.pluginName = pluginName;
|
| 1263 |
+
if (importer != null)
|
| 1264 |
+
request.importer = importer;
|
| 1265 |
+
if (namespace != null)
|
| 1266 |
+
request.namespace = namespace;
|
| 1267 |
+
if (resolveDir != null)
|
| 1268 |
+
request.resolveDir = resolveDir;
|
| 1269 |
+
if (kind != null)
|
| 1270 |
+
request.kind = kind;
|
| 1271 |
+
else
|
| 1272 |
+
throw new Error(`Must specify "kind" when calling "resolve"`);
|
| 1273 |
+
if (pluginData != null)
|
| 1274 |
+
request.pluginData = details.store(pluginData);
|
| 1275 |
+
sendRequest(refs, request, (error, response) => {
|
| 1276 |
+
if (error !== null)
|
| 1277 |
+
reject(new Error(error));
|
| 1278 |
+
else
|
| 1279 |
+
resolve2({
|
| 1280 |
+
errors: replaceDetailsInMessages(response.errors, details),
|
| 1281 |
+
warnings: replaceDetailsInMessages(response.warnings, details),
|
| 1282 |
+
path: response.path,
|
| 1283 |
+
external: response.external,
|
| 1284 |
+
sideEffects: response.sideEffects,
|
| 1285 |
+
namespace: response.namespace,
|
| 1286 |
+
suffix: response.suffix,
|
| 1287 |
+
pluginData: details.load(response.pluginData)
|
| 1288 |
+
});
|
| 1289 |
+
});
|
| 1290 |
+
});
|
| 1291 |
+
};
|
| 1292 |
+
let promise = setup({
|
| 1293 |
+
initialOptions,
|
| 1294 |
+
resolve,
|
| 1295 |
+
onStart(callback) {
|
| 1296 |
+
let registeredText = `This error came from the "onStart" callback registered here:`;
|
| 1297 |
+
let registeredNote = extractCallerV8(new Error(registeredText), streamIn, "onStart");
|
| 1298 |
+
onStartCallbacks.push({ name, callback, note: registeredNote });
|
| 1299 |
+
plugin.onStart = true;
|
| 1300 |
+
},
|
| 1301 |
+
onEnd(callback) {
|
| 1302 |
+
let registeredText = `This error came from the "onEnd" callback registered here:`;
|
| 1303 |
+
let registeredNote = extractCallerV8(new Error(registeredText), streamIn, "onEnd");
|
| 1304 |
+
onEndCallbacks.push({ name, callback, note: registeredNote });
|
| 1305 |
+
plugin.onEnd = true;
|
| 1306 |
+
},
|
| 1307 |
+
onResolve(options, callback) {
|
| 1308 |
+
let registeredText = `This error came from the "onResolve" callback registered here:`;
|
| 1309 |
+
let registeredNote = extractCallerV8(new Error(registeredText), streamIn, "onResolve");
|
| 1310 |
+
let keys2 = {};
|
| 1311 |
+
let filter = getFlag(options, keys2, "filter", mustBeRegExp);
|
| 1312 |
+
let namespace = getFlag(options, keys2, "namespace", mustBeString);
|
| 1313 |
+
checkForInvalidFlags(options, keys2, `in onResolve() call for plugin ${quote(name)}`);
|
| 1314 |
+
if (filter == null)
|
| 1315 |
+
throw new Error(`onResolve() call is missing a filter`);
|
| 1316 |
+
let id = nextCallbackID++;
|
| 1317 |
+
onResolveCallbacks[id] = { name, callback, note: registeredNote };
|
| 1318 |
+
plugin.onResolve.push({ id, filter: filter.source, namespace: namespace || "" });
|
| 1319 |
+
},
|
| 1320 |
+
onLoad(options, callback) {
|
| 1321 |
+
let registeredText = `This error came from the "onLoad" callback registered here:`;
|
| 1322 |
+
let registeredNote = extractCallerV8(new Error(registeredText), streamIn, "onLoad");
|
| 1323 |
+
let keys2 = {};
|
| 1324 |
+
let filter = getFlag(options, keys2, "filter", mustBeRegExp);
|
| 1325 |
+
let namespace = getFlag(options, keys2, "namespace", mustBeString);
|
| 1326 |
+
checkForInvalidFlags(options, keys2, `in onLoad() call for plugin ${quote(name)}`);
|
| 1327 |
+
if (filter == null)
|
| 1328 |
+
throw new Error(`onLoad() call is missing a filter`);
|
| 1329 |
+
let id = nextCallbackID++;
|
| 1330 |
+
onLoadCallbacks[id] = { name, callback, note: registeredNote };
|
| 1331 |
+
plugin.onLoad.push({ id, filter: filter.source, namespace: namespace || "" });
|
| 1332 |
+
},
|
| 1333 |
+
onDispose(callback) {
|
| 1334 |
+
onDisposeCallbacks.push(callback);
|
| 1335 |
+
},
|
| 1336 |
+
esbuild: streamIn.esbuild
|
| 1337 |
+
});
|
| 1338 |
+
if (promise)
|
| 1339 |
+
await promise;
|
| 1340 |
+
requestPlugins.push(plugin);
|
| 1341 |
+
} catch (e) {
|
| 1342 |
+
return { ok: false, error: e, pluginName: name };
|
| 1343 |
+
}
|
| 1344 |
+
}
|
| 1345 |
+
requestCallbacks["on-start"] = async (id, request) => {
|
| 1346 |
+
let response = { errors: [], warnings: [] };
|
| 1347 |
+
await Promise.all(onStartCallbacks.map(async ({ name, callback, note }) => {
|
| 1348 |
+
try {
|
| 1349 |
+
let result = await callback();
|
| 1350 |
+
if (result != null) {
|
| 1351 |
+
if (typeof result !== "object")
|
| 1352 |
+
throw new Error(`Expected onStart() callback in plugin ${quote(name)} to return an object`);
|
| 1353 |
+
let keys = {};
|
| 1354 |
+
let errors = getFlag(result, keys, "errors", mustBeArray);
|
| 1355 |
+
let warnings = getFlag(result, keys, "warnings", mustBeArray);
|
| 1356 |
+
checkForInvalidFlags(result, keys, `from onStart() callback in plugin ${quote(name)}`);
|
| 1357 |
+
if (errors != null)
|
| 1358 |
+
response.errors.push(...sanitizeMessages(errors, "errors", details, name));
|
| 1359 |
+
if (warnings != null)
|
| 1360 |
+
response.warnings.push(...sanitizeMessages(warnings, "warnings", details, name));
|
| 1361 |
+
}
|
| 1362 |
+
} catch (e) {
|
| 1363 |
+
response.errors.push(extractErrorMessageV8(e, streamIn, details, note && note(), name));
|
| 1364 |
+
}
|
| 1365 |
+
}));
|
| 1366 |
+
sendResponse(id, response);
|
| 1367 |
+
};
|
| 1368 |
+
requestCallbacks["on-resolve"] = async (id, request) => {
|
| 1369 |
+
let response = {}, name = "", callback, note;
|
| 1370 |
+
for (let id2 of request.ids) {
|
| 1371 |
+
try {
|
| 1372 |
+
({ name, callback, note } = onResolveCallbacks[id2]);
|
| 1373 |
+
let result = await callback({
|
| 1374 |
+
path: request.path,
|
| 1375 |
+
importer: request.importer,
|
| 1376 |
+
namespace: request.namespace,
|
| 1377 |
+
resolveDir: request.resolveDir,
|
| 1378 |
+
kind: request.kind,
|
| 1379 |
+
pluginData: details.load(request.pluginData)
|
| 1380 |
+
});
|
| 1381 |
+
if (result != null) {
|
| 1382 |
+
if (typeof result !== "object")
|
| 1383 |
+
throw new Error(`Expected onResolve() callback in plugin ${quote(name)} to return an object`);
|
| 1384 |
+
let keys = {};
|
| 1385 |
+
let pluginName = getFlag(result, keys, "pluginName", mustBeString);
|
| 1386 |
+
let path3 = getFlag(result, keys, "path", mustBeString);
|
| 1387 |
+
let namespace = getFlag(result, keys, "namespace", mustBeString);
|
| 1388 |
+
let suffix = getFlag(result, keys, "suffix", mustBeString);
|
| 1389 |
+
let external = getFlag(result, keys, "external", mustBeBoolean);
|
| 1390 |
+
let sideEffects = getFlag(result, keys, "sideEffects", mustBeBoolean);
|
| 1391 |
+
let pluginData = getFlag(result, keys, "pluginData", canBeAnything);
|
| 1392 |
+
let errors = getFlag(result, keys, "errors", mustBeArray);
|
| 1393 |
+
let warnings = getFlag(result, keys, "warnings", mustBeArray);
|
| 1394 |
+
let watchFiles = getFlag(result, keys, "watchFiles", mustBeArray);
|
| 1395 |
+
let watchDirs = getFlag(result, keys, "watchDirs", mustBeArray);
|
| 1396 |
+
checkForInvalidFlags(result, keys, `from onResolve() callback in plugin ${quote(name)}`);
|
| 1397 |
+
response.id = id2;
|
| 1398 |
+
if (pluginName != null)
|
| 1399 |
+
response.pluginName = pluginName;
|
| 1400 |
+
if (path3 != null)
|
| 1401 |
+
response.path = path3;
|
| 1402 |
+
if (namespace != null)
|
| 1403 |
+
response.namespace = namespace;
|
| 1404 |
+
if (suffix != null)
|
| 1405 |
+
response.suffix = suffix;
|
| 1406 |
+
if (external != null)
|
| 1407 |
+
response.external = external;
|
| 1408 |
+
if (sideEffects != null)
|
| 1409 |
+
response.sideEffects = sideEffects;
|
| 1410 |
+
if (pluginData != null)
|
| 1411 |
+
response.pluginData = details.store(pluginData);
|
| 1412 |
+
if (errors != null)
|
| 1413 |
+
response.errors = sanitizeMessages(errors, "errors", details, name);
|
| 1414 |
+
if (warnings != null)
|
| 1415 |
+
response.warnings = sanitizeMessages(warnings, "warnings", details, name);
|
| 1416 |
+
if (watchFiles != null)
|
| 1417 |
+
response.watchFiles = sanitizeStringArray(watchFiles, "watchFiles");
|
| 1418 |
+
if (watchDirs != null)
|
| 1419 |
+
response.watchDirs = sanitizeStringArray(watchDirs, "watchDirs");
|
| 1420 |
+
break;
|
| 1421 |
+
}
|
| 1422 |
+
} catch (e) {
|
| 1423 |
+
response = { id: id2, errors: [extractErrorMessageV8(e, streamIn, details, note && note(), name)] };
|
| 1424 |
+
break;
|
| 1425 |
+
}
|
| 1426 |
+
}
|
| 1427 |
+
sendResponse(id, response);
|
| 1428 |
+
};
|
| 1429 |
+
requestCallbacks["on-load"] = async (id, request) => {
|
| 1430 |
+
let response = {}, name = "", callback, note;
|
| 1431 |
+
for (let id2 of request.ids) {
|
| 1432 |
+
try {
|
| 1433 |
+
({ name, callback, note } = onLoadCallbacks[id2]);
|
| 1434 |
+
let result = await callback({
|
| 1435 |
+
path: request.path,
|
| 1436 |
+
namespace: request.namespace,
|
| 1437 |
+
suffix: request.suffix,
|
| 1438 |
+
pluginData: details.load(request.pluginData)
|
| 1439 |
+
});
|
| 1440 |
+
if (result != null) {
|
| 1441 |
+
if (typeof result !== "object")
|
| 1442 |
+
throw new Error(`Expected onLoad() callback in plugin ${quote(name)} to return an object`);
|
| 1443 |
+
let keys = {};
|
| 1444 |
+
let pluginName = getFlag(result, keys, "pluginName", mustBeString);
|
| 1445 |
+
let contents = getFlag(result, keys, "contents", mustBeStringOrUint8Array);
|
| 1446 |
+
let resolveDir = getFlag(result, keys, "resolveDir", mustBeString);
|
| 1447 |
+
let pluginData = getFlag(result, keys, "pluginData", canBeAnything);
|
| 1448 |
+
let loader = getFlag(result, keys, "loader", mustBeString);
|
| 1449 |
+
let errors = getFlag(result, keys, "errors", mustBeArray);
|
| 1450 |
+
let warnings = getFlag(result, keys, "warnings", mustBeArray);
|
| 1451 |
+
let watchFiles = getFlag(result, keys, "watchFiles", mustBeArray);
|
| 1452 |
+
let watchDirs = getFlag(result, keys, "watchDirs", mustBeArray);
|
| 1453 |
+
checkForInvalidFlags(result, keys, `from onLoad() callback in plugin ${quote(name)}`);
|
| 1454 |
+
response.id = id2;
|
| 1455 |
+
if (pluginName != null)
|
| 1456 |
+
response.pluginName = pluginName;
|
| 1457 |
+
if (contents instanceof Uint8Array)
|
| 1458 |
+
response.contents = contents;
|
| 1459 |
+
else if (contents != null)
|
| 1460 |
+
response.contents = encodeUTF8(contents);
|
| 1461 |
+
if (resolveDir != null)
|
| 1462 |
+
response.resolveDir = resolveDir;
|
| 1463 |
+
if (pluginData != null)
|
| 1464 |
+
response.pluginData = details.store(pluginData);
|
| 1465 |
+
if (loader != null)
|
| 1466 |
+
response.loader = loader;
|
| 1467 |
+
if (errors != null)
|
| 1468 |
+
response.errors = sanitizeMessages(errors, "errors", details, name);
|
| 1469 |
+
if (warnings != null)
|
| 1470 |
+
response.warnings = sanitizeMessages(warnings, "warnings", details, name);
|
| 1471 |
+
if (watchFiles != null)
|
| 1472 |
+
response.watchFiles = sanitizeStringArray(watchFiles, "watchFiles");
|
| 1473 |
+
if (watchDirs != null)
|
| 1474 |
+
response.watchDirs = sanitizeStringArray(watchDirs, "watchDirs");
|
| 1475 |
+
break;
|
| 1476 |
+
}
|
| 1477 |
+
} catch (e) {
|
| 1478 |
+
response = { id: id2, errors: [extractErrorMessageV8(e, streamIn, details, note && note(), name)] };
|
| 1479 |
+
break;
|
| 1480 |
+
}
|
| 1481 |
+
}
|
| 1482 |
+
sendResponse(id, response);
|
| 1483 |
+
};
|
| 1484 |
+
let runOnEndCallbacks = (result, done) => done([], []);
|
| 1485 |
+
if (onEndCallbacks.length > 0) {
|
| 1486 |
+
runOnEndCallbacks = (result, done) => {
|
| 1487 |
+
(async () => {
|
| 1488 |
+
const onEndErrors = [];
|
| 1489 |
+
const onEndWarnings = [];
|
| 1490 |
+
for (const { name, callback, note } of onEndCallbacks) {
|
| 1491 |
+
let newErrors;
|
| 1492 |
+
let newWarnings;
|
| 1493 |
+
try {
|
| 1494 |
+
const value = await callback(result);
|
| 1495 |
+
if (value != null) {
|
| 1496 |
+
if (typeof value !== "object")
|
| 1497 |
+
throw new Error(`Expected onEnd() callback in plugin ${quote(name)} to return an object`);
|
| 1498 |
+
let keys = {};
|
| 1499 |
+
let errors = getFlag(value, keys, "errors", mustBeArray);
|
| 1500 |
+
let warnings = getFlag(value, keys, "warnings", mustBeArray);
|
| 1501 |
+
checkForInvalidFlags(value, keys, `from onEnd() callback in plugin ${quote(name)}`);
|
| 1502 |
+
if (errors != null)
|
| 1503 |
+
newErrors = sanitizeMessages(errors, "errors", details, name);
|
| 1504 |
+
if (warnings != null)
|
| 1505 |
+
newWarnings = sanitizeMessages(warnings, "warnings", details, name);
|
| 1506 |
+
}
|
| 1507 |
+
} catch (e) {
|
| 1508 |
+
newErrors = [extractErrorMessageV8(e, streamIn, details, note && note(), name)];
|
| 1509 |
+
}
|
| 1510 |
+
if (newErrors) {
|
| 1511 |
+
onEndErrors.push(...newErrors);
|
| 1512 |
+
try {
|
| 1513 |
+
result.errors.push(...newErrors);
|
| 1514 |
+
} catch {
|
| 1515 |
+
}
|
| 1516 |
+
}
|
| 1517 |
+
if (newWarnings) {
|
| 1518 |
+
onEndWarnings.push(...newWarnings);
|
| 1519 |
+
try {
|
| 1520 |
+
result.warnings.push(...newWarnings);
|
| 1521 |
+
} catch {
|
| 1522 |
+
}
|
| 1523 |
+
}
|
| 1524 |
+
}
|
| 1525 |
+
done(onEndErrors, onEndWarnings);
|
| 1526 |
+
})();
|
| 1527 |
+
};
|
| 1528 |
+
}
|
| 1529 |
+
let scheduleOnDisposeCallbacks = () => {
|
| 1530 |
+
for (const cb of onDisposeCallbacks) {
|
| 1531 |
+
setTimeout(() => cb(), 0);
|
| 1532 |
+
}
|
| 1533 |
+
};
|
| 1534 |
+
isSetupDone = true;
|
| 1535 |
+
return {
|
| 1536 |
+
ok: true,
|
| 1537 |
+
requestPlugins,
|
| 1538 |
+
runOnEndCallbacks,
|
| 1539 |
+
scheduleOnDisposeCallbacks
|
| 1540 |
+
};
|
| 1541 |
+
};
|
| 1542 |
+
function createObjectStash() {
|
| 1543 |
+
const map = /* @__PURE__ */ new Map();
|
| 1544 |
+
let nextID = 0;
|
| 1545 |
+
return {
|
| 1546 |
+
load(id) {
|
| 1547 |
+
return map.get(id);
|
| 1548 |
+
},
|
| 1549 |
+
store(value) {
|
| 1550 |
+
if (value === void 0)
|
| 1551 |
+
return -1;
|
| 1552 |
+
const id = nextID++;
|
| 1553 |
+
map.set(id, value);
|
| 1554 |
+
return id;
|
| 1555 |
+
}
|
| 1556 |
+
};
|
| 1557 |
+
}
|
| 1558 |
+
function extractCallerV8(e, streamIn, ident) {
|
| 1559 |
+
let note;
|
| 1560 |
+
let tried = false;
|
| 1561 |
+
return () => {
|
| 1562 |
+
if (tried)
|
| 1563 |
+
return note;
|
| 1564 |
+
tried = true;
|
| 1565 |
+
try {
|
| 1566 |
+
let lines = (e.stack + "").split("\n");
|
| 1567 |
+
lines.splice(1, 1);
|
| 1568 |
+
let location = parseStackLinesV8(streamIn, lines, ident);
|
| 1569 |
+
if (location) {
|
| 1570 |
+
note = { text: e.message, location };
|
| 1571 |
+
return note;
|
| 1572 |
+
}
|
| 1573 |
+
} catch {
|
| 1574 |
+
}
|
| 1575 |
+
};
|
| 1576 |
+
}
|
| 1577 |
+
function extractErrorMessageV8(e, streamIn, stash, note, pluginName) {
|
| 1578 |
+
let text = "Internal error";
|
| 1579 |
+
let location = null;
|
| 1580 |
+
try {
|
| 1581 |
+
text = (e && e.message || e) + "";
|
| 1582 |
+
} catch {
|
| 1583 |
+
}
|
| 1584 |
+
try {
|
| 1585 |
+
location = parseStackLinesV8(streamIn, (e.stack + "").split("\n"), "");
|
| 1586 |
+
} catch {
|
| 1587 |
+
}
|
| 1588 |
+
return { id: "", pluginName, text, location, notes: note ? [note] : [], detail: stash ? stash.store(e) : -1 };
|
| 1589 |
+
}
|
| 1590 |
+
function parseStackLinesV8(streamIn, lines, ident) {
|
| 1591 |
+
let at = " at ";
|
| 1592 |
+
if (streamIn.readFileSync && !lines[0].startsWith(at) && lines[1].startsWith(at)) {
|
| 1593 |
+
for (let i = 1; i < lines.length; i++) {
|
| 1594 |
+
let line = lines[i];
|
| 1595 |
+
if (!line.startsWith(at))
|
| 1596 |
+
continue;
|
| 1597 |
+
line = line.slice(at.length);
|
| 1598 |
+
while (true) {
|
| 1599 |
+
let match = /^(?:new |async )?\S+ \((.*)\)$/.exec(line);
|
| 1600 |
+
if (match) {
|
| 1601 |
+
line = match[1];
|
| 1602 |
+
continue;
|
| 1603 |
+
}
|
| 1604 |
+
match = /^eval at \S+ \((.*)\)(?:, \S+:\d+:\d+)?$/.exec(line);
|
| 1605 |
+
if (match) {
|
| 1606 |
+
line = match[1];
|
| 1607 |
+
continue;
|
| 1608 |
+
}
|
| 1609 |
+
match = /^(\S+):(\d+):(\d+)$/.exec(line);
|
| 1610 |
+
if (match) {
|
| 1611 |
+
let contents;
|
| 1612 |
+
try {
|
| 1613 |
+
contents = streamIn.readFileSync(match[1], "utf8");
|
| 1614 |
+
} catch {
|
| 1615 |
+
break;
|
| 1616 |
+
}
|
| 1617 |
+
let lineText = contents.split(/\r\n|\r|\n|\u2028|\u2029/)[+match[2] - 1] || "";
|
| 1618 |
+
let column = +match[3] - 1;
|
| 1619 |
+
let length = lineText.slice(column, column + ident.length) === ident ? ident.length : 0;
|
| 1620 |
+
return {
|
| 1621 |
+
file: match[1],
|
| 1622 |
+
namespace: "file",
|
| 1623 |
+
line: +match[2],
|
| 1624 |
+
column: encodeUTF8(lineText.slice(0, column)).length,
|
| 1625 |
+
length: encodeUTF8(lineText.slice(column, column + length)).length,
|
| 1626 |
+
lineText: lineText + "\n" + lines.slice(1).join("\n"),
|
| 1627 |
+
suggestion: ""
|
| 1628 |
+
};
|
| 1629 |
+
}
|
| 1630 |
+
break;
|
| 1631 |
+
}
|
| 1632 |
+
}
|
| 1633 |
+
}
|
| 1634 |
+
return null;
|
| 1635 |
+
}
|
| 1636 |
+
function failureErrorWithLog(text, errors, warnings) {
|
| 1637 |
+
let limit = 5;
|
| 1638 |
+
let summary = errors.length < 1 ? "" : ` with ${errors.length} error${errors.length < 2 ? "" : "s"}:` + errors.slice(0, limit + 1).map((e, i) => {
|
| 1639 |
+
if (i === limit)
|
| 1640 |
+
return "\n...";
|
| 1641 |
+
if (!e.location)
|
| 1642 |
+
return `
|
| 1643 |
+
error: ${e.text}`;
|
| 1644 |
+
let { file, line, column } = e.location;
|
| 1645 |
+
let pluginText = e.pluginName ? `[plugin: ${e.pluginName}] ` : "";
|
| 1646 |
+
return `
|
| 1647 |
+
${file}:${line}:${column}: ERROR: ${pluginText}${e.text}`;
|
| 1648 |
+
}).join("");
|
| 1649 |
+
let error = new Error(`${text}${summary}`);
|
| 1650 |
+
error.errors = errors;
|
| 1651 |
+
error.warnings = warnings;
|
| 1652 |
+
return error;
|
| 1653 |
+
}
|
| 1654 |
+
function replaceDetailsInMessages(messages, stash) {
|
| 1655 |
+
for (const message of messages) {
|
| 1656 |
+
message.detail = stash.load(message.detail);
|
| 1657 |
+
}
|
| 1658 |
+
return messages;
|
| 1659 |
+
}
|
| 1660 |
+
function sanitizeLocation(location, where) {
|
| 1661 |
+
if (location == null)
|
| 1662 |
+
return null;
|
| 1663 |
+
let keys = {};
|
| 1664 |
+
let file = getFlag(location, keys, "file", mustBeString);
|
| 1665 |
+
let namespace = getFlag(location, keys, "namespace", mustBeString);
|
| 1666 |
+
let line = getFlag(location, keys, "line", mustBeInteger);
|
| 1667 |
+
let column = getFlag(location, keys, "column", mustBeInteger);
|
| 1668 |
+
let length = getFlag(location, keys, "length", mustBeInteger);
|
| 1669 |
+
let lineText = getFlag(location, keys, "lineText", mustBeString);
|
| 1670 |
+
let suggestion = getFlag(location, keys, "suggestion", mustBeString);
|
| 1671 |
+
checkForInvalidFlags(location, keys, where);
|
| 1672 |
+
return {
|
| 1673 |
+
file: file || "",
|
| 1674 |
+
namespace: namespace || "",
|
| 1675 |
+
line: line || 0,
|
| 1676 |
+
column: column || 0,
|
| 1677 |
+
length: length || 0,
|
| 1678 |
+
lineText: lineText || "",
|
| 1679 |
+
suggestion: suggestion || ""
|
| 1680 |
+
};
|
| 1681 |
+
}
|
| 1682 |
+
function sanitizeMessages(messages, property, stash, fallbackPluginName) {
|
| 1683 |
+
let messagesClone = [];
|
| 1684 |
+
let index = 0;
|
| 1685 |
+
for (const message of messages) {
|
| 1686 |
+
let keys = {};
|
| 1687 |
+
let id = getFlag(message, keys, "id", mustBeString);
|
| 1688 |
+
let pluginName = getFlag(message, keys, "pluginName", mustBeString);
|
| 1689 |
+
let text = getFlag(message, keys, "text", mustBeString);
|
| 1690 |
+
let location = getFlag(message, keys, "location", mustBeObjectOrNull);
|
| 1691 |
+
let notes = getFlag(message, keys, "notes", mustBeArray);
|
| 1692 |
+
let detail = getFlag(message, keys, "detail", canBeAnything);
|
| 1693 |
+
let where = `in element ${index} of "${property}"`;
|
| 1694 |
+
checkForInvalidFlags(message, keys, where);
|
| 1695 |
+
let notesClone = [];
|
| 1696 |
+
if (notes) {
|
| 1697 |
+
for (const note of notes) {
|
| 1698 |
+
let noteKeys = {};
|
| 1699 |
+
let noteText = getFlag(note, noteKeys, "text", mustBeString);
|
| 1700 |
+
let noteLocation = getFlag(note, noteKeys, "location", mustBeObjectOrNull);
|
| 1701 |
+
checkForInvalidFlags(note, noteKeys, where);
|
| 1702 |
+
notesClone.push({
|
| 1703 |
+
text: noteText || "",
|
| 1704 |
+
location: sanitizeLocation(noteLocation, where)
|
| 1705 |
+
});
|
| 1706 |
+
}
|
| 1707 |
+
}
|
| 1708 |
+
messagesClone.push({
|
| 1709 |
+
id: id || "",
|
| 1710 |
+
pluginName: pluginName || fallbackPluginName,
|
| 1711 |
+
text: text || "",
|
| 1712 |
+
location: sanitizeLocation(location, where),
|
| 1713 |
+
notes: notesClone,
|
| 1714 |
+
detail: stash ? stash.store(detail) : -1
|
| 1715 |
+
});
|
| 1716 |
+
index++;
|
| 1717 |
+
}
|
| 1718 |
+
return messagesClone;
|
| 1719 |
+
}
|
| 1720 |
+
function sanitizeStringArray(values, property) {
|
| 1721 |
+
const result = [];
|
| 1722 |
+
for (const value of values) {
|
| 1723 |
+
if (typeof value !== "string")
|
| 1724 |
+
throw new Error(`${quote(property)} must be an array of strings`);
|
| 1725 |
+
result.push(value);
|
| 1726 |
+
}
|
| 1727 |
+
return result;
|
| 1728 |
+
}
|
| 1729 |
+
function convertOutputFiles({ path: path3, contents, hash }) {
|
| 1730 |
+
let text = null;
|
| 1731 |
+
return {
|
| 1732 |
+
path: path3,
|
| 1733 |
+
contents,
|
| 1734 |
+
hash,
|
| 1735 |
+
get text() {
|
| 1736 |
+
const binary = this.contents;
|
| 1737 |
+
if (text === null || binary !== contents) {
|
| 1738 |
+
contents = binary;
|
| 1739 |
+
text = decodeUTF8(binary);
|
| 1740 |
+
}
|
| 1741 |
+
return text;
|
| 1742 |
+
}
|
| 1743 |
+
};
|
| 1744 |
+
}
|
| 1745 |
+
|
| 1746 |
+
// lib/npm/node-platform.ts
|
| 1747 |
+
var fs = require("fs");
|
| 1748 |
+
var os = require("os");
|
| 1749 |
+
var path = require("path");
|
| 1750 |
+
var ESBUILD_BINARY_PATH = process.env.ESBUILD_BINARY_PATH || ESBUILD_BINARY_PATH;
|
| 1751 |
+
var isValidBinaryPath = (x) => !!x && x !== "/usr/bin/esbuild";
|
| 1752 |
+
var packageDarwin_arm64 = "@esbuild/darwin-arm64";
|
| 1753 |
+
var packageDarwin_x64 = "@esbuild/darwin-x64";
|
| 1754 |
+
var knownWindowsPackages = {
|
| 1755 |
+
"win32 arm64 LE": "@esbuild/win32-arm64",
|
| 1756 |
+
"win32 ia32 LE": "@esbuild/win32-ia32",
|
| 1757 |
+
"win32 x64 LE": "@esbuild/win32-x64"
|
| 1758 |
+
};
|
| 1759 |
+
var knownUnixlikePackages = {
|
| 1760 |
+
"android arm64 LE": "@esbuild/android-arm64",
|
| 1761 |
+
"darwin arm64 LE": "@esbuild/darwin-arm64",
|
| 1762 |
+
"darwin x64 LE": "@esbuild/darwin-x64",
|
| 1763 |
+
"freebsd arm64 LE": "@esbuild/freebsd-arm64",
|
| 1764 |
+
"freebsd x64 LE": "@esbuild/freebsd-x64",
|
| 1765 |
+
"linux arm LE": "@esbuild/linux-arm",
|
| 1766 |
+
"linux arm64 LE": "@esbuild/linux-arm64",
|
| 1767 |
+
"linux ia32 LE": "@esbuild/linux-ia32",
|
| 1768 |
+
"linux mips64el LE": "@esbuild/linux-mips64el",
|
| 1769 |
+
"linux ppc64 LE": "@esbuild/linux-ppc64",
|
| 1770 |
+
"linux riscv64 LE": "@esbuild/linux-riscv64",
|
| 1771 |
+
"linux s390x BE": "@esbuild/linux-s390x",
|
| 1772 |
+
"linux x64 LE": "@esbuild/linux-x64",
|
| 1773 |
+
"linux loong64 LE": "@esbuild/linux-loong64",
|
| 1774 |
+
"netbsd x64 LE": "@esbuild/netbsd-x64",
|
| 1775 |
+
"openbsd x64 LE": "@esbuild/openbsd-x64",
|
| 1776 |
+
"sunos x64 LE": "@esbuild/sunos-x64"
|
| 1777 |
+
};
|
| 1778 |
+
var knownWebAssemblyFallbackPackages = {
|
| 1779 |
+
"android arm LE": "@esbuild/android-arm",
|
| 1780 |
+
"android x64 LE": "@esbuild/android-x64"
|
| 1781 |
+
};
|
| 1782 |
+
function pkgAndSubpathForCurrentPlatform() {
|
| 1783 |
+
let pkg;
|
| 1784 |
+
let subpath;
|
| 1785 |
+
let isWASM = false;
|
| 1786 |
+
let platformKey = `${process.platform} ${os.arch()} ${os.endianness()}`;
|
| 1787 |
+
if (platformKey in knownWindowsPackages) {
|
| 1788 |
+
pkg = knownWindowsPackages[platformKey];
|
| 1789 |
+
subpath = "esbuild.exe";
|
| 1790 |
+
} else if (platformKey in knownUnixlikePackages) {
|
| 1791 |
+
pkg = knownUnixlikePackages[platformKey];
|
| 1792 |
+
subpath = "bin/esbuild";
|
| 1793 |
+
} else if (platformKey in knownWebAssemblyFallbackPackages) {
|
| 1794 |
+
pkg = knownWebAssemblyFallbackPackages[platformKey];
|
| 1795 |
+
subpath = "bin/esbuild";
|
| 1796 |
+
isWASM = true;
|
| 1797 |
+
} else {
|
| 1798 |
+
throw new Error(`Unsupported platform: ${platformKey}`);
|
| 1799 |
+
}
|
| 1800 |
+
return { pkg, subpath, isWASM };
|
| 1801 |
+
}
|
| 1802 |
+
function pkgForSomeOtherPlatform() {
|
| 1803 |
+
const libMainJS = require.resolve("esbuild");
|
| 1804 |
+
const nodeModulesDirectory = path.dirname(path.dirname(path.dirname(libMainJS)));
|
| 1805 |
+
if (path.basename(nodeModulesDirectory) === "node_modules") {
|
| 1806 |
+
for (const unixKey in knownUnixlikePackages) {
|
| 1807 |
+
try {
|
| 1808 |
+
const pkg = knownUnixlikePackages[unixKey];
|
| 1809 |
+
if (fs.existsSync(path.join(nodeModulesDirectory, pkg)))
|
| 1810 |
+
return pkg;
|
| 1811 |
+
} catch {
|
| 1812 |
+
}
|
| 1813 |
+
}
|
| 1814 |
+
for (const windowsKey in knownWindowsPackages) {
|
| 1815 |
+
try {
|
| 1816 |
+
const pkg = knownWindowsPackages[windowsKey];
|
| 1817 |
+
if (fs.existsSync(path.join(nodeModulesDirectory, pkg)))
|
| 1818 |
+
return pkg;
|
| 1819 |
+
} catch {
|
| 1820 |
+
}
|
| 1821 |
+
}
|
| 1822 |
+
}
|
| 1823 |
+
return null;
|
| 1824 |
+
}
|
| 1825 |
+
function downloadedBinPath(pkg, subpath) {
|
| 1826 |
+
const esbuildLibDir = path.dirname(require.resolve("esbuild"));
|
| 1827 |
+
return path.join(esbuildLibDir, `downloaded-${pkg.replace("/", "-")}-${path.basename(subpath)}`);
|
| 1828 |
+
}
|
| 1829 |
+
function generateBinPath() {
|
| 1830 |
+
if (isValidBinaryPath(ESBUILD_BINARY_PATH)) {
|
| 1831 |
+
if (!fs.existsSync(ESBUILD_BINARY_PATH)) {
|
| 1832 |
+
console.warn(`[esbuild] Ignoring bad configuration: ESBUILD_BINARY_PATH=${ESBUILD_BINARY_PATH}`);
|
| 1833 |
+
} else {
|
| 1834 |
+
return { binPath: ESBUILD_BINARY_PATH, isWASM: false };
|
| 1835 |
+
}
|
| 1836 |
+
}
|
| 1837 |
+
const { pkg, subpath, isWASM } = pkgAndSubpathForCurrentPlatform();
|
| 1838 |
+
let binPath;
|
| 1839 |
+
try {
|
| 1840 |
+
binPath = require.resolve(`${pkg}/${subpath}`);
|
| 1841 |
+
} catch (e) {
|
| 1842 |
+
binPath = downloadedBinPath(pkg, subpath);
|
| 1843 |
+
if (!fs.existsSync(binPath)) {
|
| 1844 |
+
try {
|
| 1845 |
+
require.resolve(pkg);
|
| 1846 |
+
} catch {
|
| 1847 |
+
const otherPkg = pkgForSomeOtherPlatform();
|
| 1848 |
+
if (otherPkg) {
|
| 1849 |
+
let suggestions = `
|
| 1850 |
+
Specifically the "${otherPkg}" package is present but this platform
|
| 1851 |
+
needs the "${pkg}" package instead. People often get into this
|
| 1852 |
+
situation by installing esbuild on Windows or macOS and copying "node_modules"
|
| 1853 |
+
into a Docker image that runs Linux, or by copying "node_modules" between
|
| 1854 |
+
Windows and WSL environments.
|
| 1855 |
+
|
| 1856 |
+
If you are installing with npm, you can try not copying the "node_modules"
|
| 1857 |
+
directory when you copy the files over, and running "npm ci" or "npm install"
|
| 1858 |
+
on the destination platform after the copy. Or you could consider using yarn
|
| 1859 |
+
instead of npm which has built-in support for installing a package on multiple
|
| 1860 |
+
platforms simultaneously.
|
| 1861 |
+
|
| 1862 |
+
If you are installing with yarn, you can try listing both this platform and the
|
| 1863 |
+
other platform in your ".yarnrc.yml" file using the "supportedArchitectures"
|
| 1864 |
+
feature: https://yarnpkg.com/configuration/yarnrc/#supportedArchitectures
|
| 1865 |
+
Keep in mind that this means multiple copies of esbuild will be present.
|
| 1866 |
+
`;
|
| 1867 |
+
if (pkg === packageDarwin_x64 && otherPkg === packageDarwin_arm64 || pkg === packageDarwin_arm64 && otherPkg === packageDarwin_x64) {
|
| 1868 |
+
suggestions = `
|
| 1869 |
+
Specifically the "${otherPkg}" package is present but this platform
|
| 1870 |
+
needs the "${pkg}" package instead. People often get into this
|
| 1871 |
+
situation by installing esbuild with npm running inside of Rosetta 2 and then
|
| 1872 |
+
trying to use it with node running outside of Rosetta 2, or vice versa (Rosetta
|
| 1873 |
+
2 is Apple's on-the-fly x86_64-to-arm64 translation service).
|
| 1874 |
+
|
| 1875 |
+
If you are installing with npm, you can try ensuring that both npm and node are
|
| 1876 |
+
not running under Rosetta 2 and then reinstalling esbuild. This likely involves
|
| 1877 |
+
changing how you installed npm and/or node. For example, installing node with
|
| 1878 |
+
the universal installer here should work: https://nodejs.org/en/download/. Or
|
| 1879 |
+
you could consider using yarn instead of npm which has built-in support for
|
| 1880 |
+
installing a package on multiple platforms simultaneously.
|
| 1881 |
+
|
| 1882 |
+
If you are installing with yarn, you can try listing both "arm64" and "x64"
|
| 1883 |
+
in your ".yarnrc.yml" file using the "supportedArchitectures" feature:
|
| 1884 |
+
https://yarnpkg.com/configuration/yarnrc/#supportedArchitectures
|
| 1885 |
+
Keep in mind that this means multiple copies of esbuild will be present.
|
| 1886 |
+
`;
|
| 1887 |
+
}
|
| 1888 |
+
throw new Error(`
|
| 1889 |
+
You installed esbuild for another platform than the one you're currently using.
|
| 1890 |
+
This won't work because esbuild is written with native code and needs to
|
| 1891 |
+
install a platform-specific binary executable.
|
| 1892 |
+
${suggestions}
|
| 1893 |
+
Another alternative is to use the "esbuild-wasm" package instead, which works
|
| 1894 |
+
the same way on all platforms. But it comes with a heavy performance cost and
|
| 1895 |
+
can sometimes be 10x slower than the "esbuild" package, so you may also not
|
| 1896 |
+
want to do that.
|
| 1897 |
+
`);
|
| 1898 |
+
}
|
| 1899 |
+
throw new Error(`The package "${pkg}" could not be found, and is needed by esbuild.
|
| 1900 |
+
|
| 1901 |
+
If you are installing esbuild with npm, make sure that you don't specify the
|
| 1902 |
+
"--no-optional" or "--omit=optional" flags. The "optionalDependencies" feature
|
| 1903 |
+
of "package.json" is used by esbuild to install the correct binary executable
|
| 1904 |
+
for your current platform.`);
|
| 1905 |
+
}
|
| 1906 |
+
throw e;
|
| 1907 |
+
}
|
| 1908 |
+
}
|
| 1909 |
+
if (/\.zip\//.test(binPath)) {
|
| 1910 |
+
let pnpapi;
|
| 1911 |
+
try {
|
| 1912 |
+
pnpapi = require("pnpapi");
|
| 1913 |
+
} catch (e) {
|
| 1914 |
+
}
|
| 1915 |
+
if (pnpapi) {
|
| 1916 |
+
const root = pnpapi.getPackageInformation(pnpapi.topLevel).packageLocation;
|
| 1917 |
+
const binTargetPath = path.join(
|
| 1918 |
+
root,
|
| 1919 |
+
"node_modules",
|
| 1920 |
+
".cache",
|
| 1921 |
+
"esbuild",
|
| 1922 |
+
`pnpapi-${pkg.replace("/", "-")}-${"0.18.20"}-${path.basename(subpath)}`
|
| 1923 |
+
);
|
| 1924 |
+
if (!fs.existsSync(binTargetPath)) {
|
| 1925 |
+
fs.mkdirSync(path.dirname(binTargetPath), { recursive: true });
|
| 1926 |
+
fs.copyFileSync(binPath, binTargetPath);
|
| 1927 |
+
fs.chmodSync(binTargetPath, 493);
|
| 1928 |
+
}
|
| 1929 |
+
return { binPath: binTargetPath, isWASM };
|
| 1930 |
+
}
|
| 1931 |
+
}
|
| 1932 |
+
return { binPath, isWASM };
|
| 1933 |
+
}
|
| 1934 |
+
|
| 1935 |
+
// lib/npm/node.ts
|
| 1936 |
+
var child_process = require("child_process");
|
| 1937 |
+
var crypto = require("crypto");
|
| 1938 |
+
var path2 = require("path");
|
| 1939 |
+
var fs2 = require("fs");
|
| 1940 |
+
var os2 = require("os");
|
| 1941 |
+
var tty = require("tty");
|
| 1942 |
+
var worker_threads;
|
| 1943 |
+
if (process.env.ESBUILD_WORKER_THREADS !== "0") {
|
| 1944 |
+
try {
|
| 1945 |
+
worker_threads = require("worker_threads");
|
| 1946 |
+
} catch {
|
| 1947 |
+
}
|
| 1948 |
+
let [major, minor] = process.versions.node.split(".");
|
| 1949 |
+
if (
|
| 1950 |
+
// <v12.17.0 does not work
|
| 1951 |
+
+major < 12 || +major === 12 && +minor < 17 || +major === 13 && +minor < 13
|
| 1952 |
+
) {
|
| 1953 |
+
worker_threads = void 0;
|
| 1954 |
+
}
|
| 1955 |
+
}
|
| 1956 |
+
var _a;
|
| 1957 |
+
var isInternalWorkerThread = ((_a = worker_threads == null ? void 0 : worker_threads.workerData) == null ? void 0 : _a.esbuildVersion) === "0.18.20";
|
| 1958 |
+
var esbuildCommandAndArgs = () => {
|
| 1959 |
+
if ((!ESBUILD_BINARY_PATH || false) && (path2.basename(__filename) !== "main.js" || path2.basename(__dirname) !== "lib")) {
|
| 1960 |
+
throw new Error(
|
| 1961 |
+
`The esbuild JavaScript API cannot be bundled. Please mark the "esbuild" package as external so it's not included in the bundle.
|
| 1962 |
+
|
| 1963 |
+
More information: The file containing the code for esbuild's JavaScript API (${__filename}) does not appear to be inside the esbuild package on the file system, which usually means that the esbuild package was bundled into another file. This is problematic because the API needs to run a binary executable inside the esbuild package which is located using a relative path from the API code to the executable. If the esbuild package is bundled, the relative path will be incorrect and the executable won't be found.`
|
| 1964 |
+
);
|
| 1965 |
+
}
|
| 1966 |
+
if (false) {
|
| 1967 |
+
return ["node", [path2.join(__dirname, "..", "bin", "esbuild")]];
|
| 1968 |
+
} else {
|
| 1969 |
+
const { binPath, isWASM } = generateBinPath();
|
| 1970 |
+
if (isWASM) {
|
| 1971 |
+
return ["node", [binPath]];
|
| 1972 |
+
} else {
|
| 1973 |
+
return [binPath, []];
|
| 1974 |
+
}
|
| 1975 |
+
}
|
| 1976 |
+
};
|
| 1977 |
+
var isTTY = () => tty.isatty(2);
|
| 1978 |
+
var fsSync = {
|
| 1979 |
+
readFile(tempFile, callback) {
|
| 1980 |
+
try {
|
| 1981 |
+
let contents = fs2.readFileSync(tempFile, "utf8");
|
| 1982 |
+
try {
|
| 1983 |
+
fs2.unlinkSync(tempFile);
|
| 1984 |
+
} catch {
|
| 1985 |
+
}
|
| 1986 |
+
callback(null, contents);
|
| 1987 |
+
} catch (err) {
|
| 1988 |
+
callback(err, null);
|
| 1989 |
+
}
|
| 1990 |
+
},
|
| 1991 |
+
writeFile(contents, callback) {
|
| 1992 |
+
try {
|
| 1993 |
+
let tempFile = randomFileName();
|
| 1994 |
+
fs2.writeFileSync(tempFile, contents);
|
| 1995 |
+
callback(tempFile);
|
| 1996 |
+
} catch {
|
| 1997 |
+
callback(null);
|
| 1998 |
+
}
|
| 1999 |
+
}
|
| 2000 |
+
};
|
| 2001 |
+
var fsAsync = {
|
| 2002 |
+
readFile(tempFile, callback) {
|
| 2003 |
+
try {
|
| 2004 |
+
fs2.readFile(tempFile, "utf8", (err, contents) => {
|
| 2005 |
+
try {
|
| 2006 |
+
fs2.unlink(tempFile, () => callback(err, contents));
|
| 2007 |
+
} catch {
|
| 2008 |
+
callback(err, contents);
|
| 2009 |
+
}
|
| 2010 |
+
});
|
| 2011 |
+
} catch (err) {
|
| 2012 |
+
callback(err, null);
|
| 2013 |
+
}
|
| 2014 |
+
},
|
| 2015 |
+
writeFile(contents, callback) {
|
| 2016 |
+
try {
|
| 2017 |
+
let tempFile = randomFileName();
|
| 2018 |
+
fs2.writeFile(tempFile, contents, (err) => err !== null ? callback(null) : callback(tempFile));
|
| 2019 |
+
} catch {
|
| 2020 |
+
callback(null);
|
| 2021 |
+
}
|
| 2022 |
+
}
|
| 2023 |
+
};
|
| 2024 |
+
var version = "0.18.20";
|
| 2025 |
+
var build = (options) => ensureServiceIsRunning().build(options);
|
| 2026 |
+
var context = (buildOptions) => ensureServiceIsRunning().context(buildOptions);
|
| 2027 |
+
var transform = (input, options) => ensureServiceIsRunning().transform(input, options);
|
| 2028 |
+
var formatMessages = (messages, options) => ensureServiceIsRunning().formatMessages(messages, options);
|
| 2029 |
+
var analyzeMetafile = (messages, options) => ensureServiceIsRunning().analyzeMetafile(messages, options);
|
| 2030 |
+
var buildSync = (options) => {
|
| 2031 |
+
if (worker_threads && !isInternalWorkerThread) {
|
| 2032 |
+
if (!workerThreadService)
|
| 2033 |
+
workerThreadService = startWorkerThreadService(worker_threads);
|
| 2034 |
+
return workerThreadService.buildSync(options);
|
| 2035 |
+
}
|
| 2036 |
+
let result;
|
| 2037 |
+
runServiceSync((service) => service.buildOrContext({
|
| 2038 |
+
callName: "buildSync",
|
| 2039 |
+
refs: null,
|
| 2040 |
+
options,
|
| 2041 |
+
isTTY: isTTY(),
|
| 2042 |
+
defaultWD,
|
| 2043 |
+
callback: (err, res) => {
|
| 2044 |
+
if (err)
|
| 2045 |
+
throw err;
|
| 2046 |
+
result = res;
|
| 2047 |
+
}
|
| 2048 |
+
}));
|
| 2049 |
+
return result;
|
| 2050 |
+
};
|
| 2051 |
+
var transformSync = (input, options) => {
|
| 2052 |
+
if (worker_threads && !isInternalWorkerThread) {
|
| 2053 |
+
if (!workerThreadService)
|
| 2054 |
+
workerThreadService = startWorkerThreadService(worker_threads);
|
| 2055 |
+
return workerThreadService.transformSync(input, options);
|
| 2056 |
+
}
|
| 2057 |
+
let result;
|
| 2058 |
+
runServiceSync((service) => service.transform({
|
| 2059 |
+
callName: "transformSync",
|
| 2060 |
+
refs: null,
|
| 2061 |
+
input,
|
| 2062 |
+
options: options || {},
|
| 2063 |
+
isTTY: isTTY(),
|
| 2064 |
+
fs: fsSync,
|
| 2065 |
+
callback: (err, res) => {
|
| 2066 |
+
if (err)
|
| 2067 |
+
throw err;
|
| 2068 |
+
result = res;
|
| 2069 |
+
}
|
| 2070 |
+
}));
|
| 2071 |
+
return result;
|
| 2072 |
+
};
|
| 2073 |
+
var formatMessagesSync = (messages, options) => {
|
| 2074 |
+
if (worker_threads && !isInternalWorkerThread) {
|
| 2075 |
+
if (!workerThreadService)
|
| 2076 |
+
workerThreadService = startWorkerThreadService(worker_threads);
|
| 2077 |
+
return workerThreadService.formatMessagesSync(messages, options);
|
| 2078 |
+
}
|
| 2079 |
+
let result;
|
| 2080 |
+
runServiceSync((service) => service.formatMessages({
|
| 2081 |
+
callName: "formatMessagesSync",
|
| 2082 |
+
refs: null,
|
| 2083 |
+
messages,
|
| 2084 |
+
options,
|
| 2085 |
+
callback: (err, res) => {
|
| 2086 |
+
if (err)
|
| 2087 |
+
throw err;
|
| 2088 |
+
result = res;
|
| 2089 |
+
}
|
| 2090 |
+
}));
|
| 2091 |
+
return result;
|
| 2092 |
+
};
|
| 2093 |
+
var analyzeMetafileSync = (metafile, options) => {
|
| 2094 |
+
if (worker_threads && !isInternalWorkerThread) {
|
| 2095 |
+
if (!workerThreadService)
|
| 2096 |
+
workerThreadService = startWorkerThreadService(worker_threads);
|
| 2097 |
+
return workerThreadService.analyzeMetafileSync(metafile, options);
|
| 2098 |
+
}
|
| 2099 |
+
let result;
|
| 2100 |
+
runServiceSync((service) => service.analyzeMetafile({
|
| 2101 |
+
callName: "analyzeMetafileSync",
|
| 2102 |
+
refs: null,
|
| 2103 |
+
metafile: typeof metafile === "string" ? metafile : JSON.stringify(metafile),
|
| 2104 |
+
options,
|
| 2105 |
+
callback: (err, res) => {
|
| 2106 |
+
if (err)
|
| 2107 |
+
throw err;
|
| 2108 |
+
result = res;
|
| 2109 |
+
}
|
| 2110 |
+
}));
|
| 2111 |
+
return result;
|
| 2112 |
+
};
|
| 2113 |
+
var initializeWasCalled = false;
|
| 2114 |
+
var initialize = (options) => {
|
| 2115 |
+
options = validateInitializeOptions(options || {});
|
| 2116 |
+
if (options.wasmURL)
|
| 2117 |
+
throw new Error(`The "wasmURL" option only works in the browser`);
|
| 2118 |
+
if (options.wasmModule)
|
| 2119 |
+
throw new Error(`The "wasmModule" option only works in the browser`);
|
| 2120 |
+
if (options.worker)
|
| 2121 |
+
throw new Error(`The "worker" option only works in the browser`);
|
| 2122 |
+
if (initializeWasCalled)
|
| 2123 |
+
throw new Error('Cannot call "initialize" more than once');
|
| 2124 |
+
ensureServiceIsRunning();
|
| 2125 |
+
initializeWasCalled = true;
|
| 2126 |
+
return Promise.resolve();
|
| 2127 |
+
};
|
| 2128 |
+
var defaultWD = process.cwd();
|
| 2129 |
+
var longLivedService;
|
| 2130 |
+
var ensureServiceIsRunning = () => {
|
| 2131 |
+
if (longLivedService)
|
| 2132 |
+
return longLivedService;
|
| 2133 |
+
let [command, args] = esbuildCommandAndArgs();
|
| 2134 |
+
let child = child_process.spawn(command, args.concat(`--service=${"0.18.20"}`, "--ping"), {
|
| 2135 |
+
windowsHide: true,
|
| 2136 |
+
stdio: ["pipe", "pipe", "inherit"],
|
| 2137 |
+
cwd: defaultWD
|
| 2138 |
+
});
|
| 2139 |
+
let { readFromStdout, afterClose, service } = createChannel({
|
| 2140 |
+
writeToStdin(bytes) {
|
| 2141 |
+
child.stdin.write(bytes, (err) => {
|
| 2142 |
+
if (err)
|
| 2143 |
+
afterClose(err);
|
| 2144 |
+
});
|
| 2145 |
+
},
|
| 2146 |
+
readFileSync: fs2.readFileSync,
|
| 2147 |
+
isSync: false,
|
| 2148 |
+
hasFS: true,
|
| 2149 |
+
esbuild: node_exports
|
| 2150 |
+
});
|
| 2151 |
+
child.stdin.on("error", afterClose);
|
| 2152 |
+
child.on("error", afterClose);
|
| 2153 |
+
const stdin = child.stdin;
|
| 2154 |
+
const stdout = child.stdout;
|
| 2155 |
+
stdout.on("data", readFromStdout);
|
| 2156 |
+
stdout.on("end", afterClose);
|
| 2157 |
+
let refCount = 0;
|
| 2158 |
+
child.unref();
|
| 2159 |
+
if (stdin.unref) {
|
| 2160 |
+
stdin.unref();
|
| 2161 |
+
}
|
| 2162 |
+
if (stdout.unref) {
|
| 2163 |
+
stdout.unref();
|
| 2164 |
+
}
|
| 2165 |
+
const refs = {
|
| 2166 |
+
ref() {
|
| 2167 |
+
if (++refCount === 1)
|
| 2168 |
+
child.ref();
|
| 2169 |
+
},
|
| 2170 |
+
unref() {
|
| 2171 |
+
if (--refCount === 0)
|
| 2172 |
+
child.unref();
|
| 2173 |
+
}
|
| 2174 |
+
};
|
| 2175 |
+
longLivedService = {
|
| 2176 |
+
build: (options) => new Promise((resolve, reject) => {
|
| 2177 |
+
service.buildOrContext({
|
| 2178 |
+
callName: "build",
|
| 2179 |
+
refs,
|
| 2180 |
+
options,
|
| 2181 |
+
isTTY: isTTY(),
|
| 2182 |
+
defaultWD,
|
| 2183 |
+
callback: (err, res) => err ? reject(err) : resolve(res)
|
| 2184 |
+
});
|
| 2185 |
+
}),
|
| 2186 |
+
context: (options) => new Promise((resolve, reject) => service.buildOrContext({
|
| 2187 |
+
callName: "context",
|
| 2188 |
+
refs,
|
| 2189 |
+
options,
|
| 2190 |
+
isTTY: isTTY(),
|
| 2191 |
+
defaultWD,
|
| 2192 |
+
callback: (err, res) => err ? reject(err) : resolve(res)
|
| 2193 |
+
})),
|
| 2194 |
+
transform: (input, options) => new Promise((resolve, reject) => service.transform({
|
| 2195 |
+
callName: "transform",
|
| 2196 |
+
refs,
|
| 2197 |
+
input,
|
| 2198 |
+
options: options || {},
|
| 2199 |
+
isTTY: isTTY(),
|
| 2200 |
+
fs: fsAsync,
|
| 2201 |
+
callback: (err, res) => err ? reject(err) : resolve(res)
|
| 2202 |
+
})),
|
| 2203 |
+
formatMessages: (messages, options) => new Promise((resolve, reject) => service.formatMessages({
|
| 2204 |
+
callName: "formatMessages",
|
| 2205 |
+
refs,
|
| 2206 |
+
messages,
|
| 2207 |
+
options,
|
| 2208 |
+
callback: (err, res) => err ? reject(err) : resolve(res)
|
| 2209 |
+
})),
|
| 2210 |
+
analyzeMetafile: (metafile, options) => new Promise((resolve, reject) => service.analyzeMetafile({
|
| 2211 |
+
callName: "analyzeMetafile",
|
| 2212 |
+
refs,
|
| 2213 |
+
metafile: typeof metafile === "string" ? metafile : JSON.stringify(metafile),
|
| 2214 |
+
options,
|
| 2215 |
+
callback: (err, res) => err ? reject(err) : resolve(res)
|
| 2216 |
+
}))
|
| 2217 |
+
};
|
| 2218 |
+
return longLivedService;
|
| 2219 |
+
};
|
| 2220 |
+
var runServiceSync = (callback) => {
|
| 2221 |
+
let [command, args] = esbuildCommandAndArgs();
|
| 2222 |
+
let stdin = new Uint8Array();
|
| 2223 |
+
let { readFromStdout, afterClose, service } = createChannel({
|
| 2224 |
+
writeToStdin(bytes) {
|
| 2225 |
+
if (stdin.length !== 0)
|
| 2226 |
+
throw new Error("Must run at most one command");
|
| 2227 |
+
stdin = bytes;
|
| 2228 |
+
},
|
| 2229 |
+
isSync: true,
|
| 2230 |
+
hasFS: true,
|
| 2231 |
+
esbuild: node_exports
|
| 2232 |
+
});
|
| 2233 |
+
callback(service);
|
| 2234 |
+
let stdout = child_process.execFileSync(command, args.concat(`--service=${"0.18.20"}`), {
|
| 2235 |
+
cwd: defaultWD,
|
| 2236 |
+
windowsHide: true,
|
| 2237 |
+
input: stdin,
|
| 2238 |
+
// We don't know how large the output could be. If it's too large, the
|
| 2239 |
+
// command will fail with ENOBUFS. Reserve 16mb for now since that feels
|
| 2240 |
+
// like it should be enough. Also allow overriding this with an environment
|
| 2241 |
+
// variable.
|
| 2242 |
+
maxBuffer: +process.env.ESBUILD_MAX_BUFFER || 16 * 1024 * 1024
|
| 2243 |
+
});
|
| 2244 |
+
readFromStdout(stdout);
|
| 2245 |
+
afterClose(null);
|
| 2246 |
+
};
|
| 2247 |
+
var randomFileName = () => {
|
| 2248 |
+
return path2.join(os2.tmpdir(), `esbuild-${crypto.randomBytes(32).toString("hex")}`);
|
| 2249 |
+
};
|
| 2250 |
+
var workerThreadService = null;
|
| 2251 |
+
var startWorkerThreadService = (worker_threads2) => {
|
| 2252 |
+
let { port1: mainPort, port2: workerPort } = new worker_threads2.MessageChannel();
|
| 2253 |
+
let worker = new worker_threads2.Worker(__filename, {
|
| 2254 |
+
workerData: { workerPort, defaultWD, esbuildVersion: "0.18.20" },
|
| 2255 |
+
transferList: [workerPort],
|
| 2256 |
+
// From node's documentation: https://nodejs.org/api/worker_threads.html
|
| 2257 |
+
//
|
| 2258 |
+
// Take care when launching worker threads from preload scripts (scripts loaded
|
| 2259 |
+
// and run using the `-r` command line flag). Unless the `execArgv` option is
|
| 2260 |
+
// explicitly set, new Worker threads automatically inherit the command line flags
|
| 2261 |
+
// from the running process and will preload the same preload scripts as the main
|
| 2262 |
+
// thread. If the preload script unconditionally launches a worker thread, every
|
| 2263 |
+
// thread spawned will spawn another until the application crashes.
|
| 2264 |
+
//
|
| 2265 |
+
execArgv: []
|
| 2266 |
+
});
|
| 2267 |
+
let nextID = 0;
|
| 2268 |
+
let fakeBuildError = (text) => {
|
| 2269 |
+
let error = new Error(`Build failed with 1 error:
|
| 2270 |
+
error: ${text}`);
|
| 2271 |
+
let errors = [{ id: "", pluginName: "", text, location: null, notes: [], detail: void 0 }];
|
| 2272 |
+
error.errors = errors;
|
| 2273 |
+
error.warnings = [];
|
| 2274 |
+
return error;
|
| 2275 |
+
};
|
| 2276 |
+
let validateBuildSyncOptions = (options) => {
|
| 2277 |
+
if (!options)
|
| 2278 |
+
return;
|
| 2279 |
+
let plugins = options.plugins;
|
| 2280 |
+
if (plugins && plugins.length > 0)
|
| 2281 |
+
throw fakeBuildError(`Cannot use plugins in synchronous API calls`);
|
| 2282 |
+
};
|
| 2283 |
+
let applyProperties = (object, properties) => {
|
| 2284 |
+
for (let key in properties) {
|
| 2285 |
+
object[key] = properties[key];
|
| 2286 |
+
}
|
| 2287 |
+
};
|
| 2288 |
+
let runCallSync = (command, args) => {
|
| 2289 |
+
let id = nextID++;
|
| 2290 |
+
let sharedBuffer = new SharedArrayBuffer(8);
|
| 2291 |
+
let sharedBufferView = new Int32Array(sharedBuffer);
|
| 2292 |
+
let msg = { sharedBuffer, id, command, args };
|
| 2293 |
+
worker.postMessage(msg);
|
| 2294 |
+
let status = Atomics.wait(sharedBufferView, 0, 0);
|
| 2295 |
+
if (status !== "ok" && status !== "not-equal")
|
| 2296 |
+
throw new Error("Internal error: Atomics.wait() failed: " + status);
|
| 2297 |
+
let { message: { id: id2, resolve, reject, properties } } = worker_threads2.receiveMessageOnPort(mainPort);
|
| 2298 |
+
if (id !== id2)
|
| 2299 |
+
throw new Error(`Internal error: Expected id ${id} but got id ${id2}`);
|
| 2300 |
+
if (reject) {
|
| 2301 |
+
applyProperties(reject, properties);
|
| 2302 |
+
throw reject;
|
| 2303 |
+
}
|
| 2304 |
+
return resolve;
|
| 2305 |
+
};
|
| 2306 |
+
worker.unref();
|
| 2307 |
+
return {
|
| 2308 |
+
buildSync(options) {
|
| 2309 |
+
validateBuildSyncOptions(options);
|
| 2310 |
+
return runCallSync("build", [options]);
|
| 2311 |
+
},
|
| 2312 |
+
transformSync(input, options) {
|
| 2313 |
+
return runCallSync("transform", [input, options]);
|
| 2314 |
+
},
|
| 2315 |
+
formatMessagesSync(messages, options) {
|
| 2316 |
+
return runCallSync("formatMessages", [messages, options]);
|
| 2317 |
+
},
|
| 2318 |
+
analyzeMetafileSync(metafile, options) {
|
| 2319 |
+
return runCallSync("analyzeMetafile", [metafile, options]);
|
| 2320 |
+
}
|
| 2321 |
+
};
|
| 2322 |
+
};
|
| 2323 |
+
var startSyncServiceWorker = () => {
|
| 2324 |
+
let workerPort = worker_threads.workerData.workerPort;
|
| 2325 |
+
let parentPort = worker_threads.parentPort;
|
| 2326 |
+
let extractProperties = (object) => {
|
| 2327 |
+
let properties = {};
|
| 2328 |
+
if (object && typeof object === "object") {
|
| 2329 |
+
for (let key in object) {
|
| 2330 |
+
properties[key] = object[key];
|
| 2331 |
+
}
|
| 2332 |
+
}
|
| 2333 |
+
return properties;
|
| 2334 |
+
};
|
| 2335 |
+
try {
|
| 2336 |
+
let service = ensureServiceIsRunning();
|
| 2337 |
+
defaultWD = worker_threads.workerData.defaultWD;
|
| 2338 |
+
parentPort.on("message", (msg) => {
|
| 2339 |
+
(async () => {
|
| 2340 |
+
let { sharedBuffer, id, command, args } = msg;
|
| 2341 |
+
let sharedBufferView = new Int32Array(sharedBuffer);
|
| 2342 |
+
try {
|
| 2343 |
+
switch (command) {
|
| 2344 |
+
case "build":
|
| 2345 |
+
workerPort.postMessage({ id, resolve: await service.build(args[0]) });
|
| 2346 |
+
break;
|
| 2347 |
+
case "transform":
|
| 2348 |
+
workerPort.postMessage({ id, resolve: await service.transform(args[0], args[1]) });
|
| 2349 |
+
break;
|
| 2350 |
+
case "formatMessages":
|
| 2351 |
+
workerPort.postMessage({ id, resolve: await service.formatMessages(args[0], args[1]) });
|
| 2352 |
+
break;
|
| 2353 |
+
case "analyzeMetafile":
|
| 2354 |
+
workerPort.postMessage({ id, resolve: await service.analyzeMetafile(args[0], args[1]) });
|
| 2355 |
+
break;
|
| 2356 |
+
default:
|
| 2357 |
+
throw new Error(`Invalid command: ${command}`);
|
| 2358 |
+
}
|
| 2359 |
+
} catch (reject) {
|
| 2360 |
+
workerPort.postMessage({ id, reject, properties: extractProperties(reject) });
|
| 2361 |
+
}
|
| 2362 |
+
Atomics.add(sharedBufferView, 0, 1);
|
| 2363 |
+
Atomics.notify(sharedBufferView, 0, Infinity);
|
| 2364 |
+
})();
|
| 2365 |
+
});
|
| 2366 |
+
} catch (reject) {
|
| 2367 |
+
parentPort.on("message", (msg) => {
|
| 2368 |
+
let { sharedBuffer, id } = msg;
|
| 2369 |
+
let sharedBufferView = new Int32Array(sharedBuffer);
|
| 2370 |
+
workerPort.postMessage({ id, reject, properties: extractProperties(reject) });
|
| 2371 |
+
Atomics.add(sharedBufferView, 0, 1);
|
| 2372 |
+
Atomics.notify(sharedBufferView, 0, Infinity);
|
| 2373 |
+
});
|
| 2374 |
+
}
|
| 2375 |
+
};
|
| 2376 |
+
if (isInternalWorkerThread) {
|
| 2377 |
+
startSyncServiceWorker();
|
| 2378 |
+
}
|
| 2379 |
+
var node_default = node_exports;
|
| 2380 |
+
// Annotate the CommonJS export names for ESM import in node:
|
| 2381 |
+
0 && (module.exports = {
|
| 2382 |
+
analyzeMetafile,
|
| 2383 |
+
analyzeMetafileSync,
|
| 2384 |
+
build,
|
| 2385 |
+
buildSync,
|
| 2386 |
+
context,
|
| 2387 |
+
formatMessages,
|
| 2388 |
+
formatMessagesSync,
|
| 2389 |
+
initialize,
|
| 2390 |
+
transform,
|
| 2391 |
+
transformSync,
|
| 2392 |
+
version
|
| 2393 |
+
});
|
e-commerce/node_modules/@esbuild-kit/core-utils/node_modules/esbuild/package.json
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "esbuild",
|
| 3 |
+
"version": "0.18.20",
|
| 4 |
+
"description": "An extremely fast JavaScript and CSS bundler and minifier.",
|
| 5 |
+
"repository": "https://github.com/evanw/esbuild",
|
| 6 |
+
"scripts": {
|
| 7 |
+
"postinstall": "node install.js"
|
| 8 |
+
},
|
| 9 |
+
"main": "lib/main.js",
|
| 10 |
+
"types": "lib/main.d.ts",
|
| 11 |
+
"engines": {
|
| 12 |
+
"node": ">=12"
|
| 13 |
+
},
|
| 14 |
+
"bin": {
|
| 15 |
+
"esbuild": "bin/esbuild"
|
| 16 |
+
},
|
| 17 |
+
"optionalDependencies": {
|
| 18 |
+
"@esbuild/android-arm": "0.18.20",
|
| 19 |
+
"@esbuild/android-arm64": "0.18.20",
|
| 20 |
+
"@esbuild/android-x64": "0.18.20",
|
| 21 |
+
"@esbuild/darwin-arm64": "0.18.20",
|
| 22 |
+
"@esbuild/darwin-x64": "0.18.20",
|
| 23 |
+
"@esbuild/freebsd-arm64": "0.18.20",
|
| 24 |
+
"@esbuild/freebsd-x64": "0.18.20",
|
| 25 |
+
"@esbuild/linux-arm": "0.18.20",
|
| 26 |
+
"@esbuild/linux-arm64": "0.18.20",
|
| 27 |
+
"@esbuild/linux-ia32": "0.18.20",
|
| 28 |
+
"@esbuild/linux-loong64": "0.18.20",
|
| 29 |
+
"@esbuild/linux-mips64el": "0.18.20",
|
| 30 |
+
"@esbuild/linux-ppc64": "0.18.20",
|
| 31 |
+
"@esbuild/linux-riscv64": "0.18.20",
|
| 32 |
+
"@esbuild/linux-s390x": "0.18.20",
|
| 33 |
+
"@esbuild/linux-x64": "0.18.20",
|
| 34 |
+
"@esbuild/netbsd-x64": "0.18.20",
|
| 35 |
+
"@esbuild/openbsd-x64": "0.18.20",
|
| 36 |
+
"@esbuild/sunos-x64": "0.18.20",
|
| 37 |
+
"@esbuild/win32-arm64": "0.18.20",
|
| 38 |
+
"@esbuild/win32-ia32": "0.18.20",
|
| 39 |
+
"@esbuild/win32-x64": "0.18.20"
|
| 40 |
+
},
|
| 41 |
+
"license": "MIT"
|
| 42 |
+
}
|
e-commerce/node_modules/@esbuild-kit/core-utils/package.json
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "@esbuild-kit/core-utils",
|
| 3 |
+
"version": "3.3.2",
|
| 4 |
+
"publishConfig": {
|
| 5 |
+
"access": "public"
|
| 6 |
+
},
|
| 7 |
+
"license": "MIT",
|
| 8 |
+
"repository": "esbuild-kit/core-utils",
|
| 9 |
+
"author": {
|
| 10 |
+
"name": "Hiroki Osame",
|
| 11 |
+
"email": "hiroki.osame@gmail.com"
|
| 12 |
+
},
|
| 13 |
+
"files": [
|
| 14 |
+
"dist"
|
| 15 |
+
],
|
| 16 |
+
"main": "./dist/index.js",
|
| 17 |
+
"types": "./dist/index.d.ts",
|
| 18 |
+
"exports": {
|
| 19 |
+
"types": "./dist/index.d.ts",
|
| 20 |
+
"default": "./dist/index.js"
|
| 21 |
+
},
|
| 22 |
+
"imports": {
|
| 23 |
+
"#esbuild-kit/core-utils": {
|
| 24 |
+
"types": "./src/index.ts",
|
| 25 |
+
"development": "./src/index.ts",
|
| 26 |
+
"default": "./dist/index.js"
|
| 27 |
+
}
|
| 28 |
+
},
|
| 29 |
+
"dependencies": {
|
| 30 |
+
"esbuild": "~0.18.20",
|
| 31 |
+
"source-map-support": "^0.5.21"
|
| 32 |
+
}
|
| 33 |
+
}
|
e-commerce/node_modules/@esbuild-kit/esm-loader/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
MIT License
|
| 2 |
+
|
| 3 |
+
Copyright (c) Hiroki Osame <hiroki.osame@gmail.com>
|
| 4 |
+
|
| 5 |
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
| 6 |
+
of this software and associated documentation files (the "Software"), to deal
|
| 7 |
+
in the Software without restriction, including without limitation the rights
|
| 8 |
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
| 9 |
+
copies of the Software, and to permit persons to whom the Software is
|
| 10 |
+
furnished to do so, subject to the following conditions:
|
| 11 |
+
|
| 12 |
+
The above copyright notice and this permission notice shall be included in all
|
| 13 |
+
copies or substantial portions of the Software.
|
| 14 |
+
|
| 15 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
| 16 |
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
| 17 |
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
| 18 |
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
| 19 |
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
| 20 |
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
| 21 |
+
SOFTWARE.
|
e-commerce/node_modules/@esbuild-kit/esm-loader/README.md
ADDED
|
@@ -0,0 +1,155 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# esm-loader
|
| 2 |
+
|
| 3 |
+
[Node.js loader](https://nodejs.org/api/esm.html#loaders) for loading TypeScript files.
|
| 4 |
+
|
| 5 |
+
### Features
|
| 6 |
+
- Transforms TypeScript to ESM on demand
|
| 7 |
+
- Classic Node.js resolution (extensionless & directory imports)
|
| 8 |
+
- Cached for performance boost
|
| 9 |
+
- Supports Node.js v12.20.0+
|
| 10 |
+
- Handles `node:` import prefixes
|
| 11 |
+
- Resolves `tsconfig.json` [`paths`](https://www.typescriptlang.org/tsconfig#paths)
|
| 12 |
+
- Named imports from JSON modules
|
| 13 |
+
|
| 14 |
+
> **Protip: use with _cjs-loader_ or _tsx_**
|
| 15 |
+
>
|
| 16 |
+
> _esm-loader_ only transforms ES modules (`.mjs`/`.mts` extensions or `.js` files in `module` type packages).
|
| 17 |
+
>
|
| 18 |
+
> To transform CommonJS files (`.cjs`/`.cts` extensions or `.js` files in `commonjs` type packages), use this with [_cjs-loader_](https://github.com/esbuild-kit/cjs-loader).
|
| 19 |
+
>
|
| 20 |
+
> Alternatively, use [tsx](https://github.com/esbuild-kit/tsx) to handle them both automatically.
|
| 21 |
+
|
| 22 |
+
<br>
|
| 23 |
+
|
| 24 |
+
<p align="center">
|
| 25 |
+
<a href="https://privatenumber-sponsors.vercel.app/api/sponsor?tier=platinum">
|
| 26 |
+
<picture>
|
| 27 |
+
<source width="830" media="(prefers-color-scheme: dark)" srcset="https://privatenumber-sponsors.vercel.app/api/sponsor?tier=platinum&image=dark">
|
| 28 |
+
<source width="830" media="(prefers-color-scheme: light)" srcset="https://privatenumber-sponsors.vercel.app/api/sponsor?tier=platinum&image">
|
| 29 |
+
<img width="830" src="https://privatenumber-sponsors.vercel.app/api/sponsor?tier=platinum&image" alt="Premium sponsor banner">
|
| 30 |
+
</picture>
|
| 31 |
+
</a>
|
| 32 |
+
</p>
|
| 33 |
+
|
| 34 |
+
## Install
|
| 35 |
+
|
| 36 |
+
```sh
|
| 37 |
+
npm install --save-dev @esbuild-kit/esm-loader
|
| 38 |
+
```
|
| 39 |
+
|
| 40 |
+
## Usage
|
| 41 |
+
|
| 42 |
+
Pass `@esbuild-kit/esm-loader` into the [`--loader`](https://nodejs.org/api/cli.html#--experimental-loadermodule) flag.
|
| 43 |
+
```sh
|
| 44 |
+
node --loader @esbuild-kit/esm-loader ./file.ts
|
| 45 |
+
```
|
| 46 |
+
|
| 47 |
+
### TypeScript configuration
|
| 48 |
+
The following properties are used from `tsconfig.json` in the working directory:
|
| 49 |
+
- [`strict`](https://www.typescriptlang.org/tsconfig#strict): Whether to transform to strict mode
|
| 50 |
+
- [`jsx`](https://esbuild.github.io/api/#jsx): Whether to transform JSX
|
| 51 |
+
> **Warning:** When set to `preserve`, the JSX syntax will remain untransformed. To prevent Node.js from throwing a syntax error, chain another Node.js loader that can transform JSX to JS.
|
| 52 |
+
- [`jsxFactory`](https://esbuild.github.io/api/#jsx-factory): How to transform JSX
|
| 53 |
+
- [`jsxFragmentFactory`](https://esbuild.github.io/api/#jsx-fragment): How to transform JSX Fragments
|
| 54 |
+
- [`jsxImportSource`](https://www.typescriptlang.org/tsconfig#jsxImportSource): Where to import JSX functions from
|
| 55 |
+
- [`allowJs`](https://www.typescriptlang.org/tsconfig#allowJs): Whether to apply the tsconfig to JS files
|
| 56 |
+
- [`paths`](https://www.typescriptlang.org/tsconfig#paths): For resolving aliases
|
| 57 |
+
|
| 58 |
+
#### Custom `tsconfig.json` path
|
| 59 |
+
By default, `tsconfig.json` will be detected from the current working directory.
|
| 60 |
+
|
| 61 |
+
To set a custom path, use the `ESBK_TSCONFIG_PATH` environment variable:
|
| 62 |
+
|
| 63 |
+
```sh
|
| 64 |
+
ESBK_TSCONFIG_PATH=./path/to/tsconfig.custom.json node --loader @esbuild-kit/esm-loader ./file.ts
|
| 65 |
+
```
|
| 66 |
+
|
| 67 |
+
### Cache
|
| 68 |
+
Modules transformations are cached in the system cache directory ([`TMPDIR`](https://en.wikipedia.org/wiki/TMPDIR)). Transforms are cached by content hash so duplicate dependencies are not re-transformed.
|
| 69 |
+
|
| 70 |
+
Set environment variable `ESBK_DISABLE_CACHE` to a truthy value to disable the cache:
|
| 71 |
+
|
| 72 |
+
```sh
|
| 73 |
+
ESBK_DISABLE_CACHE=1 node --loader @esbuild-kit/esm-loader ./file.ts
|
| 74 |
+
```
|
| 75 |
+
|
| 76 |
+
<br>
|
| 77 |
+
|
| 78 |
+
<p align="center">
|
| 79 |
+
<a href="https://privatenumber-sponsors.vercel.app/api/sponsor?tier=gold">
|
| 80 |
+
<picture>
|
| 81 |
+
<source width="830" media="(prefers-color-scheme: dark)" srcset="https://privatenumber-sponsors.vercel.app/api/sponsor?tier=gold&image=dark">
|
| 82 |
+
<source width="830" media="(prefers-color-scheme: light)" srcset="https://privatenumber-sponsors.vercel.app/api/sponsor?tier=gold&image">
|
| 83 |
+
<img width="830" src="https://privatenumber-sponsors.vercel.app/api/sponsor?tier=gold&image" alt="Premium sponsor banner">
|
| 84 |
+
</picture>
|
| 85 |
+
</a>
|
| 86 |
+
</p>
|
| 87 |
+
|
| 88 |
+
## FAQ
|
| 89 |
+
|
| 90 |
+
### Can it import JSON modules?
|
| 91 |
+
Yes. This loader transpiles JSON modules so it's also compatible with named imports.
|
| 92 |
+
|
| 93 |
+
### Can it import ESM modules over network?
|
| 94 |
+
|
| 95 |
+
Node.js has built-in support for network imports [behind the `--experimental-network-imports` flag](https://nodejs.org/api/esm.html#network-based-loading-is-not-enabled-by-default).
|
| 96 |
+
|
| 97 |
+
You can pass it in with `esm-loader`:
|
| 98 |
+
|
| 99 |
+
```sh
|
| 100 |
+
node --loader @esbuild-kit/esm-loader --experimental-network-imports ./file.ts
|
| 101 |
+
```
|
| 102 |
+
|
| 103 |
+
### Can it resolve files without an extension?
|
| 104 |
+
|
| 105 |
+
In ESM, import paths must be explicit (must include file name and extension).
|
| 106 |
+
|
| 107 |
+
For backwards compatibility, this loader adds support for classic Node resolution for extensions: `.js`, `.json`, `.ts`, `.tsx`, `.jsx`. Resolving a `index` file by the directory name works too.
|
| 108 |
+
|
| 109 |
+
```js
|
| 110 |
+
import file from './file' // -> ./file.js
|
| 111 |
+
import directory from './directory' // -> ./directory/index.js
|
| 112 |
+
```
|
| 113 |
+
|
| 114 |
+
### Can it use Node.js's CommonJS resolution algorithm?
|
| 115 |
+
|
| 116 |
+
ESM import resolution expects explicit import paths, whereas CommonJS resolution expects implicit imports (eg. extensionless & directory imports).
|
| 117 |
+
|
| 118 |
+
As a result of this change, Node.js changes how it imports a path that matches both a file and directory. In ESM, the directory would be imported, but in CJS, the file would be imported.
|
| 119 |
+
|
| 120 |
+
To use to the CommonJS resolution algorithm, use the [`--experimental-specifier-resolution=node`](https://nodejs.org/api/cli.html#--experimental-specifier-resolutionmode) flag.
|
| 121 |
+
|
| 122 |
+
```sh
|
| 123 |
+
node --loader @esbuild-kit/esm-loader --experimental-specifier-resolution=node ./file.ts
|
| 124 |
+
```
|
| 125 |
+
|
| 126 |
+
## Related
|
| 127 |
+
|
| 128 |
+
- [tsx](https://github.com/esbuild-kit/tsx) - Node.js runtime powered by esbuild using [`@esbuild-kit/cjs-loader`](https://github.com/esbuild-kit/cjs-loader) and [`@esbuild-kit/esm-loader`](https://github.com/esbuild-kit/esm-loader).
|
| 129 |
+
|
| 130 |
+
- [@esbuild-kit/cjs-loader](https://github.com/esbuild-kit/cjs-loader) - TypeScript & ESM to CJS transpiler using the Node.js loader API.
|
| 131 |
+
|
| 132 |
+
## Sponsors
|
| 133 |
+
|
| 134 |
+
<p align="center">
|
| 135 |
+
<a href="https://privatenumber-sponsors.vercel.app/api/sponsor?tier=silver1">
|
| 136 |
+
<picture>
|
| 137 |
+
<source width="410" media="(prefers-color-scheme: dark)" srcset="https://privatenumber-sponsors.vercel.app/api/sponsor?tier=silver1&image=dark">
|
| 138 |
+
<source width="410" media="(prefers-color-scheme: light)" srcset="https://privatenumber-sponsors.vercel.app/api/sponsor?tier=silver1&image">
|
| 139 |
+
<img width="410" src="https://privatenumber-sponsors.vercel.app/api/sponsor?tier=silver1&image" alt="Premium sponsor banner">
|
| 140 |
+
</picture>
|
| 141 |
+
</a>
|
| 142 |
+
<a href="https://privatenumber-sponsors.vercel.app/api/sponsor?tier=silver2">
|
| 143 |
+
<picture>
|
| 144 |
+
<source width="410" media="(prefers-color-scheme: dark)" srcset="https://privatenumber-sponsors.vercel.app/api/sponsor?tier=silver2&image=dark">
|
| 145 |
+
<source width="410" media="(prefers-color-scheme: light)" srcset="https://privatenumber-sponsors.vercel.app/api/sponsor?tier=silver2&image">
|
| 146 |
+
<img width="410" src="https://privatenumber-sponsors.vercel.app/api/sponsor?tier=silver2&image" alt="Premium sponsor banner">
|
| 147 |
+
</picture>
|
| 148 |
+
</a>
|
| 149 |
+
</p>
|
| 150 |
+
|
| 151 |
+
<p align="center">
|
| 152 |
+
<a href="https://github.com/sponsors/privatenumber">
|
| 153 |
+
<img src="https://cdn.jsdelivr.net/gh/privatenumber/sponsors/sponsorkit/sponsors.svg">
|
| 154 |
+
</a>
|
| 155 |
+
</p>
|
e-commerce/node_modules/@esbuild-kit/esm-loader/dist/index.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import l from"path";import{fileURLToPath as y,pathToFileURL as U}from"url";import{installSourceMapSupport as I,compareNodeVersion as m,resolveTsPath as M,transform as S,transformDynamicImport as k}from"@esbuild-kit/core-utils";import{parseTsconfig as A,getTsconfig as J,createFilesMatcher as L,createPathsMatcher as W}from"get-tsconfig";import R from"fs";const f=new Map;async function b(t){if(f.has(t))return f.get(t);if(!await R.promises.access(t).then(()=>!0,()=>!1)){f.set(t,void 0);return}const e=await R.promises.readFile(t,"utf8");try{const n=JSON.parse(e);return f.set(t,n),n}catch{throw new Error(`Error parsing: ${t}`)}}async function $(t){let s=new URL("package.json",t);for(;!s.pathname.endsWith("/node_modules/package.json");){const e=y(s),n=await b(e);if(n)return n;const r=s;if(s=new URL("../package.json",s),s.pathname===r.pathname)break}}async function x(t){var s;const e=await $(t);return(s=e==null?void 0:e.type)!=null?s:"commonjs"}const u=I(),d=process.env.ESBK_TSCONFIG_PATH?{path:l.resolve(process.env.ESBK_TSCONFIG_PATH),config:A(process.env.ESBK_TSCONFIG_PATH)}:J(),N=d&&L(d),O=d&&W(d),w="file://",g=/\.([cm]?ts|[tj]sx)($|\?)/,_=/\.json(?:$|\?)/,C=t=>{const s=l.extname(t);if(s===".json")return"json";if(s===".mjs"||s===".mts")return"module";if(s===".cjs"||s===".cts")return"commonjs"},j=t=>{const s=C(t);if(s)return s;if(g.test(t))return x(t)},v=/\/(?:$|\?)/,K=m([20,0,0])>=0;let P=process.send?process.send.bind(process):void 0,E;const q=({port:t})=>(E=t,P=t.postMessage.bind(t),`
|
| 2 |
+
const require = getBuiltin('module').createRequire("${import.meta.url}");
|
| 3 |
+
require('@esbuild-kit/core-utils').installSourceMapSupport(port);
|
| 4 |
+
if (process.send) {
|
| 5 |
+
port.addListener('message', (message) => {
|
| 6 |
+
if (message.type === 'dependency') {
|
| 7 |
+
process.send(message);
|
| 8 |
+
}
|
| 9 |
+
});
|
| 10 |
+
}
|
| 11 |
+
port.unref(); // Allows process to exit without waiting for port to close
|
| 12 |
+
`),B=K?q:void 0,G=[".js",".json",".ts",".tsx",".jsx"];async function T(t,s,e){const[n,r]=t.split("?");let i;for(const a of G)try{return await h(n+a+(r?`?${r}`:""),s,e,!0)}catch(o){if(i===void 0&&o instanceof Error){const{message:c}=o;o.message=o.message.replace(`${a}'`,"'"),o.stack=o.stack.replace(c,o.message),i=o}}throw i}async function F(t,s,e){const n=v.test(t),r=n?"index":"/index",[i,a]=t.split("?");try{return await T(i+r+(a?`?${a}`:""),s,e)}catch(o){if(!n)try{return await T(t,s,e)}catch{}const c=o,{message:p}=c;throw c.message=c.message.replace(`${r.replace("/",l.sep)}'`,"'"),c.stack=c.stack.replace(p,c.message),c}}const H=/^\.{1,2}\//,Q=m([14,13,1])>=0||m([12,20,0])>=0,h=async function(t,s,e,n){var r;if(!Q&&t.startsWith("node:")&&(t=t.slice(5)),v.test(t))return await F(t,s,e);const i=t.startsWith(w)||H.test(t);if(O&&!i&&!((r=s.parentURL)!=null&&r.includes("/node_modules/"))){const o=O(t);for(const c of o)try{return await h(U(c).toString(),s,e)}catch{}}if(g.test(s.parentURL)){const o=M(t);if(o)try{return await h(o,s,e,!0)}catch(c){const{code:p}=c;if(p!=="ERR_MODULE_NOT_FOUND"&&p!=="ERR_PACKAGE_PATH_NOT_EXPORTED")throw c}}let a;try{a=await e(t,s)}catch(o){if(o instanceof Error&&!n){const{code:c}=o;if(c==="ERR_UNSUPPORTED_DIR_IMPORT")try{return await F(t,s,e)}catch(p){if(p.code!=="ERR_PACKAGE_IMPORT_NOT_DEFINED")throw p}if(c==="ERR_MODULE_NOT_FOUND")try{return await T(t,s,e)}catch{}}throw o}return!a.format&&a.url.startsWith(w)&&(a.format=await j(a.url)),a},X=async function(t,s,e){var n;P&&P({type:"dependency",path:t}),_.test(t)&&(s.importAssertions||(s.importAssertions={}),s.importAssertions.type="json");const r=await e(t,s);if(!r.source)return r;const i=t.startsWith("file://")?y(t):t,a=r.source.toString();if(r.format==="json"||g.test(t)){const o=await S(a,i,{tsconfigRaw:(n=N)==null?void 0:n(i)});return{format:"module",source:u(o,t,E)}}if(r.format==="module"){const o=k(i,a);o&&(r.source=u(o,t,E))}return r},V=async function(t,s,e){if(_.test(t))return{format:"module"};try{return await e(t,s,e)}catch(n){if(n.code==="ERR_UNKNOWN_FILE_EXTENSION"&&t.startsWith(w)){const r=await j(t);if(r)return{format:r}}throw n}},z=async function(t,s,e){var n;const{url:r}=s,i=r.startsWith("file://")?y(r):r;if(process.send&&process.send({type:"dependency",path:r}),_.test(r)||g.test(r)){const o=await S(t.toString(),i,{tsconfigRaw:(n=N)==null?void 0:n(i)});return{source:u(o,r)}}const a=await e(t,s,e);if(s.format==="module"){const o=k(i,a.source.toString());o&&(a.source=u(o,r))}return a},D=m([16,12,0])<0,Y=D?V:void 0,Z=D?z:void 0;export{Y as getFormat,B as globalPreload,X as load,h as resolve,Z as transformSource};
|
e-commerce/node_modules/@esbuild-kit/esm-loader/package.json
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "@esbuild-kit/esm-loader",
|
| 3 |
+
"version": "2.6.5",
|
| 4 |
+
"publishConfig": {
|
| 5 |
+
"access": "public"
|
| 6 |
+
},
|
| 7 |
+
"description": "Node.js loader for compiling TypeScript modules to ESM",
|
| 8 |
+
"keywords": [
|
| 9 |
+
"esbuild",
|
| 10 |
+
"loader",
|
| 11 |
+
"node",
|
| 12 |
+
"esm",
|
| 13 |
+
"typescript"
|
| 14 |
+
],
|
| 15 |
+
"license": "MIT",
|
| 16 |
+
"repository": "esbuild-kit/esm-loader",
|
| 17 |
+
"author": {
|
| 18 |
+
"name": "Hiroki Osame",
|
| 19 |
+
"email": "hiroki.osame@gmail.com"
|
| 20 |
+
},
|
| 21 |
+
"type": "module",
|
| 22 |
+
"files": [
|
| 23 |
+
"dist"
|
| 24 |
+
],
|
| 25 |
+
"main": "./dist/index.js",
|
| 26 |
+
"exports": "./dist/index.js",
|
| 27 |
+
"dependencies": {
|
| 28 |
+
"@esbuild-kit/core-utils": "^3.3.2",
|
| 29 |
+
"get-tsconfig": "^4.7.0"
|
| 30 |
+
}
|
| 31 |
+
}
|
e-commerce/node_modules/@esbuild/linux-x64/README.md
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# esbuild
|
| 2 |
+
|
| 3 |
+
This is the Linux 64-bit binary for esbuild, a JavaScript bundler and minifier. See https://github.com/evanw/esbuild for details.
|
e-commerce/node_modules/@esbuild/linux-x64/bin/esbuild
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:bab29b2ca7a9e89b67cf720b77b2d743f9f31f5cf0d5bd74ee8c8de30ced7014
|
| 3 |
+
size 10358936
|
e-commerce/node_modules/@esbuild/linux-x64/package.json
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "@esbuild/linux-x64",
|
| 3 |
+
"version": "0.25.12",
|
| 4 |
+
"description": "The Linux 64-bit binary for esbuild, a JavaScript bundler.",
|
| 5 |
+
"repository": {
|
| 6 |
+
"type": "git",
|
| 7 |
+
"url": "git+https://github.com/evanw/esbuild.git"
|
| 8 |
+
},
|
| 9 |
+
"license": "MIT",
|
| 10 |
+
"preferUnplugged": true,
|
| 11 |
+
"engines": {
|
| 12 |
+
"node": ">=18"
|
| 13 |
+
},
|
| 14 |
+
"os": [
|
| 15 |
+
"linux"
|
| 16 |
+
],
|
| 17 |
+
"cpu": [
|
| 18 |
+
"x64"
|
| 19 |
+
]
|
| 20 |
+
}
|
e-commerce/node_modules/@floating-ui/core/LICENSE
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
MIT License
|
| 2 |
+
|
| 3 |
+
Copyright (c) 2021-present Floating UI contributors
|
| 4 |
+
|
| 5 |
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
| 6 |
+
this software and associated documentation files (the "Software"), to deal in
|
| 7 |
+
the Software without restriction, including without limitation the rights to
|
| 8 |
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
| 9 |
+
the Software, and to permit persons to whom the Software is furnished to do so,
|
| 10 |
+
subject to the following conditions:
|
| 11 |
+
|
| 12 |
+
The above copyright notice and this permission notice shall be included in all
|
| 13 |
+
copies or substantial portions of the Software.
|
| 14 |
+
|
| 15 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
| 16 |
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
| 17 |
+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
| 18 |
+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
| 19 |
+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
| 20 |
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
e-commerce/node_modules/@floating-ui/core/README.md
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# @floating-ui/core
|
| 2 |
+
|
| 3 |
+
This is the platform-agnostic core of Floating UI, exposing the main
|
| 4 |
+
`computePosition` function but no platform interface logic.
|
e-commerce/node_modules/@floating-ui/core/dist/floating-ui.core.browser.min.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
const t=["top","right","bottom","left"],e=["start","end"],n=t.reduce(((t,n)=>t.concat(n,n+"-"+e[0],n+"-"+e[1])),[]),r=Math.min,i=Math.max,o={left:"right",right:"left",bottom:"top",top:"bottom"};function l(t,e,n){return i(t,r(e,n))}function a(t,e){return"function"==typeof t?t(e):t}function s(t){return t.split("-")[0]}function c(t){return t.split("-")[1]}function f(t){return"x"===t?"y":"x"}function u(t){return"y"===t?"height":"width"}function m(t){const e=t[0];return"t"===e||"b"===e?"y":"x"}function d(t){return f(m(t))}function g(t,e,n){void 0===n&&(n=!1);const r=c(t),i=d(t),o=u(i);let l="x"===i?r===(n?"end":"start")?"right":"left":"start"===r?"bottom":"top";return e.reference[o]>e.floating[o]&&(l=b(l)),[l,b(l)]}function p(t){return t.includes("start")?t.replace("start","end"):t.replace("end","start")}const h=["left","right"],y=["right","left"],w=["top","bottom"],x=["bottom","top"];function v(t,e,n,r){const i=c(t);let o=function(t,e,n){switch(t){case"top":case"bottom":return n?e?y:h:e?h:y;case"left":case"right":return e?w:x;default:return[]}}(s(t),"start"===n,r);return i&&(o=o.map((t=>t+"-"+i)),e&&(o=o.concat(o.map(p)))),o}function b(t){const e=s(t);return o[e]+t.slice(e.length)}function A(t){return"number"!=typeof t?function(t){var e,n,r,i;return{top:null!=(e=t.top)?e:0,right:null!=(n=t.right)?n:0,bottom:null!=(r=t.bottom)?r:0,left:null!=(i=t.left)?i:0}}(t):{top:t,right:t,bottom:t,left:t}}function R(t){const{x:e,y:n,width:r,height:i}=t;return{width:r,height:i,top:n,left:e,right:e+r,bottom:n+i,x:e,y:n}}function O(t,e,n){let{reference:r,floating:i}=t;const o=m(e),l=d(e),a=u(l),f=s(e),g="y"===o,p=r.x+r.width/2-i.width/2,h=r.y+r.height/2-i.height/2,y=r[a]/2-i[a]/2;let w;switch(f){case"top":w={x:p,y:r.y-i.height};break;case"bottom":w={x:p,y:r.y+r.height};break;case"right":w={x:r.x+r.width,y:h};break;case"left":w={x:r.x-i.width,y:h};break;default:w={x:r.x,y:r.y}}const x=c(e);return x&&(w[l]+=y*("end"===x?1:-1)*(n&&g?-1:1)),w}async function P(t,e){var n;void 0===e&&(e={});const{x:r,y:i,platform:o,rects:l,elements:s,strategy:c}=t,{boundary:f="clippingAncestors",rootBoundary:u="viewport",elementContext:m="floating",altBoundary:d=!1,padding:g=0}=a(e,t),p=A(g),h=s[d?"floating"===m?"reference":"floating":m],y=R(await o.getClippingRect({element:null==(n=await(null==o.isElement?void 0:o.isElement(h)))||n?h:h.contextElement||await(null==o.getDocumentElement?void 0:o.getDocumentElement(s.floating)),boundary:f,rootBoundary:u,strategy:c})),w="floating"===m?{x:r,y:i,width:l.floating.width,height:l.floating.height}:l.reference,x=await(null==o.getOffsetParent?void 0:o.getOffsetParent(s.floating)),v=await(null==o.isElement?void 0:o.isElement(x))&&await(null==o.getScale?void 0:o.getScale(x))||{x:1,y:1},b=R(o.convertOffsetParentRelativeRectToViewportRelativeRect?await o.convertOffsetParentRelativeRectToViewportRelativeRect({elements:s,rect:w,offsetParent:x,strategy:c}):w);return{top:(y.top-b.top+p.top)/v.y,bottom:(b.bottom-y.bottom+p.bottom)/v.y,left:(y.left-b.left+p.left)/v.x,right:(b.right-y.right+p.right)/v.x}}const D=async(t,e,n)=>{const{placement:r="bottom",strategy:i="absolute",middleware:o=[],platform:l}=n,a=l.detectOverflow?l:{...l,detectOverflow:P},s=await(null==l.isRTL?void 0:l.isRTL(e));let c=await l.getElementRects({reference:t,floating:e,strategy:i}),{x:f,y:u}=O(c,r,s),m=r,d=0;const g={};for(let n=0;n<o.length;n++){const p=o[n];if(!p)continue;const{name:h,fn:y}=p,{x:w,y:x,data:v,reset:b}=await y({x:f,y:u,initialPlacement:r,placement:m,strategy:i,middlewareData:g,rects:c,platform:a,elements:{reference:t,floating:e}});f=null!=w?w:f,u=null!=x?x:u,g[h]={...g[h],...v},b&&d<50&&(d++,"object"==typeof b&&(b.placement&&(m=b.placement),b.rects&&(c=!0===b.rects?await l.getElementRects({reference:t,floating:e,strategy:i}):b.rects),({x:f,y:u}=O(c,m,s))),n=-1)}return{x:f,y:u,placement:m,strategy:i,middlewareData:g}},E=t=>({name:"arrow",options:t,async fn(e){const{x:n,y:i,placement:o,rects:s,platform:f,elements:m,middlewareData:g}=e,{element:p,padding:h=0}=a(t,e)||{};if(null==p)return{};const y=A(h),w={x:n,y:i},x=d(o),v=u(x),b=await f.getDimensions(p),R="y"===x,O=R?"top":"left",P=R?"bottom":"right",D=R?"clientHeight":"clientWidth",E=s.reference[v]+s.reference[x]-w[x]-s.floating[v],T=w[x]-s.reference[x],L=await(null==f.getOffsetParent?void 0:f.getOffsetParent(p));let k=L?L[D]:0;k&&await(null==f.isElement?void 0:f.isElement(L))||(k=m.floating[D]||s.floating[v]);const C=E/2-T/2,H=k/2-b[v]/2-1,B=r(y[O],H),S=r(y[P],H),F=k-b[v]-S,M=k/2-b[v]/2+C,V=l(B,M,F),W=!g.arrow&&null!=c(o)&&M!==V&&s.reference[v]/2-(M<B?B:S)-b[v]/2<0,j=W?M<B?M-B:M-F:0;return{[x]:w[x]+j,data:{[x]:V,centerOffset:M-V-j,...W&&{alignmentOffset:j}},reset:W}}});const T=function(t){return void 0===t&&(t={}),{name:"autoPlacement",options:t,async fn(e){var r,i,o;const{rects:l,middlewareData:f,placement:u,platform:m,elements:d}=e,{crossAxis:h=!1,alignment:y,allowedPlacements:w=n,autoAlignment:x=!0,...v}=a(t,e),b=void 0!==y||w===n?function(t,e,n){return(t?[...n.filter((e=>c(e)===t)),...n.filter((e=>c(e)!==t))]:n.filter((t=>s(t)===t))).filter((n=>!t||c(n)===t||!!e&&p(n)!==n))}(y||null,x,w):w,A=(null==(r=f.autoPlacement)?void 0:r.index)||0,R=b[A];if(null==R)return{};if(u!==R)return{reset:{placement:b[0]}};const O=await m.detectOverflow(e,v),P=g(R,l,await(null==m.isRTL?void 0:m.isRTL(d.floating))),D=[O[s(R)],O[P[0]],O[P[1]]],E=[...(null==(i=f.autoPlacement)?void 0:i.overflows)||[],{placement:R,overflows:D}],T=b[A+1];if(T)return{data:{index:A+1,overflows:E},reset:{placement:T}};const L=E.map((t=>{const e=c(t.placement);return[t.placement,e&&h?t.overflows.slice(0,2).reduce(((t,e)=>t+e),0):t.overflows[0],t.overflows]})).sort(((t,e)=>t[1]-e[1])),k=(null==(o=L.filter((t=>t[2].slice(0,c(t[0])?2:3).every((t=>t<=0))))[0])?void 0:o[0])||L[0][0];return k!==u?{data:{index:A+1,overflows:E},reset:{placement:k}}:{}}}},L=function(t){return void 0===t&&(t={}),{name:"flip",options:t,async fn(e){var n,r;const{placement:i,middlewareData:o,rects:l,initialPlacement:c,platform:f,elements:u}=e,{mainAxis:d=!0,crossAxis:h=!0,fallbackPlacements:y,fallbackStrategy:w="bestFit",fallbackAxisSideDirection:x="none",flipAlignment:A=!0,...R}=a(t,e);if(null!=(n=o.arrow)&&n.alignmentOffset)return{};const O=s(i),P=m(c),D=s(c)===c,E=await(null==f.isRTL?void 0:f.isRTL(u.floating)),T=y||(D||!A?[b(c)]:function(t){const e=b(t);return[p(t),e,p(e)]}(c)),L="none"!==x;!y&&L&&T.push(...v(c,A,x,E));const k=[c,...T],C=await f.detectOverflow(e,R),H=[];let B=(null==(r=o.flip)?void 0:r.overflows)||[];if(d&&H.push(C[O]),h){const t=g(i,l,E);H.push(C[t[0]],C[t[1]])}if(B=[...B,{placement:i,overflows:H}],!H.every((t=>t<=0))){var S,F;const t=((null==(S=o.flip)?void 0:S.index)||0)+1,e=k[t];if(e){if(!("alignment"===h&&P!==m(e))||B.every((t=>m(t.placement)!==P||t.overflows[0]>0)))return{data:{index:t,overflows:B},reset:{placement:e}}}let n=null==(F=B.filter((t=>t.overflows[0]<=0)).sort(((t,e)=>t.overflows[1]-e.overflows[1]))[0])?void 0:F.placement;if(!n)switch(w){case"bestFit":{var M;const t=null==(M=B.filter((t=>{if(L){const e=m(t.placement);return e===P||"y"===e}return!0})).map((t=>[t.placement,t.overflows.filter((t=>t>0)).reduce(((t,e)=>t+e),0)])).sort(((t,e)=>t[1]-e[1]))[0])?void 0:M[0];t&&(n=t);break}case"initialPlacement":n=c}if(i!==n)return{reset:{placement:n}}}return{}}}};function k(t,e){return{top:t.top-e.height,right:t.right-e.width,bottom:t.bottom-e.height,left:t.left-e.width}}function C(e){return t.some((t=>e[t]>=0))}const H=function(t){return void 0===t&&(t={}),{name:"hide",options:t,async fn(e){const{rects:n,platform:r}=e,{strategy:i="referenceHidden",...o}=a(t,e);switch(i){case"referenceHidden":{const t=k(await r.detectOverflow(e,{...o,elementContext:"reference"}),n.reference);return{data:{referenceHiddenOffsets:t,referenceHidden:C(t)}}}case"escaped":{const t=k(await r.detectOverflow(e,{...o,altBoundary:!0}),n.floating);return{data:{escapedOffsets:t,escaped:C(t)}}}default:return{}}}}};function B(t){const e=r(...t.map((t=>t.left))),n=r(...t.map((t=>t.top)));return{x:e,y:n,width:i(...t.map((t=>t.right)))-e,height:i(...t.map((t=>t.bottom)))-n}}const S=function(t){return void 0===t&&(t={}),{name:"inline",options:t,async fn(e){const{placement:n,elements:o,rects:l,platform:c,strategy:f}=e,{padding:u=2,x:d,y:g}=a(t,e),p=Array.from(await(null==c.getClientRects?void 0:c.getClientRects(o.reference))||[]);if(!p.length)return{};const h=function(t){const e=t.slice().sort(((t,e)=>t.y-e.y)),n=[];let r=null;for(let t=0;t<e.length;t++){const i=e[t];!r||i.y-r.y>r.height/2?n.push([i]):n[n.length-1].push(i),r=i}return n.map((t=>R(B(t))))}(p),y=R(B(p)),w=A(u);const x=await c.getElementRects({reference:{getBoundingClientRect:function(){if(2===h.length&&(h[0].left>h[1].right||h[1].left>h[0].right)&&null!=d&&null!=g)return h.find((t=>d>t.left-w.left&&d<t.right+w.right&&g>t.top-w.top&&g<t.bottom+w.bottom))||y;if(h.length>=2){if("y"===m(n)){const t=h[0],e=h[h.length-1],r="top"===s(n),i=t.top,o=e.bottom,l=r?t.left:e.left;return R({x:l,y:i,width:(r?t.right:e.right)-l,height:o-i})}const t="left"===s(n),e=i(...h.map((t=>t.right))),o=r(...h.map((t=>t.left))),l=h.filter((n=>t?n.left===o:n.right===e)),a=l[0].top,c=l[l.length-1].bottom;return R({x:o,y:a,width:e-o,height:c-a})}return y}},floating:o.floating,strategy:f});return l.reference.x!==x.reference.x||l.reference.y!==x.reference.y||l.reference.width!==x.reference.width||l.reference.height!==x.reference.height?{reset:{rects:x}}:{}}}},F=new Set(["left","top"]);const M=function(t){return void 0===t&&(t=0),{name:"offset",options:t,async fn(e){var n,r;const{x:i,y:o,placement:l,middlewareData:f}=e,u=await async function(t,e){const{placement:n,platform:r,elements:i}=t,o=await(null==r.isRTL?void 0:r.isRTL(i.floating)),l=s(n),f=c(n),u="y"===m(n),d=F.has(l)?-1:1,g=o&&u?-1:1,p=a(e,t);let{mainAxis:h,crossAxis:y,alignmentAxis:w}="number"==typeof p?{mainAxis:p,crossAxis:0,alignmentAxis:null}:{mainAxis:p.mainAxis||0,crossAxis:p.crossAxis||0,alignmentAxis:p.alignmentAxis};return f&&"number"==typeof w&&(y="end"===f?-1*w:w),u?{x:y*g,y:h*d}:{x:h*d,y:y*g}}(e,t);return l===(null==(n=f.offset)?void 0:n.placement)&&null!=(r=f.arrow)&&r.alignmentOffset?{}:{x:i+u.x,y:o+u.y,data:{...u,placement:l}}}}},V=function(t){return void 0===t&&(t={}),{name:"shift",options:t,async fn(e){const{x:n,y:r,placement:i,platform:o}=e,{mainAxis:s=!0,crossAxis:c=!1,limiter:u={fn:t=>{let{x:e,y:n}=t;return{x:e,y:n}}},...d}=a(t,e),g={x:n,y:r},p=await o.detectOverflow(e,d),h=m(i),y=f(h);let w=g[y],x=g[h];const v=(t,e)=>l(e+p["y"===t?"top":"left"],e,e-p["y"===t?"bottom":"right"]);s&&(w=v(y,w)),c&&(x=v(h,x));const b=u.fn({...e,[y]:w,[h]:x});return{...b,data:{x:b.x-n,y:b.y-r,enabled:{[y]:s,[h]:c}}}}}},W=function(t){return void 0===t&&(t={}),{options:t,fn(e){var n,r;const{x:i,y:o,placement:l,rects:c,middlewareData:u}=e,{offset:d=0,mainAxis:g=!0,crossAxis:p=!0}=a(t,e),h={x:i,y:o},y=m(l),w=f(y);let x=h[w],v=h[y];const b=a(d,e),A="number"==typeof b?{mainAxis:b,crossAxis:0}:{mainAxis:null!=(n=b.mainAxis)?n:0,crossAxis:null!=(r=b.crossAxis)?r:0};if(g){const t="y"===w?"height":"width",e=c.reference[w]-c.floating[t]+A.mainAxis,n=c.reference[w]+c.reference[t]-A.mainAxis;x<e?x=e:x>n&&(x=n)}if(p){var R,O;const t="y"===w?"width":"height",e=F.has(s(l)),n=c.reference[y]-c.floating[t]+(e&&(null==(R=u.offset)?void 0:R[y])||0)+(e?0:A.crossAxis),r=c.reference[y]+c.reference[t]+(e?0:(null==(O=u.offset)?void 0:O[y])||0)-(e?A.crossAxis:0);v<n?v=n:v>r&&(v=r)}return{[w]:x,[y]:v}}}},j=function(t){return void 0===t&&(t={}),{name:"size",options:t,async fn(e){const{placement:n,rects:o,platform:l,elements:f}=e,{apply:u=()=>{},...d}=a(t,e),g=await l.detectOverflow(e,d),p=s(n),h=c(n),y="y"===m(n),{width:w,height:x}=o.floating;let v,b;"top"===p||"bottom"===p?(v=p,b=h===(await(null==l.isRTL?void 0:l.isRTL(f.floating))?"start":"end")?"left":"right"):(b=p,v="end"===h?"top":"bottom");const A=x-g.top-g.bottom,R=w-g.left-g.right,O=r(x-g[v],A),P=r(w-g[b],R),D=e.middlewareData.shift,E=!D;let T=O,L=P;null!=D&&D.enabled.x&&(L=R),null!=D&&D.enabled.y&&(T=A),E&&!h&&(y?L=w-2*i(g.left,g.right):T=x-2*i(g.top,g.bottom)),await u({...e,availableWidth:L,availableHeight:T});const k=await l.getDimensions(f.floating);return w!==k.width||x!==k.height?{reset:{rects:!0}}:{}}}};export{E as arrow,T as autoPlacement,D as computePosition,P as detectOverflow,L as flip,H as hide,S as inline,W as limitShift,M as offset,R as rectToClientRect,V as shift,j as size};
|
e-commerce/node_modules/@floating-ui/core/dist/floating-ui.core.browser.mjs
ADDED
|
@@ -0,0 +1,1164 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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 1 |
+
/**
|
| 2 |
+
* Custom positioning reference element.
|
| 3 |
+
* @see https://floating-ui.com/docs/virtual-elements
|
| 4 |
+
*/
|
| 5 |
+
|
| 6 |
+
const sides = ['top', 'right', 'bottom', 'left'];
|
| 7 |
+
const alignments = ['start', 'end'];
|
| 8 |
+
const placements = /*#__PURE__*/sides.reduce((acc, side) => acc.concat(side, side + "-" + alignments[0], side + "-" + alignments[1]), []);
|
| 9 |
+
const min = Math.min;
|
| 10 |
+
const max = Math.max;
|
| 11 |
+
const oppositeSideMap = {
|
| 12 |
+
left: 'right',
|
| 13 |
+
right: 'left',
|
| 14 |
+
bottom: 'top',
|
| 15 |
+
top: 'bottom'
|
| 16 |
+
};
|
| 17 |
+
function clamp(start, value, end) {
|
| 18 |
+
return max(start, min(value, end));
|
| 19 |
+
}
|
| 20 |
+
function evaluate(value, param) {
|
| 21 |
+
return typeof value === 'function' ? value(param) : value;
|
| 22 |
+
}
|
| 23 |
+
function getSide(placement) {
|
| 24 |
+
return placement.split('-')[0];
|
| 25 |
+
}
|
| 26 |
+
function getAlignment(placement) {
|
| 27 |
+
return placement.split('-')[1];
|
| 28 |
+
}
|
| 29 |
+
function getOppositeAxis(axis) {
|
| 30 |
+
return axis === 'x' ? 'y' : 'x';
|
| 31 |
+
}
|
| 32 |
+
function getAxisLength(axis) {
|
| 33 |
+
return axis === 'y' ? 'height' : 'width';
|
| 34 |
+
}
|
| 35 |
+
function getSideAxis(placement) {
|
| 36 |
+
const firstChar = placement[0];
|
| 37 |
+
return firstChar === 't' || firstChar === 'b' ? 'y' : 'x';
|
| 38 |
+
}
|
| 39 |
+
function getAlignmentAxis(placement) {
|
| 40 |
+
return getOppositeAxis(getSideAxis(placement));
|
| 41 |
+
}
|
| 42 |
+
function getAlignmentSides(placement, rects, rtl) {
|
| 43 |
+
if (rtl === void 0) {
|
| 44 |
+
rtl = false;
|
| 45 |
+
}
|
| 46 |
+
const alignment = getAlignment(placement);
|
| 47 |
+
const alignmentAxis = getAlignmentAxis(placement);
|
| 48 |
+
const length = getAxisLength(alignmentAxis);
|
| 49 |
+
let mainAlignmentSide = alignmentAxis === 'x' ? alignment === (rtl ? 'end' : 'start') ? 'right' : 'left' : alignment === 'start' ? 'bottom' : 'top';
|
| 50 |
+
if (rects.reference[length] > rects.floating[length]) {
|
| 51 |
+
mainAlignmentSide = getOppositePlacement(mainAlignmentSide);
|
| 52 |
+
}
|
| 53 |
+
return [mainAlignmentSide, getOppositePlacement(mainAlignmentSide)];
|
| 54 |
+
}
|
| 55 |
+
function getExpandedPlacements(placement) {
|
| 56 |
+
const oppositePlacement = getOppositePlacement(placement);
|
| 57 |
+
return [getOppositeAlignmentPlacement(placement), oppositePlacement, getOppositeAlignmentPlacement(oppositePlacement)];
|
| 58 |
+
}
|
| 59 |
+
function getOppositeAlignmentPlacement(placement) {
|
| 60 |
+
return placement.includes('start') ? placement.replace('start', 'end') : placement.replace('end', 'start');
|
| 61 |
+
}
|
| 62 |
+
const lrPlacement = ['left', 'right'];
|
| 63 |
+
const rlPlacement = ['right', 'left'];
|
| 64 |
+
const tbPlacement = ['top', 'bottom'];
|
| 65 |
+
const btPlacement = ['bottom', 'top'];
|
| 66 |
+
function getSideList(side, isStart, rtl) {
|
| 67 |
+
switch (side) {
|
| 68 |
+
case 'top':
|
| 69 |
+
case 'bottom':
|
| 70 |
+
if (rtl) return isStart ? rlPlacement : lrPlacement;
|
| 71 |
+
return isStart ? lrPlacement : rlPlacement;
|
| 72 |
+
case 'left':
|
| 73 |
+
case 'right':
|
| 74 |
+
return isStart ? tbPlacement : btPlacement;
|
| 75 |
+
default:
|
| 76 |
+
return [];
|
| 77 |
+
}
|
| 78 |
+
}
|
| 79 |
+
function getOppositeAxisPlacements(placement, flipAlignment, direction, rtl) {
|
| 80 |
+
const alignment = getAlignment(placement);
|
| 81 |
+
let list = getSideList(getSide(placement), direction === 'start', rtl);
|
| 82 |
+
if (alignment) {
|
| 83 |
+
list = list.map(side => side + "-" + alignment);
|
| 84 |
+
if (flipAlignment) {
|
| 85 |
+
list = list.concat(list.map(getOppositeAlignmentPlacement));
|
| 86 |
+
}
|
| 87 |
+
}
|
| 88 |
+
return list;
|
| 89 |
+
}
|
| 90 |
+
function getOppositePlacement(placement) {
|
| 91 |
+
const side = getSide(placement);
|
| 92 |
+
return oppositeSideMap[side] + placement.slice(side.length);
|
| 93 |
+
}
|
| 94 |
+
function expandPaddingObject(padding) {
|
| 95 |
+
var _padding$top, _padding$right, _padding$bottom, _padding$left;
|
| 96 |
+
return {
|
| 97 |
+
top: (_padding$top = padding.top) != null ? _padding$top : 0,
|
| 98 |
+
right: (_padding$right = padding.right) != null ? _padding$right : 0,
|
| 99 |
+
bottom: (_padding$bottom = padding.bottom) != null ? _padding$bottom : 0,
|
| 100 |
+
left: (_padding$left = padding.left) != null ? _padding$left : 0
|
| 101 |
+
};
|
| 102 |
+
}
|
| 103 |
+
function getPaddingObject(padding) {
|
| 104 |
+
return typeof padding !== 'number' ? expandPaddingObject(padding) : {
|
| 105 |
+
top: padding,
|
| 106 |
+
right: padding,
|
| 107 |
+
bottom: padding,
|
| 108 |
+
left: padding
|
| 109 |
+
};
|
| 110 |
+
}
|
| 111 |
+
function rectToClientRect(rect) {
|
| 112 |
+
const {
|
| 113 |
+
x,
|
| 114 |
+
y,
|
| 115 |
+
width,
|
| 116 |
+
height
|
| 117 |
+
} = rect;
|
| 118 |
+
return {
|
| 119 |
+
width,
|
| 120 |
+
height,
|
| 121 |
+
top: y,
|
| 122 |
+
left: x,
|
| 123 |
+
right: x + width,
|
| 124 |
+
bottom: y + height,
|
| 125 |
+
x,
|
| 126 |
+
y
|
| 127 |
+
};
|
| 128 |
+
}
|
| 129 |
+
|
| 130 |
+
function computeCoordsFromPlacement(_ref, placement, rtl) {
|
| 131 |
+
let {
|
| 132 |
+
reference,
|
| 133 |
+
floating
|
| 134 |
+
} = _ref;
|
| 135 |
+
const sideAxis = getSideAxis(placement);
|
| 136 |
+
const alignmentAxis = getAlignmentAxis(placement);
|
| 137 |
+
const alignLength = getAxisLength(alignmentAxis);
|
| 138 |
+
const side = getSide(placement);
|
| 139 |
+
const isVertical = sideAxis === 'y';
|
| 140 |
+
const commonX = reference.x + reference.width / 2 - floating.width / 2;
|
| 141 |
+
const commonY = reference.y + reference.height / 2 - floating.height / 2;
|
| 142 |
+
const commonAlign = reference[alignLength] / 2 - floating[alignLength] / 2;
|
| 143 |
+
let coords;
|
| 144 |
+
switch (side) {
|
| 145 |
+
case 'top':
|
| 146 |
+
coords = {
|
| 147 |
+
x: commonX,
|
| 148 |
+
y: reference.y - floating.height
|
| 149 |
+
};
|
| 150 |
+
break;
|
| 151 |
+
case 'bottom':
|
| 152 |
+
coords = {
|
| 153 |
+
x: commonX,
|
| 154 |
+
y: reference.y + reference.height
|
| 155 |
+
};
|
| 156 |
+
break;
|
| 157 |
+
case 'right':
|
| 158 |
+
coords = {
|
| 159 |
+
x: reference.x + reference.width,
|
| 160 |
+
y: commonY
|
| 161 |
+
};
|
| 162 |
+
break;
|
| 163 |
+
case 'left':
|
| 164 |
+
coords = {
|
| 165 |
+
x: reference.x - floating.width,
|
| 166 |
+
y: commonY
|
| 167 |
+
};
|
| 168 |
+
break;
|
| 169 |
+
default:
|
| 170 |
+
coords = {
|
| 171 |
+
x: reference.x,
|
| 172 |
+
y: reference.y
|
| 173 |
+
};
|
| 174 |
+
}
|
| 175 |
+
const alignment = getAlignment(placement);
|
| 176 |
+
if (alignment) {
|
| 177 |
+
coords[alignmentAxis] += commonAlign * (alignment === 'end' ? 1 : -1) * (rtl && isVertical ? -1 : 1);
|
| 178 |
+
}
|
| 179 |
+
return coords;
|
| 180 |
+
}
|
| 181 |
+
|
| 182 |
+
/**
|
| 183 |
+
* Resolves with an object of overflow side offsets that determine how much the
|
| 184 |
+
* element is overflowing a given clipping boundary on each side.
|
| 185 |
+
* - positive = overflowing the boundary by that number of pixels
|
| 186 |
+
* - negative = how many pixels left before it will overflow
|
| 187 |
+
* - 0 = lies flush with the boundary
|
| 188 |
+
* @see https://floating-ui.com/docs/detectOverflow
|
| 189 |
+
*/
|
| 190 |
+
async function detectOverflow(state, options) {
|
| 191 |
+
var _await$platform$isEle;
|
| 192 |
+
if (options === void 0) {
|
| 193 |
+
options = {};
|
| 194 |
+
}
|
| 195 |
+
const {
|
| 196 |
+
x,
|
| 197 |
+
y,
|
| 198 |
+
platform,
|
| 199 |
+
rects,
|
| 200 |
+
elements,
|
| 201 |
+
strategy
|
| 202 |
+
} = state;
|
| 203 |
+
const {
|
| 204 |
+
boundary = 'clippingAncestors',
|
| 205 |
+
rootBoundary = 'viewport',
|
| 206 |
+
elementContext = 'floating',
|
| 207 |
+
altBoundary = false,
|
| 208 |
+
padding = 0
|
| 209 |
+
} = evaluate(options, state);
|
| 210 |
+
const paddingObject = getPaddingObject(padding);
|
| 211 |
+
const altContext = elementContext === 'floating' ? 'reference' : 'floating';
|
| 212 |
+
const element = elements[altBoundary ? altContext : elementContext];
|
| 213 |
+
const clippingClientRect = rectToClientRect(await platform.getClippingRect({
|
| 214 |
+
element: ((_await$platform$isEle = await (platform.isElement == null ? void 0 : platform.isElement(element))) != null ? _await$platform$isEle : true) ? element : element.contextElement || (await (platform.getDocumentElement == null ? void 0 : platform.getDocumentElement(elements.floating))),
|
| 215 |
+
boundary,
|
| 216 |
+
rootBoundary,
|
| 217 |
+
strategy
|
| 218 |
+
}));
|
| 219 |
+
const rect = elementContext === 'floating' ? {
|
| 220 |
+
x,
|
| 221 |
+
y,
|
| 222 |
+
width: rects.floating.width,
|
| 223 |
+
height: rects.floating.height
|
| 224 |
+
} : rects.reference;
|
| 225 |
+
const offsetParent = await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(elements.floating));
|
| 226 |
+
const offsetScale = (await (platform.isElement == null ? void 0 : platform.isElement(offsetParent))) && (await (platform.getScale == null ? void 0 : platform.getScale(offsetParent))) || {
|
| 227 |
+
x: 1,
|
| 228 |
+
y: 1
|
| 229 |
+
};
|
| 230 |
+
const elementClientRect = rectToClientRect(platform.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform.convertOffsetParentRelativeRectToViewportRelativeRect({
|
| 231 |
+
elements,
|
| 232 |
+
rect,
|
| 233 |
+
offsetParent,
|
| 234 |
+
strategy
|
| 235 |
+
}) : rect);
|
| 236 |
+
return {
|
| 237 |
+
top: (clippingClientRect.top - elementClientRect.top + paddingObject.top) / offsetScale.y,
|
| 238 |
+
bottom: (elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom) / offsetScale.y,
|
| 239 |
+
left: (clippingClientRect.left - elementClientRect.left + paddingObject.left) / offsetScale.x,
|
| 240 |
+
right: (elementClientRect.right - clippingClientRect.right + paddingObject.right) / offsetScale.x
|
| 241 |
+
};
|
| 242 |
+
}
|
| 243 |
+
|
| 244 |
+
// Maximum number of resets that can occur before bailing to avoid infinite reset loops.
|
| 245 |
+
const MAX_RESET_COUNT = 50;
|
| 246 |
+
|
| 247 |
+
/**
|
| 248 |
+
* Computes the `x` and `y` coordinates that will place the floating element
|
| 249 |
+
* next to a given reference element.
|
| 250 |
+
*
|
| 251 |
+
* This export does not have any `platform` interface logic. You will need to
|
| 252 |
+
* write one for the platform you are using Floating UI with.
|
| 253 |
+
*/
|
| 254 |
+
const computePosition = async (reference, floating, config) => {
|
| 255 |
+
const {
|
| 256 |
+
placement = 'bottom',
|
| 257 |
+
strategy = 'absolute',
|
| 258 |
+
middleware = [],
|
| 259 |
+
platform
|
| 260 |
+
} = config;
|
| 261 |
+
const platformWithDetectOverflow = platform.detectOverflow ? platform : {
|
| 262 |
+
...platform,
|
| 263 |
+
detectOverflow
|
| 264 |
+
};
|
| 265 |
+
const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(floating));
|
| 266 |
+
let rects = await platform.getElementRects({
|
| 267 |
+
reference,
|
| 268 |
+
floating,
|
| 269 |
+
strategy
|
| 270 |
+
});
|
| 271 |
+
let {
|
| 272 |
+
x,
|
| 273 |
+
y
|
| 274 |
+
} = computeCoordsFromPlacement(rects, placement, rtl);
|
| 275 |
+
let statefulPlacement = placement;
|
| 276 |
+
let resetCount = 0;
|
| 277 |
+
const middlewareData = {};
|
| 278 |
+
for (let i = 0; i < middleware.length; i++) {
|
| 279 |
+
const currentMiddleware = middleware[i];
|
| 280 |
+
if (!currentMiddleware) {
|
| 281 |
+
continue;
|
| 282 |
+
}
|
| 283 |
+
const {
|
| 284 |
+
name,
|
| 285 |
+
fn
|
| 286 |
+
} = currentMiddleware;
|
| 287 |
+
const {
|
| 288 |
+
x: nextX,
|
| 289 |
+
y: nextY,
|
| 290 |
+
data,
|
| 291 |
+
reset
|
| 292 |
+
} = await fn({
|
| 293 |
+
x,
|
| 294 |
+
y,
|
| 295 |
+
initialPlacement: placement,
|
| 296 |
+
placement: statefulPlacement,
|
| 297 |
+
strategy,
|
| 298 |
+
middlewareData,
|
| 299 |
+
rects,
|
| 300 |
+
platform: platformWithDetectOverflow,
|
| 301 |
+
elements: {
|
| 302 |
+
reference,
|
| 303 |
+
floating
|
| 304 |
+
}
|
| 305 |
+
});
|
| 306 |
+
x = nextX != null ? nextX : x;
|
| 307 |
+
y = nextY != null ? nextY : y;
|
| 308 |
+
middlewareData[name] = {
|
| 309 |
+
...middlewareData[name],
|
| 310 |
+
...data
|
| 311 |
+
};
|
| 312 |
+
if (reset && resetCount < MAX_RESET_COUNT) {
|
| 313 |
+
resetCount++;
|
| 314 |
+
if (typeof reset === 'object') {
|
| 315 |
+
if (reset.placement) {
|
| 316 |
+
statefulPlacement = reset.placement;
|
| 317 |
+
}
|
| 318 |
+
if (reset.rects) {
|
| 319 |
+
rects = reset.rects === true ? await platform.getElementRects({
|
| 320 |
+
reference,
|
| 321 |
+
floating,
|
| 322 |
+
strategy
|
| 323 |
+
}) : reset.rects;
|
| 324 |
+
}
|
| 325 |
+
({
|
| 326 |
+
x,
|
| 327 |
+
y
|
| 328 |
+
} = computeCoordsFromPlacement(rects, statefulPlacement, rtl));
|
| 329 |
+
}
|
| 330 |
+
i = -1;
|
| 331 |
+
}
|
| 332 |
+
}
|
| 333 |
+
return {
|
| 334 |
+
x,
|
| 335 |
+
y,
|
| 336 |
+
placement: statefulPlacement,
|
| 337 |
+
strategy,
|
| 338 |
+
middlewareData
|
| 339 |
+
};
|
| 340 |
+
};
|
| 341 |
+
|
| 342 |
+
/**
|
| 343 |
+
* Provides data to position an inner element of the floating element so that it
|
| 344 |
+
* appears centered to the reference element.
|
| 345 |
+
* @see https://floating-ui.com/docs/arrow
|
| 346 |
+
*/
|
| 347 |
+
const arrow = options => ({
|
| 348 |
+
name: 'arrow',
|
| 349 |
+
options,
|
| 350 |
+
async fn(state) {
|
| 351 |
+
const {
|
| 352 |
+
x,
|
| 353 |
+
y,
|
| 354 |
+
placement,
|
| 355 |
+
rects,
|
| 356 |
+
platform,
|
| 357 |
+
elements,
|
| 358 |
+
middlewareData
|
| 359 |
+
} = state;
|
| 360 |
+
// Since `element` is required, we don't Partial<> the type.
|
| 361 |
+
const {
|
| 362 |
+
element,
|
| 363 |
+
padding = 0
|
| 364 |
+
} = evaluate(options, state) || {};
|
| 365 |
+
if (element == null) {
|
| 366 |
+
return {};
|
| 367 |
+
}
|
| 368 |
+
const paddingObject = getPaddingObject(padding);
|
| 369 |
+
const coords = {
|
| 370 |
+
x,
|
| 371 |
+
y
|
| 372 |
+
};
|
| 373 |
+
const axis = getAlignmentAxis(placement);
|
| 374 |
+
const length = getAxisLength(axis);
|
| 375 |
+
const arrowDimensions = await platform.getDimensions(element);
|
| 376 |
+
const isYAxis = axis === 'y';
|
| 377 |
+
const minProp = isYAxis ? 'top' : 'left';
|
| 378 |
+
const maxProp = isYAxis ? 'bottom' : 'right';
|
| 379 |
+
const clientProp = isYAxis ? 'clientHeight' : 'clientWidth';
|
| 380 |
+
const endDiff = rects.reference[length] + rects.reference[axis] - coords[axis] - rects.floating[length];
|
| 381 |
+
const startDiff = coords[axis] - rects.reference[axis];
|
| 382 |
+
const arrowOffsetParent = await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(element));
|
| 383 |
+
let clientSize = arrowOffsetParent ? arrowOffsetParent[clientProp] : 0;
|
| 384 |
+
|
| 385 |
+
// DOM platform can return `window` as the `offsetParent`.
|
| 386 |
+
if (!clientSize || !(await (platform.isElement == null ? void 0 : platform.isElement(arrowOffsetParent)))) {
|
| 387 |
+
clientSize = elements.floating[clientProp] || rects.floating[length];
|
| 388 |
+
}
|
| 389 |
+
const centerToReference = endDiff / 2 - startDiff / 2;
|
| 390 |
+
|
| 391 |
+
// If the padding is large enough that it causes the arrow to no longer be
|
| 392 |
+
// centered, modify the padding so that it is centered.
|
| 393 |
+
const largestPossiblePadding = clientSize / 2 - arrowDimensions[length] / 2 - 1;
|
| 394 |
+
const minPadding = min(paddingObject[minProp], largestPossiblePadding);
|
| 395 |
+
const maxPadding = min(paddingObject[maxProp], largestPossiblePadding);
|
| 396 |
+
|
| 397 |
+
// Make sure the arrow doesn't overflow the floating element if the center
|
| 398 |
+
// point is outside the floating element's bounds.
|
| 399 |
+
const max = clientSize - arrowDimensions[length] - maxPadding;
|
| 400 |
+
const center = clientSize / 2 - arrowDimensions[length] / 2 + centerToReference;
|
| 401 |
+
const offset = clamp(minPadding, center, max);
|
| 402 |
+
|
| 403 |
+
// If the reference is small enough that the arrow's padding causes it to
|
| 404 |
+
// to point to nothing for an aligned placement, adjust the offset of the
|
| 405 |
+
// floating element itself. To ensure `shift()` continues to take action,
|
| 406 |
+
// a single reset is performed when this is true.
|
| 407 |
+
const shouldAddOffset = !middlewareData.arrow && getAlignment(placement) != null && center !== offset && rects.reference[length] / 2 - (center < minPadding ? minPadding : maxPadding) - arrowDimensions[length] / 2 < 0;
|
| 408 |
+
const alignmentOffset = shouldAddOffset ? center < minPadding ? center - minPadding : center - max : 0;
|
| 409 |
+
return {
|
| 410 |
+
[axis]: coords[axis] + alignmentOffset,
|
| 411 |
+
data: {
|
| 412 |
+
[axis]: offset,
|
| 413 |
+
centerOffset: center - offset - alignmentOffset,
|
| 414 |
+
...(shouldAddOffset && {
|
| 415 |
+
alignmentOffset
|
| 416 |
+
})
|
| 417 |
+
},
|
| 418 |
+
reset: shouldAddOffset
|
| 419 |
+
};
|
| 420 |
+
}
|
| 421 |
+
});
|
| 422 |
+
|
| 423 |
+
function getPlacementList(alignment, autoAlignment, allowedPlacements) {
|
| 424 |
+
const allowedPlacementsSortedByAlignment = alignment ? [...allowedPlacements.filter(placement => getAlignment(placement) === alignment), ...allowedPlacements.filter(placement => getAlignment(placement) !== alignment)] : allowedPlacements.filter(placement => getSide(placement) === placement);
|
| 425 |
+
return allowedPlacementsSortedByAlignment.filter(placement => {
|
| 426 |
+
if (alignment) {
|
| 427 |
+
return getAlignment(placement) === alignment || (autoAlignment ? getOppositeAlignmentPlacement(placement) !== placement : false);
|
| 428 |
+
}
|
| 429 |
+
return true;
|
| 430 |
+
});
|
| 431 |
+
}
|
| 432 |
+
/**
|
| 433 |
+
* Optimizes the visibility of the floating element by choosing the placement
|
| 434 |
+
* that has the most space available automatically, without needing to specify a
|
| 435 |
+
* preferred placement. Alternative to `flip`.
|
| 436 |
+
* @see https://floating-ui.com/docs/autoPlacement
|
| 437 |
+
*/
|
| 438 |
+
const autoPlacement = function (options) {
|
| 439 |
+
if (options === void 0) {
|
| 440 |
+
options = {};
|
| 441 |
+
}
|
| 442 |
+
return {
|
| 443 |
+
name: 'autoPlacement',
|
| 444 |
+
options,
|
| 445 |
+
async fn(state) {
|
| 446 |
+
var _middlewareData$autoP, _middlewareData$autoP2, _placementsThatFitOnE;
|
| 447 |
+
const {
|
| 448 |
+
rects,
|
| 449 |
+
middlewareData,
|
| 450 |
+
placement,
|
| 451 |
+
platform,
|
| 452 |
+
elements
|
| 453 |
+
} = state;
|
| 454 |
+
const {
|
| 455 |
+
crossAxis = false,
|
| 456 |
+
alignment,
|
| 457 |
+
allowedPlacements = placements,
|
| 458 |
+
autoAlignment = true,
|
| 459 |
+
...detectOverflowOptions
|
| 460 |
+
} = evaluate(options, state);
|
| 461 |
+
const placements$1 = alignment !== undefined || allowedPlacements === placements ? getPlacementList(alignment || null, autoAlignment, allowedPlacements) : allowedPlacements;
|
| 462 |
+
const currentIndex = ((_middlewareData$autoP = middlewareData.autoPlacement) == null ? void 0 : _middlewareData$autoP.index) || 0;
|
| 463 |
+
const currentPlacement = placements$1[currentIndex];
|
| 464 |
+
if (currentPlacement == null) {
|
| 465 |
+
return {};
|
| 466 |
+
}
|
| 467 |
+
|
| 468 |
+
// Make `computeCoords` start from the right place.
|
| 469 |
+
if (placement !== currentPlacement) {
|
| 470 |
+
return {
|
| 471 |
+
reset: {
|
| 472 |
+
placement: placements$1[0]
|
| 473 |
+
}
|
| 474 |
+
};
|
| 475 |
+
}
|
| 476 |
+
const overflow = await platform.detectOverflow(state, detectOverflowOptions);
|
| 477 |
+
const alignmentSides = getAlignmentSides(currentPlacement, rects, await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating)));
|
| 478 |
+
const currentOverflows = [overflow[getSide(currentPlacement)], overflow[alignmentSides[0]], overflow[alignmentSides[1]]];
|
| 479 |
+
const allOverflows = [...(((_middlewareData$autoP2 = middlewareData.autoPlacement) == null ? void 0 : _middlewareData$autoP2.overflows) || []), {
|
| 480 |
+
placement: currentPlacement,
|
| 481 |
+
overflows: currentOverflows
|
| 482 |
+
}];
|
| 483 |
+
const nextPlacement = placements$1[currentIndex + 1];
|
| 484 |
+
|
| 485 |
+
// There are more placements to check.
|
| 486 |
+
if (nextPlacement) {
|
| 487 |
+
return {
|
| 488 |
+
data: {
|
| 489 |
+
index: currentIndex + 1,
|
| 490 |
+
overflows: allOverflows
|
| 491 |
+
},
|
| 492 |
+
reset: {
|
| 493 |
+
placement: nextPlacement
|
| 494 |
+
}
|
| 495 |
+
};
|
| 496 |
+
}
|
| 497 |
+
const placementsSortedByMostSpace = allOverflows.map(d => {
|
| 498 |
+
const alignment = getAlignment(d.placement);
|
| 499 |
+
return [d.placement, alignment && crossAxis ?
|
| 500 |
+
// Check along the mainAxis and main crossAxis side.
|
| 501 |
+
d.overflows.slice(0, 2).reduce((acc, v) => acc + v, 0) :
|
| 502 |
+
// Check only the mainAxis.
|
| 503 |
+
d.overflows[0], d.overflows];
|
| 504 |
+
}).sort((a, b) => a[1] - b[1]);
|
| 505 |
+
const placementsThatFitOnEachSide = placementsSortedByMostSpace.filter(d => d[2].slice(0,
|
| 506 |
+
// Aligned placements should not check their opposite crossAxis
|
| 507 |
+
// side.
|
| 508 |
+
getAlignment(d[0]) ? 2 : 3).every(v => v <= 0));
|
| 509 |
+
const resetPlacement = ((_placementsThatFitOnE = placementsThatFitOnEachSide[0]) == null ? void 0 : _placementsThatFitOnE[0]) || placementsSortedByMostSpace[0][0];
|
| 510 |
+
if (resetPlacement !== placement) {
|
| 511 |
+
return {
|
| 512 |
+
data: {
|
| 513 |
+
index: currentIndex + 1,
|
| 514 |
+
overflows: allOverflows
|
| 515 |
+
},
|
| 516 |
+
reset: {
|
| 517 |
+
placement: resetPlacement
|
| 518 |
+
}
|
| 519 |
+
};
|
| 520 |
+
}
|
| 521 |
+
return {};
|
| 522 |
+
}
|
| 523 |
+
};
|
| 524 |
+
};
|
| 525 |
+
|
| 526 |
+
/**
|
| 527 |
+
* Optimizes the visibility of the floating element by flipping the `placement`
|
| 528 |
+
* in order to keep it in view when the preferred placement(s) will overflow the
|
| 529 |
+
* clipping boundary. Alternative to `autoPlacement`.
|
| 530 |
+
* @see https://floating-ui.com/docs/flip
|
| 531 |
+
*/
|
| 532 |
+
const flip = function (options) {
|
| 533 |
+
if (options === void 0) {
|
| 534 |
+
options = {};
|
| 535 |
+
}
|
| 536 |
+
return {
|
| 537 |
+
name: 'flip',
|
| 538 |
+
options,
|
| 539 |
+
async fn(state) {
|
| 540 |
+
var _middlewareData$arrow, _middlewareData$flip;
|
| 541 |
+
const {
|
| 542 |
+
placement,
|
| 543 |
+
middlewareData,
|
| 544 |
+
rects,
|
| 545 |
+
initialPlacement,
|
| 546 |
+
platform,
|
| 547 |
+
elements
|
| 548 |
+
} = state;
|
| 549 |
+
const {
|
| 550 |
+
mainAxis: checkMainAxis = true,
|
| 551 |
+
crossAxis: checkCrossAxis = true,
|
| 552 |
+
fallbackPlacements: specifiedFallbackPlacements,
|
| 553 |
+
fallbackStrategy = 'bestFit',
|
| 554 |
+
fallbackAxisSideDirection = 'none',
|
| 555 |
+
flipAlignment = true,
|
| 556 |
+
...detectOverflowOptions
|
| 557 |
+
} = evaluate(options, state);
|
| 558 |
+
|
| 559 |
+
// If a reset by the arrow was caused due to an alignment offset being
|
| 560 |
+
// added, we should skip any logic now since `flip()` has already done its
|
| 561 |
+
// work.
|
| 562 |
+
// https://github.com/floating-ui/floating-ui/issues/2549#issuecomment-1719601643
|
| 563 |
+
if ((_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
|
| 564 |
+
return {};
|
| 565 |
+
}
|
| 566 |
+
const side = getSide(placement);
|
| 567 |
+
const initialSideAxis = getSideAxis(initialPlacement);
|
| 568 |
+
const isBasePlacement = getSide(initialPlacement) === initialPlacement;
|
| 569 |
+
const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating));
|
| 570 |
+
const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement(initialPlacement)] : getExpandedPlacements(initialPlacement));
|
| 571 |
+
const hasFallbackAxisSideDirection = fallbackAxisSideDirection !== 'none';
|
| 572 |
+
if (!specifiedFallbackPlacements && hasFallbackAxisSideDirection) {
|
| 573 |
+
fallbackPlacements.push(...getOppositeAxisPlacements(initialPlacement, flipAlignment, fallbackAxisSideDirection, rtl));
|
| 574 |
+
}
|
| 575 |
+
const placements = [initialPlacement, ...fallbackPlacements];
|
| 576 |
+
const overflow = await platform.detectOverflow(state, detectOverflowOptions);
|
| 577 |
+
const overflows = [];
|
| 578 |
+
let overflowsData = ((_middlewareData$flip = middlewareData.flip) == null ? void 0 : _middlewareData$flip.overflows) || [];
|
| 579 |
+
if (checkMainAxis) {
|
| 580 |
+
overflows.push(overflow[side]);
|
| 581 |
+
}
|
| 582 |
+
if (checkCrossAxis) {
|
| 583 |
+
const sides = getAlignmentSides(placement, rects, rtl);
|
| 584 |
+
overflows.push(overflow[sides[0]], overflow[sides[1]]);
|
| 585 |
+
}
|
| 586 |
+
overflowsData = [...overflowsData, {
|
| 587 |
+
placement,
|
| 588 |
+
overflows
|
| 589 |
+
}];
|
| 590 |
+
|
| 591 |
+
// One or more sides is overflowing.
|
| 592 |
+
if (!overflows.every(side => side <= 0)) {
|
| 593 |
+
var _middlewareData$flip2, _overflowsData$filter;
|
| 594 |
+
const nextIndex = (((_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.index) || 0) + 1;
|
| 595 |
+
const nextPlacement = placements[nextIndex];
|
| 596 |
+
if (nextPlacement) {
|
| 597 |
+
const ignoreCrossAxisOverflow = checkCrossAxis === 'alignment' ? initialSideAxis !== getSideAxis(nextPlacement) : false;
|
| 598 |
+
if (!ignoreCrossAxisOverflow ||
|
| 599 |
+
// We leave the current main axis only if every placement on that axis
|
| 600 |
+
// overflows the main axis.
|
| 601 |
+
overflowsData.every(d => getSideAxis(d.placement) === initialSideAxis ? d.overflows[0] > 0 : true)) {
|
| 602 |
+
// Try next placement and re-run the lifecycle.
|
| 603 |
+
return {
|
| 604 |
+
data: {
|
| 605 |
+
index: nextIndex,
|
| 606 |
+
overflows: overflowsData
|
| 607 |
+
},
|
| 608 |
+
reset: {
|
| 609 |
+
placement: nextPlacement
|
| 610 |
+
}
|
| 611 |
+
};
|
| 612 |
+
}
|
| 613 |
+
}
|
| 614 |
+
|
| 615 |
+
// First, find the candidates that fit on the mainAxis side of overflow,
|
| 616 |
+
// then find the placement that fits the best on the main crossAxis side.
|
| 617 |
+
let resetPlacement = (_overflowsData$filter = overflowsData.filter(d => d.overflows[0] <= 0).sort((a, b) => a.overflows[1] - b.overflows[1])[0]) == null ? void 0 : _overflowsData$filter.placement;
|
| 618 |
+
|
| 619 |
+
// Otherwise fallback.
|
| 620 |
+
if (!resetPlacement) {
|
| 621 |
+
switch (fallbackStrategy) {
|
| 622 |
+
case 'bestFit':
|
| 623 |
+
{
|
| 624 |
+
var _overflowsData$filter2;
|
| 625 |
+
const placement = (_overflowsData$filter2 = overflowsData.filter(d => {
|
| 626 |
+
if (hasFallbackAxisSideDirection) {
|
| 627 |
+
const currentSideAxis = getSideAxis(d.placement);
|
| 628 |
+
return currentSideAxis === initialSideAxis ||
|
| 629 |
+
// Create a bias to the `y` side axis due to horizontal
|
| 630 |
+
// reading directions favoring greater width.
|
| 631 |
+
currentSideAxis === 'y';
|
| 632 |
+
}
|
| 633 |
+
return true;
|
| 634 |
+
}).map(d => [d.placement, d.overflows.filter(overflow => overflow > 0).reduce((acc, overflow) => acc + overflow, 0)]).sort((a, b) => a[1] - b[1])[0]) == null ? void 0 : _overflowsData$filter2[0];
|
| 635 |
+
if (placement) {
|
| 636 |
+
resetPlacement = placement;
|
| 637 |
+
}
|
| 638 |
+
break;
|
| 639 |
+
}
|
| 640 |
+
case 'initialPlacement':
|
| 641 |
+
resetPlacement = initialPlacement;
|
| 642 |
+
break;
|
| 643 |
+
}
|
| 644 |
+
}
|
| 645 |
+
if (placement !== resetPlacement) {
|
| 646 |
+
return {
|
| 647 |
+
reset: {
|
| 648 |
+
placement: resetPlacement
|
| 649 |
+
}
|
| 650 |
+
};
|
| 651 |
+
}
|
| 652 |
+
}
|
| 653 |
+
return {};
|
| 654 |
+
}
|
| 655 |
+
};
|
| 656 |
+
};
|
| 657 |
+
|
| 658 |
+
function getSideOffsets(overflow, rect) {
|
| 659 |
+
return {
|
| 660 |
+
top: overflow.top - rect.height,
|
| 661 |
+
right: overflow.right - rect.width,
|
| 662 |
+
bottom: overflow.bottom - rect.height,
|
| 663 |
+
left: overflow.left - rect.width
|
| 664 |
+
};
|
| 665 |
+
}
|
| 666 |
+
function isAnySideFullyClipped(overflow) {
|
| 667 |
+
return sides.some(side => overflow[side] >= 0);
|
| 668 |
+
}
|
| 669 |
+
/**
|
| 670 |
+
* Provides data to hide the floating element in applicable situations, such as
|
| 671 |
+
* when it is not in the same clipping context as the reference element.
|
| 672 |
+
* @see https://floating-ui.com/docs/hide
|
| 673 |
+
*/
|
| 674 |
+
const hide = function (options) {
|
| 675 |
+
if (options === void 0) {
|
| 676 |
+
options = {};
|
| 677 |
+
}
|
| 678 |
+
return {
|
| 679 |
+
name: 'hide',
|
| 680 |
+
options,
|
| 681 |
+
async fn(state) {
|
| 682 |
+
const {
|
| 683 |
+
rects,
|
| 684 |
+
platform
|
| 685 |
+
} = state;
|
| 686 |
+
const {
|
| 687 |
+
strategy = 'referenceHidden',
|
| 688 |
+
...detectOverflowOptions
|
| 689 |
+
} = evaluate(options, state);
|
| 690 |
+
switch (strategy) {
|
| 691 |
+
case 'referenceHidden':
|
| 692 |
+
{
|
| 693 |
+
const overflow = await platform.detectOverflow(state, {
|
| 694 |
+
...detectOverflowOptions,
|
| 695 |
+
elementContext: 'reference'
|
| 696 |
+
});
|
| 697 |
+
const offsets = getSideOffsets(overflow, rects.reference);
|
| 698 |
+
return {
|
| 699 |
+
data: {
|
| 700 |
+
referenceHiddenOffsets: offsets,
|
| 701 |
+
referenceHidden: isAnySideFullyClipped(offsets)
|
| 702 |
+
}
|
| 703 |
+
};
|
| 704 |
+
}
|
| 705 |
+
case 'escaped':
|
| 706 |
+
{
|
| 707 |
+
const overflow = await platform.detectOverflow(state, {
|
| 708 |
+
...detectOverflowOptions,
|
| 709 |
+
altBoundary: true
|
| 710 |
+
});
|
| 711 |
+
const offsets = getSideOffsets(overflow, rects.floating);
|
| 712 |
+
return {
|
| 713 |
+
data: {
|
| 714 |
+
escapedOffsets: offsets,
|
| 715 |
+
escaped: isAnySideFullyClipped(offsets)
|
| 716 |
+
}
|
| 717 |
+
};
|
| 718 |
+
}
|
| 719 |
+
default:
|
| 720 |
+
{
|
| 721 |
+
return {};
|
| 722 |
+
}
|
| 723 |
+
}
|
| 724 |
+
}
|
| 725 |
+
};
|
| 726 |
+
};
|
| 727 |
+
|
| 728 |
+
function getBoundingRect(rects) {
|
| 729 |
+
const minX = min(...rects.map(rect => rect.left));
|
| 730 |
+
const minY = min(...rects.map(rect => rect.top));
|
| 731 |
+
const maxX = max(...rects.map(rect => rect.right));
|
| 732 |
+
const maxY = max(...rects.map(rect => rect.bottom));
|
| 733 |
+
return {
|
| 734 |
+
x: minX,
|
| 735 |
+
y: minY,
|
| 736 |
+
width: maxX - minX,
|
| 737 |
+
height: maxY - minY
|
| 738 |
+
};
|
| 739 |
+
}
|
| 740 |
+
function getRectsByLine(rects) {
|
| 741 |
+
const sortedRects = rects.slice().sort((a, b) => a.y - b.y);
|
| 742 |
+
const groups = [];
|
| 743 |
+
let prevRect = null;
|
| 744 |
+
for (let i = 0; i < sortedRects.length; i++) {
|
| 745 |
+
const rect = sortedRects[i];
|
| 746 |
+
if (!prevRect || rect.y - prevRect.y > prevRect.height / 2) {
|
| 747 |
+
groups.push([rect]);
|
| 748 |
+
} else {
|
| 749 |
+
groups[groups.length - 1].push(rect);
|
| 750 |
+
}
|
| 751 |
+
prevRect = rect;
|
| 752 |
+
}
|
| 753 |
+
return groups.map(rect => rectToClientRect(getBoundingRect(rect)));
|
| 754 |
+
}
|
| 755 |
+
/**
|
| 756 |
+
* Provides improved positioning for inline reference elements that can span
|
| 757 |
+
* over multiple lines, such as hyperlinks or range selections.
|
| 758 |
+
* @see https://floating-ui.com/docs/inline
|
| 759 |
+
*/
|
| 760 |
+
const inline = function (options) {
|
| 761 |
+
if (options === void 0) {
|
| 762 |
+
options = {};
|
| 763 |
+
}
|
| 764 |
+
return {
|
| 765 |
+
name: 'inline',
|
| 766 |
+
options,
|
| 767 |
+
async fn(state) {
|
| 768 |
+
const {
|
| 769 |
+
placement,
|
| 770 |
+
elements,
|
| 771 |
+
rects,
|
| 772 |
+
platform,
|
| 773 |
+
strategy
|
| 774 |
+
} = state;
|
| 775 |
+
// A MouseEvent's client{X,Y} coords can be up to 2 pixels off a
|
| 776 |
+
// ClientRect's bounds, despite the event listener being triggered. A
|
| 777 |
+
// padding of 2 seems to handle this issue.
|
| 778 |
+
const {
|
| 779 |
+
padding = 2,
|
| 780 |
+
x,
|
| 781 |
+
y
|
| 782 |
+
} = evaluate(options, state);
|
| 783 |
+
const nativeClientRects = Array.from((await (platform.getClientRects == null ? void 0 : platform.getClientRects(elements.reference))) || []);
|
| 784 |
+
|
| 785 |
+
// No rects (e.g. a hidden or detached reference, or a collapsed range) —
|
| 786 |
+
// keep the existing reference rect rather than resetting to an invalid
|
| 787 |
+
// one with non-finite values.
|
| 788 |
+
if (!nativeClientRects.length) {
|
| 789 |
+
return {};
|
| 790 |
+
}
|
| 791 |
+
const clientRects = getRectsByLine(nativeClientRects);
|
| 792 |
+
const fallback = rectToClientRect(getBoundingRect(nativeClientRects));
|
| 793 |
+
const paddingObject = getPaddingObject(padding);
|
| 794 |
+
function getBoundingClientRect() {
|
| 795 |
+
// There are two rects and they are disjoined.
|
| 796 |
+
if (clientRects.length === 2 && (clientRects[0].left > clientRects[1].right || clientRects[1].left > clientRects[0].right) && x != null && y != null) {
|
| 797 |
+
// Find the first rect in which the point is fully inside.
|
| 798 |
+
return clientRects.find(rect => x > rect.left - paddingObject.left && x < rect.right + paddingObject.right && y > rect.top - paddingObject.top && y < rect.bottom + paddingObject.bottom) || fallback;
|
| 799 |
+
}
|
| 800 |
+
|
| 801 |
+
// There are 2 or more connected rects.
|
| 802 |
+
if (clientRects.length >= 2) {
|
| 803 |
+
if (getSideAxis(placement) === 'y') {
|
| 804 |
+
const firstRect = clientRects[0];
|
| 805 |
+
const lastRect = clientRects[clientRects.length - 1];
|
| 806 |
+
const isTop = getSide(placement) === 'top';
|
| 807 |
+
const top = firstRect.top;
|
| 808 |
+
const bottom = lastRect.bottom;
|
| 809 |
+
const left = isTop ? firstRect.left : lastRect.left;
|
| 810 |
+
const right = isTop ? firstRect.right : lastRect.right;
|
| 811 |
+
return rectToClientRect({
|
| 812 |
+
x: left,
|
| 813 |
+
y: top,
|
| 814 |
+
width: right - left,
|
| 815 |
+
height: bottom - top
|
| 816 |
+
});
|
| 817 |
+
}
|
| 818 |
+
const isLeftSide = getSide(placement) === 'left';
|
| 819 |
+
const maxRight = max(...clientRects.map(rect => rect.right));
|
| 820 |
+
const minLeft = min(...clientRects.map(rect => rect.left));
|
| 821 |
+
const measureRects = clientRects.filter(rect => isLeftSide ? rect.left === minLeft : rect.right === maxRight);
|
| 822 |
+
const top = measureRects[0].top;
|
| 823 |
+
const bottom = measureRects[measureRects.length - 1].bottom;
|
| 824 |
+
return rectToClientRect({
|
| 825 |
+
x: minLeft,
|
| 826 |
+
y: top,
|
| 827 |
+
width: maxRight - minLeft,
|
| 828 |
+
height: bottom - top
|
| 829 |
+
});
|
| 830 |
+
}
|
| 831 |
+
return fallback;
|
| 832 |
+
}
|
| 833 |
+
const resetRects = await platform.getElementRects({
|
| 834 |
+
reference: {
|
| 835 |
+
getBoundingClientRect
|
| 836 |
+
},
|
| 837 |
+
floating: elements.floating,
|
| 838 |
+
strategy
|
| 839 |
+
});
|
| 840 |
+
if (rects.reference.x !== resetRects.reference.x || rects.reference.y !== resetRects.reference.y || rects.reference.width !== resetRects.reference.width || rects.reference.height !== resetRects.reference.height) {
|
| 841 |
+
return {
|
| 842 |
+
reset: {
|
| 843 |
+
rects: resetRects
|
| 844 |
+
}
|
| 845 |
+
};
|
| 846 |
+
}
|
| 847 |
+
return {};
|
| 848 |
+
}
|
| 849 |
+
};
|
| 850 |
+
};
|
| 851 |
+
|
| 852 |
+
const originSides = /*#__PURE__*/new Set(['left', 'top']);
|
| 853 |
+
|
| 854 |
+
// For type backwards-compatibility, the `OffsetOptions` type was also
|
| 855 |
+
// Derivable.
|
| 856 |
+
|
| 857 |
+
async function convertValueToCoords(state, options) {
|
| 858 |
+
const {
|
| 859 |
+
placement,
|
| 860 |
+
platform,
|
| 861 |
+
elements
|
| 862 |
+
} = state;
|
| 863 |
+
const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating));
|
| 864 |
+
const side = getSide(placement);
|
| 865 |
+
const alignment = getAlignment(placement);
|
| 866 |
+
const isVertical = getSideAxis(placement) === 'y';
|
| 867 |
+
const mainAxisMulti = originSides.has(side) ? -1 : 1;
|
| 868 |
+
const crossAxisMulti = rtl && isVertical ? -1 : 1;
|
| 869 |
+
const rawValue = evaluate(options, state);
|
| 870 |
+
|
| 871 |
+
// eslint-disable-next-line prefer-const
|
| 872 |
+
let {
|
| 873 |
+
mainAxis,
|
| 874 |
+
crossAxis,
|
| 875 |
+
alignmentAxis
|
| 876 |
+
} = typeof rawValue === 'number' ? {
|
| 877 |
+
mainAxis: rawValue,
|
| 878 |
+
crossAxis: 0,
|
| 879 |
+
alignmentAxis: null
|
| 880 |
+
} : {
|
| 881 |
+
mainAxis: rawValue.mainAxis || 0,
|
| 882 |
+
crossAxis: rawValue.crossAxis || 0,
|
| 883 |
+
alignmentAxis: rawValue.alignmentAxis
|
| 884 |
+
};
|
| 885 |
+
if (alignment && typeof alignmentAxis === 'number') {
|
| 886 |
+
crossAxis = alignment === 'end' ? alignmentAxis * -1 : alignmentAxis;
|
| 887 |
+
}
|
| 888 |
+
return isVertical ? {
|
| 889 |
+
x: crossAxis * crossAxisMulti,
|
| 890 |
+
y: mainAxis * mainAxisMulti
|
| 891 |
+
} : {
|
| 892 |
+
x: mainAxis * mainAxisMulti,
|
| 893 |
+
y: crossAxis * crossAxisMulti
|
| 894 |
+
};
|
| 895 |
+
}
|
| 896 |
+
|
| 897 |
+
/**
|
| 898 |
+
* Modifies the placement by translating the floating element along the
|
| 899 |
+
* specified axes.
|
| 900 |
+
* A number (shorthand for `mainAxis` or distance), or an axes configuration
|
| 901 |
+
* object may be passed.
|
| 902 |
+
* @see https://floating-ui.com/docs/offset
|
| 903 |
+
*/
|
| 904 |
+
const offset = function (options) {
|
| 905 |
+
if (options === void 0) {
|
| 906 |
+
options = 0;
|
| 907 |
+
}
|
| 908 |
+
return {
|
| 909 |
+
name: 'offset',
|
| 910 |
+
options,
|
| 911 |
+
async fn(state) {
|
| 912 |
+
var _middlewareData$offse, _middlewareData$arrow;
|
| 913 |
+
const {
|
| 914 |
+
x,
|
| 915 |
+
y,
|
| 916 |
+
placement,
|
| 917 |
+
middlewareData
|
| 918 |
+
} = state;
|
| 919 |
+
const diffCoords = await convertValueToCoords(state, options);
|
| 920 |
+
|
| 921 |
+
// If the placement is the same and the arrow caused an alignment offset
|
| 922 |
+
// then we don't need to change the positioning coordinates.
|
| 923 |
+
if (placement === ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse.placement) && (_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
|
| 924 |
+
return {};
|
| 925 |
+
}
|
| 926 |
+
return {
|
| 927 |
+
x: x + diffCoords.x,
|
| 928 |
+
y: y + diffCoords.y,
|
| 929 |
+
data: {
|
| 930 |
+
...diffCoords,
|
| 931 |
+
placement
|
| 932 |
+
}
|
| 933 |
+
};
|
| 934 |
+
}
|
| 935 |
+
};
|
| 936 |
+
};
|
| 937 |
+
|
| 938 |
+
/**
|
| 939 |
+
* Optimizes the visibility of the floating element by shifting it in order to
|
| 940 |
+
* keep it in view when it will overflow the clipping boundary.
|
| 941 |
+
* @see https://floating-ui.com/docs/shift
|
| 942 |
+
*/
|
| 943 |
+
const shift = function (options) {
|
| 944 |
+
if (options === void 0) {
|
| 945 |
+
options = {};
|
| 946 |
+
}
|
| 947 |
+
return {
|
| 948 |
+
name: 'shift',
|
| 949 |
+
options,
|
| 950 |
+
async fn(state) {
|
| 951 |
+
const {
|
| 952 |
+
x,
|
| 953 |
+
y,
|
| 954 |
+
placement,
|
| 955 |
+
platform
|
| 956 |
+
} = state;
|
| 957 |
+
const {
|
| 958 |
+
mainAxis: checkMainAxis = true,
|
| 959 |
+
crossAxis: checkCrossAxis = false,
|
| 960 |
+
limiter = {
|
| 961 |
+
fn: _ref => {
|
| 962 |
+
let {
|
| 963 |
+
x,
|
| 964 |
+
y
|
| 965 |
+
} = _ref;
|
| 966 |
+
return {
|
| 967 |
+
x,
|
| 968 |
+
y
|
| 969 |
+
};
|
| 970 |
+
}
|
| 971 |
+
},
|
| 972 |
+
...detectOverflowOptions
|
| 973 |
+
} = evaluate(options, state);
|
| 974 |
+
const coords = {
|
| 975 |
+
x,
|
| 976 |
+
y
|
| 977 |
+
};
|
| 978 |
+
const overflow = await platform.detectOverflow(state, detectOverflowOptions);
|
| 979 |
+
const crossAxis = getSideAxis(placement);
|
| 980 |
+
const mainAxis = getOppositeAxis(crossAxis);
|
| 981 |
+
let mainAxisCoord = coords[mainAxis];
|
| 982 |
+
let crossAxisCoord = coords[crossAxis];
|
| 983 |
+
const clampCoord = (axis, coord) => clamp(coord + overflow[axis === 'y' ? 'top' : 'left'], coord, coord - overflow[axis === 'y' ? 'bottom' : 'right']);
|
| 984 |
+
if (checkMainAxis) {
|
| 985 |
+
mainAxisCoord = clampCoord(mainAxis, mainAxisCoord);
|
| 986 |
+
}
|
| 987 |
+
if (checkCrossAxis) {
|
| 988 |
+
crossAxisCoord = clampCoord(crossAxis, crossAxisCoord);
|
| 989 |
+
}
|
| 990 |
+
const limitedCoords = limiter.fn({
|
| 991 |
+
...state,
|
| 992 |
+
[mainAxis]: mainAxisCoord,
|
| 993 |
+
[crossAxis]: crossAxisCoord
|
| 994 |
+
});
|
| 995 |
+
return {
|
| 996 |
+
...limitedCoords,
|
| 997 |
+
data: {
|
| 998 |
+
x: limitedCoords.x - x,
|
| 999 |
+
y: limitedCoords.y - y,
|
| 1000 |
+
enabled: {
|
| 1001 |
+
[mainAxis]: checkMainAxis,
|
| 1002 |
+
[crossAxis]: checkCrossAxis
|
| 1003 |
+
}
|
| 1004 |
+
}
|
| 1005 |
+
};
|
| 1006 |
+
}
|
| 1007 |
+
};
|
| 1008 |
+
};
|
| 1009 |
+
/**
|
| 1010 |
+
* Built-in `limiter` that will stop `shift()` at a certain point.
|
| 1011 |
+
*/
|
| 1012 |
+
const limitShift = function (options) {
|
| 1013 |
+
if (options === void 0) {
|
| 1014 |
+
options = {};
|
| 1015 |
+
}
|
| 1016 |
+
return {
|
| 1017 |
+
options,
|
| 1018 |
+
fn(state) {
|
| 1019 |
+
var _rawOffset$mainAxis, _rawOffset$crossAxis;
|
| 1020 |
+
const {
|
| 1021 |
+
x,
|
| 1022 |
+
y,
|
| 1023 |
+
placement,
|
| 1024 |
+
rects,
|
| 1025 |
+
middlewareData
|
| 1026 |
+
} = state;
|
| 1027 |
+
const {
|
| 1028 |
+
offset = 0,
|
| 1029 |
+
mainAxis: checkMainAxis = true,
|
| 1030 |
+
crossAxis: checkCrossAxis = true
|
| 1031 |
+
} = evaluate(options, state);
|
| 1032 |
+
const coords = {
|
| 1033 |
+
x,
|
| 1034 |
+
y
|
| 1035 |
+
};
|
| 1036 |
+
const crossAxis = getSideAxis(placement);
|
| 1037 |
+
const mainAxis = getOppositeAxis(crossAxis);
|
| 1038 |
+
let mainAxisCoord = coords[mainAxis];
|
| 1039 |
+
let crossAxisCoord = coords[crossAxis];
|
| 1040 |
+
const rawOffset = evaluate(offset, state);
|
| 1041 |
+
const computedOffset = typeof rawOffset === 'number' ? {
|
| 1042 |
+
mainAxis: rawOffset,
|
| 1043 |
+
crossAxis: 0
|
| 1044 |
+
} : {
|
| 1045 |
+
mainAxis: (_rawOffset$mainAxis = rawOffset.mainAxis) != null ? _rawOffset$mainAxis : 0,
|
| 1046 |
+
crossAxis: (_rawOffset$crossAxis = rawOffset.crossAxis) != null ? _rawOffset$crossAxis : 0
|
| 1047 |
+
};
|
| 1048 |
+
if (checkMainAxis) {
|
| 1049 |
+
const len = mainAxis === 'y' ? 'height' : 'width';
|
| 1050 |
+
const limitMin = rects.reference[mainAxis] - rects.floating[len] + computedOffset.mainAxis;
|
| 1051 |
+
const limitMax = rects.reference[mainAxis] + rects.reference[len] - computedOffset.mainAxis;
|
| 1052 |
+
if (mainAxisCoord < limitMin) {
|
| 1053 |
+
mainAxisCoord = limitMin;
|
| 1054 |
+
} else if (mainAxisCoord > limitMax) {
|
| 1055 |
+
mainAxisCoord = limitMax;
|
| 1056 |
+
}
|
| 1057 |
+
}
|
| 1058 |
+
if (checkCrossAxis) {
|
| 1059 |
+
var _middlewareData$offse, _middlewareData$offse2;
|
| 1060 |
+
const len = mainAxis === 'y' ? 'width' : 'height';
|
| 1061 |
+
const isOriginSide = originSides.has(getSide(placement));
|
| 1062 |
+
const limitMin = rects.reference[crossAxis] - rects.floating[len] + (isOriginSide ? ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse[crossAxis]) || 0 : 0) + (isOriginSide ? 0 : computedOffset.crossAxis);
|
| 1063 |
+
const limitMax = rects.reference[crossAxis] + rects.reference[len] + (isOriginSide ? 0 : ((_middlewareData$offse2 = middlewareData.offset) == null ? void 0 : _middlewareData$offse2[crossAxis]) || 0) - (isOriginSide ? computedOffset.crossAxis : 0);
|
| 1064 |
+
if (crossAxisCoord < limitMin) {
|
| 1065 |
+
crossAxisCoord = limitMin;
|
| 1066 |
+
} else if (crossAxisCoord > limitMax) {
|
| 1067 |
+
crossAxisCoord = limitMax;
|
| 1068 |
+
}
|
| 1069 |
+
}
|
| 1070 |
+
return {
|
| 1071 |
+
[mainAxis]: mainAxisCoord,
|
| 1072 |
+
[crossAxis]: crossAxisCoord
|
| 1073 |
+
};
|
| 1074 |
+
}
|
| 1075 |
+
};
|
| 1076 |
+
};
|
| 1077 |
+
|
| 1078 |
+
// Method syntax keeps callback parameters bivariant, but expressing the
|
| 1079 |
+
// explicit `| undefined` required by `exactOptionalPropertyTypes` needs
|
| 1080 |
+
// property syntax, which is contravariant under `strictFunctionTypes`.
|
| 1081 |
+
// Extracting the function from a method position restores that bivariance so
|
| 1082 |
+
// consumers can still assign callbacks with narrower parameter types.
|
| 1083 |
+
|
| 1084 |
+
/**
|
| 1085 |
+
* Provides data that allows you to change the size of the floating element —
|
| 1086 |
+
* for instance, prevent it from overflowing the clipping boundary or match the
|
| 1087 |
+
* width of the reference element.
|
| 1088 |
+
* @see https://floating-ui.com/docs/size
|
| 1089 |
+
*/
|
| 1090 |
+
const size = function (options) {
|
| 1091 |
+
if (options === void 0) {
|
| 1092 |
+
options = {};
|
| 1093 |
+
}
|
| 1094 |
+
return {
|
| 1095 |
+
name: 'size',
|
| 1096 |
+
options,
|
| 1097 |
+
async fn(state) {
|
| 1098 |
+
const {
|
| 1099 |
+
placement,
|
| 1100 |
+
rects,
|
| 1101 |
+
platform,
|
| 1102 |
+
elements
|
| 1103 |
+
} = state;
|
| 1104 |
+
const {
|
| 1105 |
+
apply = () => {},
|
| 1106 |
+
...detectOverflowOptions
|
| 1107 |
+
} = evaluate(options, state);
|
| 1108 |
+
const overflow = await platform.detectOverflow(state, detectOverflowOptions);
|
| 1109 |
+
const side = getSide(placement);
|
| 1110 |
+
const alignment = getAlignment(placement);
|
| 1111 |
+
const isYAxis = getSideAxis(placement) === 'y';
|
| 1112 |
+
const {
|
| 1113 |
+
width,
|
| 1114 |
+
height
|
| 1115 |
+
} = rects.floating;
|
| 1116 |
+
let heightSide;
|
| 1117 |
+
let widthSide;
|
| 1118 |
+
if (side === 'top' || side === 'bottom') {
|
| 1119 |
+
heightSide = side;
|
| 1120 |
+
widthSide = alignment === ((await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating))) ? 'start' : 'end') ? 'left' : 'right';
|
| 1121 |
+
} else {
|
| 1122 |
+
widthSide = side;
|
| 1123 |
+
heightSide = alignment === 'end' ? 'top' : 'bottom';
|
| 1124 |
+
}
|
| 1125 |
+
const maximumClippingHeight = height - overflow.top - overflow.bottom;
|
| 1126 |
+
const maximumClippingWidth = width - overflow.left - overflow.right;
|
| 1127 |
+
const overflowAvailableHeight = min(height - overflow[heightSide], maximumClippingHeight);
|
| 1128 |
+
const overflowAvailableWidth = min(width - overflow[widthSide], maximumClippingWidth);
|
| 1129 |
+
const shiftData = state.middlewareData.shift;
|
| 1130 |
+
const noShift = !shiftData;
|
| 1131 |
+
let availableHeight = overflowAvailableHeight;
|
| 1132 |
+
let availableWidth = overflowAvailableWidth;
|
| 1133 |
+
if (shiftData != null && shiftData.enabled.x) {
|
| 1134 |
+
availableWidth = maximumClippingWidth;
|
| 1135 |
+
}
|
| 1136 |
+
if (shiftData != null && shiftData.enabled.y) {
|
| 1137 |
+
availableHeight = maximumClippingHeight;
|
| 1138 |
+
}
|
| 1139 |
+
if (noShift && !alignment) {
|
| 1140 |
+
if (isYAxis) {
|
| 1141 |
+
availableWidth = width - 2 * max(overflow.left, overflow.right);
|
| 1142 |
+
} else {
|
| 1143 |
+
availableHeight = height - 2 * max(overflow.top, overflow.bottom);
|
| 1144 |
+
}
|
| 1145 |
+
}
|
| 1146 |
+
await apply({
|
| 1147 |
+
...state,
|
| 1148 |
+
availableWidth,
|
| 1149 |
+
availableHeight
|
| 1150 |
+
});
|
| 1151 |
+
const nextDimensions = await platform.getDimensions(elements.floating);
|
| 1152 |
+
if (width !== nextDimensions.width || height !== nextDimensions.height) {
|
| 1153 |
+
return {
|
| 1154 |
+
reset: {
|
| 1155 |
+
rects: true
|
| 1156 |
+
}
|
| 1157 |
+
};
|
| 1158 |
+
}
|
| 1159 |
+
return {};
|
| 1160 |
+
}
|
| 1161 |
+
};
|
| 1162 |
+
};
|
| 1163 |
+
|
| 1164 |
+
export { arrow, autoPlacement, computePosition, detectOverflow, flip, hide, inline, limitShift, offset, rectToClientRect, shift, size };
|
e-commerce/node_modules/@floating-ui/core/dist/floating-ui.core.d.mts
ADDED
|
@@ -0,0 +1,535 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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|
+
import { ClientRectObject } from '@floating-ui/utils';
|
| 5 |
+
import { Coords } from '@floating-ui/utils';
|
| 6 |
+
import { Dimensions } from '@floating-ui/utils';
|
| 7 |
+
import { ElementRects } from '@floating-ui/utils';
|
| 8 |
+
import { Length } from '@floating-ui/utils';
|
| 9 |
+
import { Padding } from '@floating-ui/utils';
|
| 10 |
+
import { Placement } from '@floating-ui/utils';
|
| 11 |
+
import { Rect } from '@floating-ui/utils';
|
| 12 |
+
import { rectToClientRect } from '@floating-ui/utils';
|
| 13 |
+
import { Side } from '@floating-ui/utils';
|
| 14 |
+
import { SideObject } from '@floating-ui/utils';
|
| 15 |
+
import { Strategy } from '@floating-ui/utils';
|
| 16 |
+
import { VirtualElement } from '@floating-ui/utils';
|
| 17 |
+
|
| 18 |
+
export { AlignedPlacement }
|
| 19 |
+
|
| 20 |
+
export { Alignment }
|
| 21 |
+
|
| 22 |
+
/**
|
| 23 |
+
* Provides data to position an inner element of the floating element so that it
|
| 24 |
+
* appears centered to the reference element.
|
| 25 |
+
* @see https://floating-ui.com/docs/arrow
|
| 26 |
+
*/
|
| 27 |
+
export declare const arrow: (options: ArrowOptions | Derivable<ArrowOptions>) => Middleware;
|
| 28 |
+
|
| 29 |
+
export declare interface ArrowOptions {
|
| 30 |
+
/**
|
| 31 |
+
* The arrow element to be positioned.
|
| 32 |
+
* @default undefined
|
| 33 |
+
*/
|
| 34 |
+
element: any;
|
| 35 |
+
/**
|
| 36 |
+
* The padding between the arrow element and the floating element edges.
|
| 37 |
+
* Useful when the floating element has rounded corners.
|
| 38 |
+
* @default 0
|
| 39 |
+
*/
|
| 40 |
+
padding?: Padding | undefined;
|
| 41 |
+
}
|
| 42 |
+
|
| 43 |
+
/**
|
| 44 |
+
* Optimizes the visibility of the floating element by choosing the placement
|
| 45 |
+
* that has the most space available automatically, without needing to specify a
|
| 46 |
+
* preferred placement. Alternative to `flip`.
|
| 47 |
+
* @see https://floating-ui.com/docs/autoPlacement
|
| 48 |
+
*/
|
| 49 |
+
export declare const autoPlacement: (options?: AutoPlacementOptions | Derivable<AutoPlacementOptions>) => Middleware;
|
| 50 |
+
|
| 51 |
+
export declare interface AutoPlacementOptions extends DetectOverflowOptions {
|
| 52 |
+
/**
|
| 53 |
+
* The axis that runs along the alignment of the floating element. Determines
|
| 54 |
+
* whether to check for most space along this axis.
|
| 55 |
+
* @default false
|
| 56 |
+
*/
|
| 57 |
+
crossAxis?: boolean | undefined;
|
| 58 |
+
/**
|
| 59 |
+
* Choose placements with a particular alignment.
|
| 60 |
+
* @default undefined
|
| 61 |
+
*/
|
| 62 |
+
alignment?: Alignment | null | undefined;
|
| 63 |
+
/**
|
| 64 |
+
* Whether to choose placements with the opposite alignment if the preferred
|
| 65 |
+
* alignment does not fit.
|
| 66 |
+
* @default true
|
| 67 |
+
*/
|
| 68 |
+
autoAlignment?: boolean | undefined;
|
| 69 |
+
/**
|
| 70 |
+
* Which placements are allowed to be chosen. Placements must be within the
|
| 71 |
+
* `alignment` option if explicitly set.
|
| 72 |
+
* @default allPlacements (variable)
|
| 73 |
+
*/
|
| 74 |
+
allowedPlacements?: Array<Placement> | undefined;
|
| 75 |
+
}
|
| 76 |
+
|
| 77 |
+
export { Axis }
|
| 78 |
+
|
| 79 |
+
declare type BivariantCallback<T extends (...args: any[]) => any> = {
|
| 80 |
+
bivariance(...args: Parameters<T>): ReturnType<T>;
|
| 81 |
+
}['bivariance'];
|
| 82 |
+
|
| 83 |
+
export declare type Boundary = any;
|
| 84 |
+
|
| 85 |
+
export { ClientRectObject }
|
| 86 |
+
|
| 87 |
+
export declare type ComputePosition = (reference: unknown, floating: unknown, config: ComputePositionConfig) => Promise<ComputePositionReturn>;
|
| 88 |
+
|
| 89 |
+
/**
|
| 90 |
+
* Computes the `x` and `y` coordinates that will place the floating element
|
| 91 |
+
* next to a given reference element.
|
| 92 |
+
*
|
| 93 |
+
* This export does not have any `platform` interface logic. You will need to
|
| 94 |
+
* write one for the platform you are using Floating UI with.
|
| 95 |
+
*/
|
| 96 |
+
export declare const computePosition: ComputePosition;
|
| 97 |
+
|
| 98 |
+
export declare interface ComputePositionConfig {
|
| 99 |
+
/**
|
| 100 |
+
* Object to interface with the current platform.
|
| 101 |
+
*/
|
| 102 |
+
platform: Platform;
|
| 103 |
+
/**
|
| 104 |
+
* Where to place the floating element relative to the reference element.
|
| 105 |
+
*/
|
| 106 |
+
placement?: Placement | undefined;
|
| 107 |
+
/**
|
| 108 |
+
* The strategy to use when positioning the floating element.
|
| 109 |
+
*/
|
| 110 |
+
strategy?: Strategy | undefined;
|
| 111 |
+
/**
|
| 112 |
+
* Array of middleware objects to modify the positioning or provide data for
|
| 113 |
+
* rendering.
|
| 114 |
+
*/
|
| 115 |
+
middleware?: Array<Middleware | null | undefined | false> | undefined;
|
| 116 |
+
}
|
| 117 |
+
|
| 118 |
+
export declare interface ComputePositionReturn extends Coords {
|
| 119 |
+
/**
|
| 120 |
+
* The final chosen placement of the floating element.
|
| 121 |
+
*/
|
| 122 |
+
placement: Placement;
|
| 123 |
+
/**
|
| 124 |
+
* The strategy used to position the floating element.
|
| 125 |
+
*/
|
| 126 |
+
strategy: Strategy;
|
| 127 |
+
/**
|
| 128 |
+
* Object containing data returned from all middleware, keyed by their name.
|
| 129 |
+
*/
|
| 130 |
+
middlewareData: MiddlewareData;
|
| 131 |
+
}
|
| 132 |
+
|
| 133 |
+
export { Coords }
|
| 134 |
+
|
| 135 |
+
/**
|
| 136 |
+
* Function option to derive middleware options from state.
|
| 137 |
+
*/
|
| 138 |
+
export declare type Derivable<T> = (state: MiddlewareState) => T;
|
| 139 |
+
|
| 140 |
+
/**
|
| 141 |
+
* Resolves with an object of overflow side offsets that determine how much the
|
| 142 |
+
* element is overflowing a given clipping boundary on each side.
|
| 143 |
+
* - positive = overflowing the boundary by that number of pixels
|
| 144 |
+
* - negative = how many pixels left before it will overflow
|
| 145 |
+
* - 0 = lies flush with the boundary
|
| 146 |
+
* @see https://floating-ui.com/docs/detectOverflow
|
| 147 |
+
*/
|
| 148 |
+
export declare function detectOverflow(state: MiddlewareState, options?: DetectOverflowOptions | Derivable<DetectOverflowOptions>): Promise<SideObject>;
|
| 149 |
+
|
| 150 |
+
export declare interface DetectOverflowOptions {
|
| 151 |
+
/**
|
| 152 |
+
* The clipping element(s) or area in which overflow will be checked.
|
| 153 |
+
* @default 'clippingAncestors'
|
| 154 |
+
*/
|
| 155 |
+
boundary?: Boundary | undefined;
|
| 156 |
+
/**
|
| 157 |
+
* The root clipping area in which overflow will be checked.
|
| 158 |
+
* @default 'viewport'
|
| 159 |
+
*/
|
| 160 |
+
rootBoundary?: RootBoundary | undefined;
|
| 161 |
+
/**
|
| 162 |
+
* The element in which overflow is being checked relative to a boundary.
|
| 163 |
+
* @default 'floating'
|
| 164 |
+
*/
|
| 165 |
+
elementContext?: ElementContext | undefined;
|
| 166 |
+
/**
|
| 167 |
+
* Whether to check for overflow using the alternate element's boundary
|
| 168 |
+
* (`clippingAncestors` boundary only).
|
| 169 |
+
* @default false
|
| 170 |
+
*/
|
| 171 |
+
altBoundary?: boolean | undefined;
|
| 172 |
+
/**
|
| 173 |
+
* Virtual padding for the resolved overflow detection offsets.
|
| 174 |
+
* @default 0
|
| 175 |
+
*/
|
| 176 |
+
padding?: Padding | undefined;
|
| 177 |
+
}
|
| 178 |
+
|
| 179 |
+
export { Dimensions }
|
| 180 |
+
|
| 181 |
+
export declare type ElementContext = 'reference' | 'floating';
|
| 182 |
+
|
| 183 |
+
export { ElementRects }
|
| 184 |
+
|
| 185 |
+
export declare interface Elements {
|
| 186 |
+
reference: ReferenceElement;
|
| 187 |
+
floating: FloatingElement;
|
| 188 |
+
}
|
| 189 |
+
|
| 190 |
+
/**
|
| 191 |
+
* Optimizes the visibility of the floating element by flipping the `placement`
|
| 192 |
+
* in order to keep it in view when the preferred placement(s) will overflow the
|
| 193 |
+
* clipping boundary. Alternative to `autoPlacement`.
|
| 194 |
+
* @see https://floating-ui.com/docs/flip
|
| 195 |
+
*/
|
| 196 |
+
export declare const flip: (options?: FlipOptions | Derivable<FlipOptions>) => Middleware;
|
| 197 |
+
|
| 198 |
+
export declare interface FlipOptions extends DetectOverflowOptions {
|
| 199 |
+
/**
|
| 200 |
+
* The axis that runs along the side of the floating element. Determines
|
| 201 |
+
* whether overflow along this axis is checked to perform a flip.
|
| 202 |
+
* @default true
|
| 203 |
+
*/
|
| 204 |
+
mainAxis?: boolean | undefined;
|
| 205 |
+
/**
|
| 206 |
+
* The axis that runs along the alignment of the floating element. Determines
|
| 207 |
+
* whether overflow along this axis is checked to perform a flip.
|
| 208 |
+
* - `true`: Whether to check cross axis overflow for both side and alignment flipping.
|
| 209 |
+
* - `false`: Whether to disable all cross axis overflow checking.
|
| 210 |
+
* - `'alignment'`: Whether to check cross axis overflow for alignment flipping only.
|
| 211 |
+
* @default true
|
| 212 |
+
*/
|
| 213 |
+
crossAxis?: boolean | 'alignment' | undefined;
|
| 214 |
+
/**
|
| 215 |
+
* Placements to try sequentially if the preferred `placement` does not fit.
|
| 216 |
+
* @default [oppositePlacement] (computed)
|
| 217 |
+
*/
|
| 218 |
+
fallbackPlacements?: Array<Placement> | undefined;
|
| 219 |
+
/**
|
| 220 |
+
* What strategy to use when no placements fit.
|
| 221 |
+
* @default 'bestFit'
|
| 222 |
+
*/
|
| 223 |
+
fallbackStrategy?: 'bestFit' | 'initialPlacement' | undefined;
|
| 224 |
+
/**
|
| 225 |
+
* Whether to allow fallback to the perpendicular axis of the preferred
|
| 226 |
+
* placement, and if so, which side direction along the axis to prefer.
|
| 227 |
+
* @default 'none' (disallow fallback)
|
| 228 |
+
*/
|
| 229 |
+
fallbackAxisSideDirection?: 'none' | 'start' | 'end' | undefined;
|
| 230 |
+
/**
|
| 231 |
+
* Whether to flip to placements with the opposite alignment if they fit
|
| 232 |
+
* better.
|
| 233 |
+
* @default true
|
| 234 |
+
*/
|
| 235 |
+
flipAlignment?: boolean | undefined;
|
| 236 |
+
}
|
| 237 |
+
|
| 238 |
+
export declare type FloatingElement = any;
|
| 239 |
+
|
| 240 |
+
/**
|
| 241 |
+
* Provides data to hide the floating element in applicable situations, such as
|
| 242 |
+
* when it is not in the same clipping context as the reference element.
|
| 243 |
+
* @see https://floating-ui.com/docs/hide
|
| 244 |
+
*/
|
| 245 |
+
export declare const hide: (options?: HideOptions | Derivable<HideOptions>) => Middleware;
|
| 246 |
+
|
| 247 |
+
export declare interface HideOptions extends DetectOverflowOptions {
|
| 248 |
+
/**
|
| 249 |
+
* The strategy used to determine when to hide the floating element.
|
| 250 |
+
*/
|
| 251 |
+
strategy?: 'referenceHidden' | 'escaped' | undefined;
|
| 252 |
+
}
|
| 253 |
+
|
| 254 |
+
/**
|
| 255 |
+
* Provides improved positioning for inline reference elements that can span
|
| 256 |
+
* over multiple lines, such as hyperlinks or range selections.
|
| 257 |
+
* @see https://floating-ui.com/docs/inline
|
| 258 |
+
*/
|
| 259 |
+
export declare const inline: (options?: InlineOptions | Derivable<InlineOptions>) => Middleware;
|
| 260 |
+
|
| 261 |
+
export declare interface InlineOptions {
|
| 262 |
+
/**
|
| 263 |
+
* Viewport-relative `x` coordinate to choose a `ClientRect`.
|
| 264 |
+
* @default undefined
|
| 265 |
+
*/
|
| 266 |
+
x?: number | undefined;
|
| 267 |
+
/**
|
| 268 |
+
* Viewport-relative `y` coordinate to choose a `ClientRect`.
|
| 269 |
+
* @default undefined
|
| 270 |
+
*/
|
| 271 |
+
y?: number | undefined;
|
| 272 |
+
/**
|
| 273 |
+
* Represents the padding around a disjoined rect when choosing it.
|
| 274 |
+
* @default 2
|
| 275 |
+
*/
|
| 276 |
+
padding?: Padding | undefined;
|
| 277 |
+
}
|
| 278 |
+
|
| 279 |
+
export { Length }
|
| 280 |
+
|
| 281 |
+
/**
|
| 282 |
+
* Built-in `limiter` that will stop `shift()` at a certain point.
|
| 283 |
+
*/
|
| 284 |
+
export declare const limitShift: (options?: LimitShiftOptions | Derivable<LimitShiftOptions>) => {
|
| 285 |
+
options: any;
|
| 286 |
+
fn: (state: MiddlewareState) => Coords;
|
| 287 |
+
};
|
| 288 |
+
|
| 289 |
+
declare type LimitShiftOffset = number | {
|
| 290 |
+
/**
|
| 291 |
+
* Offset the limiting of the axis that runs along the alignment of the
|
| 292 |
+
* floating element.
|
| 293 |
+
*/
|
| 294 |
+
mainAxis?: number | undefined;
|
| 295 |
+
/**
|
| 296 |
+
* Offset the limiting of the axis that runs along the side of the
|
| 297 |
+
* floating element.
|
| 298 |
+
*/
|
| 299 |
+
crossAxis?: number | undefined;
|
| 300 |
+
};
|
| 301 |
+
|
| 302 |
+
export declare interface LimitShiftOptions {
|
| 303 |
+
/**
|
| 304 |
+
* Offset when limiting starts. `0` will limit when the opposite edges of the
|
| 305 |
+
* reference and floating elements are aligned.
|
| 306 |
+
* - positive = start limiting earlier
|
| 307 |
+
* - negative = start limiting later
|
| 308 |
+
*/
|
| 309 |
+
offset?: LimitShiftOffset | Derivable<LimitShiftOffset> | undefined;
|
| 310 |
+
/**
|
| 311 |
+
* Whether to limit the axis that runs along the alignment of the floating
|
| 312 |
+
* element.
|
| 313 |
+
*/
|
| 314 |
+
mainAxis?: boolean | undefined;
|
| 315 |
+
/**
|
| 316 |
+
* Whether to limit the axis that runs along the side of the floating element.
|
| 317 |
+
*/
|
| 318 |
+
crossAxis?: boolean | undefined;
|
| 319 |
+
}
|
| 320 |
+
|
| 321 |
+
export declare type Middleware = {
|
| 322 |
+
name: string;
|
| 323 |
+
options?: any;
|
| 324 |
+
fn: (state: MiddlewareState) => Promisable<MiddlewareReturn>;
|
| 325 |
+
};
|
| 326 |
+
|
| 327 |
+
/**
|
| 328 |
+
* @deprecated use `MiddlewareState` instead.
|
| 329 |
+
*/
|
| 330 |
+
export declare type MiddlewareArguments = MiddlewareState;
|
| 331 |
+
|
| 332 |
+
export declare interface MiddlewareData {
|
| 333 |
+
[key: string]: any;
|
| 334 |
+
arrow?: (Partial<Coords> & {
|
| 335 |
+
centerOffset: number;
|
| 336 |
+
alignmentOffset?: number | undefined;
|
| 337 |
+
}) | undefined;
|
| 338 |
+
autoPlacement?: {
|
| 339 |
+
index?: number | undefined;
|
| 340 |
+
overflows: Array<{
|
| 341 |
+
placement: Placement;
|
| 342 |
+
overflows: Array<number>;
|
| 343 |
+
}>;
|
| 344 |
+
} | undefined;
|
| 345 |
+
flip?: {
|
| 346 |
+
index?: number | undefined;
|
| 347 |
+
overflows: Array<{
|
| 348 |
+
placement: Placement;
|
| 349 |
+
overflows: Array<number>;
|
| 350 |
+
}>;
|
| 351 |
+
} | undefined;
|
| 352 |
+
hide?: {
|
| 353 |
+
referenceHidden?: boolean | undefined;
|
| 354 |
+
escaped?: boolean | undefined;
|
| 355 |
+
referenceHiddenOffsets?: SideObject | undefined;
|
| 356 |
+
escapedOffsets?: SideObject | undefined;
|
| 357 |
+
} | undefined;
|
| 358 |
+
offset?: (Coords & {
|
| 359 |
+
placement: Placement;
|
| 360 |
+
}) | undefined;
|
| 361 |
+
shift?: (Coords & {
|
| 362 |
+
enabled: {
|
| 363 |
+
[key in Axis]: boolean;
|
| 364 |
+
};
|
| 365 |
+
}) | undefined;
|
| 366 |
+
}
|
| 367 |
+
|
| 368 |
+
export declare interface MiddlewareReturn extends Partial<Coords> {
|
| 369 |
+
data?: {
|
| 370 |
+
[key: string]: any;
|
| 371 |
+
} | undefined;
|
| 372 |
+
reset?: boolean | {
|
| 373 |
+
placement?: Placement | undefined;
|
| 374 |
+
rects?: boolean | ElementRects | undefined;
|
| 375 |
+
} | undefined;
|
| 376 |
+
}
|
| 377 |
+
|
| 378 |
+
export declare interface MiddlewareState extends Coords {
|
| 379 |
+
initialPlacement: Placement;
|
| 380 |
+
placement: Placement;
|
| 381 |
+
strategy: Strategy;
|
| 382 |
+
middlewareData: MiddlewareData;
|
| 383 |
+
elements: Elements;
|
| 384 |
+
rects: ElementRects;
|
| 385 |
+
platform: {
|
| 386 |
+
detectOverflow: typeof detectOverflow;
|
| 387 |
+
} & Platform;
|
| 388 |
+
}
|
| 389 |
+
|
| 390 |
+
/**
|
| 391 |
+
* Modifies the placement by translating the floating element along the
|
| 392 |
+
* specified axes.
|
| 393 |
+
* A number (shorthand for `mainAxis` or distance), or an axes configuration
|
| 394 |
+
* object may be passed.
|
| 395 |
+
* @see https://floating-ui.com/docs/offset
|
| 396 |
+
*/
|
| 397 |
+
export declare const offset: (options?: OffsetOptions) => Middleware;
|
| 398 |
+
|
| 399 |
+
export declare type OffsetOptions = OffsetValue | Derivable<OffsetValue>;
|
| 400 |
+
|
| 401 |
+
declare type OffsetValue = number | {
|
| 402 |
+
/**
|
| 403 |
+
* The axis that runs along the side of the floating element. Represents
|
| 404 |
+
* the distance (gutter or margin) between the reference and floating
|
| 405 |
+
* element.
|
| 406 |
+
* @default 0
|
| 407 |
+
*/
|
| 408 |
+
mainAxis?: number | undefined;
|
| 409 |
+
/**
|
| 410 |
+
* The axis that runs along the alignment of the floating element.
|
| 411 |
+
* Represents the skidding between the reference and floating element.
|
| 412 |
+
* @default 0
|
| 413 |
+
*/
|
| 414 |
+
crossAxis?: number | undefined;
|
| 415 |
+
/**
|
| 416 |
+
* The same axis as `crossAxis` but applies only to aligned placements
|
| 417 |
+
* and inverts the `end` alignment. When set to a number, it overrides the
|
| 418 |
+
* `crossAxis` value.
|
| 419 |
+
*
|
| 420 |
+
* A positive number will move the floating element in the direction of
|
| 421 |
+
* the opposite edge to the one that is aligned, while a negative number
|
| 422 |
+
* the reverse.
|
| 423 |
+
* @default null
|
| 424 |
+
*/
|
| 425 |
+
alignmentAxis?: number | null | undefined;
|
| 426 |
+
};
|
| 427 |
+
|
| 428 |
+
export { Padding }
|
| 429 |
+
|
| 430 |
+
export { Placement }
|
| 431 |
+
|
| 432 |
+
/**
|
| 433 |
+
* Platform interface methods to work with the current platform.
|
| 434 |
+
* @see https://floating-ui.com/docs/platform
|
| 435 |
+
*/
|
| 436 |
+
export declare interface Platform {
|
| 437 |
+
getElementRects: (args: {
|
| 438 |
+
reference: ReferenceElement;
|
| 439 |
+
floating: FloatingElement;
|
| 440 |
+
strategy: Strategy;
|
| 441 |
+
}) => Promisable<ElementRects>;
|
| 442 |
+
getClippingRect: (args: {
|
| 443 |
+
element: any;
|
| 444 |
+
boundary: Boundary;
|
| 445 |
+
rootBoundary: RootBoundary;
|
| 446 |
+
strategy: Strategy;
|
| 447 |
+
}) => Promisable<Rect>;
|
| 448 |
+
getDimensions: (element: any) => Promisable<Dimensions>;
|
| 449 |
+
convertOffsetParentRelativeRectToViewportRelativeRect?: ((args: {
|
| 450 |
+
elements?: Elements | undefined;
|
| 451 |
+
rect: Rect;
|
| 452 |
+
offsetParent: any;
|
| 453 |
+
strategy: Strategy;
|
| 454 |
+
}) => Promisable<Rect>) | undefined;
|
| 455 |
+
getOffsetParent?: ((element: any) => Promisable<any>) | undefined;
|
| 456 |
+
isElement?: ((value: any) => Promisable<boolean>) | undefined;
|
| 457 |
+
getDocumentElement?: ((element: any) => Promisable<any>) | undefined;
|
| 458 |
+
getClientRects?: ((element: any) => Promisable<Array<ClientRectObject>>) | undefined;
|
| 459 |
+
isRTL?: ((element: any) => Promisable<boolean>) | undefined;
|
| 460 |
+
getScale?: ((element: any) => Promisable<{
|
| 461 |
+
x: number;
|
| 462 |
+
y: number;
|
| 463 |
+
}>) | undefined;
|
| 464 |
+
detectOverflow?: typeof detectOverflow | undefined;
|
| 465 |
+
}
|
| 466 |
+
|
| 467 |
+
declare type Promisable<T> = T | Promise<T>;
|
| 468 |
+
|
| 469 |
+
export { Rect }
|
| 470 |
+
|
| 471 |
+
export { rectToClientRect }
|
| 472 |
+
|
| 473 |
+
export declare type ReferenceElement = any;
|
| 474 |
+
|
| 475 |
+
export declare type RootBoundary = 'viewport' | 'layoutViewport' | 'document' | Rect;
|
| 476 |
+
|
| 477 |
+
/**
|
| 478 |
+
* Optimizes the visibility of the floating element by shifting it in order to
|
| 479 |
+
* keep it in view when it will overflow the clipping boundary.
|
| 480 |
+
* @see https://floating-ui.com/docs/shift
|
| 481 |
+
*/
|
| 482 |
+
export declare const shift: (options?: ShiftOptions | Derivable<ShiftOptions>) => Middleware;
|
| 483 |
+
|
| 484 |
+
export declare interface ShiftOptions extends DetectOverflowOptions {
|
| 485 |
+
/**
|
| 486 |
+
* The axis that runs along the alignment of the floating element. Determines
|
| 487 |
+
* whether overflow along this axis is checked to perform shifting.
|
| 488 |
+
* @default true
|
| 489 |
+
*/
|
| 490 |
+
mainAxis?: boolean | undefined;
|
| 491 |
+
/**
|
| 492 |
+
* The axis that runs along the side of the floating element. Determines
|
| 493 |
+
* whether overflow along this axis is checked to perform shifting.
|
| 494 |
+
* @default false
|
| 495 |
+
*/
|
| 496 |
+
crossAxis?: boolean | undefined;
|
| 497 |
+
/**
|
| 498 |
+
* Accepts a function that limits the shifting done in order to prevent
|
| 499 |
+
* detachment.
|
| 500 |
+
*/
|
| 501 |
+
limiter?: {
|
| 502 |
+
fn: (state: MiddlewareState) => Coords;
|
| 503 |
+
options?: any;
|
| 504 |
+
} | undefined;
|
| 505 |
+
}
|
| 506 |
+
|
| 507 |
+
export { Side }
|
| 508 |
+
|
| 509 |
+
export { SideObject }
|
| 510 |
+
|
| 511 |
+
/**
|
| 512 |
+
* Provides data that allows you to change the size of the floating element —
|
| 513 |
+
* for instance, prevent it from overflowing the clipping boundary or match the
|
| 514 |
+
* width of the reference element.
|
| 515 |
+
* @see https://floating-ui.com/docs/size
|
| 516 |
+
*/
|
| 517 |
+
export declare const size: (options?: SizeOptions | Derivable<SizeOptions>) => Middleware;
|
| 518 |
+
|
| 519 |
+
export declare interface SizeOptions extends DetectOverflowOptions {
|
| 520 |
+
/**
|
| 521 |
+
* Function that is called to perform style mutations to the floating element
|
| 522 |
+
* to change its size.
|
| 523 |
+
* @default undefined
|
| 524 |
+
*/
|
| 525 |
+
apply?: BivariantCallback<(args: MiddlewareState & {
|
| 526 |
+
availableWidth: number;
|
| 527 |
+
availableHeight: number;
|
| 528 |
+
}) => void | Promise<void>> | undefined;
|
| 529 |
+
}
|
| 530 |
+
|
| 531 |
+
export { Strategy }
|
| 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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { AlignedPlacement } from '@floating-ui/utils';
|
| 2 |
+
import { Alignment } from '@floating-ui/utils';
|
| 3 |
+
import { Axis } from '@floating-ui/utils';
|
| 4 |
+
import { ClientRectObject } from '@floating-ui/utils';
|
| 5 |
+
import { Coords } from '@floating-ui/utils';
|
| 6 |
+
import { Dimensions } from '@floating-ui/utils';
|
| 7 |
+
import { ElementRects } from '@floating-ui/utils';
|
| 8 |
+
import { Length } from '@floating-ui/utils';
|
| 9 |
+
import { Padding } from '@floating-ui/utils';
|
| 10 |
+
import { Placement } from '@floating-ui/utils';
|
| 11 |
+
import { Rect } from '@floating-ui/utils';
|
| 12 |
+
import { rectToClientRect } from '@floating-ui/utils';
|
| 13 |
+
import { Side } from '@floating-ui/utils';
|
| 14 |
+
import { SideObject } from '@floating-ui/utils';
|
| 15 |
+
import { Strategy } from '@floating-ui/utils';
|
| 16 |
+
import { VirtualElement } from '@floating-ui/utils';
|
| 17 |
+
|
| 18 |
+
export { AlignedPlacement }
|
| 19 |
+
|
| 20 |
+
export { Alignment }
|
| 21 |
+
|
| 22 |
+
/**
|
| 23 |
+
* Provides data to position an inner element of the floating element so that it
|
| 24 |
+
* appears centered to the reference element.
|
| 25 |
+
* @see https://floating-ui.com/docs/arrow
|
| 26 |
+
*/
|
| 27 |
+
export declare const arrow: (options: ArrowOptions | Derivable<ArrowOptions>) => Middleware;
|
| 28 |
+
|
| 29 |
+
export declare interface ArrowOptions {
|
| 30 |
+
/**
|
| 31 |
+
* The arrow element to be positioned.
|
| 32 |
+
* @default undefined
|
| 33 |
+
*/
|
| 34 |
+
element: any;
|
| 35 |
+
/**
|
| 36 |
+
* The padding between the arrow element and the floating element edges.
|
| 37 |
+
* Useful when the floating element has rounded corners.
|
| 38 |
+
* @default 0
|
| 39 |
+
*/
|
| 40 |
+
padding?: Padding | undefined;
|
| 41 |
+
}
|
| 42 |
+
|
| 43 |
+
/**
|
| 44 |
+
* Optimizes the visibility of the floating element by choosing the placement
|
| 45 |
+
* that has the most space available automatically, without needing to specify a
|
| 46 |
+
* preferred placement. Alternative to `flip`.
|
| 47 |
+
* @see https://floating-ui.com/docs/autoPlacement
|
| 48 |
+
*/
|
| 49 |
+
export declare const autoPlacement: (options?: AutoPlacementOptions | Derivable<AutoPlacementOptions>) => Middleware;
|
| 50 |
+
|
| 51 |
+
export declare interface AutoPlacementOptions extends DetectOverflowOptions {
|
| 52 |
+
/**
|
| 53 |
+
* The axis that runs along the alignment of the floating element. Determines
|
| 54 |
+
* whether to check for most space along this axis.
|
| 55 |
+
* @default false
|
| 56 |
+
*/
|
| 57 |
+
crossAxis?: boolean | undefined;
|
| 58 |
+
/**
|
| 59 |
+
* Choose placements with a particular alignment.
|
| 60 |
+
* @default undefined
|
| 61 |
+
*/
|
| 62 |
+
alignment?: Alignment | null | undefined;
|
| 63 |
+
/**
|
| 64 |
+
* Whether to choose placements with the opposite alignment if the preferred
|
| 65 |
+
* alignment does not fit.
|
| 66 |
+
* @default true
|
| 67 |
+
*/
|
| 68 |
+
autoAlignment?: boolean | undefined;
|
| 69 |
+
/**
|
| 70 |
+
* Which placements are allowed to be chosen. Placements must be within the
|
| 71 |
+
* `alignment` option if explicitly set.
|
| 72 |
+
* @default allPlacements (variable)
|
| 73 |
+
*/
|
| 74 |
+
allowedPlacements?: Array<Placement> | undefined;
|
| 75 |
+
}
|
| 76 |
+
|
| 77 |
+
export { Axis }
|
| 78 |
+
|
| 79 |
+
declare type BivariantCallback<T extends (...args: any[]) => any> = {
|
| 80 |
+
bivariance(...args: Parameters<T>): ReturnType<T>;
|
| 81 |
+
}['bivariance'];
|
| 82 |
+
|
| 83 |
+
export declare type Boundary = any;
|
| 84 |
+
|
| 85 |
+
export { ClientRectObject }
|
| 86 |
+
|
| 87 |
+
export declare type ComputePosition = (reference: unknown, floating: unknown, config: ComputePositionConfig) => Promise<ComputePositionReturn>;
|
| 88 |
+
|
| 89 |
+
/**
|
| 90 |
+
* Computes the `x` and `y` coordinates that will place the floating element
|
| 91 |
+
* next to a given reference element.
|
| 92 |
+
*
|
| 93 |
+
* This export does not have any `platform` interface logic. You will need to
|
| 94 |
+
* write one for the platform you are using Floating UI with.
|
| 95 |
+
*/
|
| 96 |
+
export declare const computePosition: ComputePosition;
|
| 97 |
+
|
| 98 |
+
export declare interface ComputePositionConfig {
|
| 99 |
+
/**
|
| 100 |
+
* Object to interface with the current platform.
|
| 101 |
+
*/
|
| 102 |
+
platform: Platform;
|
| 103 |
+
/**
|
| 104 |
+
* Where to place the floating element relative to the reference element.
|
| 105 |
+
*/
|
| 106 |
+
placement?: Placement | undefined;
|
| 107 |
+
/**
|
| 108 |
+
* The strategy to use when positioning the floating element.
|
| 109 |
+
*/
|
| 110 |
+
strategy?: Strategy | undefined;
|
| 111 |
+
/**
|
| 112 |
+
* Array of middleware objects to modify the positioning or provide data for
|
| 113 |
+
* rendering.
|
| 114 |
+
*/
|
| 115 |
+
middleware?: Array<Middleware | null | undefined | false> | undefined;
|
| 116 |
+
}
|
| 117 |
+
|
| 118 |
+
export declare interface ComputePositionReturn extends Coords {
|
| 119 |
+
/**
|
| 120 |
+
* The final chosen placement of the floating element.
|
| 121 |
+
*/
|
| 122 |
+
placement: Placement;
|
| 123 |
+
/**
|
| 124 |
+
* The strategy used to position the floating element.
|
| 125 |
+
*/
|
| 126 |
+
strategy: Strategy;
|
| 127 |
+
/**
|
| 128 |
+
* Object containing data returned from all middleware, keyed by their name.
|
| 129 |
+
*/
|
| 130 |
+
middlewareData: MiddlewareData;
|
| 131 |
+
}
|
| 132 |
+
|
| 133 |
+
export { Coords }
|
| 134 |
+
|
| 135 |
+
/**
|
| 136 |
+
* Function option to derive middleware options from state.
|
| 137 |
+
*/
|
| 138 |
+
export declare type Derivable<T> = (state: MiddlewareState) => T;
|
| 139 |
+
|
| 140 |
+
/**
|
| 141 |
+
* Resolves with an object of overflow side offsets that determine how much the
|
| 142 |
+
* element is overflowing a given clipping boundary on each side.
|
| 143 |
+
* - positive = overflowing the boundary by that number of pixels
|
| 144 |
+
* - negative = how many pixels left before it will overflow
|
| 145 |
+
* - 0 = lies flush with the boundary
|
| 146 |
+
* @see https://floating-ui.com/docs/detectOverflow
|
| 147 |
+
*/
|
| 148 |
+
export declare function detectOverflow(state: MiddlewareState, options?: DetectOverflowOptions | Derivable<DetectOverflowOptions>): Promise<SideObject>;
|
| 149 |
+
|
| 150 |
+
export declare interface DetectOverflowOptions {
|
| 151 |
+
/**
|
| 152 |
+
* The clipping element(s) or area in which overflow will be checked.
|
| 153 |
+
* @default 'clippingAncestors'
|
| 154 |
+
*/
|
| 155 |
+
boundary?: Boundary | undefined;
|
| 156 |
+
/**
|
| 157 |
+
* The root clipping area in which overflow will be checked.
|
| 158 |
+
* @default 'viewport'
|
| 159 |
+
*/
|
| 160 |
+
rootBoundary?: RootBoundary | undefined;
|
| 161 |
+
/**
|
| 162 |
+
* The element in which overflow is being checked relative to a boundary.
|
| 163 |
+
* @default 'floating'
|
| 164 |
+
*/
|
| 165 |
+
elementContext?: ElementContext | undefined;
|
| 166 |
+
/**
|
| 167 |
+
* Whether to check for overflow using the alternate element's boundary
|
| 168 |
+
* (`clippingAncestors` boundary only).
|
| 169 |
+
* @default false
|
| 170 |
+
*/
|
| 171 |
+
altBoundary?: boolean | undefined;
|
| 172 |
+
/**
|
| 173 |
+
* Virtual padding for the resolved overflow detection offsets.
|
| 174 |
+
* @default 0
|
| 175 |
+
*/
|
| 176 |
+
padding?: Padding | undefined;
|
| 177 |
+
}
|
| 178 |
+
|
| 179 |
+
export { Dimensions }
|
| 180 |
+
|
| 181 |
+
export declare type ElementContext = 'reference' | 'floating';
|
| 182 |
+
|
| 183 |
+
export { ElementRects }
|
| 184 |
+
|
| 185 |
+
export declare interface Elements {
|
| 186 |
+
reference: ReferenceElement;
|
| 187 |
+
floating: FloatingElement;
|
| 188 |
+
}
|
| 189 |
+
|
| 190 |
+
/**
|
| 191 |
+
* Optimizes the visibility of the floating element by flipping the `placement`
|
| 192 |
+
* in order to keep it in view when the preferred placement(s) will overflow the
|
| 193 |
+
* clipping boundary. Alternative to `autoPlacement`.
|
| 194 |
+
* @see https://floating-ui.com/docs/flip
|
| 195 |
+
*/
|
| 196 |
+
export declare const flip: (options?: FlipOptions | Derivable<FlipOptions>) => Middleware;
|
| 197 |
+
|
| 198 |
+
export declare interface FlipOptions extends DetectOverflowOptions {
|
| 199 |
+
/**
|
| 200 |
+
* The axis that runs along the side of the floating element. Determines
|
| 201 |
+
* whether overflow along this axis is checked to perform a flip.
|
| 202 |
+
* @default true
|
| 203 |
+
*/
|
| 204 |
+
mainAxis?: boolean | undefined;
|
| 205 |
+
/**
|
| 206 |
+
* The axis that runs along the alignment of the floating element. Determines
|
| 207 |
+
* whether overflow along this axis is checked to perform a flip.
|
| 208 |
+
* - `true`: Whether to check cross axis overflow for both side and alignment flipping.
|
| 209 |
+
* - `false`: Whether to disable all cross axis overflow checking.
|
| 210 |
+
* - `'alignment'`: Whether to check cross axis overflow for alignment flipping only.
|
| 211 |
+
* @default true
|
| 212 |
+
*/
|
| 213 |
+
crossAxis?: boolean | 'alignment' | undefined;
|
| 214 |
+
/**
|
| 215 |
+
* Placements to try sequentially if the preferred `placement` does not fit.
|
| 216 |
+
* @default [oppositePlacement] (computed)
|
| 217 |
+
*/
|
| 218 |
+
fallbackPlacements?: Array<Placement> | undefined;
|
| 219 |
+
/**
|
| 220 |
+
* What strategy to use when no placements fit.
|
| 221 |
+
* @default 'bestFit'
|
| 222 |
+
*/
|
| 223 |
+
fallbackStrategy?: 'bestFit' | 'initialPlacement' | undefined;
|
| 224 |
+
/**
|
| 225 |
+
* Whether to allow fallback to the perpendicular axis of the preferred
|
| 226 |
+
* placement, and if so, which side direction along the axis to prefer.
|
| 227 |
+
* @default 'none' (disallow fallback)
|
| 228 |
+
*/
|
| 229 |
+
fallbackAxisSideDirection?: 'none' | 'start' | 'end' | undefined;
|
| 230 |
+
/**
|
| 231 |
+
* Whether to flip to placements with the opposite alignment if they fit
|
| 232 |
+
* better.
|
| 233 |
+
* @default true
|
| 234 |
+
*/
|
| 235 |
+
flipAlignment?: boolean | undefined;
|
| 236 |
+
}
|
| 237 |
+
|
| 238 |
+
export declare type FloatingElement = any;
|
| 239 |
+
|
| 240 |
+
/**
|
| 241 |
+
* Provides data to hide the floating element in applicable situations, such as
|
| 242 |
+
* when it is not in the same clipping context as the reference element.
|
| 243 |
+
* @see https://floating-ui.com/docs/hide
|
| 244 |
+
*/
|
| 245 |
+
export declare const hide: (options?: HideOptions | Derivable<HideOptions>) => Middleware;
|
| 246 |
+
|
| 247 |
+
export declare interface HideOptions extends DetectOverflowOptions {
|
| 248 |
+
/**
|
| 249 |
+
* The strategy used to determine when to hide the floating element.
|
| 250 |
+
*/
|
| 251 |
+
strategy?: 'referenceHidden' | 'escaped' | undefined;
|
| 252 |
+
}
|
| 253 |
+
|
| 254 |
+
/**
|
| 255 |
+
* Provides improved positioning for inline reference elements that can span
|
| 256 |
+
* over multiple lines, such as hyperlinks or range selections.
|
| 257 |
+
* @see https://floating-ui.com/docs/inline
|
| 258 |
+
*/
|
| 259 |
+
export declare const inline: (options?: InlineOptions | Derivable<InlineOptions>) => Middleware;
|
| 260 |
+
|
| 261 |
+
export declare interface InlineOptions {
|
| 262 |
+
/**
|
| 263 |
+
* Viewport-relative `x` coordinate to choose a `ClientRect`.
|
| 264 |
+
* @default undefined
|
| 265 |
+
*/
|
| 266 |
+
x?: number | undefined;
|
| 267 |
+
/**
|
| 268 |
+
* Viewport-relative `y` coordinate to choose a `ClientRect`.
|
| 269 |
+
* @default undefined
|
| 270 |
+
*/
|
| 271 |
+
y?: number | undefined;
|
| 272 |
+
/**
|
| 273 |
+
* Represents the padding around a disjoined rect when choosing it.
|
| 274 |
+
* @default 2
|
| 275 |
+
*/
|
| 276 |
+
padding?: Padding | undefined;
|
| 277 |
+
}
|
| 278 |
+
|
| 279 |
+
export { Length }
|
| 280 |
+
|
| 281 |
+
/**
|
| 282 |
+
* Built-in `limiter` that will stop `shift()` at a certain point.
|
| 283 |
+
*/
|
| 284 |
+
export declare const limitShift: (options?: LimitShiftOptions | Derivable<LimitShiftOptions>) => {
|
| 285 |
+
options: any;
|
| 286 |
+
fn: (state: MiddlewareState) => Coords;
|
| 287 |
+
};
|
| 288 |
+
|
| 289 |
+
declare type LimitShiftOffset = number | {
|
| 290 |
+
/**
|
| 291 |
+
* Offset the limiting of the axis that runs along the alignment of the
|
| 292 |
+
* floating element.
|
| 293 |
+
*/
|
| 294 |
+
mainAxis?: number | undefined;
|
| 295 |
+
/**
|
| 296 |
+
* Offset the limiting of the axis that runs along the side of the
|
| 297 |
+
* floating element.
|
| 298 |
+
*/
|
| 299 |
+
crossAxis?: number | undefined;
|
| 300 |
+
};
|
| 301 |
+
|
| 302 |
+
export declare interface LimitShiftOptions {
|
| 303 |
+
/**
|
| 304 |
+
* Offset when limiting starts. `0` will limit when the opposite edges of the
|
| 305 |
+
* reference and floating elements are aligned.
|
| 306 |
+
* - positive = start limiting earlier
|
| 307 |
+
* - negative = start limiting later
|
| 308 |
+
*/
|
| 309 |
+
offset?: LimitShiftOffset | Derivable<LimitShiftOffset> | undefined;
|
| 310 |
+
/**
|
| 311 |
+
* Whether to limit the axis that runs along the alignment of the floating
|
| 312 |
+
* element.
|
| 313 |
+
*/
|
| 314 |
+
mainAxis?: boolean | undefined;
|
| 315 |
+
/**
|
| 316 |
+
* Whether to limit the axis that runs along the side of the floating element.
|
| 317 |
+
*/
|
| 318 |
+
crossAxis?: boolean | undefined;
|
| 319 |
+
}
|
| 320 |
+
|
| 321 |
+
export declare type Middleware = {
|
| 322 |
+
name: string;
|
| 323 |
+
options?: any;
|
| 324 |
+
fn: (state: MiddlewareState) => Promisable<MiddlewareReturn>;
|
| 325 |
+
};
|
| 326 |
+
|
| 327 |
+
/**
|
| 328 |
+
* @deprecated use `MiddlewareState` instead.
|
| 329 |
+
*/
|
| 330 |
+
export declare type MiddlewareArguments = MiddlewareState;
|
| 331 |
+
|
| 332 |
+
export declare interface MiddlewareData {
|
| 333 |
+
[key: string]: any;
|
| 334 |
+
arrow?: (Partial<Coords> & {
|
| 335 |
+
centerOffset: number;
|
| 336 |
+
alignmentOffset?: number | undefined;
|
| 337 |
+
}) | undefined;
|
| 338 |
+
autoPlacement?: {
|
| 339 |
+
index?: number | undefined;
|
| 340 |
+
overflows: Array<{
|
| 341 |
+
placement: Placement;
|
| 342 |
+
overflows: Array<number>;
|
| 343 |
+
}>;
|
| 344 |
+
} | undefined;
|
| 345 |
+
flip?: {
|
| 346 |
+
index?: number | undefined;
|
| 347 |
+
overflows: Array<{
|
| 348 |
+
placement: Placement;
|
| 349 |
+
overflows: Array<number>;
|
| 350 |
+
}>;
|
| 351 |
+
} | undefined;
|
| 352 |
+
hide?: {
|
| 353 |
+
referenceHidden?: boolean | undefined;
|
| 354 |
+
escaped?: boolean | undefined;
|
| 355 |
+
referenceHiddenOffsets?: SideObject | undefined;
|
| 356 |
+
escapedOffsets?: SideObject | undefined;
|
| 357 |
+
} | undefined;
|
| 358 |
+
offset?: (Coords & {
|
| 359 |
+
placement: Placement;
|
| 360 |
+
}) | undefined;
|
| 361 |
+
shift?: (Coords & {
|
| 362 |
+
enabled: {
|
| 363 |
+
[key in Axis]: boolean;
|
| 364 |
+
};
|
| 365 |
+
}) | undefined;
|
| 366 |
+
}
|
| 367 |
+
|
| 368 |
+
export declare interface MiddlewareReturn extends Partial<Coords> {
|
| 369 |
+
data?: {
|
| 370 |
+
[key: string]: any;
|
| 371 |
+
} | undefined;
|
| 372 |
+
reset?: boolean | {
|
| 373 |
+
placement?: Placement | undefined;
|
| 374 |
+
rects?: boolean | ElementRects | undefined;
|
| 375 |
+
} | undefined;
|
| 376 |
+
}
|
| 377 |
+
|
| 378 |
+
export declare interface MiddlewareState extends Coords {
|
| 379 |
+
initialPlacement: Placement;
|
| 380 |
+
placement: Placement;
|
| 381 |
+
strategy: Strategy;
|
| 382 |
+
middlewareData: MiddlewareData;
|
| 383 |
+
elements: Elements;
|
| 384 |
+
rects: ElementRects;
|
| 385 |
+
platform: {
|
| 386 |
+
detectOverflow: typeof detectOverflow;
|
| 387 |
+
} & Platform;
|
| 388 |
+
}
|
| 389 |
+
|
| 390 |
+
/**
|
| 391 |
+
* Modifies the placement by translating the floating element along the
|
| 392 |
+
* specified axes.
|
| 393 |
+
* A number (shorthand for `mainAxis` or distance), or an axes configuration
|
| 394 |
+
* object may be passed.
|
| 395 |
+
* @see https://floating-ui.com/docs/offset
|
| 396 |
+
*/
|
| 397 |
+
export declare const offset: (options?: OffsetOptions) => Middleware;
|
| 398 |
+
|
| 399 |
+
export declare type OffsetOptions = OffsetValue | Derivable<OffsetValue>;
|
| 400 |
+
|
| 401 |
+
declare type OffsetValue = number | {
|
| 402 |
+
/**
|
| 403 |
+
* The axis that runs along the side of the floating element. Represents
|
| 404 |
+
* the distance (gutter or margin) between the reference and floating
|
| 405 |
+
* element.
|
| 406 |
+
* @default 0
|
| 407 |
+
*/
|
| 408 |
+
mainAxis?: number | undefined;
|
| 409 |
+
/**
|
| 410 |
+
* The axis that runs along the alignment of the floating element.
|
| 411 |
+
* Represents the skidding between the reference and floating element.
|
| 412 |
+
* @default 0
|
| 413 |
+
*/
|
| 414 |
+
crossAxis?: number | undefined;
|
| 415 |
+
/**
|
| 416 |
+
* The same axis as `crossAxis` but applies only to aligned placements
|
| 417 |
+
* and inverts the `end` alignment. When set to a number, it overrides the
|
| 418 |
+
* `crossAxis` value.
|
| 419 |
+
*
|
| 420 |
+
* A positive number will move the floating element in the direction of
|
| 421 |
+
* the opposite edge to the one that is aligned, while a negative number
|
| 422 |
+
* the reverse.
|
| 423 |
+
* @default null
|
| 424 |
+
*/
|
| 425 |
+
alignmentAxis?: number | null | undefined;
|
| 426 |
+
};
|
| 427 |
+
|
| 428 |
+
export { Padding }
|
| 429 |
+
|
| 430 |
+
export { Placement }
|
| 431 |
+
|
| 432 |
+
/**
|
| 433 |
+
* Platform interface methods to work with the current platform.
|
| 434 |
+
* @see https://floating-ui.com/docs/platform
|
| 435 |
+
*/
|
| 436 |
+
export declare interface Platform {
|
| 437 |
+
getElementRects: (args: {
|
| 438 |
+
reference: ReferenceElement;
|
| 439 |
+
floating: FloatingElement;
|
| 440 |
+
strategy: Strategy;
|
| 441 |
+
}) => Promisable<ElementRects>;
|
| 442 |
+
getClippingRect: (args: {
|
| 443 |
+
element: any;
|
| 444 |
+
boundary: Boundary;
|
| 445 |
+
rootBoundary: RootBoundary;
|
| 446 |
+
strategy: Strategy;
|
| 447 |
+
}) => Promisable<Rect>;
|
| 448 |
+
getDimensions: (element: any) => Promisable<Dimensions>;
|
| 449 |
+
convertOffsetParentRelativeRectToViewportRelativeRect?: ((args: {
|
| 450 |
+
elements?: Elements | undefined;
|
| 451 |
+
rect: Rect;
|
| 452 |
+
offsetParent: any;
|
| 453 |
+
strategy: Strategy;
|
| 454 |
+
}) => Promisable<Rect>) | undefined;
|
| 455 |
+
getOffsetParent?: ((element: any) => Promisable<any>) | undefined;
|
| 456 |
+
isElement?: ((value: any) => Promisable<boolean>) | undefined;
|
| 457 |
+
getDocumentElement?: ((element: any) => Promisable<any>) | undefined;
|
| 458 |
+
getClientRects?: ((element: any) => Promisable<Array<ClientRectObject>>) | undefined;
|
| 459 |
+
isRTL?: ((element: any) => Promisable<boolean>) | undefined;
|
| 460 |
+
getScale?: ((element: any) => Promisable<{
|
| 461 |
+
x: number;
|
| 462 |
+
y: number;
|
| 463 |
+
}>) | undefined;
|
| 464 |
+
detectOverflow?: typeof detectOverflow | undefined;
|
| 465 |
+
}
|
| 466 |
+
|
| 467 |
+
declare type Promisable<T> = T | Promise<T>;
|
| 468 |
+
|
| 469 |
+
export { Rect }
|
| 470 |
+
|
| 471 |
+
export { rectToClientRect }
|
| 472 |
+
|
| 473 |
+
export declare type ReferenceElement = any;
|
| 474 |
+
|
| 475 |
+
export declare type RootBoundary = 'viewport' | 'layoutViewport' | 'document' | Rect;
|
| 476 |
+
|
| 477 |
+
/**
|
| 478 |
+
* Optimizes the visibility of the floating element by shifting it in order to
|
| 479 |
+
* keep it in view when it will overflow the clipping boundary.
|
| 480 |
+
* @see https://floating-ui.com/docs/shift
|
| 481 |
+
*/
|
| 482 |
+
export declare const shift: (options?: ShiftOptions | Derivable<ShiftOptions>) => Middleware;
|
| 483 |
+
|
| 484 |
+
export declare interface ShiftOptions extends DetectOverflowOptions {
|
| 485 |
+
/**
|
| 486 |
+
* The axis that runs along the alignment of the floating element. Determines
|
| 487 |
+
* whether overflow along this axis is checked to perform shifting.
|
| 488 |
+
* @default true
|
| 489 |
+
*/
|
| 490 |
+
mainAxis?: boolean | undefined;
|
| 491 |
+
/**
|
| 492 |
+
* The axis that runs along the side of the floating element. Determines
|
| 493 |
+
* whether overflow along this axis is checked to perform shifting.
|
| 494 |
+
* @default false
|
| 495 |
+
*/
|
| 496 |
+
crossAxis?: boolean | undefined;
|
| 497 |
+
/**
|
| 498 |
+
* Accepts a function that limits the shifting done in order to prevent
|
| 499 |
+
* detachment.
|
| 500 |
+
*/
|
| 501 |
+
limiter?: {
|
| 502 |
+
fn: (state: MiddlewareState) => Coords;
|
| 503 |
+
options?: any;
|
| 504 |
+
} | undefined;
|
| 505 |
+
}
|
| 506 |
+
|
| 507 |
+
export { Side }
|
| 508 |
+
|
| 509 |
+
export { SideObject }
|
| 510 |
+
|
| 511 |
+
/**
|
| 512 |
+
* Provides data that allows you to change the size of the floating element —
|
| 513 |
+
* for instance, prevent it from overflowing the clipping boundary or match the
|
| 514 |
+
* width of the reference element.
|
| 515 |
+
* @see https://floating-ui.com/docs/size
|
| 516 |
+
*/
|
| 517 |
+
export declare const size: (options?: SizeOptions | Derivable<SizeOptions>) => Middleware;
|
| 518 |
+
|
| 519 |
+
export declare interface SizeOptions extends DetectOverflowOptions {
|
| 520 |
+
/**
|
| 521 |
+
* Function that is called to perform style mutations to the floating element
|
| 522 |
+
* to change its size.
|
| 523 |
+
* @default undefined
|
| 524 |
+
*/
|
| 525 |
+
apply?: BivariantCallback<(args: MiddlewareState & {
|
| 526 |
+
availableWidth: number;
|
| 527 |
+
availableHeight: number;
|
| 528 |
+
}) => void | Promise<void>> | undefined;
|
| 529 |
+
}
|
| 530 |
+
|
| 531 |
+
export { Strategy }
|
| 532 |
+
|
| 533 |
+
export { VirtualElement }
|
| 534 |
+
|
| 535 |
+
export { }
|
e-commerce/node_modules/@floating-ui/core/dist/floating-ui.core.esm.js
ADDED
|
@@ -0,0 +1,1038 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { getSideAxis, getAlignmentAxis, getAxisLength, getSide, getAlignment, evaluate, getPaddingObject, rectToClientRect, min, clamp, placements, getAlignmentSides, getOppositeAlignmentPlacement, getOppositePlacement, getExpandedPlacements, getOppositeAxisPlacements, sides, max, getOppositeAxis } from '@floating-ui/utils';
|
| 2 |
+
export { rectToClientRect } from '@floating-ui/utils';
|
| 3 |
+
|
| 4 |
+
function computeCoordsFromPlacement(_ref, placement, rtl) {
|
| 5 |
+
let {
|
| 6 |
+
reference,
|
| 7 |
+
floating
|
| 8 |
+
} = _ref;
|
| 9 |
+
const sideAxis = getSideAxis(placement);
|
| 10 |
+
const alignmentAxis = getAlignmentAxis(placement);
|
| 11 |
+
const alignLength = getAxisLength(alignmentAxis);
|
| 12 |
+
const side = getSide(placement);
|
| 13 |
+
const isVertical = sideAxis === 'y';
|
| 14 |
+
const commonX = reference.x + reference.width / 2 - floating.width / 2;
|
| 15 |
+
const commonY = reference.y + reference.height / 2 - floating.height / 2;
|
| 16 |
+
const commonAlign = reference[alignLength] / 2 - floating[alignLength] / 2;
|
| 17 |
+
let coords;
|
| 18 |
+
switch (side) {
|
| 19 |
+
case 'top':
|
| 20 |
+
coords = {
|
| 21 |
+
x: commonX,
|
| 22 |
+
y: reference.y - floating.height
|
| 23 |
+
};
|
| 24 |
+
break;
|
| 25 |
+
case 'bottom':
|
| 26 |
+
coords = {
|
| 27 |
+
x: commonX,
|
| 28 |
+
y: reference.y + reference.height
|
| 29 |
+
};
|
| 30 |
+
break;
|
| 31 |
+
case 'right':
|
| 32 |
+
coords = {
|
| 33 |
+
x: reference.x + reference.width,
|
| 34 |
+
y: commonY
|
| 35 |
+
};
|
| 36 |
+
break;
|
| 37 |
+
case 'left':
|
| 38 |
+
coords = {
|
| 39 |
+
x: reference.x - floating.width,
|
| 40 |
+
y: commonY
|
| 41 |
+
};
|
| 42 |
+
break;
|
| 43 |
+
default:
|
| 44 |
+
coords = {
|
| 45 |
+
x: reference.x,
|
| 46 |
+
y: reference.y
|
| 47 |
+
};
|
| 48 |
+
}
|
| 49 |
+
const alignment = getAlignment(placement);
|
| 50 |
+
if (alignment) {
|
| 51 |
+
coords[alignmentAxis] += commonAlign * (alignment === 'end' ? 1 : -1) * (rtl && isVertical ? -1 : 1);
|
| 52 |
+
}
|
| 53 |
+
return coords;
|
| 54 |
+
}
|
| 55 |
+
|
| 56 |
+
/**
|
| 57 |
+
* Resolves with an object of overflow side offsets that determine how much the
|
| 58 |
+
* element is overflowing a given clipping boundary on each side.
|
| 59 |
+
* - positive = overflowing the boundary by that number of pixels
|
| 60 |
+
* - negative = how many pixels left before it will overflow
|
| 61 |
+
* - 0 = lies flush with the boundary
|
| 62 |
+
* @see https://floating-ui.com/docs/detectOverflow
|
| 63 |
+
*/
|
| 64 |
+
async function detectOverflow(state, options) {
|
| 65 |
+
var _await$platform$isEle;
|
| 66 |
+
if (options === void 0) {
|
| 67 |
+
options = {};
|
| 68 |
+
}
|
| 69 |
+
const {
|
| 70 |
+
x,
|
| 71 |
+
y,
|
| 72 |
+
platform,
|
| 73 |
+
rects,
|
| 74 |
+
elements,
|
| 75 |
+
strategy
|
| 76 |
+
} = state;
|
| 77 |
+
const {
|
| 78 |
+
boundary = 'clippingAncestors',
|
| 79 |
+
rootBoundary = 'viewport',
|
| 80 |
+
elementContext = 'floating',
|
| 81 |
+
altBoundary = false,
|
| 82 |
+
padding = 0
|
| 83 |
+
} = evaluate(options, state);
|
| 84 |
+
const paddingObject = getPaddingObject(padding);
|
| 85 |
+
const altContext = elementContext === 'floating' ? 'reference' : 'floating';
|
| 86 |
+
const element = elements[altBoundary ? altContext : elementContext];
|
| 87 |
+
const clippingClientRect = rectToClientRect(await platform.getClippingRect({
|
| 88 |
+
element: ((_await$platform$isEle = await (platform.isElement == null ? void 0 : platform.isElement(element))) != null ? _await$platform$isEle : true) ? element : element.contextElement || (await (platform.getDocumentElement == null ? void 0 : platform.getDocumentElement(elements.floating))),
|
| 89 |
+
boundary,
|
| 90 |
+
rootBoundary,
|
| 91 |
+
strategy
|
| 92 |
+
}));
|
| 93 |
+
const rect = elementContext === 'floating' ? {
|
| 94 |
+
x,
|
| 95 |
+
y,
|
| 96 |
+
width: rects.floating.width,
|
| 97 |
+
height: rects.floating.height
|
| 98 |
+
} : rects.reference;
|
| 99 |
+
const offsetParent = await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(elements.floating));
|
| 100 |
+
const offsetScale = (await (platform.isElement == null ? void 0 : platform.isElement(offsetParent))) && (await (platform.getScale == null ? void 0 : platform.getScale(offsetParent))) || {
|
| 101 |
+
x: 1,
|
| 102 |
+
y: 1
|
| 103 |
+
};
|
| 104 |
+
const elementClientRect = rectToClientRect(platform.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform.convertOffsetParentRelativeRectToViewportRelativeRect({
|
| 105 |
+
elements,
|
| 106 |
+
rect,
|
| 107 |
+
offsetParent,
|
| 108 |
+
strategy
|
| 109 |
+
}) : rect);
|
| 110 |
+
return {
|
| 111 |
+
top: (clippingClientRect.top - elementClientRect.top + paddingObject.top) / offsetScale.y,
|
| 112 |
+
bottom: (elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom) / offsetScale.y,
|
| 113 |
+
left: (clippingClientRect.left - elementClientRect.left + paddingObject.left) / offsetScale.x,
|
| 114 |
+
right: (elementClientRect.right - clippingClientRect.right + paddingObject.right) / offsetScale.x
|
| 115 |
+
};
|
| 116 |
+
}
|
| 117 |
+
|
| 118 |
+
// Maximum number of resets that can occur before bailing to avoid infinite reset loops.
|
| 119 |
+
const MAX_RESET_COUNT = 50;
|
| 120 |
+
|
| 121 |
+
/**
|
| 122 |
+
* Computes the `x` and `y` coordinates that will place the floating element
|
| 123 |
+
* next to a given reference element.
|
| 124 |
+
*
|
| 125 |
+
* This export does not have any `platform` interface logic. You will need to
|
| 126 |
+
* write one for the platform you are using Floating UI with.
|
| 127 |
+
*/
|
| 128 |
+
const computePosition = async (reference, floating, config) => {
|
| 129 |
+
const {
|
| 130 |
+
placement = 'bottom',
|
| 131 |
+
strategy = 'absolute',
|
| 132 |
+
middleware = [],
|
| 133 |
+
platform
|
| 134 |
+
} = config;
|
| 135 |
+
const platformWithDetectOverflow = platform.detectOverflow ? platform : {
|
| 136 |
+
...platform,
|
| 137 |
+
detectOverflow
|
| 138 |
+
};
|
| 139 |
+
const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(floating));
|
| 140 |
+
let rects = await platform.getElementRects({
|
| 141 |
+
reference,
|
| 142 |
+
floating,
|
| 143 |
+
strategy
|
| 144 |
+
});
|
| 145 |
+
let {
|
| 146 |
+
x,
|
| 147 |
+
y
|
| 148 |
+
} = computeCoordsFromPlacement(rects, placement, rtl);
|
| 149 |
+
let statefulPlacement = placement;
|
| 150 |
+
let resetCount = 0;
|
| 151 |
+
const middlewareData = {};
|
| 152 |
+
for (let i = 0; i < middleware.length; i++) {
|
| 153 |
+
const currentMiddleware = middleware[i];
|
| 154 |
+
if (!currentMiddleware) {
|
| 155 |
+
continue;
|
| 156 |
+
}
|
| 157 |
+
const {
|
| 158 |
+
name,
|
| 159 |
+
fn
|
| 160 |
+
} = currentMiddleware;
|
| 161 |
+
const {
|
| 162 |
+
x: nextX,
|
| 163 |
+
y: nextY,
|
| 164 |
+
data,
|
| 165 |
+
reset
|
| 166 |
+
} = await fn({
|
| 167 |
+
x,
|
| 168 |
+
y,
|
| 169 |
+
initialPlacement: placement,
|
| 170 |
+
placement: statefulPlacement,
|
| 171 |
+
strategy,
|
| 172 |
+
middlewareData,
|
| 173 |
+
rects,
|
| 174 |
+
platform: platformWithDetectOverflow,
|
| 175 |
+
elements: {
|
| 176 |
+
reference,
|
| 177 |
+
floating
|
| 178 |
+
}
|
| 179 |
+
});
|
| 180 |
+
x = nextX != null ? nextX : x;
|
| 181 |
+
y = nextY != null ? nextY : y;
|
| 182 |
+
middlewareData[name] = {
|
| 183 |
+
...middlewareData[name],
|
| 184 |
+
...data
|
| 185 |
+
};
|
| 186 |
+
if (reset && resetCount < MAX_RESET_COUNT) {
|
| 187 |
+
resetCount++;
|
| 188 |
+
if (typeof reset === 'object') {
|
| 189 |
+
if (reset.placement) {
|
| 190 |
+
statefulPlacement = reset.placement;
|
| 191 |
+
}
|
| 192 |
+
if (reset.rects) {
|
| 193 |
+
rects = reset.rects === true ? await platform.getElementRects({
|
| 194 |
+
reference,
|
| 195 |
+
floating,
|
| 196 |
+
strategy
|
| 197 |
+
}) : reset.rects;
|
| 198 |
+
}
|
| 199 |
+
({
|
| 200 |
+
x,
|
| 201 |
+
y
|
| 202 |
+
} = computeCoordsFromPlacement(rects, statefulPlacement, rtl));
|
| 203 |
+
}
|
| 204 |
+
i = -1;
|
| 205 |
+
}
|
| 206 |
+
}
|
| 207 |
+
return {
|
| 208 |
+
x,
|
| 209 |
+
y,
|
| 210 |
+
placement: statefulPlacement,
|
| 211 |
+
strategy,
|
| 212 |
+
middlewareData
|
| 213 |
+
};
|
| 214 |
+
};
|
| 215 |
+
|
| 216 |
+
/**
|
| 217 |
+
* Provides data to position an inner element of the floating element so that it
|
| 218 |
+
* appears centered to the reference element.
|
| 219 |
+
* @see https://floating-ui.com/docs/arrow
|
| 220 |
+
*/
|
| 221 |
+
const arrow = options => ({
|
| 222 |
+
name: 'arrow',
|
| 223 |
+
options,
|
| 224 |
+
async fn(state) {
|
| 225 |
+
const {
|
| 226 |
+
x,
|
| 227 |
+
y,
|
| 228 |
+
placement,
|
| 229 |
+
rects,
|
| 230 |
+
platform,
|
| 231 |
+
elements,
|
| 232 |
+
middlewareData
|
| 233 |
+
} = state;
|
| 234 |
+
// Since `element` is required, we don't Partial<> the type.
|
| 235 |
+
const {
|
| 236 |
+
element,
|
| 237 |
+
padding = 0
|
| 238 |
+
} = evaluate(options, state) || {};
|
| 239 |
+
if (element == null) {
|
| 240 |
+
return {};
|
| 241 |
+
}
|
| 242 |
+
const paddingObject = getPaddingObject(padding);
|
| 243 |
+
const coords = {
|
| 244 |
+
x,
|
| 245 |
+
y
|
| 246 |
+
};
|
| 247 |
+
const axis = getAlignmentAxis(placement);
|
| 248 |
+
const length = getAxisLength(axis);
|
| 249 |
+
const arrowDimensions = await platform.getDimensions(element);
|
| 250 |
+
const isYAxis = axis === 'y';
|
| 251 |
+
const minProp = isYAxis ? 'top' : 'left';
|
| 252 |
+
const maxProp = isYAxis ? 'bottom' : 'right';
|
| 253 |
+
const clientProp = isYAxis ? 'clientHeight' : 'clientWidth';
|
| 254 |
+
const endDiff = rects.reference[length] + rects.reference[axis] - coords[axis] - rects.floating[length];
|
| 255 |
+
const startDiff = coords[axis] - rects.reference[axis];
|
| 256 |
+
const arrowOffsetParent = await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(element));
|
| 257 |
+
let clientSize = arrowOffsetParent ? arrowOffsetParent[clientProp] : 0;
|
| 258 |
+
|
| 259 |
+
// DOM platform can return `window` as the `offsetParent`.
|
| 260 |
+
if (!clientSize || !(await (platform.isElement == null ? void 0 : platform.isElement(arrowOffsetParent)))) {
|
| 261 |
+
clientSize = elements.floating[clientProp] || rects.floating[length];
|
| 262 |
+
}
|
| 263 |
+
const centerToReference = endDiff / 2 - startDiff / 2;
|
| 264 |
+
|
| 265 |
+
// If the padding is large enough that it causes the arrow to no longer be
|
| 266 |
+
// centered, modify the padding so that it is centered.
|
| 267 |
+
const largestPossiblePadding = clientSize / 2 - arrowDimensions[length] / 2 - 1;
|
| 268 |
+
const minPadding = min(paddingObject[minProp], largestPossiblePadding);
|
| 269 |
+
const maxPadding = min(paddingObject[maxProp], largestPossiblePadding);
|
| 270 |
+
|
| 271 |
+
// Make sure the arrow doesn't overflow the floating element if the center
|
| 272 |
+
// point is outside the floating element's bounds.
|
| 273 |
+
const max = clientSize - arrowDimensions[length] - maxPadding;
|
| 274 |
+
const center = clientSize / 2 - arrowDimensions[length] / 2 + centerToReference;
|
| 275 |
+
const offset = clamp(minPadding, center, max);
|
| 276 |
+
|
| 277 |
+
// If the reference is small enough that the arrow's padding causes it to
|
| 278 |
+
// to point to nothing for an aligned placement, adjust the offset of the
|
| 279 |
+
// floating element itself. To ensure `shift()` continues to take action,
|
| 280 |
+
// a single reset is performed when this is true.
|
| 281 |
+
const shouldAddOffset = !middlewareData.arrow && getAlignment(placement) != null && center !== offset && rects.reference[length] / 2 - (center < minPadding ? minPadding : maxPadding) - arrowDimensions[length] / 2 < 0;
|
| 282 |
+
const alignmentOffset = shouldAddOffset ? center < minPadding ? center - minPadding : center - max : 0;
|
| 283 |
+
return {
|
| 284 |
+
[axis]: coords[axis] + alignmentOffset,
|
| 285 |
+
data: {
|
| 286 |
+
[axis]: offset,
|
| 287 |
+
centerOffset: center - offset - alignmentOffset,
|
| 288 |
+
...(shouldAddOffset && {
|
| 289 |
+
alignmentOffset
|
| 290 |
+
})
|
| 291 |
+
},
|
| 292 |
+
reset: shouldAddOffset
|
| 293 |
+
};
|
| 294 |
+
}
|
| 295 |
+
});
|
| 296 |
+
|
| 297 |
+
function getPlacementList(alignment, autoAlignment, allowedPlacements) {
|
| 298 |
+
const allowedPlacementsSortedByAlignment = alignment ? [...allowedPlacements.filter(placement => getAlignment(placement) === alignment), ...allowedPlacements.filter(placement => getAlignment(placement) !== alignment)] : allowedPlacements.filter(placement => getSide(placement) === placement);
|
| 299 |
+
return allowedPlacementsSortedByAlignment.filter(placement => {
|
| 300 |
+
if (alignment) {
|
| 301 |
+
return getAlignment(placement) === alignment || (autoAlignment ? getOppositeAlignmentPlacement(placement) !== placement : false);
|
| 302 |
+
}
|
| 303 |
+
return true;
|
| 304 |
+
});
|
| 305 |
+
}
|
| 306 |
+
/**
|
| 307 |
+
* Optimizes the visibility of the floating element by choosing the placement
|
| 308 |
+
* that has the most space available automatically, without needing to specify a
|
| 309 |
+
* preferred placement. Alternative to `flip`.
|
| 310 |
+
* @see https://floating-ui.com/docs/autoPlacement
|
| 311 |
+
*/
|
| 312 |
+
const autoPlacement = function (options) {
|
| 313 |
+
if (options === void 0) {
|
| 314 |
+
options = {};
|
| 315 |
+
}
|
| 316 |
+
return {
|
| 317 |
+
name: 'autoPlacement',
|
| 318 |
+
options,
|
| 319 |
+
async fn(state) {
|
| 320 |
+
var _middlewareData$autoP, _middlewareData$autoP2, _placementsThatFitOnE;
|
| 321 |
+
const {
|
| 322 |
+
rects,
|
| 323 |
+
middlewareData,
|
| 324 |
+
placement,
|
| 325 |
+
platform,
|
| 326 |
+
elements
|
| 327 |
+
} = state;
|
| 328 |
+
const {
|
| 329 |
+
crossAxis = false,
|
| 330 |
+
alignment,
|
| 331 |
+
allowedPlacements = placements,
|
| 332 |
+
autoAlignment = true,
|
| 333 |
+
...detectOverflowOptions
|
| 334 |
+
} = evaluate(options, state);
|
| 335 |
+
const placements$1 = alignment !== undefined || allowedPlacements === placements ? getPlacementList(alignment || null, autoAlignment, allowedPlacements) : allowedPlacements;
|
| 336 |
+
const currentIndex = ((_middlewareData$autoP = middlewareData.autoPlacement) == null ? void 0 : _middlewareData$autoP.index) || 0;
|
| 337 |
+
const currentPlacement = placements$1[currentIndex];
|
| 338 |
+
if (currentPlacement == null) {
|
| 339 |
+
return {};
|
| 340 |
+
}
|
| 341 |
+
|
| 342 |
+
// Make `computeCoords` start from the right place.
|
| 343 |
+
if (placement !== currentPlacement) {
|
| 344 |
+
return {
|
| 345 |
+
reset: {
|
| 346 |
+
placement: placements$1[0]
|
| 347 |
+
}
|
| 348 |
+
};
|
| 349 |
+
}
|
| 350 |
+
const overflow = await platform.detectOverflow(state, detectOverflowOptions);
|
| 351 |
+
const alignmentSides = getAlignmentSides(currentPlacement, rects, await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating)));
|
| 352 |
+
const currentOverflows = [overflow[getSide(currentPlacement)], overflow[alignmentSides[0]], overflow[alignmentSides[1]]];
|
| 353 |
+
const allOverflows = [...(((_middlewareData$autoP2 = middlewareData.autoPlacement) == null ? void 0 : _middlewareData$autoP2.overflows) || []), {
|
| 354 |
+
placement: currentPlacement,
|
| 355 |
+
overflows: currentOverflows
|
| 356 |
+
}];
|
| 357 |
+
const nextPlacement = placements$1[currentIndex + 1];
|
| 358 |
+
|
| 359 |
+
// There are more placements to check.
|
| 360 |
+
if (nextPlacement) {
|
| 361 |
+
return {
|
| 362 |
+
data: {
|
| 363 |
+
index: currentIndex + 1,
|
| 364 |
+
overflows: allOverflows
|
| 365 |
+
},
|
| 366 |
+
reset: {
|
| 367 |
+
placement: nextPlacement
|
| 368 |
+
}
|
| 369 |
+
};
|
| 370 |
+
}
|
| 371 |
+
const placementsSortedByMostSpace = allOverflows.map(d => {
|
| 372 |
+
const alignment = getAlignment(d.placement);
|
| 373 |
+
return [d.placement, alignment && crossAxis ?
|
| 374 |
+
// Check along the mainAxis and main crossAxis side.
|
| 375 |
+
d.overflows.slice(0, 2).reduce((acc, v) => acc + v, 0) :
|
| 376 |
+
// Check only the mainAxis.
|
| 377 |
+
d.overflows[0], d.overflows];
|
| 378 |
+
}).sort((a, b) => a[1] - b[1]);
|
| 379 |
+
const placementsThatFitOnEachSide = placementsSortedByMostSpace.filter(d => d[2].slice(0,
|
| 380 |
+
// Aligned placements should not check their opposite crossAxis
|
| 381 |
+
// side.
|
| 382 |
+
getAlignment(d[0]) ? 2 : 3).every(v => v <= 0));
|
| 383 |
+
const resetPlacement = ((_placementsThatFitOnE = placementsThatFitOnEachSide[0]) == null ? void 0 : _placementsThatFitOnE[0]) || placementsSortedByMostSpace[0][0];
|
| 384 |
+
if (resetPlacement !== placement) {
|
| 385 |
+
return {
|
| 386 |
+
data: {
|
| 387 |
+
index: currentIndex + 1,
|
| 388 |
+
overflows: allOverflows
|
| 389 |
+
},
|
| 390 |
+
reset: {
|
| 391 |
+
placement: resetPlacement
|
| 392 |
+
}
|
| 393 |
+
};
|
| 394 |
+
}
|
| 395 |
+
return {};
|
| 396 |
+
}
|
| 397 |
+
};
|
| 398 |
+
};
|
| 399 |
+
|
| 400 |
+
/**
|
| 401 |
+
* Optimizes the visibility of the floating element by flipping the `placement`
|
| 402 |
+
* in order to keep it in view when the preferred placement(s) will overflow the
|
| 403 |
+
* clipping boundary. Alternative to `autoPlacement`.
|
| 404 |
+
* @see https://floating-ui.com/docs/flip
|
| 405 |
+
*/
|
| 406 |
+
const flip = function (options) {
|
| 407 |
+
if (options === void 0) {
|
| 408 |
+
options = {};
|
| 409 |
+
}
|
| 410 |
+
return {
|
| 411 |
+
name: 'flip',
|
| 412 |
+
options,
|
| 413 |
+
async fn(state) {
|
| 414 |
+
var _middlewareData$arrow, _middlewareData$flip;
|
| 415 |
+
const {
|
| 416 |
+
placement,
|
| 417 |
+
middlewareData,
|
| 418 |
+
rects,
|
| 419 |
+
initialPlacement,
|
| 420 |
+
platform,
|
| 421 |
+
elements
|
| 422 |
+
} = state;
|
| 423 |
+
const {
|
| 424 |
+
mainAxis: checkMainAxis = true,
|
| 425 |
+
crossAxis: checkCrossAxis = true,
|
| 426 |
+
fallbackPlacements: specifiedFallbackPlacements,
|
| 427 |
+
fallbackStrategy = 'bestFit',
|
| 428 |
+
fallbackAxisSideDirection = 'none',
|
| 429 |
+
flipAlignment = true,
|
| 430 |
+
...detectOverflowOptions
|
| 431 |
+
} = evaluate(options, state);
|
| 432 |
+
|
| 433 |
+
// If a reset by the arrow was caused due to an alignment offset being
|
| 434 |
+
// added, we should skip any logic now since `flip()` has already done its
|
| 435 |
+
// work.
|
| 436 |
+
// https://github.com/floating-ui/floating-ui/issues/2549#issuecomment-1719601643
|
| 437 |
+
if ((_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
|
| 438 |
+
return {};
|
| 439 |
+
}
|
| 440 |
+
const side = getSide(placement);
|
| 441 |
+
const initialSideAxis = getSideAxis(initialPlacement);
|
| 442 |
+
const isBasePlacement = getSide(initialPlacement) === initialPlacement;
|
| 443 |
+
const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating));
|
| 444 |
+
const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement(initialPlacement)] : getExpandedPlacements(initialPlacement));
|
| 445 |
+
const hasFallbackAxisSideDirection = fallbackAxisSideDirection !== 'none';
|
| 446 |
+
if (!specifiedFallbackPlacements && hasFallbackAxisSideDirection) {
|
| 447 |
+
fallbackPlacements.push(...getOppositeAxisPlacements(initialPlacement, flipAlignment, fallbackAxisSideDirection, rtl));
|
| 448 |
+
}
|
| 449 |
+
const placements = [initialPlacement, ...fallbackPlacements];
|
| 450 |
+
const overflow = await platform.detectOverflow(state, detectOverflowOptions);
|
| 451 |
+
const overflows = [];
|
| 452 |
+
let overflowsData = ((_middlewareData$flip = middlewareData.flip) == null ? void 0 : _middlewareData$flip.overflows) || [];
|
| 453 |
+
if (checkMainAxis) {
|
| 454 |
+
overflows.push(overflow[side]);
|
| 455 |
+
}
|
| 456 |
+
if (checkCrossAxis) {
|
| 457 |
+
const sides = getAlignmentSides(placement, rects, rtl);
|
| 458 |
+
overflows.push(overflow[sides[0]], overflow[sides[1]]);
|
| 459 |
+
}
|
| 460 |
+
overflowsData = [...overflowsData, {
|
| 461 |
+
placement,
|
| 462 |
+
overflows
|
| 463 |
+
}];
|
| 464 |
+
|
| 465 |
+
// One or more sides is overflowing.
|
| 466 |
+
if (!overflows.every(side => side <= 0)) {
|
| 467 |
+
var _middlewareData$flip2, _overflowsData$filter;
|
| 468 |
+
const nextIndex = (((_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.index) || 0) + 1;
|
| 469 |
+
const nextPlacement = placements[nextIndex];
|
| 470 |
+
if (nextPlacement) {
|
| 471 |
+
const ignoreCrossAxisOverflow = checkCrossAxis === 'alignment' ? initialSideAxis !== getSideAxis(nextPlacement) : false;
|
| 472 |
+
if (!ignoreCrossAxisOverflow ||
|
| 473 |
+
// We leave the current main axis only if every placement on that axis
|
| 474 |
+
// overflows the main axis.
|
| 475 |
+
overflowsData.every(d => getSideAxis(d.placement) === initialSideAxis ? d.overflows[0] > 0 : true)) {
|
| 476 |
+
// Try next placement and re-run the lifecycle.
|
| 477 |
+
return {
|
| 478 |
+
data: {
|
| 479 |
+
index: nextIndex,
|
| 480 |
+
overflows: overflowsData
|
| 481 |
+
},
|
| 482 |
+
reset: {
|
| 483 |
+
placement: nextPlacement
|
| 484 |
+
}
|
| 485 |
+
};
|
| 486 |
+
}
|
| 487 |
+
}
|
| 488 |
+
|
| 489 |
+
// First, find the candidates that fit on the mainAxis side of overflow,
|
| 490 |
+
// then find the placement that fits the best on the main crossAxis side.
|
| 491 |
+
let resetPlacement = (_overflowsData$filter = overflowsData.filter(d => d.overflows[0] <= 0).sort((a, b) => a.overflows[1] - b.overflows[1])[0]) == null ? void 0 : _overflowsData$filter.placement;
|
| 492 |
+
|
| 493 |
+
// Otherwise fallback.
|
| 494 |
+
if (!resetPlacement) {
|
| 495 |
+
switch (fallbackStrategy) {
|
| 496 |
+
case 'bestFit':
|
| 497 |
+
{
|
| 498 |
+
var _overflowsData$filter2;
|
| 499 |
+
const placement = (_overflowsData$filter2 = overflowsData.filter(d => {
|
| 500 |
+
if (hasFallbackAxisSideDirection) {
|
| 501 |
+
const currentSideAxis = getSideAxis(d.placement);
|
| 502 |
+
return currentSideAxis === initialSideAxis ||
|
| 503 |
+
// Create a bias to the `y` side axis due to horizontal
|
| 504 |
+
// reading directions favoring greater width.
|
| 505 |
+
currentSideAxis === 'y';
|
| 506 |
+
}
|
| 507 |
+
return true;
|
| 508 |
+
}).map(d => [d.placement, d.overflows.filter(overflow => overflow > 0).reduce((acc, overflow) => acc + overflow, 0)]).sort((a, b) => a[1] - b[1])[0]) == null ? void 0 : _overflowsData$filter2[0];
|
| 509 |
+
if (placement) {
|
| 510 |
+
resetPlacement = placement;
|
| 511 |
+
}
|
| 512 |
+
break;
|
| 513 |
+
}
|
| 514 |
+
case 'initialPlacement':
|
| 515 |
+
resetPlacement = initialPlacement;
|
| 516 |
+
break;
|
| 517 |
+
}
|
| 518 |
+
}
|
| 519 |
+
if (placement !== resetPlacement) {
|
| 520 |
+
return {
|
| 521 |
+
reset: {
|
| 522 |
+
placement: resetPlacement
|
| 523 |
+
}
|
| 524 |
+
};
|
| 525 |
+
}
|
| 526 |
+
}
|
| 527 |
+
return {};
|
| 528 |
+
}
|
| 529 |
+
};
|
| 530 |
+
};
|
| 531 |
+
|
| 532 |
+
function getSideOffsets(overflow, rect) {
|
| 533 |
+
return {
|
| 534 |
+
top: overflow.top - rect.height,
|
| 535 |
+
right: overflow.right - rect.width,
|
| 536 |
+
bottom: overflow.bottom - rect.height,
|
| 537 |
+
left: overflow.left - rect.width
|
| 538 |
+
};
|
| 539 |
+
}
|
| 540 |
+
function isAnySideFullyClipped(overflow) {
|
| 541 |
+
return sides.some(side => overflow[side] >= 0);
|
| 542 |
+
}
|
| 543 |
+
/**
|
| 544 |
+
* Provides data to hide the floating element in applicable situations, such as
|
| 545 |
+
* when it is not in the same clipping context as the reference element.
|
| 546 |
+
* @see https://floating-ui.com/docs/hide
|
| 547 |
+
*/
|
| 548 |
+
const hide = function (options) {
|
| 549 |
+
if (options === void 0) {
|
| 550 |
+
options = {};
|
| 551 |
+
}
|
| 552 |
+
return {
|
| 553 |
+
name: 'hide',
|
| 554 |
+
options,
|
| 555 |
+
async fn(state) {
|
| 556 |
+
const {
|
| 557 |
+
rects,
|
| 558 |
+
platform
|
| 559 |
+
} = state;
|
| 560 |
+
const {
|
| 561 |
+
strategy = 'referenceHidden',
|
| 562 |
+
...detectOverflowOptions
|
| 563 |
+
} = evaluate(options, state);
|
| 564 |
+
switch (strategy) {
|
| 565 |
+
case 'referenceHidden':
|
| 566 |
+
{
|
| 567 |
+
const overflow = await platform.detectOverflow(state, {
|
| 568 |
+
...detectOverflowOptions,
|
| 569 |
+
elementContext: 'reference'
|
| 570 |
+
});
|
| 571 |
+
const offsets = getSideOffsets(overflow, rects.reference);
|
| 572 |
+
return {
|
| 573 |
+
data: {
|
| 574 |
+
referenceHiddenOffsets: offsets,
|
| 575 |
+
referenceHidden: isAnySideFullyClipped(offsets)
|
| 576 |
+
}
|
| 577 |
+
};
|
| 578 |
+
}
|
| 579 |
+
case 'escaped':
|
| 580 |
+
{
|
| 581 |
+
const overflow = await platform.detectOverflow(state, {
|
| 582 |
+
...detectOverflowOptions,
|
| 583 |
+
altBoundary: true
|
| 584 |
+
});
|
| 585 |
+
const offsets = getSideOffsets(overflow, rects.floating);
|
| 586 |
+
return {
|
| 587 |
+
data: {
|
| 588 |
+
escapedOffsets: offsets,
|
| 589 |
+
escaped: isAnySideFullyClipped(offsets)
|
| 590 |
+
}
|
| 591 |
+
};
|
| 592 |
+
}
|
| 593 |
+
default:
|
| 594 |
+
{
|
| 595 |
+
return {};
|
| 596 |
+
}
|
| 597 |
+
}
|
| 598 |
+
}
|
| 599 |
+
};
|
| 600 |
+
};
|
| 601 |
+
|
| 602 |
+
function getBoundingRect(rects) {
|
| 603 |
+
const minX = min(...rects.map(rect => rect.left));
|
| 604 |
+
const minY = min(...rects.map(rect => rect.top));
|
| 605 |
+
const maxX = max(...rects.map(rect => rect.right));
|
| 606 |
+
const maxY = max(...rects.map(rect => rect.bottom));
|
| 607 |
+
return {
|
| 608 |
+
x: minX,
|
| 609 |
+
y: minY,
|
| 610 |
+
width: maxX - minX,
|
| 611 |
+
height: maxY - minY
|
| 612 |
+
};
|
| 613 |
+
}
|
| 614 |
+
function getRectsByLine(rects) {
|
| 615 |
+
const sortedRects = rects.slice().sort((a, b) => a.y - b.y);
|
| 616 |
+
const groups = [];
|
| 617 |
+
let prevRect = null;
|
| 618 |
+
for (let i = 0; i < sortedRects.length; i++) {
|
| 619 |
+
const rect = sortedRects[i];
|
| 620 |
+
if (!prevRect || rect.y - prevRect.y > prevRect.height / 2) {
|
| 621 |
+
groups.push([rect]);
|
| 622 |
+
} else {
|
| 623 |
+
groups[groups.length - 1].push(rect);
|
| 624 |
+
}
|
| 625 |
+
prevRect = rect;
|
| 626 |
+
}
|
| 627 |
+
return groups.map(rect => rectToClientRect(getBoundingRect(rect)));
|
| 628 |
+
}
|
| 629 |
+
/**
|
| 630 |
+
* Provides improved positioning for inline reference elements that can span
|
| 631 |
+
* over multiple lines, such as hyperlinks or range selections.
|
| 632 |
+
* @see https://floating-ui.com/docs/inline
|
| 633 |
+
*/
|
| 634 |
+
const inline = function (options) {
|
| 635 |
+
if (options === void 0) {
|
| 636 |
+
options = {};
|
| 637 |
+
}
|
| 638 |
+
return {
|
| 639 |
+
name: 'inline',
|
| 640 |
+
options,
|
| 641 |
+
async fn(state) {
|
| 642 |
+
const {
|
| 643 |
+
placement,
|
| 644 |
+
elements,
|
| 645 |
+
rects,
|
| 646 |
+
platform,
|
| 647 |
+
strategy
|
| 648 |
+
} = state;
|
| 649 |
+
// A MouseEvent's client{X,Y} coords can be up to 2 pixels off a
|
| 650 |
+
// ClientRect's bounds, despite the event listener being triggered. A
|
| 651 |
+
// padding of 2 seems to handle this issue.
|
| 652 |
+
const {
|
| 653 |
+
padding = 2,
|
| 654 |
+
x,
|
| 655 |
+
y
|
| 656 |
+
} = evaluate(options, state);
|
| 657 |
+
const nativeClientRects = Array.from((await (platform.getClientRects == null ? void 0 : platform.getClientRects(elements.reference))) || []);
|
| 658 |
+
|
| 659 |
+
// No rects (e.g. a hidden or detached reference, or a collapsed range) —
|
| 660 |
+
// keep the existing reference rect rather than resetting to an invalid
|
| 661 |
+
// one with non-finite values.
|
| 662 |
+
if (!nativeClientRects.length) {
|
| 663 |
+
return {};
|
| 664 |
+
}
|
| 665 |
+
const clientRects = getRectsByLine(nativeClientRects);
|
| 666 |
+
const fallback = rectToClientRect(getBoundingRect(nativeClientRects));
|
| 667 |
+
const paddingObject = getPaddingObject(padding);
|
| 668 |
+
function getBoundingClientRect() {
|
| 669 |
+
// There are two rects and they are disjoined.
|
| 670 |
+
if (clientRects.length === 2 && (clientRects[0].left > clientRects[1].right || clientRects[1].left > clientRects[0].right) && x != null && y != null) {
|
| 671 |
+
// Find the first rect in which the point is fully inside.
|
| 672 |
+
return clientRects.find(rect => x > rect.left - paddingObject.left && x < rect.right + paddingObject.right && y > rect.top - paddingObject.top && y < rect.bottom + paddingObject.bottom) || fallback;
|
| 673 |
+
}
|
| 674 |
+
|
| 675 |
+
// There are 2 or more connected rects.
|
| 676 |
+
if (clientRects.length >= 2) {
|
| 677 |
+
if (getSideAxis(placement) === 'y') {
|
| 678 |
+
const firstRect = clientRects[0];
|
| 679 |
+
const lastRect = clientRects[clientRects.length - 1];
|
| 680 |
+
const isTop = getSide(placement) === 'top';
|
| 681 |
+
const top = firstRect.top;
|
| 682 |
+
const bottom = lastRect.bottom;
|
| 683 |
+
const left = isTop ? firstRect.left : lastRect.left;
|
| 684 |
+
const right = isTop ? firstRect.right : lastRect.right;
|
| 685 |
+
return rectToClientRect({
|
| 686 |
+
x: left,
|
| 687 |
+
y: top,
|
| 688 |
+
width: right - left,
|
| 689 |
+
height: bottom - top
|
| 690 |
+
});
|
| 691 |
+
}
|
| 692 |
+
const isLeftSide = getSide(placement) === 'left';
|
| 693 |
+
const maxRight = max(...clientRects.map(rect => rect.right));
|
| 694 |
+
const minLeft = min(...clientRects.map(rect => rect.left));
|
| 695 |
+
const measureRects = clientRects.filter(rect => isLeftSide ? rect.left === minLeft : rect.right === maxRight);
|
| 696 |
+
const top = measureRects[0].top;
|
| 697 |
+
const bottom = measureRects[measureRects.length - 1].bottom;
|
| 698 |
+
return rectToClientRect({
|
| 699 |
+
x: minLeft,
|
| 700 |
+
y: top,
|
| 701 |
+
width: maxRight - minLeft,
|
| 702 |
+
height: bottom - top
|
| 703 |
+
});
|
| 704 |
+
}
|
| 705 |
+
return fallback;
|
| 706 |
+
}
|
| 707 |
+
const resetRects = await platform.getElementRects({
|
| 708 |
+
reference: {
|
| 709 |
+
getBoundingClientRect
|
| 710 |
+
},
|
| 711 |
+
floating: elements.floating,
|
| 712 |
+
strategy
|
| 713 |
+
});
|
| 714 |
+
if (rects.reference.x !== resetRects.reference.x || rects.reference.y !== resetRects.reference.y || rects.reference.width !== resetRects.reference.width || rects.reference.height !== resetRects.reference.height) {
|
| 715 |
+
return {
|
| 716 |
+
reset: {
|
| 717 |
+
rects: resetRects
|
| 718 |
+
}
|
| 719 |
+
};
|
| 720 |
+
}
|
| 721 |
+
return {};
|
| 722 |
+
}
|
| 723 |
+
};
|
| 724 |
+
};
|
| 725 |
+
|
| 726 |
+
const originSides = /*#__PURE__*/new Set(['left', 'top']);
|
| 727 |
+
|
| 728 |
+
// For type backwards-compatibility, the `OffsetOptions` type was also
|
| 729 |
+
// Derivable.
|
| 730 |
+
|
| 731 |
+
async function convertValueToCoords(state, options) {
|
| 732 |
+
const {
|
| 733 |
+
placement,
|
| 734 |
+
platform,
|
| 735 |
+
elements
|
| 736 |
+
} = state;
|
| 737 |
+
const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating));
|
| 738 |
+
const side = getSide(placement);
|
| 739 |
+
const alignment = getAlignment(placement);
|
| 740 |
+
const isVertical = getSideAxis(placement) === 'y';
|
| 741 |
+
const mainAxisMulti = originSides.has(side) ? -1 : 1;
|
| 742 |
+
const crossAxisMulti = rtl && isVertical ? -1 : 1;
|
| 743 |
+
const rawValue = evaluate(options, state);
|
| 744 |
+
|
| 745 |
+
// eslint-disable-next-line prefer-const
|
| 746 |
+
let {
|
| 747 |
+
mainAxis,
|
| 748 |
+
crossAxis,
|
| 749 |
+
alignmentAxis
|
| 750 |
+
} = typeof rawValue === 'number' ? {
|
| 751 |
+
mainAxis: rawValue,
|
| 752 |
+
crossAxis: 0,
|
| 753 |
+
alignmentAxis: null
|
| 754 |
+
} : {
|
| 755 |
+
mainAxis: rawValue.mainAxis || 0,
|
| 756 |
+
crossAxis: rawValue.crossAxis || 0,
|
| 757 |
+
alignmentAxis: rawValue.alignmentAxis
|
| 758 |
+
};
|
| 759 |
+
if (alignment && typeof alignmentAxis === 'number') {
|
| 760 |
+
crossAxis = alignment === 'end' ? alignmentAxis * -1 : alignmentAxis;
|
| 761 |
+
}
|
| 762 |
+
return isVertical ? {
|
| 763 |
+
x: crossAxis * crossAxisMulti,
|
| 764 |
+
y: mainAxis * mainAxisMulti
|
| 765 |
+
} : {
|
| 766 |
+
x: mainAxis * mainAxisMulti,
|
| 767 |
+
y: crossAxis * crossAxisMulti
|
| 768 |
+
};
|
| 769 |
+
}
|
| 770 |
+
|
| 771 |
+
/**
|
| 772 |
+
* Modifies the placement by translating the floating element along the
|
| 773 |
+
* specified axes.
|
| 774 |
+
* A number (shorthand for `mainAxis` or distance), or an axes configuration
|
| 775 |
+
* object may be passed.
|
| 776 |
+
* @see https://floating-ui.com/docs/offset
|
| 777 |
+
*/
|
| 778 |
+
const offset = function (options) {
|
| 779 |
+
if (options === void 0) {
|
| 780 |
+
options = 0;
|
| 781 |
+
}
|
| 782 |
+
return {
|
| 783 |
+
name: 'offset',
|
| 784 |
+
options,
|
| 785 |
+
async fn(state) {
|
| 786 |
+
var _middlewareData$offse, _middlewareData$arrow;
|
| 787 |
+
const {
|
| 788 |
+
x,
|
| 789 |
+
y,
|
| 790 |
+
placement,
|
| 791 |
+
middlewareData
|
| 792 |
+
} = state;
|
| 793 |
+
const diffCoords = await convertValueToCoords(state, options);
|
| 794 |
+
|
| 795 |
+
// If the placement is the same and the arrow caused an alignment offset
|
| 796 |
+
// then we don't need to change the positioning coordinates.
|
| 797 |
+
if (placement === ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse.placement) && (_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
|
| 798 |
+
return {};
|
| 799 |
+
}
|
| 800 |
+
return {
|
| 801 |
+
x: x + diffCoords.x,
|
| 802 |
+
y: y + diffCoords.y,
|
| 803 |
+
data: {
|
| 804 |
+
...diffCoords,
|
| 805 |
+
placement
|
| 806 |
+
}
|
| 807 |
+
};
|
| 808 |
+
}
|
| 809 |
+
};
|
| 810 |
+
};
|
| 811 |
+
|
| 812 |
+
/**
|
| 813 |
+
* Optimizes the visibility of the floating element by shifting it in order to
|
| 814 |
+
* keep it in view when it will overflow the clipping boundary.
|
| 815 |
+
* @see https://floating-ui.com/docs/shift
|
| 816 |
+
*/
|
| 817 |
+
const shift = function (options) {
|
| 818 |
+
if (options === void 0) {
|
| 819 |
+
options = {};
|
| 820 |
+
}
|
| 821 |
+
return {
|
| 822 |
+
name: 'shift',
|
| 823 |
+
options,
|
| 824 |
+
async fn(state) {
|
| 825 |
+
const {
|
| 826 |
+
x,
|
| 827 |
+
y,
|
| 828 |
+
placement,
|
| 829 |
+
platform
|
| 830 |
+
} = state;
|
| 831 |
+
const {
|
| 832 |
+
mainAxis: checkMainAxis = true,
|
| 833 |
+
crossAxis: checkCrossAxis = false,
|
| 834 |
+
limiter = {
|
| 835 |
+
fn: _ref => {
|
| 836 |
+
let {
|
| 837 |
+
x,
|
| 838 |
+
y
|
| 839 |
+
} = _ref;
|
| 840 |
+
return {
|
| 841 |
+
x,
|
| 842 |
+
y
|
| 843 |
+
};
|
| 844 |
+
}
|
| 845 |
+
},
|
| 846 |
+
...detectOverflowOptions
|
| 847 |
+
} = evaluate(options, state);
|
| 848 |
+
const coords = {
|
| 849 |
+
x,
|
| 850 |
+
y
|
| 851 |
+
};
|
| 852 |
+
const overflow = await platform.detectOverflow(state, detectOverflowOptions);
|
| 853 |
+
const crossAxis = getSideAxis(placement);
|
| 854 |
+
const mainAxis = getOppositeAxis(crossAxis);
|
| 855 |
+
let mainAxisCoord = coords[mainAxis];
|
| 856 |
+
let crossAxisCoord = coords[crossAxis];
|
| 857 |
+
const clampCoord = (axis, coord) => clamp(coord + overflow[axis === 'y' ? 'top' : 'left'], coord, coord - overflow[axis === 'y' ? 'bottom' : 'right']);
|
| 858 |
+
if (checkMainAxis) {
|
| 859 |
+
mainAxisCoord = clampCoord(mainAxis, mainAxisCoord);
|
| 860 |
+
}
|
| 861 |
+
if (checkCrossAxis) {
|
| 862 |
+
crossAxisCoord = clampCoord(crossAxis, crossAxisCoord);
|
| 863 |
+
}
|
| 864 |
+
const limitedCoords = limiter.fn({
|
| 865 |
+
...state,
|
| 866 |
+
[mainAxis]: mainAxisCoord,
|
| 867 |
+
[crossAxis]: crossAxisCoord
|
| 868 |
+
});
|
| 869 |
+
return {
|
| 870 |
+
...limitedCoords,
|
| 871 |
+
data: {
|
| 872 |
+
x: limitedCoords.x - x,
|
| 873 |
+
y: limitedCoords.y - y,
|
| 874 |
+
enabled: {
|
| 875 |
+
[mainAxis]: checkMainAxis,
|
| 876 |
+
[crossAxis]: checkCrossAxis
|
| 877 |
+
}
|
| 878 |
+
}
|
| 879 |
+
};
|
| 880 |
+
}
|
| 881 |
+
};
|
| 882 |
+
};
|
| 883 |
+
/**
|
| 884 |
+
* Built-in `limiter` that will stop `shift()` at a certain point.
|
| 885 |
+
*/
|
| 886 |
+
const limitShift = function (options) {
|
| 887 |
+
if (options === void 0) {
|
| 888 |
+
options = {};
|
| 889 |
+
}
|
| 890 |
+
return {
|
| 891 |
+
options,
|
| 892 |
+
fn(state) {
|
| 893 |
+
var _rawOffset$mainAxis, _rawOffset$crossAxis;
|
| 894 |
+
const {
|
| 895 |
+
x,
|
| 896 |
+
y,
|
| 897 |
+
placement,
|
| 898 |
+
rects,
|
| 899 |
+
middlewareData
|
| 900 |
+
} = state;
|
| 901 |
+
const {
|
| 902 |
+
offset = 0,
|
| 903 |
+
mainAxis: checkMainAxis = true,
|
| 904 |
+
crossAxis: checkCrossAxis = true
|
| 905 |
+
} = evaluate(options, state);
|
| 906 |
+
const coords = {
|
| 907 |
+
x,
|
| 908 |
+
y
|
| 909 |
+
};
|
| 910 |
+
const crossAxis = getSideAxis(placement);
|
| 911 |
+
const mainAxis = getOppositeAxis(crossAxis);
|
| 912 |
+
let mainAxisCoord = coords[mainAxis];
|
| 913 |
+
let crossAxisCoord = coords[crossAxis];
|
| 914 |
+
const rawOffset = evaluate(offset, state);
|
| 915 |
+
const computedOffset = typeof rawOffset === 'number' ? {
|
| 916 |
+
mainAxis: rawOffset,
|
| 917 |
+
crossAxis: 0
|
| 918 |
+
} : {
|
| 919 |
+
mainAxis: (_rawOffset$mainAxis = rawOffset.mainAxis) != null ? _rawOffset$mainAxis : 0,
|
| 920 |
+
crossAxis: (_rawOffset$crossAxis = rawOffset.crossAxis) != null ? _rawOffset$crossAxis : 0
|
| 921 |
+
};
|
| 922 |
+
if (checkMainAxis) {
|
| 923 |
+
const len = mainAxis === 'y' ? 'height' : 'width';
|
| 924 |
+
const limitMin = rects.reference[mainAxis] - rects.floating[len] + computedOffset.mainAxis;
|
| 925 |
+
const limitMax = rects.reference[mainAxis] + rects.reference[len] - computedOffset.mainAxis;
|
| 926 |
+
if (mainAxisCoord < limitMin) {
|
| 927 |
+
mainAxisCoord = limitMin;
|
| 928 |
+
} else if (mainAxisCoord > limitMax) {
|
| 929 |
+
mainAxisCoord = limitMax;
|
| 930 |
+
}
|
| 931 |
+
}
|
| 932 |
+
if (checkCrossAxis) {
|
| 933 |
+
var _middlewareData$offse, _middlewareData$offse2;
|
| 934 |
+
const len = mainAxis === 'y' ? 'width' : 'height';
|
| 935 |
+
const isOriginSide = originSides.has(getSide(placement));
|
| 936 |
+
const limitMin = rects.reference[crossAxis] - rects.floating[len] + (isOriginSide ? ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse[crossAxis]) || 0 : 0) + (isOriginSide ? 0 : computedOffset.crossAxis);
|
| 937 |
+
const limitMax = rects.reference[crossAxis] + rects.reference[len] + (isOriginSide ? 0 : ((_middlewareData$offse2 = middlewareData.offset) == null ? void 0 : _middlewareData$offse2[crossAxis]) || 0) - (isOriginSide ? computedOffset.crossAxis : 0);
|
| 938 |
+
if (crossAxisCoord < limitMin) {
|
| 939 |
+
crossAxisCoord = limitMin;
|
| 940 |
+
} else if (crossAxisCoord > limitMax) {
|
| 941 |
+
crossAxisCoord = limitMax;
|
| 942 |
+
}
|
| 943 |
+
}
|
| 944 |
+
return {
|
| 945 |
+
[mainAxis]: mainAxisCoord,
|
| 946 |
+
[crossAxis]: crossAxisCoord
|
| 947 |
+
};
|
| 948 |
+
}
|
| 949 |
+
};
|
| 950 |
+
};
|
| 951 |
+
|
| 952 |
+
// Method syntax keeps callback parameters bivariant, but expressing the
|
| 953 |
+
// explicit `| undefined` required by `exactOptionalPropertyTypes` needs
|
| 954 |
+
// property syntax, which is contravariant under `strictFunctionTypes`.
|
| 955 |
+
// Extracting the function from a method position restores that bivariance so
|
| 956 |
+
// consumers can still assign callbacks with narrower parameter types.
|
| 957 |
+
|
| 958 |
+
/**
|
| 959 |
+
* Provides data that allows you to change the size of the floating element —
|
| 960 |
+
* for instance, prevent it from overflowing the clipping boundary or match the
|
| 961 |
+
* width of the reference element.
|
| 962 |
+
* @see https://floating-ui.com/docs/size
|
| 963 |
+
*/
|
| 964 |
+
const size = function (options) {
|
| 965 |
+
if (options === void 0) {
|
| 966 |
+
options = {};
|
| 967 |
+
}
|
| 968 |
+
return {
|
| 969 |
+
name: 'size',
|
| 970 |
+
options,
|
| 971 |
+
async fn(state) {
|
| 972 |
+
const {
|
| 973 |
+
placement,
|
| 974 |
+
rects,
|
| 975 |
+
platform,
|
| 976 |
+
elements
|
| 977 |
+
} = state;
|
| 978 |
+
const {
|
| 979 |
+
apply = () => {},
|
| 980 |
+
...detectOverflowOptions
|
| 981 |
+
} = evaluate(options, state);
|
| 982 |
+
const overflow = await platform.detectOverflow(state, detectOverflowOptions);
|
| 983 |
+
const side = getSide(placement);
|
| 984 |
+
const alignment = getAlignment(placement);
|
| 985 |
+
const isYAxis = getSideAxis(placement) === 'y';
|
| 986 |
+
const {
|
| 987 |
+
width,
|
| 988 |
+
height
|
| 989 |
+
} = rects.floating;
|
| 990 |
+
let heightSide;
|
| 991 |
+
let widthSide;
|
| 992 |
+
if (side === 'top' || side === 'bottom') {
|
| 993 |
+
heightSide = side;
|
| 994 |
+
widthSide = alignment === ((await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating))) ? 'start' : 'end') ? 'left' : 'right';
|
| 995 |
+
} else {
|
| 996 |
+
widthSide = side;
|
| 997 |
+
heightSide = alignment === 'end' ? 'top' : 'bottom';
|
| 998 |
+
}
|
| 999 |
+
const maximumClippingHeight = height - overflow.top - overflow.bottom;
|
| 1000 |
+
const maximumClippingWidth = width - overflow.left - overflow.right;
|
| 1001 |
+
const overflowAvailableHeight = min(height - overflow[heightSide], maximumClippingHeight);
|
| 1002 |
+
const overflowAvailableWidth = min(width - overflow[widthSide], maximumClippingWidth);
|
| 1003 |
+
const shiftData = state.middlewareData.shift;
|
| 1004 |
+
const noShift = !shiftData;
|
| 1005 |
+
let availableHeight = overflowAvailableHeight;
|
| 1006 |
+
let availableWidth = overflowAvailableWidth;
|
| 1007 |
+
if (shiftData != null && shiftData.enabled.x) {
|
| 1008 |
+
availableWidth = maximumClippingWidth;
|
| 1009 |
+
}
|
| 1010 |
+
if (shiftData != null && shiftData.enabled.y) {
|
| 1011 |
+
availableHeight = maximumClippingHeight;
|
| 1012 |
+
}
|
| 1013 |
+
if (noShift && !alignment) {
|
| 1014 |
+
if (isYAxis) {
|
| 1015 |
+
availableWidth = width - 2 * max(overflow.left, overflow.right);
|
| 1016 |
+
} else {
|
| 1017 |
+
availableHeight = height - 2 * max(overflow.top, overflow.bottom);
|
| 1018 |
+
}
|
| 1019 |
+
}
|
| 1020 |
+
await apply({
|
| 1021 |
+
...state,
|
| 1022 |
+
availableWidth,
|
| 1023 |
+
availableHeight
|
| 1024 |
+
});
|
| 1025 |
+
const nextDimensions = await platform.getDimensions(elements.floating);
|
| 1026 |
+
if (width !== nextDimensions.width || height !== nextDimensions.height) {
|
| 1027 |
+
return {
|
| 1028 |
+
reset: {
|
| 1029 |
+
rects: true
|
| 1030 |
+
}
|
| 1031 |
+
};
|
| 1032 |
+
}
|
| 1033 |
+
return {};
|
| 1034 |
+
}
|
| 1035 |
+
};
|
| 1036 |
+
};
|
| 1037 |
+
|
| 1038 |
+
export { arrow, autoPlacement, computePosition, detectOverflow, flip, hide, inline, limitShift, offset, shift, size };
|
e-commerce/node_modules/@floating-ui/core/dist/floating-ui.core.mjs
ADDED
|
@@ -0,0 +1,1038 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { getSideAxis, getAlignmentAxis, getAxisLength, getSide, getAlignment, evaluate, getPaddingObject, rectToClientRect, min, clamp, placements, getAlignmentSides, getOppositeAlignmentPlacement, getOppositePlacement, getExpandedPlacements, getOppositeAxisPlacements, sides, max, getOppositeAxis } from '@floating-ui/utils';
|
| 2 |
+
export { rectToClientRect } from '@floating-ui/utils';
|
| 3 |
+
|
| 4 |
+
function computeCoordsFromPlacement(_ref, placement, rtl) {
|
| 5 |
+
let {
|
| 6 |
+
reference,
|
| 7 |
+
floating
|
| 8 |
+
} = _ref;
|
| 9 |
+
const sideAxis = getSideAxis(placement);
|
| 10 |
+
const alignmentAxis = getAlignmentAxis(placement);
|
| 11 |
+
const alignLength = getAxisLength(alignmentAxis);
|
| 12 |
+
const side = getSide(placement);
|
| 13 |
+
const isVertical = sideAxis === 'y';
|
| 14 |
+
const commonX = reference.x + reference.width / 2 - floating.width / 2;
|
| 15 |
+
const commonY = reference.y + reference.height / 2 - floating.height / 2;
|
| 16 |
+
const commonAlign = reference[alignLength] / 2 - floating[alignLength] / 2;
|
| 17 |
+
let coords;
|
| 18 |
+
switch (side) {
|
| 19 |
+
case 'top':
|
| 20 |
+
coords = {
|
| 21 |
+
x: commonX,
|
| 22 |
+
y: reference.y - floating.height
|
| 23 |
+
};
|
| 24 |
+
break;
|
| 25 |
+
case 'bottom':
|
| 26 |
+
coords = {
|
| 27 |
+
x: commonX,
|
| 28 |
+
y: reference.y + reference.height
|
| 29 |
+
};
|
| 30 |
+
break;
|
| 31 |
+
case 'right':
|
| 32 |
+
coords = {
|
| 33 |
+
x: reference.x + reference.width,
|
| 34 |
+
y: commonY
|
| 35 |
+
};
|
| 36 |
+
break;
|
| 37 |
+
case 'left':
|
| 38 |
+
coords = {
|
| 39 |
+
x: reference.x - floating.width,
|
| 40 |
+
y: commonY
|
| 41 |
+
};
|
| 42 |
+
break;
|
| 43 |
+
default:
|
| 44 |
+
coords = {
|
| 45 |
+
x: reference.x,
|
| 46 |
+
y: reference.y
|
| 47 |
+
};
|
| 48 |
+
}
|
| 49 |
+
const alignment = getAlignment(placement);
|
| 50 |
+
if (alignment) {
|
| 51 |
+
coords[alignmentAxis] += commonAlign * (alignment === 'end' ? 1 : -1) * (rtl && isVertical ? -1 : 1);
|
| 52 |
+
}
|
| 53 |
+
return coords;
|
| 54 |
+
}
|
| 55 |
+
|
| 56 |
+
/**
|
| 57 |
+
* Resolves with an object of overflow side offsets that determine how much the
|
| 58 |
+
* element is overflowing a given clipping boundary on each side.
|
| 59 |
+
* - positive = overflowing the boundary by that number of pixels
|
| 60 |
+
* - negative = how many pixels left before it will overflow
|
| 61 |
+
* - 0 = lies flush with the boundary
|
| 62 |
+
* @see https://floating-ui.com/docs/detectOverflow
|
| 63 |
+
*/
|
| 64 |
+
async function detectOverflow(state, options) {
|
| 65 |
+
var _await$platform$isEle;
|
| 66 |
+
if (options === void 0) {
|
| 67 |
+
options = {};
|
| 68 |
+
}
|
| 69 |
+
const {
|
| 70 |
+
x,
|
| 71 |
+
y,
|
| 72 |
+
platform,
|
| 73 |
+
rects,
|
| 74 |
+
elements,
|
| 75 |
+
strategy
|
| 76 |
+
} = state;
|
| 77 |
+
const {
|
| 78 |
+
boundary = 'clippingAncestors',
|
| 79 |
+
rootBoundary = 'viewport',
|
| 80 |
+
elementContext = 'floating',
|
| 81 |
+
altBoundary = false,
|
| 82 |
+
padding = 0
|
| 83 |
+
} = evaluate(options, state);
|
| 84 |
+
const paddingObject = getPaddingObject(padding);
|
| 85 |
+
const altContext = elementContext === 'floating' ? 'reference' : 'floating';
|
| 86 |
+
const element = elements[altBoundary ? altContext : elementContext];
|
| 87 |
+
const clippingClientRect = rectToClientRect(await platform.getClippingRect({
|
| 88 |
+
element: ((_await$platform$isEle = await (platform.isElement == null ? void 0 : platform.isElement(element))) != null ? _await$platform$isEle : true) ? element : element.contextElement || (await (platform.getDocumentElement == null ? void 0 : platform.getDocumentElement(elements.floating))),
|
| 89 |
+
boundary,
|
| 90 |
+
rootBoundary,
|
| 91 |
+
strategy
|
| 92 |
+
}));
|
| 93 |
+
const rect = elementContext === 'floating' ? {
|
| 94 |
+
x,
|
| 95 |
+
y,
|
| 96 |
+
width: rects.floating.width,
|
| 97 |
+
height: rects.floating.height
|
| 98 |
+
} : rects.reference;
|
| 99 |
+
const offsetParent = await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(elements.floating));
|
| 100 |
+
const offsetScale = (await (platform.isElement == null ? void 0 : platform.isElement(offsetParent))) && (await (platform.getScale == null ? void 0 : platform.getScale(offsetParent))) || {
|
| 101 |
+
x: 1,
|
| 102 |
+
y: 1
|
| 103 |
+
};
|
| 104 |
+
const elementClientRect = rectToClientRect(platform.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform.convertOffsetParentRelativeRectToViewportRelativeRect({
|
| 105 |
+
elements,
|
| 106 |
+
rect,
|
| 107 |
+
offsetParent,
|
| 108 |
+
strategy
|
| 109 |
+
}) : rect);
|
| 110 |
+
return {
|
| 111 |
+
top: (clippingClientRect.top - elementClientRect.top + paddingObject.top) / offsetScale.y,
|
| 112 |
+
bottom: (elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom) / offsetScale.y,
|
| 113 |
+
left: (clippingClientRect.left - elementClientRect.left + paddingObject.left) / offsetScale.x,
|
| 114 |
+
right: (elementClientRect.right - clippingClientRect.right + paddingObject.right) / offsetScale.x
|
| 115 |
+
};
|
| 116 |
+
}
|
| 117 |
+
|
| 118 |
+
// Maximum number of resets that can occur before bailing to avoid infinite reset loops.
|
| 119 |
+
const MAX_RESET_COUNT = 50;
|
| 120 |
+
|
| 121 |
+
/**
|
| 122 |
+
* Computes the `x` and `y` coordinates that will place the floating element
|
| 123 |
+
* next to a given reference element.
|
| 124 |
+
*
|
| 125 |
+
* This export does not have any `platform` interface logic. You will need to
|
| 126 |
+
* write one for the platform you are using Floating UI with.
|
| 127 |
+
*/
|
| 128 |
+
const computePosition = async (reference, floating, config) => {
|
| 129 |
+
const {
|
| 130 |
+
placement = 'bottom',
|
| 131 |
+
strategy = 'absolute',
|
| 132 |
+
middleware = [],
|
| 133 |
+
platform
|
| 134 |
+
} = config;
|
| 135 |
+
const platformWithDetectOverflow = platform.detectOverflow ? platform : {
|
| 136 |
+
...platform,
|
| 137 |
+
detectOverflow
|
| 138 |
+
};
|
| 139 |
+
const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(floating));
|
| 140 |
+
let rects = await platform.getElementRects({
|
| 141 |
+
reference,
|
| 142 |
+
floating,
|
| 143 |
+
strategy
|
| 144 |
+
});
|
| 145 |
+
let {
|
| 146 |
+
x,
|
| 147 |
+
y
|
| 148 |
+
} = computeCoordsFromPlacement(rects, placement, rtl);
|
| 149 |
+
let statefulPlacement = placement;
|
| 150 |
+
let resetCount = 0;
|
| 151 |
+
const middlewareData = {};
|
| 152 |
+
for (let i = 0; i < middleware.length; i++) {
|
| 153 |
+
const currentMiddleware = middleware[i];
|
| 154 |
+
if (!currentMiddleware) {
|
| 155 |
+
continue;
|
| 156 |
+
}
|
| 157 |
+
const {
|
| 158 |
+
name,
|
| 159 |
+
fn
|
| 160 |
+
} = currentMiddleware;
|
| 161 |
+
const {
|
| 162 |
+
x: nextX,
|
| 163 |
+
y: nextY,
|
| 164 |
+
data,
|
| 165 |
+
reset
|
| 166 |
+
} = await fn({
|
| 167 |
+
x,
|
| 168 |
+
y,
|
| 169 |
+
initialPlacement: placement,
|
| 170 |
+
placement: statefulPlacement,
|
| 171 |
+
strategy,
|
| 172 |
+
middlewareData,
|
| 173 |
+
rects,
|
| 174 |
+
platform: platformWithDetectOverflow,
|
| 175 |
+
elements: {
|
| 176 |
+
reference,
|
| 177 |
+
floating
|
| 178 |
+
}
|
| 179 |
+
});
|
| 180 |
+
x = nextX != null ? nextX : x;
|
| 181 |
+
y = nextY != null ? nextY : y;
|
| 182 |
+
middlewareData[name] = {
|
| 183 |
+
...middlewareData[name],
|
| 184 |
+
...data
|
| 185 |
+
};
|
| 186 |
+
if (reset && resetCount < MAX_RESET_COUNT) {
|
| 187 |
+
resetCount++;
|
| 188 |
+
if (typeof reset === 'object') {
|
| 189 |
+
if (reset.placement) {
|
| 190 |
+
statefulPlacement = reset.placement;
|
| 191 |
+
}
|
| 192 |
+
if (reset.rects) {
|
| 193 |
+
rects = reset.rects === true ? await platform.getElementRects({
|
| 194 |
+
reference,
|
| 195 |
+
floating,
|
| 196 |
+
strategy
|
| 197 |
+
}) : reset.rects;
|
| 198 |
+
}
|
| 199 |
+
({
|
| 200 |
+
x,
|
| 201 |
+
y
|
| 202 |
+
} = computeCoordsFromPlacement(rects, statefulPlacement, rtl));
|
| 203 |
+
}
|
| 204 |
+
i = -1;
|
| 205 |
+
}
|
| 206 |
+
}
|
| 207 |
+
return {
|
| 208 |
+
x,
|
| 209 |
+
y,
|
| 210 |
+
placement: statefulPlacement,
|
| 211 |
+
strategy,
|
| 212 |
+
middlewareData
|
| 213 |
+
};
|
| 214 |
+
};
|
| 215 |
+
|
| 216 |
+
/**
|
| 217 |
+
* Provides data to position an inner element of the floating element so that it
|
| 218 |
+
* appears centered to the reference element.
|
| 219 |
+
* @see https://floating-ui.com/docs/arrow
|
| 220 |
+
*/
|
| 221 |
+
const arrow = options => ({
|
| 222 |
+
name: 'arrow',
|
| 223 |
+
options,
|
| 224 |
+
async fn(state) {
|
| 225 |
+
const {
|
| 226 |
+
x,
|
| 227 |
+
y,
|
| 228 |
+
placement,
|
| 229 |
+
rects,
|
| 230 |
+
platform,
|
| 231 |
+
elements,
|
| 232 |
+
middlewareData
|
| 233 |
+
} = state;
|
| 234 |
+
// Since `element` is required, we don't Partial<> the type.
|
| 235 |
+
const {
|
| 236 |
+
element,
|
| 237 |
+
padding = 0
|
| 238 |
+
} = evaluate(options, state) || {};
|
| 239 |
+
if (element == null) {
|
| 240 |
+
return {};
|
| 241 |
+
}
|
| 242 |
+
const paddingObject = getPaddingObject(padding);
|
| 243 |
+
const coords = {
|
| 244 |
+
x,
|
| 245 |
+
y
|
| 246 |
+
};
|
| 247 |
+
const axis = getAlignmentAxis(placement);
|
| 248 |
+
const length = getAxisLength(axis);
|
| 249 |
+
const arrowDimensions = await platform.getDimensions(element);
|
| 250 |
+
const isYAxis = axis === 'y';
|
| 251 |
+
const minProp = isYAxis ? 'top' : 'left';
|
| 252 |
+
const maxProp = isYAxis ? 'bottom' : 'right';
|
| 253 |
+
const clientProp = isYAxis ? 'clientHeight' : 'clientWidth';
|
| 254 |
+
const endDiff = rects.reference[length] + rects.reference[axis] - coords[axis] - rects.floating[length];
|
| 255 |
+
const startDiff = coords[axis] - rects.reference[axis];
|
| 256 |
+
const arrowOffsetParent = await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(element));
|
| 257 |
+
let clientSize = arrowOffsetParent ? arrowOffsetParent[clientProp] : 0;
|
| 258 |
+
|
| 259 |
+
// DOM platform can return `window` as the `offsetParent`.
|
| 260 |
+
if (!clientSize || !(await (platform.isElement == null ? void 0 : platform.isElement(arrowOffsetParent)))) {
|
| 261 |
+
clientSize = elements.floating[clientProp] || rects.floating[length];
|
| 262 |
+
}
|
| 263 |
+
const centerToReference = endDiff / 2 - startDiff / 2;
|
| 264 |
+
|
| 265 |
+
// If the padding is large enough that it causes the arrow to no longer be
|
| 266 |
+
// centered, modify the padding so that it is centered.
|
| 267 |
+
const largestPossiblePadding = clientSize / 2 - arrowDimensions[length] / 2 - 1;
|
| 268 |
+
const minPadding = min(paddingObject[minProp], largestPossiblePadding);
|
| 269 |
+
const maxPadding = min(paddingObject[maxProp], largestPossiblePadding);
|
| 270 |
+
|
| 271 |
+
// Make sure the arrow doesn't overflow the floating element if the center
|
| 272 |
+
// point is outside the floating element's bounds.
|
| 273 |
+
const max = clientSize - arrowDimensions[length] - maxPadding;
|
| 274 |
+
const center = clientSize / 2 - arrowDimensions[length] / 2 + centerToReference;
|
| 275 |
+
const offset = clamp(minPadding, center, max);
|
| 276 |
+
|
| 277 |
+
// If the reference is small enough that the arrow's padding causes it to
|
| 278 |
+
// to point to nothing for an aligned placement, adjust the offset of the
|
| 279 |
+
// floating element itself. To ensure `shift()` continues to take action,
|
| 280 |
+
// a single reset is performed when this is true.
|
| 281 |
+
const shouldAddOffset = !middlewareData.arrow && getAlignment(placement) != null && center !== offset && rects.reference[length] / 2 - (center < minPadding ? minPadding : maxPadding) - arrowDimensions[length] / 2 < 0;
|
| 282 |
+
const alignmentOffset = shouldAddOffset ? center < minPadding ? center - minPadding : center - max : 0;
|
| 283 |
+
return {
|
| 284 |
+
[axis]: coords[axis] + alignmentOffset,
|
| 285 |
+
data: {
|
| 286 |
+
[axis]: offset,
|
| 287 |
+
centerOffset: center - offset - alignmentOffset,
|
| 288 |
+
...(shouldAddOffset && {
|
| 289 |
+
alignmentOffset
|
| 290 |
+
})
|
| 291 |
+
},
|
| 292 |
+
reset: shouldAddOffset
|
| 293 |
+
};
|
| 294 |
+
}
|
| 295 |
+
});
|
| 296 |
+
|
| 297 |
+
function getPlacementList(alignment, autoAlignment, allowedPlacements) {
|
| 298 |
+
const allowedPlacementsSortedByAlignment = alignment ? [...allowedPlacements.filter(placement => getAlignment(placement) === alignment), ...allowedPlacements.filter(placement => getAlignment(placement) !== alignment)] : allowedPlacements.filter(placement => getSide(placement) === placement);
|
| 299 |
+
return allowedPlacementsSortedByAlignment.filter(placement => {
|
| 300 |
+
if (alignment) {
|
| 301 |
+
return getAlignment(placement) === alignment || (autoAlignment ? getOppositeAlignmentPlacement(placement) !== placement : false);
|
| 302 |
+
}
|
| 303 |
+
return true;
|
| 304 |
+
});
|
| 305 |
+
}
|
| 306 |
+
/**
|
| 307 |
+
* Optimizes the visibility of the floating element by choosing the placement
|
| 308 |
+
* that has the most space available automatically, without needing to specify a
|
| 309 |
+
* preferred placement. Alternative to `flip`.
|
| 310 |
+
* @see https://floating-ui.com/docs/autoPlacement
|
| 311 |
+
*/
|
| 312 |
+
const autoPlacement = function (options) {
|
| 313 |
+
if (options === void 0) {
|
| 314 |
+
options = {};
|
| 315 |
+
}
|
| 316 |
+
return {
|
| 317 |
+
name: 'autoPlacement',
|
| 318 |
+
options,
|
| 319 |
+
async fn(state) {
|
| 320 |
+
var _middlewareData$autoP, _middlewareData$autoP2, _placementsThatFitOnE;
|
| 321 |
+
const {
|
| 322 |
+
rects,
|
| 323 |
+
middlewareData,
|
| 324 |
+
placement,
|
| 325 |
+
platform,
|
| 326 |
+
elements
|
| 327 |
+
} = state;
|
| 328 |
+
const {
|
| 329 |
+
crossAxis = false,
|
| 330 |
+
alignment,
|
| 331 |
+
allowedPlacements = placements,
|
| 332 |
+
autoAlignment = true,
|
| 333 |
+
...detectOverflowOptions
|
| 334 |
+
} = evaluate(options, state);
|
| 335 |
+
const placements$1 = alignment !== undefined || allowedPlacements === placements ? getPlacementList(alignment || null, autoAlignment, allowedPlacements) : allowedPlacements;
|
| 336 |
+
const currentIndex = ((_middlewareData$autoP = middlewareData.autoPlacement) == null ? void 0 : _middlewareData$autoP.index) || 0;
|
| 337 |
+
const currentPlacement = placements$1[currentIndex];
|
| 338 |
+
if (currentPlacement == null) {
|
| 339 |
+
return {};
|
| 340 |
+
}
|
| 341 |
+
|
| 342 |
+
// Make `computeCoords` start from the right place.
|
| 343 |
+
if (placement !== currentPlacement) {
|
| 344 |
+
return {
|
| 345 |
+
reset: {
|
| 346 |
+
placement: placements$1[0]
|
| 347 |
+
}
|
| 348 |
+
};
|
| 349 |
+
}
|
| 350 |
+
const overflow = await platform.detectOverflow(state, detectOverflowOptions);
|
| 351 |
+
const alignmentSides = getAlignmentSides(currentPlacement, rects, await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating)));
|
| 352 |
+
const currentOverflows = [overflow[getSide(currentPlacement)], overflow[alignmentSides[0]], overflow[alignmentSides[1]]];
|
| 353 |
+
const allOverflows = [...(((_middlewareData$autoP2 = middlewareData.autoPlacement) == null ? void 0 : _middlewareData$autoP2.overflows) || []), {
|
| 354 |
+
placement: currentPlacement,
|
| 355 |
+
overflows: currentOverflows
|
| 356 |
+
}];
|
| 357 |
+
const nextPlacement = placements$1[currentIndex + 1];
|
| 358 |
+
|
| 359 |
+
// There are more placements to check.
|
| 360 |
+
if (nextPlacement) {
|
| 361 |
+
return {
|
| 362 |
+
data: {
|
| 363 |
+
index: currentIndex + 1,
|
| 364 |
+
overflows: allOverflows
|
| 365 |
+
},
|
| 366 |
+
reset: {
|
| 367 |
+
placement: nextPlacement
|
| 368 |
+
}
|
| 369 |
+
};
|
| 370 |
+
}
|
| 371 |
+
const placementsSortedByMostSpace = allOverflows.map(d => {
|
| 372 |
+
const alignment = getAlignment(d.placement);
|
| 373 |
+
return [d.placement, alignment && crossAxis ?
|
| 374 |
+
// Check along the mainAxis and main crossAxis side.
|
| 375 |
+
d.overflows.slice(0, 2).reduce((acc, v) => acc + v, 0) :
|
| 376 |
+
// Check only the mainAxis.
|
| 377 |
+
d.overflows[0], d.overflows];
|
| 378 |
+
}).sort((a, b) => a[1] - b[1]);
|
| 379 |
+
const placementsThatFitOnEachSide = placementsSortedByMostSpace.filter(d => d[2].slice(0,
|
| 380 |
+
// Aligned placements should not check their opposite crossAxis
|
| 381 |
+
// side.
|
| 382 |
+
getAlignment(d[0]) ? 2 : 3).every(v => v <= 0));
|
| 383 |
+
const resetPlacement = ((_placementsThatFitOnE = placementsThatFitOnEachSide[0]) == null ? void 0 : _placementsThatFitOnE[0]) || placementsSortedByMostSpace[0][0];
|
| 384 |
+
if (resetPlacement !== placement) {
|
| 385 |
+
return {
|
| 386 |
+
data: {
|
| 387 |
+
index: currentIndex + 1,
|
| 388 |
+
overflows: allOverflows
|
| 389 |
+
},
|
| 390 |
+
reset: {
|
| 391 |
+
placement: resetPlacement
|
| 392 |
+
}
|
| 393 |
+
};
|
| 394 |
+
}
|
| 395 |
+
return {};
|
| 396 |
+
}
|
| 397 |
+
};
|
| 398 |
+
};
|
| 399 |
+
|
| 400 |
+
/**
|
| 401 |
+
* Optimizes the visibility of the floating element by flipping the `placement`
|
| 402 |
+
* in order to keep it in view when the preferred placement(s) will overflow the
|
| 403 |
+
* clipping boundary. Alternative to `autoPlacement`.
|
| 404 |
+
* @see https://floating-ui.com/docs/flip
|
| 405 |
+
*/
|
| 406 |
+
const flip = function (options) {
|
| 407 |
+
if (options === void 0) {
|
| 408 |
+
options = {};
|
| 409 |
+
}
|
| 410 |
+
return {
|
| 411 |
+
name: 'flip',
|
| 412 |
+
options,
|
| 413 |
+
async fn(state) {
|
| 414 |
+
var _middlewareData$arrow, _middlewareData$flip;
|
| 415 |
+
const {
|
| 416 |
+
placement,
|
| 417 |
+
middlewareData,
|
| 418 |
+
rects,
|
| 419 |
+
initialPlacement,
|
| 420 |
+
platform,
|
| 421 |
+
elements
|
| 422 |
+
} = state;
|
| 423 |
+
const {
|
| 424 |
+
mainAxis: checkMainAxis = true,
|
| 425 |
+
crossAxis: checkCrossAxis = true,
|
| 426 |
+
fallbackPlacements: specifiedFallbackPlacements,
|
| 427 |
+
fallbackStrategy = 'bestFit',
|
| 428 |
+
fallbackAxisSideDirection = 'none',
|
| 429 |
+
flipAlignment = true,
|
| 430 |
+
...detectOverflowOptions
|
| 431 |
+
} = evaluate(options, state);
|
| 432 |
+
|
| 433 |
+
// If a reset by the arrow was caused due to an alignment offset being
|
| 434 |
+
// added, we should skip any logic now since `flip()` has already done its
|
| 435 |
+
// work.
|
| 436 |
+
// https://github.com/floating-ui/floating-ui/issues/2549#issuecomment-1719601643
|
| 437 |
+
if ((_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
|
| 438 |
+
return {};
|
| 439 |
+
}
|
| 440 |
+
const side = getSide(placement);
|
| 441 |
+
const initialSideAxis = getSideAxis(initialPlacement);
|
| 442 |
+
const isBasePlacement = getSide(initialPlacement) === initialPlacement;
|
| 443 |
+
const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating));
|
| 444 |
+
const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement(initialPlacement)] : getExpandedPlacements(initialPlacement));
|
| 445 |
+
const hasFallbackAxisSideDirection = fallbackAxisSideDirection !== 'none';
|
| 446 |
+
if (!specifiedFallbackPlacements && hasFallbackAxisSideDirection) {
|
| 447 |
+
fallbackPlacements.push(...getOppositeAxisPlacements(initialPlacement, flipAlignment, fallbackAxisSideDirection, rtl));
|
| 448 |
+
}
|
| 449 |
+
const placements = [initialPlacement, ...fallbackPlacements];
|
| 450 |
+
const overflow = await platform.detectOverflow(state, detectOverflowOptions);
|
| 451 |
+
const overflows = [];
|
| 452 |
+
let overflowsData = ((_middlewareData$flip = middlewareData.flip) == null ? void 0 : _middlewareData$flip.overflows) || [];
|
| 453 |
+
if (checkMainAxis) {
|
| 454 |
+
overflows.push(overflow[side]);
|
| 455 |
+
}
|
| 456 |
+
if (checkCrossAxis) {
|
| 457 |
+
const sides = getAlignmentSides(placement, rects, rtl);
|
| 458 |
+
overflows.push(overflow[sides[0]], overflow[sides[1]]);
|
| 459 |
+
}
|
| 460 |
+
overflowsData = [...overflowsData, {
|
| 461 |
+
placement,
|
| 462 |
+
overflows
|
| 463 |
+
}];
|
| 464 |
+
|
| 465 |
+
// One or more sides is overflowing.
|
| 466 |
+
if (!overflows.every(side => side <= 0)) {
|
| 467 |
+
var _middlewareData$flip2, _overflowsData$filter;
|
| 468 |
+
const nextIndex = (((_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.index) || 0) + 1;
|
| 469 |
+
const nextPlacement = placements[nextIndex];
|
| 470 |
+
if (nextPlacement) {
|
| 471 |
+
const ignoreCrossAxisOverflow = checkCrossAxis === 'alignment' ? initialSideAxis !== getSideAxis(nextPlacement) : false;
|
| 472 |
+
if (!ignoreCrossAxisOverflow ||
|
| 473 |
+
// We leave the current main axis only if every placement on that axis
|
| 474 |
+
// overflows the main axis.
|
| 475 |
+
overflowsData.every(d => getSideAxis(d.placement) === initialSideAxis ? d.overflows[0] > 0 : true)) {
|
| 476 |
+
// Try next placement and re-run the lifecycle.
|
| 477 |
+
return {
|
| 478 |
+
data: {
|
| 479 |
+
index: nextIndex,
|
| 480 |
+
overflows: overflowsData
|
| 481 |
+
},
|
| 482 |
+
reset: {
|
| 483 |
+
placement: nextPlacement
|
| 484 |
+
}
|
| 485 |
+
};
|
| 486 |
+
}
|
| 487 |
+
}
|
| 488 |
+
|
| 489 |
+
// First, find the candidates that fit on the mainAxis side of overflow,
|
| 490 |
+
// then find the placement that fits the best on the main crossAxis side.
|
| 491 |
+
let resetPlacement = (_overflowsData$filter = overflowsData.filter(d => d.overflows[0] <= 0).sort((a, b) => a.overflows[1] - b.overflows[1])[0]) == null ? void 0 : _overflowsData$filter.placement;
|
| 492 |
+
|
| 493 |
+
// Otherwise fallback.
|
| 494 |
+
if (!resetPlacement) {
|
| 495 |
+
switch (fallbackStrategy) {
|
| 496 |
+
case 'bestFit':
|
| 497 |
+
{
|
| 498 |
+
var _overflowsData$filter2;
|
| 499 |
+
const placement = (_overflowsData$filter2 = overflowsData.filter(d => {
|
| 500 |
+
if (hasFallbackAxisSideDirection) {
|
| 501 |
+
const currentSideAxis = getSideAxis(d.placement);
|
| 502 |
+
return currentSideAxis === initialSideAxis ||
|
| 503 |
+
// Create a bias to the `y` side axis due to horizontal
|
| 504 |
+
// reading directions favoring greater width.
|
| 505 |
+
currentSideAxis === 'y';
|
| 506 |
+
}
|
| 507 |
+
return true;
|
| 508 |
+
}).map(d => [d.placement, d.overflows.filter(overflow => overflow > 0).reduce((acc, overflow) => acc + overflow, 0)]).sort((a, b) => a[1] - b[1])[0]) == null ? void 0 : _overflowsData$filter2[0];
|
| 509 |
+
if (placement) {
|
| 510 |
+
resetPlacement = placement;
|
| 511 |
+
}
|
| 512 |
+
break;
|
| 513 |
+
}
|
| 514 |
+
case 'initialPlacement':
|
| 515 |
+
resetPlacement = initialPlacement;
|
| 516 |
+
break;
|
| 517 |
+
}
|
| 518 |
+
}
|
| 519 |
+
if (placement !== resetPlacement) {
|
| 520 |
+
return {
|
| 521 |
+
reset: {
|
| 522 |
+
placement: resetPlacement
|
| 523 |
+
}
|
| 524 |
+
};
|
| 525 |
+
}
|
| 526 |
+
}
|
| 527 |
+
return {};
|
| 528 |
+
}
|
| 529 |
+
};
|
| 530 |
+
};
|
| 531 |
+
|
| 532 |
+
function getSideOffsets(overflow, rect) {
|
| 533 |
+
return {
|
| 534 |
+
top: overflow.top - rect.height,
|
| 535 |
+
right: overflow.right - rect.width,
|
| 536 |
+
bottom: overflow.bottom - rect.height,
|
| 537 |
+
left: overflow.left - rect.width
|
| 538 |
+
};
|
| 539 |
+
}
|
| 540 |
+
function isAnySideFullyClipped(overflow) {
|
| 541 |
+
return sides.some(side => overflow[side] >= 0);
|
| 542 |
+
}
|
| 543 |
+
/**
|
| 544 |
+
* Provides data to hide the floating element in applicable situations, such as
|
| 545 |
+
* when it is not in the same clipping context as the reference element.
|
| 546 |
+
* @see https://floating-ui.com/docs/hide
|
| 547 |
+
*/
|
| 548 |
+
const hide = function (options) {
|
| 549 |
+
if (options === void 0) {
|
| 550 |
+
options = {};
|
| 551 |
+
}
|
| 552 |
+
return {
|
| 553 |
+
name: 'hide',
|
| 554 |
+
options,
|
| 555 |
+
async fn(state) {
|
| 556 |
+
const {
|
| 557 |
+
rects,
|
| 558 |
+
platform
|
| 559 |
+
} = state;
|
| 560 |
+
const {
|
| 561 |
+
strategy = 'referenceHidden',
|
| 562 |
+
...detectOverflowOptions
|
| 563 |
+
} = evaluate(options, state);
|
| 564 |
+
switch (strategy) {
|
| 565 |
+
case 'referenceHidden':
|
| 566 |
+
{
|
| 567 |
+
const overflow = await platform.detectOverflow(state, {
|
| 568 |
+
...detectOverflowOptions,
|
| 569 |
+
elementContext: 'reference'
|
| 570 |
+
});
|
| 571 |
+
const offsets = getSideOffsets(overflow, rects.reference);
|
| 572 |
+
return {
|
| 573 |
+
data: {
|
| 574 |
+
referenceHiddenOffsets: offsets,
|
| 575 |
+
referenceHidden: isAnySideFullyClipped(offsets)
|
| 576 |
+
}
|
| 577 |
+
};
|
| 578 |
+
}
|
| 579 |
+
case 'escaped':
|
| 580 |
+
{
|
| 581 |
+
const overflow = await platform.detectOverflow(state, {
|
| 582 |
+
...detectOverflowOptions,
|
| 583 |
+
altBoundary: true
|
| 584 |
+
});
|
| 585 |
+
const offsets = getSideOffsets(overflow, rects.floating);
|
| 586 |
+
return {
|
| 587 |
+
data: {
|
| 588 |
+
escapedOffsets: offsets,
|
| 589 |
+
escaped: isAnySideFullyClipped(offsets)
|
| 590 |
+
}
|
| 591 |
+
};
|
| 592 |
+
}
|
| 593 |
+
default:
|
| 594 |
+
{
|
| 595 |
+
return {};
|
| 596 |
+
}
|
| 597 |
+
}
|
| 598 |
+
}
|
| 599 |
+
};
|
| 600 |
+
};
|
| 601 |
+
|
| 602 |
+
function getBoundingRect(rects) {
|
| 603 |
+
const minX = min(...rects.map(rect => rect.left));
|
| 604 |
+
const minY = min(...rects.map(rect => rect.top));
|
| 605 |
+
const maxX = max(...rects.map(rect => rect.right));
|
| 606 |
+
const maxY = max(...rects.map(rect => rect.bottom));
|
| 607 |
+
return {
|
| 608 |
+
x: minX,
|
| 609 |
+
y: minY,
|
| 610 |
+
width: maxX - minX,
|
| 611 |
+
height: maxY - minY
|
| 612 |
+
};
|
| 613 |
+
}
|
| 614 |
+
function getRectsByLine(rects) {
|
| 615 |
+
const sortedRects = rects.slice().sort((a, b) => a.y - b.y);
|
| 616 |
+
const groups = [];
|
| 617 |
+
let prevRect = null;
|
| 618 |
+
for (let i = 0; i < sortedRects.length; i++) {
|
| 619 |
+
const rect = sortedRects[i];
|
| 620 |
+
if (!prevRect || rect.y - prevRect.y > prevRect.height / 2) {
|
| 621 |
+
groups.push([rect]);
|
| 622 |
+
} else {
|
| 623 |
+
groups[groups.length - 1].push(rect);
|
| 624 |
+
}
|
| 625 |
+
prevRect = rect;
|
| 626 |
+
}
|
| 627 |
+
return groups.map(rect => rectToClientRect(getBoundingRect(rect)));
|
| 628 |
+
}
|
| 629 |
+
/**
|
| 630 |
+
* Provides improved positioning for inline reference elements that can span
|
| 631 |
+
* over multiple lines, such as hyperlinks or range selections.
|
| 632 |
+
* @see https://floating-ui.com/docs/inline
|
| 633 |
+
*/
|
| 634 |
+
const inline = function (options) {
|
| 635 |
+
if (options === void 0) {
|
| 636 |
+
options = {};
|
| 637 |
+
}
|
| 638 |
+
return {
|
| 639 |
+
name: 'inline',
|
| 640 |
+
options,
|
| 641 |
+
async fn(state) {
|
| 642 |
+
const {
|
| 643 |
+
placement,
|
| 644 |
+
elements,
|
| 645 |
+
rects,
|
| 646 |
+
platform,
|
| 647 |
+
strategy
|
| 648 |
+
} = state;
|
| 649 |
+
// A MouseEvent's client{X,Y} coords can be up to 2 pixels off a
|
| 650 |
+
// ClientRect's bounds, despite the event listener being triggered. A
|
| 651 |
+
// padding of 2 seems to handle this issue.
|
| 652 |
+
const {
|
| 653 |
+
padding = 2,
|
| 654 |
+
x,
|
| 655 |
+
y
|
| 656 |
+
} = evaluate(options, state);
|
| 657 |
+
const nativeClientRects = Array.from((await (platform.getClientRects == null ? void 0 : platform.getClientRects(elements.reference))) || []);
|
| 658 |
+
|
| 659 |
+
// No rects (e.g. a hidden or detached reference, or a collapsed range) —
|
| 660 |
+
// keep the existing reference rect rather than resetting to an invalid
|
| 661 |
+
// one with non-finite values.
|
| 662 |
+
if (!nativeClientRects.length) {
|
| 663 |
+
return {};
|
| 664 |
+
}
|
| 665 |
+
const clientRects = getRectsByLine(nativeClientRects);
|
| 666 |
+
const fallback = rectToClientRect(getBoundingRect(nativeClientRects));
|
| 667 |
+
const paddingObject = getPaddingObject(padding);
|
| 668 |
+
function getBoundingClientRect() {
|
| 669 |
+
// There are two rects and they are disjoined.
|
| 670 |
+
if (clientRects.length === 2 && (clientRects[0].left > clientRects[1].right || clientRects[1].left > clientRects[0].right) && x != null && y != null) {
|
| 671 |
+
// Find the first rect in which the point is fully inside.
|
| 672 |
+
return clientRects.find(rect => x > rect.left - paddingObject.left && x < rect.right + paddingObject.right && y > rect.top - paddingObject.top && y < rect.bottom + paddingObject.bottom) || fallback;
|
| 673 |
+
}
|
| 674 |
+
|
| 675 |
+
// There are 2 or more connected rects.
|
| 676 |
+
if (clientRects.length >= 2) {
|
| 677 |
+
if (getSideAxis(placement) === 'y') {
|
| 678 |
+
const firstRect = clientRects[0];
|
| 679 |
+
const lastRect = clientRects[clientRects.length - 1];
|
| 680 |
+
const isTop = getSide(placement) === 'top';
|
| 681 |
+
const top = firstRect.top;
|
| 682 |
+
const bottom = lastRect.bottom;
|
| 683 |
+
const left = isTop ? firstRect.left : lastRect.left;
|
| 684 |
+
const right = isTop ? firstRect.right : lastRect.right;
|
| 685 |
+
return rectToClientRect({
|
| 686 |
+
x: left,
|
| 687 |
+
y: top,
|
| 688 |
+
width: right - left,
|
| 689 |
+
height: bottom - top
|
| 690 |
+
});
|
| 691 |
+
}
|
| 692 |
+
const isLeftSide = getSide(placement) === 'left';
|
| 693 |
+
const maxRight = max(...clientRects.map(rect => rect.right));
|
| 694 |
+
const minLeft = min(...clientRects.map(rect => rect.left));
|
| 695 |
+
const measureRects = clientRects.filter(rect => isLeftSide ? rect.left === minLeft : rect.right === maxRight);
|
| 696 |
+
const top = measureRects[0].top;
|
| 697 |
+
const bottom = measureRects[measureRects.length - 1].bottom;
|
| 698 |
+
return rectToClientRect({
|
| 699 |
+
x: minLeft,
|
| 700 |
+
y: top,
|
| 701 |
+
width: maxRight - minLeft,
|
| 702 |
+
height: bottom - top
|
| 703 |
+
});
|
| 704 |
+
}
|
| 705 |
+
return fallback;
|
| 706 |
+
}
|
| 707 |
+
const resetRects = await platform.getElementRects({
|
| 708 |
+
reference: {
|
| 709 |
+
getBoundingClientRect
|
| 710 |
+
},
|
| 711 |
+
floating: elements.floating,
|
| 712 |
+
strategy
|
| 713 |
+
});
|
| 714 |
+
if (rects.reference.x !== resetRects.reference.x || rects.reference.y !== resetRects.reference.y || rects.reference.width !== resetRects.reference.width || rects.reference.height !== resetRects.reference.height) {
|
| 715 |
+
return {
|
| 716 |
+
reset: {
|
| 717 |
+
rects: resetRects
|
| 718 |
+
}
|
| 719 |
+
};
|
| 720 |
+
}
|
| 721 |
+
return {};
|
| 722 |
+
}
|
| 723 |
+
};
|
| 724 |
+
};
|
| 725 |
+
|
| 726 |
+
const originSides = /*#__PURE__*/new Set(['left', 'top']);
|
| 727 |
+
|
| 728 |
+
// For type backwards-compatibility, the `OffsetOptions` type was also
|
| 729 |
+
// Derivable.
|
| 730 |
+
|
| 731 |
+
async function convertValueToCoords(state, options) {
|
| 732 |
+
const {
|
| 733 |
+
placement,
|
| 734 |
+
platform,
|
| 735 |
+
elements
|
| 736 |
+
} = state;
|
| 737 |
+
const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating));
|
| 738 |
+
const side = getSide(placement);
|
| 739 |
+
const alignment = getAlignment(placement);
|
| 740 |
+
const isVertical = getSideAxis(placement) === 'y';
|
| 741 |
+
const mainAxisMulti = originSides.has(side) ? -1 : 1;
|
| 742 |
+
const crossAxisMulti = rtl && isVertical ? -1 : 1;
|
| 743 |
+
const rawValue = evaluate(options, state);
|
| 744 |
+
|
| 745 |
+
// eslint-disable-next-line prefer-const
|
| 746 |
+
let {
|
| 747 |
+
mainAxis,
|
| 748 |
+
crossAxis,
|
| 749 |
+
alignmentAxis
|
| 750 |
+
} = typeof rawValue === 'number' ? {
|
| 751 |
+
mainAxis: rawValue,
|
| 752 |
+
crossAxis: 0,
|
| 753 |
+
alignmentAxis: null
|
| 754 |
+
} : {
|
| 755 |
+
mainAxis: rawValue.mainAxis || 0,
|
| 756 |
+
crossAxis: rawValue.crossAxis || 0,
|
| 757 |
+
alignmentAxis: rawValue.alignmentAxis
|
| 758 |
+
};
|
| 759 |
+
if (alignment && typeof alignmentAxis === 'number') {
|
| 760 |
+
crossAxis = alignment === 'end' ? alignmentAxis * -1 : alignmentAxis;
|
| 761 |
+
}
|
| 762 |
+
return isVertical ? {
|
| 763 |
+
x: crossAxis * crossAxisMulti,
|
| 764 |
+
y: mainAxis * mainAxisMulti
|
| 765 |
+
} : {
|
| 766 |
+
x: mainAxis * mainAxisMulti,
|
| 767 |
+
y: crossAxis * crossAxisMulti
|
| 768 |
+
};
|
| 769 |
+
}
|
| 770 |
+
|
| 771 |
+
/**
|
| 772 |
+
* Modifies the placement by translating the floating element along the
|
| 773 |
+
* specified axes.
|
| 774 |
+
* A number (shorthand for `mainAxis` or distance), or an axes configuration
|
| 775 |
+
* object may be passed.
|
| 776 |
+
* @see https://floating-ui.com/docs/offset
|
| 777 |
+
*/
|
| 778 |
+
const offset = function (options) {
|
| 779 |
+
if (options === void 0) {
|
| 780 |
+
options = 0;
|
| 781 |
+
}
|
| 782 |
+
return {
|
| 783 |
+
name: 'offset',
|
| 784 |
+
options,
|
| 785 |
+
async fn(state) {
|
| 786 |
+
var _middlewareData$offse, _middlewareData$arrow;
|
| 787 |
+
const {
|
| 788 |
+
x,
|
| 789 |
+
y,
|
| 790 |
+
placement,
|
| 791 |
+
middlewareData
|
| 792 |
+
} = state;
|
| 793 |
+
const diffCoords = await convertValueToCoords(state, options);
|
| 794 |
+
|
| 795 |
+
// If the placement is the same and the arrow caused an alignment offset
|
| 796 |
+
// then we don't need to change the positioning coordinates.
|
| 797 |
+
if (placement === ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse.placement) && (_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
|
| 798 |
+
return {};
|
| 799 |
+
}
|
| 800 |
+
return {
|
| 801 |
+
x: x + diffCoords.x,
|
| 802 |
+
y: y + diffCoords.y,
|
| 803 |
+
data: {
|
| 804 |
+
...diffCoords,
|
| 805 |
+
placement
|
| 806 |
+
}
|
| 807 |
+
};
|
| 808 |
+
}
|
| 809 |
+
};
|
| 810 |
+
};
|
| 811 |
+
|
| 812 |
+
/**
|
| 813 |
+
* Optimizes the visibility of the floating element by shifting it in order to
|
| 814 |
+
* keep it in view when it will overflow the clipping boundary.
|
| 815 |
+
* @see https://floating-ui.com/docs/shift
|
| 816 |
+
*/
|
| 817 |
+
const shift = function (options) {
|
| 818 |
+
if (options === void 0) {
|
| 819 |
+
options = {};
|
| 820 |
+
}
|
| 821 |
+
return {
|
| 822 |
+
name: 'shift',
|
| 823 |
+
options,
|
| 824 |
+
async fn(state) {
|
| 825 |
+
const {
|
| 826 |
+
x,
|
| 827 |
+
y,
|
| 828 |
+
placement,
|
| 829 |
+
platform
|
| 830 |
+
} = state;
|
| 831 |
+
const {
|
| 832 |
+
mainAxis: checkMainAxis = true,
|
| 833 |
+
crossAxis: checkCrossAxis = false,
|
| 834 |
+
limiter = {
|
| 835 |
+
fn: _ref => {
|
| 836 |
+
let {
|
| 837 |
+
x,
|
| 838 |
+
y
|
| 839 |
+
} = _ref;
|
| 840 |
+
return {
|
| 841 |
+
x,
|
| 842 |
+
y
|
| 843 |
+
};
|
| 844 |
+
}
|
| 845 |
+
},
|
| 846 |
+
...detectOverflowOptions
|
| 847 |
+
} = evaluate(options, state);
|
| 848 |
+
const coords = {
|
| 849 |
+
x,
|
| 850 |
+
y
|
| 851 |
+
};
|
| 852 |
+
const overflow = await platform.detectOverflow(state, detectOverflowOptions);
|
| 853 |
+
const crossAxis = getSideAxis(placement);
|
| 854 |
+
const mainAxis = getOppositeAxis(crossAxis);
|
| 855 |
+
let mainAxisCoord = coords[mainAxis];
|
| 856 |
+
let crossAxisCoord = coords[crossAxis];
|
| 857 |
+
const clampCoord = (axis, coord) => clamp(coord + overflow[axis === 'y' ? 'top' : 'left'], coord, coord - overflow[axis === 'y' ? 'bottom' : 'right']);
|
| 858 |
+
if (checkMainAxis) {
|
| 859 |
+
mainAxisCoord = clampCoord(mainAxis, mainAxisCoord);
|
| 860 |
+
}
|
| 861 |
+
if (checkCrossAxis) {
|
| 862 |
+
crossAxisCoord = clampCoord(crossAxis, crossAxisCoord);
|
| 863 |
+
}
|
| 864 |
+
const limitedCoords = limiter.fn({
|
| 865 |
+
...state,
|
| 866 |
+
[mainAxis]: mainAxisCoord,
|
| 867 |
+
[crossAxis]: crossAxisCoord
|
| 868 |
+
});
|
| 869 |
+
return {
|
| 870 |
+
...limitedCoords,
|
| 871 |
+
data: {
|
| 872 |
+
x: limitedCoords.x - x,
|
| 873 |
+
y: limitedCoords.y - y,
|
| 874 |
+
enabled: {
|
| 875 |
+
[mainAxis]: checkMainAxis,
|
| 876 |
+
[crossAxis]: checkCrossAxis
|
| 877 |
+
}
|
| 878 |
+
}
|
| 879 |
+
};
|
| 880 |
+
}
|
| 881 |
+
};
|
| 882 |
+
};
|
| 883 |
+
/**
|
| 884 |
+
* Built-in `limiter` that will stop `shift()` at a certain point.
|
| 885 |
+
*/
|
| 886 |
+
const limitShift = function (options) {
|
| 887 |
+
if (options === void 0) {
|
| 888 |
+
options = {};
|
| 889 |
+
}
|
| 890 |
+
return {
|
| 891 |
+
options,
|
| 892 |
+
fn(state) {
|
| 893 |
+
var _rawOffset$mainAxis, _rawOffset$crossAxis;
|
| 894 |
+
const {
|
| 895 |
+
x,
|
| 896 |
+
y,
|
| 897 |
+
placement,
|
| 898 |
+
rects,
|
| 899 |
+
middlewareData
|
| 900 |
+
} = state;
|
| 901 |
+
const {
|
| 902 |
+
offset = 0,
|
| 903 |
+
mainAxis: checkMainAxis = true,
|
| 904 |
+
crossAxis: checkCrossAxis = true
|
| 905 |
+
} = evaluate(options, state);
|
| 906 |
+
const coords = {
|
| 907 |
+
x,
|
| 908 |
+
y
|
| 909 |
+
};
|
| 910 |
+
const crossAxis = getSideAxis(placement);
|
| 911 |
+
const mainAxis = getOppositeAxis(crossAxis);
|
| 912 |
+
let mainAxisCoord = coords[mainAxis];
|
| 913 |
+
let crossAxisCoord = coords[crossAxis];
|
| 914 |
+
const rawOffset = evaluate(offset, state);
|
| 915 |
+
const computedOffset = typeof rawOffset === 'number' ? {
|
| 916 |
+
mainAxis: rawOffset,
|
| 917 |
+
crossAxis: 0
|
| 918 |
+
} : {
|
| 919 |
+
mainAxis: (_rawOffset$mainAxis = rawOffset.mainAxis) != null ? _rawOffset$mainAxis : 0,
|
| 920 |
+
crossAxis: (_rawOffset$crossAxis = rawOffset.crossAxis) != null ? _rawOffset$crossAxis : 0
|
| 921 |
+
};
|
| 922 |
+
if (checkMainAxis) {
|
| 923 |
+
const len = mainAxis === 'y' ? 'height' : 'width';
|
| 924 |
+
const limitMin = rects.reference[mainAxis] - rects.floating[len] + computedOffset.mainAxis;
|
| 925 |
+
const limitMax = rects.reference[mainAxis] + rects.reference[len] - computedOffset.mainAxis;
|
| 926 |
+
if (mainAxisCoord < limitMin) {
|
| 927 |
+
mainAxisCoord = limitMin;
|
| 928 |
+
} else if (mainAxisCoord > limitMax) {
|
| 929 |
+
mainAxisCoord = limitMax;
|
| 930 |
+
}
|
| 931 |
+
}
|
| 932 |
+
if (checkCrossAxis) {
|
| 933 |
+
var _middlewareData$offse, _middlewareData$offse2;
|
| 934 |
+
const len = mainAxis === 'y' ? 'width' : 'height';
|
| 935 |
+
const isOriginSide = originSides.has(getSide(placement));
|
| 936 |
+
const limitMin = rects.reference[crossAxis] - rects.floating[len] + (isOriginSide ? ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse[crossAxis]) || 0 : 0) + (isOriginSide ? 0 : computedOffset.crossAxis);
|
| 937 |
+
const limitMax = rects.reference[crossAxis] + rects.reference[len] + (isOriginSide ? 0 : ((_middlewareData$offse2 = middlewareData.offset) == null ? void 0 : _middlewareData$offse2[crossAxis]) || 0) - (isOriginSide ? computedOffset.crossAxis : 0);
|
| 938 |
+
if (crossAxisCoord < limitMin) {
|
| 939 |
+
crossAxisCoord = limitMin;
|
| 940 |
+
} else if (crossAxisCoord > limitMax) {
|
| 941 |
+
crossAxisCoord = limitMax;
|
| 942 |
+
}
|
| 943 |
+
}
|
| 944 |
+
return {
|
| 945 |
+
[mainAxis]: mainAxisCoord,
|
| 946 |
+
[crossAxis]: crossAxisCoord
|
| 947 |
+
};
|
| 948 |
+
}
|
| 949 |
+
};
|
| 950 |
+
};
|
| 951 |
+
|
| 952 |
+
// Method syntax keeps callback parameters bivariant, but expressing the
|
| 953 |
+
// explicit `| undefined` required by `exactOptionalPropertyTypes` needs
|
| 954 |
+
// property syntax, which is contravariant under `strictFunctionTypes`.
|
| 955 |
+
// Extracting the function from a method position restores that bivariance so
|
| 956 |
+
// consumers can still assign callbacks with narrower parameter types.
|
| 957 |
+
|
| 958 |
+
/**
|
| 959 |
+
* Provides data that allows you to change the size of the floating element —
|
| 960 |
+
* for instance, prevent it from overflowing the clipping boundary or match the
|
| 961 |
+
* width of the reference element.
|
| 962 |
+
* @see https://floating-ui.com/docs/size
|
| 963 |
+
*/
|
| 964 |
+
const size = function (options) {
|
| 965 |
+
if (options === void 0) {
|
| 966 |
+
options = {};
|
| 967 |
+
}
|
| 968 |
+
return {
|
| 969 |
+
name: 'size',
|
| 970 |
+
options,
|
| 971 |
+
async fn(state) {
|
| 972 |
+
const {
|
| 973 |
+
placement,
|
| 974 |
+
rects,
|
| 975 |
+
platform,
|
| 976 |
+
elements
|
| 977 |
+
} = state;
|
| 978 |
+
const {
|
| 979 |
+
apply = () => {},
|
| 980 |
+
...detectOverflowOptions
|
| 981 |
+
} = evaluate(options, state);
|
| 982 |
+
const overflow = await platform.detectOverflow(state, detectOverflowOptions);
|
| 983 |
+
const side = getSide(placement);
|
| 984 |
+
const alignment = getAlignment(placement);
|
| 985 |
+
const isYAxis = getSideAxis(placement) === 'y';
|
| 986 |
+
const {
|
| 987 |
+
width,
|
| 988 |
+
height
|
| 989 |
+
} = rects.floating;
|
| 990 |
+
let heightSide;
|
| 991 |
+
let widthSide;
|
| 992 |
+
if (side === 'top' || side === 'bottom') {
|
| 993 |
+
heightSide = side;
|
| 994 |
+
widthSide = alignment === ((await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating))) ? 'start' : 'end') ? 'left' : 'right';
|
| 995 |
+
} else {
|
| 996 |
+
widthSide = side;
|
| 997 |
+
heightSide = alignment === 'end' ? 'top' : 'bottom';
|
| 998 |
+
}
|
| 999 |
+
const maximumClippingHeight = height - overflow.top - overflow.bottom;
|
| 1000 |
+
const maximumClippingWidth = width - overflow.left - overflow.right;
|
| 1001 |
+
const overflowAvailableHeight = min(height - overflow[heightSide], maximumClippingHeight);
|
| 1002 |
+
const overflowAvailableWidth = min(width - overflow[widthSide], maximumClippingWidth);
|
| 1003 |
+
const shiftData = state.middlewareData.shift;
|
| 1004 |
+
const noShift = !shiftData;
|
| 1005 |
+
let availableHeight = overflowAvailableHeight;
|
| 1006 |
+
let availableWidth = overflowAvailableWidth;
|
| 1007 |
+
if (shiftData != null && shiftData.enabled.x) {
|
| 1008 |
+
availableWidth = maximumClippingWidth;
|
| 1009 |
+
}
|
| 1010 |
+
if (shiftData != null && shiftData.enabled.y) {
|
| 1011 |
+
availableHeight = maximumClippingHeight;
|
| 1012 |
+
}
|
| 1013 |
+
if (noShift && !alignment) {
|
| 1014 |
+
if (isYAxis) {
|
| 1015 |
+
availableWidth = width - 2 * max(overflow.left, overflow.right);
|
| 1016 |
+
} else {
|
| 1017 |
+
availableHeight = height - 2 * max(overflow.top, overflow.bottom);
|
| 1018 |
+
}
|
| 1019 |
+
}
|
| 1020 |
+
await apply({
|
| 1021 |
+
...state,
|
| 1022 |
+
availableWidth,
|
| 1023 |
+
availableHeight
|
| 1024 |
+
});
|
| 1025 |
+
const nextDimensions = await platform.getDimensions(elements.floating);
|
| 1026 |
+
if (width !== nextDimensions.width || height !== nextDimensions.height) {
|
| 1027 |
+
return {
|
| 1028 |
+
reset: {
|
| 1029 |
+
rects: true
|
| 1030 |
+
}
|
| 1031 |
+
};
|
| 1032 |
+
}
|
| 1033 |
+
return {};
|
| 1034 |
+
}
|
| 1035 |
+
};
|
| 1036 |
+
};
|
| 1037 |
+
|
| 1038 |
+
export { arrow, autoPlacement, computePosition, detectOverflow, flip, hide, inline, limitShift, offset, shift, size };
|
e-commerce/node_modules/@floating-ui/core/dist/floating-ui.core.umd.js
ADDED
|
@@ -0,0 +1,1183 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
(function (global, factory) {
|
| 2 |
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
|
| 3 |
+
typeof define === 'function' && define.amd ? define(['exports'], factory) :
|
| 4 |
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.FloatingUICore = {}));
|
| 5 |
+
})(this, (function (exports) { 'use strict';
|
| 6 |
+
|
| 7 |
+
/**
|
| 8 |
+
* Custom positioning reference element.
|
| 9 |
+
* @see https://floating-ui.com/docs/virtual-elements
|
| 10 |
+
*/
|
| 11 |
+
|
| 12 |
+
const sides = ['top', 'right', 'bottom', 'left'];
|
| 13 |
+
const alignments = ['start', 'end'];
|
| 14 |
+
const placements = /*#__PURE__*/sides.reduce((acc, side) => acc.concat(side, side + "-" + alignments[0], side + "-" + alignments[1]), []);
|
| 15 |
+
const min = Math.min;
|
| 16 |
+
const max = Math.max;
|
| 17 |
+
const oppositeSideMap = {
|
| 18 |
+
left: 'right',
|
| 19 |
+
right: 'left',
|
| 20 |
+
bottom: 'top',
|
| 21 |
+
top: 'bottom'
|
| 22 |
+
};
|
| 23 |
+
function clamp(start, value, end) {
|
| 24 |
+
return max(start, min(value, end));
|
| 25 |
+
}
|
| 26 |
+
function evaluate(value, param) {
|
| 27 |
+
return typeof value === 'function' ? value(param) : value;
|
| 28 |
+
}
|
| 29 |
+
function getSide(placement) {
|
| 30 |
+
return placement.split('-')[0];
|
| 31 |
+
}
|
| 32 |
+
function getAlignment(placement) {
|
| 33 |
+
return placement.split('-')[1];
|
| 34 |
+
}
|
| 35 |
+
function getOppositeAxis(axis) {
|
| 36 |
+
return axis === 'x' ? 'y' : 'x';
|
| 37 |
+
}
|
| 38 |
+
function getAxisLength(axis) {
|
| 39 |
+
return axis === 'y' ? 'height' : 'width';
|
| 40 |
+
}
|
| 41 |
+
function getSideAxis(placement) {
|
| 42 |
+
const firstChar = placement[0];
|
| 43 |
+
return firstChar === 't' || firstChar === 'b' ? 'y' : 'x';
|
| 44 |
+
}
|
| 45 |
+
function getAlignmentAxis(placement) {
|
| 46 |
+
return getOppositeAxis(getSideAxis(placement));
|
| 47 |
+
}
|
| 48 |
+
function getAlignmentSides(placement, rects, rtl) {
|
| 49 |
+
if (rtl === void 0) {
|
| 50 |
+
rtl = false;
|
| 51 |
+
}
|
| 52 |
+
const alignment = getAlignment(placement);
|
| 53 |
+
const alignmentAxis = getAlignmentAxis(placement);
|
| 54 |
+
const length = getAxisLength(alignmentAxis);
|
| 55 |
+
let mainAlignmentSide = alignmentAxis === 'x' ? alignment === (rtl ? 'end' : 'start') ? 'right' : 'left' : alignment === 'start' ? 'bottom' : 'top';
|
| 56 |
+
if (rects.reference[length] > rects.floating[length]) {
|
| 57 |
+
mainAlignmentSide = getOppositePlacement(mainAlignmentSide);
|
| 58 |
+
}
|
| 59 |
+
return [mainAlignmentSide, getOppositePlacement(mainAlignmentSide)];
|
| 60 |
+
}
|
| 61 |
+
function getExpandedPlacements(placement) {
|
| 62 |
+
const oppositePlacement = getOppositePlacement(placement);
|
| 63 |
+
return [getOppositeAlignmentPlacement(placement), oppositePlacement, getOppositeAlignmentPlacement(oppositePlacement)];
|
| 64 |
+
}
|
| 65 |
+
function getOppositeAlignmentPlacement(placement) {
|
| 66 |
+
return placement.includes('start') ? placement.replace('start', 'end') : placement.replace('end', 'start');
|
| 67 |
+
}
|
| 68 |
+
const lrPlacement = ['left', 'right'];
|
| 69 |
+
const rlPlacement = ['right', 'left'];
|
| 70 |
+
const tbPlacement = ['top', 'bottom'];
|
| 71 |
+
const btPlacement = ['bottom', 'top'];
|
| 72 |
+
function getSideList(side, isStart, rtl) {
|
| 73 |
+
switch (side) {
|
| 74 |
+
case 'top':
|
| 75 |
+
case 'bottom':
|
| 76 |
+
if (rtl) return isStart ? rlPlacement : lrPlacement;
|
| 77 |
+
return isStart ? lrPlacement : rlPlacement;
|
| 78 |
+
case 'left':
|
| 79 |
+
case 'right':
|
| 80 |
+
return isStart ? tbPlacement : btPlacement;
|
| 81 |
+
default:
|
| 82 |
+
return [];
|
| 83 |
+
}
|
| 84 |
+
}
|
| 85 |
+
function getOppositeAxisPlacements(placement, flipAlignment, direction, rtl) {
|
| 86 |
+
const alignment = getAlignment(placement);
|
| 87 |
+
let list = getSideList(getSide(placement), direction === 'start', rtl);
|
| 88 |
+
if (alignment) {
|
| 89 |
+
list = list.map(side => side + "-" + alignment);
|
| 90 |
+
if (flipAlignment) {
|
| 91 |
+
list = list.concat(list.map(getOppositeAlignmentPlacement));
|
| 92 |
+
}
|
| 93 |
+
}
|
| 94 |
+
return list;
|
| 95 |
+
}
|
| 96 |
+
function getOppositePlacement(placement) {
|
| 97 |
+
const side = getSide(placement);
|
| 98 |
+
return oppositeSideMap[side] + placement.slice(side.length);
|
| 99 |
+
}
|
| 100 |
+
function expandPaddingObject(padding) {
|
| 101 |
+
var _padding$top, _padding$right, _padding$bottom, _padding$left;
|
| 102 |
+
return {
|
| 103 |
+
top: (_padding$top = padding.top) != null ? _padding$top : 0,
|
| 104 |
+
right: (_padding$right = padding.right) != null ? _padding$right : 0,
|
| 105 |
+
bottom: (_padding$bottom = padding.bottom) != null ? _padding$bottom : 0,
|
| 106 |
+
left: (_padding$left = padding.left) != null ? _padding$left : 0
|
| 107 |
+
};
|
| 108 |
+
}
|
| 109 |
+
function getPaddingObject(padding) {
|
| 110 |
+
return typeof padding !== 'number' ? expandPaddingObject(padding) : {
|
| 111 |
+
top: padding,
|
| 112 |
+
right: padding,
|
| 113 |
+
bottom: padding,
|
| 114 |
+
left: padding
|
| 115 |
+
};
|
| 116 |
+
}
|
| 117 |
+
function rectToClientRect(rect) {
|
| 118 |
+
const {
|
| 119 |
+
x,
|
| 120 |
+
y,
|
| 121 |
+
width,
|
| 122 |
+
height
|
| 123 |
+
} = rect;
|
| 124 |
+
return {
|
| 125 |
+
width,
|
| 126 |
+
height,
|
| 127 |
+
top: y,
|
| 128 |
+
left: x,
|
| 129 |
+
right: x + width,
|
| 130 |
+
bottom: y + height,
|
| 131 |
+
x,
|
| 132 |
+
y
|
| 133 |
+
};
|
| 134 |
+
}
|
| 135 |
+
|
| 136 |
+
function computeCoordsFromPlacement(_ref, placement, rtl) {
|
| 137 |
+
let {
|
| 138 |
+
reference,
|
| 139 |
+
floating
|
| 140 |
+
} = _ref;
|
| 141 |
+
const sideAxis = getSideAxis(placement);
|
| 142 |
+
const alignmentAxis = getAlignmentAxis(placement);
|
| 143 |
+
const alignLength = getAxisLength(alignmentAxis);
|
| 144 |
+
const side = getSide(placement);
|
| 145 |
+
const isVertical = sideAxis === 'y';
|
| 146 |
+
const commonX = reference.x + reference.width / 2 - floating.width / 2;
|
| 147 |
+
const commonY = reference.y + reference.height / 2 - floating.height / 2;
|
| 148 |
+
const commonAlign = reference[alignLength] / 2 - floating[alignLength] / 2;
|
| 149 |
+
let coords;
|
| 150 |
+
switch (side) {
|
| 151 |
+
case 'top':
|
| 152 |
+
coords = {
|
| 153 |
+
x: commonX,
|
| 154 |
+
y: reference.y - floating.height
|
| 155 |
+
};
|
| 156 |
+
break;
|
| 157 |
+
case 'bottom':
|
| 158 |
+
coords = {
|
| 159 |
+
x: commonX,
|
| 160 |
+
y: reference.y + reference.height
|
| 161 |
+
};
|
| 162 |
+
break;
|
| 163 |
+
case 'right':
|
| 164 |
+
coords = {
|
| 165 |
+
x: reference.x + reference.width,
|
| 166 |
+
y: commonY
|
| 167 |
+
};
|
| 168 |
+
break;
|
| 169 |
+
case 'left':
|
| 170 |
+
coords = {
|
| 171 |
+
x: reference.x - floating.width,
|
| 172 |
+
y: commonY
|
| 173 |
+
};
|
| 174 |
+
break;
|
| 175 |
+
default:
|
| 176 |
+
coords = {
|
| 177 |
+
x: reference.x,
|
| 178 |
+
y: reference.y
|
| 179 |
+
};
|
| 180 |
+
}
|
| 181 |
+
const alignment = getAlignment(placement);
|
| 182 |
+
if (alignment) {
|
| 183 |
+
coords[alignmentAxis] += commonAlign * (alignment === 'end' ? 1 : -1) * (rtl && isVertical ? -1 : 1);
|
| 184 |
+
}
|
| 185 |
+
return coords;
|
| 186 |
+
}
|
| 187 |
+
|
| 188 |
+
/**
|
| 189 |
+
* Resolves with an object of overflow side offsets that determine how much the
|
| 190 |
+
* element is overflowing a given clipping boundary on each side.
|
| 191 |
+
* - positive = overflowing the boundary by that number of pixels
|
| 192 |
+
* - negative = how many pixels left before it will overflow
|
| 193 |
+
* - 0 = lies flush with the boundary
|
| 194 |
+
* @see https://floating-ui.com/docs/detectOverflow
|
| 195 |
+
*/
|
| 196 |
+
async function detectOverflow(state, options) {
|
| 197 |
+
var _await$platform$isEle;
|
| 198 |
+
if (options === void 0) {
|
| 199 |
+
options = {};
|
| 200 |
+
}
|
| 201 |
+
const {
|
| 202 |
+
x,
|
| 203 |
+
y,
|
| 204 |
+
platform,
|
| 205 |
+
rects,
|
| 206 |
+
elements,
|
| 207 |
+
strategy
|
| 208 |
+
} = state;
|
| 209 |
+
const {
|
| 210 |
+
boundary = 'clippingAncestors',
|
| 211 |
+
rootBoundary = 'viewport',
|
| 212 |
+
elementContext = 'floating',
|
| 213 |
+
altBoundary = false,
|
| 214 |
+
padding = 0
|
| 215 |
+
} = evaluate(options, state);
|
| 216 |
+
const paddingObject = getPaddingObject(padding);
|
| 217 |
+
const altContext = elementContext === 'floating' ? 'reference' : 'floating';
|
| 218 |
+
const element = elements[altBoundary ? altContext : elementContext];
|
| 219 |
+
const clippingClientRect = rectToClientRect(await platform.getClippingRect({
|
| 220 |
+
element: ((_await$platform$isEle = await (platform.isElement == null ? void 0 : platform.isElement(element))) != null ? _await$platform$isEle : true) ? element : element.contextElement || (await (platform.getDocumentElement == null ? void 0 : platform.getDocumentElement(elements.floating))),
|
| 221 |
+
boundary,
|
| 222 |
+
rootBoundary,
|
| 223 |
+
strategy
|
| 224 |
+
}));
|
| 225 |
+
const rect = elementContext === 'floating' ? {
|
| 226 |
+
x,
|
| 227 |
+
y,
|
| 228 |
+
width: rects.floating.width,
|
| 229 |
+
height: rects.floating.height
|
| 230 |
+
} : rects.reference;
|
| 231 |
+
const offsetParent = await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(elements.floating));
|
| 232 |
+
const offsetScale = (await (platform.isElement == null ? void 0 : platform.isElement(offsetParent))) && (await (platform.getScale == null ? void 0 : platform.getScale(offsetParent))) || {
|
| 233 |
+
x: 1,
|
| 234 |
+
y: 1
|
| 235 |
+
};
|
| 236 |
+
const elementClientRect = rectToClientRect(platform.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform.convertOffsetParentRelativeRectToViewportRelativeRect({
|
| 237 |
+
elements,
|
| 238 |
+
rect,
|
| 239 |
+
offsetParent,
|
| 240 |
+
strategy
|
| 241 |
+
}) : rect);
|
| 242 |
+
return {
|
| 243 |
+
top: (clippingClientRect.top - elementClientRect.top + paddingObject.top) / offsetScale.y,
|
| 244 |
+
bottom: (elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom) / offsetScale.y,
|
| 245 |
+
left: (clippingClientRect.left - elementClientRect.left + paddingObject.left) / offsetScale.x,
|
| 246 |
+
right: (elementClientRect.right - clippingClientRect.right + paddingObject.right) / offsetScale.x
|
| 247 |
+
};
|
| 248 |
+
}
|
| 249 |
+
|
| 250 |
+
// Maximum number of resets that can occur before bailing to avoid infinite reset loops.
|
| 251 |
+
const MAX_RESET_COUNT = 50;
|
| 252 |
+
|
| 253 |
+
/**
|
| 254 |
+
* Computes the `x` and `y` coordinates that will place the floating element
|
| 255 |
+
* next to a given reference element.
|
| 256 |
+
*
|
| 257 |
+
* This export does not have any `platform` interface logic. You will need to
|
| 258 |
+
* write one for the platform you are using Floating UI with.
|
| 259 |
+
*/
|
| 260 |
+
const computePosition = async (reference, floating, config) => {
|
| 261 |
+
const {
|
| 262 |
+
placement = 'bottom',
|
| 263 |
+
strategy = 'absolute',
|
| 264 |
+
middleware = [],
|
| 265 |
+
platform
|
| 266 |
+
} = config;
|
| 267 |
+
const platformWithDetectOverflow = platform.detectOverflow ? platform : {
|
| 268 |
+
...platform,
|
| 269 |
+
detectOverflow
|
| 270 |
+
};
|
| 271 |
+
const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(floating));
|
| 272 |
+
let rects = await platform.getElementRects({
|
| 273 |
+
reference,
|
| 274 |
+
floating,
|
| 275 |
+
strategy
|
| 276 |
+
});
|
| 277 |
+
let {
|
| 278 |
+
x,
|
| 279 |
+
y
|
| 280 |
+
} = computeCoordsFromPlacement(rects, placement, rtl);
|
| 281 |
+
let statefulPlacement = placement;
|
| 282 |
+
let resetCount = 0;
|
| 283 |
+
const middlewareData = {};
|
| 284 |
+
for (let i = 0; i < middleware.length; i++) {
|
| 285 |
+
const currentMiddleware = middleware[i];
|
| 286 |
+
if (!currentMiddleware) {
|
| 287 |
+
continue;
|
| 288 |
+
}
|
| 289 |
+
const {
|
| 290 |
+
name,
|
| 291 |
+
fn
|
| 292 |
+
} = currentMiddleware;
|
| 293 |
+
const {
|
| 294 |
+
x: nextX,
|
| 295 |
+
y: nextY,
|
| 296 |
+
data,
|
| 297 |
+
reset
|
| 298 |
+
} = await fn({
|
| 299 |
+
x,
|
| 300 |
+
y,
|
| 301 |
+
initialPlacement: placement,
|
| 302 |
+
placement: statefulPlacement,
|
| 303 |
+
strategy,
|
| 304 |
+
middlewareData,
|
| 305 |
+
rects,
|
| 306 |
+
platform: platformWithDetectOverflow,
|
| 307 |
+
elements: {
|
| 308 |
+
reference,
|
| 309 |
+
floating
|
| 310 |
+
}
|
| 311 |
+
});
|
| 312 |
+
x = nextX != null ? nextX : x;
|
| 313 |
+
y = nextY != null ? nextY : y;
|
| 314 |
+
middlewareData[name] = {
|
| 315 |
+
...middlewareData[name],
|
| 316 |
+
...data
|
| 317 |
+
};
|
| 318 |
+
if (reset && resetCount < MAX_RESET_COUNT) {
|
| 319 |
+
resetCount++;
|
| 320 |
+
if (typeof reset === 'object') {
|
| 321 |
+
if (reset.placement) {
|
| 322 |
+
statefulPlacement = reset.placement;
|
| 323 |
+
}
|
| 324 |
+
if (reset.rects) {
|
| 325 |
+
rects = reset.rects === true ? await platform.getElementRects({
|
| 326 |
+
reference,
|
| 327 |
+
floating,
|
| 328 |
+
strategy
|
| 329 |
+
}) : reset.rects;
|
| 330 |
+
}
|
| 331 |
+
({
|
| 332 |
+
x,
|
| 333 |
+
y
|
| 334 |
+
} = computeCoordsFromPlacement(rects, statefulPlacement, rtl));
|
| 335 |
+
}
|
| 336 |
+
i = -1;
|
| 337 |
+
}
|
| 338 |
+
}
|
| 339 |
+
return {
|
| 340 |
+
x,
|
| 341 |
+
y,
|
| 342 |
+
placement: statefulPlacement,
|
| 343 |
+
strategy,
|
| 344 |
+
middlewareData
|
| 345 |
+
};
|
| 346 |
+
};
|
| 347 |
+
|
| 348 |
+
/**
|
| 349 |
+
* Provides data to position an inner element of the floating element so that it
|
| 350 |
+
* appears centered to the reference element.
|
| 351 |
+
* @see https://floating-ui.com/docs/arrow
|
| 352 |
+
*/
|
| 353 |
+
const arrow = options => ({
|
| 354 |
+
name: 'arrow',
|
| 355 |
+
options,
|
| 356 |
+
async fn(state) {
|
| 357 |
+
const {
|
| 358 |
+
x,
|
| 359 |
+
y,
|
| 360 |
+
placement,
|
| 361 |
+
rects,
|
| 362 |
+
platform,
|
| 363 |
+
elements,
|
| 364 |
+
middlewareData
|
| 365 |
+
} = state;
|
| 366 |
+
// Since `element` is required, we don't Partial<> the type.
|
| 367 |
+
const {
|
| 368 |
+
element,
|
| 369 |
+
padding = 0
|
| 370 |
+
} = evaluate(options, state) || {};
|
| 371 |
+
if (element == null) {
|
| 372 |
+
return {};
|
| 373 |
+
}
|
| 374 |
+
const paddingObject = getPaddingObject(padding);
|
| 375 |
+
const coords = {
|
| 376 |
+
x,
|
| 377 |
+
y
|
| 378 |
+
};
|
| 379 |
+
const axis = getAlignmentAxis(placement);
|
| 380 |
+
const length = getAxisLength(axis);
|
| 381 |
+
const arrowDimensions = await platform.getDimensions(element);
|
| 382 |
+
const isYAxis = axis === 'y';
|
| 383 |
+
const minProp = isYAxis ? 'top' : 'left';
|
| 384 |
+
const maxProp = isYAxis ? 'bottom' : 'right';
|
| 385 |
+
const clientProp = isYAxis ? 'clientHeight' : 'clientWidth';
|
| 386 |
+
const endDiff = rects.reference[length] + rects.reference[axis] - coords[axis] - rects.floating[length];
|
| 387 |
+
const startDiff = coords[axis] - rects.reference[axis];
|
| 388 |
+
const arrowOffsetParent = await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(element));
|
| 389 |
+
let clientSize = arrowOffsetParent ? arrowOffsetParent[clientProp] : 0;
|
| 390 |
+
|
| 391 |
+
// DOM platform can return `window` as the `offsetParent`.
|
| 392 |
+
if (!clientSize || !(await (platform.isElement == null ? void 0 : platform.isElement(arrowOffsetParent)))) {
|
| 393 |
+
clientSize = elements.floating[clientProp] || rects.floating[length];
|
| 394 |
+
}
|
| 395 |
+
const centerToReference = endDiff / 2 - startDiff / 2;
|
| 396 |
+
|
| 397 |
+
// If the padding is large enough that it causes the arrow to no longer be
|
| 398 |
+
// centered, modify the padding so that it is centered.
|
| 399 |
+
const largestPossiblePadding = clientSize / 2 - arrowDimensions[length] / 2 - 1;
|
| 400 |
+
const minPadding = min(paddingObject[minProp], largestPossiblePadding);
|
| 401 |
+
const maxPadding = min(paddingObject[maxProp], largestPossiblePadding);
|
| 402 |
+
|
| 403 |
+
// Make sure the arrow doesn't overflow the floating element if the center
|
| 404 |
+
// point is outside the floating element's bounds.
|
| 405 |
+
const max = clientSize - arrowDimensions[length] - maxPadding;
|
| 406 |
+
const center = clientSize / 2 - arrowDimensions[length] / 2 + centerToReference;
|
| 407 |
+
const offset = clamp(minPadding, center, max);
|
| 408 |
+
|
| 409 |
+
// If the reference is small enough that the arrow's padding causes it to
|
| 410 |
+
// to point to nothing for an aligned placement, adjust the offset of the
|
| 411 |
+
// floating element itself. To ensure `shift()` continues to take action,
|
| 412 |
+
// a single reset is performed when this is true.
|
| 413 |
+
const shouldAddOffset = !middlewareData.arrow && getAlignment(placement) != null && center !== offset && rects.reference[length] / 2 - (center < minPadding ? minPadding : maxPadding) - arrowDimensions[length] / 2 < 0;
|
| 414 |
+
const alignmentOffset = shouldAddOffset ? center < minPadding ? center - minPadding : center - max : 0;
|
| 415 |
+
return {
|
| 416 |
+
[axis]: coords[axis] + alignmentOffset,
|
| 417 |
+
data: {
|
| 418 |
+
[axis]: offset,
|
| 419 |
+
centerOffset: center - offset - alignmentOffset,
|
| 420 |
+
...(shouldAddOffset && {
|
| 421 |
+
alignmentOffset
|
| 422 |
+
})
|
| 423 |
+
},
|
| 424 |
+
reset: shouldAddOffset
|
| 425 |
+
};
|
| 426 |
+
}
|
| 427 |
+
});
|
| 428 |
+
|
| 429 |
+
function getPlacementList(alignment, autoAlignment, allowedPlacements) {
|
| 430 |
+
const allowedPlacementsSortedByAlignment = alignment ? [...allowedPlacements.filter(placement => getAlignment(placement) === alignment), ...allowedPlacements.filter(placement => getAlignment(placement) !== alignment)] : allowedPlacements.filter(placement => getSide(placement) === placement);
|
| 431 |
+
return allowedPlacementsSortedByAlignment.filter(placement => {
|
| 432 |
+
if (alignment) {
|
| 433 |
+
return getAlignment(placement) === alignment || (autoAlignment ? getOppositeAlignmentPlacement(placement) !== placement : false);
|
| 434 |
+
}
|
| 435 |
+
return true;
|
| 436 |
+
});
|
| 437 |
+
}
|
| 438 |
+
/**
|
| 439 |
+
* Optimizes the visibility of the floating element by choosing the placement
|
| 440 |
+
* that has the most space available automatically, without needing to specify a
|
| 441 |
+
* preferred placement. Alternative to `flip`.
|
| 442 |
+
* @see https://floating-ui.com/docs/autoPlacement
|
| 443 |
+
*/
|
| 444 |
+
const autoPlacement = function (options) {
|
| 445 |
+
if (options === void 0) {
|
| 446 |
+
options = {};
|
| 447 |
+
}
|
| 448 |
+
return {
|
| 449 |
+
name: 'autoPlacement',
|
| 450 |
+
options,
|
| 451 |
+
async fn(state) {
|
| 452 |
+
var _middlewareData$autoP, _middlewareData$autoP2, _placementsThatFitOnE;
|
| 453 |
+
const {
|
| 454 |
+
rects,
|
| 455 |
+
middlewareData,
|
| 456 |
+
placement,
|
| 457 |
+
platform,
|
| 458 |
+
elements
|
| 459 |
+
} = state;
|
| 460 |
+
const {
|
| 461 |
+
crossAxis = false,
|
| 462 |
+
alignment,
|
| 463 |
+
allowedPlacements = placements,
|
| 464 |
+
autoAlignment = true,
|
| 465 |
+
...detectOverflowOptions
|
| 466 |
+
} = evaluate(options, state);
|
| 467 |
+
const placements$1 = alignment !== undefined || allowedPlacements === placements ? getPlacementList(alignment || null, autoAlignment, allowedPlacements) : allowedPlacements;
|
| 468 |
+
const currentIndex = ((_middlewareData$autoP = middlewareData.autoPlacement) == null ? void 0 : _middlewareData$autoP.index) || 0;
|
| 469 |
+
const currentPlacement = placements$1[currentIndex];
|
| 470 |
+
if (currentPlacement == null) {
|
| 471 |
+
return {};
|
| 472 |
+
}
|
| 473 |
+
|
| 474 |
+
// Make `computeCoords` start from the right place.
|
| 475 |
+
if (placement !== currentPlacement) {
|
| 476 |
+
return {
|
| 477 |
+
reset: {
|
| 478 |
+
placement: placements$1[0]
|
| 479 |
+
}
|
| 480 |
+
};
|
| 481 |
+
}
|
| 482 |
+
const overflow = await platform.detectOverflow(state, detectOverflowOptions);
|
| 483 |
+
const alignmentSides = getAlignmentSides(currentPlacement, rects, await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating)));
|
| 484 |
+
const currentOverflows = [overflow[getSide(currentPlacement)], overflow[alignmentSides[0]], overflow[alignmentSides[1]]];
|
| 485 |
+
const allOverflows = [...(((_middlewareData$autoP2 = middlewareData.autoPlacement) == null ? void 0 : _middlewareData$autoP2.overflows) || []), {
|
| 486 |
+
placement: currentPlacement,
|
| 487 |
+
overflows: currentOverflows
|
| 488 |
+
}];
|
| 489 |
+
const nextPlacement = placements$1[currentIndex + 1];
|
| 490 |
+
|
| 491 |
+
// There are more placements to check.
|
| 492 |
+
if (nextPlacement) {
|
| 493 |
+
return {
|
| 494 |
+
data: {
|
| 495 |
+
index: currentIndex + 1,
|
| 496 |
+
overflows: allOverflows
|
| 497 |
+
},
|
| 498 |
+
reset: {
|
| 499 |
+
placement: nextPlacement
|
| 500 |
+
}
|
| 501 |
+
};
|
| 502 |
+
}
|
| 503 |
+
const placementsSortedByMostSpace = allOverflows.map(d => {
|
| 504 |
+
const alignment = getAlignment(d.placement);
|
| 505 |
+
return [d.placement, alignment && crossAxis ?
|
| 506 |
+
// Check along the mainAxis and main crossAxis side.
|
| 507 |
+
d.overflows.slice(0, 2).reduce((acc, v) => acc + v, 0) :
|
| 508 |
+
// Check only the mainAxis.
|
| 509 |
+
d.overflows[0], d.overflows];
|
| 510 |
+
}).sort((a, b) => a[1] - b[1]);
|
| 511 |
+
const placementsThatFitOnEachSide = placementsSortedByMostSpace.filter(d => d[2].slice(0,
|
| 512 |
+
// Aligned placements should not check their opposite crossAxis
|
| 513 |
+
// side.
|
| 514 |
+
getAlignment(d[0]) ? 2 : 3).every(v => v <= 0));
|
| 515 |
+
const resetPlacement = ((_placementsThatFitOnE = placementsThatFitOnEachSide[0]) == null ? void 0 : _placementsThatFitOnE[0]) || placementsSortedByMostSpace[0][0];
|
| 516 |
+
if (resetPlacement !== placement) {
|
| 517 |
+
return {
|
| 518 |
+
data: {
|
| 519 |
+
index: currentIndex + 1,
|
| 520 |
+
overflows: allOverflows
|
| 521 |
+
},
|
| 522 |
+
reset: {
|
| 523 |
+
placement: resetPlacement
|
| 524 |
+
}
|
| 525 |
+
};
|
| 526 |
+
}
|
| 527 |
+
return {};
|
| 528 |
+
}
|
| 529 |
+
};
|
| 530 |
+
};
|
| 531 |
+
|
| 532 |
+
/**
|
| 533 |
+
* Optimizes the visibility of the floating element by flipping the `placement`
|
| 534 |
+
* in order to keep it in view when the preferred placement(s) will overflow the
|
| 535 |
+
* clipping boundary. Alternative to `autoPlacement`.
|
| 536 |
+
* @see https://floating-ui.com/docs/flip
|
| 537 |
+
*/
|
| 538 |
+
const flip = function (options) {
|
| 539 |
+
if (options === void 0) {
|
| 540 |
+
options = {};
|
| 541 |
+
}
|
| 542 |
+
return {
|
| 543 |
+
name: 'flip',
|
| 544 |
+
options,
|
| 545 |
+
async fn(state) {
|
| 546 |
+
var _middlewareData$arrow, _middlewareData$flip;
|
| 547 |
+
const {
|
| 548 |
+
placement,
|
| 549 |
+
middlewareData,
|
| 550 |
+
rects,
|
| 551 |
+
initialPlacement,
|
| 552 |
+
platform,
|
| 553 |
+
elements
|
| 554 |
+
} = state;
|
| 555 |
+
const {
|
| 556 |
+
mainAxis: checkMainAxis = true,
|
| 557 |
+
crossAxis: checkCrossAxis = true,
|
| 558 |
+
fallbackPlacements: specifiedFallbackPlacements,
|
| 559 |
+
fallbackStrategy = 'bestFit',
|
| 560 |
+
fallbackAxisSideDirection = 'none',
|
| 561 |
+
flipAlignment = true,
|
| 562 |
+
...detectOverflowOptions
|
| 563 |
+
} = evaluate(options, state);
|
| 564 |
+
|
| 565 |
+
// If a reset by the arrow was caused due to an alignment offset being
|
| 566 |
+
// added, we should skip any logic now since `flip()` has already done its
|
| 567 |
+
// work.
|
| 568 |
+
// https://github.com/floating-ui/floating-ui/issues/2549#issuecomment-1719601643
|
| 569 |
+
if ((_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
|
| 570 |
+
return {};
|
| 571 |
+
}
|
| 572 |
+
const side = getSide(placement);
|
| 573 |
+
const initialSideAxis = getSideAxis(initialPlacement);
|
| 574 |
+
const isBasePlacement = getSide(initialPlacement) === initialPlacement;
|
| 575 |
+
const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating));
|
| 576 |
+
const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement(initialPlacement)] : getExpandedPlacements(initialPlacement));
|
| 577 |
+
const hasFallbackAxisSideDirection = fallbackAxisSideDirection !== 'none';
|
| 578 |
+
if (!specifiedFallbackPlacements && hasFallbackAxisSideDirection) {
|
| 579 |
+
fallbackPlacements.push(...getOppositeAxisPlacements(initialPlacement, flipAlignment, fallbackAxisSideDirection, rtl));
|
| 580 |
+
}
|
| 581 |
+
const placements = [initialPlacement, ...fallbackPlacements];
|
| 582 |
+
const overflow = await platform.detectOverflow(state, detectOverflowOptions);
|
| 583 |
+
const overflows = [];
|
| 584 |
+
let overflowsData = ((_middlewareData$flip = middlewareData.flip) == null ? void 0 : _middlewareData$flip.overflows) || [];
|
| 585 |
+
if (checkMainAxis) {
|
| 586 |
+
overflows.push(overflow[side]);
|
| 587 |
+
}
|
| 588 |
+
if (checkCrossAxis) {
|
| 589 |
+
const sides = getAlignmentSides(placement, rects, rtl);
|
| 590 |
+
overflows.push(overflow[sides[0]], overflow[sides[1]]);
|
| 591 |
+
}
|
| 592 |
+
overflowsData = [...overflowsData, {
|
| 593 |
+
placement,
|
| 594 |
+
overflows
|
| 595 |
+
}];
|
| 596 |
+
|
| 597 |
+
// One or more sides is overflowing.
|
| 598 |
+
if (!overflows.every(side => side <= 0)) {
|
| 599 |
+
var _middlewareData$flip2, _overflowsData$filter;
|
| 600 |
+
const nextIndex = (((_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.index) || 0) + 1;
|
| 601 |
+
const nextPlacement = placements[nextIndex];
|
| 602 |
+
if (nextPlacement) {
|
| 603 |
+
const ignoreCrossAxisOverflow = checkCrossAxis === 'alignment' ? initialSideAxis !== getSideAxis(nextPlacement) : false;
|
| 604 |
+
if (!ignoreCrossAxisOverflow ||
|
| 605 |
+
// We leave the current main axis only if every placement on that axis
|
| 606 |
+
// overflows the main axis.
|
| 607 |
+
overflowsData.every(d => getSideAxis(d.placement) === initialSideAxis ? d.overflows[0] > 0 : true)) {
|
| 608 |
+
// Try next placement and re-run the lifecycle.
|
| 609 |
+
return {
|
| 610 |
+
data: {
|
| 611 |
+
index: nextIndex,
|
| 612 |
+
overflows: overflowsData
|
| 613 |
+
},
|
| 614 |
+
reset: {
|
| 615 |
+
placement: nextPlacement
|
| 616 |
+
}
|
| 617 |
+
};
|
| 618 |
+
}
|
| 619 |
+
}
|
| 620 |
+
|
| 621 |
+
// First, find the candidates that fit on the mainAxis side of overflow,
|
| 622 |
+
// then find the placement that fits the best on the main crossAxis side.
|
| 623 |
+
let resetPlacement = (_overflowsData$filter = overflowsData.filter(d => d.overflows[0] <= 0).sort((a, b) => a.overflows[1] - b.overflows[1])[0]) == null ? void 0 : _overflowsData$filter.placement;
|
| 624 |
+
|
| 625 |
+
// Otherwise fallback.
|
| 626 |
+
if (!resetPlacement) {
|
| 627 |
+
switch (fallbackStrategy) {
|
| 628 |
+
case 'bestFit':
|
| 629 |
+
{
|
| 630 |
+
var _overflowsData$filter2;
|
| 631 |
+
const placement = (_overflowsData$filter2 = overflowsData.filter(d => {
|
| 632 |
+
if (hasFallbackAxisSideDirection) {
|
| 633 |
+
const currentSideAxis = getSideAxis(d.placement);
|
| 634 |
+
return currentSideAxis === initialSideAxis ||
|
| 635 |
+
// Create a bias to the `y` side axis due to horizontal
|
| 636 |
+
// reading directions favoring greater width.
|
| 637 |
+
currentSideAxis === 'y';
|
| 638 |
+
}
|
| 639 |
+
return true;
|
| 640 |
+
}).map(d => [d.placement, d.overflows.filter(overflow => overflow > 0).reduce((acc, overflow) => acc + overflow, 0)]).sort((a, b) => a[1] - b[1])[0]) == null ? void 0 : _overflowsData$filter2[0];
|
| 641 |
+
if (placement) {
|
| 642 |
+
resetPlacement = placement;
|
| 643 |
+
}
|
| 644 |
+
break;
|
| 645 |
+
}
|
| 646 |
+
case 'initialPlacement':
|
| 647 |
+
resetPlacement = initialPlacement;
|
| 648 |
+
break;
|
| 649 |
+
}
|
| 650 |
+
}
|
| 651 |
+
if (placement !== resetPlacement) {
|
| 652 |
+
return {
|
| 653 |
+
reset: {
|
| 654 |
+
placement: resetPlacement
|
| 655 |
+
}
|
| 656 |
+
};
|
| 657 |
+
}
|
| 658 |
+
}
|
| 659 |
+
return {};
|
| 660 |
+
}
|
| 661 |
+
};
|
| 662 |
+
};
|
| 663 |
+
|
| 664 |
+
function getSideOffsets(overflow, rect) {
|
| 665 |
+
return {
|
| 666 |
+
top: overflow.top - rect.height,
|
| 667 |
+
right: overflow.right - rect.width,
|
| 668 |
+
bottom: overflow.bottom - rect.height,
|
| 669 |
+
left: overflow.left - rect.width
|
| 670 |
+
};
|
| 671 |
+
}
|
| 672 |
+
function isAnySideFullyClipped(overflow) {
|
| 673 |
+
return sides.some(side => overflow[side] >= 0);
|
| 674 |
+
}
|
| 675 |
+
/**
|
| 676 |
+
* Provides data to hide the floating element in applicable situations, such as
|
| 677 |
+
* when it is not in the same clipping context as the reference element.
|
| 678 |
+
* @see https://floating-ui.com/docs/hide
|
| 679 |
+
*/
|
| 680 |
+
const hide = function (options) {
|
| 681 |
+
if (options === void 0) {
|
| 682 |
+
options = {};
|
| 683 |
+
}
|
| 684 |
+
return {
|
| 685 |
+
name: 'hide',
|
| 686 |
+
options,
|
| 687 |
+
async fn(state) {
|
| 688 |
+
const {
|
| 689 |
+
rects,
|
| 690 |
+
platform
|
| 691 |
+
} = state;
|
| 692 |
+
const {
|
| 693 |
+
strategy = 'referenceHidden',
|
| 694 |
+
...detectOverflowOptions
|
| 695 |
+
} = evaluate(options, state);
|
| 696 |
+
switch (strategy) {
|
| 697 |
+
case 'referenceHidden':
|
| 698 |
+
{
|
| 699 |
+
const overflow = await platform.detectOverflow(state, {
|
| 700 |
+
...detectOverflowOptions,
|
| 701 |
+
elementContext: 'reference'
|
| 702 |
+
});
|
| 703 |
+
const offsets = getSideOffsets(overflow, rects.reference);
|
| 704 |
+
return {
|
| 705 |
+
data: {
|
| 706 |
+
referenceHiddenOffsets: offsets,
|
| 707 |
+
referenceHidden: isAnySideFullyClipped(offsets)
|
| 708 |
+
}
|
| 709 |
+
};
|
| 710 |
+
}
|
| 711 |
+
case 'escaped':
|
| 712 |
+
{
|
| 713 |
+
const overflow = await platform.detectOverflow(state, {
|
| 714 |
+
...detectOverflowOptions,
|
| 715 |
+
altBoundary: true
|
| 716 |
+
});
|
| 717 |
+
const offsets = getSideOffsets(overflow, rects.floating);
|
| 718 |
+
return {
|
| 719 |
+
data: {
|
| 720 |
+
escapedOffsets: offsets,
|
| 721 |
+
escaped: isAnySideFullyClipped(offsets)
|
| 722 |
+
}
|
| 723 |
+
};
|
| 724 |
+
}
|
| 725 |
+
default:
|
| 726 |
+
{
|
| 727 |
+
return {};
|
| 728 |
+
}
|
| 729 |
+
}
|
| 730 |
+
}
|
| 731 |
+
};
|
| 732 |
+
};
|
| 733 |
+
|
| 734 |
+
function getBoundingRect(rects) {
|
| 735 |
+
const minX = min(...rects.map(rect => rect.left));
|
| 736 |
+
const minY = min(...rects.map(rect => rect.top));
|
| 737 |
+
const maxX = max(...rects.map(rect => rect.right));
|
| 738 |
+
const maxY = max(...rects.map(rect => rect.bottom));
|
| 739 |
+
return {
|
| 740 |
+
x: minX,
|
| 741 |
+
y: minY,
|
| 742 |
+
width: maxX - minX,
|
| 743 |
+
height: maxY - minY
|
| 744 |
+
};
|
| 745 |
+
}
|
| 746 |
+
function getRectsByLine(rects) {
|
| 747 |
+
const sortedRects = rects.slice().sort((a, b) => a.y - b.y);
|
| 748 |
+
const groups = [];
|
| 749 |
+
let prevRect = null;
|
| 750 |
+
for (let i = 0; i < sortedRects.length; i++) {
|
| 751 |
+
const rect = sortedRects[i];
|
| 752 |
+
if (!prevRect || rect.y - prevRect.y > prevRect.height / 2) {
|
| 753 |
+
groups.push([rect]);
|
| 754 |
+
} else {
|
| 755 |
+
groups[groups.length - 1].push(rect);
|
| 756 |
+
}
|
| 757 |
+
prevRect = rect;
|
| 758 |
+
}
|
| 759 |
+
return groups.map(rect => rectToClientRect(getBoundingRect(rect)));
|
| 760 |
+
}
|
| 761 |
+
/**
|
| 762 |
+
* Provides improved positioning for inline reference elements that can span
|
| 763 |
+
* over multiple lines, such as hyperlinks or range selections.
|
| 764 |
+
* @see https://floating-ui.com/docs/inline
|
| 765 |
+
*/
|
| 766 |
+
const inline = function (options) {
|
| 767 |
+
if (options === void 0) {
|
| 768 |
+
options = {};
|
| 769 |
+
}
|
| 770 |
+
return {
|
| 771 |
+
name: 'inline',
|
| 772 |
+
options,
|
| 773 |
+
async fn(state) {
|
| 774 |
+
const {
|
| 775 |
+
placement,
|
| 776 |
+
elements,
|
| 777 |
+
rects,
|
| 778 |
+
platform,
|
| 779 |
+
strategy
|
| 780 |
+
} = state;
|
| 781 |
+
// A MouseEvent's client{X,Y} coords can be up to 2 pixels off a
|
| 782 |
+
// ClientRect's bounds, despite the event listener being triggered. A
|
| 783 |
+
// padding of 2 seems to handle this issue.
|
| 784 |
+
const {
|
| 785 |
+
padding = 2,
|
| 786 |
+
x,
|
| 787 |
+
y
|
| 788 |
+
} = evaluate(options, state);
|
| 789 |
+
const nativeClientRects = Array.from((await (platform.getClientRects == null ? void 0 : platform.getClientRects(elements.reference))) || []);
|
| 790 |
+
|
| 791 |
+
// No rects (e.g. a hidden or detached reference, or a collapsed range) —
|
| 792 |
+
// keep the existing reference rect rather than resetting to an invalid
|
| 793 |
+
// one with non-finite values.
|
| 794 |
+
if (!nativeClientRects.length) {
|
| 795 |
+
return {};
|
| 796 |
+
}
|
| 797 |
+
const clientRects = getRectsByLine(nativeClientRects);
|
| 798 |
+
const fallback = rectToClientRect(getBoundingRect(nativeClientRects));
|
| 799 |
+
const paddingObject = getPaddingObject(padding);
|
| 800 |
+
function getBoundingClientRect() {
|
| 801 |
+
// There are two rects and they are disjoined.
|
| 802 |
+
if (clientRects.length === 2 && (clientRects[0].left > clientRects[1].right || clientRects[1].left > clientRects[0].right) && x != null && y != null) {
|
| 803 |
+
// Find the first rect in which the point is fully inside.
|
| 804 |
+
return clientRects.find(rect => x > rect.left - paddingObject.left && x < rect.right + paddingObject.right && y > rect.top - paddingObject.top && y < rect.bottom + paddingObject.bottom) || fallback;
|
| 805 |
+
}
|
| 806 |
+
|
| 807 |
+
// There are 2 or more connected rects.
|
| 808 |
+
if (clientRects.length >= 2) {
|
| 809 |
+
if (getSideAxis(placement) === 'y') {
|
| 810 |
+
const firstRect = clientRects[0];
|
| 811 |
+
const lastRect = clientRects[clientRects.length - 1];
|
| 812 |
+
const isTop = getSide(placement) === 'top';
|
| 813 |
+
const top = firstRect.top;
|
| 814 |
+
const bottom = lastRect.bottom;
|
| 815 |
+
const left = isTop ? firstRect.left : lastRect.left;
|
| 816 |
+
const right = isTop ? firstRect.right : lastRect.right;
|
| 817 |
+
return rectToClientRect({
|
| 818 |
+
x: left,
|
| 819 |
+
y: top,
|
| 820 |
+
width: right - left,
|
| 821 |
+
height: bottom - top
|
| 822 |
+
});
|
| 823 |
+
}
|
| 824 |
+
const isLeftSide = getSide(placement) === 'left';
|
| 825 |
+
const maxRight = max(...clientRects.map(rect => rect.right));
|
| 826 |
+
const minLeft = min(...clientRects.map(rect => rect.left));
|
| 827 |
+
const measureRects = clientRects.filter(rect => isLeftSide ? rect.left === minLeft : rect.right === maxRight);
|
| 828 |
+
const top = measureRects[0].top;
|
| 829 |
+
const bottom = measureRects[measureRects.length - 1].bottom;
|
| 830 |
+
return rectToClientRect({
|
| 831 |
+
x: minLeft,
|
| 832 |
+
y: top,
|
| 833 |
+
width: maxRight - minLeft,
|
| 834 |
+
height: bottom - top
|
| 835 |
+
});
|
| 836 |
+
}
|
| 837 |
+
return fallback;
|
| 838 |
+
}
|
| 839 |
+
const resetRects = await platform.getElementRects({
|
| 840 |
+
reference: {
|
| 841 |
+
getBoundingClientRect
|
| 842 |
+
},
|
| 843 |
+
floating: elements.floating,
|
| 844 |
+
strategy
|
| 845 |
+
});
|
| 846 |
+
if (rects.reference.x !== resetRects.reference.x || rects.reference.y !== resetRects.reference.y || rects.reference.width !== resetRects.reference.width || rects.reference.height !== resetRects.reference.height) {
|
| 847 |
+
return {
|
| 848 |
+
reset: {
|
| 849 |
+
rects: resetRects
|
| 850 |
+
}
|
| 851 |
+
};
|
| 852 |
+
}
|
| 853 |
+
return {};
|
| 854 |
+
}
|
| 855 |
+
};
|
| 856 |
+
};
|
| 857 |
+
|
| 858 |
+
const originSides = /*#__PURE__*/new Set(['left', 'top']);
|
| 859 |
+
|
| 860 |
+
// For type backwards-compatibility, the `OffsetOptions` type was also
|
| 861 |
+
// Derivable.
|
| 862 |
+
|
| 863 |
+
async function convertValueToCoords(state, options) {
|
| 864 |
+
const {
|
| 865 |
+
placement,
|
| 866 |
+
platform,
|
| 867 |
+
elements
|
| 868 |
+
} = state;
|
| 869 |
+
const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating));
|
| 870 |
+
const side = getSide(placement);
|
| 871 |
+
const alignment = getAlignment(placement);
|
| 872 |
+
const isVertical = getSideAxis(placement) === 'y';
|
| 873 |
+
const mainAxisMulti = originSides.has(side) ? -1 : 1;
|
| 874 |
+
const crossAxisMulti = rtl && isVertical ? -1 : 1;
|
| 875 |
+
const rawValue = evaluate(options, state);
|
| 876 |
+
|
| 877 |
+
// eslint-disable-next-line prefer-const
|
| 878 |
+
let {
|
| 879 |
+
mainAxis,
|
| 880 |
+
crossAxis,
|
| 881 |
+
alignmentAxis
|
| 882 |
+
} = typeof rawValue === 'number' ? {
|
| 883 |
+
mainAxis: rawValue,
|
| 884 |
+
crossAxis: 0,
|
| 885 |
+
alignmentAxis: null
|
| 886 |
+
} : {
|
| 887 |
+
mainAxis: rawValue.mainAxis || 0,
|
| 888 |
+
crossAxis: rawValue.crossAxis || 0,
|
| 889 |
+
alignmentAxis: rawValue.alignmentAxis
|
| 890 |
+
};
|
| 891 |
+
if (alignment && typeof alignmentAxis === 'number') {
|
| 892 |
+
crossAxis = alignment === 'end' ? alignmentAxis * -1 : alignmentAxis;
|
| 893 |
+
}
|
| 894 |
+
return isVertical ? {
|
| 895 |
+
x: crossAxis * crossAxisMulti,
|
| 896 |
+
y: mainAxis * mainAxisMulti
|
| 897 |
+
} : {
|
| 898 |
+
x: mainAxis * mainAxisMulti,
|
| 899 |
+
y: crossAxis * crossAxisMulti
|
| 900 |
+
};
|
| 901 |
+
}
|
| 902 |
+
|
| 903 |
+
/**
|
| 904 |
+
* Modifies the placement by translating the floating element along the
|
| 905 |
+
* specified axes.
|
| 906 |
+
* A number (shorthand for `mainAxis` or distance), or an axes configuration
|
| 907 |
+
* object may be passed.
|
| 908 |
+
* @see https://floating-ui.com/docs/offset
|
| 909 |
+
*/
|
| 910 |
+
const offset = function (options) {
|
| 911 |
+
if (options === void 0) {
|
| 912 |
+
options = 0;
|
| 913 |
+
}
|
| 914 |
+
return {
|
| 915 |
+
name: 'offset',
|
| 916 |
+
options,
|
| 917 |
+
async fn(state) {
|
| 918 |
+
var _middlewareData$offse, _middlewareData$arrow;
|
| 919 |
+
const {
|
| 920 |
+
x,
|
| 921 |
+
y,
|
| 922 |
+
placement,
|
| 923 |
+
middlewareData
|
| 924 |
+
} = state;
|
| 925 |
+
const diffCoords = await convertValueToCoords(state, options);
|
| 926 |
+
|
| 927 |
+
// If the placement is the same and the arrow caused an alignment offset
|
| 928 |
+
// then we don't need to change the positioning coordinates.
|
| 929 |
+
if (placement === ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse.placement) && (_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
|
| 930 |
+
return {};
|
| 931 |
+
}
|
| 932 |
+
return {
|
| 933 |
+
x: x + diffCoords.x,
|
| 934 |
+
y: y + diffCoords.y,
|
| 935 |
+
data: {
|
| 936 |
+
...diffCoords,
|
| 937 |
+
placement
|
| 938 |
+
}
|
| 939 |
+
};
|
| 940 |
+
}
|
| 941 |
+
};
|
| 942 |
+
};
|
| 943 |
+
|
| 944 |
+
/**
|
| 945 |
+
* Optimizes the visibility of the floating element by shifting it in order to
|
| 946 |
+
* keep it in view when it will overflow the clipping boundary.
|
| 947 |
+
* @see https://floating-ui.com/docs/shift
|
| 948 |
+
*/
|
| 949 |
+
const shift = function (options) {
|
| 950 |
+
if (options === void 0) {
|
| 951 |
+
options = {};
|
| 952 |
+
}
|
| 953 |
+
return {
|
| 954 |
+
name: 'shift',
|
| 955 |
+
options,
|
| 956 |
+
async fn(state) {
|
| 957 |
+
const {
|
| 958 |
+
x,
|
| 959 |
+
y,
|
| 960 |
+
placement,
|
| 961 |
+
platform
|
| 962 |
+
} = state;
|
| 963 |
+
const {
|
| 964 |
+
mainAxis: checkMainAxis = true,
|
| 965 |
+
crossAxis: checkCrossAxis = false,
|
| 966 |
+
limiter = {
|
| 967 |
+
fn: _ref => {
|
| 968 |
+
let {
|
| 969 |
+
x,
|
| 970 |
+
y
|
| 971 |
+
} = _ref;
|
| 972 |
+
return {
|
| 973 |
+
x,
|
| 974 |
+
y
|
| 975 |
+
};
|
| 976 |
+
}
|
| 977 |
+
},
|
| 978 |
+
...detectOverflowOptions
|
| 979 |
+
} = evaluate(options, state);
|
| 980 |
+
const coords = {
|
| 981 |
+
x,
|
| 982 |
+
y
|
| 983 |
+
};
|
| 984 |
+
const overflow = await platform.detectOverflow(state, detectOverflowOptions);
|
| 985 |
+
const crossAxis = getSideAxis(placement);
|
| 986 |
+
const mainAxis = getOppositeAxis(crossAxis);
|
| 987 |
+
let mainAxisCoord = coords[mainAxis];
|
| 988 |
+
let crossAxisCoord = coords[crossAxis];
|
| 989 |
+
const clampCoord = (axis, coord) => clamp(coord + overflow[axis === 'y' ? 'top' : 'left'], coord, coord - overflow[axis === 'y' ? 'bottom' : 'right']);
|
| 990 |
+
if (checkMainAxis) {
|
| 991 |
+
mainAxisCoord = clampCoord(mainAxis, mainAxisCoord);
|
| 992 |
+
}
|
| 993 |
+
if (checkCrossAxis) {
|
| 994 |
+
crossAxisCoord = clampCoord(crossAxis, crossAxisCoord);
|
| 995 |
+
}
|
| 996 |
+
const limitedCoords = limiter.fn({
|
| 997 |
+
...state,
|
| 998 |
+
[mainAxis]: mainAxisCoord,
|
| 999 |
+
[crossAxis]: crossAxisCoord
|
| 1000 |
+
});
|
| 1001 |
+
return {
|
| 1002 |
+
...limitedCoords,
|
| 1003 |
+
data: {
|
| 1004 |
+
x: limitedCoords.x - x,
|
| 1005 |
+
y: limitedCoords.y - y,
|
| 1006 |
+
enabled: {
|
| 1007 |
+
[mainAxis]: checkMainAxis,
|
| 1008 |
+
[crossAxis]: checkCrossAxis
|
| 1009 |
+
}
|
| 1010 |
+
}
|
| 1011 |
+
};
|
| 1012 |
+
}
|
| 1013 |
+
};
|
| 1014 |
+
};
|
| 1015 |
+
/**
|
| 1016 |
+
* Built-in `limiter` that will stop `shift()` at a certain point.
|
| 1017 |
+
*/
|
| 1018 |
+
const limitShift = function (options) {
|
| 1019 |
+
if (options === void 0) {
|
| 1020 |
+
options = {};
|
| 1021 |
+
}
|
| 1022 |
+
return {
|
| 1023 |
+
options,
|
| 1024 |
+
fn(state) {
|
| 1025 |
+
var _rawOffset$mainAxis, _rawOffset$crossAxis;
|
| 1026 |
+
const {
|
| 1027 |
+
x,
|
| 1028 |
+
y,
|
| 1029 |
+
placement,
|
| 1030 |
+
rects,
|
| 1031 |
+
middlewareData
|
| 1032 |
+
} = state;
|
| 1033 |
+
const {
|
| 1034 |
+
offset = 0,
|
| 1035 |
+
mainAxis: checkMainAxis = true,
|
| 1036 |
+
crossAxis: checkCrossAxis = true
|
| 1037 |
+
} = evaluate(options, state);
|
| 1038 |
+
const coords = {
|
| 1039 |
+
x,
|
| 1040 |
+
y
|
| 1041 |
+
};
|
| 1042 |
+
const crossAxis = getSideAxis(placement);
|
| 1043 |
+
const mainAxis = getOppositeAxis(crossAxis);
|
| 1044 |
+
let mainAxisCoord = coords[mainAxis];
|
| 1045 |
+
let crossAxisCoord = coords[crossAxis];
|
| 1046 |
+
const rawOffset = evaluate(offset, state);
|
| 1047 |
+
const computedOffset = typeof rawOffset === 'number' ? {
|
| 1048 |
+
mainAxis: rawOffset,
|
| 1049 |
+
crossAxis: 0
|
| 1050 |
+
} : {
|
| 1051 |
+
mainAxis: (_rawOffset$mainAxis = rawOffset.mainAxis) != null ? _rawOffset$mainAxis : 0,
|
| 1052 |
+
crossAxis: (_rawOffset$crossAxis = rawOffset.crossAxis) != null ? _rawOffset$crossAxis : 0
|
| 1053 |
+
};
|
| 1054 |
+
if (checkMainAxis) {
|
| 1055 |
+
const len = mainAxis === 'y' ? 'height' : 'width';
|
| 1056 |
+
const limitMin = rects.reference[mainAxis] - rects.floating[len] + computedOffset.mainAxis;
|
| 1057 |
+
const limitMax = rects.reference[mainAxis] + rects.reference[len] - computedOffset.mainAxis;
|
| 1058 |
+
if (mainAxisCoord < limitMin) {
|
| 1059 |
+
mainAxisCoord = limitMin;
|
| 1060 |
+
} else if (mainAxisCoord > limitMax) {
|
| 1061 |
+
mainAxisCoord = limitMax;
|
| 1062 |
+
}
|
| 1063 |
+
}
|
| 1064 |
+
if (checkCrossAxis) {
|
| 1065 |
+
var _middlewareData$offse, _middlewareData$offse2;
|
| 1066 |
+
const len = mainAxis === 'y' ? 'width' : 'height';
|
| 1067 |
+
const isOriginSide = originSides.has(getSide(placement));
|
| 1068 |
+
const limitMin = rects.reference[crossAxis] - rects.floating[len] + (isOriginSide ? ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse[crossAxis]) || 0 : 0) + (isOriginSide ? 0 : computedOffset.crossAxis);
|
| 1069 |
+
const limitMax = rects.reference[crossAxis] + rects.reference[len] + (isOriginSide ? 0 : ((_middlewareData$offse2 = middlewareData.offset) == null ? void 0 : _middlewareData$offse2[crossAxis]) || 0) - (isOriginSide ? computedOffset.crossAxis : 0);
|
| 1070 |
+
if (crossAxisCoord < limitMin) {
|
| 1071 |
+
crossAxisCoord = limitMin;
|
| 1072 |
+
} else if (crossAxisCoord > limitMax) {
|
| 1073 |
+
crossAxisCoord = limitMax;
|
| 1074 |
+
}
|
| 1075 |
+
}
|
| 1076 |
+
return {
|
| 1077 |
+
[mainAxis]: mainAxisCoord,
|
| 1078 |
+
[crossAxis]: crossAxisCoord
|
| 1079 |
+
};
|
| 1080 |
+
}
|
| 1081 |
+
};
|
| 1082 |
+
};
|
| 1083 |
+
|
| 1084 |
+
// Method syntax keeps callback parameters bivariant, but expressing the
|
| 1085 |
+
// explicit `| undefined` required by `exactOptionalPropertyTypes` needs
|
| 1086 |
+
// property syntax, which is contravariant under `strictFunctionTypes`.
|
| 1087 |
+
// Extracting the function from a method position restores that bivariance so
|
| 1088 |
+
// consumers can still assign callbacks with narrower parameter types.
|
| 1089 |
+
|
| 1090 |
+
/**
|
| 1091 |
+
* Provides data that allows you to change the size of the floating element —
|
| 1092 |
+
* for instance, prevent it from overflowing the clipping boundary or match the
|
| 1093 |
+
* width of the reference element.
|
| 1094 |
+
* @see https://floating-ui.com/docs/size
|
| 1095 |
+
*/
|
| 1096 |
+
const size = function (options) {
|
| 1097 |
+
if (options === void 0) {
|
| 1098 |
+
options = {};
|
| 1099 |
+
}
|
| 1100 |
+
return {
|
| 1101 |
+
name: 'size',
|
| 1102 |
+
options,
|
| 1103 |
+
async fn(state) {
|
| 1104 |
+
const {
|
| 1105 |
+
placement,
|
| 1106 |
+
rects,
|
| 1107 |
+
platform,
|
| 1108 |
+
elements
|
| 1109 |
+
} = state;
|
| 1110 |
+
const {
|
| 1111 |
+
apply = () => {},
|
| 1112 |
+
...detectOverflowOptions
|
| 1113 |
+
} = evaluate(options, state);
|
| 1114 |
+
const overflow = await platform.detectOverflow(state, detectOverflowOptions);
|
| 1115 |
+
const side = getSide(placement);
|
| 1116 |
+
const alignment = getAlignment(placement);
|
| 1117 |
+
const isYAxis = getSideAxis(placement) === 'y';
|
| 1118 |
+
const {
|
| 1119 |
+
width,
|
| 1120 |
+
height
|
| 1121 |
+
} = rects.floating;
|
| 1122 |
+
let heightSide;
|
| 1123 |
+
let widthSide;
|
| 1124 |
+
if (side === 'top' || side === 'bottom') {
|
| 1125 |
+
heightSide = side;
|
| 1126 |
+
widthSide = alignment === ((await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating))) ? 'start' : 'end') ? 'left' : 'right';
|
| 1127 |
+
} else {
|
| 1128 |
+
widthSide = side;
|
| 1129 |
+
heightSide = alignment === 'end' ? 'top' : 'bottom';
|
| 1130 |
+
}
|
| 1131 |
+
const maximumClippingHeight = height - overflow.top - overflow.bottom;
|
| 1132 |
+
const maximumClippingWidth = width - overflow.left - overflow.right;
|
| 1133 |
+
const overflowAvailableHeight = min(height - overflow[heightSide], maximumClippingHeight);
|
| 1134 |
+
const overflowAvailableWidth = min(width - overflow[widthSide], maximumClippingWidth);
|
| 1135 |
+
const shiftData = state.middlewareData.shift;
|
| 1136 |
+
const noShift = !shiftData;
|
| 1137 |
+
let availableHeight = overflowAvailableHeight;
|
| 1138 |
+
let availableWidth = overflowAvailableWidth;
|
| 1139 |
+
if (shiftData != null && shiftData.enabled.x) {
|
| 1140 |
+
availableWidth = maximumClippingWidth;
|
| 1141 |
+
}
|
| 1142 |
+
if (shiftData != null && shiftData.enabled.y) {
|
| 1143 |
+
availableHeight = maximumClippingHeight;
|
| 1144 |
+
}
|
| 1145 |
+
if (noShift && !alignment) {
|
| 1146 |
+
if (isYAxis) {
|
| 1147 |
+
availableWidth = width - 2 * max(overflow.left, overflow.right);
|
| 1148 |
+
} else {
|
| 1149 |
+
availableHeight = height - 2 * max(overflow.top, overflow.bottom);
|
| 1150 |
+
}
|
| 1151 |
+
}
|
| 1152 |
+
await apply({
|
| 1153 |
+
...state,
|
| 1154 |
+
availableWidth,
|
| 1155 |
+
availableHeight
|
| 1156 |
+
});
|
| 1157 |
+
const nextDimensions = await platform.getDimensions(elements.floating);
|
| 1158 |
+
if (width !== nextDimensions.width || height !== nextDimensions.height) {
|
| 1159 |
+
return {
|
| 1160 |
+
reset: {
|
| 1161 |
+
rects: true
|
| 1162 |
+
}
|
| 1163 |
+
};
|
| 1164 |
+
}
|
| 1165 |
+
return {};
|
| 1166 |
+
}
|
| 1167 |
+
};
|
| 1168 |
+
};
|
| 1169 |
+
|
| 1170 |
+
exports.arrow = arrow;
|
| 1171 |
+
exports.autoPlacement = autoPlacement;
|
| 1172 |
+
exports.computePosition = computePosition;
|
| 1173 |
+
exports.detectOverflow = detectOverflow;
|
| 1174 |
+
exports.flip = flip;
|
| 1175 |
+
exports.hide = hide;
|
| 1176 |
+
exports.inline = inline;
|
| 1177 |
+
exports.limitShift = limitShift;
|
| 1178 |
+
exports.offset = offset;
|
| 1179 |
+
exports.rectToClientRect = rectToClientRect;
|
| 1180 |
+
exports.shift = shift;
|
| 1181 |
+
exports.size = size;
|
| 1182 |
+
|
| 1183 |
+
}));
|
e-commerce/node_modules/@floating-ui/core/dist/floating-ui.core.umd.min.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).FloatingUICore={})}(this,(function(t){"use strict";const e=["top","right","bottom","left"],n=["start","end"],i=e.reduce(((t,e)=>t.concat(e,e+"-"+n[0],e+"-"+n[1])),[]),r=Math.min,o=Math.max,l={left:"right",right:"left",bottom:"top",top:"bottom"};function a(t,e,n){return o(t,r(e,n))}function s(t,e){return"function"==typeof t?t(e):t}function f(t){return t.split("-")[0]}function c(t){return t.split("-")[1]}function u(t){return"x"===t?"y":"x"}function m(t){return"y"===t?"height":"width"}function d(t){const e=t[0];return"t"===e||"b"===e?"y":"x"}function g(t){return u(d(t))}function p(t,e,n){void 0===n&&(n=!1);const i=c(t),r=g(t),o=m(r);let l="x"===r?i===(n?"end":"start")?"right":"left":"start"===i?"bottom":"top";return e.reference[o]>e.floating[o]&&(l=A(l)),[l,A(l)]}function h(t){return t.includes("start")?t.replace("start","end"):t.replace("end","start")}const y=["left","right"],w=["right","left"],x=["top","bottom"],v=["bottom","top"];function b(t,e,n,i){const r=c(t);let o=function(t,e,n){switch(t){case"top":case"bottom":return n?e?w:y:e?y:w;case"left":case"right":return e?x:v;default:return[]}}(f(t),"start"===n,i);return r&&(o=o.map((t=>t+"-"+r)),e&&(o=o.concat(o.map(h)))),o}function A(t){const e=f(t);return l[e]+t.slice(e.length)}function R(t){return"number"!=typeof t?function(t){var e,n,i,r;return{top:null!=(e=t.top)?e:0,right:null!=(n=t.right)?n:0,bottom:null!=(i=t.bottom)?i:0,left:null!=(r=t.left)?r:0}}(t):{top:t,right:t,bottom:t,left:t}}function O(t){const{x:e,y:n,width:i,height:r}=t;return{width:i,height:r,top:n,left:e,right:e+i,bottom:n+r,x:e,y:n}}function P(t,e,n){let{reference:i,floating:r}=t;const o=d(e),l=g(e),a=m(l),s=f(e),u="y"===o,p=i.x+i.width/2-r.width/2,h=i.y+i.height/2-r.height/2,y=i[a]/2-r[a]/2;let w;switch(s){case"top":w={x:p,y:i.y-r.height};break;case"bottom":w={x:p,y:i.y+i.height};break;case"right":w={x:i.x+i.width,y:h};break;case"left":w={x:i.x-r.width,y:h};break;default:w={x:i.x,y:i.y}}const x=c(e);return x&&(w[l]+=y*("end"===x?1:-1)*(n&&u?-1:1)),w}async function T(t,e){var n;void 0===e&&(e={});const{x:i,y:r,platform:o,rects:l,elements:a,strategy:f}=t,{boundary:c="clippingAncestors",rootBoundary:u="viewport",elementContext:m="floating",altBoundary:d=!1,padding:g=0}=s(e,t),p=R(g),h=a[d?"floating"===m?"reference":"floating":m],y=O(await o.getClippingRect({element:null==(n=await(null==o.isElement?void 0:o.isElement(h)))||n?h:h.contextElement||await(null==o.getDocumentElement?void 0:o.getDocumentElement(a.floating)),boundary:c,rootBoundary:u,strategy:f})),w="floating"===m?{x:i,y:r,width:l.floating.width,height:l.floating.height}:l.reference,x=await(null==o.getOffsetParent?void 0:o.getOffsetParent(a.floating)),v=await(null==o.isElement?void 0:o.isElement(x))&&await(null==o.getScale?void 0:o.getScale(x))||{x:1,y:1},b=O(o.convertOffsetParentRelativeRectToViewportRelativeRect?await o.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:w,offsetParent:x,strategy:f}):w);return{top:(y.top-b.top+p.top)/v.y,bottom:(b.bottom-y.bottom+p.bottom)/v.y,left:(y.left-b.left+p.left)/v.x,right:(b.right-y.right+p.right)/v.x}}function D(t,e){return{top:t.top-e.height,right:t.right-e.width,bottom:t.bottom-e.height,left:t.left-e.width}}function E(t){return e.some((e=>t[e]>=0))}function L(t){const e=r(...t.map((t=>t.left))),n=r(...t.map((t=>t.top)));return{x:e,y:n,width:o(...t.map((t=>t.right)))-e,height:o(...t.map((t=>t.bottom)))-n}}const k=new Set(["left","top"]);t.arrow=t=>({name:"arrow",options:t,async fn(e){const{x:n,y:i,placement:o,rects:l,platform:f,elements:u,middlewareData:d}=e,{element:p,padding:h=0}=s(t,e)||{};if(null==p)return{};const y=R(h),w={x:n,y:i},x=g(o),v=m(x),b=await f.getDimensions(p),A="y"===x,O=A?"top":"left",P=A?"bottom":"right",T=A?"clientHeight":"clientWidth",D=l.reference[v]+l.reference[x]-w[x]-l.floating[v],E=w[x]-l.reference[x],L=await(null==f.getOffsetParent?void 0:f.getOffsetParent(p));let k=L?L[T]:0;k&&await(null==f.isElement?void 0:f.isElement(L))||(k=u.floating[T]||l.floating[v]);const C=D/2-E/2,H=k/2-b[v]/2-1,S=r(y[O],H),B=r(y[P],H),F=k-b[v]-B,j=k/2-b[v]/2+C,z=a(S,j,F),M=!d.arrow&&null!=c(o)&&j!==z&&l.reference[v]/2-(j<S?S:B)-b[v]/2<0,V=M?j<S?j-S:j-F:0;return{[x]:w[x]+V,data:{[x]:z,centerOffset:j-z-V,...M&&{alignmentOffset:V}},reset:M}}}),t.autoPlacement=function(t){return void 0===t&&(t={}),{name:"autoPlacement",options:t,async fn(e){var n,r,o;const{rects:l,middlewareData:a,placement:u,platform:m,elements:d}=e,{crossAxis:g=!1,alignment:y,allowedPlacements:w=i,autoAlignment:x=!0,...v}=s(t,e),b=void 0!==y||w===i?function(t,e,n){return(t?[...n.filter((e=>c(e)===t)),...n.filter((e=>c(e)!==t))]:n.filter((t=>f(t)===t))).filter((n=>!t||c(n)===t||!!e&&h(n)!==n))}(y||null,x,w):w,A=(null==(n=a.autoPlacement)?void 0:n.index)||0,R=b[A];if(null==R)return{};if(u!==R)return{reset:{placement:b[0]}};const O=await m.detectOverflow(e,v),P=p(R,l,await(null==m.isRTL?void 0:m.isRTL(d.floating))),T=[O[f(R)],O[P[0]],O[P[1]]],D=[...(null==(r=a.autoPlacement)?void 0:r.overflows)||[],{placement:R,overflows:T}],E=b[A+1];if(E)return{data:{index:A+1,overflows:D},reset:{placement:E}};const L=D.map((t=>{const e=c(t.placement);return[t.placement,e&&g?t.overflows.slice(0,2).reduce(((t,e)=>t+e),0):t.overflows[0],t.overflows]})).sort(((t,e)=>t[1]-e[1])),k=(null==(o=L.filter((t=>t[2].slice(0,c(t[0])?2:3).every((t=>t<=0))))[0])?void 0:o[0])||L[0][0];return k!==u?{data:{index:A+1,overflows:D},reset:{placement:k}}:{}}}},t.computePosition=async(t,e,n)=>{const{placement:i="bottom",strategy:r="absolute",middleware:o=[],platform:l}=n,a=l.detectOverflow?l:{...l,detectOverflow:T},s=await(null==l.isRTL?void 0:l.isRTL(e));let f=await l.getElementRects({reference:t,floating:e,strategy:r}),{x:c,y:u}=P(f,i,s),m=i,d=0;const g={};for(let n=0;n<o.length;n++){const p=o[n];if(!p)continue;const{name:h,fn:y}=p,{x:w,y:x,data:v,reset:b}=await y({x:c,y:u,initialPlacement:i,placement:m,strategy:r,middlewareData:g,rects:f,platform:a,elements:{reference:t,floating:e}});c=null!=w?w:c,u=null!=x?x:u,g[h]={...g[h],...v},b&&d<50&&(d++,"object"==typeof b&&(b.placement&&(m=b.placement),b.rects&&(f=!0===b.rects?await l.getElementRects({reference:t,floating:e,strategy:r}):b.rects),({x:c,y:u}=P(f,m,s))),n=-1)}return{x:c,y:u,placement:m,strategy:r,middlewareData:g}},t.detectOverflow=T,t.flip=function(t){return void 0===t&&(t={}),{name:"flip",options:t,async fn(e){var n,i;const{placement:r,middlewareData:o,rects:l,initialPlacement:a,platform:c,elements:u}=e,{mainAxis:m=!0,crossAxis:g=!0,fallbackPlacements:y,fallbackStrategy:w="bestFit",fallbackAxisSideDirection:x="none",flipAlignment:v=!0,...R}=s(t,e);if(null!=(n=o.arrow)&&n.alignmentOffset)return{};const O=f(r),P=d(a),T=f(a)===a,D=await(null==c.isRTL?void 0:c.isRTL(u.floating)),E=y||(T||!v?[A(a)]:function(t){const e=A(t);return[h(t),e,h(e)]}(a)),L="none"!==x;!y&&L&&E.push(...b(a,v,x,D));const k=[a,...E],C=await c.detectOverflow(e,R),H=[];let S=(null==(i=o.flip)?void 0:i.overflows)||[];if(m&&H.push(C[O]),g){const t=p(r,l,D);H.push(C[t[0]],C[t[1]])}if(S=[...S,{placement:r,overflows:H}],!H.every((t=>t<=0))){var B,F;const t=((null==(B=o.flip)?void 0:B.index)||0)+1,e=k[t];if(e){if(!("alignment"===g&&P!==d(e))||S.every((t=>d(t.placement)!==P||t.overflows[0]>0)))return{data:{index:t,overflows:S},reset:{placement:e}}}let n=null==(F=S.filter((t=>t.overflows[0]<=0)).sort(((t,e)=>t.overflows[1]-e.overflows[1]))[0])?void 0:F.placement;if(!n)switch(w){case"bestFit":{var j;const t=null==(j=S.filter((t=>{if(L){const e=d(t.placement);return e===P||"y"===e}return!0})).map((t=>[t.placement,t.overflows.filter((t=>t>0)).reduce(((t,e)=>t+e),0)])).sort(((t,e)=>t[1]-e[1]))[0])?void 0:j[0];t&&(n=t);break}case"initialPlacement":n=a}if(r!==n)return{reset:{placement:n}}}return{}}}},t.hide=function(t){return void 0===t&&(t={}),{name:"hide",options:t,async fn(e){const{rects:n,platform:i}=e,{strategy:r="referenceHidden",...o}=s(t,e);switch(r){case"referenceHidden":{const t=D(await i.detectOverflow(e,{...o,elementContext:"reference"}),n.reference);return{data:{referenceHiddenOffsets:t,referenceHidden:E(t)}}}case"escaped":{const t=D(await i.detectOverflow(e,{...o,altBoundary:!0}),n.floating);return{data:{escapedOffsets:t,escaped:E(t)}}}default:return{}}}}},t.inline=function(t){return void 0===t&&(t={}),{name:"inline",options:t,async fn(e){const{placement:n,elements:i,rects:l,platform:a,strategy:c}=e,{padding:u=2,x:m,y:g}=s(t,e),p=Array.from(await(null==a.getClientRects?void 0:a.getClientRects(i.reference))||[]);if(!p.length)return{};const h=function(t){const e=t.slice().sort(((t,e)=>t.y-e.y)),n=[];let i=null;for(let t=0;t<e.length;t++){const r=e[t];!i||r.y-i.y>i.height/2?n.push([r]):n[n.length-1].push(r),i=r}return n.map((t=>O(L(t))))}(p),y=O(L(p)),w=R(u);const x=await a.getElementRects({reference:{getBoundingClientRect:function(){if(2===h.length&&(h[0].left>h[1].right||h[1].left>h[0].right)&&null!=m&&null!=g)return h.find((t=>m>t.left-w.left&&m<t.right+w.right&&g>t.top-w.top&&g<t.bottom+w.bottom))||y;if(h.length>=2){if("y"===d(n)){const t=h[0],e=h[h.length-1],i="top"===f(n),r=t.top,o=e.bottom,l=i?t.left:e.left;return O({x:l,y:r,width:(i?t.right:e.right)-l,height:o-r})}const t="left"===f(n),e=o(...h.map((t=>t.right))),i=r(...h.map((t=>t.left))),l=h.filter((n=>t?n.left===i:n.right===e)),a=l[0].top,s=l[l.length-1].bottom;return O({x:i,y:a,width:e-i,height:s-a})}return y}},floating:i.floating,strategy:c});return l.reference.x!==x.reference.x||l.reference.y!==x.reference.y||l.reference.width!==x.reference.width||l.reference.height!==x.reference.height?{reset:{rects:x}}:{}}}},t.limitShift=function(t){return void 0===t&&(t={}),{options:t,fn(e){var n,i;const{x:r,y:o,placement:l,rects:a,middlewareData:c}=e,{offset:m=0,mainAxis:g=!0,crossAxis:p=!0}=s(t,e),h={x:r,y:o},y=d(l),w=u(y);let x=h[w],v=h[y];const b=s(m,e),A="number"==typeof b?{mainAxis:b,crossAxis:0}:{mainAxis:null!=(n=b.mainAxis)?n:0,crossAxis:null!=(i=b.crossAxis)?i:0};if(g){const t="y"===w?"height":"width",e=a.reference[w]-a.floating[t]+A.mainAxis,n=a.reference[w]+a.reference[t]-A.mainAxis;x<e?x=e:x>n&&(x=n)}if(p){var R,O;const t="y"===w?"width":"height",e=k.has(f(l)),n=a.reference[y]-a.floating[t]+(e&&(null==(R=c.offset)?void 0:R[y])||0)+(e?0:A.crossAxis),i=a.reference[y]+a.reference[t]+(e?0:(null==(O=c.offset)?void 0:O[y])||0)-(e?A.crossAxis:0);v<n?v=n:v>i&&(v=i)}return{[w]:x,[y]:v}}}},t.offset=function(t){return void 0===t&&(t=0),{name:"offset",options:t,async fn(e){var n,i;const{x:r,y:o,placement:l,middlewareData:a}=e,u=await async function(t,e){const{placement:n,platform:i,elements:r}=t,o=await(null==i.isRTL?void 0:i.isRTL(r.floating)),l=f(n),a=c(n),u="y"===d(n),m=k.has(l)?-1:1,g=o&&u?-1:1,p=s(e,t);let{mainAxis:h,crossAxis:y,alignmentAxis:w}="number"==typeof p?{mainAxis:p,crossAxis:0,alignmentAxis:null}:{mainAxis:p.mainAxis||0,crossAxis:p.crossAxis||0,alignmentAxis:p.alignmentAxis};return a&&"number"==typeof w&&(y="end"===a?-1*w:w),u?{x:y*g,y:h*m}:{x:h*m,y:y*g}}(e,t);return l===(null==(n=a.offset)?void 0:n.placement)&&null!=(i=a.arrow)&&i.alignmentOffset?{}:{x:r+u.x,y:o+u.y,data:{...u,placement:l}}}}},t.rectToClientRect=O,t.shift=function(t){return void 0===t&&(t={}),{name:"shift",options:t,async fn(e){const{x:n,y:i,placement:r,platform:o}=e,{mainAxis:l=!0,crossAxis:f=!1,limiter:c={fn:t=>{let{x:e,y:n}=t;return{x:e,y:n}}},...m}=s(t,e),g={x:n,y:i},p=await o.detectOverflow(e,m),h=d(r),y=u(h);let w=g[y],x=g[h];const v=(t,e)=>a(e+p["y"===t?"top":"left"],e,e-p["y"===t?"bottom":"right"]);l&&(w=v(y,w)),f&&(x=v(h,x));const b=c.fn({...e,[y]:w,[h]:x});return{...b,data:{x:b.x-n,y:b.y-i,enabled:{[y]:l,[h]:f}}}}}},t.size=function(t){return void 0===t&&(t={}),{name:"size",options:t,async fn(e){const{placement:n,rects:i,platform:l,elements:a}=e,{apply:u=()=>{},...m}=s(t,e),g=await l.detectOverflow(e,m),p=f(n),h=c(n),y="y"===d(n),{width:w,height:x}=i.floating;let v,b;"top"===p||"bottom"===p?(v=p,b=h===(await(null==l.isRTL?void 0:l.isRTL(a.floating))?"start":"end")?"left":"right"):(b=p,v="end"===h?"top":"bottom");const A=x-g.top-g.bottom,R=w-g.left-g.right,O=r(x-g[v],A),P=r(w-g[b],R),T=e.middlewareData.shift,D=!T;let E=O,L=P;null!=T&&T.enabled.x&&(L=R),null!=T&&T.enabled.y&&(E=A),D&&!h&&(y?L=w-2*o(g.left,g.right):E=x-2*o(g.top,g.bottom)),await u({...e,availableWidth:L,availableHeight:E});const k=await l.getDimensions(a.floating);return w!==k.width||x!==k.height?{reset:{rects:!0}}:{}}}}}));
|
e-commerce/node_modules/@floating-ui/core/package.json
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "@floating-ui/core",
|
| 3 |
+
"version": "1.8.0",
|
| 4 |
+
"description": "Positioning library for floating elements: tooltips, popovers, dropdowns, and more",
|
| 5 |
+
"publishConfig": {
|
| 6 |
+
"access": "public"
|
| 7 |
+
},
|
| 8 |
+
"main": "./dist/floating-ui.core.umd.js",
|
| 9 |
+
"module": "./dist/floating-ui.core.esm.js",
|
| 10 |
+
"unpkg": "./dist/floating-ui.core.umd.min.js",
|
| 11 |
+
"types": "./dist/floating-ui.core.d.ts",
|
| 12 |
+
"exports": {
|
| 13 |
+
"./package.json": "./package.json",
|
| 14 |
+
".": {
|
| 15 |
+
"import": {
|
| 16 |
+
"types": "./dist/floating-ui.core.d.mts",
|
| 17 |
+
"default": "./dist/floating-ui.core.mjs"
|
| 18 |
+
},
|
| 19 |
+
"types": "./dist/floating-ui.core.d.ts",
|
| 20 |
+
"module": "./dist/floating-ui.core.esm.js",
|
| 21 |
+
"default": "./dist/floating-ui.core.umd.js"
|
| 22 |
+
}
|
| 23 |
+
},
|
| 24 |
+
"sideEffects": false,
|
| 25 |
+
"files": [
|
| 26 |
+
"dist"
|
| 27 |
+
],
|
| 28 |
+
"author": "atomiks",
|
| 29 |
+
"license": "MIT",
|
| 30 |
+
"bugs": "https://github.com/floating-ui/floating-ui",
|
| 31 |
+
"repository": {
|
| 32 |
+
"type": "git",
|
| 33 |
+
"url": "https://github.com/floating-ui/floating-ui.git",
|
| 34 |
+
"directory": "packages/core"
|
| 35 |
+
},
|
| 36 |
+
"homepage": "https://floating-ui.com",
|
| 37 |
+
"keywords": [
|
| 38 |
+
"tooltip",
|
| 39 |
+
"popover",
|
| 40 |
+
"dropdown",
|
| 41 |
+
"menu",
|
| 42 |
+
"popup",
|
| 43 |
+
"positioning"
|
| 44 |
+
],
|
| 45 |
+
"dependencies": {
|
| 46 |
+
"@floating-ui/utils": "^0.2.12"
|
| 47 |
+
},
|
| 48 |
+
"devDependencies": {
|
| 49 |
+
"config": "0.0.0"
|
| 50 |
+
},
|
| 51 |
+
"scripts": {
|
| 52 |
+
"test": "vitest run",
|
| 53 |
+
"test:watch": "vitest watch",
|
| 54 |
+
"lint": "eslint .",
|
| 55 |
+
"format": "prettier --ignore-path ../../.gitignore --write .",
|
| 56 |
+
"clean": "rimraf dist out-tsc",
|
| 57 |
+
"dev": "rollup -c -w",
|
| 58 |
+
"build": "rollup -c",
|
| 59 |
+
"build:api": "build-api --tsc tsconfig.lib.json",
|
| 60 |
+
"publint": "publint",
|
| 61 |
+
"typecheck": "tsc -b"
|
| 62 |
+
}
|
| 63 |
+
}
|