@remixhq/core 0.1.14 → 0.1.15

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 (72) hide show
  1. package/dist/api.d.ts +1 -1
  2. package/dist/collab.d.ts +2 -2
  3. package/dist/collab.js +1 -1
  4. package/dist/{contracts-NbV3P_Rl.d.ts → contracts-CHmD-fMj.d.ts} +1 -1
  5. package/dist/history.d.ts +64 -0
  6. package/dist/history.js +529 -0
  7. package/dist/index.d.ts +1 -1
  8. package/package.json +6 -2
  9. package/dist/chunk-2WGZS7CD.js +0 -0
  10. package/dist/chunk-34WDQCPF.js +0 -242
  11. package/dist/chunk-4276ARDF.js +0 -303
  12. package/dist/chunk-4L3ZBZUQ.js +0 -281
  13. package/dist/chunk-54CBEP2W.js +0 -570
  14. package/dist/chunk-55K5GHAZ.js +0 -252
  15. package/dist/chunk-5H5CZKGN.js +0 -691
  16. package/dist/chunk-5NTOJXEZ.js +0 -223
  17. package/dist/chunk-7WUKH3ZD.js +0 -221
  18. package/dist/chunk-AE2HPMUZ.js +0 -80
  19. package/dist/chunk-AEAOYVIL.js +0 -200
  20. package/dist/chunk-B5S3PUIR.js +0 -388
  21. package/dist/chunk-BJFCN2C3.js +0 -46
  22. package/dist/chunk-BNKPTE2U.js +0 -401
  23. package/dist/chunk-C5NBNU32.js +0 -240
  24. package/dist/chunk-CJFGQE7D.js +0 -46
  25. package/dist/chunk-CUUXZSKW.js +0 -611
  26. package/dist/chunk-DCU3646I.js +0 -12
  27. package/dist/chunk-DEWAIK5X.js +0 -11
  28. package/dist/chunk-DRD6EVTT.js +0 -447
  29. package/dist/chunk-DXCL6I4Q.js +0 -399
  30. package/dist/chunk-E4KAGBU7.js +0 -134
  31. package/dist/chunk-E6AYE22H.js +0 -343
  32. package/dist/chunk-EF3677RE.js +0 -93
  33. package/dist/chunk-EVWDYCBL.js +0 -223
  34. package/dist/chunk-EW4PWFHB.js +0 -46
  35. package/dist/chunk-FAZUMWBS.js +0 -93
  36. package/dist/chunk-GEHSFPCD.js +0 -93
  37. package/dist/chunk-GFOBGYW4.js +0 -252
  38. package/dist/chunk-INDDXWAH.js +0 -92
  39. package/dist/chunk-IXWQWFYT.js +0 -342
  40. package/dist/chunk-J3J4PBQ7.js +0 -710
  41. package/dist/chunk-K54U353Z.js +0 -691
  42. package/dist/chunk-K57ZFDGC.js +0 -15
  43. package/dist/chunk-NDA7EJJA.js +0 -286
  44. package/dist/chunk-NK2DA4X6.js +0 -357
  45. package/dist/chunk-OBYR4JHZ.js +0 -374
  46. package/dist/chunk-OJMTW22J.js +0 -286
  47. package/dist/chunk-OMUDRPUI.js +0 -195
  48. package/dist/chunk-ONKKRS2C.js +0 -239
  49. package/dist/chunk-OWFBBWU7.js +0 -196
  50. package/dist/chunk-OZRXDDEL.js +0 -46
  51. package/dist/chunk-P7EM3N73.js +0 -46
  52. package/dist/chunk-POYB6MCQ.js +0 -373
  53. package/dist/chunk-PR5QKMHM.js +0 -46
  54. package/dist/chunk-R44EOUS4.js +0 -288
  55. package/dist/chunk-R7FVSCQW.js +0 -415
  56. package/dist/chunk-RIP2MIZL.js +0 -710
  57. package/dist/chunk-RKMMEML5.js +0 -46
  58. package/dist/chunk-RM2BGDBB.js +0 -400
  59. package/dist/chunk-RREREIGW.js +0 -710
  60. package/dist/chunk-TQHLFQY4.js +0 -448
  61. package/dist/chunk-TY3SSQQK.js +0 -688
  62. package/dist/chunk-UGKPOCN5.js +0 -710
  63. package/dist/chunk-UIGKSCTD.js +0 -406
  64. package/dist/chunk-UWIVJRTI.js +0 -343
  65. package/dist/chunk-VA6WXRWB.js +0 -636
  66. package/dist/chunk-XC2FV57P.js +0 -385
  67. package/dist/chunk-XOQIADCH.js +0 -223
  68. package/dist/chunk-ZAQZKEH4.js +0 -46
  69. package/dist/chunk-ZBMOGUSJ.js +0 -17
  70. package/dist/chunk-ZXP6ENQY.js +0 -244
  71. package/dist/index.cjs +0 -1269
  72. package/dist/index.d.cts +0 -482
@@ -1,342 +0,0 @@
1
- import {
2
- getCurrentBranch
3
- } from "./chunk-RREREIGW.js";
4
- import {
5
- RemixError
6
- } from "./chunk-YZ34ICNN.js";
7
-
8
- // src/infrastructure/binding/collabBindingStore.ts
9
- import fs2 from "fs/promises";
10
- import path2 from "path";
11
-
12
- // src/shared/fs.ts
13
- import fs from "fs/promises";
14
- import path from "path";
15
- async function reserveDirectory(targetDir) {
16
- try {
17
- await fs.mkdir(targetDir);
18
- return targetDir;
19
- } catch (error) {
20
- if (error?.code === "EEXIST") {
21
- throw new RemixError("Output directory already exists.", {
22
- exitCode: 2,
23
- hint: `Choose an empty destination path: ${targetDir}`
24
- });
25
- }
26
- throw error;
27
- }
28
- }
29
- async function reserveAvailableDirPath(preferredDir) {
30
- const parent = path.dirname(preferredDir);
31
- const base = path.basename(preferredDir);
32
- for (let i = 1; i <= 1e3; i += 1) {
33
- const candidate = i === 1 ? preferredDir : path.join(parent, `${base}-${i}`);
34
- try {
35
- await fs.mkdir(candidate);
36
- return candidate;
37
- } catch (error) {
38
- if (error?.code === "EEXIST") continue;
39
- throw error;
40
- }
41
- }
42
- throw new RemixError("No available output directory name.", {
43
- exitCode: 2,
44
- hint: `Tried ${base} through ${base}-1000 under ${parent}.`
45
- });
46
- }
47
- async function writeJsonAtomic(filePath, value) {
48
- const dir = path.dirname(filePath);
49
- await fs.mkdir(dir, { recursive: true });
50
- const tmp = `${filePath}.tmp-${Date.now()}`;
51
- await fs.writeFile(tmp, `${JSON.stringify(value, null, 2)}
52
- `, "utf8");
53
- await fs.rename(tmp, filePath);
54
- }
55
-
56
- // src/infrastructure/binding/collabBindingStore.ts
57
- function getCollabBindingPath(repoRoot) {
58
- return path2.join(repoRoot, ".remix", "config.json");
59
- }
60
- function buildBindingFileV3(params) {
61
- return {
62
- schemaVersion: 3,
63
- repoFingerprint: params.repoFingerprint,
64
- remoteUrl: params.remoteUrl,
65
- defaultBranch: params.defaultBranch,
66
- branchBindings: params.branchBindings,
67
- ...params.explicitRootBinding ? { explicitRootBinding: params.explicitRootBinding } : {}
68
- };
69
- }
70
- function normalizeBranchName(value) {
71
- const normalized = String(value ?? "").trim();
72
- return normalized || null;
73
- }
74
- function normalizeProjectId(value) {
75
- const normalized = String(value ?? "").trim();
76
- return normalized || null;
77
- }
78
- function normalizeBranchBinding(value) {
79
- if (!value?.currentAppId || !value?.upstreamAppId) return null;
80
- return {
81
- projectId: normalizeProjectId(value.projectId),
82
- currentAppId: value.currentAppId,
83
- upstreamAppId: value.upstreamAppId,
84
- threadId: value.threadId ?? null,
85
- laneId: value.laneId ?? null,
86
- bindingMode: value.bindingMode === "legacy" ? "legacy" : value.bindingMode === "explicit_root" ? "explicit_root" : "lane"
87
- };
88
- }
89
- function buildResolvedBinding(params) {
90
- if (!params.binding) return null;
91
- return {
92
- schemaVersion: 3,
93
- projectId: params.binding.projectId ?? params.fallbackProjectId,
94
- currentAppId: params.binding.currentAppId,
95
- upstreamAppId: params.binding.upstreamAppId,
96
- threadId: params.binding.threadId,
97
- repoFingerprint: params.repoFingerprint,
98
- remoteUrl: params.remoteUrl,
99
- defaultBranch: params.defaultBranch,
100
- laneId: params.binding.laneId,
101
- branchName: params.branchName,
102
- bindingMode: params.binding.bindingMode
103
- };
104
- }
105
- function deriveFallbackProjectId(params) {
106
- const candidates = [
107
- params.currentBranch ? params.branchBindings[params.currentBranch]?.projectId ?? null : null,
108
- params.defaultBranch ? params.branchBindings[params.defaultBranch]?.projectId ?? null : null,
109
- ...Object.values(params.branchBindings).map((binding) => binding.projectId),
110
- params.legacyProjectId
111
- ];
112
- for (const candidate of candidates) {
113
- if (candidate) return candidate;
114
- }
115
- return null;
116
- }
117
- async function readCollabBindingState(repoRoot, options) {
118
- try {
119
- const persist = options?.persist === true;
120
- const filePath = getCollabBindingPath(repoRoot);
121
- const raw = await fs2.readFile(filePath, "utf8");
122
- const parsed = JSON.parse(raw);
123
- if (!parsed || typeof parsed !== "object") return null;
124
- const currentBranch = normalizeBranchName(await getCurrentBranch(repoRoot).catch(() => null));
125
- if (parsed.schemaVersion === 1) {
126
- if (!parsed.currentAppId || !parsed.upstreamAppId) return null;
127
- const projectId = normalizeProjectId(parsed.projectId);
128
- const preferredBranch = normalizeBranchName(parsed.preferredBranch ?? parsed.defaultBranch ?? null);
129
- const branchKey = preferredBranch ?? currentBranch ?? null;
130
- const branchBindings2 = branchKey ? {
131
- [branchKey]: {
132
- projectId,
133
- currentAppId: parsed.currentAppId,
134
- upstreamAppId: parsed.upstreamAppId,
135
- threadId: parsed.threadId ?? null,
136
- laneId: null,
137
- bindingMode: "legacy"
138
- }
139
- } : {};
140
- const migratedFile = buildBindingFileV3({
141
- repoFingerprint: parsed.repoFingerprint ?? null,
142
- remoteUrl: parsed.remoteUrl ?? null,
143
- defaultBranch: parsed.defaultBranch ?? null,
144
- branchBindings: branchBindings2
145
- });
146
- if (persist) {
147
- try {
148
- await writeJsonAtomic(filePath, migratedFile);
149
- } catch {
150
- }
151
- }
152
- return {
153
- schemaVersion: 3,
154
- projectId,
155
- repoFingerprint: migratedFile.repoFingerprint,
156
- remoteUrl: migratedFile.remoteUrl,
157
- defaultBranch: migratedFile.defaultBranch,
158
- currentBranch,
159
- branchBindings: migratedFile.branchBindings,
160
- explicitRootBinding: null,
161
- binding: buildResolvedBinding({
162
- fallbackProjectId: projectId,
163
- repoFingerprint: migratedFile.repoFingerprint,
164
- remoteUrl: migratedFile.remoteUrl,
165
- defaultBranch: migratedFile.defaultBranch,
166
- branchName: branchKey,
167
- binding: branchKey ? migratedFile.branchBindings[branchKey] : null
168
- })
169
- };
170
- }
171
- if (parsed.schemaVersion !== 2 && parsed.schemaVersion !== 3) return null;
172
- const file = parsed;
173
- let shouldPersistNormalizedBranchBindings = false;
174
- const legacyProjectId = normalizeProjectId(file.projectId);
175
- const branchBindings = Object.fromEntries(
176
- Object.entries(file.branchBindings ?? {}).map(([branchName, branchBinding]) => {
177
- const normalized = normalizeBranchBinding(branchBinding);
178
- const rawProjectId = branchBinding && typeof branchBinding === "object" && "projectId" in branchBinding ? normalizeProjectId(branchBinding.projectId) : null;
179
- const rawBindingMode = branchBinding && typeof branchBinding === "object" && "bindingMode" in branchBinding ? branchBinding.bindingMode : null;
180
- const hasLegacyPreferredBranch = Boolean(branchBinding) && typeof branchBinding === "object" && "preferredBranch" in branchBinding;
181
- let normalizedWithProject = normalized;
182
- if (normalizedWithProject && !normalizedWithProject.projectId && legacyProjectId) {
183
- normalizedWithProject = {
184
- ...normalizedWithProject,
185
- projectId: legacyProjectId
186
- };
187
- }
188
- if (normalizedWithProject && (rawBindingMode !== normalizedWithProject.bindingMode || hasLegacyPreferredBranch || rawProjectId !== normalizedWithProject.projectId)) {
189
- shouldPersistNormalizedBranchBindings = true;
190
- }
191
- return [branchName, normalizedWithProject];
192
- }).filter((entry) => Boolean(entry[1]))
193
- );
194
- const legacyExplicitBinding = normalizeBranchBinding(file.explicitBinding ?? null);
195
- const legacyExplicitBranch = currentBranch ?? normalizeBranchName(file.defaultBranch);
196
- if (legacyExplicitBinding && legacyExplicitBranch) {
197
- branchBindings[legacyExplicitBranch] = {
198
- ...legacyExplicitBinding,
199
- projectId: legacyExplicitBinding.projectId ?? branchBindings[legacyExplicitBranch]?.projectId ?? legacyProjectId,
200
- bindingMode: "lane"
201
- };
202
- shouldPersistNormalizedBranchBindings = true;
203
- }
204
- let explicitRootBinding = normalizeBranchBinding(file.explicitRootBinding ?? null);
205
- if (explicitRootBinding && !explicitRootBinding.projectId && legacyProjectId) {
206
- explicitRootBinding = {
207
- ...explicitRootBinding,
208
- projectId: legacyProjectId
209
- };
210
- shouldPersistNormalizedBranchBindings = true;
211
- }
212
- if (explicitRootBinding && explicitRootBinding.bindingMode !== "explicit_root") {
213
- explicitRootBinding = {
214
- ...explicitRootBinding,
215
- bindingMode: "explicit_root"
216
- };
217
- shouldPersistNormalizedBranchBindings = true;
218
- }
219
- if (persist && ("explicitBinding" in file || "explicitRootBinding" in file || shouldPersistNormalizedBranchBindings || parsed.schemaVersion === 2)) {
220
- try {
221
- await writeJsonAtomic(
222
- filePath,
223
- buildBindingFileV3({
224
- repoFingerprint: file.repoFingerprint ?? null,
225
- remoteUrl: file.remoteUrl ?? null,
226
- defaultBranch: file.defaultBranch ?? null,
227
- branchBindings,
228
- explicitRootBinding
229
- })
230
- );
231
- } catch {
232
- }
233
- }
234
- const resolvedBranch = currentBranch ?? normalizeBranchName(file.defaultBranch);
235
- const fallbackProjectId = deriveFallbackProjectId({
236
- branchBindings,
237
- currentBranch: resolvedBranch,
238
- defaultBranch: normalizeBranchName(file.defaultBranch),
239
- legacyProjectId: explicitRootBinding?.projectId ?? legacyProjectId
240
- });
241
- const resolvedBinding = buildResolvedBinding({
242
- fallbackProjectId,
243
- repoFingerprint: file.repoFingerprint ?? null,
244
- remoteUrl: file.remoteUrl ?? null,
245
- defaultBranch: file.defaultBranch ?? null,
246
- branchName: resolvedBranch,
247
- binding: resolvedBranch ? branchBindings[resolvedBranch] ?? null : null
248
- }) ?? (resolvedBranch && resolvedBranch === normalizeBranchName(file.defaultBranch) && explicitRootBinding ? buildResolvedBinding({
249
- fallbackProjectId,
250
- repoFingerprint: file.repoFingerprint ?? null,
251
- remoteUrl: file.remoteUrl ?? null,
252
- defaultBranch: file.defaultBranch ?? null,
253
- branchName: normalizeBranchName(file.defaultBranch),
254
- binding: explicitRootBinding
255
- }) : null);
256
- return {
257
- schemaVersion: parsed.schemaVersion,
258
- projectId: fallbackProjectId,
259
- repoFingerprint: file.repoFingerprint ?? null,
260
- remoteUrl: file.remoteUrl ?? null,
261
- defaultBranch: file.defaultBranch ?? null,
262
- currentBranch,
263
- branchBindings,
264
- explicitRootBinding: buildResolvedBinding({
265
- fallbackProjectId,
266
- repoFingerprint: file.repoFingerprint ?? null,
267
- remoteUrl: file.remoteUrl ?? null,
268
- defaultBranch: file.defaultBranch ?? null,
269
- branchName: normalizeBranchName(file.defaultBranch),
270
- binding: explicitRootBinding
271
- }),
272
- binding: resolvedBinding
273
- };
274
- } catch {
275
- return null;
276
- }
277
- }
278
- async function readCollabBinding(repoRoot) {
279
- const state = await readCollabBindingState(repoRoot);
280
- return state?.binding ?? null;
281
- }
282
- async function writeCollabBinding(repoRoot, binding) {
283
- const filePath = getCollabBindingPath(repoRoot);
284
- const currentBranch = normalizeBranchName(await getCurrentBranch(repoRoot).catch(() => null));
285
- const branchName = normalizeBranchName(binding.branchName) ?? currentBranch ?? binding.defaultBranch ?? "main";
286
- const existing = await readCollabBindingState(repoRoot, { persist: true });
287
- const branchBindings = { ...existing?.branchBindings ?? {} };
288
- branchBindings[branchName] = {
289
- projectId: normalizeProjectId(binding.projectId) ?? branchBindings[branchName]?.projectId ?? existing?.projectId ?? null,
290
- currentAppId: binding.currentAppId,
291
- upstreamAppId: binding.upstreamAppId,
292
- threadId: binding.threadId ?? null,
293
- laneId: binding.laneId ?? null,
294
- bindingMode: binding.bindingMode ?? "lane"
295
- };
296
- const explicitRootBinding = binding.bindingMode === "explicit_root" ? {
297
- ...branchBindings[branchName],
298
- bindingMode: "explicit_root"
299
- } : existing?.explicitRootBinding ? {
300
- projectId: existing.explicitRootBinding.projectId,
301
- currentAppId: existing.explicitRootBinding.currentAppId,
302
- upstreamAppId: existing.explicitRootBinding.upstreamAppId,
303
- threadId: existing.explicitRootBinding.threadId,
304
- laneId: existing.explicitRootBinding.laneId,
305
- bindingMode: "explicit_root"
306
- } : null;
307
- await writeJsonAtomic(
308
- filePath,
309
- buildBindingFileV3({
310
- repoFingerprint: binding.repoFingerprint ?? null,
311
- remoteUrl: binding.remoteUrl ?? null,
312
- defaultBranch: binding.defaultBranch ?? null,
313
- branchBindings,
314
- explicitRootBinding
315
- })
316
- );
317
- return filePath;
318
- }
319
- async function writeCollabBindingSnapshot(params) {
320
- const filePath = getCollabBindingPath(params.repoRoot);
321
- await writeJsonAtomic(
322
- filePath,
323
- buildBindingFileV3({
324
- repoFingerprint: params.repoFingerprint,
325
- remoteUrl: params.remoteUrl,
326
- defaultBranch: params.defaultBranch,
327
- branchBindings: params.branchBindings,
328
- explicitRootBinding: params.explicitRootBinding ?? null
329
- })
330
- );
331
- return filePath;
332
- }
333
-
334
- export {
335
- reserveDirectory,
336
- reserveAvailableDirPath,
337
- getCollabBindingPath,
338
- readCollabBindingState,
339
- readCollabBinding,
340
- writeCollabBinding,
341
- writeCollabBindingSnapshot
342
- };