Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return Option from Execute Regex capture groups #501

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,4 @@ gitignore
Thumbs.db

tsconfig.tsbuildinfo
app.config.*.js
39 changes: 24 additions & 15 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions biome.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"dist",
"bindings.ts",
"rspc/types.ts",
"crates/regex-syntax-wasm/pkg",
"commands.ts"
]
},
Expand Down
13 changes: 13 additions & 0 deletions crates/regex-syntax-wasm/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[package]
name = "regex-syntax-wasm"
description = "A WebAssembly version of the regex-syntax crate"
version = "0.0.0"
edition = "2021"
publish = false

[lib]
crate-type = ["cdylib"]

[dependencies]
regex-syntax = "0.8.4"
wasm-bindgen = "0.2.93"
27 changes: 27 additions & 0 deletions crates/regex-syntax-wasm/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"name": "@macrograph/regex-syntax-wasm",
"description": "A WebAssembly version of the regex-syntax crate",
"version": "0.0.0",
"files": [
"./pkg/regex_syntax_wasm_bg.wasm",
"./pkg/regex_syntax_wasm.js",
"./pkg/regex_syntax_wasm_bg.js",
"./pkg/regex_syntax_wasm.d.ts"
],
"module": "./pkg/regex_syntax_wasm.js",
"types": "./pkg/regex_syntax_wasm.d.ts",
"sideEffects": ["./pkg/regex_syntax_wasm.js"],
"exports": {
".": {
"import": "./pkg/regex_syntax_wasm.js",
"require": "./pkg/regex_syntax_wasm.js"
},
"./regex_syntax_wasm_bg.wasm": {
"import": "./pkg/regex_syntax_wasm_bg.wasm",
"require": "./pkg/regex_syntax_wasm_bg.wasm"
}
},
"scripts": {
"build": "wasm-pack build --release --target web && rm ./pkg/.gitignore"
}
}
16 changes: 16 additions & 0 deletions crates/regex-syntax-wasm/pkg/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "regex-syntax-wasm",
"type": "module",
"description": "A WebAssembly version of the regex-syntax crate",
"version": "0.0.0",
"files": [
"regex_syntax_wasm_bg.wasm",
"regex_syntax_wasm.js",
"regex_syntax_wasm.d.ts"
],
"main": "regex_syntax_wasm.js",
"types": "regex_syntax_wasm.d.ts",
"sideEffects": [
"./snippets/*"
]
}
71 changes: 71 additions & 0 deletions crates/regex-syntax-wasm/pkg/regex_syntax_wasm.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
/* tslint:disable */
/* eslint-disable */
/**
* @param {string} regex
* @returns {CaptureScope}
*/
export function get_capture_groups(regex: string): CaptureScope;
/**
*/
export class CaptureGroup {
free(): void;
/**
* @returns {string}
*/
name(): string;
/**
* @returns {boolean}
*/
optional(): boolean;
}
/**
*/
export class CaptureScope {
free(): void;
/**
* @returns {(CaptureScope)[]}
*/
scope(): (CaptureScope)[];
/**
* @returns {CaptureGroup | undefined}
*/
capture(): CaptureGroup | undefined;
}

export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;

export interface InitOutput {
readonly memory: WebAssembly.Memory;
readonly get_capture_groups: (a: number, b: number, c: number) => void;
readonly __wbg_capturescope_free: (a: number, b: number) => void;
readonly capturescope_scope: (a: number, b: number) => void;
readonly capturescope_capture: (a: number) => number;
readonly __wbg_capturegroup_free: (a: number, b: number) => void;
readonly capturegroup_name: (a: number, b: number) => void;
readonly capturegroup_optional: (a: number) => number;
readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
readonly __wbindgen_malloc: (a: number, b: number) => number;
readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
readonly __wbindgen_free: (a: number, b: number, c: number) => void;
}

export type SyncInitInput = BufferSource | WebAssembly.Module;
/**
* Instantiates the given `module`, which can either be bytes or
* a precompiled `WebAssembly.Module`.
*
* @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
*
* @returns {InitOutput}
*/
export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;

/**
* If `module_or_path` is {RequestInfo} or {URL}, makes a request and
* for everything else, calls `WebAssembly.instantiate` directly.
*
* @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
*
* @returns {Promise<InitOutput>}
*/
export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
Loading
Loading