documents.js 1.63.0 → 1.64.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.
Files changed (177) hide show
  1. package/README.md +113 -20
  2. package/dist/convert/convert.cjs +3 -3
  3. package/dist/convert/convert.d.cts +5 -2
  4. package/dist/convert/convert.d.ts +4 -1
  5. package/dist/convert/convert.js +3 -3
  6. package/dist/edit/docx/content.d.cts +1 -1
  7. package/dist/edit/docx/content.d.ts +1 -1
  8. package/dist/edit/docx/paragraph.d.cts +3 -3
  9. package/dist/edit/docx/paragraph.d.ts +3 -3
  10. package/dist/edit/ods/address.cjs +42 -24
  11. package/dist/edit/ods/address.d.cts +12 -2
  12. package/dist/edit/ods/address.d.ts +12 -2
  13. package/dist/edit/ods/address.js +39 -25
  14. package/dist/edit/ods/column-row.cjs +68 -6
  15. package/dist/edit/ods/column-row.d.cts +5 -1
  16. package/dist/edit/ods/column-row.d.ts +5 -1
  17. package/dist/edit/ods/column-row.js +68 -10
  18. package/dist/edit/ods/content.cjs +10 -2
  19. package/dist/edit/ods/content.js +10 -2
  20. package/dist/edit/ods/floating.cjs +90 -0
  21. package/dist/edit/ods/floating.d.cts +7 -0
  22. package/dist/edit/ods/floating.d.ts +7 -0
  23. package/dist/edit/ods/floating.js +88 -0
  24. package/dist/edit/ods/print-settings.cjs +158 -2
  25. package/dist/edit/ods/print-settings.js +159 -3
  26. package/dist/edit/ods/sheet.cjs +13 -0
  27. package/dist/edit/ods/sheet.d.cts +5 -1
  28. package/dist/edit/ods/sheet.d.ts +5 -1
  29. package/dist/edit/ods/sheet.js +14 -1
  30. package/dist/edit/odt/content.cjs +8 -4
  31. package/dist/edit/odt/content.js +8 -4
  32. package/dist/edit/odt/editor.cjs +7 -0
  33. package/dist/edit/odt/editor.d.cts +3 -0
  34. package/dist/edit/odt/editor.d.ts +3 -0
  35. package/dist/edit/odt/editor.js +7 -0
  36. package/dist/edit/odt/formula.cjs +19 -0
  37. package/dist/edit/odt/formula.d.cts +8 -0
  38. package/dist/edit/odt/formula.d.ts +8 -0
  39. package/dist/edit/odt/formula.js +17 -0
  40. package/dist/evaluate-BU5N1Jk1.d.ts +11 -0
  41. package/dist/evaluate-BhMXY6DM.d.cts +11 -0
  42. package/dist/firebird/backup.d.cts +1 -1
  43. package/dist/firebird/backup.d.ts +1 -1
  44. package/dist/firebird/data.cjs +30 -16
  45. package/dist/firebird/data.d.cts +3 -2
  46. package/dist/firebird/data.d.ts +3 -2
  47. package/dist/firebird/data.js +30 -17
  48. package/dist/fonts/ooxml.d.cts +1 -1
  49. package/dist/fonts/registry.d.cts +1 -1
  50. package/dist/formula-CgydMiTt.d.ts +10 -0
  51. package/dist/formula-CiwPw8nY.d.cts +10 -0
  52. package/dist/hsqldb/binary-script.d.cts +1 -1
  53. package/dist/hsqldb/binary-script.d.ts +1 -1
  54. package/dist/hsqldb/cache.d.cts +1 -1
  55. package/dist/hsqldb/cache.d.ts +1 -1
  56. package/dist/hsqldb/rowformat.cjs +22 -13
  57. package/dist/hsqldb/rowformat.js +22 -13
  58. package/dist/hsqldb/script.d.cts +1 -18
  59. package/dist/hsqldb/script.d.ts +1 -18
  60. package/dist/index.cjs +56 -0
  61. package/dist/index.d.cts +22 -8
  62. package/dist/index.d.ts +21 -7
  63. package/dist/index.js +15 -2
  64. package/dist/layout/sheets.cjs +30 -24
  65. package/dist/layout/sheets.js +31 -25
  66. package/dist/layout/slides.cjs +6 -4
  67. package/dist/layout/slides.js +7 -5
  68. package/dist/lexer-DGPWx_f2.d.cts +42 -0
  69. package/dist/lexer-DGPWx_f2.d.ts +42 -0
  70. package/dist/mathml/layout.d.cts +1 -1
  71. package/dist/mathml/layout.d.ts +1 -1
  72. package/dist/mathml/variant.d.cts +1 -6
  73. package/dist/mathml/variant.d.ts +1 -6
  74. package/dist/odb/csv.d.cts +1 -1
  75. package/dist/odb/csv.d.ts +1 -1
  76. package/dist/odb/formula/definition.cjs +49 -0
  77. package/dist/odb/formula/definition.d.cts +8 -0
  78. package/dist/odb/formula/definition.d.ts +8 -0
  79. package/dist/odb/formula/definition.js +46 -0
  80. package/dist/odb/formula/errors.cjs +47 -0
  81. package/dist/odb/formula/errors.d.cts +21 -0
  82. package/dist/odb/formula/errors.d.ts +21 -0
  83. package/dist/odb/formula/errors.js +43 -0
  84. package/dist/odb/formula/evaluate.cjs +283 -0
  85. package/dist/odb/formula/evaluate.d.cts +43 -0
  86. package/dist/odb/formula/evaluate.d.ts +43 -0
  87. package/dist/odb/formula/evaluate.js +281 -0
  88. package/dist/odb/formula/parser.cjs +198 -0
  89. package/dist/odb/formula/parser.d.cts +29 -0
  90. package/dist/odb/formula/parser.d.ts +29 -0
  91. package/dist/odb/formula/parser.js +197 -0
  92. package/dist/odb/read.d.cts +1 -1
  93. package/dist/odb/read.d.ts +1 -1
  94. package/dist/odb/report/content.cjs +27 -0
  95. package/dist/odb/report/content.d.cts +14 -0
  96. package/dist/odb/report/content.d.ts +14 -0
  97. package/dist/odb/report/content.js +25 -0
  98. package/dist/odb/report/render.cjs +106 -0
  99. package/dist/odb/report/render.d.cts +7 -0
  100. package/dist/odb/report/render.d.ts +7 -0
  101. package/dist/odb/report/render.js +106 -0
  102. package/dist/odb/report/source.cjs +45 -0
  103. package/dist/odb/report/source.d.cts +14 -0
  104. package/dist/odb/report/source.d.ts +14 -0
  105. package/dist/odb/report/source.js +42 -0
  106. package/dist/odb/spreadsheet.d.cts +1 -1
  107. package/dist/odb/spreadsheet.d.ts +1 -1
  108. package/dist/odb/sql/errors.cjs +38 -0
  109. package/dist/odb/sql/errors.d.cts +17 -0
  110. package/dist/odb/sql/errors.d.ts +17 -0
  111. package/dist/odb/sql/errors.js +35 -0
  112. package/dist/odb/sql/evaluate.cjs +312 -0
  113. package/dist/odb/sql/evaluate.d.cts +2 -0
  114. package/dist/odb/sql/evaluate.d.ts +2 -0
  115. package/dist/odb/sql/evaluate.js +311 -0
  116. package/dist/odb/sql/lexer.cjs +282 -0
  117. package/dist/odb/sql/lexer.d.cts +2 -0
  118. package/dist/odb/sql/lexer.d.ts +2 -0
  119. package/dist/odb/sql/lexer.js +281 -0
  120. package/dist/odb/sql/parser.cjs +479 -0
  121. package/dist/odb/sql/parser.d.cts +2 -0
  122. package/dist/odb/sql/parser.d.ts +2 -0
  123. package/dist/odb/sql/parser.js +478 -0
  124. package/dist/odb/values.cjs +75 -0
  125. package/dist/odb/values.d.cts +2 -0
  126. package/dist/odb/values.d.ts +2 -0
  127. package/dist/odb/values.js +69 -0
  128. package/dist/odf/odt/read.cjs +43 -21
  129. package/dist/odf/odt/read.js +43 -21
  130. package/dist/odf-package/formula.cjs +59 -0
  131. package/dist/odf-package/formula.d.cts +11 -0
  132. package/dist/odf-package/formula.d.ts +11 -0
  133. package/dist/odf-package/formula.js +58 -0
  134. package/dist/odf-package/manifest.cjs +29 -0
  135. package/dist/odf-package/manifest.d.cts +5 -2
  136. package/dist/odf-package/manifest.d.ts +5 -2
  137. package/dist/odf-package/manifest.js +30 -2
  138. package/dist/odf-package/media.cjs +2 -1
  139. package/dist/odf-package/media.js +2 -2
  140. package/dist/omml/read.cjs +265 -0
  141. package/dist/omml/read.d.cts +12 -0
  142. package/dist/omml/read.d.ts +12 -0
  143. package/dist/omml/read.js +263 -0
  144. package/dist/omml/shared.cjs +67 -0
  145. package/dist/omml/shared.d.cts +2 -0
  146. package/dist/omml/shared.d.ts +2 -0
  147. package/dist/omml/shared.js +64 -0
  148. package/dist/omml/write.cjs +3 -51
  149. package/dist/omml/write.d.cts +2 -2
  150. package/dist/omml/write.d.ts +2 -2
  151. package/dist/omml/write.js +1 -49
  152. package/dist/ooxml/docx/extras.cjs +15 -0
  153. package/dist/ooxml/docx/extras.d.cts +12 -0
  154. package/dist/ooxml/docx/extras.d.ts +12 -0
  155. package/dist/ooxml/docx/extras.js +14 -0
  156. package/dist/ooxml/docx/formula.cjs +109 -0
  157. package/dist/ooxml/docx/formula.d.cts +2 -0
  158. package/dist/ooxml/docx/formula.d.ts +2 -0
  159. package/dist/ooxml/docx/formula.js +108 -0
  160. package/dist/ooxml/docx/read.cjs +10 -2
  161. package/dist/ooxml/docx/read.d.cts +6 -2
  162. package/dist/ooxml/docx/read.d.ts +6 -2
  163. package/dist/ooxml/docx/read.js +11 -3
  164. package/dist/parser-B9vC1T6T.d.cts +101 -0
  165. package/dist/parser-DQSgYJzQ.d.ts +101 -0
  166. package/dist/{registry-CtPhMD0f.d.cts → registry-lqJej0Jr.d.cts} +1 -1
  167. package/dist/script-DsGGIzGU.d.cts +19 -0
  168. package/dist/script-DsGGIzGU.d.ts +19 -0
  169. package/dist/shared-DLZ3IQUl.d.cts +15 -0
  170. package/dist/shared-DUOzjwcL.d.ts +15 -0
  171. package/dist/values-BetetbaH.d.cts +23 -0
  172. package/dist/values-BetetbaH.d.ts +23 -0
  173. package/dist/variant-BMrebjMw.d.cts +7 -0
  174. package/dist/variant-BMrebjMw.d.ts +7 -0
  175. package/dist/{write-DuyfnbL_.d.cts → write-BQ6SK8r8.d.cts} +2 -6
  176. package/dist/{write-Zqwx6pka.d.ts → write-THs7ipBq.d.ts} +2 -6
  177. package/package.json +1 -1
@@ -0,0 +1,281 @@
1
+ import { HsqldbSqlParseError, HsqldbSqlUnsupportedError } from "./errors.js";
2
+ //#region src/odb/sql/lexer.ts
3
+ const KEYWORDS = /* @__PURE__ */ new Set([
4
+ "SELECT",
5
+ "FROM",
6
+ "WHERE",
7
+ "GROUP",
8
+ "BY",
9
+ "ORDER",
10
+ "ASC",
11
+ "DESC",
12
+ "AND",
13
+ "OR",
14
+ "NOT",
15
+ "IS",
16
+ "NULL",
17
+ "LIKE",
18
+ "IN",
19
+ "BETWEEN",
20
+ "TRUE",
21
+ "FALSE",
22
+ "COUNT",
23
+ "SUM",
24
+ "AVG",
25
+ "MIN",
26
+ "MAX",
27
+ "JOIN",
28
+ "INNER",
29
+ "OUTER",
30
+ "LEFT",
31
+ "RIGHT",
32
+ "FULL",
33
+ "CROSS",
34
+ "NATURAL",
35
+ "ON",
36
+ "USING",
37
+ "UNION",
38
+ "INTERSECT",
39
+ "EXCEPT",
40
+ "MINUS",
41
+ "DISTINCT",
42
+ "ALL",
43
+ "HAVING",
44
+ "LIMIT",
45
+ "OFFSET",
46
+ "FETCH",
47
+ "TOP",
48
+ "AS",
49
+ "CASE",
50
+ "WHEN",
51
+ "THEN",
52
+ "ELSE",
53
+ "END",
54
+ "EXISTS",
55
+ "ANY",
56
+ "SOME",
57
+ "WITH",
58
+ "INSERT",
59
+ "UPDATE",
60
+ "DELETE",
61
+ "CREATE",
62
+ "DROP",
63
+ "ALTER",
64
+ "INTO",
65
+ "VALUES",
66
+ "SET",
67
+ "ESCAPE",
68
+ "COLLATE",
69
+ "NULLS",
70
+ "FIRST",
71
+ "LAST"
72
+ ]);
73
+ const UNSUPPORTED_SYMBOLS = [
74
+ ["--", "a SQL line comment"],
75
+ ["/*", "a SQL block comment"],
76
+ ["||", "the || string-concatenation operator"],
77
+ ["!=", "the != operator (write <> instead)"],
78
+ ["+", "an arithmetic expression"],
79
+ ["/", "an arithmetic expression"],
80
+ ["%", "an arithmetic expression"],
81
+ ["?", "a parameter placeholder"],
82
+ [":", "a named parameter"],
83
+ ["@", "a variable reference"],
84
+ ["#", "a variable reference"],
85
+ ["&", "a bitwise operator"],
86
+ ["|", "a bitwise operator"],
87
+ ["^", "a bitwise operator"],
88
+ ["~", "a bitwise operator"],
89
+ ["!", "the ! operator"]
90
+ ];
91
+ function isDigit(character) {
92
+ return character >= "0" && character <= "9";
93
+ }
94
+ function isIdentifierStart(character) {
95
+ return character >= "A" && character <= "Z" || character >= "a" && character <= "z" || character === "_";
96
+ }
97
+ function isIdentifierPart(character) {
98
+ return isIdentifierStart(character) || isDigit(character) || character === "$";
99
+ }
100
+ function isWhitespace(character) {
101
+ return character === " " || character === " " || character === "\n" || character === "\r" || character === "\f" || character === "\v";
102
+ }
103
+ function readNumber(sql, start) {
104
+ let cursor = start;
105
+ while (cursor < sql.length && isDigit(sql.charAt(cursor))) cursor += 1;
106
+ if (cursor < sql.length && sql.charAt(cursor) === ".") {
107
+ cursor += 1;
108
+ while (cursor < sql.length && isDigit(sql.charAt(cursor))) cursor += 1;
109
+ }
110
+ if (cursor < sql.length && (sql.charAt(cursor) === "e" || sql.charAt(cursor) === "E")) {
111
+ const exponentStart = cursor;
112
+ cursor += 1;
113
+ if (cursor < sql.length && (sql.charAt(cursor) === "+" || sql.charAt(cursor) === "-")) cursor += 1;
114
+ if (cursor < sql.length && isDigit(sql.charAt(cursor))) while (cursor < sql.length && isDigit(sql.charAt(cursor))) cursor += 1;
115
+ else cursor = exponentStart;
116
+ }
117
+ const text = sql.slice(start, cursor);
118
+ const value = Number(text);
119
+ if (!Number.isFinite(value)) throw new HsqldbSqlParseError(`numeric literal "${text}" is not a finite number`, sql, start);
120
+ return {
121
+ value,
122
+ next: cursor
123
+ };
124
+ }
125
+ function readStringLiteral(sql, start) {
126
+ let cursor = start + 1;
127
+ let value = "";
128
+ while (cursor < sql.length) {
129
+ const character = sql.charAt(cursor);
130
+ if (character === "'") {
131
+ if (sql.charAt(cursor + 1) === "'") {
132
+ value += "'";
133
+ cursor += 2;
134
+ continue;
135
+ }
136
+ return {
137
+ value,
138
+ next: cursor + 1
139
+ };
140
+ }
141
+ value += character;
142
+ cursor += 1;
143
+ }
144
+ throw new HsqldbSqlParseError("unterminated string literal", sql, start);
145
+ }
146
+ function readQuotedIdentifier(sql, start) {
147
+ let cursor = start + 1;
148
+ let name = "";
149
+ while (cursor < sql.length) {
150
+ const character = sql.charAt(cursor);
151
+ if (character === "\"") {
152
+ if (sql.charAt(cursor + 1) === "\"") {
153
+ name += "\"";
154
+ cursor += 2;
155
+ continue;
156
+ }
157
+ if (name === "") throw new HsqldbSqlParseError("empty quoted identifier (\"\")", sql, start);
158
+ return {
159
+ name,
160
+ next: cursor + 1
161
+ };
162
+ }
163
+ name += character;
164
+ cursor += 1;
165
+ }
166
+ throw new HsqldbSqlParseError("unterminated quoted identifier", sql, start);
167
+ }
168
+ function unsupportedSymbolAt(sql, cursor) {
169
+ for (const [symbol, construct] of UNSUPPORTED_SYMBOLS) if (sql.startsWith(symbol, cursor)) return construct;
170
+ }
171
+ function tokenizeSql(sql) {
172
+ const tokens = [];
173
+ let cursor = 0;
174
+ while (cursor < sql.length) {
175
+ const character = sql.charAt(cursor);
176
+ if (isWhitespace(character)) {
177
+ cursor += 1;
178
+ continue;
179
+ }
180
+ if (character === "'") {
181
+ const start = cursor;
182
+ const literal = readStringLiteral(sql, cursor);
183
+ cursor = literal.next;
184
+ tokens.push({
185
+ kind: "string",
186
+ value: literal.value,
187
+ text: sql.slice(start, cursor),
188
+ start
189
+ });
190
+ continue;
191
+ }
192
+ if (character === "\"") {
193
+ const start = cursor;
194
+ const identifier = readQuotedIdentifier(sql, cursor);
195
+ cursor = identifier.next;
196
+ tokens.push({
197
+ kind: "identifier",
198
+ name: identifier.name,
199
+ quoted: true,
200
+ text: sql.slice(start, cursor),
201
+ start
202
+ });
203
+ continue;
204
+ }
205
+ if (isDigit(character) || character === "." && isDigit(sql.charAt(cursor + 1))) {
206
+ const start = cursor;
207
+ const numeric = readNumber(sql, cursor);
208
+ cursor = numeric.next;
209
+ tokens.push({
210
+ kind: "number",
211
+ value: numeric.value,
212
+ text: sql.slice(start, cursor),
213
+ start
214
+ });
215
+ continue;
216
+ }
217
+ if (isIdentifierStart(character)) {
218
+ const start = cursor;
219
+ while (cursor < sql.length && isIdentifierPart(sql.charAt(cursor))) cursor += 1;
220
+ const text = sql.slice(start, cursor);
221
+ const folded = text.toUpperCase();
222
+ if (KEYWORDS.has(folded)) tokens.push({
223
+ kind: "keyword",
224
+ keyword: folded,
225
+ text,
226
+ start
227
+ });
228
+ else tokens.push({
229
+ kind: "identifier",
230
+ name: folded,
231
+ quoted: false,
232
+ text,
233
+ start
234
+ });
235
+ continue;
236
+ }
237
+ if (character === "<" || character === ">" || character === "=") {
238
+ const start = cursor;
239
+ const twoCharacter = sql.slice(cursor, cursor + 2);
240
+ if (twoCharacter === "<=" || twoCharacter === ">=" || twoCharacter === "<>") {
241
+ cursor += 2;
242
+ tokens.push({
243
+ kind: "operator",
244
+ operator: twoCharacter,
245
+ text: twoCharacter,
246
+ start
247
+ });
248
+ continue;
249
+ }
250
+ cursor += 1;
251
+ tokens.push({
252
+ kind: "operator",
253
+ operator: character,
254
+ text: character,
255
+ start
256
+ });
257
+ continue;
258
+ }
259
+ const unsupported = unsupportedSymbolAt(sql, cursor);
260
+ if (unsupported !== void 0) throw new HsqldbSqlUnsupportedError(unsupported, sql);
261
+ if (character === "(" || character === ")" || character === "," || character === "." || character === "*" || character === ";" || character === "-") {
262
+ tokens.push({
263
+ kind: "punctuation",
264
+ punctuation: character,
265
+ text: character,
266
+ start: cursor
267
+ });
268
+ cursor += 1;
269
+ continue;
270
+ }
271
+ throw new HsqldbSqlParseError(`unexpected character "${character}"`, sql, cursor);
272
+ }
273
+ tokens.push({
274
+ kind: "end",
275
+ text: "",
276
+ start: sql.length
277
+ });
278
+ return tokens;
279
+ }
280
+ //#endregion
281
+ export { tokenizeSql };