morphic-blocks 0.0.1 → 0.2.0
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/LICENSE +202 -0
- package/NOTICE +5 -0
- package/README.md +74 -6
- package/definitions.schema.json +283 -0
- package/dist/code-editor-YFXMCcWg.js +4 -0
- package/dist/index.d.ts +10 -0
- package/dist/morphic/MorphicBlocks.d.ts +360 -0
- package/dist/morphic/behavior-runtime.d.ts +3 -0
- package/dist/morphic/block-font.d.ts +34 -0
- package/dist/morphic/block-namespace.d.ts +34 -0
- package/dist/morphic/block-view.d.ts +54 -0
- package/dist/morphic/code-editor.d.ts +172 -0
- package/dist/morphic/codegen.d.ts +4 -0
- package/dist/morphic/constants.d.ts +7 -0
- package/dist/morphic/definitions.d.ts +28 -0
- package/dist/morphic/element-types.d.ts +20 -0
- package/dist/morphic/resize.d.ts +35 -0
- package/dist/morphic/selection-sync.d.ts +51 -0
- package/dist/morphic/styles.d.ts +36 -0
- package/dist/morphic/syntax-highlight.d.ts +14 -0
- package/dist/morphic/template-codegen.d.ts +16 -0
- package/dist/morphic/template.d.ts +45 -0
- package/dist/morphic/toolbar.d.ts +48 -0
- package/dist/morphic/toolbox-canvas.d.ts +53 -0
- package/dist/morphic/toolbox.d.ts +3 -0
- package/dist/morphic/types.d.ts +697 -0
- package/dist/morphic/validate-definitions.d.ts +31 -0
- package/dist/morphic/view-resolver.d.ts +17 -0
- package/dist/morphic-blocks.js +4265 -0
- package/dist/morphic-blocks.umd.cjs +30 -0
- package/dist/toolbar-kxlfr8TT.js +4 -0
- package/package.json +58 -5
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { MorphicBehaviorMap, MorphicBlockDefinition, MorphicElementTypeEntry, MorphicHighlightDefinition, MorphicModeDefinition, MorphicPresetDefinition, MorphicToolboxCategory } from "./types";
|
|
2
|
+
/**
|
|
3
|
+
* Inputs for a definitions validation pass. Everything is optional except the
|
|
4
|
+
* definitions + elementTypes (available at construction); the cross-reference
|
|
5
|
+
* data (modes / highlighting / categories) arrives from the mount config.
|
|
6
|
+
*/
|
|
7
|
+
export interface ValidateDefinitionsArgs {
|
|
8
|
+
definitions: ReadonlyMap<string, MorphicBlockDefinition>;
|
|
9
|
+
elementTypes: Record<string, MorphicElementTypeEntry>;
|
|
10
|
+
behaviors: MorphicBehaviorMap;
|
|
11
|
+
modes?: MorphicModeDefinition[];
|
|
12
|
+
presets?: MorphicPresetDefinition[];
|
|
13
|
+
highlighting?: Record<string, MorphicHighlightDefinition>;
|
|
14
|
+
categories?: MorphicToolboxCategory[];
|
|
15
|
+
}
|
|
16
|
+
export interface DefinitionValidationResult {
|
|
17
|
+
/** Structural problems that guarantee wrong output — the caller should throw. */
|
|
18
|
+
errors: string[];
|
|
19
|
+
/** Degraded / dead-config problems — the caller should warn. */
|
|
20
|
+
warnings: string[];
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Static validation of a definitions file. Complements the constructor-time
|
|
24
|
+
* checks in `createDefinitionMap` (identifier / element / duplicate) with the
|
|
25
|
+
* cross-field checks that would otherwise fail silently at render time.
|
|
26
|
+
*
|
|
27
|
+
* Pure and side-effect free: it collects every problem into `errors` (throw)
|
|
28
|
+
* and `warnings` (console.warn) so the caller reports them all at once rather
|
|
29
|
+
* than failing on the first. A known-good file yields two empty arrays.
|
|
30
|
+
*/
|
|
31
|
+
export declare function validateDefinitions(args: ValidateDefinitionsArgs): DefinitionValidationResult;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { MorphicBlockDefinition, MorphicElementTypeEntry, MorphicModeDefinition, MorphicModeName, MorphicResolvedView } from "./types";
|
|
2
|
+
/**
|
|
3
|
+
* Source element of a mode: the first element in `mode.elements` whose type
|
|
4
|
+
* is "code". This is the element a codespace or preview renders when the mode
|
|
5
|
+
* is assigned to it.
|
|
6
|
+
*/
|
|
7
|
+
export declare function resolveModeSourceElement(mode: MorphicModeDefinition, elementTypes?: Record<string, MorphicElementTypeEntry>): string | undefined;
|
|
8
|
+
/**
|
|
9
|
+
* Resolves the workspace template for a block in a given mode.
|
|
10
|
+
*
|
|
11
|
+
* Resolution order:
|
|
12
|
+
* 1. First element in the mode's `elements` array whose type is "code"
|
|
13
|
+
* 2. First element in the block definition whose type is "code"
|
|
14
|
+
* 3. Element literally named "block" (backward-compat fallback)
|
|
15
|
+
* 4. First element in the block definition
|
|
16
|
+
*/
|
|
17
|
+
export declare function resolveBlockView(definition: MorphicBlockDefinition, mode: MorphicModeName, elementTypes?: Record<string, MorphicElementTypeEntry>, modeDefs?: MorphicModeDefinition[]): MorphicResolvedView;
|