@studiocms/ui 0.3.0 → 0.3.1
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@studiocms/ui",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"description": "The UI library for StudioCMS. Includes the layouts & components we use to build StudioCMS.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -21,7 +21,8 @@
|
|
|
21
21
|
"astro-ui-library",
|
|
22
22
|
"astro-components",
|
|
23
23
|
"studiocms",
|
|
24
|
-
"ui-library"
|
|
24
|
+
"ui-library",
|
|
25
|
+
"astro-integration"
|
|
25
26
|
],
|
|
26
27
|
"homepage": "https://ui.studiocms.dev",
|
|
27
28
|
"publishConfig": {
|
|
@@ -42,8 +43,9 @@
|
|
|
42
43
|
"./types": "./src/types/index.ts"
|
|
43
44
|
},
|
|
44
45
|
"dependencies": {
|
|
46
|
+
"@iconify-json/heroicons": "^1.2.1",
|
|
45
47
|
"@iconify/utils": "^2.1.33",
|
|
46
|
-
"
|
|
48
|
+
"pathe": "^1.1.2"
|
|
47
49
|
},
|
|
48
50
|
"peerDependencies": {
|
|
49
51
|
"astro": "^4.5 || ^5.0.0-beta.0"
|
package/src/integration.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { AstroIntegration } from 'astro';
|
|
2
2
|
import { createResolver } from './utils/create-resolver';
|
|
3
|
+
import { viteVirtualModulePluginBuilder } from './utils/virtual-module-plugin-builder';
|
|
3
4
|
|
|
4
5
|
// biome-ignore lint/complexity/noBannedTypes: Will be implemented in v0.3.0
|
|
5
6
|
type Options = {};
|
|
@@ -7,11 +8,23 @@ type Options = {};
|
|
|
7
8
|
export default function integration(options: Options = {}): AstroIntegration {
|
|
8
9
|
const { resolve } = createResolver(import.meta.url);
|
|
9
10
|
|
|
11
|
+
const globalCss = viteVirtualModulePluginBuilder(
|
|
12
|
+
'studiocms:ui/global-css',
|
|
13
|
+
'sui-global-css',
|
|
14
|
+
`import '${resolve('./css/global.css')}'`
|
|
15
|
+
);
|
|
16
|
+
|
|
10
17
|
return {
|
|
11
18
|
name: '@studiocms/ui',
|
|
12
19
|
hooks: {
|
|
13
|
-
'astro:config:setup': ({ injectScript }) => {
|
|
14
|
-
|
|
20
|
+
'astro:config:setup': ({ injectScript, updateConfig }) => {
|
|
21
|
+
updateConfig({
|
|
22
|
+
vite: {
|
|
23
|
+
plugins: [globalCss()],
|
|
24
|
+
},
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
injectScript('page-ssr', `import 'studiocms:ui/global-css';`);
|
|
15
28
|
},
|
|
16
29
|
},
|
|
17
30
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { dirname, resolve } from 'node:path'; // Swapped out pathe for node:path to cut down on dependencies
|
|
2
1
|
import { fileURLToPath } from 'node:url';
|
|
2
|
+
import { dirname, resolve } from 'pathe';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* From the Astro Integration Kit (https://astro-integration-kit.netlify.app/).
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { AstroConfig } from 'astro';
|
|
2
|
+
|
|
3
|
+
type VitePlugin = Required<AstroConfig['vite']>['plugins'][number];
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Builds a Vite plugin that creates a virtual module.
|
|
7
|
+
*
|
|
8
|
+
* @param moduleId - The ID of the virtual module.
|
|
9
|
+
* @param name - The name of the plugin.
|
|
10
|
+
* @param moduleContent - The content of the virtual module.
|
|
11
|
+
* @returns A Vite plugin that resolves and loads the virtual module.
|
|
12
|
+
*/
|
|
13
|
+
export function viteVirtualModulePluginBuilder(
|
|
14
|
+
moduleId: string,
|
|
15
|
+
name: string,
|
|
16
|
+
moduleContent: string
|
|
17
|
+
) {
|
|
18
|
+
return function modulePlugin(): VitePlugin {
|
|
19
|
+
const resolvedVirtualModuleId = `\0${moduleId}`; // Prefix with \0 to avoid conflicts
|
|
20
|
+
|
|
21
|
+
return {
|
|
22
|
+
name,
|
|
23
|
+
resolveId(id) {
|
|
24
|
+
if (id === moduleId) {
|
|
25
|
+
return resolvedVirtualModuleId;
|
|
26
|
+
}
|
|
27
|
+
return;
|
|
28
|
+
},
|
|
29
|
+
load(id) {
|
|
30
|
+
if (id === resolvedVirtualModuleId) {
|
|
31
|
+
return moduleContent;
|
|
32
|
+
}
|
|
33
|
+
return;
|
|
34
|
+
},
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
}
|