coralite 0.0.0-development

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.
@@ -0,0 +1,26 @@
1
+ import { normalize, sep } from 'path'
2
+
3
+ /**
4
+ * Compare two path names and get the diff from base
5
+ * @param {string} base - Base directory
6
+ * @param {string} path - Path name
7
+ */
8
+ export function getSubDirectory (base, path) {
9
+ // normalize paths to handle different OS path separators
10
+ const normalizedPath1 = normalize(base)
11
+ const normalizedPath2 = normalize(path)
12
+
13
+ // split paths into segments
14
+ const segments1 = normalizedPath1.split(sep)
15
+ const segments2 = normalizedPath2.split(sep)
16
+
17
+ let i = 0
18
+ while (i < segments1.length
19
+ && i < segments2.length
20
+ && segments1[i] === segments2[i]
21
+ ) {
22
+ i++
23
+ }
24
+
25
+ return segments2.slice(i).join(sep)
26
+ }
package/lib/tags.js ADDED
@@ -0,0 +1,145 @@
1
+ export const validTags = {
2
+ a: true,
3
+ abbr: true,
4
+ acronym: true, // Deprecated
5
+ address: true,
6
+ area: true,
7
+ article: true,
8
+ aside: true,
9
+ audio: true,
10
+ b: true,
11
+ base: true,
12
+ bdi: true,
13
+ bdo: true,
14
+ big: true, // Deprecated
15
+ blockquote: true,
16
+ body: true,
17
+ br: true,
18
+ button: true,
19
+ canvas: true,
20
+ caption: true,
21
+ center: true, // Deprecated
22
+ cite: true,
23
+ code: true,
24
+ col: true,
25
+ colgroup: true,
26
+ data: true,
27
+ datalist: true,
28
+ dd: true,
29
+ del: true,
30
+ details: true,
31
+ dfn: true,
32
+ dialog: true,
33
+ dir: true, // Deprecated
34
+ div: true,
35
+ dl: true,
36
+ dt: true,
37
+ em: true,
38
+ embed: true,
39
+ fencedframe: true, // Experimental
40
+ fieldset: true,
41
+ figcaption: true,
42
+ figure: true,
43
+ font: true, // Deprecated
44
+ footer: true,
45
+ form: true,
46
+ frame: true, // Deprecated
47
+ frameset: true, // Deprecated
48
+ h1: true,
49
+ h2: true,
50
+ h3: true,
51
+ h4: true,
52
+ h5: true,
53
+ h6: true,
54
+ head: true,
55
+ header: true,
56
+ hgroup: true,
57
+ hr: true,
58
+ html: true,
59
+ i: true,
60
+ iframe: true,
61
+ img: true,
62
+ input: true,
63
+ ins: true,
64
+ kbd: true,
65
+ label: true,
66
+ legend: true,
67
+ li: true,
68
+ link: true,
69
+ main: true,
70
+ map: true,
71
+ mark: true,
72
+ marquee: true, // Deprecated
73
+ menu: true,
74
+ meta: true,
75
+ meter: true,
76
+ nav: true,
77
+ nobr: true, // Deprecated
78
+ noembed: true, // Deprecated
79
+ noframes: true, // Deprecated
80
+ noscript: true,
81
+ object: true,
82
+ ol: true,
83
+ optgroup: true,
84
+ option: true,
85
+ output: true,
86
+ p: true,
87
+ param: true, // Deprecated
88
+ picture: true,
89
+ plaintext: true, // Deprecated
90
+ portal: true, // Experimental
91
+ pre: true,
92
+ progress: true,
93
+ q: true,
94
+ rb: true, // Deprecated
95
+ rp: true,
96
+ rt: true,
97
+ rtc: true, // Deprecated
98
+ ruby: true,
99
+ s: true,
100
+ samp: true,
101
+ script: true,
102
+ search: true,
103
+ section: true,
104
+ select: true,
105
+ slot: true,
106
+ small: true,
107
+ source: true,
108
+ span: true,
109
+ strike: true, // Deprecated
110
+ strong: true,
111
+ style: true,
112
+ sub: true,
113
+ summary: true,
114
+ sup: true,
115
+ table: true,
116
+ tbody: true,
117
+ td: true,
118
+ template: true,
119
+ textarea: true,
120
+ tfoot: true,
121
+ th: true,
122
+ thead: true,
123
+ time: true,
124
+ title: true,
125
+ tr: true,
126
+ track: true,
127
+ tt: true, // Deprecated
128
+ u: true,
129
+ ul: true,
130
+ var: true,
131
+ video: true,
132
+ wbr: true,
133
+ xmp: true
134
+ }
135
+
136
+ export const invalidCustomTags = {
137
+ 'annotation-xml': true,
138
+ 'color-profile': true,
139
+ 'font-face': true,
140
+ 'font-face-src': true,
141
+ 'font-face-uri': true,
142
+ 'font-face-format': true,
143
+ 'font-face-name': true,
144
+ 'missing-glyph': true
145
+ }
package/package.json ADDED
@@ -0,0 +1,62 @@
1
+ {
2
+ "name": "coralite",
3
+ "version": "0.0.0-development",
4
+ "description": "HTML modules static site generator",
5
+ "main": "./lib/coralite.js",
6
+ "type": "module",
7
+ "keywords": [
8
+ "static-site-generator",
9
+ "components",
10
+ "templates",
11
+ "coralite",
12
+ "blog",
13
+ "site-engine",
14
+ "documentation-tool"
15
+ ],
16
+ "homepage": "https://coralite.io",
17
+ "author": {
18
+ "name": "Thomas David",
19
+ "url": "https://thomasjackdavid.com"
20
+ },
21
+ "repository": {
22
+ "type": "git",
23
+ "url": "https://github.com/tjdav/coralite.git"
24
+ },
25
+ "license": "MPL-2.0",
26
+ "scripts": {
27
+ "commitmsg": "commitlint -e",
28
+ "format": "eslint --cache --fix .",
29
+ "lint": "eslint --cache .",
30
+ "test-unit": "node --test test/lib/*",
31
+ "semantic-release": "semantic-release"
32
+ },
33
+ "bin": "bin/coralite.js",
34
+ "imports": {
35
+ "#lib": "./lib/index.js",
36
+ "#types": "./types/index.js"
37
+ },
38
+ "exports": {
39
+ "default": "./lib/coralite.js",
40
+ "types": "./types/index.js"
41
+ },
42
+ "devDependencies": {
43
+ "@commitlint/cli": "^19.6.1",
44
+ "@commitlint/config-conventional": "^19.6.0",
45
+ "@semantic-release/git": "^10.0.1",
46
+ "@semantic-release/github": "^11.0.1",
47
+ "@stylistic/eslint-plugin-js": "^2.12.1",
48
+ "@stylistic/eslint-plugin-plus": "^2.12.1",
49
+ "@types/node": "^22.10.5",
50
+ "semantic-release": "^24.2.1"
51
+ },
52
+ "engines": {
53
+ "node": ">=18"
54
+ },
55
+ "dependencies": {
56
+ "acorn": "^8.14.0",
57
+ "commander": "^13.0.0",
58
+ "dom-serializer": "^2.0.0",
59
+ "eval-estree-expression": "^2.0.3",
60
+ "htmlparser2": "^10.0.0"
61
+ }
62
+ }
@@ -0,0 +1,11 @@
1
+ export default {
2
+ branches: ['main'],
3
+ plugins: [
4
+ '@semantic-release/commit-analyzer',
5
+ '@semantic-release/release-notes-generator',
6
+ ['@semantic-release/git', {
7
+ message: 'chore(release): ${nextRelease.version] [skip ci]\n\n${nextRelease.notes}'
8
+ }],
9
+ '@semantic-release/github'
10
+ ]
11
+ }
package/types/index.js ADDED
@@ -0,0 +1,110 @@
1
+ /**
2
+ * @typedef {Object} HTMLData
3
+ * @property {string} parentPath - Path to the directory containing this file (e.g., '../my-component').
4
+ * @property {string} name - The file's name without extension (e.g., 'my-component').
5
+ * @property {string} content - The raw HTML string contents of the file.
6
+ */
7
+
8
+ /**
9
+ * Represents the paths to Coralite pages and components within a project.
10
+ * @typedef {Object} CoralitePath
11
+ * @property {string} pages - The path to the root pages directory
12
+ * @property {string} components - The path to the root components directory
13
+ */
14
+
15
+ /**
16
+ * @typedef {Object} CoraliteTokenOptions
17
+ * @property {Object.<string, string>} [default] - Default token values for properties not explicitly set
18
+ * @property {Object.<string, string[]>} [aliases] - Token aliases and their possible values
19
+ */
20
+
21
+
22
+ /**
23
+ * @typedef {Object} CoraliteModule
24
+ * @property {string} id - Unique module identifier
25
+ * @property {CoraliteElement} template - Module's rendering template
26
+ * @property {string|undefined} script - Module's JavaScript raw code
27
+ * @property {CoraliteDocumentTokens} tokens - Tokens generated from the module's markup
28
+ * @property {CoraliteElement[]} customElements - Custom elements defined in the module
29
+ * @property {Object.<string, Object.<string,CoraliteModuleSlotElement>>} slotElements - Custom slot elements and their configurations
30
+ */
31
+
32
+ /**
33
+ * @typedef {Object} CoraliteDocumentTokens
34
+ * @property {CoraliteAttributeToken[]} attributes - Array of attribute tokens from the document
35
+ * @property {CoraliteTextNodeToken[]} textNodes - Array of text node tokens from the document
36
+ */
37
+
38
+ /**
39
+ * @typedef {Object} CoraliteToken
40
+ * @property {string} name - Token identifier
41
+ * @property {string} content - Token value or content
42
+ */
43
+
44
+ /**
45
+ * @typedef {Object} CoraliteAttributeToken
46
+ * @property {string} name - Attribute token identifier
47
+ * @property {CoraliteElement} element - Corresponding HTML element for the attribute
48
+ * @property {CoraliteToken[]} tokens - Array of associated tokens
49
+ */
50
+
51
+ /**
52
+ * @typedef {Object} CoraliteTextNodeToken
53
+ * @property {'text'} type - Type of text node ('text')
54
+ * @property {string} data - Text node raw data
55
+ * @property {CoraliteElement} parent - Parent element of the text node
56
+ */
57
+
58
+ /**
59
+ * @typedef {Object} CoraliteModuleSlotElement
60
+ * @property {string} name - Slot element identifier
61
+ * @property {CoraliteElement} element - Corresponding HTML element for the slot
62
+ */
63
+
64
+ /**
65
+ * @typedef {Object} CoraliteElement
66
+ * @property {'tag'} type - Element type
67
+ * @property {string} name - Tag name
68
+ * @property {Object.<string, string>} attribs - Element attributes
69
+ * @property {(CoraliteElement | CoraliteTextNode)[]} children - Child nodes of the element
70
+ * @property {CoraliteElement} parent - Parent element
71
+ * @property {number} [parentChildIndex] - Position in parent's child list
72
+ */
73
+
74
+
75
+ /**
76
+ * @typedef {Object} CoraliteTextNode
77
+ * @property {'text'} type - Text node type
78
+ * @property {string} data - Additional attributes for the text node
79
+ * @property {CoraliteElement} parent - Parent element of the text node
80
+ */
81
+
82
+ /**
83
+ * @typedef {Object} CoraliteSlotElement
84
+ * @property {string} name - Slot's unique identifier
85
+ * @property {CoraliteElement} customElement - Custom component for the slot
86
+ * @property {CoraliteElement} element - Corresponding HTML element for the slot
87
+ */
88
+
89
+ /**
90
+ * @typedef {Object} CoraliteDirective
91
+ * @property {'directive'} type - Node type
92
+ * @property {string} data - Raw HTML Doctype
93
+ * @property {string} name - Doctype name
94
+ */
95
+
96
+ /**
97
+ * @typedef {Object} CoraliteDocumentRoot
98
+ * @property {'root'} type - Node type
99
+ * @property {(CoraliteDirective | CoraliteElement | CoraliteTextNode)[]} children - Document list
100
+ */
101
+
102
+ /**
103
+ * @typedef {Object} CoraliteDocument
104
+ * @property {string} name - Document file name
105
+ * @property {string} parentPath - Parent file path
106
+ * @property {CoraliteDocumentRoot} root - Array of elements and text nodes in the document
107
+ * @property {CoraliteElement[]} customElements - Custom elements defined in the document
108
+ * @property {Object.<string, CoraliteSlotElement[]>} customElementSlots - Slots with their respective elements
109
+ * @property {CoralitePath} path - Document's file path
110
+ */