boss-css 0.0.1 → 0.0.2
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 +1 -0
- package/dist/_virtual/rolldown_runtime.cjs +43 -0
- package/dist/_virtual/rolldown_runtime.mjs +20 -0
- package/dist/api/browser.cjs +54 -0
- package/dist/api/browser.mjs +48 -0
- package/dist/api/config.cjs +94 -0
- package/dist/api/config.mjs +91 -0
- package/dist/api/css.cjs +304 -0
- package/dist/api/css.mjs +303 -0
- package/dist/api/dictionary.cjs +218 -0
- package/dist/api/dictionary.mjs +215 -0
- package/dist/api/file/dts.cjs +21 -0
- package/dist/api/file/dts.mjs +21 -0
- package/dist/api/file/file.cjs +123 -0
- package/dist/api/file/file.mjs +120 -0
- package/dist/api/file/js.cjs +118 -0
- package/dist/api/file/js.mjs +116 -0
- package/dist/api/names.cjs +52 -0
- package/dist/api/names.mjs +46 -0
- package/dist/api/noopCss.cjs +37 -0
- package/dist/api/noopCss.mjs +36 -0
- package/dist/api/propTree.cjs +54 -0
- package/dist/api/propTree.mjs +48 -0
- package/dist/api/server.cjs +112 -0
- package/dist/api/server.mjs +106 -0
- package/dist/cli/build.cjs +1 -0
- package/dist/cli/build.mjs +3 -0
- package/dist/cli/index.cjs +30 -0
- package/dist/cli/index.mjs +29 -0
- package/dist/cli/tasks/build.cjs +24 -0
- package/dist/cli/tasks/build.mjs +23 -0
- package/dist/cli/tasks/choose.cjs +47 -0
- package/dist/cli/tasks/choose.mjs +46 -0
- package/dist/cli/tasks/compile.cjs +68 -0
- package/dist/cli/tasks/compile.mjs +67 -0
- package/dist/cli/tasks/dev.cjs +51 -0
- package/dist/cli/tasks/dev.mjs +48 -0
- package/dist/cli/tasks/init.cjs +1835 -0
- package/dist/cli/tasks/init.mjs +1831 -0
- package/dist/cli/tasks/watch.cjs +38 -0
- package/dist/cli/tasks/watch.mjs +37 -0
- package/dist/cli/templates/init.cjs +82 -0
- package/dist/cli/templates/init.mjs +78 -0
- package/dist/cli/types.cjs +13 -0
- package/dist/cli/types.mjs +13 -0
- package/dist/cli/utils.cjs +43 -0
- package/dist/cli/utils.mjs +41 -0
- package/dist/compile/classname-strategy.cjs +79 -0
- package/dist/compile/classname-strategy.mjs +77 -0
- package/dist/compile/classname.cjs +366 -0
- package/dist/compile/classname.mjs +360 -0
- package/dist/compile/index.cjs +238 -0
- package/dist/compile/index.mjs +235 -0
- package/dist/compile/jsx.cjs +803 -0
- package/dist/compile/jsx.mjs +800 -0
- package/dist/compile/prepared.cjs +88 -0
- package/dist/compile/prepared.mjs +87 -0
- package/dist/compile/runtime.cjs +33 -0
- package/dist/compile/runtime.mjs +32 -0
- package/dist/compile/transform.cjs +371 -0
- package/dist/compile/transform.mjs +369 -0
- package/dist/cx/index.cjs +93 -0
- package/dist/cx/index.mjs +85 -0
- package/dist/detect-fw/index.cjs +384 -0
- package/dist/detect-fw/index.mjs +379 -0
- package/dist/dev/client.cjs +39 -0
- package/dist/dev/client.mjs +38 -0
- package/dist/dev/plugin/browser.cjs +11 -0
- package/dist/dev/plugin/browser.mjs +9 -0
- package/dist/dev/plugin/server.cjs +86 -0
- package/dist/dev/plugin/server.mjs +78 -0
- package/dist/dev/port.cjs +46 -0
- package/dist/dev/port.mjs +43 -0
- package/dist/dev/runtime.cjs +28 -0
- package/dist/dev/runtime.mjs +29 -0
- package/dist/dev/server.cjs +808 -0
- package/dist/dev/server.mjs +805 -0
- package/dist/dev/shared.cjs +6 -0
- package/dist/dev/shared.mjs +5 -0
- package/dist/eslint-plugin/index.cjs +66 -0
- package/dist/eslint-plugin/index.mjs +66 -0
- package/dist/eslint-plugin/rules/classnames-only.cjs +68 -0
- package/dist/eslint-plugin/rules/classnames-only.mjs +68 -0
- package/dist/eslint-plugin/rules/format-classnames.cjs +137 -0
- package/dist/eslint-plugin/rules/format-classnames.mjs +136 -0
- package/dist/eslint-plugin/rules/no-unknown-classes.cjs +119 -0
- package/dist/eslint-plugin/rules/no-unknown-classes.mjs +119 -0
- package/dist/eslint-plugin/rules/prefer-classnames.cjs +69 -0
- package/dist/eslint-plugin/rules/prefer-classnames.mjs +69 -0
- package/dist/eslint-plugin/rules/prefer-token-values.cjs +197 -0
- package/dist/eslint-plugin/rules/prefer-token-values.mjs +197 -0
- package/dist/eslint-plugin/rules/props-only.cjs +115 -0
- package/dist/eslint-plugin/rules/props-only.mjs +115 -0
- package/dist/eslint-plugin/rules/redundant-cx.cjs +66 -0
- package/dist/eslint-plugin/rules/redundant-cx.mjs +66 -0
- package/dist/eslint-plugin/rules/require-prop-functions.cjs +130 -0
- package/dist/eslint-plugin/rules/require-prop-functions.mjs +130 -0
- package/dist/eslint-plugin/utils/api.cjs +30 -0
- package/dist/eslint-plugin/utils/api.mjs +29 -0
- package/dist/eslint-plugin/utils/ast.cjs +119 -0
- package/dist/eslint-plugin/utils/ast.mjs +112 -0
- package/dist/eslint-plugin/utils/boss-classes.cjs +185 -0
- package/dist/eslint-plugin/utils/boss-classes.mjs +175 -0
- package/dist/eslint-plugin/utils/defaults.cjs +99 -0
- package/dist/eslint-plugin/utils/defaults.mjs +93 -0
- package/dist/eslint-plugin/utils/format.cjs +20 -0
- package/dist/eslint-plugin/utils/format.mjs +19 -0
- package/dist/eslint-plugin/utils/order.cjs +76 -0
- package/dist/eslint-plugin/utils/order.mjs +76 -0
- package/dist/eslint-plugin/utils/property-order.cjs +449 -0
- package/dist/eslint-plugin/utils/property-order.mjs +448 -0
- package/dist/eslint-plugin/utils/static.cjs +36 -0
- package/dist/eslint-plugin/utils/static.mjs +35 -0
- package/dist/fontsource/directory.cjs +39588 -0
- package/dist/fontsource/directory.mjs +39587 -0
- package/dist/fontsource/server.cjs +291 -0
- package/dist/fontsource/server.mjs +282 -0
- package/dist/index.cjs +10 -0
- package/dist/index.mjs +6 -0
- package/dist/log/browser.cjs +28 -0
- package/dist/log/browser.mjs +28 -0
- package/dist/log/server.cjs +32 -0
- package/dist/log/server.mjs +30 -0
- package/dist/merge/index.cjs +590 -0
- package/dist/merge/index.mjs +586 -0
- package/dist/native/browser.cjs +78 -0
- package/dist/native/browser.mjs +77 -0
- package/dist/native/server.cjs +180 -0
- package/dist/native/server.mjs +176 -0
- package/dist/native/styleTypes.cjs +168 -0
- package/dist/native/styleTypes.mjs +164 -0
- package/dist/parser/classname/server.cjs +239 -0
- package/dist/parser/classname/server.mjs +232 -0
- package/dist/parser/jsx/browser.cjs +66 -0
- package/dist/parser/jsx/browser.mjs +63 -0
- package/dist/parser/jsx/extractCode.cjs +99 -0
- package/dist/parser/jsx/extractCode.mjs +98 -0
- package/dist/parser/jsx/extractPrepared.cjs +123 -0
- package/dist/parser/jsx/extractPrepared.mjs +122 -0
- package/dist/parser/jsx/extractProps.cjs +234 -0
- package/dist/parser/jsx/extractProps.mjs +232 -0
- package/dist/parser/jsx/isDOMProp.cjs +17 -0
- package/dist/parser/jsx/isDOMProp.mjs +15 -0
- package/dist/parser/jsx/native.cjs +110 -0
- package/dist/parser/jsx/native.mjs +108 -0
- package/dist/parser/jsx/runtime.cjs +4 -0
- package/dist/parser/jsx/runtime.mjs +3 -0
- package/dist/parser/jsx/server.cjs +278 -0
- package/dist/parser/jsx/server.mjs +268 -0
- package/dist/postcss/index.cjs +16 -0
- package/dist/postcss/index.mjs +16 -0
- package/dist/prop/at/runtime-only.cjs +90 -0
- package/dist/prop/at/runtime-only.mjs +88 -0
- package/dist/prop/at/server.cjs +282 -0
- package/dist/prop/at/server.mjs +268 -0
- package/dist/prop/at/shared.cjs +153 -0
- package/dist/prop/at/shared.mjs +144 -0
- package/dist/prop/bosswind/browser.cjs +18 -0
- package/dist/prop/bosswind/browser.mjs +16 -0
- package/dist/prop/bosswind/runtime-only.cjs +18 -0
- package/dist/prop/bosswind/runtime-only.mjs +16 -0
- package/dist/prop/bosswind/server.cjs +81 -0
- package/dist/prop/bosswind/server.mjs +72 -0
- package/dist/prop/bosswind/shared.cjs +861 -0
- package/dist/prop/bosswind/shared.mjs +855 -0
- package/dist/prop/bosswind/tailwind-theme.cjs +703 -0
- package/dist/prop/bosswind/tailwind-theme.mjs +702 -0
- package/dist/prop/child/runtime-only.cjs +18 -0
- package/dist/prop/child/runtime-only.mjs +15 -0
- package/dist/prop/child/server.cjs +81 -0
- package/dist/prop/child/server.mjs +72 -0
- package/dist/prop/css/getDtsTemplate.cjs +65 -0
- package/dist/prop/css/getDtsTemplate.mjs +63 -0
- package/dist/prop/css/runtime-only.cjs +14 -0
- package/dist/prop/css/runtime-only.mjs +13 -0
- package/dist/prop/css/server.cjs +99 -0
- package/dist/prop/css/server.mjs +90 -0
- package/dist/prop/pseudo/runtime-only.cjs +23 -0
- package/dist/prop/pseudo/runtime-only.mjs +21 -0
- package/dist/prop/pseudo/server.cjs +91 -0
- package/dist/prop/pseudo/server.mjs +82 -0
- package/dist/prop/pseudo/shared.cjs +61 -0
- package/dist/prop/pseudo/shared.mjs +60 -0
- package/dist/reset/server.cjs +34 -0
- package/dist/reset/server.mjs +26 -0
- package/dist/runtime/index.cjs +119 -0
- package/dist/runtime/index.mjs +118 -0
- package/dist/runtime/preact.cjs +4 -0
- package/dist/runtime/preact.mjs +3 -0
- package/dist/runtime/qwik.cjs +21 -0
- package/dist/runtime/qwik.mjs +18 -0
- package/dist/runtime/react.cjs +4 -0
- package/dist/runtime/react.mjs +3 -0
- package/dist/runtime/solid.cjs +15 -0
- package/dist/runtime/solid.mjs +14 -0
- package/dist/runtime/stencil.cjs +25 -0
- package/dist/runtime/stencil.mjs +21 -0
- package/dist/runtime/style.cjs +14 -0
- package/dist/runtime/style.mjs +13 -0
- package/dist/shared/boundaries.cjs +288 -0
- package/dist/shared/boundaries.mjs +285 -0
- package/dist/shared/customCss.cjs +212 -0
- package/dist/shared/customCss.mjs +211 -0
- package/dist/shared/debug.cjs +76 -0
- package/dist/shared/debug.mjs +74 -0
- package/dist/shared/file.cjs +21 -0
- package/dist/shared/file.mjs +19 -0
- package/dist/shared/framework.cjs +10 -0
- package/dist/shared/framework.mjs +9 -0
- package/dist/shared/json.cjs +58 -0
- package/dist/shared/json.mjs +57 -0
- package/dist/shared/types.cjs +11 -0
- package/dist/shared/types.mjs +10 -0
- package/dist/strategy/classic/runtime-only.cjs +190 -0
- package/dist/strategy/classic/runtime-only.mjs +186 -0
- package/dist/strategy/classname-first/runtime-only.cjs +138 -0
- package/dist/strategy/classname-first/runtime-only.mjs +134 -0
- package/dist/strategy/classname-first/server.cjs +139 -0
- package/dist/strategy/classname-first/server.mjs +133 -0
- package/dist/strategy/classname-only/server.cjs +43 -0
- package/dist/strategy/classname-only/server.mjs +35 -0
- package/dist/strategy/inline-first/browser.cjs +61 -0
- package/dist/strategy/inline-first/browser.mjs +58 -0
- package/dist/strategy/inline-first/runtime-only.cjs +159 -0
- package/dist/strategy/inline-first/runtime-only.mjs +155 -0
- package/dist/strategy/inline-first/server.cjs +92 -0
- package/dist/strategy/inline-first/server.mjs +83 -0
- package/dist/strategy/runtime/runtime-only.cjs +24 -0
- package/dist/strategy/runtime/runtime-only.mjs +22 -0
- package/dist/strategy/runtime/server.cjs +72 -0
- package/dist/strategy/runtime/server.mjs +63 -0
- package/dist/strategy/runtime-only/css.cjs +183 -0
- package/dist/strategy/runtime-only/css.mjs +181 -0
- package/dist/tasks/build.cjs +88 -0
- package/dist/tasks/build.mjs +84 -0
- package/dist/tasks/compile.cjs +12 -0
- package/dist/tasks/compile.mjs +12 -0
- package/dist/tasks/postcss.cjs +116 -0
- package/dist/tasks/postcss.mjs +113 -0
- package/dist/tasks/session.cjs +46 -0
- package/dist/tasks/session.mjs +42 -0
- package/dist/tasks/watch.cjs +102 -0
- package/dist/tasks/watch.mjs +99 -0
- package/dist/transform/cache.cjs +24 -0
- package/dist/transform/cache.mjs +21 -0
- package/dist/transform/processFile.cjs +26 -0
- package/dist/transform/processFile.mjs +24 -0
- package/dist/use/token/browser.cjs +65 -0
- package/dist/use/token/browser.mjs +61 -0
- package/dist/use/token/runtime-only.cjs +245 -0
- package/dist/use/token/runtime-only.mjs +239 -0
- package/dist/use/token/server.cjs +325 -0
- package/dist/use/token/server.mjs +313 -0
- package/dist/use/token/vars.cjs +47 -0
- package/dist/use/token/vars.mjs +46 -0
- package/package.json +300 -4
- package/src/api/config.d.ts +1 -0
- package/src/fontsource/types.d.ts +50 -0
- package/src/packages/document-create-element/createElement.browser.js +3 -0
- package/src/packages/document-create-element/createElement.js +7 -0
- package/src/packages/document-create-element/package.json +17 -0
- package/src/packages/is-css-prop/browser.js +13 -0
- package/src/packages/is-css-prop/index.js +13 -0
- package/src/packages/is-css-prop/package-lock.json +52 -0
- package/src/packages/is-css-prop/package.json +17 -0
- package/src/prop/css/csstype.json +4387 -0
- package/src/prop/css/package.json +3 -0
- package/src/reset/reset.css +259 -0
|
@@ -0,0 +1,384 @@
|
|
|
1
|
+
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
const require_json = require('../shared/json.cjs');
|
|
3
|
+
let node_fs_promises = require("node:fs/promises");
|
|
4
|
+
node_fs_promises = require_rolldown_runtime.__toESM(node_fs_promises);
|
|
5
|
+
let node_path = require("node:path");
|
|
6
|
+
node_path = require_rolldown_runtime.__toESM(node_path);
|
|
7
|
+
|
|
8
|
+
//#region src/detect-fw/index.ts
|
|
9
|
+
const jsxFrameworks = [
|
|
10
|
+
{
|
|
11
|
+
id: "react",
|
|
12
|
+
name: "react",
|
|
13
|
+
label: "React",
|
|
14
|
+
fileType: "jsx",
|
|
15
|
+
className: "className",
|
|
16
|
+
jsx: {
|
|
17
|
+
importSource: "react",
|
|
18
|
+
runtimeModule: "react/jsx-runtime",
|
|
19
|
+
typesModule: "react",
|
|
20
|
+
typesNamespace: "JSX",
|
|
21
|
+
elementType: "BossJSX.ElementType",
|
|
22
|
+
componentProps: "BossJSX.ComponentPropsWithoutRef<C>"
|
|
23
|
+
},
|
|
24
|
+
detect: {
|
|
25
|
+
dependencies: [
|
|
26
|
+
"react",
|
|
27
|
+
"react-dom",
|
|
28
|
+
"react-native"
|
|
29
|
+
],
|
|
30
|
+
importSources: ["react"]
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
id: "preact",
|
|
35
|
+
name: "preact",
|
|
36
|
+
label: "Preact",
|
|
37
|
+
fileType: "jsx",
|
|
38
|
+
className: "className",
|
|
39
|
+
jsx: {
|
|
40
|
+
importSource: "preact",
|
|
41
|
+
runtimeModule: "preact/jsx-runtime",
|
|
42
|
+
typesModule: "preact",
|
|
43
|
+
typesNamespace: "JSX"
|
|
44
|
+
},
|
|
45
|
+
detect: {
|
|
46
|
+
dependencies: ["preact"],
|
|
47
|
+
importSources: ["preact"]
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
id: "solid",
|
|
52
|
+
name: "solid",
|
|
53
|
+
label: "Solid",
|
|
54
|
+
fileType: "jsx",
|
|
55
|
+
className: "class",
|
|
56
|
+
jsx: {
|
|
57
|
+
importSource: "solid-js",
|
|
58
|
+
runtimeModule: "solid-js/jsx-runtime",
|
|
59
|
+
typesModule: "solid-js",
|
|
60
|
+
typesNamespace: "JSX",
|
|
61
|
+
elementType: "BossJSX.ValidComponent",
|
|
62
|
+
componentProps: "BossJSX.ComponentProps<C>"
|
|
63
|
+
},
|
|
64
|
+
detect: {
|
|
65
|
+
dependencies: ["solid-js"],
|
|
66
|
+
importSources: ["solid-js"]
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
id: "qwik",
|
|
71
|
+
name: "qwik",
|
|
72
|
+
label: "Qwik",
|
|
73
|
+
fileType: "jsx",
|
|
74
|
+
className: "class",
|
|
75
|
+
jsx: {
|
|
76
|
+
importSource: "@builder.io/qwik",
|
|
77
|
+
runtimeModule: "@builder.io/qwik/jsx-runtime",
|
|
78
|
+
typesModule: "@builder.io/qwik",
|
|
79
|
+
typesNamespace: "JSX"
|
|
80
|
+
},
|
|
81
|
+
detect: {
|
|
82
|
+
dependencies: ["@builder.io/qwik", "@builder.io/qwik-city"],
|
|
83
|
+
importSources: ["@builder.io/qwik"]
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
id: "stencil",
|
|
88
|
+
name: "stencil",
|
|
89
|
+
label: "Stencil",
|
|
90
|
+
fileType: "jsx",
|
|
91
|
+
className: "class",
|
|
92
|
+
jsx: {
|
|
93
|
+
importSource: "@stencil/core",
|
|
94
|
+
runtimeModule: "@stencil/core/internal",
|
|
95
|
+
typesModule: "@stencil/core",
|
|
96
|
+
typesNamespace: "JSX"
|
|
97
|
+
},
|
|
98
|
+
detect: {
|
|
99
|
+
dependencies: ["@stencil/core"],
|
|
100
|
+
importSources: ["@stencil/core"]
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
];
|
|
104
|
+
const sfcFrameworks = [];
|
|
105
|
+
const frameworkById = new Map(jsxFrameworks.map((entry) => [entry.id, entry]));
|
|
106
|
+
const frameworkByImportSource = new Map(jsxFrameworks.flatMap((entry) => (entry.detect.importSources ?? []).map((source) => [source, entry])));
|
|
107
|
+
const defaultFramework = frameworkById.get("react");
|
|
108
|
+
const defaultElementType = "keyof BossIntrinsicElements | ((props: any) => any) | (new (props: any) => any)";
|
|
109
|
+
const defaultComponentProps = "C extends keyof BossIntrinsicElements ? BossIntrinsicElements[C] : any";
|
|
110
|
+
const stripJsonComments = (input) => {
|
|
111
|
+
let output = "";
|
|
112
|
+
let inString = false;
|
|
113
|
+
let stringChar = "";
|
|
114
|
+
let escaped = false;
|
|
115
|
+
let inLineComment = false;
|
|
116
|
+
let inBlockComment = false;
|
|
117
|
+
for (let index = 0; index < input.length; index += 1) {
|
|
118
|
+
const char = input[index];
|
|
119
|
+
const next = input[index + 1];
|
|
120
|
+
if (inLineComment) {
|
|
121
|
+
if (char === "\n") {
|
|
122
|
+
inLineComment = false;
|
|
123
|
+
output += char;
|
|
124
|
+
}
|
|
125
|
+
continue;
|
|
126
|
+
}
|
|
127
|
+
if (inBlockComment) {
|
|
128
|
+
if (char === "*" && next === "/") {
|
|
129
|
+
inBlockComment = false;
|
|
130
|
+
index += 1;
|
|
131
|
+
}
|
|
132
|
+
continue;
|
|
133
|
+
}
|
|
134
|
+
if (inString) {
|
|
135
|
+
output += char;
|
|
136
|
+
if (escaped) {
|
|
137
|
+
escaped = false;
|
|
138
|
+
continue;
|
|
139
|
+
}
|
|
140
|
+
if (char === "\\") {
|
|
141
|
+
escaped = true;
|
|
142
|
+
continue;
|
|
143
|
+
}
|
|
144
|
+
if (char === stringChar) {
|
|
145
|
+
inString = false;
|
|
146
|
+
stringChar = "";
|
|
147
|
+
}
|
|
148
|
+
continue;
|
|
149
|
+
}
|
|
150
|
+
if (char === "\"" || char === "'") {
|
|
151
|
+
inString = true;
|
|
152
|
+
stringChar = char;
|
|
153
|
+
output += char;
|
|
154
|
+
continue;
|
|
155
|
+
}
|
|
156
|
+
if (char === "/" && next === "/") {
|
|
157
|
+
inLineComment = true;
|
|
158
|
+
index += 1;
|
|
159
|
+
continue;
|
|
160
|
+
}
|
|
161
|
+
if (char === "/" && next === "*") {
|
|
162
|
+
inBlockComment = true;
|
|
163
|
+
index += 1;
|
|
164
|
+
continue;
|
|
165
|
+
}
|
|
166
|
+
output += char;
|
|
167
|
+
}
|
|
168
|
+
return output;
|
|
169
|
+
};
|
|
170
|
+
const stripTrailingCommas = (input) => {
|
|
171
|
+
let output = "";
|
|
172
|
+
let inString = false;
|
|
173
|
+
let stringChar = "";
|
|
174
|
+
let escaped = false;
|
|
175
|
+
for (let index = 0; index < input.length; index += 1) {
|
|
176
|
+
const char = input[index];
|
|
177
|
+
if (inString) {
|
|
178
|
+
output += char;
|
|
179
|
+
if (escaped) {
|
|
180
|
+
escaped = false;
|
|
181
|
+
continue;
|
|
182
|
+
}
|
|
183
|
+
if (char === "\\") {
|
|
184
|
+
escaped = true;
|
|
185
|
+
continue;
|
|
186
|
+
}
|
|
187
|
+
if (char === stringChar) {
|
|
188
|
+
inString = false;
|
|
189
|
+
stringChar = "";
|
|
190
|
+
}
|
|
191
|
+
continue;
|
|
192
|
+
}
|
|
193
|
+
if (char === "\"" || char === "'") {
|
|
194
|
+
inString = true;
|
|
195
|
+
stringChar = char;
|
|
196
|
+
output += char;
|
|
197
|
+
continue;
|
|
198
|
+
}
|
|
199
|
+
if (char === ",") {
|
|
200
|
+
let lookahead = index + 1;
|
|
201
|
+
while (lookahead < input.length && /\s/.test(input[lookahead])) lookahead += 1;
|
|
202
|
+
const nextChar = input[lookahead];
|
|
203
|
+
if (nextChar === "}" || nextChar === "]") continue;
|
|
204
|
+
}
|
|
205
|
+
output += char;
|
|
206
|
+
}
|
|
207
|
+
return output;
|
|
208
|
+
};
|
|
209
|
+
const parseJsonLoose = (raw, filePath) => {
|
|
210
|
+
return require_json.parseJson(stripTrailingCommas(stripJsonComments(raw)), {
|
|
211
|
+
filePath,
|
|
212
|
+
allowTrailingCommas: true
|
|
213
|
+
});
|
|
214
|
+
};
|
|
215
|
+
const readPackageJson = async (cwd) => {
|
|
216
|
+
const filePath = node_path.default.join(cwd, "package.json");
|
|
217
|
+
const raw = await node_fs_promises.default.readFile(filePath, "utf8").catch(() => null);
|
|
218
|
+
if (!raw) return null;
|
|
219
|
+
try {
|
|
220
|
+
return require_json.parseJson(raw, {
|
|
221
|
+
filePath,
|
|
222
|
+
allowTrailingCommas: true
|
|
223
|
+
});
|
|
224
|
+
} catch {
|
|
225
|
+
return null;
|
|
226
|
+
}
|
|
227
|
+
};
|
|
228
|
+
const readTsconfig = async (cwd, preferredPath) => {
|
|
229
|
+
const candidates = preferredPath ? [preferredPath] : [
|
|
230
|
+
"tsconfig.json",
|
|
231
|
+
"tsconfig.app.json",
|
|
232
|
+
"tsconfig.base.json"
|
|
233
|
+
];
|
|
234
|
+
for (const candidate of candidates) {
|
|
235
|
+
const filePath = node_path.default.isAbsolute(candidate) ? candidate : node_path.default.join(cwd, candidate);
|
|
236
|
+
const raw = await node_fs_promises.default.readFile(filePath, "utf8").catch(() => null);
|
|
237
|
+
if (!raw) continue;
|
|
238
|
+
try {
|
|
239
|
+
return parseJsonLoose(raw, filePath);
|
|
240
|
+
} catch {
|
|
241
|
+
continue;
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
return null;
|
|
245
|
+
};
|
|
246
|
+
const collectDependencies = (packageJson) => {
|
|
247
|
+
const fields = [
|
|
248
|
+
"dependencies",
|
|
249
|
+
"devDependencies",
|
|
250
|
+
"peerDependencies",
|
|
251
|
+
"optionalDependencies"
|
|
252
|
+
];
|
|
253
|
+
const deps = /* @__PURE__ */ new Set();
|
|
254
|
+
for (const field of fields) {
|
|
255
|
+
const value = packageJson[field];
|
|
256
|
+
if (!value || typeof value !== "object") continue;
|
|
257
|
+
for (const name of Object.keys(value)) deps.add(name);
|
|
258
|
+
}
|
|
259
|
+
return deps;
|
|
260
|
+
};
|
|
261
|
+
const createDescriptorFromImportSource = (importSource) => {
|
|
262
|
+
const match = frameworkByImportSource.get(importSource);
|
|
263
|
+
if (match) return match;
|
|
264
|
+
return {
|
|
265
|
+
id: "custom",
|
|
266
|
+
name: importSource,
|
|
267
|
+
label: importSource,
|
|
268
|
+
fileType: "jsx",
|
|
269
|
+
className: "className",
|
|
270
|
+
jsx: {
|
|
271
|
+
importSource,
|
|
272
|
+
runtimeModule: `${importSource}/jsx-runtime`,
|
|
273
|
+
typesModule: `${importSource}/jsx-runtime`,
|
|
274
|
+
typesNamespace: "JSX"
|
|
275
|
+
}
|
|
276
|
+
};
|
|
277
|
+
};
|
|
278
|
+
const applyFrameworkOverrides = (base, override) => {
|
|
279
|
+
if (!override) return base;
|
|
280
|
+
const next = { ...base };
|
|
281
|
+
if (override.className) next.className = override.className;
|
|
282
|
+
if (override.fileType) next.fileType = override.fileType;
|
|
283
|
+
if (override.jsx) next.jsx = {
|
|
284
|
+
importSource: override.jsx.importSource ?? next.jsx?.importSource ?? "",
|
|
285
|
+
runtimeModule: override.jsx.runtimeModule ?? next.jsx?.runtimeModule ?? "",
|
|
286
|
+
typesModule: override.jsx.typesModule ?? next.jsx?.typesModule ?? "",
|
|
287
|
+
typesNamespace: override.jsx.typesNamespace ?? next.jsx?.typesNamespace ?? "JSX",
|
|
288
|
+
elementType: override.jsx.elementType ?? next.jsx?.elementType ?? void 0,
|
|
289
|
+
componentProps: override.jsx.componentProps ?? next.jsx?.componentProps ?? void 0
|
|
290
|
+
};
|
|
291
|
+
return next;
|
|
292
|
+
};
|
|
293
|
+
const resolveFrameworkFromConfig = (config) => {
|
|
294
|
+
if (!config?.framework) return null;
|
|
295
|
+
const raw = config.framework;
|
|
296
|
+
if (typeof raw === "string") {
|
|
297
|
+
if (raw === "auto") return null;
|
|
298
|
+
const match = frameworkById.get(raw);
|
|
299
|
+
if (match) return match;
|
|
300
|
+
return createDescriptorFromImportSource(raw);
|
|
301
|
+
}
|
|
302
|
+
if (raw.name && raw.name !== "auto") {
|
|
303
|
+
const match = frameworkById.get(raw.name);
|
|
304
|
+
if (match) return applyFrameworkOverrides(match, raw);
|
|
305
|
+
return applyFrameworkOverrides(createDescriptorFromImportSource(raw.name), raw);
|
|
306
|
+
}
|
|
307
|
+
if (raw.jsx?.importSource || raw.jsx?.typesModule) return applyFrameworkOverrides(createDescriptorFromImportSource(raw.jsx.importSource ?? "custom-jsx-runtime"), raw);
|
|
308
|
+
if (raw.fileType) return applyFrameworkOverrides({
|
|
309
|
+
id: "unknown",
|
|
310
|
+
name: "unknown",
|
|
311
|
+
label: "Unknown",
|
|
312
|
+
fileType: raw.fileType,
|
|
313
|
+
className: "className"
|
|
314
|
+
}, raw);
|
|
315
|
+
return null;
|
|
316
|
+
};
|
|
317
|
+
const resolveFrameworkFromTsconfig = (tsconfig) => {
|
|
318
|
+
const compilerOptions = tsconfig?.compilerOptions;
|
|
319
|
+
if (!compilerOptions || typeof compilerOptions !== "object") return null;
|
|
320
|
+
const jsxImportSource = compilerOptions.jsxImportSource;
|
|
321
|
+
if (typeof jsxImportSource !== "string" || !jsxImportSource.trim()) return null;
|
|
322
|
+
return createDescriptorFromImportSource(jsxImportSource);
|
|
323
|
+
};
|
|
324
|
+
const resolveFrameworkFromPackageJson = (packageJson) => {
|
|
325
|
+
if (!packageJson) return null;
|
|
326
|
+
const deps = collectDependencies(packageJson);
|
|
327
|
+
for (const entry of jsxFrameworks) if (entry.detect.dependencies.some((dep) => deps.has(dep))) return entry;
|
|
328
|
+
for (const entry of sfcFrameworks) if (entry.detect.dependencies.some((dep) => deps.has(dep))) return entry;
|
|
329
|
+
return null;
|
|
330
|
+
};
|
|
331
|
+
const getJsxTypes = (framework) => {
|
|
332
|
+
const jsx = framework.jsx ?? defaultFramework.jsx;
|
|
333
|
+
return {
|
|
334
|
+
...jsx,
|
|
335
|
+
elementType: jsx?.elementType ?? defaultElementType,
|
|
336
|
+
componentProps: jsx?.componentProps ?? defaultComponentProps
|
|
337
|
+
};
|
|
338
|
+
};
|
|
339
|
+
const detectFramework = async (options = {}) => {
|
|
340
|
+
const cwd = options.cwd ?? process.cwd();
|
|
341
|
+
const notes = [];
|
|
342
|
+
const configMatch = resolveFrameworkFromConfig(options.config);
|
|
343
|
+
if (configMatch) return {
|
|
344
|
+
...configMatch,
|
|
345
|
+
source: "config",
|
|
346
|
+
notes
|
|
347
|
+
};
|
|
348
|
+
const tsconfigMatch = resolveFrameworkFromTsconfig(await readTsconfig(cwd, options.tsconfigPath));
|
|
349
|
+
if (tsconfigMatch) {
|
|
350
|
+
notes.push("tsconfig jsxImportSource");
|
|
351
|
+
return {
|
|
352
|
+
...tsconfigMatch,
|
|
353
|
+
source: "tsconfig",
|
|
354
|
+
notes
|
|
355
|
+
};
|
|
356
|
+
}
|
|
357
|
+
const packageMatch = resolveFrameworkFromPackageJson(options.packageJson ?? await readPackageJson(cwd));
|
|
358
|
+
if (packageMatch) {
|
|
359
|
+
notes.push("package.json dependencies");
|
|
360
|
+
return {
|
|
361
|
+
...packageMatch,
|
|
362
|
+
source: "package.json",
|
|
363
|
+
notes
|
|
364
|
+
};
|
|
365
|
+
}
|
|
366
|
+
return {
|
|
367
|
+
...defaultFramework,
|
|
368
|
+
source: "default",
|
|
369
|
+
notes
|
|
370
|
+
};
|
|
371
|
+
};
|
|
372
|
+
const listFrameworks = () => jsxFrameworks.map((entry) => ({
|
|
373
|
+
id: entry.id,
|
|
374
|
+
name: entry.name,
|
|
375
|
+
label: entry.label,
|
|
376
|
+
fileType: entry.fileType,
|
|
377
|
+
className: entry.className,
|
|
378
|
+
jsx: entry.jsx
|
|
379
|
+
}));
|
|
380
|
+
|
|
381
|
+
//#endregion
|
|
382
|
+
exports.detectFramework = detectFramework;
|
|
383
|
+
exports.getJsxTypes = getJsxTypes;
|
|
384
|
+
exports.listFrameworks = listFrameworks;
|