update
This commit is contained in:
@@ -0,0 +1,77 @@
|
||||
export type WaitOnEventOrTimeoutParameters = {
|
||||
/**
|
||||
* - The event target, can for example be:
|
||||
* `window`, `document`, a DOM element, or an {EventBus} instance.
|
||||
*/
|
||||
target: Object;
|
||||
/**
|
||||
* - The name of the event.
|
||||
*/
|
||||
name: string;
|
||||
/**
|
||||
* - The delay, in milliseconds, after which the
|
||||
* timeout occurs (if the event wasn't already dispatched).
|
||||
*/
|
||||
delay: number;
|
||||
};
|
||||
/**
|
||||
* Simple event bus for an application. Listeners are attached using the `on`
|
||||
* and `off` methods. To raise an event, the `dispatch` method shall be used.
|
||||
*/
|
||||
export class EventBus {
|
||||
/**
|
||||
* @param {string} eventName
|
||||
* @param {function} listener
|
||||
* @param {Object} [options]
|
||||
*/
|
||||
on(eventName: string, listener: Function, options?: Object | undefined): void;
|
||||
/**
|
||||
* @param {string} eventName
|
||||
* @param {function} listener
|
||||
* @param {Object} [options]
|
||||
*/
|
||||
off(eventName: string, listener: Function, options?: Object | undefined): void;
|
||||
/**
|
||||
* @param {string} eventName
|
||||
* @param {Object} data
|
||||
*/
|
||||
dispatch(eventName: string, data: Object): void;
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
_on(eventName: any, listener: any, options?: null): void;
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
_off(eventName: any, listener: any, options?: null): void;
|
||||
#private;
|
||||
}
|
||||
/**
|
||||
* NOTE: Only used in the Firefox build-in pdf viewer.
|
||||
*/
|
||||
export class FirefoxEventBus extends EventBus {
|
||||
constructor(globalEventNames: any, externalServices: any, isInAutomation: any);
|
||||
dispatch(eventName: any, data: any): void;
|
||||
#private;
|
||||
}
|
||||
/**
|
||||
* @typedef {Object} WaitOnEventOrTimeoutParameters
|
||||
* @property {Object} target - The event target, can for example be:
|
||||
* `window`, `document`, a DOM element, or an {EventBus} instance.
|
||||
* @property {string} name - The name of the event.
|
||||
* @property {number} delay - The delay, in milliseconds, after which the
|
||||
* timeout occurs (if the event wasn't already dispatched).
|
||||
*/
|
||||
/**
|
||||
* Allows waiting for an event or a timeout, whichever occurs first.
|
||||
* Can be used to ensure that an action always occurs, even when an event
|
||||
* arrives late or not at all.
|
||||
*
|
||||
* @param {WaitOnEventOrTimeoutParameters}
|
||||
* @returns {Promise} A promise that is resolved with a {WaitOnType} value.
|
||||
*/
|
||||
export function waitOnEventOrTimeout({ target, name, delay }: WaitOnEventOrTimeoutParameters): Promise<any>;
|
||||
export namespace WaitOnType {
|
||||
let EVENT: string;
|
||||
let TIMEOUT: string;
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
/**
|
||||
* @fileoverview Rule to flag use of an lexical declarations inside a case clause
|
||||
* @author Erik Arvidsson
|
||||
*/
|
||||
"use strict";
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Rule Definition
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/** @type {import('../shared/types').Rule} */
|
||||
module.exports = {
|
||||
meta: {
|
||||
type: "suggestion",
|
||||
|
||||
docs: {
|
||||
description: "Disallow lexical declarations in case clauses",
|
||||
recommended: true,
|
||||
url: "https://eslint.org/docs/latest/rules/no-case-declarations",
|
||||
},
|
||||
|
||||
hasSuggestions: true,
|
||||
|
||||
schema: [],
|
||||
|
||||
messages: {
|
||||
addBrackets: "Add {} brackets around the case block.",
|
||||
unexpected: "Unexpected lexical declaration in case block.",
|
||||
},
|
||||
},
|
||||
|
||||
create(context) {
|
||||
/**
|
||||
* Checks whether or not a node is a lexical declaration.
|
||||
* @param {ASTNode} node A direct child statement of a switch case.
|
||||
* @returns {boolean} Whether or not the node is a lexical declaration.
|
||||
*/
|
||||
function isLexicalDeclaration(node) {
|
||||
switch (node.type) {
|
||||
case "FunctionDeclaration":
|
||||
case "ClassDeclaration":
|
||||
return true;
|
||||
case "VariableDeclaration":
|
||||
return node.kind !== "var";
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
SwitchCase(node) {
|
||||
for (let i = 0; i < node.consequent.length; i++) {
|
||||
const statement = node.consequent[i];
|
||||
|
||||
if (isLexicalDeclaration(statement)) {
|
||||
context.report({
|
||||
node: statement,
|
||||
messageId: "unexpected",
|
||||
suggest: [
|
||||
{
|
||||
messageId: "addBrackets",
|
||||
fix: fixer => [
|
||||
fixer.insertTextBefore(
|
||||
node.consequent[0],
|
||||
"{ ",
|
||||
),
|
||||
fixer.insertTextAfter(
|
||||
node.consequent.at(-1),
|
||||
" }",
|
||||
),
|
||||
],
|
||||
},
|
||||
],
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
};
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,12 @@
|
||||
#!/usr/bin/env sh
|
||||
|
||||
set -e
|
||||
|
||||
mkdir -p .browser
|
||||
|
||||
echo
|
||||
echo Preparing browser tests:
|
||||
|
||||
find spec -type f -name '*.spec.js' | \
|
||||
xargs -I {} sh -c \
|
||||
'export f="{}"; echo $f; browserify $f -t require-globify -t brfs -x ajv -u buffer -o $(echo $f | sed -e "s/spec/.browser/");'
|
||||
@@ -0,0 +1,8 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = (flag, argv = process.argv) => {
|
||||
const prefix = flag.startsWith('-') ? '' : (flag.length === 1 ? '-' : '--');
|
||||
const position = argv.indexOf(prefix + flag);
|
||||
const terminatorPosition = argv.indexOf('--');
|
||||
return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition);
|
||||
};
|
||||
@@ -0,0 +1,444 @@
|
||||
import type { RouteIds } from './routeInfo'
|
||||
import type { AnyRouter } from './router'
|
||||
|
||||
export type NoInfer<T> = [T][T extends any ? 0 : never]
|
||||
export type IsAny<TValue, TYesResult, TNoResult = TValue> = 1 extends 0 & TValue
|
||||
? TYesResult
|
||||
: TNoResult
|
||||
|
||||
export type PickAsRequired<TValue, TKey extends keyof TValue> = Omit<
|
||||
TValue,
|
||||
TKey
|
||||
> &
|
||||
Required<Pick<TValue, TKey>>
|
||||
|
||||
export type PickRequired<T> = {
|
||||
[K in keyof T as undefined extends T[K] ? never : K]: T[K]
|
||||
}
|
||||
|
||||
export type PickOptional<T> = {
|
||||
[K in keyof T as undefined extends T[K] ? K : never]: T[K]
|
||||
}
|
||||
|
||||
// from https://stackoverflow.com/a/76458160
|
||||
export type WithoutEmpty<T> = T extends any ? ({} extends T ? never : T) : never
|
||||
|
||||
export type Expand<T> = T extends object
|
||||
? T extends infer O
|
||||
? O extends Function
|
||||
? O
|
||||
: { [K in keyof O]: O[K] }
|
||||
: never
|
||||
: T
|
||||
|
||||
export type DeepPartial<T> = T extends object
|
||||
? {
|
||||
[P in keyof T]?: DeepPartial<T[P]>
|
||||
}
|
||||
: T
|
||||
|
||||
export type MakeDifferenceOptional<TLeft, TRight> = Omit<
|
||||
TRight,
|
||||
keyof TLeft
|
||||
> & {
|
||||
[K in keyof TLeft & keyof TRight]?: TRight[K]
|
||||
}
|
||||
|
||||
// from https://stackoverflow.com/a/53955431
|
||||
// eslint-disable-next-line @typescript-eslint/naming-convention
|
||||
export type IsUnion<T, U extends T = T> = (
|
||||
T extends any ? (U extends T ? false : true) : never
|
||||
) extends false
|
||||
? false
|
||||
: true
|
||||
|
||||
export type IsNonEmptyObject<T> = T extends object
|
||||
? keyof T extends never
|
||||
? false
|
||||
: true
|
||||
: false
|
||||
|
||||
export type Assign<TLeft, TRight> = TLeft extends any
|
||||
? TRight extends any
|
||||
? IsNonEmptyObject<TLeft> extends false
|
||||
? TRight
|
||||
: IsNonEmptyObject<TRight> extends false
|
||||
? TLeft
|
||||
: keyof TLeft & keyof TRight extends never
|
||||
? TLeft & TRight
|
||||
: Omit<TLeft, keyof TRight> & TRight
|
||||
: never
|
||||
: never
|
||||
|
||||
export type IntersectAssign<TLeft, TRight> = TLeft extends any
|
||||
? TRight extends any
|
||||
? IsNonEmptyObject<TLeft> extends false
|
||||
? TRight
|
||||
: IsNonEmptyObject<TRight> extends false
|
||||
? TLeft
|
||||
: TRight & TLeft
|
||||
: never
|
||||
: never
|
||||
|
||||
export type Timeout = ReturnType<typeof setTimeout>
|
||||
|
||||
export type Updater<TPrevious, TResult = TPrevious> =
|
||||
| TResult
|
||||
| ((prev?: TPrevious) => TResult)
|
||||
|
||||
export type NonNullableUpdater<TPrevious, TResult = TPrevious> =
|
||||
| TResult
|
||||
| ((prev: TPrevious) => TResult)
|
||||
|
||||
export type ExtractObjects<TUnion> = TUnion extends MergeAllPrimitive
|
||||
? never
|
||||
: TUnion
|
||||
|
||||
export type PartialMergeAllObject<TUnion> =
|
||||
ExtractObjects<TUnion> extends infer TObj
|
||||
? [TObj] extends [never]
|
||||
? never
|
||||
: {
|
||||
[TKey in TObj extends any ? keyof TObj : never]?: TObj extends any
|
||||
? TKey extends keyof TObj
|
||||
? TObj[TKey]
|
||||
: never
|
||||
: never
|
||||
}
|
||||
: never
|
||||
|
||||
export type MergeAllPrimitive =
|
||||
| ReadonlyArray<any>
|
||||
| number
|
||||
| string
|
||||
| bigint
|
||||
| boolean
|
||||
| symbol
|
||||
| undefined
|
||||
| null
|
||||
|
||||
export type ExtractPrimitives<TUnion> = TUnion extends MergeAllPrimitive
|
||||
? TUnion
|
||||
: TUnion extends object
|
||||
? never
|
||||
: TUnion
|
||||
|
||||
export type PartialMergeAll<TUnion> =
|
||||
| ExtractPrimitives<TUnion>
|
||||
| PartialMergeAllObject<TUnion>
|
||||
|
||||
export type Constrain<T, TConstraint, TDefault = TConstraint> =
|
||||
| (T extends TConstraint ? T : never)
|
||||
| TDefault
|
||||
|
||||
export type ConstrainLiteral<T, TConstraint, TDefault = TConstraint> =
|
||||
| (T & TConstraint)
|
||||
| TDefault
|
||||
|
||||
/**
|
||||
* To be added to router types
|
||||
*/
|
||||
export type UnionToIntersection<T> = (
|
||||
T extends any ? (arg: T) => any : never
|
||||
) extends (arg: infer T) => any
|
||||
? T
|
||||
: never
|
||||
|
||||
/**
|
||||
* Merges everything in a union into one object.
|
||||
* This mapped type is homomorphic which means it preserves stuff! :)
|
||||
*/
|
||||
export type MergeAllObjects<
|
||||
TUnion,
|
||||
TIntersected = UnionToIntersection<ExtractObjects<TUnion>>,
|
||||
> = [keyof TIntersected] extends [never]
|
||||
? never
|
||||
: {
|
||||
[TKey in keyof TIntersected]: TUnion extends any
|
||||
? TUnion[TKey & keyof TUnion]
|
||||
: never
|
||||
}
|
||||
|
||||
export type MergeAll<TUnion> =
|
||||
| MergeAllObjects<TUnion>
|
||||
| ExtractPrimitives<TUnion>
|
||||
|
||||
export type ValidateJSON<T> = ((...args: Array<any>) => any) extends T
|
||||
? unknown extends T
|
||||
? never
|
||||
: 'Function is not serializable'
|
||||
: { [K in keyof T]: ValidateJSON<T[K]> }
|
||||
|
||||
export function last<T>(arr: Array<T>) {
|
||||
return arr[arr.length - 1]
|
||||
}
|
||||
|
||||
function isFunction(d: any): d is Function {
|
||||
return typeof d === 'function'
|
||||
}
|
||||
|
||||
export function functionalUpdate<TPrevious, TResult = TPrevious>(
|
||||
updater: Updater<TPrevious, TResult> | NonNullableUpdater<TPrevious, TResult>,
|
||||
previous: TPrevious,
|
||||
): TResult {
|
||||
if (isFunction(updater)) {
|
||||
return updater(previous)
|
||||
}
|
||||
|
||||
return updater
|
||||
}
|
||||
|
||||
export function pick<TValue, TKey extends keyof TValue>(
|
||||
parent: TValue,
|
||||
keys: Array<TKey>,
|
||||
): Pick<TValue, TKey> {
|
||||
return keys.reduce((obj: any, key: TKey) => {
|
||||
obj[key] = parent[key]
|
||||
return obj
|
||||
}, {} as any)
|
||||
}
|
||||
|
||||
/**
|
||||
* This function returns `prev` if `_next` is deeply equal.
|
||||
* If not, it will replace any deeply equal children of `b` with those of `a`.
|
||||
* This can be used for structural sharing between immutable JSON values for example.
|
||||
* Do not use this with signals
|
||||
*/
|
||||
export function replaceEqualDeep<T>(prev: any, _next: T): T {
|
||||
if (prev === _next) {
|
||||
return prev
|
||||
}
|
||||
|
||||
const next = _next as any
|
||||
|
||||
const array = isPlainArray(prev) && isPlainArray(next)
|
||||
|
||||
if (array || (isPlainObject(prev) && isPlainObject(next))) {
|
||||
const prevItems = array ? prev : Object.keys(prev)
|
||||
const prevSize = prevItems.length
|
||||
const nextItems = array ? next : Object.keys(next)
|
||||
const nextSize = nextItems.length
|
||||
const copy: any = array ? [] : {}
|
||||
|
||||
let equalItems = 0
|
||||
|
||||
for (let i = 0; i < nextSize; i++) {
|
||||
const key = array ? i : (nextItems[i] as any)
|
||||
if (
|
||||
((!array && prevItems.includes(key)) || array) &&
|
||||
prev[key] === undefined &&
|
||||
next[key] === undefined
|
||||
) {
|
||||
copy[key] = undefined
|
||||
equalItems++
|
||||
} else {
|
||||
copy[key] = replaceEqualDeep(prev[key], next[key])
|
||||
if (copy[key] === prev[key] && prev[key] !== undefined) {
|
||||
equalItems++
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return prevSize === nextSize && equalItems === prevSize ? prev : copy
|
||||
}
|
||||
|
||||
return next
|
||||
}
|
||||
|
||||
// Copied from: https://github.com/jonschlinkert/is-plain-object
|
||||
export function isPlainObject(o: any) {
|
||||
if (!hasObjectPrototype(o)) {
|
||||
return false
|
||||
}
|
||||
|
||||
// If has modified constructor
|
||||
const ctor = o.constructor
|
||||
if (typeof ctor === 'undefined') {
|
||||
return true
|
||||
}
|
||||
|
||||
// If has modified prototype
|
||||
const prot = ctor.prototype
|
||||
if (!hasObjectPrototype(prot)) {
|
||||
return false
|
||||
}
|
||||
|
||||
// If constructor does not have an Object-specific method
|
||||
if (!prot.hasOwnProperty('isPrototypeOf')) {
|
||||
return false
|
||||
}
|
||||
|
||||
// Most likely a plain Object
|
||||
return true
|
||||
}
|
||||
|
||||
function hasObjectPrototype(o: any) {
|
||||
return Object.prototype.toString.call(o) === '[object Object]'
|
||||
}
|
||||
|
||||
export function isPlainArray(value: unknown): value is Array<unknown> {
|
||||
return Array.isArray(value) && value.length === Object.keys(value).length
|
||||
}
|
||||
|
||||
function getObjectKeys(obj: any, ignoreUndefined: boolean) {
|
||||
let keys = Object.keys(obj)
|
||||
if (ignoreUndefined) {
|
||||
keys = keys.filter((key) => obj[key] !== undefined)
|
||||
}
|
||||
return keys
|
||||
}
|
||||
|
||||
export function deepEqual(
|
||||
a: any,
|
||||
b: any,
|
||||
opts?: { partial?: boolean; ignoreUndefined?: boolean },
|
||||
): boolean {
|
||||
if (a === b) {
|
||||
return true
|
||||
}
|
||||
|
||||
if (typeof a !== typeof b) {
|
||||
return false
|
||||
}
|
||||
|
||||
if (isPlainObject(a) && isPlainObject(b)) {
|
||||
const ignoreUndefined = opts?.ignoreUndefined ?? true
|
||||
const aKeys = getObjectKeys(a, ignoreUndefined)
|
||||
const bKeys = getObjectKeys(b, ignoreUndefined)
|
||||
|
||||
if (!opts?.partial && aKeys.length !== bKeys.length) {
|
||||
return false
|
||||
}
|
||||
|
||||
return bKeys.every((key) => deepEqual(a[key], b[key], opts))
|
||||
}
|
||||
|
||||
if (Array.isArray(a) && Array.isArray(b)) {
|
||||
if (a.length !== b.length) {
|
||||
return false
|
||||
}
|
||||
return !a.some((item, index) => !deepEqual(item, b[index], opts))
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
export type StringLiteral<T> = T extends string
|
||||
? string extends T
|
||||
? string
|
||||
: T
|
||||
: never
|
||||
|
||||
export type ThrowOrOptional<T, TThrow extends boolean> = TThrow extends true
|
||||
? T
|
||||
: T | undefined
|
||||
|
||||
export type StrictOrFrom<
|
||||
TRouter extends AnyRouter,
|
||||
TFrom,
|
||||
TStrict extends boolean = true,
|
||||
> = TStrict extends false
|
||||
? {
|
||||
from?: never
|
||||
strict: TStrict
|
||||
}
|
||||
: {
|
||||
from: ConstrainLiteral<TFrom, RouteIds<TRouter['routeTree']>>
|
||||
strict?: TStrict
|
||||
}
|
||||
|
||||
export type ThrowConstraint<
|
||||
TStrict extends boolean,
|
||||
TThrow extends boolean,
|
||||
> = TStrict extends false ? (TThrow extends true ? never : TThrow) : TThrow
|
||||
|
||||
export type ControlledPromise<T> = Promise<T> & {
|
||||
resolve: (value: T) => void
|
||||
reject: (value: any) => void
|
||||
status: 'pending' | 'resolved' | 'rejected'
|
||||
value?: T
|
||||
}
|
||||
|
||||
export function createControlledPromise<T>(onResolve?: (value: T) => void) {
|
||||
let resolveLoadPromise!: (value: T) => void
|
||||
let rejectLoadPromise!: (value: any) => void
|
||||
|
||||
const controlledPromise = new Promise<T>((resolve, reject) => {
|
||||
resolveLoadPromise = resolve
|
||||
rejectLoadPromise = reject
|
||||
}) as ControlledPromise<T>
|
||||
|
||||
controlledPromise.status = 'pending'
|
||||
|
||||
controlledPromise.resolve = (value: T) => {
|
||||
controlledPromise.status = 'resolved'
|
||||
controlledPromise.value = value
|
||||
resolveLoadPromise(value)
|
||||
onResolve?.(value)
|
||||
}
|
||||
|
||||
controlledPromise.reject = (e) => {
|
||||
controlledPromise.status = 'rejected'
|
||||
rejectLoadPromise(e)
|
||||
}
|
||||
|
||||
return controlledPromise
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @deprecated use `jsesc` instead
|
||||
*/
|
||||
export function escapeJSON(jsonString: string) {
|
||||
return jsonString
|
||||
.replace(/\\/g, '\\\\') // Escape backslashes
|
||||
.replace(/'/g, "\\'") // Escape single quotes
|
||||
.replace(/"/g, '\\"') // Escape double quotes
|
||||
}
|
||||
|
||||
export function shallow<T>(objA: T, objB: T) {
|
||||
if (Object.is(objA, objB)) {
|
||||
return true
|
||||
}
|
||||
|
||||
if (
|
||||
typeof objA !== 'object' ||
|
||||
objA === null ||
|
||||
typeof objB !== 'object' ||
|
||||
objB === null
|
||||
) {
|
||||
return false
|
||||
}
|
||||
|
||||
const keysA = Object.keys(objA)
|
||||
if (keysA.length !== Object.keys(objB).length) {
|
||||
return false
|
||||
}
|
||||
|
||||
for (const item of keysA) {
|
||||
if (
|
||||
!Object.prototype.hasOwnProperty.call(objB, item) ||
|
||||
!Object.is(objA[item as keyof T], objB[item as keyof T])
|
||||
) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a string contains URI-encoded special characters (e.g., %3F, %20).
|
||||
*
|
||||
* @param {string} inputString The string to check.
|
||||
* @returns {boolean} True if the string contains URI-encoded characters, false otherwise.
|
||||
* @example
|
||||
* ```typescript
|
||||
* const str1 = "foo%3Fbar";
|
||||
* const hasEncodedChars = hasUriEncodedChars(str1); // returns true
|
||||
* ```
|
||||
*/
|
||||
export function hasUriEncodedChars(inputString: string): boolean {
|
||||
// This regex looks for a percent sign followed by two hexadecimal digits
|
||||
const pattern = /%[0-9A-Fa-f]{2}/
|
||||
return pattern.test(inputString)
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
# napi-build-utils
|
||||
|
||||
[](https://www.npmjs.com/package/napi-build-utils)
|
||||

|
||||

|
||||
[](http://standardjs.com/)
|
||||
[](https://opensource.org/licenses/MIT)
|
||||
|
||||
A set of utilities to assist developers of tools that build [Node-API](https://nodejs.org/api/n-api.html#n_api_n_api) native add-ons.
|
||||
|
||||
## Background
|
||||
|
||||
This module is targeted to developers creating tools that build Node-API native add-ons.
|
||||
|
||||
It implements a set of functions that aid in determining the Node-API version supported by the currently running Node instance and the set of Node-API versions against which the Node-API native add-on is designed to be built. Other functions determine whether a particular Node-API version can be built and can issue console warnings for unsupported Node-API versions.
|
||||
|
||||
Unlike the modules this code is designed to facilitate building, this module is written entirely in JavaScript.
|
||||
|
||||
## Quick start
|
||||
|
||||
```bash
|
||||
npm install napi-build-utils
|
||||
```
|
||||
|
||||
The module exports a set of functions documented [here](./index.md). For example:
|
||||
|
||||
```javascript
|
||||
var napiBuildUtils = require('napi-build-utils');
|
||||
var napiVersion = napiBuildUtils.getNapiVersion(); // Node-API version supported by Node, or undefined.
|
||||
```
|
||||
|
||||
## Declaring supported Node-API versions
|
||||
|
||||
Native modules that are designed to work with [Node-API](https://nodejs.org/api/n-api.html#n_api_n_api) must explicitly declare the Node-API version(s) against which they are coded to build. This is accomplished by including a `binary.napi_versions` property in the module's `package.json` file. For example:
|
||||
|
||||
```json
|
||||
"binary": {
|
||||
"napi_versions": [2,3]
|
||||
}
|
||||
```
|
||||
|
||||
In the absence of a need to compile against a specific Node-API version, the value `3` is a good choice as this is the Node-API version that was supported when Node-API left experimental status.
|
||||
|
||||
Modules that are built against a specific Node-API version will continue to operate indefinitely, even as later versions of Node-API are introduced.
|
||||
|
||||
## History
|
||||
|
||||
**v2.0.0** This version was introduced to address a limitation when the Node-API version reached `10` in NodeJS `v23.6.0`. There was no change in the API, but a SemVer bump to `2.0.0` was made out of an abundance of caution.
|
||||
|
||||
## Support
|
||||
|
||||
If you run into problems or limitations, please file an issue and we'll take a look. Pull requests are also welcome.
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"names":["_isNode","require","assertNode","node","isNode","_node$type","type","JSON","stringify","TypeError"],"sources":["../../src/asserts/assertNode.ts"],"sourcesContent":["import isNode from \"../validators/isNode.ts\";\nimport type * as t from \"../index.ts\";\n\nexport default function assertNode(node?: any): asserts node is t.Node {\n if (!isNode(node)) {\n const type = node?.type ?? JSON.stringify(node);\n throw new TypeError(`Not a valid node of type \"${type}\"`);\n }\n}\n"],"mappings":";;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AAGe,SAASC,UAAUA,CAACC,IAAU,EAA0B;EACrE,IAAI,CAAC,IAAAC,eAAM,EAACD,IAAI,CAAC,EAAE;IAAA,IAAAE,UAAA;IACjB,MAAMC,IAAI,IAAAD,UAAA,GAAGF,IAAI,oBAAJA,IAAI,CAAEG,IAAI,YAAAD,UAAA,GAAIE,IAAI,CAACC,SAAS,CAACL,IAAI,CAAC;IAC/C,MAAM,IAAIM,SAAS,CAAC,6BAA6BH,IAAI,GAAG,CAAC;EAC3D;AACF","ignoreList":[]}
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"useSearch.cjs","sources":["../../src/useSearch.tsx"],"sourcesContent":["import { useMatch } from './useMatch'\nimport type {\n StructuralSharingOption,\n ValidateSelected,\n} from './structuralSharing'\nimport type {\n AnyRouter,\n RegisteredRouter,\n ResolveUseSearch,\n StrictOrFrom,\n ThrowConstraint,\n ThrowOrOptional,\n UseSearchResult,\n} from '@tanstack/router-core'\n\nexport interface UseSearchBaseOptions<\n TRouter extends AnyRouter,\n TFrom,\n TStrict extends boolean,\n TThrow extends boolean,\n TSelected,\n TStructuralSharing,\n> {\n select?: (\n state: ResolveUseSearch<TRouter, TFrom, TStrict>,\n ) => ValidateSelected<TRouter, TSelected, TStructuralSharing>\n shouldThrow?: TThrow\n}\n\nexport type UseSearchOptions<\n TRouter extends AnyRouter,\n TFrom,\n TStrict extends boolean,\n TThrow extends boolean,\n TSelected,\n TStructuralSharing,\n> = StrictOrFrom<TRouter, TFrom, TStrict> &\n UseSearchBaseOptions<\n TRouter,\n TFrom,\n TStrict,\n TThrow,\n TSelected,\n TStructuralSharing\n > &\n StructuralSharingOption<TRouter, TSelected, TStructuralSharing>\n\nexport type UseSearchRoute<out TFrom> = <\n TRouter extends AnyRouter = RegisteredRouter,\n TSelected = unknown,\n TStructuralSharing extends boolean = boolean,\n>(\n opts?: UseSearchBaseOptions<\n TRouter,\n TFrom,\n /* TStrict */ true,\n /* TThrow */ true,\n TSelected,\n TStructuralSharing\n > &\n StructuralSharingOption<TRouter, TSelected, TStructuralSharing>,\n) => UseSearchResult<TRouter, TFrom, true, TSelected>\n\nexport function useSearch<\n TRouter extends AnyRouter = RegisteredRouter,\n const TFrom extends string | undefined = undefined,\n TStrict extends boolean = true,\n TThrow extends boolean = true,\n TSelected = unknown,\n TStructuralSharing extends boolean = boolean,\n>(\n opts: UseSearchOptions<\n TRouter,\n TFrom,\n TStrict,\n ThrowConstraint<TStrict, TThrow>,\n TSelected,\n TStructuralSharing\n >,\n): ThrowOrOptional<\n UseSearchResult<TRouter, TFrom, TStrict, TSelected>,\n TThrow\n> {\n return useMatch({\n from: opts.from!,\n strict: opts.strict,\n shouldThrow: opts.shouldThrow,\n structuralSharing: opts.structuralSharing,\n select: (match: any) => {\n return opts.select ? opts.select(match.search) : match.search\n },\n }) as any\n}\n"],"names":["useMatch"],"mappings":";;;AA+DO,SAAS,UAQd,MAWA;AACA,SAAOA,kBAAS;AAAA,IACd,MAAM,KAAK;AAAA,IACX,QAAQ,KAAK;AAAA,IACb,aAAa,KAAK;AAAA,IAClB,mBAAmB,KAAK;AAAA,IACxB,QAAQ,CAAC,UAAe;AACtB,aAAO,KAAK,SAAS,KAAK,OAAO,MAAM,MAAM,IAAI,MAAM;AAAA,IAAA;AAAA,EACzD,CACD;AACH;;"}
|
||||
@@ -0,0 +1,3 @@
|
||||
import type { DocumentContextType } from './shared/types.js';
|
||||
declare const documentContext: React.Context<DocumentContextType>;
|
||||
export default documentContext;
|
||||
@@ -0,0 +1 @@
|
||||
module.exports={A:{A:{"2":"K D E F A B mC"},B:{"1":"0 9 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","2":"C L M G N O P","194":"Q H R S T U","260":"V W X Y Z a b c d e f g h i j k l m n"},C:{"2":"0 1 2 3 4 5 6 7 8 9 nC LC J PB K D E F A B C L M G N O P QB 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 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 qC rC"},D:{"1":"0 9 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 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 MC wB NC xB yB zB 0B 1B 2B 3B 4B 5B 6B 7B 8B","194":"9B AC BC CC DC Q H R S T U","260":"V W X Y Z a b c d e f g h i j k l m n"},E:{"2":"J PB K D E F A B C L M G sC SC tC uC vC wC TC 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 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 2 3 4 5 6 7 8 F B C G N O P QB 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 4C 5C 6C 7C FC kC 8C GC","194":"xB yB zB 0B 1B 2B 3B 4B 5B 6B","260":"7B 8B 9B AC BC CC DC Q H R OC S T U V W X Y Z"},G:{"2":"E SC 9C lC AD BD CD DD 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:{"2":"LC J I XD YD ZD aD lC bD cD"},J:{"2":"D A"},K:{"2":"A B C H FC kC GC"},L:{"2":"I"},M:{"2":"EC"},N:{"2":"A B"},O:{"2":"HC"},P:{"2":"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:{"2":"oD"},R:{"2":"pD"},S:{"2":"qD rD"}},B:7,C:"File System Access API",D:true};
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,109 @@
|
||||
{
|
||||
"name": "lightningcss",
|
||||
"version": "1.29.2",
|
||||
"license": "MPL-2.0",
|
||||
"description": "A CSS parser, transformer, and minifier written in Rust",
|
||||
"main": "node/index.js",
|
||||
"types": "node/index.d.ts",
|
||||
"exports": {
|
||||
"types": "./node/index.d.ts",
|
||||
"import": "./node/index.mjs",
|
||||
"require": "./node/index.js"
|
||||
},
|
||||
"browserslist": "last 2 versions, not dead",
|
||||
"targets": {
|
||||
"main": false,
|
||||
"types": false
|
||||
},
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/parcel"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/parcel-bundler/lightningcss.git"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 12.0.0"
|
||||
},
|
||||
"napi": {
|
||||
"name": "lightningcss"
|
||||
},
|
||||
"files": [
|
||||
"node/*.js",
|
||||
"node/*.mjs",
|
||||
"node/*.d.ts",
|
||||
"node/*.flow"
|
||||
],
|
||||
"dependencies": {
|
||||
"detect-libc": "^2.0.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/parser": "7.21.4",
|
||||
"@babel/traverse": "7.21.4",
|
||||
"@codemirror/lang-css": "^6.0.1",
|
||||
"@codemirror/lang-javascript": "^6.1.2",
|
||||
"@codemirror/lint": "^6.1.0",
|
||||
"@codemirror/theme-one-dark": "^6.1.0",
|
||||
"@mdn/browser-compat-data": "~5.7.0",
|
||||
"@napi-rs/cli": "^2.14.0",
|
||||
"autoprefixer": "^10.4.20",
|
||||
"caniuse-lite": "^1.0.30001702",
|
||||
"codemirror": "^6.0.1",
|
||||
"cssnano": "^7.0.6",
|
||||
"esbuild": "^0.19.8",
|
||||
"flowgen": "^1.21.0",
|
||||
"jest-diff": "^27.4.2",
|
||||
"json-schema-to-typescript": "^11.0.2",
|
||||
"markdown-it-anchor": "^8.6.6",
|
||||
"markdown-it-prism": "^2.3.0",
|
||||
"markdown-it-table-of-contents": "^0.6.0",
|
||||
"napi-wasm": "^1.0.1",
|
||||
"node-fetch": "^3.1.0",
|
||||
"parcel": "^2.8.2",
|
||||
"patch-package": "^6.5.0",
|
||||
"path-browserify": "^1.0.1",
|
||||
"postcss": "^8.3.11",
|
||||
"posthtml-include": "^1.7.4",
|
||||
"posthtml-markdownit": "^1.3.1",
|
||||
"posthtml-prism": "^1.0.4",
|
||||
"process": "^0.11.10",
|
||||
"puppeteer": "^12.0.1",
|
||||
"recast": "^0.22.0",
|
||||
"sharp": "^0.33.5",
|
||||
"typescript": "^5.7.2",
|
||||
"util": "^0.12.4",
|
||||
"uvu": "^0.5.6"
|
||||
},
|
||||
"resolutions": {
|
||||
"lightningcss": "link:."
|
||||
},
|
||||
"scripts": {
|
||||
"prepare": "patch-package",
|
||||
"build": "node scripts/build.js && node scripts/build-flow.js",
|
||||
"build-release": "node scripts/build.js --release && node scripts/build-flow.js",
|
||||
"prepublishOnly": "node scripts/build-flow.js",
|
||||
"wasm:build": "cargo build --target wasm32-unknown-unknown -p lightningcss_node && wasm-opt target/wasm32-unknown-unknown/debug/lightningcss_node.wasm --asyncify --pass-arg=asyncify-imports@env.await_promise_sync -Oz -o wasm/lightningcss_node.wasm && node scripts/build-wasm.js",
|
||||
"wasm:build-release": "cargo build --target wasm32-unknown-unknown -p lightningcss_node --release && wasm-opt target/wasm32-unknown-unknown/release/lightningcss_node.wasm --asyncify --pass-arg=asyncify-imports@env.await_promise_sync -Oz -o wasm/lightningcss_node.wasm && node scripts/build-wasm.js",
|
||||
"website:start": "parcel 'website/*.html' website/playground/index.html",
|
||||
"website:build": "yarn wasm:build-release && parcel build 'website/*.html' website/playground/index.html",
|
||||
"build-ast": "cargo run --example schema --features jsonschema && node scripts/build-ast.js",
|
||||
"tsc": "tsc -p node/tsconfig.json",
|
||||
"test": "uvu node/test"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"lightningcss-darwin-x64": "1.29.2",
|
||||
"lightningcss-linux-x64-gnu": "1.29.2",
|
||||
"lightningcss-win32-x64-msvc": "1.29.2",
|
||||
"lightningcss-win32-arm64-msvc": "1.29.2",
|
||||
"lightningcss-darwin-arm64": "1.29.2",
|
||||
"lightningcss-linux-arm64-gnu": "1.29.2",
|
||||
"lightningcss-linux-arm-gnueabihf": "1.29.2",
|
||||
"lightningcss-linux-arm64-musl": "1.29.2",
|
||||
"lightningcss-linux-x64-musl": "1.29.2",
|
||||
"lightningcss-freebsd-x64": "1.29.2"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user