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 path = dir.data(`/code/${site_id}/site/typings.d.ts`);
|
||||||
const file = Bun.file(path);
|
const file = Bun.file(path);
|
||||||
if (await file.exists()) {
|
if (await file.exists()) {
|
||||||
const glob = new Glob("type_def*");
|
// const glob = new Glob("type_def*");
|
||||||
for await (const item of glob.scan(
|
// for await (const item of glob.scan(
|
||||||
dir.data(`/code/${site_id}/site`)
|
// dir.data(`/code/${site_id}/site`)
|
||||||
)) {
|
// )) {
|
||||||
const stamp = parseInt(item.split(".")[1]);
|
// const stamp = parseInt(item.split(".")[1]);
|
||||||
if (file.lastModified !== stamp) {
|
// if (file.lastModified !== stamp) {
|
||||||
await removeAsync(dir.data(`/code/${site_id}/site/${item}`));
|
// await removeAsync(dir.data(`/code/${site_id}/site/${item}`));
|
||||||
} else {
|
// } else {
|
||||||
return new Response(
|
// return new Response(
|
||||||
Bun.gzipSync(
|
// Bun.gzipSync(
|
||||||
await Bun.file(
|
// await Bun.file(
|
||||||
dir.data(`/code/${site_id}/site/${item}`)
|
// dir.data(`/code/${site_id}/site/${item}`)
|
||||||
).arrayBuffer()
|
// ).arrayBuffer()
|
||||||
),
|
// ),
|
||||||
{
|
// {
|
||||||
headers: {
|
// headers: {
|
||||||
"content-type": "application/json",
|
// "content-type": "application/json",
|
||||||
"content-encoding": "gzip",
|
// "content-encoding": "gzip",
|
||||||
},
|
// },
|
||||||
}
|
// }
|
||||||
);
|
// );
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const res = JSON.stringify(await parseTypeDef(path));
|
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") {
|
} else if (body.type === "ExportNamedDeclaration") {
|
||||||
for (const s of body.specifiers) {
|
if (body.source?.type === "StringLiteral") {
|
||||||
if (s.type === "ExportSpecifier") {
|
const ex = exports[body.source.value];
|
||||||
if (s.exported) {
|
if (ex) {
|
||||||
exports[t.id.value].push({
|
for (const s of body.specifiers) {
|
||||||
type: "named",
|
if (s.type === "ExportSpecifier") {
|
||||||
kind: "const",
|
if (s.exported) {
|
||||||
val: s.exported.value,
|
const found = ex.find(
|
||||||
});
|
(e) => e.val === s.exported?.value
|
||||||
} else if (s.orig) {
|
);
|
||||||
exports[t.id.value].push({
|
if (found) {
|
||||||
type: "named",
|
exports[t.id.value].push(found);
|
||||||
kind: "const",
|
}
|
||||||
val: s.orig.value,
|
} 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;
|
return jscript;
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
console.log("e", e);
|
|
||||||
return e.message.toString();
|
return e.message.toString();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -152,6 +151,7 @@ export const code_edit: SAction["code"]["edit"] = async function (
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
|
console.log(e);
|
||||||
return e.message.toString();
|
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") {
|
if (pe.status === "init") {
|
||||||
pe.status = "loading";
|
pe.status = "loading";
|
||||||
|
|
||||||
if (window.parent) {
|
if (window.parent !== window) {
|
||||||
const send = (msg: { type: "ready" }) => {
|
const send = (msg: { type: "ready" }) => {
|
||||||
window.parent.postMessage({ mobile: true, ...msg }, "*");
|
window.parent.postMessage({ mobile: true, ...msg }, "*");
|
||||||
};
|
};
|
||||||
window.addEventListener("message", async ({ data: raw }) => {
|
window.addEventListener("message", async ({ data: raw }) => {
|
||||||
|
console.log(raw);
|
||||||
if (typeof raw === "object" && raw.mobile) {
|
if (typeof raw === "object" && raw.mobile) {
|
||||||
console.log(raw);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
send({ type: "ready" });
|
send({ type: "ready" });
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue