@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,281 +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
- };
68
- }
69
- function normalizeBranchName(value) {
70
- const normalized = String(value ?? "").trim();
71
- return normalized || null;
72
- }
73
- function normalizeProjectId(value) {
74
- const normalized = String(value ?? "").trim();
75
- return normalized || null;
76
- }
77
- function normalizeBranchBinding(value) {
78
- if (!value?.currentAppId || !value?.upstreamAppId) return null;
79
- return {
80
- projectId: normalizeProjectId(value.projectId),
81
- currentAppId: value.currentAppId,
82
- upstreamAppId: value.upstreamAppId,
83
- threadId: value.threadId ?? null,
84
- laneId: value.laneId ?? null,
85
- bindingMode: value.bindingMode === "legacy" ? "legacy" : "lane"
86
- };
87
- }
88
- function buildResolvedBinding(params) {
89
- if (!params.binding) return null;
90
- return {
91
- schemaVersion: 3,
92
- projectId: params.binding.projectId ?? params.fallbackProjectId,
93
- currentAppId: params.binding.currentAppId,
94
- upstreamAppId: params.binding.upstreamAppId,
95
- threadId: params.binding.threadId,
96
- repoFingerprint: params.repoFingerprint,
97
- remoteUrl: params.remoteUrl,
98
- defaultBranch: params.defaultBranch,
99
- laneId: params.binding.laneId,
100
- branchName: params.branchName,
101
- bindingMode: params.binding.bindingMode
102
- };
103
- }
104
- function deriveFallbackProjectId(params) {
105
- const candidates = [
106
- params.currentBranch ? params.branchBindings[params.currentBranch]?.projectId ?? null : null,
107
- params.defaultBranch ? params.branchBindings[params.defaultBranch]?.projectId ?? null : null,
108
- ...Object.values(params.branchBindings).map((binding) => binding.projectId),
109
- params.legacyProjectId
110
- ];
111
- for (const candidate of candidates) {
112
- if (candidate) return candidate;
113
- }
114
- return null;
115
- }
116
- async function readCollabBindingState(repoRoot, options) {
117
- try {
118
- const persist = options?.persist === true;
119
- const filePath = getCollabBindingPath(repoRoot);
120
- const raw = await fs2.readFile(filePath, "utf8");
121
- const parsed = JSON.parse(raw);
122
- if (!parsed || typeof parsed !== "object") return null;
123
- const currentBranch = normalizeBranchName(await getCurrentBranch(repoRoot).catch(() => null));
124
- if (parsed.schemaVersion === 1) {
125
- if (!parsed.currentAppId || !parsed.upstreamAppId) return null;
126
- const projectId = normalizeProjectId(parsed.projectId);
127
- const preferredBranch = normalizeBranchName(parsed.preferredBranch ?? parsed.defaultBranch ?? null);
128
- const branchKey = preferredBranch ?? currentBranch ?? null;
129
- const branchBindings2 = branchKey ? {
130
- [branchKey]: {
131
- projectId,
132
- currentAppId: parsed.currentAppId,
133
- upstreamAppId: parsed.upstreamAppId,
134
- threadId: parsed.threadId ?? null,
135
- laneId: null,
136
- bindingMode: "legacy"
137
- }
138
- } : {};
139
- const migratedFile = buildBindingFileV3({
140
- repoFingerprint: parsed.repoFingerprint ?? null,
141
- remoteUrl: parsed.remoteUrl ?? null,
142
- defaultBranch: parsed.defaultBranch ?? null,
143
- branchBindings: branchBindings2
144
- });
145
- if (persist) {
146
- try {
147
- await writeJsonAtomic(filePath, migratedFile);
148
- } catch {
149
- }
150
- }
151
- return {
152
- schemaVersion: 3,
153
- projectId,
154
- repoFingerprint: migratedFile.repoFingerprint,
155
- remoteUrl: migratedFile.remoteUrl,
156
- defaultBranch: migratedFile.defaultBranch,
157
- currentBranch,
158
- branchBindings: migratedFile.branchBindings,
159
- binding: buildResolvedBinding({
160
- fallbackProjectId: projectId,
161
- repoFingerprint: migratedFile.repoFingerprint,
162
- remoteUrl: migratedFile.remoteUrl,
163
- defaultBranch: migratedFile.defaultBranch,
164
- branchName: branchKey,
165
- binding: branchKey ? migratedFile.branchBindings[branchKey] : null
166
- })
167
- };
168
- }
169
- if (parsed.schemaVersion !== 2 && parsed.schemaVersion !== 3) return null;
170
- const file = parsed;
171
- let shouldPersistNormalizedBranchBindings = false;
172
- const legacyProjectId = normalizeProjectId(file.projectId);
173
- const branchBindings = Object.fromEntries(
174
- Object.entries(file.branchBindings ?? {}).map(([branchName, branchBinding]) => {
175
- const normalized = normalizeBranchBinding(branchBinding);
176
- const rawProjectId = branchBinding && typeof branchBinding === "object" && "projectId" in branchBinding ? normalizeProjectId(branchBinding.projectId) : null;
177
- const rawBindingMode = branchBinding && typeof branchBinding === "object" && "bindingMode" in branchBinding ? branchBinding.bindingMode : null;
178
- const hasLegacyPreferredBranch = Boolean(branchBinding) && typeof branchBinding === "object" && "preferredBranch" in branchBinding;
179
- let normalizedWithProject = normalized;
180
- if (normalizedWithProject && !normalizedWithProject.projectId && legacyProjectId) {
181
- normalizedWithProject = {
182
- ...normalizedWithProject,
183
- projectId: legacyProjectId
184
- };
185
- }
186
- if (normalizedWithProject && (rawBindingMode !== normalizedWithProject.bindingMode || hasLegacyPreferredBranch || rawProjectId !== normalizedWithProject.projectId)) {
187
- shouldPersistNormalizedBranchBindings = true;
188
- }
189
- return [branchName, normalizedWithProject];
190
- }).filter((entry) => Boolean(entry[1]))
191
- );
192
- const legacyExplicitBinding = normalizeBranchBinding(file.explicitBinding ?? null);
193
- const legacyExplicitBranch = currentBranch ?? normalizeBranchName(file.defaultBranch);
194
- if (legacyExplicitBinding && legacyExplicitBranch) {
195
- branchBindings[legacyExplicitBranch] = {
196
- ...legacyExplicitBinding,
197
- projectId: legacyExplicitBinding.projectId ?? branchBindings[legacyExplicitBranch]?.projectId ?? legacyProjectId,
198
- bindingMode: "lane"
199
- };
200
- shouldPersistNormalizedBranchBindings = true;
201
- }
202
- if (persist && ("explicitBinding" in file || shouldPersistNormalizedBranchBindings || parsed.schemaVersion === 2)) {
203
- try {
204
- await writeJsonAtomic(
205
- filePath,
206
- buildBindingFileV3({
207
- repoFingerprint: file.repoFingerprint ?? null,
208
- remoteUrl: file.remoteUrl ?? null,
209
- defaultBranch: file.defaultBranch ?? null,
210
- branchBindings
211
- })
212
- );
213
- } catch {
214
- }
215
- }
216
- const resolvedBranch = currentBranch ?? normalizeBranchName(file.defaultBranch);
217
- const fallbackProjectId = deriveFallbackProjectId({
218
- branchBindings,
219
- currentBranch: resolvedBranch,
220
- defaultBranch: normalizeBranchName(file.defaultBranch),
221
- legacyProjectId
222
- });
223
- return {
224
- schemaVersion: parsed.schemaVersion,
225
- projectId: fallbackProjectId,
226
- repoFingerprint: file.repoFingerprint ?? null,
227
- remoteUrl: file.remoteUrl ?? null,
228
- defaultBranch: file.defaultBranch ?? null,
229
- currentBranch,
230
- branchBindings,
231
- binding: buildResolvedBinding({
232
- fallbackProjectId,
233
- repoFingerprint: file.repoFingerprint ?? null,
234
- remoteUrl: file.remoteUrl ?? null,
235
- defaultBranch: file.defaultBranch ?? null,
236
- branchName: resolvedBranch,
237
- binding: resolvedBranch ? branchBindings[resolvedBranch] ?? null : null
238
- })
239
- };
240
- } catch {
241
- return null;
242
- }
243
- }
244
- async function readCollabBinding(repoRoot) {
245
- const state = await readCollabBindingState(repoRoot);
246
- return state?.binding ?? null;
247
- }
248
- async function writeCollabBinding(repoRoot, binding) {
249
- const filePath = getCollabBindingPath(repoRoot);
250
- const currentBranch = normalizeBranchName(await getCurrentBranch(repoRoot).catch(() => null));
251
- const branchName = normalizeBranchName(binding.branchName) ?? currentBranch ?? binding.defaultBranch ?? "main";
252
- const existing = await readCollabBindingState(repoRoot, { persist: true });
253
- const branchBindings = { ...existing?.branchBindings ?? {} };
254
- branchBindings[branchName] = {
255
- projectId: normalizeProjectId(binding.projectId) ?? branchBindings[branchName]?.projectId ?? existing?.projectId ?? null,
256
- currentAppId: binding.currentAppId,
257
- upstreamAppId: binding.upstreamAppId,
258
- threadId: binding.threadId ?? null,
259
- laneId: binding.laneId ?? null,
260
- bindingMode: binding.bindingMode ?? "lane"
261
- };
262
- await writeJsonAtomic(
263
- filePath,
264
- buildBindingFileV3({
265
- repoFingerprint: binding.repoFingerprint ?? null,
266
- remoteUrl: binding.remoteUrl ?? null,
267
- defaultBranch: binding.defaultBranch ?? null,
268
- branchBindings
269
- })
270
- );
271
- return filePath;
272
- }
273
-
274
- export {
275
- reserveDirectory,
276
- reserveAvailableDirPath,
277
- getCollabBindingPath,
278
- readCollabBindingState,
279
- readCollabBinding,
280
- writeCollabBinding
281
- };