@geometra/tw 1.10.2 → 1.10.3
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.d.ts +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -1
- package/dist/index.js.map +1 -1
- package/dist/parser.d.ts +6 -0
- package/dist/parser.d.ts.map +1 -1
- package/dist/parser.js +13 -3
- package/dist/parser.js.map +1 -1
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { FlexProps } from 'textura';
|
|
2
2
|
import type { StyleProps } from '@geometra/core';
|
|
3
|
+
import { MAX_TW_CLASS_TOKENS } from './parser.js';
|
|
4
|
+
export { MAX_TW_CLASS_TOKENS };
|
|
3
5
|
/** Combined flex layout + visual style props returned by `tw()`. */
|
|
4
6
|
export type TwResult = FlexProps & StyleProps;
|
|
5
7
|
/**
|
|
@@ -12,6 +14,8 @@ export type TwResult = FlexProps & StyleProps;
|
|
|
12
14
|
* Accepts one or more class strings. Last class wins on conflicts.
|
|
13
15
|
* Unknown classes are silently ignored. Non-string arguments are skipped at runtime so corrupt spreads
|
|
14
16
|
* (e.g. `Symbol` values) cannot make `Array#join` throw.
|
|
17
|
+
*
|
|
18
|
+
* Parsing stops after {@link MAX_TW_CLASS_TOKENS} tokens (left-to-right); excess trailing classes are ignored.
|
|
15
19
|
*/
|
|
16
20
|
export declare function tw(...classes: string[]): TwResult;
|
|
17
21
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AACxC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AACxC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAChD,OAAO,EAAE,mBAAmB,EAAgB,MAAM,aAAa,CAAA;AAE/D,OAAO,EAAE,mBAAmB,EAAE,CAAA;AAE9B,oEAAoE;AACpE,MAAM,MAAM,QAAQ,GAAG,SAAS,GAAG,UAAU,CAAA;AAE7C;;;;;;;;;;;;GAYG;AACH,wBAAgB,EAAE,CAAC,GAAG,OAAO,EAAE,MAAM,EAAE,GAAG,QAAQ,CAMjD"}
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { parseClasses } from './parser.js';
|
|
1
|
+
import { MAX_TW_CLASS_TOKENS, parseClasses } from './parser.js';
|
|
2
|
+
export { MAX_TW_CLASS_TOKENS };
|
|
2
3
|
/**
|
|
3
4
|
* Convert Tailwind-style utility classes to Geometra props.
|
|
4
5
|
*
|
|
@@ -9,6 +10,8 @@ import { parseClasses } from './parser.js';
|
|
|
9
10
|
* Accepts one or more class strings. Last class wins on conflicts.
|
|
10
11
|
* Unknown classes are silently ignored. Non-string arguments are skipped at runtime so corrupt spreads
|
|
11
12
|
* (e.g. `Symbol` values) cannot make `Array#join` throw.
|
|
13
|
+
*
|
|
14
|
+
* Parsing stops after {@link MAX_TW_CLASS_TOKENS} tokens (left-to-right); excess trailing classes are ignored.
|
|
12
15
|
*/
|
|
13
16
|
export function tw(...classes) {
|
|
14
17
|
const parts = [];
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAE/D,OAAO,EAAE,mBAAmB,EAAE,CAAA;AAK9B;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,EAAE,CAAC,GAAG,OAAiB;IACrC,MAAM,KAAK,GAAa,EAAE,CAAA;IAC1B,KAAK,MAAM,CAAC,IAAI,OAAO,EAAE,CAAC;QACxB,IAAI,OAAO,CAAC,KAAK,QAAQ;YAAE,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IAC1C,CAAC;IACD,OAAO,YAAY,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAA;AACtC,CAAC"}
|
package/dist/parser.d.ts
CHANGED
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
import type { TwResult } from './index.js';
|
|
2
|
+
/**
|
|
3
|
+
* Maximum number of whitespace-delimited utility tokens processed per {@link parseClasses} call
|
|
4
|
+
* (and therefore per {@link import('./index.js').tw} after joining arguments). Additional trailing
|
|
5
|
+
* tokens are ignored so hostile megabyte strings cannot force unbounded `split` allocations.
|
|
6
|
+
*/
|
|
7
|
+
export declare const MAX_TW_CLASS_TOKENS = 4096;
|
|
2
8
|
/** Parse a class string into tokens and resolve each to props. */
|
|
3
9
|
export declare function parseClasses(input: string): TwResult;
|
|
4
10
|
//# sourceMappingURL=parser.d.ts.map
|
package/dist/parser.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parser.d.ts","sourceRoot":"","sources":["../src/parser.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAG1C,kEAAkE;AAClE,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,QAAQ,
|
|
1
|
+
{"version":3,"file":"parser.d.ts","sourceRoot":"","sources":["../src/parser.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAG1C;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,OAAO,CAAA;AAEvC,kEAAkE;AAClE,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,QAAQ,CAYpD"}
|
package/dist/parser.js
CHANGED
|
@@ -1,14 +1,24 @@
|
|
|
1
1
|
import { resolveToken } from './resolver.js';
|
|
2
|
+
/**
|
|
3
|
+
* Maximum number of whitespace-delimited utility tokens processed per {@link parseClasses} call
|
|
4
|
+
* (and therefore per {@link import('./index.js').tw} after joining arguments). Additional trailing
|
|
5
|
+
* tokens are ignored so hostile megabyte strings cannot force unbounded `split` allocations.
|
|
6
|
+
*/
|
|
7
|
+
export const MAX_TW_CLASS_TOKENS = 4096;
|
|
2
8
|
/** Parse a class string into tokens and resolve each to props. */
|
|
3
9
|
export function parseClasses(input) {
|
|
4
10
|
if (typeof input !== 'string')
|
|
5
11
|
return {};
|
|
6
|
-
const tokens = input.split(/\s+/).filter(Boolean);
|
|
7
12
|
const result = {};
|
|
8
|
-
|
|
9
|
-
|
|
13
|
+
const tokenRe = /\S+/g;
|
|
14
|
+
let count = 0;
|
|
15
|
+
for (let m = tokenRe.exec(input); m !== null; m = tokenRe.exec(input)) {
|
|
16
|
+
if (count >= MAX_TW_CLASS_TOKENS)
|
|
17
|
+
break;
|
|
18
|
+
const resolved = resolveToken(m[0]);
|
|
10
19
|
if (resolved)
|
|
11
20
|
Object.assign(result, resolved);
|
|
21
|
+
count++;
|
|
12
22
|
}
|
|
13
23
|
return result;
|
|
14
24
|
}
|
package/dist/parser.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parser.js","sourceRoot":"","sources":["../src/parser.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAE5C,kEAAkE;AAClE,MAAM,UAAU,YAAY,CAAC,KAAa;IACxC,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,EAAc,CAAA;IACpD,MAAM,MAAM,GAAG,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,
|
|
1
|
+
{"version":3,"file":"parser.js","sourceRoot":"","sources":["../src/parser.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAE5C;;;;GAIG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,IAAI,CAAA;AAEvC,kEAAkE;AAClE,MAAM,UAAU,YAAY,CAAC,KAAa;IACxC,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,EAAc,CAAA;IACpD,MAAM,MAAM,GAA4B,EAAE,CAAA;IAC1C,MAAM,OAAO,GAAG,MAAM,CAAA;IACtB,IAAI,KAAK,GAAG,CAAC,CAAA;IACb,KAAK,IAAI,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,IAAI,EAAE,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;QACtE,IAAI,KAAK,IAAI,mBAAmB;YAAE,MAAK;QACvC,MAAM,QAAQ,GAAG,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;QACnC,IAAI,QAAQ;YAAE,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAA;QAC7C,KAAK,EAAE,CAAA;IACT,CAAC;IACD,OAAO,MAAkB,CAAA;AAC3B,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@geometra/tw",
|
|
3
|
-
"version": "1.10.
|
|
3
|
+
"version": "1.10.3",
|
|
4
4
|
"description": "Tailwind-style utility classes for Geometra",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"check": "tsc --noEmit"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@geometra/core": "^1.10.
|
|
38
|
-
"textura": "^1.10.
|
|
37
|
+
"@geometra/core": "^1.10.3",
|
|
38
|
+
"textura": "^1.10.3"
|
|
39
39
|
}
|
|
40
40
|
}
|