@bamboocss/astro-plugin-studio 1.11.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/LICENSE.md +16 -0
- package/dist/index.js +101 -0
- package/dist/index.mjs +80 -0
- package/package.json +52 -0
package/LICENSE.md
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023 Segun Adebayo
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
|
|
6
|
+
documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
|
|
7
|
+
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit
|
|
8
|
+
persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
9
|
+
|
|
10
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
|
|
11
|
+
Software.
|
|
12
|
+
|
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
|
|
14
|
+
WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
|
15
|
+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
|
16
|
+
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
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;
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
// src/index.ts
|
|
2
|
+
import { loadConfigAndCreateContext } from "@bamboocss/node";
|
|
3
|
+
import { stringify as stringifyBamboo } from "@bamboocss/core";
|
|
4
|
+
import { stringify } from "javascript-stringify";
|
|
5
|
+
var virtualModuleId = "virtual:bamboo";
|
|
6
|
+
var 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 loadConfigAndCreateContext({ configPath });
|
|
14
|
+
for (const key of Object.keys(ctx.config.theme?.textStyles ?? {})) {
|
|
15
|
+
const utility = ctx.utility.transform("textStyle", key);
|
|
16
|
+
textStyleMap[key] = stringifyBamboo(utility.styles);
|
|
17
|
+
}
|
|
18
|
+
for (const key of Object.keys(ctx.config.theme?.layerStyles ?? {})) {
|
|
19
|
+
const utility = ctx.utility.transform("layerStyle", key);
|
|
20
|
+
layerStyleMap[key] = stringifyBamboo(utility.styles);
|
|
21
|
+
}
|
|
22
|
+
if (ctx.config.themes) {
|
|
23
|
+
for (const [themeName, themeConfig] of Object.entries(ctx.config.themes)) {
|
|
24
|
+
themesMap[themeName] = themeConfig;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
config = ctx.config;
|
|
28
|
+
}
|
|
29
|
+
return {
|
|
30
|
+
name: "@bamboocss/studio",
|
|
31
|
+
async configureServer(server) {
|
|
32
|
+
server.watcher.add(configPath).on("change", async (path) => {
|
|
33
|
+
if (path !== configPath) return;
|
|
34
|
+
await loadBambooConfig();
|
|
35
|
+
const module = server.moduleGraph.getModuleById(resolvedVirtualModuleId);
|
|
36
|
+
if (module) await server.reloadModule(module);
|
|
37
|
+
});
|
|
38
|
+
},
|
|
39
|
+
resolveId(id) {
|
|
40
|
+
if (id === virtualModuleId) {
|
|
41
|
+
return resolvedVirtualModuleId;
|
|
42
|
+
}
|
|
43
|
+
return null;
|
|
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
|
+
};
|
|
59
|
+
}
|
|
60
|
+
var bambooStudio = () => ({
|
|
61
|
+
name: "@bamboocss/studio",
|
|
62
|
+
hooks: {
|
|
63
|
+
"astro:config:setup": ({ updateConfig }) => {
|
|
64
|
+
const configPath = process.env.PUBLIC_CONFIG_PATH;
|
|
65
|
+
updateConfig({
|
|
66
|
+
vite: {
|
|
67
|
+
// @ts-ignore
|
|
68
|
+
plugins: [vitePlugin(configPath)],
|
|
69
|
+
ssr: {
|
|
70
|
+
noExternal: ["nanostores", "@nanostores/react"]
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
var index_default = bambooStudio;
|
|
78
|
+
export {
|
|
79
|
+
index_default as default
|
|
80
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@bamboocss/astro-plugin-studio",
|
|
3
|
+
"version": "1.11.1",
|
|
4
|
+
"description": "Vite plugin for Bamboocss Studio",
|
|
5
|
+
"homepage": "https://bamboo-css.com",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"author": "Segun Adebayo <joseshegs@gmail.com>",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/chakra-ui/bamboo.git",
|
|
11
|
+
"directory": "packages/astro-plugin-studio"
|
|
12
|
+
},
|
|
13
|
+
"files": [
|
|
14
|
+
"dist"
|
|
15
|
+
],
|
|
16
|
+
"sideEffects": false,
|
|
17
|
+
"main": "dist/index.js",
|
|
18
|
+
"module": "dist/index.mjs",
|
|
19
|
+
"types": "dist/index.d.ts",
|
|
20
|
+
"exports": {
|
|
21
|
+
".": {
|
|
22
|
+
"source": "./src/index.ts",
|
|
23
|
+
"types": "./dist/index.d.ts",
|
|
24
|
+
"require": "./dist/index.js",
|
|
25
|
+
"import": {
|
|
26
|
+
"types": "./dist/index.d.mts",
|
|
27
|
+
"default": "./dist/index.mjs"
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
"./package.json": "./package.json"
|
|
31
|
+
},
|
|
32
|
+
"publishConfig": {
|
|
33
|
+
"access": "public"
|
|
34
|
+
},
|
|
35
|
+
"dependencies": {
|
|
36
|
+
"javascript-stringify": "2.1.0",
|
|
37
|
+
"@bamboocss/core": "1.11.1",
|
|
38
|
+
"@bamboocss/node": "1.11.1"
|
|
39
|
+
},
|
|
40
|
+
"devDependencies": {
|
|
41
|
+
"astro": "6.2.2",
|
|
42
|
+
"vite": "7.3.2"
|
|
43
|
+
},
|
|
44
|
+
"peerDependencies": {
|
|
45
|
+
"astro": ">=4"
|
|
46
|
+
},
|
|
47
|
+
"scripts": {
|
|
48
|
+
"build": "tsup src/index.ts --format=esm,cjs --dts",
|
|
49
|
+
"build-fast": "tsup src/index.ts --format=esm,cjs --no-dts",
|
|
50
|
+
"dev": "pnpm build-fast --watch"
|
|
51
|
+
}
|
|
52
|
+
}
|