mirror of
https://github.com/bigskysoftware/htmx.git
synced 2026-04-18 03:55:10 +00:00
start re-implementing scroll & show, still needs focus
website now uses real preload extension!
This commit is contained in:
@@ -1,38 +0,0 @@
|
||||
#!/bin/bash
|
||||
# This script is intended to be run from npm, via `npm run dist`
|
||||
set -euo pipefail
|
||||
|
||||
HTMX_SRC="src/htmx.js"
|
||||
|
||||
# Clean the dist directory
|
||||
rm -rf dist/*.js dist/*.ts dist/*.gz
|
||||
|
||||
# Regular IIFE script
|
||||
cp $HTMX_SRC dist/htmx.js
|
||||
|
||||
# Generate minified script
|
||||
uglifyjs -m eval -o dist/htmx.min.js dist/htmx.js
|
||||
|
||||
# Generate gzipped script
|
||||
gzip -9 -k -f dist/htmx.min.js > dist/htmx.min.js.gz
|
||||
|
||||
# Generate AMD script
|
||||
cat > dist/htmx.amd.js << EOF
|
||||
define(() => {
|
||||
$(cat $HTMX_SRC)
|
||||
return htmx
|
||||
})
|
||||
EOF
|
||||
|
||||
# Generate CJS script
|
||||
cat > dist/htmx.cjs.js << EOF
|
||||
$(cat $HTMX_SRC)
|
||||
module.exports = htmx;
|
||||
EOF
|
||||
|
||||
# Generate ESM script
|
||||
cat > dist/htmx.esm.js << EOF
|
||||
$(cat $HTMX_SRC)
|
||||
export default htmx
|
||||
EOF
|
||||
|
||||
@@ -1,145 +0,0 @@
|
||||
import fs from 'fs'
|
||||
|
||||
const classes = []
|
||||
const attributes = []
|
||||
const events = []
|
||||
|
||||
const rootPath = fs.existsSync('./www') ? './' : '../'
|
||||
|
||||
for (const file of fs.readdirSync(rootPath + 'www/content/attributes').sort()) {
|
||||
if (file.startsWith('hx-') && file.endsWith('.md')) {
|
||||
const name = file.slice(0, -3)
|
||||
const info = readAttributeInfo(name, rootPath + 'www/content/attributes/' + file)
|
||||
attributes.push({
|
||||
name,
|
||||
...info,
|
||||
'doc-url': 'https://htmx.org/attributes/' + name + '/'
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
readClassInfo()
|
||||
readEventInfo()
|
||||
|
||||
const pkg = JSON.parse(fs.readFileSync(rootPath + 'package.json', { encoding: 'utf8' }))
|
||||
|
||||
const webTypes = {
|
||||
$schema: 'https://json.schemastore.org/web-types',
|
||||
name: 'htmx',
|
||||
version: pkg.version,
|
||||
'default-icon': './htmx.svg',
|
||||
'js-types-syntax': 'typescript',
|
||||
'description-markup': 'markdown',
|
||||
contributions: {
|
||||
html: {
|
||||
attributes
|
||||
},
|
||||
css: {
|
||||
classes
|
||||
},
|
||||
js: {
|
||||
events: [
|
||||
{
|
||||
name: 'HTMX event',
|
||||
pattern: {
|
||||
items: ['/js/htmx-events'],
|
||||
template: ['htmx:', '$...', '#item:HTMX event']
|
||||
}
|
||||
}
|
||||
],
|
||||
'htmx-events': events
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fs.writeFileSync(rootPath + 'editors/jetbrains/htmx.web-types.json', JSON.stringify(webTypes, null, 2))
|
||||
|
||||
function readAttributeInfo(name, file) {
|
||||
const content = fs.readFileSync(file, { encoding: 'utf8' })
|
||||
|
||||
const isInherited = content.indexOf('`' + name + '` is inherited') !== -1
|
||||
const isNotInherited = content.indexOf('`' + name + '` is not inherited') !== -1
|
||||
|
||||
const deprecated = content.indexOf('`' + name + '` has been deprecated') !== -1
|
||||
|
||||
const sections = {}
|
||||
|
||||
if (isInherited) {
|
||||
sections.Inherited = ''
|
||||
} else if (isNotInherited) {
|
||||
sections['Not Inherited'] = ''
|
||||
}
|
||||
|
||||
const descSections = /\+\+\+\n(?:[^\n]*\n)+\+\+\+\n\n((?:[^\n]+\n)+)(?:\n((?:[^\n]+\n)+))?(?:\n((?:[^\n]+\n)+))?/mg.exec(content)
|
||||
const para1 = descSections[1].trim()
|
||||
const para2 = descSections[2]?.trim()
|
||||
const para3 = descSections[3]?.trim()
|
||||
|
||||
let description = para1
|
||||
if (para2) {
|
||||
description += '\n\n' + para2
|
||||
}
|
||||
if (para2 && para2.endsWith(':') && para3) {
|
||||
description += '\n\n' + para3
|
||||
}
|
||||
|
||||
let pattern
|
||||
if (name === 'hx-on') {
|
||||
pattern = {
|
||||
or: [
|
||||
{
|
||||
items: ['/js/events'],
|
||||
template: ['hx-on:', '#...', '#item:JS event']
|
||||
},
|
||||
{
|
||||
items: ['/js/htmx-events'],
|
||||
template: ['hx-on::', '#...', '#item:HTMX event']
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
pattern,
|
||||
description,
|
||||
'description-sections': sections,
|
||||
deprecated: deprecated ? true : undefined
|
||||
}
|
||||
}
|
||||
|
||||
function readClassInfo() {
|
||||
const content = fs.readFileSync(rootPath + 'www/content/reference.md', { encoding: 'utf8' })
|
||||
const start = content.indexOf('| Class | Description |')
|
||||
const cssTable = content.slice(start, content.indexOf('</div>', start))
|
||||
const expr = /\| `([^`]+)` \| ([^\n]+)/mg
|
||||
let match = expr.exec(cssTable)
|
||||
while (match) {
|
||||
const name = match[1]
|
||||
if (name && name.startsWith('htmx-')) {
|
||||
classes.push({
|
||||
name,
|
||||
description: match[2].trim(),
|
||||
'doc-url': 'https://htmx.org/reference/#classes'
|
||||
})
|
||||
}
|
||||
match = expr.exec(cssTable)
|
||||
}
|
||||
}
|
||||
|
||||
function readEventInfo() {
|
||||
const content = fs.readFileSync(rootPath + 'www/content/events.md', { encoding: 'utf8' })
|
||||
const expr = /### Event - `([^`]+)`[^\n]*\n+((?:(?:[^#\n]|#####)[^\n]*\n+)+)/mg
|
||||
let match = expr.exec(content)
|
||||
while (match) {
|
||||
let name = match[1]
|
||||
if (name && name.startsWith('htmx:')) {
|
||||
name = name.slice(5)
|
||||
events.push({
|
||||
name,
|
||||
description: match[2],
|
||||
'doc-url': 'https://htmx.org/events/#htmx:' + name
|
||||
})
|
||||
}
|
||||
match = expr.exec(content)
|
||||
}
|
||||
}
|
||||
@@ -1,20 +1,11 @@
|
||||
#!/bin/bash
|
||||
set -euo pipefail
|
||||
|
||||
STATIC_ROOT="www/static"
|
||||
PACKAGE_VERSION=$(cat package.json | grep version | cut -d '"' -f 4)
|
||||
|
||||
|
||||
cp node_modules/mocha/mocha.js "$STATIC_ROOT/node_modules/mocha/mocha.js"
|
||||
cp node_modules/mocha/mocha.css "$STATIC_ROOT/node_modules/mocha/mocha.css"
|
||||
cp node_modules/chai/chai.js "$STATIC_ROOT/node_modules/chai/chai.js"
|
||||
cp node_modules/chai-dom/chai-dom.js "$STATIC_ROOT/node_modules/chai-dom/chai-dom.js"
|
||||
cp node_modules/sinon/pkg/sinon.js "$STATIC_ROOT/node_modules/sinon/pkg/sinon.js"
|
||||
cp node_modules/mock-socket/dist/mock-socket.js "$STATIC_ROOT/node_modules/mock-socket/dist/mock-socket.js"
|
||||
|
||||
rm -rf "$STATIC_ROOT/test" "$STATIC_ROOT/src"
|
||||
cp -r "./test" "$STATIC_ROOT/test"
|
||||
cp -r "./src" "$STATIC_ROOT/src"
|
||||
|
||||
# copy the current htmx to the main website
|
||||
cp "src/htmx.js" "www/themes/htmx-theme/static/js/htmx.js"
|
||||
cp -r ./dist/* "$STATIC_ROOT/js"
|
||||
Reference in New Issue
Block a user