@miden-sdk/vite-plugin 0.13.3 → 0.13.4

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.
@@ -0,0 +1,15 @@
1
+ import { Plugin } from 'vite';
2
+
3
+ interface MidenVitePluginOptions {
4
+ /** Packages to deduplicate. Default: ["@miden-sdk/miden-sdk"] */
5
+ wasmPackages?: string[];
6
+ /** Enable COOP/COEP headers on dev server. Default: true */
7
+ crossOriginIsolation?: boolean;
8
+ /** gRPC-web proxy target URL. Default: "https://rpc.testnet.miden.io". Set to false to disable. */
9
+ rpcProxyTarget?: string | false;
10
+ /** gRPC-web proxy path prefix. Default: "/rpc.Api" */
11
+ rpcProxyPath?: string;
12
+ }
13
+ declare function midenVitePlugin(options?: MidenVitePluginOptions): Plugin;
14
+
15
+ export { type MidenVitePluginOptions, midenVitePlugin as default, midenVitePlugin };
@@ -0,0 +1,15 @@
1
+ import { Plugin } from 'vite';
2
+
3
+ interface MidenVitePluginOptions {
4
+ /** Packages to deduplicate. Default: ["@miden-sdk/miden-sdk"] */
5
+ wasmPackages?: string[];
6
+ /** Enable COOP/COEP headers on dev server. Default: true */
7
+ crossOriginIsolation?: boolean;
8
+ /** gRPC-web proxy target URL. Default: "https://rpc.testnet.miden.io". Set to false to disable. */
9
+ rpcProxyTarget?: string | false;
10
+ /** gRPC-web proxy path prefix. Default: "/rpc.Api" */
11
+ rpcProxyPath?: string;
12
+ }
13
+ declare function midenVitePlugin(options?: MidenVitePluginOptions): Plugin;
14
+
15
+ export { type MidenVitePluginOptions, midenVitePlugin as default, midenVitePlugin };
package/dist/index.js ADDED
@@ -0,0 +1,105 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/index.ts
31
+ var index_exports = {};
32
+ __export(index_exports, {
33
+ default: () => index_default,
34
+ midenVitePlugin: () => midenVitePlugin
35
+ });
36
+ module.exports = __toCommonJS(index_exports);
37
+ var import_path = __toESM(require("path"));
38
+ var import_node_module = require("module");
39
+ function midenVitePlugin(options) {
40
+ const {
41
+ wasmPackages = ["@miden-sdk/miden-sdk"],
42
+ crossOriginIsolation = true,
43
+ rpcProxyTarget = "https://rpc.testnet.miden.io",
44
+ rpcProxyPath = "/rpc.Api"
45
+ } = options ?? {};
46
+ return {
47
+ name: "@miden-sdk/vite-plugin",
48
+ enforce: "pre",
49
+ config(userConfig, env) {
50
+ const root = userConfig.root ?? process.cwd();
51
+ const esmRequire = (0, import_node_module.createRequire)(`file://${root}/`);
52
+ const alias = wasmPackages.map((pkg) => {
53
+ let replacement;
54
+ try {
55
+ replacement = import_path.default.dirname(esmRequire.resolve(`${pkg}/package.json`));
56
+ } catch {
57
+ replacement = import_path.default.resolve(root, "node_modules", pkg);
58
+ }
59
+ return { find: pkg, replacement };
60
+ });
61
+ const serverConfig = {};
62
+ const previewConfig = {};
63
+ if (crossOriginIsolation) {
64
+ const coopCoepHeaders = {
65
+ "Cross-Origin-Opener-Policy": "same-origin",
66
+ "Cross-Origin-Embedder-Policy": "require-corp"
67
+ };
68
+ serverConfig.headers = coopCoepHeaders;
69
+ previewConfig.headers = coopCoepHeaders;
70
+ }
71
+ if (rpcProxyTarget !== false && env.command === "serve") {
72
+ serverConfig.proxy = {
73
+ [rpcProxyPath]: {
74
+ target: rpcProxyTarget,
75
+ changeOrigin: true
76
+ }
77
+ };
78
+ }
79
+ return {
80
+ resolve: {
81
+ alias,
82
+ dedupe: [...wasmPackages],
83
+ preserveSymlinks: true
84
+ },
85
+ optimizeDeps: {
86
+ exclude: [...wasmPackages]
87
+ },
88
+ build: {
89
+ target: "esnext"
90
+ },
91
+ worker: {
92
+ format: "es",
93
+ rollupOptions: { output: { format: "es" } }
94
+ },
95
+ server: serverConfig,
96
+ preview: previewConfig
97
+ };
98
+ }
99
+ };
100
+ }
101
+ var index_default = midenVitePlugin;
102
+ // Annotate the CommonJS export names for ESM import in node:
103
+ 0 && (module.exports = {
104
+ midenVitePlugin
105
+ });
package/dist/index.mjs ADDED
@@ -0,0 +1,70 @@
1
+ // src/index.ts
2
+ import path from "path";
3
+ import { createRequire } from "module";
4
+ function midenVitePlugin(options) {
5
+ const {
6
+ wasmPackages = ["@miden-sdk/miden-sdk"],
7
+ crossOriginIsolation = true,
8
+ rpcProxyTarget = "https://rpc.testnet.miden.io",
9
+ rpcProxyPath = "/rpc.Api"
10
+ } = options ?? {};
11
+ return {
12
+ name: "@miden-sdk/vite-plugin",
13
+ enforce: "pre",
14
+ config(userConfig, env) {
15
+ const root = userConfig.root ?? process.cwd();
16
+ const esmRequire = createRequire(`file://${root}/`);
17
+ const alias = wasmPackages.map((pkg) => {
18
+ let replacement;
19
+ try {
20
+ replacement = path.dirname(esmRequire.resolve(`${pkg}/package.json`));
21
+ } catch {
22
+ replacement = path.resolve(root, "node_modules", pkg);
23
+ }
24
+ return { find: pkg, replacement };
25
+ });
26
+ const serverConfig = {};
27
+ const previewConfig = {};
28
+ if (crossOriginIsolation) {
29
+ const coopCoepHeaders = {
30
+ "Cross-Origin-Opener-Policy": "same-origin",
31
+ "Cross-Origin-Embedder-Policy": "require-corp"
32
+ };
33
+ serverConfig.headers = coopCoepHeaders;
34
+ previewConfig.headers = coopCoepHeaders;
35
+ }
36
+ if (rpcProxyTarget !== false && env.command === "serve") {
37
+ serverConfig.proxy = {
38
+ [rpcProxyPath]: {
39
+ target: rpcProxyTarget,
40
+ changeOrigin: true
41
+ }
42
+ };
43
+ }
44
+ return {
45
+ resolve: {
46
+ alias,
47
+ dedupe: [...wasmPackages],
48
+ preserveSymlinks: true
49
+ },
50
+ optimizeDeps: {
51
+ exclude: [...wasmPackages]
52
+ },
53
+ build: {
54
+ target: "esnext"
55
+ },
56
+ worker: {
57
+ format: "es",
58
+ rollupOptions: { output: { format: "es" } }
59
+ },
60
+ server: serverConfig,
61
+ preview: previewConfig
62
+ };
63
+ }
64
+ };
65
+ }
66
+ var index_default = midenVitePlugin;
67
+ export {
68
+ index_default as default,
69
+ midenVitePlugin
70
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@miden-sdk/vite-plugin",
3
- "version": "0.13.3",
3
+ "version": "0.13.4",
4
4
  "description": "Vite plugin for Miden dApps — WASM dedup, COOP/COEP headers, and gRPC-web proxy",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",