@kaskad/core 0.0.6 → 0.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "@kaskad/core",
3
- "version": "0.0.6",
3
+ "version": "0.0.8",
4
4
  "peerDependencies": {
5
- "@kaskad/types": "0.0.6",
6
- "@kaskad/config": "0.0.6",
7
- "@kaskad/definition": "0.0.6",
8
- "@kaskad/schema": "0.0.6",
9
- "@kaskad/component-tree": "0.0.6",
10
- "@kaskad/formula-parser": "0.0.6",
11
- "@kaskad/eval-tree": "0.0.6",
5
+ "@kaskad/types": "0.0.8",
6
+ "@kaskad/config": "0.0.8",
7
+ "@kaskad/definition": "0.0.8",
8
+ "@kaskad/schema": "0.0.8",
9
+ "@kaskad/component-tree": "0.0.8",
10
+ "@kaskad/formula-parser": "0.0.8",
11
+ "@kaskad/eval-tree": "0.0.8",
12
12
  "mobx": "^6.13.7",
13
13
  "rxjs": "~7.8.0",
14
14
  "yaml": "^2.0.0"
@@ -23,6 +23,10 @@
23
23
  ".": {
24
24
  "types": "./types/kaskad-core.d.ts",
25
25
  "default": "./fesm2022/kaskad-core.mjs"
26
+ },
27
+ "./testing": {
28
+ "types": "./types/kaskad-core-testing.d.ts",
29
+ "default": "./fesm2022/kaskad-core-testing.mjs"
26
30
  }
27
31
  },
28
32
  "dependencies": {
@@ -0,0 +1,34 @@
1
+ import { ComponentRecipe, TComponent, ComponentId } from '@kaskad/core';
2
+
3
+ declare function createView(rawSchema: ComponentRecipe): Promise<void>;
4
+ declare function loadYamlSchema(absolutePath: string): ComponentRecipe;
5
+ declare function loadYamlSchemaFrom(baseDir: string, relativePath: string): ComponentRecipe;
6
+ declare function createViewFromFile(baseDir: string, relativePath: string): Promise<void>;
7
+ /**
8
+ * Sets up a fetch mock that resolves `/recipes/{path}.yml` URLs to actual files.
9
+ * Use this when testing recipes that use `templateUrl` to load external templates.
10
+ *
11
+ * @param recipesBaseDir - The base directory where recipe files are located
12
+ *
13
+ * @example
14
+ * ```typescript
15
+ * // In your test file
16
+ * import { setupRecipeFetch } from '@kaskad/core/testing';
17
+ * import * as path from 'node:path';
18
+ *
19
+ * setupRecipeFetch(path.resolve(__dirname, '../..'));
20
+ * ```
21
+ */
22
+ declare function setupRecipeFetch(recipesBaseDir: string): void;
23
+ declare function setCurrent(selector: string): void;
24
+ declare function get<T = unknown>(selector: string): T;
25
+ declare function set<T = unknown>(selector: string, value: T): void;
26
+ declare function run(selector: string, ...args: unknown[]): Promise<unknown>;
27
+ declare function select(selector: string): TComponent;
28
+ declare function selectAll(selector: string): TComponent[];
29
+ declare function evaluating(selector: string): boolean;
30
+ declare function running(selector: string): boolean;
31
+ declare function getComponentType(selector: string): string;
32
+ declare function getId(selector: string): ComponentId;
33
+
34
+ export { createView, createViewFromFile, evaluating, get, getComponentType, getId, loadYamlSchema, loadYamlSchemaFrom, run, running, select, selectAll, set, setCurrent, setupRecipeFetch };
@@ -1,8 +1,11 @@
1
1
  import { ValueType, NodePosition } from '@kaskad/types';
2
2
  export * from '@kaskad/types';
3
+ import { CommandDefinition } from '@kaskad/definition';
3
4
  export * from '@kaskad/definition';
5
+ import { ComponentRawDefinition } from '@kaskad/schema';
4
6
  export { ComponentRawDefinition, ComponentRecipe, loadTemplates, templateRegistry, unfoldComponentDefinitions, unfoldNodeSchema } from '@kaskad/schema';
5
- export { FunctionRegistry, ImperativeFunctionDefinition } from '@kaskad/eval-tree';
7
+ import { FunctionDefinition } from '@kaskad/eval-tree';
8
+ export { FunctionDefinition, FunctionRegistry, ImperativeFunctionDefinition } from '@kaskad/eval-tree';
6
9
  import { AbstractNode, CommandNode } from '@kaskad/component-tree';
7
10
  export { CommandRef, ComponentStore, ComponentTreeApi, TComponent, createRootNode } from '@kaskad/component-tree';
8
11
 
@@ -16,7 +19,17 @@ declare class TemplateLoadingTracker {
16
19
  }
17
20
  declare const templateLoadingTracker: TemplateLoadingTracker;
18
21
 
19
- declare function registerCommonDefinitions(): void;
22
+ interface KaskadPlugin {
23
+ definitions?: Record<string, ComponentRawDefinition>;
24
+ shapes?: Record<string, Record<string, ValueType>>;
25
+ functions?: Record<string, FunctionDefinition>;
26
+ commands?: Record<string, CommandDefinition>;
27
+ setup?: () => void;
28
+ }
29
+ declare function registerPlugin(plugin: KaskadPlugin): void;
30
+ declare function registerPlugins(...plugins: KaskadPlugin[]): void;
31
+
32
+ declare const common: KaskadPlugin;
20
33
 
21
34
  declare function activateNode(node: AbstractNode<ValueType>): void;
22
35
 
@@ -27,9 +40,9 @@ declare function runCommand(node: CommandNode, ...args: unknown[]): Promise<unkn
27
40
  declare const debugName: (position: NodePosition, thing: string) => string;
28
41
  declare const componentInstanceMap: Map<string, unknown>;
29
42
 
30
- declare function autoRegisterCommonDefinitions(): void;
43
+ declare const sys: KaskadPlugin;
31
44
 
32
- declare function autoRegisterBrowserDefinitions(): void;
45
+ declare const browser: KaskadPlugin;
33
46
 
34
47
  interface ValidatorDefinition<TParams = any> {
35
48
  params: Record<string, ValueType>;
@@ -56,9 +69,9 @@ interface ValidatorProperty {
56
69
 
57
70
  declare function registerValidator(validatorType: string, def: ValidatorDefinition): void;
58
71
  declare function registerValidators(validators: Record<string, ValidatorDefinition>): void;
59
- declare function autoRegisterFormsDefinitions(): void;
72
+ declare const forms: KaskadPlugin;
60
73
 
61
74
  declare function initRuntime(): void;
62
75
 
63
- export { activateNode, activateStructure, autoRegisterBrowserDefinitions, autoRegisterCommonDefinitions, autoRegisterFormsDefinitions, componentInstanceMap, debugName, initRuntime, registerCommonDefinitions, registerValidator, registerValidators, runCommand, templateLoadingTracker };
64
- export type { Validate, ValidationResult, ValidatorDefinition, ValidatorProperty, ValidatorRawValue };
76
+ export { activateNode, activateStructure, browser, common, componentInstanceMap, debugName, forms, initRuntime, registerPlugin, registerPlugins, registerValidator, registerValidators, runCommand, sys, templateLoadingTracker };
77
+ export type { KaskadPlugin, Validate, ValidationResult, ValidatorDefinition, ValidatorProperty, ValidatorRawValue };