Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
63d29cc
Add 2 new profiles for the new CG spec lifecycle program:
deniak Sep 28, 2026
4e000a1
add the different regions used by cg-metadata.js to display the metad…
deniak Sep 29, 2026
830f6c5
adding tests
deniak Sep 29, 2026
b498fbe
do not add any generated paragraphs to the SotD
deniak Sep 29, 2026
f8efc5f
transferred CGs require the name/link of the new organization
deniak Sep 29, 2026
9c1bde9
generate snapshot thisVersion URL + fix trailing slash in the snapsho…
deniak Sep 29, 2026
369adb5
add/fix tests
deniak Sep 29, 2026
08aa006
missing whitespace between the title and the maturity tag
deniak Sep 30, 2026
aa0fd30
fix race condition with dark.js
deniak Oct 5, 2026
8a4dce8
create fallback with DOM calls instead of string interpolation as '<n…
deniak Oct 6, 2026
ce72847
rename parameter for clarity
deniak Oct 7, 2026
927b40e
chevron SVG: make it inline + add a aria-hidden attribute
deniak Oct 7, 2026
3c11468
fix join link
deniak Oct 7, 2026
7a899e0
Add new profiles to the supported types for CG
deniak Oct 7, 2026
b6806b2
fix group shortname parsing
deniak Oct 7, 2026
1e9db73
fix test
deniak Oct 7, 2026
317c745
incubation host TBD
deniak Oct 20, 2026
45fa2f6
prefix group name with 'W3C'
deniak Oct 21, 2026
4efe6d1
add id to the status box so it can be re-used in transferred specs
deniak Oct 23, 2026
b2dc889
export incubation host for tests
deniak Oct 23, 2026
3c3b92f
rename region function + use hyperHTML
deniak Oct 26, 2026
67b919e
use URL()
deniak Oct 26, 2026
8c64bf0
pass the defer param instead of depending on the script being loaded
deniak Oct 26, 2026
3e24e94
inline disclaimer
deniak Oct 26, 2026
fc42f44
use separate functions for the different notices
deniak Oct 26, 2026
50c9c1e
CG assets repo was renamed to cg-spec-assets
deniak Nov 20, 2026
c751bda
* CG assets repository renamed to cg-spec-assets
deniak Nov 20, 2026
3f96c4f
use group shortname only
deniak Nov 20, 2026
30c9a50
use final assets location
deniak Nov 20, 2026
b91141d
inline guidance
deniak Dec 2, 2026
e334ac5
prepend spread resource hints instead of relying on a document fragment
deniak Dec 2, 2026
1e89490
update incubation host and remove the export
deniak Dec 2, 2026
05fc0b7
update snapshots list URL and return null if it cannot be derived
deniak Dec 2, 2026
9ed28ab
apply Marcos' suggestion in createRegion
deniak Dec 2, 2026
cdd4922
generate the join link from the group's homepage in https://respec.or…
deniak Dec 2, 2026
48c9bc0
update the description of getInvolved
deniak Dec 2, 2026
2fb924d
rework comment
deniak Dec 2, 2026
bfff152
rename src/w3c/cg-spec.js to src/w3c/cg-identity.js
deniak Dec 2, 2026
de8086d
delete cg-headers-spec and move the only valuable test to cg-headers.…
deniak Dec 2, 2026
b6d55ea
rename the validateCGMaturity function to validateAndNormalizeCGMaturity
deniak Dec 2, 2026
033025a
Add rendering for former editors in cg-headers.js
deniak Dec 2, 2026
e988c38
honor 'conf.darMode=false'
deniak Dec 2, 2026
8445d87
CG-SNAPSHOT also requires a canonical link
deniak Dec 2, 2026
900be9e
before exporting, reset regions updated by cg-metadata.js
deniak Dec 2, 2026
5737206
Update status information sentence
deniak Dec 2, 2026
fe41c6d
Apply suggestion from @sidvishnoi
deniak Dec 3, 2026
944c769
use hyperHTML to create the fallback element
deniak Dec 3, 2026
b255f6c
apply Sid's suggestion
deniak Dec 3, 2026
ccf666e
use constants for the noscript elements
deniak Dec 3, 2026
59197cc
create a peopleList function to avoid code duplication
deniak Dec 3, 2026
c085bae
export at declaration
deniak Dec 3, 2026
aad01e2
move isCGSpec to src/w3c/headers.js
deniak Dec 3, 2026
b2e6b6f
cleanup createScript
deniak Dec 3, 2026
a6fd21c
rewrite isCGSpec
deniak Dec 3, 2026
ddc7c62
use isCGSpec
deniak Dec 3, 2026
bceb3b0
introduce the function templatesFor to return the right headers/sotd
deniak Dec 3, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions examples/cg-living.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<!doctype html>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure we should add this example at all to be honest.

<html lang="en">
<head>
<meta charset="utf-8" />
<title>Prioritized Task Scheduling</title>
<script src="../profiles/w3c.js" type="module" class="remove"></script>
<script class="remove">
// All config options at https://respec.org/docs/
var respecConfig = {
// A living specification in the Community Group redesign. Use
// "CG-SNAPSHOT" for an archival copy of one.
specStatus: "CG-LIVING",
// "draft" (default), "transferred" or "unmaintained".
cgMaturity: "draft",
// Required: the collected status metadata is looked up by short name.
shortName: "scheduling-apis",
group: "wicg",
github: "WICG/scheduling-apis",
// Required if cgMaturity: "transferred"
// transferredTo: { name: "ACME", url: "https://acme.org/" },
editors: [
{
name: "Your Name",
url: "https://your-site.com",
},
],
};
</script>
</head>
<body>
<section id="abstract">
<p>
This specification defines APIs for scheduling and controlling
prioritized tasks.
</p>
</section>
<section id="sotd"></section>
<section class="informative">
<h2>Introduction</h2>
<p>Some informative introductory text.</p>
</section>
<section>
<h2>Start your spec!</h2>
<p>Replace this with the specification's normative content.</p>
</section>
<section id="conformance">
<p>
This is required for specifications that contain normative material.
</p>
</section>
</body>
</html>
2 changes: 2 additions & 0 deletions profiles/w3c.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const modules = [
import("../src/core/reindent.js"),
import("../src/core/title.js"),
import("../src/w3c/level.js"),
import("../src/w3c/cg-identity.js"),
import("../src/w3c/headers.js"),
import("../src/w3c/abstract.js"),
import("../src/core/data-transform.js"),
Expand Down Expand Up @@ -42,6 +43,7 @@ const modules = [
import("../src/core/fix-headers.js"),
import("../src/core/webidl-index.js"),
import("../src/core/cddl-index.js"),
import("../src/w3c/cg-sections.js"),
import("../src/core/structure.js"),
import("../src/core/informative.js"),
import("../src/core/id-headers.js"),
Expand Down
14 changes: 14 additions & 0 deletions src/type-helper.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,17 @@ interface Conf {
* not dark-aware yet.
*/
darkMode?: boolean;
/**
* Maturity stage of a Community Group specification using the redesign, i.e.
* one with a `specStatus` of `"CG-LIVING"` or `"CG-SNAPSHOT"`. Defaults to
* `"draft"`, and has no effect on any other kind of document.
*/
cgMaturity?: "draft" | "transferred" | "unmaintained";
/**
* The organization that has taken up the work, named in the notice of a CG
* redesign specification whose `cgMaturity` is `"transferred"`.
*/
transferredTo?: string | { name: string; url?: string };

/** Indicates whether the document is a preview */
isPreview?: boolean;
Expand Down Expand Up @@ -278,6 +289,8 @@ interface Conf {
wgPatentHTML?: string | unknown[];
/** Type of W3C group */
groupType?: string | string[];
/** The group's own homepage(s) */
groupHomeURI?: string | string[];
/** Base URL for linking to issues */
issueBase?: string;
/** URL to the issue tracker */
Expand Down Expand Up @@ -411,6 +424,7 @@ type GroupDetails = {
wgPatentURI: string;
wgPatentPolicy: string;
groupType: string;
groupHomeURI: string;
};

type LicenseInfo = {
Expand Down
174 changes: 174 additions & 0 deletions src/w3c/cg-assets.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,174 @@
// @ts-check
/**
* Module w3c/cg-assets
*
* The style sheets and scripts of the Community Group specification redesign,
* which live in w3c/cg-spec-assets rather than in /StyleSheets/TR/2021/. Only
* the `cgRedesignStatus` documents use them; `CG-DRAFT` and `CG-FINAL` keep
* the older W3C-hosted CG styles.
*
* The markup this emits is the contract documented in cg-spec-assets' README,
* under "How a specification uses these".
*/

import { createResourceHint } from "../core/utils.js";
import { disableDarkStyles } from "../core/insert-style.js";
import { html } from "../core/import-maps.js";
import { sub } from "../core/pubsubhub.js";

export const name = "w3c/cg-assets";

export const CG_ASSETS_BASE = "https://incubation.w3.org/assets/specs-2026/";

/** @param {string} path */
export function cgAssetUrl(path) {
return new URL(path, CG_ASSETS_BASE).href;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: sometimes we are returning .href and other times, a URL object... make sure it's consistent and with intent.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as I can see, the return type is consistent across the different functions for the CG-related code at least.

}

/**
* base.css, cg-spec.css and dark.css all set the same `:root` custom properties
* at equal specificity, so a document that loads them out of order gets the
* wrong colours. Keep them adjacent and in this order, live and on save.
*/
const STYLES = ["css/base.css", "css/cg-spec.css", "css/dark.css"];

/** Dark mode assets */
const DARK_STYLE = "css/dark.css";
const DARK_SCRIPT = "js/dark.js";

/** @type {{ path: string; defer?: boolean }[]} */
const SCRIPTS = [
{ path: "js/cg-fixup.js" },
{ path: "js/dark.js" },
{ path: "js/cg-metadata.js", defer: true },
];

/**
* Drops the w3.org styles and hints that this module's sibling w3c/style adds
* at import time, before any configuration is readable.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question: why are these dropped?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh, I see now... I wonder if we should prevent the original ones from being added in the first place in this mode.

*/
function removeTRAssets() {
const selectors = [
'head link[rel~="preconnect"][href^="https://www.w3.org"]',
'head link[rel~="preload"][href^="https://www.w3.org/StyleSheets/TR/"]',
'head link[rel~="preload"][href^="https://www.w3.org/scripts/TR/"]',
'head link[rel~="stylesheet"][href^="https://www.w3.org/StyleSheets/TR/"]',
];
for (const link of document.querySelectorAll(selectors.join(", "))) {
link.remove();
}
}

/** @param {string[]} styles */
function createResourceHints(styles) {
/** @type {ResourceHintOption[]} */
const opts = [{ hint: "preconnect", href: CG_ASSETS_BASE }];
for (const path of styles) {
opts.push({ hint: "preload", href: cgAssetUrl(path), as: "style" });
}
return opts.map(createResourceHint);
}

/**
* The dark sheet carries `media` so that a reader without JavaScript still gets
* a palette matching their system, and `class="dark-mode"` so that
* cg-spec-assets' dark.js can find the sheet it drives from the theme picker.
*
* @param {string} path
*/
function createStyleLink(path) {
const href = cgAssetUrl(path);
return path.endsWith("dark.css")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems fragile... how about a making this an option for createStyleLink()? Also, this seems duplicative. Don't we have a similar function in utils?

? html`<link
rel="stylesheet"
class="dark-mode"
media="(prefers-color-scheme: dark)"
href="${href}"
/>`
: html`<link rel="stylesheet" href="${href}" />`;
}

/**
* @param {string} path
* @param {object} [options]
* @param {boolean} [options.defer]
*/
function createScript(path, { defer = false } = {}) {
return html`<script
src="${cgAssetUrl(path)}"
defer=${defer}
async=${false}
></script>`;
}

/**
* Puts the exported document back the way the generator wrote it.
*
* The three scripts run in ReSpec's own browser, so whatever they did to suit
* that one reader -- which theme was showing, whether the status metadata
* loaded -- would otherwise be published as everyone's starting state. This is
* the same job w3c/style's `styleMover` and `restoreDarkLinkState` do for the
* W3C TR assets.
*
* Note this receives the cloned `<html>` element, not a document; see
* core/exporter.
*
* @param {Element} exportRoot
*/
function restoreExportedState(exportRoot) {
const head = exportRoot.querySelector("head");
// Order matters as much on disk as it does live: all three sheets set the
// same `:root` custom properties at equal specificity.
for (const path of STYLES) {
const link = exportRoot.querySelector(
`head link[rel~="stylesheet"][href="${cgAssetUrl(path)}"]`
);
if (!link) continue;
head?.append(link);
// dark.js swaps the media list for "all" / "not all" to follow the reader's
// theme. Published like that, a reader without scripting gets either an
// unconditional dark page or no dark palette at all.
if (path.endsWith("dark.css")) {
link.setAttribute("media", "(prefers-color-scheme: dark)");
}
}

// dark.js also marks the body while dark is showing. core/exporter already
// drops cg-fixup.js's `toc-sidebar` / `toc-inline` for the same reason.
exportRoot.querySelector("body")?.classList.remove("darkmode");
}

/**
* Inserts the CG style sheets and scripts, replacing the W3C TR ones.
*
* `darkMode: false` drops the dark.css and dark.js.
*
* @param {Conf} conf
*/
export function insertCGAssets(conf) {
const darkMode = conf.darkMode !== false;
const styles = darkMode ? STYLES : STYLES.filter(p => p !== DARK_STYLE);
const scripts = darkMode
? SCRIPTS
: SCRIPTS.filter(({ path }) => path !== DARK_SCRIPT);

removeTRAssets();
if (!darkMode) disableDarkStyles();
document.head.prepend(...createResourceHints(styles));
for (const path of styles) {
document.head.appendChild(createStyleLink(path));
}
sub("beforesave", restoreExportedState);

// At the end, like w3c/style does for fixup.js: these scripts read the
// finished document.
sub(
"end-all",
() => {
for (const { path, defer } of scripts) {
document.body.appendChild(createScript(path, { defer }));
}
},
{ once: true }
);
}
56 changes: 56 additions & 0 deletions src/w3c/cg-identity.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
// @ts-check

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please rename this file? We use -spec.js for test specs, so it's confusing when reviewing.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

renamed into cg-identity.js (bfff152)

/**
* Module w3c/cg-identity
*
* Declares what a Community Group specification is, for cg-spec-assets'
* cg-metadata.js: which kind of document it is, which entry of the collected
* status metadata belongs to it, and how mature it is.
*
* This runs after core/github and w3c/level, both of which can still change
* `shortName`, and that name is the metadata lookup key.
*/

import { docLink, showError } from "../core/utils.js";
import { html } from "../core/import-maps.js";
import { isCGSpec } from "./headers.js";
import { sub } from "../core/pubsubhub.js";

export const name = "w3c/cg-identity";

/** @param {Conf} conf */
export function run(conf) {
if (!isCGSpec(conf)) return;

if (!conf.shortName) {
const specStatus = conf.specStatus ?? "";
const msg = docLink`The ${"[shortName]"} configuration option is required for a \`"${specStatus}"\` document.`;
const hint = docLink`The status metadata of a Community Group specification is looked up by short name. Please set ${"[shortName]"} to the specification's short name.`;
showError(msg, name, { hint });
// Without it there is nothing to look the metadata up by, so say nothing
// rather than publish an identity that cannot resolve.
return;
}

const type = conf.specStatus === "CG-SNAPSHOT" ? "snapshot" : "living";
document.head.append(
html`<meta name="cg-spec-type" content="${type}" />`,
html`<meta name="cg-spec-shortname" content="${conf.shortName}" />`,
html`<meta name="cg-spec-maturity" content="${conf.cgMaturity}" />`

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Questions: has conf.cgMaturity been validated and normalized when this gets set?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Questions: has conf.cgMaturity been validated and normalized when this gets set?

Yes, w3c/defaults runs the function validateAndNormalizeCGMaturity.

);

// State of the metadata for this document. cg-metadata.js overwrites it
// with "fresh", "stale" or "unknown-type".
document.documentElement.dataset.cgMetadata = "static";
sub(
"beforesave",
/** @param {HTMLElement} exportRoot */ exportRoot => {
exportRoot.dataset.cgMetadata = "static";
// reset regions populated by cg-metadata.js
for (const region of exportRoot.querySelectorAll("[data-cg-region]")) {
for (const node of [...region.childNodes]) {
if (node.nodeName !== "NOSCRIPT") node.remove();
}
}
}
);
}
Loading
Loading