brumate 0.1.1 → 0.3.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 (136) hide show
  1. package/dist/{boot-DN1ZU8Hg.d.ts → boot-C25Sa6vq.d.ts} +27 -2
  2. package/dist/cli.js +2 -2
  3. package/dist/client-BD6XT-s5.js +1968 -0
  4. package/dist/client-BD6XT-s5.js.map +1 -0
  5. package/dist/{client-DwJInP_a.d.ts → client-D0CqSxoO.d.ts} +211 -30
  6. package/dist/{client-routes-DakuM32C.js → client-routes-JTbGtukf.js} +28 -15
  7. package/dist/client-routes-JTbGtukf.js.map +1 -0
  8. package/dist/context-CTiSzQRc.js +27 -0
  9. package/dist/context-CTiSzQRc.js.map +1 -0
  10. package/dist/context-btHuB01Z.d.ts +42 -0
  11. package/dist/{cookies-Av5WFmcf.js → cookies-BzllthiF.js} +2 -1
  12. package/dist/cookies-BzllthiF.js.map +1 -0
  13. package/dist/defer-BbD7JQhj.js +56 -0
  14. package/dist/defer-BbD7JQhj.js.map +1 -0
  15. package/dist/devtools-CQgD7NPB.js +623 -0
  16. package/dist/devtools-CQgD7NPB.js.map +1 -0
  17. package/dist/devtools-panel-BVB-W5q4.js +1930 -0
  18. package/dist/devtools-panel-BVB-W5q4.js.map +1 -0
  19. package/dist/events-CSs7OwIC.js +85 -0
  20. package/dist/events-CSs7OwIC.js.map +1 -0
  21. package/dist/{files-DdT84mPy.js → files-BXSSrQgc.js} +34 -6
  22. package/dist/files-BXSSrQgc.js.map +1 -0
  23. package/dist/forms-Bg-CwGqX.js +406 -0
  24. package/dist/forms-Bg-CwGqX.js.map +1 -0
  25. package/dist/forms-Cl21hkHt.d.ts +281 -0
  26. package/dist/highlight.d.ts +17 -0
  27. package/dist/highlight.js +269 -0
  28. package/dist/highlight.js.map +1 -0
  29. package/dist/html-Bq1rFxX_.d.ts +92 -0
  30. package/dist/html-mNTKzaDD.js +241 -0
  31. package/dist/html-mNTKzaDD.js.map +1 -0
  32. package/dist/index.d.ts +123 -30
  33. package/dist/index.js +14 -6
  34. package/dist/index.js.map +1 -1
  35. package/dist/{inspect-BPchdWbU.js → inspect-BHpOw1LF.js} +1400 -121
  36. package/dist/inspect-BHpOw1LF.js.map +1 -0
  37. package/dist/{loader-Dc9OwY5I.js → loader-Dos_3NP0.js} +47 -11
  38. package/dist/loader-Dos_3NP0.js.map +1 -0
  39. package/dist/{navigate-CzLjnoPH.js → navigate-O78d_zGN.js} +115 -13
  40. package/dist/navigate-O78d_zGN.js.map +1 -0
  41. package/dist/produce-D0V0ICkz.d.ts +114 -0
  42. package/dist/produce-Doc91GkX.js +274 -0
  43. package/dist/produce-Doc91GkX.js.map +1 -0
  44. package/dist/routes-BZNt7DSZ.d.ts +38 -0
  45. package/dist/{rpc-9fSqL_YK.js → rpc-ygMRPmN4.js} +39 -23
  46. package/dist/rpc-ygMRPmN4.js.map +1 -0
  47. package/dist/runtime/batch.d.ts +23 -0
  48. package/dist/runtime/batch.js +69 -0
  49. package/dist/runtime/batch.js.map +1 -0
  50. package/dist/runtime/client.d.ts +5 -5
  51. package/dist/runtime/client.js +5 -1345
  52. package/dist/runtime/context.d.ts +2 -2
  53. package/dist/runtime/context.js +1 -1
  54. package/dist/runtime/devtools.d.ts +191 -5
  55. package/dist/runtime/devtools.js +1 -1
  56. package/dist/runtime/env.d.ts +44 -0
  57. package/dist/runtime/env.js +61 -0
  58. package/dist/runtime/env.js.map +1 -0
  59. package/dist/runtime/events.d.ts +42 -0
  60. package/dist/runtime/events.js +1 -0
  61. package/dist/runtime/forms.d.ts +2 -0
  62. package/dist/runtime/forms.js +1 -0
  63. package/dist/runtime/gather.d.ts +25 -0
  64. package/dist/runtime/gather.js +33 -0
  65. package/dist/runtime/gather.js.map +1 -0
  66. package/dist/runtime/hot.d.ts +1 -1
  67. package/dist/runtime/html.d.ts +2 -2
  68. package/dist/runtime/html.js +1 -1
  69. package/dist/runtime/loader.d.ts +2 -2
  70. package/dist/runtime/loader.js +2 -2
  71. package/dist/runtime/routes.d.ts +2 -21
  72. package/dist/runtime/routes.js +31 -1
  73. package/dist/runtime/routes.js.map +1 -1
  74. package/dist/runtime/server.d.ts +7 -5
  75. package/dist/runtime/server.js +6 -7
  76. package/dist/runtime/signals.d.ts +60 -3
  77. package/dist/runtime/signals.js +40 -2
  78. package/dist/runtime/signals.js.map +1 -1
  79. package/dist/runtime/static-loader.d.ts +2 -2
  80. package/dist/runtime/static-loader.js +1 -1
  81. package/dist/runtime/testing.d.ts +46 -5
  82. package/dist/runtime/testing.js +240 -33
  83. package/dist/runtime/testing.js.map +1 -1
  84. package/dist/runtime/values.d.ts +2 -0
  85. package/dist/runtime/values.js +24 -0
  86. package/dist/runtime/values.js.map +1 -0
  87. package/dist/secrets-BxagsJxJ.js +23 -0
  88. package/dist/secrets-BxagsJxJ.js.map +1 -0
  89. package/dist/server-CxVDYE_V.js +3417 -0
  90. package/dist/server-CxVDYE_V.js.map +1 -0
  91. package/dist/server-DuFYRXrd.d.ts +1460 -0
  92. package/dist/skew-FRmAy9iy.js +49 -0
  93. package/dist/skew-FRmAy9iy.js.map +1 -0
  94. package/dist/standard-schema-BNY82yX3.d.ts +63 -0
  95. package/dist/{static-loader-BcFh4ebX.d.ts → static-loader-Drpr0AzI.d.ts} +2 -2
  96. package/dist/static-loader-nZssh66R.js +333 -0
  97. package/dist/static-loader-nZssh66R.js.map +1 -0
  98. package/dist/stream-DCYZO4IF.js +424 -0
  99. package/dist/stream-DCYZO4IF.js.map +1 -0
  100. package/dist/values-B8C7CLvG.d.ts +63 -0
  101. package/dist/vite.d.ts +49 -1
  102. package/dist/vite.js +598 -68
  103. package/dist/vite.js.map +1 -1
  104. package/forms/forms.brm.ts +141 -0
  105. package/package.json +45 -3
  106. package/types.d.ts +9 -1
  107. package/dist/client-routes-DakuM32C.js.map +0 -1
  108. package/dist/context-BG8KCF3v.js +0 -15
  109. package/dist/context-BG8KCF3v.js.map +0 -1
  110. package/dist/context-aeo9esY9.d.ts +0 -16
  111. package/dist/cookies-Av5WFmcf.js.map +0 -1
  112. package/dist/devtools-BKjnHrnv.js +0 -113
  113. package/dist/devtools-BKjnHrnv.js.map +0 -1
  114. package/dist/devtools-panel-AWOn0VK2.js +0 -434
  115. package/dist/devtools-panel-AWOn0VK2.js.map +0 -1
  116. package/dist/files-DdT84mPy.js.map +0 -1
  117. package/dist/html-DEeoepg3.js +0 -152
  118. package/dist/html-DEeoepg3.js.map +0 -1
  119. package/dist/html-Du8jY2Cc.d.ts +0 -53
  120. package/dist/inspect-BPchdWbU.js.map +0 -1
  121. package/dist/loader-Dc9OwY5I.js.map +0 -1
  122. package/dist/navigate-CzLjnoPH.js.map +0 -1
  123. package/dist/produce-BRGHP7e0.js +0 -126
  124. package/dist/produce-BRGHP7e0.js.map +0 -1
  125. package/dist/produce-CtZ32UGG.d.ts +0 -60
  126. package/dist/rpc-9fSqL_YK.js.map +0 -1
  127. package/dist/runtime/client.js.map +0 -1
  128. package/dist/server-BxqjLUnV.d.ts +0 -753
  129. package/dist/server-DZsgnPKS.js +0 -1615
  130. package/dist/server-DZsgnPKS.js.map +0 -1
  131. package/dist/shared-CWYOd0H3.js +0 -40
  132. package/dist/shared-CWYOd0H3.js.map +0 -1
  133. package/dist/static-loader-ClNkHZGn.js +0 -185
  134. package/dist/static-loader-ClNkHZGn.js.map +0 -1
  135. package/dist/stream-bgNCMcaA.js +0 -280
  136. package/dist/stream-bgNCMcaA.js.map +0 -1
@@ -0,0 +1,281 @@
1
+ //#region src/runtime/forms.d.ts
2
+ /** A part of the path of a field: a key of an object, or an index of a list. */
3
+ type PathSegment = string | number;
4
+ /** The name of the submit button that holds an intent. */
5
+ declare const INTENT = "__intent";
6
+ /** The largest index of a list item in a field name, so a form cannot make a huge array. */
7
+ declare const MAX_INDEX = 999;
8
+ /** Names that would change the prototype of an object, or reach the one of its constructor. */
9
+ declare const FORBIDDEN: ReadonlySet<string>;
10
+ /**
11
+ * The path of a field name: `items[0].name` is `['items', 0, 'name']`.
12
+ * Dots separate keys, and `[n]` is the index of a list item. A number
13
+ * between dots stays a key. Undefined for a name that is not a path, such
14
+ * as one with an empty key, an index above `MAX_INDEX`, or a key such as
15
+ * `__proto__`.
16
+ */
17
+ declare function parsePath(name: string): PathSegment[] | undefined;
18
+ /** The field name of a path: `['items', 0, 'name']` is `items[0].name`. */
19
+ declare function formatPath(path: readonly PathSegment[]): string;
20
+ /** The value at a path, or undefined when a part of the path is missing. */
21
+ declare function getAt(value: unknown, path: readonly PathSegment[]): unknown;
22
+ /**
23
+ * A copy of `value` with `next` at the path. The objects and lists along the
24
+ * path are copied, and the others are shared. A missing part becomes a list
25
+ * for an index and an object for a key.
26
+ */
27
+ declare function setAt(value: unknown, path: readonly PathSegment[], next: unknown): unknown;
28
+ /** A problem that a schema found in the values of a form. */
29
+ interface FormIssue {
30
+ message: string;
31
+ path?: PathSegment[];
32
+ }
33
+ /** The errors of a form: those of each field by field name, and those of the whole form. */
34
+ interface FormErrors {
35
+ errors: Record<string, string[]>;
36
+ formErrors: string[];
37
+ }
38
+ /**
39
+ * Turns the entries of a form into a plain object:
40
+ *
41
+ * - A name that appears once holds its value.
42
+ * - A name that appears more than once holds an array of its values.
43
+ * - A name that ends with `[]` always holds an array, under the name without `[]`.
44
+ * - Dots nest objects: `address.city` is `{ address: { city } }`.
45
+ * - An index in brackets makes a list: `items[0].name` is `{ items: [{ name }] }`.
46
+ * - Values stay strings and files.
47
+ *
48
+ * A name with an empty part, a part such as `__proto__`, an index above
49
+ * 999, or one that needs an object where another field holds a value, is
50
+ * an issue, and the schema does not run.
51
+ */
52
+ declare function formValues(form: FormData, skip?: (name: string) => boolean): {
53
+ value: Record<string, unknown>;
54
+ issues?: undefined;
55
+ } | {
56
+ value?: undefined;
57
+ issues: FormIssue[];
58
+ };
59
+ /** The errors of issues by field name, such as `items[0].name`, and those of the whole form. */
60
+ declare function groupIssues(issues: readonly FormIssue[]): FormErrors;
61
+ /** The schema of a form, as `createForm` reads it: a Standard Schema of version 1. */
62
+ interface FormSchema {
63
+ readonly "~standard": {
64
+ readonly validate: (value: unknown) => unknown;
65
+ };
66
+ }
67
+ /**
68
+ * Validates the fields of a form in the browser, with the schema that the
69
+ * server uses, and groups the errors as `reply` does.
70
+ */
71
+ declare function validateForm(schema: FormSchema, form: FormData): Promise<FormErrors>;
72
+ /** Validates the values of a form in the browser, and groups the errors as `reply` does. */
73
+ declare function validateValues(schema: FormSchema, value: unknown): Promise<FormErrors>;
74
+ /**
75
+ * The errors that the browser found since the last reply: the fields that
76
+ * the user left or changed, and the errors of the form at that time.
77
+ */
78
+ interface CheckedErrors extends FormErrors {
79
+ /** The ID of the reply that the check came after, or undefined before the first submit. */
80
+ reply: string | undefined;
81
+ /** The names of the fields that the user left, whose errors show. */
82
+ touched: string[];
83
+ /** True when the errors of every field show, as after a submit. */
84
+ all: boolean;
85
+ }
86
+ /**
87
+ * A change that a submit button asks for, instead of a submit. The server
88
+ * applies it to the posted values, and answers with them.
89
+ *
90
+ * - `insert` adds an item to a list, at `index` or at its end.
91
+ * - `remove` removes the item at `index`.
92
+ * - `reorder` moves the item at `from` to `to`.
93
+ * - `reset` sets a field, or the whole form, back to its default value.
94
+ * - `validate` answers with the errors of one field.
95
+ */
96
+ type Intent = {
97
+ type: "insert";
98
+ name: string;
99
+ index?: number;
100
+ defaultValue?: unknown;
101
+ } | {
102
+ type: "remove";
103
+ name: string;
104
+ index: number;
105
+ } | {
106
+ type: "reorder";
107
+ name: string;
108
+ from: number;
109
+ to: number;
110
+ } | {
111
+ type: "reset";
112
+ name?: string;
113
+ } | {
114
+ type: "validate";
115
+ name: string;
116
+ };
117
+ /**
118
+ * Reads the intent that a submit button posted, as JSON. Undefined for a
119
+ * value that is not an intent, such as one with a name that is not a path.
120
+ */
121
+ declare function parseIntent(text: string): Intent | undefined;
122
+ /** The value of a submit button that posts an intent. */
123
+ declare function intentValue(intent: Intent): string;
124
+ /**
125
+ * Applies an intent to the posted values. Returns the new values, and the
126
+ * name of the list that it changed. Undefined when the intent does not fit
127
+ * the values, such as an index past the end of the list.
128
+ */
129
+ declare function applyIntent(value: unknown, intent: Intent): {
130
+ value: unknown;
131
+ list?: string;
132
+ } | undefined;
133
+ /**
134
+ * What a server function of a form answers, for `createForm` to show. It is
135
+ * plain data, so it goes through `$action` and the state of the page.
136
+ */
137
+ interface SubmissionResult {
138
+ /** `success` when the values passed the schema, `error` when not, and `intent` for an intent. */
139
+ status: "success" | "error" | "intent";
140
+ /**
141
+ * The values as posted, after the intent, for the fields to show again.
142
+ * Files and hidden fields are left out. Undefined after a reset, so the
143
+ * fields show their default values.
144
+ */
145
+ value?: unknown;
146
+ /** The errors of each field, by field name, such as `items[0].name`. */
147
+ errors: Record<string, string[]>;
148
+ /** The errors of the whole form. */
149
+ formErrors: string[];
150
+ /**
151
+ * The keys of the items of a list that an intent changed, by field name.
152
+ * They are new, so `#for … by` renders the items again, and an element
153
+ * never shows another item. Other lists keep the index as the key.
154
+ */
155
+ keys: Record<string, string[]>;
156
+ /** True when the form goes back to its default values, such as after a save. */
157
+ reset?: boolean;
158
+ /** A new ID for each reply, which keys of new items start with. */
159
+ id: string;
160
+ }
161
+ /** The attributes of a submit button that posts an intent. They work without scripts. */
162
+ interface IntentAttributes {
163
+ type: "submit";
164
+ name: typeof INTENT;
165
+ value: string;
166
+ formnovalidate: true;
167
+ /** With scripts, applies the intent in the browser instead of posting the form. */
168
+ onClick?: (event: MouseEvent) => unknown;
169
+ }
170
+ /**
171
+ * The changes of lists that the browser made since the last reply: the
172
+ * values of the form after them, and the keys of the items of each list.
173
+ */
174
+ interface LocalChanges {
175
+ /** The ID of the reply that the changes came after, or undefined before the first submit. */
176
+ reply: string | undefined;
177
+ value: unknown;
178
+ /** The keys of the items of each list that changed, by field name. */
179
+ keys: Record<string, string[]>;
180
+ }
181
+ /** What `formFields` reads besides the reply: the state of the browser, and the handler of intents. */
182
+ interface FormState {
183
+ checked?: CheckedErrors;
184
+ local?: LocalChanges;
185
+ /** The click handler of an intent button. */
186
+ press?: (intent: Intent) => (event: MouseEvent) => unknown;
187
+ }
188
+ /** The attributes of a field that `createForm` gives. */
189
+ interface FieldAttributes {
190
+ name: string;
191
+ id: string;
192
+ "aria-invalid"?: "true";
193
+ "aria-describedby"?: string;
194
+ value?: string;
195
+ checked?: boolean;
196
+ }
197
+ /** The state of a field: its name, its value and its errors. */
198
+ interface FieldState<T = unknown> {
199
+ /** The field name, such as `items[0].name`. */
200
+ name: string;
201
+ /** The ID of the input, for a `<label for>`. */
202
+ id: string;
203
+ /** The value that the field shows: the posted value after a submit, or the default value. */
204
+ value: T | undefined;
205
+ /** The errors of the field, or undefined when it has none. */
206
+ errors: string[] | undefined;
207
+ /** The attributes of the input: `name`, `id`, the ARIA state of its errors and its value. */
208
+ attrs: FieldAttributes;
209
+ /** The attributes of the element that shows the errors: its ID, and `role="alert"` after a submit. */
210
+ errorAttrs: {
211
+ id: string;
212
+ role?: "alert";
213
+ };
214
+ }
215
+ /** An item of a list field. */
216
+ type ListItem<T> = Field<T> & {
217
+ /** A key that stays with the item when others are added or removed, for `#for … by`. */
218
+ key: string;
219
+ index: number;
220
+ /** The attributes of a button that removes the item. */
221
+ remove: IntentAttributes;
222
+ /** The attributes of a button that moves the item up, or down. */
223
+ moveUp: IntentAttributes;
224
+ moveDown: IntentAttributes;
225
+ };
226
+ /** A field, typed by its value: a list has its items, and an object its fields. */
227
+ type Field<T> = FieldState<T> & (NonNullable<T> extends readonly (infer Item)[] ? {
228
+ list: ListItem<Item>[];
229
+ /** The attributes of a button that adds an item at the end of the list. */
230
+ insert: IntentAttributes;
231
+ } : NonNullable<T> extends Date | File | Blob ? unknown : NonNullable<T> extends object ? {
232
+ fields: Fields<NonNullable<T>>;
233
+ } : unknown);
234
+ /** The fields of an object, by key. */
235
+ type Fields<T> = { [K in keyof T]-?: Field<T[K]>; };
236
+ /** The attributes of a submit button that posts an intent. */
237
+ declare function intentButton(intent: Intent, press?: (intent: Intent) => (event: MouseEvent) => unknown): IntentAttributes;
238
+ /** The changes of the browser when they came after the last reply. */
239
+ declare function localSince(local: LocalChanges | undefined, result: SubmissionResult | undefined): LocalChanges | undefined;
240
+ /**
241
+ * Applies an intent in the browser to the values that the form holds now.
242
+ * The items of the list keep their keys, so their elements and what was
243
+ * typed in them stay, and a new item gets a new key. Undefined when the
244
+ * intent does not fit the values.
245
+ */
246
+ declare function applyLocalIntent(form: HTMLFormElement | null, intent: Intent, local: LocalChanges | undefined, result: SubmissionResult | undefined): LocalChanges | undefined;
247
+ /**
248
+ * The fields of a form, from its default value and the reply of its last
249
+ * submit. A field exists for each key of the default value or of the posted
250
+ * value, so the default value names every field that the form shows.
251
+ */
252
+ declare function formFields<T>(id: string, defaultValue: T | undefined, result: SubmissionResult | undefined, { checked, local, press }?: FormState): Fields<T>;
253
+ /** The check of the browser when it came after the last reply, or undefined when a reply came after it. */
254
+ declare function checkedSince(checked: CheckedErrors | undefined, result: SubmissionResult | undefined): CheckedErrors | undefined;
255
+ /**
256
+ * The errors of the whole form: those that the browser found, when it
257
+ * checked every field since the last reply, or else those of the reply.
258
+ */
259
+ declare function formErrorsOf(result: SubmissionResult | undefined, checked: CheckedErrors | undefined): string[] | undefined;
260
+ /**
261
+ * The next check of the browser, after the user leaves or changes a field.
262
+ * A field counts once the user leaves it. After a submit, every field counts.
263
+ * Undefined when the event changes nothing, such as typing in a field that
264
+ * the user has not left yet.
265
+ */
266
+ declare function checkField(schema: FormSchema, form: HTMLFormElement | null, name: string, left: boolean, checked: CheckedErrors | undefined, result: SubmissionResult | undefined): Promise<CheckedErrors | undefined>;
267
+ /**
268
+ * The attributes of a submit button that the form presses on Enter. Without
269
+ * it, Enter in a field presses the first submit button of the form, which
270
+ * can be an intent button, such as "Remove". It is hidden from sight and
271
+ * from assistive technology, and cannot take focus.
272
+ */
273
+ declare const DEFAULT_SUBMIT: {
274
+ readonly type: "submit";
275
+ readonly tabindex: -1;
276
+ readonly "aria-hidden": "true";
277
+ readonly style: "position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap;border:0;padding:0;margin:-1px";
278
+ };
279
+ //#endregion
280
+ export { intentValue as A, formErrorsOf as C, getAt as D, formatPath as E, validateForm as F, validateValues as I, parseIntent as M, parsePath as N, groupIssues as O, setAt as P, checkedSince as S, formValues as T, PathSegment as _, FieldAttributes as a, applyLocalIntent as b, FormErrors as c, INTENT as d, Intent as f, MAX_INDEX as g, LocalChanges as h, Field as i, localSince as j, intentButton as k, FormIssue as l, ListItem as m, DEFAULT_SUBMIT as n, FieldState as o, IntentAttributes as p, FORBIDDEN as r, Fields as s, CheckedErrors as t, FormState as u, SubmissionResult as v, formFields as w, checkField as x, applyIntent as y };
281
+ //# sourceMappingURL=forms-Cl21hkHt.d.ts.map
@@ -0,0 +1,17 @@
1
+ import { LanguageFactory, LanguageOptions, RenderOptions } from "@twinkleplop/core";
2
+ import { Grammar } from "@twinkleplop/core/compile";
3
+ //#region src/highlight.d.ts
4
+ export declare const rawGrammar: Grammar;
5
+ export declare const tokenize: LanguageFactory;
6
+ /** Returns a function that highlights `.brm` code as HTML. */
7
+ export declare function language(options?: LanguageOptions): (input: string, render?: RenderOptions) => string;
8
+ /**
9
+ * The colours of the GitHub theme of twinkleplop as CSS, for code under a
10
+ * `.twinkleplop` element. The devtools put it in their shadow root, where
11
+ * the stylesheets of the page do not reach.
12
+ */
13
+ export declare function themeCSS(theme?: "dark" | "light"): string;
14
+ /** Highlights code of a file by its extension: `.brm`, `.css`, or TypeScript and the rest. */
15
+ export declare function highlightFile(file: string, code: string, render?: RenderOptions): string;
16
+ //#endregion
17
+ //# sourceMappingURL=highlight.d.ts.map
@@ -0,0 +1,269 @@
1
+ import { always, create_language, embed_grammars, enter, fallback, goto, keyword, leave, match, on, range, to_html, within } from "@twinkleplop/core";
2
+ import { compile, define_grammar } from "@twinkleplop/core/compile";
3
+ import * as TOKENS from "@twinkleplop/core/tokens";
4
+ import { tokenize as tokenize$1 } from "@twinkleplop/css";
5
+ import { tokenize as tokenize$2 } from "@twinkleplop/tsx";
6
+ import { dark, light } from "@twinkleplop/theme-github/tokens";
7
+ //#region src/highlight.ts
8
+ /**
9
+ * A twinkleplop language for `.brm` files, for the devtools and the website: HTML-like markup with `{…}`
10
+ * expressions, attribute values without quotes, control flow blocks such as
11
+ * `#if (a) { … }`, dynamic tags `<{tag}>`, and `<script>` and `<style>`
12
+ * blocks. Scripts and expressions are highlighted as TSX, styles as CSS.
13
+ *
14
+ * Like the Svelte grammar of twinkleplop, it marks the raw text of scripts,
15
+ * styles and expressions, and a reclassifier hands each one to its language.
16
+ */
17
+ const WHITESPACE = [
18
+ " ",
19
+ " ",
20
+ "\n",
21
+ "\r"
22
+ ];
23
+ const TAG_NAME_CHARS = range([
24
+ ["a", "z"],
25
+ ["A", "Z"],
26
+ ["0", "9"],
27
+ ["-", "-"],
28
+ ["_", "_"],
29
+ [":", ":"],
30
+ [".", "."],
31
+ ["$", "$"]
32
+ ]);
33
+ const WORD_CHARS = range([
34
+ ["a", "z"],
35
+ ["A", "Z"],
36
+ ["0", "9"],
37
+ ["_", "_"],
38
+ ["$", "$"]
39
+ ]);
40
+ const ASCII_ALPHA = range([["a", "z"], ["A", "Z"]]);
41
+ const ATTR_NAME_CHARS = range([
42
+ ["a", "z"],
43
+ ["A", "Z"],
44
+ ["0", "9"],
45
+ ["-", "-"],
46
+ ["_", "_"],
47
+ ["$", "$"]
48
+ ]);
49
+ const BARE_VALUE_CHARS = range([
50
+ ["!", "!"],
51
+ ["#", "&"],
52
+ ["*", "."],
53
+ ["0", "="],
54
+ ["?", "Z"],
55
+ ["\\", "\\"],
56
+ ["^", "~"]
57
+ ]);
58
+ const BLOCK_KEYWORDS = [
59
+ "if",
60
+ "else if",
61
+ "else",
62
+ "for",
63
+ "repeat",
64
+ "switch",
65
+ "case",
66
+ "default",
67
+ "try",
68
+ "catch",
69
+ "loading",
70
+ "portal",
71
+ "head",
72
+ "client",
73
+ "offscreen",
74
+ "key",
75
+ "template"
76
+ ];
77
+ const RAW = TOKENS.raw_svelte_expression;
78
+ const rawSkips = [
79
+ within("\"", "\"", RAW, {
80
+ escape: "\\",
81
+ multiline: true
82
+ }),
83
+ within("'", "'", RAW, {
84
+ escape: "\\",
85
+ multiline: true
86
+ }),
87
+ within("`", "`", RAW, {
88
+ escape: "\\",
89
+ multiline: true
90
+ }),
91
+ within("/*", "*/", RAW, { multiline: true }),
92
+ within("//", "\n", RAW)
93
+ ];
94
+ const expressionRules = [
95
+ ...rawSkips,
96
+ match("{", RAW, enter("expression_brace")),
97
+ fallback({ token: RAW })
98
+ ];
99
+ const tagRules = [
100
+ on(WHITESPACE),
101
+ match("=", TOKENS.operator, enter("attr_value")),
102
+ match("{", TOKENS.expression, enter("expression_body")),
103
+ match("[", RAW, enter("raw_group")),
104
+ match(ATTR_NAME_CHARS, TOKENS.attr_name),
105
+ match(":", TOKENS.attr_name)
106
+ ];
107
+ /** Raw code between `start` and `end` that ends the state, as in `<\/script>`. */
108
+ function rawBlock(name, token) {
109
+ return {
110
+ [`${name}_attrs`]: { rules: [
111
+ match(">", TOKENS.punctuation, goto(`${name}_content`)),
112
+ on(WHITESPACE),
113
+ match("=", TOKENS.operator),
114
+ within("\"", "\"", TOKENS.string),
115
+ within("'", "'", TOKENS.string),
116
+ match(ATTR_NAME_CHARS, TOKENS.attr_name)
117
+ ] },
118
+ [`${name}_content`]: { rules: [on("</", enter(`${name}_close_probe`)), fallback({ token })] },
119
+ [`${name}_close_probe`]: {
120
+ mode: "probe",
121
+ fallback: `${name}_close_fail`,
122
+ rules: [on(`${name}>`, goto(`${name}_close`)), fallback(goto(`${name}_close_fail`))]
123
+ },
124
+ [`${name}_close_fail`]: { rules: [match("<", token, leave())] },
125
+ [`${name}_close`]: { rules: [
126
+ match("</", TOKENS.punctuation),
127
+ match(name, TOKENS.tag_name),
128
+ match(">", TOKENS.punctuation, goto("content"))
129
+ ] }
130
+ };
131
+ }
132
+ const rawGrammar = define_grammar({
133
+ name: "brm",
134
+ states: {
135
+ content: { rules: [
136
+ within("<!--", "-->", TOKENS.comment),
137
+ match("</", TOKENS.punctuation, enter("close_tag")),
138
+ on("<", enter("lt_probe")),
139
+ on("#", enter("hash_probe")),
140
+ match("{", TOKENS.expression, enter("expression_body")),
141
+ match("}", TOKENS.punctuation),
142
+ fallback({})
143
+ ] },
144
+ hash_probe: {
145
+ mode: "probe",
146
+ fallback: "hash_text",
147
+ rules: [on(BLOCK_KEYWORDS, {
148
+ boundary: true,
149
+ ...enter("block_start")
150
+ }), fallback(enter("hash_text"))]
151
+ },
152
+ hash_text: { rules: [on("#"), fallback(leave())] },
153
+ block_start: { rules: [match("#", TOKENS.svelte_block, goto("block_keyword"))] },
154
+ block_keyword: { rules: [keyword(["template"], goto("template_name"), TOKENS.svelte_block), match(BLOCK_KEYWORDS, TOKENS.svelte_block, goto("block_header"))] },
155
+ template_name: { rules: [
156
+ on(WHITESPACE),
157
+ match(ATTR_NAME_CHARS, TOKENS.function, goto("template_name_rest")),
158
+ fallback(goto("block_header"))
159
+ ] },
160
+ template_name_rest: { rules: [match(ATTR_NAME_CHARS, TOKENS.function), fallback(goto("block_header"))] },
161
+ block_header: { rules: [
162
+ on(WHITESPACE),
163
+ match("(", TOKENS.punctuation, goto("block_header_body")),
164
+ match("{", TOKENS.punctuation, leave()),
165
+ fallback(leave())
166
+ ] },
167
+ block_header_body: { rules: [
168
+ ...rawSkips,
169
+ match(["(", "["], RAW, enter("raw_group")),
170
+ match(")", TOKENS.punctuation, goto("block_header")),
171
+ keyword(["by"], {}, TOKENS.keyword),
172
+ match(WORD_CHARS, RAW, enter("raw_word")),
173
+ fallback({ token: RAW })
174
+ ] },
175
+ raw_word: { rules: [match(WORD_CHARS, RAW), fallback(leave())] },
176
+ lt_probe: {
177
+ mode: "probe",
178
+ fallback: "lt_text",
179
+ rules: [
180
+ on(ASCII_ALPHA, enter("lt_tag")),
181
+ on([">", "{"], enter("lt_tag")),
182
+ fallback(enter("lt_text"))
183
+ ]
184
+ },
185
+ lt_tag: { rules: [match("<", TOKENS.punctuation, goto("tag_start"))] },
186
+ lt_text: { rules: [on("<"), fallback(leave())] },
187
+ tag_start: { rules: [
188
+ keyword(["script"], goto("script_attrs"), TOKENS.tag_name),
189
+ keyword(["style"], goto("style_attrs"), TOKENS.tag_name),
190
+ match(">", TOKENS.punctuation, leave()),
191
+ match("{", TOKENS.expression, goto("dynamic_tag")),
192
+ match(TAG_NAME_CHARS, TOKENS.tag_name, goto("tag_open"))
193
+ ] },
194
+ dynamic_tag: { rules: [match("}", TOKENS.expression, goto("tag_attrs")), ...expressionRules] },
195
+ tag_open: { rules: [
196
+ match("/>", TOKENS.punctuation, leave()),
197
+ match(">", TOKENS.punctuation, leave()),
198
+ on(WHITESPACE, goto("tag_attrs")),
199
+ match(TAG_NAME_CHARS, TOKENS.tag_name)
200
+ ] },
201
+ tag_attrs: { rules: [
202
+ match("/>", TOKENS.punctuation, leave()),
203
+ match(">", TOKENS.punctuation, leave()),
204
+ ...tagRules
205
+ ] },
206
+ close_tag: { rules: [
207
+ match(">", TOKENS.punctuation, leave()),
208
+ on(WHITESPACE),
209
+ match(TAG_NAME_CHARS, TOKENS.tag_name)
210
+ ] },
211
+ attr_value: { rules: [
212
+ within("\"", "\"", TOKENS.string, { multiline: true }),
213
+ within("'", "'", TOKENS.string, { multiline: true }),
214
+ match("{", TOKENS.expression, goto("expression_body")),
215
+ fallback(goto("bare_value"))
216
+ ] },
217
+ bare_value: { rules: [
218
+ ...rawSkips,
219
+ match(["(", "["], RAW, enter("raw_group")),
220
+ match(BARE_VALUE_CHARS, RAW),
221
+ fallback(leave())
222
+ ] },
223
+ raw_group: { rules: [
224
+ ...rawSkips,
225
+ match(["(", "["], RAW, enter("raw_group")),
226
+ match([")", "]"], RAW, leave()),
227
+ fallback({ token: RAW })
228
+ ] },
229
+ expression_body: { rules: [match("}", TOKENS.expression, leave()), ...expressionRules] },
230
+ expression_brace: { rules: [match("}", RAW, leave()), ...expressionRules] },
231
+ ...rawBlock("script", TOKENS.raw_script),
232
+ ...rawBlock("style", TOKENS.raw_style)
233
+ }
234
+ });
235
+ let tsxLanguage;
236
+ let cssLanguage;
237
+ const embedTsx = (input) => (tsxLanguage ??= tokenize$2())(input);
238
+ const tokenize = create_language(compile(rawGrammar), [always(embed_grammars({
239
+ [TOKENS.raw_script]: embedTsx,
240
+ [TOKENS.raw_svelte_expression]: embedTsx,
241
+ [TOKENS.raw_style]: (input) => (cssLanguage ??= tokenize$1())(input)
242
+ }), "embed")]);
243
+ /** Returns a function that highlights `.brm` code as HTML. */
244
+ function language(options) {
245
+ const run = tokenize(options);
246
+ return (input, render) => to_html(input, run(input), render);
247
+ }
248
+ /**
249
+ * The colours of the GitHub theme of twinkleplop as CSS, for code under a
250
+ * `.twinkleplop` element. The devtools put it in their shadow root, where
251
+ * the stylesheets of the page do not reach.
252
+ */
253
+ function themeCSS(theme = "dark") {
254
+ return Object.entries(theme === "dark" ? dark : light).filter(([token]) => token !== "background_color").map(([token, color]) => `.twinkleplop .${token} { color: ${color}; }`).join("\n");
255
+ }
256
+ /** Highlights code of a file by its extension: `.brm`, `.css`, or TypeScript and the rest. */
257
+ function highlightFile(file, code, render) {
258
+ const extension = /\.(\w+)(?:\?.*)?$/.exec(file)?.[1] ?? "";
259
+ let run;
260
+ if (extension === "brm") run = brmLanguage ??= tokenize();
261
+ else if (extension === "css") run = cssLanguage ??= tokenize$1();
262
+ else run = tsxLanguage ??= tokenize$2();
263
+ return to_html(code, run(code), render);
264
+ }
265
+ let brmLanguage;
266
+ //#endregion
267
+ export { highlightFile, language, rawGrammar, themeCSS, tokenize };
268
+
269
+ //# sourceMappingURL=highlight.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"highlight.js","names":["tsx","css"],"sources":["../src/highlight.ts"],"sourcesContent":["/**\n * A twinkleplop language for `.brm` files, for the devtools and the website: HTML-like markup with `{…}`\n * expressions, attribute values without quotes, control flow blocks such as\n * `#if (a) { … }`, dynamic tags `<{tag}>`, and `<script>` and `<style>`\n * blocks. Scripts and expressions are highlighted as TSX, styles as CSS.\n *\n * Like the Svelte grammar of twinkleplop, it marks the raw text of scripts,\n * styles and expressions, and a reclassifier hands each one to its language.\n */\nimport {\n always,\n create_language,\n embed_grammars,\n enter,\n fallback,\n goto,\n keyword,\n leave,\n match,\n on,\n range,\n to_html,\n within,\n} from '@twinkleplop/core';\nimport type { LanguageFactory, LanguageOptions, RenderOptions } from '@twinkleplop/core';\nimport type { Grammar } from '@twinkleplop/core/compile';\nimport { compile, define_grammar } from '@twinkleplop/core/compile';\nimport * as TOKENS from '@twinkleplop/core/tokens';\nimport { tokenize as css } from '@twinkleplop/css';\nimport { tokenize as tsx } from '@twinkleplop/tsx';\nimport { dark, light } from '@twinkleplop/theme-github/tokens';\n\nconst WHITESPACE = [' ', '\\t', '\\n', '\\r'];\n\nconst TAG_NAME_CHARS = range([\n ['a', 'z'],\n ['A', 'Z'],\n ['0', '9'],\n ['-', '-'],\n ['_', '_'],\n [':', ':'],\n ['.', '.'],\n ['$', '$'],\n]);\n\nconst WORD_CHARS = range([\n ['a', 'z'],\n ['A', 'Z'],\n ['0', '9'],\n ['_', '_'],\n ['$', '$'],\n]);\n\nconst ASCII_ALPHA = range([\n ['a', 'z'],\n ['A', 'Z'],\n]);\n\nconst ATTR_NAME_CHARS = range([\n ['a', 'z'],\n ['A', 'Z'],\n ['0', '9'],\n ['-', '-'],\n ['_', '_'],\n ['$', '$'],\n]);\n\n// The characters of an attribute value without quotes, such as\n// `props.items[0]`. Whitespace, `>` and `/` end it.\nconst BARE_VALUE_CHARS = range([\n ['!', '!'],\n ['#', '&'],\n ['*', '.'],\n ['0', '='],\n ['?', 'Z'],\n ['\\\\', '\\\\'],\n ['^', '~'],\n]);\n\n// Sorted longest first by the compiler, so `else if` beats `else`.\nconst BLOCK_KEYWORDS = [\n 'if',\n 'else if',\n 'else',\n 'for',\n 'repeat',\n 'switch',\n 'case',\n 'default',\n 'try',\n 'catch',\n 'loading',\n 'portal',\n 'head',\n 'client',\n 'offscreen',\n 'key',\n 'template',\n];\n\nconst RAW = TOKENS.raw_svelte_expression;\n\n// Strings and comments in raw code, so their brackets do not count.\nconst rawSkips = [\n within('\"', '\"', RAW, { escape: '\\\\', multiline: true }),\n within(\"'\", \"'\", RAW, { escape: '\\\\', multiline: true }),\n within('`', '`', RAW, { escape: '\\\\', multiline: true }),\n within('/*', '*/', RAW, { multiline: true }),\n within('//', '\\n', RAW),\n];\n\n// Inside `{…}`, nested braces are tracked until the brace that closes it.\nconst expressionRules = [\n ...rawSkips,\n match('{', RAW, enter('expression_brace')),\n fallback({ token: RAW }),\n];\n\nconst tagRules = [\n on(WHITESPACE),\n match('=', TOKENS.operator, enter('attr_value')),\n match('{', TOKENS.expression, enter('expression_body')),\n match('[', RAW, enter('raw_group')),\n match(ATTR_NAME_CHARS, TOKENS.attr_name),\n match(':', TOKENS.attr_name),\n];\n\n/** Raw code between `start` and `end` that ends the state, as in `</script>`. */\nfunction rawBlock(name: 'script' | 'style', token: string) {\n return {\n [`${name}_attrs`]: {\n rules: [\n match('>', TOKENS.punctuation, goto(`${name}_content`)),\n on(WHITESPACE),\n match('=', TOKENS.operator),\n within('\"', '\"', TOKENS.string),\n within(\"'\", \"'\", TOKENS.string),\n match(ATTR_NAME_CHARS, TOKENS.attr_name),\n ],\n },\n [`${name}_content`]: {\n rules: [on('</', enter(`${name}_close_probe`)), fallback({ token })],\n },\n [`${name}_close_probe`]: {\n mode: 'probe' as const,\n fallback: `${name}_close_fail`,\n rules: [on(`${name}>`, goto(`${name}_close`)), fallback(goto(`${name}_close_fail`))],\n },\n [`${name}_close_fail`]: { rules: [match('<', token, leave())] },\n [`${name}_close`]: {\n rules: [\n match('</', TOKENS.punctuation),\n match(name, TOKENS.tag_name),\n match('>', TOKENS.punctuation, goto('content')),\n ],\n },\n };\n}\n\nexport const rawGrammar: Grammar = define_grammar({\n name: 'brm',\n states: {\n content: {\n rules: [\n within('<!--', '-->', TOKENS.comment),\n match('</', TOKENS.punctuation, enter('close_tag')),\n on('<', enter('lt_probe')),\n on('#', enter('hash_probe')),\n match('{', TOKENS.expression, enter('expression_body')),\n // The brace that closes a block body.\n match('}', TOKENS.punctuation),\n fallback({}),\n ],\n },\n\n // `#` starts a block only before a known keyword, so `#1` stays text.\n hash_probe: {\n mode: 'probe',\n fallback: 'hash_text',\n rules: [\n on(BLOCK_KEYWORDS, { boundary: true, ...enter('block_start') }),\n fallback(enter('hash_text')),\n ],\n },\n hash_text: { rules: [on('#'), fallback(leave())] },\n block_start: {\n rules: [match('#', TOKENS.svelte_block, goto('block_keyword'))],\n },\n block_keyword: {\n rules: [\n keyword(['template'], goto('template_name'), TOKENS.svelte_block),\n match(BLOCK_KEYWORDS, TOKENS.svelte_block, goto('block_header')),\n ],\n },\n // A range matches one character, so the name continues in its own state.\n template_name: {\n rules: [\n on(WHITESPACE),\n match(ATTR_NAME_CHARS, TOKENS.function, goto('template_name_rest')),\n fallback(goto('block_header')),\n ],\n },\n template_name_rest: {\n rules: [match(ATTR_NAME_CHARS, TOKENS.function), fallback(goto('block_header'))],\n },\n // An optional header in parentheses, then the `{` of the body.\n block_header: {\n rules: [\n on(WHITESPACE),\n match('(', TOKENS.punctuation, goto('block_header_body')),\n match('{', TOKENS.punctuation, leave()),\n fallback(leave()),\n ],\n },\n // `by` in `#for (item of list by item.id)` is a keyword of the block.\n // Words are read whole, so `by` only matches on its own.\n block_header_body: {\n rules: [\n ...rawSkips,\n match(['(', '['], RAW, enter('raw_group')),\n match(')', TOKENS.punctuation, goto('block_header')),\n keyword(['by'], {}, TOKENS.keyword),\n match(WORD_CHARS, RAW, enter('raw_word')),\n fallback({ token: RAW }),\n ],\n },\n raw_word: {\n rules: [match(WORD_CHARS, RAW), fallback(leave())],\n },\n\n // `<` opens a tag before a letter, `>` (a fragment) or `{` (a dynamic tag).\n lt_probe: {\n mode: 'probe',\n fallback: 'lt_text',\n rules: [\n on(ASCII_ALPHA, enter('lt_tag')),\n on(['>', '{'], enter('lt_tag')),\n fallback(enter('lt_text')),\n ],\n },\n lt_tag: { rules: [match('<', TOKENS.punctuation, goto('tag_start'))] },\n lt_text: { rules: [on('<'), fallback(leave())] },\n\n tag_start: {\n rules: [\n keyword(['script'], goto('script_attrs'), TOKENS.tag_name),\n keyword(['style'], goto('style_attrs'), TOKENS.tag_name),\n match('>', TOKENS.punctuation, leave()),\n match('{', TOKENS.expression, goto('dynamic_tag')),\n match(TAG_NAME_CHARS, TOKENS.tag_name, goto('tag_open')),\n ],\n },\n dynamic_tag: {\n rules: [match('}', TOKENS.expression, goto('tag_attrs')), ...expressionRules],\n },\n tag_open: {\n rules: [\n match('/>', TOKENS.punctuation, leave()),\n match('>', TOKENS.punctuation, leave()),\n on(WHITESPACE, goto('tag_attrs')),\n match(TAG_NAME_CHARS, TOKENS.tag_name),\n ],\n },\n tag_attrs: {\n rules: [\n match('/>', TOKENS.punctuation, leave()),\n match('>', TOKENS.punctuation, leave()),\n ...tagRules,\n ],\n },\n close_tag: {\n rules: [\n match('>', TOKENS.punctuation, leave()),\n on(WHITESPACE),\n match(TAG_NAME_CHARS, TOKENS.tag_name),\n ],\n },\n\n // The value after `=`: a string, an object in braces, or code without quotes.\n attr_value: {\n rules: [\n within('\"', '\"', TOKENS.string, { multiline: true }),\n within(\"'\", \"'\", TOKENS.string, { multiline: true }),\n match('{', TOKENS.expression, goto('expression_body')),\n fallback(goto('bare_value')),\n ],\n },\n bare_value: {\n rules: [\n ...rawSkips,\n match(['(', '['], RAW, enter('raw_group')),\n match(BARE_VALUE_CHARS, RAW),\n fallback(leave()),\n ],\n },\n raw_group: {\n rules: [\n ...rawSkips,\n match(['(', '['], RAW, enter('raw_group')),\n match([')', ']'], RAW, leave()),\n fallback({ token: RAW }),\n ],\n },\n\n expression_body: {\n rules: [match('}', TOKENS.expression, leave()), ...expressionRules],\n },\n expression_brace: {\n rules: [match('}', RAW, leave()), ...expressionRules],\n },\n\n ...rawBlock('script', TOKENS.raw_script),\n ...rawBlock('style', TOKENS.raw_style),\n },\n});\n\nlet tsxLanguage: ReturnType<typeof tsx> | undefined;\nlet cssLanguage: ReturnType<typeof css> | undefined;\nconst embedTsx = (input: string) => (tsxLanguage ??= tsx())(input);\n\nexport const tokenize: LanguageFactory = create_language(compile(rawGrammar), [\n always(\n embed_grammars({\n [TOKENS.raw_script]: embedTsx,\n [TOKENS.raw_svelte_expression]: embedTsx,\n [TOKENS.raw_style]: (input: string) => (cssLanguage ??= css())(input),\n }),\n 'embed',\n ),\n]);\n\n/** Returns a function that highlights `.brm` code as HTML. */\nexport function language(options?: LanguageOptions) {\n const run = tokenize(options);\n return (input: string, render?: RenderOptions): string => to_html(input, run(input), render);\n}\n\n/**\n * The colours of the GitHub theme of twinkleplop as CSS, for code under a\n * `.twinkleplop` element. The devtools put it in their shadow root, where\n * the stylesheets of the page do not reach.\n */\nexport function themeCSS(theme: 'dark' | 'light' = 'dark'): string {\n const palette = theme === 'dark' ? dark : light;\n return Object.entries(palette)\n .filter(([token]) => token !== 'background_color')\n .map(([token, color]) => `.twinkleplop .${token} { color: ${color}; }`)\n .join('\\n');\n}\n\n/** Highlights code of a file by its extension: `.brm`, `.css`, or TypeScript and the rest. */\nexport function highlightFile(file: string, code: string, render?: RenderOptions): string {\n const extension = /\\.(\\w+)(?:\\?.*)?$/.exec(file)?.[1] ?? '';\n let run: ReturnType<LanguageFactory>;\n if (extension === 'brm') {\n run = brmLanguage ??= tokenize();\n } else if (extension === 'css') {\n run = cssLanguage ??= css();\n } else {\n run = tsxLanguage ??= tsx();\n }\n return to_html(code, run(code), render);\n}\n\nlet brmLanguage: ReturnType<LanguageFactory> | undefined;\n"],"mappings":";;;;;;;;;;;;;;;;AAgCA,MAAM,aAAa;CAAC;CAAK;CAAM;CAAM;AAAI;AAEzC,MAAM,iBAAiB,MAAM;CAC3B,CAAC,KAAK,GAAG;CACT,CAAC,KAAK,GAAG;CACT,CAAC,KAAK,GAAG;CACT,CAAC,KAAK,GAAG;CACT,CAAC,K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