iterate-ui-next 0.1.0 → 0.1.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.
@@ -0,0 +1,10 @@
1
+ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
2
+ get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
3
+ }) : x)(function(x) {
4
+ if (typeof require !== "undefined") return require.apply(this, arguments);
5
+ throw Error('Dynamic require of "' + x + '" is not supported');
6
+ });
7
+
8
+ export {
9
+ __require
10
+ };
@@ -0,0 +1,63 @@
1
+ "use strict";
2
+ "use client";
3
+ var __create = Object.create;
4
+ var __defProp = Object.defineProperty;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getProtoOf = Object.getPrototypeOf;
8
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
9
+ var __export = (target, all) => {
10
+ for (var name in all)
11
+ __defProp(target, name, { get: all[name], enumerable: true });
12
+ };
13
+ var __copyProps = (to, from, except, desc) => {
14
+ if (from && typeof from === "object" || typeof from === "function") {
15
+ for (let key of __getOwnPropNames(from))
16
+ if (!__hasOwnProp.call(to, key) && key !== except)
17
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
18
+ }
19
+ return to;
20
+ };
21
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
22
+ // If the importer is in node compatibility mode or this is not an ESM
23
+ // file that has been converted to a CommonJS file using a Babel-
24
+ // compatible transform (i.e. "__esModule" has not been set), then set
25
+ // "default" to the CommonJS "module.exports" for node compatibility.
26
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
27
+ mod
28
+ ));
29
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
30
+
31
+ // src/devtools.tsx
32
+ var devtools_exports = {};
33
+ __export(devtools_exports, {
34
+ IterateDevTools: () => IterateDevTools,
35
+ default: () => devtools_default
36
+ });
37
+ module.exports = __toCommonJS(devtools_exports);
38
+ var import_script = __toESM(require("next/script"), 1);
39
+ var import_jsx_runtime = require("react/jsx-runtime");
40
+ function IterateDevTools({ port = 4e3 }) {
41
+ if (process.env.NODE_ENV === "production") return null;
42
+ const iterationName = process.env.ITERATE_ITERATION_NAME ?? "__original__";
43
+ const initScript = `
44
+ if(!window.__iterate_shell__){
45
+ window.__iterate_shell__={activeTool:"browse",activeIteration:${JSON.stringify(iterationName)},daemonPort:${port}};
46
+ }
47
+ `;
48
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
49
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_script.default, { id: "iterate-init", strategy: "beforeInteractive", children: initScript }),
50
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
51
+ import_script.default,
52
+ {
53
+ src: "/__iterate__/overlay.js",
54
+ strategy: "afterInteractive"
55
+ }
56
+ )
57
+ ] });
58
+ }
59
+ var devtools_default = IterateDevTools;
60
+ // Annotate the CommonJS export names for ESM import in node:
61
+ 0 && (module.exports = {
62
+ IterateDevTools
63
+ });
@@ -0,0 +1,25 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+
3
+ /**
4
+ * Drop-in overlay loader for Turbopack or any environment where the
5
+ * webpack entry-point injection doesn't run.
6
+ *
7
+ * Usage (root layout):
8
+ * ```tsx
9
+ * import { IterateDevTools } from "iterate-ui-next/devtools";
10
+ *
11
+ * export default function RootLayout({ children }) {
12
+ * return (
13
+ * <html><body>
14
+ * {children}
15
+ * <IterateDevTools />
16
+ * </body></html>
17
+ * );
18
+ * }
19
+ * ```
20
+ */
21
+ declare function IterateDevTools({ port }: {
22
+ port?: number;
23
+ }): react_jsx_runtime.JSX.Element | null;
24
+
25
+ export { IterateDevTools, IterateDevTools as default };
@@ -0,0 +1,25 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+
3
+ /**
4
+ * Drop-in overlay loader for Turbopack or any environment where the
5
+ * webpack entry-point injection doesn't run.
6
+ *
7
+ * Usage (root layout):
8
+ * ```tsx
9
+ * import { IterateDevTools } from "iterate-ui-next/devtools";
10
+ *
11
+ * export default function RootLayout({ children }) {
12
+ * return (
13
+ * <html><body>
14
+ * {children}
15
+ * <IterateDevTools />
16
+ * </body></html>
17
+ * );
18
+ * }
19
+ * ```
20
+ */
21
+ declare function IterateDevTools({ port }: {
22
+ port?: number;
23
+ }): react_jsx_runtime.JSX.Element | null;
24
+
25
+ export { IterateDevTools, IterateDevTools as default };
@@ -0,0 +1,30 @@
1
+ "use client";
2
+ import "./chunk-3RG5ZIWI.js";
3
+
4
+ // src/devtools.tsx
5
+ import Script from "next/script";
6
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
7
+ function IterateDevTools({ port = 4e3 }) {
8
+ if (process.env.NODE_ENV === "production") return null;
9
+ const iterationName = process.env.ITERATE_ITERATION_NAME ?? "__original__";
10
+ const initScript = `
11
+ if(!window.__iterate_shell__){
12
+ window.__iterate_shell__={activeTool:"browse",activeIteration:${JSON.stringify(iterationName)},daemonPort:${port}};
13
+ }
14
+ `;
15
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
16
+ /* @__PURE__ */ jsx(Script, { id: "iterate-init", strategy: "beforeInteractive", children: initScript }),
17
+ /* @__PURE__ */ jsx(
18
+ Script,
19
+ {
20
+ src: "/__iterate__/overlay.js",
21
+ strategy: "afterInteractive"
22
+ }
23
+ )
24
+ ] });
25
+ }
26
+ var devtools_default = IterateDevTools;
27
+ export {
28
+ IterateDevTools,
29
+ devtools_default as default
30
+ };
package/dist/index.cjs CHANGED
@@ -30,6 +30,18 @@ var import_node_module = require("module");
30
30
  var import_node_path = require("path");
31
31
  var import_node_fs = require("fs");
32
32
  var import_meta = {};
33
+ function isTurbopackMode() {
34
+ if (process.env.TURBOPACK === "1") return true;
35
+ if (process.argv.some((a) => a === "--turbo" || a === "--turbopack")) return true;
36
+ try {
37
+ const _req = typeof require !== "undefined" ? require : (0, import_node_module.createRequire)(import_meta.url);
38
+ const nextPkg = JSON.parse((0, import_node_fs.readFileSync)(_req.resolve("next/package.json"), "utf-8"));
39
+ const major = parseInt(nextPkg.version.split(".")[0], 10);
40
+ if (major >= 16 && !process.argv.includes("--webpack")) return true;
41
+ } catch {
42
+ }
43
+ return false;
44
+ }
33
45
  function resolvePackageEntry(packageName, _require) {
34
46
  try {
35
47
  return _require.resolve(packageName);
@@ -77,7 +89,13 @@ function withIterate(nextConfig = {}, options = {}) {
77
89
  } catch {
78
90
  console.warn("[iterate] Could not resolve overlay bundle or babel plugin");
79
91
  }
80
- return {
92
+ const turbopack = isTurbopackMode();
93
+ if (turbopack) {
94
+ console.warn(
95
+ '\x1B[33m[iterate]\x1B[0m Turbopack detected \u2014 webpack entry injection is disabled.\n The overlay will not auto-inject. To fix, choose one of:\n 1. Run with webpack: next dev --webpack\n 2. Add to your root layout: import { IterateDevTools } from "iterate-ui-next/devtools"\n Then render <IterateDevTools /> inside <body>.\n'
96
+ );
97
+ }
98
+ const result = {
81
99
  ...nextConfig,
82
100
  // Add rewrites to proxy to the daemon
83
101
  async rewrites() {
@@ -118,9 +136,10 @@ function withIterate(nextConfig = {}, options = {}) {
118
136
  ...existingRewrites.beforeFiles ?? []
119
137
  ]
120
138
  };
121
- },
122
- // Inject overlay via webpack
123
- webpack(config, context) {
139
+ }
140
+ };
141
+ if (!turbopack) {
142
+ result.webpack = function webpack(config, context) {
124
143
  if (context.isServer || !context.dev) {
125
144
  return nextConfig.webpack?.(config, context) ?? config;
126
145
  }
@@ -140,8 +159,9 @@ function withIterate(nextConfig = {}, options = {}) {
140
159
  return entries;
141
160
  };
142
161
  return nextConfig.webpack?.(config, context) ?? config;
143
- }
144
- };
162
+ };
163
+ }
164
+ return result;
145
165
  }
146
166
  function createIterateInjector(_overlayPath, daemonPort) {
147
167
  const iterationName = process.env.ITERATE_ITERATION_NAME ?? "__original__";
package/dist/index.js CHANGED
@@ -1,9 +1,6 @@
1
- var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
2
- get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
3
- }) : x)(function(x) {
4
- if (typeof require !== "undefined") return require.apply(this, arguments);
5
- throw Error('Dynamic require of "' + x + '" is not supported');
6
- });
1
+ import {
2
+ __require
3
+ } from "./chunk-3RG5ZIWI.js";
7
4
 
8
5
  // src/index.ts
9
6
  import { spawn, execSync } from "child_process";
@@ -11,6 +8,18 @@ import { createConnection } from "net";
11
8
  import { createRequire } from "module";
12
9
  import { join, dirname } from "path";
13
10
  import { readFileSync } from "fs";
11
+ function isTurbopackMode() {
12
+ if (process.env.TURBOPACK === "1") return true;
13
+ if (process.argv.some((a) => a === "--turbo" || a === "--turbopack")) return true;
14
+ try {
15
+ const _req = typeof __require !== "undefined" ? __require : createRequire(import.meta.url);
16
+ const nextPkg = JSON.parse(readFileSync(_req.resolve("next/package.json"), "utf-8"));
17
+ const major = parseInt(nextPkg.version.split(".")[0], 10);
18
+ if (major >= 16 && !process.argv.includes("--webpack")) return true;
19
+ } catch {
20
+ }
21
+ return false;
22
+ }
14
23
  function resolvePackageEntry(packageName, _require) {
15
24
  try {
16
25
  return _require.resolve(packageName);
@@ -58,7 +67,13 @@ function withIterate(nextConfig = {}, options = {}) {
58
67
  } catch {
59
68
  console.warn("[iterate] Could not resolve overlay bundle or babel plugin");
60
69
  }
61
- return {
70
+ const turbopack = isTurbopackMode();
71
+ if (turbopack) {
72
+ console.warn(
73
+ '\x1B[33m[iterate]\x1B[0m Turbopack detected \u2014 webpack entry injection is disabled.\n The overlay will not auto-inject. To fix, choose one of:\n 1. Run with webpack: next dev --webpack\n 2. Add to your root layout: import { IterateDevTools } from "iterate-ui-next/devtools"\n Then render <IterateDevTools /> inside <body>.\n'
74
+ );
75
+ }
76
+ const result = {
62
77
  ...nextConfig,
63
78
  // Add rewrites to proxy to the daemon
64
79
  async rewrites() {
@@ -99,9 +114,10 @@ function withIterate(nextConfig = {}, options = {}) {
99
114
  ...existingRewrites.beforeFiles ?? []
100
115
  ]
101
116
  };
102
- },
103
- // Inject overlay via webpack
104
- webpack(config, context) {
117
+ }
118
+ };
119
+ if (!turbopack) {
120
+ result.webpack = function webpack(config, context) {
105
121
  if (context.isServer || !context.dev) {
106
122
  return nextConfig.webpack?.(config, context) ?? config;
107
123
  }
@@ -121,8 +137,9 @@ function withIterate(nextConfig = {}, options = {}) {
121
137
  return entries;
122
138
  };
123
139
  return nextConfig.webpack?.(config, context) ?? config;
124
- }
125
- };
140
+ };
141
+ }
142
+ return result;
126
143
  }
127
144
  function createIterateInjector(_overlayPath, daemonPort) {
128
145
  const iterationName = process.env.ITERATE_ITERATION_NAME ?? "__original__";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "iterate-ui-next",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "iterate Next.js plugin — auto-starts daemon and injects overlay",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -29,24 +29,31 @@
29
29
  "types": "./dist/index.d.ts",
30
30
  "import": "./dist/index.js",
31
31
  "require": "./dist/index.cjs"
32
+ },
33
+ "./devtools": {
34
+ "types": "./dist/devtools.d.ts",
35
+ "import": "./dist/devtools.js",
36
+ "require": "./dist/devtools.cjs"
32
37
  }
33
38
  },
34
39
  "dependencies": {
35
- "iterate-ui-daemon": "0.1.0",
36
- "iterate-ui-overlay": "0.1.0",
37
- "iterate-ui-babel-plugin": "0.1.0"
40
+ "iterate-ui-babel-plugin": "0.1.1",
41
+ "iterate-ui-overlay": "0.1.1",
42
+ "iterate-ui-daemon": "0.1.1"
38
43
  },
39
44
  "peerDependencies": {
40
- "next": "^14.0.0 || ^15.0.0"
45
+ "next": "^14.0.0 || ^15.0.0 || ^16.0.0",
46
+ "react": "^18.0.0 || ^19.0.0"
41
47
  },
42
48
  "devDependencies": {
43
49
  "@types/node": "^22.0.0",
50
+ "@types/react": "^19.2.14",
44
51
  "tsup": "^8.3.0",
45
52
  "typescript": "^5.7.0"
46
53
  },
47
54
  "scripts": {
48
- "build": "tsup src/index.ts --format esm,cjs --dts",
49
- "dev": "tsup src/index.ts --format esm,cjs --dts --watch",
55
+ "build": "tsup src/index.ts src/devtools.tsx --format esm,cjs --dts --external react --external next",
56
+ "dev": "tsup src/index.ts src/devtools.tsx --format esm,cjs --dts --external react --external next --watch",
50
57
  "clean": "rm -rf dist"
51
58
  }
52
59
  }