usage-board 3.0.0 → 3.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.mjs +1 -1
- package/dist/public/_nuxt/{y3weNNd-.js → B6C9KBQ4.js} +2 -2
- package/dist/public/_nuxt/Bv6agYS5.js +119 -0
- package/dist/public/_nuxt/BvRyOET7.js +1 -0
- package/dist/public/_nuxt/CMWftE4h.js +1 -0
- package/dist/public/_nuxt/{Be3rizqy.js → COIbUy5w.js} +1 -1
- package/dist/public/_nuxt/CXLmM1yO.js +25 -0
- package/dist/public/_nuxt/DFqWEFN4.js +1 -0
- package/dist/public/_nuxt/DUoLvn3A.js +6 -0
- package/dist/public/_nuxt/D_W11Quh.js +21 -0
- package/dist/public/_nuxt/DgKrPjze.js +4 -0
- package/dist/public/_nuxt/DkxY2YMp.js +1 -0
- package/dist/public/_nuxt/{7Dy4NLP8.js → DtbPvE6R.js} +24 -24
- package/dist/public/_nuxt/HiqUua3-.js +1 -0
- package/dist/public/_nuxt/builds/latest.json +1 -1
- package/dist/public/_nuxt/builds/meta/6f98f1cb-266c-475e-a249-dad346a55f24.json +1 -0
- package/dist/public/_nuxt/entry.vHfFzkyD.css +1 -0
- package/dist/public/_nuxt/error-404.CFBEg71j.css +1 -0
- package/dist/public/_nuxt/error-500.BqCnH31G.css +1 -0
- package/dist/public/_nuxt/uHQwCIHg.js +1 -0
- package/dist/server/chunks/_/error-500.mjs +2 -20
- package/dist/server/chunks/build/client.precomputed.mjs +1 -1
- package/dist/server/chunks/nitro/nitro.mjs +2303 -3614
- package/dist/server/chunks/routes/api/analysis/agent/session.json.mjs +21 -0
- package/dist/server/chunks/routes/api/analysis/agent/token.json.mjs +24 -0
- package/dist/server/chunks/routes/api/analysis/cache.json.mjs +24 -0
- package/dist/server/chunks/routes/api/analysis/hot-project.json.mjs +24 -0
- package/dist/server/chunks/routes/api/analysis/model.json.mjs +24 -0
- package/dist/server/chunks/routes/api/analysis/overview-cards.json.mjs +24 -0
- package/dist/server/chunks/routes/api/analysis/session.json.mjs +21 -0
- package/dist/server/chunks/routes/api/analysis/token/daily.json.mjs +21 -0
- package/dist/server/chunks/routes/api/analysis/token.json.mjs +24 -0
- package/dist/server/chunks/routes/api/payload.json.mjs +9 -10
- package/dist/server/chunks/routes/api/projects/_project/modules.get.mjs +9 -10
- package/dist/server/chunks/routes/api/projects/catalog.get.mjs +9 -10
- package/dist/server/chunks/routes/renderer.mjs +17 -39183
- package/dist/server/chunks/routes/ws.mjs +9 -10
- package/dist/server/index.mjs +9 -10
- package/dist/server/node_modules/@babel/parser/lib/index.js +14582 -0
- package/dist/server/node_modules/@babel/parser/package.json +50 -0
- package/dist/server/node_modules/@iconify/utils/lib/colors/index.js +292 -0
- package/dist/server/node_modules/@iconify/utils/lib/colors/keywords.js +702 -0
- package/dist/server/node_modules/@iconify/utils/lib/css/common.js +76 -0
- package/dist/server/node_modules/@iconify/utils/lib/css/format.js +40 -0
- package/dist/server/node_modules/@iconify/utils/lib/css/icon.js +52 -0
- package/dist/server/node_modules/@iconify/utils/lib/css/icons.js +133 -0
- package/dist/server/node_modules/@iconify/utils/lib/customisations/bool.js +20 -0
- package/dist/server/node_modules/@iconify/utils/lib/customisations/defaults.js +15 -0
- package/dist/server/node_modules/@iconify/utils/lib/customisations/flip.js +18 -0
- package/dist/server/node_modules/@iconify/utils/lib/customisations/merge.js +18 -0
- package/dist/server/node_modules/@iconify/utils/lib/customisations/rotate.js +31 -0
- package/dist/server/node_modules/@iconify/utils/lib/emoji/cleanup.js +80 -0
- package/dist/server/node_modules/@iconify/utils/lib/emoji/convert.js +102 -0
- package/dist/server/node_modules/@iconify/utils/lib/emoji/data.js +29 -0
- package/dist/server/node_modules/@iconify/utils/lib/emoji/format.js +60 -0
- package/dist/server/node_modules/@iconify/utils/lib/emoji/parse.js +50 -0
- package/dist/server/node_modules/@iconify/utils/lib/emoji/regex/base.js +204 -0
- package/dist/server/node_modules/@iconify/utils/lib/emoji/regex/create.js +35 -0
- package/dist/server/node_modules/@iconify/utils/lib/emoji/regex/numbers.js +134 -0
- package/dist/server/node_modules/@iconify/utils/lib/emoji/regex/similar.js +167 -0
- package/dist/server/node_modules/@iconify/utils/lib/emoji/regex/tree.js +81 -0
- package/dist/server/node_modules/@iconify/utils/lib/emoji/replace/find.js +94 -0
- package/dist/server/node_modules/@iconify/utils/lib/emoji/replace/replace.js +28 -0
- package/dist/server/node_modules/@iconify/utils/lib/emoji/test/components.js +78 -0
- package/dist/server/node_modules/@iconify/utils/lib/emoji/test/missing.js +68 -0
- package/dist/server/node_modules/@iconify/utils/lib/emoji/test/name.js +47 -0
- package/dist/server/node_modules/@iconify/utils/lib/emoji/test/parse.js +105 -0
- package/dist/server/node_modules/@iconify/utils/lib/emoji/test/similar.js +38 -0
- package/dist/server/node_modules/@iconify/utils/lib/emoji/test/tree.js +94 -0
- package/dist/server/node_modules/@iconify/utils/lib/emoji/test/variations.js +64 -0
- package/dist/server/node_modules/@iconify/utils/lib/icon/defaults.js +26 -0
- package/dist/server/node_modules/@iconify/utils/lib/icon/merge.js +18 -0
- package/dist/server/node_modules/@iconify/utils/lib/icon/name.js +58 -0
- package/dist/server/node_modules/@iconify/utils/lib/icon/square.js +34 -0
- package/dist/server/node_modules/@iconify/utils/lib/icon/transformations.js +13 -0
- package/dist/server/node_modules/@iconify/utils/lib/icon-set/convert-info.js +126 -0
- package/dist/server/node_modules/@iconify/utils/lib/icon-set/expand.js +21 -0
- package/dist/server/node_modules/@iconify/utils/lib/icon-set/get-icon.js +27 -0
- package/dist/server/node_modules/@iconify/utils/lib/icon-set/get-icons.js +38 -0
- package/dist/server/node_modules/@iconify/utils/lib/icon-set/minify.js +93 -0
- package/dist/server/node_modules/@iconify/utils/lib/icon-set/parse.js +48 -0
- package/dist/server/node_modules/@iconify/utils/lib/icon-set/tree.js +24 -0
- package/dist/server/node_modules/@iconify/utils/lib/icon-set/validate-basic.js +44 -0
- package/dist/server/node_modules/@iconify/utils/lib/icon-set/validate.js +125 -0
- package/dist/server/node_modules/@iconify/utils/lib/index.js +53 -0
- package/dist/server/node_modules/@iconify/utils/lib/loader/custom.js +32 -0
- package/dist/server/node_modules/@iconify/utils/lib/loader/loader.js +28 -0
- package/dist/server/node_modules/@iconify/utils/lib/loader/modern.js +42 -0
- package/dist/server/node_modules/@iconify/utils/lib/loader/utils.js +63 -0
- package/dist/server/node_modules/@iconify/utils/lib/misc/objects.js +27 -0
- package/dist/server/node_modules/@iconify/utils/lib/misc/strings.js +27 -0
- package/dist/server/node_modules/@iconify/utils/lib/misc/title.js +10 -0
- package/dist/server/node_modules/@iconify/utils/lib/svg/build.js +115 -0
- package/dist/server/node_modules/@iconify/utils/lib/svg/defs.js +32 -0
- package/dist/server/node_modules/@iconify/utils/lib/svg/encode-svg-for-css.js +15 -0
- package/dist/server/node_modules/@iconify/utils/lib/svg/html.js +10 -0
- package/dist/server/node_modules/@iconify/utils/lib/svg/id.js +42 -0
- package/dist/server/node_modules/@iconify/utils/lib/svg/inner-html.js +23 -0
- package/dist/server/node_modules/@iconify/utils/lib/svg/parse.js +69 -0
- package/dist/server/node_modules/@iconify/utils/lib/svg/pretty.js +55 -0
- package/dist/server/node_modules/@iconify/utils/lib/svg/size.js +28 -0
- package/dist/server/node_modules/@iconify/utils/lib/svg/trim.js +8 -0
- package/dist/server/node_modules/@iconify/utils/lib/svg/url.js +23 -0
- package/dist/server/node_modules/@iconify/utils/lib/svg/viewbox.js +9 -0
- package/dist/server/node_modules/@iconify/utils/package.json +118 -0
- package/dist/server/node_modules/@lonewolfyx/utils/dist/index.mjs +63 -0
- package/dist/server/node_modules/@lonewolfyx/utils/package.json +64 -0
- package/dist/server/node_modules/@vue/compiler-core/dist/compiler-core.cjs.prod.js +6763 -0
- package/dist/server/node_modules/@vue/compiler-core/package.json +58 -0
- package/dist/server/node_modules/@vue/compiler-dom/dist/compiler-dom.cjs.prod.js +689 -0
- package/dist/server/node_modules/@vue/compiler-dom/package.json +57 -0
- package/dist/server/node_modules/@vue/compiler-ssr/dist/compiler-ssr.cjs.js +1413 -0
- package/dist/server/node_modules/@vue/compiler-ssr/package.json +34 -0
- package/dist/server/node_modules/@vue/reactivity/dist/reactivity.cjs.prod.js +1877 -0
- package/dist/server/node_modules/@vue/reactivity/package.json +55 -0
- package/dist/server/node_modules/@vue/runtime-core/dist/runtime-core.cjs.prod.js +6856 -0
- package/dist/server/node_modules/@vue/runtime-core/package.json +52 -0
- package/dist/server/node_modules/@vue/runtime-dom/dist/runtime-dom.cjs.prod.js +1796 -0
- package/dist/server/node_modules/@vue/runtime-dom/package.json +60 -0
- package/dist/server/node_modules/@vue/server-renderer/dist/server-renderer.cjs.prod.js +883 -0
- package/dist/server/node_modules/@vue/server-renderer/package.json +55 -0
- package/dist/server/{chunks/_/shared.cjs.prod.mjs → node_modules/@vue/shared/dist/shared.cjs.prod.js} +76 -81
- package/dist/server/node_modules/@vue/shared/package.json +47 -0
- package/dist/server/node_modules/better-sqlite3/build/Release/better_sqlite3.node +0 -0
- package/dist/server/node_modules/better-sqlite3/lib/database.js +90 -0
- package/dist/server/node_modules/better-sqlite3/lib/index.js +3 -0
- package/dist/server/node_modules/better-sqlite3/lib/methods/aggregate.js +43 -0
- package/dist/server/node_modules/better-sqlite3/lib/methods/backup.js +67 -0
- package/dist/server/node_modules/better-sqlite3/lib/methods/function.js +31 -0
- package/dist/server/node_modules/better-sqlite3/lib/methods/inspect.js +7 -0
- package/dist/server/node_modules/better-sqlite3/lib/methods/pragma.js +12 -0
- package/dist/server/node_modules/better-sqlite3/lib/methods/serialize.js +16 -0
- package/dist/server/node_modules/better-sqlite3/lib/methods/table.js +189 -0
- package/dist/server/node_modules/better-sqlite3/lib/methods/transaction.js +78 -0
- package/dist/server/node_modules/better-sqlite3/lib/methods/wrappers.js +54 -0
- package/dist/server/node_modules/better-sqlite3/lib/sqlite-error.js +20 -0
- package/dist/server/node_modules/better-sqlite3/lib/util.js +12 -0
- package/dist/server/node_modules/better-sqlite3/package.json +59 -0
- package/dist/server/node_modules/bindings/bindings.js +221 -0
- package/dist/server/node_modules/bindings/package.json +28 -0
- package/dist/server/node_modules/chokidar/handler.js +632 -0
- package/dist/server/node_modules/chokidar/index.js +822 -0
- package/dist/server/node_modules/chokidar/package.json +63 -0
- package/dist/server/{chunks/_ → node_modules/consola/dist/chunks}/prompt.mjs +2 -1
- package/dist/server/node_modules/consola/dist/core.mjs +512 -0
- package/dist/server/node_modules/consola/dist/index.mjs +651 -0
- package/dist/server/node_modules/consola/dist/shared/consola.DRwqZj3T.mjs +72 -0
- package/dist/server/node_modules/consola/dist/shared/consola.DXBYu-KD.mjs +288 -0
- package/dist/server/node_modules/consola/package.json +136 -0
- package/dist/server/node_modules/devalue/index.js +4 -0
- package/dist/server/node_modules/devalue/package.json +40 -0
- package/dist/server/node_modules/devalue/src/base64.js +60 -0
- package/dist/server/node_modules/devalue/src/constants.js +7 -0
- package/dist/server/node_modules/devalue/src/parse.js +268 -0
- package/dist/server/node_modules/devalue/src/stringify.js +335 -0
- package/dist/server/node_modules/devalue/src/uneval.js +552 -0
- package/dist/server/node_modules/devalue/src/utils.js +144 -0
- package/dist/server/node_modules/entities/dist/commonjs/decode-codepoint.js +77 -0
- package/dist/server/node_modules/entities/dist/commonjs/decode.js +568 -0
- package/dist/server/node_modules/entities/dist/commonjs/generated/decode-data-html.js +7 -0
- package/dist/server/node_modules/entities/dist/commonjs/generated/decode-data-xml.js +7 -0
- package/dist/server/node_modules/entities/dist/commonjs/internal/bin-trie-flags.js +21 -0
- package/dist/server/node_modules/entities/dist/commonjs/internal/decode-shared.js +31 -0
- package/dist/server/node_modules/entities/dist/commonjs/package.json +3 -0
- package/dist/server/node_modules/entities/package.json +120 -0
- package/dist/server/node_modules/estree-walker/dist/umd/estree-walker.js +344 -0
- package/dist/server/node_modules/estree-walker/package.json +37 -0
- package/dist/server/node_modules/file-uri-to-path/index.js +66 -0
- package/dist/server/node_modules/file-uri-to-path/package.json +32 -0
- package/dist/server/node_modules/glob/dist/esm/index.min.js +4 -0
- package/dist/server/node_modules/glob/dist/esm/package.json +3 -0
- package/dist/server/node_modules/glob/package.json +98 -0
- package/dist/server/node_modules/hookable/dist/index.mjs +257 -0
- package/dist/server/node_modules/hookable/package.json +53 -0
- package/dist/server/node_modules/md5-typescript/dist/bundles/bundle.umd.js +208 -0
- package/dist/server/node_modules/md5-typescript/package.json +31 -0
- package/dist/server/node_modules/path-type/index.js +42 -0
- package/dist/server/node_modules/path-type/package.json +51 -0
- package/dist/server/node_modules/readdirp/index.js +272 -0
- package/dist/server/node_modules/readdirp/package.json +66 -0
- package/dist/server/node_modules/source-map-js/lib/array-set.js +121 -0
- package/dist/server/node_modules/source-map-js/lib/base64-vlq.js +140 -0
- package/dist/server/node_modules/source-map-js/lib/base64.js +67 -0
- package/dist/server/node_modules/source-map-js/lib/binary-search.js +111 -0
- package/dist/server/node_modules/source-map-js/lib/mapping-list.js +79 -0
- package/dist/server/node_modules/source-map-js/lib/quick-sort.js +132 -0
- package/dist/server/node_modules/source-map-js/lib/source-map-consumer.js +1188 -0
- package/dist/server/node_modules/source-map-js/lib/source-map-generator.js +444 -0
- package/dist/server/node_modules/source-map-js/lib/source-node.js +413 -0
- package/dist/server/node_modules/source-map-js/lib/util.js +594 -0
- package/dist/server/node_modules/source-map-js/package.json +71 -0
- package/dist/server/node_modules/source-map-js/source-map.js +8 -0
- package/dist/server/node_modules/ufo/dist/index.mjs +645 -0
- package/dist/server/node_modules/ufo/package.json +48 -0
- package/dist/server/node_modules/unhead/dist/parser.mjs +508 -0
- package/dist/server/node_modules/unhead/dist/plugins.mjs +101 -0
- package/dist/server/node_modules/unhead/dist/server.mjs +180 -0
- package/dist/server/node_modules/unhead/dist/shared/unhead.B5FWS6X0.mjs +207 -0
- package/dist/server/node_modules/unhead/dist/shared/unhead.BYvz9V1x.mjs +43 -0
- package/dist/server/node_modules/unhead/dist/shared/unhead.CbpEuj3y.mjs +71 -0
- package/dist/server/node_modules/unhead/dist/shared/unhead.Ct24BOby.mjs +182 -0
- package/dist/server/node_modules/unhead/dist/shared/unhead.D4vSFytZ.mjs +236 -0
- package/dist/server/node_modules/unhead/dist/shared/unhead.DQc16pHI.mjs +196 -0
- package/dist/server/node_modules/unhead/dist/shared/unhead.TxTMM7cM.mjs +166 -0
- package/dist/server/node_modules/unhead/dist/shared/unhead.yem5I2v_.mjs +38 -0
- package/dist/server/node_modules/unhead/dist/utils.mjs +5 -0
- package/dist/server/node_modules/unhead/package.json +105 -0
- package/dist/server/node_modules/vue/dist/vue.cjs.js +80 -0
- package/dist/server/node_modules/vue/dist/vue.cjs.prod.js +66 -0
- package/dist/server/node_modules/vue/index.js +7 -0
- package/dist/server/node_modules/vue/index.mjs +1 -0
- package/dist/server/node_modules/vue/package.json +112 -0
- package/dist/server/node_modules/vue/server-renderer/index.mjs +1 -0
- package/dist/server/node_modules/vue-bundle-renderer/dist/runtime.mjs +301 -0
- package/dist/server/node_modules/vue-bundle-renderer/package.json +55 -0
- package/dist/server/package.json +37 -0
- package/package.json +3 -1
- package/dist/public/_nuxt/B-VlGWDb.js +0 -21
- package/dist/public/_nuxt/C0azgqnZ.js +0 -1
- package/dist/public/_nuxt/CMNdiQCa.js +0 -1
- package/dist/public/_nuxt/CPuXQJE_.js +0 -1
- package/dist/public/_nuxt/DenksPSi.js +0 -119
- package/dist/public/_nuxt/Dkya5WaL.js +0 -9
- package/dist/public/_nuxt/HN9OZyaQ.js +0 -25
- package/dist/public/_nuxt/JtK-nXxy.js +0 -1
- package/dist/public/_nuxt/builds/meta/37e8bb21-a086-45bf-93dc-47eeeada7299.json +0 -1
- package/dist/public/_nuxt/entry.r-q4oQC0.css +0 -1
- package/dist/public/_nuxt/error-404.B0EXnOcv.css +0 -1
- package/dist/public/_nuxt/error-500.CnSNZoEG.css +0 -1
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
import { lstat, readdir, realpath, stat } from 'node:fs/promises';
|
|
2
|
+
import { join as pjoin, relative as prelative, resolve as presolve, sep as psep } from 'node:path';
|
|
3
|
+
import { Readable } from 'node:stream';
|
|
4
|
+
export const EntryTypes = {
|
|
5
|
+
FILE_TYPE: 'files',
|
|
6
|
+
DIR_TYPE: 'directories',
|
|
7
|
+
FILE_DIR_TYPE: 'files_directories',
|
|
8
|
+
EVERYTHING_TYPE: 'all',
|
|
9
|
+
};
|
|
10
|
+
const defaultOptions = {
|
|
11
|
+
root: '.',
|
|
12
|
+
fileFilter: (_entryInfo) => true,
|
|
13
|
+
directoryFilter: (_entryInfo) => true,
|
|
14
|
+
type: EntryTypes.FILE_TYPE,
|
|
15
|
+
lstat: false,
|
|
16
|
+
depth: 2147483648,
|
|
17
|
+
alwaysStat: false,
|
|
18
|
+
highWaterMark: 4096,
|
|
19
|
+
};
|
|
20
|
+
Object.freeze(defaultOptions);
|
|
21
|
+
const RECURSIVE_ERROR_CODE = 'READDIRP_RECURSIVE_ERROR';
|
|
22
|
+
const NORMAL_FLOW_ERRORS = new Set(['ENOENT', 'EPERM', 'EACCES', 'ELOOP', RECURSIVE_ERROR_CODE]);
|
|
23
|
+
const ALL_TYPES = [
|
|
24
|
+
EntryTypes.DIR_TYPE,
|
|
25
|
+
EntryTypes.EVERYTHING_TYPE,
|
|
26
|
+
EntryTypes.FILE_DIR_TYPE,
|
|
27
|
+
EntryTypes.FILE_TYPE,
|
|
28
|
+
];
|
|
29
|
+
const DIR_TYPES = new Set([
|
|
30
|
+
EntryTypes.DIR_TYPE,
|
|
31
|
+
EntryTypes.EVERYTHING_TYPE,
|
|
32
|
+
EntryTypes.FILE_DIR_TYPE,
|
|
33
|
+
]);
|
|
34
|
+
const FILE_TYPES = new Set([
|
|
35
|
+
EntryTypes.EVERYTHING_TYPE,
|
|
36
|
+
EntryTypes.FILE_DIR_TYPE,
|
|
37
|
+
EntryTypes.FILE_TYPE,
|
|
38
|
+
]);
|
|
39
|
+
const isNormalFlowError = (error) => NORMAL_FLOW_ERRORS.has(error.code);
|
|
40
|
+
const wantBigintFsStats = process.platform === 'win32';
|
|
41
|
+
const emptyFn = (_entryInfo) => true;
|
|
42
|
+
const normalizeFilter = (filter) => {
|
|
43
|
+
if (filter === undefined)
|
|
44
|
+
return emptyFn;
|
|
45
|
+
if (typeof filter === 'function')
|
|
46
|
+
return filter;
|
|
47
|
+
if (typeof filter === 'string') {
|
|
48
|
+
const fl = filter.trim();
|
|
49
|
+
return (entry) => entry.basename === fl;
|
|
50
|
+
}
|
|
51
|
+
if (Array.isArray(filter)) {
|
|
52
|
+
const trItems = filter.map((item) => item.trim());
|
|
53
|
+
return (entry) => trItems.some((f) => entry.basename === f);
|
|
54
|
+
}
|
|
55
|
+
return emptyFn;
|
|
56
|
+
};
|
|
57
|
+
/** Readable readdir stream, emitting new files as they're being listed. */
|
|
58
|
+
export class ReaddirpStream extends Readable {
|
|
59
|
+
parents;
|
|
60
|
+
reading;
|
|
61
|
+
parent;
|
|
62
|
+
_stat;
|
|
63
|
+
_maxDepth;
|
|
64
|
+
_wantsDir;
|
|
65
|
+
_wantsFile;
|
|
66
|
+
_wantsEverything;
|
|
67
|
+
_root;
|
|
68
|
+
_isDirent;
|
|
69
|
+
_statsProp;
|
|
70
|
+
_rdOptions;
|
|
71
|
+
_fileFilter;
|
|
72
|
+
_directoryFilter;
|
|
73
|
+
constructor(options = {}) {
|
|
74
|
+
super({
|
|
75
|
+
objectMode: true,
|
|
76
|
+
autoDestroy: true,
|
|
77
|
+
highWaterMark: options.highWaterMark,
|
|
78
|
+
});
|
|
79
|
+
const opts = { ...defaultOptions, ...options };
|
|
80
|
+
const { root, type } = opts;
|
|
81
|
+
this._fileFilter = normalizeFilter(opts.fileFilter);
|
|
82
|
+
this._directoryFilter = normalizeFilter(opts.directoryFilter);
|
|
83
|
+
const statMethod = opts.lstat ? lstat : stat;
|
|
84
|
+
// Use bigint stats if it's windows and stat() supports options (node 10+).
|
|
85
|
+
if (wantBigintFsStats) {
|
|
86
|
+
this._stat = (path) => statMethod(path, { bigint: true });
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
this._stat = statMethod;
|
|
90
|
+
}
|
|
91
|
+
this._maxDepth =
|
|
92
|
+
opts.depth != null && Number.isSafeInteger(opts.depth) ? opts.depth : defaultOptions.depth;
|
|
93
|
+
this._wantsDir = type ? DIR_TYPES.has(type) : false;
|
|
94
|
+
this._wantsFile = type ? FILE_TYPES.has(type) : false;
|
|
95
|
+
this._wantsEverything = type === EntryTypes.EVERYTHING_TYPE;
|
|
96
|
+
this._root = presolve(root);
|
|
97
|
+
this._isDirent = !opts.alwaysStat;
|
|
98
|
+
this._statsProp = this._isDirent ? 'dirent' : 'stats';
|
|
99
|
+
this._rdOptions = { encoding: 'utf8', withFileTypes: this._isDirent };
|
|
100
|
+
// Launch stream with one parent, the root dir.
|
|
101
|
+
this.parents = [this._exploreDir(root, 1)];
|
|
102
|
+
this.reading = false;
|
|
103
|
+
this.parent = undefined;
|
|
104
|
+
}
|
|
105
|
+
async _read(batch) {
|
|
106
|
+
if (this.reading)
|
|
107
|
+
return;
|
|
108
|
+
this.reading = true;
|
|
109
|
+
try {
|
|
110
|
+
while (!this.destroyed && batch > 0) {
|
|
111
|
+
const par = this.parent;
|
|
112
|
+
const fil = par && par.files;
|
|
113
|
+
if (fil && fil.length > 0) {
|
|
114
|
+
const { path, depth } = par;
|
|
115
|
+
const slice = fil.splice(0, batch).map((dirent) => this._formatEntry(dirent, path));
|
|
116
|
+
const awaited = await Promise.all(slice);
|
|
117
|
+
for (const entry of awaited) {
|
|
118
|
+
if (!entry)
|
|
119
|
+
continue;
|
|
120
|
+
if (this.destroyed)
|
|
121
|
+
return;
|
|
122
|
+
const entryType = await this._getEntryType(entry);
|
|
123
|
+
if (entryType === 'directory' && this._directoryFilter(entry)) {
|
|
124
|
+
if (depth <= this._maxDepth) {
|
|
125
|
+
this.parents.push(this._exploreDir(entry.fullPath, depth + 1));
|
|
126
|
+
}
|
|
127
|
+
if (this._wantsDir) {
|
|
128
|
+
this.push(entry);
|
|
129
|
+
batch--;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
else if ((entryType === 'file' || this._includeAsFile(entry)) &&
|
|
133
|
+
this._fileFilter(entry)) {
|
|
134
|
+
if (this._wantsFile) {
|
|
135
|
+
this.push(entry);
|
|
136
|
+
batch--;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
else {
|
|
142
|
+
const parent = this.parents.pop();
|
|
143
|
+
if (!parent) {
|
|
144
|
+
this.push(null);
|
|
145
|
+
break;
|
|
146
|
+
}
|
|
147
|
+
this.parent = await parent;
|
|
148
|
+
if (this.destroyed)
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
catch (error) {
|
|
154
|
+
this.destroy(error);
|
|
155
|
+
}
|
|
156
|
+
finally {
|
|
157
|
+
this.reading = false;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
async _exploreDir(path, depth) {
|
|
161
|
+
let files;
|
|
162
|
+
try {
|
|
163
|
+
files = await readdir(path, this._rdOptions);
|
|
164
|
+
}
|
|
165
|
+
catch (error) {
|
|
166
|
+
this._onError(error);
|
|
167
|
+
}
|
|
168
|
+
return { files, depth, path };
|
|
169
|
+
}
|
|
170
|
+
async _formatEntry(dirent, path) {
|
|
171
|
+
let entry;
|
|
172
|
+
const basename = this._isDirent ? dirent.name : dirent;
|
|
173
|
+
try {
|
|
174
|
+
const fullPath = presolve(pjoin(path, basename));
|
|
175
|
+
entry = { path: prelative(this._root, fullPath), fullPath, basename };
|
|
176
|
+
entry[this._statsProp] = this._isDirent ? dirent : await this._stat(fullPath);
|
|
177
|
+
}
|
|
178
|
+
catch (err) {
|
|
179
|
+
this._onError(err);
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
182
|
+
return entry;
|
|
183
|
+
}
|
|
184
|
+
_onError(err) {
|
|
185
|
+
if (isNormalFlowError(err) && !this.destroyed) {
|
|
186
|
+
this.emit('warn', err);
|
|
187
|
+
}
|
|
188
|
+
else {
|
|
189
|
+
this.destroy(err);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
async _getEntryType(entry) {
|
|
193
|
+
// entry may be undefined, because a warning or an error were emitted
|
|
194
|
+
// and the statsProp is undefined
|
|
195
|
+
if (!entry && this._statsProp in entry) {
|
|
196
|
+
return '';
|
|
197
|
+
}
|
|
198
|
+
const stats = entry[this._statsProp];
|
|
199
|
+
if (stats.isFile())
|
|
200
|
+
return 'file';
|
|
201
|
+
if (stats.isDirectory())
|
|
202
|
+
return 'directory';
|
|
203
|
+
if (stats && stats.isSymbolicLink()) {
|
|
204
|
+
const full = entry.fullPath;
|
|
205
|
+
try {
|
|
206
|
+
const entryRealPath = await realpath(full);
|
|
207
|
+
const entryRealPathStats = await lstat(entryRealPath);
|
|
208
|
+
if (entryRealPathStats.isFile()) {
|
|
209
|
+
return 'file';
|
|
210
|
+
}
|
|
211
|
+
if (entryRealPathStats.isDirectory()) {
|
|
212
|
+
const len = entryRealPath.length;
|
|
213
|
+
if (full.startsWith(entryRealPath) && full.substr(len, 1) === psep) {
|
|
214
|
+
const recursiveError = new Error(`Circular symlink detected: "${full}" points to "${entryRealPath}"`);
|
|
215
|
+
// @ts-ignore
|
|
216
|
+
recursiveError.code = RECURSIVE_ERROR_CODE;
|
|
217
|
+
return this._onError(recursiveError);
|
|
218
|
+
}
|
|
219
|
+
return 'directory';
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
catch (error) {
|
|
223
|
+
this._onError(error);
|
|
224
|
+
return '';
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
_includeAsFile(entry) {
|
|
229
|
+
const stats = entry && entry[this._statsProp];
|
|
230
|
+
return stats && this._wantsEverything && !stats.isDirectory();
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* Streaming version: Reads all files and directories in given root recursively.
|
|
235
|
+
* Consumes ~constant small amount of RAM.
|
|
236
|
+
* @param root Root directory
|
|
237
|
+
* @param options Options to specify root (start directory), filters and recursion depth
|
|
238
|
+
*/
|
|
239
|
+
export function readdirp(root, options = {}) {
|
|
240
|
+
// @ts-ignore
|
|
241
|
+
let type = options.entryType || options.type;
|
|
242
|
+
if (type === 'both')
|
|
243
|
+
type = EntryTypes.FILE_DIR_TYPE; // backwards-compatibility
|
|
244
|
+
if (type)
|
|
245
|
+
options.type = type;
|
|
246
|
+
if (!root) {
|
|
247
|
+
throw new Error('readdirp: root argument is required. Usage: readdirp(root, options)');
|
|
248
|
+
}
|
|
249
|
+
else if (typeof root !== 'string') {
|
|
250
|
+
throw new TypeError('readdirp: root argument must be a string. Usage: readdirp(root, options)');
|
|
251
|
+
}
|
|
252
|
+
else if (type && !ALL_TYPES.includes(type)) {
|
|
253
|
+
throw new Error(`readdirp: Invalid type passed. Use one of ${ALL_TYPES.join(', ')}`);
|
|
254
|
+
}
|
|
255
|
+
options.root = root;
|
|
256
|
+
return new ReaddirpStream(options);
|
|
257
|
+
}
|
|
258
|
+
/**
|
|
259
|
+
* Promise version: Reads all files and directories in given root recursively.
|
|
260
|
+
* Compared to streaming version, will consume a lot of RAM e.g. when 1 million files are listed.
|
|
261
|
+
* @returns array of paths and their entry infos
|
|
262
|
+
*/
|
|
263
|
+
export function readdirpPromise(root, options = {}) {
|
|
264
|
+
return new Promise((resolve, reject) => {
|
|
265
|
+
const files = [];
|
|
266
|
+
readdirp(root, options)
|
|
267
|
+
.on('data', (entry) => files.push(entry))
|
|
268
|
+
.on('end', () => resolve(files))
|
|
269
|
+
.on('error', (error) => reject(error));
|
|
270
|
+
});
|
|
271
|
+
}
|
|
272
|
+
export default readdirp;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "readdirp",
|
|
3
|
+
"description": "Recursive version of fs.readdir with small RAM & CPU footprint",
|
|
4
|
+
"version": "5.0.0",
|
|
5
|
+
"homepage": "https://github.com/paulmillr/readdirp",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/paulmillr/readdirp.git"
|
|
9
|
+
},
|
|
10
|
+
"license": "MIT",
|
|
11
|
+
"bugs": {
|
|
12
|
+
"url": "https://github.com/paulmillr/readdirp/issues"
|
|
13
|
+
},
|
|
14
|
+
"author": "Thorsten Lorenz <thlorenz@gmx.de> (thlorenz.com)",
|
|
15
|
+
"contributors": [
|
|
16
|
+
"Thorsten Lorenz <thlorenz@gmx.de> (thlorenz.com)",
|
|
17
|
+
"Paul Miller (https://paulmillr.com)"
|
|
18
|
+
],
|
|
19
|
+
"engines": {
|
|
20
|
+
"node": ">= 20.19.0"
|
|
21
|
+
},
|
|
22
|
+
"files": [
|
|
23
|
+
"index.js",
|
|
24
|
+
"index.d.ts",
|
|
25
|
+
"index.d.ts.map",
|
|
26
|
+
"index.js.map"
|
|
27
|
+
],
|
|
28
|
+
"type": "module",
|
|
29
|
+
"main": "./index.js",
|
|
30
|
+
"module": "./index.js",
|
|
31
|
+
"types": "./index.d.ts",
|
|
32
|
+
"exports": {
|
|
33
|
+
".": "./index.js"
|
|
34
|
+
},
|
|
35
|
+
"sideEffects": false,
|
|
36
|
+
"keywords": [
|
|
37
|
+
"recursive",
|
|
38
|
+
"fs",
|
|
39
|
+
"stream",
|
|
40
|
+
"streams",
|
|
41
|
+
"readdir",
|
|
42
|
+
"filesystem",
|
|
43
|
+
"find",
|
|
44
|
+
"filter"
|
|
45
|
+
],
|
|
46
|
+
"scripts": {
|
|
47
|
+
"build": "tsc",
|
|
48
|
+
"lint": "prettier --check index.ts test/index.test.js",
|
|
49
|
+
"format": "prettier --write index.ts test/index.test.js",
|
|
50
|
+
"test": "node test/index.test.js",
|
|
51
|
+
"test:coverage": "c8 node test/index.test.js"
|
|
52
|
+
},
|
|
53
|
+
"devDependencies": {
|
|
54
|
+
"@paulmillr/jsbt": "0.4.5",
|
|
55
|
+
"@types/node": "24.10.1",
|
|
56
|
+
"c8": "10.1.3",
|
|
57
|
+
"chai": "4.3.4",
|
|
58
|
+
"chai-subset": "1.6.0",
|
|
59
|
+
"prettier": "3.1.1",
|
|
60
|
+
"typescript": "5.9.2"
|
|
61
|
+
},
|
|
62
|
+
"funding": {
|
|
63
|
+
"type": "individual",
|
|
64
|
+
"url": "https://paulmillr.com/funding/"
|
|
65
|
+
}
|
|
66
|
+
}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
/* -*- Mode: js; js-indent-level: 2; -*- */
|
|
2
|
+
/*
|
|
3
|
+
* Copyright 2011 Mozilla Foundation and contributors
|
|
4
|
+
* Licensed under the New BSD license. See LICENSE or:
|
|
5
|
+
* http://opensource.org/licenses/BSD-3-Clause
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
var util = require('./util');
|
|
9
|
+
var has = Object.prototype.hasOwnProperty;
|
|
10
|
+
var hasNativeMap = typeof Map !== "undefined";
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* A data structure which is a combination of an array and a set. Adding a new
|
|
14
|
+
* member is O(1), testing for membership is O(1), and finding the index of an
|
|
15
|
+
* element is O(1). Removing elements from the set is not supported. Only
|
|
16
|
+
* strings are supported for membership.
|
|
17
|
+
*/
|
|
18
|
+
function ArraySet() {
|
|
19
|
+
this._array = [];
|
|
20
|
+
this._set = hasNativeMap ? new Map() : Object.create(null);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Static method for creating ArraySet instances from an existing array.
|
|
25
|
+
*/
|
|
26
|
+
ArraySet.fromArray = function ArraySet_fromArray(aArray, aAllowDuplicates) {
|
|
27
|
+
var set = new ArraySet();
|
|
28
|
+
for (var i = 0, len = aArray.length; i < len; i++) {
|
|
29
|
+
set.add(aArray[i], aAllowDuplicates);
|
|
30
|
+
}
|
|
31
|
+
return set;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Return how many unique items are in this ArraySet. If duplicates have been
|
|
36
|
+
* added, than those do not count towards the size.
|
|
37
|
+
*
|
|
38
|
+
* @returns Number
|
|
39
|
+
*/
|
|
40
|
+
ArraySet.prototype.size = function ArraySet_size() {
|
|
41
|
+
return hasNativeMap ? this._set.size : Object.getOwnPropertyNames(this._set).length;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Add the given string to this set.
|
|
46
|
+
*
|
|
47
|
+
* @param String aStr
|
|
48
|
+
*/
|
|
49
|
+
ArraySet.prototype.add = function ArraySet_add(aStr, aAllowDuplicates) {
|
|
50
|
+
var sStr = hasNativeMap ? aStr : util.toSetString(aStr);
|
|
51
|
+
var isDuplicate = hasNativeMap ? this.has(aStr) : has.call(this._set, sStr);
|
|
52
|
+
var idx = this._array.length;
|
|
53
|
+
if (!isDuplicate || aAllowDuplicates) {
|
|
54
|
+
this._array.push(aStr);
|
|
55
|
+
}
|
|
56
|
+
if (!isDuplicate) {
|
|
57
|
+
if (hasNativeMap) {
|
|
58
|
+
this._set.set(aStr, idx);
|
|
59
|
+
} else {
|
|
60
|
+
this._set[sStr] = idx;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Is the given string a member of this set?
|
|
67
|
+
*
|
|
68
|
+
* @param String aStr
|
|
69
|
+
*/
|
|
70
|
+
ArraySet.prototype.has = function ArraySet_has(aStr) {
|
|
71
|
+
if (hasNativeMap) {
|
|
72
|
+
return this._set.has(aStr);
|
|
73
|
+
} else {
|
|
74
|
+
var sStr = util.toSetString(aStr);
|
|
75
|
+
return has.call(this._set, sStr);
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* What is the index of the given string in the array?
|
|
81
|
+
*
|
|
82
|
+
* @param String aStr
|
|
83
|
+
*/
|
|
84
|
+
ArraySet.prototype.indexOf = function ArraySet_indexOf(aStr) {
|
|
85
|
+
if (hasNativeMap) {
|
|
86
|
+
var idx = this._set.get(aStr);
|
|
87
|
+
if (idx >= 0) {
|
|
88
|
+
return idx;
|
|
89
|
+
}
|
|
90
|
+
} else {
|
|
91
|
+
var sStr = util.toSetString(aStr);
|
|
92
|
+
if (has.call(this._set, sStr)) {
|
|
93
|
+
return this._set[sStr];
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
throw new Error('"' + aStr + '" is not in the set.');
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* What is the element at the given index?
|
|
102
|
+
*
|
|
103
|
+
* @param Number aIdx
|
|
104
|
+
*/
|
|
105
|
+
ArraySet.prototype.at = function ArraySet_at(aIdx) {
|
|
106
|
+
if (aIdx >= 0 && aIdx < this._array.length) {
|
|
107
|
+
return this._array[aIdx];
|
|
108
|
+
}
|
|
109
|
+
throw new Error('No element indexed by ' + aIdx);
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Returns the array representation of this set (which has the proper indices
|
|
114
|
+
* indicated by indexOf). Note that this is a copy of the internal array used
|
|
115
|
+
* for storing the members so that no one can mess with internal state.
|
|
116
|
+
*/
|
|
117
|
+
ArraySet.prototype.toArray = function ArraySet_toArray() {
|
|
118
|
+
return this._array.slice();
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
exports.ArraySet = ArraySet;
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
/* -*- Mode: js; js-indent-level: 2; -*- */
|
|
2
|
+
/*
|
|
3
|
+
* Copyright 2011 Mozilla Foundation and contributors
|
|
4
|
+
* Licensed under the New BSD license. See LICENSE or:
|
|
5
|
+
* http://opensource.org/licenses/BSD-3-Clause
|
|
6
|
+
*
|
|
7
|
+
* Based on the Base 64 VLQ implementation in Closure Compiler:
|
|
8
|
+
* https://code.google.com/p/closure-compiler/source/browse/trunk/src/com/google/debugging/sourcemap/Base64VLQ.java
|
|
9
|
+
*
|
|
10
|
+
* Copyright 2011 The Closure Compiler Authors. All rights reserved.
|
|
11
|
+
* Redistribution and use in source and binary forms, with or without
|
|
12
|
+
* modification, are permitted provided that the following conditions are
|
|
13
|
+
* met:
|
|
14
|
+
*
|
|
15
|
+
* * Redistributions of source code must retain the above copyright
|
|
16
|
+
* notice, this list of conditions and the following disclaimer.
|
|
17
|
+
* * Redistributions in binary form must reproduce the above
|
|
18
|
+
* copyright notice, this list of conditions and the following
|
|
19
|
+
* disclaimer in the documentation and/or other materials provided
|
|
20
|
+
* with the distribution.
|
|
21
|
+
* * Neither the name of Google Inc. nor the names of its
|
|
22
|
+
* contributors may be used to endorse or promote products derived
|
|
23
|
+
* from this software without specific prior written permission.
|
|
24
|
+
*
|
|
25
|
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
26
|
+
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
27
|
+
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
28
|
+
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
29
|
+
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
30
|
+
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
31
|
+
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
32
|
+
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
33
|
+
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
34
|
+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
35
|
+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
36
|
+
*/
|
|
37
|
+
|
|
38
|
+
var base64 = require('./base64');
|
|
39
|
+
|
|
40
|
+
// A single base 64 digit can contain 6 bits of data. For the base 64 variable
|
|
41
|
+
// length quantities we use in the source map spec, the first bit is the sign,
|
|
42
|
+
// the next four bits are the actual value, and the 6th bit is the
|
|
43
|
+
// continuation bit. The continuation bit tells us whether there are more
|
|
44
|
+
// digits in this value following this digit.
|
|
45
|
+
//
|
|
46
|
+
// Continuation
|
|
47
|
+
// | Sign
|
|
48
|
+
// | |
|
|
49
|
+
// V V
|
|
50
|
+
// 101011
|
|
51
|
+
|
|
52
|
+
var VLQ_BASE_SHIFT = 5;
|
|
53
|
+
|
|
54
|
+
// binary: 100000
|
|
55
|
+
var VLQ_BASE = 1 << VLQ_BASE_SHIFT;
|
|
56
|
+
|
|
57
|
+
// binary: 011111
|
|
58
|
+
var VLQ_BASE_MASK = VLQ_BASE - 1;
|
|
59
|
+
|
|
60
|
+
// binary: 100000
|
|
61
|
+
var VLQ_CONTINUATION_BIT = VLQ_BASE;
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Converts from a two-complement value to a value where the sign bit is
|
|
65
|
+
* placed in the least significant bit. For example, as decimals:
|
|
66
|
+
* 1 becomes 2 (10 binary), -1 becomes 3 (11 binary)
|
|
67
|
+
* 2 becomes 4 (100 binary), -2 becomes 5 (101 binary)
|
|
68
|
+
*/
|
|
69
|
+
function toVLQSigned(aValue) {
|
|
70
|
+
return aValue < 0
|
|
71
|
+
? ((-aValue) << 1) + 1
|
|
72
|
+
: (aValue << 1) + 0;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Converts to a two-complement value from a value where the sign bit is
|
|
77
|
+
* placed in the least significant bit. For example, as decimals:
|
|
78
|
+
* 2 (10 binary) becomes 1, 3 (11 binary) becomes -1
|
|
79
|
+
* 4 (100 binary) becomes 2, 5 (101 binary) becomes -2
|
|
80
|
+
*/
|
|
81
|
+
function fromVLQSigned(aValue) {
|
|
82
|
+
var isNegative = (aValue & 1) === 1;
|
|
83
|
+
var shifted = aValue >> 1;
|
|
84
|
+
return isNegative
|
|
85
|
+
? -shifted
|
|
86
|
+
: shifted;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Returns the base 64 VLQ encoded value.
|
|
91
|
+
*/
|
|
92
|
+
exports.encode = function base64VLQ_encode(aValue) {
|
|
93
|
+
var encoded = "";
|
|
94
|
+
var digit;
|
|
95
|
+
|
|
96
|
+
var vlq = toVLQSigned(aValue);
|
|
97
|
+
|
|
98
|
+
do {
|
|
99
|
+
digit = vlq & VLQ_BASE_MASK;
|
|
100
|
+
vlq >>>= VLQ_BASE_SHIFT;
|
|
101
|
+
if (vlq > 0) {
|
|
102
|
+
// There are still more digits in this value, so we must make sure the
|
|
103
|
+
// continuation bit is marked.
|
|
104
|
+
digit |= VLQ_CONTINUATION_BIT;
|
|
105
|
+
}
|
|
106
|
+
encoded += base64.encode(digit);
|
|
107
|
+
} while (vlq > 0);
|
|
108
|
+
|
|
109
|
+
return encoded;
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Decodes the next base 64 VLQ value from the given string and returns the
|
|
114
|
+
* value and the rest of the string via the out parameter.
|
|
115
|
+
*/
|
|
116
|
+
exports.decode = function base64VLQ_decode(aStr, aIndex, aOutParam) {
|
|
117
|
+
var strLen = aStr.length;
|
|
118
|
+
var result = 0;
|
|
119
|
+
var shift = 0;
|
|
120
|
+
var continuation, digit;
|
|
121
|
+
|
|
122
|
+
do {
|
|
123
|
+
if (aIndex >= strLen) {
|
|
124
|
+
throw new Error("Expected more digits in base 64 VLQ value.");
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
digit = base64.decode(aStr.charCodeAt(aIndex++));
|
|
128
|
+
if (digit === -1) {
|
|
129
|
+
throw new Error("Invalid base64 digit: " + aStr.charAt(aIndex - 1));
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
continuation = !!(digit & VLQ_CONTINUATION_BIT);
|
|
133
|
+
digit &= VLQ_BASE_MASK;
|
|
134
|
+
result = result + (digit << shift);
|
|
135
|
+
shift += VLQ_BASE_SHIFT;
|
|
136
|
+
} while (continuation);
|
|
137
|
+
|
|
138
|
+
aOutParam.value = fromVLQSigned(result);
|
|
139
|
+
aOutParam.rest = aIndex;
|
|
140
|
+
};
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/* -*- Mode: js; js-indent-level: 2; -*- */
|
|
2
|
+
/*
|
|
3
|
+
* Copyright 2011 Mozilla Foundation and contributors
|
|
4
|
+
* Licensed under the New BSD license. See LICENSE or:
|
|
5
|
+
* http://opensource.org/licenses/BSD-3-Clause
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
var intToCharMap = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'.split('');
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Encode an integer in the range of 0 to 63 to a single base 64 digit.
|
|
12
|
+
*/
|
|
13
|
+
exports.encode = function (number) {
|
|
14
|
+
if (0 <= number && number < intToCharMap.length) {
|
|
15
|
+
return intToCharMap[number];
|
|
16
|
+
}
|
|
17
|
+
throw new TypeError("Must be between 0 and 63: " + number);
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Decode a single base 64 character code digit to an integer. Returns -1 on
|
|
22
|
+
* failure.
|
|
23
|
+
*/
|
|
24
|
+
exports.decode = function (charCode) {
|
|
25
|
+
var bigA = 65; // 'A'
|
|
26
|
+
var bigZ = 90; // 'Z'
|
|
27
|
+
|
|
28
|
+
var littleA = 97; // 'a'
|
|
29
|
+
var littleZ = 122; // 'z'
|
|
30
|
+
|
|
31
|
+
var zero = 48; // '0'
|
|
32
|
+
var nine = 57; // '9'
|
|
33
|
+
|
|
34
|
+
var plus = 43; // '+'
|
|
35
|
+
var slash = 47; // '/'
|
|
36
|
+
|
|
37
|
+
var littleOffset = 26;
|
|
38
|
+
var numberOffset = 52;
|
|
39
|
+
|
|
40
|
+
// 0 - 25: ABCDEFGHIJKLMNOPQRSTUVWXYZ
|
|
41
|
+
if (bigA <= charCode && charCode <= bigZ) {
|
|
42
|
+
return (charCode - bigA);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// 26 - 51: abcdefghijklmnopqrstuvwxyz
|
|
46
|
+
if (littleA <= charCode && charCode <= littleZ) {
|
|
47
|
+
return (charCode - littleA + littleOffset);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// 52 - 61: 0123456789
|
|
51
|
+
if (zero <= charCode && charCode <= nine) {
|
|
52
|
+
return (charCode - zero + numberOffset);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// 62: +
|
|
56
|
+
if (charCode == plus) {
|
|
57
|
+
return 62;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// 63: /
|
|
61
|
+
if (charCode == slash) {
|
|
62
|
+
return 63;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// Invalid base64 digit.
|
|
66
|
+
return -1;
|
|
67
|
+
};
|