@vite-hub/forge 0.1.0 → 0.3.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 +43 -7
- package/dist/{association-Cm0dUTDU-CDDhJnIh.js → association-Ds6Tgs0W-Cu9_YCGq.js} +1 -1
- package/dist/build/node.d.ts +12 -0
- package/dist/build/node.js +106 -0
- package/dist/build.d.ts +2 -0
- package/dist/build.js +2 -0
- package/dist/{events-saDWbqbf-VX_k8jtr.js → events-C6C7lk1x-J8VCAjEX.js} +4 -4
- package/dist/{events-DudKM7vq-Cj_PCDdt.js → events-DW3SFUDA-D2rhS9D-.js} +4 -4
- package/dist/{events-CeChclTf-CX-gD8oy.js → events-DjRw3KSr-C72gY7Vu.js} +4 -4
- package/dist/{events-CRaLy7U3-3PNNp5WZ.js → events-DmSWTdpS-BdJBABfI.js} +4 -4
- package/dist/{events-7EBoeIPd-A2RUkJi5.js → events-uCMi3LHU-Bz79PQtq.js} +4 -4
- package/dist/{feed-Dyf730Ys-D0HgBba6.js → feed-BlzdKdNv-DbxuSgsx.js} +4 -4
- package/dist/{feed-DsC7Vws1-M_de2nSK.js → feed-BwdcTgZq-Bm_c8br8.js} +4 -4
- package/dist/{feed-CmBoYS3Z-CuC4i0fH.js → feed-CIaAZINm-Dpe9DxwK.js} +4 -4
- package/dist/{forgejo-BN8ItCfl.js → forgejo-UNPc42cY.js} +50 -8
- package/dist/{gitee-DExkQP6X-BxJS2dRY.js → gitee-BXyl2_3W-dQOAjWqr.js} +2 -2
- package/dist/{github-DtncTfmv.js → github-CUiEF2FK.js} +65 -40
- package/dist/{gitlab-BoDm8-BC.js → gitlab-zvWb9zOi.js} +65 -8
- package/dist/{graphql-DG5aJBT3-DceyFYdM.js → graphql-BDhuP5jN-BSpB8lWf.js} +59 -7
- package/dist/identity-CNTWZZuv.d.ts +27 -0
- package/dist/identity-CmVEBLP5.js +38 -0
- package/dist/index.d.ts +332 -110
- package/dist/index.js +815 -313
- package/dist/{knot-BpyTK9D7-CVIsX4I2.js → knot-bGebBK_B-CeDHcJUz.js} +16 -9
- package/dist/{tangled-DPt_0u21-zS41xdG5.js → tangled-8lg_73Wi-bSufNXiN.js} +1 -1
- package/dist/{templates-Bn8a-pd2-D9DhJEVD.js → templates-BGDqQMu4-PSB43E1j.js} +2 -2
- package/dist/{utils-CA_4WJhJ-DNgT61X2.js → utils-DC7MBR65-B7Vr2hFm.js} +3 -306
- package/dist/{webhooks-DgHwxxYz-D1V2LOr1.js → webhooks-Bc6QhmI8-CNgCERCq.js} +326 -5
- package/package.json +19 -8
|
@@ -1,7 +1,14 @@
|
|
|
1
|
-
import { $ as toDate, d as NotFoundError, g as UnsupportedOperationError, tt as toMergeError } from "./utils-
|
|
2
|
-
import { S as toFileContent, p as fromBase64 } from "./webhooks-
|
|
3
|
-
import { t as FORGE } from "./tangled-
|
|
4
|
-
|
|
1
|
+
import { $ as toDate, d as NotFoundError, g as UnsupportedOperationError, tt as toMergeError } from "./utils-DC7MBR65-B7Vr2hFm.js";
|
|
2
|
+
import { S as toFileContent, p as fromBase64 } from "./webhooks-Bc6QhmI8-CNgCERCq.js";
|
|
3
|
+
import { t as FORGE } from "./tangled-8lg_73Wi-bSufNXiN.js";
|
|
4
|
+
String.raw`[\w:.-]+\/[\w.-]+`;
|
|
5
|
+
/**
|
|
6
|
+
* The path of a repository's page. Tangled addresses a repository by its
|
|
7
|
+
* owner's handle, and redirects a path that names the owner's DID.
|
|
8
|
+
*/
|
|
9
|
+
const repoPath = (repo) => `/${encodeURIComponent(repo.ownerHandle ?? repo.owner).replaceAll("%3A", ":")}/${encodeURIComponent(repo.name)}`;
|
|
10
|
+
//#endregion
|
|
11
|
+
//#region ../../node_modules/.pnpm/forges@0.3.1/node_modules/forges/dist/knot-bGebBK_B.mjs
|
|
5
12
|
const DEFAULT_PAGE = 30;
|
|
6
13
|
const TREE_TYPES = {
|
|
7
14
|
"0040000": "directory",
|
|
@@ -109,7 +116,7 @@ function createTangledContents({ fetcher, instance, webUrl, context, canonicalRe
|
|
|
109
116
|
}
|
|
110
117
|
};
|
|
111
118
|
}
|
|
112
|
-
const pageUrl = (repo, section, ref, path) => `${webUrl}
|
|
119
|
+
const pageUrl = (repo, section, ref, path) => `${webUrl}${repoPath(repo)}/${section}/${encodeURIComponent(ref ?? "HEAD")}/${path.split("/").map(encodeURIComponent).join("/")}`;
|
|
113
120
|
function toCommit(repo, raw, files) {
|
|
114
121
|
const sha = raw.this ?? hex(raw.hash);
|
|
115
122
|
return {
|
|
@@ -124,7 +131,7 @@ function createTangledContents({ fetcher, instance, webUrl, context, canonicalRe
|
|
|
124
131
|
author: raw.author && signature(raw.author),
|
|
125
132
|
committer: raw.committer && signature(raw.committer),
|
|
126
133
|
parents: (raw.parent_hashes ?? []).map(hex),
|
|
127
|
-
url: `${webUrl}
|
|
134
|
+
url: `${webUrl}${repoPath(repo)}/commit/${sha}`,
|
|
128
135
|
...files ? {
|
|
129
136
|
files,
|
|
130
137
|
stats: stats(files)
|
|
@@ -154,7 +161,7 @@ function createTangledContents({ fetcher, instance, webUrl, context, canonicalRe
|
|
|
154
161
|
author: author || void 0,
|
|
155
162
|
committer: committer || void 0,
|
|
156
163
|
parents: [],
|
|
157
|
-
url: `${webUrl}
|
|
164
|
+
url: `${webUrl}${repoPath(repo)}/commit/${header.SHA}`,
|
|
158
165
|
files,
|
|
159
166
|
stats: stats(files),
|
|
160
167
|
raw: {
|
|
@@ -222,7 +229,7 @@ function createTangledContents({ fetcher, instance, webUrl, context, canonicalRe
|
|
|
222
229
|
name: branch.reference.name,
|
|
223
230
|
sha: branch.reference.hash,
|
|
224
231
|
isDefault: branch.is_default ?? false,
|
|
225
|
-
url: `${webUrl}
|
|
232
|
+
url: `${webUrl}${repoPath(knot.ref)}/tree/${encodeURIComponent(branch.reference.name)}`,
|
|
226
233
|
raw: {
|
|
227
234
|
...branch,
|
|
228
235
|
commit: void 0
|
|
@@ -240,7 +247,7 @@ function createTangledContents({ fetcher, instance, webUrl, context, canonicalRe
|
|
|
240
247
|
})).tags ?? []).map((tag) => ({
|
|
241
248
|
name: tag.name,
|
|
242
249
|
sha: tag.tag ? hex(tag.tag.Target) : tag.hash,
|
|
243
|
-
url: `${webUrl}
|
|
250
|
+
url: `${webUrl}${repoPath(knot.ref)}/tree/${encodeURIComponent(tag.name)}`,
|
|
244
251
|
raw: tag
|
|
245
252
|
})), offset, limit);
|
|
246
253
|
},
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
//#region ../../node_modules/.pnpm/forges@
|
|
1
|
+
//#region ../../node_modules/.pnpm/forges@0.3.1/node_modules/forges/dist/tangled-8lg_73Wi.mjs
|
|
2
2
|
const FORGE = "tangled";
|
|
3
3
|
const COLLECTIONS = {
|
|
4
4
|
repo: "sh.tangled.repo",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { I as mapConcurrent, d as NotFoundError } from "./utils-
|
|
2
|
-
//#region ../../node_modules/.pnpm/forges@
|
|
1
|
+
import { I as mapConcurrent, d as NotFoundError } from "./utils-DC7MBR65-B7Vr2hFm.js";
|
|
2
|
+
//#region ../../node_modules/.pnpm/forges@0.3.1/node_modules/forges/dist/templates-BGDqQMu4.mjs
|
|
3
3
|
/** Where GitHub looks for a pull request template and the legacy issue template, in its order of precedence. */
|
|
4
4
|
const LOCATIONS = [
|
|
5
5
|
".github",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
//#region ../../node_modules/.pnpm/forges@
|
|
1
|
+
//#region ../../node_modules/.pnpm/forges@0.3.1/node_modules/forges/dist/model-Lem-G1_9.mjs
|
|
2
2
|
/** Whether `support` means the operation cannot be called. Test this rather than `support === false`: `'not_applicable'` is a non-empty string. Accepts the declaration-only levels too, so a declared level can be tested before it resolves. */
|
|
3
3
|
function isUnsupported(support) {
|
|
4
4
|
return support === false || support === "not_applicable";
|
|
@@ -87,311 +87,8 @@ function namespaceRef(origin, owner) {
|
|
|
87
87
|
function isResolvedThread(thread) {
|
|
88
88
|
return typeof thread.number === "string" && thread.number !== "";
|
|
89
89
|
}
|
|
90
|
-
function sameRepo(a, b) {
|
|
91
|
-
if (!b || a.forge !== b.forge || a.instance !== b.instance) return false;
|
|
92
|
-
const [left, right] = [normaliseRepoName(a), normaliseRepoName(b)];
|
|
93
|
-
return left.owner === right.owner && left.name === right.name;
|
|
94
|
-
}
|
|
95
|
-
function lineOf(value) {
|
|
96
|
-
const line = Number.parseInt(value ?? "", 10);
|
|
97
|
-
return line > 0 ? { line } : {};
|
|
98
|
-
}
|
|
99
|
-
/** Reads `base...head` or `base..head`. Git forbids `..` in a ref name, so the first `..` separates the two. */
|
|
100
|
-
function rangeOf(value) {
|
|
101
|
-
const at = value.indexOf("..");
|
|
102
|
-
const base = value.slice(0, at);
|
|
103
|
-
const head = value.slice(value[at + 2] === "." ? at + 3 : at + 2);
|
|
104
|
-
return at > 0 && head ? { compare: {
|
|
105
|
-
base,
|
|
106
|
-
head
|
|
107
|
-
} } : {};
|
|
108
|
-
}
|
|
109
|
-
function encodePath(path) {
|
|
110
|
-
return path.split("/").map(encodeURIComponent).join("/");
|
|
111
|
-
}
|
|
112
|
-
function webUrlFor(web, target) {
|
|
113
|
-
if (("file" in target ? target.file : "raw" in target ? target.raw : "commit" in target ? target.commit : "compare" in target ? target.compare : void 0)?.repo.kind === "namespace") return;
|
|
114
|
-
let path;
|
|
115
|
-
if ("repo" in target) path = "section" in target && target.section ? web.section?.(target.repo, target.section) : web.repo(target.repo);
|
|
116
|
-
else if ("thread" in target) path = isResolvedThread(target.thread) ? web.thread(target.thread) : void 0;
|
|
117
|
-
else if ("comment" in target) {
|
|
118
|
-
const { comment } = target;
|
|
119
|
-
path = isResolvedThread(comment.thread) ? web.comment?.(comment) : void 0;
|
|
120
|
-
} else if ("release" in target) path = web.release?.(target.release);
|
|
121
|
-
else if ("file" in target) path = web.file?.(target.file.repo, target.file.path, target.file.at, target.file.line);
|
|
122
|
-
else if ("raw" in target) path = web.raw?.(target.raw.repo, target.raw.path, target.raw.at);
|
|
123
|
-
else if ("commit" in target) path = target.commit.sha ? web.commit?.(target.commit.repo, target.commit.sha) : void 0;
|
|
124
|
-
else path = web.compare?.(target.compare.repo, target.compare.base, target.compare.head);
|
|
125
|
-
return path === void 0 ? void 0 : path.startsWith("/") ? `${web.baseUrl}${path}` : path;
|
|
126
|
-
}
|
|
127
|
-
/** `ssh://user@host:port/path` or `git://host:port/path` with the host in group 1, or `user@host:path` with it in group 2; the path is group 3. */
|
|
128
|
-
const CLONE_URL_RE = /^(?:(?:ssh|git):\/\/(?:[^@/]+@)?([^:/]+)(?::\d+)?\/|(?:[^@/\s]+@)?([^:/\s]+):(?!\/))(.+)$/i;
|
|
129
|
-
/** The `git+` that npm's `repository` field writes before a transport scheme. */
|
|
130
|
-
const GIT_PLUS_RE = /^git\+(?=[a-z]+:\/\/)/i;
|
|
131
|
-
/** The npm `repository` shorthand, https://docs.npmjs.com/cli/configuring-npm/package-json#repository */
|
|
132
|
-
const SHORTHAND_RE = /^(github|gitlab|bitbucket):(?!\/)/i;
|
|
133
|
-
const SHORTHAND_HOSTS = {
|
|
134
|
-
github: "github.com",
|
|
135
|
-
gitlab: "gitlab.com",
|
|
136
|
-
bitbucket: "bitbucket.org"
|
|
137
|
-
};
|
|
138
|
-
function parseWebUrl(web, input, origin) {
|
|
139
|
-
const base = new URL(web.baseUrl);
|
|
140
|
-
const prefix = base.pathname.replace(/\/$/, "");
|
|
141
|
-
const source = String(input).replace(GIT_PLUS_RE, "").replace(SHORTHAND_RE, (_, forge) => `https://${SHORTHAND_HOSTS[forge.toLowerCase()]}/`);
|
|
142
|
-
const clone = CLONE_URL_RE.exec(source);
|
|
143
|
-
let url;
|
|
144
|
-
try {
|
|
145
|
-
url = new URL(clone && (clone[1] ?? clone[2]).toLowerCase() === base.hostname ? `${base.origin}${prefix}/${clone[3]}` : source);
|
|
146
|
-
} catch {
|
|
147
|
-
return;
|
|
148
|
-
}
|
|
149
|
-
if (url.protocol !== "http:" && url.protocol !== "https:" || url.host !== base.host && !web.hosts?.includes(url.host) || url.username || url.password) return;
|
|
150
|
-
if (prefix && !url.pathname.startsWith(`${prefix}/`)) return;
|
|
151
|
-
let segments;
|
|
152
|
-
try {
|
|
153
|
-
segments = url.pathname.slice(prefix.length).split("/").filter(Boolean).map(decodeURIComponent);
|
|
154
|
-
} catch {
|
|
155
|
-
return;
|
|
156
|
-
}
|
|
157
|
-
return web.parse(segments, url, origin);
|
|
158
|
-
}
|
|
159
|
-
function referenceFor(web, ref, options = {}) {
|
|
160
|
-
if (!web || !("sha" in ref || isResolvedThread(ref))) return;
|
|
161
|
-
return web.reference?.(ref, sameRepo(ref.repo, options.from), options.expand ?? false) ?? webUrlFor(web, "sha" in ref ? { commit: ref } : { thread: ref });
|
|
162
|
-
}
|
|
163
|
-
/** `owner/name`, for forges that nest no deeper. */
|
|
164
|
-
const OWNER_NAME = String.raw`[\w.-]+\/[\w.-]+`;
|
|
165
|
-
/** What cannot come right before a reference, so that a path, an email address or a word does not read as one. */
|
|
166
|
-
const BEFORE = String.raw`(?<![\w/.@#~&!+-])`;
|
|
167
|
-
/** What cannot come right after a reference: a word character, or a dot, slash or `@` that continues a word. */
|
|
168
|
-
const AFTER = String.raw`(?![\w-]|[./@]\w)`;
|
|
169
|
-
const SHA = "[0-9a-f]{7,40}";
|
|
170
|
-
const SCHEME_CHAR = /[\w+.-]/;
|
|
171
|
-
const LETTER = /[a-z]/i;
|
|
172
|
-
const SPACE = /\s/;
|
|
173
|
-
const rules = /* @__PURE__ */ new WeakMap();
|
|
174
|
-
function repoIn(slug, origin) {
|
|
175
|
-
const at = slug.lastIndexOf("/");
|
|
176
|
-
return {
|
|
177
|
-
...origin,
|
|
178
|
-
owner: slug.slice(0, at),
|
|
179
|
-
name: slug.slice(at + 1)
|
|
180
|
-
};
|
|
181
|
-
}
|
|
182
|
-
/** The spans of URLs in `text`, each from its scheme to the next whitespace. */
|
|
183
|
-
function urlSpans(text) {
|
|
184
|
-
const spans = [];
|
|
185
|
-
for (let at = text.indexOf("://"); at !== -1; at = text.indexOf("://", at + 1)) {
|
|
186
|
-
let start = at;
|
|
187
|
-
while (start > 0 && SCHEME_CHAR.test(text[start - 1])) start--;
|
|
188
|
-
while (start < at && !LETTER.test(text[start])) start++;
|
|
189
|
-
if (start === at || at + 3 >= text.length || SPACE.test(text[at + 3])) continue;
|
|
190
|
-
let end = at + 4;
|
|
191
|
-
while (end < text.length && !SPACE.test(text[end])) end++;
|
|
192
|
-
spans.push([start, end]);
|
|
193
|
-
at = end;
|
|
194
|
-
}
|
|
195
|
-
return spans;
|
|
196
|
-
}
|
|
197
|
-
/** A bare sha needs a letter and a digit, so that neither a number nor a word reads as one. */
|
|
198
|
-
function isBareSha(value) {
|
|
199
|
-
return /[a-f]/.test(value) && /\d/.test(value);
|
|
200
|
-
}
|
|
201
|
-
function rulesFor(syntax) {
|
|
202
|
-
const cached = rules.get(syntax);
|
|
203
|
-
if (cached) return cached;
|
|
204
|
-
const compiled = [];
|
|
205
|
-
const rule = (source, read) => compiled.push({
|
|
206
|
-
pattern: new RegExp(`${BEFORE}${source}${AFTER}`, "g"),
|
|
207
|
-
read
|
|
208
|
-
});
|
|
209
|
-
const suffix = syntax.suffix ? `(?:${syntax.suffix})?` : "";
|
|
210
|
-
for (const { prefix, kind, number = String.raw`[1-9]\d*`, sameRepo: local, namespace } of syntax.threads) {
|
|
211
|
-
const thread = `${prefix.replace(/[$()*+.?[\\\]^{|}]/g, "\\$&")}(?<id>${number})${suffix}`;
|
|
212
|
-
rule(thread, ({ id }, from, origin) => ({
|
|
213
|
-
...origin,
|
|
214
|
-
repo: namespace ? namespaceRef(origin, from.owner) : from,
|
|
215
|
-
kind,
|
|
216
|
-
number: id
|
|
217
|
-
}));
|
|
218
|
-
if (syntax.repo && !local) rule(`(?<slug>${syntax.repo})${thread}`, ({ slug, id }, _, origin) => ({
|
|
219
|
-
...origin,
|
|
220
|
-
repo: repoIn(slug, origin),
|
|
221
|
-
kind,
|
|
222
|
-
number: id
|
|
223
|
-
}));
|
|
224
|
-
}
|
|
225
|
-
if (syntax.commits) {
|
|
226
|
-
rule(`(?<sha>${SHA})`, ({ sha }, from, origin) => isBareSha(sha) ? {
|
|
227
|
-
...origin,
|
|
228
|
-
repo: from,
|
|
229
|
-
sha
|
|
230
|
-
} : void 0);
|
|
231
|
-
if (syntax.repo) rule(`(?<slug>${syntax.repo})@(?<sha>${SHA})`, ({ slug, sha }, _, origin) => ({
|
|
232
|
-
...origin,
|
|
233
|
-
repo: repoIn(slug, origin),
|
|
234
|
-
sha
|
|
235
|
-
}));
|
|
236
|
-
}
|
|
237
|
-
rules.set(syntax, compiled);
|
|
238
|
-
return compiled;
|
|
239
|
-
}
|
|
240
|
-
function parseReferences(web, text, from, origin) {
|
|
241
|
-
if (!web?.references || from.forge !== origin.forge || from.instance !== origin.instance) return [];
|
|
242
|
-
const urls = urlSpans(text);
|
|
243
|
-
const found = [];
|
|
244
|
-
for (const { pattern, read } of rulesFor(web.references)) for (const match of text.matchAll(pattern)) {
|
|
245
|
-
const ref = urls.some(([start, end]) => match.index >= start && match.index < end) ? void 0 : read(match.groups, from, origin);
|
|
246
|
-
if (ref) found.push({
|
|
247
|
-
start: match.index,
|
|
248
|
-
end: match.index + match[0].length,
|
|
249
|
-
ref
|
|
250
|
-
});
|
|
251
|
-
}
|
|
252
|
-
found.sort((a, b) => a.start - b.start || b.end - a.end);
|
|
253
|
-
let end = 0;
|
|
254
|
-
return found.filter((match) => {
|
|
255
|
-
if (match.start < end) return false;
|
|
256
|
-
end = match.end;
|
|
257
|
-
return true;
|
|
258
|
-
});
|
|
259
|
-
}
|
|
260
|
-
/** Reads GitHub's file route, `blob/{at}/{path}`. */
|
|
261
|
-
function parseGitHubFile([route, at, ...path]) {
|
|
262
|
-
return route === "blob" && at && path.length ? {
|
|
263
|
-
at,
|
|
264
|
-
path: path.join("/")
|
|
265
|
-
} : void 0;
|
|
266
|
-
}
|
|
267
|
-
/** Web links for forges laid out like GitHub: `/{owner}/{name}/issues/{n}` and friends. */
|
|
268
|
-
function githubShapedWeb(baseUrl, shape) {
|
|
269
|
-
const repoPath = (repo) => `/${encodePath(repo.owner)}/${encodeURIComponent(repo.name)}`;
|
|
270
|
-
const kindPath = {
|
|
271
|
-
issue: "issues",
|
|
272
|
-
pull_request: shape.pull,
|
|
273
|
-
...shape.discussions ? { discussion: "discussions" } : {}
|
|
274
|
-
};
|
|
275
|
-
const commitPath = shape.commit ?? "commit";
|
|
276
|
-
const kindOf = new Map(Object.entries(kindPath).map(([kind, path]) => [path, kind]));
|
|
277
|
-
const reserved = new Set(shape.reserved?.map((segment) => segment.toLowerCase()));
|
|
278
|
-
const parseFile = shape.parseFile ?? parseGitHubFile;
|
|
279
|
-
return {
|
|
280
|
-
baseUrl,
|
|
281
|
-
repo: repoPath,
|
|
282
|
-
section: (repo, section) => {
|
|
283
|
-
if (repo.kind === "namespace") return;
|
|
284
|
-
const path = shape.sections?.[section];
|
|
285
|
-
if (path === null) return;
|
|
286
|
-
return `${repoPath(repo)}/${path ?? (section === "pullRequests" ? "pulls" : section)}`;
|
|
287
|
-
},
|
|
288
|
-
thread: (ref) => kindPath[ref.kind] && `${repoPath(ref.repo)}/${kindPath[ref.kind]}/${encodeURIComponent(ref.number)}`,
|
|
289
|
-
comment: (ref) => kindPath[ref.thread.kind] && `${repoPath(ref.thread.repo)}/${kindPath[ref.thread.kind]}/${encodeURIComponent(ref.thread.number)}#${shape.commentFragment}${ref.id}`,
|
|
290
|
-
commit: (repo, sha) => `${repoPath(repo)}/${commitPath}/${encodeURIComponent(sha)}`,
|
|
291
|
-
release: (ref) => ref.tag ? `${repoPath(ref.repo)}/releases/tag/${encodeURIComponent(ref.tag)}` : void 0,
|
|
292
|
-
file: (repo, path, at, line) => `${repoPath(repo)}${shape.file(at)}/${encodePath(path)}${line ? `#${shape.lineFragment(line)}` : ""}`,
|
|
293
|
-
raw: (repo, path, at) => shape.raw === false ? void 0 : shape.rawOrigin ? `${shape.rawOrigin}${repoPath(repo)}/${encodeURIComponent(at)}/${encodePath(path)}` : `${repoPath(repo)}/raw/${encodeURIComponent(at)}/${encodePath(path)}`,
|
|
294
|
-
compare: (repo, base, head) => `${repoPath(repo)}/compare/${encodeURIComponent(base)}...${encodeURIComponent(head)}`,
|
|
295
|
-
parse: (segments, url, from) => {
|
|
296
|
-
const [owner, name, section, id] = segments;
|
|
297
|
-
if (!owner || !name || reserved.has(owner.toLowerCase())) return;
|
|
298
|
-
const repo = {
|
|
299
|
-
...from,
|
|
300
|
-
owner,
|
|
301
|
-
name: name.replace(/\.git$/, "")
|
|
302
|
-
};
|
|
303
|
-
const file = parseFile(segments.slice(2));
|
|
304
|
-
if (file) return {
|
|
305
|
-
repo,
|
|
306
|
-
file: {
|
|
307
|
-
...file,
|
|
308
|
-
...lineOf(url.hash.replace(/^#L/, ""))
|
|
309
|
-
}
|
|
310
|
-
};
|
|
311
|
-
const kind = section ? kindOf.get(section) : void 0;
|
|
312
|
-
if (section === "releases" && id === "tag" && segments[4]) return {
|
|
313
|
-
repo,
|
|
314
|
-
release: {
|
|
315
|
-
...from,
|
|
316
|
-
repo,
|
|
317
|
-
id: segments[4],
|
|
318
|
-
tag: segments[4]
|
|
319
|
-
}
|
|
320
|
-
};
|
|
321
|
-
if (section === commitPath && id) return {
|
|
322
|
-
repo,
|
|
323
|
-
commit: {
|
|
324
|
-
...from,
|
|
325
|
-
repo,
|
|
326
|
-
sha: id
|
|
327
|
-
}
|
|
328
|
-
};
|
|
329
|
-
if (section === "compare" && id) return {
|
|
330
|
-
repo,
|
|
331
|
-
...rangeOf(segments.slice(3).join("/"))
|
|
332
|
-
};
|
|
333
|
-
if (!kind || !id) return { repo };
|
|
334
|
-
const thread = {
|
|
335
|
-
...from,
|
|
336
|
-
repo,
|
|
337
|
-
kind,
|
|
338
|
-
number: id
|
|
339
|
-
};
|
|
340
|
-
if (kind === "pull_request" && segments[4] === "commits" && segments[5]) return {
|
|
341
|
-
repo,
|
|
342
|
-
thread,
|
|
343
|
-
commit: {
|
|
344
|
-
...from,
|
|
345
|
-
repo,
|
|
346
|
-
sha: segments[5]
|
|
347
|
-
}
|
|
348
|
-
};
|
|
349
|
-
const comment = url.hash.startsWith(`#${shape.commentFragment}`) ? url.hash.slice(shape.commentFragment.length + 1) : void 0;
|
|
350
|
-
return {
|
|
351
|
-
repo,
|
|
352
|
-
thread,
|
|
353
|
-
...comment ? { comment: {
|
|
354
|
-
...from,
|
|
355
|
-
thread,
|
|
356
|
-
id: comment
|
|
357
|
-
} } : {}
|
|
358
|
-
};
|
|
359
|
-
},
|
|
360
|
-
reference: (ref, same) => {
|
|
361
|
-
if ("sha" in ref) return same ? ref.sha.slice(0, 7) : `${ref.repo.owner}/${ref.repo.name}@${ref.sha.slice(0, 7)}`;
|
|
362
|
-
const prefix = ref.kind === "pull_request" && shape.pullPrefix ? shape.pullPrefix : "#";
|
|
363
|
-
return `${same ? "" : `${ref.repo.owner}/${ref.repo.name}`}${prefix}${ref.number}`;
|
|
364
|
-
},
|
|
365
|
-
references: shape.references ?? {
|
|
366
|
-
threads: [{
|
|
367
|
-
prefix: "#",
|
|
368
|
-
kind: "issue"
|
|
369
|
-
}, ...shape.pullPrefix ? [{
|
|
370
|
-
prefix: shape.pullPrefix,
|
|
371
|
-
kind: "pull_request"
|
|
372
|
-
}] : []],
|
|
373
|
-
repo: OWNER_NAME,
|
|
374
|
-
commits: true
|
|
375
|
-
}
|
|
376
|
-
};
|
|
377
|
-
}
|
|
378
|
-
/** The API base URL and the instance that `options` select. */
|
|
379
|
-
function resolveInstance(definition, options) {
|
|
380
|
-
const root = (options.baseUrl ?? definition.baseUrl).replace(/\/$/, "");
|
|
381
|
-
const baseUrl = definition.apiPath && !root.endsWith(definition.apiPath) ? `${root}${definition.apiPath}` : root;
|
|
382
|
-
let host;
|
|
383
|
-
try {
|
|
384
|
-
host = new URL(baseUrl).host;
|
|
385
|
-
} catch (cause) {
|
|
386
|
-
throw new TypeError(`Invalid baseUrl for ${definition.forge}: ${JSON.stringify(baseUrl)}`, { cause });
|
|
387
|
-
}
|
|
388
|
-
return {
|
|
389
|
-
baseUrl,
|
|
390
|
-
instance: options.instance ?? definition.instance?.(host) ?? host
|
|
391
|
-
};
|
|
392
|
-
}
|
|
393
90
|
//#endregion
|
|
394
|
-
//#region ../../node_modules/.pnpm/forges@
|
|
91
|
+
//#region ../../node_modules/.pnpm/forges@0.3.1/node_modules/forges/dist/utils-DC7MBR65.mjs
|
|
395
92
|
/** Base class for every error that forges throws. */
|
|
396
93
|
var ForgeError = class extends Error {
|
|
397
94
|
name = "ForgeError";
|
|
@@ -1514,4 +1211,4 @@ function hexColour(colour, prefix = "") {
|
|
|
1514
1211
|
return `${prefix}${(colour ?? "ededed").replace(/^#/, "")}`;
|
|
1515
1212
|
}
|
|
1516
1213
|
//#endregion
|
|
1517
|
-
export { toDate as $, hexColour as A, milestoneId as B, createListing as C, forgeIterable as D, firstPageEtag as E, latestCommentOf as F, requireIssueOrPull as G, rateLimitOf as H, mapConcurrent as I, sleep as J, requireThread as K, memo as L, isFirstPage as M, isSecondaryRateLimit as N, getManyConcurrently as O, iteratePages as P, teamOrg as Q, memoBy as R, createFetcher as S, degradesToWarning as T, rateLimitPart as U, phased as V, rateLimitReset as W, summariseChecks as X, soleMergeMethod as Y, syntheticReview as Z, WebhookVerificationError as _,
|
|
1214
|
+
export { toDate as $, hexColour as A, milestoneId as B, createListing as C, forgeIterable as D, firstPageEtag as E, latestCommentOf as F, requireIssueOrPull as G, rateLimitOf as H, mapConcurrent as I, sleep as J, requireThread as K, memo as L, isFirstPage as M, isSecondaryRateLimit as N, getManyConcurrently as O, iteratePages as P, teamOrg as Q, memoBy as R, createFetcher as S, degradesToWarning as T, rateLimitPart as U, phased as V, rateLimitReset as W, summariseChecks as X, soleMergeMethod as Y, syntheticReview as Z, WebhookVerificationError as _, ForgeApiError as a, versionAtLeast as at, anySignal as b, InsufficientScopeError as c, isNamespaceRef as ct, NotFoundError as d, namespaceRef as dt, toFileStatus as et, RateLimitedError as f, normaliseRepoName as ft, UnsupportedOperationError as g, UnresolvedThreadError as h, ForbiddenError as i, toWarning as it, hostOf as j, hasEveryLabel as k, MergeBlockedError as l, isResolvedThread as lt, TokenRevokedError as m, repoRef as mt, BranchMovedError as n, toPage as nt, ForgeError as o, withEtag as ot, ReadOnlyError as p, reactionContent as pt, resolveToken as q, ContentNotTextError as r, toPullStats as rt, ForgeTimeoutError as s, REACTION_CONTENTS as st, AuthenticationRequiredError as t, toMergeError as tt, MergeConflictError as u, isUnsupported as ut, abortable as v, createRequest as w, checkRunState as x, actorLogin as y, mergeCommitMessage as z };
|