@jjlmoya/utils-science 1.60.0 → 1.62.0
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
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jjlmoya/utils-science",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.62.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./src/index.ts",
|
|
6
6
|
"types": "./src/index.ts",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"postinstall": "node scripts/postinstall.mjs",
|
|
37
37
|
"predev": "node scripts/postinstall.mjs",
|
|
38
38
|
"prestart": "node scripts/postinstall.mjs",
|
|
39
|
-
"prebuild": "node scripts/postinstall.mjs",
|
|
39
|
+
"prebuild": "node scripts/postinstall.mjs && node scripts/validate-icons.mjs",
|
|
40
40
|
"qa": "npm run lint && npm run test && npm run build",
|
|
41
41
|
"cf:dry-run": "npm run build && wrangler deploy --dry-run",
|
|
42
42
|
"cf:preview": "npm run build && wrangler deploy --config wrangler.staging.jsonc",
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { createRequire } from 'node:module';
|
|
4
|
+
import { readFileSync, readdirSync } from 'node:fs';
|
|
5
|
+
import { dirname, join, relative, resolve } from 'node:path';
|
|
6
|
+
import { fileURLToPath } from 'node:url';
|
|
7
|
+
|
|
8
|
+
const require = createRequire(import.meta.url);
|
|
9
|
+
const packageJsonPath = require.resolve('@iconify-json/mdi/package.json');
|
|
10
|
+
const packageRoot = dirname(packageJsonPath);
|
|
11
|
+
const iconSet = JSON.parse(readFileSync(join(packageRoot, 'icons.json'), 'utf8'));
|
|
12
|
+
const availableIcons = new Set([
|
|
13
|
+
...Object.keys(iconSet.icons ?? {}),
|
|
14
|
+
...Object.keys(iconSet.aliases ?? {}),
|
|
15
|
+
]);
|
|
16
|
+
|
|
17
|
+
const repoRoot = resolve(dirname(fileURLToPath(import.meta.url)), '..');
|
|
18
|
+
const sourceRoot = resolve(repoRoot, 'src');
|
|
19
|
+
const extensions = new Set(['.astro', '.js', '.mjs', '.ts', '.tsx']);
|
|
20
|
+
const iconPattern = /\bmdi:([a-z0-9-]+)\b/g;
|
|
21
|
+
const failures = [];
|
|
22
|
+
let references = 0;
|
|
23
|
+
|
|
24
|
+
function walk(directory) {
|
|
25
|
+
const entries = readdirSync(directory, { withFileTypes: true });
|
|
26
|
+
for (const entry of entries) {
|
|
27
|
+
const path = join(directory, entry.name);
|
|
28
|
+
if (entry.isDirectory()) {
|
|
29
|
+
if (entry.name !== 'node_modules' && entry.name !== 'dist' && entry.name !== 'tests') {
|
|
30
|
+
walk(path);
|
|
31
|
+
}
|
|
32
|
+
continue;
|
|
33
|
+
}
|
|
34
|
+
if (!extensions.has(path.slice(path.lastIndexOf('.')))) continue;
|
|
35
|
+
|
|
36
|
+
const source = readFileSync(path, 'utf8');
|
|
37
|
+
for (const match of source.matchAll(iconPattern)) {
|
|
38
|
+
references += 1;
|
|
39
|
+
const iconName = match[1];
|
|
40
|
+
if (availableIcons.has(iconName)) continue;
|
|
41
|
+
|
|
42
|
+
const line = source.slice(0, match.index).split('\n').length;
|
|
43
|
+
failures.push(`${relative(repoRoot, path)}:${line} — mdi:${iconName}`);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
walk(sourceRoot);
|
|
49
|
+
|
|
50
|
+
if (failures.length > 0) {
|
|
51
|
+
console.error('Invalid MDI icons found:');
|
|
52
|
+
for (const failure of failures) console.error(`- ${failure}`);
|
|
53
|
+
console.error(`Checked ${references} MDI icon references against @iconify-json/mdi.`);
|
|
54
|
+
process.exitCode = 1;
|
|
55
|
+
} else {
|
|
56
|
+
console.log(`MDI icon validation passed: ${references} references checked.`);
|
|
57
|
+
}
|
|
@@ -45,6 +45,7 @@ const ui = getCategoryUi(locale);
|
|
|
45
45
|
</ProductionPage>
|
|
46
46
|
|
|
47
47
|
<script>
|
|
48
|
+
import { observeWidgetHeight } from "../mfe/widget-height";
|
|
48
49
|
const isWidget = new URLSearchParams(window.location.search).get("widget") === "true";
|
|
49
50
|
const page = document.querySelector<HTMLElement>(".utility-production");
|
|
50
51
|
const container = document.querySelector<HTMLElement>(".utility-tool-production");
|
|
@@ -60,11 +61,10 @@ const ui = getCategoryUi(locale);
|
|
|
60
61
|
document.querySelector('[data-zoom="reset"]')?.addEventListener("click", () => { zoom = 1; applyZoom(); localStorage.removeItem("gamebob-utility-zoom"); });
|
|
61
62
|
if (isWidget) {
|
|
62
63
|
document.body.classList.add("utility-widget-body");
|
|
63
|
-
|
|
64
|
-
page.classList.add("utility-widget-mode");
|
|
65
|
-
}
|
|
64
|
+
page?.classList.add("utility-widget-mode");
|
|
66
65
|
}
|
|
67
66
|
applyZoom();
|
|
67
|
+
if (isWidget && container) observeWidgetHeight(container);
|
|
68
68
|
</script>
|
|
69
69
|
|
|
70
70
|
<style>
|
|
@@ -88,7 +88,7 @@ const ui = getCategoryUi(locale);
|
|
|
88
88
|
margin-top: 0;
|
|
89
89
|
}
|
|
90
90
|
|
|
91
|
-
.utility-production.utility-widget-mode .utility-production-inner > :not(.utility-tool-production) {
|
|
91
|
+
:global(.utility-production.utility-widget-mode .utility-production-inner > :not(.utility-tool-production)) {
|
|
92
92
|
display: none;
|
|
93
93
|
}
|
|
94
94
|
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export function observeWidgetHeight(container: HTMLElement): void {
|
|
2
|
+
if (window.parent === window) return;
|
|
3
|
+
|
|
4
|
+
const pathSlug = window.location.pathname.split("/").filter(Boolean).pop() ?? "utility";
|
|
5
|
+
const widgetId = new URLSearchParams(window.location.search).get("id") ?? `jj-widget-${pathSlug}`;
|
|
6
|
+
const reportHeight = (height: number) => {
|
|
7
|
+
if (height > 50) {
|
|
8
|
+
window.parent.postMessage({ jjlmoyaHeight: Math.ceil(height), jjlmoyaId: widgetId }, "*");
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
const observer = new ResizeObserver(([entry]) => reportHeight(entry?.contentRect.height ?? 0));
|
|
12
|
+
|
|
13
|
+
observer.observe(container);
|
|
14
|
+
}
|