@htmlplus/element 0.8.6 → 1.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.
Files changed (184) hide show
  1. package/README.md +616 -534
  2. package/bundlers/rollup.d.ts +2 -2
  3. package/bundlers/rollup.js +5 -5
  4. package/bundlers/vite.d.ts +2 -2
  5. package/bundlers/vite.js +5 -5
  6. package/client/decorators/bind.d.ts +4 -0
  7. package/client/decorators/bind.js +4 -0
  8. package/client/decorators/direction.d.ts +5 -0
  9. package/client/decorators/direction.js +8 -0
  10. package/client/decorators/element.d.ts +5 -0
  11. package/client/decorators/element.js +7 -2
  12. package/client/decorators/event.d.ts +21 -7
  13. package/client/decorators/event.js +7 -2
  14. package/client/decorators/host.d.ts +4 -2
  15. package/client/decorators/host.js +5 -8
  16. package/client/decorators/index.d.ts +3 -0
  17. package/client/decorators/index.js +3 -0
  18. package/client/decorators/isRTL.d.ts +4 -0
  19. package/client/decorators/isRTL.js +7 -0
  20. package/client/decorators/listen.d.ts +38 -8
  21. package/client/decorators/listen.js +9 -12
  22. package/client/decorators/method.d.ts +4 -0
  23. package/client/decorators/method.js +4 -0
  24. package/client/decorators/property.d.ts +8 -1
  25. package/client/decorators/property.js +4 -0
  26. package/client/decorators/query.d.ts +9 -2
  27. package/client/decorators/query.js +10 -9
  28. package/client/decorators/queryAll.d.ts +12 -2
  29. package/client/decorators/queryAll.js +13 -9
  30. package/client/decorators/slots.d.ts +4 -0
  31. package/client/decorators/slots.js +7 -0
  32. package/client/decorators/state.d.ts +4 -0
  33. package/client/decorators/state.js +4 -0
  34. package/client/decorators/watch.d.ts +5 -4
  35. package/client/decorators/watch.js +5 -4
  36. package/client/index.d.ts +1 -3
  37. package/client/index.js +1 -3
  38. package/client/utils/classes.d.ts +3 -0
  39. package/client/utils/classes.js +11 -28
  40. package/client/utils/config.d.ts +25 -3
  41. package/client/utils/config.js +18 -10
  42. package/client/utils/direction.d.ts +5 -2
  43. package/client/utils/direction.js +5 -1
  44. package/client/utils/event.d.ts +6 -0
  45. package/client/utils/event.js +6 -0
  46. package/client/utils/host.d.ts +3 -0
  47. package/client/utils/host.js +3 -0
  48. package/client/utils/index.d.ts +4 -1
  49. package/client/utils/index.js +4 -1
  50. package/client/utils/isCSSColor.d.ts +5 -0
  51. package/client/utils/isCSSColor.js +9 -0
  52. package/client/utils/isRTL.d.ts +3 -0
  53. package/client/utils/isRTL.js +3 -0
  54. package/client/utils/isServer.d.ts +3 -0
  55. package/client/utils/isServer.js +3 -0
  56. package/client/utils/query.d.ts +5 -0
  57. package/client/utils/query.js +8 -0
  58. package/client/utils/queryAll.d.ts +5 -0
  59. package/client/utils/queryAll.js +8 -0
  60. package/client/utils/request.d.ts +1 -1
  61. package/client/utils/request.js +1 -1
  62. package/client/utils/slots.d.ts +3 -0
  63. package/client/utils/slots.js +6 -1
  64. package/client/utils/styles.d.ts +3 -0
  65. package/client/utils/styles.js +3 -0
  66. package/client/utils/toDecorator.d.ts +2 -0
  67. package/client/utils/toDecorator.js +10 -0
  68. package/client/utils/toUnit.d.ts +4 -1
  69. package/client/utils/toUnit.js +6 -3
  70. package/constants/index.d.ts +1 -0
  71. package/constants/index.js +2 -0
  72. package/package.json +11 -4
  73. package/transformer/index.d.ts +3 -0
  74. package/transformer/index.js +3 -0
  75. package/transformer/plugins/assets.d.ts +8 -0
  76. package/transformer/plugins/assets.js +29 -0
  77. package/{compiler → transformer}/plugins/copy.d.ts +2 -2
  78. package/{compiler → transformer}/plugins/customElement.d.ts +2 -2
  79. package/{compiler → transformer}/plugins/customElement.js +13 -12
  80. package/{compiler → transformer}/plugins/customElementReact/customElementReact.d.ts +4 -4
  81. package/{compiler → transformer}/plugins/customElementReact/customElementReact.js +18 -18
  82. package/{compiler → transformer}/plugins/customElementReact/templates/src/components/{{fileName}}.compact.ts.hbs +1 -1
  83. package/{compiler → transformer}/plugins/customElementReact/templates/src/components/{{fileName}}.ts.hbs +3 -3
  84. package/transformer/plugins/customElementReact/templates/src/index.ts.hbs +1 -0
  85. package/transformer/plugins/document.d.ts +7 -0
  86. package/{compiler → transformer}/plugins/document.js +18 -18
  87. package/transformer/plugins/extract.d.ts +2 -0
  88. package/{compiler → transformer}/plugins/extract.js +1 -18
  89. package/transformer/plugins/parse.d.ts +6 -0
  90. package/{compiler → transformer}/plugins/parse.js +1 -1
  91. package/transformer/plugins/read.d.ts +8 -0
  92. package/transformer/plugins/read.js +20 -0
  93. package/transformer/plugins/readme.d.ts +6 -0
  94. package/{compiler → transformer}/plugins/readme.js +3 -2
  95. package/transformer/plugins/style.d.ts +6 -0
  96. package/{compiler → transformer}/plugins/style.js +4 -2
  97. package/transformer/plugins/validate.d.ts +2 -0
  98. package/transformer/plugins/validate.js +41 -0
  99. package/transformer/plugins/visualStudioCode.d.ts +8 -0
  100. package/{compiler → transformer}/plugins/visualStudioCode.js +10 -8
  101. package/transformer/plugins/webTypes.d.ts +10 -0
  102. package/{compiler → transformer}/plugins/webTypes.js +11 -7
  103. package/transformer/transformer.d.ts +6 -0
  104. package/{compiler/compiler.js → transformer/transformer.js} +17 -17
  105. package/transformer/transformer.types.d.ts +50 -0
  106. package/{compiler → transformer}/utils/printType.js +2 -2
  107. package/{compiler → transformer}/utils/renderTemplate.js +2 -0
  108. package/types/index.d.ts +2 -4
  109. package/types/index.js +1 -4
  110. package/bundlers/index.d.ts +0 -2
  111. package/bundlers/index.js +0 -2
  112. package/client/helpers/index.d.ts +0 -1
  113. package/client/helpers/index.js +0 -1
  114. package/client/services/index.d.ts +0 -1
  115. package/client/services/index.js +0 -1
  116. package/client/services/link.d.ts +0 -4
  117. package/client/services/link.js +0 -196
  118. package/client/utils/getNamespace.d.ts +0 -2
  119. package/client/utils/getNamespace.js +0 -4
  120. package/client/vendors/uhtml.d.ts +0 -29
  121. package/client/vendors/uhtml.js +0 -700
  122. package/compiler/compiler.d.ts +0 -6
  123. package/compiler/index.d.ts +0 -2
  124. package/compiler/index.js +0 -2
  125. package/compiler/plugins/assets.d.ts +0 -8
  126. package/compiler/plugins/assets.js +0 -33
  127. package/compiler/plugins/customElementReact/templates/src/index.ts.hbs +0 -1
  128. package/compiler/plugins/document.d.ts +0 -7
  129. package/compiler/plugins/extract.d.ts +0 -2
  130. package/compiler/plugins/parse.d.ts +0 -5
  131. package/compiler/plugins/read.d.ts +0 -8
  132. package/compiler/plugins/read.js +0 -13
  133. package/compiler/plugins/readme.d.ts +0 -6
  134. package/compiler/plugins/style.d.ts +0 -6
  135. package/compiler/plugins/validate.d.ts +0 -2
  136. package/compiler/plugins/validate.js +0 -37
  137. package/compiler/plugins/visualStudioCode.d.ts +0 -8
  138. package/compiler/plugins/webTypes.d.ts +0 -10
  139. package/types/context.d.ts +0 -31
  140. package/types/global.d.ts +0 -4
  141. package/types/global.js +0 -1
  142. package/types/plugin.d.ts +0 -10
  143. package/types/plugin.js +0 -1
  144. package/types/plusElement.d.ts +0 -2
  145. package/types/plusElement.js +0 -1
  146. /package/{compiler → transformer}/plugins/copy.js +0 -0
  147. /package/{compiler → transformer}/plugins/customElementReact/index.d.ts +0 -0
  148. /package/{compiler → transformer}/plugins/customElementReact/index.js +0 -0
  149. /package/{compiler → transformer}/plugins/customElementReact/templates/README.md.hbs +0 -0
  150. /package/{compiler → transformer}/plugins/customElementReact/templates/_.gitignore.hbs +0 -0
  151. /package/{compiler → transformer}/plugins/customElementReact/templates/package.json.hbs +0 -0
  152. /package/{compiler → transformer}/plugins/customElementReact/templates/rollup.config.js.hbs +0 -0
  153. /package/{compiler → transformer}/plugins/customElementReact/templates/src/components/index.ts.hbs +0 -0
  154. /package/{compiler → transformer}/plugins/customElementReact/templates/src/proxy.ts.hbs +0 -0
  155. /package/{compiler → transformer}/plugins/customElementReact/templates/tsconfig.json.hbs +0 -0
  156. /package/{compiler → transformer}/plugins/index.d.ts +0 -0
  157. /package/{compiler → transformer}/plugins/index.js +0 -0
  158. /package/{types/context.js → transformer/transformer.types.js} +0 -0
  159. /package/{compiler → transformer}/utils/__dirname.d.ts +0 -0
  160. /package/{compiler → transformer}/utils/__dirname.js +0 -0
  161. /package/{compiler → transformer}/utils/addDependency.d.ts +0 -0
  162. /package/{compiler → transformer}/utils/addDependency.js +0 -0
  163. /package/{compiler → transformer}/utils/getInitializer.d.ts +0 -0
  164. /package/{compiler → transformer}/utils/getInitializer.js +0 -0
  165. /package/{compiler → transformer}/utils/getType.d.ts +0 -0
  166. /package/{compiler → transformer}/utils/getType.js +0 -0
  167. /package/{compiler → transformer}/utils/getTypeReference.d.ts +0 -0
  168. /package/{compiler → transformer}/utils/getTypeReference.js +0 -0
  169. /package/{compiler → transformer}/utils/hasDecorator.d.ts +0 -0
  170. /package/{compiler → transformer}/utils/hasDecorator.js +0 -0
  171. /package/{compiler → transformer}/utils/index.d.ts +0 -0
  172. /package/{compiler → transformer}/utils/index.js +0 -0
  173. /package/{compiler → transformer}/utils/isDirectoryEmpty.d.ts +0 -0
  174. /package/{compiler → transformer}/utils/isDirectoryEmpty.js +0 -0
  175. /package/{compiler → transformer}/utils/print.d.ts +0 -0
  176. /package/{compiler → transformer}/utils/print.js +0 -0
  177. /package/{compiler → transformer}/utils/printType.d.ts +0 -0
  178. /package/{compiler → transformer}/utils/removeUnusedImport.d.ts +0 -0
  179. /package/{compiler → transformer}/utils/removeUnusedImport.js +0 -0
  180. /package/{compiler → transformer}/utils/renderTemplate.d.ts +0 -0
  181. /package/{compiler → transformer}/utils/tags.d.ts +0 -0
  182. /package/{compiler → transformer}/utils/tags.js +0 -0
  183. /package/{compiler → transformer}/utils/visitor.d.ts +0 -0
  184. /package/{compiler → transformer}/utils/visitor.js +0 -0
@@ -4,28 +4,31 @@ const logger = ora({
4
4
  color: 'yellow'
5
5
  });
6
6
  const log = (message, persist) => {
7
- var _a, _b;
8
- (_b = (_a = logger.start(`${new Date().toLocaleTimeString()} [HTMLPLUS] ${message}`))[persist ? 'succeed' : '']) === null || _b === void 0 ? void 0 : _b.call(_a);
7
+ const content = `${new Date().toLocaleTimeString()} [HTMLPLUS] ${message}`;
8
+ const log = logger.start(content);
9
+ if (!persist)
10
+ return;
11
+ log.succeed();
9
12
  };
10
- export const compiler = (...plugins) => {
13
+ export const transformer = (...plugins) => {
11
14
  let global = {
12
15
  contexts: []
13
16
  };
14
- log(`Starting...`, true);
15
- log(`${plugins.length} plugins found.`, true);
16
17
  const start = async () => {
17
- log(`Plugins are starting...`, true);
18
+ log(`Started.`, true);
19
+ log(`${plugins.length} plugins found.`, true);
20
+ log(`Plugins are starting.`, true);
18
21
  for (const plugin of plugins) {
19
22
  if (!plugin.start)
20
23
  continue;
21
- log(`Plugin '${plugin.name}' is starting...`);
24
+ log(`Plugin '${plugin.name}' is starting.`);
22
25
  global = (await plugin.start(global)) || global;
23
26
  log(`Plugin '${plugin.name}' started successfully.`);
24
27
  }
25
28
  log(`Plugins started successfully.`, true);
26
29
  };
27
30
  const run = async (filePath) => {
28
- const key = filePath.split(/[\/|\\]/g).pop();
31
+ const key = path.join(filePath).split(path.sep).pop();
29
32
  let context = {
30
33
  filePath
31
34
  };
@@ -33,12 +36,13 @@ export const compiler = (...plugins) => {
33
36
  for (const plugin of plugins) {
34
37
  if (!plugin.run)
35
38
  continue;
36
- log(`Plugin '${plugin.name}' is executing on '${path.basename(parsed.dir)}/${parsed.base}' file.`);
39
+ const source = path.join(parsed.dir).split(path.sep).slice(-2).concat(parsed.base).join('/');
40
+ log(`Plugin '${plugin.name}' is executing on '${source}' file.`);
37
41
  try {
38
42
  context = (await plugin.run(context, global)) || context;
39
43
  }
40
44
  catch (error) {
41
- log(`Error in '${plugin.name}' plugin on '${path.basename(parsed.dir)}/${parsed.base}' file.`, true);
45
+ log(`Error in '${plugin.name}' plugin on '${source}' file.\n`, true);
42
46
  throw error;
43
47
  }
44
48
  global.contexts = global.contexts
@@ -46,21 +50,17 @@ export const compiler = (...plugins) => {
46
50
  return current.filePath != context.filePath;
47
51
  })
48
52
  .concat(context);
49
- log(`Plugin '${plugin.name}' executed successfully on '${path.basename(filePath)}' file.`);
50
- if (context.isInvalid)
51
- break;
53
+ log(`Plugin '${plugin.name}' executed successfully on '${source}' file.`);
52
54
  }
53
55
  logger.stop();
54
- if (context.isInvalid)
55
- log(`File '${key}' break executing because file is invalid.`, true);
56
56
  return context;
57
57
  };
58
58
  const finish = async () => {
59
- log(`Plugins are finishing...`, true);
59
+ log(`Plugins are finishing.`, true);
60
60
  for (const plugin of plugins) {
61
61
  if (!plugin.finish)
62
62
  continue;
63
- log(`Plugin '${plugin.name}' is finishing...`);
63
+ log(`Plugin '${plugin.name}' is finishing.`);
64
64
  global = (await plugin.finish(global)) || global;
65
65
  log(`Plugin '${plugin.name}' finished successfully.`);
66
66
  }
@@ -0,0 +1,50 @@
1
+ import { ClassBody, ClassDeclaration, ClassMethod, ClassProperty, File } from '@babel/types';
2
+ type Return<T> = void | T | Promise<void | T>;
3
+ export interface TransformerPluginContext {
4
+ skipped?: boolean;
5
+ script?: string;
6
+ assetsDestination?: string;
7
+ assetsSource?: string;
8
+ class?: ClassDeclaration;
9
+ classEvents?: Array<ClassProperty>;
10
+ classHasMount?: boolean;
11
+ classHasUnmount?: boolean;
12
+ classMembers?: ClassBody['body'];
13
+ classMethods?: Array<ClassMethod>;
14
+ className?: string;
15
+ classProperties?: Array<ClassProperty>;
16
+ classRender?: ClassMethod;
17
+ classStates?: Array<ClassProperty>;
18
+ directoryName?: string;
19
+ directoryPath?: string;
20
+ elementKey?: string;
21
+ elementInterfaceName?: string;
22
+ elementTagName?: string;
23
+ fileAST?: File;
24
+ fileContent?: string;
25
+ fileExtension?: string;
26
+ fileName?: string;
27
+ filePath?: string;
28
+ metadata?: {
29
+ [key: string]: any;
30
+ };
31
+ readmeContent?: string;
32
+ readmeExtension?: string;
33
+ readmeName?: string;
34
+ readmePath?: string;
35
+ styleContent?: string;
36
+ styleExtension?: string;
37
+ styleName?: string;
38
+ stylePath?: string;
39
+ }
40
+ export interface TransformerPluginGlobal {
41
+ contexts: Array<TransformerPluginContext>;
42
+ }
43
+ export interface TransformerPlugin {
44
+ name: string;
45
+ options?: any;
46
+ start?: (global: TransformerPluginGlobal) => Return<TransformerPluginGlobal>;
47
+ run?: (context: TransformerPluginContext, global: TransformerPluginGlobal) => Return<TransformerPluginContext>;
48
+ finish?: (global: TransformerPluginGlobal) => Return<TransformerPluginGlobal>;
49
+ }
50
+ export {};
@@ -2,8 +2,8 @@ import { print } from './print.js';
2
2
  // TODO
3
3
  // args types
4
4
  // return type
5
- // components\grid-item\grid-item.types.ts
6
- // components\portal\portal.tsx
5
+ // elements\grid-item\grid-item.types.ts
6
+ // elements\portal\portal.tsx
7
7
  export const printType = (ast) => {
8
8
  if (!ast)
9
9
  return ast;
@@ -5,7 +5,9 @@ import path from 'path';
5
5
  export const renderTemplate = (source, destination, options) => (context) => {
6
6
  const files = glob.sync(source, options);
7
7
  for (const file of files) {
8
+ // TODO
8
9
  const from = path.resolve((options === null || options === void 0 ? void 0 : options.cwd) || '', file);
10
+ // TODO
9
11
  const to = path.join(destination, path
10
12
  .normalize(file)
11
13
  .split(path.sep)
package/types/index.d.ts CHANGED
@@ -1,4 +1,2 @@
1
- export * from './context';
2
- export * from './global';
3
- export * from './plugin';
4
- export * from './plusElement';
1
+ export interface PlusElement {
2
+ }
package/types/index.js CHANGED
@@ -1,4 +1 @@
1
- export * from './context';
2
- export * from './global';
3
- export * from './plugin';
4
- export * from './plusElement';
1
+ export {};
@@ -1,2 +0,0 @@
1
- export * from './rollup.js';
2
- export * from './vite.js';
package/bundlers/index.js DELETED
@@ -1,2 +0,0 @@
1
- export * from './rollup.js';
2
- export * from './vite.js';
@@ -1 +0,0 @@
1
- export { classes, direction, getConfig, host, isRTL, isServer, on, off, slots, styles, toUnit, setConfig } from '../utils/index.js';
@@ -1 +0,0 @@
1
- export { classes, direction, getConfig, host, isRTL, isServer, on, off, slots, styles, toUnit, setConfig } from '../utils/index.js';
@@ -1 +0,0 @@
1
- export * from './link.js';
@@ -1 +0,0 @@
1
- export * from './link.js';
@@ -1,4 +0,0 @@
1
- export type LinkConfig = {
2
- scope?: Function;
3
- };
4
- export declare const createLink: (namespace: string) => any;
@@ -1,196 +0,0 @@
1
- import { defineProperty, host } from '../utils/index.js';
2
- const links = new Map();
3
- // TODO: return type
4
- export const createLink = (namespace) => {
5
- if (links.has(namespace))
6
- return links.get(namespace);
7
- const config = {
8
- scope: (i) => i.connector
9
- };
10
- let disconnecting = false;
11
- const children = new Map();
12
- const parents = new Map();
13
- const properties = [];
14
- const find = (source) => {
15
- return properties.find((destination) => destination.instance === source.instance && destination.name === source.name);
16
- };
17
- const register = (source) => {
18
- properties.push(source);
19
- if (!children.has(source.instance))
20
- children.set(source.instance, new Set());
21
- // TODO: any
22
- const siblings = children.get(source.instance);
23
- siblings.add(source);
24
- };
25
- const unregister = (source) => {
26
- // TODO: any
27
- source = find(source);
28
- const index = properties.findIndex((property) => property === source);
29
- if (index === -1)
30
- return;
31
- properties.splice(index, 1);
32
- // TODO: any
33
- const siblings = children.get(source.instance);
34
- siblings.delete(source);
35
- if (siblings.size)
36
- return;
37
- children.delete(source.instance);
38
- parents.delete(source.instance);
39
- };
40
- const get = (source) => {
41
- // TODO: any
42
- return source.instance[source.name];
43
- };
44
- const set = (source, value) => {
45
- // TODO: any
46
- source.instance[source.name] = value;
47
- };
48
- const reset = (source) => {
49
- if (source.type === 'action')
50
- return;
51
- if (source.type === 'inject')
52
- return set(source, source.value /* TODO */);
53
- // TODO: any
54
- defineProperty(source.instance, source.name, {
55
- value: get(source) /* TODO */,
56
- enumerable: true,
57
- configurable: true
58
- });
59
- };
60
- const map = (source, destination) => {
61
- let value = get(source);
62
- if (typeof value === 'function')
63
- value = value.bind(source.instance);
64
- set(destination, value);
65
- };
66
- const proxy = (source) => {
67
- let value = get(source);
68
- // TODO: any
69
- defineProperty(source.instance, source.name, {
70
- enumerable: true,
71
- configurable: true,
72
- get() {
73
- return value;
74
- },
75
- set(input) {
76
- if (input === value)
77
- return;
78
- value = input;
79
- siblings(source, ['inject']).map((destination) => set(destination, value));
80
- }
81
- });
82
- };
83
- const parent = (source) => {
84
- var _a;
85
- const cache = parents.get(source.instance);
86
- if (cache)
87
- return cache;
88
- // TODO: element? and any
89
- let parent = (_a = source.element) === null || _a === void 0 ? void 0 : _a.parentElement;
90
- while (parent) {
91
- if (parent.shadowRoot) {
92
- const item = properties.find((property) => property.element === parent && property.name === source.name);
93
- if (item) {
94
- parents.set(source.instance, item);
95
- return item;
96
- }
97
- }
98
- parent = parent.parentElement;
99
- }
100
- };
101
- const scope = (source) => {
102
- var _a, _b;
103
- if (!source)
104
- return;
105
- // TODO
106
- if (disconnecting)
107
- return source.instance['$scope-prev'];
108
- // TODO: &&
109
- let input = config.scope && config.scope(source.instance);
110
- if (typeof input !== 'undefined')
111
- return input;
112
- // TODO: any
113
- return ((_b = (_a = scope(parent(source))) !== null && _a !== void 0 ? _a : source.instance['$scope-auto']) !== null && _b !== void 0 ? _b : (source.instance['$scope-auto'] = Math.random()));
114
- };
115
- const siblings = (source, types) => {
116
- return properties.filter((destination) => {
117
- // TODO: any
118
- if (!types.includes(destination.type))
119
- return false;
120
- if (source === destination)
121
- return false;
122
- if (source.name !== destination.name)
123
- return false;
124
- if (scope(source) !== scope(destination))
125
- return false;
126
- return true;
127
- });
128
- };
129
- const connect = (source) => {
130
- // TODO
131
- source.instance['$scope-prev'] = scope(source);
132
- register(source);
133
- switch (source.type) {
134
- case 'action':
135
- siblings(source, ['inject']).forEach((destination) => map(source, destination));
136
- break;
137
- case 'observable':
138
- proxy(source);
139
- siblings(source, ['inject']).forEach((destination) => map(source, destination));
140
- break;
141
- case 'inject':
142
- siblings(source, ['action', 'observable']).forEach((destination) => map(destination, source));
143
- break;
144
- }
145
- };
146
- const disconnect = (source) => {
147
- reset(source);
148
- if (source.type === 'inject')
149
- return unregister(source);
150
- siblings(source, ['inject']).forEach(reset);
151
- unregister(source);
152
- };
153
- const reconnect = (instance) => {
154
- const p = properties.filter((property) => property.instance === instance);
155
- disconnecting = true;
156
- p.forEach(disconnect);
157
- disconnecting = false;
158
- p.forEach(connect);
159
- };
160
- const decorator = (type) => () => (target, name) => {
161
- const connected = target.connectedCallback;
162
- target.connectedCallback = function () {
163
- connected && connected.bind(this)();
164
- const property = {
165
- element: host(this),
166
- instance: this,
167
- name,
168
- type,
169
- value: this[name]
170
- };
171
- if (find(property))
172
- console.error('TODO: Error log');
173
- connect(property);
174
- };
175
- const disconnected = target.disconnectedCallback;
176
- target.disconnectedCallback = function () {
177
- disconnected && disconnected.bind(this)();
178
- const property = find({ instance: this, name });
179
- if (!property)
180
- console.error('TODO: Error log');
181
- // TODO: any
182
- disconnect(property);
183
- };
184
- };
185
- const Action = decorator('action');
186
- const Inject = decorator('inject');
187
- const Observable = decorator('observable');
188
- const result = {
189
- Action,
190
- Inject,
191
- Observable,
192
- reconnect
193
- };
194
- links.set(namespace, result);
195
- return result;
196
- };
@@ -1,2 +0,0 @@
1
- import { PlusElement } from '../../types';
2
- export declare const getNamespace: (instance: PlusElement) => string;
@@ -1,4 +0,0 @@
1
- import { getTag } from './getTag.js';
2
- export const getNamespace = (instance) => {
3
- return getTag(instance).split('-')[0].toUpperCase();
4
- };
@@ -1,29 +0,0 @@
1
- declare namespace _default {
2
- export { Hole };
3
- export { html };
4
- export { render };
5
- export { svg };
6
- }
7
- export default _default;
8
- /**
9
- * Holds all details wrappers needed to render the content further on.
10
- * @constructor
11
- * @param {string} type The hole type, either `html` or `svg`.
12
- * @param {string[]} template The template literals used to the define the content.
13
- * @param {Array} values Zero, one, or more interpolated values to render.
14
- */
15
- export class Hole {
16
- constructor(type: any, template: any, values: any);
17
- type: any;
18
- template: any;
19
- values: any;
20
- }
21
- export const html: ((template: any, ...values: any[]) => Hole) & {
22
- for(ref: any, id: any): any;
23
- node: (template: any, ...values: any[]) => any;
24
- };
25
- export function render(where: any, what: any): any;
26
- export const svg: ((template: any, ...values: any[]) => Hole) & {
27
- for(ref: any, id: any): any;
28
- node: (template: any, ...values: any[]) => any;
29
- };