Repository navigation
Backlog
Labels
enhancementNew feature or request
Description
Follow-up to the 2.0.0 release-readiness PR #271. Do this after the 2.0.0 PRs merge. Each item is internal: exported JSON, validation results, and the public API must stay the same. Paths are under packages/ack/lib/src; search by symbol because line numbers will move.
Duplicated logic
- Three
$ref-rewriting passes:_relocateRootPointers(schema_model/ack_schema_model.dart),_shareImportedResourceswith_mapImportedChildren(schema_model/ack_schema_model_builder.dart), and the reference loop inexport2020Document(schemas/imported_json_schema.dart). Each walks indexed schemas, tracks the$idbase, toleratesFormatException, and rewrites. One helper taking(root, indexed, base, rewrite)covers all three. Keep: only indexed maps are edited, malformed$id/$refvalues stay as they are, and$schemais rewritten only in the export pass. - Four copies of one binary search in the generated Unicode tables (
json_schema/unicode_bidi.dart,unicode_contextj.dart,unicode_idna.dart,unicode_idna_scripts.dart), and_isIdnaMarkis a linear scan. Use one generic range lookup; update the generators underscripts/generate_unicode_*.dart. _jsonInstanceHashCode(constraints/list_unique_items_constraint.dart) duplicatesdeepHashCodenow that equality usesdeepEquals. UseLinkedHashSet(equals: deepEquals, hashCode: deepHashCode), as the compiler already does forenum. Keep1 == 1.0and key-order independence._copyImportJson(json_schema/json_schema_compiler.dart) duplicates the JSON copy mode of the collection walker, apart from the depth bound._warningsAtre-derives the nullable and composition rendering layout separately from_finishTypeJsonand_finishCompositionJson. Share one child-pointer helper so warning paths cannot drift from the export.
Simpler constraint encoding
ComparisonConstraint:multipleOfis encoded aseqplusmultipleValueplus key checks in three places, and_categorizeguesses the category from key prefixes. Let each factory pass its JSON Schema keywords. Two branches are dead: the defaultmultipleOfmessage (a custom builder is always set) and numericeq → const(no factory creates it).PatternConstraint: thePatternType.formatempty-map fallback is dead.
Performance
_isHostnameand_isEmail(json_schema/json_schema_formats.dart) build theirRegExps on every call, and once per label. Make them static finals.
Done when
The duplicates above are gone, cd packages/ack && dart test and the CI Chrome conformance list pass unchanged, the official format suite results are unchanged on the VM and in Chrome, and dart scripts/api_check.dart reports no API change.
Generated by Claude Code
Metadata
Metadata
Assignees
Labels
enhancementNew feature or request
Activity