@modern-js/plugin-tailwindcss 2.13.4 → 2.13.5-beta.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.
Files changed (34) hide show
  1. package/dist/cjs/cli.js +4 -0
  2. package/dist/esm/cli.js +4 -0
  3. package/dist/esm-node/cli.js +4 -0
  4. package/dist/js/modern/cli.js +174 -0
  5. package/dist/js/modern/design-token/cli/index.js +110 -0
  6. package/dist/js/modern/design-token/index.js +5 -0
  7. package/dist/js/modern/design-token/postcss-plugin/index.js +18 -0
  8. package/dist/js/modern/design-token/runtime/index.js +6 -0
  9. package/dist/js/modern/design-token/runtime/plugin.js +66 -0
  10. package/dist/js/modern/index.js +4 -0
  11. package/dist/js/modern/tailwind.js +45 -0
  12. package/dist/js/modern/types.js +0 -0
  13. package/dist/js/modern/utils.js +86 -0
  14. package/dist/js/node/cli.js +190 -0
  15. package/dist/js/node/design-token/cli/index.js +125 -0
  16. package/dist/js/node/design-token/index.js +33 -0
  17. package/dist/js/node/design-token/postcss-plugin/index.js +39 -0
  18. package/dist/js/node/design-token/runtime/index.js +34 -0
  19. package/dist/js/node/design-token/runtime/plugin.js +94 -0
  20. package/dist/js/node/index.js +31 -0
  21. package/dist/js/node/tailwind.js +68 -0
  22. package/dist/js/node/types.js +15 -0
  23. package/dist/js/node/utils.js +119 -0
  24. package/dist/js/treeshaking/cli.js +268 -0
  25. package/dist/js/treeshaking/design-token/cli/index.js +118 -0
  26. package/dist/js/treeshaking/design-token/index.js +3 -0
  27. package/dist/js/treeshaking/design-token/postcss-plugin/index.js +17 -0
  28. package/dist/js/treeshaking/design-token/runtime/index.js +4 -0
  29. package/dist/js/treeshaking/design-token/runtime/plugin.js +78 -0
  30. package/dist/js/treeshaking/index.js +2 -0
  31. package/dist/js/treeshaking/tailwind.js +91 -0
  32. package/dist/js/treeshaking/types.js +1 -0
  33. package/dist/js/treeshaking/utils.js +194 -0
  34. package/package.json +4 -4
@@ -0,0 +1,190 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
21
+ mod
22
+ ));
23
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
24
+ var __async = (__this, __arguments, generator) => {
25
+ return new Promise((resolve, reject) => {
26
+ var fulfilled = (value) => {
27
+ try {
28
+ step(generator.next(value));
29
+ } catch (e) {
30
+ reject(e);
31
+ }
32
+ };
33
+ var rejected = (value) => {
34
+ try {
35
+ step(generator.throw(value));
36
+ } catch (e) {
37
+ reject(e);
38
+ }
39
+ };
40
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
41
+ step((generator = generator.apply(__this, __arguments)).next());
42
+ });
43
+ };
44
+ var cli_exports = {};
45
+ __export(cli_exports, {
46
+ default: () => cli_default,
47
+ getRandomTwConfigFileName: () => getRandomTwConfigFileName
48
+ });
49
+ module.exports = __toCommonJS(cli_exports);
50
+ var import_path = __toESM(require("path"));
51
+ var import_utils = require("@modern-js/utils");
52
+ var import_cli = __toESM(require("./design-token/cli"));
53
+ var import_tailwind = require("./tailwind");
54
+ var import_utils2 = require("./utils");
55
+ const supportCssInJsLibrary = "styled-components";
56
+ const getRandomTwConfigFileName = (internalDirectory) => {
57
+ return (0, import_utils.slash)(
58
+ import_path.default.join(
59
+ internalDirectory,
60
+ `tailwind.config.${Date.now()}.${(0, import_utils.nanoid)()}.js`
61
+ )
62
+ );
63
+ };
64
+ var cli_default = ({ pluginName } = {
65
+ pluginName: "@modern-js/plugin-tailwindcss"
66
+ }) => ({
67
+ name: "@modern-js/plugin-tailwindcss",
68
+ usePlugins: [
69
+ (0, import_cli.default)({
70
+ pluginName
71
+ })
72
+ ],
73
+ setup: (api) => __async(void 0, null, function* () {
74
+ const { appDirectory, internalDirectory } = api.useAppContext();
75
+ let internalTwConfigPath = "";
76
+ const haveTwinMacro = yield (0, import_utils2.checkTwinMacroExist)(appDirectory);
77
+ const tailwindPath = (0, import_utils2.getTailwindPath)(appDirectory);
78
+ const tailwindVersion = (0, import_utils2.getTailwindVersion)(appDirectory);
79
+ const defaultContent = [
80
+ "./config/html/**/*.html",
81
+ "./config/html/**/*.ejs",
82
+ "./config/html/**/*.hbs",
83
+ "./src/**/*.js",
84
+ "./src/**/*.jsx",
85
+ "./src/**/*.ts",
86
+ "./src/**/*.tsx",
87
+ "./storybook/**/*"
88
+ ];
89
+ return {
90
+ prepare() {
91
+ if (haveTwinMacro) {
92
+ const twinMajorVersion = (0, import_utils2.getTwinMacroMajorVersion)(appDirectory);
93
+ const useConfigPath = twinMajorVersion && twinMajorVersion < 3;
94
+ if (useConfigPath) {
95
+ internalTwConfigPath = getRandomTwConfigFileName(internalDirectory);
96
+ const globPattern = (0, import_utils.slash)(
97
+ import_path.default.join(appDirectory, import_utils.CONFIG_CACHE_DIR, "*.cjs")
98
+ );
99
+ const files = import_utils.globby.sync(globPattern, {
100
+ absolute: true
101
+ });
102
+ if (files.length > 0) {
103
+ import_utils.fs.writeFileSync(
104
+ internalTwConfigPath,
105
+ (0, import_utils2.template)(files[files.length - 1]),
106
+ "utf-8"
107
+ );
108
+ }
109
+ }
110
+ }
111
+ },
112
+ validateSchema() {
113
+ return import_utils.PLUGIN_SCHEMAS["@modern-js/plugin-tailwindcss"];
114
+ },
115
+ config() {
116
+ let tailwindConfig;
117
+ const initTailwindConfig = () => {
118
+ var _a, _b;
119
+ if (!tailwindConfig) {
120
+ const modernConfig = api.useResolvedConfigContext();
121
+ tailwindConfig = (0, import_tailwind.getTailwindConfig)(
122
+ tailwindVersion,
123
+ (_a = modernConfig == null ? void 0 : modernConfig.tools) == null ? void 0 : _a.tailwindcss,
124
+ (_b = modernConfig == null ? void 0 : modernConfig.source) == null ? void 0 : _b.designSystem,
125
+ {
126
+ pureConfig: {
127
+ content: defaultContent
128
+ }
129
+ }
130
+ );
131
+ }
132
+ };
133
+ return {
134
+ tools: {
135
+ postcss: (config) => {
136
+ initTailwindConfig();
137
+ const tailwindPlugin = require(tailwindPath)(tailwindConfig);
138
+ if (Array.isArray(config.postcssOptions.plugins)) {
139
+ config.postcssOptions.plugins.push(tailwindPlugin);
140
+ } else {
141
+ config.postcssOptions.plugins = [tailwindPlugin];
142
+ }
143
+ },
144
+ babel(_, { addPlugins }) {
145
+ if (haveTwinMacro) {
146
+ initTailwindConfig();
147
+ addPlugins([
148
+ [
149
+ require.resolve("babel-plugin-macros"),
150
+ {
151
+ twin: {
152
+ preset: supportCssInJsLibrary,
153
+ config: internalTwConfigPath || tailwindConfig
154
+ }
155
+ }
156
+ ]
157
+ ]);
158
+ }
159
+ }
160
+ }
161
+ };
162
+ },
163
+ beforeBuildTask(config) {
164
+ const modernConfig = api.useResolvedConfigContext();
165
+ const { designSystem } = modernConfig;
166
+ const tailwindConfig = (0, import_tailwind.getTailwindConfig)(
167
+ tailwindVersion,
168
+ config.style.tailwindCss,
169
+ designSystem,
170
+ {
171
+ pureConfig: {
172
+ content: defaultContent
173
+ }
174
+ }
175
+ );
176
+ const tailwindPlugin = require(tailwindPath)(tailwindConfig);
177
+ if (Array.isArray(config.style.postcss.plugins)) {
178
+ config.style.postcss.plugins.push(tailwindPlugin);
179
+ } else {
180
+ config.style.postcss.plugins = [tailwindPlugin];
181
+ }
182
+ return config;
183
+ }
184
+ };
185
+ })
186
+ });
187
+ // Annotate the CommonJS export names for ESM import in node:
188
+ 0 && (module.exports = {
189
+ getRandomTwConfigFileName
190
+ });
@@ -0,0 +1,125 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
+ var __spreadValues = (a, b) => {
9
+ for (var prop in b || (b = {}))
10
+ if (__hasOwnProp.call(b, prop))
11
+ __defNormalProp(a, prop, b[prop]);
12
+ if (__getOwnPropSymbols)
13
+ for (var prop of __getOwnPropSymbols(b)) {
14
+ if (__propIsEnum.call(b, prop))
15
+ __defNormalProp(a, prop, b[prop]);
16
+ }
17
+ return a;
18
+ };
19
+ var __export = (target, all) => {
20
+ for (var name in all)
21
+ __defProp(target, name, { get: all[name], enumerable: true });
22
+ };
23
+ var __copyProps = (to, from, except, desc) => {
24
+ if (from && typeof from === "object" || typeof from === "function") {
25
+ for (let key of __getOwnPropNames(from))
26
+ if (!__hasOwnProp.call(to, key) && key !== except)
27
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
28
+ }
29
+ return to;
30
+ };
31
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
32
+ var cli_exports = {};
33
+ __export(cli_exports, {
34
+ default: () => cli_default
35
+ });
36
+ module.exports = __toCommonJS(cli_exports);
37
+ var import_utils = require("@modern-js/utils");
38
+ var cli_default = ({ pluginName } = { pluginName: "@modern-js/plugin-tailwindcss" }) => ({
39
+ name: "@modern-js/plugin-design-token",
40
+ setup(api) {
41
+ let pluginsExportsUtils;
42
+ const resolveConfig = (0, import_utils.lazyImport)("tailwindcss/resolveConfig", require);
43
+ const PLUGIN_IDENTIFIER = "designToken";
44
+ const getDesignTokens = (designSystem) => {
45
+ const tailwindcssConfig = {};
46
+ tailwindcssConfig.theme = designSystem ? __spreadValues({}, designSystem) : {};
47
+ if (!designSystem) {
48
+ tailwindcssConfig.presets = [];
49
+ }
50
+ if (designSystem) {
51
+ delete tailwindcssConfig.theme.supportStyledComponents;
52
+ }
53
+ return resolveConfig(tailwindcssConfig).theme || {};
54
+ };
55
+ return {
56
+ config() {
57
+ const appContext = api.useAppContext();
58
+ pluginsExportsUtils = (0, import_utils.createRuntimeExportsUtils)(
59
+ appContext.internalDirectory,
60
+ "plugins"
61
+ );
62
+ return {
63
+ source: {
64
+ alias: {
65
+ "@modern-js/runtime/plugins": pluginsExportsUtils.getPath()
66
+ }
67
+ },
68
+ tools: {}
69
+ };
70
+ },
71
+ modifyEntryImports({ entrypoint, imports }) {
72
+ var _a, _b;
73
+ const userConfig = api.useResolvedConfigContext();
74
+ const designSystem = (_b = (_a = userConfig.source) == null ? void 0 : _a.designSystem) != null ? _b : {};
75
+ if (typeof designSystem === "object" && designSystem.supportStyledComponents) {
76
+ const designTokens = getDesignTokens(userConfig.source.designSystem);
77
+ imports.push({
78
+ value: "@modern-js/runtime/plugins",
79
+ specifiers: [
80
+ {
81
+ imported: PLUGIN_IDENTIFIER
82
+ }
83
+ ],
84
+ initialize: `
85
+ const designTokens = ${JSON.stringify(designTokens)};
86
+ `
87
+ });
88
+ }
89
+ return {
90
+ entrypoint,
91
+ imports
92
+ };
93
+ },
94
+ modifyEntryRuntimePlugins({ entrypoint, plugins }) {
95
+ var _a, _b;
96
+ const userConfig = api.useResolvedConfigContext();
97
+ const designSystem = (_b = (_a = userConfig.source) == null ? void 0 : _a.designSystem) != null ? _b : {};
98
+ let useSCThemeProvider = true;
99
+ if (designSystem) {
100
+ useSCThemeProvider = (designSystem == null ? void 0 : designSystem.supportStyledComponents) || false;
101
+ }
102
+ if (typeof designSystem === "object" && designSystem.supportStyledComponents) {
103
+ plugins.push({
104
+ name: PLUGIN_IDENTIFIER,
105
+ options: `{token: designTokens, useStyledComponentsThemeProvider: ${useSCThemeProvider ? "true" : "false"}, useDesignTokenContext: false}`
106
+ });
107
+ }
108
+ return {
109
+ entrypoint,
110
+ plugins
111
+ };
112
+ },
113
+ validateSchema() {
114
+ return import_utils.PLUGIN_SCHEMAS["@modern-js/plugin-design-token"];
115
+ },
116
+ addRuntimeExports() {
117
+ pluginsExportsUtils.addExport(
118
+ `export { default as designToken } from '${pluginName}/runtime-design-token'`
119
+ );
120
+ }
121
+ };
122
+ }
123
+ });
124
+ // Annotate the CommonJS export names for ESM import in node:
125
+ 0 && (module.exports = {});
@@ -0,0 +1,33 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
22
+ mod
23
+ ));
24
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
25
+ var design_token_exports = {};
26
+ __export(design_token_exports, {
27
+ default: () => import_runtime.default
28
+ });
29
+ module.exports = __toCommonJS(design_token_exports);
30
+ var import_runtime = __toESM(require("./runtime"));
31
+ __reExport(design_token_exports, require("./runtime"), module.exports);
32
+ // Annotate the CommonJS export names for ESM import in node:
33
+ 0 && (module.exports = {});
@@ -0,0 +1,39 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var postcss_plugin_exports = {};
19
+ __export(postcss_plugin_exports, {
20
+ default: () => postcss_plugin_default
21
+ });
22
+ module.exports = __toCommonJS(postcss_plugin_exports);
23
+ var postcss_plugin_default = ({
24
+ cssVarsHash = {}
25
+ } = {}) => ({
26
+ postcssPlugin: "postcss-replace-css-vars",
27
+ Declaration(decl) {
28
+ if (decl.value && typeof decl.value === "string") {
29
+ decl.value = decl.value.replace(/--\S*/g, (match) => {
30
+ if (cssVarsHash[match]) {
31
+ return cssVarsHash[match];
32
+ }
33
+ return match;
34
+ });
35
+ }
36
+ }
37
+ });
38
+ // Annotate the CommonJS export names for ESM import in node:
39
+ 0 && (module.exports = {});
@@ -0,0 +1,34 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
22
+ mod
23
+ ));
24
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
25
+ var runtime_exports = {};
26
+ __export(runtime_exports, {
27
+ default: () => runtime_default
28
+ });
29
+ module.exports = __toCommonJS(runtime_exports);
30
+ var import_plugin = __toESM(require("./plugin"));
31
+ __reExport(runtime_exports, require("./plugin"), module.exports);
32
+ var runtime_default = import_plugin.default;
33
+ // Annotate the CommonJS export names for ESM import in node:
34
+ 0 && (module.exports = {});
@@ -0,0 +1,94 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
9
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
10
+ var __spreadValues = (a, b) => {
11
+ for (var prop in b || (b = {}))
12
+ if (__hasOwnProp.call(b, prop))
13
+ __defNormalProp(a, prop, b[prop]);
14
+ if (__getOwnPropSymbols)
15
+ for (var prop of __getOwnPropSymbols(b)) {
16
+ if (__propIsEnum.call(b, prop))
17
+ __defNormalProp(a, prop, b[prop]);
18
+ }
19
+ return a;
20
+ };
21
+ var __export = (target, all) => {
22
+ for (var name in all)
23
+ __defProp(target, name, { get: all[name], enumerable: true });
24
+ };
25
+ var __copyProps = (to, from, except, desc) => {
26
+ if (from && typeof from === "object" || typeof from === "function") {
27
+ for (let key of __getOwnPropNames(from))
28
+ if (!__hasOwnProp.call(to, key) && key !== except)
29
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
30
+ }
31
+ return to;
32
+ };
33
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
34
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
35
+ mod
36
+ ));
37
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
38
+ var plugin_exports = {};
39
+ __export(plugin_exports, {
40
+ DesignTokenContext: () => DesignTokenContext,
41
+ default: () => plugin_default,
42
+ useDesignTokens: () => useDesignTokens
43
+ });
44
+ module.exports = __toCommonJS(plugin_exports);
45
+ var import_jsx_runtime = require("react/jsx-runtime");
46
+ var import_hoist_non_react_statics = __toESM(require("hoist-non-react-statics"));
47
+ var import_react = __toESM(require("react"));
48
+ const DesignTokenContext = import_react.default.createContext({});
49
+ const useDesignTokens = () => (0, import_react.useContext)(DesignTokenContext);
50
+ var plugin_default = (options = {}) => ({
51
+ name: "@modern-js/plugin-design-token",
52
+ setup: () => ({
53
+ hoc({ App }, next) {
54
+ const DesignTokenAppWrapper = (props) => {
55
+ const {
56
+ token = {},
57
+ useStyledComponentsThemeProvider = false,
58
+ useDesignTokenContext = false
59
+ } = options;
60
+ if (useStyledComponentsThemeProvider && useDesignTokenContext) {
61
+ const { ThemeProvider } = require("@modern-js/runtime/styled");
62
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ThemeProvider, {
63
+ theme: token,
64
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DesignTokenContext.Provider, {
65
+ value: token,
66
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(App, __spreadValues({}, props))
67
+ })
68
+ });
69
+ } else if (useStyledComponentsThemeProvider) {
70
+ const { ThemeProvider } = require("@modern-js/runtime/styled");
71
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ThemeProvider, {
72
+ theme: token,
73
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(App, __spreadValues({}, props))
74
+ });
75
+ } else if (useDesignTokenContext) {
76
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DesignTokenContext.Provider, {
77
+ value: token,
78
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(App, __spreadValues({}, props))
79
+ });
80
+ } else {
81
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(App, __spreadValues({}, props));
82
+ }
83
+ };
84
+ return next({
85
+ App: (0, import_hoist_non_react_statics.default)(DesignTokenAppWrapper, App)
86
+ });
87
+ }
88
+ })
89
+ });
90
+ // Annotate the CommonJS export names for ESM import in node:
91
+ 0 && (module.exports = {
92
+ DesignTokenContext,
93
+ useDesignTokens
94
+ });
@@ -0,0 +1,31 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
21
+ mod
22
+ ));
23
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
24
+ var src_exports = {};
25
+ __export(src_exports, {
26
+ default: () => import_cli.default
27
+ });
28
+ module.exports = __toCommonJS(src_exports);
29
+ var import_cli = __toESM(require("./cli"));
30
+ // Annotate the CommonJS export names for ESM import in node:
31
+ 0 && (module.exports = {});
@@ -0,0 +1,68 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var tailwind_exports = {};
19
+ __export(tailwind_exports, {
20
+ getTailwindConfig: () => getTailwindConfig
21
+ });
22
+ module.exports = __toCommonJS(tailwind_exports);
23
+ var import_utils = require("@modern-js/utils");
24
+ var import_lodash = require("@modern-js/utils/lodash");
25
+ const checkIfExistNotAllowKeys = (tailwindConfig) => {
26
+ const notAllowExistKeys = ["theme"];
27
+ let notAllowKey = "";
28
+ const ret = Object.keys(tailwindConfig).some(
29
+ (key) => notAllowExistKeys.includes(key) && (notAllowKey = key)
30
+ );
31
+ return [ret, notAllowKey];
32
+ };
33
+ const getPureDesignSystemConfig = (designSystemConfig) => {
34
+ const pureDesignSystemConfig = (0, import_lodash.cloneDeep)(designSystemConfig);
35
+ delete pureDesignSystemConfig.supportStyledComponents;
36
+ return pureDesignSystemConfig;
37
+ };
38
+ const getTailwindConfig = (tailwindVersion, tailwindcss, designSystem, option = {}) => {
39
+ const purgeConfig = (0, import_lodash.merge)(
40
+ {
41
+ enabled: process.env.NODE_ENV === "production",
42
+ layers: ["utilities"],
43
+ content: []
44
+ },
45
+ option.pureConfig || {}
46
+ );
47
+ const defaultTailwindConfig = tailwindVersion === "3" ? { content: purgeConfig.content } : {
48
+ purge: purgeConfig
49
+ };
50
+ const tailwindConfig = (0, import_utils.applyOptionsChain)(
51
+ defaultTailwindConfig,
52
+ tailwindcss || {}
53
+ );
54
+ const designSystemConfig = getPureDesignSystemConfig(designSystem != null ? designSystem : {});
55
+ const [exist, key] = checkIfExistNotAllowKeys(tailwindConfig);
56
+ if (exist) {
57
+ import_utils.logger.error(
58
+ `should not exist '${key}' on tools.tailwindcss, please remove it`
59
+ );
60
+ process.exit(0);
61
+ }
62
+ tailwindConfig.theme = designSystemConfig || {};
63
+ return tailwindConfig;
64
+ };
65
+ // Annotate the CommonJS export names for ESM import in node:
66
+ 0 && (module.exports = {
67
+ getTailwindConfig
68
+ });
@@ -0,0 +1,15 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __copyProps = (to, from, except, desc) => {
6
+ if (from && typeof from === "object" || typeof from === "function") {
7
+ for (let key of __getOwnPropNames(from))
8
+ if (!__hasOwnProp.call(to, key) && key !== except)
9
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
10
+ }
11
+ return to;
12
+ };
13
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
14
+ var types_exports = {};
15
+ module.exports = __toCommonJS(types_exports);