@beforesemicolon/site-builder 0.30.0 → 0.33.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.
@@ -1,15 +1,15 @@
1
- export interface ObjectLiteral {
2
- [key: string]: string | number | boolean | ObjectLiteral | ObjectLiteral[] | unknown;
1
+ export interface ObjectLiteral<T = unknown> {
2
+ [key: string | number | symbol]: [T] extends [unknown] ? string | number | boolean | ObjectLiteral | ObjectLiteral[] | unknown : T;
3
3
  }
4
4
  export interface StyleObject {
5
5
  [key: string]: string | number | StyleObject;
6
6
  }
7
7
  export type Style = string | StyleObject;
8
8
  export interface ContentNode {
9
- [key: string]: string | number | boolean | Array<ContentNode | string>;
9
+ [key: string]: string | number | boolean | Array<ContentNode | string> | undefined;
10
10
  name: string;
11
- children: Array<ContentNode | string>;
12
- id: string;
11
+ children?: Array<ContentNode | string>;
12
+ id?: string;
13
13
  }
14
14
  export type TemplateContent = (string | ContentNode)[];
15
15
  export declare enum InputDefinitionType {
@@ -57,27 +57,41 @@ export declare enum TemplateType {
57
57
  Page = "page"
58
58
  }
59
59
  export interface StyleTag extends ObjectLiteral {
60
- attributes: Record<string, string>;
60
+ attributes?: Record<string, string>;
61
61
  content?: Style;
62
62
  }
63
63
  export interface ScriptTag extends ObjectLiteral {
64
- attributes: Record<string, string>;
64
+ attributes?: Record<string, string>;
65
65
  content?: string;
66
66
  }
67
67
  export type Stylesheet = string | string[] | StyleTag;
68
68
  export type Script = string | ScriptTag;
69
+ export type MetaTagDefinition = {
70
+ charset?: string;
71
+ viewport?: Record<string, string | number>;
72
+ keywords?: string[];
73
+ author?: {
74
+ name: string;
75
+ url?: string;
76
+ };
77
+ canonical?: string;
78
+ themeColor?: string;
79
+ languageDirection?: 'ltr' | 'rtl';
80
+ [attr: string]: string | number | boolean | undefined | ObjectLiteral | string[];
81
+ };
69
82
  export interface Template {
70
83
  id: string;
71
84
  name: string;
72
85
  route: string;
73
86
  type: TemplateType;
74
87
  extends: string;
88
+ excluded?: boolean;
75
89
  lang: string;
76
90
  title: string;
77
91
  domain: string;
78
92
  description: string;
79
93
  image?: string;
80
- metadata?: Record<string, string>;
94
+ metadata?: MetaTagDefinition[] | ObjectLiteral;
81
95
  scripts?: Script[];
82
96
  stylesheets?: Array<Stylesheet>;
83
97
  links?: Record<string, string>[];
@@ -85,27 +99,49 @@ export interface Template {
85
99
  favicons?: Record<string, string>[];
86
100
  manifest?: string;
87
101
  content?: TemplateContent | string;
102
+ widgetsData?: Record<string, ObjectLiteral>;
103
+ csp?: Record<string, string[]>;
104
+ preload?: Array<{
105
+ href: string;
106
+ as: string;
107
+ type?: string;
108
+ media?: string;
109
+ }>;
110
+ structuredData?: object;
111
+ }
112
+ export interface RenderContentProps extends ObjectLiteral {
113
+ env: {
114
+ id?: string | undefined;
115
+ assetsOrigin: string | undefined;
116
+ prod: boolean | undefined;
117
+ } & ObjectLiteral;
118
+ $msg: (id: string, values?: ObjectLiteral) => string;
119
+ $comp: (compId: string, compData?: ObjectLiteral) => string;
88
120
  }
121
+ export type RenderWidgetContent = (props: RenderContentProps) => string;
89
122
  export interface Widget {
90
123
  id: string;
124
+ type: 'global' | 'local';
91
125
  name: string;
92
126
  cssSelector?: string;
93
127
  scripts?: Script[];
94
128
  style?: Style | ((props?: Record<string, unknown>) => Style);
95
129
  stylesheets?: Array<Stylesheet>;
96
130
  inputs?: InputDefinition<unknown>[];
97
- render?: <P>(props: P) => string;
98
- content?: string;
131
+ render?: RenderWidgetContent;
132
+ content?: TemplateContent | string;
99
133
  }
100
134
  export interface Component {
101
135
  id: string;
102
- stylesheets: Stylesheet[];
103
- content: ContentNode[];
136
+ stylesheets?: Stylesheet[];
137
+ content: TemplateContent | string;
104
138
  }
105
139
  export interface parseOptions {
140
+ useCache?: boolean;
106
141
  prod?: boolean;
107
142
  assetsOrigin?: string;
108
143
  components?: Record<string, Component>;
144
+ locales?: Record<string, ObjectLiteral>;
109
145
  fetchWidget?: (id: string) => Widget | null | Promise<Widget | null>;
110
146
  fetchTemplate?: (id: string) => Template | null | Promise<Template | null>;
111
147
  }
@@ -0,0 +1,2 @@
1
+ import { ObjectLiteral } from '../types.ts';
2
+ export declare function flattenObject(obj: ObjectLiteral, prefix?: string, res?: ObjectLiteral): ObjectLiteral<unknown>;
@@ -1,2 +1,2 @@
1
1
  import { ObjectLiteral, InputDefinition } from '../types.ts';
2
- export declare function inputDefinitionsToObject(inputDefinitions: InputDefinition[]): ObjectLiteral;
2
+ export declare function inputDefinitionsToObject(inputDefinitions: InputDefinition[]): ObjectLiteral<unknown>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@beforesemicolon/site-builder",
3
- "version": "0.30.0",
3
+ "version": "0.33.0",
4
4
  "description": "Site builder based on JSON files",
5
5
  "engines": {
6
6
  "node": ">=18.16.0"
@@ -20,7 +20,6 @@
20
20
  "test:watch": "jest --watch",
21
21
  "docs:watch": "rm -rf website && NODE_ENV=development nodemon --watch docs -e js,css,md,json --exec 'node node_modules/@beforesemicolon/builder/dist/esm/docs/run.js'",
22
22
  "local": "nodemon --watch src -e ts --exec 'npm run build && npm pack && npm link'",
23
- "build:browser": "node ",
24
23
  "build": "rm -rf dist && npm-run-all lint test && tsc --emitDeclarationOnly && tsx ./build.ts && tsx ./build-client.ts",
25
24
  "lint": "eslint ./src && prettier --check .",
26
25
  "format": "eslint ./src --fix && prettier --write ."