@beforesemicolon/site-builder 0.32.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,6 +99,15 @@ 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;
88
111
  }
89
112
  export interface RenderContentProps extends ObjectLiteral {
90
113
  env: {
@@ -92,11 +115,13 @@ export interface RenderContentProps extends ObjectLiteral {
92
115
  assetsOrigin: string | undefined;
93
116
  prod: boolean | undefined;
94
117
  } & ObjectLiteral;
118
+ $msg: (id: string, values?: ObjectLiteral) => string;
95
119
  $comp: (compId: string, compData?: ObjectLiteral) => string;
96
120
  }
97
121
  export type RenderWidgetContent = (props: RenderContentProps) => string;
98
122
  export interface Widget {
99
123
  id: string;
124
+ type: 'global' | 'local';
100
125
  name: string;
101
126
  cssSelector?: string;
102
127
  scripts?: Script[];
@@ -104,17 +129,19 @@ export interface Widget {
104
129
  stylesheets?: Array<Stylesheet>;
105
130
  inputs?: InputDefinition<unknown>[];
106
131
  render?: RenderWidgetContent;
107
- content?: string;
132
+ content?: TemplateContent | string;
108
133
  }
109
134
  export interface Component {
110
135
  id: string;
111
- stylesheets: Stylesheet[];
112
- content: ContentNode[];
136
+ stylesheets?: Stylesheet[];
137
+ content: TemplateContent | string;
113
138
  }
114
139
  export interface parseOptions {
140
+ useCache?: boolean;
115
141
  prod?: boolean;
116
142
  assetsOrigin?: string;
117
143
  components?: Record<string, Component>;
144
+ locales?: Record<string, ObjectLiteral>;
118
145
  fetchWidget?: (id: string) => Widget | null | Promise<Widget | null>;
119
146
  fetchTemplate?: (id: string) => Template | null | Promise<Template | null>;
120
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.32.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 ."