toml | eslint | esm

This commit is contained in:
Code 2025-01-28 13:42:22 +01:00
parent d1e4e0abd6
commit ce12be9ea3
300 changed files with 26808 additions and 27292 deletions

View File

@ -1,378 +1,378 @@
import { z } from "zod";
export declare const AuthorSchema: z.ZodObject<{
name: z.ZodString;
url: z.ZodString;
}, "strip", z.ZodTypeAny, {
name?: string;
url?: string;
}, {
name?: string;
url?: string;
}>;
export declare const ContentSchema: z.ZodObject<{
body: z.ZodOptional<z.ZodString>;
features: z.ZodOptional<z.ZodString>;
highlights: z.ZodOptional<z.ZodString>;
specs: z.ZodOptional<z.ZodString>;
license: z.ZodOptional<z.ZodString>;
}, "strip", z.ZodTypeAny, {
body?: string;
features?: string;
highlights?: string;
specs?: string;
license?: string;
}, {
body?: string;
features?: string;
highlights?: string;
specs?: string;
license?: string;
}>;
export declare const AssetsSchema: z.ZodObject<{
gallery: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
renderings: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
components: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
}, "strip", z.ZodTypeAny, {
gallery?: string[];
renderings?: string[];
components?: string[];
}, {
gallery?: string[];
renderings?: string[];
components?: string[];
}>;
export declare const ProductionSchema: z.ZodObject<{
"fusion-folder": z.ZodString;
"nc-folder": z.ZodString;
cam: z.ZodArray<z.ZodObject<{
name: z.ZodString;
url: z.ZodString;
}, "strip", z.ZodTypeAny, {
name?: string;
url?: string;
}, {
name?: string;
url?: string;
}>, "many">;
}, "strip", z.ZodTypeAny, {
"fusion-folder"?: string;
"nc-folder"?: string;
cam?: {
name?: string;
url?: string;
}[];
}, {
"fusion-folder"?: string;
"nc-folder"?: string;
cam?: {
name?: string;
url?: string;
}[];
}>;
export declare const ComponentConfigSchema: z.ZodObject<{
cart_id: z.ZodOptional<z.ZodString>;
code: z.ZodString;
price: z.ZodOptional<z.ZodNumber>;
cscartCats: z.ZodOptional<z.ZodArray<z.ZodNumber, "many">>;
cscartId: z.ZodOptional<z.ZodNumber>;
vendorId: z.ZodOptional<z.ZodNumber>;
version: z.ZodOptional<z.ZodString>;
status: z.ZodOptional<z.ZodString>;
authors: z.ZodOptional<z.ZodArray<z.ZodObject<{
name: z.ZodString;
url: z.ZodString;
}, "strip", z.ZodTypeAny, {
name?: string;
url?: string;
}, {
name?: string;
url?: string;
}>, "many">>;
replaced_by: z.ZodOptional<z.ZodString>;
alternatives: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
flags: z.ZodOptional<z.ZodNumber>;
download: z.ZodOptional<z.ZodBoolean>;
name: z.ZodString;
edrawings: z.ZodOptional<z.ZodString>;
showDimensions: z.ZodOptional<z.ZodBoolean>;
showParts: z.ZodOptional<z.ZodBoolean>;
slug: z.ZodString;
score: z.ZodOptional<z.ZodNumber>;
Preview3d: z.ZodOptional<z.ZodBoolean>;
keywords: z.ZodOptional<z.ZodString>;
meta_keywords: z.ZodOptional<z.ZodString>;
content: z.ZodOptional<z.ZodObject<{
body: z.ZodOptional<z.ZodString>;
features: z.ZodOptional<z.ZodString>;
highlights: z.ZodOptional<z.ZodString>;
specs: z.ZodOptional<z.ZodString>;
license: z.ZodOptional<z.ZodString>;
}, "strip", z.ZodTypeAny, {
body?: string;
features?: string;
highlights?: string;
specs?: string;
license?: string;
}, {
body?: string;
features?: string;
highlights?: string;
specs?: string;
license?: string;
}>>;
assets: z.ZodOptional<z.ZodObject<{
gallery: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
renderings: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
components: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
}, "strip", z.ZodTypeAny, {
gallery?: string[];
renderings?: string[];
components?: string[];
}, {
gallery?: string[];
renderings?: string[];
components?: string[];
}>>;
/**
* @deprecated
*/
howto_categories: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
steps: z.ZodOptional<z.ZodAny>;
sourceLanguage: z.ZodOptional<z.ZodString>;
category: z.ZodString;
product_dimensions: z.ZodOptional<z.ZodString>;
production: z.ZodOptional<z.ZodObject<{
"fusion-folder": z.ZodString;
"nc-folder": z.ZodString;
cam: z.ZodArray<z.ZodObject<{
name: z.ZodString;
url: z.ZodString;
}, "strip", z.ZodTypeAny, {
name?: string;
url?: string;
}, {
name?: string;
url?: string;
}>, "many">;
}, "strip", z.ZodTypeAny, {
"fusion-folder"?: string;
"nc-folder"?: string;
cam?: {
name?: string;
url?: string;
}[];
}, {
"fusion-folder"?: string;
"nc-folder"?: string;
cam?: {
name?: string;
url?: string;
}[];
}>>;
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
cart_id: z.ZodOptional<z.ZodString>;
code: z.ZodString;
price: z.ZodOptional<z.ZodNumber>;
cscartCats: z.ZodOptional<z.ZodArray<z.ZodNumber, "many">>;
cscartId: z.ZodOptional<z.ZodNumber>;
vendorId: z.ZodOptional<z.ZodNumber>;
version: z.ZodOptional<z.ZodString>;
status: z.ZodOptional<z.ZodString>;
authors: z.ZodOptional<z.ZodArray<z.ZodObject<{
name: z.ZodString;
url: z.ZodString;
}, "strip", z.ZodTypeAny, {
name?: string;
url?: string;
}, {
name?: string;
url?: string;
}>, "many">>;
replaced_by: z.ZodOptional<z.ZodString>;
alternatives: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
flags: z.ZodOptional<z.ZodNumber>;
download: z.ZodOptional<z.ZodBoolean>;
name: z.ZodString;
edrawings: z.ZodOptional<z.ZodString>;
showDimensions: z.ZodOptional<z.ZodBoolean>;
showParts: z.ZodOptional<z.ZodBoolean>;
slug: z.ZodString;
score: z.ZodOptional<z.ZodNumber>;
Preview3d: z.ZodOptional<z.ZodBoolean>;
keywords: z.ZodOptional<z.ZodString>;
meta_keywords: z.ZodOptional<z.ZodString>;
content: z.ZodOptional<z.ZodObject<{
body: z.ZodOptional<z.ZodString>;
features: z.ZodOptional<z.ZodString>;
highlights: z.ZodOptional<z.ZodString>;
specs: z.ZodOptional<z.ZodString>;
license: z.ZodOptional<z.ZodString>;
}, "strip", z.ZodTypeAny, {
body?: string;
features?: string;
highlights?: string;
specs?: string;
license?: string;
}, {
body?: string;
features?: string;
highlights?: string;
specs?: string;
license?: string;
}>>;
assets: z.ZodOptional<z.ZodObject<{
gallery: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
renderings: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
components: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
}, "strip", z.ZodTypeAny, {
gallery?: string[];
renderings?: string[];
components?: string[];
}, {
gallery?: string[];
renderings?: string[];
components?: string[];
}>>;
/**
* @deprecated
*/
howto_categories: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
steps: z.ZodOptional<z.ZodAny>;
sourceLanguage: z.ZodOptional<z.ZodString>;
category: z.ZodString;
product_dimensions: z.ZodOptional<z.ZodString>;
production: z.ZodOptional<z.ZodObject<{
"fusion-folder": z.ZodString;
"nc-folder": z.ZodString;
cam: z.ZodArray<z.ZodObject<{
name: z.ZodString;
url: z.ZodString;
}, "strip", z.ZodTypeAny, {
name?: string;
url?: string;
}, {
name?: string;
url?: string;
}>, "many">;
}, "strip", z.ZodTypeAny, {
"fusion-folder"?: string;
"nc-folder"?: string;
cam?: {
name?: string;
url?: string;
}[];
}, {
"fusion-folder"?: string;
"nc-folder"?: string;
cam?: {
name?: string;
url?: string;
}[];
}>>;
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
cart_id: z.ZodOptional<z.ZodString>;
code: z.ZodString;
price: z.ZodOptional<z.ZodNumber>;
cscartCats: z.ZodOptional<z.ZodArray<z.ZodNumber, "many">>;
cscartId: z.ZodOptional<z.ZodNumber>;
vendorId: z.ZodOptional<z.ZodNumber>;
version: z.ZodOptional<z.ZodString>;
status: z.ZodOptional<z.ZodString>;
authors: z.ZodOptional<z.ZodArray<z.ZodObject<{
name: z.ZodString;
url: z.ZodString;
}, "strip", z.ZodTypeAny, {
name?: string;
url?: string;
}, {
name?: string;
url?: string;
}>, "many">>;
replaced_by: z.ZodOptional<z.ZodString>;
alternatives: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
flags: z.ZodOptional<z.ZodNumber>;
download: z.ZodOptional<z.ZodBoolean>;
name: z.ZodString;
edrawings: z.ZodOptional<z.ZodString>;
showDimensions: z.ZodOptional<z.ZodBoolean>;
showParts: z.ZodOptional<z.ZodBoolean>;
slug: z.ZodString;
score: z.ZodOptional<z.ZodNumber>;
Preview3d: z.ZodOptional<z.ZodBoolean>;
keywords: z.ZodOptional<z.ZodString>;
meta_keywords: z.ZodOptional<z.ZodString>;
content: z.ZodOptional<z.ZodObject<{
body: z.ZodOptional<z.ZodString>;
features: z.ZodOptional<z.ZodString>;
highlights: z.ZodOptional<z.ZodString>;
specs: z.ZodOptional<z.ZodString>;
license: z.ZodOptional<z.ZodString>;
}, "strip", z.ZodTypeAny, {
body?: string;
features?: string;
highlights?: string;
specs?: string;
license?: string;
}, {
body?: string;
features?: string;
highlights?: string;
specs?: string;
license?: string;
}>>;
assets: z.ZodOptional<z.ZodObject<{
gallery: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
renderings: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
components: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
}, "strip", z.ZodTypeAny, {
gallery?: string[];
renderings?: string[];
components?: string[];
}, {
gallery?: string[];
renderings?: string[];
components?: string[];
}>>;
/**
* @deprecated
*/
howto_categories: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
steps: z.ZodOptional<z.ZodAny>;
sourceLanguage: z.ZodOptional<z.ZodString>;
category: z.ZodString;
product_dimensions: z.ZodOptional<z.ZodString>;
production: z.ZodOptional<z.ZodObject<{
"fusion-folder": z.ZodString;
"nc-folder": z.ZodString;
cam: z.ZodArray<z.ZodObject<{
name: z.ZodString;
url: z.ZodString;
}, "strip", z.ZodTypeAny, {
name?: string;
url?: string;
}, {
name?: string;
url?: string;
}>, "many">;
}, "strip", z.ZodTypeAny, {
"fusion-folder"?: string;
"nc-folder"?: string;
cam?: {
name?: string;
url?: string;
}[];
}, {
"fusion-folder"?: string;
"nc-folder"?: string;
cam?: {
name?: string;
url?: string;
}[];
}>>;
}, z.ZodTypeAny, "passthrough">>;
export type IComponentConfig = z.infer<typeof ComponentConfigSchema>;
export declare const get: (src: any, root: any, type: any) => {
rel: any;
path: any;
config: any;
}[];
import { z } from "zod";
export declare const AuthorSchema: z.ZodObject<{
name: z.ZodString;
url: z.ZodString;
}, "strip", z.ZodTypeAny, {
name?: string;
url?: string;
}, {
name?: string;
url?: string;
}>;
export declare const ContentSchema: z.ZodObject<{
body: z.ZodOptional<z.ZodString>;
features: z.ZodOptional<z.ZodString>;
highlights: z.ZodOptional<z.ZodString>;
specs: z.ZodOptional<z.ZodString>;
license: z.ZodOptional<z.ZodString>;
}, "strip", z.ZodTypeAny, {
body?: string;
features?: string;
highlights?: string;
specs?: string;
license?: string;
}, {
body?: string;
features?: string;
highlights?: string;
specs?: string;
license?: string;
}>;
export declare const AssetsSchema: z.ZodObject<{
gallery: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
renderings: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
components: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
}, "strip", z.ZodTypeAny, {
gallery?: string[];
renderings?: string[];
components?: string[];
}, {
gallery?: string[];
renderings?: string[];
components?: string[];
}>;
export declare const ProductionSchema: z.ZodObject<{
"fusion-folder": z.ZodString;
"nc-folder": z.ZodString;
cam: z.ZodArray<z.ZodObject<{
name: z.ZodString;
url: z.ZodString;
}, "strip", z.ZodTypeAny, {
name?: string;
url?: string;
}, {
name?: string;
url?: string;
}>, "many">;
}, "strip", z.ZodTypeAny, {
"fusion-folder"?: string;
"nc-folder"?: string;
cam?: {
name?: string;
url?: string;
}[];
}, {
"fusion-folder"?: string;
"nc-folder"?: string;
cam?: {
name?: string;
url?: string;
}[];
}>;
export declare const ComponentConfigSchema: z.ZodObject<{
cart_id: z.ZodOptional<z.ZodString>;
code: z.ZodString;
price: z.ZodOptional<z.ZodNumber>;
cscartCats: z.ZodOptional<z.ZodArray<z.ZodNumber, "many">>;
cscartId: z.ZodOptional<z.ZodNumber>;
vendorId: z.ZodOptional<z.ZodNumber>;
version: z.ZodOptional<z.ZodString>;
status: z.ZodOptional<z.ZodString>;
authors: z.ZodOptional<z.ZodArray<z.ZodObject<{
name: z.ZodString;
url: z.ZodString;
}, "strip", z.ZodTypeAny, {
name?: string;
url?: string;
}, {
name?: string;
url?: string;
}>, "many">>;
replaced_by: z.ZodOptional<z.ZodString>;
alternatives: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
flags: z.ZodOptional<z.ZodNumber>;
download: z.ZodOptional<z.ZodBoolean>;
name: z.ZodString;
edrawings: z.ZodOptional<z.ZodString>;
showDimensions: z.ZodOptional<z.ZodBoolean>;
showParts: z.ZodOptional<z.ZodBoolean>;
slug: z.ZodString;
score: z.ZodOptional<z.ZodNumber>;
Preview3d: z.ZodOptional<z.ZodBoolean>;
keywords: z.ZodOptional<z.ZodString>;
meta_keywords: z.ZodOptional<z.ZodString>;
content: z.ZodOptional<z.ZodObject<{
body: z.ZodOptional<z.ZodString>;
features: z.ZodOptional<z.ZodString>;
highlights: z.ZodOptional<z.ZodString>;
specs: z.ZodOptional<z.ZodString>;
license: z.ZodOptional<z.ZodString>;
}, "strip", z.ZodTypeAny, {
body?: string;
features?: string;
highlights?: string;
specs?: string;
license?: string;
}, {
body?: string;
features?: string;
highlights?: string;
specs?: string;
license?: string;
}>>;
assets: z.ZodOptional<z.ZodObject<{
gallery: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
renderings: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
components: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
}, "strip", z.ZodTypeAny, {
gallery?: string[];
renderings?: string[];
components?: string[];
}, {
gallery?: string[];
renderings?: string[];
components?: string[];
}>>;
/**
* @deprecated
*/
howto_categories: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
steps: z.ZodOptional<z.ZodAny>;
sourceLanguage: z.ZodOptional<z.ZodString>;
category: z.ZodString;
product_dimensions: z.ZodOptional<z.ZodString>;
production: z.ZodOptional<z.ZodObject<{
"fusion-folder": z.ZodString;
"nc-folder": z.ZodString;
cam: z.ZodArray<z.ZodObject<{
name: z.ZodString;
url: z.ZodString;
}, "strip", z.ZodTypeAny, {
name?: string;
url?: string;
}, {
name?: string;
url?: string;
}>, "many">;
}, "strip", z.ZodTypeAny, {
"fusion-folder"?: string;
"nc-folder"?: string;
cam?: {
name?: string;
url?: string;
}[];
}, {
"fusion-folder"?: string;
"nc-folder"?: string;
cam?: {
name?: string;
url?: string;
}[];
}>>;
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
cart_id: z.ZodOptional<z.ZodString>;
code: z.ZodString;
price: z.ZodOptional<z.ZodNumber>;
cscartCats: z.ZodOptional<z.ZodArray<z.ZodNumber, "many">>;
cscartId: z.ZodOptional<z.ZodNumber>;
vendorId: z.ZodOptional<z.ZodNumber>;
version: z.ZodOptional<z.ZodString>;
status: z.ZodOptional<z.ZodString>;
authors: z.ZodOptional<z.ZodArray<z.ZodObject<{
name: z.ZodString;
url: z.ZodString;
}, "strip", z.ZodTypeAny, {
name?: string;
url?: string;
}, {
name?: string;
url?: string;
}>, "many">>;
replaced_by: z.ZodOptional<z.ZodString>;
alternatives: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
flags: z.ZodOptional<z.ZodNumber>;
download: z.ZodOptional<z.ZodBoolean>;
name: z.ZodString;
edrawings: z.ZodOptional<z.ZodString>;
showDimensions: z.ZodOptional<z.ZodBoolean>;
showParts: z.ZodOptional<z.ZodBoolean>;
slug: z.ZodString;
score: z.ZodOptional<z.ZodNumber>;
Preview3d: z.ZodOptional<z.ZodBoolean>;
keywords: z.ZodOptional<z.ZodString>;
meta_keywords: z.ZodOptional<z.ZodString>;
content: z.ZodOptional<z.ZodObject<{
body: z.ZodOptional<z.ZodString>;
features: z.ZodOptional<z.ZodString>;
highlights: z.ZodOptional<z.ZodString>;
specs: z.ZodOptional<z.ZodString>;
license: z.ZodOptional<z.ZodString>;
}, "strip", z.ZodTypeAny, {
body?: string;
features?: string;
highlights?: string;
specs?: string;
license?: string;
}, {
body?: string;
features?: string;
highlights?: string;
specs?: string;
license?: string;
}>>;
assets: z.ZodOptional<z.ZodObject<{
gallery: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
renderings: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
components: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
}, "strip", z.ZodTypeAny, {
gallery?: string[];
renderings?: string[];
components?: string[];
}, {
gallery?: string[];
renderings?: string[];
components?: string[];
}>>;
/**
* @deprecated
*/
howto_categories: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
steps: z.ZodOptional<z.ZodAny>;
sourceLanguage: z.ZodOptional<z.ZodString>;
category: z.ZodString;
product_dimensions: z.ZodOptional<z.ZodString>;
production: z.ZodOptional<z.ZodObject<{
"fusion-folder": z.ZodString;
"nc-folder": z.ZodString;
cam: z.ZodArray<z.ZodObject<{
name: z.ZodString;
url: z.ZodString;
}, "strip", z.ZodTypeAny, {
name?: string;
url?: string;
}, {
name?: string;
url?: string;
}>, "many">;
}, "strip", z.ZodTypeAny, {
"fusion-folder"?: string;
"nc-folder"?: string;
cam?: {
name?: string;
url?: string;
}[];
}, {
"fusion-folder"?: string;
"nc-folder"?: string;
cam?: {
name?: string;
url?: string;
}[];
}>>;
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
cart_id: z.ZodOptional<z.ZodString>;
code: z.ZodString;
price: z.ZodOptional<z.ZodNumber>;
cscartCats: z.ZodOptional<z.ZodArray<z.ZodNumber, "many">>;
cscartId: z.ZodOptional<z.ZodNumber>;
vendorId: z.ZodOptional<z.ZodNumber>;
version: z.ZodOptional<z.ZodString>;
status: z.ZodOptional<z.ZodString>;
authors: z.ZodOptional<z.ZodArray<z.ZodObject<{
name: z.ZodString;
url: z.ZodString;
}, "strip", z.ZodTypeAny, {
name?: string;
url?: string;
}, {
name?: string;
url?: string;
}>, "many">>;
replaced_by: z.ZodOptional<z.ZodString>;
alternatives: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
flags: z.ZodOptional<z.ZodNumber>;
download: z.ZodOptional<z.ZodBoolean>;
name: z.ZodString;
edrawings: z.ZodOptional<z.ZodString>;
showDimensions: z.ZodOptional<z.ZodBoolean>;
showParts: z.ZodOptional<z.ZodBoolean>;
slug: z.ZodString;
score: z.ZodOptional<z.ZodNumber>;
Preview3d: z.ZodOptional<z.ZodBoolean>;
keywords: z.ZodOptional<z.ZodString>;
meta_keywords: z.ZodOptional<z.ZodString>;
content: z.ZodOptional<z.ZodObject<{
body: z.ZodOptional<z.ZodString>;
features: z.ZodOptional<z.ZodString>;
highlights: z.ZodOptional<z.ZodString>;
specs: z.ZodOptional<z.ZodString>;
license: z.ZodOptional<z.ZodString>;
}, "strip", z.ZodTypeAny, {
body?: string;
features?: string;
highlights?: string;
specs?: string;
license?: string;
}, {
body?: string;
features?: string;
highlights?: string;
specs?: string;
license?: string;
}>>;
assets: z.ZodOptional<z.ZodObject<{
gallery: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
renderings: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
components: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
}, "strip", z.ZodTypeAny, {
gallery?: string[];
renderings?: string[];
components?: string[];
}, {
gallery?: string[];
renderings?: string[];
components?: string[];
}>>;
/**
* @deprecated
*/
howto_categories: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
steps: z.ZodOptional<z.ZodAny>;
sourceLanguage: z.ZodOptional<z.ZodString>;
category: z.ZodString;
product_dimensions: z.ZodOptional<z.ZodString>;
production: z.ZodOptional<z.ZodObject<{
"fusion-folder": z.ZodString;
"nc-folder": z.ZodString;
cam: z.ZodArray<z.ZodObject<{
name: z.ZodString;
url: z.ZodString;
}, "strip", z.ZodTypeAny, {
name?: string;
url?: string;
}, {
name?: string;
url?: string;
}>, "many">;
}, "strip", z.ZodTypeAny, {
"fusion-folder"?: string;
"nc-folder"?: string;
cam?: {
name?: string;
url?: string;
}[];
}, {
"fusion-folder"?: string;
"nc-folder"?: string;
cam?: {
name?: string;
url?: string;
}[];
}>>;
}, z.ZodTypeAny, "passthrough">>;
export type IComponentConfig = z.infer<typeof ComponentConfigSchema>;
export declare const get: (src: any, root: any, type: any) => {
rel: any;
path: any;
config: any;
}[];

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,138 +1,42 @@
export declare const HOME: (sub?: string) => string;
export declare const get_var: (key?: string) => string;
export declare const OSR_ROOT: (key?: string) => string;
export declare const OSR_SUB_DEFAULT: (key?: string) => string;
export declare const CONFIG_DEFAULT_PATH: (key?: string) => string;
export declare const OSR_TEMP: (key?: string) => string;
export declare const OSR_CACHE: (key?: string) => string;
export declare const OSR_PRIVATE: (key?: string) => string;
export declare const KB_ROOT: (key?: string) => string;
export declare const OSR_LIBRARY: (key?: string) => string;
export declare const OSR_LIBRARY_MACHINES: (key?: string) => string;
export declare const OSR_LIBRARY_DIRECTORY: (key?: string) => string;
export declare const PRODUCT_ROOT: (key?: string) => string;
export declare const OSR_CUSTOMER_DRIVE: (key?: string) => string;
export declare const OA_ROOT: (key?: string) => string;
export declare const OSR_USER_ASSETS: (key?: string) => string;
export declare const POLYMECH_ROOT: (key?: string) => string;
export declare const DEFAULT_ROOTS: {
OSR_ROOT: string;
OSR_TEMP: string;
PRODUCT_ROOT: string;
OA_ROOT: string;
KB_ROOT: string;
OSR_CACHE: string;
OSR_LIBRARY: string;
OSR_LIBRARY_MACHINES: string;
OSR_LIBRARY_DIRECTORY: string;
OSR_USER_ASSETS: string;
OSR_PRIVATE: string;
OSR_TEMPLATES: string;
OSR_CONTENT: string;
OSR_PROFILES: string;
OSR_CUSTOMER_DRIVE: string;
POLYMECH_ROOT: string;
};
export declare const CONFIG_DEFAULT: (key?: string) => string | false | object;
import { JSONSchemaForNPMPackageJsonFiles } from '@schemastore/package';
export declare const readNPMMeta: (_path: string) => JSONSchemaForNPMPackageJsonFiles;
export declare const readPackage: (val: any) => JSONSchemaForNPMPackageJsonFiles;
export declare const readOSRMeta: (_path: string) => import("zod").objectOutputType<{
cart_id: import("zod").ZodOptional<import("zod").ZodString>;
code: import("zod").ZodString;
price: import("zod").ZodOptional<import("zod").ZodNumber>;
cscartCats: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodNumber, "many">>;
cscartId: import("zod").ZodOptional<import("zod").ZodNumber>;
vendorId: import("zod").ZodOptional<import("zod").ZodNumber>;
version: import("zod").ZodOptional<import("zod").ZodString>;
status: import("zod").ZodOptional<import("zod").ZodString>;
authors: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodObject<{
name: import("zod").ZodString;
url: import("zod").ZodString;
}, "strip", import("zod").ZodTypeAny, {
name?: string;
url?: string;
}, {
name?: string;
url?: string;
}>, "many">>;
replaced_by: import("zod").ZodOptional<import("zod").ZodString>;
alternatives: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodString, "many">>;
flags: import("zod").ZodOptional<import("zod").ZodNumber>;
download: import("zod").ZodOptional<import("zod").ZodBoolean>;
name: import("zod").ZodString;
edrawings: import("zod").ZodOptional<import("zod").ZodString>;
showDimensions: import("zod").ZodOptional<import("zod").ZodBoolean>;
showParts: import("zod").ZodOptional<import("zod").ZodBoolean>;
slug: import("zod").ZodString;
score: import("zod").ZodOptional<import("zod").ZodNumber>;
Preview3d: import("zod").ZodOptional<import("zod").ZodBoolean>;
keywords: import("zod").ZodOptional<import("zod").ZodString>;
meta_keywords: import("zod").ZodOptional<import("zod").ZodString>;
content: import("zod").ZodOptional<import("zod").ZodObject<{
body: import("zod").ZodOptional<import("zod").ZodString>;
features: import("zod").ZodOptional<import("zod").ZodString>;
highlights: import("zod").ZodOptional<import("zod").ZodString>;
specs: import("zod").ZodOptional<import("zod").ZodString>;
license: import("zod").ZodOptional<import("zod").ZodString>;
}, "strip", import("zod").ZodTypeAny, {
body?: string;
features?: string;
highlights?: string;
specs?: string;
license?: string;
}, {
body?: string;
features?: string;
highlights?: string;
specs?: string;
license?: string;
}>>;
assets: import("zod").ZodOptional<import("zod").ZodObject<{
gallery: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodString, "many">>;
renderings: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodString, "many">>;
components: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodString, "many">>;
}, "strip", import("zod").ZodTypeAny, {
gallery?: string[];
renderings?: string[];
components?: string[];
}, {
gallery?: string[];
renderings?: string[];
components?: string[];
}>>;
howto_categories: import("zod").ZodOptional<import("zod").ZodUnion<[import("zod").ZodString, import("zod").ZodArray<import("zod").ZodString, "many">]>>;
steps: import("zod").ZodOptional<import("zod").ZodAny>;
sourceLanguage: import("zod").ZodOptional<import("zod").ZodString>;
category: import("zod").ZodString;
product_dimensions: import("zod").ZodOptional<import("zod").ZodString>;
production: import("zod").ZodOptional<import("zod").ZodObject<{
"fusion-folder": import("zod").ZodString;
"nc-folder": import("zod").ZodString;
cam: import("zod").ZodArray<import("zod").ZodObject<{
name: import("zod").ZodString;
url: import("zod").ZodString;
}, "strip", import("zod").ZodTypeAny, {
name?: string;
url?: string;
}, {
name?: string;
url?: string;
}>, "many">;
}, "strip", import("zod").ZodTypeAny, {
"fusion-folder"?: string;
"nc-folder"?: string;
cam?: {
name?: string;
url?: string;
}[];
}, {
"fusion-folder"?: string;
"nc-folder"?: string;
cam?: {
name?: string;
url?: string;
}[];
}>>;
}, import("zod").ZodTypeAny, "passthrough">;
export declare const readOSRConfig: (val: any) => any;
export declare const HOME: (sub?: string) => string;
export declare const get_var: (key?: string) => string;
export declare const OSR_ROOT: (key?: string) => string;
export declare const OSR_SUB_DEFAULT: (key?: string) => string;
export declare const CONFIG_DEFAULT_PATH: (key?: string) => string;
export declare const OSR_TEMP: (key?: string) => string;
export declare const OSR_CACHE: (key?: string) => string;
export declare const OSR_PRIVATE: (key?: string) => string;
export declare const KB_ROOT: (key?: string) => string;
export declare const OSR_LIBRARY: (key?: string) => string;
export declare const OSR_LIBRARY_MACHINES: (key?: string) => string;
export declare const OSR_LIBRARY_DIRECTORY: (key?: string) => string;
export declare const PRODUCT_ROOT: (key?: string) => string;
export declare const OSR_CUSTOMER_DRIVE: (key?: string) => string;
export declare const OA_ROOT: (key?: string) => string;
export declare const OSR_USER_ASSETS: (key?: string) => string;
export declare const POLYMECH_ROOT: (key?: string) => string;
export declare const DEFAULT_ROOTS: {
OSR_ROOT: string;
OSR_TEMP: string;
PRODUCT_ROOT: string;
OA_ROOT: string;
KB_ROOT: string;
OSR_CACHE: string;
OSR_LIBRARY: string;
OSR_LIBRARY_MACHINES: string;
OSR_LIBRARY_DIRECTORY: string;
OSR_USER_ASSETS: string;
OSR_PRIVATE: string;
OSR_TEMPLATES: string;
OSR_CONTENT: string;
OSR_PROFILES: string;
OSR_CUSTOMER_DRIVE: string;
POLYMECH_ROOT: string;
};
export declare const CONFIG_DEFAULT: (key?: string) => string | false | object;
import { JSONSchemaForNPMPackageJsonFiles } from '@schemastore/package';
import { IComponentConfig } from './component.js';
export declare const readNPMMeta: (_path: string) => JSONSchemaForNPMPackageJsonFiles;
export declare const readPackage: (val: any) => JSONSchemaForNPMPackageJsonFiles;
export declare const readOSRMeta: (_path: string) => IComponentConfig;
export declare const readOSRConfig: (val: any) => any;

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,11 +1,11 @@
export declare const MODULE_NAME = "OSR-Commons";
export declare const PROFILE_FILE_NAME = ".osrl.json";
export declare const OA_LATEST = "${OSR_ROOT}/osr-directory/pp/${YYYY}_${MM}.json";
export declare const OA_LATEST_INVALID = "${OSR_ROOT}/osr-directory/pp/${YYYY}_${MM}_INVALID.json";
export declare const OA_LATEST_CENSORED = "${OSR_ROOT}/osr-directory/pp/${YYYY}_${MM}_CENSORED.json";
export declare const OA_LATEST_MERGED = "${OSR_ROOT}/osr-directory/pp/${YYYY}_${MM}_MERGED.json";
export declare const PP_BAZAR_LATEST_INDEX = "${OSR_ROOT}/pp-bazar/${YYYY}/${MM}/index.json";
export declare const PP_BAZAR_LATEST_INDEX_MERGED = "${OSR_ROOT}/pp-bazar/${YYYY}/${MM}/index_merged.json";
export declare const API_NAMESPACE = "@polymech";
export declare const API_PREFIX = "polymech";
export declare const API_PREFIX_NEXT = "polymech";
export declare const MODULE_NAME = "OSR-Commons";
export declare const PROFILE_FILE_NAME = ".osrl.json";
export declare const OA_LATEST = "${OSR_ROOT}/osr-directory/pp/${YYYY}_${MM}.json";
export declare const OA_LATEST_INVALID = "${OSR_ROOT}/osr-directory/pp/${YYYY}_${MM}_INVALID.json";
export declare const OA_LATEST_CENSORED = "${OSR_ROOT}/osr-directory/pp/${YYYY}_${MM}_CENSORED.json";
export declare const OA_LATEST_MERGED = "${OSR_ROOT}/osr-directory/pp/${YYYY}_${MM}_MERGED.json";
export declare const PP_BAZAR_LATEST_INDEX = "${OSR_ROOT}/pp-bazar/${YYYY}/${MM}/index.json";
export declare const PP_BAZAR_LATEST_INDEX_MERGED = "${OSR_ROOT}/pp-bazar/${YYYY}/${MM}/index_merged.json";
export declare const API_NAMESPACE = "@polymech";
export declare const API_PREFIX = "polymech";
export declare const API_PREFIX_NEXT = "polymech";

View File

@ -1,17 +1,17 @@
export const MODULE_NAME = `OSR-Commons`;
export const PROFILE_FILE_NAME = `.osrl.json`;
////////////////////////////////////////
//
// OA Migration
export const OA_LATEST = '${OSR_ROOT}/osr-directory/pp/${YYYY}_${MM}.json';
export const OA_LATEST_INVALID = '${OSR_ROOT}/osr-directory/pp/${YYYY}_${MM}_INVALID.json';
export const OA_LATEST_CENSORED = '${OSR_ROOT}/osr-directory/pp/${YYYY}_${MM}_CENSORED.json';
export const OA_LATEST_MERGED = '${OSR_ROOT}/osr-directory/pp/${YYYY}_${MM}_MERGED.json';
// fecking bazar
export const PP_BAZAR_LATEST_INDEX = '${OSR_ROOT}/pp-bazar/${YYYY}/${MM}/index.json';
export const PP_BAZAR_LATEST_INDEX_MERGED = '${OSR_ROOT}/pp-bazar/${YYYY}/${MM}/index_merged.json';
// Namespaces
export const API_NAMESPACE = '@polymech';
export const API_PREFIX = 'polymech';
export const API_PREFIX_NEXT = 'polymech';
export const MODULE_NAME = `OSR-Commons`;
export const PROFILE_FILE_NAME = `.osrl.json`;
////////////////////////////////////////
//
// OA Migration
export const OA_LATEST = '${OSR_ROOT}/osr-directory/pp/${YYYY}_${MM}.json';
export const OA_LATEST_INVALID = '${OSR_ROOT}/osr-directory/pp/${YYYY}_${MM}_INVALID.json';
export const OA_LATEST_CENSORED = '${OSR_ROOT}/osr-directory/pp/${YYYY}_${MM}_CENSORED.json';
export const OA_LATEST_MERGED = '${OSR_ROOT}/osr-directory/pp/${YYYY}_${MM}_MERGED.json';
// fecking bazar
export const PP_BAZAR_LATEST_INDEX = '${OSR_ROOT}/pp-bazar/${YYYY}/${MM}/index.json';
export const PP_BAZAR_LATEST_INDEX_MERGED = '${OSR_ROOT}/pp-bazar/${YYYY}/${MM}/index_merged.json';
// Namespaces
export const API_NAMESPACE = '@polymech';
export const API_PREFIX = 'polymech';
export const API_PREFIX_NEXT = 'polymech';
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29uc3RhbnRzLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vc3JjL2NvbnN0YW50cy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxNQUFNLENBQUMsTUFBTSxXQUFXLEdBQUcsYUFBYSxDQUFBO0FBQ3hDLE1BQU0sQ0FBQyxNQUFNLGlCQUFpQixHQUFHLFlBQVksQ0FBQTtBQUM3Qyx3Q0F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sDAAsD,CAAA;AAElG,aAAa;AACb,MAAM,CAAC,MAAM,aAAa,GAAG,WAAW,CAAA;AACxC,MAAM,CAAC,MAAM,UAAU,GAAG,UAAU,CAAA;AACpC,MAAM,CAAC,MAAM,eAAe,GAAG,UAAU,CAAA"}
{"version":3,"sources":["../src/constants.ts"],"sourcesContent":["export const MODULE_NAME = `OSR-Commons`\r\nexport const PROFILE_FILE_NAME = `.osrl.json`\r\n////////////////////////////////////////\r\n//\r\n// OA Migration\r\n\r\nexport const OA_LATEST = '${OSR_ROOT}/osr-directory/pp/${YYYY}_${MM}.json'\r\nexport const OA_LATEST_INVALID = '${OSR_ROOT}/osr-directory/pp/${YYYY}_${MM}_INVALID.json'\r\nexport const OA_LATEST_CENSORED = '${OSR_ROOT}/osr-directory/pp/${YYYY}_${MM}_CENSORED.json'\r\nexport const OA_LATEST_MERGED = '${OSR_ROOT}/osr-directory/pp/${YYYY}_${MM}_MERGED.json'\r\n\r\n// fecking bazar\r\nexport const PP_BAZAR_LATEST_INDEX = '${OSR_ROOT}/pp-bazar/${YYYY}/${MM}/index.json'\r\nexport const PP_BAZAR_LATEST_INDEX_MERGED = '${OSR_ROOT}/pp-bazar/${YYYY}/${MM}/index_merged.json'\r\n\r\n// Namespaces\r\nexport const API_NAMESPACE = '@polymech'\r\nexport const API_PREFIX = 'polymech'\r\nexport const API_PREFIX_NEXT = 'polymech'"],"mappings":"AAAO,MAAM,cAAc;AACpB,MAAM,oBAAoB;AAK1B,MAAM,YAAY;AAClB,MAAM,oBAAoB;AAC1B,MAAM,qBAAqB;AAC3B,MAAM,mBAAmB;AAGzB,MAAM,wBAAwB;AAC9B,MAAM,+BAA+B;AAGrC,MAAM,gBAAgB;AACtB,MAAM,aAAa;AACnB,MAAM,kBAAkB;","names":[]}

View File

@ -1,19 +1,19 @@
import { JSONSchemaForNPMPackageJsonFiles } from '@schemastore/package';
export declare const isAPIPackage: (_path: string) => JSONSchemaForNPMPackageJsonFiles;
export declare const hasDependency: (pkg: string | JSONSchemaForNPMPackageJsonFiles, dep: string) => string;
export declare const isValidMarketplaceComponent: (_path: string) => boolean;
export declare const isInvalidMarketplaceComponent: (_path: string) => boolean;
export declare const isValidLibraryComponent: (_path: string) => boolean;
export declare const PFilterInvalid: {
marketplace_component: string;
};
export declare const PFilterValid: {
marketplace_component: string;
library_component: string;
package: string;
};
export declare const FiltersValid: {
marketplace_component: (_path: string) => boolean;
library_component: (_path: string) => boolean;
package: (_path: string) => JSONSchemaForNPMPackageJsonFiles;
};
import { JSONSchemaForNPMPackageJsonFiles } from '@schemastore/package';
export declare const isAPIPackage: (_path: string) => JSONSchemaForNPMPackageJsonFiles;
export declare const hasDependency: (pkg: string | JSONSchemaForNPMPackageJsonFiles, dep: string) => string;
export declare const isValidMarketplaceComponent: (_path: string) => boolean;
export declare const isInvalidMarketplaceComponent: (_path: string) => boolean;
export declare const isValidLibraryComponent: (_path: string) => boolean;
export declare const PFilterInvalid: {
marketplace_component: string;
};
export declare const PFilterValid: {
marketplace_component: string;
library_component: string;
package: string;
};
export declare const FiltersValid: {
marketplace_component: (_path: string) => boolean;
library_component: (_path: string) => boolean;
package: (_path: string) => JSONSchemaForNPMPackageJsonFiles;
};

View File

@ -1,65 +1,65 @@
import * as path from 'path';
import { sync as exists } from '@polymech/fs/exists';
import { API_NAMESPACE, API_PREFIX } from './constants.js';
import { readPackage, readOSRConfig } from './config.js';
//////////////////////////////////////////////////////
//
// NPM related
export const isAPIPackage = (_path) => {
const pkg = readPackage(_path);
return (pkg.name || '').startsWith(`${API_NAMESPACE}/${API_PREFIX}`) ? pkg : null;
};
export const hasDependency = (pkg, dep) => {
pkg = readPackage(pkg);
return Object.keys((pkg.dependencies || {})).
concat(Object.keys(pkg.devDependencies || {})).
find((d) => d === dep);
};
//////////////////////////////////////////////////////
//
// OSR related
export const isValidMarketplaceComponent = (_path) => {
const pkg = readOSRConfig(_path);
if (!pkg ||
!pkg.name ||
!pkg.slug ||
!pkg.code) {
return false;
}
return true;
};
export const isInvalidMarketplaceComponent = (_path) => {
const pkg = readOSRConfig(_path);
if (pkg &&
!pkg.name ||
!pkg.slug ||
!pkg.code) {
return true;
}
return false;
};
export const isValidLibraryComponent = (_path) => {
const pkg = readOSRConfig(_path);
if (!pkg || !pkg.name) {
return false;
}
const templatePath = path.resolve(`${path.parse(_path).dir}/templates/shared/body.md`);
if (!exists(templatePath)) {
return false;
}
return true;
};
export const PFilterInvalid = {
marketplace_component: 'invalid_marketplace_component'
};
export const PFilterValid = {
marketplace_component: 'marketplace_component',
library_component: 'library_component',
package: 'package'
};
export const FiltersValid = {
'marketplace_component': isValidMarketplaceComponent,
'library_component': isValidLibraryComponent,
'package': isAPIPackage
};
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZmlsdGVyLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vc3JjL2ZpbHRlci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEtBQUssSUFBSSxNQUFNLE1BQU0sQ0FBQTtBQUU1QixPQUFPLEVBQUUsSUFBSSxJQUFJLE1BQU0sRUFBRSxNQUFNLHFCQUFxQixDQUFBO0FBRXBELE9BQU8sRUFDSCxhQUFhLEVBQ2IsVUFBVSxFQUNiLE1BQU0sZ0JBQWdCLENBQUE7QUFFdkIsT0FBTyxFQUNILFdBQVcsRUFDWCxhQUFhLEVBQ2hCLE1BQU0sYUFBYSxDQUFBO0FBRXBCLHNEQUFzRDtBQUN0RCxFQUFFO0FBQ0YsZUFBZTtBQUVmLE1BQU0sQ0FBQyxNQUFNLFlBQVksR0FBRyxDQUFDLEtBQWEsRUFBRSxFQUFFO0lBQzFDLE1BQU0sR0FBRyxHQUFHLFdBQVcsQ0FBQyxLQUFLLENBQUMsQ0FBQTtJQUM5QixPQUFPLENBQUMsR0FBRyxDQUFDLElBQUksSUFBSSxFQUFFLENBQUMsQ0FBQyxVQUFVLENBQUMsR0FBRyx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JBQXVCLEVBQUUsMkJBQTJCO0lBQ3BELG1CQUFtQixFQUFFLHVCQUF1QjtJQUM1QyxTQUFTLEVBQUcsWUFBWTtDQUMzQixDQUFBIn0=
import * as path from 'path';
import { sync as exists } from '@polymech/fs/exists';
import { API_NAMESPACE, API_PREFIX } from './constants.js';
import { readPackage, readOSRConfig } from './config.js';
//////////////////////////////////////////////////////
//
// NPM related
export const isAPIPackage = (_path) => {
const pkg = readPackage(_path);
return (pkg.name || '').startsWith(`${API_NAMESPACE}/${API_PREFIX}`) ? pkg : null;
};
export const hasDependency = (pkg, dep) => {
pkg = readPackage(pkg);
return Object.keys((pkg.dependencies || {})).
concat(Object.keys(pkg.devDependencies || {})).
find((d) => d === dep);
};
//////////////////////////////////////////////////////
//
// OSR related
export const isValidMarketplaceComponent = (_path) => {
const pkg = readOSRConfig(_path);
if (!pkg ||
!pkg.name ||
!pkg.slug ||
!pkg.code) {
return false;
}
return true;
};
export const isInvalidMarketplaceComponent = (_path) => {
const pkg = readOSRConfig(_path);
if (pkg &&
!pkg.name ||
!pkg.slug ||
!pkg.code) {
return true;
}
return false;
};
export const isValidLibraryComponent = (_path) => {
const pkg = readOSRConfig(_path);
if (!pkg || !pkg.name) {
return false;
}
const templatePath = path.resolve(`${path.parse(_path).dir}/templates/shared/body.md`);
if (!exists(templatePath)) {
return false;
}
return true;
};
export const PFilterInvalid = {
marketplace_component: 'invalid_marketplace_component'
};
export const PFilterValid = {
marketplace_component: 'marketplace_component',
library_component: 'library_component',
package: 'package'
};
export const FiltersValid = {
'marketplace_component': isValidMarketplaceComponent,
'library_component': isValidLibraryComponent,
'package': isAPIPackage
};
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZmlsdGVyLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vc3JjL2ZpbHRlci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEtBQUssSUFBSSxN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,KAAa,EAAE,EAAE;IACrD,MAAM,GAAG,GAAG,aAAa,CAAC,KAAK,CAAC,CAAA;IAChC,IAAI,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,EAAC;QAClB,OAAO,KAAK,CAAA;KACf;IACD,MAAM,YAAY,GAAI,IAAI,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,GAAG,2BAA2B,CAAC,CAAA;IACvF,IAAG,CAAC,MAAM,CAAC,YAAY,CAAC,EAAC;QACrB,OAAO,KAAK,CAAA;KACf;IACD,OAAO,IAAI,CAAA;AACf,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,cAAc,GAAG;IAC1B,qBAAqB,EAAE,+BAA+B;CACzD,CAAA;AAED,MAAM,CAAC,MAAM,YAAY,GAAG;IACxB,qBAAqB,EAAE,uBAAuB;IAC9C,iBAAiB,EAAE,mBAAmB;IACtC,OAAO,EAAE,SAAS;CACrB,CAAA;AAED,MAAM,CAAC,MAAM,YAAY,GACzB;IACI,uBAAuB,EAAE,2BAA2B;IACpD,mBAAmB,EAAE,uBAAuB;IAC5C,SAAS,EAAG,YAAY;CAC3B,CAAA"}
{"version":3,"sources":["../src/filter.ts"],"sourcesContent":["import * as path from 'path'\r\nimport { JSONSchemaForNPMPackageJsonFiles } from '@schemastore/package'\r\nimport { sync as exists } from '@polymech/fs/exists'\r\n\r\nimport {\r\n API_NAMESPACE,\r\n API_PREFIX \r\n} from './constants.js'\r\n\r\nimport {\r\n readPackage,\r\n readOSRConfig\r\n} from './config.js'\r\n\r\n//////////////////////////////////////////////////////\r\n//\r\n// NPM related\r\n\r\nexport const isAPIPackage = (_path: string) => {\r\n const pkg = readPackage(_path)\r\n return (pkg.name || '').startsWith(`${API_NAMESPACE}/${API_PREFIX}`) ? pkg : null\r\n}\r\n\r\nexport const hasDependency = (pkg: string | JSONSchemaForNPMPackageJsonFiles, dep: string) => {\r\n pkg = readPackage(pkg)\r\n return Object.keys((pkg.dependencies || {})).\r\n concat( Object.keys(pkg.devDependencies || {})).\r\n find((d:string)=> d === dep)\r\n}\r\n\r\n//////////////////////////////////////////////////////\r\n//\r\n// OSR related\r\n\r\nexport const isValidMarketplaceComponent = (_path: string) => {\r\n const pkg = readOSRConfig(_path)\r\n if( !pkg ||\r\n !pkg.name ||\r\n !pkg.slug ||\r\n !pkg.code){\r\n return false\r\n }\r\n return true \r\n}\r\n\r\nexport const isInvalidMarketplaceComponent = (_path: string) => {\r\n const pkg = readOSRConfig(_path)\r\n if( pkg &&\r\n !pkg.name ||\r\n !pkg.slug ||\r\n !pkg.code){\r\n return true\r\n }\r\n return false\r\n}\r\n\r\nexport const isValidLibraryComponent = (_path: string) => {\r\n const pkg = readOSRConfig(_path)\r\n if( !pkg || !pkg.name){\r\n return false\r\n }\r\n const templatePath = path.resolve(`${path.parse(_path).dir}/templates/shared/body.md`)\r\n if(!exists(templatePath)){\r\n return false\r\n }\r\n return true\r\n}\r\n\r\nexport const PFilterInvalid = {\r\n marketplace_component: 'invalid_marketplace_component'\r\n}\r\n\r\nexport const PFilterValid = {\r\n marketplace_component: 'marketplace_component',\r\n library_component: 'library_component',\r\n package: 'package'\r\n}\r\n\r\nexport const FiltersValid =\r\n{\r\n 'marketplace_component': isValidMarketplaceComponent,\r\n 'library_component': isValidLibraryComponent,\r\n 'package' : isAPIPackage\r\n}"],"mappings":"AAAA,YAAY,UAAU;AAEtB,SAAS,QAAQ,cAAc;AAE/B;AAAA,EACI;AAAA,EACA;AAAA,OACG;AAEP;AAAA,EACI;AAAA,EACA;AAAA,OACG;AAMA,MAAM,eAAe,CAAC,UAAkB;AAC3C,QAAM,MAAM,YAAY,KAAK;AAC7B,UAAQ,IAAI,QAAQ,IAAI,WAAW,GAAG,aAAa,IAAI,UAAU,EAAE,IAAI,MAAM;AACjF;AAEO,MAAM,gBAAgB,CAAC,KAAgD,QAAgB;AAC1F,QAAM,YAAY,GAAG;AACrB,SAAQ,OAAO,KAAM,IAAI,gBAAgB,CAAC,CAAE,EACpC,OAAQ,OAAO,KAAK,IAAI,mBAAmB,CAAC,CAAC,CAAC,EAC9C,KAAK,CAAC,MAAY,MAAM,GAAG;AACvC;AAMO,MAAM,8BAA8B,CAAC,UAAkB;AAC1D,QAAM,MAAM,cAAc,KAAK;AAC/B,MAAI,CAAC,OACD,CAAC,IAAI,QACL,CAAC,IAAI,QACL,CAAC,IAAI,MAAK;AACV,WAAO;AAAA,EACX;AACA,SAAO;AACX;AAEO,MAAM,gCAAgC,CAAC,UAAkB;AAC5D,QAAM,MAAM,cAAc,KAAK;AAC/B,MAAI,OACA,CAAC,IAAI,QACL,CAAC,IAAI,QACL,CAAC,IAAI,MAAK;AACV,WAAO;AAAA,EACX;AACA,SAAO;AACX;AAEO,MAAM,0BAA0B,CAAC,UAAkB;AACtD,QAAM,MAAM,cAAc,KAAK;AAC/B,MAAI,CAAC,OAAO,CAAC,IAAI,MAAK;AAClB,WAAO;AAAA,EACX;AACA,QAAM,eAAgB,KAAK,QAAQ,GAAG,KAAK,MAAM,KAAK,EAAE,GAAG,2BAA2B;AACtF,MAAG,CAAC,OAAO,YAAY,GAAE;AACrB,WAAO;AAAA,EACX;AACA,SAAO;AACX;AAEO,MAAM,iBAAiB;AAAA,EAC1B,uBAAuB;AAC3B;AAEO,MAAM,eAAe;AAAA,EACxB,uBAAuB;AAAA,EACvB,mBAAmB;AAAA,EACnB,SAAS;AACb;AAEO,MAAM,eACb;AAAA,EACI,yBAAyB;AAAA,EACzB,qBAAqB;AAAA,EACrB,WAAY;AAChB;","names":[]}

View File

@ -1,5 +1,5 @@
export declare const UNC_REGEX: RegExp;
export declare const WIN32_PATH_REGEX: RegExp;
export declare const isFile: (src: string) => boolean;
export declare const isFolder: (src: string) => boolean;
export declare const is_absolute: (fp: any) => boolean;
export declare const UNC_REGEX: RegExp;
export declare const WIN32_PATH_REGEX: RegExp;
export declare const isFile: (src: string) => boolean;
export declare const isFolder: (src: string) => boolean;
export declare const is_absolute: (fp: any) => boolean;

View File

@ -1,36 +1,36 @@
import * as fs from 'fs';
// https://learn.microsoft.com/en-us/windows/win32/fileio/naming-a-file#namespaces
// https://github.com/isaacs/node-glob/blob/main/src/pattern.ts
export const UNC_REGEX = /^[\\\/]{2,}[^\\\/]+[\\\/]+[^\\\/]+/;
export const WIN32_PATH_REGEX = /^([a-z]:)?[\\\/]/i;
import { is_windows } from './os.js';
export const isFile = (src) => {
let srcIsFile = false;
try {
srcIsFile = fs.lstatSync(src).isFile();
}
catch (e) { }
return srcIsFile;
};
export const isFolder = (src) => {
let srcIsFolder = false;
try {
srcIsFolder = fs.lstatSync(src).isDirectory();
}
catch (e) { }
return srcIsFolder;
};
const is_relative_win32 = (fp) => !fp.test(UNC_REGEX) && !WIN32_PATH_REGEX.test(fp);
const is_absolute_posix = (fp) => fp.charAt(0) === '/';
const is_absolute_win32 = (fp) => {
if (/[a-z]/i.test(fp.charAt(0)) && fp.charAt(1) === ':' && fp.charAt(2) === '\\') {
return true;
}
// Microsoft Azure absolute filepath
if (fp.slice(0, 2) === '\\\\') {
return true;
}
return !is_relative_win32(fp);
};
export const is_absolute = (fp) => is_windows() ? is_absolute_win32(fp) : is_absolute_posix(fp);
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZnMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvZnMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxLQUFLLEVBQUUsTUFBTSxJQUFJLENBQUE7QUFFeEIsa0ZBQWtGO0FBQ2xGLCtEQUErRDtBQUUvRCxNQUFNLENBQUMsTUFBTSxTQUFTLEdBQUcsb0NBQW9DLENBQUE7QUFDN0QsTUFBTSxDQUFDLE1BQU0sZ0JBQWdCLEdBQUcsbUJBQW1CLENBQUE7QUFFbkQsT0FBTyxFQUFFLFVBQVUsRUFBRSxNQUFNLFNBQVMsQ0FBQTtBQUdwQyxNQUFNLEN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UFJLEVBQUUsQ0FBQyxNQUFNLENBQUMsQ0FBQyxDQUFDLEtBQUssR0FBRyxJQUFJLEVBQUUsQ0FBQyxNQUFNLENBQUMsQ0FBQyxDQUFDLEtBQUssSUFBSSxFQUFFO1FBQzlFLE9BQU8sSUFBSSxDQUFBO0tBQ2Q7SUFDRCxvQ0FBb0M7SUFDcEMsSUFBSSxFQUFFLENBQUMsS0FBSyxDQUFDLENBQUMsRUFBRSxDQUFDLENBQUMsS0FBSyxNQUFNLEVBQUU7UUFDM0IsT0FBTyxJQUFJLENBQUM7S0FDZjtJQUNELE9BQU8sQ0FBQyxpQkFBaUIsQ0FBQyxFQUFFLENBQUMsQ0FBQTtBQUNqQyxDQUFDLENBQUE7QUFDRCxNQUFNLENBQUMsTUFBTSxXQUFXLEdBQUcsQ0FBQyxFQUFFLEVBQUUsRUFBRSxDQUFFLFVBQVUsRUFBRSxDQUFDLENBQUMsQ0FBQyxpQkFBaUIsQ0FBQyxFQUFFLENBQUMsQ0FBQyxDQUFDLENBQUMsaUJBQWlCLENBQUMsRUFBRSxDQUFDLENBQUEifQ==
import * as fs from 'fs';
// https://learn.microsoft.com/en-us/windows/win32/fileio/naming-a-file#namespaces
// https://github.com/isaacs/node-glob/blob/main/src/pattern.ts
export const UNC_REGEX = /^[\\\/]{2,}[^\\\/]+[\\\/]+[^\\\/]+/;
export const WIN32_PATH_REGEX = /^([a-z]:)?[\\\/]/i;
import { is_windows } from './os.js';
export const isFile = (src) => {
let srcIsFile = false;
try {
srcIsFile = fs.lstatSync(src).isFile();
}
catch (e) { }
return srcIsFile;
};
export const isFolder = (src) => {
let srcIsFolder = false;
try {
srcIsFolder = fs.lstatSync(src).isDirectory();
}
catch (e) { }
return srcIsFolder;
};
const is_relative_win32 = (fp) => !fp.test(UNC_REGEX) && !WIN32_PATH_REGEX.test(fp);
const is_absolute_posix = (fp) => fp.charAt(0) === '/';
const is_absolute_win32 = (fp) => {
if (/[a-z]/i.test(fp.charAt(0)) && fp.charAt(1) === ':' && fp.charAt(2) === '\\') {
return true;
}
// Microsoft Azure absolute filepath
if (fp.slice(0, 2) === '\\\\') {
return true;
}
return !is_relative_win32(fp);
};
export const is_absolute = (fp) => is_windows() ? is_absolute_win32(fp) : is_absolute_posix(fp);
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZnMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvZnMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxLQUFLLEVBQUUsTUFBTSxJQUFJLENBQUE7QUFFeEIsa0ZBQWtGO0FBQ2xGLCtEQUErRDtBQUUvRCxNQUFNLENBQUMsTUFBTSxTQUFTLEdBQUcsb0NBQW9DLENBQUE7QUFDN0QsTUFBTSxDQUFDLE1BQU0sZ0JBQWdCLEdBQUcsbUJBQW1CLENBQUE7QUFFbkQsT0FBTyxFQUFFLFVBQVUsRUFBRSxNQUFNLFNBQVMsQ0FBQTtBQUdwQyxNQUFNLENBQUMsTUFBTSxNQUFNLEdBQUcsQ0FBQyxHQUFXLEVBQUUsRUFBRTtJQUNsQyxJQUFJLFNBQVMsR0FBRyxLQUFLLENBQUM7SUFDdEIsSUFBSSxDQUFDO1FBQ0QsU0FBUyxHQUFHLEVBQUUsQ0FBQyxTQUFTLENBQUMsR0FBRyxDQUFDLENBQUMsTUFBTSxFQUFFLENBQUE7SUFDMUMsQ0FBQztJQUFDLE9BQU8sQ0FBQyxFQUFFLENBQUMsQ0FBQyxDQUFDO0lBQ2YsT0FBTyxTQUFTLENBQUE7QUFDcEIsQ0FBQyxDQUFBO0FBRUQsTUFBTSxDQUFDLE1BQU0sUUFBUSxHQUFHLENBQUMsR0FBVyxFQUFFLEVBQUU7SUFDcEMsSUFBSSxXQUFXLEdBQUcsS0FBSyxDQUFDO0lBQ3hCLElBQUksQ0FBQztRQUNELFdBQVcsR0FBRyxFQUFFLENBQUMsU0FBUyxDQUFDL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AAA;AACnF,MAAM,iBAAiB,GAAG,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,GAAG,CAAA;AACtD,MAAM,iBAAiB,GAAG,CAAC,EAAE,EAAE,EAAE;IAC7B,IAAI,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,GAAG,IAAI,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,IAAI,EAAE;QAC9E,OAAO,IAAI,CAAA;KACd;IACD,oCAAoC;IACpC,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,MAAM,EAAE;QAC3B,OAAO,IAAI,CAAC;KACf;IACD,OAAO,CAAC,iBAAiB,CAAC,EAAE,CAAC,CAAA;AACjC,CAAC,CAAA;AACD,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,EAAE,EAAE,EAAE,CAAE,UAAU,EAAE,CAAC,CAAC,CAAC,iBAAiB,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,iBAAiB,CAAC,EAAE,CAAC,CAAA"}
{"version":3,"sources":["../src/fs.ts"],"sourcesContent":["import * as fs from 'fs'\r\n\r\n// https://learn.microsoft.com/en-us/windows/win32/fileio/naming-a-file#namespaces\r\n// https://github.com/isaacs/node-glob/blob/main/src/pattern.ts\r\n\r\nexport const UNC_REGEX = /^[\\\\\\/]{2,}[^\\\\\\/]+[\\\\\\/]+[^\\\\\\/]+/\r\nexport const WIN32_PATH_REGEX = /^([a-z]:)?[\\\\\\/]/i\r\n\r\nimport { is_windows } from './os.js'\r\n\r\n\r\nexport const isFile = (src: string) => {\r\n let srcIsFile = false;\r\n try {\r\n srcIsFile = fs.lstatSync(src).isFile()\r\n } catch (e) { }\r\n return srcIsFile\r\n}\r\n\r\nexport const isFolder = (src: string) => {\r\n let srcIsFolder = false;\r\n try {\r\n srcIsFolder = fs.lstatSync(src).isDirectory()\r\n } catch (e) { }\r\n return srcIsFolder;\r\n}\r\n\r\nconst is_relative_win32 = (fp) => !fp.test(UNC_REGEX) && !WIN32_PATH_REGEX.test(fp)\r\nconst is_absolute_posix = (fp) => fp.charAt(0) === '/'\r\nconst is_absolute_win32 = (fp) => {\r\n if (/[a-z]/i.test(fp.charAt(0)) && fp.charAt(1) === ':' && fp.charAt(2) === '\\\\') {\r\n return true\r\n }\r\n // Microsoft Azure absolute filepath\r\n if (fp.slice(0, 2) === '\\\\\\\\') {\r\n return true;\r\n }\r\n return !is_relative_win32(fp)\r\n}\r\nexport const is_absolute = (fp) => is_windows() ? is_absolute_win32(fp) : is_absolute_posix(fp)\r\n"],"mappings":"AAAA,YAAY,QAAQ;AAKb,MAAM,YAAY;AAClB,MAAM,mBAAmB;AAEhC,SAAS,kBAAkB;AAGpB,MAAM,SAAS,CAAC,QAAgB;AACnC,MAAI,YAAY;AAChB,MAAI;AACA,gBAAY,GAAG,UAAU,GAAG,EAAE,OAAO;AAAA,EACzC,SAAS,GAAG;AAAA,EAAE;AACd,SAAO;AACX;AAEO,MAAM,WAAW,CAAC,QAAgB;AACrC,MAAI,cAAc;AAClB,MAAI;AACA,kBAAc,GAAG,UAAU,GAAG,EAAE,YAAY;AAAA,EAChD,SAAS,GAAG;AAAA,EAAE;AACd,SAAO;AACX;AAEA,MAAM,oBAAoB,CAAC,OAAO,CAAC,GAAG,KAAK,SAAS,KAAK,CAAC,iBAAiB,KAAK,EAAE;AAClF,MAAM,oBAAoB,CAAC,OAAO,GAAG,OAAO,CAAC,MAAM;AACnD,MAAM,oBAAoB,CAAC,OAAO;AAC9B,MAAI,SAAS,KAAK,GAAG,OAAO,CAAC,CAAC,KAAK,GAAG,OAAO,CAAC,MAAM,OAAO,GAAG,OAAO,CAAC,MAAM,MAAM;AAC9E,WAAO;AAAA,EACX;AAEA,MAAI,GAAG,MAAM,GAAG,CAAC,MAAM,QAAQ;AAC3B,WAAO;AAAA,EACX;AACA,SAAO,CAAC,kBAAkB,EAAE;AAChC;AACO,MAAM,cAAc,CAAC,OAAQ,WAAW,IAAI,kBAAkB,EAAE,IAAI,kBAAkB,EAAE;","names":[]}

View File

@ -1,10 +1,10 @@
import { GlobOptions } from 'glob';
export declare const files: (cwd: any, glob: any, options?: any) => [];
export declare const filesEx: (cwd: any, glob: any, options?: GlobOptions) => [];
import { PATH_INFO } from '../types_common.js';
export { globBase } from './glob-base.js';
export { globParent } from './glob-parent.js';
export declare const getExtensions: (glob: string) => string[];
export declare const forward_slash: (path: any) => any;
export declare const pathInfoEx: (src: string, altToken?: boolean, globOptions?: GlobOptions) => PATH_INFO;
export declare const pathInfo: (src: string, altToken?: boolean, cwd?: string) => PATH_INFO;
import { GlobOptions } from 'glob';
export declare const files: (cwd: any, glob: any, options?: any) => [];
export declare const filesEx: (cwd: any, glob: any, options?: GlobOptions) => [];
import { PATH_INFO } from '../types_common.js';
export { globBase } from './glob-base.js';
export { globParent } from './glob-parent.js';
export declare const getExtensions: (glob: string) => string[];
export declare const forward_slash: (path: any) => any;
export declare const pathInfoEx: (src: string, altToken?: boolean, globOptions?: GlobOptions) => PATH_INFO;
export declare const pathInfo: (src: string, altToken?: boolean, cwd?: string) => PATH_INFO;

File diff suppressed because one or more lines are too long

View File

@ -1,13 +1,13 @@
/*!
* glob-base <https://github.com/jonschlinkert/glob-base>
*
* Copyright (c) 2015, Jon Schlinkert.
* Licensed under the MIT License.
*/
interface GlobBaseResult {
base: string;
isGlob: boolean;
glob: string;
}
export declare const globBase: (pattern: string) => GlobBaseResult;
export {};
/*!
* glob-base <https://github.com/jonschlinkert/glob-base>
*
* Copyright (c) 2015, Jon Schlinkert.
* Licensed under the MIT License.
*/
interface GlobBaseResult {
base: string;
isGlob: boolean;
glob: string;
}
export declare const globBase: (pattern: string) => GlobBaseResult;
export {};

View File

@ -1,47 +1,47 @@
/*!
* glob-base <https://github.com/jonschlinkert/glob-base>
*
* Copyright (c) 2015, Jon Schlinkert.
* Licensed under the MIT License.
*/
import { dirname as pathDirname } from 'path';
import { hasMagic } from 'glob';
import { globParent } from './glob-parent.js';
function dirname(glob) {
if (glob.slice(-1) === '/')
return glob;
return pathDirname(glob);
}
export const globBase = (pattern) => {
if (typeof pattern !== 'string') {
throw new TypeError('glob-base expects a string.');
}
const res = {
base: globParent(pattern),
isGlob: hasMagic(pattern),
glob: ''
};
if (res.base !== '.') {
res.glob = pattern.substr(res.base.length);
if (res.glob.charAt(0) === '/') {
res.glob = res.glob.substr(1);
}
}
else {
res.glob = pattern;
}
if (!res.isGlob) {
res.base = dirname(pattern);
res.glob = res.base !== '.'
? pattern.substr(res.base.length)
: pattern;
}
if (res.glob.substr(0, 2) === './') {
res.glob = res.glob.substr(2);
}
if (res.glob.charAt(0) === '/') {
res.glob = res.glob.substr(1);
}
return res;
};
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZ2xvYi1iYXNlLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL2ZzL2dsb2ItYmFzZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQTs7Ozs7R0FLRztBQUVILE9BQU8sRUFBRSxPQUFPLElBQUksV0FBVyxFQUFFLE1BQU0sTUFBTSxDQUFBO0FBQzdDLE9BQU8sRUFBRSxRQUFRLEVBQUUsTUFBTSxNQUFNLENBQUE7QUFDL0IsT0FBTyxFQUFFLFVBQVUsRUFBRSxNQUFNLGtCQUFrQixDQUFBO0FBUTdDLFNBQVMsT0FBTyxDQUFDLElBQVk7SUFDM0IsSUFBSSxJQUFJLENBQUMsS0FBSyxDQUFDLENBQUMsQ0FBQyxDQUFDLEtBQUssR0FBRztRQUFFLE9BQU8sSUFBSSxDQUFDO0lBQ3hDLE9BQU8sV0FBVyxDQUFDLElBQUksQ0FBQyxDQUFDO0FBQzNCLENBQUM7QUFFRCxNQUFNLENBQUMsTUFBTSxRQ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0lBRUQsSUFBSSxHQUFHLENBQUMsSUFBSSxDQUFDLE1BQU0sQ0FBQyxDQUFDLEVBQUUsQ0FBQyxDQUFDLEtBQUssSUFBSSxFQUFFO1FBQ2xDLEdBQUcsQ0FBQyxJQUFJLEdBQUcsR0FBRyxDQUFDLElBQUksQ0FBQyxNQUFNLENBQUMsQ0FBQyxDQUFDLENBQUM7S0FDL0I7SUFDRCxJQUFJLEdBQUcsQ0FBQyxJQUFJLENBQUMsTUFBTSxDQUFDLENBQUMsQ0FBQyxLQUFLLEdBQUcsRUFBRTtRQUM5QixHQUFHLENBQUMsSUFBSSxHQUFHLEdBQUcsQ0FBQyxJQUFJLENBQUMsTUFBTSxDQUFDLENBQUMsQ0FBQyxDQUFDO0tBQy9CO0lBQ0QsT0FBTyxHQUFHLENBQUM7QUFDYixDQUFDLENBQUEifQ==
/*!
* glob-base <https://github.com/jonschlinkert/glob-base>
*
* Copyright (c) 2015, Jon Schlinkert.
* Licensed under the MIT License.
*/
import { dirname as pathDirname } from 'path';
import { hasMagic } from 'glob';
import { globParent } from './glob-parent.js';
function dirname(glob) {
if (glob.slice(-1) === '/')
return glob;
return pathDirname(glob);
}
export const globBase = (pattern) => {
if (typeof pattern !== 'string') {
throw new TypeError('glob-base expects a string.');
}
const res = {
base: globParent(pattern),
isGlob: hasMagic(pattern),
glob: ''
};
if (res.base !== '.') {
res.glob = pattern.substr(res.base.length);
if (res.glob.charAt(0) === '/') {
res.glob = res.glob.substr(1);
}
}
else {
res.glob = pattern;
}
if (!res.isGlob) {
res.base = dirname(pattern);
res.glob = res.base !== '.'
? pattern.substr(res.base.length)
: pattern;
}
if (res.glob.substr(0, 2) === './') {
res.glob = res.glob.substr(2);
}
if (res.glob.charAt(0) === '/') {
res.glob = res.glob.substr(1);
}
return res;
};
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZ2xvYi1iYXNlLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOls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-1,5 +1,5 @@
interface Options {
flipBackslashes?: boolean;
}
export declare const globParent: (str: string, opts?: Options) => string;
export {};
interface Options {
flipBackslashes?: boolean;
}
export declare const globParent: (str: string, opts?: Options) => string;
export {};

View File

@ -1,58 +1,58 @@
import { posix } from 'path';
import { platform } from 'os';
import { hasMagic } from 'glob';
const isWin32 = platform() === 'win32';
const slash = '/';
const backslash = /\\/g;
const escaped = /\\([!*?|[\](){}])/g;
export const globParent = (str, opts) => {
const options = { flipBackslashes: true, ...opts };
// flip windows path separators
if (options.flipBackslashes && isWin32 && !str.includes(slash)) {
str = str.replace(backslash, slash);
}
// special case for strings ending in enclosure containing path separator
if (isEnclosure(str)) {
str += slash;
}
// preserves full path in case of trailing path separator
str += 'a';
// remove path parts that are globby
do {
str = posix.dirname(str);
} while (isGlobby(str));
// remove escape chars and return result
return str.replace(escaped, '$1');
};
function isEnclosure(str) {
const lastChar = str.slice(-1);
let enclosureStart;
switch (lastChar) {
case '}':
enclosureStart = '{';
break;
case ']':
enclosureStart = '[';
break;
default:
return false;
}
const foundIndex = str.indexOf(enclosureStart);
if (foundIndex < 0) {
return false;
}
return str.slice(foundIndex + 1, -1).includes(slash);
}
function isGlobby(str) {
if (/\([^()]+$/.test(str)) {
return true;
}
if (str[0] === '{' || str[0] === '[') {
return true;
}
if (/[^\\][{[]/.test(str)) {
return true;
}
return hasMagic(str);
}
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZ2xvYi1wYXJlbnQuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvZnMvZ2xvYi1wYXJlbnQudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFFLEtBQUssRUFBRSxNQUFNLE1BQU0sQ0FBQTtBQUM1QixPQUFPLEVBQUUsUUFBUSxFQUFFLE1BQU0sSUFBSSxDQUFBO0FBQzdCLE9BQU8sRUFBRSxRQUFRLEVBQUUs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'os';
import { hasMagic } from 'glob';
const isWin32 = platform() === 'win32';
const slash = '/';
const backslash = /\\/g;
const escaped = /\\([!*?|[\](){}])/g;
export const globParent = (str, opts) => {
const options = { flipBackslashes: true, ...opts };
// flip windows path separators
if (options.flipBackslashes && isWin32 && !str.includes(slash)) {
str = str.replace(backslash, slash);
}
// special case for strings ending in enclosure containing path separator
if (isEnclosure(str)) {
str += slash;
}
// preserves full path in case of trailing path separator
str += 'a';
// remove path parts that are globby
do {
str = posix.dirname(str);
} while (isGlobby(str));
// remove escape chars and return result
return str.replace(escaped, '$1');
};
function isEnclosure(str) {
const lastChar = str.slice(-1);
let enclosureStart;
switch (lastChar) {
case '}':
enclosureStart = '{';
break;
case ']':
enclosureStart = '[';
break;
default:
return false;
}
const foundIndex = str.indexOf(enclosureStart);
if (foundIndex < 0) {
return false;
}
return str.slice(foundIndex + 1, -1).includes(slash);
}
function isGlobby(str) {
if (/\([^()]+$/.test(str)) {
return true;
}
if (str[0] === '{' || str[0] === '[') {
return true;
}
if (/[^\\][{[]/.test(str)) {
return true;
}
return hasMagic(str);
}
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZ2xvYi1wYXJlbnQuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvZnMvZ2xvYi1wYXJlbnQudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFFLEtBQUssRUFBRSxNQUFNLE1BQU0sQ0FBQTtBQUM1QixPQUFPLEVBQUUsUUFBUSxFQUFFLE1BQU0sSUFBSSxDQUFBO0FBQzdCLE9BQU8sRUFBRSxRQUFRLEVBQUUsTUFBTSxNQUFNLENBQUE7QUFFL0IsTUFBTSxPQUFPLEdBQUcsUUFBUSxFQUFFLEtBQUssT0FBTyxDQUFBO0FBRXRDLE1BQU0sS0FBSyxHQUFHLEdBQUcsQ0FBQztBQUNsQixNQUFNLFNBQVMsR0FBRyxL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FFBQVEsRUFBRSxDQUFDO1FBQ2pCLEtBQUssR0FBRztZQUNOLGNBQWMsR0FBRyxHQUFHLENBQUM7WUFDckIsTUFBTTtRQUNSLEtBQUssR0FBRztZQUNOLGNBQWMsR0FBRyxHQUFHLENBQUM7WUFDckIsTUFBTTtRQUNSO1lBQ0UsT0FBTyxLQUFLLENBQUM7SUFDakIsQ0FBQztJQUVELE1BQU0sVUFBVSxHQUFHLEdBQUcsQ0FBQyxPQUFPLENBQUMsY0FBYyxDQUFDLENBQUM7SUFDL0MsSUFBSSxVQUFVLEdBQUcsQ0FBQyxFQUFFLENBQUM7UUFDbkIsT0FBTyxLQUFLLENBQUM7SUFDZixDQUFDO0lBRUQsT0FBTyxHQUFHLENBQUMsS0FBSyxDQUFDLFVBQVUsR0FBRyxDQUFDLEVBQUUsQ0FBQyxDQUFDLENBQUMsQ0FBQyxRQUFRLENBQUMsS0FBSyxDQUFDLENBQUM7QUFDdkQsQ0FBQztBQUVELFNBQVMsUUFBUSxDQUFDLEdBQVc7SUFDM0IsSUFBSSxXQUFXLENBQUMsSUFBSSxDQUFDLEdBQUcsQ0FBQyxFQUFFLENBQUM7UUFDMUIsT0FBTyxJQUFJLENBQUM7SUFDZCxDQUFDO0lBQ0QsSUFBSSxHQUFHLENBQUMsQ0FBQyxDQUFDLEtBQUssR0FBRyxJQUFJLEdBQUcsQ0FBQyxDQUFDLENBQUMsS0FBSyxHQUFHLEVBQUUsQ0FBQztRQUNyQyxPQUFPLElBQUksQ0FBQztJQUNkLENBQUM7SUFDRCxJQUFJLFdBQVcsQ0FBQyxJQUFJLENBQUMsR0FBRyxDQUFDLEVBQUUsQ0FBQztRQUMxQixPQUFPLElBQUksQ0FBQztJQUNkLENBQUM7SUFDRCxPQUFPLFFBQVEsQ0FBQyxHQUFHLENBQUMsQ0FBQztBQUN2QixDQUFDIn0=

View File

@ -1,10 +1,10 @@
export * from './fs.js';
export * from './config.js';
export * from './os.js';
export * from './paths.js';
export * from './variables.js';
export * from './profile.js';
export * from './types.js';
export * from './constants.js';
export * from './fs/_glob.js';
export * from './component.js';
export * from './fs.js';
export * from './config.js';
export * from './os.js';
export * from './paths.js';
export * from './variables.js';
export * from './profile.js';
export * from './types.js';
export * from './constants.js';
export * from './fs/_glob.js';
export * from './component.js';

View File

@ -1,11 +1,11 @@
export * from './fs.js';
export * from './config.js';
export * from './os.js';
export * from './paths.js';
export * from './variables.js';
export * from './profile.js';
export * from './types.js';
export * from './constants.js';
export * from './fs/_glob.js';
export * from './component.js';
export * from './fs.js';
export * from './config.js';
export * from './os.js';
export * from './paths.js';
export * from './variables.js';
export * from './profile.js';
export * from './types.js';
export * from './constants.js';
export * from './fs/_glob.js';
export * from './component.js';
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsY0FBYyxTQUFTLENBQUE7QUFDdkIsY0FBYyxhQUFhLENBQUE7QUFDM0IsY0FBYyxTQUFTLENBQUE7QUFDdkIsY0FBYyxZQUFZLENBQUE7QUFDMUIsY0FBYyxnQkFBZ0IsQ0FBQTtBQUM5QixjQUFjLGNBQWMsQ0FBQTtBQUM1QixjQUFjLFlBQVksQ0FBQTtBQUMxQixjQUFjLGdCQUFnQixDQUFBO0FBQzlCLGNBQWMsZUFBZSxDQUFBO0FBQzdCLGNBQWMsZ0JBQWdCLENBQUEifQ==

View File

@ -1 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAA;AACvB,cAAc,aAAa,CAAA;AAC3B,cAAc,SAAS,CAAA;AACvB,cAAc,YAAY,CAAA;AAC1B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,cAAc,CAAA;AAC5B,cAAc,YAAY,CAAA;AAC1B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,eAAe,CAAA;AAC7B,cAAc,gBAAgB,CAAA"}
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["export * from './fs.js'\r\nexport * from './config.js'\r\nexport * from './os.js'\r\nexport * from './paths.js'\r\nexport * from './variables.js'\r\nexport * from './profile.js'\r\nexport * from './types.js'\r\nexport * from './constants.js'\r\nexport * from './fs/_glob.js'\r\nexport * from './component.js'\r\n\r\n\r\n\r\n\r\n\r\n\r\n"],"mappings":"AAAA,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;","names":[]}

View File

@ -1,20 +1,20 @@
export declare function isFrontmatterValid(frontmatter: Record<string, any>): boolean;
export declare function extractFrontmatter(code: string): string | undefined;
export interface ParseFrontmatterOptions {
/**
* How the frontmatter should be handled in the returned `content` string.
* - `preserve`: Keep the frontmatter.
* - `remove`: Remove the frontmatter.
* - `empty-with-spaces`: Replace the frontmatter with empty spaces. (preserves sourcemap line/col/offset)
* - `empty-with-lines`: Replace the frontmatter with empty line breaks. (preserves sourcemap line/col)
*
* @default 'remove'
*/
frontmatter: 'preserve' | 'remove' | 'empty-with-spaces' | 'empty-with-lines';
}
export interface ParseFrontmatterResult {
frontmatter: Record<string, any>;
rawFrontmatter: string;
content: string;
}
export declare function parseFrontmatter(code: string, options?: ParseFrontmatterOptions): ParseFrontmatterResult;
export declare function isFrontmatterValid(frontmatter: Record<string, any>): boolean;
export declare function extractFrontmatter(code: string): string | undefined;
export interface ParseFrontmatterOptions {
/**
* How the frontmatter should be handled in the returned `content` string.
* - `preserve`: Keep the frontmatter.
* - `remove`: Remove the frontmatter.
* - `empty-with-spaces`: Replace the frontmatter with empty spaces. (preserves sourcemap line/col/offset)
* - `empty-with-lines`: Replace the frontmatter with empty line breaks. (preserves sourcemap line/col)
*
* @default 'remove'
*/
frontmatter: 'preserve' | 'remove' | 'empty-with-spaces' | 'empty-with-lines';
}
export interface ParseFrontmatterResult {
frontmatter: Record<string, any>;
rawFrontmatter: string;
content: string;
}
export declare function parseFrontmatter(code: string, options?: ParseFrontmatterOptions): ParseFrontmatterResult;

View File

@ -1,48 +1,48 @@
import yaml from 'js-yaml';
export function isFrontmatterValid(frontmatter) {
try {
// ensure frontmatter is JSON-serializable
JSON.stringify(frontmatter);
}
catch {
return false;
}
return typeof frontmatter === 'object' && frontmatter !== null;
}
// Capture frontmatter wrapped with `---`, including any characters and new lines within it.
// Only capture if `---` exists near the top of the file, including:
// 1. Start of file (including if has BOM encoding)
// 2. Start of file with any whitespace (but `---` must still start on a new line)
const frontmatterRE = /(?:^\uFEFF?|^\s*\n)---([\s\S]*?\n)---/;
export function extractFrontmatter(code) {
return frontmatterRE.exec(code)?.[1];
}
export function parseFrontmatter(code, options) {
const rawFrontmatter = extractFrontmatter(code);
if (rawFrontmatter == null) {
return { frontmatter: {}, rawFrontmatter: '', content: code };
}
const parsed = yaml.load(rawFrontmatter);
const frontmatter = (parsed && typeof parsed === 'object' ? parsed : {});
let content;
switch (options?.frontmatter ?? 'remove') {
case 'preserve':
content = code;
break;
case 'remove':
content = code.replace(`---${rawFrontmatter}---`, '');
break;
case 'empty-with-spaces':
content = code.replace(`---${rawFrontmatter}---`, ` ${rawFrontmatter.replace(/[^\r\n]/g, ' ')} `);
break;
case 'empty-with-lines':
content = code.replace(`---${rawFrontmatter}---`, rawFrontmatter.replace(/[^\r\n]/g, ''));
break;
}
return {
frontmatter,
rawFrontmatter,
content,
};
}
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZnJvbnRtYXR0ZXIuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvbGFuZy9mcm9udG1hdHRlci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLElBQUksTUFBTSxTQUFTLENBQUM7QUFFM0IsTUFBTSxVQUFVLGtCQUFrQix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T0FBTyxFQUFFLFdBQVcsSUFBSSxRQUFRLEVBQUU7UUFDekMsS0FBSyxVQUFVO1lBQ2QsT0FBTyxHQUFHLElBQUksQ0FBQztZQUNmLE1BQU07UUFDUCxLQUFLLFFBQVE7WUFDWixPQUFPLEdBQUcsSUFBSSxDQUFDLE9BQU8sQ0FBQyxNQUFNLGNBQWMsS0FBSyxFQUFFLEVBQUUsQ0FBQyxDQUFDO1lBQ3RELE1BQU07UUFDUCxLQUFLLG1CQUFtQjtZQUN2QixPQUFPLEdBQUcsSUFBSSxDQUFDLE9BQU8sQ0FDckIsTUFBTSxjQUFjLEtBQUssRUFDekIsTUFBTSxjQUFjLENBQUMsT0FBTyxDQUFDLFVBQVUsRUFBRSxHQUFHLENBQUMsS0FBSyxDQUNsRCxDQUFDO1lBQ0YsTUFBTTtRQUNQLEtBQUssa0JBQWtCO1lBQ3RCLE9BQU8sR0FBRyxJQUFJLENBQUMsT0FBTyxDQUFDLE1BQU0sY0FBYyxLQUFLLEVBQUUsY0FBYyxDQUFDLE9BQU8sQ0FBQyxVQUFVLEVBQUUsRUFBRSxDQUFDLENBQUMsQ0FBQztZQUMxRixNQUFNO0tBQ1A7SUFFRCxPQUFPO1FBQ04sV0FBVztRQUNYLGNBQWM7UUFDZCxPQUFPO0tBQ1AsQ0FBQztBQUNILENBQUMifQ==
import yaml from 'js-yaml';
export function isFrontmatterValid(frontmatter) {
try {
// ensure frontmatter is JSON-serializable
JSON.stringify(frontmatter);
}
catch {
return false;
}
return typeof frontmatter === 'object' && frontmatter !== null;
}
// Capture frontmatter wrapped with `---`, including any characters and new lines within it.
// Only capture if `---` exists near the top of the file, including:
// 1. Start of file (including if has BOM encoding)
// 2. Start of file with any whitespace (but `---` must still start on a new line)
const frontmatterRE = /(?:^\uFEFF?|^\s*\n)---([\s\S]*?\n)---/;
export function extractFrontmatter(code) {
return frontmatterRE.exec(code)?.[1];
}
export function parseFrontmatter(code, options) {
const rawFrontmatter = extractFrontmatter(code);
if (rawFrontmatter == null) {
return { frontmatter: {}, rawFrontmatter: '', content: code };
}
const parsed = yaml.load(rawFrontmatter);
const frontmatter = (parsed && typeof parsed === 'object' ? parsed : {});
let content;
switch (options?.frontmatter ?? 'remove') {
case 'preserve':
content = code;
break;
case 'remove':
content = code.replace(`---${rawFrontmatter}---`, '');
break;
case 'empty-with-spaces':
content = code.replace(`---${rawFrontmatter}---`, ` ${rawFrontmatter.replace(/[^\r\n]/g, ' ')} `);
break;
case 'empty-with-lines':
content = code.replace(`---${rawFrontmatter}---`, rawFrontmatter.replace(/[^\r\n]/g, ''));
break;
}
return {
frontmatter,
rawFrontmatter,
content,
};
}
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZnJvbnRtYXR0ZXIuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvbGFuZy9mcm9udG1hdHRlci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLElBQUksTUFBTSxTQUFTLENBQUM7QUFFM0IsTUFBTSxVQUFVLGtCQUFrQixDQUFDLFdBQWdDO0lBQ2xFLElBQUksQ0FBQztRQUNKLDBDQUEwQztRQUMxQyxJQUFJLENBQUMsU0FBUyxDQUFDLFdBQVcsQ0FBQyxDQUFDO0lBQzdCLENBQUM7SUFBQyxNQUFNLENBQUM7UUFDUixPQUFPLEtBQUssQ0FBQztJQUNkLENBQUM7SUFDRCxPQUFPLE9BQU8sV0FBVyxLQUFLLFFBQVEsSUFBSSxXQUFXLEtBQUssSUFBSSxDQUFDO0FBQ2hFLENBQUM7QUFFRCw0RkFBNEY7QUFDNUYsb0VBQW9FO0FBQ3BFLG1EQUFtRDtBQUNuRCxrRkFBa0Y7QUFDbEYsTUFBTSxhQUFhLEdBQUcsdUNBQXVDLENBQUM7QUFDOUQsTUFBTSxVQUFVLGtCQUFrQixDQUFDLElBQVk7SUFDOUMsT0FBTyxhQUFhLENBQUMsSUFBSSxD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QUM7WUFDRixNQUFNO1FBQ1AsS0FBSyxrQkFBa0I7WUFDdEIsT0FBTyxHQUFHLElBQUksQ0FBQyxPQUFPLENBQUMsTUFBTSxjQUFjLEtBQUssRUFBRSxjQUFjLENBQUMsT0FBTyxDQUFDLFVBQVUsRUFBRSxFQUFFLENBQUMsQ0FBQyxDQUFDO1lBQzFGLE1BQU07SUFDUixDQUFDO0lBRUQsT0FBTztRQUNOLFdBQVc7UUFDWCxjQUFjO1FBQ2QsT0FBTztLQUNQLENBQUM7QUFDSCxDQUFDIn0=

View File

@ -1 +1 @@
export {};
export {};

View File

@ -1,2 +1,2 @@
export {};
export {};
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29tcG9uZW50cy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9saWIvY29tcG9uZW50cy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiIn0=

View File

@ -1,2 +1,2 @@
export declare const isFile: (src: string) => boolean;
export declare const isFolder: (src: string) => boolean;
export declare const isFile: (src: string) => boolean;
export declare const isFolder: (src: string) => boolean;

View File

@ -1,18 +1,18 @@
import * as fs from 'fs';
export const isFile = (src) => {
let srcIsFile = false;
try {
srcIsFile = fs.lstatSync(src).isFile();
}
catch (e) { }
return srcIsFile;
};
export const isFolder = (src) => {
let srcIsFolder = false;
try {
srcIsFolder = fs.lstatSync(src).isDirectory();
}
catch (e) { }
return srcIsFolder;
};
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZnMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvbGliL2ZzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sS0FBSyxFQUFFLE1BQU0sSUFBSSxDQUFBO0FBRXhCLE1BQU0sQ0FBQyxNQUFNLE1BQU0sR0FBRyxDQUFDLEdBQVcsRUFBRSxFQUFFO0lBQ2xDLElBQUksU0FBUyxHQUFHLEtBQUssQ0FBQztJQUN0QixJQUFJO1FBQ0EsU0FBUyxHQUFHLEVBQUUsQ0FBQyxTQUFTLENBQUMsR0FBRyxDQUFDLENBQUMsTUFBTSxFQUFFLENBQUE7S0FDekM7SUFBQyxPQUFPLENBQUMsRUFBRSxHQUFHO0lBQ2YsT0FBTyxTQUFTLENBQUE7QUFDcEIsQ0FBQyxDQUFBO0FBQ0QsTUFBTSxDQUFDLE1BQU0sUUFBUSxHQUFHLENBQUMsR0FBVyxFQUFFLEVBQUU7SUFDcEMsSUFBSSxXQUFXLEdBQUcsS0FBSyxDQUFDO0lBQ3hCLElBQUk7UUFDQSxXQUFXLEdBQUcsRUFBRSxDQUFDLFNBQVMsQ0FBQyxHQUFHLENBQUMsQ0FBQyxXQUFXLEVBQUUsQ0FBQTtLQUNoRDtJQUFDLE9BQU8sQ0FBQyxFQUFFLEdBQUc7SUFDZixPQUFPLFdBQVcsQ0FBQztBQUN2QixDQUFDLENBQUEifQ==
import * as fs from 'fs';
export const isFile = (src) => {
let srcIsFile = false;
try {
srcIsFile = fs.lstatSync(src).isFile();
}
catch (e) { }
return srcIsFile;
};
export const isFolder = (src) => {
let srcIsFolder = false;
try {
srcIsFolder = fs.lstatSync(src).isDirectory();
}
catch (e) { }
return srcIsFolder;
};
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZnMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvbGliL2ZzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sS0FBSyxFQUFFLE1BQU0sSUFBSSxDQUFBO0FBRXhCLE1BQU0sQ0FBQyxNQUFNLE1BQU0sR0FBRyxDQUFDLEdBQVcsRUFBRSxFQUFFO0lBQ2xDLElBQUksU0FBUyxHQUFHLEtBQUssQ0FBQztJQUN0QixJQUFJLENBQUM7UUFDRCxTQUFTLEdBQUcsRUFBRSxDQUFDLFNBQVMsQ0FBQyxHQUFHLENBQUMsQ0FBQyxNQUFNLEVBQUUsQ0FBQTtJQUMxQyxDQUFDO0lBQUMsT0FBTyxDQUFDLEVBQUUsQ0FBQyxDQUFDLENBQUM7SUFDZixPQUFPLFNBQVMsQ0FBQTtBQUNwQixDQUFDLENBQUE7QUFDRCxNQUFNLENBQUMsTUFBTSxRQUFRLEdBQUcsQ0FBQyxHQUFXLEVBQUUsRUFBRTtJQUNwQyxJQUFJLFdBQVcsR0FBRyxLQUFLLENBQUM7SUFDeEIsSUFBSSxDQUFDO1FBQ0QsV0FBVyxHQUFHLEVBQUUsQ0FBQyxTQUFTLENBQUMsR0FBRyxDQUFDLENBQUMsV0FBVyxFQUFFLENBQUE7SUFDakQsQ0FBQztJQUFDLE9BQU8sQ0FBQyxFQUFFLENBQUMsQ0FBQyxDQUFDO0lBQ2YsT0FBTyxXQUFXLENBQUM7QUFDdkIsQ0FBQyxDQUFBIn0=

View File

@ -1,2 +1,2 @@
export * from './strings.js';
export * from './fs.js';
export * from './strings.js';
export * from './fs.js';

View File

@ -1,3 +1,3 @@
export * from './strings.js';
export * from './fs.js';
export * from './strings.js';
export * from './fs.js';
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvbGliL2luZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLGNBQWMsY0FBYyxDQUFBO0FBQzVCLGNBQWMsU0FBUyxDQUFBIn0=

View File

@ -1,3 +1,3 @@
export declare const regexExEmojis: RegExp;
export declare const regexExEmojis2: RegExp;
export declare const regexExEmojis3: RegExp;
export declare const regexExEmojis: RegExp;
export declare const regexExEmojis2: RegExp;
export declare const regexExEmojis3: RegExp;

File diff suppressed because one or more lines are too long

View File

@ -1,5 +1,5 @@
import { Logger } from "tslog";
export declare function createLogger(name: string, options?: any): Logger;
export declare const defaultLogger: Logger;
export { MODULE_NAME } from './constants.js';
export declare const logger: Logger;
import { Logger } from "tslog";
export declare function createLogger(name: string, options?: any): Logger;
export declare const defaultLogger: Logger;
export { MODULE_NAME } from './constants.js';
export declare const logger: Logger;

View File

@ -1,15 +1,15 @@
import { Logger } from "tslog";
export function createLogger(name, options) {
return new Logger({
name,
type: 'pretty',
...options,
});
}
export const defaultLogger = createLogger('DefaultLogger', {
minLevel: 1
});
import { MODULE_NAME } from './constants.js';
export { MODULE_NAME } from './constants.js';
export const logger = createLogger(MODULE_NAME, {});
import { Logger } from "tslog";
export function createLogger(name, options) {
return new Logger({
name,
type: 'pretty',
...options,
});
}
export const defaultLogger = createLogger('DefaultLogger', {
minLevel: 1
});
import { MODULE_NAME } from './constants.js';
export { MODULE_NAME } from './constants.js';
export const logger = createLogger(MODULE_NAME, {});
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibG9nZ2VyLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vc3JjL2xvZ2dlci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQW1CLE1BQU0sRUFBRSxNQUFNLE9BQU8sQ0FBQTtBQUUvQyxNQUFNLFVBQVUsWUFBWSxDQUFDLElBQVksRUFBRSxPQUFhO0lBQ3BELE9BQU8sSUFBSSxNQUFNLENBQUM7UUFDZCxJQUFJO1FBQ0osSUFBSSxFQUFFLFFBQVE7UUFDZCxHQUFHLE9BQU87S0FDYixDQUFDLENBQUE7QUFDTixDQUFDO0FBQ0QsTUFBTSxDQUFDLE1BQU0sYUFBYSxHQUFHLFlBQVksQ0FBQyxlQUFlLEVBQUU7SUFDdkQsUUFBUSxFQUFFLENBQUM7Q0FDZCxDQUFDLENBQUE7QUFFRixPQUFPLEVBQUUsV0FBVyxFQUFFLE1BQU0sZ0JBQWdCLENBQUE7QUFDNUMsT0FBTyxFQUFFLFdBQVcsRUFBRSxNQUFNLGdCQUFnQixDQUFBO0FBRTVDLE1BQU0sQ0FBQyxNQUFNLE1BQU0sR0FBRyxZQUFZLENBQUMsV0FBVyxFQUFFLEVBQUUsQ0FBQyxDQUFBIn0=

View File

@ -1 +1 @@
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,MAAM,EAAE,MAAM,OAAO,CAAA;AAE/C,MAAM,UAAU,YAAY,CAAC,IAAY,EAAE,OAAa;IACpD,OAAO,IAAI,MAAM,CAAC;QACd,IAAI;QACJ,IAAI,EAAE,QAAQ;QACd,GAAG,OAAO;KACb,CAAC,CAAA;AACN,CAAC;AACD,MAAM,CAAC,MAAM,aAAa,GAAG,YAAY,CAAC,eAAe,EAAE;IACvD,QAAQ,EAAE,CAAC;CACd,CAAC,CAAA;AAEF,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAE5C,MAAM,CAAC,MAAM,MAAM,GAAG,YAAY,CAAC,WAAW,EAAE,EAAE,CAAC,CAAA"}
{"version":3,"sources":["../src/logger.ts"],"sourcesContent":["import { ISettingsParam, Logger } from \"tslog\"\r\n\r\nexport function createLogger(name: string, options?: any) {\r\n return new Logger({\r\n name,\r\n type: 'pretty',\r\n ...options,\r\n })\r\n}\r\nexport const defaultLogger = createLogger('DefaultLogger', {\r\n minLevel: 1\r\n})\r\n\r\nimport { MODULE_NAME } from './constants.js'\r\nexport { MODULE_NAME } from './constants.js'\r\n\r\nexport const logger = createLogger(MODULE_NAME, {})\r\n"],"mappings":"AAAA,SAA0B,cAAc;AAEjC,SAAS,aAAa,MAAc,SAAe;AACtD,SAAO,IAAI,OAAO;AAAA,IACd;AAAA,IACA,MAAM;AAAA,IACN,GAAG;AAAA,EACP,CAAC;AACL;AACO,MAAM,gBAAgB,aAAa,iBAAiB;AAAA,EACvD,UAAU;AACd,CAAC;AAED,SAAS,mBAAmB;AAC5B,SAAS,eAAAA,oBAAmB;AAErB,MAAM,SAAS,aAAa,aAAa,CAAC,CAAC;","names":["MODULE_NAME"]}

View File

@ -1,10 +1,10 @@
export declare enum EPlatform {
Linux = "linux",
Windows = "win32",
OSX = "darwin"
}
export declare enum EArch {
x64 = "64",
x32 = "32"
}
export declare const is_windows: () => boolean;
export declare enum EPlatform {
Linux = "linux",
Windows = "win32",
OSX = "darwin"
}
export declare enum EArch {
x64 = "64",
x32 = "32"
}
export declare const is_windows: () => boolean;

View File

@ -1,13 +1,13 @@
export var EPlatform;
(function (EPlatform) {
EPlatform["Linux"] = "linux";
EPlatform["Windows"] = "win32";
EPlatform["OSX"] = "darwin";
})(EPlatform = EPlatform || (EPlatform = {}));
export var EArch;
(function (EArch) {
EArch["x64"] = "64";
EArch["x32"] = "32";
})(EArch = EArch || (EArch = {}));
export const is_windows = () => process && (process.platform === 'win32');
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoib3MuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvb3MudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsTUFBTSxDQUFOLElBQVksU0FJWDtBQUpELFdBQVksU0FBUztJQUNwQiw0QkFBZSxDQUFBO0lBQ2YsOEJBQWlCLENBQUE7SUFDakIsMkJBQWMsQ0FBQTtBQUNmLENBQUMsRUFKVyxTQUFTLEdBQVQsU0FBUyxLQUFULFNBQVMsUUFJcEI7QUFDRCxNQUFNLENBQU4sSUFBWSxLQUdYO0FBSEQsV0FBWSxLQUFLO0lBQ2hCLG1CQUFVLENBQUE7SUFDVixtQkFBVSxDQUFBO0FBQ1gsQ0FBQyxFQUhXLEtBQUssR0FBTCxLQUFLLEtBQUwsS0FBSyxRQUdoQjtBQUNELE1BQU0sQ0FBQyxNQUFNLFVBQVUsR0FBRyxHQUFHLEVBQUUsQ0FBQyxPQUFPLElBQUksQ0FBQyxPQUFPLENBQUMsUUFBUSxLQUFLLE9BQU8sQ0FBQyxDQUFBIn0=
export var EPlatform;
(function (EPlatform) {
EPlatform["Linux"] = "linux";
EPlatform["Windows"] = "win32";
EPlatform["OSX"] = "darwin";
})(EPlatform || (EPlatform = {}));
export var EArch;
(function (EArch) {
EArch["x64"] = "64";
EArch["x32"] = "32";
})(EArch || (EArch = {}));
export const is_windows = () => process && (process.platform === 'win32');
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoib3MuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvb3MudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsTUFBTSxDQUFOLElBQVksU0FJWDtBQUpELFdBQVksU0FBUztJQUNwQiw0QkFBZSxDQUFBO0lBQ2YsOEJBQWlCLENBQUE7SUFDakIsMkJBQWMsQ0FBQTtBQUNmLENBQUMsRUFKVyxTQUFTLEtBQVQsU0FBUyxRQUlwQjtBQUNELE1BQU0sQ0FBTixJQUFZLEtBR1g7QUFIRCxXQUFZLEtBQUs7SUFDaEIsbUJBQVUsQ0FBQTtJQUNWLG1CQUFVLENBQUE7QUFDWCxDQUFDLEVBSFcsS0FBSyxLQUFMLEtBQUssUUFHaEI7QUFDRCxNQUFNLENBQUMsTUFBTSxVQUFVLEdBQUcsR0FBRyxFQUFFLENBQUMsT0FBTyxJQUFJLENBQUMsT0FBTyxDQUFDLFFBQVEsS0FBSyxPQUFPLENBQUMsQ0FBQSJ9

View File

@ -1 +1 @@
{"version":3,"file":"os.js","sourceRoot":"","sources":["../src/os.ts"],"names":[],"mappings":"AAAA,MAAM,CAAN,IAAY,SAIX;AAJD,WAAY,SAAS;IACpB,4BAAe,CAAA;IACf,8BAAiB,CAAA;IACjB,2BAAc,CAAA;AACf,CAAC,EAJW,SAAS,GAAT,SAAS,KAAT,SAAS,QAIpB;AACD,MAAM,CAAN,IAAY,KAGX;AAHD,WAAY,KAAK;IAChB,mBAAU,CAAA;IACV,mBAAU,CAAA;AACX,CAAC,EAHW,KAAK,GAAL,KAAK,KAAL,KAAK,QAGhB;AACD,MAAM,CAAC,MAAM,UAAU,GAAG,GAAG,EAAE,CAAC,OAAO,IAAI,CAAC,OAAO,CAAC,QAAQ,KAAK,OAAO,CAAC,CAAA"}
{"version":3,"sources":["../src/os.ts"],"sourcesContent":["export enum EPlatform {\r\n\tLinux = 'linux',\r\n\tWindows = 'win32',\r\n\tOSX = 'darwin'\r\n}\r\nexport enum EArch {\r\n\tx64 = '64',\r\n\tx32 = '32'\r\n}\r\nexport const is_windows = () => process && (process.platform === 'win32')\r\n"],"mappings":"AAAO,IAAK,YAAL,kBAAKA,eAAL;AACN,EAAAA,WAAA,WAAQ;AACR,EAAAA,WAAA,aAAU;AACV,EAAAA,WAAA,SAAM;AAHK,SAAAA;AAAA,GAAA;AAKL,IAAK,QAAL,kBAAKC,WAAL;AACN,EAAAA,OAAA,SAAM;AACN,EAAAA,OAAA,SAAM;AAFK,SAAAA;AAAA,GAAA;AAIL,MAAM,aAAa,MAAM,WAAY,QAAQ,aAAa;","names":["EPlatform","EArch"]}

View File

@ -1 +1 @@
export {};
export {};

View File

@ -1,2 +1,2 @@
export {};
export {};
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicGF0aHMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvcGF0aHMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IiJ9

View File

@ -1 +1 @@
{"version":3,"file":"paths.js","sourceRoot":"","sources":["../src/paths.ts"],"names":[],"mappings":""}
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}

View File

@ -1,19 +1,19 @@
interface EnvVariables {
[key: string]: string;
}
interface EnvConfig {
includes: string[];
variables: EnvVariables;
}
export interface IProfile {
includes: string[];
variables: EnvVariables;
env?: {
[key: string]: EnvConfig;
};
}
export declare const resolveConfig: (config: any) => any;
export declare const parse: (profilePath: string, profile: IProfile, options?: {
env: string;
}, rel?: string) => IProfile;
export {};
interface EnvVariables {
[key: string]: string;
}
interface EnvConfig {
includes: string[];
variables: EnvVariables;
}
export interface IProfile {
includes: string[];
variables: EnvVariables;
env?: {
[key: string]: EnvConfig;
};
}
export declare const resolveConfig: (config: any) => any;
export declare const parse: (profilePath: string, profile: IProfile, options?: {
env: string;
}, rel?: string) => IProfile;
export {};

View File

@ -1,77 +1,77 @@
import * as path from 'path';
import { REGEX_VAR } from "@polymech/core/constants";
import { sync as read } from '@polymech/fs/read';
import { sync as exists } from '@polymech/fs/exists';
import { isString } from '@polymech/core/types';
import { resolve, substitute } from './variables.js';
const _resolve = (config) => {
for (const key in config) {
if (config[key] && typeof config[key] == 'string') {
const resolved = substitute(false, config[key], config);
config[key] = resolved;
}
}
return config;
};
// @todo: Implement the function `resolveConfig`
export const resolveConfig = (config) => {
config = _resolve(config);
config = _resolve(config);
return config;
};
export const parse = (profilePath, profile, options = { env: 'default' }, rel) => {
profilePath = path.resolve(resolve(profilePath, false, profile.variables));
if (!exists(profilePath)) {
return;
}
const _profile = read(profilePath, 'json') || { includes: [], variables: {} };
_profile.includes = _profile.includes || [];
_profile.variables = _profile.variables || {};
if (options.env && _profile.env && _profile.env[options.env] && _profile.env[options.env].includes) {
profile.includes = [
...profile.includes,
..._profile.includes,
..._profile.env[options.env].includes
];
}
else {
profile.includes = [
...profile.includes,
..._profile.includes
];
}
if (options.env && _profile.env && _profile.env[options.env] && _profile.env[options.env].variables) {
profile.variables = {
...profile.variables,
..._profile.variables,
..._profile.env[options.env].variables
};
}
for (const k in _profile.variables) {
if (isString(_profile.variables[k])) {
_profile.variables[k] = substitute(false, _profile.variables[k], profile.variables);
}
}
profile.variables = { ...profile.variables, ..._profile.variables, ..._profile.env[options.env]?.variables || {} };
for (const k in profile.variables) {
if (isString(profile.variables[k])) {
profile.variables[k] = substitute(false, profile.variables[k], profile.variables);
}
}
profile.includes = Array.from(new Set(profile.includes));
profile.includes = [
...profile.includes.map((i) => {
if (!path.isAbsolute(i) && rel && !i.match(REGEX_VAR)) {
return path.resolve(`${rel}/${i}`);
}
let ret = resolve(i, false, profile.variables);
ret = path.resolve(substitute(false, ret, profile.variables));
return ret;
})
];
profile.includes = profile.includes.filter((include) => include !== null &&
include !== '');
profile.includes = Array.from(new Set(profile.includes));
return profile;
};
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHJvZmlsZS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3NyYy9wcm9maWxlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sS0FBSyxJQUFJLE1BQU0sTUFBTSxDQUFBO0FBQzVCLE9BQU8sRUFBRSxTQUFTLEVBQUUsTUFBTSwwQkFBMEIsQ0FBQTtBQUNwRCxPQUFPLEVBQUUsSUFBSSxJQUFJLElBQUksRUFBRSxNQUFNLG1CQUFtQixDQUFBO0FBQ2hELE9BQU8sRUFBRSxJQUFJLElBQUksTUFBTSxFQUFFLE1BQU0scUJBQXFCLENBQUE7QUFDcEQsT0FBTyxFQUFFLFFBQVEsRUFBRSxNQUFNLHNCQUFzQixDQUFBO0FBRS9DLE9BQU8sRUFBRSxPQUFPLEVBQUUsVUFBVSxFQUFFLE1BQU0sZ0JBQWdCLENBQUE7QUFvQnBELE1BQU0sUUFBUSxHQUFHLENBQUMsTUFBTSxFQUFFLEVBQUU7SUFDeEIsS0FBSyxNQUFNLEdBQUcsSUFBSSxNQUFNLEVBQUU7UUFDdEIsSUFBSSxNQUFNLENBQUMsR0FBRyxDQUFDLElBQUksT0FBTyxNQUFNLENBQUMsR0FBRyxDQUFDLElBQUksUUFBUSxFQUFFO1lBQy9DLE1BQU0sUUFBUSxHQUFHLFVBQVUsQ0FBQyxLQUFLLEVBQUUsTUFBTSxDQU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MsVUFBVSxDQUFDLENBQUMsQ0FBQyxJQUFJLEdBQUcsSUFBSSxDQUFDLENBQUMsQ0FBQyxLQUFLLENBQUMsU0FBUyxDQUFDLEVBQUU7Z0JBQ25ELE9BQU8sSUFBSSxDQUFDLE9BQU8sQ0FBQyxHQUFHLEdBQUcsSUFBSSxDQUFDLEVBQUUsQ0FBQyxDQUFBO2FBQ3JDO1lBQ0QsSUFBSSxHQUFHLEdBQUcsT0FBTyxDQUFDLENBQUMsRUFBRSxLQUFLLEVBQUUsT0FBTyxDQUFDLFNBQVMsQ0FBQyxDQUFBO1lBQzlDLEdBQUcsR0FBRyxJQUFJLENBQUMsT0FBTyxDQUFDLFVBQVUsQ0FBQyxLQUFLLEVBQUUsR0FBRyxFQUFFLE9BQU8sQ0FBQyxTQUFTLENBQUMsQ0FBQyxDQUFBO1lBQzdELE9BQU8sR0FBRyxDQUFBO1FBQ2QsQ0FBQyxDQUFDO0tBQUMsQ0FBQTtJQUVQLE9BQU8sQ0FBQyxRQUFRLEdBQUcsT0FBTyxDQUFDLFFBQVEsQ0FBQyxNQUFNLENBQUMsQ0FBQyxPQUFPLEVBQUUsRUFBRSxDQUNuRCxPQUFPLEtBQUssSUFBSTtRQUNoQixPQUFPLEtBQUssRUFBRSxDQUFDLENBQUE7SUFDbkIsT0FBTyxDQUFDLFFBQVEsR0FBRyxLQUFLLENBQUMsSUFBSSxDQUFDLElBQUksR0FBRyxDQUFDLE9BQU8sQ0FBQyxRQUFRLENBQUMsQ0FBQyxDQUFBO0lBQ3hELE9BQU8sT0FBTyxDQUFBO0FBQ2xCLENBQUMsQ0FBQSJ9
import * as path from 'path';
import { REGEX_VAR } from "@polymech/core/constants";
import { sync as read } from '@polymech/fs/read';
import { sync as exists } from '@polymech/fs/exists';
import { isString } from '@polymech/core/types';
import { resolve, substitute } from './variables.js';
const _resolve = (config) => {
for (const key in config) {
if (config[key] && typeof config[key] == 'string') {
const resolved = substitute(false, config[key], config);
config[key] = resolved;
}
}
return config;
};
// @todo: Implement the function `resolveConfig`
export const resolveConfig = (config) => {
config = _resolve(config);
config = _resolve(config);
return config;
};
export const parse = (profilePath, profile, options = { env: 'default' }, rel) => {
profilePath = path.resolve(resolve(profilePath, false, profile.variables));
if (!exists(profilePath)) {
return;
}
const _profile = read(profilePath, 'json') || { includes: [], variables: {} };
_profile.includes = _profile.includes || [];
_profile.variables = _profile.variables || {};
if (options.env && _profile.env && _profile.env[options.env] && _profile.env[options.env].includes) {
profile.includes = [
...profile.includes,
..._profile.includes,
..._profile.env[options.env].includes
];
}
else {
profile.includes = [
...profile.includes,
..._profile.includes
];
}
if (options.env && _profile.env && _profile.env[options.env] && _profile.env[options.env].variables) {
profile.variables = {
...profile.variables,
..._profile.variables,
..._profile.env[options.env].variables
};
}
for (const k in _profile.variables) {
if (isString(_profile.variables[k])) {
_profile.variables[k] = substitute(false, _profile.variables[k], profile.variables);
}
}
profile.variables = { ...profile.variables, ..._profile.variables, ..._profile.env[options.env]?.variables || {} };
for (const k in profile.variables) {
if (isString(profile.variables[k])) {
profile.variables[k] = substitute(false, profile.variables[k], profile.variables);
}
}
profile.includes = Array.from(new Set(profile.includes));
profile.includes = [
...profile.includes.map((i) => {
if (!path.isAbsolute(i) && rel && !i.match(REGEX_VAR)) {
return path.resolve(`${rel}/${i}`);
}
let ret = resolve(i, false, profile.variables);
ret = path.resolve(substitute(false, ret, profile.variables));
return ret;
})
];
profile.includes = profile.includes.filter((include) => include !== null &&
include !== '');
profile.includes = Array.from(new Set(profile.includes));
return profile;
};
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHJvZmlsZS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3NyYy9wcm9maWxlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sS0FBSyxJQUFJLE1BQU0sTUFBTSxDQUFBO0FBQzVCLE9BQU8sRUFBRSxTQUFTLEVBQUUs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ksQ0FBQyxPQUFPLENBQUMsVUFBVSxDQUFDLEtBQUssRUFBRSxHQUFHLEVBQUUsT0FBTyxDQUFDLFNBQVMsQ0FBQyxDQUFDLENBQUE7WUFDN0QsT0FBTyxHQUFHLENBQUE7UUFDZCxDQUFDLENBQUM7S0FBQyxDQUFBO0lBRVAsT0FBTyxDQUFDLFFBQVEsR0FBRyxPQUFPLENBQUMsUUFBUSxDQUFDLE1BQU0sQ0FBQyxDQUFDLE9BQU8sRUFBRSxFQUFFLENBQ25ELE9BQU8sS0FBSyxJQUFJO1FBQ2hCLE9BQU8sS0FBSyxFQUFFLENBQUMsQ0FBQTtJQUNuQixPQUFPLENBQUMsUUFBUSxHQUFHLEtBQUssQ0FBQyxJQUFJLENBQUMsSUFBSSxHQUFHLENBQUMsT0FBTyxDQUFDLFFBQVEsQ0FBQyxDQUFDLENBQUE7SUFDeEQsT0FBTyxPQUFPLENBQUE7QUFDbEIsQ0FBQyxDQUFBIn0=

File diff suppressed because one or more lines are too long

View File

@ -1,23 +1,23 @@
import * as CLI from 'yargs';
import { z, ZodTypeAny, ZodObject } from 'zod';
export * from './path.js';
export * from './zod_map.js';
export declare const generate_interfaces: (schemas: ZodObject<any>[], dst: string) => void;
export declare const enumerateHelpStrings: (schema: ZodTypeAny, path: string[], logger: any) => void;
export declare const yargsDefaults: (yargs: CLI.Argv) => any;
export declare const getInnerSchema: (schema: ZodTypeAny) => ZodTypeAny;
export declare const getInnerType: (type: ZodTypeAny) => any;
export declare const getDefaultValue: (schema: ZodTypeAny) => any;
export declare const getFieldDefaultValue: (schema: ZodTypeAny) => any | undefined;
export declare const getDescription: (schema: ZodTypeAny) => string | undefined;
export declare const toYargs: (yargs: CLI.Argv, zodSchema: ZodObject<any>, options?: {
onKey?: (yargs: CLI.Argv, key: string, options: any) => any;
}) => CLI.Argv;
export declare const WRITERS: {
'.json': (data: any, file: string, name: string, options: {}) => void;
};
export declare const writer: (file: string) => any;
export declare const write: (schemas: ZodObject<any>[], file: string, name: string, options: {}) => void;
export declare const combineValidatorsOr: (validators: z.ZodTypeAny[]) => z.ZodEffects<z.ZodString, string, string>;
export declare const combineValidatorsOrUsingZod: (validators: z.ZodTypeAny[]) => z.ZodTypeAny;
export declare const combineValidatorsOrUsingZod2: (validators: z.ZodTypeAny[]) => z.ZodTypeAny;
import * as CLI from 'yargs';
import { z, ZodTypeAny, ZodObject } from 'zod';
export * from './path.js';
export * from './zod_map.js';
export declare const generate_interfaces: (schemas: ZodObject<any>[], dst: string) => void;
export declare const enumerateHelpStrings: (schema: ZodTypeAny, path: string[], logger: any) => void;
export declare const yargsDefaults: (yargs: CLI.Argv) => any;
export declare const getInnerSchema: (schema: ZodTypeAny) => ZodTypeAny;
export declare const getInnerType: (type: ZodTypeAny) => any;
export declare const getDefaultValue: (schema: ZodTypeAny) => any;
export declare const getFieldDefaultValue: (schema: ZodTypeAny) => any | undefined;
export declare const getDescription: (schema: ZodTypeAny) => string | undefined;
export declare const toYargs: (yargs: CLI.Argv, zodSchema: ZodObject<any>, options?: {
onKey?: (yargs: CLI.Argv, key: string, options: any) => any;
}) => CLI.Argv;
export declare const WRITERS: {
'.json': (data: any, file: string, name: string, options: {}) => void;
};
export declare const writer: (file: string) => any;
export declare const write: (schemas: ZodObject<any>[], file: string, name: string, options: {}) => void;
export declare const combineValidatorsOr: (validators: z.ZodTypeAny[]) => z.ZodEffects<z.ZodString, string, string>;
export declare const combineValidatorsOrUsingZod: (validators: z.ZodTypeAny[]) => z.ZodTypeAny;
export declare const combineValidatorsOrUsingZod2: (validators: z.ZodTypeAny[]) => z.ZodTypeAny;

File diff suppressed because one or more lines are too long

View File

@ -1 +1 @@
export {};
export {};

View File

@ -1,22 +1,22 @@
export {};
/*
export const openapi = (data: ZodObject<any>[], file: string, name: string, options: {}) => {
const registry = new OpenAPIRegistry()
data.forEach((s) => registry.register(s.description, s))
const generator = new OpenApiGeneratorV3(registry.definitions)
const component = generator.generateComponents()
// const content = stringifyYAML(component)
return component
}
*/
/*
const yaml = (data: ZodObject<any>[], file: string, name: string, options: {}) => {
const registry = new OpenAPIRegistry()
data.forEach((s) => registry.register(s.description, s))
const generator = new OpenApiGeneratorV3(registry.definitions)
const component = generator.generateComponents()
logger.debug(`Writing schema to ${file} : ${name}`,component)
writeFS(file,stringifyYAML(component))
}
*/
export {};
/*
export const openapi = (data: ZodObject<any>[], file: string, name: string, options: {}) => {
const registry = new OpenAPIRegistry()
data.forEach((s) => registry.register(s.description, s))
const generator = new OpenApiGeneratorV3(registry.definitions)
const component = generator.generateComponents()
// const content = stringifyYAML(component)
return component
}
*/
/*
const yaml = (data: ZodObject<any>[], file: string, name: string, options: {}) => {
const registry = new OpenAPIRegistry()
data.forEach((s) => registry.register(s.description, s))
const generator = new OpenApiGeneratorV3(registry.definitions)
const component = generator.generateComponents()
logger.debug(`Writing schema to ${file} : ${name}`,component)
writeFS(file,stringifyYAML(component))
}
*/
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoib3BlbmFwaS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9zaGVtYXMvb3BlbmFwaS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUE7Ozs7Ozs7OztFQVNFO0FBQ0Y7Ozs7Ozs7OztFQVNFIn0=

View File

@ -1,30 +1,30 @@
import { z, ZodTypeAny } from 'zod';
export declare enum E_PATH {
ENSURE_PATH_EXISTS = 1,
INVALID_INPUT = 2,
ENSURE_DIRECTORY_WRITABLE = 3,
ENSURE_FILE_IS_JSON = 4,
ENSURE_PATH_IS_ABSOLUTE = 5,
ENSURE_PATH_IS_RELATIVE = 6,
GET_PATH_INFO = 7
}
export declare const Transformers: Record<string, any>;
export declare const TransformersDescription: {
description: string;
fn: any;
}[];
export declare const extendSchema: (baseSchema: z.ZodObject<any>, extend: Record<string, any>) => z.ZodObject<Record<string, z.ZodTypeAny>, "strip", z.ZodTypeAny, {
[x: string]: any;
}, {
[x: string]: any;
}>;
export declare const ENSURE_DIRECTORY_WRITABLE: (inputPath: string, ctx: any, variables: Record<string, string>) => string;
export declare const IS_VALID_STRING: (inputPath: string) => boolean;
export declare const ENSURE_PATH_EXISTS: (inputPath: string, ctx: any, variables: Record<string, string>) => string;
export declare const test: () => z.ZodObject<Record<string, z.ZodTypeAny>, "strip", z.ZodTypeAny, {
[x: string]: any;
}, {
[x: string]: any;
}>;
export declare const Templates: Record<string, any>;
export declare const extend: (baseSchema: ZodTypeAny, template: any, variables?: Record<string, string>) => z.ZodTypeAny;
import { z, ZodTypeAny } from 'zod';
export declare enum E_PATH {
ENSURE_PATH_EXISTS = 1,
INVALID_INPUT = 2,
ENSURE_DIRECTORY_WRITABLE = 3,
ENSURE_FILE_IS_JSON = 4,
ENSURE_PATH_IS_ABSOLUTE = 5,
ENSURE_PATH_IS_RELATIVE = 6,
GET_PATH_INFO = 7
}
export declare const Transformers: Record<string, any>;
export declare const TransformersDescription: {
description: string;
fn: any;
}[];
export declare const extendSchema: (baseSchema: z.ZodObject<any>, extend: Record<string, any>) => z.ZodObject<Record<string, z.ZodTypeAny>, "strip", z.ZodTypeAny, {
[x: string]: any;
}, {
[x: string]: any;
}>;
export declare const ENSURE_DIRECTORY_WRITABLE: (inputPath: string, ctx: any, variables: Record<string, string>) => string;
export declare const IS_VALID_STRING: (inputPath: string) => boolean;
export declare const ENSURE_PATH_EXISTS: (inputPath: string, ctx: any, variables: Record<string, string>) => string;
export declare const test: () => z.ZodObject<Record<string, z.ZodTypeAny>, "strip", z.ZodTypeAny, {
[x: string]: any;
}, {
[x: string]: any;
}>;
export declare const Templates: Record<string, any>;
export declare const extend: (baseSchema: ZodTypeAny, template: any, variables?: Record<string, string>) => z.ZodTypeAny;

File diff suppressed because one or more lines are too long

View File

@ -1,194 +1,194 @@
export declare enum FLAG {
/**
* Instruct for no additional extra processing
* @constant
* @type int
*/
NONE = 0,
/**
* Will instruct the pre/post processor to base-64 decode or encode
* @constant
* @type int
*/
BASE_64 = 1,
/**
* Post/Pre process the value with a user function
* @constant
* @type int
*/
USE_FUNCTION = 2,
/**
* Replace variables with local scope's variables during the post/pre process
* @constant
* @type int
*/
REPLACE_VARIABLES = 4,
/**
* Replace variables with local scope's variables during the post/pre process but evaluate the whole string
* as Javascript
* @constant
* @type int
*/
REPLACE_VARIABLES_EVALUATED = 8,
/**
* Will instruct the pre/post processor to escpape evaluated or replaced variables or expressions
* @constant
* @type int
*/
ESCAPE = 16,
/**
* Will instruct the pre/post processor to replace block calls with oridinary vanilla script
* @constant
* @type int
*/
REPLACE_BLOCK_CALLS = 32,
/**
* Will instruct the pre/post processor to remove variable delimitters/placeholders from the final string
* @constant
* @type int
*/
REMOVE_DELIMTTERS = 64,
/**
* Will instruct the pre/post processor to remove "[" ,"]" , "(" , ")" , "{", "}" , "*" , "+" , "."
* @constant
* @type int
*/
ESCAPE_SPECIAL_CHARS = 128,
/**
* Will instruct the pre/post processor to use regular expressions over string substitution
* @constant
* @type int
*/
USE_REGEX = 256,
/**
* Will instruct the pre/post processor to use Filtrex (custom bison parser, needs xexpression) over string substitution
* @constant
* @type int
*/
USE_FILTREX = 512,
/**
* Cascade entry. There are cases where #USE_FUNCTION is not enough or we'd like to avoid further type checking.
* @constant
* @type int
*/
CASCADE = 1024,
/**
* Cascade entry. There are cases where #USE_FUNCTION is not enough or we'd like to avoid further type checking.
* @constant
* @type int
*/
EXPRESSION = 2048,
/**
* Dont parse anything
* @constant
* @type int
*/
DONT_PARSE = 4096,
/**
* Convert to hex
* @constant
* @type int
*/
TO_HEX = 8192,
/**
* Convert to hex
* @constant
* @type int
*/
REPLACE_HEX = 16384,
/**
* Wait for finish
* @constant
* @type int
*/
WAIT = 32768,
/**
* Wait for finish
* @constant
* @type int
*/
DONT_ESCAPE = 65536,
/**
* Flag to mark the maximum core bit mask, after here its user land
* @constant
* @type int
*/
END = 131072
}
export declare enum EType {
Number = "Number",
String = "String",
Boolean = "Boolean",
Date = "Date",
TimeStamp = "TimeStamp",
Duration = "Duration",
Url = "Url",
UrlScheme = "Url-Scheme",
Asset = "Asset",
Symbol = "Symbol",
Value = "Value",
Values = "Values",
Attribute = "Attribute",
Parameter = "Parameter",
Operation = "Operation",
ParameterOperation = "ParameterOperation",
Template = "Template",
Arguments = "Arguments"
}
export type TVector2D = [number, number];
export type TVector3D = [number, number, number];
export type TBBox = [TVector3D, TVector3D];
export type TQuaternion = [number, number, number, number];
export type TFlags = Record<string, bigint>;
export type TExpression = string | [string | RegExp, {
[key: string]: any;
}];
export type TOptions = {
flags?: TFlags | {
[key: string]: any;
};
};
export interface IUrlScheme {
url: string;
options?: {
[key: string]: any;
};
}
export interface IAsset {
urlScheme: IUrlScheme;
options?: {
[key: string]: any;
};
}
export type TSelector = TExpression | [TExpression, {
[key: string]: any;
}];
export interface ITypeInfo {
type: string;
symbol: bigint;
}
export interface IRef {
key: string | string;
struct: {
[key: string]: any;
};
}
export interface IAttribute {
type: ITypeInfo;
value: bigint;
}
export interface IParameter {
type: ITypeInfo;
value: bigint;
}
export interface IParameterOperation {
param1: bigint;
param2: bigint;
operation: bigint;
}
export type TTemplate = string | [ITypeInfo | TSelector, {
[key: string]: any;
}];
export type TArguments = {
[key: string]: any;
} | any[];
export declare enum FLAG {
/**
* Instruct for no additional extra processing
* @constant
* @type int
*/
NONE = 0,
/**
* Will instruct the pre/post processor to base-64 decode or encode
* @constant
* @type int
*/
BASE_64 = 1,
/**
* Post/Pre process the value with a user function
* @constant
* @type int
*/
USE_FUNCTION = 2,
/**
* Replace variables with local scope's variables during the post/pre process
* @constant
* @type int
*/
REPLACE_VARIABLES = 4,
/**
* Replace variables with local scope's variables during the post/pre process but evaluate the whole string
* as Javascript
* @constant
* @type int
*/
REPLACE_VARIABLES_EVALUATED = 8,
/**
* Will instruct the pre/post processor to escpape evaluated or replaced variables or expressions
* @constant
* @type int
*/
ESCAPE = 16,
/**
* Will instruct the pre/post processor to replace block calls with oridinary vanilla script
* @constant
* @type int
*/
REPLACE_BLOCK_CALLS = 32,
/**
* Will instruct the pre/post processor to remove variable delimitters/placeholders from the final string
* @constant
* @type int
*/
REMOVE_DELIMTTERS = 64,
/**
* Will instruct the pre/post processor to remove "[" ,"]" , "(" , ")" , "{", "}" , "*" , "+" , "."
* @constant
* @type int
*/
ESCAPE_SPECIAL_CHARS = 128,
/**
* Will instruct the pre/post processor to use regular expressions over string substitution
* @constant
* @type int
*/
USE_REGEX = 256,
/**
* Will instruct the pre/post processor to use Filtrex (custom bison parser, needs xexpression) over string substitution
* @constant
* @type int
*/
USE_FILTREX = 512,
/**
* Cascade entry. There are cases where #USE_FUNCTION is not enough or we'd like to avoid further type checking.
* @constant
* @type int
*/
CASCADE = 1024,
/**
* Cascade entry. There are cases where #USE_FUNCTION is not enough or we'd like to avoid further type checking.
* @constant
* @type int
*/
EXPRESSION = 2048,
/**
* Dont parse anything
* @constant
* @type int
*/
DONT_PARSE = 4096,
/**
* Convert to hex
* @constant
* @type int
*/
TO_HEX = 8192,
/**
* Convert to hex
* @constant
* @type int
*/
REPLACE_HEX = 16384,
/**
* Wait for finish
* @constant
* @type int
*/
WAIT = 32768,
/**
* Wait for finish
* @constant
* @type int
*/
DONT_ESCAPE = 65536,
/**
* Flag to mark the maximum core bit mask, after here its user land
* @constant
* @type int
*/
END = 131072
}
export declare enum EType {
Number = "Number",
String = "String",
Boolean = "Boolean",
Date = "Date",
TimeStamp = "TimeStamp",
Duration = "Duration",
Url = "Url",
UrlScheme = "Url-Scheme",
Asset = "Asset",
Symbol = "Symbol",
Value = "Value",
Values = "Values",
Attribute = "Attribute",
Parameter = "Parameter",
Operation = "Operation",
ParameterOperation = "ParameterOperation",
Template = "Template",
Arguments = "Arguments"
}
export type TVector2D = [number, number];
export type TVector3D = [number, number, number];
export type TBBox = [TVector3D, TVector3D];
export type TQuaternion = [number, number, number, number];
export type TFlags = Record<string, bigint>;
export type TExpression = string | [string | RegExp, {
[key: string]: any;
}];
export type TOptions = {
flags?: TFlags | {
[key: string]: any;
};
};
export interface IUrlScheme {
url: string;
options?: {
[key: string]: any;
};
}
export interface IAsset {
urlScheme: IUrlScheme;
options?: {
[key: string]: any;
};
}
export type TSelector = TExpression | [TExpression, {
[key: string]: any;
}];
export interface ITypeInfo {
type: string;
symbol: bigint;
}
export interface IRef {
key: string | string;
struct: {
[key: string]: any;
};
}
export interface IAttribute {
type: ITypeInfo;
value: bigint;
}
export interface IParameter {
type: ITypeInfo;
value: bigint;
}
export interface IParameterOperation {
param1: bigint;
param2: bigint;
operation: bigint;
}
export type TTemplate = string | [ITypeInfo | TSelector, {
[key: string]: any;
}];
export type TArguments = {
[key: string]: any;
} | any[];

View File

@ -1,140 +1,140 @@
export var FLAG;
(function (FLAG) {
/**
* Instruct for no additional extra processing
* @constant
* @type int
*/
FLAG[FLAG["NONE"] = 0] = "NONE";
/**
* Will instruct the pre/post processor to base-64 decode or encode
* @constant
* @type int
*/
FLAG[FLAG["BASE_64"] = 1] = "BASE_64";
/**
* Post/Pre process the value with a user function
* @constant
* @type int
*/
FLAG[FLAG["USE_FUNCTION"] = 2] = "USE_FUNCTION";
/**
* Replace variables with local scope's variables during the post/pre process
* @constant
* @type int
*/
FLAG[FLAG["REPLACE_VARIABLES"] = 4] = "REPLACE_VARIABLES";
/**
* Replace variables with local scope's variables during the post/pre process but evaluate the whole string
* as Javascript
* @constant
* @type int
*/
FLAG[FLAG["REPLACE_VARIABLES_EVALUATED"] = 8] = "REPLACE_VARIABLES_EVALUATED";
/**
* Will instruct the pre/post processor to escpape evaluated or replaced variables or expressions
* @constant
* @type int
*/
FLAG[FLAG["ESCAPE"] = 16] = "ESCAPE";
/**
* Will instruct the pre/post processor to replace block calls with oridinary vanilla script
* @constant
* @type int
*/
FLAG[FLAG["REPLACE_BLOCK_CALLS"] = 32] = "REPLACE_BLOCK_CALLS";
/**
* Will instruct the pre/post processor to remove variable delimitters/placeholders from the final string
* @constant
* @type int
*/
FLAG[FLAG["REMOVE_DELIMTTERS"] = 64] = "REMOVE_DELIMTTERS";
/**
* Will instruct the pre/post processor to remove "[" ,"]" , "(" , ")" , "{", "}" , "*" , "+" , "."
* @constant
* @type int
*/
FLAG[FLAG["ESCAPE_SPECIAL_CHARS"] = 128] = "ESCAPE_SPECIAL_CHARS";
/**
* Will instruct the pre/post processor to use regular expressions over string substitution
* @constant
* @type int
*/
FLAG[FLAG["USE_REGEX"] = 256] = "USE_REGEX";
/**
* Will instruct the pre/post processor to use Filtrex (custom bison parser, needs xexpression) over string substitution
* @constant
* @type int
*/
FLAG[FLAG["USE_FILTREX"] = 512] = "USE_FILTREX";
/**
* Cascade entry. There are cases where #USE_FUNCTION is not enough or we'd like to avoid further type checking.
* @constant
* @type int
*/
FLAG[FLAG["CASCADE"] = 1024] = "CASCADE";
/**
* Cascade entry. There are cases where #USE_FUNCTION is not enough or we'd like to avoid further type checking.
* @constant
* @type int
*/
FLAG[FLAG["EXPRESSION"] = 2048] = "EXPRESSION";
/**
* Dont parse anything
* @constant
* @type int
*/
FLAG[FLAG["DONT_PARSE"] = 4096] = "DONT_PARSE";
/**
* Convert to hex
* @constant
* @type int
*/
FLAG[FLAG["TO_HEX"] = 8192] = "TO_HEX";
/**
* Convert to hex
* @constant
* @type int
*/
FLAG[FLAG["REPLACE_HEX"] = 16384] = "REPLACE_HEX";
/**
* Wait for finish
* @constant
* @type int
*/
FLAG[FLAG["WAIT"] = 32768] = "WAIT";
/**
* Wait for finish
* @constant
* @type int
*/
FLAG[FLAG["DONT_ESCAPE"] = 65536] = "DONT_ESCAPE";
/**
* Flag to mark the maximum core bit mask, after here its user land
* @constant
* @type int
*/
FLAG[FLAG["END"] = 131072] = "END";
})(FLAG = FLAG || (FLAG = {}));
export var EType;
(function (EType) {
EType["Number"] = "Number";
EType["String"] = "String";
EType["Boolean"] = "Boolean";
EType["Date"] = "Date";
EType["TimeStamp"] = "TimeStamp";
EType["Duration"] = "Duration";
EType["Url"] = "Url";
EType["UrlScheme"] = "Url-Scheme";
EType["Asset"] = "Asset";
EType["Symbol"] = "Symbol";
EType["Value"] = "Value";
EType["Values"] = "Values";
EType["Attribute"] = "Attribute";
EType["Parameter"] = "Parameter";
EType["Operation"] = "Operation";
EType["ParameterOperation"] = "ParameterOperation";
EType["Template"] = "Template";
EType["Arguments"] = "Arguments";
})(EType = EType || (EType = {}));
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHlwZXMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvc2hlbWFzL3R5cGVzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE1BQU0sQ0FBTixJQUFZLElBb0hYO0FBcEhELFdBQVksSUFBSTtJQUNmOzs7O09BSUc7SUFDSCwrQkFBaUIsQ0FBQTtJQUNqQjs7OztPQUlHO0lBQ0gscUNBQW9CLENBQUE7SUFDcEI7Ozs7T0FJRztJQUNILCtDQUF5QixDQUFBO0lBQ3pCOzs7O09BSUc7SUFDSCx5REFBOEIsQ0FBQTtJQUM5Qjs7Ozs7T0FLRztJQUNILDZFQUF3QyxDQUFBO0lBQ3hDOzs7O09BSUc7SUFDSCxvQ0FBbUIsQ0FBQTtJQUNuQjs7OztPQUlHO0lBQ0gsOERBQWdDLENBQUE7SUFDaEM7Ozs7T0FJRztJQUNILDBEQUE4QixDQUFBO0lBQzlCOzs7O09BSUc7SUFDSCxpRUFBaUMsQ0FBQTtJQUNqQzs7OztPQUlHO0lBQ0gsMkNBQXNCLENBQUE7SUFDdEI7Ozs7T0FJRztJQUNILCtDQUF3QixDQUFBO0lBQ3hCOzs7O09BSUc7SUFDSCx3Q0FBb0IsQ0FBQTtJQUNwQjs7OztPQUlHO0lBQ0gsOENBQXVCLENBQUE7SUFDdkI7Ozs7T0FJRztJQUNILDhDQUF3QixDQUFBO0lBQ3hCOzs7O09BSUc7SUFDSCxzQ0FBb0IsQ0FBQTtJQUNwQjs7OztPQUlHO0lBQ0gsaURBQXlCLENBQUE7SUFDekI7Ozs7T0FJRztJQUNILG1DQUFrQixDQUFBO0lBQ2xCOzs7O09BSUc7SUFDSCxpREFBeUIsQ0FBQTtJQUN6Qjs7OztPQUlHO0lBQ0gsa0NBQWlCLENBQUE7QUFDbEIsQ0FBQyxFQXBIVyxJQUFJLEdBQUosSUFBSSxLQUFKLElBQUksUUFvSGY7QUFFRCxNQUFNLENBQU4sSUFBWSxLQW9CWDtBQXBCRCxXQUFZLEtBQUs7SUFFYiwwQkFBaUIsQ0FBQTtJQUNqQiwwQkFBaUIsQ0FBQTtJQUNqQiw0QkFBbUIsQ0FBQTtJQUNuQixzQkFBYSxDQUFBO0lBQ2IsZ0NBQXVCLENBQUE7SUFDdkIsOEJBQXFCLENBQUE7SUFDckIsb0JBQVcsQ0FBQTtJQUNYLGlDQUF3QixDQUFBO0lBQ3hCLHdCQUFlLENBQUE7SUFDZiwwQkFBaUIsQ0FBQTtJQUNqQix3QkFBZSxDQUFBO0lBQ2YsMEJBQWlCLENBQUE7SUFDakIsZ0NBQXVCLENBQUE7SUFDdkIsZ0NBQXVCLENBQUE7SUFDdkIsZ0NBQXVCLENBQUE7SUFDdkIsa0RBQXlDLENBQUE7SUFDekMsOEJBQXFCLENBQUE7SUFDckIsZ0NBQXVCLENBQUE7QUFDM0IsQ0FBQyxFQXBCVyxLQUFLLEdBQUwsS0FBSyxLQUFMLEtBQUssUUFvQmhCIn0=
export var FLAG;
(function (FLAG) {
/**
* Instruct for no additional extra processing
* @constant
* @type int
*/
FLAG[FLAG["NONE"] = 0] = "NONE";
/**
* Will instruct the pre/post processor to base-64 decode or encode
* @constant
* @type int
*/
FLAG[FLAG["BASE_64"] = 1] = "BASE_64";
/**
* Post/Pre process the value with a user function
* @constant
* @type int
*/
FLAG[FLAG["USE_FUNCTION"] = 2] = "USE_FUNCTION";
/**
* Replace variables with local scope's variables during the post/pre process
* @constant
* @type int
*/
FLAG[FLAG["REPLACE_VARIABLES"] = 4] = "REPLACE_VARIABLES";
/**
* Replace variables with local scope's variables during the post/pre process but evaluate the whole string
* as Javascript
* @constant
* @type int
*/
FLAG[FLAG["REPLACE_VARIABLES_EVALUATED"] = 8] = "REPLACE_VARIABLES_EVALUATED";
/**
* Will instruct the pre/post processor to escpape evaluated or replaced variables or expressions
* @constant
* @type int
*/
FLAG[FLAG["ESCAPE"] = 16] = "ESCAPE";
/**
* Will instruct the pre/post processor to replace block calls with oridinary vanilla script
* @constant
* @type int
*/
FLAG[FLAG["REPLACE_BLOCK_CALLS"] = 32] = "REPLACE_BLOCK_CALLS";
/**
* Will instruct the pre/post processor to remove variable delimitters/placeholders from the final string
* @constant
* @type int
*/
FLAG[FLAG["REMOVE_DELIMTTERS"] = 64] = "REMOVE_DELIMTTERS";
/**
* Will instruct the pre/post processor to remove "[" ,"]" , "(" , ")" , "{", "}" , "*" , "+" , "."
* @constant
* @type int
*/
FLAG[FLAG["ESCAPE_SPECIAL_CHARS"] = 128] = "ESCAPE_SPECIAL_CHARS";
/**
* Will instruct the pre/post processor to use regular expressions over string substitution
* @constant
* @type int
*/
FLAG[FLAG["USE_REGEX"] = 256] = "USE_REGEX";
/**
* Will instruct the pre/post processor to use Filtrex (custom bison parser, needs xexpression) over string substitution
* @constant
* @type int
*/
FLAG[FLAG["USE_FILTREX"] = 512] = "USE_FILTREX";
/**
* Cascade entry. There are cases where #USE_FUNCTION is not enough or we'd like to avoid further type checking.
* @constant
* @type int
*/
FLAG[FLAG["CASCADE"] = 1024] = "CASCADE";
/**
* Cascade entry. There are cases where #USE_FUNCTION is not enough or we'd like to avoid further type checking.
* @constant
* @type int
*/
FLAG[FLAG["EXPRESSION"] = 2048] = "EXPRESSION";
/**
* Dont parse anything
* @constant
* @type int
*/
FLAG[FLAG["DONT_PARSE"] = 4096] = "DONT_PARSE";
/**
* Convert to hex
* @constant
* @type int
*/
FLAG[FLAG["TO_HEX"] = 8192] = "TO_HEX";
/**
* Convert to hex
* @constant
* @type int
*/
FLAG[FLAG["REPLACE_HEX"] = 16384] = "REPLACE_HEX";
/**
* Wait for finish
* @constant
* @type int
*/
FLAG[FLAG["WAIT"] = 32768] = "WAIT";
/**
* Wait for finish
* @constant
* @type int
*/
FLAG[FLAG["DONT_ESCAPE"] = 65536] = "DONT_ESCAPE";
/**
* Flag to mark the maximum core bit mask, after here its user land
* @constant
* @type int
*/
FLAG[FLAG["END"] = 131072] = "END";
})(FLAG || (FLAG = {}));
export var EType;
(function (EType) {
EType["Number"] = "Number";
EType["String"] = "String";
EType["Boolean"] = "Boolean";
EType["Date"] = "Date";
EType["TimeStamp"] = "TimeStamp";
EType["Duration"] = "Duration";
EType["Url"] = "Url";
EType["UrlScheme"] = "Url-Scheme";
EType["Asset"] = "Asset";
EType["Symbol"] = "Symbol";
EType["Value"] = "Value";
EType["Values"] = "Values";
EType["Attribute"] = "Attribute";
EType["Parameter"] = "Parameter";
EType["Operation"] = "Operation";
EType["ParameterOperation"] = "ParameterOperation";
EType["Template"] = "Template";
EType["Arguments"] = "Arguments";
})(EType || (EType = {}));
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHlwZXMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvc2hlbWFzL3R5cGVzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE1BQU0sQ0FBTixJQUFZLElBb0hYO0FBcEhELFdBQVksSUFBSTtJQUNmOzs7O09BSUc7SUFDSCwrQkFBaUIsQ0FBQTtJQUNqQjs7OztPQUlHO0lBQ0gscUNBQW9CLENBQUE7SUFDcEI7Ozs7T0FJRztJQUNILCtDQUF5QixDQUFBO0lBQ3pCOzs7O09BSUc7SUFDSCx5REFBOEIsQ0FBQTtJQUM5Qjs7Ozs7T0FLRztJQUNILDZFQUF3QyxDQUFBO0lBQ3hDOzs7O09BSUc7SUFDSCxvQ0FBbUIsQ0FBQTtJQUNuQjs7OztPQUlHO0lBQ0gsOERBQWdDLENBQUE7SUFDaEM7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LEtBQUssS0FBTCxLQUFLLFFBb0JoQiJ9

View File

@ -1 +1 @@
export {};
export {};

View File

@ -1,3 +1,3 @@
export {};
//import { zodToJsonSchema } from "zod-to-json-schema"
export {};
//import { zodToJsonSchema } from "zod-to-json-schema"
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidmZzLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL3NoZW1hcy92ZnMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLHNEQUFzRCJ9

View File

@ -1,46 +1,46 @@
import { ZodObject, ZodTypeAny } from 'zod';
/**
* Manages a collection of Zod schema properties
* and combines them into a single Zod object schema.
*
* @template MetaType The type of metadata you want to store for each field.
* Defaults to Record<string, unknown> if not provided.
*/
export declare class ZodMetaMap<MetaType = Record<string, unknown>> {
private fieldMap;
/**
* Adds a Zod schema under a specific key (property name),
* optionally attaching typed metadata.
*
* @param key - The name of the property in the root object.
* @param schema - The Zod schema for that property.
* @param metadata - Optional metadata object (type MetaType).
*/
add<T extends ZodTypeAny>(key: string, schema: T, metadata?: MetaType): this;
/**
* Builds and returns a root Zod object
* that combines all properties which were added.
*/
root(): ZodObject<Record<string, ZodTypeAny>>;
/**
* Retrieves the metadata for a specific key, if any.
*/
getMetadata(key: string): MetaType | undefined;
/**
* Static factory method: creates a SchemaMetaManager
* while letting you optionally specify the MetaType.
*
* Usage:
* const manager = SchemaMetaManager.create<MyFieldMeta>();
*/
static create<MT = Record<string, unknown>>(): ZodMetaMap<MT>;
/**
* Returns a basic UiSchema object that RJSF can use to render form controls.
*
* - Adds a top-level "ui:submitButtonOptions" (example).
* - For each field, we set `ui:title` (uppercase key),
* `ui:description` (from Zod's .describe() if available),
* and a naive placeholder from the default value (if parse(undefined) succeeds).
*/
getUISchema(): Record<string, unknown>;
}
import { ZodObject, ZodTypeAny } from 'zod';
/**
* Manages a collection of Zod schema properties
* and combines them into a single Zod object schema.
*
* @template MetaType The type of metadata you want to store for each field.
* Defaults to Record<string, unknown> if not provided.
*/
export declare class ZodMetaMap<MetaType = Record<string, unknown>> {
private fieldMap;
/**
* Adds a Zod schema under a specific key (property name),
* optionally attaching typed metadata.
*
* @param key - The name of the property in the root object.
* @param schema - The Zod schema for that property.
* @param metadata - Optional metadata object (type MetaType).
*/
add<T extends ZodTypeAny>(key: string, schema: T, metadata?: MetaType): this;
/**
* Builds and returns a root Zod object
* that combines all properties which were added.
*/
root(): ZodObject<Record<string, ZodTypeAny>>;
/**
* Retrieves the metadata for a specific key, if any.
*/
getMetadata(key: string): MetaType | undefined;
/**
* Static factory method: creates a SchemaMetaManager
* while letting you optionally specify the MetaType.
*
* Usage:
* const manager = SchemaMetaManager.create<MyFieldMeta>();
*/
static create<MT = Record<string, unknown>>(): ZodMetaMap<MT>;
/**
* Returns a basic UiSchema object that RJSF can use to render form controls.
*
* - Adds a top-level "ui:submitButtonOptions" (example).
* - For each field, we set `ui:title` (uppercase key),
* `ui:description` (from Zod's .describe() if available),
* and a naive placeholder from the default value (if parse(undefined) succeeds).
*/
getUISchema(): Record<string, unknown>;
}

View File

@ -1,99 +1,99 @@
import { z } from 'zod';
/**
* Manages a collection of Zod schema properties
* and combines them into a single Zod object schema.
*
* @template MetaType The type of metadata you want to store for each field.
* Defaults to Record<string, unknown> if not provided.
*/
export class ZodMetaMap {
fieldMap = new Map();
/**
* Adds a Zod schema under a specific key (property name),
* optionally attaching typed metadata.
*
* @param key - The name of the property in the root object.
* @param schema - The Zod schema for that property.
* @param metadata - Optional metadata object (type MetaType).
*/
add(key, schema, metadata) {
this.fieldMap.set(key, { schema, metadata });
return this;
}
/**
* Builds and returns a root Zod object
* that combines all properties which were added.
*/
root() {
const shape = {};
for (const [key, { schema }] of this.fieldMap.entries()) {
shape[key] = schema;
}
return z.object(shape);
}
/**
* Retrieves the metadata for a specific key, if any.
*/
getMetadata(key) {
return this.fieldMap.get(key)?.metadata;
}
/**
* Static factory method: creates a SchemaMetaManager
* while letting you optionally specify the MetaType.
*
* Usage:
* const manager = SchemaMetaManager.create<MyFieldMeta>();
*/
static create() {
return new ZodMetaMap();
}
/**
* Returns a basic UiSchema object that RJSF can use to render form controls.
*
* - Adds a top-level "ui:submitButtonOptions" (example).
* - For each field, we set `ui:title` (uppercase key),
* `ui:description` (from Zod's .describe() if available),
* and a naive placeholder from the default value (if parse(undefined) succeeds).
*/
getUISchema() {
// Start with some top-level UI schema config (optional)
const uiSchema = {
'ui:submitButtonOptions': {
props: {
disabled: false,
className: 'btn btn-info',
},
norender: false,
submitText: 'Submit',
},
};
for (const [key, { schema }] of this.fieldMap.entries()) {
let fieldUi = {};
// Use the Zod description if available
// (Accessing `._def.description` is private/hacky, but commonly done.)
const sAny = schema;
if (sAny?._def?.description) {
fieldUi['ui:description'] = sAny._def.description;
}
// RJSF usually reads 'title' from JSON schema. But if you want
// to override it in UI schema, you can do so:
fieldUi['ui:title'] = key[0].toUpperCase() + key.substr(1).toLowerCase();
// If the Zod schema allows a default, we can parse(undefined) to get it.
try {
const defaultVal = schema.parse(undefined);
// There's no official 'ui:default' in RJSF, but you could do a placeholder:
fieldUi['ui:placeholder'] = defaultVal;
}
catch {
// no default
}
fieldUi = {
...fieldUi,
...this.getMetadata(key),
};
uiSchema[key] = fieldUi;
}
return uiSchema;
}
}
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiem9kX21hcC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9zaGVtYXMvem9kX21hcC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQUUsQ0FBQyxFQUF5QixNQUFNLEtBQUssQ0FBQztBQUUvQzs7Ozs7O0dBTUc7QUFDSCxNQUFNLE9BQU8sVUFBVTtJQUNYLFFBQVEsR0FBRyxJQUFJLEdBQUcsRUFHdkIsQ0FBQztJQUVKOzs7Ozs7O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UNwQixDQUFDO0NBQ0oifQ==
import { z } from 'zod';
/**
* Manages a collection of Zod schema properties
* and combines them into a single Zod object schema.
*
* @template MetaType The type of metadata you want to store for each field.
* Defaults to Record<string, unknown> if not provided.
*/
export class ZodMetaMap {
fieldMap = new Map();
/**
* Adds a Zod schema under a specific key (property name),
* optionally attaching typed metadata.
*
* @param key - The name of the property in the root object.
* @param schema - The Zod schema for that property.
* @param metadata - Optional metadata object (type MetaType).
*/
add(key, schema, metadata) {
this.fieldMap.set(key, { schema, metadata });
return this;
}
/**
* Builds and returns a root Zod object
* that combines all properties which were added.
*/
root() {
const shape = {};
for (const [key, { schema }] of this.fieldMap.entries()) {
shape[key] = schema;
}
return z.object(shape);
}
/**
* Retrieves the metadata for a specific key, if any.
*/
getMetadata(key) {
return this.fieldMap.get(key)?.metadata;
}
/**
* Static factory method: creates a SchemaMetaManager
* while letting you optionally specify the MetaType.
*
* Usage:
* const manager = SchemaMetaManager.create<MyFieldMeta>();
*/
static create() {
return new ZodMetaMap();
}
/**
* Returns a basic UiSchema object that RJSF can use to render form controls.
*
* - Adds a top-level "ui:submitButtonOptions" (example).
* - For each field, we set `ui:title` (uppercase key),
* `ui:description` (from Zod's .describe() if available),
* and a naive placeholder from the default value (if parse(undefined) succeeds).
*/
getUISchema() {
// Start with some top-level UI schema config (optional)
const uiSchema = {
'ui:submitButtonOptions': {
props: {
disabled: false,
className: 'btn btn-info',
},
norender: false,
submitText: 'Submit',
},
};
for (const [key, { schema }] of this.fieldMap.entries()) {
let fieldUi = {};
// Use the Zod description if available
// (Accessing `._def.description` is private/hacky, but commonly done.)
const sAny = schema;
if (sAny?._def?.description) {
fieldUi['ui:description'] = sAny._def.description;
}
// RJSF usually reads 'title' from JSON schema. But if you want
// to override it in UI schema, you can do so:
fieldUi['ui:title'] = key[0].toUpperCase() + key.substr(1).toLowerCase();
// If the Zod schema allows a default, we can parse(undefined) to get it.
try {
const defaultVal = schema.parse(undefined);
// There's no official 'ui:default' in RJSF, but you could do a placeholder:
fieldUi['ui:placeholder'] = defaultVal;
}
catch {
// no default
}
fieldUi = {
...fieldUi,
...this.getMetadata(key),
};
uiSchema[key] = fieldUi;
}
return uiSchema;
}
}
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiem9kX21hcC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9zaGVtYXMvem9kX21hcC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQUUsQ0FBQyxFQUF5QixNQUFNLEtBQUssQ0FBQztBQUUvQzs7Ozs7O0dBTUc7QUFDSCxNQUFNLE9BQU8sVUFBVTtJQUNYLFFBQVEsR0FBRyxJQUFJLEdBQUcsRUFHdkIsQ0FBQztJQUVKOzs7Ozs7O09BT0c7SUFDSCxHQUFHLENBQXVCLEdBQVcsRUFBRSxNQUFTLEVBQUUsUUFBbUI7UUFDakUsSUFBSSxDQUFDLFFBQVEsQ0FBQyxHQUFHLENBQUMsR0FBRyxFQUFFLEVBQUUsTUFBTSxFQUFFLFFBQVEsRUFBRSxDQUFDLENBQUM7UUFDN0MsT0FBTyxJQUFJLENBQUM7SUFDaEIsQ0FBQztJQUVEOzs7T0FHRztJQUNILElBQUk7UUFDQSxNQUFNLEtBQUssR0FBK0IsRUFBRSxDQUFDO1FBQzdDLEtBQUssTUFBTSxDQUFDLEdBQUcsRUFBRSxFQUFFLE1BQU0sRUFBRSxDQUFDLElBQUksSUFBSSxDQUFDLFFBQVEsQ0FBQyxPQUFPLEVBQUUsRUFBRSxDQUFDO1lBQ3RELEtBQUssQ0FBQyxHQUFHLENBQUMsR0FBRyxNQUFNLENBQUM7UUFDeEIsQ0FBQztRQUNELE9BQU8sQ0FBQyxDQUFDLE1BQU0sQ0FBQyxLQUFLLENBQUMsQ0FBQztJQUMzQixDQUFDO0lBRUQ7O09BRUc7SUFDSCxXQUFXLENBQUMsR0FBVztRQUNuQix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DQUFDLFdBQVcsRUFBRSxDQUFBO1lBRXhFLHlFQUF5RTtZQUN6RSxJQUFJLENBQUM7Z0JBQ0QsTUFBTSxVQUFVLEdBQUcsTUFBTSxDQUFDLEtBQUssQ0FBQyxTQUFTLENBQUMsQ0FBQztnQkFDM0MsNEVBQTRFO2dCQUM1RSxPQUFPLENBQUMsZ0JBQWdCLENBQUMsR0FBRyxVQUFVLENBQUM7WUFDM0MsQ0FBQztZQUFDLE1BQU0sQ0FBQztnQkFDTCxhQUFhO1lBQ2pCLENBQUM7WUFDRCxPQUFPLEdBQUc7Z0JBQ04sR0FBRyxPQUFPO2dCQUNWLEdBQUcsSUFBSSxDQUFDLFdBQVcsQ0FBQyxHQUFHLENBQUM7YUFDM0IsQ0FBQTtZQUNELFFBQVEsQ0FBQyxHQUFHLENBQUMsR0FBRyxPQUFPLENBQUM7UUFDNUIsQ0FBQztRQUNELE9BQU8sUUFBUSxDQUFDO0lBQ3BCLENBQUM7Q0FDSiJ9

View File

@ -1,264 +1,264 @@
export interface IConvertedFileMeta {
photoData: Blob;
objectUrl: string;
name: string;
type: string;
}
export interface IUploadedFileMeta {
downloadUrl: string;
contentType?: string | null;
fullPath: string;
name: string;
type: string;
size: number;
timeCreated: string;
updated: string;
data: any;
}
export type IModerationStatus = 'draft' | 'awaiting-moderation' | 'rejected' | 'accepted';
export interface IModerable {
moderation: IModerationStatus;
_createdBy?: string;
_id?: string;
}
export type ISODateString = string;
export interface IUserState {
user?: IUser;
}
export interface IUser {
_authID: string;
_lastActive?: ISODateString;
userName: string;
displayName: string;
moderation: IModerationStatus;
verified: boolean;
badges?: IUserBadges;
coverImages: IUploadedFileMeta[] | IConvertedFileMeta[];
links: IExternalLink[];
userRoles?: string[];
about?: string | null;
DHSite_id?: number;
DHSite_mention_name?: string;
country?: string | null;
year?: ISODateString;
stats?: IUserStats;
/** keep a map of all howto ids that a user has voted as useful */
votedUsefulHowtos?: {
[howtoId: string]: boolean;
};
/** keep a map of all Research ids that a user has voted as useful */
votedUsefulResearch?: {
[researchId: string]: boolean;
};
notifications?: INotification[];
}
interface IUserBadges {
verified: boolean;
}
interface IExternalLink {
url: string;
label: 'email' | 'website' | 'discord' | 'bazar' | 'forum' | 'social media' | 'facebook' | 'instagram' | 'github' | 'linkedin' | 'map' | 'forum' | 'marketplace' | 'other' | 'other-2';
}
/**
* Track the ids and moderation status as summary for user stats
*/
interface IUserStats {
userCreatedHowtos: {
[id: string]: IModerationStatus;
};
userCreatedResearch: {
[id: string]: IModerationStatus;
};
userCreatedEvents: {
[id: string]: IModerationStatus;
};
}
export type IUserDB = IUser;
export interface INotification {
_id: string;
_created: string;
triggeredBy: {
displayName: string;
userId: string;
};
relevantUrl?: string;
type: NotificationType;
read: boolean;
}
export type NotificationType = 'new_comment' | 'howto_useful' | 'new_comment_research' | 'research_useful';
export type PlasticTypeLabel = 'pet' | 'hdpe' | 'pvc' | 'ldpe' | 'pp' | 'ps' | 'other';
export type MachineBuilderXpLabel = 'electronics' | 'machining' | 'welding' | 'assembling' | 'mould-making' | 'development';
export type WorkspaceType = 'shredder' | 'sheetpress' | 'extrusion' | 'injection' | 'mix' | 'machine shop' | 'service' | 'educational' | 'supplier' | '3dprint';
export type TOSR_User_Type = 'Precious Plastic' | 'OSR-Plastic' | 'Unknown' | 'User Contact' | 'Crawler' | 'Fablab' | 'OSE' | 'Meetup';
export interface IPlasticType {
label: PlasticTypeLabel;
number: string;
imageSrc?: string;
}
export interface IProfileType {
label: string;
imageSrc?: string;
cleanImageSrc?: string;
cleanImageVerifiedSrc?: string;
textLabel?: string;
}
export interface IWorkspaceType {
label: WorkspaceType;
imageSrc?: string;
textLabel?: string;
subText?: string;
}
export interface IMAchineBuilderXp {
label: MachineBuilderXpLabel;
}
export interface IOpeningHours {
day: string;
openFrom: string;
openTo: string;
}
/**
* PP users can have a bunch of custom meta fields depending on profile type
*/
export interface IUserPP extends IUser {
profileType: string;
workspaceType?: WorkspaceType | null;
mapPinDescription?: string | null;
openingHours?: IOpeningHours[];
collectedPlasticTypes?: PlasticTypeLabel[] | null;
machineBuilderXp?: IMAchineBuilderXp[] | null;
isExpert?: boolean | null;
isV4Member?: boolean | null;
}
export type IUserPPDB = IUserPP;
export interface IGeoLocation {
lng: number;
lat: number;
}
export interface IOA_UserDetail {
lastActive: Date;
profilePicUrl: string;
shortDescription: string;
heroImageUrl: string;
name: string;
profileUrl: string;
}
export interface IGeo_Administrative {
name: string;
description: string;
isoName: string;
order: number;
adminLevel: number;
isoCode: string;
wikidataId: string;
geonameId: number;
}
export interface IGeo_Informative {
name: string;
description: string;
order: number;
isoCode: string;
wikidataId: string;
geonameId: number;
}
export interface IGeo_LocalityInfo {
administrative: IGeo_Administrative[];
informative: IGeo_Informative[];
}
export interface IGeo {
latitude: number;
longitude: number;
continent: string;
lookupSource: string;
continentCode: string;
localityLanguageRequested: string;
city: string;
countryName: string;
postcode: string;
countryCode: string;
principalSubdivision: string;
principalSubdivisionCode: string;
plusCode: string;
locality: string;
localityInfo: IGeo_LocalityInfo;
}
export interface IUrl {
name: string;
url: string;
}
export interface IOA_Service {
welding: boolean;
assembling: boolean;
machining: boolean;
electronics: boolean;
molds: boolean;
}
export interface IImage {
url: string;
}
export interface IOSRUserData {
urls: IUrl[];
description: string;
services: IOA_Service[];
title: string;
images: IImage[];
jsError?: boolean;
}
export interface I_OSR_USER {
_created: Date;
location: IGeoLocation;
_modified: Date;
_id: string;
detail: IOA_UserDetail;
type: string;
_deleted: boolean;
moderation: string;
geo: IGeo;
data: IOSRUserData;
}
export interface I_USER_SHORT {
name: string;
email: string;
bazar: string;
web: string;
social: string;
censored: string;
lastActive: Date;
ig: string;
}
export type IProduct = {
slug: string;
name: string;
category: string;
code: string;
forum?: string;
forumCategory?: string;
version?: string;
cart_id?: string;
};
export interface IDiscourseUser {
id: number;
username: string;
name: string;
avatar_template: string;
active: boolean;
admin: boolean;
moderator: boolean;
last_seen_at: any;
last_emailed_at: string;
created_at: string;
last_seen_age: any;
last_emailed_age: number;
created_at_age: number;
trust_level: number;
manual_locked_trust_level: any;
flag_level: number;
title: any;
time_read: number;
staged: boolean;
days_visited: number;
posts_read_count: number;
topics_entered: number;
post_count: number;
}
export * from './types_kbot.js';
export * from './types_common.js';
export interface IConvertedFileMeta {
photoData: Blob;
objectUrl: string;
name: string;
type: string;
}
export interface IUploadedFileMeta {
downloadUrl: string;
contentType?: string | null;
fullPath: string;
name: string;
type: string;
size: number;
timeCreated: string;
updated: string;
data: any;
}
export type IModerationStatus = 'draft' | 'awaiting-moderation' | 'rejected' | 'accepted';
export interface IModerable {
moderation: IModerationStatus;
_createdBy?: string;
_id?: string;
}
export type ISODateString = string;
export interface IUserState {
user?: IUser;
}
export interface IUser {
_authID: string;
_lastActive?: ISODateString;
userName: string;
displayName: string;
moderation: IModerationStatus;
verified: boolean;
badges?: IUserBadges;
coverImages: IUploadedFileMeta[] | IConvertedFileMeta[];
links: IExternalLink[];
userRoles?: string[];
about?: string | null;
DHSite_id?: number;
DHSite_mention_name?: string;
country?: string | null;
year?: ISODateString;
stats?: IUserStats;
/** keep a map of all howto ids that a user has voted as useful */
votedUsefulHowtos?: {
[howtoId: string]: boolean;
};
/** keep a map of all Research ids that a user has voted as useful */
votedUsefulResearch?: {
[researchId: string]: boolean;
};
notifications?: INotification[];
}
interface IUserBadges {
verified: boolean;
}
interface IExternalLink {
url: string;
label: 'email' | 'website' | 'discord' | 'bazar' | 'forum' | 'social media' | 'facebook' | 'instagram' | 'github' | 'linkedin' | 'map' | 'forum' | 'marketplace' | 'other' | 'other-2';
}
/**
* Track the ids and moderation status as summary for user stats
*/
interface IUserStats {
userCreatedHowtos: {
[id: string]: IModerationStatus;
};
userCreatedResearch: {
[id: string]: IModerationStatus;
};
userCreatedEvents: {
[id: string]: IModerationStatus;
};
}
export type IUserDB = IUser;
export interface INotification {
_id: string;
_created: string;
triggeredBy: {
displayName: string;
userId: string;
};
relevantUrl?: string;
type: NotificationType;
read: boolean;
}
export type NotificationType = 'new_comment' | 'howto_useful' | 'new_comment_research' | 'research_useful';
export type PlasticTypeLabel = 'pet' | 'hdpe' | 'pvc' | 'ldpe' | 'pp' | 'ps' | 'other';
export type MachineBuilderXpLabel = 'electronics' | 'machining' | 'welding' | 'assembling' | 'mould-making' | 'development';
export type WorkspaceType = 'shredder' | 'sheetpress' | 'extrusion' | 'injection' | 'mix' | 'machine shop' | 'service' | 'educational' | 'supplier' | '3dprint';
export type TOSR_User_Type = 'Precious Plastic' | 'OSR-Plastic' | 'Unknown' | 'User Contact' | 'Crawler' | 'Fablab' | 'OSE' | 'Meetup';
export interface IPlasticType {
label: PlasticTypeLabel;
number: string;
imageSrc?: string;
}
export interface IProfileType {
label: string;
imageSrc?: string;
cleanImageSrc?: string;
cleanImageVerifiedSrc?: string;
textLabel?: string;
}
export interface IWorkspaceType {
label: WorkspaceType;
imageSrc?: string;
textLabel?: string;
subText?: string;
}
export interface IMAchineBuilderXp {
label: MachineBuilderXpLabel;
}
export interface IOpeningHours {
day: string;
openFrom: string;
openTo: string;
}
/**
* PP users can have a bunch of custom meta fields depending on profile type
*/
export interface IUserPP extends IUser {
profileType: string;
workspaceType?: WorkspaceType | null;
mapPinDescription?: string | null;
openingHours?: IOpeningHours[];
collectedPlasticTypes?: PlasticTypeLabel[] | null;
machineBuilderXp?: IMAchineBuilderXp[] | null;
isExpert?: boolean | null;
isV4Member?: boolean | null;
}
export type IUserPPDB = IUserPP;
export interface IGeoLocation {
lng: number;
lat: number;
}
export interface IOA_UserDetail {
lastActive: Date;
profilePicUrl: string;
shortDescription: string;
heroImageUrl: string;
name: string;
profileUrl: string;
}
export interface IGeo_Administrative {
name: string;
description: string;
isoName: string;
order: number;
adminLevel: number;
isoCode: string;
wikidataId: string;
geonameId: number;
}
export interface IGeo_Informative {
name: string;
description: string;
order: number;
isoCode: string;
wikidataId: string;
geonameId: number;
}
export interface IGeo_LocalityInfo {
administrative: IGeo_Administrative[];
informative: IGeo_Informative[];
}
export interface IGeo {
latitude: number;
longitude: number;
continent: string;
lookupSource: string;
continentCode: string;
localityLanguageRequested: string;
city: string;
countryName: string;
postcode: string;
countryCode: string;
principalSubdivision: string;
principalSubdivisionCode: string;
plusCode: string;
locality: string;
localityInfo: IGeo_LocalityInfo;
}
export interface IUrl {
name: string;
url: string;
}
export interface IOA_Service {
welding: boolean;
assembling: boolean;
machining: boolean;
electronics: boolean;
molds: boolean;
}
export interface IImage {
url: string;
}
export interface IOSRUserData {
urls: IUrl[];
description: string;
services: IOA_Service[];
title: string;
images: IImage[];
jsError?: boolean;
}
export interface I_OSR_USER {
_created: Date;
location: IGeoLocation;
_modified: Date;
_id: string;
detail: IOA_UserDetail;
type: string;
_deleted: boolean;
moderation: string;
geo: IGeo;
data: IOSRUserData;
}
export interface I_USER_SHORT {
name: string;
email: string;
bazar: string;
web: string;
social: string;
censored: string;
lastActive: Date;
ig: string;
}
export type IProduct = {
slug: string;
name: string;
category: string;
code: string;
forum?: string;
forumCategory?: string;
version?: string;
cart_id?: string;
};
export interface IDiscourseUser {
id: number;
username: string;
name: string;
avatar_template: string;
active: boolean;
admin: boolean;
moderator: boolean;
last_seen_at: any;
last_emailed_at: string;
created_at: string;
last_seen_age: any;
last_emailed_age: number;
created_at_age: number;
trust_level: number;
manual_locked_trust_level: any;
flag_level: number;
title: any;
time_read: number;
staged: boolean;
days_visited: number;
posts_read_count: number;
topics_entered: number;
post_count: number;
}
export * from './types_kbot.js';
export * from './types_common.js';

View File

@ -1,3 +1,3 @@
export * from './types_kbot.js';
export * from './types_common.js';
export * from './types_kbot.js';
export * from './types_common.js';
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHlwZXMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvdHlwZXMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBeVdJLGNBQWMsaUJBQWlCLENBQUE7QUFDL0IsY0FBYyxtQkFBbUIsQ0FBQSJ9

File diff suppressed because one or more lines are too long

View File

@ -1,6 +1,6 @@
export interface IOptionsCache {
skip?: boolean;
clear?: boolean;
namespace?: string;
cacheRoot?: string;
}
export interface IOptionsCache {
skip?: boolean;
clear?: boolean;
namespace?: string;
cacheRoot?: string;
}

View File

@ -1,2 +1,2 @@
export {};
export {};
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHlwZXNfY2FjaGUuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvdHlwZXNfY2FjaGUudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IiJ9

View File

@ -1 +1 @@
{"version":3,"file":"types_cache.js","sourceRoot":"","sources":["../src/types_cache.ts"],"names":[],"mappings":""}
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}

View File

@ -1,114 +1,114 @@
export interface GeoPos {
lon: number;
lat: number;
}
export interface PATH_INFO {
DIR?: string;
NAME?: string;
FILE_NAME?: string;
FILE_EXT?: string;
PATH?: string;
IS_FILE?: boolean;
IS_FOLDER?: boolean;
IS_EXPRESSION?: boolean;
IS_GLOB?: boolean;
path: string;
GLOB: string;
GLOB_EXTENSIONS: string[];
FILES: string[];
}
export interface IDeeplConfig {
auth_key: string;
free_api: boolean;
}
export interface IIgConfig {
username: string;
password: string;
}
export interface ICsCartConfigMySQL {
host: string;
user: string;
database: string;
password: string;
}
export interface ICsCartConfig {
token: string;
url: string;
username: string;
siteUrl?: string;
timeout?: number;
language?: string;
userToken?: string;
mysql?: ICsCartConfigMySQL;
}
export interface IGiteaConfig {
token: string;
url: string;
}
export interface IDiscourseConfig {
host: string;
key: string;
username: string;
rateLimitConcurrency: number;
}
export interface IScaleserp {
key: string;
}
export interface IOSRConfig {
deepl: IDeeplConfig;
ig: IIgConfig;
cscart: ICsCartConfig;
discourse: IDiscourseConfig;
discourse_admin: IDiscourseConfig;
instagram: IIgConfig;
urls: any;
scaleserp?: IScaleserp;
gitea?: IGiteaConfig;
}
export interface SRC_VARIABLES {
SRC_PATH: string;
SRC_DIR: string;
SRC_NAME: string;
SRC_FILE_NAME: string;
SRC_FILE_EXT: string;
SRC_IS_FILE: boolean;
SRC_IS_FOLDER: boolean;
SRC_IS_EXPRESSION: boolean;
SRC_IS_GLOB: boolean;
SRC_GLOB: string;
SRC_GLOB_EXTENSIONS: string[];
SRC_FILES: string[];
}
export interface DST_VARIABLES {
DST_PATH: string;
DST_DIR: string;
DST_NAME: string;
DST_FILE_NAME: string;
DST_FILE_EXT: string;
DST_IS_FILE: boolean;
DST_IS_FOLDER: boolean;
DST_IS_EXPRESSION: boolean;
DST_IS_GLOB: boolean;
DST_GLOB: string;
DST_GLOB_EXTENSIONS: string[];
DST_FILES: string[];
}
export type PATH_VARIABLES = SRC_VARIABLES & DST_VARIABLES;
export interface IOptionsBase {
variables: PATH_VARIABLES;
}
export interface PATH_INFO {
DIR?: string;
FILE_EXT?: string;
FILE_NAME?: string;
FILES: string[];
GLOB_EXTENSIONS: string[];
GLOB: string;
IS_EXPRESSION?: boolean;
IS_FILE?: boolean;
IS_FOLDER?: boolean;
IS_GLOB?: boolean;
NAME?: string;
path: string;
PATH?: string;
}
export interface GeoPos {
lon: number;
lat: number;
}
export interface PATH_INFO {
DIR?: string;
NAME?: string;
FILE_NAME?: string;
FILE_EXT?: string;
PATH?: string;
IS_FILE?: boolean;
IS_FOLDER?: boolean;
IS_EXPRESSION?: boolean;
IS_GLOB?: boolean;
path: string;
GLOB: string;
GLOB_EXTENSIONS: string[];
FILES: string[];
}
export interface IDeeplConfig {
auth_key: string;
free_api: boolean;
}
export interface IIgConfig {
username: string;
password: string;
}
export interface ICsCartConfigMySQL {
host: string;
user: string;
database: string;
password: string;
}
export interface ICsCartConfig {
token: string;
url: string;
username: string;
siteUrl?: string;
timeout?: number;
language?: string;
userToken?: string;
mysql?: ICsCartConfigMySQL;
}
export interface IGiteaConfig {
token: string;
url: string;
}
export interface IDiscourseConfig {
host: string;
key: string;
username: string;
rateLimitConcurrency: number;
}
export interface IScaleserp {
key: string;
}
export interface IOSRConfig {
deepl: IDeeplConfig;
ig: IIgConfig;
cscart: ICsCartConfig;
discourse: IDiscourseConfig;
discourse_admin: IDiscourseConfig;
instagram: IIgConfig;
urls: any;
scaleserp?: IScaleserp;
gitea?: IGiteaConfig;
}
export interface SRC_VARIABLES {
SRC_PATH: string;
SRC_DIR: string;
SRC_NAME: string;
SRC_FILE_NAME: string;
SRC_FILE_EXT: string;
SRC_IS_FILE: boolean;
SRC_IS_FOLDER: boolean;
SRC_IS_EXPRESSION: boolean;
SRC_IS_GLOB: boolean;
SRC_GLOB: string;
SRC_GLOB_EXTENSIONS: string[];
SRC_FILES: string[];
}
export interface DST_VARIABLES {
DST_PATH: string;
DST_DIR: string;
DST_NAME: string;
DST_FILE_NAME: string;
DST_FILE_EXT: string;
DST_IS_FILE: boolean;
DST_IS_FOLDER: boolean;
DST_IS_EXPRESSION: boolean;
DST_IS_GLOB: boolean;
DST_GLOB: string;
DST_GLOB_EXTENSIONS: string[];
DST_FILES: string[];
}
export type PATH_VARIABLES = SRC_VARIABLES & DST_VARIABLES;
export interface IOptionsBase {
variables: PATH_VARIABLES;
}
export interface PATH_INFO {
DIR?: string;
FILE_EXT?: string;
FILE_NAME?: string;
FILES: string[];
GLOB_EXTENSIONS: string[];
GLOB: string;
IS_EXPRESSION?: boolean;
IS_FILE?: boolean;
IS_FOLDER?: boolean;
IS_GLOB?: boolean;
NAME?: string;
path: string;
PATH?: string;
}

View File

@ -1,2 +1,2 @@
export {};
export {};
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHlwZXNfY29tbW9uLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vc3JjL3R5cGVzX2NvbW1vbi50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiIn0=

View File

@ -1 +1 @@
{"version":3,"file":"types_common.js","sourceRoot":"","sources":["../src/types_common.ts"],"names":[],"mappings":""}
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}

View File

@ -1,296 +1,296 @@
/**
* Flags to describe a block's execution behavior.
*
* @enum {integer} module=xide/types/RUN_FLAGS
* @memberOf module=xide/types
*/
export declare enum RUN_FLAGS {
/**
* The block can execute child blocks.
* @constant
* @type int
*/
CHILDREN = 32,
/**
* Block is waiting for a message => EXECUTION_STATE==RUNNING
* @constant
* @type int
*/
WAIT = 32768
}
/**
* Flags to describe a block's execution state.
*
* @enum {integer} module=xide/types/EXECUTION_STATE
* @memberOf module=xide/types
*/
export declare enum EXECUTION_STATE {
/**
* The block is doing nothing and also has done nothing. The is the default state
* @constant
* @type int
*/
NONE = 0,
/**
* The block is running.
* @constant
* @type int
*/
RUNNING = 1,
/**
* The block is an error state.
* @constant
* @type int
*/
ERROR = 2,
/**
* The block is in an paused state.
* @constant
* @type int
*/
PAUSED = 4,
/**
* The block is an finished state, ready to be cleared to "NONE" at the next frame.
* @constant
* @type int
*/
FINISH = 8,
/**
* The block is an stopped state, ready to be cleared to "NONE" at the next frame.
* @constant
* @type int
*/
STOPPED = 16,
/**
* The block has been launched once...
* @constant
* @type int
*/
ONCE = 2147483648,
/**
* Block will be reseted next frame
* @constant
* @type int
*/
RESET_NEXT_FRAME = 8388608,
/**
* Block is locked and so no further inputs can be activated.
* @constant
* @type int
*/
LOCKED = 536870912
}
export declare enum BLOCK_MODE {
NORMAL = 0,
UPDATE_WIDGET_PROPERTY = 1
}
/**
* Flags to describe a block's belonging to a standard signal.
* @enum {integer} module=xblox/types/BLOCK_OUTLET
* @memberOf module=xblox/types
*/
export declare enum BLOCK_OUTLET {
NONE = 0,
PROGRESS = 1,
ERROR = 2,
PAUSED = 4,
FINISH = 8,
STOPPED = 16
}
export declare enum EVENTS {
ON_RUN_BLOCK = "onRunBlock",
ON_RUN_BLOCK_FAILED = "onRunBlockFailed",
ON_RUN_BLOCK_SUCCESS = "onRunBlockSuccess",
ON_BLOCK_SELECTED = "onItemSelected",
ON_BLOCK_UNSELECTED = "onBlockUnSelected",
ON_BLOCK_EXPRESSION_FAILED = "onExpressionFailed",
ON_BUILD_BLOCK_INFO_LIST = "onBuildBlockInfoList",
ON_BUILD_BLOCK_INFO_LIST_END = "onBuildBlockInfoListEnd",
ON_BLOCK_PROPERTY_CHANGED = "onBlockPropertyChanged",
ON_SCOPE_CREATED = "onScopeCreated",
ON_VARIABLE_CHANGED = "onVariableChanged",
ON_CREATE_VARIABLE_CI = "onCreateVariableCI"
}
export declare enum BlockType {
AssignmentExpression = "AssignmentExpression",
ArrayExpression = "ArrayExpression",
BlockStatement = "BlockStatement",
BinaryExpression = "BinaryExpression",
BreakStatement = "BreakStatement",
CallExpression = "CallExpression",
CatchClause = "CatchClause",
ConditionalExpression = "ConditionalExpression",
ContinueStatement = "ContinueStatement",
DoWhileStatement = "DoWhileStatement",
DebuggerStatement = "DebuggerStatement",
EmptyStatement = "EmptyStatement",
ExpressionStatement = "ExpressionStatement",
ForStatement = "ForStatement",
ForInStatement = "ForInStatement",
FunctionDeclaration = "FunctionDeclaration",
FunctionExpression = "FunctionExpression",
Identifier = "Identifier",
IfStatement = "IfStatement",
Literal = "Literal",
LabeledStatement = "LabeledStatement",
LogicalExpression = "LogicalExpression",
MemberExpression = "MemberExpression",
NewExpression = "NewExpression",
ObjectExpression = "ObjectExpression",
Program = "Program",
Property = "Property",
ReturnStatement = "ReturnStatement",
SequenceExpression = "SequenceExpression",
SwitchStatement = "SwitchStatement",
SwitchCase = "SwitchCase",
ThisExpression = "ThisExpression",
ThrowStatement = "ThrowStatement",
TryStatement = "TryStatement",
UnaryExpression = "UnaryExpression",
UpdateExpression = "UpdateExpression",
VariableDeclaration = "VariableDeclaration",
VariableDeclarator = "VariableDeclarator",
WhileStatement = "WhileStatement",
WithStatement = "WithStatement"
}
/**
* Variable Flags
*
* @enum {int} VARIABLE_FLAGS
* @global
*/
export declare enum VARIABLE_FLAGS {
PUBLISH = 2,
PUBLISH_IF_SERVER = 4
}
export declare enum BLOCK_GROUPS {
VARIABLE = "DriverVariable",
BASIC_COMMAND = "DriverBasicCommand",
CONDITIONAL_COMMAND = "DriverConditionalCommand",
RESPONSE_VARIABLE = "DriverResponseVariable",
RESPONSE_BLOCKS = "conditionalProcess",
RESPONSE_VARIABLES = "processVariables",
BASIC_VARIABLES = "basicVariables"
}
export declare enum COMMAND_TYPES {
BASIC_COMMAND = "basic",
CONDITIONAL_COMMAND = "conditional",
INIT_COMMAND = "init"
}
export declare enum CIFLAG {
/**
* Instruct for no additional extra processing
* @constant
* @type int
*/
NONE = 0,
/**
* Will instruct the pre/post processor to base-64 decode or encode
* @constant
* @type int
*/
BASE_64 = 1,
/**
* Post/Pre process the value with a user function
* @constant
* @type int
*/
USE_FUNCTION = 2,
/**
* Replace variables with local scope's variables during the post/pre process
* @constant
* @type int
*/
REPLACE_VARIABLES = 4,
/**
* Replace variables with local scope's variables during the post/pre process but evaluate the whole string
* as Javascript
* @constant
* @type int
*/
REPLACE_VARIABLES_EVALUATED = 8,
/**
* Will instruct the pre/post processor to escpape evaluated or replaced variables or expressions
* @constant
* @type int
*/
ESCAPE = 16,
/**
* Will instruct the pre/post processor to replace block calls with oridinary vanilla script
* @constant
* @type int
*/
REPLACE_BLOCK_CALLS = 32,
/**
* Will instruct the pre/post processor to remove variable delimitters/placeholders from the final string
* @constant
* @type int
*/
REMOVE_DELIMTTERS = 64,
/**
* Will instruct the pre/post processor to remove "[" ,"]" , "(" , ")" , "{", "}" , "*" , "+" , "."
* @constant
* @type int
*/
ESCAPE_SPECIAL_CHARS = 128,
/**
* Will instruct the pre/post processor to use regular expressions over string substitution
* @constant
* @type int
*/
USE_REGEX = 256,
/**
* Will instruct the pre/post processor to use Filtrex (custom bison parser, needs xexpression) over string substitution
* @constant
* @type int
*/
USE_FILTREX = 512,
/**
* Cascade entry. There are cases where #USE_FUNCTION is not enough or we'd like to avoid further type checking.
* @constant
* @type int
*/
CASCADE = 1024,
/**
* Cascade entry. There are cases where #USE_FUNCTION is not enough or we'd like to avoid further type checking.
* @constant
* @type int
*/
EXPRESSION = 2048,
/**
* Dont parse anything
* @constant
* @type int
*/
DONT_PARSE = 4096,
/**
* Convert to hex
* @constant
* @type int
*/
TO_HEX = 8192,
/**
* Convert to hex
* @constant
* @type int
*/
REPLACE_HEX = 16384,
/**
* Wait for finish
* @constant
* @type int
*/
WAIT = 32768,
/**
* Wait for finish
* @constant
* @type int
*/
DONT_ESCAPE = 65536,
/**
* Flag to mark the maximum core bit mask, after here its user land
* @constant
* @type int
*/
END = 131072
}
/**
* Flags to describe a block's execution behavior.
*
* @enum {integer} module=xide/types/RUN_FLAGS
* @memberOf module=xide/types
*/
export declare enum RUN_FLAGS {
/**
* The block can execute child blocks.
* @constant
* @type int
*/
CHILDREN = 32,
/**
* Block is waiting for a message => EXECUTION_STATE==RUNNING
* @constant
* @type int
*/
WAIT = 32768
}
/**
* Flags to describe a block's execution state.
*
* @enum {integer} module=xide/types/EXECUTION_STATE
* @memberOf module=xide/types
*/
export declare enum EXECUTION_STATE {
/**
* The block is doing nothing and also has done nothing. The is the default state
* @constant
* @type int
*/
NONE = 0,
/**
* The block is running.
* @constant
* @type int
*/
RUNNING = 1,
/**
* The block is an error state.
* @constant
* @type int
*/
ERROR = 2,
/**
* The block is in an paused state.
* @constant
* @type int
*/
PAUSED = 4,
/**
* The block is an finished state, ready to be cleared to "NONE" at the next frame.
* @constant
* @type int
*/
FINISH = 8,
/**
* The block is an stopped state, ready to be cleared to "NONE" at the next frame.
* @constant
* @type int
*/
STOPPED = 16,
/**
* The block has been launched once...
* @constant
* @type int
*/
ONCE = 2147483648,
/**
* Block will be reseted next frame
* @constant
* @type int
*/
RESET_NEXT_FRAME = 8388608,
/**
* Block is locked and so no further inputs can be activated.
* @constant
* @type int
*/
LOCKED = 536870912
}
export declare enum BLOCK_MODE {
NORMAL = 0,
UPDATE_WIDGET_PROPERTY = 1
}
/**
* Flags to describe a block's belonging to a standard signal.
* @enum {integer} module=xblox/types/BLOCK_OUTLET
* @memberOf module=xblox/types
*/
export declare enum BLOCK_OUTLET {
NONE = 0,
PROGRESS = 1,
ERROR = 2,
PAUSED = 4,
FINISH = 8,
STOPPED = 16
}
export declare enum EVENTS {
ON_RUN_BLOCK = "onRunBlock",
ON_RUN_BLOCK_FAILED = "onRunBlockFailed",
ON_RUN_BLOCK_SUCCESS = "onRunBlockSuccess",
ON_BLOCK_SELECTED = "onItemSelected",
ON_BLOCK_UNSELECTED = "onBlockUnSelected",
ON_BLOCK_EXPRESSION_FAILED = "onExpressionFailed",
ON_BUILD_BLOCK_INFO_LIST = "onBuildBlockInfoList",
ON_BUILD_BLOCK_INFO_LIST_END = "onBuildBlockInfoListEnd",
ON_BLOCK_PROPERTY_CHANGED = "onBlockPropertyChanged",
ON_SCOPE_CREATED = "onScopeCreated",
ON_VARIABLE_CHANGED = "onVariableChanged",
ON_CREATE_VARIABLE_CI = "onCreateVariableCI"
}
export declare enum BlockType {
AssignmentExpression = "AssignmentExpression",
ArrayExpression = "ArrayExpression",
BlockStatement = "BlockStatement",
BinaryExpression = "BinaryExpression",
BreakStatement = "BreakStatement",
CallExpression = "CallExpression",
CatchClause = "CatchClause",
ConditionalExpression = "ConditionalExpression",
ContinueStatement = "ContinueStatement",
DoWhileStatement = "DoWhileStatement",
DebuggerStatement = "DebuggerStatement",
EmptyStatement = "EmptyStatement",
ExpressionStatement = "ExpressionStatement",
ForStatement = "ForStatement",
ForInStatement = "ForInStatement",
FunctionDeclaration = "FunctionDeclaration",
FunctionExpression = "FunctionExpression",
Identifier = "Identifier",
IfStatement = "IfStatement",
Literal = "Literal",
LabeledStatement = "LabeledStatement",
LogicalExpression = "LogicalExpression",
MemberExpression = "MemberExpression",
NewExpression = "NewExpression",
ObjectExpression = "ObjectExpression",
Program = "Program",
Property = "Property",
ReturnStatement = "ReturnStatement",
SequenceExpression = "SequenceExpression",
SwitchStatement = "SwitchStatement",
SwitchCase = "SwitchCase",
ThisExpression = "ThisExpression",
ThrowStatement = "ThrowStatement",
TryStatement = "TryStatement",
UnaryExpression = "UnaryExpression",
UpdateExpression = "UpdateExpression",
VariableDeclaration = "VariableDeclaration",
VariableDeclarator = "VariableDeclarator",
WhileStatement = "WhileStatement",
WithStatement = "WithStatement"
}
/**
* Variable Flags
*
* @enum {int} VARIABLE_FLAGS
* @global
*/
export declare enum VARIABLE_FLAGS {
PUBLISH = 2,
PUBLISH_IF_SERVER = 4
}
export declare enum BLOCK_GROUPS {
VARIABLE = "DriverVariable",
BASIC_COMMAND = "DriverBasicCommand",
CONDITIONAL_COMMAND = "DriverConditionalCommand",
RESPONSE_VARIABLE = "DriverResponseVariable",
RESPONSE_BLOCKS = "conditionalProcess",
RESPONSE_VARIABLES = "processVariables",
BASIC_VARIABLES = "basicVariables"
}
export declare enum COMMAND_TYPES {
BASIC_COMMAND = "basic",
CONDITIONAL_COMMAND = "conditional",
INIT_COMMAND = "init"
}
export declare enum CIFLAG {
/**
* Instruct for no additional extra processing
* @constant
* @type int
*/
NONE = 0,
/**
* Will instruct the pre/post processor to base-64 decode or encode
* @constant
* @type int
*/
BASE_64 = 1,
/**
* Post/Pre process the value with a user function
* @constant
* @type int
*/
USE_FUNCTION = 2,
/**
* Replace variables with local scope's variables during the post/pre process
* @constant
* @type int
*/
REPLACE_VARIABLES = 4,
/**
* Replace variables with local scope's variables during the post/pre process but evaluate the whole string
* as Javascript
* @constant
* @type int
*/
REPLACE_VARIABLES_EVALUATED = 8,
/**
* Will instruct the pre/post processor to escpape evaluated or replaced variables or expressions
* @constant
* @type int
*/
ESCAPE = 16,
/**
* Will instruct the pre/post processor to replace block calls with oridinary vanilla script
* @constant
* @type int
*/
REPLACE_BLOCK_CALLS = 32,
/**
* Will instruct the pre/post processor to remove variable delimitters/placeholders from the final string
* @constant
* @type int
*/
REMOVE_DELIMTTERS = 64,
/**
* Will instruct the pre/post processor to remove "[" ,"]" , "(" , ")" , "{", "}" , "*" , "+" , "."
* @constant
* @type int
*/
ESCAPE_SPECIAL_CHARS = 128,
/**
* Will instruct the pre/post processor to use regular expressions over string substitution
* @constant
* @type int
*/
USE_REGEX = 256,
/**
* Will instruct the pre/post processor to use Filtrex (custom bison parser, needs xexpression) over string substitution
* @constant
* @type int
*/
USE_FILTREX = 512,
/**
* Cascade entry. There are cases where #USE_FUNCTION is not enough or we'd like to avoid further type checking.
* @constant
* @type int
*/
CASCADE = 1024,
/**
* Cascade entry. There are cases where #USE_FUNCTION is not enough or we'd like to avoid further type checking.
* @constant
* @type int
*/
EXPRESSION = 2048,
/**
* Dont parse anything
* @constant
* @type int
*/
DONT_PARSE = 4096,
/**
* Convert to hex
* @constant
* @type int
*/
TO_HEX = 8192,
/**
* Convert to hex
* @constant
* @type int
*/
REPLACE_HEX = 16384,
/**
* Wait for finish
* @constant
* @type int
*/
WAIT = 32768,
/**
* Wait for finish
* @constant
* @type int
*/
DONT_ESCAPE = 65536,
/**
* Flag to mark the maximum core bit mask, after here its user land
* @constant
* @type int
*/
END = 131072
}

View File

@ -1,314 +1,314 @@
/**
* Flags to describe a block's execution behavior.
*
* @enum {integer} module=xide/types/RUN_FLAGS
* @memberOf module=xide/types
*/
export var RUN_FLAGS;
(function (RUN_FLAGS) {
/**
* The block can execute child blocks.
* @constant
* @type int
*/
RUN_FLAGS[RUN_FLAGS["CHILDREN"] = 32] = "CHILDREN";
/**
* Block is waiting for a message => EXECUTION_STATE==RUNNING
* @constant
* @type int
*/
RUN_FLAGS[RUN_FLAGS["WAIT"] = 32768] = "WAIT";
})(RUN_FLAGS = RUN_FLAGS || (RUN_FLAGS = {}));
;
/**
* Flags to describe a block's execution state.
*
* @enum {integer} module=xide/types/EXECUTION_STATE
* @memberOf module=xide/types
*/
export var EXECUTION_STATE;
(function (EXECUTION_STATE) {
/**
* The block is doing nothing and also has done nothing. The is the default state
* @constant
* @type int
*/
EXECUTION_STATE[EXECUTION_STATE["NONE"] = 0] = "NONE";
/**
* The block is running.
* @constant
* @type int
*/
EXECUTION_STATE[EXECUTION_STATE["RUNNING"] = 1] = "RUNNING";
/**
* The block is an error state.
* @constant
* @type int
*/
EXECUTION_STATE[EXECUTION_STATE["ERROR"] = 2] = "ERROR";
/**
* The block is in an paused state.
* @constant
* @type int
*/
EXECUTION_STATE[EXECUTION_STATE["PAUSED"] = 4] = "PAUSED";
/**
* The block is an finished state, ready to be cleared to "NONE" at the next frame.
* @constant
* @type int
*/
EXECUTION_STATE[EXECUTION_STATE["FINISH"] = 8] = "FINISH";
/**
* The block is an stopped state, ready to be cleared to "NONE" at the next frame.
* @constant
* @type int
*/
EXECUTION_STATE[EXECUTION_STATE["STOPPED"] = 16] = "STOPPED";
/**
* The block has been launched once...
* @constant
* @type int
*/
EXECUTION_STATE[EXECUTION_STATE["ONCE"] = 2147483648] = "ONCE";
/**
* Block will be reseted next frame
* @constant
* @type int
*/
EXECUTION_STATE[EXECUTION_STATE["RESET_NEXT_FRAME"] = 8388608] = "RESET_NEXT_FRAME";
/**
* Block is locked and so no further inputs can be activated.
* @constant
* @type int
*/
EXECUTION_STATE[EXECUTION_STATE["LOCKED"] = 536870912] = "LOCKED"; // Block is locked for utilisation in xblox
})(EXECUTION_STATE = EXECUTION_STATE || (EXECUTION_STATE = {}));
export var BLOCK_MODE;
(function (BLOCK_MODE) {
BLOCK_MODE[BLOCK_MODE["NORMAL"] = 0] = "NORMAL";
BLOCK_MODE[BLOCK_MODE["UPDATE_WIDGET_PROPERTY"] = 1] = "UPDATE_WIDGET_PROPERTY";
})(BLOCK_MODE = BLOCK_MODE || (BLOCK_MODE = {}));
;
/**
* Flags to describe a block's belonging to a standard signal.
* @enum {integer} module=xblox/types/BLOCK_OUTLET
* @memberOf module=xblox/types
*/
export var BLOCK_OUTLET;
(function (BLOCK_OUTLET) {
BLOCK_OUTLET[BLOCK_OUTLET["NONE"] = 0] = "NONE";
BLOCK_OUTLET[BLOCK_OUTLET["PROGRESS"] = 1] = "PROGRESS";
BLOCK_OUTLET[BLOCK_OUTLET["ERROR"] = 2] = "ERROR";
BLOCK_OUTLET[BLOCK_OUTLET["PAUSED"] = 4] = "PAUSED";
BLOCK_OUTLET[BLOCK_OUTLET["FINISH"] = 8] = "FINISH";
BLOCK_OUTLET[BLOCK_OUTLET["STOPPED"] = 16] = "STOPPED";
})(BLOCK_OUTLET = BLOCK_OUTLET || (BLOCK_OUTLET = {}));
;
export var EVENTS;
(function (EVENTS) {
EVENTS["ON_RUN_BLOCK"] = "onRunBlock";
EVENTS["ON_RUN_BLOCK_FAILED"] = "onRunBlockFailed";
EVENTS["ON_RUN_BLOCK_SUCCESS"] = "onRunBlockSuccess";
EVENTS["ON_BLOCK_SELECTED"] = "onItemSelected";
EVENTS["ON_BLOCK_UNSELECTED"] = "onBlockUnSelected";
EVENTS["ON_BLOCK_EXPRESSION_FAILED"] = "onExpressionFailed";
EVENTS["ON_BUILD_BLOCK_INFO_LIST"] = "onBuildBlockInfoList";
EVENTS["ON_BUILD_BLOCK_INFO_LIST_END"] = "onBuildBlockInfoListEnd";
EVENTS["ON_BLOCK_PROPERTY_CHANGED"] = "onBlockPropertyChanged";
EVENTS["ON_SCOPE_CREATED"] = "onScopeCreated";
EVENTS["ON_VARIABLE_CHANGED"] = "onVariableChanged";
EVENTS["ON_CREATE_VARIABLE_CI"] = "onCreateVariableCI";
})(EVENTS = EVENTS || (EVENTS = {}));
export var BlockType;
(function (BlockType) {
BlockType["AssignmentExpression"] = "AssignmentExpression";
BlockType["ArrayExpression"] = "ArrayExpression";
BlockType["BlockStatement"] = "BlockStatement";
BlockType["BinaryExpression"] = "BinaryExpression";
BlockType["BreakStatement"] = "BreakStatement";
BlockType["CallExpression"] = "CallExpression";
BlockType["CatchClause"] = "CatchClause";
BlockType["ConditionalExpression"] = "ConditionalExpression";
BlockType["ContinueStatement"] = "ContinueStatement";
BlockType["DoWhileStatement"] = "DoWhileStatement";
BlockType["DebuggerStatement"] = "DebuggerStatement";
BlockType["EmptyStatement"] = "EmptyStatement";
BlockType["ExpressionStatement"] = "ExpressionStatement";
BlockType["ForStatement"] = "ForStatement";
BlockType["ForInStatement"] = "ForInStatement";
BlockType["FunctionDeclaration"] = "FunctionDeclaration";
BlockType["FunctionExpression"] = "FunctionExpression";
BlockType["Identifier"] = "Identifier";
BlockType["IfStatement"] = "IfStatement";
BlockType["Literal"] = "Literal";
BlockType["LabeledStatement"] = "LabeledStatement";
BlockType["LogicalExpression"] = "LogicalExpression";
BlockType["MemberExpression"] = "MemberExpression";
BlockType["NewExpression"] = "NewExpression";
BlockType["ObjectExpression"] = "ObjectExpression";
BlockType["Program"] = "Program";
BlockType["Property"] = "Property";
BlockType["ReturnStatement"] = "ReturnStatement";
BlockType["SequenceExpression"] = "SequenceExpression";
BlockType["SwitchStatement"] = "SwitchStatement";
BlockType["SwitchCase"] = "SwitchCase";
BlockType["ThisExpression"] = "ThisExpression";
BlockType["ThrowStatement"] = "ThrowStatement";
BlockType["TryStatement"] = "TryStatement";
BlockType["UnaryExpression"] = "UnaryExpression";
BlockType["UpdateExpression"] = "UpdateExpression";
BlockType["VariableDeclaration"] = "VariableDeclaration";
BlockType["VariableDeclarator"] = "VariableDeclarator";
BlockType["WhileStatement"] = "WhileStatement";
BlockType["WithStatement"] = "WithStatement";
})(BlockType = BlockType || (BlockType = {}));
;
/**
* Variable Flags
*
* @enum {int} VARIABLE_FLAGS
* @global
*/
export var VARIABLE_FLAGS;
(function (VARIABLE_FLAGS) {
VARIABLE_FLAGS[VARIABLE_FLAGS["PUBLISH"] = 2] = "PUBLISH";
VARIABLE_FLAGS[VARIABLE_FLAGS["PUBLISH_IF_SERVER"] = 4] = "PUBLISH_IF_SERVER";
})(VARIABLE_FLAGS = VARIABLE_FLAGS || (VARIABLE_FLAGS = {}));
;
export var BLOCK_GROUPS;
(function (BLOCK_GROUPS) {
BLOCK_GROUPS["VARIABLE"] = "DriverVariable";
BLOCK_GROUPS["BASIC_COMMAND"] = "DriverBasicCommand";
BLOCK_GROUPS["CONDITIONAL_COMMAND"] = "DriverConditionalCommand";
BLOCK_GROUPS["RESPONSE_VARIABLE"] = "DriverResponseVariable";
BLOCK_GROUPS["RESPONSE_BLOCKS"] = "conditionalProcess";
BLOCK_GROUPS["RESPONSE_VARIABLES"] = "processVariables";
BLOCK_GROUPS["BASIC_VARIABLES"] = "basicVariables";
})(BLOCK_GROUPS = BLOCK_GROUPS || (BLOCK_GROUPS = {}));
;
export var COMMAND_TYPES;
(function (COMMAND_TYPES) {
COMMAND_TYPES["BASIC_COMMAND"] = "basic";
COMMAND_TYPES["CONDITIONAL_COMMAND"] = "conditional";
COMMAND_TYPES["INIT_COMMAND"] = "init";
})(COMMAND_TYPES = COMMAND_TYPES || (COMMAND_TYPES = {}));
;
export var CIFLAG;
(function (CIFLAG) {
/**
* Instruct for no additional extra processing
* @constant
* @type int
*/
CIFLAG[CIFLAG["NONE"] = 0] = "NONE";
/**
* Will instruct the pre/post processor to base-64 decode or encode
* @constant
* @type int
*/
CIFLAG[CIFLAG["BASE_64"] = 1] = "BASE_64";
/**
* Post/Pre process the value with a user function
* @constant
* @type int
*/
CIFLAG[CIFLAG["USE_FUNCTION"] = 2] = "USE_FUNCTION";
/**
* Replace variables with local scope's variables during the post/pre process
* @constant
* @type int
*/
CIFLAG[CIFLAG["REPLACE_VARIABLES"] = 4] = "REPLACE_VARIABLES";
/**
* Replace variables with local scope's variables during the post/pre process but evaluate the whole string
* as Javascript
* @constant
* @type int
*/
CIFLAG[CIFLAG["REPLACE_VARIABLES_EVALUATED"] = 8] = "REPLACE_VARIABLES_EVALUATED";
/**
* Will instruct the pre/post processor to escpape evaluated or replaced variables or expressions
* @constant
* @type int
*/
CIFLAG[CIFLAG["ESCAPE"] = 16] = "ESCAPE";
/**
* Will instruct the pre/post processor to replace block calls with oridinary vanilla script
* @constant
* @type int
*/
CIFLAG[CIFLAG["REPLACE_BLOCK_CALLS"] = 32] = "REPLACE_BLOCK_CALLS";
/**
* Will instruct the pre/post processor to remove variable delimitters/placeholders from the final string
* @constant
* @type int
*/
CIFLAG[CIFLAG["REMOVE_DELIMTTERS"] = 64] = "REMOVE_DELIMTTERS";
/**
* Will instruct the pre/post processor to remove "[" ,"]" , "(" , ")" , "{", "}" , "*" , "+" , "."
* @constant
* @type int
*/
CIFLAG[CIFLAG["ESCAPE_SPECIAL_CHARS"] = 128] = "ESCAPE_SPECIAL_CHARS";
/**
* Will instruct the pre/post processor to use regular expressions over string substitution
* @constant
* @type int
*/
CIFLAG[CIFLAG["USE_REGEX"] = 256] = "USE_REGEX";
/**
* Will instruct the pre/post processor to use Filtrex (custom bison parser, needs xexpression) over string substitution
* @constant
* @type int
*/
CIFLAG[CIFLAG["USE_FILTREX"] = 512] = "USE_FILTREX";
/**
* Cascade entry. There are cases where #USE_FUNCTION is not enough or we'd like to avoid further type checking.
* @constant
* @type int
*/
CIFLAG[CIFLAG["CASCADE"] = 1024] = "CASCADE";
/**
* Cascade entry. There are cases where #USE_FUNCTION is not enough or we'd like to avoid further type checking.
* @constant
* @type int
*/
CIFLAG[CIFLAG["EXPRESSION"] = 2048] = "EXPRESSION";
/**
* Dont parse anything
* @constant
* @type int
*/
CIFLAG[CIFLAG["DONT_PARSE"] = 4096] = "DONT_PARSE";
/**
* Convert to hex
* @constant
* @type int
*/
CIFLAG[CIFLAG["TO_HEX"] = 8192] = "TO_HEX";
/**
* Convert to hex
* @constant
* @type int
*/
CIFLAG[CIFLAG["REPLACE_HEX"] = 16384] = "REPLACE_HEX";
/**
* Wait for finish
* @constant
* @type int
*/
CIFLAG[CIFLAG["WAIT"] = 32768] = "WAIT";
/**
* Wait for finish
* @constant
* @type int
*/
CIFLAG[CIFLAG["DONT_ESCAPE"] = 65536] = "DONT_ESCAPE";
/**
* Flag to mark the maximum core bit mask, after here its user land
* @constant
* @type int
*/
CIFLAG[CIFLAG["END"] = 131072] = "END";
})(CIFLAG = CIFLAG || (CIFLAG = {}));
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHlwZXNfZ3VpLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOls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EI7Ozs7T0FJRztJQUNILHFEQUF5QixDQUFBO0lBQ3pCOzs7O09BSUc7SUFDSCx1Q0FBa0IsQ0FBQTtJQUNsQjs7OztPQUlHO0lBQ0gscURBQXlCLENBQUE7SUFDekI7Ozs7T0FJRztJQUNILHNDQUFpQixDQUFBO0FBQ3JCLENBQUMsRUFwSFcsTUFBTSxHQUFOLE1BQU0sS0FBTixNQUFNLFFBb0hqQiJ9
/**
* Flags to describe a block's execution behavior.
*
* @enum {integer} module=xide/types/RUN_FLAGS
* @memberOf module=xide/types
*/
export var RUN_FLAGS;
(function (RUN_FLAGS) {
/**
* The block can execute child blocks.
* @constant
* @type int
*/
RUN_FLAGS[RUN_FLAGS["CHILDREN"] = 32] = "CHILDREN";
/**
* Block is waiting for a message => EXECUTION_STATE==RUNNING
* @constant
* @type int
*/
RUN_FLAGS[RUN_FLAGS["WAIT"] = 32768] = "WAIT";
})(RUN_FLAGS || (RUN_FLAGS = {}));
;
/**
* Flags to describe a block's execution state.
*
* @enum {integer} module=xide/types/EXECUTION_STATE
* @memberOf module=xide/types
*/
export var EXECUTION_STATE;
(function (EXECUTION_STATE) {
/**
* The block is doing nothing and also has done nothing. The is the default state
* @constant
* @type int
*/
EXECUTION_STATE[EXECUTION_STATE["NONE"] = 0] = "NONE";
/**
* The block is running.
* @constant
* @type int
*/
EXECUTION_STATE[EXECUTION_STATE["RUNNING"] = 1] = "RUNNING";
/**
* The block is an error state.
* @constant
* @type int
*/
EXECUTION_STATE[EXECUTION_STATE["ERROR"] = 2] = "ERROR";
/**
* The block is in an paused state.
* @constant
* @type int
*/
EXECUTION_STATE[EXECUTION_STATE["PAUSED"] = 4] = "PAUSED";
/**
* The block is an finished state, ready to be cleared to "NONE" at the next frame.
* @constant
* @type int
*/
EXECUTION_STATE[EXECUTION_STATE["FINISH"] = 8] = "FINISH";
/**
* The block is an stopped state, ready to be cleared to "NONE" at the next frame.
* @constant
* @type int
*/
EXECUTION_STATE[EXECUTION_STATE["STOPPED"] = 16] = "STOPPED";
/**
* The block has been launched once...
* @constant
* @type int
*/
EXECUTION_STATE[EXECUTION_STATE["ONCE"] = 2147483648] = "ONCE";
/**
* Block will be reseted next frame
* @constant
* @type int
*/
EXECUTION_STATE[EXECUTION_STATE["RESET_NEXT_FRAME"] = 8388608] = "RESET_NEXT_FRAME";
/**
* Block is locked and so no further inputs can be activated.
* @constant
* @type int
*/
EXECUTION_STATE[EXECUTION_STATE["LOCKED"] = 536870912] = "LOCKED"; // Block is locked for utilisation in xblox
})(EXECUTION_STATE || (EXECUTION_STATE = {}));
export var BLOCK_MODE;
(function (BLOCK_MODE) {
BLOCK_MODE[BLOCK_MODE["NORMAL"] = 0] = "NORMAL";
BLOCK_MODE[BLOCK_MODE["UPDATE_WIDGET_PROPERTY"] = 1] = "UPDATE_WIDGET_PROPERTY";
})(BLOCK_MODE || (BLOCK_MODE = {}));
;
/**
* Flags to describe a block's belonging to a standard signal.
* @enum {integer} module=xblox/types/BLOCK_OUTLET
* @memberOf module=xblox/types
*/
export var BLOCK_OUTLET;
(function (BLOCK_OUTLET) {
BLOCK_OUTLET[BLOCK_OUTLET["NONE"] = 0] = "NONE";
BLOCK_OUTLET[BLOCK_OUTLET["PROGRESS"] = 1] = "PROGRESS";
BLOCK_OUTLET[BLOCK_OUTLET["ERROR"] = 2] = "ERROR";
BLOCK_OUTLET[BLOCK_OUTLET["PAUSED"] = 4] = "PAUSED";
BLOCK_OUTLET[BLOCK_OUTLET["FINISH"] = 8] = "FINISH";
BLOCK_OUTLET[BLOCK_OUTLET["STOPPED"] = 16] = "STOPPED";
})(BLOCK_OUTLET || (BLOCK_OUTLET = {}));
;
export var EVENTS;
(function (EVENTS) {
EVENTS["ON_RUN_BLOCK"] = "onRunBlock";
EVENTS["ON_RUN_BLOCK_FAILED"] = "onRunBlockFailed";
EVENTS["ON_RUN_BLOCK_SUCCESS"] = "onRunBlockSuccess";
EVENTS["ON_BLOCK_SELECTED"] = "onItemSelected";
EVENTS["ON_BLOCK_UNSELECTED"] = "onBlockUnSelected";
EVENTS["ON_BLOCK_EXPRESSION_FAILED"] = "onExpressionFailed";
EVENTS["ON_BUILD_BLOCK_INFO_LIST"] = "onBuildBlockInfoList";
EVENTS["ON_BUILD_BLOCK_INFO_LIST_END"] = "onBuildBlockInfoListEnd";
EVENTS["ON_BLOCK_PROPERTY_CHANGED"] = "onBlockPropertyChanged";
EVENTS["ON_SCOPE_CREATED"] = "onScopeCreated";
EVENTS["ON_VARIABLE_CHANGED"] = "onVariableChanged";
EVENTS["ON_CREATE_VARIABLE_CI"] = "onCreateVariableCI";
})(EVENTS || (EVENTS = {}));
export var BlockType;
(function (BlockType) {
BlockType["AssignmentExpression"] = "AssignmentExpression";
BlockType["ArrayExpression"] = "ArrayExpression";
BlockType["BlockStatement"] = "BlockStatement";
BlockType["BinaryExpression"] = "BinaryExpression";
BlockType["BreakStatement"] = "BreakStatement";
BlockType["CallExpression"] = "CallExpression";
BlockType["CatchClause"] = "CatchClause";
BlockType["ConditionalExpression"] = "ConditionalExpression";
BlockType["ContinueStatement"] = "ContinueStatement";
BlockType["DoWhileStatement"] = "DoWhileStatement";
BlockType["DebuggerStatement"] = "DebuggerStatement";
BlockType["EmptyStatement"] = "EmptyStatement";
BlockType["ExpressionStatement"] = "ExpressionStatement";
BlockType["ForStatement"] = "ForStatement";
BlockType["ForInStatement"] = "ForInStatement";
BlockType["FunctionDeclaration"] = "FunctionDeclaration";
BlockType["FunctionExpression"] = "FunctionExpression";
BlockType["Identifier"] = "Identifier";
BlockType["IfStatement"] = "IfStatement";
BlockType["Literal"] = "Literal";
BlockType["LabeledStatement"] = "LabeledStatement";
BlockType["LogicalExpression"] = "LogicalExpression";
BlockType["MemberExpression"] = "MemberExpression";
BlockType["NewExpression"] = "NewExpression";
BlockType["ObjectExpression"] = "ObjectExpression";
BlockType["Program"] = "Program";
BlockType["Property"] = "Property";
BlockType["ReturnStatement"] = "ReturnStatement";
BlockType["SequenceExpression"] = "SequenceExpression";
BlockType["SwitchStatement"] = "SwitchStatement";
BlockType["SwitchCase"] = "SwitchCase";
BlockType["ThisExpression"] = "ThisExpression";
BlockType["ThrowStatement"] = "ThrowStatement";
BlockType["TryStatement"] = "TryStatement";
BlockType["UnaryExpression"] = "UnaryExpression";
BlockType["UpdateExpression"] = "UpdateExpression";
BlockType["VariableDeclaration"] = "VariableDeclaration";
BlockType["VariableDeclarator"] = "VariableDeclarator";
BlockType["WhileStatement"] = "WhileStatement";
BlockType["WithStatement"] = "WithStatement";
})(BlockType || (BlockType = {}));
;
/**
* Variable Flags
*
* @enum {int} VARIABLE_FLAGS
* @global
*/
export var VARIABLE_FLAGS;
(function (VARIABLE_FLAGS) {
VARIABLE_FLAGS[VARIABLE_FLAGS["PUBLISH"] = 2] = "PUBLISH";
VARIABLE_FLAGS[VARIABLE_FLAGS["PUBLISH_IF_SERVER"] = 4] = "PUBLISH_IF_SERVER";
})(VARIABLE_FLAGS || (VARIABLE_FLAGS = {}));
;
export var BLOCK_GROUPS;
(function (BLOCK_GROUPS) {
BLOCK_GROUPS["VARIABLE"] = "DriverVariable";
BLOCK_GROUPS["BASIC_COMMAND"] = "DriverBasicCommand";
BLOCK_GROUPS["CONDITIONAL_COMMAND"] = "DriverConditionalCommand";
BLOCK_GROUPS["RESPONSE_VARIABLE"] = "DriverResponseVariable";
BLOCK_GROUPS["RESPONSE_BLOCKS"] = "conditionalProcess";
BLOCK_GROUPS["RESPONSE_VARIABLES"] = "processVariables";
BLOCK_GROUPS["BASIC_VARIABLES"] = "basicVariables";
})(BLOCK_GROUPS || (BLOCK_GROUPS = {}));
;
export var COMMAND_TYPES;
(function (COMMAND_TYPES) {
COMMAND_TYPES["BASIC_COMMAND"] = "basic";
COMMAND_TYPES["CONDITIONAL_COMMAND"] = "conditional";
COMMAND_TYPES["INIT_COMMAND"] = "init";
})(COMMAND_TYPES || (COMMAND_TYPES = {}));
;
export var CIFLAG;
(function (CIFLAG) {
/**
* Instruct for no additional extra processing
* @constant
* @type int
*/
CIFLAG[CIFLAG["NONE"] = 0] = "NONE";
/**
* Will instruct the pre/post processor to base-64 decode or encode
* @constant
* @type int
*/
CIFLAG[CIFLAG["BASE_64"] = 1] = "BASE_64";
/**
* Post/Pre process the value with a user function
* @constant
* @type int
*/
CIFLAG[CIFLAG["USE_FUNCTION"] = 2] = "USE_FUNCTION";
/**
* Replace variables with local scope's variables during the post/pre process
* @constant
* @type int
*/
CIFLAG[CIFLAG["REPLACE_VARIABLES"] = 4] = "REPLACE_VARIABLES";
/**
* Replace variables with local scope's variables during the post/pre process but evaluate the whole string
* as Javascript
* @constant
* @type int
*/
CIFLAG[CIFLAG["REPLACE_VARIABLES_EVALUATED"] = 8] = "REPLACE_VARIABLES_EVALUATED";
/**
* Will instruct the pre/post processor to escpape evaluated or replaced variables or expressions
* @constant
* @type int
*/
CIFLAG[CIFLAG["ESCAPE"] = 16] = "ESCAPE";
/**
* Will instruct the pre/post processor to replace block calls with oridinary vanilla script
* @constant
* @type int
*/
CIFLAG[CIFLAG["REPLACE_BLOCK_CALLS"] = 32] = "REPLACE_BLOCK_CALLS";
/**
* Will instruct the pre/post processor to remove variable delimitters/placeholders from the final string
* @constant
* @type int
*/
CIFLAG[CIFLAG["REMOVE_DELIMTTERS"] = 64] = "REMOVE_DELIMTTERS";
/**
* Will instruct the pre/post processor to remove "[" ,"]" , "(" , ")" , "{", "}" , "*" , "+" , "."
* @constant
* @type int
*/
CIFLAG[CIFLAG["ESCAPE_SPECIAL_CHARS"] = 128] = "ESCAPE_SPECIAL_CHARS";
/**
* Will instruct the pre/post processor to use regular expressions over string substitution
* @constant
* @type int
*/
CIFLAG[CIFLAG["USE_REGEX"] = 256] = "USE_REGEX";
/**
* Will instruct the pre/post processor to use Filtrex (custom bison parser, needs xexpression) over string substitution
* @constant
* @type int
*/
CIFLAG[CIFLAG["USE_FILTREX"] = 512] = "USE_FILTREX";
/**
* Cascade entry. There are cases where #USE_FUNCTION is not enough or we'd like to avoid further type checking.
* @constant
* @type int
*/
CIFLAG[CIFLAG["CASCADE"] = 1024] = "CASCADE";
/**
* Cascade entry. There are cases where #USE_FUNCTION is not enough or we'd like to avoid further type checking.
* @constant
* @type int
*/
CIFLAG[CIFLAG["EXPRESSION"] = 2048] = "EXPRESSION";
/**
* Dont parse anything
* @constant
* @type int
*/
CIFLAG[CIFLAG["DONT_PARSE"] = 4096] = "DONT_PARSE";
/**
* Convert to hex
* @constant
* @type int
*/
CIFLAG[CIFLAG["TO_HEX"] = 8192] = "TO_HEX";
/**
* Convert to hex
* @constant
* @type int
*/
CIFLAG[CIFLAG["REPLACE_HEX"] = 16384] = "REPLACE_HEX";
/**
* Wait for finish
* @constant
* @type int
*/
CIFLAG[CIFLAG["WAIT"] = 32768] = "WAIT";
/**
* Wait for finish
* @constant
* @type int
*/
CIFLAG[CIFLAG["DONT_ESCAPE"] = 65536] = "DONT_ESCAPE";
/**
* Flag to mark the maximum core bit mask, after here its user land
* @constant
* @type int
*/
CIFLAG[CIFLAG["END"] = 131072] = "END";
})(CIFLAG || (CIFLAG = {}));
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHlwZXNfZ3VpLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vc3JjL3R5cGVzX2d1aS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQTs7Ozs7R0FLRztBQUNILE1BQU0sQ0FBTixJQUFZLFNBYVg7QUFiRCxXQUFZLFNBQVM7SUFDakI7Ozs7T0FJRztJQUNILGtEQUFxQixDQUFBO0lBQ3JCOzs7O09BSUc7SUFDSCw2Q0FBa0IsQ0FBQTtBQUN0QixDQUFDLEVBYlcsU0FBUyxLQUFULFNBQVMsUUFhcEI7QUFBQSxDQUFDO0FBRUY7Ozs7O0dBS0c7QUFDSCxNQUFNLENBQU4sSUFBWSxlQXVEWDtBQXZERCxXQUFZLGVBQWU7SUFDdkI7Ozs7T0FJRztJQUNILHFEQUFpQixDQUFBO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ThCLENBQUE7SUFDOUI7Ozs7O09BS0c7SUFDSCxpRkFBd0MsQ0FBQTtJQUN4Qzs7OztPQUlHO0lBQ0gsd0NBQW1CLENBQUE7SUFDbkI7Ozs7T0FJRztJQUNILGtFQUFnQyxDQUFBO0lBQ2hDOzs7O09BSUc7SUFDSCw4REFBOEIsQ0FBQTtJQUM5Qjs7OztPQUlHO0lBQ0gscUVBQWlDLENBQUE7SUFDakM7Ozs7T0FJRztJQUNILCtDQUFzQixDQUFBO0lBQ3RCOzs7O09BSUc7SUFDSCxtREFBd0IsQ0FBQTtJQUN4Qjs7OztPQUlHO0lBQ0gsNENBQW9CLENBQUE7SUFDcEI7Ozs7T0FJRztJQUNILGtEQUF1QixDQUFBO0lBQ3ZCOzs7O09BSUc7SUFDSCxrREFBd0IsQ0FBQTtJQUN4Qjs7OztPQUlHO0lBQ0gsMENBQW9CLENBQUE7SUFDcEI7Ozs7T0FJRztJQUNILHFEQUF5QixDQUFBO0lBQ3pCOzs7O09BSUc7SUFDSCx1Q0FBa0IsQ0FBQTtJQUNsQjs7OztPQUlHO0lBQ0gscURBQXlCLENBQUE7SUFDekI7Ozs7T0FJRztJQUNILHNDQUFpQixDQUFBO0FBQ3JCLENBQUMsRUFwSFcsTUFBTSxLQUFOLE1BQU0sUUFvSGpCIn0=

File diff suppressed because one or more lines are too long

View File

@ -1,192 +1,192 @@
export interface IKBotOptions {
/** Path to the project directory */
path?: string;
/** Description of the modifications to make to the project. Supports file paths. */
query?: string;
/** Optional output path for modified files */
output?: string | undefined;
/** Optional destination path for the result, will substitute ${MODEL} and ${ROUTER} in the path */
dst?: string | undefined;
/** Template (typescript) or path to use for processing, see https://git.polymech.io/polymech/ai-template-typescript */
template?: (("typescript") | string) | undefined;
/** Template root directory. When specified, templates are loaded with a prefix, eg: ${POLYMECH-ROOT}/ai-template-${options.template} */
templateRoot?: string;
/** List of template parts to disable. Addionally, tools categories can be disabled, eg: --disable=fs,git,interact,terminal,search,web,email,user */
disable?: string[];
/** List of specific tools to disable */
disableTools?: string[];
/** Glob patterns to match files for processing, comma separated, eg: src/*.tsx,src/*.ts */
glob?: string[] | undefined;
/** AI model to use for processing. Available models:

 OpenRouter models:

google/gemini-pro-1.5-exp | paid
meta-llama/llama-3.2-11b-vision-instruct:free | free
google/gemini-flash-1.5-exp | paid
google/gemini-flash-1.5-8b-exp | paid
microsoft/phi-3-medium-128k-instruct:free | free
microsoft/phi-3-mini-128k-instruct:free | free
google/gemini-2.0-flash-thinking-exp:free | free
google/gemini-2.0-flash-exp:free | free
meta-llama/llama-3.2-1b-instruct | paid
meta-llama/llama-3.2-3b-instruct | paid
meta-llama/llama-3.1-8b-instruct | paid
mistralai/mistral-7b-instruct | paid
mistralai/mistral-7b-instruct-v0.3 | paid
meta-llama/llama-3-8b-instruct | paid
amazon/nova-micro-v1 | paid
google/gemini-flash-1.5-8b | paid
mistralai/ministral-3b | paid
meta-llama/llama-3.2-11b-vision-instruct | paid
amazon/nova-lite-v1 | paid
google/gemini-flash-1.5 | paid
mistralai/ministral-8b | paid
microsoft/phi-3-mini-128k-instruct | paid
microsoft/phi-3.5-mini-128k-instruct | paid
meta-llama/llama-3.1-70b-instruct | paid
nvidia/llama-3.1-nemotron-70b-instruct | paid
deepseek/deepseek-chat | paid
cohere/command-r-08-2024 | paid
mistralai/mistral-nemo | paid
mistralai/pixtral-12b | paid
openai/gpt-4o-mini | paid
openai/gpt-4o-mini-2024-07-18 | paid
mistralai/mistral-7b-instruct-v0.1 | paid
ai21/jamba-1-5-mini | paid
mistralai/mistral-small | paid
qwen/qwen-2.5-72b-instruct | paid
meta-llama/llama-3-70b-instruct | paid
mistralai/mixtral-8x7b-instruct | paid
mistralai/mistral-tiny | paid
mistralai/codestral-mamba | paid
anthropic/claude-3-haiku:beta | paid
anthropic/claude-3-haiku | paid
nousresearch/hermes-3-llama-3.1-70b | paid
cohere/command-r-03-2024 | paid
cohere/command-r | paid
openai/gpt-3.5-turbo-0125 | paid
google/gemini-pro | paid
openai/gpt-3.5-turbo | paid
mistralai/mixtral-8x7b-instruct:nitro | paid
meta-llama/llama-3.1-405b-instruct | paid
amazon/nova-pro-v1 | paid
anthropic/claude-3.5-haiku:beta | paid
anthropic/claude-3.5-haiku | paid
anthropic/claude-3.5-haiku-20241022:beta | paid
anthropic/claude-3.5-haiku-20241022 | paid
microsoft/phi-3-medium-128k-instruct | paid
openai/gpt-3.5-turbo-1106 | paid
openai/gpt-3.5-turbo-0613 | paid
meta-llama/llama-3.2-90b-vision-instruct | paid
google/gemini-pro-1.5 | paid
mistralai/mixtral-8x22b-instruct | paid
mistralai/mistral-large | paid
mistralai/mistral-large-2407 | paid
mistralai/mistral-large-2411 | paid
mistralai/pixtral-large-2411 | paid
ai21/jamba-1-5-large | paid
x-ai/grok-2-1212 | paid
cohere/command-r-plus-08-2024 | paid
openai/gpt-4o | paid
openai/gpt-4o-2024-08-06 | paid
openai/gpt-4o-2024-11-20 | paid
mistralai/mistral-medium | paid
cohere/command-r-plus | paid
cohere/command-r-plus-04-2024 | paid
openai/gpt-3.5-turbo-16k | paid
anthropic/claude-3.5-sonnet:beta | paid
anthropic/claude-3.5-sonnet | paid
anthropic/claude-3-sonnet:beta | paid
anthropic/claude-3-sonnet | paid
anthropic/claude-3.5-sonnet-20240620:beta | paid
anthropic/claude-3.5-sonnet-20240620 | paid
openai/gpt-4o-2024-05-13 | paid
x-ai/grok-beta | paid
x-ai/grok-vision-beta | paid
openai/gpt-4o:extended | paid
openai/gpt-4-turbo | paid
openai/gpt-4-1106-preview | paid
openai/gpt-4-turbo-preview | paid
openai/o1 | paid
anthropic/claude-3-opus:beta | paid
anthropic/claude-3-opus | paid
openai/gpt-4 | paid
openai/gpt-4-0314 | paid
openai/gpt-4-32k-0314 | paid
openai/gpt-4-32k | paid

 OpenAI models:

gpt-4o-audio-preview-2024-10-01
gpt-4o-realtime-preview
gpt-4o-realtime-preview-2024-10-01
o1-mini-2024-09-12
dall-e-2
gpt-4-turbo
gpt-4-1106-preview
gpt-3.5-turbo
gpt-3.5-turbo-0125
gpt-3.5-turbo-instruct
gpt-4-1106-vision-preview
babbage-002
davinci-002
whisper-1
dall-e-3
gpt-4o-mini-2024-07-18
text-embedding-3-small
gpt-4o-mini
gpt-3.5-turbo-16k
gpt-4-0125-preview
gpt-4-turbo-preview
omni-moderation-latest
gpt-4o-2024-05-13
omni-moderation-2024-09-26
tts-1-hd-1106
chatgpt-4o-latest
gpt-4
gpt-4-0613
o1-mini
o1-preview
o1-preview-2024-09-12
tts-1-hd
gpt-4-vision-preview
text-embedding-ada-002
gpt-3.5-turbo-1106
gpt-4o-audio-preview
tts-1
tts-1-1106
gpt-3.5-turbo-instruct-0914
text-embedding-3-large
gpt-4o-realtime-preview-2024-12-17
gpt-4o-mini-realtime-preview
gpt-4o-mini-realtime-preview-2024-12-17
gpt-4o-2024-11-20
gpt-4o-audio-preview-2024-12-17
gpt-4o-mini-audio-preview
gpt-4o-2024-08-06
gpt-4o-mini-audio-preview-2024-12-17
gpt-4o
gpt-4-turbo-2024-04-09
-----
*/
model?: string;
/** Router to use: openai or openrouter */
router?: string;
/** Chat completion type - completion (without tools) or tools (with function calling) */
type?: "completion" | "tools";
/** Logging level for the application */
logLevel?: unknown;
/** Profile for constants */
profile?: string;
/** Environment (in profile) */
env?: string;
/** Configuration as JSON string or path to JSON file, eg: {"openrouter":{"key":"your-key"}} or path/to/config.json */
config?: string | undefined;
/** Write out as script */
dump?: string | undefined;
/** Path to preferences file */
preferences?: string;
/** Logging directory */
logs?: string;
}
export interface IKBotOptions {
/** Path to the project directory */
path?: string;
/** Description of the modifications to make to the project. Supports file paths. */
query?: string;
/** Optional output path for modified files */
output?: string | undefined;
/** Optional destination path for the result, will substitute ${MODEL} and ${ROUTER} in the path */
dst?: string | undefined;
/** Template (typescript) or path to use for processing, see https://git.polymech.io/polymech/ai-template-typescript */
template?: (("typescript") | string) | undefined;
/** Template root directory. When specified, templates are loaded with a prefix, eg: ${POLYMECH-ROOT}/ai-template-${options.template} */
templateRoot?: string;
/** List of template parts to disable. Addionally, tools categories can be disabled, eg: --disable=fs,git,interact,terminal,search,web,email,user */
disable?: string[];
/** List of specific tools to disable */
disableTools?: string[];
/** Glob patterns to match files for processing, comma separated, eg: src/*.tsx,src/*.ts */
glob?: string[] | undefined;
/** AI model to use for processing. Available models:

 OpenRouter models:

google/gemini-pro-1.5-exp | paid
meta-llama/llama-3.2-11b-vision-instruct:free | free
google/gemini-flash-1.5-exp | paid
google/gemini-flash-1.5-8b-exp | paid
microsoft/phi-3-medium-128k-instruct:free | free
microsoft/phi-3-mini-128k-instruct:free | free
google/gemini-2.0-flash-thinking-exp:free | free
google/gemini-2.0-flash-exp:free | free
meta-llama/llama-3.2-1b-instruct | paid
meta-llama/llama-3.2-3b-instruct | paid
meta-llama/llama-3.1-8b-instruct | paid
mistralai/mistral-7b-instruct | paid
mistralai/mistral-7b-instruct-v0.3 | paid
meta-llama/llama-3-8b-instruct | paid
amazon/nova-micro-v1 | paid
google/gemini-flash-1.5-8b | paid
mistralai/ministral-3b | paid
meta-llama/llama-3.2-11b-vision-instruct | paid
amazon/nova-lite-v1 | paid
google/gemini-flash-1.5 | paid
mistralai/ministral-8b | paid
microsoft/phi-3-mini-128k-instruct | paid
microsoft/phi-3.5-mini-128k-instruct | paid
meta-llama/llama-3.1-70b-instruct | paid
nvidia/llama-3.1-nemotron-70b-instruct | paid
deepseek/deepseek-chat | paid
cohere/command-r-08-2024 | paid
mistralai/mistral-nemo | paid
mistralai/pixtral-12b | paid
openai/gpt-4o-mini | paid
openai/gpt-4o-mini-2024-07-18 | paid
mistralai/mistral-7b-instruct-v0.1 | paid
ai21/jamba-1-5-mini | paid
mistralai/mistral-small | paid
qwen/qwen-2.5-72b-instruct | paid
meta-llama/llama-3-70b-instruct | paid
mistralai/mixtral-8x7b-instruct | paid
mistralai/mistral-tiny | paid
mistralai/codestral-mamba | paid
anthropic/claude-3-haiku:beta | paid
anthropic/claude-3-haiku | paid
nousresearch/hermes-3-llama-3.1-70b | paid
cohere/command-r-03-2024 | paid
cohere/command-r | paid
openai/gpt-3.5-turbo-0125 | paid
google/gemini-pro | paid
openai/gpt-3.5-turbo | paid
mistralai/mixtral-8x7b-instruct:nitro | paid
meta-llama/llama-3.1-405b-instruct | paid
amazon/nova-pro-v1 | paid
anthropic/claude-3.5-haiku:beta | paid
anthropic/claude-3.5-haiku | paid
anthropic/claude-3.5-haiku-20241022:beta | paid
anthropic/claude-3.5-haiku-20241022 | paid
microsoft/phi-3-medium-128k-instruct | paid
openai/gpt-3.5-turbo-1106 | paid
openai/gpt-3.5-turbo-0613 | paid
meta-llama/llama-3.2-90b-vision-instruct | paid
google/gemini-pro-1.5 | paid
mistralai/mixtral-8x22b-instruct | paid
mistralai/mistral-large | paid
mistralai/mistral-large-2407 | paid
mistralai/mistral-large-2411 | paid
mistralai/pixtral-large-2411 | paid
ai21/jamba-1-5-large | paid
x-ai/grok-2-1212 | paid
cohere/command-r-plus-08-2024 | paid
openai/gpt-4o | paid
openai/gpt-4o-2024-08-06 | paid
openai/gpt-4o-2024-11-20 | paid
mistralai/mistral-medium | paid
cohere/command-r-plus | paid
cohere/command-r-plus-04-2024 | paid
openai/gpt-3.5-turbo-16k | paid
anthropic/claude-3.5-sonnet:beta | paid
anthropic/claude-3.5-sonnet | paid
anthropic/claude-3-sonnet:beta | paid
anthropic/claude-3-sonnet | paid
anthropic/claude-3.5-sonnet-20240620:beta | paid
anthropic/claude-3.5-sonnet-20240620 | paid
openai/gpt-4o-2024-05-13 | paid
x-ai/grok-beta | paid
x-ai/grok-vision-beta | paid
openai/gpt-4o:extended | paid
openai/gpt-4-turbo | paid
openai/gpt-4-1106-preview | paid
openai/gpt-4-turbo-preview | paid
openai/o1 | paid
anthropic/claude-3-opus:beta | paid
anthropic/claude-3-opus | paid
openai/gpt-4 | paid
openai/gpt-4-0314 | paid
openai/gpt-4-32k-0314 | paid
openai/gpt-4-32k | paid

 OpenAI models:

gpt-4o-audio-preview-2024-10-01
gpt-4o-realtime-preview
gpt-4o-realtime-preview-2024-10-01
o1-mini-2024-09-12
dall-e-2
gpt-4-turbo
gpt-4-1106-preview
gpt-3.5-turbo
gpt-3.5-turbo-0125
gpt-3.5-turbo-instruct
gpt-4-1106-vision-preview
babbage-002
davinci-002
whisper-1
dall-e-3
gpt-4o-mini-2024-07-18
text-embedding-3-small
gpt-4o-mini
gpt-3.5-turbo-16k
gpt-4-0125-preview
gpt-4-turbo-preview
omni-moderation-latest
gpt-4o-2024-05-13
omni-moderation-2024-09-26
tts-1-hd-1106
chatgpt-4o-latest
gpt-4
gpt-4-0613
o1-mini
o1-preview
o1-preview-2024-09-12
tts-1-hd
gpt-4-vision-preview
text-embedding-ada-002
gpt-3.5-turbo-1106
gpt-4o-audio-preview
tts-1
tts-1-1106
gpt-3.5-turbo-instruct-0914
text-embedding-3-large
gpt-4o-realtime-preview-2024-12-17
gpt-4o-mini-realtime-preview
gpt-4o-mini-realtime-preview-2024-12-17
gpt-4o-2024-11-20
gpt-4o-audio-preview-2024-12-17
gpt-4o-mini-audio-preview
gpt-4o-2024-08-06
gpt-4o-mini-audio-preview-2024-12-17
gpt-4o
gpt-4-turbo-2024-04-09
-----
*/
model?: string;
/** Router to use: openai or openrouter */
router?: string;
/** Chat completion type - completion (without tools) or tools (with function calling) */
type?: "completion" | "tools";
/** Logging level for the application */
logLevel?: unknown;
/** Profile for constants */
profile?: string;
/** Environment (in profile) */
env?: string;
/** Configuration as JSON string or path to JSON file, eg: {"openrouter":{"key":"your-key"}} or path/to/config.json */
config?: string | undefined;
/** Write out as script */
dump?: string | undefined;
/** Path to preferences file */
preferences?: string;
/** Logging directory */
logs?: string;
}

View File

@ -1,2 +1,2 @@
export {};
export {};
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHlwZXNfa2JvdC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3NyYy90eXBlc19rYm90LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiIifQ==

View File

@ -1 +1 @@
{"version":3,"file":"types_kbot.js","sourceRoot":"","sources":["../src/types_kbot.ts"],"names":[],"mappings":""}
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}

View File

@ -1,11 +1,10 @@
/// <reference types="node" resolution-mode="require"/>
import { URL } from 'url';
import * as path from 'path';
export interface IDownloadUrl {
urlParts: URL;
pathParts: path.ParsedPath;
filename: string;
path: string;
url: string;
}
export declare const parseForDownload: (url: string, dst: string) => IDownloadUrl;
import { URL } from 'url';
import * as path from 'path';
export interface IDownloadUrl {
urlParts: URL;
pathParts: path.ParsedPath;
filename: string;
path: string;
url: string;
}
export declare const parseForDownload: (url: string, dst: string) => IDownloadUrl;

View File

@ -1,23 +1,23 @@
import { URL } from 'url';
import * as path from 'path';
const filenamify = require('filenamify');
const _sanitize = require("sanitize-filename");
const sanitize_ex = (f) => {
let str = filenamify(_sanitize(f)).replace(/[^\x00-\x7F]/g, "").replace('_', '');
return str;
};
export const parseForDownload = (url, dst) => {
const parsed = new URL(url);
const parts = path.parse(parsed.pathname);
const filename = sanitize_ex(decodeURI(parts.base));
const downloadPath = path.resolve(`${dst}/${filename}`);
const downloadUrl = parsed.origin + parsed.pathname;
return {
urlParts: parsed,
pathParts: parts,
filename: filename,
path: downloadPath,
url: downloadUrl
};
};
import { URL } from 'url';
import * as path from 'path';
const filenamify = require('filenamify');
const _sanitize = require("sanitize-filename");
const sanitize_ex = (f) => {
let str = filenamify(_sanitize(f)).replace(/[^\x00-\x7F]/g, "").replace('_', '');
return str;
};
export const parseForDownload = (url, dst) => {
const parsed = new URL(url);
const parts = path.parse(parsed.pathname);
const filename = sanitize_ex(decodeURI(parts.base));
const downloadPath = path.resolve(`${dst}/${filename}`);
const downloadUrl = parsed.origin + parsed.pathname;
return {
urlParts: parsed,
pathParts: parts,
filename: filename,
path: downloadPath,
url: downloadUrl
};
};
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJ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EAAE,CAAC,CAAA;IACvD,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,GAAG,MAAM,CAAC,QAAQ,CAAA;IAEnD,OAAO;QACH,QAAQ,EAAC,MAAM;QACf,SAAS,EAAE,KAAK;QAChB,QAAQ,EAAE,QAAQ;QAClB,IAAI,EAAE,YAAY;QAClB,GAAG,EAAE,WAAW;KACnB,CAAA;AACL,CAAC,CAAA"}
{"version":3,"sources":["../src/uri.ts"],"sourcesContent":["import { URL } from 'url'\r\nimport * as path from 'path'\r\n\r\nconst filenamify = require('filenamify')\r\nconst _sanitize = require(\"sanitize-filename\")\r\n\r\nconst sanitize_ex = (f) => {\r\n let str: string = filenamify(_sanitize(f)).replace(/[^\\x00-\\x7F]/g, \"\").replace('_', '');\r\n return str;\r\n}\r\n\r\nexport interface IDownloadUrl{\r\n urlParts: URL\r\n pathParts: path.ParsedPath\r\n filename: string\r\n path:string\r\n url: string\r\n}\r\n\r\nexport const parseForDownload = (url: string, dst: string) : IDownloadUrl => {\r\n\r\n const parsed = new URL(url);\r\n const parts = path.parse(parsed.pathname)\r\n\r\n const filename = sanitize_ex(decodeURI(parts.base))\r\n const downloadPath = path.resolve(`${dst}/${filename}`)\r\n const downloadUrl = parsed.origin + parsed.pathname\r\n \r\n return {\r\n urlParts:parsed,\r\n pathParts: parts,\r\n filename: filename,\r\n path: downloadPath,\r\n url: downloadUrl\r\n }\r\n}"],"mappings":"AAAA,SAAS,WAAW;AACpB,YAAY,UAAU;AAEtB,MAAM,aAAa,QAAQ,YAAY;AACvC,MAAM,YAAY,QAAQ,mBAAmB;AAE7C,MAAM,cAAc,CAAC,MAAM;AACvB,MAAI,MAAc,WAAW,UAAU,CAAC,CAAC,EAAE,QAAQ,iBAAiB,EAAE,EAAE,QAAQ,KAAK,EAAE;AACvF,SAAO;AACX;AAUO,MAAM,mBAAmB,CAAC,KAAa,QAA+B;AAEzE,QAAM,SAAS,IAAI,IAAI,GAAG;AAC1B,QAAM,QAAQ,KAAK,MAAM,OAAO,QAAQ;AAExC,QAAM,WAAW,YAAY,UAAU,MAAM,IAAI,CAAC;AAClD,QAAM,eAAe,KAAK,QAAQ,GAAG,GAAG,IAAI,QAAQ,EAAE;AACtD,QAAM,cAAc,OAAO,SAAS,OAAO;AAE3C,SAAO;AAAA,IACH,UAAS;AAAA,IACT,WAAW;AAAA,IACX;AAAA,IACA,MAAM;AAAA,IACN,KAAK;AAAA,EACT;AACJ;","names":[]}

View File

@ -1,12 +1,12 @@
export declare const DATE_VARS: () => {
YYYY: number;
MM: number;
DD: number;
HH: number;
SS: number;
};
export declare const _substitute: (template: any, map: Record<string, any>, keep?: boolean, alt?: boolean) => any;
export declare const substitute: (alt: boolean, template: string, vars?: Record<string, any>, keep?: boolean) => any;
export declare const DEFAULT_VARS: (vars: any) => any;
export declare const resolveVariables: (_path: string, alt?: boolean, vars?: Record<string, string>) => any;
export declare const resolve: (_path: string, alt?: boolean, vars?: Record<string, string>) => any;
export declare const DATE_VARS: () => {
YYYY: number;
MM: number;
DD: number;
HH: number;
SS: number;
};
export declare const _substitute: (template: any, map: Record<string, any>, keep?: boolean, alt?: boolean) => any;
export declare const substitute: (alt: boolean, template: string, vars?: Record<string, any>, keep?: boolean) => any;
export declare const DEFAULT_VARS: (vars: any) => any;
export declare const resolveVariables: (_path: string, alt?: boolean, vars?: Record<string, string>) => any;
export declare const resolve: (_path: string, alt?: boolean, vars?: Record<string, string>) => any;

View File

@ -1,39 +1,39 @@
import { REGEX_VAR, REGEX_VAR_ALT } from "@polymech/core/constants";
import { DEFAULT_ROOTS } from './config.js';
export const DATE_VARS = () => {
return {
YYYY: new Date(Date.now()).getFullYear(),
MM: new Date(Date.now()).getMonth() + 1,
DD: new Date(Date.now()).getDate(),
HH: new Date(Date.now()).getHours(),
SS: new Date(Date.now()).getSeconds()
};
};
export const _substitute = (template, map, keep = true, alt = false) => {
const transform = (k) => k || '';
return template.replace(alt ? REGEX_VAR_ALT : REGEX_VAR, (match, key, format) => {
if (map[key]) {
return transform(map[key]).toString();
}
else if (map[key.replace(/-/g, '_')]) {
return transform(map[key.replace(/-/g, '_')]).toString();
}
else if (keep) {
return "${" + key + "}";
}
else {
return "";
}
});
};
export const substitute = (alt, template, vars = {}, keep = true) => alt ? _substitute(template, vars, keep, alt) : _substitute(template, vars, keep, alt);
export const DEFAULT_VARS = (vars) => {
return {
...DEFAULT_ROOTS,
...DATE_VARS(),
...vars
};
};
export const resolveVariables = (_path, alt = false, vars = {}) => substitute(alt, _path, DEFAULT_VARS(vars));
export const resolve = (_path, alt = false, vars = {}) => resolveVariables(_path, alt, vars);
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidmFyaWFibGVzLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vc3JjL3ZhcmlhYmxlcy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQUUsU0FBUyxFQUFFLGFBQWEsRUFBRSxNQUFNLDBCQUEwQixDQUFBO0FBRW5FLE9BQU8sRUFBRSxhQUFhLEVBQUUsTUFBTSxhQUFhLENBQUE7QUFFM0MsTUFBTSxDQUFDLE1BQU0sU0FBUyxHQUFHLEdBQUcsRUFBRTtJQUMxQixPQUFPO1FBQ0gsSUFBSSxFQUFFLElBQUksSUFBSSxDQUFDLElBQUksQ0FBQyxHQUFHLEVBQUUsQ0FBQyxDQUFDLFdBQVcsRUFBRTtRQUN4QyxFQUFFLEVBQUUsSUFBSSxJQUFJLENBQUMsSUFBSSxDQUFDLEdBQUcsRUFBRSxDQUFDLENBQUMsUUFBUSxFQUFFLEdBQUcsQ0FBQztRQUN2QyxFQUFFLEVBQUUsSUFBSSxJQUFJLENBQUMsSUFBSSxDQUFDLEdBQUcsRUFBRSxDQUFDLENBQUMsT0FBTyxFQUFFO1FBQ2xDLEVBQUUsRUFBRSxJQUFJLElBQUksQ0FBQyxJQUFJLENBQUMsR0FBRyxFQUFFLENBQUMsQ0F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UFDLENBQUMsQ0FBQTtBQUNOLENBQUMsQ0FBQTtBQUNELE1BQU0sQ0FBQyxNQUFNLFVBQVUsR0FBRyxDQUFDLEdBQVksRUFBRSxRQUFnQixFQUFFLE9BQTRCLEVBQUUsRUFBRSxPQUFnQixJQUFJLEVBQUUsRUFBRSxDQUFDLEdBQUcsQ0FBQyxDQUFDLENBQUMsV0FBVyxDQUFDLFFBQVEsRUFBRSxJQUFJLEVBQUUsSUFBSSxFQUFFLEdBQUcsQ0FBQyxDQUFDLENBQUMsQ0FBQyxXQUFXLENBQUMsUUFBUSxFQUFFLElBQUksRUFBRSxJQUFJLEVBQUUsR0FBRyxDQUFDLENBQUE7QUFDek0sTUFBTSxDQUFDLE1BQU0sWUFBWSxHQUFHLENBQUMsSUFBUyxFQUFFLEVBQUU7SUFDdEMsT0FBTztRQUNILEdBQUcsYUFBYTtRQUNoQixHQUFHLFNBQVMsRUFBRTtRQUNkLEdBQUcsSUFBSTtLQUNWLENBQUE7QUFDTCxDQUFDLENBQUE7QUFDRCxNQUFNLENBQUMsTUFBTSxnQkFBZ0IsR0FBRyxDQUFDLEtBQWEsRUFBRSxNQUFlLEtBQUssRUFBRSxPQUErQixFQUFFLEVBQUUsRUFBRSxDQUN2RyxVQUFVLENBQUMsR0FBRyxFQUFFLEtBQUssRUFBRSxZQUFZLENBQUMsSUFBSSxDQUFDLENBQUMsQ0FBQTtBQUU5QyxNQUFNLENBQUMsTUFBTSxPQUFPLEdBQUcsQ0FBQyxLQUFhLEVBQUUsTUFBZSxLQUFLLEVBQUUsT0FBK0IsRUFBRSxFQUFFLEVBQUUsQ0FDOUYsZ0JBQWdCLENBQUMsS0FBSyxFQUFFLEdBQUcsRUFBRSxJQUFJLENBQUMsQ0FBQSJ9
import { REGEX_VAR, REGEX_VAR_ALT } from "@polymech/core/constants";
import { DEFAULT_ROOTS } from './config.js';
export const DATE_VARS = () => {
return {
YYYY: new Date(Date.now()).getFullYear(),
MM: new Date(Date.now()).getMonth() + 1,
DD: new Date(Date.now()).getDate(),
HH: new Date(Date.now()).getHours(),
SS: new Date(Date.now()).getSeconds()
};
};
export const _substitute = (template, map, keep = true, alt = false) => {
const transform = (k) => k || '';
return template.replace(alt ? REGEX_VAR_ALT : REGEX_VAR, (match, key, format) => {
if (map[key]) {
return transform(map[key]).toString();
}
else if (map[key.replace(/-/g, '_')]) {
return transform(map[key.replace(/-/g, '_')]).toString();
}
else if (keep) {
return "${" + key + "}";
}
else {
return "";
}
});
};
export const substitute = (alt, template, vars = {}, keep = true) => alt ? _substitute(template, vars, keep, alt) : _substitute(template, vars, keep, alt);
export const DEFAULT_VARS = (vars) => {
return {
...DEFAULT_ROOTS,
...DATE_VARS(),
...vars
};
};
export const resolveVariables = (_path, alt = false, vars = {}) => substitute(alt, _path, DEFAULT_VARS(vars));
export const resolve = (_path, alt = false, vars = {}) => resolveVariables(_path, alt, vars);
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidmFyaWFibGVzLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vc3JjL3ZhcmlhYmxlcy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQUUsU0FBUyxFQUFFLGFBQWEsRUFBRSxNQUFNLDBCQUEwQixDQUFBO0FBRW5FLE9BQU8sRUFBRSxhQUFhLEVBQUUsTUFBTSxhQUFhLENBQUE7QUFFM0MsTUFBTSxDQUFDLE1BQU0sU0FBUyxHQUFHLEdBQUcsRUFBRTtJQUMxQixPQUFPO1FBQ0gsSUFBSSxFQUFFLElBQUksSUFBSSxDQUFDLElBQUksQ0FBQyxHQUFHLEVBQUUsQ0FBQyxDQUFDLFdBQVcsRUFBRTtRQUN4QyxFQUFFLEVBQUUsSUFBSSxJQUFJLENBQUMsSUFBSSxDQUFDLEdBQUcsRUFBRSxDQUFDLENBQUMsUUFBUSxFQUFFLEdBQUcsQ0FBQztRQUN2QyxFQUFFLEVBQU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"],"sourcesContent":["import { REGEX_VAR, REGEX_VAR_ALT } from \"@polymech/core/constants\"\r\n\r\nimport { DEFAULT_ROOTS } from './config.js'\r\n\r\nexport const DATE_VARS = () => {\r\n return {\r\n YYYY: new Date(Date.now()).getFullYear(),\r\n MM: new Date(Date.now()).getMonth() + 1,\r\n DD: new Date(Date.now()).getDate(),\r\n HH: new Date(Date.now()).getHours(),\r\n SS: new Date(Date.now()).getSeconds()\r\n }\r\n}\r\n\r\nexport const _substitute = (template, map: Record<string, any>, keep: boolean = true, alt: boolean = false) => {\r\n const transform = (k) => k || ''\r\n return template.replace(alt ? REGEX_VAR_ALT : REGEX_VAR, (match, key, format) => {\r\n if (map[key]) {\r\n return transform(map[key]).toString()\r\n } else if (map[key.replace(/-/g, '_')]) {\r\n return transform(map[key.replace(/-/g, '_')]).toString()\r\n } else if (keep) {\r\n return \"${\" + key + \"}\"\r\n } else {\r\n return \"\"\r\n }\r\n })\r\n}\r\nexport const substitute = (alt: boolean, template: string, vars: Record<string, any> = {}, keep: boolean = true) => alt ? _substitute(template, vars, keep, alt) : _substitute(template, vars, keep, alt)\r\nexport const DEFAULT_VARS = (vars: any) => {\r\n return {\r\n ...DEFAULT_ROOTS,\r\n ...DATE_VARS(),\r\n ...vars\r\n }\r\n}\r\nexport const resolveVariables = (_path: string, alt: boolean = false, vars: Record<string, string> = {}) =>\r\n substitute(alt, _path, DEFAULT_VARS(vars))\r\n\r\nexport const resolve = (_path: string, alt: boolean = false, vars: Record<string, string> = {}) =>\r\n resolveVariables(_path, alt, vars)\r\n"],"mappings":"AAAA,SAAS,WAAW,qBAAqB;AAEzC,SAAS,qBAAqB;AAEvB,MAAM,YAAY,MAAM;AAC3B,SAAO;AAAA,IACH,MAAM,IAAI,KAAK,KAAK,IAAI,CAAC,EAAE,YAAY;AAAA,IACvC,IAAI,IAAI,KAAK,KAAK,IAAI,CAAC,EAAE,SAAS,IAAI;AAAA,IACtC,IAAI,IAAI,KAAK,KAAK,IAAI,CAAC,EAAE,QAAQ;AAAA,IACjC,IAAI,IAAI,KAAK,KAAK,IAAI,CAAC,EAAE,SAAS;AAAA,IAClC,IAAI,IAAI,KAAK,KAAK,IAAI,CAAC,EAAE,WAAW;AAAA,EACxC;AACJ;AAEO,MAAM,cAAc,CAAC,UAAU,KAA0B,OAAgB,MAAM,MAAe,UAAU;AAC3G,QAAM,YAAY,CAAC,MAAM,KAAK;AAC9B,SAAO,SAAS,QAAQ,MAAM,gBAAgB,WAAW,CAAC,OAAO,KAAK,WAAW;AAC7E,QAAI,IAAI,GAAG,GAAG;AACV,aAAO,UAAU,IAAI,GAAG,CAAC,EAAE,SAAS;AAAA,IACxC,WAAW,IAAI,IAAI,QAAQ,MAAM,GAAG,CAAC,GAAG;AACpC,aAAO,UAAU,IAAI,IAAI,QAAQ,MAAM,GAAG,CAAC,CAAC,EAAE,SAAS;AAAA,IAC3D,WAAW,MAAM;AACb,aAAO,OAAO,MAAM;AAAA,IACxB,OAAO;AACH,aAAO;AAAA,IACX;AAAA,EACJ,CAAC;AACL;AACO,MAAM,aAAa,CAAC,KAAc,UAAkB,OAA4B,CAAC,GAAG,OAAgB,SAAS,MAAM,YAAY,UAAU,MAAM,MAAM,GAAG,IAAI,YAAY,UAAU,MAAM,MAAM,GAAG;AACjM,MAAM,eAAe,CAAC,SAAc;AACvC,SAAO;AAAA,IACH,GAAG;AAAA,IACH,GAAG,UAAU;AAAA,IACb,GAAG;AAAA,EACP;AACJ;AACO,MAAM,mBAAmB,CAAC,OAAe,MAAe,OAAO,OAA+B,CAAC,MAClG,WAAW,KAAK,OAAO,aAAa,IAAI,CAAC;AAEtC,MAAM,UAAU,CAAC,OAAe,MAAe,OAAO,OAA+B,CAAC,MACzF,iBAAiB,OAAO,KAAK,IAAI;","names":[]}

View File

@ -1,95 +0,0 @@
import tseslint from 'typescript-eslint';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
// plugins
import regexpEslint from 'eslint-plugin-regexp';
const typescriptEslint = tseslint.plugin;
// parsers
const typescriptParser = tseslint.parser;
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
/** @type {import('eslint').Linter.Config[]} */
export default [
{
files: ["src/*.{ts}"]
},
...tseslint.configs.recommendedTypeChecked,
...tseslint.configs.stylisticTypeChecked,
regexpEslint.configs['flat/recommended'],
{
languageOptions: {
parser: typescriptParser,
parserOptions: {
project: ['./packages/*/tsconfig.json', './tsconfig.eslint.json'],
tsconfigRootDir: __dirname,
},
},
plugins: {
'@typescript-eslint': typescriptEslint,
regexp: regexpEslint,
},
rules: {
// These off/configured-differently-by-default rules fit well for us
'@typescript-eslint/switch-exhaustiveness-check': 'error',
'@typescript-eslint/no-shadow': 'off',
'no-console': 'off',
'@typescript-eslint/no-unsafe-enum-comparison' : 'off',
'@typescript-eslint/no-empty-object-type': 'off',
// Todo: do we want these?
'no-var': 'off',
'regexp/prefer-regexp-exec': 'off',
'@typescript-eslint/no-duplicate-enum-values': 'off',
'@typescript-eslint/no-unsafe-function-type': 'off',
'@typescript-eslint/prefer-for-of': 'off',
'@typescript-eslint/no-unused-vars': 'off',
'@typescript-eslint/array-type': 'off',
'@typescript-eslint/ban-ts-comment': 'off',
'@typescript-eslint/class-literal-property-style': 'off',
'@typescript-eslint/consistent-indexed-object-style': 'off',
'@typescript-eslint/consistent-type-definitions': 'off',
'@typescript-eslint/dot-notation': 'off',
'@typescript-eslint/no-base-to-string': 'off',
'@typescript-eslint/no-empty-function': 'off',
'@typescript-eslint/no-floating-promises': 'off',
'@typescript-eslint/no-misused-promises': 'off',
'@typescript-eslint/no-redundant-type-constituents': 'off',
'@typescript-eslint/no-this-alias': 'off',
'@typescript-eslint/no-unsafe-argument': 'off',
'@typescript-eslint/no-unsafe-assignment': 'off',
'@typescript-eslint/no-unsafe-call': 'off',
'@typescript-eslint/no-unsafe-member-access': 'off',
'@typescript-eslint/no-unused-expressions': 'off',
'@typescript-eslint/only-throw-error': 'off',
'@typescript-eslint/no-unsafe-return': 'off',
'@typescript-eslint/no-unnecessary-type-assertion': 'off',
'@typescript-eslint/prefer-nullish-coalescing': 'off',
'@typescript-eslint/prefer-optional-chain': 'off',
'@typescript-eslint/prefer-promise-reject-errors': 'off',
'@typescript-eslint/prefer-string-starts-ends-with': 'off',
'@typescript-eslint/require-await': 'off',
'@typescript-eslint/restrict-plus-operands': 'off',
'@typescript-eslint/restrict-template-expressions': 'off',
'@typescript-eslint/sort-type-constituents': 'off',
'@typescript-eslint/unbound-method': 'off',
'@typescript-eslint/no-explicit-any': 'off',
// Used by Biome
'@typescript-eslint/consistent-type-imports': 'off',
// These rules enabled by the preset configs don't work well for us
'@typescript-eslint/await-thenable': 'off',
'prefer-const': 'off',
// In some cases, using explicit letter-casing is more performant than the `i` flag
'regexp/use-ignore-case': 'off',
'regexp/prefer-regexp-exec': 'warn',
'regexp/prefer-regexp-test': 'warn',
'no-control-regex': 'off'
}
}
]

View File

@ -65,7 +65,7 @@
"@polymech/fs": "link:..\\fs",
"@schemastore/package": "^0.0.10",
"env-var": "^7.5.0",
"glob": "^10.4.1",
"glob": "^10.4.5",
"js-yaml": "^4.1.0",
"tslog": "^3.3.3",
"tsup": "^8.3.5",
@ -75,17 +75,9 @@
"zod-to-ts": "^1.2.0"
},
"devDependencies": {
"@eslint/js": "^9.18.0",
"@repo/eslint-config": "workspace:*",
"@repo/typescript-config": "workspace:*",
"@types/node": "^8.10.66",
"eslint": "^8.57.1",
"eslint-plugin-import": "^2.31.0",
"eslint-plugin-regexp": "^2.7.0",
"globals": "^15.14.0",
"ts-node": "^10.9.1",
"typescript": "^4.9.5",
"typescript-eslint": "^8.20.0"
"@types/node": "^22.12.0",
"typescript": "^5.7.3"
},
"scripts": {
"test": "tsc && mocha build/test",

View File

@ -7,7 +7,6 @@ import { sync as exists } from '@polymech/fs/exists'
export const files = (cwd, glob, options?: any) => globSync(glob, { ...{ dot: true, cwd, absolute: true, caseSensitiveMatch: false }, ...options || {} }) as []
export const filesEx = (cwd, glob, options?: GlobOptions) => globSync(glob, { ...{ dot: true, cwd, absolute: true, caseSensitiveMatch: false }, ...options || {} }) as []
import { substitute } from '../variables.js'
import { isFile, isFolder } from '../fs.js'
import { PATH_INFO } from '../types_common.js'
@ -18,8 +17,6 @@ export { globParent } from './glob-parent.js'
const GLOB_GROUP_PATTERN = /[!*+?@]\(.*\)/
export const getExtensions = (glob: string) => {
//const parseGlob = require('parse-glob')
//https://github.com/micromatch/parse-glob/blob/master/index.js
const match = glob.match(GLOB_GROUP_PATTERN);
if (match) {
return glob.substring((match.index || 0) + 2, glob.lastIndexOf(')')).split('|')

View File

@ -1,287 +1,287 @@
import { CancellationToken } from './cancellation.js';
import { ISplice } from './sequence.js';
/**
* Returns the last element of an array.
* @param array The array.
* @param n Which element from the end (default is zero).
*/
export declare function tail<T>(array: ArrayLike<T>, n?: number): T | undefined;
export declare function tail2<T>(arr: T[]): [T[], T];
export declare function equals<T>(one: ReadonlyArray<T> | undefined, other: ReadonlyArray<T> | undefined, itemEquals?: (a: T, b: T) => boolean): boolean;
/**
* Remove the element at `index` by replacing it with the last element. This is faster than `splice`
* but changes the order of the array
*/
export declare function removeFastWithoutKeepingOrder<T>(array: T[], index: number): void;
/**
* Performs a binary search algorithm over a sorted array.
*
* @param array The array being searched.
* @param key The value we search for.
* @param comparator A function that takes two array elements and returns zero
* if they are equal, a negative number if the first element precedes the
* second one in the sorting order, or a positive number if the second element
* precedes the first one.
* @return See {@link binarySearch2}
*/
export declare function binarySearch<T>(array: ReadonlyArray<T>, key: T, comparator: (op1: T, op2: T) => number): number;
/**
* Performs a binary search algorithm over a sorted collection. Useful for cases
* when we need to perform a binary search over something that isn't actually an
* array, and converting data to an array would defeat the use of binary search
* in the first place.
*
* @param length The collection length.
* @param compareToKey A function that takes an index of an element in the
* collection and returns zero if the value at this index is equal to the
* search key, a negative number if the value precedes the search key in the
* sorting order, or a positive number if the search key precedes the value.
* @return A non-negative index of an element, if found. If not found, the
* result is -(n+1) (or ~n, using bitwise notation), where n is the index
* where the key should be inserted to maintain the sorting order.
*/
export declare function binarySearch2(length: number, compareToKey: (index: number) => number): number;
type Compare<T> = (a: T, b: T) => number;
export declare function quickSelect<T>(nth: number, data: T[], compare: Compare<T>): T;
export declare function groupBy<T>(data: ReadonlyArray<T>, compare: (a: T, b: T) => number): T[][];
/**
* Splits the given items into a list of (non-empty) groups.
* `shouldBeGrouped` is used to decide if two consecutive items should be in the same group.
* The order of the items is preserved.
*/
export declare function groupAdjacentBy<T>(items: Iterable<T>, shouldBeGrouped: (item1: T, item2: T) => boolean): Iterable<T[]>;
export declare function forEachAdjacent<T>(arr: T[], f: (item1: T | undefined, item2: T | undefined) => void): void;
export declare function forEachWithNeighbors<T>(arr: T[], f: (before: T | undefined, element: T, after: T | undefined) => void): void;
/**
* Diffs two *sorted* arrays and computes the splices which apply the diff.
*/
export declare function sortedDiff<T>(before: ReadonlyArray<T>, after: ReadonlyArray<T>, compare: (a: T, b: T) => number): ISplice<T>[];
/**
* Takes two *sorted* arrays and computes their delta (removed, added elements).
* Finishes in `Math.min(before.length, after.length)` steps.
*/
export declare function delta<T>(before: ReadonlyArray<T>, after: ReadonlyArray<T>, compare: (a: T, b: T) => number): {
removed: T[];
added: T[];
};
/**
* Returns the top N elements from the array.
*
* Faster than sorting the entire array when the array is a lot larger than N.
*
* @param array The unsorted array.
* @param compare A sort function for the elements.
* @param n The number of elements to return.
* @return The first n elements from array when sorted with compare.
*/
export declare function top<T>(array: ReadonlyArray<T>, compare: (a: T, b: T) => number, n: number): T[];
/**
* Asynchronous variant of `top()` allowing for splitting up work in batches between which the event loop can run.
*
* Returns the top N elements from the array.
*
* Faster than sorting the entire array when the array is a lot larger than N.
*
* @param array The unsorted array.
* @param compare A sort function for the elements.
* @param n The number of elements to return.
* @param batch The number of elements to examine before yielding to the event loop.
* @return The first n elements from array when sorted with compare.
*/
export declare function topAsync<T>(array: T[], compare: (a: T, b: T) => number, n: number, batch: number, token?: CancellationToken): Promise<T[]>;
/**
* @returns New array with all falsy values removed. The original array IS NOT modified.
*/
export declare function coalesce<T>(array: ReadonlyArray<T | undefined | null>): T[];
/**
* Remove all falsy values from `array`. The original array IS modified.
*/
export declare function coalesceInPlace<T>(array: Array<T | undefined | null>): asserts array is Array<T>;
/**
* @deprecated Use `Array.copyWithin` instead
*/
export declare function move(array: unknown[], from: number, to: number): void;
/**
* @returns false if the provided object is an array and not empty.
*/
export declare function isFalsyOrEmpty(obj: any): boolean;
/**
* @returns True if the provided object is an array and has at least one element.
*/
export declare function isNonEmptyArray<T>(obj: T[] | undefined | null): obj is T[];
export declare function isNonEmptyArray<T>(obj: readonly T[] | undefined | null): obj is readonly T[];
/**
* Removes duplicates from the given array. The optional keyFn allows to specify
* how elements are checked for equality by returning an alternate value for each.
*/
export declare function distinct<T>(array: ReadonlyArray<T>, keyFn?: (value: T) => unknown): T[];
export declare function uniqueFilter<T, R>(keyFn: (t: T) => R): (t: T) => boolean;
export declare function commonPrefixLength<T>(one: ReadonlyArray<T>, other: ReadonlyArray<T>, equals?: (a: T, b: T) => boolean): number;
export declare function range(to: number): number[];
export declare function range(from: number, to: number): number[];
export declare function index<T>(array: ReadonlyArray<T>, indexer: (t: T) => string): {
[key: string]: T;
};
export declare function index<T, R>(array: ReadonlyArray<T>, indexer: (t: T) => string, mapper: (t: T) => R): {
[key: string]: R;
};
/**
* Inserts an element into an array. Returns a function which, when
* called, will remove that element from the array.
*
* @deprecated In almost all cases, use a `Set<T>` instead.
*/
export declare function insert<T>(array: T[], element: T): () => void;
/**
* Removes an element from an array if it can be found.
*
* @deprecated In almost all cases, use a `Set<T>` instead.
*/
export declare function remove<T>(array: T[], element: T): T | undefined;
/**
* Insert `insertArr` inside `target` at `insertIndex`.
* Please don't touch unless you understand https://jsperf.com/inserting-an-array-within-an-array
*/
export declare function arrayInsert<T>(target: T[], insertIndex: number, insertArr: T[]): T[];
/**
* Uses Fisher-Yates shuffle to shuffle the given array
*/
export declare function shuffle<T>(array: T[], _seed?: number): void;
/**
* Pushes an element to the start of the array, if found.
*/
export declare function pushToStart<T>(arr: T[], value: T): void;
/**
* Pushes an element to the end of the array, if found.
*/
export declare function pushToEnd<T>(arr: T[], value: T): void;
export declare function pushMany<T>(arr: T[], items: ReadonlyArray<T>): void;
export declare function mapArrayOrNot<T, U>(items: T | T[], fn: (_: T) => U): U | U[];
export declare function asArray<T>(x: T | T[]): T[];
export declare function asArray<T>(x: T | readonly T[]): readonly T[];
export declare function getRandomElement<T>(arr: T[]): T | undefined;
/**
* Insert the new items in the array.
* @param array The original array.
* @param start The zero-based location in the array from which to start inserting elements.
* @param newItems The items to be inserted
*/
export declare function insertInto<T>(array: T[], start: number, newItems: T[]): void;
/**
* Removes elements from an array and inserts new elements in their place, returning the deleted elements. Alternative to the native Array.splice method, it
* can only support limited number of items due to the maximum call stack size limit.
* @param array The original array.
* @param start The zero-based location in the array from which to start removing elements.
* @param deleteCount The number of elements to remove.
* @returns An array containing the elements that were deleted.
*/
export declare function splice<T>(array: T[], start: number, deleteCount: number, newItems: T[]): T[];
/**
* When comparing two values,
* a negative number indicates that the first value is less than the second,
* a positive number indicates that the first value is greater than the second,
* and zero indicates that neither is the case.
*/
export type CompareResult = number;
export declare namespace CompareResult {
function isLessThan(result: CompareResult): boolean;
function isLessThanOrEqual(result: CompareResult): boolean;
function isGreaterThan(result: CompareResult): boolean;
function isNeitherLessOrGreaterThan(result: CompareResult): boolean;
const greaterThan = 1;
const lessThan = -1;
const neitherLessOrGreaterThan = 0;
}
/**
* A comparator `c` defines a total order `<=` on `T` as following:
* `c(a, b) <= 0` iff `a` <= `b`.
* We also have `c(a, b) == 0` iff `c(b, a) == 0`.
*/
export type Comparator<T> = (a: T, b: T) => CompareResult;
export declare function compareBy<TItem, TCompareBy>(selector: (item: TItem) => TCompareBy, comparator: Comparator<TCompareBy>): Comparator<TItem>;
export declare function tieBreakComparators<TItem>(...comparators: Comparator<TItem>[]): Comparator<TItem>;
/**
* The natural order on numbers.
*/
export declare const numberComparator: Comparator<number>;
export declare const booleanComparator: Comparator<boolean>;
export declare function reverseOrder<TItem>(comparator: Comparator<TItem>): Comparator<TItem>;
export declare class ArrayQueue<T> {
private firstIdx;
private items;
private lastIdx;
/**
* Constructs a queue that is backed by the given array. Runtime is O(1).
*/
constructor();
get length(): number;
/**
* Consumes elements from the beginning of the queue as long as the predicate returns true.
* If no elements were consumed, `null` is returned. Has a runtime of O(result.length).
*/
takeWhile(predicate: (value: T) => boolean): T[] | null;
/**
* Consumes elements from the end of the queue as long as the predicate returns true.
* If no elements were consumed, `null` is returned.
* The result has the same order as the underlying array!
*/
takeFromEndWhile(predicate: (value: T) => boolean): T[] | null;
peek(): T | undefined;
peekLast(): T | undefined;
dequeue(): T | undefined;
removeLast(): T | undefined;
takeCount(count: number): T[];
}
/**
* This class is faster than an iterator and array for lazy computed data.
*/
export declare class CallbackIterable<T> {
/**
* Calls the callback for every item.
* Stops when the callback returns false.
*/
readonly iterate: (callback: (item: T) => boolean) => void;
static readonly empty: CallbackIterable<never>;
constructor(
/**
* Calls the callback for every item.
* Stops when the callback returns false.
*/
iterate: (callback: (item: T) => boolean) => void);
forEach(handler: (item: T) => void): void;
toArray(): T[];
filter(predicate: (item: T) => boolean): CallbackIterable<T>;
map<TResult>(mapFn: (item: T) => TResult): CallbackIterable<TResult>;
some(predicate: (item: T) => boolean): boolean;
findFirst(predicate: (item: T) => boolean): T | undefined;
findLast(predicate: (item: T) => boolean): T | undefined;
findLastMaxBy(comparator: Comparator<T>): T | undefined;
}
/**
* Represents a re-arrangement of items in an array.
*/
export declare class Permutation {
private readonly _indexMap;
constructor(_indexMap: readonly number[]);
/**
* Returns a permutation that sorts the given array according to the given compare function.
*/
static createSortPermutation<T>(arr: readonly T[], compareFn: (a: T, b: T) => number): Permutation;
/**
* Returns a new array with the elements of the given array re-arranged according to this permutation.
*/
apply<T>(arr: readonly T[]): T[];
/**
* Returns a new permutation that undoes the re-arrangement of this permutation.
*/
inverse(): Permutation;
}
/**
* Asynchronous variant of `Array.find()`, returning the first element in
* the array for which the predicate returns true.
*
* This implementation does not bail early and waits for all promises to
* resolve before returning.
*/
export declare function findAsync<T>(array: readonly T[], predicate: (element: T, index: number) => Promise<boolean>): Promise<T | undefined>;
export {};
import { CancellationToken } from './cancellation.js';
import { ISplice } from './sequence.js';
/**
* Returns the last element of an array.
* @param array The array.
* @param n Which element from the end (default is zero).
*/
export declare function tail<T>(array: ArrayLike<T>, n?: number): T | undefined;
export declare function tail2<T>(arr: T[]): [T[], T];
export declare function equals<T>(one: ReadonlyArray<T> | undefined, other: ReadonlyArray<T> | undefined, itemEquals?: (a: T, b: T) => boolean): boolean;
/**
* Remove the element at `index` by replacing it with the last element. This is faster than `splice`
* but changes the order of the array
*/
export declare function removeFastWithoutKeepingOrder<T>(array: T[], index: number): void;
/**
* Performs a binary search algorithm over a sorted array.
*
* @param array The array being searched.
* @param key The value we search for.
* @param comparator A function that takes two array elements and returns zero
* if they are equal, a negative number if the first element precedes the
* second one in the sorting order, or a positive number if the second element
* precedes the first one.
* @return See {@link binarySearch2}
*/
export declare function binarySearch<T>(array: ReadonlyArray<T>, key: T, comparator: (op1: T, op2: T) => number): number;
/**
* Performs a binary search algorithm over a sorted collection. Useful for cases
* when we need to perform a binary search over something that isn't actually an
* array, and converting data to an array would defeat the use of binary search
* in the first place.
*
* @param length The collection length.
* @param compareToKey A function that takes an index of an element in the
* collection and returns zero if the value at this index is equal to the
* search key, a negative number if the value precedes the search key in the
* sorting order, or a positive number if the search key precedes the value.
* @return A non-negative index of an element, if found. If not found, the
* result is -(n+1) (or ~n, using bitwise notation), where n is the index
* where the key should be inserted to maintain the sorting order.
*/
export declare function binarySearch2(length: number, compareToKey: (index: number) => number): number;
type Compare<T> = (a: T, b: T) => number;
export declare function quickSelect<T>(nth: number, data: T[], compare: Compare<T>): T;
export declare function groupBy<T>(data: ReadonlyArray<T>, compare: (a: T, b: T) => number): T[][];
/**
* Splits the given items into a list of (non-empty) groups.
* `shouldBeGrouped` is used to decide if two consecutive items should be in the same group.
* The order of the items is preserved.
*/
export declare function groupAdjacentBy<T>(items: Iterable<T>, shouldBeGrouped: (item1: T, item2: T) => boolean): Iterable<T[]>;
export declare function forEachAdjacent<T>(arr: T[], f: (item1: T | undefined, item2: T | undefined) => void): void;
export declare function forEachWithNeighbors<T>(arr: T[], f: (before: T | undefined, element: T, after: T | undefined) => void): void;
/**
* Diffs two *sorted* arrays and computes the splices which apply the diff.
*/
export declare function sortedDiff<T>(before: ReadonlyArray<T>, after: ReadonlyArray<T>, compare: (a: T, b: T) => number): ISplice<T>[];
/**
* Takes two *sorted* arrays and computes their delta (removed, added elements).
* Finishes in `Math.min(before.length, after.length)` steps.
*/
export declare function delta<T>(before: ReadonlyArray<T>, after: ReadonlyArray<T>, compare: (a: T, b: T) => number): {
removed: T[];
added: T[];
};
/**
* Returns the top N elements from the array.
*
* Faster than sorting the entire array when the array is a lot larger than N.
*
* @param array The unsorted array.
* @param compare A sort function for the elements.
* @param n The number of elements to return.
* @return The first n elements from array when sorted with compare.
*/
export declare function top<T>(array: ReadonlyArray<T>, compare: (a: T, b: T) => number, n: number): T[];
/**
* Asynchronous variant of `top()` allowing for splitting up work in batches between which the event loop can run.
*
* Returns the top N elements from the array.
*
* Faster than sorting the entire array when the array is a lot larger than N.
*
* @param array The unsorted array.
* @param compare A sort function for the elements.
* @param n The number of elements to return.
* @param batch The number of elements to examine before yielding to the event loop.
* @return The first n elements from array when sorted with compare.
*/
export declare function topAsync<T>(array: T[], compare: (a: T, b: T) => number, n: number, batch: number, token?: CancellationToken): Promise<T[]>;
/**
* @returns New array with all falsy values removed. The original array IS NOT modified.
*/
export declare function coalesce<T>(array: ReadonlyArray<T | undefined | null>): T[];
/**
* Remove all falsy values from `array`. The original array IS modified.
*/
export declare function coalesceInPlace<T>(array: Array<T | undefined | null>): asserts array is Array<T>;
/**
* @deprecated Use `Array.copyWithin` instead
*/
export declare function move(array: unknown[], from: number, to: number): void;
/**
* @returns false if the provided object is an array and not empty.
*/
export declare function isFalsyOrEmpty(obj: any): boolean;
/**
* @returns True if the provided object is an array and has at least one element.
*/
export declare function isNonEmptyArray<T>(obj: T[] | undefined | null): obj is T[];
export declare function isNonEmptyArray<T>(obj: readonly T[] | undefined | null): obj is readonly T[];
/**
* Removes duplicates from the given array. The optional keyFn allows to specify
* how elements are checked for equality by returning an alternate value for each.
*/
export declare function distinct<T>(array: ReadonlyArray<T>, keyFn?: (value: T) => unknown): T[];
export declare function uniqueFilter<T, R>(keyFn: (t: T) => R): (t: T) => boolean;
export declare function commonPrefixLength<T>(one: ReadonlyArray<T>, other: ReadonlyArray<T>, equals?: (a: T, b: T) => boolean): number;
export declare function range(to: number): number[];
export declare function range(from: number, to: number): number[];
export declare function index<T>(array: ReadonlyArray<T>, indexer: (t: T) => string): {
[key: string]: T;
};
export declare function index<T, R>(array: ReadonlyArray<T>, indexer: (t: T) => string, mapper: (t: T) => R): {
[key: string]: R;
};
/**
* Inserts an element into an array. Returns a function which, when
* called, will remove that element from the array.
*
* @deprecated In almost all cases, use a `Set<T>` instead.
*/
export declare function insert<T>(array: T[], element: T): () => void;
/**
* Removes an element from an array if it can be found.
*
* @deprecated In almost all cases, use a `Set<T>` instead.
*/
export declare function remove<T>(array: T[], element: T): T | undefined;
/**
* Insert `insertArr` inside `target` at `insertIndex`.
* Please don't touch unless you understand https://jsperf.com/inserting-an-array-within-an-array
*/
export declare function arrayInsert<T>(target: T[], insertIndex: number, insertArr: T[]): T[];
/**
* Uses Fisher-Yates shuffle to shuffle the given array
*/
export declare function shuffle<T>(array: T[], _seed?: number): void;
/**
* Pushes an element to the start of the array, if found.
*/
export declare function pushToStart<T>(arr: T[], value: T): void;
/**
* Pushes an element to the end of the array, if found.
*/
export declare function pushToEnd<T>(arr: T[], value: T): void;
export declare function pushMany<T>(arr: T[], items: ReadonlyArray<T>): void;
export declare function mapArrayOrNot<T, U>(items: T | T[], fn: (_: T) => U): U | U[];
export declare function asArray<T>(x: T | T[]): T[];
export declare function asArray<T>(x: T | readonly T[]): readonly T[];
export declare function getRandomElement<T>(arr: T[]): T | undefined;
/**
* Insert the new items in the array.
* @param array The original array.
* @param start The zero-based location in the array from which to start inserting elements.
* @param newItems The items to be inserted
*/
export declare function insertInto<T>(array: T[], start: number, newItems: T[]): void;
/**
* Removes elements from an array and inserts new elements in their place, returning the deleted elements. Alternative to the native Array.splice method, it
* can only support limited number of items due to the maximum call stack size limit.
* @param array The original array.
* @param start The zero-based location in the array from which to start removing elements.
* @param deleteCount The number of elements to remove.
* @returns An array containing the elements that were deleted.
*/
export declare function splice<T>(array: T[], start: number, deleteCount: number, newItems: T[]): T[];
/**
* When comparing two values,
* a negative number indicates that the first value is less than the second,
* a positive number indicates that the first value is greater than the second,
* and zero indicates that neither is the case.
*/
export type CompareResult = number;
export declare namespace CompareResult {
function isLessThan(result: CompareResult): boolean;
function isLessThanOrEqual(result: CompareResult): boolean;
function isGreaterThan(result: CompareResult): boolean;
function isNeitherLessOrGreaterThan(result: CompareResult): boolean;
const greaterThan = 1;
const lessThan = -1;
const neitherLessOrGreaterThan = 0;
}
/**
* A comparator `c` defines a total order `<=` on `T` as following:
* `c(a, b) <= 0` iff `a` <= `b`.
* We also have `c(a, b) == 0` iff `c(b, a) == 0`.
*/
export type Comparator<T> = (a: T, b: T) => CompareResult;
export declare function compareBy<TItem, TCompareBy>(selector: (item: TItem) => TCompareBy, comparator: Comparator<TCompareBy>): Comparator<TItem>;
export declare function tieBreakComparators<TItem>(...comparators: Comparator<TItem>[]): Comparator<TItem>;
/**
* The natural order on numbers.
*/
export declare const numberComparator: Comparator<number>;
export declare const booleanComparator: Comparator<boolean>;
export declare function reverseOrder<TItem>(comparator: Comparator<TItem>): Comparator<TItem>;
export declare class ArrayQueue<T> {
private firstIdx;
private items;
private lastIdx;
/**
* Constructs a queue that is backed by the given array. Runtime is O(1).
*/
constructor();
get length(): number;
/**
* Consumes elements from the beginning of the queue as long as the predicate returns true.
* If no elements were consumed, `null` is returned. Has a runtime of O(result.length).
*/
takeWhile(predicate: (value: T) => boolean): T[] | null;
/**
* Consumes elements from the end of the queue as long as the predicate returns true.
* If no elements were consumed, `null` is returned.
* The result has the same order as the underlying array!
*/
takeFromEndWhile(predicate: (value: T) => boolean): T[] | null;
peek(): T | undefined;
peekLast(): T | undefined;
dequeue(): T | undefined;
removeLast(): T | undefined;
takeCount(count: number): T[];
}
/**
* This class is faster than an iterator and array for lazy computed data.
*/
export declare class CallbackIterable<T> {
/**
* Calls the callback for every item.
* Stops when the callback returns false.
*/
readonly iterate: (callback: (item: T) => boolean) => void;
static readonly empty: CallbackIterable<never>;
constructor(
/**
* Calls the callback for every item.
* Stops when the callback returns false.
*/
iterate: (callback: (item: T) => boolean) => void);
forEach(handler: (item: T) => void): void;
toArray(): T[];
filter(predicate: (item: T) => boolean): CallbackIterable<T>;
map<TResult>(mapFn: (item: T) => TResult): CallbackIterable<TResult>;
some(predicate: (item: T) => boolean): boolean;
findFirst(predicate: (item: T) => boolean): T | undefined;
findLast(predicate: (item: T) => boolean): T | undefined;
findLastMaxBy(comparator: Comparator<T>): T | undefined;
}
/**
* Represents a re-arrangement of items in an array.
*/
export declare class Permutation {
private readonly _indexMap;
constructor(_indexMap: readonly number[]);
/**
* Returns a permutation that sorts the given array according to the given compare function.
*/
static createSortPermutation<T>(arr: readonly T[], compareFn: (a: T, b: T) => number): Permutation;
/**
* Returns a new array with the elements of the given array re-arranged according to this permutation.
*/
apply<T>(arr: readonly T[]): T[];
/**
* Returns a new permutation that undoes the re-arrangement of this permutation.
*/
inverse(): Permutation;
}
/**
* Asynchronous variant of `Array.find()`, returning the first element in
* the array for which the predicate returns true.
*
* This implementation does not bail early and waits for all promises to
* resolve before returning.
*/
export declare function findAsync<T>(array: readonly T[], predicate: (element: T, index: number) => Promise<boolean>): Promise<T | undefined>;
export {};

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@ -1,67 +1,67 @@
import { Comparator } from './arrays.js';
export declare function findLast<T>(array: readonly T[], predicate: (item: T) => boolean): T | undefined;
export declare function findLastIdx<T>(array: readonly T[], predicate: (item: T) => boolean, fromIndex?: number): number;
/**
* Finds the last item where predicate is true using binary search.
* `predicate` must be monotonous, i.e. `arr.map(predicate)` must be like `[true, ..., true, false, ..., false]`!
*
* @returns `undefined` if no item matches, otherwise the last item that matches the predicate.
*/
export declare function findLastMonotonous<T>(array: readonly T[], predicate: (item: T) => boolean): T | undefined;
/**
* Finds the last item where predicate is true using binary search.
* `predicate` must be monotonous, i.e. `arr.map(predicate)` must be like `[true, ..., true, false, ..., false]`!
*
* @returns `startIdx - 1` if predicate is false for all items, otherwise the index of the last item that matches the predicate.
*/
export declare function findLastIdxMonotonous<T>(array: readonly T[], predicate: (item: T) => boolean, startIdx?: number, endIdxEx?: number): number;
/**
* Finds the first item where predicate is true using binary search.
* `predicate` must be monotonous, i.e. `arr.map(predicate)` must be like `[false, ..., false, true, ..., true]`!
*
* @returns `undefined` if no item matches, otherwise the first item that matches the predicate.
*/
export declare function findFirstMonotonous<T>(array: readonly T[], predicate: (item: T) => boolean): T | undefined;
/**
* Finds the first item where predicate is true using binary search.
* `predicate` must be monotonous, i.e. `arr.map(predicate)` must be like `[false, ..., false, true, ..., true]`!
*
* @returns `endIdxEx` if predicate is false for all items, otherwise the index of the first item that matches the predicate.
*/
export declare function findFirstIdxMonotonousOrArrLen<T>(array: readonly T[], predicate: (item: T) => boolean, startIdx?: number, endIdxEx?: number): number;
export declare function findFirstIdxMonotonous<T>(array: readonly T[], predicate: (item: T) => boolean, startIdx?: number, endIdxEx?: number): number;
/**
* Use this when
* * You have a sorted array
* * You query this array with a monotonous predicate to find the last item that has a certain property.
* * You query this array multiple times with monotonous predicates that get weaker and weaker.
*/
export declare class MonotonousArray<T> {
private readonly _array;
static assertInvariants: boolean;
private _findLastMonotonousLastIdx;
private _prevFindLastPredicate;
constructor(_array: readonly T[]);
/**
* The predicate must be monotonous, i.e. `arr.map(predicate)` must be like `[true, ..., true, false, ..., false]`!
* For subsequent calls, current predicate must be weaker than (or equal to) the previous predicate, i.e. more entries must be `true`.
*/
findLastMonotonous(predicate: (item: T) => boolean): T | undefined;
}
/**
* Returns the first item that is equal to or greater than every other item.
*/
export declare function findFirstMax<T>(array: readonly T[], comparator: Comparator<T>): T | undefined;
/**
* Returns the last item that is equal to or greater than every other item.
*/
export declare function findLastMax<T>(array: readonly T[], comparator: Comparator<T>): T | undefined;
/**
* Returns the first item that is equal to or less than every other item.
*/
export declare function findFirstMin<T>(array: readonly T[], comparator: Comparator<T>): T | undefined;
export declare function findMaxIdx<T>(array: readonly T[], comparator: Comparator<T>): number;
/**
* Returns the first mapped value of the array which is not undefined.
*/
export declare function mapFindFirst<T, R>(items: Iterable<T>, mapFn: (value: T) => R | undefined): R | undefined;
import { Comparator } from './arrays.js';
export declare function findLast<T>(array: readonly T[], predicate: (item: T) => boolean): T | undefined;
export declare function findLastIdx<T>(array: readonly T[], predicate: (item: T) => boolean, fromIndex?: number): number;
/**
* Finds the last item where predicate is true using binary search.
* `predicate` must be monotonous, i.e. `arr.map(predicate)` must be like `[true, ..., true, false, ..., false]`!
*
* @returns `undefined` if no item matches, otherwise the last item that matches the predicate.
*/
export declare function findLastMonotonous<T>(array: readonly T[], predicate: (item: T) => boolean): T | undefined;
/**
* Finds the last item where predicate is true using binary search.
* `predicate` must be monotonous, i.e. `arr.map(predicate)` must be like `[true, ..., true, false, ..., false]`!
*
* @returns `startIdx - 1` if predicate is false for all items, otherwise the index of the last item that matches the predicate.
*/
export declare function findLastIdxMonotonous<T>(array: readonly T[], predicate: (item: T) => boolean, startIdx?: number, endIdxEx?: number): number;
/**
* Finds the first item where predicate is true using binary search.
* `predicate` must be monotonous, i.e. `arr.map(predicate)` must be like `[false, ..., false, true, ..., true]`!
*
* @returns `undefined` if no item matches, otherwise the first item that matches the predicate.
*/
export declare function findFirstMonotonous<T>(array: readonly T[], predicate: (item: T) => boolean): T | undefined;
/**
* Finds the first item where predicate is true using binary search.
* `predicate` must be monotonous, i.e. `arr.map(predicate)` must be like `[false, ..., false, true, ..., true]`!
*
* @returns `endIdxEx` if predicate is false for all items, otherwise the index of the first item that matches the predicate.
*/
export declare function findFirstIdxMonotonousOrArrLen<T>(array: readonly T[], predicate: (item: T) => boolean, startIdx?: number, endIdxEx?: number): number;
export declare function findFirstIdxMonotonous<T>(array: readonly T[], predicate: (item: T) => boolean, startIdx?: number, endIdxEx?: number): number;
/**
* Use this when
* * You have a sorted array
* * You query this array with a monotonous predicate to find the last item that has a certain property.
* * You query this array multiple times with monotonous predicates that get weaker and weaker.
*/
export declare class MonotonousArray<T> {
private readonly _array;
static assertInvariants: boolean;
private _findLastMonotonousLastIdx;
private _prevFindLastPredicate;
constructor(_array: readonly T[]);
/**
* The predicate must be monotonous, i.e. `arr.map(predicate)` must be like `[true, ..., true, false, ..., false]`!
* For subsequent calls, current predicate must be weaker than (or equal to) the previous predicate, i.e. more entries must be `true`.
*/
findLastMonotonous(predicate: (item: T) => boolean): T | undefined;
}
/**
* Returns the first item that is equal to or greater than every other item.
*/
export declare function findFirstMax<T>(array: readonly T[], comparator: Comparator<T>): T | undefined;
/**
* Returns the last item that is equal to or greater than every other item.
*/
export declare function findLastMax<T>(array: readonly T[], comparator: Comparator<T>): T | undefined;
/**
* Returns the first item that is equal to or less than every other item.
*/
export declare function findFirstMin<T>(array: readonly T[], comparator: Comparator<T>): T | undefined;
export declare function findMaxIdx<T>(array: readonly T[], comparator: Comparator<T>): number;
/**
* Returns the first mapped value of the array which is not undefined.
*/
export declare function mapFindFirst<T, R>(items: Iterable<T>, mapFn: (value: T) => R | undefined): R | undefined;

View File

@ -1,182 +1,182 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
export function findLast(array, predicate) {
const idx = findLastIdx(array, predicate);
if (idx === -1) {
return undefined;
}
return array[idx];
}
export function findLastIdx(array, predicate, fromIndex = array.length - 1) {
for (let i = fromIndex; i >= 0; i--) {
const element = array[i];
if (predicate(element)) {
return i;
}
}
return -1;
}
/**
* Finds the last item where predicate is true using binary search.
* `predicate` must be monotonous, i.e. `arr.map(predicate)` must be like `[true, ..., true, false, ..., false]`!
*
* @returns `undefined` if no item matches, otherwise the last item that matches the predicate.
*/
export function findLastMonotonous(array, predicate) {
const idx = findLastIdxMonotonous(array, predicate);
return idx === -1 ? undefined : array[idx];
}
/**
* Finds the last item where predicate is true using binary search.
* `predicate` must be monotonous, i.e. `arr.map(predicate)` must be like `[true, ..., true, false, ..., false]`!
*
* @returns `startIdx - 1` if predicate is false for all items, otherwise the index of the last item that matches the predicate.
*/
export function findLastIdxMonotonous(array, predicate, startIdx = 0, endIdxEx = array.length) {
let i = startIdx;
let j = endIdxEx;
while (i < j) {
const k = Math.floor((i + j) / 2);
if (predicate(array[k])) {
i = k + 1;
}
else {
j = k;
}
}
return i - 1;
}
/**
* Finds the first item where predicate is true using binary search.
* `predicate` must be monotonous, i.e. `arr.map(predicate)` must be like `[false, ..., false, true, ..., true]`!
*
* @returns `undefined` if no item matches, otherwise the first item that matches the predicate.
*/
export function findFirstMonotonous(array, predicate) {
const idx = findFirstIdxMonotonousOrArrLen(array, predicate);
return idx === array.length ? undefined : array[idx];
}
/**
* Finds the first item where predicate is true using binary search.
* `predicate` must be monotonous, i.e. `arr.map(predicate)` must be like `[false, ..., false, true, ..., true]`!
*
* @returns `endIdxEx` if predicate is false for all items, otherwise the index of the first item that matches the predicate.
*/
export function findFirstIdxMonotonousOrArrLen(array, predicate, startIdx = 0, endIdxEx = array.length) {
let i = startIdx;
let j = endIdxEx;
while (i < j) {
const k = Math.floor((i + j) / 2);
if (predicate(array[k])) {
j = k;
}
else {
i = k + 1;
}
}
return i;
}
export function findFirstIdxMonotonous(array, predicate, startIdx = 0, endIdxEx = array.length) {
const idx = findFirstIdxMonotonousOrArrLen(array, predicate, startIdx, endIdxEx);
return idx === array.length ? -1 : idx;
}
/**
* Use this when
* * You have a sorted array
* * You query this array with a monotonous predicate to find the last item that has a certain property.
* * You query this array multiple times with monotonous predicates that get weaker and weaker.
*/
export class MonotonousArray {
_array;
static assertInvariants = false;
_findLastMonotonousLastIdx = 0;
_prevFindLastPredicate;
constructor(_array) {
this._array = _array;
}
/**
* The predicate must be monotonous, i.e. `arr.map(predicate)` must be like `[true, ..., true, false, ..., false]`!
* For subsequent calls, current predicate must be weaker than (or equal to) the previous predicate, i.e. more entries must be `true`.
*/
findLastMonotonous(predicate) {
if (MonotonousArray.assertInvariants) {
if (this._prevFindLastPredicate) {
for (const item of this._array) {
if (this._prevFindLastPredicate(item) && !predicate(item)) {
throw new Error('MonotonousArray: current predicate must be weaker than (or equal to) the previous predicate.');
}
}
}
this._prevFindLastPredicate = predicate;
}
const idx = findLastIdxMonotonous(this._array, predicate, this._findLastMonotonousLastIdx);
this._findLastMonotonousLastIdx = idx + 1;
return idx === -1 ? undefined : this._array[idx];
}
}
/**
* Returns the first item that is equal to or greater than every other item.
*/
export function findFirstMax(array, comparator) {
if (array.length === 0) {
return undefined;
}
let max = array[0];
for (let i = 1; i < array.length; i++) {
const item = array[i];
if (comparator(item, max) > 0) {
max = item;
}
}
return max;
}
/**
* Returns the last item that is equal to or greater than every other item.
*/
export function findLastMax(array, comparator) {
if (array.length === 0) {
return undefined;
}
let max = array[0];
for (let i = 1; i < array.length; i++) {
const item = array[i];
if (comparator(item, max) >= 0) {
max = item;
}
}
return max;
}
/**
* Returns the first item that is equal to or less than every other item.
*/
export function findFirstMin(array, comparator) {
return findFirstMax(array, (a, b) => -comparator(a, b));
}
export function findMaxIdx(array, comparator) {
if (array.length === 0) {
return -1;
}
let maxIdx = 0;
for (let i = 1; i < array.length; i++) {
const item = array[i];
if (comparator(item, array[maxIdx]) > 0) {
maxIdx = i;
}
}
return maxIdx;
}
/**
* Returns the first mapped value of the array which is not undefined.
*/
export function mapFindFirst(items, mapFn) {
for (const value of items) {
const mapped = mapFn(value);
if (mapped !== undefined) {
return mapped;
}
}
return undefined;
}
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
export function findLast(array, predicate) {
const idx = findLastIdx(array, predicate);
if (idx === -1) {
return undefined;
}
return array[idx];
}
export function findLastIdx(array, predicate, fromIndex = array.length - 1) {
for (let i = fromIndex; i >= 0; i--) {
const element = array[i];
if (predicate(element)) {
return i;
}
}
return -1;
}
/**
* Finds the last item where predicate is true using binary search.
* `predicate` must be monotonous, i.e. `arr.map(predicate)` must be like `[true, ..., true, false, ..., false]`!
*
* @returns `undefined` if no item matches, otherwise the last item that matches the predicate.
*/
export function findLastMonotonous(array, predicate) {
const idx = findLastIdxMonotonous(array, predicate);
return idx === -1 ? undefined : array[idx];
}
/**
* Finds the last item where predicate is true using binary search.
* `predicate` must be monotonous, i.e. `arr.map(predicate)` must be like `[true, ..., true, false, ..., false]`!
*
* @returns `startIdx - 1` if predicate is false for all items, otherwise the index of the last item that matches the predicate.
*/
export function findLastIdxMonotonous(array, predicate, startIdx = 0, endIdxEx = array.length) {
let i = startIdx;
let j = endIdxEx;
while (i < j) {
const k = Math.floor((i + j) / 2);
if (predicate(array[k])) {
i = k + 1;
}
else {
j = k;
}
}
return i - 1;
}
/**
* Finds the first item where predicate is true using binary search.
* `predicate` must be monotonous, i.e. `arr.map(predicate)` must be like `[false, ..., false, true, ..., true]`!
*
* @returns `undefined` if no item matches, otherwise the first item that matches the predicate.
*/
export function findFirstMonotonous(array, predicate) {
const idx = findFirstIdxMonotonousOrArrLen(array, predicate);
return idx === array.length ? undefined : array[idx];
}
/**
* Finds the first item where predicate is true using binary search.
* `predicate` must be monotonous, i.e. `arr.map(predicate)` must be like `[false, ..., false, true, ..., true]`!
*
* @returns `endIdxEx` if predicate is false for all items, otherwise the index of the first item that matches the predicate.
*/
export function findFirstIdxMonotonousOrArrLen(array, predicate, startIdx = 0, endIdxEx = array.length) {
let i = startIdx;
let j = endIdxEx;
while (i < j) {
const k = Math.floor((i + j) / 2);
if (predicate(array[k])) {
j = k;
}
else {
i = k + 1;
}
}
return i;
}
export function findFirstIdxMonotonous(array, predicate, startIdx = 0, endIdxEx = array.length) {
const idx = findFirstIdxMonotonousOrArrLen(array, predicate, startIdx, endIdxEx);
return idx === array.length ? -1 : idx;
}
/**
* Use this when
* * You have a sorted array
* * You query this array with a monotonous predicate to find the last item that has a certain property.
* * You query this array multiple times with monotonous predicates that get weaker and weaker.
*/
export class MonotonousArray {
_array;
static assertInvariants = false;
_findLastMonotonousLastIdx = 0;
_prevFindLastPredicate;
constructor(_array) {
this._array = _array;
}
/**
* The predicate must be monotonous, i.e. `arr.map(predicate)` must be like `[true, ..., true, false, ..., false]`!
* For subsequent calls, current predicate must be weaker than (or equal to) the previous predicate, i.e. more entries must be `true`.
*/
findLastMonotonous(predicate) {
if (MonotonousArray.assertInvariants) {
if (this._prevFindLastPredicate) {
for (const item of this._array) {
if (this._prevFindLastPredicate(item) && !predicate(item)) {
throw new Error('MonotonousArray: current predicate must be weaker than (or equal to) the previous predicate.');
}
}
}
this._prevFindLastPredicate = predicate;
}
const idx = findLastIdxMonotonous(this._array, predicate, this._findLastMonotonousLastIdx);
this._findLastMonotonousLastIdx = idx + 1;
return idx === -1 ? undefined : this._array[idx];
}
}
/**
* Returns the first item that is equal to or greater than every other item.
*/
export function findFirstMax(array, comparator) {
if (array.length === 0) {
return undefined;
}
let max = array[0];
for (let i = 1; i < array.length; i++) {
const item = array[i];
if (comparator(item, max) > 0) {
max = item;
}
}
return max;
}
/**
* Returns the last item that is equal to or greater than every other item.
*/
export function findLastMax(array, comparator) {
if (array.length === 0) {
return undefined;
}
let max = array[0];
for (let i = 1; i < array.length; i++) {
const item = array[i];
if (comparator(item, max) >= 0) {
max = item;
}
}
return max;
}
/**
* Returns the first item that is equal to or less than every other item.
*/
export function findFirstMin(array, comparator) {
return findFirstMax(array, (a, b) => -comparator(a, b));
}
export function findMaxIdx(array, comparator) {
if (array.length === 0) {
return -1;
}
let maxIdx = 0;
for (let i = 1; i < array.length; i++) {
const item = array[i];
if (comparator(item, array[maxIdx]) > 0) {
maxIdx = i;
}
}
return maxIdx;
}
/**
* Returns the first mapped value of the array which is not undefined.
*/
export function mapFindFirst(items, mapFn) {
for (const value of items) {
const mapped = mapFn(value);
if (mapped !== undefined) {
return mapped;
}
}
return undefined;
}
//# sourceMappingURL=arraysFind.js.map

View File

@ -1 +1 @@
{"version":3,"file":"arraysFind.js","sourceRoot":"","sources":["../src/arraysFind.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAIhG,MAAM,UAAU,QAAQ,CAAI,KAAmB,EAAE,SAA+B;IAC/E,MAAM,GAAG,GAAG,WAAW,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;IAC1C,IAAI,GAAG,KAAK,CAAC,CAAC,EAAE;QACf,OAAO,SAAS,CAAC;KACjB;IACD,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC;AACnB,CAAC;AAED,MAAM,UAAU,WAAW,CAAI,KAAmB,EAAE,SAA+B,EAAE,SAAS,GAAG,KAAK,CAAC,MAAM,GAAG,CAAC;IAChH,KAAK,IAAI,CAAC,GAAG,SAAS,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE;QACpC,MAAM,OAAO,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;QAEzB,IAAI,SAAS,CAAC,OAAO,CAAC,EAAE;YACvB,OAAO,CAAC,CAAC;SACT;KACD;IAED,OAAO,CAAC,CAAC,CAAC;AACX,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,kBAAkB,CAAI,KAAmB,EAAE,SAA+B;IACzF,MAAM,GAAG,GAAG,qBAAqB,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;IACpD,OAAO,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;AAC5C,CAAC;AAED;;;;;GAKG;AACH,MAAM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;AAED;;GAEG;AACH,MAAM,UAAU,YAAY,CAAO,KAAkB,EAAE,KAAkC;IACxF,KAAK,MAAM,KAAK,IAAI,KAAK,EAAE,CAAC;QAC3B,MAAM,MAAM,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC;QAC5B,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;YAC1B,OAAO,MAAM,CAAC;QACf,CAAC;IACF,CAAC;IAED,OAAO,SAAS,CAAC;AAClB,CAAC"}

View File

@ -1,87 +1,87 @@
export declare enum SIGNALS {
BEFORE = "BEFORE",
AFTER = "AFTER",
AROUND = "AROUND",
ERROR = "ERROR"
}
type AnyFunction = (...args: any[]) => any;
/**
* If a function returns a Promise<T>, then its awaited type is T.
* Otherwise, it's just ReturnType<T>.
*/
type AwaitedReturn<T extends AnyFunction> = T extends (...args: any[]) => Promise<infer U> ? U : ReturnType<T>;
/**
* BEFORE advice:
* - Receives `context` (the `this` of the function)
* - Receives the original `args`
* - Can return either nothing (`void`) or new arguments (`Parameters<T>`)
* - Can be async, returning a Promise that resolves to new args or `void`
*/
export type BeforeAdvice<T extends AnyFunction> = (context: ThisParameterType<T>, args: Parameters<T>) => void | Parameters<T> | Promise<void | Parameters<T>>;
/**
* AFTER advice:
* - Receives `context`, the original functions final (awaited) result,
* and the original arguments
* - Can return a new result (sync or async)
*/
export type AfterAdvice<T extends AnyFunction> = (context: ThisParameterType<T>, result: AwaitedReturn<T>, args: Parameters<T>) => AwaitedReturn<T> | Promise<AwaitedReturn<T>>;
/**
* AROUND advice:
* - Provides a `proceed(...args)` function that calls the original method
* - You can call `proceed` any number of times, or skip it
* - Supports both sync and async usage
*/
export type AroundAdvice<T extends AnyFunction> = (proceed: (...args: Parameters<T>) => ReturnType<T>, context: ThisParameterType<T>, args: Parameters<T>) => ReturnType<T>;
/**
* ERROR advice:
* - Intercepts errors thrown by the original method (sync or async)
* - Can return a fallback result or rethrow
*/
export type ErrorAdvice<T extends AnyFunction> = (error: unknown, context: ThisParameterType<T>, args: Parameters<T>) => ReturnType<T> | void;
interface AspectOptions<T extends SIGNALS, A> {
type: T;
advice: A;
}
/**
* The core aspect(...) function
* - Returns a decorator if used in that style
* - Otherwise, can wrap a function directly
*/
declare function aspect<T extends SIGNALS, A>({ type, advice }: AspectOptions<T, A>): (target: any, _name?: string, descriptor?: PropertyDescriptor) => any;
/**
* `before`:
* Decorator usage => @before((ctx, args) => ...)
* Direct usage => myFn = before(myFn, (ctx, args) => ...)
*/
export declare function before<T extends AnyFunction>(advice: BeforeAdvice<T>): (target: any, name?: string, descriptor?: PropertyDescriptor) => any;
export declare function before<T extends AnyFunction>(fn: T, advice: BeforeAdvice<T>): T;
/**
* `after`:
* Decorator usage => @after((ctx, result, args) => ...)
* Direct usage => myFn = after(myFn, (ctx, result, args) => ...)
*/
export declare function after<T extends AnyFunction>(advice: AfterAdvice<T>): (target: any, name?: string, descriptor?: PropertyDescriptor) => any;
export declare function after<T extends AnyFunction>(fn: T, advice: AfterAdvice<T>): T;
/**
* `around`:
* Decorator usage => @around((proceed, ctx, args) => ...)
* Direct usage => myFn = around(myFn, (proceed, ctx, args) => ...)
*/
export declare function around<T extends AnyFunction>(advice: AroundAdvice<T>): (target: any, name?: string, descriptor?: PropertyDescriptor) => any;
export declare function around<T extends AnyFunction>(fn: T, advice: AroundAdvice<T>): T;
/**
* `error`:
* Decorator usage => @error((err, ctx, args) => ...)
* Direct usage => myFn = error(myFn, (err, ctx, args) => ...)
*/
export declare function error<T extends AnyFunction>(advice: ErrorAdvice<T>): (target: any, name?: string, descriptor?: PropertyDescriptor) => any;
export declare function error<T extends AnyFunction>(fn: T, advice: ErrorAdvice<T>): T;
declare const _default: {
SIGNALS: typeof SIGNALS;
before: typeof before;
after: typeof after;
around: typeof around;
error: typeof error;
aspect: typeof aspect;
};
export default _default;
export declare enum SIGNALS {
BEFORE = "BEFORE",
AFTER = "AFTER",
AROUND = "AROUND",
ERROR = "ERROR"
}
type AnyFunction = (...args: any[]) => any;
/**
* If a function returns a Promise<T>, then its awaited type is T.
* Otherwise, it's just ReturnType<T>.
*/
type AwaitedReturn<T extends AnyFunction> = T extends (...args: any[]) => Promise<infer U> ? U : ReturnType<T>;
/**
* BEFORE advice:
* - Receives `context` (the `this` of the function)
* - Receives the original `args`
* - Can return either nothing (`void`) or new arguments (`Parameters<T>`)
* - Can be async, returning a Promise that resolves to new args or `void`
*/
export type BeforeAdvice<T extends AnyFunction> = (context: ThisParameterType<T>, args: Parameters<T>) => void | Parameters<T> | Promise<void | Parameters<T>>;
/**
* AFTER advice:
* - Receives `context`, the original functions final (awaited) result,
* and the original arguments
* - Can return a new result (sync or async)
*/
export type AfterAdvice<T extends AnyFunction> = (context: ThisParameterType<T>, result: AwaitedReturn<T>, args: Parameters<T>) => AwaitedReturn<T> | Promise<AwaitedReturn<T>>;
/**
* AROUND advice:
* - Provides a `proceed(...args)` function that calls the original method
* - You can call `proceed` any number of times, or skip it
* - Supports both sync and async usage
*/
export type AroundAdvice<T extends AnyFunction> = (proceed: (...args: Parameters<T>) => ReturnType<T>, context: ThisParameterType<T>, args: Parameters<T>) => ReturnType<T>;
/**
* ERROR advice:
* - Intercepts errors thrown by the original method (sync or async)
* - Can return a fallback result or rethrow
*/
export type ErrorAdvice<T extends AnyFunction> = (error: unknown, context: ThisParameterType<T>, args: Parameters<T>) => ReturnType<T> | void;
interface AspectOptions<T extends SIGNALS, A> {
type: T;
advice: A;
}
/**
* The core aspect(...) function
* - Returns a decorator if used in that style
* - Otherwise, can wrap a function directly
*/
declare function aspect<T extends SIGNALS, A>({ type, advice }: AspectOptions<T, A>): (target: any, _name?: string, descriptor?: PropertyDescriptor) => any;
/**
* `before`:
* Decorator usage => @before((ctx, args) => ...)
* Direct usage => myFn = before(myFn, (ctx, args) => ...)
*/
export declare function before<T extends AnyFunction>(advice: BeforeAdvice<T>): (target: any, name?: string, descriptor?: PropertyDescriptor) => any;
export declare function before<T extends AnyFunction>(fn: T, advice: BeforeAdvice<T>): T;
/**
* `after`:
* Decorator usage => @after((ctx, result, args) => ...)
* Direct usage => myFn = after(myFn, (ctx, result, args) => ...)
*/
export declare function after<T extends AnyFunction>(advice: AfterAdvice<T>): (target: any, name?: string, descriptor?: PropertyDescriptor) => any;
export declare function after<T extends AnyFunction>(fn: T, advice: AfterAdvice<T>): T;
/**
* `around`:
* Decorator usage => @around((proceed, ctx, args) => ...)
* Direct usage => myFn = around(myFn, (proceed, ctx, args) => ...)
*/
export declare function around<T extends AnyFunction>(advice: AroundAdvice<T>): (target: any, name?: string, descriptor?: PropertyDescriptor) => any;
export declare function around<T extends AnyFunction>(fn: T, advice: AroundAdvice<T>): T;
/**
* `error`:
* Decorator usage => @error((err, ctx, args) => ...)
* Direct usage => myFn = error(myFn, (err, ctx, args) => ...)
*/
export declare function error<T extends AnyFunction>(advice: ErrorAdvice<T>): (target: any, name?: string, descriptor?: PropertyDescriptor) => any;
export declare function error<T extends AnyFunction>(fn: T, advice: ErrorAdvice<T>): T;
declare const _default: {
SIGNALS: typeof SIGNALS;
before: typeof before;
after: typeof after;
around: typeof around;
error: typeof error;
aspect: typeof aspect;
};
export default _default;

View File

@ -1,188 +1,188 @@
/* -------------------------------------------------------------------------
* aspects.ts
*
* A robust aspect system supporting:
* - before: optionally modifies arguments (sync or async)
* - after: optionally modifies return value (sync or async)
* - around: complete control over function invocation
* - error: intercept errors (sync or async)
*
* Works as both:
* 1) Decorators for class methods (e.g. @before(...))
* 2) Direct function wrappers (e.g. fn = before(fn, ...)).
* ------------------------------------------------------------------------ */
/* -------------------------------------------------------------------------
* 1) SIGNALS Enum (string-based to avoid symbol issues)
* ------------------------------------------------------------------------ */
export var SIGNALS;
(function (SIGNALS) {
SIGNALS["BEFORE"] = "BEFORE";
SIGNALS["AFTER"] = "AFTER";
SIGNALS["AROUND"] = "AROUND";
SIGNALS["ERROR"] = "ERROR";
})(SIGNALS = SIGNALS || (SIGNALS = {}));
/* -------------------------------------------------------------------------
* 5) The SignalMap Implementation
* - This is where the actual "wrapping" logic lives.
* ------------------------------------------------------------------------ */
const SignalMap = {
/**
* BEFORE:
* - Possibly modifies arguments
* - If returns a Promise, we await it before calling original
* - If returns an array, we use that as new arguments
*/
[SIGNALS.BEFORE](original, advice) {
return function (...args) {
const maybeNewArgs = advice(this, args);
if (maybeNewArgs instanceof Promise) {
return maybeNewArgs.then((resolvedArgs) => {
const finalArgs = resolvedArgs || args;
const result = original.apply(this, finalArgs);
return (result instanceof Promise) ? result : Promise.resolve(result);
});
}
else {
const finalArgs = Array.isArray(maybeNewArgs) ? maybeNewArgs : args;
return original.apply(this, finalArgs);
}
};
},
/**
* AFTER:
* - Possibly modifies the return value
* - If original is async, we chain on its promise
* - Advice can be sync or async
*/
[SIGNALS.AFTER](original, advice) {
return function (...args) {
const result = original.apply(this, args);
if (result instanceof Promise) {
return result.then((unwrapped) => {
const maybeNewResult = advice(this, unwrapped, args);
return (maybeNewResult instanceof Promise) ? maybeNewResult : maybeNewResult;
});
}
else {
const maybeNewResult = advice(this, result, args);
if (maybeNewResult instanceof Promise) {
return maybeNewResult.then(r => r);
}
return maybeNewResult;
}
};
},
/**
* AROUND:
* - Full control over invocation
* - Typically you do: proceed(...args)
* - If you want to skip or call multiple times, you can
*/
[SIGNALS.AROUND](original, advice) {
return function (...args) {
const proceed = (...innerArgs) => original.apply(this, innerArgs);
return advice(proceed, this, args);
};
},
/**
* ERROR:
* - Intercepts errors thrown by the original function or a rejected Promise
* - Optionally returns a fallback or rethrows
*/
[SIGNALS.ERROR](original, advice) {
return function (...args) {
try {
const result = original.apply(this, args);
if (result instanceof Promise) {
// Handle async rejections
return result.catch((err) => {
return advice(err, this, args);
});
}
return result;
}
catch (err) {
// Synchronous error
return advice(err, this, args);
}
};
},
};
/* -------------------------------------------------------------------------
* 6) Decorator Helper
* ------------------------------------------------------------------------ */
/** Checks if were decorating a class method. */
function isMethod(_target, descriptor) {
return !!descriptor && typeof descriptor.value === 'function';
}
/* -------------------------------------------------------------------------
* 7) Wrapped Helpers (cutMethod, cut, aspect)
* ------------------------------------------------------------------------ */
/** Strictly typed wrapping for class methods. */
function cutMethod(descriptor, advice, type) {
const original = descriptor.value;
descriptor.value = SignalMap[type](original, advice); // Cast `any` or refine further
return descriptor;
}
/** Strictly typed wrapping for direct function usage. */
function cut(target, advice, type) {
return SignalMap[type](target, advice);
}
/**
* The core aspect(...) function
* - Returns a decorator if used in that style
* - Otherwise, can wrap a function directly
*/
function aspect({ type, advice }) {
// If type is invalid, produce a no-op decorator
if (!(type in SignalMap)) {
return function crosscut(target, _name, descriptor) {
return descriptor || target;
};
}
// Return a decorator function
return function crosscut(target, _name, descriptor) {
// If used on a method
if (isMethod(target, descriptor)) {
return cutMethod(descriptor, advice, type);
}
// If used directly on a function or something else
return cut(target, advice, type);
};
}
export function before(arg1, arg2) {
if (typeof arg1 === 'function' && typeof arg2 === 'function') {
return SignalMap[SIGNALS.BEFORE](arg1, arg2);
}
return aspect({ type: SIGNALS.BEFORE, advice: arg1 });
}
export function after(arg1, arg2) {
if (typeof arg1 === 'function' && typeof arg2 === 'function') {
return SignalMap[SIGNALS.AFTER](arg1, arg2);
}
return aspect({ type: SIGNALS.AFTER, advice: arg1 });
}
export function around(arg1, arg2) {
if (typeof arg1 === 'function' && typeof arg2 === 'function') {
return SignalMap[SIGNALS.AROUND](arg1, arg2);
}
return aspect({ type: SIGNALS.AROUND, advice: arg1 });
}
export function error(arg1, arg2) {
if (typeof arg1 === 'function' && typeof arg2 === 'function') {
return SignalMap[SIGNALS.ERROR](arg1, arg2);
}
return aspect({ type: SIGNALS.ERROR, advice: arg1 });
}
/* -------------------------------------------------------------------------
* 9) Default Export
* ------------------------------------------------------------------------ */
export default {
SIGNALS,
before,
after,
around,
error,
aspect,
};
/* -------------------------------------------------------------------------
* aspects.ts
*
* A robust aspect system supporting:
* - before: optionally modifies arguments (sync or async)
* - after: optionally modifies return value (sync or async)
* - around: complete control over function invocation
* - error: intercept errors (sync or async)
*
* Works as both:
* 1) Decorators for class methods (e.g. @before(...))
* 2) Direct function wrappers (e.g. fn = before(fn, ...)).
* ------------------------------------------------------------------------ */
/* -------------------------------------------------------------------------
* 1) SIGNALS Enum (string-based to avoid symbol issues)
* ------------------------------------------------------------------------ */
export var SIGNALS;
(function (SIGNALS) {
SIGNALS["BEFORE"] = "BEFORE";
SIGNALS["AFTER"] = "AFTER";
SIGNALS["AROUND"] = "AROUND";
SIGNALS["ERROR"] = "ERROR";
})(SIGNALS || (SIGNALS = {}));
/* -------------------------------------------------------------------------
* 5) The SignalMap Implementation
* - This is where the actual "wrapping" logic lives.
* ------------------------------------------------------------------------ */
const SignalMap = {
/**
* BEFORE:
* - Possibly modifies arguments
* - If returns a Promise, we await it before calling original
* - If returns an array, we use that as new arguments
*/
[SIGNALS.BEFORE](original, advice) {
return function (...args) {
const maybeNewArgs = advice(this, args);
if (maybeNewArgs instanceof Promise) {
return maybeNewArgs.then((resolvedArgs) => {
const finalArgs = resolvedArgs || args;
const result = original.apply(this, finalArgs);
return (result instanceof Promise) ? result : Promise.resolve(result);
});
}
else {
const finalArgs = Array.isArray(maybeNewArgs) ? maybeNewArgs : args;
return original.apply(this, finalArgs);
}
};
},
/**
* AFTER:
* - Possibly modifies the return value
* - If original is async, we chain on its promise
* - Advice can be sync or async
*/
[SIGNALS.AFTER](original, advice) {
return function (...args) {
const result = original.apply(this, args);
if (result instanceof Promise) {
return result.then((unwrapped) => {
const maybeNewResult = advice(this, unwrapped, args);
return (maybeNewResult instanceof Promise) ? maybeNewResult : maybeNewResult;
});
}
else {
const maybeNewResult = advice(this, result, args);
if (maybeNewResult instanceof Promise) {
return maybeNewResult.then(r => r);
}
return maybeNewResult;
}
};
},
/**
* AROUND:
* - Full control over invocation
* - Typically you do: proceed(...args)
* - If you want to skip or call multiple times, you can
*/
[SIGNALS.AROUND](original, advice) {
return function (...args) {
const proceed = (...innerArgs) => original.apply(this, innerArgs);
return advice(proceed, this, args);
};
},
/**
* ERROR:
* - Intercepts errors thrown by the original function or a rejected Promise
* - Optionally returns a fallback or rethrows
*/
[SIGNALS.ERROR](original, advice) {
return function (...args) {
try {
const result = original.apply(this, args);
if (result instanceof Promise) {
// Handle async rejections
return result.catch((err) => {
return advice(err, this, args);
});
}
return result;
}
catch (err) {
// Synchronous error
return advice(err, this, args);
}
};
},
};
/* -------------------------------------------------------------------------
* 6) Decorator Helper
* ------------------------------------------------------------------------ */
/** Checks if were decorating a class method. */
function isMethod(_target, descriptor) {
return !!descriptor && typeof descriptor.value === 'function';
}
/* -------------------------------------------------------------------------
* 7) Wrapped Helpers (cutMethod, cut, aspect)
* ------------------------------------------------------------------------ */
/** Strictly typed wrapping for class methods. */
function cutMethod(descriptor, advice, type) {
const original = descriptor.value;
descriptor.value = SignalMap[type](original, advice); // Cast `any` or refine further
return descriptor;
}
/** Strictly typed wrapping for direct function usage. */
function cut(target, advice, type) {
return SignalMap[type](target, advice);
}
/**
* The core aspect(...) function
* - Returns a decorator if used in that style
* - Otherwise, can wrap a function directly
*/
function aspect({ type, advice }) {
// If type is invalid, produce a no-op decorator
if (!(type in SignalMap)) {
return function crosscut(target, _name, descriptor) {
return descriptor || target;
};
}
// Return a decorator function
return function crosscut(target, _name, descriptor) {
// If used on a method
if (isMethod(target, descriptor)) {
return cutMethod(descriptor, advice, type);
}
// If used directly on a function or something else
return cut(target, advice, type);
};
}
export function before(arg1, arg2) {
if (typeof arg1 === 'function' && typeof arg2 === 'function') {
return SignalMap[SIGNALS.BEFORE](arg1, arg2);
}
return aspect({ type: SIGNALS.BEFORE, advice: arg1 });
}
export function after(arg1, arg2) {
if (typeof arg1 === 'function' && typeof arg2 === 'function') {
return SignalMap[SIGNALS.AFTER](arg1, arg2);
}
return aspect({ type: SIGNALS.AFTER, advice: arg1 });
}
export function around(arg1, arg2) {
if (typeof arg1 === 'function' && typeof arg2 === 'function') {
return SignalMap[SIGNALS.AROUND](arg1, arg2);
}
return aspect({ type: SIGNALS.AROUND, advice: arg1 });
}
export function error(arg1, arg2) {
if (typeof arg1 === 'function' && typeof arg2 === 'function') {
return SignalMap[SIGNALS.ERROR](arg1, arg2);
}
return aspect({ type: SIGNALS.ERROR, advice: arg1 });
}
/* -------------------------------------------------------------------------
* 9) Default Export
* ------------------------------------------------------------------------ */
export default {
SIGNALS,
before,
after,
around,
error,
aspect,
};
//# sourceMappingURL=aspects.js.map

View File

@ -1 +1 @@
{"version":3,"file":"aspects.js","sourceRoot":"","sources":["../src/aspects.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;8EAY8E;AAE9E;;8EAE8E;AAC9E,MAAM,CAAN,IAAY,OAKX;AALD,WAAY,OAAO;IACjB,4BAAiB,CAAA;IACjB,0BAAe,CAAA;IACf,4BAAiB,CAAA;IACjB,0BAAe,CAAA;AACjB,CAAC,EALW,OAAO,GAAP,OAAO,KAAP,OAAO,QAKlB;AA2ED;;;8EAG8E;AAC9E,MAAM,SAAS,GAAe;IAC5B;;;;;OAKG;IACH,CAAC,OAAO,CAAC,MAAM,CAAC,CAAwB,QAAW,EAAE,MAAuB;QAC1E,OAAO,UAAsC,GAAG,IAAmB;YACjE,MAAM,YAAY,GAAG,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;YAExC,IAAI,YAAY,YAAY,OAAO,EAAE;gBACnC,OAAO,YAAY,CAAC,IAAI,CAAC,CAAC,YAAY,EAAE,EAAE;oBACxC,MAAM,SAAS,GAAG,YAAY,IAAI,IAAI,CAAC;oBACvC,MAAM,MAAM,GAAG,QAAQ,CAAC,KAAK,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;oBAC/C,OAAO,CAAC,MAAM,YAAY,OAAO,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;gBACxE,CAAC,CAAkB,CAAC;aACrB;iBAAM;gBACL,MAAM,SAAS,GAAG,KAAK,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,IAAI,CAAC;gBACpE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AsB,EAAE,CAAC,CAAC;AACzE,CAAC;AAED;;8EAE8E;AAC9E,eAAe;IACb,OAAO;IACP,MAAM;IACN,KAAK;IACL,MAAM;IACN,KAAK;IACL,MAAM;CACP,CAAC"}

View File

@ -1,68 +1,68 @@
export declare enum SIGNALS {
BEFORE = "BEFORE",
AFTER = "AFTER",
AROUND = "AROUND",
ERROR = "ERROR"
}
type AnyFunction = (...args: any[]) => any;
/**
* If a function returns a Promise<T>, then its awaited type is T.
* Otherwise, it's just ReturnType<T>.
*/
type AwaitedReturn<T extends AnyFunction> = T extends (...args: any[]) => Promise<infer U> ? U : ReturnType<T>;
/**
* BEFORE advice:
* - Receives `context` (the `this` of the function)
* - Receives the original `args`
* - Can return either nothing (`void`) or new arguments (`Parameters<T>`)
* - Can be async, returning a Promise that resolves to new args or `void`
*/
export type BeforeAdvice<T extends AnyFunction> = (context: ThisParameterType<T>, args: Parameters<T>) => void | Parameters<T> | Promise<void | Parameters<T>>;
/**
* AFTER advice:
* - Receives `context`, the original functions final (awaited) result,
* and the original arguments
* - Can return a new result (sync or async)
*/
export type AfterAdvice<T extends AnyFunction> = (context: ThisParameterType<T>, result: AwaitedReturn<T>, args: Parameters<T>) => AwaitedReturn<T> | Promise<AwaitedReturn<T>>;
/**
* AROUND advice:
* - Provides a `proceed(...args)` function that calls the original method
* - You can call `proceed` any number of times, or skip it
* - Supports both sync and async usage
*/
export type AroundAdvice<T extends AnyFunction> = (proceed: (...args: Parameters<T>) => ReturnType<T>, context: ThisParameterType<T>, args: Parameters<T>) => ReturnType<T>;
/**
* ERROR advice:
* - Intercepts errors thrown by the original function (sync or async)
* - Can return a fallback result or rethrow
*/
export type ErrorAdvice<T extends AnyFunction> = (error: unknown, context: ThisParameterType<T>, args: Parameters<T>) => ReturnType<T> | void;
/**
* `before`:
* Direct usage => myFn = before(myFn, (ctx, args) => ...)
*/
export declare function before<T extends AnyFunction>(fn: T, advice: BeforeAdvice<T>): T;
/**
* `after`:
* Direct usage => myFn = after(myFn, (ctx, result, args) => ...)
*/
export declare function after<T extends AnyFunction>(fn: T, advice: AfterAdvice<T>): T;
/**
* `around`:
* Direct usage => myFn = around(myFn, (proceed, ctx, args) => ...)
*/
export declare function around<T extends AnyFunction>(fn: T, advice: AroundAdvice<T>): T;
/**
* `error`:
* Direct usage => myFn = error(myFn, (err, ctx, args) => ...)
*/
export declare function error<T extends AnyFunction>(fn: T, advice: ErrorAdvice<T>): T;
declare const _default: {
SIGNALS: typeof SIGNALS;
before: typeof before;
after: typeof after;
around: typeof around;
error: typeof error;
};
export default _default;
export declare enum SIGNALS {
BEFORE = "BEFORE",
AFTER = "AFTER",
AROUND = "AROUND",
ERROR = "ERROR"
}
type AnyFunction = (...args: any[]) => any;
/**
* If a function returns a Promise<T>, then its awaited type is T.
* Otherwise, it's just ReturnType<T>.
*/
type AwaitedReturn<T extends AnyFunction> = T extends (...args: any[]) => Promise<infer U> ? U : ReturnType<T>;
/**
* BEFORE advice:
* - Receives `context` (the `this` of the function)
* - Receives the original `args`
* - Can return either nothing (`void`) or new arguments (`Parameters<T>`)
* - Can be async, returning a Promise that resolves to new args or `void`
*/
export type BeforeAdvice<T extends AnyFunction> = (context: ThisParameterType<T>, args: Parameters<T>) => void | Parameters<T> | Promise<void | Parameters<T>>;
/**
* AFTER advice:
* - Receives `context`, the original functions final (awaited) result,
* and the original arguments
* - Can return a new result (sync or async)
*/
export type AfterAdvice<T extends AnyFunction> = (context: ThisParameterType<T>, result: AwaitedReturn<T>, args: Parameters<T>) => AwaitedReturn<T> | Promise<AwaitedReturn<T>>;
/**
* AROUND advice:
* - Provides a `proceed(...args)` function that calls the original method
* - You can call `proceed` any number of times, or skip it
* - Supports both sync and async usage
*/
export type AroundAdvice<T extends AnyFunction> = (proceed: (...args: Parameters<T>) => ReturnType<T>, context: ThisParameterType<T>, args: Parameters<T>) => ReturnType<T>;
/**
* ERROR advice:
* - Intercepts errors thrown by the original function (sync or async)
* - Can return a fallback result or rethrow
*/
export type ErrorAdvice<T extends AnyFunction> = (error: unknown, context: ThisParameterType<T>, args: Parameters<T>) => ReturnType<T> | void;
/**
* `before`:
* Direct usage => myFn = before(myFn, (ctx, args) => ...)
*/
export declare function before<T extends AnyFunction>(fn: T, advice: BeforeAdvice<T>): T;
/**
* `after`:
* Direct usage => myFn = after(myFn, (ctx, result, args) => ...)
*/
export declare function after<T extends AnyFunction>(fn: T, advice: AfterAdvice<T>): T;
/**
* `around`:
* Direct usage => myFn = around(myFn, (proceed, ctx, args) => ...)
*/
export declare function around<T extends AnyFunction>(fn: T, advice: AroundAdvice<T>): T;
/**
* `error`:
* Direct usage => myFn = error(myFn, (err, ctx, args) => ...)
*/
export declare function error<T extends AnyFunction>(fn: T, advice: ErrorAdvice<T>): T;
declare const _default: {
SIGNALS: typeof SIGNALS;
before: typeof before;
after: typeof after;
around: typeof around;
error: typeof error;
};
export default _default;

View File

@ -1,150 +1,150 @@
/* -------------------------------------------------------------------------
* aspects.ts
*
* A robust aspect system supporting:
* - before: optionally modifies arguments (sync or async)
* - after: optionally modifies return value (sync or async)
* - around: complete control over function invocation
* - error: intercept errors (sync or async)
*
* Only supports direct function wrappers (e.g. fn = before(fn, ...)).
* ------------------------------------------------------------------------ */
/* -------------------------------------------------------------------------
* 1) SIGNALS Enum (string-based to avoid symbol issues)
* ------------------------------------------------------------------------ */
export var SIGNALS;
(function (SIGNALS) {
SIGNALS["BEFORE"] = "BEFORE";
SIGNALS["AFTER"] = "AFTER";
SIGNALS["AROUND"] = "AROUND";
SIGNALS["ERROR"] = "ERROR";
})(SIGNALS = SIGNALS || (SIGNALS = {}));
/* -------------------------------------------------------------------------
* 5) The SignalMap Implementation
* - This is where the actual "wrapping" logic lives.
* ------------------------------------------------------------------------ */
const SignalMap = {
/**
* BEFORE:
* - Possibly modifies arguments
* - If returns a Promise, we await it before calling original
* - If returns an array, we use that as new arguments
*/
[SIGNALS.BEFORE](original, advice) {
return function (...args) {
const maybeNewArgs = advice(this, args);
if (maybeNewArgs instanceof Promise) {
return maybeNewArgs.then((resolvedArgs) => {
const finalArgs = resolvedArgs || args;
const result = original.apply(this, finalArgs);
return (result instanceof Promise) ? result : Promise.resolve(result);
});
}
else {
const finalArgs = Array.isArray(maybeNewArgs) ? maybeNewArgs : args;
return original.apply(this, finalArgs);
}
};
},
/**
* AFTER:
* - Possibly modifies the return value
* - If original is async, we chain on its promise
* - Advice can be sync or async
*/
[SIGNALS.AFTER](original, advice) {
return function (...args) {
const result = original.apply(this, args);
if (result instanceof Promise) {
return result.then((unwrapped) => {
const maybeNewResult = advice(this, unwrapped, args);
return (maybeNewResult instanceof Promise) ? maybeNewResult : maybeNewResult;
});
}
else {
const maybeNewResult = advice(this, result, args);
if (maybeNewResult instanceof Promise) {
return maybeNewResult.then(r => r);
}
return maybeNewResult;
}
};
},
/**
* AROUND:
* - Full control over invocation
* - Typically you do: proceed(...args)
* - If you want to skip or call multiple times, you can
*/
[SIGNALS.AROUND](original, advice) {
return function (...args) {
const proceed = (...innerArgs) => original.apply(this, innerArgs);
return advice(proceed, this, args);
};
},
/**
* ERROR:
* - Intercepts errors thrown by the original function or a rejected Promise
* - Optionally returns a fallback or rethrows
*/
[SIGNALS.ERROR](original, advice) {
return function (...args) {
try {
const result = original.apply(this, args);
if (result instanceof Promise) {
// Handle async rejections
return result.catch((err) => {
return advice(err, this, args);
});
}
return result;
}
catch (err) {
// Synchronous error
return advice(err, this, args);
}
};
},
};
/* -------------------------------------------------------------------------
* 6) Direct Usage Functions (no decorator support)
* ------------------------------------------------------------------------ */
/**
* `before`:
* Direct usage => myFn = before(myFn, (ctx, args) => ...)
*/
export function before(fn, advice) {
return SignalMap[SIGNALS.BEFORE](fn, advice);
}
/**
* `after`:
* Direct usage => myFn = after(myFn, (ctx, result, args) => ...)
*/
export function after(fn, advice) {
return SignalMap[SIGNALS.AFTER](fn, advice);
}
/**
* `around`:
* Direct usage => myFn = around(myFn, (proceed, ctx, args) => ...)
*/
export function around(fn, advice) {
return SignalMap[SIGNALS.AROUND](fn, advice);
}
/**
* `error`:
* Direct usage => myFn = error(myFn, (err, ctx, args) => ...)
*/
export function error(fn, advice) {
return SignalMap[SIGNALS.ERROR](fn, advice);
}
/* -------------------------------------------------------------------------
* 7) Default Export
* ------------------------------------------------------------------------ */
export default {
SIGNALS,
before,
after,
around,
error,
};
/* -------------------------------------------------------------------------
* aspects.ts
*
* A robust aspect system supporting:
* - before: optionally modifies arguments (sync or async)
* - after: optionally modifies return value (sync or async)
* - around: complete control over function invocation
* - error: intercept errors (sync or async)
*
* Only supports direct function wrappers (e.g. fn = before(fn, ...)).
* ------------------------------------------------------------------------ */
/* -------------------------------------------------------------------------
* 1) SIGNALS Enum (string-based to avoid symbol issues)
* ------------------------------------------------------------------------ */
export var SIGNALS;
(function (SIGNALS) {
SIGNALS["BEFORE"] = "BEFORE";
SIGNALS["AFTER"] = "AFTER";
SIGNALS["AROUND"] = "AROUND";
SIGNALS["ERROR"] = "ERROR";
})(SIGNALS || (SIGNALS = {}));
/* -------------------------------------------------------------------------
* 5) The SignalMap Implementation
* - This is where the actual "wrapping" logic lives.
* ------------------------------------------------------------------------ */
const SignalMap = {
/**
* BEFORE:
* - Possibly modifies arguments
* - If returns a Promise, we await it before calling original
* - If returns an array, we use that as new arguments
*/
[SIGNALS.BEFORE](original, advice) {
return function (...args) {
const maybeNewArgs = advice(this, args);
if (maybeNewArgs instanceof Promise) {
return maybeNewArgs.then((resolvedArgs) => {
const finalArgs = resolvedArgs || args;
const result = original.apply(this, finalArgs);
return (result instanceof Promise) ? result : Promise.resolve(result);
});
}
else {
const finalArgs = Array.isArray(maybeNewArgs) ? maybeNewArgs : args;
return original.apply(this, finalArgs);
}
};
},
/**
* AFTER:
* - Possibly modifies the return value
* - If original is async, we chain on its promise
* - Advice can be sync or async
*/
[SIGNALS.AFTER](original, advice) {
return function (...args) {
const result = original.apply(this, args);
if (result instanceof Promise) {
return result.then((unwrapped) => {
const maybeNewResult = advice(this, unwrapped, args);
return (maybeNewResult instanceof Promise) ? maybeNewResult : maybeNewResult;
});
}
else {
const maybeNewResult = advice(this, result, args);
if (maybeNewResult instanceof Promise) {
return maybeNewResult.then(r => r);
}
return maybeNewResult;
}
};
},
/**
* AROUND:
* - Full control over invocation
* - Typically you do: proceed(...args)
* - If you want to skip or call multiple times, you can
*/
[SIGNALS.AROUND](original, advice) {
return function (...args) {
const proceed = (...innerArgs) => original.apply(this, innerArgs);
return advice(proceed, this, args);
};
},
/**
* ERROR:
* - Intercepts errors thrown by the original function or a rejected Promise
* - Optionally returns a fallback or rethrows
*/
[SIGNALS.ERROR](original, advice) {
return function (...args) {
try {
const result = original.apply(this, args);
if (result instanceof Promise) {
// Handle async rejections
return result.catch((err) => {
return advice(err, this, args);
});
}
return result;
}
catch (err) {
// Synchronous error
return advice(err, this, args);
}
};
},
};
/* -------------------------------------------------------------------------
* 6) Direct Usage Functions (no decorator support)
* ------------------------------------------------------------------------ */
/**
* `before`:
* Direct usage => myFn = before(myFn, (ctx, args) => ...)
*/
export function before(fn, advice) {
return SignalMap[SIGNALS.BEFORE](fn, advice);
}
/**
* `after`:
* Direct usage => myFn = after(myFn, (ctx, result, args) => ...)
*/
export function after(fn, advice) {
return SignalMap[SIGNALS.AFTER](fn, advice);
}
/**
* `around`:
* Direct usage => myFn = around(myFn, (proceed, ctx, args) => ...)
*/
export function around(fn, advice) {
return SignalMap[SIGNALS.AROUND](fn, advice);
}
/**
* `error`:
* Direct usage => myFn = error(myFn, (err, ctx, args) => ...)
*/
export function error(fn, advice) {
return SignalMap[SIGNALS.ERROR](fn, advice);
}
/* -------------------------------------------------------------------------
* 7) Default Export
* ------------------------------------------------------------------------ */
export default {
SIGNALS,
before,
after,
around,
error,
};
//# sourceMappingURL=aspects_simple.js.map

View File

@ -1 +1 @@
{"version":3,"file":"aspects_simple.js","sourceRoot":"","sources":["../src/aspects_simple.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;8EAU8E;AAE9E;;8EAE8E;AAC9E,MAAM,CAAN,IAAY,OAKT;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YAChB,CAAC;YAAC,OAAO,GAAG,EAAE,CAAC;gBACb,oBAAoB;gBACpB,OAAO,MAAM,CAAC,GAAG,EAAE,IAAI,EAAE,IAAI,CAAkB,CAAC;YAClD,CAAC;QACH,CAAM,CAAC;IACT,CAAC;CACF,CAAC;AAEF;;8EAE8E;AAE9E;;;GAGG;AACH,MAAM,UAAU,MAAM,CAAwB,EAAK,EAAE,MAAuB;IAC1E,OAAO,SAAS,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC;AAC/C,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,KAAK,CAAwB,EAAK,EAAE,MAAsB;IACxE,OAAO,SAAS,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC;AAC9C,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,MAAM,CAAwB,EAAK,EAAE,MAAuB;IAC1E,OAAO,SAAS,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC;AAC/C,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,KAAK,CAAwB,EAAK,EAAE,MAAsB;IACxE,OAAO,SAAS,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC;AAC9C,CAAC;AAED;;8EAE8E;AAC9E,eAAe;IACb,OAAO;IACP,MAAM;IACN,KAAK;IACL,MAAM;IACN,KAAK;CACN,CAAC"}

View File

@ -1,26 +1,26 @@
/**
* Throws an error with the provided message if the provided value does not evaluate to a true Javascript value.
*
* @deprecated Use `assert(...)` instead.
* This method is usually used like this:
* ```ts
* import * as assert from 'vs/base/common/assert';
* assert.ok(...);
* ```
*
* However, `assert` in that example is a user chosen name.
* There is no tooling for generating such an import statement.
* Thus, the `assert(...)` function should be used instead.
*/
export declare function ok(value?: unknown, message?: string): void;
export declare function assertNever(value: never, message?: string): never;
export declare function assert(condition: boolean, message?: string): asserts condition;
/**
* Like assert, but doesn't throw.
*/
export declare function softAssert(condition: boolean): void;
/**
* condition must be side-effect free!
*/
export declare function assertFn(condition: () => boolean): void;
export declare function checkAdjacentItems<T>(items: readonly T[], predicate: (item1: T, item2: T) => boolean): boolean;
/**
* Throws an error with the provided message if the provided value does not evaluate to a true Javascript value.
*
* @deprecated Use `assert(...)` instead.
* This method is usually used like this:
* ```ts
* import * as assert from 'vs/base/common/assert';
* assert.ok(...);
* ```
*
* However, `assert` in that example is a user chosen name.
* There is no tooling for generating such an import statement.
* Thus, the `assert(...)` function should be used instead.
*/
export declare function ok(value?: unknown, message?: string): void;
export declare function assertNever(value: never, message?: string): never;
export declare function assert(condition: boolean, message?: string): asserts condition;
/**
* Like assert, but doesn't throw.
*/
export declare function softAssert(condition: boolean): void;
/**
* condition must be side-effect free!
*/
export declare function assertFn(condition: () => boolean): void;
export declare function checkAdjacentItems<T>(items: readonly T[], predicate: (item1: T, item2: T) => boolean): boolean;

View File

@ -1,65 +1,65 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { BugIndicatingError, onUnexpectedError } from './errors.js';
/**
* Throws an error with the provided message if the provided value does not evaluate to a true Javascript value.
*
* @deprecated Use `assert(...)` instead.
* This method is usually used like this:
* ```ts
* import * as assert from 'vs/base/common/assert';
* assert.ok(...);
* ```
*
* However, `assert` in that example is a user chosen name.
* There is no tooling for generating such an import statement.
* Thus, the `assert(...)` function should be used instead.
*/
export function ok(value, message) {
if (!value) {
throw new Error(message ? `Assertion failed (${message})` : 'Assertion Failed');
}
}
export function assertNever(value, message = 'Unreachable') {
throw new Error(message);
}
export function assert(condition, message = 'unexpected state') {
if (!condition) {
throw new BugIndicatingError(`Assertion Failed: ${message}`);
}
}
/**
* Like assert, but doesn't throw.
*/
export function softAssert(condition) {
if (!condition) {
onUnexpectedError(new BugIndicatingError('Soft Assertion Failed'));
}
}
/**
* condition must be side-effect free!
*/
export function assertFn(condition) {
if (!condition()) {
// eslint-disable-next-line no-debugger
debugger;
// Reevaluate `condition` again to make debugging easier
condition();
onUnexpectedError(new BugIndicatingError('Assertion Failed'));
}
}
export function checkAdjacentItems(items, predicate) {
let i = 0;
while (i < items.length - 1) {
const a = items[i];
const b = items[i + 1];
if (!predicate(a, b)) {
return false;
}
i++;
}
return true;
}
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { BugIndicatingError, onUnexpectedError } from './errors.js';
/**
* Throws an error with the provided message if the provided value does not evaluate to a true Javascript value.
*
* @deprecated Use `assert(...)` instead.
* This method is usually used like this:
* ```ts
* import * as assert from 'vs/base/common/assert';
* assert.ok(...);
* ```
*
* However, `assert` in that example is a user chosen name.
* There is no tooling for generating such an import statement.
* Thus, the `assert(...)` function should be used instead.
*/
export function ok(value, message) {
if (!value) {
throw new Error(message ? `Assertion failed (${message})` : 'Assertion Failed');
}
}
export function assertNever(value, message = 'Unreachable') {
throw new Error(message);
}
export function assert(condition, message = 'unexpected state') {
if (!condition) {
throw new BugIndicatingError(`Assertion Failed: ${message}`);
}
}
/**
* Like assert, but doesn't throw.
*/
export function softAssert(condition) {
if (!condition) {
onUnexpectedError(new BugIndicatingError('Soft Assertion Failed'));
}
}
/**
* condition must be side-effect free!
*/
export function assertFn(condition) {
if (!condition()) {
// eslint-disable-next-line no-debugger
debugger;
// Reevaluate `condition` again to make debugging easier
condition();
onUnexpectedError(new BugIndicatingError('Assertion Failed'));
}
}
export function checkAdjacentItems(items, predicate) {
let i = 0;
while (i < items.length - 1) {
const a = items[i];
const b = items[i + 1];
if (!predicate(a, b)) {
return false;
}
i++;
}
return true;
}
//# sourceMappingURL=assert.js.map

View File

@ -1 +1 @@
{"version":3,"file":"assert.js","sourceRoot":"","sources":["../src/assert.ts"],"names":[],"mappings":"AAAA;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AAC;QACZ,iBAAiB,CAAC,IAAI,kBAAkB,CAAC,kBAAkB,CAAC,CAAC,CAAC;IAC/D,CAAC;AACF,CAAC;AAED,MAAM,UAAU,kBAAkB,CAAI,KAAmB,EAAE,SAA0C;IACpG,IAAI,CAAC,GAAG,CAAC,CAAC;IACV,OAAO,CAAC,GAAG,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC7B,MAAM,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;QACnB,MAAM,CAAC,GAAG,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;QACvB,IAAI,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC;YACtB,OAAO,KAAK,CAAC;QACd,CAAC;QACD,CAAC,EAAE,CAAC;IACL,CAAC;IACD,OAAO,IAAI,CAAC;AACb,CAAC"}

View File

@ -1,46 +1,46 @@
import { CancellationToken } from './cancellation.js';
import { IDisposable } from './lifecycle.js';
export interface CacheResult<T> extends IDisposable {
promise: Promise<T>;
}
export declare class Cache<T> {
private task;
private result;
constructor(task: (ct: CancellationToken) => Promise<T>);
get(): CacheResult<T>;
}
export declare function identity<T>(t: T): T;
interface ICacheOptions<TArg> {
/**
* The cache key is used to identify the cache entry.
* Strict equality is used to compare cache keys.
*/
getCacheKey: (arg: TArg) => unknown;
}
/**
* Uses a LRU cache to make a given parametrized function cached.
* Caches just the last key/value.
*/
export declare class LRUCachedFunction<TArg, TComputed> {
private lastCache;
private lastArgKey;
private readonly _fn;
private readonly _computeKey;
constructor(fn: (arg: TArg) => TComputed);
constructor(options: ICacheOptions<TArg>, fn: (arg: TArg) => TComputed);
get(arg: TArg): TComputed;
}
/**
* Uses an unbounded cache to memoize the results of the given function.
*/
export declare class CachedFunction<TArg, TComputed> {
private readonly _map;
private readonly _map2;
get cachedValues(): ReadonlyMap<TArg, TComputed>;
private readonly _fn;
private readonly _computeKey;
constructor(fn: (arg: TArg) => TComputed);
constructor(options: ICacheOptions<TArg>, fn: (arg: TArg) => TComputed);
get(arg: TArg): TComputed;
}
export {};
import { CancellationToken } from './cancellation.js';
import { IDisposable } from './lifecycle.js';
export interface CacheResult<T> extends IDisposable {
promise: Promise<T>;
}
export declare class Cache<T> {
private task;
private result;
constructor(task: (ct: CancellationToken) => Promise<T>);
get(): CacheResult<T>;
}
export declare function identity<T>(t: T): T;
interface ICacheOptions<TArg> {
/**
* The cache key is used to identify the cache entry.
* Strict equality is used to compare cache keys.
*/
getCacheKey: (arg: TArg) => unknown;
}
/**
* Uses a LRU cache to make a given parametrized function cached.
* Caches just the last key/value.
*/
export declare class LRUCachedFunction<TArg, TComputed> {
private lastCache;
private lastArgKey;
private readonly _fn;
private readonly _computeKey;
constructor(fn: (arg: TArg) => TComputed);
constructor(options: ICacheOptions<TArg>, fn: (arg: TArg) => TComputed);
get(arg: TArg): TComputed;
}
/**
* Uses an unbounded cache to memoize the results of the given function.
*/
export declare class CachedFunction<TArg, TComputed> {
private readonly _map;
private readonly _map2;
get cachedValues(): ReadonlyMap<TArg, TComputed>;
private readonly _fn;
private readonly _computeKey;
constructor(fn: (arg: TArg) => TComputed);
constructor(options: ICacheOptions<TArg>, fn: (arg: TArg) => TComputed);
get(arg: TArg): TComputed;
}
export {};

View File

@ -1,92 +1,92 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { CancellationTokenSource } from './cancellation.js';
export class Cache {
task;
result = null;
constructor(task) {
this.task = task;
}
get() {
if (this.result) {
return this.result;
}
const cts = new CancellationTokenSource();
const promise = this.task(cts.token);
this.result = {
promise,
dispose: () => {
this.result = null;
cts.cancel();
cts.dispose();
}
};
return this.result;
}
}
export function identity(t) {
return t;
}
/**
* Uses a LRU cache to make a given parametrized function cached.
* Caches just the last key/value.
*/
export class LRUCachedFunction {
lastCache = undefined;
lastArgKey = undefined;
_fn;
_computeKey;
constructor(arg1, arg2) {
if (typeof arg1 === 'function') {
this._fn = arg1;
this._computeKey = identity;
}
else {
this._fn = arg2;
this._computeKey = arg1.getCacheKey;
}
}
get(arg) {
const key = this._computeKey(arg);
if (this.lastArgKey !== key) {
this.lastArgKey = key;
this.lastCache = this._fn(arg);
}
return this.lastCache;
}
}
/**
* Uses an unbounded cache to memoize the results of the given function.
*/
export class CachedFunction {
_map = new Map();
_map2 = new Map();
get cachedValues() {
return this._map;
}
_fn;
_computeKey;
constructor(arg1, arg2) {
if (typeof arg1 === 'function') {
this._fn = arg1;
this._computeKey = identity;
}
else {
this._fn = arg2;
this._computeKey = arg1.getCacheKey;
}
}
get(arg) {
const key = this._computeKey(arg);
if (this._map2.has(key)) {
return this._map2.get(key);
}
const value = this._fn(arg);
this._map.set(arg, value);
this._map2.set(key, value);
return value;
}
}
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { CancellationTokenSource } from './cancellation.js';
export class Cache {
task;
result = null;
constructor(task) {
this.task = task;
}
get() {
if (this.result) {
return this.result;
}
const cts = new CancellationTokenSource();
const promise = this.task(cts.token);
this.result = {
promise,
dispose: () => {
this.result = null;
cts.cancel();
cts.dispose();
}
};
return this.result;
}
}
export function identity(t) {
return t;
}
/**
* Uses a LRU cache to make a given parametrized function cached.
* Caches just the last key/value.
*/
export class LRUCachedFunction {
lastCache = undefined;
lastArgKey = undefined;
_fn;
_computeKey;
constructor(arg1, arg2) {
if (typeof arg1 === 'function') {
this._fn = arg1;
this._computeKey = identity;
}
else {
this._fn = arg2;
this._computeKey = arg1.getCacheKey;
}
}
get(arg) {
const key = this._computeKey(arg);
if (this.lastArgKey !== key) {
this.lastArgKey = key;
this.lastCache = this._fn(arg);
}
return this.lastCache;
}
}
/**
* Uses an unbounded cache to memoize the results of the given function.
*/
export class CachedFunction {
_map = new Map();
_map2 = new Map();
get cachedValues() {
return this._map;
}
_fn;
_computeKey;
constructor(arg1, arg2) {
if (typeof arg1 === 'function') {
this._fn = arg1;
this._computeKey = identity;
}
else {
this._fn = arg2;
this._computeKey = arg1.getCacheKey;
}
}
get(arg) {
const key = this._computeKey(arg);
if (this._map2.has(key)) {
return this._map2.get(key);
}
const value = this._fn(arg);
this._map.set(arg, value);
this._map2.set(key, value);
return value;
}
}
//# sourceMappingURL=cache.js.map

View File

@ -1 +1 @@
{"version":3,"file":"cache.js","sourceRoot":"","sources":["../src/cache.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAqB,uBAAuB,EAAE,MAAM,mBAAmB,CAAC;AAO/E,MAAM,OAAO,KAAK;IAGG;IADZ,MAAM,GAA0B,IAAI,CAAC;IAC7C,YAAoB,IAA2C;QAA3C,SAAI,GAAJ,IAAI,CAAuC;IAAI,CAAC;IAEpE,GAAG;QACF,IAAI,IAAI,CAAC,MAAM,EAAE;YAChB,OAAO,IAAI,CAAC,MAAM,CAAC;SACnB;QAED,MAAM,GAAG,GAAG,IAAI,uBAAuB,EAAE,CAAC;QAC1C,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QAErC,IAAI,CAAC,MAAM,GAAG;YACb,OAAO;YACP,OAAO,EAAE,GAAG,EAAE;gBACb,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;gBACnB,GAAG,CAAC,MAAM,EAAE,CAAC;gBACb,GAAG,CAAC,OAAO,EAAE,CAAC;YACf,CAAC;SACD,CAAC;QAEF,OAAO,IAAI,CAAC,MAAM,CAAC;IACpB,CAAC;CACD;AAED,MAAM,UAAU,QAAQ,CAAI,CAAI;IAC/B,OAAO,CAAC,CAAC;AACV,CAAC;AAUD;;;EAGE;AACF,MAAM,OAAO,iBAAiB;IACrB,SAAS,GAA0B,SAAS,CAAC;IAC7C,UAAU,GAAwB,SAAS,CAAC;IAEnC,GAAG,CAA2B;IAC9B,WAAW,CAAyB;I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