@kawaijs/renderer-dom 0.1.10 → 0.1.12
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/README.md +34 -12
- package/dist/asset-fallbacks.d.ts +13 -0
- package/dist/asset-fallbacks.d.ts.map +1 -0
- package/dist/asset-fallbacks.js +41 -0
- package/dist/asset-fallbacks.js.map +1 -0
- package/dist/components/choice-menu.d.ts +12 -0
- package/dist/components/choice-menu.d.ts.map +1 -0
- package/dist/components/choice-menu.js +44 -0
- package/dist/components/choice-menu.js.map +1 -0
- package/dist/components/dialogue-box.d.ts +29 -0
- package/dist/components/dialogue-box.d.ts.map +1 -0
- package/dist/components/dialogue-box.js +155 -0
- package/dist/components/dialogue-box.js.map +1 -0
- package/dist/components/hotspot-layer.d.ts +13 -0
- package/dist/components/hotspot-layer.d.ts.map +1 -0
- package/dist/components/hotspot-layer.js +47 -0
- package/dist/components/hotspot-layer.js.map +1 -0
- package/dist/components/main-menu.d.ts +36 -0
- package/dist/components/main-menu.d.ts.map +1 -0
- package/dist/components/main-menu.js +257 -0
- package/dist/components/main-menu.js.map +1 -0
- package/dist/components/quick-menu.d.ts +22 -0
- package/dist/components/quick-menu.d.ts.map +1 -0
- package/dist/components/quick-menu.js +59 -0
- package/dist/components/quick-menu.js.map +1 -0
- package/dist/components/stage-layer.d.ts +39 -0
- package/dist/components/stage-layer.d.ts.map +1 -0
- package/dist/components/stage-layer.js +253 -0
- package/dist/components/stage-layer.js.map +1 -0
- package/dist/components/vfx-layer.d.ts +28 -0
- package/dist/components/vfx-layer.d.ts.map +1 -0
- package/dist/components/vfx-layer.js +310 -0
- package/dist/components/vfx-layer.js.map +1 -0
- package/dist/embed.d.ts +5 -0
- package/dist/embed.d.ts.map +1 -0
- package/dist/embed.js +17 -0
- package/dist/embed.js.map +1 -0
- package/dist/icons.d.ts +31 -0
- package/dist/icons.d.ts.map +1 -0
- package/dist/icons.js +31 -0
- package/dist/icons.js.map +1 -0
- package/dist/index.d.ts +31 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +69 -3
- package/dist/index.js.map +1 -1
- package/dist/layout/viewport-adapter.d.ts +52 -0
- package/dist/layout/viewport-adapter.d.ts.map +1 -0
- package/dist/layout/viewport-adapter.js +123 -0
- package/dist/layout/viewport-adapter.js.map +1 -0
- package/dist/modals/about-modal.d.ts +3 -0
- package/dist/modals/about-modal.d.ts.map +1 -0
- package/dist/modals/about-modal.js +59 -0
- package/dist/modals/about-modal.js.map +1 -0
- package/dist/modals/achievements-modal.d.ts +4 -0
- package/dist/modals/achievements-modal.d.ts.map +1 -0
- package/dist/modals/achievements-modal.js +103 -0
- package/dist/modals/achievements-modal.js.map +1 -0
- package/dist/modals/confirm-modal.d.ts +9 -0
- package/dist/modals/confirm-modal.d.ts.map +1 -0
- package/dist/modals/confirm-modal.js +80 -0
- package/dist/modals/confirm-modal.js.map +1 -0
- package/dist/modals/gallery-modal.d.ts +4 -0
- package/dist/modals/gallery-modal.d.ts.map +1 -0
- package/dist/modals/gallery-modal.js +128 -0
- package/dist/modals/gallery-modal.js.map +1 -0
- package/dist/modals/history-modal.d.ts +3 -0
- package/dist/modals/history-modal.d.ts.map +1 -0
- package/dist/modals/history-modal.js +66 -0
- package/dist/modals/history-modal.js.map +1 -0
- package/dist/modals/input-modal.d.ts +10 -0
- package/dist/modals/input-modal.d.ts.map +1 -0
- package/dist/modals/input-modal.js +62 -0
- package/dist/modals/input-modal.js.map +1 -0
- package/dist/modals/save-load-modal.d.ts +3 -0
- package/dist/modals/save-load-modal.d.ts.map +1 -0
- package/dist/modals/save-load-modal.js +262 -0
- package/dist/modals/save-load-modal.js.map +1 -0
- package/dist/modals/settings-modal.d.ts +14 -0
- package/dist/modals/settings-modal.d.ts.map +1 -0
- package/dist/modals/settings-modal.js +128 -0
- package/dist/modals/settings-modal.js.map +1 -0
- package/dist/renderer.d.ts +75 -34
- package/dist/renderer.d.ts.map +1 -1
- package/dist/renderer.js +763 -529
- package/dist/renderer.js.map +1 -1
- package/dist/share-meta.d.ts +27 -0
- package/dist/share-meta.d.ts.map +1 -0
- package/dist/share-meta.js +113 -0
- package/dist/share-meta.js.map +1 -0
- package/dist/touch.d.ts +16 -0
- package/dist/touch.d.ts.map +1 -0
- package/dist/touch.js +60 -0
- package/dist/touch.js.map +1 -0
- package/dist/types.d.ts +134 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +60 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/focus-trap.d.ts +6 -0
- package/dist/utils/focus-trap.d.ts.map +1 -0
- package/dist/utils/focus-trap.js +52 -0
- package/dist/utils/focus-trap.js.map +1 -0
- package/dist/utils/rich-text.d.ts +7 -0
- package/dist/utils/rich-text.d.ts.map +1 -0
- package/dist/utils/rich-text.js +31 -0
- package/dist/utils/rich-text.js.map +1 -0
- package/package.json +17 -3
- package/src/theme.css +1995 -523
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lightweight focus trap for modal dialogs.
|
|
3
|
+
* Returns a disposer that restores focus to the previously focused element.
|
|
4
|
+
*/
|
|
5
|
+
export function trapFocus(container) {
|
|
6
|
+
const previouslyFocused = typeof document !== 'undefined' && document.activeElement instanceof HTMLElement
|
|
7
|
+
? document.activeElement
|
|
8
|
+
: null;
|
|
9
|
+
const getFocusable = () => Array.from(container.querySelectorAll('button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])')).filter((el) => el.offsetParent !== null || el === document.activeElement);
|
|
10
|
+
const onKeyDown = (e) => {
|
|
11
|
+
if (e.key !== 'Tab')
|
|
12
|
+
return;
|
|
13
|
+
const focusable = getFocusable();
|
|
14
|
+
if (focusable.length === 0) {
|
|
15
|
+
e.preventDefault();
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
const first = focusable[0];
|
|
19
|
+
const last = focusable[focusable.length - 1];
|
|
20
|
+
if (e.shiftKey) {
|
|
21
|
+
if (document.activeElement === first || !container.contains(document.activeElement)) {
|
|
22
|
+
e.preventDefault();
|
|
23
|
+
last.focus();
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
else if (document.activeElement === last) {
|
|
27
|
+
e.preventDefault();
|
|
28
|
+
first.focus();
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
container.addEventListener('keydown', onKeyDown);
|
|
32
|
+
const focusTimer = setTimeout(() => {
|
|
33
|
+
const focusable = getFocusable();
|
|
34
|
+
(focusable[0] ?? container).focus();
|
|
35
|
+
}, 0);
|
|
36
|
+
if (!container.hasAttribute('tabindex')) {
|
|
37
|
+
container.setAttribute('tabindex', '-1');
|
|
38
|
+
}
|
|
39
|
+
return () => {
|
|
40
|
+
clearTimeout(focusTimer);
|
|
41
|
+
container.removeEventListener('keydown', onKeyDown);
|
|
42
|
+
if (previouslyFocused && typeof previouslyFocused.focus === 'function') {
|
|
43
|
+
try {
|
|
44
|
+
previouslyFocused.focus();
|
|
45
|
+
}
|
|
46
|
+
catch {
|
|
47
|
+
/* ignore */
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=focus-trap.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"focus-trap.js","sourceRoot":"","sources":["../../src/utils/focus-trap.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,UAAU,SAAS,CAAC,SAAsB;IAC9C,MAAM,iBAAiB,GACrB,OAAO,QAAQ,KAAK,WAAW,IAAI,QAAQ,CAAC,aAAa,YAAY,WAAW;QAC9E,CAAC,CAAC,QAAQ,CAAC,aAAa;QACxB,CAAC,CAAC,IAAI,CAAC;IAEX,MAAM,YAAY,GAAG,GAAkB,EAAE,CACvC,KAAK,CAAC,IAAI,CACR,SAAS,CAAC,gBAAgB,CACxB,0IAA0I,CAC3I,CACF,CAAC,MAAM,CAAC,CAAC,EAAE,EAAE,EAAE,CAA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C,SAAS,CAAC,YAAY,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC;IAC3C,CAAC;IAED,OAAO,GAAG,EAAE;QACV,YAAY,CAAC,UAAU,CAAC,CAAC;QACzB,SAAS,CAAC,mBAAmB,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;QACpD,IAAI,iBAAiB,IAAI,OAAO,iBAAiB,CAAC,KAAK,KAAK,UAAU,EAAE,CAAC;YACvE,IAAI,CAAC;gBACH,iBAAiB,CAAC,KAAK,EAAE,CAAC;YAC5B,CAAC;YAAC,MAAM,CAAC;gBACP,YAAY;YACd,CAAC;QACH,CAAC;IACH,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parses inline rich text markup: {b}...{/b}, {i}...{/i}, {color=#hex}...{/color}, {size=1.2em}...{/size}
|
|
3
|
+
* Includes sanitization against attribute injection and XSS.
|
|
4
|
+
*/
|
|
5
|
+
export declare function escapeHtml(raw: string): string;
|
|
6
|
+
export declare function formatRichText(raw: string): string;
|
|
7
|
+
//# sourceMappingURL=rich-text.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rich-text.d.ts","sourceRoot":"","sources":["../../src/utils/rich-text.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAO9C;AAED,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAmBlD"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parses inline rich text markup: {b}...{/b}, {i}...{/i}, {color=#hex}...{/color}, {size=1.2em}...{/size}
|
|
3
|
+
* Includes sanitization against attribute injection and XSS.
|
|
4
|
+
*/
|
|
5
|
+
export function escapeHtml(raw) {
|
|
6
|
+
return (raw || '')
|
|
7
|
+
.replace(/&/g, '&')
|
|
8
|
+
.replace(/</g, '<')
|
|
9
|
+
.replace(/>/g, '>')
|
|
10
|
+
.replace(/"/g, '"')
|
|
11
|
+
.replace(/'/g, ''');
|
|
12
|
+
}
|
|
13
|
+
export function formatRichText(raw) {
|
|
14
|
+
let formatted = escapeHtml(raw);
|
|
15
|
+
// {b}...{/b}
|
|
16
|
+
formatted = formatted.replace(/\{b\}(.*?)\{\/b\}/gi, '<strong class="kawa-bold">$1</strong>');
|
|
17
|
+
// {i}...{/i}
|
|
18
|
+
formatted = formatted.replace(/\{i\}(.*?)\{\/i\}/gi, '<em class="kawa-italic">$1</em>');
|
|
19
|
+
// {color=#hex|name}...{/color} — reject parentheses to reduce CSS injection surface
|
|
20
|
+
formatted = formatted.replace(/\{color=([#a-zA-Z0-9_.,\s-]+)\}(.*?)\{\/color\}/gi, (_match, colorVal, inner) => {
|
|
21
|
+
const cleanColor = colorVal.replace(/[^#a-zA-Z0-9_.,\s-]/g, '').trim();
|
|
22
|
+
return `<span style="color:${cleanColor}">${inner}</span>`;
|
|
23
|
+
});
|
|
24
|
+
// {size=1.2em}...{/size}
|
|
25
|
+
formatted = formatted.replace(/\{size=([0-9.]+(?:px|em|rem|%|vw|vh)?)\}(.*?)\{\/size\}/gi, (_match, sizeVal, inner) => {
|
|
26
|
+
const cleanSize = sizeVal.replace(/[^0-9.a-z%]/gi, '').trim();
|
|
27
|
+
return `<span style="font-size:${cleanSize}">${inner}</span>`;
|
|
28
|
+
});
|
|
29
|
+
return formatted;
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=rich-text.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rich-text.js","sourceRoot":"","sources":["../../src/utils/rich-text.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,UAAU,UAAU,CAAC,GAAW;IACpC,OAAO,CAAC,GAAG,IAAI,EAAE,CAAC;SACf,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC;SACtB,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC;SACrB,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC;SACrB,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC;SACvB,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;AAC5B,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,GAAW;IACxC,IAAI,SAAS,GAAG,UAAU,CAAC,GAAG,CAAC,CAAC;IAEhC,aAAa;IACb,SAAS,GAAG,SAAS,CAAC,OAAO,CAAC,qBAAqB,EAAE,uCAAuC,CAAC,CAAC;IAC9F,aAAa;IACb,SAAS,GAAG,SAAS,CAAC,OAAO,CAAC,qBAAqB,EAAE,iCAAiC,CAAC,CAAC;IACxF,oFAAoF;IACpF,SAAS,GAAG,SAAS,CAAC,OAAO,CAAC,mDAAmD,EAAE,CAAC,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,EAAE;QAC7G,MAAM,UAAU,GAAG,QAAQ,CAAC,OAAO,CAAC,sBAAsB,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;QACvE,OAAO,sBAAsB,UAAU,KAAK,KAAK,SAAS,CAAC;IAC7D,CAAC,CAAC,CAAC;IACH,yBAAyB;IACzB,SAAS,GAAG,SAAS,CAAC,OAAO,CAAC,2DAA2D,EAAE,CAAC,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE;QACpH,MAAM,SAAS,GAAG,OAAO,CAAC,OAAO,CAAC,eAAe,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;QAC9D,OAAO,0BAA0B,SAAS,KAAK,KAAK,SAAS,CAAC;IAChE,CAAC,CAAC,CAAC;IAEH,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,9 +1,22 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kawaijs/renderer-dom",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.12",
|
|
4
4
|
"description": "Standard semantic DOM and CSS rendering engine for Kawaijs visual novels",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
7
|
+
"module": "./dist/index.js",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.js"
|
|
12
|
+
},
|
|
13
|
+
"./theme.css": "./src/theme.css",
|
|
14
|
+
"./dist/theme.css": "./src/theme.css"
|
|
15
|
+
},
|
|
16
|
+
"sideEffects": [
|
|
17
|
+
"./src/theme.css",
|
|
18
|
+
"**/*.css"
|
|
19
|
+
],
|
|
7
20
|
"type": "module",
|
|
8
21
|
"files": [
|
|
9
22
|
"dist",
|
|
@@ -26,8 +39,9 @@
|
|
|
26
39
|
"typecheck": "tsc --noEmit"
|
|
27
40
|
},
|
|
28
41
|
"dependencies": {
|
|
29
|
-
"@kawaijs/ast": "^0.1.
|
|
30
|
-
"@kawaijs/
|
|
42
|
+
"@kawaijs/ast": "^0.1.12",
|
|
43
|
+
"@kawaijs/audio": "^0.1.12",
|
|
44
|
+
"@kawaijs/runtime": "^0.1.12"
|
|
31
45
|
},
|
|
32
46
|
"keywords": [
|
|
33
47
|
"kawaijs",
|