@remixhq/core 0.1.13 → 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 (78) hide show
  1. package/dist/api.d.ts +76 -1
  2. package/dist/api.js +1 -1
  3. package/dist/auth.js +1 -1
  4. package/dist/binding-WiIRI2fl.d.ts +43 -0
  5. package/dist/binding.d.ts +1 -21
  6. package/dist/binding.js +2 -0
  7. package/dist/{chunk-EVWDYCBL.js → chunk-P6JHXOV4.js} +36 -23
  8. package/dist/{chunk-R7FVSCQW.js → chunk-US5SM7ZC.js} +19 -1
  9. package/dist/collab.d.ts +376 -611
  10. package/dist/collab.js +2381 -376
  11. package/dist/contracts-CHmD-fMj.d.ts +677 -0
  12. package/dist/history.d.ts +64 -0
  13. package/dist/history.js +529 -0
  14. package/dist/index.d.ts +1 -0
  15. package/dist/index.js +2 -2
  16. package/package.json +9 -3
  17. package/dist/chunk-2WGZS7CD.js +0 -0
  18. package/dist/chunk-34WDQCPF.js +0 -242
  19. package/dist/chunk-4276ARDF.js +0 -303
  20. package/dist/chunk-4L3ZBZUQ.js +0 -281
  21. package/dist/chunk-54CBEP2W.js +0 -570
  22. package/dist/chunk-55K5GHAZ.js +0 -252
  23. package/dist/chunk-5H5CZKGN.js +0 -691
  24. package/dist/chunk-5NTOJXEZ.js +0 -223
  25. package/dist/chunk-7WUKH3ZD.js +0 -221
  26. package/dist/chunk-AE2HPMUZ.js +0 -80
  27. package/dist/chunk-AEAOYVIL.js +0 -200
  28. package/dist/chunk-B5S3PUIR.js +0 -388
  29. package/dist/chunk-BJFCN2C3.js +0 -46
  30. package/dist/chunk-BNKPTE2U.js +0 -401
  31. package/dist/chunk-C5NBNU32.js +0 -240
  32. package/dist/chunk-CJFGQE7D.js +0 -46
  33. package/dist/chunk-CUUXZSKW.js +0 -611
  34. package/dist/chunk-DCU3646I.js +0 -12
  35. package/dist/chunk-DEWAIK5X.js +0 -11
  36. package/dist/chunk-DRD6EVTT.js +0 -447
  37. package/dist/chunk-DXCL6I4Q.js +0 -399
  38. package/dist/chunk-E4KAGBU7.js +0 -134
  39. package/dist/chunk-E6AYE22H.js +0 -343
  40. package/dist/chunk-EF3677RE.js +0 -93
  41. package/dist/chunk-EW4PWFHB.js +0 -46
  42. package/dist/chunk-FAZUMWBS.js +0 -93
  43. package/dist/chunk-GEHSFPCD.js +0 -93
  44. package/dist/chunk-GFOBGYW4.js +0 -252
  45. package/dist/chunk-INDDXWAH.js +0 -92
  46. package/dist/chunk-IXWQWFYT.js +0 -342
  47. package/dist/chunk-J3J4PBQ7.js +0 -710
  48. package/dist/chunk-K54U353Z.js +0 -691
  49. package/dist/chunk-K57ZFDGC.js +0 -15
  50. package/dist/chunk-NDA7EJJA.js +0 -286
  51. package/dist/chunk-NK2DA4X6.js +0 -357
  52. package/dist/chunk-OBYR4JHZ.js +0 -374
  53. package/dist/chunk-OJMTW22J.js +0 -286
  54. package/dist/chunk-OMUDRPUI.js +0 -195
  55. package/dist/chunk-ONKKRS2C.js +0 -239
  56. package/dist/chunk-OWFBBWU7.js +0 -196
  57. package/dist/chunk-OZRXDDEL.js +0 -46
  58. package/dist/chunk-P7EM3N73.js +0 -46
  59. package/dist/chunk-POYB6MCQ.js +0 -373
  60. package/dist/chunk-PR5QKMHM.js +0 -46
  61. package/dist/chunk-R44EOUS4.js +0 -288
  62. package/dist/chunk-RIP2MIZL.js +0 -710
  63. package/dist/chunk-RKMMEML5.js +0 -46
  64. package/dist/chunk-RM2BGDBB.js +0 -400
  65. package/dist/chunk-RREREIGW.js +0 -710
  66. package/dist/chunk-TQHLFQY4.js +0 -448
  67. package/dist/chunk-TY3SSQQK.js +0 -688
  68. package/dist/chunk-UGKPOCN5.js +0 -710
  69. package/dist/chunk-UIGKSCTD.js +0 -406
  70. package/dist/chunk-UWIVJRTI.js +0 -343
  71. package/dist/chunk-VA6WXRWB.js +0 -636
  72. package/dist/chunk-XC2FV57P.js +0 -385
  73. package/dist/chunk-XOQIADCH.js +0 -223
  74. package/dist/chunk-ZAQZKEH4.js +0 -46
  75. package/dist/chunk-ZBMOGUSJ.js +0 -17
  76. package/dist/chunk-ZXP6ENQY.js +0 -244
  77. package/dist/index.cjs +0 -1269
  78. package/dist/index.d.cts +0 -482
@@ -1,244 +0,0 @@
1
- import {
2
- getCurrentBranch
3
- } from "./chunk-K54U353Z.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 buildBindingFileV2(params) {
61
- return {
62
- schemaVersion: 2,
63
- projectId: params.projectId,
64
- repoFingerprint: params.repoFingerprint,
65
- remoteUrl: params.remoteUrl,
66
- defaultBranch: params.defaultBranch,
67
- branchBindings: params.branchBindings
68
- };
69
- }
70
- function normalizeBranchName(value) {
71
- const normalized = String(value ?? "").trim();
72
- return normalized || null;
73
- }
74
- function normalizeBranchBinding(value) {
75
- if (!value?.currentAppId || !value?.upstreamAppId) return null;
76
- return {
77
- currentAppId: value.currentAppId,
78
- upstreamAppId: value.upstreamAppId,
79
- threadId: value.threadId ?? null,
80
- preferredBranch: value.preferredBranch ?? null,
81
- laneId: value.laneId ?? null,
82
- bindingMode: value.bindingMode === "legacy" ? "legacy" : "lane"
83
- };
84
- }
85
- function buildResolvedBinding(params) {
86
- if (!params.binding) return null;
87
- return {
88
- schemaVersion: 2,
89
- projectId: params.projectId,
90
- currentAppId: params.binding.currentAppId,
91
- upstreamAppId: params.binding.upstreamAppId,
92
- threadId: params.binding.threadId,
93
- repoFingerprint: params.repoFingerprint,
94
- remoteUrl: params.remoteUrl,
95
- defaultBranch: params.defaultBranch,
96
- preferredBranch: params.binding.preferredBranch ?? params.defaultBranch ?? null,
97
- laneId: params.binding.laneId,
98
- branchName: params.branchName,
99
- bindingMode: params.binding.bindingMode
100
- };
101
- }
102
- async function readCollabBindingState(repoRoot) {
103
- try {
104
- const filePath = getCollabBindingPath(repoRoot);
105
- const raw = await fs2.readFile(filePath, "utf8");
106
- const parsed = JSON.parse(raw);
107
- if (!parsed || typeof parsed !== "object" || !("projectId" in parsed) || !parsed.projectId) return null;
108
- const currentBranch = normalizeBranchName(await getCurrentBranch(repoRoot).catch(() => null));
109
- if (parsed.schemaVersion === 1) {
110
- if (!parsed.currentAppId || !parsed.upstreamAppId) return null;
111
- const preferredBranch = normalizeBranchName(parsed.preferredBranch ?? parsed.defaultBranch ?? null);
112
- const branchKey = preferredBranch ?? currentBranch ?? null;
113
- const branchBindings2 = branchKey ? {
114
- [branchKey]: {
115
- currentAppId: parsed.currentAppId,
116
- upstreamAppId: parsed.upstreamAppId,
117
- threadId: parsed.threadId ?? null,
118
- preferredBranch,
119
- laneId: null,
120
- bindingMode: "legacy"
121
- }
122
- } : {};
123
- const migratedFile = buildBindingFileV2({
124
- projectId: parsed.projectId,
125
- repoFingerprint: parsed.repoFingerprint ?? null,
126
- remoteUrl: parsed.remoteUrl ?? null,
127
- defaultBranch: parsed.defaultBranch ?? null,
128
- branchBindings: branchBindings2
129
- });
130
- try {
131
- await writeJsonAtomic(filePath, migratedFile);
132
- } catch {
133
- }
134
- return {
135
- schemaVersion: 2,
136
- projectId: migratedFile.projectId,
137
- repoFingerprint: migratedFile.repoFingerprint,
138
- remoteUrl: migratedFile.remoteUrl,
139
- defaultBranch: migratedFile.defaultBranch,
140
- currentBranch,
141
- branchBindings: migratedFile.branchBindings,
142
- binding: buildResolvedBinding({
143
- projectId: migratedFile.projectId,
144
- repoFingerprint: migratedFile.repoFingerprint,
145
- remoteUrl: migratedFile.remoteUrl,
146
- defaultBranch: migratedFile.defaultBranch,
147
- branchName: branchKey,
148
- binding: branchKey ? migratedFile.branchBindings[branchKey] : null
149
- })
150
- };
151
- }
152
- if (parsed.schemaVersion !== 2) return null;
153
- const file = parsed;
154
- if (!file.projectId) return null;
155
- let shouldPersistNormalizedBranchBindings = false;
156
- const branchBindings = Object.fromEntries(
157
- Object.entries(file.branchBindings ?? {}).map(([branchName, branchBinding]) => {
158
- const normalized = normalizeBranchBinding(branchBinding);
159
- const rawBindingMode = branchBinding && typeof branchBinding === "object" && "bindingMode" in branchBinding ? branchBinding.bindingMode : null;
160
- if (normalized && rawBindingMode !== normalized.bindingMode) {
161
- shouldPersistNormalizedBranchBindings = true;
162
- }
163
- return [branchName, normalized];
164
- }).filter((entry) => Boolean(entry[1]))
165
- );
166
- const legacyExplicitBinding = normalizeBranchBinding(file.explicitBinding ?? null);
167
- const legacyExplicitBranch = normalizeBranchName(legacyExplicitBinding?.preferredBranch) ?? currentBranch ?? normalizeBranchName(file.defaultBranch);
168
- if (legacyExplicitBinding && legacyExplicitBranch) {
169
- branchBindings[legacyExplicitBranch] = {
170
- ...legacyExplicitBinding,
171
- preferredBranch: legacyExplicitBinding.preferredBranch ?? legacyExplicitBranch,
172
- bindingMode: "lane"
173
- };
174
- }
175
- if ("explicitBinding" in file || shouldPersistNormalizedBranchBindings) {
176
- try {
177
- await writeJsonAtomic(filePath, buildBindingFileV2({
178
- projectId: file.projectId,
179
- repoFingerprint: file.repoFingerprint ?? null,
180
- remoteUrl: file.remoteUrl ?? null,
181
- defaultBranch: file.defaultBranch ?? null,
182
- branchBindings
183
- }));
184
- } catch {
185
- }
186
- }
187
- const resolvedBranch = currentBranch ?? normalizeBranchName(file.defaultBranch);
188
- return {
189
- schemaVersion: 2,
190
- projectId: file.projectId,
191
- repoFingerprint: file.repoFingerprint ?? null,
192
- remoteUrl: file.remoteUrl ?? null,
193
- defaultBranch: file.defaultBranch ?? null,
194
- currentBranch,
195
- branchBindings,
196
- binding: buildResolvedBinding({
197
- projectId: file.projectId,
198
- repoFingerprint: file.repoFingerprint ?? null,
199
- remoteUrl: file.remoteUrl ?? null,
200
- defaultBranch: file.defaultBranch ?? null,
201
- branchName: resolvedBranch,
202
- binding: resolvedBranch ? branchBindings[resolvedBranch] ?? null : null
203
- })
204
- };
205
- } catch {
206
- return null;
207
- }
208
- }
209
- async function readCollabBinding(repoRoot) {
210
- const state = await readCollabBindingState(repoRoot);
211
- return state?.binding ?? null;
212
- }
213
- async function writeCollabBinding(repoRoot, binding) {
214
- const filePath = getCollabBindingPath(repoRoot);
215
- const currentBranch = normalizeBranchName(await getCurrentBranch(repoRoot).catch(() => null));
216
- const branchName = normalizeBranchName(binding.branchName) ?? currentBranch ?? normalizeBranchName(binding.preferredBranch) ?? binding.defaultBranch ?? "main";
217
- const existing = await readCollabBindingState(repoRoot);
218
- const branchBindings = { ...existing?.branchBindings ?? {} };
219
- branchBindings[branchName] = {
220
- currentAppId: binding.currentAppId,
221
- upstreamAppId: binding.upstreamAppId,
222
- threadId: binding.threadId ?? null,
223
- preferredBranch: binding.preferredBranch ?? branchName,
224
- laneId: binding.laneId ?? null,
225
- bindingMode: binding.bindingMode ?? "lane"
226
- };
227
- await writeJsonAtomic(filePath, buildBindingFileV2({
228
- projectId: binding.projectId,
229
- repoFingerprint: binding.repoFingerprint ?? null,
230
- remoteUrl: binding.remoteUrl ?? null,
231
- defaultBranch: binding.defaultBranch ?? null,
232
- branchBindings
233
- }));
234
- return filePath;
235
- }
236
-
237
- export {
238
- reserveDirectory,
239
- reserveAvailableDirPath,
240
- getCollabBindingPath,
241
- readCollabBindingState,
242
- readCollabBinding,
243
- writeCollabBinding
244
- };