livestylesync-nextjs 0.1.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.
@@ -0,0 +1,8 @@
1
+ import { NextConfig } from 'next';
2
+
3
+ interface LiveStyleSyncOptions {
4
+ port?: number;
5
+ }
6
+ declare function withLiveStyleSync(nextConfig?: NextConfig, options?: LiveStyleSyncOptions): NextConfig;
7
+
8
+ export { withLiveStyleSync };
package/dist/index.js ADDED
@@ -0,0 +1,38 @@
1
+ // src/LiveStyleSyncPlugin.ts
2
+ import { startWss } from "livestylesync-server-core";
3
+ var started = false;
4
+ var LiveStyleSyncPlugin = class {
5
+ constructor(options = {}) {
6
+ this.port = options.port ?? 3100;
7
+ }
8
+ apply(compiler) {
9
+ if (compiler.options.mode !== "development") return;
10
+ if (started) return;
11
+ compiler.hooks.afterEnvironment.tap("LiveStyleSyncPlugin", () => {
12
+ if (started) return;
13
+ started = true;
14
+ const root = compiler.context;
15
+ startWss(root, null, this.port);
16
+ });
17
+ }
18
+ };
19
+
20
+ // src/index.ts
21
+ function withLiveStyleSync(nextConfig = {}, options = {}) {
22
+ return {
23
+ ...nextConfig,
24
+ webpack(config, context) {
25
+ if (context.dev) {
26
+ config.plugins ?? (config.plugins = []);
27
+ config.plugins.push(new LiveStyleSyncPlugin({ port: options.port }));
28
+ }
29
+ if (typeof nextConfig.webpack === "function") {
30
+ return nextConfig.webpack(config, context);
31
+ }
32
+ return config;
33
+ }
34
+ };
35
+ }
36
+ export {
37
+ withLiveStyleSync
38
+ };
package/package.json ADDED
@@ -0,0 +1,32 @@
1
+ {
2
+ "name": "livestylesync-nextjs",
3
+ "version": "0.1.0",
4
+ "description": "Next.js plugin for LiveStyleSync",
5
+ "license": "MIT",
6
+ "type": "module",
7
+ "main": "dist/index.js",
8
+ "types": "dist/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "import": "./dist/index.js",
12
+ "types": "./dist/index.d.ts"
13
+ }
14
+ },
15
+ "files": ["dist", "README.md"],
16
+ "scripts": {
17
+ "build": "tsup"
18
+ },
19
+ "peerDependencies": {
20
+ "next": ">=14.0.0",
21
+ "webpack": ">=5.0.0"
22
+ },
23
+ "dependencies": {
24
+ "livestylesync-server-core": "workspace:*"
25
+ },
26
+ "devDependencies": {
27
+ "@types/node": "^24.12.2",
28
+ "@types/webpack": "^5.28.5",
29
+ "tsup": "^8.5.1",
30
+ "typescript": "^6.0.3"
31
+ }
32
+ }