Skip to content

Commit dd56bea

Browse files
committed
Fixed some bugs
1 parent 887b14f commit dd56bea

File tree

7 files changed

+40
-31
lines changed

7 files changed

+40
-31
lines changed

ext/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use strict'
22

33
if (process.env.NODE_ENV === 'production') {
4-
module.exports = require('../dist/js-elements.ext.cjs.production.js')
4+
module.exports = require('../dist/js-elements-ext.cjs.production.js')
55
} else {
6-
module.exports = require('../dist/js-elements.ext.cjs.development.js')
6+
module.exports = require('../dist/js-elements-ext.cjs.development.js')
77
}

ext/package.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"name": "js-elements-ext",
3+
"version": "0.0.1",
4+
"description": "",
5+
"main": "index.js",
6+
"module": "../dist/js-elements-ext.esm.producion.js",
7+
"unpkg": "../dist/js-elements-ext.umd.production.js",
8+
"jsdelivr": "../dist/js-elements-ext.umd.production.js",
9+
"types": "../dist/types/js-elements-ext.d.ts"
10+
}

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
{
22
"name": "js-elements",
3-
"version": "0.0.72",
3+
"version": "0.0.76",
44
"description": "",
55
"main": "index.js",
66
"module": "dist/js-elements.esm.producion.js",
77
"unpkg": "dist/js-elements.umd.production.js",
88
"jsdelivr": "dist/js-elements.umd.production.js",
9-
"types": "dist/types/main/index.d.ts",
9+
"types": "dist/types/js-elements.d.ts",
1010
"files": [
1111
"index.js",
1212
"dist",

rollup.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ function createConfig(pkg, moduleFormat, productive) {
3333
file:
3434
pkg === 'root'
3535
? `dist/js-elements.${moduleFormat}.${env}.js`
36-
: `dist/js-elements.${pkg}.${moduleFormat}.${env}.js`,
36+
: `dist/js-elements-${pkg}.${moduleFormat}.${env}.js`,
3737

3838
format: moduleFormat,
3939
sourcemap: false, // productive ? false : 'inline', // TODO

src/main/core/prop.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@ type TypeType<T extends Type | null> = T extends null
2626

2727
type PropTypeBuilder<T> = {
2828
opt: {
29-
(): PropType<T, false, false>
30-
(defaultValue: T): PropType<T, true, false>
29+
(): PropType<T, 'optional'>
30+
(defaultValue: T): PropType<T, 'optional-with-default'>
3131
}
3232

33-
req: () => PropType<T, false, true>
33+
req: () => PropType<T, 'required'>
3434
}
3535

3636
type ExtPropTypeBuilder<T> = PropTypeBuilder<T> & {
@@ -52,7 +52,7 @@ type PropFunc = ExtPropTypeBuilder<any> & {
5252
nfunc: ExtPropTypeBuilder<((...args: any[]) => any) | null>
5353
narr: ExtPropTypeBuilder<any[] | null>
5454

55-
evt<T = any>(): PropType<(event: T) => void, false, false>
55+
evt<T = any>(): PropType<(event: T) => void, 'optional'>
5656

5757
<T extends Type>(t: T): ExtPropTypeBuilder<TypeType<T>>
5858

src/main/core/types.ts

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -103,14 +103,13 @@ type Notifier = {
103103
notify(): void
104104
}
105105

106-
declare const kind: unique symbol
106+
declare const tag: unique symbol
107107

108108
type PropType<
109109
Type,
110-
HasDefaultValue extends Boolean,
111-
Required extends boolean
110+
Kind extends 'optional' | 'optional-with-default' | 'required'
112111
> = {
113-
readonly [kind]: 'PropType'
112+
readonly [tag]: 'PropType'
114113
}
115114

116115
type ComponentOptions = {
@@ -147,14 +146,14 @@ type PropConfig =
147146
}
148147

149148
type PropsConfig = {
150-
[key: string]: PropType<any, any, any>
149+
[key: string]: PropType<any, any>
151150
}
152151

153152
type ExternalPropsOf<PC extends PropsConfig> = Partial<
154153
OmitNevers<
155154
{
156-
[K in keyof PC]: PC[K] extends PropType<infer T, infer D, infer R>
157-
? R extends true
155+
[K in keyof PC]: PC[K] extends PropType<infer T, infer K>
156+
? K extends 'required'
158157
? never
159158
: T
160159
: never
@@ -163,8 +162,8 @@ type ExternalPropsOf<PC extends PropsConfig> = Partial<
163162
> &
164163
OmitNevers<
165164
{
166-
[K in keyof PC]: PC[K] extends PropType<infer T, infer D, infer R>
167-
? R extends true
165+
[K in keyof PC]: PC[K] extends PropType<infer T, infer K>
166+
? K extends 'required'
168167
? T
169168
: never
170169
: never
@@ -174,10 +173,10 @@ type ExternalPropsOf<PC extends PropsConfig> = Partial<
174173
type InternalPropsOf<PC extends PropsConfig> = Partial<
175174
OmitNevers<
176175
{
177-
[K in keyof PC]: PC[K] extends PropType<infer T, infer D, infer R>
178-
? R extends true
176+
[K in keyof PC]: PC[K] extends PropType<infer T, infer K>
177+
? K extends 'required'
179178
? never
180-
: D extends true
179+
: K extends 'optional-with-default'
181180
? never
182181
: T
183182
: never
@@ -186,10 +185,10 @@ type InternalPropsOf<PC extends PropsConfig> = Partial<
186185
> &
187186
OmitNevers<
188187
{
189-
[K in keyof PC]: PC[K] extends PropType<infer T, infer D, infer R>
190-
? R extends true
188+
[K in keyof PC]: PC[K] extends PropType<infer T, infer K>
189+
? K extends 'required'
191190
? T
192-
: D extends true
191+
: K extends 'optional-with-default'
193192
? T
194193
: never
195194
: never

src/main/js-elements.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -318,15 +318,15 @@ const renderer = (content: VElement, target: Element) => {
318318
// === render ========================================================
319319

320320
function render(content: VElement, container: Element | string) {
321-
if (content !== null && (!content || content.kind !== 'virtual-element')) {
322-
//throw new TypeError()
323-
// 'First argument "content" of function "render" must be a virtual element or null'
321+
if (content !== null && (!content || content.isVElement !== true)) {
322+
throw new TypeError()
323+
'First argument "content" of function "render" must be a virtual element or null'
324324
}
325325

326326
if (!container || (typeof container !== 'string' && !container.tagName)) {
327-
//throw new TypeError(
328-
// 'Second argument "container" of funtion "render" must either be a DOM element or selector string for the DOM element'
329-
// )
327+
throw new TypeError(
328+
'Second argument "container" of function "render" must either be a DOM element or selector string for the DOM element'
329+
)
330330
}
331331

332332
const target =
@@ -341,7 +341,7 @@ function render(content: VElement, container: Element | string) {
341341
target.innerHTML = ''
342342

343343
if (content !== null) {
344-
patch(content, target)
344+
renderer(content, target)
345345
}
346346
}
347347

0 commit comments

Comments
 (0)