oca_package 1.1.0 → 1.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/oca_extensions/extensions.js +15 -3
- package/dist/cjs/oca_extensions/state/overlays/example.js +59 -0
- package/dist/cjs/oca_extensions/state/overlays/framing/unit_framing.js +12 -5
- package/dist/cjs/oca_extensions/state/overlays/ordering.js +2 -2
- package/dist/cjs/oca_extensions/state/overlays/range.js +36 -0
- package/dist/cjs/utils/canonical.js +54 -0
- package/dist/esm/oca_extensions/extensions.js +15 -3
- package/dist/esm/oca_extensions/state/overlays/example.js +54 -0
- package/dist/esm/oca_extensions/state/overlays/framing/unit_framing.js +9 -5
- package/dist/esm/oca_extensions/state/overlays/ordering.js +2 -2
- package/dist/esm/oca_extensions/state/overlays/range.js +31 -0
- package/dist/esm/utils/canonical.js +52 -0
- package/dist/types/oca_extensions/extensions.d.ts.map +1 -1
- package/dist/types/oca_extensions/state/overlays/example.d.ts +19 -0
- package/dist/types/oca_extensions/state/overlays/example.d.ts.map +1 -0
- package/dist/types/oca_extensions/state/overlays/framing/unit_framing.d.ts.map +1 -1
- package/dist/types/oca_extensions/state/overlays/range.d.ts +15 -0
- package/dist/types/oca_extensions/state/overlays/range.d.ts.map +1 -0
- package/dist/types/utils/canonical.d.ts +15 -0
- package/dist/types/utils/canonical.d.ts.map +1 -0
- package/package.json +1 -1
|
@@ -6,6 +6,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.Extension = exports.Overlay = exports.ExtensionState = void 0;
|
|
7
7
|
const ordering_js_1 = __importDefault(require("./state/overlays/ordering.js"));
|
|
8
8
|
const unit_framing_js_1 = __importDefault(require("./state/overlays/framing/unit_framing.js"));
|
|
9
|
+
const example_js_1 = __importDefault(require("./state/overlays/example.js"));
|
|
10
|
+
const range_js_1 = __importDefault(require("./state/overlays/range.js"));
|
|
9
11
|
const helpers_js_1 = require("../utils/helpers.js");
|
|
10
12
|
const saidify_1 = require("saidify");
|
|
11
13
|
const ADC_COMMUNITY = 'adc';
|
|
@@ -40,16 +42,26 @@ class Overlay {
|
|
|
40
42
|
const overlay = {};
|
|
41
43
|
for (const ov_type in this._overlay) {
|
|
42
44
|
if (ov_type === 'ordering_overlay') {
|
|
43
|
-
const ordering_instance = new ordering_js_1.default(this._overlay);
|
|
45
|
+
const ordering_instance = new ordering_js_1.default(this._overlay.ordering_overlay);
|
|
44
46
|
const ordering_ov = ordering_instance.GenerateOverlay();
|
|
45
47
|
overlay['ordering'] = JSON.parse(ordering_ov);
|
|
46
48
|
}
|
|
47
49
|
else if (ov_type === 'unit_framing_overlay') {
|
|
48
|
-
const unit_framing_instance = new unit_framing_js_1.default(this._overlay);
|
|
50
|
+
const unit_framing_instance = new unit_framing_js_1.default(this._overlay.unit_framing_overlay);
|
|
49
51
|
const unit_framing_ov = unit_framing_instance.GenerateOverlay();
|
|
50
52
|
overlay['unit_framing'] = JSON.parse(unit_framing_ov);
|
|
51
53
|
}
|
|
54
|
+
else if (ov_type === 'range_overlay') {
|
|
55
|
+
const range_instance = new range_js_1.default(this._overlay.range_overlay);
|
|
56
|
+
const range_ov = range_instance.GenerateOverlay();
|
|
57
|
+
overlay['range'] = JSON.parse(range_ov);
|
|
58
|
+
}
|
|
59
|
+
else if (ov_type === 'example_overlay') {
|
|
60
|
+
const example_ov = example_js_1.default.GenerateOverlay(this._overlay.example_overlay);
|
|
61
|
+
overlay['example'] = JSON.parse(example_ov);
|
|
62
|
+
}
|
|
52
63
|
else {
|
|
64
|
+
// throwing an error as all extension overlays authored by adc should be handled by the overlay class
|
|
53
65
|
throw new Error('Invalid overlay name');
|
|
54
66
|
}
|
|
55
67
|
}
|
|
@@ -74,7 +86,7 @@ class ADCOverlayStrategy {
|
|
|
74
86
|
// To implement overlays for external communities, create a new class that implements the OverlayStrategy interface.
|
|
75
87
|
// For example, if you have a community called "external_community", you can create a class like this:
|
|
76
88
|
class DefaultOverlayStrategy {
|
|
77
|
-
GenerateOverlay(
|
|
89
|
+
GenerateOverlay(_extensions) {
|
|
78
90
|
throw new Error('Unsupported community type');
|
|
79
91
|
}
|
|
80
92
|
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const saidify_1 = require("saidify");
|
|
7
|
+
const canonical_js_1 = __importDefault(require("../../../utils/canonical.js"));
|
|
8
|
+
class ExampleOverlay {
|
|
9
|
+
constructor(dynOverlay) {
|
|
10
|
+
if (!dynOverlay) {
|
|
11
|
+
throw new Error('A dynamic extension overlay is required');
|
|
12
|
+
}
|
|
13
|
+
this.dynOverlay = dynOverlay;
|
|
14
|
+
}
|
|
15
|
+
get language() {
|
|
16
|
+
return this.dynOverlay.language;
|
|
17
|
+
}
|
|
18
|
+
GetAttributeExamples() {
|
|
19
|
+
const examples = this.dynOverlay.attribute_examples;
|
|
20
|
+
const canonicalizedExamples = (0, canonical_js_1.default)(examples);
|
|
21
|
+
const sortedExamples = JSON.parse(canonicalizedExamples);
|
|
22
|
+
return sortedExamples;
|
|
23
|
+
}
|
|
24
|
+
toJSON() {
|
|
25
|
+
return {
|
|
26
|
+
d: '',
|
|
27
|
+
type: 'community/overlays/adc/example/1.1',
|
|
28
|
+
language: this.language,
|
|
29
|
+
attribute_examples: this.GetAttributeExamples(),
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
Saidifying() {
|
|
33
|
+
const [, sad] = (0, saidify_1.saidify)(this.toJSON());
|
|
34
|
+
return sad;
|
|
35
|
+
}
|
|
36
|
+
// generates a single example overlay
|
|
37
|
+
GenerateExampleOverlay() {
|
|
38
|
+
return JSON.stringify(this.Saidifying());
|
|
39
|
+
}
|
|
40
|
+
static GenerateOverlay(dynOverlay) {
|
|
41
|
+
if (!dynOverlay || typeof dynOverlay !== 'object' || !Array.isArray(dynOverlay['example_overlays'])) {
|
|
42
|
+
throw new Error('Invalid dynOverlay structure. Expected an object with an "example_overlays" array.');
|
|
43
|
+
}
|
|
44
|
+
const example_overlays = [];
|
|
45
|
+
const overlays = dynOverlay['example_overlays'];
|
|
46
|
+
for (let example_ov of overlays) {
|
|
47
|
+
try {
|
|
48
|
+
const example_overlay = new ExampleOverlay(example_ov);
|
|
49
|
+
example_overlays.push(JSON.parse(example_overlay.GenerateExampleOverlay()));
|
|
50
|
+
}
|
|
51
|
+
catch (error) {
|
|
52
|
+
console.error('Failed to process example overlay:', error);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
example_overlays.sort((a, b) => a.language.localeCompare(b.language));
|
|
56
|
+
return JSON.stringify(example_overlays);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
exports.default = ExampleOverlay;
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
const saidify_1 = require("saidify");
|
|
7
|
+
const canonical_js_1 = __importDefault(require("../../../../utils/canonical.js"));
|
|
4
8
|
class UnitFraming {
|
|
5
9
|
constructor(dynOverlay) {
|
|
6
10
|
if (!dynOverlay) {
|
|
@@ -9,19 +13,22 @@ class UnitFraming {
|
|
|
9
13
|
this.dynOverlay = dynOverlay;
|
|
10
14
|
}
|
|
11
15
|
GetUnits() {
|
|
12
|
-
|
|
16
|
+
const units = this.dynOverlay.units;
|
|
17
|
+
const canonicalizedUnits = (0, canonical_js_1.default)(units);
|
|
18
|
+
const sortedUnits = JSON.parse(canonicalizedUnits);
|
|
19
|
+
return sortedUnits;
|
|
13
20
|
}
|
|
14
21
|
GetId() {
|
|
15
|
-
return this.dynOverlay.
|
|
22
|
+
return this.dynOverlay.properties.id;
|
|
16
23
|
}
|
|
17
24
|
GetLabel() {
|
|
18
|
-
return this.dynOverlay.
|
|
25
|
+
return this.dynOverlay.properties.label;
|
|
19
26
|
}
|
|
20
27
|
GetLocation() {
|
|
21
|
-
return this.dynOverlay.
|
|
28
|
+
return this.dynOverlay.properties.location;
|
|
22
29
|
}
|
|
23
30
|
GetVersion() {
|
|
24
|
-
return this.dynOverlay.
|
|
31
|
+
return this.dynOverlay.properties.version;
|
|
25
32
|
}
|
|
26
33
|
toJSON() {
|
|
27
34
|
return {
|
|
@@ -9,10 +9,10 @@ class Ordering {
|
|
|
9
9
|
this.dynOverlay = dynOverlay;
|
|
10
10
|
}
|
|
11
11
|
GetAttributeOrdering() {
|
|
12
|
-
return this.dynOverlay.
|
|
12
|
+
return this.dynOverlay.attribute_ordering;
|
|
13
13
|
}
|
|
14
14
|
GetEntryCodeOrdering() {
|
|
15
|
-
return this.dynOverlay.
|
|
15
|
+
return this.dynOverlay.entry_code_ordering;
|
|
16
16
|
}
|
|
17
17
|
toJSON() {
|
|
18
18
|
return {
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const saidify_1 = require("saidify");
|
|
7
|
+
const canonical_js_1 = __importDefault(require("../../../utils/canonical.js"));
|
|
8
|
+
class Range {
|
|
9
|
+
constructor(dynOverlay) {
|
|
10
|
+
if (!dynOverlay) {
|
|
11
|
+
throw new Error('a dynamic extension overlay are required');
|
|
12
|
+
}
|
|
13
|
+
this.dynOverlay = dynOverlay;
|
|
14
|
+
}
|
|
15
|
+
GetAttributes() {
|
|
16
|
+
const range_overlay_attributes = this.dynOverlay.attributes;
|
|
17
|
+
const canonicalized_attributes = (0, canonical_js_1.default)(range_overlay_attributes);
|
|
18
|
+
const sortedAttributes = JSON.parse(canonicalized_attributes);
|
|
19
|
+
return sortedAttributes;
|
|
20
|
+
}
|
|
21
|
+
toJSON() {
|
|
22
|
+
return {
|
|
23
|
+
d: '',
|
|
24
|
+
type: 'community/overlays/adc/range/1.1',
|
|
25
|
+
attributes: this.GetAttributes(),
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
Saidifying() {
|
|
29
|
+
const [, sad] = (0, saidify_1.saidify)(this.toJSON());
|
|
30
|
+
return sad;
|
|
31
|
+
}
|
|
32
|
+
GenerateOverlay() {
|
|
33
|
+
return JSON.stringify(this.Saidifying());
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
exports.default = Range;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
/**
|
|
4
|
+
* Canonicalizes a JSON object by sorting its properties and maintaining the order of array elements.
|
|
5
|
+
* This function is useful for generating a consistent string representation of JSON data.
|
|
6
|
+
*
|
|
7
|
+
* @param {JsonValue} object - The JSON object to canonicalize.
|
|
8
|
+
* @returns {string} - The canonicalized string representation of the JSON object.
|
|
9
|
+
*/
|
|
10
|
+
const canonicalize = (object) => {
|
|
11
|
+
let buffer = '';
|
|
12
|
+
serialize(object);
|
|
13
|
+
return buffer;
|
|
14
|
+
function serialize(object) {
|
|
15
|
+
if (object === null || typeof object !== 'object' || typeof object.toJSON === 'function') {
|
|
16
|
+
// Primitive type or toJSON - Use ES6/JSON
|
|
17
|
+
buffer += JSON.stringify(object);
|
|
18
|
+
}
|
|
19
|
+
else if (Array.isArray(object)) {
|
|
20
|
+
// Array - Maintain element order
|
|
21
|
+
buffer += '[';
|
|
22
|
+
let next = false;
|
|
23
|
+
object.forEach(element => {
|
|
24
|
+
if (next) {
|
|
25
|
+
buffer += ',';
|
|
26
|
+
}
|
|
27
|
+
next = true;
|
|
28
|
+
// Array element - Recursive expansion
|
|
29
|
+
serialize(element);
|
|
30
|
+
});
|
|
31
|
+
buffer += ']';
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
// Object - Sort properties before serializing
|
|
35
|
+
buffer += '{';
|
|
36
|
+
let next = false;
|
|
37
|
+
Object.keys(object)
|
|
38
|
+
.sort()
|
|
39
|
+
.forEach(property => {
|
|
40
|
+
if (next) {
|
|
41
|
+
buffer += ',';
|
|
42
|
+
}
|
|
43
|
+
next = true;
|
|
44
|
+
// Property names are strings - Use ES6/JSON
|
|
45
|
+
buffer += JSON.stringify(property);
|
|
46
|
+
buffer += ':';
|
|
47
|
+
// Property value - Recursive expansion
|
|
48
|
+
serialize(object[property]);
|
|
49
|
+
});
|
|
50
|
+
buffer += '}';
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
exports.default = canonicalize;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import Ordering from './state/overlays/ordering.js';
|
|
2
2
|
import UnitFraming from './state/overlays/framing/unit_framing.js';
|
|
3
|
+
import ExampleOverlay from './state/overlays/example.js';
|
|
4
|
+
import Range from './state/overlays/range.js';
|
|
3
5
|
import { ocabundleDigest, getOcaBundleFromDeps, getDigest, isOcaBundleWithDeps } from '../utils/helpers.js';
|
|
4
6
|
import { saidify } from 'saidify';
|
|
5
7
|
const ADC_COMMUNITY = 'adc';
|
|
@@ -33,16 +35,26 @@ export class Overlay {
|
|
|
33
35
|
const overlay = {};
|
|
34
36
|
for (const ov_type in this._overlay) {
|
|
35
37
|
if (ov_type === 'ordering_overlay') {
|
|
36
|
-
const ordering_instance = new Ordering(this._overlay);
|
|
38
|
+
const ordering_instance = new Ordering(this._overlay.ordering_overlay);
|
|
37
39
|
const ordering_ov = ordering_instance.GenerateOverlay();
|
|
38
40
|
overlay['ordering'] = JSON.parse(ordering_ov);
|
|
39
41
|
}
|
|
40
42
|
else if (ov_type === 'unit_framing_overlay') {
|
|
41
|
-
const unit_framing_instance = new UnitFraming(this._overlay);
|
|
43
|
+
const unit_framing_instance = new UnitFraming(this._overlay.unit_framing_overlay);
|
|
42
44
|
const unit_framing_ov = unit_framing_instance.GenerateOverlay();
|
|
43
45
|
overlay['unit_framing'] = JSON.parse(unit_framing_ov);
|
|
44
46
|
}
|
|
47
|
+
else if (ov_type === 'range_overlay') {
|
|
48
|
+
const range_instance = new Range(this._overlay.range_overlay);
|
|
49
|
+
const range_ov = range_instance.GenerateOverlay();
|
|
50
|
+
overlay['range'] = JSON.parse(range_ov);
|
|
51
|
+
}
|
|
52
|
+
else if (ov_type === 'example_overlay') {
|
|
53
|
+
const example_ov = ExampleOverlay.GenerateOverlay(this._overlay.example_overlay);
|
|
54
|
+
overlay['example'] = JSON.parse(example_ov);
|
|
55
|
+
}
|
|
45
56
|
else {
|
|
57
|
+
// throwing an error as all extension overlays authored by adc should be handled by the overlay class
|
|
46
58
|
throw new Error('Invalid overlay name');
|
|
47
59
|
}
|
|
48
60
|
}
|
|
@@ -66,7 +78,7 @@ class ADCOverlayStrategy {
|
|
|
66
78
|
// To implement overlays for external communities, create a new class that implements the OverlayStrategy interface.
|
|
67
79
|
// For example, if you have a community called "external_community", you can create a class like this:
|
|
68
80
|
class DefaultOverlayStrategy {
|
|
69
|
-
GenerateOverlay(
|
|
81
|
+
GenerateOverlay(_extensions) {
|
|
70
82
|
throw new Error('Unsupported community type');
|
|
71
83
|
}
|
|
72
84
|
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { saidify } from 'saidify';
|
|
2
|
+
import canonicalize from '../../../utils/canonical.js';
|
|
3
|
+
class ExampleOverlay {
|
|
4
|
+
constructor(dynOverlay) {
|
|
5
|
+
if (!dynOverlay) {
|
|
6
|
+
throw new Error('A dynamic extension overlay is required');
|
|
7
|
+
}
|
|
8
|
+
this.dynOverlay = dynOverlay;
|
|
9
|
+
}
|
|
10
|
+
get language() {
|
|
11
|
+
return this.dynOverlay.language;
|
|
12
|
+
}
|
|
13
|
+
GetAttributeExamples() {
|
|
14
|
+
const examples = this.dynOverlay.attribute_examples;
|
|
15
|
+
const canonicalizedExamples = canonicalize(examples);
|
|
16
|
+
const sortedExamples = JSON.parse(canonicalizedExamples);
|
|
17
|
+
return sortedExamples;
|
|
18
|
+
}
|
|
19
|
+
toJSON() {
|
|
20
|
+
return {
|
|
21
|
+
d: '',
|
|
22
|
+
type: 'community/overlays/adc/example/1.1',
|
|
23
|
+
language: this.language,
|
|
24
|
+
attribute_examples: this.GetAttributeExamples(),
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
Saidifying() {
|
|
28
|
+
const [, sad] = saidify(this.toJSON());
|
|
29
|
+
return sad;
|
|
30
|
+
}
|
|
31
|
+
// generates a single example overlay
|
|
32
|
+
GenerateExampleOverlay() {
|
|
33
|
+
return JSON.stringify(this.Saidifying());
|
|
34
|
+
}
|
|
35
|
+
static GenerateOverlay(dynOverlay) {
|
|
36
|
+
if (!dynOverlay || typeof dynOverlay !== 'object' || !Array.isArray(dynOverlay['example_overlays'])) {
|
|
37
|
+
throw new Error('Invalid dynOverlay structure. Expected an object with an "example_overlays" array.');
|
|
38
|
+
}
|
|
39
|
+
const example_overlays = [];
|
|
40
|
+
const overlays = dynOverlay['example_overlays'];
|
|
41
|
+
for (let example_ov of overlays) {
|
|
42
|
+
try {
|
|
43
|
+
const example_overlay = new ExampleOverlay(example_ov);
|
|
44
|
+
example_overlays.push(JSON.parse(example_overlay.GenerateExampleOverlay()));
|
|
45
|
+
}
|
|
46
|
+
catch (error) {
|
|
47
|
+
console.error('Failed to process example overlay:', error);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
example_overlays.sort((a, b) => a.language.localeCompare(b.language));
|
|
51
|
+
return JSON.stringify(example_overlays);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
export default ExampleOverlay;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { saidify } from 'saidify';
|
|
2
|
+
import canonicalize from '../../../../utils/canonical.js';
|
|
2
3
|
class UnitFraming {
|
|
3
4
|
constructor(dynOverlay) {
|
|
4
5
|
if (!dynOverlay) {
|
|
@@ -7,19 +8,22 @@ class UnitFraming {
|
|
|
7
8
|
this.dynOverlay = dynOverlay;
|
|
8
9
|
}
|
|
9
10
|
GetUnits() {
|
|
10
|
-
|
|
11
|
+
const units = this.dynOverlay.units;
|
|
12
|
+
const canonicalizedUnits = canonicalize(units);
|
|
13
|
+
const sortedUnits = JSON.parse(canonicalizedUnits);
|
|
14
|
+
return sortedUnits;
|
|
11
15
|
}
|
|
12
16
|
GetId() {
|
|
13
|
-
return this.dynOverlay.
|
|
17
|
+
return this.dynOverlay.properties.id;
|
|
14
18
|
}
|
|
15
19
|
GetLabel() {
|
|
16
|
-
return this.dynOverlay.
|
|
20
|
+
return this.dynOverlay.properties.label;
|
|
17
21
|
}
|
|
18
22
|
GetLocation() {
|
|
19
|
-
return this.dynOverlay.
|
|
23
|
+
return this.dynOverlay.properties.location;
|
|
20
24
|
}
|
|
21
25
|
GetVersion() {
|
|
22
|
-
return this.dynOverlay.
|
|
26
|
+
return this.dynOverlay.properties.version;
|
|
23
27
|
}
|
|
24
28
|
toJSON() {
|
|
25
29
|
return {
|
|
@@ -7,10 +7,10 @@ class Ordering {
|
|
|
7
7
|
this.dynOverlay = dynOverlay;
|
|
8
8
|
}
|
|
9
9
|
GetAttributeOrdering() {
|
|
10
|
-
return this.dynOverlay.
|
|
10
|
+
return this.dynOverlay.attribute_ordering;
|
|
11
11
|
}
|
|
12
12
|
GetEntryCodeOrdering() {
|
|
13
|
-
return this.dynOverlay.
|
|
13
|
+
return this.dynOverlay.entry_code_ordering;
|
|
14
14
|
}
|
|
15
15
|
toJSON() {
|
|
16
16
|
return {
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { saidify } from 'saidify';
|
|
2
|
+
import canonicalize from '../../../utils/canonical.js';
|
|
3
|
+
class Range {
|
|
4
|
+
constructor(dynOverlay) {
|
|
5
|
+
if (!dynOverlay) {
|
|
6
|
+
throw new Error('a dynamic extension overlay are required');
|
|
7
|
+
}
|
|
8
|
+
this.dynOverlay = dynOverlay;
|
|
9
|
+
}
|
|
10
|
+
GetAttributes() {
|
|
11
|
+
const range_overlay_attributes = this.dynOverlay.attributes;
|
|
12
|
+
const canonicalized_attributes = canonicalize(range_overlay_attributes);
|
|
13
|
+
const sortedAttributes = JSON.parse(canonicalized_attributes);
|
|
14
|
+
return sortedAttributes;
|
|
15
|
+
}
|
|
16
|
+
toJSON() {
|
|
17
|
+
return {
|
|
18
|
+
d: '',
|
|
19
|
+
type: 'community/overlays/adc/range/1.1',
|
|
20
|
+
attributes: this.GetAttributes(),
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
Saidifying() {
|
|
24
|
+
const [, sad] = saidify(this.toJSON());
|
|
25
|
+
return sad;
|
|
26
|
+
}
|
|
27
|
+
GenerateOverlay() {
|
|
28
|
+
return JSON.stringify(this.Saidifying());
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
export default Range;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Canonicalizes a JSON object by sorting its properties and maintaining the order of array elements.
|
|
3
|
+
* This function is useful for generating a consistent string representation of JSON data.
|
|
4
|
+
*
|
|
5
|
+
* @param {JsonValue} object - The JSON object to canonicalize.
|
|
6
|
+
* @returns {string} - The canonicalized string representation of the JSON object.
|
|
7
|
+
*/
|
|
8
|
+
const canonicalize = (object) => {
|
|
9
|
+
let buffer = '';
|
|
10
|
+
serialize(object);
|
|
11
|
+
return buffer;
|
|
12
|
+
function serialize(object) {
|
|
13
|
+
if (object === null || typeof object !== 'object' || typeof object.toJSON === 'function') {
|
|
14
|
+
// Primitive type or toJSON - Use ES6/JSON
|
|
15
|
+
buffer += JSON.stringify(object);
|
|
16
|
+
}
|
|
17
|
+
else if (Array.isArray(object)) {
|
|
18
|
+
// Array - Maintain element order
|
|
19
|
+
buffer += '[';
|
|
20
|
+
let next = false;
|
|
21
|
+
object.forEach(element => {
|
|
22
|
+
if (next) {
|
|
23
|
+
buffer += ',';
|
|
24
|
+
}
|
|
25
|
+
next = true;
|
|
26
|
+
// Array element - Recursive expansion
|
|
27
|
+
serialize(element);
|
|
28
|
+
});
|
|
29
|
+
buffer += ']';
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
// Object - Sort properties before serializing
|
|
33
|
+
buffer += '{';
|
|
34
|
+
let next = false;
|
|
35
|
+
Object.keys(object)
|
|
36
|
+
.sort()
|
|
37
|
+
.forEach(property => {
|
|
38
|
+
if (next) {
|
|
39
|
+
buffer += ',';
|
|
40
|
+
}
|
|
41
|
+
next = true;
|
|
42
|
+
// Property names are strings - Use ES6/JSON
|
|
43
|
+
buffer += JSON.stringify(property);
|
|
44
|
+
buffer += ':';
|
|
45
|
+
// Property value - Recursive expansion
|
|
46
|
+
serialize(object[property]);
|
|
47
|
+
});
|
|
48
|
+
buffer += '}';
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
export default canonicalize;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extensions.d.ts","sourceRoot":"","sources":["../../../src/oca_extensions/extensions.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"extensions.d.ts","sourceRoot":"","sources":["../../../src/oca_extensions/extensions.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAQzC,MAAM,WAAW,kBAAkB;IACjC,CAAC,SAAS,EAAE,MAAM,GAAG;QACnB,CAAC,aAAa,EAAE,IAAI,GAAG,UAAU,EAAE,CAAC;KACrC,CAAC;CACH;AAGD,MAAM,WAAW,eAAe;IAC9B,CAAC,SAAS,EAAE,MAAM,GAAG;QACnB,CAAC,aAAa,EAAE,IAAI,GAAG,UAAU,CAAC;KACnC,CAAC;CACH;AAED,qBAAa,cAAc;IACzB,OAAO,CAAC,qBAAqB,CAAqB;IAC3C,eAAe,EAAE,eAAe,CAAC;gBAE5B,kBAAkB,EAAE,kBAAkB;IAKlD,OAAO,CAAC,mBAAmB;IAiB3B,IAAW,WAAW,IAAI,eAAe,CAExC;CACF;AAKD,MAAM,WAAW,UAAU;IACzB,CAAC,OAAO,EAAE,MAAM,GAAG;QACjB,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;KACpB,CAAC;CACH;AAED,qBAAa,OAAQ,YAAW,UAAU;IACxC,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;gBAEP,iBAAiB,EAAE,UAAU;IAIlC,eAAe,IAAI,QAAQ,CAAC,UAAU,CAAC;CA0B/C;AAiFD,MAAM,WAAW,UAAU;IACzB,CAAC,EAAE,IAAI,CAAC;IACR,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,qBAAa,SAAU,YAAW,UAAU;IAC1C,QAAQ,CAAC,CAAC,EAAE,IAAI,CAAM;IACf,UAAU,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,UAAU,CAAC;IAC9B,QAAQ,CAAC,QAAQ,KAAM;gBAEX,iBAAiB,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM;IAU5D,OAAO,CAAC,gBAAgB;IAMxB,OAAO,CAAC,MAAM;IAQd,OAAO,CAAC,UAAU;IAKX,iBAAiB,IAAI,GAAG;CAGhC;AAED,KAAK,gBAAgB,GAAG;IAAE,CAAC,SAAS,EAAE,MAAM,GAAG;QAAE,CAAC,mBAAmB,EAAE,MAAM,GAAG,SAAS,CAAA;KAAE,CAAA;CAAE,CAAC;AAE9F,cAAM,YAAY;IACT,eAAe,EAAE,gBAAgB,CAAC;IAClC,WAAW,EAAE,GAAG,CAAC;IACjB,eAAe,EAAE,cAAc,CAAC;gBAE3B,oBAAoB,EAAE,kBAAkB,EAAE,UAAU,EAAE,GAAG;IAMrE,IAAW,kBAAkB,IAAI,gBAAgB,CA4BhD;CACF;AAED,eAAe,YAAY,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { DynOverlay } from '../../extensions.js';
|
|
2
|
+
export interface IExampleOverlay {
|
|
3
|
+
dynOverlay: DynOverlay;
|
|
4
|
+
GenerateExampleOverlay(): string;
|
|
5
|
+
}
|
|
6
|
+
declare class ExampleOverlay implements IExampleOverlay {
|
|
7
|
+
dynOverlay: DynOverlay;
|
|
8
|
+
constructor(dynOverlay: DynOverlay);
|
|
9
|
+
get language(): any;
|
|
10
|
+
private GetAttributeExamples;
|
|
11
|
+
private toJSON;
|
|
12
|
+
private Saidifying;
|
|
13
|
+
GenerateExampleOverlay(): string;
|
|
14
|
+
static GenerateOverlay(dynOverlay: {
|
|
15
|
+
example_overlays: any[];
|
|
16
|
+
}): string;
|
|
17
|
+
}
|
|
18
|
+
export default ExampleOverlay;
|
|
19
|
+
//# sourceMappingURL=example.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"example.d.ts","sourceRoot":"","sources":["../../../../../src/oca_extensions/state/overlays/example.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAIjD,MAAM,WAAW,eAAe;IAC9B,UAAU,EAAE,UAAU,CAAC;IACvB,sBAAsB,IAAI,MAAM,CAAC;CAClC;AAED,cAAM,cAAe,YAAW,eAAe;IACtC,UAAU,EAAE,UAAU,CAAC;gBAElB,UAAU,EAAE,UAAU;IAOlC,IAAW,QAAQ,IAAI,GAAG,CAEzB;IAED,OAAO,CAAC,oBAAoB;IAO5B,OAAO,CAAC,MAAM;IASd,OAAO,CAAC,UAAU;IAMX,sBAAsB,IAAI,MAAM;WAIzB,eAAe,CAAC,UAAU,EAAE;QAAE,gBAAgB,EAAE,GAAG,EAAE,CAAA;KAAE,GAAG,MAAM;CAqB/E;AAED,eAAe,cAAc,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unit_framing.d.ts","sourceRoot":"","sources":["../../../../../../src/oca_extensions/state/overlays/framing/unit_framing.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"unit_framing.d.ts","sourceRoot":"","sources":["../../../../../../src/oca_extensions/state/overlays/framing/unit_framing.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAOpD,MAAM,WAAW,YAAY;IAC3B,UAAU,EAAE,UAAU,CAAC;IACvB,eAAe,IAAI,MAAM,CAAC;CAC3B;AAED,cAAM,WAAY,YAAW,YAAY;IAChC,UAAU,EAAE,UAAU,CAAC;gBAElB,UAAU,EAAE,UAAU;IAQlC,OAAO,CAAC,QAAQ;IAMhB,OAAO,CAAC,KAAK;IAGb,OAAO,CAAC,QAAQ;IAGhB,OAAO,CAAC,WAAW;IAGnB,OAAO,CAAC,UAAU;IAGlB,OAAO,CAAC,MAAM;IAad,OAAO,CAAC,UAAU;IAIX,eAAe,IAAI,MAAM;CAGjC;AACD,eAAe,WAAW,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { DynOverlay } from '../../extensions.js';
|
|
2
|
+
export interface IRange {
|
|
3
|
+
dynOverlay: DynOverlay;
|
|
4
|
+
GenerateOverlay(): string;
|
|
5
|
+
}
|
|
6
|
+
declare class Range implements IRange {
|
|
7
|
+
dynOverlay: DynOverlay;
|
|
8
|
+
constructor(dynOverlay: DynOverlay);
|
|
9
|
+
private GetAttributes;
|
|
10
|
+
private toJSON;
|
|
11
|
+
private Saidifying;
|
|
12
|
+
GenerateOverlay(): string;
|
|
13
|
+
}
|
|
14
|
+
export default Range;
|
|
15
|
+
//# sourceMappingURL=range.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"range.d.ts","sourceRoot":"","sources":["../../../../../src/oca_extensions/state/overlays/range.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAIjD,MAAM,WAAW,MAAM;IACrB,UAAU,EAAE,UAAU,CAAC;IACvB,eAAe,IAAI,MAAM,CAAC;CAC3B;AAED,cAAM,KAAM,YAAW,MAAM;IACpB,UAAU,EAAE,UAAU,CAAC;gBAElB,UAAU,EAAE,UAAU;IAQlC,OAAO,CAAC,aAAa;IAQrB,OAAO,CAAC,MAAM;IAOd,OAAO,CAAC,UAAU;IAIX,eAAe,IAAI,MAAM;CAGjC;AACD,eAAe,KAAK,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
type JsonObject = {
|
|
2
|
+
[key: string]: JsonValue;
|
|
3
|
+
};
|
|
4
|
+
type JsonArray = JsonValue[];
|
|
5
|
+
type JsonValue = string | number | boolean | null | JsonObject | JsonArray;
|
|
6
|
+
/**
|
|
7
|
+
* Canonicalizes a JSON object by sorting its properties and maintaining the order of array elements.
|
|
8
|
+
* This function is useful for generating a consistent string representation of JSON data.
|
|
9
|
+
*
|
|
10
|
+
* @param {JsonValue} object - The JSON object to canonicalize.
|
|
11
|
+
* @returns {string} - The canonicalized string representation of the JSON object.
|
|
12
|
+
*/
|
|
13
|
+
declare const canonicalize: (object: JsonValue) => string;
|
|
14
|
+
export default canonicalize;
|
|
15
|
+
//# sourceMappingURL=canonical.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"canonical.d.ts","sourceRoot":"","sources":["../../../src/utils/canonical.ts"],"names":[],"mappings":"AAAA,KAAK,UAAU,GAAG;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE,CAAC;AAC/C,KAAK,SAAS,GAAG,SAAS,EAAE,CAAC;AAC7B,KAAK,SAAS,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,GAAG,UAAU,GAAG,SAAS,CAAC;AAE3E;;;;;;GAMG;AACH,QAAA,MAAM,YAAY,WAAY,SAAS,KAAG,MA0CzC,CAAC;AAEF,eAAe,YAAY,CAAC"}
|