@pajh/buldng 0.0.6 → 0.0.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.
- package/package.json +1 -1
- package/src/buldng-html.js +17 -3
- package/src/buldng-web.ts +3 -2
- package/src/layout-err.ts +4 -2
- package/src/layout.ts +3 -2
- package/src/log-label.ts +7 -0
- package/src/wrapper.html +2 -1
package/package.json
CHANGED
package/src/buldng-html.js
CHANGED
|
@@ -94,7 +94,12 @@ function packageFileAbs(filename) {
|
|
|
94
94
|
// --------------------------------------------------
|
|
95
95
|
// buldngHTMLWrapper()
|
|
96
96
|
// --------------------------------------------------
|
|
97
|
-
export function buldngHTMLWrapper(source) {
|
|
97
|
+
export function buldngHTMLWrapper(source, { title = "Buldng", logLabel = "Buldng" } = {}) {
|
|
98
|
+
for (const [name, value] of Object.entries({ title, logLabel })) {
|
|
99
|
+
if (typeof value !== "string" || !value.trim()) {
|
|
100
|
+
throw new Error(`buldngHTMLWrapper(): '${name}' must be a non-empty string`);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
98
103
|
const srcWF = ensureWorkFile(source, "source");
|
|
99
104
|
|
|
100
105
|
// Compile buldng's layout.ts (lazy)
|
|
@@ -110,7 +115,16 @@ export function buldngHTMLWrapper(source) {
|
|
|
110
115
|
|
|
111
116
|
// Wrap project shell in wrapper.html
|
|
112
117
|
const wrapperWF = new WorkFile("file", { absPath: packageFileAbs("wrapper.html") }, []);
|
|
113
|
-
|
|
118
|
+
let html = replace(wrapperWF, "<!--TITLE-->", escapeHTML(title));
|
|
119
|
+
html = replace(html, "<!--LOG-LABEL-->", escapeHTML(logLabel));
|
|
120
|
+
return replace(html, "<!--CAMERA-STYLE-->", srcWF);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
function escapeHTML(value) {
|
|
124
|
+
return value.replace(/[&<>"']/g, character => ({
|
|
125
|
+
"&": "&", "<": "<", ">": ">",
|
|
126
|
+
'"': """, "'": "'"
|
|
127
|
+
})[character]);
|
|
114
128
|
}
|
|
115
129
|
|
|
116
130
|
// --------------------------------------------------
|
|
@@ -146,7 +160,7 @@ export function pageHTML({ app, css = null, js = null, out }) {
|
|
|
146
160
|
if (!projectCSS && !_warned.projectCSS) {
|
|
147
161
|
console.warn(
|
|
148
162
|
"pageHTML(): no 'projectCSS' registered — page will not include project CSS.\n" +
|
|
149
|
-
"To register project CSS use: reg('projectCSS', file`layout/
|
|
163
|
+
"To register project CSS use: reg('projectCSS', file`layout/project.css`)"
|
|
150
164
|
);
|
|
151
165
|
_warned.projectCSS = true;
|
|
152
166
|
}
|
package/src/buldng-web.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
// buldng-web.ts
|
|
2
|
-
// Runtime-only listener installer for
|
|
2
|
+
// Runtime-only listener installer for Buldng clients.
|
|
3
3
|
// This module contains NO production logic and NO module-level state.
|
|
4
4
|
// It is safe to be bundled multiple times.
|
|
5
5
|
|
|
6
6
|
export { showModal } from "./buldng-modal";
|
|
7
|
+
import { projectLogLabel } from "./log-label";
|
|
7
8
|
export type {
|
|
8
9
|
ModalIcon,
|
|
9
10
|
ModalResult,
|
|
@@ -25,7 +26,7 @@ export function setErrorPage(page: string) {
|
|
|
25
26
|
window.__error_handler?.(event, page);
|
|
26
27
|
});
|
|
27
28
|
|
|
28
|
-
console.log(
|
|
29
|
+
console.log(`${projectLogLabel()}: Error handler listener installed, redirect ${page}`);
|
|
29
30
|
|
|
30
31
|
}
|
|
31
32
|
|
package/src/layout-err.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* ============================================================
|
|
3
|
-
*
|
|
3
|
+
* BULDNG PRODUCTION ERROR SUBSYSTEM — layout-err.ts
|
|
4
4
|
* ============================================================
|
|
5
5
|
*
|
|
6
6
|
* This module is bundled ONLY by layout.ts.
|
|
@@ -22,6 +22,8 @@
|
|
|
22
22
|
* ============================================================
|
|
23
23
|
*/
|
|
24
24
|
|
|
25
|
+
import { projectLogLabel } from "./log-label";
|
|
26
|
+
|
|
25
27
|
const ERROR_STORAGE_PREFIX = "buldng:error:";
|
|
26
28
|
|
|
27
29
|
// ------------------------------------------------------------
|
|
@@ -36,7 +38,7 @@ export function installErrorHandler() {
|
|
|
36
38
|
window.__error_handler = (event, page) => {
|
|
37
39
|
handleError(event, page);
|
|
38
40
|
};
|
|
39
|
-
console.log(
|
|
41
|
+
console.log(`${projectLogLabel()}: Production error handler installed`);
|
|
40
42
|
}
|
|
41
43
|
|
|
42
44
|
// ------------------------------------------------------------
|
package/src/layout.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { installErrorHandler } from "./layout-err";
|
|
2
|
+
import { projectLogLabel } from "./log-label";
|
|
2
3
|
|
|
3
4
|
installErrorHandler();
|
|
4
5
|
|
|
@@ -133,7 +134,7 @@ function updateViewportInfo() {
|
|
|
133
134
|
buldrViewport.mode = mode;
|
|
134
135
|
|
|
135
136
|
console.log(
|
|
136
|
-
`[
|
|
137
|
+
`[${projectLogLabel()}] viewport ${buldrViewport.width}x${buldrViewport.height}, `
|
|
137
138
|
+ `aspect=${buldrViewport.aspect.toFixed(3)}, `
|
|
138
139
|
+ `mode=${mode}`
|
|
139
140
|
);
|
|
@@ -185,4 +186,4 @@ function initLayout() {
|
|
|
185
186
|
|
|
186
187
|
// Run layout immediately
|
|
187
188
|
initLayout();
|
|
188
|
-
window.__ready._resolveA();
|
|
189
|
+
window.__ready._resolveA();
|
package/src/log-label.ts
ADDED
package/src/wrapper.html
CHANGED
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
<head>
|
|
4
4
|
<meta charset="UTF-8">
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
6
|
-
<title
|
|
6
|
+
<title><!--TITLE--></title>
|
|
7
|
+
<meta name="application-name" content="<!--LOG-LABEL-->">
|
|
7
8
|
<link rel="icon" type="image/svg+xml" href="/favicon.svg">
|
|
8
9
|
<link rel="stylesheet" href="/buldng.css">
|
|
9
10
|
|