@codesuma/baseline 1.0.17 → 1.0.18
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/README.md +12 -0
- package/components/base.ts +0 -34
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -17,6 +17,18 @@ npm install @codesuma/baseline
|
|
|
17
17
|
- **Tiny** - The entire framework is smaller than most framework's "hello world" bundle.
|
|
18
18
|
- **Stable** - No dependencies means no breaking changes from upstream.
|
|
19
19
|
|
|
20
|
+
## Examples
|
|
21
|
+
|
|
22
|
+
Baseline comes with built-in examples to help you get started:
|
|
23
|
+
|
|
24
|
+
```typescript
|
|
25
|
+
import { CounterExample, TodoExample } from '@codesuma/baseline'
|
|
26
|
+
|
|
27
|
+
// Use them in your app
|
|
28
|
+
document.body.appendChild(CounterExample().el)
|
|
29
|
+
document.body.appendChild(TodoExample().el)
|
|
30
|
+
```
|
|
31
|
+
|
|
20
32
|
## Quick Start
|
|
21
33
|
|
|
22
34
|
```typescript
|
package/components/base.ts
CHANGED
|
@@ -11,24 +11,6 @@ export function Base<K extends keyof HTMLElementTagNameMap>(name: K = 'div' as K
|
|
|
11
11
|
const el = document.createElement(name)
|
|
12
12
|
el.setAttribute('data-base-id', id)
|
|
13
13
|
|
|
14
|
-
try {
|
|
15
|
-
const stack = new Error().stack
|
|
16
|
-
if (stack) {
|
|
17
|
-
const lines = stack.split('\n')
|
|
18
|
-
// V8: Error, at Base, at Caller -> index 2
|
|
19
|
-
// Firefox/Safari: Base@..., Caller@... -> index 1
|
|
20
|
-
const callerLine = lines[0].includes('Error') ? lines[2] : lines[1]
|
|
21
|
-
if (callerLine) {
|
|
22
|
-
const match = callerLine.match(/at\s+([^\s(]+)/) || callerLine.match(/^([^\s@]+)/)
|
|
23
|
-
if (match?.[1]) {
|
|
24
|
-
el.setAttribute('data-component-name', match[1].replace(/([a-z0-9])([A-Z])/g, '$1-$2').toLowerCase())
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
} catch (e) {
|
|
29
|
-
// Ignore stack trace errors
|
|
30
|
-
}
|
|
31
|
-
|
|
32
14
|
const component: any = { id, el, isMounted: false, parent: undefined }
|
|
33
15
|
|
|
34
16
|
Object.assign(component, createEmitter(), createAppender(component), createStyler(component))
|
|
@@ -41,22 +23,6 @@ export function BaseSVG<K extends keyof SVGElementTagNameMap>(name: K = 'svg' as
|
|
|
41
23
|
const el = document.createElementNS('http://www.w3.org/2000/svg', name)
|
|
42
24
|
el.setAttribute('data-base-id', id)
|
|
43
25
|
|
|
44
|
-
try {
|
|
45
|
-
const stack = new Error().stack
|
|
46
|
-
if (stack) {
|
|
47
|
-
const lines = stack.split('\n')
|
|
48
|
-
const callerLine = lines[0].includes('Error') ? lines[2] : lines[1]
|
|
49
|
-
if (callerLine) {
|
|
50
|
-
const match = callerLine.match(/at\s+([^\s(]+)/) || callerLine.match(/^([^\s@]+)/)
|
|
51
|
-
if (match?.[1]) {
|
|
52
|
-
el.setAttribute('data-component-name', match[1].replace(/([a-z0-9])([A-Z])/g, '$1-$2').toLowerCase())
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
} catch (e) {
|
|
57
|
-
// Ignore stack trace errors
|
|
58
|
-
}
|
|
59
|
-
|
|
60
26
|
const component: any = { id, el, isMounted: false, parent: undefined }
|
|
61
27
|
|
|
62
28
|
Object.assign(component, createEmitter(), createAppender(component), createStyler(component))
|
package/package.json
CHANGED