0.0.3: Exotic Type Gymnastics #3
|
@ -2,12 +2,12 @@
|
||||||
"name": "laterano",
|
"name": "laterano",
|
||||||
"version": "0.0.1",
|
"version": "0.0.1",
|
||||||
"main": "dist/main.min.js",
|
"main": "dist/main.min.js",
|
||||||
"types": "dist/types.d.ts",
|
"types": "dist/types/main.d.ts",
|
||||||
"module": "dist/main.min.js",
|
"module": "dist/main.min.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "tsc && rollup -c && npm run cleanup-intermediate",
|
"build": "tsc && rollup -c && npm run cleanup-intermediate",
|
||||||
"prepare": "npm run build",
|
"prepare": "npm run build",
|
||||||
"cleanup-intermediate": "rimraf dist/main.js dist/types",
|
"cleanup-intermediate": "rimraf dist/main.js dist/utils",
|
||||||
"quality-check": "biome ci .",
|
"quality-check": "biome ci .",
|
||||||
"qc": "npm run quality-check",
|
"qc": "npm run quality-check",
|
||||||
"lint": "biome format . --write"
|
"lint": "biome format . --write"
|
||||||
|
|
|
@ -5,7 +5,7 @@ import dts from 'rollup-plugin-dts'
|
||||||
|
|
||||||
export default [
|
export default [
|
||||||
{
|
{
|
||||||
input: 'dist/main.js',
|
input: 'src/main.ts',
|
||||||
output: [
|
output: [
|
||||||
{
|
{
|
||||||
file: 'dist/main.min.js',
|
file: 'dist/main.min.js',
|
||||||
|
@ -15,10 +15,20 @@ export default [
|
||||||
],
|
],
|
||||||
plugins: [resolve(), typescript()],
|
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',
|
input: 'dist/types/main.d.ts',
|
||||||
output: {
|
output: {
|
||||||
file: 'dist/types.d.ts',
|
file: 'dist/types/main.d.ts',
|
||||||
format: 'es',
|
format: 'es',
|
||||||
},
|
},
|
||||||
plugins: [dts()],
|
plugins: [dts()],
|
||||||
|
|
21
src/main.ts
21
src/main.ts
|
@ -1,5 +1,26 @@
|
||||||
import utils from './utils/index'
|
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) => {
|
export default (options: ComponentOptions) => {
|
||||||
const {
|
const {
|
||||||
tag,
|
tag,
|
||||||
|
|
29
src/types.d.ts
vendored
29
src/types.d.ts
vendored
|
@ -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 }
|
|
||||||
}
|
|
|
@ -1,5 +1,19 @@
|
||||||
import setupArrowFunctionHandler from './setupArrowFunctionHandler'
|
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(
|
export default function processTemplateMacros(
|
||||||
element: Element,
|
element: Element,
|
||||||
context: CustomElement,
|
context: CustomElement,
|
||||||
|
|
|
@ -35,7 +35,7 @@
|
||||||
// "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
|
// "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. */
|
// "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. */
|
// "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. */
|
// "types": [], /* Specify type package names to be included without being referenced in a source file. */
|
||||||
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
|
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
|
||||||
// "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */
|
// "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */
|
||||||
|
|
Loading…
Reference in New Issue
Block a user