fractalpop 0.1.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 (77) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +232 -0
  3. package/dist/core.d.ts +110 -0
  4. package/dist/core.js +313 -0
  5. package/dist/full.d.ts +1 -0
  6. package/dist/full.js +356 -0
  7. package/dist/gpu.d.ts +59 -0
  8. package/dist/gpu.js +215 -0
  9. package/dist/index.d.ts +108 -0
  10. package/dist/index.js +523 -0
  11. package/dist/lang/c.d.ts +5 -0
  12. package/dist/lang/c.js +90 -0
  13. package/dist/lang/cpp.d.ts +5 -0
  14. package/dist/lang/cpp.js +138 -0
  15. package/dist/lang/csharp.d.ts +5 -0
  16. package/dist/lang/csharp.js +148 -0
  17. package/dist/lang/css.d.ts +21 -0
  18. package/dist/lang/css.js +164 -0
  19. package/dist/lang/diff.d.ts +30 -0
  20. package/dist/lang/diff.js +18 -0
  21. package/dist/lang/dockerfile.d.ts +5 -0
  22. package/dist/lang/dockerfile.js +60 -0
  23. package/dist/lang/go.d.ts +5 -0
  24. package/dist/lang/go.js +91 -0
  25. package/dist/lang/graphql.d.ts +5 -0
  26. package/dist/lang/graphql.js +66 -0
  27. package/dist/lang/hcl.d.ts +5 -0
  28. package/dist/lang/hcl.js +51 -0
  29. package/dist/lang/html.d.ts +12 -0
  30. package/dist/lang/html.js +168 -0
  31. package/dist/lang/java.d.ts +5 -0
  32. package/dist/lang/java.js +96 -0
  33. package/dist/lang/javascript.d.ts +5 -0
  34. package/dist/lang/javascript.js +0 -0
  35. package/dist/lang/json.d.ts +5 -0
  36. package/dist/lang/json.js +47 -0
  37. package/dist/lang/kotlin.d.ts +5 -0
  38. package/dist/lang/kotlin.js +113 -0
  39. package/dist/lang/lua.d.ts +5 -0
  40. package/dist/lang/lua.js +65 -0
  41. package/dist/lang/markdown.d.ts +12 -0
  42. package/dist/lang/markdown.js +172 -0
  43. package/dist/lang/php.d.ts +5 -0
  44. package/dist/lang/php.js +129 -0
  45. package/dist/lang/plaintext.d.ts +7 -0
  46. package/dist/lang/plaintext.js +3 -0
  47. package/dist/lang/powershell.d.ts +5 -0
  48. package/dist/lang/powershell.js +74 -0
  49. package/dist/lang/python.d.ts +5 -0
  50. package/dist/lang/python.js +75 -0
  51. package/dist/lang/ruby.d.ts +5 -0
  52. package/dist/lang/ruby.js +84 -0
  53. package/dist/lang/rust.d.ts +5 -0
  54. package/dist/lang/rust.js +95 -0
  55. package/dist/lang/sass.d.ts +15 -0
  56. package/dist/lang/sass.js +201 -0
  57. package/dist/lang/scss.d.ts +14 -0
  58. package/dist/lang/scss.js +105 -0
  59. package/dist/lang/shell.d.ts +5 -0
  60. package/dist/lang/shell.js +64 -0
  61. package/dist/lang/sql.d.ts +5 -0
  62. package/dist/lang/sql.js +129 -0
  63. package/dist/lang/svelte.d.ts +15 -0
  64. package/dist/lang/svelte.js +0 -0
  65. package/dist/lang/swift.d.ts +5 -0
  66. package/dist/lang/swift.js +125 -0
  67. package/dist/lang/toml.d.ts +5 -0
  68. package/dist/lang/toml.js +45 -0
  69. package/dist/lang/typescript.d.ts +5 -0
  70. package/dist/lang/typescript.js +0 -0
  71. package/dist/lang/yaml.d.ts +5 -0
  72. package/dist/lang/yaml.js +64 -0
  73. package/dist/lang/zig.d.ts +5 -0
  74. package/dist/lang/zig.js +133 -0
  75. package/dist/lang.d.ts +30 -0
  76. package/dist/lang.js +345 -0
  77. package/package.json +68 -0
@@ -0,0 +1,5 @@
1
+ import { ParseOptions } from '../core.js';
2
+
3
+ declare const config: ParseOptions;
4
+
5
+ export { config };
@@ -0,0 +1,91 @@
1
+ /** Reusable comment-scanner bases shared by keyword-based language presets. */ /** Build onCommentStart/onCommentEnd for a mix of line + block comment styles.
2
+ * Line comments open as type 1 and close at `\n`; block comments open as type 2
3
+ * and close at the terminator — so a single onCommentEnd serves both. */ function commentRules(style) {
4
+ const line = style.line ?? [];
5
+ const hasSlash = line.includes('//');
6
+ const hasHash = line.includes('#');
7
+ const hasDash = line.includes('--');
8
+ const block = style.block ?? false;
9
+ return {
10
+ onCommentStart (curr, next) {
11
+ if (block && curr === '/' && next === '*') return 2;
12
+ if (hasSlash && curr === '/' && next === '/') return 1;
13
+ if (hasHash && curr === '#') return 1;
14
+ if (hasDash && curr === '-' && next === '-') return 1;
15
+ return 0;
16
+ },
17
+ onCommentEnd (prev, curr) {
18
+ if (curr === '\n') return 1;
19
+ if (block && prev === '*' && curr === '/') return 2;
20
+ return 0;
21
+ }
22
+ };
23
+ }
24
+ /** Assemble a keyword-based language config over the shared general lexer. */ function keywordLang(spec) {
25
+ const config = {};
26
+ if (spec.keywords) config.keywords = new Set(spec.keywords);
27
+ if (spec.typeKeywords) config.typeKeywords = new Set(spec.typeKeywords);
28
+ if (spec.caseInsensitive) config.caseInsensitive = true;
29
+ if (spec.comments) Object.assign(config, commentRules(spec.comments));
30
+ return config;
31
+ }
32
+
33
+ const config = keywordLang({
34
+ keywords: [
35
+ "break",
36
+ "case",
37
+ "chan",
38
+ "const",
39
+ "continue",
40
+ "default",
41
+ "defer",
42
+ "else",
43
+ "fallthrough",
44
+ "for",
45
+ "func",
46
+ "go",
47
+ "goto",
48
+ "if",
49
+ "import",
50
+ "interface",
51
+ "map",
52
+ "package",
53
+ "range",
54
+ "return",
55
+ "select",
56
+ "struct",
57
+ "switch",
58
+ "type",
59
+ "var"
60
+ ],
61
+ typeKeywords: [
62
+ "bool",
63
+ "byte",
64
+ "complex64",
65
+ "complex128",
66
+ "error",
67
+ "float32",
68
+ "float64",
69
+ "int",
70
+ "int8",
71
+ "int16",
72
+ "int32",
73
+ "int64",
74
+ "rune",
75
+ "string",
76
+ "uint",
77
+ "uint8",
78
+ "uint16",
79
+ "uint32",
80
+ "uint64",
81
+ "uintptr"
82
+ ],
83
+ comments: {
84
+ "line": [
85
+ "//"
86
+ ],
87
+ "block": true
88
+ }
89
+ });
90
+
91
+ export { config };
@@ -0,0 +1,5 @@
1
+ import { ParseOptions } from '../core.js';
2
+
3
+ declare const config: ParseOptions;
4
+
5
+ export { config };
@@ -0,0 +1,66 @@
1
+ /** Reusable comment-scanner bases shared by keyword-based language presets. */ /** Build onCommentStart/onCommentEnd for a mix of line + block comment styles.
2
+ * Line comments open as type 1 and close at `\n`; block comments open as type 2
3
+ * and close at the terminator — so a single onCommentEnd serves both. */ function commentRules(style) {
4
+ const line = style.line ?? [];
5
+ const hasSlash = line.includes('//');
6
+ const hasHash = line.includes('#');
7
+ const hasDash = line.includes('--');
8
+ const block = style.block ?? false;
9
+ return {
10
+ onCommentStart (curr, next) {
11
+ if (block && curr === '/' && next === '*') return 2;
12
+ if (hasSlash && curr === '/' && next === '/') return 1;
13
+ if (hasHash && curr === '#') return 1;
14
+ if (hasDash && curr === '-' && next === '-') return 1;
15
+ return 0;
16
+ },
17
+ onCommentEnd (prev, curr) {
18
+ if (curr === '\n') return 1;
19
+ if (block && prev === '*' && curr === '/') return 2;
20
+ return 0;
21
+ }
22
+ };
23
+ }
24
+ /** Assemble a keyword-based language config over the shared general lexer. */ function keywordLang(spec) {
25
+ const config = {};
26
+ if (spec.keywords) config.keywords = new Set(spec.keywords);
27
+ if (spec.typeKeywords) config.typeKeywords = new Set(spec.typeKeywords);
28
+ if (spec.caseInsensitive) config.caseInsensitive = true;
29
+ if (spec.comments) Object.assign(config, commentRules(spec.comments));
30
+ return config;
31
+ }
32
+
33
+ const config = keywordLang({
34
+ keywords: [
35
+ "directive",
36
+ "enum",
37
+ "extend",
38
+ "fragment",
39
+ "implements",
40
+ "input",
41
+ "interface",
42
+ "mutation",
43
+ "on",
44
+ "query",
45
+ "repeatable",
46
+ "scalar",
47
+ "schema",
48
+ "subscription",
49
+ "type",
50
+ "union"
51
+ ],
52
+ typeKeywords: [
53
+ "Boolean",
54
+ "Float",
55
+ "ID",
56
+ "Int",
57
+ "String"
58
+ ],
59
+ comments: {
60
+ "line": [
61
+ "#"
62
+ ]
63
+ }
64
+ });
65
+
66
+ export { config };
@@ -0,0 +1,5 @@
1
+ import { ParseOptions } from '../core.js';
2
+
3
+ declare const config: ParseOptions;
4
+
5
+ export { config };
@@ -0,0 +1,51 @@
1
+ /** Reusable comment-scanner bases shared by keyword-based language presets. */ /** Build onCommentStart/onCommentEnd for a mix of line + block comment styles.
2
+ * Line comments open as type 1 and close at `\n`; block comments open as type 2
3
+ * and close at the terminator — so a single onCommentEnd serves both. */ function commentRules(style) {
4
+ const line = style.line ?? [];
5
+ const hasSlash = line.includes('//');
6
+ const hasHash = line.includes('#');
7
+ const hasDash = line.includes('--');
8
+ const block = style.block ?? false;
9
+ return {
10
+ onCommentStart (curr, next) {
11
+ if (block && curr === '/' && next === '*') return 2;
12
+ if (hasSlash && curr === '/' && next === '/') return 1;
13
+ if (hasHash && curr === '#') return 1;
14
+ if (hasDash && curr === '-' && next === '-') return 1;
15
+ return 0;
16
+ },
17
+ onCommentEnd (prev, curr) {
18
+ if (curr === '\n') return 1;
19
+ if (block && prev === '*' && curr === '/') return 2;
20
+ return 0;
21
+ }
22
+ };
23
+ }
24
+ /** Assemble a keyword-based language config over the shared general lexer. */ function keywordLang(spec) {
25
+ const config = {};
26
+ if (spec.keywords) config.keywords = new Set(spec.keywords);
27
+ if (spec.typeKeywords) config.typeKeywords = new Set(spec.typeKeywords);
28
+ if (spec.caseInsensitive) config.caseInsensitive = true;
29
+ if (spec.comments) Object.assign(config, commentRules(spec.comments));
30
+ return config;
31
+ }
32
+
33
+ const config = keywordLang({
34
+ keywords: [
35
+ "false",
36
+ "for",
37
+ "if",
38
+ "in",
39
+ "null",
40
+ "true"
41
+ ],
42
+ comments: {
43
+ "line": [
44
+ "//",
45
+ "#"
46
+ ],
47
+ "block": true
48
+ }
49
+ });
50
+
51
+ export { config };
@@ -0,0 +1,12 @@
1
+ import { ParseOptions } from '../core.js';
2
+
3
+ /** A lexer emits these: `[numericType, value]`. */
4
+ type Token = [number, string];
5
+
6
+ /** HTML / XML / markup tokenizer. Also the basis for Svelte markup regions.
7
+ * Emits tags (class), attribute names (property), values (string), and text. */
8
+
9
+ declare const tokenize: (code: string) => Token[];
10
+ declare const config: ParseOptions;
11
+
12
+ export { config, tokenize };
@@ -0,0 +1,168 @@
1
+ /**
2
+ * fractalpop core — token model, line assembly, and rendering.
3
+ *
4
+ * Design: tokens are numeric `[type, value]` pairs during lexing (fast Set/array
5
+ * work); the string type names are resolved only at render. Output is an HTML
6
+ * string with no DOM required — so SSR and client produce identical markup.
7
+ */ /** The stable, ordered token-type list. This list is the theming contract:
8
+ * each type maps to one CSS variable `--fp-<type>` and one class `fp__token--<type>`. */ const TokenTypes = [
9
+ 'identifier',
10
+ 'keyword',
11
+ 'string',
12
+ 'class',
13
+ 'property',
14
+ 'entity',
15
+ 'jsxliterals',
16
+ 'sign',
17
+ 'comment',
18
+ 'break',
19
+ 'space'
20
+ ];
21
+ // Numeric indices, used everywhere in the hot path.
22
+ const T_IDENTIFIER = 0;
23
+ const T_STRING = 2;
24
+ const T_CLASS = 3;
25
+ const T_PROPERTY = 4;
26
+ const T_SIGN = 7;
27
+ const T_COMMENT = 8;
28
+ const T_BREAK = 9;
29
+ const T_SPACE = 10;
30
+ ({
31
+ TokenMap: new Map(TokenTypes.map((type, index)=>[
32
+ type,
33
+ index
34
+ ]))
35
+ });
36
+
37
+ const isSpace = (c)=>c === ' ' || c === '\t' || c === '\r';
38
+ const isNameChar = (c)=>/[A-Za-z0-9_:.\-]/.test(c);
39
+ /** Push text, splitting out newlines (break) and horizontal whitespace (space). */ function pushText(tokens, type, text) {
40
+ if (!text) return;
41
+ let buf = '';
42
+ const flush = ()=>{
43
+ if (buf) {
44
+ tokens.push([
45
+ type,
46
+ buf
47
+ ]);
48
+ buf = '';
49
+ }
50
+ };
51
+ for (const ch of text){
52
+ if (ch === '\n') {
53
+ flush();
54
+ tokens.push([
55
+ T_BREAK,
56
+ '\n'
57
+ ]);
58
+ } else {
59
+ buf += ch;
60
+ }
61
+ }
62
+ flush();
63
+ }
64
+ const tokenize = (code)=>{
65
+ const tokens = [];
66
+ let i = 0;
67
+ const n = code.length;
68
+ while(i < n){
69
+ const curr = code[i];
70
+ // Comment <!-- ... -->
71
+ if (code.startsWith('<!--', i)) {
72
+ const end = code.indexOf('-->', i + 4);
73
+ const stop = end === -1 ? n : end + 3;
74
+ pushText(tokens, T_COMMENT, code.slice(i, stop));
75
+ i = stop;
76
+ continue;
77
+ }
78
+ // Tag start
79
+ if (curr === '<') {
80
+ tokens.push([
81
+ T_SIGN,
82
+ '<'
83
+ ]);
84
+ i++;
85
+ if (code[i] === '/') {
86
+ tokens.push([
87
+ T_SIGN,
88
+ '/'
89
+ ]);
90
+ i++;
91
+ }
92
+ // tag name
93
+ const nameStart = i;
94
+ while(i < n && isNameChar(code[i]))i++;
95
+ if (i > nameStart) tokens.push([
96
+ T_CLASS,
97
+ code.slice(nameStart, i)
98
+ ]);
99
+ // attributes until > or />
100
+ while(i < n && code[i] !== '>'){
101
+ const c = code[i];
102
+ if (c === '\n') {
103
+ tokens.push([
104
+ T_BREAK,
105
+ '\n'
106
+ ]);
107
+ i++;
108
+ } else if (isSpace(c)) {
109
+ const s = i++;
110
+ while(i < n && isSpace(code[i]))i++;
111
+ tokens.push([
112
+ T_SPACE,
113
+ code.slice(s, i)
114
+ ]);
115
+ } else if (c === '/') {
116
+ tokens.push([
117
+ T_SIGN,
118
+ '/'
119
+ ]);
120
+ i++;
121
+ } else if (c === '=') {
122
+ tokens.push([
123
+ T_SIGN,
124
+ '='
125
+ ]);
126
+ i++;
127
+ } else if (c === '"' || c === "'") {
128
+ const q = c;
129
+ const s = i++;
130
+ while(i < n && code[i] !== q)i++;
131
+ if (i < n) i++;
132
+ pushText(tokens, T_STRING, code.slice(s, i));
133
+ } else if (isNameChar(c)) {
134
+ const s = i++;
135
+ while(i < n && isNameChar(code[i]))i++;
136
+ tokens.push([
137
+ T_PROPERTY,
138
+ code.slice(s, i)
139
+ ]);
140
+ } else {
141
+ tokens.push([
142
+ T_SIGN,
143
+ c
144
+ ]);
145
+ i++;
146
+ }
147
+ }
148
+ if (code[i] === '>') {
149
+ tokens.push([
150
+ T_SIGN,
151
+ '>'
152
+ ]);
153
+ i++;
154
+ }
155
+ continue;
156
+ }
157
+ // Text run until next tag
158
+ const start = i;
159
+ while(i < n && code[i] !== '<')i++;
160
+ pushText(tokens, T_IDENTIFIER, code.slice(start, i));
161
+ }
162
+ return tokens;
163
+ };
164
+ const config = {
165
+ tokenize
166
+ };
167
+
168
+ export { config, tokenize };
@@ -0,0 +1,5 @@
1
+ import { ParseOptions } from '../core.js';
2
+
3
+ declare const config: ParseOptions;
4
+
5
+ export { config };
@@ -0,0 +1,96 @@
1
+ /** Reusable comment-scanner bases shared by keyword-based language presets. */ /** Build onCommentStart/onCommentEnd for a mix of line + block comment styles.
2
+ * Line comments open as type 1 and close at `\n`; block comments open as type 2
3
+ * and close at the terminator — so a single onCommentEnd serves both. */ function commentRules(style) {
4
+ const line = style.line ?? [];
5
+ const hasSlash = line.includes('//');
6
+ const hasHash = line.includes('#');
7
+ const hasDash = line.includes('--');
8
+ const block = style.block ?? false;
9
+ return {
10
+ onCommentStart (curr, next) {
11
+ if (block && curr === '/' && next === '*') return 2;
12
+ if (hasSlash && curr === '/' && next === '/') return 1;
13
+ if (hasHash && curr === '#') return 1;
14
+ if (hasDash && curr === '-' && next === '-') return 1;
15
+ return 0;
16
+ },
17
+ onCommentEnd (prev, curr) {
18
+ if (curr === '\n') return 1;
19
+ if (block && prev === '*' && curr === '/') return 2;
20
+ return 0;
21
+ }
22
+ };
23
+ }
24
+ /** Assemble a keyword-based language config over the shared general lexer. */ function keywordLang(spec) {
25
+ const config = {};
26
+ if (spec.keywords) config.keywords = new Set(spec.keywords);
27
+ if (spec.typeKeywords) config.typeKeywords = new Set(spec.typeKeywords);
28
+ if (spec.caseInsensitive) config.caseInsensitive = true;
29
+ if (spec.comments) Object.assign(config, commentRules(spec.comments));
30
+ return config;
31
+ }
32
+
33
+ const config = keywordLang({
34
+ keywords: [
35
+ "abstract",
36
+ "assert",
37
+ "break",
38
+ "case",
39
+ "catch",
40
+ "class",
41
+ "const",
42
+ "continue",
43
+ "default",
44
+ "do",
45
+ "else",
46
+ "enum",
47
+ "extends",
48
+ "final",
49
+ "finally",
50
+ "for",
51
+ "goto",
52
+ "if",
53
+ "implements",
54
+ "import",
55
+ "instanceof",
56
+ "interface",
57
+ "native",
58
+ "new",
59
+ "package",
60
+ "private",
61
+ "protected",
62
+ "public",
63
+ "return",
64
+ "static",
65
+ "strictfp",
66
+ "super",
67
+ "switch",
68
+ "synchronized",
69
+ "this",
70
+ "throw",
71
+ "throws",
72
+ "transient",
73
+ "try",
74
+ "volatile",
75
+ "while"
76
+ ],
77
+ typeKeywords: [
78
+ "boolean",
79
+ "byte",
80
+ "char",
81
+ "double",
82
+ "float",
83
+ "int",
84
+ "long",
85
+ "short",
86
+ "void"
87
+ ],
88
+ comments: {
89
+ "line": [
90
+ "//"
91
+ ],
92
+ "block": true
93
+ }
94
+ });
95
+
96
+ export { config };
@@ -0,0 +1,5 @@
1
+ import { ParseOptions } from '../core.js';
2
+
3
+ declare const config: ParseOptions;
4
+
5
+ export { config };
Binary file
@@ -0,0 +1,5 @@
1
+ import { ParseOptions } from '../core.js';
2
+
3
+ declare const config: ParseOptions;
4
+
5
+ export { config };
@@ -0,0 +1,47 @@
1
+ /** Reusable comment-scanner bases shared by keyword-based language presets. */ /** Build onCommentStart/onCommentEnd for a mix of line + block comment styles.
2
+ * Line comments open as type 1 and close at `\n`; block comments open as type 2
3
+ * and close at the terminator — so a single onCommentEnd serves both. */ function commentRules(style) {
4
+ const line = style.line ?? [];
5
+ const hasSlash = line.includes('//');
6
+ const hasHash = line.includes('#');
7
+ const hasDash = line.includes('--');
8
+ const block = style.block ?? false;
9
+ return {
10
+ onCommentStart (curr, next) {
11
+ if (block && curr === '/' && next === '*') return 2;
12
+ if (hasSlash && curr === '/' && next === '/') return 1;
13
+ if (hasHash && curr === '#') return 1;
14
+ if (hasDash && curr === '-' && next === '-') return 1;
15
+ return 0;
16
+ },
17
+ onCommentEnd (prev, curr) {
18
+ if (curr === '\n') return 1;
19
+ if (block && prev === '*' && curr === '/') return 2;
20
+ return 0;
21
+ }
22
+ };
23
+ }
24
+ /** Assemble a keyword-based language config over the shared general lexer. */ function keywordLang(spec) {
25
+ const config = {};
26
+ if (spec.keywords) config.keywords = new Set(spec.keywords);
27
+ if (spec.typeKeywords) config.typeKeywords = new Set(spec.typeKeywords);
28
+ if (spec.caseInsensitive) config.caseInsensitive = true;
29
+ if (spec.comments) Object.assign(config, commentRules(spec.comments));
30
+ return config;
31
+ }
32
+
33
+ const config = keywordLang({
34
+ keywords: [
35
+ "true",
36
+ "false",
37
+ "null"
38
+ ],
39
+ comments: {
40
+ "line": [
41
+ "//"
42
+ ],
43
+ "block": true
44
+ }
45
+ });
46
+
47
+ export { config };
@@ -0,0 +1,5 @@
1
+ import { ParseOptions } from '../core.js';
2
+
3
+ declare const config: ParseOptions;
4
+
5
+ export { config };