url.js — svelte Source File
Architecture documentation for url.js, a javascript file in the svelte codebase. 11 imports, 2 dependents.
Entity Profile
Dependency Diagram
graph LR 19ab2c95_d135_7687_9e01_bd8cfc8a8f42["url.js"] e5c35d51_28d8_9054_923d_b7f82a3c8dc2["sources.js"] 19ab2c95_d135_7687_9e01_bd8cfc8a8f42 --> e5c35d51_28d8_9054_923d_b7f82a3c8dc2 63ee8247_ada4_9f1d_e139_0c1167cd5b1c["set"] 19ab2c95_d135_7687_9e01_bd8cfc8a8f42 --> 63ee8247_ada4_9f1d_e139_0c1167cd5b1c 39208392_58c1_7201_b748_aa74d97cadb9["state"] 19ab2c95_d135_7687_9e01_bd8cfc8a8f42 --> 39208392_58c1_7201_b748_aa74d97cadb9 2696eb67_452f_4c32_3e13_ee172192b366["tracing.js"] 19ab2c95_d135_7687_9e01_bd8cfc8a8f42 --> 2696eb67_452f_4c32_3e13_ee172192b366 4dfcf957_8573_ff55_bd31_4181227109e3["tag"] 19ab2c95_d135_7687_9e01_bd8cfc8a8f42 --> 4dfcf957_8573_ff55_bd31_4181227109e3 bde4209f_8ffc_1594_4024_b1835a44bcf6["runtime.js"] 19ab2c95_d135_7687_9e01_bd8cfc8a8f42 --> bde4209f_8ffc_1594_4024_b1835a44bcf6 a08b6cc5_af73_1be4_d02f_3113cf8a8305["get"] 19ab2c95_d135_7687_9e01_bd8cfc8a8f42 --> a08b6cc5_af73_1be4_d02f_3113cf8a8305 bb708ca7_388e_3591_68c1_42bce13ff37d["url-search-params.js"] 19ab2c95_d135_7687_9e01_bd8cfc8a8f42 --> bb708ca7_388e_3591_68c1_42bce13ff37d b48043f5_5a93_dc20_5376_9a775073fc34["REPLACE"] 19ab2c95_d135_7687_9e01_bd8cfc8a8f42 --> b48043f5_5a93_dc20_5376_9a775073fc34 0a948943_ab4c_5a17_8110_53e6ebf727dd["SvelteURLSearchParams"] 19ab2c95_d135_7687_9e01_bd8cfc8a8f42 --> 0a948943_ab4c_5a17_8110_53e6ebf727dd c9866d91_a204_fa55_a9e3_6bcc6aaaec1e["esm-env"] 19ab2c95_d135_7687_9e01_bd8cfc8a8f42 --> c9866d91_a204_fa55_a9e3_6bcc6aaaec1e bb708ca7_388e_3591_68c1_42bce13ff37d["url-search-params.js"] bb708ca7_388e_3591_68c1_42bce13ff37d --> 19ab2c95_d135_7687_9e01_bd8cfc8a8f42 4706453c_293a_0c92_672f_d49761b1dae7["url.test.ts"] 4706453c_293a_0c92_672f_d49761b1dae7 --> 19ab2c95_d135_7687_9e01_bd8cfc8a8f42 style 19ab2c95_d135_7687_9e01_bd8cfc8a8f42 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import { DEV } from 'esm-env';
import { set, state } from '../internal/client/reactivity/sources.js';
import { tag } from '../internal/client/dev/tracing.js';
import { get } from '../internal/client/runtime.js';
import { REPLACE, SvelteURLSearchParams } from './url-search-params.js';
/** @type {SvelteURL | null} */
let current_url = null;
export function get_current_url() {
// ideally we'd just export `current_url` directly, but it seems Vitest doesn't respect live bindings
return current_url;
}
/**
* A reactive version of the built-in [`URL`](https://developer.mozilla.org/en-US/docs/Web/API/URL) object.
* Reading properties of the URL (such as `url.href` or `url.pathname`) in an [effect](https://svelte.dev/docs/svelte/$effect) or [derived](https://svelte.dev/docs/svelte/$derived)
* will cause it to be re-evaluated as necessary when the URL changes.
*
* The `searchParams` property is an instance of [SvelteURLSearchParams](https://svelte.dev/docs/svelte/svelte-reactivity#SvelteURLSearchParams).
*
* [Example](https://svelte.dev/playground/5a694758901b448c83dc40dc31c71f2a):
*
* ```svelte
* <script>
* import { SvelteURL } from 'svelte/reactivity';
*
* const url = new SvelteURL('https://example.com/path');
* </script>
*
* <!-- changes to these... -->
* <input bind:value={url.protocol} />
* <input bind:value={url.hostname} />
* <input bind:value={url.pathname} />
*
* <hr />
*
* <!-- will update `href` and vice versa -->
* <input bind:value={url.href} size="65" />
* ```
*/
export class SvelteURL extends URL {
#protocol = state(super.protocol);
#username = state(super.username);
#password = state(super.password);
#hostname = state(super.hostname);
#port = state(super.port);
#pathname = state(super.pathname);
#hash = state(super.hash);
#search = state(super.search);
#searchParams;
/**
* @param {string | URL} url
* @param {string | URL} [base]
*/
constructor(url, base) {
url = new URL(url, base);
super(url);
// ... (146 more lines)
Domain
Subdomains
Functions
Classes
Dependencies
Imported By
Source
Frequently Asked Questions
What does url.js do?
url.js is a source file in the svelte codebase, written in javascript. It belongs to the SharedInternal domain, DOMUtils subdomain.
What functions are defined in url.js?
url.js defines 1 function(s): get_current_url.
What does url.js depend on?
url.js imports 11 module(s): REPLACE, SvelteURLSearchParams, esm-env, get, runtime.js, set, sources.js, state, and 3 more.
What files import url.js?
url.js is imported by 2 file(s): url-search-params.js, url.test.ts.
Where is url.js in the architecture?
url.js is located at packages/svelte/src/reactivity/url.js (domain: SharedInternal, subdomain: DOMUtils, directory: packages/svelte/src/reactivity).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free