@dvaji/cheerox 0.1.1 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. package/Cargo.lock +1 -4
  2. package/Cargo.toml +3 -2
  3. package/THIRD_PARTY_NOTICES.md +5 -3
  4. package/cheerox.darwin-arm64.node +0 -0
  5. package/cheerox.darwin-x64.node +0 -0
  6. package/cheerox.linux-arm64-gnu.node +0 -0
  7. package/cheerox.linux-arm64-musl.node +0 -0
  8. package/cheerox.linux-x64-gnu.node +0 -0
  9. package/cheerox.linux-x64-musl.node +0 -0
  10. package/cheerox.win32-arm64-msvc.node +0 -0
  11. package/cheerox.win32-x64-msvc.node +0 -0
  12. package/dist/{cheerio-compat-DSwBAJ1s.cjs → cheerio-compat-8HucV2qE.cjs} +9 -7
  13. package/dist/cheerio-compat-8HucV2qE.cjs.map +1 -0
  14. package/dist/{cheerio-compat-DRLPzBdX.d.mts → cheerio-compat-BM4_lqVU.d.mts} +3 -3
  15. package/dist/{cheerio-compat-DRsINTwV.d.ts → cheerio-compat-BnFvIIuE.d.cts} +3 -3
  16. package/dist/{cheerio-compat-DRsINTwV.d.cts → cheerio-compat-BnFvIIuE.d.ts} +3 -3
  17. package/dist/{cheerio-compat-BS--qPzw.mjs → cheerio-compat-Dwarm-h8.mjs} +9 -7
  18. package/dist/cheerio-compat-Dwarm-h8.mjs.map +1 -0
  19. package/dist/cheerio-compat.cjs +1 -1
  20. package/dist/cheerio-compat.d.cts +1 -1
  21. package/dist/cheerio-compat.d.mts +1 -1
  22. package/dist/cheerio-compat.d.ts +1 -1
  23. package/dist/cheerio-compat.mjs +1 -1
  24. package/dist/index.d.mts +1 -1
  25. package/dist/{modern-CvXcTn82.mjs → modern-BwcwZX6l.mjs} +2 -2
  26. package/dist/{modern-CvXcTn82.mjs.map → modern-BwcwZX6l.mjs.map} +1 -1
  27. package/dist/{modern-CHQGP0Yt.cjs → modern-DMcsyA4b.cjs} +2 -2
  28. package/dist/{modern-CHQGP0Yt.cjs.map → modern-DMcsyA4b.cjs.map} +1 -1
  29. package/dist/modern.cjs +2 -2
  30. package/dist/modern.mjs +2 -2
  31. package/dist/{nodes-jbWWhssj.cjs → nodes-Be5sB8rQ.cjs} +23 -15
  32. package/dist/nodes-Be5sB8rQ.cjs.map +1 -0
  33. package/dist/{nodes-sYxb5qyZ.mjs → nodes-C95i5k2P.mjs} +23 -15
  34. package/dist/nodes-C95i5k2P.mjs.map +1 -0
  35. package/dist/slim.cjs +1 -1
  36. package/dist/slim.mjs +1 -1
  37. package/native/src/lib.rs +509 -1
  38. package/native/vendor/README.md +12 -3
  39. package/native/vendor/scraper-0.24.0/Cargo.toml +52 -0
  40. package/native/vendor/scraper-0.24.0/LICENSE +15 -0
  41. package/native/vendor/scraper-0.24.0/src/element_ref/element.rs +212 -0
  42. package/native/vendor/scraper-0.24.0/src/element_ref/mod.rs +236 -0
  43. package/native/vendor/scraper-0.24.0/src/element_ref/serializable.rs +15 -0
  44. package/native/vendor/scraper-0.24.0/src/error/utils.rs +91 -0
  45. package/native/vendor/scraper-0.24.0/src/error.rs +118 -0
  46. package/native/vendor/scraper-0.24.0/src/html/mod.rs +270 -0
  47. package/native/vendor/scraper-0.24.0/src/html/serializable.rs +27 -0
  48. package/native/vendor/scraper-0.24.0/src/html/tree_sink.rs +285 -0
  49. package/native/vendor/scraper-0.24.0/src/lib.rs +180 -0
  50. package/native/vendor/scraper-0.24.0/src/node/serializable.rs +52 -0
  51. package/native/vendor/scraper-0.24.0/src/node.rs +465 -0
  52. package/native/vendor/scraper-0.24.0/src/selectable.rs +70 -0
  53. package/native/vendor/scraper-0.24.0/src/selector.rs +290 -0
  54. package/package.json +1 -1
  55. package/scripts/check-release.mjs +2 -2
  56. package/scripts/generate-notices.mjs +10 -4
  57. package/src/cheerio-compat.ts +14 -4
  58. package/src/native.ts +23 -9
  59. package/dist/cheerio-compat-BS--qPzw.mjs.map +0 -1
  60. package/dist/cheerio-compat-DSwBAJ1s.cjs.map +0 -1
  61. package/dist/nodes-jbWWhssj.cjs.map +0 -1
  62. package/dist/nodes-sYxb5qyZ.mjs.map +0 -1
@@ -1,5 +1,4 @@
1
1
  import { createRequire } from "node:module";
2
- import { existsSync } from "node:fs";
3
2
  import { dirname, join } from "node:path";
4
3
  import { fileURLToPath } from "node:url";
5
4
  // src/codec.ts
@@ -262,6 +261,21 @@ let bindingError;
262
261
  function packageDirectory() {
263
262
  return typeof __dirname === "string" ? __dirname : dirname(fileURLToPath(import.meta.url));
264
263
  }
264
+ /** The platform directory component used by binary names and companion packages. */
265
+ function platformComponent() {
266
+ const libc = process.platform === "linux" ? (process.report?.getReport())?.header?.glibcVersionRuntime ? "gnu" : "musl" : void 0;
267
+ return `${process.platform}-${process.arch}${libc ? `-${libc}` : process.platform === "win32" ? "-msvc" : ""}`;
268
+ }
269
+ /**
270
+ * Where the native addon may be found, most preferred first: the
271
+ * platform-specific companion package published alongside the main package
272
+ * (`@dvaji/cheerox-<platform>`), then the binaries bundled with the package
273
+ * (or present in a parent directory for source checkouts).
274
+ */
275
+ function nativeBindingCandidates(platform, directories) {
276
+ const names = [`cheerox.${platform}.node`, "cheerox.node"];
277
+ return [`@dvaji/cheerox-${platform}`, ...new Set(directories.flatMap((directory) => names.map((name) => join(directory, name))))];
278
+ }
265
279
  /** Resolve the native addon bundled with the npm package. */
266
280
  function nativeBinding() {
267
281
  if (attempted) return cached;
@@ -269,20 +283,14 @@ function nativeBinding() {
269
283
  const moduleDirectory = packageDirectory();
270
284
  const require = createRequire(join(moduleDirectory, "cheerox-loader.cjs"));
271
285
  const directories = [moduleDirectory, dirname(moduleDirectory)];
272
- const libc = process.platform === "linux" ? (process.report?.getReport())?.header?.glibcVersionRuntime ? "gnu" : "musl" : void 0;
273
- const names = [`cheerox.${`${process.platform}-${process.arch}${libc ? `-${libc}` : process.platform === "win32" ? "-msvc" : ""}`}.node`, "cheerox.node"];
274
- const candidates = [...new Set(directories.flatMap((directory) => names.map((name) => join(directory, name))))];
275
- for (const candidate of candidates) {
276
- if (!existsSync(candidate)) continue;
277
- try {
278
- const loaded = require(candidate);
279
- if (typeof loaded.NativeDocument === "function") {
280
- cached = wrapNativeBinding(loaded);
281
- return cached;
282
- }
283
- } catch (error) {
284
- bindingError ??= error;
286
+ for (const candidate of nativeBindingCandidates(platformComponent(), directories)) try {
287
+ const loaded = require(candidate);
288
+ if (typeof loaded.NativeDocument === "function") {
289
+ cached = wrapNativeBinding(loaded);
290
+ return cached;
285
291
  }
292
+ } catch (error) {
293
+ bindingError ??= error;
286
294
  }
287
295
  }
288
296
  function requireNative() {
@@ -3800,4 +3808,4 @@ function importNodes(document, input) {
3800
3808
  }
3801
3809
  export { structureSnapshot as $, isDocument as A, VIEW_SELF as B, NodeWithChildren as C, isCDATA as D, hasChildren as E, IDS as F, leaseNodes as G, attributeAt as H, IS_PLAIN as I, recordAt as J, plainSnapshot as K, LEASE as L, isText as M, API as N, isComment as O, DOCUMENT as P, stateIn as Q, VALUES as R, Node as S, Text as T, exposeDocumentTo as U, VIEW_STATE as V, isRouted as W, routeDocument as X, resumeCollection as Y, sameNodeSpace as Z, Comment as _, hydrateLocation as a, createTokenizerSession as at, Element as b, nodeId as c, hasParserHooks as ct, rootNode as d, NodeSnapshot as dt, updateLease as et, setRootIfCached as f, nativeStatus as ft, CDATA as g, viewIdIn as h, hasMaterializedChildren as i, createDiagnosticSession as it, isTag as j, isDirective as k, nodeRecord as l, parseNativeDocument as lt, viewId as m, decodeJson as mt, getNodesOfType as n, writeCount as nt, importNodes as o, createTreeAdapterSession as ot, traverseRecords as p, requireNative as pt, prepareBulkViews as q, hasMaterializedAttributes as r, cleanParserOptions as rt, nodeBinding as s, deliverParseErrors as st, getNode as t, usePreparedSnapshot as tt, operation as u, parserOptions as ut, DataNode as v, ProcessingInstruction as w, ElementType as x, Document as y, VIEW_LOCAL as z };
3802
3810
 
3803
- //# sourceMappingURL=nodes-sYxb5qyZ.mjs.map
3811
+ //# sourceMappingURL=nodes-C95i5k2P.mjs.map