update
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
import { Derived } from './derived.cjs';
|
||||
import { Store } from './store.cjs';
|
||||
/**
|
||||
* This is here to solve the pyramid dependency problem where:
|
||||
* A
|
||||
* / \
|
||||
* B C
|
||||
* \ /
|
||||
* D
|
||||
*
|
||||
* Where we deeply traverse this tree, how do we avoid D being recomputed twice; once when B is updated, once when C is.
|
||||
*
|
||||
* To solve this, we create linkedDeps that allows us to sync avoid writes to the state until all of the deps have been
|
||||
* resolved.
|
||||
*
|
||||
* This is a record of stores, because derived stores are not able to write values to, but stores are
|
||||
*/
|
||||
export declare const __storeToDerived: WeakMap<Store<unknown, (cb: unknown) => unknown>, Set<Derived<unknown, readonly any[]>>>;
|
||||
export declare const __derivedToStore: WeakMap<Derived<unknown, readonly any[]>, Set<Store<unknown, (cb: unknown) => unknown>>>;
|
||||
export declare const __depsThatHaveWrittenThisTick: {
|
||||
current: Array<Derived<unknown> | Store<unknown>>;
|
||||
};
|
||||
/**
|
||||
* @private only to be called from `Store` on write
|
||||
*/
|
||||
export declare function __flush(store: Store<unknown>): void;
|
||||
export declare function batch(fn: () => void): void;
|
||||
@@ -0,0 +1,315 @@
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
/* prettier-ignore */
|
||||
|
||||
/* auto-generated by NAPI-RS */
|
||||
|
||||
const { existsSync, readFileSync } = require('fs')
|
||||
const { join } = require('path')
|
||||
|
||||
const { platform, arch } = process
|
||||
|
||||
let nativeBinding = null
|
||||
let localFileExisted = false
|
||||
let loadError = null
|
||||
|
||||
function isMusl() {
|
||||
// For Node 10
|
||||
if (!process.report || typeof process.report.getReport !== 'function') {
|
||||
try {
|
||||
const lddPath = require('child_process').execSync('which ldd').toString().trim()
|
||||
return readFileSync(lddPath, 'utf8').includes('musl')
|
||||
} catch (e) {
|
||||
return true
|
||||
}
|
||||
} else {
|
||||
const { glibcVersionRuntime } = process.report.getReport().header
|
||||
return !glibcVersionRuntime
|
||||
}
|
||||
}
|
||||
|
||||
switch (platform) {
|
||||
case 'android':
|
||||
switch (arch) {
|
||||
case 'arm64':
|
||||
localFileExisted = existsSync(join(__dirname, 'tailwindcss-oxide.android-arm64.node'))
|
||||
try {
|
||||
if (localFileExisted) {
|
||||
nativeBinding = require('./tailwindcss-oxide.android-arm64.node')
|
||||
} else {
|
||||
nativeBinding = require('@tailwindcss/oxide-android-arm64')
|
||||
}
|
||||
} catch (e) {
|
||||
loadError = e
|
||||
}
|
||||
break
|
||||
case 'arm':
|
||||
localFileExisted = existsSync(join(__dirname, 'tailwindcss-oxide.android-arm-eabi.node'))
|
||||
try {
|
||||
if (localFileExisted) {
|
||||
nativeBinding = require('./tailwindcss-oxide.android-arm-eabi.node')
|
||||
} else {
|
||||
nativeBinding = require('@tailwindcss/oxide-android-arm-eabi')
|
||||
}
|
||||
} catch (e) {
|
||||
loadError = e
|
||||
}
|
||||
break
|
||||
default:
|
||||
throw new Error(`Unsupported architecture on Android ${arch}`)
|
||||
}
|
||||
break
|
||||
case 'win32':
|
||||
switch (arch) {
|
||||
case 'x64':
|
||||
localFileExisted = existsSync(
|
||||
join(__dirname, 'tailwindcss-oxide.win32-x64-msvc.node')
|
||||
)
|
||||
try {
|
||||
if (localFileExisted) {
|
||||
nativeBinding = require('./tailwindcss-oxide.win32-x64-msvc.node')
|
||||
} else {
|
||||
nativeBinding = require('@tailwindcss/oxide-win32-x64-msvc')
|
||||
}
|
||||
} catch (e) {
|
||||
loadError = e
|
||||
}
|
||||
break
|
||||
case 'ia32':
|
||||
localFileExisted = existsSync(
|
||||
join(__dirname, 'tailwindcss-oxide.win32-ia32-msvc.node')
|
||||
)
|
||||
try {
|
||||
if (localFileExisted) {
|
||||
nativeBinding = require('./tailwindcss-oxide.win32-ia32-msvc.node')
|
||||
} else {
|
||||
nativeBinding = require('@tailwindcss/oxide-win32-ia32-msvc')
|
||||
}
|
||||
} catch (e) {
|
||||
loadError = e
|
||||
}
|
||||
break
|
||||
case 'arm64':
|
||||
localFileExisted = existsSync(
|
||||
join(__dirname, 'tailwindcss-oxide.win32-arm64-msvc.node')
|
||||
)
|
||||
try {
|
||||
if (localFileExisted) {
|
||||
nativeBinding = require('./tailwindcss-oxide.win32-arm64-msvc.node')
|
||||
} else {
|
||||
nativeBinding = require('@tailwindcss/oxide-win32-arm64-msvc')
|
||||
}
|
||||
} catch (e) {
|
||||
loadError = e
|
||||
}
|
||||
break
|
||||
default:
|
||||
throw new Error(`Unsupported architecture on Windows: ${arch}`)
|
||||
}
|
||||
break
|
||||
case 'darwin':
|
||||
localFileExisted = existsSync(join(__dirname, 'tailwindcss-oxide.darwin-universal.node'))
|
||||
try {
|
||||
if (localFileExisted) {
|
||||
nativeBinding = require('./tailwindcss-oxide.darwin-universal.node')
|
||||
} else {
|
||||
nativeBinding = require('@tailwindcss/oxide-darwin-universal')
|
||||
}
|
||||
break
|
||||
} catch {}
|
||||
switch (arch) {
|
||||
case 'x64':
|
||||
localFileExisted = existsSync(join(__dirname, 'tailwindcss-oxide.darwin-x64.node'))
|
||||
try {
|
||||
if (localFileExisted) {
|
||||
nativeBinding = require('./tailwindcss-oxide.darwin-x64.node')
|
||||
} else {
|
||||
nativeBinding = require('@tailwindcss/oxide-darwin-x64')
|
||||
}
|
||||
} catch (e) {
|
||||
loadError = e
|
||||
}
|
||||
break
|
||||
case 'arm64':
|
||||
localFileExisted = existsSync(
|
||||
join(__dirname, 'tailwindcss-oxide.darwin-arm64.node')
|
||||
)
|
||||
try {
|
||||
if (localFileExisted) {
|
||||
nativeBinding = require('./tailwindcss-oxide.darwin-arm64.node')
|
||||
} else {
|
||||
nativeBinding = require('@tailwindcss/oxide-darwin-arm64')
|
||||
}
|
||||
} catch (e) {
|
||||
loadError = e
|
||||
}
|
||||
break
|
||||
default:
|
||||
throw new Error(`Unsupported architecture on macOS: ${arch}`)
|
||||
}
|
||||
break
|
||||
case 'freebsd':
|
||||
if (arch !== 'x64') {
|
||||
throw new Error(`Unsupported architecture on FreeBSD: ${arch}`)
|
||||
}
|
||||
localFileExisted = existsSync(join(__dirname, 'tailwindcss-oxide.freebsd-x64.node'))
|
||||
try {
|
||||
if (localFileExisted) {
|
||||
nativeBinding = require('./tailwindcss-oxide.freebsd-x64.node')
|
||||
} else {
|
||||
nativeBinding = require('@tailwindcss/oxide-freebsd-x64')
|
||||
}
|
||||
} catch (e) {
|
||||
loadError = e
|
||||
}
|
||||
break
|
||||
case 'linux':
|
||||
switch (arch) {
|
||||
case 'x64':
|
||||
if (isMusl()) {
|
||||
localFileExisted = existsSync(
|
||||
join(__dirname, 'tailwindcss-oxide.linux-x64-musl.node')
|
||||
)
|
||||
try {
|
||||
if (localFileExisted) {
|
||||
nativeBinding = require('./tailwindcss-oxide.linux-x64-musl.node')
|
||||
} else {
|
||||
nativeBinding = require('@tailwindcss/oxide-linux-x64-musl')
|
||||
}
|
||||
} catch (e) {
|
||||
loadError = e
|
||||
}
|
||||
} else {
|
||||
localFileExisted = existsSync(
|
||||
join(__dirname, 'tailwindcss-oxide.linux-x64-gnu.node')
|
||||
)
|
||||
try {
|
||||
if (localFileExisted) {
|
||||
nativeBinding = require('./tailwindcss-oxide.linux-x64-gnu.node')
|
||||
} else {
|
||||
nativeBinding = require('@tailwindcss/oxide-linux-x64-gnu')
|
||||
}
|
||||
} catch (e) {
|
||||
loadError = e
|
||||
}
|
||||
}
|
||||
break
|
||||
case 'arm64':
|
||||
if (isMusl()) {
|
||||
localFileExisted = existsSync(
|
||||
join(__dirname, 'tailwindcss-oxide.linux-arm64-musl.node')
|
||||
)
|
||||
try {
|
||||
if (localFileExisted) {
|
||||
nativeBinding = require('./tailwindcss-oxide.linux-arm64-musl.node')
|
||||
} else {
|
||||
nativeBinding = require('@tailwindcss/oxide-linux-arm64-musl')
|
||||
}
|
||||
} catch (e) {
|
||||
loadError = e
|
||||
}
|
||||
} else {
|
||||
localFileExisted = existsSync(
|
||||
join(__dirname, 'tailwindcss-oxide.linux-arm64-gnu.node')
|
||||
)
|
||||
try {
|
||||
if (localFileExisted) {
|
||||
nativeBinding = require('./tailwindcss-oxide.linux-arm64-gnu.node')
|
||||
} else {
|
||||
nativeBinding = require('@tailwindcss/oxide-linux-arm64-gnu')
|
||||
}
|
||||
} catch (e) {
|
||||
loadError = e
|
||||
}
|
||||
}
|
||||
break
|
||||
case 'arm':
|
||||
if (isMusl()) {
|
||||
localFileExisted = existsSync(
|
||||
join(__dirname, 'tailwindcss-oxide.linux-arm-musleabihf.node')
|
||||
)
|
||||
try {
|
||||
if (localFileExisted) {
|
||||
nativeBinding = require('./tailwindcss-oxide.linux-arm-musleabihf.node')
|
||||
} else {
|
||||
nativeBinding = require('@tailwindcss/oxide-linux-arm-musleabihf')
|
||||
}
|
||||
} catch (e) {
|
||||
loadError = e
|
||||
}
|
||||
} else {
|
||||
localFileExisted = existsSync(
|
||||
join(__dirname, 'tailwindcss-oxide.linux-arm-gnueabihf.node')
|
||||
)
|
||||
try {
|
||||
if (localFileExisted) {
|
||||
nativeBinding = require('./tailwindcss-oxide.linux-arm-gnueabihf.node')
|
||||
} else {
|
||||
nativeBinding = require('@tailwindcss/oxide-linux-arm-gnueabihf')
|
||||
}
|
||||
} catch (e) {
|
||||
loadError = e
|
||||
}
|
||||
}
|
||||
break
|
||||
case 'riscv64':
|
||||
if (isMusl()) {
|
||||
localFileExisted = existsSync(
|
||||
join(__dirname, 'tailwindcss-oxide.linux-riscv64-musl.node')
|
||||
)
|
||||
try {
|
||||
if (localFileExisted) {
|
||||
nativeBinding = require('./tailwindcss-oxide.linux-riscv64-musl.node')
|
||||
} else {
|
||||
nativeBinding = require('@tailwindcss/oxide-linux-riscv64-musl')
|
||||
}
|
||||
} catch (e) {
|
||||
loadError = e
|
||||
}
|
||||
} else {
|
||||
localFileExisted = existsSync(
|
||||
join(__dirname, 'tailwindcss-oxide.linux-riscv64-gnu.node')
|
||||
)
|
||||
try {
|
||||
if (localFileExisted) {
|
||||
nativeBinding = require('./tailwindcss-oxide.linux-riscv64-gnu.node')
|
||||
} else {
|
||||
nativeBinding = require('@tailwindcss/oxide-linux-riscv64-gnu')
|
||||
}
|
||||
} catch (e) {
|
||||
loadError = e
|
||||
}
|
||||
}
|
||||
break
|
||||
case 's390x':
|
||||
localFileExisted = existsSync(
|
||||
join(__dirname, 'tailwindcss-oxide.linux-s390x-gnu.node')
|
||||
)
|
||||
try {
|
||||
if (localFileExisted) {
|
||||
nativeBinding = require('./tailwindcss-oxide.linux-s390x-gnu.node')
|
||||
} else {
|
||||
nativeBinding = require('@tailwindcss/oxide-linux-s390x-gnu')
|
||||
}
|
||||
} catch (e) {
|
||||
loadError = e
|
||||
}
|
||||
break
|
||||
default:
|
||||
throw new Error(`Unsupported architecture on Linux: ${arch}`)
|
||||
}
|
||||
break
|
||||
default:
|
||||
throw new Error(`Unsupported OS: ${platform}, architecture: ${arch}`)
|
||||
}
|
||||
|
||||
if (!nativeBinding) {
|
||||
if (loadError) {
|
||||
throw loadError
|
||||
}
|
||||
throw new Error(`Failed to load native binding`)
|
||||
}
|
||||
|
||||
const { Scanner } = nativeBinding
|
||||
|
||||
module.exports.Scanner = Scanner
|
||||
@@ -0,0 +1,287 @@
|
||||
"use strict";
|
||||
var __create = Object.create;
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __getProtoOf = Object.getPrototypeOf;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
||||
// If the importer is in node compatibility mode or this is not an ESM
|
||||
// file that has been converted to a CommonJS file using a Babel-
|
||||
// compatible transform (i.e. "__esModule" has not been set), then set
|
||||
// "default" to the CommonJS "module.exports" for node compatibility.
|
||||
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
||||
mod
|
||||
));
|
||||
|
||||
// lib/npm/node-platform.ts
|
||||
var fs = require("fs");
|
||||
var os = require("os");
|
||||
var path = require("path");
|
||||
var ESBUILD_BINARY_PATH = process.env.ESBUILD_BINARY_PATH || ESBUILD_BINARY_PATH;
|
||||
var isValidBinaryPath = (x) => !!x && x !== "/usr/bin/esbuild";
|
||||
var knownWindowsPackages = {
|
||||
"win32 arm64 LE": "@esbuild/win32-arm64",
|
||||
"win32 ia32 LE": "@esbuild/win32-ia32",
|
||||
"win32 x64 LE": "@esbuild/win32-x64"
|
||||
};
|
||||
var knownUnixlikePackages = {
|
||||
"aix ppc64 BE": "@esbuild/aix-ppc64",
|
||||
"android arm64 LE": "@esbuild/android-arm64",
|
||||
"darwin arm64 LE": "@esbuild/darwin-arm64",
|
||||
"darwin x64 LE": "@esbuild/darwin-x64",
|
||||
"freebsd arm64 LE": "@esbuild/freebsd-arm64",
|
||||
"freebsd x64 LE": "@esbuild/freebsd-x64",
|
||||
"linux arm LE": "@esbuild/linux-arm",
|
||||
"linux arm64 LE": "@esbuild/linux-arm64",
|
||||
"linux ia32 LE": "@esbuild/linux-ia32",
|
||||
"linux mips64el LE": "@esbuild/linux-mips64el",
|
||||
"linux ppc64 LE": "@esbuild/linux-ppc64",
|
||||
"linux riscv64 LE": "@esbuild/linux-riscv64",
|
||||
"linux s390x BE": "@esbuild/linux-s390x",
|
||||
"linux x64 LE": "@esbuild/linux-x64",
|
||||
"linux loong64 LE": "@esbuild/linux-loong64",
|
||||
"netbsd arm64 LE": "@esbuild/netbsd-arm64",
|
||||
"netbsd x64 LE": "@esbuild/netbsd-x64",
|
||||
"openbsd arm64 LE": "@esbuild/openbsd-arm64",
|
||||
"openbsd x64 LE": "@esbuild/openbsd-x64",
|
||||
"sunos x64 LE": "@esbuild/sunos-x64"
|
||||
};
|
||||
var knownWebAssemblyFallbackPackages = {
|
||||
"android arm LE": "@esbuild/android-arm",
|
||||
"android x64 LE": "@esbuild/android-x64"
|
||||
};
|
||||
function pkgAndSubpathForCurrentPlatform() {
|
||||
let pkg;
|
||||
let subpath;
|
||||
let isWASM = false;
|
||||
let platformKey = `${process.platform} ${os.arch()} ${os.endianness()}`;
|
||||
if (platformKey in knownWindowsPackages) {
|
||||
pkg = knownWindowsPackages[platformKey];
|
||||
subpath = "esbuild.exe";
|
||||
} else if (platformKey in knownUnixlikePackages) {
|
||||
pkg = knownUnixlikePackages[platformKey];
|
||||
subpath = "bin/esbuild";
|
||||
} else if (platformKey in knownWebAssemblyFallbackPackages) {
|
||||
pkg = knownWebAssemblyFallbackPackages[platformKey];
|
||||
subpath = "bin/esbuild";
|
||||
isWASM = true;
|
||||
} else {
|
||||
throw new Error(`Unsupported platform: ${platformKey}`);
|
||||
}
|
||||
return { pkg, subpath, isWASM };
|
||||
}
|
||||
function downloadedBinPath(pkg, subpath) {
|
||||
const esbuildLibDir = path.dirname(require.resolve("esbuild"));
|
||||
return path.join(esbuildLibDir, `downloaded-${pkg.replace("/", "-")}-${path.basename(subpath)}`);
|
||||
}
|
||||
|
||||
// lib/npm/node-install.ts
|
||||
var fs2 = require("fs");
|
||||
var os2 = require("os");
|
||||
var path2 = require("path");
|
||||
var zlib = require("zlib");
|
||||
var https = require("https");
|
||||
var child_process = require("child_process");
|
||||
var versionFromPackageJSON = require(path2.join(__dirname, "package.json")).version;
|
||||
var toPath = path2.join(__dirname, "bin", "esbuild");
|
||||
var isToPathJS = true;
|
||||
function validateBinaryVersion(...command) {
|
||||
command.push("--version");
|
||||
let stdout;
|
||||
try {
|
||||
stdout = child_process.execFileSync(command.shift(), command, {
|
||||
// Without this, this install script strangely crashes with the error
|
||||
// "EACCES: permission denied, write" but only on Ubuntu Linux when node is
|
||||
// installed from the Snap Store. This is not a problem when you download
|
||||
// the official version of node. The problem appears to be that stderr
|
||||
// (i.e. file descriptor 2) isn't writable?
|
||||
//
|
||||
// More info:
|
||||
// - https://snapcraft.io/ (what the Snap Store is)
|
||||
// - https://nodejs.org/dist/ (download the official version of node)
|
||||
// - https://github.com/evanw/esbuild/issues/1711#issuecomment-1027554035
|
||||
//
|
||||
stdio: "pipe"
|
||||
}).toString().trim();
|
||||
} catch (err) {
|
||||
if (os2.platform() === "darwin" && /_SecTrustEvaluateWithError/.test(err + "")) {
|
||||
let os3 = "this version of macOS";
|
||||
try {
|
||||
os3 = "macOS " + child_process.execFileSync("sw_vers", ["-productVersion"]).toString().trim();
|
||||
} catch {
|
||||
}
|
||||
throw new Error(`The "esbuild" package cannot be installed because ${os3} is too outdated.
|
||||
|
||||
The Go compiler (which esbuild relies on) no longer supports ${os3},
|
||||
which means the "esbuild" binary executable can't be run. You can either:
|
||||
|
||||
* Update your version of macOS to one that the Go compiler supports
|
||||
* Use the "esbuild-wasm" package instead of the "esbuild" package
|
||||
* Build esbuild yourself using an older version of the Go compiler
|
||||
`);
|
||||
}
|
||||
throw err;
|
||||
}
|
||||
if (stdout !== versionFromPackageJSON) {
|
||||
throw new Error(`Expected ${JSON.stringify(versionFromPackageJSON)} but got ${JSON.stringify(stdout)}`);
|
||||
}
|
||||
}
|
||||
function isYarn() {
|
||||
const { npm_config_user_agent } = process.env;
|
||||
if (npm_config_user_agent) {
|
||||
return /\byarn\//.test(npm_config_user_agent);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
function fetch(url) {
|
||||
return new Promise((resolve, reject) => {
|
||||
https.get(url, (res) => {
|
||||
if ((res.statusCode === 301 || res.statusCode === 302) && res.headers.location)
|
||||
return fetch(res.headers.location).then(resolve, reject);
|
||||
if (res.statusCode !== 200)
|
||||
return reject(new Error(`Server responded with ${res.statusCode}`));
|
||||
let chunks = [];
|
||||
res.on("data", (chunk) => chunks.push(chunk));
|
||||
res.on("end", () => resolve(Buffer.concat(chunks)));
|
||||
}).on("error", reject);
|
||||
});
|
||||
}
|
||||
function extractFileFromTarGzip(buffer, subpath) {
|
||||
try {
|
||||
buffer = zlib.unzipSync(buffer);
|
||||
} catch (err) {
|
||||
throw new Error(`Invalid gzip data in archive: ${err && err.message || err}`);
|
||||
}
|
||||
let str = (i, n) => String.fromCharCode(...buffer.subarray(i, i + n)).replace(/\0.*$/, "");
|
||||
let offset = 0;
|
||||
subpath = `package/${subpath}`;
|
||||
while (offset < buffer.length) {
|
||||
let name = str(offset, 100);
|
||||
let size = parseInt(str(offset + 124, 12), 8);
|
||||
offset += 512;
|
||||
if (!isNaN(size)) {
|
||||
if (name === subpath) return buffer.subarray(offset, offset + size);
|
||||
offset += size + 511 & ~511;
|
||||
}
|
||||
}
|
||||
throw new Error(`Could not find ${JSON.stringify(subpath)} in archive`);
|
||||
}
|
||||
function installUsingNPM(pkg, subpath, binPath) {
|
||||
const env = { ...process.env, npm_config_global: void 0 };
|
||||
const esbuildLibDir = path2.dirname(require.resolve("esbuild"));
|
||||
const installDir = path2.join(esbuildLibDir, "npm-install");
|
||||
fs2.mkdirSync(installDir);
|
||||
try {
|
||||
fs2.writeFileSync(path2.join(installDir, "package.json"), "{}");
|
||||
child_process.execSync(
|
||||
`npm install --loglevel=error --prefer-offline --no-audit --progress=false ${pkg}@${versionFromPackageJSON}`,
|
||||
{ cwd: installDir, stdio: "pipe", env }
|
||||
);
|
||||
const installedBinPath = path2.join(installDir, "node_modules", pkg, subpath);
|
||||
fs2.renameSync(installedBinPath, binPath);
|
||||
} finally {
|
||||
try {
|
||||
removeRecursive(installDir);
|
||||
} catch {
|
||||
}
|
||||
}
|
||||
}
|
||||
function removeRecursive(dir) {
|
||||
for (const entry of fs2.readdirSync(dir)) {
|
||||
const entryPath = path2.join(dir, entry);
|
||||
let stats;
|
||||
try {
|
||||
stats = fs2.lstatSync(entryPath);
|
||||
} catch {
|
||||
continue;
|
||||
}
|
||||
if (stats.isDirectory()) removeRecursive(entryPath);
|
||||
else fs2.unlinkSync(entryPath);
|
||||
}
|
||||
fs2.rmdirSync(dir);
|
||||
}
|
||||
function applyManualBinaryPathOverride(overridePath) {
|
||||
const pathString = JSON.stringify(overridePath);
|
||||
fs2.writeFileSync(toPath, `#!/usr/bin/env node
|
||||
require('child_process').execFileSync(${pathString}, process.argv.slice(2), { stdio: 'inherit' });
|
||||
`);
|
||||
const libMain = path2.join(__dirname, "lib", "main.js");
|
||||
const code = fs2.readFileSync(libMain, "utf8");
|
||||
fs2.writeFileSync(libMain, `var ESBUILD_BINARY_PATH = ${pathString};
|
||||
${code}`);
|
||||
}
|
||||
function maybeOptimizePackage(binPath) {
|
||||
if (os2.platform() !== "win32" && !isYarn()) {
|
||||
const tempPath = path2.join(__dirname, "bin-esbuild");
|
||||
try {
|
||||
fs2.linkSync(binPath, tempPath);
|
||||
fs2.renameSync(tempPath, toPath);
|
||||
isToPathJS = false;
|
||||
fs2.unlinkSync(tempPath);
|
||||
} catch {
|
||||
}
|
||||
}
|
||||
}
|
||||
async function downloadDirectlyFromNPM(pkg, subpath, binPath) {
|
||||
const url = `https://registry.npmjs.org/${pkg}/-/${pkg.replace("@esbuild/", "")}-${versionFromPackageJSON}.tgz`;
|
||||
console.error(`[esbuild] Trying to download ${JSON.stringify(url)}`);
|
||||
try {
|
||||
fs2.writeFileSync(binPath, extractFileFromTarGzip(await fetch(url), subpath));
|
||||
fs2.chmodSync(binPath, 493);
|
||||
} catch (e) {
|
||||
console.error(`[esbuild] Failed to download ${JSON.stringify(url)}: ${e && e.message || e}`);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
async function checkAndPreparePackage() {
|
||||
if (isValidBinaryPath(ESBUILD_BINARY_PATH)) {
|
||||
if (!fs2.existsSync(ESBUILD_BINARY_PATH)) {
|
||||
console.warn(`[esbuild] Ignoring bad configuration: ESBUILD_BINARY_PATH=${ESBUILD_BINARY_PATH}`);
|
||||
} else {
|
||||
applyManualBinaryPathOverride(ESBUILD_BINARY_PATH);
|
||||
return;
|
||||
}
|
||||
}
|
||||
const { pkg, subpath } = pkgAndSubpathForCurrentPlatform();
|
||||
let binPath;
|
||||
try {
|
||||
binPath = require.resolve(`${pkg}/${subpath}`);
|
||||
} catch (e) {
|
||||
console.error(`[esbuild] Failed to find package "${pkg}" on the file system
|
||||
|
||||
This can happen if you use the "--no-optional" flag. The "optionalDependencies"
|
||||
package.json feature is used by esbuild to install the correct binary executable
|
||||
for your current platform. This install script will now attempt to work around
|
||||
this. If that fails, you need to remove the "--no-optional" flag to use esbuild.
|
||||
`);
|
||||
binPath = downloadedBinPath(pkg, subpath);
|
||||
try {
|
||||
console.error(`[esbuild] Trying to install package "${pkg}" using npm`);
|
||||
installUsingNPM(pkg, subpath, binPath);
|
||||
} catch (e2) {
|
||||
console.error(`[esbuild] Failed to install package "${pkg}" using npm: ${e2 && e2.message || e2}`);
|
||||
try {
|
||||
await downloadDirectlyFromNPM(pkg, subpath, binPath);
|
||||
} catch (e3) {
|
||||
throw new Error(`Failed to install package "${pkg}"`);
|
||||
}
|
||||
}
|
||||
}
|
||||
maybeOptimizePackage(binPath);
|
||||
}
|
||||
checkAndPreparePackage().then(() => {
|
||||
if (isToPathJS) {
|
||||
validateBinaryVersion(process.execPath, toPath);
|
||||
} else {
|
||||
validateBinaryVersion(toPath);
|
||||
}
|
||||
});
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1 @@
|
||||
self.Flatted=function(t){"use strict";const{parse:e,stringify:n}=JSON,{keys:r}=Object,s=String,o="string",c={},l="object",a=(t,e)=>e,f=t=>t instanceof s?s(t):t,i=(t,e)=>typeof e===o?new s(e):e,u=(t,e,n,o)=>{const a=[];for(let f=r(n),{length:i}=f,u=0;u<i;u++){const r=f[u],i=n[r];if(i instanceof s){const s=t[i];typeof s!==l||e.has(s)?n[r]=o.call(n,r,s):(e.add(s),n[r]=c,a.push({k:r,a:[t,e,s,o]}))}else n[r]!==c&&(n[r]=o.call(n,r,i))}for(let{length:t}=a,e=0;e<t;e++){const{k:t,a:r}=a[e];n[t]=o.call(n,t,u.apply(null,r))}return n},p=(t,e,n)=>{const r=s(e.push(n)-1);return t.set(n,r),r},y=(t,n)=>{const r=e(t,i).map(f),s=r[0],o=n||a,c=typeof s===l&&s?u(r,new Set,s,o):s;return o.call({"":c},"",c)},g=(t,e,r)=>{const s=e&&typeof e===l?(t,n)=>""===t||-1<e.indexOf(t)?n:void 0:e||a,c=new Map,f=[],i=[];let u=+p(c,f,s.call({"":t},"",t)),y=!u;for(;u<f.length;)y=!0,i[u]=n(f[u++],g,r);return"["+i.join(",")+"]";function g(t,e){if(y)return y=!y,e;const n=s.call(this,t,e);switch(typeof n){case l:if(null===n)return n;case o:return c.get(n)||p(c,f,n)}return n}};return t.fromJSON=t=>y(n(t)),t.parse=y,t.stringify=g,t.toJSON=t=>e(g(t)),t}({});
|
||||
@@ -0,0 +1,61 @@
|
||||
/*!
|
||||
* word-wrap <https://github.com/jonschlinkert/word-wrap>
|
||||
*
|
||||
* Copyright (c) 2014-2023, Jon Schlinkert.
|
||||
* Released under the MIT License.
|
||||
*/
|
||||
|
||||
function trimEnd(str) {
|
||||
let lastCharPos = str.length - 1;
|
||||
let lastChar = str[lastCharPos];
|
||||
while(lastChar === ' ' || lastChar === '\t') {
|
||||
lastChar = str[--lastCharPos];
|
||||
}
|
||||
return str.substring(0, lastCharPos + 1);
|
||||
}
|
||||
|
||||
function trimTabAndSpaces(str) {
|
||||
const lines = str.split('\n');
|
||||
const trimmedLines = lines.map((line) => trimEnd(line));
|
||||
return trimmedLines.join('\n');
|
||||
}
|
||||
|
||||
module.exports = function(str, options) {
|
||||
options = options || {};
|
||||
if (str == null) {
|
||||
return str;
|
||||
}
|
||||
|
||||
var width = options.width || 50;
|
||||
var indent = (typeof options.indent === 'string')
|
||||
? options.indent
|
||||
: ' ';
|
||||
|
||||
var newline = options.newline || '\n' + indent;
|
||||
var escape = typeof options.escape === 'function'
|
||||
? options.escape
|
||||
: identity;
|
||||
|
||||
var regexString = '.{1,' + width + '}';
|
||||
if (options.cut !== true) {
|
||||
regexString += '([\\s\u200B]+|$)|[^\\s\u200B]+?([\\s\u200B]+|$)';
|
||||
}
|
||||
|
||||
var re = new RegExp(regexString, 'g');
|
||||
var lines = str.match(re) || [];
|
||||
var result = indent + lines.map(function(line) {
|
||||
if (line.slice(-1) === '\n') {
|
||||
line = line.slice(0, line.length - 1);
|
||||
}
|
||||
return escape(line);
|
||||
}).join(newline);
|
||||
|
||||
if (options.trim === true) {
|
||||
result = trimTabAndSpaces(result);
|
||||
}
|
||||
return result;
|
||||
};
|
||||
|
||||
function identity(str) {
|
||||
return str;
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.DEPRECATED_ALIASES = void 0;
|
||||
const DEPRECATED_ALIASES = exports.DEPRECATED_ALIASES = {
|
||||
ModuleDeclaration: "ImportOrExportDeclaration"
|
||||
};
|
||||
|
||||
//# sourceMappingURL=deprecated-aliases.js.map
|
||||
@@ -0,0 +1,246 @@
|
||||
'use client';
|
||||
var __rest = (this && this.__rest) || function (s, e) {
|
||||
var t = {};
|
||||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
||||
t[p] = s[p];
|
||||
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
||||
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
||||
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
||||
t[p[i]] = s[p[i]];
|
||||
}
|
||||
return t;
|
||||
};
|
||||
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
||||
import { useEffect, useMemo, useRef } from 'react';
|
||||
import makeCancellable from 'make-cancellable-promise';
|
||||
import makeEventProps from 'make-event-props';
|
||||
import clsx from 'clsx';
|
||||
import mergeRefs from 'merge-refs';
|
||||
import invariant from 'tiny-invariant';
|
||||
import warning from 'warning';
|
||||
import PageContext from './PageContext.js';
|
||||
import Message from './Message.js';
|
||||
import Canvas from './Page/Canvas.js';
|
||||
import TextLayer from './Page/TextLayer.js';
|
||||
import AnnotationLayer from './Page/AnnotationLayer.js';
|
||||
import { cancelRunningTask, isProvided, makePageCallback } from './shared/utils.js';
|
||||
import useDocumentContext from './shared/hooks/useDocumentContext.js';
|
||||
import useResolver from './shared/hooks/useResolver.js';
|
||||
const defaultScale = 1;
|
||||
/**
|
||||
* Displays a page.
|
||||
*
|
||||
* Should be placed inside `<Document />`. Alternatively, it can have `pdf` prop passed, which can be obtained from `<Document />`'s `onLoadSuccess` callback function, however some advanced functions like linking between pages inside a document may not be working correctly.
|
||||
*/
|
||||
export default function Page(props) {
|
||||
const documentContext = useDocumentContext();
|
||||
const mergedProps = Object.assign(Object.assign({}, documentContext), props);
|
||||
const { _className = 'react-pdf__Page', _enableRegisterUnregisterPage = true, canvasBackground, canvasRef, children, className, customRenderer: CustomRenderer, customTextRenderer, devicePixelRatio, error = 'Failed to load the page.', height, inputRef, loading = 'Loading page…', noData = 'No page specified.', onGetAnnotationsError: onGetAnnotationsErrorProps, onGetAnnotationsSuccess: onGetAnnotationsSuccessProps, onGetStructTreeError: onGetStructTreeErrorProps, onGetStructTreeSuccess: onGetStructTreeSuccessProps, onGetTextError: onGetTextErrorProps, onGetTextSuccess: onGetTextSuccessProps, onLoadError: onLoadErrorProps, onLoadSuccess: onLoadSuccessProps, onRenderAnnotationLayerError: onRenderAnnotationLayerErrorProps, onRenderAnnotationLayerSuccess: onRenderAnnotationLayerSuccessProps, onRenderError: onRenderErrorProps, onRenderSuccess: onRenderSuccessProps, onRenderTextLayerError: onRenderTextLayerErrorProps, onRenderTextLayerSuccess: onRenderTextLayerSuccessProps, pageIndex: pageIndexProps, pageNumber: pageNumberProps, pdf, registerPage, renderAnnotationLayer: renderAnnotationLayerProps = true, renderForms = false, renderMode = 'canvas', renderTextLayer: renderTextLayerProps = true, rotate: rotateProps, scale: scaleProps = defaultScale, unregisterPage, width } = mergedProps, otherProps = __rest(mergedProps, ["_className", "_enableRegisterUnregisterPage", "canvasBackground", "canvasRef", "children", "className", "customRenderer", "customTextRenderer", "devicePixelRatio", "error", "height", "inputRef", "loading", "noData", "onGetAnnotationsError", "onGetAnnotationsSuccess", "onGetStructTreeError", "onGetStructTreeSuccess", "onGetTextError", "onGetTextSuccess", "onLoadError", "onLoadSuccess", "onRenderAnnotationLayerError", "onRenderAnnotationLayerSuccess", "onRenderError", "onRenderSuccess", "onRenderTextLayerError", "onRenderTextLayerSuccess", "pageIndex", "pageNumber", "pdf", "registerPage", "renderAnnotationLayer", "renderForms", "renderMode", "renderTextLayer", "rotate", "scale", "unregisterPage", "width"]);
|
||||
const [pageState, pageDispatch] = useResolver();
|
||||
const { value: page, error: pageError } = pageState;
|
||||
const pageElement = useRef(null);
|
||||
invariant(pdf, 'Attempted to load a page, but no document was specified. Wrap <Page /> in a <Document /> or pass explicit `pdf` prop.');
|
||||
const pageIndex = isProvided(pageNumberProps) ? pageNumberProps - 1 : (pageIndexProps !== null && pageIndexProps !== void 0 ? pageIndexProps : null);
|
||||
const pageNumber = pageNumberProps !== null && pageNumberProps !== void 0 ? pageNumberProps : (isProvided(pageIndexProps) ? pageIndexProps + 1 : null);
|
||||
const rotate = rotateProps !== null && rotateProps !== void 0 ? rotateProps : (page ? page.rotate : null);
|
||||
const scale = useMemo(() => {
|
||||
if (!page) {
|
||||
return null;
|
||||
}
|
||||
// Be default, we'll render page at 100% * scale width.
|
||||
let pageScale = 1;
|
||||
// Passing scale explicitly null would cause the page not to render
|
||||
const scaleWithDefault = scaleProps !== null && scaleProps !== void 0 ? scaleProps : defaultScale;
|
||||
// If width/height is defined, calculate the scale of the page so it could be of desired width.
|
||||
if (width || height) {
|
||||
const viewport = page.getViewport({ scale: 1, rotation: rotate });
|
||||
if (width) {
|
||||
pageScale = width / viewport.width;
|
||||
}
|
||||
else if (height) {
|
||||
pageScale = height / viewport.height;
|
||||
}
|
||||
}
|
||||
return scaleWithDefault * pageScale;
|
||||
}, [height, page, rotate, scaleProps, width]);
|
||||
// biome-ignore lint/correctness/useExhaustiveDependencies: useEffect intentionally triggered on pdf change
|
||||
useEffect(function hook() {
|
||||
return () => {
|
||||
if (!isProvided(pageIndex)) {
|
||||
// Impossible, but TypeScript doesn't know that
|
||||
return;
|
||||
}
|
||||
if (_enableRegisterUnregisterPage && unregisterPage) {
|
||||
unregisterPage(pageIndex);
|
||||
}
|
||||
};
|
||||
}, [_enableRegisterUnregisterPage, pdf, pageIndex, unregisterPage]);
|
||||
/**
|
||||
* Called when a page is loaded successfully
|
||||
*/
|
||||
function onLoadSuccess() {
|
||||
if (onLoadSuccessProps) {
|
||||
if (!page || !scale) {
|
||||
// Impossible, but TypeScript doesn't know that
|
||||
return;
|
||||
}
|
||||
onLoadSuccessProps(makePageCallback(page, scale));
|
||||
}
|
||||
if (_enableRegisterUnregisterPage && registerPage) {
|
||||
if (!isProvided(pageIndex) || !pageElement.current) {
|
||||
// Impossible, but TypeScript doesn't know that
|
||||
return;
|
||||
}
|
||||
registerPage(pageIndex, pageElement.current);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Called when a page failed to load
|
||||
*/
|
||||
function onLoadError() {
|
||||
if (!pageError) {
|
||||
// Impossible, but TypeScript doesn't know that
|
||||
return;
|
||||
}
|
||||
warning(false, pageError.toString());
|
||||
if (onLoadErrorProps) {
|
||||
onLoadErrorProps(pageError);
|
||||
}
|
||||
}
|
||||
// biome-ignore lint/correctness/useExhaustiveDependencies: useEffect intentionally triggered on pdf and pageIndex change
|
||||
useEffect(function resetPage() {
|
||||
pageDispatch({ type: 'RESET' });
|
||||
}, [pageDispatch, pdf, pageIndex]);
|
||||
useEffect(function loadPage() {
|
||||
if (!pdf || !pageNumber) {
|
||||
return;
|
||||
}
|
||||
const cancellable = makeCancellable(pdf.getPage(pageNumber));
|
||||
const runningTask = cancellable;
|
||||
cancellable.promise
|
||||
.then((nextPage) => {
|
||||
pageDispatch({ type: 'RESOLVE', value: nextPage });
|
||||
})
|
||||
.catch((error) => {
|
||||
pageDispatch({ type: 'REJECT', error });
|
||||
});
|
||||
return () => cancelRunningTask(runningTask);
|
||||
}, [pageDispatch, pdf, pageNumber]);
|
||||
// biome-ignore lint/correctness/useExhaustiveDependencies: Ommitted callbacks so they are not called every time they change
|
||||
useEffect(() => {
|
||||
if (page === undefined) {
|
||||
return;
|
||||
}
|
||||
if (page === false) {
|
||||
onLoadError();
|
||||
return;
|
||||
}
|
||||
onLoadSuccess();
|
||||
}, [page, scale]);
|
||||
const childContext = useMemo(() =>
|
||||
// Technically there cannot be page without pageIndex, pageNumber, rotate and scale, but TypeScript doesn't know that
|
||||
page && isProvided(pageIndex) && pageNumber && isProvided(rotate) && isProvided(scale)
|
||||
? {
|
||||
_className,
|
||||
canvasBackground,
|
||||
customTextRenderer,
|
||||
devicePixelRatio,
|
||||
onGetAnnotationsError: onGetAnnotationsErrorProps,
|
||||
onGetAnnotationsSuccess: onGetAnnotationsSuccessProps,
|
||||
onGetStructTreeError: onGetStructTreeErrorProps,
|
||||
onGetStructTreeSuccess: onGetStructTreeSuccessProps,
|
||||
onGetTextError: onGetTextErrorProps,
|
||||
onGetTextSuccess: onGetTextSuccessProps,
|
||||
onRenderAnnotationLayerError: onRenderAnnotationLayerErrorProps,
|
||||
onRenderAnnotationLayerSuccess: onRenderAnnotationLayerSuccessProps,
|
||||
onRenderError: onRenderErrorProps,
|
||||
onRenderSuccess: onRenderSuccessProps,
|
||||
onRenderTextLayerError: onRenderTextLayerErrorProps,
|
||||
onRenderTextLayerSuccess: onRenderTextLayerSuccessProps,
|
||||
page,
|
||||
pageIndex,
|
||||
pageNumber,
|
||||
renderForms,
|
||||
renderTextLayer: renderTextLayerProps,
|
||||
rotate,
|
||||
scale,
|
||||
}
|
||||
: null, [
|
||||
_className,
|
||||
canvasBackground,
|
||||
customTextRenderer,
|
||||
devicePixelRatio,
|
||||
onGetAnnotationsErrorProps,
|
||||
onGetAnnotationsSuccessProps,
|
||||
onGetStructTreeErrorProps,
|
||||
onGetStructTreeSuccessProps,
|
||||
onGetTextErrorProps,
|
||||
onGetTextSuccessProps,
|
||||
onRenderAnnotationLayerErrorProps,
|
||||
onRenderAnnotationLayerSuccessProps,
|
||||
onRenderErrorProps,
|
||||
onRenderSuccessProps,
|
||||
onRenderTextLayerErrorProps,
|
||||
onRenderTextLayerSuccessProps,
|
||||
page,
|
||||
pageIndex,
|
||||
pageNumber,
|
||||
renderForms,
|
||||
renderTextLayerProps,
|
||||
rotate,
|
||||
scale,
|
||||
]);
|
||||
const eventProps = useMemo(() => makeEventProps(otherProps, () => page ? (scale ? makePageCallback(page, scale) : undefined) : page),
|
||||
// biome-ignore lint/correctness/useExhaustiveDependencies: FIXME
|
||||
[otherProps, page, scale]);
|
||||
const pageKey = `${pageIndex}@${scale}/${rotate}`;
|
||||
function renderMainLayer() {
|
||||
switch (renderMode) {
|
||||
case 'custom': {
|
||||
invariant(CustomRenderer, `renderMode was set to "custom", but no customRenderer was passed.`);
|
||||
return _jsx(CustomRenderer, {}, `${pageKey}_custom`);
|
||||
}
|
||||
case 'none':
|
||||
return null;
|
||||
case 'canvas':
|
||||
default:
|
||||
return _jsx(Canvas, { canvasRef: canvasRef }, `${pageKey}_canvas`);
|
||||
}
|
||||
}
|
||||
function renderTextLayer() {
|
||||
if (!renderTextLayerProps) {
|
||||
return null;
|
||||
}
|
||||
return _jsx(TextLayer, {}, `${pageKey}_text`);
|
||||
}
|
||||
function renderAnnotationLayer() {
|
||||
if (!renderAnnotationLayerProps) {
|
||||
return null;
|
||||
}
|
||||
return _jsx(AnnotationLayer, {}, `${pageKey}_annotations`);
|
||||
}
|
||||
function renderChildren() {
|
||||
return (_jsxs(PageContext.Provider, { value: childContext, children: [renderMainLayer(), renderTextLayer(), renderAnnotationLayer(), children] }));
|
||||
}
|
||||
function renderContent() {
|
||||
if (!pageNumber) {
|
||||
return _jsx(Message, { type: "no-data", children: typeof noData === 'function' ? noData() : noData });
|
||||
}
|
||||
if (pdf === null || page === undefined || page === null) {
|
||||
return (_jsx(Message, { type: "loading", children: typeof loading === 'function' ? loading() : loading }));
|
||||
}
|
||||
if (pdf === false || page === false) {
|
||||
return _jsx(Message, { type: "error", children: typeof error === 'function' ? error() : error });
|
||||
}
|
||||
return renderChildren();
|
||||
}
|
||||
return (_jsx("div", Object.assign({ className: clsx(_className, className), "data-page-number": pageNumber,
|
||||
// Assertion is needed for React 18 compatibility
|
||||
ref: mergeRefs(inputRef, pageElement), style: {
|
||||
['--scale-factor']: `${scale}`,
|
||||
backgroundColor: canvasBackground || 'white',
|
||||
position: 'relative',
|
||||
minWidth: 'min-content',
|
||||
minHeight: 'min-content',
|
||||
} }, eventProps, { children: renderContent() })));
|
||||
}
|
||||
@@ -0,0 +1,223 @@
|
||||
/*
|
||||
MIT License http://www.opensource.org/licenses/mit-license.php
|
||||
Author Ivan Kopeykin @vankop
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
const DescriptionFileUtils = require("./DescriptionFileUtils");
|
||||
const forEachBail = require("./forEachBail");
|
||||
const { processImportsField } = require("./util/entrypoints");
|
||||
const { parseIdentifier } = require("./util/identifier");
|
||||
const {
|
||||
invalidSegmentRegEx,
|
||||
deprecatedInvalidSegmentRegEx
|
||||
} = require("./util/path");
|
||||
|
||||
/** @typedef {import("./Resolver")} Resolver */
|
||||
/** @typedef {import("./Resolver").JsonObject} JsonObject */
|
||||
/** @typedef {import("./Resolver").ResolveRequest} ResolveRequest */
|
||||
/** @typedef {import("./Resolver").ResolveStepHook} ResolveStepHook */
|
||||
/** @typedef {import("./util/entrypoints").FieldProcessor} FieldProcessor */
|
||||
/** @typedef {import("./util/entrypoints").ImportsField} ImportsField */
|
||||
|
||||
const dotCode = ".".charCodeAt(0);
|
||||
|
||||
module.exports = class ImportsFieldPlugin {
|
||||
/**
|
||||
* @param {string | ResolveStepHook} source source
|
||||
* @param {Set<string>} conditionNames condition names
|
||||
* @param {string | string[]} fieldNamePath name path
|
||||
* @param {string | ResolveStepHook} targetFile target file
|
||||
* @param {string | ResolveStepHook} targetPackage target package
|
||||
*/
|
||||
constructor(
|
||||
source,
|
||||
conditionNames,
|
||||
fieldNamePath,
|
||||
targetFile,
|
||||
targetPackage
|
||||
) {
|
||||
this.source = source;
|
||||
this.targetFile = targetFile;
|
||||
this.targetPackage = targetPackage;
|
||||
this.conditionNames = conditionNames;
|
||||
this.fieldName = fieldNamePath;
|
||||
/** @type {WeakMap<JsonObject, FieldProcessor>} */
|
||||
this.fieldProcessorCache = new WeakMap();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Resolver} resolver the resolver
|
||||
* @returns {void}
|
||||
*/
|
||||
apply(resolver) {
|
||||
const targetFile = resolver.ensureHook(this.targetFile);
|
||||
const targetPackage = resolver.ensureHook(this.targetPackage);
|
||||
|
||||
resolver
|
||||
.getHook(this.source)
|
||||
.tapAsync("ImportsFieldPlugin", (request, resolveContext, callback) => {
|
||||
// When there is no description file, abort
|
||||
if (!request.descriptionFilePath || request.request === undefined) {
|
||||
return callback();
|
||||
}
|
||||
|
||||
const remainingRequest =
|
||||
request.request + request.query + request.fragment;
|
||||
const importsField =
|
||||
/** @type {ImportsField|null|undefined} */
|
||||
(
|
||||
DescriptionFileUtils.getField(
|
||||
/** @type {JsonObject} */ (request.descriptionFileData),
|
||||
this.fieldName
|
||||
)
|
||||
);
|
||||
if (!importsField) return callback();
|
||||
|
||||
if (request.directory) {
|
||||
return callback(
|
||||
new Error(
|
||||
`Resolving to directories is not possible with the imports field (request was ${remainingRequest}/)`
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/** @type {string[]} */
|
||||
let paths;
|
||||
/** @type {string | null} */
|
||||
let usedField;
|
||||
|
||||
try {
|
||||
// We attach the cache to the description file instead of the importsField value
|
||||
// because we use a WeakMap and the importsField could be a string too.
|
||||
// Description file is always an object when exports field can be accessed.
|
||||
let fieldProcessor = this.fieldProcessorCache.get(
|
||||
/** @type {JsonObject} */ (request.descriptionFileData)
|
||||
);
|
||||
if (fieldProcessor === undefined) {
|
||||
fieldProcessor = processImportsField(importsField);
|
||||
this.fieldProcessorCache.set(
|
||||
/** @type {JsonObject} */ (request.descriptionFileData),
|
||||
fieldProcessor
|
||||
);
|
||||
}
|
||||
[paths, usedField] = fieldProcessor(
|
||||
remainingRequest,
|
||||
this.conditionNames
|
||||
);
|
||||
} catch (/** @type {unknown} */ err) {
|
||||
if (resolveContext.log) {
|
||||
resolveContext.log(
|
||||
`Imports field in ${request.descriptionFilePath} can't be processed: ${err}`
|
||||
);
|
||||
}
|
||||
return callback(/** @type {Error} */ (err));
|
||||
}
|
||||
|
||||
if (paths.length === 0) {
|
||||
return callback(
|
||||
new Error(
|
||||
`Package import ${remainingRequest} is not imported from package ${request.descriptionFileRoot} (see imports field in ${request.descriptionFilePath})`
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
forEachBail(
|
||||
paths,
|
||||
/**
|
||||
* @param {string} p path
|
||||
* @param {(err?: null|Error, result?: null|ResolveRequest) => void} callback callback
|
||||
* @param {number} i index
|
||||
* @returns {void}
|
||||
*/
|
||||
(p, callback, i) => {
|
||||
const parsedIdentifier = parseIdentifier(p);
|
||||
|
||||
if (!parsedIdentifier) return callback();
|
||||
|
||||
const [path_, query, fragment] = parsedIdentifier;
|
||||
|
||||
switch (path_.charCodeAt(0)) {
|
||||
// should be relative
|
||||
case dotCode: {
|
||||
if (
|
||||
invalidSegmentRegEx.exec(path_.slice(2)) !== null &&
|
||||
deprecatedInvalidSegmentRegEx.test(path_.slice(2)) !== null
|
||||
) {
|
||||
if (paths.length === i) {
|
||||
return callback(
|
||||
new Error(
|
||||
`Invalid "imports" target "${p}" defined for "${usedField}" in the package config ${request.descriptionFilePath}, targets must start with "./"`
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
return callback();
|
||||
}
|
||||
|
||||
/** @type {ResolveRequest} */
|
||||
const obj = {
|
||||
...request,
|
||||
request: undefined,
|
||||
path: resolver.join(
|
||||
/** @type {string} */ (request.descriptionFileRoot),
|
||||
path_
|
||||
),
|
||||
relativePath: path_,
|
||||
query,
|
||||
fragment
|
||||
};
|
||||
|
||||
resolver.doResolve(
|
||||
targetFile,
|
||||
obj,
|
||||
"using imports field: " + p,
|
||||
resolveContext,
|
||||
(err, result) => {
|
||||
if (err) return callback(err);
|
||||
// Don't allow to continue - https://github.com/webpack/enhanced-resolve/issues/400
|
||||
if (result === undefined) return callback(null, null);
|
||||
callback(null, result);
|
||||
}
|
||||
);
|
||||
break;
|
||||
}
|
||||
|
||||
// package resolving
|
||||
default: {
|
||||
/** @type {ResolveRequest} */
|
||||
const obj = {
|
||||
...request,
|
||||
request: path_,
|
||||
relativePath: path_,
|
||||
fullySpecified: true,
|
||||
query,
|
||||
fragment
|
||||
};
|
||||
|
||||
resolver.doResolve(
|
||||
targetPackage,
|
||||
obj,
|
||||
"using imports field: " + p,
|
||||
resolveContext,
|
||||
(err, result) => {
|
||||
if (err) return callback(err);
|
||||
// Don't allow to continue - https://github.com/webpack/enhanced-resolve/issues/400
|
||||
if (result === undefined) return callback(null, null);
|
||||
callback(null, result);
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
},
|
||||
/**
|
||||
* @param {null|Error} [err] error
|
||||
* @param {null|ResolveRequest} [result] result
|
||||
* @returns {void}
|
||||
*/
|
||||
(err, result) => callback(err, result || null)
|
||||
);
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,39 @@
|
||||
{
|
||||
"name": "path-key",
|
||||
"version": "3.1.1",
|
||||
"description": "Get the PATH environment variable key cross-platform",
|
||||
"license": "MIT",
|
||||
"repository": "sindresorhus/path-key",
|
||||
"author": {
|
||||
"name": "Sindre Sorhus",
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"url": "sindresorhus.com"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=8"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && ava && tsd"
|
||||
},
|
||||
"files": [
|
||||
"index.js",
|
||||
"index.d.ts"
|
||||
],
|
||||
"keywords": [
|
||||
"path",
|
||||
"key",
|
||||
"environment",
|
||||
"env",
|
||||
"variable",
|
||||
"var",
|
||||
"get",
|
||||
"cross-platform",
|
||||
"windows"
|
||||
],
|
||||
"devDependencies": {
|
||||
"@types/node": "^11.13.0",
|
||||
"ava": "^1.4.1",
|
||||
"tsd": "^0.7.2",
|
||||
"xo": "^0.24.0"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
||||
const useRouterState = require("./useRouterState.cjs");
|
||||
function useCanGoBack() {
|
||||
return useRouterState.useRouterState({ select: (s) => s.location.state.__TSR_index !== 0 });
|
||||
}
|
||||
exports.useCanGoBack = useCanGoBack;
|
||||
//# sourceMappingURL=useCanGoBack.cjs.map
|
||||
@@ -0,0 +1,15 @@
|
||||
import { useMatch } from "./useMatch.js";
|
||||
function useLoaderData(opts) {
|
||||
return useMatch({
|
||||
from: opts.from,
|
||||
strict: opts.strict,
|
||||
structuralSharing: opts.structuralSharing,
|
||||
select: (s) => {
|
||||
return opts.select ? opts.select(s.loaderData) : s.loaderData;
|
||||
}
|
||||
});
|
||||
}
|
||||
export {
|
||||
useLoaderData
|
||||
};
|
||||
//# sourceMappingURL=useLoaderData.js.map
|
||||
@@ -0,0 +1,304 @@
|
||||
import { jsx } from "react/jsx-runtime";
|
||||
import * as React from "react";
|
||||
import { flushSync } from "react-dom";
|
||||
import { preloadWarning, functionalUpdate, exactPathTest, removeTrailingSlash, deepEqual } from "@tanstack/router-core";
|
||||
import { useRouterState } from "./useRouterState.js";
|
||||
import { useRouter } from "./useRouter.js";
|
||||
import { useForwardedRef, useIntersectionObserver, useLayoutEffect } from "./utils.js";
|
||||
import { useMatches } from "./Matches.js";
|
||||
function useLinkProps(options, forwardedRef) {
|
||||
const router = useRouter();
|
||||
const [isTransitioning, setIsTransitioning] = React.useState(false);
|
||||
const hasRenderFetched = React.useRef(false);
|
||||
const innerRef = useForwardedRef(forwardedRef);
|
||||
const {
|
||||
// custom props
|
||||
activeProps = () => ({ className: "active" }),
|
||||
inactiveProps = () => ({}),
|
||||
activeOptions,
|
||||
to,
|
||||
preload: userPreload,
|
||||
preloadDelay: userPreloadDelay,
|
||||
hashScrollIntoView,
|
||||
replace,
|
||||
startTransition,
|
||||
resetScroll,
|
||||
viewTransition,
|
||||
// element props
|
||||
children,
|
||||
target,
|
||||
disabled,
|
||||
style,
|
||||
className,
|
||||
onClick,
|
||||
onFocus,
|
||||
onMouseEnter,
|
||||
onMouseLeave,
|
||||
onTouchStart,
|
||||
ignoreBlocker,
|
||||
...rest
|
||||
} = options;
|
||||
const {
|
||||
// prevent these from being returned
|
||||
params: _params,
|
||||
search: _search,
|
||||
hash: _hash,
|
||||
state: _state,
|
||||
mask: _mask,
|
||||
reloadDocument: _reloadDocument,
|
||||
...propsSafeToSpread
|
||||
} = rest;
|
||||
const type = React.useMemo(() => {
|
||||
try {
|
||||
new URL(`${to}`);
|
||||
return "external";
|
||||
} catch {
|
||||
}
|
||||
return "internal";
|
||||
}, [to]);
|
||||
const currentSearch = useRouterState({
|
||||
select: (s) => s.location.search,
|
||||
structuralSharing: true
|
||||
});
|
||||
const from = useMatches({
|
||||
select: (matches) => {
|
||||
var _a;
|
||||
return options.from ?? ((_a = matches[matches.length - 1]) == null ? void 0 : _a.fullPath);
|
||||
}
|
||||
});
|
||||
const _options = React.useMemo(() => ({ ...options, from }), [options, from]);
|
||||
const next = React.useMemo(
|
||||
() => router.buildLocation(_options),
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
[router, _options, currentSearch]
|
||||
);
|
||||
const preload = React.useMemo(() => {
|
||||
if (_options.reloadDocument) {
|
||||
return false;
|
||||
}
|
||||
return userPreload ?? router.options.defaultPreload;
|
||||
}, [router.options.defaultPreload, userPreload, _options.reloadDocument]);
|
||||
const preloadDelay = userPreloadDelay ?? router.options.defaultPreloadDelay ?? 0;
|
||||
const isActive = useRouterState({
|
||||
select: (s) => {
|
||||
if (activeOptions == null ? void 0 : activeOptions.exact) {
|
||||
const testExact = exactPathTest(
|
||||
s.location.pathname,
|
||||
next.pathname,
|
||||
router.basepath
|
||||
);
|
||||
if (!testExact) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
const currentPathSplit = removeTrailingSlash(
|
||||
s.location.pathname,
|
||||
router.basepath
|
||||
).split("/");
|
||||
const nextPathSplit = removeTrailingSlash(
|
||||
next.pathname,
|
||||
router.basepath
|
||||
).split("/");
|
||||
const pathIsFuzzyEqual = nextPathSplit.every(
|
||||
(d, i) => d === currentPathSplit[i]
|
||||
);
|
||||
if (!pathIsFuzzyEqual) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if ((activeOptions == null ? void 0 : activeOptions.includeSearch) ?? true) {
|
||||
const searchTest = deepEqual(s.location.search, next.search, {
|
||||
partial: !(activeOptions == null ? void 0 : activeOptions.exact),
|
||||
ignoreUndefined: !(activeOptions == null ? void 0 : activeOptions.explicitUndefined)
|
||||
});
|
||||
if (!searchTest) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (activeOptions == null ? void 0 : activeOptions.includeHash) {
|
||||
return s.location.hash === next.hash;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
});
|
||||
const doPreload = React.useCallback(() => {
|
||||
router.preloadRoute(_options).catch((err) => {
|
||||
console.warn(err);
|
||||
console.warn(preloadWarning);
|
||||
});
|
||||
}, [_options, router]);
|
||||
const preloadViewportIoCallback = React.useCallback(
|
||||
(entry) => {
|
||||
if (entry == null ? void 0 : entry.isIntersecting) {
|
||||
doPreload();
|
||||
}
|
||||
},
|
||||
[doPreload]
|
||||
);
|
||||
useIntersectionObserver(
|
||||
innerRef,
|
||||
preloadViewportIoCallback,
|
||||
{ rootMargin: "100px" },
|
||||
{ disabled: !!disabled || !(preload === "viewport") }
|
||||
);
|
||||
useLayoutEffect(() => {
|
||||
if (hasRenderFetched.current) {
|
||||
return;
|
||||
}
|
||||
if (!disabled && preload === "render") {
|
||||
doPreload();
|
||||
hasRenderFetched.current = true;
|
||||
}
|
||||
}, [disabled, doPreload, preload]);
|
||||
if (type === "external") {
|
||||
return {
|
||||
...propsSafeToSpread,
|
||||
ref: innerRef,
|
||||
type,
|
||||
href: to,
|
||||
...children && { children },
|
||||
...target && { target },
|
||||
...disabled && { disabled },
|
||||
...style && { style },
|
||||
...className && { className },
|
||||
...onClick && { onClick },
|
||||
...onFocus && { onFocus },
|
||||
...onMouseEnter && { onMouseEnter },
|
||||
...onMouseLeave && { onMouseLeave },
|
||||
...onTouchStart && { onTouchStart }
|
||||
};
|
||||
}
|
||||
const handleClick = (e) => {
|
||||
if (!disabled && !isCtrlEvent(e) && !e.defaultPrevented && (!target || target === "_self") && e.button === 0) {
|
||||
e.preventDefault();
|
||||
flushSync(() => {
|
||||
setIsTransitioning(true);
|
||||
});
|
||||
const unsub = router.subscribe("onResolved", () => {
|
||||
unsub();
|
||||
setIsTransitioning(false);
|
||||
});
|
||||
return router.navigate({
|
||||
..._options,
|
||||
replace,
|
||||
resetScroll,
|
||||
hashScrollIntoView,
|
||||
startTransition,
|
||||
viewTransition,
|
||||
ignoreBlocker
|
||||
});
|
||||
}
|
||||
};
|
||||
const handleFocus = (_) => {
|
||||
if (disabled) return;
|
||||
if (preload) {
|
||||
doPreload();
|
||||
}
|
||||
};
|
||||
const handleTouchStart = handleFocus;
|
||||
const handleEnter = (e) => {
|
||||
if (disabled) return;
|
||||
const eventTarget = e.target || {};
|
||||
if (preload) {
|
||||
if (eventTarget.preloadTimeout) {
|
||||
return;
|
||||
}
|
||||
eventTarget.preloadTimeout = setTimeout(() => {
|
||||
eventTarget.preloadTimeout = null;
|
||||
doPreload();
|
||||
}, preloadDelay);
|
||||
}
|
||||
};
|
||||
const handleLeave = (e) => {
|
||||
if (disabled) return;
|
||||
const eventTarget = e.target || {};
|
||||
if (eventTarget.preloadTimeout) {
|
||||
clearTimeout(eventTarget.preloadTimeout);
|
||||
eventTarget.preloadTimeout = null;
|
||||
}
|
||||
};
|
||||
const composeHandlers = (handlers) => (e) => {
|
||||
var _a;
|
||||
(_a = e.persist) == null ? void 0 : _a.call(e);
|
||||
handlers.filter(Boolean).forEach((handler) => {
|
||||
if (e.defaultPrevented) return;
|
||||
handler(e);
|
||||
});
|
||||
};
|
||||
const resolvedActiveProps = isActive ? functionalUpdate(activeProps, {}) ?? {} : {};
|
||||
const resolvedInactiveProps = isActive ? {} : functionalUpdate(inactiveProps, {});
|
||||
const resolvedClassName = [
|
||||
className,
|
||||
resolvedActiveProps.className,
|
||||
resolvedInactiveProps.className
|
||||
].filter(Boolean).join(" ");
|
||||
const resolvedStyle = {
|
||||
...style,
|
||||
...resolvedActiveProps.style,
|
||||
...resolvedInactiveProps.style
|
||||
};
|
||||
return {
|
||||
...propsSafeToSpread,
|
||||
...resolvedActiveProps,
|
||||
...resolvedInactiveProps,
|
||||
href: disabled ? void 0 : next.maskedLocation ? router.history.createHref(next.maskedLocation.href) : router.history.createHref(next.href),
|
||||
ref: innerRef,
|
||||
onClick: composeHandlers([onClick, handleClick]),
|
||||
onFocus: composeHandlers([onFocus, handleFocus]),
|
||||
onMouseEnter: composeHandlers([onMouseEnter, handleEnter]),
|
||||
onMouseLeave: composeHandlers([onMouseLeave, handleLeave]),
|
||||
onTouchStart: composeHandlers([onTouchStart, handleTouchStart]),
|
||||
disabled: !!disabled,
|
||||
target,
|
||||
...Object.keys(resolvedStyle).length && { style: resolvedStyle },
|
||||
...resolvedClassName && { className: resolvedClassName },
|
||||
...disabled && {
|
||||
role: "link",
|
||||
"aria-disabled": true
|
||||
},
|
||||
...isActive && { "data-status": "active", "aria-current": "page" },
|
||||
...isTransitioning && { "data-transitioning": "transitioning" }
|
||||
};
|
||||
}
|
||||
function createLink(Comp) {
|
||||
return React.forwardRef(function CreatedLink(props, ref) {
|
||||
return /* @__PURE__ */ jsx(Link, { ...props, _asChild: Comp, ref });
|
||||
});
|
||||
}
|
||||
const Link = React.forwardRef(
|
||||
(props, ref) => {
|
||||
const { _asChild, ...rest } = props;
|
||||
const {
|
||||
type: _type,
|
||||
ref: innerRef,
|
||||
...linkProps
|
||||
} = useLinkProps(rest, ref);
|
||||
const children = typeof rest.children === "function" ? rest.children({
|
||||
isActive: linkProps["data-status"] === "active"
|
||||
}) : rest.children;
|
||||
if (typeof _asChild === "undefined") {
|
||||
delete linkProps.disabled;
|
||||
}
|
||||
return React.createElement(
|
||||
_asChild ? _asChild : "a",
|
||||
{
|
||||
...linkProps,
|
||||
ref: innerRef
|
||||
},
|
||||
children
|
||||
);
|
||||
}
|
||||
);
|
||||
function isCtrlEvent(e) {
|
||||
return !!(e.metaKey || e.altKey || e.ctrlKey || e.shiftKey);
|
||||
}
|
||||
const linkOptions = (options) => {
|
||||
return options;
|
||||
};
|
||||
export {
|
||||
Link,
|
||||
createLink,
|
||||
linkOptions,
|
||||
useLinkProps
|
||||
};
|
||||
//# sourceMappingURL=link.js.map
|
||||
@@ -0,0 +1 @@
|
||||
module.exports={A:{A:{"2":"K D E F A B mC"},B:{"1":"0 9 N O P Q H R S T U V W X Y Z a b c d e f g h i j k l m n o p q r s t u v w x y z AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB I","260":"C","514":"L M G"},C:{"1":"0 9 bB cB dB eB fB gB hB iB jB kB lB mB nB oB pB qB rB sB tB uB vB MC wB NC xB yB zB 0B 1B 2B 3B 4B 5B 6B 7B 8B 9B AC BC CC DC Q H R OC S T U V W X Y Z a b c d e f g h i j k l m n o p q r s t u v w x y z AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB I PC EC QC RC oC pC","2":"1 2 3 4 5 6 7 8 nC LC J PB K D E F A B C L M G N O P QB RB SB TB UB qC rC","194":"VB WB XB YB ZB aB"},D:{"1":"0 9 bB cB dB eB fB gB hB iB jB kB lB mB nB oB pB qB rB sB tB uB vB MC wB NC xB yB zB 0B 1B 2B 3B 4B 5B 6B 7B 8B 9B AC BC CC DC Q H R S T U V W X Y Z a b c d e f g h i j k l m n o p q r s t u v w x y z AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB I PC EC QC RC","2":"1 2 3 4 5 6 7 8 J PB K D E F A B C L M G N O P QB RB SB TB UB VB WB","260":"XB YB ZB aB"},E:{"2":"J PB K D sC SC tC uC","260":"E vC","1028":"F A wC TC","3076":"B C L M G FC GC xC yC zC UC VC HC 0C IC WC XC YC ZC aC 1C JC bC cC dC eC fC 2C KC gC hC iC jC 3C"},F:{"1":"0 6 7 8 RB SB TB UB VB WB XB YB ZB aB bB cB dB eB fB gB hB iB jB kB lB mB nB oB pB qB rB sB tB uB vB wB xB yB zB 0B 1B 2B 3B 4B 5B 6B 7B 8B 9B AC BC CC DC Q H R OC S T U V W X Y Z a b c d e f g h i j k l m n o p q r s t u v w x y z","2":"1 F B C G N O P QB 4C 5C 6C 7C FC kC 8C GC","260":"2 3 4 5"},G:{"2":"SC 9C lC AD BD CD","260":"E DD","1028":"ED FD GD HD ID JD KD LD MD ND OD PD QD RD SD UC VC HC TD IC WC XC YC ZC aC UD JC bC cC dC eC fC VD KC gC hC iC jC"},H:{"2":"WD"},I:{"1":"I","2":"LC J XD YD ZD aD lC bD cD"},J:{"2":"D A"},K:{"1":"H","2":"A B C FC kC GC"},L:{"1":"I"},M:{"1":"EC"},N:{"2":"A B"},O:{"1":"HC"},P:{"1":"1 2 3 4 5 6 7 8 J dD eD fD gD hD TC iD jD kD lD mD IC JC KC nD"},Q:{"1":"oD"},R:{"1":"pD"},S:{"1":"qD rD"}},B:1,C:"Srcset and sizes attributes",D:true};
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"names":["_iterableToArray","iter","Symbol","iterator","Array","from"],"sources":["../../src/helpers/iterableToArray.ts"],"sourcesContent":["/* @minVersion 7.0.0-beta.0 */\n\nexport default function _iterableToArray<T>(iter: Iterable<T>) {\n if (\n (typeof Symbol !== \"undefined\" && iter[Symbol.iterator] != null) ||\n (iter as any)[\"@@iterator\"] != null\n ) {\n return Array.from(iter);\n }\n}\n"],"mappings":";;;;;;AAEe,SAASA,gBAAgBA,CAAIC,IAAiB,EAAE;EAC7D,IACG,OAAOC,MAAM,KAAK,WAAW,IAAID,IAAI,CAACC,MAAM,CAACC,QAAQ,CAAC,IAAI,IAAI,IAC9DF,IAAI,CAAS,YAAY,CAAC,IAAI,IAAI,EACnC;IACA,OAAOG,KAAK,CAACC,IAAI,CAACJ,IAAI,CAAC;EACzB;AACF","ignoreList":[]}
|
||||
@@ -0,0 +1,9 @@
|
||||
/*
|
||||
MIT License http://www.opensource.org/licenses/mit-license.php
|
||||
Author Tobias Koppers @sokra
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
// TODO remove in next major
|
||||
module.exports = require("./ModulesInHierarchicalDirectoriesPlugin");
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"names":["_getBindingIdentifiers","require","_default","exports","default","getOuterBindingIdentifiers","node","duplicates","getBindingIdentifiers"],"sources":["../../src/retrievers/getOuterBindingIdentifiers.ts"],"sourcesContent":["import getBindingIdentifiers from \"./getBindingIdentifiers.ts\";\nimport type * as t from \"../index.ts\";\n\nexport default getOuterBindingIdentifiers as {\n (node: t.Node, duplicates: true): Record<string, Array<t.Identifier>>;\n (node: t.Node, duplicates?: false): Record<string, t.Identifier>;\n (\n node: t.Node,\n duplicates?: boolean,\n ): Record<string, t.Identifier> | Record<string, Array<t.Identifier>>;\n};\n\nfunction getOuterBindingIdentifiers(\n node: t.Node,\n duplicates: boolean,\n): Record<string, t.Identifier> | Record<string, Array<t.Identifier>> {\n return getBindingIdentifiers(node, duplicates, true);\n}\n"],"mappings":";;;;;;AAAA,IAAAA,sBAAA,GAAAC,OAAA;AAA+D,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAGhDC,0BAA0B;AASzC,SAASA,0BAA0BA,CACjCC,IAAY,EACZC,UAAmB,EACiD;EACpE,OAAO,IAAAC,8BAAqB,EAACF,IAAI,EAAEC,UAAU,EAAE,IAAI,CAAC;AACtD","ignoreList":[]}
|
||||
@@ -0,0 +1,18 @@
|
||||
import { dirname, resolve } from 'path';
|
||||
import { readdirSync, statSync } from 'fs';
|
||||
|
||||
export default function (start, callback) {
|
||||
let dir = resolve('.', start);
|
||||
let tmp, stats = statSync(dir);
|
||||
|
||||
if (!stats.isDirectory()) {
|
||||
dir = dirname(dir);
|
||||
}
|
||||
|
||||
while (true) {
|
||||
tmp = callback(dir, readdirSync(dir));
|
||||
if (tmp) return resolve(dir, tmp);
|
||||
dir = dirname(tmp = dir);
|
||||
if (tmp === dir) break;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
||||
const withSelector_js = require("use-sync-external-store/shim/with-selector.js");
|
||||
const store = require("@tanstack/store");
|
||||
function useStore(store2, selector = (d) => d) {
|
||||
const slice = withSelector_js.useSyncExternalStoreWithSelector(
|
||||
store2.subscribe,
|
||||
() => store2.state,
|
||||
() => store2.state,
|
||||
selector,
|
||||
shallow
|
||||
);
|
||||
return slice;
|
||||
}
|
||||
function shallow(objA, objB) {
|
||||
if (Object.is(objA, objB)) {
|
||||
return true;
|
||||
}
|
||||
if (typeof objA !== "object" || objA === null || typeof objB !== "object" || objB === null) {
|
||||
return false;
|
||||
}
|
||||
if (objA instanceof Map && objB instanceof Map) {
|
||||
if (objA.size !== objB.size) return false;
|
||||
for (const [k, v] of objA) {
|
||||
if (!objB.has(k) || !Object.is(v, objB.get(k))) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (objA instanceof Set && objB instanceof Set) {
|
||||
if (objA.size !== objB.size) return false;
|
||||
for (const v of objA) {
|
||||
if (!objB.has(v)) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
const keysA = Object.keys(objA);
|
||||
if (keysA.length !== Object.keys(objB).length) {
|
||||
return false;
|
||||
}
|
||||
for (let i = 0; i < keysA.length; i++) {
|
||||
if (!Object.prototype.hasOwnProperty.call(objB, keysA[i]) || !Object.is(objA[keysA[i]], objB[keysA[i]])) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
exports.shallow = shallow;
|
||||
exports.useStore = useStore;
|
||||
Object.keys(store).forEach((k) => {
|
||||
if (k !== "default" && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
||||
enumerable: true,
|
||||
get: () => store[k]
|
||||
});
|
||||
});
|
||||
//# sourceMappingURL=index.cjs.map
|
||||
Reference in New Issue
Block a user