@esportsplus/template 0.40.0 → 0.40.2
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/build/compiler/constants.d.ts +2 -2
- package/build/compiler/constants.js +2 -2
- package/build/compiler/index.js +2 -2
- package/build/compiler/parser.js +2 -2
- package/build/compiler/plugins/vite.js +2 -2
- package/build/compiler/ts-parser.js +3 -3
- package/package.json +3 -3
- package/src/compiler/constants.ts +2 -2
- package/src/compiler/index.ts +2 -2
- package/src/compiler/parser.ts +2 -2
- package/src/compiler/plugins/vite.ts +2 -2
- package/src/compiler/ts-parser.ts +3 -3
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
declare const ENTRYPOINT = "html";
|
|
2
2
|
declare const ENTRYPOINT_REACTIVITY = "reactive";
|
|
3
3
|
declare const NAMESPACE: string;
|
|
4
|
-
declare const
|
|
4
|
+
declare const PACKAGE_NAME = "@esportsplus/template";
|
|
5
5
|
declare const enum TYPES {
|
|
6
6
|
ArraySlot = "array-slot",
|
|
7
7
|
Attributes = "attributes",
|
|
@@ -13,4 +13,4 @@ declare const enum TYPES {
|
|
|
13
13
|
Static = "static",
|
|
14
14
|
Unknown = "unknown"
|
|
15
15
|
}
|
|
16
|
-
export { ENTRYPOINT, ENTRYPOINT_REACTIVITY, NAMESPACE,
|
|
16
|
+
export { ENTRYPOINT, ENTRYPOINT_REACTIVITY, NAMESPACE, PACKAGE_NAME, TYPES };
|
|
@@ -2,7 +2,7 @@ import { uid } from '@esportsplus/typescript/compiler';
|
|
|
2
2
|
const ENTRYPOINT = 'html';
|
|
3
3
|
const ENTRYPOINT_REACTIVITY = 'reactive';
|
|
4
4
|
const NAMESPACE = uid('template');
|
|
5
|
-
const
|
|
5
|
+
const PACKAGE_NAME = '@esportsplus/template';
|
|
6
6
|
var TYPES;
|
|
7
7
|
(function (TYPES) {
|
|
8
8
|
TYPES["ArraySlot"] = "array-slot";
|
|
@@ -16,4 +16,4 @@ var TYPES;
|
|
|
16
16
|
TYPES["Unknown"] = "unknown";
|
|
17
17
|
})(TYPES || (TYPES = {}));
|
|
18
18
|
;
|
|
19
|
-
export { ENTRYPOINT, ENTRYPOINT_REACTIVITY, NAMESPACE,
|
|
19
|
+
export { ENTRYPOINT, ENTRYPOINT_REACTIVITY, NAMESPACE, PACKAGE_NAME, TYPES };
|
package/build/compiler/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ts } from '@esportsplus/typescript';
|
|
2
2
|
import { ast } from '@esportsplus/typescript/compiler';
|
|
3
|
-
import { ENTRYPOINT, ENTRYPOINT_REACTIVITY, NAMESPACE,
|
|
3
|
+
import { ENTRYPOINT, ENTRYPOINT_REACTIVITY, NAMESPACE, PACKAGE_NAME } from './constants.js';
|
|
4
4
|
import { generateCode, printer } from './codegen.js';
|
|
5
5
|
import { findHtmlTemplates, findReactiveCalls } from './ts-parser.js';
|
|
6
6
|
export default {
|
|
@@ -45,7 +45,7 @@ export default {
|
|
|
45
45
|
}
|
|
46
46
|
intents.imports.push({
|
|
47
47
|
namespace: NAMESPACE,
|
|
48
|
-
package:
|
|
48
|
+
package: PACKAGE_NAME,
|
|
49
49
|
remove: remove
|
|
50
50
|
});
|
|
51
51
|
return intents;
|
package/build/compiler/parser.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SLOT_HTML } from '../constants.js';
|
|
2
|
-
import {
|
|
2
|
+
import { PACKAGE_NAME, TYPES } from './constants.js';
|
|
3
3
|
const ATTRIBUTE_DELIMITERS = {
|
|
4
4
|
class: ' ',
|
|
5
5
|
style: ';'
|
|
@@ -123,7 +123,7 @@ const parse = (literals) => {
|
|
|
123
123
|
if (attr) {
|
|
124
124
|
let attrs = attributes[attr];
|
|
125
125
|
if (!attrs) {
|
|
126
|
-
throw new Error(`${
|
|
126
|
+
throw new Error(`${PACKAGE_NAME}: attribute metadata could not be found for '${attr}'`);
|
|
127
127
|
}
|
|
128
128
|
slots.push({ attributes: attrs, path, type: TYPES.Attribute });
|
|
129
129
|
for (let i = 0, n = attrs.names.length; i < n; i++) {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { plugin } from '@esportsplus/typescript/compiler';
|
|
2
|
-
import {
|
|
2
|
+
import { PACKAGE_NAME } from '../constants.js';
|
|
3
3
|
import reactivity from '@esportsplus/reactivity/compiler';
|
|
4
4
|
import template from '../index.js';
|
|
5
5
|
export default plugin.vite({
|
|
6
|
-
name:
|
|
6
|
+
name: PACKAGE_NAME,
|
|
7
7
|
plugins: [reactivity, template]
|
|
8
8
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ts } from '@esportsplus/typescript';
|
|
2
2
|
import { imports } from '@esportsplus/typescript/compiler';
|
|
3
|
-
import { ENTRYPOINT, ENTRYPOINT_REACTIVITY,
|
|
3
|
+
import { ENTRYPOINT, ENTRYPOINT_REACTIVITY, PACKAGE_NAME } from './constants.js';
|
|
4
4
|
function visitReactiveCalls(node, calls, checker) {
|
|
5
5
|
if (ts.isCallExpression(node) &&
|
|
6
6
|
ts.isPropertyAccessExpression(node.expression) &&
|
|
@@ -8,7 +8,7 @@ function visitReactiveCalls(node, calls, checker) {
|
|
|
8
8
|
node.expression.name.text === ENTRYPOINT_REACTIVITY &&
|
|
9
9
|
node.arguments.length === 2 &&
|
|
10
10
|
node.expression.expression.text === ENTRYPOINT &&
|
|
11
|
-
(!checker || imports.includes(checker, node.expression.expression,
|
|
11
|
+
(!checker || imports.includes(checker, node.expression.expression, PACKAGE_NAME, ENTRYPOINT))) {
|
|
12
12
|
calls.push({
|
|
13
13
|
arrayArg: node.arguments[0],
|
|
14
14
|
callbackArg: node.arguments[1],
|
|
@@ -26,7 +26,7 @@ function visitTemplates(node, depth, templates, checker) {
|
|
|
26
26
|
if (ts.isTaggedTemplateExpression(node) &&
|
|
27
27
|
ts.isIdentifier(node.tag) &&
|
|
28
28
|
node.tag.text === ENTRYPOINT &&
|
|
29
|
-
(!checker || imports.includes(checker, node.tag,
|
|
29
|
+
(!checker || imports.includes(checker, node.tag, PACKAGE_NAME, ENTRYPOINT))) {
|
|
30
30
|
let { expressions, literals } = extractTemplateParts(node.template);
|
|
31
31
|
templates.push({
|
|
32
32
|
depth,
|
package/package.json
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
"author": "ICJR",
|
|
3
3
|
"dependencies": {
|
|
4
4
|
"@esportsplus/queue": "^0.2.0",
|
|
5
|
-
"@esportsplus/reactivity": "^0.29.
|
|
6
|
-
"@esportsplus/typescript": "^0.27.
|
|
5
|
+
"@esportsplus/reactivity": "^0.29.11",
|
|
6
|
+
"@esportsplus/typescript": "^0.27.2",
|
|
7
7
|
"@esportsplus/utilities": "^0.27.2",
|
|
8
8
|
"serve": "^14.2.5"
|
|
9
9
|
},
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
},
|
|
40
40
|
"type": "module",
|
|
41
41
|
"types": "./build/index.d.ts",
|
|
42
|
-
"version": "0.40.
|
|
42
|
+
"version": "0.40.2",
|
|
43
43
|
"scripts": {
|
|
44
44
|
"build": "tsc",
|
|
45
45
|
"build:test": "vite build --config test/vite.config.ts",
|
|
@@ -7,7 +7,7 @@ const ENTRYPOINT_REACTIVITY = 'reactive';
|
|
|
7
7
|
|
|
8
8
|
const NAMESPACE = uid('template');
|
|
9
9
|
|
|
10
|
-
const
|
|
10
|
+
const PACKAGE_NAME = '@esportsplus/template';
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
const enum TYPES {
|
|
@@ -23,4 +23,4 @@ const enum TYPES {
|
|
|
23
23
|
};
|
|
24
24
|
|
|
25
25
|
|
|
26
|
-
export { ENTRYPOINT, ENTRYPOINT_REACTIVITY, NAMESPACE,
|
|
26
|
+
export { ENTRYPOINT, ENTRYPOINT_REACTIVITY, NAMESPACE, PACKAGE_NAME, TYPES };
|
package/src/compiler/index.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ts } from '@esportsplus/typescript';
|
|
2
2
|
import { ast } from '@esportsplus/typescript/compiler';
|
|
3
3
|
import type { ImportIntent, ReplacementIntent, TransformContext } from '@esportsplus/typescript/compiler';
|
|
4
|
-
import { ENTRYPOINT, ENTRYPOINT_REACTIVITY, NAMESPACE,
|
|
4
|
+
import { ENTRYPOINT, ENTRYPOINT_REACTIVITY, NAMESPACE, PACKAGE_NAME } from './constants';
|
|
5
5
|
import { generateCode, printer } from './codegen';
|
|
6
6
|
import { findHtmlTemplates, findReactiveCalls } from './ts-parser';
|
|
7
7
|
|
|
@@ -60,7 +60,7 @@ export default {
|
|
|
60
60
|
|
|
61
61
|
intents.imports.push({
|
|
62
62
|
namespace: NAMESPACE,
|
|
63
|
-
package:
|
|
63
|
+
package: PACKAGE_NAME,
|
|
64
64
|
remove: remove
|
|
65
65
|
});
|
|
66
66
|
|
package/src/compiler/parser.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SLOT_HTML } from '../constants';
|
|
2
|
-
import {
|
|
2
|
+
import { PACKAGE_NAME, TYPES } from './constants';
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
type NodePath = ('firstChild' | 'firstElementChild' | 'nextElementSibling' | 'nextSibling')[];
|
|
@@ -182,7 +182,7 @@ const parse = (literals: string[]) => {
|
|
|
182
182
|
let attrs = attributes[attr];
|
|
183
183
|
|
|
184
184
|
if (!attrs) {
|
|
185
|
-
throw new Error(`${
|
|
185
|
+
throw new Error(`${PACKAGE_NAME}: attribute metadata could not be found for '${attr}'`);
|
|
186
186
|
}
|
|
187
187
|
|
|
188
188
|
slots.push({ attributes: attrs, path, type: TYPES.Attribute });
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { plugin } from '@esportsplus/typescript/compiler';
|
|
2
|
-
import {
|
|
2
|
+
import { PACKAGE_NAME } from '../constants';
|
|
3
3
|
import reactivity from '@esportsplus/reactivity/compiler';
|
|
4
4
|
import template from '..';
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
export default plugin.vite({
|
|
8
|
-
name:
|
|
8
|
+
name: PACKAGE_NAME,
|
|
9
9
|
plugins: [reactivity, template]
|
|
10
10
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ts } from '@esportsplus/typescript';
|
|
2
2
|
import { imports } from '@esportsplus/typescript/compiler';
|
|
3
|
-
import { ENTRYPOINT, ENTRYPOINT_REACTIVITY,
|
|
3
|
+
import { ENTRYPOINT, ENTRYPOINT_REACTIVITY, PACKAGE_NAME } from './constants';
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
type ReactiveCallInfo = {
|
|
@@ -29,7 +29,7 @@ function visitReactiveCalls(node: ts.Node, calls: ReactiveCallInfo[], checker: t
|
|
|
29
29
|
node.expression.name.text === ENTRYPOINT_REACTIVITY &&
|
|
30
30
|
node.arguments.length === 2 &&
|
|
31
31
|
node.expression.expression.text === ENTRYPOINT &&
|
|
32
|
-
(!checker || imports.includes(checker, node.expression.expression,
|
|
32
|
+
(!checker || imports.includes(checker, node.expression.expression, PACKAGE_NAME, ENTRYPOINT))
|
|
33
33
|
) {
|
|
34
34
|
calls.push({
|
|
35
35
|
arrayArg: node.arguments[0],
|
|
@@ -52,7 +52,7 @@ function visitTemplates(node: ts.Node, depth: number, templates: TemplateInfo[],
|
|
|
52
52
|
ts.isTaggedTemplateExpression(node) &&
|
|
53
53
|
ts.isIdentifier(node.tag) &&
|
|
54
54
|
node.tag.text === ENTRYPOINT &&
|
|
55
|
-
(!checker || imports.includes(checker, node.tag,
|
|
55
|
+
(!checker || imports.includes(checker, node.tag, PACKAGE_NAME, ENTRYPOINT))
|
|
56
56
|
) {
|
|
57
57
|
let { expressions, literals } = extractTemplateParts(node.template);
|
|
58
58
|
|