[WIP] Refactor to NPM workspaces (#104)

This commit is contained in:
Gregory Schier
2024-09-22 21:27:10 -07:00
committed by GitHub
parent 93633875ac
commit 101b6284d6
176 changed files with 1983 additions and 1249 deletions

View 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" };

View File

@@ -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(())
}

View File

@@ -0,0 +1 @@
export * from './bindings/parser';

View 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";
};

View 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 });

View File

@@ -0,0 +1 @@
export * from './bindings/parser';

View 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);

View 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"
}
}

View File

@@ -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() ]}");

View 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"
]
}