proskomma-core 0.11.2 → 0.11.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +68 -26
- package/dist/index.mjs +68 -26
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -15992,7 +15992,7 @@ var bitset = { exports: {} };
|
|
|
15992
15992
|
var bitsetExports = bitset.exports;
|
|
15993
15993
|
const BitSet = /* @__PURE__ */ getDefaultExportFromCjs(bitsetExports);
|
|
15994
15994
|
const name = "proskomma-core";
|
|
15995
|
-
const version = "0.11.
|
|
15995
|
+
const version = "0.11.4";
|
|
15996
15996
|
const description$h = "A Scripture Runtime Engine";
|
|
15997
15997
|
const files = [
|
|
15998
15998
|
"dist"
|
|
@@ -16084,7 +16084,7 @@ const packageJson = {
|
|
|
16084
16084
|
dependencies: dependencies$1,
|
|
16085
16085
|
devDependencies
|
|
16086
16086
|
};
|
|
16087
|
-
const stringToUtf8ByteArray = function(str) {
|
|
16087
|
+
const stringToUtf8ByteArray$1 = function(str) {
|
|
16088
16088
|
var out = [], p = 0;
|
|
16089
16089
|
for (var i = 0; i < str.length; i++) {
|
|
16090
16090
|
var c = str.charCodeAt(i);
|
|
@@ -16133,7 +16133,7 @@ const utf8ByteArrayToString = function(bytes) {
|
|
|
16133
16133
|
};
|
|
16134
16134
|
var utf8StringBytes = {
|
|
16135
16135
|
utf8ByteArrayToString,
|
|
16136
|
-
stringToUtf8ByteArray
|
|
16136
|
+
stringToUtf8ByteArray: stringToUtf8ByteArray$1
|
|
16137
16137
|
};
|
|
16138
16138
|
var base64Js = {};
|
|
16139
16139
|
base64Js.byteLength = byteLength;
|
|
@@ -18917,19 +18917,36 @@ const recordPreEnum = (docSet, category, value) => {
|
|
|
18917
18917
|
docSet.preEnums[category].get(value).frequency++;
|
|
18918
18918
|
}
|
|
18919
18919
|
};
|
|
18920
|
+
const stringToUtf8ByteArray = (s) => {
|
|
18921
|
+
const encoder = new TextEncoder();
|
|
18922
|
+
return Array.from(encoder.encode(s));
|
|
18923
|
+
};
|
|
18920
18924
|
const buildEnum = (docSet, category, preEnumOb) => {
|
|
18921
18925
|
const sortedPreEnums = new Map([...preEnumOb.entries()]);
|
|
18922
18926
|
for (const enumText of sortedPreEnums.keys()) {
|
|
18923
|
-
|
|
18927
|
+
let truncatedText = enumText;
|
|
18928
|
+
const utf8Bytes = stringToUtf8ByteArray(enumText);
|
|
18929
|
+
if (utf8Bytes.length > 255) {
|
|
18924
18930
|
console.log(
|
|
18925
18931
|
"enum text for",
|
|
18926
18932
|
category,
|
|
18927
|
-
"has length",
|
|
18928
|
-
|
|
18929
|
-
"in buildEnum - truncating"
|
|
18933
|
+
"has byte length",
|
|
18934
|
+
utf8Bytes.length,
|
|
18935
|
+
"in buildEnum - truncating to 255 bytes"
|
|
18930
18936
|
);
|
|
18937
|
+
let byteCount = 0;
|
|
18938
|
+
let charCount = 0;
|
|
18939
|
+
for (const char of enumText) {
|
|
18940
|
+
const charBytes = stringToUtf8ByteArray(char).length;
|
|
18941
|
+
if (byteCount + charBytes > 255) {
|
|
18942
|
+
break;
|
|
18943
|
+
}
|
|
18944
|
+
byteCount += charBytes;
|
|
18945
|
+
charCount++;
|
|
18946
|
+
}
|
|
18947
|
+
truncatedText = enumText.substring(0, charCount);
|
|
18931
18948
|
}
|
|
18932
|
-
docSet.enums[category].pushCountedString(
|
|
18949
|
+
docSet.enums[category].pushCountedString(truncatedText);
|
|
18933
18950
|
}
|
|
18934
18951
|
docSet.enums[category].trim();
|
|
18935
18952
|
};
|
|
@@ -18949,7 +18966,22 @@ const enumForCategoryValue = (docSet, category, value, addUnknown) => {
|
|
|
18949
18966
|
enum: docSet.preEnums[category].size,
|
|
18950
18967
|
frequency: 1
|
|
18951
18968
|
});
|
|
18952
|
-
|
|
18969
|
+
let truncatedValue = value;
|
|
18970
|
+
const utf8Bytes = stringToUtf8ByteArray(value);
|
|
18971
|
+
if (utf8Bytes.length > 255) {
|
|
18972
|
+
let byteCount = 0;
|
|
18973
|
+
let charCount = 0;
|
|
18974
|
+
for (const char of value) {
|
|
18975
|
+
const charBytes = stringToUtf8ByteArray(char).length;
|
|
18976
|
+
if (byteCount + charBytes > 255) {
|
|
18977
|
+
break;
|
|
18978
|
+
}
|
|
18979
|
+
byteCount += charBytes;
|
|
18980
|
+
charCount++;
|
|
18981
|
+
}
|
|
18982
|
+
truncatedValue = value.substring(0, charCount);
|
|
18983
|
+
}
|
|
18984
|
+
docSet.enums[category].pushCountedString(truncatedValue);
|
|
18953
18985
|
docSet.buildEnumIndex(category);
|
|
18954
18986
|
return docSet.preEnums[category].get(value).enum;
|
|
18955
18987
|
} else {
|
|
@@ -43664,31 +43696,30 @@ const Block = class {
|
|
|
43664
43696
|
}
|
|
43665
43697
|
}
|
|
43666
43698
|
for (const swaStart of swaStarts) {
|
|
43699
|
+
const spanLabel = this.items[swaStart - 1].payload;
|
|
43700
|
+
const attPrefix = `attribute/${spanLabel}/`;
|
|
43667
43701
|
let pos = swaStart;
|
|
43668
|
-
let
|
|
43702
|
+
let others = [];
|
|
43669
43703
|
let scopes = [];
|
|
43670
|
-
while (
|
|
43671
|
-
if (pos >= this.items.length) {
|
|
43672
|
-
break;
|
|
43673
|
-
}
|
|
43704
|
+
while (pos < this.items.length) {
|
|
43674
43705
|
const item = this.items[pos];
|
|
43675
|
-
if (item.type === "
|
|
43676
|
-
|
|
43677
|
-
} else if (item.subType === "start" && item.payload.startsWith(
|
|
43706
|
+
if (item.type === "scope" && item.payload === spanLabel) {
|
|
43707
|
+
break;
|
|
43708
|
+
} else if (item.subType === "start" && item.payload.startsWith(attPrefix)) {
|
|
43678
43709
|
scopes.push(item);
|
|
43679
43710
|
} else {
|
|
43680
|
-
|
|
43711
|
+
others.push(item);
|
|
43681
43712
|
}
|
|
43682
43713
|
pos++;
|
|
43683
43714
|
}
|
|
43684
|
-
if (
|
|
43715
|
+
if (others.length !== 0 && scopes.length !== 0) {
|
|
43685
43716
|
let pos2 = swaStart;
|
|
43686
43717
|
for (const s of scopes) {
|
|
43687
43718
|
this.items[pos2] = s;
|
|
43688
43719
|
pos2++;
|
|
43689
43720
|
}
|
|
43690
|
-
for (const
|
|
43691
|
-
this.items[pos2] =
|
|
43721
|
+
for (const o of others) {
|
|
43722
|
+
this.items[pos2] = o;
|
|
43692
43723
|
pos2++;
|
|
43693
43724
|
}
|
|
43694
43725
|
}
|
|
@@ -44531,7 +44562,7 @@ const specs = (pt) => [
|
|
|
44531
44562
|
{
|
|
44532
44563
|
// END MILESTONE - close scope, clear attribute context
|
|
44533
44564
|
contexts: [["endMilestoneMarker"]],
|
|
44534
|
-
parser: { during: (parser) => parser.clearAttributeContext() }
|
|
44565
|
+
parser: { during: (parser) => parser.clearAttributeContext("milestone") }
|
|
44535
44566
|
},
|
|
44536
44567
|
{
|
|
44537
44568
|
// ATTRIBUTE - open scope based on attribute context
|
|
@@ -44689,7 +44720,9 @@ const Parser2 = class {
|
|
|
44689
44720
|
parentSequence: null,
|
|
44690
44721
|
baseSequenceType: "main",
|
|
44691
44722
|
inlineSequenceType: null,
|
|
44692
|
-
attributeContext: null
|
|
44723
|
+
attributeContext: null,
|
|
44724
|
+
spanAttributeContext: null,
|
|
44725
|
+
milestoneAttributeContext: null
|
|
44693
44726
|
};
|
|
44694
44727
|
}
|
|
44695
44728
|
parseItem(lexedItem) {
|
|
@@ -45098,11 +45131,20 @@ const Parser2 = class {
|
|
|
45098
45131
|
payload: label
|
|
45099
45132
|
});
|
|
45100
45133
|
}
|
|
45134
|
+
// Milestones may sit inside spans with attributes (eg \w ... \zx-s |a="b"\* ... \zx-e\* |lemma="c"\w*),
|
|
45135
|
+
// so keep separate contexts for each, with the milestone context taking priority while it is open
|
|
45101
45136
|
setAttributeContext(label) {
|
|
45102
|
-
|
|
45137
|
+
const contextKey = label.startsWith("milestone") ? "milestoneAttributeContext" : "spanAttributeContext";
|
|
45138
|
+
this.current[contextKey] = label;
|
|
45139
|
+
this.updateAttributeContext();
|
|
45140
|
+
}
|
|
45141
|
+
clearAttributeContext(scopeType) {
|
|
45142
|
+
const contextKey = scopeType === "milestone" ? "milestoneAttributeContext" : "spanAttributeContext";
|
|
45143
|
+
this.current[contextKey] = null;
|
|
45144
|
+
this.updateAttributeContext();
|
|
45103
45145
|
}
|
|
45104
|
-
|
|
45105
|
-
this.current.attributeContext = null;
|
|
45146
|
+
updateAttributeContext() {
|
|
45147
|
+
this.current.attributeContext = this.current.milestoneAttributeContext || this.current.spanAttributeContext || null;
|
|
45106
45148
|
}
|
|
45107
45149
|
};
|
|
45108
45150
|
const ByteArray$2 = utils.ByteArray;
|
package/dist/index.mjs
CHANGED
|
@@ -15990,7 +15990,7 @@ var bitset = { exports: {} };
|
|
|
15990
15990
|
var bitsetExports = bitset.exports;
|
|
15991
15991
|
const BitSet = /* @__PURE__ */ getDefaultExportFromCjs(bitsetExports);
|
|
15992
15992
|
const name = "proskomma-core";
|
|
15993
|
-
const version = "0.11.
|
|
15993
|
+
const version = "0.11.4";
|
|
15994
15994
|
const description$h = "A Scripture Runtime Engine";
|
|
15995
15995
|
const files = [
|
|
15996
15996
|
"dist"
|
|
@@ -16082,7 +16082,7 @@ const packageJson = {
|
|
|
16082
16082
|
dependencies: dependencies$1,
|
|
16083
16083
|
devDependencies
|
|
16084
16084
|
};
|
|
16085
|
-
const stringToUtf8ByteArray = function(str) {
|
|
16085
|
+
const stringToUtf8ByteArray$1 = function(str) {
|
|
16086
16086
|
var out = [], p = 0;
|
|
16087
16087
|
for (var i = 0; i < str.length; i++) {
|
|
16088
16088
|
var c = str.charCodeAt(i);
|
|
@@ -16131,7 +16131,7 @@ const utf8ByteArrayToString = function(bytes) {
|
|
|
16131
16131
|
};
|
|
16132
16132
|
var utf8StringBytes = {
|
|
16133
16133
|
utf8ByteArrayToString,
|
|
16134
|
-
stringToUtf8ByteArray
|
|
16134
|
+
stringToUtf8ByteArray: stringToUtf8ByteArray$1
|
|
16135
16135
|
};
|
|
16136
16136
|
var base64Js = {};
|
|
16137
16137
|
base64Js.byteLength = byteLength;
|
|
@@ -18915,19 +18915,36 @@ const recordPreEnum = (docSet, category, value) => {
|
|
|
18915
18915
|
docSet.preEnums[category].get(value).frequency++;
|
|
18916
18916
|
}
|
|
18917
18917
|
};
|
|
18918
|
+
const stringToUtf8ByteArray = (s) => {
|
|
18919
|
+
const encoder = new TextEncoder();
|
|
18920
|
+
return Array.from(encoder.encode(s));
|
|
18921
|
+
};
|
|
18918
18922
|
const buildEnum = (docSet, category, preEnumOb) => {
|
|
18919
18923
|
const sortedPreEnums = new Map([...preEnumOb.entries()]);
|
|
18920
18924
|
for (const enumText of sortedPreEnums.keys()) {
|
|
18921
|
-
|
|
18925
|
+
let truncatedText = enumText;
|
|
18926
|
+
const utf8Bytes = stringToUtf8ByteArray(enumText);
|
|
18927
|
+
if (utf8Bytes.length > 255) {
|
|
18922
18928
|
console.log(
|
|
18923
18929
|
"enum text for",
|
|
18924
18930
|
category,
|
|
18925
|
-
"has length",
|
|
18926
|
-
|
|
18927
|
-
"in buildEnum - truncating"
|
|
18931
|
+
"has byte length",
|
|
18932
|
+
utf8Bytes.length,
|
|
18933
|
+
"in buildEnum - truncating to 255 bytes"
|
|
18928
18934
|
);
|
|
18935
|
+
let byteCount = 0;
|
|
18936
|
+
let charCount = 0;
|
|
18937
|
+
for (const char of enumText) {
|
|
18938
|
+
const charBytes = stringToUtf8ByteArray(char).length;
|
|
18939
|
+
if (byteCount + charBytes > 255) {
|
|
18940
|
+
break;
|
|
18941
|
+
}
|
|
18942
|
+
byteCount += charBytes;
|
|
18943
|
+
charCount++;
|
|
18944
|
+
}
|
|
18945
|
+
truncatedText = enumText.substring(0, charCount);
|
|
18929
18946
|
}
|
|
18930
|
-
docSet.enums[category].pushCountedString(
|
|
18947
|
+
docSet.enums[category].pushCountedString(truncatedText);
|
|
18931
18948
|
}
|
|
18932
18949
|
docSet.enums[category].trim();
|
|
18933
18950
|
};
|
|
@@ -18947,7 +18964,22 @@ const enumForCategoryValue = (docSet, category, value, addUnknown) => {
|
|
|
18947
18964
|
enum: docSet.preEnums[category].size,
|
|
18948
18965
|
frequency: 1
|
|
18949
18966
|
});
|
|
18950
|
-
|
|
18967
|
+
let truncatedValue = value;
|
|
18968
|
+
const utf8Bytes = stringToUtf8ByteArray(value);
|
|
18969
|
+
if (utf8Bytes.length > 255) {
|
|
18970
|
+
let byteCount = 0;
|
|
18971
|
+
let charCount = 0;
|
|
18972
|
+
for (const char of value) {
|
|
18973
|
+
const charBytes = stringToUtf8ByteArray(char).length;
|
|
18974
|
+
if (byteCount + charBytes > 255) {
|
|
18975
|
+
break;
|
|
18976
|
+
}
|
|
18977
|
+
byteCount += charBytes;
|
|
18978
|
+
charCount++;
|
|
18979
|
+
}
|
|
18980
|
+
truncatedValue = value.substring(0, charCount);
|
|
18981
|
+
}
|
|
18982
|
+
docSet.enums[category].pushCountedString(truncatedValue);
|
|
18951
18983
|
docSet.buildEnumIndex(category);
|
|
18952
18984
|
return docSet.preEnums[category].get(value).enum;
|
|
18953
18985
|
} else {
|
|
@@ -43662,31 +43694,30 @@ const Block = class {
|
|
|
43662
43694
|
}
|
|
43663
43695
|
}
|
|
43664
43696
|
for (const swaStart of swaStarts) {
|
|
43697
|
+
const spanLabel = this.items[swaStart - 1].payload;
|
|
43698
|
+
const attPrefix = `attribute/${spanLabel}/`;
|
|
43665
43699
|
let pos = swaStart;
|
|
43666
|
-
let
|
|
43700
|
+
let others = [];
|
|
43667
43701
|
let scopes = [];
|
|
43668
|
-
while (
|
|
43669
|
-
if (pos >= this.items.length) {
|
|
43670
|
-
break;
|
|
43671
|
-
}
|
|
43702
|
+
while (pos < this.items.length) {
|
|
43672
43703
|
const item = this.items[pos];
|
|
43673
|
-
if (item.type === "
|
|
43674
|
-
|
|
43675
|
-
} else if (item.subType === "start" && item.payload.startsWith(
|
|
43704
|
+
if (item.type === "scope" && item.payload === spanLabel) {
|
|
43705
|
+
break;
|
|
43706
|
+
} else if (item.subType === "start" && item.payload.startsWith(attPrefix)) {
|
|
43676
43707
|
scopes.push(item);
|
|
43677
43708
|
} else {
|
|
43678
|
-
|
|
43709
|
+
others.push(item);
|
|
43679
43710
|
}
|
|
43680
43711
|
pos++;
|
|
43681
43712
|
}
|
|
43682
|
-
if (
|
|
43713
|
+
if (others.length !== 0 && scopes.length !== 0) {
|
|
43683
43714
|
let pos2 = swaStart;
|
|
43684
43715
|
for (const s of scopes) {
|
|
43685
43716
|
this.items[pos2] = s;
|
|
43686
43717
|
pos2++;
|
|
43687
43718
|
}
|
|
43688
|
-
for (const
|
|
43689
|
-
this.items[pos2] =
|
|
43719
|
+
for (const o of others) {
|
|
43720
|
+
this.items[pos2] = o;
|
|
43690
43721
|
pos2++;
|
|
43691
43722
|
}
|
|
43692
43723
|
}
|
|
@@ -44529,7 +44560,7 @@ const specs = (pt) => [
|
|
|
44529
44560
|
{
|
|
44530
44561
|
// END MILESTONE - close scope, clear attribute context
|
|
44531
44562
|
contexts: [["endMilestoneMarker"]],
|
|
44532
|
-
parser: { during: (parser) => parser.clearAttributeContext() }
|
|
44563
|
+
parser: { during: (parser) => parser.clearAttributeContext("milestone") }
|
|
44533
44564
|
},
|
|
44534
44565
|
{
|
|
44535
44566
|
// ATTRIBUTE - open scope based on attribute context
|
|
@@ -44687,7 +44718,9 @@ const Parser2 = class {
|
|
|
44687
44718
|
parentSequence: null,
|
|
44688
44719
|
baseSequenceType: "main",
|
|
44689
44720
|
inlineSequenceType: null,
|
|
44690
|
-
attributeContext: null
|
|
44721
|
+
attributeContext: null,
|
|
44722
|
+
spanAttributeContext: null,
|
|
44723
|
+
milestoneAttributeContext: null
|
|
44691
44724
|
};
|
|
44692
44725
|
}
|
|
44693
44726
|
parseItem(lexedItem) {
|
|
@@ -45096,11 +45129,20 @@ const Parser2 = class {
|
|
|
45096
45129
|
payload: label
|
|
45097
45130
|
});
|
|
45098
45131
|
}
|
|
45132
|
+
// Milestones may sit inside spans with attributes (eg \w ... \zx-s |a="b"\* ... \zx-e\* |lemma="c"\w*),
|
|
45133
|
+
// so keep separate contexts for each, with the milestone context taking priority while it is open
|
|
45099
45134
|
setAttributeContext(label) {
|
|
45100
|
-
|
|
45135
|
+
const contextKey = label.startsWith("milestone") ? "milestoneAttributeContext" : "spanAttributeContext";
|
|
45136
|
+
this.current[contextKey] = label;
|
|
45137
|
+
this.updateAttributeContext();
|
|
45138
|
+
}
|
|
45139
|
+
clearAttributeContext(scopeType) {
|
|
45140
|
+
const contextKey = scopeType === "milestone" ? "milestoneAttributeContext" : "spanAttributeContext";
|
|
45141
|
+
this.current[contextKey] = null;
|
|
45142
|
+
this.updateAttributeContext();
|
|
45101
45143
|
}
|
|
45102
|
-
|
|
45103
|
-
this.current.attributeContext = null;
|
|
45144
|
+
updateAttributeContext() {
|
|
45145
|
+
this.current.attributeContext = this.current.milestoneAttributeContext || this.current.spanAttributeContext || null;
|
|
45104
45146
|
}
|
|
45105
45147
|
};
|
|
45106
45148
|
const ByteArray$2 = utils.ByteArray;
|