@syrin/iris 0.5.0 → 0.8.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/dist/vite.d.ts ADDED
@@ -0,0 +1,43 @@
1
+ declare const IRIS_VITE_PLUGIN_NAME = "iris";
2
+ interface IrisVitePluginOptions {
3
+ /** Bridge WebSocket port. Defaults to the SDK default; only baked into connect() when non-default. */
4
+ port?: number;
5
+ /** Stable session label for the bridge. Defaults to the SDK's auto-generated id. */
6
+ session?: string;
7
+ /** Auth token forwarded to connect() when the bridge requires one. */
8
+ token?: string;
9
+ /** Stamp data-iris-source for React 19 source mapping. Default true (harmless on React <=18). */
10
+ sourceMapping?: boolean;
11
+ /** Auto-inject the dev-gated iris.connect() call. Default true. */
12
+ inject?: boolean;
13
+ }
14
+ /** Structural Vite plugin shape — avoids a hard dependency on `vite` while staying assignable to its `Plugin`. */
15
+ interface IrisVitePlugin {
16
+ name: string;
17
+ apply: 'serve';
18
+ enforce: 'pre';
19
+ transform: (code: string, id: string) => {
20
+ code: string;
21
+ map: string | null;
22
+ } | null;
23
+ resolveId: (id: string) => string | null;
24
+ load: (id: string) => string | null;
25
+ transformIndexHtml: (html: string) => HtmlTag[];
26
+ }
27
+ interface HtmlTag {
28
+ tag: string;
29
+ attrs: Record<string, string>;
30
+ injectTo: 'body';
31
+ }
32
+ /**
33
+ * Iris Vite plugin. Add to your `plugins` array and the entire integration is done:
34
+ *
35
+ * import { iris } from '@syrin/iris/vite';
36
+ * export default defineConfig({ plugins: [react(), iris()] });
37
+ *
38
+ * `apply: 'serve'` means Vite drops the plugin entirely from `vite build` — production bundles
39
+ * are never instrumented. Gating is the tool's job, not a user-managed env check.
40
+ */
41
+ declare function iris(options?: IrisVitePluginOptions): IrisVitePlugin;
42
+
43
+ export { IRIS_VITE_PLUGIN_NAME, type IrisVitePlugin, type IrisVitePluginOptions, iris };
package/dist/vite.js ADDED
@@ -0,0 +1,148 @@
1
+ // ../vite-plugin/dist/index.js
2
+ import { transformSync } from "@babel/core";
3
+
4
+ // ../babel-plugin/dist/index.js
5
+ import { relative } from "path";
6
+ var SOURCE_ATTR = "data-iris-source";
7
+ function irisSourcePlugin({ types: t }) {
8
+ return {
9
+ name: "iris-source",
10
+ visitor: {
11
+ JSXOpeningElement(path, state) {
12
+ const node = path.node;
13
+ if (node.name.type !== "JSXIdentifier")
14
+ return;
15
+ const first = node.name.name[0];
16
+ if (first === void 0 || first !== first.toLowerCase())
17
+ return;
18
+ const alreadyStamped = node.attributes.some((attr) => attr.type === "JSXAttribute" && attr.name.type === "JSXIdentifier" && attr.name.name === SOURCE_ATTR);
19
+ if (alreadyStamped)
20
+ return;
21
+ const loc = node.loc;
22
+ if (loc === null || loc === void 0)
23
+ return;
24
+ const filename = state.filename ?? "unknown";
25
+ const rel = relative(process.cwd(), filename);
26
+ const value = `${rel}:${String(loc.start.line)}:${String(loc.start.column)}`;
27
+ node.attributes.push(t.jsxAttribute(t.jsxIdentifier(SOURCE_ATTR), t.stringLiteral(value)));
28
+ }
29
+ }
30
+ };
31
+ }
32
+
33
+ // ../protocol/dist/constants.js
34
+ var IRIS_DEFAULT_PORT = 4400;
35
+ var IRIS_WS_PATH = "/iris";
36
+ var TRANSPORT_LIMITS = {
37
+ MAX_MESSAGE_BYTES: 1024 * 1024,
38
+ MAX_MESSAGES_PER_SECOND: 1e3,
39
+ MAX_SESSIONS: 32,
40
+ MAX_PENDING_CONNECTIONS: 16,
41
+ HELLO_TIMEOUT_MS: 5e3,
42
+ MAX_BUFFER_BYTES: 8 * 1024 * 1024,
43
+ MAX_SESSION_ID_LENGTH: 128,
44
+ MAX_URL_LENGTH: 4096,
45
+ MAX_TITLE_LENGTH: 512,
46
+ MAX_ADAPTERS: 32,
47
+ MAX_ADAPTER_NAME_LENGTH: 128,
48
+ MAX_TOKEN_LENGTH: 512,
49
+ MAX_COMMAND_ID_LENGTH: 128,
50
+ MAX_COMMAND_NAME_LENGTH: 128,
51
+ MAX_REF_LENGTH: 128,
52
+ MAX_ERROR_LENGTH: 4096,
53
+ MAX_SERIALIZE_DEPTH: 8,
54
+ MAX_COLLECTION_ITEMS: 200,
55
+ MAX_OBJECT_KEYS: 200,
56
+ MAX_STRING_LENGTH: 64 * 1024,
57
+ /** Human review marks: the note the human types when flagging a mistake on the page. */
58
+ MAX_MARK_NOTE_LENGTH: 2e3,
59
+ /** Human review marks: the legible element label that pins the mark (e.g. "Submit button"). */
60
+ MAX_MARK_LABEL_LENGTH: 256
61
+ };
62
+ var UpdateCheckIntervalMs = 24 * 60 * 60 * 1e3;
63
+ var RING_BUFFER_DEFAULTS = {
64
+ MAX_EVENTS: 2e3,
65
+ MAX_AGE_MS: 6e4,
66
+ MAX_BYTES: TRANSPORT_LIMITS.MAX_BUFFER_BYTES
67
+ };
68
+
69
+ // ../vite-plugin/dist/index.js
70
+ var IRIS_VITE_PLUGIN_NAME = "iris";
71
+ var IRIS_PACKAGE = "@syrin/iris";
72
+ var JSX_FILE = /\.[jt]sx$/;
73
+ var VIRTUAL_PREFIX = "\0";
74
+ var NODE_MODULES = "node_modules";
75
+ var IRIS_CONNECT_MODULE = "/@iris-connect";
76
+ function shouldStamp(id) {
77
+ if (id.startsWith(VIRTUAL_PREFIX))
78
+ return false;
79
+ if (id.includes(NODE_MODULES))
80
+ return false;
81
+ const clean = id.split("?")[0] ?? id;
82
+ return JSX_FILE.test(clean);
83
+ }
84
+ function stamp(code, id) {
85
+ const out = transformSync(code, {
86
+ filename: id,
87
+ plugins: [irisSourcePlugin],
88
+ parserOpts: { plugins: ["jsx", "typescript"] },
89
+ sourceMaps: true,
90
+ configFile: false,
91
+ babelrc: false
92
+ });
93
+ if (out?.code === void 0 || out.code === null)
94
+ return null;
95
+ return {
96
+ code: out.code,
97
+ map: out.map === void 0 || out.map === null ? null : JSON.stringify(out.map)
98
+ };
99
+ }
100
+ function connectArgs(options) {
101
+ const args = {};
102
+ const port = options.port ?? IRIS_DEFAULT_PORT;
103
+ if (port !== IRIS_DEFAULT_PORT)
104
+ args["url"] = `ws://localhost:${String(port)}${IRIS_WS_PATH}`;
105
+ if (options.session !== void 0)
106
+ args["session"] = options.session;
107
+ if (options.token !== void 0)
108
+ args["token"] = options.token;
109
+ return Object.keys(args).length > 0 ? JSON.stringify(args) : "";
110
+ }
111
+ function connectModuleSource(options) {
112
+ const args = connectArgs(options);
113
+ return `import { iris, install } from '${IRIS_PACKAGE}';
114
+ install();
115
+ iris.connect(${args});
116
+ `;
117
+ }
118
+ function iris(options = {}) {
119
+ const sourceMapping = options.sourceMapping !== false;
120
+ const inject = options.inject !== false;
121
+ return {
122
+ name: IRIS_VITE_PLUGIN_NAME,
123
+ apply: "serve",
124
+ enforce: "pre",
125
+ transform(code, id) {
126
+ if (!sourceMapping || !shouldStamp(id))
127
+ return null;
128
+ return stamp(code, id);
129
+ },
130
+ resolveId(id) {
131
+ return inject && id === IRIS_CONNECT_MODULE ? IRIS_CONNECT_MODULE : null;
132
+ },
133
+ load(id) {
134
+ return inject && id === IRIS_CONNECT_MODULE ? connectModuleSource(options) : null;
135
+ },
136
+ transformIndexHtml() {
137
+ if (!inject)
138
+ return [];
139
+ return [
140
+ { tag: "script", attrs: { type: "module", src: IRIS_CONNECT_MODULE }, injectTo: "body" }
141
+ ];
142
+ }
143
+ };
144
+ }
145
+ export {
146
+ IRIS_VITE_PLUGIN_NAME,
147
+ iris
148
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@syrin/iris",
3
- "version": "0.5.0",
3
+ "version": "0.8.0",
4
4
  "description": "One-install Iris: the dev-only SDK (browser + React adapter) and the spec runner under one package, with subpaths for the source-mapping plugins and the MCP server.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -32,6 +32,10 @@
32
32
  "types": "./dist/babel.d.ts",
33
33
  "default": "./dist/babel.js"
34
34
  },
35
+ "./vite": {
36
+ "types": "./dist/vite.d.ts",
37
+ "default": "./dist/vite.js"
38
+ },
35
39
  "./eslint": {
36
40
  "types": "./dist/eslint.d.ts",
37
41
  "default": "./dist/eslint.js"
@@ -52,14 +56,15 @@
52
56
  "@types/ws": "^8.5.13",
53
57
  "tsup": "^8.3.5",
54
58
  "typescript": "^5.6.0",
55
- "@syrin/iris-babel-plugin": "0.5.0",
56
- "@syrin/iris-browser": "0.5.0",
57
- "@syrin/iris-react": "0.5.0",
58
- "@syrin/iris-next": "0.5.0",
59
- "@syrin/iris-eslint-plugin": "0.5.0",
60
- "@syrin/iris-server": "0.5.0",
61
- "@syrin/iris-protocol": "0.5.0",
62
- "@syrin/iris-test": "0.5.0"
59
+ "@syrin/iris-babel-plugin": "0.8.0",
60
+ "@syrin/iris-eslint-plugin": "0.8.0",
61
+ "@syrin/iris-browser": "0.8.0",
62
+ "@syrin/iris-next": "0.8.0",
63
+ "@syrin/iris-react": "0.8.0",
64
+ "@syrin/iris-server": "0.8.0",
65
+ "@syrin/iris-test": "0.8.0",
66
+ "@syrin/iris-protocol": "0.8.0",
67
+ "@syrin/iris-vite-plugin": "0.8.0"
63
68
  },
64
69
  "optionalDependencies": {
65
70
  "pixelmatch": "^7.2.0",
@@ -70,7 +75,7 @@
70
75
  "eslint": ">=9",
71
76
  "next": ">=13",
72
77
  "react": ">=18",
73
- "vitest": "^3.0.0"
78
+ "vitest": "^3.2.6"
74
79
  },
75
80
  "peerDependenciesMeta": {
76
81
  "eslint": {