@marianoguerra/tailwindcss 0.1.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 +59 -0
- package/ffi.js +27715 -0
- package/index.mjs +46 -0
- package/package.json +35 -0
package/index.mjs
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
// Ergonomic JavaScript wrapper around the MoonBit Tailwind compiler.
|
|
2
|
+
//
|
|
3
|
+
// It expects the compiled MoonBit ESM module next to this file as `./ffi.js`
|
|
4
|
+
// (see ./README.md for the build + copy step). The wrapper adds no runtime
|
|
5
|
+
// dependencies.
|
|
6
|
+
|
|
7
|
+
import { compile_css_json } from './ffi.js'
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Compile a Tailwind v4 stylesheet in memory.
|
|
11
|
+
*
|
|
12
|
+
* @param {object} request
|
|
13
|
+
* @param {string} request.input Entry CSS source.
|
|
14
|
+
* @param {string[]} [request.candidates=[]] Utility class names to generate.
|
|
15
|
+
* @param {Object<string,string>} [request.imports={}]
|
|
16
|
+
* In-memory map of path -> stylesheet content used to resolve `@import`.
|
|
17
|
+
* There is no filesystem access, so every `@import` must be listed here.
|
|
18
|
+
* @param {string} [request.base=''] Base directory for resolving relative imports.
|
|
19
|
+
* @param {string} [request.from] Path of the entry stylesheet (for import resolution).
|
|
20
|
+
* @param {number} [request.polyfills=3]
|
|
21
|
+
* Bitmask: 0=none, 1=@property, 2=color-mix, 3=all.
|
|
22
|
+
* @returns {{ css: string }}
|
|
23
|
+
* @throws {Error} if compilation fails.
|
|
24
|
+
*/
|
|
25
|
+
export function compile({
|
|
26
|
+
input,
|
|
27
|
+
candidates = [],
|
|
28
|
+
imports = {},
|
|
29
|
+
base = '',
|
|
30
|
+
from,
|
|
31
|
+
polyfills = 3,
|
|
32
|
+
} = {}) {
|
|
33
|
+
if (typeof input !== 'string') {
|
|
34
|
+
throw new TypeError('compile: `input` (CSS string) is required')
|
|
35
|
+
}
|
|
36
|
+
const request = { css: input, candidates, imports, base, polyfills }
|
|
37
|
+
if (from !== undefined) request.from = from
|
|
38
|
+
|
|
39
|
+
const result = JSON.parse(compile_css_json(JSON.stringify(request)))
|
|
40
|
+
if (!result.ok) {
|
|
41
|
+
throw new Error(`tailwindcss: ${result.error}`)
|
|
42
|
+
}
|
|
43
|
+
return { css: result.css }
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export default compile
|
package/package.json
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@marianoguerra/tailwindcss",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "A MoonBit implementation of the Tailwind CSS v4 compiler, compiled to JavaScript. Compiles Tailwind v4 CSS fully in memory (no filesystem access).",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./index.mjs",
|
|
7
|
+
"module": "./index.mjs",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": "./index.mjs"
|
|
10
|
+
},
|
|
11
|
+
"files": [
|
|
12
|
+
"index.mjs",
|
|
13
|
+
"ffi.js",
|
|
14
|
+
"README.md"
|
|
15
|
+
],
|
|
16
|
+
"keywords": [
|
|
17
|
+
"css",
|
|
18
|
+
"tailwindcss",
|
|
19
|
+
"compiler",
|
|
20
|
+
"moonbit"
|
|
21
|
+
],
|
|
22
|
+
"license": "MIT",
|
|
23
|
+
"author": "Mariano Guerra",
|
|
24
|
+
"repository": {
|
|
25
|
+
"type": "git",
|
|
26
|
+
"url": "https://github.com/marianoguerra/tailwindcss-moonbit.git",
|
|
27
|
+
"directory": "ffi/js"
|
|
28
|
+
},
|
|
29
|
+
"engines": {
|
|
30
|
+
"node": ">=18"
|
|
31
|
+
},
|
|
32
|
+
"publishConfig": {
|
|
33
|
+
"access": "public"
|
|
34
|
+
}
|
|
35
|
+
}
|