@yahoo/uds 0.1.20 → 0.2.2

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 (67) hide show
  1. package/cli/README.md +2 -8
  2. package/cli/bunfig.toml +3 -0
  3. package/cli/commands/expo/_setup.ts +1 -0
  4. package/cli/commands/expo/build.ts +1 -1
  5. package/cli/commands/expo/launch.ts +1 -1
  6. package/cli/commands/purge.ts +1 -1
  7. package/cli/commands/sync.ts +16 -4
  8. package/cli/commands/uds.ts +4 -1
  9. package/cli/commands/version.ts +1 -1
  10. package/cli/preload.ts +32 -0
  11. package/cli/utils/configWorker.ts +30 -11
  12. package/cli/utils/getCommandHelp.ts +22 -13
  13. package/cli/utils/purgeCSS.test.ts +99 -0
  14. package/cli/utils/purgeCSS.ts +5 -7
  15. package/cli/utils/setupConfigWorker.ts +8 -38
  16. package/cli/utils/types.ts +5 -2
  17. package/dist/Image.native-C6kOWgnf.d.ts +38 -0
  18. package/dist/Image.native-VeXt5aeI.d.cts +38 -0
  19. package/dist/VStack-BSD9TbBd.d.cts +114 -0
  20. package/dist/VStack-Dk3-8IyU.d.ts +114 -0
  21. package/dist/experimental/index.cjs +1 -0
  22. package/dist/experimental/index.d.cts +229 -0
  23. package/dist/experimental/index.d.ts +229 -0
  24. package/dist/experimental/index.js +1 -0
  25. package/dist/experimental/index.native.cjs +1 -0
  26. package/dist/experimental/index.native.d.cts +51 -0
  27. package/dist/experimental/index.native.d.ts +51 -0
  28. package/dist/experimental/index.native.js +1 -0
  29. package/dist/fixtures/index.cjs +1 -1
  30. package/dist/fixtures/index.d.cts +15 -1
  31. package/dist/fixtures/index.d.ts +15 -1
  32. package/dist/fixtures/index.js +1 -1
  33. package/dist/index.cjs +1 -1
  34. package/dist/index.d.cts +134 -456
  35. package/dist/index.d.ts +134 -456
  36. package/dist/index.js +1 -1
  37. package/dist/{index.native-C5-xv9Na.d.cts → index.native-CisPq4BI.d.ts} +1 -1
  38. package/dist/{index.native-DqJv5EjY.d.ts → index.native-DJlx-bfM.d.cts} +1 -1
  39. package/dist/index.native.cjs +1 -1
  40. package/dist/index.native.d.cts +11 -83
  41. package/dist/index.native.d.ts +11 -83
  42. package/dist/index.native.js +1 -1
  43. package/dist/tailwindPlugin.cjs +1 -1
  44. package/dist/tailwindPlugin.d.cts +1 -1
  45. package/dist/tailwindPlugin.d.ts +1 -1
  46. package/dist/tailwindPlugin.js +1 -1
  47. package/dist/tailwindPurge.cjs +1 -1
  48. package/dist/tailwindPurge.js +1 -1
  49. package/dist/tokens/index.cjs +1 -1
  50. package/dist/tokens/index.d.cts +2 -2
  51. package/dist/tokens/index.d.ts +2 -2
  52. package/dist/tokens/index.js +1 -1
  53. package/dist/tokens/index.native.cjs +1 -1
  54. package/dist/tokens/index.native.d.cts +2 -2
  55. package/dist/tokens/index.native.d.ts +2 -2
  56. package/dist/tokens/index.native.js +1 -1
  57. package/dist/tokens/parseTokens.cjs +1 -1
  58. package/dist/tokens/parseTokens.d.cts +1 -1
  59. package/dist/tokens/parseTokens.d.ts +1 -1
  60. package/dist/tokens/parseTokens.js +1 -1
  61. package/dist/tokens/parseTokens.native.d.cts +1 -1
  62. package/dist/tokens/parseTokens.native.d.ts +1 -1
  63. package/dist/{types-ZrxnB4cM.d.cts → types-CzJpH_Oi.d.cts} +2 -2
  64. package/dist/{types-ZrxnB4cM.d.ts → types-CzJpH_Oi.d.ts} +2 -2
  65. package/dist/{types-BO2kLynl.d.cts → types-FO65RM-W.d.cts} +1 -1
  66. package/dist/{types-BO2kLynl.d.ts → types-FO65RM-W.d.ts} +1 -1
  67. package/package.json +19 -2
package/cli/README.md CHANGED
@@ -8,10 +8,10 @@ Bluebun relies on Bun APIs and is designed to be extremely fast, with no-depende
8
8
 
9
9
  # Commands
10
10
 
11
- In any consumer of `@yahoo/uds` the following commands are available:
12
-
13
11
  > Please note: If you are _not_ running the CLI from a package.json script you will need to add `bun` before the binary in order to run it directly. i.e. `bun uds purge`
14
12
 
13
+ In any consumer of `@yahoo/uds` the following commands are available:
14
+
15
15
  ## Config
16
16
 
17
17
  ### Using args
@@ -23,9 +23,7 @@ In any consumer of `@yahoo/uds` the following commands are available:
23
23
 
24
24
  ```shell
25
25
  uds sync --id [id] --outFile [path]
26
- ```
27
26
 
28
- ```shell
29
27
  uds sync --id [id]
30
28
  ```
31
29
 
@@ -36,10 +34,6 @@ uds sync --id [id]
36
34
  | UDS_ID | true | |
37
35
  | UDS_OUT_FILE | false | ./uds.config.ts |
38
36
 
39
- ```shell
40
- UDS_ID=[id] uds sync --outFile [path]
41
- ```
42
-
43
37
  ```shell
44
38
  UDS_ID=[id] UDS_OUT_FILE=[path] uds sync
45
39
  ```
@@ -0,0 +1,3 @@
1
+ [test]
2
+ # Load these modules before running tests.
3
+ preload = ["./preload"]
@@ -1,6 +1,7 @@
1
1
  import fs from 'node:fs';
2
2
  import os from 'node:os';
3
3
 
4
+ // @ts-expect-error this is a transitive dep of expo, which is required in consumers to even run this setup
4
5
  import { EasJsonAccessor, EasJsonUtils, Platform } from '@expo/eas-json';
5
6
  import { print, type Props } from 'bluebun';
6
7
  import { $, semver, which } from 'bun';
@@ -4,7 +4,7 @@ import { type MobileProps, needsBinary, needsBrewFormula, setup } from './_setup
4
4
 
5
5
  export default {
6
6
  name: 'build',
7
- description: '🚀 Build',
7
+ description: '🏗️ Build',
8
8
  run: async (props: MobileProps) => {
9
9
  const { platform, profile, output } = await setup({
10
10
  props,
@@ -5,7 +5,7 @@ import { setup } from './_setup';
5
5
 
6
6
  export default {
7
7
  name: 'launch',
8
- description: '🚀 Launch',
8
+ description: '📱 Launch',
9
9
  run: async (props: MobileProps) => {
10
10
  const { platform, output } = await setup({
11
11
  props,
@@ -11,6 +11,6 @@ export default {
11
11
 
12
12
  await purge();
13
13
 
14
- spinStop('✅ Purging css done!');
14
+ spinStop('✅', 'Purging css done!');
15
15
  },
16
16
  };
@@ -1,4 +1,4 @@
1
- import { Props } from 'bluebun';
1
+ import { magenta, print, Props } from 'bluebun';
2
2
 
3
3
  import { setupConfigWorker } from '../utils/setupConfigWorker';
4
4
  import { SyncOptions } from '../utils/types';
@@ -9,10 +9,22 @@ interface SyncProps extends Props {
9
9
 
10
10
  export default {
11
11
  name: 'sync',
12
- description: '🌈 Sync',
13
- run: async ({ options }: SyncProps) => {
12
+ description: '🔄 Update to latest design config 🎨',
13
+ alias: ['update'],
14
+ run: async ({ name, commandPath, options }: SyncProps) => {
15
+ const { id = Bun.env.UDS_ID, outFile = Bun.env.UDS_OUT_FILE } = options;
16
+
17
+ if (!id || typeof id === 'boolean') {
18
+ console.error(
19
+ '\nMissing config ID. Please pass an --id flag or set the UDS_ID env variable.\n',
20
+ );
21
+ print(`${magenta('Usage:')} ${name} ${commandPath} --id <config-id>\n`);
22
+ return;
23
+ }
24
+
14
25
  await setupConfigWorker({
15
- ...options,
26
+ id,
27
+ outFile: outFile ?? './uds.config.ts',
16
28
  onUpdate: ({ worker }) => {
17
29
  if (!options.watch) {
18
30
  worker.terminate();
@@ -1,4 +1,4 @@
1
- import { type Props } from 'bluebun';
1
+ import { print, type Props, red } from 'bluebun';
2
2
 
3
3
  import { getCommandHelp } from '../utils/getCommandHelp';
4
4
 
@@ -6,6 +6,9 @@ export default {
6
6
  name: 'uds',
7
7
  description: '',
8
8
  run: async (props: Props) => {
9
+ if (props.first) {
10
+ print(red(`Unknown command: ${props.first}`));
11
+ }
9
12
  await getCommandHelp(props);
10
13
  },
11
14
  };
@@ -4,7 +4,7 @@ import packageJson from '../../package.json';
4
4
 
5
5
  export default {
6
6
  name: 'version',
7
- description: `💾 ${packageJson.version}`,
7
+ description: `${packageJson.version}`,
8
8
  run: async () => {
9
9
  print(packageJson.version);
10
10
  },
package/cli/preload.ts ADDED
@@ -0,0 +1,32 @@
1
+ import { jest, mock } from 'bun:test';
2
+
3
+ const mockFastGlob = jest.fn().mockResolvedValue(['/pages/PageA.tsx', '/pages/PageB.tsx']);
4
+
5
+ mock.module('fast-glob', () => ({ __esModule: true, default: mockFastGlob }));
6
+
7
+ mock.module('@yahoo/uds/tailwindPurge', () => ({
8
+ componentsDependencies: {
9
+ Button: ['Icon', 'Pressable', 'Text'],
10
+ Spinner: [],
11
+ HStack: ['Box'],
12
+ },
13
+ componentToVariants: {
14
+ Button: ['color'],
15
+ HStack: ['alignItems', 'justifyContent'],
16
+ Icon: ['color'],
17
+ Text: ['fontSize', 'fontFamily'],
18
+ Pressable: ['display'],
19
+ },
20
+ variantsList: ['color', 'alignItems', 'justifyContent', 'display', 'fontSize', 'fontFamily'],
21
+ variantToTailwindClass: {
22
+ color: 'text-accent text-alert text-black text-brand text-positive text-warning text-white',
23
+ alignItems: 'items-start items-end items-center items-stretch items-baseline',
24
+ justifyContent:
25
+ 'justify-start justify-end justify-center justify-between justify-around justify-evenly',
26
+ display:
27
+ 'block inline-block inline flex inline-flex table inline-table table-caption table-cell table-column table-column-group table-footer-group table-header-group table-row-group table-row flow-root grid contents',
28
+ fontSize: 'font-size-display1 font-size-title1 ',
29
+ fontFamily:
30
+ 'font-icons font-sans font-sans-beta font-sans-condensed font-serif-text font-serif-display font-display1 font-title1 font-title2 font-title3 font-title4 font-headline1 font-body1 font-label1 font-label2 font-caption1 font-caption2 font-legal1',
31
+ },
32
+ }));
@@ -1,30 +1,49 @@
1
1
  // prevents TS errors
2
2
  declare var self: Worker;
3
3
 
4
- import { $ } from 'bun';
4
+ import { UniversalTokensConfig } from '@yahoo/uds/tokens';
5
5
 
6
6
  import { ConfigWorkerThreadMessage } from './types';
7
7
 
8
+ const CLOUD_FUNCTION = 'https://syncconfig-j57v6zmjrq-uc.a.run.app';
9
+
8
10
  self.onmessage = async ({ data }: ConfigWorkerThreadMessage) => {
11
+ const { id } = data.resp;
12
+
9
13
  if (data.type === 'init') {
10
14
  try {
11
- // Only listen for updates if firebase is available. This will only be available in UDS monorepo atm
15
+ // The firebase packaage available if we're in the UDS monorepo. Listen for updates.
12
16
  const firebase = await import('database/firebase');
13
- console.write('Fetching from local database package...\n');
14
- firebase.onBranchSnapshot(data.resp.id, ({ config, status }) => {
17
+
18
+ // Bail if the branch doesn't exist in configurator.
19
+ const branchExists = await firebase.branchExists(id);
20
+ if (!branchExists) {
21
+ throw new Error(`Config id '${id}' does not exist in the Configurator.`);
22
+ }
23
+
24
+ console.log('Fetching using local database package...');
25
+
26
+ firebase.onBranchSnapshot(id, ({ config, status }) => {
15
27
  postMessage({ type: 'update', resp: { config, status } });
16
28
  });
17
29
  } catch (err) {
18
30
  try {
19
- const res =
20
- await $`curl https://syncconfig-j57v6zmjrq-uc.a.run.app?id=${data.resp.id}`.json();
21
- if (res?.config) {
22
- postMessage({ type: 'update', resp: { config: res.config, status: 'error' } });
23
- } else {
24
- throw Error;
31
+ console.log('Fetching from configurator...');
32
+
33
+ const resp = await fetch(`${CLOUD_FUNCTION}?id=${id}`);
34
+ if (!resp.ok) {
35
+ throw new Error(`Error fetching config id '${id}'. Does it exist in the Configurator?`);
25
36
  }
37
+
38
+ const { config } = ((await resp.json()) as { config: UniversalTokensConfig }) ?? {};
39
+ if (!config) {
40
+ throw new Error('Config JSON could not be parsed.');
41
+ }
42
+
43
+ postMessage({ type: 'update', resp: { config, status: 'error' } });
26
44
  } catch (err) {
27
- throw new Error('Error fetching config');
45
+ console.error(`\n${(err as Error).message}\n`);
46
+ throw err;
28
47
  }
29
48
  }
30
49
  }
@@ -1,21 +1,21 @@
1
1
  import {
2
- bold,
3
2
  calcWidestCommandName,
4
- CommandTree,
3
+ type CommandTree,
5
4
  commandTree,
6
5
  cyan,
7
6
  gray,
7
+ green,
8
+ magenta,
8
9
  print,
9
- Props,
10
+ type Props,
10
11
  white,
11
12
  } from 'bluebun';
12
13
 
13
14
  /**
14
- *
15
15
  * The formatting from bluebun for the help command is not great.
16
16
  * I forked code from https://github.com/jamonholmgren/bluebun/blob/main/src/command-help.ts
17
17
  *
18
- * TODO: Maybe create helpers for better styling control for this & other features
18
+ * TODO: create helpers for better styling control for this & other features
19
19
  *
20
20
  * Some packages to checkout:
21
21
  * - https://github.com/wobsoriano/blipgloss
@@ -29,7 +29,7 @@ async function formatHelp(initialProps: Props) {
29
29
  const _tree = await commandTree(initialProps);
30
30
  const tree = categoryToFilter ? { [categoryToFilter]: _tree[categoryToFilter] } : _tree;
31
31
 
32
- const widest = calcWidestCommandName(tree) + 5;
32
+ const widest = calcWidestCommandName(tree) + 10;
33
33
 
34
34
  function generateHelp(cmdTree: CommandTree, prefix: string): string[] {
35
35
  return Object.keys(cmdTree).flatMap((key) => {
@@ -49,16 +49,25 @@ async function formatHelp(initialProps: Props) {
49
49
 
50
50
  const helpLines = generateHelp(tree, name);
51
51
 
52
- const help = `${bold(white('Commands:'))}
53
-
54
- ${helpLines.join('\n')}
55
- `;
52
+ // https://texteditor.com/multiline-text-art/
53
+ const banner = `
54
+ █ █ █▀▄ ▄▀▀ ▄▀▀ █ █
55
+ ▀▄█ █▄▀ ▄██ ▀▄▄ █▄▄ █
56
+ Universal Design System
57
+ `.trim();
58
+
59
+ const help = `
60
+ ${green(banner)}
61
+
62
+ ${magenta(`Usage: ${white(`${name} <command>`)}`)}
63
+
64
+ ${magenta('Commands:')}
65
+ ${helpLines.join('\n')}
66
+ `;
56
67
 
57
68
  return help;
58
69
  }
59
70
 
60
71
  export async function getCommandHelp(props: Props) {
61
- print('');
62
- const helpText = await formatHelp(props);
63
- print(helpText);
72
+ print(await formatHelp(props));
64
73
  }
@@ -0,0 +1,99 @@
1
+ import { describe, expect, it } from 'bun:test';
2
+ import { Project } from 'ts-morph';
3
+
4
+ import {
5
+ getComponentsToConvertToTW,
6
+ getFiles,
7
+ getTailwindSafelist,
8
+ isUDSComponent,
9
+ parseFiles,
10
+ } from './purgeCSS';
11
+
12
+ const PAGE_A_CODE = `
13
+ import { Button } from '@yahoo/uds';
14
+
15
+ const PageA = () => {
16
+ return (
17
+ <div>
18
+ <Button> Click me </Button>
19
+ </div>
20
+ )
21
+ }
22
+ `;
23
+
24
+ const PAGE_B_CODE = `
25
+ import { HStack, Spinner } from '@yahoo/uds';
26
+ import { noop } from 'lodash';
27
+
28
+ const PageB = () => {
29
+ return (
30
+ <div>
31
+ <HStack flexGrow="1" alignItems="center" justifyContent="center">
32
+ <Spinner />
33
+ </HStack>
34
+ </div>
35
+ )
36
+ }
37
+ `;
38
+
39
+ const FILES = ['/pages/PageA.tsx', '/pages/PageB.tsx'];
40
+ const IMPORTED_UDS_COMPONENTS = ['Button', 'HStack', 'Spinner'];
41
+
42
+ describe('purgeCSS', () => {
43
+ const project = new Project();
44
+
45
+ describe('getFiles', () => {
46
+ it('returns the list of files', async () => {
47
+ const files = await getFiles();
48
+
49
+ expect(files).toEqual(FILES);
50
+ });
51
+ });
52
+
53
+ describe('parseFiles', () => {
54
+ it('returns the list of imports from @yahoo/uds', () => {
55
+ project.createSourceFile(FILES[0], PAGE_A_CODE, {
56
+ overwrite: true,
57
+ });
58
+ project.createSourceFile(FILES[1], PAGE_B_CODE, {
59
+ overwrite: true,
60
+ });
61
+
62
+ const res = parseFiles(project, FILES);
63
+
64
+ expect(res).toEqual(IMPORTED_UDS_COMPONENTS);
65
+ });
66
+ });
67
+
68
+ describe('getTailwindSafelist', () => {
69
+ it('returns the tailwind classes corresponding to the props on a component', () => {
70
+ const res = getTailwindSafelist(IMPORTED_UDS_COMPONENTS);
71
+
72
+ expect(res).toEqual(
73
+ 'text-accent text-alert text-black text-brand text-positive text-warning text-white items-start items-end items-center items-stretch items-baseline justify-start justify-end justify-center justify-between justify-around justify-evenly ',
74
+ );
75
+ });
76
+ });
77
+
78
+ describe('getComponentsToConvertToTW', () => {
79
+ it('should get just exports which are components from UDS', () => {
80
+ const res = getComponentsToConvertToTW(['Button', 'HStack', 'randomThingy']);
81
+
82
+ expect(res).toEqual(['Button', 'Icon', 'Pressable', 'Text', 'HStack', 'Box']);
83
+ });
84
+ });
85
+
86
+ describe('isUDSComponent', () => {
87
+ it('returns true if the component is exported from UDS', () => {
88
+ const res = isUDSComponent('Button');
89
+
90
+ expect(res).toBeTrue();
91
+ });
92
+
93
+ it('returns false if the component is not exported from UDS', () => {
94
+ const res = isUDSComponent('NotUdsComponent');
95
+
96
+ expect(res).toBeFalse();
97
+ });
98
+ });
99
+ });
@@ -17,7 +17,7 @@ type Files = string[];
17
17
  // TODO: use CLI args to power the output file path
18
18
  const OUTPUT_FILE_PATH = Bun.file(`${Bun.env.PWD}/dist/safelist.js`);
19
19
 
20
- const getFiles = async (): Promise<Files> => {
20
+ export const getFiles = async (): Promise<Files> => {
21
21
  const workspaceDir = Bun.env.PWD;
22
22
  const srcDir = path.join(workspaceDir, '/src/');
23
23
  const files = await FastGlob(`${srcDir}/**/*.{jsx,tsx}`);
@@ -28,7 +28,7 @@ const getFiles = async (): Promise<Files> => {
28
28
  /**
29
29
  * Given a file it returns the list of imports from @yahoo/uds
30
30
  */
31
- const parseFiles = (project: Project, files: Files): ImportsList => {
31
+ export const parseFiles = (project: Project, files: Files): ImportsList => {
32
32
  const importsSet = new Set();
33
33
 
34
34
  const importsPerFile: string[] = files
@@ -59,13 +59,11 @@ const parseFiles = (project: Project, files: Files): ImportsList => {
59
59
  return Array.from(importsSet) as string[];
60
60
  };
61
61
 
62
- const getTailwindSafelist = (componentList: string[]): SafeList => {
62
+ export const getTailwindSafelist = (componentList: string[]): SafeList => {
63
63
  const validVariants = new Set<string>(variantsList);
64
64
  const usedProps = new Set<string>();
65
65
  componentList.forEach((component: string) => {
66
66
  if (isUDSComponent(component)) {
67
- // go through the list of props of that particular component
68
- // and get the related tailwind classes
69
67
  componentToVariants[component].forEach((prop: string) => {
70
68
  if (validVariants.has(prop) && !usedProps.has(prop)) {
71
69
  usedProps.add(prop);
@@ -81,7 +79,7 @@ const getTailwindSafelist = (componentList: string[]): SafeList => {
81
79
  return safeList;
82
80
  };
83
81
 
84
- const isUDSComponent = (component: string): boolean => {
82
+ export const isUDSComponent = (component: string): boolean => {
85
83
  return !!componentToVariants[component];
86
84
  };
87
85
 
@@ -96,7 +94,7 @@ const saveToFile = async (safeList: SafeList) => {
96
94
  await Bun.write(OUTPUT_FILE_PATH, fileContent);
97
95
  };
98
96
 
99
- const getComponentsToConvertToTW = (udsImport: ImportsList): string[] => {
97
+ export const getComponentsToConvertToTW = (udsImport: ImportsList): string[] => {
100
98
  // filter out just the components
101
99
  const components = udsImport.filter((importedItem) => !!componentToVariants[importedItem]);
102
100
  const set = new Set();
@@ -2,52 +2,22 @@ import path from 'node:path';
2
2
 
3
3
  import { sortKeys } from './sortKeys';
4
4
  import { ConfigWorkerMainThreadMessage, SyncOptions } from './types';
5
-
6
- const workerPath = path.resolve(import.meta.dir, './configWorker');
7
- const workerURL = new URL(Bun.pathToFileURL(workerPath)).href;
8
-
9
5
  interface ConfigWorkerOptions extends SyncOptions {
10
6
  onUpdate?: (params: { worker: Worker }) => void;
11
7
  }
12
8
 
13
- export async function setupConfigWorker({
14
- id = Bun.env.UDS_ID,
15
- outFile = Bun.env.UDS_OUT_FILE,
16
- onUpdate,
17
- }: ConfigWorkerOptions = {}) {
18
- const workspaceDir = Bun.env.PWD;
19
- let configID = id;
20
- let configOutFile = outFile ?? './uds.config.ts';
21
-
22
- // If we didn't get the config ID from the command line or env vars, check for a uds.json file
23
- if (!configID) {
24
- const udsConfigFile = Bun.file(`${workspaceDir}/uds.json`);
25
- const udsConfigFileExists = await udsConfigFile.exists();
26
- if (udsConfigFileExists) {
27
- const configJsonFile = (await udsConfigFile.json()) as { id: string; outFile: string };
28
-
29
- configID = configJsonFile.id;
30
- configOutFile = configJsonFile.outFile;
31
- }
32
- }
33
-
34
- // have _nothing_, warn the eng to do something
35
- if (!configID) {
36
- console.error(
37
- '\nMissing config ID. Please pass in --id, set UDS_ID in your .env, or create a uds.json file with { "id": "your-config-id" } defined.\n',
38
- );
39
- process.exit(1);
40
- }
41
-
42
- const outFilePath = `${workspaceDir}/${configOutFile}`;
9
+ export async function setupConfigWorker({ id, outFile, onUpdate }: ConfigWorkerOptions) {
10
+ const workerPath = path.resolve(import.meta.dir, './configWorker');
11
+ const workerURL = Bun.pathToFileURL(workerPath).href;
12
+ const outFilePath = `${Bun.env.PWD}/${outFile}`;
43
13
 
44
14
  const worker = new Worker(workerURL);
45
15
 
46
16
  worker.addEventListener('open', () => {
47
- worker.postMessage({ type: 'init', resp: { id: configID } });
17
+ worker.postMessage({ type: 'init', resp: { id } });
48
18
  });
49
19
 
50
- worker.onmessage = async ({ data }: ConfigWorkerMainThreadMessage) => {
20
+ worker.addEventListener('message', async ({ data }: ConfigWorkerMainThreadMessage) => {
51
21
  if (data.type === 'update') {
52
22
  // Firebase does not guarantee the order of the keys in the config
53
23
  // this can give us a false diff when writing to existing file
@@ -59,11 +29,11 @@ import { type UniversalTokensConfig } from '@yahoo/uds';
59
29
  export const config: UniversalTokensConfig = ${JSON.stringify(sortedConfig, null, 2)};
60
30
  `.trimStart();
61
31
 
62
- console.log(`✅ Synced UDS config ${configID} to ${outFilePath}`);
32
+ console.log(`✅ Synced UDS config ${id} to ${outFilePath}`);
63
33
  await Bun.write(outFilePath, configContent);
64
34
  onUpdate?.({ worker });
65
35
  }
66
- };
36
+ });
67
37
 
68
38
  // Register a handler for the SIGINT signal (Ctrl + C)
69
39
  process.on('SIGINT', () => {
@@ -7,7 +7,10 @@ export type ConfigWorkerMainThreadMessage = MessageEvent<{
7
7
  }>;
8
8
 
9
9
  export type SyncOptions = {
10
- id?: string;
11
- outFile?: string;
10
+ /** Configurator (branch) id */
11
+ id: string;
12
+ /** The file to write the config to. Defaults to uds.config.ts. */
13
+ outFile: string;
14
+ /** Enable watch mode? */
12
15
  watch?: boolean;
13
16
  };
@@ -0,0 +1,38 @@
1
+ import * as react from 'react';
2
+ import { l as UniversalPressableProps, n as UniversalIconButtonProps, o as UniversalImageProps } from './types-CzJpH_Oi.js';
3
+ import { View, PressableProps as PressableProps$1, StyleProp, ViewStyle } from 'react-native';
4
+ import * as react_jsx_runtime from 'react/jsx-runtime';
5
+ import { ImageProps as ImageProps$1 } from 'expo-image';
6
+
7
+ type NativePressableProps = Omit<PressableProps$1, 'children' | 'style' | 'onPress'> & {
8
+ style?: StyleProp<ViewStyle>;
9
+ };
10
+ interface PressableProps extends UniversalPressableProps, NativePressableProps {
11
+ }
12
+ declare const Pressable: react.ForwardRefExoticComponent<PressableProps & react.RefAttributes<View>>;
13
+
14
+ interface IconButtonProps extends PressableProps, UniversalIconButtonProps {
15
+ }
16
+ /**
17
+ * An icon button element that can be used to trigger an action.
18
+ * @example
19
+ ```tsx
20
+ import { IconButton } from "@yahoo/uds"
21
+
22
+ export function IconButtonDemo() {
23
+ return (
24
+ <IconButton variant="accent-outline" name="close" onPress={console.log} />
25
+ )
26
+ }
27
+ ```
28
+ */
29
+ declare const IconButton: react.ForwardRefExoticComponent<IconButtonProps & react.RefAttributes<View>>;
30
+
31
+ interface ImageProps extends Omit<ImageProps$1, 'alt' | 'source'>, UniversalImageProps {
32
+ }
33
+ /**
34
+ * An image element
35
+ */
36
+ declare function Image({ width: imageWidth, height: imageHeight, src, alt, contentFit, elevation, backgroundColor, backgroundColorOnActive, backgroundColorOnHover, backgroundColorOnChecked, opacity, bordered, borderedTop, borderedBottom, borderedStart, borderedEnd, borderedHorizontal, borderedVertical, borderRadius, borderTopStartRadius, borderTopEndRadius, borderBottomStartRadius, borderBottomEndRadius, borderColor, borderColorOnActive, borderColorOnFocus, borderColorOnChecked, borderColorOnHover, borderStartColor, borderEndColor, borderTopColor, borderBottomColor, borderWidth, borderVerticalWidth, borderHorizontalWidth, borderStartWidth, borderEndWidth, borderTopWidth, borderBottomWidth, alignContent, alignItems, alignSelf, flex, flexDirection, flexGrow, flexShrink, flexWrap, justifyContent, flexBasis, display, zIndex, overflow, overflowX, overflowY, position, spacing, spacingHorizontal, spacingVertical, spacingBottom, spacingEnd, spacingStart, spacingTop, offset, offsetVertical, offsetHorizontal, offsetBottom, offsetEnd, offsetStart, offsetTop, columnGap, rowGap, minHeight, maxHeight, minWidth, maxWidth, ...props }: ImageProps): react_jsx_runtime.JSX.Element;
37
+
38
+ export { type ImageProps as I, type PressableProps as P, IconButton as a, type IconButtonProps as b, Image as c, Pressable as d };
@@ -0,0 +1,38 @@
1
+ import * as react from 'react';
2
+ import { l as UniversalPressableProps, n as UniversalIconButtonProps, o as UniversalImageProps } from './types-CzJpH_Oi.cjs';
3
+ import { View, PressableProps as PressableProps$1, StyleProp, ViewStyle } from 'react-native';
4
+ import * as react_jsx_runtime from 'react/jsx-runtime';
5
+ import { ImageProps as ImageProps$1 } from 'expo-image';
6
+
7
+ type NativePressableProps = Omit<PressableProps$1, 'children' | 'style' | 'onPress'> & {
8
+ style?: StyleProp<ViewStyle>;
9
+ };
10
+ interface PressableProps extends UniversalPressableProps, NativePressableProps {
11
+ }
12
+ declare const Pressable: react.ForwardRefExoticComponent<PressableProps & react.RefAttributes<View>>;
13
+
14
+ interface IconButtonProps extends PressableProps, UniversalIconButtonProps {
15
+ }
16
+ /**
17
+ * An icon button element that can be used to trigger an action.
18
+ * @example
19
+ ```tsx
20
+ import { IconButton } from "@yahoo/uds"
21
+
22
+ export function IconButtonDemo() {
23
+ return (
24
+ <IconButton variant="accent-outline" name="close" onPress={console.log} />
25
+ )
26
+ }
27
+ ```
28
+ */
29
+ declare const IconButton: react.ForwardRefExoticComponent<IconButtonProps & react.RefAttributes<View>>;
30
+
31
+ interface ImageProps extends Omit<ImageProps$1, 'alt' | 'source'>, UniversalImageProps {
32
+ }
33
+ /**
34
+ * An image element
35
+ */
36
+ declare function Image({ width: imageWidth, height: imageHeight, src, alt, contentFit, elevation, backgroundColor, backgroundColorOnActive, backgroundColorOnHover, backgroundColorOnChecked, opacity, bordered, borderedTop, borderedBottom, borderedStart, borderedEnd, borderedHorizontal, borderedVertical, borderRadius, borderTopStartRadius, borderTopEndRadius, borderBottomStartRadius, borderBottomEndRadius, borderColor, borderColorOnActive, borderColorOnFocus, borderColorOnChecked, borderColorOnHover, borderStartColor, borderEndColor, borderTopColor, borderBottomColor, borderWidth, borderVerticalWidth, borderHorizontalWidth, borderStartWidth, borderEndWidth, borderTopWidth, borderBottomWidth, alignContent, alignItems, alignSelf, flex, flexDirection, flexGrow, flexShrink, flexWrap, justifyContent, flexBasis, display, zIndex, overflow, overflowX, overflowY, position, spacing, spacingHorizontal, spacingVertical, spacingBottom, spacingEnd, spacingStart, spacingTop, offset, offsetVertical, offsetHorizontal, offsetBottom, offsetEnd, offsetStart, offsetTop, columnGap, rowGap, minHeight, maxHeight, minWidth, maxWidth, ...props }: ImageProps): react_jsx_runtime.JSX.Element;
37
+
38
+ export { type ImageProps as I, type PressableProps as P, IconButton as a, type IconButtonProps as b, Image as c, Pressable as d };