astromache 0.1.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/CHANGELOG.md ADDED
@@ -0,0 +1,11 @@
1
+ # Changelog
2
+
3
+ ## 0.1.0 — first release candidate
4
+
5
+ - Semantic Astro document shell with validated publication metadata.
6
+ - Bounded native Astro navigation-prefetch helpers; browser installation is safe to call during SSR.
7
+ - Single-gallery portfolio with native accessible lightbox and consumer-supplied images.
8
+ - Optional unmodified IBM Plex Sans and Mono regular fonts with OFL provenance.
9
+ - Five explicit source subpath exports, MIT OR Apache-2.0 owner-code licensing, and shipped API/toolchain documentation.
10
+
11
+ This candidate is prepared for review and is not yet published. It is the component-machinery package within the intended AstroMache publication-template product; the complete starter is not shipped in this version.
package/LICENSE ADDED
@@ -0,0 +1,3 @@
1
+ Owner-authored AstroMache code is licensed under MIT OR Apache-2.0, at your option.
2
+ See LICENSE-MIT and LICENSE-APACHE for the complete terms.
3
+ Third-party components retain their respective licenses and notices.
package/LICENSE-APACHE ADDED
@@ -0,0 +1,73 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.
10
+
11
+ "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.
12
+
13
+ "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
14
+
15
+ "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License.
16
+
17
+ "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.
18
+
19
+ "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.
20
+
21
+ "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below).
22
+
23
+ "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.
24
+
25
+ "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution."
26
+
27
+ "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.
28
+
29
+ 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
30
+
31
+ 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed.
32
+
33
+ 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
34
+
35
+ (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and
36
+
37
+ (b) You must cause any modified files to carry prominent notices stating that You changed the files; and
38
+
39
+ (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
40
+
41
+ (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License.
42
+
43
+ You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.
44
+
45
+ 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.
46
+
47
+ 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.
48
+
49
+ 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.
50
+
51
+ 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.
52
+
53
+ 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.
54
+
55
+ END OF TERMS AND CONDITIONS
56
+
57
+ APPENDIX: How to apply the Apache License to your work.
58
+
59
+ To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives.
60
+
61
+ Copyright [yyyy] [name of copyright owner]
62
+
63
+ Licensed under the Apache License, Version 2.0 (the "License");
64
+ you may not use this file except in compliance with the License.
65
+ You may obtain a copy of the License at
66
+
67
+ http://www.apache.org/licenses/LICENSE-2.0
68
+
69
+ Unless required by applicable law or agreed to in writing, software
70
+ distributed under the License is distributed on an "AS IS" BASIS,
71
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
72
+ See the License for the specific language governing permissions and
73
+ limitations under the License.
package/LICENSE-MIT ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Steven Zimmerman
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,47 @@
1
+ # AstroMache
2
+
3
+ AstroMache is intended to become a reusable publication template product. This 0.1.0 npm candidate supplies its extracted Astro publication machinery; a complete starter is not included yet. Site identity, routes, content, styling, deployment and independently versioned integrations belong to consumers.
4
+
5
+ `astromache/portfolio` preserves the reusable photography presentation concept: a large-title hero, responsive gallery, image descriptions, and a keyboard-accessible native lightbox. Consumers supply images and their rights. The neutral example uses an original geometric SVG fixture under the owner code license; this package contains no personal photographs. One gallery instance per page is currently supported.
6
+
7
+ Version 0.1.0 is prepared as the first npm release candidate. It has not been published. The neutral example proves component integration; it is not the complete intended publication starter.
8
+
9
+ Owner-authored machinery is available under **MIT OR Apache-2.0**, at your option. Dependencies retain their own licenses.
10
+
11
+ Public templates may opt into `astromache/fonts.css` for unmodified IBM Plex Sans and IBM Plex Mono regular faces. Choose the families in consumer CSS. The package retains IBM's OFL notice and source hashes in `fonts/`; the neutral packed consumer exercises this import. The personal publication's fonts and identity remain consumer-owned.
12
+
13
+ ## Publication and lifecycle contract
14
+
15
+ `document` accepts required title, description, absolute HTTP(S) canonical URL and BCP47 language, plus optional `htmlAttributes`. It renders `head`, `header`, default/main and `footer` slots. The document supplies semantic markup and skip navigation; consumers own CSS, identity, content, scripts and hosting. The document itself adds no client router, prefetch, tracking or worker.
16
+
17
+ ```astro
18
+ ---
19
+ import Document from "astromache/document";
20
+ ---
21
+ <Document title="Example" description="Consumer-owned publication" canonical={new URL("https://example.com/")} language="en">
22
+ <link slot="head" rel="stylesheet" href="/publication.css" />
23
+ <nav slot="header">Consumer navigation</nav>
24
+ <h1>Consumer content</h1>
25
+ <footer slot="footer">Consumer attribution</footer>
26
+ </Document>
27
+ ```
28
+
29
+ `portfolio` accepts title, description and an array of source/alt/title/medium/intent items; tools are optional. One gallery per document is supported because the native dialog uses fixed internal IDs. Opening any item replaces all labels/tool chips. Enter, Escape, close button, backdrop and repeated selection preserve native dialog focus return. Broken images retain their alt and an operable close path. Consumer CSS may set `--portfolio-background`, `--portfolio-foreground`, `--portfolio-border` and `--portfolio-focus`; Canvas/CanvasText/currentColor/Highlight are defaults. Styling is standalone CSS with no Tailwind requirement. Multiple galleries are not promised.
30
+
31
+ ## Bounded native navigation policy
32
+
33
+ `navigation` exports `backgroundDownloadsAllowed(connection?, online = true)` and `installNavigationPrefetch(prefetch, options)`. Consumers inject Astro's native `prefetch` function; the module does not implement a second fetch/cache stack. Options are `maxTargets` (default 6, allowed 0-12), `delayMs` (default 120, allowed 0-2000) and an additional `include(URL)` restriction. Only debounced hover/focus intent triggers same-origin document targets, with per-document deduplication. API/share, query/hash, downloads, file targets and external links are excluded. Static public contact HTML is eligible: native HTML prefetch does not execute its CAPTCHA scripts or submit its form. A consumer may restrict that route with `include`. Offline, Save-Data, 2G/3G, downlink below 1.5Mbps and RTT at least 500ms suppress background requests. Missing connection hints use the bounded normal policy.
34
+
35
+ Enable native Astro prefetch with `prefetchAll:false`. Call the installer once; it returns a disposer. A consumer with ClientRouter must dispose/reinstall on its navigation lifecycle; static consumers initialize on direct document load. Consumers own worker scope/cache names, route allowlist, static manifest, byte/file budgets, online-only contact and the registration lifecycle. Gate explicit bulk registration with the same connection predicate, but existing browser-managed worker update checks are not fully controllable by application code. No persistent preferences, new storage permission, provider or analytics is introduced.
36
+
37
+ ## Installation and runtime boundary
38
+
39
+ This source package requires Astro ^7.3.5 and an Astro-compatible TypeScript compiler/bundler. The metadata and navigation entry points ship TypeScript source, not precompiled JavaScript; plain Node consumers need TypeScript loading support. Navigation imports are safe during SSR and installation becomes a no-op without browser globals. Astro components are compiled by the consumer. Only the five documented subpaths are supported; no root export is provided.
40
+
41
+ See the repository release checklist before proposing a public version.
42
+
43
+ ## Install and supported toolchain
44
+
45
+ After registry publication, install with `pnpm add astromache@0.1.0 astro@^7.3.5`. Before publication, install the reviewed archive path instead. Node >=24.19.0 <25 is the supported build runtime; Astro 7.3.5 is the qualified peer version. The broader declared Astro ^7.3.5 range is not exhaustively tested. Ordinary Astro compilation does not require this repository's native-TS7 qualification patch or Vite+ override.
46
+
47
+ Do not import private paths. Preserve the prior archive and lockfile for consumer rollback. Release candidates are identified by commit and archive SHA-256.
Binary file
Binary file
package/fonts/OFL.txt ADDED
@@ -0,0 +1,94 @@
1
+ Copyright © 2017 IBM Corp. with Reserved Font Name "Plex"
2
+
3
+ This Font Software is licensed under the SIL Open Font License, Version 1.1.
4
+
5
+ This license is copied below, and is also available with a FAQ at: http://scripts.sil.org/OFL
6
+
7
+
8
+ -----------------------------------------------------------
9
+ SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
10
+ -----------------------------------------------------------
11
+
12
+ PREAMBLE
13
+ The goals of the Open Font License (OFL) are to stimulate worldwide
14
+ development of collaborative font projects, to support the font creation
15
+ efforts of academic and linguistic communities, and to provide a free and
16
+ open framework in which fonts may be shared and improved in partnership
17
+ with others.
18
+
19
+ The OFL allows the licensed fonts to be used, studied, modified and
20
+ redistributed freely as long as they are not sold by themselves. The
21
+ fonts, including any derivative works, can be bundled, embedded,
22
+ redistributed and/or sold with any software provided that any reserved
23
+ names are not used by derivative works. The fonts and derivatives,
24
+ however, cannot be released under any other type of license. The
25
+ requirement for fonts to remain under this license does not apply
26
+ to any document created using the fonts or their derivatives.
27
+
28
+ DEFINITIONS
29
+ "Font Software" refers to the set of files released by the Copyright
30
+ Holder(s) under this license and clearly marked as such. This may
31
+ include source files, build scripts and documentation.
32
+
33
+ "Reserved Font Name" refers to any names specified as such after the
34
+ copyright statement(s).
35
+
36
+ "Original Version" refers to the collection of Font Software components as
37
+ distributed by the Copyright Holder(s).
38
+
39
+ "Modified Version" refers to any derivative made by adding to, deleting,
40
+ or substituting -- in part or in whole -- any of the components of the
41
+ Original Version, by changing formats or by porting the Font Software to a
42
+ new environment.
43
+
44
+ "Author" refers to any designer, engineer, programmer, technical
45
+ writer or other person who contributed to the Font Software.
46
+
47
+ PERMISSION & CONDITIONS
48
+ Permission is hereby granted, free of charge, to any person obtaining
49
+ a copy of the Font Software, to use, study, copy, merge, embed, modify,
50
+ redistribute, and sell modified and unmodified copies of the Font
51
+ Software, subject to the following conditions:
52
+
53
+ 1) Neither the Font Software nor any of its individual components,
54
+ in Original or Modified Versions, may be sold by itself.
55
+
56
+ 2) Original or Modified Versions of the Font Software may be bundled,
57
+ redistributed and/or sold with any software, provided that each copy
58
+ contains the above copyright notice and this license. These can be
59
+ included either as stand-alone text files, human-readable headers or
60
+ in the appropriate machine-readable metadata fields within text or
61
+ binary files as long as those fields can be easily viewed by the user.
62
+
63
+ 3) No Modified Version of the Font Software may use the Reserved Font
64
+ Name(s) unless explicit written permission is granted by the corresponding
65
+ Copyright Holder. This restriction only applies to the primary font name as
66
+ presented to the users.
67
+
68
+ 4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
69
+ Software shall not be used to promote, endorse or advertise any
70
+ Modified Version, except to acknowledge the contribution(s) of the
71
+ Copyright Holder(s) and the Author(s) or with their explicit written
72
+ permission.
73
+
74
+ 5) The Font Software, modified or unmodified, in part or in whole,
75
+ must be distributed entirely under this license, and must not be
76
+ distributed under any other license. The requirement for fonts to
77
+ remain under this license does not apply to any document created
78
+ using the Font Software.
79
+
80
+ TERMINATION
81
+ This license becomes null and void if any of the above conditions are
82
+ not met.
83
+
84
+ DISCLAIMER
85
+ THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
86
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
87
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
88
+ OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
89
+ COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
90
+ INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
91
+ DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
92
+ FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
93
+ OTHER DEALINGS IN THE FONT SOFTWARE.
94
+
@@ -0,0 +1,22 @@
1
+ {
2
+ "ownerDecision": "Steven Zimmerman selected IBM Plex as the reusable template font on 2026-10-04",
3
+ "license": "OFL-1.1",
4
+ "fonts": [
5
+ {
6
+ "file": "IBMPlexSans-Regular.woff2",
7
+ "source": "https://raw.githubusercontent.com/IBM/plex/master/packages/plex-sans/fonts/complete/woff2/IBMPlexSans-Regular.woff2",
8
+ "gitBlob": "231a1ad716215de37ce8102dde533be859036f91",
9
+ "sha256": "ba711a3085ff9f27440b6b9c4550cfc47c97bf36591d5da958b975bb3add8c1a",
10
+ "bytes": 63020,
11
+ "modified": false
12
+ },
13
+ {
14
+ "file": "IBMPlexMono-Regular.woff2",
15
+ "source": "https://raw.githubusercontent.com/IBM/plex/master/packages/plex-mono/fonts/complete/woff2/IBMPlexMono-Regular.woff2",
16
+ "gitBlob": "8bdb4c4b3f8fae88cc2e3c9c744952dccf89b15a",
17
+ "sha256": "ba204497f16b6d334cee9d1e963a831b73e3a56e1d6300a8489d18df7214b350",
18
+ "bytes": 49248,
19
+ "modified": false
20
+ }
21
+ ]
22
+ }
package/package.json ADDED
@@ -0,0 +1,50 @@
1
+ {
2
+ "name": "astromache",
3
+ "version": "0.1.0",
4
+ "private": false,
5
+ "description": "Astro publication components, metadata validation and bounded native navigation helpers",
6
+ "homepage": "https://github.com/EffortlessMetrics/astromache#readme",
7
+ "bugs": {
8
+ "url": "https://github.com/EffortlessMetrics/astromache/issues"
9
+ },
10
+ "license": "MIT OR Apache-2.0",
11
+ "repository": {
12
+ "type": "git",
13
+ "url": "https://github.com/EffortlessMetrics/astromache.git",
14
+ "directory": "packages/astromache"
15
+ },
16
+ "files": [
17
+ "CHANGELOG.md",
18
+ "LICENSE",
19
+ "LICENSE-MIT",
20
+ "LICENSE-APACHE",
21
+ "fonts",
22
+ "src/fonts.css",
23
+ "src/Portfolio.astro",
24
+ "src/PortfolioLightbox.astro",
25
+ "src/Document.astro",
26
+ "src/metadata.ts",
27
+ "src/navigation.ts"
28
+ ],
29
+ "type": "module",
30
+ "exports": {
31
+ "./document": "./src/Document.astro",
32
+ "./metadata": "./src/metadata.ts",
33
+ "./navigation": "./src/navigation.ts",
34
+ "./fonts.css": "./src/fonts.css",
35
+ "./portfolio": "./src/Portfolio.astro"
36
+ },
37
+ "publishConfig": {
38
+ "access": "public",
39
+ "registry": "https://registry.npmjs.org/"
40
+ },
41
+ "dependencies": {
42
+ "bcp-47": "2.1.1"
43
+ },
44
+ "peerDependencies": {
45
+ "astro": "^7.3.5"
46
+ },
47
+ "engines": {
48
+ "node": ">=24.19.0 <25"
49
+ }
50
+ }
@@ -0,0 +1,24 @@
1
+ ---
2
+ import { publicationMetadata, type PublicationMetadata } from "./metadata";
3
+ import type { HTMLAttributes } from "astro/types";
4
+ type Props = PublicationMetadata & { htmlAttributes?: HTMLAttributes<"html"> };
5
+ const metadata = publicationMetadata(Astro.props);
6
+ ---
7
+
8
+ <!doctype html>
9
+ <html {...{ ...Astro.props.htmlAttributes, lang: metadata.language }}>
10
+ <head>
11
+ <meta charset="utf-8" />
12
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
13
+ <title>{metadata.title}</title>
14
+ <meta name="description" content={metadata.description} />
15
+ <link rel="canonical" href={metadata.canonical.href} />
16
+ <slot name="head" />
17
+ </head>
18
+ <body>
19
+ <a href="#main">Skip to content</a>
20
+ <slot name="header" />
21
+ <main id="main" tabindex="-1"><slot /></main>
22
+ <slot name="footer" />
23
+ </body>
24
+ </html>
@@ -0,0 +1,37 @@
1
+ ---
2
+ import PortfolioLightbox, { type PortfolioLightboxItem } from "./PortfolioLightbox.astro";
3
+ interface Props {
4
+ title: string;
5
+ description?: string;
6
+ items: PortfolioLightboxItem[];
7
+ }
8
+ const { title, description, items } = Astro.props;
9
+ ---
10
+ <section class="portfolio" aria-label={title}>
11
+ <div class="hero">
12
+ <h1>{title}</h1>
13
+ {description && <p>{description}</p>}
14
+ <slot name="introduction" />
15
+ </div>
16
+ <div class="gallery">
17
+ {items.map((item, index) => <figure>
18
+ <button type="button" data-portfolio-trigger={index} aria-label={`Open ${item.title} in the portfolio lightbox`}>
19
+ <img src={item.src} alt={item.alt} loading="lazy" width="960" height="640" />
20
+ </button>
21
+ <figcaption><h2>{item.title}</h2><p>{item.medium}</p><p>{item.intent}</p></figcaption>
22
+ </figure>)}
23
+ </div>
24
+ <PortfolioLightbox items={items} />
25
+ </section>
26
+ <style>
27
+ .portfolio {max-width:64rem;margin-inline:auto;padding:1rem;overflow-wrap:anywhere;}
28
+ .hero {padding:clamp(1.5rem,4vw,3.5rem);border:1px solid var(--portfolio-border,currentColor);border-radius:2rem;background:radial-gradient(ellipse at 50% 0,color-mix(in srgb,currentColor 8%,transparent),transparent 65%);}
29
+ h1 {font-size:clamp(2.25rem,1.75rem + 2.5vw,3.5rem);font-weight:600;letter-spacing:-.025em;line-height:1.5;margin:0;}
30
+ .gallery {display:grid;gap:2rem;margin-block:3rem;}
31
+ figure {margin:0;min-width:0;}
32
+ button {display:block;width:100%;padding:0;border:0;border-radius:1.5rem;overflow:hidden;cursor:pointer;background:transparent;}
33
+ button:focus-visible {outline:3px solid var(--portfolio-focus,currentColor);outline-offset:4px;}
34
+ img {display:block;width:100%;height:auto;aspect-ratio:3/2;object-fit:cover;}
35
+ h2 {font-weight:600;line-height:1.5;}
36
+ @media(min-width:48rem){.gallery{grid-template-columns:repeat(2,minmax(0,1fr));}}
37
+ </style>
@@ -0,0 +1,184 @@
1
+ ---
2
+ export interface PortfolioLightboxItem {
3
+ title: string;
4
+ medium: string;
5
+ intent: string;
6
+ alt: string;
7
+ src: string;
8
+ tools?: string[];
9
+ }
10
+
11
+ export interface Props {
12
+ items: PortfolioLightboxItem[];
13
+ }
14
+
15
+ const { items } = Astro.props as Props;
16
+ ---
17
+
18
+ <dialog
19
+ id="portfolio-lightbox"
20
+ class="portfolio-lightbox"
21
+ aria-labelledby="portfolio-lightbox-title"
22
+ >
23
+ <div class="portfolio-controls">
24
+ <button
25
+ id="portfolio-lightbox-close"
26
+ type="button"
27
+ class="portfolio-close"
28
+ >
29
+ Close
30
+ </button>
31
+ </div>
32
+
33
+ <div
34
+ class="portfolio-detail-grid"
35
+ >
36
+ <figure>
37
+ <img
38
+ id="portfolio-lightbox-image"
39
+ alt=""
40
+ loading="eager"
41
+ />
42
+ </figure>
43
+
44
+ <div>
45
+ <p
46
+ id="portfolio-lightbox-medium"
47
+ >
48
+ </p>
49
+ <h2
50
+ id="portfolio-lightbox-title"
51
+ >
52
+ </h2>
53
+ <p
54
+ id="portfolio-lightbox-intent"
55
+ >
56
+ </p>
57
+ <ul id="portfolio-lightbox-tools" hidden>
58
+ </ul>
59
+ </div>
60
+ </div>
61
+ </dialog>
62
+
63
+ <style>
64
+ .portfolio-lightbox {
65
+ background:var(--portfolio-background,Canvas);
66
+ color:var(--portfolio-foreground,CanvasText);
67
+ border:1px solid var(--portfolio-border,currentColor);
68
+ padding:1rem;
69
+ inset: 0;
70
+ max-height: calc(100dvh - 2rem);
71
+ max-width: calc(100vw - 2rem);
72
+ margin: auto;
73
+ width: min(1200px, calc(100vw - 2rem));
74
+ }
75
+
76
+ .portfolio-lightbox::backdrop {
77
+ background: rgba(7, 10, 18, 0.82);
78
+ backdrop-filter: blur(10px);
79
+ }
80
+ .portfolio-lightbox > div:first-child {display:flex;justify-content:flex-end;}
81
+ .portfolio-lightbox > div:nth-child(2) {max-height:calc(100dvh - 8rem);overflow:auto;}
82
+ .portfolio-lightbox figure {margin:1rem 0;}
83
+ .portfolio-lightbox img {width:100%;height:auto;max-height:65dvh;object-fit:contain;}
84
+ .portfolio-lightbox ul {list-style:none;display:flex;flex-wrap:wrap;gap:0.5rem;padding:0;}
85
+ .portfolio-lightbox ul[hidden] {display:none;}
86
+ .portfolio-close {font:inherit;color:inherit;background:transparent;border:1px solid var(--portfolio-border,currentColor);border-radius:0.5rem;padding:0.35rem 0.75rem;cursor:pointer;}
87
+ .portfolio-close:focus-visible {outline:2px solid var(--portfolio-focus,Highlight);outline-offset:3px;}
88
+ .portfolio-detail-grid {display:grid;gap:1rem;}
89
+ #portfolio-lightbox-title {font-size:clamp(1.25rem,2vw,2rem);line-height:1.3;}
90
+ .portfolio-lightbox :global(.portfolio-tool) {border:1px solid var(--portfolio-border,currentColor);border-radius:1rem;padding:0.2rem 0.6rem;font-size:0.75rem;}
91
+ @media(min-width:800px) {.portfolio-detail-grid {grid-template-columns:minmax(0,1.6fr) minmax(16rem,1fr);}}
92
+ </style>
93
+
94
+ <script define:vars={{ items }}>
95
+ const lightboxItems = items;
96
+
97
+ const initPortfolioLightbox = () => {
98
+ const dialog = document.getElementById("portfolio-lightbox");
99
+ if (!(dialog instanceof HTMLDialogElement)) return;
100
+
101
+ const image = document.getElementById("portfolio-lightbox-image");
102
+ const title = document.getElementById("portfolio-lightbox-title");
103
+ const medium = document.getElementById("portfolio-lightbox-medium");
104
+ const intent = document.getElementById("portfolio-lightbox-intent");
105
+ const tools = document.getElementById("portfolio-lightbox-tools");
106
+ const closeButton = document.getElementById("portfolio-lightbox-close");
107
+
108
+ if (
109
+ !(image instanceof HTMLImageElement) ||
110
+ !(title instanceof HTMLElement) ||
111
+ !(medium instanceof HTMLElement) ||
112
+ !(intent instanceof HTMLElement) ||
113
+ !(tools instanceof HTMLElement) ||
114
+ !(closeButton instanceof HTMLButtonElement)
115
+ ) {
116
+ return;
117
+ }
118
+
119
+ if (dialog.dataset.lightboxBound !== "true") {
120
+ closeButton.addEventListener("click", () => dialog.close());
121
+
122
+ dialog.addEventListener("click", event => {
123
+ if (event.target !== dialog) return;
124
+ const rect = dialog.getBoundingClientRect();
125
+ const insideBounds =
126
+ event.clientX >= rect.left &&
127
+ event.clientX <= rect.right &&
128
+ event.clientY >= rect.top &&
129
+ event.clientY <= rect.bottom;
130
+
131
+ if (!insideBounds) {
132
+ dialog.close();
133
+ }
134
+ });
135
+
136
+ dialog.dataset.lightboxBound = "true";
137
+ }
138
+
139
+ const renderItem = index => {
140
+ const item = lightboxItems[index];
141
+ if (!item) return;
142
+
143
+ image.src = item.src;
144
+ image.alt = item.alt;
145
+ title.textContent = item.title;
146
+ medium.textContent = item.medium;
147
+ intent.textContent = item.intent;
148
+
149
+ tools.replaceChildren();
150
+
151
+ if (Array.isArray(item.tools) && item.tools.length > 0) {
152
+ for (const label of item.tools) {
153
+ const chip = document.createElement("li");
154
+ chip.className = "portfolio-tool";
155
+ chip.textContent = label;
156
+ tools.append(chip);
157
+ }
158
+ tools.hidden = false;
159
+ } else {
160
+ tools.hidden = true;
161
+ }
162
+ };
163
+
164
+ document.querySelectorAll("[data-portfolio-trigger]").forEach(trigger => {
165
+ if (!(trigger instanceof HTMLElement)) return;
166
+ if (trigger.dataset.lightboxBound === "true") return;
167
+
168
+ trigger.addEventListener("click", () => {
169
+ const rawIndex = trigger.dataset.portfolioTrigger;
170
+ const index = Number(rawIndex);
171
+ if (!Number.isFinite(index)) return;
172
+ renderItem(index);
173
+ dialog.showModal();
174
+ });
175
+
176
+ trigger.dataset.lightboxBound = "true";
177
+ });
178
+ };
179
+
180
+ initPortfolioLightbox();
181
+ document.addEventListener("astro:page-load", initPortfolioLightbox);
182
+ document.addEventListener("astro:after-swap", initPortfolioLightbox);
183
+ </script>
184
+
package/src/fonts.css ADDED
@@ -0,0 +1,15 @@
1
+ /* Optional public-template alternative. Personal consumers choose their own fonts. */
2
+ @font-face {
3
+ font-family: "IBM Plex Sans";
4
+ src: url("../fonts/IBMPlexSans-Regular.woff2") format("woff2");
5
+ font-weight: 400;
6
+ font-style: normal;
7
+ font-display: swap;
8
+ }
9
+ @font-face {
10
+ font-family: "IBM Plex Mono";
11
+ src: url("../fonts/IBMPlexMono-Regular.woff2") format("woff2");
12
+ font-weight: 400;
13
+ font-style: normal;
14
+ font-display: swap;
15
+ }
@@ -0,0 +1,31 @@
1
+ import { parse, stringify } from "bcp-47";
2
+
3
+ export interface PublicationMetadata {
4
+ title: string;
5
+ description: string;
6
+ canonical: URL;
7
+ language: string;
8
+ }
9
+
10
+ export function publicationMetadata(input: PublicationMetadata): PublicationMetadata {
11
+ if (!input.title.trim() || !input.description.trim() || !input.language.trim()) {
12
+ throw new Error("Publication metadata requires a title, description and language");
13
+ }
14
+ const language = parse(input.language, { normalize: false });
15
+ const variants = language.variants.map((variant) => variant.toLowerCase());
16
+ const singletons = language.extensions.map((extension) => extension.singleton.toLowerCase());
17
+ if (
18
+ stringify(language).toLowerCase() !== input.language.toLowerCase() ||
19
+ new Set(variants).size !== variants.length ||
20
+ new Set(singletons).size !== singletons.length
21
+ ) {
22
+ throw new Error("Publication language must be a well-formed BCP 47 tag");
23
+ }
24
+ if (!["http:", "https:"].includes(input.canonical.protocol)) {
25
+ throw new Error("Canonical publication URLs must use HTTP or HTTPS");
26
+ }
27
+ if (input.canonical.username || input.canonical.password || input.canonical.hash) {
28
+ throw new Error("Canonical publication URLs cannot contain credentials or fragments");
29
+ }
30
+ return { ...input, canonical: new URL(input.canonical.href) };
31
+ }
@@ -0,0 +1,104 @@
1
+ export interface ConnectionHints {
2
+ readonly saveData?: boolean;
3
+ readonly effectiveType?: string;
4
+ readonly downlink?: number;
5
+ readonly rtt?: number;
6
+ }
7
+
8
+ /** No persistent preferences, prompts, provider calls or analytics. */
9
+ export function backgroundDownloadsAllowed(connection?: ConnectionHints, online = true): boolean {
10
+ return (
11
+ online &&
12
+ !connection?.saveData &&
13
+ !/^(slow-2g|2g|3g)$/i.test(connection?.effectiveType ?? "") &&
14
+ !(
15
+ typeof connection?.downlink === "number" &&
16
+ connection.downlink > 0 &&
17
+ connection.downlink < 1.5
18
+ ) &&
19
+ !(typeof connection?.rtt === "number" && connection.rtt >= 500)
20
+ );
21
+ }
22
+
23
+ export interface NavigationPrefetchOptions {
24
+ /** Per document, 0 disables; bounded to at most 12 distinct targets. Default 6. */
25
+ maxTargets?: number;
26
+ /** Intent debounce, default 120ms. */
27
+ delayMs?: number;
28
+ /** Additional consumer-owned route restrictions. */
29
+ include?: (url: URL) => boolean;
30
+ }
31
+
32
+ /** Consumer injects Astro's native prefetch; no second fetch/cache implementation. */
33
+ export function installNavigationPrefetch(
34
+ prefetch: (url: string) => void,
35
+ options: NavigationPrefetchOptions = {},
36
+ ): () => void {
37
+ if (typeof document === "undefined" || typeof window === "undefined") return () => {};
38
+ const maximum = options.maxTargets ?? 6;
39
+ const delay = options.delayMs ?? 120;
40
+ if (
41
+ !Number.isInteger(maximum) ||
42
+ maximum < 0 ||
43
+ maximum > 12 ||
44
+ !Number.isFinite(delay) ||
45
+ delay < 0 ||
46
+ delay > 2000
47
+ )
48
+ throw new RangeError("Prefetch requires a bounded target count and delay");
49
+ const requested = new Set<string>();
50
+ const controller = new AbortController();
51
+ let timer: ReturnType<typeof setTimeout> | undefined;
52
+ const allowed = () =>
53
+ backgroundDownloadsAllowed(
54
+ (navigator as Navigator & { connection?: ConnectionHints }).connection,
55
+ navigator.onLine,
56
+ ) && document.visibilityState !== "hidden";
57
+ const anchor = (target: EventTarget | null) =>
58
+ target instanceof Element ? target.closest<HTMLAnchorElement>("a[href]") : null;
59
+ const cancel = () => clearTimeout(timer);
60
+ const schedule = (event: Event) => {
61
+ const link = anchor(event.target);
62
+ if (
63
+ !link ||
64
+ link.hasAttribute("download") ||
65
+ (link.target && link.target !== "_self") ||
66
+ requested.size >= maximum ||
67
+ !allowed()
68
+ )
69
+ return;
70
+ if (event instanceof MouseEvent && anchor(event.relatedTarget) === link) return;
71
+ const url = new URL(link.href, location.href);
72
+ if (
73
+ url.origin !== location.origin ||
74
+ url.username ||
75
+ url.password ||
76
+ url.search ||
77
+ url.hash ||
78
+ url.pathname === location.pathname ||
79
+ /^\/(api|share)(\/|$)/.test(url.pathname) ||
80
+ /\.[^/]+$/.test(url.pathname) ||
81
+ options.include?.(url) === false ||
82
+ requested.has(url.href)
83
+ )
84
+ return;
85
+ cancel();
86
+ timer = setTimeout(() => {
87
+ if (!allowed() || requested.size >= maximum || requested.has(url.href)) return;
88
+ requested.add(url.href);
89
+ prefetch(url.href);
90
+ }, delay);
91
+ };
92
+ const leave = (event: Event) => {
93
+ if (event instanceof MouseEvent && anchor(event.relatedTarget) === anchor(event.target)) return;
94
+ cancel();
95
+ };
96
+ for (const name of ["mouseover", "focusin"])
97
+ document.addEventListener(name, schedule, { passive: true, signal: controller.signal });
98
+ for (const name of ["mouseout", "focusout"])
99
+ document.addEventListener(name, leave, { passive: true, signal: controller.signal });
100
+ return () => {
101
+ cancel();
102
+ controller.abort();
103
+ };
104
+ }