Repository navigation
feat(serialize): name each separate asset tag's components, and OutsideSlotContentError - #805
Merged
Merged
Conversation
…deSlotContentError Each SerializedAssets group that deps_position="separate" returns now has css_entries and js_entries: the same tags as css and js, each as a SerializedAssetEntry with the class ids of the components that declared it and an instance flag that is True when the tag may hold one render's data. Citry fills them from its dependency records: each wrapper comment carries only the tag's position in a per-call list, so no owner is read from tag text. A tag no record names, such as one an on_dependencies hook added or rebuilt, reports instance=True. combine_assets() combines the entries. Serializing a child render on its own when it holds slot content from outside now raises OutsideSlotContentError, a TypeError subclass. Both are Experimental, groundwork for the citry-django integration. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01KUhrHaXagmW5ZxpRAMwyom
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
(Opus 5.5)
Two small Experimental additions for citry 1.1.0, groundwork for the citry-django integration. citry-django renders each interactive region of a Django page as its own Vue app with
serialize_result(deps_position="separate"). Its compressor today reads Citry's internaldata-citry-css-classattribute from tag text, and it recognises the island slot-content refusal by its message text. This PR gives it a public API for each. It builds on #801 and #802 (combine_assets), both merged, and does not conflict with #803.1.
SerializedAssetEntry: which components declared a tagPrior art.
Dependency.origin_class_idandkind(ext/dependencies/types.py) already record the declaring class and whether a sheet holdscss_data()values ("variables")._resolve_records(ext/dependencies/emission.py) already tracks which instances list each dependency.SerializedScriptSecurity.origin_class_idexposes the owner for scripts in security metadata.data-citry-css-classlists the owners of a component's own sheet in static output only, and it is tag text. The compressor (citry_django_compressor/__init__.py,PageTag.origin_class_idandshareable) needs two answers per tag: which class declared it (to look upcss_fileand choose a precompiler), and whether an inline<style>is the same on every page or holds one instance's data.API.
SerializedAssetsgainscss_entriesandjs_entries. They hold the same tags ascss/js, in the same order, each as aSerializedAssetEntry(tag, class_ids, instance).class_idslists every component that declared the tag. It is a tuple because byte-identical CSS or a shared file can have several owners.instance=Falseonly when Citry's records prove the tag is the same on every render:runtime_assetstags, a component's own tags, andDependenciestags. Acss_data()sheet, everyapp_assetstag, and any tag no record names (a tag anon_dependencieshook added or rebuilt) reportTrue, so the flag fails closed. Settingorigin_class_idon a hook's tag names its component, but it does not make the tag shareable.css/jsfields and their behavior are unchanged. Creating aSerializedAssetswhose entries name other tags raisesValueError.combine_assets()combines the entries too: a merged tag lists the components of every tag it replaced and isinstancewhen any of them was. When a group has tags but no entries (a hand-built group), the result has none for that kind. feat(vue): one stylesheet tag for several apps, and experimental combine_assets() #802 was already merged, so this PR updatescombine_assetsdirectly.How owners travel. Each wrapper comment that
"separate"puts around a tag now carries only the tag's position in a per-call list. The emitter fills that list from the dependency records, and the serializer reads it when it cuts the tags out. No owner is ever read from tag text, and page data cannot write a wrapper because it cannot know the per-call 128-bit value.Alternatives rejected.
data-citry-css-classfrom the tag, or encode the class ids into the wrapper comment and read them back. Both read owners out of HTML text, and the attribute exists only on static component sheets.css_ownerstuples aligned by index withcss. Every consumer would have to zip the two and keep them in step. An entry that holds its own tag is self-contained and survivescombine_assets.What would show it is wrong. An entry whose
class_idscomes from a tag's attributes, or a one-render tag (css_data()or hook-built) reportedinstance=False.test_owners_come_from_records_not_from_the_tag_textandtest_a_stylesheet_a_hook_rebuilds_is_never_shareablecover both.2.
OutsideSlotContentErrorPrior art. #801 raises an internal
UnsupportedPreparedView(aTypeError) from_stable_ownerin_vue/direct_capture.pywhen a child holding slot content from outside it is serialized as its own Vue app. None of the fourexcept UnsupportedPreparedViewsites wraps_stable_owner.API.
citry.OutsideSlotContentError(TypeError), Experimental, raised at that one site.except TypeErrorstill catches it. The docs forneeds_browser_runtime(),serialize()(Raises) and "Split into several apps" name it.Alternatives rejected.
UnsupportedPreparedView. That exposes an internal class in a public class's base classes.TypeError. Callers would still need to inspect the error instead of catching it by type.What would show it is wrong. Code that caught the old exception no longer catching it. It is still a
TypeError, and no internal handler covered that raise.Checks
test_serialize_separate_assets.py, and 2 updated. The four focused files (separate assets, Vue migration coverage, deps emission, serialize security) pass: 728 tests. The fullcitrysuite (no e2e) passed 14,789 tests before the review fixes. Its 3 failures and 11 collection errors come from the minimal venv: missingyaml/citry_ui, two tests that also fail on base, and a timing test that passes alone.packages/py/citry/citry: no issues on macOS or with--platform linux.origin/mainagainst this branch, fresh processes alternating, best of 15 renders (budget about 5 minutes, threshold 3%):benchmarks/slot_renders.py --scenario filled --runs 5: base median 20.23 ms, head 20.48 ms (+1.2%, within noise; this path does not reach the changed code).css_data(): median 51.01 ms against 51.43 ms (+0.8%).benchmarks/client_scenario.pyon main uses template syntax that has since been removed.Fixed during the review
instanceused to report a tag as shareable whenever Citry could not tell, for example acss_data()sheet that a hook rebuilt. It now fails closed. The reviewer re-ran its test scripts and confirmed the fix.app_assetstag has emptyclass_idswere corrected.Versioning
Additions only, all Experimental and named in the Experimental list on the versioning page. The new exception subclasses
TypeError, so existing handlers keep working. A minor release (1.1.0) fits. The wrapper comment is internal to one serialize call and never leaves it. Changelog: one entry under Unreleased > Added for each change, marked as groundwork for the citry-django integration.🤖 Generated with Claude Code
https://claude.ai/code/session_01KUhrHaXagmW5ZxpRAMwyom