@sugarcube-org/vite 0.0.0-alpha.2 → 0.0.0-alpha.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/LICENSE.md +9 -0
- package/README.md +42 -0
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +4 -11
- package/package.json +4 -3
package/LICENSE.md
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# Proprietary Software
|
|
2
|
+
|
|
3
|
+
This software is proprietary and confidential. All rights reserved.
|
|
4
|
+
|
|
5
|
+
Copyright (c) 2025 Mark Tomlinson
|
|
6
|
+
|
|
7
|
+
This software is provided "as is" without warranty of any kind, either express or implied.
|
|
8
|
+
|
|
9
|
+
Unauthorized copying, distribution, or use of this software is strictly prohibited.
|
package/README.md
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# @sugarcube-org/vite
|
|
2
|
+
|
|
3
|
+
Vite plugin for automatic sugarcube CSS generation.
|
|
4
|
+
|
|
5
|
+
## What it does
|
|
6
|
+
|
|
7
|
+
- Automatically regenerates CSS variables and utilities when design tokens change
|
|
8
|
+
- Integrates with Vite's file watching and hot module replacement
|
|
9
|
+
- Provides seamless development experience for sugarcube projects
|
|
10
|
+
|
|
11
|
+
## Installation
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npm install @sugarcube-org/vite
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Usage
|
|
18
|
+
|
|
19
|
+
```js
|
|
20
|
+
// vite.config.js
|
|
21
|
+
import { defineConfig } from 'vite'
|
|
22
|
+
import sugarcube from '@sugarcube-org/vite'
|
|
23
|
+
|
|
24
|
+
export default defineConfig({
|
|
25
|
+
plugins: [sugarcube()]
|
|
26
|
+
})
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Features
|
|
30
|
+
|
|
31
|
+
- **Hot reload** - CSS updates automatically when tokens change
|
|
32
|
+
- **File watching** - Monitors token files and configuration
|
|
33
|
+
- **Error handling** - Graceful error reporting in development
|
|
34
|
+
- **Performance** - Efficient processing with caching
|
|
35
|
+
|
|
36
|
+
## Development
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
pnpm install
|
|
40
|
+
pnpm build
|
|
41
|
+
pnpm test
|
|
42
|
+
```
|
package/dist/index.d.mts
CHANGED
package/dist/index.mjs
CHANGED
|
@@ -1,11 +1,4 @@
|
|
|
1
|
-
var
|
|
2
|
-
|
|
3
|
-
`)),e.
|
|
4
|
-
`)),e.
|
|
5
|
-
`)),t.length>0){o.ws.send("vite:error",{message:"Token processing failed",stack:t.join(`
|
|
6
|
-
|
|
7
|
-
`)}),o.config.logger.error(`[sugarcube] Token processing failed:
|
|
8
|
-
${t.join(`
|
|
9
|
-
|
|
10
|
-
`)}`);return}const f=a(r);await u(e.output,!0,f)}catch(e){o.ws.send("vite:error",{message:"Token processing failed",stack:e instanceof Error?e.stack:String(e)}),o.config.logger.error(`[sugarcube] Error processing tokens:
|
|
11
|
-
${e instanceof Error?e.stack:String(e)}`)}},"processTokens");i();const n=a(r);for(const e of n)o.watcher.add(e);o.watcher.on("change",async e=>{n.some(t=>l(e,t))&&await i()})},async handleHotUpdate(o){if(a(r).some(n=>l(o.file,n)))try{const n=await g(r),e=a(r);return await u(n.output,!0,e),[]}catch{return[]}return null}}}c(m,"viteSugarcube");export{m as default};
|
|
1
|
+
var _=Object.defineProperty;var c=(t,n)=>_(t,"name",{value:n,configurable:!0});import{loadConfig as k,normalizeConfig as C,Instrumentation as w,generateIndex as v,tokenProcessingPipeline as W,generateCSSVariables as D,writeCSSVariablesToDisk as T,generateCSSUtilityClasses as V,writeCSSUtilitiesToDisk as z}from"@sugarcube-org/core";import{normalize as m,relative as G}from"pathe";var I=c((t,n)=>(n=Symbol[t])?n:Symbol.for("Symbol."+t),"__knownSymbol"),P=c(t=>{throw TypeError(t)},"__typeError"),S=c((t,n,u)=>{if(n!=null){typeof n!="object"&&typeof n!="function"&&P("Object expected");var f,d;f===void 0&&(f=n[I("dispose")]),typeof f!="function"&&P("Object not disposable"),d&&(f=c(function(){try{d.call(this)}catch(p){return Promise.reject(p)}},"dispose")),t.push([u,f,n])}return n},"__using"),y=c((t,n,u)=>{var f=typeof SuppressedError=="function"?SuppressedError:function(l,e,i,a){return a=Error(i),a.name="SuppressedError",a.error=l,a.suppressed=e,a},d=c(l=>n=u?new f(l,n,"An error was suppressed during disposal"):(u=!0,l),"fail"),p=c(l=>{for(;l=t.pop();)try{var e=l[1]&&l[1].call(l[2]);if(l[0])return Promise.resolve(e).then(p,i=>(d(i),p()))}catch(i){d(i)}if(u)throw n},"next");return p()},"__callDispose");let b=null;const o=process.env.DEBUG==="true",E=c((t,n)=>{if(!b){console.error(`[sugarcube] ${t}`,n);return}const u=n instanceof Error?n.message:String(n);b.config.logger.error(`[sugarcube] ${t}${u}`)},"reportError"),j=c(t=>{try{return m(G(process.cwd(),t))}catch(n){return o&&console.warn("[sugarcube] Failed to convert path to relative:",t,n),m(t)}},"toRelativePath");function x(){let t=null;const n=c(e=>{if(!t)return!1;const i=j(e),a=t.config.output.tokens;return i.startsWith(a)&&i.endsWith(".json")},"isTokenFile"),u=c(e=>e===t?.configPath,"isSCConfigFile"),f=c(async()=>{var e=[];try{const s=S(e,new w);if(o&&s.start("Process Tokens"),!t)throw new Error("Sugarcube config not initialized");o&&s.start("Token Processing Pipeline");const r=await W({type:"files",config:t.config}),g=[...r.errors.load,...r.errors.flatten,...r.errors.validation,...r.errors.resolution];return g.length>0&&E(`Token processing issues found:
|
|
2
|
+
`,g.map(h=>` - ${h.message}`).join(`
|
|
3
|
+
`)),o&&s.end("Token Processing Pipeline"),o&&s.end("Process Tokens"),{resolved:r.resolved,trees:r.trees}}catch(s){var i=s,a=!0}finally{y(e,i,a)}},"processTokens"),d=c(async e=>{var i=[];try{const r=S(i,new w);if(o&&r.start("Generate and Write CSS Variables"),!t)throw new Error("Sugarcube config not initialized");o&&r.start("CSS Variables Pipeline");const g=await D(e.trees,e.resolved,t.config);o&&r.end("CSS Variables Pipeline"),o&&r.start("Write CSS Variables to Disk"),await T(g.output),o&&r.end("Write CSS Variables to Disk"),o&&r.end("Generate and Write CSS Variables")}catch(r){var a=r,s=!0}finally{y(i,a,s)}},"generateAndWriteCSSVariables"),p=c(async e=>{var i=[];try{const r=S(i,new w);if(o&&r.start("Generate and Write Utilities"),!t)throw new Error("Sugarcube config not initialized");o&&r.start("Generate Utility CSS");const{output:g}=V(e.resolved,t.config);o&&r.end("Generate Utility CSS"),o&&r.start("Write CSS Utilities to Disk"),await z(g),o&&r.end("Write CSS Utilities to Disk"),o&&r.end("Generate and Write Utilities")}catch(r){var a=r,s=!0}finally{y(i,a,s)}},"generateAndWriteUtilities"),l=c(async()=>{var e=[];try{const s=S(e,new w);o&&s.start("Process and Update");try{const r=await f();await d(r),await p(r)}catch(r){E("Sugarcube processing failed",r)}o&&s.end("Process and Update")}catch(s){var i=s,a=!0}finally{y(e,i,a)}},"processAndUpdate");return{name:"vite-plugin-sugarcube",async config(){try{if(t=await k(),!t)throw new Error("Failed to load Sugarcube config");const e=C(t.config);return t={...t,config:e},{exclude:[t.config.output.css]}}catch(e){throw e instanceof Error?new Error(`[sugarcube] Configuration error:
|
|
4
|
+
${e.message}`):e}},async configResolved(e){if(!t)throw new Error("Sugarcube config not initialized")},async buildStart(){await l()},configureServer(e){var i=[];try{const r=S(i,new w);if(b=e,t){e.watcher.add(t.config.output.tokens),e.watcher.add(t.config.output.css);const g=t.config,h=t.config.output.css;e.watcher.on("add",async U=>{await v(h,g)}),e.watcher.on("unlink",async U=>{await v(h,g)})}t?.configPath&&e.watcher.add(t.configPath)}catch(r){var a=r,s=!0}finally{y(i,a,s)}},async handleHotUpdate({file:e}){if(!e.includes("/.astro/")&&(n(e)||u(e))){if(u(e)&&(t=await k(),t)){const i=C(t.config);t={...t,config:i}}return await l(),[]}}}}c(x,"sugarcubePlugin");export{x as default};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sugarcube-org/vite",
|
|
3
|
-
"version": "0.0.0-alpha.
|
|
3
|
+
"version": "0.0.0-alpha.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -33,7 +33,8 @@
|
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"minimatch": "^10.0.1",
|
|
36
|
-
"
|
|
36
|
+
"pathe": "^2.0.3",
|
|
37
|
+
"@sugarcube-org/core": "0.0.1-alpha.6"
|
|
37
38
|
},
|
|
38
39
|
"peerDependencies": {
|
|
39
40
|
"vite": "^5.2.0 || ^6"
|
|
@@ -44,7 +45,7 @@
|
|
|
44
45
|
"vite": "^6.0.0"
|
|
45
46
|
},
|
|
46
47
|
"scripts": {
|
|
47
|
-
"build": "pkgroll --minify
|
|
48
|
+
"build": "pkgroll --minify",
|
|
48
49
|
"dev": "pkgroll --watch",
|
|
49
50
|
"test": "vitest run",
|
|
50
51
|
"test:watch": "vitest",
|