chaincss 1.13.3 → 2.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/CHANGELOG.md +81 -0
- package/LICENSE +2 -3
- package/README.md +238 -105
- package/dist/cli/commands/build.d.ts +3 -0
- package/dist/cli/commands/build.d.ts.map +1 -0
- package/dist/cli/commands/compile.d.ts +3 -0
- package/dist/cli/commands/compile.d.ts.map +1 -0
- package/dist/cli/commands/init.d.ts +5 -0
- package/dist/cli/commands/init.d.ts.map +1 -0
- package/dist/cli/commands/timeline.d.ts +2 -0
- package/dist/cli/commands/timeline.d.ts.map +1 -0
- package/dist/cli/commands/watch.d.ts +6 -0
- package/dist/cli/commands/watch.d.ts.map +1 -0
- package/dist/cli/index.d.ts +2 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +5960 -0
- package/dist/cli/types.d.ts +51 -0
- package/dist/cli/types.d.ts.map +1 -0
- package/dist/cli/utils/config-loader.d.ts +8 -0
- package/dist/cli/utils/config-loader.d.ts.map +1 -0
- package/dist/cli/utils/file-utils.d.ts +9 -0
- package/dist/cli/utils/file-utils.d.ts.map +1 -0
- package/dist/cli/utils/logger.d.ts +17 -0
- package/dist/cli/utils/logger.d.ts.map +1 -0
- package/dist/compiler/atomic-optimizer.d.ts +76 -0
- package/dist/compiler/atomic-optimizer.d.ts.map +1 -0
- package/dist/compiler/btt.d.ts +138 -0
- package/dist/compiler/btt.d.ts.map +1 -0
- package/dist/compiler/cache-manager.d.ts +20 -0
- package/dist/compiler/cache-manager.d.ts.map +1 -0
- package/dist/compiler/commonProps.d.ts +2 -0
- package/dist/compiler/commonProps.d.ts.map +1 -0
- package/dist/compiler/index.d.ts +12 -0
- package/dist/compiler/index.d.ts.map +1 -0
- package/dist/compiler/index.js +5177 -0
- package/dist/compiler/prefixer.d.ts +42 -0
- package/dist/compiler/prefixer.d.ts.map +1 -0
- package/dist/compiler/theme-contract.d.ts +61 -0
- package/dist/compiler/theme-contract.d.ts.map +1 -0
- package/dist/compiler/tokens.d.ts +52 -0
- package/dist/compiler/tokens.d.ts.map +1 -0
- package/dist/compiler/types.d.ts +57 -0
- package/dist/compiler/types.d.ts.map +1 -0
- package/dist/core/compiler.d.ts +32 -0
- package/dist/core/compiler.d.ts.map +1 -0
- package/dist/core/constants.d.ts +129 -0
- package/dist/core/constants.d.ts.map +1 -0
- package/dist/core/index.d.ts +4 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/types.d.ts +88 -0
- package/dist/core/types.d.ts.map +1 -0
- package/dist/core/utils.d.ts +37 -0
- package/dist/core/utils.d.ts.map +1 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +5667 -0
- package/dist/plugins/vite.d.ts +11 -0
- package/dist/plugins/vite.d.ts.map +1 -0
- package/dist/plugins/vite.js +25839 -0
- package/dist/plugins/webpack.d.ts +45 -0
- package/dist/plugins/webpack.d.ts.map +1 -0
- package/dist/plugins/webpack.js +107 -0
- package/dist/runtime/hmr.d.ts +3 -0
- package/dist/runtime/hmr.d.ts.map +1 -0
- package/dist/runtime/index.d.ts +15 -0
- package/dist/runtime/index.d.ts.map +1 -0
- package/dist/runtime/index.js +552 -0
- package/dist/runtime/injector.d.ts +85 -0
- package/dist/runtime/injector.d.ts.map +1 -0
- package/dist/runtime/react.d.ts +54 -0
- package/dist/runtime/react.d.ts.map +1 -0
- package/dist/runtime/react.js +270 -0
- package/dist/runtime/types.d.ts +45 -0
- package/dist/runtime/types.d.ts.map +1 -0
- package/dist/runtime/utils.d.ts +62 -0
- package/dist/runtime/utils.d.ts.map +1 -0
- package/dist/runtime/vue.d.ts +52 -0
- package/dist/runtime/vue.d.ts.map +1 -0
- package/dist/runtime/vue.js +232 -0
- package/package.json +90 -119
- package/browser/commonProps.js +0 -14
- package/browser/index.js +0 -3
- package/browser/react-hooks.js +0 -162
- package/browser/rtt.js +0 -400
- package/browser/vue-composables.js +0 -200
- package/node/atomic-optimizer.js +0 -526
- package/node/btt.js +0 -1009
- package/node/cache-manager.js +0 -56
- package/node/chaincss.js +0 -642
- package/node/index.js +0 -2
- package/node/loaders/chaincss-loader.js +0 -62
- package/node/plugins/next-plugin.js +0 -120
- package/node/plugins/vite-plugin.js +0 -383
- package/node/plugins/webpack-plugin.js +0 -41
- package/node/prefixer.js +0 -237
- package/node/strVal.js +0 -92
- package/node/theme-validator.js +0 -32
- package/shared/theme-contract.js +0 -98
- package/shared/tokens.cjs +0 -256
- package/shared/tokens.mjs +0 -320
- package/types.d.ts +0 -325
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
export interface ChainCSSLoaderOptions {
|
|
2
|
+
/**
|
|
3
|
+
* Mode: 'build' for production (zero-runtime), 'runtime' for development
|
|
4
|
+
* @default process.env.NODE_ENV === 'production' ? 'build' : 'runtime'
|
|
5
|
+
*/
|
|
6
|
+
mode?: 'build' | 'runtime';
|
|
7
|
+
/**
|
|
8
|
+
* Enable atomic CSS optimization
|
|
9
|
+
* @default false
|
|
10
|
+
*/
|
|
11
|
+
atomic?: boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Enable CSS minification
|
|
14
|
+
* @default process.env.NODE_ENV === 'production'
|
|
15
|
+
*/
|
|
16
|
+
minify?: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Enable source maps
|
|
19
|
+
* @default false
|
|
20
|
+
*/
|
|
21
|
+
sourceMap?: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Output directory for compiled CSS
|
|
24
|
+
* @default '.chaincss-cache'
|
|
25
|
+
*/
|
|
26
|
+
outputDir?: string;
|
|
27
|
+
/**
|
|
28
|
+
* Verbose logging
|
|
29
|
+
* @default false
|
|
30
|
+
*/
|
|
31
|
+
verbose?: boolean;
|
|
32
|
+
}
|
|
33
|
+
interface LoaderContext {
|
|
34
|
+
async: () => (err: Error | null, code?: string) => void;
|
|
35
|
+
getOptions: () => ChainCSSLoaderOptions;
|
|
36
|
+
resourcePath: string;
|
|
37
|
+
context: string;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Webpack loader for ChainCSS
|
|
41
|
+
* Converts .chain.js / .chain.ts files to static CSS at build time
|
|
42
|
+
*/
|
|
43
|
+
export default function chaincssLoader(this: LoaderContext, source: string): void;
|
|
44
|
+
export {};
|
|
45
|
+
//# sourceMappingURL=webpack.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webpack.d.ts","sourceRoot":"","sources":["../../src/plugins/webpack.ts"],"names":[],"mappings":"AAUA,MAAM,WAAW,qBAAqB;IACpC;;;OAGG;IACH,IAAI,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAE3B;;;OAGG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;IAEjB;;;OAGG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;IAEjB;;;OAGG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IAEpB;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,UAAU,aAAa;IACrB,KAAK,EAAE,MAAM,CAAC,GAAG,EAAE,KAAK,GAAG,IAAI,EAAE,IAAI,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IACxD,UAAU,EAAE,MAAM,qBAAqB,CAAC;IACxC,YAAY,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;;GAGG;AACH,MAAM,CAAC,OAAO,UAAU,cAAc,CAAC,IAAI,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI,CAqHhF"}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
// src/plugins/webpack.ts
|
|
2
|
+
import path from "path";
|
|
3
|
+
import { execSync } from "child_process";
|
|
4
|
+
import fs from "fs";
|
|
5
|
+
import { fileURLToPath } from "url";
|
|
6
|
+
var __filename = fileURLToPath(import.meta.url);
|
|
7
|
+
var __dirname = path.dirname(__filename);
|
|
8
|
+
function chaincssLoader(source) {
|
|
9
|
+
const callback = this.async();
|
|
10
|
+
const options = this.getOptions() || {};
|
|
11
|
+
const mode = options.mode || (process.env.NODE_ENV === "production" ? "build" : "runtime");
|
|
12
|
+
if (mode === "runtime") {
|
|
13
|
+
if (options.verbose) {
|
|
14
|
+
console.log(`[chaincss-loader] Runtime mode for ${this.resourcePath}`);
|
|
15
|
+
}
|
|
16
|
+
const styleNames = extractStyleNames(source);
|
|
17
|
+
const code = `
|
|
18
|
+
import { $, compile } from 'chaincss/runtime';
|
|
19
|
+
const styles = (() => {
|
|
20
|
+
${source}
|
|
21
|
+
return { ${styleNames} };
|
|
22
|
+
})();
|
|
23
|
+
export default styles;
|
|
24
|
+
`;
|
|
25
|
+
callback(null, code);
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
try {
|
|
29
|
+
if (options.verbose) {
|
|
30
|
+
console.log(`[chaincss-loader] Build mode for ${this.resourcePath}`);
|
|
31
|
+
}
|
|
32
|
+
const tempFile = path.join(this.context, `.temp.${Date.now()}.chain.js`);
|
|
33
|
+
const outputDir = options.outputDir || path.join(process.cwd(), ".chaincss-cache");
|
|
34
|
+
if (!fs.existsSync(path.dirname(tempFile))) {
|
|
35
|
+
fs.mkdirSync(path.dirname(tempFile), { recursive: true });
|
|
36
|
+
}
|
|
37
|
+
fs.writeFileSync(tempFile, source, "utf8");
|
|
38
|
+
if (!fs.existsSync(outputDir)) {
|
|
39
|
+
fs.mkdirSync(outputDir, { recursive: true });
|
|
40
|
+
}
|
|
41
|
+
const chaincssCli = path.join(__dirname, "../cli/index.js");
|
|
42
|
+
let cmd = `node ${chaincssCli} compile "${tempFile}" "${outputDir}"`;
|
|
43
|
+
if (options.atomic) {
|
|
44
|
+
cmd += " --atomic";
|
|
45
|
+
}
|
|
46
|
+
if (options.minify) {
|
|
47
|
+
cmd += " --minify";
|
|
48
|
+
}
|
|
49
|
+
if (options.sourceMap) {
|
|
50
|
+
cmd += " --source-map";
|
|
51
|
+
}
|
|
52
|
+
if (options.verbose) {
|
|
53
|
+
console.log(`[chaincss-loader] Executing: ${cmd}`);
|
|
54
|
+
}
|
|
55
|
+
execSync(cmd, { stdio: options.verbose ? "inherit" : "pipe" });
|
|
56
|
+
const baseName = path.basename(this.resourcePath, path.extname(this.resourcePath));
|
|
57
|
+
const cssPath = path.join(outputDir, `${baseName}.css`);
|
|
58
|
+
const jsPath = path.join(outputDir, `${baseName}.js`);
|
|
59
|
+
let css = "";
|
|
60
|
+
if (fs.existsSync(cssPath)) {
|
|
61
|
+
css = fs.readFileSync(cssPath, "utf8");
|
|
62
|
+
}
|
|
63
|
+
let classExports = "";
|
|
64
|
+
if (fs.existsSync(jsPath)) {
|
|
65
|
+
classExports = fs.readFileSync(jsPath, "utf8");
|
|
66
|
+
}
|
|
67
|
+
fs.unlinkSync(tempFile);
|
|
68
|
+
const code = `
|
|
69
|
+
// Generated by ChainCSS Webpack Loader (Build Mode)
|
|
70
|
+
// Zero-runtime CSS injection
|
|
71
|
+
|
|
72
|
+
${classExports}
|
|
73
|
+
|
|
74
|
+
const css = ${JSON.stringify(css)};
|
|
75
|
+
if (typeof document !== 'undefined') {
|
|
76
|
+
const styleId = 'chaincss-${baseName}';
|
|
77
|
+
let style = document.getElementById(styleId);
|
|
78
|
+
if (!style) {
|
|
79
|
+
style = document.createElement('style');
|
|
80
|
+
style.id = styleId;
|
|
81
|
+
style.setAttribute('data-chaincss', ${JSON.stringify(this.resourcePath)});
|
|
82
|
+
document.head.appendChild(style);
|
|
83
|
+
}
|
|
84
|
+
style.textContent = css;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export default { ${extractStyleNames(source)} };
|
|
88
|
+
`;
|
|
89
|
+
callback(null, code);
|
|
90
|
+
} catch (err) {
|
|
91
|
+
console.error(`[chaincss-loader] Error compiling ${this.resourcePath}:`, err.message);
|
|
92
|
+
callback(err);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
function extractStyleNames(source) {
|
|
96
|
+
const matches = source.match(/const\s+(\w+)\s*=\s*\$\(/g);
|
|
97
|
+
if (!matches)
|
|
98
|
+
return "";
|
|
99
|
+
const names = matches.map((m) => {
|
|
100
|
+
const match = m.match(/const\s+(\w+)/);
|
|
101
|
+
return match ? match[1] : "";
|
|
102
|
+
}).filter(Boolean);
|
|
103
|
+
return names.join(", ");
|
|
104
|
+
}
|
|
105
|
+
export {
|
|
106
|
+
chaincssLoader as default
|
|
107
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hmr.d.ts","sourceRoot":"","sources":["../../src/runtime/hmr.ts"],"names":[],"mappings":"AASA,wBAAgB,QAAQ,SAUvB;AAED,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,QAS3E"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ChainCSS Runtime Module
|
|
3
|
+
*
|
|
4
|
+
* WARNING: Importing from this module adds ~3.2KB to your bundle.
|
|
5
|
+
* For production, use build-time compilation with chaincss/plugin/vite instead.
|
|
6
|
+
*/
|
|
7
|
+
export { chainRuntime as $, compileRuntime as compile, runRuntime as run, styleInjector } from './injector.js';
|
|
8
|
+
export { useChainStyles, useDynamicChainStyles, useThemeChainStyles, ChainCSSGlobal, cx, withChainStyles, enableChainCSSDebug, disableChainCSSDebug, isDebugEnabled, createStyledComponent, useComputedStyles } from './react.js';
|
|
9
|
+
export { useAtomicClasses, ChainCSSGlobal as ChainCSSGlobalVue, createStyledComponent as createStyledVueComponent, // This is fine - it renames
|
|
10
|
+
createStyledComponents as createStyledVueComponents, useComputedStyles as useComputedStylesVue, // This renames useComputedStyles
|
|
11
|
+
provideStyleContext, injectStyleContext } from './vue.js';
|
|
12
|
+
export { setupHMR, registerForHMR } from './hmr.js';
|
|
13
|
+
export { generateStyleId, hashString, kebabCase, isBrowser, isDevelopment, isProduction, debounce, memoize, cn as cnUtils, devWarn, devLog, logError, createDebugger } from './utils.js';
|
|
14
|
+
export type { RuntimeStyleDefinition, UseChainStylesOptions, RuntimeCompiledResult, StyleInjector, UseAtomicClassesReturn, HMRPayload, ChainCSSDebugger } from './types.js';
|
|
15
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/runtime/index.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AAGH,OAAO,EAAE,YAAY,IAAI,CAAC,EAAE,cAAc,IAAI,OAAO,EAAE,UAAU,IAAI,GAAG,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAG/G,OAAO,EACL,cAAc,EACd,qBAAqB,EACrB,mBAAmB,EACnB,cAAc,EACd,EAAE,EACF,eAAe,EACf,mBAAmB,EACnB,oBAAoB,EACpB,cAAc,EACd,qBAAqB,EACrB,iBAAiB,EAClB,MAAM,YAAY,CAAC;AAGpB,OAAO,EACL,gBAAgB,EAChB,cAAc,IAAI,iBAAiB,EACnC,qBAAqB,IAAI,wBAAwB,EAAG,4BAA4B;AAChF,sBAAsB,IAAI,yBAAyB,EACnD,iBAAiB,IAAI,oBAAoB,EAAG,iCAAiC;AAC7E,mBAAmB,EACnB,kBAAkB,EACnB,MAAM,UAAU,CAAC;AAGlB,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAGpD,OAAO,EACL,eAAe,EACf,UAAU,EACV,SAAS,EACT,SAAS,EACT,aAAa,EACb,YAAY,EACZ,QAAQ,EACR,OAAO,EACP,EAAE,IAAI,OAAO,EACb,OAAO,EACP,MAAM,EACN,QAAQ,EACR,cAAc,EACf,MAAM,YAAY,CAAC;AAGpB,YAAY,EACV,sBAAsB,EACtB,qBAAqB,EACrB,qBAAqB,EACrB,aAAa,EACb,sBAAsB,EACtB,UAAU,EACV,gBAAgB,EACjB,MAAM,YAAY,CAAC"}
|