full PC config setup
shifting towards manual symlinks for more complex setup than laptop, allows for GUI settings changes to actually apply, and is much easier than nix-ifying every config
This commit is contained in:
149 files changed
+9539
-478
No files matched your search
@@ -0,0 +1,11 @@
|
||||
**/README*
|
||||
**/CHANGELOG*
|
||||
**/LICENSE*
|
||||
**/NOTICE*
|
||||
**/METADATA*
|
||||
**/*.png
|
||||
**/*.txt
|
||||
**/*.md
|
||||
**/.vsixmanifest
|
||||
**/images
|
||||
**/.vscode
|
||||
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"comments": {
|
||||
"lineComment": "#",
|
||||
"blockComment": [ "/*", "*/" ]
|
||||
},
|
||||
"brackets": [
|
||||
["{", "}"],
|
||||
["[", "]"],
|
||||
["(", ")"]
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
{
|
||||
"name": "Nix",
|
||||
"description": "Nix language support for Visual Studio Code.",
|
||||
"version": "1.0.1",
|
||||
"publisher": "bbenoist",
|
||||
"icon": "images/icon.png",
|
||||
"galleryBanner": {
|
||||
"color": "#FFFFFF",
|
||||
"theme": "light"
|
||||
},
|
||||
"license": "SEE LICENSE IN LICENSE.md",
|
||||
"bugs": {
|
||||
"url": "https://github.com/bbenoist/vscode-nix/issues"
|
||||
},
|
||||
"homepage": "https://github.com/bbenoist/vscode-nix/blob/master/README.md",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/bbenoist/vscode-nix.git"
|
||||
},
|
||||
"engines": {
|
||||
"vscode": "^0.10.1"
|
||||
},
|
||||
"categories": [
|
||||
"Languages"
|
||||
],
|
||||
"contributes": {
|
||||
"languages": [
|
||||
{
|
||||
"id": "nix",
|
||||
"extensions": [
|
||||
".nix"
|
||||
],
|
||||
"configuration": "./nix.configuration.json"
|
||||
}
|
||||
],
|
||||
"grammars": [
|
||||
{
|
||||
"language": "nix",
|
||||
"scopeName": "source.nix",
|
||||
"path": "./syntaxes/nix.tmLanguage"
|
||||
}
|
||||
]
|
||||
},
|
||||
"__metadata": {
|
||||
"installedTimestamp": 1783821078168,
|
||||
"targetPlatform": "undefined",
|
||||
"size": 120743
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1 @@
|
||||
[{"identifier":{"id":"bbenoist.nix","uuid":"5b21bd54-5258-4a3e-887f-193d9bb5f063"},"version":"1.0.1","location":{"$mid":1,"path":"/home/grey/.vscode/extensions/bbenoist.nix-1.0.1","scheme":"file"},"relativeLocation":"bbenoist.nix-1.0.1","metadata":{"installedTimestamp":1783821077845,"pinned":false,"source":"gallery","id":"5b21bd54-5258-4a3e-887f-193d9bb5f063","publisherId":"787ce942-60d4-48d6-b14e-25bdc72bd145","publisherDisplayName":"Baptist BENOIST","targetPlatform":"undefined","updated":false,"private":false,"isPreReleaseVersion":false,"hasPreReleaseVersion":false}},{"identifier":{"id":"kdl-org.kdl","uuid":"85fc99f6-11df-44ee-91ed-ae96cfa2d7ac"},"version":"2.1.3","location":{"$mid":1,"path":"/home/grey/.vscode/extensions/kdl-org.kdl-2.1.3","scheme":"file"},"relativeLocation":"kdl-org.kdl-2.1.3","metadata":{"installedTimestamp":1783821237413,"pinned":false,"source":"gallery","id":"85fc99f6-11df-44ee-91ed-ae96cfa2d7ac","publisherId":"0e4cb19e-bf6d-4e62-a862-ae4b91baf151","publisherDisplayName":"kdl-org","targetPlatform":"undefined","updated":false,"private":false,"isPreReleaseVersion":false,"hasPreReleaseVersion":false}},{"identifier":{"id":"jdunkel.patternstore"},"version":"0.1.12","location":{"$mid":1,"fsPath":"/home/grey/.vscode/extensions/jdunkel.patternstore-0.1.12","external":"file:///home/grey/.vscode/extensions/jdunkel.patternstore-0.1.12","path":"/home/grey/.vscode/extensions/jdunkel.patternstore-0.1.12","scheme":"file"},"relativeLocation":"jdunkel.patternstore-0.1.12","metadata":{"installedTimestamp":1783822349360,"pinned":false,"source":"gallery","id":"936ed925-ee84-4824-9d58-98729b2f744c","publisherId":"6df66903-9b7e-463b-a33d-f4eca8208706","publisherDisplayName":"jdunkel","targetPlatform":"undefined","updated":false,"private":false,"isPreReleaseVersion":false,"hasPreReleaseVersion":false}}]
|
||||
@@ -0,0 +1,64 @@
|
||||
{
|
||||
"patternStore.savedPatterns": [
|
||||
{
|
||||
"label": "Import quotes to angles",
|
||||
"find": "\"([^\"]+)\"",
|
||||
"replace": "<$1>",
|
||||
"flags": {
|
||||
"isRegex": true,
|
||||
"isCaseSensitive": false,
|
||||
"matchWholeWord": false,
|
||||
"isMultiline": false
|
||||
},
|
||||
"scope": "global"
|
||||
},
|
||||
{
|
||||
"label": "TODO",
|
||||
"find": "TODO",
|
||||
"flags": {
|
||||
"isRegex": false,
|
||||
"isCaseSensitive": true,
|
||||
"matchWholeWord": true,
|
||||
"isMultiline": false
|
||||
},
|
||||
"scope": "global"
|
||||
},
|
||||
{
|
||||
"label": "Dynamic module import",
|
||||
"find": "${prompt:module}([^\"]*)",
|
||||
"replace": "<${prompt:module}$1>",
|
||||
"flags": {
|
||||
"isRegex": true,
|
||||
"isCaseSensitive": true,
|
||||
"matchWholeWord": false,
|
||||
"isMultiline": false
|
||||
},
|
||||
"scope": "global"
|
||||
},
|
||||
{
|
||||
"label": "Find all TODOs (no replace)",
|
||||
"find": "TODO",
|
||||
"flags": {
|
||||
"isRegex": false,
|
||||
"isCaseSensitive": true,
|
||||
"matchWholeWord": true,
|
||||
"isMultiline": false
|
||||
},
|
||||
"scope": "global"
|
||||
}
|
||||
],
|
||||
"patternStore.workspacePatterns": [
|
||||
{
|
||||
"label": "Workspace specific pattern",
|
||||
"find": "oldClass",
|
||||
"replace": "newClass",
|
||||
"flags": {
|
||||
"isRegex": false,
|
||||
"isCaseSensitive": true,
|
||||
"matchWholeWord": true,
|
||||
"isMultiline": false
|
||||
},
|
||||
"scope": "workspace"
|
||||
}
|
||||
]
|
||||
}
|
||||
Generated
Vendored
+19
@@ -0,0 +1,19 @@
|
||||
import uuid from "./index.js";
|
||||
export import v1 = uuid.v1;
|
||||
export import v1ToV6 = uuid.v1ToV6;
|
||||
export import v3 = uuid.v3;
|
||||
export import v4 = uuid.v4;
|
||||
export import v5 = uuid.v5;
|
||||
export import v6 = uuid.v6;
|
||||
export import v6ToV1 = uuid.v6ToV1;
|
||||
export import v7 = uuid.v7;
|
||||
export import NIL = uuid.NIL;
|
||||
export import MAX = uuid.MAX;
|
||||
export import version = uuid.version;
|
||||
export import validate = uuid.validate;
|
||||
export import stringify = uuid.stringify;
|
||||
export import parse = uuid.parse;
|
||||
export import V1Options = uuid.V1Options;
|
||||
export import V4Options = uuid.V4Options;
|
||||
export import V6Options = uuid.V6Options;
|
||||
export import V7Options = uuid.V7Options;
|
||||
Generated
Vendored
+54
@@ -0,0 +1,54 @@
|
||||
{
|
||||
"name": "@types/uuid",
|
||||
"version": "10.0.0",
|
||||
"description": "TypeScript definitions for uuid",
|
||||
"homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/uuid",
|
||||
"license": "MIT",
|
||||
"contributors": [
|
||||
{
|
||||
"name": "Oliver Hoffmann",
|
||||
"githubUsername": "iamolivinius",
|
||||
"url": "https://github.com/iamolivinius"
|
||||
},
|
||||
{
|
||||
"name": "Felipe Ochoa",
|
||||
"githubUsername": "felipeochoa",
|
||||
"url": "https://github.com/felipeochoa"
|
||||
},
|
||||
{
|
||||
"name": "Chris Barth",
|
||||
"githubUsername": "cjbarth",
|
||||
"url": "https://github.com/cjbarth"
|
||||
},
|
||||
{
|
||||
"name": "Linus Unnebäck",
|
||||
"githubUsername": "LinusU",
|
||||
"url": "https://github.com/LinusU"
|
||||
},
|
||||
{
|
||||
"name": "Christoph Tavan",
|
||||
"githubUsername": "ctavan",
|
||||
"url": "https://github.com/ctavan"
|
||||
}
|
||||
],
|
||||
"main": "",
|
||||
"types": "index.d.ts",
|
||||
"exports": {
|
||||
"./package.json": "./package.json",
|
||||
".": {
|
||||
"types": {
|
||||
"import": "./index.d.mts",
|
||||
"default": "./index.d.ts"
|
||||
}
|
||||
}
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/DefinitelyTyped/DefinitelyTyped.git",
|
||||
"directory": "types/uuid"
|
||||
},
|
||||
"scripts": {},
|
||||
"dependencies": {},
|
||||
"typesPublisherContentHash": "08fbc5ff7d23aaac1e81b5acf98181d2544ce6ffd5578e9879e2a75f0c087d54",
|
||||
"typeScriptVersion": "4.7"
|
||||
}
|
||||
Generated
Vendored
+2
@@ -0,0 +1,2 @@
|
||||
#!/usr/bin/env node
|
||||
import '../uuid-bin.js';
|
||||
Generated
Vendored
+14
@@ -0,0 +1,14 @@
|
||||
export { default as MAX } from './max.js';
|
||||
export { default as NIL } from './nil.js';
|
||||
export { default as parse } from './parse.js';
|
||||
export { default as stringify } from './stringify.js';
|
||||
export { default as v1 } from './v1.js';
|
||||
export { default as v1ToV6 } from './v1ToV6.js';
|
||||
export { default as v3 } from './v3.js';
|
||||
export { default as v4 } from './v4.js';
|
||||
export { default as v5 } from './v5.js';
|
||||
export { default as v6 } from './v6.js';
|
||||
export { default as v6ToV1 } from './v6ToV1.js';
|
||||
export { default as v7 } from './v7.js';
|
||||
export { default as validate } from './validate.js';
|
||||
export { default as version } from './version.js';
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
export default 'ffffffff-ffff-ffff-ffff-ffffffffffff';
|
||||
Generated
Vendored
+11
@@ -0,0 +1,11 @@
|
||||
import { createHash } from 'node:crypto';
|
||||
function md5(bytes) {
|
||||
if (Array.isArray(bytes)) {
|
||||
bytes = Buffer.from(bytes);
|
||||
}
|
||||
else if (typeof bytes === 'string') {
|
||||
bytes = Buffer.from(bytes, 'utf8');
|
||||
}
|
||||
return createHash('md5').update(bytes).digest();
|
||||
}
|
||||
export default md5;
|
||||
Generated
Vendored
+2
@@ -0,0 +1,2 @@
|
||||
import { randomUUID } from 'node:crypto';
|
||||
export default { randomUUID };
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
export default '00000000-0000-0000-0000-000000000000';
|
||||
Generated
Vendored
+9
@@ -0,0 +1,9 @@
|
||||
import validate from './validate.js';
|
||||
function parse(uuid) {
|
||||
if (!validate(uuid)) {
|
||||
throw TypeError('Invalid UUID');
|
||||
}
|
||||
let v;
|
||||
return Uint8Array.of((v = parseInt(uuid.slice(0, 8), 16)) >>> 24, (v >>> 16) & 0xff, (v >>> 8) & 0xff, v & 0xff, (v = parseInt(uuid.slice(9, 13), 16)) >>> 8, v & 0xff, (v = parseInt(uuid.slice(14, 18), 16)) >>> 8, v & 0xff, (v = parseInt(uuid.slice(19, 23), 16)) >>> 8, v & 0xff, ((v = parseInt(uuid.slice(24, 36), 16)) / 0x10000000000) & 0xff, (v / 0x100000000) & 0xff, (v >>> 24) & 0xff, (v >>> 16) & 0xff, (v >>> 8) & 0xff, v & 0xff);
|
||||
}
|
||||
export default parse;
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
export default /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/i;
|
||||
Generated
Vendored
+10
@@ -0,0 +1,10 @@
|
||||
import { randomFillSync } from 'node:crypto';
|
||||
const rnds8Pool = new Uint8Array(256);
|
||||
let poolPtr = rnds8Pool.length;
|
||||
export default function rng() {
|
||||
if (poolPtr > rnds8Pool.length - 16) {
|
||||
randomFillSync(rnds8Pool);
|
||||
poolPtr = 0;
|
||||
}
|
||||
return rnds8Pool.slice(poolPtr, (poolPtr += 16));
|
||||
}
|
||||
Generated
Vendored
+11
@@ -0,0 +1,11 @@
|
||||
import { createHash } from 'node:crypto';
|
||||
function sha1(bytes) {
|
||||
if (Array.isArray(bytes)) {
|
||||
bytes = Buffer.from(bytes);
|
||||
}
|
||||
else if (typeof bytes === 'string') {
|
||||
bytes = Buffer.from(bytes, 'utf8');
|
||||
}
|
||||
return createHash('sha1').update(bytes).digest();
|
||||
}
|
||||
export default sha1;
|
||||
Generated
Vendored
+35
@@ -0,0 +1,35 @@
|
||||
import validate from './validate.js';
|
||||
const byteToHex = [];
|
||||
for (let i = 0; i < 256; ++i) {
|
||||
byteToHex.push((i + 0x100).toString(16).slice(1));
|
||||
}
|
||||
export function unsafeStringify(arr, offset = 0) {
|
||||
return (byteToHex[arr[offset + 0]] +
|
||||
byteToHex[arr[offset + 1]] +
|
||||
byteToHex[arr[offset + 2]] +
|
||||
byteToHex[arr[offset + 3]] +
|
||||
'-' +
|
||||
byteToHex[arr[offset + 4]] +
|
||||
byteToHex[arr[offset + 5]] +
|
||||
'-' +
|
||||
byteToHex[arr[offset + 6]] +
|
||||
byteToHex[arr[offset + 7]] +
|
||||
'-' +
|
||||
byteToHex[arr[offset + 8]] +
|
||||
byteToHex[arr[offset + 9]] +
|
||||
'-' +
|
||||
byteToHex[arr[offset + 10]] +
|
||||
byteToHex[arr[offset + 11]] +
|
||||
byteToHex[arr[offset + 12]] +
|
||||
byteToHex[arr[offset + 13]] +
|
||||
byteToHex[arr[offset + 14]] +
|
||||
byteToHex[arr[offset + 15]]).toLowerCase();
|
||||
}
|
||||
function stringify(arr, offset = 0) {
|
||||
const uuid = unsafeStringify(arr, offset);
|
||||
if (!validate(uuid)) {
|
||||
throw TypeError('Stringified UUID is invalid');
|
||||
}
|
||||
return uuid;
|
||||
}
|
||||
export default stringify;
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
export {};
|
||||
Generated
Vendored
+70
@@ -0,0 +1,70 @@
|
||||
import * as assert from 'node:assert/strict';
|
||||
import v1 from './v1.js';
|
||||
import v3 from './v3.js';
|
||||
import v4 from './v4.js';
|
||||
import v5 from './v5.js';
|
||||
import v6 from './v6.js';
|
||||
import v7 from './v7.js';
|
||||
function usage() {
|
||||
console.log('Usage:');
|
||||
console.log(' uuid');
|
||||
console.log(' uuid v1');
|
||||
console.log(' uuid v3 <name> <namespace uuid>');
|
||||
console.log(' uuid v4');
|
||||
console.log(' uuid v5 <name> <namespace uuid>');
|
||||
console.log(' uuid v6');
|
||||
console.log(' uuid v7');
|
||||
console.log(' uuid --help');
|
||||
console.log('\nNote: <namespace uuid> may be "URL" or "DNS" to use the corresponding UUIDs defined by RFC9562');
|
||||
}
|
||||
const args = process.argv.slice(2);
|
||||
if (args.indexOf('--help') >= 0) {
|
||||
usage();
|
||||
process.exit(0);
|
||||
}
|
||||
const version = args.shift() || 'v4';
|
||||
switch (version) {
|
||||
case 'v1':
|
||||
console.log(v1());
|
||||
break;
|
||||
case 'v3': {
|
||||
const name = args.shift();
|
||||
let namespace = args.shift();
|
||||
assert.ok(name != null, 'v3 name not specified');
|
||||
assert.ok(namespace != null, 'v3 namespace not specified');
|
||||
if (namespace === 'URL') {
|
||||
namespace = v3.URL;
|
||||
}
|
||||
if (namespace === 'DNS') {
|
||||
namespace = v3.DNS;
|
||||
}
|
||||
console.log(v3(name, namespace));
|
||||
break;
|
||||
}
|
||||
case 'v4':
|
||||
console.log(v4());
|
||||
break;
|
||||
case 'v5': {
|
||||
const name = args.shift();
|
||||
let namespace = args.shift();
|
||||
assert.ok(name != null, 'v5 name not specified');
|
||||
assert.ok(namespace != null, 'v5 namespace not specified');
|
||||
if (namespace === 'URL') {
|
||||
namespace = v5.URL;
|
||||
}
|
||||
if (namespace === 'DNS') {
|
||||
namespace = v5.DNS;
|
||||
}
|
||||
console.log(v5(name, namespace));
|
||||
break;
|
||||
}
|
||||
case 'v6':
|
||||
console.log(v6());
|
||||
break;
|
||||
case 'v7':
|
||||
console.log(v7());
|
||||
break;
|
||||
default:
|
||||
usage();
|
||||
process.exit(1);
|
||||
}
|
||||
Generated
Vendored
+83
@@ -0,0 +1,83 @@
|
||||
import rng from './rng.js';
|
||||
import { unsafeStringify } from './stringify.js';
|
||||
const _state = {};
|
||||
function v1(options, buf, offset) {
|
||||
let bytes;
|
||||
const isV6 = options?._v6 ?? false;
|
||||
if (options) {
|
||||
const optionsKeys = Object.keys(options);
|
||||
if (optionsKeys.length === 1 && optionsKeys[0] === '_v6') {
|
||||
options = undefined;
|
||||
}
|
||||
}
|
||||
if (options) {
|
||||
bytes = v1Bytes(options.random ?? options.rng?.() ?? rng(), options.msecs, options.nsecs, options.clockseq, options.node, buf, offset);
|
||||
}
|
||||
else {
|
||||
const now = Date.now();
|
||||
const rnds = rng();
|
||||
updateV1State(_state, now, rnds);
|
||||
bytes = v1Bytes(rnds, _state.msecs, _state.nsecs, isV6 ? undefined : _state.clockseq, isV6 ? undefined : _state.node, buf, offset);
|
||||
}
|
||||
return buf ?? unsafeStringify(bytes);
|
||||
}
|
||||
export function updateV1State(state, now, rnds) {
|
||||
state.msecs ??= -Infinity;
|
||||
state.nsecs ??= 0;
|
||||
if (now === state.msecs) {
|
||||
state.nsecs++;
|
||||
if (state.nsecs >= 10000) {
|
||||
state.node = undefined;
|
||||
state.nsecs = 0;
|
||||
}
|
||||
}
|
||||
else if (now > state.msecs) {
|
||||
state.nsecs = 0;
|
||||
}
|
||||
else if (now < state.msecs) {
|
||||
state.node = undefined;
|
||||
}
|
||||
if (!state.node) {
|
||||
state.node = rnds.slice(10, 16);
|
||||
state.node[0] |= 0x01;
|
||||
state.clockseq = ((rnds[8] << 8) | rnds[9]) & 0x3fff;
|
||||
}
|
||||
state.msecs = now;
|
||||
return state;
|
||||
}
|
||||
function v1Bytes(rnds, msecs, nsecs, clockseq, node, buf, offset = 0) {
|
||||
if (rnds.length < 16) {
|
||||
throw new Error('Random bytes length must be >= 16');
|
||||
}
|
||||
if (!buf) {
|
||||
buf = new Uint8Array(16);
|
||||
offset = 0;
|
||||
}
|
||||
else {
|
||||
if (offset < 0 || offset + 16 > buf.length) {
|
||||
throw new RangeError(`UUID byte range ${offset}:${offset + 15} is out of buffer bounds`);
|
||||
}
|
||||
}
|
||||
msecs ??= Date.now();
|
||||
nsecs ??= 0;
|
||||
clockseq ??= ((rnds[8] << 8) | rnds[9]) & 0x3fff;
|
||||
node ??= rnds.slice(10, 16);
|
||||
msecs += 12219292800000;
|
||||
const tl = ((msecs & 0xfffffff) * 10000 + nsecs) % 0x100000000;
|
||||
buf[offset++] = (tl >>> 24) & 0xff;
|
||||
buf[offset++] = (tl >>> 16) & 0xff;
|
||||
buf[offset++] = (tl >>> 8) & 0xff;
|
||||
buf[offset++] = tl & 0xff;
|
||||
const tmh = ((msecs / 0x100000000) * 10000) & 0xfffffff;
|
||||
buf[offset++] = (tmh >>> 8) & 0xff;
|
||||
buf[offset++] = tmh & 0xff;
|
||||
buf[offset++] = ((tmh >>> 24) & 0xf) | 0x10;
|
||||
buf[offset++] = (tmh >>> 16) & 0xff;
|
||||
buf[offset++] = (clockseq >>> 8) | 0x80;
|
||||
buf[offset++] = clockseq & 0xff;
|
||||
for (let n = 0; n < 6; ++n) {
|
||||
buf[offset++] = node[n];
|
||||
}
|
||||
return buf;
|
||||
}
|
||||
export default v1;
|
||||
Generated
Vendored
+10
@@ -0,0 +1,10 @@
|
||||
import parse from './parse.js';
|
||||
import { unsafeStringify } from './stringify.js';
|
||||
export default function v1ToV6(uuid) {
|
||||
const v1Bytes = typeof uuid === 'string' ? parse(uuid) : uuid;
|
||||
const v6Bytes = _v1ToV6(v1Bytes);
|
||||
return typeof uuid === 'string' ? unsafeStringify(v6Bytes) : v6Bytes;
|
||||
}
|
||||
function _v1ToV6(v1Bytes) {
|
||||
return Uint8Array.of(((v1Bytes[6] & 0x0f) << 4) | ((v1Bytes[7] >> 4) & 0x0f), ((v1Bytes[7] & 0x0f) << 4) | ((v1Bytes[4] & 0xf0) >> 4), ((v1Bytes[4] & 0x0f) << 4) | ((v1Bytes[5] & 0xf0) >> 4), ((v1Bytes[5] & 0x0f) << 4) | ((v1Bytes[0] & 0xf0) >> 4), ((v1Bytes[0] & 0x0f) << 4) | ((v1Bytes[1] & 0xf0) >> 4), ((v1Bytes[1] & 0x0f) << 4) | ((v1Bytes[2] & 0xf0) >> 4), 0x60 | (v1Bytes[2] & 0x0f), v1Bytes[3], v1Bytes[8], v1Bytes[9], v1Bytes[10], v1Bytes[11], v1Bytes[12], v1Bytes[13], v1Bytes[14], v1Bytes[15]);
|
||||
}
|
||||
Generated
Vendored
+9
@@ -0,0 +1,9 @@
|
||||
import md5 from './md5.js';
|
||||
import v35, { DNS, URL } from './v35.js';
|
||||
export { DNS, URL } from './v35.js';
|
||||
function v3(value, namespace, buf, offset) {
|
||||
return v35(0x30, md5, value, namespace, buf, offset);
|
||||
}
|
||||
v3.DNS = DNS;
|
||||
v3.URL = URL;
|
||||
export default v3;
|
||||
Generated
Vendored
+36
@@ -0,0 +1,36 @@
|
||||
import parse from './parse.js';
|
||||
import { unsafeStringify } from './stringify.js';
|
||||
export function stringToBytes(str) {
|
||||
str = unescape(encodeURIComponent(str));
|
||||
const bytes = new Uint8Array(str.length);
|
||||
for (let i = 0; i < str.length; ++i) {
|
||||
bytes[i] = str.charCodeAt(i);
|
||||
}
|
||||
return bytes;
|
||||
}
|
||||
export const DNS = '6ba7b810-9dad-11d1-80b4-00c04fd430c8';
|
||||
export const URL = '6ba7b811-9dad-11d1-80b4-00c04fd430c8';
|
||||
export default function v35(version, hash, value, namespace, buf, offset) {
|
||||
const valueBytes = typeof value === 'string' ? stringToBytes(value) : value;
|
||||
const namespaceBytes = typeof namespace === 'string' ? parse(namespace) : namespace;
|
||||
if (typeof namespace === 'string') {
|
||||
namespace = parse(namespace);
|
||||
}
|
||||
if (namespace?.length !== 16) {
|
||||
throw TypeError('Namespace must be array-like (16 iterable integer values, 0-255)');
|
||||
}
|
||||
let bytes = new Uint8Array(16 + valueBytes.length);
|
||||
bytes.set(namespaceBytes);
|
||||
bytes.set(valueBytes, namespaceBytes.length);
|
||||
bytes = hash(bytes);
|
||||
bytes[6] = (bytes[6] & 0x0f) | version;
|
||||
bytes[8] = (bytes[8] & 0x3f) | 0x80;
|
||||
if (buf) {
|
||||
offset = offset || 0;
|
||||
for (let i = 0; i < 16; ++i) {
|
||||
buf[offset + i] = bytes[i];
|
||||
}
|
||||
return buf;
|
||||
}
|
||||
return unsafeStringify(bytes);
|
||||
}
|
||||
Generated
Vendored
+30
@@ -0,0 +1,30 @@
|
||||
import native from './native.js';
|
||||
import rng from './rng.js';
|
||||
import { unsafeStringify } from './stringify.js';
|
||||
function _v4(options, buf, offset) {
|
||||
options = options || {};
|
||||
const rnds = options.random ?? options.rng?.() ?? rng();
|
||||
if (rnds.length < 16) {
|
||||
throw new Error('Random bytes length must be >= 16');
|
||||
}
|
||||
rnds[6] = (rnds[6] & 0x0f) | 0x40;
|
||||
rnds[8] = (rnds[8] & 0x3f) | 0x80;
|
||||
if (buf) {
|
||||
offset = offset || 0;
|
||||
if (offset < 0 || offset + 16 > buf.length) {
|
||||
throw new RangeError(`UUID byte range ${offset}:${offset + 15} is out of buffer bounds`);
|
||||
}
|
||||
for (let i = 0; i < 16; ++i) {
|
||||
buf[offset + i] = rnds[i];
|
||||
}
|
||||
return buf;
|
||||
}
|
||||
return unsafeStringify(rnds);
|
||||
}
|
||||
function v4(options, buf, offset) {
|
||||
if (native.randomUUID && !buf && !options) {
|
||||
return native.randomUUID();
|
||||
}
|
||||
return _v4(options, buf, offset);
|
||||
}
|
||||
export default v4;
|
||||
Generated
Vendored
+9
@@ -0,0 +1,9 @@
|
||||
import sha1 from './sha1.js';
|
||||
import v35, { DNS, URL } from './v35.js';
|
||||
export { DNS, URL } from './v35.js';
|
||||
function v5(value, namespace, buf, offset) {
|
||||
return v35(0x50, sha1, value, namespace, buf, offset);
|
||||
}
|
||||
v5.DNS = DNS;
|
||||
v5.URL = URL;
|
||||
export default v5;
|
||||
Generated
Vendored
+17
@@ -0,0 +1,17 @@
|
||||
import { unsafeStringify } from './stringify.js';
|
||||
import v1 from './v1.js';
|
||||
import v1ToV6 from './v1ToV6.js';
|
||||
function v6(options, buf, offset) {
|
||||
options ??= {};
|
||||
offset ??= 0;
|
||||
let bytes = v1({ ...options, _v6: true }, new Uint8Array(16));
|
||||
bytes = v1ToV6(bytes);
|
||||
if (buf) {
|
||||
for (let i = 0; i < 16; i++) {
|
||||
buf[offset + i] = bytes[i];
|
||||
}
|
||||
return buf;
|
||||
}
|
||||
return unsafeStringify(bytes);
|
||||
}
|
||||
export default v6;
|
||||
Generated
Vendored
+10
@@ -0,0 +1,10 @@
|
||||
import parse from './parse.js';
|
||||
import { unsafeStringify } from './stringify.js';
|
||||
export default function v6ToV1(uuid) {
|
||||
const v6Bytes = typeof uuid === 'string' ? parse(uuid) : uuid;
|
||||
const v1Bytes = _v6ToV1(v6Bytes);
|
||||
return typeof uuid === 'string' ? unsafeStringify(v1Bytes) : v1Bytes;
|
||||
}
|
||||
function _v6ToV1(v6Bytes) {
|
||||
return Uint8Array.of(((v6Bytes[3] & 0x0f) << 4) | ((v6Bytes[4] >> 4) & 0x0f), ((v6Bytes[4] & 0x0f) << 4) | ((v6Bytes[5] & 0xf0) >> 4), ((v6Bytes[5] & 0x0f) << 4) | (v6Bytes[6] & 0x0f), v6Bytes[7], ((v6Bytes[1] & 0x0f) << 4) | ((v6Bytes[2] & 0xf0) >> 4), ((v6Bytes[2] & 0x0f) << 4) | ((v6Bytes[3] & 0xf0) >> 4), 0x10 | ((v6Bytes[0] & 0xf0) >> 4), ((v6Bytes[0] & 0x0f) << 4) | ((v6Bytes[1] & 0xf0) >> 4), v6Bytes[8], v6Bytes[9], v6Bytes[10], v6Bytes[11], v6Bytes[12], v6Bytes[13], v6Bytes[14], v6Bytes[15]);
|
||||
}
|
||||
Generated
Vendored
+65
@@ -0,0 +1,65 @@
|
||||
import rng from './rng.js';
|
||||
import { unsafeStringify } from './stringify.js';
|
||||
const _state = {};
|
||||
function v7(options, buf, offset) {
|
||||
let bytes;
|
||||
if (options) {
|
||||
bytes = v7Bytes(options.random ?? options.rng?.() ?? rng(), options.msecs, options.seq, buf, offset);
|
||||
}
|
||||
else {
|
||||
const now = Date.now();
|
||||
const rnds = rng();
|
||||
updateV7State(_state, now, rnds);
|
||||
bytes = v7Bytes(rnds, _state.msecs, _state.seq, buf, offset);
|
||||
}
|
||||
return buf ?? unsafeStringify(bytes);
|
||||
}
|
||||
export function updateV7State(state, now, rnds) {
|
||||
state.msecs ??= -Infinity;
|
||||
state.seq ??= 0;
|
||||
if (now > state.msecs) {
|
||||
state.seq = (rnds[6] << 23) | (rnds[7] << 16) | (rnds[8] << 8) | rnds[9];
|
||||
state.msecs = now;
|
||||
}
|
||||
else {
|
||||
state.seq = (state.seq + 1) | 0;
|
||||
if (state.seq === 0) {
|
||||
state.msecs++;
|
||||
}
|
||||
}
|
||||
return state;
|
||||
}
|
||||
function v7Bytes(rnds, msecs, seq, buf, offset = 0) {
|
||||
if (rnds.length < 16) {
|
||||
throw new Error('Random bytes length must be >= 16');
|
||||
}
|
||||
if (!buf) {
|
||||
buf = new Uint8Array(16);
|
||||
offset = 0;
|
||||
}
|
||||
else {
|
||||
if (offset < 0 || offset + 16 > buf.length) {
|
||||
throw new RangeError(`UUID byte range ${offset}:${offset + 15} is out of buffer bounds`);
|
||||
}
|
||||
}
|
||||
msecs ??= Date.now();
|
||||
seq ??= ((rnds[6] * 0x7f) << 24) | (rnds[7] << 16) | (rnds[8] << 8) | rnds[9];
|
||||
buf[offset++] = (msecs / 0x10000000000) & 0xff;
|
||||
buf[offset++] = (msecs / 0x100000000) & 0xff;
|
||||
buf[offset++] = (msecs / 0x1000000) & 0xff;
|
||||
buf[offset++] = (msecs / 0x10000) & 0xff;
|
||||
buf[offset++] = (msecs / 0x100) & 0xff;
|
||||
buf[offset++] = msecs & 0xff;
|
||||
buf[offset++] = 0x70 | ((seq >>> 28) & 0x0f);
|
||||
buf[offset++] = (seq >>> 20) & 0xff;
|
||||
buf[offset++] = 0x80 | ((seq >>> 14) & 0x3f);
|
||||
buf[offset++] = (seq >>> 6) & 0xff;
|
||||
buf[offset++] = ((seq << 2) & 0xff) | (rnds[10] & 0x03);
|
||||
buf[offset++] = rnds[11];
|
||||
buf[offset++] = rnds[12];
|
||||
buf[offset++] = rnds[13];
|
||||
buf[offset++] = rnds[14];
|
||||
buf[offset++] = rnds[15];
|
||||
return buf;
|
||||
}
|
||||
export default v7;
|
||||
Generated
Vendored
+5
@@ -0,0 +1,5 @@
|
||||
import REGEX from './regex.js';
|
||||
function validate(uuid) {
|
||||
return typeof uuid === 'string' && REGEX.test(uuid);
|
||||
}
|
||||
export default validate;
|
||||
assets/dotfiles/vscode-extensions/jdunkel.patternstore-0.1.12/node_modules/uuid/dist-node/version.js
Generated
Vendored
+8
@@ -0,0 +1,8 @@
|
||||
import validate from './validate.js';
|
||||
function version(uuid) {
|
||||
if (!validate(uuid)) {
|
||||
throw TypeError('Invalid UUID');
|
||||
}
|
||||
return parseInt(uuid.slice(14, 15), 16);
|
||||
}
|
||||
export default version;
|
||||
Generated
Vendored
+14
@@ -0,0 +1,14 @@
|
||||
export { default as MAX } from './max.js';
|
||||
export { default as NIL } from './nil.js';
|
||||
export { default as parse } from './parse.js';
|
||||
export { default as stringify } from './stringify.js';
|
||||
export { default as v1 } from './v1.js';
|
||||
export { default as v1ToV6 } from './v1ToV6.js';
|
||||
export { default as v3 } from './v3.js';
|
||||
export { default as v4 } from './v4.js';
|
||||
export { default as v5 } from './v5.js';
|
||||
export { default as v6 } from './v6.js';
|
||||
export { default as v6ToV1 } from './v6ToV1.js';
|
||||
export { default as v7 } from './v7.js';
|
||||
export { default as validate } from './validate.js';
|
||||
export { default as version } from './version.js';
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
export default 'ffffffff-ffff-ffff-ffff-ffffffffffff';
|
||||
Generated
Vendored
+135
@@ -0,0 +1,135 @@
|
||||
function md5(bytes) {
|
||||
const words = uint8ToUint32(bytes);
|
||||
const md5Bytes = wordsToMd5(words, bytes.length * 8);
|
||||
return uint32ToUint8(md5Bytes);
|
||||
}
|
||||
function uint32ToUint8(input) {
|
||||
const bytes = new Uint8Array(input.length * 4);
|
||||
for (let i = 0; i < input.length * 4; i++) {
|
||||
bytes[i] = (input[i >> 2] >>> ((i % 4) * 8)) & 0xff;
|
||||
}
|
||||
return bytes;
|
||||
}
|
||||
function getOutputLength(inputLength8) {
|
||||
return (((inputLength8 + 64) >>> 9) << 4) + 14 + 1;
|
||||
}
|
||||
function wordsToMd5(x, len) {
|
||||
const xpad = new Uint32Array(getOutputLength(len)).fill(0);
|
||||
xpad.set(x);
|
||||
xpad[len >> 5] |= 0x80 << len % 32;
|
||||
xpad[xpad.length - 1] = len;
|
||||
x = xpad;
|
||||
let a = 1732584193;
|
||||
let b = -271733879;
|
||||
let c = -1732584194;
|
||||
let d = 271733878;
|
||||
for (let i = 0; i < x.length; i += 16) {
|
||||
const olda = a;
|
||||
const oldb = b;
|
||||
const oldc = c;
|
||||
const oldd = d;
|
||||
a = md5ff(a, b, c, d, x[i], 7, -680876936);
|
||||
d = md5ff(d, a, b, c, x[i + 1], 12, -389564586);
|
||||
c = md5ff(c, d, a, b, x[i + 2], 17, 606105819);
|
||||
b = md5ff(b, c, d, a, x[i + 3], 22, -1044525330);
|
||||
a = md5ff(a, b, c, d, x[i + 4], 7, -176418897);
|
||||
d = md5ff(d, a, b, c, x[i + 5], 12, 1200080426);
|
||||
c = md5ff(c, d, a, b, x[i + 6], 17, -1473231341);
|
||||
b = md5ff(b, c, d, a, x[i + 7], 22, -45705983);
|
||||
a = md5ff(a, b, c, d, x[i + 8], 7, 1770035416);
|
||||
d = md5ff(d, a, b, c, x[i + 9], 12, -1958414417);
|
||||
c = md5ff(c, d, a, b, x[i + 10], 17, -42063);
|
||||
b = md5ff(b, c, d, a, x[i + 11], 22, -1990404162);
|
||||
a = md5ff(a, b, c, d, x[i + 12], 7, 1804603682);
|
||||
d = md5ff(d, a, b, c, x[i + 13], 12, -40341101);
|
||||
c = md5ff(c, d, a, b, x[i + 14], 17, -1502002290);
|
||||
b = md5ff(b, c, d, a, x[i + 15], 22, 1236535329);
|
||||
a = md5gg(a, b, c, d, x[i + 1], 5, -165796510);
|
||||
d = md5gg(d, a, b, c, x[i + 6], 9, -1069501632);
|
||||
c = md5gg(c, d, a, b, x[i + 11], 14, 643717713);
|
||||
b = md5gg(b, c, d, a, x[i], 20, -373897302);
|
||||
a = md5gg(a, b, c, d, x[i + 5], 5, -701558691);
|
||||
d = md5gg(d, a, b, c, x[i + 10], 9, 38016083);
|
||||
c = md5gg(c, d, a, b, x[i + 15], 14, -660478335);
|
||||
b = md5gg(b, c, d, a, x[i + 4], 20, -405537848);
|
||||
a = md5gg(a, b, c, d, x[i + 9], 5, 568446438);
|
||||
d = md5gg(d, a, b, c, x[i + 14], 9, -1019803690);
|
||||
c = md5gg(c, d, a, b, x[i + 3], 14, -187363961);
|
||||
b = md5gg(b, c, d, a, x[i + 8], 20, 1163531501);
|
||||
a = md5gg(a, b, c, d, x[i + 13], 5, -1444681467);
|
||||
d = md5gg(d, a, b, c, x[i + 2], 9, -51403784);
|
||||
c = md5gg(c, d, a, b, x[i + 7], 14, 1735328473);
|
||||
b = md5gg(b, c, d, a, x[i + 12], 20, -1926607734);
|
||||
a = md5hh(a, b, c, d, x[i + 5], 4, -378558);
|
||||
d = md5hh(d, a, b, c, x[i + 8], 11, -2022574463);
|
||||
c = md5hh(c, d, a, b, x[i + 11], 16, 1839030562);
|
||||
b = md5hh(b, c, d, a, x[i + 14], 23, -35309556);
|
||||
a = md5hh(a, b, c, d, x[i + 1], 4, -1530992060);
|
||||
d = md5hh(d, a, b, c, x[i + 4], 11, 1272893353);
|
||||
c = md5hh(c, d, a, b, x[i + 7], 16, -155497632);
|
||||
b = md5hh(b, c, d, a, x[i + 10], 23, -1094730640);
|
||||
a = md5hh(a, b, c, d, x[i + 13], 4, 681279174);
|
||||
d = md5hh(d, a, b, c, x[i], 11, -358537222);
|
||||
c = md5hh(c, d, a, b, x[i + 3], 16, -722521979);
|
||||
b = md5hh(b, c, d, a, x[i + 6], 23, 76029189);
|
||||
a = md5hh(a, b, c, d, x[i + 9], 4, -640364487);
|
||||
d = md5hh(d, a, b, c, x[i + 12], 11, -421815835);
|
||||
c = md5hh(c, d, a, b, x[i + 15], 16, 530742520);
|
||||
b = md5hh(b, c, d, a, x[i + 2], 23, -995338651);
|
||||
a = md5ii(a, b, c, d, x[i], 6, -198630844);
|
||||
d = md5ii(d, a, b, c, x[i + 7], 10, 1126891415);
|
||||
c = md5ii(c, d, a, b, x[i + 14], 15, -1416354905);
|
||||
b = md5ii(b, c, d, a, x[i + 5], 21, -57434055);
|
||||
a = md5ii(a, b, c, d, x[i + 12], 6, 1700485571);
|
||||
d = md5ii(d, a, b, c, x[i + 3], 10, -1894986606);
|
||||
c = md5ii(c, d, a, b, x[i + 10], 15, -1051523);
|
||||
b = md5ii(b, c, d, a, x[i + 1], 21, -2054922799);
|
||||
a = md5ii(a, b, c, d, x[i + 8], 6, 1873313359);
|
||||
d = md5ii(d, a, b, c, x[i + 15], 10, -30611744);
|
||||
c = md5ii(c, d, a, b, x[i + 6], 15, -1560198380);
|
||||
b = md5ii(b, c, d, a, x[i + 13], 21, 1309151649);
|
||||
a = md5ii(a, b, c, d, x[i + 4], 6, -145523070);
|
||||
d = md5ii(d, a, b, c, x[i + 11], 10, -1120210379);
|
||||
c = md5ii(c, d, a, b, x[i + 2], 15, 718787259);
|
||||
b = md5ii(b, c, d, a, x[i + 9], 21, -343485551);
|
||||
a = safeAdd(a, olda);
|
||||
b = safeAdd(b, oldb);
|
||||
c = safeAdd(c, oldc);
|
||||
d = safeAdd(d, oldd);
|
||||
}
|
||||
return Uint32Array.of(a, b, c, d);
|
||||
}
|
||||
function uint8ToUint32(input) {
|
||||
if (input.length === 0) {
|
||||
return new Uint32Array();
|
||||
}
|
||||
const output = new Uint32Array(getOutputLength(input.length * 8)).fill(0);
|
||||
for (let i = 0; i < input.length; i++) {
|
||||
output[i >> 2] |= (input[i] & 0xff) << ((i % 4) * 8);
|
||||
}
|
||||
return output;
|
||||
}
|
||||
function safeAdd(x, y) {
|
||||
const lsw = (x & 0xffff) + (y & 0xffff);
|
||||
const msw = (x >> 16) + (y >> 16) + (lsw >> 16);
|
||||
return (msw << 16) | (lsw & 0xffff);
|
||||
}
|
||||
function bitRotateLeft(num, cnt) {
|
||||
return (num << cnt) | (num >>> (32 - cnt));
|
||||
}
|
||||
function md5cmn(q, a, b, x, s, t) {
|
||||
return safeAdd(bitRotateLeft(safeAdd(safeAdd(a, q), safeAdd(x, t)), s), b);
|
||||
}
|
||||
function md5ff(a, b, c, d, x, s, t) {
|
||||
return md5cmn((b & c) | (~b & d), a, b, x, s, t);
|
||||
}
|
||||
function md5gg(a, b, c, d, x, s, t) {
|
||||
return md5cmn((b & d) | (c & ~d), a, b, x, s, t);
|
||||
}
|
||||
function md5hh(a, b, c, d, x, s, t) {
|
||||
return md5cmn(b ^ c ^ d, a, b, x, s, t);
|
||||
}
|
||||
function md5ii(a, b, c, d, x, s, t) {
|
||||
return md5cmn(c ^ (b | ~d), a, b, x, s, t);
|
||||
}
|
||||
export default md5;
|
||||
Generated
Vendored
+2
@@ -0,0 +1,2 @@
|
||||
const randomUUID = typeof crypto !== 'undefined' && crypto.randomUUID && crypto.randomUUID.bind(crypto);
|
||||
export default { randomUUID };
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
export default '00000000-0000-0000-0000-000000000000';
|
||||
Generated
Vendored
+9
@@ -0,0 +1,9 @@
|
||||
import validate from './validate.js';
|
||||
function parse(uuid) {
|
||||
if (!validate(uuid)) {
|
||||
throw TypeError('Invalid UUID');
|
||||
}
|
||||
let v;
|
||||
return Uint8Array.of((v = parseInt(uuid.slice(0, 8), 16)) >>> 24, (v >>> 16) & 0xff, (v >>> 8) & 0xff, v & 0xff, (v = parseInt(uuid.slice(9, 13), 16)) >>> 8, v & 0xff, (v = parseInt(uuid.slice(14, 18), 16)) >>> 8, v & 0xff, (v = parseInt(uuid.slice(19, 23), 16)) >>> 8, v & 0xff, ((v = parseInt(uuid.slice(24, 36), 16)) / 0x10000000000) & 0xff, (v / 0x100000000) & 0xff, (v >>> 24) & 0xff, (v >>> 16) & 0xff, (v >>> 8) & 0xff, v & 0xff);
|
||||
}
|
||||
export default parse;
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
export default /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/i;
|
||||
Generated
Vendored
+11
@@ -0,0 +1,11 @@
|
||||
let getRandomValues;
|
||||
const rnds8 = new Uint8Array(16);
|
||||
export default function rng() {
|
||||
if (!getRandomValues) {
|
||||
if (typeof crypto === 'undefined' || !crypto.getRandomValues) {
|
||||
throw new Error('crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported');
|
||||
}
|
||||
getRandomValues = crypto.getRandomValues.bind(crypto);
|
||||
}
|
||||
return getRandomValues(rnds8);
|
||||
}
|
||||
Generated
Vendored
+70
@@ -0,0 +1,70 @@
|
||||
function f(s, x, y, z) {
|
||||
switch (s) {
|
||||
case 0:
|
||||
return (x & y) ^ (~x & z);
|
||||
case 1:
|
||||
return x ^ y ^ z;
|
||||
case 2:
|
||||
return (x & y) ^ (x & z) ^ (y & z);
|
||||
case 3:
|
||||
return x ^ y ^ z;
|
||||
}
|
||||
}
|
||||
function ROTL(x, n) {
|
||||
return (x << n) | (x >>> (32 - n));
|
||||
}
|
||||
function sha1(bytes) {
|
||||
const K = [0x5a827999, 0x6ed9eba1, 0x8f1bbcdc, 0xca62c1d6];
|
||||
const H = [0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476, 0xc3d2e1f0];
|
||||
const newBytes = new Uint8Array(bytes.length + 1);
|
||||
newBytes.set(bytes);
|
||||
newBytes[bytes.length] = 0x80;
|
||||
bytes = newBytes;
|
||||
const l = bytes.length / 4 + 2;
|
||||
const N = Math.ceil(l / 16);
|
||||
const M = new Array(N);
|
||||
for (let i = 0; i < N; ++i) {
|
||||
const arr = new Uint32Array(16);
|
||||
for (let j = 0; j < 16; ++j) {
|
||||
arr[j] =
|
||||
(bytes[i * 64 + j * 4] << 24) |
|
||||
(bytes[i * 64 + j * 4 + 1] << 16) |
|
||||
(bytes[i * 64 + j * 4 + 2] << 8) |
|
||||
bytes[i * 64 + j * 4 + 3];
|
||||
}
|
||||
M[i] = arr;
|
||||
}
|
||||
M[N - 1][14] = ((bytes.length - 1) * 8) / Math.pow(2, 32);
|
||||
M[N - 1][14] = Math.floor(M[N - 1][14]);
|
||||
M[N - 1][15] = ((bytes.length - 1) * 8) & 0xffffffff;
|
||||
for (let i = 0; i < N; ++i) {
|
||||
const W = new Uint32Array(80);
|
||||
for (let t = 0; t < 16; ++t) {
|
||||
W[t] = M[i][t];
|
||||
}
|
||||
for (let t = 16; t < 80; ++t) {
|
||||
W[t] = ROTL(W[t - 3] ^ W[t - 8] ^ W[t - 14] ^ W[t - 16], 1);
|
||||
}
|
||||
let a = H[0];
|
||||
let b = H[1];
|
||||
let c = H[2];
|
||||
let d = H[3];
|
||||
let e = H[4];
|
||||
for (let t = 0; t < 80; ++t) {
|
||||
const s = Math.floor(t / 20);
|
||||
const T = (ROTL(a, 5) + f(s, b, c, d) + e + K[s] + W[t]) >>> 0;
|
||||
e = d;
|
||||
d = c;
|
||||
c = ROTL(b, 30) >>> 0;
|
||||
b = a;
|
||||
a = T;
|
||||
}
|
||||
H[0] = (H[0] + a) >>> 0;
|
||||
H[1] = (H[1] + b) >>> 0;
|
||||
H[2] = (H[2] + c) >>> 0;
|
||||
H[3] = (H[3] + d) >>> 0;
|
||||
H[4] = (H[4] + e) >>> 0;
|
||||
}
|
||||
return Uint8Array.of(H[0] >> 24, H[0] >> 16, H[0] >> 8, H[0], H[1] >> 24, H[1] >> 16, H[1] >> 8, H[1], H[2] >> 24, H[2] >> 16, H[2] >> 8, H[2], H[3] >> 24, H[3] >> 16, H[3] >> 8, H[3], H[4] >> 24, H[4] >> 16, H[4] >> 8, H[4]);
|
||||
}
|
||||
export default sha1;
|
||||
Generated
Vendored
+35
@@ -0,0 +1,35 @@
|
||||
import validate from './validate.js';
|
||||
const byteToHex = [];
|
||||
for (let i = 0; i < 256; ++i) {
|
||||
byteToHex.push((i + 0x100).toString(16).slice(1));
|
||||
}
|
||||
export function unsafeStringify(arr, offset = 0) {
|
||||
return (byteToHex[arr[offset + 0]] +
|
||||
byteToHex[arr[offset + 1]] +
|
||||
byteToHex[arr[offset + 2]] +
|
||||
byteToHex[arr[offset + 3]] +
|
||||
'-' +
|
||||
byteToHex[arr[offset + 4]] +
|
||||
byteToHex[arr[offset + 5]] +
|
||||
'-' +
|
||||
byteToHex[arr[offset + 6]] +
|
||||
byteToHex[arr[offset + 7]] +
|
||||
'-' +
|
||||
byteToHex[arr[offset + 8]] +
|
||||
byteToHex[arr[offset + 9]] +
|
||||
'-' +
|
||||
byteToHex[arr[offset + 10]] +
|
||||
byteToHex[arr[offset + 11]] +
|
||||
byteToHex[arr[offset + 12]] +
|
||||
byteToHex[arr[offset + 13]] +
|
||||
byteToHex[arr[offset + 14]] +
|
||||
byteToHex[arr[offset + 15]]).toLowerCase();
|
||||
}
|
||||
function stringify(arr, offset = 0) {
|
||||
const uuid = unsafeStringify(arr, offset);
|
||||
if (!validate(uuid)) {
|
||||
throw TypeError('Stringified UUID is invalid');
|
||||
}
|
||||
return uuid;
|
||||
}
|
||||
export default stringify;
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
export {};
|
||||
Generated
Vendored
+70
@@ -0,0 +1,70 @@
|
||||
import * as assert from 'node:assert/strict';
|
||||
import v1 from './v1.js';
|
||||
import v3 from './v3.js';
|
||||
import v4 from './v4.js';
|
||||
import v5 from './v5.js';
|
||||
import v6 from './v6.js';
|
||||
import v7 from './v7.js';
|
||||
function usage() {
|
||||
console.log('Usage:');
|
||||
console.log(' uuid');
|
||||
console.log(' uuid v1');
|
||||
console.log(' uuid v3 <name> <namespace uuid>');
|
||||
console.log(' uuid v4');
|
||||
console.log(' uuid v5 <name> <namespace uuid>');
|
||||
console.log(' uuid v6');
|
||||
console.log(' uuid v7');
|
||||
console.log(' uuid --help');
|
||||
console.log('\nNote: <namespace uuid> may be "URL" or "DNS" to use the corresponding UUIDs defined by RFC9562');
|
||||
}
|
||||
const args = process.argv.slice(2);
|
||||
if (args.indexOf('--help') >= 0) {
|
||||
usage();
|
||||
process.exit(0);
|
||||
}
|
||||
const version = args.shift() || 'v4';
|
||||
switch (version) {
|
||||
case 'v1':
|
||||
console.log(v1());
|
||||
break;
|
||||
case 'v3': {
|
||||
const name = args.shift();
|
||||
let namespace = args.shift();
|
||||
assert.ok(name != null, 'v3 name not specified');
|
||||
assert.ok(namespace != null, 'v3 namespace not specified');
|
||||
if (namespace === 'URL') {
|
||||
namespace = v3.URL;
|
||||
}
|
||||
if (namespace === 'DNS') {
|
||||
namespace = v3.DNS;
|
||||
}
|
||||
console.log(v3(name, namespace));
|
||||
break;
|
||||
}
|
||||
case 'v4':
|
||||
console.log(v4());
|
||||
break;
|
||||
case 'v5': {
|
||||
const name = args.shift();
|
||||
let namespace = args.shift();
|
||||
assert.ok(name != null, 'v5 name not specified');
|
||||
assert.ok(namespace != null, 'v5 namespace not specified');
|
||||
if (namespace === 'URL') {
|
||||
namespace = v5.URL;
|
||||
}
|
||||
if (namespace === 'DNS') {
|
||||
namespace = v5.DNS;
|
||||
}
|
||||
console.log(v5(name, namespace));
|
||||
break;
|
||||
}
|
||||
case 'v6':
|
||||
console.log(v6());
|
||||
break;
|
||||
case 'v7':
|
||||
console.log(v7());
|
||||
break;
|
||||
default:
|
||||
usage();
|
||||
process.exit(1);
|
||||
}
|
||||
Generated
Vendored
+83
@@ -0,0 +1,83 @@
|
||||
import rng from './rng.js';
|
||||
import { unsafeStringify } from './stringify.js';
|
||||
const _state = {};
|
||||
function v1(options, buf, offset) {
|
||||
let bytes;
|
||||
const isV6 = options?._v6 ?? false;
|
||||
if (options) {
|
||||
const optionsKeys = Object.keys(options);
|
||||
if (optionsKeys.length === 1 && optionsKeys[0] === '_v6') {
|
||||
options = undefined;
|
||||
}
|
||||
}
|
||||
if (options) {
|
||||
bytes = v1Bytes(options.random ?? options.rng?.() ?? rng(), options.msecs, options.nsecs, options.clockseq, options.node, buf, offset);
|
||||
}
|
||||
else {
|
||||
const now = Date.now();
|
||||
const rnds = rng();
|
||||
updateV1State(_state, now, rnds);
|
||||
bytes = v1Bytes(rnds, _state.msecs, _state.nsecs, isV6 ? undefined : _state.clockseq, isV6 ? undefined : _state.node, buf, offset);
|
||||
}
|
||||
return buf ?? unsafeStringify(bytes);
|
||||
}
|
||||
export function updateV1State(state, now, rnds) {
|
||||
state.msecs ??= -Infinity;
|
||||
state.nsecs ??= 0;
|
||||
if (now === state.msecs) {
|
||||
state.nsecs++;
|
||||
if (state.nsecs >= 10000) {
|
||||
state.node = undefined;
|
||||
state.nsecs = 0;
|
||||
}
|
||||
}
|
||||
else if (now > state.msecs) {
|
||||
state.nsecs = 0;
|
||||
}
|
||||
else if (now < state.msecs) {
|
||||
state.node = undefined;
|
||||
}
|
||||
if (!state.node) {
|
||||
state.node = rnds.slice(10, 16);
|
||||
state.node[0] |= 0x01;
|
||||
state.clockseq = ((rnds[8] << 8) | rnds[9]) & 0x3fff;
|
||||
}
|
||||
state.msecs = now;
|
||||
return state;
|
||||
}
|
||||
function v1Bytes(rnds, msecs, nsecs, clockseq, node, buf, offset = 0) {
|
||||
if (rnds.length < 16) {
|
||||
throw new Error('Random bytes length must be >= 16');
|
||||
}
|
||||
if (!buf) {
|
||||
buf = new Uint8Array(16);
|
||||
offset = 0;
|
||||
}
|
||||
else {
|
||||
if (offset < 0 || offset + 16 > buf.length) {
|
||||
throw new RangeError(`UUID byte range ${offset}:${offset + 15} is out of buffer bounds`);
|
||||
}
|
||||
}
|
||||
msecs ??= Date.now();
|
||||
nsecs ??= 0;
|
||||
clockseq ??= ((rnds[8] << 8) | rnds[9]) & 0x3fff;
|
||||
node ??= rnds.slice(10, 16);
|
||||
msecs += 12219292800000;
|
||||
const tl = ((msecs & 0xfffffff) * 10000 + nsecs) % 0x100000000;
|
||||
buf[offset++] = (tl >>> 24) & 0xff;
|
||||
buf[offset++] = (tl >>> 16) & 0xff;
|
||||
buf[offset++] = (tl >>> 8) & 0xff;
|
||||
buf[offset++] = tl & 0xff;
|
||||
const tmh = ((msecs / 0x100000000) * 10000) & 0xfffffff;
|
||||
buf[offset++] = (tmh >>> 8) & 0xff;
|
||||
buf[offset++] = tmh & 0xff;
|
||||
buf[offset++] = ((tmh >>> 24) & 0xf) | 0x10;
|
||||
buf[offset++] = (tmh >>> 16) & 0xff;
|
||||
buf[offset++] = (clockseq >>> 8) | 0x80;
|
||||
buf[offset++] = clockseq & 0xff;
|
||||
for (let n = 0; n < 6; ++n) {
|
||||
buf[offset++] = node[n];
|
||||
}
|
||||
return buf;
|
||||
}
|
||||
export default v1;
|
||||
Generated
Vendored
+10
@@ -0,0 +1,10 @@
|
||||
import parse from './parse.js';
|
||||
import { unsafeStringify } from './stringify.js';
|
||||
export default function v1ToV6(uuid) {
|
||||
const v1Bytes = typeof uuid === 'string' ? parse(uuid) : uuid;
|
||||
const v6Bytes = _v1ToV6(v1Bytes);
|
||||
return typeof uuid === 'string' ? unsafeStringify(v6Bytes) : v6Bytes;
|
||||
}
|
||||
function _v1ToV6(v1Bytes) {
|
||||
return Uint8Array.of(((v1Bytes[6] & 0x0f) << 4) | ((v1Bytes[7] >> 4) & 0x0f), ((v1Bytes[7] & 0x0f) << 4) | ((v1Bytes[4] & 0xf0) >> 4), ((v1Bytes[4] & 0x0f) << 4) | ((v1Bytes[5] & 0xf0) >> 4), ((v1Bytes[5] & 0x0f) << 4) | ((v1Bytes[0] & 0xf0) >> 4), ((v1Bytes[0] & 0x0f) << 4) | ((v1Bytes[1] & 0xf0) >> 4), ((v1Bytes[1] & 0x0f) << 4) | ((v1Bytes[2] & 0xf0) >> 4), 0x60 | (v1Bytes[2] & 0x0f), v1Bytes[3], v1Bytes[8], v1Bytes[9], v1Bytes[10], v1Bytes[11], v1Bytes[12], v1Bytes[13], v1Bytes[14], v1Bytes[15]);
|
||||
}
|
||||
Generated
Vendored
+9
@@ -0,0 +1,9 @@
|
||||
import md5 from './md5.js';
|
||||
import v35, { DNS, URL } from './v35.js';
|
||||
export { DNS, URL } from './v35.js';
|
||||
function v3(value, namespace, buf, offset) {
|
||||
return v35(0x30, md5, value, namespace, buf, offset);
|
||||
}
|
||||
v3.DNS = DNS;
|
||||
v3.URL = URL;
|
||||
export default v3;
|
||||
Generated
Vendored
+36
@@ -0,0 +1,36 @@
|
||||
import parse from './parse.js';
|
||||
import { unsafeStringify } from './stringify.js';
|
||||
export function stringToBytes(str) {
|
||||
str = unescape(encodeURIComponent(str));
|
||||
const bytes = new Uint8Array(str.length);
|
||||
for (let i = 0; i < str.length; ++i) {
|
||||
bytes[i] = str.charCodeAt(i);
|
||||
}
|
||||
return bytes;
|
||||
}
|
||||
export const DNS = '6ba7b810-9dad-11d1-80b4-00c04fd430c8';
|
||||
export const URL = '6ba7b811-9dad-11d1-80b4-00c04fd430c8';
|
||||
export default function v35(version, hash, value, namespace, buf, offset) {
|
||||
const valueBytes = typeof value === 'string' ? stringToBytes(value) : value;
|
||||
const namespaceBytes = typeof namespace === 'string' ? parse(namespace) : namespace;
|
||||
if (typeof namespace === 'string') {
|
||||
namespace = parse(namespace);
|
||||
}
|
||||
if (namespace?.length !== 16) {
|
||||
throw TypeError('Namespace must be array-like (16 iterable integer values, 0-255)');
|
||||
}
|
||||
let bytes = new Uint8Array(16 + valueBytes.length);
|
||||
bytes.set(namespaceBytes);
|
||||
bytes.set(valueBytes, namespaceBytes.length);
|
||||
bytes = hash(bytes);
|
||||
bytes[6] = (bytes[6] & 0x0f) | version;
|
||||
bytes[8] = (bytes[8] & 0x3f) | 0x80;
|
||||
if (buf) {
|
||||
offset = offset || 0;
|
||||
for (let i = 0; i < 16; ++i) {
|
||||
buf[offset + i] = bytes[i];
|
||||
}
|
||||
return buf;
|
||||
}
|
||||
return unsafeStringify(bytes);
|
||||
}
|
||||
Generated
Vendored
+30
@@ -0,0 +1,30 @@
|
||||
import native from './native.js';
|
||||
import rng from './rng.js';
|
||||
import { unsafeStringify } from './stringify.js';
|
||||
function _v4(options, buf, offset) {
|
||||
options = options || {};
|
||||
const rnds = options.random ?? options.rng?.() ?? rng();
|
||||
if (rnds.length < 16) {
|
||||
throw new Error('Random bytes length must be >= 16');
|
||||
}
|
||||
rnds[6] = (rnds[6] & 0x0f) | 0x40;
|
||||
rnds[8] = (rnds[8] & 0x3f) | 0x80;
|
||||
if (buf) {
|
||||
offset = offset || 0;
|
||||
if (offset < 0 || offset + 16 > buf.length) {
|
||||
throw new RangeError(`UUID byte range ${offset}:${offset + 15} is out of buffer bounds`);
|
||||
}
|
||||
for (let i = 0; i < 16; ++i) {
|
||||
buf[offset + i] = rnds[i];
|
||||
}
|
||||
return buf;
|
||||
}
|
||||
return unsafeStringify(rnds);
|
||||
}
|
||||
function v4(options, buf, offset) {
|
||||
if (native.randomUUID && !buf && !options) {
|
||||
return native.randomUUID();
|
||||
}
|
||||
return _v4(options, buf, offset);
|
||||
}
|
||||
export default v4;
|
||||
Generated
Vendored
+9
@@ -0,0 +1,9 @@
|
||||
import sha1 from './sha1.js';
|
||||
import v35, { DNS, URL } from './v35.js';
|
||||
export { DNS, URL } from './v35.js';
|
||||
function v5(value, namespace, buf, offset) {
|
||||
return v35(0x50, sha1, value, namespace, buf, offset);
|
||||
}
|
||||
v5.DNS = DNS;
|
||||
v5.URL = URL;
|
||||
export default v5;
|
||||
Generated
Vendored
+17
@@ -0,0 +1,17 @@
|
||||
import { unsafeStringify } from './stringify.js';
|
||||
import v1 from './v1.js';
|
||||
import v1ToV6 from './v1ToV6.js';
|
||||
function v6(options, buf, offset) {
|
||||
options ??= {};
|
||||
offset ??= 0;
|
||||
let bytes = v1({ ...options, _v6: true }, new Uint8Array(16));
|
||||
bytes = v1ToV6(bytes);
|
||||
if (buf) {
|
||||
for (let i = 0; i < 16; i++) {
|
||||
buf[offset + i] = bytes[i];
|
||||
}
|
||||
return buf;
|
||||
}
|
||||
return unsafeStringify(bytes);
|
||||
}
|
||||
export default v6;
|
||||
Generated
Vendored
+10
@@ -0,0 +1,10 @@
|
||||
import parse from './parse.js';
|
||||
import { unsafeStringify } from './stringify.js';
|
||||
export default function v6ToV1(uuid) {
|
||||
const v6Bytes = typeof uuid === 'string' ? parse(uuid) : uuid;
|
||||
const v1Bytes = _v6ToV1(v6Bytes);
|
||||
return typeof uuid === 'string' ? unsafeStringify(v1Bytes) : v1Bytes;
|
||||
}
|
||||
function _v6ToV1(v6Bytes) {
|
||||
return Uint8Array.of(((v6Bytes[3] & 0x0f) << 4) | ((v6Bytes[4] >> 4) & 0x0f), ((v6Bytes[4] & 0x0f) << 4) | ((v6Bytes[5] & 0xf0) >> 4), ((v6Bytes[5] & 0x0f) << 4) | (v6Bytes[6] & 0x0f), v6Bytes[7], ((v6Bytes[1] & 0x0f) << 4) | ((v6Bytes[2] & 0xf0) >> 4), ((v6Bytes[2] & 0x0f) << 4) | ((v6Bytes[3] & 0xf0) >> 4), 0x10 | ((v6Bytes[0] & 0xf0) >> 4), ((v6Bytes[0] & 0x0f) << 4) | ((v6Bytes[1] & 0xf0) >> 4), v6Bytes[8], v6Bytes[9], v6Bytes[10], v6Bytes[11], v6Bytes[12], v6Bytes[13], v6Bytes[14], v6Bytes[15]);
|
||||
}
|
||||
Generated
Vendored
+65
@@ -0,0 +1,65 @@
|
||||
import rng from './rng.js';
|
||||
import { unsafeStringify } from './stringify.js';
|
||||
const _state = {};
|
||||
function v7(options, buf, offset) {
|
||||
let bytes;
|
||||
if (options) {
|
||||
bytes = v7Bytes(options.random ?? options.rng?.() ?? rng(), options.msecs, options.seq, buf, offset);
|
||||
}
|
||||
else {
|
||||
const now = Date.now();
|
||||
const rnds = rng();
|
||||
updateV7State(_state, now, rnds);
|
||||
bytes = v7Bytes(rnds, _state.msecs, _state.seq, buf, offset);
|
||||
}
|
||||
return buf ?? unsafeStringify(bytes);
|
||||
}
|
||||
export function updateV7State(state, now, rnds) {
|
||||
state.msecs ??= -Infinity;
|
||||
state.seq ??= 0;
|
||||
if (now > state.msecs) {
|
||||
state.seq = (rnds[6] << 23) | (rnds[7] << 16) | (rnds[8] << 8) | rnds[9];
|
||||
state.msecs = now;
|
||||
}
|
||||
else {
|
||||
state.seq = (state.seq + 1) | 0;
|
||||
if (state.seq === 0) {
|
||||
state.msecs++;
|
||||
}
|
||||
}
|
||||
return state;
|
||||
}
|
||||
function v7Bytes(rnds, msecs, seq, buf, offset = 0) {
|
||||
if (rnds.length < 16) {
|
||||
throw new Error('Random bytes length must be >= 16');
|
||||
}
|
||||
if (!buf) {
|
||||
buf = new Uint8Array(16);
|
||||
offset = 0;
|
||||
}
|
||||
else {
|
||||
if (offset < 0 || offset + 16 > buf.length) {
|
||||
throw new RangeError(`UUID byte range ${offset}:${offset + 15} is out of buffer bounds`);
|
||||
}
|
||||
}
|
||||
msecs ??= Date.now();
|
||||
seq ??= ((rnds[6] * 0x7f) << 24) | (rnds[7] << 16) | (rnds[8] << 8) | rnds[9];
|
||||
buf[offset++] = (msecs / 0x10000000000) & 0xff;
|
||||
buf[offset++] = (msecs / 0x100000000) & 0xff;
|
||||
buf[offset++] = (msecs / 0x1000000) & 0xff;
|
||||
buf[offset++] = (msecs / 0x10000) & 0xff;
|
||||
buf[offset++] = (msecs / 0x100) & 0xff;
|
||||
buf[offset++] = msecs & 0xff;
|
||||
buf[offset++] = 0x70 | ((seq >>> 28) & 0x0f);
|
||||
buf[offset++] = (seq >>> 20) & 0xff;
|
||||
buf[offset++] = 0x80 | ((seq >>> 14) & 0x3f);
|
||||
buf[offset++] = (seq >>> 6) & 0xff;
|
||||
buf[offset++] = ((seq << 2) & 0xff) | (rnds[10] & 0x03);
|
||||
buf[offset++] = rnds[11];
|
||||
buf[offset++] = rnds[12];
|
||||
buf[offset++] = rnds[13];
|
||||
buf[offset++] = rnds[14];
|
||||
buf[offset++] = rnds[15];
|
||||
return buf;
|
||||
}
|
||||
export default v7;
|
||||
Generated
Vendored
+5
@@ -0,0 +1,5 @@
|
||||
import REGEX from './regex.js';
|
||||
function validate(uuid) {
|
||||
return typeof uuid === 'string' && REGEX.test(uuid);
|
||||
}
|
||||
export default validate;
|
||||
Generated
Vendored
+8
@@ -0,0 +1,8 @@
|
||||
import validate from './validate.js';
|
||||
function version(uuid) {
|
||||
if (!validate(uuid)) {
|
||||
throw TypeError('Invalid UUID');
|
||||
}
|
||||
return parseInt(uuid.slice(14, 15), 16);
|
||||
}
|
||||
export default version;
|
||||
Generated
Vendored
+119
@@ -0,0 +1,119 @@
|
||||
{
|
||||
"name": "uuid",
|
||||
"version": "13.0.0",
|
||||
"description": "RFC9562 UUIDs",
|
||||
"type": "module",
|
||||
"funding": [
|
||||
"https://github.com/sponsors/broofa",
|
||||
"https://github.com/sponsors/ctavan"
|
||||
],
|
||||
"commitlint": {
|
||||
"extends": [
|
||||
"@commitlint/config-conventional"
|
||||
]
|
||||
},
|
||||
"keywords": [
|
||||
"uuid",
|
||||
"guid",
|
||||
"rfc4122",
|
||||
"rfc9562"
|
||||
],
|
||||
"license": "MIT",
|
||||
"bin": {
|
||||
"uuid": "./dist-node/bin/uuid"
|
||||
},
|
||||
"sideEffects": false,
|
||||
"types": "./dist/index.d.ts",
|
||||
"exports": {
|
||||
".": {
|
||||
"node": "./dist-node/index.js",
|
||||
"default": "./dist/index.js"
|
||||
},
|
||||
"./package.json": "./package.json"
|
||||
},
|
||||
"files": [
|
||||
"dist",
|
||||
"dist-node",
|
||||
"!**/test"
|
||||
],
|
||||
"devDependencies": {
|
||||
"@babel/eslint-parser": "7.27.1",
|
||||
"@commitlint/cli": "19.8.0",
|
||||
"@commitlint/config-conventional": "19.8.0",
|
||||
"@eslint/js": "9.26.0",
|
||||
"bundlewatch": "0.4.1",
|
||||
"commander": "13.1.0",
|
||||
"eslint": "9.26.0",
|
||||
"eslint-config-prettier": "10.1.2",
|
||||
"eslint-plugin-prettier": "5.4.0",
|
||||
"globals": "16.0.0",
|
||||
"husky": "9.1.7",
|
||||
"jest": "29.7.0",
|
||||
"lint-staged": "15.5.2",
|
||||
"neostandard": "0.12.1",
|
||||
"npm-run-all": "4.1.5",
|
||||
"prettier": "3.5.3",
|
||||
"release-please": "17.0.0",
|
||||
"runmd": "1.4.1",
|
||||
"standard-version": "9.5.0",
|
||||
"typescript": "5.2.2",
|
||||
"typescript-eslint": "8.32.0"
|
||||
},
|
||||
"optionalDevDependencies": {
|
||||
"@wdio/browserstack-service": "9.2.1",
|
||||
"@wdio/cli": "9.2.1",
|
||||
"@wdio/jasmine-framework": "9.2.1",
|
||||
"@wdio/local-runner": "9.2.1",
|
||||
"@wdio/spec-reporter": "9.1.3",
|
||||
"@wdio/static-server-service": "9.1.3"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "./scripts/build.sh",
|
||||
"build:watch": "tsc --watch -p tsconfig.json",
|
||||
"bundlewatch": "npm run pretest:browser && bundlewatch --config bundlewatch.config.json",
|
||||
"docs:diff": "npm run docs && git diff --quiet -I \"[0-9a-f-]{36}\" README.md",
|
||||
"docs": "npm run build && npx runmd --output=README.md README_js.md",
|
||||
"eslint:check": "eslint src/ test/ examples/ *.[jt]s",
|
||||
"eslint:fix": "eslint --fix src/ test/ examples/ *.[jt]s",
|
||||
"examples:browser:rollup:build": "cd examples/browser-rollup && npm run build",
|
||||
"examples:browser:webpack:build": "cd examples/browser-webpack && npm run build",
|
||||
"examples:node:esmodules:test": "cd examples/node-esmodules && npm test",
|
||||
"examples:node:jest:test": "cd examples/node-jest && npm test",
|
||||
"examples:node:typescript:test": "cd examples/typescript && npm test",
|
||||
"lint": "npm run eslint:check && npm run prettier:check",
|
||||
"md": "runmd --watch --output=README.md README_js.md",
|
||||
"prepack": "npm run build -- --no-pack",
|
||||
"prepare": "husky",
|
||||
"prepublishOnly": "npm run build",
|
||||
"pretest:benchmark": "npm run build",
|
||||
"pretest:browser": "./scripts/iodd && npm run build && npm-run-all --parallel examples:browser:**",
|
||||
"pretest:node": "npm run build",
|
||||
"pretest": "npm run build",
|
||||
"prettier:check": "prettier --check .",
|
||||
"prettier:fix": "prettier --write .",
|
||||
"release": "standard-version --no-verify",
|
||||
"test:benchmark": "cd examples/benchmark && npm test",
|
||||
"test:browser": "wdio run ./wdio.conf.js",
|
||||
"test:node": "npm-run-all --parallel examples:node:**",
|
||||
"test:watch": "node --test --enable-source-maps --watch dist-node/test/*.js",
|
||||
"test": "node --test --enable-source-maps dist-node/test/*.js"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/uuidjs/uuid.git"
|
||||
},
|
||||
"lint-staged": {
|
||||
"*": [
|
||||
"prettier --no-error-on-unmatched-pattern --write"
|
||||
],
|
||||
"*.{js,jsx}": [
|
||||
"eslint --no-error-on-unmatched-pattern --fix"
|
||||
]
|
||||
},
|
||||
"standard-version": {
|
||||
"scripts": {
|
||||
"postchangelog": "prettier --write CHANGELOG.md"
|
||||
}
|
||||
},
|
||||
"packageManager": "npm@11.3.0"
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.CHOICE_WORKSPACE_DESC = exports.CHOICE_WORKSPACE_LABEL = exports.CHOICE_GLOBAL_DESC = exports.CHOICE_GLOBAL_LABEL = exports.PROMPT_CONFIRM_OVERWRITE = exports.PROMPT_CONFIRM_DELETE = exports.PROMPT_SELECT_PATTERN = exports.PROMPT_SELECT_SCOPE = exports.PROMPT_PATTERN_NAME_PLACEHOLDER = exports.PROMPT_PATTERN_NAME = exports.INFO_PATTERN_DELETED = exports.INFO_PATTERN_SAVED = exports.INFO_PATTERN_LOADED = exports.INFO_NO_PATTERNS = exports.ERR_MANAGING_PATTERNS = exports.ERR_LOADING_PATTERN = exports.ERR_SAVING_PATTERN = exports.ERR_PATTERN_NAME_EMPTY = exports.ERR_NO_SEARCH_STATE = exports.UI_MANAGE_TITLE = exports.UI_SECTION_USER = exports.UI_SECTION_WORKSPACE = exports.UI_NO_PATTERNS_FOUND = exports.UI_NO_PATTERNS = exports.MSG_TYPE_SAVE = exports.MSG_TYPE_LOAD = exports.MSG_TYPE_DELETE = exports.MSG_TYPE_PATTERNS = exports.MSG_TYPE_READY = exports.COMMAND_MANAGE = exports.SCOPE_WORKSPACE = exports.SCOPE_GLOBAL = exports.CONFIG_KEY_WORKSPACE_PATTERNS = exports.CONFIG_KEY_USER_PATTERNS = exports.CONFIG_NAMESPACE = void 0;
|
||||
exports.CONFIG_NAMESPACE = 'patternStore';
|
||||
exports.CONFIG_KEY_USER_PATTERNS = 'savedPatterns';
|
||||
exports.CONFIG_KEY_WORKSPACE_PATTERNS = 'workspacePatterns';
|
||||
exports.SCOPE_GLOBAL = 'global';
|
||||
exports.SCOPE_WORKSPACE = 'workspace';
|
||||
exports.COMMAND_MANAGE = 'patternStore.manage';
|
||||
exports.MSG_TYPE_READY = 'ready';
|
||||
exports.MSG_TYPE_PATTERNS = 'patterns';
|
||||
exports.MSG_TYPE_DELETE = 'delete';
|
||||
exports.MSG_TYPE_LOAD = 'load';
|
||||
exports.MSG_TYPE_SAVE = 'save';
|
||||
exports.UI_NO_PATTERNS = 'No patterns yet';
|
||||
exports.UI_NO_PATTERNS_FOUND = 'No patterns found';
|
||||
exports.UI_SECTION_WORKSPACE = 'Workspace';
|
||||
exports.UI_SECTION_USER = 'User';
|
||||
exports.UI_MANAGE_TITLE = 'Manage Patterns';
|
||||
exports.ERR_NO_SEARCH_STATE = 'Could not read current search state';
|
||||
exports.ERR_PATTERN_NAME_EMPTY = 'Pattern name cannot be empty';
|
||||
exports.ERR_SAVING_PATTERN = 'Error saving pattern';
|
||||
exports.ERR_LOADING_PATTERN = 'Error loading pattern';
|
||||
exports.ERR_MANAGING_PATTERNS = 'Error managing patterns';
|
||||
exports.INFO_NO_PATTERNS = 'No saved patterns found. Use "PatternStore: Save Pattern" to create one.';
|
||||
exports.INFO_PATTERN_LOADED = 'Loaded pattern';
|
||||
exports.INFO_PATTERN_SAVED = 'Pattern saved';
|
||||
exports.INFO_PATTERN_DELETED = 'Pattern deleted';
|
||||
exports.PROMPT_PATTERN_NAME = 'Enter a name for this pattern';
|
||||
exports.PROMPT_PATTERN_NAME_PLACEHOLDER = 'e.g., "Replace quotes with angles"';
|
||||
exports.PROMPT_SELECT_SCOPE = 'Choose storage scope';
|
||||
exports.PROMPT_SELECT_PATTERN = 'Select a pattern to load';
|
||||
exports.PROMPT_CONFIRM_DELETE = 'Delete pattern';
|
||||
exports.PROMPT_CONFIRM_OVERWRITE = 'already exists. Overwrite?';
|
||||
exports.CHOICE_GLOBAL_LABEL = 'Global';
|
||||
exports.CHOICE_GLOBAL_DESC = 'Available in all workspaces';
|
||||
exports.CHOICE_WORKSPACE_LABEL = 'Workspace';
|
||||
exports.CHOICE_WORKSPACE_DESC = 'Only for this workspace';
|
||||
//# sourceMappingURL=constants.js.map
|
||||
@@ -0,0 +1,127 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || (function () {
|
||||
var ownKeys = function(o) {
|
||||
ownKeys = Object.getOwnPropertyNames || function (o) {
|
||||
var ar = [];
|
||||
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
||||
return ar;
|
||||
};
|
||||
return ownKeys(o);
|
||||
};
|
||||
return function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
})();
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.activate = activate;
|
||||
exports.deactivate = deactivate;
|
||||
const vscode = __importStar(require("vscode"));
|
||||
const storage = __importStar(require("./storage"));
|
||||
const searchCtx = __importStar(require("./searchCtx"));
|
||||
const WebviewManager_1 = require("./webview/WebviewManager");
|
||||
/**
|
||||
* Called when the extension is activated
|
||||
*/
|
||||
function activate(context) {
|
||||
console.log('PatternStore extension is now active!');
|
||||
// Register command: Manage Patterns
|
||||
const manageCommand = vscode.commands.registerCommand('patternStore.manage', async () => {
|
||||
await managePatternsCommand(context.extensionUri);
|
||||
});
|
||||
context.subscriptions.push(manageCommand);
|
||||
}
|
||||
/**
|
||||
* Called when the extension is deactivated
|
||||
*/
|
||||
function deactivate() {
|
||||
console.log('PatternStore extension is now deactivated');
|
||||
}
|
||||
/**
|
||||
* Command: Save the current search state as a pattern
|
||||
*/
|
||||
async function savePatternCommand() {
|
||||
try {
|
||||
vscode.window.showInformationMessage('PatternStore: Save Pattern command executed!');
|
||||
// Get current search state
|
||||
const searchState = await searchCtx.getCurrentSearchState();
|
||||
if (!searchState) {
|
||||
vscode.window.showErrorMessage('Could not read current search state');
|
||||
return;
|
||||
}
|
||||
// Prompt for pattern name
|
||||
const label = await vscode.window.showInputBox({
|
||||
prompt: 'Enter a name for this pattern',
|
||||
placeHolder: 'e.g., "Replace quotes with angles"',
|
||||
validateInput: (value) => {
|
||||
if (!value || value.trim().length === 0) {
|
||||
return 'Pattern name cannot be empty';
|
||||
}
|
||||
return null;
|
||||
}
|
||||
});
|
||||
if (!label) {
|
||||
return; // User cancelled
|
||||
}
|
||||
// Ask for scope
|
||||
const scopeChoice = await vscode.window.showQuickPick([
|
||||
{ label: 'Global', description: 'Available in all workspaces', value: 'global' },
|
||||
{ label: 'Workspace', description: 'Only for this workspace', value: 'workspace' }
|
||||
], { placeHolder: 'Choose storage scope' });
|
||||
if (!scopeChoice) {
|
||||
return; // User cancelled
|
||||
}
|
||||
// Create pattern object
|
||||
const pattern = {
|
||||
id: 'new', // Temporary ID for new patterns
|
||||
label: label.trim(),
|
||||
find: searchState.find || '',
|
||||
replace: searchState.replace || '',
|
||||
flags: searchState.flags || {
|
||||
isRegex: false,
|
||||
isCaseSensitive: false,
|
||||
matchWholeWord: false,
|
||||
isMultiline: false
|
||||
},
|
||||
scope: scopeChoice.value
|
||||
};
|
||||
// Check if pattern exists (will check when we implement storage)
|
||||
const exists = storage.patternExists(pattern.label, pattern.scope);
|
||||
if (exists) {
|
||||
const overwrite = await vscode.window.showWarningMessage(`A pattern named "${pattern.label}" already exists. Overwrite?`, 'Yes', 'No');
|
||||
if (overwrite !== 'Yes') {
|
||||
return;
|
||||
}
|
||||
}
|
||||
// Save pattern
|
||||
await storage.savePattern(pattern);
|
||||
}
|
||||
catch (error) {
|
||||
vscode.window.showErrorMessage(`Error saving pattern: ${error}`);
|
||||
}
|
||||
}
|
||||
async function managePatternsCommand(extensionUri) {
|
||||
console.log('Manage Patterns command pressed - opening webview');
|
||||
// For now, just open global patterns. We'll add separate commands later
|
||||
WebviewManager_1.WebviewManager.show(extensionUri, 'global');
|
||||
}
|
||||
//# sourceMappingURL=extension.js.map
|
||||
@@ -0,0 +1,129 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || (function () {
|
||||
var ownKeys = function(o) {
|
||||
ownKeys = Object.getOwnPropertyNames || function (o) {
|
||||
var ar = [];
|
||||
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
||||
return ar;
|
||||
};
|
||||
return ownKeys(o);
|
||||
};
|
||||
return function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
})();
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.getCurrentSearchState = getCurrentSearchState;
|
||||
exports.loadPatternIntoSearch = loadPatternIntoSearch;
|
||||
const vscode = __importStar(require("vscode"));
|
||||
/**
|
||||
* Get the current search state from the Search panel
|
||||
* Returns null if unable to get the state
|
||||
*
|
||||
* NOTE: VS Code doesn't expose search panel state via API.
|
||||
* This function tries to use editor selection as fallback.
|
||||
*/
|
||||
async function getCurrentSearchState() {
|
||||
// Try to get selected text from active editor
|
||||
const editor = vscode.window.activeTextEditor;
|
||||
const selection = editor?.document.getText(editor.selection);
|
||||
if (selection && selection.length > 0) {
|
||||
// Use selection as find text
|
||||
return {
|
||||
find: selection,
|
||||
replace: '',
|
||||
flags: {
|
||||
isRegex: false,
|
||||
isCaseSensitive: false,
|
||||
matchWholeWord: false,
|
||||
isMultiline: false
|
||||
}
|
||||
};
|
||||
}
|
||||
// No selection available - return null
|
||||
// User will need to enter manually
|
||||
return null;
|
||||
}
|
||||
/**
|
||||
* Resolve placeholders like ${prompt:varname} in multiple strings
|
||||
* Prompts once per unique placeholder name and reuses the value
|
||||
*/
|
||||
async function resolvePlaceholdersMultiple(texts) {
|
||||
const RE = /\$\{prompt:([^}]+)\}/g;
|
||||
// Collect all unique placeholder names across all texts
|
||||
const allNames = new Set();
|
||||
for (const text of texts) {
|
||||
Array.from(text.matchAll(RE), m => m[1]).forEach(name => allNames.add(name));
|
||||
}
|
||||
const vals = {};
|
||||
// Prompt once for each unique placeholder
|
||||
for (const name of allNames) {
|
||||
const value = await vscode.window.showInputBox({
|
||||
prompt: `Value for ${name}`,
|
||||
placeHolder: name
|
||||
});
|
||||
if (value === undefined) {
|
||||
return undefined; // User cancelled
|
||||
}
|
||||
vals[name] = value;
|
||||
}
|
||||
// Replace placeholders in all texts using the collected values
|
||||
return texts.map(text => text.replace(RE, (_, name) => vals[name] ?? ""));
|
||||
}
|
||||
/**
|
||||
* Resolve placeholders like ${prompt:varname} in a string (single text version)
|
||||
*/
|
||||
async function resolvePlaceholders(text) {
|
||||
const result = await resolvePlaceholdersMultiple([text]);
|
||||
return result ? result[0] : undefined;
|
||||
}
|
||||
async function loadPatternIntoSearch(pattern) {
|
||||
try {
|
||||
const hasReplace = pattern.replace && pattern.replace.trim().length > 0;
|
||||
const textsToResolve = hasReplace ? [pattern.find, pattern.replace] : [pattern.find];
|
||||
const resolved = await resolvePlaceholdersMultiple(textsToResolve);
|
||||
if (!resolved) {
|
||||
return; // User cancelled
|
||||
}
|
||||
const find = resolved[0];
|
||||
const replace = hasReplace ? resolved[1] : '';
|
||||
const commandArgs = {
|
||||
query: find,
|
||||
replace: replace,
|
||||
triggerSearch: false, // Don't auto-trigger search
|
||||
isRegex: pattern.flags.isRegex,
|
||||
isCaseSensitive: pattern.flags.isCaseSensitive,
|
||||
matchWholeWord: pattern.flags.matchWholeWord,
|
||||
preserveCase: false,
|
||||
filesToInclude: pattern.filesToInclude || '',
|
||||
filesToExclude: pattern.filesToExclude || ''
|
||||
};
|
||||
await vscode.commands.executeCommand("workbench.action.findInFiles", commandArgs);
|
||||
vscode.window.showInformationMessage(`✅ Loaded pattern: "${pattern.label}"`);
|
||||
}
|
||||
catch (error) {
|
||||
vscode.window.showErrorMessage(`Failed to load pattern: ${error}`);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=searchCtx.js.map
|
||||
@@ -0,0 +1,158 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || (function () {
|
||||
var ownKeys = function(o) {
|
||||
ownKeys = Object.getOwnPropertyNames || function (o) {
|
||||
var ar = [];
|
||||
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
||||
return ar;
|
||||
};
|
||||
return ownKeys(o);
|
||||
};
|
||||
return function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
})();
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.getAllPatterns = getAllPatterns;
|
||||
exports.savePattern = savePattern;
|
||||
exports.deletePattern = deletePattern;
|
||||
exports.renamePattern = renamePattern;
|
||||
exports.patternExists = patternExists;
|
||||
const vscode = __importStar(require("vscode"));
|
||||
const C = __importStar(require("./constants"));
|
||||
/**
|
||||
* Get patterns from settings and add runtime IDs
|
||||
*/
|
||||
function getPatternsByScope(scope) {
|
||||
const config = vscode.workspace.getConfiguration(C.CONFIG_NAMESPACE);
|
||||
const configKey = scope === 'global' ? C.CONFIG_KEY_USER_PATTERNS : C.CONFIG_KEY_WORKSPACE_PATTERNS;
|
||||
let storedPatterns;
|
||||
if (scope === 'global') {
|
||||
storedPatterns = config.inspect(C.CONFIG_KEY_USER_PATTERNS)?.globalValue || [];
|
||||
}
|
||||
else {
|
||||
storedPatterns = config.inspect(C.CONFIG_KEY_WORKSPACE_PATTERNS)?.workspaceValue || [];
|
||||
}
|
||||
// Add runtime IDs and ensure scope is set
|
||||
return storedPatterns.map((p, index) => ({
|
||||
...p,
|
||||
id: `${scope}-${index}`, // Index-based runtime ID
|
||||
scope: scope
|
||||
}));
|
||||
}
|
||||
function getAllPatterns() {
|
||||
const workspace = getPatternsByScope('workspace');
|
||||
const global = getPatternsByScope('global');
|
||||
// Return all patterns - duplicates across scopes are allowed
|
||||
return [...workspace, ...global];
|
||||
}
|
||||
async function savePattern(pattern) {
|
||||
const config = vscode.workspace.getConfiguration(C.CONFIG_NAMESPACE);
|
||||
const configKey = pattern.scope === 'global' ? C.CONFIG_KEY_USER_PATTERNS : C.CONFIG_KEY_WORKSPACE_PATTERNS;
|
||||
const target = pattern.scope === 'global'
|
||||
? vscode.ConfigurationTarget.Global
|
||||
: vscode.ConfigurationTarget.Workspace;
|
||||
// Read fresh patterns with runtime IDs
|
||||
const patternsWithIds = getPatternsByScope(pattern.scope);
|
||||
// Find existing pattern by ID (runtime ID tells us the index it came from)
|
||||
const existingIndex = patternsWithIds.findIndex(p => p.id === pattern.id);
|
||||
const isUpdate = existingIndex !== -1;
|
||||
// Strip runtime ID before saving
|
||||
const { id, ...storedPattern } = pattern;
|
||||
// Create array of stored patterns (without IDs)
|
||||
let storedPatterns = patternsWithIds.map(p => {
|
||||
const { id, ...stored } = p;
|
||||
return stored;
|
||||
});
|
||||
if (isUpdate) {
|
||||
// Update existing pattern IN PLACE (maintains order)
|
||||
storedPatterns[existingIndex] = storedPattern;
|
||||
}
|
||||
else {
|
||||
// New pattern - add at beginning
|
||||
storedPatterns.unshift(storedPattern);
|
||||
}
|
||||
// Save to settings (without IDs)
|
||||
await config.update(configKey, storedPatterns, target);
|
||||
// Only show message if it's a new pattern (not an update)
|
||||
if (!isUpdate) {
|
||||
vscode.window.showInformationMessage(`✅ Pattern "${pattern.label}" saved to ${pattern.scope} settings`);
|
||||
}
|
||||
}
|
||||
async function deletePattern(id, scope) {
|
||||
const config = vscode.workspace.getConfiguration(C.CONFIG_NAMESPACE);
|
||||
const configKey = scope === 'global' ? C.CONFIG_KEY_USER_PATTERNS : C.CONFIG_KEY_WORKSPACE_PATTERNS;
|
||||
const target = scope === 'global'
|
||||
? vscode.ConfigurationTarget.Global
|
||||
: vscode.ConfigurationTarget.Workspace;
|
||||
// Read fresh patterns with runtime IDs
|
||||
const patternsWithIds = getPatternsByScope(scope);
|
||||
// Find pattern by runtime ID
|
||||
const patternToDelete = patternsWithIds.find(p => p.id === id);
|
||||
if (!patternToDelete) {
|
||||
vscode.window.showWarningMessage(`Pattern not found in ${scope} settings`);
|
||||
return;
|
||||
}
|
||||
// Filter out the pattern and strip IDs
|
||||
const storedPatterns = patternsWithIds
|
||||
.filter(p => p.id !== id)
|
||||
.map(p => {
|
||||
const { id, ...stored } = p;
|
||||
return stored;
|
||||
});
|
||||
// Save updated list (without IDs)
|
||||
await config.update(configKey, storedPatterns, target);
|
||||
vscode.window.showInformationMessage(`🗑️ Pattern "${patternToDelete.label}" deleted from ${scope} settings`);
|
||||
}
|
||||
async function renamePattern(id, newLabel, scope) {
|
||||
const config = vscode.workspace.getConfiguration(C.CONFIG_NAMESPACE);
|
||||
const configKey = scope === 'global' ? C.CONFIG_KEY_USER_PATTERNS : C.CONFIG_KEY_WORKSPACE_PATTERNS;
|
||||
const target = scope === 'global'
|
||||
? vscode.ConfigurationTarget.Global
|
||||
: vscode.ConfigurationTarget.Workspace;
|
||||
// Read fresh patterns with runtime IDs
|
||||
const patternsWithIds = getPatternsByScope(scope);
|
||||
// Find pattern by runtime ID
|
||||
const pattern = patternsWithIds.find(p => p.id === id);
|
||||
if (!pattern) {
|
||||
vscode.window.showWarningMessage(`Pattern not found in ${scope} settings`);
|
||||
return;
|
||||
}
|
||||
const oldLabel = pattern.label;
|
||||
// Update label and strip IDs for saving
|
||||
const storedPatterns = patternsWithIds.map(p => {
|
||||
const { id: _id, ...stored } = p;
|
||||
if (p.id === id) {
|
||||
return { ...stored, label: newLabel };
|
||||
}
|
||||
return stored;
|
||||
});
|
||||
// Save updated list (without IDs)
|
||||
await config.update(configKey, storedPatterns, target);
|
||||
vscode.window.showInformationMessage(`✏️ Pattern renamed from "${oldLabel}" to "${newLabel}" in ${scope} settings`);
|
||||
}
|
||||
function patternExists(label, scope) {
|
||||
const patterns = getPatternsByScope(scope);
|
||||
return patterns.some(p => p.label === label);
|
||||
}
|
||||
//# sourceMappingURL=storage.js.map
|
||||
@@ -0,0 +1,3 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
//# sourceMappingURL=types.js.map
|
||||
+266
@@ -0,0 +1,266 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || (function () {
|
||||
var ownKeys = function(o) {
|
||||
ownKeys = Object.getOwnPropertyNames || function (o) {
|
||||
var ar = [];
|
||||
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
||||
return ar;
|
||||
};
|
||||
return ownKeys(o);
|
||||
};
|
||||
return function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
})();
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.WebviewManager = void 0;
|
||||
const vscode = __importStar(require("vscode"));
|
||||
const path = __importStar(require("path"));
|
||||
const fs = __importStar(require("fs"));
|
||||
const storage = __importStar(require("../storage"));
|
||||
const searchCtx = __importStar(require("../searchCtx"));
|
||||
/**
|
||||
* Manages the webview panel for pattern management
|
||||
*/
|
||||
class WebviewManager {
|
||||
/**
|
||||
* Create or show the webview panel
|
||||
*/
|
||||
static show(extensionUri, scope) {
|
||||
const column = vscode.window.activeTextEditor
|
||||
? vscode.window.activeTextEditor.viewColumn
|
||||
: undefined;
|
||||
// If we already have a panel, show it
|
||||
if (WebviewManager.currentPanel) {
|
||||
WebviewManager.currentPanel.panel.reveal(column);
|
||||
return;
|
||||
}
|
||||
const panel = vscode.window.createWebviewPanel('patternStoreManage', 'PatternStore', column || vscode.ViewColumn.One, {
|
||||
enableScripts: true,
|
||||
retainContextWhenHidden: true,
|
||||
});
|
||||
WebviewManager.currentPanel = new WebviewManager(panel, extensionUri, scope);
|
||||
}
|
||||
constructor(panel, extensionUri, scope) {
|
||||
this.disposables = [];
|
||||
this.isInternalSave = false;
|
||||
this.panel = panel;
|
||||
this.extensionUri = extensionUri;
|
||||
this.scope = scope;
|
||||
// Set initial HTML content
|
||||
this.panel.webview.html = this.getHtmlContent();
|
||||
// Listen for when the panel is disposed
|
||||
this.panel.onDidDispose(() => this.dispose(), null, this.disposables);
|
||||
// Handle messages from the webview
|
||||
this.panel.webview.onDidReceiveMessage(message => {
|
||||
this.handleMessage(message);
|
||||
}, null, this.disposables);
|
||||
// Watch for external config changes
|
||||
vscode.workspace.onDidChangeConfiguration(e => {
|
||||
if (e.affectsConfiguration('patternStore')) {
|
||||
this.handleExternalConfigChange();
|
||||
}
|
||||
}, null, this.disposables);
|
||||
this.sendPatterns();
|
||||
}
|
||||
sendPatterns(selectId, selectScope, clearSelection) {
|
||||
const allPatterns = storage.getAllPatterns();
|
||||
const workspacePatterns = allPatterns.filter(p => p.scope === 'workspace');
|
||||
const userPatterns = allPatterns.filter(p => p.scope === 'global');
|
||||
const message = {
|
||||
type: 'patterns',
|
||||
workspace: workspacePatterns,
|
||||
user: userPatterns
|
||||
};
|
||||
if (selectId && selectScope) {
|
||||
message.selectPattern = {
|
||||
id: selectId,
|
||||
scope: selectScope
|
||||
};
|
||||
}
|
||||
if (clearSelection) {
|
||||
message.clearSelection = true;
|
||||
}
|
||||
this.panel.webview.postMessage(message);
|
||||
}
|
||||
/**
|
||||
* Handle external configuration changes (e.g., manual edits to settings.json)
|
||||
*/
|
||||
handleExternalConfigChange() {
|
||||
// Don't show notification if this was an internal save
|
||||
if (this.isInternalSave) {
|
||||
this.isInternalSave = false;
|
||||
return;
|
||||
}
|
||||
// Show warning to user for actual external changes
|
||||
vscode.window.showWarningMessage('Pattern settings changed externally. Webview reloaded.');
|
||||
// Force full reload - this clears any dirty state and rebuilds runtime IDs
|
||||
// Pass clearSelection flag to force the webview to clear the details view
|
||||
this.sendPatterns(undefined, undefined, true);
|
||||
}
|
||||
async handleMessage(message) {
|
||||
console.log('Received message from webview:', message);
|
||||
switch (message.type) {
|
||||
case 'ready':
|
||||
// Webview is ready, send patterns
|
||||
this.sendPatterns();
|
||||
break;
|
||||
case 'delete':
|
||||
await this.handleDelete(message.id, message.scope);
|
||||
break;
|
||||
case 'load':
|
||||
await this.handleLoad(message.id, message.scope, message.pattern);
|
||||
break;
|
||||
case 'create':
|
||||
await this.handleCreate(message.scope);
|
||||
break;
|
||||
case 'save':
|
||||
await this.handleSave(message.pattern);
|
||||
break;
|
||||
}
|
||||
}
|
||||
async handleCreate(scope) {
|
||||
// Generate unique label for new pattern
|
||||
const existingPatterns = storage.getAllPatterns().filter(p => p.scope === scope);
|
||||
const baseName = 'New Pattern';
|
||||
let label = baseName;
|
||||
let counter = 1;
|
||||
while (existingPatterns.some(p => p.label === label)) {
|
||||
counter++;
|
||||
label = `${baseName} ${counter}`;
|
||||
}
|
||||
const newPattern = {
|
||||
id: 'new', // Temporary ID for new patterns
|
||||
label: label,
|
||||
find: '',
|
||||
replace: '',
|
||||
flags: {
|
||||
isRegex: false,
|
||||
isCaseSensitive: false,
|
||||
matchWholeWord: false,
|
||||
isMultiline: false
|
||||
},
|
||||
scope: scope
|
||||
};
|
||||
// Mark as internal save to suppress external change notification
|
||||
this.isInternalSave = true;
|
||||
await storage.savePattern(newPattern);
|
||||
// New pattern will be at index 0 (savePattern uses unshift)
|
||||
this.sendPatterns(`${scope}-0`, scope);
|
||||
}
|
||||
async handleSave(patternData) {
|
||||
const { id, label, find, replace, flags, filesToInclude, filesToExclude, scope } = patternData;
|
||||
const pattern = {
|
||||
id: id, // Preserve existing ID
|
||||
label: label,
|
||||
find: find,
|
||||
replace: replace,
|
||||
flags: flags,
|
||||
filesToInclude: filesToInclude,
|
||||
filesToExclude: filesToExclude,
|
||||
scope: scope
|
||||
};
|
||||
// Mark as internal save to suppress external change notification
|
||||
this.isInternalSave = true;
|
||||
await storage.savePattern(pattern);
|
||||
this.sendPatterns(id, scope);
|
||||
}
|
||||
async handleDelete(id, scope) {
|
||||
// Find pattern to get label for confirmation
|
||||
const allPatterns = storage.getAllPatterns();
|
||||
const pattern = allPatterns.find(p => p.id === id && p.scope === scope);
|
||||
if (!pattern) {
|
||||
vscode.window.showErrorMessage(`Pattern not found`);
|
||||
return;
|
||||
}
|
||||
// Confirm deletion
|
||||
const confirm = await vscode.window.showWarningMessage(`Delete pattern "${pattern.label}"?`, { modal: true }, 'Delete');
|
||||
if (confirm === 'Delete') {
|
||||
// Mark as internal save to suppress external change notification
|
||||
this.isInternalSave = true;
|
||||
await storage.deletePattern(id, scope);
|
||||
// Refresh pattern list
|
||||
this.sendPatterns();
|
||||
}
|
||||
}
|
||||
async handleLoad(id, scope, providedPattern) {
|
||||
let pattern = providedPattern;
|
||||
// If no pattern was provided, look it up
|
||||
if (!pattern) {
|
||||
const allPatterns = storage.getAllPatterns();
|
||||
pattern = allPatterns.find(p => p.id === id && p.scope === scope);
|
||||
if (!pattern) {
|
||||
vscode.window.showErrorMessage(`Pattern "${id}" not found`);
|
||||
return;
|
||||
}
|
||||
}
|
||||
await searchCtx.loadPatternIntoSearch(pattern);
|
||||
}
|
||||
getHtmlContent() {
|
||||
// Generate nonce for CSP
|
||||
const nonce = this.getNonce();
|
||||
// Get URIs for webview resources
|
||||
const cspSource = this.panel.webview.cspSource;
|
||||
// Load HTML, CSS, and JS from files
|
||||
const htmlPath = path.join(this.extensionUri.fsPath, 'src', 'webview', 'html', 'patternManager.html');
|
||||
const cssPath = path.join(this.extensionUri.fsPath, 'src', 'webview', 'css', 'patternManager.css');
|
||||
const jsPath = path.join(this.extensionUri.fsPath, 'src', 'webview', 'js', 'patternManager.js');
|
||||
let html = fs.readFileSync(htmlPath, 'utf8');
|
||||
const css = fs.readFileSync(cssPath, 'utf8');
|
||||
const js = fs.readFileSync(jsPath, 'utf8');
|
||||
// Build style tag with nonce
|
||||
const styleTag = `<style nonce="${nonce}">\n${css}\n </style>`;
|
||||
// Replace placeholders
|
||||
html = html.replace(/{{nonce}}/g, nonce);
|
||||
html = html.replace(/{{cspSource}}/g, cspSource);
|
||||
html = html.replace(/{{styleTag}}/g, styleTag);
|
||||
html = html.replace(/{{script}}/g, js);
|
||||
return html;
|
||||
}
|
||||
/**
|
||||
* Generate a nonce for CSP
|
||||
*/
|
||||
getNonce() {
|
||||
let text = '';
|
||||
const possible = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
|
||||
for (let i = 0; i < 32; i++) {
|
||||
text += possible.charAt(Math.floor(Math.random() * possible.length));
|
||||
}
|
||||
return text;
|
||||
}
|
||||
/**
|
||||
* Clean up resources
|
||||
*/
|
||||
dispose() {
|
||||
WebviewManager.currentPanel = undefined;
|
||||
this.panel.dispose();
|
||||
while (this.disposables.length) {
|
||||
const disposable = this.disposables.pop();
|
||||
if (disposable) {
|
||||
disposable.dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
exports.WebviewManager = WebviewManager;
|
||||
//# sourceMappingURL=WebviewManager.js.map
|
||||
@@ -0,0 +1,148 @@
|
||||
{
|
||||
"name": "patternstore",
|
||||
"displayName": "PatternStore",
|
||||
"description": "Save and recall reusable regex find/replace pairs in VS Code",
|
||||
"version": "0.1.12",
|
||||
"publisher": "jdunkel",
|
||||
"engines": {
|
||||
"vscode": "^1.85.0"
|
||||
},
|
||||
"icon": "assets/pattern-store-icon.png",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/JoachimDunkel/PatternStore"
|
||||
},
|
||||
"keywords": [
|
||||
"search",
|
||||
"replace",
|
||||
"regex",
|
||||
"find",
|
||||
"pattern",
|
||||
"snippet"
|
||||
],
|
||||
"categories": [
|
||||
"Other"
|
||||
],
|
||||
"galleryBanner": {
|
||||
"color": "#1e1e1e",
|
||||
"theme": "dark"
|
||||
},
|
||||
"main": "./out/extension.js",
|
||||
"contributes": {
|
||||
"commands": [
|
||||
{
|
||||
"command": "patternStore.manage",
|
||||
"title": "PatternStore: Manage Patterns",
|
||||
"icon": "$(book)"
|
||||
}
|
||||
],
|
||||
"configuration": {
|
||||
"title": "PatternStore",
|
||||
"properties": {
|
||||
"patternStore.savedPatterns": {
|
||||
"type": "array",
|
||||
"default": [],
|
||||
"description": "Global patterns available in all workspaces",
|
||||
"items": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"label": {
|
||||
"type": "string"
|
||||
},
|
||||
"find": {
|
||||
"type": "string"
|
||||
},
|
||||
"replace": {
|
||||
"type": "string"
|
||||
},
|
||||
"flags": {
|
||||
"type": "object"
|
||||
},
|
||||
"filesToInclude": {
|
||||
"type": "string",
|
||||
"description": "Files to include (glob pattern, e.g. '*.ts,*.js' or 'src/**')"
|
||||
},
|
||||
"filesToExclude": {
|
||||
"type": "string",
|
||||
"description": "Files to exclude (glob pattern, e.g. 'node_modules/**,dist/**')"
|
||||
},
|
||||
"scope": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"patternStore.workspacePatterns": {
|
||||
"type": "array",
|
||||
"default": [],
|
||||
"description": "Workspace-specific patterns",
|
||||
"scope": "resource",
|
||||
"items": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"label": {
|
||||
"type": "string"
|
||||
},
|
||||
"find": {
|
||||
"type": "string"
|
||||
},
|
||||
"replace": {
|
||||
"type": "string"
|
||||
},
|
||||
"flags": {
|
||||
"type": "object"
|
||||
},
|
||||
"filesToInclude": {
|
||||
"type": "string",
|
||||
"description": "Files to include (glob pattern, e.g. '*.ts,*.js' or 'src/**')"
|
||||
},
|
||||
"filesToExclude": {
|
||||
"type": "string",
|
||||
"description": "Files to exclude (glob pattern, e.g. 'node_modules/**,dist/**')"
|
||||
},
|
||||
"scope": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"keybindings": [
|
||||
{
|
||||
"command": "patternStore.manage",
|
||||
"key": "ctrl+alt+r",
|
||||
"mac": "cmd+alt+r"
|
||||
}
|
||||
],
|
||||
"menus": {
|
||||
"view/title": [
|
||||
{
|
||||
"command": "patternStore.manage",
|
||||
"when": "view == workbench.view.search",
|
||||
"group": "navigation"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"scripts": {
|
||||
"vscode:prepublish": "npm run compile",
|
||||
"compile": "tsc -p ./",
|
||||
"watch": "tsc -watch -p ./",
|
||||
"pretest": "npm run compile && npm run lint",
|
||||
"lint": "eslint src --ext ts"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^20.x",
|
||||
"@types/vscode": "^1.85.0",
|
||||
"@typescript-eslint/eslint-plugin": "^6.x",
|
||||
"@typescript-eslint/parser": "^6.x",
|
||||
"eslint": "^8.x",
|
||||
"typescript": "^5.3.0"
|
||||
},
|
||||
"__metadata": {
|
||||
"installedTimestamp": 1783822352061,
|
||||
"targetPlatform": "undefined",
|
||||
"size": 1218391
|
||||
}
|
||||
}
|
||||
+561
@@ -0,0 +1,561 @@
|
||||
body {
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
font-family: var(--vscode-font-family);
|
||||
color: var(--vscode-foreground);
|
||||
}
|
||||
|
||||
.container {
|
||||
display: flex;
|
||||
height: 100vh;
|
||||
gap: 0;
|
||||
background: var(--vscode-panel-border);
|
||||
position: relative;
|
||||
}
|
||||
|
||||
/* Left panel - Pattern list */
|
||||
.pattern-list-panel {
|
||||
flex: 0 0 300px;
|
||||
min-width: 200px;
|
||||
max-width: 600px;
|
||||
background: var(--vscode-sideBar-background);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
/* Resize Handle */
|
||||
.resize-handle {
|
||||
flex: 0 0 4px;
|
||||
background: var(--vscode-panel-border);
|
||||
cursor: ew-resize;
|
||||
position: relative;
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
.resize-handle:hover {
|
||||
background: var(--vscode-focusBorder);
|
||||
}
|
||||
|
||||
.resize-handle.resizing {
|
||||
background: var(--vscode-focusBorder);
|
||||
}
|
||||
|
||||
.search-box {
|
||||
padding: 8px;
|
||||
background: var(--vscode-sideBar-background);
|
||||
border-bottom: 1px solid var(--vscode-panel-border);
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.search-wrapper {
|
||||
position: relative;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.search-icon {
|
||||
position: absolute;
|
||||
left: 8px;
|
||||
pointer-events: none;
|
||||
color: var(--vscode-input-placeholderForeground);
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.search-input {
|
||||
width: 100%;
|
||||
padding: 6px 30px 6px 30px;
|
||||
background: var(--vscode-input-background);
|
||||
color: var(--vscode-input-foreground);
|
||||
border: 1px solid var(--vscode-input-border);
|
||||
border-radius: 2px;
|
||||
font-size: 13px;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.search-input:focus {
|
||||
outline: none;
|
||||
border-color: var(--vscode-focusBorder);
|
||||
}
|
||||
|
||||
.search-clear {
|
||||
position: absolute;
|
||||
right: 6px;
|
||||
padding: 4px;
|
||||
background: transparent;
|
||||
border: none;
|
||||
cursor: pointer;
|
||||
color: var(--vscode-input-placeholderForeground);
|
||||
border-radius: 3px;
|
||||
display: none;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
transition: all 0.15s ease;
|
||||
}
|
||||
|
||||
.search-clear:hover {
|
||||
background: var(--vscode-toolbar-hoverBackground);
|
||||
color: var(--vscode-foreground);
|
||||
}
|
||||
|
||||
.search-clear.visible {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.search-clear .codicon {
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.pattern-list {
|
||||
flex: 1;
|
||||
overflow-y: auto;
|
||||
padding: 4px;
|
||||
}
|
||||
|
||||
.section-header {
|
||||
padding: 8px 12px;
|
||||
font-weight: 600;
|
||||
font-size: 11px;
|
||||
text-transform: uppercase;
|
||||
color: var(--vscode-foreground);
|
||||
opacity: 0.6;
|
||||
letter-spacing: 0.5px;
|
||||
margin-top: 8px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
.section-header-left {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
cursor: pointer;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.add-pattern-btn {
|
||||
padding: 4px;
|
||||
background: transparent;
|
||||
border: none;
|
||||
cursor: pointer;
|
||||
color: var(--vscode-foreground);
|
||||
opacity: 0.6;
|
||||
border-radius: 3px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
transition: all 0.15s ease;
|
||||
}
|
||||
|
||||
.add-pattern-btn:hover {
|
||||
background: var(--vscode-toolbar-hoverBackground);
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.add-pattern-btn .codicon {
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.section-header:hover {
|
||||
opacity: 0.8;
|
||||
}
|
||||
|
||||
.section-header:first-child {
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
.section-header .codicon {
|
||||
font-size: 14px;
|
||||
transition: transform 0.1s ease;
|
||||
}
|
||||
|
||||
.section-header.collapsed .codicon {
|
||||
transform: rotate(-90deg);
|
||||
}
|
||||
|
||||
.section-content {
|
||||
max-height: 10000px;
|
||||
overflow: hidden;
|
||||
transition: max-height 0.15s ease;
|
||||
}
|
||||
|
||||
.section-content.collapsed {
|
||||
max-height: 0;
|
||||
}
|
||||
|
||||
.empty-state {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 48px 24px;
|
||||
color: var(--vscode-descriptionForeground);
|
||||
text-align: center;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.empty-state-section {
|
||||
padding: 16px;
|
||||
text-align: center;
|
||||
color: var(--vscode-descriptionForeground);
|
||||
font-size: 13px;
|
||||
opacity: 0.8;
|
||||
}
|
||||
|
||||
.pattern-item {
|
||||
padding: 8px 12px;
|
||||
cursor: pointer;
|
||||
border-radius: 3px;
|
||||
margin-bottom: 2px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.pattern-item:hover {
|
||||
background: var(--vscode-list-hoverBackground);
|
||||
}
|
||||
|
||||
.pattern-item:hover .pattern-actions {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.pattern-item.selected {
|
||||
background: var(--vscode-list-activeSelectionBackground);
|
||||
color: var(--vscode-list-activeSelectionForeground);
|
||||
}
|
||||
|
||||
.pattern-info {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.pattern-name {
|
||||
font-weight: 500;
|
||||
margin-bottom: 2px;
|
||||
}
|
||||
|
||||
.pattern-preview {
|
||||
font-size: 12px;
|
||||
opacity: 0.8;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.pattern-item-invalid {
|
||||
border-left: 2px solid var(--vscode-errorForeground);
|
||||
opacity: 0.8;
|
||||
}
|
||||
|
||||
.pattern-item-invalid .pattern-name .codicon-warning {
|
||||
color: var(--vscode-errorForeground);
|
||||
margin-left: 4px;
|
||||
font-size: 13px;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.pattern-item-invalid .pattern-preview {
|
||||
color: var(--vscode-errorForeground);
|
||||
}
|
||||
|
||||
.pattern-item-invalid .pattern-preview em {
|
||||
font-style: italic;
|
||||
opacity: 0.7;
|
||||
}
|
||||
|
||||
/* Action buttons */
|
||||
.pattern-actions {
|
||||
display: flex;
|
||||
gap: 4px;
|
||||
opacity: 0;
|
||||
transition: opacity 0.15s ease;
|
||||
}
|
||||
|
||||
.action-btn {
|
||||
padding: 4px;
|
||||
background: transparent;
|
||||
border: none;
|
||||
cursor: pointer;
|
||||
color: var(--vscode-foreground);
|
||||
opacity: 0.7;
|
||||
border-radius: 3px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 24px;
|
||||
height: 24px;
|
||||
}
|
||||
|
||||
.action-btn:hover {
|
||||
background: var(--vscode-toolbar-hoverBackground);
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.action-btn .codicon {
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
.action-btn.delete:hover {
|
||||
color: var(--vscode-errorForeground);
|
||||
}
|
||||
|
||||
.action-btn.load:hover {
|
||||
color: var(--vscode-textLink-foreground);
|
||||
}
|
||||
|
||||
/* Right panel - Edit form */
|
||||
.edit-panel {
|
||||
flex: 1;
|
||||
background: var(--vscode-editor-background);
|
||||
overflow-y: auto;
|
||||
padding: 16px;
|
||||
}
|
||||
|
||||
.edit-empty-state {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
height: 100%;
|
||||
opacity: 0.5;
|
||||
text-align: center;
|
||||
padding: 40px 20px;
|
||||
}
|
||||
|
||||
.edit-empty-state .codicon {
|
||||
font-size: 64px;
|
||||
margin-bottom: 16px;
|
||||
opacity: 0.6;
|
||||
}
|
||||
|
||||
.edit-empty-state p {
|
||||
margin: 4px 0;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.edit-empty-state .hint {
|
||||
font-size: 12px;
|
||||
opacity: 0.7;
|
||||
}
|
||||
|
||||
.edit-form {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.edit-form.active {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.edit-form-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
|
||||
.edit-form h2 {
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
margin: 0;
|
||||
text-transform: uppercase;
|
||||
opacity: 0.8;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.form-input-inline {
|
||||
flex: 1;
|
||||
padding: 4px 6px;
|
||||
background: var(--vscode-input-background);
|
||||
color: var(--vscode-input-foreground);
|
||||
border: 1px solid var(--vscode-input-border);
|
||||
border-radius: 2px;
|
||||
font-size: 13px;
|
||||
font-family: var(--vscode-editor-font-family);
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.form-input-inline:focus {
|
||||
outline: none;
|
||||
border-color: var(--vscode-focusBorder);
|
||||
}
|
||||
|
||||
.form-group {
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
|
||||
.form-label {
|
||||
display: block;
|
||||
margin-bottom: 3px;
|
||||
font-weight: 500;
|
||||
font-size: 11px;
|
||||
opacity: 0.8;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
.form-label-with-options {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
margin-bottom: 3px;
|
||||
}
|
||||
|
||||
.form-label-with-options .form-label {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.form-input,
|
||||
.form-textarea {
|
||||
width: 100%;
|
||||
padding: 4px 6px;
|
||||
background: var(--vscode-input-background);
|
||||
color: var(--vscode-input-foreground);
|
||||
border: 1px solid var(--vscode-input-border);
|
||||
border-radius: 2px;
|
||||
font-size: 13px;
|
||||
font-family: var(--vscode-editor-font-family);
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.form-input:focus,
|
||||
.form-textarea:focus {
|
||||
outline: none;
|
||||
border-color: var(--vscode-focusBorder);
|
||||
}
|
||||
|
||||
.form-input.error,
|
||||
.form-textarea.error {
|
||||
border-color: var(--vscode-errorForeground);
|
||||
}
|
||||
|
||||
.form-input.dirty,
|
||||
.form-input-inline.dirty,
|
||||
.form-textarea.dirty {
|
||||
box-shadow: 0 0 0 1px rgba(106, 153, 85, 0.6);
|
||||
}
|
||||
|
||||
.form-textarea {
|
||||
min-height: 60px;
|
||||
resize: vertical;
|
||||
font-family: var(--vscode-editor-font-family);
|
||||
}
|
||||
|
||||
.validation-error {
|
||||
display: none;
|
||||
color: var(--vscode-errorForeground);
|
||||
font-size: 11px;
|
||||
margin-top: 3px;
|
||||
}
|
||||
|
||||
.validation-error.visible {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.checkbox-group-icons {
|
||||
display: flex;
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
.toggle-btn {
|
||||
padding: 4px 8px;
|
||||
background: var(--vscode-button-secondaryBackground);
|
||||
color: var(--vscode-button-secondaryForeground);
|
||||
border: 1px solid transparent;
|
||||
border-radius: 2px;
|
||||
cursor: pointer;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
transition: all 0.15s ease;
|
||||
min-width: 28px;
|
||||
height: 24px;
|
||||
}
|
||||
|
||||
.toggle-btn:hover {
|
||||
background: var(--vscode-button-secondaryHoverBackground);
|
||||
}
|
||||
|
||||
.toggle-btn.active {
|
||||
background: var(--vscode-button-background);
|
||||
color: var(--vscode-button-foreground);
|
||||
border-color: var(--vscode-focusBorder);
|
||||
}
|
||||
|
||||
.toggle-btn.dirty {
|
||||
border-color: #6a9955;
|
||||
}
|
||||
|
||||
.toggle-btn.active.dirty {
|
||||
background: var(--vscode-button-background);
|
||||
color: var(--vscode-button-foreground);
|
||||
border-color: #6a9955;
|
||||
}
|
||||
|
||||
.toggle-btn .codicon {
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.button-group {
|
||||
display: flex;
|
||||
gap: 6px;
|
||||
margin-top: 16px;
|
||||
padding-top: 12px;
|
||||
border-top: 1px solid var(--vscode-panel-border);
|
||||
}
|
||||
|
||||
button {
|
||||
padding: 5px 12px;
|
||||
background: var(--vscode-button-background);
|
||||
color: var(--vscode-button-foreground);
|
||||
border: none;
|
||||
border-radius: 2px;
|
||||
cursor: pointer;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
button:hover {
|
||||
background: var(--vscode-button-hoverBackground);
|
||||
}
|
||||
|
||||
button.secondary {
|
||||
background: var(--vscode-button-secondaryBackground);
|
||||
color: var(--vscode-button-secondaryForeground);
|
||||
}
|
||||
|
||||
button.secondary:hover {
|
||||
background: var(--vscode-button-secondaryHoverBackground);
|
||||
}
|
||||
|
||||
.dirty-indicator {
|
||||
margin-left: 6px;
|
||||
color: var(--vscode-editorWarning-foreground);
|
||||
font-size: 8px;
|
||||
animation: pulse 2s ease-in-out infinite;
|
||||
width: 8px;
|
||||
display: inline-block;
|
||||
visibility: hidden;
|
||||
}
|
||||
|
||||
@keyframes pulse {
|
||||
0%, 100% {
|
||||
opacity: 1;
|
||||
}
|
||||
50% {
|
||||
opacity: 0.5;
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes pulseBorder {
|
||||
0%, 100% {
|
||||
border-color: #4ec9b0;
|
||||
}
|
||||
50% {
|
||||
border-color: #dcdcaa;
|
||||
}
|
||||
}
|
||||
+106
@@ -0,0 +1,106 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta http-equiv="Content-Security-Policy"
|
||||
content="default-src 'none'; style-src {{cspSource}} https://unpkg.com 'nonce-{{nonce}}'; font-src https://unpkg.com; script-src 'nonce-{{nonce}}';">
|
||||
<title>Manage Patterns</title>
|
||||
<link href="https://unpkg.com/@vscode/codicons/dist/codicon.css" rel="stylesheet" />
|
||||
{{styleTag}}
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="container">
|
||||
<!-- Left: Pattern List -->
|
||||
<div class="pattern-list-panel">
|
||||
<div class="search-box">
|
||||
<div class="search-wrapper">
|
||||
<i class="codicon codicon-search search-icon"></i>
|
||||
<input type="text" class="search-input" placeholder="Search patterns..." id="searchInput" />
|
||||
<button class="search-clear" id="searchClear" title="Clear search">
|
||||
<i class="codicon codicon-close"></i>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="pattern-list" id="patternList">
|
||||
<!-- Patterns will be inserted here -->
|
||||
<div class="empty-state">No patterns yet</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Resize Handle -->
|
||||
<div class="resize-handle" id="resizeHandle"></div>
|
||||
|
||||
<div class="edit-panel" id="editPanel">
|
||||
<div class="edit-empty-state" id="editEmptyState">
|
||||
<i class="codicon codicon-list-selection"></i>
|
||||
<p>Select a pattern to edit</p>
|
||||
<p class="hint">or create a new one with the + button</p>
|
||||
</div>
|
||||
|
||||
<div class="edit-form" id="editForm">
|
||||
<div class="edit-form-header">
|
||||
<h2>Pattern</h2>
|
||||
<input type="text" class="form-input-inline" id="labelInput" placeholder="Pattern name" />
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<div class="form-label-with-options">
|
||||
<label class="form-label" for="findInput">Find</label>
|
||||
<div class="checkbox-group-icons">
|
||||
|
||||
<button type="button" class="toggle-btn" id="isCaseSensitiveBtn" title="Match Case">
|
||||
<i class="codicon codicon-case-sensitive"></i>
|
||||
</button>
|
||||
<button type="button" class="toggle-btn" id="matchWholeWordBtn" title="Match Whole Word">
|
||||
<i class="codicon codicon-whole-word"></i>
|
||||
</button>
|
||||
<button type="button" class="toggle-btn" id="isRegexBtn" title="Use Regular Expression">
|
||||
<i class="codicon codicon-regex"></i>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<textarea class="form-textarea" id="findInput" placeholder="Search pattern or regex"></textarea>
|
||||
<div class="validation-error" id="findValidationError"></div>
|
||||
<!-- Hidden checkboxes to maintain state -->
|
||||
<input type="checkbox" id="isCaseSensitive" hidden />
|
||||
<input type="checkbox" id="matchWholeWord" hidden />
|
||||
<input type="checkbox" id="isRegex" hidden />
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="form-label" for="replaceInput">Replace (optional)</label>
|
||||
<textarea class="form-textarea" id="replaceInput" placeholder="Replacement text"></textarea>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="form-label" for="filesToInclude">Files to Include</label>
|
||||
<input type="text" class="form-input" id="filesToInclude" placeholder="*.ts,*.js or src/**" />
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="form-label" for="filesToExclude">Files to Exclude</label>
|
||||
<input type="text" class="form-input" id="filesToExclude" placeholder="node_modules/**,dist/**" />
|
||||
</div>
|
||||
|
||||
<div class="button-group">
|
||||
<button id="saveBtn">
|
||||
Save
|
||||
<span id="dirtyIndicator" class="dirty-indicator">
|
||||
<i class="codicon codicon-circle-filled"></i>
|
||||
</span>
|
||||
</button>
|
||||
<button id="loadBtn" class="secondary">
|
||||
<i class="codicon codicon-arrow-right"></i>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script nonce="{{nonce}}">{{script}}</script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
+857
@@ -0,0 +1,857 @@
|
||||
const vscode = acquireVsCodeApi();
|
||||
|
||||
// Store patterns data
|
||||
let workspacePatterns = [];
|
||||
let userPatterns = [];
|
||||
let workspacePatternsMap = new Map(); // id -> pattern
|
||||
let userPatternsMap = new Map(); // id -> pattern
|
||||
let searchQuery = '';
|
||||
|
||||
// Dirty state tracking
|
||||
let savedPatternState = null;
|
||||
|
||||
// Cache DOM elements for performance
|
||||
const domCache = {
|
||||
labelInput: null,
|
||||
findInput: null,
|
||||
replaceInput: null,
|
||||
filesToInclude: null,
|
||||
filesToExclude: null,
|
||||
isRegex: null,
|
||||
isCaseSensitive: null,
|
||||
matchWholeWord: null,
|
||||
isRegexBtn: null,
|
||||
isCaseSensitiveBtn: null,
|
||||
matchWholeWordBtn: null,
|
||||
dirtyIndicator: null,
|
||||
patternList: null,
|
||||
editForm: null,
|
||||
editEmptyState: null,
|
||||
findValidationError: null
|
||||
};
|
||||
|
||||
function initDomCache() {
|
||||
domCache.labelInput = document.getElementById('labelInput');
|
||||
domCache.findInput = document.getElementById('findInput');
|
||||
domCache.replaceInput = document.getElementById('replaceInput');
|
||||
domCache.filesToInclude = document.getElementById('filesToInclude');
|
||||
domCache.filesToExclude = document.getElementById('filesToExclude');
|
||||
domCache.isRegex = document.getElementById('isRegex');
|
||||
domCache.isCaseSensitive = document.getElementById('isCaseSensitive');
|
||||
domCache.matchWholeWord = document.getElementById('matchWholeWord');
|
||||
domCache.isRegexBtn = document.getElementById('isRegexBtn');
|
||||
domCache.isCaseSensitiveBtn = document.getElementById('isCaseSensitiveBtn');
|
||||
domCache.matchWholeWordBtn = document.getElementById('matchWholeWordBtn');
|
||||
domCache.dirtyIndicator = document.getElementById('dirtyIndicator');
|
||||
domCache.patternList = document.getElementById('patternList');
|
||||
domCache.editForm = document.getElementById('editForm');
|
||||
domCache.editEmptyState = document.getElementById('editEmptyState');
|
||||
domCache.findValidationError = document.getElementById('findValidationError');
|
||||
}
|
||||
|
||||
function checkIfDirty() {
|
||||
const state = vscode.getState() || {};
|
||||
const currentPattern = state.currentPattern;
|
||||
|
||||
if (!currentPattern || !savedPatternState) {
|
||||
updateDirtyIndicator(false);
|
||||
clearAllDirtyClasses();
|
||||
return;
|
||||
}
|
||||
|
||||
// Compare current form values with saved state
|
||||
const isDirty =
|
||||
domCache.labelInput.value.trim() !== savedPatternState.label ||
|
||||
domCache.findInput.value !== savedPatternState.find ||
|
||||
domCache.replaceInput.value !== savedPatternState.replace ||
|
||||
domCache.isRegex.checked !== savedPatternState.flags.isRegex ||
|
||||
domCache.isCaseSensitive.checked !== savedPatternState.flags.isCaseSensitive ||
|
||||
domCache.matchWholeWord.checked !== savedPatternState.flags.matchWholeWord ||
|
||||
(domCache.filesToInclude.value.trim() || '') !== (savedPatternState.filesToInclude || '') ||
|
||||
(domCache.filesToExclude.value.trim() || '') !== (savedPatternState.filesToExclude || '');
|
||||
|
||||
updateDirtyIndicator(isDirty);
|
||||
updateFieldDirtyStates();
|
||||
}
|
||||
|
||||
function updateDirtyIndicator(isDirty) {
|
||||
if (domCache.dirtyIndicator) {
|
||||
domCache.dirtyIndicator.style.visibility = isDirty ? 'visible' : 'hidden';
|
||||
}
|
||||
}
|
||||
|
||||
function updateFieldDirtyStates() {
|
||||
if (!savedPatternState) {
|
||||
clearAllDirtyClasses();
|
||||
return;
|
||||
}
|
||||
|
||||
// Check text inputs using cached DOM references
|
||||
if (domCache.labelInput) {
|
||||
toggleDirtyClass(domCache.labelInput, domCache.labelInput.value.trim() !== savedPatternState.label);
|
||||
}
|
||||
if (domCache.findInput) {
|
||||
toggleDirtyClass(domCache.findInput, domCache.findInput.value !== savedPatternState.find);
|
||||
}
|
||||
if (domCache.replaceInput) {
|
||||
toggleDirtyClass(domCache.replaceInput, domCache.replaceInput.value !== savedPatternState.replace);
|
||||
}
|
||||
if (domCache.filesToInclude) {
|
||||
toggleDirtyClass(domCache.filesToInclude, (domCache.filesToInclude.value.trim() || '') !== (savedPatternState.filesToInclude || ''));
|
||||
}
|
||||
if (domCache.filesToExclude) {
|
||||
toggleDirtyClass(domCache.filesToExclude, (domCache.filesToExclude.value.trim() || '') !== (savedPatternState.filesToExclude || ''));
|
||||
}
|
||||
|
||||
// Check toggle buttons using cached DOM references
|
||||
if (domCache.isRegexBtn && domCache.isRegex) {
|
||||
toggleDirtyClass(domCache.isRegexBtn, domCache.isRegex.checked !== savedPatternState.flags.isRegex);
|
||||
}
|
||||
if (domCache.isCaseSensitiveBtn && domCache.isCaseSensitive) {
|
||||
toggleDirtyClass(domCache.isCaseSensitiveBtn, domCache.isCaseSensitive.checked !== savedPatternState.flags.isCaseSensitive);
|
||||
}
|
||||
if (domCache.matchWholeWordBtn && domCache.matchWholeWord) {
|
||||
toggleDirtyClass(domCache.matchWholeWordBtn, domCache.matchWholeWord.checked !== savedPatternState.flags.matchWholeWord);
|
||||
}
|
||||
}
|
||||
|
||||
function toggleDirtyClass(element, isDirty) {
|
||||
if (isDirty) {
|
||||
element.classList.add('dirty');
|
||||
} else {
|
||||
element.classList.remove('dirty');
|
||||
}
|
||||
}
|
||||
|
||||
function clearAllDirtyClasses() {
|
||||
const elements = [
|
||||
domCache.labelInput, domCache.findInput, domCache.replaceInput,
|
||||
domCache.filesToInclude, domCache.filesToExclude,
|
||||
domCache.isRegexBtn, domCache.isCaseSensitiveBtn, domCache.matchWholeWordBtn
|
||||
];
|
||||
|
||||
elements.forEach(element => {
|
||||
if (element) {
|
||||
element.classList.remove('dirty');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function saveDirtyState(pattern) {
|
||||
savedPatternState = {
|
||||
label: pattern.label,
|
||||
find: pattern.find || '',
|
||||
replace: pattern.replace || '',
|
||||
flags: { ...pattern.flags },
|
||||
filesToInclude: pattern.filesToInclude || '',
|
||||
filesToExclude: pattern.filesToExclude || ''
|
||||
};
|
||||
updateDirtyIndicator(false);
|
||||
clearAllDirtyClasses();
|
||||
}
|
||||
|
||||
function findPatternById(id, scope) {
|
||||
const map = scope === 'workspace' ? workspacePatternsMap : userPatternsMap;
|
||||
return map.get(id);
|
||||
}
|
||||
|
||||
function rebuildPatternMaps() {
|
||||
workspacePatternsMap.clear();
|
||||
userPatternsMap.clear();
|
||||
|
||||
workspacePatterns.forEach(p => workspacePatternsMap.set(p.id, p));
|
||||
userPatterns.forEach(p => userPatternsMap.set(p.id, p));
|
||||
}
|
||||
|
||||
// Get collapse state from localStorage
|
||||
const getCollapseState = (section) => {
|
||||
const state = vscode.getState() || {};
|
||||
return state[section + '_collapsed'] === true;
|
||||
};
|
||||
|
||||
// Get collapse state with a default value if not previously set
|
||||
const getCollapseStateWithDefault = (section, defaultValue) => {
|
||||
const state = vscode.getState() || {};
|
||||
const key = section + '_collapsed';
|
||||
// If user has explicitly set a preference, use it; otherwise use default
|
||||
return state[key] !== undefined ? state[key] : defaultValue;
|
||||
};
|
||||
|
||||
// Save collapse state to localStorage
|
||||
const setCollapseState = (section, collapsed) => {
|
||||
const state = vscode.getState() || {};
|
||||
state[section + '_collapsed'] = collapsed;
|
||||
vscode.setState(state);
|
||||
};
|
||||
|
||||
window.addEventListener('message', event => {
|
||||
const message = event.data;
|
||||
|
||||
if (message.type === 'patterns') {
|
||||
|
||||
disablePatternList(false);
|
||||
document.body.style.cursor = '';
|
||||
|
||||
workspacePatterns = message.workspace;
|
||||
userPatterns = message.user;
|
||||
rebuildPatternMaps(); // Rebuild Maps for O(1) lookups
|
||||
renderPatternList();
|
||||
setupSearchInput();
|
||||
|
||||
// Force clear selection if requested (e.g., on external config changes)
|
||||
if (message.clearSelection) {
|
||||
clearDetailsView();
|
||||
} else if (message.selectPattern) {
|
||||
selectPattern(message.selectPattern.id, message.selectPattern.scope);
|
||||
} else {
|
||||
const state = vscode.getState() || {};
|
||||
if (state.currentPattern) {
|
||||
const allPatterns = state.currentPattern.scope === 'workspace' ? workspacePatterns : userPatterns;
|
||||
const stillExists = allPatterns.some(p => p.id === state.currentPattern.id);
|
||||
|
||||
if (!stillExists) {
|
||||
clearDetailsView();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Focus search input when webview opens
|
||||
const searchInput = document.getElementById('searchInput');
|
||||
if (searchInput) {
|
||||
searchInput.focus();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
function setupSearchInput() {
|
||||
const searchInput = document.getElementById('searchInput');
|
||||
const searchClear = document.getElementById('searchClear');
|
||||
|
||||
if (!searchInput || !searchClear) return;
|
||||
|
||||
// if (searchInput.dataset.initialized === 'true') {
|
||||
// return;
|
||||
// }
|
||||
|
||||
// searchInput.dataset.initialized = 'true';
|
||||
|
||||
searchInput.addEventListener('input', (e) => {
|
||||
searchQuery = e.target.value.toLowerCase();
|
||||
|
||||
if (searchQuery) {
|
||||
searchClear.classList.add('visible');
|
||||
} else {
|
||||
searchClear.classList.remove('visible');
|
||||
}
|
||||
|
||||
renderPatternList();
|
||||
});
|
||||
|
||||
searchClear.addEventListener('click', () => {
|
||||
searchInput.value = '';
|
||||
searchQuery = '';
|
||||
searchClear.classList.remove('visible');
|
||||
renderPatternList();
|
||||
searchInput.focus();
|
||||
});
|
||||
|
||||
searchInput.addEventListener('keydown', (e) => {
|
||||
if (e.key === 'Escape' && searchQuery) {
|
||||
searchInput.value = '';
|
||||
searchQuery = '';
|
||||
searchClear.classList.remove('visible');
|
||||
renderPatternList();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function filterPatterns(patterns) {
|
||||
if (!searchQuery) return patterns;
|
||||
|
||||
return patterns.filter(pattern => {
|
||||
const nameMatch = pattern.label.toLowerCase().includes(searchQuery);
|
||||
const findMatch = pattern.find.toLowerCase().includes(searchQuery);
|
||||
const replaceMatch = pattern.replace && pattern.replace.toLowerCase().includes(searchQuery);
|
||||
return nameMatch || findMatch || replaceMatch;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function renderPatternList() {
|
||||
const listContainer = document.getElementById('patternList');
|
||||
|
||||
const filteredWorkspace = filterPatterns(workspacePatterns);
|
||||
const filteredUser = filterPatterns(userPatterns);
|
||||
let html = '';
|
||||
|
||||
if (searchQuery && filteredWorkspace.length === 0 && filteredUser.length === 0) {
|
||||
listContainer.innerHTML = '<div class="empty-state">No patterns found</div>';
|
||||
return;
|
||||
}
|
||||
|
||||
// Collapse empty sections by default, but respect user's saved preference
|
||||
const workspaceCollapsed = searchQuery ? false : getCollapseStateWithDefault('workspace', filteredWorkspace.length === 0);
|
||||
html += renderSection('workspace', 'Workspace', filteredWorkspace, workspaceCollapsed);
|
||||
|
||||
const userCollapsed = searchQuery ? false : getCollapseStateWithDefault('user', filteredUser.length === 0);
|
||||
html += renderSection('user', 'User', filteredUser, userCollapsed);
|
||||
|
||||
listContainer.innerHTML = html;
|
||||
|
||||
document.querySelectorAll('.section-header').forEach(header => {
|
||||
header.addEventListener('click', toggleSection);
|
||||
});
|
||||
|
||||
// Event delegation handles all pattern list interactions, no need to re-attach
|
||||
}
|
||||
|
||||
|
||||
function renderSection(id, title, patterns, collapsed) {
|
||||
const chevron = collapsed ? 'codicon-chevron-right' : 'codicon-chevron-down';
|
||||
const contentClass = collapsed ? 'section-content collapsed' : 'section-content';
|
||||
|
||||
let html = `
|
||||
<div class="section-header ${collapsed ? 'collapsed' : ''}" data-section="${id}">
|
||||
<div class="section-header-left">
|
||||
<i class="codicon ${chevron}"></i>
|
||||
<span>${title} (${patterns.length})</span>
|
||||
</div>
|
||||
<button class="add-pattern-btn" data-scope="${id}" title="Add new pattern">
|
||||
<i class="codicon codicon-add"></i>
|
||||
</button>
|
||||
</div>
|
||||
<div class="${contentClass}" data-section-content="${id}">
|
||||
`;
|
||||
|
||||
if (patterns.length === 0) {
|
||||
html += '<div class="empty-state-section">No patterns in this scope</div>';
|
||||
} else {
|
||||
patterns.forEach(pattern => {
|
||||
html += renderPatternItem(pattern);
|
||||
});
|
||||
}
|
||||
|
||||
html += '</div>';
|
||||
return html;
|
||||
}
|
||||
|
||||
|
||||
function toggleSection(event) {
|
||||
if (event.target.closest('.add-pattern-btn')) {
|
||||
return;
|
||||
}
|
||||
|
||||
const header = event.currentTarget;
|
||||
const sectionId = header.dataset.section;
|
||||
const content = document.querySelector('[data-section-content="' + sectionId + '"]');
|
||||
const chevron = header.querySelector('.codicon');
|
||||
|
||||
const isCollapsed = header.classList.contains('collapsed');
|
||||
|
||||
if (isCollapsed) {
|
||||
header.classList.remove('collapsed');
|
||||
content.classList.remove('collapsed');
|
||||
chevron.classList.remove('codicon-chevron-right');
|
||||
chevron.classList.add('codicon-chevron-down');
|
||||
setCollapseState(sectionId, false);
|
||||
} else {
|
||||
header.classList.add('collapsed');
|
||||
content.classList.add('collapsed');
|
||||
chevron.classList.remove('codicon-chevron-down');
|
||||
chevron.classList.add('codicon-chevron-right');
|
||||
setCollapseState(sectionId, true);
|
||||
}
|
||||
}
|
||||
|
||||
function renderPatternItem(pattern) {
|
||||
const preview = pattern.find.substring(0, 40);
|
||||
const truncated = pattern.find.length > 40 ? '...' : '';
|
||||
const isInvalid = !pattern.find || pattern.find.trim() === '';
|
||||
const invalidClass = isInvalid ? 'pattern-item-invalid' : '';
|
||||
|
||||
return `
|
||||
<div class="pattern-item ${invalidClass}" data-id="${pattern.id}" data-label="${pattern.label}" data-scope="${pattern.scope}"> <div class="pattern-info">
|
||||
<div class="pattern-name">
|
||||
${pattern.label}
|
||||
${isInvalid ? '<i class="codicon codicon-warning" title="Find field is empty"></i>' : ''}
|
||||
</div>
|
||||
<div class="pattern-preview">${isInvalid ? '<em>Empty find pattern</em>' : preview + truncated}</div>
|
||||
</div>
|
||||
<div class="pattern-actions">
|
||||
${renderActionButton('trash', 'delete', 'Delete pattern')}
|
||||
${renderActionButton('arrow-right', 'load', 'Load to search')}
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
|
||||
function renderActionButton(icon, action, title) {
|
||||
return `
|
||||
<button class="action-btn ${action}"
|
||||
data-action="${action}"
|
||||
title="${title}"
|
||||
onclick="event.stopPropagation()">
|
||||
<i class="codicon codicon-${icon}"></i>
|
||||
</button>
|
||||
`;
|
||||
}
|
||||
|
||||
// Event delegation for pattern list - set up once, works for all items
|
||||
function setupEventDelegation() {
|
||||
if (!domCache.patternList) return;
|
||||
|
||||
// Delegate all pattern list events to the parent container
|
||||
domCache.patternList.addEventListener('click', (event) => {
|
||||
// Handle pattern item click
|
||||
const patternItem = event.target.closest('.pattern-item');
|
||||
if (patternItem && !event.target.closest('.action-btn') && !event.target.closest('.add-pattern-btn')) {
|
||||
handlePatternClick(patternItem);
|
||||
return;
|
||||
}
|
||||
|
||||
// Handle action button clicks (load, delete)
|
||||
const actionBtn = event.target.closest('.action-btn');
|
||||
if (actionBtn) {
|
||||
event.stopPropagation();
|
||||
handleActionClick(actionBtn);
|
||||
return;
|
||||
}
|
||||
|
||||
// Handle add pattern button clicks
|
||||
const addBtn = event.target.closest('.add-pattern-btn');
|
||||
if (addBtn) {
|
||||
event.stopPropagation();
|
||||
handleAddPattern(addBtn);
|
||||
return;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function handlePatternClick(item) {
|
||||
const id = item.dataset.id;
|
||||
const scope = item.dataset.scope;
|
||||
|
||||
document.querySelectorAll('.pattern-item').forEach(i => {
|
||||
i.classList.remove('selected');
|
||||
});
|
||||
|
||||
item.classList.add('selected');
|
||||
|
||||
const pattern = findPatternById(id, scope);
|
||||
|
||||
if (pattern) {
|
||||
populateDetailsView(pattern);
|
||||
}
|
||||
}
|
||||
|
||||
function populateDetailsView(pattern) {
|
||||
domCache.editEmptyState.style.display = 'none';
|
||||
domCache.editForm.classList.add('active');
|
||||
|
||||
domCache.labelInput.value = pattern.label;
|
||||
domCache.findInput.value = pattern.find || '';
|
||||
domCache.replaceInput.value = pattern.replace || '';
|
||||
|
||||
domCache.isRegex.checked = pattern.flags.isRegex;
|
||||
domCache.isCaseSensitive.checked = pattern.flags.isCaseSensitive;
|
||||
domCache.matchWholeWord.checked = pattern.flags.matchWholeWord;
|
||||
|
||||
updateToggleButtonState(domCache.isRegexBtn, pattern.flags.isRegex);
|
||||
updateToggleButtonState(domCache.isCaseSensitiveBtn, pattern.flags.isCaseSensitive);
|
||||
updateToggleButtonState(domCache.matchWholeWordBtn, pattern.flags.matchWholeWord);
|
||||
|
||||
domCache.findInput.classList.remove('error');
|
||||
domCache.findValidationError.classList.remove('visible');
|
||||
validateRegexPattern();
|
||||
|
||||
domCache.filesToInclude.value = pattern.filesToInclude || '';
|
||||
domCache.filesToExclude.value = pattern.filesToExclude || '';
|
||||
|
||||
const state = vscode.getState() || {};
|
||||
state.currentPattern = {
|
||||
id: pattern.id,
|
||||
label: pattern.label,
|
||||
scope: pattern.scope
|
||||
};
|
||||
vscode.setState(state);
|
||||
|
||||
// Save the clean state for dirty tracking
|
||||
saveDirtyState(pattern);
|
||||
}
|
||||
|
||||
function selectPattern(id, scope) {
|
||||
const item = document.querySelector(
|
||||
`.pattern-item[data-id="${id}"][data-scope="${scope}"]`
|
||||
);
|
||||
|
||||
if (item) {
|
||||
item.click();
|
||||
}
|
||||
}
|
||||
|
||||
function handleSavePattern() {
|
||||
const state = vscode.getState() || {};
|
||||
const currentPattern = state.currentPattern;
|
||||
|
||||
if (!currentPattern) {
|
||||
console.error('No pattern selected to save');
|
||||
return;
|
||||
}
|
||||
|
||||
const label = domCache.labelInput.value.trim();
|
||||
const find = domCache.findInput.value;
|
||||
const replace = domCache.replaceInput.value;
|
||||
|
||||
if (!label) {
|
||||
alert('Pattern name cannot be empty');
|
||||
return;
|
||||
}
|
||||
|
||||
disablePatternList(true);
|
||||
document.body.style.cursor = 'wait';
|
||||
|
||||
const pattern = {
|
||||
id: currentPattern.id,
|
||||
label: label,
|
||||
find: find,
|
||||
replace: replace,
|
||||
flags: {
|
||||
isRegex: domCache.isRegex.checked,
|
||||
isCaseSensitive: domCache.isCaseSensitive.checked,
|
||||
matchWholeWord: domCache.matchWholeWord.checked,
|
||||
isMultiline: false
|
||||
},
|
||||
filesToInclude: domCache.filesToInclude.value.trim() || undefined,
|
||||
filesToExclude: domCache.filesToExclude.value.trim() || undefined,
|
||||
scope: currentPattern.scope
|
||||
};
|
||||
|
||||
vscode.postMessage({
|
||||
type: 'save',
|
||||
pattern: pattern
|
||||
});
|
||||
}
|
||||
|
||||
function disablePatternList(disabled) {
|
||||
const listPanel = document.querySelector('.pattern-list-panel');
|
||||
if (disabled) {
|
||||
listPanel.style.pointerEvents = 'none';
|
||||
listPanel.style.opacity = '0.6';
|
||||
} else {
|
||||
listPanel.style.pointerEvents = '';
|
||||
listPanel.style.opacity = '';
|
||||
}
|
||||
}
|
||||
|
||||
function handleDeletePattern() {
|
||||
const state = vscode.getState() || {};
|
||||
const currentPattern = state.currentPattern;
|
||||
|
||||
if (!currentPattern) {
|
||||
console.error('No pattern selected to delete');
|
||||
return;
|
||||
}
|
||||
|
||||
vscode.postMessage({
|
||||
type: 'delete',
|
||||
id: currentPattern.id,
|
||||
scope: currentPattern.scope
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
function handleLoadPatternFromDetails() {
|
||||
const state = vscode.getState() || {};
|
||||
const currentPattern = state.currentPattern;
|
||||
|
||||
if (!currentPattern) {
|
||||
console.error('No pattern selected to load');
|
||||
return;
|
||||
}
|
||||
|
||||
// Build pattern from current form values (may be dirty)
|
||||
const pattern = {
|
||||
id: currentPattern.id,
|
||||
label: domCache.labelInput.value.trim(),
|
||||
find: domCache.findInput.value,
|
||||
replace: domCache.replaceInput.value,
|
||||
flags: {
|
||||
isRegex: domCache.isRegex.checked,
|
||||
isCaseSensitive: domCache.isCaseSensitive.checked,
|
||||
matchWholeWord: domCache.matchWholeWord.checked,
|
||||
isMultiline: false
|
||||
},
|
||||
filesToInclude: domCache.filesToInclude.value.trim() || undefined,
|
||||
filesToExclude: domCache.filesToExclude.value.trim() || undefined,
|
||||
scope: currentPattern.scope
|
||||
};
|
||||
|
||||
vscode.postMessage({
|
||||
type: 'load',
|
||||
id: currentPattern.id,
|
||||
scope: currentPattern.scope,
|
||||
pattern: pattern
|
||||
});
|
||||
}
|
||||
|
||||
function clearDetailsView() {
|
||||
domCache.editForm.classList.remove('active');
|
||||
domCache.editEmptyState.style.display = 'flex';
|
||||
|
||||
domCache.labelInput.value = '';
|
||||
domCache.findInput.value = '';
|
||||
domCache.replaceInput.value = '';
|
||||
domCache.isRegex.checked = false;
|
||||
domCache.isCaseSensitive.checked = false;
|
||||
domCache.matchWholeWord.checked = false;
|
||||
domCache.filesToInclude.value = '';
|
||||
domCache.filesToExclude.value = '';
|
||||
|
||||
const state = vscode.getState() || {};
|
||||
delete state.currentPattern;
|
||||
vscode.setState(state);
|
||||
|
||||
document.querySelectorAll('.pattern-item').forEach(i => {
|
||||
i.classList.remove('selected');
|
||||
});
|
||||
|
||||
// Clear dirty state
|
||||
savedPatternState = null;
|
||||
updateDirtyIndicator(false);
|
||||
clearAllDirtyClasses();
|
||||
}
|
||||
|
||||
/**
|
||||
* Setup toggle buttons for flags
|
||||
*/
|
||||
function setupToggleButtons() {
|
||||
const buttons = [
|
||||
{ btnId: 'isRegexBtn', checkboxId: 'isRegex' },
|
||||
{ btnId: 'isCaseSensitiveBtn', checkboxId: 'isCaseSensitive' },
|
||||
{ btnId: 'matchWholeWordBtn', checkboxId: 'matchWholeWord' }
|
||||
];
|
||||
|
||||
buttons.forEach(({ btnId, checkboxId }) => {
|
||||
const btn = document.getElementById(btnId);
|
||||
const checkbox = document.getElementById(checkboxId);
|
||||
|
||||
if (!btn || !checkbox) return;
|
||||
|
||||
btn.addEventListener('click', () => {
|
||||
checkbox.checked = !checkbox.checked;
|
||||
updateToggleButtonState(btn, checkbox.checked);
|
||||
|
||||
// Validate regex when regex flag changes
|
||||
if (checkboxId === 'isRegex') {
|
||||
validateRegexPattern();
|
||||
}
|
||||
|
||||
// Check if field is dirty
|
||||
checkIfDirty();
|
||||
});
|
||||
|
||||
// Initialize button state
|
||||
updateToggleButtonState(btn, checkbox.checked);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Update visual state of toggle button
|
||||
*/
|
||||
function updateToggleButtonState(button, isActive) {
|
||||
if (isActive) {
|
||||
button.classList.add('active');
|
||||
} else {
|
||||
button.classList.remove('active');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate regex pattern
|
||||
*/
|
||||
function validateRegexPattern() {
|
||||
const isRegex = domCache.isRegex.checked;
|
||||
|
||||
if (!isRegex) {
|
||||
// Not using regex, clear any errors
|
||||
domCache.findInput.classList.remove('error');
|
||||
domCache.findValidationError.classList.remove('visible');
|
||||
domCache.findValidationError.textContent = '';
|
||||
return true;
|
||||
}
|
||||
|
||||
const pattern = domCache.findInput.value;
|
||||
|
||||
if (!pattern) {
|
||||
// Empty pattern is okay
|
||||
domCache.findInput.classList.remove('error');
|
||||
domCache.findValidationError.classList.remove('visible');
|
||||
domCache.findValidationError.textContent = '';
|
||||
return true;
|
||||
}
|
||||
|
||||
try {
|
||||
new RegExp(pattern);
|
||||
// Valid regex
|
||||
domCache.findInput.classList.remove('error');
|
||||
domCache.findValidationError.classList.remove('visible');
|
||||
domCache.findValidationError.textContent = '';
|
||||
return true;
|
||||
} catch (e) {
|
||||
// Invalid regex
|
||||
domCache.findInput.classList.add('error');
|
||||
domCache.findValidationError.classList.add('visible');
|
||||
domCache.findValidationError.textContent = `Invalid regular expression: ${e.message}`;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function handleAddPattern(button) {
|
||||
const scope = button.dataset.scope;
|
||||
|
||||
// Visual feedback: disable button temporarily
|
||||
button.disabled = true;
|
||||
button.style.opacity = '0.5';
|
||||
button.style.cursor = 'wait';
|
||||
|
||||
vscode.postMessage({
|
||||
type: 'create',
|
||||
scope: scope === 'workspace' ? 'workspace' : 'global'
|
||||
});
|
||||
|
||||
// Re-enable after 2 seconds (fallback in case of error)
|
||||
setTimeout(() => {
|
||||
button.disabled = false;
|
||||
button.style.opacity = '';
|
||||
button.style.cursor = '';
|
||||
}, 2000);
|
||||
}
|
||||
|
||||
function handleActionClick(button) {
|
||||
const action = button.dataset.action;
|
||||
const item = button.closest('.pattern-item');
|
||||
const id = item.dataset.id;
|
||||
const scope = item.dataset.scope;
|
||||
|
||||
if (action === 'delete') {
|
||||
handleDelete(id, scope);
|
||||
} else if (action === 'load') {
|
||||
handleLoad(id, scope);
|
||||
}
|
||||
}
|
||||
|
||||
function handleDelete(id, scope) {
|
||||
vscode.postMessage({
|
||||
type: 'delete',
|
||||
id: id,
|
||||
scope: scope
|
||||
});
|
||||
}
|
||||
|
||||
function handleLoad(id, scope) {
|
||||
if (!id || !scope) {
|
||||
console.error('Pattern not found');
|
||||
return;
|
||||
}
|
||||
|
||||
vscode.postMessage({
|
||||
type: 'load',
|
||||
id: id,
|
||||
scope: scope
|
||||
});
|
||||
}
|
||||
|
||||
document.getElementById('saveBtn').addEventListener('click', handleSavePattern);
|
||||
document.getElementById('loadBtn').addEventListener('click', handleLoadPatternFromDetails);
|
||||
|
||||
setupToggleButtons();
|
||||
|
||||
// Add event listeners to all form inputs for dirty tracking
|
||||
const formInputs = [
|
||||
'labelInput', 'findInput', 'replaceInput',
|
||||
'isRegex', 'isCaseSensitive', 'matchWholeWord',
|
||||
'filesToInclude', 'filesToExclude'
|
||||
];
|
||||
|
||||
formInputs.forEach(id => {
|
||||
const element = document.getElementById(id);
|
||||
if (element) {
|
||||
element.addEventListener('input', checkIfDirty);
|
||||
element.addEventListener('change', checkIfDirty);
|
||||
}
|
||||
});
|
||||
|
||||
// Initialize DOM cache for performance
|
||||
initDomCache();
|
||||
|
||||
// Set up event delegation for pattern list (once, not per render)
|
||||
setupEventDelegation();
|
||||
|
||||
// Resizable panels functionality
|
||||
function setupResizablePanels() {
|
||||
const resizeHandle = document.getElementById('resizeHandle');
|
||||
const patternListPanel = document.querySelector('.pattern-list-panel');
|
||||
|
||||
if (!resizeHandle || !patternListPanel) return;
|
||||
|
||||
let isResizing = false;
|
||||
let startX = 0;
|
||||
let startWidth = 0;
|
||||
|
||||
// Load saved width from state
|
||||
const state = vscode.getState() || {};
|
||||
if (state.panelWidth) {
|
||||
patternListPanel.style.flexBasis = `${state.panelWidth}px`;
|
||||
}
|
||||
|
||||
resizeHandle.addEventListener('mousedown', (e) => {
|
||||
isResizing = true;
|
||||
startX = e.clientX;
|
||||
startWidth = patternListPanel.offsetWidth;
|
||||
resizeHandle.classList.add('resizing');
|
||||
document.body.style.cursor = 'ew-resize';
|
||||
document.body.style.userSelect = 'none';
|
||||
e.preventDefault();
|
||||
});
|
||||
|
||||
document.addEventListener('mousemove', (e) => {
|
||||
if (!isResizing) return;
|
||||
|
||||
const deltaX = e.clientX - startX;
|
||||
const newWidth = startWidth + deltaX;
|
||||
|
||||
// Respect min/max constraints
|
||||
const minWidth = 200;
|
||||
const maxWidth = 600;
|
||||
const clampedWidth = Math.max(minWidth, Math.min(maxWidth, newWidth));
|
||||
|
||||
patternListPanel.style.flexBasis = `${clampedWidth}px`;
|
||||
});
|
||||
|
||||
document.addEventListener('mouseup', () => {
|
||||
if (isResizing) {
|
||||
isResizing = false;
|
||||
resizeHandle.classList.remove('resizing');
|
||||
document.body.style.cursor = '';
|
||||
document.body.style.userSelect = '';
|
||||
|
||||
// Save width to state
|
||||
const currentWidth = patternListPanel.offsetWidth;
|
||||
const state = vscode.getState() || {};
|
||||
state.panelWidth = currentWidth;
|
||||
vscode.setState(state);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Set up resizable panels
|
||||
setupResizablePanels();
|
||||
|
||||
// Add validation listener to find input
|
||||
if (domCache.findInput) {
|
||||
domCache.findInput.addEventListener('input', () => {
|
||||
validateRegexPattern();
|
||||
});
|
||||
}
|
||||
|
||||
vscode.postMessage({ type: 'ready' });
|
||||
@@ -0,0 +1,86 @@
|
||||
var oT=Object.create;var ca=Object.defineProperty;var aT=Object.getOwnPropertyDescriptor;var cT=Object.getOwnPropertyNames;var uT=Object.getPrototypeOf,lT=Object.prototype.hasOwnProperty;var T=(n,e)=>()=>(e||n((e={exports:{}}).exports,e),e.exports),dT=(n,e)=>{for(var t in e)ca(n,t,{get:e[t],enumerable:!0})},Kg=(n,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of cT(e))!lT.call(n,r)&&r!==t&&ca(n,r,{get:()=>e[r],enumerable:!(i=aT(e,r))||i.enumerable});return n};var bl=(n,e,t)=>(t=n!=null?oT(uT(n)):{},Kg(e||!n||!n.__esModule?ca(t,"default",{value:n,enumerable:!0}):t,n)),pT=n=>Kg(ca({},"__esModule",{value:!0}),n);var Xg=T((NL,Vg)=>{var Gg=require("stream").Stream,fT=require("util");Vg.exports=Bn;function Bn(){this.source=null,this.dataSize=0,this.maxDataSize=1024*1024,this.pauseStream=!0,this._maxDataSizeExceeded=!1,this._released=!1,this._bufferedEvents=[]}fT.inherits(Bn,Gg);Bn.create=function(n,e){var t=new this;e=e||{};for(var i in e)t[i]=e[i];t.source=n;var r=n.emit;return n.emit=function(){return t._handleEmit(arguments),r.apply(n,arguments)},n.on("error",function(){}),t.pauseStream&&n.pause(),t};Object.defineProperty(Bn.prototype,"readable",{configurable:!0,enumerable:!0,get:function(){return this.source.readable}});Bn.prototype.setEncoding=function(){return this.source.setEncoding.apply(this.source,arguments)};Bn.prototype.resume=function(){this._released||this.release(),this.source.resume()};Bn.prototype.pause=function(){this.source.pause()};Bn.prototype.release=function(){this._released=!0,this._bufferedEvents.forEach(function(n){this.emit.apply(this,n)}.bind(this)),this._bufferedEvents=[]};Bn.prototype.pipe=function(){var n=Gg.prototype.pipe.apply(this,arguments);return this.resume(),n};Bn.prototype._handleEmit=function(n){if(this._released){this.emit.apply(this,n);return}n[0]==="data"&&(this.dataSize+=n[1].length,this._checkIfMaxDataSizeExceeded()),this._bufferedEvents.push(n)};Bn.prototype._checkIfMaxDataSizeExceeded=function(){if(!this._maxDataSizeExceeded&&!(this.dataSize<=this.maxDataSize)){this._maxDataSizeExceeded=!0;var n="DelayedStream#maxDataSize of "+this.maxDataSize+" bytes exceeded.";this.emit("error",new Error(n))}}});var Zg=T((AL,Qg)=>{var hT=require("util"),Yg=require("stream").Stream,Jg=Xg();Qg.exports=dt;function dt(){this.writable=!1,this.readable=!0,this.dataSize=0,this.maxDataSize=2*1024*1024,this.pauseStreams=!0,this._released=!1,this._streams=[],this._currentStream=null,this._insideLoop=!1,this._pendingNext=!1}hT.inherits(dt,Yg);dt.create=function(n){var e=new this;n=n||{};for(var t in n)e[t]=n[t];return e};dt.isStreamLike=function(n){return typeof n!="function"&&typeof n!="string"&&typeof n!="boolean"&&typeof n!="number"&&!Buffer.isBuffer(n)};dt.prototype.append=function(n){var e=dt.isStreamLike(n);if(e){if(!(n instanceof Jg)){var t=Jg.create(n,{maxDataSize:1/0,pauseStream:this.pauseStreams});n.on("data",this._checkDataSize.bind(this)),n=t}this._handleErrors(n),this.pauseStreams&&n.pause()}return this._streams.push(n),this};dt.prototype.pipe=function(n,e){return Yg.prototype.pipe.call(this,n,e),this.resume(),n};dt.prototype._getNext=function(){if(this._currentStream=null,this._insideLoop){this._pendingNext=!0;return}this._insideLoop=!0;try{do this._pendingNext=!1,this._realGetNext();while(this._pendingNext)}finally{this._insideLoop=!1}};dt.prototype._realGetNext=function(){var n=this._streams.shift();if(typeof n>"u"){this.end();return}if(typeof n!="function"){this._pipeNext(n);return}var e=n;e(function(t){var i=dt.isStreamLike(t);i&&(t.on("data",this._checkDataSize.bind(this)),this._handleErrors(t)),this._pipeNext(t)}.bind(this))};dt.prototype._pipeNext=function(n){this._currentStream=n;var e=dt.isStreamLike(n);if(e){n.on("end",this._getNext.bind(this)),n.pipe(this,{end:!1});return}var t=n;this.write(t),this._getNext()};dt.prototype._handleErrors=function(n){var e=this;n.on("error",function(t){e._emitError(t)})};dt.prototype.write=function(n){this.emit("data",n)};dt.prototype.pause=function(){this.pauseStreams&&(this.pauseStreams&&this._currentStream&&typeof this._currentStream.pause=="function"&&this._currentStream.pause(),this.emit("pause"))};dt.prototype.resume=function(){this._released||(this._released=!0,this.writable=!0,this._getNext()),this.pauseStreams&&this._currentStream&&typeof this._currentStream.resume=="function"&&this._currentStream.resume(),this.emit("resume")};dt.prototype.end=function(){this._reset(),this.emit("end")};dt.prototype.destroy=function(){this._reset(),this.emit("close")};dt.prototype._reset=function(){this.writable=!1,this._streams=[],this._currentStream=null};dt.prototype._checkDataSize=function(){if(this._updateDataSize(),!(this.dataSize<=this.maxDataSize)){var n="DelayedStream#maxDataSize of "+this.maxDataSize+" bytes exceeded.";this._emitError(new Error(n))}};dt.prototype._updateDataSize=function(){this.dataSize=0;var n=this;this._streams.forEach(function(e){e.dataSize&&(n.dataSize+=e.dataSize)}),this._currentStream&&this._cLine truncated
|
||||
`;Te.DEFAULT_CONTENT_TYPE="application/octet-stream";Te.prototype.append=function(n,e,t){t=t||{},typeof t=="string"&&(t={filename:t});var i=kl.prototype.append.bind(this);if(typeof e=="number"&&(e=""+e),Rv.isArray(e)){this._error(new Error("Arrays are not supported."));return}var r=this._multiPartHeader(n,e,t),s=this._multiPartFooter();i(r),i(e),i(s),this._trackLength(r,e,t)};Te.prototype._trackLength=function(n,e,t){var i=0;t.knownLength!=null?i+=+t.knownLength:Buffer.isBuffer(e)?i=e.length:typeof e=="string"&&(i=Buffer.byteLength(e)),this._valueLength+=i,this._overheadLength+=Buffer.byteLength(n)+Te.LINE_BREAK.length,!(!e||!e.path&&!(e.readable&&e.hasOwnProperty("httpVersion"))&&!(e instanceof GT))&&(t.knownLength||this._valuesToMeasure.push(e))};Te.prototype._lengthRetriever=function(n,e){n.hasOwnProperty("fd")?n.end!=null&&n.end!=1/0&&n.start!=null?e(null,n.end+1-(n.start?n.start:0)):KT.stat(n.path,function(t,i){var r;if(t){e(t);return}r=i.size-(n.start?n.start:0),e(null,r)}):n.hasOwnProperty("httpVersion")?e(null,+n.headers["content-length"]):n.hasOwnProperty("httpModule")?(n.on("response",function(t){n.pause(),e(null,+t.headers["content-length"])}),n.resume()):e("Unknown stream")};Te.prototype._multiPartHeader=function(n,e,t){if(typeof t.header=="string")return t.header;var i=this._getContentDisposition(e,t),r=this._getContentType(e,t),s="",o={"Content-Disposition":["form-data",'name="'+n+'"'].concat(i||[]),"Content-Type":[].concat(r||[])};typeof t.header=="object"&&Pl(o,t.header);var a;for(var c in o)o.hasOwnProperty(c)&&(a=o[c],a!=null&&(Array.isArray(a)||(a=[a]),a.length&&(s+=c+": "+a.join("; ")+Te.LINE_BREAK)));return"--"+this.getBoundary()+Te.LINE_BREAK+s+Te.LINE_BREAK};Te.prototype._getContentDisposition=function(n,e){var t,i;return typeof e.filepath=="string"?t=Tl.normalize(e.filepath).replace(/\\/g,"/"):e.filename||n.name||n.path?t=Tl.basename(e.filename||n.name||n.path):n.readable&&n.hasOwnProperty("httpVersion")&&(t=Tl.basename(n.client._httpMessage.path||"")),t&&(i='filename="'+t+'"'),i};Te.prototype._getContentType=function(n,e){var t=e.contentType;return!t&&n.name&&(t=El.lookup(n.name)),!t&&n.path&&(t=El.lookup(n.path)),!t&&n.readable&&n.hasOwnProperty("httpVersion")&&(t=n.headers["content-type"]),!t&&(e.filepath||e.filename)&&(t=El.lookup(e.filepath||e.filename)),!t&&typeof n=="object"&&(t=Te.DEFAULT_CONTENT_TYPE),t};Te.prototype._multiPartFooter=function(){return function(n){var e=Te.LINE_BREAK,t=this._streams.length===0;t&&(e+=this._lastBoundary()),n(e)}.bind(this)};Te.prototype._lastBoundary=function(){return"--"+this.getBoundary()+"--"+Te.LINE_BREAK};Te.prototype.getHeaders=function(n){var e,t={"content-type":"multipart/form-data; boundary="+this.getBoundary()};for(e in n)n.hasOwnProperty(e)&&(t[e.toLowerCase()]=n[e]);return t};Te.prototype.setBoundary=function(n){this._boundary=n};Te.prototype.getBoundary=function(){return this._boundary||this._generateBoundary(),this._boundary};Te.prototype.getBuffer=function(){for(var n=new Buffer.alloc(0),e=this.getBoundary(),t=0,i=this._streams.length;t<i;t++)typeof this._streams[t]!="function"&&(Buffer.isBuffer(this._streams[t])?n=Buffer.concat([n,this._streams[t]]):n=Buffer.concat([n,Buffer.from(this._streams[t])]),(typeof this._streams[t]!="string"||this._streams[t].substring(2,e.length+2)!==e)&&(n=Buffer.concat([n,Buffer.from(Te.LINE_BREAK)])));return Buffer.concat([n,Buffer.from(this._lastBoundary())])};Te.prototype._generateBoundary=function(){for(var n="--------------------------",e=0;e<24;e++)n+=Math.floor(Math.random()*10).toString(16);this._boundary=n};Te.prototype.getLengthSync=function(){var n=this._overheadLength+this._valueLength;return this._streams.length&&(n+=this._lastBoundary().length),this.hasKnownLength()||this._error(new Error("Cannot calculate proper length in synchronous way.")),n};Te.prototype.hasKnownLength=function(){var n=!0;return this._valuesToMeasure.length&&(n=!1),n};Te.prototype.getLength=function(n){var e=this._overheadLength+this._valueLength;if(this._streams.length&&(e+=this._lastBoundary().length),!this._valuesToMeasure.length){process.nextTick(n.bind(this,null,e));return}VT.parallel(this._valuesToMeasure,this._lengthRetriever,function(t,i){if(t){n(t);return}i.forEach(function(r){e+=r}),n(null,e)})};Te.prototype.submit=function(n,e){var t,i,r={method:"post"};return typeof n=="string"?(n=WT(n),i=Pl({port:n.port,path:n.pathname,host:n.hostname,protocol:n.protocol},r)):(i=Pl(n,r),i.port||(i.port=i.protocol=="https:"?443:80)),i.headers=this.getHeaders(n.headers),i.protocol=="https:"?t=BT.request(i):t=HT.request(i),this.getLength(function(s,o){if(s&&s!=="Unknown stream"){this._error(s);return}if(o&&t.setHeader("Content-Length",o),this.pipe(t),e){var a,c=function(u,l){return t.removeListener("error",c),t.removeListener("response",a),e.call(this,u,l)};a=c.bind(this,null),t.on("error",c),t.on("response",a)}}.bind(this)),t};Te.prototype._error=function(n){this.error||(this.error=n,this.pause(),this.emit("error",n))};
Line truncated
|
||||
`).forEach(function(o){r=o.indexOf(":"),t=o.substring(0,r).trim().toLowerCase(),i=o.substring(r+1).trim(),!(!t||e[t]&&SP[t])&&(t==="set-cookie"?e[t]?e[t].push(i):e[t]=[i]:e[t]=e[t]?e[t]+", "+i:i)}),e},$v=Symbol("internals");function Vs(n){return n&&String(n).trim().toLowerCase()}function pa(n){return n===!1||n==null?n:q.isArray(n)?n.map(pa):String(n)}function RP(n){let e=Object.create(null),t=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g,i;for(;i=t.exec(n);)e[i[1]]=i[2];return e}var DP=n=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(n.trim());function Bl(n,e,t,i,r){if(q.isFunction(i))return i.call(this,e,t);if(r&&(e=t),!!q.isString(e)){if(q.isString(i))return e.indexOf(i)!==-1;if(q.isRegExp(i))return i.test(e)}}function TP(n){return n.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(e,t,i)=>t.toUpperCase()+i)}function EP(n,e){let t=q.toCamelCase(" "+e);["get","set","has"].forEach(i=>{Object.defineProperty(n,i+t,{value:function(r,s,o){return this[i].call(this,e,r,s,o)},configurable:!0})})}var zr=class{constructor(e){e&&this.set(e)}set(e,t,i){let r=this;function s(a,c,u){let l=Vs(c);if(!l)throw new Error("header name must be a non-empty string");let p=q.findKey(r,l);(!p||r[p]===void 0||u===!0||u===void 0&&r[p]!==!1)&&(r[p||c]=pa(a))}let o=(a,c)=>q.forEach(a,(u,l)=>s(u,l,c));if(q.isPlainObject(e)||e instanceof this.constructor)o(e,t);else if(q.isString(e)&&(e=e.trim())&&!DP(e))o(CP(e),t);else if(q.isHeaders(e))for(let[a,c]of e.entries())s(c,a,i);else e!=null&&s(t,e,i);return this}get(e,t){if(e=Vs(e),e){let i=q.findKey(this,e);if(i){let r=this[i];if(!t)return r;if(t===!0)return RP(r);if(q.isFunction(t))return t.call(this,r,i);if(q.isRegExp(t))return t.exec(r);throw new TypeError("parser must be boolean|regexp|function")}}}has(e,t){if(e=Vs(e),e){let i=q.findKey(this,e);return!!(i&&this[i]!==void 0&&(!t||Bl(this,this[i],i,t)))}return!1}delete(e,t){let i=this,r=!1;function s(o){if(o=Vs(o),o){let a=q.findKey(i,o);a&&(!t||Bl(i,i[a],a,t))&&(delete i[a],r=!0)}}return q.isArray(e)?e.forEach(s):s(e),r}clear(e){let t=Object.keys(this),i=t.length,r=!1;for(;i--;){let s=t[i];(!e||Bl(this,this[s],s,e,!0))&&(delete this[s],r=!0)}return r}normalize(e){let t=this,i={};return q.forEach(this,(r,s)=>{let o=q.findKey(i,s);if(o){t[o]=pa(r),delete t[s];return}let a=e?TP(s):String(s).trim();a!==s&&delete t[s],t[a]=pa(r),i[a]=!0}),this}concat(...e){return this.constructor.concat(this,...e)}toJSON(e){let t=Object.create(null);return q.forEach(this,(i,r)=>{i!=null&&i!==!1&&(t[r]=e&&q.isArray(i)?i.join(", "):i)}),t}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([e,t])=>e+": "+t).join(`
|
||||
`)}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(e){return e instanceof this?e:new this(e)}static concat(e,...t){let i=new this(e);return t.forEach(r=>i.set(r)),i}static accessor(e){let i=(this[$v]=this[$v]={accessors:{}}).accessors,r=this.prototype;function s(o){let a=Vs(o);i[a]||(EP(r,o),i[a]=!0)}return q.isArray(e)?e.forEach(s):s(e),this}};zr.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);q.reduceDescriptors(zr.prototype,({value:n},e)=>{let t=e[0].toUpperCase()+e.slice(1);return{get:()=>n,set(i){this[t]=i}}});q.freezeMethods(zr);var rn=zr;function Wl(n,e){let t=this||ld,i=e||t,r=rn.from(i.headers),s=i.data;return q.forEach(n,function(a){s=a.call(t,s,r.normalize(),e?e.status:void 0)}),r.normalize(),s}function yx(n){return!!(n&&n.__CANCEL__)}function Mi(n,e,t){V.call(this,n??"canceled",V.ERR_CANCELED,e,t),this.name="CanceledError"}q.inherits(Mi,V,{__CANCEL__:!0});function Ur(n,e,t){let i=t.config.validateStatus;!t.status||!i||i(t.status)?n(t):e(new V("Request failed with status code "+t.status,[V.ERR_BAD_REQUEST,V.ERR_BAD_RESPONSE][Math.floor(t.status/100)-4],t.config,t.request,t))}function PP(n){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(n)}function kP(n,e){return e?n.replace(/\/?\/$/,"")+"/"+e.replace(/^\/+/,""):n}function dd(n,e){return n&&!PP(e)?kP(n,e):e}var ma="1.7.9";function bx(n){let e=/^([-+\w]{1,25})(:?\/\/|:)/.exec(n);return e&&e[1]||""}var OP=/^(?:([^;]+);)?(?:[^;]+;)?(base64|),([\s\S]*)$/;function qP(n,e,t){let i=t&&t.Blob||bt.classes.Blob,r=bx(n);if(e===void 0&&i&&(e=!0),r==="data"){n=r.length?n.slice(r.length+1):n;let s=OP.exec(n);if(!s)throw new V("Invalid URL",V.ERR_INVALID_URL);let o=s[1],a=s[2],c=s[3],u=Buffer.from(decodeURIComponent(c),a?"base64":"utf8");if(e){if(!i)throw new V("Blob is not supported",V.ERR_NOT_SUPPORT);return new i([u],{type:o})}return u}throw new V("Unsupported protocol "+r,V.ERR_NOT_SUPPORT)}var Kl=Symbol("internals"),Ql=class extends Ii.default.Transform{constructor(e){e=q.toFlatObject(e,{maxRate:0,chunkSize:64*1024,minChunkSize:100,timeWindow:500,ticksRate:2,samplesCount:15},null,(i,r)=>!q.isUndefined(r[i])),super({readableHighWaterMark:e.chunkSize});let t=this[Kl]={timeWindow:e.timeWindow,chunkSize:e.chunkSize,maxRate:e.maxRate,minChunkSize:e.minChunkSize,bytesSeen:0,isCaptured:!1,notifiedBytesLoaded:0,ts:Date.now(),bytes:0,onReadCallback:null};this.on("newListener",i=>{i==="progress"&&(t.isCaptured||(t.isCaptured=!0))})}_read(e){let t=this[Kl];return t.onReadCallback&&t.onReadCallback(),super._read(e)}_transform(e,t,i){let r=this[Kl],s=r.maxRate,o=this.readableHighWaterMark,a=r.timeWindow,c=1e3/a,u=s/c,l=r.minChunkSize!==!1?Math.max(r.minChunkSize,u*.01):0,p=(x,f)=>{let y=Buffer.byteLength(x);r.bytesSeen+=y,r.bytes+=y,r.isCaptured&&this.emit("progress",r.bytesSeen),this.push(x)?process.nextTick(f):r.onReadCallback=()=>{r.onReadCallback=null,process.nextTick(f)}},h=(x,f)=>{let y=Buffer.byteLength(x),w=null,S=o,O,k=0;if(s){let N=Date.now();(!r.ts||(k=N-r.ts)>=a)&&(r.ts=N,O=u-r.bytes,r.bytes=O<0?-O:0,k=0),O=u-r.bytes}if(s){if(O<=0)return setTimeout(()=>{f(null,x)},a-k);O<S&&(S=O)}S&&y>S&&y-S>l&&(w=x.subarray(S),x=x.subarray(0,S)),p(x,w?()=>{process.nextTick(f,null,w)}:f)};h(e,function x(f,y){if(f)return i(f);y?h(y,x):i(null)})}},Hv=Ql,{asyncIterator:Bv}=Symbol,FP=async function*(n){n.stream?yield*n.stream():n.arrayBuffer?yield await n.arrayBuffer():n[Bv]?yield*n[Bv]():yield n},wx=FP,NP=q.ALPHABET.ALPHA_DIGIT+"-_",Js=typeof TextEncoder=="function"?new TextEncoder:new rx.default.TextEncoder,ji=`\r
|
||||
`,AP=Js.encode(ji),IP=2,Zl=class{constructor(e,t){let{escapeName:i}=this.constructor,r=q.isString(t),s=`Content-Disposition: form-data; name="${i(e)}"${!r&&t.name?`; filename="${i(t.name)}"`:""}${ji}`;r?t=Js.encode(String(t).replace(/\r?\n|\r\n?/g,ji)):s+=`Content-Type: ${t.type||"application/octet-stream"}${ji}`,this.headers=Js.encode(s+ji),this.contentLength=r?t.byteLength:t.size,this.size=this.headers.byteLength+this.contentLength+IP,this.name=e,this.value=t}async*encode(){yield this.headers;let{value:e}=this;q.isTypedArray(e)?yield e:yield*wx(e),yield AP}static escapeName(e){return String(e).replace(/[\r\n"]/g,t=>({"\r":"%0D","\n":"%0A",'"':"%22"})[t])}},jP=(n,e,t)=>{let{tag:i="form-data-boundary",size:r=25,boundary:s=i+"-"+q.generateString(r,NP)}=t||{};if(!q.isFormData(n))throw TypeError("FormData instance required");if(s.length<1||s.length>70)throw Error("boundary must be 10-70 characters long");let o=Js.encode("--"+s+ji),a=Js.encode("--"+s+"--"+ji+ji),c=a.byteLength,u=Array.from(n.entries()).map(([p,h])=>{let x=new Zl(p,h);return c+=x.size,x});c+=o.byteLength*u.length,c=q.toFiniteNumber(c);let l={"Content-Type":`multipart/form-data; boundary=${s}`};return Number.isFinite(c)&&(l["Content-Length"]=c),e&&e(l),nx.Readable.from(async function*(){for(let p of u)yield o,yield*p.encode();yield a}())},LP=jP,ed=class extends Ii.default.Transform{__transform(e,t,i){this.push(e),i()}_transform(e,t,i){if(e.length!==0&&(this._transform=this.__transform,e[0]!==120)){let r=Buffer.alloc(2);r[0]=120,r[1]=156,this.push(r,t)}this.__transform(e,t,i)}},MP=ed,UP=(n,e)=>q.isAsyncFn(n)?function(...t){let i=t.pop();n.apply(this,t).then(r=>{try{e?i(null,...e(r)):i(null,r)}catch(s){i(s)}},i)}:n,zP=UP;function $P(n,e){n=n||10;let t=new Array(n),i=new Array(n),r=0,s=0,o;return e=e!==void 0?e:1e3,function(c){let u=Date.now(),l=i[s];o||(o=u),t[r]=c,i[r]=u;let p=s,h=0;for(;p!==r;)h+=t[p++],p=p%n;if(r=(r+1)%n,r===s&&(s=(s+1)%n),u-o<e)return;let x=l&&u-l;return x?Math.round(h*1e3/x):void 0}}function HP(n,e){let t=0,i=1e3/e,r,s,o=(u,l=Date.now())=>{t=l,r=null,s&&(clearTimeout(s),s=null),n.apply(null,u)};return[(...u)=>{let l=Date.now(),p=l-t;p>=i?o(u,l):(r=u,s||(s=setTimeout(()=>{s=null,o(r)},i-p)))},()=>r&&o(r)]}var $r=(n,e,t=3)=>{let i=0,r=$P(50,250);return HP(s=>{let o=s.loaded,a=s.lengthComputable?s.total:void 0,c=o-i,u=r(c),l=o<=a;i=o;let p={loaded:o,total:a,progress:a?o/a:void 0,bytes:c,rate:u||void 0,estimated:u&&a&&l?(a-o)/u:void 0,event:s,lengthComputable:a!=null,[e?"download":"upload"]:!0};n(p)},t)},ga=(n,e)=>{let t=n!=null;return[i=>e[0]({lengthComputable:t,total:n,loaded:i}),e[1]]},va=n=>(...e)=>q.asap(()=>n(...e)),Wv={flush:Li.default.constants.Z_SYNC_FLUSH,finishFlush:Li.default.constants.Z_SYNC_FLUSH},BP={flush:Li.default.constants.BROTLI_OPERATION_FLUSH,finishFlush:Li.default.constants.BROTLI_OPERATION_FLUSH},Kv=q.isFunction(Li.default.createBrotliDecompress),{http:WP,https:KP}=CE.default,GP=/https:?/,Gv=bt.protocols.map(n=>n+":"),Vv=(n,[e,t])=>(n.on("end",t).on("error",t),e);function VP(n,e){n.beforeRedirects.proxy&&n.beforeRedirects.proxy(n),n.beforeRedirects.config&&n.beforeRedirects.config(n,e)}function _x(n,e,t){let i=e;if(!i&&i!==!1){let r=wE.default.getProxyForUrl(t);r&&(i=new URL(r))}if(i){if(i.username&&(i.auth=(i.username||"")+":"+(i.password||"")),i.auth){(i.auth.username||i.auth.password)&&(i.auth=(i.auth.username||"")+":"+(i.auth.password||""));let s=Buffer.from(i.auth,"utf8").toString("base64");n.headers["Proxy-Authorization"]="Basic "+s}n.headers.host=n.hostname+(n.port?":"+n.port:"");let r=i.hostname||i.host;n.hostname=r,n.host=r,n.port=i.port,n.path=t,i.protocol&&(n.protocol=i.protocol.includes(":")?i.protocol:`${i.protocol}:`)}n.beforeRedirects.proxy=function(s){_x(s,e,s.href)}}var XP=typeof process<"u"&&q.kindOf(process)==="process",JP=n=>new Promise((e,t)=>{let i,r,s=(c,u)=>{r||(r=!0,i&&i(c,u))},o=c=>{s(c),e(c)},a=c=>{s(c,!0),t(c)};n(o,a,c=>i=c).catch(a)}),YP=({address:n,family:e})=>{if(!q.isString(n))throw TypeError("address must be a string");return{address:n,family:e||(n.indexOf(".")<0?6:4)}},Xv=(n,e)=>YP(q.isObject(n)?n:{address:n,family:e}),QP=XP&&function(e){return JP(async function(i,r,s){let{data:o,lookup:a,family:c}=e,{responseType:u,responseEncoding:l}=e,p=e.method.toUpperCase(),h,x=!1,f;if(a){let se=zP(a,ie=>q.isArray(ie)?ie:[ie]);a=(ie,de,ut)=>{se(ie,de,(Re,Ke,Sn)=>{if(Re)return ut(Re);let gt=q.isArray(Ke)?Ke.map(it=>Xv(it)):[Xv(Ke,Sn)];de.all?ut(Re,gt):ut(Re,gt[0].address,gt[0].family)})}}let y=new yE.EventEmitter,w=()=>{e.cancelToken&&e.cancelToken.unsubscribe(S),e.signal&&e.signal.removeEventListener("abort",S),y.removeAllListeners()};s((se,ie)=>{h=!0,ie&&(x=!0,w())});function S(se){y.emit("abort",!se||se.type?new Mi(null,e,f):se)}y.once("abort",r),(e.cancelToken||e.signal)&&(e.cancelToken&&e.cancelToken.subscribe(S),e.signal&&(e.signal.aborted?S():e.signal.addEventListener("abort",S)));let O=dd(e.baseURL,e.url),k=new URL(O,bt.hasBrowserEnv?bt.origin:void 0),N=k.protocol||Gv[0];if(N==
Line truncated
|
||||
`+s.map(Zv).join(`
|
||||
`):" "+Zv(s[0]):"as no adapter specified";throw new V("There is no suitable adapter to dispatch the request "+o,"ERR_NOT_SUPPORT")}return i},adapters:nd};function Gl(n){if(n.cancelToken&&n.cancelToken.throwIfRequested(),n.signal&&n.signal.aborted)throw new Mi(null,n)}function ex(n){return Gl(n),n.headers=rn.from(n.headers),n.data=Wl.call(n,n.transformRequest),["post","put","patch"].indexOf(n.method)!==-1&&n.headers.setContentType("application/x-www-form-urlencoded",!1),Dx.getAdapter(n.adapter||ld.adapter)(n).then(function(i){return Gl(n),i.data=Wl.call(n,n.transformResponse,i),i.headers=rn.from(i.headers),i},function(i){return yx(i)||(Gl(n),i&&i.response&&(i.response.data=Wl.call(n,n.transformResponse,i.response),i.response.headers=rn.from(i.response.headers))),Promise.reject(i)})}var Ca={};["object","boolean","number","function","string","symbol"].forEach((n,e)=>{Ca[n]=function(i){return typeof i===n||"a"+(e<1?"n ":" ")+n}});var tx={};Ca.transitional=function(e,t,i){function r(s,o){return"[Axios v"+ma+"] Transitional option '"+s+"'"+o+(i?". "+i:"")}return(s,o,a)=>{if(e===!1)throw new V(r(o," has been removed"+(t?" in "+t:"")),V.ERR_DEPRECATED);return t&&!tx[o]&&(tx[o]=!0,console.warn(r(o," has been deprecated since v"+t+" and will be removed in the near future"))),e?e(s,o,a):!0}};Ca.spelling=function(e){return(t,i)=>(console.warn(`${i} is likely a misspelling of ${e}`),!0)};function hk(n,e,t){if(typeof n!="object")throw new V("options must be an object",V.ERR_BAD_OPTION_VALUE);let i=Object.keys(n),r=i.length;for(;r-- >0;){let s=i[r],o=e[s];if(o){let a=n[s],c=a===void 0||o(a,s,n);if(c!==!0)throw new V("option "+s+" must be "+c,V.ERR_BAD_OPTION_VALUE);continue}if(t!==!0)throw new V("Unknown option "+s,V.ERR_BAD_OPTION)}}var fa={assertOptions:hk,validators:Ca},si=fa.validators,Hr=class{constructor(e){this.defaults=e,this.interceptors={request:new zv,response:new zv}}async request(e,t){try{return await this._request(e,t)}catch(i){if(i instanceof Error){let r={};Error.captureStackTrace?Error.captureStackTrace(r):r=new Error;let s=r.stack?r.stack.replace(/^.+\n/,""):"";try{i.stack?s&&!String(i.stack).endsWith(s.replace(/^.+\n.+\n/,""))&&(i.stack+=`
|
||||
`+s):i.stack=s}catch{}}throw i}}_request(e,t){typeof e=="string"?(t=t||{},t.url=e):t=e||{},t=yr(this.defaults,t);let{transitional:i,paramsSerializer:r,headers:s}=t;i!==void 0&&fa.assertOptions(i,{silentJSONParsing:si.transitional(si.boolean),forcedJSONParsing:si.transitional(si.boolean),clarifyTimeoutError:si.transitional(si.boolean)},!1),r!=null&&(q.isFunction(r)?t.paramsSerializer={serialize:r}:fa.assertOptions(r,{encode:si.function,serialize:si.function},!0)),fa.assertOptions(t,{baseUrl:si.spelling("baseURL"),withXsrfToken:si.spelling("withXSRFToken")},!0),t.method=(t.method||this.defaults.method||"get").toLowerCase();let o=s&&q.merge(s.common,s[t.method]);s&&q.forEach(["delete","get","head","post","put","patch","common"],f=>{delete s[f]}),t.headers=rn.concat(o,s);let a=[],c=!0;this.interceptors.request.forEach(function(y){typeof y.runWhen=="function"&&y.runWhen(t)===!1||(c=c&&y.synchronous,a.unshift(y.fulfilled,y.rejected))});let u=[];this.interceptors.response.forEach(function(y){u.push(y.fulfilled,y.rejected)});let l,p=0,h;if(!c){let f=[ex.bind(this),void 0];for(f.unshift.apply(f,a),f.push.apply(f,u),h=f.length,l=Promise.resolve(t);p<h;)l=l.then(f[p++],f[p++]);return l}h=a.length;let x=t;for(p=0;p<h;){let f=a[p++],y=a[p++];try{x=f(x)}catch(w){y.call(this,w);break}}try{l=ex.call(this,x)}catch(f){return Promise.reject(f)}for(p=0,h=u.length;p<h;)l=l.then(u[p++],u[p++]);return l}getUri(e){e=yr(this.defaults,e);let t=dd(e.baseURL,e.url);return od(t,e.params,e.paramsSerializer)}};q.forEach(["delete","get","head","options"],function(e){Hr.prototype[e]=function(t,i){return this.request(yr(i||{},{method:e,url:t,data:(i||{}).data}))}});q.forEach(["post","put","patch"],function(e){function t(i){return function(s,o,a){return this.request(yr(a||{},{method:e,headers:i?{"Content-Type":"multipart/form-data"}:{},url:s,data:o}))}}Hr.prototype[e]=t(),Hr.prototype[e+"Form"]=t(!0)});var ha=Hr,id=class n{constructor(e){if(typeof e!="function")throw new TypeError("executor must be a function.");let t;this.promise=new Promise(function(s){t=s});let i=this;this.promise.then(r=>{if(!i._listeners)return;let s=i._listeners.length;for(;s-- >0;)i._listeners[s](r);i._listeners=null}),this.promise.then=r=>{let s,o=new Promise(a=>{i.subscribe(a),s=a}).then(r);return o.cancel=function(){i.unsubscribe(s)},o},e(function(s,o,a){i.reason||(i.reason=new Mi(s,o,a),t(i.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){if(this.reason){e(this.reason);return}this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;let t=this._listeners.indexOf(e);t!==-1&&this._listeners.splice(t,1)}toAbortSignal(){let e=new AbortController,t=i=>{e.abort(i)};return this.subscribe(t),e.signal.unsubscribe=()=>this.unsubscribe(t),e.signal}static source(){let e;return{token:new n(function(r){e=r}),cancel:e}}},mk=id;function gk(n){return function(t){return n.apply(null,t)}}function vk(n){return q.isObject(n)&&n.isAxiosError===!0}var rd={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(rd).forEach(([n,e])=>{rd[e]=n});var xk=rd;function Tx(n){let e=new ha(n),t=sx(ha.prototype.request,e);return q.extend(t,ha.prototype,e,{allOwnKeys:!0}),q.extend(t,e,null,{allOwnKeys:!0}),t.create=function(r){return Tx(yr(n,r))},t}var wt=Tx(ld);wt.Axios=ha;wt.CanceledError=Mi;wt.CancelToken=mk;wt.isCancel=yx;wt.VERSION=ma;wt.toFormData=_a;wt.AxiosError=V;wt.Cancel=wt.CanceledError;wt.all=function(e){return Promise.all(e)};wt.spread=gk;wt.isAxiosError=vk;wt.mergeConfig=yr;wt.AxiosHeaders=rn;wt.formToJSON=n=>xx(q.isHTMLForm(n)?new FormData(n):n);wt.getAdapter=Dx.getAdapter;wt.HttpStatusCode=xk;wt.default=wt;Ex.exports=wt});var Nx=T((tM,Fx)=>{"use strict";Fx.exports=Ox;function Ox(n,e,t){n instanceof RegExp&&(n=kx(n,t)),e instanceof RegExp&&(e=kx(e,t));var i=qx(n,e,t);return i&&{star
Line truncated
|
||||
globstar while`,e,h,t,x,f),this.matchOne(e.slice(h),t.slice(x),i))return this.debug("globstar found match!",h,c,f),!0;if(f==="."||f===".."||!r.dot&&f.charAt(0)==="."){this.debug("dot detected!",e,h,t,x);break}this.debug("globstar swallow a segment, and continue"),h++}return!!(i&&(this.debug(`
|
||||
>>> no match, partial?`,e,h,t,x),h===c))}let y;if(typeof l=="string"?(y=p===l,this.debug("string match",l,p,y)):(y=l.test(p),this.debug("pattern match",l,p,y)),!y)return!1}if(o===c&&a===u)return!0;if(o===c)return i;if(a===u)return o===c-1&&e[o]==="";throw new Error("wtf?")}braceExpand(){return(0,ee.braceExpand)(this.pattern,this.options)}parse(e){(0,Fa.assertValidPattern)(e);let t=this.options;if(e==="**")return ee.GLOBSTAR;if(e==="")return"";let i,r=null;(i=e.match(tO))?r=t.dot?iO:nO:(i=e.match(Wk))?r=(t.nocase?t.dot?Xk:Vk:t.dot?Gk:Kk)(i[1]):(i=e.match(rO))?r=(t.nocase?t.dot?oO:sO:t.dot?aO:cO)(i):(i=e.match(Jk))?r=t.dot?Qk:Yk:(i=e.match(Zk))&&(r=eO);let s=Yx.AST.fromGlob(e,this.options).toMMPattern();return r&&typeof s=="object"&&Reflect.defineProperty(s,"test",{value:r}),s}makeRe(){if(this.regexp||this.regexp===!1)return this.regexp;let e=this.set;if(!e.length)return this.regexp=!1,this.regexp;let t=this.options,i=t.noglobstar?lO:t.dot?dO:pO,r=new Set(t.nocase?["i"]:[]),s=e.map(c=>{let u=c.map(l=>{if(l instanceof RegExp)for(let p of l.flags.split(""))r.add(p);return typeof l=="string"?xO(l):l===ee.GLOBSTAR?ee.GLOBSTAR:l._src});return u.forEach((l,p)=>{let h=u[p+1],x=u[p-1];l!==ee.GLOBSTAR||x===ee.GLOBSTAR||(x===void 0?h!==void 0&&h!==ee.GLOBSTAR?u[p+1]="(?:\\/|"+i+"\\/)?"+h:u[p]=i:h===void 0?u[p-1]=x+"(?:\\/|"+i+")?":h!==ee.GLOBSTAR&&(u[p-1]=x+"(?:\\/|\\/"+i+"\\/)"+h,u[p+1]=ee.GLOBSTAR))}),u.filter(l=>l!==ee.GLOBSTAR).join("/")}).join("|"),[o,a]=e.length>1?["(?:",")"]:["",""];s="^"+o+s+a+"$",this.negate&&(s="^(?!"+s+").+$");try{this.regexp=new RegExp(s,[...r].join(""))}catch{this.regexp=!1}return this.regexp}slashSplit(e){return this.preserveMultipleSlashes?e.split("/"):this.isWindows&&/^\/\/[^\/]+/.test(e)?["",...e.split(/\/+/)]:e.split(/\/+/)}match(e,t=this.partial){if(this.debug("match",e,this.pattern),this.comment)return!1;if(this.empty)return e==="";if(e==="/"&&t)return!0;let i=this.options;this.isWindows&&(e=e.split("\\").join("/"));let r=this.slashSplit(e);this.debug(this.pattern,"split",r);let s=this.set;this.debug(this.pattern,"set",s);let o=r[r.length-1];if(!o)for(let a=r.length-2;!o&&a>=0;a--)o=r[a];for(let a=0;a<s.length;a++){let c=s[a],u=r;if(i.matchBase&&c.length===1&&(u=[o]),this.matchOne(u,c,t))return i.flipNegate?!0:!this.negate}return i.flipNegate?!1:this.negate}static defaults(e){return ee.minimatch.defaults(e).Minimatch}};ee.Minimatch=br;var yO=gd();Object.defineProperty(ee,"AST",{enumerable:!0,get:function(){return yO.AST}});var bO=vd();Object.defineProperty(ee,"escape",{enumerable:!0,get:function(){return bO.escape}});var wO=Ea();Object.defineProperty(ee,"unescape",{enumerable:!0,get:function(){return wO.unescape}});ee.minimatch.AST=Yx.AST;ee.minimatch.Minimatch=br;ee.minimatch.escape=$k.escape;ee.minimatch.unescape=Hk.unescape});var sy=T(Aa=>{"use strict";Object.defineProperty(Aa,"__esModule",{value:!0});Aa.LRUCache=void 0;var Wr=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,ny=new Set,xd=typeof process=="object"&&process?process:{},iy=(n,e,t,i)=>{typeof xd.emitWarning=="function"?xd.emitWarning(n,e,t,i):console.error(`[${t}] ${e}: ${n}`)},Na=globalThis.AbortController,ty=globalThis.AbortSignal;if(typeof Na>"u"){ty=class{onabort;_onabort=[];reason;aborted=!1;addEventListener(i,r){this._onabort.push(r)}},Na=class{constructor(){e()}signal=new ty;abort(i){if(!this.signal.aborted){this.signal.reason=i,this.signal.aborted=!0;for(let r of this.signal._onabort)r(i);this.signal.onabort?.(i)}}};let n=xd.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",e=()=>{n&&(n=!1,iy("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.","NO_ABORT_CONTROLLER","ENOTSUP",e))}}var _O=n=>!ny.has(n),fM=Symbol("type"),zi=n=>n&&n===Math.floor(n)&&n>0&&isFinite(n),ry=n=>zi(n)?n<=Math.pow(2,8)?Uint8Array:n<=Math.pow(2,16)?Uint16Array:n<=Math.pow(2,32)?Uint32Array:n<=Number.MAX_SAFE_INTEGER?Kr:null:null,Kr=class extends Array{constructor(e){super(e),this.fill(0)}},yd=class n{heap;length;static#e=!1;static create(e){let t=ry(e);if(!t)return[];n.#e=!0;let i=new n(e,t);return n.#e=!1,i}constructor(e,t){if(!n.#e)throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new t(e),this.length=0}push(e){this.heap[this.length++]=e}pop(){return this.heap[--this.length]}},bd=class n{#e;#n;#s;#i;#a;ttl;ttlResolution;ttlAutopurge;updateAgeOnGet;updateAgeOnHas;allowStale;noDisposeOnSet;noUpdateTTL;maxEntrySize;sizeCalculation;noDeleteOnFetchRejection;noDeleteOnStaleGet;allowStaleOnFetchAbort;allowStaleOnFetchRejection;ignoreFetchAbort;#u;#d;#c;#o;#t;#m;#v;#f;#p;#b;#g;#R;#D;#w;#y;#E;#h;static unsafeExposeInternals(e){r
Line truncated
|
||||
`;o.forEach(c=>{a+=c}),a+=`
|
||||
|
||||
Correct usage: new Package("my-binary", "https://example.com/binary/download.tar.gz", {"my-binary": "my-binary"})`,wo(a)}this.url=t,this.name=e,this.filename=i,this.zipExt=r,this.installDirectory=wc(__dirname,"node_modules",".bin_real"),this.binaries=s,Zd(this.installDirectory)||Sb(this.installDirectory,{recursive:!0})}exists(){for(let e in this.binaries){let t=this.binaries[e],i=wc(this.installDirectory,t);if(!Zd(i))return!1}return!0}install(e,t=!1){return this.exists()?(t||console.error(`${this.name} is already installed, skipping installation.`),Promise.resolve()):(Zd(this.installDirectory)&&T1.sync(this.installDirectory),Sb(this.installDirectory,{recursive:!0}),t||console.error(`Downloading release from ${this.url}`),D1({...e,url:this.url,responseType:"stream"}).then(i=>new Promise((r,s)=>{S1(`${E1}${C1}`,(o,a)=>{let c=wc(a,this.filename),u=i.data.pipe(_1(c));u.on("error",l=>s(l)),u.on("close",()=>{if(/\.tar\.*/.test(this.zipExt)){let l=ep("tar",["xf",c,"--strip-components","1","-C",this.installDirectory]);l.status==0?r():l.error?s(l.error):s(new Error(`An error occurred untarring the artifact: stdout: ${l.stdout}; stderr: ${l.stderr}`))}else if(this.zipExt==".zip"){let l=ep("unzip",["-q",c,"-d",this.installDirectory]);l.status==0?r():l.error?s(l.error):s(new Error(`An error occurred unzipping the artifact: stdout: ${l.stdout}; stderr: ${l.stderr}`))}else s(new Error(`Unrecognized file extension: ${this.zipExt}`))})})})).then(()=>{t||console.error(`${this.name} has been installed!`)}).catch(i=>{wo(`Error fetching release: ${i.message}`)}))}run(e,t){(this.exists()?Promise.resolve():this.install(t,!0)).then(()=>{let[,,...r]=process.argv,s={cwd:process.cwd(),stdio:"inherit"},o=this.binaries[e];o||wo(`${e} is not a known binary in ${this.name}`);let a=wc(this.installDirectory,o),c=ep(a,r,s);c.error&&wo(c.error),process.exit(c.status)}).catch(r=>{wo(r.message),process.exit(1)})}};Cb.exports.Package=tp});var Db=T((zM,_c)=>{var P1=function(){"use strict";function n(o,a,c,u){var l;typeof a=="object"&&(c=a.depth,u=a.prototype,l=a.filter,a=a.circular);var p=[],h=[],x=typeof Buffer<"u";typeof a>"u"&&(a=!0),typeof c>"u"&&(c=1/0);function f(y,w){if(y===null)return null;if(w==0)return y;var S,O;if(typeof y!="object")return y;if(n.__isArray(y))S=[];else if(n.__isRegExp(y))S=new RegExp(y.source,s(y)),y.lastIndex&&(S.lastIndex=y.lastIndex);else if(n.__isDate(y))S=new Date(y.getTime());else{if(x&&Buffer.isBuffer(y))return Buffer.allocUnsafe?S=Buffer.allocUnsafe(y.length):S=new Buffer(y.length),y.copy(S),S;typeof u>"u"?(O=Object.getPrototypeOf(y),S=Object.create(O)):(S=Object.create(u),O=u)}if(a){var k=p.indexOf(y);if(k!=-1)return h[k];p.push(y),h.push(S)}for(var N in y){var j;O&&(j=Object.getOwnPropertyDescriptor(O,N)),!(j&&j.set==null)&&(S[N]=f(y[N],w-1))}return S}return f(o,c)}n.clonePrototype=function(a){if(a===null)return null;var c=function(){};return c.prototype=a,new c};function e(o){return Object.prototype.toString.call(o)}n.__objToStr=e;function t(o){return typeof o=="object"&&e(o)==="[object Date]"}n.__isDate=t;function i(o){return typeof o=="object"&&e(o)==="[object Array]"}n.__isArray=i;function r(o){return typeof o=="object"&&e(o)==="[object RegExp]"}n.__isRegExp=r;function s(o){var a="";return o.global&&(a+="g"),o.ignoreCase&&(a+="i"),o.multiline&&(a+="m"),a}return n.__getRegExpFlags=s,n}();typeof _c=="object"&&_c.exports&&(_c.exports=P1)});var Eb=T(($M,Tb)=>{var k1=Db();Tb.exports=function(n,e){return n=n||{},Object.keys(e).forEach(function(t){typeof n[t]>"u"&&(n[t]=k1(e[t]))}),n}});var kb=T((HM,Pb)=>{Pb.exports=[[768,879],[1155,1158],[1160,1161],[1425,1469],[1471,1471],[1473,1474],[1476,1477],[1479,1479],[1536,1539],[1552,1557],[1611,1630],[1648,1648],[1750,1764],[1767,1768],[1770,1773],[1807,1807],[1809,1809],[1840,1866],[1958,1968],[2027,2035],[2305,2306],[2364,2364],[2369,2376],[2381,2381],[2385,2388],[2402,2403],[2433,2433],[2492,2492],[2497,2500],[2509,2509],[2530,2531],[2561,2562],[2620,2620],[2625,2626],[2631,2632],[2635,2637],[2672,2673],[2689,2690],[2748,2748],[2753,2757],[2759,2760],[2765,2765],[2786,2787],[2817,2817],[2876,2876],[2879,2879],[2881,2883],[2893,2893],[2902,2902],[2946,2946],[3008,3008],[3021,3021],[3134,3136],[3142,3144],[3146,3149],[3157,3158],[3260,3260],[3263,3263],[3270,3270],[3276,3277],[3298,3299],[3393,3395],[3405,3405],[3530,3530],[3538,3540],[3542,3542],[3633,3633],[3636,3642],[3655,3662],[3761,3761],[3764,3769],[3771,3772],[3784,3789],[3864,3865],[3893,3893],[3895,3895],[3897,3897],[3953,3966],[3968,3972],[3974,3975],[3984,3991],[3993,4028],[4038,4038],[4141,4144],[4146,4146],[4150,4151],[4153,4153],[4184,4185],[4448,4607],[4959,4959],[5906,5908],[5938,5940],[5970,5971],[6002,6003],[6068,6069],[6071,6077],[6086,6086],[6089,6099],[6109,6109],[6155,6157],[6313,6313],[6432,6434],[6439,6440],[6450,6450],[6457,6459],[6679,6680],[6912,6915],[6964,6964],[6966,6970],[6972,6972],[6978,6978],[7019,7027],[7616,7626],[7678,7679],[8203,8207],[8234,8238],[8288,8291],[8298,8303],[8400
Line truncated
|
||||
`}),i};Me.prototype.toString=function(){var n=this.columns(),e=new Me;return e.separator=this.separator,n.forEach(function(t){e.cell(t,t)}),e.newRow(),e.pushDelimeter(n),e.rows=e.rows.concat(this.rows),this.totals&&this.rows.length&&(e.pushDelimeter(n),this.forEachTotal(e.cell.bind(e)),e.newRow()),e.print()};Me.prototype.pushDelimeter=function(n){return n=n||this.columns(),n.forEach(function(e){this.cell(e,void 0,op("-"))},this),this.newRow()};Me.prototype.forEachTotal=function(n){for(var e in this.totals){var t=this.totals[e],i=t.init,r=this.rows.length;this.rows.forEach(function(s,o){i=t.reduce.call(s,i,s[e],o,r)}),n(e,i,t.printer)}};Me.prototype.printTransposed=function(n){n=n||{};var e=new Me;return e.separator=n.separator||this.separator,this.columns().forEach(function(t){e.cell(0,t,n.namePrinter),this.rows.forEach(function(i,r){e.cell(r+1,i[t],i.__printers[t])}),e.newRow()},this),e.print()};Me.prototype.sort=function(n){if(typeof n=="function")return this.rows.sort(n),this;var e=Array.isArray(n)?n:this.columns(),t=e.map(function(i){var r="asc",s=/(.*)\|\s*(asc|des)\s*$/.exec(i);return s&&(i=s[1],r=s[2]),function(o,a){return r=="asc"?rp(o[i],a[i]):rp(a[i],o[i])}});return this.sort(function(i,r){for(var s=0;s<t.length;s++){var o=t[s](i,r);if(o!=0)return o}return 0})};function rp(n,e){return n===e?0:n===void 0?1:e===void 0?-1:n===null?1:e===null?-1:n>e?1:n<e?-1:rp(String(n),String(e))}Me.prototype.total=function(n,e){return e=e||{},this.totals=this.totals||{},this.totals[n]={reduce:e.reduce||Me.aggr.sum,printer:e.printer||ap,init:e.init==null?0:e.init},this};Me.aggr={};Me.aggr.printer=function(n,e){return e=e||So,function(t,i){return ap(n+e(t),i)}};Me.aggr.sum=function(n,e){return n+e};Me.aggr.avg=function(n,e,t,i){return n=n+e,t+1==i?n/i:n};Me.print=function(n,e,t){var i=e||{};e=typeof e=="function"?e:function(o,a){for(var c in o)if(o.hasOwnProperty(c)){var u=i[c]||{};a(u.name||c,o[c],u.printer)}};var r=new Me,s=r.cell.bind(r);return Array.isArray(n)?(t=t||function(o){return o.toString()},n.forEach(function(o){e(o,s),r.newRow()})):(t=t||function(o){return o.printTransposed({separator:" : "})},e(n,s),r.newRow()),t(r)};Me.log=function(n,e,t){console.log(Me.print(n,e,t))};Me.prototype.log=function(){console.log(this.toString())}});var Ub=T((KM,Mb)=>{(function(){"use strict";function n(){if(typeof console>"u")throw new Error("Weird, console object is undefined");if(typeof console.table=="function"&&console.table===x)return;function e(f,y){return typeof y===f}var t=e.bind(null,"string");function i(f,y){return Array.isArray(y)&&y.every(f)}var r=i.bind(null,t),s=i.bind(null,Array.isArray),o=Lb();function a(f){var y=new o;return f.forEach(function(w){typeof w=="string"||typeof w=="number"?y.cell("item",w):Object.keys(w).forEach(function(S){y.cell(S,w[S])}),y.newRow()}),y.toString()}function c(f,y,w){var S=new o;y.forEach(function(k){k.forEach(function(N,j){S.cell(f[j],N)}),S.newRow()});var O=S.toString();return w?O:console.log(O)}function u(f,y){var w=a(y),S=w.indexOf(`
|
||||
`);if(S>0){f.length>S&&(S=f.length),console.log(f);var O="-",k,N="";for(k=0;k<S;k+=1)N+=O;console.log(N)}console.log(w)}function l(f,y){var w=a(y),S=w.indexOf(`
|
||||
`),O="";if(S>0){f.length>S&&(S=f.length),O+=f+`
|
||||
`;var k="-",N,j="";for(N=0;N<S;N+=1)j+=k;O+=j+`
|
||||
`}return O+w}function p(f){var y=Object.keys(f);return y.map(function(w){return{key:w,value:f[w]}})}function h(f){return a(p(f))}function x(){var f=Array.prototype.slice.call(arguments);if(f.length===2&&typeof f[0]=="string"&&Array.isArray(f[1]))return u(f[0],f[1]);if(f.length===2&&r(f[0])&&s(f[1]))return c(f[0],f[1]);f.forEach(function(y){if(typeof y=="string")return console.log(y);Array.isArray(y)?console.log(a(y)):typeof y=="object"&&console.log(h(y))})}Mb.exports.getTable=function(){var f=Array.prototype.slice.call(arguments),y="";return f.length===2&&typeof f[0]=="string"&&Array.isArray(f[1])?l(f[0],f[1]):f.length===2&&r(f[0])&&s(f[1])?c(f[0],f[1],!0):(f.forEach(function(w,S){if(typeof w=="string"){y+=w,S!==f.length-1&&(y+=`
|
||||
`);return}else Array.isArray(w)?y+=a(w)+`
|
||||
`:typeof w=="object"&&(y+=h(w))}),y)},console.table=x}n()})()});var Hb=T((GM,$b)=>{"use strict";var zb=()=>process.platform==="linux",Sc=null,N1=()=>{if(!Sc)if(zb()&&process.report){let n=process.report.excludeNetwork;process.report.excludeNetwork=!0,Sc=process.report.getReport(),process.report.excludeNetwork=n}else Sc={};return Sc};$b.exports={isLinux:zb,getReport:N1}});var Kb=T((VM,Wb)=>{"use strict";var Bb=require("fs"),A1="/usr/bin/ldd",I1=n=>Bb.readFileSync(n,"utf-8"),j1=n=>new Promise((e,t)=>{Bb.readFile(n,"utf-8",(i,r)=>{i?t(i):e(r)})});Wb.exports={LDD_PATH:A1,readFileSync:I1,readFile:j1}});var lw=T((XM,uw)=>{"use strict";var Vb=require("child_process"),{isLinux:as,getReport:Xb}=Hb(),{LDD_PATH:Cc,readFile:Jb,readFileSync:Yb}=Kb(),ui,li,Qb="getconf GNU_LIBC_VERSION 2>&1 || true; ldd --version 2>&1 || true",Yi="",Zb=()=>Yi||new Promise(n=>{Vb.exec(Qb,(e,t)=>{Yi=e?" ":t,n(Yi)})}),ew=()=>{if(!Yi)try{Yi=Vb.execSync(Qb,{encoding:"utf8"})}catch{Yi=" "}return Yi},Qi="glibc",tw=/LIBC[a-z0-9 \-).]*?(\d+\.\d+)/i,os="musl",L1=n=>n.includes("libc.musl-")||n.includes("ld-musl-"),nw=()=>{let n=Xb();return n.header&&n.header.glibcVersionRuntime?Qi:Array.isArray(n.sharedObjects)&&n.sharedObjects.some(L1)?os:null},iw=n=>{let[e,t]=n.split(/[\r\n]+/);return e&&e.includes(Qi)?Qi:t&&t.includes(os)?os:null},rw=n=>n.includes("musl")?os:n.includes("GNU C Library")?Qi:null,M1=async()=>{if(ui!==void 0)return ui;ui=null;try{let n=await Jb(Cc);ui=rw(n)}catch{}return ui},U1=()=>{if(ui!==void 0)return ui;ui=null;try{let n=Yb(Cc);ui=rw(n)}catch{}return ui},sw=async()=>{let n=null;if(as()&&(n=await M1(),n||(n=nw()),!n)){let e=await Zb();n=iw(e)}return n},ow=()=>{let n=null;if(as()&&(n=U1(),n||(n=nw()),!n)){let e=ew();n=iw(e)}return n},z1=async()=>as()&&await sw()!==Qi,$1=()=>as()&&ow()!==Qi,H1=async()=>{if(li!==void 0)return li;li=null;try{let e=(await Jb(Cc)).match(tw);e&&(li=e[1])}catch{}return li},B1=()=>{if(li!==void 0)return li;li=null;try{let e=Yb(Cc).match(tw);e&&(li=e[1])}catch{}return li},aw=()=>{let n=Xb();return n.header&&n.header.glibcVersionRuntime?n.header.glibcVersionRuntime:null},Gb=n=>n.trim().split(/\s+/)[1],cw=n=>{let[e,t,i]=n.split(/[\r\n]+/);return e&&e.includes(Qi)?Gb(e):t&&i&&t.includes(os)?Gb(i):null},W1=async()=>{let n=null;if(as()&&(n=await H1(),n||(n=aw()),!n)){let e=await Zb();n=cw(e)}return n},K1=()=>{let n=null;if(as()&&(n=B1(),n||(n=aw()),!n)){let e=ew();n=cw(e)}return n};uw.exports={GLIBC:Qi,MUSL:os,family:sw,familySync:ow,isNonGlibcLinux:z1,isNonGlibcLinuxSync:$1,version:W1,versionSync:K1}});var pw=T(Rc=>{"use strict";Object.defineProperty(Rc,"__esModule",{value:!0});Rc.getProxyEnv=void 0;var dw=n=>n.replace(/^\.*/,".").toLowerCase(),G1=n=>{n=n.trim();let e=n.split(":",2),t=dw(e[0]),i=e[1],r=n.indexOf(":")>-1;return{hostname:t,port:i,hasPort:r}},V1=(n,e)=>{let t=n.port||(n.protocol==="https:"?"443":"80"),i=dw(n.hostname);return e.split(",").map(G1).some(s=>{let o=i.indexOf(s.hostname),a=o>-1&&o===i.length-s.hostname.length;return s.hasPort?t===s.port&&a:a})},X1=n=>{let e=process.env.NO_PROXY||process.env.no_proxy||"";return e==="*"||e!==""&&V1(n,e)?null:n.protocol=="http:"?process.env.HTTP_PROXY||process.env.http_proxy||null:n.protocol=="https:"&&(process.env.HTTPS_PROXY||process.env.https_proxy)||null};Rc.getProxyEnv=X1});var gw=T(cs=>{"use strict";var YM=require("net"),J1=require("tls"),cp=require("http"),fw=require("https"),Y1=require("events"),QM=require("assert"),Q1=require("util");cs.httpOverHttp=Z1;cs.httpsOverHttp=eF;cs.httpOverHttps=tF;cs.httpsOverHttps=nF;function Z1(n){var e=new Si(n);return e.request=cp.request,e}function eF(n){var e=new Si(n);return e.request=cp.request,e.createSocket=hw,e.defaultPort=443,e}function tF(n){var e=new Si(n);return e.request=fw.request,e}function nF(n){var e=new Si(n);return e.request=fw.request,e.createSocket=hw,e.defaultPort=443,e}function Si(n){var e=this;e.options=n||{},e.proxyOptions=e.options.proxy||{},e.maxSockets=e.options.maxSockets||cp.Agent.defaultMaxSockets,e.requests=[],e.sockets=[],e.on("free",function(i,r,s,o){for(var a=mw(r,s,o),c=0,u=e.requests.length;c<u;++c){var l=e.requests[c];if(l.host===a.host&&l.port===a.port){e.requests.splice(c,1),l.request.onSocket(i);return}}i.destroy(),e.removeSocket(i)})}Q1.inherits(Si,Y1.EventEmitter);Si.prototype.addRequest=function(e,t,i,r){var s=this,o=up({request:e},s.options,mw(t,i,r));if(s.sockets.length>=this.maxSockets){s.requests.push(o);return}s.createSocket(o,function(a){a.on("free",c),a.on("close",u),a.on("agentRemove",u),e.onSocket(a);function c(){s.emit("free",a,o)}function u(l){s.removeSocket(a),a.removeListener("free",c),a.removeListener("close",u),a.removeListener("agentRemove",u)}})};Si.prototype.createSocket=function(e,t){var i=this,r={};i.sockets.push(r);var s=up({},i.proxyOptions,{method:"CONNECT",path:e.host+":"+e.port,agent:!1,headers:{host:e.host+":"+e.port}});e.localAddress&&(s.localAddress=e.localAddress),s.proxyAuth&&(s.headers=s.headers||{},s.headers["Proxy-Authorization"]="Basic "+n
Line truncated
|
||||
`,p.message,p.stack);var h=new Error("tunneling socket could not be established, cause="+p.message);h.code="ECONNRESET",e.request.emit("error",h),i.removeSocket(r)}};Si.prototype.removeSocket=function(e){var t=this.sockets.indexOf(e);if(t!==-1){this.sockets.splice(t,1);var i=this.requests.shift();i&&this.createSocket(i,function(r){i.request.onSocket(r)})}};function hw(n,e){var t=this;Si.prototype.createSocket.call(t,n,function(i){var r=n.request.getHeader("host"),s=up({},t.options,{socket:i,servername:r?r.replace(/:.*$/,""):n.host}),o=J1.connect(0,s);t.sockets[t.sockets.indexOf(i)]=o,e(o)})}function mw(n,e,t){return typeof n=="string"?{host:n,port:e,localAddress:t}:n}function up(n){for(var e=1,t=arguments.length;e<t;++e){var i=arguments[e];if(typeof i=="object")for(var r=Object.keys(i),s=0,o=r.length;s<o;++s){var a=r[s];i[a]!==void 0&&(n[a]=i[a])}}return n}var Zi;process.env.NODE_DEBUG&&/\btunnel\b/.test(process.env.NODE_DEBUG)?Zi=function(){var n=Array.prototype.slice.call(arguments);typeof n[0]=="string"?n[0]="TUNNEL: "+n[0]:n.unshift("TUNNEL:"),console.error.apply(console,n)}:Zi=function(){};cs.debug=Zi});var xw=T((e2,vw)=>{vw.exports=gw()});var yw=T(Dc=>{"use strict";Object.defineProperty(Dc,"__esModule",{value:!0});Dc.configureProxy=void 0;var iF=pw(),rF=xw(),sF=n=>{let e=new URL(n),t=(0,iF.getProxyEnv)(e);if(!t)return null;let{hostname:i,port:r,protocol:s,username:o,password:a}=new URL(t);return e.protocol==="https:"&&s==="http:"?{proxy:!1,httpsAgent:(0,rF.httpsOverHttp)({proxy:{host:i,port:parseInt(r)}})}:{proxy:{protocol:s,hostname:i,port:parseInt(r),auth:{username:o,password:a}}}};Dc.configureProxy=sF});var bw=T(Tc=>{"use strict";Object.defineProperty(Tc,"__esModule",{value:!0});Tc.configureProxy=void 0;var oF=yw();Object.defineProperty(Tc,"configureProxy",{enumerable:!0,get:function(){return oF.configureProxy}})});var ww=T((i2,aF)=>{aF.exports={artifactDownloadUrl:"https://github.com/kdl-org/kdl-rs/releases/download/v6.3.2",bin:{"kdl-lsp":"run-kdl-lsp.js"},contributors:["Kat March\xE1n <kzm@zkat.tech>","KDL Community"],dependencies:{axios:"^1.7.9","axios-proxy-builder":"^0.1.2","console.table":"^0.10.0","detect-libc":"^2.0.3",rimraf:"^5.0.8"},description:"LSP Server for the KDL Document Language",devDependencies:{prettier:"^3.4.2"},engines:{node:">=14",npm:">=6"},glibcMinimum:{major:2,series:31},homepage:"https://kdl.dev",keywords:["kdl","document","config","lsp","language-server"],license:"Apache-2.0",name:"kdl-lsp",preferUnplugged:!0,repository:"https://github.com/kdl-org/kdl-rs",scripts:{fmt:"prettier --write **/*.js","fmt:check":"prettier --check **/*.js",postinstall:"node ./install.js"},supportedPlatforms:{"aarch64-apple-darwin":{artifactName:"kdl-lsp-aarch64-apple-darwin.tar.xz",bins:{"kdl-lsp":"kdl-lsp"},zipExt:".tar.xz"},"aarch64-pc-windows-gnu":{artifactName:"kdl-lsp-aarch64-pc-windows-msvc.zip",bins:{"kdl-lsp":"kdl-lsp.exe"},zipExt:".zip"},"aarch64-pc-windows-msvc":{artifactName:"kdl-lsp-aarch64-pc-windows-msvc.zip",bins:{"kdl-lsp":"kdl-lsp.exe"},zipExt:".zip"},"aarch64-unknown-linux-gnu":{artifactName:"kdl-lsp-aarch64-unknown-linux-gnu.tar.xz",bins:{"kdl-lsp":"kdl-lsp"},zipExt:".tar.xz"},"x86_64-apple-darwin":{artifactName:"kdl-lsp-x86_64-apple-darwin.tar.xz",bins:{"kdl-lsp":"kdl-lsp"},zipExt:".tar.xz"},"x86_64-pc-windows-gnu":{artifactName:"kdl-lsp-x86_64-pc-windows-msvc.zip",bins:{"kdl-lsp":"kdl-lsp.exe"},zipExt:".zip"},"x86_64-pc-windows-msvc":{artifactName:"kdl-lsp-x86_64-pc-windows-msvc.zip",bins:{"kdl-lsp":"kdl-lsp.exe"},zipExt:".zip"},"x86_64-unknown-linux-gnu":{artifactName:"kdl-lsp-x86_64-unknown-linux-gnu.tar.xz",bins:{"kdl-lsp":"kdl-lsp"},zipExt:".tar.xz"}},version:"6.3.2",volta:{node:"18.14.1",npm:"9.5.0"}}});var Ew=T((s2,Tw)=>{var{Package:cF}=Rb(),_w=require("os"),r2=Ub(),lp=lw(),{configureProxy:Cw}=bw(),uF=n=>{console.error(n),process.exit(1)},{name:Rw,artifactDownloadUrl:dp,supportedPlatforms:Sw,glibcMinimum:Dw}=ww(),lF=Dw.major,dF=Dw.series,pF=()=>{let n=_w.type(),e=_w.arch(),t="";switch(n){case"Windows_NT":t="pc-windows-msvc";break;case"Darwin":t="apple-darwin";break;case"Linux":t="unknown-linux-gnu";break}let i="";switch(e){case"x64":i="x86_64";break;case"arm64":i="aarch64";break}if(n==="Linux")if(lp.familySync()=="musl")t="unknown-linux-musl-dynamic";else if(lp.isNonGlibcLinuxSync())console.warn("Your libc is neither glibc nor musl; trying static musl binary instead"),t="unknown-linux-musl-static";else{let a=lp.versionSync().split("."),c=a[0],u=a[1];(c!=lF||u<dF)&&(console.warn("Your glibc isn't compatible; trying static musl binary instead"),t="unknown-linux-musl-static")}let r=`${i}-${t}`,s=Sw[r];return s||uF(`Platform with type "${n}" and architecture "${e}" is not supported by ${Rw}.
|
||||
Your system must be one of the following:
|
||||
|
||||
${Object.keys(Sw).join(",")}`),s},pp=()=>{let n=pF(),e=`${dp}/${n.artifactName}`,t=n.artifactName,i=n.zipExt;return new cF(Rw,e,t,i,n.bins)},fF=n=>{if(!dp||dp.length===0){console.warn("in demo mode, not installing binaries");return}let e=pp(),t=Cw(e.url);return e.install(t,n)},hF=n=>{let e=pp(),t=Cw(e.url);e.run(n,t)};Tw.exports={install:fF,run:hF,getPackage:pp}});var kw=T(Ec=>{"use strict";Object.defineProperty(Ec,"__esModule",{value:!0});Ec.getProxyEnv=void 0;var Pw=n=>n.replace(/^\.*/,".").toLowerCase(),mF=n=>{n=n.trim();let e=n.split(":",2),t=Pw(e[0]),i=e[1],r=n.indexOf(":")>-1;return{hostname:t,port:i,hasPort:r}},gF=(n,e)=>{let t=n.port||(n.protocol==="https:"?"443":"80"),i=Pw(n.hostname);return e.split(",").map(mF).some(s=>{let o=i.indexOf(s.hostname),a=o>-1&&o===i.length-s.hostname.length;return s.hasPort?t===s.port&&a:a})},vF=n=>{let e=process.env.NO_PROXY||process.env.no_proxy||"";return e==="*"||e!==""&&gF(n,e)?null:n.protocol=="http:"?process.env.HTTP_PROXY||process.env.http_proxy||null:n.protocol=="https:"&&(process.env.HTTPS_PROXY||process.env.https_proxy)||null};Ec.getProxyEnv=vF});var Nw=T(us=>{"use strict";var a2=require("net"),xF=require("tls"),fp=require("http"),Ow=require("https"),yF=require("events"),c2=require("assert"),bF=require("util");us.httpOverHttp=wF;us.httpsOverHttp=_F;us.httpOverHttps=SF;us.httpsOverHttps=CF;function wF(n){var e=new Ci(n);return e.request=fp.request,e}function _F(n){var e=new Ci(n);return e.request=fp.request,e.createSocket=qw,e.defaultPort=443,e}function SF(n){var e=new Ci(n);return e.request=Ow.request,e}function CF(n){var e=new Ci(n);return e.request=Ow.request,e.createSocket=qw,e.defaultPort=443,e}function Ci(n){var e=this;e.options=n||{},e.proxyOptions=e.options.proxy||{},e.maxSockets=e.options.maxSockets||fp.Agent.defaultMaxSockets,e.requests=[],e.sockets=[],e.on("free",function(i,r,s,o){for(var a=Fw(r,s,o),c=0,u=e.requests.length;c<u;++c){var l=e.requests[c];if(l.host===a.host&&l.port===a.port){e.requests.splice(c,1),l.request.onSocket(i);return}}i.destroy(),e.removeSocket(i)})}bF.inherits(Ci,yF.EventEmitter);Ci.prototype.addRequest=function(e,t,i,r){var s=this,o=hp({request:e},s.options,Fw(t,i,r));if(s.sockets.length>=this.maxSockets){s.requests.push(o);return}s.createSocket(o,function(a){a.on("free",c),a.on("close",u),a.on("agentRemove",u),e.onSocket(a);function c(){s.emit("free",a,o)}function u(l){s.removeSocket(a),a.removeListener("free",c),a.removeListener("close",u),a.removeListener("agentRemove",u)}})};Ci.prototype.createSocket=function(e,t){var i=this,r={};i.sockets.push(r);var s=hp({},i.proxyOptions,{method:"CONNECT",path:e.host+":"+e.port,agent:!1,headers:{host:e.host+":"+e.port}});e.localAddress&&(s.localAddress=e.localAddress),s.proxyAuth&&(s.headers=s.headers||{},s.headers["Proxy-Authorization"]="Basic "+new Buffer(s.proxyAuth).toString("base64")),er("making CONNECT request");var o=i.request(s);o.useChunkedEncodingByDefault=!1,o.once("response",a),o.once("upgrade",c),o.once("connect",u),o.once("error",l),o.end();function a(p){p.upgrade=!0}function c(p,h,x){process.nextTick(function(){u(p,h,x)})}function u(p,h,x){if(o.removeAllListeners(),h.removeAllListeners(),p.statusCode!==200){er("tunneling socket could not be established, statusCode=%d",p.statusCode),h.destroy();var f=new Error("tunneling socket could not be established, statusCode="+p.statusCode);f.code="ECONNRESET",e.request.emit("error",f),i.removeSocket(r);return}if(x.length>0){er("got illegal response body from proxy"),h.destroy();var f=new Error("got illegal response body from proxy");f.code="ECONNRESET",e.request.emit("error",f),i.removeSocket(r);return}return er("tunneling connection has established"),i.sockets[i.sockets.indexOf(r)]=h,t(h)}function l(p){o.removeAllListeners(),er(`tunneling socket could not be established, cause=%s
|
||||
`,p.message,p.stack);var h=new Error("tunneling socket could not be established, cause="+p.message);h.code="ECONNRESET",e.request.emit("error",h),i.removeSocket(r)}};Ci.prototype.removeSocket=function(e){var t=this.sockets.indexOf(e);if(t!==-1){this.sockets.splice(t,1);var i=this.requests.shift();i&&this.createSocket(i,function(r){i.request.onSocket(r)})}};function qw(n,e){var t=this;Ci.prototype.createSocket.call(t,n,function(i){var r=n.request.getHeader("host"),s=hp({},t.options,{socket:i,servername:r?r.replace(/:.*$/,""):n.host}),o=xF.connect(0,s);t.sockets[t.sockets.indexOf(i)]=o,e(o)})}function Fw(n,e,t){return typeof n=="string"?{host:n,port:e,localAddress:t}:n}function hp(n){for(var e=1,t=arguments.length;e<t;++e){var i=arguments[e];if(typeof i=="object")for(var r=Object.keys(i),s=0,o=r.length;s<o;++s){var a=r[s];i[a]!==void 0&&(n[a]=i[a])}}return n}var er;process.env.NODE_DEBUG&&/\btunnel\b/.test(process.env.NODE_DEBUG)?er=function(){var n=Array.prototype.slice.call(arguments);typeof n[0]=="string"?n[0]="TUNNEL: "+n[0]:n.unshift("TUNNEL:"),console.error.apply(console,n)}:er=function(){};us.debug=er});var Iw=T((l2,Aw)=>{Aw.exports=Nw()});var jw=T(Pc=>{"use strict";Object.defineProperty(Pc,"__esModule",{value:!0});Pc.configureProxy=void 0;var RF=kw(),DF=Iw(),TF=n=>{let e=new URL(n),t=(0,RF.getProxyEnv)(e);if(!t)return null;let{hostname:i,port:r,protocol:s,username:o,password:a}=new URL(t);return e.protocol==="https:"&&s==="http:"?{proxy:!1,httpsAgent:(0,DF.httpsOverHttp)({proxy:{host:i,port:parseInt(r)}})}:{proxy:{protocol:s,hostname:i,port:parseInt(r),auth:{username:o,password:a}}}};Pc.configureProxy=TF});var Lw=T(kc=>{"use strict";Object.defineProperty(kc,"__esModule",{value:!0});kc.configureProxy=void 0;var EF=jw();Object.defineProperty(kc,"configureProxy",{enumerable:!0,get:function(){return EF.configureProxy}})});var qn=T(pt=>{"use strict";Object.defineProperty(pt,"__esModule",{value:!0});pt.asPromise=pt.thenable=pt.typedArray=pt.stringArray=pt.array=pt.func=pt.error=pt.number=pt.string=pt.boolean=void 0;function PF(n){return n===!0||n===!1}pt.boolean=PF;function Mw(n){return typeof n=="string"||n instanceof String}pt.string=Mw;function kF(n){return typeof n=="number"||n instanceof Number}pt.number=kF;function OF(n){return n instanceof Error}pt.error=OF;function Uw(n){return typeof n=="function"}pt.func=Uw;function zw(n){return Array.isArray(n)}pt.array=zw;function qF(n){return zw(n)&&n.every(e=>Mw(e))}pt.stringArray=qF;function FF(n,e){return Array.isArray(n)&&n.every(e)}pt.typedArray=FF;function $w(n){return n&&Uw(n.then)}pt.thenable=$w;function NF(n){return n instanceof Promise?n:$w(n)?new Promise((e,t)=>{n.then(i=>e(i),i=>t(i))}):Promise.resolve(n)}pt.asPromise=NF});var ls=T(Ut=>{"use strict";Object.defineProperty(Ut,"__esModule",{value:!0});Ut.stringArray=Ut.array=Ut.func=Ut.error=Ut.number=Ut.string=Ut.boolean=void 0;function AF(n){return n===!0||n===!1}Ut.boolean=AF;function Hw(n){return typeof n=="string"||n instanceof String}Ut.string=Hw;function IF(n){return typeof n=="number"||n instanceof Number}Ut.number=IF;function jF(n){return n instanceof Error}Ut.error=jF;function LF(n){return typeof n=="function"}Ut.func=LF;function Bw(n){return Array.isArray(n)}Ut.array=Bw;function MF(n){return Bw(n)&&n.every(e=>Hw(e))}Ut.stringArray=MF});var Mp=T(ne=>{"use strict";Object.defineProperty(ne,"__esModule",{value:!0});ne.Message=ne.NotificationType9=ne.NotificationType8=ne.NotificationType7=ne.NotificationType6=ne.NotificationType5=ne.NotificationType4=ne.NotificationType3=ne.NotificationType2=ne.NotificationType1=ne.NotificationType0=ne.NotificationType=ne.RequestType9=ne.RequestType8=ne.RequestType7=ne.RequestType6=ne.RequestType5=ne.RequestType4=ne.RequestType3=ne.RequestType2=ne.RequestType1=ne.RequestType=ne.RequestType0=ne.AbstractMessageSignature=ne.ParameterStructures=ne.ResponseError=ne.ErrorCodes=void 0;var Cr=ls(),mp;(function(n){n.ParseError=-32700,n.InvalidRequest=-32600,n.MethodNotFound=-32601,n.InvalidParams=-32602,n.InternalError=-32603,n.jsonrpcReservedErrorRangeStart=-32099,n.serverErrorStart=-32099,n.MessageWriteError=-32099,n.MessageReadError=-32098,n.PendingResponseRejected=-32097,n.ConnectionInactive=-32096,n.ServerNotInitialized=-32002,n.UnknownErrorCode=-32001,n.jsonrpcReservedErrorRangeEnd=-32e3,n.serverErrorEnd=-32e3})(mp||(ne.ErrorCodes=mp={}));var gp=class n extends Error{constructor(e,t,i){super(t),this.code=Cr.number(e)?e:mp.UnknownErrorCode,this.data=i,Object.setPrototypeOf(this,n.prototype)}toJson(){let e={code:this.code,message:this.message};return this.data!==void 0&&(e.data=this.data),e}};ne.ResponseError=gp;var sn=class n{constructor(e){this.kind=e}static is(e){return e===n.auto||e===n.byName||e===n.byPosition}toString(){return this.kind}};ne.ParameterStructures=sn;sn.auto=new sn("auto");sn.byPosition=new sn("byPosition");sn.byName=new sn("byName");var Xe=class{constructor(e,t){this.method=e,this.numberOfParams=t}get parameterStructures(){return sn.auto}};ne.Abs
Line truncated
|
||||
${JSON.stringify(Object.fromEntries(i))}`));return}let s=parseInt(r);if(isNaN(s)){this.fireError(new Error(`Content-Length value must be a number. Got ${r}`));return}this.nextMessageLength=s}let t=this.buffer.tryReadBody(this.nextMessageLength);if(t===void 0){this.setPartialMessageTimer();return}this.clearPartialMessageTimer(),this.nextMessageLength=-1,this.readSemaphore.lock(async()=>{let i=this.options.contentDecoder!==void 0?await this.options.contentDecoder.decode(t):t,r=await this.options.contentTypeDecoder.decode(i,this.options);this.callback(r)}).catch(i=>{this.fireError(i)})}}catch(t){this.fireError(t)}}clearPartialMessageTimer(){this.partialMessageTimer&&(this.partialMessageTimer.dispose(),this.partialMessageTimer=void 0)}setPartialMessageTimer(){this.clearPartialMessageTimer(),!(this._partialMessageTimeout<=0)&&(this.partialMessageTimer=(0,tf.default)().timer.setTimeout((e,t)=>{this.partialMessageTimer=void 0,e===this.messageToken&&(this.firePartialMessage({messageToken:e,waitingTime:t}),this.setPartialMessageTimer())},this._partialMessageTimeout,this.messageToken,this._partialMessageTimeout))}};ir.ReadableStreamMessageReader=rf});var i_=T(rr=>{"use strict";Object.defineProperty(rr,"__esModule",{value:!0});rr.WriteableStreamMessageWriter=rr.AbstractMessageWriter=rr.MessageWriter=void 0;var Zw=nr(),Ro=ls(),GF=Zp(),e_=ps(),VF="Content-Length: ",t_=`\r
|
||||
`,n_;(function(n){function e(t){let i=t;return i&&Ro.func(i.dispose)&&Ro.func(i.onClose)&&Ro.func(i.onError)&&Ro.func(i.write)}n.is=e})(n_||(rr.MessageWriter=n_={}));var Mc=class{constructor(){this.errorEmitter=new e_.Emitter,this.closeEmitter=new e_.Emitter}dispose(){this.errorEmitter.dispose(),this.closeEmitter.dispose()}get onError(){return this.errorEmitter.event}fireError(e,t,i){this.errorEmitter.fire([this.asError(e),t,i])}get onClose(){return this.closeEmitter.event}fireClose(){this.closeEmitter.fire(void 0)}asError(e){return e instanceof Error?e:new Error(`Writer received error. Reason: ${Ro.string(e.message)?e.message:"unknown"}`)}};rr.AbstractMessageWriter=Mc;var sf;(function(n){function e(t){return t===void 0||typeof t=="string"?{charset:t??"utf-8",contentTypeEncoder:(0,Zw.default)().applicationJson.encoder}:{charset:t.charset??"utf-8",contentEncoder:t.contentEncoder,contentTypeEncoder:t.contentTypeEncoder??(0,Zw.default)().applicationJson.encoder}}n.fromOptions=e})(sf||(sf={}));var of=class extends Mc{constructor(e,t){super(),this.writable=e,this.options=sf.fromOptions(t),this.errorCount=0,this.writeSemaphore=new GF.Semaphore(1),this.writable.onError(i=>this.fireError(i)),this.writable.onClose(()=>this.fireClose())}async write(e){return this.writeSemaphore.lock(async()=>this.options.contentTypeEncoder.encode(e,this.options).then(i=>this.options.contentEncoder!==void 0?this.options.contentEncoder.encode(i):i).then(i=>{let r=[];return r.push(VF,i.byteLength.toString(),t_),r.push(t_),this.doWrite(e,r,i)},i=>{throw this.fireError(i),i}))}async doWrite(e,t,i){try{return await this.writable.write(t.join(""),"ascii"),this.writable.write(i)}catch(r){return this.handleError(r,e),Promise.reject(r)}}handleError(e,t){this.errorCount++,this.fireError(e,t,this.errorCount)}end(){this.writable.end()}};rr.WriteableStreamMessageWriter=of});var r_=T(Uc=>{"use strict";Object.defineProperty(Uc,"__esModule",{value:!0});Uc.AbstractMessageBuffer=void 0;var XF=13,JF=10,YF=`\r
|
||||
`,af=class{constructor(e="utf-8"){this._encoding=e,this._chunks=[],this._totalLength=0}get encoding(){return this._encoding}append(e){let t=typeof e=="string"?this.fromString(e,this._encoding):e;this._chunks.push(t),this._totalLength+=t.byteLength}tryReadHeaders(e=!1){if(this._chunks.length===0)return;let t=0,i=0,r=0,s=0;e:for(;i<this._chunks.length;){let u=this._chunks[i];for(r=0;r<u.length;){switch(u[r]){case XF:switch(t){case 0:t=1;break;case 2:t=3;break;default:t=0}break;case JF:switch(t){case 1:t=2;break;case 3:t=4,r++;break e;default:t=0}break;default:t=0}r++}s+=u.byteLength,i++}if(t!==4)return;let o=this._read(s+r),a=new Map,c=this.toString(o,"ascii").split(YF);if(c.length<2)return a;for(let u=0;u<c.length-2;u++){let l=c[u],p=l.indexOf(":");if(p===-1)throw new Error(`Message header must separate key and value using ':'
|
||||
${l}`);let h=l.substr(0,p),x=l.substr(p+1).trim();a.set(e?h.toLowerCase():h,x)}return a}tryReadBody(e){if(!(this._totalLength<e))return this._read(e)}get numberOfBytes(){return this._totalLength}_read(e){if(e===0)return this.emptyBuffer();if(e>this._totalLength)throw new Error("Cannot read so many bytes!");if(this._chunks[0].byteLength===e){let s=this._chunks[0];return this._chunks.shift(),this._totalLength-=e,this.asNative(s)}if(this._chunks[0].byteLength>e){let s=this._chunks[0],o=this.asNative(s,e);return this._chunks[0]=s.slice(e),this._totalLength-=e,o}let t=this.allocNative(e),i=0,r=0;for(;e>0;){let s=this._chunks[r];if(s.byteLength>e){let o=s.slice(0,e);t.set(o,i),i+=e,this._chunks[r]=s.slice(e),this._totalLength-=e,e-=e}else t.set(s,i),i+=s.byteLength,this._chunks.shift(),this._totalLength-=s.byteLength,e-=s.byteLength}return t}};Uc.AbstractMessageBuffer=af});var u_=T(pe=>{"use strict";Object.defineProperty(pe,"__esModule",{value:!0});pe.createMessageConnection=pe.ConnectionOptions=pe.MessageStrategy=pe.CancellationStrategy=pe.CancellationSenderStrategy=pe.CancellationReceiverStrategy=pe.RequestCancellationReceiverStrategy=pe.IdCancellationReceiverStrategy=pe.ConnectionStrategy=pe.ConnectionError=pe.ConnectionErrors=pe.LogTraceNotification=pe.SetTraceNotification=pe.TraceFormat=pe.TraceValues=pe.Trace=pe.NullLogger=pe.ProgressType=pe.ProgressToken=void 0;var s_=nr(),rt=ls(),oe=Mp(),o_=zp(),Do=ps(),cf=Ic(),Po;(function(n){n.type=new oe.NotificationType("$/cancelRequest")})(Po||(Po={}));var uf;(function(n){function e(t){return typeof t=="string"||typeof t=="number"}n.is=e})(uf||(pe.ProgressToken=uf={}));var To;(function(n){n.type=new oe.NotificationType("$/progress")})(To||(To={}));var lf=class{constructor(){}};pe.ProgressType=lf;var df;(function(n){function e(t){return rt.func(t)}n.is=e})(df||(df={}));pe.NullLogger=Object.freeze({error:()=>{},warn:()=>{},info:()=>{},log:()=>{}});var qe;(function(n){n[n.Off=0]="Off",n[n.Messages=1]="Messages",n[n.Compact=2]="Compact",n[n.Verbose=3]="Verbose"})(qe||(pe.Trace=qe={}));var a_;(function(n){n.Off="off",n.Messages="messages",n.Compact="compact",n.Verbose="verbose"})(a_||(pe.TraceValues=a_={}));(function(n){function e(i){if(!rt.string(i))return n.Off;switch(i=i.toLowerCase(),i){case"off":return n.Off;case"messages":return n.Messages;case"compact":return n.Compact;case"verbose":return n.Verbose;default:return n.Off}}n.fromString=e;function t(i){switch(i){case n.Off:return"off";case n.Messages:return"messages";case n.Compact:return"compact";case n.Verbose:return"verbose";default:return"off"}}n.toString=t})(qe||(pe.Trace=qe={}));var vn;(function(n){n.Text="text",n.JSON="json"})(vn||(pe.TraceFormat=vn={}));(function(n){function e(t){return rt.string(t)?(t=t.toLowerCase(),t==="json"?n.JSON:n.Text):n.Text}n.fromString=e})(vn||(pe.TraceFormat=vn={}));var pf;(function(n){n.type=new oe.NotificationType("$/setTrace")})(pf||(pe.SetTraceNotification=pf={}));var zc;(function(n){n.type=new oe.NotificationType("$/logTrace")})(zc||(pe.LogTraceNotification=zc={}));var Eo;(function(n){n[n.Closed=1]="Closed",n[n.Disposed=2]="Disposed",n[n.AlreadyListening=3]="AlreadyListening"})(Eo||(pe.ConnectionErrors=Eo={}));var gs=class n extends Error{constructor(e,t){super(t),this.code=e,Object.setPrototypeOf(this,n.prototype)}};pe.ConnectionError=gs;var ff;(function(n){function e(t){let i=t;return i&&rt.func(i.cancelUndispatched)}n.is=e})(ff||(pe.ConnectionStrategy=ff={}));var $c;(function(n){function e(t){let i=t;return i&&(i.kind===void 0||i.kind==="id")&&rt.func(i.createCancellationTokenSource)&&(i.dispose===void 0||rt.func(i.dispose))}n.is=e})($c||(pe.IdCancellationReceiverStrategy=$c={}));var hf;(function(n){function e(t){let i=t;return i&&i.kind==="request"&&rt.func(i.createCancellationTokenSource)&&(i.dispose===void 0||rt.func(i.dispose))}n.is=e})(hf||(pe.RequestCancellationReceiverStrategy=hf={}));var Hc;(function(n){n.Message=Object.freeze({createCancellationTokenSource(t){return new cf.CancellationTokenSource}});function e(t){return $c.is(t)||hf.is(t)}n.is=e})(Hc||(pe.CancellationReceiverStrategy=Hc={}));var Bc;(function(n){n.Message=Object.freeze({sendCancellation(t,i){return t.sendNotification(Po.type,{id:i})},cleanup(t){}});function e(t){let i=t;return i&&rt.func(i.sendCancellation)&&rt.func(i.cleanup)}n.is=e})(Bc||(pe.CancellationSenderStrategy=Bc={}));var Wc;(function(n){n.Message=Object.freeze({receiver:Hc.Message,sender:Bc.Message});function e(t){let i=t;return i&&Hc.is(i.receiver)&&Bc.is(i.sender)}n.is=e})(Wc||(pe.CancellationStrategy=Wc={}));var Kc;(function(n){function e(t){let i=t;return i&&rt.func(i.handleMessage)}n.is=e})(Kc||(pe.MessageStrategy=Kc={}));var c_;(function(n){function e(t){let i=t;return i&&(Wc.is(i.cancellationStrategy)||ff.is(i.connectionStrategy)||Kc.is(i.messageStrategy))}n.is=e})(c_||(pe.ConnectionOptions=c_={}));var Vn;(function(n){n[n.New=1]="New",n[n.Listening=2]="Listening",n[n.Closed=3]="Closed",n[n.Disposed=4]="Disposed"})(Vn||(Vn={}));fun
Line truncated
|
||||
${JSON.stringify(C.error,void 0,4)}`):r.error("Received response message without id. No further error information provided.");else{let L=C.id,B=w.get(L);if(ti(C,B),B!==void 0){w.delete(L);try{if(C.error){let K=C.error;B.reject(new oe.ResponseError(K.code,K.message,K.data))}else if(C.result!==void 0)B.resolve(C.result);else throw new Error("Should never happen.")}catch(K){K.message?r.error(`Response handler '${B.method}' failed with message: ${K.message}`):r.error(`Response handler '${B.method}' failed unexpectedly.`)}}}}function Un(C){if(ut())return;let L,B;if(C.method===Po.type.method){let K=C.params.id;S.delete(K),Tn(C);return}else{let K=h.get(C.method);K&&(B=K.handler,L=K.type)}if(B||p)try{if(Tn(C),B)if(C.params===void 0)L!==void 0&&L.numberOfParams!==0&&L.parameterStructures!==oe.ParameterStructures.byName&&r.error(`Notification ${C.method} defines ${L.numberOfParams} params but received none.`),B();else if(Array.isArray(C.params)){let K=C.params;C.method===To.type.method&&K.length===2&&uf.is(K[0])?B({token:K[0],value:K[1]}):(L!==void 0&&(L.parameterStructures===oe.ParameterStructures.byName&&r.error(`Notification ${C.method} defines parameters by name but received parameters by position`),L.numberOfParams!==C.params.length&&r.error(`Notification ${C.method} defines ${L.numberOfParams} params but received ${K.length} arguments`)),B(...K))}else L!==void 0&&L.parameterStructures===oe.ParameterStructures.byPosition&&r.error(`Notification ${C.method} defines parameters by position but received parameters by name`),B(C.params);else p&&p(C.method,C.params)}catch(K){K.message?r.error(`Notification handler '${C.method}' failed with message: ${K.message}`):r.error(`Notification handler '${C.method}' failed unexpectedly.`)}else te.fire(C)}function ei(C){if(!C){r.error("Received empty message.");return}r.error(`Received message which is neither a response nor a notification message:
|
||||
${JSON.stringify(C,null,4)}`);let L=C;if(rt.string(L.id)||rt.number(L.id)){let B=L.id,K=w.get(B);K&&K.reject(new Error("The received response has neither a result nor an error property."))}}function yt(C){if(C!=null)switch(k){case qe.Verbose:return JSON.stringify(C,null,4);case qe.Compact:return JSON.stringify(C);default:return}}function mi(C){if(!(k===qe.Off||!j))if(N===vn.Text){let L;(k===qe.Verbose||k===qe.Compact)&&C.params&&(L=`Params: ${yt(C.params)}
|
||||
|
||||
`),j.log(`Sending request '${C.method} - (${C.id})'.`,L)}else vt("send-request",C)}function zn(C){if(!(k===qe.Off||!j))if(N===vn.Text){let L;(k===qe.Verbose||k===qe.Compact)&&(C.params?L=`Params: ${yt(C.params)}
|
||||
|
||||
`:L=`No parameters provided.
|
||||
|
||||
`),j.log(`Sending notification '${C.method}'.`,L)}else vt("send-notification",C)}function Dn(C,L,B){if(!(k===qe.Off||!j))if(N===vn.Text){let K;(k===qe.Verbose||k===qe.Compact)&&(C.error&&C.error.data?K=`Error data: ${yt(C.error.data)}
|
||||
|
||||
`:C.result?K=`Result: ${yt(C.result)}
|
||||
|
||||
`:C.error===void 0&&(K=`No result returned.
|
||||
|
||||
`)),j.log(`Sending response '${L} - (${C.id})'. Processing request took ${Date.now()-B}ms`,K)}else vt("send-response",C)}function Fi(C){if(!(k===qe.Off||!j))if(N===vn.Text){let L;(k===qe.Verbose||k===qe.Compact)&&C.params&&(L=`Params: ${yt(C.params)}
|
||||
|
||||
`),j.log(`Received request '${C.method} - (${C.id})'.`,L)}else vt("receive-request",C)}function Tn(C){if(!(k===qe.Off||!j||C.method===zc.type.method))if(N===vn.Text){let L;(k===qe.Verbose||k===qe.Compact)&&(C.params?L=`Params: ${yt(C.params)}
|
||||
|
||||
`:L=`No parameters provided.
|
||||
|
||||
`),j.log(`Received notification '${C.method}'.`,L)}else vt("receive-notification",C)}function ti(C,L){if(!(k===qe.Off||!j))if(N===vn.Text){let B;if((k===qe.Verbose||k===qe.Compact)&&(C.error&&C.error.data?B=`Error data: ${yt(C.error.data)}
|
||||
|
||||
`:C.result?B=`Result: ${yt(C.result)}
|
||||
|
||||
`:C.error===void 0&&(B=`No result returned.
|
||||
|
||||
`)),L){let K=C.error?` Request failed: ${C.error.message} (${C.error.code}).`:"";j.log(`Received response '${L.method} - (${C.id})' in ${Date.now()-L.timerStart}ms.${K}`,B)}else j.log(`Received response ${C.id} without active response promise.`,B)}else vt("receive-response",C)}function vt(C,L){if(!j||k===qe.Off)return;let B={isLSPMessage:!0,type:C,message:L,timestamp:Date.now()};j.log(B)}function Lt(){if(de())throw new gs(Eo.Closed,"Connection is closed.");if(ut())throw new gs(Eo.Disposed,"Connection is disposed.")}function Nt(){if(ie())throw new gs(Eo.AlreadyListening,"Connection is already listening")}function fn(){if(!ie())throw new Error("Call listen() first.")}function Zt(C){return C===void 0?null:C}function ni(C){if(C!==null)return C}function gi(C){return C!=null&&!Array.isArray(C)&&typeof C=="object"}function $n(C,L){switch(C){case oe.ParameterStructures.auto:return gi(L)?ni(L):[Zt(L)];case oe.ParameterStructures.byName:if(!gi(L))throw new Error("Received parameters by name but param is not an object literal.");return ni(L);case oe.ParameterStructures.byPosition:return[Zt(L)];default:throw new Error(`Unknown parameter structure ${C.toString()}`)}}function vi(C,L){let B,K=C.numberOfParams;switch(K){case 0:B=void 0;break;case 1:B=$n(C.parameterStructures,L[0]);break;default:B=[];for(let De=0;De<L.length&&De<K;De++)B.push(Zt(L[De]));if(L.length<K)for(let De=L.length;De<K;De++)B.push(null);break}return B}let Gt={sendNotification:(C,...L)=>{Lt();let B,K;if(rt.string(C)){B=C;let Se=L[0],Ae=0,Ue=oe.ParameterStructures.auto;oe.ParameterStructures.is(Se)&&(Ae=1,Ue=Se);let me=L.length,Pe=me-Ae;switch(Pe){case 0:K=void 0;break;case 1:K=$n(Ue,L[Ae]);break;default:if(Ue===oe.ParameterStructures.byName)throw new Error(`Received ${Pe} parameters for 'by Name' notification parameter structure.`);K=L.slice(Ae,me).map(ye=>Zt(ye));break}}else{let Se=L;B=C.method,K=vi(C,Se)}let De={jsonrpc:c,method:B,params:K};return zn(De),e.write(De).catch(Se=>{throw r.error("Sending notification failed."),Se})},onNotification:(C,L)=>{Lt();let B;return rt.func(C)?p=C:L&&(rt.string(C)?(B=C,h.set(C,{type:void 0,handler:L})):(B=C.method,h.set(C.method,{type:C,handler:L}))),{dispose:()=>{B!==void 0?h.delete(B):p=void 0}}},onProgress:(C,L,B)=>{if(x.has(L))throw new Error(`Progress handler for token ${L} already registered`);return x.set(L,B),{dispose:()=>{x.delete(L)}}},sendProgress:(C,L,B)=>Gt.sendNotification(To.type,{token:L,value:B}),onUnhandledProgress:Oe.event,sendRequest:(C,...L)=>{Lt(),fn();let B,K,De;if(rt.string(C)){B=C;let me=L[0],Pe=L[L.length-1],ye=0,ze=oe.ParameterStructures.auto;oe.ParameterStructures.is(me)&&(ye=1,ze=me);let lt=L.length;cf.CancellationToken.is(Pe)&&(lt=lt-1,De=Pe);let Dt=lt-ye;switch(Dt){case 0:K=void 0;break;case 1:K=$n(ze,L[ye]);break;default:if(ze===oe.ParameterStructures.byName)throw new Error(`Received ${Dt} parameters for 'by Name' request parameter structure.`);K=L.slice(ye,lt).map(Ni=>Zt(Ni));break}}else{let me=L;B=C.method,K=vi(C,me);let Pe=C.numberOfParams;De=cf.CancellationToken.is(me[Pe])?me[Pe]:void 0}let Se=s++,Ae;De&&(Ae=De.onCancellationRequested(()=>{let me=We.sender.sendCancellation(Gt,Se);return me===void 0?(r.log(`Received no promise from cancellation strategy when cancelling id ${Se}`),Promise.resolve()):me.catch(()=>{r.log(`Sending cancellation messages for id ${Se} failed`)})}));let Ue={jsonrpc:c,id:Se,method:B,params:K};return mi(Ue),typeof We.sender.enableCancellation=="function"&&We.sender.enableCancellation(Ue),new Promise(async(me,Pe)=>{let ye=Dt=>{me(Dt),We.sender.cleanup(Se),Ae?.dispose()},ze=Dt=>{Pe(Dt),We.sender.cleanup(Se),Ae?.dispose()},lt={method:B,timerStart:Date.now(),resolve:ye,reject:ze};try{await e.write(Ue),w.set(Se,lt)}catch(Dt){throw r.error("Sending request failed."),lt.reject(new oe.ResponseError(oe.ErrorCodes.MessageWriteError,Dt.message?Dt.message:"Unknown reason")),Dt}})},onRequest:(C,L)=>{Lt();let B=null;return df.is(C)?(B=void 0,u=C):rt.string(C)?(B=null,L!==void 0&&(B=C,l.set(C,{handler:L,type:void 0}))):L!==void 0&&(B=C.method,l.set(C.method,{type:C,handler:L})),{dispose:()=>{B!==null&&(B!==void 0?l.delete(B):u=void 0)}}},hasPendingResponse:()=>w.size>0,trace:async(C,L,B)=>{let K=!1,De=vn.Text;B!==void 0&&(rt.boolean(B)?K=B:(K=B.sendNotification||!1,De=B.traceFormat||vn.Text)),k=C,N=De,k===qe.Off?j=void 0:j=L,K&&!de()&&!ut()&&await Gt.sendNotification(pf.type,{value:qe.toString(C)})},onError:$.event,onClose:Q.event,onUnhandledNotification:te.event,onDispose:Ye.event,end:()=>{e.end()},dispose:()=>{if(ut())return;G=Vn.Disposed,Ye.fire(void 0);let C=new oe.ResponseError(oe.ErrorCodes.PendingResponseRejected,"Pending response rejected since connection got disposed");for(let L of w.values())L.reject(C);w=new Map,O=new Map,S=new Set,y=new o_.LinkedMap,rt.func(e.dispose)&&e.dispose(),rt.func(n.dispose)&&n.dispose()},listen:()=>{Lt(),Nt(),G=Vn.Listening,n.listen(Rn)},inspect:()=>{(0,s_.default)().console.log("inspect")}};return Gt.onNotification(zc.type,C=>{if(k=
Line truncated
|
||||
`,`\r
|
||||
`,"\r"];var Y;(function(v){function R(F,M,ce,Qe){return new ke(F,M,ce,Qe)}v.create=R;function D(F){var M=F;return!!(P.defined(M)&&P.string(M.uri)&&(P.undefined(M.languageId)||P.string(M.languageId))&&P.uinteger(M.lineCount)&&P.func(M.getText)&&P.func(M.positionAt)&&P.func(M.offsetAt))}v.is=D;function b(F,M){for(var ce=F.getText(),Qe=m(M,function(ii,d){var E=ii.range.start.line-d.range.start.line;return E===0?ii.range.start.character-d.range.start.character:E}),$e=ce.length,en=Qe.length-1;en>=0;en--){var hn=Qe[en],Hn=F.offsetAt(hn.range.start),xe=F.offsetAt(hn.range.end);if(xe<=$e)ce=ce.substring(0,Hn)+hn.newText+ce.substring(xe,ce.length);else throw new Error("Overlapping edit");$e=Hn}return ce}v.applyEdits=b;function m(F,M){if(F.length<=1)return F;var ce=F.length/2|0,Qe=F.slice(0,ce),$e=F.slice(ce);m(Qe,M),m($e,M);for(var en=0,hn=0,Hn=0;en<Qe.length&&hn<$e.length;){var xe=M(Qe[en],$e[hn]);xe<=0?F[Hn++]=Qe[en++]:F[Hn++]=$e[hn++]}for(;en<Qe.length;)F[Hn++]=Qe[en++];for(;hn<$e.length;)F[Hn++]=$e[hn++];return F}})(Y||(e.TextDocument=Y={}));var ke=function(){function v(R,D,b,m){this._uri=R,this._languageId=D,this._version=b,this._content=m,this._lineOffsets=void 0}return Object.defineProperty(v.prototype,"uri",{get:function(){return this._uri},enumerable:!1,configurable:!0}),Object.defineProperty(v.prototype,"languageId",{get:function(){return this._languageId},enumerable:!1,configurable:!0}),Object.defineProperty(v.prototype,"version",{get:function(){return this._version},enumerable:!1,configurable:!0}),v.prototype.getText=function(R){if(R){var D=this.offsetAt(R.start),b=this.offsetAt(R.end);return this._content.substring(D,b)}return this._content},v.prototype.update=function(R,D){this._content=R.text,this._version=D,this._lineOffsets=void 0},v.prototype.getLineOffsets=function(){if(this._lineOffsets===void 0){for(var R=[],D=this._content,b=!0,m=0;m<D.length;m++){b&&(R.push(m),b=!1);var F=D.charAt(m);b=F==="\r"||F===`
|
||||
`,F==="\r"&&m+1<D.length&&D.charAt(m+1)===`
|
||||
`&&m++}b&&D.length>0&&R.push(D.length),this._lineOffsets=R}return this._lineOffsets},v.prototype.positionAt=function(R){R=Math.max(Math.min(R,this._content.length),0);var D=this.getLineOffsets(),b=0,m=D.length;if(m===0)return o.create(0,R);for(;b<m;){var F=Math.floor((b+m)/2);D[F]>R?m=F:b=F+1}var M=b-1;return o.create(M,R-D[M])},v.prototype.offsetAt=function(R){var D=this.getLineOffsets();if(R.line>=D.length)return this._content.length;if(R.line<0)return 0;var b=D[R.line],m=R.line+1<D.length?D[R.line+1]:this._content.length;return Math.max(Math.min(b+R.character,m),b)},Object.defineProperty(v.prototype,"lineCount",{get:function(){return this.getLineOffsets().length},enumerable:!1,configurable:!0}),v}(),P;(function(v){var R=Object.prototype.toString;function D(xe){return typeof xe<"u"}v.defined=D;function b(xe){return typeof xe>"u"}v.undefined=b;function m(xe){return xe===!0||xe===!1}v.boolean=m;function F(xe){return R.call(xe)==="[object String]"}v.string=F;function M(xe){return R.call(xe)==="[object Number]"}v.number=M;function ce(xe,ii,d){return R.call(xe)==="[object Number]"&&ii<=xe&&xe<=d}v.numberRange=ce;function Qe(xe){return R.call(xe)==="[object Number]"&&-2147483648<=xe&&xe<=2147483647}v.integer=Qe;function $e(xe){return R.call(xe)==="[object Number]"&&0<=xe&&xe<=2147483647}v.uinteger=$e;function en(xe){return R.call(xe)==="[object Function]"}v.func=en;function hn(xe){return xe!==null&&typeof xe=="object"}v.objectLiteral=hn;function Hn(xe,ii){return Array.isArray(xe)&&xe.every(ii)}v.typedArray=Hn})(P||(P={}))})});var et=T(on=>{"use strict";Object.defineProperty(on,"__esModule",{value:!0});on.ProtocolNotificationType=on.ProtocolNotificationType0=on.ProtocolRequestType=on.ProtocolRequestType0=on.RegistrationType=on.MessageDirection=void 0;var xs=Tr(),b_;(function(n){n.clientToServer="clientToServer",n.serverToClient="serverToClient",n.both="both"})(b_||(on.MessageDirection=b_={}));var Tf=class{constructor(e){this.method=e}};on.RegistrationType=Tf;var Ef=class extends xs.RequestType0{constructor(e){super(e)}};on.ProtocolRequestType0=Ef;var Pf=class extends xs.RequestType{constructor(e){super(e,xs.ParameterStructures.byName)}};on.ProtocolRequestType=Pf;var kf=class extends xs.NotificationType0{constructor(e){super(e)}};on.ProtocolNotificationType0=kf;var Of=class extends xs.NotificationType{constructor(e){super(e,xs.ParameterStructures.byName)}};on.ProtocolNotificationType=Of});var eu=T(St=>{"use strict";Object.defineProperty(St,"__esModule",{value:!0});St.objectLiteral=St.typedArray=St.stringArray=St.array=St.func=St.error=St.number=St.string=St.boolean=void 0;function mN(n){return n===!0||n===!1}St.boolean=mN;function w_(n){return typeof n=="string"||n instanceof String}St.string=w_;function gN(n){return typeof n=="number"||n instanceof Number}St.number=gN;function vN(n){return n instanceof Error}St.error=vN;function xN(n){return typeof n=="function"}St.func=xN;function __(n){return Array.isArray(n)}St.array=__;function yN(n){return __(n)&&n.every(e=>w_(e))}St.stringArray=yN;function bN(n,e){return Array.isArray(n)&&n.every(e)}St.typedArray=bN;function wN(n){return n!==null&&typeof n=="object"}St.objectLiteral=wN});var R_=T(tu=>{"use strict";Object.defineProperty(tu,"__esModule",{value:!0});tu.ImplementationRequest=void 0;var S_=et(),C_;(function(n){n.method="textDocument/implementation",n.messageDirection=S_.MessageDirection.clientToServer,n.type=new S_.ProtocolRequestType(n.method)})(C_||(tu.ImplementationRequest=C_={}))});var E_=T(nu=>{"use strict";Object.defineProperty(nu,"__esModule",{value:!0});nu.TypeDefinitionRequest=void 0;var D_=et(),T_;(function(n){n.method="textDocument/typeDefinition",n.messageDirection=D_.MessageDirection.clientToServer,n.type=new D_.ProtocolRequestType(n.method)})(T_||(nu.TypeDefinitionRequest=T_={}))});var O_=T(ys=>{"use strict";Object.defineProperty(ys,"__esModule",{value:!0});ys.DidChangeWorkspaceFoldersNotification=ys.WorkspaceFoldersRequest=void 0;var iu=et(),P_;(function(n){n.method="workspace/workspaceFolders",n.messageDirection=iu.MessageDirection.serverToClient,n.type=new iu.ProtocolRequestType0(n.method)})(P_||(ys.WorkspaceFoldersRequest=P_={}));var k_;(function(n){n.method="workspace/didChangeWorkspaceFolders",n.messageDirection=iu.MessageDirection.clientToServer,n.type=new iu.ProtocolNotificationType(n.method)})(k_||(ys.DidChangeWorkspaceFoldersNotification=k_={}))});var N_=T(ru=>{"use strict";Object.defineProperty(ru,"__esModule",{value:!0});ru.ConfigurationRequest=void 0;var q_=et(),F_;(function(n){n.method="workspace/configuration",n.messageDirection=q_.MessageDirection.serverToClient,n.type=new q_.ProtocolRequestType(n.method)})(F_||(ru.ConfigurationRequest=F_={}))});var j_=T(bs=>{"use strict";Object.defineProperty(bs,"__esModule",{value:!0});bs.ColorPresentationRequest=bs.DocumentColorRequest=void 0;var su=et(),A_;(function(n){n.method="textDocument/documentColor",n.messageDirection=su.MessageDirection.clientToServer,n.type=new su.ProtocolRequestType(
Line truncated
|
||||
${JSON.stringify(Le,void 0,4)}`)},E)}else if(d.changes){let At=d.changes;await Ee.forEach(Object.keys(At),Le=>{Tt.set(r(Le),mt(At[Le]))},E)}return Tt}function C(d){if(d!==void 0)return{label:d.label,needsConfirmation:!!d.needsConfirmation,description:d.description}}function L(d){let E=f(d.range),U=d.target?s(d.target):void 0,Z=new aA.default(E,U);return d.tooltip!==void 0&&(Z.tooltip=d.tooltip),d.data!==void 0&&d.data!==null&&(Z.data=d.data),Z}async function B(d,E){if(d)return Ee.map(d,L,E)}function K(d){return new W.Color(d.red,d.green,d.blue,d.alpha)}function De(d){return new W.ColorInformation(f(d.range),K(d.color))}async function Se(d,E){if(d)return Ee.map(d,De,E)}function Ae(d){let E=new W.ColorPresentation(d.label);return E.additionalTextEdits=mt(d.additionalTextEdits),d.textEdit&&(E.textEdit=Ne(d.textEdit)),E}async function Ue(d,E){if(d)return Ee.map(d,Ae,E)}function me(d){if(d)switch(d){case ae.FoldingRangeKind.Comment:return W.FoldingRangeKind.Comment;case ae.FoldingRangeKind.Imports:return W.FoldingRangeKind.Imports;case ae.FoldingRangeKind.Region:return W.FoldingRangeKind.Region}}function Pe(d){return new W.FoldingRange(d.startLine,d.endLine,me(d.kind))}async function ye(d,E){if(d)return Ee.map(d,Pe,E)}function ze(d){return new W.SelectionRange(f(d.range),d.parent?ze(d.parent):void 0)}async function lt(d,E){return Array.isArray(d)?Ee.map(d,ze,E):[]}function Dt(d){return ae.InlineValueText.is(d)?new W.InlineValueText(f(d.range),d.text):ae.InlineValueVariableLookup.is(d)?new W.InlineValueVariableLookup(f(d.range),d.variableName,d.caseSensitiveLookup):new W.InlineValueEvaluatableExpression(f(d.range),d.expression)}async function Ni(d,E){return Array.isArray(d)?Ee.map(d,Dt,E):[]}async function Ai(d,E){let U=typeof d.label=="string"?d.label:await Ee.map(d.label,g,E),Z=new pA.default(x(d.position),U);return d.kind!==void 0&&(Z.kind=d.kind),d.textEdits!==void 0&&(Z.textEdits=await ct(d.textEdits,E)),d.tooltip!==void 0&&(Z.tooltip=A(d.tooltip)),d.paddingLeft!==void 0&&(Z.paddingLeft=d.paddingLeft),d.paddingRight!==void 0&&(Z.paddingRight=d.paddingRight),d.data!==void 0&&(Z.data=d.data),Z}function g(d){let E=new W.InlayHintLabelPart(d.value);return d.location!==void 0&&(E.location=Ke(d.location)),d.tooltip!==void 0&&(E.tooltip=A(d.tooltip)),d.command!==void 0&&(E.command=vt(d.command)),E}function A(d){return typeof d=="string"?d:k(d)}async function Y(d,E){if(Array.isArray(d))return Ee.mapAsync(d,Ai,E)}function ke(d){if(d===null)return;let E=new uA.default(yt(d.kind),d.name,d.detail||"",s(d.uri),f(d.range),f(d.selectionRange),d.data);return d.tags!==void 0&&(E.tags=zn(d.tags)),E}async function P(d,E){if(d!==null)return Ee.map(d,ke,E)}async function v(d,E){return new W.CallHierarchyIncomingCall(ke(d.from),await y(d.fromRanges,E))}async function R(d,E){if(d!==null)return Ee.mapAsync(d,v,E)}async function D(d,E){return new W.CallHierarchyOutgoingCall(ke(d.to),await y(d.fromRanges,E))}async function b(d,E){if(d!==null)return Ee.mapAsync(d,D,E)}async function m(d,E){if(d!=null)return new W.SemanticTokens(new Uint32Array(d.data),d.resultId)}function F(d){return new W.SemanticTokensEdit(d.start,d.deleteCount,d.data!==void 0?new Uint32Array(d.data):void 0)}async function M(d,E){if(d!=null)return new W.SemanticTokensEdits(d.edits.map(F),d.resultId)}function ce(d){return d}async function Qe(d,E){if(d!=null)return new W.LinkedEditingRanges(await y(d.ranges,E),$e(d.wordPattern))}function $e(d){if(d!=null)return new RegExp(d)}function en(d){if(d===null)return;let E=new lA.default(yt(d.kind),d.name,d.detail||"",s(d.uri),f(d.range),f(d.selectionRange),d.data);return d.tags!==void 0&&(E.tags=zn(d.tags)),E}async function hn(d,E){if(d!==null)return Ee.map(d,en,E)}function Hn(d){if(An.string(d))return d;if(ae.RelativePattern.is(d)){if(ae.URI.is(d.baseUri))return new W.RelativePattern(s(d.baseUri),d.pattern);if(ae.WorkspaceFolder.is(d.baseUri)){let E=W.workspace.getWorkspaceFolder(s(d.baseUri.uri));return E!==void 0?new W.RelativePattern(E,d.pattern):void 0}}}async function xe(d,E){if(!d)return;if(Array.isArray(d))return Ee.map(d,Tt=>ii(Tt),E);let U=d,Z=await Ee.map(U.items,Tt=>ii(Tt),E);return new W.InlineCompletionList(Z)}function ii(d){let E;typeof d.insertText=="string"?E=d.insertText:E=new W.SnippetString(d.insertText.value);let U;d.command&&(U=vt(d.command));let Z=new W.InlineCompletionItem(E,f(d.range),U);return d.filterText&&(Z.filterText=d.filterText),Z}return{asUri:s,asDocumentSelector:o,asDiagnostics:a,asDiagnostic:u,asRange:f,asRanges:y,asPosition:x,asDiagnosticSeverity:w,asDiagnosticTag:h,asHover:N,asCompletionResult:j,asCompletionItem:Oe,asTextEdit:Ne,asTextEdits:ct,asSignatureHelp:se,asSignatureInformations:ie,asSignatureInformation:de,asParameterInformations:ut,asParameterInformation:Re,asDeclarationResult:Sn,asDefinitionResult:gt,asLocation:Ke,asReferences:Rn,asDocumentHighlights:Ge,asDocumentHighlight:Mn,asDocumentHighlightKind:Un,asSymbolKind:yt,asSymbolTag:mi,asSymbolTags:zn,asSymbolInformations:ei,asSymb
Line truncated
|
||||
globstar while`,e,p,t,h,x),this.matchOne(e.slice(p),t.slice(h),i))return this.debug("globstar found match!",p,a,x),!0;if(x==="."||x===".."||!r.dot&&x.charAt(0)==="."){this.debug("dot detected!",e,p,t,h);break}this.debug("globstar swallow a segment, and continue"),p++}return!!(i&&(this.debug(`
|
||||
>>> no match, partial?`,e,p,t,h),p===a))}var f;if(typeof u=="string"?(f=l===u,this.debug("string match",u,l,f)):(f=l.match(u),this.debug("pattern match",u,l,f)),!f)return!1}if(s===a&&o===c)return!0;if(s===a)return i;if(o===c)return s===a-1&&e[s]==="";throw new Error("wtf?")}braceExpand(){return eR(this.pattern,this.options)}parse(e,t){Su(e);let i=this.options;if(e==="**")if(i.noglobstar)e="*";else return Jn;if(e==="")return"";let r="",s=!1,o=!1,a=[],c=[],u,l=!1,p=-1,h=-1,x,f,y,w=e.charAt(0)===".",S=i.dot||w,O=()=>w?"":S?"(?!(?:^|\\/)\\.{1,2}(?:$|\\/))":"(?!\\.)",k=$=>$.charAt(0)==="."?"":i.dot?"(?!(?:^|\\/)\\.{1,2}(?:$|\\/))":"(?!\\.)",N=()=>{if(u){switch(u){case"*":r+=Ph,s=!0;break;case"?":r+=qh,s=!0;break;default:r+="\\"+u;break}this.debug("clearStateChar %j %j",u,r),u=!1}};for(let $=0,Q;$<e.length&&(Q=e.charAt($));$++){if(this.debug("%s %s %s %j",e,$,r,Q),o){if(Q==="/")return!1;Y0[Q]&&(r+="\\"),r+=Q,o=!1;continue}switch(Q){case"/":return!1;case"\\":if(l&&e.charAt($+1)==="-"){r+=Q;continue}N(),o=!0;continue;case"?":case"*":case"+":case"@":case"!":if(this.debug("%s %s %s %j <-- stateChar",e,$,r,Q),l){this.debug(" in class"),Q==="!"&&$===h+1&&(Q="^"),r+=Q;continue}this.debug("call clearStateChar %j",u),N(),u=Q,i.noext&&N();continue;case"(":{if(l){r+="(";continue}if(!u){r+="\\(";continue}let te={type:u,start:$-1,reStart:r.length,open:J0[u].open,close:J0[u].close};this.debug(this.pattern," ",te),a.push(te),r+=te.open,te.start===0&&te.type!=="!"&&(w=!0,r+=k(e.slice($+1))),this.debug("plType %j %j",u,r),u=!1;continue}case")":{let te=a[a.length-1];if(l||!te){r+="\\)";continue}a.pop(),N(),s=!0,f=te,r+=f.close,f.type==="!"&&c.push(Object.assign(f,{reEnd:r.length}));continue}case"|":{let te=a[a.length-1];if(l||!te){r+="\\|";continue}N(),r+="|",te.start===0&&te.type!=="!"&&(w=!0,r+=k(e.slice($+1)));continue}case"[":if(N(),l){r+="\\"+Q;continue}l=!0,h=$,p=r.length,r+=Q;continue;case"]":if($===h+1||!l){r+="\\"+Q;continue}x=e.substring(h+1,$);try{RegExp("["+NA(qA(x))+"]"),r+=Q}catch{r=r.substring(0,p)+"(?:$.)"}s=!0,l=!1;continue;default:N(),Y0[Q]&&!(Q==="^"&&l)&&(r+="\\"),r+=Q;break}}for(l&&(x=e.slice(h+1),y=this.parse(x,kh),r=r.substring(0,p)+"\\["+y[0],s=s||y[1]),f=a.pop();f;f=a.pop()){let $;$=r.slice(f.reStart+f.open.length),this.debug("setting tail",r,f),$=$.replace(/((?:\\{2}){0,64})(\\?)\|/g,(te,Oe,Ye)=>(Ye||(Ye="\\"),Oe+Oe+Ye+"|")),this.debug(`tail=%j
|
||||
%s`,$,$,f,r);let Q=f.type==="*"?Ph:f.type==="?"?qh:"\\"+f.type;s=!0,r=r.slice(0,f.reStart)+Q+"\\("+$}N(),o&&(r+="\\\\");let j=PA[r.charAt(0)];for(let $=c.length-1;$>-1;$--){let Q=c[$],te=r.slice(0,Q.reStart),Oe=r.slice(Q.reStart,Q.reEnd-8),Ye=r.slice(Q.reEnd),We=r.slice(Q.reEnd-8,Q.reEnd)+Ye,Kt=te.split(")").length,Ne=te.split("(").length-Kt,ct=Ye;for(let se=0;se<Ne;se++)ct=ct.replace(/\)[+*?]?/,"");Ye=ct;let mt=Ye===""&&t!==kh?"(?:$|\\/)":"";r=te+Oe+Ye+mt+We}if(r!==""&&s&&(r="(?=.)"+r),j&&(r=O()+r),t===kh)return[r,s];if(i.nocase&&!s&&(s=e.toUpperCase()!==e.toLowerCase()),!s)return OA(e);let G=i.nocase?"i":"";try{return Object.assign(new RegExp("^"+r+"$",G),{_glob:e,_src:r})}catch{return new RegExp("$.")}}makeRe(){if(this.regexp||this.regexp===!1)return this.regexp;let e=this.set;if(!e.length)return this.regexp=!1,this.regexp;let t=this.options,i=t.noglobstar?Ph:t.dot?TA:EA,r=t.nocase?"i":"",s=e.map(o=>(o=o.map(a=>typeof a=="string"?FA(a):a===Jn?Jn:a._src).reduce((a,c)=>(a[a.length-1]===Jn&&c===Jn||a.push(c),a),[]),o.forEach((a,c)=>{a!==Jn||o[c-1]===Jn||(c===0?o.length>1?o[c+1]="(?:\\/|"+i+"\\/)?"+o[c+1]:o[c]=i:c===o.length-1?o[c-1]+="(?:\\/|"+i+")?":(o[c-1]+="(?:\\/|\\/"+i+"\\/)"+o[c+1],o[c+1]=Jn))}),o.filter(a=>a!==Jn).join("/"))).join("|");s="^(?:"+s+")$",this.negate&&(s="^(?!"+s+").*$");try{this.regexp=new RegExp(s,r)}catch{this.regexp=!1}return this.regexp}match(e,t=this.partial){if(this.debug("match",e,this.pattern),this.comment)return!1;if(this.empty)return e==="";if(e==="/"&&t)return!0;let i=this.options;Oh.sep!=="/"&&(e=e.split(Oh.sep).join("/")),e=e.split(Q0),this.debug(this.pattern,"split",e);let r=this.set;this.debug(this.pattern,"set",r);let s;for(let o=e.length-1;o>=0&&(s=e[o],!s);o--);for(let o=0;o<r.length;o++){let a=r[o],c=e;if(i.matchBase&&a.length===1&&(c=[s]),this.matchOne(c,a,t))return i.flipNegate?!0:!this.negate}return i.flipNegate?!1:this.negate}static defaults(e){return yn.defaults(e).Minimatch}};yn.Minimatch=ks});var zh=T(dr=>{"use strict";Object.defineProperty(dr,"__esModule",{value:!0});dr.DiagnosticFeature=dr.DiagnosticPullMode=dr.vsdiag=void 0;var AA=Cu(),be=require("vscode"),ht=ue(),IA=tt(),Nh=Ce();function Ru(n,e){return n[e]===void 0&&(n[e]={}),n[e]}var jn;(function(n){let e;(function(t){t.full="full",t.unChanged="unChanged"})(e=n.DocumentDiagnosticReportKind||(n.DocumentDiagnosticReportKind={}))})(jn||(dr.vsdiag=jn={}));var Du;(function(n){n.onType="onType",n.onSave="onSave"})(Du||(dr.DiagnosticPullMode=Du={}));var Bt;(function(n){n.active="open",n.reschedule="reschedule",n.outDated="drop"})(Bt||(Bt={}));var Ah=class n{constructor(){this.open=new Set,this._onOpen=new be.EventEmitter,this._onClose=new be.EventEmitter,n.fillTabResources(this.open);let e=t=>{if(t.closed.length===0&&t.opened.length===0)return;let i=this.open,r=new Set;n.fillTabResources(r);let s=new Set,o=new Set(r);for(let a of i.values())r.has(a)?o.delete(a):s.add(a);if(this.open=r,s.size>0){let a=new Set;for(let c of s)a.add(be.Uri.parse(c));this._onClose.fire(a)}if(o.size>0){let a=new Set;for(let c of o)a.add(be.Uri.parse(c));this._onOpen.fire(a)}};be.window.tabGroups.onDidChangeTabs!==void 0?this.disposable=be.window.tabGroups.onDidChangeTabs(e):this.disposable={dispose:()=>{}}}get onClose(){return this._onClose.event}get onOpen(){return this._onOpen.event}dispose(){this.disposable.dispose()}isActive(e){return e instanceof be.Uri?be.window.activeTextEditor?.document.uri===e:be.window.activeTextEditor?.document===e}isVisible(e){let t=e instanceof be.Uri?e:e.uri;return this.open.has(t.toString())}getTabResources(){let e=new Set;return n.fillTabResources(new Set,e),e}static fillTabResources(e,t){let i=e??new Set;for(let r of be.window.tabGroups.all)for(let s of r.tabs){let o=s.input,a;o instanceof be.TabInputText?a=o.uri:o instanceof be.TabInputTextDiff?a=o.modified:o instanceof be.TabInputCustom&&(a=o.uri),a!==void 0&&!i.has(a.toString())&&(i.add(a.toString()),t!==void 0&&t.add(a))}}},Rt;(function(n){n[n.document=1]="document",n[n.workspace=2]="workspace"})(Rt||(Rt={}));var Ti;(function(n){function e(t){return t instanceof be.Uri?t.toString():t.uri.toString()}n.asKey=e})(Ti||(Ti={}));var Ih=class{constructor(){this.documentPullStates=new Map,this.workspacePullStates=new Map}track(e,t,i){let r=e===Rt.document?this.documentPullStates:this.workspacePullStates,[s,o,a]=t instanceof be.Uri?[t.toString(),t,i]:[t.uri.toString(),t.uri,t.version],c=r.get(s);return c===void 0&&(c={document:o,pulledVersion:a,resultId:void 0},r.set(s,c)),c}update(e,t,i,r){let s=e===Rt.document?this.documentPullStates:this.workspacePullStates,[o,a,c,u]=t instanceof be.Uri?[t.toString(),t,i,r]:[t.uri.toString(),t.uri,t.version,i],l=s.get(o);l===void 0?(l={document:a,pulledVersion:c,resultId:u},s.set(o,l)):(l.pulledVersion=c,l.resultId=u)}unTrack(e,t){let i=Ti.asKey(t);(e===Rt.document?this.documentPullStates:this.workspacePullStates).delete(i)}tracks(e,t){let i=Ti.asKey(t);return(e===Rt.document?this.documentPullStates:this.workspacePu
Line truncated
|
||||
Code: ${t.code} ${t.data?`
|
||||
`+t.data.toString():""}`}return e instanceof Error?Zn.string(e.stack)?e.stack:e.message:Zn.string(e)?e:e.toString()}debug(e,t,i=!0){this.logOutputMessage(z.MessageType.Debug,jr.Debug,"Debug",e,t,i)}info(e,t,i=!0){this.logOutputMessage(z.MessageType.Info,jr.Info,"Info",e,t,i)}warn(e,t,i=!0){this.logOutputMessage(z.MessageType.Warning,jr.Warn,"Warn",e,t,i)}error(e,t,i=!0){this.logOutputMessage(z.MessageType.Error,jr.Error,"Error",e,t,i)}logOutputMessage(e,t,i,r,s,o){this.outputChannel.appendLine(`[${i.padEnd(5)} - ${new Date().toLocaleTimeString()}] ${r}`),s!=null&&this.outputChannel.appendLine(this.data2String(s)),(o==="force"||o&&this._clientOptions.revealOutputChannelOn<=t)&&this.showNotificationMessage(e,r)}showNotificationMessage(e,t){t=t??"A request has failed. See the output for more information.",(e===z.MessageType.Error?je.window.showErrorMessage:e===z.MessageType.Warning?je.window.showWarningMessage:je.window.showInformationMessage)(t,"Go to output").then(r=>{r!==void 0&&this.outputChannel.show(!0)})}logTrace(e,t){this.traceOutputChannel.appendLine(`[Trace - ${new Date().toLocaleTimeString()}] ${e}`),t&&this.traceOutputChannel.appendLine(this.data2String(t))}logObjectTrace(e){e.isLSPMessage&&e.type?this.traceOutputChannel.append(`[LSP - ${new Date().toLocaleTimeString()}] `):this.traceOutputChannel.append(`[Trace - ${new Date().toLocaleTimeString()}] `),e&&this.traceOutputChannel.appendLine(`${JSON.stringify(e)}`)}needsStart(){return this.$state===ve.Initial||this.$state===ve.Stopping||this.$state===ve.Stopped}needsStop(){return this.$state===ve.Starting||this.$state===ve.Running}activeConnection(){return this.$state===ve.Running&&this._connection!==void 0?this._connection:void 0}isRunning(){return this.$state===ve.Running}async start(){if(this._disposed==="disposing"||this._disposed==="disposed")throw new Error("Client got disposed and can't be restarted.");if(this.$state===ve.Stopping)throw new Error("Client is currently stopping. Can only restart a full stopped client");if(this._onStart!==void 0)return this._onStart;let[e,t,i]=this.createOnStartPromise();this._onStart=e,this._diagnostics===void 0&&(this._diagnostics=this._clientOptions.diagnosticCollectionName?je.languages.createDiagnosticCollection(this._clientOptions.diagnosticCollectionName):je.languages.createDiagnosticCollection());for(let[r,s]of this._notificationHandlers)this._pendingNotificationHandlers.has(r)||this._pendingNotificationHandlers.set(r,s);for(let[r,s]of this._requestHandlers)this._pendingRequestHandlers.has(r)||this._pendingRequestHandlers.set(r,s);for(let[r,s]of this._progressHandlers)this._pendingProgressHandlers.has(r)||this._pendingProgressHandlers.set(r,s);this.$state=ve.Starting;try{let r=await this.createConnection();r.onNotification(z.LogMessageNotification.type,s=>{switch(s.type){case z.MessageType.Error:this.error(s.message,void 0,!1);break;case z.MessageType.Warning:this.warn(s.message,void 0,!1);break;case z.MessageType.Info:this.info(s.message,void 0,!1);break;case z.MessageType.Debug:this.debug(s.message,void 0,!1);break;default:this.outputChannel.appendLine(s.message)}}),r.onNotification(z.ShowMessageNotification.type,s=>{switch(s.type){case z.MessageType.Error:je.window.showErrorMessage(s.message);break;case z.MessageType.Warning:je.window.showWarningMessage(s.message);break;case z.MessageType.Info:je.window.showInformationMessage(s.message);break;default:je.window.showInformationMessage(s.message)}}),r.onRequest(z.ShowMessageRequest.type,s=>{let o;switch(s.type){case z.MessageType.Error:o=je.window.showErrorMessage;break;case z.MessageType.Warning:o=je.window.showWarningMessage;break;case z.MessageType.Info:o=je.window.showInformationMessage;break;default:o=je.window.showInformationMessage}let a=s.actions||[];return o(s.message,...a)}),r.onNotification(z.TelemetryEventNotification.type,s=>{this._telemetryEmitter.fire(s)}),r.onRequest(z.ShowDocumentRequest.type,async s=>{let o=async c=>{let u=this.protocol2CodeConverter.asUri(c.uri);try{if(c.external===!0)return{success:await je.env.openExternal(u)};{let l={};return c.selection!==void 0&&(l.selection=this.protocol2CodeConverter.asRange(c.selection)),c.takeFocus===void 0||c.takeFocus===!1?l.preserveFocus=!0:c.takeFocus===!0&&(l.preserveFocus=!1),await je.window.showTextDocument(u,l),{success:!0}}}catch{return{success:!1}}},a=this._clientOptions.middleware.window?.showDocument;return a!==void 0?a(s,o):o(s)}),r.listen(),await this.initialize(r),t()}catch(r){this.$state=ve.StartFailed,this.error(`${this._name} client: couldn't create connection to server.`,r,"force"),i(r)}return this._onStart}createOnStartPromise(){let e,t;return[new Promise((r,s)=>{e=r,t=s}),e,t]}async initialize(e){this.refreshTrace(e,!1);let t=this._clientOptions.initializationOptions,[i,r]=this._clientOptions.workspaceFolder!==void 0?[this._clientOptions.workspaceFolder.uri.fsPath,[{uri:this._c2p.asUri(this._clientOptions.workspaceFolder.uri),name:this._clientOptions.workspaceFolder.name}Line truncated
|
||||
${e.message}
|
||||
Shutting down server.`,void 0,r.handled===!0?!1:"force"),this.stop().catch(s=>{this.error("Stopping server failed",s,!1)})):this.error(r.message??`Client ${this._name}: connection to server is erroring.
|
||||
${e.message}`,void 0,r.handled===!0?!1:"force")}hookConfigurationChanged(e){this._listeners.push(je.workspace.onDidChangeConfiguration(()=>{this.refreshTrace(e,!0)}))}refreshTrace(e,t=!1){let i=je.workspace.getConfiguration(this._id),r=z.Trace.Off,s=z.TraceFormat.Text;if(i){let o=i.get("trace.server","off");typeof o=="string"?r=z.Trace.fromString(o):(r=z.Trace.fromString(i.get("trace.server.verbosity","off")),s=z.TraceFormat.fromString(i.get("trace.server.format","text")))}this._trace=r,this._traceFormat=s,e.trace(this._trace,this._tracer,{sendNotification:t,traceFormat:this._traceFormat}).catch(o=>{this.error("Updating trace failed with error",o,!1)})}hookFileEvents(e){let t=this._clientOptions.synchronize.fileEvents;if(!t)return;let i;Zn.array(t)?i=t:i=[t],i&&this._dynamicFeatures.get(z.DidChangeWatchedFilesNotification.type.method).registerRaw(VR.generateUuid(),i)}registerFeatures(e){for(let t of e)this.registerFeature(t)}registerFeature(e){if(this._features.push(e),Qn.DynamicFeature.is(e)){let t=e.registrationType;this._dynamicFeatures.set(t.method,e)}}getFeature(e){return this._dynamicFeatures.get(e)}hasDedicatedTextSynchronizationFeature(e){let t=this.getFeature(z.NotebookDocumentSyncRegistrationType.method);return t===void 0||!(t instanceof XR.NotebookDocumentSyncFeature)?!1:t.handles(e)}registerBuiltinFeatures(){let e=new Map;this.registerFeature(new JR.ConfigurationFeature(this)),this.registerFeature(new Ms.DidOpenTextDocumentFeature(this,this._syncedDocuments)),this._didChangeTextDocumentFeature=new Ms.DidChangeTextDocumentFeature(this,e),this._didChangeTextDocumentFeature.onPendingChangeAdded(()=>{this.triggerPendingChangeDelivery()}),this.registerFeature(this._didChangeTextDocumentFeature),this.registerFeature(new Ms.WillSaveFeature(this)),this.registerFeature(new Ms.WillSaveWaitUntilFeature(this)),this.registerFeature(new Ms.DidSaveTextDocumentFeature(this)),this.registerFeature(new Ms.DidCloseTextDocumentFeature(this,this._syncedDocuments,e)),this.registerFeature(new GI.FileSystemWatcherFeature(this,t=>this.notifyFileEvent(t))),this.registerFeature(new NI.CompletionItemFeature(this)),this.registerFeature(new AI.HoverFeature(this)),this.registerFeature(new jI.SignatureHelpFeature(this)),this.registerFeature(new II.DefinitionFeature(this)),this.registerFeature(new zI.ReferencesFeature(this)),this.registerFeature(new LI.DocumentHighlightFeature(this)),this.registerFeature(new MI.DocumentSymbolFeature(this)),this.registerFeature(new UI.WorkspaceSymbolFeature(this)),this.registerFeature(new $I.CodeActionFeature(this)),this.registerFeature(new HI.CodeLensFeature(this)),this.registerFeature(new vg.DocumentFormattingFeature(this)),this.registerFeature(new vg.DocumentRangeFormattingFeature(this)),this.registerFeature(new vg.DocumentOnTypeFormattingFeature(this)),this.registerFeature(new BI.RenameFeature(this)),this.registerFeature(new WI.DocumentLinkFeature(this)),this.registerFeature(new KI.ExecuteCommandFeature(this)),this.registerFeature(new JR.SyncConfigurationFeature(this)),this.registerFeature(new JI.TypeDefinitionFeature(this)),this.registerFeature(new XI.ImplementationFeature(this)),this.registerFeature(new VI.ColorProviderFeature(this)),this.clientOptions.workspaceFolder===void 0&&this.registerFeature(new YI.WorkspaceFoldersFeature(this)),this.registerFeature(new QI.FoldingRangeFeature(this)),this.registerFeature(new ZI.DeclarationFeature(this)),this.registerFeature(new ej.SelectionRangeFeature(this)),this.registerFeature(new tj.ProgressFeature(this)),this.registerFeature(new nj.CallHierarchyFeature(this)),this.registerFeature(new ij.SemanticTokensFeature(this)),this.registerFeature(new rj.LinkedEditingFeature(this)),this.registerFeature(new Us.DidCreateFilesFeature(this)),this.registerFeature(new Us.DidRenameFilesFeature(this)),this.registerFeature(new Us.DidDeleteFilesFeature(this)),this.registerFeature(new Us.WillCreateFilesFeature(this)),this.registerFeature(new Us.WillRenameFilesFeature(this)),this.registerFeature(new Us.WillDeleteFilesFeature(this)),this.registerFeature(new sj.TypeHierarchyFeature(this)),this.registerFeature(new oj.InlineValueFeature(this)),this.registerFeature(new aj.InlayHintsFeature(this)),this.registerFeature(new FI.DiagnosticFeature(this)),this.registerFeature(new XR.NotebookDocumentSyncFeature(this))}registerProposedFeatures(){this.registerFeatures(wg.createAll(this))}fillInitializeParams(e){for(let t of this._features)Zn.func(t.fillInitializeParams)&&t.fillInitializeParams(e)}computeClientCapabilities(){let e={};(0,Qn.ensure)(e,"workspace").applyEdit=!0;let t=(0,Qn.ensure)((0,Qn.ensure)(e,"workspace"),"workspaceEdit");t.documentChanges=!0,t.resourceOperations=[z.ResourceOperationKind.Create,z.ResourceOperationKind.Rename,z.ResourceOperationKind.Delete],t.failureHandling=z.FailureHandlingKind.TextOnlyTransactional,t.normalizesLineEndings=!0,t.changeAnnotationSupport={groupsOnLabel:!0};let i=(0,Qn.ensure)((0,Qn.ensure)(e,"textDocument"),"publishDiagnostics");i.rela
Line truncated
|
||||
/*! Bundled license information:
|
||||
|
||||
mime-db/index.js:
|
||||
(*!
|
||||
* mime-db
|
||||
* Copyright(c) 2014 Jonathan Ong
|
||||
* Copyright(c) 2015-2022 Douglas Christopher Wilson
|
||||
* MIT Licensed
|
||||
*)
|
||||
|
||||
mime-types/index.js:
|
||||
(*!
|
||||
* mime-types
|
||||
* Copyright(c) 2014 Jonathan Ong
|
||||
* Copyright(c) 2015 Douglas Christopher Wilson
|
||||
* MIT Licensed
|
||||
*)
|
||||
*/
|
||||
Generated
Vendored
BIN
Binary file not shown.
@@ -0,0 +1,48 @@
|
||||
{
|
||||
"comments": {
|
||||
// symbol used for single line comment. Remove this entry if your language does not support line comments
|
||||
"lineComment": "//",
|
||||
// symbols used for start and end a block comment. Remove this entry if your language does not support block comments
|
||||
"blockComment": [
|
||||
"/*",
|
||||
"*/"
|
||||
]
|
||||
},
|
||||
// symbols used as brackets
|
||||
"brackets": [
|
||||
[
|
||||
"{",
|
||||
"}"
|
||||
],
|
||||
],
|
||||
// symbols that are auto closed when typing
|
||||
"autoClosingPairs": [
|
||||
[
|
||||
"{",
|
||||
"}"
|
||||
],
|
||||
[
|
||||
"\"",
|
||||
"\""
|
||||
],
|
||||
[
|
||||
"(",
|
||||
")"
|
||||
]
|
||||
],
|
||||
// symbols that can be used to surround a selection
|
||||
"surroundingPairs": [
|
||||
[
|
||||
"{",
|
||||
"}"
|
||||
],
|
||||
[
|
||||
"\"",
|
||||
"\""
|
||||
],
|
||||
[
|
||||
"(",
|
||||
")"
|
||||
]
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,114 @@
|
||||
{
|
||||
"name": "kdl",
|
||||
"displayName": "KDL",
|
||||
"description": "Language support for the KDL Document Language. This extension supports only KDL v2.0.0. Use `kdl-v1` for legacy KDL highlighting.",
|
||||
"version": "2.1.3",
|
||||
"license": "Apache-2.0",
|
||||
"publisher": "kdl-org",
|
||||
"repository": "https://github.com/kdl-org/vscode-kdl.git",
|
||||
"main": "./dist/extension.js",
|
||||
"scripts": {
|
||||
"pack": "vsce package",
|
||||
"compile": "npm run check-types && node esbuild.js",
|
||||
"check-types": "tsc --noEmit",
|
||||
"watch": "npm-run-all -p watch:*",
|
||||
"watch:esbuild": "node esbuild.js --watch",
|
||||
"watch:tsc": "tsc --noEmit --watch --project tsconfig.json",
|
||||
"vscode:prepublish": "npm run package",
|
||||
"package": "npm run check-types && node esbuild.js --production",
|
||||
"publish": "vsce publish"
|
||||
},
|
||||
"engines": {
|
||||
"vscode": "^1.96.0"
|
||||
},
|
||||
"categories": [
|
||||
"Programming Languages"
|
||||
],
|
||||
"activationEvents": [
|
||||
"onStartupFinished"
|
||||
],
|
||||
"icon": "KDL_Logo_Only_128x128.png",
|
||||
"contributes": {
|
||||
"languages": [
|
||||
{
|
||||
"id": "kdl",
|
||||
"aliases": [
|
||||
"KDL",
|
||||
"kdl"
|
||||
],
|
||||
"extensions": [
|
||||
".kdl"
|
||||
],
|
||||
"configuration": "./language-configuration.json"
|
||||
}
|
||||
],
|
||||
"grammars": [
|
||||
{
|
||||
"language": "kdl",
|
||||
"scopeName": "source.kdl",
|
||||
"path": "./syntaxes/kdl.tmLanguage.json"
|
||||
}
|
||||
],
|
||||
"configuration": {
|
||||
"type": "object",
|
||||
"title": "KDL",
|
||||
"properties": {
|
||||
"kdl.enable": {
|
||||
"scope": "resource",
|
||||
"type": "boolean",
|
||||
"default": true,
|
||||
"description": "Enable/disable the KDL language server"
|
||||
},
|
||||
"kdl.command": {
|
||||
"scope": "resource",
|
||||
"type": "string",
|
||||
"description": "LSP server command (defaults to bundled server)"
|
||||
},
|
||||
"kdl.argv": {
|
||||
"scope": "resource",
|
||||
"type": "array",
|
||||
"default": [],
|
||||
"items": {
|
||||
"type": "string"
|
||||
},
|
||||
"description": "LSP server arguments"
|
||||
},
|
||||
"kdl.loglevel": {
|
||||
"scope": "resource",
|
||||
"description": "Log level for the KDL LSP server",
|
||||
"type": "string",
|
||||
"default": "info",
|
||||
"enum": [
|
||||
"off",
|
||||
"error",
|
||||
"warn",
|
||||
"info",
|
||||
"debug"
|
||||
],
|
||||
"enumDescriptions": [
|
||||
"No server tracing",
|
||||
"Errors only",
|
||||
"Warnings and errors",
|
||||
"Information, warnings, and errors",
|
||||
"Full debug output"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^22.10.5",
|
||||
"@types/vscode": "^1.96.0",
|
||||
"axios-proxy-builder": "^0.1.2",
|
||||
"esbuild": "^0.24.2",
|
||||
"kdl-lsp": "^6.3.2",
|
||||
"npm-run-all": "^4.1.5",
|
||||
"vsce": "^1.99.0",
|
||||
"vscode-languageclient": "^9.0.1"
|
||||
},
|
||||
"__metadata": {
|
||||
"installedTimestamp": 1783821237752,
|
||||
"targetPlatform": "undefined",
|
||||
"size": 822494
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,227 @@
|
||||
{
|
||||
"$schema": "https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json",
|
||||
"comment": "Some of these patterns are taken straight from rust-analyzer: https://github.com/rust-lang/vscode-rust/blob/master/rust-analyzer/editors/code/rust.tmGrammar.json. Some was also taken from https://github.com/arm32x/vscode-sdlang/blob/master/syntaxes/sdlang.tmLanguage.json",
|
||||
"name": "kdl",
|
||||
"patterns": [
|
||||
{
|
||||
"include": "#forbidden_ident"
|
||||
},
|
||||
{
|
||||
"include": "#null"
|
||||
},
|
||||
{
|
||||
"include": "#boolean"
|
||||
},
|
||||
{
|
||||
"include": "#float_keyword"
|
||||
},
|
||||
{
|
||||
"include": "#float_fraction"
|
||||
},
|
||||
{
|
||||
"include": "#float_exp"
|
||||
},
|
||||
{
|
||||
"include": "#decimal"
|
||||
},
|
||||
{
|
||||
"include": "#hexadecimal"
|
||||
},
|
||||
{
|
||||
"include": "#octal"
|
||||
},
|
||||
{
|
||||
"include": "#binary"
|
||||
},
|
||||
{
|
||||
"include": "#raw-string"
|
||||
},
|
||||
{
|
||||
"include": "#string_multi_line"
|
||||
},
|
||||
{
|
||||
"include": "#string_single_line"
|
||||
},
|
||||
{
|
||||
"include": "#block_comment"
|
||||
},
|
||||
{
|
||||
"include": "#block_doc_comment"
|
||||
},
|
||||
{
|
||||
"include": "#slashdash_block_comment"
|
||||
},
|
||||
{
|
||||
"include": "#slashdash_comment"
|
||||
},
|
||||
{
|
||||
"include": "#slashdash_node_comment"
|
||||
},
|
||||
{
|
||||
"include": "#slashdash_node_with_children_comment"
|
||||
},
|
||||
{
|
||||
"include": "#line_comment"
|
||||
},
|
||||
{
|
||||
"include": "#attribute"
|
||||
},
|
||||
{
|
||||
"include": "#node_name"
|
||||
},
|
||||
{
|
||||
"include": "#ident_string"
|
||||
}
|
||||
],
|
||||
"repository": {
|
||||
"float_fraction": {
|
||||
"comment": "Floating point literal (fraction)",
|
||||
"name": "constant.numeric.float.rust",
|
||||
"match": "\\b([0-9\\-\\+]|\\-|\\+)[0-9_]*\\.[0-9][0-9_]*([eE][+-]?[0-9_]+)?\\b"
|
||||
},
|
||||
"float_exp": {
|
||||
"comment": "Floating point literal (exponent)",
|
||||
"name": "constant.numeric.float.rust",
|
||||
"match": "\\b[0-9][0-9_]*(\\.[0-9][0-9_]*)?[eE][+-]?[0-9_]+\\b"
|
||||
},
|
||||
"decimal": {
|
||||
"comment": "Integer literal (decimal)",
|
||||
"name": "constant.numeric.integer.decimal.rust",
|
||||
"match": "\\b[0-9\\-\\+][0-9_]*\\b"
|
||||
},
|
||||
"hexadecimal": {
|
||||
"comment": "Integer literal (hexadecimal)",
|
||||
"name": "constant.numeric.integer.hexadecimal.rust",
|
||||
"match": "\\b0x[a-fA-F0-9][a-fA-F0-9_]*\\b"
|
||||
},
|
||||
"octal": {
|
||||
"comment": "Integer literal (octal)",
|
||||
"name": "constant.numeric.integer.octal.rust",
|
||||
"match": "\\b0o[0-7][0-7_]*\\b"
|
||||
},
|
||||
"binary": {
|
||||
"comment": "Integer literal (binary)",
|
||||
"name": "constant.numeric.integer.binary.rust",
|
||||
"match": "\\b0b[01][01_]*\\b"
|
||||
},
|
||||
"forbidden_ident": {
|
||||
"name": "invalid.illegal.kdl.bad-ident",
|
||||
"match": "(?<!#)(?:true|false|null|nan|[-]?inf)"
|
||||
},
|
||||
"node_name": {
|
||||
"name": "entity.name.tag",
|
||||
"match": "((?<={|;)|^)\\s*(?![/\\\\{\\}#;\\[\\]\\=])[<>:\\w\\-_~,'`!\\?@\\$%^&*+|.\\(\\)]+\\d*[<>:\\w\\-_~,'`!\\?@\\$%^&*+|.\\(\\)]*"
|
||||
},
|
||||
"attribute": {
|
||||
"name": "entity.other.attribute-name.kdl",
|
||||
"match": "(?![/\\\\{\\}#;\\[\\]\\=])[<>:\\w\\-_~,'`!\\?@\\$%^&*+|.\\(\\)]+\\d*[<>:\\w\\-_~,'`!\\?@\\$%^&*+|.\\(\\)]*(=)",
|
||||
"captures": {
|
||||
"1": {
|
||||
"name": "punctuation.separator.key-value.kdl"
|
||||
}
|
||||
}
|
||||
},
|
||||
"ident_string": {
|
||||
"name": "string.unquoted",
|
||||
"match": "(?![/\\\\{\\}#;\\[\\]\\=])[<>:\\w\\-_~,'`!\\?@\\$%^&*+|.\\(\\)]+\\d*[<>:\\w\\-_~,'`!\\?@\\$%^&*+|.\\(\\)]*"
|
||||
},
|
||||
"float_keyword": {
|
||||
"name": "constant.language.other.kdl",
|
||||
"match": "#nan|#inf|#-inf"
|
||||
},
|
||||
"null": {
|
||||
"name": "constant.language.null.kdl",
|
||||
"match": "#null"
|
||||
},
|
||||
"boolean": {
|
||||
"name": "constant.language.boolean.kdl",
|
||||
"match": "#true|#false"
|
||||
},
|
||||
"string_single_line": {
|
||||
"name": "string.quoted.double.kdl",
|
||||
"begin": "\"",
|
||||
"end": "\"",
|
||||
"patterns": [
|
||||
{
|
||||
"name": "constant.character.escape.kdl",
|
||||
"match": "\\\\(:?[nrtbfs\\\\\"]|u\\{[a-fA-F0-9]{1,6}\\})"
|
||||
}
|
||||
]
|
||||
},
|
||||
"string_multi_line": {
|
||||
"name": "string.quoted.triple.kdl",
|
||||
"begin": "\"\"\"",
|
||||
"end": "\"\"\"",
|
||||
"patterns": [
|
||||
{
|
||||
"name": "constant.character.escape.kdl",
|
||||
"match": "\\\\(:?[nrtbfs\\\\\"]|u\\{[a-fA-F0-9]{1,6}\\})"
|
||||
}
|
||||
]
|
||||
},
|
||||
"raw-string": {
|
||||
"name": "string.quoted.other.raw.kdl",
|
||||
"begin": "(#+)(\"\"\"|\")",
|
||||
"end": "\\2\\1"
|
||||
},
|
||||
"block_doc_comment": {
|
||||
"comment": "Block documentation comment",
|
||||
"name": "comment.block.documentation.kdl",
|
||||
"begin": "/\\*[\\*!](?![\\*/])",
|
||||
"end": "\\*/",
|
||||
"patterns": [
|
||||
{
|
||||
"include": "#block_doc_comment"
|
||||
},
|
||||
{
|
||||
"include": "#block_comment"
|
||||
}
|
||||
]
|
||||
},
|
||||
"block_comment": {
|
||||
"comment": "Block comment",
|
||||
"name": "comment.block.kdl",
|
||||
"begin": "/\\*",
|
||||
"end": "\\*/",
|
||||
"patterns": [
|
||||
{
|
||||
"include": "#block_doc_comment"
|
||||
},
|
||||
{
|
||||
"include": "#block_comment"
|
||||
}
|
||||
]
|
||||
},
|
||||
"line_comment": {
|
||||
"comment": "Single-line comment",
|
||||
"name": "comment.line.double-slash.kdl",
|
||||
"begin": "//",
|
||||
"end": "$"
|
||||
},
|
||||
"slashdash_comment": {
|
||||
"name": "comment.block.slashdash.kdl",
|
||||
"comment": "Slashdash inline comment",
|
||||
"begin": "(?<!^)\\s*/-\\s*",
|
||||
"end": "\\s"
|
||||
},
|
||||
"slashdash_node_comment": {
|
||||
"name": "comment.block.slashdash.kdl",
|
||||
"comment": "Slashdash node comment",
|
||||
"begin": "(?<=^)\\s*/-[^{]+$",
|
||||
"end": "(?:;|(?<!\\\\)$)"
|
||||
},
|
||||
"slashdash_node_with_children_comment": {
|
||||
"name": "comment.block.slashdash.kdl",
|
||||
"comment": "Slashdash node comment",
|
||||
"begin": "(?<=^)\\s*/-[^{]+{",
|
||||
"end": "\\}"
|
||||
},
|
||||
"slashdash_block_comment": {
|
||||
"name": "comment.block.slashdash.kdl",
|
||||
"comment": "Slashdash block comment",
|
||||
"begin": "/-\\s*{",
|
||||
"end": "\\}"
|
||||
}
|
||||
},
|
||||
"scopeName": "source.kdl"
|
||||
}
|
||||
Reference in new issue
Block a user