tencil 0.0.0-stage → 0.3.1

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,561 @@
1
+ import { z } from "zod";
2
+ //#region ../protocol/src/context.d.ts
3
+ /**
4
+ * Everything the overlay knows about the picked element. Captured once when
5
+ * the pin is placed and forwarded to the agent as context.
6
+ */
7
+ declare const ElementContext: z.ZodObject<{
8
+ tagName: z.ZodString;
9
+ selector: z.ZodString;
10
+ html: z.ZodString;
11
+ text: z.ZodOptional<z.ZodString>;
12
+ components: z.ZodDefault<z.ZodArray<z.ZodObject<{
13
+ name: z.ZodString;
14
+ source: z.ZodOptional<z.ZodObject<{
15
+ file: z.ZodString;
16
+ line: z.ZodOptional<z.ZodNumber>;
17
+ column: z.ZodOptional<z.ZodNumber>;
18
+ }, z.core.$strip>>;
19
+ library: z.ZodOptional<z.ZodString>;
20
+ }, z.core.$strip>>>;
21
+ rect: z.ZodObject<{
22
+ x: z.ZodNumber;
23
+ y: z.ZodNumber;
24
+ width: z.ZodNumber;
25
+ height: z.ZodNumber;
26
+ }, z.core.$strip>;
27
+ viewport: z.ZodObject<{
28
+ width: z.ZodNumber;
29
+ height: z.ZodNumber;
30
+ dpr: z.ZodNumber;
31
+ }, z.core.$strip>;
32
+ selection: z.ZodOptional<z.ZodString>;
33
+ }, z.core.$strip>;
34
+ type ElementContext = z.infer<typeof ElementContext>;
35
+ declare const ImageAttachment: z.ZodObject<{
36
+ name: z.ZodString;
37
+ mimeType: z.ZodEnum<{
38
+ "image/png": "image/png";
39
+ "image/jpeg": "image/jpeg";
40
+ "image/webp": "image/webp";
41
+ }>;
42
+ dataUrl: z.ZodString;
43
+ }, z.core.$strip>;
44
+ type ImageAttachment = z.infer<typeof ImageAttachment>;
45
+ //#endregion
46
+ //#region ../protocol/src/thread.d.ts
47
+ /**
48
+ * Provider-agnostic run state.
49
+ * - `starting`: thread is being created on the provider
50
+ * - `working`: the agent is producing a turn
51
+ * - `waiting`: the agent needs approval/input inside the provider UI
52
+ * - `idle`: last turn finished, ready for a follow-up
53
+ * - `error`: last turn or the thread itself failed
54
+ */
55
+ declare const ThreadStatus: z.ZodEnum<{
56
+ starting: "starting";
57
+ working: "working";
58
+ waiting: "waiting";
59
+ idle: "idle";
60
+ error: "error";
61
+ }>;
62
+ type ThreadStatus = z.infer<typeof ThreadStatus>;
63
+ declare const MessageRole: z.ZodEnum<{
64
+ user: "user";
65
+ assistant: "assistant";
66
+ system: "system";
67
+ }>;
68
+ type MessageRole = z.infer<typeof MessageRole>;
69
+ /**
70
+ * A conversation Tencil tracks, backed by one provider thread. Owned and
71
+ * persisted by the bridge. Pinned threads sit on an element of a page;
72
+ * threads opened from the provider's list have no anchor and live in the dock.
73
+ * Several pins may continue the same provider thread.
74
+ */
75
+ declare const Thread: z.ZodObject<{
76
+ id: z.ZodString;
77
+ title: z.ZodString;
78
+ pageUrl: z.ZodOptional<z.ZodString>;
79
+ anchor: z.ZodOptional<z.ZodObject<{
80
+ selector: z.ZodString;
81
+ offsetX: z.ZodNumber;
82
+ offsetY: z.ZodNumber;
83
+ }, z.core.$strip>>;
84
+ context: z.ZodOptional<z.ZodObject<{
85
+ tagName: z.ZodString;
86
+ selector: z.ZodString;
87
+ html: z.ZodString;
88
+ text: z.ZodOptional<z.ZodString>;
89
+ components: z.ZodDefault<z.ZodArray<z.ZodObject<{
90
+ name: z.ZodString;
91
+ source: z.ZodOptional<z.ZodObject<{
92
+ file: z.ZodString;
93
+ line: z.ZodOptional<z.ZodNumber>;
94
+ column: z.ZodOptional<z.ZodNumber>;
95
+ }, z.core.$strip>>;
96
+ library: z.ZodOptional<z.ZodString>;
97
+ }, z.core.$strip>>>;
98
+ rect: z.ZodObject<{
99
+ x: z.ZodNumber;
100
+ y: z.ZodNumber;
101
+ width: z.ZodNumber;
102
+ height: z.ZodNumber;
103
+ }, z.core.$strip>;
104
+ viewport: z.ZodObject<{
105
+ width: z.ZodNumber;
106
+ height: z.ZodNumber;
107
+ dpr: z.ZodNumber;
108
+ }, z.core.$strip>;
109
+ selection: z.ZodOptional<z.ZodString>;
110
+ }, z.core.$strip>>;
111
+ status: z.ZodEnum<{
112
+ starting: "starting";
113
+ working: "working";
114
+ waiting: "waiting";
115
+ idle: "idle";
116
+ error: "error";
117
+ }>;
118
+ statusDetail: z.ZodOptional<z.ZodString>;
119
+ resolved: z.ZodDefault<z.ZodBoolean>;
120
+ messages: z.ZodArray<z.ZodObject<{
121
+ id: z.ZodString;
122
+ role: z.ZodEnum<{
123
+ user: "user";
124
+ assistant: "assistant";
125
+ system: "system";
126
+ }>;
127
+ text: z.ZodString;
128
+ streaming: z.ZodDefault<z.ZodBoolean>;
129
+ createdAt: z.ZodString;
130
+ }, z.core.$strip>>;
131
+ provider: z.ZodObject<{
132
+ id: z.ZodString;
133
+ threadId: z.ZodOptional<z.ZodString>;
134
+ url: z.ZodOptional<z.ZodString>;
135
+ }, z.core.$strip>;
136
+ createdAt: z.ZodString;
137
+ updatedAt: z.ZodString;
138
+ }, z.core.$strip>;
139
+ type Thread = z.infer<typeof Thread>;
140
+ /** A thread as listed by the provider (e.g. every T3 Code thread in the project). */
141
+ declare const ProviderThreadSummary: z.ZodObject<{
142
+ id: z.ZodString;
143
+ title: z.ZodString;
144
+ status: z.ZodEnum<{
145
+ working: "working";
146
+ waiting: "waiting";
147
+ idle: "idle";
148
+ error: "error";
149
+ }>;
150
+ updatedAt: z.ZodString;
151
+ url: z.ZodOptional<z.ZodString>;
152
+ branch: z.ZodOptional<z.ZodString>;
153
+ pullRequest: z.ZodOptional<z.ZodObject<{
154
+ number: z.ZodNumber;
155
+ url: z.ZodString;
156
+ }, z.core.$strip>>;
157
+ background: z.ZodOptional<z.ZodEnum<{
158
+ working: "working";
159
+ monitoring: "monitoring";
160
+ }>>;
161
+ agent: z.ZodOptional<z.ZodString>;
162
+ }, z.core.$strip>;
163
+ type ProviderThreadSummary = z.infer<typeof ProviderThreadSummary>;
164
+ /** How the provider presents the project the threads belong to. */
165
+ declare const ProviderProject: z.ZodObject<{
166
+ name: z.ZodString;
167
+ iconUrl: z.ZodOptional<z.ZodString>;
168
+ emoji: z.ZodOptional<z.ZodString>;
169
+ }, z.core.$strip>;
170
+ type ProviderProject = z.infer<typeof ProviderProject>;
171
+ //#endregion
172
+ //#region ../protocol/src/messages.d.ts
173
+ declare const PROTOCOL_VERSION = 1;
174
+ declare const ProviderInfo: z.ZodObject<{
175
+ id: z.ZodString;
176
+ label: z.ZodString;
177
+ state: z.ZodEnum<{
178
+ connecting: "connecting";
179
+ ready: "ready";
180
+ unauthorized: "unauthorized";
181
+ unavailable: "unavailable";
182
+ }>;
183
+ detail: z.ZodOptional<z.ZodString>;
184
+ target: z.ZodOptional<z.ZodString>;
185
+ canPair: z.ZodOptional<z.ZodBoolean>;
186
+ }, z.core.$strip>;
187
+ type ProviderInfo = z.infer<typeof ProviderInfo>;
188
+ /** A provider the project can send pins to. */
189
+ declare const ProviderOption: z.ZodObject<{
190
+ id: z.ZodString;
191
+ label: z.ZodString;
192
+ }, z.core.$strip>;
193
+ type ProviderOption = z.infer<typeof ProviderOption>;
194
+ /** Per-project settings, as the overlay shows them. */
195
+ declare const ProjectSettings: z.ZodObject<{
196
+ provider: z.ZodString;
197
+ providers: z.ZodArray<z.ZodObject<{
198
+ id: z.ZodString;
199
+ label: z.ZodString;
200
+ }, z.core.$strip>>;
201
+ }, z.core.$strip>;
202
+ type ProjectSettings = z.infer<typeof ProjectSettings>;
203
+ type ServerMessage = {
204
+ type: 'ready';
205
+ protocol: typeof PROTOCOL_VERSION;
206
+ version: string;
207
+ project: {
208
+ name: string;
209
+ root: string;
210
+ };
211
+ /** The provider new pins go to. */
212
+ provider: ProviderInfo;
213
+ settings: ProjectSettings;
214
+ threads: Thread[];
215
+ } | {
216
+ type: 'provider.status';
217
+ provider: ProviderInfo;
218
+ } | {
219
+ type: 'settings';
220
+ settings: ProjectSettings;
221
+ } |
222
+ /** The daemon couldn't tell which project this page belongs to; the overlay asks. */
223
+ {
224
+ type: 'project.unknown';
225
+ pageUrl: string;
226
+ choices: Array<{
227
+ root: string;
228
+ title: string;
229
+ }>;
230
+ /** What to do when there are no choices. */
231
+ emptyHint?: string;
232
+ } | {
233
+ type: 'thread.upsert';
234
+ thread: Thread;
235
+ } | {
236
+ type: 'thread.removed';
237
+ threadId: string;
238
+ } | {
239
+ type: 'provider.threads';
240
+ project: ProviderProject;
241
+ threads: ProviderThreadSummary[];
242
+ } | {
243
+ type: 'error';
244
+ message: string;
245
+ threadId?: string;
246
+ };
247
+ //#endregion
248
+ //#region ../protocol/src/provider.d.ts
249
+ /**
250
+ * A provider is the agent backend a pin is delegated to (T3 Code, Claude Code,
251
+ * …). The bridge owns pins and talks to exactly one provider per process; the
252
+ * provider owns the conversation.
253
+ *
254
+ * Providers only ever see plain text + images: the bridge renders element
255
+ * context into the prompt so every provider gets identical input.
256
+ */
257
+ interface Provider {
258
+ readonly id: string;
259
+ readonly label: string;
260
+ /** Connect/authenticate. Must not throw; report problems through `info()`. */
261
+ start(): Promise<void>;
262
+ info(): ProviderInfo;
263
+ onInfoChange(listener: (info: ProviderInfo) => void): () => void;
264
+ /** Authorize against the provider (e.g. pair with T3 Code). Optional. */
265
+ pair?(): Promise<void>;
266
+ /** Threads that already exist for this project, newest first. */
267
+ listThreads(): Promise<{
268
+ project: ProviderProject;
269
+ threads: ProviderThreadSummary[];
270
+ }>;
271
+ /** Deep link into the provider UI for a thread, when it has one. */
272
+ threadUrl(providerThreadId: string): string | undefined;
273
+ createThread(input: CreateThreadInput): Promise<CreatedThread>;
274
+ sendMessage(input: SendMessageInput): Promise<void>;
275
+ interrupt(providerThreadId: string): Promise<void>;
276
+ /**
277
+ * Stream updates for a thread. Called right after `createThread` and again
278
+ * for every persisted thread when the bridge restarts. The provider should
279
+ * replay current state first, then live updates.
280
+ */
281
+ watch(providerThreadId: string, sink: ThreadSink): () => void;
282
+ dispose(): Promise<void>;
283
+ }
284
+ interface CreateThreadInput {
285
+ title: string;
286
+ text: string;
287
+ attachments: ImageAttachment[];
288
+ }
289
+ interface CreatedThread {
290
+ providerThreadId: string;
291
+ url?: string;
292
+ }
293
+ interface SendMessageInput {
294
+ providerThreadId: string;
295
+ text: string;
296
+ attachments: ImageAttachment[];
297
+ }
298
+ interface ProviderMessage {
299
+ id: string;
300
+ role: MessageRole;
301
+ text: string;
302
+ streaming: boolean;
303
+ createdAt: string;
304
+ }
305
+ interface ThreadSink {
306
+ /** Upsert by `id`; `text` is cumulative. */
307
+ message(message: ProviderMessage): void;
308
+ status(status: Exclude<ThreadStatus, 'starting'>, detail?: string): void;
309
+ /** Provider no longer has this thread (deleted/archived on its side). */
310
+ gone(): void;
311
+ }
312
+ //#endregion
313
+ //#region src/daemon/project-providers.d.ts
314
+ interface ProjectProvidersOptions {
315
+ /** Providers the project can pick from. */
316
+ choices: ProviderOption[];
317
+ /** Used until the project picks one: the daemon's `--provider`. */
318
+ fallback: string;
319
+ create: (id: string) => Provider;
320
+ /** Where the project's choice is saved; in memory only when absent. */
321
+ settingsPath?: string;
322
+ }
323
+ /**
324
+ * The providers of one project. New pins go to the project's default, which
325
+ * the overlay's settings change; existing pins keep the provider they were
326
+ * made with. Providers are created and started on first use.
327
+ */
328
+ declare class ProjectProviders {
329
+ #private;
330
+ readonly choices: ProviderOption[];
331
+ constructor(options: ProjectProvidersOptions);
332
+ /** One fixed provider and no settings file (tests). */
333
+ static of(provider: Provider): ProjectProviders;
334
+ load(): Promise<void>;
335
+ get defaultId(): string;
336
+ default(): Provider;
337
+ /** Can pins of this provider be served (a choice, or one already running)? */
338
+ has(id: string): boolean;
339
+ get(id: string): Provider;
340
+ setDefault(id: string): Promise<void>;
341
+ onDefaultChange(listener: () => void): () => void;
342
+ dispose(): Promise<void>;
343
+ }
344
+ //#endregion
345
+ //#region src/daemon/thread-store.d.ts
346
+ /** Where Tencil keeps per-machine state, shared by every project. */
347
+ export declare function defaultDataDir(): string;
348
+ /**
349
+ * One file per project under the global data dir, named after the folder plus
350
+ * a hash of its path: readable when browsing, unique per checkout, and never
351
+ * shared between two bridges.
352
+ */
353
+ export declare function projectStorePath(projectRoot: string, dataDir?: string): string;
354
+ /**
355
+ * Pins for one project, persisted outside the repo so they survive bridge
356
+ * restarts without leaving files in the project. Writes are debounced and atomic.
357
+ */
358
+ export declare class ThreadStore {
359
+ #private;
360
+ readonly path: string;
361
+ constructor(projectRoot: string, dataDir?: string);
362
+ load(): Promise<void>;
363
+ list(): Thread[];
364
+ get(id: string): Thread | undefined;
365
+ findByProviderThread(providerId: string, providerThreadId: string): Thread | undefined;
366
+ upsert(thread: Thread): void;
367
+ delete(id: string): boolean;
368
+ flush(): Promise<void>;
369
+ }
370
+ //#endregion
371
+ //#region src/daemon/bridge.d.ts
372
+ interface BridgeClient {
373
+ send(message: ServerMessage): void;
374
+ }
375
+ interface BridgeOptions {
376
+ providers: ProjectProviders;
377
+ store: ThreadStore;
378
+ project: {
379
+ name: string;
380
+ root: string;
381
+ };
382
+ version: string;
383
+ log?: (message: string) => void;
384
+ }
385
+ /**
386
+ * Owns pins and fans provider updates out to every connected overlay. One
387
+ * bridge serves one project; any number of tabs may be connected.
388
+ */
389
+ export declare class Bridge {
390
+ #private;
391
+ constructor(options: BridgeOptions);
392
+ connect(client: BridgeClient): () => void;
393
+ handle(client: BridgeClient, raw: unknown): Promise<void>;
394
+ dispose(): Promise<void>;
395
+ }
396
+ //#endregion
397
+ //#region src/daemon/project-resolver.d.ts
398
+ /** Runs a command and returns stdout; injectable so tests don't depend on the OS. */
399
+ type Exec = (command: string, args: string[]) => Promise<string>;
400
+ /**
401
+ * Works out which project folder a page belongs to:
402
+ * 1. what the user picked for this address before,
403
+ * 2. the dev server's working directory, found from the port it listens on.
404
+ * Returns undefined when neither works; the overlay then asks.
405
+ */
406
+ export declare class ProjectResolver {
407
+ #private;
408
+ constructor(options: {
409
+ dataDir: string;
410
+ exec?: Exec;
411
+ platform?: NodeJS.Platform;
412
+ });
413
+ resolve(pageUrl: string): Promise<string | undefined>;
414
+ /** Remember the user's choice for an address (from the overlay's project picker). */
415
+ remember(pageUrl: string, root: string): Promise<void>;
416
+ /** Folder of the process listening on `port`: its working directory, or its script's package. */
417
+ folderForPort(port: number): Promise<string | undefined>;
418
+ }
419
+ /** Closest folder with a package.json at or above `folder`, or `folder` itself. */
420
+ export declare function projectRoot(folder: string): string;
421
+ //#endregion
422
+ //#region src/daemon/prompt.d.ts
423
+ /**
424
+ * Renders the text sent to the agent: the user's words first, then a fenced
425
+ * block of element context. The block is stripped again before messages are
426
+ * shown in the overlay (`stripContext`).
427
+ */
428
+ export declare function renderPrompt(input: {
429
+ prompt: string;
430
+ pageUrl: string;
431
+ context: ElementContext;
432
+ hasScreenshot: boolean;
433
+ }): string;
434
+ export declare function stripContext(text: string): string;
435
+ //#endregion
436
+ //#region ../provider-claude-code/src/claude-code-provider.d.ts
437
+ /** The permission modes that work without anyone at a terminal to answer prompts. */
438
+ type PermissionMode = 'default' | 'acceptEdits' | 'auto' | 'bypassPermissions';
439
+ //#endregion
440
+ //#region ../provider-t3code/src/auth.d.ts
441
+ interface StoredCredential {
442
+ token: string;
443
+ scope: string;
444
+ expiresAt: string;
445
+ }
446
+ /** Credentials live outside the project so they never end up in git. */
447
+ declare class CredentialStore {
448
+ #private;
449
+ readonly path: string;
450
+ constructor(path?: string);
451
+ get(baseUrl: string): Promise<StoredCredential | undefined>;
452
+ lastBaseUrl(): Promise<string | undefined>;
453
+ set(baseUrl: string, credential: StoredCredential): Promise<void>;
454
+ }
455
+ //#endregion
456
+ //#region ../provider-t3code/src/protocols/adapter.d.ts
457
+ type RuntimeMode = 'approval-required' | 'auto-accept-edits' | 'auto' | 'full-access';
458
+ interface ModelSelection {
459
+ instanceId: string;
460
+ model: string;
461
+ }
462
+ //#endregion
463
+ //#region ../provider-t3code/src/t3code-provider.d.ts
464
+ interface T3CodeProviderOptions {
465
+ /** Directory the dev site lives in; mapped to a T3 Code project by workspace root. */
466
+ projectRoot: string;
467
+ /** Defaults to the server `tencil connect` paired with last, then localhost:3773. */
468
+ baseUrl?: string;
469
+ /** Explicit bearer token. Defaults to the one stored by `tencil connect`. */
470
+ token?: string;
471
+ credentials?: CredentialStore;
472
+ modelSelection?: ModelSelection;
473
+ runtimeMode?: RuntimeMode;
474
+ interactionMode?: 'default' | 'plan';
475
+ /** Register `projectRoot` as a T3 Code project when no project matches. */
476
+ createProjectIfMissing?: boolean;
477
+ /** Pair with a local T3 Code on its own when no token is stored. Defaults to true. */
478
+ autoPair?: boolean;
479
+ /** Mints a pairing code. Defaults to running the `t3` CLI matching the server version. */
480
+ createPairingCode?: (baseUrl: string) => Promise<string | undefined>;
481
+ timeouts?: {
482
+ httpMs?: number;
483
+ rpcMs?: number;
484
+ retryMinMs?: number;
485
+ retryMaxMs?: number;
486
+ };
487
+ log?: (message: string) => void;
488
+ }
489
+ //#endregion
490
+ //#region src/daemon/agents.d.ts
491
+ declare const PROVIDERS: readonly ["t3code", "claude-code"];
492
+ type ProviderName = (typeof PROVIDERS)[number];
493
+ //#endregion
494
+ //#region src/daemon/server.d.ts
495
+ export declare const DEFAULT_PORT = 4747;
496
+ interface DaemonOptions {
497
+ port?: number;
498
+ /** Main address; status checks and local tools use it. Defaults to 127.0.0.1. */
499
+ host?: string;
500
+ /** Extra addresses to listen on, e.g. a Tailscale IP for a remote browser. */
501
+ listen?: string[];
502
+ /** Extra origins allowed to connect, besides loopback ones. */
503
+ allowedOrigins?: string[];
504
+ /** Pins, credentials and remembered projects; defaults to ~/.config/tencil. */
505
+ dataDir?: string;
506
+ /**
507
+ * The agent of projects that haven't picked one in their settings. Defaults
508
+ * to the machine's choice (`tencil setup`), else the agent found on it.
509
+ */
510
+ provider?: ProviderName;
511
+ claudeCode?: {
512
+ model?: string;
513
+ permissionMode?: PermissionMode;
514
+ };
515
+ t3?: Pick<T3CodeProviderOptions, 'autoPair' | 'createPairingCode' | 'timeouts'> & {
516
+ url?: string;
517
+ token?: string;
518
+ credentials?: CredentialStore;
519
+ modelSelection?: ModelSelection;
520
+ runtimeMode?: RuntimeMode;
521
+ createProjectIfMissing?: boolean;
522
+ };
523
+ /** Overrides how pages map to projects (tests). */
524
+ resolveProject?: (pageUrl: string) => Promise<string | undefined>;
525
+ /** Overrides process lookups for the default resolver (tests). */
526
+ exec?: Exec;
527
+ /** Build a project's provider by id (tests). */
528
+ createProvider?: (root: string, id: string) => Provider;
529
+ log?: (message: string) => void;
530
+ /** The CLI flags this daemon runs with, reported on /health so a restart can keep them. */
531
+ flags?: string[];
532
+ }
533
+ interface ProjectStatus {
534
+ root: string;
535
+ name: string;
536
+ clients: number;
537
+ provider: ReturnType<Provider['info']>;
538
+ }
539
+ interface Daemon {
540
+ url: string;
541
+ scriptUrl: string;
542
+ port: number;
543
+ projects(): ProjectStatus[];
544
+ close(): Promise<void>;
545
+ }
546
+ /**
547
+ * One Tencil daemon per machine. Pages load `/tencil.js` from it; each
548
+ * page's WebSocket is attached to the project it belongs to (worked out from
549
+ * the dev server's port, or picked by the user), and every project gets its
550
+ * own bridge, provider connection and pin store, created on first use.
551
+ */
552
+ export declare function startDaemon(options?: DaemonOptions): Promise<Daemon>;
553
+ /** Is a Tencil daemon answering on this port? Returns its health report. */
554
+ export declare function probeDaemon(port?: number, host?: string): Promise<{
555
+ version: string;
556
+ pid: number;
557
+ flags: string[];
558
+ projects: ProjectStatus[];
559
+ } | undefined>;
560
+ //#endregion
561
+ export type { Daemon, DaemonOptions, ProjectStatus };
package/dist/index.mjs ADDED
@@ -0,0 +1,2 @@
1
+ import { C as renderPrompt, S as Bridge, b as ProjectResolver, d as projectStorePath, l as ThreadStore, n as probeDaemon, r as startDaemon, t as DEFAULT_PORT, u as defaultDataDir, w as stripContext, x as projectRoot } from "./server-PYBcw-eR.mjs";
2
+ export { Bridge, DEFAULT_PORT, ProjectResolver, ThreadStore, defaultDataDir, probeDaemon, projectRoot, projectStorePath, renderPrompt, startDaemon, stripContext };
@@ -0,0 +1,21 @@
1
+ //#region src/integrations/loader.ts
2
+ /** Port of the Tencil daemon unless configured otherwise. */
3
+ const DEFAULT_DAEMON_PORT = 4747;
4
+ /**
5
+ * Browser code that loads the overlay from the daemon on the machine serving
6
+ * the page: `localhost:4747` for a local dev server, `devbox:4747` for one
7
+ * opened as http://devbox:3000. The daemon always speaks plain HTTP.
8
+ */
9
+ function overlayLoader(port = DEFAULT_DAEMON_PORT) {
10
+ return `;(() => {
11
+ if (typeof document === "undefined") return;
12
+ const src = "http://" + location.hostname + ":${Number(port)}/tencil.js";
13
+ if (document.querySelector('script[src="' + src + '"]')) return;
14
+ const script = document.createElement("script");
15
+ script.src = src;
16
+ script.async = true;
17
+ document.head.appendChild(script);
18
+ })();`;
19
+ }
20
+ //#endregion
21
+ export { overlayLoader as n, DEFAULT_DAEMON_PORT as t };