tencil 0.7.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/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-BRcZL2Ov.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 {
@@ -95,6 +95,11 @@ interface BridgeOptions {
95
95
  root: string;
96
96
  };
97
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;
98
103
  log?: (message: string) => void;
99
104
  }
100
105
  /**
@@ -129,7 +134,8 @@ type Exec = (command: string, args: string[]) => Promise<string>;
129
134
  /**
130
135
  * Works out which project folder a page belongs to:
131
136
  * 1. what the user picked for this address before,
132
- * 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.
133
139
  * Returns undefined when neither works; the overlay then asks.
134
140
  */
135
141
  export declare class ProjectResolver {
@@ -139,10 +145,13 @@ export declare class ProjectResolver {
139
145
  exec?: Exec;
140
146
  platform?: NodeJS.Platform;
141
147
  });
142
- resolve(pageUrl: string): Promise<string | undefined>;
148
+ resolve(pageUrl: string, claimedRoot?: string): Promise<string | undefined>;
143
149
  /** Remember the user's choice for an address (from the overlay's project picker). */
144
150
  remember(pageUrl: string, root: string): Promise<void>;
145
- /** 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
+ */
146
155
  folderForPort(port: number): Promise<string | undefined>;
147
156
  }
148
157
  /** Closest folder with a package.json at or above `folder`, or `folder` itself. */
@@ -208,6 +217,39 @@ interface T3CodeProviderOptions {
208
217
  declare const PROVIDERS: readonly ["t3code", "claude-code"];
209
218
  type ProviderName = (typeof PROVIDERS)[number];
210
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
211
253
  //#region src/daemon/server.d.ts
212
254
  export declare const DEFAULT_PORT = 4747;
213
255
  interface DaemonOptions {
@@ -238,7 +280,7 @@ interface DaemonOptions {
238
280
  createProjectIfMissing?: boolean;
239
281
  };
240
282
  /** Overrides how pages map to projects (tests). */
241
- resolveProject?: (pageUrl: string) => Promise<string | undefined>;
283
+ resolveProject?: (pageUrl: string, root?: string) => Promise<string | undefined>;
242
284
  /** Overrides process lookups for the default resolver (tests). */
243
285
  exec?: Exec;
244
286
  /** Build a project's provider by id (tests). */
@@ -246,6 +288,10 @@ interface DaemonOptions {
246
288
  log?: (message: string) => void;
247
289
  /** The CLI flags this daemon runs with, reported on /health so a restart can keep them. */
248
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;
249
295
  }
250
296
  interface ProjectStatus {
251
297
  root: string;
@@ -258,6 +304,8 @@ interface Daemon {
258
304
  scriptUrl: string;
259
305
  port: number;
260
306
  projects(): ProjectStatus[];
307
+ /** Look for a new Tencil now instead of at the next daily check. */
308
+ checkForUpdates(): Promise<void>;
261
309
  close(): Promise<void>;
262
310
  }
263
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-1L4Fi2wN.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-jOobzTY9.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
  }