boss-css 0.0.20 → 0.0.22

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 (148) hide show
  1. package/dist/ai/server.d.cts +9 -0
  2. package/dist/ai/server.d.mts +9 -0
  3. package/dist/ai/skills.d.cts +13 -0
  4. package/dist/ai/skills.d.mts +13 -0
  5. package/dist/api/browser.d.cts +7 -0
  6. package/dist/api/browser.d.mts +7 -0
  7. package/dist/api/config.d.cts +6 -0
  8. package/dist/api/config.d.mts +6 -0
  9. package/dist/api/dictionary.d.cts +29 -0
  10. package/dist/api/dictionary.d.mts +29 -0
  11. package/dist/api/noopCss.d.cts +29 -0
  12. package/dist/api/noopCss.d.mts +29 -0
  13. package/dist/api/server.d.cts +7 -0
  14. package/dist/api/server.d.mts +7 -0
  15. package/dist/cli/index.d.cts +1 -0
  16. package/dist/cli/index.d.mts +1 -0
  17. package/dist/compile/runtime.d.cts +5 -0
  18. package/dist/compile/runtime.d.mts +5 -0
  19. package/dist/cx/index.d.cts +15 -0
  20. package/dist/cx/index.d.mts +15 -0
  21. package/dist/detect-fw/index.d.cts +47 -0
  22. package/dist/detect-fw/index.d.mts +47 -0
  23. package/dist/dev/client.d.cts +10 -0
  24. package/dist/dev/client.d.mts +10 -0
  25. package/dist/dev/plugin/browser.d.cts +7 -0
  26. package/dist/dev/plugin/browser.d.mts +7 -0
  27. package/dist/dev/plugin/server.d.cts +8 -0
  28. package/dist/dev/plugin/server.d.mts +8 -0
  29. package/dist/dev/runtime.d.cts +1 -0
  30. package/dist/dev/runtime.d.mts +1 -0
  31. package/dist/dev/server.d.cts +16 -0
  32. package/dist/dev/server.d.mts +16 -0
  33. package/dist/devtools-app/index.mjs +192 -192
  34. package/dist/eslint-plugin/index.d.cts +1472 -0
  35. package/dist/eslint-plugin/index.d.mts +1473 -0
  36. package/dist/fontsource/directory.d.cts +19 -0
  37. package/dist/fontsource/directory.d.mts +19 -0
  38. package/dist/fontsource/server.d.cts +7 -0
  39. package/dist/fontsource/server.d.mts +7 -0
  40. package/dist/fontsource/types.d.cts +37 -0
  41. package/dist/fontsource/types.d.mts +37 -0
  42. package/dist/index.d.cts +6 -0
  43. package/dist/index.d.mts +6 -0
  44. package/dist/merge/index.d.cts +18 -0
  45. package/dist/merge/index.d.mts +18 -0
  46. package/dist/native/browser.d.cts +7 -0
  47. package/dist/native/browser.d.mts +7 -0
  48. package/dist/native/server.d.cts +9 -0
  49. package/dist/native/server.d.mts +9 -0
  50. package/dist/parser/classname/server.d.cts +7 -0
  51. package/dist/parser/classname/server.d.mts +7 -0
  52. package/dist/parser/jsx/browser.d.cts +7 -0
  53. package/dist/parser/jsx/browser.d.mts +7 -0
  54. package/dist/parser/jsx/native.d.cts +7 -0
  55. package/dist/parser/jsx/native.d.mts +7 -0
  56. package/dist/parser/jsx/runtime.d.cts +2 -0
  57. package/dist/parser/jsx/runtime.d.mts +2 -0
  58. package/dist/parser/jsx/server.d.cts +9 -0
  59. package/dist/parser/jsx/server.d.mts +9 -0
  60. package/dist/postcss/index.d.cts +12 -0
  61. package/dist/postcss/index.d.mts +12 -0
  62. package/dist/prop/at/runtime-only.d.cts +8 -0
  63. package/dist/prop/at/runtime-only.d.mts +8 -0
  64. package/dist/prop/at/server.d.cts +13 -0
  65. package/dist/prop/at/server.d.mts +13 -0
  66. package/dist/prop/bosswind/browser.d.cts +8 -0
  67. package/dist/prop/bosswind/browser.d.mts +8 -0
  68. package/dist/prop/bosswind/runtime-only.d.cts +8 -0
  69. package/dist/prop/bosswind/runtime-only.d.mts +8 -0
  70. package/dist/prop/bosswind/server.d.cts +9 -0
  71. package/dist/prop/bosswind/server.d.mts +9 -0
  72. package/dist/prop/bosswind/shared.d.cts +11 -0
  73. package/dist/prop/bosswind/shared.d.mts +11 -0
  74. package/dist/prop/child/runtime-only.d.cts +8 -0
  75. package/dist/prop/child/runtime-only.d.mts +8 -0
  76. package/dist/prop/child/server.d.cts +9 -0
  77. package/dist/prop/child/server.d.mts +9 -0
  78. package/dist/prop/css/runtime-only.d.cts +5 -0
  79. package/dist/prop/css/runtime-only.d.mts +5 -0
  80. package/dist/prop/css/server.d.cts +9 -0
  81. package/dist/prop/css/server.d.mts +9 -0
  82. package/dist/prop/pseudo/runtime-only.d.cts +8 -0
  83. package/dist/prop/pseudo/runtime-only.d.mts +8 -0
  84. package/dist/prop/pseudo/server.d.cts +9 -0
  85. package/dist/prop/pseudo/server.d.mts +9 -0
  86. package/dist/reset/server.d.cts +7 -0
  87. package/dist/reset/server.d.mts +7 -0
  88. package/dist/runtime/index.d.cts +20 -0
  89. package/dist/runtime/index.d.mts +20 -0
  90. package/dist/runtime/preact.d.cts +2 -0
  91. package/dist/runtime/preact.d.mts +2 -0
  92. package/dist/runtime/qwik.d.cts +8 -0
  93. package/dist/runtime/qwik.d.mts +8 -0
  94. package/dist/runtime/react.d.cts +2 -0
  95. package/dist/runtime/react.d.mts +2 -0
  96. package/dist/runtime/solid.d.cts +6 -0
  97. package/dist/runtime/solid.d.mts +6 -0
  98. package/dist/runtime/stencil.d.cts +7 -0
  99. package/dist/runtime/stencil.d.mts +7 -0
  100. package/dist/runtime/style.d.cts +4 -0
  101. package/dist/runtime/style.d.mts +4 -0
  102. package/dist/shared/types.d.cts +96 -0
  103. package/dist/shared/types.d.mts +96 -0
  104. package/dist/strategy/classic/runtime-only.d.cts +7 -0
  105. package/dist/strategy/classic/runtime-only.d.mts +7 -0
  106. package/dist/strategy/classname-first/browser.d.cts +7 -0
  107. package/dist/strategy/classname-first/browser.d.mts +7 -0
  108. package/dist/strategy/classname-first/runtime-only.d.cts +7 -0
  109. package/dist/strategy/classname-first/runtime-only.d.mts +7 -0
  110. package/dist/strategy/classname-first/server.d.cts +9 -0
  111. package/dist/strategy/classname-first/server.d.mts +9 -0
  112. package/dist/strategy/classname-only/server.d.cts +8 -0
  113. package/dist/strategy/classname-only/server.d.mts +8 -0
  114. package/dist/strategy/inline-first/browser.d.cts +7 -0
  115. package/dist/strategy/inline-first/browser.d.mts +7 -0
  116. package/dist/strategy/inline-first/runtime-only.d.cts +7 -0
  117. package/dist/strategy/inline-first/runtime-only.d.mts +7 -0
  118. package/dist/strategy/inline-first/server.d.cts +9 -0
  119. package/dist/strategy/inline-first/server.d.mts +9 -0
  120. package/dist/strategy/runtime/runtime-only.d.cts +9 -0
  121. package/dist/strategy/runtime/runtime-only.d.mts +9 -0
  122. package/dist/strategy/runtime/server.d.cts +9 -0
  123. package/dist/strategy/runtime/server.d.mts +9 -0
  124. package/dist/strategy/runtime-only/css.d.cts +43 -0
  125. package/dist/strategy/runtime-only/css.d.mts +43 -0
  126. package/dist/tasks/build.d.cts +23 -0
  127. package/dist/tasks/build.d.mts +23 -0
  128. package/dist/tasks/compile.d.cts +31 -0
  129. package/dist/tasks/compile.d.mts +31 -0
  130. package/dist/tasks/postcss.cjs +8 -13
  131. package/dist/tasks/postcss.d.cts +10 -0
  132. package/dist/tasks/postcss.d.mts +10 -0
  133. package/dist/tasks/postcss.mjs +8 -13
  134. package/dist/tasks/session.d.cts +12 -0
  135. package/dist/tasks/session.d.mts +12 -0
  136. package/dist/tasks/watch.d.cts +17 -0
  137. package/dist/tasks/watch.d.mts +17 -0
  138. package/dist/types/Plugin.d.cts +251 -0
  139. package/dist/types/Plugin.d.mts +251 -0
  140. package/dist/use/token/browser.d.cts +16 -0
  141. package/dist/use/token/browser.d.mts +16 -0
  142. package/dist/use/token/propMap.d.cts +8 -0
  143. package/dist/use/token/propMap.d.mts +8 -0
  144. package/dist/use/token/runtime-only.d.cts +22 -0
  145. package/dist/use/token/runtime-only.d.mts +22 -0
  146. package/dist/use/token/server.d.cts +19 -0
  147. package/dist/use/token/server.d.mts +19 -0
  148. package/package.json +1 -1
@@ -91,7 +91,6 @@ const runPostcss = async (root, result, options = {}) => {
91
91
  promises.push(require_processFile.default(file));
92
92
  });
93
93
  const processedFiles = await Promise.allSettled(promises);
94
- const onParseTasks = [];
95
94
  for (const settled of processedFiles) {
96
95
  if (settled.status !== "fulfilled") continue;
97
96
  const processed = settled.value;
@@ -100,19 +99,15 @@ const runPostcss = async (root, result, options = {}) => {
100
99
  const changedPath = value.path ? node_path.default.resolve(value.path) : null;
101
100
  if (changedPath) api.css?.removeSource?.(changedPath);
102
101
  const sourcePath = changedPath ?? value.path ?? "(unknown file)";
103
- onParseTasks.push({
104
- filePath: sourcePath,
105
- promise: api.trigger("onParse", value)
106
- });
102
+ try {
103
+ await api.trigger("onParse", value);
104
+ } catch (parseError) {
105
+ const relativePath = node_path.default.relative(baseDir ?? process.cwd(), sourcePath);
106
+ const sourceLabel = relativePath && !relativePath.startsWith("..") ? relativePath : sourcePath;
107
+ const reason = parseError instanceof Error ? parseError.message : String(parseError ?? "Unknown parsing error");
108
+ result.warn(`[boss-css] Failed parsing ${sourceLabel}: ${reason}`, { plugin: "boss-postcss-plugin" });
109
+ }
107
110
  }
108
- (await Promise.allSettled(onParseTasks.map((task) => task.promise))).forEach((parseResult, index) => {
109
- if (parseResult.status !== "rejected") return;
110
- const task = onParseTasks[index];
111
- const relativePath = node_path.default.relative(baseDir ?? process.cwd(), task.filePath);
112
- const sourceLabel = relativePath && !relativePath.startsWith("..") ? relativePath : task.filePath;
113
- const reason = parseResult.reason instanceof Error ? parseResult.reason.message : String(parseResult.reason ?? "Unknown parsing error");
114
- result.warn(`[boss-css] Failed parsing ${sourceLabel}: ${reason}`, { plugin: "boss-postcss-plugin" });
115
- });
116
111
  const boundaryResult = await require_boundaries.resolveBoundaryOutputs(api, {
117
112
  rootDir: baseDir ?? process.cwd(),
118
113
  stylesheetPath,
@@ -0,0 +1,10 @@
1
+ import postcss from "postcss";
2
+
3
+ //#region src/tasks/postcss.d.ts
4
+ type BossPostcssOptions = {
5
+ baseDir?: string;
6
+ dirDependencies?: boolean;
7
+ };
8
+ declare const runPostcss: (root: postcss.Root, result: postcss.Result, options?: BossPostcssOptions) => Promise<void>;
9
+ //#endregion
10
+ export { BossPostcssOptions, runPostcss };
@@ -0,0 +1,10 @@
1
+ import postcss from "postcss";
2
+
3
+ //#region src/tasks/postcss.d.ts
4
+ type BossPostcssOptions = {
5
+ baseDir?: string;
6
+ dirDependencies?: boolean;
7
+ };
8
+ declare const runPostcss: (root: postcss.Root, result: postcss.Result, options?: BossPostcssOptions) => Promise<void>;
9
+ //#endregion
10
+ export { BossPostcssOptions, runPostcss };
@@ -88,7 +88,6 @@ const runPostcss = async (root, result, options = {}) => {
88
88
  promises.push(processFile(file));
89
89
  });
90
90
  const processedFiles = await Promise.allSettled(promises);
91
- const onParseTasks = [];
92
91
  for (const settled of processedFiles) {
93
92
  if (settled.status !== "fulfilled") continue;
94
93
  const processed = settled.value;
@@ -97,19 +96,15 @@ const runPostcss = async (root, result, options = {}) => {
97
96
  const changedPath = value.path ? path.resolve(value.path) : null;
98
97
  if (changedPath) api.css?.removeSource?.(changedPath);
99
98
  const sourcePath = changedPath ?? value.path ?? "(unknown file)";
100
- onParseTasks.push({
101
- filePath: sourcePath,
102
- promise: api.trigger("onParse", value)
103
- });
99
+ try {
100
+ await api.trigger("onParse", value);
101
+ } catch (parseError) {
102
+ const relativePath = path.relative(baseDir ?? process.cwd(), sourcePath);
103
+ const sourceLabel = relativePath && !relativePath.startsWith("..") ? relativePath : sourcePath;
104
+ const reason = parseError instanceof Error ? parseError.message : String(parseError ?? "Unknown parsing error");
105
+ result.warn(`[boss-css] Failed parsing ${sourceLabel}: ${reason}`, { plugin: "boss-postcss-plugin" });
106
+ }
104
107
  }
105
- (await Promise.allSettled(onParseTasks.map((task) => task.promise))).forEach((parseResult, index) => {
106
- if (parseResult.status !== "rejected") return;
107
- const task = onParseTasks[index];
108
- const relativePath = path.relative(baseDir ?? process.cwd(), task.filePath);
109
- const sourceLabel = relativePath && !relativePath.startsWith("..") ? relativePath : task.filePath;
110
- const reason = parseResult.reason instanceof Error ? parseResult.reason.message : String(parseResult.reason ?? "Unknown parsing error");
111
- result.warn(`[boss-css] Failed parsing ${sourceLabel}: ${reason}`, { plugin: "boss-postcss-plugin" });
112
- });
113
108
  const boundaryResult = await resolveBoundaryOutputs(api, {
114
109
  rootDir: baseDir ?? process.cwd(),
115
110
  stylesheetPath,
@@ -0,0 +1,12 @@
1
+ //#region src/tasks/session.d.ts
2
+ type SessionPhase = 'start' | 'run' | 'stop';
3
+ type SessionKind = 'watch' | 'postcss' | 'build' | 'compile' | 'custom';
4
+ type SessionPayload = {
5
+ phase: SessionPhase;
6
+ kind: SessionKind;
7
+ baseDir: string;
8
+ configPath: string | null;
9
+ runtimePath: string | null;
10
+ };
11
+ //#endregion
12
+ export { SessionPayload };
@@ -0,0 +1,12 @@
1
+ //#region src/tasks/session.d.ts
2
+ type SessionPhase = 'start' | 'run' | 'stop';
3
+ type SessionKind = 'watch' | 'postcss' | 'build' | 'compile' | 'custom';
4
+ type SessionPayload = {
5
+ phase: SessionPhase;
6
+ kind: SessionKind;
7
+ baseDir: string;
8
+ configPath: string | null;
9
+ runtimePath: string | null;
10
+ };
11
+ //#endregion
12
+ export { SessionPayload };
@@ -0,0 +1,17 @@
1
+ import { UserConfig } from "../shared/types.cjs";
2
+ import { BuildResult } from "./build.cjs";
3
+
4
+ //#region src/tasks/watch.d.ts
5
+ type WatchResult = {
6
+ close: () => Promise<void>;
7
+ };
8
+ type WatchOptions = {
9
+ baseDir?: string;
10
+ debounceMs?: number;
11
+ onBuild?: (result: BuildResult) => void;
12
+ onError?: (error: Error) => void;
13
+ onReady?: () => void;
14
+ };
15
+ declare const runWatch: (userConfig: UserConfig, options?: WatchOptions) => Promise<WatchResult>;
16
+ //#endregion
17
+ export { WatchOptions, WatchResult, runWatch };
@@ -0,0 +1,17 @@
1
+ import { UserConfig } from "../shared/types.mjs";
2
+ import { BuildResult } from "./build.mjs";
3
+
4
+ //#region src/tasks/watch.d.ts
5
+ type WatchResult = {
6
+ close: () => Promise<void>;
7
+ };
8
+ type WatchOptions = {
9
+ baseDir?: string;
10
+ debounceMs?: number;
11
+ onBuild?: (result: BuildResult) => void;
12
+ onError?: (error: Error) => void;
13
+ onReady?: () => void;
14
+ };
15
+ declare const runWatch: (userConfig: UserConfig, options?: WatchOptions) => Promise<WatchResult>;
16
+ //#endregion
17
+ export { WatchOptions, WatchResult, runWatch };
@@ -0,0 +1,251 @@
1
+ import { DebugValue, UserConfig } from "../shared/types.cjs";
2
+ import { FrameworkDescriptor } from "../detect-fw/index.cjs";
3
+ import { Dictionary } from "../api/dictionary.cjs";
4
+ import { SessionPayload } from "../tasks/session.cjs";
5
+
6
+ //#region src/types/Plugin.d.ts
7
+ type BossPropPrimitive = string | number | boolean | null | undefined;
8
+ type BossProp = {
9
+ value: BossPropValue;
10
+ dynamic?: boolean;
11
+ isFn?: boolean;
12
+ ast?: unknown;
13
+ code?: string;
14
+ selectorValue?: unknown;
15
+ selectorName?: string;
16
+ classToken?: string;
17
+ important?: boolean;
18
+ named?: string;
19
+ rawName?: string;
20
+ query?: string | null;
21
+ tokenKey?: string;
22
+ tokenPath?: string;
23
+ [key: string]: unknown;
24
+ };
25
+ type BossPropTree = Record<string, BossProp>;
26
+ type BossPropValue = BossPropPrimitive | BossPropTree | BossProp[] | Record<string, unknown> | unknown[];
27
+ type BossParseInput = {
28
+ content: string;
29
+ path?: string;
30
+ file?: string;
31
+ preparedOnly?: boolean;
32
+ [key: string]: unknown;
33
+ };
34
+ type BossPropTreePayload = {
35
+ input: Record<string, unknown>;
36
+ tree: BossPropTree;
37
+ preferVariables?: boolean;
38
+ parser?: 'jsx' | 'classname' | string;
39
+ file?: BossParseInput | {
40
+ path?: string;
41
+ file?: string;
42
+ } | null;
43
+ code?: string;
44
+ };
45
+ type BossPropPayload = {
46
+ name: string;
47
+ prop: BossProp;
48
+ contexts: string[];
49
+ preferVariables?: boolean;
50
+ file?: BossParseInput | {
51
+ path?: string;
52
+ file?: string;
53
+ } | null;
54
+ };
55
+ type BossCompilePropPayload = {
56
+ name: string;
57
+ prop: BossProp;
58
+ output: Record<string, BossProp | unknown>;
59
+ tag?: string;
60
+ file?: BossParseInput | {
61
+ path?: string;
62
+ file?: string;
63
+ } | null;
64
+ keep?: boolean;
65
+ remove?: boolean;
66
+ };
67
+ type BossBrowserObjectPayload = {
68
+ input: Record<string, unknown>;
69
+ output?: Record<string, unknown>;
70
+ tag?: string;
71
+ contexts?: string[];
72
+ };
73
+ type BossMetaDataPayload = {
74
+ kind: string;
75
+ data?: unknown;
76
+ label?: string;
77
+ type?: string;
78
+ [key: string]: unknown;
79
+ };
80
+ type BossPluginEventName = 'onBoot' | 'onReady' | 'onParse' | 'onPropTree' | 'onProp' | 'onCompileProp' | 'onInit' | 'onBrowserObjectStart' | 'onSession' | 'onMetaData';
81
+ type BossPluginEventPayload = {
82
+ onBoot: void;
83
+ onReady: void;
84
+ onParse: BossParseInput;
85
+ onPropTree: BossPropTreePayload;
86
+ onProp: BossPropPayload;
87
+ onCompileProp: BossCompilePropPayload;
88
+ onInit: void;
89
+ onBrowserObjectStart: BossBrowserObjectPayload;
90
+ onSession: SessionPayload;
91
+ onMetaData: BossMetaDataPayload;
92
+ };
93
+ type BossCssSelectorInput = {
94
+ className?: string | null;
95
+ selector?: string | null;
96
+ pseudos?: string[];
97
+ query?: string | null;
98
+ source?: string | null;
99
+ };
100
+ type BossCssRuleOptions = {
101
+ important?: boolean;
102
+ };
103
+ type BossCssCustomBlock = {
104
+ start: number;
105
+ end: number;
106
+ cssText: string;
107
+ };
108
+ type BossLogger = {
109
+ namespace: string;
110
+ enabled: boolean;
111
+ log: (...args: any[]) => void;
112
+ child: (name: string) => BossLogger;
113
+ };
114
+ interface BossCssLike {
115
+ text: string;
116
+ source?: string | null;
117
+ setSource?: (source: string | null) => void;
118
+ selector: (input: BossCssSelectorInput) => void;
119
+ rule: (property: string, value: unknown, options?: BossCssRuleOptions) => void;
120
+ addRule: (rule: string, query?: string | null, source?: string | null) => void;
121
+ addImport: (url: string) => void;
122
+ addRoot: (value: string, source?: string | null) => void;
123
+ removeSource: (source: string | null | undefined) => void;
124
+ write: () => void;
125
+ reset: () => void;
126
+ snapshot?: () => unknown;
127
+ restore?: (snapshot: unknown) => void;
128
+ syncCustomBlocks?: (file: string | undefined, blocks: BossCssCustomBlock[]) => void;
129
+ getCustomText?: () => string;
130
+ current?: unknown;
131
+ imports?: Set<string>;
132
+ root?: Set<string>;
133
+ }
134
+ type BossFileSection = 'head' | 'import' | 'body' | 'foot';
135
+ type BossFileEntry = {
136
+ content: unknown;
137
+ test?: () => boolean;
138
+ };
139
+ interface BossFileBase {
140
+ get: (section: BossFileSection) => Map<unknown, BossFileEntry>;
141
+ set: (section: BossFileSection, key: unknown, content: unknown, test?: () => boolean) => this;
142
+ append: (section: BossFileSection, key: unknown, content: string, test?: () => boolean) => this;
143
+ prepend: (section: BossFileSection, key: unknown, content: string, test?: () => boolean) => this;
144
+ replace: (section: BossFileSection, key: unknown, callback: (value: BossFileEntry | BossFileEntry['content']) => BossFileEntry | string) => this;
145
+ write: () => Promise<void>;
146
+ text: string;
147
+ hasContent: boolean;
148
+ }
149
+ interface BossDtsFile extends BossFileBase {}
150
+ interface BossJsFile extends BossFileBase {
151
+ dts: BossDtsFile;
152
+ import: (options: {
153
+ name?: string | null;
154
+ from: string;
155
+ as?: string | null;
156
+ }, test?: () => boolean) => string;
157
+ importAndConfig: (options: {
158
+ name: string;
159
+ from: string;
160
+ }, test?: () => boolean) => string;
161
+ config: (options: {
162
+ from: string;
163
+ config: Record<string, unknown>;
164
+ }, test?: () => boolean) => void;
165
+ }
166
+ type BossApiFiles = {
167
+ js: BossJsFile;
168
+ native: BossJsFile;
169
+ [key: string]: BossJsFile;
170
+ };
171
+ type BossRuntimeAdapter = {
172
+ createElement: (component: unknown, props: Record<string, unknown> | null, children?: unknown, dev?: unknown) => unknown;
173
+ getChildren?: (restArgs: unknown[]) => unknown;
174
+ getFactoryChildren?: (props: unknown, ref: unknown, restArgs: unknown[]) => unknown;
175
+ applyRef?: (props: Record<string, unknown>, ref: unknown) => void;
176
+ getDev?: (ref: unknown, restArgs: unknown[]) => unknown;
177
+ };
178
+ type BossApiConfig = UserConfig & {
179
+ plugins?: BossPluginModule[] | unknown[];
180
+ debug?: DebugValue;
181
+ baseDir?: string;
182
+ runtimeApi?: BossRuntimeAdapter;
183
+ framework?: FrameworkDescriptor | UserConfig['framework'];
184
+ strategy?: string;
185
+ };
186
+ interface BossApiBase extends Omit<UserConfig, 'css' | 'plugins' | 'framework'> {
187
+ unit: string;
188
+ plugins: BossPluginModule[];
189
+ trigger: BossPluginTrigger;
190
+ dictionary: Dictionary;
191
+ css?: BossCssLike;
192
+ file?: BossApiFiles;
193
+ log: BossLogger;
194
+ isServer?: boolean;
195
+ isBrowser?: boolean;
196
+ baseDir?: string;
197
+ userConfig?: UserConfig;
198
+ framework?: FrameworkDescriptor | UserConfig['framework'];
199
+ strategy?: string;
200
+ emitAllTokens?: boolean;
201
+ runtimeApi?: BossRuntimeAdapter;
202
+ tokenVars?: (tokens?: Record<string, unknown>) => Record<string, string | number>;
203
+ tokenPropGroups?: Record<string, string[]>;
204
+ propTreeToObject: (tree: BossPropTree) => Record<string, unknown>;
205
+ propTreeToArray: (tree: BossProp[]) => unknown[];
206
+ propTreeToValue: (tree: BossPropTree | BossProp[] | BossProp | unknown) => unknown;
207
+ walkPropTree: (tree: BossPropTree, callback: (name: string, prop: BossProp) => void) => void;
208
+ objectToPropTree: (obj: Record<string, unknown>, output?: BossPropTree) => BossPropTree;
209
+ mapPropTree: (tree: BossPropTree, callback: (name: string, prop: BossProp, depth: number) => BossProp, depth?: number) => BossPropTree;
210
+ escapeClassName: (value: string) => string;
211
+ contextToCSSVariable: (name: string, value: unknown, contexts: string[], selectorPrefix?: string) => string;
212
+ contextToClassName: (name: string, value: unknown, contexts: string[], useSelector?: boolean, selectorPrefix?: string) => string;
213
+ camelCaseToDash: (value: string) => string;
214
+ dashToCamelCase: (value: string) => string;
215
+ classTokenToSelector: (value: string) => string;
216
+ applyChildSelectors: (selector: string, contexts: string[]) => string;
217
+ }
218
+ interface BossServerApi extends BossApiBase {
219
+ isServer: true;
220
+ css: BossCssLike;
221
+ file: BossApiFiles;
222
+ }
223
+ interface BossBrowserApi extends BossApiBase {
224
+ isBrowser: true;
225
+ }
226
+ type BossApi = BossServerApi | BossBrowserApi;
227
+ type BossPluginEventApiMap = {
228
+ onBoot: BossServerApi;
229
+ onReady: BossServerApi;
230
+ onParse: BossServerApi;
231
+ onPropTree: BossServerApi;
232
+ onProp: BossServerApi;
233
+ onCompileProp: BossServerApi;
234
+ onInit: BossBrowserApi;
235
+ onBrowserObjectStart: BossBrowserApi;
236
+ onSession: BossServerApi;
237
+ onMetaData: BossServerApi;
238
+ };
239
+ type BossPluginTest = (plugin: BossPluginModule) => boolean | Promise<boolean>;
240
+ type BossPluginHandler<Event extends BossPluginEventName> = BossPluginEventPayload[Event] extends void ? (api: BossPluginEventApiMap[Event], payload?: BossPluginEventPayload[Event]) => void | Promise<void> : (api: BossPluginEventApiMap[Event], payload: BossPluginEventPayload[Event]) => void | Promise<void>;
241
+ type BossPluginHandlers = { [Event in BossPluginEventName]?: BossPluginHandler<Event> | Array<BossPluginHandler<Event>> };
242
+ interface BossPluginModule extends BossPluginHandlers {
243
+ name: string;
244
+ dependencies?: Set<string>;
245
+ settings?: Map<string, unknown>;
246
+ [key: string]: unknown;
247
+ }
248
+ type BossPluginTrigger = <Event extends BossPluginEventName>(eventName: Event, payload?: BossPluginEventPayload[Event], test?: BossPluginTest) => void | Promise<void>;
249
+ type Plugin<T extends BossPluginEventName> = BossPluginHandler<T>;
250
+ //#endregion
251
+ export { BossApi, BossApiBase, BossApiConfig, BossApiFiles, BossBrowserApi, BossBrowserObjectPayload, BossCssCustomBlock, BossCssLike, BossCssRuleOptions, BossCssSelectorInput, BossDtsFile, BossFileBase, BossFileEntry, BossFileSection, BossJsFile, BossMetaDataPayload, BossParseInput, BossPluginEventName, BossPluginEventPayload, BossPluginHandler, BossPluginHandlers, BossPluginModule, BossPluginTest, BossPluginTrigger, BossProp, BossPropPayload, BossPropPrimitive, BossPropTree, BossPropTreePayload, BossPropValue, BossRuntimeAdapter, BossServerApi, Plugin };
@@ -0,0 +1,251 @@
1
+ import { DebugValue, UserConfig } from "../shared/types.mjs";
2
+ import { FrameworkDescriptor } from "../detect-fw/index.mjs";
3
+ import { Dictionary } from "../api/dictionary.mjs";
4
+ import { SessionPayload } from "../tasks/session.mjs";
5
+
6
+ //#region src/types/Plugin.d.ts
7
+ type BossPropPrimitive = string | number | boolean | null | undefined;
8
+ type BossProp = {
9
+ value: BossPropValue;
10
+ dynamic?: boolean;
11
+ isFn?: boolean;
12
+ ast?: unknown;
13
+ code?: string;
14
+ selectorValue?: unknown;
15
+ selectorName?: string;
16
+ classToken?: string;
17
+ important?: boolean;
18
+ named?: string;
19
+ rawName?: string;
20
+ query?: string | null;
21
+ tokenKey?: string;
22
+ tokenPath?: string;
23
+ [key: string]: unknown;
24
+ };
25
+ type BossPropTree = Record<string, BossProp>;
26
+ type BossPropValue = BossPropPrimitive | BossPropTree | BossProp[] | Record<string, unknown> | unknown[];
27
+ type BossParseInput = {
28
+ content: string;
29
+ path?: string;
30
+ file?: string;
31
+ preparedOnly?: boolean;
32
+ [key: string]: unknown;
33
+ };
34
+ type BossPropTreePayload = {
35
+ input: Record<string, unknown>;
36
+ tree: BossPropTree;
37
+ preferVariables?: boolean;
38
+ parser?: 'jsx' | 'classname' | string;
39
+ file?: BossParseInput | {
40
+ path?: string;
41
+ file?: string;
42
+ } | null;
43
+ code?: string;
44
+ };
45
+ type BossPropPayload = {
46
+ name: string;
47
+ prop: BossProp;
48
+ contexts: string[];
49
+ preferVariables?: boolean;
50
+ file?: BossParseInput | {
51
+ path?: string;
52
+ file?: string;
53
+ } | null;
54
+ };
55
+ type BossCompilePropPayload = {
56
+ name: string;
57
+ prop: BossProp;
58
+ output: Record<string, BossProp | unknown>;
59
+ tag?: string;
60
+ file?: BossParseInput | {
61
+ path?: string;
62
+ file?: string;
63
+ } | null;
64
+ keep?: boolean;
65
+ remove?: boolean;
66
+ };
67
+ type BossBrowserObjectPayload = {
68
+ input: Record<string, unknown>;
69
+ output?: Record<string, unknown>;
70
+ tag?: string;
71
+ contexts?: string[];
72
+ };
73
+ type BossMetaDataPayload = {
74
+ kind: string;
75
+ data?: unknown;
76
+ label?: string;
77
+ type?: string;
78
+ [key: string]: unknown;
79
+ };
80
+ type BossPluginEventName = 'onBoot' | 'onReady' | 'onParse' | 'onPropTree' | 'onProp' | 'onCompileProp' | 'onInit' | 'onBrowserObjectStart' | 'onSession' | 'onMetaData';
81
+ type BossPluginEventPayload = {
82
+ onBoot: void;
83
+ onReady: void;
84
+ onParse: BossParseInput;
85
+ onPropTree: BossPropTreePayload;
86
+ onProp: BossPropPayload;
87
+ onCompileProp: BossCompilePropPayload;
88
+ onInit: void;
89
+ onBrowserObjectStart: BossBrowserObjectPayload;
90
+ onSession: SessionPayload;
91
+ onMetaData: BossMetaDataPayload;
92
+ };
93
+ type BossCssSelectorInput = {
94
+ className?: string | null;
95
+ selector?: string | null;
96
+ pseudos?: string[];
97
+ query?: string | null;
98
+ source?: string | null;
99
+ };
100
+ type BossCssRuleOptions = {
101
+ important?: boolean;
102
+ };
103
+ type BossCssCustomBlock = {
104
+ start: number;
105
+ end: number;
106
+ cssText: string;
107
+ };
108
+ type BossLogger = {
109
+ namespace: string;
110
+ enabled: boolean;
111
+ log: (...args: any[]) => void;
112
+ child: (name: string) => BossLogger;
113
+ };
114
+ interface BossCssLike {
115
+ text: string;
116
+ source?: string | null;
117
+ setSource?: (source: string | null) => void;
118
+ selector: (input: BossCssSelectorInput) => void;
119
+ rule: (property: string, value: unknown, options?: BossCssRuleOptions) => void;
120
+ addRule: (rule: string, query?: string | null, source?: string | null) => void;
121
+ addImport: (url: string) => void;
122
+ addRoot: (value: string, source?: string | null) => void;
123
+ removeSource: (source: string | null | undefined) => void;
124
+ write: () => void;
125
+ reset: () => void;
126
+ snapshot?: () => unknown;
127
+ restore?: (snapshot: unknown) => void;
128
+ syncCustomBlocks?: (file: string | undefined, blocks: BossCssCustomBlock[]) => void;
129
+ getCustomText?: () => string;
130
+ current?: unknown;
131
+ imports?: Set<string>;
132
+ root?: Set<string>;
133
+ }
134
+ type BossFileSection = 'head' | 'import' | 'body' | 'foot';
135
+ type BossFileEntry = {
136
+ content: unknown;
137
+ test?: () => boolean;
138
+ };
139
+ interface BossFileBase {
140
+ get: (section: BossFileSection) => Map<unknown, BossFileEntry>;
141
+ set: (section: BossFileSection, key: unknown, content: unknown, test?: () => boolean) => this;
142
+ append: (section: BossFileSection, key: unknown, content: string, test?: () => boolean) => this;
143
+ prepend: (section: BossFileSection, key: unknown, content: string, test?: () => boolean) => this;
144
+ replace: (section: BossFileSection, key: unknown, callback: (value: BossFileEntry | BossFileEntry['content']) => BossFileEntry | string) => this;
145
+ write: () => Promise<void>;
146
+ text: string;
147
+ hasContent: boolean;
148
+ }
149
+ interface BossDtsFile extends BossFileBase {}
150
+ interface BossJsFile extends BossFileBase {
151
+ dts: BossDtsFile;
152
+ import: (options: {
153
+ name?: string | null;
154
+ from: string;
155
+ as?: string | null;
156
+ }, test?: () => boolean) => string;
157
+ importAndConfig: (options: {
158
+ name: string;
159
+ from: string;
160
+ }, test?: () => boolean) => string;
161
+ config: (options: {
162
+ from: string;
163
+ config: Record<string, unknown>;
164
+ }, test?: () => boolean) => void;
165
+ }
166
+ type BossApiFiles = {
167
+ js: BossJsFile;
168
+ native: BossJsFile;
169
+ [key: string]: BossJsFile;
170
+ };
171
+ type BossRuntimeAdapter = {
172
+ createElement: (component: unknown, props: Record<string, unknown> | null, children?: unknown, dev?: unknown) => unknown;
173
+ getChildren?: (restArgs: unknown[]) => unknown;
174
+ getFactoryChildren?: (props: unknown, ref: unknown, restArgs: unknown[]) => unknown;
175
+ applyRef?: (props: Record<string, unknown>, ref: unknown) => void;
176
+ getDev?: (ref: unknown, restArgs: unknown[]) => unknown;
177
+ };
178
+ type BossApiConfig = UserConfig & {
179
+ plugins?: BossPluginModule[] | unknown[];
180
+ debug?: DebugValue;
181
+ baseDir?: string;
182
+ runtimeApi?: BossRuntimeAdapter;
183
+ framework?: FrameworkDescriptor | UserConfig['framework'];
184
+ strategy?: string;
185
+ };
186
+ interface BossApiBase extends Omit<UserConfig, 'css' | 'plugins' | 'framework'> {
187
+ unit: string;
188
+ plugins: BossPluginModule[];
189
+ trigger: BossPluginTrigger;
190
+ dictionary: Dictionary;
191
+ css?: BossCssLike;
192
+ file?: BossApiFiles;
193
+ log: BossLogger;
194
+ isServer?: boolean;
195
+ isBrowser?: boolean;
196
+ baseDir?: string;
197
+ userConfig?: UserConfig;
198
+ framework?: FrameworkDescriptor | UserConfig['framework'];
199
+ strategy?: string;
200
+ emitAllTokens?: boolean;
201
+ runtimeApi?: BossRuntimeAdapter;
202
+ tokenVars?: (tokens?: Record<string, unknown>) => Record<string, string | number>;
203
+ tokenPropGroups?: Record<string, string[]>;
204
+ propTreeToObject: (tree: BossPropTree) => Record<string, unknown>;
205
+ propTreeToArray: (tree: BossProp[]) => unknown[];
206
+ propTreeToValue: (tree: BossPropTree | BossProp[] | BossProp | unknown) => unknown;
207
+ walkPropTree: (tree: BossPropTree, callback: (name: string, prop: BossProp) => void) => void;
208
+ objectToPropTree: (obj: Record<string, unknown>, output?: BossPropTree) => BossPropTree;
209
+ mapPropTree: (tree: BossPropTree, callback: (name: string, prop: BossProp, depth: number) => BossProp, depth?: number) => BossPropTree;
210
+ escapeClassName: (value: string) => string;
211
+ contextToCSSVariable: (name: string, value: unknown, contexts: string[], selectorPrefix?: string) => string;
212
+ contextToClassName: (name: string, value: unknown, contexts: string[], useSelector?: boolean, selectorPrefix?: string) => string;
213
+ camelCaseToDash: (value: string) => string;
214
+ dashToCamelCase: (value: string) => string;
215
+ classTokenToSelector: (value: string) => string;
216
+ applyChildSelectors: (selector: string, contexts: string[]) => string;
217
+ }
218
+ interface BossServerApi extends BossApiBase {
219
+ isServer: true;
220
+ css: BossCssLike;
221
+ file: BossApiFiles;
222
+ }
223
+ interface BossBrowserApi extends BossApiBase {
224
+ isBrowser: true;
225
+ }
226
+ type BossApi = BossServerApi | BossBrowserApi;
227
+ type BossPluginEventApiMap = {
228
+ onBoot: BossServerApi;
229
+ onReady: BossServerApi;
230
+ onParse: BossServerApi;
231
+ onPropTree: BossServerApi;
232
+ onProp: BossServerApi;
233
+ onCompileProp: BossServerApi;
234
+ onInit: BossBrowserApi;
235
+ onBrowserObjectStart: BossBrowserApi;
236
+ onSession: BossServerApi;
237
+ onMetaData: BossServerApi;
238
+ };
239
+ type BossPluginTest = (plugin: BossPluginModule) => boolean | Promise<boolean>;
240
+ type BossPluginHandler<Event extends BossPluginEventName> = BossPluginEventPayload[Event] extends void ? (api: BossPluginEventApiMap[Event], payload?: BossPluginEventPayload[Event]) => void | Promise<void> : (api: BossPluginEventApiMap[Event], payload: BossPluginEventPayload[Event]) => void | Promise<void>;
241
+ type BossPluginHandlers = { [Event in BossPluginEventName]?: BossPluginHandler<Event> | Array<BossPluginHandler<Event>> };
242
+ interface BossPluginModule extends BossPluginHandlers {
243
+ name: string;
244
+ dependencies?: Set<string>;
245
+ settings?: Map<string, unknown>;
246
+ [key: string]: unknown;
247
+ }
248
+ type BossPluginTrigger = <Event extends BossPluginEventName>(eventName: Event, payload?: BossPluginEventPayload[Event], test?: BossPluginTest) => void | Promise<void>;
249
+ type Plugin<T extends BossPluginEventName> = BossPluginHandler<T>;
250
+ //#endregion
251
+ export { BossApi, BossApiBase, BossApiConfig, BossApiFiles, BossBrowserApi, BossBrowserObjectPayload, BossCssCustomBlock, BossCssLike, BossCssRuleOptions, BossCssSelectorInput, BossDtsFile, BossFileBase, BossFileEntry, BossFileSection, BossJsFile, BossMetaDataPayload, BossParseInput, BossPluginEventName, BossPluginEventPayload, BossPluginHandler, BossPluginHandlers, BossPluginModule, BossPluginTest, BossPluginTrigger, BossProp, BossPropPayload, BossPropPrimitive, BossPropTree, BossPropTreePayload, BossPropValue, BossRuntimeAdapter, BossServerApi, Plugin };
@@ -0,0 +1,16 @@
1
+ import { Plugin } from "../../types/Plugin.cjs";
2
+
3
+ //#region src/use/token/browser.d.ts
4
+ type TokenFn = (() => string) & {
5
+ IS_TOKEN_FN?: boolean;
6
+ };
7
+ type TokenProxy = TokenFn & {
8
+ [key: string]: TokenProxy;
9
+ };
10
+ declare const tokenVars: (input?: Record<string, unknown>) => Record<string, string | number>;
11
+ declare const onInit: Plugin<'onInit'>;
12
+ declare const create: (currentKey?: string) => TokenProxy;
13
+ declare const tokenPaths: Set<unknown>;
14
+ declare const onBrowserObjectStart: Plugin<'onBrowserObjectStart'>;
15
+ //#endregion
16
+ export { TokenProxy, create, onBrowserObjectStart, onInit, tokenPaths, tokenVars };