@sublang/spex 4.2.0 → 6.0.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/README.md +438 -89
- package/dist/cli.js +80 -42
- package/dist/commands/add.d.ts +12 -0
- package/dist/commands/add.js +138 -0
- package/dist/commands/auth-target.d.ts +12 -0
- package/dist/commands/auth-target.js +52 -0
- package/dist/commands/environment.d.ts +117 -0
- package/dist/commands/environment.js +399 -0
- package/dist/commands/export.d.ts +21 -0
- package/dist/commands/export.js +663 -0
- package/dist/commands/home.d.ts +56 -0
- package/dist/commands/home.js +215 -0
- package/dist/commands/install.d.ts +2 -0
- package/dist/commands/install.js +48 -0
- package/dist/commands/list.d.ts +2 -0
- package/dist/commands/list.js +87 -0
- package/dist/commands/login.d.ts +2 -0
- package/dist/commands/login.js +211 -0
- package/dist/commands/logout.d.ts +2 -0
- package/dist/commands/logout.js +74 -0
- package/dist/commands/publish.d.ts +2 -0
- package/dist/commands/publish.js +120 -0
- package/dist/commands/remove.d.ts +2 -0
- package/dist/commands/remove.js +34 -0
- package/dist/commands/run.d.ts +50 -0
- package/dist/commands/run.js +312 -0
- package/dist/commands/search.d.ts +2 -0
- package/dist/commands/search.js +34 -0
- package/dist/commands/settle.d.ts +124 -0
- package/dist/commands/settle.js +475 -0
- package/dist/commands/update.d.ts +2 -0
- package/dist/commands/update.js +37 -0
- package/dist/commands/whoami.d.ts +2 -0
- package/dist/commands/whoami.js +71 -0
- package/dist/lib/environment/agent-folders.d.ts +14 -0
- package/dist/lib/environment/agent-folders.js +11 -0
- package/dist/lib/environment/archive.d.ts +39 -0
- package/dist/lib/environment/archive.js +122 -0
- package/dist/lib/environment/builtins.d.ts +112 -0
- package/dist/lib/environment/builtins.js +539 -0
- package/dist/lib/environment/citations.d.ts +75 -0
- package/dist/lib/environment/citations.js +267 -0
- package/dist/lib/environment/exports.d.ts +190 -0
- package/dist/lib/environment/exports.js +1029 -0
- package/dist/lib/environment/format.d.ts +133 -0
- package/dist/lib/environment/format.js +651 -0
- package/dist/lib/environment/git-source.d.ts +41 -0
- package/dist/lib/environment/git-source.js +159 -0
- package/dist/lib/environment/index.d.ts +20 -0
- package/dist/lib/environment/index.js +27 -0
- package/dist/lib/environment/install.d.ts +140 -0
- package/dist/lib/environment/install.js +694 -0
- package/dist/lib/environment/layout.d.ts +15 -0
- package/dist/lib/environment/layout.js +50 -0
- package/dist/lib/environment/lock.d.ts +87 -0
- package/dist/lib/environment/lock.js +305 -0
- package/dist/lib/environment/marker.d.ts +15 -0
- package/dist/lib/environment/marker.js +31 -0
- package/dist/lib/environment/own-paths.d.ts +59 -0
- package/dist/lib/environment/own-paths.js +174 -0
- package/dist/lib/environment/placed-record.d.ts +32 -0
- package/dist/lib/environment/placed-record.js +72 -0
- package/dist/lib/environment/registries.d.ts +23 -0
- package/dist/lib/environment/registries.js +48 -0
- package/dist/lib/environment/registry.d.ts +172 -0
- package/dist/lib/environment/registry.js +390 -0
- package/dist/lib/environment/requests.d.ts +109 -0
- package/dist/lib/environment/requests.js +401 -0
- package/dist/lib/environment/resolve.d.ts +70 -0
- package/dist/lib/environment/resolve.js +451 -0
- package/dist/lib/environment/semver.d.ts +30 -0
- package/dist/lib/environment/semver.js +130 -0
- package/dist/lib/environment/store.d.ts +23 -0
- package/dist/lib/environment/store.js +123 -0
- package/dist/lib/environment/tar.d.ts +27 -0
- package/dist/lib/environment/tar.js +219 -0
- package/dist/lib/files.d.ts +66 -0
- package/dist/lib/files.js +233 -0
- package/dist/lib/git-host.d.ts +579 -0
- package/dist/lib/git-host.js +1363 -0
- package/dist/lib/home-file.d.ts +124 -0
- package/dist/lib/home-file.js +288 -0
- package/dist/lib/instance.d.ts +63 -0
- package/dist/lib/instance.js +130 -0
- package/dist/lib/words.d.ts +32 -0
- package/dist/lib/words.js +27 -0
- package/dist/lint.js +8 -0
- package/dist/testing/index.d.ts +1 -0
- package/dist/testing/index.js +7 -0
- package/dist/testing/standin-registry.d.ts +94 -0
- package/dist/testing/standin-registry.js +449 -0
- package/package.json +37 -3
- package/dist/attached-cli.d.ts +0 -13
- package/dist/attached-cli.js +0 -249
- package/dist/attached-client.d.ts +0 -53
- package/dist/attached-client.js +0 -237
- package/dist/generated-protocol.d.ts +0 -2
- package/dist/generated-protocol.js +0 -6
- package/dist/package-init.d.ts +0 -21
- package/dist/package-init.js +0 -442
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { CLIENT_ID } from "./git-host.js";
|
|
2
|
+
export { CLIENT_ID };
|
|
3
|
+
export declare const HOME_FILE = "home.yaml";
|
|
4
|
+
export interface HomeAccount {
|
|
5
|
+
id: string;
|
|
6
|
+
login: string;
|
|
7
|
+
displayName: string | null;
|
|
8
|
+
}
|
|
9
|
+
/** An instance the home has signed in to (DR-127), by its canonical
|
|
10
|
+
* origin: its client, the account it signed in as, whether it was
|
|
11
|
+
* signed out since, and its display name as last read. */
|
|
12
|
+
export interface HomeInstance {
|
|
13
|
+
origin: string;
|
|
14
|
+
clientId: typeof CLIENT_ID;
|
|
15
|
+
account?: HomeAccount;
|
|
16
|
+
signedOut?: boolean;
|
|
17
|
+
displayName?: string;
|
|
18
|
+
}
|
|
19
|
+
export interface HomeFolder {
|
|
20
|
+
path: string;
|
|
21
|
+
repository: string;
|
|
22
|
+
aliases?: string[];
|
|
23
|
+
}
|
|
24
|
+
export interface HomeFile {
|
|
25
|
+
format: 2;
|
|
26
|
+
device: string;
|
|
27
|
+
/** The origin the home was created with: the default instance while
|
|
28
|
+
* no instance is listed. */
|
|
29
|
+
origin: string;
|
|
30
|
+
/** Every instance the home has signed in to; the first is the
|
|
31
|
+
* default instance. */
|
|
32
|
+
instances: HomeInstance[];
|
|
33
|
+
own: string;
|
|
34
|
+
folders: HomeFolder[];
|
|
35
|
+
}
|
|
36
|
+
/** Why an instance operation was refused (DR-127):
|
|
37
|
+
* - `another-account`: a sign-in to a listed instance as another account;
|
|
38
|
+
* - `signed-in`: Forget of an instance still signed in.
|
|
39
|
+
* The message is the library's own; the reader's words are composed
|
|
40
|
+
* where each host speaks. */
|
|
41
|
+
export declare class InstanceRefused extends Error {
|
|
42
|
+
readonly reason: "another-account" | "signed-in";
|
|
43
|
+
readonly origin: string;
|
|
44
|
+
constructor(reason: "another-account" | "signed-in", origin: string);
|
|
45
|
+
}
|
|
46
|
+
/** Lowercase kebab-case: runs of anything else become one hyphen. */
|
|
47
|
+
export declare function kebab(value: string): string;
|
|
48
|
+
/** This device's user name as a group folder name (storage-2). */
|
|
49
|
+
export declare function defaultOwnName(env?: NodeJS.ProcessEnv): string;
|
|
50
|
+
/** Whether a name may stand as a group folder under `workspace/`. */
|
|
51
|
+
export declare function isGroupName(value: string): boolean;
|
|
52
|
+
export declare const invalidHome: () => string;
|
|
53
|
+
/** The reason a URL stands as no instance's canonical origin (DR-127). */
|
|
54
|
+
export declare function notAnOrigin(url: string): string;
|
|
55
|
+
/** A check of the pairings a host reads, after every other field. */
|
|
56
|
+
export type FoldersCheck = (folders: readonly unknown[], file: string) => void;
|
|
57
|
+
/**
|
|
58
|
+
* `home.yaml`'s value checked field by field (storage-2): its format,
|
|
59
|
+
* device, origin, your own group's name and every instance's entry —
|
|
60
|
+
* one per origin, and no two origins at one folder — and the pairings a
|
|
61
|
+
* list, each entry checked by `checkFolders` where the host supplies it.
|
|
62
|
+
* A malformed or unknown file is refused, never guessed at.
|
|
63
|
+
*/
|
|
64
|
+
export declare function parseHomeFile(value: unknown, file: string, checkFolders?: FoldersCheck): HomeFile;
|
|
65
|
+
/** `home.yaml`'s value from its text; text that will not read is
|
|
66
|
+
* refused as a storage diagnostic of the file. */
|
|
67
|
+
export declare function parseHomeText(text: string, file: string, checkFolders?: FoldersCheck): HomeFile;
|
|
68
|
+
/** A new home, not yet written: a fresh device id unless one is
|
|
69
|
+
* supplied, the origin the environment names, no instance signed in
|
|
70
|
+
* to, and this device's user name as your own group. A URL the
|
|
71
|
+
* environment names that is no instance's origin is refused as a
|
|
72
|
+
* storage diagnostic of `file`. */
|
|
73
|
+
export declare function newHomeFile(file: string, options?: {
|
|
74
|
+
own?: string;
|
|
75
|
+
env?: NodeJS.ProcessEnv;
|
|
76
|
+
device?: string;
|
|
77
|
+
}): HomeFile;
|
|
78
|
+
/** The default instance: the first listed, else the origin the home
|
|
79
|
+
* was created with. */
|
|
80
|
+
export declare function defaultInstanceOf(home: HomeFile): HomeInstance;
|
|
81
|
+
/** The listed instance at an origin, in any spelling of it. */
|
|
82
|
+
export declare function instanceAt(home: HomeFile, origin: string): HomeInstance | undefined;
|
|
83
|
+
/** The instance whose folder under `workspace/` is `folder`: a listed
|
|
84
|
+
* one, else the origin the home was created with. */
|
|
85
|
+
export declare function instanceByFolder(home: HomeFile, folder: string): HomeInstance | undefined;
|
|
86
|
+
/** The instance whose folder a key lies in; none for a key outside
|
|
87
|
+
* every instance's folder. */
|
|
88
|
+
export declare function instanceOfKey(home: HomeFile, key: string): HomeInstance | undefined;
|
|
89
|
+
/** The account at an instance while it is signed in there; the
|
|
90
|
+
* default instance where no origin is named. */
|
|
91
|
+
export declare function accountAt(home: HomeFile, origin?: string): HomeAccount | null;
|
|
92
|
+
/** The home after a sign-in read `account` at `origin` (storage-2): the
|
|
93
|
+
* instance listed where it is not, after those that are — an origin
|
|
94
|
+
* that is none refused as a diagnostic of `file` — its entry signed in
|
|
95
|
+
* again, and a sign-in as another account than the one it lists refused
|
|
96
|
+
* with `InstanceRefused`. The caller checks the whole next file. */
|
|
97
|
+
export declare function withSignIn(home: HomeFile, origin: string, account: HomeAccount, file: string): HomeFile;
|
|
98
|
+
/** The home after the credential at an instance went while its account
|
|
99
|
+
* is kept (git-host-4, git-host-10): it reads signed out until its next
|
|
100
|
+
* sign-in. The default instance's where no origin is named; unchanged
|
|
101
|
+
* where none is listed or signed in. */
|
|
102
|
+
export declare function withSignOut(home: HomeFile, origin?: string): HomeFile;
|
|
103
|
+
/** The home after an instance signed out, or never signed in, is
|
|
104
|
+
* forgotten: its entry goes; one signed in is refused with
|
|
105
|
+
* `InstanceRefused`. Null where none is listed at that origin. */
|
|
106
|
+
export declare function withoutInstance(home: HomeFile, origin: string): HomeFile | null;
|
|
107
|
+
/** The home with an instance's display name as last read; null where it
|
|
108
|
+
* is not listed. */
|
|
109
|
+
export declare function withDisplayName(home: HomeFile, origin: string, displayName: string | null): HomeFile | null;
|
|
110
|
+
/** The path of a home's file. */
|
|
111
|
+
export declare function homeFilePath(root: string): string;
|
|
112
|
+
/** A home's file as it stands, checked; null where none stands. */
|
|
113
|
+
export declare function readHomeFile(root: string, checkFolders?: FoldersCheck): HomeFile | null;
|
|
114
|
+
/**
|
|
115
|
+
* Change a home's file in one step (DR-111, DR-165): read at its version
|
|
116
|
+
* — a new home where none stands — changed, checked whole and written
|
|
117
|
+
* under the version read, so a writer that changed it meanwhile makes
|
|
118
|
+
* the write a `VersionConflictError` and nothing is lost. A change
|
|
119
|
+
* returning null writes nothing. Returns the file as it then stands.
|
|
120
|
+
*/
|
|
121
|
+
export declare function updateHomeFile(root: string, change: (home: HomeFile) => HomeFile | null, options?: {
|
|
122
|
+
env?: NodeJS.ProcessEnv;
|
|
123
|
+
checkFolders?: FoldersCheck;
|
|
124
|
+
}): HomeFile;
|
|
@@ -0,0 +1,288 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
// SPDX-FileCopyrightText: 2026 SubLang International <https://sublang.ai>
|
|
3
|
+
// The home file's encoding and its instances (storage-2, DR-103, DR-127,
|
|
4
|
+
// DR-165): `home.yaml` names this device, the origin the home was
|
|
5
|
+
// created with, every instance it has signed in to with its account,
|
|
6
|
+
// your own group's folder name, and each working folder paired with its
|
|
7
|
+
// spex repository's key. This module reads and checks the file, and
|
|
8
|
+
// adds, updates and removes an instance's entry; the pairings are the
|
|
9
|
+
// app's, which checks them where it reads them. Either host changes the
|
|
10
|
+
// file in one step — read, changed and written under the version read —
|
|
11
|
+
// so what one wrote the other sees at its next read.
|
|
12
|
+
import { randomUUID } from "node:crypto";
|
|
13
|
+
import { mkdirSync } from "node:fs";
|
|
14
|
+
import { userInfo } from "node:os";
|
|
15
|
+
import { join } from "node:path";
|
|
16
|
+
import { parse as parseYaml, stringify as stringifyYaml } from "yaml";
|
|
17
|
+
import { closed, isObject, isText, isUuid, knownFormat, need, readVersioned, StorageFormatError, writeVersionedBytes, } from "./files.js";
|
|
18
|
+
import { CLIENT_ID } from "./git-host.js";
|
|
19
|
+
import { canonicalOrigin, hostUrlFor, instanceFolder, instanceSegmentOf, OriginRefused } from "./instance.js";
|
|
20
|
+
import { words } from "./words.js";
|
|
21
|
+
export { CLIENT_ID };
|
|
22
|
+
export const HOME_FILE = "home.yaml";
|
|
23
|
+
const GROUP_NAME = /^[a-z0-9][a-z0-9-]*$/;
|
|
24
|
+
/** Why an instance operation was refused (DR-127):
|
|
25
|
+
* - `another-account`: a sign-in to a listed instance as another account;
|
|
26
|
+
* - `signed-in`: Forget of an instance still signed in.
|
|
27
|
+
* The message is the library's own; the reader's words are composed
|
|
28
|
+
* where each host speaks. */
|
|
29
|
+
export class InstanceRefused extends Error {
|
|
30
|
+
reason;
|
|
31
|
+
origin;
|
|
32
|
+
constructor(reason, origin) {
|
|
33
|
+
super(reason === "another-account" ? `${origin} is signed in as another account` : `${origin} is signed in`);
|
|
34
|
+
this.reason = reason;
|
|
35
|
+
this.origin = origin;
|
|
36
|
+
this.name = "InstanceRefused";
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
/** Lowercase kebab-case: runs of anything else become one hyphen. */
|
|
40
|
+
export function kebab(value) {
|
|
41
|
+
return value.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
|
|
42
|
+
}
|
|
43
|
+
/** This device's user name as a group folder name (storage-2). */
|
|
44
|
+
export function defaultOwnName(env = process.env) {
|
|
45
|
+
let name = "";
|
|
46
|
+
try {
|
|
47
|
+
name = userInfo().username;
|
|
48
|
+
}
|
|
49
|
+
catch {
|
|
50
|
+
name = env.USER ?? env.USERNAME ?? "";
|
|
51
|
+
}
|
|
52
|
+
return kebab(name) || "me";
|
|
53
|
+
}
|
|
54
|
+
/** Whether a name may stand as a group folder under `workspace/`. */
|
|
55
|
+
export function isGroupName(value) {
|
|
56
|
+
return GROUP_NAME.test(value);
|
|
57
|
+
}
|
|
58
|
+
export const invalidHome = () => words().invalidHome();
|
|
59
|
+
/** A URL shown in a diagnostic: any user info it carries, which may hold
|
|
60
|
+
* a secret, stands as `…`. */
|
|
61
|
+
function shownUrl(url) {
|
|
62
|
+
return url.replace(/^([a-z][a-z0-9+.-]*:\/\/)[^/?#]*@/i, "$1…@");
|
|
63
|
+
}
|
|
64
|
+
/** The reason a URL stands as no instance's canonical origin (DR-127). */
|
|
65
|
+
export function notAnOrigin(url) {
|
|
66
|
+
return words().notAnOrigin(shownUrl(url));
|
|
67
|
+
}
|
|
68
|
+
/** Whether a value is an instance's origin as it is recorded: canonical. */
|
|
69
|
+
function isOrigin(value) {
|
|
70
|
+
if (!isText(value))
|
|
71
|
+
return false;
|
|
72
|
+
try {
|
|
73
|
+
return canonicalOrigin(value) === value;
|
|
74
|
+
}
|
|
75
|
+
catch {
|
|
76
|
+
return false;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
/** `home.yaml`'s format, refused unless it is this Spex's: format 1 says
|
|
80
|
+
* the instances migration has not run (storage-1). */
|
|
81
|
+
function homeFormat(value, file) {
|
|
82
|
+
need(value.format !== 1, file, words().homeBeforeInstances());
|
|
83
|
+
knownFormat(value, file, 2);
|
|
84
|
+
}
|
|
85
|
+
function parseAccount(value, file) {
|
|
86
|
+
closed(value, ["id", "login", "displayName"], [], file);
|
|
87
|
+
need(isText(value.id) && isText(value.login) && (value.displayName === null || typeof value.displayName === "string"), file, invalidHome());
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* `home.yaml`'s value checked field by field (storage-2): its format,
|
|
91
|
+
* device, origin, your own group's name and every instance's entry —
|
|
92
|
+
* one per origin, and no two origins at one folder — and the pairings a
|
|
93
|
+
* list, each entry checked by `checkFolders` where the host supplies it.
|
|
94
|
+
* A malformed or unknown file is refused, never guessed at.
|
|
95
|
+
*/
|
|
96
|
+
export function parseHomeFile(value, file, checkFolders) {
|
|
97
|
+
need(isObject(value), file, invalidHome());
|
|
98
|
+
homeFormat(value, file);
|
|
99
|
+
closed(value, ["format", "device", "origin", "instances", "own", "folders"], [], file);
|
|
100
|
+
need(isUuid(value.device) && typeof value.own === "string" && GROUP_NAME.test(value.own) &&
|
|
101
|
+
Array.isArray(value.instances) && Array.isArray(value.folders) && isText(value.origin), file, invalidHome());
|
|
102
|
+
need(isOrigin(value.origin), file, notAnOrigin(value.origin));
|
|
103
|
+
const folders = new Map();
|
|
104
|
+
for (const instance of value.instances) {
|
|
105
|
+
closed(instance, ["origin", "clientId", "account"], ["signedOut", "displayName"], file);
|
|
106
|
+
need(isText(instance.origin) && instance.clientId === CLIENT_ID &&
|
|
107
|
+
(instance.signedOut === undefined || typeof instance.signedOut === "boolean") &&
|
|
108
|
+
(instance.displayName === undefined || typeof instance.displayName === "string"), file, invalidHome());
|
|
109
|
+
need(isOrigin(instance.origin), file, notAnOrigin(instance.origin));
|
|
110
|
+
parseAccount(instance.account, file);
|
|
111
|
+
// One entry per origin, and no two origins at one folder (DR-127).
|
|
112
|
+
const folder = instanceFolder(instance.origin);
|
|
113
|
+
const first = folders.get(folder);
|
|
114
|
+
need(first === undefined, file, words().instancesShareFolder(first ?? "", instance.origin, folder));
|
|
115
|
+
folders.set(folder, instance.origin);
|
|
116
|
+
}
|
|
117
|
+
checkFolders?.(value.folders, file);
|
|
118
|
+
return value;
|
|
119
|
+
}
|
|
120
|
+
/** `home.yaml`'s value from its text; text that will not read is
|
|
121
|
+
* refused as a storage diagnostic of the file. */
|
|
122
|
+
export function parseHomeText(text, file, checkFolders) {
|
|
123
|
+
let value;
|
|
124
|
+
try {
|
|
125
|
+
value = parseYaml(text);
|
|
126
|
+
}
|
|
127
|
+
catch (error) {
|
|
128
|
+
throw new StorageFormatError(file, error.message);
|
|
129
|
+
}
|
|
130
|
+
return parseHomeFile(value, file, checkFolders);
|
|
131
|
+
}
|
|
132
|
+
/** The canonical origin a caller names, or the refusal of one that is
|
|
133
|
+
* none as a storage diagnostic of `file`. */
|
|
134
|
+
function originOf(origin, file) {
|
|
135
|
+
try {
|
|
136
|
+
return canonicalOrigin(origin);
|
|
137
|
+
}
|
|
138
|
+
catch (error) {
|
|
139
|
+
if (!(error instanceof OriginRefused))
|
|
140
|
+
throw error;
|
|
141
|
+
throw new StorageFormatError(file, notAnOrigin(origin));
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
/** A new home, not yet written: a fresh device id unless one is
|
|
145
|
+
* supplied, the origin the environment names, no instance signed in
|
|
146
|
+
* to, and this device's user name as your own group. A URL the
|
|
147
|
+
* environment names that is no instance's origin is refused as a
|
|
148
|
+
* storage diagnostic of `file`. */
|
|
149
|
+
export function newHomeFile(file, options = {}) {
|
|
150
|
+
const own = options.own ?? defaultOwnName(options.env);
|
|
151
|
+
let origin;
|
|
152
|
+
try {
|
|
153
|
+
origin = hostUrlFor(options.env);
|
|
154
|
+
}
|
|
155
|
+
catch (error) {
|
|
156
|
+
if (!(error instanceof OriginRefused))
|
|
157
|
+
throw error;
|
|
158
|
+
throw new StorageFormatError(file, notAnOrigin((options.env ?? process.env).SPEX_HOST_URL?.trim() ?? ""));
|
|
159
|
+
}
|
|
160
|
+
return { format: 2, device: options.device ?? randomUUID(), origin, instances: [], own, folders: [] };
|
|
161
|
+
}
|
|
162
|
+
// -- instances (DR-127) ------------------------------------------------------
|
|
163
|
+
/** The listed entry at an origin in any spelling; -1 where none, or
|
|
164
|
+
* where the value is no origin. */
|
|
165
|
+
function indexOf(home, origin) {
|
|
166
|
+
let canonical;
|
|
167
|
+
try {
|
|
168
|
+
canonical = canonicalOrigin(origin);
|
|
169
|
+
}
|
|
170
|
+
catch {
|
|
171
|
+
return -1;
|
|
172
|
+
}
|
|
173
|
+
return home.instances.findIndex((entry) => entry.origin === canonical);
|
|
174
|
+
}
|
|
175
|
+
/** The default instance: the first listed, else the origin the home
|
|
176
|
+
* was created with. */
|
|
177
|
+
export function defaultInstanceOf(home) {
|
|
178
|
+
const first = home.instances[0];
|
|
179
|
+
return first ? structuredClone(first) : { origin: home.origin, clientId: CLIENT_ID };
|
|
180
|
+
}
|
|
181
|
+
/** The listed instance at an origin, in any spelling of it. */
|
|
182
|
+
export function instanceAt(home, origin) {
|
|
183
|
+
const index = indexOf(home, origin);
|
|
184
|
+
return index < 0 ? undefined : structuredClone(home.instances[index]);
|
|
185
|
+
}
|
|
186
|
+
/** The instance whose folder under `workspace/` is `folder`: a listed
|
|
187
|
+
* one, else the origin the home was created with. */
|
|
188
|
+
export function instanceByFolder(home, folder) {
|
|
189
|
+
const listed = home.instances.find((entry) => instanceFolder(entry.origin) === folder);
|
|
190
|
+
if (listed)
|
|
191
|
+
return structuredClone(listed);
|
|
192
|
+
return instanceFolder(home.origin) === folder ? { origin: home.origin, clientId: CLIENT_ID } : undefined;
|
|
193
|
+
}
|
|
194
|
+
/** The instance whose folder a key lies in; none for a key outside
|
|
195
|
+
* every instance's folder. */
|
|
196
|
+
export function instanceOfKey(home, key) {
|
|
197
|
+
const folder = instanceSegmentOf(key);
|
|
198
|
+
return folder === null ? undefined : instanceByFolder(home, folder);
|
|
199
|
+
}
|
|
200
|
+
/** The account at an instance while it is signed in there; the
|
|
201
|
+
* default instance where no origin is named. */
|
|
202
|
+
export function accountAt(home, origin) {
|
|
203
|
+
const index = indexOf(home, origin ?? defaultInstanceOf(home).origin);
|
|
204
|
+
const entry = index < 0 ? undefined : home.instances[index];
|
|
205
|
+
return entry?.account && entry.signedOut !== true ? structuredClone(entry.account) : null;
|
|
206
|
+
}
|
|
207
|
+
/** The home after a sign-in read `account` at `origin` (storage-2): the
|
|
208
|
+
* instance listed where it is not, after those that are — an origin
|
|
209
|
+
* that is none refused as a diagnostic of `file` — its entry signed in
|
|
210
|
+
* again, and a sign-in as another account than the one it lists refused
|
|
211
|
+
* with `InstanceRefused`. The caller checks the whole next file. */
|
|
212
|
+
export function withSignIn(home, origin, account, file) {
|
|
213
|
+
const canonical = originOf(origin, file);
|
|
214
|
+
const index = indexOf(home, canonical);
|
|
215
|
+
const prior = index < 0 ? undefined : home.instances[index];
|
|
216
|
+
if (prior?.account && prior.account.id !== account.id)
|
|
217
|
+
throw new InstanceRefused("another-account", canonical);
|
|
218
|
+
const entry = {
|
|
219
|
+
origin: canonical, clientId: CLIENT_ID,
|
|
220
|
+
account: { id: account.id, login: account.login, displayName: account.displayName },
|
|
221
|
+
...(prior?.displayName !== undefined ? { displayName: prior.displayName } : {}),
|
|
222
|
+
};
|
|
223
|
+
const instances = index < 0 ? [...home.instances, entry] : home.instances.map((item, at) => at === index ? entry : item);
|
|
224
|
+
return { ...home, instances };
|
|
225
|
+
}
|
|
226
|
+
/** The home after the credential at an instance went while its account
|
|
227
|
+
* is kept (git-host-4, git-host-10): it reads signed out until its next
|
|
228
|
+
* sign-in. The default instance's where no origin is named; unchanged
|
|
229
|
+
* where none is listed or signed in. */
|
|
230
|
+
export function withSignOut(home, origin) {
|
|
231
|
+
const index = indexOf(home, origin ?? defaultInstanceOf(home).origin);
|
|
232
|
+
if (index < 0 || !home.instances[index].account)
|
|
233
|
+
return home;
|
|
234
|
+
return { ...home, instances: home.instances.map((item, at) => at === index ? { ...item, signedOut: true } : item) };
|
|
235
|
+
}
|
|
236
|
+
/** The home after an instance signed out, or never signed in, is
|
|
237
|
+
* forgotten: its entry goes; one signed in is refused with
|
|
238
|
+
* `InstanceRefused`. Null where none is listed at that origin. */
|
|
239
|
+
export function withoutInstance(home, origin) {
|
|
240
|
+
const index = indexOf(home, origin);
|
|
241
|
+
if (index < 0)
|
|
242
|
+
return null;
|
|
243
|
+
const entry = home.instances[index];
|
|
244
|
+
if (entry.account && entry.signedOut !== true)
|
|
245
|
+
throw new InstanceRefused("signed-in", entry.origin);
|
|
246
|
+
return { ...home, instances: home.instances.filter((_, at) => at !== index) };
|
|
247
|
+
}
|
|
248
|
+
/** The home with an instance's display name as last read; null where it
|
|
249
|
+
* is not listed. */
|
|
250
|
+
export function withDisplayName(home, origin, displayName) {
|
|
251
|
+
const index = indexOf(home, origin);
|
|
252
|
+
if (index < 0)
|
|
253
|
+
return null;
|
|
254
|
+
const { displayName: _, ...rest } = home.instances[index];
|
|
255
|
+
const entry = displayName === null ? rest : { ...rest, displayName };
|
|
256
|
+
return { ...home, instances: home.instances.map((item, at) => at === index ? entry : item) };
|
|
257
|
+
}
|
|
258
|
+
// -- one step ----------------------------------------------------------------
|
|
259
|
+
/** The path of a home's file. */
|
|
260
|
+
export function homeFilePath(root) {
|
|
261
|
+
return join(root, HOME_FILE);
|
|
262
|
+
}
|
|
263
|
+
/** A home's file as it stands, checked; null where none stands. */
|
|
264
|
+
export function readHomeFile(root, checkFolders) {
|
|
265
|
+
const file = homeFilePath(root);
|
|
266
|
+
const { bytes } = readVersioned(file);
|
|
267
|
+
return bytes === null ? null : parseHomeText(bytes.toString("utf8"), file, checkFolders);
|
|
268
|
+
}
|
|
269
|
+
/**
|
|
270
|
+
* Change a home's file in one step (DR-111, DR-165): read at its version
|
|
271
|
+
* — a new home where none stands — changed, checked whole and written
|
|
272
|
+
* under the version read, so a writer that changed it meanwhile makes
|
|
273
|
+
* the write a `VersionConflictError` and nothing is lost. A change
|
|
274
|
+
* returning null writes nothing. Returns the file as it then stands.
|
|
275
|
+
*/
|
|
276
|
+
export function updateHomeFile(root, change, options = {}) {
|
|
277
|
+
const file = homeFilePath(root);
|
|
278
|
+
const { bytes, version } = readVersioned(file);
|
|
279
|
+
const current = bytes === null ? newHomeFile(file, { env: options.env }) : parseHomeText(bytes.toString("utf8"), file, options.checkFolders);
|
|
280
|
+
const next = change(structuredClone(current));
|
|
281
|
+
if (next === null)
|
|
282
|
+
return current;
|
|
283
|
+
parseHomeFile(next, file, options.checkFolders);
|
|
284
|
+
mkdirSync(root, { recursive: true, mode: 0o700 });
|
|
285
|
+
writeVersionedBytes(file, stringifyYaml(next), version);
|
|
286
|
+
return next;
|
|
287
|
+
}
|
|
288
|
+
//# sourceMappingURL=home-file.js.map
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/** The instance a new home records unless `SPEX_HOST_URL` names another
|
|
2
|
+
* (git-host-1). */
|
|
3
|
+
export declare const DEFAULT_HOST_URL = "https://spex.sublang.ai";
|
|
4
|
+
/** An instance's folder under `workspace/` (DR-127): `@`, its host in
|
|
5
|
+
* lowercase — labels joined by single dots, none leading or trailing —
|
|
6
|
+
* and `_<port>` where its origin names a port or its scheme is `http`:
|
|
7
|
+
* `@spex.sublang.ai`, `@127.0.0.1_4100`. The core's protocol spells the
|
|
8
|
+
* same pattern for the keys it carries; a test of the core holds the two
|
|
9
|
+
* equal. */
|
|
10
|
+
export declare const INSTANCE_FOLDER_PATTERN: RegExp;
|
|
11
|
+
/** Why a URL stands as no instance's origin:
|
|
12
|
+
* - `invalid`: it does not parse as a URL;
|
|
13
|
+
* - `scheme`: its scheme is neither `http` nor `https`;
|
|
14
|
+
* - `user`: it carries a user or a password;
|
|
15
|
+
* - `path`: it names a path other than `/`;
|
|
16
|
+
* - `query`: it carries a query, even an empty one;
|
|
17
|
+
* - `fragment`: it carries a fragment, even an empty one;
|
|
18
|
+
* - `host`: its host is not DNS labels of `[a-z0-9-]`, none starting
|
|
19
|
+
* or ending with `-`, joined by single dots with none leading or
|
|
20
|
+
* trailing — a host holding `_` or an IPv6 literal among them;
|
|
21
|
+
* - `port`: it names port 0;
|
|
22
|
+
* - `insecure`: it is `http` on a host that is not loopback —
|
|
23
|
+
* `localhost` or an address in 127.0.0.0/8. */
|
|
24
|
+
export type OriginRefusal = "invalid" | "scheme" | "user" | "path" | "query" | "fragment" | "host" | "port" | "insecure";
|
|
25
|
+
/** A URL refused as an instance's origin, with its reason. The message
|
|
26
|
+
* never repeats the URL, which may carry a secret in its user info. */
|
|
27
|
+
export declare class OriginRefused extends Error {
|
|
28
|
+
readonly reason: OriginRefusal;
|
|
29
|
+
constructor(reason: OriginRefusal);
|
|
30
|
+
}
|
|
31
|
+
/** An instance's origin in its parts: `port` null where it is the
|
|
32
|
+
* scheme's default. */
|
|
33
|
+
export interface InstanceOrigin {
|
|
34
|
+
origin: string;
|
|
35
|
+
scheme: "http" | "https";
|
|
36
|
+
host: string;
|
|
37
|
+
port: number | null;
|
|
38
|
+
}
|
|
39
|
+
/** The origin a URL names, canonical, or `OriginRefused` with the first
|
|
40
|
+
* reason found among its scheme, user info, path, query, fragment, host
|
|
41
|
+
* and port, in that order. */
|
|
42
|
+
export declare function parseOrigin(value: string): InstanceOrigin;
|
|
43
|
+
/** The canonical origin a URL names (`OriginRefused` where it names
|
|
44
|
+
* none): `HTTPS://Spex.Sublang.Ai:443/` is `https://spex.sublang.ai`. */
|
|
45
|
+
export declare function canonicalOrigin(value: string): string;
|
|
46
|
+
/** The folder under `workspace/` of the instance a URL names
|
|
47
|
+
* (`OriginRefused` where it names none): `@spex.sublang.ai` for
|
|
48
|
+
* `https://spex.sublang.ai`, `@127.0.0.1_4100` for `http://127.0.0.1:4100`,
|
|
49
|
+
* `@localhost_80` for `http://localhost`. */
|
|
50
|
+
export declare function instanceFolder(value: string): string;
|
|
51
|
+
/** Whether a path segment stands as an instance's folder. */
|
|
52
|
+
export declare function isInstanceFolder(value: string): boolean;
|
|
53
|
+
/** The instance folder a key begins with — `@spex.sublang.ai` of
|
|
54
|
+
* `@spex.sublang.ai/acme/a-spex` — or null for a key outside every instance's
|
|
55
|
+
* folder, as your own group's and the local-only clones' are. */
|
|
56
|
+
export declare function instanceSegmentOf(key: string): string | null;
|
|
57
|
+
/**
|
|
58
|
+
* The instance a home names (git-host-1), as its canonical origin: a
|
|
59
|
+
* home that already records one keeps it whatever the environment says;
|
|
60
|
+
* a new home takes a nonempty `SPEX_HOST_URL`, else spex.sublang.ai. A URL the
|
|
61
|
+
* origin rule refuses throws `OriginRefused`.
|
|
62
|
+
*/
|
|
63
|
+
export declare function hostUrlFor(env?: NodeJS.ProcessEnv, existing?: string | null): string;
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
// SPDX-FileCopyrightText: 2026 SubLang International <https://sublang.ai>
|
|
3
|
+
// Instances by their origin (DR-127): an instance is recorded by its
|
|
4
|
+
// origin — the scheme, the host in lowercase, and the port where it is
|
|
5
|
+
// not the scheme's default — so one instance never stands twice under
|
|
6
|
+
// two spellings, and every spex repository at it lies under its folder,
|
|
7
|
+
// `@<host>` with `_<port>` where the origin names a port or its scheme
|
|
8
|
+
// is `http`. A folder names no scheme, so it is never read back into an
|
|
9
|
+
// origin: a clone's instance is the listed instance whose folder its key
|
|
10
|
+
// begins with. This module composes no reader-facing prose: a refusal
|
|
11
|
+
// carries its reason, which the core phrases where it speaks.
|
|
12
|
+
/** The instance a new home records unless `SPEX_HOST_URL` names another
|
|
13
|
+
* (git-host-1). */
|
|
14
|
+
export const DEFAULT_HOST_URL = "https://spex.sublang.ai";
|
|
15
|
+
/** A DNS label in lowercase: letters, digits and `-`, neither first nor
|
|
16
|
+
* last a hyphen. */
|
|
17
|
+
const HOST_LABEL = "[a-z0-9](?:[a-z0-9-]*[a-z0-9])?";
|
|
18
|
+
/** A port from 1 to 65535, written without a leading zero. */
|
|
19
|
+
const PORT = "(?:[1-9][0-9]{0,3}|[1-5][0-9]{4}|6[0-4][0-9]{3}|65[0-4][0-9]{2}|655[0-2][0-9]|6553[0-5])";
|
|
20
|
+
/** An instance's folder under `workspace/` (DR-127): `@`, its host in
|
|
21
|
+
* lowercase — labels joined by single dots, none leading or trailing —
|
|
22
|
+
* and `_<port>` where its origin names a port or its scheme is `http`:
|
|
23
|
+
* `@spex.sublang.ai`, `@127.0.0.1_4100`. The core's protocol spells the
|
|
24
|
+
* same pattern for the keys it carries; a test of the core holds the two
|
|
25
|
+
* equal. */
|
|
26
|
+
export const INSTANCE_FOLDER_PATTERN = new RegExp(`^@${HOST_LABEL}(?:\\.${HOST_LABEL})*(?:_${PORT})?$`);
|
|
27
|
+
const LOOPBACK_V4 = /^127\.\d{1,3}\.\d{1,3}\.\d{1,3}$/;
|
|
28
|
+
const REFUSALS = {
|
|
29
|
+
invalid: "not a URL",
|
|
30
|
+
scheme: "the scheme is neither http nor https",
|
|
31
|
+
user: "the URL carries a user or a password",
|
|
32
|
+
path: "the URL names a path",
|
|
33
|
+
query: "the URL carries a query",
|
|
34
|
+
fragment: "the URL carries a fragment",
|
|
35
|
+
host: "the host is not DNS labels of [a-z0-9-] joined by single dots",
|
|
36
|
+
port: "the port is not from 1 to 65535",
|
|
37
|
+
insecure: "http on a host that is not loopback",
|
|
38
|
+
};
|
|
39
|
+
/** A URL refused as an instance's origin, with its reason. The message
|
|
40
|
+
* never repeats the URL, which may carry a secret in its user info. */
|
|
41
|
+
export class OriginRefused extends Error {
|
|
42
|
+
reason;
|
|
43
|
+
constructor(reason) {
|
|
44
|
+
super(`origin refused: ${REFUSALS[reason]}`);
|
|
45
|
+
this.name = "OriginRefused";
|
|
46
|
+
this.reason = reason;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
/** The origin a URL names, canonical, or `OriginRefused` with the first
|
|
50
|
+
* reason found among its scheme, user info, path, query, fragment, host
|
|
51
|
+
* and port, in that order. */
|
|
52
|
+
export function parseOrigin(value) {
|
|
53
|
+
let url;
|
|
54
|
+
try {
|
|
55
|
+
url = new URL(value.trim());
|
|
56
|
+
}
|
|
57
|
+
catch {
|
|
58
|
+
throw new OriginRefused("invalid");
|
|
59
|
+
}
|
|
60
|
+
if (url.protocol !== "http:" && url.protocol !== "https:")
|
|
61
|
+
throw new OriginRefused("scheme");
|
|
62
|
+
if (url.username !== "" || url.password !== "")
|
|
63
|
+
throw new OriginRefused("user");
|
|
64
|
+
if (url.pathname !== "/")
|
|
65
|
+
throw new OriginRefused("path");
|
|
66
|
+
// An empty query or fragment parses to an empty `search` or `hash`
|
|
67
|
+
// but stays in `href`, after the path.
|
|
68
|
+
const rest = url.href.slice(`${url.protocol}//${url.host}/`.length);
|
|
69
|
+
if (rest.startsWith("?"))
|
|
70
|
+
throw new OriginRefused("query");
|
|
71
|
+
if (rest.startsWith("#"))
|
|
72
|
+
throw new OriginRefused("fragment");
|
|
73
|
+
// The parser has lowercased the host, mapped it to ASCII, and read the
|
|
74
|
+
// port as a number up to 65535, dropping a default one and any leading
|
|
75
|
+
// zero; the host's folder is then the instance's folder's own spelling.
|
|
76
|
+
const host = url.hostname;
|
|
77
|
+
if (!INSTANCE_FOLDER_PATTERN.test(`@${host}`))
|
|
78
|
+
throw new OriginRefused("host");
|
|
79
|
+
const port = url.port === "" ? null : Number(url.port);
|
|
80
|
+
if (port === 0)
|
|
81
|
+
throw new OriginRefused("port");
|
|
82
|
+
const scheme = url.protocol === "http:" ? "http" : "https";
|
|
83
|
+
if (scheme === "http" && !isLoopback(host))
|
|
84
|
+
throw new OriginRefused("insecure");
|
|
85
|
+
return { origin: `${scheme}://${host}${port === null ? "" : `:${port}`}`, scheme, host, port };
|
|
86
|
+
}
|
|
87
|
+
/** The canonical origin a URL names (`OriginRefused` where it names
|
|
88
|
+
* none): `HTTPS://Spex.Sublang.Ai:443/` is `https://spex.sublang.ai`. */
|
|
89
|
+
export function canonicalOrigin(value) {
|
|
90
|
+
return parseOrigin(value).origin;
|
|
91
|
+
}
|
|
92
|
+
/** The folder under `workspace/` of the instance a URL names
|
|
93
|
+
* (`OriginRefused` where it names none): `@spex.sublang.ai` for
|
|
94
|
+
* `https://spex.sublang.ai`, `@127.0.0.1_4100` for `http://127.0.0.1:4100`,
|
|
95
|
+
* `@localhost_80` for `http://localhost`. */
|
|
96
|
+
export function instanceFolder(value) {
|
|
97
|
+
const { scheme, host, port } = parseOrigin(value);
|
|
98
|
+
const named = port ?? (scheme === "http" ? 80 : null);
|
|
99
|
+
return named === null ? `@${host}` : `@${host}_${named}`;
|
|
100
|
+
}
|
|
101
|
+
/** Whether a path segment stands as an instance's folder. */
|
|
102
|
+
export function isInstanceFolder(value) {
|
|
103
|
+
return INSTANCE_FOLDER_PATTERN.test(value);
|
|
104
|
+
}
|
|
105
|
+
/** The instance folder a key begins with — `@spex.sublang.ai` of
|
|
106
|
+
* `@spex.sublang.ai/acme/a-spex` — or null for a key outside every instance's
|
|
107
|
+
* folder, as your own group's and the local-only clones' are. */
|
|
108
|
+
export function instanceSegmentOf(key) {
|
|
109
|
+
const at = key.indexOf("/");
|
|
110
|
+
if (at < 0)
|
|
111
|
+
return null;
|
|
112
|
+
const segment = key.slice(0, at);
|
|
113
|
+
return isInstanceFolder(segment) ? segment : null;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* The instance a home names (git-host-1), as its canonical origin: a
|
|
117
|
+
* home that already records one keeps it whatever the environment says;
|
|
118
|
+
* a new home takes a nonempty `SPEX_HOST_URL`, else spex.sublang.ai. A URL the
|
|
119
|
+
* origin rule refuses throws `OriginRefused`.
|
|
120
|
+
*/
|
|
121
|
+
export function hostUrlFor(env = process.env, existing) {
|
|
122
|
+
if (typeof existing === "string" && existing.trim().length > 0)
|
|
123
|
+
return canonicalOrigin(existing);
|
|
124
|
+
const fromEnv = env.SPEX_HOST_URL?.trim();
|
|
125
|
+
return canonicalOrigin(fromEnv ? fromEnv : DEFAULT_HOST_URL);
|
|
126
|
+
}
|
|
127
|
+
function isLoopback(host) {
|
|
128
|
+
return host === "localhost" || LOOPBACK_V4.test(host);
|
|
129
|
+
}
|
|
130
|
+
//# sourceMappingURL=instance.js.map
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/** Every phrase the library composes. */
|
|
2
|
+
export interface LibraryWords {
|
|
3
|
+
/** Separates names listed in one message. */
|
|
4
|
+
listSeparator(): string;
|
|
5
|
+
/** A storage fault as one line: the file, then the reason. */
|
|
6
|
+
storageFault(file: string, reason: string): string;
|
|
7
|
+
/** A record in a file is not an object. */
|
|
8
|
+
expectedObject(): string;
|
|
9
|
+
/** A closed record's fields; `optional` is `optionalFields(...)` or empty. */
|
|
10
|
+
expectedFields(required: string, optional: string): string;
|
|
11
|
+
/** The clause naming the fields a record may also carry. */
|
|
12
|
+
optionalFields(fields: string): string;
|
|
13
|
+
/** A file names a layout version this Spex does not read. */
|
|
14
|
+
unsupportedFormat(format: string): string;
|
|
15
|
+
/** A file names a layout version that is no number. */
|
|
16
|
+
unsupportedUnnamedFormat(): string;
|
|
17
|
+
/** A file changed between a read and a write under its version. */
|
|
18
|
+
changedMeanwhile(file: string): string;
|
|
19
|
+
/** `home.yaml`'s own fields are malformed. */
|
|
20
|
+
invalidHome(): string;
|
|
21
|
+
/** A URL is not a Space's address written canonically. */
|
|
22
|
+
notAnOrigin(url: string): string;
|
|
23
|
+
/** `home.yaml` still holds the layout before the instances migration. */
|
|
24
|
+
homeBeforeInstances(): string;
|
|
25
|
+
/** Two instances `home.yaml` lists would share one folder. */
|
|
26
|
+
instancesShareFolder(first: string, second: string, folder: string): string;
|
|
27
|
+
}
|
|
28
|
+
/** The phrasing in force. */
|
|
29
|
+
export declare function words(): LibraryWords;
|
|
30
|
+
/** Install a host's phrasing, every phrase named: a host never leaves
|
|
31
|
+
* one to read in English unnoticed. */
|
|
32
|
+
export declare function phraseLibrary(phrasing: LibraryWords): void;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
// SPDX-FileCopyrightText: 2026 SubLang International <https://sublang.ai>
|
|
3
|
+
const ENGLISH = {
|
|
4
|
+
listSeparator: () => ", ",
|
|
5
|
+
storageFault: (file, reason) => `${file}: ${reason}`,
|
|
6
|
+
expectedObject: () => "expected an object",
|
|
7
|
+
expectedFields: (required, optional) => `expected fields ${required}${optional}`,
|
|
8
|
+
optionalFields: (fields) => `; optional ${fields}`,
|
|
9
|
+
unsupportedFormat: (format) => `unsupported format ${format}; preserved unchanged`,
|
|
10
|
+
unsupportedUnnamedFormat: () => "unsupported format; preserved unchanged",
|
|
11
|
+
changedMeanwhile: (file) => `${file} changed meanwhile; retry`,
|
|
12
|
+
invalidHome: () => "invalid fields",
|
|
13
|
+
notAnOrigin: (url) => `${url} is not a Space's address`,
|
|
14
|
+
homeBeforeInstances: () => "format 1: the migration to several Spaces has not run; preserved unchanged",
|
|
15
|
+
instancesShareFolder: (first, second, folder) => `Spaces ${first} and ${second} share the folder ${folder}`,
|
|
16
|
+
};
|
|
17
|
+
let current = ENGLISH;
|
|
18
|
+
/** The phrasing in force. */
|
|
19
|
+
export function words() {
|
|
20
|
+
return current;
|
|
21
|
+
}
|
|
22
|
+
/** Install a host's phrasing, every phrase named: a host never leaves
|
|
23
|
+
* one to read in English unnoticed. */
|
|
24
|
+
export function phraseLibrary(phrasing) {
|
|
25
|
+
current = { ...phrasing };
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=words.js.map
|