Skip to content

Commit 97f606d

Browse files
committed
move import inside module declaration in package types
1 parent dcc4ec1 commit 97f606d

File tree

4 files changed

+11
-45
lines changed

4 files changed

+11
-45
lines changed

gulpfile.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1234,13 +1234,6 @@ function generateTypeScriptDefinitions(
12341234
"raiseEvent(...arguments: Parameters<Listener>): void;",
12351235
);
12361236

1237-
// Wrap the source to actually be inside of a declared cesium module
1238-
// and add any workaround and private utility types.
1239-
source = `declare module "@${scope}/${workspaceName}" {
1240-
${source}
1241-
}
1242-
`;
1243-
12441237
if (importModules) {
12451238
let imports = "";
12461239
Object.keys(importModules).forEach((workspace) => {
@@ -1254,6 +1247,13 @@ ${source}
12541247
source = imports + source;
12551248
}
12561249

1250+
// Wrap the source to actually be inside of a declared cesium module
1251+
// and add any workaround and private utility types.
1252+
source = `declare module "@${scope}/${workspaceName}" {
1253+
${source}
1254+
}
1255+
`;
1256+
12571257
// Write the final source file back out
12581258
writeFileSync(definitionsPath, source);
12591259

packages/sandcastle/sandcastle.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import process from "process";
33
const config = {
44
root: ".",
55
sourceUrl: "https://github.com/CesiumGS/cesium/blob/main/packages/sandcastle",
6-
publicDir: "./public",
6+
publicDirectory: "./public",
77
gallery: {
88
files: ["gallery"],
99
searchOptions: {

packages/sandcastle/scripts/buildGallery.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ if (import.meta.url.endsWith(`${pathToFileURL(process.argv[1])}`)) {
304304

305305
try {
306306
const config = await import(configPath);
307-
const { root, publicDir, gallery, sourceUrl } = config.default;
307+
const { root, publicDirectory, gallery, sourceUrl } = config.default;
308308

309309
// Paths are specified relative to the config file
310310
const configDir = dirname(configPath);
@@ -320,7 +320,7 @@ if (import.meta.url.endsWith(`${pathToFileURL(process.argv[1])}`)) {
320320

321321
buildGalleryOptions = {
322322
rootDirectory: configRoot,
323-
publicDirectory: publicDir,
323+
publicDirectory: publicDirectory,
324324
galleryFiles: files,
325325
sourceUrl,
326326
defaultThumbnail,

packages/sandcastle/src/SandcastleEditor.tsx

Lines changed: 1 addition & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -214,49 +214,15 @@ function SandcastleEditor({
214214
var Sandcastle: typeof import('Sandcastle').default;`;
215215
},
216216
},
217-
{
218-
url: typeImportPaths["@cesium/engine"],
219-
filename: "ts:cesium-engine.d.ts",
220-
},
221-
{
222-
url: typeImportPaths["@cesium/widgets"],
223-
filename: "ts:cesium-widgets.d.ts",
224-
transformTypes(typesContent) {
225-
// Monaco expects the import statements to be inside the module so
226-
// move the module declaration to the top of the "file"
227-
return `declare module "@cesium/widgets" {
228-
${typesContent.replace('declare module "@cesium/widgets" {', "")}`;
229-
},
230-
},
231217
];
232218

233219
const extraImportNames = Object.keys(typeImportPaths).filter(
234-
(name) =>
235-
!["cesium", "Sandcastle", "@cesium/engine", "@cesium/widgets"].includes(
236-
name,
237-
),
220+
(name) => !["cesium", "Sandcastle"].includes(name),
238221
);
239222
for (const extraName of extraImportNames) {
240223
typeImports.push({
241224
url: typeImportPaths[extraName],
242225
filename: `ts:${extraName.replace(/@\//, "-")}.d.ts`,
243-
transformTypes(typesContent) {
244-
// TODO: this feels a little messy and still very targeted at our own modules, is there a way to improve?
245-
// I was experimenting with setting the transform from Vite but that doesn't work with functions
246-
247-
// Monaco expects the import statements to be inside the module so
248-
// move the module declaration to the top of the "file"
249-
if (typesContent.trim().startsWith("import")) {
250-
const declareModuleLine = typesContent.match(
251-
/declare module "([\w@\-\/]+)" {/gm,
252-
)?.[0];
253-
if (declareModuleLine) {
254-
return `${declareModuleLine}
255-
${typesContent.replace(declareModuleLine, "")}`;
256-
}
257-
}
258-
return typesContent;
259-
},
260226
});
261227
}
262228

0 commit comments

Comments
 (0)