@htmlplus/element 0.1.1 → 0.1.4

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.
Files changed (91) hide show
  1. package/README.md +123 -25
  2. package/dist/client/decorators/attributes.js +5 -8
  3. package/dist/client/decorators/bind.d.ts +4 -1
  4. package/dist/client/decorators/bind.js +2 -3
  5. package/dist/client/decorators/element.js +115 -2
  6. package/dist/client/decorators/event.d.ts +20 -2
  7. package/dist/client/decorators/event.js +6 -6
  8. package/dist/client/decorators/index.js +0 -1
  9. package/dist/client/decorators/listen.d.ts +12 -2
  10. package/dist/client/decorators/listen.js +5 -10
  11. package/dist/client/decorators/method.d.ts +2 -1
  12. package/dist/client/decorators/method.js +9 -13
  13. package/dist/client/decorators/property.d.ts +12 -2
  14. package/dist/client/decorators/property.js +25 -18
  15. package/dist/client/decorators/state.d.ts +2 -1
  16. package/dist/client/decorators/state.js +19 -17
  17. package/dist/client/decorators/watch.js +3 -4
  18. package/dist/client/helpers/direction.d.ts +1 -1
  19. package/dist/client/helpers/direction.js +1 -1
  20. package/dist/client/helpers/index.d.ts +1 -3
  21. package/dist/client/helpers/index.js +1 -3
  22. package/dist/client/helpers/query-all.js +1 -1
  23. package/dist/client/helpers/query.js +1 -1
  24. package/dist/client/services/link.js +3 -3
  25. package/dist/client/utils/api.d.ts +5 -1
  26. package/dist/client/utils/append-to-method.d.ts +1 -0
  27. package/dist/client/utils/append-to-method.js +7 -0
  28. package/dist/client/{helpers → utils}/event.d.ts +0 -0
  29. package/dist/client/{helpers → utils}/event.js +0 -0
  30. package/dist/client/{helpers → utils}/host.d.ts +0 -0
  31. package/dist/client/{helpers → utils}/host.js +1 -1
  32. package/dist/client/utils/index.d.ts +4 -4
  33. package/dist/client/utils/index.js +4 -4
  34. package/dist/client/utils/on-ready.d.ts +1 -0
  35. package/dist/client/utils/on-ready.js +4 -0
  36. package/dist/client/utils/proxy.js +65 -25
  37. package/dist/client/utils/sync.js +3 -2
  38. package/dist/compiler/compiler.js +3 -3
  39. package/dist/compiler/index.d.ts +1 -2
  40. package/dist/compiler/index.js +1 -2
  41. package/dist/compiler/plugins/attach.js +7 -10
  42. package/dist/compiler/plugins/docs.js +1 -0
  43. package/dist/compiler/plugins/extract.js +14 -2
  44. package/dist/compiler/plugins/index.d.ts +1 -0
  45. package/dist/compiler/plugins/index.js +1 -0
  46. package/dist/compiler/plugins/react.proxy/index.d.ts +1 -0
  47. package/dist/compiler/plugins/react.proxy/index.js +1 -0
  48. package/dist/compiler/plugins/react.proxy/react.proxy.d.ts +9 -0
  49. package/dist/compiler/plugins/react.proxy/react.proxy.js +60 -0
  50. package/dist/compiler/plugins/react.proxy/templates/README.md.hbs +1 -0
  51. package/dist/compiler/plugins/react.proxy/templates/_.gitignore.hbs +2 -0
  52. package/dist/compiler/plugins/react.proxy/templates/package.json.hbs +36 -0
  53. package/dist/compiler/plugins/react.proxy/templates/rollup.config.js.hbs +20 -0
  54. package/dist/compiler/plugins/react.proxy/templates/src/components/index.ts.hbs +3 -0
  55. package/dist/compiler/plugins/react.proxy/templates/src/components/{{fileName}}.ts.hbs +38 -0
  56. package/dist/compiler/plugins/react.proxy/templates/src/index.ts.hbs +1 -0
  57. package/dist/compiler/plugins/react.proxy/templates/src/proxy.ts.hbs +277 -0
  58. package/dist/compiler/plugins/react.proxy/templates/tsconfig.json.hbs +17 -0
  59. package/dist/compiler/utils/__dirname.d.ts +1 -0
  60. package/dist/compiler/utils/__dirname.js +5 -0
  61. package/dist/compiler/utils/index.d.ts +3 -0
  62. package/dist/compiler/utils/index.js +3 -0
  63. package/dist/compiler/utils/is-directory-empty.d.ts +1 -0
  64. package/dist/compiler/utils/is-directory-empty.js +19 -0
  65. package/dist/compiler/utils/render-template.d.ts +1 -0
  66. package/dist/compiler/utils/render-template.js +25 -0
  67. package/dist/types/context.d.ts +2 -0
  68. package/dist/types/index.d.ts +0 -5
  69. package/dist/types/index.js +0 -5
  70. package/dist/types/plugin.d.ts +4 -3
  71. package/package.json +9 -6
  72. package/dist/client/decorators/listen-options.d.ts +0 -2
  73. package/dist/client/decorators/listen-options.js +0 -2
  74. package/dist/client/helpers/is-server.d.ts +0 -1
  75. package/dist/client/helpers/is-server.js +0 -1
  76. package/dist/client/utils/decorator.d.ts +0 -5
  77. package/dist/client/utils/decorator.js +0 -14
  78. package/dist/client/utils/define-element.d.ts +0 -1
  79. package/dist/client/utils/define-element.js +0 -7
  80. package/dist/client/utils/define-method.d.ts +0 -1
  81. package/dist/client/utils/define-method.js +0 -7
  82. package/dist/types/api.d.ts +0 -5
  83. package/dist/types/api.js +0 -1
  84. package/dist/types/direction.d.ts +0 -1
  85. package/dist/types/direction.js +0 -1
  86. package/dist/types/event-options.d.ts +0 -18
  87. package/dist/types/event-options.js +0 -1
  88. package/dist/types/listen-options.d.ts +0 -7
  89. package/dist/types/listen-options.js +0 -1
  90. package/dist/types/property-options.d.ts +0 -10
  91. package/dist/types/property-options.js +0 -1
@@ -0,0 +1,20 @@
1
+ import commonjs from '@rollup/plugin-commonjs';
2
+ import resolve from '@rollup/plugin-node-resolve';
3
+ import peerDepsExternal from 'rollup-plugin-peer-deps-external';
4
+ import typescript from 'rollup-plugin-typescript2';
5
+
6
+ export default {
7
+ input: 'src/index.ts',
8
+ output: [
9
+ {
10
+ dir: 'dist/components',
11
+ format: 'esm'
12
+ }
13
+ ],
14
+ plugins: [
15
+ peerDepsExternal(),
16
+ resolve(),
17
+ commonjs(),
18
+ typescript()
19
+ ]
20
+ };
@@ -0,0 +1,3 @@
1
+ {{#each groups}}
2
+ export * from './{{root.fileName}}';
3
+ {{/each}}
@@ -0,0 +1,38 @@
1
+ /* eslint-disable */
2
+ /* tslint:disable */
3
+ /* auto-generated */
4
+
5
+ import { proxy } from '../proxy';
6
+ import type { JSX } from '{{options.corePackageName}}';
7
+
8
+ {{#each all}}
9
+ import {{componentClassName}} from '{{../options.corePackageName}}/{{fileName}}';
10
+ {{/each}}
11
+
12
+ {{#each all}}
13
+ const {{componentClassName}} = /*@__PURE__*/ proxy<{{componentInterfaceName}}, JSX.{{componentClassName}}>(
14
+ '{{componentTag}}',
15
+ [
16
+ {{#each classProperties}}
17
+ '{{key.name}}',
18
+ {{/each}}
19
+ ],
20
+ [
21
+ {{#each classEvents}}
22
+ '{{key.name}}',
23
+ {{/each}}
24
+ ],
25
+ );
26
+
27
+ {{/each}}
28
+ {{#if single}}
29
+ export { {{root.componentClassName}} }
30
+ {{else}}
31
+ const All = /*@__PURE__*/ Object.assign({{root.componentClassName}}, {
32
+ {{#each filterd}}
33
+ {{componentClassNameInCategory}}: {{componentClassName}},
34
+ {{/each}}
35
+ });
36
+
37
+ export { All as {{root.componentClassName}} }
38
+ {{/if}}
@@ -0,0 +1 @@
1
+ export * from './components';
@@ -0,0 +1,277 @@
1
+ /**
2
+ * version 0.0.9
3
+ */
4
+ import { camelCase, paramCase, pascalCase } from 'change-case';
5
+ import React from 'react';
6
+
7
+ type EventHandlerType = (event: Event) => any;
8
+
9
+ type FinalPropsType<ElementType> = Omit<PropsType<ElementType>, 'forwardedRef'>;
10
+
11
+ type Mutable<T> = { -readonly [P in keyof T]-?: T[P] };
12
+
13
+ interface ExtraType {
14
+ props?: Array<string>;
15
+ events?: Array<string>;
16
+ }
17
+
18
+ interface PropsType<ElementType> extends React.HTMLAttributes<ElementType> {
19
+ forwardedRef: React.RefObject<ElementType>;
20
+ ref?: React.Ref<any>;
21
+ }
22
+
23
+ export interface StyleReactProps {
24
+ class?: string;
25
+ className?: string;
26
+ style?: {
27
+ [key: string]: any;
28
+ };
29
+ }
30
+
31
+ const arrayToMap = (array: string[] | DOMTokenList) => {
32
+ const map = new Map<string, string>();
33
+
34
+ (array as string[]).forEach((s: string) => map.set(s, s));
35
+
36
+ return map;
37
+ };
38
+
39
+ const getCustomEvent = (name: string, events: Array<string>) => {
40
+ // TODO
41
+ name = camelCase(name.slice(3));
42
+
43
+ const event = events.find((event) => event.endsWith(name));
44
+
45
+ if (!event) return;
46
+
47
+ return event;
48
+ };
49
+
50
+ const forwardRef = <ElementType, PropType>(ReactComponent: any) => {
51
+ const forwardRef = (
52
+ props: PropType & Omit<React.HTMLAttributes<ElementType>, 'style'> & StyleReactProps,
53
+ ref: React.Ref<ElementType>
54
+ ) => {
55
+ const { children, ...remainedProps } = props;
56
+
57
+ const newProps = {
58
+ ...remainedProps,
59
+ forwardedRef: ref
60
+ };
61
+
62
+ return React.createElement(ReactComponent, newProps, children);
63
+ };
64
+
65
+ forwardRef.displayName = ReactComponent.displayName;
66
+
67
+ return React.forwardRef(forwardRef);
68
+ };
69
+
70
+ const isEvent = (name: string) => {
71
+ return name.indexOf('on') === 0 && name[2] === name[2].toUpperCase();
72
+ };
73
+
74
+ const isPrimitive = (value: any) => {
75
+ const type = typeof value;
76
+
77
+ const match = type.match(/boolean|string|number/);
78
+
79
+ return match;
80
+ };
81
+
82
+ const getProps = <ElementType>(ref: React.Ref<ElementType>, props: PropsType<ElementType>, extra: ExtraType) => {
83
+ const { forwardedRef } = props;
84
+
85
+ const result: FinalPropsType<ElementType> = {
86
+ ref: mergeRefs(forwardedRef, ref)
87
+ };
88
+
89
+ Object.keys(props).forEach((name) => {
90
+ if (name === 'children' || name === 'className' || name === 'forwardedRef' || name === 'ref') return;
91
+
92
+ const value = props[name];
93
+
94
+ if (isEvent(name)) {
95
+ if (typeof document === 'undefined') return;
96
+
97
+ const event = getCustomEvent(name, extra.events);
98
+
99
+ if (event) return;
100
+
101
+ result[name] = value;
102
+ } else if (extra.props.includes(name)) {
103
+ if (!isPrimitive(value)) return;
104
+
105
+ result[paramCase(name)] = value;
106
+ } else {
107
+ result[name] = value;
108
+ }
109
+ });
110
+
111
+ return result;
112
+ };
113
+
114
+ const mergeRefs =
115
+ <ElementType>(...refs: React.Ref<ElementType>[]) =>
116
+ (value: ElementType) => {
117
+ return refs.forEach((ref) => {
118
+ if (typeof ref === 'function') return ref(value);
119
+
120
+ if (ref == null) return;
121
+
122
+ (ref as Mutable<React.RefObject<ElementType>>).current = value;
123
+ });
124
+ };
125
+
126
+ const setClass = <ElementType>(element: ElementType, props: PropsType<ElementType>) => {
127
+ const classes: string[] = [];
128
+
129
+ const current = arrayToMap((element as any).classList);
130
+
131
+ const prev: string = element['$class'];
132
+ const next: string = props.className || (props as any).class;
133
+
134
+ const prevClass = arrayToMap(prev ? prev.split(' ') : []);
135
+ const nextClass = arrayToMap(next ? next.split(' ') : []);
136
+
137
+ current.forEach((key) => {
138
+ if (nextClass.has(key)) {
139
+ classes.push(key);
140
+
141
+ nextClass.delete(key);
142
+ } else if (!prevClass.has(key)) {
143
+ classes.push(key);
144
+ }
145
+ });
146
+
147
+ nextClass.forEach((key) => classes.push(key));
148
+
149
+ const className = classes.join(' ');
150
+
151
+ (element as any).className = className;
152
+
153
+ element['$class'] = className;
154
+ };
155
+
156
+ const setEvent = (element: Element, name: string, handler: EventHandlerType) => {
157
+ const events = element['$events'] || (element['$events'] = {});
158
+
159
+ const previous = events[name];
160
+
161
+ previous && element.removeEventListener(name, previous);
162
+
163
+ function callback(event: Event) {
164
+ handler && handler.call(this, event);
165
+ }
166
+
167
+ element.addEventListener(name, (events[name] = callback));
168
+ };
169
+
170
+ const setProps = <ElementType>(element: ElementType, props: PropsType<ElementType>, extra: ExtraType) => {
171
+ if (!(element instanceof Element)) return;
172
+
173
+ setClass<ElementType>(element, props);
174
+
175
+ Object.keys(props).forEach((name) => {
176
+ if (
177
+ name === 'children' ||
178
+ name === 'class' ||
179
+ name === 'className' ||
180
+ name === 'forwardedRef' ||
181
+ name === 'ref' ||
182
+ name === 'style'
183
+ )
184
+ return;
185
+
186
+ const value = props[name];
187
+
188
+ if (isEvent(name)) {
189
+ if (typeof document === 'undefined') return;
190
+
191
+ const event = getCustomEvent(name, extra.events);
192
+
193
+ if (!event) return;
194
+
195
+ setEvent(element, event, value);
196
+ } else if (extra.props.includes(name)) {
197
+ if (isPrimitive(value)) {
198
+ element.setAttribute(paramCase(name), value);
199
+ } else {
200
+ element[name] = value;
201
+ }
202
+ } else {
203
+ element[name] = value;
204
+ }
205
+ });
206
+ };
207
+
208
+ export const proxy = <ElementType, PropType>(
209
+ tagName: string,
210
+ props: Array<string> = [],
211
+ events: Array<string> = []
212
+ ) => {
213
+ const extra: ExtraType = {
214
+ props,
215
+ events
216
+ };
217
+
218
+ const ReactComponent = class extends React.Component<PropsType<ElementType>> {
219
+ element!: ElementType;
220
+
221
+ setElement = (element: ElementType) => {
222
+ this.element = element;
223
+ };
224
+
225
+ constructor(props: PropsType<ElementType>) {
226
+ super(props);
227
+ }
228
+
229
+ componentDidMount() {
230
+ this.componentDidUpdate(/*this.props*/);
231
+ }
232
+
233
+ componentDidUpdate(/*prevProps: InternalProps<ElementType>*/) {
234
+ setProps<ElementType>(this.element as any, this.props, extra);
235
+ }
236
+
237
+ componentWillUnmount() {
238
+ if (!this.element) return;
239
+
240
+ const events = this.element['$events'] || {};
241
+
242
+ Object.keys(events).forEach((name) => {
243
+ const handler = events[name];
244
+
245
+ (this.element as any).removeEventListener(name, handler);
246
+ });
247
+
248
+ delete this.element['$events'];
249
+ }
250
+
251
+ render() {
252
+ const { children } = this.props;
253
+
254
+ const props = getProps<ElementType>(this.setElement, this.props, extra);
255
+
256
+ return React.createElement(tagName, props, children);
257
+ }
258
+ };
259
+
260
+ // TODO
261
+ // const ReactComponentNew = (props: InternalPropsType<ElementType>) => {
262
+
263
+ // const { children } = props;
264
+
265
+ // const ref = useRef(null);
266
+
267
+ // const newProps: FinalPropsType<ElementType> = getProps(ref, props, events);
268
+
269
+ // useEffect(() => setProps(ref.current, props, events));
270
+
271
+ // return React.createElement(tagName, newProps, children);
272
+ // }
273
+
274
+ ReactComponent['displayName'] = pascalCase(tagName);
275
+
276
+ return forwardRef<ElementType, PropType>(ReactComponent);
277
+ };
@@ -0,0 +1,17 @@
1
+ {
2
+ "compilerOptions": {
3
+ "experimentalDecorators": true,
4
+ "declaration": true,
5
+ "declarationDir": "dist",
6
+ "module": "esnext",
7
+ "target": "es5",
8
+ "lib": ["es6", "dom", "es2016", "es2017"],
9
+ "sourceMap": true,
10
+ "jsx": "react",
11
+ "moduleResolution": "node",
12
+ "allowSyntheticDefaultImports": true,
13
+ "esModuleInterop": true
14
+ },
15
+ "include": ["src"],
16
+ "exclude": ["dist", "node_modules"]
17
+ }
@@ -0,0 +1 @@
1
+ export declare const __dirname: (url: string | URL) => string;
@@ -0,0 +1,5 @@
1
+ import { dirname } from 'path';
2
+ import { fileURLToPath } from 'url';
3
+ export const __dirname = (url) => {
4
+ return dirname(fileURLToPath(url));
5
+ };
@@ -1,7 +1,10 @@
1
+ export * from './__dirname.js';
1
2
  export * from './get-initializer.js';
2
3
  export * from './get-tags.js';
3
4
  export * from './get-type.js';
4
5
  export * from './has-decorator.js';
6
+ export * from './is-directory-empty.js';
5
7
  export * from './print-type.js';
6
8
  export * from './print.js';
9
+ export * from './render-template.js';
7
10
  export * from './visitor.js';
@@ -1,7 +1,10 @@
1
+ export * from './__dirname.js';
1
2
  export * from './get-initializer.js';
2
3
  export * from './get-tags.js';
3
4
  export * from './get-type.js';
4
5
  export * from './has-decorator.js';
6
+ export * from './is-directory-empty.js';
5
7
  export * from './print-type.js';
6
8
  export * from './print.js';
9
+ export * from './render-template.js';
7
10
  export * from './visitor.js';
@@ -0,0 +1 @@
1
+ export declare const isDirectoryEmpty: (directory: string) => Promise<boolean>;
@@ -0,0 +1,19 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import fs from 'fs';
11
+ export const isDirectoryEmpty = (directory) => __awaiter(void 0, void 0, void 0, function* () {
12
+ try {
13
+ const files = yield fs.readdirSync(directory);
14
+ return !files.length;
15
+ }
16
+ catch (_a) {
17
+ return true;
18
+ }
19
+ });
@@ -0,0 +1 @@
1
+ export declare const renderTemplate: (source: string | Array<string>, destination: string, options?: any) => (context: any) => void;
@@ -0,0 +1,25 @@
1
+ import glob from 'fast-glob';
2
+ import fs from 'fs';
3
+ import handlebars from 'handlebars';
4
+ import path from 'path';
5
+ export const renderTemplate = (source, destination, options) => (context) => {
6
+ const files = glob.sync(source, options);
7
+ for (const file of files) {
8
+ const from = path.resolve((options === null || options === void 0 ? void 0 : options.cwd) || '', file);
9
+ const to = path.join(destination, path
10
+ .normalize(file)
11
+ .split(path.sep)
12
+ .slice(1)
13
+ .map((section) => handlebars.compile(section)(context))
14
+ .join(path.sep)
15
+ .replace('_.', '.')
16
+ .replace('.hbs', ''));
17
+ const directory = path.dirname(to);
18
+ const raw = fs.readFileSync(from, 'utf8');
19
+ const template = handlebars.compile(raw)(context);
20
+ if (!fs.existsSync(directory)) {
21
+ fs.mkdirSync(directory, { recursive: true });
22
+ }
23
+ fs.writeFileSync(to, template, 'utf8');
24
+ }
25
+ };
@@ -1,6 +1,8 @@
1
1
  import { ClassBody, ClassDeclaration, ClassMethod, ClassProperty, File } from '@babel/types';
2
2
  export interface Context {
3
3
  script?: string;
4
+ componentClassName?: string;
5
+ componentInterfaceName?: string;
4
6
  componentKey?: string;
5
7
  componentTag?: string;
6
8
  directoryName?: string;
@@ -1,8 +1,3 @@
1
- export * from './api.js';
2
1
  export * from './context.js';
3
- export * from './direction.js';
4
- export * from './event-options.js';
5
- export * from './listen-options.js';
6
2
  export * from './plugin.js';
7
3
  export * from './plus-element.js';
8
- export * from './property-options.js';
@@ -1,8 +1,3 @@
1
- export * from './api.js';
2
1
  export * from './context.js';
3
- export * from './direction.js';
4
- export * from './event-options.js';
5
- export * from './listen-options.js';
6
2
  export * from './plugin.js';
7
3
  export * from './plus-element.js';
8
- export * from './property-options.js';
@@ -1,7 +1,8 @@
1
1
  import { Context } from './context.js';
2
+ export declare type Return<T> = void | T | Promise<T>;
2
3
  export declare type Plugin = {
3
4
  name: string;
4
- start?: (global: any) => void;
5
- next?: (context: Context, global: any) => void | Context | Promise<Context>;
6
- finish?: (global: any) => void;
5
+ start?: (global: any) => Return<any>;
6
+ next?: (context: Context, global: any) => Return<Context>;
7
+ finish?: (global: any) => Return<any>;
7
8
  };
package/package.json CHANGED
@@ -1,16 +1,17 @@
1
1
  {
2
2
  "name": "@htmlplus/element",
3
- "version": "0.1.1",
3
+ "version": "0.1.4",
4
4
  "license": "MIT",
5
5
  "author": "Masood Abdolian <m.abdolian@gmail.com>",
6
6
  "description": "Compiler of HTMLPlus",
7
7
  "type": "module",
8
8
  "scripts": {
9
- "build": "npm run clean && tsc",
9
+ "build": "tsc",
10
10
  "build:watch": "tsc -w",
11
- "clean": "rimraf dist",
12
- "prettier": "prettier --write .",
13
- "start": "node src/dev/start.js"
11
+ "postbuild": "node scripts/build.post.js",
12
+ "format": "prettier --write .",
13
+ "dev:start": "node src/dev/start.js",
14
+ "dev:build": "node src/dev/build.js"
14
15
  },
15
16
  "exports": {
16
17
  ".": {
@@ -78,6 +79,8 @@
78
79
  "@babel/types": "^7.16.0",
79
80
  "@types/node": "^16.11.11",
80
81
  "change-case": "^4.1.2",
82
+ "fast-glob": "^3.2.11",
83
+ "handlebars": "^4.7.7",
81
84
  "log-update": "^5.0.0",
82
85
  "sass": "^1.43.4",
83
86
  "ts-node": "^10.4.0",
@@ -86,8 +89,8 @@
86
89
  },
87
90
  "devDependencies": {
88
91
  "@trivago/prettier-plugin-sort-imports": "^3.1.1",
92
+ "cpy": "^9.0.0",
89
93
  "prettier": "^2.5.0",
90
- "rimraf": "^3.0.2",
91
94
  "vite": "^2.7.10"
92
95
  }
93
96
  }
@@ -1,2 +0,0 @@
1
- import { ListenOptions as ListenOptionsBase } from '../../types/index.js';
2
- export declare function ListenOptions(options?: Omit<ListenOptionsBase, 'target'>): void;
@@ -1,2 +0,0 @@
1
- // TODO
2
- export function ListenOptions(options = {}) { }
@@ -1 +0,0 @@
1
- export { isServer } from '../utils/index.js';
@@ -1 +0,0 @@
1
- export { isServer } from '../utils/index.js';
@@ -1,5 +0,0 @@
1
- export declare type DecoratorSetup = (target: Object, propertyKey: PropertyKey, descriptor?: PropertyDescriptor) => DecoratorSetupReturn;
2
- export declare type DecoratorSetupReturn = PropertyDescriptor & {
3
- onReady?(): void;
4
- };
5
- export declare const decorator: (setup: DecoratorSetup) => (target: Object, propertyKey: PropertyKey, descriptor?: PropertyDescriptor | undefined) => DecoratorSetupReturn | undefined;
@@ -1,14 +0,0 @@
1
- import { defineProperty } from './define-property.js';
2
- export const decorator = (setup) => {
3
- return function (target, propertyKey, descriptor) {
4
- var _a;
5
- const options = setup(target, propertyKey, descriptor);
6
- // TODO
7
- if (options.onReady)
8
- ((_a = target['setup']) !== null && _a !== void 0 ? _a : (target['setup'] = [])).push(options.onReady);
9
- if (descriptor)
10
- return options;
11
- if (Object.keys(options).some((key) => ['configurable', 'enumerable', 'value', 'writable', 'get', 'set'].includes(key)))
12
- defineProperty(target, propertyKey, options);
13
- };
14
- };
@@ -1 +0,0 @@
1
- export declare const defineElement: (name: string, Class: any) => void;
@@ -1,7 +0,0 @@
1
- import { isServer } from './is-server.js';
2
- // TODO: Class type
3
- export const defineElement = (name, Class) => {
4
- if (isServer())
5
- return;
6
- window.customElements.define(name, Class);
7
- };
@@ -1 +0,0 @@
1
- export declare const defineMethod: <T>(target: T, propertyKey: PropertyKey, handler: any) => void;
@@ -1,7 +0,0 @@
1
- // TODO: handler type
2
- export const defineMethod = (target, propertyKey, handler) => {
3
- const callback = target[propertyKey];
4
- target[propertyKey] = function (...args) {
5
- return handler(this, callback === null || callback === void 0 ? void 0 : callback.bind(this), args);
6
- };
7
- };
@@ -1,5 +0,0 @@
1
- export interface Api {
2
- ready: boolean;
3
- host(): HTMLElement;
4
- request(states?: any): void;
5
- }
package/dist/types/api.js DELETED
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export declare type Direction = 'ltr' | 'rtl';
@@ -1 +0,0 @@
1
- export {};
@@ -1,18 +0,0 @@
1
- export interface EventOptions {
2
- /**
3
- * A string custom event name to override the default.
4
- */
5
- name?: string;
6
- /**
7
- * A Boolean indicating whether the event bubbles up through the DOM or not. default is `false`.
8
- */
9
- bubbles?: boolean;
10
- /**
11
- * A Boolean indicating whether the event is cancelable. default is `false`.
12
- */
13
- cancelable?: boolean;
14
- /**
15
- * A Boolean value indicating whether or not the event can bubble across the boundary between the shadow DOM and the regular DOM. The default is false.
16
- */
17
- composed?: boolean;
18
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,7 +0,0 @@
1
- export interface ListenOptions {
2
- target?: 'host' | 'body' | 'document' | 'window';
3
- once?: boolean;
4
- passive?: boolean;
5
- signal?: AbortSignal;
6
- capture?: boolean;
7
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,10 +0,0 @@
1
- export interface PropertyOptions {
2
- /**
3
- * TODO
4
- */
5
- attribute?: boolean | string;
6
- /**
7
- * Whether property value is reflected back to the associated attribute. default is `false`.
8
- */
9
- reflect?: boolean;
10
- }
@@ -1 +0,0 @@
1
- export {};