fix: rollup compress the utils folder
Some checks failed
Quality Check & Publish / quality (push) Failing after 22s
Quality Check & Publish / quality-failed-webhook (push) Has been skipped
Quality Check & Publish / publish (push) Has been skipped
Quality Check & Publish / publish-failed-webhook (push) Has been skipped

This commit is contained in:
Astrian Zheng 2025-05-21 22:12:32 +10:00
parent 9b1ce3faca
commit 5f3b4395ab
Signed by: Astrian
SSH Key Fingerprint: SHA256:rVnhx3DAKjujCwWE13aDl7uV6+9U1MvydLkNRXJrBiA
6 changed files with 50 additions and 34 deletions

View File

@ -2,12 +2,12 @@
"name": "laterano",
"version": "0.0.1",
"main": "dist/main.min.js",
"types": "dist/types.d.ts",
"types": "dist/types/main.d.ts",
"module": "dist/main.min.js",
"scripts": {
"build": "tsc && rollup -c && npm run cleanup-intermediate",
"prepare": "npm run build",
"cleanup-intermediate": "rimraf dist/main.js dist/types",
"cleanup-intermediate": "rimraf dist/main.js dist/utils",
"quality-check": "biome ci .",
"qc": "npm run quality-check",
"lint": "biome format . --write"

View File

@ -5,7 +5,7 @@ import dts from 'rollup-plugin-dts'
export default [
{
input: 'dist/main.js',
input: 'src/main.ts',
output: [
{
file: 'dist/main.min.js',
@ -15,10 +15,20 @@ export default [
],
plugins: [resolve(), typescript()],
},
{
input: 'dist/utils/index.js',
output: {
file: 'dist/utils.bundle.min.js',
format: 'esm',
inlineDynamicImports: true,
plugins: [terser()],
},
plugins: [resolve(), typescript({ outDir: 'dist' })],
},
{
input: 'dist/types/main.d.ts',
output: {
file: 'dist/types.d.ts',
file: 'dist/types/main.d.ts',
format: 'es',
},
plugins: [dts()],

View File

@ -1,5 +1,26 @@
import utils from './utils/index'
interface ComponentOptions {
tag: string
template: string
style?: string
onMount?: (this: CustomElement) => void
onUnmount?: () => void
onAttributeChanged?: (
attrName: string,
oldValue: string,
newValue: string,
) => void
states?: Record<string, unknown>
statesListeners?: { [key: string]: (value: unknown) => void }
funcs?: { [key: string]: (...args: unknown[]) => void }
}
interface CustomElement extends HTMLElement {
setState(key_path: string, value: unknown): void
getState(key_path: string): unknown
}
export default (options: ComponentOptions) => {
const {
tag,

29
src/types.d.ts vendored
View File

@ -1,29 +0,0 @@
interface CustomElement extends HTMLElement {
setState(key_path: string, value: unknown): void
getState(key_path: string): unknown
}
interface ListRenderingContext {
states: Record<string, unknown>
stateToElementsMap: Record<string, Set<HTMLElement>>
statesListeners: Record<string, (value: unknown) => void>
setState: (keyPath: string, value: unknown) => void
getState: (keyPath: string) => unknown
triggerFunc: (eventName: string, ...args: unknown[]) => void
}
interface ComponentOptions {
tag: string
template: string
style?: string
onMount?: (this: CustomElement) => void
onUnmount?: () => void
onAttributeChanged?: (
attrName: string,
oldValue: string,
newValue: string,
) => void
states?: Record<string, unknown>
statesListeners?: { [key: string]: (value: unknown) => void }
funcs?: { [key: string]: (...args: unknown[]) => void }
}

View File

@ -1,5 +1,19 @@
import setupArrowFunctionHandler from './setupArrowFunctionHandler'
interface CustomElement extends HTMLElement {
setState(key_path: string, value: unknown): void
getState(key_path: string): unknown
}
interface ListRenderingContext {
states: Record<string, unknown>
stateToElementsMap: Record<string, Set<HTMLElement>>
statesListeners: Record<string, (value: unknown) => void>
setState: (keyPath: string, value: unknown) => void
getState: (keyPath: string) => unknown
triggerFunc: (eventName: string, ...args: unknown[]) => void
}
export default function processTemplateMacros(
element: Element,
context: CustomElement,

View File

@ -35,7 +35,7 @@
// "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
// "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
// "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
// "typeRoots": ["./src/types"], /* Specify multiple folders that act like './node_modules/@types'. */
"typeRoots": ["./src/types"], /* Specify multiple folders that act like './node_modules/@types'. */
// "types": [], /* Specify type package names to be included without being referenced in a source file. */
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
// "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */