ember-scoped-css 3.0.0 → 3.2.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/README.md +61 -3
- package/dist/cjs/all-DJjr6YEx.cjs +1534 -0
- package/dist/cjs/all.cjs +1 -1
- package/dist/cjs/babel.cjs +1 -1
- package/dist/cjs/rollup.cjs +1 -1
- package/dist/cjs/vite.cjs +1 -1
- package/package.json +7 -2
- package/src/lib/path/utils.js +29 -5
- package/types.d.ts +30 -0
- package/dist/cjs/all-BI7LOSuT.cjs +0 -1519
package/dist/cjs/all.cjs
CHANGED
package/dist/cjs/babel.cjs
CHANGED
package/dist/cjs/rollup.cjs
CHANGED
package/dist/cjs/vite.cjs
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ember-scoped-css",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.2.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ember-addon"
|
|
@@ -19,7 +19,8 @@
|
|
|
19
19
|
"dist",
|
|
20
20
|
"declarations",
|
|
21
21
|
"addon-main.cjs",
|
|
22
|
-
"template-registry.d.ts"
|
|
22
|
+
"template-registry.d.ts",
|
|
23
|
+
"types.d.ts"
|
|
23
24
|
],
|
|
24
25
|
"exports": {
|
|
25
26
|
".": {
|
|
@@ -42,6 +43,10 @@
|
|
|
42
43
|
"types": "./template-registry.d.ts",
|
|
43
44
|
"default": "./src/noop.js"
|
|
44
45
|
},
|
|
46
|
+
"./types": {
|
|
47
|
+
"types": "./types.d.ts",
|
|
48
|
+
"default": "./src/noop.js"
|
|
49
|
+
},
|
|
45
50
|
"./test-support": {
|
|
46
51
|
"types": "./declarations/runtime/test-support.d.ts",
|
|
47
52
|
"default": "./dist/runtime/test-support.js"
|
package/src/lib/path/utils.js
CHANGED
|
@@ -235,16 +235,37 @@ export function isRelevantFile(fileName, { additionalRoots, cwd }) {
|
|
|
235
235
|
if (fileName.startsWith(leadingSlashPath.atEmbroider)) return false;
|
|
236
236
|
if (IRRELEVANT_PATHS.some((i) => fileName.includes(i))) return false;
|
|
237
237
|
|
|
238
|
-
let workspace = findWorkspacePath(fileName);
|
|
239
|
-
|
|
240
238
|
assert(cwd, `cwd was not passed to isRelevantFile`);
|
|
241
239
|
|
|
240
|
+
let isInAdditionalRoot = additionalRoots?.some((root) => {
|
|
241
|
+
let relative = path.relative(path.resolve(cwd, root), fileName);
|
|
242
|
+
|
|
243
|
+
return (
|
|
244
|
+
relative !== '..' &&
|
|
245
|
+
!relative.startsWith(`..${path.sep}`) &&
|
|
246
|
+
!path.isAbsolute(relative)
|
|
247
|
+
);
|
|
248
|
+
});
|
|
249
|
+
|
|
250
|
+
let workspace = findWorkspacePath(fileName);
|
|
251
|
+
|
|
242
252
|
let ourWorkspace = findWorkspacePath(cwd);
|
|
243
253
|
|
|
244
|
-
if (workspace !== ourWorkspace) {
|
|
254
|
+
if (workspace !== ourWorkspace && !isInAdditionalRoot) {
|
|
245
255
|
return false;
|
|
246
256
|
}
|
|
247
257
|
|
|
258
|
+
let isInWorkspaceAdditionalRoot =
|
|
259
|
+
workspace === ourWorkspace &&
|
|
260
|
+
additionalRoots?.some((root) => {
|
|
261
|
+
if (path.isAbsolute(root)) return false;
|
|
262
|
+
|
|
263
|
+
let normalizedFileName = `${path.sep}${path.normalize(fileName)}${path.sep}`;
|
|
264
|
+
let normalizedRoot = `${path.sep}${path.normalize(root)}${path.sep}`;
|
|
265
|
+
|
|
266
|
+
return normalizedFileName.includes(normalizedRoot);
|
|
267
|
+
});
|
|
268
|
+
|
|
248
269
|
let local = fileName.replace(workspace, '');
|
|
249
270
|
let [, ...parts] = local.split(path.sep).filter(Boolean);
|
|
250
271
|
|
|
@@ -260,10 +281,13 @@ export function isRelevantFile(fileName, { additionalRoots, cwd }) {
|
|
|
260
281
|
leadingSlashPath.componentsDir,
|
|
261
282
|
leadingSlashPath.templatesDir,
|
|
262
283
|
leadingSlashPath.routesDir,
|
|
263
|
-
...(additionalRoots || []),
|
|
264
284
|
];
|
|
265
285
|
|
|
266
|
-
if (
|
|
286
|
+
if (
|
|
287
|
+
!isInAdditionalRoot &&
|
|
288
|
+
!isInWorkspaceAdditionalRoot &&
|
|
289
|
+
!roots.some((root) => fileName.includes(root))
|
|
290
|
+
) {
|
|
267
291
|
return;
|
|
268
292
|
}
|
|
269
293
|
|
package/types.d.ts
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This declaration file teaches TypeScript (via Glint) about the special
|
|
3
|
+
* attributes that ember-scoped-css adds to the `<style>` element,
|
|
4
|
+
* so that `<style scoped>` and `<style inline>` type-check.
|
|
5
|
+
*
|
|
6
|
+
* Add it to your tsconfig.json:
|
|
7
|
+
*
|
|
8
|
+
* ```jsonc
|
|
9
|
+
* {
|
|
10
|
+
* "compilerOptions": {
|
|
11
|
+
* "types": ["ember-scoped-css/types"]
|
|
12
|
+
* }
|
|
13
|
+
* }
|
|
14
|
+
* ```
|
|
15
|
+
*
|
|
16
|
+
* or, if you don't use `compilerOptions.types`, import it from a
|
|
17
|
+
* type-declaration file that is included in your project:
|
|
18
|
+
*
|
|
19
|
+
* ```ts
|
|
20
|
+
* import 'ember-scoped-css/types';
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
import '@glint/template';
|
|
24
|
+
|
|
25
|
+
declare global {
|
|
26
|
+
interface HTMLStyleElementAttributes {
|
|
27
|
+
scoped: '';
|
|
28
|
+
inline: '';
|
|
29
|
+
}
|
|
30
|
+
}
|