@absolutejs/absolute 0.19.0-beta.782 → 0.19.0-beta.783

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/dist/vue/index.js CHANGED
@@ -1940,11 +1940,14 @@ var init_lowerAwaitSlotSyntax = __esm(() => {
1940
1940
  var exports_stylePreprocessor = {};
1941
1941
  __export(exports_stylePreprocessor, {
1942
1942
  stylePreprocessorPlugin: () => stylePreprocessorPlugin,
1943
+ recordStyleOutput: () => recordStyleOutput,
1943
1944
  isStylePath: () => isStylePath,
1944
1945
  isStyleModulePath: () => isStyleModulePath,
1945
1946
  isPreprocessableStylePath: () => isPreprocessableStylePath,
1946
1947
  getStyleBaseName: () => getStyleBaseName,
1947
1948
  getCssOutputExtension: () => getCssOutputExtension,
1949
+ forgetStyleEntry: () => forgetStyleEntry,
1950
+ findStyleEntriesImporting: () => findStyleEntriesImporting,
1948
1951
  createSvelteStylePreprocessor: () => createSvelteStylePreprocessor,
1949
1952
  createStyleTransformConfig: () => createStyleTransformConfig,
1950
1953
  createStylePreprocessorPlugin: () => createStylePreprocessorPlugin,
@@ -1952,10 +1955,18 @@ __export(exports_stylePreprocessor, {
1952
1955
  compileStyleFileIfNeededSync: () => compileStyleFileIfNeededSync,
1953
1956
  compileStyleFileIfNeeded: () => compileStyleFileIfNeeded
1954
1957
  });
1958
+ import { createHash } from "crypto";
1955
1959
  import { existsSync as existsSync4, readFileSync as readFileSync4 } from "fs";
1956
1960
  import { readFile } from "fs/promises";
1957
1961
  import { createRequire } from "module";
1958
- import { dirname as dirname3, extname, isAbsolute, join as join4, relative, resolve as resolve3 } from "path";
1962
+ import {
1963
+ dirname as dirname3,
1964
+ extname,
1965
+ isAbsolute,
1966
+ join as join4,
1967
+ relative,
1968
+ resolve as resolve3
1969
+ } from "path";
1959
1970
  import { fileURLToPath } from "url";
1960
1971
  var CSS_EXTENSION_PATTERN, STYLE_EXTENSION_PATTERN, STYLE_MODULE_EXTENSION_PATTERN, STYLE_LANGUAGE_PATTERN, importOptionalPeer, requireOptionalPeer, requireFromCwd, isPreprocessableStylePath = (filePath) => STYLE_EXTENSION_PATTERN.test(filePath), isStyleModulePath = (filePath) => STYLE_MODULE_EXTENSION_PATTERN.test(filePath), isStylePath = (filePath) => /\.(css|s[ac]ss|less|styl(?:us)?)$/i.test(filePath), getStyleBaseName = (filePath) => filePath.replace(/\.(css|s[ac]ss|less|styl(?:us)?)$/i, ""), getStyleLanguage = (filePathOrLanguage) => {
1961
1972
  const normalized = filePathOrLanguage.toLowerCase();
@@ -1968,7 +1979,22 @@ var CSS_EXTENSION_PATTERN, STYLE_EXTENSION_PATTERN, STYLE_MODULE_EXTENSION_PATTE
1968
1979
  if (normalized === "styl" || normalized === "stylus" || normalized.endsWith(".styl") || normalized.endsWith(".stylus"))
1969
1980
  return "stylus";
1970
1981
  return null;
1971
- }, missingDependencyError = (name, filePath) => new Error(`Unable to compile ${filePath}: install optional dependency "${name}" to use this stylesheet preprocessor.`), requireOptionalPeerSync = (specifier) => {
1982
+ }, missingDependencyError = (name, filePath) => new Error(`Unable to compile ${filePath}: install optional dependency "${name}" to use this stylesheet preprocessor.`), throwPreprocessorError = (error, filePath, language) => {
1983
+ if (!(error instanceof Error)) {
1984
+ throw new Error(`${language} compile failed in ${filePath}: ${String(error)}`);
1985
+ }
1986
+ const detail = error;
1987
+ const sassLine = detail.span?.start?.line;
1988
+ const sassCol = detail.span?.start?.column;
1989
+ const line = detail.line ?? sassLine;
1990
+ const column = detail.column ?? sassCol;
1991
+ const location = typeof line === "number" ? `:${line}${typeof column === "number" ? `:${column}` : ""}` : "";
1992
+ const message = detail.formatted ?? detail.message;
1993
+ const wrapped = new Error(`${language} compile failed in ${filePath}${location}
1994
+ ${message}`);
1995
+ wrapped.cause = error;
1996
+ throw wrapped;
1997
+ }, requireOptionalPeerSync = (specifier) => {
1972
1998
  try {
1973
1999
  return requireFromCwd(specifier);
1974
2000
  } catch {
@@ -2007,7 +2033,10 @@ var CSS_EXTENSION_PATTERN, STYLE_EXTENSION_PATTERN, STYLE_MODULE_EXTENSION_PATTE
2007
2033
  }, getAliasEntries = (config) => {
2008
2034
  const tsconfig = readTsconfigAliases();
2009
2035
  return {
2010
- aliases: [...normalizeAliasEntries(config?.aliases), ...tsconfig.aliases],
2036
+ aliases: [
2037
+ ...normalizeAliasEntries(config?.aliases),
2038
+ ...tsconfig.aliases
2039
+ ],
2011
2040
  baseUrl: tsconfig.baseUrl
2012
2041
  };
2013
2042
  }, aliasPatternToRegExp = (pattern) => new RegExp(`^${pattern.split("*").map((part) => part.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("(.+)")}$`), resolveAliasTargets = (specifier, config) => {
@@ -2168,7 +2197,7 @@ ${contents}` : contents, normalizePostcssModule = (mod) => {
2168
2197
  ...postcssConfig.options
2169
2198
  });
2170
2199
  return result.css;
2171
- }, createSassImporter = (entryFile, loadPaths, language, config) => ({
2200
+ }, createSassImporter = (entryFile, loadPaths, language, config, deps) => ({
2172
2201
  canonicalize(specifier, options) {
2173
2202
  const fromDirectory = options.containingUrl ? dirname3(fileURLToPath(options.containingUrl)) : dirname3(entryFile);
2174
2203
  const resolved = resolveImportPath(specifier, fromDirectory, loadPaths, language, config);
@@ -2176,6 +2205,7 @@ ${contents}` : contents, normalizePostcssModule = (mod) => {
2176
2205
  },
2177
2206
  load(canonicalUrl) {
2178
2207
  const filePath = fileURLToPath(canonicalUrl);
2208
+ deps?.add(filePath);
2179
2209
  const fileLanguage = getStyleLanguage(filePath);
2180
2210
  if (fileLanguage !== "scss" && fileLanguage !== "sass" && fileLanguage !== null)
2181
2211
  return null;
@@ -2184,7 +2214,7 @@ ${contents}` : contents, normalizePostcssModule = (mod) => {
2184
2214
  syntax: filePath.endsWith(".sass") ? "indented" : "scss"
2185
2215
  };
2186
2216
  }
2187
- }), createLessFileManager = (entryFile, loadPaths, config) => ({
2217
+ }), createLessFileManager = (entryFile, loadPaths, config, deps) => ({
2188
2218
  install(less, pluginManager) {
2189
2219
  const baseManager = new less.FileManager;
2190
2220
  const manager = Object.create(baseManager);
@@ -2194,6 +2224,7 @@ ${contents}` : contents, normalizePostcssModule = (mod) => {
2194
2224
  if (!resolved) {
2195
2225
  throw new Error(`Unable to resolve Less import "${filename}"`);
2196
2226
  }
2227
+ deps?.add(resolved);
2197
2228
  return {
2198
2229
  contents: preprocessLoadedStyle(await readFile(resolved, "utf-8"), resolved, entryFile, loadPaths, "less", config),
2199
2230
  filename: resolved
@@ -2201,7 +2232,7 @@ ${contents}` : contents, normalizePostcssModule = (mod) => {
2201
2232
  };
2202
2233
  pluginManager.addFileManager(manager);
2203
2234
  }
2204
- }), renderStylus = async (contents, filePath, loadPaths, options) => {
2235
+ }), renderStylus = async (contents, filePath, loadPaths, options, deps) => {
2205
2236
  let stylus;
2206
2237
  try {
2207
2238
  const stylusModule = await importOptionalPeer("stylus");
@@ -2218,15 +2249,51 @@ ${contents}` : contents, normalizePostcssModule = (mod) => {
2218
2249
  for (const path of loadPaths)
2219
2250
  renderer.include(path);
2220
2251
  renderer.render((error, css) => {
2221
- if (error)
2252
+ if (error) {
2222
2253
  reject(error);
2223
- else
2224
- resolveCss(css ?? "");
2254
+ return;
2255
+ }
2256
+ if (deps) {
2257
+ const stylusDeps = renderer.deps?.();
2258
+ if (Array.isArray(stylusDeps)) {
2259
+ for (const dep of stylusDeps)
2260
+ deps.add(resolve3(dep));
2261
+ }
2262
+ }
2263
+ resolveCss(css ?? "");
2225
2264
  });
2226
2265
  });
2266
+ }, styleDependencyGraph, styleOutputHashes, recordStyleDeps = (entry, deps) => {
2267
+ const key = resolve3(entry);
2268
+ const stripped = new Set;
2269
+ for (const dep of deps) {
2270
+ const resolved = resolve3(dep);
2271
+ if (resolved !== key)
2272
+ stripped.add(resolved);
2273
+ }
2274
+ styleDependencyGraph.set(key, stripped);
2275
+ }, findStyleEntriesImporting = (changedPath) => {
2276
+ const target = resolve3(changedPath);
2277
+ const importers = [];
2278
+ for (const [entry, deps] of styleDependencyGraph) {
2279
+ if (deps.has(target))
2280
+ importers.push(entry);
2281
+ }
2282
+ return importers;
2283
+ }, recordStyleOutput = (entry, css) => {
2284
+ const key = resolve3(entry);
2285
+ const hash = createHash("sha1").update(css).digest("hex");
2286
+ const previous = styleOutputHashes.get(key);
2287
+ styleOutputHashes.set(key, hash);
2288
+ return previous !== hash;
2289
+ }, forgetStyleEntry = (entry) => {
2290
+ const key = resolve3(entry);
2291
+ styleDependencyGraph.delete(key);
2292
+ styleOutputHashes.delete(key);
2227
2293
  }, compileStyleSource = async (filePath, source, languageHint, config) => {
2228
2294
  const language = getStyleLanguage(languageHint ?? filePath);
2229
2295
  const rawContents = source ?? await readFile(filePath, "utf-8");
2296
+ const deps = new Set;
2230
2297
  if (language === "scss" || language === "sass") {
2231
2298
  const options = getSassOptions(config, language);
2232
2299
  const packageName = options.implementation ?? "sass";
@@ -2238,16 +2305,22 @@ ${contents}` : contents, normalizePostcssModule = (mod) => {
2238
2305
  }
2239
2306
  const contents = withAdditionalData(rawContents, options.additionalData);
2240
2307
  const loadPaths = normalizeLoadPaths(filePath, options.loadPaths);
2241
- const result = sass.compileString(contents, {
2242
- importers: [
2243
- createSassImporter(filePath, loadPaths, language, config)
2244
- ],
2245
- loadPaths,
2246
- style: "expanded",
2247
- syntax: language === "sass" ? "indented" : "scss",
2248
- url: new URL(`file://${filePath}`)
2249
- });
2250
- return runPostcss(result.css, filePath, config);
2308
+ try {
2309
+ const result = sass.compileString(contents, {
2310
+ importers: [
2311
+ createSassImporter(filePath, loadPaths, language, config, deps)
2312
+ ],
2313
+ loadPaths,
2314
+ style: "expanded",
2315
+ syntax: language === "sass" ? "indented" : "scss",
2316
+ url: new URL(`file://${filePath}`)
2317
+ });
2318
+ const css = await runPostcss(result.css, filePath, config);
2319
+ recordStyleDeps(filePath, deps);
2320
+ return css;
2321
+ } catch (error) {
2322
+ throwPreprocessorError(error, filePath, language);
2323
+ }
2251
2324
  }
2252
2325
  if (language === "less") {
2253
2326
  const options = getLessOptions(config);
@@ -2263,22 +2336,34 @@ ${contents}` : contents, normalizePostcssModule = (mod) => {
2263
2336
  throw missingDependencyError("less", filePath);
2264
2337
  const contents = withAdditionalData(rawContents, options.additionalData);
2265
2338
  const loadPaths = normalizeLoadPaths(filePath, options.paths);
2266
- const result = await render(contents, {
2267
- ...options.options ?? {},
2268
- filename: filePath,
2269
- paths: loadPaths,
2270
- plugins: [
2271
- ...options.options?.plugins ?? [],
2272
- createLessFileManager(filePath, loadPaths, config)
2273
- ]
2274
- });
2275
- return runPostcss(result.css, filePath, config);
2339
+ try {
2340
+ const result = await render(contents, {
2341
+ ...options.options ?? {},
2342
+ filename: filePath,
2343
+ paths: loadPaths,
2344
+ plugins: [
2345
+ ...options.options?.plugins ?? [],
2346
+ createLessFileManager(filePath, loadPaths, config, deps)
2347
+ ]
2348
+ });
2349
+ const css = await runPostcss(result.css, filePath, config);
2350
+ recordStyleDeps(filePath, deps);
2351
+ return css;
2352
+ } catch (error) {
2353
+ throwPreprocessorError(error, filePath, "less");
2354
+ }
2276
2355
  }
2277
2356
  if (language === "stylus") {
2278
2357
  const options = getStylusOptions(config);
2279
2358
  const loadPaths = normalizeLoadPaths(filePath, options.paths);
2280
2359
  const contents = withAdditionalData(preprocessLoadedStyle(rawContents, filePath, filePath, loadPaths, "stylus", config), options.additionalData);
2281
- return runPostcss(await renderStylus(contents, filePath, loadPaths, options), filePath, config);
2360
+ try {
2361
+ const css = await runPostcss(await renderStylus(contents, filePath, loadPaths, options, deps), filePath, config);
2362
+ recordStyleDeps(filePath, deps);
2363
+ return css;
2364
+ } catch (error) {
2365
+ throwPreprocessorError(error, filePath, "stylus");
2366
+ }
2282
2367
  }
2283
2368
  return runPostcss(rawContents, filePath, config);
2284
2369
  }, createStylePreprocessorPlugin = (config) => ({
@@ -2383,6 +2468,8 @@ var init_stylePreprocessor = __esm(() => {
2383
2468
  importOptionalPeer = new Function("specifier", "return import(specifier)");
2384
2469
  requireOptionalPeer = new Function("specifier", "return require(specifier)");
2385
2470
  requireFromCwd = createRequire(join4(process.cwd(), "package.json"));
2471
+ styleDependencyGraph = new Map;
2472
+ styleOutputHashes = new Map;
2386
2473
  stylePreprocessorPlugin = createStylePreprocessorPlugin();
2387
2474
  });
2388
2475
 
@@ -4286,5 +4373,5 @@ export {
4286
4373
  Image
4287
4374
  };
4288
4375
 
4289
- //# debugId=BC0B4D9B42DF46C164756E2164756E21
4376
+ //# debugId=68E950950998A46264756E2164756E21
4290
4377
  //# sourceMappingURL=index.js.map