@animus-ui/vite-plugin 0.1.0-next.34 → 0.1.0-next.36

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.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AA6BA,OAAO,KAAK,EAAU,MAAM,EAAE,MAAM,MAAM,CAAC;AAI3C,MAAM,WAAW,oBAAoB;IACnC;;;;;OAKG;IACH,MAAM,EAAE,MAAM,CAAC;IACf,qEAAqE;IACrE,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,gCAAgC;IAChC,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,qGAAqG;IACrG,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,2EAA2E;IAC3E,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAC5B;;;;;OAKG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB;;;;;OAKG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;;;;;;OAQG;IACH,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;CACnB;AA6ID,wBAAgB,aAAa,CAAC,OAAO,EAAE,oBAAoB,GAAG,MAAM,CA09BnE;AAED,eAAe,aAAa,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AA6BA,OAAO,KAAK,EAAU,MAAM,EAAE,MAAM,MAAM,CAAC;AAI3C,MAAM,WAAW,oBAAoB;IACnC;;;;;OAKG;IACH,MAAM,EAAE,MAAM,CAAC;IACf,qEAAqE;IACrE,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,gCAAgC;IAChC,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,qGAAqG;IACrG,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,2EAA2E;IAC3E,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAC5B;;;;;OAKG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB;;;;;OAKG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;;;;;;OAQG;IACH,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;CACnB;AA6ID,wBAAgB,aAAa,CAAC,OAAO,EAAE,oBAAoB,GAAG,MAAM,CAo+BnE;AAED,eAAe,aAAa,CAAC"}
package/dist/index.mjs CHANGED
@@ -150,7 +150,7 @@ function animusExtract(options) {
150
150
  try {
151
151
  const ts = Date.now();
152
152
  const tmpOut = join(tmpdir(), `animus-system-${ts}.json`);
153
- execSubprocess(`const m = require(${JSON.stringify(resolvedSystemPath)});\nconst ds = m.ds || m.default || m.system;\nif (!ds || !ds.toConfig) { throw new Error('Module does not export a SystemInstance with .serialize()'); }\nconst cfg = ds.toConfig();\nconst tokens = m.tokens || m.theme || null;\nconst serialized = tokens && typeof tokens.serialize === 'function' ? tokens.serialize() : null;\nconst globalStyleBlocks = {};\nfor (const [key, val] of Object.entries(m)) {\n if (val && typeof val === 'object' && val.__brand === 'GlobalStyleBlock') {\n globalStyleBlocks[key] = val.styles;\n }\n}\nrequire('fs').writeFileSync(${JSON.stringify(tmpOut)}, JSON.stringify({\n propConfig: cfg.propConfig,\n groupRegistry: cfg.groupRegistry,\n serialized: serialized,\n transformNames: Object.keys(cfg.transforms || {}),\n globalStyleBlocks: Object.keys(globalStyleBlocks).length > 0 ? globalStyleBlocks : null\n}));\n`, rootDir);
153
+ execSubprocess(`const m = require(${JSON.stringify(resolvedSystemPath)});\nconst exportNames = Object.keys(m);\nconst candidates = exportNames.filter(k => m[k] && typeof m[k].toConfig === 'function');\nif (candidates.length === 0) {\n throw new Error('[animus-extract] No SystemInstance found. Exports: [' + exportNames.join(', ') + ']. None have a .toConfig() method. A SystemInstance is created by: export const ds = createSystem().build()');\n}\nif (candidates.length > 1) {\n throw new Error('[animus-extract] Multiple SystemInstance candidates found: [' + candidates.join(', ') + ']. Specify which one to use.');\n}\nconst ds = m[candidates[0]];\nconst cfg = ds.toConfig();\nconst tokens = m.tokens || m.theme || null;\nconst serialized = tokens && typeof tokens.serialize === 'function' ? tokens.serialize() : null;\nconst globalStyleBlocks = {};\nfor (const [key, val] of Object.entries(m)) {\n if (val && typeof val === 'object' && val.__brand === 'GlobalStyleBlock') {\n globalStyleBlocks[key] = val.styles;\n }\n}\nrequire('fs').writeFileSync(${JSON.stringify(tmpOut)}, JSON.stringify({\n propConfig: cfg.propConfig,\n groupRegistry: cfg.groupRegistry,\n serialized: serialized,\n transformNames: Object.keys(cfg.transforms || {}),\n globalStyleBlocks: Object.keys(globalStyleBlocks).length > 0 ? globalStyleBlocks : null\n}));\n`, rootDir);
154
154
  const result = readFileSync(tmpOut, "utf-8");
155
155
  try {
156
156
  unlinkSync(tmpOut);
@@ -164,10 +164,11 @@ function animusExtract(options) {
164
164
  variableCss = parsed.serialized.variableCss;
165
165
  contextualVarsJson = parsed.serialized.contextualVarsJson;
166
166
  if (options.prefix) {
167
- const prefixed = applyPrefix(options.prefix, variableMapJson, variableCss, themeJson);
167
+ const prefixed = applyPrefix(options.prefix, variableMapJson, variableCss, themeJson, contextualVarsJson);
168
168
  variableMapJson = prefixed.variableMapJson;
169
169
  variableCss = prefixed.variableCss;
170
170
  if (prefixed.themeJson) themeJson = prefixed.themeJson;
171
+ if (prefixed.contextualVarsJson) contextualVarsJson = prefixed.contextualVarsJson;
171
172
  }
172
173
  } else throw new Error("[animus-extract] Theme must be built with createTheme().build(). No .serialize() method found on tokens export.");
173
174
  if (parsed.globalStyleBlocks) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@animus-ui/vite-plugin",
3
- "version": "0.1.0-next.34",
3
+ "version": "0.1.0-next.36",
4
4
  "description": "Animus static CSS extraction Vite plugin",
5
5
  "author": "codecaaron <airrobb@gmail.com>",
6
6
  "license": "MIT",
@@ -18,15 +18,16 @@
18
18
  "url": "git+https://github.com/codecaaron/animus"
19
19
  },
20
20
  "scripts": {
21
- "build": "tsdown && tsc -p tsconfig.build.json",
21
+ "build": "bun run build:ts",
22
+ "build:ts": "tsdown && tsc -p tsconfig.build.json",
22
23
  "compile": "tsc --noEmit"
23
24
  },
24
25
  "peerDependencies": {
25
26
  "vite": ">=5.0.0"
26
27
  },
27
28
  "dependencies": {
28
- "@animus-ui/extract": "0.1.0-next.34",
29
- "@animus-ui/system": "0.1.0-next.34",
29
+ "@animus-ui/extract": "0.1.0-next.36",
30
+ "@animus-ui/system": "0.1.0-next.36",
30
31
  "browserslist": "^4.24.0",
31
32
  "lightningcss": "^1.29.0"
32
33
  }