@alivault/pico 0.3.2 → 0.5.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/.output/nitro.json +1 -1
- package/.output/public/assets/{index-ga3WrbUv.js → index-Di2FsKXl.js} +3 -3
- package/.output/public/assets/routes-3i6aEePK.js +2156 -0
- package/.output/public/assets/styles-CUjj8zXo.css +2 -0
- package/.output/public/screenshots/pico-mobile-alt.png +0 -0
- package/.output/public/screenshots/pico-mobile.png +0 -0
- package/.output/public/screenshots/pico-workspace-alt.png +0 -0
- package/.output/public/screenshots/pico-workspace.png +0 -0
- package/.output/server/_libs/@pierre/diffs+[...].mjs +53 -1
- package/.output/server/_libs/entities.mjs +372 -0
- package/.output/server/_libs/hast-util-from-parse5+[...].mjs +741 -0
- package/.output/server/_libs/hast-util-raw+[...].mjs +7897 -0
- package/.output/server/_libs/hast-util-sanitize.mjs +780 -0
- package/.output/server/_libs/hast-util-to-jsx-runtime+[...].mjs +3 -82
- package/.output/server/_libs/mdast-util-find-and-replace.mjs +198 -0
- package/.output/server/_libs/mdast-util-gfm+[...].mjs +4 -288
- package/.output/server/_libs/mdast-util-to-hast+[...].mjs +1 -2
- package/.output/server/_libs/react-markdown+[...].mjs +1 -1
- package/.output/server/_libs/rehype-raw.mjs +37 -0
- package/.output/server/_libs/rehype-sanitize.mjs +27 -0
- package/.output/server/_ssr/{router-DQcefit6.mjs → router-DxIs8YF4.mjs} +3 -3
- package/.output/server/_ssr/{routes-C7eO3ZVn.mjs → routes-BgLr8w7S.mjs} +286 -161
- package/.output/server/_ssr/{routes-DHXvlqAP.mjs → routes-DZ8MN7tJ.mjs} +2 -2
- package/.output/server/_ssr/ssr.mjs +2 -2
- package/.output/server/{_tanstack-start-manifest_v-ChF3TvKp.mjs → _tanstack-start-manifest_v-CxIiv5yq.mjs} +4 -4
- package/.output/server/index.mjs +486 -472
- package/README.md +6 -2
- package/package.json +3 -1
- package/public/screenshots/pico-mobile-alt.png +0 -0
- package/public/screenshots/pico-mobile.png +0 -0
- package/public/screenshots/pico-workspace-alt.png +0 -0
- package/public/screenshots/pico-workspace.png +0 -0
- package/.output/public/assets/routes-BApV813x.js +0 -2151
- package/.output/public/assets/styles-4lJzavCj.css +0 -2
- package/.output/server/_libs/mdast-util-find-and-replace+[...].mjs +0 -636
|
@@ -0,0 +1,741 @@
|
|
|
1
|
+
import { d as svg, f as find, i as parse, m as normalize, o as parse$1, u as html } from "./@pierre/diffs+[...].mjs";
|
|
2
|
+
import "./devlop.mjs";
|
|
3
|
+
//#region node_modules/.pnpm/hast-util-parse-selector@4.0.0/node_modules/hast-util-parse-selector/lib/index.js
|
|
4
|
+
/**
|
|
5
|
+
* @typedef {import('hast').Element} Element
|
|
6
|
+
* @typedef {import('hast').Properties} Properties
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* @template {string} SimpleSelector
|
|
10
|
+
* Selector type.
|
|
11
|
+
* @template {string} DefaultTagName
|
|
12
|
+
* Default tag name.
|
|
13
|
+
* @typedef {(
|
|
14
|
+
* SimpleSelector extends ''
|
|
15
|
+
* ? DefaultTagName
|
|
16
|
+
* : SimpleSelector extends `${infer TagName}.${infer Rest}`
|
|
17
|
+
* ? ExtractTagName<TagName, DefaultTagName>
|
|
18
|
+
* : SimpleSelector extends `${infer TagName}#${infer Rest}`
|
|
19
|
+
* ? ExtractTagName<TagName, DefaultTagName>
|
|
20
|
+
* : SimpleSelector extends string
|
|
21
|
+
* ? SimpleSelector
|
|
22
|
+
* : DefaultTagName
|
|
23
|
+
* )} ExtractTagName
|
|
24
|
+
* Extract tag name from a simple selector.
|
|
25
|
+
*/
|
|
26
|
+
var search = /[#.]/g;
|
|
27
|
+
/**
|
|
28
|
+
* Create a hast element from a simple CSS selector.
|
|
29
|
+
*
|
|
30
|
+
* @template {string} Selector
|
|
31
|
+
* Type of selector.
|
|
32
|
+
* @template {string} [DefaultTagName='div']
|
|
33
|
+
* Type of default tag name (default: `'div'`).
|
|
34
|
+
* @param {Selector | null | undefined} [selector]
|
|
35
|
+
* Simple CSS selector (optional).
|
|
36
|
+
*
|
|
37
|
+
* Can contain a tag name (`foo`), classes (`.bar`), and an ID (`#baz`).
|
|
38
|
+
* Multiple classes are allowed.
|
|
39
|
+
* Uses the last ID if multiple IDs are found.
|
|
40
|
+
* @param {DefaultTagName | null | undefined} [defaultTagName='div']
|
|
41
|
+
* Tag name to use if `selector` does not specify one (default: `'div'`).
|
|
42
|
+
* @returns {Element & {tagName: ExtractTagName<Selector, DefaultTagName>}}
|
|
43
|
+
* Built element.
|
|
44
|
+
*/
|
|
45
|
+
function parseSelector(selector, defaultTagName) {
|
|
46
|
+
const value = selector || "";
|
|
47
|
+
/** @type {Properties} */
|
|
48
|
+
const props = {};
|
|
49
|
+
let start = 0;
|
|
50
|
+
/** @type {string | undefined} */
|
|
51
|
+
let previous;
|
|
52
|
+
/** @type {string | undefined} */
|
|
53
|
+
let tagName;
|
|
54
|
+
while (start < value.length) {
|
|
55
|
+
search.lastIndex = start;
|
|
56
|
+
const match = search.exec(value);
|
|
57
|
+
const subvalue = value.slice(start, match ? match.index : value.length);
|
|
58
|
+
if (subvalue) {
|
|
59
|
+
if (!previous) tagName = subvalue;
|
|
60
|
+
else if (previous === "#") props.id = subvalue;
|
|
61
|
+
else if (Array.isArray(props.className)) props.className.push(subvalue);
|
|
62
|
+
else props.className = [subvalue];
|
|
63
|
+
start += subvalue.length;
|
|
64
|
+
}
|
|
65
|
+
if (match) {
|
|
66
|
+
previous = match[0];
|
|
67
|
+
start++;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return {
|
|
71
|
+
type: "element",
|
|
72
|
+
tagName: tagName || defaultTagName || "div",
|
|
73
|
+
properties: props,
|
|
74
|
+
children: []
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
//#endregion
|
|
78
|
+
//#region node_modules/.pnpm/hastscript@9.0.1/node_modules/hastscript/lib/create-h.js
|
|
79
|
+
/**
|
|
80
|
+
* @import {Element, Nodes, RootContent, Root} from 'hast'
|
|
81
|
+
* @import {Info, Schema} from 'property-information'
|
|
82
|
+
*/
|
|
83
|
+
/**
|
|
84
|
+
* @typedef {Array<Nodes | PrimitiveChild>} ArrayChildNested
|
|
85
|
+
* List of children (deep).
|
|
86
|
+
*/
|
|
87
|
+
/**
|
|
88
|
+
* @typedef {Array<ArrayChildNested | Nodes | PrimitiveChild>} ArrayChild
|
|
89
|
+
* List of children.
|
|
90
|
+
*/
|
|
91
|
+
/**
|
|
92
|
+
* @typedef {Array<number | string>} ArrayValue
|
|
93
|
+
* List of property values for space- or comma separated values (such as `className`).
|
|
94
|
+
*/
|
|
95
|
+
/**
|
|
96
|
+
* @typedef {ArrayChild | Nodes | PrimitiveChild} Child
|
|
97
|
+
* Acceptable child value.
|
|
98
|
+
*/
|
|
99
|
+
/**
|
|
100
|
+
* @typedef {number | string | null | undefined} PrimitiveChild
|
|
101
|
+
* Primitive children, either ignored (nullish), or turned into text nodes.
|
|
102
|
+
*/
|
|
103
|
+
/**
|
|
104
|
+
* @typedef {boolean | number | string | null | undefined} PrimitiveValue
|
|
105
|
+
* Primitive property value.
|
|
106
|
+
*/
|
|
107
|
+
/**
|
|
108
|
+
* @typedef {Record<string, PropertyValue | Style>} Properties
|
|
109
|
+
* Acceptable value for element properties.
|
|
110
|
+
*/
|
|
111
|
+
/**
|
|
112
|
+
* @typedef {ArrayValue | PrimitiveValue} PropertyValue
|
|
113
|
+
* Primitive value or list value.
|
|
114
|
+
*/
|
|
115
|
+
/**
|
|
116
|
+
* @typedef {Element | Root} Result
|
|
117
|
+
* Result from a `h` (or `s`) call.
|
|
118
|
+
*/
|
|
119
|
+
/**
|
|
120
|
+
* @typedef {number | string} StyleValue
|
|
121
|
+
* Value for a CSS style field.
|
|
122
|
+
*/
|
|
123
|
+
/**
|
|
124
|
+
* @typedef {Record<string, StyleValue>} Style
|
|
125
|
+
* Supported value of a `style` prop.
|
|
126
|
+
*/
|
|
127
|
+
/**
|
|
128
|
+
* @param {Schema} schema
|
|
129
|
+
* Schema to use.
|
|
130
|
+
* @param {string} defaultTagName
|
|
131
|
+
* Default tag name.
|
|
132
|
+
* @param {ReadonlyArray<string> | undefined} [caseSensitive]
|
|
133
|
+
* Case-sensitive tag names (default: `undefined`).
|
|
134
|
+
* @returns
|
|
135
|
+
* `h`.
|
|
136
|
+
*/
|
|
137
|
+
function createH(schema, defaultTagName, caseSensitive) {
|
|
138
|
+
const adjust = caseSensitive ? createAdjustMap(caseSensitive) : void 0;
|
|
139
|
+
/**
|
|
140
|
+
* Hyperscript compatible DSL for creating virtual hast trees.
|
|
141
|
+
*
|
|
142
|
+
* @overload
|
|
143
|
+
* @param {null | undefined} [selector]
|
|
144
|
+
* @param {...Child} children
|
|
145
|
+
* @returns {Root}
|
|
146
|
+
*
|
|
147
|
+
* @overload
|
|
148
|
+
* @param {string} selector
|
|
149
|
+
* @param {Properties} properties
|
|
150
|
+
* @param {...Child} children
|
|
151
|
+
* @returns {Element}
|
|
152
|
+
*
|
|
153
|
+
* @overload
|
|
154
|
+
* @param {string} selector
|
|
155
|
+
* @param {...Child} children
|
|
156
|
+
* @returns {Element}
|
|
157
|
+
*
|
|
158
|
+
* @param {string | null | undefined} [selector]
|
|
159
|
+
* Selector.
|
|
160
|
+
* @param {Child | Properties | null | undefined} [properties]
|
|
161
|
+
* Properties (or first child) (default: `undefined`).
|
|
162
|
+
* @param {...Child} children
|
|
163
|
+
* Children.
|
|
164
|
+
* @returns {Result}
|
|
165
|
+
* Result.
|
|
166
|
+
*/
|
|
167
|
+
function h(selector, properties, ...children) {
|
|
168
|
+
/** @type {Result} */
|
|
169
|
+
let node;
|
|
170
|
+
if (selector === null || selector === void 0) {
|
|
171
|
+
node = {
|
|
172
|
+
type: "root",
|
|
173
|
+
children: []
|
|
174
|
+
};
|
|
175
|
+
const child = properties;
|
|
176
|
+
children.unshift(child);
|
|
177
|
+
} else {
|
|
178
|
+
node = parseSelector(selector, defaultTagName);
|
|
179
|
+
const lower = node.tagName.toLowerCase();
|
|
180
|
+
const adjusted = adjust ? adjust.get(lower) : void 0;
|
|
181
|
+
node.tagName = adjusted || lower;
|
|
182
|
+
if (isChild(properties)) children.unshift(properties);
|
|
183
|
+
else for (const [key, value] of Object.entries(properties)) addProperty(schema, node.properties, key, value);
|
|
184
|
+
}
|
|
185
|
+
for (const child of children) addChild(node.children, child);
|
|
186
|
+
if (node.type === "element" && node.tagName === "template") {
|
|
187
|
+
node.content = {
|
|
188
|
+
type: "root",
|
|
189
|
+
children: node.children
|
|
190
|
+
};
|
|
191
|
+
node.children = [];
|
|
192
|
+
}
|
|
193
|
+
return node;
|
|
194
|
+
}
|
|
195
|
+
return h;
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* Check if something is properties or a child.
|
|
199
|
+
*
|
|
200
|
+
* @param {Child | Properties} value
|
|
201
|
+
* Value to check.
|
|
202
|
+
* @returns {value is Child}
|
|
203
|
+
* Whether `value` is definitely a child.
|
|
204
|
+
*/
|
|
205
|
+
function isChild(value) {
|
|
206
|
+
if (value === null || typeof value !== "object" || Array.isArray(value)) return true;
|
|
207
|
+
if (typeof value.type !== "string") return false;
|
|
208
|
+
const record = value;
|
|
209
|
+
const keys = Object.keys(value);
|
|
210
|
+
for (const key of keys) {
|
|
211
|
+
const value = record[key];
|
|
212
|
+
if (value && typeof value === "object") {
|
|
213
|
+
if (!Array.isArray(value)) return true;
|
|
214
|
+
const list = value;
|
|
215
|
+
for (const item of list) if (typeof item !== "number" && typeof item !== "string") return true;
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
if ("children" in value && Array.isArray(value.children)) return true;
|
|
219
|
+
return false;
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* @param {Schema} schema
|
|
223
|
+
* Schema.
|
|
224
|
+
* @param {Properties} properties
|
|
225
|
+
* Properties object.
|
|
226
|
+
* @param {string} key
|
|
227
|
+
* Property name.
|
|
228
|
+
* @param {PropertyValue | Style} value
|
|
229
|
+
* Property value.
|
|
230
|
+
* @returns {undefined}
|
|
231
|
+
* Nothing.
|
|
232
|
+
*/
|
|
233
|
+
function addProperty(schema, properties, key, value) {
|
|
234
|
+
const info = find(schema, key);
|
|
235
|
+
/** @type {PropertyValue} */
|
|
236
|
+
let result;
|
|
237
|
+
if (value === null || value === void 0) return;
|
|
238
|
+
if (typeof value === "number") {
|
|
239
|
+
if (Number.isNaN(value)) return;
|
|
240
|
+
result = value;
|
|
241
|
+
} else if (typeof value === "boolean") result = value;
|
|
242
|
+
else if (typeof value === "string") if (info.spaceSeparated) result = parse(value);
|
|
243
|
+
else if (info.commaSeparated) result = parse$1(value);
|
|
244
|
+
else if (info.commaOrSpaceSeparated) result = parse(parse$1(value).join(" "));
|
|
245
|
+
else result = parsePrimitive(info, info.property, value);
|
|
246
|
+
else if (Array.isArray(value)) result = [...value];
|
|
247
|
+
else result = info.property === "style" ? style(value) : String(value);
|
|
248
|
+
if (Array.isArray(result)) {
|
|
249
|
+
/** @type {Array<number | string>} */
|
|
250
|
+
const finalResult = [];
|
|
251
|
+
for (const item of result) finalResult.push(parsePrimitive(info, info.property, item));
|
|
252
|
+
result = finalResult;
|
|
253
|
+
}
|
|
254
|
+
if (info.property === "className" && Array.isArray(properties.className)) result = properties.className.concat(result);
|
|
255
|
+
properties[info.property] = result;
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* @param {Array<RootContent>} nodes
|
|
259
|
+
* Children.
|
|
260
|
+
* @param {Child} value
|
|
261
|
+
* Child.
|
|
262
|
+
* @returns {undefined}
|
|
263
|
+
* Nothing.
|
|
264
|
+
*/
|
|
265
|
+
function addChild(nodes, value) {
|
|
266
|
+
if (value === null || value === void 0) {} else if (typeof value === "number" || typeof value === "string") nodes.push({
|
|
267
|
+
type: "text",
|
|
268
|
+
value: String(value)
|
|
269
|
+
});
|
|
270
|
+
else if (Array.isArray(value)) for (const child of value) addChild(nodes, child);
|
|
271
|
+
else if (typeof value === "object" && "type" in value) if (value.type === "root") addChild(nodes, value.children);
|
|
272
|
+
else nodes.push(value);
|
|
273
|
+
else throw new Error("Expected node, nodes, or string, got `" + value + "`");
|
|
274
|
+
}
|
|
275
|
+
/**
|
|
276
|
+
* Parse a single primitives.
|
|
277
|
+
*
|
|
278
|
+
* @param {Info} info
|
|
279
|
+
* Property information.
|
|
280
|
+
* @param {string} name
|
|
281
|
+
* Property name.
|
|
282
|
+
* @param {PrimitiveValue} value
|
|
283
|
+
* Property value.
|
|
284
|
+
* @returns {PrimitiveValue}
|
|
285
|
+
* Property value.
|
|
286
|
+
*/
|
|
287
|
+
function parsePrimitive(info, name, value) {
|
|
288
|
+
if (typeof value === "string") {
|
|
289
|
+
if (info.number && value && !Number.isNaN(Number(value))) return Number(value);
|
|
290
|
+
if ((info.boolean || info.overloadedBoolean) && (value === "" || normalize(value) === normalize(name))) return true;
|
|
291
|
+
}
|
|
292
|
+
return value;
|
|
293
|
+
}
|
|
294
|
+
/**
|
|
295
|
+
* Serialize a `style` object as a string.
|
|
296
|
+
*
|
|
297
|
+
* @param {Style} styles
|
|
298
|
+
* Style object.
|
|
299
|
+
* @returns {string}
|
|
300
|
+
* CSS string.
|
|
301
|
+
*/
|
|
302
|
+
function style(styles) {
|
|
303
|
+
/** @type {Array<string>} */
|
|
304
|
+
const result = [];
|
|
305
|
+
for (const [key, value] of Object.entries(styles)) result.push([key, value].join(": "));
|
|
306
|
+
return result.join("; ");
|
|
307
|
+
}
|
|
308
|
+
/**
|
|
309
|
+
* Create a map to adjust casing.
|
|
310
|
+
*
|
|
311
|
+
* @param {ReadonlyArray<string>} values
|
|
312
|
+
* List of properly cased keys.
|
|
313
|
+
* @returns {Map<string, string>}
|
|
314
|
+
* Map of lowercase keys to uppercase keys.
|
|
315
|
+
*/
|
|
316
|
+
function createAdjustMap(values) {
|
|
317
|
+
/** @type {Map<string, string>} */
|
|
318
|
+
const result = /* @__PURE__ */ new Map();
|
|
319
|
+
for (const value of values) result.set(value.toLowerCase(), value);
|
|
320
|
+
return result;
|
|
321
|
+
}
|
|
322
|
+
//#endregion
|
|
323
|
+
//#region node_modules/.pnpm/hastscript@9.0.1/node_modules/hastscript/lib/svg-case-sensitive-tag-names.js
|
|
324
|
+
/**
|
|
325
|
+
* List of case-sensitive SVG tag names.
|
|
326
|
+
*
|
|
327
|
+
* @type {ReadonlyArray<string>}
|
|
328
|
+
*/
|
|
329
|
+
var svgCaseSensitiveTagNames = [
|
|
330
|
+
"altGlyph",
|
|
331
|
+
"altGlyphDef",
|
|
332
|
+
"altGlyphItem",
|
|
333
|
+
"animateColor",
|
|
334
|
+
"animateMotion",
|
|
335
|
+
"animateTransform",
|
|
336
|
+
"clipPath",
|
|
337
|
+
"feBlend",
|
|
338
|
+
"feColorMatrix",
|
|
339
|
+
"feComponentTransfer",
|
|
340
|
+
"feComposite",
|
|
341
|
+
"feConvolveMatrix",
|
|
342
|
+
"feDiffuseLighting",
|
|
343
|
+
"feDisplacementMap",
|
|
344
|
+
"feDistantLight",
|
|
345
|
+
"feDropShadow",
|
|
346
|
+
"feFlood",
|
|
347
|
+
"feFuncA",
|
|
348
|
+
"feFuncB",
|
|
349
|
+
"feFuncG",
|
|
350
|
+
"feFuncR",
|
|
351
|
+
"feGaussianBlur",
|
|
352
|
+
"feImage",
|
|
353
|
+
"feMerge",
|
|
354
|
+
"feMergeNode",
|
|
355
|
+
"feMorphology",
|
|
356
|
+
"feOffset",
|
|
357
|
+
"fePointLight",
|
|
358
|
+
"feSpecularLighting",
|
|
359
|
+
"feSpotLight",
|
|
360
|
+
"feTile",
|
|
361
|
+
"feTurbulence",
|
|
362
|
+
"foreignObject",
|
|
363
|
+
"glyphRef",
|
|
364
|
+
"linearGradient",
|
|
365
|
+
"radialGradient",
|
|
366
|
+
"solidColor",
|
|
367
|
+
"textArea",
|
|
368
|
+
"textPath"
|
|
369
|
+
];
|
|
370
|
+
//#endregion
|
|
371
|
+
//#region node_modules/.pnpm/hastscript@9.0.1/node_modules/hastscript/lib/index.js
|
|
372
|
+
/**
|
|
373
|
+
* @typedef {import('./jsx-classic.js').Element} h.JSX.Element
|
|
374
|
+
* @typedef {import('./jsx-classic.js').ElementChildrenAttribute} h.JSX.ElementChildrenAttribute
|
|
375
|
+
* @typedef {import('./jsx-classic.js').IntrinsicAttributes} h.JSX.IntrinsicAttributes
|
|
376
|
+
* @typedef {import('./jsx-classic.js').IntrinsicElements} h.JSX.IntrinsicElements
|
|
377
|
+
*/
|
|
378
|
+
/**
|
|
379
|
+
* @typedef {import('./jsx-classic.js').Element} s.JSX.Element
|
|
380
|
+
* @typedef {import('./jsx-classic.js').ElementChildrenAttribute} s.JSX.ElementChildrenAttribute
|
|
381
|
+
* @typedef {import('./jsx-classic.js').IntrinsicAttributes} s.JSX.IntrinsicAttributes
|
|
382
|
+
* @typedef {import('./jsx-classic.js').IntrinsicElements} s.JSX.IntrinsicElements
|
|
383
|
+
*/
|
|
384
|
+
/** @type {ReturnType<createH>} */
|
|
385
|
+
var h = createH(html, "div");
|
|
386
|
+
/** @type {ReturnType<createH>} */
|
|
387
|
+
var s = createH(svg, "g", svgCaseSensitiveTagNames);
|
|
388
|
+
//#endregion
|
|
389
|
+
//#region node_modules/.pnpm/vfile-location@5.0.3/node_modules/vfile-location/lib/index.js
|
|
390
|
+
/**
|
|
391
|
+
* @import {VFile, Value} from 'vfile'
|
|
392
|
+
* @import {Location} from 'vfile-location'
|
|
393
|
+
*/
|
|
394
|
+
/**
|
|
395
|
+
* Create an index of the given document to translate between line/column and
|
|
396
|
+
* offset based positional info.
|
|
397
|
+
*
|
|
398
|
+
* Also implemented in Rust in [`wooorm/markdown-rs`][markdown-rs].
|
|
399
|
+
*
|
|
400
|
+
* [markdown-rs]: https://github.com/wooorm/markdown-rs/blob/main/src/util/location.rs
|
|
401
|
+
*
|
|
402
|
+
* @param {VFile | Value} file
|
|
403
|
+
* File to index.
|
|
404
|
+
* @returns {Location}
|
|
405
|
+
* Accessors for index.
|
|
406
|
+
*/
|
|
407
|
+
function location(file) {
|
|
408
|
+
const value = String(file);
|
|
409
|
+
/**
|
|
410
|
+
* List, where each index is a line number (0-based), and each value is the
|
|
411
|
+
* byte index *after* where the line ends.
|
|
412
|
+
*
|
|
413
|
+
* @type {Array<number>}
|
|
414
|
+
*/
|
|
415
|
+
const indices = [];
|
|
416
|
+
return {
|
|
417
|
+
toOffset,
|
|
418
|
+
toPoint
|
|
419
|
+
};
|
|
420
|
+
/** @type {Location['toPoint']} */
|
|
421
|
+
function toPoint(offset) {
|
|
422
|
+
if (typeof offset === "number" && offset > -1 && offset <= value.length) {
|
|
423
|
+
let index = 0;
|
|
424
|
+
while (true) {
|
|
425
|
+
let end = indices[index];
|
|
426
|
+
if (end === void 0) {
|
|
427
|
+
const eol = next(value, indices[index - 1]);
|
|
428
|
+
end = eol === -1 ? value.length + 1 : eol + 1;
|
|
429
|
+
indices[index] = end;
|
|
430
|
+
}
|
|
431
|
+
if (end > offset) return {
|
|
432
|
+
line: index + 1,
|
|
433
|
+
column: offset - (index > 0 ? indices[index - 1] : 0) + 1,
|
|
434
|
+
offset
|
|
435
|
+
};
|
|
436
|
+
index++;
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
/** @type {Location['toOffset']} */
|
|
441
|
+
function toOffset(point) {
|
|
442
|
+
if (point && typeof point.line === "number" && typeof point.column === "number" && !Number.isNaN(point.line) && !Number.isNaN(point.column)) {
|
|
443
|
+
while (indices.length < point.line) {
|
|
444
|
+
const from = indices[indices.length - 1];
|
|
445
|
+
const eol = next(value, from);
|
|
446
|
+
const end = eol === -1 ? value.length + 1 : eol + 1;
|
|
447
|
+
if (from === end) break;
|
|
448
|
+
indices.push(end);
|
|
449
|
+
}
|
|
450
|
+
const offset = (point.line > 1 ? indices[point.line - 2] : 0) + point.column - 1;
|
|
451
|
+
if (offset < indices[point.line - 1]) return offset;
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
/**
|
|
456
|
+
* @param {string} value
|
|
457
|
+
* @param {number} from
|
|
458
|
+
*/
|
|
459
|
+
function next(value, from) {
|
|
460
|
+
const cr = value.indexOf("\r", from);
|
|
461
|
+
const lf = value.indexOf("\n", from);
|
|
462
|
+
if (lf === -1) return cr;
|
|
463
|
+
if (cr === -1 || cr + 1 === lf) return lf;
|
|
464
|
+
return cr < lf ? cr : lf;
|
|
465
|
+
}
|
|
466
|
+
//#endregion
|
|
467
|
+
//#region node_modules/.pnpm/web-namespaces@2.0.1/node_modules/web-namespaces/index.js
|
|
468
|
+
/**
|
|
469
|
+
* Map of web namespaces.
|
|
470
|
+
*
|
|
471
|
+
* @type {Record<string, string>}
|
|
472
|
+
*/
|
|
473
|
+
var webNamespaces = {
|
|
474
|
+
html: "http://www.w3.org/1999/xhtml",
|
|
475
|
+
mathml: "http://www.w3.org/1998/Math/MathML",
|
|
476
|
+
svg: "http://www.w3.org/2000/svg",
|
|
477
|
+
xlink: "http://www.w3.org/1999/xlink",
|
|
478
|
+
xml: "http://www.w3.org/XML/1998/namespace",
|
|
479
|
+
xmlns: "http://www.w3.org/2000/xmlns/"
|
|
480
|
+
};
|
|
481
|
+
//#endregion
|
|
482
|
+
//#region node_modules/.pnpm/hast-util-from-parse5@8.0.3/node_modules/hast-util-from-parse5/lib/index.js
|
|
483
|
+
/**
|
|
484
|
+
* @import {ElementData, Element, Nodes, RootContent, Root} from 'hast'
|
|
485
|
+
* @import {DefaultTreeAdapterMap, Token} from 'parse5'
|
|
486
|
+
* @import {Schema} from 'property-information'
|
|
487
|
+
* @import {Point, Position} from 'unist'
|
|
488
|
+
* @import {VFile} from 'vfile'
|
|
489
|
+
* @import {Options} from 'hast-util-from-parse5'
|
|
490
|
+
*/
|
|
491
|
+
/**
|
|
492
|
+
* @typedef State
|
|
493
|
+
* Info passed around about the current state.
|
|
494
|
+
* @property {VFile | undefined} file
|
|
495
|
+
* Corresponding file.
|
|
496
|
+
* @property {boolean} location
|
|
497
|
+
* Whether location info was found.
|
|
498
|
+
* @property {Schema} schema
|
|
499
|
+
* Current schema.
|
|
500
|
+
* @property {boolean | undefined} verbose
|
|
501
|
+
* Add extra positional info.
|
|
502
|
+
*/
|
|
503
|
+
var own = {}.hasOwnProperty;
|
|
504
|
+
/** @type {unknown} */
|
|
505
|
+
var proto = Object.prototype;
|
|
506
|
+
/**
|
|
507
|
+
* Transform a `parse5` AST to hast.
|
|
508
|
+
*
|
|
509
|
+
* @param {DefaultTreeAdapterMap['node']} tree
|
|
510
|
+
* `parse5` tree to transform.
|
|
511
|
+
* @param {Options | null | undefined} [options]
|
|
512
|
+
* Configuration (optional).
|
|
513
|
+
* @returns {Nodes}
|
|
514
|
+
* hast tree.
|
|
515
|
+
*/
|
|
516
|
+
function fromParse5(tree, options) {
|
|
517
|
+
const settings = options || {};
|
|
518
|
+
return one({
|
|
519
|
+
file: settings.file || void 0,
|
|
520
|
+
location: false,
|
|
521
|
+
schema: settings.space === "svg" ? svg : html,
|
|
522
|
+
verbose: settings.verbose || false
|
|
523
|
+
}, tree);
|
|
524
|
+
}
|
|
525
|
+
/**
|
|
526
|
+
* Transform a node.
|
|
527
|
+
*
|
|
528
|
+
* @param {State} state
|
|
529
|
+
* Info passed around about the current state.
|
|
530
|
+
* @param {DefaultTreeAdapterMap['node']} node
|
|
531
|
+
* p5 node.
|
|
532
|
+
* @returns {Nodes}
|
|
533
|
+
* hast node.
|
|
534
|
+
*/
|
|
535
|
+
function one(state, node) {
|
|
536
|
+
/** @type {Nodes} */
|
|
537
|
+
let result;
|
|
538
|
+
switch (node.nodeName) {
|
|
539
|
+
case "#comment": {
|
|
540
|
+
const reference = node;
|
|
541
|
+
result = {
|
|
542
|
+
type: "comment",
|
|
543
|
+
value: reference.data
|
|
544
|
+
};
|
|
545
|
+
patch(state, reference, result);
|
|
546
|
+
return result;
|
|
547
|
+
}
|
|
548
|
+
case "#document":
|
|
549
|
+
case "#document-fragment": {
|
|
550
|
+
const reference = node;
|
|
551
|
+
const quirksMode = "mode" in reference ? reference.mode === "quirks" || reference.mode === "limited-quirks" : false;
|
|
552
|
+
result = {
|
|
553
|
+
type: "root",
|
|
554
|
+
children: all(state, node.childNodes),
|
|
555
|
+
data: { quirksMode }
|
|
556
|
+
};
|
|
557
|
+
if (state.file && state.location) {
|
|
558
|
+
const document = String(state.file);
|
|
559
|
+
const loc = location(document);
|
|
560
|
+
const start = loc.toPoint(0);
|
|
561
|
+
const end = loc.toPoint(document.length);
|
|
562
|
+
result.position = {
|
|
563
|
+
start,
|
|
564
|
+
end
|
|
565
|
+
};
|
|
566
|
+
}
|
|
567
|
+
return result;
|
|
568
|
+
}
|
|
569
|
+
case "#documentType": {
|
|
570
|
+
const reference = node;
|
|
571
|
+
result = { type: "doctype" };
|
|
572
|
+
patch(state, reference, result);
|
|
573
|
+
return result;
|
|
574
|
+
}
|
|
575
|
+
case "#text": {
|
|
576
|
+
const reference = node;
|
|
577
|
+
result = {
|
|
578
|
+
type: "text",
|
|
579
|
+
value: reference.value
|
|
580
|
+
};
|
|
581
|
+
patch(state, reference, result);
|
|
582
|
+
return result;
|
|
583
|
+
}
|
|
584
|
+
default:
|
|
585
|
+
result = element(state, node);
|
|
586
|
+
return result;
|
|
587
|
+
}
|
|
588
|
+
}
|
|
589
|
+
/**
|
|
590
|
+
* Transform children.
|
|
591
|
+
*
|
|
592
|
+
* @param {State} state
|
|
593
|
+
* Info passed around about the current state.
|
|
594
|
+
* @param {Array<DefaultTreeAdapterMap['node']>} nodes
|
|
595
|
+
* Nodes.
|
|
596
|
+
* @returns {Array<RootContent>}
|
|
597
|
+
* hast nodes.
|
|
598
|
+
*/
|
|
599
|
+
function all(state, nodes) {
|
|
600
|
+
let index = -1;
|
|
601
|
+
/** @type {Array<RootContent>} */
|
|
602
|
+
const results = [];
|
|
603
|
+
while (++index < nodes.length) {
|
|
604
|
+
const result = one(state, nodes[index]);
|
|
605
|
+
results.push(result);
|
|
606
|
+
}
|
|
607
|
+
return results;
|
|
608
|
+
}
|
|
609
|
+
/**
|
|
610
|
+
* Transform an element.
|
|
611
|
+
*
|
|
612
|
+
* @param {State} state
|
|
613
|
+
* Info passed around about the current state.
|
|
614
|
+
* @param {DefaultTreeAdapterMap['element']} node
|
|
615
|
+
* `parse5` node to transform.
|
|
616
|
+
* @returns {Element}
|
|
617
|
+
* hast node.
|
|
618
|
+
*/
|
|
619
|
+
function element(state, node) {
|
|
620
|
+
const schema = state.schema;
|
|
621
|
+
state.schema = node.namespaceURI === webNamespaces.svg ? svg : html;
|
|
622
|
+
let index = -1;
|
|
623
|
+
/** @type {Record<string, string>} */
|
|
624
|
+
const properties = {};
|
|
625
|
+
while (++index < node.attrs.length) {
|
|
626
|
+
const attribute = node.attrs[index];
|
|
627
|
+
const name = (attribute.prefix ? attribute.prefix + ":" : "") + attribute.name;
|
|
628
|
+
if (!own.call(proto, name)) properties[name] = attribute.value;
|
|
629
|
+
}
|
|
630
|
+
const result = (state.schema.space === "svg" ? s : h)(node.tagName, properties, all(state, node.childNodes));
|
|
631
|
+
patch(state, node, result);
|
|
632
|
+
if (result.tagName === "template") {
|
|
633
|
+
const reference = node;
|
|
634
|
+
const pos = reference.sourceCodeLocation;
|
|
635
|
+
const startTag = pos && pos.startTag && position(pos.startTag);
|
|
636
|
+
const endTag = pos && pos.endTag && position(pos.endTag);
|
|
637
|
+
const content = one(state, reference.content);
|
|
638
|
+
if (startTag && endTag && state.file) content.position = {
|
|
639
|
+
start: startTag.end,
|
|
640
|
+
end: endTag.start
|
|
641
|
+
};
|
|
642
|
+
result.content = content;
|
|
643
|
+
}
|
|
644
|
+
state.schema = schema;
|
|
645
|
+
return result;
|
|
646
|
+
}
|
|
647
|
+
/**
|
|
648
|
+
* Patch positional info from `from` onto `to`.
|
|
649
|
+
*
|
|
650
|
+
* @param {State} state
|
|
651
|
+
* Info passed around about the current state.
|
|
652
|
+
* @param {DefaultTreeAdapterMap['node']} from
|
|
653
|
+
* p5 node.
|
|
654
|
+
* @param {Nodes} to
|
|
655
|
+
* hast node.
|
|
656
|
+
* @returns {undefined}
|
|
657
|
+
* Nothing.
|
|
658
|
+
*/
|
|
659
|
+
function patch(state, from, to) {
|
|
660
|
+
if ("sourceCodeLocation" in from && from.sourceCodeLocation && state.file) {
|
|
661
|
+
const position = createLocation(state, to, from.sourceCodeLocation);
|
|
662
|
+
if (position) {
|
|
663
|
+
state.location = true;
|
|
664
|
+
to.position = position;
|
|
665
|
+
}
|
|
666
|
+
}
|
|
667
|
+
}
|
|
668
|
+
/**
|
|
669
|
+
* Create clean positional information.
|
|
670
|
+
*
|
|
671
|
+
* @param {State} state
|
|
672
|
+
* Info passed around about the current state.
|
|
673
|
+
* @param {Nodes} node
|
|
674
|
+
* hast node.
|
|
675
|
+
* @param {Token.ElementLocation} location
|
|
676
|
+
* p5 location info.
|
|
677
|
+
* @returns {Position | undefined}
|
|
678
|
+
* Position, or nothing.
|
|
679
|
+
*/
|
|
680
|
+
function createLocation(state, node, location) {
|
|
681
|
+
const result = position(location);
|
|
682
|
+
if (node.type === "element") {
|
|
683
|
+
const tail = node.children[node.children.length - 1];
|
|
684
|
+
if (result && !location.endTag && tail && tail.position && tail.position.end) result.end = Object.assign({}, tail.position.end);
|
|
685
|
+
if (state.verbose) {
|
|
686
|
+
/** @type {Record<string, Position | undefined>} */
|
|
687
|
+
const properties = {};
|
|
688
|
+
/** @type {string} */
|
|
689
|
+
let key;
|
|
690
|
+
if (location.attrs) {
|
|
691
|
+
for (key in location.attrs) if (own.call(location.attrs, key)) properties[find(state.schema, key).property] = position(location.attrs[key]);
|
|
692
|
+
}
|
|
693
|
+
location.startTag;
|
|
694
|
+
const opening = position(location.startTag);
|
|
695
|
+
const closing = location.endTag ? position(location.endTag) : void 0;
|
|
696
|
+
/** @type {ElementData['position']} */
|
|
697
|
+
const data = { opening };
|
|
698
|
+
if (closing) data.closing = closing;
|
|
699
|
+
data.properties = properties;
|
|
700
|
+
node.data = { position: data };
|
|
701
|
+
}
|
|
702
|
+
}
|
|
703
|
+
return result;
|
|
704
|
+
}
|
|
705
|
+
/**
|
|
706
|
+
* Turn a p5 location into a position.
|
|
707
|
+
*
|
|
708
|
+
* @param {Token.Location} loc
|
|
709
|
+
* Location.
|
|
710
|
+
* @returns {Position | undefined}
|
|
711
|
+
* Position or nothing.
|
|
712
|
+
*/
|
|
713
|
+
function position(loc) {
|
|
714
|
+
const start = point({
|
|
715
|
+
line: loc.startLine,
|
|
716
|
+
column: loc.startCol,
|
|
717
|
+
offset: loc.startOffset
|
|
718
|
+
});
|
|
719
|
+
const end = point({
|
|
720
|
+
line: loc.endLine,
|
|
721
|
+
column: loc.endCol,
|
|
722
|
+
offset: loc.endOffset
|
|
723
|
+
});
|
|
724
|
+
return start || end ? {
|
|
725
|
+
start,
|
|
726
|
+
end
|
|
727
|
+
} : void 0;
|
|
728
|
+
}
|
|
729
|
+
/**
|
|
730
|
+
* Filter out invalid points.
|
|
731
|
+
*
|
|
732
|
+
* @param {Point} point
|
|
733
|
+
* Point with potentially `undefined` values.
|
|
734
|
+
* @returns {Point | undefined}
|
|
735
|
+
* Point or nothing.
|
|
736
|
+
*/
|
|
737
|
+
function point(point) {
|
|
738
|
+
return point.line && point.column ? point : void 0;
|
|
739
|
+
}
|
|
740
|
+
//#endregion
|
|
741
|
+
export { webNamespaces as n, fromParse5 as t };
|