bc-minecraft-bedrock-shared 1.0.1-0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/conditional/index.d.ts +2 -0
- package/dist/conditional/index.d.ts.map +1 -0
- package/dist/conditional/index.js +18 -0
- package/dist/conditional/index.js.map +1 -0
- package/dist/conditional/types.d.ts +32 -0
- package/dist/conditional/types.d.ts.map +1 -0
- package/dist/conditional/types.js +55 -0
- package/dist/conditional/types.js.map +1 -0
- package/dist/conditional/types.test.d.ts +2 -0
- package/dist/conditional/types.test.d.ts.map +1 -0
- package/dist/conditional/types.test.js +40 -0
- package/dist/conditional/types.test.js.map +1 -0
- package/dist/definition/index.d.ts +2 -0
- package/dist/definition/index.d.ts.map +1 -0
- package/dist/definition/index.js +18 -0
- package/dist/definition/index.js.map +1 -0
- package/dist/definition/types.d.ts +43 -0
- package/dist/definition/types.d.ts.map +1 -0
- package/dist/definition/types.js +73 -0
- package/dist/definition/types.js.map +1 -0
- package/dist/definition/types.test.d.ts +2 -0
- package/dist/definition/types.test.d.ts.map +1 -0
- package/dist/definition/types.test.js +64 -0
- package/dist/definition/types.test.js.map +1 -0
- package/dist/document-location/index.d.ts +2 -0
- package/dist/document-location/index.d.ts.map +1 -0
- package/dist/document-location/index.js +18 -0
- package/dist/document-location/index.js.map +1 -0
- package/dist/document-location/types.d.ts +54 -0
- package/dist/document-location/types.d.ts.map +1 -0
- package/dist/document-location/types.js +93 -0
- package/dist/document-location/types.js.map +1 -0
- package/dist/document-location/types.test.d.ts +2 -0
- package/dist/document-location/types.test.d.ts.map +1 -0
- package/dist/document-location/types.test.js +112 -0
- package/dist/document-location/types.test.js.map +1 -0
- package/dist/documentated/index.d.ts +2 -0
- package/dist/documentated/index.d.ts.map +1 -0
- package/dist/documentated/index.js +18 -0
- package/dist/documentated/index.js.map +1 -0
- package/dist/documentated/types.d.ts +17 -0
- package/dist/documentated/types.d.ts.map +1 -0
- package/dist/documentated/types.js +30 -0
- package/dist/documentated/types.js.map +1 -0
- package/dist/glob/glob.d.ts +47 -0
- package/dist/glob/glob.d.ts.map +1 -0
- package/dist/glob/glob.js +96 -0
- package/dist/glob/glob.js.map +1 -0
- package/dist/glob/glob.test.d.ts +2 -0
- package/dist/glob/glob.test.d.ts.map +1 -0
- package/dist/glob/glob.test.js +74 -0
- package/dist/glob/glob.test.js.map +1 -0
- package/dist/glob/index.d.ts +2 -0
- package/dist/glob/index.d.ts.map +1 -0
- package/dist/glob/index.js +18 -0
- package/dist/glob/index.js.map +1 -0
- package/dist/identifiable/index.d.ts +2 -0
- package/dist/identifiable/index.d.ts.map +1 -0
- package/dist/identifiable/index.js +18 -0
- package/dist/identifiable/index.js.map +1 -0
- package/dist/identifiable/types.d.ts +34 -0
- package/dist/identifiable/types.d.ts.map +1 -0
- package/dist/identifiable/types.js +42 -0
- package/dist/identifiable/types.js.map +1 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +32 -0
- package/dist/index.js.map +1 -0
- package/dist/json-path/index.d.ts +2 -0
- package/dist/json-path/index.d.ts.map +1 -0
- package/dist/json-path/index.js +18 -0
- package/dist/json-path/index.js.map +1 -0
- package/dist/json-path/types.d.ts +35 -0
- package/dist/json-path/types.d.ts.map +1 -0
- package/dist/json-path/types.js +53 -0
- package/dist/json-path/types.js.map +1 -0
- package/dist/json-path/types.test.d.ts +2 -0
- package/dist/json-path/types.test.d.ts.map +1 -0
- package/dist/json-path/types.test.js +62 -0
- package/dist/json-path/types.test.js.map +1 -0
- package/dist/jsonc/index.d.ts +2 -0
- package/dist/jsonc/index.d.ts.map +1 -0
- package/dist/jsonc/index.js +18 -0
- package/dist/jsonc/index.js.map +1 -0
- package/dist/jsonc/jsonc.d.ts +35 -0
- package/dist/jsonc/jsonc.d.ts.map +1 -0
- package/dist/jsonc/jsonc.js +59 -0
- package/dist/jsonc/jsonc.js.map +1 -0
- package/dist/jsonc/jsonc.test.d.ts +2 -0
- package/dist/jsonc/jsonc.test.d.ts.map +1 -0
- package/dist/jsonc/jsonc.test.js +131 -0
- package/dist/jsonc/jsonc.test.js.map +1 -0
- package/dist/locatable/index.d.ts +2 -0
- package/dist/locatable/index.d.ts.map +1 -0
- package/dist/locatable/index.js +18 -0
- package/dist/locatable/index.js.map +1 -0
- package/dist/locatable/types.d.ts +23 -0
- package/dist/locatable/types.d.ts.map +1 -0
- package/dist/locatable/types.js +33 -0
- package/dist/locatable/types.js.map +1 -0
- package/dist/location/index.d.ts +2 -0
- package/dist/location/index.d.ts.map +1 -0
- package/dist/location/index.js +18 -0
- package/dist/location/index.js.map +1 -0
- package/dist/location/types.d.ts +32 -0
- package/dist/location/types.d.ts.map +1 -0
- package/dist/location/types.js +41 -0
- package/dist/location/types.js.map +1 -0
- package/dist/objects/index.d.ts +19 -0
- package/dist/objects/index.d.ts.map +1 -0
- package/dist/objects/index.js +36 -0
- package/dist/objects/index.js.map +1 -0
- package/dist/objects/index.test.d.ts +2 -0
- package/dist/objects/index.test.d.ts.map +1 -0
- package/dist/objects/index.test.js +67 -0
- package/dist/objects/index.test.js.map +1 -0
- package/dist/offset-word/index.d.ts +2 -0
- package/dist/offset-word/index.d.ts.map +1 -0
- package/dist/offset-word/index.js +18 -0
- package/dist/offset-word/index.js.map +1 -0
- package/dist/offset-word/types.d.ts +29 -0
- package/dist/offset-word/types.d.ts.map +1 -0
- package/dist/offset-word/types.js +32 -0
- package/dist/offset-word/types.js.map +1 -0
- package/dist/offset-word/types.test.d.ts +2 -0
- package/dist/offset-word/types.test.d.ts.map +1 -0
- package/dist/offset-word/types.test.js +38 -0
- package/dist/offset-word/types.test.js.map +1 -0
- package/dist/position/index.d.ts +2 -0
- package/dist/position/index.d.ts.map +1 -0
- package/dist/position/index.js +18 -0
- package/dist/position/index.js.map +1 -0
- package/dist/position/types.d.ts +47 -0
- package/dist/position/types.d.ts.map +1 -0
- package/dist/position/types.js +81 -0
- package/dist/position/types.js.map +1 -0
- package/dist/position/types.test.d.ts +2 -0
- package/dist/position/types.test.d.ts.map +1 -0
- package/dist/position/types.test.js +82 -0
- package/dist/position/types.test.js.map +1 -0
- package/dist/range/index.d.ts +2 -0
- package/dist/range/index.d.ts.map +1 -0
- package/dist/range/index.js +18 -0
- package/dist/range/index.js.map +1 -0
- package/dist/range/types.d.ts +39 -0
- package/dist/range/types.d.ts.map +1 -0
- package/dist/range/types.js +44 -0
- package/dist/range/types.js.map +1 -0
- package/dist/range/types.test.d.ts +2 -0
- package/dist/range/types.test.d.ts.map +1 -0
- package/dist/range/types.test.js +48 -0
- package/dist/range/types.test.js.map +1 -0
- package/dist/version/index.d.ts +2 -0
- package/dist/version/index.d.ts.map +1 -0
- package/dist/version/index.js +18 -0
- package/dist/version/index.js.map +1 -0
- package/dist/version/types.d.ts +46 -0
- package/dist/version/types.d.ts.map +1 -0
- package/dist/version/types.js +121 -0
- package/dist/version/types.js.map +1 -0
- package/dist/version/types.test.d.ts +2 -0
- package/dist/version/types.test.d.ts.map +1 -0
- package/dist/version/types.test.js +64 -0
- package/dist/version/types.test.js.map +1 -0
- package/package.json +43 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/conditional/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./types"), exports);
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/conditional/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0CAAwB"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A conditional object
|
|
3
|
+
* @example { "walk.anim": "query.random" }
|
|
4
|
+
*/
|
|
5
|
+
export interface Conditional {
|
|
6
|
+
/**The id is an animation / controller that is to be activated if the string value is evaluated to be 1.0 or higher*/
|
|
7
|
+
[id: string]: string | number;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* The namespace of the conditional
|
|
11
|
+
*/
|
|
12
|
+
export declare namespace Conditional {
|
|
13
|
+
/**
|
|
14
|
+
* Returns the identification of the conditional
|
|
15
|
+
* @param data Either a conditional object or a string
|
|
16
|
+
* @returns Returns the identification string (property key) or the string itself
|
|
17
|
+
*/
|
|
18
|
+
function getId(data: Conditional | string): string;
|
|
19
|
+
/**
|
|
20
|
+
* Returns the condition value of the conditional
|
|
21
|
+
* @param data Either a conditional object or a string
|
|
22
|
+
* @returns Returns the condition value or 1.0 if a string was provided
|
|
23
|
+
*/
|
|
24
|
+
function getCondition(data: Conditional | string): string | number;
|
|
25
|
+
/**
|
|
26
|
+
* Iterates through each conditional or string in the provided array
|
|
27
|
+
* @param data An array of conditional objects or strings
|
|
28
|
+
* @param callbackfn A callback function that is called for each item
|
|
29
|
+
*/
|
|
30
|
+
function forEach(data: (Conditional | string)[] | Conditional[] | string[] | undefined, callbackfn: (id: string, value: string | number, index: number, data: (Conditional | string)[]) => void): void;
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/conditional/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,WAAW,WAAW;IAC1B,qHAAqH;IACrH,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC;CAC/B;AAED;;GAEG;AACH,yBAAiB,WAAW,CAAC;IAC3B;;;;OAIG;IACH,SAAgB,KAAK,CAAC,IAAI,EAAE,WAAW,GAAG,MAAM,GAAG,MAAM,CAIxD;IAED;;;;OAIG;IACH,SAAgB,YAAY,CAAC,IAAI,EAAE,WAAW,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,CAQxE;IAED;;;;OAIG;IACH,SAAgB,OAAO,CACrB,IAAI,EAAE,CAAC,WAAW,GAAG,MAAM,CAAC,EAAE,GAAG,WAAW,EAAE,GAAG,MAAM,EAAE,GAAG,SAAS,EACrE,UAAU,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,WAAW,GAAG,MAAM,CAAC,EAAE,KAAK,IAAI,GACtG,IAAI,CAcN;CACF"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Conditional = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* The namespace of the conditional
|
|
6
|
+
*/
|
|
7
|
+
var Conditional;
|
|
8
|
+
(function (Conditional) {
|
|
9
|
+
/**
|
|
10
|
+
* Returns the identification of the conditional
|
|
11
|
+
* @param data Either a conditional object or a string
|
|
12
|
+
* @returns Returns the identification string (property key) or the string itself
|
|
13
|
+
*/
|
|
14
|
+
function getId(data) {
|
|
15
|
+
if (typeof data === 'string')
|
|
16
|
+
return data;
|
|
17
|
+
return Object.getOwnPropertyNames(data)[0] ?? '';
|
|
18
|
+
}
|
|
19
|
+
Conditional.getId = getId;
|
|
20
|
+
/**
|
|
21
|
+
* Returns the condition value of the conditional
|
|
22
|
+
* @param data Either a conditional object or a string
|
|
23
|
+
* @returns Returns the condition value or 1.0 if a string was provided
|
|
24
|
+
*/
|
|
25
|
+
function getCondition(data) {
|
|
26
|
+
if (typeof data === 'string')
|
|
27
|
+
return '1.0';
|
|
28
|
+
const id = Object.getOwnPropertyNames(data)[0];
|
|
29
|
+
if (id)
|
|
30
|
+
return data[id] ?? '1.0';
|
|
31
|
+
return '1.0';
|
|
32
|
+
}
|
|
33
|
+
Conditional.getCondition = getCondition;
|
|
34
|
+
/**
|
|
35
|
+
* Iterates through each conditional or string in the provided array
|
|
36
|
+
* @param data An array of conditional objects or strings
|
|
37
|
+
* @param callbackfn A callback function that is called for each item
|
|
38
|
+
*/
|
|
39
|
+
function forEach(data, callbackfn) {
|
|
40
|
+
if (!data)
|
|
41
|
+
return;
|
|
42
|
+
data.forEach((item, index) => {
|
|
43
|
+
if (typeof item === 'string') {
|
|
44
|
+
callbackfn(item, '1.0', index, data);
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
//Is an conditional
|
|
48
|
+
const id = Object.getOwnPropertyNames(item)[0];
|
|
49
|
+
if (id)
|
|
50
|
+
callbackfn(id, item[id] ?? '1.0', index, data);
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
Conditional.forEach = forEach;
|
|
54
|
+
})(Conditional || (exports.Conditional = Conditional = {}));
|
|
55
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/conditional/types.ts"],"names":[],"mappings":";;;AASA;;GAEG;AACH,IAAiB,WAAW,CAkD3B;AAlDD,WAAiB,WAAW;IAC1B;;;;OAIG;IACH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"version":3,"file":"types.test.d.ts","sourceRoot":"","sources":["../../src/conditional/types.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const types_1 = require("./types");
|
|
4
|
+
describe('Conditional', () => {
|
|
5
|
+
it('getId', () => {
|
|
6
|
+
const example = { example: 1 };
|
|
7
|
+
expect(types_1.Conditional.getId(example)).toEqual('example');
|
|
8
|
+
});
|
|
9
|
+
it('getId2', () => {
|
|
10
|
+
expect(types_1.Conditional.getId('example')).toEqual('example');
|
|
11
|
+
});
|
|
12
|
+
it('getCondition', () => {
|
|
13
|
+
const example = { example: 1 };
|
|
14
|
+
expect(types_1.Conditional.getCondition(example)).toEqual(1);
|
|
15
|
+
});
|
|
16
|
+
it('getCondition2', () => {
|
|
17
|
+
const example = { example: 'foo' };
|
|
18
|
+
expect(types_1.Conditional.getCondition(example)).toEqual('foo');
|
|
19
|
+
});
|
|
20
|
+
it('forEach works as intented', () => {
|
|
21
|
+
const example = [{ example: 'foo' }, 'foo', { example2: 1 }];
|
|
22
|
+
const values = [];
|
|
23
|
+
const ids = [];
|
|
24
|
+
types_1.Conditional.forEach(example, (id, value) => {
|
|
25
|
+
values.push(value);
|
|
26
|
+
ids.push(id);
|
|
27
|
+
});
|
|
28
|
+
expect(ids).toEqual(expect.arrayContaining(['example', 'foo', 'example2']));
|
|
29
|
+
expect(values).toEqual(expect.arrayContaining(['foo', 1, '1.0']));
|
|
30
|
+
});
|
|
31
|
+
it('getCondition with empty object', () => {
|
|
32
|
+
const example = {};
|
|
33
|
+
expect(types_1.Conditional.getCondition(example)).toEqual('1.0');
|
|
34
|
+
});
|
|
35
|
+
it('getId with empty object', () => {
|
|
36
|
+
const example = {};
|
|
37
|
+
expect(types_1.Conditional.getId(example)).toEqual('');
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
//# sourceMappingURL=types.test.js.map
|
|
@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,EAAE,CAAC;QAEzB,mBAAW,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC,EAAE,EAAE,KAAK,EAAE,EAAE;YACzC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YACnB,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACf,CAAC,CAAC,CAAC;QAEH,MAAM,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC,SAAS,EAAE,KAAK,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC;QAC5E,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC,KAAK,EAAE,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC;IACpE,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,gCAAgC,EAAE,GAAG,EAAE;QACxC,MAAM,OAAO,GAAgB,EAAE,CAAC;QAEhC,MAAM,CAAC,mBAAW,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IAC3D,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,yBAAyB,EAAE,GAAG,EAAE;QACjC,MAAM,OAAO,GAAgB,EAAE,CAAC;QAEhC,MAAM,CAAC,mBAAW,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;IACjD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/definition/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./types"), exports);
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/definition/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0CAAwB"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**A Definition object
|
|
2
|
+
* @example { "walk.anim": "animation.sheep.walk" }*/
|
|
3
|
+
export interface Definition {
|
|
4
|
+
/**The reference is an internal reference to something that is to be used, such as animations / controllers*/
|
|
5
|
+
[reference: string]: string;
|
|
6
|
+
}
|
|
7
|
+
/**The namespace that provides functionallity to definitions*/
|
|
8
|
+
export declare namespace Definition {
|
|
9
|
+
/**
|
|
10
|
+
* Counts the number of definitions in the given object
|
|
11
|
+
* @param data The object to count the definitions in
|
|
12
|
+
* @returns The number of definitions
|
|
13
|
+
*/
|
|
14
|
+
function count(data: Definition): number;
|
|
15
|
+
/**Returns the idenfitication used
|
|
16
|
+
* @param data The data to look through
|
|
17
|
+
* @param index The index of the definition
|
|
18
|
+
* @returns*/
|
|
19
|
+
function getId(data: Definition, index: number): string;
|
|
20
|
+
/**Returns the idenfitication used
|
|
21
|
+
* @param data The data to look through
|
|
22
|
+
* @returns*/
|
|
23
|
+
function getIds(data: Definition): string[];
|
|
24
|
+
/**
|
|
25
|
+
* @param data The data to look through
|
|
26
|
+
* @param index The index of the definition
|
|
27
|
+
* @returns
|
|
28
|
+
*/
|
|
29
|
+
function getReference(data: Definition, index: number): string;
|
|
30
|
+
/**
|
|
31
|
+
* @param data The data to look through
|
|
32
|
+
* @returns
|
|
33
|
+
*/
|
|
34
|
+
function getReferences(data: Definition): string[];
|
|
35
|
+
/**
|
|
36
|
+
*
|
|
37
|
+
* @param data
|
|
38
|
+
* @param callbackfn
|
|
39
|
+
* @returns
|
|
40
|
+
*/
|
|
41
|
+
function forEach(data: Definition | undefined, callbackfn: (reference: string, id: string, index: number, data: Definition) => void): void;
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/definition/types.ts"],"names":[],"mappings":"AAAA;qDACqD;AACrD,MAAM,WAAW,UAAU;IACzB,6GAA6G;IAC7G,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAAC;CAC7B;AAED,8DAA8D;AAC9D,yBAAiB,UAAU,CAAC;IAC1B;;;;OAIG;IACH,SAAgB,KAAK,CAAC,IAAI,EAAE,UAAU,GAAG,MAAM,CAE9C;IAED;;;iBAGa;IACb,SAAgB,KAAK,CAAC,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAI7D;IAED;;iBAEa;IACb,SAAgB,MAAM,CAAC,IAAI,EAAE,UAAU,GAAG,MAAM,EAAE,CAYjD;IAED;;;;OAIG;IACH,SAAgB,YAAY,CAAC,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAEpE;IAED;;;OAGG;IACH,SAAgB,aAAa,CAAC,IAAI,EAAE,UAAU,GAAG,MAAM,EAAE,CAExD;IAED;;;;;OAKG;IACH,SAAgB,OAAO,CACrB,IAAI,EAAE,UAAU,GAAG,SAAS,EAC5B,UAAU,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,KAAK,IAAI,GACnF,IAAI,CAQN;CACF"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Definition = void 0;
|
|
4
|
+
/**The namespace that provides functionallity to definitions*/
|
|
5
|
+
var Definition;
|
|
6
|
+
(function (Definition) {
|
|
7
|
+
/**
|
|
8
|
+
* Counts the number of definitions in the given object
|
|
9
|
+
* @param data The object to count the definitions in
|
|
10
|
+
* @returns The number of definitions
|
|
11
|
+
*/
|
|
12
|
+
function count(data) {
|
|
13
|
+
return Object.getOwnPropertyNames(data).length;
|
|
14
|
+
}
|
|
15
|
+
Definition.count = count;
|
|
16
|
+
/**Returns the idenfitication used
|
|
17
|
+
* @param data The data to look through
|
|
18
|
+
* @param index The index of the definition
|
|
19
|
+
* @returns*/
|
|
20
|
+
function getId(data, index) {
|
|
21
|
+
const key = Object.getOwnPropertyNames(data)[index];
|
|
22
|
+
return data[key];
|
|
23
|
+
}
|
|
24
|
+
Definition.getId = getId;
|
|
25
|
+
/**Returns the idenfitication used
|
|
26
|
+
* @param data The data to look through
|
|
27
|
+
* @returns*/
|
|
28
|
+
function getIds(data) {
|
|
29
|
+
const out = [];
|
|
30
|
+
const keys = Object.getOwnPropertyNames(data);
|
|
31
|
+
for (let I = 0; I < keys.length; I++) {
|
|
32
|
+
const k = keys[I];
|
|
33
|
+
const value = data[k];
|
|
34
|
+
if (typeof value === 'string')
|
|
35
|
+
out.push(value);
|
|
36
|
+
}
|
|
37
|
+
return out;
|
|
38
|
+
}
|
|
39
|
+
Definition.getIds = getIds;
|
|
40
|
+
/**
|
|
41
|
+
* @param data The data to look through
|
|
42
|
+
* @param index The index of the definition
|
|
43
|
+
* @returns
|
|
44
|
+
*/
|
|
45
|
+
function getReference(data, index) {
|
|
46
|
+
return Object.getOwnPropertyNames(data)[index];
|
|
47
|
+
}
|
|
48
|
+
Definition.getReference = getReference;
|
|
49
|
+
/**
|
|
50
|
+
* @param data The data to look through
|
|
51
|
+
* @returns
|
|
52
|
+
*/
|
|
53
|
+
function getReferences(data) {
|
|
54
|
+
return Object.getOwnPropertyNames(data);
|
|
55
|
+
}
|
|
56
|
+
Definition.getReferences = getReferences;
|
|
57
|
+
/**
|
|
58
|
+
*
|
|
59
|
+
* @param data
|
|
60
|
+
* @param callbackfn
|
|
61
|
+
* @returns
|
|
62
|
+
*/
|
|
63
|
+
function forEach(data, callbackfn) {
|
|
64
|
+
if (!data)
|
|
65
|
+
return;
|
|
66
|
+
const keys = Object.getOwnPropertyNames(data);
|
|
67
|
+
keys.forEach((reference, index) => {
|
|
68
|
+
callbackfn(reference, data[reference], index, data);
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
Definition.forEach = forEach;
|
|
72
|
+
})(Definition || (exports.Definition = Definition = {}));
|
|
73
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/definition/types.ts"],"names":[],"mappings":";;;AAOA,8DAA8D;AAC9D,IAAiB,UAAU,CAwE1B;AAxED,WAAiB,UAAU;IACzB;;;;OAIG;IACH,SAAgB,KAAK,CAAC,IAAgB;QACpC,OAAO,MAAM,CAAC,mBAAmB,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC;IACjD,CAAC;IAFe,gBAAK,QAEpB,CAAA;IAED;;;iBAGa;IACb,SAAgB,KAAK,CAAC,IAAgB,EAAE,KAAa;QACnD,MAAM,GAAG,GAAG,MAAM,CAAC,mBAAmB,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC;QAEpD,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC;IACnB,CAAC;IAJe,g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tB,CAAA;AACH,CAAC,EAxEgB,UAAU,0BAAV,UAAU,QAwE1B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.test.d.ts","sourceRoot":"","sources":["../../src/definition/types.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const types_1 = require("./types");
|
|
4
|
+
describe('Definition', () => {
|
|
5
|
+
it('getId', () => {
|
|
6
|
+
const example = {
|
|
7
|
+
walk: 'animation.sheep.walk',
|
|
8
|
+
default: 'animation.sheep.default',
|
|
9
|
+
};
|
|
10
|
+
expect(types_1.Definition.count(example)).toEqual(2);
|
|
11
|
+
expect(types_1.Definition.getId(example, 0)).toEqual('animation.sheep.walk');
|
|
12
|
+
expect(types_1.Definition.getId(example, 1)).toEqual('animation.sheep.default');
|
|
13
|
+
});
|
|
14
|
+
it('getIds', () => {
|
|
15
|
+
const example = {
|
|
16
|
+
walk: 'animation.sheep.walk',
|
|
17
|
+
default: 'animation.sheep.default',
|
|
18
|
+
};
|
|
19
|
+
const keys = types_1.Definition.getIds(example);
|
|
20
|
+
expect(keys).toEqual(expect.arrayContaining(['animation.sheep.walk', 'animation.sheep.default']));
|
|
21
|
+
});
|
|
22
|
+
it('getReference', () => {
|
|
23
|
+
const example = {
|
|
24
|
+
walk: 'animation.sheep.walk',
|
|
25
|
+
default: 'animation.sheep.default',
|
|
26
|
+
};
|
|
27
|
+
expect(types_1.Definition.count(example)).toEqual(2);
|
|
28
|
+
expect(types_1.Definition.getReference(example, 0)).toEqual('walk');
|
|
29
|
+
expect(types_1.Definition.getReference(example, 1)).toEqual('default');
|
|
30
|
+
});
|
|
31
|
+
it('getReferences', () => {
|
|
32
|
+
const example = {
|
|
33
|
+
walk: 'animation.sheep.walk',
|
|
34
|
+
default: 'animation.sheep.default',
|
|
35
|
+
};
|
|
36
|
+
const keys = types_1.Definition.getReferences(example);
|
|
37
|
+
expect(keys).toEqual(expect.arrayContaining(['walk', 'default']));
|
|
38
|
+
});
|
|
39
|
+
it('foreach', () => {
|
|
40
|
+
const example = {
|
|
41
|
+
walk: 'animation.sheep.walk',
|
|
42
|
+
default: 'animation.sheep.default',
|
|
43
|
+
};
|
|
44
|
+
const ids = [];
|
|
45
|
+
const references = [];
|
|
46
|
+
types_1.Definition.forEach(example, (reference, id) => {
|
|
47
|
+
ids.push(id);
|
|
48
|
+
references.push(reference);
|
|
49
|
+
});
|
|
50
|
+
expect(ids).toEqual(expect.arrayContaining(['animation.sheep.walk', 'animation.sheep.default']));
|
|
51
|
+
expect(references).toEqual(expect.arrayContaining(['walk', 'default']));
|
|
52
|
+
});
|
|
53
|
+
it('foreach with undefined', () => {
|
|
54
|
+
const ids = [];
|
|
55
|
+
const references = [];
|
|
56
|
+
types_1.Definition.forEach(undefined, (reference, id) => {
|
|
57
|
+
ids.push(id);
|
|
58
|
+
references.push(reference);
|
|
59
|
+
});
|
|
60
|
+
expect(ids).toEqual([]);
|
|
61
|
+
expect(references).toEqual([]);
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
//# sourceMappingURL=types.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.test.js","sourceRoot":"","sources":["../../src/definition/types.test.ts"],"names":[],"mappings":";;AAAA,mCAAqC;AAErC,QAAQ,CAAC,YAAY,EAAE,GAAG,EAAE;IAC1B,EAAE,CAAC,OAAO,EAAE,GAAG,EAAE;QACf,MAAM,OAAO,GAAe;YAC1B,IAAI,EAAE,sBAAsB;YAC5B,OAAO,EAAE,yBAAyB;SACnC,CAAC;QAEF,MAAM,CAAC,kBAAU,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;QAC7C,MAAM,CAAC,kBAAU,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,sBAA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AAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/document-location/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./types"), exports);
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/document-location/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0CAAwB"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { JsonPath } from '../json-path';
|
|
2
|
+
import { OffsetWord } from '../offset-word';
|
|
3
|
+
import { Position } from '../position';
|
|
4
|
+
import { Range } from '../range';
|
|
5
|
+
/**The type of a document location */
|
|
6
|
+
export type DocumentLocation = Position | OffsetWord | JsonPath | number;
|
|
7
|
+
/** A string or document object that can provide text */
|
|
8
|
+
export type TextOrDoc = string | {
|
|
9
|
+
getText(): string;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Document location utilities
|
|
13
|
+
*/
|
|
14
|
+
export declare namespace DocumentLocation {
|
|
15
|
+
/**
|
|
16
|
+
* Converts a DocumentLocation to an offset number.
|
|
17
|
+
* @param data The document location to convert (number, string path, Position, or OffsetWord)
|
|
18
|
+
*/
|
|
19
|
+
function toOffset(data: number): number;
|
|
20
|
+
/**
|
|
21
|
+
* Converts a DocumentLocation to an offset number.
|
|
22
|
+
* @param data The document location to convert (number, string path, Position, or OffsetWord)
|
|
23
|
+
*/
|
|
24
|
+
function toOffset(data: OffsetWord): number;
|
|
25
|
+
/**
|
|
26
|
+
* Converts a DocumentLocation to an offset number.
|
|
27
|
+
* @param loc The document location to convert (number, string path, Position, or OffsetWord)
|
|
28
|
+
* @param text The text content or document object needed for conversion
|
|
29
|
+
* @returns The offset number representing the location
|
|
30
|
+
*/
|
|
31
|
+
function toOffset(data: DocumentLocation, text: TextOrDoc): number;
|
|
32
|
+
/**
|
|
33
|
+
* Converts a DocumentLocation to a Position object.
|
|
34
|
+
* Handles conversion from numbers, JSON paths, and Position/OffsetWord objects.
|
|
35
|
+
* @param data The document location to convert (number, string path, Position, or OffsetWord)
|
|
36
|
+
* @param text The text content or document object needed for conversion
|
|
37
|
+
* @returns A Position object representing the location
|
|
38
|
+
*/
|
|
39
|
+
function toPosition(data: DocumentLocation, text: TextOrDoc): Position;
|
|
40
|
+
/**
|
|
41
|
+
* Converts a DocumentLocation to a Range object.
|
|
42
|
+
* @param data The document location to convert (OffsetWord)
|
|
43
|
+
*/
|
|
44
|
+
function toRange(data: OffsetWord): Range;
|
|
45
|
+
/**
|
|
46
|
+
* Converts a DocumentLocation to a Range object.
|
|
47
|
+
* @param data The document location to convert (number, string path, Position)
|
|
48
|
+
* @param text The text content or document object needed for conversion
|
|
49
|
+
* @param length The length of the range
|
|
50
|
+
* @returns A Range object representing the location
|
|
51
|
+
*/
|
|
52
|
+
function toRange(data: DocumentLocation, text: TextOrDoc, length: number): Range;
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/document-location/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACxC,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAEjC,qCAAqC;AACrC,MAAM,MAAM,gBAAgB,GAAG,QAAQ,GAAG,UAAU,GAAG,QAAQ,GAAG,MAAM,CAAC;AAEzE,wDAAwD;AACxD,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG;IAAE,OAAO,IAAI,MAAM,CAAA;CAAE,CAAC;AAOvD;;GAEG;AACH,yBAAiB,gBAAgB,CAAC;IAChC;;;OAGG;IACH,SAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;IAC/C;;;OAGG;IACH,SAAgB,QAAQ,CAAC,IAAI,EAAE,UAAU,GAAG,MAAM,CAAC;IACnD;;;;;OAKG;IACH,SAAgB,QAAQ,CAAC,IAAI,EAAE,gBAAgB,EAAE,IAAI,EAAE,SAAS,GAAG,MAAM,CAAC;IAgC1E;;;;;;OAMG;IACH,SAAgB,UAAU,CAAC,IAAI,EAAE,gBAAgB,EAAE,IAAI,EAAE,SAAS,GAAG,QAAQ,CAoB5E;IAED;;;OAGG;IACH,SAAgB,OAAO,CAAC,IAAI,EAAE,UAAU,GAAG,KAAK,CAAC;IACjD;;;;;;OAMG;IACH,SAAgB,OAAO,CAAC,IAAI,EAAE,gBAAgB,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,GAAG,KAAK,CAAC;CAuBzF"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DocumentLocation = void 0;
|
|
4
|
+
const json_path_1 = require("../json-path");
|
|
5
|
+
const offset_word_1 = require("../offset-word");
|
|
6
|
+
const position_1 = require("../position");
|
|
7
|
+
const range_1 = require("../range");
|
|
8
|
+
/** Converts TextOrDoc to string */
|
|
9
|
+
function ToText(value) {
|
|
10
|
+
return typeof value === 'string' ? value : value.getText();
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Document location utilities
|
|
14
|
+
*/
|
|
15
|
+
var DocumentLocation;
|
|
16
|
+
(function (DocumentLocation) {
|
|
17
|
+
/**
|
|
18
|
+
* Converts a DocumentLocation to an offset number.
|
|
19
|
+
* @param loc The document location to convert (number, string path, Position, or OffsetWord)
|
|
20
|
+
* @param text The text content or document object needed for conversion
|
|
21
|
+
* @returns The offset number representing the location
|
|
22
|
+
*/
|
|
23
|
+
function toOffset(loc, text) {
|
|
24
|
+
switch (typeof loc) {
|
|
25
|
+
case 'number':
|
|
26
|
+
return loc;
|
|
27
|
+
//Json path
|
|
28
|
+
case 'string':
|
|
29
|
+
if (text === undefined)
|
|
30
|
+
throw new Error('text or document must be provided');
|
|
31
|
+
return json_path_1.JsonPath.resolve(text, loc);
|
|
32
|
+
//Position
|
|
33
|
+
case 'object':
|
|
34
|
+
if (offset_word_1.OffsetWord.is(loc)) {
|
|
35
|
+
return loc.offset;
|
|
36
|
+
}
|
|
37
|
+
if (text === undefined)
|
|
38
|
+
throw new Error('text or document must be provided');
|
|
39
|
+
return position_1.Position.toOffset(loc, ToText(text));
|
|
40
|
+
default:
|
|
41
|
+
return 0;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
DocumentLocation.toOffset = toOffset;
|
|
45
|
+
/**
|
|
46
|
+
* Converts a DocumentLocation to a Position object.
|
|
47
|
+
* Handles conversion from numbers, JSON paths, and Position/OffsetWord objects.
|
|
48
|
+
* @param data The document location to convert (number, string path, Position, or OffsetWord)
|
|
49
|
+
* @param text The text content or document object needed for conversion
|
|
50
|
+
* @returns A Position object representing the location
|
|
51
|
+
*/
|
|
52
|
+
function toPosition(data, text) {
|
|
53
|
+
switch (typeof data) {
|
|
54
|
+
case 'number':
|
|
55
|
+
return position_1.Position.toPosition(data, ToText(text));
|
|
56
|
+
//Json path
|
|
57
|
+
case 'string':
|
|
58
|
+
return position_1.Position.toPosition(json_path_1.JsonPath.resolve(text, data), ToText(text));
|
|
59
|
+
//Position
|
|
60
|
+
case 'object':
|
|
61
|
+
if (offset_word_1.OffsetWord.is(data)) {
|
|
62
|
+
return position_1.Position.toPosition(data.offset, data.text);
|
|
63
|
+
}
|
|
64
|
+
return data;
|
|
65
|
+
default:
|
|
66
|
+
return position_1.Position.create(0, 0);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
DocumentLocation.toPosition = toPosition;
|
|
70
|
+
/**
|
|
71
|
+
* Converts a DocumentLocation to a Range object.
|
|
72
|
+
* @param data The document location to convert (number, string path, Position)
|
|
73
|
+
* @param text The text content or document object needed for conversion
|
|
74
|
+
* @param length The length of the range
|
|
75
|
+
* @returns A Range object representing the location
|
|
76
|
+
*/
|
|
77
|
+
function toRange(data, text, length) {
|
|
78
|
+
if (offset_word_1.OffsetWord.is(data)) {
|
|
79
|
+
const t = data.text;
|
|
80
|
+
return range_1.Range.create(position_1.Position.toPosition(data.offset, t), position_1.Position.toPosition(data.offset + t.length, t));
|
|
81
|
+
}
|
|
82
|
+
if (text === undefined)
|
|
83
|
+
throw new Error('requires text or document');
|
|
84
|
+
if (length === undefined)
|
|
85
|
+
throw new Error('requires length');
|
|
86
|
+
const startindex = toOffset(data, text);
|
|
87
|
+
const endindex = startindex + length;
|
|
88
|
+
const t = ToText(text);
|
|
89
|
+
return range_1.Range.create(position_1.Position.toPosition(startindex, t), position_1.Position.toPosition(endindex, t));
|
|
90
|
+
}
|
|
91
|
+
DocumentLocation.toRange = toRange;
|
|
92
|
+
})(DocumentLocation || (exports.DocumentLocation = DocumentLocation = {}));
|
|
93
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/document-location/types.ts"],"names":[],"mappings":";;;AAAA,4CAAwC;AACxC,gDAA4C;AAC5C,0CAAuC;AACvC,oCAAiC;AAQjC,mCAAmC;AACnC,SAAS,MAAM,CAAC,KAAgB;IAC9B,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC;AAC7D,CAAC;AAED;;GAEG;AACH,IAAiB,gBAAgB,CAiHhC;AAjHD,WAAiB,gBAAgB;IAmB/B;;;;;OAKG;IACH,SAAgB,QAAQ,CAAC,GAAqB,EAAE,IAAgB;QAC9D,QAAQ,OAAO,GAAG,EAAE,CAAC;YACnB,KAAK,QAAQ;gBACX,OAAO,GAAG,CAAC;YAEb,WAAW;YACX,KAAK,QAAQ;gBACX,IAAI,IAAI,KAAK,SAAS;oBAAE,MAAM,IAAI,KAAK,CAAC,mCAAmC,CAAC,CAAC;gBAC7E,OAAO,oBAAQ,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;YAErC,UAAU;YACV,KAAK,QAAQ;gBACX,IAAI,wBAAU,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC;oBACvB,OAAO,GAAG,CAAC,MAAM,CAAC;gBACpB,CAAC;gBAED,IAAI,IAAI,KAAK,SAAS;oBAAE,MAAM,IAAI,KAAK,CAAC,mCAAmC,CAAC,CAAC;gBAC7E,OAAO,mBAAQ,CAAC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;YAE9C;gBACE,OAAO,CAAC,CAAC;QACb,CAAC;IACH,CAAC;IAtBe,yBAAQ,WAsBvB,CAAA;IA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