Skip to content

Commit d56944f

Browse files
typescript dev dep and dist dir
1 parent 0992701 commit d56944f

File tree

8 files changed

+102
-5
lines changed

8 files changed

+102
-5
lines changed

.gitignore

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
11
node_modules/
22

33
.DS_Store
4-
5-
dist/

dist/cjs/index.d.ts

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export {};

dist/cjs/index.js

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
"use strict";
2+
var __importDefault = (this && this.__importDefault) || function (mod) {
3+
return (mod && mod.__esModule) ? mod : { "default": mod };
4+
};
5+
Object.defineProperty(exports, "__esModule", { value: true });
6+
const plugin_1 = __importDefault(require("tailwindcss/plugin"));
7+
module.exports = plugin_1.default.withOptions(function (options = {}) {
8+
return function ({ matchUtilities, theme, config }) {
9+
const context = {
10+
theme,
11+
config,
12+
...(options !== null && options !== void 0 ? options : {}),
13+
};
14+
matchUtilities({
15+
js: (value) => {
16+
const escape = (str) => {
17+
console.log(`escaping \`${str}\``);
18+
return str.replace(/_/g, '\\_').replace(/ /g, '_');
19+
};
20+
const unescape = (str) => {
21+
console.log(`unescaping \`${str}\``);
22+
str = str.replace(/(?<!\\)_/g, ' ');
23+
str = str.replace(/\\_/g, '_');
24+
return str;
25+
};
26+
const parseString = (str) => {
27+
console.log(`parsing \`${str}\``);
28+
return str.split(/(#{.*?})/g).map((el, i) => (i % 2 === 1 ? el.slice(2, -1) : el));
29+
};
30+
const parts = parseString(escape(value));
31+
const utility = parts
32+
.map((part, i) => {
33+
if (i % 2 === 0) {
34+
return part;
35+
}
36+
else {
37+
const args = Object.keys(context);
38+
const values = Object.values(context);
39+
const func = new Function(...args, `return ${unescape(part)};`);
40+
return escape(`${func(...values)}`);
41+
}
42+
})
43+
.join('');
44+
return {
45+
[`@apply ${utility}`]: {},
46+
};
47+
},
48+
});
49+
};
50+
});

dist/esm/index.d.ts

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export {};

dist/esm/index.js

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import plugin from 'tailwindcss/plugin';
2+
module.exports = plugin.withOptions(function (options = {}) {
3+
return function ({ matchUtilities, theme, config }) {
4+
const context = {
5+
theme,
6+
config,
7+
...(options !== null && options !== void 0 ? options : {}),
8+
};
9+
matchUtilities({
10+
js: (value) => {
11+
const escape = (str) => {
12+
console.log(`escaping \`${str}\``);
13+
return str.replace(/_/g, '\\_').replace(/ /g, '_');
14+
};
15+
const unescape = (str) => {
16+
console.log(`unescaping \`${str}\``);
17+
str = str.replace(/(?<!\\)_/g, ' ');
18+
str = str.replace(/\\_/g, '_');
19+
return str;
20+
};
21+
const parseString = (str) => {
22+
console.log(`parsing \`${str}\``);
23+
return str.split(/(#{.*?})/g).map((el, i) => (i % 2 === 1 ? el.slice(2, -1) : el));
24+
};
25+
const parts = parseString(escape(value));
26+
const utility = parts
27+
.map((part, i) => {
28+
if (i % 2 === 0) {
29+
return part;
30+
}
31+
else {
32+
const args = Object.keys(context);
33+
const values = Object.values(context);
34+
const func = new Function(...args, `return ${unescape(part)};`);
35+
return escape(`${func(...values)}`);
36+
}
37+
})
38+
.join('');
39+
return {
40+
[`@apply ${utility}`]: {},
41+
};
42+
},
43+
});
44+
};
45+
});

dist/types/index.d.ts

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export {};

package-lock.json

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
"eslint": "^8.41.0",
5252
"eslint-config-prettier": "^8.8.0",
5353
"eslint-plugin-prettier": "^5.0.0-alpha.1",
54-
"npm-run-all": "^4.1.5"
54+
"npm-run-all": "^4.1.5",
55+
"typescript": "^5.1.6"
5556
}
5657
}

0 commit comments

Comments
 (0)