fix
This commit is contained in:
parent
06a8d6e482
commit
9397ebc5ca
File diff suppressed because one or more lines are too long
|
|
@ -75,6 +75,37 @@ export const initExtNotif = async (vi: VG, prasi_ext: PrasiExt) => {
|
||||||
switch (data.type) {
|
switch (data.type) {
|
||||||
case "notification-token":
|
case "notification-token":
|
||||||
prasi_ext.notif = { token: data.token };
|
prasi_ext.notif = { token: data.token };
|
||||||
|
w.notif = {
|
||||||
|
async send(data: NOTIF_ARG) {
|
||||||
|
if (vi && vi.site.api) {
|
||||||
|
return await vi.site.api._notif("send", {
|
||||||
|
type: "send",
|
||||||
|
id:
|
||||||
|
typeof data.user_id === "string"
|
||||||
|
? data.user_id
|
||||||
|
: data.user_id.toString(),
|
||||||
|
body: data.body,
|
||||||
|
title: data.title,
|
||||||
|
data: data.data,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
async register(user_id: any) {
|
||||||
|
if (vi && vi.site.api && prasi_ext.notif?.token) {
|
||||||
|
return await vi.site.api._notif("register", {
|
||||||
|
type: "register",
|
||||||
|
id:
|
||||||
|
typeof user_id === "string"
|
||||||
|
? user_id
|
||||||
|
: user_id.toString(),
|
||||||
|
token: prasi_ext.notif.token,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onReceive(notif) {},
|
||||||
|
onTap(notif) {},
|
||||||
|
};
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case "notification-tap":
|
case "notification-tap":
|
||||||
if (!w.notif?.onTap) {
|
if (!w.notif?.onTap) {
|
||||||
|
|
@ -111,38 +142,5 @@ export const initExtNotif = async (vi: VG, prasi_ext: PrasiExt) => {
|
||||||
});
|
});
|
||||||
|
|
||||||
window.parent.postMessage({ mobile: true, type: "ready" }, "*");
|
window.parent.postMessage({ mobile: true, type: "ready" }, "*");
|
||||||
w.notif = {
|
|
||||||
async send() {},
|
|
||||||
register() {},
|
|
||||||
onReceive(notif) {},
|
|
||||||
onTap(notif) {},
|
|
||||||
};
|
|
||||||
w.notif.register = async (user_id: any) => {
|
|
||||||
await waitUntil(() => prasi_ext.notif?.token);
|
|
||||||
if (vi && vi.site.api && prasi_ext.notif?.token) {
|
|
||||||
return await vi.site.api._notif("register", {
|
|
||||||
type: "register",
|
|
||||||
id: typeof user_id === "string" ? user_id : user_id.toString(),
|
|
||||||
token: prasi_ext.notif.token,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
if (w.notif) {
|
|
||||||
w.notif.send = async (data: NOTIF_ARG) => {
|
|
||||||
if (vi && vi.site.api) {
|
|
||||||
return await vi.site.api._notif("send", {
|
|
||||||
type: "send",
|
|
||||||
id:
|
|
||||||
typeof data.user_id === "string"
|
|
||||||
? data.user_id
|
|
||||||
: data.user_id.toString(),
|
|
||||||
body: data.body,
|
|
||||||
title: data.title,
|
|
||||||
data: data.data,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -30,25 +30,28 @@ await build({
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const glob = new Glob("**");
|
const build_all =
|
||||||
const public_files = [] as string[];
|
process.argv[process.argv.length - 1] === "main" ? false : true;
|
||||||
for await (const file of glob.scan(dir.path("app/web/public"))) {
|
if (build_all) {
|
||||||
|
const glob = new Glob("**");
|
||||||
|
const public_files = [] as string[];
|
||||||
|
for await (const file of glob.scan(dir.path("app/web/public"))) {
|
||||||
public_files.push(file);
|
public_files.push(file);
|
||||||
}
|
}
|
||||||
await Bun.write(
|
await Bun.write(
|
||||||
dir.path("app/web/public_files.ts"),
|
dir.path("app/web/public_files.ts"),
|
||||||
`export const files = ${JSON.stringify(public_files, null, 2)}`
|
`export const files = ${JSON.stringify(public_files, null, 2)}`
|
||||||
);
|
);
|
||||||
|
|
||||||
await removeAsync(dir.path("app/web/.parcel-cache"));
|
await removeAsync(dir.path("app/web/.parcel-cache"));
|
||||||
await removeAsync(dir.path("app/static"));
|
await removeAsync(dir.path("app/static"));
|
||||||
|
|
||||||
await writeAsync(
|
await writeAsync(
|
||||||
dir.path("app/web/timestamp.ts"),
|
dir.path("app/web/timestamp.ts"),
|
||||||
`export const version = "${createId().substring(0, 7)}";`
|
`export const version = "${createId().substring(0, 7)}";`
|
||||||
);
|
);
|
||||||
|
|
||||||
const args = [
|
const args = [
|
||||||
"node",
|
"node",
|
||||||
dir.path("node_modules/.bin/parcel"),
|
dir.path("node_modules/.bin/parcel"),
|
||||||
"build",
|
"build",
|
||||||
|
|
@ -57,18 +60,20 @@ const args = [
|
||||||
"--no-scope-hoist",
|
"--no-scope-hoist",
|
||||||
"--dist-dir",
|
"--dist-dir",
|
||||||
dir.path(`app/static`),
|
dir.path(`app/static`),
|
||||||
];
|
];
|
||||||
|
|
||||||
const parcel = spawn({
|
const parcel = spawn({
|
||||||
cmd: args,
|
cmd: args,
|
||||||
cwd: dir.path("app/web"),
|
cwd: dir.path("app/web"),
|
||||||
stdio: ["ignore", "inherit", "inherit"],
|
stdio: ["ignore", "inherit", "inherit"],
|
||||||
});
|
});
|
||||||
await parcel.exited;
|
await parcel.exited;
|
||||||
|
|
||||||
const public_br = dir.path("app/web/public-br");
|
const public_br = dir.path("app/web/public-br");
|
||||||
if (!(await existsAsync(public_br))) {
|
if (!(await existsAsync(public_br))) {
|
||||||
const api = new fdir().withRelativePaths().crawl(dir.path("app/web/public"));
|
const api = new fdir()
|
||||||
|
.withRelativePaths()
|
||||||
|
.crawl(dir.path("app/web/public"));
|
||||||
const files = api.sync();
|
const files = api.sync();
|
||||||
if (files) {
|
if (files) {
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
|
|
@ -89,12 +94,12 @@ if (!(await existsAsync(public_br))) {
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const static_br = dir.path("app/static-br");
|
const static_br = dir.path("app/static-br");
|
||||||
await removeAsync(static_br);
|
await removeAsync(static_br);
|
||||||
const files = await listAsync(dir.path("app/static"));
|
const files = await listAsync(dir.path("app/static"));
|
||||||
if (files) {
|
if (files) {
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
files
|
files
|
||||||
.filter((file) => statSync(dir.path(`app/static/${file}`)).isFile())
|
.filter((file) => statSync(dir.path(`app/static/${file}`)).isFile())
|
||||||
|
|
@ -130,4 +135,5 @@ if (files) {
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue