@proyecto-viviana/ui 0.4.0 → 0.5.0
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/styles.css +0 -3
- package/dist/vite.d.ts +1 -0
- package/dist/vite.d.ts.map +1 -1
- package/dist/vite.js +9 -1
- package/dist/vite.js.map +1 -1
- package/dist/vite.jsx +9 -1
- package/dist/vite.jsx.map +1 -1
- package/dist/viviana-tokens.css +240 -171
- package/package.json +3 -57
- package/src/vite.ts +13 -1
- package/src/viviana-tokens.css +240 -171
- package/dist/CalendarCard.d.ts +0 -2
- package/dist/CalendarCard.d.ts.map +0 -1
- package/dist/CalendarCard.js +0 -97
- package/dist/CalendarCard.js.map +0 -1
- package/dist/CalendarCard.jsx +0 -51
- package/dist/CalendarCard.jsx.map +0 -1
- package/dist/Chip.d.ts +0 -2
- package/dist/Chip.d.ts.map +0 -1
- package/dist/Chip.js +0 -2
- package/dist/Chip.jsx +0 -2
- package/dist/Conversation.d.ts +0 -2
- package/dist/Conversation.d.ts.map +0 -1
- package/dist/Conversation.js +0 -177
- package/dist/Conversation.js.map +0 -1
- package/dist/Conversation.jsx +0 -107
- package/dist/Conversation.jsx.map +0 -1
- package/dist/EventCard.d.ts +0 -2
- package/dist/EventCard.d.ts.map +0 -1
- package/dist/EventCard.js +0 -173
- package/dist/EventCard.js.map +0 -1
- package/dist/EventCard.jsx +0 -96
- package/dist/EventCard.jsx.map +0 -1
- package/dist/Logo.d.ts +0 -2
- package/dist/Logo.d.ts.map +0 -1
- package/dist/Logo.js +0 -116
- package/dist/Logo.js.map +0 -1
- package/dist/Logo.jsx +0 -101
- package/dist/Logo.jsx.map +0 -1
- package/dist/PageLayout.d.ts +0 -2
- package/dist/PageLayout.d.ts.map +0 -1
- package/dist/PageLayout.js +0 -31
- package/dist/PageLayout.js.map +0 -1
- package/dist/PageLayout.jsx +0 -23
- package/dist/PageLayout.jsx.map +0 -1
- package/dist/ProfileCard.d.ts +0 -2
- package/dist/ProfileCard.d.ts.map +0 -1
- package/dist/ProfileCard.js +0 -78
- package/dist/ProfileCard.js.map +0 -1
- package/dist/ProfileCard.jsx +0 -53
- package/dist/ProfileCard.jsx.map +0 -1
- package/dist/ProjectCard.d.ts +0 -2
- package/dist/ProjectCard.d.ts.map +0 -1
- package/dist/ProjectCard.js +0 -164
- package/dist/ProjectCard.js.map +0 -1
- package/dist/ProjectCard.jsx +0 -133
- package/dist/ProjectCard.jsx.map +0 -1
- package/dist/TimelineItem.d.ts +0 -2
- package/dist/TimelineItem.d.ts.map +0 -1
- package/dist/TimelineItem.js +0 -137
- package/dist/TimelineItem.js.map +0 -1
- package/dist/TimelineItem.jsx +0 -70
- package/dist/TimelineItem.jsx.map +0 -1
- package/dist/chip2.js +0 -82
- package/dist/chip2.js.map +0 -1
- package/dist/chip2.jsx +0 -68
- package/dist/chip2.jsx.map +0 -1
- package/dist/custom/calendar-card/index.d.ts +0 -12
- package/dist/custom/calendar-card/index.d.ts.map +0 -1
- package/dist/custom/chip/index.d.ts +0 -16
- package/dist/custom/chip/index.d.ts.map +0 -1
- package/dist/custom/conversation/index.d.ts +0 -32
- package/dist/custom/conversation/index.d.ts.map +0 -1
- package/dist/custom/event-card/index.d.ts +0 -30
- package/dist/custom/event-card/index.d.ts.map +0 -1
- package/dist/custom/header/index.d.ts +0 -12
- package/dist/custom/header/index.d.ts.map +0 -1
- package/dist/custom/lateral-nav/index.d.ts +0 -32
- package/dist/custom/lateral-nav/index.d.ts.map +0 -1
- package/dist/custom/logo/index.d.ts +0 -11
- package/dist/custom/logo/index.d.ts.map +0 -1
- package/dist/custom/nav-header/index.d.ts +0 -13
- package/dist/custom/nav-header/index.d.ts.map +0 -1
- package/dist/custom/page-layout/index.d.ts +0 -7
- package/dist/custom/page-layout/index.d.ts.map +0 -1
- package/dist/custom/profile-card/index.d.ts +0 -16
- package/dist/custom/profile-card/index.d.ts.map +0 -1
- package/dist/custom/project-card/index.d.ts +0 -13
- package/dist/custom/project-card/index.d.ts.map +0 -1
- package/dist/custom/timeline-item/index.d.ts +0 -28
- package/dist/custom/timeline-item/index.d.ts.map +0 -1
- package/src/CalendarCard.ts +0 -1
- package/src/Chip.ts +0 -1
- package/src/Conversation.ts +0 -1
- package/src/EventCard.ts +0 -1
- package/src/Logo.ts +0 -1
- package/src/PageLayout.ts +0 -1
- package/src/ProfileCard.ts +0 -1
- package/src/ProjectCard.ts +0 -1
- package/src/TimelineItem.ts +0 -1
- package/src/custom/calendar-card/index.tsx +0 -115
- package/src/custom/chip/index.tsx +0 -78
- package/src/custom/conversation/index.tsx +0 -199
- package/src/custom/event-card/index.tsx +0 -232
- package/src/custom/header/index.tsx +0 -64
- package/src/custom/lateral-nav/index.tsx +0 -134
- package/src/custom/logo/index.tsx +0 -53
- package/src/custom/nav-header/index.tsx +0 -98
- package/src/custom/page-layout/index.tsx +0 -33
- package/src/custom/profile-card/index.tsx +0 -114
- package/src/custom/project-card/index.tsx +0 -76
- package/src/custom/timeline-item/index.tsx +0 -140
package/dist/styles.css
CHANGED
|
@@ -4,6 +4,3 @@
|
|
|
4
4
|
isn't reliably followed when this package is consumed through its export map,
|
|
5
5
|
so we inline it (mirrors solid-spectrum, whose styles.css *is* its macro CSS). */
|
|
6
6
|
@import "@proyecto-viviana/solid-spectrum/styles.css";
|
|
7
|
-
|
|
8
|
-
/* viviana custom components — extracted S2 macro CSS (inlined) */
|
|
9
|
-
@layer _.a{.LQAax0d13{max-width:calc(31.25rem * var(--s2-scale))}.ZKniM13{width:calc(5rem * var(--s2-scale))}.FKniM13{height:calc(5rem * var(--s2-scale))}.ij1j4Pd13{border-color:var(--color-accent)}._wb13{flex-wrap:wrap}._Ce13{justify-content:space-between}.Zm13{width:calc(1.25rem * var(--s2-scale))}.Fn13{height:calc(1.25rem * var(--s2-scale))}._Cg13{justify-content:start}._Cb13{justify-content:end}.Ua13{row-gap:.125rem}.qa13{column-gap:.125rem}.LbmOfn13{max-width:70%}.gg0eWE13{background-color:var(--color-bg-300)}.pcoywsd13{color:var(--color-text-muted)}.pg0eWE13{color:var(--color-bg-300)}._Pc13{position:relative}._Pa13{position:absolute}.WJ13{top:8px}._zI13{inset-inline-end:8px}.ZC13{width:calc(2rem * var(--s2-scale))}.Fx13{height:calc(2rem * var(--s2-scale))}.fu4qurc13{aspect-ratio:16/9}.-_6BNtrc-g13{--fs:pow(1.125, 4)}.Tt13{padding-top:8px}.Qt13{padding-bottom:8px}.St13{padding-inline-start:8px}.Rt13{padding-inline-end:8px}._Wd13{text-align:start}.ry13{cursor:pointer}._je13{border-style:none}.ZF13{width:calc(3rem * var(--s2-scale))}.Fz13{height:calc(3rem * var(--s2-scale))}._va13{flex-shrink:0}.ob13{border-start-start-radius:.5rem}.nb13{border-start-end-radius:.5rem}.kb13{border-end-start-radius:.5rem}.jb13{border-end-end-radius:.5rem}._Hb13{object-fit:cover}.xc13{font-weight:500}.ea13{align-items:baseline}.uk13{font-family:var(--s2-font-family-sans,adobe-clean-spectrum-vf), adobe-clean-variable, adobe-clean, ui-sans-serif, system-ui, sans-serif;font-family:var(--s2-font-family-sans,adobe-clean-spectrum-vf), adobe-clean-variable, adobe-clean, ui-sans-serif, system-ui, sans-serif;font-family:var(--s2-font-family-sans,adobe-clean-spectrum-vf), adobe-clean-variable, adobe-clean, ui-sans-serif, system-ui, sans-serif;font-family:var(--s2-font-family-sans,adobe-clean-spectrum-vf), adobe-clean-variable, adobe-clean, ui-sans-serif, system-ui, sans-serif}.-_6BNtrc-KaY1Ce13{--fs:pow(1.125, 5)}.xf13{font-weight:900}._Fd13{line-height:round(1em * (1.15 + (1 - ((min(32, var(--s2-font-size-base,14) * var(--fs)) - 10)) / 22) * .15), 2px);line-height:round(1em * (1.15 + (1 - ((min(32, var(--s2-font-size-base,14) * var(--fs)) - 10)) / 22) * .15), 2px);line-height:round(1em * (1.15 + (1 - ((min(32, var(--s2-font-size-base,14) * var(--fs)) - 10)) / 22) * .15), 2px);line-height:round(1em * (1.15 + (1 - ((min(32, var(--s2-font-size-base,14) * var(--fs)) - 10)) / 22) * .15), 2px)}.po13{color:light-dark(#131313,#f2f2f2)}.Mc13{min-height:100vh}.g318zje13{background-color:var(--color-background)}.pO550xe13{color:var(--color-text)}.Tr13{padding-top:64px}._nLeasBb13{box-shadow:0 4px 12px light-dark(#00000014,#0000003d),0 2px 6px light-dark(#0000000a,#0000001f),0 0 2px light-dark(#0000001f,#0000005c)}.ed13{align-items:start}.Ub13{row-gap:.25rem}.qb13{column-gap:.25rem}._ub13{flex-grow:1}.Na13{min-width:0}.Ul13{row-gap:1rem}.ql13{column-gap:1rem}.oc13{border-start-start-radius:.625rem}.nc13{border-start-end-radius:.625rem}.kc13{border-end-start-radius:.625rem}.jc13{border-end-end-radius:.625rem}.izfTM513{border-color:var(--color-border)}._Xa13{text-decoration:none}.Te13{padding-top:12px}.Tf13{padding-top:16px}.Qe13{padding-bottom:12px}.Qf13{padding-bottom:16px}.Sf13{padding-inline-start:16px}.Rf13{padding-inline-end:16px}._Ib13{opacity:1}._IqmMfn13{opacity:.5}.fa13{aspect-ratio:1}._Ha13{object-fit:contain}.oa13{border-start-start-radius:.25rem}.na13{border-start-end-radius:.25rem}.ka13{border-end-start-radius:.25rem}.ja13{border-end-end-radius:.25rem}.Za13{width:100%}.pt13{color:light-dark(#292929,#dbdbdb)}.uk13{font-family:var(--s2-font-family-sans,adobe-clean-spectrum-vf), adobe-clean-variable, adobe-clean, ui-sans-serif, system-ui, sans-serif;font-family:var(--s2-font-family-sans,adobe-clean-spectrum-vf), adobe-clean-variable, adobe-clean, ui-sans-serif, system-ui, sans-serif;font-family:var(--s2-font-family-sans,adobe-clean-spectrum-vf), adobe-clean-variable, adobe-clean, ui-sans-serif, system-ui, sans-serif}.-_6BNtrc-d13{--fs:pow(1.125, 1)}._Fd13{line-height:round(1em * (1.15 + (1 - ((min(32, var(--s2-font-size-base,14) * var(--fs)) - 10)) / 22) * .15), 2px);line-height:round(1em * (1.15 + (1 - ((min(32, var(--s2-font-size-base,14) * var(--fs)) - 10)) / 22) * .15), 2px);line-height:round(1em * (1.15 + (1 - ((min(32, var(--s2-font-size-base,14) * var(--fs)) - 10)) / 22) * .15), 2px)}._ta13{flex-direction:column}.Ui13{row-gap:1.25rem}.qi13{column-gap:1.25rem}.Tg13{padding-top:20px}.Qg13{padding-bottom:20px}.Sg13{padding-inline-start:20px}.Rg13{padding-inline-end:20px}.oe13{border-start-start-radius:1rem}.ne13{border-start-end-radius:1rem}.ke13{border-end-start-radius:1rem}.je13{border-end-end-radius:1rem}._kb13{border-top-width:1px}.hb13{border-bottom-width:1px}.mb13{border-inline-start-width:1px}.lb13{border-inline-end-width:1px}.iJJKqyb13{border-color:var(--color-primary-700)}.gDE5VE13{background-color:var(--color-bg-200)}.Ug13{row-gap:.75rem}.qg13{column-gap:.75rem}._Wa13{text-align:center}.-_6BNtrc-c13{--fs:pow(1.125, 0)}.sh13{display:inline-flex}.eb13{align-items:center}._Ca13{justify-content:center}.qc13{column-gap:.428571em}.Mg13{min-height:calc(1.5rem * var(--s2-scale))}.ZJ13{width:fit-content}.Se13{padding-inline-start:12px}.Re13{padding-inline-end:12px}.og13{border-start-start-radius:9999px}.ng13{border-start-end-radius:9999px}.kg13{border-end-start-radius:9999px}.jg13{border-end-end-radius:9999px}._jf13{border-style:solid}._kc13{border-top-width:2px}.hc13{border-bottom-width:2px}.mc13{border-inline-start-width:2px}.lc13{border-inline-end-width:2px}.pTloWE13{color:var(--color-bg-400)}.pAZZpyb13{color:var(--color-primary-200)}.iA13{border-color:#0000}.i6nBqyb13{border-color:var(--color-primary-600)}.gJJKqyb13{background-color:var(--color-primary-700)}.g0iWVE13{background-color:var(--color-bg-100)}.gj1j4Pd13{background-color:var(--color-accent)}.g913{background-color:#0000}.-_6BNtrc-f13{--fs:pow(1.125, 3)}.xe13{font-weight:800}.pXDQpyb13{color:var(--color-primary-100)}.xd13{font-weight:700}.pj1j4Pd13{color:var(--color-accent)}.uk13{font-family:var(--s2-font-family-sans,adobe-clean-spectrum-vf), adobe-clean-variable, adobe-clean, ui-sans-serif, system-ui, sans-serif}.-_6BNtrc-b13{--fs:pow(1.125, -1)}.vx13{font-size:round(var(--s2-font-size-base,14) * var(--fs) / 16 * 1rem, 1px)}.xb13{font-weight:400}._xa13{font-synthesis-weight:none}._Fd13{line-height:round(1em * (1.15 + (1 - ((min(32, var(--s2-font-size-base,14) * var(--fs)) - 10)) / 22) * .15), 2px)}.pxeCuqc13{color:var(--color-text-secondary)}._Nc13{overflow-x:hidden}.Pc13{overflow-y:hidden}._Yb13{text-overflow:ellipsis}._7c13{white-space:nowrap}.sd13{display:flex}.Ue13{row-gap:.5rem}.qe13{column-gap:.5rem}}@layer _.b{.xfd13:lang(ja,ko,zh,zh-Hant,zh-Hans){font-weight:700}._xfa13:lang(ja,ko,zh,zh-Hant,zh-Hans){font-synthesis-weight:none}.xX0cczbd13:lang(ja,ko,zh){font-weight:700}.xX0cczbc13:lang(ja,ko,zh){font-weight:500}._xX0cczba13:lang(ja,ko,zh){font-synthesis-weight:none}.ucJ9TBTb13:lang(ar){font-family:adobe-clean-arabic,myriad-arabic,ui-sans-serif,system-ui,sans-serif}._FnuYUweb13:lang(ja,ko,zh,zh-Hant,zh-Hans,zh-CN,zh-SG){line-height:1.5}}@layer _.c{.xfX0cczbc13:lang(ja,ko,zh):lang(ja,ko,zh,zh-Hant,zh-Hans){font-weight:500}._xfX0cczba13:lang(ja,ko,zh):lang(ja,ko,zh,zh-Hant,zh-Hans){font-synthesis-weight:none}.xfe13:lang(ja,ko,zh,zh-Hant,zh-Hans){font-weight:800}._xfa13:lang(ja,ko,zh,zh-Hant,zh-Hans){font-synthesis-weight:none}.ud3Euai13:lang(he){font-family:adobe-clean-hebrew,myriad-hebrew,ui-sans-serif,system-ui,sans-serif}}@layer _.d{.xfX0cczbd13:lang(ja,ko,zh):lang(ja,ko,zh,zh-Hant,zh-Hans){font-weight:700}._xfX0cczba13:lang(ja,ko,zh):lang(ja,ko,zh,zh-Hant,zh-Hans){font-synthesis-weight:none}.uea13:lang(ja){font-family:adobe-clean-han-japanese,Hiragino Kaku Gothic ProN,ヒラギノ角ゴ ProN W3,Osaka,YuGothic,Yu Gothic,メイリオ,Meiryo,MS Pゴシック,MS PGothic,sans-serif}}@layer _.e{.ugb13:lang(ko){font-family:adobe-clean-han-korean,source-han-korean,Malgun Gothic,Apple Gothic,sans-serif}}@layer _.f{.uhd13:lang(zh){font-family:adobe-clean-han-traditional,source-han-traditional,MingLiu,Heiti TC Light,sans-serif}}@layer _.g{.uje13:lang(zh-hant){font-family:adobe-clean-han-traditional,source-han-traditional,MingLiu,Microsoft JhengHei UI,Microsoft JhengHei,Heiti TC Light,sans-serif}}@layer _.h{.u2NhKxcl13:lang(zh-HK){font-family:adobe-clean-han-hong-kong,source-han-hong-kong,MingLiu,Microsoft JhengHei UI,Microsoft JhengHei,Heiti TC Light,sans-serif}}@layer _.i{.uic13:lang(zh-Hans,zh-CN,zh-SG){font-family:adobe-clean-han-simplified-c,source-han-simplified-c,SimSun,Heiti SC Light,sans-serif}}@layer _.b.s{@media not ((hover:hover) and (pointer:fine)){.qsd13{column-gap:.470588em}}}
|
package/dist/vite.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
interface MacroPlugin {
|
|
2
2
|
name?: string;
|
|
3
|
+
transformInclude?: (id: string) => boolean | void;
|
|
3
4
|
transform?: (this: unknown, code: string, id: string) => unknown;
|
|
4
5
|
resolveId?: (this: unknown, id: string, importer?: string, options?: object) => unknown;
|
|
5
6
|
loadInclude?: (id: string) => boolean | void;
|
package/dist/vite.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vite.d.ts","sourceRoot":"","sources":["../src/vite.ts"],"names":[],"mappings":"AA8CA,UAAU,WAAW;IACnB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,EAA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
|
|
|
2
2
|
//#region src/vite.ts
|
|
3
3
|
const macroCssIdPattern = /^macro-[a-f0-9]+\.css$/;
|
|
4
4
|
const macroCssImportPattern = /import\s+["']macro-[a-f0-9]+\.css["'];\n?/g;
|
|
5
|
+
function getMacroSourceFilePath(id) {
|
|
6
|
+
const queryIndex = id.indexOf("?");
|
|
7
|
+
if (queryIndex === -1 || !/^\?tsr-split=[^&#]+(?:#.*)?$/.test(id.slice(queryIndex))) return id;
|
|
8
|
+
return id.slice(0, queryIndex);
|
|
9
|
+
}
|
|
5
10
|
function getMacroCssFileName(id) {
|
|
6
11
|
const fileName = id.split("/").pop();
|
|
7
12
|
return fileName && macroCssIdPattern.test(fileName) ? fileName : null;
|
|
@@ -32,8 +37,11 @@ function vivianaMacros() {
|
|
|
32
37
|
};
|
|
33
38
|
return {
|
|
34
39
|
...plugin,
|
|
40
|
+
transformInclude(id) {
|
|
41
|
+
return plugin.transformInclude?.(getMacroSourceFilePath(id)) ?? false;
|
|
42
|
+
},
|
|
35
43
|
async transform(code, id) {
|
|
36
|
-
const result = await plugin.transform?.call(this, code, id);
|
|
44
|
+
const result = await plugin.transform?.call(this, code, getMacroSourceFilePath(id));
|
|
37
45
|
const transformedCode = typeof result === "string" ? result : result && typeof result === "object" && "code" in result ? String(result.code) : "";
|
|
38
46
|
for (const match of transformedCode.matchAll(/import\s+["'](macro-[a-f0-9]+\.css)["'];/g)) {
|
|
39
47
|
const content = await plugin.load?.call(this, match[1]);
|
package/dist/vite.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vite.js","names":[],"sources":["../src/vite.ts"],"sourcesContent":["// The supported Vite macro preset for apps that author their own `style()` calls\n// against `@proyecto-viviana/ui/style`.\n//\n// Consuming the *pre-built* components needs no macro plugin — their style()\n// calls are already expanded in the published build. But an app that writes its\n// own macro calls must run the S2 style() macro at its own build. The bare\n// `unplugin-parcel-macros` plugin isn't enough under rolldown-vite: the macro\n// emits `import \"macro-<hash>.css\"` statements plus matching virtual CSS modules,\n// and rolldown doesn't honor the plugin's resolveId/load for those virtual ids\n// (\"failed to resolve import macro-….css\"). So we wrap it: cache each macro CSS\n// body as it's transformed, resolve/serve those ids ourselves (with a `.css`\n// extension so Vite's CSS pipeline bundles them), then strip the now-redundant JS\n// import. This is the single source of truth for that wrapper — apps import it\n// instead of copying it into their config.\n//\n// `unplugin-parcel-macros` is a peerDependency: every app that authors style()\n// already installs it, and it must be the app's instance (it runs at the app's\n// build), so we never bundle it.\n//\n// Usage (a dual-target app build, e.g. TanStack Start / solid-start):\n//\n// import { defineConfig } from \"vite\";\n// import solid from \"vite-plugin-solid\";\n// import { vivianaMacros } from \"@proyecto-viviana/ui/vite\";\n//\n// export default defineConfig({\n// plugins: [vivianaMacros(), solid({ ssr: true })],\n// // Keep our Solid packages out of the optimizer and bundle them into SSR:\n// optimizeDeps: { exclude: [\"@proyecto-viviana/ui\", \"@proyecto-viviana/solid-spectrum\"] },\n// ssr: { noExternal: [\"@proyecto-viviana/ui\", \"@proyecto-viviana/solid-spectrum\"] },\n// });\n//\n// Plugin order: place `vivianaMacros()` before `vite-plugin-solid` (the macro\n// must expand style() before Solid compiles JSX), and before framework plugins\n// (TanStack Start / Cloudflare) that wrap the build. The macro plugin only\n// touches macro CSS resolution/loading and import stripping; the\n// `optimizeDeps.exclude` / `ssr.noExternal` of our Solid packages stays\n// app-owned (it depends on whether the app links sources or pre-built dists).\nimport macros from \"unplugin-parcel-macros\";\n\n// A minimal structural view of the rolldown plugin that\n// `unplugin-parcel-macros` returns — only the hooks we wrap. Kept local (and\n// self-contained, with no rolldown/vite type imports) so the emitted\n// `dist/vite.d.ts` is portable: consumers don't need rolldown's types resolvable\n// to use the helper, and tsc can name the return type. `macros.rolldown()` is\n// typed `Plugin | Plugin[]`; we always get the single-plugin form.\ninterface MacroPlugin {\n name?: string;\n transform?: (this: unknown, code: string, id: string) => unknown;\n resolveId?: (this: unknown, id: string, importer?: string, options?: object) => unknown;\n loadInclude?: (id: string) => boolean | void;\n load?: (this: unknown, id: string) => unknown;\n [key: string]: unknown;\n}\n\nconst macroCssIdPattern = /^macro-[a-f0-9]+\\.css$/;\nconst macroCssImportPattern = /import\\s+[\"']macro-[a-f0-9]+\\.css[\"'];\\n?/g;\n\nfunction getMacroCssFileName(id: string) {\n const fileName = id.split(\"/\").pop();\n return fileName && macroCssIdPattern.test(fileName) ? fileName : null;\n}\n\nfunction removeMacroCssImports(code: string) {\n return code.replace(macroCssImportPattern, \"\");\n}\n\nfunction getMacroCssContent(content: unknown) {\n if (typeof content === \"string\") {\n return content;\n }\n\n if (content && typeof content === \"object\" && \"code\" in content) {\n const code = (content as { code: unknown }).code;\n return typeof code === \"string\" ? code : null;\n }\n\n return null;\n}\n\n/**\n * Returns the S2 style() macro plugin wrapped so its emitted CSS resolves and\n * loads correctly under rolldown-vite. Place it before `vite-plugin-solid`.\n */\nexport function vivianaMacros(): MacroPlugin {\n const plugin = macros.rolldown() as unknown as MacroPlugin;\n const macroCssCache = new Map<string, string>();\n\n const cacheMacroCss = (id: string, content: unknown) => {\n const fileName = getMacroCssFileName(id);\n const css = getMacroCssContent(content);\n if (fileName && css != null) {\n macroCssCache.set(fileName, css);\n }\n return css;\n };\n\n return {\n ...plugin,\n async transform(this: unknown, code: string, id: string) {\n const result = await plugin.transform?.call(this, code, id);\n const transformedCode =\n typeof result === \"string\"\n ? result\n : result && typeof result === \"object\" && \"code\" in result\n ? String(result.code)\n : \"\";\n\n for (const match of transformedCode.matchAll(/import\\s+[\"'](macro-[a-f0-9]+\\.css)[\"'];/g)) {\n const content = await plugin.load?.call(this, match[1]);\n cacheMacroCss(match[1], content);\n }\n\n return result;\n },\n async resolveId(this: unknown, id: string, importer?: string, options?: object) {\n const resolved = await plugin.resolveId?.call(this, id, importer, options);\n if (resolved) {\n return resolved;\n }\n const fileName = getMacroCssFileName(id);\n if (fileName && macroCssCache.has(fileName)) {\n return fileName;\n }\n return resolved;\n },\n loadInclude(id: string) {\n const fileName = getMacroCssFileName(id);\n return (\n (fileName != null && macroCssCache.has(fileName)) || (plugin.loadInclude?.(id) ?? false)\n );\n },\n async load(this: unknown, id: string) {\n if (plugin.loadInclude?.(id)) {\n const content = await plugin.load?.call(this, id);\n const css = cacheMacroCss(id, content);\n if (css != null) {\n return css;\n }\n return content;\n }\n const fileName = getMacroCssFileName(id);\n if (fileName) {\n return macroCssCache.get(fileName);\n }\n return null;\n },\n renderChunk(code: string) {\n return removeMacroCssImports(code);\n },\n };\n}\n"],"mappings":";;
|
|
1
|
+
{"version":3,"file":"vite.js","names":[],"sources":["../src/vite.ts"],"sourcesContent":["// The supported Vite macro preset for apps that author their own `style()` calls\n// against `@proyecto-viviana/ui/style`.\n//\n// Consuming the *pre-built* components needs no macro plugin — their style()\n// calls are already expanded in the published build. But an app that writes its\n// own macro calls must run the S2 style() macro at its own build. The bare\n// `unplugin-parcel-macros` plugin isn't enough under rolldown-vite: the macro\n// emits `import \"macro-<hash>.css\"` statements plus matching virtual CSS modules,\n// and rolldown doesn't honor the plugin's resolveId/load for those virtual ids\n// (\"failed to resolve import macro-….css\"). So we wrap it: cache each macro CSS\n// body as it's transformed, resolve/serve those ids ourselves (with a `.css`\n// extension so Vite's CSS pipeline bundles them), then strip the now-redundant JS\n// import. This is the single source of truth for that wrapper — apps import it\n// instead of copying it into their config.\n//\n// `unplugin-parcel-macros` is a peerDependency: every app that authors style()\n// already installs it, and it must be the app's instance (it runs at the app's\n// build), so we never bundle it.\n//\n// Usage (a dual-target app build, e.g. TanStack Start / solid-start):\n//\n// import { defineConfig } from \"vite\";\n// import solid from \"vite-plugin-solid\";\n// import { vivianaMacros } from \"@proyecto-viviana/ui/vite\";\n//\n// export default defineConfig({\n// plugins: [vivianaMacros(), solid({ ssr: true })],\n// // Keep our Solid packages out of the optimizer and bundle them into SSR:\n// optimizeDeps: { exclude: [\"@proyecto-viviana/ui\", \"@proyecto-viviana/solid-spectrum\"] },\n// ssr: { noExternal: [\"@proyecto-viviana/ui\", \"@proyecto-viviana/solid-spectrum\"] },\n// });\n//\n// Plugin order: place `vivianaMacros()` before `vite-plugin-solid` (the macro\n// must expand style() before Solid compiles JSX), and before framework plugins\n// (TanStack Start / Cloudflare) that wrap the build. The macro plugin only\n// touches macro CSS resolution/loading and import stripping; the\n// `optimizeDeps.exclude` / `ssr.noExternal` of our Solid packages stays\n// app-owned (it depends on whether the app links sources or pre-built dists).\nimport macros from \"unplugin-parcel-macros\";\n\n// A minimal structural view of the rolldown plugin that\n// `unplugin-parcel-macros` returns — only the hooks we wrap. Kept local (and\n// self-contained, with no rolldown/vite type imports) so the emitted\n// `dist/vite.d.ts` is portable: consumers don't need rolldown's types resolvable\n// to use the helper, and tsc can name the return type. `macros.rolldown()` is\n// typed `Plugin | Plugin[]`; we always get the single-plugin form.\ninterface MacroPlugin {\n name?: string;\n transformInclude?: (id: string) => boolean | void;\n transform?: (this: unknown, code: string, id: string) => unknown;\n resolveId?: (this: unknown, id: string, importer?: string, options?: object) => unknown;\n loadInclude?: (id: string) => boolean | void;\n load?: (this: unknown, id: string) => unknown;\n [key: string]: unknown;\n}\n\nconst macroCssIdPattern = /^macro-[a-f0-9]+\\.css$/;\nconst macroCssImportPattern = /import\\s+[\"']macro-[a-f0-9]+\\.css[\"'];\\n?/g;\n\nfunction getMacroSourceFilePath(id: string) {\n const queryIndex = id.indexOf(\"?\");\n if (queryIndex === -1 || !/^\\?tsr-split=[^&#]+(?:#.*)?$/.test(id.slice(queryIndex))) {\n return id;\n }\n return id.slice(0, queryIndex);\n}\n\nfunction getMacroCssFileName(id: string) {\n const fileName = id.split(\"/\").pop();\n return fileName && macroCssIdPattern.test(fileName) ? fileName : null;\n}\n\nfunction removeMacroCssImports(code: string) {\n return code.replace(macroCssImportPattern, \"\");\n}\n\nfunction getMacroCssContent(content: unknown) {\n if (typeof content === \"string\") {\n return content;\n }\n\n if (content && typeof content === \"object\" && \"code\" in content) {\n const code = (content as { code: unknown }).code;\n return typeof code === \"string\" ? code : null;\n }\n\n return null;\n}\n\n/**\n * Returns the S2 style() macro plugin wrapped so its emitted CSS resolves and\n * loads correctly under rolldown-vite. Place it before `vite-plugin-solid`.\n */\nexport function vivianaMacros(): MacroPlugin {\n const plugin = macros.rolldown() as unknown as MacroPlugin;\n const macroCssCache = new Map<string, string>();\n\n const cacheMacroCss = (id: string, content: unknown) => {\n const fileName = getMacroCssFileName(id);\n const css = getMacroCssContent(content);\n if (fileName && css != null) {\n macroCssCache.set(fileName, css);\n }\n return css;\n };\n\n return {\n ...plugin,\n transformInclude(id: string) {\n return plugin.transformInclude?.(getMacroSourceFilePath(id)) ?? false;\n },\n async transform(this: unknown, code: string, id: string) {\n const result = await plugin.transform?.call(this, code, getMacroSourceFilePath(id));\n const transformedCode =\n typeof result === \"string\"\n ? result\n : result && typeof result === \"object\" && \"code\" in result\n ? String(result.code)\n : \"\";\n\n for (const match of transformedCode.matchAll(/import\\s+[\"'](macro-[a-f0-9]+\\.css)[\"'];/g)) {\n const content = await plugin.load?.call(this, match[1]);\n cacheMacroCss(match[1], content);\n }\n\n return result;\n },\n async resolveId(this: unknown, id: string, importer?: string, options?: object) {\n const resolved = await plugin.resolveId?.call(this, id, importer, options);\n if (resolved) {\n return resolved;\n }\n const fileName = getMacroCssFileName(id);\n if (fileName && macroCssCache.has(fileName)) {\n return fileName;\n }\n return resolved;\n },\n loadInclude(id: string) {\n const fileName = getMacroCssFileName(id);\n return (\n (fileName != null && macroCssCache.has(fileName)) || (plugin.loadInclude?.(id) ?? false)\n );\n },\n async load(this: unknown, id: string) {\n if (plugin.loadInclude?.(id)) {\n const content = await plugin.load?.call(this, id);\n const css = cacheMacroCss(id, content);\n if (css != null) {\n return css;\n }\n return content;\n }\n const fileName = getMacroCssFileName(id);\n if (fileName) {\n return macroCssCache.get(fileName);\n }\n return null;\n },\n renderChunk(code: string) {\n return removeMacroCssImports(code);\n },\n };\n}\n"],"mappings":";;AAwDA,MAAM,oBAAoB;AAC1B,MAAM,wBAAwB;AAE9B,SA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AAM,OAAO,MAAM,KAAK,MAAM,MAAM,EAAE;IACtD,cAAc,MAAM,IAAI,OAAO;GACjC;GAEA,OAAO;EACT;EACA,MAAM,UAAyB,IAAY,UAAmB,SAAkB;GAC9E,MAAM,WAAW,MAAM,OAAO,WAAW,KAAK,MAAM,IAAI,UAAU,OAAO;GACzE,IAAI,UACF,OAAO;GAET,MAAM,WAAW,oBAAoB,EAAE;GACvC,IAAI,YAAY,cAAc,IAAI,QAAQ,GACxC,OAAO;GAET,OAAO;EACT;EACA,YAAY,IAAY;GACtB,MAAM,WAAW,oBAAoB,EAAE;GACvC,OACG,YAAY,QAAQ,cAAc,IAAI,QAAQ,MAAO,OAAO,cAAc,EAAE,KAAK;EAEtF;EACA,MAAM,KAAoB,IAAY;GACpC,IAAI,OAAO,cAAc,EAAE,GAAG;IAC5B,MAAM,UAAU,MAAM,OAAO,MAAM,KAAK,MAAM,EAAE;IAChD,MAAM,MAAM,cAAc,IAAI,OAAO;IACrC,IAAI,OAAO,MACT,OAAO;IAET,OAAO;GACT;GACA,MAAM,WAAW,oBAAoB,EAAE;GACvC,IAAI,UACF,OAAO,cAAc,IAAI,QAAQ;GAEnC,OAAO;EACT;EACA,YAAY,MAAc;GACxB,OAAO,sBAAsB,IAAI;EACnC;CACF;AACF"}
|
package/dist/vite.jsx
CHANGED
|
@@ -2,6 +2,11 @@ import macros from "unplugin-parcel-macros";
|
|
|
2
2
|
//#region src/vite.ts
|
|
3
3
|
const macroCssIdPattern = /^macro-[a-f0-9]+\.css$/;
|
|
4
4
|
const macroCssImportPattern = /import\s+["']macro-[a-f0-9]+\.css["'];\n?/g;
|
|
5
|
+
function getMacroSourceFilePath(id) {
|
|
6
|
+
const queryIndex = id.indexOf("?");
|
|
7
|
+
if (queryIndex === -1 || !/^\?tsr-split=[^&#]+(?:#.*)?$/.test(id.slice(queryIndex))) return id;
|
|
8
|
+
return id.slice(0, queryIndex);
|
|
9
|
+
}
|
|
5
10
|
function getMacroCssFileName(id) {
|
|
6
11
|
const fileName = id.split("/").pop();
|
|
7
12
|
return fileName && macroCssIdPattern.test(fileName) ? fileName : null;
|
|
@@ -32,8 +37,11 @@ function vivianaMacros() {
|
|
|
32
37
|
};
|
|
33
38
|
return {
|
|
34
39
|
...plugin,
|
|
40
|
+
transformInclude(id) {
|
|
41
|
+
return plugin.transformInclude?.(getMacroSourceFilePath(id)) ?? false;
|
|
42
|
+
},
|
|
35
43
|
async transform(code, id) {
|
|
36
|
-
const result = await plugin.transform?.call(this, code, id);
|
|
44
|
+
const result = await plugin.transform?.call(this, code, getMacroSourceFilePath(id));
|
|
37
45
|
const transformedCode = typeof result === "string" ? result : result && typeof result === "object" && "code" in result ? String(result.code) : "";
|
|
38
46
|
for (const match of transformedCode.matchAll(/import\s+["'](macro-[a-f0-9]+\.css)["'];/g)) {
|
|
39
47
|
const content = await plugin.load?.call(this, match[1]);
|
package/dist/vite.jsx.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vite.jsx","names":[],"sources":["../src/vite.ts"],"sourcesContent":["// The supported Vite macro preset for apps that author their own `style()` calls\n// against `@proyecto-viviana/ui/style`.\n//\n// Consuming the *pre-built* components needs no macro plugin — their style()\n// calls are already expanded in the published build. But an app that writes its\n// own macro calls must run the S2 style() macro at its own build. The bare\n// `unplugin-parcel-macros` plugin isn't enough under rolldown-vite: the macro\n// emits `import \"macro-<hash>.css\"` statements plus matching virtual CSS modules,\n// and rolldown doesn't honor the plugin's resolveId/load for those virtual ids\n// (\"failed to resolve import macro-….css\"). So we wrap it: cache each macro CSS\n// body as it's transformed, resolve/serve those ids ourselves (with a `.css`\n// extension so Vite's CSS pipeline bundles them), then strip the now-redundant JS\n// import. This is the single source of truth for that wrapper — apps import it\n// instead of copying it into their config.\n//\n// `unplugin-parcel-macros` is a peerDependency: every app that authors style()\n// already installs it, and it must be the app's instance (it runs at the app's\n// build), so we never bundle it.\n//\n// Usage (a dual-target app build, e.g. TanStack Start / solid-start):\n//\n// import { defineConfig } from \"vite\";\n// import solid from \"vite-plugin-solid\";\n// import { vivianaMacros } from \"@proyecto-viviana/ui/vite\";\n//\n// export default defineConfig({\n// plugins: [vivianaMacros(), solid({ ssr: true })],\n// // Keep our Solid packages out of the optimizer and bundle them into SSR:\n// optimizeDeps: { exclude: [\"@proyecto-viviana/ui\", \"@proyecto-viviana/solid-spectrum\"] },\n// ssr: { noExternal: [\"@proyecto-viviana/ui\", \"@proyecto-viviana/solid-spectrum\"] },\n// });\n//\n// Plugin order: place `vivianaMacros()` before `vite-plugin-solid` (the macro\n// must expand style() before Solid compiles JSX), and before framework plugins\n// (TanStack Start / Cloudflare) that wrap the build. The macro plugin only\n// touches macro CSS resolution/loading and import stripping; the\n// `optimizeDeps.exclude` / `ssr.noExternal` of our Solid packages stays\n// app-owned (it depends on whether the app links sources or pre-built dists).\nimport macros from \"unplugin-parcel-macros\";\n\n// A minimal structural view of the rolldown plugin that\n// `unplugin-parcel-macros` returns — only the hooks we wrap. Kept local (and\n// self-contained, with no rolldown/vite type imports) so the emitted\n// `dist/vite.d.ts` is portable: consumers don't need rolldown's types resolvable\n// to use the helper, and tsc can name the return type. `macros.rolldown()` is\n// typed `Plugin | Plugin[]`; we always get the single-plugin form.\ninterface MacroPlugin {\n name?: string;\n transform?: (this: unknown, code: string, id: string) => unknown;\n resolveId?: (this: unknown, id: string, importer?: string, options?: object) => unknown;\n loadInclude?: (id: string) => boolean | void;\n load?: (this: unknown, id: string) => unknown;\n [key: string]: unknown;\n}\n\nconst macroCssIdPattern = /^macro-[a-f0-9]+\\.css$/;\nconst macroCssImportPattern = /import\\s+[\"']macro-[a-f0-9]+\\.css[\"'];\\n?/g;\n\nfunction getMacroCssFileName(id: string) {\n const fileName = id.split(\"/\").pop();\n return fileName && macroCssIdPattern.test(fileName) ? fileName : null;\n}\n\nfunction removeMacroCssImports(code: string) {\n return code.replace(macroCssImportPattern, \"\");\n}\n\nfunction getMacroCssContent(content: unknown) {\n if (typeof content === \"string\") {\n return content;\n }\n\n if (content && typeof content === \"object\" && \"code\" in content) {\n const code = (content as { code: unknown }).code;\n return typeof code === \"string\" ? code : null;\n }\n\n return null;\n}\n\n/**\n * Returns the S2 style() macro plugin wrapped so its emitted CSS resolves and\n * loads correctly under rolldown-vite. Place it before `vite-plugin-solid`.\n */\nexport function vivianaMacros(): MacroPlugin {\n const plugin = macros.rolldown() as unknown as MacroPlugin;\n const macroCssCache = new Map<string, string>();\n\n const cacheMacroCss = (id: string, content: unknown) => {\n const fileName = getMacroCssFileName(id);\n const css = getMacroCssContent(content);\n if (fileName && css != null) {\n macroCssCache.set(fileName, css);\n }\n return css;\n };\n\n return {\n ...plugin,\n async transform(this: unknown, code: string, id: string) {\n const result = await plugin.transform?.call(this, code, id);\n const transformedCode =\n typeof result === \"string\"\n ? result\n : result && typeof result === \"object\" && \"code\" in result\n ? String(result.code)\n : \"\";\n\n for (const match of transformedCode.matchAll(/import\\s+[\"'](macro-[a-f0-9]+\\.css)[\"'];/g)) {\n const content = await plugin.load?.call(this, match[1]);\n cacheMacroCss(match[1], content);\n }\n\n return result;\n },\n async resolveId(this: unknown, id: string, importer?: string, options?: object) {\n const resolved = await plugin.resolveId?.call(this, id, importer, options);\n if (resolved) {\n return resolved;\n }\n const fileName = getMacroCssFileName(id);\n if (fileName && macroCssCache.has(fileName)) {\n return fileName;\n }\n return resolved;\n },\n loadInclude(id: string) {\n const fileName = getMacroCssFileName(id);\n return (\n (fileName != null && macroCssCache.has(fileName)) || (plugin.loadInclude?.(id) ?? false)\n );\n },\n async load(this: unknown, id: string) {\n if (plugin.loadInclude?.(id)) {\n const content = await plugin.load?.call(this, id);\n const css = cacheMacroCss(id, content);\n if (css != null) {\n return css;\n }\n return content;\n }\n const fileName = getMacroCssFileName(id);\n if (fileName) {\n return macroCssCache.get(fileName);\n }\n return null;\n },\n renderChunk(code: string) {\n return removeMacroCssImports(code);\n },\n };\n}\n"],"mappings":";;
|
|
1
|
+
{"version":3,"file":"vite.jsx","names":[],"sources":["../src/vite.ts"],"sourcesContent":["// The supported Vite macro preset for apps that author their own `style()` calls\n// against `@proyecto-viviana/ui/style`.\n//\n// Consuming the *pre-built* components needs no macro plugin — their style()\n// calls are already expanded in the published build. But an app that writes its\n// own macro calls must run the S2 style() macro at its own build. The bare\n// `unplugin-parcel-macros` plugin isn't enough under rolldown-vite: the macro\n// emits `import \"macro-<hash>.css\"` statements plus matching virtual CSS modules,\n// and rolldown doesn't honor the plugin's resolveId/load for those virtual ids\n// (\"failed to resolve import macro-….css\"). So we wrap it: cache each macro CSS\n// body as it's transformed, resolve/serve those ids ourselves (with a `.css`\n// extension so Vite's CSS pipeline bundles them), then strip the now-redundant JS\n// import. This is the single source of truth for that wrapper — apps import it\n// instead of copying it into their config.\n//\n// `unplugin-parcel-macros` is a peerDependency: every app that authors style()\n// already installs it, and it must be the app's instance (it runs at the app's\n// build), so we never bundle it.\n//\n// Usage (a dual-target app build, e.g. TanStack Start / solid-start):\n//\n// import { defineConfig } from \"vite\";\n// import solid from \"vite-plugin-solid\";\n// import { vivianaMacros } from \"@proyecto-viviana/ui/vite\";\n//\n// export default defineConfig({\n// plugins: [vivianaMacros(), solid({ ssr: true })],\n// // Keep our Solid packages out of the optimizer and bundle them into SSR:\n// optimizeDeps: { exclude: [\"@proyecto-viviana/ui\", \"@proyecto-viviana/solid-spectrum\"] },\n// ssr: { noExternal: [\"@proyecto-viviana/ui\", \"@proyecto-viviana/solid-spectrum\"] },\n// });\n//\n// Plugin order: place `vivianaMacros()` before `vite-plugin-solid` (the macro\n// must expand style() before Solid compiles JSX), and before framework plugins\n// (TanStack Start / Cloudflare) that wrap the build. The macro plugin only\n// touches macro CSS resolution/loading and import stripping; the\n// `optimizeDeps.exclude` / `ssr.noExternal` of our Solid packages stays\n// app-owned (it depends on whether the app links sources or pre-built dists).\nimport macros from \"unplugin-parcel-macros\";\n\n// A minimal structural view of the rolldown plugin that\n// `unplugin-parcel-macros` returns — only the hooks we wrap. Kept local (and\n// self-contained, with no rolldown/vite type imports) so the emitted\n// `dist/vite.d.ts` is portable: consumers don't need rolldown's types resolvable\n// to use the helper, and tsc can name the return type. `macros.rolldown()` is\n// typed `Plugin | Plugin[]`; we always get the single-plugin form.\ninterface MacroPlugin {\n name?: string;\n transformInclude?: (id: string) => boolean | void;\n transform?: (this: unknown, code: string, id: string) => unknown;\n resolveId?: (this: unknown, id: string, importer?: string, options?: object) => unknown;\n loadInclude?: (id: string) => boolean | void;\n load?: (this: unknown, id: string) => unknown;\n [key: string]: unknown;\n}\n\nconst macroCssIdPattern = /^macro-[a-f0-9]+\\.css$/;\nconst macroCssImportPattern = /import\\s+[\"']macro-[a-f0-9]+\\.css[\"'];\\n?/g;\n\nfunction getMacroSourceFilePath(id: string) {\n const queryIndex = id.indexOf(\"?\");\n if (queryIndex === -1 || !/^\\?tsr-split=[^&#]+(?:#.*)?$/.test(id.slice(queryIndex))) {\n return id;\n }\n return id.slice(0, queryIndex);\n}\n\nfunction getMacroCssFileName(id: string) {\n const fileName = id.split(\"/\").pop();\n return fileName && macroCssIdPattern.test(fileName) ? fileName : null;\n}\n\nfunction removeMacroCssImports(code: string) {\n return code.replace(macroCssImportPattern, \"\");\n}\n\nfunction getMacroCssContent(content: unknown) {\n if (typeof content === \"string\") {\n return content;\n }\n\n if (content && typeof content === \"object\" && \"code\" in content) {\n const code = (content as { code: unknown }).code;\n return typeof code === \"string\" ? code : null;\n }\n\n return null;\n}\n\n/**\n * Returns the S2 style() macro plugin wrapped so its emitted CSS resolves and\n * loads correctly under rolldown-vite. Place it before `vite-plugin-solid`.\n */\nexport function vivianaMacros(): MacroPlugin {\n const plugin = macros.rolldown() as unknown as MacroPlugin;\n const macroCssCache = new Map<string, string>();\n\n const cacheMacroCss = (id: string, content: unknown) => {\n const fileName = getMacroCssFileName(id);\n const css = getMacroCssContent(content);\n if (fileName && css != null) {\n macroCssCache.set(fileName, css);\n }\n return css;\n };\n\n return {\n ...plugin,\n transformInclude(id: string) {\n return plugin.transformInclude?.(getMacroSourceFilePath(id)) ?? false;\n },\n async transform(this: unknown, code: string, id: string) {\n const result = await plugin.transform?.call(this, code, getMacroSourceFilePath(id));\n const transformedCode =\n typeof result === \"string\"\n ? result\n : result && typeof result === \"object\" && \"code\" in result\n ? String(result.code)\n : \"\";\n\n for (const match of transformedCode.matchAll(/import\\s+[\"'](macro-[a-f0-9]+\\.css)[\"'];/g)) {\n const content = await plugin.load?.call(this, match[1]);\n cacheMacroCss(match[1], content);\n }\n\n return result;\n },\n async resolveId(this: unknown, id: string, importer?: string, options?: object) {\n const resolved = await plugin.resolveId?.call(this, id, importer, options);\n if (resolved) {\n return resolved;\n }\n const fileName = getMacroCssFileName(id);\n if (fileName && macroCssCache.has(fileName)) {\n return fileName;\n }\n return resolved;\n },\n loadInclude(id: string) {\n const fileName = getMacroCssFileName(id);\n return (\n (fileName != null && macroCssCache.has(fileName)) || (plugin.loadInclude?.(id) ?? false)\n );\n },\n async load(this: unknown, id: string) {\n if (plugin.loadInclude?.(id)) {\n const content = await plugin.load?.call(this, id);\n const css = cacheMacroCss(id, content);\n if (css != null) {\n return css;\n }\n return content;\n }\n const fileName = getMacroCssFileName(id);\n if (fileName) {\n return macroCssCache.get(fileName);\n }\n return null;\n },\n renderChunk(code: string) {\n return removeMacroCssImports(code);\n },\n };\n}\n"],"mappings":";;AAwDA,MAAM,oBAAoB;AAC1B,MAAM,wBAAwB;AAE9B,SAAS,uBAAuB,IAAY;CAC1C,MAAM,aAAa,GAAG,QAAQ,GAAG;CACjC,IAAI,eAAe,MAAM,CAAC,+BAA+B,KAAK,GAAG,MAAM,UAAU,CAAC,GAChF,OAAO;CAET,OAAO,GAAG,MAAM,GAAG,UAAU;AAC/B;AAEA,SAAS,oBAAoB,IAAY;CACvC,MAAM,WAAW,GAAG,MAAM,GAAG,EAAE,IAAI;CACnC,OAAO,YAAY,kBAAkB,KAAK,QAAQ,IAAI,WAAW;AACnE;AAEA,SAAS,sBAAsB,MAAc;CAC3C,OAAO,KAAK,QAA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