@tenphi/tasty 0.0.0-snapshot.01d8a9e
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/README.md +635 -0
- package/dist/_virtual/_rolldown/runtime.js +7 -0
- package/dist/chunks/cacheKey.d.ts +1 -0
- package/dist/chunks/cacheKey.js +77 -0
- package/dist/chunks/cacheKey.js.map +1 -0
- package/dist/chunks/definitions.d.ts +37 -0
- package/dist/chunks/definitions.js +258 -0
- package/dist/chunks/definitions.js.map +1 -0
- package/dist/chunks/index.d.ts +1 -0
- package/dist/chunks/renderChunk.d.ts +1 -0
- package/dist/chunks/renderChunk.js +59 -0
- package/dist/chunks/renderChunk.js.map +1 -0
- package/dist/compute-styles.d.ts +31 -0
- package/dist/compute-styles.js +336 -0
- package/dist/compute-styles.js.map +1 -0
- package/dist/config.d.ts +407 -0
- package/dist/config.js +591 -0
- package/dist/config.js.map +1 -0
- package/dist/core/index.d.ts +34 -0
- package/dist/core/index.js +27 -0
- package/dist/counter-style/index.js +51 -0
- package/dist/counter-style/index.js.map +1 -0
- package/dist/debug.d.ts +89 -0
- package/dist/debug.js +453 -0
- package/dist/debug.js.map +1 -0
- package/dist/font-face/index.js +63 -0
- package/dist/font-face/index.js.map +1 -0
- package/dist/hooks/index.d.ts +7 -0
- package/dist/hooks/useCounterStyle.d.ts +36 -0
- package/dist/hooks/useCounterStyle.js +65 -0
- package/dist/hooks/useCounterStyle.js.map +1 -0
- package/dist/hooks/useFontFace.d.ts +45 -0
- package/dist/hooks/useFontFace.js +66 -0
- package/dist/hooks/useFontFace.js.map +1 -0
- package/dist/hooks/useGlobalStyles.d.ts +46 -0
- package/dist/hooks/useGlobalStyles.js +88 -0
- package/dist/hooks/useGlobalStyles.js.map +1 -0
- package/dist/hooks/useKeyframes.d.ts +58 -0
- package/dist/hooks/useKeyframes.js +55 -0
- package/dist/hooks/useKeyframes.js.map +1 -0
- package/dist/hooks/useProperty.d.ts +81 -0
- package/dist/hooks/useProperty.js +96 -0
- package/dist/hooks/useProperty.js.map +1 -0
- package/dist/hooks/useRawCSS.d.ts +22 -0
- package/dist/hooks/useRawCSS.js +103 -0
- package/dist/hooks/useRawCSS.js.map +1 -0
- package/dist/hooks/useStyles.d.ts +40 -0
- package/dist/hooks/useStyles.js +31 -0
- package/dist/hooks/useStyles.js.map +1 -0
- package/dist/index.d.ts +51 -0
- package/dist/index.js +36 -0
- package/dist/injector/index.d.ts +182 -0
- package/dist/injector/index.js +185 -0
- package/dist/injector/index.js.map +1 -0
- package/dist/injector/injector.d.ts +198 -0
- package/dist/injector/injector.js +651 -0
- package/dist/injector/injector.js.map +1 -0
- package/dist/injector/sheet-manager.d.ts +132 -0
- package/dist/injector/sheet-manager.js +699 -0
- package/dist/injector/sheet-manager.js.map +1 -0
- package/dist/injector/types.d.ts +235 -0
- package/dist/keyframes/index.js +206 -0
- package/dist/keyframes/index.js.map +1 -0
- package/dist/parser/classify.js +319 -0
- package/dist/parser/classify.js.map +1 -0
- package/dist/parser/const.js +60 -0
- package/dist/parser/const.js.map +1 -0
- package/dist/parser/lru.js +109 -0
- package/dist/parser/lru.js.map +1 -0
- package/dist/parser/parser.d.ts +25 -0
- package/dist/parser/parser.js +115 -0
- package/dist/parser/parser.js.map +1 -0
- package/dist/parser/tokenizer.js +69 -0
- package/dist/parser/tokenizer.js.map +1 -0
- package/dist/parser/types.d.ts +51 -0
- package/dist/parser/types.js +46 -0
- package/dist/parser/types.js.map +1 -0
- package/dist/pipeline/conditions.d.ts +134 -0
- package/dist/pipeline/conditions.js +406 -0
- package/dist/pipeline/conditions.js.map +1 -0
- package/dist/pipeline/exclusive.js +283 -0
- package/dist/pipeline/exclusive.js.map +1 -0
- package/dist/pipeline/index.d.ts +55 -0
- package/dist/pipeline/index.js +708 -0
- package/dist/pipeline/index.js.map +1 -0
- package/dist/pipeline/materialize.js +1157 -0
- package/dist/pipeline/materialize.js.map +1 -0
- package/dist/pipeline/parseStateKey.d.ts +15 -0
- package/dist/pipeline/parseStateKey.js +446 -0
- package/dist/pipeline/parseStateKey.js.map +1 -0
- package/dist/pipeline/simplify.js +690 -0
- package/dist/pipeline/simplify.js.map +1 -0
- package/dist/pipeline/warnings.js +18 -0
- package/dist/pipeline/warnings.js.map +1 -0
- package/dist/plugins/index.d.ts +2 -0
- package/dist/plugins/okhsl-plugin.d.ts +35 -0
- package/dist/plugins/okhsl-plugin.js +97 -0
- package/dist/plugins/okhsl-plugin.js.map +1 -0
- package/dist/plugins/types.d.ts +87 -0
- package/dist/properties/index.js +222 -0
- package/dist/properties/index.js.map +1 -0
- package/dist/properties/property-type-resolver.d.ts +24 -0
- package/dist/properties/property-type-resolver.js +90 -0
- package/dist/properties/property-type-resolver.js.map +1 -0
- package/dist/rsc-cache.js +79 -0
- package/dist/rsc-cache.js.map +1 -0
- package/dist/ssr/astro-client.d.ts +1 -0
- package/dist/ssr/astro-client.js +19 -0
- package/dist/ssr/astro-client.js.map +1 -0
- package/dist/ssr/astro-middleware.d.ts +15 -0
- package/dist/ssr/astro-middleware.js +19 -0
- package/dist/ssr/astro-middleware.js.map +1 -0
- package/dist/ssr/astro.d.ts +108 -0
- package/dist/ssr/astro.js +149 -0
- package/dist/ssr/astro.js.map +1 -0
- package/dist/ssr/async-storage.d.ts +17 -0
- package/dist/ssr/async-storage.js +44 -0
- package/dist/ssr/async-storage.js.map +1 -0
- package/dist/ssr/collect-auto-properties.js +58 -0
- package/dist/ssr/collect-auto-properties.js.map +1 -0
- package/dist/ssr/collector.d.ts +94 -0
- package/dist/ssr/collector.js +233 -0
- package/dist/ssr/collector.js.map +1 -0
- package/dist/ssr/context.js +16 -0
- package/dist/ssr/context.js.map +1 -0
- package/dist/ssr/format-global-rules.js +22 -0
- package/dist/ssr/format-global-rules.js.map +1 -0
- package/dist/ssr/format-keyframes.js +69 -0
- package/dist/ssr/format-keyframes.js.map +1 -0
- package/dist/ssr/format-property.js +49 -0
- package/dist/ssr/format-property.js.map +1 -0
- package/dist/ssr/format-rules.js +73 -0
- package/dist/ssr/format-rules.js.map +1 -0
- package/dist/ssr/hydrate.d.ts +29 -0
- package/dist/ssr/hydrate.js +45 -0
- package/dist/ssr/hydrate.js.map +1 -0
- package/dist/ssr/index.d.ts +4 -0
- package/dist/ssr/index.js +10 -0
- package/dist/ssr/index.js.map +1 -0
- package/dist/ssr/next.d.ts +46 -0
- package/dist/ssr/next.js +75 -0
- package/dist/ssr/next.js.map +1 -0
- package/dist/ssr/ssr-collector-ref.js +29 -0
- package/dist/ssr/ssr-collector-ref.js.map +1 -0
- package/dist/states/index.d.ts +49 -0
- package/dist/states/index.js +170 -0
- package/dist/states/index.js.map +1 -0
- package/dist/static/index.d.ts +5 -0
- package/dist/static/index.js +4 -0
- package/dist/static/inject.d.ts +5 -0
- package/dist/static/inject.js +17 -0
- package/dist/static/inject.js.map +1 -0
- package/dist/static/tastyStatic.d.ts +46 -0
- package/dist/static/tastyStatic.js +30 -0
- package/dist/static/tastyStatic.js.map +1 -0
- package/dist/static/types.d.ts +49 -0
- package/dist/static/types.js +24 -0
- package/dist/static/types.js.map +1 -0
- package/dist/styles/border.d.ts +25 -0
- package/dist/styles/border.js +120 -0
- package/dist/styles/border.js.map +1 -0
- package/dist/styles/color.d.ts +14 -0
- package/dist/styles/color.js +26 -0
- package/dist/styles/color.js.map +1 -0
- package/dist/styles/const.js +17 -0
- package/dist/styles/const.js.map +1 -0
- package/dist/styles/createStyle.js +79 -0
- package/dist/styles/createStyle.js.map +1 -0
- package/dist/styles/dimension.js +109 -0
- package/dist/styles/dimension.js.map +1 -0
- package/dist/styles/directional.js +133 -0
- package/dist/styles/directional.js.map +1 -0
- package/dist/styles/display.d.ts +30 -0
- package/dist/styles/display.js +73 -0
- package/dist/styles/display.js.map +1 -0
- package/dist/styles/fade.d.ts +15 -0
- package/dist/styles/fade.js +62 -0
- package/dist/styles/fade.js.map +1 -0
- package/dist/styles/fill.d.ts +42 -0
- package/dist/styles/fill.js +51 -0
- package/dist/styles/fill.js.map +1 -0
- package/dist/styles/flow.d.ts +16 -0
- package/dist/styles/flow.js +12 -0
- package/dist/styles/flow.js.map +1 -0
- package/dist/styles/gap.d.ts +31 -0
- package/dist/styles/gap.js +38 -0
- package/dist/styles/gap.js.map +1 -0
- package/dist/styles/height.d.ts +17 -0
- package/dist/styles/height.js +19 -0
- package/dist/styles/height.js.map +1 -0
- package/dist/styles/index.d.ts +1 -0
- package/dist/styles/index.js +8 -0
- package/dist/styles/index.js.map +1 -0
- package/dist/styles/inset.d.ts +24 -0
- package/dist/styles/inset.js +34 -0
- package/dist/styles/inset.js.map +1 -0
- package/dist/styles/list.d.ts +16 -0
- package/dist/styles/list.js +100 -0
- package/dist/styles/list.js.map +1 -0
- package/dist/styles/margin.d.ts +24 -0
- package/dist/styles/margin.js +32 -0
- package/dist/styles/margin.js.map +1 -0
- package/dist/styles/outline.d.ts +29 -0
- package/dist/styles/outline.js +55 -0
- package/dist/styles/outline.js.map +1 -0
- package/dist/styles/padding.d.ts +24 -0
- package/dist/styles/padding.js +32 -0
- package/dist/styles/padding.js.map +1 -0
- package/dist/styles/placement.d.ts +37 -0
- package/dist/styles/placement.js +74 -0
- package/dist/styles/placement.js.map +1 -0
- package/dist/styles/predefined.d.ts +71 -0
- package/dist/styles/predefined.js +237 -0
- package/dist/styles/predefined.js.map +1 -0
- package/dist/styles/preset.d.ts +52 -0
- package/dist/styles/preset.js +127 -0
- package/dist/styles/preset.js.map +1 -0
- package/dist/styles/radius.d.ts +12 -0
- package/dist/styles/radius.js +83 -0
- package/dist/styles/radius.js.map +1 -0
- package/dist/styles/scrollMargin.d.ts +24 -0
- package/dist/styles/scrollMargin.js +32 -0
- package/dist/styles/scrollMargin.js.map +1 -0
- package/dist/styles/scrollbar.d.ts +25 -0
- package/dist/styles/scrollbar.js +51 -0
- package/dist/styles/scrollbar.js.map +1 -0
- package/dist/styles/shadow.d.ts +14 -0
- package/dist/styles/shadow.js +25 -0
- package/dist/styles/shadow.js.map +1 -0
- package/dist/styles/shared.js +17 -0
- package/dist/styles/shared.js.map +1 -0
- package/dist/styles/transition.d.ts +14 -0
- package/dist/styles/transition.js +159 -0
- package/dist/styles/transition.js.map +1 -0
- package/dist/styles/types.d.ts +564 -0
- package/dist/styles/width.d.ts +17 -0
- package/dist/styles/width.js +19 -0
- package/dist/styles/width.js.map +1 -0
- package/dist/tasty.d.ts +134 -0
- package/dist/tasty.js +248 -0
- package/dist/tasty.js.map +1 -0
- package/dist/types.d.ts +184 -0
- package/dist/utils/cache-wrapper.js +21 -0
- package/dist/utils/cache-wrapper.js.map +1 -0
- package/dist/utils/case-converter.js +8 -0
- package/dist/utils/case-converter.js.map +1 -0
- package/dist/utils/color-math.d.ts +46 -0
- package/dist/utils/color-math.js +749 -0
- package/dist/utils/color-math.js.map +1 -0
- package/dist/utils/color-space.d.ts +5 -0
- package/dist/utils/color-space.js +228 -0
- package/dist/utils/color-space.js.map +1 -0
- package/dist/utils/colors.d.ts +5 -0
- package/dist/utils/colors.js +10 -0
- package/dist/utils/colors.js.map +1 -0
- package/dist/utils/css-types.d.ts +7 -0
- package/dist/utils/deps-equal.js +15 -0
- package/dist/utils/deps-equal.js.map +1 -0
- package/dist/utils/dotize.d.ts +26 -0
- package/dist/utils/dotize.js +122 -0
- package/dist/utils/dotize.js.map +1 -0
- package/dist/utils/filter-base-props.d.ts +15 -0
- package/dist/utils/filter-base-props.js +45 -0
- package/dist/utils/filter-base-props.js.map +1 -0
- package/dist/utils/get-display-name.d.ts +7 -0
- package/dist/utils/get-display-name.js +10 -0
- package/dist/utils/get-display-name.js.map +1 -0
- package/dist/utils/has-keys.js +13 -0
- package/dist/utils/has-keys.js.map +1 -0
- package/dist/utils/hash.js +14 -0
- package/dist/utils/hash.js.map +1 -0
- package/dist/utils/is-dev-env.js +19 -0
- package/dist/utils/is-dev-env.js.map +1 -0
- package/dist/utils/is-valid-element-type.js +15 -0
- package/dist/utils/is-valid-element-type.js.map +1 -0
- package/dist/utils/merge-styles.d.ts +7 -0
- package/dist/utils/merge-styles.js +145 -0
- package/dist/utils/merge-styles.js.map +1 -0
- package/dist/utils/mod-attrs.d.ts +6 -0
- package/dist/utils/mod-attrs.js +20 -0
- package/dist/utils/mod-attrs.js.map +1 -0
- package/dist/utils/process-tokens.d.ts +17 -0
- package/dist/utils/process-tokens.js +83 -0
- package/dist/utils/process-tokens.js.map +1 -0
- package/dist/utils/resolve-recipes.d.ts +17 -0
- package/dist/utils/resolve-recipes.js +146 -0
- package/dist/utils/resolve-recipes.js.map +1 -0
- package/dist/utils/selector-transform.js +32 -0
- package/dist/utils/selector-transform.js.map +1 -0
- package/dist/utils/string.js +8 -0
- package/dist/utils/string.js.map +1 -0
- package/dist/utils/styles.d.ts +99 -0
- package/dist/utils/styles.js +220 -0
- package/dist/utils/styles.js.map +1 -0
- package/dist/utils/typography.d.ts +58 -0
- package/dist/utils/typography.js +51 -0
- package/dist/utils/typography.js.map +1 -0
- package/dist/utils/warnings.d.ts +16 -0
- package/dist/utils/warnings.js +16 -0
- package/dist/utils/warnings.js.map +1 -0
- package/dist/zero/babel.d.ts +81 -0
- package/dist/zero/babel.js +462 -0
- package/dist/zero/babel.js.map +1 -0
- package/dist/zero/css-writer.d.ts +45 -0
- package/dist/zero/css-writer.js +73 -0
- package/dist/zero/css-writer.js.map +1 -0
- package/dist/zero/extractor.d.ts +24 -0
- package/dist/zero/extractor.js +266 -0
- package/dist/zero/extractor.js.map +1 -0
- package/dist/zero/index.d.ts +3 -0
- package/dist/zero/index.js +3 -0
- package/dist/zero/next.d.ts +86 -0
- package/dist/zero/next.js +143 -0
- package/dist/zero/next.js.map +1 -0
- package/docs/PIPELINE.md +519 -0
- package/docs/README.md +31 -0
- package/docs/adoption.md +298 -0
- package/docs/comparison.md +419 -0
- package/docs/configuration.md +394 -0
- package/docs/debug.md +318 -0
- package/docs/design-system.md +436 -0
- package/docs/dsl.md +688 -0
- package/docs/getting-started.md +217 -0
- package/docs/injector.md +544 -0
- package/docs/methodology.md +616 -0
- package/docs/react-api.md +557 -0
- package/docs/ssr.md +442 -0
- package/docs/styles.md +596 -0
- package/docs/tasty-static.md +532 -0
- package/package.json +221 -0
- package/tasty.config.ts +14 -0
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { TastyZeroConfig } from "./babel.js";
|
|
2
|
+
|
|
3
|
+
//#region src/zero/next.d.ts
|
|
4
|
+
interface WebpackConfigContext {
|
|
5
|
+
isServer: boolean;
|
|
6
|
+
dev: boolean;
|
|
7
|
+
buildId: string;
|
|
8
|
+
dir: string;
|
|
9
|
+
}
|
|
10
|
+
interface TurbopackLoaderItem {
|
|
11
|
+
loader: string;
|
|
12
|
+
options?: Record<string, unknown>;
|
|
13
|
+
}
|
|
14
|
+
interface TurbopackRuleConfig {
|
|
15
|
+
loaders: (string | TurbopackLoaderItem)[];
|
|
16
|
+
as?: string;
|
|
17
|
+
condition?: unknown;
|
|
18
|
+
}
|
|
19
|
+
interface TurbopackConfig {
|
|
20
|
+
rules?: Record<string, TurbopackRuleConfig | TurbopackRuleConfig[]>;
|
|
21
|
+
[key: string]: unknown;
|
|
22
|
+
}
|
|
23
|
+
interface NextConfig {
|
|
24
|
+
webpack?: (config: any, context: WebpackConfigContext) => any;
|
|
25
|
+
turbopack?: TurbopackConfig;
|
|
26
|
+
[key: string]: unknown;
|
|
27
|
+
}
|
|
28
|
+
interface TastyZeroNextOptions {
|
|
29
|
+
/**
|
|
30
|
+
* Output path for CSS relative to project root.
|
|
31
|
+
* @default 'public/tasty.css'
|
|
32
|
+
*/
|
|
33
|
+
output?: string;
|
|
34
|
+
/**
|
|
35
|
+
* Whether to enable the plugin.
|
|
36
|
+
* @default true
|
|
37
|
+
*/
|
|
38
|
+
enabled?: boolean;
|
|
39
|
+
/**
|
|
40
|
+
* Tasty configuration for build-time processing.
|
|
41
|
+
* For static configs that don't change during dev.
|
|
42
|
+
*
|
|
43
|
+
* For configs that depend on theme files, use `configFile` instead.
|
|
44
|
+
*/
|
|
45
|
+
config?: TastyZeroConfig;
|
|
46
|
+
/**
|
|
47
|
+
* Path to a TypeScript/JavaScript module that exports the tasty zero config
|
|
48
|
+
* as its default export. The module is re-evaluated on each
|
|
49
|
+
* compilation, enabling hot reload when the file (or its imports) change.
|
|
50
|
+
*
|
|
51
|
+
* @example './app/tasty-zero.config.ts'
|
|
52
|
+
*/
|
|
53
|
+
configFile?: string;
|
|
54
|
+
/**
|
|
55
|
+
* Extra file paths (relative to project root) that the config depends on.
|
|
56
|
+
* When any of these files change, the Babel cache is invalidated and
|
|
57
|
+
* the config is re-evaluated.
|
|
58
|
+
*
|
|
59
|
+
* The `configFile` itself is always tracked automatically.
|
|
60
|
+
* Use this for transitive dependencies that aren't directly imported
|
|
61
|
+
* by the config file, or when using `config` instead of `configFile`.
|
|
62
|
+
*
|
|
63
|
+
* @example ['./app/theme.ts']
|
|
64
|
+
*/
|
|
65
|
+
configDeps?: string[];
|
|
66
|
+
/**
|
|
67
|
+
* Output mode for extracted CSS.
|
|
68
|
+
*
|
|
69
|
+
* - `'file'` (default): CSS is written to a single output file.
|
|
70
|
+
* - `'inject'`: CSS is embedded inline in JS and injected at runtime.
|
|
71
|
+
* No CSS file is written. Best for reusable components and extensions.
|
|
72
|
+
*
|
|
73
|
+
* When `mode` is `'inject'`, `output` is ignored.
|
|
74
|
+
*
|
|
75
|
+
* @default 'file'
|
|
76
|
+
*/
|
|
77
|
+
mode?: 'file' | 'inject';
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Next.js configuration wrapper for tasty-zero.
|
|
81
|
+
* Configures both webpack and Turbopack bundlers automatically.
|
|
82
|
+
*/
|
|
83
|
+
declare function withTastyZero(options?: TastyZeroNextOptions): (nextConfig?: NextConfig) => NextConfig;
|
|
84
|
+
//#endregion
|
|
85
|
+
export { TastyZeroNextOptions, withTastyZero };
|
|
86
|
+
//# sourceMappingURL=next.d.ts.map
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import * as path from "path";
|
|
2
|
+
import { createJiti } from "jiti";
|
|
3
|
+
import { createRequire } from "module";
|
|
4
|
+
import { fileURLToPath } from "url";
|
|
5
|
+
//#region src/zero/next.ts
|
|
6
|
+
/**
|
|
7
|
+
* Next.js configuration wrapper for tasty-zero.
|
|
8
|
+
*
|
|
9
|
+
* Supports both webpack and Turbopack bundlers:
|
|
10
|
+
* - **webpack**: Injects a babel-loader rule with the tasty-zero Babel plugin
|
|
11
|
+
* via `webpack()` config hook. Config is passed as a jiti factory function.
|
|
12
|
+
* - **Turbopack**: Adds a `turbopack.rules` entry with babel-loader and
|
|
13
|
+
* JSON-serializable options (`configFile` path instead of a function).
|
|
14
|
+
* The Babel plugin loads the config internally via jiti.
|
|
15
|
+
*
|
|
16
|
+
* The generated CSS is injected automatically — `@tenphi/tasty/static`
|
|
17
|
+
* imports are replaced with an import of the output CSS file at build time.
|
|
18
|
+
* No manual CSS import in layout files is needed.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```javascript
|
|
22
|
+
* // next.config.js
|
|
23
|
+
* const { withTastyZero } = require('@tenphi/tasty/next');
|
|
24
|
+
*
|
|
25
|
+
* module.exports = withTastyZero({
|
|
26
|
+
* output: 'public/tasty.css',
|
|
27
|
+
* configFile: './app/tasty-zero.config.ts',
|
|
28
|
+
* })({
|
|
29
|
+
* // your Next.js config
|
|
30
|
+
* });
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
34
|
+
const __dirname = path.dirname(__filename);
|
|
35
|
+
/**
|
|
36
|
+
* Next.js configuration wrapper for tasty-zero.
|
|
37
|
+
* Configures both webpack and Turbopack bundlers automatically.
|
|
38
|
+
*/
|
|
39
|
+
function withTastyZero(options = {}) {
|
|
40
|
+
const { output = "public/tasty.css", enabled = true, config: tastyConfig, configFile, configDeps = [], mode } = options;
|
|
41
|
+
return (nextConfig = {}) => {
|
|
42
|
+
if (!enabled) return nextConfig;
|
|
43
|
+
const projectDir = process.cwd();
|
|
44
|
+
const absoluteOutput = path.resolve(projectDir, output);
|
|
45
|
+
const babelPluginPath = path.resolve(__dirname, "babel.js");
|
|
46
|
+
const absoluteConfigFile = configFile ? path.resolve(projectDir, configFile) : void 0;
|
|
47
|
+
const allDeps = [...absoluteConfigFile ? [absoluteConfigFile] : [], ...configDeps.map((dep) => path.resolve(projectDir, dep))];
|
|
48
|
+
const turbopackBabelOptions = {
|
|
49
|
+
babelrc: false,
|
|
50
|
+
configFile: false,
|
|
51
|
+
parserOpts: { plugins: [
|
|
52
|
+
"typescript",
|
|
53
|
+
"jsx",
|
|
54
|
+
"decorators-legacy"
|
|
55
|
+
] },
|
|
56
|
+
plugins: [[babelPluginPath, {
|
|
57
|
+
output: absoluteOutput,
|
|
58
|
+
injectImport: true,
|
|
59
|
+
...mode ? { mode } : {},
|
|
60
|
+
...absoluteConfigFile ? { configFile: absoluteConfigFile } : tastyConfig ? { config: tastyConfig } : {},
|
|
61
|
+
...allDeps.length > 0 ? { configDeps: allDeps } : {}
|
|
62
|
+
}]]
|
|
63
|
+
};
|
|
64
|
+
const existingTurbopack = nextConfig.turbopack || {};
|
|
65
|
+
const existingRules = existingTurbopack.rules || {};
|
|
66
|
+
const existingExperimental = nextConfig.experimental || {};
|
|
67
|
+
return {
|
|
68
|
+
...nextConfig,
|
|
69
|
+
experimental: {
|
|
70
|
+
...existingExperimental,
|
|
71
|
+
turbopackUseBuiltinBabel: true
|
|
72
|
+
},
|
|
73
|
+
turbopack: {
|
|
74
|
+
...existingTurbopack,
|
|
75
|
+
rules: {
|
|
76
|
+
...existingRules,
|
|
77
|
+
"*.{ts,tsx,js,jsx}": {
|
|
78
|
+
condition: { not: "foreign" },
|
|
79
|
+
loaders: [{
|
|
80
|
+
loader: "babel-loader",
|
|
81
|
+
options: turbopackBabelOptions
|
|
82
|
+
}]
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
webpack(config, context) {
|
|
87
|
+
const { dir } = context;
|
|
88
|
+
const wpProjectDir = dir || projectDir;
|
|
89
|
+
const wpAbsoluteOutput = path.resolve(wpProjectDir, output);
|
|
90
|
+
const projectRequire = createRequire(path.resolve(wpProjectDir, "package.json"));
|
|
91
|
+
const wpAbsoluteConfigFile = configFile ? path.resolve(wpProjectDir, configFile) : void 0;
|
|
92
|
+
const wpAllDeps = [...wpAbsoluteConfigFile ? [wpAbsoluteConfigFile] : [], ...configDeps.map((dep) => path.resolve(wpProjectDir, dep))];
|
|
93
|
+
const babelPluginOptions = {
|
|
94
|
+
output: wpAbsoluteOutput,
|
|
95
|
+
injectImport: true,
|
|
96
|
+
...mode ? { mode } : {}
|
|
97
|
+
};
|
|
98
|
+
if (wpAbsoluteConfigFile) {
|
|
99
|
+
const jiti = createJiti(wpProjectDir, { moduleCache: false });
|
|
100
|
+
babelPluginOptions.config = () => {
|
|
101
|
+
return jiti(wpAbsoluteConfigFile);
|
|
102
|
+
};
|
|
103
|
+
} else if (tastyConfig) babelPluginOptions.config = tastyConfig;
|
|
104
|
+
if (wpAllDeps.length > 0) babelPluginOptions.configDeps = wpAllDeps;
|
|
105
|
+
const babelPluginConfig = [babelPluginPath, babelPluginOptions];
|
|
106
|
+
const existingRule = config.module?.rules?.find((rule) => rule.use?.loader === "babel-loader" || rule.use?.some?.((u) => u.loader === "babel-loader"));
|
|
107
|
+
if (existingRule) {
|
|
108
|
+
const babelUse = Array.isArray(existingRule.use) ? existingRule.use.find((u) => u.loader === "babel-loader") : existingRule.use;
|
|
109
|
+
if (babelUse?.options) {
|
|
110
|
+
babelUse.options.plugins = babelUse.options.plugins || [];
|
|
111
|
+
babelUse.options.plugins.push(babelPluginConfig);
|
|
112
|
+
}
|
|
113
|
+
} else {
|
|
114
|
+
config.module = config.module || {};
|
|
115
|
+
config.module.rules = config.module.rules || [];
|
|
116
|
+
config.module.rules.push({
|
|
117
|
+
test: /\.(tsx?|jsx?)$/,
|
|
118
|
+
exclude: /node_modules/,
|
|
119
|
+
use: [{
|
|
120
|
+
loader: projectRequire.resolve("babel-loader"),
|
|
121
|
+
options: {
|
|
122
|
+
babelrc: false,
|
|
123
|
+
configFile: false,
|
|
124
|
+
parserOpts: { plugins: [
|
|
125
|
+
"typescript",
|
|
126
|
+
"jsx",
|
|
127
|
+
"decorators-legacy"
|
|
128
|
+
] },
|
|
129
|
+
plugins: [babelPluginConfig]
|
|
130
|
+
}
|
|
131
|
+
}]
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
if (typeof nextConfig.webpack === "function") return nextConfig.webpack(config, context);
|
|
135
|
+
return config;
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
//#endregion
|
|
141
|
+
export { withTastyZero };
|
|
142
|
+
|
|
143
|
+
//# sourceMappingURL=next.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"next.js","names":[],"sources":["../../src/zero/next.ts"],"sourcesContent":["/**\n * Next.js configuration wrapper for tasty-zero.\n *\n * Supports both webpack and Turbopack bundlers:\n * - **webpack**: Injects a babel-loader rule with the tasty-zero Babel plugin\n * via `webpack()` config hook. Config is passed as a jiti factory function.\n * - **Turbopack**: Adds a `turbopack.rules` entry with babel-loader and\n * JSON-serializable options (`configFile` path instead of a function).\n * The Babel plugin loads the config internally via jiti.\n *\n * The generated CSS is injected automatically — `@tenphi/tasty/static`\n * imports are replaced with an import of the output CSS file at build time.\n * No manual CSS import in layout files is needed.\n *\n * @example\n * ```javascript\n * // next.config.js\n * const { withTastyZero } = require('@tenphi/tasty/next');\n *\n * module.exports = withTastyZero({\n * output: 'public/tasty.css',\n * configFile: './app/tasty-zero.config.ts',\n * })({\n * // your Next.js config\n * });\n * ```\n */\n\nimport { createRequire } from 'module';\nimport * as path from 'path';\nimport { fileURLToPath } from 'url';\n\nimport { createJiti } from 'jiti';\n\nimport type { TastyZeroBabelOptions, TastyZeroConfig } from './babel';\n\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = path.dirname(__filename);\n\n// Next.js types (inline to avoid requiring next as a dependency)\ninterface WebpackConfigContext {\n isServer: boolean;\n dev: boolean;\n buildId: string;\n dir: string;\n}\n\n/* eslint-disable @typescript-eslint/no-explicit-any -- webpack/Next.js config types are complex */\ninterface TurbopackLoaderItem {\n loader: string;\n options?: Record<string, unknown>;\n}\n\ninterface TurbopackRuleConfig {\n loaders: (string | TurbopackLoaderItem)[];\n as?: string;\n condition?: unknown;\n}\n\ninterface TurbopackConfig {\n rules?: Record<string, TurbopackRuleConfig | TurbopackRuleConfig[]>;\n [key: string]: unknown;\n}\n\ninterface NextConfig {\n webpack?: (config: any, context: WebpackConfigContext) => any;\n turbopack?: TurbopackConfig;\n [key: string]: unknown;\n}\n\nexport interface TastyZeroNextOptions {\n /**\n * Output path for CSS relative to project root.\n * @default 'public/tasty.css'\n */\n output?: string;\n\n /**\n * Whether to enable the plugin.\n * @default true\n */\n enabled?: boolean;\n\n /**\n * Tasty configuration for build-time processing.\n * For static configs that don't change during dev.\n *\n * For configs that depend on theme files, use `configFile` instead.\n */\n config?: TastyZeroConfig;\n\n /**\n * Path to a TypeScript/JavaScript module that exports the tasty zero config\n * as its default export. The module is re-evaluated on each\n * compilation, enabling hot reload when the file (or its imports) change.\n *\n * @example './app/tasty-zero.config.ts'\n */\n configFile?: string;\n\n /**\n * Extra file paths (relative to project root) that the config depends on.\n * When any of these files change, the Babel cache is invalidated and\n * the config is re-evaluated.\n *\n * The `configFile` itself is always tracked automatically.\n * Use this for transitive dependencies that aren't directly imported\n * by the config file, or when using `config` instead of `configFile`.\n *\n * @example ['./app/theme.ts']\n */\n configDeps?: string[];\n\n /**\n * Output mode for extracted CSS.\n *\n * - `'file'` (default): CSS is written to a single output file.\n * - `'inject'`: CSS is embedded inline in JS and injected at runtime.\n * No CSS file is written. Best for reusable components and extensions.\n *\n * When `mode` is `'inject'`, `output` is ignored.\n *\n * @default 'file'\n */\n mode?: 'file' | 'inject';\n}\n\n/**\n * Next.js configuration wrapper for tasty-zero.\n * Configures both webpack and Turbopack bundlers automatically.\n */\nexport function withTastyZero(options: TastyZeroNextOptions = {}) {\n const {\n output = 'public/tasty.css',\n enabled = true,\n config: tastyConfig,\n configFile,\n configDeps = [],\n mode,\n } = options;\n\n return (nextConfig: NextConfig = {}): NextConfig => {\n if (!enabled) {\n return nextConfig;\n }\n\n const projectDir = process.cwd();\n const absoluteOutput = path.resolve(projectDir, output);\n const babelPluginPath = path.resolve(__dirname, 'babel.js');\n\n const absoluteConfigFile = configFile\n ? path.resolve(projectDir, configFile)\n : undefined;\n\n const allDeps = [\n ...(absoluteConfigFile ? [absoluteConfigFile] : []),\n ...configDeps.map((dep) => path.resolve(projectDir, dep)),\n ];\n\n // --- Turbopack configuration ---\n // Turbopack loader options must be JSON-serializable (no functions).\n // The Babel plugin loads config internally via `configFile` path + jiti.\n const turbopackBabelOptions: Record<string, unknown> = {\n babelrc: false,\n configFile: false,\n parserOpts: {\n plugins: ['typescript', 'jsx', 'decorators-legacy'],\n },\n plugins: [\n [\n babelPluginPath,\n {\n output: absoluteOutput,\n injectImport: true,\n ...(mode ? { mode } : {}),\n ...(absoluteConfigFile\n ? { configFile: absoluteConfigFile }\n : tastyConfig\n ? { config: tastyConfig }\n : {}),\n ...(allDeps.length > 0 ? { configDeps: allDeps } : {}),\n },\n ],\n ],\n };\n\n const existingTurbopack = nextConfig.turbopack || {};\n const existingRules = existingTurbopack.rules || {};\n\n const existingExperimental =\n (nextConfig.experimental as Record<string, unknown>) || {};\n\n return {\n ...nextConfig,\n\n experimental: {\n ...existingExperimental,\n turbopackUseBuiltinBabel: true,\n },\n\n turbopack: {\n ...existingTurbopack,\n rules: {\n ...existingRules,\n '*.{ts,tsx,js,jsx}': {\n condition: { not: 'foreign' },\n loaders: [\n {\n loader: 'babel-loader',\n options: turbopackBabelOptions,\n },\n ],\n },\n },\n },\n\n webpack(config: any, context: WebpackConfigContext) {\n const { dir } = context;\n\n const wpProjectDir = dir || projectDir;\n const wpAbsoluteOutput = path.resolve(wpProjectDir, output);\n const projectRequire = createRequire(\n path.resolve(wpProjectDir, 'package.json'),\n );\n\n const wpAbsoluteConfigFile = configFile\n ? path.resolve(wpProjectDir, configFile)\n : undefined;\n\n const wpAllDeps = [\n ...(wpAbsoluteConfigFile ? [wpAbsoluteConfigFile] : []),\n ...configDeps.map((dep) => path.resolve(wpProjectDir, dep)),\n ];\n\n const babelPluginOptions: TastyZeroBabelOptions = {\n output: wpAbsoluteOutput,\n injectImport: true,\n ...(mode ? { mode } : {}),\n };\n\n if (wpAbsoluteConfigFile) {\n const jiti = createJiti(wpProjectDir, {\n moduleCache: false,\n });\n\n babelPluginOptions.config = () => {\n return jiti(wpAbsoluteConfigFile) as TastyZeroConfig;\n };\n } else if (tastyConfig) {\n babelPluginOptions.config = tastyConfig;\n }\n\n if (wpAllDeps.length > 0) {\n babelPluginOptions.configDeps = wpAllDeps;\n }\n\n const babelPluginConfig = [babelPluginPath, babelPluginOptions];\n\n const existingRule = config.module?.rules?.find(\n (rule: any) =>\n rule.use?.loader === 'babel-loader' ||\n rule.use?.some?.((u: any) => u.loader === 'babel-loader'),\n );\n\n if (existingRule) {\n const babelUse = Array.isArray(existingRule.use)\n ? existingRule.use.find((u: any) => u.loader === 'babel-loader')\n : existingRule.use;\n\n if (babelUse?.options) {\n babelUse.options.plugins = babelUse.options.plugins || [];\n babelUse.options.plugins.push(babelPluginConfig);\n }\n } else {\n config.module = config.module || {};\n config.module.rules = config.module.rules || [];\n config.module.rules.push({\n test: /\\.(tsx?|jsx?)$/,\n exclude: /node_modules/,\n use: [\n {\n loader: projectRequire.resolve('babel-loader'),\n options: {\n babelrc: false,\n configFile: false,\n parserOpts: {\n plugins: ['typescript', 'jsx', 'decorators-legacy'],\n },\n plugins: [babelPluginConfig],\n },\n },\n ],\n });\n }\n\n if (typeof nextConfig.webpack === 'function') {\n return nextConfig.webpack(config, context);\n }\n\n return config;\n },\n };\n };\n}\n"],"mappings":";;;;;;;;;;;;;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