@sugarcube-org/core 0.0.1-alpha.11 → 0.0.1-alpha.12

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.
Files changed (2) hide show
  1. package/dist/index.js +1 -1
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -34,7 +34,7 @@ ${t.map(n=>` - ${n}`).join(`
34
34
  `).replace(/\r/g,`
35
35
  `).trim()}s(Z,"normalizeContent");function Yr(e){return Gr+e}s(Yr,"addWarningBanner");async function Hr(e){for(const t of e){const n=Yr(t.css);try{await Ee(re(t.path),{recursive:!0});let r=!0;if(v(t.path))try{const o=await w(t.path,"utf-8");Z(o)===Z(n)&&(r=!1)}catch{}r&&await ge(t.path,n,"utf-8")}catch(r){throw new Error(`Failed to write CSS file ${t.path}: ${r instanceof Error?r.message:"Unknown error"}`)}}return e}s(Hr,"writeCSSVariablesToDisk");async function Kr(e){for(const t of e){const n=Br+t.css;try{await Ee(re(t.path),{recursive:!0});let r=!0;if(v(t.path))try{const o=await w(t.path,"utf-8");Z(o)===Z(n)&&(r=!1)}catch{}r&&await ge(t.path,n,"utf-8")}catch(r){throw new Error(`Failed to write utility CSS file ${t.path}: ${r instanceof Error?r.message:"Unknown error"}`)}}return e}s(Kr,"writeCSSUtilitiesToDisk");const tt=l.object({min:l.number(),max:l.number()}),nt=l.object({source:l.string(),directions:l.union([l.enum(["top","right","bottom","left","x","y","full","all"]),l.array(l.enum(["top","right","bottom","left","x","y","full","all"]))]).optional(),prefix:l.string().optional(),stripDuplicates:l.boolean().optional()}),rt=l.union([nt,l.array(nt)]),ot=l.object({resolver:l.string().optional(),transforms:l.object({fluid:tt.optional(),colorFallbackStrategy:l.enum(["native","polyfill"]).optional()}).optional(),output:l.object({css:l.string().optional(),components:l.string().optional(),themeAttribute:l.string().optional(),defaultContext:l.string().optional()}).optional(),utilities:l.record(l.string(),rt).optional()}),st=l.object({resolver:l.string().optional(),transforms:l.object({fluid:tt,colorFallbackStrategy:l.enum(["native","polyfill"])}),output:l.object({css:l.string(),components:l.string().optional(),themeAttribute:l.string(),defaultContext:l.string().optional()}),utilities:l.record(l.string(),rt).optional()}),b={output:{css:"src/styles",components:"src/components/ui",themeAttribute:"data-theme"},transforms:{fluid:{min:320,max:1200},colorFallbackStrategy:"native"}},qr="default",zr="default";function le(e){const t={resolver:e.resolver,transforms:{fluid:e.transforms?.fluid??b.transforms.fluid,colorFallbackStrategy:e.transforms?.colorFallbackStrategy??b.transforms.colorFallbackStrategy},output:{css:e.output?.css??b.output.css,themeAttribute:e.output?.themeAttribute??b.output.themeAttribute,defaultContext:e.output?.defaultContext}};return(e.output?.components!==void 0||b.output.components!==void 0)&&(t.output.components=e.output?.components??b.output.components),e.utilities&&(t.utilities=e.utilities),t}s(le,"fillDefaults");function Q(e){const t=ot.safeParse(e);if(!t.success){const n=t.error.errors.map(r=>{const o=r.path.join(".");return f.CONFIG.INVALID_CONFIG(o||"root",r.message)});throw new Error(n.join(`
36
36
  `))}return t.data}s(Q,"validateUserConfig");function pe(e){const t=st.safeParse(e);if(!t.success){const n=t.error.errors.map(r=>{const o=r.path.join(".");return f.CONFIG.INVALID_CONFIG(o||"root",r.message)});throw new Error(n.join(`
37
- `))}return t.data}s(pe,"validateInternalConfig");function it(e){const t=Q(e),n=le(t);return pe(n)}s(it,"validateConfig");function Jr(e){try{const t=JSON.parse(e);return it(t)}catch(t){throw t instanceof SyntaxError?new Error(f.CONFIG.INVALID_JSON(t.message)):t}}s(Jr,"parseAndValidateConfig");function de(e="sugarcube.config"){const t=[".ts",".js"];for(const n of t){const r=R(process.cwd(),`${e}${n}`);if(v(r))return r}return null}s(de,"findConfigFile");function Xr(e="sugarcube.config"){return de(e)!==null}s(Xr,"configFileExists");async function at(e){try{await import("tsx");const t=yt(e).href,r=await new Function("url","return import(url)")(t);if(r&&typeof r=="object"&&"default"in r)return r.default;throw new Error(f.CONFIG.INVALID_CONFIG("root","Config file must export a default object"))}catch(t){throw t instanceof Error?new Error(f.CONFIG.INVALID_CONFIG("root",t.message)):t}}s(at,"loadTSConfig");async function ct(e){if(e.endsWith(".ts")||e.endsWith(".js"))return await at(e);const n=await k.readFile(e,"utf-8");return JSON.parse(n)}s(ct,"loadConfigFile");function ut(e){if(e)return R(process.cwd(),e);const t=de();if(!t)throw new Error(f.CONFIG.FILE_NOT_FOUND(P));return t}s(ut,"resolveConfigPath");async function Zr(e){const t=ut(e);try{const n=await ct(t);return{config:Q(n),configPath:t}}catch(n){throw n instanceof Error&&"code"in n&&n.code==="ENOENT"?new Error(f.CONFIG.FILE_NOT_FOUND(t)):n instanceof SyntaxError?new Error(f.CONFIG.INVALID_JSON(n.message)):n}}s(Zr,"loadUserConfig");async function Qr(e){const t=ut(e);try{const n=await ct(t),r=Q(n),o=le(r);return{config:pe(o),configPath:t}}catch(n){throw n instanceof Error&&"code"in n&&n.code==="ENOENT"?new Error(f.CONFIG.FILE_NOT_FOUND(t)):n instanceof SyntaxError?new Error(f.CONFIG.INVALID_JSON(n.message)):n}}s(Qr,"loadInternalConfig");class ft extends Map{static{s(this,"DefaultMap")}constructor(t){super(),this.factory=t}get(t){let n=super.get(t);return n===void 0&&(n=this.factory(t,this),this.set(t,n)),n}}const eo=process.env.DEBUG==="true";class to{static{s(this,"Instrumentation")}constructor(t=n=>void process.stderr.write(`${n}
37
+ `))}return t.data}s(pe,"validateInternalConfig");function it(e){const t=Q(e),n=le(t);return pe(n)}s(it,"validateConfig");function Jr(e){try{const t=JSON.parse(e);return it(t)}catch(t){throw t instanceof SyntaxError?new Error(f.CONFIG.INVALID_JSON(t.message)):t}}s(Jr,"parseAndValidateConfig");function de(e="sugarcube.config"){const t=[".ts",".js"],n=process.cwd();for(const r of t){const o=R(n,`${e}${r}`);if(v(o))return o}return null}s(de,"findConfigFile");function Xr(e="sugarcube.config"){return de(e)!==null}s(Xr,"configFileExists");async function at(e){try{typeof globalThis.Bun<"u"||await import("tsx");const n=yt(e).href,o=await new Function("url","return import(url)")(n);if(o&&typeof o=="object"&&"default"in o)return o.default;throw new Error(f.CONFIG.INVALID_CONFIG("root","Config file must export a default object"))}catch(t){throw t instanceof Error?new Error(f.CONFIG.INVALID_CONFIG("root",t.message)):t}}s(at,"loadTSConfig");async function ct(e){if(e.endsWith(".ts")||e.endsWith(".js"))return await at(e);const n=await k.readFile(e,"utf-8");return JSON.parse(n)}s(ct,"loadConfigFile");function ut(e){if(e)return R(process.cwd(),e);const t=de();if(!t)throw new Error(f.CONFIG.FILE_NOT_FOUND(P));return t}s(ut,"resolveConfigPath");async function Zr(e){const t=ut(e);try{const n=await ct(t);return{config:Q(n),configPath:t}}catch(n){throw n instanceof Error&&"code"in n&&n.code==="ENOENT"?new Error(f.CONFIG.FILE_NOT_FOUND(t)):n instanceof SyntaxError?new Error(f.CONFIG.INVALID_JSON(n.message)):n}}s(Zr,"loadUserConfig");async function Qr(e){const t=ut(e);try{const n=await ct(t),r=Q(n),o=le(r);return{config:pe(o),configPath:t}}catch(n){throw n instanceof Error&&"code"in n&&n.code==="ENOENT"?new Error(f.CONFIG.FILE_NOT_FOUND(t)):n instanceof SyntaxError?new Error(f.CONFIG.INVALID_JSON(n.message)):n}}s(Qr,"loadInternalConfig");class ft extends Map{static{s(this,"DefaultMap")}constructor(t){super(),this.factory=t}get(t){let n=super.get(t);return n===void 0&&(n=this.factory(t,this),this.set(t,n)),n}}const eo=process.env.DEBUG==="true";class to{static{s(this,"Instrumentation")}constructor(t=n=>void process.stderr.write(`${n}
38
38
  `)){this.defaultFlush=t}#n=new ft(()=>({value:0}));#t=new ft(()=>({value:0n}));#e=[];hit(t){this.#n.get(t).value++}start(t){const n=this.#e.map(o=>o.label).join("//"),r=`${n}${n.length===0?"":"//"}${t}`;this.#n.get(r).value++,this.#t.get(r),this.#e.push({id:r,label:t,namespace:n,value:process.hrtime.bigint()})}end(t){const n=process.hrtime.bigint();if(this.#e.length===0)throw new Error("Timer stack is empty");const r=this.#e.length-1,o=this.#e[r];if(!o)throw new Error("Timer stack is corrupted");if(o.label!==t)throw new Error(`Mismatched timer label: ${t}`);const i=this.#e.pop();if(!i)throw new Error("Timer stack is empty");const a=n-i.value;this.#t.get(i.id).value+=a}report(t=this.defaultFlush){const n=[];let r=!1;for(let o=this.#e.length-1;o>=0;o--){const i=this.#e[o];i&&this.end(i.label)}for(const[o,{value:i}]of this.#n.entries()){if(this.#t.has(o))continue;n.length===0&&(r=!0,n.push("Hits:"));const a=o.split("//").length;n.push(`${" ".repeat(a)}${o} \xD7 ${i}`)}if(this.#t.size>0){r&&n.push(`
39
39
  Timers:`);for(const[o,{value:i}]of this.#t){const a=o.split("//").length,c=`${(Number(i)/1e6).toFixed(2)}ms`;n.push(`${" ".repeat(a-1)}${o.split("//").pop()} [${c}] ${this.#n.get(o).value===1?"":`\xD7 ${this.#n.get(o).value}`}`.trimEnd())}}t(`
40
40
  ${n.join(`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sugarcube-org/core",
3
- "version": "0.0.1-alpha.11",
3
+ "version": "0.0.1-alpha.12",
4
4
  "publishConfig": {
5
5
  "access": "public",
6
6
  "provenance": false