@vizejs/native 0.425.1 → 0.426.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.
Files changed (3) hide show
  1. package/index.d.ts +101 -0
  2. package/index.js +3 -0
  3. package/package.json +9 -9
package/index.d.ts CHANGED
@@ -706,6 +706,107 @@ export interface LintResultNapi {
706
706
  timeMs: number;
707
707
  }
708
708
 
709
+ /** A plugin as the SDK's `definePlugin` hands it to the host. */
710
+ export interface JsPluginNapi {
711
+ name: string;
712
+ version: string;
713
+ /** The SDK's digest of the plugin's rule sources. */
714
+ fingerprint: string;
715
+ visit?: Array<string>;
716
+ demands?: Array<string>;
717
+ /** Configuration and ambient values read by the rule. Required for caching. */
718
+ cacheInputs?: Array<PluginCacheInputNapi>;
719
+ /** `(batchJson) => reportsJson` — one call per document. */
720
+ run: (arg: string) => string;
721
+ }
722
+
723
+ /** One stable value a cached JS plugin declares it reads outside the batch. */
724
+ export interface PluginCacheInputNapi {
725
+ name: string;
726
+ value: string;
727
+ }
728
+
729
+ export interface PluginLintOptionsNapi {
730
+ filename?: string;
731
+ /** Reuse a result whose content key this process has already seen. */
732
+ cache?: boolean;
733
+ /** Optional directory for reusing results across Node processes. */
734
+ cacheDir?: string;
735
+ }
736
+
737
+ export interface PluginDiagnosticNapi {
738
+ ruleId: string;
739
+ plugin: string;
740
+ severity: string;
741
+ message: string;
742
+ start: number;
743
+ end: number;
744
+ line: number;
745
+ column: number;
746
+ endLine: number;
747
+ endColumn: number;
748
+ }
749
+
750
+ /** One plugin's cost in this lint run. */
751
+ export interface PluginCostNapi {
752
+ name: string;
753
+ version: string;
754
+ contentKey: string;
755
+ /** Nodes in the plugin's batch (0 when served from the cache). */
756
+ nodes: number;
757
+ batchBytes: number;
758
+ reports: number;
759
+ cached: boolean;
760
+ /** Host time for this plugin: batch build, the JS call, report mapping. */
761
+ elapsedNs: number;
762
+ /** The JS call alone. */
763
+ jsNs: number;
764
+ }
765
+
766
+ export interface PluginLintOutputNapi {
767
+ filename: string;
768
+ diagnostics: Array<PluginDiagnosticNapi>;
769
+ plugins: Array<PluginCostNapi>;
770
+ }
771
+
772
+ /**
773
+ * Lint one SFC with JS plugins: one batch and one call per plugin, every
774
+ * plugin's cost attributed, diagnostics in the host's one order.
775
+ */
776
+ export declare function lintWithPlugins(
777
+ source: string,
778
+ plugins: Array<JsPluginNapi>,
779
+ options?: PluginLintOptionsNapi | undefined | null,
780
+ ): PluginLintOutputNapi;
781
+
782
+ /**
783
+ * The proxy arm the spike measured and rejected: the same document behind
784
+ * a handle whose every read is one napi call.
785
+ */
786
+ export declare class PluginDocumentHandle {
787
+ /** How many nodes the document has (ids are `0..count`). */
788
+ count(): number;
789
+ kind(id: number): string | null;
790
+ /** The owning node, or -1. */
791
+ parent(id: number): number;
792
+ /** `name`, `value`, `alias.value`, `alias.key` or `alias.index`. */
793
+ field(id: number, key: string): string | null;
794
+ /** The names scope `id` binds (`templateScopes`), or `null`. */
795
+ scope(id: number): Array<ScopeEntryNapi> | null;
796
+ }
797
+
798
+ /** Open the proxy-arm handle over one SFC, computing `templateScopes`. */
799
+ export declare function openPluginDocument(
800
+ source: string,
801
+ filename?: string | undefined | null,
802
+ ): PluginDocumentHandle;
803
+
804
+ /** One `templateScopes` entry on the proxy arm. */
805
+ export interface ScopeEntryNapi {
806
+ name: string;
807
+ position: string;
808
+ }
809
+
709
810
  export interface MacroArtifactNapi {
710
811
  kind: string;
711
812
  name: string;
package/index.js CHANGED
@@ -5,6 +5,7 @@
5
5
  const nativeBinding = require("./native-binding");
6
6
 
7
7
  module.exports = nativeBinding;
8
+ module.exports.PluginDocumentHandle = nativeBinding.PluginDocumentHandle;
8
9
  module.exports.applyViteDefineReplacements = nativeBinding.applyViteDefineReplacements;
9
10
  module.exports.artToCsf = nativeBinding.artToCsf;
10
11
  module.exports.buildDesignTokenMap = nativeBinding.buildDesignTokenMap;
@@ -52,6 +53,7 @@ module.exports.isSfcImportableAssetUrl = nativeBinding.isSfcImportableAssetUrl;
52
53
  module.exports.isViteBareSpecifier = nativeBinding.isViteBareSpecifier;
53
54
  module.exports.lint = nativeBinding.lint;
54
55
  module.exports.lintPatinaSfc = nativeBinding.lintPatinaSfc;
56
+ module.exports.lintWithPlugins = nativeBinding.lintWithPlugins;
55
57
  module.exports.normalizeViteCssModuleFilename = nativeBinding.normalizeViteCssModuleFilename;
56
58
  module.exports.normalizeViteDevMiddlewareUrl = nativeBinding.normalizeViteDevMiddlewareUrl;
57
59
  module.exports.normalizeViteFsIdForBuild = nativeBinding.normalizeViteFsIdForBuild;
@@ -60,6 +62,7 @@ module.exports.normalizeViteRequireBase = nativeBinding.normalizeViteRequireBase
60
62
  module.exports.normalizeViteResolvedVuePath = nativeBinding.normalizeViteResolvedVuePath;
61
63
  module.exports.normalizeViteVirtualVueModuleId = nativeBinding.normalizeViteVirtualVueModuleId;
62
64
  module.exports.normalizeVizeConfig = nativeBinding.normalizeVizeConfig;
65
+ module.exports.openPluginDocument = nativeBinding.openPluginDocument;
63
66
  module.exports.parseArt = nativeBinding.parseArt;
64
67
  module.exports.parseArtStatusWarnings = nativeBinding.parseArtStatusWarnings;
65
68
  module.exports.parseCssAst = nativeBinding.parseCssAst;
package/package.json CHANGED
@@ -47,14 +47,14 @@
47
47
  ]
48
48
  },
49
49
  "optionalDependencies": {
50
- "@vizejs/native-darwin-arm64": "0.425.1",
51
- "@vizejs/native-darwin-x64": "0.425.1",
52
- "@vizejs/native-linux-arm64-gnu": "0.425.1",
53
- "@vizejs/native-linux-arm64-musl": "0.425.1",
54
- "@vizejs/native-linux-x64-gnu": "0.425.1",
55
- "@vizejs/native-linux-x64-musl": "0.425.1",
56
- "@vizejs/native-win32-arm64-msvc": "0.425.1",
57
- "@vizejs/native-win32-x64-msvc": "0.425.1"
50
+ "@vizejs/native-darwin-arm64": "0.426.0",
51
+ "@vizejs/native-darwin-x64": "0.426.0",
52
+ "@vizejs/native-linux-arm64-gnu": "0.426.0",
53
+ "@vizejs/native-linux-arm64-musl": "0.426.0",
54
+ "@vizejs/native-linux-x64-gnu": "0.426.0",
55
+ "@vizejs/native-linux-x64-musl": "0.426.0",
56
+ "@vizejs/native-win32-arm64-msvc": "0.426.0",
57
+ "@vizejs/native-win32-x64-msvc": "0.426.0"
58
58
  },
59
59
  "publishConfig": {
60
60
  "access": "public"
@@ -65,7 +65,7 @@
65
65
  "url": "https://github.com/ubugeeei-prod/vize"
66
66
  },
67
67
  "types": "index.d.ts",
68
- "version": "0.425.1",
68
+ "version": "0.426.0",
69
69
  "scripts": {
70
70
  "build": "node ./scripts/build-local.mjs --release",
71
71
  "build:ci": "napi build --platform --profile ci --manifest-path ../../crates/vize_vitrine/Cargo.toml -p vize_vitrine --features napi,legacy --output-dir . && node ./scripts/sync-entrypoint.mjs",