veryfront 0.1.320 → 0.1.321
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/esm/deno.js +1 -1
- package/esm/extensions/ext-tailwind/src/index.d.ts +9 -0
- package/esm/extensions/ext-tailwind/src/index.d.ts.map +1 -0
- package/esm/extensions/ext-tailwind/src/index.js +69 -0
- package/esm/src/html/styles-builder/tailwind-compiler-cache.d.ts.map +1 -1
- package/esm/src/html/styles-builder/tailwind-compiler-cache.js +30 -2
- package/esm/src/utils/version-constant.d.ts +1 -1
- package/esm/src/utils/version-constant.js +1 -1
- package/package.json +2 -1
- package/src/deno.js +1 -1
- package/src/extensions/ext-tailwind/src/index.ts +80 -0
- package/src/src/html/styles-builder/tailwind-compiler-cache.ts +36 -2
- package/src/src/utils/version-constant.ts +1 -1
package/esm/deno.js
CHANGED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ExtensionFactory } from "../../../src/extensions/index.js";
|
|
2
|
+
import type { CSSCompileOptions, CSSCompiler, CSSProcessor } from "../../../src/extensions/interfaces/index.js";
|
|
3
|
+
declare class TailwindCSSProcessor implements CSSProcessor {
|
|
4
|
+
compile(stylesheet: string, options: CSSCompileOptions): Promise<CSSCompiler>;
|
|
5
|
+
}
|
|
6
|
+
declare const extTailwind: ExtensionFactory;
|
|
7
|
+
export default extTailwind;
|
|
8
|
+
export { TailwindCSSProcessor };
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/extensions/ext-tailwind/src/index.ts"],"names":[],"mappings":"AAoBA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AACzE,OAAO,KAAK,EAAE,iBAAiB,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,6CAA6C,CAAC;AAgBhH,cAAM,oBAAqB,YAAW,YAAY;IAC1C,OAAO,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,WAAW,CAAC;CAgBpF;AAED,QAAA,MAAM,WAAW,EAAE,gBAoBlB,CAAC;AAEF,eAAe,WAAW,CAAC;AAC3B,OAAO,EAAE,oBAAoB,EAAE,CAAC"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ext-tailwind — CSSProcessor implementation backed by Tailwind CSS v4.
|
|
3
|
+
*
|
|
4
|
+
* Provides the `CSSProcessor` contract:
|
|
5
|
+
* - `compile(stylesheet, options)` — delegates to tailwindcss `compile()`
|
|
6
|
+
* and returns a compiler whose `build(candidates)` emits CSS for the
|
|
7
|
+
* class-name candidates discovered at render time.
|
|
8
|
+
*
|
|
9
|
+
* The extension also installs three `globalThis` shims on setup so that
|
|
10
|
+
* Tailwind plugin bundles loaded at runtime from esm.sh can bind their
|
|
11
|
+
* `tailwindcss/plugin`, `tailwindcss/defaultTheme`, and `tailwindcss/colors`
|
|
12
|
+
* imports to the same tailwindcss copy this extension ships. Core's
|
|
13
|
+
* `plugin-loader.ts` rewrites plugin bundle code to reference these shims
|
|
14
|
+
* by name; without the shims installed, dynamic plugin loading fails.
|
|
15
|
+
*
|
|
16
|
+
* @module extensions/ext-tailwind
|
|
17
|
+
*/
|
|
18
|
+
import * as dntShim from "../../../_dnt.shims.js";
|
|
19
|
+
import { compile } from "tailwindcss";
|
|
20
|
+
import plugin from "tailwindcss/plugin";
|
|
21
|
+
import defaultTheme from "tailwindcss/defaultTheme";
|
|
22
|
+
import colors from "tailwindcss/colors";
|
|
23
|
+
function installTailwindPluginShims() {
|
|
24
|
+
const g = dntShim.dntGlobalThis;
|
|
25
|
+
g.__tailwindPluginShim = { default: plugin, __esModule: true };
|
|
26
|
+
g.__tailwindDefaultThemeShim = { default: defaultTheme, __esModule: true };
|
|
27
|
+
g.__tailwindColorsShim = { default: colors, __esModule: true };
|
|
28
|
+
}
|
|
29
|
+
class TailwindCSSProcessor {
|
|
30
|
+
async compile(stylesheet, options) {
|
|
31
|
+
const native = await compile(stylesheet, {
|
|
32
|
+
base: options.base,
|
|
33
|
+
loadStylesheet: options.loadStylesheet,
|
|
34
|
+
loadModule: async (id) => {
|
|
35
|
+
const loaded = await options.loadModule(id);
|
|
36
|
+
// deno-lint-ignore no-explicit-any -- loaded plugin modules are opaque to the contract
|
|
37
|
+
return { module: loaded.module, base: loaded.base, path: loaded.path };
|
|
38
|
+
},
|
|
39
|
+
});
|
|
40
|
+
return {
|
|
41
|
+
build(candidates) {
|
|
42
|
+
return native.build(candidates);
|
|
43
|
+
},
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
const extTailwind = () => {
|
|
48
|
+
const impl = new TailwindCSSProcessor();
|
|
49
|
+
return {
|
|
50
|
+
name: "ext-tailwind",
|
|
51
|
+
version: "0.1.0",
|
|
52
|
+
capabilities: [
|
|
53
|
+
{ type: "contract", name: "CSSProcessor" },
|
|
54
|
+
{ type: "net", hosts: ["esm.sh"] },
|
|
55
|
+
],
|
|
56
|
+
setup(ctx) {
|
|
57
|
+
installTailwindPluginShims();
|
|
58
|
+
ctx.provide("CSSProcessor", impl);
|
|
59
|
+
ctx.logger.info("[ext-tailwind] CSSProcessor registered");
|
|
60
|
+
},
|
|
61
|
+
teardown() {
|
|
62
|
+
// Shims stay installed — removing them could break in-flight plugin
|
|
63
|
+
// loads. The globalThis pollution is intentional and scoped to keys
|
|
64
|
+
// with `__tailwind` prefix.
|
|
65
|
+
},
|
|
66
|
+
};
|
|
67
|
+
};
|
|
68
|
+
export default extTailwind;
|
|
69
|
+
export { TailwindCSSProcessor };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tailwind-compiler-cache.d.ts","sourceRoot":"","sources":["../../../../src/src/html/styles-builder/tailwind-compiler-cache.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;
|
|
1
|
+
{"version":3,"file":"tailwind-compiler-cache.d.ts","sourceRoot":"","sources":["../../../../src/src/html/styles-builder/tailwind-compiler-cache.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAMH,OAAO,KAAK,EAAE,WAAW,EAAgB,MAAM,sCAAsC,CAAC;AA0GtF,wBAAsB,WAAW,CAC/B,UAAU,EAAE,MAAM,EAClB,WAAW,CAAC,EAAE,MAAM,GACnB,OAAO,CAAC,WAAW,CAAC,CAgEtB;AAED,wBAAgB,kBAAkB,IAAI,IAAI,CAGzC;AAED;;GAEG;AACH,wBAAgB,qBAAqB,IAAI;IACvC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CAC1E,CAQA;AAED,wBAAgB,gBAAgB,CAAC,EAAE,CAAC,EAAE,MAAM,GAAG,IAAI,CAalD"}
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
*
|
|
14
14
|
* @module html/styles-builder/tailwind-compiler-cache
|
|
15
15
|
*/
|
|
16
|
-
import { tryResolve as tryResolveContract } from "../../extensions/contracts.js";
|
|
16
|
+
import { register as registerContract, tryResolve as tryResolveContract, } from "../../extensions/contracts.js";
|
|
17
17
|
import { serverLogger } from "../../utils/index.js";
|
|
18
18
|
import { DEPENDENCY_MISSING, NETWORK_ERROR } from "../../errors/index.js";
|
|
19
19
|
import { getTailwindCSSUrl } from "../../utils/constants/cdn.js";
|
|
@@ -51,6 +51,34 @@ async function getTailwindBaseCSS() {
|
|
|
51
51
|
}
|
|
52
52
|
return tailwindBaseCSS;
|
|
53
53
|
}
|
|
54
|
+
async function resolveCSSProcessor() {
|
|
55
|
+
const registeredProcessor = tryResolveContract("CSSProcessor");
|
|
56
|
+
if (registeredProcessor)
|
|
57
|
+
return registeredProcessor;
|
|
58
|
+
try {
|
|
59
|
+
const { default: createTailwindExtension } = await import("../../../extensions/ext-tailwind/src/index.js");
|
|
60
|
+
const extension = createTailwindExtension();
|
|
61
|
+
await extension.setup?.({
|
|
62
|
+
config: {},
|
|
63
|
+
logger,
|
|
64
|
+
provide: (name, impl) => registerContract(name, impl),
|
|
65
|
+
get: () => undefined,
|
|
66
|
+
require: (name) => {
|
|
67
|
+
const contract = tryResolveContract(name);
|
|
68
|
+
if (contract === undefined) {
|
|
69
|
+
throw new Error(`Missing required extension contract: ${name}`);
|
|
70
|
+
}
|
|
71
|
+
return contract;
|
|
72
|
+
},
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
catch (error) {
|
|
76
|
+
logger.warn("Failed to register built-in CSSProcessor extension", {
|
|
77
|
+
error: error instanceof Error ? error.message : String(error),
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
return tryResolveContract("CSSProcessor");
|
|
81
|
+
}
|
|
54
82
|
function evictOldestCompiler() {
|
|
55
83
|
if (compilerCache.size < MAX_CACHED_COMPILERS)
|
|
56
84
|
return;
|
|
@@ -79,7 +107,7 @@ export async function getCompiler(stylesheet, projectSlug) {
|
|
|
79
107
|
return cached.compiler;
|
|
80
108
|
}
|
|
81
109
|
logger.debug("Creating new compiler", { hash, projectSlug });
|
|
82
|
-
const processor =
|
|
110
|
+
const processor = await resolveCSSProcessor();
|
|
83
111
|
if (!processor) {
|
|
84
112
|
logger.warn("No CSSProcessor extension registered — CSS output will be empty. Install it with: deno add @veryfront/ext-tailwind");
|
|
85
113
|
const noopCompiler = { build: () => "" };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "0.1.
|
|
1
|
+
export declare const VERSION = "0.1.321";
|
|
2
2
|
//# sourceMappingURL=version-constant.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "veryfront",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.321",
|
|
4
4
|
"description": "The simplest way to build AI-powered apps",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -239,6 +239,7 @@
|
|
|
239
239
|
"remark-parse": "11.0.0",
|
|
240
240
|
"remark-rehype": "11.1.2",
|
|
241
241
|
"tailwind-merge": "3.5.0",
|
|
242
|
+
"tailwindcss": "4.2.2",
|
|
242
243
|
"unified": "11.0.5",
|
|
243
244
|
"unist-util-visit": "5.1.0",
|
|
244
245
|
"vfile": "6.0.3",
|
package/src/deno.js
CHANGED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ext-tailwind — CSSProcessor implementation backed by Tailwind CSS v4.
|
|
3
|
+
*
|
|
4
|
+
* Provides the `CSSProcessor` contract:
|
|
5
|
+
* - `compile(stylesheet, options)` — delegates to tailwindcss `compile()`
|
|
6
|
+
* and returns a compiler whose `build(candidates)` emits CSS for the
|
|
7
|
+
* class-name candidates discovered at render time.
|
|
8
|
+
*
|
|
9
|
+
* The extension also installs three `globalThis` shims on setup so that
|
|
10
|
+
* Tailwind plugin bundles loaded at runtime from esm.sh can bind their
|
|
11
|
+
* `tailwindcss/plugin`, `tailwindcss/defaultTheme`, and `tailwindcss/colors`
|
|
12
|
+
* imports to the same tailwindcss copy this extension ships. Core's
|
|
13
|
+
* `plugin-loader.ts` rewrites plugin bundle code to reference these shims
|
|
14
|
+
* by name; without the shims installed, dynamic plugin loading fails.
|
|
15
|
+
*
|
|
16
|
+
* @module extensions/ext-tailwind
|
|
17
|
+
*/
|
|
18
|
+
import * as dntShim from "../../../_dnt.shims.js";
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
import type { ExtensionFactory } from "../../../src/extensions/index.js";
|
|
22
|
+
import type { CSSCompileOptions, CSSCompiler, CSSProcessor } from "../../../src/extensions/interfaces/index.js";
|
|
23
|
+
|
|
24
|
+
import { compile } from "tailwindcss";
|
|
25
|
+
import plugin from "tailwindcss/plugin";
|
|
26
|
+
import defaultTheme from "tailwindcss/defaultTheme";
|
|
27
|
+
import colors from "tailwindcss/colors";
|
|
28
|
+
|
|
29
|
+
type ShimGlobal = Record<string, unknown>;
|
|
30
|
+
|
|
31
|
+
function installTailwindPluginShims(): void {
|
|
32
|
+
const g = dntShim.dntGlobalThis as ShimGlobal;
|
|
33
|
+
g.__tailwindPluginShim = { default: plugin, __esModule: true };
|
|
34
|
+
g.__tailwindDefaultThemeShim = { default: defaultTheme, __esModule: true };
|
|
35
|
+
g.__tailwindColorsShim = { default: colors, __esModule: true };
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
class TailwindCSSProcessor implements CSSProcessor {
|
|
39
|
+
async compile(stylesheet: string, options: CSSCompileOptions): Promise<CSSCompiler> {
|
|
40
|
+
const native = await compile(stylesheet, {
|
|
41
|
+
base: options.base,
|
|
42
|
+
loadStylesheet: options.loadStylesheet,
|
|
43
|
+
loadModule: async (id: string) => {
|
|
44
|
+
const loaded = await options.loadModule(id);
|
|
45
|
+
// deno-lint-ignore no-explicit-any -- loaded plugin modules are opaque to the contract
|
|
46
|
+
return { module: loaded.module as any, base: loaded.base, path: loaded.path };
|
|
47
|
+
},
|
|
48
|
+
});
|
|
49
|
+
return {
|
|
50
|
+
build(candidates: string[]): string {
|
|
51
|
+
return native.build(candidates);
|
|
52
|
+
},
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const extTailwind: ExtensionFactory = () => {
|
|
58
|
+
const impl = new TailwindCSSProcessor();
|
|
59
|
+
return {
|
|
60
|
+
name: "ext-tailwind",
|
|
61
|
+
version: "0.1.0",
|
|
62
|
+
capabilities: [
|
|
63
|
+
{ type: "contract", name: "CSSProcessor" },
|
|
64
|
+
{ type: "net", hosts: ["esm.sh"] },
|
|
65
|
+
],
|
|
66
|
+
setup(ctx) {
|
|
67
|
+
installTailwindPluginShims();
|
|
68
|
+
ctx.provide("CSSProcessor", impl);
|
|
69
|
+
ctx.logger.info("[ext-tailwind] CSSProcessor registered");
|
|
70
|
+
},
|
|
71
|
+
teardown() {
|
|
72
|
+
// Shims stay installed — removing them could break in-flight plugin
|
|
73
|
+
// loads. The globalThis pollution is intentional and scoped to keys
|
|
74
|
+
// with `__tailwind` prefix.
|
|
75
|
+
},
|
|
76
|
+
};
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
export default extTailwind;
|
|
80
|
+
export { TailwindCSSProcessor };
|
|
@@ -14,7 +14,10 @@
|
|
|
14
14
|
* @module html/styles-builder/tailwind-compiler-cache
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
import {
|
|
17
|
+
import {
|
|
18
|
+
register as registerContract,
|
|
19
|
+
tryResolve as tryResolveContract,
|
|
20
|
+
} from "../../extensions/contracts.js";
|
|
18
21
|
import type { CSSCompiler, CSSProcessor } from "../../extensions/interfaces/index.js";
|
|
19
22
|
import { serverLogger } from "../../utils/index.js";
|
|
20
23
|
import { DEPENDENCY_MISSING, NETWORK_ERROR } from "../../errors/index.js";
|
|
@@ -71,6 +74,37 @@ async function getTailwindBaseCSS(): Promise<string> {
|
|
|
71
74
|
return tailwindBaseCSS;
|
|
72
75
|
}
|
|
73
76
|
|
|
77
|
+
async function resolveCSSProcessor(): Promise<CSSProcessor | undefined> {
|
|
78
|
+
const registeredProcessor = tryResolveContract<CSSProcessor>("CSSProcessor");
|
|
79
|
+
if (registeredProcessor) return registeredProcessor;
|
|
80
|
+
|
|
81
|
+
try {
|
|
82
|
+
const { default: createTailwindExtension } = await import(
|
|
83
|
+
"../../../extensions/ext-tailwind/src/index.js"
|
|
84
|
+
);
|
|
85
|
+
const extension = createTailwindExtension();
|
|
86
|
+
await extension.setup?.({
|
|
87
|
+
config: {},
|
|
88
|
+
logger,
|
|
89
|
+
provide: (name: string, impl: unknown) => registerContract(name, impl),
|
|
90
|
+
get: () => undefined,
|
|
91
|
+
require: <T>(name: string): T => {
|
|
92
|
+
const contract = tryResolveContract<T>(name);
|
|
93
|
+
if (contract === undefined) {
|
|
94
|
+
throw new Error(`Missing required extension contract: ${name}`);
|
|
95
|
+
}
|
|
96
|
+
return contract;
|
|
97
|
+
},
|
|
98
|
+
});
|
|
99
|
+
} catch (error) {
|
|
100
|
+
logger.warn("Failed to register built-in CSSProcessor extension", {
|
|
101
|
+
error: error instanceof Error ? error.message : String(error),
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
return tryResolveContract<CSSProcessor>("CSSProcessor");
|
|
106
|
+
}
|
|
107
|
+
|
|
74
108
|
function evictOldestCompiler(): void {
|
|
75
109
|
if (compilerCache.size < MAX_CACHED_COMPILERS) return;
|
|
76
110
|
|
|
@@ -108,7 +142,7 @@ export async function getCompiler(
|
|
|
108
142
|
|
|
109
143
|
logger.debug("Creating new compiler", { hash, projectSlug });
|
|
110
144
|
|
|
111
|
-
const processor =
|
|
145
|
+
const processor = await resolveCSSProcessor();
|
|
112
146
|
if (!processor) {
|
|
113
147
|
logger.warn(
|
|
114
148
|
"No CSSProcessor extension registered — CSS output will be empty. Install it with: deno add @veryfront/ext-tailwind",
|