@chassis-ui/docs 0.3.3 → 0.3.4
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 +1 -1
- package/index.ts +0 -1
- package/package.json +2 -2
- package/src/layouts/footer/Scripts.astro +3 -14
- package/src/libs/vite.ts +0 -45
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
> Shared Astro layouts, components, and utilities for Chassis documentation sites.
|
|
4
4
|
|
|
5
|
-
[](https://opensource.org/licenses/MIT) [](https://opensource.org/licenses/MIT) [](https://www.npmjs.com/package/@chassis-ui/docs) [](https://www.npmjs.com/package/@chassis-ui/docs)
|
|
6
6
|
|
|
7
7
|
## Overview
|
|
8
8
|
|
package/index.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chassis-ui/docs",
|
|
3
3
|
"description": "Shared Astro components and layouts for Chassis documentation sites.",
|
|
4
|
-
"version": "0.3.
|
|
4
|
+
"version": "0.3.4",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
47
47
|
"@astrojs/markdown-remark": "^7.0.0",
|
|
48
|
-
"@chassis-ui/css": ">=0.3.
|
|
48
|
+
"@chassis-ui/css": ">=0.3.2",
|
|
49
49
|
"@pagefind/component-ui": "^1.0.0",
|
|
50
50
|
"@shikijs/transformers": "^4.3.1",
|
|
51
51
|
"astro": "^7.0.0",
|
|
@@ -6,7 +6,6 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import type { Layout } from '../../libs/layout'
|
|
9
|
-
import type { HTMLAttributes } from 'astro/types'
|
|
10
9
|
|
|
11
10
|
interface Props {
|
|
12
11
|
/** Current layout context */
|
|
@@ -14,21 +13,11 @@ interface Props {
|
|
|
14
13
|
}
|
|
15
14
|
|
|
16
15
|
const { layout } = Astro.props
|
|
17
|
-
|
|
18
|
-
function getChassisJsProps() {
|
|
19
|
-
// __CHASSIS_JS_SRC__ is an optional dev-mode override injected via vite.define by the
|
|
20
|
-
// host project's integration. When set, it replaces the default public-dir bundle path.
|
|
21
|
-
const src =
|
|
22
|
-
(import.meta.env.DEV && (globalThis as any).__CHASSIS_JS_SRC__) ||
|
|
23
|
-
(import.meta.env.PROD ? '/static/js/chassis.bundle.min.js' : '/static/js/chassis.bundle.js')
|
|
24
|
-
|
|
25
|
-
const cxJsLinkProps: HTMLAttributes<'script'> = { type: 'module', src }
|
|
26
|
-
|
|
27
|
-
return cxJsLinkProps
|
|
28
|
-
}
|
|
29
16
|
---
|
|
30
17
|
|
|
31
18
|
<script src="../../js/search.js"></script>
|
|
32
|
-
<script
|
|
19
|
+
<script>
|
|
20
|
+
import '@chassis-ui/css'
|
|
21
|
+
</script>
|
|
33
22
|
{layout === 'docs' && <script src="../../js/sidebar.js" />}
|
|
34
23
|
<slot name="scripts" />
|
package/src/libs/vite.ts
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import fs from 'node:fs'
|
|
2
|
-
import path from 'node:path'
|
|
3
|
-
import type { Plugin } from 'vite'
|
|
4
|
-
|
|
5
|
-
// Virtual module URL served by Vite's module graph at /@id/__x00__chassis-bundle.
|
|
6
|
-
// Used to give the browser a single shared ESM instance of the chassis bundle in dev.
|
|
7
|
-
const CHASSIS_BUNDLE_VIRTUAL_URL = '/@id/__x00__chassis-bundle'
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Vite plugin that resolves `@chassis-ui/css` to a virtual module in dev so
|
|
11
|
-
* both the `<script>` tag and any `import()` share one ESM instance.
|
|
12
|
-
*
|
|
13
|
-
* In build, `rollupOptions.external` + `paths` in the consuming `astro.config.ts`
|
|
14
|
-
* handles deduplication instead.
|
|
15
|
-
*
|
|
16
|
-
* @param getChassisCSSFsPath - Returns the absolute path to the compiled Chassis CSS dist folder.
|
|
17
|
-
*/
|
|
18
|
-
export function chassisBundlePlugin(getChassisCSSFsPath: () => string) {
|
|
19
|
-
return {
|
|
20
|
-
plugin: {
|
|
21
|
-
name: 'chassis-ui-css',
|
|
22
|
-
enforce: 'pre',
|
|
23
|
-
apply: 'serve',
|
|
24
|
-
resolveId(id: string) {
|
|
25
|
-
if (id === '@chassis-ui/css') return '\0@chassis-ui/css'
|
|
26
|
-
if (id === '/@chassis-bundle') return '\0chassis-bundle'
|
|
27
|
-
},
|
|
28
|
-
load(id: string) {
|
|
29
|
-
if (id === '\0@chassis-ui/css') return `export * from "/@chassis-bundle"`
|
|
30
|
-
if (id === '\0chassis-bundle') {
|
|
31
|
-
const bundlePath = path.join(getChassisCSSFsPath(), 'js/chassis.bundle.js')
|
|
32
|
-
const content = fs.readFileSync(bundlePath, 'utf-8')
|
|
33
|
-
// Strip sourceMappingURL — the map isn't resolvable from a virtual module URL.
|
|
34
|
-
return content.replace(/^\/\/# sourceMappingURL=.+$/m, '')
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
} satisfies Plugin,
|
|
38
|
-
// __CHASSIS_JS_SRC__ is a @chassis-ui/docs extension point: sets the URL for the
|
|
39
|
-
// chassis JS <script> tag in dev mode. Points at the virtual module so the browser
|
|
40
|
-
// gets one shared ESM instance instead of a second copy from public/.
|
|
41
|
-
define: {
|
|
42
|
-
'globalThis.__CHASSIS_JS_SRC__': JSON.stringify(CHASSIS_BUNDLE_VIRTUAL_URL)
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
}
|