@newlogic-digital/core 2.1.2 → 3.0.0-next.1
Sign up to get free protection for your applications and to get access to all the features.
- package/index.js +34 -20
- package/package.json +12 -11
- package/src/prism.js +10 -10
- package/types/index.d.ts +2 -1
package/index.js
CHANGED
@@ -41,7 +41,7 @@ const posthtmlPrism = {
|
|
41
41
|
|
42
42
|
const postcssImportSupports = {
|
43
43
|
name: 'postcss-import-supports',
|
44
|
-
transform
|
44
|
+
transform(code, path) {
|
45
45
|
if (path.endsWith('.css')) {
|
46
46
|
return {
|
47
47
|
code: code.replace('@media supports', '@supports')
|
@@ -57,33 +57,39 @@ const defaultOptions = {
|
|
57
57
|
mode: null,
|
58
58
|
cert: 'localhost',
|
59
59
|
format: ['latte'],
|
60
|
+
manualChunks: {},
|
60
61
|
emails: {
|
61
62
|
outputDir: resolve(process.cwd(), 'public/email'),
|
62
63
|
appDir: resolve(process.cwd(), 'app/Templates/Emails')
|
63
64
|
},
|
64
65
|
vituum: {
|
65
66
|
pages: {
|
66
|
-
dir: './src/
|
67
|
+
dir: './src/pages'
|
67
68
|
}
|
68
69
|
},
|
69
70
|
posthtml: {
|
70
71
|
root: resolve(process.cwd(), 'src')
|
71
72
|
},
|
72
73
|
juice: {
|
73
|
-
paths: ['src/
|
74
|
+
paths: ['src/pages/email'],
|
75
|
+
postcss: {
|
76
|
+
globalData: {
|
77
|
+
files: ['./src/emails/styles/main/base/config.css']
|
78
|
+
}
|
79
|
+
}
|
74
80
|
},
|
75
81
|
tailwindcss: {},
|
76
82
|
send: {},
|
77
83
|
latte: {
|
78
|
-
renderTransformedHtml:
|
84
|
+
renderTransformedHtml: filename => dirname(filename).endsWith('email'),
|
79
85
|
globals: {
|
80
86
|
srcPath: resolve(process.cwd(), 'src'),
|
81
87
|
templatesPath: resolve(process.cwd(), 'src/templates'),
|
82
|
-
template: './src/templates/
|
88
|
+
template: './src/templates/layouts/default.latte'
|
83
89
|
},
|
84
90
|
functions: {
|
85
91
|
pages: () => {
|
86
|
-
return fs.readdirSync(resolve(process.cwd(), 'src/
|
92
|
+
return fs.readdirSync(resolve(process.cwd(), 'src/pages')).filter(file => fs.statSync(resolve(process.cwd(), 'src/pages/' + file)).isFile())
|
87
93
|
}
|
88
94
|
},
|
89
95
|
filters: {
|
@@ -126,10 +132,10 @@ const plugin = (options = {}) => {
|
|
126
132
|
return [{
|
127
133
|
name,
|
128
134
|
enforce: 'pre',
|
129
|
-
config
|
130
|
-
const isHttps = userConfig?.server?.https !== false
|
131
|
-
fs.existsSync(join(os.homedir(), `.ssh/${options.cert}.pem`))
|
132
|
-
fs.existsSync(join(os.homedir(), `.ssh/${options.cert}-key.pem`))
|
135
|
+
config(userConfig, userEnv) {
|
136
|
+
const isHttps = userConfig?.server?.https !== false
|
137
|
+
&& fs.existsSync(join(os.homedir(), `.ssh/${options.cert}.pem`))
|
138
|
+
&& fs.existsSync(join(os.homedir(), `.ssh/${options.cert}-key.pem`))
|
133
139
|
|
134
140
|
let defaultInput = [
|
135
141
|
'./src/styles/*.{css,pcss,scss,sass,less,styl,stylus}',
|
@@ -142,8 +148,8 @@ const plugin = (options = {}) => {
|
|
142
148
|
|
143
149
|
if (options.mode === 'development') {
|
144
150
|
defaultInput = [
|
145
|
-
'./src/
|
146
|
-
'!./src/
|
151
|
+
'./src/pages/**/*.{json,latte,twig,liquid,njk,hbs,pug,html}',
|
152
|
+
'!./src/pages/**/*.{latte,twig,liquid,njk,hbs,pug,html}.json',
|
147
153
|
'./src/styles/*.{css,pcss,scss,sass,less,styl,stylus}',
|
148
154
|
'./src/scripts/*.{js,ts,mjs}'
|
149
155
|
]
|
@@ -157,8 +163,8 @@ const plugin = (options = {}) => {
|
|
157
163
|
userEnv.mode = 'production'
|
158
164
|
|
159
165
|
defaultInput = [
|
160
|
-
'./src/
|
161
|
-
'!./src/
|
166
|
+
'./src/pages/email/**/*.{json,latte,twig,liquid,njk,hbs,pug,html}',
|
167
|
+
'!./src/pages/email/**/*.{latte,twig,liquid,njk,hbs,pug,html}.json'
|
162
168
|
]
|
163
169
|
}
|
164
170
|
|
@@ -173,7 +179,7 @@ const plugin = (options = {}) => {
|
|
173
179
|
}, userConfig.optimizeDeps ?? {})
|
174
180
|
|
175
181
|
userConfig.build = Object.assign({
|
176
|
-
target: ['
|
182
|
+
target: ['edge111', 'firefox111', 'chrome111', 'safari16'],
|
177
183
|
manifest: 'manifest.json',
|
178
184
|
emptyOutDir: false,
|
179
185
|
modulePreload: false,
|
@@ -182,7 +188,15 @@ const plugin = (options = {}) => {
|
|
182
188
|
}, userConfig.build ?? {})
|
183
189
|
|
184
190
|
userConfig.build.rollupOptions = Object.assign({
|
185
|
-
input: defaultInput
|
191
|
+
input: defaultInput,
|
192
|
+
output: {
|
193
|
+
manualChunks: {
|
194
|
+
swup: ['swup'],
|
195
|
+
stimulus: ['@hotwired/stimulus'],
|
196
|
+
naja: ['naja'],
|
197
|
+
...options.manualChunks
|
198
|
+
}
|
199
|
+
}
|
186
200
|
}, userConfig.build.rollupOptions ?? {})
|
187
201
|
|
188
202
|
userConfig.server = Object.assign({
|
@@ -192,16 +206,16 @@ const plugin = (options = {}) => {
|
|
192
206
|
},
|
193
207
|
https: isHttps
|
194
208
|
? {
|
195
|
-
|
196
|
-
|
197
|
-
|
209
|
+
key: fs.readFileSync(join(os.homedir(), `.ssh/${options.cert}-key.pem`)),
|
210
|
+
cert: fs.readFileSync(join(os.homedir(), `.ssh/${options.cert}.pem`))
|
211
|
+
}
|
198
212
|
: false
|
199
213
|
}, userConfig.server ?? {})
|
200
214
|
},
|
201
215
|
writeBundle: async () => {
|
202
216
|
if (options.mode === 'emails') {
|
203
217
|
const emails = FastGlob.sync(`${resolve(process.cwd(), options.emails.outputDir)}/**`).filter(entry => !entry.endsWith('test.html'))
|
204
|
-
const emailsProd = emails.map(path => {
|
218
|
+
const emailsProd = emails.map((path) => {
|
205
219
|
return path.replace(resolve(process.cwd(), options.emails.outputDir), resolve(process.cwd(), options.emails.appDir)).replace('.html', '.latte')
|
206
220
|
})
|
207
221
|
|
package/package.json
CHANGED
@@ -1,38 +1,39 @@
|
|
1
1
|
{
|
2
2
|
"name": "@newlogic-digital/core",
|
3
3
|
"type": "module",
|
4
|
-
"version": "
|
4
|
+
"version": "3.0.0-next.1",
|
5
5
|
"main": "index.js",
|
6
6
|
"author": "New Logic Studio s.r.o.",
|
7
7
|
"description": "Set of tools that can be used to create modern web applications",
|
8
8
|
"license": "MIT",
|
9
9
|
"scripts": {
|
10
10
|
"tsc": "tsc",
|
11
|
-
"eslint": "eslint '**/*.js' --fix"
|
11
|
+
"eslint": "eslint '**/*.js' --fix",
|
12
|
+
"publish-next": "npm publish --tag next"
|
12
13
|
},
|
13
14
|
"dependencies": {
|
14
15
|
"@vituum/vite-plugin-posthtml": "^1.1.0",
|
15
16
|
"@vituum/vite-plugin-juice": "^1.2.0",
|
16
|
-
"@vituum/vite-plugin-latte": "^1.1
|
17
|
+
"@vituum/vite-plugin-latte": "^1.2.1",
|
17
18
|
"@vituum/vite-plugin-twig": "^1.1.0",
|
18
19
|
"@vituum/vite-plugin-tailwindcss": "^1.1.0",
|
19
20
|
"@vituum/vite-plugin-send": "^1.1.0",
|
20
|
-
"vituum": "^1.1.
|
21
|
+
"vituum": "^1.1.1",
|
21
22
|
"posthtml": "^0.16.6",
|
22
|
-
"posthtml-prism": "^2.0.
|
23
|
+
"posthtml-prism": "^2.0.1",
|
23
24
|
"prismjs": "^1.29.0",
|
24
25
|
"html-minifier-terser": "^7.2.0",
|
25
26
|
"lodash": "^4.17.21",
|
26
27
|
"fast-glob": "^3.3.2",
|
27
28
|
"fs-extra": "^11.2.0",
|
28
|
-
"picocolors": "^1.0.
|
29
|
+
"picocolors": "^1.0.1"
|
29
30
|
},
|
30
31
|
"devDependencies": {
|
31
|
-
"@types/node": "^
|
32
|
-
"eslint": "^
|
33
|
-
"
|
34
|
-
"typescript": "^5.
|
35
|
-
"vite": "^5.
|
32
|
+
"@types/node": "^22.2.0",
|
33
|
+
"eslint": "^9.9.0",
|
34
|
+
"neostandard": "^0.11.2",
|
35
|
+
"typescript": "^5.5.4",
|
36
|
+
"vite": "^5.4.0"
|
36
37
|
},
|
37
38
|
"files": [
|
38
39
|
"latte",
|
package/src/prism.js
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
import Prism from 'prismjs'
|
2
|
-
import {render} from 'posthtml-render'
|
2
|
+
import { render } from 'posthtml-render'
|
3
3
|
import loadLanguages from 'prismjs/components/index.js'
|
4
4
|
import NormalizeWhitespace from 'prismjs/plugins/normalize-whitespace/prism-normalize-whitespace.js'
|
5
5
|
|
@@ -7,22 +7,22 @@ const Normalize = new NormalizeWhitespace({
|
|
7
7
|
'remove-trailing': true,
|
8
8
|
'remove-indent': true,
|
9
9
|
'left-trim': true,
|
10
|
-
'right-trim': true
|
11
|
-
})
|
10
|
+
'right-trim': true
|
11
|
+
})
|
12
12
|
|
13
|
-
const createPrismPlugin = options => {
|
14
|
-
return tree => {
|
15
|
-
const highlightCodeTags = node => tree.match.call(node, {tag: 'code'}, highlightNode)
|
13
|
+
const createPrismPlugin = (options) => {
|
14
|
+
return (tree) => {
|
15
|
+
const highlightCodeTags = node => tree.match.call(node, { tag: 'code' }, highlightNode)
|
16
16
|
|
17
17
|
if (options.inline) {
|
18
18
|
highlightCodeTags(tree)
|
19
19
|
} else {
|
20
|
-
tree.match({tag: 'pre'}, highlightCodeTags)
|
20
|
+
tree.match({ tag: 'pre' }, highlightCodeTags)
|
21
21
|
}
|
22
22
|
}
|
23
23
|
}
|
24
24
|
|
25
|
-
const highlightNode = node => {
|
25
|
+
const highlightNode = (node) => {
|
26
26
|
const attrs = node.attrs || {}
|
27
27
|
const classList = `${attrs.class || ''}`.trimStart()
|
28
28
|
|
@@ -74,13 +74,13 @@ const mapStringOrNode = (stringOrNode, lang = null) => {
|
|
74
74
|
return stringOrNode
|
75
75
|
}
|
76
76
|
|
77
|
-
const getExplicitLanguage = classList => {
|
77
|
+
const getExplicitLanguage = (classList) => {
|
78
78
|
const matches = classList.match(/(?:lang|language)-(\w*)/)
|
79
79
|
|
80
80
|
return matches === null ? null : matches[1]
|
81
81
|
}
|
82
82
|
|
83
|
-
const plugin = options => {
|
83
|
+
const plugin = (options) => {
|
84
84
|
options = options || {}
|
85
85
|
options.inline = options.inline || false
|
86
86
|
|
package/types/index.d.ts
CHANGED
@@ -7,8 +7,9 @@ export interface PluginUserConfig {
|
|
7
7
|
mode?: 'development' | 'production' | 'emails'
|
8
8
|
format?: string[]
|
9
9
|
cert?: string
|
10
|
+
manualChunks?: import('rollup').ManualChunksOption
|
10
11
|
emails?: Emails
|
11
|
-
vituum?: import('vituum
|
12
|
+
vituum?: import('vituum').UserConfig,
|
12
13
|
posthtml?: import('@vituum/vite-plugin-posthtml/types').PluginUserConfig
|
13
14
|
juice?: import('@vituum/vite-plugin-juice/types').PluginUserConfig
|
14
15
|
send?: import('@vituum/vite-plugin-send/types').PluginUserConfig
|