slice-machine-ui 2.19.2-alpha.lg-import-slices.1 → 2.19.2-alpha.xru-unskip-e2e-test-redirection.2
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/out/404.html +1 -1
- package/out/_next/static/UxC5PuGC_LR5N5R6FFDo6/_buildManifest.js +1 -0
- package/out/_next/static/chunks/422-c9192a1dbdd2ae0e.js +1 -0
- package/out/_next/static/chunks/{429-e5d7e39160de9f5e.js → 429-aab52070cad2884b.js} +1 -1
- package/out/_next/static/chunks/489-ce3053e1d81ade83.js +1 -0
- package/out/_next/static/chunks/907-180eb33eefccc237.js +1 -0
- package/out/_next/static/chunks/pages/{_app-a8345a65a46d8112.js → _app-0e4d39dfdf8ae39a.js} +1 -1
- package/out/_next/static/chunks/pages/custom-types/{[customTypeId]-97120b65616617fb.js → [customTypeId]-af9376721beb489e.js} +1 -1
- package/out/_next/static/chunks/pages/page-types/{[pageTypeId]-b358358b5c2c1c43.js → [pageTypeId]-a24665e91b882169.js} +1 -1
- package/out/_next/static/chunks/pages/slices/[lib]/[sliceName]/[variation]/{simulator-8c70298caf51bed0.js → simulator-faeb6d2f77d97096.js} +1 -1
- package/out/_next/static/chunks/pages/slices-81c1c3f1bcad60f4.js +1 -0
- package/out/changelog.html +1 -1
- package/out/changes.html +1 -1
- package/out/custom-types/[customTypeId].html +1 -1
- package/out/custom-types.html +1 -1
- package/out/index.html +1 -1
- package/out/labs.html +1 -1
- package/out/page-types/[pageTypeId].html +1 -1
- package/out/slices/[lib]/[sliceName]/[variation]/simulator.html +1 -1
- package/out/slices/[lib]/[sliceName]/[variation].html +1 -1
- package/out/slices.html +1 -1
- package/package.json +3 -3
- package/src/features/customTypes/customTypesBuilder/CreateSliceFromImageModal/CreateSliceFromImageModal.tsx +36 -3
- package/src/features/customTypes/customTypesBuilder/SliceZoneBlankSlate.tsx +0 -11
- package/src/features/customTypes/customTypesBuilder/sliceCreationOptions.tsx +0 -14
- package/src/legacy/lib/builders/CustomTypeBuilder/SliceZone/index.tsx +0 -51
- package/src/pages/slices.tsx +0 -30
- package/out/_next/static/Q_2lm2CqEzK8hMGWeR30R/_buildManifest.js +0 -1
- package/out/_next/static/chunks/130-e1a16d2f94fb2b64.js +0 -1
- package/out/_next/static/chunks/489-d6580011169630a1.js +0 -1
- package/out/_next/static/chunks/585-c89bb2471e85b9f8.js +0 -1
- package/out/_next/static/chunks/928-ebbe58b08e1e70b1.js +0 -1
- package/out/_next/static/chunks/954-bedaaabf664584a0.js +0 -1
- package/out/_next/static/chunks/pages/slices-d5a2b0fcb7490565.js +0 -1
- package/src/features/customTypes/customTypesBuilder/ImportSlicesFromLibraryModal/ImportSlicesFromLibraryModal.tsx +0 -291
- package/src/features/customTypes/customTypesBuilder/ImportSlicesFromLibraryModal/SliceCard.tsx +0 -48
- package/src/features/customTypes/customTypesBuilder/ImportSlicesFromLibraryModal/hooks/useImportSlicesFromGithub.ts +0 -93
- package/src/features/customTypes/customTypesBuilder/ImportSlicesFromLibraryModal/index.tsx +0 -1
- package/src/features/customTypes/customTypesBuilder/ImportSlicesFromLibraryModal/types.ts +0 -28
- package/src/features/customTypes/customTypesBuilder/ImportSlicesFromLibraryModal/utils/addSlices.ts +0 -193
- package/src/features/customTypes/customTypesBuilder/ImportSlicesFromLibraryModal/utils/github.ts +0 -630
- package/src/features/customTypes/customTypesBuilder/ImportSlicesFromLibraryModal/utils/mapWithConcurrency.ts +0 -28
- package/src/features/customTypes/customTypesBuilder/ImportSlicesFromLibraryModal/utils/sliceWithoutConflicts.ts +0 -51
- package/src/features/customTypes/customTypesBuilder/shared/getSubmitButtonLabel.ts +0 -12
- package/src/features/customTypes/customTypesBuilder/shared/useExistingSlices.ts +0 -26
- /package/out/_next/static/{Q_2lm2CqEzK8hMGWeR30R → UxC5PuGC_LR5N5R6FFDo6}/_ssgManifest.js +0 -0
package/src/features/customTypes/customTypesBuilder/ImportSlicesFromLibraryModal/utils/addSlices.ts
DELETED
|
@@ -1,193 +0,0 @@
|
|
|
1
|
-
import { managerClient } from "@/managerClient";
|
|
2
|
-
|
|
3
|
-
import { NewSlice, SliceFile } from "../types";
|
|
4
|
-
import { mapWithConcurrency } from "./mapWithConcurrency";
|
|
5
|
-
|
|
6
|
-
export async function addSlices(newSlices: NewSlice[]) {
|
|
7
|
-
// use the first library
|
|
8
|
-
const { libraries = [] } =
|
|
9
|
-
await managerClient.project.getSliceMachineConfig();
|
|
10
|
-
const library = libraries[0];
|
|
11
|
-
if (!library) {
|
|
12
|
-
throw new Error("No library found in the config.");
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
// Create slices with bounded concurrency
|
|
16
|
-
await mapWithConcurrency(newSlices, 3, async (slice: NewSlice) => {
|
|
17
|
-
const { errors } = await managerClient.slices.createSlice({
|
|
18
|
-
libraryID: library,
|
|
19
|
-
model: slice.model,
|
|
20
|
-
componentContents: slice.componentContents,
|
|
21
|
-
});
|
|
22
|
-
if (errors.length) {
|
|
23
|
-
throw new Error(`Failed to create slice ${slice.model.id}.`);
|
|
24
|
-
}
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
// Update mocks and screenshots, and write additional files
|
|
28
|
-
const slices = await mapWithConcurrency(
|
|
29
|
-
newSlices,
|
|
30
|
-
3,
|
|
31
|
-
async (slice: NewSlice) => {
|
|
32
|
-
const { model, image, langSmithUrl, mocks, files, screenshots } = slice;
|
|
33
|
-
|
|
34
|
-
// Update mocks if available
|
|
35
|
-
if (mocks && Array.isArray(mocks) && mocks.length > 0) {
|
|
36
|
-
const { errors: mocksErrors } =
|
|
37
|
-
await managerClient.slices.updateSliceMocks({
|
|
38
|
-
libraryID: library,
|
|
39
|
-
sliceID: model.id,
|
|
40
|
-
mocks,
|
|
41
|
-
});
|
|
42
|
-
if (mocksErrors.length) {
|
|
43
|
-
console.warn(
|
|
44
|
-
`Failed to update mocks for slice ${model.id}:`,
|
|
45
|
-
mocksErrors,
|
|
46
|
-
);
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
// Update screenshots for all variations
|
|
51
|
-
if (screenshots && Object.keys(screenshots).length > 0) {
|
|
52
|
-
await Promise.all(
|
|
53
|
-
Object.entries(screenshots).map(
|
|
54
|
-
async ([variationID, screenshotFile]) => {
|
|
55
|
-
if (screenshotFile.size > 0) {
|
|
56
|
-
await managerClient.slices.updateSliceScreenshot({
|
|
57
|
-
libraryID: library,
|
|
58
|
-
sliceID: model.id,
|
|
59
|
-
variationID,
|
|
60
|
-
data: screenshotFile,
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
},
|
|
64
|
-
),
|
|
65
|
-
);
|
|
66
|
-
} else if (
|
|
67
|
-
image.size > 0 &&
|
|
68
|
-
model.variations !== undefined &&
|
|
69
|
-
model.variations.length > 0
|
|
70
|
-
) {
|
|
71
|
-
// Fallback to using the first image if no screenshots were provided
|
|
72
|
-
await managerClient.slices.updateSliceScreenshot({
|
|
73
|
-
libraryID: library,
|
|
74
|
-
sliceID: model.id,
|
|
75
|
-
variationID: model.variations[0].id,
|
|
76
|
-
data: image,
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
// Write additional files (CSS, other assets, etc.)
|
|
81
|
-
console.log(
|
|
82
|
-
`About to write files for slice ${model.id}:`,
|
|
83
|
-
files
|
|
84
|
-
? `${files.length} file(s) - ${files
|
|
85
|
-
.map((f: SliceFile) => f.path)
|
|
86
|
-
.join(", ")}`
|
|
87
|
-
: "no files",
|
|
88
|
-
);
|
|
89
|
-
if (files && files.length > 0) {
|
|
90
|
-
await writeSliceFiles({
|
|
91
|
-
libraryID: library,
|
|
92
|
-
sliceID: model.id,
|
|
93
|
-
files,
|
|
94
|
-
});
|
|
95
|
-
} else {
|
|
96
|
-
console.warn(`No files to write for slice ${model.id}. Files:`, files);
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
return { model, langSmithUrl };
|
|
100
|
-
},
|
|
101
|
-
);
|
|
102
|
-
|
|
103
|
-
return { library, slices };
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
/**
|
|
107
|
-
* Writes additional slice files to the filesystem using the manager's plugin runner
|
|
108
|
-
* Uses the manager client's RPC interface to write files
|
|
109
|
-
*/
|
|
110
|
-
async function writeSliceFiles(args: {
|
|
111
|
-
libraryID: string;
|
|
112
|
-
sliceID: string;
|
|
113
|
-
files: SliceFile[];
|
|
114
|
-
}): Promise<void> {
|
|
115
|
-
const { libraryID, sliceID, files } = args;
|
|
116
|
-
|
|
117
|
-
if (files.length === 0) {
|
|
118
|
-
return;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
// Filter out files that are already handled by other methods
|
|
122
|
-
// Note: We still write ALL files, but skip ones that are handled by createSlice/updateSliceMocks/updateSliceScreenshot
|
|
123
|
-
// This includes component files in subdirectories, CSS files, assets, etc.
|
|
124
|
-
const filesToWrite = files.filter(
|
|
125
|
-
(file) =>
|
|
126
|
-
// Skip mocks.json (handled by updateSliceMocks)
|
|
127
|
-
file.path !== "mocks.json" &&
|
|
128
|
-
// Skip screenshots (handled by updateSliceScreenshot)
|
|
129
|
-
!file.path.startsWith("screenshot-") &&
|
|
130
|
-
// Skip the main index component file (handled by createSlice with componentContents)
|
|
131
|
-
// But allow component files in subdirectories (e.g., components/Button.tsx)
|
|
132
|
-
!file.path.match(/^index\.(tsx?|jsx?|vue|svelte)$/),
|
|
133
|
-
);
|
|
134
|
-
|
|
135
|
-
console.log(
|
|
136
|
-
`Writing ${filesToWrite.length} additional file(s) for slice ${sliceID}:`,
|
|
137
|
-
filesToWrite.map((f) => f.path),
|
|
138
|
-
);
|
|
139
|
-
|
|
140
|
-
if (filesToWrite.length === 0) {
|
|
141
|
-
return;
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
try {
|
|
145
|
-
// Convert ArrayBuffer to base64 string for binary files to send via RPC
|
|
146
|
-
const filesForRPC = filesToWrite.map((file) => {
|
|
147
|
-
if (file.isBinary && file.contents instanceof ArrayBuffer) {
|
|
148
|
-
// Convert ArrayBuffer to base64
|
|
149
|
-
const bytes = new Uint8Array(file.contents);
|
|
150
|
-
const binary = bytes.reduce(
|
|
151
|
-
(acc, byte) => acc + String.fromCharCode(byte),
|
|
152
|
-
"",
|
|
153
|
-
);
|
|
154
|
-
return {
|
|
155
|
-
path: file.path,
|
|
156
|
-
contents: btoa(binary),
|
|
157
|
-
isBinary: true,
|
|
158
|
-
};
|
|
159
|
-
} else if (typeof file.contents === "string") {
|
|
160
|
-
return {
|
|
161
|
-
path: file.path,
|
|
162
|
-
contents: file.contents,
|
|
163
|
-
isBinary: false,
|
|
164
|
-
};
|
|
165
|
-
} else {
|
|
166
|
-
throw new Error(`Unexpected file contents type for ${file.path}`);
|
|
167
|
-
}
|
|
168
|
-
});
|
|
169
|
-
|
|
170
|
-
const result = await managerClient.slices.writeSliceFiles({
|
|
171
|
-
libraryID,
|
|
172
|
-
sliceID,
|
|
173
|
-
files: filesForRPC,
|
|
174
|
-
});
|
|
175
|
-
|
|
176
|
-
if (result.errors.length > 0) {
|
|
177
|
-
console.error(
|
|
178
|
-
`Errors writing files for slice ${sliceID}:`,
|
|
179
|
-
result.errors.map((e: { message?: string }) => e.message ?? String(e)),
|
|
180
|
-
);
|
|
181
|
-
} else {
|
|
182
|
-
console.log(
|
|
183
|
-
`Successfully wrote ${filesToWrite.length} file(s) for slice ${sliceID}`,
|
|
184
|
-
);
|
|
185
|
-
}
|
|
186
|
-
} catch (error) {
|
|
187
|
-
console.error(
|
|
188
|
-
`Error writing files for slice ${sliceID}:`,
|
|
189
|
-
error instanceof Error ? error.message : String(error),
|
|
190
|
-
);
|
|
191
|
-
// Don't throw - allow slice creation to succeed even if some files fail
|
|
192
|
-
}
|
|
193
|
-
}
|