@unframework.dev/compiler 0.0.0 → 0.2.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/README.md +7 -0
- package/dist/config-types.d.ts +37 -0
- package/dist/config.d.ts +5 -1
- package/dist/config.js +20 -2
- package/dist/index.d.ts +3 -2
- package/dist/index.js +2 -1
- package/package.json +14 -14
package/README.md
CHANGED
|
@@ -176,6 +176,8 @@ and `unframework.config.ts`.
|
|
|
176
176
|
| `strict` | `false` | a boolean |
|
|
177
177
|
| `package.targets` | left out | as `targets`, and each name also in `targets` |
|
|
178
178
|
| `package.resolveFrom` | left out | a path, or a path per built-in name, each made absolute |
|
|
179
|
+
| `vite` | left out | a function, kept as it is (ADR-0104) |
|
|
180
|
+
| `liveFonts` | `[]` | a list of font family names that aren't empty (ADR-0105) |
|
|
179
181
|
|
|
180
182
|
A field of the wrong shape, or one the config doesn't have, is UF7002. A name that isn't a built-in
|
|
181
183
|
target is UF7003, with a did-you-mean where one is close. Options a target's schema rejects are
|
|
@@ -185,5 +187,10 @@ A target without a schema takes no options, so any key under it is UF7004 too. N
|
|
|
185
187
|
declares a schema yet, so `react: { compiler: true }` reports "`react` declares no options" until
|
|
186
188
|
React declares that option.
|
|
187
189
|
|
|
190
|
+
`vite` and `liveFonts` are for `unframework test`, `visual` and `preview`, which
|
|
191
|
+
`@unframework.dev/testing` and `@unframework.dev/visual` read. `compile()`, `build` and `check`
|
|
192
|
+
ignore them. `DEFAULT_PASS_THROUGH`, the analyser's default prefixes, is exported for the harness,
|
|
193
|
+
which declares the modules under them for Angular's compile.
|
|
194
|
+
|
|
188
195
|
Each message gives the field's JSON pointer, and `config` is `undefined` when there is any
|
|
189
196
|
diagnostic. A known field set to `undefined` counts as left out.
|
package/dist/config-types.d.ts
CHANGED
|
@@ -7,6 +7,30 @@ export interface PackageConfig {
|
|
|
7
7
|
/** One directory, or one per target. */
|
|
8
8
|
resolveFrom?: string | Partial<Record<TargetName, string>>;
|
|
9
9
|
}
|
|
10
|
+
/**
|
|
11
|
+
* One entry of Vite's `plugins`, as far as the configuration reads it: a plugin, which has a
|
|
12
|
+
* name, nothing, a list of them, or a promise of one. This file imports nothing, so Vite's own
|
|
13
|
+
* `PluginOption`, which every Vite plugin matches, stands here as its shape (ADR-0104).
|
|
14
|
+
*/
|
|
15
|
+
export type VitePluginOption = {
|
|
16
|
+
readonly name: string;
|
|
17
|
+
} | false | null | undefined | readonly VitePluginOption[] | PromiseLike<VitePluginOption>;
|
|
18
|
+
/** The kind of Vite server a project's `vite` config is for (ADR-0104). */
|
|
19
|
+
export type ViteMode = "browser" | "ssr" | "preview";
|
|
20
|
+
/** What a project's `vite` function is called with: the server's target and its kind. */
|
|
21
|
+
export interface ViteContext {
|
|
22
|
+
readonly target: TargetName;
|
|
23
|
+
readonly mode: ViteMode;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* The partial Vite config a project's `vite` function returns, as far as this file can say
|
|
27
|
+
* without importing Vite (ADR-0076): its `plugins` are checked, and any other key Vite's
|
|
28
|
+
* `UserConfig` has passes, whether the function returns an object literal or Vite's own type
|
|
29
|
+
* (ADR-0104).
|
|
30
|
+
*/
|
|
31
|
+
export type ProjectViteConfig = {
|
|
32
|
+
plugins?: readonly VitePluginOption[];
|
|
33
|
+
} & object;
|
|
10
34
|
/** The configuration as a project writes it, with `defineConfig` from `@uxfront/unframework/config`. */
|
|
11
35
|
export interface UnframeworkConfig {
|
|
12
36
|
/** Defaults to all seven targets. */
|
|
@@ -22,5 +46,18 @@ export interface UnframeworkConfig {
|
|
|
22
46
|
/** Plan §8.1: `true` makes portability warnings errors, in the CLI. Defaults to `false`. */
|
|
23
47
|
strict?: boolean;
|
|
24
48
|
package?: PackageConfig;
|
|
49
|
+
/**
|
|
50
|
+
* The project's Vite config for the servers `unframework test`, `visual` and `preview` start,
|
|
51
|
+
* such as the plugin of a styling engine that serves `virtual:` modules (ADR-0064). Each server
|
|
52
|
+
* calls it with its target and kind, for a fresh set of plugins, since a plugin may hold one
|
|
53
|
+
* server's state. Its plugins are listed before the unframework plugin, and the other keys merge into
|
|
54
|
+
* the server's own config, which it never replaces (ADR-0104).
|
|
55
|
+
*/
|
|
56
|
+
vite?: (context: ViteContext) => ProjectViteConfig | Promise<ProjectViteConfig>;
|
|
57
|
+
/**
|
|
58
|
+
* The font families that may draw text when pixels compare live, besides the bundled Inter, as
|
|
59
|
+
* the `font-fallback` message names them. Committed baselines take Inter alone (ADR-0105).
|
|
60
|
+
*/
|
|
61
|
+
liveFonts?: readonly string[];
|
|
25
62
|
}
|
|
26
63
|
//#endregion
|
package/dist/config.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PackageConfig, TargetName } from "./config-types.js";
|
|
1
|
+
import { PackageConfig, TargetName, UnframeworkConfig } from "./config-types.js";
|
|
2
2
|
import { Diagnostic } from "@unframework.dev/diagnostics";
|
|
3
3
|
//#region src/config.d.ts
|
|
4
4
|
/** The configuration with its defaults applied, and its paths absolute. */
|
|
@@ -10,6 +10,10 @@ export interface ResolvedConfig {
|
|
|
10
10
|
typeOracle: "syntactic" | "tsgo";
|
|
11
11
|
strict: boolean;
|
|
12
12
|
package?: PackageConfig;
|
|
13
|
+
/** The project's Vite config, as a function each server calls (ADR-0104). */
|
|
14
|
+
vite?: UnframeworkConfig["vite"];
|
|
15
|
+
/** The font families that may draw text when pixels compare live, besides Inter (ADR-0105). */
|
|
16
|
+
liveFonts: readonly string[];
|
|
13
17
|
}
|
|
14
18
|
/** Where a configuration came from: what {@link loadConfig} gives {@link resolveConfig}. */
|
|
15
19
|
export interface ConfigOrigin {
|
package/dist/config.js
CHANGED
|
@@ -19,7 +19,9 @@ const FIELDS = [
|
|
|
19
19
|
"targetOptions",
|
|
20
20
|
"typeOracle",
|
|
21
21
|
"strict",
|
|
22
|
-
"package"
|
|
22
|
+
"package",
|
|
23
|
+
"vite",
|
|
24
|
+
"liveFonts"
|
|
23
25
|
];
|
|
24
26
|
const PACKAGE_FIELDS = ["targets", "resolveFrom"];
|
|
25
27
|
const TYPE_ORACLES = ["syntactic", "tsgo"];
|
|
@@ -108,6 +110,8 @@ async function checkConfig(raw, directory, report) {
|
|
|
108
110
|
if (raw.typeOracle !== void 0 && !TYPE_ORACLES.includes(raw.typeOracle)) report("UF7002", "/typeOracle", `must be "syntactic" or "tsgo".`);
|
|
109
111
|
if (raw.strict !== void 0 && typeof raw.strict !== "boolean") report("UF7002", "/strict", "must be a boolean.");
|
|
110
112
|
const packaging = raw.package === void 0 ? void 0 : resolvePackage(raw.package, targets, directory, report);
|
|
113
|
+
if (raw.vite !== void 0 && typeof raw.vite !== "function") report("UF7002", "/vite", "must be a function that returns a Vite config, such as `() => ({ plugins: [engine()] })`: each Vite server calls it for a fresh set of plugins.");
|
|
114
|
+
const liveFonts = fontList(raw.liveFonts, report);
|
|
111
115
|
return {
|
|
112
116
|
targets,
|
|
113
117
|
srcDir,
|
|
@@ -115,9 +119,23 @@ async function checkConfig(raw, directory, report) {
|
|
|
115
119
|
targetOptions,
|
|
116
120
|
typeOracle: raw.typeOracle ?? "syntactic",
|
|
117
121
|
strict: raw.strict ?? false,
|
|
118
|
-
...packaging ? { package: packaging } : {}
|
|
122
|
+
...packaging ? { package: packaging } : {},
|
|
123
|
+
...raw.vite === void 0 ? {} : { vite: raw.vite },
|
|
124
|
+
liveFonts
|
|
119
125
|
};
|
|
120
126
|
}
|
|
127
|
+
/** The font families a live capture may take, each a name that isn't empty (ADR-0105). */
|
|
128
|
+
function fontList(value, report) {
|
|
129
|
+
if (value === void 0) return [];
|
|
130
|
+
if (!Array.isArray(value)) {
|
|
131
|
+
report("UF7002", "/liveFonts", "must be a list of font family names, as the `font-fallback` message names them.");
|
|
132
|
+
return [];
|
|
133
|
+
}
|
|
134
|
+
const names = [];
|
|
135
|
+
for (const [index, item] of value.entries()) if (typeof item !== "string" || !item || item.trim() !== item) report("UF7002", `/liveFonts/${index}`, "must be a font family's name, as a string that isn't empty and has no space at either end.");
|
|
136
|
+
else names.push(item);
|
|
137
|
+
return names;
|
|
138
|
+
}
|
|
121
139
|
/**
|
|
122
140
|
* Node gives a CommonJS file a `default`, its `module.exports`, even when it exports nothing, and a
|
|
123
141
|
* `.ts` or `.js` file with no ES module syntax left once its types are stripped loads as CommonJS
|
package/dist/index.d.ts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import { PackageConfig, TargetName, UnframeworkConfig } from "./config-types.js";
|
|
1
|
+
import { PackageConfig, ProjectViteConfig, TargetName, UnframeworkConfig, ViteContext, ViteMode, VitePluginOption } from "./config-types.js";
|
|
2
2
|
import { FileResolverOptions, ResolveRequest, ResolvedModule, ResolvedStylesheet, Resolver } from "./resolver.js";
|
|
3
3
|
import { TARGET_NAMES, builtinTargets, resolveTarget } from "./targets.js";
|
|
4
4
|
import { CompileOptions, CompileResult, CompilerPlugin, OutputHookContext, checkPassThrough, compile } from "./compile.js";
|
|
5
5
|
import { Project, ProjectOptions, ProjectUpdate, createFileResolver, createProject } from "./project.js";
|
|
6
6
|
import { ConfigOrigin, LoadedConfig, ResolveConfigResult, ResolvedConfig, loadConfig, resolveConfig } from "./config.js";
|
|
7
7
|
import { checkCapabilities } from "./capabilities.js";
|
|
8
|
+
import { DEFAULT_PASS_THROUGH } from "@unframework.dev/analyzer";
|
|
8
9
|
import { OutputFile, Target, requiredCapabilities } from "@unframework.dev/codegen";
|
|
9
10
|
import { Diagnostic } from "@unframework.dev/diagnostics";
|
|
10
11
|
import { UfModule } from "@unframework.dev/ir";
|
|
11
12
|
import { SyntacticOracleOptions, TypeOracle, createSyntacticOracle } from "@unframework.dev/type-oracle";
|
|
12
|
-
export { type CompileOptions, type CompileResult, type CompilerPlugin, type ConfigOrigin, type Diagnostic, type FileResolverOptions, type LoadedConfig, type OutputFile, type OutputHookContext, type PackageConfig, type Project, type ProjectOptions, type ProjectUpdate, type ResolveConfigResult, type ResolveRequest, type ResolvedConfig, type ResolvedModule, type ResolvedStylesheet, type Resolver, type SyntacticOracleOptions, TARGET_NAMES, type Target, type TargetName, type TypeOracle, type UfModule, type UnframeworkConfig, builtinTargets, checkCapabilities, checkPassThrough, compile, createFileResolver, createProject, createSyntacticOracle, loadConfig, requiredCapabilities, resolveConfig, resolveTarget };
|
|
13
|
+
export { type CompileOptions, type CompileResult, type CompilerPlugin, type ConfigOrigin, DEFAULT_PASS_THROUGH, type Diagnostic, type FileResolverOptions, type LoadedConfig, type OutputFile, type OutputHookContext, type PackageConfig, type Project, type ProjectOptions, type ProjectUpdate, type ProjectViteConfig, type ResolveConfigResult, type ResolveRequest, type ResolvedConfig, type ResolvedModule, type ResolvedStylesheet, type Resolver, type SyntacticOracleOptions, TARGET_NAMES, type Target, type TargetName, type TypeOracle, type UfModule, type UnframeworkConfig, type ViteContext, type ViteMode, type VitePluginOption, builtinTargets, checkCapabilities, checkPassThrough, compile, createFileResolver, createProject, createSyntacticOracle, loadConfig, requiredCapabilities, resolveConfig, resolveTarget };
|
package/dist/index.js
CHANGED
|
@@ -3,6 +3,7 @@ import { TARGET_NAMES, builtinTargets, resolveTarget } from "./targets.js";
|
|
|
3
3
|
import { checkPassThrough, compile } from "./compile.js";
|
|
4
4
|
import { createFileResolver, createProject } from "./project.js";
|
|
5
5
|
import { loadConfig, resolveConfig } from "./config.js";
|
|
6
|
+
import { DEFAULT_PASS_THROUGH } from "@unframework.dev/analyzer";
|
|
6
7
|
import { requiredCapabilities } from "@unframework.dev/codegen";
|
|
7
8
|
import { createSyntacticOracle } from "@unframework.dev/type-oracle";
|
|
8
|
-
export { TARGET_NAMES, builtinTargets, checkCapabilities, checkPassThrough, compile, createFileResolver, createProject, createSyntacticOracle, loadConfig, requiredCapabilities, resolveConfig, resolveTarget };
|
|
9
|
+
export { DEFAULT_PASS_THROUGH, TARGET_NAMES, builtinTargets, checkCapabilities, checkPassThrough, compile, createFileResolver, createProject, createSyntacticOracle, loadConfig, requiredCapabilities, resolveConfig, resolveTarget };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unframework.dev/compiler",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "The Unframework compiler: compile() turns one .uf.tsx source into native React, Vue, Svelte, Solid, Angular, Qwik and Astro components.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"angular",
|
|
@@ -41,19 +41,19 @@
|
|
|
41
41
|
"access": "public"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@unframework.dev/analyzer": "0.
|
|
45
|
-
"@unframework.dev/codegen": "0.
|
|
46
|
-
"@unframework.dev/diagnostics": "0.
|
|
47
|
-
"@unframework.dev/ir": "0.
|
|
48
|
-
"@unframework.dev/parser": "0.
|
|
49
|
-
"@unframework.dev/target-angular": "0.
|
|
50
|
-
"@unframework.dev/target-astro": "0.
|
|
51
|
-
"@unframework.dev/target-qwik": "0.
|
|
52
|
-
"@unframework.dev/target-react": "0.
|
|
53
|
-
"@unframework.dev/target-solid": "0.
|
|
54
|
-
"@unframework.dev/target-svelte": "0.
|
|
55
|
-
"@unframework.dev/target-vue": "0.
|
|
56
|
-
"@unframework.dev/type-oracle": "0.
|
|
44
|
+
"@unframework.dev/analyzer": "0.1.0",
|
|
45
|
+
"@unframework.dev/codegen": "0.1.0",
|
|
46
|
+
"@unframework.dev/diagnostics": "0.1.0",
|
|
47
|
+
"@unframework.dev/ir": "0.1.0",
|
|
48
|
+
"@unframework.dev/parser": "0.1.0",
|
|
49
|
+
"@unframework.dev/target-angular": "0.1.0",
|
|
50
|
+
"@unframework.dev/target-astro": "0.1.0",
|
|
51
|
+
"@unframework.dev/target-qwik": "0.1.0",
|
|
52
|
+
"@unframework.dev/target-react": "0.1.0",
|
|
53
|
+
"@unframework.dev/target-solid": "0.1.0",
|
|
54
|
+
"@unframework.dev/target-svelte": "0.1.0",
|
|
55
|
+
"@unframework.dev/target-vue": "0.1.0",
|
|
56
|
+
"@unframework.dev/type-oracle": "0.1.0"
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
59
59
|
"@types/node": "^24.19.0",
|