@sugarcube-org/postcss 0.0.1-alpha.2 → 0.0.1-alpha.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/LICENSE.md ADDED
@@ -0,0 +1,31 @@
1
+ # Sugarcube Private Alpha License
2
+
3
+ Copyright © 2025 Mark Tomlinson. All rights reserved.
4
+
5
+ **Version 1.0 – December 2025**
6
+
7
+ This software is provided under a temporary, non-exclusive, non-transferable
8
+ license for private evaluation and internal use as part of the Sugarcube
9
+ Private Alpha Program.
10
+
11
+ ## Permitted
12
+
13
+ - Use in internal and client projects for the purpose of evaluating Sugarcube
14
+ - Reporting bugs, performance issues, and usability feedback
15
+
16
+ ## Not Permitted
17
+
18
+ - Redistribution of the software or any derivative works
19
+ - Public hosting of the source code
20
+ - Sublicensing, resale, or commercial distribution of Sugarcube itself
21
+ - Reverse engineering for the purpose of creating a competing product
22
+
23
+ ## Disclaimer
24
+
25
+ This software is provided "as is", without warranty of any kind, express or
26
+ implied. The author assumes no liability for damages arising from its use.
27
+
28
+ ## Future Licensing
29
+
30
+ This license will be replaced by an open-source license at public beta or
31
+ general availability.
package/README.md ADDED
@@ -0,0 +1,7 @@
1
+ # @sugarcube-org/postcss
2
+
3
+ > ⚠️ **Private Alpha** — This package is under active development and not yet ready for public use.
4
+
5
+ ## License
6
+
7
+ See [LICENSE.md](./LICENSE.md) for terms.
package/dist/index.cjs CHANGED
@@ -1,3 +1,3 @@
1
- "use strict";var h=Object.defineProperty;var u=(s,n)=>h(s,"name",{value:n,configurable:!0});var f=require("node:fs"),c=require("node:path"),l=require("@sugarcube-org/core");function y(s){return s&&"source"in s&&Array.isArray(s.source)}u(y,"isSingleCollection");function d(s,n,t=new Set){for(const r of s)if(!r.includes("*")&&f.existsSync(r)){const e=c.resolve(process.cwd(),r);t.has(e)||n.messages.push({type:"dependency",plugin:"postcss-sugarcube",file:e})}else if(r.includes("*")){const e=c.dirname(r),o=c.basename(r);f.existsSync(e)&&n.messages.push({type:"dir-dependency",plugin:"postcss-sugarcube",dir:c.resolve(process.cwd(),e),glob:o})}}u(d,"processTokenSources");function b(s,n){if(n.messages.push({type:"dependency",plugin:"postcss-sugarcube",file:c.resolve(process.cwd(),"sugarcube.config.json")}),!s.tokens)return;const t=s.output?.directories?.css||"./src/styles",r=new Set;if(s.output?.css?.separate?r.add(c.resolve(process.cwd(),`${t}/global/variables/colors.variables.css`)):r.add(c.resolve(process.cwd(),`${t}/tokens.css`)),y(s.tokens))d(s.tokens.source,n,r);else for(const[e,o]of Object.entries(s.tokens))o&&"source"in o&&Array.isArray(o.source)&&d(o.source,n,r)}u(b,"registerDependencies");function v(s){const n=s.filter(e=>e.file||e.source?.sourcePath),t=s.filter(e=>!e.file&&(!e.source||!e.source.sourcePath)),r=[];for(const e of n){const o=e.file||e.source?.sourcePath;if(!o)continue;const i=c.relative(process.cwd(),o),a=e.message.replace(o,i);r.push(a)}for(const e of t)r.push(e.message);return r.join(`
2
- - `)}u(v,"formatErrors");let g=0;const w=u((s={})=>({postcssPlugin:"postcss-sugarcube",async Once(n,{result:t}){if(!t.opts.from){t.warn("No input file provided to postcss-sugarcube");return}try{const e=n.nodes[0];if(e&&e.type==="comment"&&e.text.includes("AUTOMATICALLY GENERATED FILE"))return;const o=await l.loadConfig();b(o,t);const i=await l.tokensToCSSPipeline(o),a=[...i.errors.load,...i.errors.flatten,...i.errors.validation,...i.errors.resolution];if(a.length>0){t.warn(`Token validation failed:
3
- - ${v(a)}`,{plugin:"postcss-sugarcube",word:"error"});return}const m=l.getTokenPathsFromConfig(o);await l.writeCSSFilesToDisk(i.output,!0,m);const p=Date.now();!s.silent&&p-g>1e3&&(t.messages.push({type:"log",plugin:"postcss-sugarcube",text:"\u2728 Generated CSS files from tokens"}),g=p)}catch(e){t.warn(e instanceof Error?e.message:String(e),{plugin:"postcss-sugarcube",word:"error"})}}}),"sugarcubePlugin");w.postcss=!0,module.exports=w;
1
+ "use strict";var P=Object.defineProperty;var l=(e,r)=>P(e,"name",{value:r,configurable:!0});var h=require("node:fs"),S=require("node:path"),f=require("@sugarcube-org/core"),A=l((e,r)=>(r=Symbol[e])?r:Symbol.for("Symbol."+e),"__knownSymbol"),m=l(e=>{throw TypeError(e)},"__typeError"),b=l((e,r,t)=>{if(r!=null){typeof r!="object"&&typeof r!="function"&&m("Object expected");var n,a;n===void 0&&(n=r[A("dispose")]),typeof n!="function"&&m("Object not disposable"),a&&(n=l(function(){try{a.call(this)}catch(g){return Promise.reject(g)}},"dispose")),e.push([t,n,r])}return r},"__using"),v=l((e,r,t)=>{var n=typeof SuppressedError=="function"?SuppressedError:function(c,p,u,i){return i=Error(u),i.name="SuppressedError",i.error=c,i.suppressed=p,i},a=l(c=>r=t?new n(c,r,"An error was suppressed during disposal"):(t=!0,c),"fail"),g=l(c=>{for(;c=e.pop();)try{var p=c[1]&&c[1].call(c[2]);if(c[0])return Promise.resolve(p).then(g,u=>(a(u),g()))}catch(u){a(u)}if(t)throw r},"next");return g()},"__callDispose");const o=process.env.DEBUG==="true";function T(e){return e&&"source"in e&&Array.isArray(e.source)}l(T,"isSingleCollection");function C(e,r,t=new Set){for(const n of e)if(!n.includes("*")&&h.existsSync(n)){const a=S.resolve(process.cwd(),n);t.has(a)||r.messages.push({type:"dependency",plugin:"postcss-sugarcube",file:a})}else if(n.includes("*")){const a=S.dirname(n),g=S.basename(n);h.existsSync(a)&&r.messages.push({type:"dir-dependency",plugin:"postcss-sugarcube",dir:S.resolve(process.cwd(),a),glob:g})}}l(C,"processTokenSources");function D(e,r){const t=f.findConfigFile();if(t&&r.messages.push({type:"dependency",plugin:"postcss-sugarcube",file:t}),!e.tokens)return;const n=e.output?.css||"./src/styles",a=new Set;if(e.output?.separate?a.add(S.resolve(process.cwd(),`${n}/global/variables/colors.variables.gen.css`)):a.add(S.resolve(process.cwd(),`${n}/global/variables/tokens.variables.gen.css`)),T(e.tokens))C(e.tokens.source,r,a);else for(const[g,c]of Object.entries(e.tokens))c&&"source"in c&&Array.isArray(c.source)&&C(c.source,r,a)}l(D,"registerDependencies");const k=l((e,r,t)=>{const n=t instanceof Error?t.message:String(t);e.warn(`[sugarcube] ${r}${n}`,{plugin:"postcss-sugarcube",word:"error"})},"reportError"),E=l(()=>(console.log("\u{1F3AF} PostCSS Sugarcube plugin is initializing"),{postcssPlugin:"postcss-sugarcube",prepare(e){console.log("\u26A1 PostCSS Sugarcube plugin is preparing...");const r=f.findConfigFile();r&&e.messages.push({type:"dependency",plugin:"postcss-sugarcube",file:r}),e.messages.push({type:"dir-dependency",plugin:"postcss-sugarcube",dir:S.resolve(process.cwd(),"src/design-tokens"),glob:"*.json"});let t=null;const n=l(async()=>{var p=[];try{const d=b(p,new f.Instrumentation);if(o&&d.start("Process Tokens"),!t)throw new Error("Sugarcube config not initialized");o&&d.start("Token Processing Pipeline");const s=await f.loadAndResolveTokens({type:"files",config:t.config}),y=[...s.errors.load,...s.errors.flatten,...s.errors.validation,...s.errors.resolution];return y.length>0&&k(e,`Token processing issues found:
2
+ `,y.map(w=>` - ${w.message}`).join(`
3
+ `)),o&&d.end("Token Processing Pipeline"),o&&d.end("Process Tokens"),{resolved:s.resolved,trees:s.trees}}catch(d){var u=d,i=!0}finally{v(p,u,i)}},"processTokens"),a=l(async p=>{var u=[];try{const s=b(u,new f.Instrumentation);if(o&&s.start("Generate and Write CSS Variables"),!t)throw new Error("Sugarcube config not initialized");o&&s.start("CSS Variables Pipeline");const y=await f.processAndConvertTokens(p.trees,p.resolved,t.config),w=await f.generateCSSVariables(y,t.config);o&&s.end("CSS Variables Pipeline"),o&&s.start("Write CSS Variables to Disk"),await f.writeCSSVariablesToDisk(w),o&&s.end("Write CSS Variables to Disk"),o&&s.end("Generate and Write CSS Variables")}catch(s){var i=s,d=!0}finally{v(u,i,d)}},"generateAndWriteCSSVariables"),g=l(async p=>{var u=[];try{const s=b(u,new f.Instrumentation);if(o&&s.start("Generate and Write Utilities"),!t)throw new Error("Sugarcube config not initialized");o&&s.start("Scan for used classes"),o&&s.end("Scan for used classes"),o&&s.start("Generate Utility CSS"),o&&s.end("Generate Utility CSS"),o&&s.start("Write CSS Utilities to Disk"),o&&s.end("Write CSS Utilities to Disk"),o&&s.end("Generate and Write Utilities")}catch(s){var i=s,d=!0}finally{v(u,i,d)}},"generateAndWriteUtilities"),c=l(async()=>{var p=[];try{const d=b(p,new f.Instrumentation);o&&d.start("Process and Update");try{const s=await n();await a(s),await g(s)}catch(s){k(e,"Sugarcube processing failed",s)}o&&d.end("Process and Update")}catch(d){var u=d,i=!0}finally{v(p,u,i)}},"processAndUpdate");return{async Once(p){if(console.log(" Once called for file:",e.opts.from),!e.opts.from){e.warn("No input file provided to postcss-sugarcube");return}try{const i=p.nodes[0];if(i&&i.type==="comment"&&i.text.includes("AUTOMATICALLY GENERATED FILE"))return;t=await f.loadInternalConfig(),D(t.config,e),await c()}catch(i){k(e,"Sugarcube processing failed",i)}}}}}),"sugarcubePlugin");E.postcss=!0,module.exports=E;
package/dist/index.d.cts CHANGED
@@ -5,6 +5,6 @@ interface PostcssSugarcubeOptions {
5
5
  validateOnly?: boolean;
6
6
  checkSync?: boolean;
7
7
  }
8
- declare const sugarcubePlugin: PluginCreator<PostcssSugarcubeOptions>;
8
+ declare const sugarcubePlugin: PluginCreator<Record<string, unknown>>;
9
9
 
10
10
  export { type PostcssSugarcubeOptions, sugarcubePlugin as default };
package/dist/index.d.mts CHANGED
@@ -5,6 +5,6 @@ interface PostcssSugarcubeOptions {
5
5
  validateOnly?: boolean;
6
6
  checkSync?: boolean;
7
7
  }
8
- declare const sugarcubePlugin: PluginCreator<PostcssSugarcubeOptions>;
8
+ declare const sugarcubePlugin: PluginCreator<Record<string, unknown>>;
9
9
 
10
10
  export { type PostcssSugarcubeOptions, sugarcubePlugin as default };
package/dist/index.mjs CHANGED
@@ -1,3 +1,3 @@
1
- var h=Object.defineProperty;var u=(s,o)=>h(s,"name",{value:o,configurable:!0});var y=(s,o)=>()=>(o||s((o={exports:{}}).exports,o),o.exports);import p from"node:fs";import c from"node:path";import{loadConfig as b,tokensToCSSPipeline as v,getTokenPathsFromConfig as S,writeCSSFilesToDisk as k}from"@sugarcube-org/core";var A=y((N,m)=>{function E(s){return s&&"source"in s&&Array.isArray(s.source)}u(E,"isSingleCollection");function f(s,o,n=new Set){for(const r of s)if(!r.includes("*")&&p.existsSync(r)){const e=c.resolve(process.cwd(),r);n.has(e)||o.messages.push({type:"dependency",plugin:"postcss-sugarcube",file:e})}else if(r.includes("*")){const e=c.dirname(r),t=c.basename(r);p.existsSync(e)&&o.messages.push({type:"dir-dependency",plugin:"postcss-sugarcube",dir:c.resolve(process.cwd(),e),glob:t})}}u(f,"processTokenSources");function P(s,o){if(o.messages.push({type:"dependency",plugin:"postcss-sugarcube",file:c.resolve(process.cwd(),"sugarcube.config.json")}),!s.tokens)return;const n=s.output?.directories?.css||"./src/styles",r=new Set;if(s.output?.css?.separate?r.add(c.resolve(process.cwd(),`${n}/global/variables/colors.variables.css`)):r.add(c.resolve(process.cwd(),`${n}/tokens.css`)),E(s.tokens))f(s.tokens.source,o,r);else for(const[e,t]of Object.entries(s.tokens))t&&"source"in t&&Array.isArray(t.source)&&f(t.source,o,r)}u(P,"registerDependencies");function T(s){const o=s.filter(e=>e.file||e.source?.sourcePath),n=s.filter(e=>!e.file&&(!e.source||!e.source.sourcePath)),r=[];for(const e of o){const t=e.file||e.source?.sourcePath;if(!t)continue;const i=c.relative(process.cwd(),t),a=e.message.replace(t,i);r.push(a)}for(const e of n)r.push(e.message);return r.join(`
2
- - `)}u(T,"formatErrors");let d=0;const g=u((s={})=>({postcssPlugin:"postcss-sugarcube",async Once(o,{result:n}){if(!n.opts.from){n.warn("No input file provided to postcss-sugarcube");return}try{const e=o.nodes[0];if(e&&e.type==="comment"&&e.text.includes("AUTOMATICALLY GENERATED FILE"))return;const t=await b();P(t,n);const i=await v(t),a=[...i.errors.load,...i.errors.flatten,...i.errors.validation,...i.errors.resolution];if(a.length>0){n.warn(`Token validation failed:
3
- - ${T(a)}`,{plugin:"postcss-sugarcube",word:"error"});return}const w=S(t);await k(i.output,!0,w);const l=Date.now();!s.silent&&l-d>1e3&&(n.messages.push({type:"log",plugin:"postcss-sugarcube",text:"\u2728 Generated CSS files from tokens"}),d=l)}catch(e){n.warn(e instanceof Error?e.message:String(e),{plugin:"postcss-sugarcube",word:"error"})}}}),"sugarcubePlugin");g.postcss=!0,m.exports=g});export default A();
1
+ var T=Object.defineProperty;var l=(e,s)=>T(e,"name",{value:s,configurable:!0});var D=(e,s)=>()=>(s||e((s={exports:{}}).exports,s),s.exports);import k from"node:fs";import g from"node:path";import{findConfigFile as h,loadInternalConfig as U,Instrumentation as y,loadAndResolveTokens as _,processAndConvertTokens as W,generateCSSVariables as F,writeCSSVariablesToDisk as G}from"@sugarcube-org/core";var x=D((N,A)=>{var V=l((e,s)=>(s=Symbol[e])?s:Symbol.for("Symbol."+e),"__knownSymbol"),C=l(e=>{throw TypeError(e)},"__typeError"),b=l((e,s,t)=>{if(s!=null){typeof s!="object"&&typeof s!="function"&&C("Object expected");var n,a;n===void 0&&(n=s[V("dispose")]),typeof n!="function"&&C("Object not disposable"),a&&(n=l(function(){try{a.call(this)}catch(f){return Promise.reject(f)}},"dispose")),e.push([t,n,s])}return s},"__using"),w=l((e,s,t)=>{var n=typeof SuppressedError=="function"?SuppressedError:function(c,p,u,i){return i=Error(u),i.name="SuppressedError",i.error=c,i.suppressed=p,i},a=l(c=>s=t?new n(c,s,"An error was suppressed during disposal"):(t=!0,c),"fail"),f=l(c=>{for(;c=e.pop();)try{var p=c[1]&&c[1].call(c[2]);if(c[0])return Promise.resolve(p).then(f,u=>(a(u),f()))}catch(u){a(u)}if(t)throw s},"next");return f()},"__callDispose");const o=process.env.DEBUG==="true";function I(e){return e&&"source"in e&&Array.isArray(e.source)}l(I,"isSingleCollection");function E(e,s,t=new Set){for(const n of e)if(!n.includes("*")&&k.existsSync(n)){const a=g.resolve(process.cwd(),n);t.has(a)||s.messages.push({type:"dependency",plugin:"postcss-sugarcube",file:a})}else if(n.includes("*")){const a=g.dirname(n),f=g.basename(n);k.existsSync(a)&&s.messages.push({type:"dir-dependency",plugin:"postcss-sugarcube",dir:g.resolve(process.cwd(),a),glob:f})}}l(E,"processTokenSources");function j(e,s){const t=h();if(t&&s.messages.push({type:"dependency",plugin:"postcss-sugarcube",file:t}),!e.tokens)return;const n=e.output?.css||"./src/styles",a=new Set;if(e.output?.separate?a.add(g.resolve(process.cwd(),`${n}/global/variables/colors.variables.gen.css`)):a.add(g.resolve(process.cwd(),`${n}/global/variables/tokens.variables.gen.css`)),I(e.tokens))E(e.tokens.source,s,a);else for(const[f,c]of Object.entries(e.tokens))c&&"source"in c&&Array.isArray(c.source)&&E(c.source,s,a)}l(j,"registerDependencies");const m=l((e,s,t)=>{const n=t instanceof Error?t.message:String(t);e.warn(`[sugarcube] ${s}${n}`,{plugin:"postcss-sugarcube",word:"error"})},"reportError"),P=l(()=>(console.log("\u{1F3AF} PostCSS Sugarcube plugin is initializing"),{postcssPlugin:"postcss-sugarcube",prepare(e){console.log("\u26A1 PostCSS Sugarcube plugin is preparing...");const s=h();s&&e.messages.push({type:"dependency",plugin:"postcss-sugarcube",file:s}),e.messages.push({type:"dir-dependency",plugin:"postcss-sugarcube",dir:g.resolve(process.cwd(),"src/design-tokens"),glob:"*.json"});let t=null;const n=l(async()=>{var p=[];try{const d=b(p,new y);if(o&&d.start("Process Tokens"),!t)throw new Error("Sugarcube config not initialized");o&&d.start("Token Processing Pipeline");const r=await _({type:"files",config:t.config}),S=[...r.errors.load,...r.errors.flatten,...r.errors.validation,...r.errors.resolution];return S.length>0&&m(e,`Token processing issues found:
2
+ `,S.map(v=>` - ${v.message}`).join(`
3
+ `)),o&&d.end("Token Processing Pipeline"),o&&d.end("Process Tokens"),{resolved:r.resolved,trees:r.trees}}catch(d){var u=d,i=!0}finally{w(p,u,i)}},"processTokens"),a=l(async p=>{var u=[];try{const r=b(u,new y);if(o&&r.start("Generate and Write CSS Variables"),!t)throw new Error("Sugarcube config not initialized");o&&r.start("CSS Variables Pipeline");const S=await W(p.trees,p.resolved,t.config),v=await F(S,t.config);o&&r.end("CSS Variables Pipeline"),o&&r.start("Write CSS Variables to Disk"),await G(v),o&&r.end("Write CSS Variables to Disk"),o&&r.end("Generate and Write CSS Variables")}catch(r){var i=r,d=!0}finally{w(u,i,d)}},"generateAndWriteCSSVariables"),f=l(async p=>{var u=[];try{const r=b(u,new y);if(o&&r.start("Generate and Write Utilities"),!t)throw new Error("Sugarcube config not initialized");o&&r.start("Scan for used classes"),o&&r.end("Scan for used classes"),o&&r.start("Generate Utility CSS"),o&&r.end("Generate Utility CSS"),o&&r.start("Write CSS Utilities to Disk"),o&&r.end("Write CSS Utilities to Disk"),o&&r.end("Generate and Write Utilities")}catch(r){var i=r,d=!0}finally{w(u,i,d)}},"generateAndWriteUtilities"),c=l(async()=>{var p=[];try{const d=b(p,new y);o&&d.start("Process and Update");try{const r=await n();await a(r),await f(r)}catch(r){m(e,"Sugarcube processing failed",r)}o&&d.end("Process and Update")}catch(d){var u=d,i=!0}finally{w(p,u,i)}},"processAndUpdate");return{async Once(p){if(console.log(" Once called for file:",e.opts.from),!e.opts.from){e.warn("No input file provided to postcss-sugarcube");return}try{const i=p.nodes[0];if(i&&i.type==="comment"&&i.text.includes("AUTOMATICALLY GENERATED FILE"))return;t=await U(),j(t.config,e),await c()}catch(i){m(e,"Sugarcube processing failed",i)}}}}}),"sugarcubePlugin");P.postcss=!0,A.exports=P});export default x();
package/package.json CHANGED
@@ -1,6 +1,17 @@
1
1
  {
2
2
  "name": "@sugarcube-org/postcss",
3
- "version": "0.0.1-alpha.2",
3
+ "version": "0.0.1-alpha.4",
4
+ "publishConfig": {
5
+ "access": "public",
6
+ "provenance": false
7
+ },
8
+ "description": "PostCSS plugin for sugarcube",
9
+ "license": "SEE LICENSE IN LICENSE.md",
10
+ "author": "Mark Tomlinson",
11
+ "repository": {
12
+ "type": "git",
13
+ "url": "https://github.com/sugarcube-org/sugarcube"
14
+ },
4
15
  "exports": {
5
16
  "require": {
6
17
  "types": "./dist/index.d.cts",
@@ -12,21 +23,23 @@
12
23
  }
13
24
  },
14
25
  "files": [
15
- "dist/"
26
+ "dist/",
27
+ "README.md",
28
+ "LICENSE.md"
16
29
  ],
17
30
  "dependencies": {
18
- "@sugarcube-org/core": "0.0.1-alpha.5"
31
+ "@sugarcube-org/core": "0.0.1-alpha.7"
19
32
  },
20
33
  "peerDependencies": {
21
34
  "postcss": "^8.4.0"
22
35
  },
23
36
  "devDependencies": {
24
- "pkgroll": "^2.5.1",
25
- "postcss": "^8.4.31",
26
- "tsx": "^4.19.2"
37
+ "pkgroll": "2.5.1",
38
+ "postcss": "8.4.31",
39
+ "tsx": "4.19.2"
27
40
  },
28
41
  "scripts": {
29
- "build": "pkgroll --minify --clean-dist",
42
+ "build": "pkgroll --minify",
30
43
  "dev": "pkgroll --watch",
31
44
  "type-check": "tsc --noEmit"
32
45
  }