@celljs/ta-moments 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.
@@ -205,15 +205,47 @@ var TaLanguageUtil;
205
205
  var TaLocation;
206
206
  (function(TaLocation2) {
207
207
  TaLocation2.SSH = "ssh://";
208
+ TaLocation2.CLOUD = "ta://";
209
+ const CLOUD_NAME = /^[a-z0-9][a-z0-9-]{0,39}$/;
208
210
  const HOST = /^(?!-)[\w.@:%+[\]-]+$/;
209
211
  function isRemote(location) {
210
- return location.startsWith(TaLocation2.SSH);
212
+ return location.startsWith(TaLocation2.SSH) || location.startsWith(TaLocation2.CLOUD);
211
213
  }
212
214
  TaLocation2.isRemote = isRemote;
215
+ function isCloud(host2) {
216
+ return !!host2 && host2.startsWith(TaLocation2.CLOUD);
217
+ }
218
+ TaLocation2.isCloud = isCloud;
219
+ function isCloudName(name) {
220
+ return CLOUD_NAME.test(name);
221
+ }
222
+ TaLocation2.isCloudName = isCloudName;
223
+ function cloud(name, path2 = "") {
224
+ return `${TaLocation2.CLOUD}${name}${path2 ? normalize(path2) : ""}`;
225
+ }
226
+ TaLocation2.cloud = cloud;
227
+ function cloudName(hostOrLocation) {
228
+ if (!hostOrLocation.startsWith(TaLocation2.CLOUD)) {
229
+ return;
230
+ }
231
+ const rest = hostOrLocation.slice(TaLocation2.CLOUD.length);
232
+ const slash = rest.indexOf("/");
233
+ return slash < 0 ? rest : rest.slice(0, slash);
234
+ }
235
+ TaLocation2.cloudName = cloudName;
213
236
  function parse(location) {
237
+ var _a;
214
238
  if (!isRemote(location)) {
215
239
  return;
216
240
  }
241
+ if (location.startsWith(TaLocation2.CLOUD)) {
242
+ const name = (_a = cloudName(location)) !== null && _a !== undefined ? _a : "";
243
+ if (!isCloudName(name)) {
244
+ throw new Error(`${JSON.stringify(location)} names no cloud workspace: write ta://<name>/<path>.`);
245
+ }
246
+ const path3 = location.slice(TaLocation2.CLOUD.length + name.length);
247
+ return { host: `${TaLocation2.CLOUD}${name}`, path: path3 ? normalize(path3) : "" };
248
+ }
217
249
  const rest = location.slice(TaLocation2.SSH.length);
218
250
  const slash = rest.indexOf("/");
219
251
  const host2 = slash < 0 ? rest : rest.slice(0, slash);
@@ -225,7 +257,7 @@ var TaLocation;
225
257
  }
226
258
  TaLocation2.parse = parse;
227
259
  function isHost(host2) {
228
- return HOST.test(host2);
260
+ return isCloud(host2) ? isCloudName(host2.slice(TaLocation2.CLOUD.length)) : HOST.test(host2);
229
261
  }
230
262
  TaLocation2.isHost = isHost;
231
263
  const FLAGS = /^-[46AaCfGgKkMNnqsTtVvXxYy]+$/;
@@ -289,10 +321,13 @@ var TaLocation;
289
321
  }
290
322
  TaLocation2.readHost = readHost;
291
323
  function ssh(host2, path2 = "") {
292
- return `${TaLocation2.SSH}${host2}${path2 ? normalize(path2) : ""}`;
324
+ return isCloud(host2) ? `${host2}${path2 ? normalize(path2) : ""}` : `${TaLocation2.SSH}${host2}${path2 ? normalize(path2) : ""}`;
293
325
  }
294
326
  TaLocation2.ssh = ssh;
295
327
  function hostLabel(host2) {
328
+ if (isCloud(host2)) {
329
+ return host2.slice(TaLocation2.CLOUD.length);
330
+ }
296
331
  const name = host2.replace(/^[^@]*@/, "").replace(/^\[(.*)\](?::\d+)?$/, "$1").replace(/^([^:]*):\d+$/, "$1");
297
332
  return /^[\d.]+$/.test(name) || name.includes(":") ? name : name.split(".")[0] || name;
298
333
  }
package/host/index.mjs CHANGED
@@ -248,15 +248,47 @@ var TaGatewayServer = Symbol("TaGatewayServer");
248
248
  var TaLocation;
249
249
  (function(TaLocation2) {
250
250
  TaLocation2.SSH = "ssh://";
251
+ TaLocation2.CLOUD = "ta://";
252
+ const CLOUD_NAME = /^[a-z0-9][a-z0-9-]{0,39}$/;
251
253
  const HOST = /^(?!-)[\w.@:%+[\]-]+$/;
252
254
  function isRemote(location) {
253
- return location.startsWith(TaLocation2.SSH);
255
+ return location.startsWith(TaLocation2.SSH) || location.startsWith(TaLocation2.CLOUD);
254
256
  }
255
257
  TaLocation2.isRemote = isRemote;
258
+ function isCloud(host2) {
259
+ return !!host2 && host2.startsWith(TaLocation2.CLOUD);
260
+ }
261
+ TaLocation2.isCloud = isCloud;
262
+ function isCloudName(name) {
263
+ return CLOUD_NAME.test(name);
264
+ }
265
+ TaLocation2.isCloudName = isCloudName;
266
+ function cloud(name, path2 = "") {
267
+ return `${TaLocation2.CLOUD}${name}${path2 ? normalize(path2) : ""}`;
268
+ }
269
+ TaLocation2.cloud = cloud;
270
+ function cloudName(hostOrLocation) {
271
+ if (!hostOrLocation.startsWith(TaLocation2.CLOUD)) {
272
+ return;
273
+ }
274
+ const rest = hostOrLocation.slice(TaLocation2.CLOUD.length);
275
+ const slash = rest.indexOf("/");
276
+ return slash < 0 ? rest : rest.slice(0, slash);
277
+ }
278
+ TaLocation2.cloudName = cloudName;
256
279
  function parse(location) {
280
+ var _a;
257
281
  if (!isRemote(location)) {
258
282
  return;
259
283
  }
284
+ if (location.startsWith(TaLocation2.CLOUD)) {
285
+ const name = (_a = cloudName(location)) !== null && _a !== undefined ? _a : "";
286
+ if (!isCloudName(name)) {
287
+ throw new Error(`${JSON.stringify(location)} names no cloud workspace: write ta://<name>/<path>.`);
288
+ }
289
+ const path3 = location.slice(TaLocation2.CLOUD.length + name.length);
290
+ return { host: `${TaLocation2.CLOUD}${name}`, path: path3 ? normalize(path3) : "" };
291
+ }
260
292
  const rest = location.slice(TaLocation2.SSH.length);
261
293
  const slash = rest.indexOf("/");
262
294
  const host2 = slash < 0 ? rest : rest.slice(0, slash);
@@ -268,7 +300,7 @@ var TaLocation;
268
300
  }
269
301
  TaLocation2.parse = parse;
270
302
  function isHost(host2) {
271
- return HOST.test(host2);
303
+ return isCloud(host2) ? isCloudName(host2.slice(TaLocation2.CLOUD.length)) : HOST.test(host2);
272
304
  }
273
305
  TaLocation2.isHost = isHost;
274
306
  const FLAGS = /^-[46AaCfGgKkMNnqsTtVvXxYy]+$/;
@@ -332,10 +364,13 @@ var TaLocation;
332
364
  }
333
365
  TaLocation2.readHost = readHost;
334
366
  function ssh(host2, path2 = "") {
335
- return `${TaLocation2.SSH}${host2}${path2 ? normalize(path2) : ""}`;
367
+ return isCloud(host2) ? `${host2}${path2 ? normalize(path2) : ""}` : `${TaLocation2.SSH}${host2}${path2 ? normalize(path2) : ""}`;
336
368
  }
337
369
  TaLocation2.ssh = ssh;
338
370
  function hostLabel(host2) {
371
+ if (isCloud(host2)) {
372
+ return host2.slice(TaLocation2.CLOUD.length);
373
+ }
339
374
  const name = host2.replace(/^[^@]*@/, "").replace(/^\[(.*)\](?::\d+)?$/, "$1").replace(/^([^:]*):\d+$/, "$1");
340
375
  return /^[\d.]+$/.test(name) || name.includes(":") ? name : name.split(".")[0] || name;
341
376
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@celljs/ta-moments",
3
- "version": "4.15.2",
3
+ "version": "4.16.0",
4
4
  "description": "A pi package for Ta: Moments, what friends made with Ta that one can take and use. Ta drafts a post of what you made and you post it; your Ta friends see it, like it and take it, their Ta reading the code first",
5
5
  "keywords": [
6
6
  "pi-package"
@@ -27,9 +27,9 @@
27
27
  "watch": "tsc -b -w --preserveWatchOutput"
28
28
  },
29
29
  "devDependencies": {
30
- "@celljs/ta-protocol": "4.15.2",
31
- "@celljs/ta-relay": "4.15.2",
32
- "@celljs/ta-web": "4.15.2",
30
+ "@celljs/ta-protocol": "4.16.0",
31
+ "@celljs/ta-relay": "4.16.0",
32
+ "@celljs/ta-web": "4.16.0",
33
33
  "@types/react": "^19.3.0"
34
34
  },
35
35
  "publishConfig": {
package/web/index.js CHANGED
@@ -499,15 +499,47 @@ var TaGatewayServer = Symbol("TaGatewayServer");
499
499
  var TaLocation;
500
500
  (function(TaLocation2) {
501
501
  TaLocation2.SSH = "ssh://";
502
+ TaLocation2.CLOUD = "ta://";
503
+ const CLOUD_NAME = /^[a-z0-9][a-z0-9-]{0,39}$/;
502
504
  const HOST = /^(?!-)[\w.@:%+[\]-]+$/;
503
505
  function isRemote(location) {
504
- return location.startsWith(TaLocation2.SSH);
506
+ return location.startsWith(TaLocation2.SSH) || location.startsWith(TaLocation2.CLOUD);
505
507
  }
506
508
  TaLocation2.isRemote = isRemote;
509
+ function isCloud(host2) {
510
+ return !!host2 && host2.startsWith(TaLocation2.CLOUD);
511
+ }
512
+ TaLocation2.isCloud = isCloud;
513
+ function isCloudName(name) {
514
+ return CLOUD_NAME.test(name);
515
+ }
516
+ TaLocation2.isCloudName = isCloudName;
517
+ function cloud(name, path2 = "") {
518
+ return `${TaLocation2.CLOUD}${name}${path2 ? normalize(path2) : ""}`;
519
+ }
520
+ TaLocation2.cloud = cloud;
521
+ function cloudName(hostOrLocation) {
522
+ if (!hostOrLocation.startsWith(TaLocation2.CLOUD)) {
523
+ return;
524
+ }
525
+ const rest = hostOrLocation.slice(TaLocation2.CLOUD.length);
526
+ const slash = rest.indexOf("/");
527
+ return slash < 0 ? rest : rest.slice(0, slash);
528
+ }
529
+ TaLocation2.cloudName = cloudName;
507
530
  function parse(location) {
531
+ var _a;
508
532
  if (!isRemote(location)) {
509
533
  return;
510
534
  }
535
+ if (location.startsWith(TaLocation2.CLOUD)) {
536
+ const name = (_a = cloudName(location)) !== null && _a !== undefined ? _a : "";
537
+ if (!isCloudName(name)) {
538
+ throw new Error(`${JSON.stringify(location)} names no cloud workspace: write ta://<name>/<path>.`);
539
+ }
540
+ const path3 = location.slice(TaLocation2.CLOUD.length + name.length);
541
+ return { host: `${TaLocation2.CLOUD}${name}`, path: path3 ? normalize(path3) : "" };
542
+ }
511
543
  const rest = location.slice(TaLocation2.SSH.length);
512
544
  const slash = rest.indexOf("/");
513
545
  const host2 = slash < 0 ? rest : rest.slice(0, slash);
@@ -519,7 +551,7 @@ var TaLocation;
519
551
  }
520
552
  TaLocation2.parse = parse;
521
553
  function isHost(host2) {
522
- return HOST.test(host2);
554
+ return isCloud(host2) ? isCloudName(host2.slice(TaLocation2.CLOUD.length)) : HOST.test(host2);
523
555
  }
524
556
  TaLocation2.isHost = isHost;
525
557
  const FLAGS = /^-[46AaCfGgKkMNnqsTtVvXxYy]+$/;
@@ -583,10 +615,13 @@ var TaLocation;
583
615
  }
584
616
  TaLocation2.readHost = readHost;
585
617
  function ssh(host2, path2 = "") {
586
- return `${TaLocation2.SSH}${host2}${path2 ? normalize(path2) : ""}`;
618
+ return isCloud(host2) ? `${host2}${path2 ? normalize(path2) : ""}` : `${TaLocation2.SSH}${host2}${path2 ? normalize(path2) : ""}`;
587
619
  }
588
620
  TaLocation2.ssh = ssh;
589
621
  function hostLabel(host2) {
622
+ if (isCloud(host2)) {
623
+ return host2.slice(TaLocation2.CLOUD.length);
624
+ }
590
625
  const name = host2.replace(/^[^@]*@/, "").replace(/^\[(.*)\](?::\d+)?$/, "$1").replace(/^([^:]*):\d+$/, "$1");
591
626
  return /^[\d.]+$/.test(name) || name.includes(":") ? name : name.split(".")[0] || name;
592
627
  }