@brickflow/ui 0.0.34 → 0.0.35

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/module.json CHANGED
@@ -4,7 +4,7 @@
4
4
  },
5
5
  "configKey": "brickflowUi",
6
6
  "name": "@brickflow/ui",
7
- "version": "0.0.34",
7
+ "version": "0.0.35",
8
8
  "builder": {
9
9
  "@nuxt/module-builder": "1.0.3",
10
10
  "unbuild": "3.6.1"
package/dist/module.mjs CHANGED
@@ -3,7 +3,7 @@ import tailwindcss from '@tailwindcss/vite';
3
3
  import { createJiti } from 'jiti';
4
4
  import { readdir, mkdir, readFile, writeFile } from 'node:fs/promises';
5
5
  import { join, basename, extname, dirname, resolve, relative } from 'node:path';
6
- import { isBrickflowUiStyleReference, getBrickflowUiStyleReferencePath, defineBrickflowUiConfig } from '../dist/runtime/tailwind.js';
6
+ import { isBrickflowUiStyleReference, getBrickflowUiStyleReferencePath, defineBrickflowUi } from '../dist/runtime/tailwind.js';
7
7
  import { generateFonts, FontAssetType, OtherAssetType } from 'fantasticon';
8
8
 
9
9
  const ICON_FILE_PATTERN = /\.svg$/i;
@@ -157,25 +157,23 @@ const replaceUiConfigMacros = (code, config, styles, id, error) => {
157
157
  return result + code.slice(cursor);
158
158
  }
159
159
  const genericStart = start + UI_CONFIG_MACRO.length;
160
- if (code[genericStart] !== "<") {
161
- result += code.slice(cursor, genericStart);
162
- cursor = genericStart;
163
- continue;
164
- }
165
- let depth = 0;
166
- let index = genericStart;
167
- for (; index < code.length; index += 1) {
168
- if (code[index] === "<") {
169
- depth += 1;
170
- }
171
- if (code[index] === ">") {
172
- depth -= 1;
173
- }
174
- if (depth === 0) {
175
- break;
160
+ let callStart = genericStart;
161
+ if (code[genericStart] === "<") {
162
+ let depth = 0;
163
+ let index = genericStart;
164
+ for (; index < code.length; index += 1) {
165
+ if (code[index] === "<") {
166
+ depth += 1;
167
+ }
168
+ if (code[index] === ">") {
169
+ depth -= 1;
170
+ }
171
+ if (depth === 0) {
172
+ break;
173
+ }
176
174
  }
175
+ callStart = index + 1;
177
176
  }
178
- let callStart = index + 1;
179
177
  while (/\s/u.test(code[callStart] ?? "")) {
180
178
  callStart += 1;
181
179
  }
@@ -396,14 +394,17 @@ const brickflowUiStylePlugin = (options) => ({
396
394
  },
397
395
  name: "brickflow-ui-style",
398
396
  async transform(code, id) {
399
- if (!SCRIPT_FILE_PATTERN.test(id) || !code.includes("UI_STYLE.") && !code.includes("UI_CONFIG.") && !code.includes(UI_CONFIG_MACRO)) {
397
+ const cleanId = id.split("?")[0] ?? id;
398
+ const isVirtualModule = cleanId.startsWith("\0") || cleanId.startsWith("virtual:");
399
+ const isVueSubmodule = cleanId.endsWith(".vue") && id.includes("?vue");
400
+ if (isVirtualModule || isVueSubmodule && !code.includes(UI_CONFIG_MACRO) || !SCRIPT_FILE_PATTERN.test(id) || !code.includes("UI_STYLE.") && !code.includes("UI_CONFIG.") && !code.includes(UI_CONFIG_MACRO)) {
400
401
  return null;
401
402
  }
402
403
  this.addWatchFile?.(options.configPath);
403
404
  const styles = await options.getStyles();
404
405
  const config = await options.getConfig();
405
- const isConfigFile = normalizePath(id.split("?")[0] ?? id) === normalizePath(options.configPath);
406
- const hasUiConfigMacro = code.includes(UI_CONFIG_MACRO);
406
+ const isConfigFile = normalizePath(cleanId) === normalizePath(options.configPath);
407
+ const hasUiConfigMacro = cleanId.endsWith(".vue") && code.includes(UI_CONFIG_MACRO);
407
408
  let changed = false;
408
409
  const codeWithUiConfigMacros = hasUiConfigMacro ? replaceUiConfigMacros(code, config, styles, id, this.error.bind(this)) : code;
409
410
  if (codeWithUiConfigMacros !== code) {
@@ -678,7 +679,7 @@ const module$1 = defineNuxtModule({
678
679
  );
679
680
  };
680
681
  const loadUiConfig = async () => {
681
- const validateConfig = defineBrickflowUiConfig;
682
+ const validateConfig = defineBrickflowUi;
682
683
  return validateConfig(
683
684
  await loadConfig.import(resolvedConfigPath).catch(() => ({}))
684
685
  );
@@ -755,10 +756,10 @@ const module$1 = defineNuxtModule({
755
756
  const uiConfigTemplate = addTemplate({
756
757
  filename: "brickflow/brickflow-ui-config.mjs",
757
758
  getContents: () => [
758
- `import { defineBrickflowUiConfig } from ${JSON.stringify(resolver.resolve("./runtime/tailwind").replaceAll("\\", "/"))}`,
759
+ `import { defineBrickflowUi } from ${JSON.stringify(resolver.resolve("./runtime/tailwind").replaceAll("\\", "/"))}`,
759
760
  `import rawConfig from ${JSON.stringify(resolvedConfigPath.replaceAll("\\", "/"))}`,
760
761
  "",
761
- "const config = defineBrickflowUiConfig(rawConfig)",
762
+ "const config = defineBrickflowUi(rawConfig)",
762
763
  "",
763
764
  "export const UI_STYLE = config.uiStyles",
764
765
  "export const UI_CONFIG = config.uiConfig",
@@ -1,5 +1,4 @@
1
1
  <script>
2
- const UI_CONFIG = defineUiConfig();
3
2
  export const uiDemo = {
4
3
  title: "Color & Variants"
5
4
  };
@@ -7,6 +6,7 @@ export const uiDemo = {
7
6
 
8
7
  <script setup>
9
8
  import Button from "./index.vue";
9
+ const UI_CONFIG = defineUiConfig();
10
10
  const colors = Object.entries(UI_CONFIG.colorClasses).map(([name, classes]) => ({
11
11
  name,
12
12
  variants: Object.keys(classes)
@@ -10,6 +10,10 @@ export type BrickflowUiConfigValue = BrickflowUiConfigObject | BrickflowUiStyleR
10
10
  export interface BrickflowUiStyleReference {
11
11
  readonly [UI_STYLE_REFERENCE]: readonly string[];
12
12
  }
13
+ /** A chainable compile-time reference to a string in `uiStyles`. */
14
+ export type BrickflowUiStyleReferenceValue = string & {
15
+ readonly [key: string]: any;
16
+ };
13
17
  declare global {
14
18
  interface BrickflowUiConfigSchema {
15
19
  }
@@ -41,12 +45,12 @@ type BrickflowUiConfigValidation<TConfig extends BrickflowUiConfigObject> = keyo
41
45
  export declare const emptyUiStyles: {};
42
46
  export declare const emptyUiConfig: {};
43
47
  export declare const emptyBrickflowUiConfig: BrickflowUiConfig<typeof emptyUiStyles, typeof emptyUiConfig>;
44
- export declare function defineBrickflowUiConfig(): BrickflowUiConfig<typeof emptyUiStyles, typeof emptyUiConfig>;
45
- export declare function defineBrickflowUiConfig<const TStyles extends BrickflowUiConfigStylePaths, const TConfig extends BrickflowUiConfigObject>(config: BrickflowUiConfigContext & BrickflowUiConfigInput<BrickflowUiStrictStyles<TStyles>, TConfig> & BrickflowUiConfigValidation<TConfig>): BrickflowUiConfig<TStyles, TConfig>;
48
+ export declare function defineBrickflowUi(): BrickflowUiConfig<typeof emptyUiStyles, typeof emptyUiConfig>;
49
+ export declare function defineBrickflowUi<const TStyles extends BrickflowUiConfigStylePaths, const TConfig extends BrickflowUiConfigObject>(config: BrickflowUiConfigContext & BrickflowUiConfigInput<BrickflowUiStrictStyles<TStyles>, TConfig> & BrickflowUiConfigValidation<TConfig>): BrickflowUiConfig<TStyles, TConfig>;
46
50
  export declare const uiStyles: {};
47
51
  export declare const uiConfig: {};
48
52
  /** A compile-time reference to a value in `uiStyles`, for use inside `uiConfig`. */
49
- export declare const UI_STYLE: BrickflowUiStyleReference;
53
+ export declare const UI_STYLE: BrickflowUiStyleReferenceValue;
50
54
  export declare const isBrickflowUiStyleReference: (value: unknown) => value is BrickflowUiStyleReference;
51
55
  export declare const getBrickflowUiStyleReferencePath: (value: BrickflowUiStyleReference) => readonly string[];
52
56
  export default emptyBrickflowUiConfig;
@@ -5,7 +5,7 @@ export const emptyBrickflowUiConfig = {
5
5
  uiConfig: emptyUiConfig,
6
6
  uiStyles: emptyUiStyles
7
7
  };
8
- export function defineBrickflowUiConfig(config = {}) {
8
+ export function defineBrickflowUi(config = {}) {
9
9
  const uiConfig2 = config.uiConfig ?? emptyUiConfig;
10
10
  const uiStyles2 = config.uiStyles ?? emptyUiStyles;
11
11
  validateUiConfig(uiConfig2);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brickflow/ui",
3
- "version": "0.0.34",
3
+ "version": "0.0.35",
4
4
  "type": "module",
5
5
  "description": "brickflow UI Nuxt module.",
6
6
  "files": [