fix type
This commit is contained in:
parent
a8002d9bab
commit
a9ff40264e
|
|
@ -41,29 +41,29 @@ export const _ = {
|
|||
const path = dir.data(`/code/${site_id}/site/typings.d.ts`);
|
||||
const file = Bun.file(path);
|
||||
if (await file.exists()) {
|
||||
const glob = new Glob("type_def*");
|
||||
for await (const item of glob.scan(
|
||||
dir.data(`/code/${site_id}/site`)
|
||||
)) {
|
||||
const stamp = parseInt(item.split(".")[1]);
|
||||
if (file.lastModified !== stamp) {
|
||||
await removeAsync(dir.data(`/code/${site_id}/site/${item}`));
|
||||
} else {
|
||||
return new Response(
|
||||
Bun.gzipSync(
|
||||
await Bun.file(
|
||||
dir.data(`/code/${site_id}/site/${item}`)
|
||||
).arrayBuffer()
|
||||
),
|
||||
{
|
||||
headers: {
|
||||
"content-type": "application/json",
|
||||
"content-encoding": "gzip",
|
||||
},
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
// const glob = new Glob("type_def*");
|
||||
// for await (const item of glob.scan(
|
||||
// dir.data(`/code/${site_id}/site`)
|
||||
// )) {
|
||||
// const stamp = parseInt(item.split(".")[1]);
|
||||
// if (file.lastModified !== stamp) {
|
||||
// await removeAsync(dir.data(`/code/${site_id}/site/${item}`));
|
||||
// } else {
|
||||
// return new Response(
|
||||
// Bun.gzipSync(
|
||||
// await Bun.file(
|
||||
// dir.data(`/code/${site_id}/site/${item}`)
|
||||
// ).arrayBuffer()
|
||||
// ),
|
||||
// {
|
||||
// headers: {
|
||||
// "content-type": "application/json",
|
||||
// "content-encoding": "gzip",
|
||||
// },
|
||||
// }
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
|
||||
try {
|
||||
const res = JSON.stringify(await parseTypeDef(path));
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -58,20 +58,45 @@ export const parseTypeDef = async (path: string) => {
|
|||
}
|
||||
}
|
||||
} else if (body.type === "ExportNamedDeclaration") {
|
||||
for (const s of body.specifiers) {
|
||||
if (s.type === "ExportSpecifier") {
|
||||
if (s.exported) {
|
||||
exports[t.id.value].push({
|
||||
type: "named",
|
||||
kind: "const",
|
||||
val: s.exported.value,
|
||||
});
|
||||
} else if (s.orig) {
|
||||
exports[t.id.value].push({
|
||||
type: "named",
|
||||
kind: "const",
|
||||
val: s.orig.value,
|
||||
});
|
||||
if (body.source?.type === "StringLiteral") {
|
||||
const ex = exports[body.source.value];
|
||||
if (ex) {
|
||||
for (const s of body.specifiers) {
|
||||
if (s.type === "ExportSpecifier") {
|
||||
if (s.exported) {
|
||||
const found = ex.find(
|
||||
(e) => e.val === s.exported?.value
|
||||
);
|
||||
if (found) {
|
||||
exports[t.id.value].push(found);
|
||||
}
|
||||
} else if (s.orig) {
|
||||
const found = ex.find(
|
||||
(e) => e.val === s.orig?.value
|
||||
);
|
||||
if (found) {
|
||||
exports[t.id.value].push(found);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (const s of body.specifiers) {
|
||||
if (s.type === "ExportSpecifier") {
|
||||
if (s.exported) {
|
||||
exports[t.id.value].push({
|
||||
type: "named",
|
||||
kind: "const",
|
||||
val: s.exported.value,
|
||||
});
|
||||
} else if (s.orig) {
|
||||
exports[t.id.value].push({
|
||||
type: "named",
|
||||
kind: "const",
|
||||
val: s.orig.value,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -114,7 +114,6 @@ export const code_edit: SAction["code"]["edit"] = async function (
|
|||
|
||||
return jscript;
|
||||
} catch (e: any) {
|
||||
console.log("e", e);
|
||||
return e.message.toString();
|
||||
}
|
||||
} else {
|
||||
|
|
@ -152,6 +151,7 @@ export const code_edit: SAction["code"]["edit"] = async function (
|
|||
});
|
||||
}
|
||||
} catch (e: any) {
|
||||
console.log(e);
|
||||
return e.message.toString();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
|
@ -15,13 +15,13 @@ export const initExts = async (vi: VG) => {
|
|||
if (pe.status === "init") {
|
||||
pe.status = "loading";
|
||||
|
||||
if (window.parent) {
|
||||
if (window.parent !== window) {
|
||||
const send = (msg: { type: "ready" }) => {
|
||||
window.parent.postMessage({ mobile: true, ...msg }, "*");
|
||||
};
|
||||
window.addEventListener("message", async ({ data: raw }) => {
|
||||
console.log(raw);
|
||||
if (typeof raw === "object" && raw.mobile) {
|
||||
console.log(raw);
|
||||
}
|
||||
});
|
||||
send({ type: "ready" });
|
||||
|
|
|
|||
Loading…
Reference in New Issue