@stnd/modules 0.5.1 → 0.5.2

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 CHANGED
@@ -2,21 +2,24 @@
2
2
  title: "@stnd/modules"
3
3
  aliases: []
4
4
  created: 2026-07-04 23:28
5
- modified: 2026-07-05 19:23
5
+ modified: 2026-09-16T17:28:28.771Z
6
6
  last_audited: 2026-07-14
7
7
  audit_interval_days: 90
8
8
  next_audit: 2026-10-12
9
9
  audit_priority: 3
10
10
  maturity: tree
11
11
  mode: read
12
- publish: false
12
+ publish: true
13
13
  status: active
14
14
  tags:
15
15
  - package
16
16
  - stnd
17
17
  theme: kernel
18
18
  type: package
19
- visibility: private
19
+ visibility: public
20
+ garden-url: https://standard.garden/@francis/readme
21
+ garden-short: https://stnd.gd/wAgx4e
22
+ permalink: readme
20
23
  ---
21
24
 
22
25
  # @[stnd](../README)/modules
@@ -58,11 +61,20 @@ environment?: string | string[]
58
61
 
59
62
  // Unified Hooks (Logic & Interface)
60
63
  // ---------------------------------------------------------------------------
61
- // Standard automatically routes hooks based on their file extension:
62
- // - .js, .ts -> LOGIC (Listeners / Handlers)
63
- // - .astro, .svelte, .md -> UI (Components / Plugs)
64
+ // A hook name resolves to one of two kinds — never both, for the same name:
65
+ // - LOGIC (virtual:stnd/hooks, runHook/runPipeline): the name starts with
66
+ // "astro:" (Astro's own lifecycle), OR the entry is a .js/.ts path and the
67
+ // name doesn't start with "launcher:" or end in ":action".
68
+ // - UI/action zone (virtual:stnd/components, <Hook zone="..."> + direct
69
+ // extensions[zone] reads): everything else — .astro/.svelte/.md paths,
70
+ // and any "launcher:"/":action" name regardless of file type.
64
71
  //
65
- // These can be a single string or an array of entries.
72
+ // Two modules registering the same hook name as different kinds is a
73
+ // build-time fatal error (hook-kind-mismatch), not a silent split.
74
+ //
75
+ // These can be a single string (shorthand for `{ ui: "path" }`) or an array
76
+ // of entries (`{ ui: "..." }` / `{ action: "..." }`, or `component` for
77
+ // backward-compat with `ui`).
66
78
  hooks?: {
67
79
  [hookName: string]: string | Array<string | HookEntry>
68
80
  }
@@ -110,34 +122,24 @@ dependencies?: string[]
110
122
 
111
123
  ## Unified Hooks Architecture
112
124
 
113
- The `hooks` object is the brain of your module. It handles both system events and UI injection.
114
-
115
- ### 1. Integration Hooks (Logic)
116
-
117
- If the hook name starts with `astro:` or the entry ends in `.js`/`.ts`, it’s treated as logic.
125
+ The `hooks` object is the brain of your module. It handles both system events and UI injection — see [Hooks & Extension Points](https://stnd.build/manual/modules/hooks) in the manual for the full walkthrough and the native hooks the framework ships with. Quick reference:
118
126
 
119
127
  ```javascript
120
128
  // index.module.js
121
129
  export default {
122
130
  id: "my-feature",
123
131
  hooks: {
124
- "astro:config:setup": "./hooks/setup.js", // Astro native hook
125
- "app:init": "./hooks/init.ts", // Custom app hook
126
- },
127
- };
128
- ```
129
-
130
- ### 2. Interface Hooks (UI Plugs)
132
+ // UI into zones (use `ui` key, or a bare string as shorthand for it)
133
+ "stnd:base": ["./components/Banner.astro"],
134
+ "stnd:client": [{ ui: "./Drawer.svelte", meta: { "client:load": true } }],
131
135
 
132
- If the entry ends in `.astro`, `.svelte`, `.md`, or any other format, it’s treated as a UI component.
136
+ // Lifecycle hooks and JS action handlers (use `action`)
137
+ "astro:build:done": [{ action: "./hooks/generate-feed.js" }],
138
+ "launcher:action": [{ action: "./actions/nav.js" }],
133
139
 
134
- ```javascript
135
- // index.module.js
136
- export default {
137
- id: "my-feature",
138
- hooks: {
139
- "header:top": ["./components/Banner.astro"],
140
- "footer:bottom": "./components/Copyright.astro",
140
+ // Launcher views — a `launcher:`-prefixed name is always UI/action,
141
+ // even though its entry is registered under `ui`
142
+ "launcher:view": [{ ui: "./views/ShareView.svelte", trigger: "::share", meta: { title: "Share" } }],
141
143
  },
142
144
  };
143
145
  ```
@@ -146,26 +148,25 @@ export default {
146
148
 
147
149
  **UI Rendering (Zones):**
148
150
 
149
- In your Layout or components, use the `<Hook />` component to render all registered components for a hook ID.
151
+ In your Layout or components, use the `<Hook />` component to render every registered entry for a zone name — the prop is `zone`, not `id`.
150
152
 
151
153
  ```astro
152
154
  ---
153
155
  import Hook from "@stnd/core/Hook";
154
156
  ---
155
157
 
156
- <header>
157
- <Hook id="header:top" props={{ theme: "dark" }} />
158
- </header>
158
+ <Hook zone="stnd:base" />
159
+ <Hook zone="stnd:client" hydrated props={{ theme: "dark" }} />
159
160
  ```
160
161
 
161
162
  **Logic Execution:**
162
163
 
163
- Trigger logic hooks via the virtual module.
164
+ Trigger logic hooks via the virtual module — `runHook` fans out and collects every module's result; `runPipeline` threads one value through each handler in sequence.
164
165
 
165
166
  ```javascript
166
167
  import { runHook } from "virtual:stnd/hooks";
167
168
 
168
- await runHook("app:init", { some: "data" });
169
+ const results = await runHook("astro:build:done", buildContext);
169
170
  ```
170
171
 
171
172
  ### Middleware
@@ -323,29 +324,53 @@ These built-in modules come with `@stnd/modules` and can be loaded via `moduleLo
323
324
 
324
325
  ### Gold Standard (loaded by default)
325
326
 
326
- Every `@stnd` site ships with these. Opt out via `moduleExclude`.
327
-
328
- | Module | ID | Route | What it does |
329
- | :----------------------- | :-------------- | :------------------ | :----------------------------------------------------------------- |
330
- | `@stnd/modules/styles` | `stnd-styles` | — | Injects the Standard design stylesheet |
331
- | `@stnd/modules/robots` | `stnd-robots` | `/robots.txt` | Generates `robots.txt` from site config |
332
- | `@stnd/modules/headers` | `stnd-headers` | `/_headers` | Emits security headers (HSTS, X-Frame-Options, Permissions-Policy) |
333
- | `@stnd/modules/manifest` | `stnd-manifest` | `/site.webmanifest` | Serves the web app manifest |
334
- | `@stnd/modules/sitemap` | `stnd-sitemap` | — | Sitemap generation via `@astrojs/sitemap` |
327
+ Every `@stnd` site ships with these — the definitive list lives in
328
+ `GOLD_STANDARD_MODULES` in `packages/core/standard.js`. Opt out via
329
+ `moduleExclude`. (Three more gold standard entries — `@stnd/fonts/inter`,
330
+ `@stnd/fonts/source-serif-4`, `@stnd/fonts/ibm-plex` — and `@stnd/icon/module`
331
+ ship from their own packages, not from here.)
332
+
333
+ | Module | ID | Route | What it does |
334
+ | :----------------------------- | :--------------------- | :------------ | :------------------------------------------------------------------ |
335
+ | `@stnd/modules/toast` | `stnd-toast` | — | Zero-dependency global notification system |
336
+ | `@stnd/modules/confetti` | `stnd-confetti` | — | A fun confetti explosion on page load |
337
+ | `@stnd/modules/lab` | `stnd-lab` | — | Loads the StandardLab inspector/debug bundle (dev mode) |
338
+ | `@stnd/modules/launcher` | `stnd::launcher` | — | Universal command palette engine |
339
+ | `@stnd/modules/styles` | `stnd-styles` | — | Injects the Standard design stylesheet |
340
+ | `@stnd/modules/copy-buttons` | `stnd-copy-buttons` | — | Adds copy-to-clipboard buttons to code blocks |
341
+ | `@stnd/modules/image-zoom` | `stnd-image-zoom` | — | Click-to-zoom lightbox behavior for images |
342
+ | `@stnd/modules/scroll-wrappers`| `stnd-scroll-wrappers` | — | Scroll-linked wrapper behaviors for content |
343
+ | `@stnd/modules/mermaid` | `mermaid` | — | Diagram and flowchart rendering with Mermaid.js |
344
+ | `@stnd/modules/math` | `math` | — | Mathematical notation rendering with KaTeX |
345
+ | `@stnd/modules/prism` | `stnd-prism` | — | Syntax highlighting via Prism.js, loaded from CDN |
346
+ | `@stnd/modules/robots` | `stnd-robots` | `/robots.txt` | Generates `robots.txt` from site config |
347
+ | `@stnd/modules/headers` | `stnd-headers` | `/_headers` | Emits security headers (HSTS, X-Frame-Options, Permissions-Policy) |
348
+ | `@stnd/modules/manifest` | `stnd-manifest` | `/site.webmanifest` | Serves the web app manifest |
349
+ | `@stnd/modules/sitemap` | `stnd-sitemap` | — | Sitemap generation via `@astrojs/sitemap` |
335
350
 
336
351
  ### Opt-In Modules
337
352
 
338
353
  Load these explicitly via `moduleLoad` when your site needs them.
339
354
 
340
- | Module | ID | Route | What it does |
341
- | :--------------------------- | :------------------ | :-------------------------- | :----------------------------------------------------- |
342
- | `@stnd/modules/rss` | `stnd-rss` | `/rss.xml` | Generates an RSS 2.0 feed from site content and config |
343
- | `@stnd/modules/security-txt` | `stnd-security-txt` | `/.well-known/security.txt` | RFC 9116 security contact disclosure |
344
- | `@stnd/modules/humans` | `stnd-humans` | `/humans.txt` | The people and tools behind the site |
345
- | `@stnd/modules/themes` | `stnd-themes` | — | Theme/temperament stylesheet injection |
346
- | `@stnd/modules/lab` | `stnd-lab` | — | StandardLab CSS inspector (dev tool) |
347
- | `@stnd/modules/content` | `stnd-content` | `/[…slug]` | Content collection catch-all route |
348
- | `@stnd/modules/maintenance` | `stnd-maintenance` | `/maintenance` | Maintenance mode with redirect middleware |
355
+ | Module | ID | Route | What it does |
356
+ | :--------------------------- | :------------------ | :--------------------------- | :----------------------------------------------------------- |
357
+ | `@stnd/modules/rss` | `stnd-rss` | `/rss.xml` | Generates an RSS 2.0 feed from site content and config |
358
+ | `@stnd/modules/security-txt` | `stnd-security-txt` | `/.well-known/security.txt` | RFC 9116 security contact disclosure |
359
+ | `@stnd/modules/humans` | `stnd-humans` | `/humans.txt` | The people and tools behind the site |
360
+ | `@stnd/modules/themes` | `stnd-themes` | — | Theme/temperament stylesheet injection |
361
+ | `@stnd/modules/content` | `stnd-content` | `/[…slug]` | Content collection catch-all route |
362
+ | `@stnd/modules/maintenance` | `stnd-maintenance` | `/maintenance` | Maintenance mode with redirect middleware |
363
+ | `@stnd/modules/brand-manual` | `stnd-brand-manual` | `/brand` | A brand manual page showing the active theme's design tokens |
364
+ | `@stnd/modules/deep-link` | `stnd-deep-link` | — | Deep-linking client behavior |
365
+ | `@stnd/modules/eink` | `stnd-eink` | — | E-ink display detection and adaptation |
366
+ | `@stnd/modules/fonts` | `stnd-fonts` | — | Loads every shipped font folio at once, instead of cherry-picking one |
367
+ | `@stnd/modules/gestures` | `stnd-gestures` | — | Touch/gesture client behaviors |
368
+ | `@stnd/modules/gsap` | `gsap` | — | GSAP animation library with ScrollTrigger, loaded from CDN on demand |
369
+ | `@stnd/modules/iconify` | `stnd-iconify` | — | Client-side icon resolution via Iconify |
370
+ | `@stnd/modules/keyboard` | `stnd-keyboard` | — | Keyboard-shortcut client behaviors |
371
+ | `@stnd/modules/p5` | `p5` | — | Creative coding with p5.js, preloaded from CDN as `window.p5` |
372
+ | `@stnd/modules/stripe` | `stnd-stripe` | `/api/stripe/mock-checkout` | Commerce integration and mock checkout service |
373
+ | `@stnd/modules/theme-utils` | `stnd-theme-utils` | — | Global theme switcher — apply themes via `data-theme` buttons |
349
374
 
350
375
  ## Usage in an App
351
376
 
@@ -8,8 +8,8 @@
8
8
  */
9
9
 
10
10
  import { getCollection, render } from "astro:content";
11
- import Base from "../../layouts/Base.astro";
12
- import { generatePermalink } from "../../core/permalink";
11
+ import Base from "@stnd/layout/Base.astro";
12
+ import { generatePermalink } from "@stnd/utils";
13
13
 
14
14
  export async function getStaticPaths() {
15
15
  const content = await getCollection("content");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stnd/modules",
3
- "version": "0.5.1",
3
+ "version": "0.5.2",
4
4
  "type": "module",
5
5
  "svelte": "./stripe/views/CheckoutView.svelte",
6
6
  "author": "Francis Fontaine",
@@ -17,8 +17,10 @@
17
17
  },
18
18
  "dependencies": {
19
19
  "@astrojs/sitemap": "^3.7.3",
20
- "wrangler": "^4.105.0",
20
+ "wrangler": "^4.129.0",
21
+ "@stnd/client": "0.5.0",
21
22
  "@stnd/icon": "0.2.0",
23
+ "@stnd/layout": "0.5.1",
22
24
  "@stnd/log": "0.5.0",
23
25
  "@stnd/styles": "0.5.2",
24
26
  "@stnd/utils": "0.5.0"
package/prism/README.md CHANGED
@@ -1,3 +1,18 @@
1
+ ---
2
+ title: "@stnd/modules/prism"
3
+ type: package
4
+ publish: true
5
+ visibility: public
6
+ tags:
7
+ - package
8
+ - stnd
9
+ garden-url: https://standard.garden/@francis/readme
10
+ permalink: readme
11
+ garden-short: https://stnd.gd/wAgx4e
12
+ created: 2026-09-06T00:41:06.667Z
13
+ modified: 2026-09-16T17:28:25.903Z
14
+ ---
15
+
1
16
  # Prism Syntax Highlighting Module
2
17
 
3
18
  This module loads Prism.js and Prism.css from CDN and ensures syntax highlighting is applied to all code blocks on initial load and after every Astro navigation ("astro:after-swap").
@@ -1,3 +1,6 @@
1
+ ---
2
+ publish: false
3
+ ---
1
4
  # Theme Utils Module
2
5
 
3
6
  Global theme switcher for managing themes across the entire site.