@jk2908/cxx 0.2.3 → 0.2.6
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 +1 -1
- package/dist/build.d.ts +37 -0
- package/dist/build.d.ts.map +1 -0
- package/dist/build.js +188 -0
- package/dist/build.js.map +13 -0
- package/dist/index.d.ts +3 -36
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -184
- package/dist/index.js.map +4 -7
- package/dist/logger.d.ts +9 -9
- package/dist/lru.d.ts +2 -2
- package/dist/next/cxx-loader.cjs +37 -22
- package/dist/next/cxx-loader.cjs.map +7 -7
- package/dist/next/index.js +7 -13
- package/dist/next/index.js.map +6 -6
- package/dist/vite/index.d.ts +3 -3
- package/dist/vite/index.d.ts.map +1 -1
- package/dist/vite/index.js +9 -15
- package/dist/vite/index.js.map +7 -7
- package/package.json +13 -9
- package/src/build.ts +208 -0
- package/src/index.ts +3 -206
- package/src/logger.ts +9 -9
- package/src/lru.ts +2 -2
- package/src/next/index.ts +1 -1
- package/src/vite/index.ts +1 -1
package/dist/next/cxx-loader.cjs
CHANGED
|
@@ -4,38 +4,59 @@ var __defProp = Object.defineProperty;
|
|
|
4
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
5
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
function __accessProp(key) {
|
|
8
|
+
return this[key];
|
|
9
|
+
}
|
|
10
|
+
var __toESMCache_node;
|
|
11
|
+
var __toESMCache_esm;
|
|
7
12
|
var __toESM = (mod, isNodeMode, target) => {
|
|
13
|
+
var canCache = mod != null && typeof mod === "object";
|
|
14
|
+
if (canCache) {
|
|
15
|
+
var cache = isNodeMode ? __toESMCache_node ??= new WeakMap : __toESMCache_esm ??= new WeakMap;
|
|
16
|
+
var cached = cache.get(mod);
|
|
17
|
+
if (cached)
|
|
18
|
+
return cached;
|
|
19
|
+
}
|
|
8
20
|
target = mod != null ? __create(__getProtoOf(mod)) : {};
|
|
9
21
|
const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
|
|
10
22
|
for (let key of __getOwnPropNames(mod))
|
|
11
23
|
if (!__hasOwnProp.call(to, key))
|
|
12
24
|
__defProp(to, key, {
|
|
13
|
-
get: (
|
|
25
|
+
get: __accessProp.bind(mod, key),
|
|
14
26
|
enumerable: true
|
|
15
27
|
});
|
|
28
|
+
if (canCache)
|
|
29
|
+
cache.set(mod, to);
|
|
16
30
|
return to;
|
|
17
31
|
};
|
|
18
|
-
var __moduleCache = /* @__PURE__ */ new WeakMap;
|
|
19
32
|
var __toCommonJS = (from) => {
|
|
20
|
-
var entry = __moduleCache.get(from), desc;
|
|
33
|
+
var entry = (__moduleCache ??= new WeakMap).get(from), desc;
|
|
21
34
|
if (entry)
|
|
22
35
|
return entry;
|
|
23
36
|
entry = __defProp({}, "__esModule", { value: true });
|
|
24
|
-
if (from && typeof from === "object" || typeof from === "function")
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
37
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
38
|
+
for (var key of __getOwnPropNames(from))
|
|
39
|
+
if (!__hasOwnProp.call(entry, key))
|
|
40
|
+
__defProp(entry, key, {
|
|
41
|
+
get: __accessProp.bind(from, key),
|
|
42
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
43
|
+
});
|
|
44
|
+
}
|
|
29
45
|
__moduleCache.set(from, entry);
|
|
30
46
|
return entry;
|
|
31
47
|
};
|
|
48
|
+
var __moduleCache;
|
|
49
|
+
var __returnValue = (v) => v;
|
|
50
|
+
function __exportSetter(name, newValue) {
|
|
51
|
+
this[name] = __returnValue.bind(null, newValue);
|
|
52
|
+
}
|
|
32
53
|
var __export = (target, all) => {
|
|
33
54
|
for (var name in all)
|
|
34
55
|
__defProp(target, name, {
|
|
35
56
|
get: all[name],
|
|
36
57
|
enumerable: true,
|
|
37
58
|
configurable: true,
|
|
38
|
-
set: (
|
|
59
|
+
set: __exportSetter.bind(all, name)
|
|
39
60
|
});
|
|
40
61
|
};
|
|
41
62
|
|
|
@@ -139,7 +160,7 @@ var import_node_path2 = __toESM(require("node:path"));
|
|
|
139
160
|
var import_node_url = require("node:url");
|
|
140
161
|
var import_watcher = __toESM(require("@parcel/watcher"));
|
|
141
162
|
|
|
142
|
-
// src/
|
|
163
|
+
// src/build.ts
|
|
143
164
|
var import_node_crypto = require("node:crypto");
|
|
144
165
|
var import_promises = __toESM(require("node:fs/promises"));
|
|
145
166
|
var import_node_path = __toESM(require("node:path"));
|
|
@@ -194,7 +215,7 @@ function pascalise(str) {
|
|
|
194
215
|
return str.split(/[ _-]+/).map(capitalise).join("");
|
|
195
216
|
}
|
|
196
217
|
|
|
197
|
-
// src/
|
|
218
|
+
// src/build.ts
|
|
198
219
|
var collectCache = new LruCache;
|
|
199
220
|
var fileCache = new LruCache;
|
|
200
221
|
function isENOENT(err) {
|
|
@@ -225,7 +246,8 @@ function hashCss(code) {
|
|
|
225
246
|
return `cxx-${import_node_crypto.createHash("sha256").update(code).digest("base64url").slice(0, 12)}`;
|
|
226
247
|
}
|
|
227
248
|
|
|
228
|
-
class
|
|
249
|
+
class DuplicateTagError extends Error {
|
|
250
|
+
name = "DuplicateTagError";
|
|
229
251
|
constructor(tag) {
|
|
230
252
|
super(`Tag ${tag} has already been seen. Tags must be unique across your application`);
|
|
231
253
|
}
|
|
@@ -249,7 +271,7 @@ function collect(source, id, config) {
|
|
|
249
271
|
const suffix = typeof config.typeSuffix === "string" ? config.typeSuffix : config.typeSuffix === false ? "" : "Classes";
|
|
250
272
|
const tagWithSuffix = pascalise(`${tag}${suffix}`);
|
|
251
273
|
if (tags.has(tagWithSuffix))
|
|
252
|
-
throw new
|
|
274
|
+
throw new DuplicateTagError(tagWithSuffix);
|
|
253
275
|
tags.set(tagWithSuffix, Object.keys(styles));
|
|
254
276
|
}
|
|
255
277
|
return [
|
|
@@ -298,19 +320,12 @@ function flattenTags(tagsByFile) {
|
|
|
298
320
|
for (const fileTags of tagsByFile.values()) {
|
|
299
321
|
for (const [name, classes] of fileTags) {
|
|
300
322
|
if (tags.has(name))
|
|
301
|
-
throw new
|
|
323
|
+
throw new DuplicateTagError(name);
|
|
302
324
|
tags.set(name, classes);
|
|
303
325
|
}
|
|
304
326
|
}
|
|
305
327
|
return tags;
|
|
306
328
|
}
|
|
307
|
-
var cxx = Object.assign((_) => ["", {}, ""], {
|
|
308
|
-
tag: (_) => (_strings) => [
|
|
309
|
-
"",
|
|
310
|
-
{},
|
|
311
|
-
""
|
|
312
|
-
]
|
|
313
|
-
});
|
|
314
329
|
|
|
315
330
|
// src/next/index.ts
|
|
316
331
|
var nextDir = import_node_path2.default.dirname(import_node_url.fileURLToPath("file:///Users/jeromekenway/Documents/dev.nosync/me/repo/cxx/packages/cxx/src/next/index.ts"));
|
|
@@ -413,4 +428,4 @@ var loader2 = function(source) {
|
|
|
413
428
|
};
|
|
414
429
|
var cxx_loader_default = loader2;
|
|
415
430
|
|
|
416
|
-
//# debugId=
|
|
431
|
+
//# debugId=207C47062023FB5664756E2164756E21
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../../src/logger.ts", "../../src/next/index.ts", "../../src/
|
|
3
|
+
"sources": ["../../src/logger.ts", "../../src/next/index.ts", "../../src/build.ts", "../../src/config.ts", "../../src/lru.ts", "../../src/utils.ts", "../../src/next/cxx-loader.js"],
|
|
4
4
|
"sourcesContent": [
|
|
5
|
-
"const LEVELS = {\n\tdebug: 0,\n\tinfo: 1,\n\twarn: 2,\n\terror: 3,\n\tfatal: 4,\n} as const\n\nexport type LogLevel = keyof typeof LEVELS\n\ntype LogEntry = {\n\tts: number\n\tlevel: LogLevel\n\tmessage: string\n\terror?:\n\t\t| Error\n\t\t| {\n\t\t\t\tmessage: string\n\t\t\t\tstack?: string\n\t\t\t\tcause?: unknown\n\t\t }\n}\n\n/**\n * Log messages with different severity levels
|
|
6
|
-
"import type { AsyncSubscription, Event } from '@parcel/watcher'\nimport type { NextConfig } from 'next'\n\nimport fs from 'node:fs/promises'\nimport path from 'node:path'\nimport { fileURLToPath } from 'node:url'\n\nimport watcher from '@parcel/watcher'\n\nimport type { Logger } from '../logger.js'\nimport type { PluginConfig, Tags } from '../types.js'\nimport { collect, flattenTags, isENOENT, writeTypes } from '../
|
|
7
|
-
"import { createHash } from 'node:crypto'\nimport fs from 'node:fs/promises'\nimport path from 'node:path'\n\nimport { transform } from 'lightningcss'\n\nimport type { BuildContext,
|
|
5
|
+
"const LEVELS = {\n\tdebug: 0,\n\tinfo: 1,\n\twarn: 2,\n\terror: 3,\n\tfatal: 4,\n} as const\n\nexport type LogLevel = keyof typeof LEVELS\n\ntype LogEntry = {\n\tts: number\n\tlevel: LogLevel\n\tmessage: string\n\terror?:\n\t\t| Error\n\t\t| {\n\t\t\t\tmessage: string\n\t\t\t\tstack?: string\n\t\t\t\tcause?: unknown\n\t\t }\n}\n\n/**\n * Log messages with different severity levels.\n */\nexport class Logger {\n\tstatic #defaultLevel: LogLevel = 'info'\n\n\t#level?: LogLevel\n\n\tconstructor(\n\t\tlevel?: LogLevel,\n\t\tpublic name?: string,\n\t) {\n\t\tthis.#level = level\n\t}\n\n\tstatic set defaultLevel(level: LogLevel) {\n\t\tLogger.#defaultLevel = level\n\t}\n\n\tstatic get defaultLevel() {\n\t\treturn Logger.#defaultLevel\n\t}\n\n\t/**\n\t * Convert a value to an Error instance.\n\t */\n\tstatic toError(err: unknown) {\n\t\treturn err instanceof Error ? err : new Error(String(err), { cause: err })\n\t}\n\n\t/**\n\t * Stringify the error for logging.\n\t */\n\tstatic print(err: unknown) {\n\t\tif (err instanceof Error) {\n\t\t\treturn err.message + (err.stack ? `\\n${err.stack}` : '')\n\t\t}\n\n\t\t// for plain objects, attempt to stringify with indentation\n\t\t// for readability\n\t\tif (typeof err === 'object' && err !== null) {\n\t\t\ttry {\n\t\t\t\treturn JSON.stringify(err, null, 2)\n\t\t\t} catch {\n\t\t\t\t// if stringify fails (e.g. circular reference), fall back\n\t\t\t\t// to basic string conversion\n\t\t\t\treturn String(err)\n\t\t\t}\n\t\t}\n\n\t\treturn String(err)\n\t}\n\n\tset level(level: LogLevel) {\n\t\tthis.#level = level\n\t}\n\n\tget level() {\n\t\treturn this.#level ?? Logger.#defaultLevel\n\t}\n\n\t/**\n\t * Log a message with a specific level.\n\t */\n\tlog(level: LogLevel, message: string, error?: Error) {\n\t\tif (LEVELS[level] < LEVELS[this.level]) return\n\n\t\tconst entry: LogEntry = {\n\t\t\tts: Date.now(),\n\t\t\tlevel,\n\t\t\tmessage,\n\t\t}\n\n\t\tif (level === 'error' || level === 'fatal') {\n\t\t\tentry.error = error ? Logger.toError(error) : new Error(message)\n\t\t}\n\n\t\tconst line = `${this.name ? `[${this.name}]` : ''} [${entry.ts}] [${level.toUpperCase()}] ${message}`\n\t\tconst extra = entry.error ? `\\n${Logger.print(entry.error)}` : ''\n\n\t\tif (level === 'warn') {\n\t\t\tconsole.warn(line, extra)\n\t\t\treturn\n\t\t}\n\n\t\tif (level === 'error' || level === 'fatal') {\n\t\t\tconsole.error(line, extra)\n\t\t\treturn\n\t\t}\n\n\t\tconsole.log(line, extra)\n\t}\n\n\t/**\n\t * Log a debug message.\n\t */\n\tdebug(...messages: string[]) {\n\t\tthis.log('debug', messages.join(' '))\n\t}\n\n\t/**\n\t * Log an info message.\n\t */\n\tinfo(...messages: string[]) {\n\t\tthis.log('info', messages.join(' '))\n\t}\n\n\t/**\n\t * Log a warning message.\n\t */\n\twarn(...messages: string[]) {\n\t\tthis.log('warn', messages.join(' '))\n\t}\n\n\t/**\n\t * Log an error message.\n\t */\n\terror(message: string, error?: unknown) {\n\t\tthis.log('error', message, error === undefined ? undefined : Logger.toError(error))\n\t}\n\n\t/**\n\t * Log a fatal error message.\n\t */\n\tfatal(message: string, error?: unknown) {\n\t\tthis.log('fatal', message, error === undefined ? undefined : Logger.toError(error))\n\t}\n}\n",
|
|
6
|
+
"import type { AsyncSubscription, Event } from '@parcel/watcher'\nimport type { NextConfig } from 'next'\n\nimport fs from 'node:fs/promises'\nimport path from 'node:path'\nimport { fileURLToPath } from 'node:url'\n\nimport watcher from '@parcel/watcher'\n\nimport type { Logger } from '../logger.js'\nimport type { PluginConfig, Tags } from '../types.js'\nimport { collect, flattenTags, isENOENT, writeTypes } from '../build.js'\n\nconst nextDir = path.dirname(fileURLToPath(import.meta.url))\nconst loader = path.join(nextDir, 'cxx-loader.cjs')\n\n// keep the latest extracted tags per file so one edit can rebuild the full type surface\nconst tagsByFile: Map<string, Tags> = new Map()\n\n// directory watches are shared, but rebuilds still need the file's config and logger\nconst watchedFiles = new Map<string, { pluginConfig: PluginConfig; logger: Logger }>()\nconst subscriptionsByDir = new Map<string, Promise<AsyncSubscription>>()\n\n/**\n * Rebuild the generated type surface for one watched file after a Parcel event\n */\nasync function rebuildFile(filePath: string, event: Event['type']) {\n\tconst watchedFile = watchedFiles.get(filePath)\n\tif (!watchedFile) return\n\n\tconst { pluginConfig, logger } = watchedFile\n\tconst hadTags = tagsByFile.has(filePath)\n\n\tif (event === 'delete') {\n\t\ttagsByFile.delete(filePath)\n\t\tif (!hadTags) return\n\n\t\tawait writeTypes(flattenTags(tagsByFile))\n\t\tlogger.info(`updated types from ${filePath}`)\n\n\t\treturn\n\t}\n\n\ttry {\n\t\tconst source = await fs.readFile(filePath, 'utf-8')\n\t\tconst { tags } = collect(source, filePath, pluginConfig)\n\t\tconst hasTags = tags.size > 0\n\n\t\tif (hasTags) {\n\t\t\ttagsByFile.set(filePath, tags)\n\t\t} else {\n\t\t\ttagsByFile.delete(filePath)\n\t\t}\n\n\t\tif (!hadTags && !hasTags) return\n\n\t\tawait writeTypes(flattenTags(tagsByFile))\n\t\tlogger.info(`updated types from ${filePath}`)\n\t} catch (err) {\n\t\tif (!isENOENT(err)) throw err\n\t\tif (!hadTags) return\n\n\t\ttagsByFile.delete(filePath)\n\t\tawait writeTypes(flattenTags(tagsByFile))\n\n\t\tlogger.info(`updated types from ${filePath}`)\n\t}\n}\n\n/**\n * Transform one module and, in development, register it with the shared watcher state\n */\nexport function processFile(\n\tsource: string,\n\tfilePath: string,\n\tpluginConfig: PluginConfig,\n\tlogger: Logger,\n) {\n\tconst resolvedFilePath = path.resolve(filePath)\n\tconst directoryPath = path.dirname(resolvedFilePath)\n\tlet subscription = subscriptionsByDir.get(directoryPath)\n\n\tif (process.env.NODE_ENV !== 'production') {\n\t\t// Parcel watches directories, so remember the exact file inputs we care about\n\t\twatchedFiles.set(resolvedFilePath, { pluginConfig, logger })\n\n\t\tif (!subscription) {\n\t\t\t// one subscription per directory is enough; the callback filters back down to watched files\n\t\t\tsubscription = watcher.subscribe(directoryPath, async (err, events) => {\n\t\t\t\tif (err) {\n\t\t\t\t\tlogger.error(`failed to update types from ${directoryPath}`, err)\n\t\t\t\t\treturn\n\t\t\t\t}\n\n\t\t\t\t// Parcel can report unrelated files from the same directory, so ignore anything unregistered\n\t\t\t\tfor (const event of events) {\n\t\t\t\t\tconst eventFilePath = path.resolve(event.path)\n\t\t\t\t\tif (!watchedFiles.has(eventFilePath)) continue\n\n\t\t\t\t\ttry {\n\t\t\t\t\t\tawait rebuildFile(eventFilePath, event.type)\n\t\t\t\t\t} catch (watchErr) {\n\t\t\t\t\t\tlogger.error(`failed to update types from ${eventFilePath}`, watchErr)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t})\n\n\t\t\tsubscriptionsByDir.set(directoryPath, subscription)\n\t\t}\n\t}\n\n\tconst result = collect(source, filePath, pluginConfig)\n\n\tif (result.tags.size > 0) {\n\t\ttagsByFile.set(filePath, result.tags)\n\t} else {\n\t\ttagsByFile.delete(filePath)\n\t}\n\n\tvoid writeTypes(flattenTags(tagsByFile))\n\n\treturn result\n}\n\n/**\n * Close all active Parcel subscriptions before the process exits\n */\nasync function cleanup() {\n\tawait Promise.all(\n\t\t[...subscriptionsByDir].map(async ([directoryPath, subPromise]) => {\n\t\t\tsubscriptionsByDir.delete(directoryPath)\n\t\t\tawait (await subPromise).unsubscribe()\n\t\t}),\n\t)\n\n\tsubscriptionsByDir.clear()\n}\n\nprocess.once('SIGINT', () => {\n\tcleanup().finally(() => process.exit(130))\n})\n\nprocess.once('SIGTERM', () => {\n\tcleanup().finally(() => process.exit(143))\n})\n\nexport async function withCxx(\n\tnextConfig: NextConfig = {},\n\tpluginConfig: PluginConfig = {},\n) {\n\tconst TURBOPACK_GLOB = '*.{tsx,jsx,ts,js}'\n\n\tconst loaderItem = {\n\t\tloader,\n\t\toptions: {\n\t\t\tpluginConfig,\n\t\t},\n\t}\n\n\tconst currentRule = nextConfig.turbopack?.rules?.[TURBOPACK_GLOB]\n\n\treturn {\n\t\t...nextConfig,\n\t\tturbopack: {\n\t\t\t...nextConfig.turbopack,\n\t\t\trules: {\n\t\t\t\t...nextConfig.turbopack?.rules,\n\t\t\t\t[TURBOPACK_GLOB]: Array.isArray(currentRule)\n\t\t\t\t\t? [...currentRule, loaderItem]\n\t\t\t\t\t: currentRule\n\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\t...currentRule,\n\t\t\t\t\t\t\t\tloaders: [...(currentRule.loaders ?? []), loaderItem],\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t: { loaders: [loaderItem] },\n\t\t\t},\n\t\t},\n\t}\n}\n",
|
|
7
|
+
"import { createHash } from 'node:crypto'\nimport fs from 'node:fs/promises'\nimport path from 'node:path'\n\nimport { transform } from 'lightningcss'\n\nimport type { BuildContext, PluginConfig, Tags } from './types.js'\nimport { AUTOGEN_MSG, GENERATED_DIR, PKG_NAME } from './config.js'\nimport { LruCache } from './lru.js'\nimport { pascalise } from './utils.js'\n\n/**\n * LRU cache of `collect` results by file id and last seen source so watcher and transform can\n * reuse the same parsed template/tags.\n */\nconst collectCache = new LruCache<{ source: string; template: string; tags: Tags }>()\n\n/**\n * LRU cache for file content. Stores the last written content per file path so `maybeWrite`\n * can skip disk i/o when nothing has changed.\n */\nconst fileCache = new LruCache<string>()\n\n/**\n * Returns whether the error was caused by a missing file or directory.\n */\nexport function isENOENT(err: unknown) {\n\treturn err instanceof Error && 'code' in err && err.code === 'ENOENT'\n}\n\n/**\n * Write a file only if the content has changed since the last build.\n */\nexport async function maybeWrite(filePath: string, content: string) {\n\tconst cached = fileCache.get(filePath)\n\n\tif (cached !== content) {\n\t\t// cache says content changed, write without reading\n\t\tawait fs.writeFile(filePath, content)\n\t\tfileCache.set(filePath, content)\n\n\t\treturn true\n\t}\n\n\t// cache miss or cache hit with same content — verify on disk\n\ttry {\n\t\tif ((await fs.readFile(filePath, 'utf-8')) === content) {\n\t\t\tfileCache.set(filePath, content)\n\t\t\treturn false\n\t\t}\n\t} catch (err) {\n\t\tif (!isENOENT(err)) throw err\n\t}\n\n\tawait fs.writeFile(filePath, content)\n\tfileCache.set(filePath, content)\n\n\treturn true\n}\n\n// matches `[css, classes, href] = cxx\\`...\\`` and `cxx.tag<T>('name')\\`...\\``\n// capture groups: 1-3 assigned variable names, 4 plain css body, 5 quote\n// kind, 6 tag name, 7 tagged css body\nconst regex =\n\t/(?:const|var|let)\\s*\\[(\\w+|)\\s*,?\\s*(\\w+|)\\s*,?\\s*(\\w+|)\\s*\\]\\s*=\\s*cxx(?:\\s*`([\\s\\S]*?)`|\\s*\\.\\s*tag(?:\\s*<[^>]+>)?\\s*\\(\\s*(['\"])(.*?)\\5\\s*\\)\\s*`([\\s\\S]*?)`)/gm\n\n/**\n * Hash transformed CSS into a stable href for style deduplication.\n */\nfunction hashCss(code: Uint8Array) {\n\treturn `cxx-${createHash('sha256').update(code).digest('base64url').slice(0, 12)}`\n}\n\nexport class DuplicateTagError extends Error {\n\tname = 'DuplicateTagError'\n\n\tconstructor(tag: string) {\n\t\tsuper(`Tag ${tag} has already been seen. Tags must be unique across your application`)\n\t}\n}\n\n/**\n * Transform `cxx` templates in one source file and collect any exported tag types.\n */\nexport function collect(source: string, id: string, config: PluginConfig) {\n\tconst tags: Tags = new Map()\n\n\tconst cached = collectCache.get(id)\n\tif (cached?.source === source) return cached\n\n\tconst template = source.replace(\n\t\tregex,\n\t\t(_match, varOne, varTwo, varThree, plainCss, _quote, tag, taggedCss) => {\n\t\t\tconst css = plainCss ?? taggedCss\n\n\t\t\tconst { code, exports = {} } = transform({\n\t\t\t\tminify: true,\n\t\t\t\tcssModules: true,\n\t\t\t\tfilename: id,\n\t\t\t\tcode: new TextEncoder().encode(css),\n\t\t\t})\n\n\t\t\tconst href = hashCss(code)\n\t\t\tconst styles = Object.fromEntries(\n\t\t\t\tObject.entries(exports).map(([k, v]) => [k, v.name]),\n\t\t\t)\n\n\t\t\tif (tag) {\n\t\t\t\tconst suffix =\n\t\t\t\t\ttypeof config.typeSuffix === 'string'\n\t\t\t\t\t\t? config.typeSuffix\n\t\t\t\t\t\t: config.typeSuffix === false\n\t\t\t\t\t\t\t? ''\n\t\t\t\t\t\t\t: 'Classes'\n\t\t\t\tconst tagWithSuffix = pascalise(`${tag}${suffix}`)\n\n\t\t\t\tif (tags.has(tagWithSuffix)) throw new DuplicateTagError(tagWithSuffix)\n\n\t\t\t\t// side effect but neccessary\n\t\t\t\ttags.set(tagWithSuffix, Object.keys(styles))\n\t\t\t}\n\n\t\t\treturn [\n\t\t\t\tvarOne && `const ${varOne} = \\`${code}\\``,\n\t\t\t\tvarTwo && `const ${varTwo} = ${JSON.stringify(styles)}`,\n\t\t\t\tvarThree && `const ${varThree} = \\`${href}\\``,\n\t\t\t]\n\t\t\t\t.filter(Boolean)\n\t\t\t\t.join('\\n')\n\t\t},\n\t)\n\n\t// cache\n\tcollectCache.set(id, { source, template, tags })\n\n\treturn {\n\t\ttemplate,\n\t\ttags,\n\t}\n}\n\n/**\n * Write the generated declaration file for the current set of collected tags.\n */\nexport async function writeTypes(tags: Tags) {\n\tconst filePath = path.join(GENERATED_DIR, 'index.d.ts')\n\n\tif (!tags.size) {\n\t\ttry {\n\t\t\tawait fs.rm(filePath, { force: true })\n\t\t\tfileCache.delete(filePath)\n\t\t} catch (err) {\n\t\t\tif (!isENOENT(err)) throw err\n\t\t}\n\n\t\treturn\n\t}\n\n\tawait fs.mkdir(GENERATED_DIR, { recursive: true })\n\n\tawait maybeWrite(\n\t\tfilePath,\n\t\t`${AUTOGEN_MSG}\n\n\t\t\timport '${PKG_NAME}'\n\n\t\t\tdeclare module '${PKG_NAME}' {\n\t\t\t\t${tagsToType(tags)}\n\t\t\t}\n\t\t`,\n\t)\n}\n\n/**\n * Render collected tags as a module augmentation for the package entrypoint.\n */\nexport function tagsToType(tags: Tags) {\n\treturn [...tags]\n\t\t.map(\n\t\t\t([tag, classes]) => `\n\t\texport type ${tag} = ${\n\t\t\tclasses.length > 0\n\t\t\t\t? classes\n\t\t\t\t\t\t.toSorted((a, b) => a.length - b.length)\n\t\t\t\t\t\t.map(c => `'${c}'`)\n\t\t\t\t\t\t.join(' | ')\n\t\t\t\t: 'never'\n\t\t}\n\t`,\n\t\t)\n\t\t.join('\\n')\n}\n\n/**\n * Merge per-file tag maps into one application-wide tag map.\n */\nexport function flattenTags(tagsByFile: BuildContext['tagsByFile']) {\n\tconst tags = new Map<string, string[]>()\n\n\tfor (const fileTags of tagsByFile.values()) {\n\t\tfor (const [name, classes] of fileTags) {\n\t\t\tif (tags.has(name)) throw new DuplicateTagError(name)\n\t\t\ttags.set(name, classes)\n\t\t}\n\t}\n\n\treturn tags\n}\n",
|
|
8
8
|
"export const NAME = 'cxx'\nexport const PKG_NAME = `@jk2908/${NAME}`\nexport const GENERATED_DIR = `.${NAME}`\nexport const AUTOGEN_MSG = `// auto-generated by ${NAME}`\n",
|
|
9
|
-
"export const CACHE_MAX_SIZE = 100\n\nexport class LruCache<T> {\n\t#cache: Map<string, T> = new Map()\n\t#maxSize: number\n\n\tconstructor(maxSize = CACHE_MAX_SIZE) {\n\t\tthis.#maxSize = maxSize\n\t}\n\n\tget size() {\n\t\treturn this.#cache.size\n\t}\n\n\t/**\n\t * Retrieve a cached value and promote it to most-recently-used so it won't\n\t * be evicted while still actively referenced
|
|
9
|
+
"export const CACHE_MAX_SIZE = 100\n\nexport class LruCache<T> {\n\t#cache: Map<string, T> = new Map()\n\t#maxSize: number\n\n\tconstructor(maxSize = CACHE_MAX_SIZE) {\n\t\tthis.#maxSize = maxSize\n\t}\n\n\tget size() {\n\t\treturn this.#cache.size\n\t}\n\n\t/**\n\t * Retrieve a cached value and promote it to most-recently-used so it won't\n\t * be evicted while still actively referenced.\n\t */\n\tget(key: string) {\n\t\tconst cached = this.#cache.get(key)\n\t\tif (this.#cache.has(key)) this.set(key, cached as T)\n\n\t\treturn cached\n\t}\n\n\t/**\n\t * Promote an existing cache entry to most-recently-used by deleting and\n\t * re-inserting it, which moves it to the end of the Map's iteration\n\t * order. If the cache is at capacity, evict the least recently used\n\t * entry (front) before inserting.\n\t */\n\tset(key: string, value: T) {\n\t\t// drop any existing entry\n\t\tthis.#cache.delete(key)\n\n\t\tif (this.#cache.size >= this.#maxSize) {\n\t\t\tconst lru = this.#cache.keys().next().value\n\t\t\tif (lru !== undefined) this.#cache.delete(lru)\n\t\t}\n\n\t\tthis.#cache.set(key, value)\n\t}\n\n\tdelete(key: string) {\n\t\treturn this.#cache.delete(key)\n\t}\n\n\tclear() {\n\t\treturn this.#cache.clear()\n\t}\n}\n",
|
|
10
10
|
"export function capitalise(str: string) {\n\treturn str.charAt(0).toUpperCase() + str.slice(1)\n}\n\nexport function pascalise(str: string) {\n\treturn str\n\t\t.split(/[ _-]+/)\n\t\t.map(capitalise)\n\t\t.join('')\n}\n\nexport function debounce<T extends unknown[]>(fn: (...args: T) => void, wait: number) {\n\tlet timeoutId: ReturnType<typeof setTimeout> | null = null\n\n\treturn (...args: T) => {\n\t\tif (timeoutId) {\n\t\t\tclearTimeout(timeoutId)\n\t\t}\n\n\t\ttimeoutId = setTimeout(() => {\n\t\t\tfn.apply(null, args)\n\t\t}, wait)\n\t}\n}\n",
|
|
11
11
|
"import { Logger } from '../logger.js'\nimport { processFile } from './index.js'\n\nconst loader = function (source) {\n\tconst { pluginConfig } = this.getOptions()\n\tconst logger = new Logger(\n\t\t(pluginConfig?.logger?.level ?? process.env.NODE_ENV === 'production')\n\t\t\t? 'error'\n\t\t\t: 'debug',\n\t)\n\n\tconst { template } = processFile(source, this.resourcePath, pluginConfig, logger)\n\n\treturn template\n}\n\nexport default loader\n"
|
|
12
12
|
],
|
|
13
|
-
"mappings": "
|
|
14
|
-
"debugId": "
|
|
13
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAM,SAAS;AAAA,EACd,OAAO;AAAA,EACP,MAAM;AAAA,EACN,MAAM;AAAA,EACN,OAAO;AAAA,EACP,OAAO;AACR;AAAA;AAoBO,MAAM,OAAO;AAAA,EAOX;AAAA,SAND,gBAA0B;AAAA,EAEjC;AAAA,EAEA,WAAW,CACV,OACO,MACN;AAAA,IADM;AAAA,IAEP,KAAK,SAAS;AAAA;AAAA,aAGJ,YAAY,CAAC,OAAiB;AAAA,IACxC,OAAO,gBAAgB;AAAA;AAAA,aAGb,YAAY,GAAG;AAAA,IACzB,OAAO,OAAO;AAAA;AAAA,SAMR,OAAO,CAAC,KAAc;AAAA,IAC5B,OAAO,eAAe,QAAQ,MAAM,IAAI,MAAM,OAAO,GAAG,GAAG,EAAE,OAAO,IAAI,CAAC;AAAA;AAAA,SAMnE,KAAK,CAAC,KAAc;AAAA,IAC1B,IAAI,eAAe,OAAO;AAAA,MACzB,OAAO,IAAI,WAAW,IAAI,QAAQ;AAAA,EAAK,IAAI,UAAU;AAAA,IACtD;AAAA,IAIA,IAAI,OAAO,QAAQ,YAAY,QAAQ,MAAM;AAAA,MAC5C,IAAI;AAAA,QACH,OAAO,KAAK,UAAU,KAAK,MAAM,CAAC;AAAA,QACjC,MAAM;AAAA,QAGP,OAA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AU,MAAM;AAAA,EAC5B,QAAQ,EAAE,QAAQ,MAAM,QAAQ,KAAK,GAAG,CAAC;AAAA,CACzC;AAED,QAAQ,KAAK,WAAW,MAAM;AAAA,EAC7B,QAAQ,EAAE,QAAQ,MAAM,QAAQ,KAAK,GAAG,CAAC;AAAA,CACzC;;;AK7ID,IAAM,UAAS,QAAS,CAAC,QAAQ;AAAA,EAChC,QAAQ,iBAAiB,KAAK,WAAW;AAAA,EACzC,MAAM,SAAS,IAAI,OACjB,cAAc,QAAQ,SAAS,QAC7B,UACA,OACJ;AAAA,EAEA,QAAQ,aAAa,YAAY,QAAQ,KAAK,cAAc,cAAc,MAAM;AAAA,EAEhF,OAAO;AAAA;AAGR,IAAe;",
|
|
14
|
+
"debugId": "207C47062023FB5664756E2164756E21",
|
|
15
15
|
"names": []
|
|
16
16
|
}
|
package/dist/next/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// src/
|
|
1
|
+
// src/build.ts
|
|
2
2
|
import { createHash } from "node:crypto";
|
|
3
3
|
import fs from "node:fs/promises";
|
|
4
4
|
import path from "node:path";
|
|
@@ -64,7 +64,7 @@ function debounce(fn, wait) {
|
|
|
64
64
|
};
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
-
// src/
|
|
67
|
+
// src/build.ts
|
|
68
68
|
var collectCache = new LruCache;
|
|
69
69
|
var fileCache = new LruCache;
|
|
70
70
|
function isENOENT(err) {
|
|
@@ -95,7 +95,8 @@ function hashCss(code) {
|
|
|
95
95
|
return `cxx-${createHash("sha256").update(code).digest("base64url").slice(0, 12)}`;
|
|
96
96
|
}
|
|
97
97
|
|
|
98
|
-
class
|
|
98
|
+
class DuplicateTagError extends Error {
|
|
99
|
+
name = "DuplicateTagError";
|
|
99
100
|
constructor(tag) {
|
|
100
101
|
super(`Tag ${tag} has already been seen. Tags must be unique across your application`);
|
|
101
102
|
}
|
|
@@ -119,7 +120,7 @@ function collect(source, id, config) {
|
|
|
119
120
|
const suffix = typeof config.typeSuffix === "string" ? config.typeSuffix : config.typeSuffix === false ? "" : "Classes";
|
|
120
121
|
const tagWithSuffix = pascalise(`${tag}${suffix}`);
|
|
121
122
|
if (tags.has(tagWithSuffix))
|
|
122
|
-
throw new
|
|
123
|
+
throw new DuplicateTagError(tagWithSuffix);
|
|
123
124
|
tags.set(tagWithSuffix, Object.keys(styles));
|
|
124
125
|
}
|
|
125
126
|
return [
|
|
@@ -168,19 +169,12 @@ function flattenTags(tagsByFile) {
|
|
|
168
169
|
for (const fileTags of tagsByFile.values()) {
|
|
169
170
|
for (const [name, classes] of fileTags) {
|
|
170
171
|
if (tags.has(name))
|
|
171
|
-
throw new
|
|
172
|
+
throw new DuplicateTagError(name);
|
|
172
173
|
tags.set(name, classes);
|
|
173
174
|
}
|
|
174
175
|
}
|
|
175
176
|
return tags;
|
|
176
177
|
}
|
|
177
|
-
var cxx = Object.assign((_) => ["", {}, ""], {
|
|
178
|
-
tag: (_) => (_strings) => [
|
|
179
|
-
"",
|
|
180
|
-
{},
|
|
181
|
-
""
|
|
182
|
-
]
|
|
183
|
-
});
|
|
184
178
|
|
|
185
179
|
// src/next/index.ts
|
|
186
180
|
import fs2 from "node:fs/promises";
|
|
@@ -305,4 +299,4 @@ export {
|
|
|
305
299
|
processFile
|
|
306
300
|
};
|
|
307
301
|
|
|
308
|
-
//# debugId=
|
|
302
|
+
//# debugId=B9F61A8763996E6064756E2164756E21
|
package/dist/next/index.js.map
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../src/
|
|
3
|
+
"sources": ["../src/build.ts", "../src/config.ts", "../src/lru.ts", "../src/utils.ts", "../src/next/index.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
|
-
"import { createHash } from 'node:crypto'\nimport fs from 'node:fs/promises'\nimport path from 'node:path'\n\nimport { transform } from 'lightningcss'\n\nimport type { BuildContext,
|
|
5
|
+
"import { createHash } from 'node:crypto'\nimport fs from 'node:fs/promises'\nimport path from 'node:path'\n\nimport { transform } from 'lightningcss'\n\nimport type { BuildContext, PluginConfig, Tags } from './types.js'\nimport { AUTOGEN_MSG, GENERATED_DIR, PKG_NAME } from './config.js'\nimport { LruCache } from './lru.js'\nimport { pascalise } from './utils.js'\n\n/**\n * LRU cache of `collect` results by file id and last seen source so watcher and transform can\n * reuse the same parsed template/tags.\n */\nconst collectCache = new LruCache<{ source: string; template: string; tags: Tags }>()\n\n/**\n * LRU cache for file content. Stores the last written content per file path so `maybeWrite`\n * can skip disk i/o when nothing has changed.\n */\nconst fileCache = new LruCache<string>()\n\n/**\n * Returns whether the error was caused by a missing file or directory.\n */\nexport function isENOENT(err: unknown) {\n\treturn err instanceof Error && 'code' in err && err.code === 'ENOENT'\n}\n\n/**\n * Write a file only if the content has changed since the last build.\n */\nexport async function maybeWrite(filePath: string, content: string) {\n\tconst cached = fileCache.get(filePath)\n\n\tif (cached !== content) {\n\t\t// cache says content changed, write without reading\n\t\tawait fs.writeFile(filePath, content)\n\t\tfileCache.set(filePath, content)\n\n\t\treturn true\n\t}\n\n\t// cache miss or cache hit with same content — verify on disk\n\ttry {\n\t\tif ((await fs.readFile(filePath, 'utf-8')) === content) {\n\t\t\tfileCache.set(filePath, content)\n\t\t\treturn false\n\t\t}\n\t} catch (err) {\n\t\tif (!isENOENT(err)) throw err\n\t}\n\n\tawait fs.writeFile(filePath, content)\n\tfileCache.set(filePath, content)\n\n\treturn true\n}\n\n// matches `[css, classes, href] = cxx\\`...\\`` and `cxx.tag<T>('name')\\`...\\``\n// capture groups: 1-3 assigned variable names, 4 plain css body, 5 quote\n// kind, 6 tag name, 7 tagged css body\nconst regex =\n\t/(?:const|var|let)\\s*\\[(\\w+|)\\s*,?\\s*(\\w+|)\\s*,?\\s*(\\w+|)\\s*\\]\\s*=\\s*cxx(?:\\s*`([\\s\\S]*?)`|\\s*\\.\\s*tag(?:\\s*<[^>]+>)?\\s*\\(\\s*(['\"])(.*?)\\5\\s*\\)\\s*`([\\s\\S]*?)`)/gm\n\n/**\n * Hash transformed CSS into a stable href for style deduplication.\n */\nfunction hashCss(code: Uint8Array) {\n\treturn `cxx-${createHash('sha256').update(code).digest('base64url').slice(0, 12)}`\n}\n\nexport class DuplicateTagError extends Error {\n\tname = 'DuplicateTagError'\n\n\tconstructor(tag: string) {\n\t\tsuper(`Tag ${tag} has already been seen. Tags must be unique across your application`)\n\t}\n}\n\n/**\n * Transform `cxx` templates in one source file and collect any exported tag types.\n */\nexport function collect(source: string, id: string, config: PluginConfig) {\n\tconst tags: Tags = new Map()\n\n\tconst cached = collectCache.get(id)\n\tif (cached?.source === source) return cached\n\n\tconst template = source.replace(\n\t\tregex,\n\t\t(_match, varOne, varTwo, varThree, plainCss, _quote, tag, taggedCss) => {\n\t\t\tconst css = plainCss ?? taggedCss\n\n\t\t\tconst { code, exports = {} } = transform({\n\t\t\t\tminify: true,\n\t\t\t\tcssModules: true,\n\t\t\t\tfilename: id,\n\t\t\t\tcode: new TextEncoder().encode(css),\n\t\t\t})\n\n\t\t\tconst href = hashCss(code)\n\t\t\tconst styles = Object.fromEntries(\n\t\t\t\tObject.entries(exports).map(([k, v]) => [k, v.name]),\n\t\t\t)\n\n\t\t\tif (tag) {\n\t\t\t\tconst suffix =\n\t\t\t\t\ttypeof config.typeSuffix === 'string'\n\t\t\t\t\t\t? config.typeSuffix\n\t\t\t\t\t\t: config.typeSuffix === false\n\t\t\t\t\t\t\t? ''\n\t\t\t\t\t\t\t: 'Classes'\n\t\t\t\tconst tagWithSuffix = pascalise(`${tag}${suffix}`)\n\n\t\t\t\tif (tags.has(tagWithSuffix)) throw new DuplicateTagError(tagWithSuffix)\n\n\t\t\t\t// side effect but neccessary\n\t\t\t\ttags.set(tagWithSuffix, Object.keys(styles))\n\t\t\t}\n\n\t\t\treturn [\n\t\t\t\tvarOne && `const ${varOne} = \\`${code}\\``,\n\t\t\t\tvarTwo && `const ${varTwo} = ${JSON.stringify(styles)}`,\n\t\t\t\tvarThree && `const ${varThree} = \\`${href}\\``,\n\t\t\t]\n\t\t\t\t.filter(Boolean)\n\t\t\t\t.join('\\n')\n\t\t},\n\t)\n\n\t// cache\n\tcollectCache.set(id, { source, template, tags })\n\n\treturn {\n\t\ttemplate,\n\t\ttags,\n\t}\n}\n\n/**\n * Write the generated declaration file for the current set of collected tags.\n */\nexport async function writeTypes(tags: Tags) {\n\tconst filePath = path.join(GENERATED_DIR, 'index.d.ts')\n\n\tif (!tags.size) {\n\t\ttry {\n\t\t\tawait fs.rm(filePath, { force: true })\n\t\t\tfileCache.delete(filePath)\n\t\t} catch (err) {\n\t\t\tif (!isENOENT(err)) throw err\n\t\t}\n\n\t\treturn\n\t}\n\n\tawait fs.mkdir(GENERATED_DIR, { recursive: true })\n\n\tawait maybeWrite(\n\t\tfilePath,\n\t\t`${AUTOGEN_MSG}\n\n\t\t\timport '${PKG_NAME}'\n\n\t\t\tdeclare module '${PKG_NAME}' {\n\t\t\t\t${tagsToType(tags)}\n\t\t\t}\n\t\t`,\n\t)\n}\n\n/**\n * Render collected tags as a module augmentation for the package entrypoint.\n */\nexport function tagsToType(tags: Tags) {\n\treturn [...tags]\n\t\t.map(\n\t\t\t([tag, classes]) => `\n\t\texport type ${tag} = ${\n\t\t\tclasses.length > 0\n\t\t\t\t? classes\n\t\t\t\t\t\t.toSorted((a, b) => a.length - b.length)\n\t\t\t\t\t\t.map(c => `'${c}'`)\n\t\t\t\t\t\t.join(' | ')\n\t\t\t\t: 'never'\n\t\t}\n\t`,\n\t\t)\n\t\t.join('\\n')\n}\n\n/**\n * Merge per-file tag maps into one application-wide tag map.\n */\nexport function flattenTags(tagsByFile: BuildContext['tagsByFile']) {\n\tconst tags = new Map<string, string[]>()\n\n\tfor (const fileTags of tagsByFile.values()) {\n\t\tfor (const [name, classes] of fileTags) {\n\t\t\tif (tags.has(name)) throw new DuplicateTagError(name)\n\t\t\ttags.set(name, classes)\n\t\t}\n\t}\n\n\treturn tags\n}\n",
|
|
6
6
|
"export const NAME = 'cxx'\nexport const PKG_NAME = `@jk2908/${NAME}`\nexport const GENERATED_DIR = `.${NAME}`\nexport const AUTOGEN_MSG = `// auto-generated by ${NAME}`\n",
|
|
7
|
-
"export const CACHE_MAX_SIZE = 100\n\nexport class LruCache<T> {\n\t#cache: Map<string, T> = new Map()\n\t#maxSize: number\n\n\tconstructor(maxSize = CACHE_MAX_SIZE) {\n\t\tthis.#maxSize = maxSize\n\t}\n\n\tget size() {\n\t\treturn this.#cache.size\n\t}\n\n\t/**\n\t * Retrieve a cached value and promote it to most-recently-used so it won't\n\t * be evicted while still actively referenced
|
|
7
|
+
"export const CACHE_MAX_SIZE = 100\n\nexport class LruCache<T> {\n\t#cache: Map<string, T> = new Map()\n\t#maxSize: number\n\n\tconstructor(maxSize = CACHE_MAX_SIZE) {\n\t\tthis.#maxSize = maxSize\n\t}\n\n\tget size() {\n\t\treturn this.#cache.size\n\t}\n\n\t/**\n\t * Retrieve a cached value and promote it to most-recently-used so it won't\n\t * be evicted while still actively referenced.\n\t */\n\tget(key: string) {\n\t\tconst cached = this.#cache.get(key)\n\t\tif (this.#cache.has(key)) this.set(key, cached as T)\n\n\t\treturn cached\n\t}\n\n\t/**\n\t * Promote an existing cache entry to most-recently-used by deleting and\n\t * re-inserting it, which moves it to the end of the Map's iteration\n\t * order. If the cache is at capacity, evict the least recently used\n\t * entry (front) before inserting.\n\t */\n\tset(key: string, value: T) {\n\t\t// drop any existing entry\n\t\tthis.#cache.delete(key)\n\n\t\tif (this.#cache.size >= this.#maxSize) {\n\t\t\tconst lru = this.#cache.keys().next().value\n\t\t\tif (lru !== undefined) this.#cache.delete(lru)\n\t\t}\n\n\t\tthis.#cache.set(key, value)\n\t}\n\n\tdelete(key: string) {\n\t\treturn this.#cache.delete(key)\n\t}\n\n\tclear() {\n\t\treturn this.#cache.clear()\n\t}\n}\n",
|
|
8
8
|
"export function capitalise(str: string) {\n\treturn str.charAt(0).toUpperCase() + str.slice(1)\n}\n\nexport function pascalise(str: string) {\n\treturn str\n\t\t.split(/[ _-]+/)\n\t\t.map(capitalise)\n\t\t.join('')\n}\n\nexport function debounce<T extends unknown[]>(fn: (...args: T) => void, wait: number) {\n\tlet timeoutId: ReturnType<typeof setTimeout> | null = null\n\n\treturn (...args: T) => {\n\t\tif (timeoutId) {\n\t\t\tclearTimeout(timeoutId)\n\t\t}\n\n\t\ttimeoutId = setTimeout(() => {\n\t\t\tfn.apply(null, args)\n\t\t}, wait)\n\t}\n}\n",
|
|
9
|
-
"import type { AsyncSubscription, Event } from '@parcel/watcher'\nimport type { NextConfig } from 'next'\n\nimport fs from 'node:fs/promises'\nimport path from 'node:path'\nimport { fileURLToPath } from 'node:url'\n\nimport watcher from '@parcel/watcher'\n\nimport type { Logger } from '../logger.js'\nimport type { PluginConfig, Tags } from '../types.js'\nimport { collect, flattenTags, isENOENT, writeTypes } from '../
|
|
9
|
+
"import type { AsyncSubscription, Event } from '@parcel/watcher'\nimport type { NextConfig } from 'next'\n\nimport fs from 'node:fs/promises'\nimport path from 'node:path'\nimport { fileURLToPath } from 'node:url'\n\nimport watcher from '@parcel/watcher'\n\nimport type { Logger } from '../logger.js'\nimport type { PluginConfig, Tags } from '../types.js'\nimport { collect, flattenTags, isENOENT, writeTypes } from '../build.js'\n\nconst nextDir = path.dirname(fileURLToPath(import.meta.url))\nconst loader = path.join(nextDir, 'cxx-loader.cjs')\n\n// keep the latest extracted tags per file so one edit can rebuild the full type surface\nconst tagsByFile: Map<string, Tags> = new Map()\n\n// directory watches are shared, but rebuilds still need the file's config and logger\nconst watchedFiles = new Map<string, { pluginConfig: PluginConfig; logger: Logger }>()\nconst subscriptionsByDir = new Map<string, Promise<AsyncSubscription>>()\n\n/**\n * Rebuild the generated type surface for one watched file after a Parcel event\n */\nasync function rebuildFile(filePath: string, event: Event['type']) {\n\tconst watchedFile = watchedFiles.get(filePath)\n\tif (!watchedFile) return\n\n\tconst { pluginConfig, logger } = watchedFile\n\tconst hadTags = tagsByFile.has(filePath)\n\n\tif (event === 'delete') {\n\t\ttagsByFile.delete(filePath)\n\t\tif (!hadTags) return\n\n\t\tawait writeTypes(flattenTags(tagsByFile))\n\t\tlogger.info(`updated types from ${filePath}`)\n\n\t\treturn\n\t}\n\n\ttry {\n\t\tconst source = await fs.readFile(filePath, 'utf-8')\n\t\tconst { tags } = collect(source, filePath, pluginConfig)\n\t\tconst hasTags = tags.size > 0\n\n\t\tif (hasTags) {\n\t\t\ttagsByFile.set(filePath, tags)\n\t\t} else {\n\t\t\ttagsByFile.delete(filePath)\n\t\t}\n\n\t\tif (!hadTags && !hasTags) return\n\n\t\tawait writeTypes(flattenTags(tagsByFile))\n\t\tlogger.info(`updated types from ${filePath}`)\n\t} catch (err) {\n\t\tif (!isENOENT(err)) throw err\n\t\tif (!hadTags) return\n\n\t\ttagsByFile.delete(filePath)\n\t\tawait writeTypes(flattenTags(tagsByFile))\n\n\t\tlogger.info(`updated types from ${filePath}`)\n\t}\n}\n\n/**\n * Transform one module and, in development, register it with the shared watcher state\n */\nexport function processFile(\n\tsource: string,\n\tfilePath: string,\n\tpluginConfig: PluginConfig,\n\tlogger: Logger,\n) {\n\tconst resolvedFilePath = path.resolve(filePath)\n\tconst directoryPath = path.dirname(resolvedFilePath)\n\tlet subscription = subscriptionsByDir.get(directoryPath)\n\n\tif (process.env.NODE_ENV !== 'production') {\n\t\t// Parcel watches directories, so remember the exact file inputs we care about\n\t\twatchedFiles.set(resolvedFilePath, { pluginConfig, logger })\n\n\t\tif (!subscription) {\n\t\t\t// one subscription per directory is enough; the callback filters back down to watched files\n\t\t\tsubscription = watcher.subscribe(directoryPath, async (err, events) => {\n\t\t\t\tif (err) {\n\t\t\t\t\tlogger.error(`failed to update types from ${directoryPath}`, err)\n\t\t\t\t\treturn\n\t\t\t\t}\n\n\t\t\t\t// Parcel can report unrelated files from the same directory, so ignore anything unregistered\n\t\t\t\tfor (const event of events) {\n\t\t\t\t\tconst eventFilePath = path.resolve(event.path)\n\t\t\t\t\tif (!watchedFiles.has(eventFilePath)) continue\n\n\t\t\t\t\ttry {\n\t\t\t\t\t\tawait rebuildFile(eventFilePath, event.type)\n\t\t\t\t\t} catch (watchErr) {\n\t\t\t\t\t\tlogger.error(`failed to update types from ${eventFilePath}`, watchErr)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t})\n\n\t\t\tsubscriptionsByDir.set(directoryPath, subscription)\n\t\t}\n\t}\n\n\tconst result = collect(source, filePath, pluginConfig)\n\n\tif (result.tags.size > 0) {\n\t\ttagsByFile.set(filePath, result.tags)\n\t} else {\n\t\ttagsByFile.delete(filePath)\n\t}\n\n\tvoid writeTypes(flattenTags(tagsByFile))\n\n\treturn result\n}\n\n/**\n * Close all active Parcel subscriptions before the process exits\n */\nasync function cleanup() {\n\tawait Promise.all(\n\t\t[...subscriptionsByDir].map(async ([directoryPath, subPromise]) => {\n\t\t\tsubscriptionsByDir.delete(directoryPath)\n\t\t\tawait (await subPromise).unsubscribe()\n\t\t}),\n\t)\n\n\tsubscriptionsByDir.clear()\n}\n\nprocess.once('SIGINT', () => {\n\tcleanup().finally(() => process.exit(130))\n})\n\nprocess.once('SIGTERM', () => {\n\tcleanup().finally(() => process.exit(143))\n})\n\nexport async function withCxx(\n\tnextConfig: NextConfig = {},\n\tpluginConfig: PluginConfig = {},\n) {\n\tconst TURBOPACK_GLOB = '*.{tsx,jsx,ts,js}'\n\n\tconst loaderItem = {\n\t\tloader,\n\t\toptions: {\n\t\t\tpluginConfig,\n\t\t},\n\t}\n\n\tconst currentRule = nextConfig.turbopack?.rules?.[TURBOPACK_GLOB]\n\n\treturn {\n\t\t...nextConfig,\n\t\tturbopack: {\n\t\t\t...nextConfig.turbopack,\n\t\t\trules: {\n\t\t\t\t...nextConfig.turbopack?.rules,\n\t\t\t\t[TURBOPACK_GLOB]: Array.isArray(currentRule)\n\t\t\t\t\t? [...currentRule, loaderItem]\n\t\t\t\t\t: currentRule\n\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\t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Q,KAAK,GAAG,CAAC;AAAA,CACzC;AAED,QAAQ,KAAK,WAAW,MAAM;AAAA,EAC7B,QAAQ,EAAE,QAAQ,MAAM,QAAQ,KAAK,GAAG,CAAC;AAAA,CACzC;AAED,eAAsB,OAAO,CAC5B,aAAyB,CAAC,GAC1B,eAA6B,CAAC,GAC7B;AAAA,EACD,MAAM,iBAAiB;AAAA,EAEvB,MAAM,aAAa;AAAA,IAClB;AAAA,IACA,SAAS;AAAA,MACR;AAAA,IACD;AAAA,EACD;AAAA,EAEA,MAAM,cAAc,WAAW,WAAW,QAAQ;AAAA,EAElD,OAAO;AAAA,OACH;AAAA,IACH,WAAW;AAAA,SACP,WAAW;AAAA,MACd,OAAO;AAAA,WACH,WAAW,WAAW;AAAA,SACxB,iBAAiB,MAAM,QAAQ,WAAW,IACxC,CAAC,GAAG,aAAa,UAAU,IAC3B,cACC;AAAA,aACG;AAAA,UACH,SAAS,CAAC,GAAI,YAAY,WAAW,CAAC,GAAI,UAAU;AAAA,QACrD,IACC,EAAE,SAAS,CAAC,UAAU,EAAE;AAAA,MAC7B;AAAA,IACD;AAAA,EACD;AAAA;",
|
|
12
|
+
"debugId": "B9F61A8763996E6064756E2164756E21",
|
|
13
13
|
"names": []
|
|
14
14
|
}
|
package/dist/vite/index.d.ts
CHANGED
|
@@ -3,11 +3,11 @@ import type { PluginConfig } from '../types.js';
|
|
|
3
3
|
export default function cxx(pluginConfig?: PluginConfig): {
|
|
4
4
|
name: string;
|
|
5
5
|
enforce: "pre";
|
|
6
|
-
transform(this: import("
|
|
6
|
+
transform(this: import("rolldown").TransformPluginContext, code: string, id: string): {
|
|
7
7
|
code: string;
|
|
8
8
|
map: null;
|
|
9
9
|
};
|
|
10
|
-
configureServer(this:
|
|
11
|
-
writeBundle(this: import("
|
|
10
|
+
configureServer(this: import("vite").MinimalPluginContextWithoutEnvironment, server: ViteDevServer): void;
|
|
11
|
+
writeBundle(this: import("rolldown").PluginContext): Promise<void>;
|
|
12
12
|
};
|
|
13
13
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/vite/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/vite/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAe,KAAK,aAAa,EAAE,MAAM,MAAM,CAAA;AAEtD,OAAO,KAAK,EAAgB,YAAY,EAAE,MAAM,aAAa,CAAA;AAY7D,MAAM,CAAC,OAAO,UAAU,GAAG,CAAC,YAAY,GAAE,YAAiB;;;;;;;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/vite/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAe,KAAK,aAAa,EAAE,MAAM,MAAM,CAAA;AAEtD,OAAO,KAAK,EAAgB,YAAY,EAAE,MAAM,aAAa,CAAA;AAY7D,MAAM,CAAC,OAAO,UAAU,GAAG,CAAC,YAAY,GAAE,YAAiB;;;;;;;yFA6HjC,aAAa;;EAYtC"}
|
package/dist/vite/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// src/
|
|
1
|
+
// src/build.ts
|
|
2
2
|
import { createHash } from "node:crypto";
|
|
3
3
|
import fs from "node:fs/promises";
|
|
4
4
|
import path from "node:path";
|
|
@@ -64,7 +64,7 @@ function debounce(fn, wait) {
|
|
|
64
64
|
};
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
-
// src/
|
|
67
|
+
// src/build.ts
|
|
68
68
|
var collectCache = new LruCache;
|
|
69
69
|
var fileCache = new LruCache;
|
|
70
70
|
function isENOENT(err) {
|
|
@@ -95,7 +95,8 @@ function hashCss(code) {
|
|
|
95
95
|
return `cxx-${createHash("sha256").update(code).digest("base64url").slice(0, 12)}`;
|
|
96
96
|
}
|
|
97
97
|
|
|
98
|
-
class
|
|
98
|
+
class DuplicateTagError extends Error {
|
|
99
|
+
name = "DuplicateTagError";
|
|
99
100
|
constructor(tag) {
|
|
100
101
|
super(`Tag ${tag} has already been seen. Tags must be unique across your application`);
|
|
101
102
|
}
|
|
@@ -119,7 +120,7 @@ function collect(source, id, config) {
|
|
|
119
120
|
const suffix = typeof config.typeSuffix === "string" ? config.typeSuffix : config.typeSuffix === false ? "" : "Classes";
|
|
120
121
|
const tagWithSuffix = pascalise(`${tag}${suffix}`);
|
|
121
122
|
if (tags.has(tagWithSuffix))
|
|
122
|
-
throw new
|
|
123
|
+
throw new DuplicateTagError(tagWithSuffix);
|
|
123
124
|
tags.set(tagWithSuffix, Object.keys(styles));
|
|
124
125
|
}
|
|
125
126
|
return [
|
|
@@ -168,19 +169,12 @@ function flattenTags(tagsByFile) {
|
|
|
168
169
|
for (const fileTags of tagsByFile.values()) {
|
|
169
170
|
for (const [name, classes] of fileTags) {
|
|
170
171
|
if (tags.has(name))
|
|
171
|
-
throw new
|
|
172
|
+
throw new DuplicateTagError(name);
|
|
172
173
|
tags.set(name, classes);
|
|
173
174
|
}
|
|
174
175
|
}
|
|
175
176
|
return tags;
|
|
176
177
|
}
|
|
177
|
-
var cxx = Object.assign((_) => ["", {}, ""], {
|
|
178
|
-
tag: (_) => (_strings) => [
|
|
179
|
-
"",
|
|
180
|
-
{},
|
|
181
|
-
""
|
|
182
|
-
]
|
|
183
|
-
});
|
|
184
178
|
|
|
185
179
|
// src/vite/index.ts
|
|
186
180
|
import { realpathSync } from "node:fs";
|
|
@@ -279,7 +273,7 @@ var ACCEPTED_EXTENSIONS = new Set([".js", ".jsx", ".ts", ".tsx"]);
|
|
|
279
273
|
function normaliseWatchPath(p) {
|
|
280
274
|
return p.replace(/\\/g, "/");
|
|
281
275
|
}
|
|
282
|
-
function
|
|
276
|
+
function cxx(pluginConfig = {}) {
|
|
283
277
|
const buildContext = {
|
|
284
278
|
tagsByFile: new Map
|
|
285
279
|
};
|
|
@@ -373,7 +367,7 @@ function cxx2(pluginConfig = {}) {
|
|
|
373
367
|
};
|
|
374
368
|
}
|
|
375
369
|
export {
|
|
376
|
-
|
|
370
|
+
cxx as default
|
|
377
371
|
};
|
|
378
372
|
|
|
379
|
-
//# debugId=
|
|
373
|
+
//# debugId=99F5EDE4479120ED64756E2164756E21
|