@gtkx/utils 1.3.0 → 1.4.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/README.md +5 -4
- package/dist/source/escape-identifier-start.d.ts +2 -1
- package/dist/source/escape-identifier-start.d.ts.map +1 -1
- package/dist/source/escape-identifier-start.js +3 -1
- package/dist/source/escape-identifier-start.js.map +1 -1
- package/dist/source/escape-reserved.d.ts +2 -1
- package/dist/source/escape-reserved.d.ts.map +1 -1
- package/dist/source/escape-reserved.js +8 -1
- package/dist/source/escape-reserved.js.map +1 -1
- package/dist/source/index.d.ts +1 -0
- package/dist/source/index.d.ts.map +1 -1
- package/dist/source/index.js +1 -0
- package/dist/source/index.js.map +1 -1
- package/dist/source/unsanitize-identifier.d.ts +3 -0
- package/dist/source/unsanitize-identifier.d.ts.map +1 -0
- package/dist/source/unsanitize-identifier.js +8 -0
- package/dist/source/unsanitize-identifier.js.map +1 -0
- package/package.json +2 -2
- package/src/source/escape-identifier-start.ts +5 -1
- package/src/source/escape-reserved.ts +11 -1
- package/src/source/index.ts +1 -0
- package/src/source/unsanitize-identifier.ts +9 -0
package/README.md
CHANGED
|
@@ -5,9 +5,9 @@
|
|
|
5
5
|
<h1 align="center">GTKX</h1>
|
|
6
6
|
|
|
7
7
|
<p align="center">
|
|
8
|
-
The React framework for Linux.<br />
|
|
9
|
-
Write native
|
|
10
|
-
|
|
8
|
+
The React framework for Linux, built on GTK.<br />
|
|
9
|
+
Write native GTK4 desktop applications with React and TypeScript.
|
|
10
|
+
Real GTK widgets, the GNOME stack, and standard web tooling.
|
|
11
11
|
</p>
|
|
12
12
|
|
|
13
13
|
<p align="center">
|
|
@@ -98,7 +98,7 @@ GTK4 is mature, and GtkBuilder XML can lay out a static interface, but nothing r
|
|
|
98
98
|
- a React reconciler that exposes every GObject as a JSX element,
|
|
99
99
|
- a CLI for scaffolding, development, and production builds,
|
|
100
100
|
- a dev server with Fast Refresh that patches your running UI in place,
|
|
101
|
-
- CSS-in-JS styling, React Spring animations, and high-level list, grid, and dialog components,
|
|
101
|
+
- CSS-in-JS styling, React Spring animations, React Navigation stack, tab, drawer, and split view navigators, and high-level list, grid, and dialog components,
|
|
102
102
|
- a Testing Library-style API for querying and driving your widgets in tests,
|
|
103
103
|
- and a Model Context Protocol (MCP) server that exposes your live app to AI agents.
|
|
104
104
|
|
|
@@ -158,6 +158,7 @@ Explore the [example apps](https://github.com/gtkx-org/gtkx/tree/main/examples):
|
|
|
158
158
|
- [`gtk-demo`](https://github.com/gtkx-org/gtkx/tree/main/examples/gtk-demo): a React port of the official GTK4 widget showcase, covering lists, dialogs, gestures, CSS, and OpenGL.
|
|
159
159
|
- [`browser`](https://github.com/gtkx-org/gtkx/tree/main/examples/browser): a WebKitWebView-based web browser.
|
|
160
160
|
- [`animations`](https://github.com/gtkx-org/gtkx/tree/main/examples/animations): a tour of `@gtkx/animated`, React Spring animations driven by the GTK frame clock.
|
|
161
|
+
- [`navigation`](https://github.com/gtkx-org/gtkx/tree/main/examples/navigation): a tour of `@gtkx/navigation`, React Navigation's stack, tab, and drawer navigators rendered with libadwaita.
|
|
161
162
|
- [`tutorial`](https://github.com/gtkx-org/gtkx/tree/main/examples/tutorial): the Tasks app the documentation builds.
|
|
162
163
|
|
|
163
164
|
## Status
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
declare const escapeIdentifierStart: (name: string) => string;
|
|
2
|
-
|
|
2
|
+
declare const unescapeIdentifierStart: (name: string) => string;
|
|
3
|
+
export { escapeIdentifierStart, unescapeIdentifierStart };
|
|
3
4
|
//# sourceMappingURL=escape-identifier-start.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"escape-identifier-start.d.ts","sourceRoot":"","sources":["../../src/source/escape-identifier-start.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"escape-identifier-start.d.ts","sourceRoot":"","sources":["../../src/source/escape-identifier-start.ts"],"names":[],"mappings":"AAGA,QAAA,MAAM,qBAAqB,GAAI,MAAM,MAAM,KAAG,MAAsD,CAAC;AAErG,QAAA,MAAM,uBAAuB,GAAI,MAAM,MAAM,KAAG,MACS,CAAC;AAE1D,OAAO,EAAE,qBAAqB,EAAE,uBAAuB,EAAE,CAAC"}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
const DIGIT_START = /^\d/;
|
|
2
|
+
const ESCAPED_DIGIT_START = /^_\d/;
|
|
2
3
|
const escapeIdentifierStart = (name) => (DIGIT_START.test(name) ? `_${name}` : name);
|
|
3
|
-
|
|
4
|
+
const unescapeIdentifierStart = (name) => ESCAPED_DIGIT_START.test(name) ? name.slice(1) : name;
|
|
5
|
+
export { escapeIdentifierStart, unescapeIdentifierStart };
|
|
4
6
|
//# sourceMappingURL=escape-identifier-start.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"escape-identifier-start.js","sourceRoot":"","sources":["../../src/source/escape-identifier-start.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,GAAG,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"escape-identifier-start.js","sourceRoot":"","sources":["../../src/source/escape-identifier-start.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,GAAG,KAAK,CAAC;AAC1B,MAAM,mBAAmB,GAAG,MAAM,CAAC;AAEnC,MAAM,qBAAqB,GAAG,CAAC,IAAY,EAAU,EAAE,CAAC,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;AAErG,MAAM,uBAAuB,GAAG,CAAC,IAAY,EAAU,EAAE,CACrD,mBAAmB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;AAE1D,OAAO,EAAE,qBAAqB,EAAE,uBAAuB,EAAE,CAAC","sourcesContent":["const DIGIT_START = /^\\d/;\nconst ESCAPED_DIGIT_START = /^_\\d/;\n\nconst escapeIdentifierStart = (name: string): string => (DIGIT_START.test(name) ? `_${name}` : name);\n\nconst unescapeIdentifierStart = (name: string): string =>\n ESCAPED_DIGIT_START.test(name) ? name.slice(1) : name;\n\nexport { escapeIdentifierStart, unescapeIdentifierStart };\n"]}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
declare const escapeReserved: (name: string, reserved: Set<string>) => string;
|
|
2
|
-
|
|
2
|
+
declare const unescapeReserved: (name: string, reserved: Set<string>) => string;
|
|
3
|
+
export { escapeReserved, unescapeReserved };
|
|
3
4
|
//# sourceMappingURL=escape-reserved.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"escape-reserved.d.ts","sourceRoot":"","sources":["../../src/source/escape-reserved.ts"],"names":[],"mappings":"AAYA,QAAA,MAAM,cAAc,GAAI,MAAM,MAAM,EAAE,UAAU,GAAG,CAAC,MAAM,CAAC,KAAG,MACW,CAAC;AAE1E,OAAO,EAAE,cAAc,EAAE,CAAC"}
|
|
1
|
+
{"version":3,"file":"escape-reserved.d.ts","sourceRoot":"","sources":["../../src/source/escape-reserved.ts"],"names":[],"mappings":"AAYA,QAAA,MAAM,cAAc,GAAI,MAAM,MAAM,EAAE,UAAU,GAAG,CAAC,MAAM,CAAC,KAAG,MACW,CAAC;AAE1E,QAAA,MAAM,gBAAgB,GAAI,MAAM,MAAM,EAAE,UAAU,GAAG,CAAC,MAAM,CAAC,KAAG,MAQ/D,CAAC;AAEF,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,CAAC"}
|
|
@@ -7,5 +7,12 @@ const getUnsuffixedName = (name) => {
|
|
|
7
7
|
return name.slice(0, end);
|
|
8
8
|
};
|
|
9
9
|
const escapeReserved = (name, reserved) => reserved.has(getUnsuffixedName(name)) ? `${name}${UNDERSCORE}` : name;
|
|
10
|
-
|
|
10
|
+
const unescapeReserved = (name, reserved) => {
|
|
11
|
+
if (!name.endsWith(UNDERSCORE)) {
|
|
12
|
+
return name;
|
|
13
|
+
}
|
|
14
|
+
const escaped = name.slice(0, -1);
|
|
15
|
+
return reserved.has(getUnsuffixedName(escaped)) ? escaped : name;
|
|
16
|
+
};
|
|
17
|
+
export { escapeReserved, unescapeReserved };
|
|
11
18
|
//# sourceMappingURL=escape-reserved.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"escape-reserved.js","sourceRoot":"","sources":["../../src/source/escape-reserved.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,GAAG,GAAG,CAAC;AAEvB,MAAM,iBAAiB,GAAG,CAAC,IAAY,EAAU,EAAE;IAC/C,IAAI,GAAG,GAAG,IAAI,CAAC,MAAM,CAAC;IAEtB,OAAO,GAAG,GAAG,CAAC,IAAI,IAAI,CAAC,MAAM,CAAC,GAAG,GAAG,CAAC,CAAC,KAAK,UAAU,EAAE,CAAC;QACpD,GAAG,IAAI,CAAC,CAAC;IACb,CAAC;IAED,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;AAC9B,CAAC,CAAC;AAEF,MAAM,cAAc,GAAG,CAAC,IAAY,EAAE,QAAqB,EAAU,EAAE,CACnE,QAAQ,CAAC,GAAG,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,GAAG,UAAU,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;AAE1E,OAAO,EAAE,cAAc,EAAE,CAAC","sourcesContent":["const UNDERSCORE = \"_\";\n\nconst getUnsuffixedName = (name: string): string => {\n let end = name.length;\n\n while (end > 0 && name.charAt(end - 1) === UNDERSCORE) {\n end -= 1;\n }\n\n return name.slice(0, end);\n};\n\nconst escapeReserved = (name: string, reserved: Set<string>): string =>\n reserved.has(getUnsuffixedName(name)) ? `${name}${UNDERSCORE}` : name;\n\nexport { escapeReserved };\n"]}
|
|
1
|
+
{"version":3,"file":"escape-reserved.js","sourceRoot":"","sources":["../../src/source/escape-reserved.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,GAAG,GAAG,CAAC;AAEvB,MAAM,iBAAiB,GAAG,CAAC,IAAY,EAAU,EAAE;IAC/C,IAAI,GAAG,GAAG,IAAI,CAAC,MAAM,CAAC;IAEtB,OAAO,GAAG,GAAG,CAAC,IAAI,IAAI,CAAC,MAAM,CAAC,GAAG,GAAG,CAAC,CAAC,KAAK,UAAU,EAAE,CAAC;QACpD,GAAG,IAAI,CAAC,CAAC;IACb,CAAC;IAED,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;AAC9B,CAAC,CAAC;AAEF,MAAM,cAAc,GAAG,CAAC,IAAY,EAAE,QAAqB,EAAU,EAAE,CACnE,QAAQ,CAAC,GAAG,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,GAAG,UAAU,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;AAE1E,MAAM,gBAAgB,GAAG,CAAC,IAAY,EAAE,QAAqB,EAAU,EAAE;IACrE,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE,CAAC;QAC7B,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IAElC,OAAO,QAAQ,CAAC,GAAG,CAAC,iBAAiB,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC;AACrE,CAAC,CAAC;AAEF,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,CAAC","sourcesContent":["const UNDERSCORE = \"_\";\n\nconst getUnsuffixedName = (name: string): string => {\n let end = name.length;\n\n while (end > 0 && name.charAt(end - 1) === UNDERSCORE) {\n end -= 1;\n }\n\n return name.slice(0, end);\n};\n\nconst escapeReserved = (name: string, reserved: Set<string>): string =>\n reserved.has(getUnsuffixedName(name)) ? `${name}${UNDERSCORE}` : name;\n\nconst unescapeReserved = (name: string, reserved: Set<string>): string => {\n if (!name.endsWith(UNDERSCORE)) {\n return name;\n }\n\n const escaped = name.slice(0, -1);\n\n return reserved.has(getUnsuffixedName(escaped)) ? escaped : name;\n};\n\nexport { escapeReserved, unescapeReserved };\n"]}
|
package/dist/source/index.d.ts
CHANGED
|
@@ -3,4 +3,5 @@ export { sanitizeIdentifier } from "./sanitize-identifier.ts";
|
|
|
3
3
|
export { sanitizeTypeIdentifier } from "./sanitize-type-identifier.ts";
|
|
4
4
|
export { sourceStringLiteral } from "./source-string-literal.ts";
|
|
5
5
|
export { toCamelIdentifier } from "./to-camel-identifier.ts";
|
|
6
|
+
export { unsanitizeIdentifier } from "./unsanitize-identifier.ts";
|
|
6
7
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/source/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AACrE,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AACvE,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/source/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AACrE,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AACvE,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC"}
|
package/dist/source/index.js
CHANGED
|
@@ -3,4 +3,5 @@ export { sanitizeIdentifier } from "./sanitize-identifier.js";
|
|
|
3
3
|
export { sanitizeTypeIdentifier } from "./sanitize-type-identifier.js";
|
|
4
4
|
export { sourceStringLiteral } from "./source-string-literal.js";
|
|
5
5
|
export { toCamelIdentifier } from "./to-camel-identifier.js";
|
|
6
|
+
export { unsanitizeIdentifier } from "./unsanitize-identifier.js";
|
|
6
7
|
//# sourceMappingURL=index.js.map
|
package/dist/source/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/source/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AACrE,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AACvE,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC","sourcesContent":["export { escapeIdentifierStart } from \"./escape-identifier-start.ts\";\nexport { sanitizeIdentifier } from \"./sanitize-identifier.ts\";\nexport { sanitizeTypeIdentifier } from \"./sanitize-type-identifier.ts\";\nexport { sourceStringLiteral } from \"./source-string-literal.ts\";\nexport { toCamelIdentifier } from \"./to-camel-identifier.ts\";\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/source/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AACrE,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AACvE,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC","sourcesContent":["export { escapeIdentifierStart } from \"./escape-identifier-start.ts\";\nexport { sanitizeIdentifier } from \"./sanitize-identifier.ts\";\nexport { sanitizeTypeIdentifier } from \"./sanitize-type-identifier.ts\";\nexport { sourceStringLiteral } from \"./source-string-literal.ts\";\nexport { toCamelIdentifier } from \"./to-camel-identifier.ts\";\nexport { unsanitizeIdentifier } from \"./unsanitize-identifier.ts\";\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unsanitize-identifier.d.ts","sourceRoot":"","sources":["../../src/source/unsanitize-identifier.ts"],"names":[],"mappings":"AAIA,iBAAS,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAElD;AAED,OAAO,EAAE,oBAAoB,EAAE,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { unescapeIdentifierStart } from "./escape-identifier-start.js";
|
|
2
|
+
import { unescapeReserved } from "./escape-reserved.js";
|
|
3
|
+
import { RESERVED } from "./sanitize-identifier.js";
|
|
4
|
+
function unsanitizeIdentifier(name) {
|
|
5
|
+
return unescapeReserved(unescapeIdentifierStart(name), RESERVED);
|
|
6
|
+
}
|
|
7
|
+
export { unsanitizeIdentifier };
|
|
8
|
+
//# sourceMappingURL=unsanitize-identifier.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unsanitize-identifier.js","sourceRoot":"","sources":["../../src/source/unsanitize-identifier.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AACvE,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAEpD,SAAS,oBAAoB,CAAC,IAAY;IACtC,OAAO,gBAAgB,CAAC,uBAAuB,CAAC,IAAI,CAAC,EAAE,QAAQ,CAAC,CAAC;AACrE,CAAC;AAED,OAAO,EAAE,oBAAoB,EAAE,CAAC","sourcesContent":["import { unescapeIdentifierStart } from \"./escape-identifier-start.ts\";\nimport { unescapeReserved } from \"./escape-reserved.ts\";\nimport { RESERVED } from \"./sanitize-identifier.ts\";\n\nfunction unsanitizeIdentifier(name: string): string {\n return unescapeReserved(unescapeIdentifierStart(name), RESERVED);\n}\n\nexport { unsanitizeIdentifier };\n"]}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gtkx/utils",
|
|
3
|
-
"version": "1.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "1.4.0",
|
|
4
|
+
"description": "Shared utilities for the GTK toolchain: logging, errors, strings.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"gtkx",
|
|
7
7
|
"gtk",
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
const DIGIT_START = /^\d/;
|
|
2
|
+
const ESCAPED_DIGIT_START = /^_\d/;
|
|
2
3
|
|
|
3
4
|
const escapeIdentifierStart = (name: string): string => (DIGIT_START.test(name) ? `_${name}` : name);
|
|
4
5
|
|
|
5
|
-
|
|
6
|
+
const unescapeIdentifierStart = (name: string): string =>
|
|
7
|
+
ESCAPED_DIGIT_START.test(name) ? name.slice(1) : name;
|
|
8
|
+
|
|
9
|
+
export { escapeIdentifierStart, unescapeIdentifierStart };
|
|
@@ -13,4 +13,14 @@ const getUnsuffixedName = (name: string): string => {
|
|
|
13
13
|
const escapeReserved = (name: string, reserved: Set<string>): string =>
|
|
14
14
|
reserved.has(getUnsuffixedName(name)) ? `${name}${UNDERSCORE}` : name;
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
const unescapeReserved = (name: string, reserved: Set<string>): string => {
|
|
17
|
+
if (!name.endsWith(UNDERSCORE)) {
|
|
18
|
+
return name;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const escaped = name.slice(0, -1);
|
|
22
|
+
|
|
23
|
+
return reserved.has(getUnsuffixedName(escaped)) ? escaped : name;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export { escapeReserved, unescapeReserved };
|
package/src/source/index.ts
CHANGED
|
@@ -3,3 +3,4 @@ export { sanitizeIdentifier } from "./sanitize-identifier.ts";
|
|
|
3
3
|
export { sanitizeTypeIdentifier } from "./sanitize-type-identifier.ts";
|
|
4
4
|
export { sourceStringLiteral } from "./source-string-literal.ts";
|
|
5
5
|
export { toCamelIdentifier } from "./to-camel-identifier.ts";
|
|
6
|
+
export { unsanitizeIdentifier } from "./unsanitize-identifier.ts";
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { unescapeIdentifierStart } from "./escape-identifier-start.ts";
|
|
2
|
+
import { unescapeReserved } from "./escape-reserved.ts";
|
|
3
|
+
import { RESERVED } from "./sanitize-identifier.ts";
|
|
4
|
+
|
|
5
|
+
function unsanitizeIdentifier(name: string): string {
|
|
6
|
+
return unescapeReserved(unescapeIdentifierStart(name), RESERVED);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export { unsanitizeIdentifier };
|