retouche-dev 0.1.1 → 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.
package/dist/cli.js CHANGED
@@ -2,7 +2,7 @@
2
2
  import { t as WATCHED_GROUPS } from "./class-groups-DKpPgmHx.js";
3
3
  import { A as voiceIdSchema, i as FOLLOW_OUTCOMES } from "./clock-BJi08VJS.js";
4
4
  import { d as FOLLOW_TOOL, l as reviewItems, p as mcpFollowPrompt, t as cardMarkdown, u as FOLLOW_PROMPT } from "./voice-markdown-BiOKT1SX.js";
5
- import { a as writeFollow, g as failure, i as readFollower, l as readSessionFile, n as followedSession, o as writeFollower, r as readFollow, s as NO_FOLDER, t as EMPTY_FOLLOW, u as projectFolder } from "./follow-files-CfuW6Ah5.js";
5
+ import { _ as failure, a as writeFollow, i as readFollower, l as readSessionFile, n as followedSession, o as writeFollower, r as readFollow, s as NO_FOLDER, t as EMPTY_FOLLOW, u as projectFolder } from "./follow-files-Dcya6bMQ.js";
6
6
  import { existsSync, readFileSync } from "node:fs";
7
7
  import { fileURLToPath } from "node:url";
8
8
  import { z } from "zod";
@@ -36,12 +36,26 @@ function failure(error, status) {
36
36
  function outcomeResponse(outcome) {
37
37
  return outcome.ok ? jsonResponse(outcome.value) : errorResponse(outcome.error, outcome.status);
38
38
  }
39
+ // src/server/deferred.ts
40
+ const unsettled = () => {};
41
+ function deferred() {
42
+ let settle = unsettled;
43
+ let fail = unsettled;
44
+ return {
45
+ promise: new Promise((resolve, reject) => {
46
+ settle = resolve;
47
+ fail = reject;
48
+ }),
49
+ reject: fail,
50
+ resolve: settle
51
+ };
52
+ }
39
53
  // src/server/voice/keyed-queue.ts
40
54
  function createKeyedQueue() {
41
55
  const tails = /* @__PURE__ */ new Map();
42
56
  return async (key, task) => {
43
57
  const previous = tails.get(key);
44
- const { promise: done, resolve } = Promise.withResolvers();
58
+ const { promise: done, resolve } = deferred();
45
59
  tails.set(key, done);
46
60
  try {
47
61
  await previous;
@@ -268,4 +282,4 @@ async function followedSession(projectFolder) {
268
282
  const follow = await readFollow(newest.folder);
269
283
  return follow !== null && follow.closedAt === null ? newest : null;
270
284
  }
271
- export { imageResponse as _, writeFollow as a, SessionFiles as c, projectId as d, userConfigFolder as f, failure as g, errorResponse as h, readFollower as i, readSessionFile as l, createKeyedQueue as m, followedSession as n, writeFollower as o, writePrivateFile as p, readFollow as r, NO_FOLDER as s, EMPTY_FOLLOW as t, projectFolder as u, jsonResponse as v, outcomeResponse as y };
285
+ export { failure as _, writeFollow as a, outcomeResponse as b, SessionFiles as c, projectId as d, userConfigFolder as f, errorResponse as g, deferred as h, readFollower as i, readSessionFile as l, createKeyedQueue as m, followedSession as n, writeFollower as o, writePrivateFile as p, readFollow as r, NO_FOLDER as s, EMPTY_FOLLOW as t, projectFolder as u, imageResponse as v, jsonResponse as y };
@@ -1,5 +1,5 @@
1
1
  import { D as voiceFigureUploadSchema, E as voiceAnalysisRequestSchema, F as voiceShotUploadSchema, I as voiceStreamRequestSchema, M as voiceKeyRequestSchema, N as voiceSessionRequestSchema, O as voiceHistoryRequestSchema, R as voiceTranscriptRequestSchema, _ as TRANSCRIBER_PROVIDER_NAMES, b as isServerFrame, c as EDITORS, d as ROUTE_BASE, g as TRANSCRIBER_PROVIDERS, h as STREAMED_TRANSCRIBERS, l as ENDPOINTS, m as STATUS_MARKER, n as recordedMs, p as SERVER_FRAME_PREFIX, r as pendingPassages, s as BUILT_IN_AGENTS, t as clock, u as REQUEST_HEADER, v as VOICE_ID } from "./clock-BJi08VJS.js";
2
- import { _ as imageResponse, c as SessionFiles, d as projectId, f as userConfigFolder, g as failure$1, h as errorResponse, i as readFollower, m as createKeyedQueue, p as writePrivateFile, r as readFollow, u as projectFolder, v as jsonResponse, y as outcomeResponse } from "./follow-files-CfuW6Ah5.js";
2
+ import { _ as failure$1, b as outcomeResponse, c as SessionFiles, d as projectId, f as userConfigFolder, g as errorResponse, h as deferred, i as readFollower, m as createKeyedQueue, p as writePrivateFile, r as readFollow, u as projectFolder, v as imageResponse, y as jsonResponse } from "./follow-files-Dcya6bMQ.js";
3
3
  import { n as passageRuns, r as spokenWords } from "./spoken-timeline-1xtFghWv.js";
4
4
  import { constants, existsSync, readFileSync, realpathSync } from "node:fs";
5
5
  import { fileURLToPath } from "node:url";
@@ -426,31 +426,32 @@ function readsEnv(options) {
426
426
  const read = /* @__PURE__ */ new Set([...PRESET_KEY_ENVS, ...optionKeyEnvs(options.voice)]);
427
427
  return (name) => name.startsWith(OWN_PREFIX) || read.has(name);
428
428
  }
429
- function withEnvFiles(files, options) {
429
+ const ENV_FILE_NAME = /^\s*(?:export\s+)?(?<name>[\w.-]+)(?:\s*=|:\s)/gmu;
430
+ function envFileNames({ folders, mode }) {
431
+ const files = [
432
+ ".env",
433
+ ".env.local",
434
+ `.env.${mode}`,
435
+ `.env.${mode}.local`
436
+ ];
437
+ const paths = folders.flatMap((folder) => files.map((file) => join(folder, file)));
438
+ return new Set(paths.flatMap((path) => existsSync(path) ? [...readFileSync(path, "utf-8").matchAll(ENV_FILE_NAME)].flatMap((match) => match.groups?.name ?? []) : []));
439
+ }
440
+ function withoutNames(env, drop) {
441
+ return Object.fromEntries(Object.entries(env).filter(([name]) => !drop(name)));
442
+ }
443
+ function appEnvs(loaded, files, options) {
430
444
  const isRead = readsEnv(options);
431
- const picked = Object.entries(files).filter(([name]) => isRead(name));
445
+ const fromFiles = envFileNames(files);
446
+ const env = withoutNames(loaded, (name) => fromFiles.has(name) && !isRead(name));
432
447
  return {
433
- ...process.env,
434
- ...Object.fromEntries(picked)
448
+ env,
449
+ spawnEnv: withoutNames(env, (name) => fromFiles.has(name) && !name.startsWith(OWN_PREFIX))
435
450
  };
436
451
  }
437
- const APP_ENV_FILES = [
438
- ".env",
439
- ".env.local",
440
- ".env.development",
441
- ".env.development.local"
442
- ];
443
- const ENV_FILE_NAME = /^\s*(?:export\s+)?(?<name>[\w.-]+)\s*=/gmu;
444
- function envFileNames(root) {
445
- return new Set(APP_ENV_FILES.flatMap((file) => {
446
- const path = join(root, file);
447
- return existsSync(path) ? [...readFileSync(path, "utf-8").matchAll(ENV_FILE_NAME)].flatMap((match) => match.groups?.name ?? []) : [];
448
- }));
449
- }
450
- function withoutEnvFiles(env, options) {
451
- const isRead = readsEnv(options);
452
- const fromFiles = envFileNames(resolve(presentValue(options.root) ?? process.cwd()));
453
- return Object.fromEntries(Object.entries(env).filter(([name]) => !fromFiles.has(name) || isRead(name)));
452
+ function appEnvFolders(options) {
453
+ const root = resolve(presentValue(options.root) ?? process.cwd());
454
+ return [.../* @__PURE__ */ new Set([process.cwd(), root])];
454
455
  }
455
456
  function resolveServerOptions(options, env) {
456
457
  return {
@@ -992,8 +993,8 @@ async function chatRequest(config, prompt) {
992
993
  }
993
994
  });
994
995
  }
995
- function createEndpointBackend(config) {
996
- return { run: async ({ env, prompt, signal }) => {
996
+ function createEndpointBackend(config, env) {
997
+ return { run: async ({ prompt, signal }) => {
997
998
  const reply = await callEndpoint({
998
999
  answer: chatCompletionSchema,
999
1000
  body: await chatRequest(config, prompt),
@@ -1100,7 +1101,7 @@ function createStopper(child) {
1100
1101
  };
1101
1102
  }
1102
1103
  async function runProcess(call) {
1103
- const { promise, resolve } = Promise.withResolvers();
1104
+ const { promise, resolve } = deferred();
1104
1105
  const child = spawn(call.command, call.args, {
1105
1106
  cwd: call.cwd,
1106
1107
  env: agentEnv(call.env),
@@ -1179,8 +1180,8 @@ function watchExit(child) {
1179
1180
  child.stderr.setEncoding("utf-8").on("data", (chunk) => {
1180
1181
  stderr = (stderr + chunk).slice(-4096);
1181
1182
  });
1182
- const exit = Promise.withResolvers();
1183
- const ended = Promise.withResolvers();
1183
+ const exit = deferred();
1184
+ const ended = deferred();
1184
1185
  child.once("error", (error) => {
1185
1186
  ended.resolve(null);
1186
1187
  exit.resolve({
@@ -1339,7 +1340,7 @@ function failure(error) {
1339
1340
  };
1340
1341
  }
1341
1342
  function deadline(signal) {
1342
- const { promise, resolve } = Promise.withResolvers();
1343
+ const { promise, resolve } = deferred();
1343
1344
  const onAbort = () => {
1344
1345
  resolve("aborted");
1345
1346
  };
@@ -1383,7 +1384,7 @@ async function cancelTurn(running) {
1383
1384
  const { connection, sessionId } = running;
1384
1385
  if (sessionId === null || connection.signal.aborted) return;
1385
1386
  await connection.agent.notify(methods.agent.session.cancel, { sessionId }).catch(() => null);
1386
- const { promise, resolve } = Promise.withResolvers();
1387
+ const { promise, resolve } = deferred();
1387
1388
  const timer = setTimeout(resolve, CANCEL_GRACE_MS, null);
1388
1389
  await Promise.race([running.turn.catch(() => null), promise]);
1389
1390
  clearTimeout(timer);
@@ -1780,18 +1781,18 @@ async function builtInAgent({ id, name }, env) {
1780
1781
  kind: "command"
1781
1782
  };
1782
1783
  }
1783
- async function configuredAgent(config, env) {
1784
+ async function configuredAgent(config, { env, spawnEnv }) {
1784
1785
  const agent = {
1785
1786
  id: agentIdOf(config.name),
1786
1787
  name: config.name
1787
1788
  };
1788
1789
  if (config.kind === "endpoint") return isEndpointReady(config, env) ? {
1789
1790
  agent,
1790
- backend: createEndpointBackend(config),
1791
+ backend: createEndpointBackend(config, env),
1791
1792
  checkSignIn: null,
1792
1793
  kind: "endpoint"
1793
1794
  } : null;
1794
- const command = await findCommand(config.command, env);
1795
+ const command = await findCommand(config.command, spawnEnv);
1795
1796
  return command === null ? null : {
1796
1797
  agent,
1797
1798
  backend: createAcpBackend({
@@ -1802,8 +1803,11 @@ async function configuredAgent(config, env) {
1802
1803
  kind: "command"
1803
1804
  };
1804
1805
  }
1805
- async function findAvailable({ agents, env }) {
1806
- return (await Promise.all([...BUILT_IN_AGENTS.map(async (agent) => await builtInAgent(agent, env)), ...agents.map(async (config) => await configuredAgent(config, env))])).filter((entry) => entry !== null);
1806
+ async function findAvailable({ agents, env, spawnEnv }) {
1807
+ return (await Promise.all([...BUILT_IN_AGENTS.map(async (agent) => await builtInAgent(agent, spawnEnv)), ...agents.map(async (config) => await configuredAgent(config, {
1808
+ env,
1809
+ spawnEnv
1810
+ }))])).filter((entry) => entry !== null);
1807
1811
  }
1808
1812
  async function listAgents(registered) {
1809
1813
  return await Promise.all(registered.map(async ({ agent, checkSignIn, kind }) => ({
@@ -2551,7 +2555,7 @@ var MistralStream = class {
2551
2555
  #keyOrigin;
2552
2556
  #chunkBytes;
2553
2557
  #session;
2554
- #done = Promise.withResolvers();
2558
+ #done = deferred();
2555
2559
  #queued = [];
2556
2560
  #text = "";
2557
2561
  #failure = null;
@@ -2805,15 +2809,16 @@ function transcriptionRoutes(transcription) {
2805
2809
  };
2806
2810
  }
2807
2811
  function createVoiceRoutes(context) {
2808
- const { env, voice } = context;
2812
+ const { env, spawnEnv, voice } = context;
2809
2813
  const store = new SessionFiles(() => projectFolder(env, projectId(context.root())));
2810
2814
  const agents = createAgentRegistry({
2811
2815
  agents: voice.agents,
2812
- env
2816
+ env,
2817
+ spawnEnv
2813
2818
  });
2814
2819
  const analyze = createAnalyzer({
2815
2820
  agents,
2816
- env,
2821
+ env: spawnEnv,
2817
2822
  store
2818
2823
  });
2819
2824
  const transcription = {
@@ -2895,7 +2900,7 @@ async function rejectUnpaired(request, allowedHosts) {
2895
2900
  const isStatus = endpointOf(new URL(request.url).pathname) === ENDPOINTS.status;
2896
2901
  return jsonResponse(unpaired, isStatus ? 200 : 401);
2897
2902
  }
2898
- function createRouteHandler(options = {}, env = process.env) {
2903
+ function createRouteHandler(options = {}, env = process.env, spawnEnv = env) {
2899
2904
  const settings = resolveServerOptions(options, env);
2900
2905
  let roots = null;
2901
2906
  const projectRoots = () => {
@@ -2905,6 +2910,7 @@ function createRouteHandler(options = {}, env = process.env) {
2905
2910
  const voice = createVoiceRoutes({
2906
2911
  env,
2907
2912
  root: () => projectRoots().root,
2913
+ spawnEnv,
2908
2914
  voice: settings.voice
2909
2915
  });
2910
2916
  const routes = {
@@ -2926,4 +2932,4 @@ function createRouteHandler(options = {}, env = process.env) {
2926
2932
  }
2927
2933
  };
2928
2934
  }
2929
- export { withoutEnvFiles as a, withEnvFiles as i, BODY_LIMIT_ERROR as n, isLoopbackAddress as o, MAX_BODY_BYTES as r, createRouteHandler as t };
2935
+ export { appEnvs as a, appEnvFolders as i, BODY_LIMIT_ERROR as n, isLoopbackAddress as o, MAX_BODY_BYTES as r, createRouteHandler as t };
package/dist/index.js CHANGED
@@ -3,7 +3,7 @@ import { c } from "react/compiler-runtime";
3
3
  import { Suspense, lazy, useSyncExternalStore } from "react";
4
4
  import { jsx } from "react/jsx-runtime";
5
5
  // src/retouche.tsx
6
- const Layer = process.env.NODE_ENV === "production" ? null : lazy(async () => await import("./layer-Ce6QQdAy.js"));
6
+ const Layer = process.env.NODE_ENV === "production" ? null : lazy(async () => await import("./layer-Bw5Xt2p7.js"));
7
7
  function subscribeToNothing() {
8
8
  return () => {};
9
9
  }
@@ -2729,6 +2729,7 @@ function stopClicksAtHost(host) {
2729
2729
  // src/client/fiber/react-fiber.ts
2730
2730
  const MEMO_TYPE = Symbol.for("react.memo");
2731
2731
  const FORWARD_REF_TYPE = Symbol.for("react.forward_ref");
2732
+ const ELEMENT_TYPES = /* @__PURE__ */ new Set([Symbol.for("react.transitional.element"), Symbol.for("react.element")]);
2732
2733
  const MAX_WRAPPER_DEPTH = 3;
2733
2734
  const MAX_CLONE_DEPTH = 3;
2734
2735
  const FIBER_KEY_PREFIXES = ["__reactFiber$", "__reactInternalInstance$"];
@@ -2826,8 +2827,11 @@ function hostElementsOf(fiber) {
2826
2827
  }
2827
2828
  return elements;
2828
2829
  }
2830
+ function isElement(value) {
2831
+ return isRecord(value) && !("then" in value && typeof value.then === "function") && "$$typeof" in value && ELEMENT_TYPES.has(value.$$typeof) && "type" in value && "key" in value && "props" in value;
2832
+ }
2829
2833
  function isPassedElement(value) {
2830
- return isRecord(value) && "type" in value && "_owner" in value && "props" in value && isProps(value.props);
2834
+ return isElement(value) && "_owner" in value && isProps(value.props);
2831
2835
  }
2832
2836
  function sameStyling(passed, rendered) {
2833
2837
  if (passed.className !== rendered.className) return false;
@@ -2860,14 +2864,10 @@ function writtenPlace(fiber) {
2860
2864
  };
2861
2865
  }
2862
2866
  // src/client/renders/record/app-values.ts
2863
- const ELEMENT_TYPES = /* @__PURE__ */ new Set([Symbol.for("react.transitional.element"), Symbol.for("react.element")]);
2864
2867
  const UNREADABLE = { kind: "object" };
2865
2868
  function isArrayValue(value) {
2866
2869
  return Array.isArray(value);
2867
2870
  }
2868
- function isElement(value) {
2869
- return isRecord(value) && "$$typeof" in value && ELEMENT_TYPES.has(value.$$typeof) && "type" in value && "key" in value && "props" in value;
2870
- }
2871
2871
  function isPlainObject(value) {
2872
2872
  if (!isRecord(value) || isElement(value)) return false;
2873
2873
  const prototype = Object.getPrototypeOf(value);
@@ -3231,7 +3231,7 @@ function renderReportOf(element) {
3231
3231
  };
3232
3232
  return tally.report;
3233
3233
  }
3234
- // src/client/fiber/strip-override.ts
3234
+ // src/client/fiber/strip/strip-override.ts
3235
3235
  const COMPUTED_PROPERTY = {
3236
3236
  "font-family": "font-family",
3237
3237
  "font-size": "font-size",
package/dist/next.js CHANGED
@@ -1,10 +1,17 @@
1
- import { a as withoutEnvFiles, t as createRouteHandler } from "./handler-BHcVQ8_D.js";
1
+ import { a as appEnvs, i as appEnvFolders, t as createRouteHandler } from "./handler-CoK5CtV4.js";
2
2
  // src/server/next.ts
3
3
  function createRoute(options = {}) {
4
4
  let handler = null;
5
5
  const serve = async (request) => {
6
6
  if (process.env.NODE_ENV !== "development") return new Response(null, { status: 404 });
7
- handler ??= createRouteHandler(options, withoutEnvFiles(process.env, options));
7
+ if (handler === null) {
8
+ const files = {
9
+ folders: appEnvFolders(options),
10
+ mode: "development"
11
+ };
12
+ const { env, spawnEnv } = appEnvs(process.env, files, options);
13
+ handler = createRouteHandler(options, env, spawnEnv);
14
+ }
8
15
  return await handler(request);
9
16
  };
10
17
  return {
package/dist/vite.js CHANGED
@@ -1,10 +1,10 @@
1
1
  import { d as ROUTE_BASE } from "./clock-BJi08VJS.js";
2
- import { i as withEnvFiles, n as BODY_LIMIT_ERROR, o as isLoopbackAddress, t as createRouteHandler } from "./handler-BHcVQ8_D.js";
3
- import { h as errorResponse } from "./follow-files-CfuW6Ah5.js";
2
+ import { a as appEnvs, n as BODY_LIMIT_ERROR, o as isLoopbackAddress, t as createRouteHandler } from "./handler-CoK5CtV4.js";
3
+ import { g as errorResponse, h as deferred } from "./follow-files-Dcya6bMQ.js";
4
4
  import { loadEnv } from "vite";
5
5
  // src/server/node-http.ts
6
6
  async function readBody(request) {
7
- const { promise, reject, resolve } = Promise.withResolvers();
7
+ const { promise, reject, resolve } = deferred();
8
8
  const chunks = [];
9
9
  let size = 0;
10
10
  const onData = (chunk) => {
@@ -80,10 +80,17 @@ function retouche(options = {}) {
80
80
  return {
81
81
  apply: "serve",
82
82
  configResolved(config) {
83
+ const { env, spawnEnv } = appEnvs({
84
+ ...process.env,
85
+ ...loadEnv(config.mode, config.envDir, "")
86
+ }, {
87
+ folders: config.envDir === false ? [] : [config.envDir],
88
+ mode: config.mode
89
+ }, options);
83
90
  handler = createRouteHandler({
84
91
  ...options,
85
92
  root: options.root ?? config.root
86
- }, withEnvFiles(loadEnv(config.mode, config.envDir, ""), options));
93
+ }, env, spawnEnv);
87
94
  },
88
95
  configureServer(server) {
89
96
  server.middlewares.use(ROUTE_BASE, (request, response, next) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "retouche-dev",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "Dots on every element whose call site overrides your design system's typography.",
5
5
  "keywords": [
6
6
  "design-system",
@@ -67,7 +67,7 @@
67
67
  "pack": "tsdown && bun pm pack --filename retouche.tgz --quiet",
68
68
  "prepublishOnly": "tsdown",
69
69
  "test": "vitest run",
70
- "typecheck": "tsc --noEmit"
70
+ "typecheck": "tsc --noEmit && tsc --noEmit -p tsconfig.server.json"
71
71
  },
72
72
  "dependencies": {
73
73
  "@agentclientprotocol/sdk": "^2.12.0",
@@ -101,5 +101,8 @@
101
101
  "vite": {
102
102
  "optional": true
103
103
  }
104
+ },
105
+ "engines": {
106
+ "node": ">=20.9"
104
107
  }
105
108
  }