update
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
import { AnyRouter } from './router.cjs';
|
||||
import { ParsedLocation } from './location.cjs';
|
||||
import { NonNullableUpdater } from './utils.cjs';
|
||||
export type ScrollRestorationEntry = {
|
||||
scrollX: number;
|
||||
scrollY: number;
|
||||
};
|
||||
export type ScrollRestorationByElement = Record<string, ScrollRestorationEntry>;
|
||||
export type ScrollRestorationByKey = Record<string, ScrollRestorationByElement>;
|
||||
export type ScrollRestorationCache = {
|
||||
state: ScrollRestorationByKey;
|
||||
set: (updater: NonNullableUpdater<ScrollRestorationByKey>) => void;
|
||||
};
|
||||
export type ScrollRestorationOptions = {
|
||||
getKey?: (location: ParsedLocation) => string;
|
||||
scrollBehavior?: ScrollToOptions['behavior'];
|
||||
};
|
||||
export declare const storageKey = "tsr-scroll-restoration-v1_3";
|
||||
export declare const scrollRestorationCache: ScrollRestorationCache;
|
||||
/**
|
||||
* The default `getKey` function for `useScrollRestoration`.
|
||||
* It returns the `key` from the location state or the `href` of the location.
|
||||
*
|
||||
* The `location.href` is used as a fallback to support the use case where the location state is not available like the initial render.
|
||||
*/
|
||||
export declare const defaultGetScrollRestorationKey: (location: ParsedLocation) => string;
|
||||
export declare function getCssSelector(el: any): string;
|
||||
export declare function restoreScroll(storageKey: string, key: string | undefined, behavior: ScrollToOptions['behavior'] | undefined, shouldScrollRestoration: boolean | undefined, scrollToTopSelectors: Array<string> | undefined): void;
|
||||
export declare function setupScrollRestoration(router: AnyRouter, force?: boolean): void;
|
||||
/**
|
||||
* @internal
|
||||
* Handles hash-based scrolling after navigation completes.
|
||||
* To be used in framework-specific <Transitioner> components during the onResolved event.
|
||||
*
|
||||
* Provides hash scrolling for programmatic navigation when default browser handling is prevented.
|
||||
* @param router The router instance containing current location and state
|
||||
*/
|
||||
export declare function handleHashScroll(router: AnyRouter): void;
|
||||
@@ -0,0 +1,204 @@
|
||||
'use client';
|
||||
|
||||
import { useEffect, useMemo, useRef } from 'react';
|
||||
import makeCancellable from 'make-cancellable-promise';
|
||||
import clsx from 'clsx';
|
||||
import invariant from 'tiny-invariant';
|
||||
import warning from 'warning';
|
||||
import * as pdfjs from 'pdfjs-dist';
|
||||
|
||||
import useDocumentContext from '../shared/hooks/useDocumentContext.js';
|
||||
import usePageContext from '../shared/hooks/usePageContext.js';
|
||||
import useResolver from '../shared/hooks/useResolver.js';
|
||||
import { cancelRunningTask } from '../shared/utils.js';
|
||||
|
||||
import type { Annotations } from '../shared/types.js';
|
||||
|
||||
export default function AnnotationLayer(): React.ReactElement {
|
||||
const documentContext = useDocumentContext();
|
||||
const pageContext = usePageContext();
|
||||
|
||||
invariant(pageContext, 'Unable to find Page context.');
|
||||
|
||||
const mergedProps = { ...documentContext, ...pageContext };
|
||||
const {
|
||||
imageResourcesPath,
|
||||
linkService,
|
||||
onGetAnnotationsError: onGetAnnotationsErrorProps,
|
||||
onGetAnnotationsSuccess: onGetAnnotationsSuccessProps,
|
||||
onRenderAnnotationLayerError: onRenderAnnotationLayerErrorProps,
|
||||
onRenderAnnotationLayerSuccess: onRenderAnnotationLayerSuccessProps,
|
||||
page,
|
||||
pdf,
|
||||
renderForms,
|
||||
rotate,
|
||||
scale = 1,
|
||||
} = mergedProps;
|
||||
|
||||
invariant(
|
||||
pdf,
|
||||
'Attempted to load page annotations, but no document was specified. Wrap <Page /> in a <Document /> or pass explicit `pdf` prop.',
|
||||
);
|
||||
invariant(page, 'Attempted to load page annotations, but no page was specified.');
|
||||
invariant(linkService, 'Attempted to load page annotations, but no linkService was specified.');
|
||||
|
||||
const [annotationsState, annotationsDispatch] = useResolver<Annotations>();
|
||||
const { value: annotations, error: annotationsError } = annotationsState;
|
||||
const layerElement = useRef<HTMLDivElement>(null);
|
||||
|
||||
warning(
|
||||
Number.parseInt(
|
||||
window.getComputedStyle(document.body).getPropertyValue('--react-pdf-annotation-layer'),
|
||||
10,
|
||||
) === 1,
|
||||
'AnnotationLayer styles not found. Read more: https://github.com/wojtekmaj/react-pdf#support-for-annotations',
|
||||
);
|
||||
|
||||
function onLoadSuccess() {
|
||||
if (!annotations) {
|
||||
// Impossible, but TypeScript doesn't know that
|
||||
return;
|
||||
}
|
||||
|
||||
if (onGetAnnotationsSuccessProps) {
|
||||
onGetAnnotationsSuccessProps(annotations);
|
||||
}
|
||||
}
|
||||
|
||||
function onLoadError() {
|
||||
if (!annotationsError) {
|
||||
// Impossible, but TypeScript doesn't know that
|
||||
return;
|
||||
}
|
||||
|
||||
warning(false, annotationsError.toString());
|
||||
|
||||
if (onGetAnnotationsErrorProps) {
|
||||
onGetAnnotationsErrorProps(annotationsError);
|
||||
}
|
||||
}
|
||||
|
||||
// biome-ignore lint/correctness/useExhaustiveDependencies: useEffect intentionally triggered on page change
|
||||
useEffect(
|
||||
function resetAnnotations() {
|
||||
annotationsDispatch({ type: 'RESET' });
|
||||
},
|
||||
[annotationsDispatch, page],
|
||||
);
|
||||
|
||||
useEffect(
|
||||
function loadAnnotations() {
|
||||
if (!page) {
|
||||
return;
|
||||
}
|
||||
|
||||
const cancellable = makeCancellable(page.getAnnotations());
|
||||
const runningTask = cancellable;
|
||||
|
||||
cancellable.promise
|
||||
.then((nextAnnotations) => {
|
||||
annotationsDispatch({ type: 'RESOLVE', value: nextAnnotations });
|
||||
})
|
||||
.catch((error) => {
|
||||
annotationsDispatch({ type: 'REJECT', error });
|
||||
});
|
||||
|
||||
return () => {
|
||||
cancelRunningTask(runningTask);
|
||||
};
|
||||
},
|
||||
[annotationsDispatch, page],
|
||||
);
|
||||
|
||||
// biome-ignore lint/correctness/useExhaustiveDependencies: Ommitted callbacks so they are not called every time they change
|
||||
useEffect(() => {
|
||||
if (annotations === undefined) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (annotations === false) {
|
||||
onLoadError();
|
||||
return;
|
||||
}
|
||||
|
||||
onLoadSuccess();
|
||||
}, [annotations]);
|
||||
|
||||
function onRenderSuccess() {
|
||||
if (onRenderAnnotationLayerSuccessProps) {
|
||||
onRenderAnnotationLayerSuccessProps();
|
||||
}
|
||||
}
|
||||
|
||||
function onRenderError(error: unknown) {
|
||||
warning(false, `${error}`);
|
||||
|
||||
if (onRenderAnnotationLayerErrorProps) {
|
||||
onRenderAnnotationLayerErrorProps(error);
|
||||
}
|
||||
}
|
||||
|
||||
const viewport = useMemo(
|
||||
() => page.getViewport({ scale, rotation: rotate }),
|
||||
[page, rotate, scale],
|
||||
);
|
||||
|
||||
// biome-ignore lint/correctness/useExhaustiveDependencies: Ommitted callbacks so they are not called every time they change
|
||||
useEffect(
|
||||
function renderAnnotationLayer() {
|
||||
if (!pdf || !page || !linkService || !annotations) {
|
||||
return;
|
||||
}
|
||||
|
||||
const { current: layer } = layerElement;
|
||||
|
||||
if (!layer) {
|
||||
return;
|
||||
}
|
||||
|
||||
const clonedViewport = viewport.clone({ dontFlip: true });
|
||||
|
||||
const annotationLayerParameters = {
|
||||
accessibilityManager: null, // TODO: Implement this
|
||||
annotationCanvasMap: null, // TODO: Implement this
|
||||
annotationEditorUIManager: null, // TODO: Implement this
|
||||
div: layer,
|
||||
l10n: null, // TODO: Implement this
|
||||
page,
|
||||
structTreeLayer: null, // TODO: Implement this
|
||||
viewport: clonedViewport,
|
||||
};
|
||||
|
||||
const renderParameters = {
|
||||
annotations,
|
||||
annotationStorage: pdf.annotationStorage,
|
||||
div: layer,
|
||||
imageResourcesPath,
|
||||
linkService,
|
||||
page,
|
||||
renderForms,
|
||||
viewport: clonedViewport,
|
||||
};
|
||||
|
||||
layer.innerHTML = '';
|
||||
|
||||
try {
|
||||
new pdfjs.AnnotationLayer(annotationLayerParameters).render(renderParameters);
|
||||
|
||||
// Intentional immediate callback
|
||||
onRenderSuccess();
|
||||
} catch (error) {
|
||||
onRenderError(error);
|
||||
}
|
||||
|
||||
return () => {
|
||||
// TODO: Cancel running task?
|
||||
};
|
||||
},
|
||||
[annotations, imageResourcesPath, linkService, page, pdf, renderForms, viewport],
|
||||
);
|
||||
|
||||
return (
|
||||
<div className={clsx('react-pdf__Page__annotations', 'annotationLayer')} ref={layerElement} />
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
module.exports={C:{"135":0.0452,"136":1.9888,_:"2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 137 138 139 140 3.5 3.6"},D:{"46":0.0452,"53":0.0452,"72":0.1808,"83":0.226,"120":0.0452,"131":0.226,"132":0.452,"133":1.4464,"134":12.7916,_:"4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 47 48 49 50 51 52 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 73 74 75 76 77 78 79 80 81 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 121 122 123 124 125 126 127 128 129 130 135 136 137 138"},F:{"117":0.0904,_:"9 11 12 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 60 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 9.5-9.6 10.0-10.1 10.5 10.6 11.1 11.5 11.6 12.1"},B:{"131":0.1808,"133":0.0904,"134":2.8024,_:"12 13 14 15 16 17 18 79 80 81 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 132"},E:{_:"0 4 5 6 7 8 9 10 11 12 13 14 15 3.1 3.2 5.1 6.1 7.1 9.1 10.1 11.1 12.1 13.1 14.1 15.1 15.2-15.3 15.5 15.6 16.0 16.1 16.2 16.3 16.4 16.5 16.6 17.0 17.2 17.3 17.4 17.5 17.6 18.1 18.2 18.4","15.4":0.0452,"17.1":0.0452,"18.0":0.0904,"18.3":0.2712},G:{"8":0,"3.2":0,"4.0-4.1":0,"4.2-4.3":0.00057,"5.0-5.1":0,"6.0-6.1":0.00171,"7.0-7.1":0.00114,"8.1-8.4":0,"9.0-9.2":0.00085,"9.3":0.00399,"10.0-10.2":0.00028,"10.3":0.00655,"11.0-11.2":0.03019,"11.3-11.4":0.00199,"12.0-12.1":0.00114,"12.2-12.5":0.02819,"13.0-13.1":0.00057,"13.2":0.00085,"13.3":0.00114,"13.4-13.7":0.00399,"14.0-14.4":0.00997,"14.5-14.8":0.01196,"15.0-15.1":0.00655,"15.2-15.3":0.00655,"15.4":0.00797,"15.5":0.00911,"15.6-15.8":0.11221,"16.0":0.01595,"16.1":0.03275,"16.2":0.01709,"16.3":0.02962,"16.4":0.00655,"16.5":0.01225,"16.6-16.7":0.133,"17.0":0.00797,"17.1":0.01424,"17.2":0.01082,"17.3":0.01509,"17.4":0.03019,"17.5":0.06721,"17.6-17.7":0.19508,"18.0":0.05468,"18.1":0.17885,"18.2":0.08003,"18.3":1.6726,"18.4":0.02478},P:{"21":0.69794,"27":0.60556,_:"4 20 22 23 24 25 26 5.0-5.4 6.2-6.4 7.2-7.4 8.2 9.2 10.1 11.1-11.2 12.0 14.0 15.0 16.0 17.0 18.0 19.0","13.0":0.14369},I:{"0":0.13901,"3":0,"4":0,"2.1":0,"2.2":0,"2.3":0,"4.1":0,"4.2-4.3":0.00004,"4.4":0,"4.4.3-4.4.4":0.00015},K:{"0":0.09287,_:"10 11 12 11.1 11.5 12.1"},A:{_:"6 7 8 9 10 11 5.5"},S:{_:"2.5 3.0-3.1"},J:{_:"7 10"},N:{_:"10 11"},R:{_:"0"},M:{_:"0"},Q:{_:"14.9"},O:{_:"0"},H:{"0":0},L:{"0":73.75524}};
|
||||
@@ -0,0 +1,18 @@
|
||||
/* eslint-disable @typescript-eslint/ban-ts-comment */
|
||||
|
||||
// @ts-ignore `lightningcss` may not be installed
|
||||
import type Lightningcss from 'lightningcss'
|
||||
|
||||
/* eslint-enable @typescript-eslint/ban-ts-comment */
|
||||
|
||||
export type LightningCSSOptions = Omit<
|
||||
Lightningcss.BundleAsyncOptions<Lightningcss.CustomAtRules>,
|
||||
| 'filename'
|
||||
| 'resolver'
|
||||
| 'minify'
|
||||
| 'sourceMap'
|
||||
| 'analyzeDependencies'
|
||||
// properties not overridden by Vite, but does not make sense to set by end users
|
||||
| 'inputSourceMap'
|
||||
| 'projectRoot'
|
||||
>
|
||||
@@ -0,0 +1,32 @@
|
||||
/**
|
||||
* These are types for things that are present in the upcoming React 18 release.
|
||||
*
|
||||
* Once React 18 is released they can just be moved to the main index file.
|
||||
*
|
||||
* To load the types declared here in an actual project, there are three ways. The easiest one,
|
||||
* if your `tsconfig.json` already has a `"types"` array in the `"compilerOptions"` section,
|
||||
* is to add `"react-dom/canary"` to the `"types"` array.
|
||||
*
|
||||
* Alternatively, a specific import syntax can to be used from a typescript file.
|
||||
* This module does not exist in reality, which is why the {} is important:
|
||||
*
|
||||
* ```ts
|
||||
* import {} from 'react-dom/canary'
|
||||
* ```
|
||||
*
|
||||
* It is also possible to include it through a triple-slash reference:
|
||||
*
|
||||
* ```ts
|
||||
* /// <reference types="react-dom/canary" />
|
||||
* ```
|
||||
*
|
||||
* Either the import or the reference only needs to appear once, anywhere in the project.
|
||||
*/
|
||||
|
||||
// See https://github.com/facebook/react/blob/main/packages/react-dom/index.js to see how the exports are declared,
|
||||
// but confirm with published source code (e.g. https://unpkg.com/react-dom@canary) that these exports end up in the published code
|
||||
|
||||
import React = require("react");
|
||||
import ReactDOM = require(".");
|
||||
|
||||
export {};
|
||||
@@ -0,0 +1,59 @@
|
||||
'use strict';
|
||||
|
||||
|
||||
function isNothing(subject) {
|
||||
return (typeof subject === 'undefined') || (subject === null);
|
||||
}
|
||||
|
||||
|
||||
function isObject(subject) {
|
||||
return (typeof subject === 'object') && (subject !== null);
|
||||
}
|
||||
|
||||
|
||||
function toArray(sequence) {
|
||||
if (Array.isArray(sequence)) return sequence;
|
||||
else if (isNothing(sequence)) return [];
|
||||
|
||||
return [ sequence ];
|
||||
}
|
||||
|
||||
|
||||
function extend(target, source) {
|
||||
var index, length, key, sourceKeys;
|
||||
|
||||
if (source) {
|
||||
sourceKeys = Object.keys(source);
|
||||
|
||||
for (index = 0, length = sourceKeys.length; index < length; index += 1) {
|
||||
key = sourceKeys[index];
|
||||
target[key] = source[key];
|
||||
}
|
||||
}
|
||||
|
||||
return target;
|
||||
}
|
||||
|
||||
|
||||
function repeat(string, count) {
|
||||
var result = '', cycle;
|
||||
|
||||
for (cycle = 0; cycle < count; cycle += 1) {
|
||||
result += string;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
function isNegativeZero(number) {
|
||||
return (number === 0) && (Number.NEGATIVE_INFINITY === 1 / number);
|
||||
}
|
||||
|
||||
|
||||
module.exports.isNothing = isNothing;
|
||||
module.exports.isObject = isObject;
|
||||
module.exports.toArray = toArray;
|
||||
module.exports.repeat = repeat;
|
||||
module.exports.isNegativeZero = isNegativeZero;
|
||||
module.exports.extend = extend;
|
||||
@@ -0,0 +1,75 @@
|
||||
{
|
||||
"name": "minimist",
|
||||
"version": "1.2.8",
|
||||
"description": "parse argument options",
|
||||
"main": "index.js",
|
||||
"devDependencies": {
|
||||
"@ljharb/eslint-config": "^21.0.1",
|
||||
"aud": "^2.0.2",
|
||||
"auto-changelog": "^2.4.0",
|
||||
"eslint": "=8.8.0",
|
||||
"in-publish": "^2.0.1",
|
||||
"npmignore": "^0.3.0",
|
||||
"nyc": "^10.3.2",
|
||||
"safe-publish-latest": "^2.0.0",
|
||||
"tape": "^5.6.3"
|
||||
},
|
||||
"scripts": {
|
||||
"prepack": "npmignore --auto --commentLines=auto",
|
||||
"prepublishOnly": "safe-publish-latest",
|
||||
"prepublish": "not-in-publish || npm run prepublishOnly",
|
||||
"lint": "eslint --ext=js,mjs .",
|
||||
"pretest": "npm run lint",
|
||||
"tests-only": "nyc tape 'test/**/*.js'",
|
||||
"test": "npm run tests-only",
|
||||
"posttest": "aud --production",
|
||||
"version": "auto-changelog && git add CHANGELOG.md",
|
||||
"postversion": "auto-changelog && git add CHANGELOG.md && git commit --no-edit --amend && git tag -f \"v$(node -e \"console.log(require('./package.json').version)\")\""
|
||||
},
|
||||
"testling": {
|
||||
"files": "test/*.js",
|
||||
"browsers": [
|
||||
"ie/6..latest",
|
||||
"ff/5",
|
||||
"firefox/latest",
|
||||
"chrome/10",
|
||||
"chrome/latest",
|
||||
"safari/5.1",
|
||||
"safari/latest",
|
||||
"opera/12"
|
||||
]
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/minimistjs/minimist.git"
|
||||
},
|
||||
"homepage": "https://github.com/minimistjs/minimist",
|
||||
"keywords": [
|
||||
"argv",
|
||||
"getopt",
|
||||
"parser",
|
||||
"optimist"
|
||||
],
|
||||
"author": {
|
||||
"name": "James Halliday",
|
||||
"email": "mail@substack.net",
|
||||
"url": "http://substack.net"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
},
|
||||
"license": "MIT",
|
||||
"auto-changelog": {
|
||||
"output": "CHANGELOG.md",
|
||||
"template": "keepachangelog",
|
||||
"unreleased": false,
|
||||
"commitLimit": false,
|
||||
"backfillLimit": false,
|
||||
"hideCredit": true
|
||||
},
|
||||
"publishConfig": {
|
||||
"ignore": [
|
||||
".github/workflows"
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
export default function StructTree(): React.ReactElement | null;
|
||||
@@ -0,0 +1,31 @@
|
||||
// duplicated from transform-file so we do not have to import anything here
|
||||
type TransformFile = {
|
||||
(filename: string, callback: (error: Error, file: null) => void): void;
|
||||
(
|
||||
filename: string,
|
||||
opts: any,
|
||||
callback: (error: Error, file: null) => void,
|
||||
): void;
|
||||
};
|
||||
|
||||
export const transformFile: TransformFile = function transformFile(
|
||||
filename,
|
||||
opts,
|
||||
callback?: (error: Error, file: null) => void,
|
||||
) {
|
||||
if (typeof opts === "function") {
|
||||
callback = opts;
|
||||
}
|
||||
|
||||
callback(new Error("Transforming files is not supported in browsers"), null);
|
||||
};
|
||||
|
||||
export function transformFileSync(): never {
|
||||
throw new Error("Transforming files is not supported in browsers");
|
||||
}
|
||||
|
||||
export function transformFileAsync() {
|
||||
return Promise.reject(
|
||||
new Error("Transforming files is not supported in browsers"),
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,227 @@
|
||||
# rc
|
||||
|
||||
The non-configurable configuration loader for lazy people.
|
||||
|
||||
## Usage
|
||||
|
||||
The only option is to pass rc the name of your app, and your default configuration.
|
||||
|
||||
```javascript
|
||||
var conf = require('rc')(appname, {
|
||||
//defaults go here.
|
||||
port: 2468,
|
||||
|
||||
//defaults which are objects will be merged, not replaced
|
||||
views: {
|
||||
engine: 'jade'
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
`rc` will return your configuration options merged with the defaults you specify.
|
||||
If you pass in a predefined defaults object, it will be mutated:
|
||||
|
||||
```javascript
|
||||
var conf = {};
|
||||
require('rc')(appname, conf);
|
||||
```
|
||||
|
||||
If `rc` finds any config files for your app, the returned config object will have
|
||||
a `configs` array containing their paths:
|
||||
|
||||
```javascript
|
||||
var appCfg = require('rc')(appname, conf);
|
||||
appCfg.configs[0] // /etc/appnamerc
|
||||
appCfg.configs[1] // /home/dominictarr/.config/appname
|
||||
appCfg.config // same as appCfg.configs[appCfg.configs.length - 1]
|
||||
```
|
||||
|
||||
## Standards
|
||||
|
||||
Given your application name (`appname`), rc will look in all the obvious places for configuration.
|
||||
|
||||
* command line arguments, parsed by minimist _(e.g. `--foo baz`, also nested: `--foo.bar=baz`)_
|
||||
* environment variables prefixed with `${appname}_`
|
||||
* or use "\_\_" to indicate nested properties <br/> _(e.g. `appname_foo__bar__baz` => `foo.bar.baz`)_
|
||||
* if you passed an option `--config file` then from that file
|
||||
* a local `.${appname}rc` or the first found looking in `./ ../ ../../ ../../../` etc.
|
||||
* `$HOME/.${appname}rc`
|
||||
* `$HOME/.${appname}/config`
|
||||
* `$HOME/.config/${appname}`
|
||||
* `$HOME/.config/${appname}/config`
|
||||
* `/etc/${appname}rc`
|
||||
* `/etc/${appname}/config`
|
||||
* the defaults object you passed in.
|
||||
|
||||
All configuration sources that were found will be flattened into one object,
|
||||
so that sources **earlier** in this list override later ones.
|
||||
|
||||
|
||||
## Configuration File Formats
|
||||
|
||||
Configuration files (e.g. `.appnamerc`) may be in either [json](http://json.org/example) or [ini](http://en.wikipedia.org/wiki/INI_file) format. **No** file extension (`.json` or `.ini`) should be used. The example configurations below are equivalent:
|
||||
|
||||
|
||||
#### Formatted as `ini`
|
||||
|
||||
```
|
||||
; You can include comments in `ini` format if you want.
|
||||
|
||||
dependsOn=0.10.0
|
||||
|
||||
|
||||
; `rc` has built-in support for ini sections, see?
|
||||
|
||||
[commands]
|
||||
www = ./commands/www
|
||||
console = ./commands/repl
|
||||
|
||||
|
||||
; You can even do nested sections
|
||||
|
||||
[generators.options]
|
||||
engine = ejs
|
||||
|
||||
[generators.modules]
|
||||
new = generate-new
|
||||
engine = generate-backend
|
||||
|
||||
```
|
||||
|
||||
#### Formatted as `json`
|
||||
|
||||
```javascript
|
||||
{
|
||||
// You can even comment your JSON, if you want
|
||||
"dependsOn": "0.10.0",
|
||||
"commands": {
|
||||
"www": "./commands/www",
|
||||
"console": "./commands/repl"
|
||||
},
|
||||
"generators": {
|
||||
"options": {
|
||||
"engine": "ejs"
|
||||
},
|
||||
"modules": {
|
||||
"new": "generate-new",
|
||||
"backend": "generate-backend"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Comments are stripped from JSON config via [strip-json-comments](https://github.com/sindresorhus/strip-json-comments).
|
||||
|
||||
> Since ini, and env variables do not have a standard for types, your application needs be prepared for strings.
|
||||
|
||||
To ensure that string representations of booleans and numbers are always converted into their proper types (especially useful if you intend to do strict `===` comparisons), consider using a module such as [parse-strings-in-object](https://github.com/anselanza/parse-strings-in-object) to wrap the config object returned from rc.
|
||||
|
||||
|
||||
## Simple example demonstrating precedence
|
||||
Assume you have an application like this (notice the hard-coded defaults passed to rc):
|
||||
```
|
||||
const conf = require('rc')('myapp', {
|
||||
port: 12345,
|
||||
mode: 'test'
|
||||
});
|
||||
|
||||
console.log(JSON.stringify(conf, null, 2));
|
||||
```
|
||||
You also have a file `config.json`, with these contents:
|
||||
```
|
||||
{
|
||||
"port": 9000,
|
||||
"foo": "from config json",
|
||||
"something": "else"
|
||||
}
|
||||
```
|
||||
And a file `.myapprc` in the same folder, with these contents:
|
||||
```
|
||||
{
|
||||
"port": "3001",
|
||||
"foo": "bar"
|
||||
}
|
||||
```
|
||||
Here is the expected output from various commands:
|
||||
|
||||
`node .`
|
||||
```
|
||||
{
|
||||
"port": "3001",
|
||||
"mode": "test",
|
||||
"foo": "bar",
|
||||
"_": [],
|
||||
"configs": [
|
||||
"/Users/stephen/repos/conftest/.myapprc"
|
||||
],
|
||||
"config": "/Users/stephen/repos/conftest/.myapprc"
|
||||
}
|
||||
```
|
||||
*Default `mode` from hard-coded object is retained, but port is overridden by `.myapprc` file (automatically found based on appname match), and `foo` is added.*
|
||||
|
||||
|
||||
`node . --foo baz`
|
||||
```
|
||||
{
|
||||
"port": "3001",
|
||||
"mode": "test",
|
||||
"foo": "baz",
|
||||
"_": [],
|
||||
"configs": [
|
||||
"/Users/stephen/repos/conftest/.myapprc"
|
||||
],
|
||||
"config": "/Users/stephen/repos/conftest/.myapprc"
|
||||
}
|
||||
```
|
||||
*Same result as above but `foo` is overridden because command-line arguments take precedence over `.myapprc` file.*
|
||||
|
||||
`node . --foo barbar --config config.json`
|
||||
```
|
||||
{
|
||||
"port": 9000,
|
||||
"mode": "test",
|
||||
"foo": "barbar",
|
||||
"something": "else",
|
||||
"_": [],
|
||||
"config": "config.json",
|
||||
"configs": [
|
||||
"/Users/stephen/repos/conftest/.myapprc",
|
||||
"config.json"
|
||||
]
|
||||
}
|
||||
```
|
||||
*Now the `port` comes from the `config.json` file specified (overriding the value from `.myapprc`), and `foo` value is overriden by command-line despite also being specified in the `config.json` file.*
|
||||
|
||||
|
||||
|
||||
## Advanced Usage
|
||||
|
||||
#### Pass in your own `argv`
|
||||
|
||||
You may pass in your own `argv` as the third argument to `rc`. This is in case you want to [use your own command-line opts parser](https://github.com/dominictarr/rc/pull/12).
|
||||
|
||||
```javascript
|
||||
require('rc')(appname, defaults, customArgvParser);
|
||||
```
|
||||
|
||||
## Pass in your own parser
|
||||
|
||||
If you have a special need to use a non-standard parser,
|
||||
you can do so by passing in the parser as the 4th argument.
|
||||
(leave the 3rd as null to get the default args parser)
|
||||
|
||||
```javascript
|
||||
require('rc')(appname, defaults, null, parser);
|
||||
```
|
||||
|
||||
This may also be used to force a more strict format,
|
||||
such as strict, valid JSON only.
|
||||
|
||||
## Note on Performance
|
||||
|
||||
`rc` is running `fs.statSync`-- so make sure you don't use it in a hot code path (e.g. a request handler)
|
||||
|
||||
|
||||
## License
|
||||
|
||||
Multi-licensed under the two-clause BSD License, MIT License, or Apache License, version 2.0
|
||||
@@ -0,0 +1,24 @@
|
||||
export type Manifest = {
|
||||
routes: Record<string, {
|
||||
filePath?: string;
|
||||
preloads?: Array<string>;
|
||||
assets?: Array<RouterManagedTag>;
|
||||
}>;
|
||||
};
|
||||
export type RouterManagedTag = {
|
||||
tag: 'title';
|
||||
attrs?: Record<string, any>;
|
||||
children: string;
|
||||
} | {
|
||||
tag: 'meta' | 'link';
|
||||
attrs?: Record<string, any>;
|
||||
children?: never;
|
||||
} | {
|
||||
tag: 'script';
|
||||
attrs?: Record<string, any>;
|
||||
children?: string;
|
||||
} | {
|
||||
tag: 'style';
|
||||
attrs?: Record<string, any>;
|
||||
children?: string;
|
||||
};
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1 @@
|
||||
module.exports={A:{A:{"1":"A B","2":"K D E F mC"},B:{"1":"0 9 C L M G 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"},C:{"1":"0 9 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","2":"nC LC J PB K D E F A B C L M G N qC rC","4":"1 2 3 4 5 6 7 8 O P QB"},D:{"1":"0 1 2 3 4 5 6 7 8 9 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 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":"J"},E:{"1":"PB K D E F A B C L M G 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","2":"J sC SC"},F:{"1":"0 1 2 3 4 5 6 7 8 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 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":"F B C 4C 5C 6C 7C FC kC 8C GC"},G:{"1":"E 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","2":"SC"},H:{"2":"WD"},I:{"1":"LC J I YD ZD aD lC bD cD","2":"XD"},J:{"1":"D A"},K:{"1":"H","2":"A B C FC kC GC"},L:{"1":"I"},M:{"1":"EC"},N:{"1":"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:"sandbox attribute for iframes",D:true};
|
||||
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
MIT License http://www.opensource.org/licenses/mit-license.php
|
||||
Author Tobias Koppers @sokra
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
/** @typedef {import("./Resolver")} Resolver */
|
||||
/** @typedef {import("./Resolver").ResolveRequest} ResolveRequest */
|
||||
/** @typedef {import("./Resolver").ResolveStepHook} ResolveStepHook */
|
||||
|
||||
module.exports = class AppendPlugin {
|
||||
/**
|
||||
* @param {string | ResolveStepHook} source source
|
||||
* @param {string} appending appending
|
||||
* @param {string | ResolveStepHook} target target
|
||||
*/
|
||||
constructor(source, appending, target) {
|
||||
this.source = source;
|
||||
this.appending = appending;
|
||||
this.target = target;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Resolver} resolver the resolver
|
||||
* @returns {void}
|
||||
*/
|
||||
apply(resolver) {
|
||||
const target = resolver.ensureHook(this.target);
|
||||
resolver
|
||||
.getHook(this.source)
|
||||
.tapAsync("AppendPlugin", (request, resolveContext, callback) => {
|
||||
/** @type {ResolveRequest} */
|
||||
const obj = {
|
||||
...request,
|
||||
path: request.path + this.appending,
|
||||
relativePath:
|
||||
request.relativePath && request.relativePath + this.appending
|
||||
};
|
||||
resolver.doResolve(
|
||||
target,
|
||||
obj,
|
||||
this.appending,
|
||||
resolveContext,
|
||||
callback
|
||||
);
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,229 @@
|
||||
/**
|
||||
* @fileoverview Rule to flag numbers that will lose significant figure precision at runtime
|
||||
* @author Jacob Moore
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Rule Definition
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/** @type {import('../shared/types').Rule} */
|
||||
module.exports = {
|
||||
meta: {
|
||||
type: "problem",
|
||||
|
||||
docs: {
|
||||
description: "Disallow literal numbers that lose precision",
|
||||
recommended: true,
|
||||
url: "https://eslint.org/docs/latest/rules/no-loss-of-precision",
|
||||
},
|
||||
schema: [],
|
||||
messages: {
|
||||
noLossOfPrecision:
|
||||
"This number literal will lose precision at runtime.",
|
||||
},
|
||||
},
|
||||
|
||||
create(context) {
|
||||
/**
|
||||
* Returns whether the node is number literal
|
||||
* @param {Node} node the node literal being evaluated
|
||||
* @returns {boolean} true if the node is a number literal
|
||||
*/
|
||||
function isNumber(node) {
|
||||
return typeof node.value === "number";
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the source code of the given number literal. Removes `_` numeric separators from the result.
|
||||
* @param {Node} node the number `Literal` node
|
||||
* @returns {string} raw source code of the literal, without numeric separators
|
||||
*/
|
||||
function getRaw(node) {
|
||||
return node.raw.replace(/_/gu, "");
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether the number is base ten
|
||||
* @param {ASTNode} node the node being evaluated
|
||||
* @returns {boolean} true if the node is in base ten
|
||||
*/
|
||||
function isBaseTen(node) {
|
||||
const prefixes = ["0x", "0X", "0b", "0B", "0o", "0O"];
|
||||
|
||||
return (
|
||||
prefixes.every(prefix => !node.raw.startsWith(prefix)) &&
|
||||
!/^0[0-7]+$/u.test(node.raw)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks that the user-intended non-base ten number equals the actual number after is has been converted to the Number type
|
||||
* @param {Node} node the node being evaluated
|
||||
* @returns {boolean} true if they do not match
|
||||
*/
|
||||
function notBaseTenLosesPrecision(node) {
|
||||
const rawString = getRaw(node).toUpperCase();
|
||||
let base;
|
||||
|
||||
if (rawString.startsWith("0B")) {
|
||||
base = 2;
|
||||
} else if (rawString.startsWith("0X")) {
|
||||
base = 16;
|
||||
} else {
|
||||
base = 8;
|
||||
}
|
||||
|
||||
return !rawString.endsWith(node.value.toString(base).toUpperCase());
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a decimal point to the numeric string at index 1
|
||||
* @param {string} stringNumber the numeric string without any decimal point
|
||||
* @returns {string} the numeric string with a decimal point in the proper place
|
||||
*/
|
||||
function addDecimalPointToNumber(stringNumber) {
|
||||
return `${stringNumber[0]}.${stringNumber.slice(1)}`;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number stripped of leading zeros
|
||||
* @param {string} numberAsString the string representation of the number
|
||||
* @returns {string} the stripped string
|
||||
*/
|
||||
function removeLeadingZeros(numberAsString) {
|
||||
for (let i = 0; i < numberAsString.length; i++) {
|
||||
if (numberAsString[i] !== "0") {
|
||||
return numberAsString.slice(i);
|
||||
}
|
||||
}
|
||||
return numberAsString;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number stripped of trailing zeros
|
||||
* @param {string} numberAsString the string representation of the number
|
||||
* @returns {string} the stripped string
|
||||
*/
|
||||
function removeTrailingZeros(numberAsString) {
|
||||
for (let i = numberAsString.length - 1; i >= 0; i--) {
|
||||
if (numberAsString[i] !== "0") {
|
||||
return numberAsString.slice(0, i + 1);
|
||||
}
|
||||
}
|
||||
return numberAsString;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts an integer to an object containing the integer's coefficient and order of magnitude
|
||||
* @param {string} stringInteger the string representation of the integer being converted
|
||||
* @returns {Object} the object containing the integer's coefficient and order of magnitude
|
||||
*/
|
||||
function normalizeInteger(stringInteger) {
|
||||
const significantDigits = removeTrailingZeros(
|
||||
removeLeadingZeros(stringInteger),
|
||||
);
|
||||
|
||||
return {
|
||||
magnitude: stringInteger.startsWith("0")
|
||||
? stringInteger.length - 2
|
||||
: stringInteger.length - 1,
|
||||
coefficient: addDecimalPointToNumber(significantDigits),
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Converts a float to an object containing the floats's coefficient and order of magnitude
|
||||
* @param {string} stringFloat the string representation of the float being converted
|
||||
* @returns {Object} the object containing the integer's coefficient and order of magnitude
|
||||
*/
|
||||
function normalizeFloat(stringFloat) {
|
||||
const trimmedFloat = removeLeadingZeros(stringFloat);
|
||||
|
||||
if (trimmedFloat.startsWith(".")) {
|
||||
const decimalDigits = trimmedFloat.slice(1);
|
||||
const significantDigits = removeLeadingZeros(decimalDigits);
|
||||
|
||||
return {
|
||||
magnitude:
|
||||
significantDigits.length - decimalDigits.length - 1,
|
||||
coefficient: addDecimalPointToNumber(significantDigits),
|
||||
};
|
||||
}
|
||||
return {
|
||||
magnitude: trimmedFloat.indexOf(".") - 1,
|
||||
coefficient: addDecimalPointToNumber(
|
||||
trimmedFloat.replace(".", ""),
|
||||
),
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a base ten number to proper scientific notation
|
||||
* @param {string} stringNumber the string representation of the base ten number to be converted
|
||||
* @returns {string} the number converted to scientific notation
|
||||
*/
|
||||
function convertNumberToScientificNotation(stringNumber) {
|
||||
const splitNumber = stringNumber.replace("E", "e").split("e");
|
||||
const originalCoefficient = splitNumber[0];
|
||||
const normalizedNumber = stringNumber.includes(".")
|
||||
? normalizeFloat(originalCoefficient)
|
||||
: normalizeInteger(originalCoefficient);
|
||||
const normalizedCoefficient = normalizedNumber.coefficient;
|
||||
const magnitude =
|
||||
splitNumber.length > 1
|
||||
? parseInt(splitNumber[1], 10) + normalizedNumber.magnitude
|
||||
: normalizedNumber.magnitude;
|
||||
|
||||
return `${normalizedCoefficient}e${magnitude}`;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks that the user-intended base ten number equals the actual number after is has been converted to the Number type
|
||||
* @param {Node} node the node being evaluated
|
||||
* @returns {boolean} true if they do not match
|
||||
*/
|
||||
function baseTenLosesPrecision(node) {
|
||||
const normalizedRawNumber = convertNumberToScientificNotation(
|
||||
getRaw(node),
|
||||
);
|
||||
const requestedPrecision = normalizedRawNumber
|
||||
.split("e")[0]
|
||||
.replace(".", "").length;
|
||||
|
||||
if (requestedPrecision > 100) {
|
||||
return true;
|
||||
}
|
||||
const storedNumber = node.value.toPrecision(requestedPrecision);
|
||||
const normalizedStoredNumber =
|
||||
convertNumberToScientificNotation(storedNumber);
|
||||
|
||||
return normalizedRawNumber !== normalizedStoredNumber;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks that the user-intended number equals the actual number after is has been converted to the Number type
|
||||
* @param {Node} node the node being evaluated
|
||||
* @returns {boolean} true if they do not match
|
||||
*/
|
||||
function losesPrecision(node) {
|
||||
return isBaseTen(node)
|
||||
? baseTenLosesPrecision(node)
|
||||
: notBaseTenLosesPrecision(node);
|
||||
}
|
||||
|
||||
return {
|
||||
Literal(node) {
|
||||
if (node.value && isNumber(node) && losesPrecision(node)) {
|
||||
context.report({
|
||||
messageId: "noLossOfPrecision",
|
||||
node,
|
||||
});
|
||||
}
|
||||
},
|
||||
};
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2014 Jameson Little
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
@@ -0,0 +1,406 @@
|
||||
/**
|
||||
* @license React
|
||||
* scheduler-unstable_mock.production.js
|
||||
*
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
function push(heap, node) {
|
||||
var index = heap.length;
|
||||
heap.push(node);
|
||||
a: for (; 0 < index; ) {
|
||||
var parentIndex = (index - 1) >>> 1,
|
||||
parent = heap[parentIndex];
|
||||
if (0 < compare(parent, node))
|
||||
(heap[parentIndex] = node), (heap[index] = parent), (index = parentIndex);
|
||||
else break a;
|
||||
}
|
||||
}
|
||||
function peek(heap) {
|
||||
return 0 === heap.length ? null : heap[0];
|
||||
}
|
||||
function pop(heap) {
|
||||
if (0 === heap.length) return null;
|
||||
var first = heap[0],
|
||||
last = heap.pop();
|
||||
if (last !== first) {
|
||||
heap[0] = last;
|
||||
a: for (
|
||||
var index = 0, length = heap.length, halfLength = length >>> 1;
|
||||
index < halfLength;
|
||||
|
||||
) {
|
||||
var leftIndex = 2 * (index + 1) - 1,
|
||||
left = heap[leftIndex],
|
||||
rightIndex = leftIndex + 1,
|
||||
right = heap[rightIndex];
|
||||
if (0 > compare(left, last))
|
||||
rightIndex < length && 0 > compare(right, left)
|
||||
? ((heap[index] = right),
|
||||
(heap[rightIndex] = last),
|
||||
(index = rightIndex))
|
||||
: ((heap[index] = left),
|
||||
(heap[leftIndex] = last),
|
||||
(index = leftIndex));
|
||||
else if (rightIndex < length && 0 > compare(right, last))
|
||||
(heap[index] = right), (heap[rightIndex] = last), (index = rightIndex);
|
||||
else break a;
|
||||
}
|
||||
}
|
||||
return first;
|
||||
}
|
||||
function compare(a, b) {
|
||||
var diff = a.sortIndex - b.sortIndex;
|
||||
return 0 !== diff ? diff : a.id - b.id;
|
||||
}
|
||||
var taskQueue = [],
|
||||
timerQueue = [],
|
||||
taskIdCounter = 1,
|
||||
currentTask = null,
|
||||
currentPriorityLevel = 3,
|
||||
isPerformingWork = !1,
|
||||
isHostCallbackScheduled = !1,
|
||||
isHostTimeoutScheduled = !1,
|
||||
currentMockTime = 0,
|
||||
scheduledCallback = null,
|
||||
scheduledTimeout = null,
|
||||
timeoutTime = -1,
|
||||
yieldedValues = null,
|
||||
expectedNumberOfYields = -1,
|
||||
didStop = !1,
|
||||
isFlushing = !1,
|
||||
needsPaint = !1,
|
||||
shouldYieldForPaint = !1,
|
||||
disableYieldValue = !1;
|
||||
function advanceTimers(currentTime) {
|
||||
for (var timer = peek(timerQueue); null !== timer; ) {
|
||||
if (null === timer.callback) pop(timerQueue);
|
||||
else if (timer.startTime <= currentTime)
|
||||
pop(timerQueue),
|
||||
(timer.sortIndex = timer.expirationTime),
|
||||
push(taskQueue, timer);
|
||||
else break;
|
||||
timer = peek(timerQueue);
|
||||
}
|
||||
}
|
||||
function handleTimeout(currentTime) {
|
||||
isHostTimeoutScheduled = !1;
|
||||
advanceTimers(currentTime);
|
||||
if (!isHostCallbackScheduled)
|
||||
if (null !== peek(taskQueue))
|
||||
(isHostCallbackScheduled = !0), (scheduledCallback = flushWork);
|
||||
else {
|
||||
var firstTimer = peek(timerQueue);
|
||||
null !== firstTimer &&
|
||||
((currentTime = firstTimer.startTime - currentTime),
|
||||
(scheduledTimeout = handleTimeout),
|
||||
(timeoutTime = currentMockTime + currentTime));
|
||||
}
|
||||
}
|
||||
function flushWork(hasTimeRemaining, initialTime) {
|
||||
isHostCallbackScheduled = !1;
|
||||
isHostTimeoutScheduled &&
|
||||
((isHostTimeoutScheduled = !1),
|
||||
(scheduledTimeout = null),
|
||||
(timeoutTime = -1));
|
||||
isPerformingWork = !0;
|
||||
var previousPriorityLevel = currentPriorityLevel;
|
||||
try {
|
||||
a: {
|
||||
advanceTimers(initialTime);
|
||||
for (
|
||||
currentTask = peek(taskQueue);
|
||||
null !== currentTask &&
|
||||
(!(currentTask.expirationTime > initialTime) ||
|
||||
(hasTimeRemaining && !shouldYieldToHost()));
|
||||
|
||||
) {
|
||||
var callback = currentTask.callback;
|
||||
if ("function" === typeof callback) {
|
||||
currentTask.callback = null;
|
||||
currentPriorityLevel = currentTask.priorityLevel;
|
||||
var continuationCallback = callback(
|
||||
currentTask.expirationTime <= initialTime
|
||||
);
|
||||
initialTime = currentMockTime;
|
||||
if ("function" === typeof continuationCallback) {
|
||||
if (
|
||||
((currentTask.callback = continuationCallback),
|
||||
advanceTimers(initialTime),
|
||||
shouldYieldForPaint)
|
||||
) {
|
||||
var JSCompiler_inline_result = (needsPaint = !0);
|
||||
break a;
|
||||
}
|
||||
} else
|
||||
currentTask === peek(taskQueue) && pop(taskQueue),
|
||||
advanceTimers(initialTime);
|
||||
} else pop(taskQueue);
|
||||
currentTask = peek(taskQueue);
|
||||
}
|
||||
if (null !== currentTask) JSCompiler_inline_result = !0;
|
||||
else {
|
||||
var firstTimer = peek(timerQueue);
|
||||
if (null !== firstTimer) {
|
||||
var ms = firstTimer.startTime - initialTime;
|
||||
scheduledTimeout = handleTimeout;
|
||||
timeoutTime = currentMockTime + ms;
|
||||
}
|
||||
JSCompiler_inline_result = !1;
|
||||
}
|
||||
}
|
||||
return JSCompiler_inline_result;
|
||||
} finally {
|
||||
(currentTask = null),
|
||||
(currentPriorityLevel = previousPriorityLevel),
|
||||
(isPerformingWork = !1);
|
||||
}
|
||||
}
|
||||
function shouldYieldToHost() {
|
||||
return (0 === expectedNumberOfYields && null === yieldedValues) ||
|
||||
(-1 !== expectedNumberOfYields &&
|
||||
null !== yieldedValues &&
|
||||
yieldedValues.length >= expectedNumberOfYields) ||
|
||||
(shouldYieldForPaint && needsPaint)
|
||||
? (didStop = !0)
|
||||
: !1;
|
||||
}
|
||||
function unstable_flushAllWithoutAsserting() {
|
||||
if (isFlushing) throw Error("Already flushing work.");
|
||||
if (null !== scheduledCallback) {
|
||||
var cb = scheduledCallback;
|
||||
isFlushing = !0;
|
||||
try {
|
||||
var hasMoreWork = !0;
|
||||
do hasMoreWork = cb(!0, currentMockTime);
|
||||
while (hasMoreWork);
|
||||
hasMoreWork || (scheduledCallback = null);
|
||||
return !0;
|
||||
} finally {
|
||||
isFlushing = !1;
|
||||
}
|
||||
} else return !1;
|
||||
}
|
||||
exports.log = function (value) {
|
||||
"disabledLog" === console.log.name ||
|
||||
disableYieldValue ||
|
||||
(null === yieldedValues
|
||||
? (yieldedValues = [value])
|
||||
: yieldedValues.push(value));
|
||||
};
|
||||
exports.reset = function () {
|
||||
if (isFlushing) throw Error("Cannot reset while already flushing work.");
|
||||
currentMockTime = 0;
|
||||
scheduledTimeout = scheduledCallback = null;
|
||||
timeoutTime = -1;
|
||||
yieldedValues = null;
|
||||
expectedNumberOfYields = -1;
|
||||
needsPaint = isFlushing = didStop = !1;
|
||||
};
|
||||
exports.unstable_IdlePriority = 5;
|
||||
exports.unstable_ImmediatePriority = 1;
|
||||
exports.unstable_LowPriority = 4;
|
||||
exports.unstable_NormalPriority = 3;
|
||||
exports.unstable_Profiling = null;
|
||||
exports.unstable_UserBlockingPriority = 2;
|
||||
exports.unstable_advanceTime = function (ms) {
|
||||
"disabledLog" === console.log.name ||
|
||||
disableYieldValue ||
|
||||
((currentMockTime += ms),
|
||||
null !== scheduledTimeout &&
|
||||
timeoutTime <= currentMockTime &&
|
||||
(scheduledTimeout(currentMockTime),
|
||||
(timeoutTime = -1),
|
||||
(scheduledTimeout = null)));
|
||||
};
|
||||
exports.unstable_cancelCallback = function (task) {
|
||||
task.callback = null;
|
||||
};
|
||||
exports.unstable_clearLog = function () {
|
||||
if (null === yieldedValues) return [];
|
||||
var values = yieldedValues;
|
||||
yieldedValues = null;
|
||||
return values;
|
||||
};
|
||||
exports.unstable_flushAll = function () {
|
||||
if (null !== yieldedValues)
|
||||
throw Error(
|
||||
"Log is not empty. Assert on the log of yielded values before flushing additional work."
|
||||
);
|
||||
unstable_flushAllWithoutAsserting();
|
||||
if (null !== yieldedValues)
|
||||
throw Error(
|
||||
"While flushing work, something yielded a value. Use an assertion helper to assert on the log of yielded values, e.g. expect(Scheduler).toFlushAndYield([...])"
|
||||
);
|
||||
};
|
||||
exports.unstable_flushAllWithoutAsserting = unstable_flushAllWithoutAsserting;
|
||||
exports.unstable_flushExpired = function () {
|
||||
if (isFlushing) throw Error("Already flushing work.");
|
||||
if (null !== scheduledCallback) {
|
||||
isFlushing = !0;
|
||||
try {
|
||||
scheduledCallback(!1, currentMockTime) || (scheduledCallback = null);
|
||||
} finally {
|
||||
isFlushing = !1;
|
||||
}
|
||||
}
|
||||
};
|
||||
exports.unstable_flushNumberOfYields = function (count) {
|
||||
if (isFlushing) throw Error("Already flushing work.");
|
||||
if (null !== scheduledCallback) {
|
||||
var cb = scheduledCallback;
|
||||
expectedNumberOfYields = count;
|
||||
isFlushing = !0;
|
||||
try {
|
||||
count = !0;
|
||||
do count = cb(!0, currentMockTime);
|
||||
while (count && !didStop);
|
||||
count || (scheduledCallback = null);
|
||||
} finally {
|
||||
(expectedNumberOfYields = -1), (isFlushing = didStop = !1);
|
||||
}
|
||||
}
|
||||
};
|
||||
exports.unstable_flushUntilNextPaint = function () {
|
||||
if (isFlushing) throw Error("Already flushing work.");
|
||||
if (null !== scheduledCallback) {
|
||||
var cb = scheduledCallback;
|
||||
shouldYieldForPaint = !0;
|
||||
needsPaint = !1;
|
||||
isFlushing = !0;
|
||||
try {
|
||||
var hasMoreWork = !0;
|
||||
do hasMoreWork = cb(!0, currentMockTime);
|
||||
while (hasMoreWork && !didStop);
|
||||
hasMoreWork || (scheduledCallback = null);
|
||||
} finally {
|
||||
isFlushing = didStop = shouldYieldForPaint = !1;
|
||||
}
|
||||
}
|
||||
return !1;
|
||||
};
|
||||
exports.unstable_forceFrameRate = function () {};
|
||||
exports.unstable_getCurrentPriorityLevel = function () {
|
||||
return currentPriorityLevel;
|
||||
};
|
||||
exports.unstable_hasPendingWork = function () {
|
||||
return null !== scheduledCallback;
|
||||
};
|
||||
exports.unstable_next = function (eventHandler) {
|
||||
switch (currentPriorityLevel) {
|
||||
case 1:
|
||||
case 2:
|
||||
case 3:
|
||||
var priorityLevel = 3;
|
||||
break;
|
||||
default:
|
||||
priorityLevel = currentPriorityLevel;
|
||||
}
|
||||
var previousPriorityLevel = currentPriorityLevel;
|
||||
currentPriorityLevel = priorityLevel;
|
||||
try {
|
||||
return eventHandler();
|
||||
} finally {
|
||||
currentPriorityLevel = previousPriorityLevel;
|
||||
}
|
||||
};
|
||||
exports.unstable_now = function () {
|
||||
return currentMockTime;
|
||||
};
|
||||
exports.unstable_requestPaint = function () {
|
||||
needsPaint = !0;
|
||||
};
|
||||
exports.unstable_runWithPriority = function (priorityLevel, eventHandler) {
|
||||
switch (priorityLevel) {
|
||||
case 1:
|
||||
case 2:
|
||||
case 3:
|
||||
case 4:
|
||||
case 5:
|
||||
break;
|
||||
default:
|
||||
priorityLevel = 3;
|
||||
}
|
||||
var previousPriorityLevel = currentPriorityLevel;
|
||||
currentPriorityLevel = priorityLevel;
|
||||
try {
|
||||
return eventHandler();
|
||||
} finally {
|
||||
currentPriorityLevel = previousPriorityLevel;
|
||||
}
|
||||
};
|
||||
exports.unstable_scheduleCallback = function (
|
||||
priorityLevel,
|
||||
callback,
|
||||
options
|
||||
) {
|
||||
var currentTime = currentMockTime;
|
||||
"object" === typeof options && null !== options
|
||||
? ((options = options.delay),
|
||||
(options =
|
||||
"number" === typeof options && 0 < options
|
||||
? currentTime + options
|
||||
: currentTime))
|
||||
: (options = currentTime);
|
||||
switch (priorityLevel) {
|
||||
case 1:
|
||||
var timeout = -1;
|
||||
break;
|
||||
case 2:
|
||||
timeout = 250;
|
||||
break;
|
||||
case 5:
|
||||
timeout = 1073741823;
|
||||
break;
|
||||
case 4:
|
||||
timeout = 1e4;
|
||||
break;
|
||||
default:
|
||||
timeout = 5e3;
|
||||
}
|
||||
timeout = options + timeout;
|
||||
priorityLevel = {
|
||||
id: taskIdCounter++,
|
||||
callback: callback,
|
||||
priorityLevel: priorityLevel,
|
||||
startTime: options,
|
||||
expirationTime: timeout,
|
||||
sortIndex: -1
|
||||
};
|
||||
options > currentTime
|
||||
? ((priorityLevel.sortIndex = options),
|
||||
push(timerQueue, priorityLevel),
|
||||
null === peek(taskQueue) &&
|
||||
priorityLevel === peek(timerQueue) &&
|
||||
(isHostTimeoutScheduled
|
||||
? ((scheduledTimeout = null), (timeoutTime = -1))
|
||||
: (isHostTimeoutScheduled = !0),
|
||||
(scheduledTimeout = handleTimeout),
|
||||
(timeoutTime = currentMockTime + (options - currentTime))))
|
||||
: ((priorityLevel.sortIndex = timeout),
|
||||
push(taskQueue, priorityLevel),
|
||||
isHostCallbackScheduled ||
|
||||
isPerformingWork ||
|
||||
((isHostCallbackScheduled = !0), (scheduledCallback = flushWork)));
|
||||
return priorityLevel;
|
||||
};
|
||||
exports.unstable_setDisableYieldValue = function (newValue) {
|
||||
disableYieldValue = newValue;
|
||||
};
|
||||
exports.unstable_shouldYield = shouldYieldToHost;
|
||||
exports.unstable_wrapCallback = function (callback) {
|
||||
var parentPriorityLevel = currentPriorityLevel;
|
||||
return function () {
|
||||
var previousPriorityLevel = currentPriorityLevel;
|
||||
currentPriorityLevel = parentPriorityLevel;
|
||||
try {
|
||||
return callback.apply(this, arguments);
|
||||
} finally {
|
||||
currentPriorityLevel = previousPriorityLevel;
|
||||
}
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1 @@
|
||||
module.exports={A:{A:{"2":"K D E F A B mC"},B:{"2":"0 9 C L M 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","66":"Q","257":"G N O P"},C:{"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 VB WB XB YB ZB aB bB cB dB eB fB gB hB iB jB kB lB mB nB oB pB qB qC rC","129":"0 9 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","194":"rB"},D:{"2":"0 1 2 3 4 5 6 7 8 9 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 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","66":"uB vB MC wB NC xB yB zB 0B 1B 2B 3B 4B 5B 6B 7B 8B 9B AC BC CC DC Q"},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:{"2":"0 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 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 4C 5C 6C 7C FC kC 8C GC","66":"hB iB jB kB lB mB nB oB pB qB rB sB tB uB vB wB xB yB zB 0B 1B"},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:{"513":"J","516":"1 2 3 4 5 6 7 8 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:"WebVR API",D:true};
|
||||
Reference in New Issue
Block a user