@gravity-ui/data-source 0.10.0-alpha.1 → 0.10.0-alpha.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.
@@ -1,4 +1,4 @@
1
- const require_factory = require("./factory-Cdmba_F_.cjs");
1
+ const require_factory = require("./factory-CmOH3Kh6.cjs");
2
2
  //#region src/plugin/esbuild.ts
3
3
  var esbuild_default = (0, require("unplugin").createEsbuildPlugin)(require_factory.dataSourceLazyUnpluginFactory);
4
4
  //#endregion
@@ -1,4 +1,4 @@
1
- import { n as dataSourceLazyUnpluginFactory } from "./factory-2tSt4Rte.mjs";
1
+ import { n as dataSourceLazyUnpluginFactory } from "./factory--H-amlua.mjs";
2
2
  import { createEsbuildPlugin } from "unplugin";
3
3
  //#region src/plugin/esbuild.ts
4
4
  var esbuild_default = createEsbuildPlugin(dataSourceLazyUnpluginFactory);
@@ -27,8 +27,9 @@ function makeVirtualId(type, sourceFile) {
27
27
  return `${VIRTUAL_PREFIX}:${type}:${sourceFile}`;
28
28
  }
29
29
  function parseVirtualId(id) {
30
- if (id.indexOf("\0dsl-plugin") !== 0) return null;
31
- const rest = id.slice(12);
30
+ const prefixIndex = id.indexOf(VIRTUAL_PREFIX);
31
+ if (prefixIndex === -1) return null;
32
+ const rest = id.slice(prefixIndex + 11 + 1);
32
33
  const colonIndex = rest.indexOf(":");
33
34
  if (colonIndex === -1) return null;
34
35
  const type = rest.slice(0, colonIndex);
@@ -483,7 +484,8 @@ const dataSourceLazyUnpluginFactory = (options = {}) => {
483
484
  const info = getHocInfo(id, code);
484
485
  const usages = extractUsages(id, code);
485
486
  if (!info && usages.length === 0) return null;
486
- const verifiedUsages = (await Promise.all(usages.map(async (usage) => {
487
+ const filteredUsages = info ? dropAccessesInsideHocArgs(info, usages) : usages;
488
+ const verifiedUsages = (await Promise.all(filteredUsages.map(async (usage) => {
487
489
  const resolvedSourceFile = await resolveSourceFile(this, usage.decl.source, id);
488
490
  if (!resolvedSourceFile) return null;
489
491
  const usageInfo = getHocInfo(resolvedSourceFile);
@@ -509,5 +511,24 @@ const dataSourceLazyUnpluginFactory = (options = {}) => {
509
511
  }
510
512
  };
511
513
  };
514
+ function isInside(info, access) {
515
+ return info.argStart <= access.start && access.end <= info.argEnd;
516
+ }
517
+ function dropAccessesInsideHocArgs(info, usages) {
518
+ const result = [];
519
+ for (const usage of usages) {
520
+ const accesses = usage.accesses.filter((access) => !isInside(info.loading, access) && !isInside(info.error, access) && !(info.content.kind === "inline" && isInside(info.content, access)));
521
+ if (accesses.length === 0) continue;
522
+ if (accesses.length === usage.accesses.length) {
523
+ result.push(usage);
524
+ continue;
525
+ }
526
+ result.push({
527
+ ...usage,
528
+ accesses
529
+ });
530
+ }
531
+ return result;
532
+ }
512
533
  //#endregion
513
534
  export { dataSourceLazyUnpluginFactory as n, DEFAULT_HOCS as t };
@@ -52,8 +52,9 @@ function makeVirtualId(type, sourceFile) {
52
52
  return `${VIRTUAL_PREFIX}:${type}:${sourceFile}`;
53
53
  }
54
54
  function parseVirtualId(id) {
55
- if (id.indexOf("\0dsl-plugin") !== 0) return null;
56
- const rest = id.slice(12);
55
+ const prefixIndex = id.indexOf(VIRTUAL_PREFIX);
56
+ if (prefixIndex === -1) return null;
57
+ const rest = id.slice(prefixIndex + 11 + 1);
57
58
  const colonIndex = rest.indexOf(":");
58
59
  if (colonIndex === -1) return null;
59
60
  const type = rest.slice(0, colonIndex);
@@ -508,7 +509,8 @@ const dataSourceLazyUnpluginFactory = (options = {}) => {
508
509
  const info = getHocInfo(id, code);
509
510
  const usages = extractUsages(id, code);
510
511
  if (!info && usages.length === 0) return null;
511
- const verifiedUsages = (await Promise.all(usages.map(async (usage) => {
512
+ const filteredUsages = info ? dropAccessesInsideHocArgs(info, usages) : usages;
513
+ const verifiedUsages = (await Promise.all(filteredUsages.map(async (usage) => {
512
514
  const resolvedSourceFile = await resolveSourceFile(this, usage.decl.source, id);
513
515
  if (!resolvedSourceFile) return null;
514
516
  const usageInfo = getHocInfo(resolvedSourceFile);
@@ -534,6 +536,25 @@ const dataSourceLazyUnpluginFactory = (options = {}) => {
534
536
  }
535
537
  };
536
538
  };
539
+ function isInside(info, access) {
540
+ return info.argStart <= access.start && access.end <= info.argEnd;
541
+ }
542
+ function dropAccessesInsideHocArgs(info, usages) {
543
+ const result = [];
544
+ for (const usage of usages) {
545
+ const accesses = usage.accesses.filter((access) => !isInside(info.loading, access) && !isInside(info.error, access) && !(info.content.kind === "inline" && isInside(info.content, access)));
546
+ if (accesses.length === 0) continue;
547
+ if (accesses.length === usage.accesses.length) {
548
+ result.push(usage);
549
+ continue;
550
+ }
551
+ result.push({
552
+ ...usage,
553
+ accesses
554
+ });
555
+ }
556
+ return result;
557
+ }
537
558
  //#endregion
538
559
  Object.defineProperty(exports, "DEFAULT_HOCS", {
539
560
  enumerable: true,
@@ -2,7 +2,7 @@ Object.defineProperties(exports, {
2
2
  __esModule: { value: true },
3
3
  [Symbol.toStringTag]: { value: "Module" }
4
4
  });
5
- const require_factory = require("./factory-Cdmba_F_.cjs");
5
+ const require_factory = require("./factory-CmOH3Kh6.cjs");
6
6
  //#region src/plugin/index.ts
7
7
  const DataSourceLazyPlugin = /* @__PURE__ */ (0, require("unplugin").createUnplugin)(require_factory.dataSourceLazyUnpluginFactory);
8
8
  //#endregion
@@ -1,4 +1,4 @@
1
- import { n as dataSourceLazyUnpluginFactory, t as DEFAULT_HOCS } from "./factory-2tSt4Rte.mjs";
1
+ import { n as dataSourceLazyUnpluginFactory, t as DEFAULT_HOCS } from "./factory--H-amlua.mjs";
2
2
  import { createUnplugin } from "unplugin";
3
3
  //#region src/plugin/index.ts
4
4
  const DataSourceLazyPlugin = /* @__PURE__ */ createUnplugin(dataSourceLazyUnpluginFactory);
@@ -1,4 +1,4 @@
1
- const require_factory = require("./factory-Cdmba_F_.cjs");
1
+ const require_factory = require("./factory-CmOH3Kh6.cjs");
2
2
  //#region src/plugin/rollup.ts
3
3
  var rollup_default = (0, require("unplugin").createRollupPlugin)(require_factory.dataSourceLazyUnpluginFactory);
4
4
  //#endregion
@@ -1,4 +1,4 @@
1
- import { n as dataSourceLazyUnpluginFactory } from "./factory-2tSt4Rte.mjs";
1
+ import { n as dataSourceLazyUnpluginFactory } from "./factory--H-amlua.mjs";
2
2
  import { createRollupPlugin } from "unplugin";
3
3
  //#region src/plugin/rollup.ts
4
4
  var rollup_default = createRollupPlugin(dataSourceLazyUnpluginFactory);
@@ -1,4 +1,4 @@
1
- const require_factory = require("./factory-Cdmba_F_.cjs");
1
+ const require_factory = require("./factory-CmOH3Kh6.cjs");
2
2
  //#region src/plugin/rspack.ts
3
3
  var rspack_default = (0, require("unplugin").createRspackPlugin)(require_factory.dataSourceLazyUnpluginFactory);
4
4
  //#endregion
@@ -1,4 +1,4 @@
1
- import { n as dataSourceLazyUnpluginFactory } from "./factory-2tSt4Rte.mjs";
1
+ import { n as dataSourceLazyUnpluginFactory } from "./factory--H-amlua.mjs";
2
2
  import { createRspackPlugin } from "unplugin";
3
3
  //#region src/plugin/rspack.ts
4
4
  var rspack_default = createRspackPlugin(dataSourceLazyUnpluginFactory);
@@ -1,4 +1,4 @@
1
- const require_factory = require("./factory-Cdmba_F_.cjs");
1
+ const require_factory = require("./factory-CmOH3Kh6.cjs");
2
2
  //#region src/plugin/vite.ts
3
3
  var vite_default = (0, require("unplugin").createVitePlugin)(require_factory.dataSourceLazyUnpluginFactory);
4
4
  //#endregion
@@ -1,4 +1,4 @@
1
- import { n as dataSourceLazyUnpluginFactory } from "./factory-2tSt4Rte.mjs";
1
+ import { n as dataSourceLazyUnpluginFactory } from "./factory--H-amlua.mjs";
2
2
  import { createVitePlugin } from "unplugin";
3
3
  //#region src/plugin/vite.ts
4
4
  var vite_default = createVitePlugin(dataSourceLazyUnpluginFactory);
@@ -1,4 +1,4 @@
1
- const require_factory = require("./factory-Cdmba_F_.cjs");
1
+ const require_factory = require("./factory-CmOH3Kh6.cjs");
2
2
  //#region src/plugin/webpack.ts
3
3
  var webpack_default = (0, require("unplugin").createWebpackPlugin)(require_factory.dataSourceLazyUnpluginFactory);
4
4
  //#endregion
@@ -1,4 +1,4 @@
1
- import { n as dataSourceLazyUnpluginFactory } from "./factory-2tSt4Rte.mjs";
1
+ import { n as dataSourceLazyUnpluginFactory } from "./factory--H-amlua.mjs";
2
2
  import { createWebpackPlugin } from "unplugin";
3
3
  //#region src/plugin/webpack.ts
4
4
  var webpack_default = createWebpackPlugin(dataSourceLazyUnpluginFactory);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gravity-ui/data-source",
3
- "version": "0.10.0-alpha.1",
3
+ "version": "0.10.0-alpha.3",
4
4
  "description": "A wrapper around data fetching",
5
5
  "keywords": [
6
6
  "data-fetching",
@@ -24,9 +24,6 @@
24
24
  "yarn": "Please use npm instead of yarn to install dependencies",
25
25
  "pnpm": "Please use npm instead of pnpm to install dependencies"
26
26
  },
27
- "main": "build/cjs/index.js",
28
- "module": "build/esm/index.js",
29
- "types": "build/esm/index.d.ts",
30
27
  "exports": {
31
28
  ".": {
32
29
  "types": "./build/esm/index.d.ts",