@analogjs/content 3.0.0-alpha.1 → 3.0.0-alpha.11

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 (103) hide show
  1. package/LICENSE +21 -0
  2. package/fesm2022/__vite-browser-external.mjs +9 -0
  3. package/fesm2022/analogjs-content-md4x.mjs +290 -0
  4. package/fesm2022/analogjs-content-mdc.mjs +170 -0
  5. package/fesm2022/analogjs-content-og.mjs +34 -46
  6. package/fesm2022/analogjs-content-prism-highlighter.mjs +81 -68
  7. package/fesm2022/analogjs-content-resources.mjs +115 -124
  8. package/fesm2022/analogjs-content-shiki-highlighter.mjs +9 -14
  9. package/fesm2022/analogjs-content.mjs +18538 -621
  10. package/fesm2022/api_vite.mjs +7 -0
  11. package/fesm2022/browser.mjs +6069 -0
  12. package/fesm2022/build2.mjs +5259 -0
  13. package/fesm2022/chunk.mjs +37 -0
  14. package/fesm2022/chunk2.mjs +41 -0
  15. package/fesm2022/jiti.mjs +4477 -0
  16. package/fesm2022/lib.mjs +365 -0
  17. package/fesm2022/main.mjs +2341 -0
  18. package/fesm2022/node.mjs +791 -0
  19. package/fesm2022/postcss-import.mjs +451 -0
  20. package/fesm2022/postcss.mjs +3236 -0
  21. package/fesm2022/prompt-BYQIwEjg.mjs +847 -0
  22. package/md4x/package.json +4 -0
  23. package/mdc/package.json +4 -0
  24. package/og/package.json +2 -2
  25. package/package.json +35 -9
  26. package/prism-highlighter/package.json +2 -2
  27. package/resources/package.json +2 -2
  28. package/shiki-highlighter/package.json +2 -2
  29. package/src/lib/devtools/content-devtools-client.ts +215 -0
  30. package/src/lib/devtools/content-devtools.styles.css +194 -0
  31. package/types/md4x/src/index.d.ts +5 -0
  32. package/types/md4x/src/lib/md4x-content-renderer.service.d.ts +33 -0
  33. package/types/md4x/src/lib/md4x-wasm-content-renderer.service.d.ts +16 -0
  34. package/types/md4x/src/lib/provide-md4x.d.ts +26 -0
  35. package/types/md4x/src/lib/streaming-markdown-renderer.d.ts +21 -0
  36. package/types/mdc/src/index.d.ts +2 -0
  37. package/types/mdc/src/lib/mdc-component-registry.d.ts +25 -0
  38. package/types/mdc/src/lib/mdc-renderer.directive.d.ts +33 -0
  39. package/types/og/src/index.d.ts +2 -0
  40. package/types/og/src/lib/og.d.ts +5 -0
  41. package/types/og/src/lib/options.d.ts +11 -0
  42. package/types/prism-highlighter/src/index.d.ts +8 -0
  43. package/types/prism-highlighter/src/lib/prism/angular.d.ts +1 -0
  44. package/types/prism-highlighter/src/lib/prism-highlighter.d.ts +8 -0
  45. package/types/resources/src/content-file-resource.d.ts +37 -0
  46. package/types/resources/src/content-files-resource.d.ts +3 -0
  47. package/types/resources/src/index.d.ts +2 -0
  48. package/types/shiki-highlighter/src/index.d.ts +7 -0
  49. package/types/src/index.d.ts +18 -0
  50. package/types/src/lib/anchor-navigation.directive.d.ts +9 -0
  51. package/types/src/lib/content-file-loader.d.ts +6 -0
  52. package/types/src/lib/content-file.d.ts +8 -0
  53. package/types/src/lib/content-files-list-token.d.ts +3 -0
  54. package/types/src/lib/content-files-token.d.ts +3 -0
  55. package/types/src/lib/content-list-loader.d.ts +7 -0
  56. package/types/src/lib/content-renderer.d.ts +33 -0
  57. package/types/src/lib/content.d.ts +14 -0
  58. package/types/src/lib/devtools/content-devtools-plugin.d.ts +23 -0
  59. package/types/src/lib/devtools/content-devtools-renderer.d.ts +23 -0
  60. package/types/src/lib/devtools/index.d.ts +23 -0
  61. package/types/src/lib/get-content-files.d.ts +14 -0
  62. package/types/src/lib/inject-content-files.d.ts +4 -0
  63. package/types/src/lib/markdown-content-renderer.service.d.ts +10 -0
  64. package/types/src/lib/markdown-route.component.d.ts +15 -0
  65. package/types/src/lib/markdown.component.d.ts +26 -0
  66. package/types/src/lib/marked-content-highlighter.d.ts +17 -0
  67. package/types/src/lib/marked-setup.service.d.ts +10 -0
  68. package/types/src/lib/parse-raw-content-file.d.ts +18 -0
  69. package/types/src/lib/provide-content.d.ts +7 -0
  70. package/types/src/lib/render-task.service.d.ts +8 -0
  71. package/types/src/lib/utils/zone-wait-for.d.ts +2 -0
  72. package/fesm2022/analogjs-content-og.mjs.map +0 -1
  73. package/fesm2022/analogjs-content-prism-highlighter.mjs.map +0 -1
  74. package/fesm2022/analogjs-content-resources.mjs.map +0 -1
  75. package/fesm2022/analogjs-content-shiki-highlighter.mjs.map +0 -1
  76. package/fesm2022/analogjs-content.mjs.map +0 -1
  77. package/og/README.md +0 -3
  78. package/plugin/README.md +0 -11
  79. package/plugin/migrations.json +0 -75
  80. package/plugin/package.json +0 -23
  81. package/plugin/src/index.d.ts +0 -2
  82. package/plugin/src/index.js +0 -4
  83. package/plugin/src/index.js.map +0 -1
  84. package/plugin/src/migrations/update-markdown-renderer-feature/compat.d.ts +0 -2
  85. package/plugin/src/migrations/update-markdown-renderer-feature/compat.js +0 -6
  86. package/plugin/src/migrations/update-markdown-renderer-feature/compat.js.map +0 -1
  87. package/plugin/src/migrations/update-markdown-renderer-feature/update-markdown-renderer-feature.d.ts +0 -2
  88. package/plugin/src/migrations/update-markdown-renderer-feature/update-markdown-renderer-feature.js +0 -48
  89. package/plugin/src/migrations/update-markdown-renderer-feature/update-markdown-renderer-feature.js.map +0 -1
  90. package/plugin/src/migrations/update-markdown-version/compat.d.ts +0 -2
  91. package/plugin/src/migrations/update-markdown-version/compat.js +0 -6
  92. package/plugin/src/migrations/update-markdown-version/compat.js.map +0 -1
  93. package/plugin/src/migrations/update-markdown-version/update-markdown-version.d.ts +0 -2
  94. package/plugin/src/migrations/update-markdown-version/update-markdown-version.js +0 -23
  95. package/plugin/src/migrations/update-markdown-version/update-markdown-version.js.map +0 -1
  96. package/prism-highlighter/README.md +0 -3
  97. package/resources/README.md +0 -3
  98. package/shiki-highlighter/README.md +0 -3
  99. package/types/analogjs-content-og.d.ts +0 -19
  100. package/types/analogjs-content-prism-highlighter.d.ts +0 -15
  101. package/types/analogjs-content-resources.d.ts +0 -20
  102. package/types/analogjs-content-shiki-highlighter.d.ts +0 -11
  103. package/types/analogjs-content.d.ts +0 -168
@@ -0,0 +1,791 @@
1
+ import { i as __toESM, r as __require, t as __commonJSMin } from "./chunk.mjs";
2
+ import { t as require___vite_browser_external } from "./__vite-browser-external.mjs";
3
+ //#region node_modules/.pnpm/detect-libc@2.1.2/node_modules/detect-libc/lib/process.js
4
+ var require_process = /* @__PURE__ */ __commonJSMin(((exports, module) => {
5
+ var isLinux = () => process.platform === "linux";
6
+ var report = null;
7
+ var getReport = () => {
8
+ if (!report)
9
+ /* istanbul ignore next */
10
+ if (isLinux() && process.report) {
11
+ const orig = process.report.excludeNetwork;
12
+ process.report.excludeNetwork = true;
13
+ report = process.report.getReport();
14
+ process.report.excludeNetwork = orig;
15
+ } else report = {};
16
+ return report;
17
+ };
18
+ module.exports = {
19
+ isLinux,
20
+ getReport
21
+ };
22
+ }));
23
+ //#endregion
24
+ //#region node_modules/.pnpm/detect-libc@2.1.2/node_modules/detect-libc/lib/filesystem.js
25
+ var require_filesystem = /* @__PURE__ */ __commonJSMin(((exports, module) => {
26
+ var fs = require___vite_browser_external();
27
+ var LDD_PATH = "/usr/bin/ldd";
28
+ var SELF_PATH = "/proc/self/exe";
29
+ var MAX_LENGTH = 2048;
30
+ /**
31
+ * Read the content of a file synchronous
32
+ *
33
+ * @param {string} path
34
+ * @returns {Buffer}
35
+ */
36
+ var readFileSync = (path) => {
37
+ const fd = fs.openSync(path, "r");
38
+ const buffer = Buffer.alloc(MAX_LENGTH);
39
+ const bytesRead = fs.readSync(fd, buffer, 0, MAX_LENGTH, 0);
40
+ fs.close(fd, () => {});
41
+ return buffer.subarray(0, bytesRead);
42
+ };
43
+ /**
44
+ * Read the content of a file
45
+ *
46
+ * @param {string} path
47
+ * @returns {Promise<Buffer>}
48
+ */
49
+ var readFile = (path) => new Promise((resolve, reject) => {
50
+ fs.open(path, "r", (err, fd) => {
51
+ if (err) reject(err);
52
+ else {
53
+ const buffer = Buffer.alloc(MAX_LENGTH);
54
+ fs.read(fd, buffer, 0, MAX_LENGTH, 0, (_, bytesRead) => {
55
+ resolve(buffer.subarray(0, bytesRead));
56
+ fs.close(fd, () => {});
57
+ });
58
+ }
59
+ });
60
+ });
61
+ module.exports = {
62
+ LDD_PATH,
63
+ SELF_PATH,
64
+ readFileSync,
65
+ readFile
66
+ };
67
+ }));
68
+ //#endregion
69
+ //#region node_modules/.pnpm/detect-libc@2.1.2/node_modules/detect-libc/lib/elf.js
70
+ var require_elf = /* @__PURE__ */ __commonJSMin(((exports, module) => {
71
+ var interpreterPath = (elf) => {
72
+ if (elf.length < 64) return null;
73
+ if (elf.readUInt32BE(0) !== 2135247942) return null;
74
+ if (elf.readUInt8(4) !== 2) return null;
75
+ if (elf.readUInt8(5) !== 1) return null;
76
+ const offset = elf.readUInt32LE(32);
77
+ const size = elf.readUInt16LE(54);
78
+ const count = elf.readUInt16LE(56);
79
+ for (let i = 0; i < count; i++) {
80
+ const headerOffset = offset + i * size;
81
+ if (elf.readUInt32LE(headerOffset) === 3) {
82
+ const fileOffset = elf.readUInt32LE(headerOffset + 8);
83
+ const fileSize = elf.readUInt32LE(headerOffset + 32);
84
+ return elf.subarray(fileOffset, fileOffset + fileSize).toString().replace(/\0.*$/g, "");
85
+ }
86
+ }
87
+ return null;
88
+ };
89
+ module.exports = { interpreterPath };
90
+ }));
91
+ //#endregion
92
+ //#region node_modules/.pnpm/detect-libc@2.1.2/node_modules/detect-libc/lib/detect-libc.js
93
+ var require_detect_libc = /* @__PURE__ */ __commonJSMin(((exports, module) => {
94
+ var childProcess = require___vite_browser_external();
95
+ var { isLinux, getReport } = require_process();
96
+ var { LDD_PATH, SELF_PATH, readFile, readFileSync } = require_filesystem();
97
+ var { interpreterPath } = require_elf();
98
+ var cachedFamilyInterpreter;
99
+ var cachedFamilyFilesystem;
100
+ var cachedVersionFilesystem;
101
+ var command = "getconf GNU_LIBC_VERSION 2>&1 || true; ldd --version 2>&1 || true";
102
+ var commandOut = "";
103
+ var safeCommand = () => {
104
+ if (!commandOut) return new Promise((resolve) => {
105
+ childProcess.exec(command, (err, out) => {
106
+ commandOut = err ? " " : out;
107
+ resolve(commandOut);
108
+ });
109
+ });
110
+ return commandOut;
111
+ };
112
+ var safeCommandSync = () => {
113
+ if (!commandOut) try {
114
+ commandOut = childProcess.execSync(command, { encoding: "utf8" });
115
+ } catch (_err) {
116
+ commandOut = " ";
117
+ }
118
+ return commandOut;
119
+ };
120
+ /**
121
+ * A String constant containing the value `glibc`.
122
+ * @type {string}
123
+ * @public
124
+ */
125
+ var GLIBC = "glibc";
126
+ /**
127
+ * A Regexp constant to get the GLIBC Version.
128
+ * @type {string}
129
+ */
130
+ var RE_GLIBC_VERSION = /LIBC[a-z0-9 \-).]*?(\d+\.\d+)/i;
131
+ /**
132
+ * A String constant containing the value `musl`.
133
+ * @type {string}
134
+ * @public
135
+ */
136
+ var MUSL = "musl";
137
+ var isFileMusl = (f) => f.includes("libc.musl-") || f.includes("ld-musl-");
138
+ var familyFromReport = () => {
139
+ const report = getReport();
140
+ if (report.header && report.header.glibcVersionRuntime) return GLIBC;
141
+ if (Array.isArray(report.sharedObjects)) {
142
+ if (report.sharedObjects.some(isFileMusl)) return MUSL;
143
+ }
144
+ return null;
145
+ };
146
+ var familyFromCommand = (out) => {
147
+ const [getconf, ldd1] = out.split(/[\r\n]+/);
148
+ if (getconf && getconf.includes(GLIBC)) return GLIBC;
149
+ if (ldd1 && ldd1.includes(MUSL)) return MUSL;
150
+ return null;
151
+ };
152
+ var familyFromInterpreterPath = (path) => {
153
+ if (path) {
154
+ if (path.includes("/ld-musl-")) return MUSL;
155
+ else if (path.includes("/ld-linux-")) return GLIBC;
156
+ }
157
+ return null;
158
+ };
159
+ var getFamilyFromLddContent = (content) => {
160
+ content = content.toString();
161
+ if (content.includes("musl")) return MUSL;
162
+ if (content.includes("GNU C Library")) return GLIBC;
163
+ return null;
164
+ };
165
+ var familyFromFilesystem = async () => {
166
+ if (cachedFamilyFilesystem !== void 0) return cachedFamilyFilesystem;
167
+ cachedFamilyFilesystem = null;
168
+ try {
169
+ cachedFamilyFilesystem = getFamilyFromLddContent(await readFile(LDD_PATH));
170
+ } catch (e) {}
171
+ return cachedFamilyFilesystem;
172
+ };
173
+ var familyFromFilesystemSync = () => {
174
+ if (cachedFamilyFilesystem !== void 0) return cachedFamilyFilesystem;
175
+ cachedFamilyFilesystem = null;
176
+ try {
177
+ cachedFamilyFilesystem = getFamilyFromLddContent(readFileSync(LDD_PATH));
178
+ } catch (e) {}
179
+ return cachedFamilyFilesystem;
180
+ };
181
+ var familyFromInterpreter = async () => {
182
+ if (cachedFamilyInterpreter !== void 0) return cachedFamilyInterpreter;
183
+ cachedFamilyInterpreter = null;
184
+ try {
185
+ cachedFamilyInterpreter = familyFromInterpreterPath(interpreterPath(await readFile(SELF_PATH)));
186
+ } catch (e) {}
187
+ return cachedFamilyInterpreter;
188
+ };
189
+ var familyFromInterpreterSync = () => {
190
+ if (cachedFamilyInterpreter !== void 0) return cachedFamilyInterpreter;
191
+ cachedFamilyInterpreter = null;
192
+ try {
193
+ cachedFamilyInterpreter = familyFromInterpreterPath(interpreterPath(readFileSync(SELF_PATH)));
194
+ } catch (e) {}
195
+ return cachedFamilyInterpreter;
196
+ };
197
+ /**
198
+ * Resolves with the libc family when it can be determined, `null` otherwise.
199
+ * @returns {Promise<?string>}
200
+ */
201
+ var family = async () => {
202
+ let family = null;
203
+ if (isLinux()) {
204
+ family = await familyFromInterpreter();
205
+ if (!family) {
206
+ family = await familyFromFilesystem();
207
+ if (!family) family = familyFromReport();
208
+ if (!family) family = familyFromCommand(await safeCommand());
209
+ }
210
+ }
211
+ return family;
212
+ };
213
+ /**
214
+ * Returns the libc family when it can be determined, `null` otherwise.
215
+ * @returns {?string}
216
+ */
217
+ var familySync = () => {
218
+ let family = null;
219
+ if (isLinux()) {
220
+ family = familyFromInterpreterSync();
221
+ if (!family) {
222
+ family = familyFromFilesystemSync();
223
+ if (!family) family = familyFromReport();
224
+ if (!family) family = familyFromCommand(safeCommandSync());
225
+ }
226
+ }
227
+ return family;
228
+ };
229
+ /**
230
+ * Resolves `true` only when the platform is Linux and the libc family is not `glibc`.
231
+ * @returns {Promise<boolean>}
232
+ */
233
+ var isNonGlibcLinux = async () => isLinux() && await family() !== GLIBC;
234
+ /**
235
+ * Returns `true` only when the platform is Linux and the libc family is not `glibc`.
236
+ * @returns {boolean}
237
+ */
238
+ var isNonGlibcLinuxSync = () => isLinux() && familySync() !== GLIBC;
239
+ var versionFromFilesystem = async () => {
240
+ if (cachedVersionFilesystem !== void 0) return cachedVersionFilesystem;
241
+ cachedVersionFilesystem = null;
242
+ try {
243
+ const versionMatch = (await readFile(LDD_PATH)).match(RE_GLIBC_VERSION);
244
+ if (versionMatch) cachedVersionFilesystem = versionMatch[1];
245
+ } catch (e) {}
246
+ return cachedVersionFilesystem;
247
+ };
248
+ var versionFromFilesystemSync = () => {
249
+ if (cachedVersionFilesystem !== void 0) return cachedVersionFilesystem;
250
+ cachedVersionFilesystem = null;
251
+ try {
252
+ const versionMatch = readFileSync(LDD_PATH).match(RE_GLIBC_VERSION);
253
+ if (versionMatch) cachedVersionFilesystem = versionMatch[1];
254
+ } catch (e) {}
255
+ return cachedVersionFilesystem;
256
+ };
257
+ var versionFromReport = () => {
258
+ const report = getReport();
259
+ if (report.header && report.header.glibcVersionRuntime) return report.header.glibcVersionRuntime;
260
+ return null;
261
+ };
262
+ var versionSuffix = (s) => s.trim().split(/\s+/)[1];
263
+ var versionFromCommand = (out) => {
264
+ const [getconf, ldd1, ldd2] = out.split(/[\r\n]+/);
265
+ if (getconf && getconf.includes(GLIBC)) return versionSuffix(getconf);
266
+ if (ldd1 && ldd2 && ldd1.includes(MUSL)) return versionSuffix(ldd2);
267
+ return null;
268
+ };
269
+ /**
270
+ * Resolves with the libc version when it can be determined, `null` otherwise.
271
+ * @returns {Promise<?string>}
272
+ */
273
+ var version = async () => {
274
+ let version = null;
275
+ if (isLinux()) {
276
+ version = await versionFromFilesystem();
277
+ if (!version) version = versionFromReport();
278
+ if (!version) version = versionFromCommand(await safeCommand());
279
+ }
280
+ return version;
281
+ };
282
+ /**
283
+ * Returns the libc version when it can be determined, `null` otherwise.
284
+ * @returns {?string}
285
+ */
286
+ var versionSync = () => {
287
+ let version = null;
288
+ if (isLinux()) {
289
+ version = versionFromFilesystemSync();
290
+ if (!version) version = versionFromReport();
291
+ if (!version) version = versionFromCommand(safeCommandSync());
292
+ }
293
+ return version;
294
+ };
295
+ module.exports = {
296
+ GLIBC,
297
+ MUSL,
298
+ family,
299
+ familySync,
300
+ isNonGlibcLinux,
301
+ isNonGlibcLinuxSync,
302
+ version,
303
+ versionSync
304
+ };
305
+ }));
306
+ //#endregion
307
+ //#region node_modules/.pnpm/lightningcss@1.32.0/node_modules/lightningcss/node/browserslistToTargets.js
308
+ var require_browserslistToTargets = /* @__PURE__ */ __commonJSMin(((exports, module) => {
309
+ var BROWSER_MAPPING = {
310
+ and_chr: "chrome",
311
+ and_ff: "firefox",
312
+ ie_mob: "ie",
313
+ op_mob: "opera",
314
+ and_qq: null,
315
+ and_uc: null,
316
+ baidu: null,
317
+ bb: null,
318
+ kaios: null,
319
+ op_mini: null
320
+ };
321
+ function browserslistToTargets(browserslist) {
322
+ let targets = {};
323
+ for (let browser of browserslist) {
324
+ let [name, v] = browser.split(" ");
325
+ if (BROWSER_MAPPING[name] === null) continue;
326
+ let version = parseVersion(v);
327
+ if (version == null) continue;
328
+ if (targets[name] == null || version < targets[name]) targets[name] = version;
329
+ }
330
+ return targets;
331
+ }
332
+ function parseVersion(version) {
333
+ let [major, minor = 0, patch = 0] = version.split("-")[0].split(".").map((v) => parseInt(v, 10));
334
+ if (isNaN(major) || isNaN(minor) || isNaN(patch)) return null;
335
+ return major << 16 | minor << 8 | patch;
336
+ }
337
+ module.exports = browserslistToTargets;
338
+ }));
339
+ //#endregion
340
+ //#region node_modules/.pnpm/lightningcss@1.32.0/node_modules/lightningcss/node/composeVisitors.js
341
+ var require_composeVisitors = /* @__PURE__ */ __commonJSMin(((exports, module) => {
342
+ /** @typedef {import('./index').Visitor} Visitor */
343
+ /** @typedef {import('./index').VisitorFunction} VisitorFunction */
344
+ /**
345
+ * Composes multiple visitor objects into a single one.
346
+ * @param {(Visitor | VisitorFunction)[]} visitors
347
+ * @return {Visitor | VisitorFunction}
348
+ */
349
+ function composeVisitors(visitors) {
350
+ if (visitors.length === 1) return visitors[0];
351
+ if (visitors.some((v) => typeof v === "function")) return (opts) => {
352
+ return composeVisitors(visitors.map((v) => typeof v === "function" ? v(opts) : v));
353
+ };
354
+ /** @type Visitor */
355
+ let res = {};
356
+ composeSimpleVisitors(res, visitors, "StyleSheet");
357
+ composeSimpleVisitors(res, visitors, "StyleSheetExit");
358
+ composeObjectVisitors(res, visitors, "Rule", ruleVisitor, wrapCustomAndUnknownAtRule);
359
+ composeObjectVisitors(res, visitors, "RuleExit", ruleVisitor, wrapCustomAndUnknownAtRule);
360
+ composeObjectVisitors(res, visitors, "Declaration", declarationVisitor, wrapCustomProperty);
361
+ composeObjectVisitors(res, visitors, "DeclarationExit", declarationVisitor, wrapCustomProperty);
362
+ composeSimpleVisitors(res, visitors, "Url");
363
+ composeSimpleVisitors(res, visitors, "Color");
364
+ composeSimpleVisitors(res, visitors, "Image");
365
+ composeSimpleVisitors(res, visitors, "ImageExit");
366
+ composeSimpleVisitors(res, visitors, "Length");
367
+ composeSimpleVisitors(res, visitors, "Angle");
368
+ composeSimpleVisitors(res, visitors, "Ratio");
369
+ composeSimpleVisitors(res, visitors, "Resolution");
370
+ composeSimpleVisitors(res, visitors, "Time");
371
+ composeSimpleVisitors(res, visitors, "CustomIdent");
372
+ composeSimpleVisitors(res, visitors, "DashedIdent");
373
+ composeArrayFunctions(res, visitors, "MediaQuery");
374
+ composeArrayFunctions(res, visitors, "MediaQueryExit");
375
+ composeSimpleVisitors(res, visitors, "SupportsCondition");
376
+ composeSimpleVisitors(res, visitors, "SupportsConditionExit");
377
+ composeArrayFunctions(res, visitors, "Selector");
378
+ composeTokenVisitors(res, visitors, "Token", "token", false);
379
+ composeTokenVisitors(res, visitors, "Function", "function", false);
380
+ composeTokenVisitors(res, visitors, "FunctionExit", "function", true);
381
+ composeTokenVisitors(res, visitors, "Variable", "var", false);
382
+ composeTokenVisitors(res, visitors, "VariableExit", "var", true);
383
+ composeTokenVisitors(res, visitors, "EnvironmentVariable", "env", false);
384
+ composeTokenVisitors(res, visitors, "EnvironmentVariableExit", "env", true);
385
+ return res;
386
+ }
387
+ module.exports = composeVisitors;
388
+ function wrapCustomAndUnknownAtRule(k, f) {
389
+ if (k === "unknown") return ((value) => f({
390
+ type: "unknown",
391
+ value
392
+ }));
393
+ if (k === "custom") return ((value) => f({
394
+ type: "custom",
395
+ value
396
+ }));
397
+ return f;
398
+ }
399
+ function wrapCustomProperty(k, f) {
400
+ return k === "custom" ? ((value) => f({
401
+ property: "custom",
402
+ value
403
+ })) : f;
404
+ }
405
+ /**
406
+ * @param {import('./index').Visitor['Rule']} f
407
+ * @param {import('./ast').Rule} item
408
+ */
409
+ function ruleVisitor(f, item) {
410
+ if (typeof f === "object") {
411
+ if (item.type === "unknown") {
412
+ let v = f.unknown;
413
+ if (typeof v === "object") v = v[item.value.name];
414
+ return v?.(item.value);
415
+ }
416
+ if (item.type === "custom") {
417
+ let v = f.custom;
418
+ if (typeof v === "object") v = v[item.value.name];
419
+ return v?.(item.value);
420
+ }
421
+ return f[item.type]?.(item);
422
+ }
423
+ return f?.(item);
424
+ }
425
+ /**
426
+ * @param {import('./index').Visitor['Declaration']} f
427
+ * @param {import('./ast').Declaration} item
428
+ */
429
+ function declarationVisitor(f, item) {
430
+ if (typeof f === "object") {
431
+ /** @type {string} */
432
+ let name = item.property;
433
+ if (item.property === "unparsed") name = item.value.propertyId.property;
434
+ else if (item.property === "custom") {
435
+ let v = f.custom;
436
+ if (typeof v === "object") v = v[item.value.name];
437
+ return v?.(item.value);
438
+ }
439
+ return f[name]?.(item);
440
+ }
441
+ return f?.(item);
442
+ }
443
+ /**
444
+ *
445
+ * @param {Visitor[]} visitors
446
+ * @param {string} key
447
+ * @returns {[any[], boolean, Set<string>]}
448
+ */
449
+ function extractObjectsOrFunctions(visitors, key) {
450
+ let values = [];
451
+ let hasFunction = false;
452
+ let allKeys = /* @__PURE__ */ new Set();
453
+ for (let visitor of visitors) {
454
+ let v = visitor[key];
455
+ if (v) {
456
+ if (typeof v === "function") hasFunction = true;
457
+ else for (let key in v) allKeys.add(key);
458
+ values.push(v);
459
+ }
460
+ }
461
+ return [
462
+ values,
463
+ hasFunction,
464
+ allKeys
465
+ ];
466
+ }
467
+ /**
468
+ * @template {keyof Visitor} K
469
+ * @param {Visitor} res
470
+ * @param {Visitor[]} visitors
471
+ * @param {K} key
472
+ * @param {(visitor: Visitor[K], item: any) => any | any[] | void} apply
473
+ * @param {(k: string, f: any) => any} wrapKey
474
+ */
475
+ function composeObjectVisitors(res, visitors, key, apply, wrapKey) {
476
+ let [values, hasFunction, allKeys] = extractObjectsOrFunctions(visitors, key);
477
+ if (values.length === 0) return;
478
+ if (values.length === 1) {
479
+ res[key] = values[0];
480
+ return;
481
+ }
482
+ let f = createArrayVisitor(visitors, (visitor, item) => apply(visitor[key], item));
483
+ if (hasFunction) res[key] = f;
484
+ else {
485
+ /** @type {any} */
486
+ let v = {};
487
+ for (let k of allKeys) v[k] = wrapKey(k, f);
488
+ res[key] = v;
489
+ }
490
+ }
491
+ /**
492
+ * @param {Visitor} res
493
+ * @param {Visitor[]} visitors
494
+ * @param {string} key
495
+ * @param {import('./ast').TokenOrValue['type']} type
496
+ * @param {boolean} isExit
497
+ */
498
+ function composeTokenVisitors(res, visitors, key, type, isExit) {
499
+ let [values, hasFunction, allKeys] = extractObjectsOrFunctions(visitors, key);
500
+ if (values.length === 0) return;
501
+ if (values.length === 1) {
502
+ res[key] = values[0];
503
+ return;
504
+ }
505
+ let f = createTokenVisitor(visitors, type, isExit);
506
+ if (hasFunction) res[key] = f;
507
+ else {
508
+ let v = {};
509
+ for (let key of allKeys) v[key] = f;
510
+ res[key] = v;
511
+ }
512
+ }
513
+ /**
514
+ * @param {Visitor[]} visitors
515
+ * @param {import('./ast').TokenOrValue['type']} type
516
+ */
517
+ function createTokenVisitor(visitors, type, isExit) {
518
+ let v = createArrayVisitor(visitors, (visitor, item) => {
519
+ let f;
520
+ switch (item.type) {
521
+ case "token":
522
+ f = visitor.Token;
523
+ if (typeof f === "object") f = f[item.value.type];
524
+ break;
525
+ case "function":
526
+ f = isExit ? visitor.FunctionExit : visitor.Function;
527
+ if (typeof f === "object") f = f[item.value.name];
528
+ break;
529
+ case "var":
530
+ f = isExit ? visitor.VariableExit : visitor.Variable;
531
+ break;
532
+ case "env":
533
+ f = isExit ? visitor.EnvironmentVariableExit : visitor.EnvironmentVariable;
534
+ if (typeof f === "object") {
535
+ let name;
536
+ switch (item.value.name.type) {
537
+ case "ua":
538
+ case "unknown":
539
+ name = item.value.name.value;
540
+ break;
541
+ case "custom":
542
+ name = item.value.name.ident;
543
+ break;
544
+ }
545
+ f = f[name];
546
+ }
547
+ break;
548
+ case "color":
549
+ f = visitor.Color;
550
+ break;
551
+ case "url":
552
+ f = visitor.Url;
553
+ break;
554
+ case "length":
555
+ f = visitor.Length;
556
+ break;
557
+ case "angle":
558
+ f = visitor.Angle;
559
+ break;
560
+ case "time":
561
+ f = visitor.Time;
562
+ break;
563
+ case "resolution":
564
+ f = visitor.Resolution;
565
+ break;
566
+ case "dashed-ident":
567
+ f = visitor.DashedIdent;
568
+ break;
569
+ }
570
+ if (!f) return;
571
+ let res = f(item.value);
572
+ switch (item.type) {
573
+ case "color":
574
+ case "url":
575
+ case "length":
576
+ case "angle":
577
+ case "time":
578
+ case "resolution":
579
+ case "dashed-ident":
580
+ if (Array.isArray(res)) res = res.map((value) => ({
581
+ type: item.type,
582
+ value
583
+ }));
584
+ else if (res) res = {
585
+ type: item.type,
586
+ value: res
587
+ };
588
+ break;
589
+ }
590
+ return res;
591
+ });
592
+ return (value) => v({
593
+ type,
594
+ value
595
+ });
596
+ }
597
+ /**
598
+ * @param {Visitor[]} visitors
599
+ * @param {string} key
600
+ */
601
+ function extractFunctions(visitors, key) {
602
+ let functions = [];
603
+ for (let visitor of visitors) {
604
+ let f = visitor[key];
605
+ if (f) functions.push(f);
606
+ }
607
+ return functions;
608
+ }
609
+ /**
610
+ * @param {Visitor} res
611
+ * @param {Visitor[]} visitors
612
+ * @param {string} key
613
+ */
614
+ function composeSimpleVisitors(res, visitors, key) {
615
+ let functions = extractFunctions(visitors, key);
616
+ if (functions.length === 0) return;
617
+ if (functions.length === 1) {
618
+ res[key] = functions[0];
619
+ return;
620
+ }
621
+ res[key] = (arg) => {
622
+ let mutated = false;
623
+ for (let f of functions) {
624
+ let res = f(arg);
625
+ if (res) {
626
+ arg = res;
627
+ mutated = true;
628
+ }
629
+ }
630
+ return mutated ? arg : void 0;
631
+ };
632
+ }
633
+ /**
634
+ * @param {Visitor} res
635
+ * @param {Visitor[]} visitors
636
+ * @param {string} key
637
+ */
638
+ function composeArrayFunctions(res, visitors, key) {
639
+ let functions = extractFunctions(visitors, key);
640
+ if (functions.length === 0) return;
641
+ if (functions.length === 1) {
642
+ res[key] = functions[0];
643
+ return;
644
+ }
645
+ res[key] = createArrayVisitor(functions, (f, item) => f(item));
646
+ }
647
+ /**
648
+ * @template T
649
+ * @template V
650
+ * @param {T[]} visitors
651
+ * @param {(visitor: T, item: V) => V | V[] | void} apply
652
+ * @returns {(item: V) => V | V[] | void}
653
+ */
654
+ function createArrayVisitor(visitors, apply) {
655
+ let seen = new Bitset(visitors.length);
656
+ return (arg) => {
657
+ let arr = [arg];
658
+ let mutated = false;
659
+ seen.clear();
660
+ for (let i = 0; i < arr.length; i++) for (let v = 0; v < visitors.length && i < arr.length;) {
661
+ if (seen.get(v)) {
662
+ v++;
663
+ continue;
664
+ }
665
+ let item = arr[i];
666
+ let visitor = visitors[v];
667
+ let res = apply(visitor, item);
668
+ if (Array.isArray(res)) {
669
+ if (res.length === 0) arr.splice(i, 1);
670
+ else if (res.length === 1) arr[i] = res[0];
671
+ else arr.splice(i, 1, ...res);
672
+ mutated = true;
673
+ seen.set(v);
674
+ v = 0;
675
+ } else if (res) {
676
+ arr[i] = res;
677
+ mutated = true;
678
+ seen.set(v);
679
+ v = 0;
680
+ } else v++;
681
+ }
682
+ if (!mutated) return;
683
+ return arr.length === 1 ? arr[0] : arr;
684
+ };
685
+ }
686
+ var Bitset = class {
687
+ constructor(maxBits = 32) {
688
+ this.bits = 0;
689
+ this.more = maxBits > 32 ? new Uint32Array(Math.ceil((maxBits - 32) / 32)) : null;
690
+ }
691
+ /** @param {number} bit */
692
+ get(bit) {
693
+ if (bit >= 32 && this.more) {
694
+ let i = Math.floor((bit - 32) / 32);
695
+ let b = bit % 32;
696
+ return Boolean(this.more[i] & 1 << b);
697
+ } else return Boolean(this.bits & 1 << bit);
698
+ }
699
+ /** @param {number} bit */
700
+ set(bit) {
701
+ if (bit >= 32 && this.more) {
702
+ let i = Math.floor((bit - 32) / 32);
703
+ let b = bit % 32;
704
+ this.more[i] |= 1 << b;
705
+ } else this.bits |= 1 << bit;
706
+ }
707
+ clear() {
708
+ this.bits = 0;
709
+ if (this.more) this.more.fill(0);
710
+ }
711
+ };
712
+ }));
713
+ //#endregion
714
+ //#region node_modules/.pnpm/lightningcss@1.32.0/node_modules/lightningcss/node/flags.js
715
+ var require_flags = /* @__PURE__ */ __commonJSMin(((exports) => {
716
+ exports.Features = {
717
+ Nesting: 1,
718
+ NotSelectorList: 2,
719
+ DirSelector: 4,
720
+ LangSelectorList: 8,
721
+ IsSelector: 16,
722
+ TextDecorationThicknessPercent: 32,
723
+ MediaIntervalSyntax: 64,
724
+ MediaRangeSyntax: 128,
725
+ CustomMediaQueries: 256,
726
+ ClampFunction: 512,
727
+ ColorFunction: 1024,
728
+ OklabColors: 2048,
729
+ LabColors: 4096,
730
+ P3Colors: 8192,
731
+ HexAlphaColors: 16384,
732
+ SpaceSeparatedColorNotation: 32768,
733
+ FontFamilySystemUi: 65536,
734
+ DoublePositionGradients: 131072,
735
+ VendorPrefixes: 262144,
736
+ LogicalProperties: 524288,
737
+ LightDark: 1048576,
738
+ Selectors: 31,
739
+ MediaQueries: 448,
740
+ Colors: 1113088
741
+ };
742
+ }));
743
+ var { transform, transformStyleAttribute, bundle, bundleAsync, browserslistToTargets, composeVisitors, Features } = (/* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((exports, module) => {
744
+ var parts = [process.platform, process.arch];
745
+ if (process.platform === "linux") {
746
+ const { MUSL, familySync } = require_detect_libc();
747
+ if (familySync() === MUSL) parts.push("musl");
748
+ else if (process.arch === "arm") parts.push("gnueabihf");
749
+ else parts.push("gnu");
750
+ } else if (process.platform === "win32") parts.push("msvc");
751
+ var native;
752
+ try {
753
+ native = __require(`lightningcss-${parts.join("-")}`);
754
+ } catch (err) {
755
+ native = __require(`../lightningcss.${parts.join("-")}.node`);
756
+ }
757
+ module.exports.transform = wrap(native.transform);
758
+ module.exports.transformStyleAttribute = wrap(native.transformStyleAttribute);
759
+ module.exports.bundle = wrap(native.bundle);
760
+ module.exports.bundleAsync = wrap(native.bundleAsync);
761
+ module.exports.browserslistToTargets = require_browserslistToTargets();
762
+ module.exports.composeVisitors = require_composeVisitors();
763
+ module.exports.Features = require_flags().Features;
764
+ function wrap(call) {
765
+ return (options) => {
766
+ if (typeof options.visitor === "function") {
767
+ let deps = [];
768
+ options.visitor = options.visitor({ addDependency(dep) {
769
+ deps.push(dep);
770
+ } });
771
+ let result = call(options);
772
+ if (result instanceof Promise) result = result.then((res) => {
773
+ if (deps.length) {
774
+ res.dependencies ??= [];
775
+ res.dependencies.push(...deps);
776
+ }
777
+ return res;
778
+ });
779
+ else if (deps.length) {
780
+ result.dependencies ??= [];
781
+ result.dependencies.push(...deps);
782
+ }
783
+ return result;
784
+ } else return call(options);
785
+ };
786
+ }
787
+ })))(), 1)).default;
788
+ //#endregion
789
+ export { Features, browserslistToTargets, bundle, bundleAsync, composeVisitors, transform, transformStyleAttribute };
790
+
791
+ //# sourceMappingURL=node.mjs.map