Skip to content

Commit 0936a53

Browse files
committed
refactor!: drop css-inline support
1 parent a10f6d6 commit 0936a53

14 files changed

Lines changed: 41 additions & 219 deletions

File tree

package.json

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,6 @@
6868
"test:chrome": "HAS_CHROME=true vitest"
6969
},
7070
"peerDependencies": {
71-
"@css-inline/css-inline": "^0.19.0",
72-
"@css-inline/css-inline-wasm": "^0.19.0",
7371
"@resvg/resvg-js": "^2.6.0",
7472
"@resvg/resvg-wasm": "^2.6.0",
7573
"@takumi-rs/core": "^0.62.0",
@@ -84,12 +82,6 @@
8482
"unstorage": "^1.15.0"
8583
},
8684
"peerDependenciesMeta": {
87-
"@css-inline/css-inline": {
88-
"optional": true
89-
},
90-
"@css-inline/css-inline-wasm": {
91-
"optional": true
92-
},
9385
"@resvg/resvg-js": {
9486
"optional": true
9587
},
@@ -154,8 +146,6 @@
154146
},
155147
"devDependencies": {
156148
"@antfu/eslint-config": "catalog:",
157-
"@css-inline/css-inline": "catalog:",
158-
"@css-inline/css-inline-wasm": "catalog:",
159149
"@iconify-json/carbon": "catalog:",
160150
"@iconify-json/logos": "catalog:",
161151
"@iconify-json/noto": "catalog:",

pnpm-workspace.yaml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,7 @@ overrides:
2222

2323
catalog:
2424
'@antfu/eslint-config': ^7.3.0
25-
'@clack/prompts': ^1.0.0
26-
'@css-inline/css-inline': ^0.20.0
27-
'@css-inline/css-inline-wasm': ^0.20.0
25+
'@clack/prompts': ^1.0.1
2826
'@iconify-json/carbon': ^1.2.18
2927
'@iconify-json/logos': ^1.2.10
3028
'@iconify-json/noto': ^1.2.7

src/compatibility.ts

Lines changed: 39 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import { addTemplate, useNuxt } from '@nuxt/kit'
66
import { defu } from 'defu'
77
import { env, provider } from 'std-env'
88
import { logger } from './runtime/logger'
9-
import { hasResolvableDependency } from './util'
109

1110
const autodetectableProviders = {
1211
azure_static: 'azure',
@@ -25,13 +24,12 @@ const autodetectableStaticProviders = {
2524

2625
export const NodeRuntime: RuntimeCompatibilitySchema = {
2726
// node-server runtime
28-
'browser': 'on-demand', // this gets changed build start
29-
'css-inline': 'node',
30-
'resvg': 'node',
31-
'satori': 'node',
32-
'takumi': 'node',
33-
'sharp': 'node', // will be disabled if they're missing the dependency
34-
'emoji': 'local', // can bundle icons, no size constraints
27+
browser: 'on-demand', // this gets changed build start
28+
resvg: 'node',
29+
satori: 'node',
30+
takumi: 'node',
31+
sharp: 'node', // will be disabled if they're missing the dependency
32+
emoji: 'local', // can bundle icons, no size constraints
3533
}
3634

3735
const NodeDevRuntime: RuntimeCompatibilitySchema = {
@@ -41,36 +39,33 @@ const NodeDevRuntime: RuntimeCompatibilitySchema = {
4139
}
4240

4341
const cloudflare: RuntimeCompatibilitySchema = {
44-
'browser': 'cloudflare',
45-
'css-inline': false,
46-
'resvg': 'wasm',
47-
'satori': '0-15-wasm',
48-
'takumi': 'wasm',
49-
'sharp': false,
50-
'emoji': 'fetch', // edge size limits - use API instead of bundling 24MB icons
51-
'wasm': {
42+
browser: 'cloudflare',
43+
resvg: 'wasm',
44+
satori: 'wasm',
45+
takumi: 'wasm',
46+
sharp: false,
47+
emoji: 'fetch', // edge size limits - use API instead of bundling 24MB icons
48+
wasm: {
5249
esmImport: true,
5350
lazy: true,
5451
},
5552
}
5653
const awsLambda: RuntimeCompatibilitySchema = {
57-
'browser': false,
58-
'css-inline': 'wasm',
59-
'resvg': 'node',
60-
'satori': 'node',
61-
'takumi': 'node',
62-
'sharp': false, // 0.33.x has issues
63-
'emoji': 'local', // serverless has larger size limits
54+
browser: false,
55+
resvg: 'node',
56+
satori: 'node',
57+
takumi: 'node',
58+
sharp: false, // 0.33.x has issues
59+
emoji: 'local', // serverless has larger size limits
6460
}
6561

6662
export const WebContainer: RuntimeCompatibilitySchema = {
67-
'browser': false,
68-
'css-inline': 'wasm-fs',
69-
'resvg': 'wasm-fs',
70-
'satori': 'wasm-fs',
71-
'takumi': 'wasm',
72-
'sharp': false,
73-
'emoji': 'fetch', // webcontainer has size constraints
63+
browser: false,
64+
resvg: 'wasm-fs',
65+
satori: 'wasm-fs',
66+
takumi: 'wasm',
67+
sharp: false,
68+
emoji: 'fetch', // webcontainer has size constraints
7469
}
7570

7671
export const RuntimeCompatibility: Record<string, RuntimeCompatibilitySchema> = {
@@ -82,14 +77,13 @@ export const RuntimeCompatibility: Record<string, RuntimeCompatibilitySchema> =
8277
'aws-lambda': awsLambda,
8378
'netlify': awsLambda,
8479
'netlify-edge': {
85-
'browser': false,
86-
'css-inline': 'wasm',
87-
'resvg': 'wasm',
88-
'satori': 'node',
89-
'takumi': 'wasm',
90-
'sharp': false,
91-
'emoji': 'fetch', // edge size limits
92-
'wasm': {
80+
browser: false,
81+
resvg: 'wasm',
82+
satori: 'node',
83+
takumi: 'wasm',
84+
sharp: false,
85+
emoji: 'fetch', // edge size limits
86+
wasm: {
9387
rollup: {
9488
targetEnv: 'auto-inline',
9589
sync: ['@resvg/resvg-wasm/index_bg.wasm'],
@@ -99,14 +93,13 @@ export const RuntimeCompatibility: Record<string, RuntimeCompatibilitySchema> =
9993
'firebase': awsLambda,
10094
'vercel': awsLambda,
10195
'vercel-edge': {
102-
'browser': false,
103-
'css-inline': false, // size constraint (2mb is max)
104-
'resvg': 'wasm',
105-
'satori': '0-15-wasm', // 0.16+ uses WebAssembly.instantiate() blocked by edge
106-
'takumi': 'wasm',
107-
'sharp': false,
108-
'emoji': 'fetch', // edge size limits - bundling 24MB icons not viable
109-
'wasm': {
96+
browser: false,
97+
resvg: 'wasm',
98+
satori: 'wasm',
99+
takumi: 'wasm',
100+
sharp: false,
101+
emoji: 'fetch', // edge size limits - bundling 24MB icons not viable
102+
wasm: {
110103
// lowers workers kb size
111104
esmImport: true,
112105
lazy: true,
@@ -152,9 +145,6 @@ export async function applyNitroPresetCompatibility(nitroConfig: NitroConfig, op
152145
const target = resolveNitroPreset(nitroConfig)
153146
const compatibility: RuntimeCompatibilitySchema = getPresetNitroPresetCompatibility(target)
154147

155-
const hasCssInlineNode = await hasResolvableDependency('@css-inline/css-inline')
156-
const hasCssInlineWasm = await hasResolvableDependency('@css-inline/css-inline-wasm')
157-
158148
const { resolve, detectedRenderers } = options
159149

160150
// Enable renderers based on detected component suffixes
@@ -180,11 +170,6 @@ export async function applyNitroPresetCompatibility(nitroConfig: NitroConfig, op
180170
let binding = options.compatibility?.[key]
181171
if (typeof binding === 'undefined')
182172
binding = compatibility[key]
183-
if (key === 'css-inline' && typeof binding === 'string') {
184-
if ((binding === 'node' && !hasCssInlineNode) || (['wasm', 'wasm-fs'].includes(binding) && !hasCssInlineWasm)) {
185-
binding = false
186-
}
187-
}
188173
// @ts-expect-error untyped
189174
resolvedCompatibility[key] = binding
190175
return {
@@ -197,7 +182,6 @@ export async function applyNitroPresetCompatibility(nitroConfig: NitroConfig, op
197182
await applyBinding('takumi'),
198183
await applyBinding('resvg'),
199184
await applyBinding('sharp'),
200-
await applyBinding('css-inline'),
201185
nitroConfig.alias || {},
202186
)
203187
// if we're using any wasm modules we need to enable the wasm runtime

src/runtime/server/og-image/bindings/css-inline/node.ts

Lines changed: 0 additions & 8 deletions
This file was deleted.

src/runtime/server/og-image/bindings/css-inline/wasm-fs.ts

Lines changed: 0 additions & 10 deletions
This file was deleted.

src/runtime/server/og-image/bindings/css-inline/wasm.ts

Lines changed: 0 additions & 9 deletions
This file was deleted.

src/runtime/server/og-image/satori/instances.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import type _sharp from 'sharp'
33

44
// we keep instances alive to avoid re-importing them on every request
55
// Using any for bindings since they differ between node/wasm variants
6-
const cssInlineInstance: { instance?: { initWasmPromise: Promise<void>, cssInline: any } } = { instance: undefined }
76
const sharpInstance: { instance?: typeof _sharp } = { instance: undefined }
87
const resvgInstance: { instance?: { initWasmPromise: Promise<void>, Resvg: any } } = { instance: undefined }
98
const satoriInstance: { instance?: { initWasmPromise: Promise<void>, satori: typeof _satori } } = { instance: undefined }
@@ -24,9 +23,3 @@ export async function useSharp() {
2423
sharpInstance.instance = sharpInstance.instance || await import('#og-image/bindings/sharp').then(m => m.default)
2524
return sharpInstance.instance!
2625
}
27-
28-
export async function useCssInline() {
29-
cssInlineInstance.instance = cssInlineInstance.instance || await import('#og-image/bindings/css-inline').then(m => m.default)
30-
await cssInlineInstance.instance!.initWasmPromise
31-
return cssInlineInstance.instance!.cssInline
32-
}

src/runtime/server/og-image/satori/transforms/inlineCss.ts

Lines changed: 0 additions & 74 deletions
This file was deleted.

src/runtime/server/og-image/satori/vnodes.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import imageSrc from './plugins/imageSrc'
1313
import nuxtIcon from './plugins/nuxt-icon'
1414
import twClasses from './plugins/twClasses'
1515
import { applyEmojis } from './transforms/emojis'
16-
import { applyInlineCss } from './transforms/inlineCss'
1716
import { walkSatoriTree } from './utils'
1817

1918
function camelCase(str: string): string {
@@ -91,9 +90,8 @@ export async function createVNodes(ctx: OgImageRenderEventContext): Promise<VNod
9190
// this fixes any inline style props that need to be wrapped in single quotes, such as:
9291
// background image, fonts, etc
9392
island.html = htmlDecodeQuotes(island.html)
94-
// pre-transform HTML - apply emoji replacements and inline CSS
93+
// pre-transform HTML - apply emoji replacements
9594
await applyEmojis(ctx, island)
96-
await applyInlineCss(ctx, island)
9795
html = island.html
9896
if (html?.includes('<body>')) {
9997
// get inner contents of body

src/runtime/types.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,6 @@ export interface SatoriFontConfig extends FontConfig {
221221

222222
export interface RuntimeCompatibilitySchema {
223223
browser: 'chrome-launcher' | 'on-demand' | 'playwright' | 'cloudflare' | false
224-
['css-inline']: 'node' | 'wasm' | 'wasm-fs' | false
225224
resvg: 'node' | 'node-dev' | 'wasm' | 'wasm-fs' | 'wasm-edge' | false
226225
satori: 'node' | 'wasm' | '0-15-wasm' | 'wasm-fs' | 'wasm-edge' | false
227226
takumi: 'node' | 'node-dev' | 'wasm' | false

0 commit comments

Comments
 (0)