@telepath-computer/television 0.1.26 → 0.1.28

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/electron.cjs CHANGED
@@ -56473,7 +56473,7 @@ var require_websocket_server = __commonJS({
56473
56473
  }
56474
56474
  });
56475
56475
 
56476
- // src/electron/index.ts
56476
+ // packages/desktop/src/index.ts
56477
56477
  var index_exports = {};
56478
56478
  __export(index_exports, {
56479
56479
  App: () => App,
@@ -56483,41 +56483,7 @@ module.exports = __toCommonJS(index_exports);
56483
56483
  var import_electron = require("electron");
56484
56484
  var import_node_path10 = __toESM(require("node:path"), 1);
56485
56485
 
56486
- // src/config.ts
56487
- var import_node_os = __toESM(require("node:os"), 1);
56488
- var import_node_path = __toESM(require("node:path"), 1);
56489
- var TRUE_ENV_VALUE = "true";
56490
- var APP_HIDDEN_DIRECTORY = ".television";
56491
- var TELEVISION_DATA_DIR_ENV = "TELEVISION_DATA_DIR";
56492
- var TELEVISION_PORT_ENV = "TELEVISION_PORT";
56493
- var DEFAULT_SERVER_HOST = "localhost";
56494
- var DEFAULT_SERVER_PORT = 32848;
56495
- var DEFAULT_SERVER_URL = buildServerURL(DEFAULT_SERVER_HOST, DEFAULT_SERVER_PORT);
56496
- function buildServerURL(host, port) {
56497
- return `http://${host}:${port}`;
56498
- }
56499
- function getTelevisionDataDir() {
56500
- return process.env[TELEVISION_DATA_DIR_ENV] ?? import_node_path.default.join(import_node_os.default.homedir(), APP_HIDDEN_DIRECTORY);
56501
- }
56502
- function getTelevisionRendererUrlEnv() {
56503
- return process.env.TELEVISION_RENDERER_URL;
56504
- }
56505
- function getTelevisionPortEnv() {
56506
- const rawPort = process.env[TELEVISION_PORT_ENV];
56507
- if (!rawPort) {
56508
- return void 0;
56509
- }
56510
- const port = Number.parseInt(rawPort, 10);
56511
- return Number.isInteger(port) ? port : void 0;
56512
- }
56513
- function isVitestRuntime() {
56514
- return process.env.VITEST === TRUE_ENV_VALUE;
56515
- }
56516
- function isDevMode() {
56517
- return process.env.NODE_ENV !== "production";
56518
- }
56519
-
56520
- // src/server/server.ts
56486
+ // packages/server/src/server.ts
56521
56487
  var import_express2 = __toESM(require_express2(), 1);
56522
56488
 
56523
56489
  // node_modules/@telepath-computer/tool-router/dist/index.js
@@ -78803,7 +78769,7 @@ function createAPIRouter(options) {
78803
78769
  return router;
78804
78770
  }
78805
78771
 
78806
- // src/server/server.ts
78772
+ // packages/server/src/server.ts
78807
78773
  var import_node_http = __toESM(require("node:http"), 1);
78808
78774
 
78809
78775
  // node_modules/ws/wrapper.mjs
@@ -78816,15 +78782,15 @@ var import_subprotocol = __toESM(require_subprotocol(), 1);
78816
78782
  var import_websocket = __toESM(require_websocket(), 1);
78817
78783
  var import_websocket_server = __toESM(require_websocket_server(), 1);
78818
78784
 
78819
- // src/server/acp-bridge.ts
78785
+ // packages/server/src/acp-bridge.ts
78820
78786
  var import_node_child_process = require("node:child_process");
78821
78787
  var import_promises = require("node:fs/promises");
78822
- var import_node_os2 = require("node:os");
78823
- var import_node_path2 = __toESM(require("node:path"), 1);
78788
+ var import_node_os = require("node:os");
78789
+ var import_node_path = __toESM(require("node:path"), 1);
78824
78790
  var ACP_COMMAND = "openclaw";
78825
78791
  var ACP_ARGS = ["acp"];
78826
78792
  var ACP_STOP_TIMEOUT_MS = 5e3;
78827
- var ACP_STUB_CWD = import_node_path2.default.join((0, import_node_os2.homedir)(), ".television", "acp");
78793
+ var ACP_STUB_CWD = import_node_path.default.join((0, import_node_os.homedir)(), ".television", "acp");
78828
78794
  var ACPBridge = class {
78829
78795
  child = null;
78830
78796
  status = "exited";
@@ -78954,84 +78920,6 @@ var ACPBridge = class {
78954
78920
  }
78955
78921
  };
78956
78922
 
78957
- // src/acp-bridge-types.ts
78958
- function isACPBridgeClientMessage(value) {
78959
- if (typeof value !== "object" || value === null || !("type" in value)) {
78960
- return false;
78961
- }
78962
- const message = value;
78963
- switch (message.type) {
78964
- case "acp-bridge-connect":
78965
- return true;
78966
- case "acp-bridge-message":
78967
- return "message" in message;
78968
- default:
78969
- return false;
78970
- }
78971
- }
78972
-
78973
- // node_modules/@rupertsworld/event-target/dist/index.js
78974
- var RESERVED_EVENT_KEYS = /* @__PURE__ */ new Set([
78975
- "target",
78976
- "currentTarget",
78977
- "eventPhase",
78978
- "defaultPrevented",
78979
- "isTrusted",
78980
- "timeStamp",
78981
- "srcElement",
78982
- "returnValue",
78983
- "cancelBubble",
78984
- "NONE",
78985
- "CAPTURING_PHASE",
78986
- "AT_TARGET",
78987
- "BUBBLING_PHASE",
78988
- "composedPath",
78989
- "stopPropagation",
78990
- "stopImmediatePropagation",
78991
- "preventDefault",
78992
- "initEvent"
78993
- ]);
78994
- function assertNoReservedPayloadKeys(props) {
78995
- for (const key of Object.keys(props)) {
78996
- if (RESERVED_EVENT_KEYS.has(key)) {
78997
- throw new Error(`Event payload key "${key}" is reserved; choose a different property name`);
78998
- }
78999
- }
79000
- }
79001
- function assignPayload(target, props) {
79002
- assertNoReservedPayloadKeys(props);
79003
- for (const key of Object.keys(props)) {
79004
- Object.defineProperty(target, key, {
79005
- value: props[key],
79006
- writable: true,
79007
- enumerable: true,
79008
- configurable: true
79009
- });
79010
- }
79011
- }
79012
- function defineEvent() {
79013
- class DefinedEvent extends Event {
79014
- constructor(type, init) {
79015
- const { type: initType, bubbles, cancelable, composed, ...payload } = init ?? {};
79016
- if (initType !== void 0) {
79017
- throw new Error(`Do not pass "type" in init; use the constructor argument instead`);
79018
- }
79019
- super(type, { bubbles, cancelable, composed });
79020
- assignPayload(this, payload);
79021
- }
79022
- }
79023
- return DefinedEvent;
79024
- }
79025
- var EventTarget = class extends globalThis.EventTarget {
79026
- };
79027
-
79028
- // src/events.ts
79029
- var ChangeEvent = defineEvent();
79030
- var ServerMessageEvent = defineEvent();
79031
- var LayoutMutationEvent = defineEvent();
79032
- var LayoutScrollEvent = defineEvent();
79033
- var StoreChangeEvent = defineEvent();
79034
-
79035
78923
  // node_modules/ulid/dist/node/index.js
79036
78924
  var import_node_crypto = __toESM(require("node:crypto"), 1);
79037
78925
  var ENCODING = "0123456789ABCDEFGHJKMNPQRSTVWXYZ";
@@ -79127,10 +79015,7 @@ function ulid3(seedTime, prng) {
79127
79015
  return encodeTime(seed, TIME_LEN) + encodeRandom(RANDOM_LEN, currentPRNG);
79128
79016
  }
79129
79017
 
79130
- // src/server/server-store.ts
79131
- var import_node_crypto2 = require("node:crypto");
79132
-
79133
- // src/artifacts.ts
79018
+ // packages/shared/src/artifacts.ts
79134
79019
  var ValidationError = class extends Error {
79135
79020
  constructor(message) {
79136
79021
  super(message);
@@ -79195,11 +79080,7 @@ function wrapArtifactHTML(input) {
79195
79080
  </html>`;
79196
79081
  }
79197
79082
 
79198
- // src/server/server-store.ts
79199
- var import_node_fs = require("node:fs");
79200
- var import_node_path3 = __toESM(require("node:path"), 1);
79201
-
79202
- // src/constants.ts
79083
+ // packages/layout/src/constants.ts
79203
79084
  var LAYOUT_FULL_WIDTH_UNITS = 4;
79204
79085
  var LAYOUT_FULL_HEIGHT_UNITS = 6;
79205
79086
  var MIN_LAYOUT_CARD_WIDTH_UNITS = 2;
@@ -79211,44 +79092,7 @@ var CARD_GAP = 16;
79211
79092
  var CARD_WIDTH = DEFAULT_LAYOUT_UNIT * LAYOUT_FULL_WIDTH_UNITS + CARD_GAP * (LAYOUT_FULL_WIDTH_UNITS - 1);
79212
79093
  var CARD_HEIGHT = DEFAULT_LAYOUT_UNIT * LAYOUT_FULL_HEIGHT_UNITS + CARD_GAP * (LAYOUT_FULL_HEIGHT_UNITS - 1);
79213
79094
 
79214
- // src/types.ts
79215
- function createCardNode(artifactID, overrides = {}) {
79216
- return {
79217
- id: overrides.id ?? ulid3(),
79218
- type: "card",
79219
- artifactID,
79220
- width: overrides.width ?? DEFAULT_LAYOUT_CARD_WIDTH,
79221
- height: overrides.height ?? DEFAULT_LAYOUT_CARD_HEIGHT
79222
- };
79223
- }
79224
- function layoutContainsArtifactID(layout, artifactID) {
79225
- return layout.some((node) => nodeContainsArtifactID(node, artifactID));
79226
- }
79227
- function nodeContainsArtifactID(node, artifactID) {
79228
- switch (node.type) {
79229
- case "card":
79230
- return node.artifactID === artifactID;
79231
- case "row":
79232
- return node.children.some((child) => child.artifactID === artifactID);
79233
- case "stack":
79234
- return node.children.some((child) => nodeContainsArtifactID(child, artifactID));
79235
- }
79236
- }
79237
- function getWorkspaceArtifactIDs(workspace) {
79238
- return workspace.layout.flatMap(collectArtifactIDs);
79239
- }
79240
- function collectArtifactIDs(node) {
79241
- switch (node.type) {
79242
- case "card":
79243
- return [node.artifactID];
79244
- case "row":
79245
- return node.children.map((child) => child.artifactID);
79246
- case "stack":
79247
- return node.children.flatMap(collectArtifactIDs);
79248
- }
79249
- }
79250
-
79251
- // src/layout/layout.ts
79095
+ // packages/layout/src/layout.ts
79252
79096
  var LEGACY_BAND_HEIGHT_ROWS = 6;
79253
79097
  var LEGACY_NARROW_COLS = 1;
79254
79098
  var LEGACY_FULL_COLS = 2;
@@ -79519,7 +79363,125 @@ function cloneStackChild(node) {
79519
79363
  };
79520
79364
  }
79521
79365
 
79522
- // src/server/server-store.ts
79366
+ // packages/shared/src/types.ts
79367
+ function createCardNode(artifactID, overrides = {}) {
79368
+ return {
79369
+ id: overrides.id ?? ulid3(),
79370
+ type: "card",
79371
+ artifactID,
79372
+ width: overrides.width ?? DEFAULT_LAYOUT_CARD_WIDTH,
79373
+ height: overrides.height ?? DEFAULT_LAYOUT_CARD_HEIGHT
79374
+ };
79375
+ }
79376
+ function layoutContainsArtifactID(layout, artifactID) {
79377
+ return layout.some((node) => nodeContainsArtifactID(node, artifactID));
79378
+ }
79379
+ function nodeContainsArtifactID(node, artifactID) {
79380
+ switch (node.type) {
79381
+ case "card":
79382
+ return node.artifactID === artifactID;
79383
+ case "row":
79384
+ return node.children.some((child) => child.artifactID === artifactID);
79385
+ case "stack":
79386
+ return node.children.some((child) => nodeContainsArtifactID(child, artifactID));
79387
+ }
79388
+ }
79389
+ function getWorkspaceArtifactIDs(workspace) {
79390
+ return workspace.layout.flatMap(collectArtifactIDs);
79391
+ }
79392
+ function collectArtifactIDs(node) {
79393
+ switch (node.type) {
79394
+ case "card":
79395
+ return [node.artifactID];
79396
+ case "row":
79397
+ return node.children.map((child) => child.artifactID);
79398
+ case "stack":
79399
+ return node.children.flatMap(collectArtifactIDs);
79400
+ }
79401
+ }
79402
+
79403
+ // node_modules/@rupertsworld/event-target/dist/index.js
79404
+ var RESERVED_EVENT_KEYS = /* @__PURE__ */ new Set([
79405
+ "target",
79406
+ "currentTarget",
79407
+ "eventPhase",
79408
+ "defaultPrevented",
79409
+ "isTrusted",
79410
+ "timeStamp",
79411
+ "srcElement",
79412
+ "returnValue",
79413
+ "cancelBubble",
79414
+ "NONE",
79415
+ "CAPTURING_PHASE",
79416
+ "AT_TARGET",
79417
+ "BUBBLING_PHASE",
79418
+ "composedPath",
79419
+ "stopPropagation",
79420
+ "stopImmediatePropagation",
79421
+ "preventDefault",
79422
+ "initEvent"
79423
+ ]);
79424
+ function assertNoReservedPayloadKeys(props) {
79425
+ for (const key of Object.keys(props)) {
79426
+ if (RESERVED_EVENT_KEYS.has(key)) {
79427
+ throw new Error(`Event payload key "${key}" is reserved; choose a different property name`);
79428
+ }
79429
+ }
79430
+ }
79431
+ function assignPayload(target, props) {
79432
+ assertNoReservedPayloadKeys(props);
79433
+ for (const key of Object.keys(props)) {
79434
+ Object.defineProperty(target, key, {
79435
+ value: props[key],
79436
+ writable: true,
79437
+ enumerable: true,
79438
+ configurable: true
79439
+ });
79440
+ }
79441
+ }
79442
+ function defineEvent() {
79443
+ class DefinedEvent extends Event {
79444
+ constructor(type, init) {
79445
+ const { type: initType, bubbles, cancelable, composed, ...payload } = init ?? {};
79446
+ if (initType !== void 0) {
79447
+ throw new Error(`Do not pass "type" in init; use the constructor argument instead`);
79448
+ }
79449
+ super(type, { bubbles, cancelable, composed });
79450
+ assignPayload(this, payload);
79451
+ }
79452
+ }
79453
+ return DefinedEvent;
79454
+ }
79455
+ var EventTarget = class extends globalThis.EventTarget {
79456
+ };
79457
+
79458
+ // packages/shared/src/events.ts
79459
+ var ChangeEvent = defineEvent();
79460
+ var ServerMessageEvent = defineEvent();
79461
+ var LayoutMutationEvent = defineEvent();
79462
+ var LayoutScrollEvent = defineEvent();
79463
+ var StoreChangeEvent = defineEvent();
79464
+
79465
+ // packages/shared/src/acp-bridge-types.ts
79466
+ function isACPBridgeClientMessage(value) {
79467
+ if (typeof value !== "object" || value === null || !("type" in value)) {
79468
+ return false;
79469
+ }
79470
+ const message = value;
79471
+ switch (message.type) {
79472
+ case "acp-bridge-connect":
79473
+ return true;
79474
+ case "acp-bridge-message":
79475
+ return "message" in message;
79476
+ default:
79477
+ return false;
79478
+ }
79479
+ }
79480
+
79481
+ // packages/server/src/server-store.ts
79482
+ var import_node_crypto2 = require("node:crypto");
79483
+ var import_node_fs = require("node:fs");
79484
+ var import_node_path2 = __toESM(require("node:path"), 1);
79523
79485
  var JSON_INDENT_SPACES = 2;
79524
79486
  var AUTH_TOKEN_BYTES = 32;
79525
79487
  var DEFAULT_COLS = 2;
@@ -79767,7 +79729,7 @@ var ServerStore = class extends EventTarget {
79767
79729
  }
79768
79730
  load() {
79769
79731
  for (const file2 of this.readEntityFiles(this.workspacesDir)) {
79770
- const filePath = import_node_path3.default.join(this.workspacesDir, file2);
79732
+ const filePath = import_node_path2.default.join(this.workspacesDir, file2);
79771
79733
  const raw = this.readJsonFile(filePath);
79772
79734
  if (!raw || typeof raw !== "object") continue;
79773
79735
  const renamedLegacyFields = migrateWorkspaceJson(raw);
@@ -79781,7 +79743,7 @@ var ServerStore = class extends EventTarget {
79781
79743
  }
79782
79744
  }
79783
79745
  for (const file2 of this.readEntityFiles(this.artifactsDir)) {
79784
- const filePath = import_node_path3.default.join(this.artifactsDir, file2);
79746
+ const filePath = import_node_path2.default.join(this.artifactsDir, file2);
79785
79747
  const artifactData = this.readJsonFile(filePath);
79786
79748
  if (!artifactData) continue;
79787
79749
  const artifact = this.validateArtifactData(artifactData, file2, filePath);
@@ -79806,7 +79768,7 @@ var ServerStore = class extends EventTarget {
79806
79768
  layout: []
79807
79769
  };
79808
79770
  this.workspaces.set(workspace.id, workspace);
79809
- this.workspaceFilePaths.set(workspace.id, import_node_path3.default.join(this.workspacesDir, `${workspace.id}.json`));
79771
+ this.workspaceFilePaths.set(workspace.id, import_node_path2.default.join(this.workspacesDir, `${workspace.id}.json`));
79810
79772
  this.persistWorkspace(workspace);
79811
79773
  }
79812
79774
  ensureDirectories() {
@@ -79841,40 +79803,40 @@ var ServerStore = class extends EventTarget {
79841
79803
  }
79842
79804
  persistWorkspace(workspace) {
79843
79805
  (0, import_node_fs.writeFileSync)(
79844
- import_node_path3.default.join(this.workspacesDir, `${workspace.id}.json`),
79806
+ import_node_path2.default.join(this.workspacesDir, `${workspace.id}.json`),
79845
79807
  JSON.stringify(workspace, null, JSON_INDENT_SPACES)
79846
79808
  );
79847
79809
  }
79848
79810
  persistArtifact(artifact) {
79849
79811
  (0, import_node_fs.writeFileSync)(
79850
- import_node_path3.default.join(this.artifactsDir, `${artifact.id}.json`),
79812
+ import_node_path2.default.join(this.artifactsDir, `${artifact.id}.json`),
79851
79813
  JSON.stringify(artifact, null, JSON_INDENT_SPACES)
79852
79814
  );
79853
79815
  }
79854
79816
  deleteArtifactFile(artifactID) {
79855
- (0, import_node_fs.rmSync)(import_node_path3.default.join(this.artifactsDir, `${artifactID}.json`), { force: true });
79817
+ (0, import_node_fs.rmSync)(import_node_path2.default.join(this.artifactsDir, `${artifactID}.json`), { force: true });
79856
79818
  }
79857
79819
  deleteWorkspaceFile(workspaceID) {
79858
- (0, import_node_fs.rmSync)(import_node_path3.default.join(this.workspacesDir, `${workspaceID}.json`), {
79820
+ (0, import_node_fs.rmSync)(import_node_path2.default.join(this.workspacesDir, `${workspaceID}.json`), {
79859
79821
  force: true
79860
79822
  });
79861
79823
  }
79862
79824
  get workspacesDir() {
79863
- return import_node_path3.default.join(this.dataDir, "workspaces");
79825
+ return import_node_path2.default.join(this.dataDir, "workspaces");
79864
79826
  }
79865
79827
  get artifactsDir() {
79866
- return import_node_path3.default.join(this.dataDir, "artifacts");
79828
+ return import_node_path2.default.join(this.dataDir, "artifacts");
79867
79829
  }
79868
79830
  get tokenPath() {
79869
- return import_node_path3.default.join(this.dataDir, "token");
79831
+ return import_node_path2.default.join(this.dataDir, "token");
79870
79832
  }
79871
79833
  };
79872
79834
 
79873
- // src/file-artifact-path.ts
79835
+ // packages/server/src/file-artifact-path.ts
79874
79836
  var import_node_fs2 = require("node:fs");
79875
- var import_node_path4 = __toESM(require("node:path"), 1);
79837
+ var import_node_path3 = __toESM(require("node:path"), 1);
79876
79838
  function validateArtifactFilePath(type, inputPath) {
79877
- const normalized = import_node_path4.default.posix.normalize(inputPath);
79839
+ const normalized = import_node_path3.default.posix.normalize(inputPath);
79878
79840
  if (!normalized.startsWith("/")) {
79879
79841
  throw new Error(`Path must be absolute: ${inputPath}`);
79880
79842
  }
@@ -79901,7 +79863,7 @@ function ensureArtifactFileExists(inputPath) {
79901
79863
  }
79902
79864
  }
79903
79865
  function deriveArtifactTitleFromPath(inputPath) {
79904
- return import_node_path4.default.basename(inputPath);
79866
+ return import_node_path3.default.basename(inputPath);
79905
79867
  }
79906
79868
  function readArtifactFileContent(inputPath) {
79907
79869
  return (0, import_node_fs2.readFileSync)(inputPath, "utf8");
@@ -79910,7 +79872,7 @@ function writeArtifactFileContent(inputPath, content) {
79910
79872
  (0, import_node_fs2.writeFileSync)(inputPath, content, "utf8");
79911
79873
  }
79912
79874
 
79913
- // src/server/tools.ts
79875
+ // packages/server/src/tools.ts
79914
79876
  var import_node_fs3 = require("node:fs");
79915
79877
  function listWorkspaceChoices(workspaces) {
79916
79878
  return workspaces.map((workspace) => `${workspace.name} (${workspace.id})`).join(", ");
@@ -80096,18 +80058,18 @@ function createTools(store) {
80096
80058
  ];
80097
80059
  }
80098
80060
 
80099
- // src/server/artifact-renderer.ts
80061
+ // packages/server/src/artifact-renderer.ts
80100
80062
  var import_node_fs4 = require("node:fs");
80101
- var import_node_path5 = __toESM(require("node:path"), 1);
80063
+ var import_node_path4 = __toESM(require("node:path"), 1);
80102
80064
  var cachedBundle = null;
80103
80065
  function findRuntimeDir(staticDir) {
80104
80066
  const candidates = [
80105
- staticDir ? import_node_path5.default.resolve(staticDir, "..", "artifact-runtime") : null,
80106
- import_node_path5.default.resolve(process.cwd(), "dist", "artifact-runtime"),
80107
- import_node_path5.default.resolve(process.cwd(), "src", "artifact-runtime")
80067
+ staticDir ? import_node_path4.default.resolve(staticDir, "..", "artifact-runtime") : null,
80068
+ import_node_path4.default.resolve(process.cwd(), "dist", "artifact-runtime"),
80069
+ import_node_path4.default.resolve(process.cwd(), "src", "artifact-runtime")
80108
80070
  ].filter((candidate) => typeof candidate === "string");
80109
80071
  for (const candidate of candidates) {
80110
- if ((0, import_node_fs4.existsSync)(import_node_path5.default.join(candidate, "style.css")) && (0, import_node_fs4.existsSync)(import_node_path5.default.join(candidate, "index.js")) || (0, import_node_fs4.existsSync)(import_node_path5.default.join(candidate, "base.css")) && (0, import_node_fs4.existsSync)(import_node_path5.default.join(candidate, "runtime.js"))) {
80072
+ if ((0, import_node_fs4.existsSync)(import_node_path4.default.join(candidate, "style.css")) && (0, import_node_fs4.existsSync)(import_node_path4.default.join(candidate, "index.js")) || (0, import_node_fs4.existsSync)(import_node_path4.default.join(candidate, "base.css")) && (0, import_node_fs4.existsSync)(import_node_path4.default.join(candidate, "runtime.js"))) {
80111
80073
  return candidate;
80112
80074
  }
80113
80075
  }
@@ -80118,8 +80080,8 @@ function loadRuntimeFiles(staticDir) {
80118
80080
  return cachedBundle;
80119
80081
  }
80120
80082
  const runtimeDir = findRuntimeDir(staticDir);
80121
- const cssPath = (0, import_node_fs4.existsSync)(import_node_path5.default.join(runtimeDir, "style.css")) ? import_node_path5.default.join(runtimeDir, "style.css") : import_node_path5.default.join(runtimeDir, "base.css");
80122
- const jsPath = (0, import_node_fs4.existsSync)(import_node_path5.default.join(runtimeDir, "index.js")) ? import_node_path5.default.join(runtimeDir, "index.js") : import_node_path5.default.join(runtimeDir, "runtime.js");
80083
+ const cssPath = (0, import_node_fs4.existsSync)(import_node_path4.default.join(runtimeDir, "style.css")) ? import_node_path4.default.join(runtimeDir, "style.css") : import_node_path4.default.join(runtimeDir, "base.css");
80084
+ const jsPath = (0, import_node_fs4.existsSync)(import_node_path4.default.join(runtimeDir, "index.js")) ? import_node_path4.default.join(runtimeDir, "index.js") : import_node_path4.default.join(runtimeDir, "runtime.js");
80123
80085
  const bundle = {
80124
80086
  css: (0, import_node_fs4.readFileSync)(cssPath, "utf8"),
80125
80087
  js: (0, import_node_fs4.readFileSync)(jsPath, "utf8")
@@ -80168,14 +80130,14 @@ function parseEditableMarkdownClientMessage(data) {
80168
80130
  // node_modules/watcher/dist/watcher.js
80169
80131
  var import_node_events = require("node:events");
80170
80132
  var import_node_fs8 = __toESM(require("node:fs"), 1);
80171
- var import_node_path9 = __toESM(require("node:path"), 1);
80133
+ var import_node_path8 = __toESM(require("node:path"), 1);
80172
80134
 
80173
80135
  // node_modules/watcher/dist/constants.js
80174
- var import_node_os3 = __toESM(require("node:os"), 1);
80136
+ var import_node_os2 = __toESM(require("node:os"), 1);
80175
80137
  var DEBOUNCE = 300;
80176
80138
  var DEPTH = 20;
80177
80139
  var LIMIT = 1e7;
80178
- var PLATFORM = import_node_os3.default.platform();
80140
+ var PLATFORM = import_node_os2.default.platform();
80179
80141
  var IS_MAC = PLATFORM === "darwin";
80180
80142
  var IS_WINDOWS = PLATFORM === "win32";
80181
80143
  var HAS_NATIVE_RECURSION = IS_MAC || IS_WINDOWS;
@@ -80304,7 +80266,7 @@ var debounce_default = debounce;
80304
80266
 
80305
80267
  // node_modules/watcher/dist/utils.js
80306
80268
  var import_node_fs7 = __toESM(require("node:fs"), 1);
80307
- var import_node_path7 = __toESM(require("node:path"), 1);
80269
+ var import_node_path6 = __toESM(require("node:path"), 1);
80308
80270
 
80309
80271
  // node_modules/stubborn-fs/dist/index.js
80310
80272
  var import_node_fs5 = __toESM(require("node:fs"), 1);
@@ -80510,7 +80472,7 @@ var dist_default = FS;
80510
80472
 
80511
80473
  // node_modules/tiny-readdir/dist/index.js
80512
80474
  var import_node_fs6 = __toESM(require("node:fs"), 1);
80513
- var import_node_path6 = __toESM(require("node:path"), 1);
80475
+ var import_node_path5 = __toESM(require("node:path"), 1);
80514
80476
 
80515
80477
  // node_modules/promise-make-naked/dist/utils.js
80516
80478
  var noop = () => {
@@ -80672,7 +80634,7 @@ var readdir = (rootPath, options) => {
80672
80634
  const handleDirent = (dirmap, rootPath2, dirent, depth) => {
80673
80635
  if (signal.aborted)
80674
80636
  return;
80675
- const separator = rootPath2 === import_node_path6.default.sep ? "" : import_node_path6.default.sep;
80637
+ const separator = rootPath2 === import_node_path5.default.sep ? "" : import_node_path5.default.sep;
80676
80638
  const name = dirent.name;
80677
80639
  const subPath = `${rootPath2}${separator}${name}`;
80678
80640
  if (isIgnored(subPath))
@@ -80725,7 +80687,7 @@ var readdir = (rootPath, options) => {
80725
80687
  return decrement();
80726
80688
  if (signal.aborted)
80727
80689
  return decrement();
80728
- const name = import_node_path6.default.basename(realPath);
80690
+ const name = import_node_path5.default.basename(realPath);
80729
80691
  const dirmap = map2[rootPath2] = { directories: [], directoriesNames: /* @__PURE__ */ new Set(), directoriesNamesToPaths: {}, files: [], filesNames: /* @__PURE__ */ new Set(), filesNamesToPaths: {}, symlinks: [], symlinksNames: /* @__PURE__ */ new Set(), symlinksNamesToPaths: {} };
80730
80692
  handleStat(dirmap, realPath, name, stat, depth);
80731
80693
  decrement();
@@ -80733,7 +80695,7 @@ var readdir = (rootPath, options) => {
80733
80695
  });
80734
80696
  };
80735
80697
  const populateResultFromRoot = async (rootPath2, depth = 1) => {
80736
- rootPath2 = import_node_path6.default.normalize(rootPath2);
80698
+ rootPath2 = import_node_path5.default.normalize(rootPath2);
80737
80699
  visited.add(rootPath2);
80738
80700
  populateResultFromPath(rootPath2, depth);
80739
80701
  await promise2;
@@ -80827,7 +80789,7 @@ var Utils = {
80827
80789
  /* FS API */
80828
80790
  fs: {
80829
80791
  getDepth: (targetPath) => {
80830
- return Math.max(0, targetPath.split(import_node_path7.default.sep).length - 1);
80792
+ return Math.max(0, targetPath.split(import_node_path6.default.sep).length - 1);
80831
80793
  },
80832
80794
  getRealPath: (targetPath, native) => {
80833
80795
  try {
@@ -80837,7 +80799,7 @@ var Utils = {
80837
80799
  }
80838
80800
  },
80839
80801
  isSubPath: (targetPath, subPath) => {
80840
- return subPath.startsWith(targetPath) && subPath[targetPath.length] === import_node_path7.default.sep && subPath.length - targetPath.length > import_node_path7.default.sep.length;
80802
+ return subPath.startsWith(targetPath) && subPath[targetPath.length] === import_node_path6.default.sep && subPath.length - targetPath.length > import_node_path6.default.sep.length;
80841
80803
  },
80842
80804
  poll: (targetPath, timeout = POLLING_TIMEOUT) => {
80843
80805
  return dist_default.retry.stat(timeout)(targetPath, { bigint: true }).catch(Utils.lang.noop);
@@ -80856,7 +80818,7 @@ var Utils = {
80856
80818
  var utils_default = Utils;
80857
80819
 
80858
80820
  // node_modules/watcher/dist/watcher_handler.js
80859
- var import_node_path8 = __toESM(require("node:path"), 1);
80821
+ var import_node_path7 = __toESM(require("node:path"), 1);
80860
80822
  var WatcherHandler = class {
80861
80823
  /* CONSTRUCTOR */
80862
80824
  constructor(watcher, config2, base) {
@@ -80992,7 +80954,7 @@ var WatcherHandler = class {
80992
80954
  }
80993
80955
  }
80994
80956
  onTargetUnlink(targetPath) {
80995
- this.watcher.watchersClose(import_node_path8.default.dirname(targetPath), targetPath, false);
80957
+ this.watcher.watchersClose(import_node_path7.default.dirname(targetPath), targetPath, false);
80996
80958
  if (this._isSubRoot(targetPath)) {
80997
80959
  if (this.options.renameDetection) {
80998
80960
  this.watcher._locker.getLockTargetUnlink(targetPath, this.options.renameTimeout);
@@ -81002,7 +80964,7 @@ var WatcherHandler = class {
81002
80964
  }
81003
80965
  }
81004
80966
  onTargetUnlinkDir(targetPath) {
81005
- this.watcher.watchersClose(import_node_path8.default.dirname(targetPath), targetPath, false);
80967
+ this.watcher.watchersClose(import_node_path7.default.dirname(targetPath), targetPath, false);
81006
80968
  this.watcher.watchersClose(targetPath);
81007
80969
  if (this._isSubRoot(targetPath)) {
81008
80970
  if (this.options.renameDetection) {
@@ -81037,7 +80999,7 @@ var WatcherHandler = class {
81037
80999
  onWatcherChange(event = FSTargetEvent.CHANGE, targetName) {
81038
81000
  if (this.watcher.isClosed())
81039
81001
  return;
81040
- const targetPath = import_node_path8.default.resolve(this.folderPath, targetName || "");
81002
+ const targetPath = import_node_path7.default.resolve(this.folderPath, targetName || "");
81041
81003
  if (this.filePath && targetPath !== this.folderPath && targetPath !== this.filePath)
81042
81004
  return;
81043
81005
  if (this.watcher.isIgnored(targetPath, this.options.ignore))
@@ -81609,14 +81571,14 @@ var Watcher = class _Watcher extends import_node_events.EventEmitter {
81609
81571
  const configsSibling = this._watchers[folderPath];
81610
81572
  if (!!configsSibling?.find((config2) => config2.handler === handler && (!config2.filePath || config2.filePath === filePath) && config2.options.ignore === options.ignore && !!config2.options.native === !!options.native && (!options.recursive || config2.options.recursive)))
81611
81573
  return true;
81612
- let folderAncestorPath = import_node_path9.default.dirname(folderPath);
81574
+ let folderAncestorPath = import_node_path8.default.dirname(folderPath);
81613
81575
  for (let depth = 1; depth < Infinity; depth++) {
81614
81576
  const configsAncestor = this._watchers[folderAncestorPath];
81615
81577
  if (!!configsAncestor?.find((config2) => (depth === 1 || config2.options.recursive && depth <= (config2.options.depth ?? DEPTH)) && config2.handler === handler && (!config2.filePath || config2.filePath === filePath) && config2.options.ignore === options.ignore && !!config2.options.native === !!options.native && (!options.recursive || config2.options.recursive && (HAS_NATIVE_RECURSION && config2.options.native !== false))))
81616
81578
  return true;
81617
81579
  if (!HAS_NATIVE_RECURSION)
81618
81580
  break;
81619
- const folderAncestorPathNext = import_node_path9.default.dirname(folderPath);
81581
+ const folderAncestorPathNext = import_node_path8.default.dirname(folderPath);
81620
81582
  if (folderAncestorPath === folderAncestorPathNext)
81621
81583
  break;
81622
81584
  folderAncestorPath = folderAncestorPathNext;
@@ -81641,7 +81603,7 @@ var Watcher = class _Watcher extends import_node_events.EventEmitter {
81641
81603
  const isRoot = this._roots.has(filePath || folderPath);
81642
81604
  if (isRoot) {
81643
81605
  const parentOptions = { ...options, ignoreInitial: true, recursive: false };
81644
- const parentFolderPath = import_node_path9.default.dirname(folderPath);
81606
+ const parentFolderPath = import_node_path8.default.dirname(folderPath);
81645
81607
  const parentFilePath = folderPath;
81646
81608
  await this.watchDirectories([parentFolderPath], parentOptions, handler, parentFilePath, watcherHandler);
81647
81609
  }
@@ -81711,7 +81673,7 @@ var Watcher = class _Watcher extends import_node_events.EventEmitter {
81711
81673
  if (this.isIgnored(filePath, options.ignore))
81712
81674
  return;
81713
81675
  options = { ...options, recursive: false };
81714
- const folderPath = import_node_path9.default.dirname(filePath);
81676
+ const folderPath = import_node_path8.default.dirname(filePath);
81715
81677
  return this.watchDirectory(folderPath, options, handler, filePath);
81716
81678
  }
81717
81679
  async watchPollingOnce(targetPath, options, callback) {
@@ -81782,12 +81744,12 @@ var Watcher = class _Watcher extends import_node_events.EventEmitter {
81782
81744
  async watchPath(targetPath, options, handler) {
81783
81745
  if (this.isClosed())
81784
81746
  return;
81785
- targetPath = import_node_path9.default.resolve(targetPath);
81747
+ targetPath = import_node_path8.default.resolve(targetPath);
81786
81748
  if (this.isIgnored(targetPath, options.ignore))
81787
81749
  return;
81788
81750
  const stats = await utils_default.fs.poll(targetPath, options.pollingTimeout);
81789
81751
  if (!stats) {
81790
- const parentPath = import_node_path9.default.dirname(targetPath);
81752
+ const parentPath = import_node_path8.default.dirname(targetPath);
81791
81753
  const parentStats = await utils_default.fs.poll(parentPath, options.pollingTimeout);
81792
81754
  if (parentStats?.isDirectory()) {
81793
81755
  return this.watchUnknownChild(targetPath, options, handler);
@@ -81975,7 +81937,7 @@ function editableMarkdownSocketServer(options) {
81975
81937
  return new EditableMarkdownSocketServer(options);
81976
81938
  }
81977
81939
 
81978
- // src/server/server.ts
81940
+ // packages/server/src/server.ts
81979
81941
  var import_node_fs9 = require("node:fs");
81980
81942
  var AUTH_FAILED_CLOSE_CODE = 4401;
81981
81943
  var HTTP_UNAUTHORIZED_STATUS = 401;
@@ -82393,7 +82355,41 @@ function isLayoutNode(value) {
82393
82355
  }
82394
82356
  }
82395
82357
 
82396
- // src/electron/index.ts
82358
+ // packages/server/src/config.ts
82359
+ var import_node_os3 = __toESM(require("node:os"), 1);
82360
+ var import_node_path9 = __toESM(require("node:path"), 1);
82361
+ var TRUE_ENV_VALUE = "true";
82362
+ var APP_HIDDEN_DIRECTORY = ".television";
82363
+ var TELEVISION_DATA_DIR_ENV = "TELEVISION_DATA_DIR";
82364
+ var TELEVISION_PORT_ENV = "TELEVISION_PORT";
82365
+ var DEFAULT_SERVER_HOST = "localhost";
82366
+ var DEFAULT_SERVER_PORT = 32848;
82367
+ var DEFAULT_SERVER_URL = buildServerURL(DEFAULT_SERVER_HOST, DEFAULT_SERVER_PORT);
82368
+ function buildServerURL(host, port) {
82369
+ return `http://${host}:${port}`;
82370
+ }
82371
+ function getTelevisionDataDir() {
82372
+ return process.env[TELEVISION_DATA_DIR_ENV] ?? import_node_path9.default.join(import_node_os3.default.homedir(), APP_HIDDEN_DIRECTORY);
82373
+ }
82374
+ function getTelevisionRendererUrlEnv() {
82375
+ return process.env.TELEVISION_RENDERER_URL;
82376
+ }
82377
+ function getTelevisionPortEnv() {
82378
+ const rawPort = process.env[TELEVISION_PORT_ENV];
82379
+ if (!rawPort) {
82380
+ return void 0;
82381
+ }
82382
+ const port = Number.parseInt(rawPort, 10);
82383
+ return Number.isInteger(port) ? port : void 0;
82384
+ }
82385
+ function isVitestRuntime() {
82386
+ return process.env.VITEST === TRUE_ENV_VALUE;
82387
+ }
82388
+ function isDevMode() {
82389
+ return process.env.NODE_ENV !== "production";
82390
+ }
82391
+
82392
+ // packages/desktop/src/index.ts
82397
82393
  var WINDOW_WIDTH = 900;
82398
82394
  var WINDOW_HEIGHT = 700;
82399
82395
  var TRAFFIC_LIGHT_POSITION = { x: 12, y: 12 };