mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-04-21 08:11:24 +02:00
[WIP] Refactor to NPM workspaces (#104)
This commit is contained in:
9
src-tauri/yaak_templates/bindings/parser.ts
Normal file
9
src-tauri/yaak_templates/bindings/parser.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
|
||||
|
||||
export type FnArg = { name: string, value: Val, };
|
||||
|
||||
export type Token = { "type": "raw", text: string, } | { "type": "tag", val: Val, } | { "type": "eof" };
|
||||
|
||||
export type Tokens = { tokens: Array<Token>, };
|
||||
|
||||
export type Val = { "type": "str", text: string, } | { "type": "var", name: string, } | { "type": "bool", value: boolean, } | { "type": "fn", name: string, args: Array<FnArg>, } | { "type": "null" };
|
||||
@@ -1,6 +0,0 @@
|
||||
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
// Tell ts-rs where to generate types to
|
||||
println!("cargo:rustc-env=TS_RS_EXPORT_DIR=../../src-web/gen");
|
||||
|
||||
Ok(())
|
||||
}
|
||||
1
src-tauri/yaak_templates/index.ts
Normal file
1
src-tauri/yaak_templates/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
export * from './bindings/parser';
|
||||
32
src-tauri/yaak_templates/lib/bindings/parser.d.ts
vendored
Normal file
32
src-tauri/yaak_templates/lib/bindings/parser.d.ts
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
export type FnArg = {
|
||||
name: string;
|
||||
value: Val;
|
||||
};
|
||||
export type Token = {
|
||||
"type": "raw";
|
||||
text: string;
|
||||
} | {
|
||||
"type": "tag";
|
||||
val: Val;
|
||||
} | {
|
||||
"type": "eof";
|
||||
};
|
||||
export type Tokens = {
|
||||
tokens: Array<Token>;
|
||||
};
|
||||
export type Val = {
|
||||
"type": "str";
|
||||
text: string;
|
||||
} | {
|
||||
"type": "var";
|
||||
name: string;
|
||||
} | {
|
||||
"type": "bool";
|
||||
value: boolean;
|
||||
} | {
|
||||
"type": "fn";
|
||||
name: string;
|
||||
args: Array<FnArg>;
|
||||
} | {
|
||||
"type": "null";
|
||||
};
|
||||
3
src-tauri/yaak_templates/lib/bindings/parser.js
Normal file
3
src-tauri/yaak_templates/lib/bindings/parser.js
Normal file
@@ -0,0 +1,3 @@
|
||||
"use strict";
|
||||
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
1
src-tauri/yaak_templates/lib/index.d.ts
vendored
Normal file
1
src-tauri/yaak_templates/lib/index.d.ts
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export * from './bindings/parser';
|
||||
17
src-tauri/yaak_templates/lib/index.js
Normal file
17
src-tauri/yaak_templates/lib/index.js
Normal file
@@ -0,0 +1,17 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
||||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
__exportStar(require("./bindings/parser"), exports);
|
||||
10
src-tauri/yaak_templates/package.json
Normal file
10
src-tauri/yaak_templates/package.json
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"name": "@yaakapp-internal/template",
|
||||
"private": true,
|
||||
"version": "1.0.0",
|
||||
"main": "lib/index.js",
|
||||
"typings": "./lib/index.d.ts",
|
||||
"scripts": {
|
||||
"build": "tsc"
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,7 @@ use std::fmt::Display;
|
||||
use ts_rs::TS;
|
||||
|
||||
#[derive(Clone, PartialEq, Debug, Serialize, Deserialize, TS)]
|
||||
#[ts(export)]
|
||||
#[ts(export, export_to="parser.ts")]
|
||||
pub struct Tokens {
|
||||
pub tokens: Vec<Token>,
|
||||
}
|
||||
@@ -21,7 +21,7 @@ impl Display for Tokens {
|
||||
}
|
||||
|
||||
#[derive(Clone, PartialEq, Debug, Serialize, Deserialize, TS)]
|
||||
#[ts(export)]
|
||||
#[ts(export, export_to="parser.ts")]
|
||||
pub struct FnArg {
|
||||
pub name: String,
|
||||
pub value: Val,
|
||||
@@ -36,7 +36,7 @@ impl Display for FnArg {
|
||||
|
||||
#[derive(Clone, PartialEq, Debug, Serialize, Deserialize, TS)]
|
||||
#[serde(rename_all = "snake_case", tag = "type")]
|
||||
#[ts(export)]
|
||||
#[ts(export, export_to="parser.ts")]
|
||||
pub enum Val {
|
||||
Str { text: String },
|
||||
Var { name: String },
|
||||
@@ -71,7 +71,7 @@ impl Display for Val {
|
||||
|
||||
#[derive(Clone, PartialEq, Debug, Serialize, Deserialize, TS)]
|
||||
#[serde(rename_all = "snake_case", tag = "type")]
|
||||
#[ts(export)]
|
||||
#[ts(export, export_to="parser.ts")]
|
||||
pub enum Token {
|
||||
Raw { text: String },
|
||||
Tag { val: Val },
|
||||
@@ -292,7 +292,7 @@ impl Parser {
|
||||
|
||||
Some(text)
|
||||
}
|
||||
|
||||
|
||||
fn parse_fn_name(&mut self) -> Option<String> {
|
||||
let start_pos = self.pos;
|
||||
|
||||
@@ -512,7 +512,7 @@ mod tests {
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
#[test]
|
||||
fn fn_dot_name() {
|
||||
let mut p = Parser::new("${[ foo.bar.baz() ]}");
|
||||
|
||||
15
src-tauri/yaak_templates/tsconfig.json
Normal file
15
src-tauri/yaak_templates/tsconfig.json
Normal file
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "node16",
|
||||
"target": "es6",
|
||||
"lib": ["es2021"],
|
||||
"declaration": true,
|
||||
"declarationDir": "./lib",
|
||||
"outDir": "./lib",
|
||||
"strict": true,
|
||||
"types": ["node"]
|
||||
},
|
||||
"files": [
|
||||
"index.ts"
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user