@blocklet/pages-kit-core 0.0.1
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 +13 -0
- package/lib/cjs/block.d.ts +11 -0
- package/lib/cjs/block.js +91 -0
- package/lib/cjs/core.d.ts +12 -0
- package/lib/cjs/core.js +43 -0
- package/lib/cjs/dataset.d.ts +8 -0
- package/lib/cjs/dataset.js +34 -0
- package/lib/cjs/index.d.ts +3 -0
- package/lib/cjs/index.js +19 -0
- package/lib/cjs/page.d.ts +11 -0
- package/lib/cjs/page.js +77 -0
- package/lib/cjs/renderable.d.ts +6 -0
- package/lib/cjs/renderable.js +6 -0
- package/lib/cjs/tsconfig.tsbuildinfo +1 -0
- package/lib/cjs/types/block.d.ts +4 -0
- package/lib/cjs/types/block.js +2 -0
- package/lib/cjs/types/core.d.ts +22 -0
- package/lib/cjs/types/core.js +2 -0
- package/lib/cjs/types/dataset.d.ts +16 -0
- package/lib/cjs/types/dataset.js +2 -0
- package/lib/cjs/types/env.d.ts +6 -0
- package/lib/cjs/types/env.js +3 -0
- package/lib/cjs/types/index.d.ts +6 -0
- package/lib/cjs/types/index.js +22 -0
- package/lib/cjs/types/page.d.ts +28 -0
- package/lib/cjs/types/page.js +2 -0
- package/lib/cjs/types/renderable.d.ts +11 -0
- package/lib/cjs/types/renderable.js +2 -0
- package/lib/esm/block.d.ts +11 -0
- package/lib/esm/block.js +64 -0
- package/lib/esm/core.d.ts +12 -0
- package/lib/esm/core.js +39 -0
- package/lib/esm/dataset.d.ts +8 -0
- package/lib/esm/dataset.js +30 -0
- package/lib/esm/index.d.ts +3 -0
- package/lib/esm/index.js +3 -0
- package/lib/esm/page.d.ts +11 -0
- package/lib/esm/page.js +73 -0
- package/lib/esm/renderable.d.ts +6 -0
- package/lib/esm/renderable.js +2 -0
- package/lib/esm/tsconfig.tsbuildinfo +1 -0
- package/lib/esm/types/block.d.ts +4 -0
- package/lib/esm/types/block.js +1 -0
- package/lib/esm/types/core.d.ts +22 -0
- package/lib/esm/types/core.js +1 -0
- package/lib/esm/types/dataset.d.ts +16 -0
- package/lib/esm/types/dataset.js +1 -0
- package/lib/esm/types/env.d.ts +6 -0
- package/lib/esm/types/env.js +2 -0
- package/lib/esm/types/index.d.ts +6 -0
- package/lib/esm/types/index.js +6 -0
- package/lib/esm/types/page.d.ts +28 -0
- package/lib/esm/types/page.js +1 -0
- package/lib/esm/types/renderable.d.ts +11 -0
- package/lib/esm/types/renderable.js +1 -0
- package/lib/types/block.d.ts +11 -0
- package/lib/types/core.d.ts +12 -0
- package/lib/types/dataset.d.ts +8 -0
- package/lib/types/index.d.ts +3 -0
- package/lib/types/page.d.ts +11 -0
- package/lib/types/renderable.d.ts +6 -0
- package/lib/types/tsconfig.tsbuildinfo +1 -0
- package/lib/types/types/block.d.ts +4 -0
- package/lib/types/types/core.d.ts +22 -0
- package/lib/types/types/dataset.d.ts +16 -0
- package/lib/types/types/env.d.ts +6 -0
- package/lib/types/types/index.d.ts +6 -0
- package/lib/types/types/page.d.ts +28 -0
- package/lib/types/types/renderable.d.ts +11 -0
- package/package.json +75 -0
- package/tsconfig.json +16 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export interface PageMetadata {
|
|
2
|
+
id: string;
|
|
3
|
+
title?: string;
|
|
4
|
+
ogImage?: string;
|
|
5
|
+
description?: string;
|
|
6
|
+
slug: string;
|
|
7
|
+
[key: string]: any;
|
|
8
|
+
}
|
|
9
|
+
export interface DatasetStructure {
|
|
10
|
+
[pageId: string]: DatasetStructure;
|
|
11
|
+
}
|
|
12
|
+
export interface IDataset<T = any> {
|
|
13
|
+
get(key: string): Promise<T | null>;
|
|
14
|
+
set(key: string, value: T): Promise<T | null>;
|
|
15
|
+
clear(): Promise<void>;
|
|
16
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Block } from './block';
|
|
2
|
+
import { Renderable } from './renderable';
|
|
3
|
+
export interface PageBlocks extends Map<string, Block> {
|
|
4
|
+
}
|
|
5
|
+
export interface PageStructure {
|
|
6
|
+
[pageId: string]: PageBlocks;
|
|
7
|
+
}
|
|
8
|
+
export interface Page extends Renderable {
|
|
9
|
+
blocks?: PageBlocks;
|
|
10
|
+
}
|
|
11
|
+
export interface PageSection {
|
|
12
|
+
id: string;
|
|
13
|
+
component: string;
|
|
14
|
+
name?: string;
|
|
15
|
+
config?: Record<string, any>;
|
|
16
|
+
properties?: Record<string, any>;
|
|
17
|
+
code?: string;
|
|
18
|
+
}
|
|
19
|
+
export interface PageMeta {
|
|
20
|
+
backgroundColor?: string;
|
|
21
|
+
}
|
|
22
|
+
export interface PageData {
|
|
23
|
+
id: string;
|
|
24
|
+
createdAt: string;
|
|
25
|
+
updatedAt: string;
|
|
26
|
+
meta: PageMeta;
|
|
27
|
+
sections: PageSection[];
|
|
28
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export interface CacheOptions {
|
|
2
|
+
key: string;
|
|
3
|
+
ttl?: number;
|
|
4
|
+
}
|
|
5
|
+
export interface RenderOptions {
|
|
6
|
+
locale?: string;
|
|
7
|
+
cacheOptions?: CacheOptions;
|
|
8
|
+
}
|
|
9
|
+
export interface Renderable<I = any, O = any> {
|
|
10
|
+
render(input: I, options?: RenderOptions): Promise<O>;
|
|
11
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Block as BlockType } from '@types';
|
|
2
|
+
import { ReactElement } from 'react';
|
|
3
|
+
import { Renderable, RenderOptions } from './types/renderable';
|
|
4
|
+
export declare class Block implements BlockType, Renderable<Record<string, any>, ReactElement | null> {
|
|
5
|
+
code?: string | undefined;
|
|
6
|
+
private ESM_IMPORT_REGEX;
|
|
7
|
+
private ESM_KEYWORDS;
|
|
8
|
+
constructor(code?: string | undefined);
|
|
9
|
+
setData(code: string): void;
|
|
10
|
+
render(input?: Record<string, any>, _options?: RenderOptions): Promise<ReactElement | null>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Block, CoreConstructor, CoreOptions, ICore, Page } from '@types';
|
|
2
|
+
import { Dataset } from './dataset';
|
|
3
|
+
export declare class Core<B extends Block = Block, D extends Dataset = Dataset, P extends Page = Page> implements ICore<B, D, P> {
|
|
4
|
+
readonly blocks: Map<string, B>;
|
|
5
|
+
readonly datasets: Map<string, D>;
|
|
6
|
+
readonly pages: Map<string, P>;
|
|
7
|
+
readonly options: CoreOptions;
|
|
8
|
+
constructor({ blocks, datasets, pages, options, }?: CoreConstructor<B, D, P>);
|
|
9
|
+
readonly block: Block;
|
|
10
|
+
readonly page: Page;
|
|
11
|
+
private mergeRenderOptions;
|
|
12
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { DatasetStructure, IDataset } from '@types';
|
|
2
|
+
export declare class Dataset implements IDataset<DatasetStructure> {
|
|
3
|
+
private store;
|
|
4
|
+
constructor(initialData?: DatasetStructure);
|
|
5
|
+
get(key: string): Promise<DatasetStructure | null>;
|
|
6
|
+
set(key: string, value: DatasetStructure): Promise<DatasetStructure | null>;
|
|
7
|
+
clear(): Promise<void>;
|
|
8
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Page as PageType, PageData, PageBlocks, RenderOptions } from '@types';
|
|
2
|
+
import { ReactElement } from 'react';
|
|
3
|
+
export declare class Page implements PageType {
|
|
4
|
+
private data?;
|
|
5
|
+
blocks: PageBlocks;
|
|
6
|
+
constructor(data?: PageData);
|
|
7
|
+
private initBlocks;
|
|
8
|
+
private createPageElement;
|
|
9
|
+
setData(data: PageData): void;
|
|
10
|
+
render(input?: Record<string, any>, options?: RenderOptions): Promise<ReactElement | null>;
|
|
11
|
+
}
|