@css-inline/css-inline 0.15.0 → 0.17.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 +17 -2
- package/index.d.ts +17 -6
- package/index.js +9 -4
- package/js-binding.js +0 -29
- package/package.json +13 -13
package/README.md
CHANGED
|
@@ -116,6 +116,7 @@ var inlined = inlineFragment(
|
|
|
116
116
|
- `inlineStyleTags`. Specifies whether to inline CSS from "style" tags. Default: `true`
|
|
117
117
|
- `keepStyleTags`. Specifies whether to keep "style" tags after inlining. Default: `false`
|
|
118
118
|
- `keepLinkTags`. Specifies whether to keep "link" tags after inlining. Default: `false`
|
|
119
|
+
- `keepAtRules`. Specifies whether to keep "at-rules" (starting with `@`) after inlining. Default: `false`
|
|
119
120
|
- `baseUrl`. The base URL used to resolve relative URLs. If you'd like to load stylesheets from your filesystem, use the `file://` scheme. Default: `null`
|
|
120
121
|
- `loadRemoteStylesheets`. Specifies whether remote stylesheets should be loaded. Default: `true`
|
|
121
122
|
- `cache`. Specifies caching options for external stylesheets (for example, `{size: 5}`). Default: `null`
|
|
@@ -148,7 +149,8 @@ The `data-css-inline="ignore"` attribute also allows you to skip `link` and `sty
|
|
|
148
149
|
```
|
|
149
150
|
|
|
150
151
|
Alternatively, you may keep `style` from being removed by using the `data-css-inline="keep"` attribute.
|
|
151
|
-
This is useful if you want to keep `@media` queries for responsive emails in separate `style` tags
|
|
152
|
+
This is useful if you want to keep `@media` queries for responsive emails in separate `style` tags.
|
|
153
|
+
Such tags will be kept in the resulting HTML even if the `keep_style_tags` option is set to `false`.
|
|
152
154
|
|
|
153
155
|
```html
|
|
154
156
|
<head>
|
|
@@ -160,7 +162,20 @@ This is useful if you want to keep `@media` queries for responsive emails in sep
|
|
|
160
162
|
</body>
|
|
161
163
|
```
|
|
162
164
|
|
|
163
|
-
|
|
165
|
+
Another possibility is to set `keep_at_rules` option to `true`. At-rules cannot be inlined into HTML therefore they
|
|
166
|
+
get removed by default. This is useful if you want to keep at-rules, e.g. `@media` queries for responsive emails in
|
|
167
|
+
separate `style` tags but inline any styles which can be inlined.
|
|
168
|
+
Such tags will be kept in the resulting HTML even if the `keep_style_tags` option is explicitly set to `false`.
|
|
169
|
+
|
|
170
|
+
```html
|
|
171
|
+
<head>
|
|
172
|
+
<!-- With keep_at_rules=true "color:blue" will get inlined into <h1> but @media will be kept in <style> -->
|
|
173
|
+
<style>h1 { color: blue; } @media (max-width: 600px) { h1 { font-size: 18px; } }</style>
|
|
174
|
+
</head>
|
|
175
|
+
<body>
|
|
176
|
+
<h1>Big Text</h1>
|
|
177
|
+
</body>
|
|
178
|
+
```
|
|
164
179
|
|
|
165
180
|
You can also cache external stylesheets to avoid excessive network requests:
|
|
166
181
|
|
package/index.d.ts
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
/*
|
|
1
|
+
/* auto-generated by NAPI-RS */
|
|
2
2
|
/* eslint-disable */
|
|
3
|
+
/** Inline CSS styles from <style> tags to matching elements in the HTML tree and return a string. */
|
|
4
|
+
export declare function inline(html: string, options?: Options | undefined | null): string
|
|
3
5
|
|
|
4
|
-
|
|
6
|
+
/** Inline CSS styles into an HTML fragment. */
|
|
7
|
+
export declare function inlineFragment(html: string, css: string, options?: Options | undefined | null): string
|
|
5
8
|
|
|
6
9
|
export interface Options {
|
|
7
10
|
/**
|
|
@@ -15,10 +18,14 @@ export interface Options {
|
|
|
15
18
|
keepStyleTags?: boolean
|
|
16
19
|
/** Keep "link" tags after inlining. */
|
|
17
20
|
keepLinkTags?: boolean
|
|
21
|
+
/** Keep "at-rules" after inlining. */
|
|
22
|
+
keepAtRules?: boolean
|
|
18
23
|
/** Used for loading external stylesheets via relative URLs. */
|
|
19
24
|
baseUrl?: string
|
|
20
25
|
/** Whether remote stylesheets should be loaded or not. */
|
|
21
26
|
loadRemoteStylesheets?: boolean
|
|
27
|
+
/** An LRU Cache for external stylesheets. */
|
|
28
|
+
cache?: StylesheetCache
|
|
22
29
|
/** Additional CSS to inline. */
|
|
23
30
|
extraCss?: string
|
|
24
31
|
/**
|
|
@@ -27,7 +34,11 @@ export interface Options {
|
|
|
27
34
|
*/
|
|
28
35
|
preallocateNodeCapacity?: number
|
|
29
36
|
}
|
|
30
|
-
|
|
31
|
-
export
|
|
32
|
-
/**
|
|
33
|
-
|
|
37
|
+
|
|
38
|
+
export interface StylesheetCache {
|
|
39
|
+
/** Cache size. */
|
|
40
|
+
size: number
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/** Get the package version. */
|
|
44
|
+
export declare function version(): string
|
package/index.js
CHANGED
|
@@ -246,13 +246,18 @@ switch (platform) {
|
|
|
246
246
|
}
|
|
247
247
|
|
|
248
248
|
if (!nativeBinding) {
|
|
249
|
-
|
|
250
|
-
|
|
249
|
+
try {
|
|
250
|
+
nativeBinding = require('@css-inline/css-inline-wasm');
|
|
251
|
+
} catch (e) {
|
|
252
|
+
if (loadError) {
|
|
253
|
+
throw loadError;
|
|
254
|
+
}
|
|
255
|
+
throw e;
|
|
251
256
|
}
|
|
252
|
-
throw new Error(`Failed to load native binding`)
|
|
253
257
|
}
|
|
254
258
|
|
|
255
|
-
const { inline, inlineFragment } = nativeBinding
|
|
259
|
+
const { inline, inlineFragment, version } = nativeBinding
|
|
256
260
|
|
|
257
261
|
module.exports.inline = inline
|
|
258
262
|
module.exports.inlineFragment = inlineFragment
|
|
263
|
+
module.exports.version = version
|
package/js-binding.js
CHANGED
|
@@ -252,35 +252,6 @@ switch (platform) {
|
|
|
252
252
|
}
|
|
253
253
|
}
|
|
254
254
|
break
|
|
255
|
-
case 'riscv64':
|
|
256
|
-
if (isMusl()) {
|
|
257
|
-
localFileExisted = existsSync(
|
|
258
|
-
join(__dirname, 'css-inline.linux-riscv64-musl.node')
|
|
259
|
-
)
|
|
260
|
-
try {
|
|
261
|
-
if (localFileExisted) {
|
|
262
|
-
nativeBinding = require('./css-inline.linux-riscv64-musl.node')
|
|
263
|
-
} else {
|
|
264
|
-
nativeBinding = require('@css-inline/css-inline-linux-riscv64-musl')
|
|
265
|
-
}
|
|
266
|
-
} catch (e) {
|
|
267
|
-
loadError = e
|
|
268
|
-
}
|
|
269
|
-
} else {
|
|
270
|
-
localFileExisted = existsSync(
|
|
271
|
-
join(__dirname, 'css-inline.linux-riscv64-gnu.node')
|
|
272
|
-
)
|
|
273
|
-
try {
|
|
274
|
-
if (localFileExisted) {
|
|
275
|
-
nativeBinding = require('./css-inline.linux-riscv64-gnu.node')
|
|
276
|
-
} else {
|
|
277
|
-
nativeBinding = require('@css-inline/css-inline-linux-riscv64-gnu')
|
|
278
|
-
}
|
|
279
|
-
} catch (e) {
|
|
280
|
-
loadError = e
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
|
-
break
|
|
284
255
|
default:
|
|
285
256
|
throw new Error(`Unsupported architecture on Linux: ${arch}`)
|
|
286
257
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@css-inline/css-inline",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.17.0",
|
|
4
4
|
"description": "High-performance library for inlining CSS into HTML 'style' attributes",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"repository": "https://github.com/Stranger6667/css-inline",
|
|
@@ -97,18 +97,18 @@
|
|
|
97
97
|
"universal": "napi universal",
|
|
98
98
|
"version": "napi version"
|
|
99
99
|
},
|
|
100
|
-
"packageManager": "yarn@4.
|
|
100
|
+
"packageManager": "yarn@4.9.2",
|
|
101
101
|
"optionalDependencies": {
|
|
102
|
-
"@css-inline/css-inline-win32-x64-msvc": "0.
|
|
103
|
-
"@css-inline/css-inline-darwin-x64": "0.
|
|
104
|
-
"@css-inline/css-inline-linux-x64-gnu": "0.
|
|
105
|
-
"@css-inline/css-inline-darwin-arm64": "0.
|
|
106
|
-
"@css-inline/css-inline-android-arm64": "0.
|
|
107
|
-
"@css-inline/css-inline-win32-arm64-msvc": "0.
|
|
108
|
-
"@css-inline/css-inline-linux-arm64-gnu": "0.
|
|
109
|
-
"@css-inline/css-inline-linux-arm64-musl": "0.
|
|
110
|
-
"@css-inline/css-inline-linux-arm-gnueabihf": "0.
|
|
111
|
-
"@css-inline/css-inline-linux-x64-musl": "0.
|
|
112
|
-
"@css-inline/css-inline-android-arm-eabi": "0.
|
|
102
|
+
"@css-inline/css-inline-win32-x64-msvc": "0.17.0",
|
|
103
|
+
"@css-inline/css-inline-darwin-x64": "0.17.0",
|
|
104
|
+
"@css-inline/css-inline-linux-x64-gnu": "0.17.0",
|
|
105
|
+
"@css-inline/css-inline-darwin-arm64": "0.17.0",
|
|
106
|
+
"@css-inline/css-inline-android-arm64": "0.17.0",
|
|
107
|
+
"@css-inline/css-inline-win32-arm64-msvc": "0.17.0",
|
|
108
|
+
"@css-inline/css-inline-linux-arm64-gnu": "0.17.0",
|
|
109
|
+
"@css-inline/css-inline-linux-arm64-musl": "0.17.0",
|
|
110
|
+
"@css-inline/css-inline-linux-arm-gnueabihf": "0.17.0",
|
|
111
|
+
"@css-inline/css-inline-linux-x64-musl": "0.17.0",
|
|
112
|
+
"@css-inline/css-inline-android-arm-eabi": "0.17.0"
|
|
113
113
|
}
|
|
114
114
|
}
|