tamedevil 0.1.0-rc.2 → 0.1.0-rc.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/CHANGELOG.md +31 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +28 -28
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,36 @@
|
|
|
1
1
|
# tamedevil
|
|
2
2
|
|
|
3
|
+
## 0.1.0-rc.4
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`a3722d6`](https://github.com/graphile/crystal/commit/a3722d613bc6fb9e32f167aae9a31eaa422ceef1)
|
|
8
|
+
Thanks [@benjie](https://github.com/benjie)! - Refactor to enable TypeScript
|
|
9
|
+
options rewriteRelativeImportExtensions and erasableSyntaxOnly (including
|
|
10
|
+
using .ts extensions in source code)
|
|
11
|
+
- Updated dependencies
|
|
12
|
+
[[`a3722d6`](https://github.com/graphile/crystal/commit/a3722d613bc6fb9e32f167aae9a31eaa422ceef1)]:
|
|
13
|
+
- @graphile/lru@5.0.0-rc.4
|
|
14
|
+
|
|
15
|
+
## 0.1.0-rc.3
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- [#2873](https://github.com/graphile/crystal/pull/2873)
|
|
20
|
+
[`0772086`](https://github.com/graphile/crystal/commit/0772086411a55d56b4e345cff1eef133eee31b36)
|
|
21
|
+
Thanks [@benjie](https://github.com/benjie)! - Update TypeScript configuration
|
|
22
|
+
to support Node 22 minimum
|
|
23
|
+
|
|
24
|
+
- [#2888](https://github.com/graphile/crystal/pull/2888)
|
|
25
|
+
[`1a56db2`](https://github.com/graphile/crystal/commit/1a56db2f53bc455a3d3ba6555a2cd777b27b271c)
|
|
26
|
+
Thanks [@benjaie](https://github.com/benjaie)! - Node v22+ is required for
|
|
27
|
+
this module.
|
|
28
|
+
|
|
29
|
+
- Updated dependencies
|
|
30
|
+
[[`0772086`](https://github.com/graphile/crystal/commit/0772086411a55d56b4e345cff1eef133eee31b36),
|
|
31
|
+
[`1a56db2`](https://github.com/graphile/crystal/commit/1a56db2f53bc455a3d3ba6555a2cd777b27b271c)]:
|
|
32
|
+
- @graphile/lru@5.0.0-rc.3
|
|
33
|
+
|
|
3
34
|
## 0.1.0-rc.2
|
|
4
35
|
|
|
5
36
|
### Patch Changes
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { reservedWords } from "./reservedWords.
|
|
2
|
-
import { $$type } from "./thereCanBeOnlyOne.
|
|
1
|
+
import { reservedWords } from "./reservedWords.ts";
|
|
2
|
+
import { $$type } from "./thereCanBeOnlyOne.ts";
|
|
3
3
|
/**
|
|
4
4
|
* Represents raw TE, the text will be output verbatim into the compiled code.
|
|
5
5
|
*/
|
package/dist/index.js
CHANGED
|
@@ -28,9 +28,9 @@ exports.subcomment = subcomment;
|
|
|
28
28
|
exports.substring = substring;
|
|
29
29
|
exports.tempVar = tempVar;
|
|
30
30
|
exports.tmp = tmp;
|
|
31
|
-
const
|
|
32
|
-
Object.defineProperty(exports, "reservedWords", { enumerable: true, get: function () { return
|
|
33
|
-
const
|
|
31
|
+
const reservedWords_ts_1 = require("./reservedWords.js");
|
|
32
|
+
Object.defineProperty(exports, "reservedWords", { enumerable: true, get: function () { return reservedWords_ts_1.reservedWords; } });
|
|
33
|
+
const thereCanBeOnlyOne_ts_1 = require("./thereCanBeOnlyOne.js");
|
|
34
34
|
/**
|
|
35
35
|
* For compatibility with graphile-export
|
|
36
36
|
*/
|
|
@@ -51,13 +51,13 @@ function exportAs(thing, exportName) {
|
|
|
51
51
|
const isDev = typeof process !== "undefined" && process.env.GRAPHILE_ENV === "development";
|
|
52
52
|
function makeRawNode(text) {
|
|
53
53
|
return {
|
|
54
|
-
[
|
|
54
|
+
[thereCanBeOnlyOne_ts_1.$$type]: "RAW",
|
|
55
55
|
t: text,
|
|
56
56
|
};
|
|
57
57
|
}
|
|
58
58
|
function makeExportedRawNode(text, exportName) {
|
|
59
59
|
const newNode = {
|
|
60
|
-
[
|
|
60
|
+
[thereCanBeOnlyOne_ts_1.$$type]: "RAW",
|
|
61
61
|
t: text,
|
|
62
62
|
};
|
|
63
63
|
exportAs(newNode, exportName);
|
|
@@ -66,7 +66,7 @@ function makeExportedRawNode(text, exportName) {
|
|
|
66
66
|
// Simple function to help V8 optimize it.
|
|
67
67
|
function makeRefNode(rawValue, name) {
|
|
68
68
|
return Object.freeze({
|
|
69
|
-
[
|
|
69
|
+
[thereCanBeOnlyOne_ts_1.$$type]: "REF",
|
|
70
70
|
v: rawValue,
|
|
71
71
|
n: name,
|
|
72
72
|
});
|
|
@@ -74,21 +74,21 @@ function makeRefNode(rawValue, name) {
|
|
|
74
74
|
// Simple function to help V8 optimize it.
|
|
75
75
|
function makeTemporaryVariableNode(symbol) {
|
|
76
76
|
return Object.freeze({
|
|
77
|
-
[
|
|
77
|
+
[thereCanBeOnlyOne_ts_1.$$type]: "VARIABLE",
|
|
78
78
|
s: symbol,
|
|
79
79
|
});
|
|
80
80
|
}
|
|
81
81
|
// Simple function to help V8 optimize it.
|
|
82
82
|
function makeIndentNode(content) {
|
|
83
83
|
return Object.freeze({
|
|
84
|
-
[
|
|
85
|
-
c: content[
|
|
84
|
+
[thereCanBeOnlyOne_ts_1.$$type]: "INDENT",
|
|
85
|
+
c: content[thereCanBeOnlyOne_ts_1.$$type] === "QUERY" ? content : makeQueryNode([content]),
|
|
86
86
|
});
|
|
87
87
|
}
|
|
88
88
|
// Simple function to help V8 optimize it.
|
|
89
89
|
function makeQueryNode(nodes) {
|
|
90
90
|
return Object.freeze({
|
|
91
|
-
[
|
|
91
|
+
[thereCanBeOnlyOne_ts_1.$$type]: "QUERY",
|
|
92
92
|
n: nodes,
|
|
93
93
|
});
|
|
94
94
|
}
|
|
@@ -98,7 +98,7 @@ function makeQueryNode(nodes) {
|
|
|
98
98
|
function isTE(node) {
|
|
99
99
|
return (typeof node === "object" &&
|
|
100
100
|
node !== null &&
|
|
101
|
-
typeof node[
|
|
101
|
+
typeof node[thereCanBeOnlyOne_ts_1.$$type] === "string");
|
|
102
102
|
}
|
|
103
103
|
function debug(expression) {
|
|
104
104
|
const result = te.compile(expression);
|
|
@@ -162,7 +162,7 @@ function serialize(item, refs, refMap, varMap, indent = 0) {
|
|
|
162
162
|
if (item == null) {
|
|
163
163
|
enforceValidNode(item);
|
|
164
164
|
}
|
|
165
|
-
switch (item[
|
|
165
|
+
switch (item[thereCanBeOnlyOne_ts_1.$$type]) {
|
|
166
166
|
case "QUERY": {
|
|
167
167
|
for (const listItem of item.n) {
|
|
168
168
|
str += serialize(listItem, refs, refMap, varMap, indent);
|
|
@@ -267,7 +267,7 @@ const teBase = function te(strings, ...values) {
|
|
|
267
267
|
// Special case te`${...}` - just return the node directly
|
|
268
268
|
if (stringsLength === 2 && strings[0] === "" && strings[1] === "") {
|
|
269
269
|
const v = values[0];
|
|
270
|
-
return v[
|
|
270
|
+
return v[thereCanBeOnlyOne_ts_1.$$type] !== undefined ? v : enforceValidNode(v);
|
|
271
271
|
}
|
|
272
272
|
const items = [];
|
|
273
273
|
let lastRawNode = null;
|
|
@@ -285,19 +285,19 @@ const teBase = function te(strings, ...values) {
|
|
|
285
285
|
currentText += text;
|
|
286
286
|
if (i !== finalStringIndex) {
|
|
287
287
|
const v = values[i];
|
|
288
|
-
const valid = v[
|
|
288
|
+
const valid = v[thereCanBeOnlyOne_ts_1.$$type] !== undefined
|
|
289
289
|
? v
|
|
290
290
|
: enforceValidNode(v, `literal placeholder ${i}`);
|
|
291
|
-
if (valid[
|
|
291
|
+
if (valid[thereCanBeOnlyOne_ts_1.$$type] === "RAW") {
|
|
292
292
|
lastRawNode = valid;
|
|
293
293
|
currentText += valid.t;
|
|
294
294
|
}
|
|
295
|
-
else if (valid[
|
|
295
|
+
else if (valid[thereCanBeOnlyOne_ts_1.$$type] === "QUERY") {
|
|
296
296
|
const nodes = valid.n;
|
|
297
297
|
const nodeCount = nodes.length;
|
|
298
298
|
for (let nodeIndex = 0; nodeIndex < nodeCount; nodeIndex++) {
|
|
299
299
|
const node = nodes[nodeIndex];
|
|
300
|
-
if (node[
|
|
300
|
+
if (node[thereCanBeOnlyOne_ts_1.$$type] === "RAW") {
|
|
301
301
|
lastRawNode = node;
|
|
302
302
|
currentText += node.t;
|
|
303
303
|
}
|
|
@@ -570,7 +570,7 @@ const canBeObjectKeyWithoutQuotes = (key) => Number.isFinite(key) ||
|
|
|
570
570
|
* as a variable name.
|
|
571
571
|
*/
|
|
572
572
|
function isValidVariableName(name) {
|
|
573
|
-
if (
|
|
573
|
+
if (reservedWords_ts_1.reservedWords.has(name)) {
|
|
574
574
|
return false;
|
|
575
575
|
}
|
|
576
576
|
if (!/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(name)) {
|
|
@@ -695,7 +695,7 @@ function tempVar(symbol = Symbol()) {
|
|
|
695
695
|
* @experimental
|
|
696
696
|
*/
|
|
697
697
|
function tmp(obj, callback) {
|
|
698
|
-
const trustedObj = obj[
|
|
698
|
+
const trustedObj = obj[thereCanBeOnlyOne_ts_1.$$type] !== undefined ? obj : enforceValidNode(obj);
|
|
699
699
|
// ENHANCEMENT: we should be able to reuse these tempvars between tmp calls
|
|
700
700
|
// that aren't nested (or are nested at the same level).
|
|
701
701
|
const varName = te.tempVar();
|
|
@@ -725,7 +725,7 @@ function isForbidden(thing) {
|
|
|
725
725
|
thing.$$export === false);
|
|
726
726
|
}
|
|
727
727
|
function _runCore(fragmentOrStrings, exportable = false) {
|
|
728
|
-
const fragment = fragmentOrStrings[
|
|
728
|
+
const fragment = fragmentOrStrings[thereCanBeOnlyOne_ts_1.$$type] !== undefined
|
|
729
729
|
? fragmentOrStrings
|
|
730
730
|
: enforceValidNode(fragmentOrStrings);
|
|
731
731
|
const compiled = compile(fragment);
|
|
@@ -824,7 +824,7 @@ function join(items, separator = "") {
|
|
|
824
824
|
}
|
|
825
825
|
else if (items.length === 1) {
|
|
826
826
|
const rawNode = items[0];
|
|
827
|
-
const node = rawNode[
|
|
827
|
+
const node = rawNode[thereCanBeOnlyOne_ts_1.$$type] !== undefined
|
|
828
828
|
? rawNode
|
|
829
829
|
: enforceValidNode(rawNode, `join item ${0}`);
|
|
830
830
|
return node;
|
|
@@ -834,16 +834,16 @@ function join(items, separator = "") {
|
|
|
834
834
|
const currentItems = [];
|
|
835
835
|
for (let i = 0, l = items.length; i < l; i++) {
|
|
836
836
|
const rawNode = items[i];
|
|
837
|
-
const node = rawNode[
|
|
837
|
+
const node = rawNode[thereCanBeOnlyOne_ts_1.$$type] !== undefined
|
|
838
838
|
? rawNode
|
|
839
839
|
: enforceValidNode(rawNode, `join item ${i}`);
|
|
840
840
|
const addSeparator = i > 0 && hasSeparator;
|
|
841
841
|
if (addSeparator) {
|
|
842
842
|
currentText += separator;
|
|
843
843
|
}
|
|
844
|
-
if (node[
|
|
844
|
+
if (node[thereCanBeOnlyOne_ts_1.$$type] === "QUERY") {
|
|
845
845
|
for (const innerNode of node.n) {
|
|
846
|
-
if (innerNode[
|
|
846
|
+
if (innerNode[thereCanBeOnlyOne_ts_1.$$type] === "RAW") {
|
|
847
847
|
currentText += innerNode.t;
|
|
848
848
|
}
|
|
849
849
|
else {
|
|
@@ -855,7 +855,7 @@ function join(items, separator = "") {
|
|
|
855
855
|
}
|
|
856
856
|
}
|
|
857
857
|
}
|
|
858
|
-
else if (node[
|
|
858
|
+
else if (node[thereCanBeOnlyOne_ts_1.$$type] === "RAW") {
|
|
859
859
|
currentText += node.t;
|
|
860
860
|
}
|
|
861
861
|
else {
|
|
@@ -877,7 +877,7 @@ function join(items, separator = "") {
|
|
|
877
877
|
function indent(fragmentOrStrings, ...values) {
|
|
878
878
|
const fragment = "raw" in fragmentOrStrings
|
|
879
879
|
? te(fragmentOrStrings, ...values)
|
|
880
|
-
: fragmentOrStrings[
|
|
880
|
+
: fragmentOrStrings[thereCanBeOnlyOne_ts_1.$$type] !== undefined
|
|
881
881
|
? fragmentOrStrings
|
|
882
882
|
: enforceValidNode(fragmentOrStrings);
|
|
883
883
|
if (!isDev) {
|
|
@@ -890,7 +890,7 @@ function indent(fragmentOrStrings, ...values) {
|
|
|
890
890
|
* node, otherwise it will be returned verbatim.
|
|
891
891
|
*/
|
|
892
892
|
function indentIf(condition, fragment) {
|
|
893
|
-
const trusted = fragment[
|
|
893
|
+
const trusted = fragment[thereCanBeOnlyOne_ts_1.$$type] !== undefined ? fragment : enforceValidNode(fragment);
|
|
894
894
|
return isDev && condition ? makeIndentNode(trusted) : trusted;
|
|
895
895
|
}
|
|
896
896
|
/**
|
|
@@ -901,7 +901,7 @@ function indentIf(condition, fragment) {
|
|
|
901
901
|
class Idents {
|
|
902
902
|
constructor() {
|
|
903
903
|
// Initialized with forbidden words
|
|
904
|
-
this.idents = new Set(
|
|
904
|
+
this.idents = new Set(reservedWords_ts_1.reservedWords);
|
|
905
905
|
}
|
|
906
906
|
/**
|
|
907
907
|
* Don't allow using these identifiers (presumably because they're already in use).
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tamedevil",
|
|
3
|
-
"version": "0.1.0-rc.
|
|
3
|
+
"version": "0.1.0-rc.4",
|
|
4
4
|
"description": "Build and evaluate JavaScript strings safely via tagged template literals",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -44,13 +44,13 @@
|
|
|
44
44
|
"typescript": "^5.9.3"
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"@graphile/lru": "^5.0.0-rc.
|
|
47
|
+
"@graphile/lru": "^5.0.0-rc.4",
|
|
48
48
|
"tslib": "^2.8.1"
|
|
49
49
|
},
|
|
50
50
|
"files": [
|
|
51
51
|
"dist"
|
|
52
52
|
],
|
|
53
53
|
"engines": {
|
|
54
|
-
"node": ">=
|
|
54
|
+
"node": ">=22"
|
|
55
55
|
}
|
|
56
56
|
}
|