plac-micro-common 1.3.5 → 1.3.7
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.
|
@@ -39,19 +39,15 @@ const path = __importStar(require("path"));
|
|
|
39
39
|
const ejs = __importStar(require("ejs"));
|
|
40
40
|
let cached_font_base64 = null;
|
|
41
41
|
const cached_templates = {};
|
|
42
|
+
function getPackageRootPath() {
|
|
43
|
+
return path.resolve(__dirname, "..", "..", "..");
|
|
44
|
+
}
|
|
42
45
|
function getAssetsRootPath() {
|
|
43
|
-
return path.join(
|
|
46
|
+
return path.join(getPackageRootPath(), "dist", "assets");
|
|
44
47
|
}
|
|
45
48
|
function getFontBase64() {
|
|
46
49
|
if (!cached_font_base64) {
|
|
47
50
|
const font_path = path.join(getAssetsRootPath(), "fonts", "KhmerOS.ttf");
|
|
48
|
-
if (!fs.existsSync(font_path)) {
|
|
49
|
-
throw new Error(`Khmer font not found at path: ${font_path}`);
|
|
50
|
-
}
|
|
51
|
-
console.log("[generateFormSIO] __dirname =", __dirname);
|
|
52
|
-
console.log("[generateFormSIO] assets_root =", getAssetsRootPath());
|
|
53
|
-
console.log("[generateFormSIO] font_path =", font_path);
|
|
54
|
-
console.log("[generateFormSIO] font exists =", fs.existsSync(font_path));
|
|
55
51
|
const font_buffer = fs.readFileSync(font_path);
|
|
56
52
|
cached_font_base64 = font_buffer.toString("base64");
|
|
57
53
|
}
|
|
@@ -62,13 +58,6 @@ function getTemplate(lang) {
|
|
|
62
58
|
const template_path = lang === "en"
|
|
63
59
|
? path.join(getAssetsRootPath(), "templates", "sio-form-en.ejs")
|
|
64
60
|
: path.join(getAssetsRootPath(), "templates", "sio-form-kh.ejs");
|
|
65
|
-
if (!fs.existsSync(template_path)) {
|
|
66
|
-
throw new Error(`SIO template not found at path: ${template_path}`);
|
|
67
|
-
}
|
|
68
|
-
console.log("[generateFormSIO] __dirname =", __dirname);
|
|
69
|
-
console.log("[generateFormSIO] assets_root =", getAssetsRootPath());
|
|
70
|
-
console.log("[generateFormSIO] template_path =", template_path);
|
|
71
|
-
console.log("[generateFormSIO] template exists =", fs.existsSync(template_path));
|
|
72
61
|
const template = fs.readFileSync(template_path, "utf8");
|
|
73
62
|
cached_templates[lang] = ejs.compile(template);
|
|
74
63
|
}
|