pub fn add_state<T: AnyFreeze + Clone>(
        &self,
        url: &PathMaybeWithLocale,
        val: T,
        is_widget: bool,
    ) -> Result<(), ClientError> {
        let mut map = self.map.borrow_mut();
        // We want to modify any existing entries to avoid wiping out document metadata
        if let Some(entry) = map.get_mut(url) {
            entry.set_state(Box::new(val))?
        } else {
            let mut new_entry = PssEntry::default();
            new_entry.set_state(Box::new(val))?;
            map.insert(url.clone(), new_entry);
        }
        let mut order = self.order.borrow_mut();
        // If we haven't been told to keep this page, enter it in the order list so it
        // can be evicted later (unless it's a widget)
        if !self.keep_list.borrow().iter().any(|x| x == url) && !is_widget {
            // Get rid of any previous mentions of this page in the order list
            order.retain(|stored_url| stored_url != url);
            order.push(url.clone());
            // If we've used up the maximum size yet, we should get rid of the oldest pages
            drop(order);
            drop(map);
            self.evict_page_if_needed();
        }

        Ok(())
    }
Adds page state to the entry in the store with the given URL, creating
it if it doesn't exist. Any state previously set for the item will
be overridden, but any document metadata will be preserved.

This will be added to the end of the `order` property, and any previous
entries of it in that list will be removed, unless it is specified to
be a widget.

If there's already an entry for the given URL that has been marked as
not accepting state, this will return an error, and the entry will
not be added. When this is called for HSR purposes, this should be taken
with a grain of salt, as documented on `.set_state()` for [`PssEntry`].
packages/perseus/src/state/state_store.rs