CoolFace
Apppublic

AK-21/Graphite-Industrial-Intelligence

sourceHugging Faceupdated 3mo agoView on Hugging Face
0likes
experimental-index.mjs331 linesDownload Raw Back to dist
1import { n as __toESM, t as require_binding } from "./shared/binding-Dh6LYCIB.mjs";2import { n as BuiltinPlugin, t as normalizedStringOrRegex } from "./shared/normalize-string-or-regex-BpXHYeN4.mjs";3import { o as transformToRollupOutput } from "./shared/bindingify-input-options-CzVhGygm.mjs";4import { c as validateOption, n as createBundlerOptions, t as RolldownBuild, u as PluginDriver } from "./shared/rolldown-build-DR0wzp0V.mjs";5import { i as unwrapBindingResult, r as normalizeBindingResult } from "./shared/error-B68YLzl3.mjs";6import { n as parseSync$1, t as parse$1 } from "./shared/parse-CTgsjpo8.mjs";7import { a as viteDynamicImportVarsPlugin, c as viteLoadFallbackPlugin, d as viteReporterPlugin, f as viteResolvePlugin, i as viteBuildImportAnalysisPlugin, l as viteModulePreloadPolyfillPlugin, n as isolatedDeclarationPlugin, o as viteImportGlobPlugin, p as viteWebWorkerPostPlugin, r as oxcRuntimePlugin, s as viteJsonPlugin, u as viteReactRefreshWrapperPlugin } from "./shared/constructors-688OwP2q.mjs";8import { a as minify$1, i as transformSync$1, n as resolveTsconfig, o as minifySync$1, r as transform$1, t as TsconfigCache$1 } from "./shared/resolve-tsconfig-BkhP9bkX.mjs";9import { pathToFileURL } from "node:url";10//#region src/api/dev/dev-engine.ts11var import_binding = /* @__PURE__ */ __toESM(require_binding(), 1);12var DevEngine = class DevEngine {13	#inner;14	#cachedBuildFinishPromise = null;15	static async create(inputOptions, outputOptions = {}, devOptions = {}) {16		inputOptions = await PluginDriver.callOptionsHook(inputOptions);17		const options = await createBundlerOptions(inputOptions, outputOptions, false);18		const userOnHmrUpdates = devOptions.onHmrUpdates;19		const bindingOnHmrUpdates = userOnHmrUpdates ? function(rawResult) {20			const result = normalizeBindingResult(rawResult);21			if (result instanceof Error) {22				userOnHmrUpdates(result);23				return;24			}25			const [updates, changedFiles] = result;26			userOnHmrUpdates({27				updates,28				changedFiles29			});30		} : void 0;31		const userOnOutput = devOptions.onOutput;32		const bindingOnOutput = userOnOutput ? function(rawResult) {33			const result = normalizeBindingResult(rawResult);34			if (result instanceof Error) {35				userOnOutput(result);36				return;37			}38			userOnOutput(transformToRollupOutput(result));39		} : void 0;40		const userOnAdditionalAssets = devOptions.onAdditionalAssets;41		const bindingDevOptions = {42			onHmrUpdates: bindingOnHmrUpdates,43			onOutput: bindingOnOutput,44			onAdditionalAssets: userOnAdditionalAssets ? function(output) {45				userOnAdditionalAssets(transformToRollupOutput(output));46			} : void 0,47			rebuildStrategy: devOptions.rebuildStrategy ? devOptions.rebuildStrategy === "always" ? import_binding.BindingRebuildStrategy.Always : devOptions.rebuildStrategy === "auto" ? import_binding.BindingRebuildStrategy.Auto : import_binding.BindingRebuildStrategy.Never : void 0,48			watch: devOptions.watch && {49				skipWrite: devOptions.watch.skipWrite,50				usePolling: devOptions.watch.usePolling,51				pollInterval: devOptions.watch.pollInterval,52				useDebounce: devOptions.watch.useDebounce,53				debounceDuration: devOptions.watch.debounceDuration,54				compareContentsForPolling: devOptions.watch.compareContentsForPolling,55				debounceTickRate: devOptions.watch.debounceTickRate,56				include: normalizedStringOrRegex(devOptions.watch.include),57				exclude: normalizedStringOrRegex(devOptions.watch.exclude)58			}59		};60		return new DevEngine(new import_binding.BindingDevEngine(options.bundlerOptions, bindingDevOptions));61	}62	constructor(inner) {63		this.#inner = inner;64	}65	async run() {66		await this.#inner.run();67	}68	async ensureCurrentBuildFinish() {69		if (this.#cachedBuildFinishPromise) return this.#cachedBuildFinishPromise;70		const promise = this.#inner.ensureCurrentBuildFinish().then(() => {71			this.#cachedBuildFinishPromise = null;72		});73		this.#cachedBuildFinishPromise = promise;74		return promise;75	}76	async getBundleState() {77		return this.#inner.getBundleState();78	}79	async ensureLatestBuildOutput() {80		unwrapBindingResult(await this.#inner.ensureLatestBuildOutput());81	}82	triggerFullBuild() {83		this.#inner.triggerFullBuild();84	}85	async invalidate(file, firstInvalidatedBy) {86		return unwrapBindingResult(await this.#inner.invalidate(file, firstInvalidatedBy));87	}88	async registerModules(clientId, modules) {89		await this.#inner.registerModules(clientId, modules);90	}91	async removeClient(clientId) {92		await this.#inner.removeClient(clientId);93	}94	async close() {95		await this.#inner.close();96	}97	/**98	* Compile a lazy entry module and return HMR-style patch code.99	*100	* This is called when a dynamically imported module is first requested at runtime.101	* The module was previously stubbed with a proxy, and now we need to compile the102	* actual module and its dependencies.103	*104	* @param moduleId - The absolute file path of the module to compile105	* @param clientId - The client ID requesting this compilation106	* @returns The compiled JavaScript code as a string (HMR patch format)107	*/108	async compileEntry(moduleId, clientId) {109		return this.#inner.compileEntry(moduleId, clientId);110	}111};112//#endregion113//#region src/api/dev/index.ts114const dev = (...args) => DevEngine.create(...args);115//#endregion116//#region src/types/external-memory-handle.ts117const symbolForExternalMemoryHandle = "__rolldown_external_memory_handle__";118/**119* Frees the external memory held by the given handle.120*121* This is useful when you want to manually release memory held by Rust objects122* (like `OutputChunk` or `OutputAsset`) before they are garbage collected.123*124* @param handle - The object with external memory to free125* @param keepDataAlive - If true, evaluates all lazy fields before freeing memory (default: false).126*   This will take time to copy data from Rust to JavaScript, but prevents errors127*   when accessing properties after the memory is freed.128* @returns Status object with `freed` boolean and optional `reason` string.129*   - `{ freed: true }` if memory was successfully freed130*   - `{ freed: false, reason: "..." }` if memory couldn't be freed (e.g., already freed or other references exist)131*132* @example133* ```typescript134* import { freeExternalMemory } from 'rolldown/experimental';135*136* const output = await bundle.generate();137* const chunk = output.output[0];138*139* // Use the chunk...140*141* // Manually free the memory (fast, but accessing properties after will throw)142* const status = freeExternalMemory(chunk); // { freed: true }143* const statusAgain = freeExternalMemory(chunk); // { freed: false, reason: "Memory has already been freed" }144*145* // Keep data alive before freeing (slower, but data remains accessible)146* freeExternalMemory(chunk, true); // Evaluates all lazy fields first147* console.log(chunk.code); // OK - data was copied to JavaScript before freeing148*149* // Without keepDataAlive, accessing chunk properties after freeing will throw an error150* ```151*/152function freeExternalMemory(handle, keepDataAlive = false) {153	return handle[symbolForExternalMemoryHandle](keepDataAlive);154}155//#endregion156//#region src/api/experimental.ts157/**158* This is an experimental API. Its behavior may change in the future.159*160* - Calling this API will only execute the `scan/build` stage of rolldown.161* - `scan` will clean up all resources automatically, but if you want to ensure timely cleanup, you need to wait for the returned promise to resolve.162*163* @example To ensure cleanup of resources, use the returned promise to wait for the scan to complete.164* ```ts165* import { scan } from 'rolldown/api/experimental';166*167* const cleanupPromise = await scan(...);168* await cleanupPromise;169* // Now all resources have been cleaned up.170* ```171*/172const scan = async (rawInputOptions, rawOutputOptions = {}) => {173	validateOption("input", rawInputOptions);174	validateOption("output", rawOutputOptions);175	const ret = await createBundlerOptions(await PluginDriver.callOptionsHook(rawInputOptions), rawOutputOptions, false);176	const bundler = new import_binding.BindingBundler();177	if (RolldownBuild.asyncRuntimeShutdown) (0, import_binding.startAsyncRuntime)();178	async function cleanup() {179		await bundler.close();180		await ret.stopWorkers?.();181		(0, import_binding.shutdownAsyncRuntime)();182		RolldownBuild.asyncRuntimeShutdown = true;183	}184	let cleanupPromise = Promise.resolve();185	try {186		unwrapBindingResult(await bundler.scan(ret.bundlerOptions));187	} catch (err) {188		await cleanup();189		throw err;190	} finally {191		cleanupPromise = cleanup();192	}193	return cleanupPromise;194};195//#endregion196//#region src/plugin/parallel-plugin.ts197function defineParallelPlugin(pluginPath) {198	return (options) => {199		return { _parallel: {200			fileUrl: pathToFileURL(pluginPath).href,201			options202		} };203	};204}205//#endregion206//#region src/builtin-plugin/alias-plugin.ts207function viteAliasPlugin(config) {208	return new BuiltinPlugin("builtin:vite-alias", config);209}210//#endregion211//#region src/builtin-plugin/bundle-analyzer-plugin.ts212/**213* A plugin that analyzes bundle composition and generates detailed reports.214*215* The plugin outputs a file containing detailed information about:216* - All chunks and their relationships217* - Modules bundled in each chunk218* - Import dependencies between chunks219* - Reachable modules from each entry point220*221* @example222* ```js223* import { bundleAnalyzerPlugin } from 'rolldown/experimental';224*225* export default {226*   plugins: [227*     bundleAnalyzerPlugin()228*   ]229* }230* ```231*232* @example233* **Custom filename**234* ```js235* import { bundleAnalyzerPlugin } from 'rolldown/experimental';236*237* export default {238*   plugins: [239*     bundleAnalyzerPlugin({240*       fileName: 'bundle-analysis.json'241*     })242*   ]243* }244* ```245*246* @example247* **LLM-friendly markdown output**248* ```js249* import { bundleAnalyzerPlugin } from 'rolldown/experimental';250*251* export default {252*   plugins: [253*     bundleAnalyzerPlugin({254*       format: 'md'255*     })256*   ]257* }258* ```259*/260function bundleAnalyzerPlugin(config) {261	return new BuiltinPlugin("builtin:bundle-analyzer", config);262}263//#endregion264//#region src/builtin-plugin/transform-plugin.ts265function viteTransformPlugin(config) {266	return new BuiltinPlugin("builtin:vite-transform", {267		...config,268		include: normalizedStringOrRegex(config.include),269		exclude: normalizedStringOrRegex(config.exclude),270		jsxRefreshInclude: normalizedStringOrRegex(config.jsxRefreshInclude),271		jsxRefreshExclude: normalizedStringOrRegex(config.jsxRefreshExclude),272		yarnPnp: typeof process === "object" && !!process.versions?.pnp273	});274}275//#endregion276//#region src/builtin-plugin/vite-manifest-plugin.ts277function viteManifestPlugin(config) {278	return new BuiltinPlugin("builtin:vite-manifest", config);279}280//#endregion281//#region src/experimental-index.ts282/**283* In-memory file system for browser builds.284*285* This is a re-export of the {@link https://github.com/streamich/memfs | memfs} package used by the WASI runtime.286* It allows you to read and write files to a virtual filesystem when using rolldown in browser environments.287*288* - `fs`: A Node.js-compatible filesystem API (`IFs` from memfs)289* - `volume`: The underlying `Volume` instance that stores the filesystem state290*291* Returns `undefined` in Node.js builds (only available in browser builds via `@rolldown/browser`).292*293* @example294* ```typescript295* import { memfs } from 'rolldown/experimental';296*297* // Write files to virtual filesystem before bundling298* memfs?.volume.fromJSON({299*   '/src/index.js': 'export const foo = 42;',300*   '/package.json': '{"name": "my-app"}'301* });302*303* // Read files from the virtual filesystem304* const content = memfs?.fs.readFileSync('/src/index.js', 'utf8');305* ```306*307* @see {@link https://github.com/streamich/memfs} for more information on the memfs API.308*/309const memfs = void 0;310/** @deprecated Use from `rolldown/utils` instead. */311const parse = parse$1;312/** @deprecated Use from `rolldown/utils` instead. */313const parseSync = parseSync$1;314/** @deprecated Use from `rolldown/utils` instead. */315const minify = minify$1;316/** @deprecated Use from `rolldown/utils` instead. */317const minifySync = minifySync$1;318/** @deprecated Use from `rolldown/utils` instead. */319const transform = transform$1;320/** @deprecated Use from `rolldown/utils` instead. */321const transformSync = transformSync$1;322/** @deprecated Use from `rolldown/utils` instead. */323const TsconfigCache = TsconfigCache$1;324//#endregion325var BindingRebuildStrategy = import_binding.BindingRebuildStrategy;326var ResolverFactory = import_binding.ResolverFactory;327var isolatedDeclaration = import_binding.isolatedDeclaration;328var isolatedDeclarationSync = import_binding.isolatedDeclarationSync;329var moduleRunnerTransform = import_binding.moduleRunnerTransform;330export { BindingRebuildStrategy, DevEngine, ResolverFactory, TsconfigCache, bundleAnalyzerPlugin, defineParallelPlugin, dev, viteDynamicImportVarsPlugin as dynamicImportVarsPlugin, viteDynamicImportVarsPlugin, freeExternalMemory, viteImportGlobPlugin as importGlobPlugin, viteImportGlobPlugin, isolatedDeclaration, isolatedDeclarationPlugin, isolatedDeclarationSync, memfs, minify, minifySync, moduleRunnerTransform, oxcRuntimePlugin, parse, parseSync, resolveTsconfig, scan, transform, transformSync, viteAliasPlugin, viteBuildImportAnalysisPlugin, viteJsonPlugin, viteLoadFallbackPlugin, viteManifestPlugin, viteModulePreloadPolyfillPlugin, viteReactRefreshWrapperPlugin, viteReporterPlugin, viteResolvePlugin, viteTransformPlugin, viteWebWorkerPostPlugin };331