@shapeshift-labs/frontier-lang-css 0.1.6 → 0.1.7

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/dist/index.d.ts CHANGED
@@ -273,40 +273,35 @@ export interface CssSafeMergeResult {
273
273
  readonly headChangedDeclarations?: number;
274
274
  readonly workerChangedCssModuleContracts?: number;
275
275
  readonly headChangedCssModuleContracts?: number;
276
+ readonly parserEvidence?: CssSafeMergeParserEvidence;
277
+ }
278
+
279
+ export interface CssSafeMergeParserEvidence {
280
+ readonly kind: 'frontier.lang.cssSafeMergeParserEvidence';
281
+ readonly version: 1;
282
+ readonly parserNames: readonly string[];
283
+ readonly sourceCodeLocationInfo: boolean; readonly parserBackedSourceSpans: boolean; readonly parserBackedDeclarationSpans: boolean; readonly parserBackedTriviaHashes: boolean;
284
+ readonly scopedCascadeGraphHashPresent: boolean; readonly parseErrors: number;
285
+ readonly sides: Readonly<Record<string, CssSafeMergeParserSideEvidence>>;
286
+ }
287
+
288
+ export interface CssSafeMergeParserSideEvidence {
289
+ readonly parserName: string;
290
+ readonly sourceCodeLocationInfo: boolean; readonly parserBackedSourceSpans: boolean; readonly parserBackedDeclarationSpans: boolean; readonly parserBackedTriviaHashes: boolean;
291
+ readonly scopedCascadeGraphHashPresent: boolean; readonly parseErrors: number; readonly recordCount: number; readonly declarationCount: number;
276
292
  }
277
293
 
278
294
  export interface CssSafeMergeInput {
279
- readonly id?: string;
280
- readonly sourcePath?: string;
281
- readonly baseSourceText?: string;
282
- readonly workerSourceText?: string;
283
- readonly headSourceText?: string;
284
- readonly cssModule?: boolean;
285
- readonly cssModules?: boolean;
295
+ readonly id?: string; readonly sourcePath?: string; readonly baseSourceText?: string; readonly workerSourceText?: string; readonly headSourceText?: string;
296
+ readonly cssModule?: boolean; readonly cssModules?: boolean;
286
297
  readonly generatedClassNameMap?: Readonly<Record<string, string>>;
287
- readonly generatedClassNameMapHash?: string;
288
- readonly jsTsUseSiteGraphHash?: string;
289
- readonly cssModuleCompositionGraphHash?: string;
290
- readonly icssGraphHash?: string;
291
- readonly scopedCascadeGraphHash?: string;
292
- readonly baseGeneratedClassNameMap?: Readonly<Record<string, string>>;
293
- readonly workerGeneratedClassNameMap?: Readonly<Record<string, string>>;
294
- readonly headGeneratedClassNameMap?: Readonly<Record<string, string>>;
295
- readonly baseGeneratedClassNameMapHash?: string;
296
- readonly workerGeneratedClassNameMapHash?: string;
297
- readonly headGeneratedClassNameMapHash?: string;
298
- readonly baseJsTsUseSiteGraphHash?: string;
299
- readonly workerJsTsUseSiteGraphHash?: string;
300
- readonly headJsTsUseSiteGraphHash?: string;
301
- readonly baseCssModuleCompositionGraphHash?: string;
302
- readonly workerCssModuleCompositionGraphHash?: string;
303
- readonly headCssModuleCompositionGraphHash?: string;
304
- readonly baseIcssGraphHash?: string;
305
- readonly workerIcssGraphHash?: string;
306
- readonly headIcssGraphHash?: string;
307
- readonly baseScopedCascadeGraphHash?: string;
308
- readonly workerScopedCascadeGraphHash?: string;
309
- readonly headScopedCascadeGraphHash?: string;
298
+ readonly generatedClassNameMapHash?: string; readonly jsTsUseSiteGraphHash?: string; readonly cssModuleCompositionGraphHash?: string; readonly icssGraphHash?: string; readonly scopedCascadeGraphHash?: string;
299
+ readonly baseGeneratedClassNameMap?: Readonly<Record<string, string>>; readonly workerGeneratedClassNameMap?: Readonly<Record<string, string>>; readonly headGeneratedClassNameMap?: Readonly<Record<string, string>>;
300
+ readonly baseGeneratedClassNameMapHash?: string; readonly workerGeneratedClassNameMapHash?: string; readonly headGeneratedClassNameMapHash?: string;
301
+ readonly baseJsTsUseSiteGraphHash?: string; readonly workerJsTsUseSiteGraphHash?: string; readonly headJsTsUseSiteGraphHash?: string;
302
+ readonly baseCssModuleCompositionGraphHash?: string; readonly workerCssModuleCompositionGraphHash?: string; readonly headCssModuleCompositionGraphHash?: string;
303
+ readonly baseIcssGraphHash?: string; readonly workerIcssGraphHash?: string; readonly headIcssGraphHash?: string;
304
+ readonly baseScopedCascadeGraphHash?: string; readonly workerScopedCascadeGraphHash?: string; readonly headScopedCascadeGraphHash?: string;
310
305
  }
311
306
 
312
307
  export declare function toCssAst(document: FrontierLangDocument, options?: CssProjectionOptions): CssAstStylesheet;
@@ -30,7 +30,8 @@ function safeMergeCssSource(input = {}, context = {}) {
30
30
  const moduleConflicts = cssModuleContractConflicts(id, sourcePath, moduleChanges);
31
31
  const sourceShapeConflicts = unsupportedSourceShapeConflicts(id, sourcePath, sheets, changed, hash);
32
32
  const conflicts = [...parserConflicts, ...proofConflicts, ...overlapConflicts, ...moduleConflicts, ...sourceShapeConflicts];
33
- if (conflicts.length) return blocked(id, sourcePath, 'css-semantic-merge-conflict', conflicts);
33
+ const parserEvidence = mergeParserEvidence(sheets);
34
+ if (conflicts.length) return blocked(id, sourcePath, 'css-semantic-merge-conflict', conflicts, { parserEvidence });
34
35
  const mergedIndex = applyDeclarationChanges(applyDeclarationChanges(indexes.base, changed.head), changed.worker);
35
36
  return merged(id, sourcePath, renderDeclarationIndex(mergedIndex), 'semantic-declaration-merge', hash, {
36
37
  baseSheetHash: sheets.base.sheetHash,
@@ -39,7 +40,8 @@ function safeMergeCssSource(input = {}, context = {}) {
39
40
  workerChangedDeclarations: changed.worker.length,
40
41
  headChangedDeclarations: changed.head.length,
41
42
  workerChangedCssModuleContracts: moduleChanges.worker.length,
42
- headChangedCssModuleContracts: moduleChanges.head.length
43
+ headChangedCssModuleContracts: moduleChanges.head.length,
44
+ parserEvidence
43
45
  });
44
46
  }
45
47
 
@@ -107,6 +109,38 @@ function parserErrorConflicts(id, sourcePath, sheets) {
107
109
  .map((gap) => conflict(id, sourcePath, 'css-parser-error-blocked', gap.code, { side, proofGap: gap })));
108
110
  }
109
111
 
112
+ function mergeParserEvidence(sheets) {
113
+ const entries = Object.entries(sheets).map(([side, sheet]) => [side, sheetParserEvidence(sheet)]);
114
+ return {
115
+ kind: 'frontier.lang.cssSafeMergeParserEvidence',
116
+ version: 1,
117
+ parserNames: unique(entries.map(([, evidence]) => evidence.parserName)),
118
+ sourceCodeLocationInfo: entries.every(([, evidence]) => evidence.sourceCodeLocationInfo === true),
119
+ parserBackedSourceSpans: entries.every(([, evidence]) => evidence.parserBackedSourceSpans === true),
120
+ parserBackedDeclarationSpans: entries.every(([, evidence]) => evidence.parserBackedDeclarationSpans === true),
121
+ parserBackedTriviaHashes: entries.every(([, evidence]) => evidence.parserBackedTriviaHashes === true),
122
+ scopedCascadeGraphHashPresent: entries.every(([, evidence]) => evidence.scopedCascadeGraphHashPresent === true),
123
+ parseErrors: entries.reduce((sum, [, evidence]) => sum + evidence.parseErrors, 0),
124
+ sides: Object.fromEntries(entries)
125
+ };
126
+ }
127
+
128
+ function sheetParserEvidence(sheet) {
129
+ const records = sheet.records ?? [];
130
+ const declarations = records.flatMap((record) => record.declarations ?? []);
131
+ return {
132
+ parserName: sheet.parser?.name ?? 'unknown',
133
+ sourceCodeLocationInfo: sheet.parser?.sourceCodeLocationInfo === true,
134
+ parserBackedSourceSpans: records.some((record) => record.parser === 'postcss' && record.sourceSpan?.startOffset !== undefined),
135
+ parserBackedDeclarationSpans: declarations.some((declaration) => declaration.sourceSpan?.startOffset !== undefined),
136
+ parserBackedTriviaHashes: records.some((record) => record.parser === 'postcss' && typeof record.rawTextHash === 'string'),
137
+ scopedCascadeGraphHashPresent: records.every((record) => !(record.scopes?.length) || Boolean(record.scopedCascadeGraphHash)),
138
+ parseErrors: sheet.parser?.parseErrors?.length ?? 0,
139
+ recordCount: records.length,
140
+ declarationCount: declarations.length
141
+ };
142
+ }
143
+
110
144
  function overlapDeclarationConflicts(id, sourcePath, workerChanges, headChanges) {
111
145
  const headByKey = new Map(headChanges.map((change) => [change.key, change]));
112
146
  return workerChanges.flatMap((workerChange) => {
@@ -217,10 +251,11 @@ function merged(id, sourcePath, sourceText, operation, hash, extra = {}) {
217
251
  });
218
252
  }
219
253
 
220
- function blocked(id, sourcePath, reasonCode, conflicts = []) {
254
+ function blocked(id, sourcePath, reasonCode, conflicts = [], extra = {}) {
221
255
  return result(id, sourcePath, 'blocked', {
222
256
  operation: 'blocked',
223
- conflicts: conflicts.length ? conflicts : [conflict(id, sourcePath, reasonCode, reasonCode)]
257
+ conflicts: conflicts.length ? conflicts : [conflict(id, sourcePath, reasonCode, reasonCode)],
258
+ ...extra
224
259
  });
225
260
  }
226
261
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shapeshift-labs/frontier-lang-css",
3
- "version": "0.1.6",
3
+ "version": "0.1.7",
4
4
  "description": "CSS semantic merge evidence and projection adapter for Frontier Lang semantic source documents.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",