@wix/zero-config-implementation 1.23.0 → 1.25.0
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/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"registry": "https://registry.npmjs.org/",
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
7
|
-
"version": "1.
|
|
7
|
+
"version": "1.25.0",
|
|
8
8
|
"description": "Core library for extracting component manifests from JS and CSS files",
|
|
9
9
|
"type": "module",
|
|
10
10
|
"main": "dist/index.js",
|
|
@@ -83,5 +83,5 @@
|
|
|
83
83
|
]
|
|
84
84
|
}
|
|
85
85
|
},
|
|
86
|
-
"falconPackageHash": "
|
|
86
|
+
"falconPackageHash": "e76e4e02feadede0d8c9d011d32118218b349b5ab948a12605907e98"
|
|
87
87
|
}
|
|
@@ -1,6 +1,21 @@
|
|
|
1
|
+
import { existsSync } from 'node:fs'
|
|
1
2
|
import { createRequire } from 'node:module'
|
|
3
|
+
import { dirname, join } from 'node:path'
|
|
2
4
|
import { Result, err } from 'neverthrow'
|
|
3
5
|
|
|
6
|
+
function collectNodeModulesPaths(filePath: string): string[] {
|
|
7
|
+
const paths: string[] = []
|
|
8
|
+
let dir = dirname(filePath)
|
|
9
|
+
while (true) {
|
|
10
|
+
const candidate = join(dir, 'node_modules')
|
|
11
|
+
if (existsSync(candidate)) paths.push(candidate)
|
|
12
|
+
const parent = dirname(dir)
|
|
13
|
+
if (parent === dir) break
|
|
14
|
+
dir = parent
|
|
15
|
+
}
|
|
16
|
+
return paths
|
|
17
|
+
}
|
|
18
|
+
|
|
4
19
|
const require = createRequire(import.meta.url)
|
|
5
20
|
|
|
6
21
|
export function compileSass(filePath: string): Result<string, Error> {
|
|
@@ -14,26 +29,11 @@ export function compileSass(filePath: string): Result<string, Error> {
|
|
|
14
29
|
),
|
|
15
30
|
)
|
|
16
31
|
}
|
|
32
|
+
const loadPaths = collectNodeModulesPaths(filePath)
|
|
17
33
|
return Result.fromThrowable(
|
|
18
34
|
() =>
|
|
19
35
|
sass.compile(filePath, {
|
|
20
|
-
|
|
21
|
-
{
|
|
22
|
-
// Return null for relative paths and built-in sass: modules so the
|
|
23
|
-
// built-in filesystem resolver handles them. For everything else
|
|
24
|
-
// (aliases, missing node_modules, etc.) silently return empty content
|
|
25
|
-
// rather than failing the whole compilation.
|
|
26
|
-
canonicalize(url: string): URL | null {
|
|
27
|
-
if (url.startsWith('.') || url.startsWith('/') || url.startsWith('sass:')) {
|
|
28
|
-
return null
|
|
29
|
-
}
|
|
30
|
-
return new URL(`empty-sass-import:${encodeURIComponent(url)}`)
|
|
31
|
-
},
|
|
32
|
-
load(): { contents: string; syntax: 'scss' } {
|
|
33
|
-
return { contents: '', syntax: 'scss' }
|
|
34
|
-
},
|
|
35
|
-
},
|
|
36
|
-
],
|
|
36
|
+
loadPaths,
|
|
37
37
|
}).css,
|
|
38
38
|
(thrown) => (thrown instanceof Error ? thrown : new Error(String(thrown))),
|
|
39
39
|
)()
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
* based on its tag, role, and whether it has text content.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
+
import { CSS_PROPERTIES } from '@wix/zero-config-schema'
|
|
8
9
|
import type { CreateElementEvent, ReactExtractor } from './core/types'
|
|
9
10
|
|
|
10
11
|
// ─────────────────────────────────────────────────────────────────────────────
|
|
@@ -62,41 +63,50 @@ const INTERACTIVE_TAGS = new Set(['button', 'input', 'textarea', 'select'])
|
|
|
62
63
|
/**
|
|
63
64
|
* CSS properties for Layout Containers and Interactive Elements
|
|
64
65
|
*/
|
|
66
|
+
const { CSS_PROPERTY_TYPE } = CSS_PROPERTIES
|
|
67
|
+
|
|
65
68
|
const CONTAINER_CSS_PROPERTIES = [
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
69
|
+
CSS_PROPERTY_TYPE.background,
|
|
70
|
+
CSS_PROPERTY_TYPE.borderTop,
|
|
71
|
+
CSS_PROPERTY_TYPE.borderBottom,
|
|
72
|
+
CSS_PROPERTY_TYPE.borderInlineStart,
|
|
73
|
+
CSS_PROPERTY_TYPE.borderInlineEnd,
|
|
74
|
+
CSS_PROPERTY_TYPE.paddingTop,
|
|
75
|
+
CSS_PROPERTY_TYPE.paddingBottom,
|
|
76
|
+
CSS_PROPERTY_TYPE.paddingInlineStart,
|
|
77
|
+
CSS_PROPERTY_TYPE.paddingInlineEnd,
|
|
78
|
+
CSS_PROPERTY_TYPE.borderStartStartRadius,
|
|
79
|
+
CSS_PROPERTY_TYPE.borderStartEndRadius,
|
|
80
|
+
CSS_PROPERTY_TYPE.borderEndStartRadius,
|
|
81
|
+
CSS_PROPERTY_TYPE.borderEndEndRadius,
|
|
82
|
+
CSS_PROPERTY_TYPE.boxShadow,
|
|
80
83
|
]
|
|
81
84
|
|
|
82
85
|
/**
|
|
83
86
|
* CSS properties for Text elements and leaf elements with textContent
|
|
84
87
|
*/
|
|
85
|
-
const TEXT_CSS_PROPERTIES = [
|
|
88
|
+
const TEXT_CSS_PROPERTIES = [
|
|
89
|
+
CSS_PROPERTY_TYPE.font,
|
|
90
|
+
CSS_PROPERTY_TYPE.lineHeight,
|
|
91
|
+
CSS_PROPERTY_TYPE.letterSpacing,
|
|
92
|
+
CSS_PROPERTY_TYPE.textDecorationLine,
|
|
93
|
+
CSS_PROPERTY_TYPE.textTransform,
|
|
94
|
+
CSS_PROPERTY_TYPE.color,
|
|
95
|
+
]
|
|
86
96
|
|
|
87
97
|
/**
|
|
88
98
|
* CSS properties for Media elements (excluding svg)
|
|
89
99
|
*/
|
|
90
100
|
const MEDIA_CSS_PROPERTIES = [
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
101
|
+
CSS_PROPERTY_TYPE.borderTop,
|
|
102
|
+
CSS_PROPERTY_TYPE.borderBottom,
|
|
103
|
+
CSS_PROPERTY_TYPE.borderInlineStart,
|
|
104
|
+
CSS_PROPERTY_TYPE.borderInlineEnd,
|
|
105
|
+
CSS_PROPERTY_TYPE.borderStartStartRadius,
|
|
106
|
+
CSS_PROPERTY_TYPE.borderStartEndRadius,
|
|
107
|
+
CSS_PROPERTY_TYPE.borderEndStartRadius,
|
|
108
|
+
CSS_PROPERTY_TYPE.borderEndEndRadius,
|
|
109
|
+
CSS_PROPERTY_TYPE.boxShadow,
|
|
100
110
|
]
|
|
101
111
|
|
|
102
112
|
// ─────────────────────────────────────────────────────────────────────────────
|