1
0
mirror of https://github.com/jaandrle/deka-dom-el synced 2025-07-01 12:22:15 +02:00

Replace “observable” term with “signal” (#19)

*  refact docs

to make editing (now renaming observables to signal) easier

*   use signal(s) term isntead of observable(s)

*  🔤 version + typo

* 🐛 customElement example (0→S)

* 📺 version in package-lock.json
This commit is contained in:
2024-05-22 21:43:49 +02:00
committed by GitHub
parent 4014e79740
commit cd62782c7b
65 changed files with 1426 additions and 978 deletions

View File

@ -1,14 +1,14 @@
#!/usr/bin/env -S npx nodejsscript
import { bundle as bundleDTS } from "dts-bundler";
const files= [ "index", "index-with-observables" ];
const files= [ "index", "index-with-signals" ];
const filesOut= (file, mark= "esm")=> "dist/"+file.replace("index", mark);
const css= echo.css`
.info{ color: gray; }
`;
$.api("", true)
.option("--minify", "Level of minification [ full (default), partial ]")
.action(async function main({ minify= "full" }){
.option("--minify", "Level of minification [ full, partial (default) ]")
.action(async function main({ minify= "partial" }){
for(const file_root of files){
const file= file_root+".js";
echo("Processing: "+ file);

View File

@ -2,20 +2,21 @@
/* jshint esversion: 11,-W097, -W040, module: true, node: true, expr: true, undef: true *//* global echo, $, pipe, s, fetch, cyclicLoop */
echo("Building static documentation files…");
echo("Preparing…");
import { path_target, pages, styles, dispatchEvent } from "../docs_src/ssr.js";
import { path_target, pages as pages_registered, styles, dispatchEvent } from "../docs_src/ssr.js";
import { createHTMl } from "./docs/jsdom.js";
import { register } from "../jsdom.js";
const pkg= s.cat("package.json").xargs(JSON.parse);
for(const info of pages){
const { id }= info;
echo("Collecting list of pages…");
const pages= s.ls($.xdg.main`../docs_src/*.html.js`).map(addPage);
for(const { id, info } of pages){
echo(`Generating ${id}.html…`);
const serverDOM= createHTMl("");
serverDOM.registerGlobally(
"HTMLScriptElement"
);
const { el }= await register(serverDOM.dom);
const { page }= await import(`../docs_src/${id}.html.js`); //→ TODO: important to mention in docs!!!
const { page }= await import(`../docs_src/${id}.html.js`);
serverDOM.document.body.append(
el(page, { pkg, info }),
);
@ -27,3 +28,17 @@ for(const info of pages){
s.echo(styles.content).to(path_target.css+styles.name);
dispatchEvent("onssrend");
echo("Done");
/** @param {`${string}/${string}.html.js`} path */
function addPage(path){
const id= idFromPath(path);
const [ info_pre ]= s.cat(path).match(/(?<=\s*export\s+const\s+info\s*=\s*)\{(.|\s)*?\}(?=;)/gm);
const info= { id, href: id, ...eval(`(${info_pre})`) };
pages_registered.push(info);
return { id, info };
}
/** @param {`${string}/${string}.html.js`} path */
function idFromPath(path){
const file_start= path.lastIndexOf("/");
return path.slice(file_start+1, path.indexOf(".", file_start));
}