@celljs/ta-workspace 4.15.2 → 4.16.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.
Files changed (2) hide show
  1. package/package.json +3 -3
  2. package/web/index.js +38 -3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@celljs/ta-workspace",
3
- "version": "4.15.2",
3
+ "version": "4.16.0",
4
4
  "description": "A pi package for Ta: the workspace beside the conversation, with an explorer, open files, search, source control, terminals and a browser",
5
5
  "keywords": [
6
6
  "pi-package"
@@ -25,8 +25,8 @@
25
25
  "watch": "tsc -b -w --preserveWatchOutput"
26
26
  },
27
27
  "devDependencies": {
28
- "@celljs/ta-protocol": "4.15.2",
29
- "@celljs/ta-web": "4.15.2",
28
+ "@celljs/ta-protocol": "4.16.0",
29
+ "@celljs/ta-web": "4.16.0",
30
30
  "@types/react": "^19.3.0",
31
31
  "marked": "^14.1.4"
32
32
  },
package/web/index.js CHANGED
@@ -6221,15 +6221,47 @@ var TaGatewayServer = Symbol("TaGatewayServer");
6221
6221
  var TaLocation;
6222
6222
  (function(TaLocation2) {
6223
6223
  TaLocation2.SSH = "ssh://";
6224
+ TaLocation2.CLOUD = "ta://";
6225
+ const CLOUD_NAME = /^[a-z0-9][a-z0-9-]{0,39}$/;
6224
6226
  const HOST = /^(?!-)[\w.@:%+[\]-]+$/;
6225
6227
  function isRemote(location2) {
6226
- return location2.startsWith(TaLocation2.SSH);
6228
+ return location2.startsWith(TaLocation2.SSH) || location2.startsWith(TaLocation2.CLOUD);
6227
6229
  }
6228
6230
  TaLocation2.isRemote = isRemote;
6231
+ function isCloud(host2) {
6232
+ return !!host2 && host2.startsWith(TaLocation2.CLOUD);
6233
+ }
6234
+ TaLocation2.isCloud = isCloud;
6235
+ function isCloudName(name) {
6236
+ return CLOUD_NAME.test(name);
6237
+ }
6238
+ TaLocation2.isCloudName = isCloudName;
6239
+ function cloud(name, path2 = "") {
6240
+ return `${TaLocation2.CLOUD}${name}${path2 ? normalize(path2) : ""}`;
6241
+ }
6242
+ TaLocation2.cloud = cloud;
6243
+ function cloudName(hostOrLocation) {
6244
+ if (!hostOrLocation.startsWith(TaLocation2.CLOUD)) {
6245
+ return;
6246
+ }
6247
+ const rest = hostOrLocation.slice(TaLocation2.CLOUD.length);
6248
+ const slash = rest.indexOf("/");
6249
+ return slash < 0 ? rest : rest.slice(0, slash);
6250
+ }
6251
+ TaLocation2.cloudName = cloudName;
6229
6252
  function parse(location2) {
6253
+ var _a;
6230
6254
  if (!isRemote(location2)) {
6231
6255
  return;
6232
6256
  }
6257
+ if (location2.startsWith(TaLocation2.CLOUD)) {
6258
+ const name = (_a = cloudName(location2)) !== null && _a !== undefined ? _a : "";
6259
+ if (!isCloudName(name)) {
6260
+ throw new Error(`${JSON.stringify(location2)} names no cloud workspace: write ta://<name>/<path>.`);
6261
+ }
6262
+ const path3 = location2.slice(TaLocation2.CLOUD.length + name.length);
6263
+ return { host: `${TaLocation2.CLOUD}${name}`, path: path3 ? normalize(path3) : "" };
6264
+ }
6233
6265
  const rest = location2.slice(TaLocation2.SSH.length);
6234
6266
  const slash = rest.indexOf("/");
6235
6267
  const host2 = slash < 0 ? rest : rest.slice(0, slash);
@@ -6241,7 +6273,7 @@ var TaLocation;
6241
6273
  }
6242
6274
  TaLocation2.parse = parse;
6243
6275
  function isHost(host2) {
6244
- return HOST.test(host2);
6276
+ return isCloud(host2) ? isCloudName(host2.slice(TaLocation2.CLOUD.length)) : HOST.test(host2);
6245
6277
  }
6246
6278
  TaLocation2.isHost = isHost;
6247
6279
  const FLAGS = /^-[46AaCfGgKkMNnqsTtVvXxYy]+$/;
@@ -6305,10 +6337,13 @@ var TaLocation;
6305
6337
  }
6306
6338
  TaLocation2.readHost = readHost;
6307
6339
  function ssh(host2, path2 = "") {
6308
- return `${TaLocation2.SSH}${host2}${path2 ? normalize(path2) : ""}`;
6340
+ return isCloud(host2) ? `${host2}${path2 ? normalize(path2) : ""}` : `${TaLocation2.SSH}${host2}${path2 ? normalize(path2) : ""}`;
6309
6341
  }
6310
6342
  TaLocation2.ssh = ssh;
6311
6343
  function hostLabel(host2) {
6344
+ if (isCloud(host2)) {
6345
+ return host2.slice(TaLocation2.CLOUD.length);
6346
+ }
6312
6347
  const name = host2.replace(/^[^@]*@/, "").replace(/^\[(.*)\](?::\d+)?$/, "$1").replace(/^([^:]*):\d+$/, "$1");
6313
6348
  return /^[\d.]+$/.test(name) || name.includes(":") ? name : name.split(".")[0] || name;
6314
6349
  }