@shapeshift-labs/frontier-lang-parser 0.3.32 → 0.3.33
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/conversion-constraint-record.js +18 -7
- package/dist/conversion.js +11 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -473,7 +473,7 @@ conversion TodoJavascriptToRust @id("conversion_todo_js_rust") {
|
|
|
473
473
|
|
|
474
474
|
`sourceRuntime` and `targetRuntime` become runtime maps. `runtimeRequirement` rows become proof obligations for host/runtime capabilities, including authored `requiredSignals` denominators such as source hashes, target hashes, probe ids, runtime commands, telemetry hashes, and capability-specific trace hashes. `proofEvidence` and `evidence` attach evidence ids, but the compiler still requires bound evidence records before a proof obligation is satisfied. `dialect` and `extern` rows preserve dialect-specific constructs, projection readiness, loss/evidence ids, and binding metadata without requiring the authored Frontier file to drop down to raw JSON.
|
|
475
475
|
|
|
476
|
-
`constraint` rows accept every universal conversion constraint family used by route admission, including hyphenated spellings such as `module-constraint`, `scope-binding`, `memory-model`, `effect-constraint`, `control-flow`, `borrow-scope`, `borrow-checker`, `host-environment`, `callable-boundary`, `adt-pattern`, `data-layout`, `numeric-semantics`, `text-semantics`, `collection-semantics`, `serialization-semantics`, `dependency-semantics`, `object-model`, and `protocol`. The parser preserves family-specific fields such as module specifiers, package conditions, binding/reference ids, memory ordering, locks, capabilities, host permissions, callable signatures, pattern exhaustiveness, ABI/layout hints, numeric/text/collection behavior, wire formats, dependency lockfile evidence, and effect adapters as authored evidence inputs. Record-level targets use explicit labels such as `effectTarget` so `role target` rows cannot be mistaken for an authored target field. These rows do not prove translation equivalence; they make the required proof surface explicit for downstream gates and admission records.
|
|
476
|
+
`constraint` rows accept every universal conversion constraint family used by route admission, including hyphenated spellings such as `module-constraint`, `scope-binding`, `memory-model`, `effect-constraint`, `control-flow`, `borrow-scope`, `borrow-checker`, `host-environment`, `callable-boundary`, `adt-pattern`, `data-layout`, `layout-style`, `layout`, `style`, `numeric-semantics`, `text-semantics`, `collection-semantics`, `serialization-semantics`, `dependency-semantics`, `object-model`, and `protocol`. The parser preserves family-specific fields such as module specifiers, package conditions, binding/reference ids, memory ordering, locks, capabilities, host permissions, callable signatures, pattern exhaustiveness, ABI/layout hints, selector/style/cascade/layout evidence, numeric/text/collection behavior, wire formats, dependency lockfile evidence, and effect adapters as authored evidence inputs. Constraint entries and family-specific records can also carry `sourceMap`, `sourceMapMapping`, `proofObligation`, `proofEvidence`, `missingEvidence`, and `failClosed` so downstream compiler, merge, and admission tooling can keep source-bound denominators visible. Record-level targets use explicit labels such as `effectTarget` so `role target` rows cannot be mistaken for an authored target field. These rows do not prove translation equivalence; they make the required proof surface explicit for downstream gates and admission records.
|
|
477
477
|
|
|
478
478
|
## Authored runtime capability syntax
|
|
479
479
|
|
|
@@ -8,6 +8,7 @@ const FAMILY_ROWS = [
|
|
|
8
8
|
['callableBoundary', 'callableBoundaryConstraints', 'sourceCallables', 'targetCallables', ['callableBoundaryConstraint', 'callable-boundary', 'callable-boundary-constraint'], { extraSourceKeys: ['sourceCallableBoundaryRecords'], extraTargetKeys: ['targetCallableBoundaryRecords'] }],
|
|
9
9
|
['adtPattern', 'adtPatternConstraints', 'sourcePatterns', 'targetPatterns', ['adtPatternConstraint', 'adt-pattern', 'adt-pattern-constraint'], { extraSourceKeys: ['sourceAdtPatternRecords'], extraTargetKeys: ['targetAdtPatternRecords'] }],
|
|
10
10
|
['dataLayout', 'dataLayoutConstraints', 'sourceLayouts', 'targetLayouts', ['dataLayoutConstraint', 'data-layout', 'data-layout-constraint'], { extraSourceKeys: ['sourceDataLayoutRecords'], extraTargetKeys: ['targetDataLayoutRecords'] }],
|
|
11
|
+
['layoutStyle', 'layoutStyleConstraints', 'sourceLayoutStyles', 'targetLayoutStyles', ['layoutStyleConstraint', 'layout-style', 'layout-style-constraint', 'layout', 'layoutConstraint', 'layout-constraint', 'style', 'styleConstraint', 'style-constraint', 'css-style', 'css-rule', 'style-layout', 'render-layout'], { extraSourceKeys: ['sourceLayoutStyleRecords'], extraTargetKeys: ['targetLayoutStyleRecords'] }],
|
|
11
12
|
['effect', 'effectConstraints', 'sourceEffects', 'targetEffects', ['effectConstraint', 'effect-constraint']],
|
|
12
13
|
['concurrencyModel', 'concurrencyModelConstraints', 'sourceConcurrencyModels', 'targetConcurrencyModels', ['concurrencyModelConstraint', 'concurrency-model', 'concurrency-model-constraint'], { extraSourceKeys: ['sourceConcurrencyModelRecords'], extraTargetKeys: ['targetConcurrencyModelRecords'] }],
|
|
13
14
|
['errorModel', 'errorModelConstraints', 'sourceErrors', 'targetErrors', ['errorModelConstraint', 'error-model', 'error-model-constraint'], { extraSourceKeys: ['sourceErrorModelRecords'], extraTargetKeys: ['targetErrorModelRecords'] }],
|
|
@@ -48,7 +49,7 @@ const WORD_FIELDS = [
|
|
|
48
49
|
['controlFlowKind'], ['sourceControlFlowId'], ['sourceId', 'from', 'sourceId'], ['targetId', 'to', 'targetId'], ['label'],
|
|
49
50
|
['conditionHash'], ['orderingKey', 'orderingKey', 'orderKey'], ['lifetimeKind'], ['lifetimeRegionId', 'lifetimeRegion', 'lifetimeRegionId'],
|
|
50
51
|
['regionKind'], ['resourceId', 'resource', 'resourceId'],
|
|
51
|
-
['functionName'], ['methodName'], ['callableName'], ['callableKind'], ['callSignatureHash'],
|
|
52
|
+
['functionName'], ['methodName'], ['callableName'], ['callableKind'], ['callSignatureHash'], ['restParameter', 'restParameter', 'rest'],
|
|
52
53
|
['receiverKind', 'receiverKind', 'receiver'], ['thisBinding'], ['selfBinding'], ['returnKind', 'returnKind', 'returnType'],
|
|
53
54
|
['asyncKind', 'asyncKind', 'asyncMode'], ['generatorKind', 'generatorKind', 'yieldKind'], ['callbackKind'],
|
|
54
55
|
['closureCapture', 'closureCapture', 'captureKind'], ['overloadSet', 'overloadSet', 'overloads'],
|
|
@@ -57,7 +58,7 @@ const WORD_FIELDS = [
|
|
|
57
58
|
['symbolKind'], ['relationKind'], ['representationKind'], ['typeId', 'typeId', 'nodeId'], ['nodeId'], ['structId'], ['unionId'],
|
|
58
59
|
['enumId'], ['fieldId'], ['bitfieldId'], ['endianness', 'endianness', 'endian'], ['repr', 'repr', 'reprAttribute'],
|
|
59
60
|
['numericKind', 'numericKind', 'numberKind'], ['numberKind'], ['numericTypeName'], ['signedness'], ['overflowMode', 'overflowMode', 'overflowBehavior'],
|
|
60
|
-
['divisionMode', 'divisionMode', 'integerDivisionMode'], ['moduloMode', 'moduloMode', 'remainderMode'], ['floatPrecision'], ['roundingMode'],
|
|
61
|
+
['divisionMode', 'divisionMode', 'integerDivisionMode'], ['moduloMode', 'moduloMode', 'remainderMode'], ['floatFormat'], ['floatPrecision'], ['roundingMode'],
|
|
61
62
|
['separatorPolicy'], ['coercionKind', 'coercionKind', 'conversionKind'], ['conversionKind'], ['literalKind'],
|
|
62
63
|
['textKind', 'textKind', 'stringKind'], ['stringKind'], ['stringTypeName'], ['encoding', 'encoding', 'charset', 'codepage'],
|
|
63
64
|
['charset'], ['codepage'], ['codeUnit', 'codeUnit', 'codeUnitWidth'], ['indexingUnit', 'indexingUnit', 'indexUnit'],
|
|
@@ -83,15 +84,19 @@ const WORD_FIELDS = [
|
|
|
83
84
|
['buildTool', 'buildTool', 'builder'], ['packageManagerVersion', 'packageManagerVersion', 'managerVersion'],
|
|
84
85
|
['offlineCache', 'offlineCache', 'cachePolicy'], ['dedupeHoist', 'dedupeHoist', 'hoistPolicy'], ['provenance', 'provenance', 'sourceProvenance'],
|
|
85
86
|
['trust', 'trust', 'supplyChainTrust'], ['concurrencyKind'], ['constructId', 'constructId', 'taskId', 'threadId', 'actorId', 'channelId'],
|
|
86
|
-
['taskId'], ['threadId'], ['executor', 'executor', 'queue', 'runtime'], ['executorId'], ['isolationKey'], ['cancellationKey', 'cancellationKey', 'signalId', 'contextId'],
|
|
87
|
+
['taskId'], ['threadId'], ['scheduler'], ['executor', 'executor', 'queue', 'runtime'], ['executorId'], ['isolationKey'], ['cancellationKey', 'cancellationKey', 'signalId', 'contextId'],
|
|
87
88
|
['signalId'], ['contextId'], ['errorKind'], ['errorType', 'errorType', 'exceptionType', 'resultType'], ['exceptionType'], ['resultType'],
|
|
88
89
|
['boundaryId', 'boundaryId', 'catchId', 'handlerId'], ['catchId'], ['handlerId'], ['evaluationKind', 'evaluationKind', 'expressionKind'],
|
|
89
90
|
['expressionKind'], ['expressionId', 'expressionId', 'nodeId'], ['operator'], ['evaluationOrder', 'evaluationOrder', 'order'],
|
|
90
91
|
['expansionKind', 'expansionKind', 'macroKind', 'templateKind', 'decoratorKind', 'generatorKind'], ['macroKind'], ['templateKind'],
|
|
91
92
|
['decoratorKind'], ['expansionId'], ['generatorId'], ['generatedSourcePath'], ['expandedHash', 'expandedHash', 'generatedHash'],
|
|
92
|
-
['generatedHash'], ['classId'], ['classKind'], ['prototypeId'], ['mixinId'], ['constructorId'], ['inheritanceKind'], ['referenceSemantics'],
|
|
93
|
+
['generatedHash'], ['classId'], ['classKind'], ['prototypeId'], ['mixinId'], ['methodId'], ['constructorId'], ['inheritanceKind'], ['referenceSemantics'],
|
|
93
94
|
['valueSemantics'], ['protocolKind'], ['protocolName'], ['traitName'], ['interfaceName'], ['subjectName', 'subjectName', 'receiverName', 'implementedFor'],
|
|
94
|
-
['implementedFor'], ['sourcePath', 'sourcePath', 'path'], ['sourceHash'], ['
|
|
95
|
+
['implementedFor'], ['sourcePath', 'sourcePath', 'path'], ['sourceHash'], ['selector'], ['value'], ['styleProperty', 'styleProperty', 'property', 'cssProperty'],
|
|
96
|
+
['cssProperty', 'cssProperty', 'styleProperty', 'property'], ['computedValue'], ['cascadeLayer'], ['specificity'], ['mediaQuery'],
|
|
97
|
+
['containerQuery'], ['boxModel'], ['display'], ['position'], ['zIndex'], ['writingMode'], ['direction'], ['viewport'], ['renderTreeId'],
|
|
98
|
+
['styleRuleId'], ['computedStyleHash'], ['layoutSnapshotHash'], ['bitmapHash'], ['accessibilityTreeHash'], ['focusOrderHash'],
|
|
99
|
+
['target', 'effectTarget', 'targetResource']
|
|
95
100
|
];
|
|
96
101
|
const LIST_FIELDS = [
|
|
97
102
|
['factKinds', 'fact', 'facts', 'factKind', 'factKinds'], ['importAttributes', 'importAttribute', 'importAttributes', 'assertion', 'assertions'],
|
|
@@ -108,14 +113,20 @@ const LIST_FIELDS = [
|
|
|
108
113
|
['devDependencies'], ['features', 'features', 'extras', 'flags'], ['lifecycleScripts', 'lifecycleScripts', 'scripts'],
|
|
109
114
|
['requirementNames', 'requirementNames', 'requirements', 'methods', 'members'], ['associatedTypeNames', 'associatedTypeNames', 'associatedTypes'],
|
|
110
115
|
['boundNames', 'boundNames', 'bounds', 'traitBounds', 'protocolBounds', 'whereBounds'], ['implementationKinds', 'implementationKinds', 'implKinds', 'implementations'],
|
|
111
|
-
['dispatchKinds', 'dispatchKinds', 'dispatchModes'], ['coherenceKinds', 'coherenceKinds', 'coherenceRules'],
|
|
116
|
+
['dispatchKinds', 'dispatchKinds', 'dispatchModes'], ['coherenceKinds', 'coherenceKinds', 'coherenceRules'],
|
|
117
|
+
['sourceMapIds', 'sourceMap', 'sourceMaps', 'sourceMapId', 'sourceMapIds'],
|
|
118
|
+
['sourceMapMappingIds', 'sourceMapMapping', 'sourceMapMappings', 'sourceMapMappingId', 'sourceMapMappingIds'],
|
|
119
|
+
['proofObligationIds', 'proofObligation', 'proofObligations', 'proofObligationId', 'proofObligationIds', 'obligation', 'obligations'],
|
|
120
|
+
['proofEvidenceIds', 'proofEvidence', 'proofEvidenceId', 'proofEvidenceIds'],
|
|
121
|
+
['missingEvidence', 'missingEvidence', 'missingEvidenceIds'],
|
|
122
|
+
['evidenceIds', 'evidence', 'evidenceIds']
|
|
112
123
|
];
|
|
113
124
|
const NUMBER_FIELDS = [
|
|
114
125
|
['arity'], ['size'], ['alignment'], ['parameterCount'], ['requiredParameterCount'], ['optionalParameterCount'],
|
|
115
126
|
['sizeBytes'], ['alignmentBytes'], ['offsetBytes'], ['pointerWidth'], ['integerWidth'], ['bitWidth'], ['width'],
|
|
116
127
|
['codeUnitWidth'], ['indexBase']
|
|
117
128
|
];
|
|
118
|
-
const FLAG_FIELDS = ['nullable', 'optional', 'publicContract', 'closure', 'captured', 'writeExpr', 'mutable', 'shadowed', 'hoisted', 'typeOnly', 'isTypeReference', 'isValueReference', 'shared', 'volatile', 'atomic', 'adapterRequired', 'async', 'generator', 'exceptional', 'cancellable', 'variadic', 'signed', 'nan', 'infinity', 'deterministic', 'streaming', 'framing', 'copyOnWrite', 'multipleInheritance', 'reflection', 'staticDispatch', 'virtual', 'spawn', 'await', 'structured', 'reentrant', 'cancelable'];
|
|
129
|
+
const FLAG_FIELDS = ['nullable', 'optional', 'publicContract', 'closure', 'captured', 'writeExpr', 'mutable', 'shadowed', 'hoisted', 'typeOnly', 'isTypeReference', 'isValueReference', 'shared', 'volatile', 'atomic', 'adapterRequired', 'async', 'generator', 'exceptional', 'cancellable', 'variadic', 'signed', 'nan', 'infinity', 'deterministic', 'streaming', 'framing', 'copyOnWrite', 'multipleInheritance', 'reflection', 'staticDispatch', 'virtual', 'spawn', 'await', 'structured', 'reentrant', 'cancelable', 'failClosed'];
|
|
119
130
|
|
|
120
131
|
export const FAMILIES = Object.freeze(Object.fromEntries(FAMILY_ROWS.flatMap(([name, field, sourceKey, targetKey, aliases = [], extra = {}]) => {
|
|
121
132
|
const config = { field, sourceKey, targetKey, ...extra };
|
package/dist/conversion.js
CHANGED
|
@@ -88,10 +88,15 @@ function addConstraint(plan, family, name, text) {
|
|
|
88
88
|
sourceLanguage: readInlineWord('sourceLanguage', text) ?? plan.sourceLanguage,
|
|
89
89
|
target: readInlineWord('targetLanguage', text) ?? plan.targets[0],
|
|
90
90
|
mode: readInlineWord('mode', text),
|
|
91
|
+
sourceMapIds: readInlineList(text, 'sourceMap', 'sourceMaps', 'sourceMapId', 'sourceMapIds'),
|
|
92
|
+
sourceMapMappingIds: readInlineList(text, 'sourceMapMapping', 'sourceMapMappings', 'sourceMapMappingId', 'sourceMapMappingIds'),
|
|
93
|
+
proofObligationIds: readInlineList(text, 'proofObligation', 'proofObligations', 'proofObligationId', 'proofObligationIds', 'obligation', 'obligations'),
|
|
94
|
+
proofEvidenceIds: readInlineList(text, 'proofEvidence', 'proofEvidenceId', 'proofEvidenceIds'),
|
|
91
95
|
evidenceIds: readInlineList(text, 'evidence', 'evidenceIds'),
|
|
92
96
|
missingEvidence: readInlineList(text, 'missingEvidence'),
|
|
93
97
|
blockers: readInlineList(text, 'blocker', 'blockers'),
|
|
94
98
|
review: readInlineList(text, 'review'),
|
|
99
|
+
failClosed: readInlineFlag('failClosed', text),
|
|
95
100
|
metadata: { name, family, authoredConversionBlockId: plan.id }
|
|
96
101
|
});
|
|
97
102
|
const recordKey = role === 'target' ? config.targetKey : config.sourceKey;
|
|
@@ -113,6 +118,12 @@ function resourceGraphFromRecord(record, entry) {
|
|
|
113
118
|
sourcePath: record.sourcePath,
|
|
114
119
|
sourceHash: record.sourceHash,
|
|
115
120
|
evidenceIds,
|
|
121
|
+
sourceMapIds: record.sourceMapIds ?? entry.sourceMapIds,
|
|
122
|
+
sourceMapMappingIds: record.sourceMapMappingIds ?? entry.sourceMapMappingIds,
|
|
123
|
+
proofObligationIds: record.proofObligationIds ?? entry.proofObligationIds,
|
|
124
|
+
proofEvidenceIds: record.proofEvidenceIds ?? entry.proofEvidenceIds,
|
|
125
|
+
missingEvidence: record.missingEvidence ?? entry.missingEvidence,
|
|
126
|
+
failClosed: record.failClosed ?? entry.failClosed,
|
|
116
127
|
resources: [{
|
|
117
128
|
id: resourceId,
|
|
118
129
|
resourceKind: record.resourceKind ?? record.kind ?? record.constraintKind,
|