@bamboocss/astro-plugin-studio 1.11.1 → 1.11.3
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/dist/index.cjs +57 -0
- package/dist/index.d.cts +5 -0
- package/dist/index.d.mts +6 -0
- package/dist/index.mjs +53 -76
- package/package.json +10 -10
- package/dist/index.js +0 -101
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
let _bamboocss_node = require("@bamboocss/node");
|
|
2
|
+
let _bamboocss_core = require("@bamboocss/core");
|
|
3
|
+
let javascript_stringify = require("javascript-stringify");
|
|
4
|
+
//#region src/index.ts
|
|
5
|
+
const virtualModuleId = "virtual:bamboo";
|
|
6
|
+
const resolvedVirtualModuleId = "\0" + virtualModuleId;
|
|
7
|
+
function vitePlugin(configPath) {
|
|
8
|
+
let config;
|
|
9
|
+
const textStyleMap = {};
|
|
10
|
+
const layerStyleMap = {};
|
|
11
|
+
const themesMap = {};
|
|
12
|
+
async function loadBambooConfig() {
|
|
13
|
+
const ctx = await (0, _bamboocss_node.loadConfigAndCreateContext)({ configPath });
|
|
14
|
+
for (const key of Object.keys(ctx.config.theme?.textStyles ?? {})) textStyleMap[key] = (0, _bamboocss_core.stringify)(ctx.utility.transform("textStyle", key).styles);
|
|
15
|
+
for (const key of Object.keys(ctx.config.theme?.layerStyles ?? {})) layerStyleMap[key] = (0, _bamboocss_core.stringify)(ctx.utility.transform("layerStyle", key).styles);
|
|
16
|
+
if (ctx.config.themes) for (const [themeName, themeConfig] of Object.entries(ctx.config.themes)) themesMap[themeName] = themeConfig;
|
|
17
|
+
config = ctx.config;
|
|
18
|
+
}
|
|
19
|
+
return {
|
|
20
|
+
name: "@bamboocss/studio",
|
|
21
|
+
async configureServer(server) {
|
|
22
|
+
server.watcher.add(configPath).on("change", async (path) => {
|
|
23
|
+
if (path !== configPath) return;
|
|
24
|
+
await loadBambooConfig();
|
|
25
|
+
const module = server.moduleGraph.getModuleById(resolvedVirtualModuleId);
|
|
26
|
+
if (module) await server.reloadModule(module);
|
|
27
|
+
});
|
|
28
|
+
},
|
|
29
|
+
resolveId(id) {
|
|
30
|
+
if (id === virtualModuleId) return resolvedVirtualModuleId;
|
|
31
|
+
return null;
|
|
32
|
+
},
|
|
33
|
+
async load(id) {
|
|
34
|
+
if (id === resolvedVirtualModuleId) {
|
|
35
|
+
await loadBambooConfig();
|
|
36
|
+
return { code: [
|
|
37
|
+
`export const config = ${(0, javascript_stringify.stringify)(config)}`,
|
|
38
|
+
`export const textStyles = ${(0, javascript_stringify.stringify)(textStyleMap)}`,
|
|
39
|
+
`export const layerStyles = ${(0, javascript_stringify.stringify)(layerStyleMap)}`,
|
|
40
|
+
`export const themes = ${(0, javascript_stringify.stringify)(themesMap)}`
|
|
41
|
+
].join("\n\n") };
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
const bambooStudio = () => ({
|
|
47
|
+
name: "@bamboocss/studio",
|
|
48
|
+
hooks: { "astro:config:setup": ({ updateConfig }) => {
|
|
49
|
+
const configPath = process.env.PUBLIC_CONFIG_PATH;
|
|
50
|
+
updateConfig({ vite: {
|
|
51
|
+
plugins: [vitePlugin(configPath)],
|
|
52
|
+
ssr: { noExternal: ["nanostores", "@nanostores/react"] }
|
|
53
|
+
} });
|
|
54
|
+
} }
|
|
55
|
+
});
|
|
56
|
+
//#endregion
|
|
57
|
+
module.exports = bambooStudio;
|
package/dist/index.d.cts
ADDED
package/dist/index.d.mts
ADDED
package/dist/index.mjs
CHANGED
|
@@ -1,80 +1,57 @@
|
|
|
1
|
-
// src/index.ts
|
|
2
1
|
import { loadConfigAndCreateContext } from "@bamboocss/node";
|
|
3
|
-
import { stringify
|
|
4
|
-
import { stringify } from "javascript-stringify";
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
import { stringify } from "@bamboocss/core";
|
|
3
|
+
import { stringify as stringify$1 } from "javascript-stringify";
|
|
4
|
+
//#region src/index.ts
|
|
5
|
+
const virtualModuleId = "virtual:bamboo";
|
|
6
|
+
const resolvedVirtualModuleId = "\0" + virtualModuleId;
|
|
7
7
|
function vitePlugin(configPath) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
async load(id) {
|
|
46
|
-
if (id === resolvedVirtualModuleId) {
|
|
47
|
-
await loadBambooConfig();
|
|
48
|
-
return {
|
|
49
|
-
code: [
|
|
50
|
-
`export const config = ${stringify(config)}`,
|
|
51
|
-
`export const textStyles = ${stringify(textStyleMap)}`,
|
|
52
|
-
`export const layerStyles = ${stringify(layerStyleMap)}`,
|
|
53
|
-
`export const themes = ${stringify(themesMap)}`
|
|
54
|
-
].join("\n\n")
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
};
|
|
8
|
+
let config;
|
|
9
|
+
const textStyleMap = {};
|
|
10
|
+
const layerStyleMap = {};
|
|
11
|
+
const themesMap = {};
|
|
12
|
+
async function loadBambooConfig() {
|
|
13
|
+
const ctx = await loadConfigAndCreateContext({ configPath });
|
|
14
|
+
for (const key of Object.keys(ctx.config.theme?.textStyles ?? {})) textStyleMap[key] = stringify(ctx.utility.transform("textStyle", key).styles);
|
|
15
|
+
for (const key of Object.keys(ctx.config.theme?.layerStyles ?? {})) layerStyleMap[key] = stringify(ctx.utility.transform("layerStyle", key).styles);
|
|
16
|
+
if (ctx.config.themes) for (const [themeName, themeConfig] of Object.entries(ctx.config.themes)) themesMap[themeName] = themeConfig;
|
|
17
|
+
config = ctx.config;
|
|
18
|
+
}
|
|
19
|
+
return {
|
|
20
|
+
name: "@bamboocss/studio",
|
|
21
|
+
async configureServer(server) {
|
|
22
|
+
server.watcher.add(configPath).on("change", async (path) => {
|
|
23
|
+
if (path !== configPath) return;
|
|
24
|
+
await loadBambooConfig();
|
|
25
|
+
const module = server.moduleGraph.getModuleById(resolvedVirtualModuleId);
|
|
26
|
+
if (module) await server.reloadModule(module);
|
|
27
|
+
});
|
|
28
|
+
},
|
|
29
|
+
resolveId(id) {
|
|
30
|
+
if (id === virtualModuleId) return resolvedVirtualModuleId;
|
|
31
|
+
return null;
|
|
32
|
+
},
|
|
33
|
+
async load(id) {
|
|
34
|
+
if (id === resolvedVirtualModuleId) {
|
|
35
|
+
await loadBambooConfig();
|
|
36
|
+
return { code: [
|
|
37
|
+
`export const config = ${stringify$1(config)}`,
|
|
38
|
+
`export const textStyles = ${stringify$1(textStyleMap)}`,
|
|
39
|
+
`export const layerStyles = ${stringify$1(layerStyleMap)}`,
|
|
40
|
+
`export const themes = ${stringify$1(themesMap)}`
|
|
41
|
+
].join("\n\n") };
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
};
|
|
59
45
|
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
ssr: {
|
|
70
|
-
noExternal: ["nanostores", "@nanostores/react"]
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
}
|
|
46
|
+
const bambooStudio = () => ({
|
|
47
|
+
name: "@bamboocss/studio",
|
|
48
|
+
hooks: { "astro:config:setup": ({ updateConfig }) => {
|
|
49
|
+
const configPath = process.env.PUBLIC_CONFIG_PATH;
|
|
50
|
+
updateConfig({ vite: {
|
|
51
|
+
plugins: [vitePlugin(configPath)],
|
|
52
|
+
ssr: { noExternal: ["nanostores", "@nanostores/react"] }
|
|
53
|
+
} });
|
|
54
|
+
} }
|
|
76
55
|
});
|
|
77
|
-
|
|
78
|
-
export {
|
|
79
|
-
index_default as default
|
|
80
|
-
};
|
|
56
|
+
//#endregion
|
|
57
|
+
export { bambooStudio as default };
|
package/package.json
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bamboocss/astro-plugin-studio",
|
|
3
|
-
"version": "1.11.
|
|
3
|
+
"version": "1.11.3",
|
|
4
4
|
"description": "Vite plugin for Bamboocss Studio",
|
|
5
5
|
"homepage": "https://bamboo-css.com",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"author": "Segun Adebayo <joseshegs@gmail.com>",
|
|
8
8
|
"repository": {
|
|
9
9
|
"type": "git",
|
|
10
|
-
"url": "git+https://github.com/
|
|
10
|
+
"url": "git+https://github.com/bamboocss/bamboo.git",
|
|
11
11
|
"directory": "packages/astro-plugin-studio"
|
|
12
12
|
},
|
|
13
13
|
"files": [
|
|
14
14
|
"dist"
|
|
15
15
|
],
|
|
16
16
|
"sideEffects": false,
|
|
17
|
-
"main": "dist/index.
|
|
17
|
+
"main": "dist/index.cjs",
|
|
18
18
|
"module": "dist/index.mjs",
|
|
19
|
-
"types": "dist/index.d.
|
|
19
|
+
"types": "dist/index.d.cts",
|
|
20
20
|
"exports": {
|
|
21
21
|
".": {
|
|
22
22
|
"source": "./src/index.ts",
|
|
23
|
-
"types": "./dist/index.d.
|
|
24
|
-
"require": "./dist/index.
|
|
23
|
+
"types": "./dist/index.d.cts",
|
|
24
|
+
"require": "./dist/index.cjs",
|
|
25
25
|
"import": {
|
|
26
26
|
"types": "./dist/index.d.mts",
|
|
27
27
|
"default": "./dist/index.mjs"
|
|
@@ -34,8 +34,8 @@
|
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"javascript-stringify": "2.1.0",
|
|
37
|
-
"@bamboocss/core": "1.11.
|
|
38
|
-
"@bamboocss/node": "1.11.
|
|
37
|
+
"@bamboocss/core": "1.11.3",
|
|
38
|
+
"@bamboocss/node": "1.11.3"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"astro": "6.2.2",
|
|
@@ -45,8 +45,8 @@
|
|
|
45
45
|
"astro": ">=4"
|
|
46
46
|
},
|
|
47
47
|
"scripts": {
|
|
48
|
-
"build": "
|
|
49
|
-
"build-fast": "
|
|
48
|
+
"build": "tsdown src/index.ts --format=esm,cjs --dts",
|
|
49
|
+
"build-fast": "tsdown --dts=false src/index.ts --format=esm,cjs",
|
|
50
50
|
"dev": "pnpm build-fast --watch"
|
|
51
51
|
}
|
|
52
52
|
}
|
package/dist/index.js
DELETED
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
// src/index.ts
|
|
21
|
-
var index_exports = {};
|
|
22
|
-
__export(index_exports, {
|
|
23
|
-
default: () => index_default
|
|
24
|
-
});
|
|
25
|
-
module.exports = __toCommonJS(index_exports);
|
|
26
|
-
var import_node = require("@bamboocss/node");
|
|
27
|
-
var import_core = require("@bamboocss/core");
|
|
28
|
-
var import_javascript_stringify = require("javascript-stringify");
|
|
29
|
-
var virtualModuleId = "virtual:bamboo";
|
|
30
|
-
var resolvedVirtualModuleId = "\0" + virtualModuleId;
|
|
31
|
-
function vitePlugin(configPath) {
|
|
32
|
-
let config;
|
|
33
|
-
const textStyleMap = {};
|
|
34
|
-
const layerStyleMap = {};
|
|
35
|
-
const themesMap = {};
|
|
36
|
-
async function loadBambooConfig() {
|
|
37
|
-
const ctx = await (0, import_node.loadConfigAndCreateContext)({ configPath });
|
|
38
|
-
for (const key of Object.keys(ctx.config.theme?.textStyles ?? {})) {
|
|
39
|
-
const utility = ctx.utility.transform("textStyle", key);
|
|
40
|
-
textStyleMap[key] = (0, import_core.stringify)(utility.styles);
|
|
41
|
-
}
|
|
42
|
-
for (const key of Object.keys(ctx.config.theme?.layerStyles ?? {})) {
|
|
43
|
-
const utility = ctx.utility.transform("layerStyle", key);
|
|
44
|
-
layerStyleMap[key] = (0, import_core.stringify)(utility.styles);
|
|
45
|
-
}
|
|
46
|
-
if (ctx.config.themes) {
|
|
47
|
-
for (const [themeName, themeConfig] of Object.entries(ctx.config.themes)) {
|
|
48
|
-
themesMap[themeName] = themeConfig;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
config = ctx.config;
|
|
52
|
-
}
|
|
53
|
-
return {
|
|
54
|
-
name: "@bamboocss/studio",
|
|
55
|
-
async configureServer(server) {
|
|
56
|
-
server.watcher.add(configPath).on("change", async (path) => {
|
|
57
|
-
if (path !== configPath) return;
|
|
58
|
-
await loadBambooConfig();
|
|
59
|
-
const module2 = server.moduleGraph.getModuleById(resolvedVirtualModuleId);
|
|
60
|
-
if (module2) await server.reloadModule(module2);
|
|
61
|
-
});
|
|
62
|
-
},
|
|
63
|
-
resolveId(id) {
|
|
64
|
-
if (id === virtualModuleId) {
|
|
65
|
-
return resolvedVirtualModuleId;
|
|
66
|
-
}
|
|
67
|
-
return null;
|
|
68
|
-
},
|
|
69
|
-
async load(id) {
|
|
70
|
-
if (id === resolvedVirtualModuleId) {
|
|
71
|
-
await loadBambooConfig();
|
|
72
|
-
return {
|
|
73
|
-
code: [
|
|
74
|
-
`export const config = ${(0, import_javascript_stringify.stringify)(config)}`,
|
|
75
|
-
`export const textStyles = ${(0, import_javascript_stringify.stringify)(textStyleMap)}`,
|
|
76
|
-
`export const layerStyles = ${(0, import_javascript_stringify.stringify)(layerStyleMap)}`,
|
|
77
|
-
`export const themes = ${(0, import_javascript_stringify.stringify)(themesMap)}`
|
|
78
|
-
].join("\n\n")
|
|
79
|
-
};
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
};
|
|
83
|
-
}
|
|
84
|
-
var bambooStudio = () => ({
|
|
85
|
-
name: "@bamboocss/studio",
|
|
86
|
-
hooks: {
|
|
87
|
-
"astro:config:setup": ({ updateConfig }) => {
|
|
88
|
-
const configPath = process.env.PUBLIC_CONFIG_PATH;
|
|
89
|
-
updateConfig({
|
|
90
|
-
vite: {
|
|
91
|
-
// @ts-ignore
|
|
92
|
-
plugins: [vitePlugin(configPath)],
|
|
93
|
-
ssr: {
|
|
94
|
-
noExternal: ["nanostores", "@nanostores/react"]
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
});
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
});
|
|
101
|
-
var index_default = bambooStudio;
|