,
- "ref" | "color" | "slot" | OmitKeys
-> & {
- as?: As;
-};
-
-export type PropGetter, R = DOMAttributes> = (
- props?: Merge,
- ref?: React.Ref,
-) => R & React.RefAttributes;
-
-export const spacingScaleKeys = [
- "0",
- "xs",
- "sm",
- "md",
- "lg",
- "xl",
- "2xl",
- "3xl",
- "4xl",
- "5xl",
- "6xl",
- "7xl",
- "8xl",
- "9xl",
- "1",
- "2",
- "3",
- "3.5",
- "4",
- "5",
- "6",
- "7",
- "8",
- "9",
- "10",
- "11",
- "12",
- "13",
- "14",
- "15",
- "16",
- "17",
- "18",
- "20",
- "24",
- "28",
- "32",
- "36",
- "40",
- "44",
- "48",
- "52",
- "56",
- "60",
- "64",
- "72",
- "80",
- "96",
-];
-
-export const mappedSpacingScaleKeys = spacingScaleKeys.map((key) => `unit-${key}`);
-
-export type SpacingScaleKeys = (typeof spacingScaleKeys)[number];
-
diff --git a/src/utils/utils.ts b/src/utils/utils.ts
deleted file mode 100644
index 0e06fd9..0000000
--- a/src/utils/utils.ts
+++ /dev/null
@@ -1,120 +0,0 @@
-import {tv as tvBase, TV} from "tailwind-variants";
-
-import {mappedSpacingScaleKeys} from "./types";
-
-export const mapPropsVariants = , K extends keyof T>(
- props: T,
- variantKeys?: K[],
- removeVariantProps = true,
-): readonly [Omit | T, Pick | {}] => {
- if (!variantKeys) {
- return [props, {}];
- }
-
- const picked = variantKeys.reduce((acc, key) => {
- // Only include the key in `picked` if it exists in `props`
- if (key in props) {
- return {...acc, [key]: props[key]};
- } else {
- return acc;
- }
- }, {});
-
- if (removeVariantProps) {
- const omitted = Object.keys(props)
- .filter((key) => !variantKeys.includes(key as K))
- .reduce((acc, key) => ({...acc, [key]: props[key as keyof T]}), {});
-
- return [omitted, picked] as [Omit, Pick];
- } else {
- return [props, picked] as [T, Pick];
- }
-};
-
-const COMMON_UNITS = ["small", "medium", "large"];
-
-export const tv: TV = (options, config) =>
- tvBase(options, {
- ...config,
- twMerge: config?.twMerge ?? true,
- twMergeConfig: {
- ...config?.twMergeConfig,
- theme: {
- ...config?.twMergeConfig?.theme,
- opacity: ["disabled"],
- spacing: ["divider", "unit", ...mappedSpacingScaleKeys],
- borderWidth: COMMON_UNITS,
- borderRadius: COMMON_UNITS,
- },
- classGroups: {
- ...config?.twMergeConfig?.classGroups,
- shadow: [{shadow: COMMON_UNITS}],
- "font-size": [{text: ["tiny", ...COMMON_UNITS]}],
- "bg-image": ["bg-stripe-gradient"],
- "min-w": [
- {
- "min-w": ["unit", ...mappedSpacingScaleKeys],
- },
- ],
- "min-h": [
- {
- "min-h": ["unit", ...mappedSpacingScaleKeys],
- },
- ],
- },
- },
- });
-
-/* eslint-disable no-shadow-restricted-names */
-/* eslint-disable no-plusplus */
-function toVal(mix: any) {
- var k,
- y,
- str = "";
-
- if (typeof mix === "string" || typeof mix === "number") {
- str += mix;
- } else if (typeof mix === "object") {
- if (Array.isArray(mix)) {
- for (k = 0; k < mix.length; k++) {
- if (mix[k]) {
- if ((y = toVal(mix[k]))) {
- str && (str += " ");
- str += y;
- }
- }
- }
- } else {
- for (k in mix) {
- if (mix[k]) {
- str && (str += " ");
- str += k;
- }
- }
- }
- }
-
- return str;
-}
-
-export function clsx(...args: any[]) {
- var i = 0,
- tmp,
- x,
- str = "";
-
- while (i < args.length) {
- if ((tmp = args[i++])) {
- if ((x = toVal(tmp))) {
- str && (str += " ");
- str += x;
- }
- }
- }
-
- return str;
-}
-
-type Booleanish = boolean | "true" | "false";
-export const dataAttr = (condition: boolean | undefined) =>
- (condition ? "true" : undefined) as Booleanish;
\ No newline at end of file
diff --git a/src/utils/worker.js b/src/utils/worker.js
deleted file mode 100644
index c836f86..0000000
--- a/src/utils/worker.js
+++ /dev/null
@@ -1,33 +0,0 @@
-import wasm_bindgen, { greet, compileCairoProgram, runCairoProgram, compileStarknetContract } from '@/pkg/wasm-cairo';
-
-const url = new URL('/wasm-cairo_bg.wasm', import.meta.url).href;
-
-(async () => {
- await wasm_bindgen(url)
-
- console.log(greet("StarknetAstro"))
-})();
-
-onmessage = function (e) {
- const { data, functionToRun, replaceIds } = e.data;
- wasm_bindgen(url).then(() => {
- let result;
- switch (functionToRun) {
- case "runCairoProgram":
- const { availableGas, printFullMemory, useDBGPrintHint } = e.data;
- result = runCairoProgram(data, availableGas, printFullMemory, useDBGPrintHint);
- break;
- case "compileCairoProgram":
- result = compileCairoProgram(data, replaceIds);
- break;
- case "compileStarknetContract":
- result = compileStarknetContract(data, replaceIds);
- break;
- default:
- console.error(`Unexpected function: ${functionToRun}`);
- return;
- }
- console.log("text: " + result)
- postMessage(result);
- });
-}
\ No newline at end of file
diff --git a/src/vite-env.d.ts b/src/vite-env.d.ts
deleted file mode 100644
index 11f02fe..0000000
--- a/src/vite-env.d.ts
+++ /dev/null
@@ -1 +0,0 @@
-///
diff --git a/tsconfig.json b/tsconfig.json
index aa55537..7b28589 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -1,28 +1,26 @@
{
"compilerOptions": {
- "target": "ES2020",
- "useDefineForClassFields": true,
- "lib": ["ES2020", "DOM", "DOM.Iterable"],
- "module": "ESNext",
+ "lib": ["dom", "dom.iterable", "esnext"],
+ "allowJs": true,
"skipLibCheck": true,
-
- /* Bundler mode */
+ "strict": true,
+ "noEmit": true,
+ "esModuleInterop": true,
+ "module": "esnext",
"moduleResolution": "bundler",
- "allowImportingTsExtensions": true,
"resolveJsonModule": true,
"isolatedModules": true,
- "noEmit": true,
- "jsx": "react-jsx",
-
- /* Linting */
- "strict": true,
- "noUnusedLocals": true,
- "noUnusedParameters": true,
- "noFallthroughCasesInSwitch": true,
+ "jsx": "preserve",
+ "incremental": true,
+ "plugins": [
+ {
+ "name": "next"
+ }
+ ],
"paths": {
"@/*": ["./src/*"]
}
},
- "include": ["src"],
- "references": [{ "path": "./tsconfig.node.json" }]
+ "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
+ "exclude": ["node_modules"]
}
diff --git a/vite.config.ts b/vite.config.ts
deleted file mode 100644
index 308b25b..0000000
--- a/vite.config.ts
+++ /dev/null
@@ -1,29 +0,0 @@
-import { defineConfig } from 'vite'
-import react from '@vitejs/plugin-react-swc'
-import path from "path";
-
-const wasmContentTypePlugin = {
- name: "wasm-content-type-plugin",
- configureServer(server) {
- server.middlewares.use((req, res, next) => {
- if (req.url.endsWith(".wasm")) {
- res.setHeader("Content-Type", "application/wasm");
- }
- next();
- });
- },
-};
-
-// https://vitejs.dev/config/
-export default defineConfig({
- plugins: [react(), wasmContentTypePlugin],
- build: {
- outDir: './docs'
- },
- resolve: {
- alias: {
- "@": path.resolve(__dirname, "./src"),
- },
- },
- base: './'
-})
diff --git a/worker.js b/worker.js
new file mode 100644
index 0000000..ed570be
--- /dev/null
+++ b/worker.js
@@ -0,0 +1,39 @@
+
+import wasmCairo, { compileStarknetContract, runTests, runCairoProgram, compileCairoProgram, greet } from 'wasm-cairo';
+
+
+(async () => {
+ await wasmCairo();
+ // await wasm_bindgen(url)
+
+ console.log(greet("StarknetAstro"))
+})();
+
+async function handleMessage (e) {
+ const {data, functionToRun, replaceIds} = e.data;
+ await wasmCairo();
+ let result;
+ console.log(e.data)
+ switch (functionToRun) {
+ case "runCairoProgram":
+ const {availableGas, printFullMemory, useDBGPrintHint} = e.data;
+ result = runCairoProgram(data, availableGas, true, printFullMemory, false, useDBGPrintHint);
+ break;
+ case "compileCairoProgram":
+ result = compileCairoProgram(data, replaceIds);
+ break;
+ case "compileStarknetContract":
+ result = compileStarknetContract(data, true, replaceIds);
+ break;
+ case "runTest":
+ result = runTests(data, true, false, true, true, false, false, true, true);
+ break;
+ default:
+ console.error(`Unexpected function: ${functionToRun}`);
+ return;
+ }
+ console.log("text: " + result)
+ postMessage(result);
+}
+
+addEventListener('message', handleMessage)
\ No newline at end of file