tailwindcss-injector 0.0.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/LICENSE +21 -0
- package/dist/index.cjs +44 -0
- package/dist/index.d.cts +8 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +24 -0
- package/dist/postcss.cjs +96 -0
- package/dist/postcss.d.cts +13 -0
- package/dist/postcss.d.ts +13 -0
- package/dist/postcss.js +94 -0
- package/package.json +49 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2021 ice breaker
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var src_exports = {};
|
|
22
|
+
__export(src_exports, {
|
|
23
|
+
bar: () => bar,
|
|
24
|
+
getDirname: () => getDirname,
|
|
25
|
+
xx: () => xx
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(src_exports);
|
|
28
|
+
function bar() {
|
|
29
|
+
return "foo";
|
|
30
|
+
}
|
|
31
|
+
function getDirname() {
|
|
32
|
+
return __dirname;
|
|
33
|
+
}
|
|
34
|
+
var xx = /* @__PURE__ */ ((xx2) => {
|
|
35
|
+
xx2[xx2["id"] = 0] = "id";
|
|
36
|
+
xx2[xx2["dd"] = 1] = "dd";
|
|
37
|
+
return xx2;
|
|
38
|
+
})(xx || {});
|
|
39
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
40
|
+
0 && (module.exports = {
|
|
41
|
+
bar,
|
|
42
|
+
getDirname,
|
|
43
|
+
xx
|
|
44
|
+
});
|
package/dist/index.d.cts
ADDED
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// ../../node_modules/.pnpm/tsup@8.3.5_jiti@2.4.0_postcss@8.4.49_tsx@4.19.2_typescript@5.7.2_yaml@2.6.1/node_modules/tsup/assets/esm_shims.js
|
|
2
|
+
import { fileURLToPath } from "url";
|
|
3
|
+
import path from "path";
|
|
4
|
+
var getFilename = () => fileURLToPath(import.meta.url);
|
|
5
|
+
var getDirname = () => path.dirname(getFilename());
|
|
6
|
+
var __dirname = /* @__PURE__ */ getDirname();
|
|
7
|
+
|
|
8
|
+
// src/index.ts
|
|
9
|
+
function bar() {
|
|
10
|
+
return "foo";
|
|
11
|
+
}
|
|
12
|
+
function getDirname2() {
|
|
13
|
+
return __dirname;
|
|
14
|
+
}
|
|
15
|
+
var xx = /* @__PURE__ */ ((xx2) => {
|
|
16
|
+
xx2[xx2["id"] = 0] = "id";
|
|
17
|
+
xx2[xx2["dd"] = 1] = "dd";
|
|
18
|
+
return xx2;
|
|
19
|
+
})(xx || {});
|
|
20
|
+
export {
|
|
21
|
+
bar,
|
|
22
|
+
getDirname2 as getDirname,
|
|
23
|
+
xx
|
|
24
|
+
};
|
package/dist/postcss.cjs
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }// ../../node_modules/.pnpm/defu@6.1.4/node_modules/defu/dist/defu.mjs
|
|
2
|
+
function isPlainObject(value) {
|
|
3
|
+
if (value === null || typeof value !== "object") {
|
|
4
|
+
return false;
|
|
5
|
+
}
|
|
6
|
+
const prototype = Object.getPrototypeOf(value);
|
|
7
|
+
if (prototype !== null && prototype !== Object.prototype && Object.getPrototypeOf(prototype) !== null) {
|
|
8
|
+
return false;
|
|
9
|
+
}
|
|
10
|
+
if (Symbol.iterator in value) {
|
|
11
|
+
return false;
|
|
12
|
+
}
|
|
13
|
+
if (Symbol.toStringTag in value) {
|
|
14
|
+
return Object.prototype.toString.call(value) === "[object Module]";
|
|
15
|
+
}
|
|
16
|
+
return true;
|
|
17
|
+
}
|
|
18
|
+
function _defu(baseObject, defaults, namespace = ".", merger) {
|
|
19
|
+
if (!isPlainObject(defaults)) {
|
|
20
|
+
return _defu(baseObject, {}, namespace, merger);
|
|
21
|
+
}
|
|
22
|
+
const object = Object.assign({}, defaults);
|
|
23
|
+
for (const key in baseObject) {
|
|
24
|
+
if (key === "__proto__" || key === "constructor") {
|
|
25
|
+
continue;
|
|
26
|
+
}
|
|
27
|
+
const value = baseObject[key];
|
|
28
|
+
if (value === null || value === void 0) {
|
|
29
|
+
continue;
|
|
30
|
+
}
|
|
31
|
+
if (merger && merger(object, key, value, namespace)) {
|
|
32
|
+
continue;
|
|
33
|
+
}
|
|
34
|
+
if (Array.isArray(value) && Array.isArray(object[key])) {
|
|
35
|
+
object[key] = [...value, ...object[key]];
|
|
36
|
+
} else if (isPlainObject(value) && isPlainObject(object[key])) {
|
|
37
|
+
object[key] = _defu(
|
|
38
|
+
value,
|
|
39
|
+
object[key],
|
|
40
|
+
(namespace ? `${namespace}.` : "") + key.toString(),
|
|
41
|
+
merger
|
|
42
|
+
);
|
|
43
|
+
} else {
|
|
44
|
+
object[key] = value;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return object;
|
|
48
|
+
}
|
|
49
|
+
function createDefu(merger) {
|
|
50
|
+
return (...arguments_) => (
|
|
51
|
+
// eslint-disable-next-line unicorn/no-array-reduce
|
|
52
|
+
arguments_.reduce((p, c) => _defu(p, c, "", merger), {})
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
var defu = createDefu();
|
|
56
|
+
var defuFn = createDefu((object, key, currentValue) => {
|
|
57
|
+
if (object[key] !== void 0 && typeof currentValue === "function") {
|
|
58
|
+
object[key] = currentValue(object[key]);
|
|
59
|
+
return true;
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
var defuArrayFn = createDefu((object, key, currentValue) => {
|
|
63
|
+
if (Array.isArray(object[key]) && typeof currentValue === "function") {
|
|
64
|
+
object[key] = currentValue(object[key]);
|
|
65
|
+
return true;
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
// src/postcss.ts
|
|
70
|
+
var _postcss = require('postcss'); var _postcss2 = _interopRequireDefault(_postcss);
|
|
71
|
+
var _tailwindcss = require('tailwindcss'); var _tailwindcss2 = _interopRequireDefault(_tailwindcss);
|
|
72
|
+
var creator = (options) => {
|
|
73
|
+
const { config, filter } = defu(options, {
|
|
74
|
+
filter: () => true,
|
|
75
|
+
config: void 0
|
|
76
|
+
});
|
|
77
|
+
return {
|
|
78
|
+
postcssPlugin: "postcss-tailwindcss-injector",
|
|
79
|
+
async Once(root) {
|
|
80
|
+
if (filter(_optionalChain([root, 'access', _ => _.source, 'optionalAccess', _2 => _2.input]))) {
|
|
81
|
+
const cfg = typeof config === "function" ? config(_optionalChain([root, 'access', _3 => _3.source, 'optionalAccess', _4 => _4.input])) : config;
|
|
82
|
+
const { root: newRoot } = await _postcss2.default.call(void 0, [
|
|
83
|
+
_tailwindcss2.default.call(void 0, cfg)
|
|
84
|
+
]).process(root);
|
|
85
|
+
root.replaceWith(newRoot);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
};
|
|
90
|
+
creator.postcss = true;
|
|
91
|
+
var postcss_default = creator;
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
exports.default = postcss_default;
|
|
95
|
+
|
|
96
|
+
module.exports = exports.default;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import postcss, { PluginCreator } from 'postcss';
|
|
2
|
+
import { Config } from 'tailwindcss';
|
|
3
|
+
|
|
4
|
+
type InlineTailwindcssOptions = string | Config | {
|
|
5
|
+
config: string | Config;
|
|
6
|
+
} | undefined;
|
|
7
|
+
interface Options {
|
|
8
|
+
filter: (input?: postcss.Input) => boolean;
|
|
9
|
+
config: InlineTailwindcssOptions | ((input?: postcss.Input) => InlineTailwindcssOptions);
|
|
10
|
+
}
|
|
11
|
+
declare const creator: PluginCreator<Partial<Options>>;
|
|
12
|
+
|
|
13
|
+
export { type Options, creator as default };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import postcss, { PluginCreator } from 'postcss';
|
|
2
|
+
import { Config } from 'tailwindcss';
|
|
3
|
+
|
|
4
|
+
type InlineTailwindcssOptions = string | Config | {
|
|
5
|
+
config: string | Config;
|
|
6
|
+
} | undefined;
|
|
7
|
+
interface Options {
|
|
8
|
+
filter: (input?: postcss.Input) => boolean;
|
|
9
|
+
config: InlineTailwindcssOptions | ((input?: postcss.Input) => InlineTailwindcssOptions);
|
|
10
|
+
}
|
|
11
|
+
declare const creator: PluginCreator<Partial<Options>>;
|
|
12
|
+
|
|
13
|
+
export { type Options, creator as default };
|
package/dist/postcss.js
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
// ../../node_modules/.pnpm/defu@6.1.4/node_modules/defu/dist/defu.mjs
|
|
2
|
+
function isPlainObject(value) {
|
|
3
|
+
if (value === null || typeof value !== "object") {
|
|
4
|
+
return false;
|
|
5
|
+
}
|
|
6
|
+
const prototype = Object.getPrototypeOf(value);
|
|
7
|
+
if (prototype !== null && prototype !== Object.prototype && Object.getPrototypeOf(prototype) !== null) {
|
|
8
|
+
return false;
|
|
9
|
+
}
|
|
10
|
+
if (Symbol.iterator in value) {
|
|
11
|
+
return false;
|
|
12
|
+
}
|
|
13
|
+
if (Symbol.toStringTag in value) {
|
|
14
|
+
return Object.prototype.toString.call(value) === "[object Module]";
|
|
15
|
+
}
|
|
16
|
+
return true;
|
|
17
|
+
}
|
|
18
|
+
function _defu(baseObject, defaults, namespace = ".", merger) {
|
|
19
|
+
if (!isPlainObject(defaults)) {
|
|
20
|
+
return _defu(baseObject, {}, namespace, merger);
|
|
21
|
+
}
|
|
22
|
+
const object = Object.assign({}, defaults);
|
|
23
|
+
for (const key in baseObject) {
|
|
24
|
+
if (key === "__proto__" || key === "constructor") {
|
|
25
|
+
continue;
|
|
26
|
+
}
|
|
27
|
+
const value = baseObject[key];
|
|
28
|
+
if (value === null || value === void 0) {
|
|
29
|
+
continue;
|
|
30
|
+
}
|
|
31
|
+
if (merger && merger(object, key, value, namespace)) {
|
|
32
|
+
continue;
|
|
33
|
+
}
|
|
34
|
+
if (Array.isArray(value) && Array.isArray(object[key])) {
|
|
35
|
+
object[key] = [...value, ...object[key]];
|
|
36
|
+
} else if (isPlainObject(value) && isPlainObject(object[key])) {
|
|
37
|
+
object[key] = _defu(
|
|
38
|
+
value,
|
|
39
|
+
object[key],
|
|
40
|
+
(namespace ? `${namespace}.` : "") + key.toString(),
|
|
41
|
+
merger
|
|
42
|
+
);
|
|
43
|
+
} else {
|
|
44
|
+
object[key] = value;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return object;
|
|
48
|
+
}
|
|
49
|
+
function createDefu(merger) {
|
|
50
|
+
return (...arguments_) => (
|
|
51
|
+
// eslint-disable-next-line unicorn/no-array-reduce
|
|
52
|
+
arguments_.reduce((p, c) => _defu(p, c, "", merger), {})
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
var defu = createDefu();
|
|
56
|
+
var defuFn = createDefu((object, key, currentValue) => {
|
|
57
|
+
if (object[key] !== void 0 && typeof currentValue === "function") {
|
|
58
|
+
object[key] = currentValue(object[key]);
|
|
59
|
+
return true;
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
var defuArrayFn = createDefu((object, key, currentValue) => {
|
|
63
|
+
if (Array.isArray(object[key]) && typeof currentValue === "function") {
|
|
64
|
+
object[key] = currentValue(object[key]);
|
|
65
|
+
return true;
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
// src/postcss.ts
|
|
70
|
+
import postcss from "postcss";
|
|
71
|
+
import tailwindcss from "tailwindcss";
|
|
72
|
+
var creator = (options) => {
|
|
73
|
+
const { config, filter } = defu(options, {
|
|
74
|
+
filter: () => true,
|
|
75
|
+
config: void 0
|
|
76
|
+
});
|
|
77
|
+
return {
|
|
78
|
+
postcssPlugin: "postcss-tailwindcss-injector",
|
|
79
|
+
async Once(root) {
|
|
80
|
+
if (filter(root.source?.input)) {
|
|
81
|
+
const cfg = typeof config === "function" ? config(root.source?.input) : config;
|
|
82
|
+
const { root: newRoot } = await postcss([
|
|
83
|
+
tailwindcss(cfg)
|
|
84
|
+
]).process(root);
|
|
85
|
+
root.replaceWith(newRoot);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
};
|
|
90
|
+
creator.postcss = true;
|
|
91
|
+
var postcss_default = creator;
|
|
92
|
+
export {
|
|
93
|
+
postcss_default as default
|
|
94
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "tailwindcss-injector",
|
|
3
|
+
"type": "module",
|
|
4
|
+
"version": "0.0.0",
|
|
5
|
+
"description": "tsup(esbuild) build package template",
|
|
6
|
+
"author": "ice breaker <1324318532@qq.com>",
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/sonofmagic/monorepo-template.git",
|
|
11
|
+
"directory": "packages/bar"
|
|
12
|
+
},
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/sonofmagic/monorepo-template/issues"
|
|
15
|
+
},
|
|
16
|
+
"keywords": [],
|
|
17
|
+
"sideEffects": false,
|
|
18
|
+
"exports": {
|
|
19
|
+
".": {
|
|
20
|
+
"types": "./dist/index.d.ts",
|
|
21
|
+
"import": "./dist/index.js",
|
|
22
|
+
"require": "./dist/index.cjs"
|
|
23
|
+
},
|
|
24
|
+
"./postcss": {
|
|
25
|
+
"types": "./dist/postcss.d.ts",
|
|
26
|
+
"import": "./dist/postcss.js",
|
|
27
|
+
"require": "./dist/postcss.cjs"
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
"files": [
|
|
31
|
+
"dist"
|
|
32
|
+
],
|
|
33
|
+
"dependencies": {
|
|
34
|
+
"postcss": "^8.4.49",
|
|
35
|
+
"tailwindcss": "^3.4.15"
|
|
36
|
+
},
|
|
37
|
+
"scripts": {
|
|
38
|
+
"dev": "tsup --watch --sourcemap",
|
|
39
|
+
"build": "tsup",
|
|
40
|
+
"test": "vitest run",
|
|
41
|
+
"test:dev": "vitest",
|
|
42
|
+
"release": "pnpm publish",
|
|
43
|
+
"lint": "eslint .",
|
|
44
|
+
"lint:fix": "eslint . --fix"
|
|
45
|
+
},
|
|
46
|
+
"main": "./dist/index.cjs",
|
|
47
|
+
"module": "./dist/index.js",
|
|
48
|
+
"types": "./dist/index.d.ts"
|
|
49
|
+
}
|