@gravity-ui/data-source 0.10.0-alpha.10 → 0.10.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.
- package/build/plugin/esbuild.cjs +1 -1
- package/build/plugin/esbuild.mjs +1 -1
- package/build/plugin/{factory-C_-OCKcW.mjs → factory-BdwLvQEp.mjs} +20 -10
- package/build/plugin/{factory-B49Ym3ij.cjs → factory-TMKD3PiJ.cjs} +20 -10
- package/build/plugin/index.cjs +1 -1
- package/build/plugin/index.mjs +1 -1
- package/build/plugin/rollup.cjs +1 -1
- package/build/plugin/rollup.mjs +1 -1
- package/build/plugin/rspack.cjs +1 -1
- package/build/plugin/rspack.mjs +1 -1
- package/build/plugin/vite.cjs +1 -1
- package/build/plugin/vite.mjs +1 -1
- package/build/plugin/webpack.cjs +1 -1
- package/build/plugin/webpack.mjs +1 -1
- package/package.json +1 -1
package/build/plugin/esbuild.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const require_factory = require("./factory-
|
|
1
|
+
const require_factory = require("./factory-TMKD3PiJ.cjs");
|
|
2
2
|
//#region src/plugin/esbuild.ts
|
|
3
3
|
var esbuild_default = (0, require("unplugin").createEsbuildPlugin)(require_factory.dataSourceLazyUnpluginFactory);
|
|
4
4
|
//#endregion
|
package/build/plugin/esbuild.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as dataSourceLazyUnpluginFactory } from "./factory-
|
|
1
|
+
import { n as dataSourceLazyUnpluginFactory } from "./factory-BdwLvQEp.mjs";
|
|
2
2
|
import { createEsbuildPlugin } from "unplugin";
|
|
3
3
|
//#region src/plugin/esbuild.ts
|
|
4
4
|
var esbuild_default = createEsbuildPlugin(dataSourceLazyUnpluginFactory);
|
|
@@ -272,6 +272,9 @@ function extractUsages(filename, source) {
|
|
|
272
272
|
}
|
|
273
273
|
return result;
|
|
274
274
|
}
|
|
275
|
+
function isAccessInsideArg(arg, access) {
|
|
276
|
+
return arg.argStart <= access.start && access.end <= arg.argEnd;
|
|
277
|
+
}
|
|
275
278
|
function collectIdentifiers(node) {
|
|
276
279
|
const result = /* @__PURE__ */ new Set();
|
|
277
280
|
walk(node, (current) => {
|
|
@@ -422,7 +425,7 @@ function resolveWithCompiler(compiler, directory, request) {
|
|
|
422
425
|
}
|
|
423
426
|
//#endregion
|
|
424
427
|
//#region src/plugin/core/transform.ts
|
|
425
|
-
function transformDefinitionModule(s, filename, info) {
|
|
428
|
+
function transformDefinitionModule(s, filename, info, verifiedUsages) {
|
|
426
429
|
const name = info.exportedName;
|
|
427
430
|
const cleanFilename = stripQuery(filename);
|
|
428
431
|
const localSource = `./${path.basename(cleanFilename, path.extname(cleanFilename))}`;
|
|
@@ -433,13 +436,23 @@ function transformDefinitionModule(s, filename, info) {
|
|
|
433
436
|
if (info.error) s.overwrite(info.error.argStart, info.error.argEnd, `${name}Error`);
|
|
434
437
|
if (info.content.kind === "identifier") s.append(`\nexport {${info.content.name} as ${name}Content};\n`);
|
|
435
438
|
else {
|
|
436
|
-
|
|
439
|
+
const contentSource = verifiedUsages.length > 0 ? renderInlineContent(info.content, verifiedUsages) : info.content.argSource;
|
|
440
|
+
s.appendLeft(info.hocExportStart, `const ${name}Content = ${contentSource};\n\n`);
|
|
437
441
|
s.overwrite(info.content.argStart, info.content.argEnd, `${name}Content`);
|
|
438
442
|
s.append(`\nexport {${name}Content};\n`);
|
|
439
443
|
}
|
|
440
444
|
}
|
|
441
|
-
function
|
|
442
|
-
|
|
445
|
+
function renderInlineContent(content, usages) {
|
|
446
|
+
const s = new MagicString(content.argSource);
|
|
447
|
+
for (const { usage } of usages) for (const access of usage.accesses) if (isAccessInsideArg(content, access)) s.overwrite(access.start - content.argStart, access.end - content.argStart, `${usage.spec.localName}${access.prop}`);
|
|
448
|
+
return s.toString();
|
|
449
|
+
}
|
|
450
|
+
function transformUsages(s, usages, info) {
|
|
451
|
+
const inlineContent = info?.content.kind === "inline" ? info.content : null;
|
|
452
|
+
for (const { usage } of usages) for (const access of usage.accesses) {
|
|
453
|
+
if (inlineContent && isAccessInsideArg(inlineContent, access)) continue;
|
|
454
|
+
s.overwrite(access.start, access.end, `${usage.spec.localName}${access.prop}`);
|
|
455
|
+
}
|
|
443
456
|
const newImports = [];
|
|
444
457
|
for (const { usage, hocImportSource, hocExportedName } of usages) {
|
|
445
458
|
const propsUsed = new Set(usage.accesses.map((access) => access.prop));
|
|
@@ -612,8 +625,8 @@ const dataSourceLazyUnpluginFactory = (options = {}) => {
|
|
|
612
625
|
const verifiedUsages = await verifyUsages(this, filteredUsages, id);
|
|
613
626
|
if (!info && verifiedUsages.length === 0) return null;
|
|
614
627
|
const s = new MagicString(code);
|
|
615
|
-
if (info) transformDefinitionModule(s, id, info);
|
|
616
|
-
if (verifiedUsages.length > 0) transformUsages(s, verifiedUsages);
|
|
628
|
+
if (info) transformDefinitionModule(s, id, info, verifiedUsages);
|
|
629
|
+
if (verifiedUsages.length > 0) transformUsages(s, verifiedUsages, info);
|
|
617
630
|
if (!s.hasChanged()) return null;
|
|
618
631
|
return {
|
|
619
632
|
code: s.toString(),
|
|
@@ -631,13 +644,10 @@ const dataSourceLazyUnpluginFactory = (options = {}) => {
|
|
|
631
644
|
}
|
|
632
645
|
};
|
|
633
646
|
};
|
|
634
|
-
function isInside(info, access) {
|
|
635
|
-
return info.argStart <= access.start && access.end <= info.argEnd;
|
|
636
|
-
}
|
|
637
647
|
function dropAccessesInsideHocArgs(info, usages) {
|
|
638
648
|
const result = [];
|
|
639
649
|
for (const usage of usages) {
|
|
640
|
-
const accesses = usage.accesses.filter((access) => !
|
|
650
|
+
const accesses = usage.accesses.filter((access) => !isAccessInsideArg(info.loading, access) && !(info.error && isAccessInsideArg(info.error, access)));
|
|
641
651
|
if (accesses.length === 0) continue;
|
|
642
652
|
if (accesses.length === usage.accesses.length) {
|
|
643
653
|
result.push(usage);
|
|
@@ -297,6 +297,9 @@ function extractUsages(filename, source) {
|
|
|
297
297
|
}
|
|
298
298
|
return result;
|
|
299
299
|
}
|
|
300
|
+
function isAccessInsideArg(arg, access) {
|
|
301
|
+
return arg.argStart <= access.start && access.end <= arg.argEnd;
|
|
302
|
+
}
|
|
300
303
|
function collectIdentifiers(node) {
|
|
301
304
|
const result = /* @__PURE__ */ new Set();
|
|
302
305
|
walk(node, (current) => {
|
|
@@ -447,7 +450,7 @@ function resolveWithCompiler(compiler, directory, request) {
|
|
|
447
450
|
}
|
|
448
451
|
//#endregion
|
|
449
452
|
//#region src/plugin/core/transform.ts
|
|
450
|
-
function transformDefinitionModule(s, filename, info) {
|
|
453
|
+
function transformDefinitionModule(s, filename, info, verifiedUsages) {
|
|
451
454
|
const name = info.exportedName;
|
|
452
455
|
const cleanFilename = stripQuery(filename);
|
|
453
456
|
const localSource = `./${node_path.default.basename(cleanFilename, node_path.default.extname(cleanFilename))}`;
|
|
@@ -458,13 +461,23 @@ function transformDefinitionModule(s, filename, info) {
|
|
|
458
461
|
if (info.error) s.overwrite(info.error.argStart, info.error.argEnd, `${name}Error`);
|
|
459
462
|
if (info.content.kind === "identifier") s.append(`\nexport {${info.content.name} as ${name}Content};\n`);
|
|
460
463
|
else {
|
|
461
|
-
|
|
464
|
+
const contentSource = verifiedUsages.length > 0 ? renderInlineContent(info.content, verifiedUsages) : info.content.argSource;
|
|
465
|
+
s.appendLeft(info.hocExportStart, `const ${name}Content = ${contentSource};\n\n`);
|
|
462
466
|
s.overwrite(info.content.argStart, info.content.argEnd, `${name}Content`);
|
|
463
467
|
s.append(`\nexport {${name}Content};\n`);
|
|
464
468
|
}
|
|
465
469
|
}
|
|
466
|
-
function
|
|
467
|
-
|
|
470
|
+
function renderInlineContent(content, usages) {
|
|
471
|
+
const s = new magic_string.default(content.argSource);
|
|
472
|
+
for (const { usage } of usages) for (const access of usage.accesses) if (isAccessInsideArg(content, access)) s.overwrite(access.start - content.argStart, access.end - content.argStart, `${usage.spec.localName}${access.prop}`);
|
|
473
|
+
return s.toString();
|
|
474
|
+
}
|
|
475
|
+
function transformUsages(s, usages, info) {
|
|
476
|
+
const inlineContent = info?.content.kind === "inline" ? info.content : null;
|
|
477
|
+
for (const { usage } of usages) for (const access of usage.accesses) {
|
|
478
|
+
if (inlineContent && isAccessInsideArg(inlineContent, access)) continue;
|
|
479
|
+
s.overwrite(access.start, access.end, `${usage.spec.localName}${access.prop}`);
|
|
480
|
+
}
|
|
468
481
|
const newImports = [];
|
|
469
482
|
for (const { usage, hocImportSource, hocExportedName } of usages) {
|
|
470
483
|
const propsUsed = new Set(usage.accesses.map((access) => access.prop));
|
|
@@ -637,8 +650,8 @@ const dataSourceLazyUnpluginFactory = (options = {}) => {
|
|
|
637
650
|
const verifiedUsages = await verifyUsages(this, filteredUsages, id);
|
|
638
651
|
if (!info && verifiedUsages.length === 0) return null;
|
|
639
652
|
const s = new magic_string.default(code);
|
|
640
|
-
if (info) transformDefinitionModule(s, id, info);
|
|
641
|
-
if (verifiedUsages.length > 0) transformUsages(s, verifiedUsages);
|
|
653
|
+
if (info) transformDefinitionModule(s, id, info, verifiedUsages);
|
|
654
|
+
if (verifiedUsages.length > 0) transformUsages(s, verifiedUsages, info);
|
|
642
655
|
if (!s.hasChanged()) return null;
|
|
643
656
|
return {
|
|
644
657
|
code: s.toString(),
|
|
@@ -656,13 +669,10 @@ const dataSourceLazyUnpluginFactory = (options = {}) => {
|
|
|
656
669
|
}
|
|
657
670
|
};
|
|
658
671
|
};
|
|
659
|
-
function isInside(info, access) {
|
|
660
|
-
return info.argStart <= access.start && access.end <= info.argEnd;
|
|
661
|
-
}
|
|
662
672
|
function dropAccessesInsideHocArgs(info, usages) {
|
|
663
673
|
const result = [];
|
|
664
674
|
for (const usage of usages) {
|
|
665
|
-
const accesses = usage.accesses.filter((access) => !
|
|
675
|
+
const accesses = usage.accesses.filter((access) => !isAccessInsideArg(info.loading, access) && !(info.error && isAccessInsideArg(info.error, access)));
|
|
666
676
|
if (accesses.length === 0) continue;
|
|
667
677
|
if (accesses.length === usage.accesses.length) {
|
|
668
678
|
result.push(usage);
|
package/build/plugin/index.cjs
CHANGED
|
@@ -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-
|
|
5
|
+
const require_factory = require("./factory-TMKD3PiJ.cjs");
|
|
6
6
|
//#region src/plugin/index.ts
|
|
7
7
|
const DataSourceLazyPlugin = /* @__PURE__ */ (0, require("unplugin").createUnplugin)(require_factory.dataSourceLazyUnpluginFactory);
|
|
8
8
|
//#endregion
|
package/build/plugin/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as dataSourceLazyUnpluginFactory, t as DEFAULT_HOCS } from "./factory-
|
|
1
|
+
import { n as dataSourceLazyUnpluginFactory, t as DEFAULT_HOCS } from "./factory-BdwLvQEp.mjs";
|
|
2
2
|
import { createUnplugin } from "unplugin";
|
|
3
3
|
//#region src/plugin/index.ts
|
|
4
4
|
const DataSourceLazyPlugin = /* @__PURE__ */ createUnplugin(dataSourceLazyUnpluginFactory);
|
package/build/plugin/rollup.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const require_factory = require("./factory-
|
|
1
|
+
const require_factory = require("./factory-TMKD3PiJ.cjs");
|
|
2
2
|
//#region src/plugin/rollup.ts
|
|
3
3
|
var rollup_default = (0, require("unplugin").createRollupPlugin)(require_factory.dataSourceLazyUnpluginFactory);
|
|
4
4
|
//#endregion
|
package/build/plugin/rollup.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as dataSourceLazyUnpluginFactory } from "./factory-
|
|
1
|
+
import { n as dataSourceLazyUnpluginFactory } from "./factory-BdwLvQEp.mjs";
|
|
2
2
|
import { createRollupPlugin } from "unplugin";
|
|
3
3
|
//#region src/plugin/rollup.ts
|
|
4
4
|
var rollup_default = createRollupPlugin(dataSourceLazyUnpluginFactory);
|
package/build/plugin/rspack.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const require_factory = require("./factory-
|
|
1
|
+
const require_factory = require("./factory-TMKD3PiJ.cjs");
|
|
2
2
|
//#region src/plugin/rspack.ts
|
|
3
3
|
var rspack_default = (0, require("unplugin").createRspackPlugin)(require_factory.dataSourceLazyUnpluginFactory);
|
|
4
4
|
//#endregion
|
package/build/plugin/rspack.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as dataSourceLazyUnpluginFactory } from "./factory-
|
|
1
|
+
import { n as dataSourceLazyUnpluginFactory } from "./factory-BdwLvQEp.mjs";
|
|
2
2
|
import { createRspackPlugin } from "unplugin";
|
|
3
3
|
//#region src/plugin/rspack.ts
|
|
4
4
|
var rspack_default = createRspackPlugin(dataSourceLazyUnpluginFactory);
|
package/build/plugin/vite.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const require_factory = require("./factory-
|
|
1
|
+
const require_factory = require("./factory-TMKD3PiJ.cjs");
|
|
2
2
|
//#region src/plugin/vite.ts
|
|
3
3
|
var vite_default = (0, require("unplugin").createVitePlugin)(require_factory.dataSourceLazyUnpluginFactory);
|
|
4
4
|
//#endregion
|
package/build/plugin/vite.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as dataSourceLazyUnpluginFactory } from "./factory-
|
|
1
|
+
import { n as dataSourceLazyUnpluginFactory } from "./factory-BdwLvQEp.mjs";
|
|
2
2
|
import { createVitePlugin } from "unplugin";
|
|
3
3
|
//#region src/plugin/vite.ts
|
|
4
4
|
var vite_default = createVitePlugin(dataSourceLazyUnpluginFactory);
|
package/build/plugin/webpack.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const require_factory = require("./factory-
|
|
1
|
+
const require_factory = require("./factory-TMKD3PiJ.cjs");
|
|
2
2
|
//#region src/plugin/webpack.ts
|
|
3
3
|
var webpack_default = (0, require("unplugin").createWebpackPlugin)(require_factory.dataSourceLazyUnpluginFactory);
|
|
4
4
|
//#endregion
|
package/build/plugin/webpack.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as dataSourceLazyUnpluginFactory } from "./factory-
|
|
1
|
+
import { n as dataSourceLazyUnpluginFactory } from "./factory-BdwLvQEp.mjs";
|
|
2
2
|
import { createWebpackPlugin } from "unplugin";
|
|
3
3
|
//#region src/plugin/webpack.ts
|
|
4
4
|
var webpack_default = createWebpackPlugin(dataSourceLazyUnpluginFactory);
|