typewritingclass-next 0.1.1 → 0.1.3
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 -1
- package/dist/index.cjs +60 -0
- package/{src/TWCStyles.tsx → dist/index.d.cts} +6 -9
- package/dist/index.d.ts +30 -0
- package/dist/index.js +20 -0
- package/dist/plugin.cjs +56 -0
- package/dist/plugin.d.cts +37 -0
- package/dist/plugin.d.ts +37 -0
- package/dist/plugin.js +31 -0
- package/package.json +32 -12
- package/src/index.ts +0 -3
- package/src/plugin.ts +0 -70
package/README.md
CHANGED
|
@@ -40,7 +40,7 @@ Use `tw` directly -- no hooks, no client boundary:
|
|
|
40
40
|
import { tw } from 'typewritingclass'
|
|
41
41
|
|
|
42
42
|
export default function Home() {
|
|
43
|
-
return <h1 className={
|
|
43
|
+
return <h1 className={tw.text('2xl').font('700').textColor('slate-900')}>Hello</h1>
|
|
44
44
|
}
|
|
45
45
|
```
|
|
46
46
|
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/index.ts
|
|
31
|
+
var src_exports = {};
|
|
32
|
+
__export(src_exports, {
|
|
33
|
+
TWCStyles: () => TWCStyles,
|
|
34
|
+
getStyleSheet: () => import_server2.getStyleSheet,
|
|
35
|
+
getStyleTag: () => import_server2.getStyleTag,
|
|
36
|
+
useStyle: () => import_typewritingclass_react.useStyle
|
|
37
|
+
});
|
|
38
|
+
module.exports = __toCommonJS(src_exports);
|
|
39
|
+
|
|
40
|
+
// src/TWCStyles.tsx
|
|
41
|
+
var import_react = __toESM(require("react"), 1);
|
|
42
|
+
var import_server = require("typewritingclass-react/server");
|
|
43
|
+
function TWCStyles() {
|
|
44
|
+
const css = (0, import_server.getStyleSheet)();
|
|
45
|
+
return import_react.default.createElement("style", {
|
|
46
|
+
"data-twc": "",
|
|
47
|
+
dangerouslySetInnerHTML: { __html: css }
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// src/index.ts
|
|
52
|
+
var import_typewritingclass_react = require("typewritingclass-react");
|
|
53
|
+
var import_server2 = require("typewritingclass-react/server");
|
|
54
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
55
|
+
0 && (module.exports = {
|
|
56
|
+
TWCStyles,
|
|
57
|
+
getStyleSheet,
|
|
58
|
+
getStyleTag,
|
|
59
|
+
useStyle
|
|
60
|
+
});
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import React from 'react'
|
|
2
|
-
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export { useStyle } from 'typewritingclass-react';
|
|
3
|
+
export { getStyleSheet, getStyleTag } from 'typewritingclass-react/server';
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* Server component that injects typewritingclass CSS into the document head.
|
|
@@ -24,10 +25,6 @@ import { getStyleSheet } from 'typewritingclass-react/server'
|
|
|
24
25
|
* }
|
|
25
26
|
* ```
|
|
26
27
|
*/
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
'data-twc': '',
|
|
31
|
-
dangerouslySetInnerHTML: { __html: css },
|
|
32
|
-
})
|
|
33
|
-
}
|
|
28
|
+
declare function TWCStyles(): React.JSX.Element;
|
|
29
|
+
|
|
30
|
+
export { TWCStyles };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export { useStyle } from 'typewritingclass-react';
|
|
3
|
+
export { getStyleSheet, getStyleTag } from 'typewritingclass-react/server';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Server component that injects typewritingclass CSS into the document head.
|
|
7
|
+
*
|
|
8
|
+
* Place this in your root layout to ensure all styles are included during SSR.
|
|
9
|
+
* This component is safe to use in React Server Components — it has no client-side
|
|
10
|
+
* dependencies.
|
|
11
|
+
*
|
|
12
|
+
* @example app/layout.tsx
|
|
13
|
+
* ```tsx
|
|
14
|
+
* import { TWCStyles } from 'typewritingclass-next'
|
|
15
|
+
*
|
|
16
|
+
* export default function RootLayout({ children }: { children: React.ReactNode }) {
|
|
17
|
+
* return (
|
|
18
|
+
* <html>
|
|
19
|
+
* <head>
|
|
20
|
+
* <TWCStyles />
|
|
21
|
+
* </head>
|
|
22
|
+
* <body>{children}</body>
|
|
23
|
+
* </html>
|
|
24
|
+
* )
|
|
25
|
+
* }
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
declare function TWCStyles(): React.JSX.Element;
|
|
29
|
+
|
|
30
|
+
export { TWCStyles };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// src/TWCStyles.tsx
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { getStyleSheet } from "typewritingclass-react/server";
|
|
4
|
+
function TWCStyles() {
|
|
5
|
+
const css = getStyleSheet();
|
|
6
|
+
return React.createElement("style", {
|
|
7
|
+
"data-twc": "",
|
|
8
|
+
dangerouslySetInnerHTML: { __html: css }
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
// src/index.ts
|
|
13
|
+
import { useStyle } from "typewritingclass-react";
|
|
14
|
+
import { getStyleSheet as getStyleSheet2, getStyleTag } from "typewritingclass-react/server";
|
|
15
|
+
export {
|
|
16
|
+
TWCStyles,
|
|
17
|
+
getStyleSheet2 as getStyleSheet,
|
|
18
|
+
getStyleTag,
|
|
19
|
+
useStyle
|
|
20
|
+
};
|
package/dist/plugin.cjs
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/plugin.ts
|
|
21
|
+
var plugin_exports = {};
|
|
22
|
+
__export(plugin_exports, {
|
|
23
|
+
withTwc: () => withTwc
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(plugin_exports);
|
|
26
|
+
function withTwc(nextConfig = {}, options = {}) {
|
|
27
|
+
const babelOptions = {
|
|
28
|
+
outputFile: options.outputFile ?? ".next/twc.css",
|
|
29
|
+
strict: options.strict ?? true
|
|
30
|
+
};
|
|
31
|
+
return {
|
|
32
|
+
...nextConfig,
|
|
33
|
+
webpack(config, context) {
|
|
34
|
+
config.module.rules.push({
|
|
35
|
+
test: /\.[jt]sx?$/,
|
|
36
|
+
exclude: /node_modules/,
|
|
37
|
+
use: {
|
|
38
|
+
loader: "babel-loader",
|
|
39
|
+
options: {
|
|
40
|
+
plugins: [
|
|
41
|
+
["typewritingclass-babel", babelOptions]
|
|
42
|
+
]
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
if (typeof nextConfig.webpack === "function") {
|
|
47
|
+
return nextConfig.webpack(config, context);
|
|
48
|
+
}
|
|
49
|
+
return config;
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
54
|
+
0 && (module.exports = {
|
|
55
|
+
withTwc
|
|
56
|
+
});
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
interface NextConfig {
|
|
2
|
+
webpack?: (config: any, context: any) => any;
|
|
3
|
+
[key: string]: any;
|
|
4
|
+
}
|
|
5
|
+
interface TwcNextPluginOptions {
|
|
6
|
+
/** Path to write the combined CSS output file. Default: ".next/twc.css" */
|
|
7
|
+
outputFile?: string;
|
|
8
|
+
/** Enable strict mode for the compiler. Default: true */
|
|
9
|
+
strict?: boolean;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Next.js plugin that integrates typewritingclass build-time CSS extraction.
|
|
13
|
+
*
|
|
14
|
+
* Configures webpack to run the typewritingclass Babel transform on your source
|
|
15
|
+
* files, extracting static CSS at build time.
|
|
16
|
+
*
|
|
17
|
+
* @example next.config.mjs
|
|
18
|
+
* ```js
|
|
19
|
+
* import { withTwc } from 'typewritingclass-next/plugin'
|
|
20
|
+
*
|
|
21
|
+
* export default withTwc({
|
|
22
|
+
* // your next config
|
|
23
|
+
* })
|
|
24
|
+
* ```
|
|
25
|
+
*
|
|
26
|
+
* @example With options
|
|
27
|
+
* ```js
|
|
28
|
+
* import { withTwc } from 'typewritingclass-next/plugin'
|
|
29
|
+
*
|
|
30
|
+
* export default withTwc({
|
|
31
|
+
* // your next config
|
|
32
|
+
* }, { strict: true })
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
declare function withTwc(nextConfig?: NextConfig, options?: TwcNextPluginOptions): NextConfig;
|
|
36
|
+
|
|
37
|
+
export { type TwcNextPluginOptions, withTwc };
|
package/dist/plugin.d.ts
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
interface NextConfig {
|
|
2
|
+
webpack?: (config: any, context: any) => any;
|
|
3
|
+
[key: string]: any;
|
|
4
|
+
}
|
|
5
|
+
interface TwcNextPluginOptions {
|
|
6
|
+
/** Path to write the combined CSS output file. Default: ".next/twc.css" */
|
|
7
|
+
outputFile?: string;
|
|
8
|
+
/** Enable strict mode for the compiler. Default: true */
|
|
9
|
+
strict?: boolean;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Next.js plugin that integrates typewritingclass build-time CSS extraction.
|
|
13
|
+
*
|
|
14
|
+
* Configures webpack to run the typewritingclass Babel transform on your source
|
|
15
|
+
* files, extracting static CSS at build time.
|
|
16
|
+
*
|
|
17
|
+
* @example next.config.mjs
|
|
18
|
+
* ```js
|
|
19
|
+
* import { withTwc } from 'typewritingclass-next/plugin'
|
|
20
|
+
*
|
|
21
|
+
* export default withTwc({
|
|
22
|
+
* // your next config
|
|
23
|
+
* })
|
|
24
|
+
* ```
|
|
25
|
+
*
|
|
26
|
+
* @example With options
|
|
27
|
+
* ```js
|
|
28
|
+
* import { withTwc } from 'typewritingclass-next/plugin'
|
|
29
|
+
*
|
|
30
|
+
* export default withTwc({
|
|
31
|
+
* // your next config
|
|
32
|
+
* }, { strict: true })
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
declare function withTwc(nextConfig?: NextConfig, options?: TwcNextPluginOptions): NextConfig;
|
|
36
|
+
|
|
37
|
+
export { type TwcNextPluginOptions, withTwc };
|
package/dist/plugin.js
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// src/plugin.ts
|
|
2
|
+
function withTwc(nextConfig = {}, options = {}) {
|
|
3
|
+
const babelOptions = {
|
|
4
|
+
outputFile: options.outputFile ?? ".next/twc.css",
|
|
5
|
+
strict: options.strict ?? true
|
|
6
|
+
};
|
|
7
|
+
return {
|
|
8
|
+
...nextConfig,
|
|
9
|
+
webpack(config, context) {
|
|
10
|
+
config.module.rules.push({
|
|
11
|
+
test: /\.[jt]sx?$/,
|
|
12
|
+
exclude: /node_modules/,
|
|
13
|
+
use: {
|
|
14
|
+
loader: "babel-loader",
|
|
15
|
+
options: {
|
|
16
|
+
plugins: [
|
|
17
|
+
["typewritingclass-babel", babelOptions]
|
|
18
|
+
]
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
if (typeof nextConfig.webpack === "function") {
|
|
23
|
+
return nextConfig.webpack(config, context);
|
|
24
|
+
}
|
|
25
|
+
return config;
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
export {
|
|
30
|
+
withTwc
|
|
31
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "typewritingclass-next",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -9,30 +9,50 @@
|
|
|
9
9
|
},
|
|
10
10
|
"exports": {
|
|
11
11
|
".": {
|
|
12
|
-
"
|
|
13
|
-
|
|
12
|
+
"import": {
|
|
13
|
+
"types": "./dist/index.d.ts",
|
|
14
|
+
"default": "./dist/index.js"
|
|
15
|
+
},
|
|
16
|
+
"require": {
|
|
17
|
+
"types": "./dist/index.d.cts",
|
|
18
|
+
"default": "./dist/index.cjs"
|
|
19
|
+
}
|
|
14
20
|
},
|
|
15
21
|
"./plugin": {
|
|
16
|
-
"
|
|
17
|
-
|
|
22
|
+
"import": {
|
|
23
|
+
"types": "./dist/plugin.d.ts",
|
|
24
|
+
"default": "./dist/plugin.js"
|
|
25
|
+
},
|
|
26
|
+
"require": {
|
|
27
|
+
"types": "./dist/plugin.d.cts",
|
|
28
|
+
"default": "./dist/plugin.cjs"
|
|
29
|
+
}
|
|
18
30
|
}
|
|
19
31
|
},
|
|
20
|
-
"
|
|
32
|
+
"main": "./dist/index.cjs",
|
|
33
|
+
"module": "./dist/index.js",
|
|
34
|
+
"types": "./dist/index.d.ts",
|
|
35
|
+
"files": [
|
|
36
|
+
"dist"
|
|
37
|
+
],
|
|
21
38
|
"peerDependencies": {
|
|
22
39
|
"next": "^13 || ^14 || ^15",
|
|
23
40
|
"react": "^18 || ^19",
|
|
24
|
-
"typewritingclass": "
|
|
25
|
-
"typewritingclass-react": "
|
|
41
|
+
"typewritingclass": "0.2.3",
|
|
42
|
+
"typewritingclass-react": "0.2.1"
|
|
26
43
|
},
|
|
27
44
|
"dependencies": {
|
|
28
|
-
"typewritingclass-babel": "
|
|
45
|
+
"typewritingclass-babel": "0.1.3"
|
|
29
46
|
},
|
|
30
47
|
"devDependencies": {
|
|
31
48
|
"next": "^15.0.0",
|
|
32
49
|
"react": "^19.0.0",
|
|
33
50
|
"@types/react": "^19.0.0",
|
|
34
51
|
"typescript": "^5.7.3",
|
|
35
|
-
"typewritingclass": "
|
|
36
|
-
"typewritingclass-react": "
|
|
52
|
+
"typewritingclass": "0.2.3",
|
|
53
|
+
"typewritingclass-react": "0.2.1"
|
|
54
|
+
},
|
|
55
|
+
"scripts": {
|
|
56
|
+
"build": "tsup"
|
|
37
57
|
}
|
|
38
|
-
}
|
|
58
|
+
}
|
package/src/index.ts
DELETED
package/src/plugin.ts
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import type { TwcBabelPluginOptions } from 'typewritingclass-babel'
|
|
2
|
-
|
|
3
|
-
interface NextConfig {
|
|
4
|
-
webpack?: (config: any, context: any) => any
|
|
5
|
-
[key: string]: any
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export interface TwcNextPluginOptions {
|
|
9
|
-
/** Path to write the combined CSS output file. Default: ".next/twc.css" */
|
|
10
|
-
outputFile?: string
|
|
11
|
-
/** Enable strict mode for the compiler. Default: true */
|
|
12
|
-
strict?: boolean
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Next.js plugin that integrates typewritingclass build-time CSS extraction.
|
|
17
|
-
*
|
|
18
|
-
* Configures webpack to run the typewritingclass Babel transform on your source
|
|
19
|
-
* files, extracting static CSS at build time.
|
|
20
|
-
*
|
|
21
|
-
* @example next.config.mjs
|
|
22
|
-
* ```js
|
|
23
|
-
* import { withTwc } from 'typewritingclass-next/plugin'
|
|
24
|
-
*
|
|
25
|
-
* export default withTwc({
|
|
26
|
-
* // your next config
|
|
27
|
-
* })
|
|
28
|
-
* ```
|
|
29
|
-
*
|
|
30
|
-
* @example With options
|
|
31
|
-
* ```js
|
|
32
|
-
* import { withTwc } from 'typewritingclass-next/plugin'
|
|
33
|
-
*
|
|
34
|
-
* export default withTwc({
|
|
35
|
-
* // your next config
|
|
36
|
-
* }, { strict: true })
|
|
37
|
-
* ```
|
|
38
|
-
*/
|
|
39
|
-
export function withTwc(nextConfig: NextConfig = {}, options: TwcNextPluginOptions = {}): NextConfig {
|
|
40
|
-
const babelOptions: TwcBabelPluginOptions = {
|
|
41
|
-
outputFile: options.outputFile ?? '.next/twc.css',
|
|
42
|
-
strict: options.strict ?? true,
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
return {
|
|
46
|
-
...nextConfig,
|
|
47
|
-
webpack(config: any, context: any) {
|
|
48
|
-
// Add the typewritingclass babel plugin to the webpack babel-loader
|
|
49
|
-
config.module.rules.push({
|
|
50
|
-
test: /\.[jt]sx?$/,
|
|
51
|
-
exclude: /node_modules/,
|
|
52
|
-
use: {
|
|
53
|
-
loader: 'babel-loader',
|
|
54
|
-
options: {
|
|
55
|
-
plugins: [
|
|
56
|
-
['typewritingclass-babel', babelOptions],
|
|
57
|
-
],
|
|
58
|
-
},
|
|
59
|
-
},
|
|
60
|
-
})
|
|
61
|
-
|
|
62
|
-
// Call the user's webpack config if they provided one
|
|
63
|
-
if (typeof nextConfig.webpack === 'function') {
|
|
64
|
-
return nextConfig.webpack(config, context)
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
return config
|
|
68
|
-
},
|
|
69
|
-
}
|
|
70
|
-
}
|