anentrypoint-design 0.0.354 → 0.0.355
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": "anentrypoint-design",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.355",
|
|
4
4
|
"description": "247420 design system SDK — webjsx + modified ripple-ui, single-file ESM bundle for reproducible use of the AnEntrypoint design.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/247420.js",
|
|
@@ -30,6 +30,11 @@
|
|
|
30
30
|
"default": "./src/lint.js"
|
|
31
31
|
},
|
|
32
32
|
"./package.json": "./package.json",
|
|
33
|
+
"./kits/flatspace-theme": {
|
|
34
|
+
"import": "./src/kits/flatspace-theme/index.js",
|
|
35
|
+
"default": "./src/kits/flatspace-theme/index.js"
|
|
36
|
+
},
|
|
37
|
+
"./kits/flatspace-theme/html-utils.js": "./src/kits/flatspace-theme/html-utils.js",
|
|
33
38
|
"./kits/os": {
|
|
34
39
|
"import": "./src/kits/os/index.js",
|
|
35
40
|
"default": "./src/kits/os/index.js"
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
// Shared HTML/JSON escaping + raw-HTML article extraction utilities for
|
|
2
|
+
// flatspace `theme.mjs` renderers (rs-codeinsight, rs-plugkit, gm, and any
|
|
3
|
+
// future flatspace site consuming the AnEntrypoint design system).
|
|
4
|
+
//
|
|
5
|
+
// escapeHtml/escapeJson are used by every known theme.mjs verbatim (byte-
|
|
6
|
+
// identical across rs-codeinsight and rs-plugkit prior to this extraction).
|
|
7
|
+
// extractArticle/rewriteLegacyLinks are OPT-IN: only sites with
|
|
8
|
+
// layout:'article' pages sourced from raw pre-existing HTML docs (gm's
|
|
9
|
+
// docs/*.html papers) need them. A single-page or YAML-only site never calls
|
|
10
|
+
// them, so importing this module carries no cost for sites that don't.
|
|
11
|
+
|
|
12
|
+
export const escapeHtml = (s) => String(s ?? '')
|
|
13
|
+
.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>')
|
|
14
|
+
.replace(/"/g, '"').replace(/'/g, ''');
|
|
15
|
+
|
|
16
|
+
export const escapeJson = (obj) => JSON.stringify(obj)
|
|
17
|
+
.replace(/</g, '\\u003c').replace(/>/g, '\\u003e').replace(/&/g, '\\u0026')
|
|
18
|
+
.replace(new RegExp('\\u2028', 'g'), '\\u2028').replace(new RegExp('\\u2029', 'g'), '\\u2029');
|
|
19
|
+
|
|
20
|
+
// Strips <header>/<footer> chrome and the <html>/<head>/<body> wrapper from a
|
|
21
|
+
// raw standalone HTML document, returning just the body's inner content for
|
|
22
|
+
// re-hosting inside a flatspace-rendered article shell. Opt-in: only called
|
|
23
|
+
// by sites with layout:'article' pages whose `source` field points at a raw
|
|
24
|
+
// pre-existing .html file (gm's docs/paper.html etc).
|
|
25
|
+
export function extractArticle(html) {
|
|
26
|
+
const bodyOpen = html.search(/<body[^>]*>/i);
|
|
27
|
+
if (bodyOpen < 0) return html;
|
|
28
|
+
const bodyStart = html.indexOf('>', bodyOpen) + 1;
|
|
29
|
+
const bodyEnd = html.lastIndexOf('</body>');
|
|
30
|
+
let body = html.slice(bodyStart, bodyEnd >= 0 ? bodyEnd : html.length);
|
|
31
|
+
body = body.replace(/<header[^>]*>[\s\S]*?<\/header>/gi, '');
|
|
32
|
+
body = body.replace(/<footer\b[^>]*>[\s\S]*?<\/footer>/gi, '');
|
|
33
|
+
return body.trim();
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// Rewrites legacy same-site relative .html links (paper.html, distribution.html,
|
|
37
|
+
// etc) found inside extracted article HTML into flatspace's route paths
|
|
38
|
+
// (/paper/, /distribution/, ...), given the caller's own slug->path map.
|
|
39
|
+
// Opt-in, same scope as extractArticle: only needed when article HTML
|
|
40
|
+
// predates the flatspace multi-page routing and still uses .html-relative
|
|
41
|
+
// hrefs. `slugToPath` defaults to gm's known page set but callers with a
|
|
42
|
+
// different page inventory pass their own map.
|
|
43
|
+
const DEFAULT_SLUGS = ['index', 'paper', 'distribution', 'made-with', 'stats', 'crates', 'skills'];
|
|
44
|
+
const DEFAULT_SLUG_TO_PATH = {
|
|
45
|
+
index: '/', paper: '/paper/', distribution: '/distribution/',
|
|
46
|
+
'made-with': '/made-with/', stats: '/stats/', crates: '/crates/', skills: '/skills/',
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
export function rewriteLegacyLinks(html, basePath, opts = {}) {
|
|
50
|
+
const slugs = opts.slugs || DEFAULT_SLUGS;
|
|
51
|
+
const slugToPath = opts.slugToPath || DEFAULT_SLUG_TO_PATH;
|
|
52
|
+
return html.replace(/href="([^"]+)"/g, (full, hrefRaw) => {
|
|
53
|
+
const href = hrefRaw.trim();
|
|
54
|
+
if (/^(https?:)?\/\//i.test(href) || href.startsWith('#') || href.startsWith('mailto:') || href.startsWith('/')) return full;
|
|
55
|
+
let path = href, hash = '';
|
|
56
|
+
const hi = path.indexOf('#');
|
|
57
|
+
if (hi >= 0) { hash = path.slice(hi); path = path.slice(0, hi); }
|
|
58
|
+
path = path.replace(/^\.\//, '').replace(/\.html$/, '').replace(/\/$/, '');
|
|
59
|
+
if (slugs.includes(path)) return `href="${basePath}${slugToPath[path]}${hash}"`;
|
|
60
|
+
return full;
|
|
61
|
+
});
|
|
62
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// Public entry point for the flatspace-theme kit. Re-exports the shared
|
|
2
|
+
// escaping + opt-in article-extraction utilities every known flatspace
|
|
3
|
+
// theme.mjs (rs-codeinsight, rs-plugkit, gm) needs. Each site's own
|
|
4
|
+
// page-composition logic (component layout, data contract) stays local to
|
|
5
|
+
// its own site/theme.mjs -- that part legitimately differs per site (single-
|
|
6
|
+
// page Hero/Features/Quickstart vs gm's multi-page article/landing split)
|
|
7
|
+
// and is not force-unified here.
|
|
8
|
+
export { escapeHtml, escapeJson, extractArticle, rewriteLegacyLinks } from './html-utils.js';
|
|
9
|
+
|
|
10
|
+
// Canonical unpkg URLs every theme.mjs's importmap/<link> points at, kept in
|
|
11
|
+
// one place so a future SDK CDN path change is a single-file edit instead of
|
|
12
|
+
// a 3-repo grep-and-replace.
|
|
13
|
+
export const SDK_CSS_URL = 'https://unpkg.com/anentrypoint-design@latest/dist/247420.css';
|
|
14
|
+
export const SDK_JS_URL = 'https://unpkg.com/anentrypoint-design@latest/dist/247420.js';
|