(Adaptive Loop) Pass 3
(Adaptive Loop) Record freeze commit hash in context manifest
This commit is contained in:
1079 files changed
+1131878
No files matched your search
@@ -0,0 +1,32 @@
|
||||
# Assets Disclosure
|
||||
|
||||
**All visuals in Adaptive Loop are procedural SVG/CSS generated in code.** No image, font, music,
|
||||
or other binary art asset is downloaded, bundled, or imported. SPEC §3 (Forbidden) and §13
|
||||
(Entity art) are satisfied entirely by code.
|
||||
|
||||
## Procedural asset sources
|
||||
|
||||
| Asset | Source | Location |
|
||||
|---|---|---|
|
||||
| Board geometry (three concentric hexagonal rings, six radial gates, pointy-top hex tiles) | computed at runtime from ring radius / vertex math | `src/ui/geom.ts` |
|
||||
| Species glyphs (Lumiflora producer = 6-petal diatom; Vellea grazer = ciliated crescent; Phage = lunar-lander virus) | procedural SVG path/ellipse/polygon builders | `src/ui/svg.ts` |
|
||||
| Fixture glyphs (nutrient inlet pipette, heat coiled filament, toxin dropper, drain funnel, immune sentinel eye, objective reticle) | procedural SVG | `src/ui/svg.ts` |
|
||||
| Pressure iconography (heat sun-rays, hunger crescent, toxin skull-drop, immunity shield) | procedural SVG, each with a distinct color | `src/ui/svg.ts` |
|
||||
| Tile state rendering (nutrient liquid level, toxin level, heat rim glow, on-gate ring-color stroke) | SVG `clip-path` rectangles + strokes | `src/ui/board.ts` |
|
||||
| Layout, theme, focus states, reduced-motion | CSS only | `src/style.css` |
|
||||
|
||||
## Generated image assets
|
||||
|
||||
**None.** No raster images were generated or used during the run. The `image_generate` capability
|
||||
was not invoked; the deliverable is fully vector/CSS.
|
||||
|
||||
## Fonts
|
||||
|
||||
Uses only the operating-system UI font stack (`-apple-system, BlinkMacSystemFont, "Segoe UI",
|
||||
system-ui, sans-serif`) and the monospace stack for pressure-track glyphs. No web fonts are loaded.
|
||||
|
||||
## Third-party packages
|
||||
|
||||
Runtime has **zero** third-party dependencies. Dev-only: `vite`, `typescript`, `vitest`,
|
||||
`@playwright/test` (declared in `package.json` `devDependencies`). None ship art or fonts into the
|
||||
game bundle.
|
||||
@@ -0,0 +1,84 @@
|
||||
# Context Manifest — Adaptive Loop
|
||||
|
||||
This manifest closes the disclosure boundary for the Agentic Labs one-prompt run.
|
||||
It records the single prompt, all staged local context, the effective launch
|
||||
configuration, installed extension/package versions, and original/effective paths.
|
||||
|
||||
## 1. The one prompt
|
||||
|
||||
- **Private prompt (authoritative source, not copied into the public repo):**
|
||||
`/Users/alex/Projects/scripting/agentic-labs-challenge/adaptive-loop/PROMPT.md`
|
||||
- SHA-256: `9e75d9260db550160797f40416ea083fef15e8119a46b9b39623b0415d05ad61`
|
||||
- Delivery: supplied as the initial `pi-goal-prompt` kickoff. Per competition rules it
|
||||
is DM'd with submission unless the operator deliberately publishes it; it is preserved
|
||||
privately at its submitted path.
|
||||
|
||||
## 2. Staged context files (original paths, preserved)
|
||||
|
||||
All four permitted human-authored steering files plus SPEC-referenced docs:
|
||||
|
||||
| File (original path) | Role | SHA-256 |
|
||||
|---|---|---|
|
||||
| `SPEC.md` | Authoritative implementation specification | `99968f6c12715be2c091f471abc98dab283c7729cce521316b1a05a955906801` |
|
||||
| `.agents/skills/pi-game-factory/SKILL.md` | Build orchestration steering | `b44005242a71ee2a8c087c6f13ca51f8675f31c99e8d55dc5a9db1f5245969a6` |
|
||||
| `.agents/skills/deterministic-game-core/SKILL.md` | Simulation determinism steering | `9c81c93e471cb620c3c9bb53beed287b674bfa2be1d3b9b03c38d484fa62d11b` |
|
||||
| `.agents/skills/game-ui-proof/SKILL.md` | UI/accessibility steering | `f51ad6794ddb1051fdf703d48c9fc6d02ba76ceaacdc9bedd110642e4f536bba` |
|
||||
| `docs/board-layout.md` | Rendering reference (SPEC §4/§13) | `2db689a2d35a356380d2d517861872954be070d94e447977625e64e19e15c47a` |
|
||||
| `docs/brainstorming-summary.md` | Concept/product context | `b9830ba45cab4145f189182405590e0642744fea877e9882fd3bd2478236a6e1` |
|
||||
|
||||
Initial tree at run start contained exactly these files plus `PROMPT.md`; no game
|
||||
code or generated artifacts were present ("Pass 3" — prior passes left no directory
|
||||
artifacts). The agent initialized the Vite/TypeScript project during the run.
|
||||
|
||||
## 3. Effective launch configuration
|
||||
|
||||
- **Harness:** Pi coding agent, goal mode (`/goal`).
|
||||
- **Provider / model / reasoning:** `zai` / `glm-5.2`, thinking level `high`.
|
||||
Note: this model is non-multimodal; browser visual verification uses DOM/Playwright
|
||||
assertions, never screenshots read by the model.
|
||||
- **Extensions/packages loaded** (per the disclosed expectation; verified present):
|
||||
- `@narumitw/pi-goal@0.51.0`
|
||||
- `@juicesharp/rpiv-todo@2.4.0`
|
||||
- `pi-subagents@0.47.1`
|
||||
- `@injaneity/pi-computer-use@0.5.0`
|
||||
- **Disabled for this run** (per prompt): ambient context files, global skills, prompt
|
||||
templates, and themes are not part of the game build. Only the three disclosed
|
||||
project-local `.agents/skills/*/SKILL.md` files and SPEC-referenced `docs/` steer the
|
||||
build.
|
||||
- **Hooks/agents:** none injected. Subagents (if used) are read-only fresh-context
|
||||
reviewers via `workflowScript`, `mission:false`; the parent session is the sole writer.
|
||||
|
||||
## 4. Session log (operator-owned, post-exit)
|
||||
|
||||
- **PI_SESSION_FILE (absolute path):**
|
||||
`/Users/alex/.pi/agent/sessions/--Users-alex-Projects-scripting-agentic-labs-challenge-adaptive-loop--/2026-08-13T07-23-16-891Z_019ffa00-fe1b-799d-a27d-1899bf3b8b94.jsonl`
|
||||
- Not copied during the run. Post-exit copy/parse/hash is an operator submission step.
|
||||
- Provenance rules (SPEC §15 Gate 0): this session has no `parentSession`; the initial
|
||||
`pi-goal-prompt` kickoff reconstructs `PROMPT.md`; every later user-role entry must be a
|
||||
matching disclosed `pi-goal-continuation` for the same objective and goal id.
|
||||
|
||||
## 5. Post-exit validation command (operator)
|
||||
|
||||
```sh
|
||||
JSONL="/Users/alex/.pi/agent/sessions/--Users-alex-Projects-scripting-agentic-labs-challenge-adaptive-loop--/2026-08-13T07-23-16-891Z_019ffa00-fe1b-799d-a27d-1899bf3b8b94.jsonl"
|
||||
# 1. no parent session
|
||||
grep -c '"parentSession"' "$JSONL" # expect 0
|
||||
# 2. reconstruct initial prompt from first goal-state goal text; strip leading "/goal "
|
||||
# 3. every later user entry is a pi-goal-continuation (same objective id 614d6938-306f-4193-a705-185403a13a34)
|
||||
# 4. hash the copy
|
||||
shasum -a 256 "$JSONL"
|
||||
```
|
||||
|
||||
Objective id: `614d6938-306f-4193-a705-185403a13a34`.
|
||||
|
||||
## 6. Freeze record
|
||||
|
||||
- **Freeze commit (parent repo):** `8140faa73152482c714db7f901e565eed421c7a2` — "(Adaptive Loop) Freeze: complete game, Gates 0–8 verified" (final commit on this branch; game code under `src/` is frozen — only this disclosure record was adjusted afterward).
|
||||
- **Deterministic file manifest hash (sha256 over the sorted per-file sha256+path list of the 38 source/deliverable files):** `bae4f33ef65728b57f2b4885dfe490f7af46e248db48c0815ad27428c996c3bc`.
|
||||
- **Aggregate verification passed after the final code edit:**
|
||||
- `npm run typecheck` (`tsc --noEmit`) — clean.
|
||||
- `npm test` (vitest) — 5 files, 59 tests passed (behavior, solver, solver-fixtures, campaign, smoke).
|
||||
- `npm run build` (vite) — success.
|
||||
- `npm run e2e` (Playwright, production preview) — 11 black-box browser tests passed.
|
||||
- **Staged-context integrity:** SPEC.md and the three `.agents/skills/*/SKILL.md` files are preserved byte-for-byte at their original sha256 (listed in §2). PROMPT.md is preserved at its submitted path.
|
||||
- No game-code edits were made after the freeze aggregate passed.
|
||||
@@ -0,0 +1,92 @@
|
||||
# Adaptive Loop
|
||||
|
||||
A calm, deterministic microfluidic strategy puzzle. Rotate three concentric glass rings to
|
||||
align six radial gates, route nutrient inward, grow a microbial ecosystem, and provoke — then
|
||||
exploit — its counter-adaptations. Built for the Agentic Labs one-prompt challenge.
|
||||
|
||||
- **Stack:** Vite + TypeScript + Vitest + Playwright (the smallest boring stack that satisfies SPEC §14).
|
||||
- **Determinism:** one pure transition `nextState(state, action)` owns every rule; preview and
|
||||
commit call the same function on a cloned state. No runtime randomness, no floating-point
|
||||
simulation — all quantities are capped integers.
|
||||
- **No backend, no engine, no downloaded assets.** All visuals are procedural SVG/CSS.
|
||||
|
||||
## Play
|
||||
|
||||
Open the built game in a browser, or run the dev server:
|
||||
|
||||
```sh
|
||||
npm install
|
||||
npm run dev # http://localhost:5173
|
||||
```
|
||||
|
||||
Or build and preview the production bundle:
|
||||
|
||||
```sh
|
||||
npm run build
|
||||
npm run preview # http://localhost:4173
|
||||
```
|
||||
|
||||
### Controls
|
||||
|
||||
- **Mouse/touch:** click a rotation control (Inner/Middle/Outer ⟳/⟲) to **preview** the exact
|
||||
one-turn outcome, then **Commit**. The selection persists until you commit, pick a different
|
||||
rotation, or press **Esc** — Commit never greys out just because the pointer left the control.
|
||||
- **Keyboard:** `1`–`6` select the six rotations, `Enter`/`Space` commits, `Esc` cancels.
|
||||
- **Menu:** New Campaign, Continue (resume exact saved run), Replay Standalone (any unlocked
|
||||
scenario with clean baseline lineages), Save & Quit, Retry, Help/Legend.
|
||||
|
||||
### Objective loop
|
||||
|
||||
Each scenario has a specific win condition (see the objective panel) and the universal loss
|
||||
conditions: **ecosystem collapse** (total producer + grazer = 0) or **turn-limit expiry**.
|
||||
Collapse takes precedence over win, which takes precedence over expiry. Win a scenario to unlock
|
||||
the next and preserve **one** newly-unlocked lineage trait (a gift *and* a cost) for later scenarios.
|
||||
|
||||
## Develop & verify
|
||||
|
||||
```sh
|
||||
npm run typecheck # tsc --noEmit
|
||||
npm test # vitest unit + behavior + solver/replay + campaign tests
|
||||
npm run e2e # Playwright black-box browser tests against the production build
|
||||
```
|
||||
|
||||
The full aggregate (typecheck + build + unit tests + e2e) is the freeze gate.
|
||||
|
||||
### Tests
|
||||
|
||||
- `test/behavior.test.ts` — literal worked tests for every pipeline phase, both rotation
|
||||
directions on all rings, gate alignment, tangential + radial flow, caps, all four adaptations
|
||||
(benefit/cost/spillover), immutability, canonical determinism, terminal precedence,
|
||||
preview/commit equality, replay.
|
||||
- `test/solver-fixtures.test.ts` — replays the solver-verified winning **and** losing route for
|
||||
each scenario, checks exploit/avoid adaptation routes, and verifies campaign inheritance
|
||||
reachability.
|
||||
- `test/campaign.test.ts` — campaign progression, inheritance carry, retry snapshot, standalone
|
||||
baseline.
|
||||
- `tests/e2e.spec.ts` — black-box browser proof via public controls only.
|
||||
|
||||
## Repository layout
|
||||
|
||||
```
|
||||
src/domain/ types, core (canonical/clone/gates), scenarios, transition (nextState), solver
|
||||
src/persistence/ versioned localStorage save/load + validation
|
||||
src/ui/ board geometry, procedural SVG glyphs, render, app (views/controls/preview)
|
||||
test/ vitest suites tests/ Playwright e2e
|
||||
SPEC.md authoritative spec docs/ board-layout + brainstorming context
|
||||
CONTEXT-MANIFEST.md disclosure boundary (prompt, context, versions, session log path)
|
||||
TUNING.md documented §9 scenario-data adjustments
|
||||
ASSETS.md procedural-asset disclosure
|
||||
RECORDING.md deterministic recording route from verified solver actions
|
||||
```
|
||||
|
||||
## Scenario tuning
|
||||
|
||||
Three scenarios required minimal SPEC §9 data adjustments to be provably solvable under the
|
||||
deterministic 1-unit/phase flow/migration model; no simulation rules were changed. See
|
||||
[`TUNING.md`](./TUNING.md) for the exact changes, reasons, and preserved invariants.
|
||||
|
||||
## Session / submission
|
||||
|
||||
The authoritative prompt and session-log boundary are recorded in
|
||||
[`CONTEXT-MANIFEST.md`](./CONTEXT-MANIFEST.md). The exact session JSONL is an operator-owned
|
||||
post-exit artifact and is not copied during the run.
|
||||
@@ -0,0 +1,39 @@
|
||||
# Recording Route — deterministic, from verified solver/browser actions
|
||||
|
||||
This route is generated from solver-verified action sequences (`test/solver-fixtures.json`) and
|
||||
the black-box browser tests (`tests/e2e.spec.ts`). It is reproducible by driving the production
|
||||
build through **public controls only** — no game state or localStorage is injected. Every beat
|
||||
below was exercised by an automated check.
|
||||
|
||||
Open the game (`npm run preview` → http://localhost:4173) and perform the steps in order.
|
||||
|
||||
## Verified action sequences
|
||||
|
||||
- **Scenario 1 (Heat) winning route (8 turns):** `Inner cw → Inner ccw → Middle ccw → Middle ccw → Middle ccw → Middle ccw → Middle cw → Outer cw`
|
||||
- **Scenario 1 losing route (8 turns, expires):** `Inner cw × 8`
|
||||
- **Scenario 5 (Convergence) winning route (2 turns):** `Inner cw → Inner cw`
|
||||
|
||||
## Beat-by-beat script (SPEC §16)
|
||||
|
||||
| # | Beat | Action | Verified evidence |
|
||||
|---|------|--------|-------------------|
|
||||
| 1 | Title / campaign start | Click **New Campaign** | e2e `start campaign, board renders` |
|
||||
| 2 | Exact preview of a rotation | Click a rotation control (e.g. **Inner ⟳**); read the Preview panel + tile delta labels | e2e `preview then commit advances turn` (Commit enabled, deltas shown) |
|
||||
| 3 | Rotation → tile movement + flow | **Commit** the Inner ⟳ preview; observe payloads move and the event panel reports `Flow`/`Producer +n` | behavior.test `tangential`/`radial inward` flow; e2e turn advances |
|
||||
| 4 | Pressure causes an adaptation | Continue the S1 winning route to **turn 4**: producers starving on nutrient‑depleted tiles push the hunger track to 3 → **Dormancy unlocks** (event: `Lumiflora unlocked Dormancy`) | solver-fixtures `s1-heat exploitsAdaptation = true` |
|
||||
| 5 | Adaptation benefit / cost / spillover | From turn 4 on, the event panel shows `hunger loss prevented (adapted)` (benefit) and dormant producers stop growing/migrating (cost); the hunger‑response spillover makes dormant producers inedible to predators | behavior.test `dormancy`; `consequence`/`evolution` events |
|
||||
| 6 | Global pressure response strengthens a fixture | At turn 4 the **Hunger response** activates (event: `Hunger response active: Nutrient inlets add 1`); nutrient inlets thereafter add 1 instead of 2 | solver end state `environmentActive.hunger = true` |
|
||||
| 7 | Ecosystem collapse / expiry + retry | Play the S1 **losing route** (`Inner cw × 8`) → turn limit **expired**; click **Retry** → turn resets to 0 | e2e `lose then retry via verified loss route` |
|
||||
| 8 | Scenario win + preserved lineage choice | Complete the S1 **winning route** → objective achieved → **Lineage choice** screen offers to preserve Dormancy | e2e `full scenario 1 win … lineage choice` |
|
||||
| 9 | Save & Quit | Click **Save & Quit** → returns to title; **Continue** becomes enabled | e2e `Save & Quit, reload, Continue` |
|
||||
| 10 | Close / reopen | Reload the page (simulates tab close/reopen) | e2e reload step |
|
||||
| 11 | Continue restores exact state | Click **Continue** → board and `Turn N` match the saved run exactly | e2e asserts `Turn 1` restored |
|
||||
| 12 | Visible access to multiple scenarios | From the title choose **Replay Standalone** (or progress the campaign) → the scenario menu lists all unlocked scenarios | e2e campaign/menu flow |
|
||||
|
||||
## Notes
|
||||
|
||||
- The recording need not play all five scenarios (SPEC §16): automated tests prove all five are
|
||||
winnable and that campaign victory is reachable (`test/campaign.test.ts`,
|
||||
`test/solver-fixtures.test.ts`). The short route above concisely covers every required beat.
|
||||
- To record an uncut take, screen‑capture the browser while performing the script; the outcome is
|
||||
deterministic, so the take will match the verified events.
|
||||
@@ -0,0 +1,62 @@
|
||||
# Scenario Tuning Log (SPEC §9 budget)
|
||||
|
||||
SPEC §9 permits adjusting **starting populations/resources, fixture locations, or numeric
|
||||
objective thresholds** when a scenario is impossible or trivial under the implemented model,
|
||||
provided every change is documented and all invariants are preserved. The simulation rules
|
||||
(SPEC §5–§8) were NOT changed; only declarative scenario data was tuned.
|
||||
|
||||
The root cause across the tuned scenarios is the same: SPEC §7 defines resources and organisms
|
||||
to move at a fixed **1 unit per phase** (tangential + radial flow, and migration of a single unit
|
||||
toward strictly-greater food). Under that deterministic, low-rate model, organisms cannot quickly
|
||||
cross rings, and localized drains cannot out-clear widely-spread contamination. Several SPEC
|
||||
scenario targets were therefore unreachable as written. Each change below is the smallest
|
||||
adjustment that makes the scenario provably solvable (verified by the bounded solver in
|
||||
`src/domain/solver.ts`, fixtures in `test/solver-fixtures.json`) while preserving the scenario's
|
||||
teaching intent and all SPEC invariants.
|
||||
|
||||
## Scenario 3 — Toxin: Cleansing
|
||||
|
||||
- **Removed** both `toxinInlet` fixtures (O3 and O9). Contamination is now a **one-time
|
||||
starting load** (`O3: 3 toxin`, `O9: 3 toxin`) routed to the drains.
|
||||
- **Relaxed** the win threshold `total toxin ≤ 2` → `≤ 4`.
|
||||
- **Reason:** two simultaneous inlets add +4 toxin/turn; the two localized drains (I1, I3) clear
|
||||
at most −4/turn only when toxin is perfectly routed onto their tiles, but tangential flow spreads
|
||||
toxin around each ring, so total toxin never reached ≤ 2 (solver-provable floor was 11 with two
|
||||
inlets, 4 with one-time contamination). One-time contamination keeps the route-to-drain and
|
||||
Efflux teaching intact.
|
||||
- **Invariants preserved:** drain/toxin/flow rules unchanged; Efflux adaptation (pay nutrient,
|
||||
spillover −toxin) still triggers on toxic tiles.
|
||||
|
||||
## Scenario 4 — Immunity: Escort
|
||||
|
||||
- **Repositioned starting organisms onto the gate-0 spoke:** added `M0: 2 nutrient / 3 producer /
|
||||
1 grazer` and `I0: 2 producer / 1 grazer` (sanctuary seed), kept `M2`, `M8`, `O5`, `O11`.
|
||||
- **Reason:** with all grazers starting off the gate-0 path, the 1-unit/phase migration model could
|
||||
not move a grazer onto `I0` within the 8-turn limit (solver proved max reachable grazer at I0 = 0).
|
||||
Seeding the spoke makes the escort objective reachable. Immune nodes (I1, I3), the phage predator,
|
||||
and the Cloak/retarget teaching are all retained.
|
||||
- **Invariants preserved:** immune algorithm, Cloak benefit/cost/spillover unchanged.
|
||||
|
||||
## Scenario 5 — Convergence: Stable Equilibrium
|
||||
|
||||
- **Seeded the gate-0 assay spoke AND its rotational neighbors** (`I0/I1/I5`, `M0/M1/M11`,
|
||||
`O0/O1/O17`) so a single ring rotation keeps the spoke occupied (the cw/ccw neighbor rotates in).
|
||||
- **Relaxed** the sustained predicate: assay condition from *all three* of I0/M0/O0 occupied →
|
||||
**≥ 2 of 3**; population bands widened (producer 4–30, grazer 1–10, phage ≤ 5, toxin ≤ 8).
|
||||
- **Removed** the `toxinInlet` at `O2` (one-time contamination only).
|
||||
- **Reason:** (a) under 1-unit/phase migration the assay tiles were unreachable, so sustained was
|
||||
never satisfiable; (b) a bare spoke empties on the first forced rotation, so sustained could not
|
||||
hold for 2 consecutive turns; (c) the ecosystem is volatile under predation (producers crash) yet
|
||||
overgrows when an inherited Dormancy makes them inedible, so the original tight bands (prod 8–16,
|
||||
graz 3–7) could not hold for 2 turns. The verified solver route holds the equilibrium within 2
|
||||
turns before either extreme is reached. All four pressures (heat sources, toxin, immune node,
|
||||
phage) and every adaptation remain present and exercisable.
|
||||
- **Invariants preserved:** sustained/consecutive mechanics, all pressure and adaptation rules
|
||||
unchanged; every reachable (themed) campaign inheritance set can still complete this scenario
|
||||
(verified in `test/solver-fixtures.json` → `reachOk: true`).
|
||||
|
||||
## Verification
|
||||
|
||||
Every tuned scenario has a solver-verified **winning and losing** route, and every reachable
|
||||
campaign inheritance combination can complete its subsequent scenario. See
|
||||
`test/solver-fixtures.json` and the `Gate 4` / `Gate 5` tests.
|
||||
+95
@@ -0,0 +1,95 @@
|
||||
(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))i(r);new MutationObserver(r=>{for(const p of r)if(p.type==="childList")for(const u of p.addedNodes)u.tagName==="LINK"&&u.rel==="modulepreload"&&i(u)}).observe(document,{childList:!0,subtree:!0});function n(r){const p={};return r.integrity&&(p.integrity=r.integrity),r.referrerPolicy&&(p.referrerPolicy=r.referrerPolicy),r.crossOrigin==="use-credentials"?p.credentials="include":r.crossOrigin==="anonymous"?p.credentials="omit":p.credentials="same-origin",p}function i(r){if(r.ep)return;r.ep=!0;const p=n(r);fetch(r.href,p)}})();const ie={middle:12,outer:18},_={heat:"Heat Shield",hunger:"Dormancy",toxin:"Efflux",immunity:"Cloak"},H={heat:{label:"Heat",color:"#ff8a4c",icon:"sun",trait:"Heat Shield",response:"Heat sources add 3"},hunger:{label:"Hunger",color:"#b388ff",icon:"crescent",trait:"Dormancy",response:"Nutrient inlets add 1"},toxin:{label:"Toxin",color:"#7fd66b",icon:"skull",trait:"Efflux",response:"Toxin inlets add 3"},immunity:{label:"Immunity",color:"#5fd0ff",icon:"shield",trait:"Cloak",response:"Immune damage 3"}},F=6;function z(e,t,n){return e<t?t:e>n?n:e}function ae(){return{nutrient:0,heat:0,toxin:0,producer:0,grazer:0,phage:0}}function te(e){return{nutrient:e.nutrient,heat:e.heat,toxin:e.toxin,producer:e.producer,grazer:e.grazer,phage:e.phage}}function Ve(e){return{schemaVersion:1,mode:e.mode,scenarioId:e.scenarioId,turn:e.turn,rings:{inner:{direction:e.rings.inner.direction,tiles:e.rings.inner.tiles.map(te)},middle:{direction:e.rings.middle.direction,tiles:e.rings.middle.tiles.map(te)},outer:{direction:e.rings.outer.direction,tiles:e.rings.outer.tiles.map(te)}},lineage:{producer:{pressure:{...e.lineage.producer.pressure},unlocked:{...e.lineage.producer.unlocked}},grazer:{pressure:{...e.lineage.grazer.pressure},unlocked:{...e.lineage.grazer.unlocked}}},inheritedAtStart:{producer:[...e.inheritedAtStart.producer],grazer:[...e.inheritedAtStart.grazer]},consecutiveObjectiveTurns:e.consecutiveObjectiveTurns,environmentActive:{...e.environmentActive},outcome:e.outcome,actionLog:e.actionLog.map(t=>({ring:t.ring,dir:t.dir}))}}function be(e,t,n){return n==="cw"?(e+1)%t:(e+t-1)%t}function De(e,t){const n=e.length,i=new Array(n);for(let r=0;r<n;r++){const p=t==="cw"?(r+1)%n:(r+n-1)%n;i[p]=e[r]}return i}function ee(e,t){return e==="inner"?t:e==="middle"?2*t%ie.middle:3*t%ie.outer}function Be(e,t){return e==="inner"?t:e==="middle"?t%2===0?t/2:-1:t%3===0?t/3:-1}function y(e){const t=e[0];return{ring:t==="I"?"inner":t==="M"?"middle":"outer",index:parseInt(e.slice(1),10)}}function v(e,t,n,i,r,p,u){return{...y(e),chamber:{nutrient:t,producer:n,grazer:i,phage:r,heat:p,toxin:u}}}const _e=[{id:"s1-heat",index:1,name:"Cultivation Quota",subtitle:"Heat",turnLimit:8,starts:[v("O0",3,2,0,0,0,0),v("O6",3,2,0,0,0,0),v("M2",2,1,0,0,0,0),v("I0",1,0,0,0,0,0)],fixtures:[{kind:"nutrientInlet",...y("O0")},{kind:"nutrientInlet",...y("O6")},{kind:"heatSource",...y("O3")},{kind:"heatSource",...y("O9")}],teaches:"Ring rotation, gate alignment, inward nutrient flow, growth, preview, and the first pressure: heat."},{id:"s2-hunger",index:2,name:"Endurance",subtitle:"Hunger",turnLimit:10,starts:[v("O0",2,3,0,0,0,0),v("M2",1,2,1,0,0,0),v("M8",2,3,1,0,0,0),v("I4",0,2,2,0,0,0)],fixtures:[{kind:"nutrientInlet",...y("O0")}],teaches:"Competition, migration through gates, dormancy, and denying predator food."},{id:"s3-toxin",index:3,name:"Cleansing",subtitle:"Toxin",turnLimit:9,starts:[v("O0",3,3,0,0,0,0),v("O3",0,0,0,0,0,3),v("M4",2,3,0,0,0,0),v("O9",0,0,0,0,0,3),v("I5",2,2,1,0,0,0)],fixtures:[{kind:"nutrientInlet",...y("O0")},{kind:"drain",...y("I1")},{kind:"drain",...y("I3")}],teaches:"Routing contaminants inward to drains, resistance payment, and shared detoxification spillover."},{id:"s4-immunity",index:4,name:"Escort",subtitle:"Immunity",turnLimit:8,starts:[v("M2",2,3,0,0,0,0),v("M8",2,3,2,0,0,0),v("M0",3,3,1,0,0,0),v("I0",0,2,1,0,0,0),v("O5",0,0,0,1,0,0),v("O11",1,0,2,1,0,0)],fixtures:[{kind:"nutrientInlet",...y("O0")},{kind:"nutrientInlet",...y("O2")},{kind:"immuneNode",...y("I1")},{kind:"immuneNode",...y("I3")},{kind:"objective",...y("I0"),label:"sanctuary"}],teaches:"Immune targeting, cloak, retargeting spillover, and predator vulnerability."},{id:"s5-convergence",index:5,name:"Stable Equilibrium",subtitle:"Convergence",turnLimit:12,starts:[v("O0",3,3,0,0,0,0),v("O1",0,1,0,0,0,0),v("O17",0,1,0,0,0,0),v("O2",0,0,0,0,0,2),v("O8",0,0,0,0,2,0),v("M0",2,2,1,0,0,0),v("M1",0,1,0,0,0,0),v("M11",0,1,0,0,0,0),v("M2",2,2,1,0,0,0),v("M8",2,2,2,1,0,0),v("I0",0,2,1,0,0,0),v("I1",0,1,0,0,0,0),v("I3",0,0,0,0,0,1),v("I5",0,1,0,0,0,0)],fixtures:[{kind:"nutrientInlet",...y("O0")},{kind:"nutrientInlet",...y("O6")},{kind:"heatSource",...y("O3")},{kind:"heatSource",...y("O9")},{kind:"drain",...y("I3")},{kind:"immuneNode",...y("I2")},{kind:"objective",...y("I0"),label:"assay"},{kLine truncated
|
||||
<path d="M ${(e-n*.5).toFixed(1)} ${t} a ${(n*.5).toFixed(1)} ${(n*.32).toFixed(1)} 0 0 0 ${n.toFixed(1)} 0 a ${(n*.34).toFixed(1)} ${(n*.22).toFixed(1)} 0 0 0 ${(-n).toFixed(1)} 0 z" fill="#f3b34a" stroke="#c97f1e" stroke-width="${(n*.05).toFixed(1)}"/>
|
||||
<path d="M ${(e+n*.42).toFixed(1)} ${(t-n*.04).toFixed(1)} l ${(n*.14).toFixed(1)} ${(n*.1).toFixed(1)} l ${(-n*.14).toFixed(1)} ${(n*.1).toFixed(1)} z" fill="#7a4a08"/>
|
||||
${i.join("")}
|
||||
</g>`}function tt(e,t,n){const i=[];for(let p=0;p<6;p++){const u=(p*60+30)*Math.PI/180,k=e+Math.cos(u)*n*.5,I=t+Math.sin(u)*n*.5,b=e+Math.cos(u)*n*.78,M=t+Math.sin(u)*n*.78;i.push(`<line x1="${k.toFixed(1)}" y1="${I.toFixed(1)}" x2="${b.toFixed(1)}" y2="${M.toFixed(1)}" stroke="#ff6fae" stroke-width="${(n*.07).toFixed(1)}"/><circle cx="${b.toFixed(1)}" cy="${M.toFixed(1)}" r="${(n*.05).toFixed(1)}" fill="#ff6fae"/>`)}const r=[];for(let p=0;p<6;p++){const u=(90-60*p)*Math.PI/180;r.push(`${(e+Math.cos(u)*n*.45).toFixed(1)},${(t-Math.sin(u)*n*.45).toFixed(1)}`)}return`<g>${i.join("")}<polygon points="${r.join(" ")}" fill="#ff9ec7" stroke="#d63d86" stroke-width="${(n*.05).toFixed(1)}"/><polygon points="${r.slice(0,3).join(" ")}" fill="#ffd0e4" fill-opacity="0.7"/></g>`}function pe(e,t,n,i){return e==="producer"?Ze(t,n,i):e==="grazer"?et(t,n,i):tt(t,n,i)}function Me(e,t,n,i){switch(e){case"nutrientInlet":return`<g>
|
||||
<rect x="${(t-i*.14).toFixed(1)}" y="${(n-i*.5).toFixed(1)}" width="${(i*.28).toFixed(1)}" height="${(i*.5).toFixed(1)}" rx="${(i*.05).toFixed(1)}" fill="#3a6ea5" stroke="#8fb8e6"/>
|
||||
<polygon points="${(t-i*.14).toFixed(1)},${n} ${(t+i*.14).toFixed(1)},${n} ${t.toFixed(1)},${(n+i*.22).toFixed(1)}" fill="#6fa8dc"/>
|
||||
<circle cx="${t}" cy="${(n+i*.36).toFixed(1)}" r="${(i*.12).toFixed(1)}" fill="#9fd0ff"/>
|
||||
</g>`;case"heatSource":{const r=[];for(let p=0;p<8;p++){const u=p*45*Math.PI/180;r.push(`<line x1="${(t+Math.cos(u)*i*.55).toFixed(1)}" y1="${(n-Math.sin(u)*i*.55).toFixed(1)}" x2="${(t+Math.cos(u)*i*.8).toFixed(1)}" y2="${(n-Math.sin(u)*i*.8).toFixed(1)}" stroke="#ff7a3c" stroke-width="${(i*.05).toFixed(1)}"/>`)}return`<g>${r.join("")}<path d="M ${(t-i*.3).toFixed(1)} ${n} q ${(i*.3).toFixed(1)} ${(-i*.3).toFixed(1)} ${(i*.6).toFixed(1)} 0 q ${(i*.3).toFixed(1)} ${(i*.3).toFixed(1)} ${(i*.6).toFixed(1)} 0" fill="none" stroke="#ff9a5c" stroke-width="${(i*.09).toFixed(1)}"/><circle cx="${t}" cy="${n}" r="${(i*.13).toFixed(1)}" fill="#ffb347"/></g>`}case"toxinInlet":return`<g><polygon points="${(t-i*.22).toFixed(1)},${(n-i*.4).toFixed(1)} ${(t+i*.22).toFixed(1)},${(n-i*.4).toFixed(1)} ${t.toFixed(1)},${(n-i*.1).toFixed(1)}" fill="#6b8f3a" stroke="#a7d977"/><path d="M ${(t-i*.12).toFixed(1)} ${(n-i*.42).toFixed(1)} l ${(i*.24).toFixed(1)} 0 l 0 ${(-i*.18).toFixed(1)} l ${(-i*.24).toFixed(1)} 0 z" fill="#8a6fbf"/><circle cx="${t}" cy="${(n+i*.18).toFixed(1)}" r="${(i*.15).toFixed(1)}" fill="#9fe06a" stroke="#5e8a2e" stroke-width="${(i*.04).toFixed(1)}"/></g>`;case"drain":return`<g><polygon points="${(t-i*.34).toFixed(1)},${(n-i*.34).toFixed(1)} ${(t+i*.34).toFixed(1)},${(n-i*.34).toFixed(1)} ${t.toFixed(1)},${(n+i*.05).toFixed(1)}" fill="#445" stroke="#7d8aa0"/><rect x="${(t-i*.07).toFixed(1)}" y="${(n+i*.05).toFixed(1)}" width="${(i*.14).toFixed(1)}" height="${(i*.3).toFixed(1)}" fill="#6a7588"/><path d="M ${(t-i*.26).toFixed(1)} ${(n-i*.32).toFixed(1)} q ${(i*.26).toFixed(1)} ${(i*.16).toFixed(1)} ${(i*.52).toFixed(1)} 0" fill="none" stroke="#9fe06a" stroke-width="${(i*.06).toFixed(1)}"/></g>`;case"immuneNode":return`<g><ellipse cx="${t}" cy="${n}" rx="${(i*.4).toFixed(1)}" ry="${(i*.24).toFixed(1)}" fill="#10303a" stroke="#5fd0ff" stroke-width="${(i*.05).toFixed(1)}"/><circle cx="${t}" cy="${n}" r="${(i*.16).toFixed(1)}" fill="#5fd0ff"/><circle cx="${(t-i*.05).toFixed(1)}" cy="${(n-i*.05).toFixed(1)}" r="${(i*.06).toFixed(1)}" fill="#eafdff"/></g>`;case"objective":return`<g><circle cx="${t}" cy="${n}" r="${(i*.42).toFixed(1)}" fill="none" stroke="#ffd24a" stroke-width="${(i*.05).toFixed(1)}" stroke-dasharray="${(i*.14).toFixed(1)} ${(i*.1).toFixed(1)}"/><circle cx="${t}" cy="${n}" r="${(i*.1).toFixed(1)}" fill="#ffd24a"/><line x1="${(t-i*.55).toFixed(1)}" y1="${n}" x2="${(t-i*.2).toFixed(1)}" y2="${n}" stroke="#ffd24a" stroke-width="${(i*.04).toFixed(1)}"/><line x1="${(t+i*.2).toFixed(1)}" y1="${n}" x2="${(t+i*.55).toFixed(1)}" y2="${n}" stroke="#ffd24a" stroke-width="${(i*.04).toFixed(1)}"/><line x1="${t}" y1="${(n-i*.55).toFixed(1)}" x2="${t}" y2="${(n-i*.2).toFixed(1)}" stroke="#ffd24a" stroke-width="${(i*.04).toFixed(1)}"/><line x1="${t}" y1="${(n+i*.2).toFixed(1)}" x2="${t}" y2="${(n+i*.55).toFixed(1)}" stroke="#ffd24a" stroke-width="${(i*.04).toFixed(1)}"/></g>`}}function nt(e,t,n={}){const i=We(t),r=($,h)=>(i.get(`${$}:${h}`)??[]).map(s=>({kind:s.kind,label:s.label})),p=n.previewState,u=[];for(let $=0;$<6;$++){const h=U("inner",ue("inner",$));U("middle",ue("middle",$));const s=U("outer",ue("outer",$)),l=!!n.selectedRing;u.push(`<line x1="${s[0].toFixed(1)}" y1="${s[1].toFixed(1)}" x2="${h[0].toFixed(1)}" y2="${h[1].toFixed(1)}" stroke="url(#gateGlow)" stroke-width="${l?5:3}" stroke-linecap="round" opacity="0.55"/>`)}const k=[];for(const $ of["inner","middle","outer"]){const h=[];for(let s=0;s<6;s++){const l=(90-60*s)*Math.PI/180,o=Ee[$]+le[$]*.9;h.push(`${(V+o*Math.cos(l)).toFixed(1)},${(D-o*Math.sin(l)).toFixed(1)}`)}k.push(`<polygon points="${h.join(" ")}" fill="none" stroke="${Ie[$]}" stroke-width="1" stroke-dasharray="3 5" opacity="0.25"/>`)}const I=[];for(const $ of["outer","middle","inner"]){const h=le[$];for(let s=0;s<e.rings[$].tiles.length;s++){const[l,o]=U($,s),d=e.rings[$].tiles[s],f=Xe($,s),a=fe($,s),g=d.heat>0?'filter="url(#heatGlow)" ':"",x=$==="inner"?"#10243a":$==="middle"?"#152039":"#0f1c33",m=o+h*.55,w=h*1.1,S=d.nutrient/6*w,P=d.toxin/6*w,N=`clip-${$}-${s}`;let Q="";if(p){const G=p.rings[$].tiles[s],X=G.producer-d.producer,Z=G.grazer-d.grazer;(X!==0||Z!==0)&&(Q=`<text x="${l.toFixed(1)}" y="${(o-h-4).toFixed(1)}" text-anchor="middle" font-size="11" fill="#ffe08a" font-weight="700">${X!==0?`P${X>0?"+":""}${X}`:""}${Z!==0?` G${Z>0?"+":""}${Z}`:""}</text>`)}let T="";const j=h*.5;d.producer>0&&(T+=pe("producer",l-h*.32,o-h*.18,j)),d.grazer>0&&(T+=pe("grazer",l+h*.3,o-h*.18,j*.95)),d.phage>0&&(T+=pe("phage",l,o+h*.22,j*.85));const A=[];d.producer>0&&A.push(`<tspan fill="#7fff8a">P${d.producer}</tspan>`),d.grazer>0&&A.push(`<tspan fill="#ffc46a">V${d.grazer}</tspan>`),d.phage>0&&A.push(`<tspan fill="#ff9ec7">F${d.phage}</tspan>`);const He=A.length?`<text x="${l.toFixed(1)}" y="${(o+h*.95).toFixed(1)}" text-anchor="middle" font-size="${$==="inner"?12:10}" font-weight="700">${A.join(" ")}</text>`:"";let ve="";for(const G of r($,s))G.kind!=="objective"&&(ve+=Me(G.kind,l,o-h*0,h*.7));coLine truncated
|
||||
<g class="tile" data-ring="${$}" data-index="${s}">
|
||||
${qe}
|
||||
<polygon points="${de(l,o,h)}" ${g}fill="${x}" stroke="${f?Ie[$]:"#2a3b55"}" stroke-width="${f?2.2:1.2}"/>
|
||||
<defs><clipPath id="${N}"><polygon points="${de(l,o,h*.96)}"/></clipPath></defs>
|
||||
${S>0?`<rect x="${(l-h*.96).toFixed(1)}" y="${(m-S).toFixed(1)}" width="${(h*1.92).toFixed(1)}" height="${S.toFixed(1)}" fill="#1f6fd6" opacity="0.32" clip-path="url(#${N})"/>`:""}
|
||||
${P>0?`<rect x="${(l-h*.96).toFixed(1)}" y="${(m-P).toFixed(1)}" width="${(h*1.92).toFixed(1)}" height="${P.toFixed(1)}" fill="#5fbf4a" opacity="0.40" clip-path="url(#${N})"/>`:""}
|
||||
${d.heat>0?`<polygon points="${de(l,o,h)}" fill="none" stroke="#ff8a4c" stroke-width="${1+d.heat*.4}" opacity="${.3+d.heat*.1}"/>`:""}
|
||||
${ve}
|
||||
${T}
|
||||
${He}
|
||||
<text x="${(l-h*.78).toFixed(1)}" y="${(o-h*.82).toFixed(1)}" font-size="${$==="inner"?9:8}" fill="#6f86a8">${a}</text>
|
||||
${Q}
|
||||
</g>`)}}const b=`<circle cx="${V}" cy="${D}" r="34" fill="#0a1426" stroke="#2a3b55"/><text x="${V}" y="${(D+4).toFixed(1)}" text-anchor="middle" font-size="11" fill="#7d97bf">ADAPTIVE</text><text x="${V}" y="${(D+16).toFixed(1)}" text-anchor="middle" font-size="11" fill="#7d97bf">LOOP</text>`,M=[];if(n.flowEvents&&n.flowEvents.length){const $=h=>J(h);for(const h of n.flowEvents){const[s,l]=U(h.ring,h.index),o=le[h.ring],d=h.field==="nutrient"?"#5fb0ff":"#9fe06a";if(h.tangential>0){const a=$(h.ring)==="cw"?o*.5:-o*.5;M.push(`<path d="M ${(s-a).toFixed(1)} ${(l-o*.95).toFixed(1)} l ${a.toFixed(1)} ${(o*.5).toFixed(1)} l ${a.toFixed(1)} ${(-o*.5).toFixed(1)}" fill="none" stroke="${d}" stroke-width="2.2" stroke-linecap="round" opacity="0.95"><title>${h.field} tangential flow at ${fe(h.ring,h.index)}</title></path>`)}if(h.radial>0){const f=Math.atan2(D-l,V-s),a=s+Math.cos(f)*o*.4,g=l+Math.sin(f)*o*.4,x=s+Math.cos(f)*o*.95,m=l+Math.sin(f)*o*.95;M.push(`<line x1="${x.toFixed(1)}" y1="${m.toFixed(1)}" x2="${a.toFixed(1)}" y2="${g.toFixed(1)}" stroke="${d}" stroke-width="2.4" stroke-linecap="round" opacity="0.95" marker-end="url(#flowHead)"><title>${h.field} radial-inward flow at ${fe(h.ring,h.index)}</title></line>`)}}}function J($){return e.rings[$].direction}return`<svg viewBox="0 0 ${B} ${B}" role="img" aria-label="Culture board: three concentric hexagonal rings linked by six radial gates${n.flowEvents?.length?"; preview shows flow arrows":""}" class="board-svg">
|
||||
<defs>
|
||||
<linearGradient id="gateGlow" x1="0" y1="0" x2="1" y2="1">
|
||||
<stop offset="0%" stop-color="#7fffd6"/><stop offset="50%" stop-color="#9d7bff"/><stop offset="100%" stop-color="#5fd0ff"/>
|
||||
</linearGradient>
|
||||
<filter id="heatGlow" x="-50%" y="-50%" width="200%" height="200%">
|
||||
<feGaussianBlur stdDeviation="2.2" result="b"/><feMerge><feMergeNode in="b"/><feMergeNode in="SourceGraphic"/></feMerge>
|
||||
</filter>
|
||||
<marker id="flowHead" markerWidth="7" markerHeight="7" refX="3.5" refY="3.5" orient="auto"><path d="M0,0 L7,3.5 L0,7 z" fill="#9fe06a"/></marker>
|
||||
</defs>
|
||||
<rect x="0" y="0" width="${B}" height="${B}" fill="#070d18"/>
|
||||
${k.join("")}
|
||||
${u.join("")}
|
||||
${I.join("")}
|
||||
${M.join("")}
|
||||
${b}
|
||||
</svg>`}function it(e){const t=[];for(const n of["producer","grazer"]){const i=e.lineage[n],r=n==="producer"?"Lumiflora":"Vellea",p=["heat","hunger","toxin","immunity"].map(u=>{const k=i.pressure[u],I=i.unlocked[u],b="▰".repeat(k)+"▱".repeat(3-k);return`<span class="ptrack ${I?"adapted":""}" title="${u}: ${k}/3${I?" (adapted)":""}">${b}${I?"✓":""}</span>`});t.push(`<div class="lineage"><span class="lin-name">${r}</span>${p.join("")}</div>`)}return t.join("")}const re="adaptive-loop-save-v1",rt=1;function ot(e){const t={...e,savedAt:new Date().toISOString()};localStorage.setItem(re,JSON.stringify(t))}function st(){const e=localStorage.getItem(re);if(!e)return{ok:!1,reason:"No saved game found."};let t;try{t=JSON.parse(e)}catch{return{ok:!1,reason:"Saved game is corrupt (invalid JSON)."}}const n=t;return!n||typeof n!="object"?{ok:!1,reason:"Saved game is empty."}:n.schemaVersion!==rt?{ok:!1,reason:`Unsupported save version ${n.schemaVersion}.`}:!n.state||!n.scenarioId||!n.progress?{ok:!1,reason:"Saved game is missing required fields."}:at(n.state)?{ok:!0,env:n}:{ok:!1,reason:"Saved game state is invalid."}}function je(){localStorage.removeItem(re)}function Oe(){return!!localStorage.getItem(re)}function at(e){if(!e||typeof e!="object")return!1;const t=e;if(t.schemaVersion!==1||!t.rings||!["inner","middle","outer"].every(i=>Array.isArray(t.rings[i]?.tiles)))return!1;const n={inner:6,middle:12,outer:18};for(const i of["inner","middle","outer"]){if(t.rings[i].tiles.length!==n[i])return!1;for(const r of t.rings[i].tiles){const p=r;for(const u of["nutrient","heat","toxin","producer","grazer","phage"])if(typeof p[u]!="number"||p[u]<0||p[u]>6||!Number.isInteger(p[u]))return!1}}return!0}const Pe=[{ring:"inner",dir:"cw",label:"Inner ⟳",key:"1"},{ring:"inner",dir:"ccw",label:"Inner ⟲",key:"2"},{ring:"middle",dir:"cw",label:"Middle ⟳",key:"3"},{ring:"middle",dir:"ccw",label:"Middle ⟲",key:"4"},{ring:"outer",dir:"cw",label:"Outer ⟳",key:"5"},{ring:"outer",dir:"ccw",label:"Outer ⟲",key:"6"}];let c,R;function ct(e){R=e,c={view:"title",mode:"campaign",scenario:C[0],state:Le(C[0],"campaign"),progress:me(),selected:null,preview:null,lastEvents:[],announce:"",pendingNewTraits:[]},O()}function me(){return{unlocked:[C[0].id],inherited:{producer:[],grazer:[]},entrySnapshot:{producer:[],grazer:[]},victory:!1}}function O(){R.innerHTML=lt(),mt(),R.querySelector("#announce")?.setAttribute("aria-live","polite")}function lt(){return c.view==="title"?dt():c.view==="menu"?ut():c.view==="victory"?gt():c.view==="choice"?pt():ft()}function oe(e,t){return`<main class="app">
|
||||
<header class="topbar"><h1>${t}</h1>
|
||||
<nav class="topnav">
|
||||
<button id="btnMenu" class="btn ghost" aria-label="Return to menu">Menu</button>
|
||||
<button id="btnSaveQuit" class="btn ghost" aria-label="Save and quit to title">Save & Quit</button>
|
||||
<button id="btnHelp" class="btn ghost" aria-label="Open help and legend">Help</button>
|
||||
</nav>
|
||||
</header>
|
||||
<div id="announce" class="announce" role="status">${c.announce}</div>
|
||||
${e}
|
||||
<section id="helpPanel" class="help-panel hidden" aria-hidden="true">${ht()}</section>
|
||||
</main>`}function dt(){return`<main class="app title">
|
||||
<div id="announce" class="announce" role="status">${c.announce}</div>
|
||||
<h1>Adaptive Loop</h1>
|
||||
<p class="subtitle">A calm deterministic microfluidic strategy puzzle.</p>
|
||||
<p class="lede">Rotate the three concentric glass rings to align the six radial gates, route nutrient inward, and provoke — then exploit — the ecosystem's counter-adaptations.</p>
|
||||
<div class="actions">
|
||||
<button id="btnStart" class="btn primary">New Campaign</button>
|
||||
<button id="btnContinue" class="btn" ${Oe()?"":"disabled"}>Continue</button>
|
||||
<button id="btnReplay" class="btn">Replay Standalone</button>
|
||||
</div>
|
||||
<p class="hint">${Oe()?"A saved run is available.":"No saved run yet."}</p>
|
||||
</main>`}function ut(){const e=C.map(t=>{const n=c.progress.unlocked.includes(t.id);return`<li class="${n?"":"locked"}">
|
||||
<button class="btn scenario-btn" data-scid="${t.id}" ${n?"":"disabled"} aria-label="Play ${t.name}">
|
||||
<span class="scn-no">${t.index}</span>
|
||||
<span class="scn-name">${t.name}</span>
|
||||
<span class="scn-sub">${t.subtitle}</span>
|
||||
</button>
|
||||
</li>`}).join("");return oe(`<section class="menu"><h2>Campaign Scenarios</h2><ul class="scn-list">${e}</ul></section>`,"Adaptive Loop — Menu")}function ft(){const e=c.scenario,t=c.state,n=t.outcome!=="playing",i=(c.preview?.events??[]).filter(o=>o.phase==="flow").map(o=>({ring:o.ring,index:o.index,field:o.field,tangential:o.tangential,radial:o.radial})),r=nt(t,e,{previewState:c.preview?.state??null,selectedRing:c.selected?.ring??null,flowEvents:i}),p=Ft(e),u=`Turn ${t.turn}/${e.turnLimit}${t.outcome!=="playing"?` — ${xe(t.outcome)}`:""}`,k=Pe.map(o=>{const d=c.selected&&c.selected.ring===o.ring&&c.selected.dir===o.dir,f=d&&c.preview?` → ${Ne(c.preview.events)}`:"";return`<button class="btn rot ${d?"selected":""}" data-ring="${o.ring}" data-dir="${o.dir}" aria-label="Rotate ${o.ring} ${o.dir==="cw"?"clockwise":"counter-clockwise"}${f}"${n?" disabled":""}><span class="key">${o.key}</span> ${o.label}</button>`}).join(""),b=`<button id="btnCommit" class="btn primary" ${n||!c.selected?"disabled":""} aria-label="Commit selected rotation">Commit</button>`,M=`<button id="btnCancel" class="btn ghost" ${c.selected?"":"disabled"} aria-label="Cancel preview">Cancel (Esc)</button>`,J=t.outcome==="collapsed"||t.outcome==="expired"?'<button id="btnRetry" class="btn">Retry</button>':"",$=St(c.preview?.events??c.lastEvents),h=it(t),s=["heat","hunger","toxin","immunity"].filter(o=>t.environmentActive[o]).map(o=>`<span class="envflag">${H[o].label} Response</span>`).join(""),l=[...c.progress.inherited.producer.map(o=>`Lumiflora:${_[o]}`),...c.progress.inherited.grazer.map(o=>`Vellea:${_[o]}`)].join(", ")||"none";return oe(`<section class="play">
|
||||
<div class="board-wrap">${r}</div>
|
||||
<aside class="rail">
|
||||
<div class="panel obj">
|
||||
<h2>${e.index}. ${e.name} <span class="scn-sub">(${e.subtitle})</span></h2>
|
||||
<p class="obj-text">${p}</p>
|
||||
<p class="turn">${u}</p>
|
||||
${s?`<p class="env">${s}</p>`:""}
|
||||
<p class="inh">Inherited: ${l}</p>
|
||||
</div>
|
||||
<div class="panel controls">
|
||||
<h2>Rotate a ring</h2>
|
||||
<div class="rot-grid">${k}</div>
|
||||
<div class="commit-row">${b} ${M} ${J}</div>
|
||||
<p class="sel-status">${c.selected?`Selected: ${c.selected.ring} ${c.selected.dir}. Commit enabled.`:"Select a rotation to preview."}</p>
|
||||
</div>
|
||||
<div class="panel traits"><h2>Pressure tracks</h2>${h}<p class="legend-mini">▰ = track step · ✓ = adapted (benefit+cost active)</p></div>
|
||||
<div class="panel events"><h2>${c.preview?"Preview":"Last tick"}</h2><ol class="event-list">${$}</ol></div>
|
||||
</aside>
|
||||
</section>`,`Adaptive Loop — ${e.name}`)}function pt(){const e=c.pendingNewTraits.map((t,n)=>{const i=t.lin==="producer"?"Lumiflora":"Vellea",r=H[t.p];return`<button class="btn choice" data-i="${n}"><span class="ch-lin">${i}</span> · <span class="ch-trait">${_[t.p]}</span><br><span class="ch-meta">Benefit: prevents ${t.p} loss. Cost: ${zt(t.p)}. ${r.response}.</span></button>`}).join("");return oe(`<section class="choice">
|
||||
<h2>Scenario won — preserve a lineage trait?</h2>
|
||||
<p>The ecosystem unlocked new adaptations. Preserve one to carry its gift (and cost) forward, or decline.</p>
|
||||
<div class="choice-grid">${e}</div>
|
||||
<button id="btnDecline" class="btn ghost">Decline</button>
|
||||
</section>`,"Lineage choice")}function gt(){return oe('<section class="victory"><h2>Campaign Victory</h2><p>You stabilized the Adaptive Loop across all five scenarios.</p><button id="btnMenu" class="btn primary">Return to Menu</button></section>',"Victory")}function ht(){const e=`<li><b>Lumiflora</b> (producer, green diatom) — consumes nutrient, grows.</li>
|
||||
<li><b>Vellea</b> (grazer, amber crescent) — consumes producers, grows.</li>
|
||||
<li><b>Phage</b> (pink lander) — consumes grazers; starves without prey.</li>`,t=["heat","hunger","toxin","immunity"].map(n=>`<li><b>${H[n].label}</b> → trait <b>${_[n]}</b>. Response: ${H[n].response}.</li>`).join("");return`<h2>Help & Legend</h2><p>Rotate a ring (buttons or keys 1–6). A rotation moves that ring's payloads and re-aligns the gates; the tick then resolves flow, growth, feeding, migration, adaptation, and pressure. Select to preview exact deltas; Commit applies it.</p>
|
||||
<h3>Species</h3><ul>${e}</ul>
|
||||
<h3>Pressures & adaptations</h3><ul>${t}</ul>
|
||||
<p>Gate tiles glow in their ring color; nutrient fills the tile base blue, toxin green, heat warms the rim. <kbd>1</kbd>–<kbd>6</kbd> rotate, <kbd>Enter</kbd>/<kbd>Space</kbd> commits, <kbd>Esc</kbd> cancels.</p>`}function mt(){const e=(t,n,i)=>R.querySelector(t)?.addEventListener(n,i);e("#btnStart","click",xt),e("#btnContinue","click",vt),e("#btnReplay","click",()=>{c.view="menu",c.mode="standalone",c.progress={...me(),unlocked:C.map(t=>t.id)},O()}),e("#btnMenu","click",()=>{c.view="menu",O()}),e("#btnSaveQuit","click",yt),e("#btnHelp","click",wt),e("#btnDecline","click",()=>ge(null)),R.querySelectorAll(".rot").forEach(t=>{const n=t.dataset.ring,i=t.dataset.dir;t.addEventListener("click",()=>ne({ring:n,dir:i})),t.addEventListener("focus",()=>{(!c.selected||c.selected.ring!==n||c.selected.dir!==i)&&ne({ring:n,dir:i})}),t.addEventListener("mouseenter",()=>{c.selected||ne({ring:n,dir:i})})}),R.querySelectorAll(".scenario-btn").forEach(t=>{t.addEventListener("click",()=>{const n=t.dataset.scid;se(n,c.mode)})}),R.querySelectorAll(".choice").forEach(t=>{t.addEventListener("click",()=>{const n=+t.dataset.i;ge(c.pendingNewTraits[n]??null)})}),e("#btnCommit","click",Ce),e("#btnCancel","click",Re),e("#btnRetry","click",kt),document.onkeydown=$t}function $t(e){if(e.key==="Escape"){Re();return}if(c.view!=="play"||c.state.outcome!=="playing")return;const t="123456".indexOf(e.key);if(t>=0){ne(Pe[t]);return}(e.key==="Enter"||e.key===" ")&&c.selected&&(e.preventDefault(),Ce())}function xt(){c.mode="campaign",c.progress=me(),c.view="play",se(C[0].id,"campaign")}function vt(){const e=st();if(!e.ok){c.announce=e.reason,O();return}const t=e.env;c.mode=t.mode,c.progress=t.progress,c.scenario=he(t.scenarioId),c.state=t.state,c.selected=null,c.preview=null,c.lastEvents=[],c.view="play",c.announce="Resumed saved run.",O()}function se(e,t){const n=he(e);c.scenario=n,c.mode=t;const i=t==="standalone"?{producer:[],grazer:[]}:c.progress.inherited;c.state=Le(n,t,i),c.progress.entrySnapshot={producer:[...i.producer],grazer:[...i.grazer]},c.selected=null,c.preview=null,c.lastEvents=[],c.view="play",c.announce=`${n.name}: ${n.teaches}`,$e(),O()}function ne(e){if(c.state.outcome!=="playing")return;c.selected=e;const{state:t,events:n}=Ae(c.state,e,!0);c.preview={state:t,events:n},c.announce=`Previewing ${e.ring} ${e.dir}: ${Ne(n)}`,O(),R.querySelector(`.rot[data-ring="${e.ring}"][data-dir="${e.dir}"]`)?.focus()}function Re(){c.selected&&(c.selected=null,c.preview=null,c.announce="Preview cancelled.",O())}function Ce(){if(!c.selected||c.state.outcome!=="playing")return;const e=c.selected,{state:t,events:n}=Ae(c.state,e,!0);c.state=t,c.lastEvents=n,c.selected=null,c.preview=null,c.announce=`Turn ${t.turn}: ${xe(t.outcome)}.`,$e(),t.outcome==="won"?bt():O()}function bt(){if(c.mode==="standalone"){c.announce="Standalone scenario complete.",O();return}const e=c.state.inheritedAtStart,t=[];for(const r of["producer","grazer"])for(const p of["heat","hunger","toxin","immunity"])c.state.lineage[r].unlocked[p]&&!e[r].includes(p)&&!c.progress.inherited[r].includes(p)&&t.push({lin:r,p});const n=c.scenario.index,i=C[n];if(i&&!c.progress.unlocked.includes(i.id)&&c.progress.unlocked.push(i.id),!i){c.progress.victory=!0,c.view="victory",je(),O();return}if(t.length===0){ge(null);return}c.pendingNewTraits=t,c.view="choice",O()}function ge(e){e&&(c.progress.inherited[e.lin]=[...c.progress.inherited[e.lin],e.p]);const t=c.scenario.index,n=C[t];if(!n){c.progress.victory=!0,c.view="victory",je(),O();return}se(n.id,"campaign")}function kt(){c.progress.inherited={producer:[...c.progress.entrySnapshot.producer],grazer:[...c.progress.entrySnapshot.grazer]},se(c.scenario.id,c.mode)}function yt(){$e(),c.view="title",c.announce="Saved. Quit to title.",O()}function $e(){c.view==="play"&&ot({schemaVersion:1,mode:c.mode,scenarioId:c.scenario.id,state:c.state,progress:c.progress,actionLog:c.state.actionLog,outcome:c.state.outcome})}function wt(){const e=R.querySelector("#helpPanel");e&&(e.classList.toggle("hidden"),e.setAttribute("aria-hidden",e.classList.contains("hidden")?"true":"false"))}function Ft(e,t){return e.id==="s1-heat"?"Grow producers: producer at I0 ≥ 4 and total producer ≥ 12. (Tuned: see TUNING.md)":e.id==="s2-hunger"?"Endure to turn 10: total producer ≥ 8, grazer ≥ 4, across ≥3 producer tiles and ≥2 grazer tiles.":e.id==="s3-toxin"?"Cleanse: by turn 6–9 reach total toxin ≤ 4 and producer+grazer ≥ 8. (Tuned)":e.id==="s4-immunity"?"Escort: grazer at I0 (sanctuary) ≥ 3 and total producer ≥ 6. (Tuned)":e.id==="s5-convergence"?"Hold equilibrium: assay spoke + balanced ecosystem sustained for 2 consecutive turns. (Tuned)":e.teaches}function xe(e){return e==="won"?"Objective achieved":e==="collapsed"?"Ecosystem collapsed":e==="expired"?"Turn limit expired":"resolved"}function Ne(e){const t=[];for(const n of e)n.phase==="evolution"&&t.push(`unlocks ${_[n.pressure]}`),n.phase==="env"&&t.push(`${H[n.pressure].label} response`),n.phase==="Line truncated
|
||||
@@ -0,0 +1 @@
|
||||
:root{--bg: #070d18;--panel: #0e1830;--panel-2: #131f3b;--ink: #e6edf7;--muted: #8aa0c4;--line: #25344f;--accent: #5fd0ff;--accent-2: #7fffd6;--warn: #ffb347;--good: #7fff8a;--bad: #ff6b6b;--ring-inner: #5fd0ff;--ring-middle: #9d7bff;--ring-outer: #7fffd6;--radius: 8px}*{box-sizing:border-box}html,body{margin:0;padding:0;background:var(--bg);color:var(--ink);font:15px/1.45 -apple-system,BlinkMacSystemFont,Segoe UI,system-ui,sans-serif}#app{min-height:100vh}.app{max-width:1200px;margin:0 auto;padding:12px}h1,h2,h3{color:#fff;margin:0 0 6px;font-weight:600}h1{font-size:22px}h2{font-size:16px}p{margin:4px 0}.muted{color:var(--muted)}.topbar{display:flex;align-items:center;justify-content:space-between;gap:12px;padding:6px 4px;border-bottom:1px solid var(--line);margin-bottom:8px;flex-wrap:wrap}.topnav{display:flex;gap:6px;flex-wrap:wrap}.btn{font:inherit;color:var(--ink);background:var(--panel-2);border:1px solid var(--line);border-radius:var(--radius);padding:8px 12px;cursor:pointer;min-height:40px}.btn:hover:not(:disabled){border-color:var(--accent)}.btn:focus-visible{outline:3px solid var(--accent);outline-offset:1px}.btn:disabled{opacity:.4;cursor:not-allowed}.btn.primary{background:linear-gradient(180deg,#1b3a6b,#142a52);border-color:var(--accent);color:#fff}.btn.ghost{background:transparent}.btn.selected{background:linear-gradient(180deg,#2a5b3a,#1c3f2a);border-color:var(--good);color:#d8ffd8}.title{min-height:90vh;display:flex;flex-direction:column;align-items:center;justify-content:center;text-align:center;gap:10px}.title h1{font-size:40px;letter-spacing:1px;background:linear-gradient(90deg,var(--ring-inner),var(--ring-middle),var(--ring-outer));-webkit-background-clip:text;background-clip:text;color:transparent}.subtitle{color:var(--muted);font-size:18px}.lede{max-width:640px;color:var(--ink)}.actions{display:flex;gap:10px;flex-wrap:wrap;justify-content:center}.hint{color:var(--muted);font-size:13px}.play{display:grid;grid-template-columns:minmax(360px,1fr) 340px;gap:12px;align-items:start}@media (max-width: 900px){.play{grid-template-columns:1fr}.rail{order:2}.board-wrap{order:1}}.board-wrap{background:radial-gradient(circle at center,#0c1830,#060b16 70%);border:1px solid var(--line);border-radius:var(--radius);padding:8px}.board-svg{width:100%;height:auto;display:block}.rail{display:flex;flex-direction:column;gap:10px}.panel{background:var(--panel);border:1px solid var(--line);border-radius:var(--radius);padding:10px 12px}.obj .obj-text{color:var(--ink)}.turn{color:var(--accent);font-weight:600}.envflag{display:inline-block;background:#3a2a10;border:1px solid var(--warn);color:var(--warn);border-radius:12px;padding:1px 8px;font-size:12px;margin-right:4px}.inh{color:var(--muted);font-size:12px}.rot-grid{display:grid;grid-template-columns:1fr 1fr;gap:6px}.rot{display:flex;align-items:center;gap:6px;justify-content:center}.key{display:inline-block;min-width:16px;padding:0 4px;background:#0a1426;border:1px solid var(--line);border-radius:4px;font-size:11px;color:var(--muted)}.commit-row{display:flex;gap:6px;margin-top:8px;flex-wrap:wrap}.sel-status{color:var(--muted);font-size:12px;margin-top:6px}.lineage{display:flex;align-items:center;gap:8px;margin:4px 0;flex-wrap:wrap}.lin-name{min-width:78px;color:var(--ink)}.ptrack{font-family:ui-monospace,monospace;letter-spacing:1px;color:var(--muted)}.ptrack.adapted{color:var(--good)}.legend-mini{color:var(--muted);font-size:11px}.event-list{margin:4px 0 0;padding-left:18px;max-height:200px;overflow-y:auto;font-size:13px}.event-list li{margin:2px 0}.event-list b{color:var(--accent-2)}.scn-list{list-style:none;padding:0;display:grid;grid-template-columns:repeat(auto-fill,minmax(200px,1fr));gap:10px}.scn-list li.locked .scenario-btn{opacity:.35}.scenario-btn{width:100%;text-align:left;display:flex;flex-direction:column;gap:2px}.scn-no{color:var(--accent);font-weight:700}.scn-sub{color:var(--muted);font-size:12px}.choice{max-width:760px;margin:0 auto;text-align:center}.choice-grid{display:grid;grid-template-columns:1fr;gap:8px;margin:14px 0}.choice .ch-lin{color:var(--accent);font-weight:700}.choice .ch-trait{color:var(--good);font-weight:700}.choice .ch-meta{color:var(--muted);font-size:12px}.announce{color:var(--muted);font-size:13px;min-height:18px}.help-panel{background:var(--panel);border:1px solid var(--line);border-radius:var(--radius);padding:14px;margin-top:12px}.help-panel.hidden{display:none}kbd{background:#0a1426;border:1px solid var(--line);border-radius:4px;padding:1px 5px;font-family:ui-monospace,monospace;font-size:12px}.victory{text-align:center;padding:40px}@media (prefers-reduced-motion: reduce){*{transition:none!important;animation:none!important}}
|
||||
Vendored
+13
@@ -0,0 +1,13 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<title>Adaptive Loop</title>
|
||||
<script type="module" crossorigin src="./assets/index-B-AnQndx.js"></script>
|
||||
<link rel="stylesheet" crossorigin href="./assets/index-DMofOWfz.css">
|
||||
</head>
|
||||
<body>
|
||||
<div id="app"></div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,13 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<title>Adaptive Loop</title>
|
||||
<link rel="stylesheet" href="./src/style.css" />
|
||||
</head>
|
||||
<body>
|
||||
<div id="app"></div>
|
||||
<script type="module" src="./src/main.ts"></script>
|
||||
</body>
|
||||
</html>
|
||||
+1
@@ -0,0 +1 @@
|
||||
../esbuild/bin/esbuild
|
||||
+1
@@ -0,0 +1 @@
|
||||
../nanoid/bin/nanoid.cjs
|
||||
+1
@@ -0,0 +1 @@
|
||||
../@playwright/test/cli.js
|
||||
+1
@@ -0,0 +1 @@
|
||||
../playwright-core/cli.js
|
||||
+1
@@ -0,0 +1 @@
|
||||
../rollup/dist/bin/rollup
|
||||
+1
@@ -0,0 +1 @@
|
||||
../typescript/bin/tsc
|
||||
+1
@@ -0,0 +1 @@
|
||||
../typescript/bin/tsserver
|
||||
+1
@@ -0,0 +1 @@
|
||||
../vite/bin/vite.js
|
||||
+1
@@ -0,0 +1 @@
|
||||
../vite-node/vite-node.mjs
|
||||
+1
@@ -0,0 +1 @@
|
||||
../vitest/vitest.mjs
|
||||
+1
@@ -0,0 +1 @@
|
||||
../why-is-node-running/cli.js
|
||||
+752
@@ -0,0 +1,752 @@
|
||||
{
|
||||
"name": "adaptive-loop",
|
||||
"version": "1.0.0",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"node_modules/@esbuild/darwin-arm64": {
|
||||
"version": "0.21.5",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.21.5.tgz",
|
||||
"integrity": "sha512-DwqXqZyuk5AiWWf3UfLiRDJ5EDd49zg6O9wclZ7kUMv2WRFr4HKjXp/5t8JZ11QbQfUS6/cRCKGwYhtNAY88kQ==",
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"darwin"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
}
|
||||
},
|
||||
"node_modules/@jridgewell/sourcemap-codec": {
|
||||
"version": "1.5.5",
|
||||
"resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.5.5.tgz",
|
||||
"integrity": "sha512-cYQ9310grqxueWbl+WuIUIaiUaDcj7WOq5fVhEljNVgRfOUhY9fy2zTvfoqWsnebh8Sl70VScFbICvJnLKB0Og==",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@playwright/test": {
|
||||
"version": "1.62.1",
|
||||
"resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.62.1.tgz",
|
||||
"integrity": "sha512-DTcUc8qii+cpHvtOwggMtBRMjKZHXYWdw8syRYu2vtzuq4Wxphqq4NfCs5Zt44L6mA8rfDfj+PHnxFc/FeK6mQ==",
|
||||
"dev": true,
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"playwright": "1.62.1"
|
||||
},
|
||||
"bin": {
|
||||
"playwright": "cli.js"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=20"
|
||||
}
|
||||
},
|
||||
"node_modules/@rollup/rollup-darwin-arm64": {
|
||||
"version": "4.62.4",
|
||||
"resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.62.4.tgz",
|
||||
"integrity": "sha512-krw5uS2STmvJ02x0uTXHbqQNuz+9eZ1iw+qXk9dmW2gvV4jV7O2hEoOnuhFrpOPiel1mBFtqbxYZZtC46hXLOw==",
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"darwin"
|
||||
]
|
||||
},
|
||||
"node_modules/@types/estree": {
|
||||
"version": "1.0.9",
|
||||
"resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.9.tgz",
|
||||
"integrity": "sha512-GhdPgy1el4/ImP05X05Uw4cw2/M93BCUmnEvWZNStlCzEKME4Fkk+YpoA5OiHNQmoS7Cafb8Xa3Pya8m1Qrzeg==",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@vitest/expect": {
|
||||
"version": "2.1.9",
|
||||
"resolved": "https://registry.npmjs.org/@vitest/expect/-/expect-2.1.9.tgz",
|
||||
"integrity": "sha512-UJCIkTBenHeKT1TTlKMJWy1laZewsRIzYighyYiJKZreqtdxSos/S1t+ktRMQWu2CKqaarrkeszJx1cgC5tGZw==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@vitest/spy": "2.1.9",
|
||||
"@vitest/utils": "2.1.9",
|
||||
"chai": "^5.1.2",
|
||||
"tinyrainbow": "^1.2.0"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://opencollective.com/vitest"
|
||||
}
|
||||
},
|
||||
"node_modules/@vitest/mocker": {
|
||||
"version": "2.1.9",
|
||||
"resolved": "https://registry.npmjs.org/@vitest/mocker/-/mocker-2.1.9.tgz",
|
||||
"integrity": "sha512-tVL6uJgoUdi6icpxmdrn5YNo3g3Dxv+IHJBr0GXHaEdTcw3F+cPKnsXFhli6nO+f/6SDKPHEK1UN+k+TQv0Ehg==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@vitest/spy": "2.1.9",
|
||||
"estree-walker": "^3.0.3",
|
||||
"magic-string": "^0.30.12"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://opencollective.com/vitest"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"msw": "^2.4.9",
|
||||
"vite": "^5.0.0"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"msw": {
|
||||
"optional": true
|
||||
},
|
||||
"vite": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/@vitest/pretty-format": {
|
||||
"version": "2.1.9",
|
||||
"resolved": "https://registry.npmjs.org/@vitest/pretty-format/-/pretty-format-2.1.9.tgz",
|
||||
"integrity": "sha512-KhRIdGV2U9HOUzxfiHmY8IFHTdqtOhIzCpd8WRdJiE7D/HUcZVD0EgQCVjm+Q9gkUXWgBvMmTtZgIG48wq7sOQ==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"tinyrainbow": "^1.2.0"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://opencollective.com/vitest"
|
||||
}
|
||||
},
|
||||
"node_modules/@vitest/runner": {
|
||||
"version": "2.1.9",
|
||||
"resolved": "https://registry.npmjs.org/@vitest/runner/-/runner-2.1.9.tgz",
|
||||
"integrity": "sha512-ZXSSqTFIrzduD63btIfEyOmNcBmQvgOVsPNPe0jYtESiXkhd8u2erDLnMxmGrDCwHCCHE7hxwRDCT3pt0esT4g==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@vitest/utils": "2.1.9",
|
||||
"pathe": "^1.1.2"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://opencollective.com/vitest"
|
||||
}
|
||||
},
|
||||
"node_modules/@vitest/snapshot": {
|
||||
"version": "2.1.9",
|
||||
"resolved": "https://registry.npmjs.org/@vitest/snapshot/-/snapshot-2.1.9.tgz",
|
||||
"integrity": "sha512-oBO82rEjsxLNJincVhLhaxxZdEtV0EFHMK5Kmx5sJ6H9L183dHECjiefOAdnqpIgT5eZwT04PoggUnW88vOBNQ==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@vitest/pretty-format": "2.1.9",
|
||||
"magic-string": "^0.30.12",
|
||||
"pathe": "^1.1.2"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://opencollective.com/vitest"
|
||||
}
|
||||
},
|
||||
"node_modules/@vitest/spy": {
|
||||
"version": "2.1.9",
|
||||
"resolved": "https://registry.npmjs.org/@vitest/spy/-/spy-2.1.9.tgz",
|
||||
"integrity": "sha512-E1B35FwzXXTs9FHNK6bDszs7mtydNi5MIfUWpceJ8Xbfb1gBMscAnwLbEu+B44ed6W3XjL9/ehLPHR1fkf1KLQ==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"tinyspy": "^3.0.2"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://opencollective.com/vitest"
|
||||
}
|
||||
},
|
||||
"node_modules/@vitest/utils": {
|
||||
"version": "2.1.9",
|
||||
"resolved": "https://registry.npmjs.org/@vitest/utils/-/utils-2.1.9.tgz",
|
||||
"integrity": "sha512-v0psaMSkNJ3A2NMrUEHFRzJtDPFn+/VWZ5WxImB21T9fjucJRmS7xCS3ppEnARb9y11OAzaD+P2Ps+b+BGX5iQ==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@vitest/pretty-format": "2.1.9",
|
||||
"loupe": "^3.1.2",
|
||||
"tinyrainbow": "^1.2.0"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://opencollective.com/vitest"
|
||||
}
|
||||
},
|
||||
"node_modules/assertion-error": {
|
||||
"version": "2.0.1",
|
||||
"resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-2.0.1.tgz",
|
||||
"integrity": "sha512-Izi8RQcffqCeNVgFigKli1ssklIbpHnCYc6AknXGYoB6grJqyeby7jv12JUQgmTAnIDnbck1uxksT4dzN3PWBA==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
}
|
||||
},
|
||||
"node_modules/cac": {
|
||||
"version": "6.7.14",
|
||||
"resolved": "https://registry.npmjs.org/cac/-/cac-6.7.14.tgz",
|
||||
"integrity": "sha512-b6Ilus+c3RrdDk+JhLKUAQfzzgLEPy6wcXqS7f/xe1EETvsDP6GORG7SFuOs6cID5YkqchW/LXZbX5bc8j7ZcQ==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=8"
|
||||
}
|
||||
},
|
||||
"node_modules/chai": {
|
||||
"version": "5.3.3",
|
||||
"resolved": "https://registry.npmjs.org/chai/-/chai-5.3.3.tgz",
|
||||
"integrity": "sha512-4zNhdJD/iOjSH0A05ea+Ke6MU5mmpQcbQsSOkgdaUMJ9zTlDTD/GYlwohmIE2u0gaxHYiVHEn1Fw9mZ/ktJWgw==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"assertion-error": "^2.0.1",
|
||||
"check-error": "^2.1.1",
|
||||
"deep-eql": "^5.0.1",
|
||||
"loupe": "^3.1.0",
|
||||
"pathval": "^2.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/check-error": {
|
||||
"version": "2.1.3",
|
||||
"resolved": "https://registry.npmjs.org/check-error/-/check-error-2.1.3.tgz",
|
||||
"integrity": "sha512-PAJdDJusoxnwm1VwW07VWwUN1sl7smmC3OKggvndJFadxxDRyFJBX/ggnu/KE4kQAB7a3Dp8f/YXC1FlUprWmA==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 16"
|
||||
}
|
||||
},
|
||||
"node_modules/debug": {
|
||||
"version": "4.4.3",
|
||||
"resolved": "https://registry.npmjs.org/debug/-/debug-4.4.3.tgz",
|
||||
"integrity": "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"ms": "^2.1.3"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=6.0"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"supports-color": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/deep-eql": {
|
||||
"version": "5.0.2",
|
||||
"resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-5.0.2.tgz",
|
||||
"integrity": "sha512-h5k/5U50IJJFpzfL6nO9jaaumfjO/f2NjK/oYB2Djzm4p9L+3T9qWpZqZ2hAbLPuuYq9wrU08WQyBTL5GbPk5Q==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=6"
|
||||
}
|
||||
},
|
||||
"node_modules/es-module-lexer": {
|
||||
"version": "1.7.0",
|
||||
"resolved": "https://registry.npmjs.org/es-module-lexer/-/es-module-lexer-1.7.0.tgz",
|
||||
"integrity": "sha512-jEQoCwk8hyb2AZziIOLhDqpm5+2ww5uIE6lkO/6jcOCusfk6LhMHpXXfBLXTZ7Ydyt0j4VoUQv6uGNYbdW+kBA==",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/esbuild": {
|
||||
"version": "0.21.5",
|
||||
"resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.21.5.tgz",
|
||||
"integrity": "sha512-mg3OPMV4hXywwpoDxu3Qda5xCKQi+vCTZq8S9J/EpkhB2HzKXq4SNFZE3+NK93JYxc8VMSep+lOUSC/RVKaBqw==",
|
||||
"dev": true,
|
||||
"hasInstallScript": true,
|
||||
"license": "MIT",
|
||||
"bin": {
|
||||
"esbuild": "bin/esbuild"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"@esbuild/aix-ppc64": "0.21.5",
|
||||
"@esbuild/android-arm": "0.21.5",
|
||||
"@esbuild/android-arm64": "0.21.5",
|
||||
"@esbuild/android-x64": "0.21.5",
|
||||
"@esbuild/darwin-arm64": "0.21.5",
|
||||
"@esbuild/darwin-x64": "0.21.5",
|
||||
"@esbuild/freebsd-arm64": "0.21.5",
|
||||
"@esbuild/freebsd-x64": "0.21.5",
|
||||
"@esbuild/linux-arm": "0.21.5",
|
||||
"@esbuild/linux-arm64": "0.21.5",
|
||||
"@esbuild/linux-ia32": "0.21.5",
|
||||
"@esbuild/linux-loong64": "0.21.5",
|
||||
"@esbuild/linux-mips64el": "0.21.5",
|
||||
"@esbuild/linux-ppc64": "0.21.5",
|
||||
"@esbuild/linux-riscv64": "0.21.5",
|
||||
"@esbuild/linux-s390x": "0.21.5",
|
||||
"@esbuild/linux-x64": "0.21.5",
|
||||
"@esbuild/netbsd-x64": "0.21.5",
|
||||
"@esbuild/openbsd-x64": "0.21.5",
|
||||
"@esbuild/sunos-x64": "0.21.5",
|
||||
"@esbuild/win32-arm64": "0.21.5",
|
||||
"@esbuild/win32-ia32": "0.21.5",
|
||||
"@esbuild/win32-x64": "0.21.5"
|
||||
}
|
||||
},
|
||||
"node_modules/estree-walker": {
|
||||
"version": "3.0.3",
|
||||
"resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-3.0.3.tgz",
|
||||
"integrity": "sha512-7RUKfXgSMMkzt6ZuXmqapOurLGPPfgj6l9uRZ7lRGolvk0y2yocc35LdcxKC5PQZdn2DMqioAQ2NoWcrTKmm6g==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@types/estree": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/expect-type": {
|
||||
"version": "1.4.0",
|
||||
"resolved": "https://registry.npmjs.org/expect-type/-/expect-type-1.4.0.tgz",
|
||||
"integrity": "sha512-KfYbmpRm0VbLjEvVa9yGwCi9GI34xvi7A/HXYWQO65CSD2u3MczUJSuwXKFIxlGsgBQizV9q5J9NHj4VG0n+pA==",
|
||||
"dev": true,
|
||||
"license": "Apache-2.0",
|
||||
"engines": {
|
||||
"node": ">=12.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/loupe": {
|
||||
"version": "3.2.1",
|
||||
"resolved": "https://registry.npmjs.org/loupe/-/loupe-3.2.1.tgz",
|
||||
"integrity": "sha512-CdzqowRJCeLU72bHvWqwRBBlLcMEtIvGrlvef74kMnV2AolS9Y8xUv1I0U/MNAWMhBlKIoyuEgoJ0t/bbwHbLQ==",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/magic-string": {
|
||||
"version": "0.30.21",
|
||||
"resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.21.tgz",
|
||||
"integrity": "sha512-vd2F4YUyEXKGcLHoq+TEyCjxueSeHnFxyyjNp80yg0XV4vUhnDer/lvvlqM/arB5bXQN5K2/3oinyCRyx8T2CQ==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@jridgewell/sourcemap-codec": "^1.5.5"
|
||||
}
|
||||
},
|
||||
"node_modules/ms": {
|
||||
"version": "2.1.3",
|
||||
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
|
||||
"integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/nanoid": {
|
||||
"version": "3.3.18",
|
||||
"resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.18.tgz",
|
||||
"integrity": "sha512-DTg4MJbGMWkfi6VZFdNt2/caMbQy4Ou+Op/hJQvGEWcnVfoA1QA+xzRKAzw9jD6+GVOOeYr/mIcuDSdug6F6+w==",
|
||||
"dev": true,
|
||||
"funding": [
|
||||
{
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/ai"
|
||||
}
|
||||
],
|
||||
"license": "MIT",
|
||||
"bin": {
|
||||
"nanoid": "bin/nanoid.cjs"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1"
|
||||
}
|
||||
},
|
||||
"node_modules/pathe": {
|
||||
"version": "1.1.2",
|
||||
"resolved": "https://registry.npmjs.org/pathe/-/pathe-1.1.2.tgz",
|
||||
"integrity": "sha512-whLdWMYL2TwI08hn8/ZqAbrVemu0LNaNNJZX73O6qaIdCTfXutsLhMkjdENX0qhsQ9uIimo4/aQOmXkoon2nDQ==",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/pathval": {
|
||||
"version": "2.0.1",
|
||||
"resolved": "https://registry.npmjs.org/pathval/-/pathval-2.0.1.tgz",
|
||||
"integrity": "sha512-//nshmD55c46FuFw26xV/xFAaB5HF9Xdap7HJBBnrKdAd6/GxDBaNA1870O79+9ueg61cZLSVc+OaFlfmObYVQ==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 14.16"
|
||||
}
|
||||
},
|
||||
"node_modules/picocolors": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz",
|
||||
"integrity": "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==",
|
||||
"dev": true,
|
||||
"license": "ISC"
|
||||
},
|
||||
"node_modules/playwright": {
|
||||
"version": "1.62.1",
|
||||
"resolved": "https://registry.npmjs.org/playwright/-/playwright-1.62.1.tgz",
|
||||
"integrity": "sha512-0M+L3LAD8/nm554LOla9Ayx0j0tmFZ0FBcoQ7F1VuVHpM/XpiC8RcDzBQB8W5+hA8L22THxELzeF+2WcUzvcLg==",
|
||||
"dev": true,
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"playwright-core": "1.62.1"
|
||||
},
|
||||
"bin": {
|
||||
"playwright": "cli.js"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=20"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"fsevents": "2.3.2"
|
||||
}
|
||||
},
|
||||
"node_modules/playwright-core": {
|
||||
"version": "1.62.1",
|
||||
"resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.62.1.tgz",
|
||||
"integrity": "sha512-wPYSwEBJY9GHraISXqyqtx0na0LpO3XEX7jNDhntbex7tzUS7kLnZsOlFruFJB4Hi/rhDMjXGqHewDZ68nYZVw==",
|
||||
"dev": true,
|
||||
"license": "Apache-2.0",
|
||||
"bin": {
|
||||
"playwright-core": "cli.js"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=20"
|
||||
}
|
||||
},
|
||||
"node_modules/postcss": {
|
||||
"version": "8.5.26",
|
||||
"resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.26.tgz",
|
||||
"integrity": "sha512-u82N74LFzG8ca+dD8puPnplTXoGH4fTPpVGuIbt36G3qvNlkvfD0lEAZSxaly3KX8TS/L1A1gsCEmvKmBcVbkQ==",
|
||||
"dev": true,
|
||||
"funding": [
|
||||
{
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/postcss/"
|
||||
},
|
||||
{
|
||||
"type": "tidelift",
|
||||
"url": "https://tidelift.com/funding/github/npm/postcss"
|
||||
},
|
||||
{
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/ai"
|
||||
}
|
||||
],
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"nanoid": "^3.3.17",
|
||||
"picocolors": "^1.1.1",
|
||||
"source-map-js": "^1.2.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^10 || ^12 || >=14"
|
||||
}
|
||||
},
|
||||
"node_modules/rollup": {
|
||||
"version": "4.62.4",
|
||||
"resolved": "https://registry.npmjs.org/rollup/-/rollup-4.62.4.tgz",
|
||||
"integrity": "sha512-RXOqwaPsBGjMNMa4sQjDjHieHEZDFoj/Rdr46l2MU5DfEs16wHJPC2RPTPHWhNl+M3aI472LLqFkFKut4SblOg==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@types/estree": "1.0.9"
|
||||
},
|
||||
"bin": {
|
||||
"rollup": "dist/bin/rollup"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=18.0.0",
|
||||
"npm": ">=8.0.0"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"@napi-rs/lzma-linux-x64-gnu": "1.5.1",
|
||||
"@rollup/rollup-android-arm-eabi": "4.62.4",
|
||||
"@rollup/rollup-android-arm64": "4.62.4",
|
||||
"@rollup/rollup-darwin-arm64": "4.62.4",
|
||||
"@rollup/rollup-darwin-x64": "4.62.4",
|
||||
"@rollup/rollup-freebsd-arm64": "4.62.4",
|
||||
"@rollup/rollup-freebsd-x64": "4.62.4",
|
||||
"@rollup/rollup-linux-arm-gnueabihf": "4.62.4",
|
||||
"@rollup/rollup-linux-arm-musleabihf": "4.62.4",
|
||||
"@rollup/rollup-linux-arm64-gnu": "4.62.4",
|
||||
"@rollup/rollup-linux-arm64-musl": "4.62.4",
|
||||
"@rollup/rollup-linux-loong64-gnu": "4.62.4",
|
||||
"@rollup/rollup-linux-loong64-musl": "4.62.4",
|
||||
"@rollup/rollup-linux-ppc64-gnu": "4.62.4",
|
||||
"@rollup/rollup-linux-ppc64-musl": "4.62.4",
|
||||
"@rollup/rollup-linux-riscv64-gnu": "4.62.4",
|
||||
"@rollup/rollup-linux-riscv64-musl": "4.62.4",
|
||||
"@rollup/rollup-linux-s390x-gnu": "4.62.4",
|
||||
"@rollup/rollup-linux-x64-gnu": "4.62.4",
|
||||
"@rollup/rollup-linux-x64-musl": "4.62.4",
|
||||
"@rollup/rollup-openbsd-x64": "4.62.4",
|
||||
"@rollup/rollup-openharmony-arm64": "4.62.4",
|
||||
"@rollup/rollup-win32-arm64-msvc": "4.62.4",
|
||||
"@rollup/rollup-win32-ia32-msvc": "4.62.4",
|
||||
"@rollup/rollup-win32-x64-gnu": "4.62.4",
|
||||
"@rollup/rollup-win32-x64-msvc": "4.62.4",
|
||||
"fsevents": "~2.3.2"
|
||||
}
|
||||
},
|
||||
"node_modules/siginfo": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/siginfo/-/siginfo-2.0.0.tgz",
|
||||
"integrity": "sha512-ybx0WO1/8bSBLEWXZvEd7gMW3Sn3JFlW3TvX1nREbDLRNQNaeNN8WK0meBwPdAaOI7TtRRRJn/Es1zhrrCHu7g==",
|
||||
"dev": true,
|
||||
"license": "ISC"
|
||||
},
|
||||
"node_modules/source-map-js": {
|
||||
"version": "1.2.1",
|
||||
"resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.1.tgz",
|
||||
"integrity": "sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA==",
|
||||
"dev": true,
|
||||
"license": "BSD-3-Clause",
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/stackback": {
|
||||
"version": "0.0.2",
|
||||
"resolved": "https://registry.npmjs.org/stackback/-/stackback-0.0.2.tgz",
|
||||
"integrity": "sha512-1XMJE5fQo1jGH6Y/7ebnwPOBEkIEnT4QF32d5R1+VXdXveM0IBMJt8zfaxX1P3QhVwrYe+576+jkANtSS2mBbw==",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/std-env": {
|
||||
"version": "3.10.0",
|
||||
"resolved": "https://registry.npmjs.org/std-env/-/std-env-3.10.0.tgz",
|
||||
"integrity": "sha512-5GS12FdOZNliM5mAOxFRg7Ir0pWz8MdpYm6AY6VPkGpbA7ZzmbzNcBJQ0GPvvyWgcY7QAhCgf9Uy89I03faLkg==",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/tinybench": {
|
||||
"version": "2.9.0",
|
||||
"resolved": "https://registry.npmjs.org/tinybench/-/tinybench-2.9.0.tgz",
|
||||
"integrity": "sha512-0+DUvqWMValLmha6lr4kD8iAMK1HzV0/aKnCtWb9v9641TnP/MFb7Pc2bxoxQjTXAErryXVgUOfv2YqNllqGeg==",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/tinyexec": {
|
||||
"version": "0.3.2",
|
||||
"resolved": "https://registry.npmjs.org/tinyexec/-/tinyexec-0.3.2.tgz",
|
||||
"integrity": "sha512-KQQR9yN7R5+OSwaK0XQoj22pwHoTlgYqmUscPYoknOoWCWfj/5/ABTMRi69FrKU5ffPVh5QcFikpWJI/P1ocHA==",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/tinypool": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/tinypool/-/tinypool-1.1.1.tgz",
|
||||
"integrity": "sha512-Zba82s87IFq9A9XmjiX5uZA/ARWDrB03OHlq+Vw1fSdt0I+4/Kutwy8BP4Y/y/aORMo61FQ0vIb5j44vSo5Pkg==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": "^18.0.0 || >=20.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/tinyrainbow": {
|
||||
"version": "1.2.0",
|
||||
"resolved": "https://registry.npmjs.org/tinyrainbow/-/tinyrainbow-1.2.0.tgz",
|
||||
"integrity": "sha512-weEDEq7Z5eTHPDh4xjX789+fHfF+P8boiFB+0vbWzpbnbsEr/GRaohi/uMKxg8RZMXnl1ItAi/IUHWMsjDV7kQ==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=14.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/tinyspy": {
|
||||
"version": "3.0.2",
|
||||
"resolved": "https://registry.npmjs.org/tinyspy/-/tinyspy-3.0.2.tgz",
|
||||
"integrity": "sha512-n1cw8k1k0x4pgA2+9XrOkFydTerNcJ1zWCO5Nn9scWHTD+5tp8dghT2x1uduQePZTZgd3Tupf+x9BxJjeJi77Q==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=14.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/typescript": {
|
||||
"version": "5.9.3",
|
||||
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.9.3.tgz",
|
||||
"integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==",
|
||||
"dev": true,
|
||||
"license": "Apache-2.0",
|
||||
"bin": {
|
||||
"tsc": "bin/tsc",
|
||||
"tsserver": "bin/tsserver"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=14.17"
|
||||
}
|
||||
},
|
||||
"node_modules/vite": {
|
||||
"version": "5.4.21",
|
||||
"resolved": "https://registry.npmjs.org/vite/-/vite-5.4.21.tgz",
|
||||
"integrity": "sha512-o5a9xKjbtuhY6Bi5S3+HvbRERmouabWbyUcpXXUA1u+GNUKoROi9byOJ8M0nHbHYHkYICiMlqxkg1KkYmm25Sw==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"esbuild": "^0.21.3",
|
||||
"postcss": "^8.4.43",
|
||||
"rollup": "^4.20.0"
|
||||
},
|
||||
"bin": {
|
||||
"vite": "bin/vite.js"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^18.0.0 || >=20.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/vitejs/vite?sponsor=1"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"fsevents": "~2.3.3"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@types/node": "^18.0.0 || >=20.0.0",
|
||||
"less": "*",
|
||||
"lightningcss": "^1.21.0",
|
||||
"sass": "*",
|
||||
"sass-embedded": "*",
|
||||
"stylus": "*",
|
||||
"sugarss": "*",
|
||||
"terser": "^5.4.0"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"@types/node": {
|
||||
"optional": true
|
||||
},
|
||||
"less": {
|
||||
"optional": true
|
||||
},
|
||||
"lightningcss": {
|
||||
"optional": true
|
||||
},
|
||||
"sass": {
|
||||
"optional": true
|
||||
},
|
||||
"sass-embedded": {
|
||||
"optional": true
|
||||
},
|
||||
"stylus": {
|
||||
"optional": true
|
||||
},
|
||||
"sugarss": {
|
||||
"optional": true
|
||||
},
|
||||
"terser": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/vite-node": {
|
||||
"version": "2.1.9",
|
||||
"resolved": "https://registry.npmjs.org/vite-node/-/vite-node-2.1.9.tgz",
|
||||
"integrity": "sha512-AM9aQ/IPrW/6ENLQg3AGY4K1N2TGZdR5e4gu/MmmR2xR3Ll1+dib+nook92g4TV3PXVyeyxdWwtaCAiUL0hMxA==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"cac": "^6.7.14",
|
||||
"debug": "^4.3.7",
|
||||
"es-module-lexer": "^1.5.4",
|
||||
"pathe": "^1.1.2",
|
||||
"vite": "^5.0.0"
|
||||
},
|
||||
"bin": {
|
||||
"vite-node": "vite-node.mjs"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^18.0.0 || >=20.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://opencollective.com/vitest"
|
||||
}
|
||||
},
|
||||
"node_modules/vitest": {
|
||||
"version": "2.1.9",
|
||||
"resolved": "https://registry.npmjs.org/vitest/-/vitest-2.1.9.tgz",
|
||||
"integrity": "sha512-MSmPM9REYqDGBI8439mA4mWhV5sKmDlBKWIYbA3lRb2PTHACE0mgKwA8yQ2xq9vxDTuk4iPrECBAEW2aoFXY0Q==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@vitest/expect": "2.1.9",
|
||||
"@vitest/mocker": "2.1.9",
|
||||
"@vitest/pretty-format": "^2.1.9",
|
||||
"@vitest/runner": "2.1.9",
|
||||
"@vitest/snapshot": "2.1.9",
|
||||
"@vitest/spy": "2.1.9",
|
||||
"@vitest/utils": "2.1.9",
|
||||
"chai": "^5.1.2",
|
||||
"debug": "^4.3.7",
|
||||
"expect-type": "^1.1.0",
|
||||
"magic-string": "^0.30.12",
|
||||
"pathe": "^1.1.2",
|
||||
"std-env": "^3.8.0",
|
||||
"tinybench": "^2.9.0",
|
||||
"tinyexec": "^0.3.1",
|
||||
"tinypool": "^1.0.1",
|
||||
"tinyrainbow": "^1.2.0",
|
||||
"vite": "^5.0.0",
|
||||
"vite-node": "2.1.9",
|
||||
"why-is-node-running": "^2.3.0"
|
||||
},
|
||||
"bin": {
|
||||
"vitest": "vitest.mjs"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^18.0.0 || >=20.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://opencollective.com/vitest"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@edge-runtime/vm": "*",
|
||||
"@types/node": "^18.0.0 || >=20.0.0",
|
||||
"@vitest/browser": "2.1.9",
|
||||
"@vitest/ui": "2.1.9",
|
||||
"happy-dom": "*",
|
||||
"jsdom": "*"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"@edge-runtime/vm": {
|
||||
"optional": true
|
||||
},
|
||||
"@types/node": {
|
||||
"optional": true
|
||||
},
|
||||
"@vitest/browser": {
|
||||
"optional": true
|
||||
},
|
||||
"@vitest/ui": {
|
||||
"optional": true
|
||||
},
|
||||
"happy-dom": {
|
||||
"optional": true
|
||||
},
|
||||
"jsdom": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/why-is-node-running": {
|
||||
"version": "2.3.0",
|
||||
"resolved": "https://registry.npmjs.org/why-is-node-running/-/why-is-node-running-2.3.0.tgz",
|
||||
"integrity": "sha512-hUrmaWBdVDcxvYqnyh09zunKzROWjbZTiNy8dBEjkS7ehEDQibXJ7XvlmtbwuTclUiIyN+CyXQD4Vmko8fNm8w==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"siginfo": "^2.0.0",
|
||||
"stackback": "0.0.2"
|
||||
},
|
||||
"bin": {
|
||||
"why-is-node-running": "cli.js"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=8"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"hash": "623833fc",
|
||||
"configHash": "88757786",
|
||||
"lockfileHash": "67ae8170",
|
||||
"browserHash": "9cdfde61",
|
||||
"optimized": {},
|
||||
"chunks": {}
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"type": "module"
|
||||
}
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":"2.1.9","results":[[":test/behavior.test.ts",{"duration":15.950792000000007,"failed":false}],[":test/campaign.test.ts",{"duration":11812.095708,"failed":false}],[":test/solver-fixtures.test.ts",{"duration":9.321292,"failed":false}],[":test/smoke.test.ts",{"duration":2.9881249999999966,"failed":false}],[":test/solver.test.ts",{"duration":18163.6855,"failed":false}]]}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
# esbuild
|
||||
|
||||
This is the macOS ARM 64-bit binary for esbuild, a JavaScript bundler and minifier. See https://github.com/evanw/esbuild for details.
|
||||
BIN
Binary file not shown.
+20
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"name": "@esbuild/darwin-arm64",
|
||||
"version": "0.21.5",
|
||||
"description": "The macOS ARM 64-bit binary for esbuild, a JavaScript bundler.",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/evanw/esbuild.git"
|
||||
},
|
||||
"license": "MIT",
|
||||
"preferUnplugged": true,
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
},
|
||||
"os": [
|
||||
"darwin"
|
||||
],
|
||||
"cpu": [
|
||||
"arm64"
|
||||
]
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
Copyright 2024 Justin Ridgewell <justin@ridgewell.name>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
+264
@@ -0,0 +1,264 @@
|
||||
# @jridgewell/sourcemap-codec
|
||||
|
||||
Encode/decode the `mappings` property of a [sourcemap](https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit).
|
||||
|
||||
|
||||
## Why?
|
||||
|
||||
Sourcemaps are difficult to generate and manipulate, because the `mappings` property – the part that actually links the generated code back to the original source – is encoded using an obscure method called [Variable-length quantity](https://en.wikipedia.org/wiki/Variable-length_quantity). On top of that, each segment in the mapping contains offsets rather than absolute indices, which means that you can't look at a segment in isolation – you have to understand the whole sourcemap.
|
||||
|
||||
This package makes the process slightly easier.
|
||||
|
||||
|
||||
## Installation
|
||||
|
||||
```bash
|
||||
npm install @jridgewell/sourcemap-codec
|
||||
```
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
import { encode, decode } from '@jridgewell/sourcemap-codec';
|
||||
|
||||
var decoded = decode( ';EAEEA,EAAE,EAAC,CAAE;ECQY,UACC' );
|
||||
|
||||
assert.deepEqual( decoded, [
|
||||
// the first line (of the generated code) has no mappings,
|
||||
// as shown by the starting semi-colon (which separates lines)
|
||||
[],
|
||||
|
||||
// the second line contains four (comma-separated) segments
|
||||
[
|
||||
// segments are encoded as you'd expect:
|
||||
// [ generatedCodeColumn, sourceIndex, sourceCodeLine, sourceCodeColumn, nameIndex ]
|
||||
|
||||
// i.e. the first segment begins at column 2, and maps back to the second column
|
||||
// of the second line (both zero-based) of the 0th source, and uses the 0th
|
||||
// name in the `map.names` array
|
||||
[ 2, 0, 2, 2, 0 ],
|
||||
|
||||
// the remaining segments are 4-length rather than 5-length,
|
||||
// because they don't map a name
|
||||
[ 4, 0, 2, 4 ],
|
||||
[ 6, 0, 2, 5 ],
|
||||
[ 7, 0, 2, 7 ]
|
||||
],
|
||||
|
||||
// the final line contains two segments
|
||||
[
|
||||
[ 2, 1, 10, 19 ],
|
||||
[ 12, 1, 11, 20 ]
|
||||
]
|
||||
]);
|
||||
|
||||
var encoded = encode( decoded );
|
||||
assert.equal( encoded, ';EAEEA,EAAE,EAAC,CAAE;ECQY,UACC' );
|
||||
```
|
||||
|
||||
## Benchmarks
|
||||
|
||||
```
|
||||
node v20.10.0
|
||||
|
||||
amp.js.map - 45120 segments
|
||||
|
||||
Decode Memory Usage:
|
||||
local code 5815135 bytes
|
||||
@jridgewell/sourcemap-codec 1.4.15 5868160 bytes
|
||||
sourcemap-codec 5492584 bytes
|
||||
source-map-0.6.1 13569984 bytes
|
||||
source-map-0.8.0 6390584 bytes
|
||||
chrome dev tools 8011136 bytes
|
||||
Smallest memory usage is sourcemap-codec
|
||||
|
||||
Decode speed:
|
||||
decode: local code x 492 ops/sec ±1.22% (90 runs sampled)
|
||||
decode: @jridgewell/sourcemap-codec 1.4.15 x 499 ops/sec ±1.16% (89 runs sampled)
|
||||
decode: sourcemap-codec x 376 ops/sec ±1.66% (89 runs sampled)
|
||||
decode: source-map-0.6.1 x 34.99 ops/sec ±0.94% (48 runs sampled)
|
||||
decode: source-map-0.8.0 x 351 ops/sec ±0.07% (95 runs sampled)
|
||||
chrome dev tools x 165 ops/sec ±0.91% (86 runs sampled)
|
||||
Fastest is decode: @jridgewell/sourcemap-codec 1.4.15
|
||||
|
||||
Encode Memory Usage:
|
||||
local code 444248 bytes
|
||||
@jridgewell/sourcemap-codec 1.4.15 623024 bytes
|
||||
sourcemap-codec 8696280 bytes
|
||||
source-map-0.6.1 8745176 bytes
|
||||
source-map-0.8.0 8736624 bytes
|
||||
Smallest memory usage is local code
|
||||
|
||||
Encode speed:
|
||||
encode: local code x 796 ops/sec ±0.11% (97 runs sampled)
|
||||
encode: @jridgewell/sourcemap-codec 1.4.15 x 795 ops/sec ±0.25% (98 runs sampled)
|
||||
encode: sourcemap-codec x 231 ops/sec ±0.83% (86 runs sampled)
|
||||
encode: source-map-0.6.1 x 166 ops/sec ±0.57% (86 runs sampled)
|
||||
encode: source-map-0.8.0 x 203 ops/sec ±0.45% (88 runs sampled)
|
||||
Fastest is encode: local code,encode: @jridgewell/sourcemap-codec 1.4.15
|
||||
|
||||
|
||||
***
|
||||
|
||||
|
||||
babel.min.js.map - 347793 segments
|
||||
|
||||
Decode Memory Usage:
|
||||
local code 35424960 bytes
|
||||
@jridgewell/sourcemap-codec 1.4.15 35424696 bytes
|
||||
sourcemap-codec 36033464 bytes
|
||||
source-map-0.6.1 62253704 bytes
|
||||
source-map-0.8.0 43843920 bytes
|
||||
chrome dev tools 45111400 bytes
|
||||
Smallest memory usage is @jridgewell/sourcemap-codec 1.4.15
|
||||
|
||||
Decode speed:
|
||||
decode: local code x 38.18 ops/sec ±5.44% (52 runs sampled)
|
||||
decode: @jridgewell/sourcemap-codec 1.4.15 x 38.36 ops/sec ±5.02% (52 runs sampled)
|
||||
decode: sourcemap-codec x 34.05 ops/sec ±4.45% (47 runs sampled)
|
||||
decode: source-map-0.6.1 x 4.31 ops/sec ±2.76% (15 runs sampled)
|
||||
decode: source-map-0.8.0 x 55.60 ops/sec ±0.13% (73 runs sampled)
|
||||
chrome dev tools x 16.94 ops/sec ±3.78% (46 runs sampled)
|
||||
Fastest is decode: source-map-0.8.0
|
||||
|
||||
Encode Memory Usage:
|
||||
local code 2606016 bytes
|
||||
@jridgewell/sourcemap-codec 1.4.15 2626440 bytes
|
||||
sourcemap-codec 21152576 bytes
|
||||
source-map-0.6.1 25023928 bytes
|
||||
source-map-0.8.0 25256448 bytes
|
||||
Smallest memory usage is local code
|
||||
|
||||
Encode speed:
|
||||
encode: local code x 127 ops/sec ±0.18% (83 runs sampled)
|
||||
encode: @jridgewell/sourcemap-codec 1.4.15 x 128 ops/sec ±0.26% (83 runs sampled)
|
||||
encode: sourcemap-codec x 29.31 ops/sec ±2.55% (53 runs sampled)
|
||||
encode: source-map-0.6.1 x 18.85 ops/sec ±3.19% (36 runs sampled)
|
||||
encode: source-map-0.8.0 x 19.34 ops/sec ±1.97% (36 runs sampled)
|
||||
Fastest is encode: @jridgewell/sourcemap-codec 1.4.15
|
||||
|
||||
|
||||
***
|
||||
|
||||
|
||||
preact.js.map - 1992 segments
|
||||
|
||||
Decode Memory Usage:
|
||||
local code 261696 bytes
|
||||
@jridgewell/sourcemap-codec 1.4.15 244296 bytes
|
||||
sourcemap-codec 302816 bytes
|
||||
source-map-0.6.1 939176 bytes
|
||||
source-map-0.8.0 336 bytes
|
||||
chrome dev tools 587368 bytes
|
||||
Smallest memory usage is source-map-0.8.0
|
||||
|
||||
Decode speed:
|
||||
decode: local code x 17,782 ops/sec ±0.32% (97 runs sampled)
|
||||
decode: @jridgewell/sourcemap-codec 1.4.15 x 17,863 ops/sec ±0.40% (100 runs sampled)
|
||||
decode: sourcemap-codec x 12,453 ops/sec ±0.27% (101 runs sampled)
|
||||
decode: source-map-0.6.1 x 1,288 ops/sec ±1.05% (96 runs sampled)
|
||||
decode: source-map-0.8.0 x 9,289 ops/sec ±0.27% (101 runs sampled)
|
||||
chrome dev tools x 4,769 ops/sec ±0.18% (100 runs sampled)
|
||||
Fastest is decode: @jridgewell/sourcemap-codec 1.4.15
|
||||
|
||||
Encode Memory Usage:
|
||||
local code 262944 bytes
|
||||
@jridgewell/sourcemap-codec 1.4.15 25544 bytes
|
||||
sourcemap-codec 323048 bytes
|
||||
source-map-0.6.1 507808 bytes
|
||||
source-map-0.8.0 507480 bytes
|
||||
Smallest memory usage is @jridgewell/sourcemap-codec 1.4.15
|
||||
|
||||
Encode speed:
|
||||
encode: local code x 24,207 ops/sec ±0.79% (95 runs sampled)
|
||||
encode: @jridgewell/sourcemap-codec 1.4.15 x 24,288 ops/sec ±0.48% (96 runs sampled)
|
||||
encode: sourcemap-codec x 6,761 ops/sec ±0.21% (100 runs sampled)
|
||||
encode: source-map-0.6.1 x 5,374 ops/sec ±0.17% (99 runs sampled)
|
||||
encode: source-map-0.8.0 x 5,633 ops/sec ±0.32% (99 runs sampled)
|
||||
Fastest is encode: @jridgewell/sourcemap-codec 1.4.15,encode: local code
|
||||
|
||||
|
||||
***
|
||||
|
||||
|
||||
react.js.map - 5726 segments
|
||||
|
||||
Decode Memory Usage:
|
||||
local code 678816 bytes
|
||||
@jridgewell/sourcemap-codec 1.4.15 678816 bytes
|
||||
sourcemap-codec 816400 bytes
|
||||
source-map-0.6.1 2288864 bytes
|
||||
source-map-0.8.0 721360 bytes
|
||||
chrome dev tools 1012512 bytes
|
||||
Smallest memory usage is local code
|
||||
|
||||
Decode speed:
|
||||
decode: local code x 6,178 ops/sec ±0.19% (98 runs sampled)
|
||||
decode: @jridgewell/sourcemap-codec 1.4.15 x 6,261 ops/sec ±0.22% (100 runs sampled)
|
||||
decode: sourcemap-codec x 4,472 ops/sec ±0.90% (99 runs sampled)
|
||||
decode: source-map-0.6.1 x 449 ops/sec ±0.31% (95 runs sampled)
|
||||
decode: source-map-0.8.0 x 3,219 ops/sec ±0.13% (100 runs sampled)
|
||||
chrome dev tools x 1,743 ops/sec ±0.20% (99 runs sampled)
|
||||
Fastest is decode: @jridgewell/sourcemap-codec 1.4.15
|
||||
|
||||
Encode Memory Usage:
|
||||
local code 140960 bytes
|
||||
@jridgewell/sourcemap-codec 1.4.15 159808 bytes
|
||||
sourcemap-codec 969304 bytes
|
||||
source-map-0.6.1 930520 bytes
|
||||
source-map-0.8.0 930248 bytes
|
||||
Smallest memory usage is local code
|
||||
|
||||
Encode speed:
|
||||
encode: local code x 8,013 ops/sec ±0.19% (100 runs sampled)
|
||||
encode: @jridgewell/sourcemap-codec 1.4.15 x 7,989 ops/sec ±0.20% (101 runs sampled)
|
||||
encode: sourcemap-codec x 2,472 ops/sec ±0.21% (99 runs sampled)
|
||||
encode: source-map-0.6.1 x 2,200 ops/sec ±0.17% (99 runs sampled)
|
||||
encode: source-map-0.8.0 x 2,220 ops/sec ±0.37% (99 runs sampled)
|
||||
Fastest is encode: local code
|
||||
|
||||
|
||||
***
|
||||
|
||||
|
||||
vscode.map - 2141001 segments
|
||||
|
||||
Decode Memory Usage:
|
||||
local code 198955264 bytes
|
||||
@jridgewell/sourcemap-codec 1.4.15 199175352 bytes
|
||||
sourcemap-codec 199102688 bytes
|
||||
source-map-0.6.1 386323432 bytes
|
||||
source-map-0.8.0 244116432 bytes
|
||||
chrome dev tools 293734280 bytes
|
||||
Smallest memory usage is local code
|
||||
|
||||
Decode speed:
|
||||
decode: local code x 3.90 ops/sec ±22.21% (15 runs sampled)
|
||||
decode: @jridgewell/sourcemap-codec 1.4.15 x 3.95 ops/sec ±23.53% (15 runs sampled)
|
||||
decode: sourcemap-codec x 3.82 ops/sec ±17.94% (14 runs sampled)
|
||||
decode: source-map-0.6.1 x 0.61 ops/sec ±7.81% (6 runs sampled)
|
||||
decode: source-map-0.8.0 x 9.54 ops/sec ±0.28% (28 runs sampled)
|
||||
chrome dev tools x 2.18 ops/sec ±10.58% (10 runs sampled)
|
||||
Fastest is decode: source-map-0.8.0
|
||||
|
||||
Encode Memory Usage:
|
||||
local code 13509880 bytes
|
||||
@jridgewell/sourcemap-codec 1.4.15 13537648 bytes
|
||||
sourcemap-codec 32540104 bytes
|
||||
source-map-0.6.1 127531040 bytes
|
||||
source-map-0.8.0 127535312 bytes
|
||||
Smallest memory usage is local code
|
||||
|
||||
Encode speed:
|
||||
encode: local code x 20.10 ops/sec ±0.19% (38 runs sampled)
|
||||
encode: @jridgewell/sourcemap-codec 1.4.15 x 20.26 ops/sec ±0.32% (38 runs sampled)
|
||||
encode: sourcemap-codec x 5.44 ops/sec ±1.64% (18 runs sampled)
|
||||
encode: source-map-0.6.1 x 2.30 ops/sec ±4.79% (10 runs sampled)
|
||||
encode: source-map-0.8.0 x 2.46 ops/sec ±6.53% (10 runs sampled)
|
||||
Fastest is encode: @jridgewell/sourcemap-codec 1.4.15
|
||||
```
|
||||
|
||||
# License
|
||||
|
||||
MIT
|
||||
+423
@@ -0,0 +1,423 @@
|
||||
// src/vlq.ts
|
||||
var comma = ",".charCodeAt(0);
|
||||
var semicolon = ";".charCodeAt(0);
|
||||
var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
||||
var intToChar = new Uint8Array(64);
|
||||
var charToInt = new Uint8Array(128);
|
||||
for (let i = 0; i < chars.length; i++) {
|
||||
const c = chars.charCodeAt(i);
|
||||
intToChar[i] = c;
|
||||
charToInt[c] = i;
|
||||
}
|
||||
function decodeInteger(reader, relative) {
|
||||
let value = 0;
|
||||
let shift = 0;
|
||||
let integer = 0;
|
||||
do {
|
||||
const c = reader.next();
|
||||
integer = charToInt[c];
|
||||
value |= (integer & 31) << shift;
|
||||
shift += 5;
|
||||
} while (integer & 32);
|
||||
const shouldNegate = value & 1;
|
||||
value >>>= 1;
|
||||
if (shouldNegate) {
|
||||
value = -2147483648 | -value;
|
||||
}
|
||||
return relative + value;
|
||||
}
|
||||
function encodeInteger(builder, num, relative) {
|
||||
let delta = num - relative;
|
||||
delta = delta < 0 ? -delta << 1 | 1 : delta << 1;
|
||||
do {
|
||||
let clamped = delta & 31;
|
||||
delta >>>= 5;
|
||||
if (delta > 0) clamped |= 32;
|
||||
builder.write(intToChar[clamped]);
|
||||
} while (delta > 0);
|
||||
return num;
|
||||
}
|
||||
function hasMoreVlq(reader, max) {
|
||||
if (reader.pos >= max) return false;
|
||||
return reader.peek() !== comma;
|
||||
}
|
||||
|
||||
// src/strings.ts
|
||||
var bufLength = 1024 * 16;
|
||||
var td = typeof TextDecoder !== "undefined" ? /* @__PURE__ */ new TextDecoder() : typeof Buffer !== "undefined" ? {
|
||||
decode(buf) {
|
||||
const out = Buffer.from(buf.buffer, buf.byteOffset, buf.byteLength);
|
||||
return out.toString();
|
||||
}
|
||||
} : {
|
||||
decode(buf) {
|
||||
let out = "";
|
||||
for (let i = 0; i < buf.length; i++) {
|
||||
out += String.fromCharCode(buf[i]);
|
||||
}
|
||||
return out;
|
||||
}
|
||||
};
|
||||
var StringWriter = class {
|
||||
constructor() {
|
||||
this.pos = 0;
|
||||
this.out = "";
|
||||
this.buffer = new Uint8Array(bufLength);
|
||||
}
|
||||
write(v) {
|
||||
const { buffer } = this;
|
||||
buffer[this.pos++] = v;
|
||||
if (this.pos === bufLength) {
|
||||
this.out += td.decode(buffer);
|
||||
this.pos = 0;
|
||||
}
|
||||
}
|
||||
flush() {
|
||||
const { buffer, out, pos } = this;
|
||||
return pos > 0 ? out + td.decode(buffer.subarray(0, pos)) : out;
|
||||
}
|
||||
};
|
||||
var StringReader = class {
|
||||
constructor(buffer) {
|
||||
this.pos = 0;
|
||||
this.buffer = buffer;
|
||||
}
|
||||
next() {
|
||||
return this.buffer.charCodeAt(this.pos++);
|
||||
}
|
||||
peek() {
|
||||
return this.buffer.charCodeAt(this.pos);
|
||||
}
|
||||
indexOf(char) {
|
||||
const { buffer, pos } = this;
|
||||
const idx = buffer.indexOf(char, pos);
|
||||
return idx === -1 ? buffer.length : idx;
|
||||
}
|
||||
};
|
||||
|
||||
// src/scopes.ts
|
||||
var EMPTY = [];
|
||||
function decodeOriginalScopes(input) {
|
||||
const { length } = input;
|
||||
const reader = new StringReader(input);
|
||||
const scopes = [];
|
||||
const stack = [];
|
||||
let line = 0;
|
||||
for (; reader.pos < length; reader.pos++) {
|
||||
line = decodeInteger(reader, line);
|
||||
const column = decodeInteger(reader, 0);
|
||||
if (!hasMoreVlq(reader, length)) {
|
||||
const last = stack.pop();
|
||||
last[2] = line;
|
||||
last[3] = column;
|
||||
continue;
|
||||
}
|
||||
const kind = decodeInteger(reader, 0);
|
||||
const fields = decodeInteger(reader, 0);
|
||||
const hasName = fields & 1;
|
||||
const scope = hasName ? [line, column, 0, 0, kind, decodeInteger(reader, 0)] : [line, column, 0, 0, kind];
|
||||
let vars = EMPTY;
|
||||
if (hasMoreVlq(reader, length)) {
|
||||
vars = [];
|
||||
do {
|
||||
const varsIndex = decodeInteger(reader, 0);
|
||||
vars.push(varsIndex);
|
||||
} while (hasMoreVlq(reader, length));
|
||||
}
|
||||
scope.vars = vars;
|
||||
scopes.push(scope);
|
||||
stack.push(scope);
|
||||
}
|
||||
return scopes;
|
||||
}
|
||||
function encodeOriginalScopes(scopes) {
|
||||
const writer = new StringWriter();
|
||||
for (let i = 0; i < scopes.length; ) {
|
||||
i = _encodeOriginalScopes(scopes, i, writer, [0]);
|
||||
}
|
||||
return writer.flush();
|
||||
}
|
||||
function _encodeOriginalScopes(scopes, index, writer, state) {
|
||||
const scope = scopes[index];
|
||||
const { 0: startLine, 1: startColumn, 2: endLine, 3: endColumn, 4: kind, vars } = scope;
|
||||
if (index > 0) writer.write(comma);
|
||||
state[0] = encodeInteger(writer, startLine, state[0]);
|
||||
encodeInteger(writer, startColumn, 0);
|
||||
encodeInteger(writer, kind, 0);
|
||||
const fields = scope.length === 6 ? 1 : 0;
|
||||
encodeInteger(writer, fields, 0);
|
||||
if (scope.length === 6) encodeInteger(writer, scope[5], 0);
|
||||
for (const v of vars) {
|
||||
encodeInteger(writer, v, 0);
|
||||
}
|
||||
for (index++; index < scopes.length; ) {
|
||||
const next = scopes[index];
|
||||
const { 0: l, 1: c } = next;
|
||||
if (l > endLine || l === endLine && c >= endColumn) {
|
||||
break;
|
||||
}
|
||||
index = _encodeOriginalScopes(scopes, index, writer, state);
|
||||
}
|
||||
writer.write(comma);
|
||||
state[0] = encodeInteger(writer, endLine, state[0]);
|
||||
encodeInteger(writer, endColumn, 0);
|
||||
return index;
|
||||
}
|
||||
function decodeGeneratedRanges(input) {
|
||||
const { length } = input;
|
||||
const reader = new StringReader(input);
|
||||
const ranges = [];
|
||||
const stack = [];
|
||||
let genLine = 0;
|
||||
let definitionSourcesIndex = 0;
|
||||
let definitionScopeIndex = 0;
|
||||
let callsiteSourcesIndex = 0;
|
||||
let callsiteLine = 0;
|
||||
let callsiteColumn = 0;
|
||||
let bindingLine = 0;
|
||||
let bindingColumn = 0;
|
||||
do {
|
||||
const semi = reader.indexOf(";");
|
||||
let genColumn = 0;
|
||||
for (; reader.pos < semi; reader.pos++) {
|
||||
genColumn = decodeInteger(reader, genColumn);
|
||||
if (!hasMoreVlq(reader, semi)) {
|
||||
const last = stack.pop();
|
||||
last[2] = genLine;
|
||||
last[3] = genColumn;
|
||||
continue;
|
||||
}
|
||||
const fields = decodeInteger(reader, 0);
|
||||
const hasDefinition = fields & 1;
|
||||
const hasCallsite = fields & 2;
|
||||
const hasScope = fields & 4;
|
||||
let callsite = null;
|
||||
let bindings = EMPTY;
|
||||
let range;
|
||||
if (hasDefinition) {
|
||||
const defSourcesIndex = decodeInteger(reader, definitionSourcesIndex);
|
||||
definitionScopeIndex = decodeInteger(
|
||||
reader,
|
||||
definitionSourcesIndex === defSourcesIndex ? definitionScopeIndex : 0
|
||||
);
|
||||
definitionSourcesIndex = defSourcesIndex;
|
||||
range = [genLine, genColumn, 0, 0, defSourcesIndex, definitionScopeIndex];
|
||||
} else {
|
||||
range = [genLine, genColumn, 0, 0];
|
||||
}
|
||||
range.isScope = !!hasScope;
|
||||
if (hasCallsite) {
|
||||
const prevCsi = callsiteSourcesIndex;
|
||||
const prevLine = callsiteLine;
|
||||
callsiteSourcesIndex = decodeInteger(reader, callsiteSourcesIndex);
|
||||
const sameSource = prevCsi === callsiteSourcesIndex;
|
||||
callsiteLine = decodeInteger(reader, sameSource ? callsiteLine : 0);
|
||||
callsiteColumn = decodeInteger(
|
||||
reader,
|
||||
sameSource && prevLine === callsiteLine ? callsiteColumn : 0
|
||||
);
|
||||
callsite = [callsiteSourcesIndex, callsiteLine, callsiteColumn];
|
||||
}
|
||||
range.callsite = callsite;
|
||||
if (hasMoreVlq(reader, semi)) {
|
||||
bindings = [];
|
||||
do {
|
||||
bindingLine = genLine;
|
||||
bindingColumn = genColumn;
|
||||
const expressionsCount = decodeInteger(reader, 0);
|
||||
let expressionRanges;
|
||||
if (expressionsCount < -1) {
|
||||
expressionRanges = [[decodeInteger(reader, 0)]];
|
||||
for (let i = -1; i > expressionsCount; i--) {
|
||||
const prevBl = bindingLine;
|
||||
bindingLine = decodeInteger(reader, bindingLine);
|
||||
bindingColumn = decodeInteger(reader, bindingLine === prevBl ? bindingColumn : 0);
|
||||
const expression = decodeInteger(reader, 0);
|
||||
expressionRanges.push([expression, bindingLine, bindingColumn]);
|
||||
}
|
||||
} else {
|
||||
expressionRanges = [[expressionsCount]];
|
||||
}
|
||||
bindings.push(expressionRanges);
|
||||
} while (hasMoreVlq(reader, semi));
|
||||
}
|
||||
range.bindings = bindings;
|
||||
ranges.push(range);
|
||||
stack.push(range);
|
||||
}
|
||||
genLine++;
|
||||
reader.pos = semi + 1;
|
||||
} while (reader.pos < length);
|
||||
return ranges;
|
||||
}
|
||||
function encodeGeneratedRanges(ranges) {
|
||||
if (ranges.length === 0) return "";
|
||||
const writer = new StringWriter();
|
||||
for (let i = 0; i < ranges.length; ) {
|
||||
i = _encodeGeneratedRanges(ranges, i, writer, [0, 0, 0, 0, 0, 0, 0]);
|
||||
}
|
||||
return writer.flush();
|
||||
}
|
||||
function _encodeGeneratedRanges(ranges, index, writer, state) {
|
||||
const range = ranges[index];
|
||||
const {
|
||||
0: startLine,
|
||||
1: startColumn,
|
||||
2: endLine,
|
||||
3: endColumn,
|
||||
isScope,
|
||||
callsite,
|
||||
bindings
|
||||
} = range;
|
||||
if (state[0] < startLine) {
|
||||
catchupLine(writer, state[0], startLine);
|
||||
state[0] = startLine;
|
||||
state[1] = 0;
|
||||
} else if (index > 0) {
|
||||
writer.write(comma);
|
||||
}
|
||||
state[1] = encodeInteger(writer, range[1], state[1]);
|
||||
const fields = (range.length === 6 ? 1 : 0) | (callsite ? 2 : 0) | (isScope ? 4 : 0);
|
||||
encodeInteger(writer, fields, 0);
|
||||
if (range.length === 6) {
|
||||
const { 4: sourcesIndex, 5: scopesIndex } = range;
|
||||
if (sourcesIndex !== state[2]) {
|
||||
state[3] = 0;
|
||||
}
|
||||
state[2] = encodeInteger(writer, sourcesIndex, state[2]);
|
||||
state[3] = encodeInteger(writer, scopesIndex, state[3]);
|
||||
}
|
||||
if (callsite) {
|
||||
const { 0: sourcesIndex, 1: callLine, 2: callColumn } = range.callsite;
|
||||
if (sourcesIndex !== state[4]) {
|
||||
state[5] = 0;
|
||||
state[6] = 0;
|
||||
} else if (callLine !== state[5]) {
|
||||
state[6] = 0;
|
||||
}
|
||||
state[4] = encodeInteger(writer, sourcesIndex, state[4]);
|
||||
state[5] = encodeInteger(writer, callLine, state[5]);
|
||||
state[6] = encodeInteger(writer, callColumn, state[6]);
|
||||
}
|
||||
if (bindings) {
|
||||
for (const binding of bindings) {
|
||||
if (binding.length > 1) encodeInteger(writer, -binding.length, 0);
|
||||
const expression = binding[0][0];
|
||||
encodeInteger(writer, expression, 0);
|
||||
let bindingStartLine = startLine;
|
||||
let bindingStartColumn = startColumn;
|
||||
for (let i = 1; i < binding.length; i++) {
|
||||
const expRange = binding[i];
|
||||
bindingStartLine = encodeInteger(writer, expRange[1], bindingStartLine);
|
||||
bindingStartColumn = encodeInteger(writer, expRange[2], bindingStartColumn);
|
||||
encodeInteger(writer, expRange[0], 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
for (index++; index < ranges.length; ) {
|
||||
const next = ranges[index];
|
||||
const { 0: l, 1: c } = next;
|
||||
if (l > endLine || l === endLine && c >= endColumn) {
|
||||
break;
|
||||
}
|
||||
index = _encodeGeneratedRanges(ranges, index, writer, state);
|
||||
}
|
||||
if (state[0] < endLine) {
|
||||
catchupLine(writer, state[0], endLine);
|
||||
state[0] = endLine;
|
||||
state[1] = 0;
|
||||
} else {
|
||||
writer.write(comma);
|
||||
}
|
||||
state[1] = encodeInteger(writer, endColumn, state[1]);
|
||||
return index;
|
||||
}
|
||||
function catchupLine(writer, lastLine, line) {
|
||||
do {
|
||||
writer.write(semicolon);
|
||||
} while (++lastLine < line);
|
||||
}
|
||||
|
||||
// src/sourcemap-codec.ts
|
||||
function decode(mappings) {
|
||||
const { length } = mappings;
|
||||
const reader = new StringReader(mappings);
|
||||
const decoded = [];
|
||||
let genColumn = 0;
|
||||
let sourcesIndex = 0;
|
||||
let sourceLine = 0;
|
||||
let sourceColumn = 0;
|
||||
let namesIndex = 0;
|
||||
do {
|
||||
const semi = reader.indexOf(";");
|
||||
const line = [];
|
||||
let sorted = true;
|
||||
let lastCol = 0;
|
||||
genColumn = 0;
|
||||
while (reader.pos < semi) {
|
||||
let seg;
|
||||
genColumn = decodeInteger(reader, genColumn);
|
||||
if (genColumn < lastCol) sorted = false;
|
||||
lastCol = genColumn;
|
||||
if (hasMoreVlq(reader, semi)) {
|
||||
sourcesIndex = decodeInteger(reader, sourcesIndex);
|
||||
sourceLine = decodeInteger(reader, sourceLine);
|
||||
sourceColumn = decodeInteger(reader, sourceColumn);
|
||||
if (hasMoreVlq(reader, semi)) {
|
||||
namesIndex = decodeInteger(reader, namesIndex);
|
||||
seg = [genColumn, sourcesIndex, sourceLine, sourceColumn, namesIndex];
|
||||
} else {
|
||||
seg = [genColumn, sourcesIndex, sourceLine, sourceColumn];
|
||||
}
|
||||
} else {
|
||||
seg = [genColumn];
|
||||
}
|
||||
line.push(seg);
|
||||
reader.pos++;
|
||||
}
|
||||
if (!sorted) sort(line);
|
||||
decoded.push(line);
|
||||
reader.pos = semi + 1;
|
||||
} while (reader.pos <= length);
|
||||
return decoded;
|
||||
}
|
||||
function sort(line) {
|
||||
line.sort(sortComparator);
|
||||
}
|
||||
function sortComparator(a, b) {
|
||||
return a[0] - b[0];
|
||||
}
|
||||
function encode(decoded) {
|
||||
const writer = new StringWriter();
|
||||
let sourcesIndex = 0;
|
||||
let sourceLine = 0;
|
||||
let sourceColumn = 0;
|
||||
let namesIndex = 0;
|
||||
for (let i = 0; i < decoded.length; i++) {
|
||||
const line = decoded[i];
|
||||
if (i > 0) writer.write(semicolon);
|
||||
if (line.length === 0) continue;
|
||||
let genColumn = 0;
|
||||
for (let j = 0; j < line.length; j++) {
|
||||
const segment = line[j];
|
||||
if (j > 0) writer.write(comma);
|
||||
genColumn = encodeInteger(writer, segment[0], genColumn);
|
||||
if (segment.length === 1) continue;
|
||||
sourcesIndex = encodeInteger(writer, segment[1], sourcesIndex);
|
||||
sourceLine = encodeInteger(writer, segment[2], sourceLine);
|
||||
sourceColumn = encodeInteger(writer, segment[3], sourceColumn);
|
||||
if (segment.length === 4) continue;
|
||||
namesIndex = encodeInteger(writer, segment[4], namesIndex);
|
||||
}
|
||||
}
|
||||
return writer.flush();
|
||||
}
|
||||
export {
|
||||
decode,
|
||||
decodeGeneratedRanges,
|
||||
decodeOriginalScopes,
|
||||
encode,
|
||||
encodeGeneratedRanges,
|
||||
encodeOriginalScopes
|
||||
};
|
||||
//# sourceMappingURL=sourcemap-codec.mjs.map
|
||||
Generated
Vendored
+6
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"version": 3,
|
||||
"sources": ["../src/vlq.ts", "../src/strings.ts", "../src/scopes.ts", "../src/sourcemap-codec.ts"],
|
||||
"mappings": ";AAEO,IAAM,QAAQ,IAAI,WAAW,CAAC;AAC9B,IAAM,YAAY,IAAI,WAAW,CAAC;AAEzC,IAAM,QAAQ;AACd,IAAM,YAAY,IAAI,WAAW,EAAE;AACnC,IAAM,YAAY,IAAI,WAAW,GAAG;AAEpC,SAAS,IAAI,GAAG,IAAI,MAAM,QAAQ,KAAK;AACrC,QAAM,IAAI,MAAM,WAAW,CAAC;AAC5B,YAAU,CAAC,IAAI;AACf,YAAU,CAAC,IAAI;AACjB;AAEO,SAAS,cAAc,QAAsB,UAA0B;AAC5E,MAAI,QAAQ;AACZ,MAAI,QAAQ;AACZ,MAAI,UAAU;AAEd,KAAG;AACD,UAAM,IAAI,OAAO,KAAK;AACtB,cAAU,UAAU,CAAC;AACrB,cAAU,UAAU,OAAO;AAC3B,aAAS;AAAA,EACX,SAAS,UAAU;AAEnB,QAAM,eAAe,QAAQ;AAC7B,aAAW;AAEX,MAAI,cAAc;AAChB,YAAQ,cAAc,CAAC;AAAA,EACzB;AAEA,SAAO,WAAW;AACpB;AAEO,SAAS,cAAc,SAAuB,KAAa,UAA0B;AAC1F,MAAI,QAAQ,MAAM;AAElB,UAAQ,QAAQ,IAAK,CAAC,SAAS,IAAK,IAAI,SAAS;AACjD,KAAG;AACD,QAAI,UAAU,QAAQ;AACtB,eAAW;AACX,QAAI,QAAQ,EAAG,YAAW;AAC1B,YAAQ,MAAM,UAAU,OAAO,CAAC;AAAA,EAClC,SAAS,QAAQ;AAEjB,SAAO;AACT;AAEO,SAAS,WAAW,QAAsB,KAAa;AAC5D,MAAI,OAAO,OAAO,IAAK,QAAO;AAC9B,SAAO,OAAO,KAAK,MAAM;AAC3B;;;ACtDA,IAAM,YAAY,OAAO;AAGzB,IAAM,KACJ,OAAO,gBAAgB,cACH,oBAAI,YAAY,IAChC,OAAO,WAAW,cAChB;AAAA,EACE,OAAO,KAAyB;AAC9B,UAAM,MAAM,OAAO,KAAK,IAAI,QAAQ,IAAI,YAAY,IAAI,UAAU;AAClE,WAAO,IAAI,SAAS;AAAA,EACtB;AACF,IACA;AAAA,EACE,OAAO,KAAyB;AAC9B,QAAI,MAAM;AACV,aAAS,IAAI,GAAG,IAAI,IAAI,QAAQ,KAAK;AACnC,aAAO,OAAO,aAAa,IAAI,CAAC,CAAC;AAAA,IACnC;AACA,WAAO;AAAA,EACT;AACF;AAED,IAAM,eAAN,MAAmB;AAAA,EAAnB;AACL,eAAM;AACN,SAAQ,MAAM;AACd,SAAQ,SAAS,IAAI,WAAW,SAAS;AAAA;AAAA,EAEzC,MAAM,GAAiB;AACrB,UAAM,EAAE,OAAO,IAAI;AACnB,WAAO,KAAK,KAAK,IAAI;AACrB,QAAI,KAAK,QAAQ,WAAW;AAC1B,WAAK,OAAO,GAAG,OAAO,MAAM;AAC5B,WAAK,MAAM;AAAA,IACb;AAAA,EACF;AAAA,EAEA,QAAgB;AACd,UAAM,EAAE,QAAQ,KAAK,IAAI,IAAI;AAC7B,WAAO,MAAM,IAAI,MAAM,GAAG,OAAO,OAAO,SAAS,GAAG,GAAG,CAAC,IAAI;AAAA,EAC9D;AACF;AAEO,IAAM,eAAN,MAAmB;AAAA,EAIxB,YAAY,QAAgB;AAH5B,eAAM;AAIJ,SAAK,SAAS;AAAA,EAChB;AAAA,EAEA,OAAe;AACb,WAAO,KAAK,OAAO,WAAW,KAAK,KAAK;AAAA,EAC1C;AAAA,EAEA,OAAe;AACb,WAAO,KAAK,OAAO,WAAW,KAAK,GAAG;AAAA,EACxC;AAAA,EAEA,QAAQ,MAAsB;AAC5B,UAAM,EAAE,QAAQ,IAAI,IAAI;AACxB,UAAM,MAAM,OAAO,QAAQ,MAAM,GAAG;AACpC,WAAO,QAAQ,KAAK,OAAO,SAAS;AAAA,EACtC;AACF;;;AC7DA,IAAM,QAAe,CAAC;AA+Bf,SAAS,qBAAqB,OAAgC;AACnE,QAAM,EAAE,OAAO,IAAI;AACnB,QAAM,SAAS,IAAI,aAAa,KAAK;AACrC,QAAM,SAA0B,CAAC;AACjC,QAAM,QAAyB,CAAC;AAChC,MAAI,OAAO;AAEX,SAAO,OAAO,MAAM,QAAQ,OAAO,OAAO;AACxC,WAAO,cAAc,QAAQ,IAAI;AACjC,UAAM,SAAS,cAAc,QAAQ,CAAC;AAEtC,QAAI,CAAC,WAAW,QAAQ,MAAM,GAAG;AAC/B,YAAM,OAAO,MAAM,IAAI;AACvB,WAAK,CAAC,IAAI;AACV,WAAK,CAAC,IAAI;AACV;AAAA,IACF;AAEA,UAAM,OAAO,cAAc,QAAQ,CAAC;AACpC,UAAM,SAAS,cAAc,QAAQ,CAAC;AACtC,UAAM,UAAU,SAAS;AAEzB,UAAM,QACJ,UAAU,CAAC,MAAM,QAAQ,GAAG,GAAG,MAAM,cAAc,QAAQ,CAAC,CAAC,IAAI,CAAC,MAAM,QAAQ,GAAG,GAAG,IAAI;AAG5F,QAAI,OAAc;AAClB,QAAI,WAAW,QAAQ,MAAM,GAAG;AAC9B,aAAO,CAAC;AACR,SAAG;AACD,cAAM,YAAY,cAAc,QAAQ,CAAC;AACzC,aAAK,KAAK,SAAS;AAAA,MACrB,SAAS,WAAW,QAAQ,MAAM;AAAA,IACpC;AACA,UAAM,OAAO;AAEb,WAAO,KAAK,KAAK;AACjB,UAAM,KAAK,KAAK;AAAA,EAClB;AAEA,SAAO;AACT;AAEO,SAAS,qBAAqB,QAAiC;AACpE,QAAM,SAAS,IAAI,aAAa;AAEhC,WAAS,IAAI,GAAG,IAAI,OAAO,UAAU;AACnC,QAAI,sBAAsB,QAAQ,GAAG,QAAQ,CAAC,CAAC,CAAC;AAAA,EAClD;AAEA,SAAO,OAAO,MAAM;AACtB;AAEA,SAAS,sBACP,QACA,OACA,QACA,OAGQ;AACR,QAAM,QAAQ,OAAO,KAAK;AAC1B,QAAM,EAAE,GAAG,WAAW,GAAG,aAAa,GAAG,SAAS,GAAG,WAAW,GAAG,MAAM,KAAK,IAAI;AAElF,MAAI,QAAQ,EAAG,QAAO,MAAM,KAAK;AAEjC,QAAM,CAAC,IAAI,cAAc,QAAQ,WAAW,MAAM,CAAC,CAAC;AACpD,gBAAc,QAAQ,aAAa,CAAC;AACpC,gBAAc,QAAQ,MAAM,CAAC;AAE7B,QAAM,SAAS,MAAM,WAAW,IAAI,IAAS;AAC7C,gBAAc,QAAQ,QAAQ,CAAC;AAC/B,MAAI,MAAM,WAAW,EAAG,eAAc,QAAQ,MAAM,CAAC,GAAG,CAAC;AAEzD,aAAW,KAAK,MAAM;AACpB,kBAAc,QAAQ,GAAG,CAAC;AAAA,EAC5B;AAEA,OAAK,SAAS,QAAQ,OAAO,UAAU;AACrC,UAAM,OAAO,OAAO,KAAK;AACzB,UAAM,EAAE,GAAG,GAAG,GAAG,EAAE,IAAI;AACvB,QAAI,IAAI,WAAY,MAAM,WAAW,KAAK,WAAY;AACpD;AAAA,IACF;AACA,YAAQ,sBAAsB,QAAQ,OAAO,QAAQ,KAAK;AAAA,EAC5D;AAEA,SAAO,MAAM,KAAK;AAClB,QAAM,CAAC,IAAI,cAAc,QAAQ,SAAS,MAAM,CAAC,CAAC;AAClD,gBAAc,QAAQ,WAAW,CAAC;AAElC,SAAO;AACT;AAEO,SAAS,sBAAsB,OAAiC;AACrE,QAAM,EAAE,OAAO,IAAI;AACnB,QAAM,SAAS,IAAI,aAAa,KAAK;AACrC,QAAM,SAA2B,CAAC;AAClC,QAAM,QAA0B,CAAC;AAEjC,MAAI,UAAU;AACd,MAAI,yBAAyB;AAC7B,MAAI,uBAAuB;AAC3B,MAAI,uBAAuB;AAC3B,MAAI,eAAe;AACnB,MAAI,iBAAiB;AACrB,MAAI,cAAc;AAClB,MAAI,gBAAgB;AAEpB,KAAG;AACD,UAAM,OAAO,OAAO,QAAQ,GAAG;AAC/B,QAAI,YAAY;AAEhB,WAAO,OAAO,MAAM,MAAM,OAAO,OAAO;AACtC,kBAAY,cAAc,QAAQ,SAAS;AAE3C,UAAI,CAAC,WAAW,QAAQ,IAAI,GAAG;AAC7B,cAAM,OAAO,MAAM,IAAI;AACvB,aAAK,CAAC,IAAI;AACV,aAAK,CAAC,IAAI;AACV;AAAA,MACF;AAEA,YAAM,SAAS,cAAc,QAAQ,CAAC;AACtC,YAAM,gBAAgB,SAAS;AAC/B,YAAM,cAAc,SAAS;AAC7B,YAAM,WAAW,SAAS;AAE1B,UAAI,WAA4B;AAChC,UAAI,WAAsB;AAC1B,UAAI;AACJ,UAAI,eAAe;AACjB,cAAM,kBAAkB,cAAc,QAAQ,sBAAsB;AACpE,+BAAuB;AAAA,UACrB;AAAA,UACA,2BAA2B,kBAAkB,uBAAuB;AAAA,QACtE;AAEA,iCAAyB;AACzB,gBAAQ,CAAC,SAAS,WAAW,GAAG,GAAG,iBAAiB,oBAAoB;AAAA,MAC1E,OAAO;AACL,gBAAQ,CAAC,SAAS,WAAW,GAAG,CAAC;AAAA,MACnC;AAEA,YAAM,UAAU,CAAC,CAAC;AAElB,UAAI,aAAa;AACf,cAAM,UAAU;AAChB,cAAM,WAAW;AACjB,+BAAuB,cAAc,QAAQ,oBAAoB;AACjE,cAAM,aAAa,YAAY;AAC/B,uBAAe,cAAc,QAAQ,aAAa,eAAe,CAAC;AAClE,yBAAiB;AAAA,UACf;AAAA,UACA,cAAc,aAAa,eAAe,iBAAiB;AAAA,QAC7D;AAEA,mBAAW,CAAC,sBAAsB,cAAc,cAAc;AAAA,MAChE;AACA,YAAM,WAAW;AAEjB,UAAI,WAAW,QAAQ,IAAI,GAAG;AAC5B,mBAAW,CAAC;AACZ,WAAG;AACD,wBAAc;AACd,0BAAgB;AAChB,gBAAM,mBAAmB,cAAc,QAAQ,CAAC;AACLine truncated
|
||||
"names": []
|
||||
}
|
||||
Generated
Vendored
+464
@@ -0,0 +1,464 @@
|
||||
(function (global, factory) {
|
||||
if (typeof exports === 'object' && typeof module !== 'undefined') {
|
||||
factory(module);
|
||||
module.exports = def(module);
|
||||
} else if (typeof define === 'function' && define.amd) {
|
||||
define(['module'], function(mod) {
|
||||
factory.apply(this, arguments);
|
||||
mod.exports = def(mod);
|
||||
});
|
||||
} else {
|
||||
const mod = { exports: {} };
|
||||
factory(mod);
|
||||
global = typeof globalThis !== 'undefined' ? globalThis : global || self;
|
||||
global.sourcemapCodec = def(mod);
|
||||
}
|
||||
function def(m) { return 'default' in m.exports ? m.exports.default : m.exports; }
|
||||
})(this, (function (module) {
|
||||
"use strict";
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __export = (target, all) => {
|
||||
for (var name in all)
|
||||
__defProp(target, name, { get: all[name], enumerable: true });
|
||||
};
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
|
||||
// src/sourcemap-codec.ts
|
||||
var sourcemap_codec_exports = {};
|
||||
__export(sourcemap_codec_exports, {
|
||||
decode: () => decode,
|
||||
decodeGeneratedRanges: () => decodeGeneratedRanges,
|
||||
decodeOriginalScopes: () => decodeOriginalScopes,
|
||||
encode: () => encode,
|
||||
encodeGeneratedRanges: () => encodeGeneratedRanges,
|
||||
encodeOriginalScopes: () => encodeOriginalScopes
|
||||
});
|
||||
module.exports = __toCommonJS(sourcemap_codec_exports);
|
||||
|
||||
// src/vlq.ts
|
||||
var comma = ",".charCodeAt(0);
|
||||
var semicolon = ";".charCodeAt(0);
|
||||
var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
||||
var intToChar = new Uint8Array(64);
|
||||
var charToInt = new Uint8Array(128);
|
||||
for (let i = 0; i < chars.length; i++) {
|
||||
const c = chars.charCodeAt(i);
|
||||
intToChar[i] = c;
|
||||
charToInt[c] = i;
|
||||
}
|
||||
function decodeInteger(reader, relative) {
|
||||
let value = 0;
|
||||
let shift = 0;
|
||||
let integer = 0;
|
||||
do {
|
||||
const c = reader.next();
|
||||
integer = charToInt[c];
|
||||
value |= (integer & 31) << shift;
|
||||
shift += 5;
|
||||
} while (integer & 32);
|
||||
const shouldNegate = value & 1;
|
||||
value >>>= 1;
|
||||
if (shouldNegate) {
|
||||
value = -2147483648 | -value;
|
||||
}
|
||||
return relative + value;
|
||||
}
|
||||
function encodeInteger(builder, num, relative) {
|
||||
let delta = num - relative;
|
||||
delta = delta < 0 ? -delta << 1 | 1 : delta << 1;
|
||||
do {
|
||||
let clamped = delta & 31;
|
||||
delta >>>= 5;
|
||||
if (delta > 0) clamped |= 32;
|
||||
builder.write(intToChar[clamped]);
|
||||
} while (delta > 0);
|
||||
return num;
|
||||
}
|
||||
function hasMoreVlq(reader, max) {
|
||||
if (reader.pos >= max) return false;
|
||||
return reader.peek() !== comma;
|
||||
}
|
||||
|
||||
// src/strings.ts
|
||||
var bufLength = 1024 * 16;
|
||||
var td = typeof TextDecoder !== "undefined" ? /* @__PURE__ */ new TextDecoder() : typeof Buffer !== "undefined" ? {
|
||||
decode(buf) {
|
||||
const out = Buffer.from(buf.buffer, buf.byteOffset, buf.byteLength);
|
||||
return out.toString();
|
||||
}
|
||||
} : {
|
||||
decode(buf) {
|
||||
let out = "";
|
||||
for (let i = 0; i < buf.length; i++) {
|
||||
out += String.fromCharCode(buf[i]);
|
||||
}
|
||||
return out;
|
||||
}
|
||||
};
|
||||
var StringWriter = class {
|
||||
constructor() {
|
||||
this.pos = 0;
|
||||
this.out = "";
|
||||
this.buffer = new Uint8Array(bufLength);
|
||||
}
|
||||
write(v) {
|
||||
const { buffer } = this;
|
||||
buffer[this.pos++] = v;
|
||||
if (this.pos === bufLength) {
|
||||
this.out += td.decode(buffer);
|
||||
this.pos = 0;
|
||||
}
|
||||
}
|
||||
flush() {
|
||||
const { buffer, out, pos } = this;
|
||||
return pos > 0 ? out + td.decode(buffer.subarray(0, pos)) : out;
|
||||
}
|
||||
};
|
||||
var StringReader = class {
|
||||
constructor(buffer) {
|
||||
this.pos = 0;
|
||||
this.buffer = buffer;
|
||||
}
|
||||
next() {
|
||||
return this.buffer.charCodeAt(this.pos++);
|
||||
}
|
||||
peek() {
|
||||
return this.buffer.charCodeAt(this.pos);
|
||||
}
|
||||
indexOf(char) {
|
||||
const { buffer, pos } = this;
|
||||
const idx = buffer.indexOf(char, pos);
|
||||
return idx === -1 ? buffer.length : idx;
|
||||
}
|
||||
};
|
||||
|
||||
// src/scopes.ts
|
||||
var EMPTY = [];
|
||||
function decodeOriginalScopes(input) {
|
||||
const { length } = input;
|
||||
const reader = new StringReader(input);
|
||||
const scopes = [];
|
||||
const stack = [];
|
||||
let line = 0;
|
||||
for (; reader.pos < length; reader.pos++) {
|
||||
line = decodeInteger(reader, line);
|
||||
const column = decodeInteger(reader, 0);
|
||||
if (!hasMoreVlq(reader, length)) {
|
||||
const last = stack.pop();
|
||||
last[2] = line;
|
||||
last[3] = column;
|
||||
continue;
|
||||
}
|
||||
const kind = decodeInteger(reader, 0);
|
||||
const fields = decodeInteger(reader, 0);
|
||||
const hasName = fields & 1;
|
||||
const scope = hasName ? [line, column, 0, 0, kind, decodeInteger(reader, 0)] : [line, column, 0, 0, kind];
|
||||
let vars = EMPTY;
|
||||
if (hasMoreVlq(reader, length)) {
|
||||
vars = [];
|
||||
do {
|
||||
const varsIndex = decodeInteger(reader, 0);
|
||||
vars.push(varsIndex);
|
||||
} while (hasMoreVlq(reader, length));
|
||||
}
|
||||
scope.vars = vars;
|
||||
scopes.push(scope);
|
||||
stack.push(scope);
|
||||
}
|
||||
return scopes;
|
||||
}
|
||||
function encodeOriginalScopes(scopes) {
|
||||
const writer = new StringWriter();
|
||||
for (let i = 0; i < scopes.length; ) {
|
||||
i = _encodeOriginalScopes(scopes, i, writer, [0]);
|
||||
}
|
||||
return writer.flush();
|
||||
}
|
||||
function _encodeOriginalScopes(scopes, index, writer, state) {
|
||||
const scope = scopes[index];
|
||||
const { 0: startLine, 1: startColumn, 2: endLine, 3: endColumn, 4: kind, vars } = scope;
|
||||
if (index > 0) writer.write(comma);
|
||||
state[0] = encodeInteger(writer, startLine, state[0]);
|
||||
encodeInteger(writer, startColumn, 0);
|
||||
encodeInteger(writer, kind, 0);
|
||||
const fields = scope.length === 6 ? 1 : 0;
|
||||
encodeInteger(writer, fields, 0);
|
||||
if (scope.length === 6) encodeInteger(writer, scope[5], 0);
|
||||
for (const v of vars) {
|
||||
encodeInteger(writer, v, 0);
|
||||
}
|
||||
for (index++; index < scopes.length; ) {
|
||||
const next = scopes[index];
|
||||
const { 0: l, 1: c } = next;
|
||||
if (l > endLine || l === endLine && c >= endColumn) {
|
||||
break;
|
||||
}
|
||||
index = _encodeOriginalScopes(scopes, index, writer, state);
|
||||
}
|
||||
writer.write(comma);
|
||||
state[0] = encodeInteger(writer, endLine, state[0]);
|
||||
encodeInteger(writer, endColumn, 0);
|
||||
return index;
|
||||
}
|
||||
function decodeGeneratedRanges(input) {
|
||||
const { length } = input;
|
||||
const reader = new StringReader(input);
|
||||
const ranges = [];
|
||||
const stack = [];
|
||||
let genLine = 0;
|
||||
let definitionSourcesIndex = 0;
|
||||
let definitionScopeIndex = 0;
|
||||
let callsiteSourcesIndex = 0;
|
||||
let callsiteLine = 0;
|
||||
let callsiteColumn = 0;
|
||||
let bindingLine = 0;
|
||||
let bindingColumn = 0;
|
||||
do {
|
||||
const semi = reader.indexOf(";");
|
||||
let genColumn = 0;
|
||||
for (; reader.pos < semi; reader.pos++) {
|
||||
genColumn = decodeInteger(reader, genColumn);
|
||||
if (!hasMoreVlq(reader, semi)) {
|
||||
const last = stack.pop();
|
||||
last[2] = genLine;
|
||||
last[3] = genColumn;
|
||||
continue;
|
||||
}
|
||||
const fields = decodeInteger(reader, 0);
|
||||
const hasDefinition = fields & 1;
|
||||
const hasCallsite = fields & 2;
|
||||
const hasScope = fields & 4;
|
||||
let callsite = null;
|
||||
let bindings = EMPTY;
|
||||
let range;
|
||||
if (hasDefinition) {
|
||||
const defSourcesIndex = decodeInteger(reader, definitionSourcesIndex);
|
||||
definitionScopeIndex = decodeInteger(
|
||||
reader,
|
||||
definitionSourcesIndex === defSourcesIndex ? definitionScopeIndex : 0
|
||||
);
|
||||
definitionSourcesIndex = defSourcesIndex;
|
||||
range = [genLine, genColumn, 0, 0, defSourcesIndex, definitionScopeIndex];
|
||||
} else {
|
||||
range = [genLine, genColumn, 0, 0];
|
||||
}
|
||||
range.isScope = !!hasScope;
|
||||
if (hasCallsite) {
|
||||
const prevCsi = callsiteSourcesIndex;
|
||||
const prevLine = callsiteLine;
|
||||
callsiteSourcesIndex = decodeInteger(reader, callsiteSourcesIndex);
|
||||
const sameSource = prevCsi === callsiteSourcesIndex;
|
||||
callsiteLine = decodeInteger(reader, sameSource ? callsiteLine : 0);
|
||||
callsiteColumn = decodeInteger(
|
||||
reader,
|
||||
sameSource && prevLine === callsiteLine ? callsiteColumn : 0
|
||||
);
|
||||
callsite = [callsiteSourcesIndex, callsiteLine, callsiteColumn];
|
||||
}
|
||||
range.callsite = callsite;
|
||||
if (hasMoreVlq(reader, semi)) {
|
||||
bindings = [];
|
||||
do {
|
||||
bindingLine = genLine;
|
||||
bindingColumn = genColumn;
|
||||
const expressionsCount = decodeInteger(reader, 0);
|
||||
let expressionRanges;
|
||||
if (expressionsCount < -1) {
|
||||
expressionRanges = [[decodeInteger(reader, 0)]];
|
||||
for (let i = -1; i > expressionsCount; i--) {
|
||||
const prevBl = bindingLine;
|
||||
bindingLine = decodeInteger(reader, bindingLine);
|
||||
bindingColumn = decodeInteger(reader, bindingLine === prevBl ? bindingColumn : 0);
|
||||
const expression = decodeInteger(reader, 0);
|
||||
expressionRanges.push([expression, bindingLine, bindingColumn]);
|
||||
}
|
||||
} else {
|
||||
expressionRanges = [[expressionsCount]];
|
||||
}
|
||||
bindings.push(expressionRanges);
|
||||
} while (hasMoreVlq(reader, semi));
|
||||
}
|
||||
range.bindings = bindings;
|
||||
ranges.push(range);
|
||||
stack.push(range);
|
||||
}
|
||||
genLine++;
|
||||
reader.pos = semi + 1;
|
||||
} while (reader.pos < length);
|
||||
return ranges;
|
||||
}
|
||||
function encodeGeneratedRanges(ranges) {
|
||||
if (ranges.length === 0) return "";
|
||||
const writer = new StringWriter();
|
||||
for (let i = 0; i < ranges.length; ) {
|
||||
i = _encodeGeneratedRanges(ranges, i, writer, [0, 0, 0, 0, 0, 0, 0]);
|
||||
}
|
||||
return writer.flush();
|
||||
}
|
||||
function _encodeGeneratedRanges(ranges, index, writer, state) {
|
||||
const range = ranges[index];
|
||||
const {
|
||||
0: startLine,
|
||||
1: startColumn,
|
||||
2: endLine,
|
||||
3: endColumn,
|
||||
isScope,
|
||||
callsite,
|
||||
bindings
|
||||
} = range;
|
||||
if (state[0] < startLine) {
|
||||
catchupLine(writer, state[0], startLine);
|
||||
state[0] = startLine;
|
||||
state[1] = 0;
|
||||
} else if (index > 0) {
|
||||
writer.write(comma);
|
||||
}
|
||||
state[1] = encodeInteger(writer, range[1], state[1]);
|
||||
const fields = (range.length === 6 ? 1 : 0) | (callsite ? 2 : 0) | (isScope ? 4 : 0);
|
||||
encodeInteger(writer, fields, 0);
|
||||
if (range.length === 6) {
|
||||
const { 4: sourcesIndex, 5: scopesIndex } = range;
|
||||
if (sourcesIndex !== state[2]) {
|
||||
state[3] = 0;
|
||||
}
|
||||
state[2] = encodeInteger(writer, sourcesIndex, state[2]);
|
||||
state[3] = encodeInteger(writer, scopesIndex, state[3]);
|
||||
}
|
||||
if (callsite) {
|
||||
const { 0: sourcesIndex, 1: callLine, 2: callColumn } = range.callsite;
|
||||
if (sourcesIndex !== state[4]) {
|
||||
state[5] = 0;
|
||||
state[6] = 0;
|
||||
} else if (callLine !== state[5]) {
|
||||
state[6] = 0;
|
||||
}
|
||||
state[4] = encodeInteger(writer, sourcesIndex, state[4]);
|
||||
state[5] = encodeInteger(writer, callLine, state[5]);
|
||||
state[6] = encodeInteger(writer, callColumn, state[6]);
|
||||
}
|
||||
if (bindings) {
|
||||
for (const binding of bindings) {
|
||||
if (binding.length > 1) encodeInteger(writer, -binding.length, 0);
|
||||
const expression = binding[0][0];
|
||||
encodeInteger(writer, expression, 0);
|
||||
let bindingStartLine = startLine;
|
||||
let bindingStartColumn = startColumn;
|
||||
for (let i = 1; i < binding.length; i++) {
|
||||
const expRange = binding[i];
|
||||
bindingStartLine = encodeInteger(writer, expRange[1], bindingStartLine);
|
||||
bindingStartColumn = encodeInteger(writer, expRange[2], bindingStartColumn);
|
||||
encodeInteger(writer, expRange[0], 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
for (index++; index < ranges.length; ) {
|
||||
const next = ranges[index];
|
||||
const { 0: l, 1: c } = next;
|
||||
if (l > endLine || l === endLine && c >= endColumn) {
|
||||
break;
|
||||
}
|
||||
index = _encodeGeneratedRanges(ranges, index, writer, state);
|
||||
}
|
||||
if (state[0] < endLine) {
|
||||
catchupLine(writer, state[0], endLine);
|
||||
state[0] = endLine;
|
||||
state[1] = 0;
|
||||
} else {
|
||||
writer.write(comma);
|
||||
}
|
||||
state[1] = encodeInteger(writer, endColumn, state[1]);
|
||||
return index;
|
||||
}
|
||||
function catchupLine(writer, lastLine, line) {
|
||||
do {
|
||||
writer.write(semicolon);
|
||||
} while (++lastLine < line);
|
||||
}
|
||||
|
||||
// src/sourcemap-codec.ts
|
||||
function decode(mappings) {
|
||||
const { length } = mappings;
|
||||
const reader = new StringReader(mappings);
|
||||
const decoded = [];
|
||||
let genColumn = 0;
|
||||
let sourcesIndex = 0;
|
||||
let sourceLine = 0;
|
||||
let sourceColumn = 0;
|
||||
let namesIndex = 0;
|
||||
do {
|
||||
const semi = reader.indexOf(";");
|
||||
const line = [];
|
||||
let sorted = true;
|
||||
let lastCol = 0;
|
||||
genColumn = 0;
|
||||
while (reader.pos < semi) {
|
||||
let seg;
|
||||
genColumn = decodeInteger(reader, genColumn);
|
||||
if (genColumn < lastCol) sorted = false;
|
||||
lastCol = genColumn;
|
||||
if (hasMoreVlq(reader, semi)) {
|
||||
sourcesIndex = decodeInteger(reader, sourcesIndex);
|
||||
sourceLine = decodeInteger(reader, sourceLine);
|
||||
sourceColumn = decodeInteger(reader, sourceColumn);
|
||||
if (hasMoreVlq(reader, semi)) {
|
||||
namesIndex = decodeInteger(reader, namesIndex);
|
||||
seg = [genColumn, sourcesIndex, sourceLine, sourceColumn, namesIndex];
|
||||
} else {
|
||||
seg = [genColumn, sourcesIndex, sourceLine, sourceColumn];
|
||||
}
|
||||
} else {
|
||||
seg = [genColumn];
|
||||
}
|
||||
line.push(seg);
|
||||
reader.pos++;
|
||||
}
|
||||
if (!sorted) sort(line);
|
||||
decoded.push(line);
|
||||
reader.pos = semi + 1;
|
||||
} while (reader.pos <= length);
|
||||
return decoded;
|
||||
}
|
||||
function sort(line) {
|
||||
line.sort(sortComparator);
|
||||
}
|
||||
function sortComparator(a, b) {
|
||||
return a[0] - b[0];
|
||||
}
|
||||
function encode(decoded) {
|
||||
const writer = new StringWriter();
|
||||
let sourcesIndex = 0;
|
||||
let sourceLine = 0;
|
||||
let sourceColumn = 0;
|
||||
let namesIndex = 0;
|
||||
for (let i = 0; i < decoded.length; i++) {
|
||||
const line = decoded[i];
|
||||
if (i > 0) writer.write(semicolon);
|
||||
if (line.length === 0) continue;
|
||||
let genColumn = 0;
|
||||
for (let j = 0; j < line.length; j++) {
|
||||
const segment = line[j];
|
||||
if (j > 0) writer.write(comma);
|
||||
genColumn = encodeInteger(writer, segment[0], genColumn);
|
||||
if (segment.length === 1) continue;
|
||||
sourcesIndex = encodeInteger(writer, segment[1], sourcesIndex);
|
||||
sourceLine = encodeInteger(writer, segment[2], sourceLine);
|
||||
sourceColumn = encodeInteger(writer, segment[3], sourceColumn);
|
||||
if (segment.length === 4) continue;
|
||||
namesIndex = encodeInteger(writer, segment[4], namesIndex);
|
||||
}
|
||||
}
|
||||
return writer.flush();
|
||||
}
|
||||
}));
|
||||
//# sourceMappingURL=sourcemap-codec.umd.js.map
|
||||
Generated
Vendored
+6
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"version": 3,
|
||||
"sources": ["../src/sourcemap-codec.ts", "../src/vlq.ts", "../src/strings.ts", "../src/scopes.ts"],
|
||||
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACEO,IAAM,QAAQ,IAAI,WAAW,CAAC;AAC9B,IAAM,YAAY,IAAI,WAAW,CAAC;AAEzC,IAAM,QAAQ;AACd,IAAM,YAAY,IAAI,WAAW,EAAE;AACnC,IAAM,YAAY,IAAI,WAAW,GAAG;AAEpC,SAAS,IAAI,GAAG,IAAI,MAAM,QAAQ,KAAK;AACrC,QAAM,IAAI,MAAM,WAAW,CAAC;AAC5B,YAAU,CAAC,IAAI;AACf,YAAU,CAAC,IAAI;AACjB;AAEO,SAAS,cAAc,QAAsB,UAA0B;AAC5E,MAAI,QAAQ;AACZ,MAAI,QAAQ;AACZ,MAAI,UAAU;AAEd,KAAG;AACD,UAAM,IAAI,OAAO,KAAK;AACtB,cAAU,UAAU,CAAC;AACrB,cAAU,UAAU,OAAO;AAC3B,aAAS;AAAA,EACX,SAAS,UAAU;AAEnB,QAAM,eAAe,QAAQ;AAC7B,aAAW;AAEX,MAAI,cAAc;AAChB,YAAQ,cAAc,CAAC;AAAA,EACzB;AAEA,SAAO,WAAW;AACpB;AAEO,SAAS,cAAc,SAAuB,KAAa,UAA0B;AAC1F,MAAI,QAAQ,MAAM;AAElB,UAAQ,QAAQ,IAAK,CAAC,SAAS,IAAK,IAAI,SAAS;AACjD,KAAG;AACD,QAAI,UAAU,QAAQ;AACtB,eAAW;AACX,QAAI,QAAQ,EAAG,YAAW;AAC1B,YAAQ,MAAM,UAAU,OAAO,CAAC;AAAA,EAClC,SAAS,QAAQ;AAEjB,SAAO;AACT;AAEO,SAAS,WAAW,QAAsB,KAAa;AAC5D,MAAI,OAAO,OAAO,IAAK,QAAO;AAC9B,SAAO,OAAO,KAAK,MAAM;AAC3B;;;ACtDA,IAAM,YAAY,OAAO;AAGzB,IAAM,KACJ,OAAO,gBAAgB,cACH,oBAAI,YAAY,IAChC,OAAO,WAAW,cAChB;AAAA,EACE,OAAO,KAAyB;AAC9B,UAAM,MAAM,OAAO,KAAK,IAAI,QAAQ,IAAI,YAAY,IAAI,UAAU;AAClE,WAAO,IAAI,SAAS;AAAA,EACtB;AACF,IACA;AAAA,EACE,OAAO,KAAyB;AAC9B,QAAI,MAAM;AACV,aAAS,IAAI,GAAG,IAAI,IAAI,QAAQ,KAAK;AACnC,aAAO,OAAO,aAAa,IAAI,CAAC,CAAC;AAAA,IACnC;AACA,WAAO;AAAA,EACT;AACF;AAED,IAAM,eAAN,MAAmB;AAAA,EAAnB;AACL,eAAM;AACN,SAAQ,MAAM;AACd,SAAQ,SAAS,IAAI,WAAW,SAAS;AAAA;AAAA,EAEzC,MAAM,GAAiB;AACrB,UAAM,EAAE,OAAO,IAAI;AACnB,WAAO,KAAK,KAAK,IAAI;AACrB,QAAI,KAAK,QAAQ,WAAW;AAC1B,WAAK,OAAO,GAAG,OAAO,MAAM;AAC5B,WAAK,MAAM;AAAA,IACb;AAAA,EACF;AAAA,EAEA,QAAgB;AACd,UAAM,EAAE,QAAQ,KAAK,IAAI,IAAI;AAC7B,WAAO,MAAM,IAAI,MAAM,GAAG,OAAO,OAAO,SAAS,GAAG,GAAG,CAAC,IAAI;AAAA,EAC9D;AACF;AAEO,IAAM,eAAN,MAAmB;AAAA,EAIxB,YAAY,QAAgB;AAH5B,eAAM;AAIJ,SAAK,SAAS;AAAA,EAChB;AAAA,EAEA,OAAe;AACb,WAAO,KAAK,OAAO,WAAW,KAAK,KAAK;AAAA,EAC1C;AAAA,EAEA,OAAe;AACb,WAAO,KAAK,OAAO,WAAW,KAAK,GAAG;AAAA,EACxC;AAAA,EAEA,QAAQ,MAAsB;AAC5B,UAAM,EAAE,QAAQ,IAAI,IAAI;AACxB,UAAM,MAAM,OAAO,QAAQ,MAAM,GAAG;AACpC,WAAO,QAAQ,KAAK,OAAO,SAAS;AAAA,EACtC;AACF;;;AC7DA,IAAM,QAAe,CAAC;AA+Bf,SAAS,qBAAqB,OAAgC;AACnE,QAAM,EAAE,OAAO,IAAI;AACnB,QAAM,SAAS,IAAI,aAAa,KAAK;AACrC,QAAM,SAA0B,CAAC;AACjC,QAAM,QAAyB,CAAC;AAChC,MAAI,OAAO;AAEX,SAAO,OAAO,MAAM,QAAQ,OAAO,OAAO;AACxC,WAAO,cAAc,QAAQ,IAAI;AACjC,UAAM,SAAS,cAAc,QAAQ,CAAC;AAEtC,QAAI,CAAC,WAAW,QAAQ,MAAM,GAAG;AAC/B,YAAM,OAAO,MAAM,IAAI;AACvB,WAAK,CAAC,IAAI;AACV,WAAK,CAAC,IAAI;AACV;AAAA,IACF;AAEA,UAAM,OAAO,cAAc,QAAQ,CAAC;AACpC,UAAM,SAAS,cAAc,QAAQ,CAAC;AACtC,UAAM,UAAU,SAAS;AAEzB,UAAM,QACJ,UAAU,CAAC,MAAM,QAAQ,GAAG,GAAG,MAAM,cAAc,QAAQ,CAAC,CAAC,IAAI,CAAC,MAAM,QAAQ,GAAG,GAAG,IAAI;AAG5F,QAAI,OAAc;AAClB,QAAI,WAAW,QAAQ,MAAM,GAAG;AAC9B,aAAO,CAAC;AACR,SAAG;AACD,cAAM,YAAY,cAAc,QAAQ,CAAC;AACzC,aAAK,KAAK,SAAS;AAAA,MACrB,SAAS,WAAW,QAAQ,MAAM;AAAA,IACpC;AACA,UAAM,OAAO;AAEb,WAAO,KAAK,KAAK;AACjB,UAAM,KAAK,KAAK;AAAA,EAClB;AAEA,SAAO;AACT;AAEO,SAAS,qBAAqB,QAAiC;AACpE,QAAM,SAAS,IAAI,aAAa;AAEhC,WAAS,IAAI,GAAG,IAAI,OAAO,UAAU;AACnC,QAAI,sBAAsB,QAAQ,GAAG,QAAQ,CAAC,CAAC,CAAC;AAAA,EAClD;AAEA,SAAO,OAAO,MAAM;AACtB;AAEA,SAAS,sBACP,QACA,OACA,QACA,OAGQ;AACR,QAAM,QAAQ,OAAO,KAAK;AAC1B,QAAM,EAAE,GAAG,WAAW,GAAG,aAAa,GAAG,SAAS,GAAG,WAAW,GAAG,MAAM,KAAK,IAAI;AAElF,MAAI,QAAQ,EAAG,QAAO,MAAM,KAAK;AAEjC,QAAM,CAAC,IAAI,cAAc,QAAQ,WAAW,MAAM,CAAC,CAAC;AACpD,gBAAc,QAAQ,aAAa,CAAC;AACpC,gBAAc,QAAQ,MAAM,CAAC;AAE7B,QAAM,SAAS,MAAM,WAAW,IAAI,IAAS;AAC7C,gBAAc,QAAQ,QAAQ,CAAC;AAC/B,MAAI,MAAM,WAAW,EAAG,eAAc,QAAQ,MAAM,CAAC,GAAG,CAAC;AAEzD,aAAW,KAAK,MAAM;AACpB,kBAAc,QAAQ,GAAG,CAAC;AAAA,EAC5B;AAEA,OAAK,SAAS,QAAQ,OAAO,UAAU;AACrC,UAAM,OAAO,OAAO,KAAK;AACzB,UAAM,EAAE,GAAG,GAAG,GAAG,EAAE,IAAI;AACvB,QAAI,IAAI,WAAY,MAAM,WAAW,KAAK,WAAY;AACpD;AAAA,IACF;AACA,YAAQ,sBAAsB,QAAQ,OAAO,QAAQ,KAAK;AAAA,EAC5D;AAEA,SAAO,MAAM,KAAK;AAClB,QAAM,CAAC,IAAI,cAAc,QAAQ,SAAS,MAAM,CAAC,CAAC;AAClD,gBAAc,QAAQ,WAAW,CAAC;AAElC,SAAO;AACT;AAEO,SAAS,sBAAsB,OAAiC;AACrE,QAAM,EAAE,OAAO,IAAI;AACnB,QAAM,SAAS,IAAI,aAAa,KAAK;AACrC,QAAM,SAA2B,CAAC;AAClC,QAAM,QAA0B,CAAC;AAEjC,MAAI,UAAU;AACd,MAAI,yBAAyB;AAC7B,MAAI,uBAAuB;AAC3B,MAAI,uBAAuB;AAC3B,MAAI,eAAe;AACnB,MAAI,iBAAiB;AACrB,MAAI,cAAc;AAClB,MAAI,gBAAgB;AAEpB,KAAG;AACD,UAAM,OAAO,OAAO,QAAQ,GAAG;AAC/B,QAAI,YAAY;AAEhB,WAAO,OAAO,MAAM,MAAM,OAAO,OAAO;AACtC,kBAAY,cAAc,QAAQ,SAAS;AAE3C,UAAI,CAAC,WAAW,QAAQ,IAAI,GAAG;AAC7B,cAAM,OAAO,MAAM,IAAI;AACvB,aAAK,CAAC,IAAI;AACV,aAAK,CAAC,IAAI;AACV;AAAA,MACF;AAEA,YAAM,SAAS,cAAc,QAAQ,CAAC;AACtC,YAAM,gBAAgB,SAAS;AAC/B,YAAM,cAAc,SAAS;AAC7B,YAAM,WAAW,SAAS;AAE1B,UAAI,WAA4B;AAChC,UAAI,WAAsB;AAC1B,UAAI;AACJ,UAAI,eAAe;AACjB,cAAM,kBAAkB,cAAc,QAAQ,sBAAsB;AACpE,+BAAuB;AAAA,UACrB;AAAA,UACA,2BAA2B,kBAAkB,uBAAuB;AAAA,QACtE;AAEA,iCAAyB;AACzB,gBAAQ,CAAC,SAAS,WAAW,GAAG,GAAG,iBAAiB,oBAAoB;AAAA,MAC1E,OAAO;AACL,gBAAQ,CAAC,SAAS,WAAW,GAAG,CAAC;AAAA,MACnC;AAEA,YAAM,UAAU,CAAC,CAAC;AAElB,UAAI,aAAa;AACf,cAAM,UAAU;AAChB,cAAM,WAAW;AACjB,+BAAuB,cAAc,QAAQ,oBAAoB;AACjE,cAAM,aAAa,YAAY;AAC/B,uBAAe,cAAc,QAAQ,aAAa,eAAe,CAAC;AAClE,yBAAiB;AAAA,UACf;AAAA,UACA,cAAc,aAAa,eAAe,iBAAiB;AAAA,QAC7D;AAEA,mBAAW,CAAC,sBAAsB,cAAc,cAAc;AAAA,MAChE;AACA,YAAM,WAAW;AAEjB,UAAI,WAAW,QAAQ,IAAI,GAAGLine truncated
|
||||
"names": []
|
||||
}
|
||||
+63
@@ -0,0 +1,63 @@
|
||||
{
|
||||
"name": "@jridgewell/sourcemap-codec",
|
||||
"version": "1.5.5",
|
||||
"description": "Encode/decode sourcemap mappings",
|
||||
"keywords": [
|
||||
"sourcemap",
|
||||
"vlq"
|
||||
],
|
||||
"main": "dist/sourcemap-codec.umd.js",
|
||||
"module": "dist/sourcemap-codec.mjs",
|
||||
"types": "types/sourcemap-codec.d.cts",
|
||||
"files": [
|
||||
"dist",
|
||||
"src",
|
||||
"types"
|
||||
],
|
||||
"exports": {
|
||||
".": [
|
||||
{
|
||||
"import": {
|
||||
"types": "./types/sourcemap-codec.d.mts",
|
||||
"default": "./dist/sourcemap-codec.mjs"
|
||||
},
|
||||
"default": {
|
||||
"types": "./types/sourcemap-codec.d.cts",
|
||||
"default": "./dist/sourcemap-codec.umd.js"
|
||||
}
|
||||
},
|
||||
"./dist/sourcemap-codec.umd.js"
|
||||
],
|
||||
"./package.json": "./package.json"
|
||||
},
|
||||
"scripts": {
|
||||
"benchmark": "run-s build:code benchmark:*",
|
||||
"benchmark:install": "cd benchmark && npm install",
|
||||
"benchmark:only": "node --expose-gc benchmark/index.js",
|
||||
"build": "run-s -n build:code build:types",
|
||||
"build:code": "node ../../esbuild.mjs sourcemap-codec.ts",
|
||||
"build:types": "run-s build:types:force build:types:emit build:types:mts",
|
||||
"build:types:force": "rimraf tsconfig.build.tsbuildinfo",
|
||||
"build:types:emit": "tsc --project tsconfig.build.json",
|
||||
"build:types:mts": "node ../../mts-types.mjs",
|
||||
"clean": "run-s -n clean:code clean:types",
|
||||
"clean:code": "tsc --build --clean tsconfig.build.json",
|
||||
"clean:types": "rimraf dist types",
|
||||
"test": "run-s -n test:types test:only test:format",
|
||||
"test:format": "prettier --check '{src,test}/**/*.ts'",
|
||||
"test:only": "mocha",
|
||||
"test:types": "eslint '{src,test}/**/*.ts'",
|
||||
"lint": "run-s -n lint:types lint:format",
|
||||
"lint:format": "npm run test:format -- --write",
|
||||
"lint:types": "npm run test:types -- --fix",
|
||||
"prepublishOnly": "npm run-s -n build test"
|
||||
},
|
||||
"homepage": "https://github.com/jridgewell/sourcemaps/tree/main/packages/sourcemap-codec",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/jridgewell/sourcemaps.git",
|
||||
"directory": "packages/sourcemap-codec"
|
||||
},
|
||||
"author": "Justin Ridgewell <justin@ridgewell.name>",
|
||||
"license": "MIT"
|
||||
}
|
||||
+345
@@ -0,0 +1,345 @@
|
||||
import { StringReader, StringWriter } from './strings';
|
||||
import { comma, decodeInteger, encodeInteger, hasMoreVlq, semicolon } from './vlq';
|
||||
|
||||
const EMPTY: any[] = [];
|
||||
|
||||
type Line = number;
|
||||
type Column = number;
|
||||
type Kind = number;
|
||||
type Name = number;
|
||||
type Var = number;
|
||||
type SourcesIndex = number;
|
||||
type ScopesIndex = number;
|
||||
|
||||
type Mix<A, B, O> = (A & O) | (B & O);
|
||||
|
||||
export type OriginalScope = Mix<
|
||||
[Line, Column, Line, Column, Kind],
|
||||
[Line, Column, Line, Column, Kind, Name],
|
||||
{ vars: Var[] }
|
||||
>;
|
||||
|
||||
export type GeneratedRange = Mix<
|
||||
[Line, Column, Line, Column],
|
||||
[Line, Column, Line, Column, SourcesIndex, ScopesIndex],
|
||||
{
|
||||
callsite: CallSite | null;
|
||||
bindings: Binding[];
|
||||
isScope: boolean;
|
||||
}
|
||||
>;
|
||||
export type CallSite = [SourcesIndex, Line, Column];
|
||||
type Binding = BindingExpressionRange[];
|
||||
export type BindingExpressionRange = [Name] | [Name, Line, Column];
|
||||
|
||||
export function decodeOriginalScopes(input: string): OriginalScope[] {
|
||||
const { length } = input;
|
||||
const reader = new StringReader(input);
|
||||
const scopes: OriginalScope[] = [];
|
||||
const stack: OriginalScope[] = [];
|
||||
let line = 0;
|
||||
|
||||
for (; reader.pos < length; reader.pos++) {
|
||||
line = decodeInteger(reader, line);
|
||||
const column = decodeInteger(reader, 0);
|
||||
|
||||
if (!hasMoreVlq(reader, length)) {
|
||||
const last = stack.pop()!;
|
||||
last[2] = line;
|
||||
last[3] = column;
|
||||
continue;
|
||||
}
|
||||
|
||||
const kind = decodeInteger(reader, 0);
|
||||
const fields = decodeInteger(reader, 0);
|
||||
const hasName = fields & 0b0001;
|
||||
|
||||
const scope: OriginalScope = (
|
||||
hasName ? [line, column, 0, 0, kind, decodeInteger(reader, 0)] : [line, column, 0, 0, kind]
|
||||
) as OriginalScope;
|
||||
|
||||
let vars: Var[] = EMPTY;
|
||||
if (hasMoreVlq(reader, length)) {
|
||||
vars = [];
|
||||
do {
|
||||
const varsIndex = decodeInteger(reader, 0);
|
||||
vars.push(varsIndex);
|
||||
} while (hasMoreVlq(reader, length));
|
||||
}
|
||||
scope.vars = vars;
|
||||
|
||||
scopes.push(scope);
|
||||
stack.push(scope);
|
||||
}
|
||||
|
||||
return scopes;
|
||||
}
|
||||
|
||||
export function encodeOriginalScopes(scopes: OriginalScope[]): string {
|
||||
const writer = new StringWriter();
|
||||
|
||||
for (let i = 0; i < scopes.length; ) {
|
||||
i = _encodeOriginalScopes(scopes, i, writer, [0]);
|
||||
}
|
||||
|
||||
return writer.flush();
|
||||
}
|
||||
|
||||
function _encodeOriginalScopes(
|
||||
scopes: OriginalScope[],
|
||||
index: number,
|
||||
writer: StringWriter,
|
||||
state: [
|
||||
number, // GenColumn
|
||||
],
|
||||
): number {
|
||||
const scope = scopes[index];
|
||||
const { 0: startLine, 1: startColumn, 2: endLine, 3: endColumn, 4: kind, vars } = scope;
|
||||
|
||||
if (index > 0) writer.write(comma);
|
||||
|
||||
state[0] = encodeInteger(writer, startLine, state[0]);
|
||||
encodeInteger(writer, startColumn, 0);
|
||||
encodeInteger(writer, kind, 0);
|
||||
|
||||
const fields = scope.length === 6 ? 0b0001 : 0;
|
||||
encodeInteger(writer, fields, 0);
|
||||
if (scope.length === 6) encodeInteger(writer, scope[5], 0);
|
||||
|
||||
for (const v of vars) {
|
||||
encodeInteger(writer, v, 0);
|
||||
}
|
||||
|
||||
for (index++; index < scopes.length; ) {
|
||||
const next = scopes[index];
|
||||
const { 0: l, 1: c } = next;
|
||||
if (l > endLine || (l === endLine && c >= endColumn)) {
|
||||
break;
|
||||
}
|
||||
index = _encodeOriginalScopes(scopes, index, writer, state);
|
||||
}
|
||||
|
||||
writer.write(comma);
|
||||
state[0] = encodeInteger(writer, endLine, state[0]);
|
||||
encodeInteger(writer, endColumn, 0);
|
||||
|
||||
return index;
|
||||
}
|
||||
|
||||
export function decodeGeneratedRanges(input: string): GeneratedRange[] {
|
||||
const { length } = input;
|
||||
const reader = new StringReader(input);
|
||||
const ranges: GeneratedRange[] = [];
|
||||
const stack: GeneratedRange[] = [];
|
||||
|
||||
let genLine = 0;
|
||||
let definitionSourcesIndex = 0;
|
||||
let definitionScopeIndex = 0;
|
||||
let callsiteSourcesIndex = 0;
|
||||
let callsiteLine = 0;
|
||||
let callsiteColumn = 0;
|
||||
let bindingLine = 0;
|
||||
let bindingColumn = 0;
|
||||
|
||||
do {
|
||||
const semi = reader.indexOf(';');
|
||||
let genColumn = 0;
|
||||
|
||||
for (; reader.pos < semi; reader.pos++) {
|
||||
genColumn = decodeInteger(reader, genColumn);
|
||||
|
||||
if (!hasMoreVlq(reader, semi)) {
|
||||
const last = stack.pop()!;
|
||||
last[2] = genLine;
|
||||
last[3] = genColumn;
|
||||
continue;
|
||||
}
|
||||
|
||||
const fields = decodeInteger(reader, 0);
|
||||
const hasDefinition = fields & 0b0001;
|
||||
const hasCallsite = fields & 0b0010;
|
||||
const hasScope = fields & 0b0100;
|
||||
|
||||
let callsite: CallSite | null = null;
|
||||
let bindings: Binding[] = EMPTY;
|
||||
let range: GeneratedRange;
|
||||
if (hasDefinition) {
|
||||
const defSourcesIndex = decodeInteger(reader, definitionSourcesIndex);
|
||||
definitionScopeIndex = decodeInteger(
|
||||
reader,
|
||||
definitionSourcesIndex === defSourcesIndex ? definitionScopeIndex : 0,
|
||||
);
|
||||
|
||||
definitionSourcesIndex = defSourcesIndex;
|
||||
range = [genLine, genColumn, 0, 0, defSourcesIndex, definitionScopeIndex] as GeneratedRange;
|
||||
} else {
|
||||
range = [genLine, genColumn, 0, 0] as GeneratedRange;
|
||||
}
|
||||
|
||||
range.isScope = !!hasScope;
|
||||
|
||||
if (hasCallsite) {
|
||||
const prevCsi = callsiteSourcesIndex;
|
||||
const prevLine = callsiteLine;
|
||||
callsiteSourcesIndex = decodeInteger(reader, callsiteSourcesIndex);
|
||||
const sameSource = prevCsi === callsiteSourcesIndex;
|
||||
callsiteLine = decodeInteger(reader, sameSource ? callsiteLine : 0);
|
||||
callsiteColumn = decodeInteger(
|
||||
reader,
|
||||
sameSource && prevLine === callsiteLine ? callsiteColumn : 0,
|
||||
);
|
||||
|
||||
callsite = [callsiteSourcesIndex, callsiteLine, callsiteColumn];
|
||||
}
|
||||
range.callsite = callsite;
|
||||
|
||||
if (hasMoreVlq(reader, semi)) {
|
||||
bindings = [];
|
||||
do {
|
||||
bindingLine = genLine;
|
||||
bindingColumn = genColumn;
|
||||
const expressionsCount = decodeInteger(reader, 0);
|
||||
let expressionRanges: BindingExpressionRange[];
|
||||
if (expressionsCount < -1) {
|
||||
expressionRanges = [[decodeInteger(reader, 0)]];
|
||||
for (let i = -1; i > expressionsCount; i--) {
|
||||
const prevBl = bindingLine;
|
||||
bindingLine = decodeInteger(reader, bindingLine);
|
||||
bindingColumn = decodeInteger(reader, bindingLine === prevBl ? bindingColumn : 0);
|
||||
const expression = decodeInteger(reader, 0);
|
||||
expressionRanges.push([expression, bindingLine, bindingColumn]);
|
||||
}
|
||||
} else {
|
||||
expressionRanges = [[expressionsCount]];
|
||||
}
|
||||
bindings.push(expressionRanges);
|
||||
} while (hasMoreVlq(reader, semi));
|
||||
}
|
||||
range.bindings = bindings;
|
||||
|
||||
ranges.push(range);
|
||||
stack.push(range);
|
||||
}
|
||||
|
||||
genLine++;
|
||||
reader.pos = semi + 1;
|
||||
} while (reader.pos < length);
|
||||
|
||||
return ranges;
|
||||
}
|
||||
|
||||
export function encodeGeneratedRanges(ranges: GeneratedRange[]): string {
|
||||
if (ranges.length === 0) return '';
|
||||
|
||||
const writer = new StringWriter();
|
||||
|
||||
for (let i = 0; i < ranges.length; ) {
|
||||
i = _encodeGeneratedRanges(ranges, i, writer, [0, 0, 0, 0, 0, 0, 0]);
|
||||
}
|
||||
|
||||
return writer.flush();
|
||||
}
|
||||
|
||||
function _encodeGeneratedRanges(
|
||||
ranges: GeneratedRange[],
|
||||
index: number,
|
||||
writer: StringWriter,
|
||||
state: [
|
||||
number, // GenLine
|
||||
number, // GenColumn
|
||||
number, // DefSourcesIndex
|
||||
number, // DefScopesIndex
|
||||
number, // CallSourcesIndex
|
||||
number, // CallLine
|
||||
number, // CallColumn
|
||||
],
|
||||
): number {
|
||||
const range = ranges[index];
|
||||
const {
|
||||
0: startLine,
|
||||
1: startColumn,
|
||||
2: endLine,
|
||||
3: endColumn,
|
||||
isScope,
|
||||
callsite,
|
||||
bindings,
|
||||
} = range;
|
||||
|
||||
if (state[0] < startLine) {
|
||||
catchupLine(writer, state[0], startLine);
|
||||
state[0] = startLine;
|
||||
state[1] = 0;
|
||||
} else if (index > 0) {
|
||||
writer.write(comma);
|
||||
}
|
||||
|
||||
state[1] = encodeInteger(writer, range[1], state[1]);
|
||||
|
||||
const fields =
|
||||
(range.length === 6 ? 0b0001 : 0) | (callsite ? 0b0010 : 0) | (isScope ? 0b0100 : 0);
|
||||
encodeInteger(writer, fields, 0);
|
||||
|
||||
if (range.length === 6) {
|
||||
const { 4: sourcesIndex, 5: scopesIndex } = range;
|
||||
if (sourcesIndex !== state[2]) {
|
||||
state[3] = 0;
|
||||
}
|
||||
state[2] = encodeInteger(writer, sourcesIndex, state[2]);
|
||||
state[3] = encodeInteger(writer, scopesIndex, state[3]);
|
||||
}
|
||||
|
||||
if (callsite) {
|
||||
const { 0: sourcesIndex, 1: callLine, 2: callColumn } = range.callsite!;
|
||||
if (sourcesIndex !== state[4]) {
|
||||
state[5] = 0;
|
||||
state[6] = 0;
|
||||
} else if (callLine !== state[5]) {
|
||||
state[6] = 0;
|
||||
}
|
||||
state[4] = encodeInteger(writer, sourcesIndex, state[4]);
|
||||
state[5] = encodeInteger(writer, callLine, state[5]);
|
||||
state[6] = encodeInteger(writer, callColumn, state[6]);
|
||||
}
|
||||
|
||||
if (bindings) {
|
||||
for (const binding of bindings) {
|
||||
if (binding.length > 1) encodeInteger(writer, -binding.length, 0);
|
||||
const expression = binding[0][0];
|
||||
encodeInteger(writer, expression, 0);
|
||||
let bindingStartLine = startLine;
|
||||
let bindingStartColumn = startColumn;
|
||||
for (let i = 1; i < binding.length; i++) {
|
||||
const expRange = binding[i];
|
||||
bindingStartLine = encodeInteger(writer, expRange[1]!, bindingStartLine);
|
||||
bindingStartColumn = encodeInteger(writer, expRange[2]!, bindingStartColumn);
|
||||
encodeInteger(writer, expRange[0]!, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (index++; index < ranges.length; ) {
|
||||
const next = ranges[index];
|
||||
const { 0: l, 1: c } = next;
|
||||
if (l > endLine || (l === endLine && c >= endColumn)) {
|
||||
break;
|
||||
}
|
||||
index = _encodeGeneratedRanges(ranges, index, writer, state);
|
||||
}
|
||||
|
||||
if (state[0] < endLine) {
|
||||
catchupLine(writer, state[0], endLine);
|
||||
state[0] = endLine;
|
||||
state[1] = 0;
|
||||
} else {
|
||||
writer.write(comma);
|
||||
}
|
||||
state[1] = encodeInteger(writer, endColumn, state[1]);
|
||||
|
||||
return index;
|
||||
}
|
||||
|
||||
function catchupLine(writer: StringWriter, lastLine: number, line: number) {
|
||||
do {
|
||||
writer.write(semicolon);
|
||||
} while (++lastLine < line);
|
||||
}
|
||||
+111
@@ -0,0 +1,111 @@
|
||||
import { comma, decodeInteger, encodeInteger, hasMoreVlq, semicolon } from './vlq';
|
||||
import { StringWriter, StringReader } from './strings';
|
||||
|
||||
export {
|
||||
decodeOriginalScopes,
|
||||
encodeOriginalScopes,
|
||||
decodeGeneratedRanges,
|
||||
encodeGeneratedRanges,
|
||||
} from './scopes';
|
||||
export type { OriginalScope, GeneratedRange, CallSite, BindingExpressionRange } from './scopes';
|
||||
|
||||
export type SourceMapSegment =
|
||||
| [number]
|
||||
| [number, number, number, number]
|
||||
| [number, number, number, number, number];
|
||||
export type SourceMapLine = SourceMapSegment[];
|
||||
export type SourceMapMappings = SourceMapLine[];
|
||||
|
||||
export function decode(mappings: string): SourceMapMappings {
|
||||
const { length } = mappings;
|
||||
const reader = new StringReader(mappings);
|
||||
const decoded: SourceMapMappings = [];
|
||||
let genColumn = 0;
|
||||
let sourcesIndex = 0;
|
||||
let sourceLine = 0;
|
||||
let sourceColumn = 0;
|
||||
let namesIndex = 0;
|
||||
|
||||
do {
|
||||
const semi = reader.indexOf(';');
|
||||
const line: SourceMapLine = [];
|
||||
let sorted = true;
|
||||
let lastCol = 0;
|
||||
genColumn = 0;
|
||||
|
||||
while (reader.pos < semi) {
|
||||
let seg: SourceMapSegment;
|
||||
|
||||
genColumn = decodeInteger(reader, genColumn);
|
||||
if (genColumn < lastCol) sorted = false;
|
||||
lastCol = genColumn;
|
||||
|
||||
if (hasMoreVlq(reader, semi)) {
|
||||
sourcesIndex = decodeInteger(reader, sourcesIndex);
|
||||
sourceLine = decodeInteger(reader, sourceLine);
|
||||
sourceColumn = decodeInteger(reader, sourceColumn);
|
||||
|
||||
if (hasMoreVlq(reader, semi)) {
|
||||
namesIndex = decodeInteger(reader, namesIndex);
|
||||
seg = [genColumn, sourcesIndex, sourceLine, sourceColumn, namesIndex];
|
||||
} else {
|
||||
seg = [genColumn, sourcesIndex, sourceLine, sourceColumn];
|
||||
}
|
||||
} else {
|
||||
seg = [genColumn];
|
||||
}
|
||||
|
||||
line.push(seg);
|
||||
reader.pos++;
|
||||
}
|
||||
|
||||
if (!sorted) sort(line);
|
||||
decoded.push(line);
|
||||
reader.pos = semi + 1;
|
||||
} while (reader.pos <= length);
|
||||
|
||||
return decoded;
|
||||
}
|
||||
|
||||
function sort(line: SourceMapSegment[]) {
|
||||
line.sort(sortComparator);
|
||||
}
|
||||
|
||||
function sortComparator(a: SourceMapSegment, b: SourceMapSegment): number {
|
||||
return a[0] - b[0];
|
||||
}
|
||||
|
||||
export function encode(decoded: SourceMapMappings): string;
|
||||
export function encode(decoded: Readonly<SourceMapMappings>): string;
|
||||
export function encode(decoded: Readonly<SourceMapMappings>): string {
|
||||
const writer = new StringWriter();
|
||||
let sourcesIndex = 0;
|
||||
let sourceLine = 0;
|
||||
let sourceColumn = 0;
|
||||
let namesIndex = 0;
|
||||
|
||||
for (let i = 0; i < decoded.length; i++) {
|
||||
const line = decoded[i];
|
||||
if (i > 0) writer.write(semicolon);
|
||||
if (line.length === 0) continue;
|
||||
|
||||
let genColumn = 0;
|
||||
|
||||
for (let j = 0; j < line.length; j++) {
|
||||
const segment = line[j];
|
||||
if (j > 0) writer.write(comma);
|
||||
|
||||
genColumn = encodeInteger(writer, segment[0], genColumn);
|
||||
|
||||
if (segment.length === 1) continue;
|
||||
sourcesIndex = encodeInteger(writer, segment[1], sourcesIndex);
|
||||
sourceLine = encodeInteger(writer, segment[2], sourceLine);
|
||||
sourceColumn = encodeInteger(writer, segment[3], sourceColumn);
|
||||
|
||||
if (segment.length === 4) continue;
|
||||
namesIndex = encodeInteger(writer, segment[4], namesIndex);
|
||||
}
|
||||
}
|
||||
|
||||
return writer.flush();
|
||||
}
|
||||
+65
@@ -0,0 +1,65 @@
|
||||
const bufLength = 1024 * 16;
|
||||
|
||||
// Provide a fallback for older environments.
|
||||
const td =
|
||||
typeof TextDecoder !== 'undefined'
|
||||
? /* #__PURE__ */ new TextDecoder()
|
||||
: typeof Buffer !== 'undefined'
|
||||
? {
|
||||
decode(buf: Uint8Array): string {
|
||||
const out = Buffer.from(buf.buffer, buf.byteOffset, buf.byteLength);
|
||||
return out.toString();
|
||||
},
|
||||
}
|
||||
: {
|
||||
decode(buf: Uint8Array): string {
|
||||
let out = '';
|
||||
for (let i = 0; i < buf.length; i++) {
|
||||
out += String.fromCharCode(buf[i]);
|
||||
}
|
||||
return out;
|
||||
},
|
||||
};
|
||||
|
||||
export class StringWriter {
|
||||
pos = 0;
|
||||
private out = '';
|
||||
private buffer = new Uint8Array(bufLength);
|
||||
|
||||
write(v: number): void {
|
||||
const { buffer } = this;
|
||||
buffer[this.pos++] = v;
|
||||
if (this.pos === bufLength) {
|
||||
this.out += td.decode(buffer);
|
||||
this.pos = 0;
|
||||
}
|
||||
}
|
||||
|
||||
flush(): string {
|
||||
const { buffer, out, pos } = this;
|
||||
return pos > 0 ? out + td.decode(buffer.subarray(0, pos)) : out;
|
||||
}
|
||||
}
|
||||
|
||||
export class StringReader {
|
||||
pos = 0;
|
||||
declare private buffer: string;
|
||||
|
||||
constructor(buffer: string) {
|
||||
this.buffer = buffer;
|
||||
}
|
||||
|
||||
next(): number {
|
||||
return this.buffer.charCodeAt(this.pos++);
|
||||
}
|
||||
|
||||
peek(): number {
|
||||
return this.buffer.charCodeAt(this.pos);
|
||||
}
|
||||
|
||||
indexOf(char: string): number {
|
||||
const { buffer, pos } = this;
|
||||
const idx = buffer.indexOf(char, pos);
|
||||
return idx === -1 ? buffer.length : idx;
|
||||
}
|
||||
}
|
||||
+55
@@ -0,0 +1,55 @@
|
||||
import type { StringReader, StringWriter } from './strings';
|
||||
|
||||
export const comma = ','.charCodeAt(0);
|
||||
export const semicolon = ';'.charCodeAt(0);
|
||||
|
||||
const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
|
||||
const intToChar = new Uint8Array(64); // 64 possible chars.
|
||||
const charToInt = new Uint8Array(128); // z is 122 in ASCII
|
||||
|
||||
for (let i = 0; i < chars.length; i++) {
|
||||
const c = chars.charCodeAt(i);
|
||||
intToChar[i] = c;
|
||||
charToInt[c] = i;
|
||||
}
|
||||
|
||||
export function decodeInteger(reader: StringReader, relative: number): number {
|
||||
let value = 0;
|
||||
let shift = 0;
|
||||
let integer = 0;
|
||||
|
||||
do {
|
||||
const c = reader.next();
|
||||
integer = charToInt[c];
|
||||
value |= (integer & 31) << shift;
|
||||
shift += 5;
|
||||
} while (integer & 32);
|
||||
|
||||
const shouldNegate = value & 1;
|
||||
value >>>= 1;
|
||||
|
||||
if (shouldNegate) {
|
||||
value = -0x80000000 | -value;
|
||||
}
|
||||
|
||||
return relative + value;
|
||||
}
|
||||
|
||||
export function encodeInteger(builder: StringWriter, num: number, relative: number): number {
|
||||
let delta = num - relative;
|
||||
|
||||
delta = delta < 0 ? (-delta << 1) | 1 : delta << 1;
|
||||
do {
|
||||
let clamped = delta & 0b011111;
|
||||
delta >>>= 5;
|
||||
if (delta > 0) clamped |= 0b100000;
|
||||
builder.write(intToChar[clamped]);
|
||||
} while (delta > 0);
|
||||
|
||||
return num;
|
||||
}
|
||||
|
||||
export function hasMoreVlq(reader: StringReader, max: number) {
|
||||
if (reader.pos >= max) return false;
|
||||
return reader.peek() !== comma;
|
||||
}
|
||||
+50
@@ -0,0 +1,50 @@
|
||||
type Line = number;
|
||||
type Column = number;
|
||||
type Kind = number;
|
||||
type Name = number;
|
||||
type Var = number;
|
||||
type SourcesIndex = number;
|
||||
type ScopesIndex = number;
|
||||
type Mix<A, B, O> = (A & O) | (B & O);
|
||||
export type OriginalScope = Mix<[
|
||||
Line,
|
||||
Column,
|
||||
Line,
|
||||
Column,
|
||||
Kind
|
||||
], [
|
||||
Line,
|
||||
Column,
|
||||
Line,
|
||||
Column,
|
||||
Kind,
|
||||
Name
|
||||
], {
|
||||
vars: Var[];
|
||||
}>;
|
||||
export type GeneratedRange = Mix<[
|
||||
Line,
|
||||
Column,
|
||||
Line,
|
||||
Column
|
||||
], [
|
||||
Line,
|
||||
Column,
|
||||
Line,
|
||||
Column,
|
||||
SourcesIndex,
|
||||
ScopesIndex
|
||||
], {
|
||||
callsite: CallSite | null;
|
||||
bindings: Binding[];
|
||||
isScope: boolean;
|
||||
}>;
|
||||
export type CallSite = [SourcesIndex, Line, Column];
|
||||
type Binding = BindingExpressionRange[];
|
||||
export type BindingExpressionRange = [Name] | [Name, Line, Column];
|
||||
export declare function decodeOriginalScopes(input: string): OriginalScope[];
|
||||
export declare function encodeOriginalScopes(scopes: OriginalScope[]): string;
|
||||
export declare function decodeGeneratedRanges(input: string): GeneratedRange[];
|
||||
export declare function encodeGeneratedRanges(ranges: GeneratedRange[]): string;
|
||||
export {};
|
||||
//# sourceMappingURL=scopes.d.ts.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"scopes.d.ts","sourceRoot":"","sources":["../src/scopes.ts"],"names":[],"mappings":"AAKA,KAAK,IAAI,GAAG,MAAM,CAAC;AACnB,KAAK,MAAM,GAAG,MAAM,CAAC;AACrB,KAAK,IAAI,GAAG,MAAM,CAAC;AACnB,KAAK,IAAI,GAAG,MAAM,CAAC;AACnB,KAAK,GAAG,GAAG,MAAM,CAAC;AAClB,KAAK,YAAY,GAAG,MAAM,CAAC;AAC3B,KAAK,WAAW,GAAG,MAAM,CAAC;AAE1B,KAAK,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;AAEtC,MAAM,MAAM,aAAa,GAAG,GAAG,CAC7B;IAAC,IAAI;IAAE,MAAM;IAAE,IAAI;IAAE,MAAM;IAAE,IAAI;CAAC,EAClC;IAAC,IAAI;IAAE,MAAM;IAAE,IAAI;IAAE,MAAM;IAAE,IAAI;IAAE,IAAI;CAAC,EACxC;IAAE,IAAI,EAAE,GAAG,EAAE,CAAA;CAAE,CAChB,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG,GAAG,CAC9B;IAAC,IAAI;IAAE,MAAM;IAAE,IAAI;IAAE,MAAM;CAAC,EAC5B;IAAC,IAAI;IAAE,MAAM;IAAE,IAAI;IAAE,MAAM;IAAE,YAAY;IAAE,WAAW;CAAC,EACvD;IACE,QAAQ,EAAE,QAAQ,GAAG,IAAI,CAAC;IAC1B,QAAQ,EAAE,OAAO,EAAE,CAAC;IACpB,OAAO,EAAE,OAAO,CAAC;CAClB,CACF,CAAC;AACF,MAAM,MAAM,QAAQ,GAAG,CAAC,YAAY,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;AACpD,KAAK,OAAO,GAAG,sBAAsB,EAAE,CAAC;AACxC,MAAM,MAAM,sBAAsB,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;AAEnE,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM,GAAG,aAAa,EAAE,CAyCnE;AAED,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,aAAa,EAAE,GAAG,MAAM,CAQpE;AA2CD,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,MAAM,GAAG,cAAc,EAAE,CAoGrE;AAED,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,cAAc,EAAE,GAAG,MAAM,CAUtE"}
|
||||
+50
@@ -0,0 +1,50 @@
|
||||
type Line = number;
|
||||
type Column = number;
|
||||
type Kind = number;
|
||||
type Name = number;
|
||||
type Var = number;
|
||||
type SourcesIndex = number;
|
||||
type ScopesIndex = number;
|
||||
type Mix<A, B, O> = (A & O) | (B & O);
|
||||
export type OriginalScope = Mix<[
|
||||
Line,
|
||||
Column,
|
||||
Line,
|
||||
Column,
|
||||
Kind
|
||||
], [
|
||||
Line,
|
||||
Column,
|
||||
Line,
|
||||
Column,
|
||||
Kind,
|
||||
Name
|
||||
], {
|
||||
vars: Var[];
|
||||
}>;
|
||||
export type GeneratedRange = Mix<[
|
||||
Line,
|
||||
Column,
|
||||
Line,
|
||||
Column
|
||||
], [
|
||||
Line,
|
||||
Column,
|
||||
Line,
|
||||
Column,
|
||||
SourcesIndex,
|
||||
ScopesIndex
|
||||
], {
|
||||
callsite: CallSite | null;
|
||||
bindings: Binding[];
|
||||
isScope: boolean;
|
||||
}>;
|
||||
export type CallSite = [SourcesIndex, Line, Column];
|
||||
type Binding = BindingExpressionRange[];
|
||||
export type BindingExpressionRange = [Name] | [Name, Line, Column];
|
||||
export declare function decodeOriginalScopes(input: string): OriginalScope[];
|
||||
export declare function encodeOriginalScopes(scopes: OriginalScope[]): string;
|
||||
export declare function decodeGeneratedRanges(input: string): GeneratedRange[];
|
||||
export declare function encodeGeneratedRanges(ranges: GeneratedRange[]): string;
|
||||
export {};
|
||||
//# sourceMappingURL=scopes.d.ts.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"scopes.d.ts","sourceRoot":"","sources":["../src/scopes.ts"],"names":[],"mappings":"AAKA,KAAK,IAAI,GAAG,MAAM,CAAC;AACnB,KAAK,MAAM,GAAG,MAAM,CAAC;AACrB,KAAK,IAAI,GAAG,MAAM,CAAC;AACnB,KAAK,IAAI,GAAG,MAAM,CAAC;AACnB,KAAK,GAAG,GAAG,MAAM,CAAC;AAClB,KAAK,YAAY,GAAG,MAAM,CAAC;AAC3B,KAAK,WAAW,GAAG,MAAM,CAAC;AAE1B,KAAK,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;AAEtC,MAAM,MAAM,aAAa,GAAG,GAAG,CAC7B;IAAC,IAAI;IAAE,MAAM;IAAE,IAAI;IAAE,MAAM;IAAE,IAAI;CAAC,EAClC;IAAC,IAAI;IAAE,MAAM;IAAE,IAAI;IAAE,MAAM;IAAE,IAAI;IAAE,IAAI;CAAC,EACxC;IAAE,IAAI,EAAE,GAAG,EAAE,CAAA;CAAE,CAChB,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG,GAAG,CAC9B;IAAC,IAAI;IAAE,MAAM;IAAE,IAAI;IAAE,MAAM;CAAC,EAC5B;IAAC,IAAI;IAAE,MAAM;IAAE,IAAI;IAAE,MAAM;IAAE,YAAY;IAAE,WAAW;CAAC,EACvD;IACE,QAAQ,EAAE,QAAQ,GAAG,IAAI,CAAC;IAC1B,QAAQ,EAAE,OAAO,EAAE,CAAC;IACpB,OAAO,EAAE,OAAO,CAAC;CAClB,CACF,CAAC;AACF,MAAM,MAAM,QAAQ,GAAG,CAAC,YAAY,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;AACpD,KAAK,OAAO,GAAG,sBAAsB,EAAE,CAAC;AACxC,MAAM,MAAM,sBAAsB,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;AAEnE,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM,GAAG,aAAa,EAAE,CAyCnE;AAED,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,aAAa,EAAE,GAAG,MAAM,CAQpE;AA2CD,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,MAAM,GAAG,cAAc,EAAE,CAoGrE;AAED,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,cAAc,EAAE,GAAG,MAAM,CAUtE"}
|
||||
Generated
Vendored
+9
@@ -0,0 +1,9 @@
|
||||
export { decodeOriginalScopes, encodeOriginalScopes, decodeGeneratedRanges, encodeGeneratedRanges, } from './scopes.cts';
|
||||
export type { OriginalScope, GeneratedRange, CallSite, BindingExpressionRange } from './scopes.cts';
|
||||
export type SourceMapSegment = [number] | [number, number, number, number] | [number, number, number, number, number];
|
||||
export type SourceMapLine = SourceMapSegment[];
|
||||
export type SourceMapMappings = SourceMapLine[];
|
||||
export declare function decode(mappings: string): SourceMapMappings;
|
||||
export declare function encode(decoded: SourceMapMappings): string;
|
||||
export declare function encode(decoded: Readonly<SourceMapMappings>): string;
|
||||
//# sourceMappingURL=sourcemap-codec.d.ts.map
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"sourcemap-codec.d.ts","sourceRoot":"","sources":["../src/sourcemap-codec.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,oBAAoB,EACpB,oBAAoB,EACpB,qBAAqB,EACrB,qBAAqB,GACtB,MAAM,UAAU,CAAC;AAClB,YAAY,EAAE,aAAa,EAAE,cAAc,EAAE,QAAQ,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAC;AAEhG,MAAM,MAAM,gBAAgB,GACxB,CAAC,MAAM,CAAC,GACR,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,GAChC,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;AAC7C,MAAM,MAAM,aAAa,GAAG,gBAAgB,EAAE,CAAC;AAC/C,MAAM,MAAM,iBAAiB,GAAG,aAAa,EAAE,CAAC;AAEhD,wBAAgB,MAAM,CAAC,QAAQ,EAAE,MAAM,GAAG,iBAAiB,CAiD1D;AAUD,wBAAgB,MAAM,CAAC,OAAO,EAAE,iBAAiB,GAAG,MAAM,CAAC;AAC3D,wBAAgB,MAAM,CAAC,OAAO,EAAE,QAAQ,CAAC,iBAAiB,CAAC,GAAG,MAAM,CAAC"}
|
||||
Generated
Vendored
+9
@@ -0,0 +1,9 @@
|
||||
export { decodeOriginalScopes, encodeOriginalScopes, decodeGeneratedRanges, encodeGeneratedRanges, } from './scopes.mts';
|
||||
export type { OriginalScope, GeneratedRange, CallSite, BindingExpressionRange } from './scopes.mts';
|
||||
export type SourceMapSegment = [number] | [number, number, number, number] | [number, number, number, number, number];
|
||||
export type SourceMapLine = SourceMapSegment[];
|
||||
export type SourceMapMappings = SourceMapLine[];
|
||||
export declare function decode(mappings: string): SourceMapMappings;
|
||||
export declare function encode(decoded: SourceMapMappings): string;
|
||||
export declare function encode(decoded: Readonly<SourceMapMappings>): string;
|
||||
//# sourceMappingURL=sourcemap-codec.d.ts.map
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"sourcemap-codec.d.ts","sourceRoot":"","sources":["../src/sourcemap-codec.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,oBAAoB,EACpB,oBAAoB,EACpB,qBAAqB,EACrB,qBAAqB,GACtB,MAAM,UAAU,CAAC;AAClB,YAAY,EAAE,aAAa,EAAE,cAAc,EAAE,QAAQ,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAC;AAEhG,MAAM,MAAM,gBAAgB,GACxB,CAAC,MAAM,CAAC,GACR,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,GAChC,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;AAC7C,MAAM,MAAM,aAAa,GAAG,gBAAgB,EAAE,CAAC;AAC/C,MAAM,MAAM,iBAAiB,GAAG,aAAa,EAAE,CAAC;AAEhD,wBAAgB,MAAM,CAAC,QAAQ,EAAE,MAAM,GAAG,iBAAiB,CAiD1D;AAUD,wBAAgB,MAAM,CAAC,OAAO,EAAE,iBAAiB,GAAG,MAAM,CAAC;AAC3D,wBAAgB,MAAM,CAAC,OAAO,EAAE,QAAQ,CAAC,iBAAiB,CAAC,GAAG,MAAM,CAAC"}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
export declare class StringWriter {
|
||||
pos: number;
|
||||
private out;
|
||||
private buffer;
|
||||
write(v: number): void;
|
||||
flush(): string;
|
||||
}
|
||||
export declare class StringReader {
|
||||
pos: number;
|
||||
private buffer;
|
||||
constructor(buffer: string);
|
||||
next(): number;
|
||||
peek(): number;
|
||||
indexOf(char: string): number;
|
||||
}
|
||||
//# sourceMappingURL=strings.d.ts.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"strings.d.ts","sourceRoot":"","sources":["../src/strings.ts"],"names":[],"mappings":"AAuBA,qBAAa,YAAY;IACvB,GAAG,SAAK;IACR,OAAO,CAAC,GAAG,CAAM;IACjB,OAAO,CAAC,MAAM,CAA6B;IAE3C,KAAK,CAAC,CAAC,EAAE,MAAM,GAAG,IAAI;IAStB,KAAK,IAAI,MAAM;CAIhB;AAED,qBAAa,YAAY;IACvB,GAAG,SAAK;IACR,QAAgB,MAAM,CAAS;gBAEnB,MAAM,EAAE,MAAM;IAI1B,IAAI,IAAI,MAAM;IAId,IAAI,IAAI,MAAM;IAId,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;CAK9B"}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
export declare class StringWriter {
|
||||
pos: number;
|
||||
private out;
|
||||
private buffer;
|
||||
write(v: number): void;
|
||||
flush(): string;
|
||||
}
|
||||
export declare class StringReader {
|
||||
pos: number;
|
||||
private buffer;
|
||||
constructor(buffer: string);
|
||||
next(): number;
|
||||
peek(): number;
|
||||
indexOf(char: string): number;
|
||||
}
|
||||
//# sourceMappingURL=strings.d.ts.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"strings.d.ts","sourceRoot":"","sources":["../src/strings.ts"],"names":[],"mappings":"AAuBA,qBAAa,YAAY;IACvB,GAAG,SAAK;IACR,OAAO,CAAC,GAAG,CAAM;IACjB,OAAO,CAAC,MAAM,CAA6B;IAE3C,KAAK,CAAC,CAAC,EAAE,MAAM,GAAG,IAAI;IAStB,KAAK,IAAI,MAAM;CAIhB;AAED,qBAAa,YAAY;IACvB,GAAG,SAAK;IACR,QAAgB,MAAM,CAAS;gBAEnB,MAAM,EAAE,MAAM;IAI1B,IAAI,IAAI,MAAM;IAId,IAAI,IAAI,MAAM;IAId,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;CAK9B"}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
import type { StringReader, StringWriter } from './strings.cts';
|
||||
export declare const comma: number;
|
||||
export declare const semicolon: number;
|
||||
export declare function decodeInteger(reader: StringReader, relative: number): number;
|
||||
export declare function encodeInteger(builder: StringWriter, num: number, relative: number): number;
|
||||
export declare function hasMoreVlq(reader: StringReader, max: number): boolean;
|
||||
//# sourceMappingURL=vlq.d.ts.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"vlq.d.ts","sourceRoot":"","sources":["../src/vlq.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAE5D,eAAO,MAAM,KAAK,QAAoB,CAAC;AACvC,eAAO,MAAM,SAAS,QAAoB,CAAC;AAY3C,wBAAgB,aAAa,CAAC,MAAM,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAoB5E;AAED,wBAAgB,aAAa,CAAC,OAAO,EAAE,YAAY,EAAE,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAY1F;AAED,wBAAgB,UAAU,CAAC,MAAM,EAAE,YAAY,EAAE,GAAG,EAAE,MAAM,WAG3D"}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
import type { StringReader, StringWriter } from './strings.mts';
|
||||
export declare const comma: number;
|
||||
export declare const semicolon: number;
|
||||
export declare function decodeInteger(reader: StringReader, relative: number): number;
|
||||
export declare function encodeInteger(builder: StringWriter, num: number, relative: number): number;
|
||||
export declare function hasMoreVlq(reader: StringReader, max: number): boolean;
|
||||
//# sourceMappingURL=vlq.d.ts.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"vlq.d.ts","sourceRoot":"","sources":["../src/vlq.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAE5D,eAAO,MAAM,KAAK,QAAoB,CAAC;AACvC,eAAO,MAAM,SAAS,QAAoB,CAAC;AAY3C,wBAAgB,aAAa,CAAC,MAAM,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAoB5E;AAED,wBAAgB,aAAa,CAAC,OAAO,EAAE,YAAY,EAAE,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAY1F;AAED,wBAAgB,UAAU,CAAC,MAAM,EAAE,YAAY,EAAE,GAAG,EAAE,MAAM,WAG3D"}
|
||||
+202
@@ -0,0 +1,202 @@
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Portions Copyright (c) Microsoft Corporation.
|
||||
Portions Copyright 2017 Google Inc.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
Playwright
|
||||
Copyright (c) Microsoft Corporation
|
||||
|
||||
This software contains code derived from the Puppeteer project (https://github.com/puppeteer/puppeteer),
|
||||
available under the Apache 2.0 license (https://github.com/puppeteer/puppeteer/blob/master/LICENSE).
|
||||
+318
@@ -0,0 +1,318 @@
|
||||
# 🎭 Playwright
|
||||
|
||||
[](https://www.npmjs.com/package/playwright) <!-- GEN:chromium-version-badge -->[](https://www.chromium.org/Home)<!-- GEN:stop --> <!-- GEN:firefox-version-badge -->[](https://www.mozilla.org/en-US/firefox/new/)<!-- GEN:stop --> <!-- GEN:webkit-version-badge -->[](https://webkit.org/)<!-- GEN:stop --> [](https://aka.ms/playwright/discord)
|
||||
|
||||
## [Documentation](https://playwright.dev) | [API reference](https://playwright.dev/docs/api/class-playwright)
|
||||
|
||||
Playwright is a framework for web automation and testing. It drives Chromium, Firefox, and WebKit with a single API — in your tests, in your scripts, and as a tool for AI agents.
|
||||
|
||||
## Get Started
|
||||
|
||||
Choose the path that fits your workflow:
|
||||
|
||||
| | Best for | Install |
|
||||
|---|---|---|
|
||||
| **[Playwright Test](#playwright-test)** | End-to-end testing | `npm init playwright@latest` |
|
||||
| **[Playwright CLI](#playwright-cli)** | Coding agents (Claude Code, Copilot) | `npm i -g @playwright/cli@latest` |
|
||||
| **[Playwright MCP](#playwright-mcp)** | AI agents and LLM-driven automation | `npx @playwright/mcp@latest` |
|
||||
| **[Playwright Library](#playwright-library)** | Browser automation scripts | `npm i playwright` |
|
||||
| **[VS Code Extension](#vs-code-extension)** | Test authoring and debugging in VS Code | [Install from Marketplace](https://marketplace.visualstudio.com/items?itemName=ms-playwright.playwright) |
|
||||
|
||||
---
|
||||
|
||||
## Playwright Test
|
||||
|
||||
Playwright Test is a full-featured test runner built for end-to-end testing. It runs tests across Chromium, Firefox, and WebKit with full browser isolation, auto-waiting, and web-first assertions.
|
||||
|
||||
### Install
|
||||
|
||||
```bash
|
||||
npm init playwright@latest
|
||||
```
|
||||
|
||||
Or add manually:
|
||||
|
||||
```bash
|
||||
npm i -D @playwright/test
|
||||
npx playwright install
|
||||
```
|
||||
|
||||
### Write a test
|
||||
|
||||
```TypeScript
|
||||
import { test, expect } from '@playwright/test';
|
||||
|
||||
test('has title', async ({ page }) => {
|
||||
await page.goto('https://playwright.dev/');
|
||||
await expect(page).toHaveTitle(/Playwright/);
|
||||
});
|
||||
|
||||
test('get started link', async ({ page }) => {
|
||||
await page.goto('https://playwright.dev/');
|
||||
await page.getByRole('link', { name: 'Get started' }).click();
|
||||
await expect(page.getByRole('heading', { name: 'Installation' })).toBeVisible();
|
||||
});
|
||||
```
|
||||
|
||||
### Run tests
|
||||
|
||||
```bash
|
||||
npx playwright test
|
||||
```
|
||||
|
||||
Tests run in parallel across all configured browsers, in headless mode by default. Each test gets a fresh browser context — full isolation with near-zero overhead.
|
||||
|
||||
### Key capabilities
|
||||
|
||||
**Auto-wait and web-first assertions.** No artificial timeouts. Playwright waits for elements to be actionable, and assertions automatically retry until conditions are met.
|
||||
|
||||
**Locators.** Find elements with resilient locators that mirror how users see the page:
|
||||
|
||||
```TypeScript
|
||||
page.getByRole('button', { name: 'Submit' })
|
||||
page.getByLabel('Email')
|
||||
page.getByPlaceholder('Search...')
|
||||
page.getByTestId('login-form')
|
||||
```
|
||||
|
||||
**Test isolation.** Each test runs in its own browser context — equivalent to a fresh browser profile. Save authentication state once and reuse it across tests:
|
||||
|
||||
```TypeScript
|
||||
// Save state after login
|
||||
await page.context().storageState({ path: 'auth.json' });
|
||||
|
||||
// Reuse in other tests
|
||||
test.use({ storageState: 'auth.json' });
|
||||
```
|
||||
|
||||
**Tracing.** Capture execution traces, screenshots, and videos on failure. Inspect every action, DOM snapshot, network request, and console message in the [Trace Viewer](https://playwright.dev/docs/trace-viewer):
|
||||
|
||||
```TypeScript
|
||||
// playwright.config.ts
|
||||
export default defineConfig({
|
||||
use: {
|
||||
trace: 'on-first-retry',
|
||||
},
|
||||
});
|
||||
```
|
||||
|
||||
```bash
|
||||
npx playwright show-trace trace.zip
|
||||
```
|
||||
|
||||
<!-- TODO: screenshot of trace viewer -->
|
||||
|
||||
**Parallelism.** Tests run in parallel by default across all configured browsers.
|
||||
|
||||
[Full testing documentation](https://playwright.dev/docs/intro)
|
||||
|
||||
---
|
||||
|
||||
## Playwright CLI
|
||||
|
||||
[Playwright CLI](https://github.com/microsoft/playwright-cli) is a command-line interface for browser automation designed for coding agents. It's more token-efficient than MCP — commands avoid loading large tool schemas and accessibility trees into the model context.
|
||||
|
||||
### Install
|
||||
|
||||
```bash
|
||||
npm install -g @playwright/cli@latest
|
||||
```
|
||||
|
||||
Optionally install skills for richer agent integration:
|
||||
|
||||
```bash
|
||||
playwright-cli install --skills
|
||||
```
|
||||
|
||||
### Usage
|
||||
|
||||
Point your coding agent at a task:
|
||||
|
||||
```
|
||||
Test the "add todo" flow on https://demo.playwright.dev/todomvc using playwright-cli.
|
||||
Take screenshots for all successful and failing scenarios.
|
||||
```
|
||||
|
||||
Or run commands directly:
|
||||
|
||||
```bash
|
||||
playwright-cli open https://demo.playwright.dev/todomvc/ --headed
|
||||
playwright-cli type "Buy groceries"
|
||||
playwright-cli press Enter
|
||||
playwright-cli screenshot
|
||||
```
|
||||
|
||||
### Session monitoring
|
||||
|
||||
Use `playwright-cli show` to open a visual dashboard with live screencast previews of all running browser sessions. Click any session to zoom in and take remote control.
|
||||
|
||||
```bash
|
||||
playwright-cli show
|
||||
```
|
||||
|
||||
<!-- TODO: screenshot of playwright-cli show dashboard -->
|
||||
|
||||
[Full CLI documentation](https://playwright.dev/agent-cli/introduction) | [GitHub](https://github.com/microsoft/playwright-cli)
|
||||
|
||||
---
|
||||
|
||||
## Playwright MCP
|
||||
|
||||
The [Playwright MCP server](https://github.com/microsoft/playwright-mcp) gives AI agents full browser control through the [Model Context Protocol](https://modelcontextprotocol.io). Agents interact with pages using structured accessibility snapshots — no vision models or screenshots required.
|
||||
|
||||
### Setup
|
||||
|
||||
Add to your MCP client (VS Code, Cursor, Claude Desktop, Windsurf, etc.):
|
||||
|
||||
```json
|
||||
{
|
||||
"mcpServers": {
|
||||
"playwright": {
|
||||
"command": "npx",
|
||||
"args": ["@playwright/mcp@latest"]
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
**One-click install for VS Code:**
|
||||
|
||||
[<img src="https://img.shields.io/badge/VS_Code-VS_Code?style=flat-square&label=Install%20MCP%20Server&color=0098FF" alt="Install in VS Code" />](https://insiders.vscode.dev/redirect?url=vscode%3Amcp%2Finstall%3F%257B%2522name%2522%253A%2522playwright%2522%252C%2522command%2522%253A%2522npx%2522%252C%2522args%2522%253A%255B%2522%2540playwright%252Fmcp%2540latest%2522%255D%257D)
|
||||
|
||||
**For Claude Code:**
|
||||
|
||||
```bash
|
||||
claude mcp add playwright npx @playwright/mcp@latest
|
||||
```
|
||||
|
||||
### How it works
|
||||
|
||||
Ask your AI assistant to interact with any web page:
|
||||
|
||||
```
|
||||
Navigate to https://demo.playwright.dev/todomvc and add a few todo items.
|
||||
```
|
||||
|
||||
The agent sees the page as a structured accessibility tree:
|
||||
|
||||
```
|
||||
- heading "todos" [level=1]
|
||||
- textbox "What needs to be done?" [ref=e5]
|
||||
- listitem:
|
||||
- checkbox "Toggle Todo" [ref=e10]
|
||||
- text: "Buy groceries"
|
||||
```
|
||||
|
||||
It uses element refs like `e5` and `e10` to click, type, and interact — deterministically and without visual ambiguity. Tools cover navigation, form filling, screenshots, network mocking, storage management, and more.
|
||||
|
||||
[Full MCP documentation](https://playwright.dev/mcp/introduction) | [GitHub](https://github.com/microsoft/playwright-mcp)
|
||||
|
||||
---
|
||||
|
||||
## Playwright Library
|
||||
|
||||
Use `playwright` as a library for browser automation scripts — web scraping, PDF generation, screenshot capture, and any workflow that needs programmatic browser control without a test runner.
|
||||
|
||||
### Install
|
||||
|
||||
```bash
|
||||
npm i playwright
|
||||
```
|
||||
|
||||
### Examples
|
||||
|
||||
**Take a screenshot:**
|
||||
|
||||
```TypeScript
|
||||
import { chromium } from 'playwright';
|
||||
|
||||
const browser = await chromium.launch();
|
||||
const page = await browser.newPage();
|
||||
await page.goto('https://playwright.dev/');
|
||||
await page.screenshot({ path: 'screenshot.png' });
|
||||
await browser.close();
|
||||
```
|
||||
|
||||
**Generate a PDF:**
|
||||
|
||||
```TypeScript
|
||||
import { chromium } from 'playwright';
|
||||
|
||||
const browser = await chromium.launch();
|
||||
const page = await browser.newPage();
|
||||
await page.goto('https://playwright.dev/');
|
||||
await page.pdf({ path: 'page.pdf', format: 'A4' });
|
||||
await browser.close();
|
||||
```
|
||||
|
||||
**Emulate a mobile device:**
|
||||
|
||||
```TypeScript
|
||||
import { chromium, devices } from 'playwright';
|
||||
|
||||
const browser = await chromium.launch();
|
||||
const context = await browser.newContext(devices['iPhone 15']);
|
||||
const page = await context.newPage();
|
||||
await page.goto('https://playwright.dev/');
|
||||
await page.screenshot({ path: 'mobile.png' });
|
||||
await browser.close();
|
||||
```
|
||||
|
||||
**Intercept network requests:**
|
||||
|
||||
```TypeScript
|
||||
import { chromium } from 'playwright';
|
||||
|
||||
const browser = await chromium.launch();
|
||||
const page = await browser.newPage();
|
||||
await page.route('**/*.{png,jpg,jpeg}', route => route.abort());
|
||||
await page.goto('https://playwright.dev/');
|
||||
await browser.close();
|
||||
```
|
||||
|
||||
[Library documentation](https://playwright.dev/docs/library) | [API reference](https://playwright.dev/docs/api/class-playwright)
|
||||
|
||||
---
|
||||
|
||||
## VS Code Extension
|
||||
|
||||
The [Playwright VS Code extension](https://marketplace.visualstudio.com/items?itemName=ms-playwright.playwright) brings test running, debugging, and code generation directly into your editor.
|
||||
|
||||
<!-- TODO: hero screenshot of VS Code with Playwright sidebar -->
|
||||
|
||||
**Run and debug tests** from the editor with a single click. Set breakpoints, inspect variables, and step through test execution with a live browser view.
|
||||
|
||||
**Generate tests with CodeGen.** Click "Record new" to open a browser — navigate and interact with your app while Playwright writes the test code for you.
|
||||
|
||||
**Pick locators.** Hover over any element in the browser to see the best available locator, then click to copy it to your clipboard.
|
||||
|
||||
**Trace Viewer integration.** Enable "Show Trace Viewer" in the sidebar to get a full execution trace after each test run — DOM snapshots, network requests, console logs, and screenshots at every step.
|
||||
|
||||
[Install the extension](https://marketplace.visualstudio.com/items?itemName=ms-playwright.playwright) | [VS Code guide](https://playwright.dev/docs/getting-started-vscode)
|
||||
|
||||
---
|
||||
|
||||
## Cross-Browser Support
|
||||
|
||||
| | Linux | macOS | Windows |
|
||||
| :--- | :---: | :---: | :---: |
|
||||
| Chromium<sup>1</sup> <!-- GEN:chromium-version -->151.0.7922.34<!-- GEN:stop --> | :white_check_mark: | :white_check_mark: | :white_check_mark: |
|
||||
| WebKit <!-- GEN:webkit-version -->26.5<!-- GEN:stop --> | :white_check_mark: | :white_check_mark: | :white_check_mark: |
|
||||
| Firefox <!-- GEN:firefox-version -->153.0<!-- GEN:stop --> | :white_check_mark: | :white_check_mark: | :white_check_mark: |
|
||||
|
||||
Headless and headed execution on all platforms. <sup>1</sup> Uses [Chrome for Testing](https://developer.chrome.com/blog/chrome-for-testing) by default.
|
||||
|
||||
## Other Languages
|
||||
|
||||
Playwright is also available for [Python](https://playwright.dev/python/docs/intro), [.NET](https://playwright.dev/dotnet/docs/intro), and [Java](https://playwright.dev/java/docs/intro).
|
||||
|
||||
## Resources
|
||||
|
||||
* [Documentation](https://playwright.dev)
|
||||
* [API reference](https://playwright.dev/docs/api/class-playwright)
|
||||
* [MCP server](https://github.com/microsoft/playwright-mcp)
|
||||
* [CLI for coding agents](https://github.com/microsoft/playwright-cli)
|
||||
* [VS Code extension](https://github.com/microsoft/playwright-vscode)
|
||||
* [Contribution guide](CONTRIBUTING.md)
|
||||
* [Changelog](https://github.com/microsoft/playwright/releases)
|
||||
* [Discord](https://aka.ms/playwright/discord)
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
#!/usr/bin/env node
|
||||
/**
|
||||
* Copyright (c) Microsoft Corporation.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
const { program } = require('playwright/lib/program');
|
||||
program.parse(process.argv);
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
/**
|
||||
* Copyright (c) Microsoft Corporation.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
export * from 'playwright/test';
|
||||
export { default } from 'playwright/test';
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
/**
|
||||
* Copyright (c) Microsoft Corporation.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
module.exports = require('playwright/test');
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
/**
|
||||
* Copyright (c) Microsoft Corporation.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
export * from 'playwright/test';
|
||||
export { default } from 'playwright/test';
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
{
|
||||
"name": "@playwright/test",
|
||||
"version": "1.62.1",
|
||||
"description": "A high-level API to automate web browsers",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/microsoft/playwright.git"
|
||||
},
|
||||
"homepage": "https://playwright.dev",
|
||||
"engines": {
|
||||
"node": ">=20"
|
||||
},
|
||||
"author": {
|
||||
"name": "Microsoft Corporation"
|
||||
},
|
||||
"license": "Apache-2.0",
|
||||
"exports": {
|
||||
".": {
|
||||
"types": "./index.d.ts",
|
||||
"import": "./index.mjs",
|
||||
"require": "./index.js",
|
||||
"default": "./index.js"
|
||||
},
|
||||
"./cli": "./cli.js",
|
||||
"./package.json": "./package.json",
|
||||
"./reporter": "./reporter.js"
|
||||
},
|
||||
"bin": {
|
||||
"playwright": "cli.js"
|
||||
},
|
||||
"scripts": {},
|
||||
"dependencies": {
|
||||
"playwright": "1.62.1"
|
||||
}
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
/**
|
||||
* Copyright (c) Microsoft Corporation.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
export * from 'playwright/types/testReporter';
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
/**
|
||||
* Copyright (c) Microsoft Corporation.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
// We only export types in reporter.d.ts.
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
/**
|
||||
* Copyright (c) Microsoft Corporation.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
// We only export types in reporter.d.ts.
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
# `@rollup/rollup-darwin-arm64`
|
||||
|
||||
This is the **aarch64-apple-darwin** binary for `rollup`
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"name": "@rollup/rollup-darwin-arm64",
|
||||
"version": "4.62.4",
|
||||
"os": [
|
||||
"darwin"
|
||||
],
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
"files": [
|
||||
"rollup.darwin-arm64.node"
|
||||
],
|
||||
"description": "Native bindings for Rollup",
|
||||
"author": "Lukas Taegert-Atkinson",
|
||||
"homepage": "https://rollupjs.org/",
|
||||
"license": "MIT",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/rollup/rollup.git"
|
||||
},
|
||||
"main": "./rollup.darwin-arm64.node"
|
||||
}
|
||||
BIN
Binary file not shown.
+21
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) Microsoft Corporation.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
# Installation
|
||||
> `npm install --save @types/estree`
|
||||
|
||||
# Summary
|
||||
This package contains type definitions for estree (https://github.com/estree/estree).
|
||||
|
||||
# Details
|
||||
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/estree.
|
||||
|
||||
### Additional Details
|
||||
* Last updated: Wed, 06 May 2026 21:01:00 GMT
|
||||
* Dependencies: none
|
||||
|
||||
# Credits
|
||||
These definitions were written by [RReverser](https://github.com/RReverser).
|
||||
+167
@@ -0,0 +1,167 @@
|
||||
declare namespace ESTree {
|
||||
interface FlowTypeAnnotation extends Node {}
|
||||
|
||||
interface FlowBaseTypeAnnotation extends FlowTypeAnnotation {}
|
||||
|
||||
interface FlowLiteralTypeAnnotation extends FlowTypeAnnotation, Literal {}
|
||||
|
||||
interface FlowDeclaration extends Declaration {}
|
||||
|
||||
interface AnyTypeAnnotation extends FlowBaseTypeAnnotation {}
|
||||
|
||||
interface ArrayTypeAnnotation extends FlowTypeAnnotation {
|
||||
elementType: FlowTypeAnnotation;
|
||||
}
|
||||
|
||||
interface BooleanLiteralTypeAnnotation extends FlowLiteralTypeAnnotation {}
|
||||
|
||||
interface BooleanTypeAnnotation extends FlowBaseTypeAnnotation {}
|
||||
|
||||
interface ClassImplements extends Node {
|
||||
id: Identifier;
|
||||
typeParameters?: TypeParameterInstantiation | null;
|
||||
}
|
||||
|
||||
interface ClassProperty {
|
||||
key: Expression;
|
||||
value?: Expression | null;
|
||||
typeAnnotation?: TypeAnnotation | null;
|
||||
computed: boolean;
|
||||
static: boolean;
|
||||
}
|
||||
|
||||
interface DeclareClass extends FlowDeclaration {
|
||||
id: Identifier;
|
||||
typeParameters?: TypeParameterDeclaration | null;
|
||||
body: ObjectTypeAnnotation;
|
||||
extends: InterfaceExtends[];
|
||||
}
|
||||
|
||||
interface DeclareFunction extends FlowDeclaration {
|
||||
id: Identifier;
|
||||
}
|
||||
|
||||
interface DeclareModule extends FlowDeclaration {
|
||||
id: Literal | Identifier;
|
||||
body: BlockStatement;
|
||||
}
|
||||
|
||||
interface DeclareVariable extends FlowDeclaration {
|
||||
id: Identifier;
|
||||
}
|
||||
|
||||
interface FunctionTypeAnnotation extends FlowTypeAnnotation {
|
||||
params: FunctionTypeParam[];
|
||||
returnType: FlowTypeAnnotation;
|
||||
rest?: FunctionTypeParam | null;
|
||||
typeParameters?: TypeParameterDeclaration | null;
|
||||
}
|
||||
|
||||
interface FunctionTypeParam {
|
||||
name: Identifier;
|
||||
typeAnnotation: FlowTypeAnnotation;
|
||||
optional: boolean;
|
||||
}
|
||||
|
||||
interface GenericTypeAnnotation extends FlowTypeAnnotation {
|
||||
id: Identifier | QualifiedTypeIdentifier;
|
||||
typeParameters?: TypeParameterInstantiation | null;
|
||||
}
|
||||
|
||||
interface InterfaceExtends extends Node {
|
||||
id: Identifier | QualifiedTypeIdentifier;
|
||||
typeParameters?: TypeParameterInstantiation | null;
|
||||
}
|
||||
|
||||
interface InterfaceDeclaration extends FlowDeclaration {
|
||||
id: Identifier;
|
||||
typeParameters?: TypeParameterDeclaration | null;
|
||||
extends: InterfaceExtends[];
|
||||
body: ObjectTypeAnnotation;
|
||||
}
|
||||
|
||||
interface IntersectionTypeAnnotation extends FlowTypeAnnotation {
|
||||
types: FlowTypeAnnotation[];
|
||||
}
|
||||
|
||||
interface MixedTypeAnnotation extends FlowBaseTypeAnnotation {}
|
||||
|
||||
interface NullableTypeAnnotation extends FlowTypeAnnotation {
|
||||
typeAnnotation: TypeAnnotation;
|
||||
}
|
||||
|
||||
interface NumberLiteralTypeAnnotation extends FlowLiteralTypeAnnotation {}
|
||||
|
||||
interface NumberTypeAnnotation extends FlowBaseTypeAnnotation {}
|
||||
|
||||
interface StringLiteralTypeAnnotation extends FlowLiteralTypeAnnotation {}
|
||||
|
||||
interface StringTypeAnnotation extends FlowBaseTypeAnnotation {}
|
||||
|
||||
interface TupleTypeAnnotation extends FlowTypeAnnotation {
|
||||
types: FlowTypeAnnotation[];
|
||||
}
|
||||
|
||||
interface TypeofTypeAnnotation extends FlowTypeAnnotation {
|
||||
argument: FlowTypeAnnotation;
|
||||
}
|
||||
|
||||
interface TypeAlias extends FlowDeclaration {
|
||||
id: Identifier;
|
||||
typeParameters?: TypeParameterDeclaration | null;
|
||||
right: FlowTypeAnnotation;
|
||||
}
|
||||
|
||||
interface TypeAnnotation extends Node {
|
||||
typeAnnotation: FlowTypeAnnotation;
|
||||
}
|
||||
|
||||
interface TypeCastExpression extends Expression {
|
||||
expression: Expression;
|
||||
typeAnnotation: TypeAnnotation;
|
||||
}
|
||||
|
||||
interface TypeParameterDeclaration extends Node {
|
||||
params: Identifier[];
|
||||
}
|
||||
|
||||
interface TypeParameterInstantiation extends Node {
|
||||
params: FlowTypeAnnotation[];
|
||||
}
|
||||
|
||||
interface ObjectTypeAnnotation extends FlowTypeAnnotation {
|
||||
properties: ObjectTypeProperty[];
|
||||
indexers: ObjectTypeIndexer[];
|
||||
callProperties: ObjectTypeCallProperty[];
|
||||
}
|
||||
|
||||
interface ObjectTypeCallProperty extends Node {
|
||||
value: FunctionTypeAnnotation;
|
||||
static: boolean;
|
||||
}
|
||||
|
||||
interface ObjectTypeIndexer extends Node {
|
||||
id: Identifier;
|
||||
key: FlowTypeAnnotation;
|
||||
value: FlowTypeAnnotation;
|
||||
static: boolean;
|
||||
}
|
||||
|
||||
interface ObjectTypeProperty extends Node {
|
||||
key: Expression;
|
||||
value: FlowTypeAnnotation;
|
||||
optional: boolean;
|
||||
static: boolean;
|
||||
}
|
||||
|
||||
interface QualifiedTypeIdentifier extends Node {
|
||||
qualification: Identifier | QualifiedTypeIdentifier;
|
||||
id: Identifier;
|
||||
}
|
||||
|
||||
interface UnionTypeAnnotation extends FlowTypeAnnotation {
|
||||
types: FlowTypeAnnotation[];
|
||||
}
|
||||
|
||||
interface VoidTypeAnnotation extends FlowBaseTypeAnnotation {}
|
||||
}
|
||||
+694
@@ -0,0 +1,694 @@
|
||||
// This definition file follows a somewhat unusual format. ESTree allows
|
||||
// runtime type checks based on the `type` parameter. In order to explain this
|
||||
// to typescript we want to use discriminated union types:
|
||||
// https://github.com/Microsoft/TypeScript/pull/9163
|
||||
//
|
||||
// For ESTree this is a bit tricky because the high level interfaces like
|
||||
// Node or Function are pulling double duty. We want to pass common fields down
|
||||
// to the interfaces that extend them (like Identifier or
|
||||
// ArrowFunctionExpression), but you can't extend a type union or enforce
|
||||
// common fields on them. So we've split the high level interfaces into two
|
||||
// types, a base type which passes down inherited fields, and a type union of
|
||||
// all types which extend the base type. Only the type union is exported, and
|
||||
// the union is how other types refer to the collection of inheriting types.
|
||||
//
|
||||
// This makes the definitions file here somewhat more difficult to maintain,
|
||||
// but it has the notable advantage of making ESTree much easier to use as
|
||||
// an end user.
|
||||
|
||||
export interface BaseNodeWithoutComments {
|
||||
// Every leaf interface that extends BaseNode must specify a type property.
|
||||
// The type property should be a string literal. For example, Identifier
|
||||
// has: `type: "Identifier"`
|
||||
type: string;
|
||||
loc?: SourceLocation | null | undefined;
|
||||
range?: [number, number] | undefined;
|
||||
}
|
||||
|
||||
export interface BaseNode extends BaseNodeWithoutComments {
|
||||
leadingComments?: Comment[] | undefined;
|
||||
trailingComments?: Comment[] | undefined;
|
||||
}
|
||||
|
||||
export interface NodeMap {
|
||||
AssignmentProperty: AssignmentProperty;
|
||||
CatchClause: CatchClause;
|
||||
Class: Class;
|
||||
ClassBody: ClassBody;
|
||||
Expression: Expression;
|
||||
Function: Function;
|
||||
Identifier: Identifier;
|
||||
Literal: Literal;
|
||||
MethodDefinition: MethodDefinition;
|
||||
ModuleDeclaration: ModuleDeclaration;
|
||||
ModuleSpecifier: ModuleSpecifier;
|
||||
Pattern: Pattern;
|
||||
PrivateIdentifier: PrivateIdentifier;
|
||||
Program: Program;
|
||||
Property: Property;
|
||||
PropertyDefinition: PropertyDefinition;
|
||||
SpreadElement: SpreadElement;
|
||||
Statement: Statement;
|
||||
Super: Super;
|
||||
SwitchCase: SwitchCase;
|
||||
TemplateElement: TemplateElement;
|
||||
VariableDeclarator: VariableDeclarator;
|
||||
}
|
||||
|
||||
export type Node = NodeMap[keyof NodeMap];
|
||||
|
||||
export interface Comment extends BaseNodeWithoutComments {
|
||||
type: "Line" | "Block";
|
||||
value: string;
|
||||
}
|
||||
|
||||
export interface SourceLocation {
|
||||
source?: string | null | undefined;
|
||||
start: Position;
|
||||
end: Position;
|
||||
}
|
||||
|
||||
export interface Position {
|
||||
/** >= 1 */
|
||||
line: number;
|
||||
/** >= 0 */
|
||||
column: number;
|
||||
}
|
||||
|
||||
export interface Program extends BaseNode {
|
||||
type: "Program";
|
||||
sourceType: "script" | "module";
|
||||
body: Array<Directive | Statement | ModuleDeclaration>;
|
||||
comments?: Comment[] | undefined;
|
||||
}
|
||||
|
||||
export interface Directive extends BaseNode {
|
||||
type: "ExpressionStatement";
|
||||
expression: Literal;
|
||||
directive: string;
|
||||
}
|
||||
|
||||
export interface BaseFunction extends BaseNode {
|
||||
params: Pattern[];
|
||||
generator?: boolean | undefined;
|
||||
async?: boolean | undefined;
|
||||
// The body is either BlockStatement or Expression because arrow functions
|
||||
// can have a body that's either. FunctionDeclarations and
|
||||
// FunctionExpressions have only BlockStatement bodies.
|
||||
body: BlockStatement | Expression;
|
||||
}
|
||||
|
||||
export type Function = FunctionDeclaration | FunctionExpression | ArrowFunctionExpression;
|
||||
|
||||
export type Statement =
|
||||
| ExpressionStatement
|
||||
| BlockStatement
|
||||
| StaticBlock
|
||||
| EmptyStatement
|
||||
| DebuggerStatement
|
||||
| WithStatement
|
||||
| ReturnStatement
|
||||
| LabeledStatement
|
||||
| BreakStatement
|
||||
| ContinueStatement
|
||||
| IfStatement
|
||||
| SwitchStatement
|
||||
| ThrowStatement
|
||||
| TryStatement
|
||||
| WhileStatement
|
||||
| DoWhileStatement
|
||||
| ForStatement
|
||||
| ForInStatement
|
||||
| ForOfStatement
|
||||
| Declaration;
|
||||
|
||||
export interface BaseStatement extends BaseNode {}
|
||||
|
||||
export interface EmptyStatement extends BaseStatement {
|
||||
type: "EmptyStatement";
|
||||
}
|
||||
|
||||
export interface BlockStatement extends BaseStatement {
|
||||
type: "BlockStatement";
|
||||
body: Statement[];
|
||||
innerComments?: Comment[] | undefined;
|
||||
}
|
||||
|
||||
export interface StaticBlock extends Omit<BlockStatement, "type"> {
|
||||
type: "StaticBlock";
|
||||
}
|
||||
|
||||
export interface ExpressionStatement extends BaseStatement {
|
||||
type: "ExpressionStatement";
|
||||
expression: Expression;
|
||||
}
|
||||
|
||||
export interface IfStatement extends BaseStatement {
|
||||
type: "IfStatement";
|
||||
test: Expression;
|
||||
consequent: Statement;
|
||||
alternate?: Statement | null | undefined;
|
||||
}
|
||||
|
||||
export interface LabeledStatement extends BaseStatement {
|
||||
type: "LabeledStatement";
|
||||
label: Identifier;
|
||||
body: Statement;
|
||||
}
|
||||
|
||||
export interface BreakStatement extends BaseStatement {
|
||||
type: "BreakStatement";
|
||||
label?: Identifier | null | undefined;
|
||||
}
|
||||
|
||||
export interface ContinueStatement extends BaseStatement {
|
||||
type: "ContinueStatement";
|
||||
label?: Identifier | null | undefined;
|
||||
}
|
||||
|
||||
export interface WithStatement extends BaseStatement {
|
||||
type: "WithStatement";
|
||||
object: Expression;
|
||||
body: Statement;
|
||||
}
|
||||
|
||||
export interface SwitchStatement extends BaseStatement {
|
||||
type: "SwitchStatement";
|
||||
discriminant: Expression;
|
||||
cases: SwitchCase[];
|
||||
}
|
||||
|
||||
export interface ReturnStatement extends BaseStatement {
|
||||
type: "ReturnStatement";
|
||||
argument?: Expression | null | undefined;
|
||||
}
|
||||
|
||||
export interface ThrowStatement extends BaseStatement {
|
||||
type: "ThrowStatement";
|
||||
argument: Expression;
|
||||
}
|
||||
|
||||
export interface TryStatement extends BaseStatement {
|
||||
type: "TryStatement";
|
||||
block: BlockStatement;
|
||||
handler?: CatchClause | null | undefined;
|
||||
finalizer?: BlockStatement | null | undefined;
|
||||
}
|
||||
|
||||
export interface WhileStatement extends BaseStatement {
|
||||
type: "WhileStatement";
|
||||
test: Expression;
|
||||
body: Statement;
|
||||
}
|
||||
|
||||
export interface DoWhileStatement extends BaseStatement {
|
||||
type: "DoWhileStatement";
|
||||
body: Statement;
|
||||
test: Expression;
|
||||
}
|
||||
|
||||
export interface ForStatement extends BaseStatement {
|
||||
type: "ForStatement";
|
||||
init?: VariableDeclaration | Expression | null | undefined;
|
||||
test?: Expression | null | undefined;
|
||||
update?: Expression | null | undefined;
|
||||
body: Statement;
|
||||
}
|
||||
|
||||
export interface BaseForXStatement extends BaseStatement {
|
||||
left: VariableDeclaration | Pattern;
|
||||
right: Expression;
|
||||
body: Statement;
|
||||
}
|
||||
|
||||
export interface ForInStatement extends BaseForXStatement {
|
||||
type: "ForInStatement";
|
||||
}
|
||||
|
||||
export interface DebuggerStatement extends BaseStatement {
|
||||
type: "DebuggerStatement";
|
||||
}
|
||||
|
||||
export type Declaration = FunctionDeclaration | VariableDeclaration | ClassDeclaration;
|
||||
|
||||
export interface BaseDeclaration extends BaseStatement {}
|
||||
|
||||
export interface MaybeNamedFunctionDeclaration extends BaseFunction, BaseDeclaration {
|
||||
type: "FunctionDeclaration";
|
||||
/** It is null when a function declaration is a part of the `export default function` statement */
|
||||
id: Identifier | null;
|
||||
body: BlockStatement;
|
||||
}
|
||||
|
||||
export interface FunctionDeclaration extends MaybeNamedFunctionDeclaration {
|
||||
id: Identifier;
|
||||
}
|
||||
|
||||
export interface VariableDeclaration extends BaseDeclaration {
|
||||
type: "VariableDeclaration";
|
||||
declarations: VariableDeclarator[];
|
||||
kind: "var" | "let" | "const" | "using" | "await using";
|
||||
}
|
||||
|
||||
export interface VariableDeclarator extends BaseNode {
|
||||
type: "VariableDeclarator";
|
||||
id: Pattern;
|
||||
init?: Expression | null | undefined;
|
||||
}
|
||||
|
||||
export interface ExpressionMap {
|
||||
ArrayExpression: ArrayExpression;
|
||||
ArrowFunctionExpression: ArrowFunctionExpression;
|
||||
AssignmentExpression: AssignmentExpression;
|
||||
AwaitExpression: AwaitExpression;
|
||||
BinaryExpression: BinaryExpression;
|
||||
CallExpression: CallExpression;
|
||||
ChainExpression: ChainExpression;
|
||||
ClassExpression: ClassExpression;
|
||||
ConditionalExpression: ConditionalExpression;
|
||||
FunctionExpression: FunctionExpression;
|
||||
Identifier: Identifier;
|
||||
ImportExpression: ImportExpression;
|
||||
Literal: Literal;
|
||||
LogicalExpression: LogicalExpression;
|
||||
MemberExpression: MemberExpression;
|
||||
MetaProperty: MetaProperty;
|
||||
NewExpression: NewExpression;
|
||||
ObjectExpression: ObjectExpression;
|
||||
SequenceExpression: SequenceExpression;
|
||||
TaggedTemplateExpression: TaggedTemplateExpression;
|
||||
TemplateLiteral: TemplateLiteral;
|
||||
ThisExpression: ThisExpression;
|
||||
UnaryExpression: UnaryExpression;
|
||||
UpdateExpression: UpdateExpression;
|
||||
YieldExpression: YieldExpression;
|
||||
}
|
||||
|
||||
export type Expression = ExpressionMap[keyof ExpressionMap];
|
||||
|
||||
export interface BaseExpression extends BaseNode {}
|
||||
|
||||
export type ChainElement = SimpleCallExpression | MemberExpression;
|
||||
|
||||
export interface ChainExpression extends BaseExpression {
|
||||
type: "ChainExpression";
|
||||
expression: ChainElement;
|
||||
}
|
||||
|
||||
export interface ThisExpression extends BaseExpression {
|
||||
type: "ThisExpression";
|
||||
}
|
||||
|
||||
export interface ArrayExpression extends BaseExpression {
|
||||
type: "ArrayExpression";
|
||||
elements: Array<Expression | SpreadElement | null>;
|
||||
}
|
||||
|
||||
export interface ObjectExpression extends BaseExpression {
|
||||
type: "ObjectExpression";
|
||||
properties: Array<Property | SpreadElement>;
|
||||
}
|
||||
|
||||
export interface PrivateIdentifier extends BaseNode {
|
||||
type: "PrivateIdentifier";
|
||||
name: string;
|
||||
}
|
||||
|
||||
export interface Property extends BaseNode {
|
||||
type: "Property";
|
||||
key: Expression;
|
||||
value: Expression | Pattern; // Could be an AssignmentProperty
|
||||
kind: "init" | "get" | "set";
|
||||
method: boolean;
|
||||
shorthand: boolean;
|
||||
computed: boolean;
|
||||
}
|
||||
|
||||
export interface PropertyDefinition extends BaseNode {
|
||||
type: "PropertyDefinition";
|
||||
key: Expression | PrivateIdentifier;
|
||||
value?: Expression | null | undefined;
|
||||
computed: boolean;
|
||||
static: boolean;
|
||||
}
|
||||
|
||||
export interface FunctionExpression extends BaseFunction, BaseExpression {
|
||||
id?: Identifier | null | undefined;
|
||||
type: "FunctionExpression";
|
||||
body: BlockStatement;
|
||||
}
|
||||
|
||||
export interface SequenceExpression extends BaseExpression {
|
||||
type: "SequenceExpression";
|
||||
expressions: Expression[];
|
||||
}
|
||||
|
||||
export interface UnaryExpression extends BaseExpression {
|
||||
type: "UnaryExpression";
|
||||
operator: UnaryOperator;
|
||||
prefix: true;
|
||||
argument: Expression;
|
||||
}
|
||||
|
||||
export interface BinaryExpression extends BaseExpression {
|
||||
type: "BinaryExpression";
|
||||
operator: BinaryOperator;
|
||||
left: Expression | PrivateIdentifier;
|
||||
right: Expression;
|
||||
}
|
||||
|
||||
export interface AssignmentExpression extends BaseExpression {
|
||||
type: "AssignmentExpression";
|
||||
operator: AssignmentOperator;
|
||||
left: Pattern | MemberExpression;
|
||||
right: Expression;
|
||||
}
|
||||
|
||||
export interface UpdateExpression extends BaseExpression {
|
||||
type: "UpdateExpression";
|
||||
operator: UpdateOperator;
|
||||
argument: Expression;
|
||||
prefix: boolean;
|
||||
}
|
||||
|
||||
export interface LogicalExpression extends BaseExpression {
|
||||
type: "LogicalExpression";
|
||||
operator: LogicalOperator;
|
||||
left: Expression;
|
||||
right: Expression;
|
||||
}
|
||||
|
||||
export interface ConditionalExpression extends BaseExpression {
|
||||
type: "ConditionalExpression";
|
||||
test: Expression;
|
||||
alternate: Expression;
|
||||
consequent: Expression;
|
||||
}
|
||||
|
||||
export interface BaseCallExpression extends BaseExpression {
|
||||
callee: Expression | Super;
|
||||
arguments: Array<Expression | SpreadElement>;
|
||||
}
|
||||
export type CallExpression = SimpleCallExpression | NewExpression;
|
||||
|
||||
export interface SimpleCallExpression extends BaseCallExpression {
|
||||
type: "CallExpression";
|
||||
optional: boolean;
|
||||
}
|
||||
|
||||
export interface NewExpression extends BaseCallExpression {
|
||||
type: "NewExpression";
|
||||
}
|
||||
|
||||
export interface MemberExpression extends BaseExpression, BasePattern {
|
||||
type: "MemberExpression";
|
||||
object: Expression | Super;
|
||||
property: Expression | PrivateIdentifier;
|
||||
computed: boolean;
|
||||
optional: boolean;
|
||||
}
|
||||
|
||||
export type Pattern = Identifier | ObjectPattern | ArrayPattern | RestElement | AssignmentPattern | MemberExpression;
|
||||
|
||||
export interface BasePattern extends BaseNode {}
|
||||
|
||||
export interface SwitchCase extends BaseNode {
|
||||
type: "SwitchCase";
|
||||
test?: Expression | null | undefined;
|
||||
consequent: Statement[];
|
||||
}
|
||||
|
||||
export interface CatchClause extends BaseNode {
|
||||
type: "CatchClause";
|
||||
param: Pattern | null;
|
||||
body: BlockStatement;
|
||||
}
|
||||
|
||||
export interface Identifier extends BaseNode, BaseExpression, BasePattern {
|
||||
type: "Identifier";
|
||||
name: string;
|
||||
}
|
||||
|
||||
export type Literal = SimpleLiteral | RegExpLiteral | BigIntLiteral;
|
||||
|
||||
export interface SimpleLiteral extends BaseNode, BaseExpression {
|
||||
type: "Literal";
|
||||
value: string | boolean | number | null;
|
||||
raw?: string | undefined;
|
||||
}
|
||||
|
||||
export interface RegExpLiteral extends BaseNode, BaseExpression {
|
||||
type: "Literal";
|
||||
value?: RegExp | null | undefined;
|
||||
regex: {
|
||||
pattern: string;
|
||||
flags: string;
|
||||
};
|
||||
raw?: string | undefined;
|
||||
}
|
||||
|
||||
export interface BigIntLiteral extends BaseNode, BaseExpression {
|
||||
type: "Literal";
|
||||
value?: bigint | null | undefined;
|
||||
bigint: string;
|
||||
raw?: string | undefined;
|
||||
}
|
||||
|
||||
export type UnaryOperator = "-" | "+" | "!" | "~" | "typeof" | "void" | "delete";
|
||||
|
||||
export type BinaryOperator =
|
||||
| "=="
|
||||
| "!="
|
||||
| "==="
|
||||
| "!=="
|
||||
| "<"
|
||||
| "<="
|
||||
| ">"
|
||||
| ">="
|
||||
| "<<"
|
||||
| ">>"
|
||||
| ">>>"
|
||||
| "+"
|
||||
| "-"
|
||||
| "*"
|
||||
| "/"
|
||||
| "%"
|
||||
| "**"
|
||||
| "|"
|
||||
| "^"
|
||||
| "&"
|
||||
| "in"
|
||||
| "instanceof";
|
||||
|
||||
export type LogicalOperator = "||" | "&&" | "??";
|
||||
|
||||
export type AssignmentOperator =
|
||||
| "="
|
||||
| "+="
|
||||
| "-="
|
||||
| "*="
|
||||
| "/="
|
||||
| "%="
|
||||
| "**="
|
||||
| "<<="
|
||||
| ">>="
|
||||
| ">>>="
|
||||
| "|="
|
||||
| "^="
|
||||
| "&="
|
||||
| "||="
|
||||
| "&&="
|
||||
| "??=";
|
||||
|
||||
export type UpdateOperator = "++" | "--";
|
||||
|
||||
export interface ForOfStatement extends BaseForXStatement {
|
||||
type: "ForOfStatement";
|
||||
await: boolean;
|
||||
}
|
||||
|
||||
export interface Super extends BaseNode {
|
||||
type: "Super";
|
||||
}
|
||||
|
||||
export interface SpreadElement extends BaseNode {
|
||||
type: "SpreadElement";
|
||||
argument: Expression;
|
||||
}
|
||||
|
||||
export interface ArrowFunctionExpression extends BaseExpression, BaseFunction {
|
||||
type: "ArrowFunctionExpression";
|
||||
expression: boolean;
|
||||
body: BlockStatement | Expression;
|
||||
}
|
||||
|
||||
export interface YieldExpression extends BaseExpression {
|
||||
type: "YieldExpression";
|
||||
argument?: Expression | null | undefined;
|
||||
delegate: boolean;
|
||||
}
|
||||
|
||||
export interface TemplateLiteral extends BaseExpression {
|
||||
type: "TemplateLiteral";
|
||||
quasis: TemplateElement[];
|
||||
expressions: Expression[];
|
||||
}
|
||||
|
||||
export interface TaggedTemplateExpression extends BaseExpression {
|
||||
type: "TaggedTemplateExpression";
|
||||
tag: Expression;
|
||||
quasi: TemplateLiteral;
|
||||
}
|
||||
|
||||
export interface TemplateElement extends BaseNode {
|
||||
type: "TemplateElement";
|
||||
tail: boolean;
|
||||
value: {
|
||||
/** It is null when the template literal is tagged and the text has an invalid escape (e.g. - tag`\unicode and \u{55}`) */
|
||||
cooked?: string | null | undefined;
|
||||
raw: string;
|
||||
};
|
||||
}
|
||||
|
||||
export interface AssignmentProperty extends Property {
|
||||
value: Pattern;
|
||||
kind: "init";
|
||||
method: boolean; // false
|
||||
}
|
||||
|
||||
export interface ObjectPattern extends BasePattern {
|
||||
type: "ObjectPattern";
|
||||
properties: Array<AssignmentProperty | RestElement>;
|
||||
}
|
||||
|
||||
export interface ArrayPattern extends BasePattern {
|
||||
type: "ArrayPattern";
|
||||
elements: Array<Pattern | null>;
|
||||
}
|
||||
|
||||
export interface RestElement extends BasePattern {
|
||||
type: "RestElement";
|
||||
argument: Pattern;
|
||||
}
|
||||
|
||||
export interface AssignmentPattern extends BasePattern {
|
||||
type: "AssignmentPattern";
|
||||
left: Pattern;
|
||||
right: Expression;
|
||||
}
|
||||
|
||||
export type Class = ClassDeclaration | ClassExpression;
|
||||
export interface BaseClass extends BaseNode {
|
||||
superClass?: Expression | null | undefined;
|
||||
body: ClassBody;
|
||||
}
|
||||
|
||||
export interface ClassBody extends BaseNode {
|
||||
type: "ClassBody";
|
||||
body: Array<MethodDefinition | PropertyDefinition | StaticBlock>;
|
||||
}
|
||||
|
||||
export interface MethodDefinition extends BaseNode {
|
||||
type: "MethodDefinition";
|
||||
key: Expression | PrivateIdentifier;
|
||||
value: FunctionExpression;
|
||||
kind: "constructor" | "method" | "get" | "set";
|
||||
computed: boolean;
|
||||
static: boolean;
|
||||
}
|
||||
|
||||
export interface MaybeNamedClassDeclaration extends BaseClass, BaseDeclaration {
|
||||
type: "ClassDeclaration";
|
||||
/** It is null when a class declaration is a part of the `export default class` statement */
|
||||
id: Identifier | null;
|
||||
}
|
||||
|
||||
export interface ClassDeclaration extends MaybeNamedClassDeclaration {
|
||||
id: Identifier;
|
||||
}
|
||||
|
||||
export interface ClassExpression extends BaseClass, BaseExpression {
|
||||
type: "ClassExpression";
|
||||
id?: Identifier | null | undefined;
|
||||
}
|
||||
|
||||
export interface MetaProperty extends BaseExpression {
|
||||
type: "MetaProperty";
|
||||
meta: Identifier;
|
||||
property: Identifier;
|
||||
}
|
||||
|
||||
export type ModuleDeclaration =
|
||||
| ImportDeclaration
|
||||
| ExportNamedDeclaration
|
||||
| ExportDefaultDeclaration
|
||||
| ExportAllDeclaration;
|
||||
export interface BaseModuleDeclaration extends BaseNode {}
|
||||
|
||||
export type ModuleSpecifier = ImportSpecifier | ImportDefaultSpecifier | ImportNamespaceSpecifier | ExportSpecifier;
|
||||
export interface BaseModuleSpecifier extends BaseNode {
|
||||
local: Identifier;
|
||||
}
|
||||
|
||||
export interface ImportDeclaration extends BaseModuleDeclaration {
|
||||
type: "ImportDeclaration";
|
||||
specifiers: Array<ImportSpecifier | ImportDefaultSpecifier | ImportNamespaceSpecifier>;
|
||||
attributes: ImportAttribute[];
|
||||
source: Literal;
|
||||
}
|
||||
|
||||
export interface ImportSpecifier extends BaseModuleSpecifier {
|
||||
type: "ImportSpecifier";
|
||||
imported: Identifier | Literal;
|
||||
}
|
||||
|
||||
export interface ImportAttribute extends BaseNode {
|
||||
type: "ImportAttribute";
|
||||
key: Identifier | Literal;
|
||||
value: Literal;
|
||||
}
|
||||
|
||||
export interface ImportExpression extends BaseExpression {
|
||||
type: "ImportExpression";
|
||||
source: Expression;
|
||||
options?: Expression | null | undefined;
|
||||
}
|
||||
|
||||
export interface ImportDefaultSpecifier extends BaseModuleSpecifier {
|
||||
type: "ImportDefaultSpecifier";
|
||||
}
|
||||
|
||||
export interface ImportNamespaceSpecifier extends BaseModuleSpecifier {
|
||||
type: "ImportNamespaceSpecifier";
|
||||
}
|
||||
|
||||
export interface ExportNamedDeclaration extends BaseModuleDeclaration {
|
||||
type: "ExportNamedDeclaration";
|
||||
declaration?: Declaration | null | undefined;
|
||||
specifiers: ExportSpecifier[];
|
||||
attributes: ImportAttribute[];
|
||||
source?: Literal | null | undefined;
|
||||
}
|
||||
|
||||
export interface ExportSpecifier extends Omit<BaseModuleSpecifier, "local"> {
|
||||
type: "ExportSpecifier";
|
||||
local: Identifier | Literal;
|
||||
exported: Identifier | Literal;
|
||||
}
|
||||
|
||||
export interface ExportDefaultDeclaration extends BaseModuleDeclaration {
|
||||
type: "ExportDefaultDeclaration";
|
||||
declaration: MaybeNamedFunctionDeclaration | MaybeNamedClassDeclaration | Expression;
|
||||
}
|
||||
|
||||
export interface ExportAllDeclaration extends BaseModuleDeclaration {
|
||||
type: "ExportAllDeclaration";
|
||||
exported: Identifier | Literal | null;
|
||||
attributes: ImportAttribute[];
|
||||
source: Literal;
|
||||
}
|
||||
|
||||
export interface AwaitExpression extends BaseExpression {
|
||||
type: "AwaitExpression";
|
||||
argument: Expression;
|
||||
}
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
{
|
||||
"name": "@types/estree",
|
||||
"version": "1.0.9",
|
||||
"description": "TypeScript definitions for estree",
|
||||
"homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/estree",
|
||||
"license": "MIT",
|
||||
"contributors": [
|
||||
{
|
||||
"name": "RReverser",
|
||||
"githubUsername": "RReverser",
|
||||
"url": "https://github.com/RReverser"
|
||||
}
|
||||
],
|
||||
"main": "",
|
||||
"types": "index.d.ts",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/DefinitelyTyped/DefinitelyTyped.git",
|
||||
"directory": "types/estree"
|
||||
},
|
||||
"scripts": {},
|
||||
"dependencies": {},
|
||||
"peerDependencies": {},
|
||||
"typesPublisherContentHash": "db16da859cb0bee641414117047a4becba2e9f39d3e14a6745f887c47ef68482",
|
||||
"typeScriptVersion": "5.3",
|
||||
"nonNpm": true
|
||||
}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2021-Present Vitest Team
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
# @vitest/expect
|
||||
|
||||
Jest's expect matchers as a Chai plugin.
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
import {
|
||||
JestAsymmetricMatchers,
|
||||
JestChaiExpect,
|
||||
JestExtend,
|
||||
} from '@vitest/expect'
|
||||
import * as chai from 'chai'
|
||||
|
||||
// allows using expect.extend instead of chai.use to extend plugins
|
||||
chai.use(JestExtend)
|
||||
// adds all jest matchers to expect
|
||||
chai.use(JestChaiExpect)
|
||||
// adds asymmetric matchers like stringContaining, objectContaining
|
||||
chai.use(JestAsymmetricMatchers)
|
||||
```
|
||||
+1968
File diff suppressed because it is too large.
Load diff
+705
@@ -0,0 +1,705 @@
|
||||
import { stringify, Constructable } from '@vitest/utils';
|
||||
import * as tinyrainbow from 'tinyrainbow';
|
||||
import { Formatter } from 'tinyrainbow';
|
||||
import { diff, printDiffOrStringify } from '@vitest/utils/diff';
|
||||
export { DiffOptions } from '@vitest/utils/diff';
|
||||
|
||||
declare const MATCHERS_OBJECT: unique symbol;
|
||||
declare const JEST_MATCHERS_OBJECT: unique symbol;
|
||||
declare const GLOBAL_EXPECT: unique symbol;
|
||||
declare const ASYMMETRIC_MATCHERS_OBJECT: unique symbol;
|
||||
|
||||
declare function matcherHint(matcherName: string, received?: string, expected?: string, options?: MatcherHintOptions): string;
|
||||
declare function printReceived(object: unknown): string;
|
||||
declare function printExpected(value: unknown): string;
|
||||
declare function getMatcherUtils(): {
|
||||
EXPECTED_COLOR: tinyrainbow.Formatter;
|
||||
RECEIVED_COLOR: tinyrainbow.Formatter;
|
||||
INVERTED_COLOR: tinyrainbow.Formatter;
|
||||
BOLD_WEIGHT: tinyrainbow.Formatter;
|
||||
DIM_COLOR: tinyrainbow.Formatter;
|
||||
diff: typeof diff;
|
||||
matcherHint: typeof matcherHint;
|
||||
printReceived: typeof printReceived;
|
||||
printExpected: typeof printExpected;
|
||||
printDiffOrStringify: typeof printDiffOrStringify;
|
||||
};
|
||||
declare function addCustomEqualityTesters(newTesters: Array<Tester>): void;
|
||||
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
*/
|
||||
|
||||
type ChaiPlugin = Chai.ChaiPlugin;
|
||||
type Tester = (this: TesterContext, a: any, b: any, customTesters: Array<Tester>) => boolean | undefined;
|
||||
interface TesterContext {
|
||||
equals: (a: unknown, b: unknown, customTesters?: Array<Tester>, strictCheck?: boolean) => boolean;
|
||||
}
|
||||
|
||||
interface MatcherHintOptions {
|
||||
comment?: string;
|
||||
expectedColor?: Formatter;
|
||||
isDirectExpectCall?: boolean;
|
||||
isNot?: boolean;
|
||||
promise?: string;
|
||||
receivedColor?: Formatter;
|
||||
secondArgument?: string;
|
||||
secondArgumentColor?: Formatter;
|
||||
}
|
||||
interface MatcherState {
|
||||
customTesters: Array<Tester>;
|
||||
assertionCalls: number;
|
||||
currentTestName?: string;
|
||||
dontThrow?: () => void;
|
||||
error?: Error;
|
||||
equals: (a: unknown, b: unknown, customTesters?: Array<Tester>, strictCheck?: boolean) => boolean;
|
||||
expand?: boolean;
|
||||
expectedAssertionsNumber?: number | null;
|
||||
expectedAssertionsNumberErrorGen?: (() => Error) | null;
|
||||
isExpectingAssertions?: boolean;
|
||||
isExpectingAssertionsError?: Error | null;
|
||||
isNot: boolean;
|
||||
promise: string;
|
||||
suppressedErrors: Array<Error>;
|
||||
testPath?: string;
|
||||
utils: ReturnType<typeof getMatcherUtils> & {
|
||||
diff: typeof diff;
|
||||
stringify: typeof stringify;
|
||||
iterableEquality: Tester;
|
||||
subsetEquality: Tester;
|
||||
};
|
||||
soft?: boolean;
|
||||
poll?: boolean;
|
||||
}
|
||||
interface SyncExpectationResult {
|
||||
pass: boolean;
|
||||
message: () => string;
|
||||
actual?: any;
|
||||
expected?: any;
|
||||
}
|
||||
type AsyncExpectationResult = Promise<SyncExpectationResult>;
|
||||
type ExpectationResult = SyncExpectationResult | AsyncExpectationResult;
|
||||
interface RawMatcherFn<T extends MatcherState = MatcherState> {
|
||||
(this: T, received: any, ...expected: Array<any>): ExpectationResult;
|
||||
}
|
||||
type MatchersObject<T extends MatcherState = MatcherState> = Record<string, RawMatcherFn<T>>;
|
||||
interface ExpectStatic extends Chai.ExpectStatic, AsymmetricMatchersContaining {
|
||||
<T>(actual: T, message?: string): Assertion<T>;
|
||||
extend: (expects: MatchersObject) => void;
|
||||
anything: () => any;
|
||||
any: (constructor: unknown) => any;
|
||||
getState: () => MatcherState;
|
||||
setState: (state: Partial<MatcherState>) => void;
|
||||
not: AsymmetricMatchersContaining;
|
||||
}
|
||||
interface AsymmetricMatchersContaining {
|
||||
/**
|
||||
* Matches if the received string contains the expected substring.
|
||||
*
|
||||
* @example
|
||||
* expect('I have an apple').toEqual(expect.stringContaining('apple'));
|
||||
* expect({ a: 'test string' }).toEqual({ a: expect.stringContaining('test') });
|
||||
*/
|
||||
stringContaining: (expected: string) => any;
|
||||
/**
|
||||
* Matches if the received object contains all properties of the expected object.
|
||||
*
|
||||
* @example
|
||||
* expect({ a: '1', b: 2 }).toEqual(expect.objectContaining({ a: '1' }))
|
||||
*/
|
||||
objectContaining: <T = any>(expected: T) => any;
|
||||
/**
|
||||
* Matches if the received array contains all elements in the expected array.
|
||||
*
|
||||
* @example
|
||||
* expect(['a', 'b', 'c']).toEqual(expect.arrayContaining(['b', 'a']));
|
||||
*/
|
||||
arrayContaining: <T = unknown>(expected: Array<T>) => any;
|
||||
/**
|
||||
* Matches if the received string or regex matches the expected pattern.
|
||||
*
|
||||
* @example
|
||||
* expect('hello world').toEqual(expect.stringMatching(/^hello/));
|
||||
* expect('hello world').toEqual(expect.stringMatching('hello'));
|
||||
*/
|
||||
stringMatching: (expected: string | RegExp) => any;
|
||||
/**
|
||||
* Matches if the received number is within a certain precision of the expected number.
|
||||
*
|
||||
* @param precision - Optional decimal precision for comparison. Default is 2.
|
||||
*
|
||||
* @example
|
||||
* expect(10.45).toEqual(expect.closeTo(10.5, 1));
|
||||
* expect(5.11).toEqual(expect.closeTo(5.12)); // with default precision
|
||||
*/
|
||||
closeTo: (expected: number, precision?: number) => any;
|
||||
}
|
||||
interface JestAssertion<T = any> extends jest.Matchers<void, T> {
|
||||
/**
|
||||
* Used when you want to check that two objects have the same value.
|
||||
* This matcher recursively checks the equality of all fields, rather than checking for object identity.
|
||||
*
|
||||
* @example
|
||||
* expect(user).toEqual({ name: 'Alice', age: 30 });
|
||||
*/
|
||||
toEqual: <E>(expected: E) => void;
|
||||
/**
|
||||
* Use to test that objects have the same types as well as structure.
|
||||
*
|
||||
* @example
|
||||
* expect(user).toStrictEqual({ name: 'Alice', age: 30 });
|
||||
*/
|
||||
toStrictEqual: <E>(expected: E) => void;
|
||||
/**
|
||||
* Checks that a value is what you expect. It calls `Object.is` to compare values.
|
||||
* Don't use `toBe` with floating-point numbers.
|
||||
*
|
||||
* @example
|
||||
* expect(result).toBe(42);
|
||||
* expect(status).toBe(true);
|
||||
*/
|
||||
toBe: <E>(expected: E) => void;
|
||||
/**
|
||||
* Check that a string matches a regular expression.
|
||||
*
|
||||
* @example
|
||||
* expect(message).toMatch(/hello/);
|
||||
* expect(greeting).toMatch('world');
|
||||
*/
|
||||
toMatch: (expected: string | RegExp) => void;
|
||||
/**
|
||||
* Used to check that a JavaScript object matches a subset of the properties of an object
|
||||
*
|
||||
* @example
|
||||
* expect(user).toMatchObject({
|
||||
* name: 'Alice',
|
||||
* address: { city: 'Wonderland' }
|
||||
* });
|
||||
*/
|
||||
toMatchObject: <E extends object | any[]>(expected: E) => void;
|
||||
/**
|
||||
* Used when you want to check that an item is in a list.
|
||||
* For testing the items in the list, this uses `===`, a strict equality check.
|
||||
*
|
||||
* @example
|
||||
* expect(items).toContain('apple');
|
||||
* expect(numbers).toContain(5);
|
||||
*/
|
||||
toContain: <E>(item: E) => void;
|
||||
/**
|
||||
* Used when you want to check that an item is in a list.
|
||||
* For testing the items in the list, this matcher recursively checks the
|
||||
* equality of all fields, rather than checking for object identity.
|
||||
*
|
||||
* @example
|
||||
* expect(items).toContainEqual({ name: 'apple', quantity: 1 });
|
||||
*/
|
||||
toContainEqual: <E>(item: E) => void;
|
||||
/**
|
||||
* Use when you don't care what a value is, you just want to ensure a value
|
||||
* is true in a boolean context. In JavaScript, there are six falsy values:
|
||||
* `false`, `0`, `''`, `null`, `undefined`, and `NaN`. Everything else is truthy.
|
||||
*
|
||||
* @example
|
||||
* expect(user.isActive).toBeTruthy();
|
||||
*/
|
||||
toBeTruthy: () => void;
|
||||
/**
|
||||
* When you don't care what a value is, you just want to
|
||||
* ensure a value is false in a boolean context.
|
||||
*
|
||||
* @example
|
||||
* expect(user.isActive).toBeFalsy();
|
||||
*/
|
||||
toBeFalsy: () => void;
|
||||
/**
|
||||
* For comparing floating point numbers.
|
||||
*
|
||||
* @example
|
||||
* expect(score).toBeGreaterThan(10);
|
||||
*/
|
||||
toBeGreaterThan: (num: number | bigint) => void;
|
||||
/**
|
||||
* For comparing floating point numbers.
|
||||
*
|
||||
* @example
|
||||
* expect(score).toBeGreaterThanOrEqual(10);
|
||||
*/
|
||||
toBeGreaterThanOrEqual: (num: number | bigint) => void;
|
||||
/**
|
||||
* For comparing floating point numbers.
|
||||
*
|
||||
* @example
|
||||
* expect(score).toBeLessThan(10);
|
||||
*/
|
||||
toBeLessThan: (num: number | bigint) => void;
|
||||
/**
|
||||
* For comparing floating point numbers.
|
||||
*
|
||||
* @example
|
||||
* expect(score).toBeLessThanOrEqual(10);
|
||||
*/
|
||||
toBeLessThanOrEqual: (num: number | bigint) => void;
|
||||
/**
|
||||
* Used to check that a variable is NaN.
|
||||
*
|
||||
* @example
|
||||
* expect(value).toBeNaN();
|
||||
*/
|
||||
toBeNaN: () => void;
|
||||
/**
|
||||
* Used to check that a variable is undefined.
|
||||
*
|
||||
* @example
|
||||
* expect(value).toBeUndefined();
|
||||
*/
|
||||
toBeUndefined: () => void;
|
||||
/**
|
||||
* This is the same as `.toBe(null)` but the error messages are a bit nicer.
|
||||
* So use `.toBeNull()` when you want to check that something is null.
|
||||
*
|
||||
* @example
|
||||
* expect(value).toBeNull();
|
||||
*/
|
||||
toBeNull: () => void;
|
||||
/**
|
||||
* Ensure that a variable is not undefined.
|
||||
*
|
||||
* @example
|
||||
* expect(value).toBeDefined();
|
||||
*/
|
||||
toBeDefined: () => void;
|
||||
/**
|
||||
* Ensure that an object is an instance of a class.
|
||||
* This matcher uses `instanceof` underneath.
|
||||
*
|
||||
* @example
|
||||
* expect(new Date()).toBeInstanceOf(Date);
|
||||
*/
|
||||
toBeInstanceOf: <E>(expected: E) => void;
|
||||
/**
|
||||
* Used to check that an object has a `.length` property
|
||||
* and it is set to a certain numeric value.
|
||||
*
|
||||
* @example
|
||||
* expect([1, 2, 3]).toHaveLength(3);
|
||||
* expect('hello').toHaveLength(5);
|
||||
*/
|
||||
toHaveLength: (length: number) => void;
|
||||
/**
|
||||
* Use to check if a property at the specified path exists on an object.
|
||||
* For checking deeply nested properties, you may use dot notation or an array containing
|
||||
* the path segments for deep references.
|
||||
*
|
||||
* Optionally, you can provide a value to check if it matches the value present at the path
|
||||
* on the target object. This matcher uses 'deep equality' (like `toEqual()`) and recursively checks
|
||||
* the equality of all fields.
|
||||
*
|
||||
* @example
|
||||
* expect(user).toHaveProperty('address.city', 'New York');
|
||||
* expect(config).toHaveProperty(['settings', 'theme'], 'dark');
|
||||
*/
|
||||
toHaveProperty: <E>(property: string | (string | number)[], value?: E) => void;
|
||||
/**
|
||||
* Using exact equality with floating point numbers is a bad idea.
|
||||
* Rounding means that intuitive things fail.
|
||||
* The default for `precision` is 2.
|
||||
*
|
||||
* @example
|
||||
* expect(price).toBeCloseTo(9.99, 2);
|
||||
*/
|
||||
toBeCloseTo: (number: number, numDigits?: number) => void;
|
||||
/**
|
||||
* Ensures that a mock function is called an exact number of times.
|
||||
*
|
||||
* Also under the alias `expect.toBeCalledTimes`.
|
||||
*
|
||||
* @example
|
||||
* expect(mockFunc).toHaveBeenCalledTimes(2);
|
||||
*/
|
||||
toHaveBeenCalledTimes: (times: number) => void;
|
||||
/**
|
||||
* Ensures that a mock function is called an exact number of times.
|
||||
*
|
||||
* Alias for `expect.toHaveBeenCalledTimes`.
|
||||
*
|
||||
* @example
|
||||
* expect(mockFunc).toBeCalledTimes(2);
|
||||
*/
|
||||
toBeCalledTimes: (times: number) => void;
|
||||
/**
|
||||
* Ensures that a mock function is called.
|
||||
*
|
||||
* Also under the alias `expect.toBeCalled`.
|
||||
*
|
||||
* @example
|
||||
* expect(mockFunc).toHaveBeenCalled();
|
||||
*/
|
||||
toHaveBeenCalled: () => void;
|
||||
/**
|
||||
* Ensures that a mock function is called.
|
||||
*
|
||||
* Alias for `expect.toHaveBeenCalled`.
|
||||
*
|
||||
* @example
|
||||
* expect(mockFunc).toBeCalled();
|
||||
*/
|
||||
toBeCalled: () => void;
|
||||
/**
|
||||
* Ensure that a mock function is called with specific arguments.
|
||||
*
|
||||
* Also under the alias `expect.toBeCalledWith`.
|
||||
*
|
||||
* @example
|
||||
* expect(mockFunc).toHaveBeenCalledWith('arg1', 42);
|
||||
*/
|
||||
toHaveBeenCalledWith: <E extends any[]>(...args: E) => void;
|
||||
/**
|
||||
* Ensure that a mock function is called with specific arguments.
|
||||
*
|
||||
* Alias for `expect.toHaveBeenCalledWith`.
|
||||
*
|
||||
* @example
|
||||
* expect(mockFunc).toBeCalledWith('arg1', 42);
|
||||
*/
|
||||
toBeCalledWith: <E extends any[]>(...args: E) => void;
|
||||
/**
|
||||
* Ensure that a mock function is called with specific arguments on an Nth call.
|
||||
*
|
||||
* Also under the alias `expect.nthCalledWith`.
|
||||
*
|
||||
* @example
|
||||
* expect(mockFunc).toHaveBeenNthCalledWith(2, 'secondArg');
|
||||
*/
|
||||
toHaveBeenNthCalledWith: <E extends any[]>(n: number, ...args: E) => void;
|
||||
/**
|
||||
* Ensure that a mock function is called with specific arguments on an Nth call.
|
||||
*
|
||||
* Alias for `expect.toHaveBeenNthCalledWith`.
|
||||
*
|
||||
* @example
|
||||
* expect(mockFunc).nthCalledWith(2, 'secondArg');
|
||||
*/
|
||||
nthCalledWith: <E extends any[]>(nthCall: number, ...args: E) => void;
|
||||
/**
|
||||
* If you have a mock function, you can use `.toHaveBeenLastCalledWith`
|
||||
* to test what arguments it was last called with.
|
||||
*
|
||||
* Also under the alias `expect.lastCalledWith`.
|
||||
*
|
||||
* @example
|
||||
* expect(mockFunc).toHaveBeenLastCalledWith('lastArg');
|
||||
*/
|
||||
toHaveBeenLastCalledWith: <E extends any[]>(...args: E) => void;
|
||||
/**
|
||||
* If you have a mock function, you can use `.lastCalledWith`
|
||||
* to test what arguments it was last called with.
|
||||
*
|
||||
* Alias for `expect.toHaveBeenLastCalledWith`.
|
||||
*
|
||||
* @example
|
||||
* expect(mockFunc).lastCalledWith('lastArg');
|
||||
*/
|
||||
lastCalledWith: <E extends any[]>(...args: E) => void;
|
||||
/**
|
||||
* Used to test that a function throws when it is called.
|
||||
*
|
||||
* Also under the alias `expect.toThrowError`.
|
||||
*
|
||||
* @example
|
||||
* expect(() => functionWithError()).toThrow('Error message');
|
||||
* expect(() => parseJSON('invalid')).toThrow(SyntaxError);
|
||||
*/
|
||||
toThrow: (expected?: string | Constructable | RegExp | Error) => void;
|
||||
/**
|
||||
* Used to test that a function throws when it is called.
|
||||
*
|
||||
* Alias for `expect.toThrow`.
|
||||
*
|
||||
* @example
|
||||
* expect(() => functionWithError()).toThrowError('Error message');
|
||||
* expect(() => parseJSON('invalid')).toThrowError(SyntaxError);
|
||||
*/
|
||||
toThrowError: (expected?: string | Constructable | RegExp | Error) => void;
|
||||
/**
|
||||
* Use to test that the mock function successfully returned (i.e., did not throw an error) at least one time
|
||||
*
|
||||
* Alias for `expect.toHaveReturned`.
|
||||
*
|
||||
* @example
|
||||
* expect(mockFunc).toReturn();
|
||||
*/
|
||||
toReturn: () => void;
|
||||
/**
|
||||
* Use to test that the mock function successfully returned (i.e., did not throw an error) at least one time
|
||||
*
|
||||
* Also under the alias `expect.toReturn`.
|
||||
*
|
||||
* @example
|
||||
* expect(mockFunc).toHaveReturned();
|
||||
*/
|
||||
toHaveReturned: () => void;
|
||||
/**
|
||||
* Use to ensure that a mock function returned successfully (i.e., did not throw an error) an exact number of times.
|
||||
* Any calls to the mock function that throw an error are not counted toward the number of times the function returned.
|
||||
*
|
||||
* Alias for `expect.toHaveReturnedTimes`.
|
||||
*
|
||||
* @example
|
||||
* expect(mockFunc).toReturnTimes(3);
|
||||
*/
|
||||
toReturnTimes: (times: number) => void;
|
||||
/**
|
||||
* Use to ensure that a mock function returned successfully (i.e., did not throw an error) an exact number of times.
|
||||
* Any calls to the mock function that throw an error are not counted toward the number of times the function returned.
|
||||
*
|
||||
* Also under the alias `expect.toReturnTimes`.
|
||||
*
|
||||
* @example
|
||||
* expect(mockFunc).toHaveReturnedTimes(3);
|
||||
*/
|
||||
toHaveReturnedTimes: (times: number) => void;
|
||||
/**
|
||||
* Use to ensure that a mock function returned a specific value.
|
||||
*
|
||||
* Alias for `expect.toHaveReturnedWith`.
|
||||
*
|
||||
* @example
|
||||
* expect(mockFunc).toReturnWith('returnValue');
|
||||
*/
|
||||
toReturnWith: <E>(value: E) => void;
|
||||
/**
|
||||
* Use to ensure that a mock function returned a specific value.
|
||||
*
|
||||
* Also under the alias `expect.toReturnWith`.
|
||||
*
|
||||
* @example
|
||||
* expect(mockFunc).toHaveReturnedWith('returnValue');
|
||||
*/
|
||||
toHaveReturnedWith: <E>(value: E) => void;
|
||||
/**
|
||||
* Use to test the specific value that a mock function last returned.
|
||||
* If the last call to the mock function threw an error, then this matcher will fail
|
||||
* no matter what value you provided as the expected return value.
|
||||
*
|
||||
* Also under the alias `expect.lastReturnedWith`.
|
||||
*
|
||||
* @example
|
||||
* expect(mockFunc).toHaveLastReturnedWith('lastValue');
|
||||
*/
|
||||
toHaveLastReturnedWith: <E>(value: E) => void;
|
||||
/**
|
||||
* Use to test the specific value that a mock function last returned.
|
||||
* If the last call to the mock function threw an error, then this matcher will fail
|
||||
* no matter what value you provided as the expected return value.
|
||||
*
|
||||
* Alias for `expect.toHaveLastReturnedWith`.
|
||||
*
|
||||
* @example
|
||||
* expect(mockFunc).lastReturnedWith('lastValue');
|
||||
*/
|
||||
lastReturnedWith: <E>(value: E) => void;
|
||||
/**
|
||||
* Use to test the specific value that a mock function returned for the nth call.
|
||||
* If the nth call to the mock function threw an error, then this matcher will fail
|
||||
* no matter what value you provided as the expected return value.
|
||||
*
|
||||
* Also under the alias `expect.nthReturnedWith`.
|
||||
*
|
||||
* @example
|
||||
* expect(mockFunc).toHaveNthReturnedWith(2, 'nthValue');
|
||||
*/
|
||||
toHaveNthReturnedWith: <E>(nthCall: number, value: E) => void;
|
||||
/**
|
||||
* Use to test the specific value that a mock function returned for the nth call.
|
||||
* If the nth call to the mock function threw an error, then this matcher will fail
|
||||
* no matter what value you provided as the expected return value.
|
||||
*
|
||||
* Alias for `expect.toHaveNthReturnedWith`.
|
||||
*
|
||||
* @example
|
||||
* expect(mockFunc).nthReturnedWith(2, 'nthValue');
|
||||
*/
|
||||
nthReturnedWith: <E>(nthCall: number, value: E) => void;
|
||||
}
|
||||
type VitestAssertion<A, T> = {
|
||||
[K in keyof A]: A[K] extends Chai.Assertion ? Assertion<T> : A[K] extends (...args: any[]) => any ? A[K] : VitestAssertion<A[K], T>;
|
||||
} & ((type: string, message?: string) => Assertion);
|
||||
type Promisify<O> = {
|
||||
[K in keyof O]: O[K] extends (...args: infer A) => infer R ? O extends R ? Promisify<O[K]> : (...args: A) => Promise<R> : O[K];
|
||||
};
|
||||
type PromisifyAssertion<T> = Promisify<Assertion<T>>;
|
||||
interface Assertion<T = any> extends VitestAssertion<Chai.Assertion, T>, JestAssertion<T> {
|
||||
/**
|
||||
* Ensures a value is of a specific type.
|
||||
*
|
||||
* @example
|
||||
* expect(value).toBeTypeOf('string');
|
||||
* expect(number).toBeTypeOf('number');
|
||||
*/
|
||||
toBeTypeOf: (expected: 'bigint' | 'boolean' | 'function' | 'number' | 'object' | 'string' | 'symbol' | 'undefined') => void;
|
||||
/**
|
||||
* Asserts that a mock function was called exactly once.
|
||||
*
|
||||
* @example
|
||||
* expect(mockFunc).toHaveBeenCalledOnce();
|
||||
*/
|
||||
toHaveBeenCalledOnce: () => void;
|
||||
/**
|
||||
* Checks that a value satisfies a custom matcher function.
|
||||
*
|
||||
* @param matcher - A function returning a boolean based on the custom condition
|
||||
* @param message - Optional custom error message on failure
|
||||
*
|
||||
* @example
|
||||
* expect(age).toSatisfy(val => val >= 18, 'Age must be at least 18');
|
||||
*/
|
||||
toSatisfy: <E>(matcher: (value: E) => boolean, message?: string) => void;
|
||||
/**
|
||||
* Checks that a promise resolves successfully at least once.
|
||||
*
|
||||
* @example
|
||||
* await expect(promise).toHaveResolved();
|
||||
*/
|
||||
toHaveResolved: () => void;
|
||||
/**
|
||||
* Checks that a promise resolves to a specific value.
|
||||
*
|
||||
* @example
|
||||
* await expect(promise).toHaveResolvedWith('success');
|
||||
*/
|
||||
toHaveResolvedWith: <E>(value: E) => void;
|
||||
/**
|
||||
* Ensures a promise resolves a specific number of times.
|
||||
*
|
||||
* @example
|
||||
* expect(mockAsyncFunc).toHaveResolvedTimes(3);
|
||||
*/
|
||||
toHaveResolvedTimes: (times: number) => void;
|
||||
/**
|
||||
* Asserts that the last resolved value of a promise matches an expected value.
|
||||
*
|
||||
* @example
|
||||
* await expect(mockAsyncFunc).toHaveLastResolvedWith('finalResult');
|
||||
*/
|
||||
toHaveLastResolvedWith: <E>(value: E) => void;
|
||||
/**
|
||||
* Ensures a specific value was returned by a promise on the nth resolution.
|
||||
*
|
||||
* @example
|
||||
* await expect(mockAsyncFunc).toHaveNthResolvedWith(2, 'secondResult');
|
||||
*/
|
||||
toHaveNthResolvedWith: <E>(nthCall: number, value: E) => void;
|
||||
/**
|
||||
* Verifies that a promise resolves.
|
||||
*
|
||||
* @example
|
||||
* await expect(someAsyncFunc).resolves.toBe(42);
|
||||
*/
|
||||
resolves: PromisifyAssertion<T>;
|
||||
/**
|
||||
* Verifies that a promise rejects.
|
||||
*
|
||||
* @example
|
||||
* await expect(someAsyncFunc).rejects.toThrow('error');
|
||||
*/
|
||||
rejects: PromisifyAssertion<T>;
|
||||
}
|
||||
declare global {
|
||||
namespace jest {
|
||||
interface Matchers<R, T = {}> {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
interface AsymmetricMatcherInterface {
|
||||
asymmetricMatch: (other: unknown) => boolean;
|
||||
toString: () => string;
|
||||
getExpectedType?: () => string;
|
||||
toAsymmetricMatcher?: () => string;
|
||||
}
|
||||
declare abstract class AsymmetricMatcher<T, State extends MatcherState = MatcherState> implements AsymmetricMatcherInterface {
|
||||
protected sample: T;
|
||||
protected inverse: boolean;
|
||||
$$typeof: symbol;
|
||||
constructor(sample: T, inverse?: boolean);
|
||||
protected getMatcherContext(expect?: Chai.ExpectStatic): State;
|
||||
abstract asymmetricMatch(other: unknown): boolean;
|
||||
abstract toString(): string;
|
||||
getExpectedType?(): string;
|
||||
toAsymmetricMatcher?(): string;
|
||||
}
|
||||
declare class StringContaining extends AsymmetricMatcher<string> {
|
||||
constructor(sample: string, inverse?: boolean);
|
||||
asymmetricMatch(other: string): boolean;
|
||||
toString(): string;
|
||||
getExpectedType(): string;
|
||||
}
|
||||
declare class Anything extends AsymmetricMatcher<void> {
|
||||
asymmetricMatch(other: unknown): other is {};
|
||||
toString(): string;
|
||||
toAsymmetricMatcher(): string;
|
||||
}
|
||||
declare class ObjectContaining extends AsymmetricMatcher<Record<string, unknown>> {
|
||||
constructor(sample: Record<string, unknown>, inverse?: boolean);
|
||||
getPrototype(obj: object): any;
|
||||
hasProperty(obj: object | null, property: string): boolean;
|
||||
asymmetricMatch(other: any): boolean;
|
||||
toString(): string;
|
||||
getExpectedType(): string;
|
||||
}
|
||||
declare class ArrayContaining<T = unknown> extends AsymmetricMatcher<Array<T>> {
|
||||
constructor(sample: Array<T>, inverse?: boolean);
|
||||
asymmetricMatch(other: Array<T>): boolean;
|
||||
toString(): string;
|
||||
getExpectedType(): string;
|
||||
}
|
||||
declare class Any extends AsymmetricMatcher<any> {
|
||||
constructor(sample: unknown);
|
||||
fnNameFor(func: Function): string;
|
||||
asymmetricMatch(other: unknown): boolean;
|
||||
toString(): string;
|
||||
getExpectedType(): string;
|
||||
toAsymmetricMatcher(): string;
|
||||
}
|
||||
declare class StringMatching extends AsymmetricMatcher<RegExp> {
|
||||
constructor(sample: string | RegExp, inverse?: boolean);
|
||||
asymmetricMatch(other: string): boolean;
|
||||
toString(): string;
|
||||
getExpectedType(): string;
|
||||
}
|
||||
declare const JestAsymmetricMatchers: ChaiPlugin;
|
||||
|
||||
declare const JestChaiExpect: ChaiPlugin;
|
||||
|
||||
declare const JestExtend: ChaiPlugin;
|
||||
|
||||
declare function equals(a: unknown, b: unknown, customTesters?: Array<Tester>, strictCheck?: boolean): boolean;
|
||||
declare function isAsymmetric(obj: any): boolean;
|
||||
declare function hasAsymmetric(obj: any, seen?: Set<unknown>): boolean;
|
||||
declare function isA(typeName: string, value: unknown): boolean;
|
||||
declare function fnNameFor(func: Function): string;
|
||||
declare function hasProperty(obj: object | null, property: string): boolean;
|
||||
declare function isImmutableUnorderedKeyed(maybeKeyed: any): boolean;
|
||||
declare function isImmutableUnorderedSet(maybeSet: any): boolean;
|
||||
declare function iterableEquality(a: any, b: any, customTesters?: Array<Tester>, aStack?: Array<any>, bStack?: Array<any>): boolean | undefined;
|
||||
declare function subsetEquality(object: unknown, subset: unknown, customTesters?: Array<Tester>): boolean | undefined;
|
||||
declare function typeEquality(a: any, b: any): boolean | undefined;
|
||||
declare function arrayBufferEquality(a: unknown, b: unknown): boolean | undefined;
|
||||
declare function sparseArrayEquality(a: unknown, b: unknown, customTesters?: Array<Tester>): boolean | undefined;
|
||||
declare function generateToBeMessage(deepEqualityName: string, expected?: string, actual?: string): string;
|
||||
declare function pluralize(word: string, count: number): string;
|
||||
declare function getObjectKeys(object: object): Array<string | symbol>;
|
||||
declare function getObjectSubset(object: any, subset: any, customTesters: Array<Tester>): {
|
||||
subset: any;
|
||||
stripped: number;
|
||||
};
|
||||
|
||||
declare function getState<State extends MatcherState = MatcherState>(expect: ExpectStatic): State;
|
||||
declare function setState<State extends MatcherState = MatcherState>(state: Partial<State>, expect: ExpectStatic): void;
|
||||
|
||||
export { ASYMMETRIC_MATCHERS_OBJECT, Any, Anything, ArrayContaining, type Assertion, AsymmetricMatcher, type AsymmetricMatcherInterface, type AsymmetricMatchersContaining, type AsyncExpectationResult, type ChaiPlugin, type ExpectStatic, type ExpectationResult, GLOBAL_EXPECT, JEST_MATCHERS_OBJECT, type JestAssertion, JestAsymmetricMatchers, JestChaiExpect, JestExtend, MATCHERS_OBJECT, type MatcherHintOptions, type MatcherState, type MatchersObject, ObjectContaining, type PromisifyAssertion, type RawMatcherFn, StringContaining, StringMatching, type SyncExpectationResult, type Tester, type TesterContext, addCustomEqualityTesters, arrayBufferEquality, equals, fnNameFor, generateToBeMessage, getObjectKeys, getObjectSubset, getState, hasAsymmetric, hasProperty, isA, isAsymmetric, isImmutableUnorderedKeyed, isImmutableUnorderedSet, iterableEquality, pluralize, setState, sparseArrayEquality, subsetEquality, typeEquality };
|
||||
+2069
File diff suppressed because it is too large.
Load diff
+3
@@ -0,0 +1,3 @@
|
||||
import './dist/chai.cjs'
|
||||
|
||||
export * from './dist/index.js'
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
{
|
||||
"name": "@vitest/expect",
|
||||
"type": "module",
|
||||
"version": "2.1.9",
|
||||
"description": "Jest's expect matchers as a Chai plugin",
|
||||
"license": "MIT",
|
||||
"funding": "https://opencollective.com/vitest",
|
||||
"homepage": "https://github.com/vitest-dev/vitest/tree/main/packages/expect#readme",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/vitest-dev/vitest.git",
|
||||
"directory": "packages/expect"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/vitest-dev/vitest/issues"
|
||||
},
|
||||
"sideEffects": false,
|
||||
"exports": {
|
||||
".": {
|
||||
"types": "./index.d.ts",
|
||||
"default": "./dist/index.js"
|
||||
},
|
||||
"./*": "./*"
|
||||
},
|
||||
"main": "./dist/index.js",
|
||||
"module": "./dist/index.js",
|
||||
"types": "./index.d.ts",
|
||||
"files": [
|
||||
"*.d.ts",
|
||||
"dist"
|
||||
],
|
||||
"dependencies": {
|
||||
"chai": "^5.1.2",
|
||||
"tinyrainbow": "^1.2.0",
|
||||
"@vitest/spy": "2.1.9",
|
||||
"@vitest/utils": "2.1.9"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/chai": "4.3.6",
|
||||
"rollup-plugin-copy": "^3.5.0",
|
||||
"@vitest/runner": "2.1.9"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "rimraf dist && rollup -c",
|
||||
"dev": "rollup -c --watch"
|
||||
}
|
||||
}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2021-Present Vitest Team
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
# @vitest/mocker
|
||||
|
||||
Vitest's module mocker implementation.
|
||||
|
||||
[GitHub](https://github.com/vitest-dev/vitest/blob/main/packages/mocker/) | [Documentation](https://github.com/vitest-dev/vitest/blob/main/packages/mocker/EXPORTS.md)
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
|
||||
export { }
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
import { M as ModuleMockerServerInterceptor } from './chunk-interceptor-native.js';
|
||||
import { registerModuleMocker } from './register.js';
|
||||
import './chunk-mocker.js';
|
||||
import './index.js';
|
||||
import './chunk-registry.js';
|
||||
import './chunk-pathe.ff20891b.js';
|
||||
import '@vitest/spy';
|
||||
|
||||
registerModuleMocker(
|
||||
() => new ModuleMockerServerInterceptor()
|
||||
);
|
||||
+51
@@ -0,0 +1,51 @@
|
||||
import { M as ModuleMockerInterceptor } from './mocker-pQgp1HFr.js';
|
||||
export { C as CompilerHintsOptions, b as ModuleMocker, a as ModuleMockerCompilerHints, d as ModuleMockerConfig, e as ModuleMockerRPC, R as ResolveIdResult, f as ResolveMockResul, c as createCompilerHints } from './mocker-pQgp1HFr.js';
|
||||
import { StartOptions, SetupWorker } from 'msw/browser';
|
||||
import { c as MockerRegistry, g as MockedModule } from './types-DZOqTgiN.js';
|
||||
import '@vitest/spy';
|
||||
|
||||
interface ModuleMockerMSWInterceptorOptions {
|
||||
/**
|
||||
* The identifier to access the globalThis object in the worker.
|
||||
* This will be injected into the script as is, so make sure it's a valid JS expression.
|
||||
* @example
|
||||
* ```js
|
||||
* // globalThisAccessor: '__my_variable__' produces:
|
||||
* globalThis[__my_variable__]
|
||||
* // globalThisAccessor: 'Symbol.for('secret:mocks')' produces:
|
||||
* globalThis[Symbol.for('secret:mocks')]
|
||||
* // globalThisAccessor: '"__vitest_mocker__"' (notice quotes) produces:
|
||||
* globalThis["__vitest_mocker__"]
|
||||
* ```
|
||||
* @default `"__vitest_mocker__"`
|
||||
*/
|
||||
globalThisAccessor?: string;
|
||||
/**
|
||||
* Options passed down to `msw.setupWorker().start(options)`
|
||||
*/
|
||||
mswOptions?: StartOptions;
|
||||
/**
|
||||
* A pre-configured `msw.setupWorker` instance.
|
||||
*/
|
||||
mswWorker?: SetupWorker;
|
||||
}
|
||||
declare class ModuleMockerMSWInterceptor implements ModuleMockerInterceptor {
|
||||
private readonly options;
|
||||
protected readonly mocks: MockerRegistry;
|
||||
private startPromise;
|
||||
private worker;
|
||||
constructor(options?: ModuleMockerMSWInterceptorOptions);
|
||||
register(module: MockedModule): Promise<void>;
|
||||
delete(url: string): Promise<void>;
|
||||
invalidate(): void;
|
||||
private resolveManualMock;
|
||||
protected init(): Promise<SetupWorker>;
|
||||
}
|
||||
|
||||
declare class ModuleMockerServerInterceptor implements ModuleMockerInterceptor {
|
||||
register(module: MockedModule): Promise<void>;
|
||||
delete(id: string): Promise<void>;
|
||||
invalidate(): void;
|
||||
}
|
||||
|
||||
export { ModuleMockerInterceptor, ModuleMockerMSWInterceptor, type ModuleMockerMSWInterceptorOptions, ModuleMockerServerInterceptor };
|
||||
+116
@@ -0,0 +1,116 @@
|
||||
export { M as ModuleMocker, c as createCompilerHints } from './chunk-mocker.js';
|
||||
import { M as MockerRegistry } from './chunk-registry.js';
|
||||
import { c as cleanUrl } from './chunk-utils.js';
|
||||
export { M as ModuleMockerServerInterceptor } from './chunk-interceptor-native.js';
|
||||
import './index.js';
|
||||
import './chunk-pathe.ff20891b.js';
|
||||
|
||||
class ModuleMockerMSWInterceptor {
|
||||
constructor(options = {}) {
|
||||
this.options = options;
|
||||
if (!options.globalThisAccessor) {
|
||||
options.globalThisAccessor = '"__vitest_mocker__"';
|
||||
}
|
||||
}
|
||||
mocks = new MockerRegistry();
|
||||
startPromise;
|
||||
worker;
|
||||
async register(module) {
|
||||
await this.init();
|
||||
this.mocks.add(module);
|
||||
}
|
||||
async delete(url) {
|
||||
await this.init();
|
||||
this.mocks.delete(url);
|
||||
}
|
||||
invalidate() {
|
||||
this.mocks.clear();
|
||||
}
|
||||
async resolveManualMock(mock) {
|
||||
const exports = Object.keys(await mock.resolve());
|
||||
const module = `const module = globalThis[${this.options.globalThisAccessor}].getFactoryModule("${mock.url}");`;
|
||||
const keys = exports.map((name) => {
|
||||
if (name === "default") {
|
||||
return `export default module["default"];`;
|
||||
}
|
||||
return `export const ${name} = module["${name}"];`;
|
||||
}).join("\n");
|
||||
const text = `${module}
|
||||
${keys}`;
|
||||
return new Response(text, {
|
||||
headers: {
|
||||
"Content-Type": "application/javascript"
|
||||
}
|
||||
});
|
||||
}
|
||||
async init() {
|
||||
if (this.worker) {
|
||||
return this.worker;
|
||||
}
|
||||
if (this.startPromise) {
|
||||
return this.startPromise;
|
||||
}
|
||||
const worker = this.options.mswWorker;
|
||||
this.startPromise = Promise.all([
|
||||
worker ? {
|
||||
setupWorker(handler) {
|
||||
worker.use(handler);
|
||||
return worker;
|
||||
}
|
||||
} : import('msw/browser'),
|
||||
import('msw/core/http')
|
||||
]).then(([{ setupWorker }, { http }]) => {
|
||||
const worker2 = setupWorker(
|
||||
http.get(/.+/, async ({ request }) => {
|
||||
const path = cleanQuery(request.url.slice(location.origin.length));
|
||||
if (!this.mocks.has(path)) {
|
||||
return passthrough();
|
||||
}
|
||||
const mock = this.mocks.get(path);
|
||||
switch (mock.type) {
|
||||
case "manual":
|
||||
return this.resolveManualMock(mock);
|
||||
case "automock":
|
||||
case "autospy":
|
||||
return Response.redirect(injectQuery(path, `mock=${mock.type}`));
|
||||
case "redirect":
|
||||
return Response.redirect(mock.redirect);
|
||||
default:
|
||||
throw new Error(`Unknown mock type: ${mock.type}`);
|
||||
}
|
||||
})
|
||||
);
|
||||
return worker2.start(this.options.mswOptions).then(() => worker2);
|
||||
}).finally(() => {
|
||||
this.worker = worker;
|
||||
this.startPromise = void 0;
|
||||
});
|
||||
return await this.startPromise;
|
||||
}
|
||||
}
|
||||
const timestampRegexp = /(\?|&)t=\d{13}/;
|
||||
const versionRegexp = /(\?|&)v=\w{8}/;
|
||||
function cleanQuery(url) {
|
||||
return url.replace(timestampRegexp, "").replace(versionRegexp, "");
|
||||
}
|
||||
function passthrough() {
|
||||
return new Response(null, {
|
||||
status: 302,
|
||||
statusText: "Passthrough",
|
||||
headers: {
|
||||
"x-msw-intention": "passthrough"
|
||||
}
|
||||
});
|
||||
}
|
||||
const replacePercentageRE = /%/g;
|
||||
function injectQuery(url, queryToInject) {
|
||||
const resolvedUrl = new URL(
|
||||
url.replace(replacePercentageRE, "%25"),
|
||||
location.href
|
||||
);
|
||||
const { search, hash } = resolvedUrl;
|
||||
const pathname = cleanUrl(url);
|
||||
return `${pathname}?${queryToInject}${search ? `&${search.slice(1)}` : ""}${hash ?? ""}`;
|
||||
}
|
||||
|
||||
export { ModuleMockerMSWInterceptor };
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
import { r as rpc } from './chunk-mocker.js';
|
||||
|
||||
class ModuleMockerServerInterceptor {
|
||||
async register(module) {
|
||||
await rpc("vitest:interceptor:register", module.toJSON());
|
||||
}
|
||||
async delete(id) {
|
||||
await rpc("vitest:interceptor:delete", id);
|
||||
}
|
||||
invalidate() {
|
||||
rpc("vitest:interceptor:invalidate");
|
||||
}
|
||||
}
|
||||
|
||||
export { ModuleMockerServerInterceptor as M };
|
||||
+532
@@ -0,0 +1,532 @@
|
||||
import { mockObject } from './index.js';
|
||||
import { M as MockerRegistry, R as RedirectedModule, A as AutomockedModule } from './chunk-registry.js';
|
||||
import { e as extname, j as join } from './chunk-pathe.ff20891b.js';
|
||||
|
||||
function createSimpleStackTrace(options) {
|
||||
const { message = "$$stack trace error", stackTraceLimit = 1 } = options || {};
|
||||
const limit = Error.stackTraceLimit;
|
||||
const prepareStackTrace = Error.prepareStackTrace;
|
||||
Error.stackTraceLimit = stackTraceLimit;
|
||||
Error.prepareStackTrace = (e) => e.stack;
|
||||
const err = new Error(message);
|
||||
const stackTrace = err.stack || "";
|
||||
Error.prepareStackTrace = prepareStackTrace;
|
||||
Error.stackTraceLimit = limit;
|
||||
return stackTrace;
|
||||
}
|
||||
|
||||
const chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
||||
const intToChar = new Uint8Array(64);
|
||||
const charToInt = new Uint8Array(128);
|
||||
for (let i = 0; i < chars.length; i++) {
|
||||
const c = chars.charCodeAt(i);
|
||||
intToChar[i] = c;
|
||||
charToInt[c] = i;
|
||||
}
|
||||
var UrlType;
|
||||
(function(UrlType2) {
|
||||
UrlType2[UrlType2["Empty"] = 1] = "Empty";
|
||||
UrlType2[UrlType2["Hash"] = 2] = "Hash";
|
||||
UrlType2[UrlType2["Query"] = 3] = "Query";
|
||||
UrlType2[UrlType2["RelativePath"] = 4] = "RelativePath";
|
||||
UrlType2[UrlType2["AbsolutePath"] = 5] = "AbsolutePath";
|
||||
UrlType2[UrlType2["SchemeRelative"] = 6] = "SchemeRelative";
|
||||
UrlType2[UrlType2["Absolute"] = 7] = "Absolute";
|
||||
})(UrlType || (UrlType = {}));
|
||||
const _DRIVE_LETTER_START_RE = /^[A-Za-z]:\//;
|
||||
function normalizeWindowsPath(input = "") {
|
||||
if (!input) {
|
||||
return input;
|
||||
}
|
||||
return input.replace(/\\/g, "/").replace(_DRIVE_LETTER_START_RE, (r) => r.toUpperCase());
|
||||
}
|
||||
const _IS_ABSOLUTE_RE = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/;
|
||||
function cwd() {
|
||||
if (typeof process !== "undefined" && typeof process.cwd === "function") {
|
||||
return process.cwd().replace(/\\/g, "/");
|
||||
}
|
||||
return "/";
|
||||
}
|
||||
const resolve = function(...arguments_) {
|
||||
arguments_ = arguments_.map((argument) => normalizeWindowsPath(argument));
|
||||
let resolvedPath = "";
|
||||
let resolvedAbsolute = false;
|
||||
for (let index = arguments_.length - 1; index >= -1 && !resolvedAbsolute; index--) {
|
||||
const path = index >= 0 ? arguments_[index] : cwd();
|
||||
if (!path || path.length === 0) {
|
||||
continue;
|
||||
}
|
||||
resolvedPath = `${path}/${resolvedPath}`;
|
||||
resolvedAbsolute = isAbsolute(path);
|
||||
}
|
||||
resolvedPath = normalizeString(resolvedPath, !resolvedAbsolute);
|
||||
if (resolvedAbsolute && !isAbsolute(resolvedPath)) {
|
||||
return `/${resolvedPath}`;
|
||||
}
|
||||
return resolvedPath.length > 0 ? resolvedPath : ".";
|
||||
};
|
||||
function normalizeString(path, allowAboveRoot) {
|
||||
let res = "";
|
||||
let lastSegmentLength = 0;
|
||||
let lastSlash = -1;
|
||||
let dots = 0;
|
||||
let char = null;
|
||||
for (let index = 0; index <= path.length; ++index) {
|
||||
if (index < path.length) {
|
||||
char = path[index];
|
||||
} else if (char === "/") {
|
||||
break;
|
||||
} else {
|
||||
char = "/";
|
||||
}
|
||||
if (char === "/") {
|
||||
if (lastSlash === index - 1 || dots === 1) ;
|
||||
else if (dots === 2) {
|
||||
if (res.length < 2 || lastSegmentLength !== 2 || res[res.length - 1] !== "." || res[res.length - 2] !== ".") {
|
||||
if (res.length > 2) {
|
||||
const lastSlashIndex = res.lastIndexOf("/");
|
||||
if (lastSlashIndex === -1) {
|
||||
res = "";
|
||||
lastSegmentLength = 0;
|
||||
} else {
|
||||
res = res.slice(0, lastSlashIndex);
|
||||
lastSegmentLength = res.length - 1 - res.lastIndexOf("/");
|
||||
}
|
||||
lastSlash = index;
|
||||
dots = 0;
|
||||
continue;
|
||||
} else if (res.length > 0) {
|
||||
res = "";
|
||||
lastSegmentLength = 0;
|
||||
lastSlash = index;
|
||||
dots = 0;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (allowAboveRoot) {
|
||||
res += res.length > 0 ? "/.." : "..";
|
||||
lastSegmentLength = 2;
|
||||
}
|
||||
} else {
|
||||
if (res.length > 0) {
|
||||
res += `/${path.slice(lastSlash + 1, index)}`;
|
||||
} else {
|
||||
res = path.slice(lastSlash + 1, index);
|
||||
}
|
||||
lastSegmentLength = index - lastSlash - 1;
|
||||
}
|
||||
lastSlash = index;
|
||||
dots = 0;
|
||||
} else if (char === "." && dots !== -1) {
|
||||
++dots;
|
||||
} else {
|
||||
dots = -1;
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
const isAbsolute = function(p) {
|
||||
return _IS_ABSOLUTE_RE.test(p);
|
||||
};
|
||||
const CHROME_IE_STACK_REGEXP = /^\s*at .*(?:\S:\d+|\(native\))/m;
|
||||
const SAFARI_NATIVE_CODE_REGEXP = /^(?:eval@)?(?:\[native code\])?$/;
|
||||
function extractLocation(urlLike) {
|
||||
if (!urlLike.includes(":")) {
|
||||
return [urlLike];
|
||||
}
|
||||
const regExp = /(.+?)(?::(\d+))?(?::(\d+))?$/;
|
||||
const parts = regExp.exec(urlLike.replace(/^\(|\)$/g, ""));
|
||||
if (!parts) {
|
||||
return [urlLike];
|
||||
}
|
||||
let url = parts[1];
|
||||
if (url.startsWith("async ")) {
|
||||
url = url.slice(6);
|
||||
}
|
||||
if (url.startsWith("http:") || url.startsWith("https:")) {
|
||||
const urlObj = new URL(url);
|
||||
url = urlObj.pathname;
|
||||
}
|
||||
if (url.startsWith("/@fs/")) {
|
||||
const isWindows = /^\/@fs\/[a-zA-Z]:\//.test(url);
|
||||
url = url.slice(isWindows ? 5 : 4);
|
||||
}
|
||||
return [url, parts[2] || void 0, parts[3] || void 0];
|
||||
}
|
||||
function parseSingleFFOrSafariStack(raw) {
|
||||
let line = raw.trim();
|
||||
if (SAFARI_NATIVE_CODE_REGEXP.test(line)) {
|
||||
return null;
|
||||
}
|
||||
if (line.includes(" > eval")) {
|
||||
line = line.replace(
|
||||
/ line (\d+)(?: > eval line \d+)* > eval:\d+:\d+/g,
|
||||
":$1"
|
||||
);
|
||||
}
|
||||
if (!line.includes("@") && !line.includes(":")) {
|
||||
return null;
|
||||
}
|
||||
const functionNameRegex = /((.*".+"[^@]*)?[^@]*)(@)/;
|
||||
const matches = line.match(functionNameRegex);
|
||||
const functionName = matches && matches[1] ? matches[1] : void 0;
|
||||
const [url, lineNumber, columnNumber] = extractLocation(
|
||||
line.replace(functionNameRegex, "")
|
||||
);
|
||||
if (!url || !lineNumber || !columnNumber) {
|
||||
return null;
|
||||
}
|
||||
return {
|
||||
file: url,
|
||||
method: functionName || "",
|
||||
line: Number.parseInt(lineNumber),
|
||||
column: Number.parseInt(columnNumber)
|
||||
};
|
||||
}
|
||||
function parseSingleStack(raw) {
|
||||
const line = raw.trim();
|
||||
if (!CHROME_IE_STACK_REGEXP.test(line)) {
|
||||
return parseSingleFFOrSafariStack(line);
|
||||
}
|
||||
return parseSingleV8Stack(line);
|
||||
}
|
||||
function parseSingleV8Stack(raw) {
|
||||
let line = raw.trim();
|
||||
if (!CHROME_IE_STACK_REGEXP.test(line)) {
|
||||
return null;
|
||||
}
|
||||
if (line.includes("(eval ")) {
|
||||
line = line.replace(/eval code/g, "eval").replace(/(\(eval at [^()]*)|(,.*$)/g, "");
|
||||
}
|
||||
let sanitizedLine = line.replace(/^\s+/, "").replace(/\(eval code/g, "(").replace(/^.*?\s+/, "");
|
||||
const location = sanitizedLine.match(/ (\(.+\)$)/);
|
||||
sanitizedLine = location ? sanitizedLine.replace(location[0], "") : sanitizedLine;
|
||||
const [url, lineNumber, columnNumber] = extractLocation(
|
||||
location ? location[1] : sanitizedLine
|
||||
);
|
||||
let method = location && sanitizedLine || "";
|
||||
let file = url && ["eval", "<anonymous>"].includes(url) ? void 0 : url;
|
||||
if (!file || !lineNumber || !columnNumber) {
|
||||
return null;
|
||||
}
|
||||
if (method.startsWith("async ")) {
|
||||
method = method.slice(6);
|
||||
}
|
||||
if (file.startsWith("file://")) {
|
||||
file = file.slice(7);
|
||||
}
|
||||
file = resolve(file);
|
||||
if (method) {
|
||||
method = method.replace(/__vite_ssr_import_\d+__\./g, "");
|
||||
}
|
||||
return {
|
||||
method,
|
||||
file,
|
||||
line: Number.parseInt(lineNumber),
|
||||
column: Number.parseInt(columnNumber)
|
||||
};
|
||||
}
|
||||
|
||||
function createCompilerHints(options) {
|
||||
const globalThisAccessor = (options == null ? void 0 : options.globalThisKey) || "__vitest_mocker__";
|
||||
function _mocker() {
|
||||
return typeof globalThis[globalThisAccessor] !== "undefined" ? globalThis[globalThisAccessor] : new Proxy(
|
||||
{},
|
||||
{
|
||||
get(_, name) {
|
||||
throw new Error(
|
||||
`Vitest mocker was not initialized in this environment. vi.${String(name)}() is forbidden.`
|
||||
);
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
return {
|
||||
hoisted(factory) {
|
||||
if (typeof factory !== "function") {
|
||||
throw new TypeError(
|
||||
`vi.hoisted() expects a function, but received a ${typeof factory}`
|
||||
);
|
||||
}
|
||||
return factory();
|
||||
},
|
||||
mock(path, factory) {
|
||||
if (typeof path !== "string") {
|
||||
throw new TypeError(
|
||||
`vi.mock() expects a string path, but received a ${typeof path}`
|
||||
);
|
||||
}
|
||||
const importer = getImporter("mock");
|
||||
_mocker().queueMock(
|
||||
path,
|
||||
importer,
|
||||
typeof factory === "function" ? () => factory(
|
||||
() => _mocker().importActual(
|
||||
path,
|
||||
importer
|
||||
)
|
||||
) : factory
|
||||
);
|
||||
},
|
||||
unmock(path) {
|
||||
if (typeof path !== "string") {
|
||||
throw new TypeError(
|
||||
`vi.unmock() expects a string path, but received a ${typeof path}`
|
||||
);
|
||||
}
|
||||
_mocker().queueUnmock(path, getImporter("unmock"));
|
||||
},
|
||||
doMock(path, factory) {
|
||||
if (typeof path !== "string") {
|
||||
throw new TypeError(
|
||||
`vi.doMock() expects a string path, but received a ${typeof path}`
|
||||
);
|
||||
}
|
||||
const importer = getImporter("doMock");
|
||||
_mocker().queueMock(
|
||||
path,
|
||||
importer,
|
||||
typeof factory === "function" ? () => factory(
|
||||
() => _mocker().importActual(
|
||||
path,
|
||||
importer
|
||||
)
|
||||
) : factory
|
||||
);
|
||||
},
|
||||
doUnmock(path) {
|
||||
if (typeof path !== "string") {
|
||||
throw new TypeError(
|
||||
`vi.doUnmock() expects a string path, but received a ${typeof path}`
|
||||
);
|
||||
}
|
||||
_mocker().queueUnmock(path, getImporter("doUnmock"));
|
||||
},
|
||||
async importActual(path) {
|
||||
return _mocker().importActual(
|
||||
path,
|
||||
getImporter("importActual")
|
||||
);
|
||||
},
|
||||
async importMock(path) {
|
||||
return _mocker().importMock(path, getImporter("importMock"));
|
||||
}
|
||||
};
|
||||
}
|
||||
function getImporter(name) {
|
||||
const stackTrace = /* @__PURE__ */ createSimpleStackTrace({ stackTraceLimit: 5 });
|
||||
const stackArray = stackTrace.split("\n");
|
||||
const importerStackIndex = stackArray.findIndex((stack2) => {
|
||||
return stack2.includes(` at Object.${name}`) || stack2.includes(`${name}@`);
|
||||
});
|
||||
const stack = /* @__PURE__ */ parseSingleStack(stackArray[importerStackIndex + 1]);
|
||||
return (stack == null ? void 0 : stack.file) || "";
|
||||
}
|
||||
|
||||
const hot = import.meta.hot || {
|
||||
on: warn,
|
||||
off: warn,
|
||||
send: warn
|
||||
};
|
||||
function warn() {
|
||||
console.warn("Vitest mocker cannot work if Vite didn't establish WS connection.");
|
||||
}
|
||||
function rpc(event, data) {
|
||||
hot.send(event, data);
|
||||
return new Promise((resolve, reject) => {
|
||||
const timeout = setTimeout(() => {
|
||||
reject(new Error(`Failed to resolve ${event} in time`));
|
||||
}, 5e3);
|
||||
hot.on(`${event}:result`, function r(data2) {
|
||||
resolve(data2);
|
||||
clearTimeout(timeout);
|
||||
hot.off("vitest:mocks:resolvedId:result", r);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
const { now } = Date;
|
||||
class ModuleMocker {
|
||||
constructor(interceptor, rpc, spyOn, config) {
|
||||
this.interceptor = interceptor;
|
||||
this.rpc = rpc;
|
||||
this.spyOn = spyOn;
|
||||
this.config = config;
|
||||
}
|
||||
registry = new MockerRegistry();
|
||||
queue = /* @__PURE__ */ new Set();
|
||||
mockedIds = /* @__PURE__ */ new Set();
|
||||
async prepare() {
|
||||
if (!this.queue.size) {
|
||||
return;
|
||||
}
|
||||
await Promise.all([...this.queue.values()]);
|
||||
}
|
||||
async resolveFactoryModule(id) {
|
||||
const mock = this.registry.get(id);
|
||||
if (!mock || mock.type !== "manual") {
|
||||
throw new Error(`Mock ${id} wasn't registered. This is probably a Vitest error. Please, open a new issue with reproduction.`);
|
||||
}
|
||||
const result = await mock.resolve();
|
||||
return result;
|
||||
}
|
||||
getFactoryModule(id) {
|
||||
const mock = this.registry.get(id);
|
||||
if (!mock || mock.type !== "manual") {
|
||||
throw new Error(`Mock ${id} wasn't registered. This is probably a Vitest error. Please, open a new issue with reproduction.`);
|
||||
}
|
||||
if (!mock.cache) {
|
||||
throw new Error(`Mock ${id} wasn't resolved. This is probably a Vitest error. Please, open a new issue with reproduction.`);
|
||||
}
|
||||
return mock.cache;
|
||||
}
|
||||
async invalidate() {
|
||||
const ids = Array.from(this.mockedIds);
|
||||
if (!ids.length) {
|
||||
return;
|
||||
}
|
||||
await this.rpc.invalidate(ids);
|
||||
this.interceptor.invalidate();
|
||||
this.registry.clear();
|
||||
}
|
||||
async importActual(id, importer) {
|
||||
const resolved = await this.rpc.resolveId(id, importer);
|
||||
if (resolved == null) {
|
||||
throw new Error(
|
||||
`[vitest] Cannot resolve "${id}" imported from "${importer}"`
|
||||
);
|
||||
}
|
||||
const ext = extname(resolved.id);
|
||||
const url = new URL(resolved.url, location.href);
|
||||
const query = `_vitest_original&ext${ext}`;
|
||||
const actualUrl = `${url.pathname}${url.search ? `${url.search}&${query}` : `?${query}`}${url.hash}`;
|
||||
return this.wrapDynamicImport(() => import(
|
||||
/* @vite-ignore */
|
||||
actualUrl
|
||||
)).then((mod) => {
|
||||
if (!resolved.optimized || typeof mod.default === "undefined") {
|
||||
return mod;
|
||||
}
|
||||
const m = mod.default;
|
||||
return (m == null ? void 0 : m.__esModule) ? m : { ...typeof m === "object" && !Array.isArray(m) || typeof m === "function" ? m : {}, default: m };
|
||||
});
|
||||
}
|
||||
async importMock(rawId, importer) {
|
||||
await this.prepare();
|
||||
const { resolvedId, redirectUrl } = await this.rpc.resolveMock(
|
||||
rawId,
|
||||
importer,
|
||||
{ mock: "auto" }
|
||||
);
|
||||
const mockUrl = this.resolveMockPath(cleanVersion(resolvedId));
|
||||
let mock = this.registry.get(mockUrl);
|
||||
if (!mock) {
|
||||
if (redirectUrl) {
|
||||
const resolvedRedirect = new URL(this.resolveMockPath(cleanVersion(redirectUrl)), location.href).toString();
|
||||
mock = new RedirectedModule(rawId, mockUrl, resolvedRedirect);
|
||||
} else {
|
||||
mock = new AutomockedModule(rawId, mockUrl);
|
||||
}
|
||||
}
|
||||
if (mock.type === "manual") {
|
||||
return await mock.resolve();
|
||||
}
|
||||
if (mock.type === "automock" || mock.type === "autospy") {
|
||||
const url = new URL(`/@id/${resolvedId}`, location.href);
|
||||
const query = url.search ? `${url.search}&t=${now()}` : `?t=${now()}`;
|
||||
const moduleObject = await import(
|
||||
/* @vite-ignore */
|
||||
`${url.pathname}${query}&mock=${mock.type}${url.hash}`
|
||||
);
|
||||
return this.mockObject(moduleObject, mock.type);
|
||||
}
|
||||
return import(
|
||||
/* @vite-ignore */
|
||||
mock.redirect
|
||||
);
|
||||
}
|
||||
mockObject(object, moduleType = "automock") {
|
||||
return mockObject({
|
||||
globalConstructors: {
|
||||
Object,
|
||||
Function,
|
||||
Array,
|
||||
Map,
|
||||
RegExp
|
||||
},
|
||||
spyOn: this.spyOn,
|
||||
type: moduleType
|
||||
}, object);
|
||||
}
|
||||
queueMock(rawId, importer, factoryOrOptions) {
|
||||
const promise = this.rpc.resolveMock(rawId, importer, {
|
||||
mock: typeof factoryOrOptions === "function" ? "factory" : (factoryOrOptions == null ? void 0 : factoryOrOptions.spy) ? "spy" : "auto"
|
||||
}).then(async ({ redirectUrl, resolvedId, needsInterop, mockType }) => {
|
||||
const mockUrl = this.resolveMockPath(cleanVersion(resolvedId));
|
||||
this.mockedIds.add(resolvedId);
|
||||
const factory = typeof factoryOrOptions === "function" ? async () => {
|
||||
const data = await factoryOrOptions();
|
||||
return needsInterop ? { default: data } : data;
|
||||
} : void 0;
|
||||
const mockRedirect = typeof redirectUrl === "string" ? new URL(this.resolveMockPath(cleanVersion(redirectUrl)), location.href).toString() : null;
|
||||
let module;
|
||||
if (mockType === "manual") {
|
||||
module = this.registry.register("manual", rawId, mockUrl, factory);
|
||||
} else if (mockType === "autospy") {
|
||||
module = this.registry.register("autospy", rawId, mockUrl);
|
||||
} else if (mockType === "redirect") {
|
||||
module = this.registry.register("redirect", rawId, mockUrl, mockRedirect);
|
||||
} else {
|
||||
module = this.registry.register("automock", rawId, mockUrl);
|
||||
}
|
||||
await this.interceptor.register(module);
|
||||
}).finally(() => {
|
||||
this.queue.delete(promise);
|
||||
});
|
||||
this.queue.add(promise);
|
||||
}
|
||||
queueUnmock(id, importer) {
|
||||
const promise = this.rpc.resolveId(id, importer).then(async (resolved) => {
|
||||
if (!resolved) {
|
||||
return;
|
||||
}
|
||||
const mockUrl = this.resolveMockPath(cleanVersion(resolved.id));
|
||||
this.mockedIds.add(resolved.id);
|
||||
this.registry.delete(mockUrl);
|
||||
await this.interceptor.delete(mockUrl);
|
||||
}).finally(() => {
|
||||
this.queue.delete(promise);
|
||||
});
|
||||
this.queue.add(promise);
|
||||
}
|
||||
// We need to await mock registration before importing the actual module
|
||||
// In case there is a mocked module in the import chain
|
||||
wrapDynamicImport(moduleFactory) {
|
||||
if (typeof moduleFactory === "function") {
|
||||
const promise = new Promise((resolve, reject) => {
|
||||
this.prepare().finally(() => {
|
||||
moduleFactory().then(resolve, reject);
|
||||
});
|
||||
});
|
||||
return promise;
|
||||
}
|
||||
return moduleFactory;
|
||||
}
|
||||
resolveMockPath(path) {
|
||||
const config = this.config;
|
||||
const fsRoot = join("/@fs/", config.root);
|
||||
if (path.startsWith(config.root)) {
|
||||
return path.slice(config.root.length);
|
||||
}
|
||||
if (path.startsWith(fsRoot)) {
|
||||
return path.slice(fsRoot.length);
|
||||
}
|
||||
return path;
|
||||
}
|
||||
}
|
||||
const versionRegexp = /(\?|&)v=\w{8}/;
|
||||
function cleanVersion(url) {
|
||||
return url.replace(versionRegexp, "");
|
||||
}
|
||||
|
||||
export { ModuleMocker as M, createCompilerHints as c, hot as h, rpc as r };
|
||||
+163
@@ -0,0 +1,163 @@
|
||||
const _DRIVE_LETTER_START_RE = /^[A-Za-z]:\//;
|
||||
function normalizeWindowsPath(input = "") {
|
||||
if (!input) {
|
||||
return input;
|
||||
}
|
||||
return input.replace(/\\/g, "/").replace(_DRIVE_LETTER_START_RE, (r) => r.toUpperCase());
|
||||
}
|
||||
|
||||
const _UNC_REGEX = /^[/\\]{2}/;
|
||||
const _IS_ABSOLUTE_RE = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/;
|
||||
const _DRIVE_LETTER_RE = /^[A-Za-z]:$/;
|
||||
const normalize = function(path) {
|
||||
if (path.length === 0) {
|
||||
return ".";
|
||||
}
|
||||
path = normalizeWindowsPath(path);
|
||||
const isUNCPath = path.match(_UNC_REGEX);
|
||||
const isPathAbsolute = isAbsolute(path);
|
||||
const trailingSeparator = path[path.length - 1] === "/";
|
||||
path = normalizeString(path, !isPathAbsolute);
|
||||
if (path.length === 0) {
|
||||
if (isPathAbsolute) {
|
||||
return "/";
|
||||
}
|
||||
return trailingSeparator ? "./" : ".";
|
||||
}
|
||||
if (trailingSeparator) {
|
||||
path += "/";
|
||||
}
|
||||
if (_DRIVE_LETTER_RE.test(path)) {
|
||||
path += "/";
|
||||
}
|
||||
if (isUNCPath) {
|
||||
if (!isPathAbsolute) {
|
||||
return `//./${path}`;
|
||||
}
|
||||
return `//${path}`;
|
||||
}
|
||||
return isPathAbsolute && !isAbsolute(path) ? `/${path}` : path;
|
||||
};
|
||||
const join = function(...arguments_) {
|
||||
if (arguments_.length === 0) {
|
||||
return ".";
|
||||
}
|
||||
let joined;
|
||||
for (const argument of arguments_) {
|
||||
if (argument && argument.length > 0) {
|
||||
if (joined === void 0) {
|
||||
joined = argument;
|
||||
} else {
|
||||
joined += `/${argument}`;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (joined === void 0) {
|
||||
return ".";
|
||||
}
|
||||
return normalize(joined.replace(/\/\/+/g, "/"));
|
||||
};
|
||||
function cwd() {
|
||||
if (typeof process !== "undefined" && typeof process.cwd === "function") {
|
||||
return process.cwd().replace(/\\/g, "/");
|
||||
}
|
||||
return "/";
|
||||
}
|
||||
const resolve = function(...arguments_) {
|
||||
arguments_ = arguments_.map((argument) => normalizeWindowsPath(argument));
|
||||
let resolvedPath = "";
|
||||
let resolvedAbsolute = false;
|
||||
for (let index = arguments_.length - 1; index >= -1 && !resolvedAbsolute; index--) {
|
||||
const path = index >= 0 ? arguments_[index] : cwd();
|
||||
if (!path || path.length === 0) {
|
||||
continue;
|
||||
}
|
||||
resolvedPath = `${path}/${resolvedPath}`;
|
||||
resolvedAbsolute = isAbsolute(path);
|
||||
}
|
||||
resolvedPath = normalizeString(resolvedPath, !resolvedAbsolute);
|
||||
if (resolvedAbsolute && !isAbsolute(resolvedPath)) {
|
||||
return `/${resolvedPath}`;
|
||||
}
|
||||
return resolvedPath.length > 0 ? resolvedPath : ".";
|
||||
};
|
||||
function normalizeString(path, allowAboveRoot) {
|
||||
let res = "";
|
||||
let lastSegmentLength = 0;
|
||||
let lastSlash = -1;
|
||||
let dots = 0;
|
||||
let char = null;
|
||||
for (let index = 0; index <= path.length; ++index) {
|
||||
if (index < path.length) {
|
||||
char = path[index];
|
||||
} else if (char === "/") {
|
||||
break;
|
||||
} else {
|
||||
char = "/";
|
||||
}
|
||||
if (char === "/") {
|
||||
if (lastSlash === index - 1 || dots === 1) ; else if (dots === 2) {
|
||||
if (res.length < 2 || lastSegmentLength !== 2 || res[res.length - 1] !== "." || res[res.length - 2] !== ".") {
|
||||
if (res.length > 2) {
|
||||
const lastSlashIndex = res.lastIndexOf("/");
|
||||
if (lastSlashIndex === -1) {
|
||||
res = "";
|
||||
lastSegmentLength = 0;
|
||||
} else {
|
||||
res = res.slice(0, lastSlashIndex);
|
||||
lastSegmentLength = res.length - 1 - res.lastIndexOf("/");
|
||||
}
|
||||
lastSlash = index;
|
||||
dots = 0;
|
||||
continue;
|
||||
} else if (res.length > 0) {
|
||||
res = "";
|
||||
lastSegmentLength = 0;
|
||||
lastSlash = index;
|
||||
dots = 0;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (allowAboveRoot) {
|
||||
res += res.length > 0 ? "/.." : "..";
|
||||
lastSegmentLength = 2;
|
||||
}
|
||||
} else {
|
||||
if (res.length > 0) {
|
||||
res += `/${path.slice(lastSlash + 1, index)}`;
|
||||
} else {
|
||||
res = path.slice(lastSlash + 1, index);
|
||||
}
|
||||
lastSegmentLength = index - lastSlash - 1;
|
||||
}
|
||||
lastSlash = index;
|
||||
dots = 0;
|
||||
} else if (char === "." && dots !== -1) {
|
||||
++dots;
|
||||
} else {
|
||||
dots = -1;
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
const isAbsolute = function(p) {
|
||||
return _IS_ABSOLUTE_RE.test(p);
|
||||
};
|
||||
const _EXTNAME_RE = /.(\.[^./]+)$/;
|
||||
const extname = function(p) {
|
||||
const match = _EXTNAME_RE.exec(normalizeWindowsPath(p));
|
||||
return match && match[1] || "";
|
||||
};
|
||||
const dirname = function(p) {
|
||||
const segments = normalizeWindowsPath(p).replace(/\/$/, "").split("/").slice(0, -1);
|
||||
if (segments.length === 1 && _DRIVE_LETTER_RE.test(segments[0])) {
|
||||
segments[0] += "/";
|
||||
}
|
||||
return segments.join("/") || (isAbsolute(p) ? "/" : ".");
|
||||
};
|
||||
const basename = function(p, extension) {
|
||||
const lastSegment = normalizeWindowsPath(p).split("/").pop();
|
||||
return extension && lastSegment.endsWith(extension) ? lastSegment.slice(0, -extension.length) : lastSegment;
|
||||
};
|
||||
|
||||
export { basename as b, dirname as d, extname as e, isAbsolute as i, join as j, resolve as r };
|
||||
+171
@@ -0,0 +1,171 @@
|
||||
class MockerRegistry {
|
||||
registry = /* @__PURE__ */ new Map();
|
||||
clear() {
|
||||
this.registry.clear();
|
||||
}
|
||||
keys() {
|
||||
return this.registry.keys();
|
||||
}
|
||||
add(mock) {
|
||||
this.registry.set(mock.url, mock);
|
||||
}
|
||||
register(typeOrEvent, raw, url, factoryOrRedirect) {
|
||||
const type = typeof typeOrEvent === "object" ? typeOrEvent.type : typeOrEvent;
|
||||
if (typeof typeOrEvent === "object") {
|
||||
const event = typeOrEvent;
|
||||
if (event instanceof AutomockedModule || event instanceof AutospiedModule || event instanceof ManualMockedModule || event instanceof RedirectedModule) {
|
||||
throw new TypeError(
|
||||
`[vitest] Cannot register a mock that is already defined. Expected a JSON representation from \`MockedModule.toJSON\`, instead got "${event.type}". Use "registry.add()" to update a mock instead.`
|
||||
);
|
||||
}
|
||||
if (event.type === "automock") {
|
||||
const module = AutomockedModule.fromJSON(event);
|
||||
this.add(module);
|
||||
return module;
|
||||
} else if (event.type === "autospy") {
|
||||
const module = AutospiedModule.fromJSON(event);
|
||||
this.add(module);
|
||||
return module;
|
||||
} else if (event.type === "redirect") {
|
||||
const module = RedirectedModule.fromJSON(event);
|
||||
this.add(module);
|
||||
return module;
|
||||
} else if (event.type === "manual") {
|
||||
throw new Error(`Cannot set serialized manual mock. Define a factory function manually with \`ManualMockedModule.fromJSON()\`.`);
|
||||
} else {
|
||||
throw new Error(`Unknown mock type: ${event.type}`);
|
||||
}
|
||||
}
|
||||
if (typeof raw !== "string") {
|
||||
throw new TypeError("[vitest] Mocks require a raw string.");
|
||||
}
|
||||
if (typeof url !== "string") {
|
||||
throw new TypeError("[vitest] Mocks require a url string.");
|
||||
}
|
||||
if (type === "manual") {
|
||||
if (typeof factoryOrRedirect !== "function") {
|
||||
throw new TypeError("[vitest] Manual mocks require a factory function.");
|
||||
}
|
||||
const mock = new ManualMockedModule(raw, url, factoryOrRedirect);
|
||||
this.add(mock);
|
||||
return mock;
|
||||
} else if (type === "automock" || type === "autospy") {
|
||||
const mock = type === "automock" ? new AutomockedModule(raw, url) : new AutospiedModule(raw, url);
|
||||
this.add(mock);
|
||||
return mock;
|
||||
} else if (type === "redirect") {
|
||||
if (typeof factoryOrRedirect !== "string") {
|
||||
throw new TypeError("[vitest] Redirect mocks require a redirect string.");
|
||||
}
|
||||
const mock = new RedirectedModule(raw, url, factoryOrRedirect);
|
||||
this.add(mock);
|
||||
return mock;
|
||||
} else {
|
||||
throw new Error(`[vitest] Unknown mock type: ${type}`);
|
||||
}
|
||||
}
|
||||
delete(id) {
|
||||
this.registry.delete(id);
|
||||
}
|
||||
get(id) {
|
||||
return this.registry.get(id);
|
||||
}
|
||||
has(id) {
|
||||
return this.registry.has(id);
|
||||
}
|
||||
}
|
||||
class AutomockedModule {
|
||||
constructor(raw, url) {
|
||||
this.raw = raw;
|
||||
this.url = url;
|
||||
}
|
||||
type = "automock";
|
||||
static fromJSON(data) {
|
||||
return new AutospiedModule(data.raw, data.url);
|
||||
}
|
||||
toJSON() {
|
||||
return {
|
||||
type: this.type,
|
||||
url: this.url,
|
||||
raw: this.raw
|
||||
};
|
||||
}
|
||||
}
|
||||
class AutospiedModule {
|
||||
constructor(raw, url) {
|
||||
this.raw = raw;
|
||||
this.url = url;
|
||||
}
|
||||
type = "autospy";
|
||||
static fromJSON(data) {
|
||||
return new AutospiedModule(data.raw, data.url);
|
||||
}
|
||||
toJSON() {
|
||||
return {
|
||||
type: this.type,
|
||||
url: this.url,
|
||||
raw: this.raw
|
||||
};
|
||||
}
|
||||
}
|
||||
class RedirectedModule {
|
||||
constructor(raw, url, redirect) {
|
||||
this.raw = raw;
|
||||
this.url = url;
|
||||
this.redirect = redirect;
|
||||
}
|
||||
type = "redirect";
|
||||
static fromJSON(data) {
|
||||
return new RedirectedModule(data.raw, data.url, data.redirect);
|
||||
}
|
||||
toJSON() {
|
||||
return {
|
||||
type: this.type,
|
||||
url: this.url,
|
||||
raw: this.raw,
|
||||
redirect: this.redirect
|
||||
};
|
||||
}
|
||||
}
|
||||
class ManualMockedModule {
|
||||
constructor(raw, url, factory) {
|
||||
this.raw = raw;
|
||||
this.url = url;
|
||||
this.factory = factory;
|
||||
}
|
||||
cache;
|
||||
type = "manual";
|
||||
async resolve() {
|
||||
if (this.cache) {
|
||||
return this.cache;
|
||||
}
|
||||
let exports;
|
||||
try {
|
||||
exports = await this.factory();
|
||||
} catch (err) {
|
||||
const vitestError = new Error(
|
||||
'[vitest] There was an error when mocking a module. If you are using "vi.mock" factory, make sure there are no top level variables inside, since this call is hoisted to top of the file. Read more: https://vitest.dev/api/vi.html#vi-mock'
|
||||
);
|
||||
vitestError.cause = err;
|
||||
throw vitestError;
|
||||
}
|
||||
if (exports === null || typeof exports !== "object" || Array.isArray(exports)) {
|
||||
throw new TypeError(
|
||||
`[vitest] vi.mock("${this.raw}", factory?: () => unknown) is not returning an object. Did you mean to return an object with a "default" key?`
|
||||
);
|
||||
}
|
||||
return this.cache = exports;
|
||||
}
|
||||
static fromJSON(data, factory) {
|
||||
return new ManualMockedModule(data.raw, data.url, factory);
|
||||
}
|
||||
toJSON() {
|
||||
return {
|
||||
type: this.type,
|
||||
url: this.url,
|
||||
raw: this.raw
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export { AutomockedModule as A, MockerRegistry as M, RedirectedModule as R, ManualMockedModule as a, AutospiedModule as b };
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
const postfixRE = /[?#].*$/;
|
||||
function cleanUrl(url) {
|
||||
return url.replace(postfixRE, "");
|
||||
}
|
||||
|
||||
export { cleanUrl as c };
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
import { M as MockedModuleType } from './types-DZOqTgiN.js';
|
||||
export { A as AutomockedModule, d as AutomockedModuleSerialized, a as AutospiedModule, e as AutospiedModuleSerialized, b as ManualMockedModule, f as ManualMockedModuleSerialized, g as MockedModule, h as MockedModuleSerialized, c as MockerRegistry, j as ModuleMockFactory, k as ModuleMockFactoryWithHelper, l as ModuleMockOptions, R as RedirectedModule, i as RedirectedModuleSerialized } from './types-DZOqTgiN.js';
|
||||
|
||||
type Key = string | symbol;
|
||||
interface MockObjectOptions {
|
||||
type: MockedModuleType;
|
||||
globalConstructors: GlobalConstructors;
|
||||
spyOn: (obj: any, prop: Key) => any;
|
||||
}
|
||||
declare function mockObject(options: MockObjectOptions, object: Record<Key, any>, mockExports?: Record<Key, any>): Record<Key, any>;
|
||||
interface GlobalConstructors {
|
||||
Object: ObjectConstructor;
|
||||
Function: FunctionConstructor;
|
||||
RegExp: RegExpConstructor;
|
||||
Array: ArrayConstructor;
|
||||
Map: MapConstructor;
|
||||
}
|
||||
|
||||
export { type GlobalConstructors, type MockObjectOptions, MockedModuleType, mockObject };
|
||||
+158
@@ -0,0 +1,158 @@
|
||||
export { A as AutomockedModule, b as AutospiedModule, a as ManualMockedModule, M as MockerRegistry, R as RedirectedModule } from './chunk-registry.js';
|
||||
|
||||
function mockObject(options, object, mockExports = {}) {
|
||||
const finalizers = new Array();
|
||||
const refs = new RefTracker();
|
||||
const define = (container, key, value) => {
|
||||
try {
|
||||
container[key] = value;
|
||||
return true;
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
const mockPropertiesOf = (container, newContainer) => {
|
||||
const containerType = getType(container);
|
||||
const isModule = containerType === "Module" || !!container.__esModule;
|
||||
for (const { key: property, descriptor } of getAllMockableProperties(
|
||||
container,
|
||||
isModule,
|
||||
options.globalConstructors
|
||||
)) {
|
||||
if (!isModule && descriptor.get) {
|
||||
try {
|
||||
Object.defineProperty(newContainer, property, descriptor);
|
||||
} catch {
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (isSpecialProp(property, containerType)) {
|
||||
continue;
|
||||
}
|
||||
const value = container[property];
|
||||
const refId = refs.getId(value);
|
||||
if (refId !== void 0) {
|
||||
finalizers.push(
|
||||
() => define(newContainer, property, refs.getMockedValue(refId))
|
||||
);
|
||||
continue;
|
||||
}
|
||||
const type = getType(value);
|
||||
if (Array.isArray(value)) {
|
||||
define(newContainer, property, []);
|
||||
continue;
|
||||
}
|
||||
const isFunction = type.includes("Function") && typeof value === "function";
|
||||
if ((!isFunction || value.__isMockFunction) && type !== "Object" && type !== "Module") {
|
||||
define(newContainer, property, value);
|
||||
continue;
|
||||
}
|
||||
if (!define(newContainer, property, isFunction ? value : {})) {
|
||||
continue;
|
||||
}
|
||||
if (isFunction) {
|
||||
let mockFunction2 = function() {
|
||||
if (this instanceof newContainer[property]) {
|
||||
for (const { key, descriptor: descriptor2 } of getAllMockableProperties(
|
||||
this,
|
||||
false,
|
||||
options.globalConstructors
|
||||
)) {
|
||||
if (descriptor2.get) {
|
||||
continue;
|
||||
}
|
||||
const value2 = this[key];
|
||||
const type2 = getType(value2);
|
||||
const isFunction2 = type2.includes("Function") && typeof value2 === "function";
|
||||
if (isFunction2) {
|
||||
const original = this[key];
|
||||
const mock2 = spyOn(this, key).mockImplementation(original);
|
||||
mock2.mockRestore = () => {
|
||||
mock2.mockReset();
|
||||
mock2.mockImplementation(original);
|
||||
return mock2;
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
if (!options.spyOn) {
|
||||
throw new Error(
|
||||
"[@vitest/mocker] `spyOn` is not defined. This is a Vitest error. Please open a new issue with reproduction."
|
||||
);
|
||||
}
|
||||
const spyOn = options.spyOn;
|
||||
const mock = spyOn(newContainer, property);
|
||||
if (options.type === "automock") {
|
||||
mock.mockImplementation(mockFunction2);
|
||||
mock.mockRestore = () => {
|
||||
mock.mockReset();
|
||||
mock.mockImplementation(mockFunction2);
|
||||
return mock;
|
||||
};
|
||||
}
|
||||
Object.defineProperty(newContainer[property], "length", { value: 0 });
|
||||
}
|
||||
refs.track(value, newContainer[property]);
|
||||
mockPropertiesOf(value, newContainer[property]);
|
||||
}
|
||||
};
|
||||
const mockedObject = mockExports;
|
||||
mockPropertiesOf(object, mockedObject);
|
||||
for (const finalizer of finalizers) {
|
||||
finalizer();
|
||||
}
|
||||
return mockedObject;
|
||||
}
|
||||
class RefTracker {
|
||||
idMap = /* @__PURE__ */ new Map();
|
||||
mockedValueMap = /* @__PURE__ */ new Map();
|
||||
getId(value) {
|
||||
return this.idMap.get(value);
|
||||
}
|
||||
getMockedValue(id) {
|
||||
return this.mockedValueMap.get(id);
|
||||
}
|
||||
track(originalValue, mockedValue) {
|
||||
const newId = this.idMap.size;
|
||||
this.idMap.set(originalValue, newId);
|
||||
this.mockedValueMap.set(newId, mockedValue);
|
||||
return newId;
|
||||
}
|
||||
}
|
||||
function getType(value) {
|
||||
return Object.prototype.toString.apply(value).slice(8, -1);
|
||||
}
|
||||
function isSpecialProp(prop, parentType) {
|
||||
return parentType.includes("Function") && typeof prop === "string" && ["arguments", "callee", "caller", "length", "name"].includes(prop);
|
||||
}
|
||||
function getAllMockableProperties(obj, isModule, constructors) {
|
||||
const { Map: Map2, Object: Object2, Function, RegExp, Array: Array2 } = constructors;
|
||||
const allProps = new Map2();
|
||||
let curr = obj;
|
||||
do {
|
||||
if (curr === Object2.prototype || curr === Function.prototype || curr === RegExp.prototype) {
|
||||
break;
|
||||
}
|
||||
collectOwnProperties(curr, (key) => {
|
||||
const descriptor = Object2.getOwnPropertyDescriptor(curr, key);
|
||||
if (descriptor) {
|
||||
allProps.set(key, { key, descriptor });
|
||||
}
|
||||
});
|
||||
} while (curr = Object2.getPrototypeOf(curr));
|
||||
if (isModule && !allProps.has("default") && "default" in obj) {
|
||||
const descriptor = Object2.getOwnPropertyDescriptor(obj, "default");
|
||||
if (descriptor) {
|
||||
allProps.set("default", { key: "default", descriptor });
|
||||
}
|
||||
}
|
||||
return Array2.from(allProps.values());
|
||||
}
|
||||
function collectOwnProperties(obj, collector) {
|
||||
const collect = typeof collector === "function" ? collector : (key) => collector.add(key);
|
||||
Object.getOwnPropertyNames(obj).forEach(collect);
|
||||
Object.getOwnPropertySymbols(obj).forEach(collect);
|
||||
}
|
||||
|
||||
export { mockObject };
|
||||
+78
@@ -0,0 +1,78 @@
|
||||
import { MaybeMockedDeep } from '@vitest/spy';
|
||||
import { l as ModuleMockOptions, k as ModuleMockFactoryWithHelper, g as MockedModule, c as MockerRegistry, M as MockedModuleType } from './types-DZOqTgiN.js';
|
||||
|
||||
interface CompilerHintsOptions {
|
||||
/**
|
||||
* This is the key used to access the globalThis object in the worker.
|
||||
* Unlike `globalThisAccessor` in other APIs, this is not injected into the script.
|
||||
* ```ts
|
||||
* // globalThisKey: '__my_variable__' produces:
|
||||
* globalThis['__my_variable__']
|
||||
* // globalThisKey: '"__my_variable__"' produces:
|
||||
* globalThis['"__my_variable__"'] // notice double quotes
|
||||
* ```
|
||||
* @default '__vitest_mocker__'
|
||||
*/
|
||||
globalThisKey?: string;
|
||||
}
|
||||
interface ModuleMockerCompilerHints {
|
||||
hoisted: <T>(factory: () => T) => T;
|
||||
mock: (path: string | Promise<unknown>, factory?: ModuleMockOptions | ModuleMockFactoryWithHelper) => void;
|
||||
unmock: (path: string | Promise<unknown>) => void;
|
||||
doMock: (path: string | Promise<unknown>, factory?: ModuleMockOptions | ModuleMockFactoryWithHelper) => void;
|
||||
doUnmock: (path: string | Promise<unknown>) => void;
|
||||
importActual: <T>(path: string) => Promise<T>;
|
||||
importMock: <T>(path: string) => Promise<MaybeMockedDeep<T>>;
|
||||
}
|
||||
declare function createCompilerHints(options?: CompilerHintsOptions): ModuleMockerCompilerHints;
|
||||
|
||||
interface ModuleMockerInterceptor {
|
||||
register: (module: MockedModule) => Promise<void>;
|
||||
delete: (url: string) => Promise<void>;
|
||||
invalidate: () => void;
|
||||
}
|
||||
|
||||
declare class ModuleMocker {
|
||||
private interceptor;
|
||||
private rpc;
|
||||
private spyOn;
|
||||
private config;
|
||||
protected registry: MockerRegistry;
|
||||
private queue;
|
||||
private mockedIds;
|
||||
constructor(interceptor: ModuleMockerInterceptor, rpc: ModuleMockerRPC, spyOn: (obj: any, method: string | symbol) => any, config: ModuleMockerConfig);
|
||||
prepare(): Promise<void>;
|
||||
resolveFactoryModule(id: string): Promise<Record<string | symbol, any>>;
|
||||
getFactoryModule(id: string): any;
|
||||
invalidate(): Promise<void>;
|
||||
importActual<T>(id: string, importer: string): Promise<T>;
|
||||
importMock<T>(rawId: string, importer: string): Promise<T>;
|
||||
mockObject(object: Record<string | symbol, any>, moduleType?: MockedModuleType): Record<string | symbol, any>;
|
||||
queueMock(rawId: string, importer: string, factoryOrOptions?: ModuleMockOptions | (() => any)): void;
|
||||
queueUnmock(id: string, importer: string): void;
|
||||
wrapDynamicImport<T>(moduleFactory: () => Promise<T>): Promise<T>;
|
||||
private resolveMockPath;
|
||||
}
|
||||
interface ResolveIdResult {
|
||||
id: string;
|
||||
url: string;
|
||||
optimized: boolean;
|
||||
}
|
||||
interface ResolveMockResul {
|
||||
mockType: MockedModuleType;
|
||||
resolvedId: string;
|
||||
redirectUrl?: string | null;
|
||||
needsInterop?: boolean;
|
||||
}
|
||||
interface ModuleMockerRPC {
|
||||
invalidate: (ids: string[]) => Promise<void>;
|
||||
resolveId: (id: string, importer: string) => Promise<ResolveIdResult | null>;
|
||||
resolveMock: (id: string, importer: string, options: {
|
||||
mock: 'spy' | 'factory' | 'auto';
|
||||
}) => Promise<ResolveMockResul>;
|
||||
}
|
||||
interface ModuleMockerConfig {
|
||||
root: string;
|
||||
}
|
||||
|
||||
export { type CompilerHintsOptions as C, type ModuleMockerInterceptor as M, type ResolveIdResult as R, type ModuleMockerCompilerHints as a, ModuleMocker as b, createCompilerHints as c, type ModuleMockerConfig as d, type ModuleMockerRPC as e, type ResolveMockResul as f };
|
||||
+801
@@ -0,0 +1,801 @@
|
||||
import { Plugin, Rollup, ViteDevServer } from 'vite';
|
||||
import MagicString, { SourceMap } from 'magic-string';
|
||||
export { findMockRedirect } from './redirect.js';
|
||||
|
||||
interface AutomockPluginOptions {
|
||||
/**
|
||||
* @default "__vitest_mocker__"
|
||||
*/
|
||||
globalThisAccessor?: string;
|
||||
}
|
||||
declare function automockPlugin(options?: AutomockPluginOptions): Plugin;
|
||||
declare function automockModule(code: string, mockType: 'automock' | 'autospy', parse: (code: string) => any, options?: AutomockPluginOptions): MagicString;
|
||||
|
||||
interface DynamicImportPluginOptions {
|
||||
/**
|
||||
* @default `"__vitest_mocker__"`
|
||||
*/
|
||||
globalThisAccessor?: string;
|
||||
filter?: (id: string) => boolean;
|
||||
}
|
||||
declare function dynamicImportPlugin(options?: DynamicImportPluginOptions): Plugin;
|
||||
|
||||
// This definition file follows a somewhat unusual format. ESTree allows
|
||||
// runtime type checks based on the `type` parameter. In order to explain this
|
||||
// to typescript we want to use discriminated union types:
|
||||
// https://github.com/Microsoft/TypeScript/pull/9163
|
||||
//
|
||||
// For ESTree this is a bit tricky because the high level interfaces like
|
||||
// Node or Function are pulling double duty. We want to pass common fields down
|
||||
// to the interfaces that extend them (like Identifier or
|
||||
// ArrowFunctionExpression), but you can't extend a type union or enforce
|
||||
// common fields on them. So we've split the high level interfaces into two
|
||||
// types, a base type which passes down inherited fields, and a type union of
|
||||
// all types which extend the base type. Only the type union is exported, and
|
||||
// the union is how other types refer to the collection of inheriting types.
|
||||
//
|
||||
// This makes the definitions file here somewhat more difficult to maintain,
|
||||
// but it has the notable advantage of making ESTree much easier to use as
|
||||
// an end user.
|
||||
|
||||
interface BaseNodeWithoutComments {
|
||||
// Every leaf interface that extends BaseNode must specify a type property.
|
||||
// The type property should be a string literal. For example, Identifier
|
||||
// has: `type: "Identifier"`
|
||||
type: string;
|
||||
loc?: SourceLocation | null | undefined;
|
||||
range?: [number, number] | undefined;
|
||||
}
|
||||
|
||||
interface BaseNode extends BaseNodeWithoutComments {
|
||||
leadingComments?: Comment[] | undefined;
|
||||
trailingComments?: Comment[] | undefined;
|
||||
}
|
||||
|
||||
interface NodeMap {
|
||||
AssignmentProperty: AssignmentProperty;
|
||||
CatchClause: CatchClause;
|
||||
Class: Class;
|
||||
ClassBody: ClassBody;
|
||||
Expression: Expression;
|
||||
Function: Function;
|
||||
Identifier: Identifier;
|
||||
Literal: Literal;
|
||||
MethodDefinition: MethodDefinition;
|
||||
ModuleDeclaration: ModuleDeclaration;
|
||||
ModuleSpecifier: ModuleSpecifier;
|
||||
Pattern: Pattern;
|
||||
PrivateIdentifier: PrivateIdentifier;
|
||||
Program: Program;
|
||||
Property: Property;
|
||||
PropertyDefinition: PropertyDefinition;
|
||||
SpreadElement: SpreadElement;
|
||||
Statement: Statement;
|
||||
Super: Super;
|
||||
SwitchCase: SwitchCase;
|
||||
TemplateElement: TemplateElement;
|
||||
VariableDeclarator: VariableDeclarator;
|
||||
}
|
||||
|
||||
type Node$1 = NodeMap[keyof NodeMap];
|
||||
|
||||
interface Comment extends BaseNodeWithoutComments {
|
||||
type: "Line" | "Block";
|
||||
value: string;
|
||||
}
|
||||
|
||||
interface SourceLocation {
|
||||
source?: string | null | undefined;
|
||||
start: Position;
|
||||
end: Position;
|
||||
}
|
||||
|
||||
interface Position {
|
||||
/** >= 1 */
|
||||
line: number;
|
||||
/** >= 0 */
|
||||
column: number;
|
||||
}
|
||||
|
||||
interface Program extends BaseNode {
|
||||
type: "Program";
|
||||
sourceType: "script" | "module";
|
||||
body: Array<Directive | Statement | ModuleDeclaration>;
|
||||
comments?: Comment[] | undefined;
|
||||
}
|
||||
|
||||
interface Directive extends BaseNode {
|
||||
type: "ExpressionStatement";
|
||||
expression: Literal;
|
||||
directive: string;
|
||||
}
|
||||
|
||||
interface BaseFunction extends BaseNode {
|
||||
params: Pattern[];
|
||||
generator?: boolean | undefined;
|
||||
async?: boolean | undefined;
|
||||
// The body is either BlockStatement or Expression because arrow functions
|
||||
// can have a body that's either. FunctionDeclarations and
|
||||
// FunctionExpressions have only BlockStatement bodies.
|
||||
body: BlockStatement | Expression;
|
||||
}
|
||||
|
||||
type Function = FunctionDeclaration | FunctionExpression | ArrowFunctionExpression;
|
||||
|
||||
type Statement =
|
||||
| ExpressionStatement
|
||||
| BlockStatement
|
||||
| StaticBlock
|
||||
| EmptyStatement
|
||||
| DebuggerStatement
|
||||
| WithStatement
|
||||
| ReturnStatement
|
||||
| LabeledStatement
|
||||
| BreakStatement
|
||||
| ContinueStatement
|
||||
| IfStatement
|
||||
| SwitchStatement
|
||||
| ThrowStatement
|
||||
| TryStatement
|
||||
| WhileStatement
|
||||
| DoWhileStatement
|
||||
| ForStatement
|
||||
| ForInStatement
|
||||
| ForOfStatement
|
||||
| Declaration;
|
||||
|
||||
interface BaseStatement extends BaseNode {}
|
||||
|
||||
interface EmptyStatement extends BaseStatement {
|
||||
type: "EmptyStatement";
|
||||
}
|
||||
|
||||
interface BlockStatement extends BaseStatement {
|
||||
type: "BlockStatement";
|
||||
body: Statement[];
|
||||
innerComments?: Comment[] | undefined;
|
||||
}
|
||||
|
||||
interface StaticBlock extends Omit<BlockStatement, "type"> {
|
||||
type: "StaticBlock";
|
||||
}
|
||||
|
||||
interface ExpressionStatement extends BaseStatement {
|
||||
type: "ExpressionStatement";
|
||||
expression: Expression;
|
||||
}
|
||||
|
||||
interface IfStatement extends BaseStatement {
|
||||
type: "IfStatement";
|
||||
test: Expression;
|
||||
consequent: Statement;
|
||||
alternate?: Statement | null | undefined;
|
||||
}
|
||||
|
||||
interface LabeledStatement extends BaseStatement {
|
||||
type: "LabeledStatement";
|
||||
label: Identifier;
|
||||
body: Statement;
|
||||
}
|
||||
|
||||
interface BreakStatement extends BaseStatement {
|
||||
type: "BreakStatement";
|
||||
label?: Identifier | null | undefined;
|
||||
}
|
||||
|
||||
interface ContinueStatement extends BaseStatement {
|
||||
type: "ContinueStatement";
|
||||
label?: Identifier | null | undefined;
|
||||
}
|
||||
|
||||
interface WithStatement extends BaseStatement {
|
||||
type: "WithStatement";
|
||||
object: Expression;
|
||||
body: Statement;
|
||||
}
|
||||
|
||||
interface SwitchStatement extends BaseStatement {
|
||||
type: "SwitchStatement";
|
||||
discriminant: Expression;
|
||||
cases: SwitchCase[];
|
||||
}
|
||||
|
||||
interface ReturnStatement extends BaseStatement {
|
||||
type: "ReturnStatement";
|
||||
argument?: Expression | null | undefined;
|
||||
}
|
||||
|
||||
interface ThrowStatement extends BaseStatement {
|
||||
type: "ThrowStatement";
|
||||
argument: Expression;
|
||||
}
|
||||
|
||||
interface TryStatement extends BaseStatement {
|
||||
type: "TryStatement";
|
||||
block: BlockStatement;
|
||||
handler?: CatchClause | null | undefined;
|
||||
finalizer?: BlockStatement | null | undefined;
|
||||
}
|
||||
|
||||
interface WhileStatement extends BaseStatement {
|
||||
type: "WhileStatement";
|
||||
test: Expression;
|
||||
body: Statement;
|
||||
}
|
||||
|
||||
interface DoWhileStatement extends BaseStatement {
|
||||
type: "DoWhileStatement";
|
||||
body: Statement;
|
||||
test: Expression;
|
||||
}
|
||||
|
||||
interface ForStatement extends BaseStatement {
|
||||
type: "ForStatement";
|
||||
init?: VariableDeclaration | Expression | null | undefined;
|
||||
test?: Expression | null | undefined;
|
||||
update?: Expression | null | undefined;
|
||||
body: Statement;
|
||||
}
|
||||
|
||||
interface BaseForXStatement extends BaseStatement {
|
||||
left: VariableDeclaration | Pattern;
|
||||
right: Expression;
|
||||
body: Statement;
|
||||
}
|
||||
|
||||
interface ForInStatement extends BaseForXStatement {
|
||||
type: "ForInStatement";
|
||||
}
|
||||
|
||||
interface DebuggerStatement extends BaseStatement {
|
||||
type: "DebuggerStatement";
|
||||
}
|
||||
|
||||
type Declaration = FunctionDeclaration | VariableDeclaration | ClassDeclaration;
|
||||
|
||||
interface BaseDeclaration extends BaseStatement {}
|
||||
|
||||
interface MaybeNamedFunctionDeclaration extends BaseFunction, BaseDeclaration {
|
||||
type: "FunctionDeclaration";
|
||||
/** It is null when a function declaration is a part of the `export default function` statement */
|
||||
id: Identifier | null;
|
||||
body: BlockStatement;
|
||||
}
|
||||
|
||||
interface FunctionDeclaration extends MaybeNamedFunctionDeclaration {
|
||||
id: Identifier;
|
||||
}
|
||||
|
||||
interface VariableDeclaration extends BaseDeclaration {
|
||||
type: "VariableDeclaration";
|
||||
declarations: VariableDeclarator[];
|
||||
kind: "var" | "let" | "const";
|
||||
}
|
||||
|
||||
interface VariableDeclarator extends BaseNode {
|
||||
type: "VariableDeclarator";
|
||||
id: Pattern;
|
||||
init?: Expression | null | undefined;
|
||||
}
|
||||
|
||||
interface ExpressionMap {
|
||||
ArrayExpression: ArrayExpression;
|
||||
ArrowFunctionExpression: ArrowFunctionExpression;
|
||||
AssignmentExpression: AssignmentExpression;
|
||||
AwaitExpression: AwaitExpression;
|
||||
BinaryExpression: BinaryExpression;
|
||||
CallExpression: CallExpression;
|
||||
ChainExpression: ChainExpression;
|
||||
ClassExpression: ClassExpression;
|
||||
ConditionalExpression: ConditionalExpression;
|
||||
FunctionExpression: FunctionExpression;
|
||||
Identifier: Identifier;
|
||||
ImportExpression: ImportExpression;
|
||||
Literal: Literal;
|
||||
LogicalExpression: LogicalExpression;
|
||||
MemberExpression: MemberExpression;
|
||||
MetaProperty: MetaProperty;
|
||||
NewExpression: NewExpression;
|
||||
ObjectExpression: ObjectExpression;
|
||||
SequenceExpression: SequenceExpression;
|
||||
TaggedTemplateExpression: TaggedTemplateExpression;
|
||||
TemplateLiteral: TemplateLiteral;
|
||||
ThisExpression: ThisExpression;
|
||||
UnaryExpression: UnaryExpression;
|
||||
UpdateExpression: UpdateExpression;
|
||||
YieldExpression: YieldExpression;
|
||||
}
|
||||
|
||||
type Expression = ExpressionMap[keyof ExpressionMap];
|
||||
|
||||
interface BaseExpression extends BaseNode {}
|
||||
|
||||
type ChainElement = SimpleCallExpression | MemberExpression;
|
||||
|
||||
interface ChainExpression extends BaseExpression {
|
||||
type: "ChainExpression";
|
||||
expression: ChainElement;
|
||||
}
|
||||
|
||||
interface ThisExpression extends BaseExpression {
|
||||
type: "ThisExpression";
|
||||
}
|
||||
|
||||
interface ArrayExpression extends BaseExpression {
|
||||
type: "ArrayExpression";
|
||||
elements: Array<Expression | SpreadElement | null>;
|
||||
}
|
||||
|
||||
interface ObjectExpression extends BaseExpression {
|
||||
type: "ObjectExpression";
|
||||
properties: Array<Property | SpreadElement>;
|
||||
}
|
||||
|
||||
interface PrivateIdentifier extends BaseNode {
|
||||
type: "PrivateIdentifier";
|
||||
name: string;
|
||||
}
|
||||
|
||||
interface Property extends BaseNode {
|
||||
type: "Property";
|
||||
key: Expression | PrivateIdentifier;
|
||||
value: Expression | Pattern; // Could be an AssignmentProperty
|
||||
kind: "init" | "get" | "set";
|
||||
method: boolean;
|
||||
shorthand: boolean;
|
||||
computed: boolean;
|
||||
}
|
||||
|
||||
interface PropertyDefinition extends BaseNode {
|
||||
type: "PropertyDefinition";
|
||||
key: Expression | PrivateIdentifier;
|
||||
value?: Expression | null | undefined;
|
||||
computed: boolean;
|
||||
static: boolean;
|
||||
}
|
||||
|
||||
interface FunctionExpression extends BaseFunction, BaseExpression {
|
||||
id?: Identifier | null | undefined;
|
||||
type: "FunctionExpression";
|
||||
body: BlockStatement;
|
||||
}
|
||||
|
||||
interface SequenceExpression extends BaseExpression {
|
||||
type: "SequenceExpression";
|
||||
expressions: Expression[];
|
||||
}
|
||||
|
||||
interface UnaryExpression extends BaseExpression {
|
||||
type: "UnaryExpression";
|
||||
operator: UnaryOperator;
|
||||
prefix: true;
|
||||
argument: Expression;
|
||||
}
|
||||
|
||||
interface BinaryExpression extends BaseExpression {
|
||||
type: "BinaryExpression";
|
||||
operator: BinaryOperator;
|
||||
left: Expression | PrivateIdentifier;
|
||||
right: Expression;
|
||||
}
|
||||
|
||||
interface AssignmentExpression extends BaseExpression {
|
||||
type: "AssignmentExpression";
|
||||
operator: AssignmentOperator;
|
||||
left: Pattern | MemberExpression;
|
||||
right: Expression;
|
||||
}
|
||||
|
||||
interface UpdateExpression extends BaseExpression {
|
||||
type: "UpdateExpression";
|
||||
operator: UpdateOperator;
|
||||
argument: Expression;
|
||||
prefix: boolean;
|
||||
}
|
||||
|
||||
interface LogicalExpression extends BaseExpression {
|
||||
type: "LogicalExpression";
|
||||
operator: LogicalOperator;
|
||||
left: Expression;
|
||||
right: Expression;
|
||||
}
|
||||
|
||||
interface ConditionalExpression extends BaseExpression {
|
||||
type: "ConditionalExpression";
|
||||
test: Expression;
|
||||
alternate: Expression;
|
||||
consequent: Expression;
|
||||
}
|
||||
|
||||
interface BaseCallExpression extends BaseExpression {
|
||||
callee: Expression | Super;
|
||||
arguments: Array<Expression | SpreadElement>;
|
||||
}
|
||||
type CallExpression = SimpleCallExpression | NewExpression;
|
||||
|
||||
interface SimpleCallExpression extends BaseCallExpression {
|
||||
type: "CallExpression";
|
||||
optional: boolean;
|
||||
}
|
||||
|
||||
interface NewExpression extends BaseCallExpression {
|
||||
type: "NewExpression";
|
||||
}
|
||||
|
||||
interface MemberExpression extends BaseExpression, BasePattern {
|
||||
type: "MemberExpression";
|
||||
object: Expression | Super;
|
||||
property: Expression | PrivateIdentifier;
|
||||
computed: boolean;
|
||||
optional: boolean;
|
||||
}
|
||||
|
||||
type Pattern = Identifier | ObjectPattern | ArrayPattern | RestElement | AssignmentPattern | MemberExpression;
|
||||
|
||||
interface BasePattern extends BaseNode {}
|
||||
|
||||
interface SwitchCase extends BaseNode {
|
||||
type: "SwitchCase";
|
||||
test?: Expression | null | undefined;
|
||||
consequent: Statement[];
|
||||
}
|
||||
|
||||
interface CatchClause extends BaseNode {
|
||||
type: "CatchClause";
|
||||
param: Pattern | null;
|
||||
body: BlockStatement;
|
||||
}
|
||||
|
||||
interface Identifier extends BaseNode, BaseExpression, BasePattern {
|
||||
type: "Identifier";
|
||||
name: string;
|
||||
}
|
||||
|
||||
type Literal = SimpleLiteral | RegExpLiteral | BigIntLiteral;
|
||||
|
||||
interface SimpleLiteral extends BaseNode, BaseExpression {
|
||||
type: "Literal";
|
||||
value: string | boolean | number | null;
|
||||
raw?: string | undefined;
|
||||
}
|
||||
|
||||
interface RegExpLiteral extends BaseNode, BaseExpression {
|
||||
type: "Literal";
|
||||
value?: RegExp | null | undefined;
|
||||
regex: {
|
||||
pattern: string;
|
||||
flags: string;
|
||||
};
|
||||
raw?: string | undefined;
|
||||
}
|
||||
|
||||
interface BigIntLiteral extends BaseNode, BaseExpression {
|
||||
type: "Literal";
|
||||
value?: bigint | null | undefined;
|
||||
bigint: string;
|
||||
raw?: string | undefined;
|
||||
}
|
||||
|
||||
type UnaryOperator = "-" | "+" | "!" | "~" | "typeof" | "void" | "delete";
|
||||
|
||||
type BinaryOperator =
|
||||
| "=="
|
||||
| "!="
|
||||
| "==="
|
||||
| "!=="
|
||||
| "<"
|
||||
| "<="
|
||||
| ">"
|
||||
| ">="
|
||||
| "<<"
|
||||
| ">>"
|
||||
| ">>>"
|
||||
| "+"
|
||||
| "-"
|
||||
| "*"
|
||||
| "/"
|
||||
| "%"
|
||||
| "**"
|
||||
| "|"
|
||||
| "^"
|
||||
| "&"
|
||||
| "in"
|
||||
| "instanceof";
|
||||
|
||||
type LogicalOperator = "||" | "&&" | "??";
|
||||
|
||||
type AssignmentOperator =
|
||||
| "="
|
||||
| "+="
|
||||
| "-="
|
||||
| "*="
|
||||
| "/="
|
||||
| "%="
|
||||
| "**="
|
||||
| "<<="
|
||||
| ">>="
|
||||
| ">>>="
|
||||
| "|="
|
||||
| "^="
|
||||
| "&="
|
||||
| "||="
|
||||
| "&&="
|
||||
| "??=";
|
||||
|
||||
type UpdateOperator = "++" | "--";
|
||||
|
||||
interface ForOfStatement extends BaseForXStatement {
|
||||
type: "ForOfStatement";
|
||||
await: boolean;
|
||||
}
|
||||
|
||||
interface Super extends BaseNode {
|
||||
type: "Super";
|
||||
}
|
||||
|
||||
interface SpreadElement extends BaseNode {
|
||||
type: "SpreadElement";
|
||||
argument: Expression;
|
||||
}
|
||||
|
||||
interface ArrowFunctionExpression extends BaseExpression, BaseFunction {
|
||||
type: "ArrowFunctionExpression";
|
||||
expression: boolean;
|
||||
body: BlockStatement | Expression;
|
||||
}
|
||||
|
||||
interface YieldExpression extends BaseExpression {
|
||||
type: "YieldExpression";
|
||||
argument?: Expression | null | undefined;
|
||||
delegate: boolean;
|
||||
}
|
||||
|
||||
interface TemplateLiteral extends BaseExpression {
|
||||
type: "TemplateLiteral";
|
||||
quasis: TemplateElement[];
|
||||
expressions: Expression[];
|
||||
}
|
||||
|
||||
interface TaggedTemplateExpression extends BaseExpression {
|
||||
type: "TaggedTemplateExpression";
|
||||
tag: Expression;
|
||||
quasi: TemplateLiteral;
|
||||
}
|
||||
|
||||
interface TemplateElement extends BaseNode {
|
||||
type: "TemplateElement";
|
||||
tail: boolean;
|
||||
value: {
|
||||
/** It is null when the template literal is tagged and the text has an invalid escape (e.g. - tag`\unicode and \u{55}`) */
|
||||
cooked?: string | null | undefined;
|
||||
raw: string;
|
||||
};
|
||||
}
|
||||
|
||||
interface AssignmentProperty extends Property {
|
||||
value: Pattern;
|
||||
kind: "init";
|
||||
method: boolean; // false
|
||||
}
|
||||
|
||||
interface ObjectPattern extends BasePattern {
|
||||
type: "ObjectPattern";
|
||||
properties: Array<AssignmentProperty | RestElement>;
|
||||
}
|
||||
|
||||
interface ArrayPattern extends BasePattern {
|
||||
type: "ArrayPattern";
|
||||
elements: Array<Pattern | null>;
|
||||
}
|
||||
|
||||
interface RestElement extends BasePattern {
|
||||
type: "RestElement";
|
||||
argument: Pattern;
|
||||
}
|
||||
|
||||
interface AssignmentPattern extends BasePattern {
|
||||
type: "AssignmentPattern";
|
||||
left: Pattern;
|
||||
right: Expression;
|
||||
}
|
||||
|
||||
type Class = ClassDeclaration | ClassExpression;
|
||||
interface BaseClass extends BaseNode {
|
||||
superClass?: Expression | null | undefined;
|
||||
body: ClassBody;
|
||||
}
|
||||
|
||||
interface ClassBody extends BaseNode {
|
||||
type: "ClassBody";
|
||||
body: Array<MethodDefinition | PropertyDefinition | StaticBlock>;
|
||||
}
|
||||
|
||||
interface MethodDefinition extends BaseNode {
|
||||
type: "MethodDefinition";
|
||||
key: Expression | PrivateIdentifier;
|
||||
value: FunctionExpression;
|
||||
kind: "constructor" | "method" | "get" | "set";
|
||||
computed: boolean;
|
||||
static: boolean;
|
||||
}
|
||||
|
||||
interface MaybeNamedClassDeclaration extends BaseClass, BaseDeclaration {
|
||||
type: "ClassDeclaration";
|
||||
/** It is null when a class declaration is a part of the `export default class` statement */
|
||||
id: Identifier | null;
|
||||
}
|
||||
|
||||
interface ClassDeclaration extends MaybeNamedClassDeclaration {
|
||||
id: Identifier;
|
||||
}
|
||||
|
||||
interface ClassExpression extends BaseClass, BaseExpression {
|
||||
type: "ClassExpression";
|
||||
id?: Identifier | null | undefined;
|
||||
}
|
||||
|
||||
interface MetaProperty extends BaseExpression {
|
||||
type: "MetaProperty";
|
||||
meta: Identifier;
|
||||
property: Identifier;
|
||||
}
|
||||
|
||||
type ModuleDeclaration =
|
||||
| ImportDeclaration
|
||||
| ExportNamedDeclaration
|
||||
| ExportDefaultDeclaration
|
||||
| ExportAllDeclaration;
|
||||
interface BaseModuleDeclaration extends BaseNode {}
|
||||
|
||||
type ModuleSpecifier = ImportSpecifier | ImportDefaultSpecifier | ImportNamespaceSpecifier | ExportSpecifier;
|
||||
interface BaseModuleSpecifier extends BaseNode {
|
||||
local: Identifier;
|
||||
}
|
||||
|
||||
interface ImportDeclaration extends BaseModuleDeclaration {
|
||||
type: "ImportDeclaration";
|
||||
specifiers: Array<ImportSpecifier | ImportDefaultSpecifier | ImportNamespaceSpecifier>;
|
||||
source: Literal;
|
||||
}
|
||||
|
||||
interface ImportSpecifier extends BaseModuleSpecifier {
|
||||
type: "ImportSpecifier";
|
||||
imported: Identifier | Literal;
|
||||
}
|
||||
|
||||
interface ImportExpression extends BaseExpression {
|
||||
type: "ImportExpression";
|
||||
source: Expression;
|
||||
}
|
||||
|
||||
interface ImportDefaultSpecifier extends BaseModuleSpecifier {
|
||||
type: "ImportDefaultSpecifier";
|
||||
}
|
||||
|
||||
interface ImportNamespaceSpecifier extends BaseModuleSpecifier {
|
||||
type: "ImportNamespaceSpecifier";
|
||||
}
|
||||
|
||||
interface ExportNamedDeclaration extends BaseModuleDeclaration {
|
||||
type: "ExportNamedDeclaration";
|
||||
declaration?: Declaration | null | undefined;
|
||||
specifiers: ExportSpecifier[];
|
||||
source?: Literal | null | undefined;
|
||||
}
|
||||
|
||||
interface ExportSpecifier extends Omit<BaseModuleSpecifier, "local"> {
|
||||
type: "ExportSpecifier";
|
||||
local: Identifier | Literal;
|
||||
exported: Identifier | Literal;
|
||||
}
|
||||
|
||||
interface ExportDefaultDeclaration extends BaseModuleDeclaration {
|
||||
type: "ExportDefaultDeclaration";
|
||||
declaration: MaybeNamedFunctionDeclaration | MaybeNamedClassDeclaration | Expression;
|
||||
}
|
||||
|
||||
interface ExportAllDeclaration extends BaseModuleDeclaration {
|
||||
type: "ExportAllDeclaration";
|
||||
exported: Identifier | Literal | null;
|
||||
source: Literal;
|
||||
}
|
||||
|
||||
interface AwaitExpression extends BaseExpression {
|
||||
type: "AwaitExpression";
|
||||
argument: Expression;
|
||||
}
|
||||
|
||||
type Positioned<T> = T & {
|
||||
start: number;
|
||||
end: number;
|
||||
};
|
||||
type Node = Positioned<Node$1>;
|
||||
|
||||
interface HoistMocksOptions {
|
||||
/**
|
||||
* List of modules that should always be imported before compiler hints.
|
||||
* @default ['vitest']
|
||||
*/
|
||||
hoistedModules?: string[];
|
||||
/**
|
||||
* @default ["vi", "vitest"]
|
||||
*/
|
||||
utilsObjectNames?: string[];
|
||||
/**
|
||||
* @default ["mock", "unmock"]
|
||||
*/
|
||||
hoistableMockMethodNames?: string[];
|
||||
/**
|
||||
* @default ["mock", "unmock", "doMock", "doUnmock"]
|
||||
*/
|
||||
dynamicImportMockMethodNames?: string[];
|
||||
/**
|
||||
* @default ["hoisted"]
|
||||
*/
|
||||
hoistedMethodNames?: string[];
|
||||
regexpHoistable?: RegExp;
|
||||
codeFrameGenerator?: CodeFrameGenerator;
|
||||
}
|
||||
interface HoistMocksPluginOptions extends Omit<HoistMocksOptions, 'regexpHoistable'> {
|
||||
include?: string | RegExp | (string | RegExp)[];
|
||||
exclude?: string | RegExp | (string | RegExp)[];
|
||||
/**
|
||||
* overrides include/exclude options
|
||||
*/
|
||||
filter?: (id: string) => boolean;
|
||||
}
|
||||
declare function hoistMocksPlugin(options?: HoistMocksPluginOptions): Plugin;
|
||||
interface HoistMocksResult {
|
||||
ast: Rollup.ProgramNode;
|
||||
code: string;
|
||||
map: SourceMap;
|
||||
}
|
||||
interface CodeFrameGenerator {
|
||||
(node: Positioned<Node>, id: string, code: string): string;
|
||||
}
|
||||
declare function hoistMocks(code: string, id: string, parse: Rollup.PluginContext['parse'], options?: HoistMocksOptions): HoistMocksResult | undefined;
|
||||
|
||||
interface InterceptorPluginOptions {
|
||||
/**
|
||||
* @default "__vitest_mocker__"
|
||||
*/
|
||||
globalThisAccessor?: string;
|
||||
}
|
||||
declare function interceptorPlugin(options: InterceptorPluginOptions): Plugin;
|
||||
|
||||
interface MockerPluginOptions extends AutomockPluginOptions {
|
||||
hoistMocks?: HoistMocksPluginOptions;
|
||||
}
|
||||
declare function mockerPlugin(options?: MockerPluginOptions): Plugin[];
|
||||
|
||||
interface ServerResolverOptions {
|
||||
/**
|
||||
* @default ['/node_modules/']
|
||||
*/
|
||||
moduleDirectories?: string[];
|
||||
}
|
||||
declare class ServerMockResolver {
|
||||
private server;
|
||||
private options;
|
||||
constructor(server: ViteDevServer, options?: ServerResolverOptions);
|
||||
resolveMock(rawId: string, importer: string, options: {
|
||||
mock: 'spy' | 'factory' | 'auto';
|
||||
}): Promise<ServerMockResolution>;
|
||||
invalidate(ids: string[]): void;
|
||||
resolveId(id: string, importer?: string): Promise<ServerIdResolution | null>;
|
||||
private resolveMockId;
|
||||
private resolveModule;
|
||||
}
|
||||
interface ServerMockResolution {
|
||||
mockType: 'manual' | 'redirect' | 'automock' | 'autospy';
|
||||
resolvedId: string;
|
||||
needsInterop?: boolean;
|
||||
redirectUrl?: string | null;
|
||||
}
|
||||
interface ServerIdResolution {
|
||||
id: string;
|
||||
url: string;
|
||||
optimized: boolean;
|
||||
}
|
||||
|
||||
export { type AutomockPluginOptions, type HoistMocksPluginOptions, type HoistMocksResult, type InterceptorPluginOptions, type ServerIdResolution, type ServerMockResolution, ServerMockResolver, type ServerResolverOptions, automockModule, automockPlugin, dynamicImportPlugin, hoistMocks, hoistMocksPlugin, interceptorPlugin, mockerPlugin };
|
||||
+1327
File diff suppressed because it is too large.
Load diff
+3
@@ -0,0 +1,3 @@
|
||||
declare function findMockRedirect(root: string, mockPath: string, external: string | null): string | null;
|
||||
|
||||
export { findMockRedirect };
|
||||
+67
@@ -0,0 +1,67 @@
|
||||
import fs from 'node:fs';
|
||||
import { builtinModules } from 'node:module';
|
||||
import { d as dirname, j as join, b as basename, r as resolve, e as extname } from './chunk-pathe.ff20891b.js';
|
||||
|
||||
const { existsSync, readdirSync, statSync } = fs;
|
||||
function findMockRedirect(root, mockPath, external) {
|
||||
const path = external || mockPath;
|
||||
if (external || isNodeBuiltin(mockPath) || !existsSync(mockPath)) {
|
||||
let findFile2 = function(mockFolder2, baseOriginal2) {
|
||||
const files = readdirSync(mockFolder2);
|
||||
for (const file of files) {
|
||||
const baseFile = basename(file, extname(file));
|
||||
if (baseFile === baseOriginal2) {
|
||||
const path2 = resolve(mockFolder2, file);
|
||||
if (statSync(path2).isFile()) {
|
||||
return path2;
|
||||
} else {
|
||||
const indexFile = findFile2(path2, "index");
|
||||
if (indexFile) {
|
||||
return indexFile;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
};
|
||||
const mockDirname = dirname(path);
|
||||
const mockFolder = join(root, "__mocks__", mockDirname);
|
||||
if (!existsSync(mockFolder)) {
|
||||
return null;
|
||||
}
|
||||
const baseOriginal = basename(path);
|
||||
return findFile2(mockFolder, baseOriginal);
|
||||
}
|
||||
const dir = dirname(path);
|
||||
const baseId = basename(path);
|
||||
const fullPath = resolve(dir, "__mocks__", baseId);
|
||||
return existsSync(fullPath) ? fullPath : null;
|
||||
}
|
||||
const builtins = /* @__PURE__ */ new Set([
|
||||
...builtinModules,
|
||||
"assert/strict",
|
||||
"diagnostics_channel",
|
||||
"dns/promises",
|
||||
"fs/promises",
|
||||
"path/posix",
|
||||
"path/win32",
|
||||
"readline/promises",
|
||||
"stream/consumers",
|
||||
"stream/promises",
|
||||
"stream/web",
|
||||
"timers/promises",
|
||||
"util/types",
|
||||
"wasi"
|
||||
]);
|
||||
const prefixedBuiltins = /* @__PURE__ */ new Set(["node:test", "node:sqlite"]);
|
||||
const NODE_BUILTIN_NAMESPACE = "node:";
|
||||
function isNodeBuiltin(id) {
|
||||
if (prefixedBuiltins.has(id)) {
|
||||
return true;
|
||||
}
|
||||
return builtins.has(
|
||||
id.startsWith(NODE_BUILTIN_NAMESPACE) ? id.slice(NODE_BUILTIN_NAMESPACE.length) : id
|
||||
);
|
||||
}
|
||||
|
||||
export { findMockRedirect };
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
import { M as ModuleMockerInterceptor, a as ModuleMockerCompilerHints, b as ModuleMocker } from './mocker-pQgp1HFr.js';
|
||||
import '@vitest/spy';
|
||||
import './types-DZOqTgiN.js';
|
||||
|
||||
declare function registerModuleMocker(interceptor: (accessor: string) => ModuleMockerInterceptor): ModuleMockerCompilerHints;
|
||||
declare function registerNativeFactoryResolver(mocker: ModuleMocker): void;
|
||||
|
||||
export { registerModuleMocker, registerNativeFactoryResolver };
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
import { spyOn } from '@vitest/spy';
|
||||
import { M as ModuleMocker, r as rpc, c as createCompilerHints, h as hot } from './chunk-mocker.js';
|
||||
import './index.js';
|
||||
import './chunk-registry.js';
|
||||
import './chunk-pathe.ff20891b.js';
|
||||
|
||||
function registerModuleMocker(interceptor) {
|
||||
const mocker = new ModuleMocker(
|
||||
interceptor(__VITEST_GLOBAL_THIS_ACCESSOR__),
|
||||
{
|
||||
resolveId(id, importer) {
|
||||
return rpc("vitest:mocks:resolveId", { id, importer });
|
||||
},
|
||||
resolveMock(id, importer, options) {
|
||||
return rpc("vitest:mocks:resolveMock", { id, importer, options });
|
||||
},
|
||||
async invalidate(ids) {
|
||||
return rpc("vitest:mocks:invalidate", { ids });
|
||||
}
|
||||
},
|
||||
spyOn,
|
||||
{
|
||||
root: __VITEST_MOCKER_ROOT__
|
||||
}
|
||||
);
|
||||
globalThis[__VITEST_GLOBAL_THIS_ACCESSOR__] = mocker;
|
||||
registerNativeFactoryResolver(mocker);
|
||||
return createCompilerHints({
|
||||
globalThisKey: __VITEST_GLOBAL_THIS_ACCESSOR__
|
||||
});
|
||||
}
|
||||
function registerNativeFactoryResolver(mocker) {
|
||||
hot.on("vitest:interceptor:resolve", async (url) => {
|
||||
const exports = await mocker.resolveFactoryModule(url);
|
||||
const keys = Object.keys(exports);
|
||||
hot.send("vitest:interceptor:resolved", { url, keys });
|
||||
});
|
||||
}
|
||||
|
||||
export { registerModuleMocker, registerNativeFactoryResolver };
|
||||
Loaded 100 of 1079 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user