glass-easel 0.1.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/README.md +40 -0
- package/dist/glass_easel.all.d.ts +1 -0
- package/dist/glass_easel.all.js +2 -0
- package/dist/glass_easel.all.js.map +1 -0
- package/dist/glass_easel.domlike.global.d.ts +1 -0
- package/dist/glass_easel.domlike.global.js +2 -0
- package/dist/glass_easel.domlike.global.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/types/src/backend/backend_protocol.d.ts +119 -0
- package/dist/types/src/backend/backend_protocol.d.ts.map +1 -0
- package/dist/types/src/backend/composed_backend_protocol.d.ts +90 -0
- package/dist/types/src/backend/composed_backend_protocol.d.ts.map +1 -0
- package/dist/types/src/backend/domlike_backend_protocol.d.ts +76 -0
- package/dist/types/src/backend/domlike_backend_protocol.d.ts.map +1 -0
- package/dist/types/src/backend/mode.d.ts +46 -0
- package/dist/types/src/backend/mode.d.ts.map +1 -0
- package/dist/types/src/backend/suggested_backend_protocol.d.ts +30 -0
- package/dist/types/src/backend/suggested_backend_protocol.d.ts.map +1 -0
- package/dist/types/src/behavior.d.ts +428 -0
- package/dist/types/src/behavior.d.ts.map +1 -0
- package/dist/types/src/class_list.d.ts +79 -0
- package/dist/types/src/class_list.d.ts.map +1 -0
- package/dist/types/src/component.d.ts +291 -0
- package/dist/types/src/component.d.ts.map +1 -0
- package/dist/types/src/component_params.d.ts +239 -0
- package/dist/types/src/component_params.d.ts.map +1 -0
- package/dist/types/src/component_space.d.ts +164 -0
- package/dist/types/src/component_space.d.ts.map +1 -0
- package/dist/types/src/data_path.d.ts +5 -0
- package/dist/types/src/data_path.d.ts.map +1 -0
- package/dist/types/src/data_proxy.d.ts +107 -0
- package/dist/types/src/data_proxy.d.ts.map +1 -0
- package/dist/types/src/data_utils.d.ts +3 -0
- package/dist/types/src/data_utils.d.ts.map +1 -0
- package/dist/types/src/element.d.ts +275 -0
- package/dist/types/src/element.d.ts.map +1 -0
- package/dist/types/src/element_iterator.d.ts +43 -0
- package/dist/types/src/element_iterator.d.ts.map +1 -0
- package/dist/types/src/event.d.ts +104 -0
- package/dist/types/src/event.d.ts.map +1 -0
- package/dist/types/src/external_shadow_tree.d.ts +20 -0
- package/dist/types/src/external_shadow_tree.d.ts.map +1 -0
- package/dist/types/src/func_arr.d.ts +39 -0
- package/dist/types/src/func_arr.d.ts.map +1 -0
- package/dist/types/src/global_options.d.ts +111 -0
- package/dist/types/src/global_options.d.ts.map +1 -0
- package/dist/types/src/index.d.ts +43 -0
- package/dist/types/src/index.d.ts.map +1 -0
- package/dist/types/src/mutation_observer.d.ts +79 -0
- package/dist/types/src/mutation_observer.d.ts.map +1 -0
- package/dist/types/src/native_node.d.ts +8 -0
- package/dist/types/src/native_node.d.ts.map +1 -0
- package/dist/types/src/node.d.ts +49 -0
- package/dist/types/src/node.d.ts.map +1 -0
- package/dist/types/src/relation.d.ts +47 -0
- package/dist/types/src/relation.d.ts.map +1 -0
- package/dist/types/src/render.d.ts +3 -0
- package/dist/types/src/render.d.ts.map +1 -0
- package/dist/types/src/selector.d.ts +32 -0
- package/dist/types/src/selector.d.ts.map +1 -0
- package/dist/types/src/shadow_root.d.ts +136 -0
- package/dist/types/src/shadow_root.d.ts.map +1 -0
- package/dist/types/src/template_engine.d.ts +18 -0
- package/dist/types/src/template_engine.d.ts.map +1 -0
- package/dist/types/src/text_node.d.ts +32 -0
- package/dist/types/src/text_node.d.ts.map +1 -0
- package/dist/types/src/tmpl/index.d.ts +18 -0
- package/dist/types/src/tmpl/index.d.ts.map +1 -0
- package/dist/types/src/tmpl/native_rendering.d.ts +45 -0
- package/dist/types/src/tmpl/native_rendering.d.ts.map +1 -0
- package/dist/types/src/tmpl/proc_gen_wrapper.d.ts +80 -0
- package/dist/types/src/tmpl/proc_gen_wrapper.d.ts.map +1 -0
- package/dist/types/src/tmpl/proc_gen_wrapper_dom.d.ts +50 -0
- package/dist/types/src/tmpl/proc_gen_wrapper_dom.d.ts.map +1 -0
- package/dist/types/src/tmpl/range_list_diff.d.ts +19 -0
- package/dist/types/src/tmpl/range_list_diff.d.ts.map +1 -0
- package/dist/types/src/trait_behaviors.d.ts +38 -0
- package/dist/types/src/trait_behaviors.d.ts.map +1 -0
- package/dist/types/src/virtual_node.d.ts +10 -0
- package/dist/types/src/virtual_node.d.ts.map +1 -0
- package/dist/types/tests/backend/domlike.test.d.ts +2 -0
- package/dist/types/tests/backend/domlike.test.d.ts.map +1 -0
- package/dist/types/tests/base/env.d.ts +29 -0
- package/dist/types/tests/base/env.d.ts.map +1 -0
- package/dist/types/tests/base/match.d.ts +9 -0
- package/dist/types/tests/base/match.d.ts.map +1 -0
- package/dist/types/tests/core/backend.test.d.ts +2 -0
- package/dist/types/tests/core/backend.test.d.ts.map +1 -0
- package/dist/types/tests/core/behavior.test.d.ts +2 -0
- package/dist/types/tests/core/behavior.test.d.ts.map +1 -0
- package/dist/types/tests/core/component_space.test.d.ts +2 -0
- package/dist/types/tests/core/component_space.test.d.ts.map +1 -0
- package/dist/types/tests/core/data_update.test.d.ts +2 -0
- package/dist/types/tests/core/data_update.test.d.ts.map +1 -0
- package/dist/types/tests/core/misc.test.d.ts +2 -0
- package/dist/types/tests/core/misc.test.d.ts.map +1 -0
- package/dist/types/tests/core/placeholder.test.d.ts +2 -0
- package/dist/types/tests/core/placeholder.test.d.ts.map +1 -0
- package/dist/types/tests/core/slot.test.d.ts +2 -0
- package/dist/types/tests/core/slot.test.d.ts.map +1 -0
- package/dist/types/tests/core/trait_behaviors.test.d.ts +2 -0
- package/dist/types/tests/core/trait_behaviors.test.d.ts.map +1 -0
- package/dist/types/tests/tmpl/binding_map.test.d.ts +2 -0
- package/dist/types/tests/tmpl/binding_map.test.d.ts.map +1 -0
- package/dist/types/tests/tmpl/event.test.d.ts +2 -0
- package/dist/types/tests/tmpl/event.test.d.ts.map +1 -0
- package/dist/types/tests/tmpl/expression.test.d.ts +2 -0
- package/dist/types/tests/tmpl/expression.test.d.ts.map +1 -0
- package/dist/types/tests/tmpl/lvalue.test.d.ts +2 -0
- package/dist/types/tests/tmpl/lvalue.test.d.ts.map +1 -0
- package/dist/types/tests/tmpl/native_rendering.test.d.ts +2 -0
- package/dist/types/tests/tmpl/native_rendering.test.d.ts.map +1 -0
- package/dist/types/tests/tmpl/structure.test.d.ts +2 -0
- package/dist/types/tests/tmpl/structure.test.d.ts.map +1 -0
- package/dist/types/tests/types/chaining.test.d.ts +2 -0
- package/dist/types/tests/types/chaining.test.d.ts.map +1 -0
- package/dist/types/tests/types/createElement.test.d.ts +2 -0
- package/dist/types/tests/types/createElement.test.d.ts.map +1 -0
- package/dist/types/tests/types/definition.test.d.ts +2 -0
- package/dist/types/tests/types/definition.test.d.ts.map +1 -0
- package/guide/zh_CN/advanced/binding_map_update.md +32 -0
- package/guide/zh_CN/advanced/build_args.md +28 -0
- package/guide/zh_CN/advanced/component_filter.md +70 -0
- package/guide/zh_CN/advanced/component_space.md +124 -0
- package/guide/zh_CN/advanced/custom_backend.md +53 -0
- package/guide/zh_CN/advanced/error_listener.md +32 -0
- package/guide/zh_CN/advanced/external_component.md +73 -0
- package/guide/zh_CN/advanced/template_engine.md +61 -0
- package/guide/zh_CN/appendix/backend_protocol.md +501 -0
- package/guide/zh_CN/appendix/list_diff_algorithm.md +406 -0
- package/guide/zh_CN/basic/beginning.md +94 -0
- package/guide/zh_CN/basic/component.md +156 -0
- package/guide/zh_CN/basic/event.md +169 -0
- package/guide/zh_CN/basic/lifetime.md +66 -0
- package/guide/zh_CN/basic/method.md +62 -0
- package/guide/zh_CN/basic/template.md +135 -0
- package/guide/zh_CN/data_management/advanced_update.md +170 -0
- package/guide/zh_CN/data_management/data_deep_copy.md +157 -0
- package/guide/zh_CN/data_management/data_observer.md +154 -0
- package/guide/zh_CN/data_management/property_early_init.md +31 -0
- package/guide/zh_CN/data_management/pure_data_pattern.md +21 -0
- package/guide/zh_CN/index.md +93 -0
- package/guide/zh_CN/interaction/behavior.md +52 -0
- package/guide/zh_CN/interaction/component_path.md +37 -0
- package/guide/zh_CN/interaction/generic.md +73 -0
- package/guide/zh_CN/interaction/placeholder.md +40 -0
- package/guide/zh_CN/interaction/relation.md +151 -0
- package/guide/zh_CN/interaction/slot.md +137 -0
- package/guide/zh_CN/interaction/template_import.md +94 -0
- package/guide/zh_CN/interaction/trait_behavior.md +117 -0
- package/guide/zh_CN/styling/external_class.md +46 -0
- package/guide/zh_CN/styling/style_isolation.md +54 -0
- package/guide/zh_CN/styling/virtual_host.md +52 -0
- package/guide/zh_CN/tree/element_iterator.md +54 -0
- package/guide/zh_CN/tree/mutation_observer.md +52 -0
- package/guide/zh_CN/tree/node_tree.md +142 -0
- package/guide/zh_CN/tree/node_tree_modification.md +78 -0
- package/guide/zh_CN/tree/selector.md +66 -0
- package/jest.config.js +6 -0
- package/jest.dts.config.js +9 -0
- package/jest.unit.config.js +14 -0
- package/package.json +28 -0
- package/src/backend/backend_protocol.ts +313 -0
- package/src/backend/composed_backend_protocol.ts +252 -0
- package/src/backend/domlike_backend_protocol.ts +370 -0
- package/src/backend/mode.ts +51 -0
- package/src/backend/suggested_backend_protocol.ts +83 -0
- package/src/behavior.ts +1655 -0
- package/src/bootstrap_dom_dev.js +22 -0
- package/src/class_list.ts +376 -0
- package/src/component.ts +1309 -0
- package/src/component_params.ts +461 -0
- package/src/component_space.ts +547 -0
- package/src/data_path.ts +225 -0
- package/src/data_proxy.ts +670 -0
- package/src/data_utils.ts +50 -0
- package/src/element.ts +1966 -0
- package/src/element_iterator.ts +158 -0
- package/src/event.ts +401 -0
- package/src/external_shadow_tree.ts +27 -0
- package/src/func_arr.ts +198 -0
- package/src/global_options.ts +242 -0
- package/src/index.ts +187 -0
- package/src/mutation_observer.ts +252 -0
- package/src/native_node.ts +74 -0
- package/src/node.ts +174 -0
- package/src/relation.ts +380 -0
- package/src/render.ts +25 -0
- package/src/selector.ts +218 -0
- package/src/shadow_root.ts +766 -0
- package/src/template_engine.ts +45 -0
- package/src/text_node.ts +149 -0
- package/src/tmpl/index.ts +199 -0
- package/src/tmpl/native_rendering.ts +175 -0
- package/src/tmpl/proc_gen_wrapper.ts +954 -0
- package/src/tmpl/proc_gen_wrapper_dom.ts +230 -0
- package/src/tmpl/range_list_diff.ts +443 -0
- package/src/trait_behaviors.ts +51 -0
- package/src/virtual_node.ts +51 -0
- package/tests/backend/domlike.test.ts +254 -0
- package/tests/base/env.ts +78 -0
- package/tests/base/match.ts +185 -0
- package/tests/core/backend.test.ts +144 -0
- package/tests/core/behavior.test.ts +546 -0
- package/tests/core/component_space.test.ts +212 -0
- package/tests/core/data_update.test.ts +461 -0
- package/tests/core/misc.test.ts +339 -0
- package/tests/core/placeholder.test.ts +180 -0
- package/tests/core/slot.test.ts +1495 -0
- package/tests/core/trait_behaviors.test.ts +153 -0
- package/tests/legacy/README.md +3 -0
- package/tests/legacy/behavior.test.js +293 -0
- package/tests/legacy/component.test.js +1247 -0
- package/tests/legacy/data_path.test.js +149 -0
- package/tests/legacy/data_proxy.test.js +759 -0
- package/tests/legacy/element_iterator.test.js +148 -0
- package/tests/legacy/event.test.js +849 -0
- package/tests/legacy/external.test.js +510 -0
- package/tests/legacy/extra_info.test.js +109 -0
- package/tests/legacy/generics.test.js +176 -0
- package/tests/legacy/mutation_observer.test.js +210 -0
- package/tests/legacy/relation.test.js +517 -0
- package/tests/legacy/selector.test.js +263 -0
- package/tests/legacy/slot.test.js +915 -0
- package/tests/legacy/virtual.test.js +394 -0
- package/tests/tmpl/binding_map.test.ts +208 -0
- package/tests/tmpl/event.test.ts +206 -0
- package/tests/tmpl/expression.test.ts +429 -0
- package/tests/tmpl/lvalue.test.ts +160 -0
- package/tests/tmpl/native_rendering.test.ts +155 -0
- package/tests/tmpl/structure.test.ts +998 -0
- package/tests/types/chaining.test.ts +614 -0
- package/tests/types/createElement.test.ts +82 -0
- package/tests/types/definition.test.ts +442 -0
- package/tsconfig.json +11 -0
- package/webpack.config.js +270 -0
|
@@ -0,0 +1,442 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/ban-ts-comment */
|
|
2
|
+
import { expectType } from 'tsd'
|
|
3
|
+
import * as glassEasel from '../../src'
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Properties
|
|
7
|
+
*/
|
|
8
|
+
glassEasel.registerElement({
|
|
9
|
+
properties: {
|
|
10
|
+
propStr: String,
|
|
11
|
+
propNum: Number,
|
|
12
|
+
propBool: Boolean,
|
|
13
|
+
propObj: Object,
|
|
14
|
+
propObjFoo: {
|
|
15
|
+
value: { foo: 'foo' },
|
|
16
|
+
},
|
|
17
|
+
propObjBar: {
|
|
18
|
+
default: () => ({ bar: 'bar' }),
|
|
19
|
+
},
|
|
20
|
+
propFunc: Function,
|
|
21
|
+
propFuncFoo: {
|
|
22
|
+
type: Function,
|
|
23
|
+
value: () => 'foo',
|
|
24
|
+
},
|
|
25
|
+
propArr: Array,
|
|
26
|
+
propArrBooks: {
|
|
27
|
+
value: [] as { name: string }[],
|
|
28
|
+
},
|
|
29
|
+
|
|
30
|
+
propOptional: {
|
|
31
|
+
type: String,
|
|
32
|
+
optionalTypes: [Number, Boolean],
|
|
33
|
+
},
|
|
34
|
+
propOptionalFoo: {
|
|
35
|
+
type: String,
|
|
36
|
+
optionalTypes: [Number, Boolean],
|
|
37
|
+
value: 'foo',
|
|
38
|
+
},
|
|
39
|
+
|
|
40
|
+
invalid: {
|
|
41
|
+
type: String,
|
|
42
|
+
value: 123,
|
|
43
|
+
},
|
|
44
|
+
|
|
45
|
+
propNull: null,
|
|
46
|
+
},
|
|
47
|
+
created() {
|
|
48
|
+
expectType<string>(this.data.propStr)
|
|
49
|
+
expectType<number>(this.data.propNum)
|
|
50
|
+
expectType<boolean>(this.data.propBool)
|
|
51
|
+
expectType<Readonly<Record<string, any>> | null>(this.data.propObj)
|
|
52
|
+
expectType<{ readonly foo: string }>(this.data.propObjFoo)
|
|
53
|
+
expectType<string>(this.data.propObjFoo.foo)
|
|
54
|
+
expectType<{ readonly bar: string }>(this.data.propObjBar)
|
|
55
|
+
expectType<string>(this.data.propObjBar.bar)
|
|
56
|
+
expectType<(...args: any[]) => any>(this.data.propFunc)
|
|
57
|
+
expectType<() => 'foo'>(this.data.propFuncFoo)
|
|
58
|
+
expectType<readonly any[]>(this.data.propArr)
|
|
59
|
+
expectType<readonly { readonly name: string }[]>(this.data.propArrBooks)
|
|
60
|
+
expectType<any>(this.data.propNull)
|
|
61
|
+
|
|
62
|
+
expectType<string | number | boolean>(this.data.propOptional)
|
|
63
|
+
expectType<string | number | boolean>(this.data.propOptionalFoo)
|
|
64
|
+
|
|
65
|
+
expectType<never>(this.data.invalid)
|
|
66
|
+
|
|
67
|
+
// @ts-expect-error
|
|
68
|
+
expectType<any>(this.data.nonExists)
|
|
69
|
+
|
|
70
|
+
// @ts-expect-error
|
|
71
|
+
this.data.propStr = '123'
|
|
72
|
+
// @ts-expect-error
|
|
73
|
+
this.data.propObjFoo.foo = '123'
|
|
74
|
+
},
|
|
75
|
+
})
|
|
76
|
+
|
|
77
|
+
// glassEasel.registerElement({
|
|
78
|
+
// properties: {
|
|
79
|
+
// invalid: {
|
|
80
|
+
// // @ts-expect-error
|
|
81
|
+
// type: '123',
|
|
82
|
+
// // @ts-expect-error
|
|
83
|
+
// optionalTypes: {},
|
|
84
|
+
// // @ts-expect-error
|
|
85
|
+
// observer: true,
|
|
86
|
+
// },
|
|
87
|
+
// },
|
|
88
|
+
// })
|
|
89
|
+
|
|
90
|
+
glassEasel.registerElement({
|
|
91
|
+
created() {
|
|
92
|
+
// @ts-expect-error
|
|
93
|
+
expectType<any>(this.data.non_exists)
|
|
94
|
+
},
|
|
95
|
+
})
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Data
|
|
99
|
+
*/
|
|
100
|
+
glassEasel.registerElement({
|
|
101
|
+
data: {
|
|
102
|
+
str: '123',
|
|
103
|
+
num: 123,
|
|
104
|
+
bool: true,
|
|
105
|
+
foo: {
|
|
106
|
+
foo: 'foo',
|
|
107
|
+
},
|
|
108
|
+
func: () => 'foo',
|
|
109
|
+
arr: [1],
|
|
110
|
+
books: [{ name: 'book' }],
|
|
111
|
+
},
|
|
112
|
+
created() {
|
|
113
|
+
expectType<string>(this.data.str)
|
|
114
|
+
expectType<number>(this.data.num)
|
|
115
|
+
expectType<boolean>(this.data.bool)
|
|
116
|
+
expectType<{ readonly foo: string }>(this.data.foo)
|
|
117
|
+
expectType<() => 'foo'>(this.data.func)
|
|
118
|
+
expectType<readonly number[]>(this.data.arr)
|
|
119
|
+
expectType<readonly { readonly name: string }[]>(this.data.books)
|
|
120
|
+
|
|
121
|
+
// @ts-expect-error
|
|
122
|
+
expectType<any>(this.data.nonExists)
|
|
123
|
+
|
|
124
|
+
// @ts-expect-error
|
|
125
|
+
this.data.str = '123'
|
|
126
|
+
// @ts-expect-error
|
|
127
|
+
this.data.foo.foo = '123'
|
|
128
|
+
},
|
|
129
|
+
})
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* SetData
|
|
133
|
+
*/
|
|
134
|
+
glassEasel.registerElement({
|
|
135
|
+
properties: {
|
|
136
|
+
propStr: String,
|
|
137
|
+
},
|
|
138
|
+
data: {
|
|
139
|
+
str: '123',
|
|
140
|
+
},
|
|
141
|
+
created() {
|
|
142
|
+
this.setData({ propStr: '123' })
|
|
143
|
+
|
|
144
|
+
this.setData({ str: '123' })
|
|
145
|
+
|
|
146
|
+
// @ts-expect-error
|
|
147
|
+
this.setData({ propStr: 123 })
|
|
148
|
+
// @ts-expect-error
|
|
149
|
+
this.setData({ str: 123 })
|
|
150
|
+
// @ts-expect-error
|
|
151
|
+
this.setData({ propStr: null })
|
|
152
|
+
// @ts-expect-error
|
|
153
|
+
this.setData({ str: null })
|
|
154
|
+
// @ts-expect-error
|
|
155
|
+
this.setData({ 'propStr.length': 123 })
|
|
156
|
+
// @ts-expect-error
|
|
157
|
+
this.setData({ 'str.length': 123 })
|
|
158
|
+
// @ts-expect-error
|
|
159
|
+
this.setData({ 'propStr[0]': 123 })
|
|
160
|
+
// @ts-expect-error
|
|
161
|
+
this.setData({ 'str[0]': 123 })
|
|
162
|
+
},
|
|
163
|
+
})
|
|
164
|
+
|
|
165
|
+
glassEasel.registerElement({
|
|
166
|
+
properties: {
|
|
167
|
+
propNum: Number,
|
|
168
|
+
},
|
|
169
|
+
data: {
|
|
170
|
+
num: 123,
|
|
171
|
+
},
|
|
172
|
+
created() {
|
|
173
|
+
this.setData({ propNum: 123 })
|
|
174
|
+
|
|
175
|
+
this.setData({ num: 123 })
|
|
176
|
+
|
|
177
|
+
// @ts-expect-error
|
|
178
|
+
this.setData({ propNum: '123' })
|
|
179
|
+
// @ts-expect-error
|
|
180
|
+
this.setData({ num: '123' })
|
|
181
|
+
// @ts-expect-error
|
|
182
|
+
this.setData({ propNum: null })
|
|
183
|
+
// @ts-expect-error
|
|
184
|
+
this.setData({ num: null })
|
|
185
|
+
// @ts-expect-error
|
|
186
|
+
this.setData({ 'propNum.length': 123 })
|
|
187
|
+
// @ts-expect-error
|
|
188
|
+
this.setData({ 'num.length': 123 })
|
|
189
|
+
// @ts-expect-error
|
|
190
|
+
this.setData({ 'propNum[0]': 123 })
|
|
191
|
+
// @ts-expect-error
|
|
192
|
+
this.setData({ 'num[0]': 123 })
|
|
193
|
+
},
|
|
194
|
+
})
|
|
195
|
+
|
|
196
|
+
glassEasel.registerElement({
|
|
197
|
+
properties: {
|
|
198
|
+
propBool: Boolean,
|
|
199
|
+
},
|
|
200
|
+
data: {
|
|
201
|
+
bool: true,
|
|
202
|
+
},
|
|
203
|
+
created() {
|
|
204
|
+
this.setData({ propBool: true })
|
|
205
|
+
|
|
206
|
+
this.setData({ bool: true })
|
|
207
|
+
|
|
208
|
+
// @ts-expect-error
|
|
209
|
+
this.setData({ propBool: 0 })
|
|
210
|
+
// @ts-expect-error
|
|
211
|
+
this.setData({ bool: 0 })
|
|
212
|
+
// @ts-expect-error
|
|
213
|
+
this.setData({ propBool: null })
|
|
214
|
+
// @ts-expect-error
|
|
215
|
+
this.setData({ bool: null })
|
|
216
|
+
// @ts-expect-error
|
|
217
|
+
this.setData({ 'propBool.length': 123 })
|
|
218
|
+
// @ts-expect-error
|
|
219
|
+
this.setData({ 'bool.length': 123 })
|
|
220
|
+
// @ts-expect-error
|
|
221
|
+
this.setData({ 'propBool[0]': 123 })
|
|
222
|
+
// @ts-expect-error
|
|
223
|
+
this.setData({ 'bool[0]': 123 })
|
|
224
|
+
},
|
|
225
|
+
})
|
|
226
|
+
|
|
227
|
+
glassEasel.registerElement({
|
|
228
|
+
properties: {
|
|
229
|
+
propObj: Object,
|
|
230
|
+
},
|
|
231
|
+
data: {
|
|
232
|
+
obj: {} as Record<string, any> | null,
|
|
233
|
+
},
|
|
234
|
+
created() {
|
|
235
|
+
this.setData({ propObj: {} })
|
|
236
|
+
this.setData({ propObj: null })
|
|
237
|
+
this.setData({ 'propObj.foo': 123 })
|
|
238
|
+
|
|
239
|
+
this.setData({ obj: {} })
|
|
240
|
+
this.setData({ obj: null })
|
|
241
|
+
this.setData({ 'obj.foo': 123 })
|
|
242
|
+
|
|
243
|
+
// @ts-expect-error
|
|
244
|
+
this.setData({ propObj: 0 })
|
|
245
|
+
// @ts-expect-error
|
|
246
|
+
this.setData({ obj: 0 })
|
|
247
|
+
// @ts-expect-error
|
|
248
|
+
this.setData({ 'propObj[0]': 123 })
|
|
249
|
+
// @ts-expect-error
|
|
250
|
+
this.setData({ 'obj[0]': 123 })
|
|
251
|
+
},
|
|
252
|
+
})
|
|
253
|
+
|
|
254
|
+
glassEasel.registerElement({
|
|
255
|
+
properties: {
|
|
256
|
+
propObjFoo: {
|
|
257
|
+
type: Object,
|
|
258
|
+
value: { foo: 'foo' },
|
|
259
|
+
},
|
|
260
|
+
},
|
|
261
|
+
data: {
|
|
262
|
+
foo: { foo: 'foo' },
|
|
263
|
+
},
|
|
264
|
+
created() {
|
|
265
|
+
this.setData({ propObjFoo: { foo: 'foo' } })
|
|
266
|
+
this.setData({ 'propObjFoo.foo': '123' })
|
|
267
|
+
|
|
268
|
+
this.setData({ foo: { foo: 'foo' } })
|
|
269
|
+
this.setData({ 'foo.foo': '123' })
|
|
270
|
+
|
|
271
|
+
// @ts-expect-error
|
|
272
|
+
this.setData({ propObjFoo: null })
|
|
273
|
+
// @ts-expect-error
|
|
274
|
+
this.setData({ foo: null })
|
|
275
|
+
// @ts-expect-error
|
|
276
|
+
this.setData({ propObjFoo: 0 })
|
|
277
|
+
// @ts-expect-error
|
|
278
|
+
this.setData({ foo: 0 })
|
|
279
|
+
// @ts-expect-error
|
|
280
|
+
this.setData({ propObjFoo: { foo: 'foo', bar: 'bar' } })
|
|
281
|
+
// @ts-expect-error
|
|
282
|
+
this.setData({ foo: { foo: 'foo', bar: 'bar' } })
|
|
283
|
+
// @ts-expect-error
|
|
284
|
+
this.setData({ 'propObjFoo[0]': 123 })
|
|
285
|
+
// @ts-expect-error
|
|
286
|
+
this.setData({ 'foo[0]': 123 })
|
|
287
|
+
// @ts-expect-error
|
|
288
|
+
this.setData({ 'propObjFoo.foo': 123 })
|
|
289
|
+
// @ts-expect-error
|
|
290
|
+
this.setData({ 'foo.foo': 123 })
|
|
291
|
+
// @ts-expect-error
|
|
292
|
+
this.setData({ 'propObjFoo.nonExists': 123 })
|
|
293
|
+
// @ts-expect-error
|
|
294
|
+
this.setData({ 'foo.nonExists': 123 })
|
|
295
|
+
},
|
|
296
|
+
})
|
|
297
|
+
|
|
298
|
+
glassEasel.registerElement({
|
|
299
|
+
properties: {
|
|
300
|
+
propFunc: {
|
|
301
|
+
type: Function,
|
|
302
|
+
value: () => 'foo',
|
|
303
|
+
},
|
|
304
|
+
},
|
|
305
|
+
data: {
|
|
306
|
+
func: () => 'foo',
|
|
307
|
+
},
|
|
308
|
+
created() {
|
|
309
|
+
this.setData({ propFunc: () => 'foo' })
|
|
310
|
+
|
|
311
|
+
this.setData({ func: () => 'foo' })
|
|
312
|
+
|
|
313
|
+
// @ts-expect-error
|
|
314
|
+
this.setData({ propFunc: null })
|
|
315
|
+
// @ts-expect-error
|
|
316
|
+
this.setData({ func: null })
|
|
317
|
+
// @ts-expect-error
|
|
318
|
+
this.setData({ propFunc: 0 })
|
|
319
|
+
// @ts-expect-error
|
|
320
|
+
this.setData({ func: 0 })
|
|
321
|
+
// @ts-expect-error
|
|
322
|
+
this.setData({ propFunc: (_: any) => 'foo' })
|
|
323
|
+
// @ts-expect-error
|
|
324
|
+
this.setData({ func: (_: any) => 'foo' })
|
|
325
|
+
// @ts-expect-error
|
|
326
|
+
this.setData({ 'propFunc[0]': 123 })
|
|
327
|
+
// @ts-expect-error
|
|
328
|
+
this.setData({ 'func[0]': 123 })
|
|
329
|
+
// @ts-expect-error
|
|
330
|
+
this.setData({ 'propFunc.foo': 123 })
|
|
331
|
+
// @ts-expect-error
|
|
332
|
+
this.setData({ 'func.foo': 123 })
|
|
333
|
+
},
|
|
334
|
+
})
|
|
335
|
+
|
|
336
|
+
glassEasel.registerElement({
|
|
337
|
+
properties: {
|
|
338
|
+
propArr: Array,
|
|
339
|
+
},
|
|
340
|
+
data: {
|
|
341
|
+
arr: [] as any[],
|
|
342
|
+
},
|
|
343
|
+
created() {
|
|
344
|
+
this.setData({ propArr: [] })
|
|
345
|
+
this.setData({ propArr: [1, 'foo', true, {}, null, undefined] })
|
|
346
|
+
this.setData({ 'propArr[0]': 123 })
|
|
347
|
+
this.setData({ 'propArr[0].foo': 'foo' })
|
|
348
|
+
|
|
349
|
+
this.setData({ arr: [] })
|
|
350
|
+
this.setData({ arr: [1, 'foo', true, {}, null, undefined] })
|
|
351
|
+
this.setData({ 'arr[0]': 123 })
|
|
352
|
+
this.setData({ 'arr[0].foo': 'foo' })
|
|
353
|
+
|
|
354
|
+
// @ts-expect-error
|
|
355
|
+
this.setData({ propArr: null })
|
|
356
|
+
// @ts-expect-error
|
|
357
|
+
this.setData({ arr: null })
|
|
358
|
+
// @ts-expect-error
|
|
359
|
+
this.setData({ propArr: 0 })
|
|
360
|
+
// @ts-expect-error
|
|
361
|
+
this.setData({ arr: 0 })
|
|
362
|
+
// @ts-expect-error
|
|
363
|
+
this.setData({ 'propArr.foo': 123 })
|
|
364
|
+
// @ts-expect-error
|
|
365
|
+
this.setData({ 'arr.foo': 123 })
|
|
366
|
+
},
|
|
367
|
+
})
|
|
368
|
+
|
|
369
|
+
glassEasel.registerElement({
|
|
370
|
+
properties: {
|
|
371
|
+
propArrObj: {
|
|
372
|
+
type: Array,
|
|
373
|
+
value: [{ name: 'book' }],
|
|
374
|
+
},
|
|
375
|
+
},
|
|
376
|
+
data: {
|
|
377
|
+
arrObj: [{ name: 'book' }],
|
|
378
|
+
},
|
|
379
|
+
created() {
|
|
380
|
+
this.setData({ propArrObj: [] })
|
|
381
|
+
this.setData({ propArrObj: [{ name: '123' }, { name: '233' }] })
|
|
382
|
+
this.setData({ 'propArrObj[0]': { name: 'foo' } })
|
|
383
|
+
this.setData({ 'propArrObj[0].name': 'foo' })
|
|
384
|
+
|
|
385
|
+
this.setData({ arrObj: [] })
|
|
386
|
+
this.setData({ arrObj: [{ name: '123' }, { name: '233' }] })
|
|
387
|
+
this.setData({ 'arrObj[0]': { name: 'foo' } })
|
|
388
|
+
this.setData({ 'arrObj[0].name': 'foo' })
|
|
389
|
+
|
|
390
|
+
// @ts-expect-error
|
|
391
|
+
this.setData({ propArrObj: null })
|
|
392
|
+
// @ts-expect-error
|
|
393
|
+
this.setData({ arrObj: null })
|
|
394
|
+
// @ts-expect-error
|
|
395
|
+
this.setData({ propArrObj: 0 })
|
|
396
|
+
// @ts-expect-error
|
|
397
|
+
this.setData({ arrObj: 0 })
|
|
398
|
+
// @ts-expect-error
|
|
399
|
+
this.setData({ 'propArrObj.foo': 123 })
|
|
400
|
+
// @ts-expect-error
|
|
401
|
+
this.setData({ 'arrObj.foo': 123 })
|
|
402
|
+
// @ts-expect-error
|
|
403
|
+
this.setData({ 'propArrObj[0].name': 123 })
|
|
404
|
+
// @ts-expect-error
|
|
405
|
+
this.setData({ 'arrObj[0].name': 123 })
|
|
406
|
+
// @ts-expect-error
|
|
407
|
+
this.setData({ 'propArrObj[0].nonExists': 'foo' })
|
|
408
|
+
// @ts-expect-error
|
|
409
|
+
this.setData({ 'arrObj[0].nonExists': 'foo' })
|
|
410
|
+
},
|
|
411
|
+
})
|
|
412
|
+
|
|
413
|
+
/**
|
|
414
|
+
* Methods
|
|
415
|
+
*/
|
|
416
|
+
glassEasel.registerElement({
|
|
417
|
+
methods: {
|
|
418
|
+
sum(a: number, b: number) {
|
|
419
|
+
return a + b
|
|
420
|
+
},
|
|
421
|
+
foo() {
|
|
422
|
+
//
|
|
423
|
+
},
|
|
424
|
+
bar() {
|
|
425
|
+
expectType<void>(this.bar())
|
|
426
|
+
expectType<void>(this.foo())
|
|
427
|
+
expectType<number>(this.sum(1, 2))
|
|
428
|
+
|
|
429
|
+
// @ts-expect-error
|
|
430
|
+
this.bar(1)
|
|
431
|
+
// @ts-expect-error
|
|
432
|
+
this.foo(1)
|
|
433
|
+
// @ts-expect-error
|
|
434
|
+
this.sum()
|
|
435
|
+
// @ts-expect-error
|
|
436
|
+
this.sum('1', '2')
|
|
437
|
+
// @ts-expect-error
|
|
438
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
|
|
439
|
+
this.nonExists()
|
|
440
|
+
},
|
|
441
|
+
},
|
|
442
|
+
})
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
|
|
3
|
+
const path = require('path')
|
|
4
|
+
const webpack = require('webpack')
|
|
5
|
+
const { RawSource } = require('webpack-sources')
|
|
6
|
+
|
|
7
|
+
const jobs = []
|
|
8
|
+
let mainJobOutput = null
|
|
9
|
+
let minimize = null
|
|
10
|
+
let dev = false
|
|
11
|
+
const args = process.env['GLASS_EASEL_ARGS'] || ''
|
|
12
|
+
args.split(' ').forEach((arg) => {
|
|
13
|
+
if (!arg) return
|
|
14
|
+
if (arg[0] === '-') {
|
|
15
|
+
if (arg === '--minimize') minimize = true
|
|
16
|
+
else if (arg === '--no-minimize') minimize = false
|
|
17
|
+
else if (arg === '--dev') dev = true
|
|
18
|
+
} else {
|
|
19
|
+
jobs.push(arg)
|
|
20
|
+
}
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
const genOutputName = (jobExt) => `glass_easel.${jobExt}${dev ? '.dev' : ''}.js`
|
|
24
|
+
|
|
25
|
+
const mode = dev ? 'development' : 'production'
|
|
26
|
+
|
|
27
|
+
const rules = [
|
|
28
|
+
{
|
|
29
|
+
test: /\.ts$/,
|
|
30
|
+
loader: 'ts-loader',
|
|
31
|
+
exclude: /node_modules/,
|
|
32
|
+
},
|
|
33
|
+
]
|
|
34
|
+
|
|
35
|
+
const optimization = {
|
|
36
|
+
minimize: minimize === null ? undefined : minimize,
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const devtool = 'source-map'
|
|
40
|
+
|
|
41
|
+
const resolve = {
|
|
42
|
+
extensions: [ '.ts', '.js' ],
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const performance = {
|
|
46
|
+
maxEntrypointSize: 512000,
|
|
47
|
+
maxAssetSize: 512000,
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
class BundleDeclarationEntrancePlugin {
|
|
51
|
+
apply(compiler) {
|
|
52
|
+
compiler.hooks.compilation.tap('BundleDeclarationEntrancePlugin', (compilation, compilationParams) => {
|
|
53
|
+
compilation.hooks.additionalAssets.tapPromise('ExtraAssetPlugin', async () => {
|
|
54
|
+
Object.keys(compilation.assets).forEach((file) => {
|
|
55
|
+
if (file.endsWith('.js')) {
|
|
56
|
+
const dtsFile = file.replace(/\.js$/, '.d.ts')
|
|
57
|
+
compilation.assets[dtsFile] = new RawSource('export * from "./types/src/index"')
|
|
58
|
+
}
|
|
59
|
+
})
|
|
60
|
+
if (mainJobOutput) {
|
|
61
|
+
compilation.assets['index.js'] = new RawSource(`module.exports = require('./${mainJobOutput}')`)
|
|
62
|
+
compilation.assets['index.d.ts'] = new RawSource(`export * from "./${mainJobOutput}"`)
|
|
63
|
+
}
|
|
64
|
+
})
|
|
65
|
+
})
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const globalPlugins = [new BundleDeclarationEntrancePlugin()]
|
|
70
|
+
|
|
71
|
+
const allCompilation = {
|
|
72
|
+
mode,
|
|
73
|
+
output: {
|
|
74
|
+
path: path.resolve(__dirname, 'dist'),
|
|
75
|
+
filename: genOutputName('all'),
|
|
76
|
+
libraryTarget: 'commonjs2',
|
|
77
|
+
},
|
|
78
|
+
optimization,
|
|
79
|
+
devtool,
|
|
80
|
+
module: {
|
|
81
|
+
rules,
|
|
82
|
+
},
|
|
83
|
+
resolve,
|
|
84
|
+
performance,
|
|
85
|
+
plugins: [
|
|
86
|
+
new webpack.DefinePlugin({
|
|
87
|
+
'BM.DYNAMIC': true,
|
|
88
|
+
'BM.SHADOW': false,
|
|
89
|
+
'BM.COMPOSED': false,
|
|
90
|
+
'BM.DOMLIKE': false,
|
|
91
|
+
}),
|
|
92
|
+
...globalPlugins
|
|
93
|
+
],
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
const shadowCompilation = {
|
|
97
|
+
mode,
|
|
98
|
+
output: {
|
|
99
|
+
path: path.resolve(__dirname, 'dist'),
|
|
100
|
+
filename: genOutputName('shadow'),
|
|
101
|
+
libraryTarget: 'commonjs2',
|
|
102
|
+
},
|
|
103
|
+
optimization,
|
|
104
|
+
devtool,
|
|
105
|
+
module: {
|
|
106
|
+
rules,
|
|
107
|
+
},
|
|
108
|
+
resolve,
|
|
109
|
+
performance,
|
|
110
|
+
plugins: [
|
|
111
|
+
new webpack.DefinePlugin({
|
|
112
|
+
'BM.DYNAMIC': false,
|
|
113
|
+
'BM.SHADOW': true,
|
|
114
|
+
'BM.COMPOSED': false,
|
|
115
|
+
'BM.DOMLIKE': false,
|
|
116
|
+
}),
|
|
117
|
+
...globalPlugins
|
|
118
|
+
],
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
const shadowGlobalCompilation = {
|
|
122
|
+
mode,
|
|
123
|
+
output: {
|
|
124
|
+
path: path.resolve(__dirname, 'dist'),
|
|
125
|
+
filename: genOutputName('shadow.global'),
|
|
126
|
+
libraryTarget: 'var',
|
|
127
|
+
library: 'glassEasel',
|
|
128
|
+
},
|
|
129
|
+
optimization,
|
|
130
|
+
devtool,
|
|
131
|
+
module: {
|
|
132
|
+
rules,
|
|
133
|
+
},
|
|
134
|
+
resolve,
|
|
135
|
+
performance,
|
|
136
|
+
plugins: [
|
|
137
|
+
new webpack.DefinePlugin({
|
|
138
|
+
'BM.DYNAMIC': false,
|
|
139
|
+
'BM.SHADOW': true,
|
|
140
|
+
'BM.COMPOSED': false,
|
|
141
|
+
'BM.DOMLIKE': false,
|
|
142
|
+
}),
|
|
143
|
+
...globalPlugins
|
|
144
|
+
],
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
const composedCompilation = {
|
|
148
|
+
mode,
|
|
149
|
+
output: {
|
|
150
|
+
path: path.resolve(__dirname, 'dist'),
|
|
151
|
+
filename: genOutputName('composed'),
|
|
152
|
+
libraryTarget: 'commonjs2',
|
|
153
|
+
},
|
|
154
|
+
optimization,
|
|
155
|
+
devtool,
|
|
156
|
+
module: {
|
|
157
|
+
rules,
|
|
158
|
+
},
|
|
159
|
+
resolve,
|
|
160
|
+
performance,
|
|
161
|
+
plugins: [
|
|
162
|
+
new webpack.DefinePlugin({
|
|
163
|
+
'BM.DYNAMIC': false,
|
|
164
|
+
'BM.SHADOW': false,
|
|
165
|
+
'BM.COMPOSED': true,
|
|
166
|
+
'BM.DOMLIKE': false,
|
|
167
|
+
}),
|
|
168
|
+
...globalPlugins
|
|
169
|
+
],
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
const composedGlobalCompilation = {
|
|
173
|
+
mode,
|
|
174
|
+
output: {
|
|
175
|
+
path: path.resolve(__dirname, 'dist'),
|
|
176
|
+
filename: genOutputName('composed.global'),
|
|
177
|
+
libraryTarget: 'var',
|
|
178
|
+
library: 'glassEasel',
|
|
179
|
+
},
|
|
180
|
+
optimization,
|
|
181
|
+
devtool,
|
|
182
|
+
module: {
|
|
183
|
+
rules,
|
|
184
|
+
},
|
|
185
|
+
resolve,
|
|
186
|
+
performance,
|
|
187
|
+
plugins: [
|
|
188
|
+
new webpack.DefinePlugin({
|
|
189
|
+
'BM.DYNAMIC': false,
|
|
190
|
+
'BM.SHADOW': false,
|
|
191
|
+
'BM.COMPOSED': true,
|
|
192
|
+
'BM.DOMLIKE': false,
|
|
193
|
+
}),
|
|
194
|
+
...globalPlugins
|
|
195
|
+
],
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
const domlikeCompilation = {
|
|
199
|
+
mode,
|
|
200
|
+
output: {
|
|
201
|
+
path: path.resolve(__dirname, 'dist'),
|
|
202
|
+
filename: genOutputName('domlike'),
|
|
203
|
+
libraryTarget: 'commonjs2',
|
|
204
|
+
},
|
|
205
|
+
entry: dev ? './src/bootstrap_dom_dev.js' : './src/index.ts',
|
|
206
|
+
optimization,
|
|
207
|
+
devtool,
|
|
208
|
+
module: {
|
|
209
|
+
rules,
|
|
210
|
+
},
|
|
211
|
+
resolve,
|
|
212
|
+
performance,
|
|
213
|
+
plugins: [
|
|
214
|
+
new webpack.DefinePlugin({
|
|
215
|
+
'BM.DYNAMIC': false,
|
|
216
|
+
'BM.SHADOW': false,
|
|
217
|
+
'BM.COMPOSED': false,
|
|
218
|
+
'BM.DOMLIKE': true,
|
|
219
|
+
}),
|
|
220
|
+
...globalPlugins
|
|
221
|
+
],
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
const domlikeGlobalCompilation = {
|
|
225
|
+
mode,
|
|
226
|
+
output: {
|
|
227
|
+
path: path.resolve(__dirname, 'dist'),
|
|
228
|
+
filename: genOutputName('domlike.global'),
|
|
229
|
+
libraryTarget: 'var',
|
|
230
|
+
library: 'glassEasel',
|
|
231
|
+
},
|
|
232
|
+
entry: dev ? './src/bootstrap_dom_dev.js' : './src/index.ts',
|
|
233
|
+
optimization,
|
|
234
|
+
devtool,
|
|
235
|
+
module: {
|
|
236
|
+
rules,
|
|
237
|
+
},
|
|
238
|
+
resolve,
|
|
239
|
+
performance,
|
|
240
|
+
plugins: [
|
|
241
|
+
new webpack.DefinePlugin({
|
|
242
|
+
'BM.DYNAMIC': false,
|
|
243
|
+
'BM.SHADOW': false,
|
|
244
|
+
'BM.COMPOSED': false,
|
|
245
|
+
'BM.DOMLIKE': true,
|
|
246
|
+
}),
|
|
247
|
+
...globalPlugins
|
|
248
|
+
],
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
const defaultJobs = [allCompilation, domlikeGlobalCompilation]
|
|
252
|
+
|
|
253
|
+
if (jobs.length) {
|
|
254
|
+
module.exports = jobs.map((name) => {
|
|
255
|
+
const map = {
|
|
256
|
+
'all': allCompilation,
|
|
257
|
+
'shadow': shadowCompilation,
|
|
258
|
+
'shadow-global': shadowGlobalCompilation,
|
|
259
|
+
'composed': composedCompilation,
|
|
260
|
+
'composed-global': composedGlobalCompilation,
|
|
261
|
+
'domlike': domlikeCompilation,
|
|
262
|
+
'domlike-global': domlikeGlobalCompilation,
|
|
263
|
+
}
|
|
264
|
+
if (map[name]) return map[name]
|
|
265
|
+
throw new Error('Unknown job: ' + name)
|
|
266
|
+
})
|
|
267
|
+
} else {
|
|
268
|
+
module.exports = defaultJobs
|
|
269
|
+
}
|
|
270
|
+
mainJobOutput = module.exports[0]?.output.filename.slice(0, -3)
|