@hinkal/common 0.1.3 → 0.1.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.
package/README.md CHANGED
@@ -18,62 +18,6 @@ Or, yarn:
18
18
  yarn add @hinkal/common
19
19
  ```
20
20
 
21
-
22
- ## Vite-based React App
23
- #### Step 1: Create a Vite App
24
- If you don't have a Vite app set up, create one using the following command:
25
-
26
- ```bash
27
- npm create vite@latest my-vite-app --template react
28
- cd my-vite-app
29
- ```
30
-
31
- ## Next.js-based App
32
- #### Step 1: Create a Next.js App
33
- If you don't have a Next.js app set up, create one using the following command:
34
-
35
- ```bash
36
- npx create-next-app@latest my-next-app
37
- cd my-next-app
38
- ```
39
-
40
- #### Step 2: Install Required Packages
41
- For correct operation in Next.js, you should install copy-webpack-plugin:
42
-
43
- ```bash
44
- npm install copy-webpack-plugin node-polyfill-webpack-plugin
45
- ```
46
-
47
- #### Step 3: Configure Next.js
48
- Create or update the next.config.js file in the root of your Next.js project and add the following configuration:
49
-
50
- ```javascript
51
- // next.config.js
52
- const CopyPlugin = require("copy-webpack-plugin");
53
-
54
- module.exports = {
55
- webpack: (config) => {
56
- config.plugins.push(
57
- new NodePolyfillPlugin({
58
- additionalAliases: ['fs'],
59
- excludeAliases: ['constants']
60
- }),
61
- // TODO: research better solution
62
- new ReplaceInFileWebpackPlugin([{
63
- dir: 'node_modules/fastfile/src',
64
- files: ['fastfile.js'],
65
- rules: [{
66
- search: 'import { O_TRUNC, O_CREAT, O_RDWR, O_EXCL, O_RDONLY } from "constants";',
67
- replace: 'import t from "constants"; const { O_TRUNC, O_CREAT, O_RDWR, O_EXCL, O_RDONLY } = t;'
68
- }],
69
- }]),
70
- );
71
- return config;
72
- },
73
- };
74
- ```
75
- The CopyPlugin in the Next.js configuration is required to ensure that the necessary worker scripts are correctly loaded into your application. By copying the worker-related assets to the appropriate directory, you enable seamless access to these resources. This setup is crucial for the proper functioning of your library, which relies on Web Workers.
76
-
77
21
  ### Usage
78
22
 
79
23
  1. Import hinkal from @hinkal/common package and initiate a Hinkal instance:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hinkal/common",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
4
4
  "homepage": "hinkal.pro",
5
5
  "author": {
6
6
  "name": "Hinkal Protocol"
@@ -1 +1,21 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./zkProofWorker/zkProofWorkerLauncher.cjs"),o=require("./snarkjsWorker/snarkjsWorkerLauncher.cjs"),t=require("./utxoWorker/utxoWorkerLauncher.cjs"),r=require("./worker.registry.cjs"),n=async()=>({[r.WorkerVariant.ZKProof]:e,[r.WorkerVariant.SnarkJS]:o,[r.WorkerVariant.UTXO]:t});exports.getWorkerViteURL=n;
1
+
2
+ const domain = 'https://d13x2m0ev3hbsi.cloudfront.net';
3
+
4
+ // Returns a blob:// URL which points
5
+ // to a javascript file which will call
6
+ // importScripts with the given URL
7
+ async function getWorkerURL(url) {
8
+ const contentRes = await fetch(url);
9
+ const content = await contentRes.text()
10
+
11
+ return URL.createObjectURL(new Blob([content], { type: "application/javascript" }));
12
+ }
13
+
14
+ var e = /* @__PURE__ */ ((r) => (r.ZKProof = "ZKProof", r.SnarkJS = "SnarkJS", r.UTXO = "UTXO", r))(e || {});
15
+
16
+ const n = async () => ({
17
+ [e.ZKProof]: await getWorkerURL(domain + '/0.1.1/' + 'zkProofWorkerLauncher.js'),
18
+ [e.SnarkJS]: await getWorkerURL(domain + '/0.1.1/' + 'snarkjsWorkerLauncher.js'),
19
+ [e.UTXO]: await getWorkerURL(domain + '/0.1.1/' + 'utxoWorkerLauncher.js'),
20
+ });
21
+ exports.getWorkerViteURL = n;
@@ -18,6 +18,4 @@
18
18
  [e.SnarkJS]: await getWorkerURL(domain + '/0.1.1/' + 'snarkjsWorkerLauncher.js'),
19
19
  [e.UTXO]: await getWorkerURL(domain + '/0.1.1/' + 'utxoWorkerLauncher.js'),
20
20
  });
21
- export {
22
- n as getWorkerViteURL
23
- };
21
+ export { n as getWorkerViteURL };