jails-js 5.0.0-beta.9 → 5.0.0
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.
- package/.editorconfig +2 -0
- package/README.md +114 -48
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/logo.svg +29 -0
- package/package.json +6 -5
- package/src/component.ts +44 -56
- package/src/element.ts +23 -6
- package/src/index.ts +9 -8
- package/src/template-system.ts +19 -22
- package/src/utils/events.ts +1 -1
- package/src/utils/index.ts +34 -12
- package/src/utils/pubsub.ts +5 -10
- package/tsconfig.json +103 -13
- package/types/component.d.ts +32 -0
- package/types/element.d.ts +311 -0
- package/types/index.d.ts +5 -0
- package/types/index.ts +41 -0
- package/types/template-system.d.ts +1 -0
- package/types/utils/events.d.ts +3 -0
- package/types/utils/index.d.ts +8 -0
- package/types/utils/pubsub.d.ts +2 -0
- package/webpack.config.js +13 -13
- package/dist/jails.js +0 -2
- package/dist/jails.js.map +0 -1
package/src/component.ts
CHANGED
@@ -2,31 +2,25 @@ import morphdom from 'morphdom'
|
|
2
2
|
|
3
3
|
import { rAF, dup, buildtemplates } from './utils'
|
4
4
|
import { on, off, trigger } from './utils/events'
|
5
|
-
import { publish, subscribe
|
5
|
+
import { publish, subscribe } from './utils/pubsub'
|
6
6
|
|
7
|
-
|
7
|
+
export default function Component( elm, { module, dependencies, templates, components }) {
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
const options = getOptions(module)
|
12
|
-
|
13
|
-
buildtemplates(elm, components, templates)
|
9
|
+
const options = getOptions( module )
|
10
|
+
buildtemplates( elm, components, templates )
|
14
11
|
|
15
12
|
const tplid = elm.getAttribute('tplid')
|
16
|
-
const template = templates[tplid]
|
13
|
+
const template = tplid ? templates[tplid] : null
|
17
14
|
const state = { data: module.model ? dup(module.model) : {} }
|
18
15
|
|
19
|
-
let batchUpdates = []
|
20
|
-
|
21
16
|
const base = {
|
22
17
|
template,
|
23
18
|
elm,
|
24
19
|
dependencies,
|
25
20
|
publish,
|
26
21
|
subscribe,
|
27
|
-
unsubscribe,
|
28
22
|
|
29
|
-
main(fn
|
23
|
+
main(fn) {
|
30
24
|
options.main = fn
|
31
25
|
},
|
32
26
|
|
@@ -38,26 +32,29 @@ export default function Component(elm, { module, dependencies, templates, compon
|
|
38
32
|
options.onupdate = fn
|
39
33
|
},
|
40
34
|
|
41
|
-
on(eventName
|
35
|
+
on(eventName, selectorOrCallback, callback) {
|
42
36
|
on(elm, eventName, selectorOrCallback, callback)
|
43
37
|
},
|
44
38
|
|
45
|
-
off(eventName
|
39
|
+
off(eventName, callback) {
|
46
40
|
off(elm, eventName, callback)
|
47
41
|
},
|
48
42
|
|
49
|
-
trigger(eventName
|
50
|
-
if (target.constructor === String)
|
51
|
-
|
43
|
+
trigger(eventName, target, args) {
|
44
|
+
if (target.constructor === String) {
|
45
|
+
Array
|
46
|
+
.from(elm.querySelectorAll(target))
|
47
|
+
.forEach( children => trigger(children, eventName, { args: args }) )
|
48
|
+
}
|
52
49
|
else trigger(elm, eventName, { args: target })
|
53
50
|
},
|
54
51
|
|
55
|
-
emit: (...args) => {
|
52
|
+
emit: ( ...args ) => {
|
56
53
|
trigger(elm, args.shift(), { args: args })
|
57
54
|
},
|
58
55
|
|
59
56
|
state: {
|
60
|
-
set(data
|
57
|
+
set( data ) {
|
61
58
|
if (data.constructor === Function) {
|
62
59
|
const newstate = dup(state.data)
|
63
60
|
data(newstate)
|
@@ -72,37 +69,26 @@ export default function Component(elm, { module, dependencies, templates, compon
|
|
72
69
|
}
|
73
70
|
},
|
74
71
|
|
75
|
-
render(data
|
72
|
+
render(data = state.data) {
|
76
73
|
|
77
|
-
if (!document.body.contains(elm))
|
74
|
+
if (!document.body.contains(elm)) {
|
78
75
|
return
|
76
|
+
}
|
79
77
|
|
80
|
-
|
81
|
-
|
82
|
-
rAF(() => {
|
83
|
-
rAF(() => {
|
84
|
-
if (batchUpdates.length) {
|
85
|
-
|
86
|
-
const batchData = {}
|
87
|
-
batchUpdates.forEach(d => Object.assign(batchData, d))
|
88
|
-
batchUpdates = []
|
89
|
-
|
90
|
-
state.data = Object.assign(state.data, batchData)
|
78
|
+
state.data = Object.assign(state.data, data)
|
91
79
|
|
92
|
-
|
93
|
-
|
80
|
+
const newdata = dup(state.data)
|
81
|
+
const newhtml = base.template(options.view(newdata))
|
94
82
|
|
95
|
-
|
83
|
+
morphdom(elm, newhtml, morphdomOptions(elm, options))
|
96
84
|
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
}
|
105
|
-
})
|
85
|
+
rAF(_ => {
|
86
|
+
Array
|
87
|
+
.from(elm.querySelectorAll('[tplid]'))
|
88
|
+
.forEach((child: any) => {
|
89
|
+
child.options.onupdate(newdata)
|
90
|
+
child.base.render(newdata)
|
91
|
+
})
|
106
92
|
})
|
107
93
|
}
|
108
94
|
}
|
@@ -111,13 +97,13 @@ export default function Component(elm, { module, dependencies, templates, compon
|
|
111
97
|
}
|
112
98
|
|
113
99
|
const getOptions = (module) => ({
|
114
|
-
main:
|
115
|
-
unmount:
|
116
|
-
onupdate:
|
117
|
-
view: module.view ? module.view :
|
100
|
+
main: (a) => a,
|
101
|
+
unmount: (a) => a,
|
102
|
+
onupdate: (a) => a,
|
103
|
+
view: module.view ? module.view : (a) => a
|
118
104
|
})
|
119
105
|
|
120
|
-
const morphdomOptions = (_parent, options) => ({
|
106
|
+
const morphdomOptions = (_parent, options ) => ({
|
121
107
|
|
122
108
|
onNodeAdded: onUpdates(_parent, options),
|
123
109
|
onElUpdated: onUpdates(_parent, options),
|
@@ -125,14 +111,15 @@ const morphdomOptions = (_parent, options) => ({
|
|
125
111
|
onBeforeElUpdated: checkStatic,
|
126
112
|
|
127
113
|
getNodeKey(node) {
|
128
|
-
if (node.nodeType === 1 && node.getAttribute('tplid'))
|
129
|
-
return node.
|
114
|
+
if (node.nodeType === 1 && node.getAttribute('tplid')){
|
115
|
+
return 'key' in node.attributes? node.attributes.key.value : node.getAttribute('tplid')
|
116
|
+
}
|
130
117
|
return false
|
131
118
|
}
|
132
119
|
})
|
133
120
|
|
134
121
|
const checkStatic = (node) => {
|
135
|
-
if ('static' in node.
|
122
|
+
if ('html-static' in node.attributes) {
|
136
123
|
return false
|
137
124
|
}
|
138
125
|
}
|
@@ -142,11 +129,10 @@ const onUpdates = (_parent, options) => (node) => {
|
|
142
129
|
if (node.nodeType === 1) {
|
143
130
|
|
144
131
|
if (node.getAttribute && node.getAttribute('scope')) {
|
145
|
-
|
146
|
-
const scope =
|
147
|
-
|
132
|
+
const json = node.getAttribute('scope')
|
133
|
+
const scope = (new Function(`return ${json}`))()
|
148
134
|
Array.from(node.querySelectorAll('[tplid]'))
|
149
|
-
.map(el => {
|
135
|
+
.map((el) => {
|
150
136
|
const data = Object.assign({}, _parent.base.state.get(), scope)
|
151
137
|
options.onupdate(data)
|
152
138
|
el.base.render(data)
|
@@ -155,4 +141,6 @@ const onUpdates = (_parent, options) => (node) => {
|
|
155
141
|
node.removeAttribute('scope')
|
156
142
|
}
|
157
143
|
}
|
144
|
+
|
145
|
+
return node
|
158
146
|
}
|
package/src/element.ts
CHANGED
@@ -1,9 +1,15 @@
|
|
1
1
|
import Component from './component'
|
2
|
+
import { purge } from './utils'
|
2
3
|
|
3
4
|
export default function Element(module, dependencies, templates, components) {
|
4
5
|
|
5
6
|
return class extends HTMLElement {
|
6
7
|
|
8
|
+
base: any
|
9
|
+
options: any
|
10
|
+
returns : any
|
11
|
+
__events: any
|
12
|
+
|
7
13
|
constructor() {
|
8
14
|
|
9
15
|
super()
|
@@ -12,20 +18,31 @@ export default function Element(module, dependencies, templates, components) {
|
|
12
18
|
|
13
19
|
this.base = base
|
14
20
|
this.options = options
|
15
|
-
|
16
|
-
module.default(base)
|
21
|
+
this.returns = module.default(base)
|
17
22
|
}
|
18
23
|
|
19
24
|
connectedCallback() {
|
20
25
|
this.base.render()
|
21
|
-
|
26
|
+
|
27
|
+
if( this.returns && this.returns.constructor === Promise ) {
|
28
|
+
this.returns.then( _ => {
|
29
|
+
if( this.base ) {
|
30
|
+
this.options.main().forEach(f => f(this.base))
|
31
|
+
}
|
32
|
+
})
|
33
|
+
}else {
|
34
|
+
this.options.main().forEach(f => f(this.base))
|
35
|
+
}
|
22
36
|
}
|
23
37
|
|
24
38
|
disconnectedCallback() {
|
25
39
|
this.options.unmount(this.base)
|
26
|
-
|
27
|
-
|
28
|
-
|
40
|
+
if(!document.body.contains(this) ) {
|
41
|
+
this.__events = null
|
42
|
+
this.base.elm = null
|
43
|
+
this.base = null
|
44
|
+
purge(this)
|
45
|
+
}
|
29
46
|
}
|
30
47
|
|
31
48
|
attributeChangedCallback() {
|
package/src/index.ts
CHANGED
@@ -1,27 +1,28 @@
|
|
1
|
-
|
1
|
+
|
2
|
+
import { buildtemplates } from './utils'
|
2
3
|
import Element from './element'
|
3
4
|
|
4
|
-
|
5
|
-
|
5
|
+
const templates = {}
|
6
|
+
const components = {}
|
6
7
|
|
7
8
|
export default {
|
8
9
|
|
9
|
-
register(name:
|
10
|
+
register( name:string, module:any, dependencies: object ) {
|
10
11
|
components[name] = { name, module, dependencies }
|
11
12
|
},
|
12
13
|
|
13
14
|
start() {
|
14
15
|
const body = document.body
|
15
|
-
|
16
|
-
buildtemplates(body, components, templates)
|
16
|
+
buildtemplates( body, components, templates )
|
17
17
|
registerComponents()
|
18
18
|
}
|
19
19
|
}
|
20
20
|
|
21
21
|
const registerComponents = () => {
|
22
22
|
Object
|
23
|
-
.values(components)
|
24
|
-
.forEach((
|
23
|
+
.values( components )
|
24
|
+
.forEach( (component) => {
|
25
|
+
const { name, module, dependencies } = component
|
25
26
|
const Base = Element(module, dependencies, templates, components)
|
26
27
|
customElements.define(name, Base)
|
27
28
|
})
|
package/src/template-system.ts
CHANGED
@@ -1,30 +1,27 @@
|
|
1
1
|
import { compile, defaultConfig, filters } from 'squirrelly'
|
2
|
-
import {
|
2
|
+
import { decodeHtmlEntities } from './utils'
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
tags: ['{', '}'],
|
7
|
-
useWith: true
|
8
|
-
}
|
4
|
+
defaultConfig.tags = ['{', '}']
|
5
|
+
defaultConfig.useWith = true
|
9
6
|
|
10
|
-
export default function templateSystem(element) {
|
7
|
+
export default function templateSystem( element ) {
|
11
8
|
|
12
|
-
const
|
9
|
+
const tree = document.createElement('template')
|
13
10
|
|
14
|
-
|
11
|
+
tree.innerHTML = element.outerHTML.replace(/<\/?template[^>]*>/g, '')
|
15
12
|
|
16
|
-
|
13
|
+
directives(tree.content)
|
17
14
|
|
18
15
|
const html = decodeHtmlEntities(
|
19
|
-
|
16
|
+
tree.innerHTML
|
20
17
|
.replace(/html-(selected|checked|readonly|disabled|autoplay)=\"(.*)\"/g, `{@if ($2) }$1{/if}`)
|
21
18
|
.replace(/html-/g, '')
|
22
19
|
)
|
23
20
|
|
24
|
-
const template = compile(html,
|
21
|
+
const template = compile(html, defaultConfig)
|
25
22
|
|
26
|
-
return (data) => {
|
27
|
-
return template(data,
|
23
|
+
return ( data ) => {
|
24
|
+
return template(data, defaultConfig)
|
28
25
|
}
|
29
26
|
}
|
30
27
|
|
@@ -38,10 +35,10 @@ const directives = (vdom) => {
|
|
38
35
|
|
39
36
|
if (nodes.length) {
|
40
37
|
|
41
|
-
nodes.forEach(node => {
|
38
|
+
nodes.forEach(( node ) => {
|
42
39
|
if (node.getAttribute('html-foreach')) {
|
43
|
-
const instruction = node.getAttribute('html-foreach')
|
44
|
-
const split = instruction.match(/(.*)\sin\s(.*)/)
|
40
|
+
const instruction = node.getAttribute('html-foreach') || ''
|
41
|
+
const split = instruction.match(/(.*)\sin\s(.*)/) || ''
|
45
42
|
const varname = split[1]
|
46
43
|
const object = split[2]
|
47
44
|
node.removeAttribute('html-foreach')
|
@@ -50,8 +47,8 @@ const directives = (vdom) => {
|
|
50
47
|
const close = document.createTextNode('{/foreach}')
|
51
48
|
wrap(open, node, close)
|
52
49
|
} else if (node.getAttribute('html-for')) {
|
53
|
-
const instruction = node.getAttribute('html-for')
|
54
|
-
const split = instruction.match(/(.*)\sin\s(.*)/)
|
50
|
+
const instruction = node.getAttribute('html-for') || ''
|
51
|
+
const split = instruction.match(/(.*)\sin\s(.*)/) || ''
|
55
52
|
const varname = split[1]
|
56
53
|
const object = split[2]
|
57
54
|
node.removeAttribute('html-for')
|
@@ -75,7 +72,7 @@ const directives = (vdom) => {
|
|
75
72
|
filters.define('JSON', (scope, index, varname) => {
|
76
73
|
|
77
74
|
const key = index.constructor == String ? '$key' : '$index'
|
78
|
-
const newobject = { $index: index }
|
75
|
+
const newobject = { $index: index } as any
|
79
76
|
|
80
77
|
newobject[varname] = scope
|
81
78
|
newobject[key] = index
|
@@ -84,6 +81,6 @@ filters.define('JSON', (scope, index, varname) => {
|
|
84
81
|
})
|
85
82
|
|
86
83
|
const wrap = (open, node, close) => {
|
87
|
-
node.parentNode
|
88
|
-
node.parentNode
|
84
|
+
node.parentNode?.insertBefore(open, node)
|
85
|
+
node.parentNode?.insertBefore(close, node.nextSibling)
|
89
86
|
}
|
package/src/utils/events.ts
CHANGED
package/src/utils/index.ts
CHANGED
@@ -3,7 +3,10 @@ import templateSystem from '../template-system'
|
|
3
3
|
const textarea = document.createElement('textarea')
|
4
4
|
|
5
5
|
export const rAF = (fn) => {
|
6
|
-
(requestAnimationFrame
|
6
|
+
if (requestAnimationFrame)
|
7
|
+
return requestAnimationFrame(fn)
|
8
|
+
else
|
9
|
+
return setTimeout(fn, 1000 / 60)
|
7
10
|
}
|
8
11
|
|
9
12
|
export const uuid = () => {
|
@@ -13,11 +16,11 @@ export const uuid = () => {
|
|
13
16
|
})
|
14
17
|
}
|
15
18
|
|
16
|
-
export const stripTemplateTag = (element) => {
|
19
|
+
export const stripTemplateTag = ( element ) => {
|
17
20
|
const templates = Array.from(element.querySelectorAll('template'))
|
18
21
|
// https://gist.github.com/harmenjanssen/07e425248779c65bc5d11b02fb913274
|
19
|
-
templates.forEach(template => {
|
20
|
-
template.parentNode
|
22
|
+
templates.forEach((template) => {
|
23
|
+
template.parentNode?.replaceChild(template.content, template)
|
21
24
|
stripTemplateTag(template.content)
|
22
25
|
})
|
23
26
|
}
|
@@ -26,7 +29,7 @@ export const dup = (o) => {
|
|
26
29
|
return JSON.parse(JSON.stringify(o))
|
27
30
|
}
|
28
31
|
|
29
|
-
export const createTemplateId = (element, templates) => {
|
32
|
+
export const createTemplateId = (element, templates ) => {
|
30
33
|
|
31
34
|
const tplid = element.getAttribute('tplid')
|
32
35
|
|
@@ -34,25 +37,44 @@ export const createTemplateId = (element, templates) => {
|
|
34
37
|
const id = uuid()
|
35
38
|
element.setAttribute('tplid', id)
|
36
39
|
templates[id] = templateSystem(element)
|
37
|
-
return templates[id]
|
38
40
|
}
|
39
|
-
|
40
|
-
return templates[tplid]
|
41
41
|
}
|
42
42
|
|
43
|
-
export const buildtemplates = (target, components, templates) => {
|
43
|
+
export const buildtemplates = ( target, components, templates ) => {
|
44
44
|
|
45
45
|
return Array
|
46
46
|
.from(target.querySelectorAll('*'))
|
47
|
-
.filter(node => node.tagName.
|
47
|
+
.filter((node) => node.tagName.toLowerCase() in components)
|
48
48
|
.reverse()
|
49
|
-
.map(node => {
|
49
|
+
.map((node) => {
|
50
|
+
Array.from(node.querySelectorAll('template'))
|
51
|
+
.map((template) => buildtemplates(template.content, components, templates))
|
50
52
|
createTemplateId(node, templates)
|
51
53
|
return node
|
52
54
|
})
|
53
55
|
}
|
54
56
|
|
55
|
-
export const decodeHtmlEntities = (str) => {
|
57
|
+
export const decodeHtmlEntities = ( str ) => {
|
56
58
|
textarea.innerHTML = str
|
57
59
|
return textarea.value
|
58
60
|
}
|
61
|
+
|
62
|
+
// http://crockford.com/javascript/memory/leak.html
|
63
|
+
export const purge = (d) => {
|
64
|
+
var a = d.attributes, i, l, n
|
65
|
+
if (a) {
|
66
|
+
for (i = a.length - 1; i >= 0; i -= 1) {
|
67
|
+
n = a[i].name
|
68
|
+
if (typeof d[n] === 'function') {
|
69
|
+
d[n] = null
|
70
|
+
}
|
71
|
+
}
|
72
|
+
}
|
73
|
+
a = d.childNodes
|
74
|
+
if (a) {
|
75
|
+
l = a.length
|
76
|
+
for (i = 0; i < l; i += 1) {
|
77
|
+
purge(d.childNodes[i])
|
78
|
+
}
|
79
|
+
}
|
80
|
+
}
|
package/src/utils/pubsub.ts
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
const topics = {}
|
2
|
-
const _async = {}
|
1
|
+
const topics: any = {}
|
2
|
+
const _async: any = {}
|
3
3
|
|
4
4
|
export const publish = (name, params) => {
|
5
5
|
_async[name] = Object.assign({}, _async[name], params)
|
@@ -13,13 +13,8 @@ export const subscribe = (name, method) => {
|
|
13
13
|
if (name in _async) {
|
14
14
|
method(_async[name])
|
15
15
|
}
|
16
|
-
|
17
|
-
|
18
|
-
export const unsubscribe = (topic) => {
|
19
|
-
topics[topic.name] = (topics[topic.name] || [])
|
20
|
-
.filter(t => t != topic.method)
|
21
|
-
if (!topics[topic.name].length) {
|
22
|
-
delete topics[topic.name]
|
23
|
-
delete _async[topic.name]
|
16
|
+
return () => {
|
17
|
+
topics[name] = topics[name].filter( fn => fn != method )
|
24
18
|
}
|
25
19
|
}
|
20
|
+
|
package/tsconfig.json
CHANGED
@@ -1,16 +1,106 @@
|
|
1
1
|
{
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
2
|
+
"compilerOptions": {
|
3
|
+
/* Visit https://aka.ms/tsconfig to read more about this file */
|
4
|
+
|
5
|
+
/* Projects */
|
6
|
+
// "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */
|
7
|
+
// "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */
|
8
|
+
// "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */
|
9
|
+
// "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */
|
10
|
+
// "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */
|
11
|
+
// "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */
|
12
|
+
|
13
|
+
/* Language and Environment */
|
14
|
+
"target": "ES2015", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
|
15
|
+
"lib": ["es2015", "dom"], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
|
16
|
+
// "jsx": "preserve", /* Specify what JSX code is generated. */
|
17
|
+
// "experimentalDecorators": true, /* Enable experimental support for TC39 stage 2 draft decorators. */
|
18
|
+
// "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */
|
19
|
+
// "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */
|
20
|
+
// "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */
|
21
|
+
// "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */
|
22
|
+
// "reactNamespace": "", /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */
|
23
|
+
// "noLib": true, /* Disable including any library files, including the default lib.d.ts. */
|
24
|
+
// "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */
|
25
|
+
// "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */
|
26
|
+
|
27
|
+
/* Modules */
|
28
|
+
"module":"CommonJS", /* Specify what module code is generated. */
|
29
|
+
// "rootDir": "./src", /* Specify the root folder within your source files. */
|
30
|
+
"moduleResolution": "node", /* Specify how TypeScript looks up a file from a given module specifier. */
|
31
|
+
// "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
|
32
|
+
// "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
|
33
|
+
// "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
|
34
|
+
// "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */
|
35
|
+
// "types": [], /* Specify type package names to be included without being referenced in a source file. */
|
36
|
+
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
|
37
|
+
// "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */
|
38
|
+
// "resolveJsonModule": true, /* Enable importing .json files. */
|
39
|
+
// "noResolve": true, /* Disallow 'import's, 'require's or '<reference>'s from expanding the number of files TypeScript should add to a project. */
|
40
|
+
|
41
|
+
/* JavaScript Support */
|
42
|
+
// "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */
|
43
|
+
// "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */
|
44
|
+
// "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */
|
45
|
+
|
46
|
+
/* Emit */
|
47
|
+
"declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */
|
48
|
+
// "declarationMap": true, /* Create sourcemaps for d.ts files. */
|
49
|
+
"emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */
|
50
|
+
// "sourceMap": true, /* Create source map files for emitted JavaScript files. */
|
51
|
+
// "outFile": "types/index.d.ts", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */
|
52
|
+
"outDir": "types", /* Specify an output folder for all emitted files. */
|
53
|
+
// "removeComments": true, /* Disable emitting comments. */
|
54
|
+
// "noEmit": true, /* Disable emitting files from a compilation. */
|
55
|
+
// "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */
|
56
|
+
// "importsNotUsedAsValues": "remove", /* Specify emit/checking behavior for imports that are only used for types. */
|
57
|
+
// "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */
|
58
|
+
// "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */
|
59
|
+
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
|
60
|
+
// "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */
|
61
|
+
// "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */
|
62
|
+
// "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */
|
63
|
+
// "newLine": "crlf", /* Set the newline character for emitting files. */
|
64
|
+
// "stripInternal": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */
|
65
|
+
// "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */
|
66
|
+
// "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */
|
67
|
+
// "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */
|
68
|
+
// "declarationDir": "./dist/types", /* Specify the output directory for generated declaration files. */
|
69
|
+
// "preserveValueImports": true, /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */
|
70
|
+
|
71
|
+
/* Interop Constraints */
|
72
|
+
// "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */
|
73
|
+
// "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */
|
74
|
+
"esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */
|
75
|
+
// "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */
|
76
|
+
"forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */
|
77
|
+
|
78
|
+
/* Type Checking */
|
79
|
+
// "strict": true, /* Enable all strict type-checking options. */
|
80
|
+
"noImplicitAny": false, /* Enable error reporting for expressions and declarations with an implied 'any' type. */
|
81
|
+
// "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */
|
82
|
+
// "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */
|
83
|
+
// "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */
|
84
|
+
// "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */
|
85
|
+
// "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */
|
86
|
+
// "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */
|
87
|
+
// "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */
|
88
|
+
// "noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */
|
89
|
+
// "noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */
|
90
|
+
// "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */
|
91
|
+
// "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */
|
92
|
+
// "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */
|
93
|
+
// "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */
|
94
|
+
// "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */
|
95
|
+
// "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */
|
96
|
+
// "allowUnusedLabels": true, /* Disable error reporting for unused labels. */
|
97
|
+
// "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */
|
98
|
+
|
99
|
+
/* Completeness */
|
100
|
+
// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
|
101
|
+
"skipLibCheck": true /* Skip type checking all .d.ts files. */
|
102
|
+
},
|
103
|
+
"files": [
|
104
|
+
"src/index.ts"
|
15
105
|
]
|
16
106
|
}
|
@@ -0,0 +1,32 @@
|
|
1
|
+
export default function Component(elm: any, { module, dependencies, templates, components }: {
|
2
|
+
module: any;
|
3
|
+
dependencies: any;
|
4
|
+
templates: any;
|
5
|
+
components: any;
|
6
|
+
}): {
|
7
|
+
base: {
|
8
|
+
template: any;
|
9
|
+
elm: any;
|
10
|
+
dependencies: any;
|
11
|
+
publish: (name: any, params: any) => void;
|
12
|
+
subscribe: (name: any, method: any) => () => void;
|
13
|
+
main(fn: any): void;
|
14
|
+
unmount(fn: any): void;
|
15
|
+
onupdate(fn: any): void;
|
16
|
+
on(eventName: any, selectorOrCallback: any, callback: any): void;
|
17
|
+
off(eventName: any, callback: any): void;
|
18
|
+
trigger(eventName: any, target: any, args: any): void;
|
19
|
+
emit: (...args: any[]) => void;
|
20
|
+
state: {
|
21
|
+
set(data: any): Promise<unknown>;
|
22
|
+
get(): any;
|
23
|
+
};
|
24
|
+
render(data?: any): void;
|
25
|
+
};
|
26
|
+
options: {
|
27
|
+
main: (a: any) => any;
|
28
|
+
unmount: (a: any) => any;
|
29
|
+
onupdate: (a: any) => any;
|
30
|
+
view: any;
|
31
|
+
};
|
32
|
+
};
|