@lass-lang/core 0.0.1
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/CHANGELOG.md +23 -0
- package/LICENSE +21 -0
- package/README.md +93 -0
- package/dist/constants.d.ts +32 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +32 -0
- package/dist/constants.js.map +1 -0
- package/dist/context-tracker.d.ts +46 -0
- package/dist/context-tracker.d.ts.map +1 -0
- package/dist/context-tracker.js +76 -0
- package/dist/context-tracker.js.map +1 -0
- package/dist/errors.d.ts +80 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +81 -0
- package/dist/errors.js.map +1 -0
- package/dist/helpers.d.ts +24 -0
- package/dist/helpers.d.ts.map +1 -0
- package/dist/helpers.js +32 -0
- package/dist/helpers.js.map +1 -0
- package/dist/index.d.ts +66 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +82 -0
- package/dist/index.js.map +1 -0
- package/dist/scanner.d.ts +326 -0
- package/dist/scanner.d.ts.map +1 -0
- package/dist/scanner.js +815 -0
- package/dist/scanner.js.map +1 -0
- package/dist/scope-tracker.d.ts +160 -0
- package/dist/scope-tracker.d.ts.map +1 -0
- package/dist/scope-tracker.js +376 -0
- package/dist/scope-tracker.js.map +1 -0
- package/dist/transpiler.d.ts +153 -0
- package/dist/transpiler.d.ts.map +1 -0
- package/dist/transpiler.js +650 -0
- package/dist/transpiler.js.map +1 -0
- package/dist/types.d.ts +55 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +7 -0
- package/dist/types.js.map +1 -0
- package/package.json +56 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scanner.js","sourceRoot":"","sources":["../src/scanner.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAChE,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,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AAC;IACd,CAAC"}
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Scope tracking utilities for CSS property accumulation.
|
|
3
|
+
*
|
|
4
|
+
* Story 3.1: CSS Accumulator in Transpiler
|
|
5
|
+
* Story 3.3: Lookup in {{ }} Context
|
|
6
|
+
* Story 5.1: @{ } Style Block context tracking
|
|
7
|
+
*
|
|
8
|
+
* This module provides utilities for:
|
|
9
|
+
* 1. Cutting CSS into slices at brace boundaries
|
|
10
|
+
* 2. Looking up property values by walking parent chain
|
|
11
|
+
*
|
|
12
|
+
* The approach uses string slices and lazy regex lookup (not Maps).
|
|
13
|
+
* This is compile-time resolution - values are resolved during transpilation.
|
|
14
|
+
*
|
|
15
|
+
* Story 3.3 additions:
|
|
16
|
+
* - Each slice tracks its type ('css' or 'js') based on brace type
|
|
17
|
+
* - Each slice has a parent reference for easy scope walking
|
|
18
|
+
* - findPropertyValue() skips JS-type slices during lookup
|
|
19
|
+
*
|
|
20
|
+
* Story 5.1 additions:
|
|
21
|
+
* - @{ } creates CSS context inside JS context
|
|
22
|
+
* - Context nesting: CSS → {{ JS → @{ CSS → {{ JS }} → CSS } → JS }} → CSS
|
|
23
|
+
*/
|
|
24
|
+
/**
|
|
25
|
+
* Brace types for context tracking.
|
|
26
|
+
* Story 5.1: Added '@{' for style blocks.
|
|
27
|
+
*/
|
|
28
|
+
export type BraceType = '{{' | '{' | '@{' | null;
|
|
29
|
+
/**
|
|
30
|
+
* A single scope slice with metadata.
|
|
31
|
+
* Story 3.3: Added type and parent for scope tracking.
|
|
32
|
+
* Story 5.1: Added openedBy to track brace type.
|
|
33
|
+
*/
|
|
34
|
+
export interface ScopeSlice {
|
|
35
|
+
/** The text content of this slice */
|
|
36
|
+
content: string;
|
|
37
|
+
/** Type of scope: 'css' for { } and @{ }, 'js' for {{ }} */
|
|
38
|
+
type: 'css' | 'js';
|
|
39
|
+
/** Index of parent slice, or null for root-level slices */
|
|
40
|
+
parent: number | null;
|
|
41
|
+
/** What brace type opened this slice: '{{', '{', '@{', or null for root */
|
|
42
|
+
openedBy: BraceType;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Result of cutting CSS by braces.
|
|
46
|
+
*/
|
|
47
|
+
export interface ScopeSlices {
|
|
48
|
+
/** Array of slice objects with content, type, and parent reference */
|
|
49
|
+
slices: ScopeSlice[];
|
|
50
|
+
/** Minimum depth reached (negative indicates unbalanced closing braces) */
|
|
51
|
+
minDepth: number;
|
|
52
|
+
/** Maximum depth reached */
|
|
53
|
+
maxDepth: number;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Cuts CSS text into slices at brace boundaries.
|
|
57
|
+
*
|
|
58
|
+
* Handles three brace types:
|
|
59
|
+
* - { } for CSS blocks (CSS context)
|
|
60
|
+
* - {{ }} for JS expressions (JS context)
|
|
61
|
+
* - @{ } for style blocks (CSS context inside JS)
|
|
62
|
+
*
|
|
63
|
+
* Story 3.3: Each slice now includes:
|
|
64
|
+
* - type: 'css' for content inside { } and @{ }, 'js' for content inside {{ }}
|
|
65
|
+
* - parent: index of the parent slice for scope walking
|
|
66
|
+
*
|
|
67
|
+
* Story 5.1: @{ } creates CSS context inside JS, enabling @(prop) resolution
|
|
68
|
+
* inside style blocks.
|
|
69
|
+
*
|
|
70
|
+
* Example with CSS nesting:
|
|
71
|
+
* ```
|
|
72
|
+
* Input: ".parent { color: blue; .child { border: 1px; } }"
|
|
73
|
+
* Slices: [
|
|
74
|
+
* { content: ".parent ", type: 'css', parent: null },
|
|
75
|
+
* { content: " color: blue; .child ", type: 'css', parent: 0 },
|
|
76
|
+
* { content: " border: 1px; ", type: 'css', parent: 1 },
|
|
77
|
+
* { content: " ", type: 'css', parent: 0 },
|
|
78
|
+
* { content: "", type: 'css', parent: null }
|
|
79
|
+
* ]
|
|
80
|
+
* ```
|
|
81
|
+
*
|
|
82
|
+
* Example with JS expression:
|
|
83
|
+
* ```
|
|
84
|
+
* Input: ".box { color: {{ expr }}; }"
|
|
85
|
+
* Slices: [
|
|
86
|
+
* { content: ".box ", type: 'css', parent: null },
|
|
87
|
+
* { content: " color: ", type: 'css', parent: 0 },
|
|
88
|
+
* { content: " expr ", type: 'js', parent: 1 },
|
|
89
|
+
* { content: "; ", type: 'css', parent: 0 },
|
|
90
|
+
* { content: "", type: 'css', parent: null }
|
|
91
|
+
* ]
|
|
92
|
+
* ```
|
|
93
|
+
*
|
|
94
|
+
* Example with style block:
|
|
95
|
+
* ```
|
|
96
|
+
* Input: ".box { {{ @{ color: red; } }} }"
|
|
97
|
+
* Slices: [
|
|
98
|
+
* { content: ".box ", type: 'css', parent: null },
|
|
99
|
+
* { content: " ", type: 'css', parent: 0 },
|
|
100
|
+
* { content: " ", type: 'js', parent: 1 },
|
|
101
|
+
* { content: " color: red; ", type: 'css', parent: 2 }, // CSS inside @{ }
|
|
102
|
+
* { content: " ", type: 'js', parent: 1 },
|
|
103
|
+
* { content: " ", type: 'css', parent: 0 },
|
|
104
|
+
* { content: "", type: 'css', parent: null }
|
|
105
|
+
* ]
|
|
106
|
+
* ```
|
|
107
|
+
*
|
|
108
|
+
* @param cssZone - The CSS text to split
|
|
109
|
+
* @returns Object with slices array, minDepth, and maxDepth
|
|
110
|
+
*/
|
|
111
|
+
export declare function cutByBraces(cssZone: string): ScopeSlices;
|
|
112
|
+
/**
|
|
113
|
+
* Finds the value of a CSS property by searching the scope tree.
|
|
114
|
+
*
|
|
115
|
+
* Story 3.3: Algorithm using parent references:
|
|
116
|
+
* 1. Search current slice (up to the position before @prop)
|
|
117
|
+
* 2. Search earlier sibling slices (same parent, earlier index)
|
|
118
|
+
* 3. Walk up to parent and repeat
|
|
119
|
+
* 4. Stop when we reach a root slice (parent: null) and exhaust all earlier siblings
|
|
120
|
+
*
|
|
121
|
+
* JS-type slices ({{ }}) are skipped during search since they contain
|
|
122
|
+
* JS code, not CSS property declarations.
|
|
123
|
+
*
|
|
124
|
+
* @param propName - The property name to look up (e.g., "border")
|
|
125
|
+
* @param slices - The slices from cutByBraces()
|
|
126
|
+
* @param currentIndex - Index of the slice containing the @prop reference
|
|
127
|
+
* @param positionInSlice - Character position in current slice (for self-reference protection)
|
|
128
|
+
* @returns The property value, or empty string if not found
|
|
129
|
+
*/
|
|
130
|
+
export declare function findPropertyValue(propName: string, slices: ScopeSlice[], currentIndex: number, positionInSlice?: number): string;
|
|
131
|
+
/**
|
|
132
|
+
* Determines if two slices are in different sibling selector trees.
|
|
133
|
+
*
|
|
134
|
+
* Sibling trees are isolated - properties from one top-level rule
|
|
135
|
+
* cannot be accessed from another. Two slices are siblings when
|
|
136
|
+
* they don't share a common ancestor (neither is in the other's parent chain).
|
|
137
|
+
*
|
|
138
|
+
* Story 3.3: Uses parent references for simpler implementation.
|
|
139
|
+
*
|
|
140
|
+
* @param sliceIndexA - Index of first slice
|
|
141
|
+
* @param sliceIndexB - Index of second slice
|
|
142
|
+
* @param slices - The slices from cutByBraces()
|
|
143
|
+
* @returns true if slices are in DIFFERENT sibling trees (isolated from each other)
|
|
144
|
+
*/
|
|
145
|
+
export declare function areSiblingTrees(sliceIndexA: number, sliceIndexB: number, slices: ScopeSlice[]): boolean;
|
|
146
|
+
/**
|
|
147
|
+
* Checks if a slice is inside an at-rule boundary (@media, @layer, etc).
|
|
148
|
+
*
|
|
149
|
+
* At-rule boundaries create separate scopes - properties from outside
|
|
150
|
+
* cannot be accessed from inside (in v0).
|
|
151
|
+
*
|
|
152
|
+
* Story 3.3: Uses parent references for simpler implementation.
|
|
153
|
+
* Walks up the parent chain checking if any ancestor contains an at-rule.
|
|
154
|
+
*
|
|
155
|
+
* @param slices - The slices from cutByBraces()
|
|
156
|
+
* @param sliceIndex - Index of the slice to check
|
|
157
|
+
* @returns true if the slice is inside an at-rule
|
|
158
|
+
*/
|
|
159
|
+
export declare function isInsideAtRule(slices: ScopeSlice[], sliceIndex: number): boolean;
|
|
160
|
+
//# sourceMappingURL=scope-tracker.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
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cT"}
|
|
@@ -0,0 +1,376 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Scope tracking utilities for CSS property accumulation.
|
|
3
|
+
*
|
|
4
|
+
* Story 3.1: CSS Accumulator in Transpiler
|
|
5
|
+
* Story 3.3: Lookup in {{ }} Context
|
|
6
|
+
* Story 5.1: @{ } Style Block context tracking
|
|
7
|
+
*
|
|
8
|
+
* This module provides utilities for:
|
|
9
|
+
* 1. Cutting CSS into slices at brace boundaries
|
|
10
|
+
* 2. Looking up property values by walking parent chain
|
|
11
|
+
*
|
|
12
|
+
* The approach uses string slices and lazy regex lookup (not Maps).
|
|
13
|
+
* This is compile-time resolution - values are resolved during transpilation.
|
|
14
|
+
*
|
|
15
|
+
* Story 3.3 additions:
|
|
16
|
+
* - Each slice tracks its type ('css' or 'js') based on brace type
|
|
17
|
+
* - Each slice has a parent reference for easy scope walking
|
|
18
|
+
* - findPropertyValue() skips JS-type slices during lookup
|
|
19
|
+
*
|
|
20
|
+
* Story 5.1 additions:
|
|
21
|
+
* - @{ } creates CSS context inside JS context
|
|
22
|
+
* - Context nesting: CSS → {{ JS → @{ CSS → {{ JS }} → CSS } → JS }} → CSS
|
|
23
|
+
*/
|
|
24
|
+
/**
|
|
25
|
+
* Cuts CSS text into slices at brace boundaries.
|
|
26
|
+
*
|
|
27
|
+
* Handles three brace types:
|
|
28
|
+
* - { } for CSS blocks (CSS context)
|
|
29
|
+
* - {{ }} for JS expressions (JS context)
|
|
30
|
+
* - @{ } for style blocks (CSS context inside JS)
|
|
31
|
+
*
|
|
32
|
+
* Story 3.3: Each slice now includes:
|
|
33
|
+
* - type: 'css' for content inside { } and @{ }, 'js' for content inside {{ }}
|
|
34
|
+
* - parent: index of the parent slice for scope walking
|
|
35
|
+
*
|
|
36
|
+
* Story 5.1: @{ } creates CSS context inside JS, enabling @(prop) resolution
|
|
37
|
+
* inside style blocks.
|
|
38
|
+
*
|
|
39
|
+
* Example with CSS nesting:
|
|
40
|
+
* ```
|
|
41
|
+
* Input: ".parent { color: blue; .child { border: 1px; } }"
|
|
42
|
+
* Slices: [
|
|
43
|
+
* { content: ".parent ", type: 'css', parent: null },
|
|
44
|
+
* { content: " color: blue; .child ", type: 'css', parent: 0 },
|
|
45
|
+
* { content: " border: 1px; ", type: 'css', parent: 1 },
|
|
46
|
+
* { content: " ", type: 'css', parent: 0 },
|
|
47
|
+
* { content: "", type: 'css', parent: null }
|
|
48
|
+
* ]
|
|
49
|
+
* ```
|
|
50
|
+
*
|
|
51
|
+
* Example with JS expression:
|
|
52
|
+
* ```
|
|
53
|
+
* Input: ".box { color: {{ expr }}; }"
|
|
54
|
+
* Slices: [
|
|
55
|
+
* { content: ".box ", type: 'css', parent: null },
|
|
56
|
+
* { content: " color: ", type: 'css', parent: 0 },
|
|
57
|
+
* { content: " expr ", type: 'js', parent: 1 },
|
|
58
|
+
* { content: "; ", type: 'css', parent: 0 },
|
|
59
|
+
* { content: "", type: 'css', parent: null }
|
|
60
|
+
* ]
|
|
61
|
+
* ```
|
|
62
|
+
*
|
|
63
|
+
* Example with style block:
|
|
64
|
+
* ```
|
|
65
|
+
* Input: ".box { {{ @{ color: red; } }} }"
|
|
66
|
+
* Slices: [
|
|
67
|
+
* { content: ".box ", type: 'css', parent: null },
|
|
68
|
+
* { content: " ", type: 'css', parent: 0 },
|
|
69
|
+
* { content: " ", type: 'js', parent: 1 },
|
|
70
|
+
* { content: " color: red; ", type: 'css', parent: 2 }, // CSS inside @{ }
|
|
71
|
+
* { content: " ", type: 'js', parent: 1 },
|
|
72
|
+
* { content: " ", type: 'css', parent: 0 },
|
|
73
|
+
* { content: "", type: 'css', parent: null }
|
|
74
|
+
* ]
|
|
75
|
+
* ```
|
|
76
|
+
*
|
|
77
|
+
* @param cssZone - The CSS text to split
|
|
78
|
+
* @returns Object with slices array, minDepth, and maxDepth
|
|
79
|
+
*/
|
|
80
|
+
export function cutByBraces(cssZone) {
|
|
81
|
+
if (!cssZone) {
|
|
82
|
+
return {
|
|
83
|
+
slices: [{ content: '', type: 'css', parent: null, openedBy: null }],
|
|
84
|
+
minDepth: 0,
|
|
85
|
+
maxDepth: 0
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
const slices = [];
|
|
89
|
+
const parentStack = []; // Stack of parent slice indices
|
|
90
|
+
const contextStack = []; // Stack of brace types for matching
|
|
91
|
+
let currentSlice = '';
|
|
92
|
+
let currentType = 'css';
|
|
93
|
+
let currentOpenedBy = null; // What opened the current slice
|
|
94
|
+
let depth = 0;
|
|
95
|
+
let minDepth = 0;
|
|
96
|
+
let maxDepth = 0;
|
|
97
|
+
for (let i = 0; i < cssZone.length; i++) {
|
|
98
|
+
const char = cssZone[i];
|
|
99
|
+
const nextChar = cssZone[i + 1];
|
|
100
|
+
// Check for {{ (double opening brace - JS expression)
|
|
101
|
+
if (char === '{' && nextChar === '{') {
|
|
102
|
+
// Push current slice with current parent and openedBy
|
|
103
|
+
const parent = parentStack.length > 0 ? parentStack[parentStack.length - 1] : null;
|
|
104
|
+
slices.push({ content: currentSlice, type: currentType, parent, openedBy: currentOpenedBy });
|
|
105
|
+
// The slice we just pushed becomes the parent for nested content
|
|
106
|
+
parentStack.push(slices.length - 1);
|
|
107
|
+
contextStack.push({ braceType: '{{', sliceIndex: slices.length - 1 });
|
|
108
|
+
currentSlice = '';
|
|
109
|
+
currentType = 'js'; // Entering JS expression
|
|
110
|
+
currentOpenedBy = '{{';
|
|
111
|
+
depth++;
|
|
112
|
+
maxDepth = Math.max(maxDepth, depth);
|
|
113
|
+
i++; // Skip the second {
|
|
114
|
+
}
|
|
115
|
+
// Check for }} (double closing brace - JS expression)
|
|
116
|
+
else if (char === '}' && nextChar === '}') {
|
|
117
|
+
// Push current slice with current parent and openedBy
|
|
118
|
+
const parent = parentStack.length > 0 ? parentStack[parentStack.length - 1] : null;
|
|
119
|
+
slices.push({ content: currentSlice, type: currentType, parent, openedBy: currentOpenedBy });
|
|
120
|
+
// Pop parent since we're exiting this scope
|
|
121
|
+
parentStack.pop();
|
|
122
|
+
contextStack.pop();
|
|
123
|
+
currentSlice = '';
|
|
124
|
+
// Determine what type and openedBy to return to based on context stack
|
|
125
|
+
currentType = getContextType(contextStack);
|
|
126
|
+
currentOpenedBy = getContextOpenedBy(contextStack);
|
|
127
|
+
depth--;
|
|
128
|
+
minDepth = Math.min(minDepth, depth);
|
|
129
|
+
i++; // Skip the second }
|
|
130
|
+
}
|
|
131
|
+
// Check for @{ (style block - CSS inside JS)
|
|
132
|
+
else if (char === '@' && nextChar === '{') {
|
|
133
|
+
// Push current slice with current parent and openedBy
|
|
134
|
+
const parent = parentStack.length > 0 ? parentStack[parentStack.length - 1] : null;
|
|
135
|
+
slices.push({ content: currentSlice, type: currentType, parent, openedBy: currentOpenedBy });
|
|
136
|
+
// The slice we just pushed becomes the parent for nested content
|
|
137
|
+
parentStack.push(slices.length - 1);
|
|
138
|
+
contextStack.push({ braceType: '@{', sliceIndex: slices.length - 1 });
|
|
139
|
+
currentSlice = '';
|
|
140
|
+
currentType = 'css'; // @{ } creates CSS context
|
|
141
|
+
currentOpenedBy = '@{';
|
|
142
|
+
depth++;
|
|
143
|
+
maxDepth = Math.max(maxDepth, depth);
|
|
144
|
+
i++; // Skip the {
|
|
145
|
+
}
|
|
146
|
+
// Single { (CSS block)
|
|
147
|
+
else if (char === '{') {
|
|
148
|
+
// Push current slice with current parent and openedBy
|
|
149
|
+
const parent = parentStack.length > 0 ? parentStack[parentStack.length - 1] : null;
|
|
150
|
+
slices.push({ content: currentSlice, type: currentType, parent, openedBy: currentOpenedBy });
|
|
151
|
+
// The slice we just pushed becomes the parent for nested content
|
|
152
|
+
parentStack.push(slices.length - 1);
|
|
153
|
+
contextStack.push({ braceType: '{', sliceIndex: slices.length - 1 });
|
|
154
|
+
currentSlice = '';
|
|
155
|
+
currentOpenedBy = '{';
|
|
156
|
+
// CSS block stays in current type (CSS if in CSS, JS if in JS)
|
|
157
|
+
depth++;
|
|
158
|
+
maxDepth = Math.max(maxDepth, depth);
|
|
159
|
+
}
|
|
160
|
+
// Single } (closes CSS block, @{ block, or is part of JS)
|
|
161
|
+
else if (char === '}') {
|
|
162
|
+
// Push current slice with current parent and openedBy
|
|
163
|
+
const parent = parentStack.length > 0 ? parentStack[parentStack.length - 1] : null;
|
|
164
|
+
slices.push({ content: currentSlice, type: currentType, parent, openedBy: currentOpenedBy });
|
|
165
|
+
// Pop parent since we're exiting this scope
|
|
166
|
+
parentStack.pop();
|
|
167
|
+
contextStack.pop();
|
|
168
|
+
currentSlice = '';
|
|
169
|
+
// Determine what type and openedBy to return to based on context stack
|
|
170
|
+
currentType = getContextType(contextStack);
|
|
171
|
+
currentOpenedBy = getContextOpenedBy(contextStack);
|
|
172
|
+
depth--;
|
|
173
|
+
minDepth = Math.min(minDepth, depth);
|
|
174
|
+
}
|
|
175
|
+
else {
|
|
176
|
+
currentSlice += char;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
// Always add trailing content (even if empty) to maintain consistent structure
|
|
180
|
+
const parent = parentStack.length > 0 ? parentStack[parentStack.length - 1] : null;
|
|
181
|
+
slices.push({ content: currentSlice, type: currentType, parent, openedBy: currentOpenedBy });
|
|
182
|
+
return { slices, minDepth, maxDepth };
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Determines the current context type based on the context stack.
|
|
186
|
+
*
|
|
187
|
+
* - Empty stack or top is '{' → 'css'
|
|
188
|
+
* - Top is '{{' → 'js'
|
|
189
|
+
* - Top is '@{' → 'css' (style block creates CSS inside JS)
|
|
190
|
+
*/
|
|
191
|
+
function getContextType(contextStack) {
|
|
192
|
+
if (contextStack.length === 0) {
|
|
193
|
+
return 'css';
|
|
194
|
+
}
|
|
195
|
+
const top = contextStack[contextStack.length - 1];
|
|
196
|
+
switch (top.braceType) {
|
|
197
|
+
case '{{':
|
|
198
|
+
return 'js';
|
|
199
|
+
case '@{':
|
|
200
|
+
case '{':
|
|
201
|
+
default:
|
|
202
|
+
return 'css';
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* Determines what brace opened the current context based on the context stack.
|
|
207
|
+
*/
|
|
208
|
+
function getContextOpenedBy(contextStack) {
|
|
209
|
+
if (contextStack.length === 0) {
|
|
210
|
+
return null;
|
|
211
|
+
}
|
|
212
|
+
return contextStack[contextStack.length - 1].braceType;
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* Finds the value of a CSS property by searching the scope tree.
|
|
216
|
+
*
|
|
217
|
+
* Story 3.3: Algorithm using parent references:
|
|
218
|
+
* 1. Search current slice (up to the position before @prop)
|
|
219
|
+
* 2. Search earlier sibling slices (same parent, earlier index)
|
|
220
|
+
* 3. Walk up to parent and repeat
|
|
221
|
+
* 4. Stop when we reach a root slice (parent: null) and exhaust all earlier siblings
|
|
222
|
+
*
|
|
223
|
+
* JS-type slices ({{ }}) are skipped during search since they contain
|
|
224
|
+
* JS code, not CSS property declarations.
|
|
225
|
+
*
|
|
226
|
+
* @param propName - The property name to look up (e.g., "border")
|
|
227
|
+
* @param slices - The slices from cutByBraces()
|
|
228
|
+
* @param currentIndex - Index of the slice containing the @prop reference
|
|
229
|
+
* @param positionInSlice - Character position in current slice (for self-reference protection)
|
|
230
|
+
* @returns The property value, or empty string if not found
|
|
231
|
+
*/
|
|
232
|
+
export function findPropertyValue(propName, slices, currentIndex, positionInSlice = -1) {
|
|
233
|
+
if (currentIndex < 0 || currentIndex >= slices.length) {
|
|
234
|
+
return '';
|
|
235
|
+
}
|
|
236
|
+
// Escape special regex characters in property name
|
|
237
|
+
const escapedPropName = propName.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
238
|
+
// Pattern: propName followed by : but NOT preceded by @
|
|
239
|
+
// Must match whole property name (word boundary or start of string)
|
|
240
|
+
// Captures the value between : and ; (or end of block)
|
|
241
|
+
// Uses negative lookbehind to exclude @propName: (CSS at-rules)
|
|
242
|
+
const pattern = new RegExp(`(?:^|[\\s;])(?<!@)${escapedPropName}\\s*:\\s*([^;{}]+?)(?:;|$)`, 'gi');
|
|
243
|
+
// Helper to check if a value is resolved (doesn't contain @(...) references)
|
|
244
|
+
const isResolvedValue = (value) => {
|
|
245
|
+
return !value.includes('@(');
|
|
246
|
+
};
|
|
247
|
+
// Search current slice first (with position limit for self-reference protection)
|
|
248
|
+
const currentSlice = slices[currentIndex];
|
|
249
|
+
if (currentSlice.type === 'css') {
|
|
250
|
+
const searchContent = positionInSlice >= 0
|
|
251
|
+
? currentSlice.content.slice(0, positionInSlice)
|
|
252
|
+
: currentSlice.content;
|
|
253
|
+
const match = findLastMatch(searchContent, pattern);
|
|
254
|
+
if (match) {
|
|
255
|
+
const trimmed = match.trim();
|
|
256
|
+
// Skip values that contain unresolved @(...) references
|
|
257
|
+
if (isResolvedValue(trimmed)) {
|
|
258
|
+
return trimmed;
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
// Now search backwards through all earlier slices
|
|
263
|
+
// We search slices with the same parent first (siblings), then walk up
|
|
264
|
+
// The key insight: walk backward through slices, but only search those
|
|
265
|
+
// that are in our ancestry chain (share a common parent path)
|
|
266
|
+
// Build the set of all ancestor indices (the parent chain from current slice)
|
|
267
|
+
const ancestorIndices = new Set();
|
|
268
|
+
let parentIndex = currentSlice.parent;
|
|
269
|
+
while (parentIndex !== null) {
|
|
270
|
+
ancestorIndices.add(parentIndex);
|
|
271
|
+
parentIndex = slices[parentIndex].parent;
|
|
272
|
+
}
|
|
273
|
+
// Walk backward through slices, searching those that share our ancestry
|
|
274
|
+
for (let i = currentIndex - 1; i >= 0; i--) {
|
|
275
|
+
const slice = slices[i];
|
|
276
|
+
// Skip JS-type slices
|
|
277
|
+
if (slice.type === 'js') {
|
|
278
|
+
continue;
|
|
279
|
+
}
|
|
280
|
+
// Check if this slice is in our ancestor chain or shares a parent with one of them
|
|
281
|
+
// A slice is reachable if:
|
|
282
|
+
// 1. It's one of our ancestors (in ancestorIndices)
|
|
283
|
+
// 2. Its parent is one of our ancestors (it's a sibling of an ancestor)
|
|
284
|
+
const isAncestor = ancestorIndices.has(i);
|
|
285
|
+
const isReachableSibling = slice.parent !== null && ancestorIndices.has(slice.parent);
|
|
286
|
+
// Also include slices whose parent is the same as current slice's parent (direct siblings)
|
|
287
|
+
const isDirectSibling = slice.parent === currentSlice.parent;
|
|
288
|
+
if (!isAncestor && !isReachableSibling && !isDirectSibling) {
|
|
289
|
+
continue;
|
|
290
|
+
}
|
|
291
|
+
// Search this slice
|
|
292
|
+
const match = findLastMatch(slice.content, pattern);
|
|
293
|
+
if (match) {
|
|
294
|
+
const trimmed = match.trim();
|
|
295
|
+
// Skip values that contain unresolved @(...) references
|
|
296
|
+
if (isResolvedValue(trimmed)) {
|
|
297
|
+
return trimmed;
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
// Not found - return empty string (MVP behavior)
|
|
302
|
+
return '';
|
|
303
|
+
}
|
|
304
|
+
/**
|
|
305
|
+
* Finds the last match of a pattern in text.
|
|
306
|
+
* Returns the captured group 1 (the property value).
|
|
307
|
+
*/
|
|
308
|
+
function findLastMatch(text, pattern) {
|
|
309
|
+
// Reset lastIndex for global regex
|
|
310
|
+
pattern.lastIndex = 0;
|
|
311
|
+
let lastMatch = null;
|
|
312
|
+
let match;
|
|
313
|
+
while ((match = pattern.exec(text)) !== null) {
|
|
314
|
+
lastMatch = match[1] ?? null;
|
|
315
|
+
}
|
|
316
|
+
return lastMatch;
|
|
317
|
+
}
|
|
318
|
+
/**
|
|
319
|
+
* Determines if two slices are in different sibling selector trees.
|
|
320
|
+
*
|
|
321
|
+
* Sibling trees are isolated - properties from one top-level rule
|
|
322
|
+
* cannot be accessed from another. Two slices are siblings when
|
|
323
|
+
* they don't share a common ancestor (neither is in the other's parent chain).
|
|
324
|
+
*
|
|
325
|
+
* Story 3.3: Uses parent references for simpler implementation.
|
|
326
|
+
*
|
|
327
|
+
* @param sliceIndexA - Index of first slice
|
|
328
|
+
* @param sliceIndexB - Index of second slice
|
|
329
|
+
* @param slices - The slices from cutByBraces()
|
|
330
|
+
* @returns true if slices are in DIFFERENT sibling trees (isolated from each other)
|
|
331
|
+
*/
|
|
332
|
+
export function areSiblingTrees(sliceIndexA, sliceIndexB, slices) {
|
|
333
|
+
// Build set of all ancestors of slice A (including A itself)
|
|
334
|
+
const ancestorsA = new Set();
|
|
335
|
+
let index = sliceIndexA;
|
|
336
|
+
while (index !== null) {
|
|
337
|
+
ancestorsA.add(index);
|
|
338
|
+
index = slices[index].parent;
|
|
339
|
+
}
|
|
340
|
+
// Check if slice B or any of its ancestors is in A's ancestor set
|
|
341
|
+
index = sliceIndexB;
|
|
342
|
+
while (index !== null) {
|
|
343
|
+
if (ancestorsA.has(index)) {
|
|
344
|
+
return false; // Found common ancestor - not siblings
|
|
345
|
+
}
|
|
346
|
+
index = slices[index].parent;
|
|
347
|
+
}
|
|
348
|
+
return true; // No common ancestor - they are siblings
|
|
349
|
+
}
|
|
350
|
+
/**
|
|
351
|
+
* Checks if a slice is inside an at-rule boundary (@media, @layer, etc).
|
|
352
|
+
*
|
|
353
|
+
* At-rule boundaries create separate scopes - properties from outside
|
|
354
|
+
* cannot be accessed from inside (in v0).
|
|
355
|
+
*
|
|
356
|
+
* Story 3.3: Uses parent references for simpler implementation.
|
|
357
|
+
* Walks up the parent chain checking if any ancestor contains an at-rule.
|
|
358
|
+
*
|
|
359
|
+
* @param slices - The slices from cutByBraces()
|
|
360
|
+
* @param sliceIndex - Index of the slice to check
|
|
361
|
+
* @returns true if the slice is inside an at-rule
|
|
362
|
+
*/
|
|
363
|
+
export function isInsideAtRule(slices, sliceIndex) {
|
|
364
|
+
// Walk up parent chain looking for at-rule patterns
|
|
365
|
+
let index = slices[sliceIndex]?.parent ?? null;
|
|
366
|
+
while (index !== null) {
|
|
367
|
+
const slice = slices[index];
|
|
368
|
+
// Check if this ancestor contains an at-rule
|
|
369
|
+
if (/@(?:media|layer|supports|container|keyframes|font-face)\b/i.test(slice.content)) {
|
|
370
|
+
return true;
|
|
371
|
+
}
|
|
372
|
+
index = slice.parent;
|
|
373
|
+
}
|
|
374
|
+
return false;
|
|
375
|
+
}
|
|
376
|
+
//# sourceMappingURL=scope-tracker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scope-tracker.js","sourceRoot":"","sources":["../src/scope-tracker.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AA4CH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuDG;AACH,MAAM,UAAU,WAAW,CAAC,OAAe;IACzC,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,OAAO;YACL,MAAM,EAAE,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;YACpE,QAAQ,EAAE,CAAC;YACX,QAAQ,EAAE,CAAC;SACZ,CAAC;IACJ,CAAC;IAED,MAAM,MAAM,GAAiB,EAAE,CAAC;IAChC,MAAM,WAAW,GAAa,EAAE,CAAC,CAAE,gCAAgC;IACnE,MAAM,YAAY,GAAmB,EAAE,CAAC,CAAE,oCAAoC;IAC9E,IAAI,YAAY,GAAG,EAAE,CAAC;IACtB,IAAI,WAAW,GAAiB,KAAK,CAAC;IACtC,IAAI,eAAe,GAAc,IAAI,CAAC,CAAE,gCAAgC;IACxE,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,IAAI,QAAQ,GAAG,CAAC,CAAC;IACjB,IAAI,QAAQ,GAAG,CAAC,CAAC;IAEjB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACxC,MAAM,IAAI,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;QACxB,MAAM,QAAQ,GAAG,OAAO,CAAC,CAAC,GAAG,CAAC,CAA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