tencil 0.6.1 → 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/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { a as Thread, i as Viewer, n as ProviderOption, o as ElementContext, r as ServerMessage, t as Provider } from "./index-B0phpEz9.mjs";
1
+ import { a as Viewer, i as UpdateStatus, n as ProviderOption, o as Thread, r as ServerMessage, s as ElementContext, t as Provider } from "./index-C4SmNUQW.mjs";
2
2
  //#region ../bridge/src/project-providers.d.ts
3
3
  /** What a project picked in the overlay's settings. */
4
4
  interface SavedProjectSettings {
@@ -8,6 +8,8 @@ interface SavedProjectSettings {
8
8
  models?: Record<string, string>;
9
9
  /** Queue new comments and send them together; on when unset. */
10
10
  batch?: boolean;
11
+ /** Offer the ruler in the overlay's toolbar; on when unset. */
12
+ ruler?: boolean;
11
13
  }
12
14
  /**
13
15
  * Where a project's settings live: a file next to its pins for the daemon,
@@ -54,7 +56,9 @@ declare class ProjectProviders {
54
56
  setModel(id: string, model: string | null): Promise<void>;
55
57
  get batch(): boolean;
56
58
  setBatch(on: boolean): Promise<void>;
57
- /** Fires when a picked model or batching changes. */
59
+ get ruler(): boolean;
60
+ setRuler(on: boolean): Promise<void>;
61
+ /** Fires when a picked model, batching or the ruler changes. */
58
62
  onSettingsChange(listener: () => void): () => void;
59
63
  onDefaultChange(listener: () => void): () => void;
60
64
  dispose(): Promise<void>;
@@ -91,6 +95,11 @@ interface BridgeOptions {
91
95
  root: string;
92
96
  };
93
97
  version: string;
98
+ /**
99
+ * The host's own updates, sent in `ready`. The local daemon has them (and
100
+ * handles `update.start` itself); Tencil Cloud doesn't.
101
+ */
102
+ update?: () => UpdateStatus;
94
103
  log?: (message: string) => void;
95
104
  }
96
105
  /**
@@ -125,7 +134,8 @@ type Exec = (command: string, args: string[]) => Promise<string>;
125
134
  /**
126
135
  * Works out which project folder a page belongs to:
127
136
  * 1. what the user picked for this address before,
128
- * 2. the dev server's working directory, found from the port it listens on.
137
+ * 2. the repository root the Vite or Next loader sent, if it's a git checkout,
138
+ * 3. the dev server's working directory, found from the port it listens on.
129
139
  * Returns undefined when neither works; the overlay then asks.
130
140
  */
131
141
  export declare class ProjectResolver {
@@ -135,10 +145,13 @@ export declare class ProjectResolver {
135
145
  exec?: Exec;
136
146
  platform?: NodeJS.Platform;
137
147
  });
138
- resolve(pageUrl: string): Promise<string | undefined>;
148
+ resolve(pageUrl: string, claimedRoot?: string): Promise<string | undefined>;
139
149
  /** Remember the user's choice for an address (from the overlay's project picker). */
140
150
  remember(pageUrl: string, root: string): Promise<void>;
141
- /** Folder of the process listening on `port`: its working directory, or its script's package. */
151
+ /**
152
+ * Folder of the process listening on `port`: its working directory, or its script's
153
+ * package. When Docker publishes the port, the compose project of the container.
154
+ */
142
155
  folderForPort(port: number): Promise<string | undefined>;
143
156
  }
144
157
  /** Closest folder with a package.json at or above `folder`, or `folder` itself. */
@@ -204,6 +217,39 @@ interface T3CodeProviderOptions {
204
217
  declare const PROVIDERS: readonly ["t3code", "claude-code"];
205
218
  type ProviderName = (typeof PROVIDERS)[number];
206
219
  //#endregion
220
+ //#region src/service/self-update.d.ts
221
+ /** Installs a package spec into a folder, like `npm install --prefix dir spec`. */
222
+ type Installer = (spec: string, dir: string) => Promise<void>;
223
+ /** What the helper needs to move the daemon on `port` to the staged `version`. */
224
+ interface UpdatePlan {
225
+ version: string;
226
+ port: number;
227
+ dataDir: string;
228
+ node: string;
229
+ /** The running daemon's flags, kept by the new one. */
230
+ flags: string[];
231
+ /** The CLI the running daemon was started from, to go back to on failure. */
232
+ previousCli: string;
233
+ }
234
+ //#endregion
235
+ //#region src/daemon/updates.d.ts
236
+ interface UpdateOptions {
237
+ /** Ask the registry at all. Defaults to on, unless opted out (`updateChecksDisabled`). */
238
+ check?: boolean;
239
+ /** Registry base URL; defaults to `registryUrl()`. */
240
+ registry?: string;
241
+ /** Between checks; a failed one is retried sooner. Defaults to a day. */
242
+ intervalMs?: number;
243
+ /** Installs the new version (tests fake it); defaults to npm. */
244
+ install?: Installer;
245
+ /** Starts the helper that restarts the daemon (tests fake it). */
246
+ handOff?: (plan: UpdatePlan) => void;
247
+ /** How often to look again while threads are running. */
248
+ idlePollMs?: number;
249
+ /** How long to wait for the helper to replace this daemon before giving up. */
250
+ restartTimeoutMs?: number;
251
+ }
252
+ //#endregion
207
253
  //#region src/daemon/server.d.ts
208
254
  export declare const DEFAULT_PORT = 4747;
209
255
  interface DaemonOptions {
@@ -234,7 +280,7 @@ interface DaemonOptions {
234
280
  createProjectIfMissing?: boolean;
235
281
  };
236
282
  /** Overrides how pages map to projects (tests). */
237
- resolveProject?: (pageUrl: string) => Promise<string | undefined>;
283
+ resolveProject?: (pageUrl: string, root?: string) => Promise<string | undefined>;
238
284
  /** Overrides process lookups for the default resolver (tests). */
239
285
  exec?: Exec;
240
286
  /** Build a project's provider by id (tests). */
@@ -242,6 +288,10 @@ interface DaemonOptions {
242
288
  log?: (message: string) => void;
243
289
  /** The CLI flags this daemon runs with, reported on /health so a restart can keep them. */
244
290
  flags?: string[];
291
+ /** The CLI entry this daemon runs from; updating from the overlay needs it. */
292
+ cli?: string;
293
+ /** Update checks and the overlay's Update button (fakes in tests). */
294
+ updates?: UpdateOptions;
245
295
  }
246
296
  interface ProjectStatus {
247
297
  root: string;
@@ -254,6 +304,8 @@ interface Daemon {
254
304
  scriptUrl: string;
255
305
  port: number;
256
306
  projects(): ProjectStatus[];
307
+ /** Look for a new Tencil now instead of at the next daily check. */
308
+ checkForUpdates(): Promise<void>;
257
309
  close(): Promise<void>;
258
310
  }
259
311
  /**
package/dist/index.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import { C as renderPrompt, S as Bridge, b as ProjectResolver, d as projectStorePath, l as FileThreadStore, n as probeDaemon, r as startDaemon, t as DEFAULT_PORT, u as defaultDataDir, w as stripContext, x as projectRoot } from "./server-CbF3t-Cx.mjs";
1
+ import { C as projectStorePath, F as renderPrompt, I as stripContext, M as ProjectResolver, N as projectRoot, P as Bridge, S as defaultDataDir, n as probeDaemon, r as startDaemon, t as DEFAULT_PORT, x as FileThreadStore } from "./server-Cbvie3Om.mjs";
2
2
  export { Bridge, DEFAULT_PORT, ProjectResolver, FileThreadStore as ThreadStore, defaultDataDir, probeDaemon, projectRoot, projectStorePath, renderPrompt, startDaemon, stripContext };
@@ -5,11 +5,16 @@ const DEFAULT_DAEMON_PORT = 4747;
5
5
  * Browser code that loads the overlay from the daemon on the machine serving
6
6
  * the page: `localhost:4747` for a local dev server, `devbox:4747` for one
7
7
  * opened as http://devbox:3000. The daemon always speaks plain HTTP.
8
+ *
9
+ * `root` is the repository the dev server runs in; the daemon uses it to find
10
+ * the page's project when no Node process in that folder serves the page
11
+ * (Laravel on Sail or Herd, a backend behind a proxy).
8
12
  */
9
- function overlayLoader(port = DEFAULT_DAEMON_PORT) {
13
+ function overlayLoader(port = DEFAULT_DAEMON_PORT, root) {
14
+ const query = root ? `?root=${encodeURIComponent(root)}` : "";
10
15
  return `;(() => {
11
16
  if (typeof document === "undefined") return;
12
- const src = "http://" + location.hostname + ":${Number(port)}/tencil.js";
17
+ const src = "http://" + location.hostname + ":${Number(port)}/tencil.js${query}";
13
18
  if (document.querySelector('script[src="' + src + '"]')) return;
14
19
  const script = document.createElement("script");
15
20
  script.src = src;
package/dist/next.d.mts CHANGED
@@ -1,10 +1,13 @@
1
- import { t as TencilCloudOptions } from "./cloud-CIAGUsk2.mjs";
1
+ import { t as TencilCloudOptions } from "./cloud-DPNrsIER.mjs";
2
2
  //#region src/integrations/next.d.ts
3
3
  /**
4
4
  * Wrap `next.config` for Tencil Cloud preview builds: every element gets a
5
5
  * `data-tencil-src` attribute with its file and line, because production React
6
- * keeps no source info. Without TENCIL_CLOUD, in development and on production
7
- * deployments the config comes back untouched.
6
+ * keeps no source info. Without TENCIL_CLOUD, on production deployments the
7
+ * config comes back untouched.
8
+ *
9
+ * In development it hands `<Tencil />` the repository root (TENCIL_ROOT), so
10
+ * the daemon finds the project even when the page isn't served by Next itself.
8
11
  *
9
12
  * export default withTencil(nextConfig);
10
13
  */
package/dist/next.mjs CHANGED
@@ -1,16 +1,30 @@
1
1
  import { r as resolveCloudBuild } from "./cloud-CiwIrP1h.mjs";
2
+ import { n as repositoryRoot } from "./source-attributes-Cs2NvuxG.mjs";
2
3
  import { fileURLToPath } from "node:url";
3
4
  //#region src/integrations/next.ts
4
5
  /**
5
6
  * Wrap `next.config` for Tencil Cloud preview builds: every element gets a
6
7
  * `data-tencil-src` attribute with its file and line, because production React
7
- * keeps no source info. Without TENCIL_CLOUD, in development and on production
8
- * deployments the config comes back untouched.
8
+ * keeps no source info. Without TENCIL_CLOUD, on production deployments the
9
+ * config comes back untouched.
10
+ *
11
+ * In development it hands `<Tencil />` the repository root (TENCIL_ROOT), so
12
+ * the daemon finds the project even when the page isn't served by Next itself.
9
13
  *
10
14
  * export default withTencil(nextConfig);
11
15
  */
12
16
  function withTencil(config = {}, options = {}) {
13
- if (process.env.NODE_ENV === "development") return config;
17
+ if (process.env.NODE_ENV === "development") {
18
+ const parts = config;
19
+ const env = {
20
+ ...parts.env,
21
+ TENCIL_ROOT: repositoryRoot(process.cwd())
22
+ };
23
+ return {
24
+ ...parts,
25
+ env
26
+ };
27
+ }
14
28
  if (resolveCloudBuild(process.env, options.cloud).kind !== "on") return config;
15
29
  return addSourceLoader(config);
16
30
  }