@microsoft/fast-html 1.0.0-alpha.8 → 1.0.0-alpha.9
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 +44 -2
- package/dist/dts/components/template.d.ts +14 -1
- package/dist/esm/components/template.js +12 -0
- package/dist/esm/fixtures/attribute/main.js +8 -1
- package/dist/esm/fixtures/binding/main.js +13 -1
- package/dist/esm/fixtures/children/main.js +8 -1
- package/dist/esm/fixtures/dot-syntax/main.js +8 -1
- package/dist/esm/fixtures/event/main.js +8 -1
- package/dist/esm/fixtures/partial/main.js +8 -1
- package/dist/esm/fixtures/ref/main.js +8 -1
- package/dist/esm/fixtures/repeat/main.js +8 -1
- package/dist/esm/fixtures/slotted/main.js +8 -1
- package/dist/esm/fixtures/when/main.js +53 -1
- package/dist/esm/tsconfig.tsbuildinfo +1 -1
- package/dist/fast-html.api.json +85 -0
- package/dist/fast-html.d.ts +15 -0
- package/dist/fast-html.untrimmed.d.ts +15 -0
- package/package.json +9 -5
- package/rules/attribute-directives.yml +38 -0
- package/rules/call-expression-with-event-argument.yml +41 -0
- package/rules/member-expression.yml +33 -0
- package/rules/tag-function-to-template-literal.yml +16 -0
package/dist/fast-html.api.json
CHANGED
|
@@ -228,6 +228,37 @@
|
|
|
228
228
|
"isAbstract": false,
|
|
229
229
|
"name": "connectedCallback"
|
|
230
230
|
},
|
|
231
|
+
{
|
|
232
|
+
"kind": "Property",
|
|
233
|
+
"canonicalReference": "@microsoft/fast-html!TemplateElement.elementOptions:member",
|
|
234
|
+
"docComment": "/**\n * A dictionary of custom element options\n */\n",
|
|
235
|
+
"excerptTokens": [
|
|
236
|
+
{
|
|
237
|
+
"kind": "Content",
|
|
238
|
+
"text": "static elementOptions: "
|
|
239
|
+
},
|
|
240
|
+
{
|
|
241
|
+
"kind": "Reference",
|
|
242
|
+
"text": "ElementOptions",
|
|
243
|
+
"canonicalReference": "@microsoft/fast-html!~ElementOptions:interface"
|
|
244
|
+
},
|
|
245
|
+
{
|
|
246
|
+
"kind": "Content",
|
|
247
|
+
"text": ";"
|
|
248
|
+
}
|
|
249
|
+
],
|
|
250
|
+
"isReadonly": false,
|
|
251
|
+
"isOptional": false,
|
|
252
|
+
"releaseTag": "Public",
|
|
253
|
+
"name": "elementOptions",
|
|
254
|
+
"propertyTypeTokenRange": {
|
|
255
|
+
"startIndex": 1,
|
|
256
|
+
"endIndex": 2
|
|
257
|
+
},
|
|
258
|
+
"isStatic": true,
|
|
259
|
+
"isProtected": false,
|
|
260
|
+
"isAbstract": false
|
|
261
|
+
},
|
|
231
262
|
{
|
|
232
263
|
"kind": "Property",
|
|
233
264
|
"canonicalReference": "@microsoft/fast-html!TemplateElement#name:member",
|
|
@@ -257,6 +288,60 @@
|
|
|
257
288
|
"isStatic": false,
|
|
258
289
|
"isProtected": false,
|
|
259
290
|
"isAbstract": false
|
|
291
|
+
},
|
|
292
|
+
{
|
|
293
|
+
"kind": "Method",
|
|
294
|
+
"canonicalReference": "@microsoft/fast-html!TemplateElement.options:member(1)",
|
|
295
|
+
"docComment": "",
|
|
296
|
+
"excerptTokens": [
|
|
297
|
+
{
|
|
298
|
+
"kind": "Content",
|
|
299
|
+
"text": "static options(elementOptions?: "
|
|
300
|
+
},
|
|
301
|
+
{
|
|
302
|
+
"kind": "Reference",
|
|
303
|
+
"text": "ElementOptions",
|
|
304
|
+
"canonicalReference": "@microsoft/fast-html!~ElementOptions:interface"
|
|
305
|
+
},
|
|
306
|
+
{
|
|
307
|
+
"kind": "Content",
|
|
308
|
+
"text": "): "
|
|
309
|
+
},
|
|
310
|
+
{
|
|
311
|
+
"kind": "Content",
|
|
312
|
+
"text": "typeof "
|
|
313
|
+
},
|
|
314
|
+
{
|
|
315
|
+
"kind": "Reference",
|
|
316
|
+
"text": "TemplateElement",
|
|
317
|
+
"canonicalReference": "@microsoft/fast-html!TemplateElement:class"
|
|
318
|
+
},
|
|
319
|
+
{
|
|
320
|
+
"kind": "Content",
|
|
321
|
+
"text": ";"
|
|
322
|
+
}
|
|
323
|
+
],
|
|
324
|
+
"isStatic": true,
|
|
325
|
+
"returnTypeTokenRange": {
|
|
326
|
+
"startIndex": 3,
|
|
327
|
+
"endIndex": 5
|
|
328
|
+
},
|
|
329
|
+
"releaseTag": "Public",
|
|
330
|
+
"isProtected": false,
|
|
331
|
+
"overloadIndex": 1,
|
|
332
|
+
"parameters": [
|
|
333
|
+
{
|
|
334
|
+
"parameterName": "elementOptions",
|
|
335
|
+
"parameterTypeTokenRange": {
|
|
336
|
+
"startIndex": 1,
|
|
337
|
+
"endIndex": 2
|
|
338
|
+
},
|
|
339
|
+
"isOptional": true
|
|
340
|
+
}
|
|
341
|
+
],
|
|
342
|
+
"isOptional": false,
|
|
343
|
+
"isAbstract": false,
|
|
344
|
+
"name": "options"
|
|
260
345
|
}
|
|
261
346
|
],
|
|
262
347
|
"extendsTokenRange": {
|
package/dist/fast-html.d.ts
CHANGED
|
@@ -1,4 +1,14 @@
|
|
|
1
1
|
import { FASTElement } from '@microsoft/fast-element';
|
|
2
|
+
import { ShadowRootOptions } from '@microsoft/fast-element';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* A dictionary of element options the TemplateElement will use to update the registered element
|
|
6
|
+
*/
|
|
7
|
+
declare interface ElementOptions {
|
|
8
|
+
[key: string]: {
|
|
9
|
+
shadowOptions: ShadowRootOptions | undefined;
|
|
10
|
+
};
|
|
11
|
+
}
|
|
2
12
|
|
|
3
13
|
/**
|
|
4
14
|
* The <f-template> custom element that will provide view logic to the element
|
|
@@ -8,7 +18,12 @@ export declare class TemplateElement extends FASTElement {
|
|
|
8
18
|
* The name of the custom element this template will be applied to
|
|
9
19
|
*/
|
|
10
20
|
name?: string;
|
|
21
|
+
/**
|
|
22
|
+
* A dictionary of custom element options
|
|
23
|
+
*/
|
|
24
|
+
static elementOptions: ElementOptions;
|
|
11
25
|
private partials;
|
|
26
|
+
static options(elementOptions?: ElementOptions): typeof TemplateElement;
|
|
12
27
|
connectedCallback(): void;
|
|
13
28
|
/**
|
|
14
29
|
* Resolve strings and values from an innerHTML string
|
|
@@ -1,4 +1,14 @@
|
|
|
1
1
|
import { FASTElement } from '@microsoft/fast-element';
|
|
2
|
+
import { ShadowRootOptions } from '@microsoft/fast-element';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* A dictionary of element options the TemplateElement will use to update the registered element
|
|
6
|
+
*/
|
|
7
|
+
declare interface ElementOptions {
|
|
8
|
+
[key: string]: {
|
|
9
|
+
shadowOptions: ShadowRootOptions | undefined;
|
|
10
|
+
};
|
|
11
|
+
}
|
|
2
12
|
|
|
3
13
|
/**
|
|
4
14
|
* The <f-template> custom element that will provide view logic to the element
|
|
@@ -8,7 +18,12 @@ export declare class TemplateElement extends FASTElement {
|
|
|
8
18
|
* The name of the custom element this template will be applied to
|
|
9
19
|
*/
|
|
10
20
|
name?: string;
|
|
21
|
+
/**
|
|
22
|
+
* A dictionary of custom element options
|
|
23
|
+
*/
|
|
24
|
+
static elementOptions: ElementOptions;
|
|
11
25
|
private partials;
|
|
26
|
+
static options(elementOptions?: ElementOptions): typeof TemplateElement;
|
|
12
27
|
connectedCallback(): void;
|
|
13
28
|
/**
|
|
14
29
|
* Resolve strings and values from an innerHTML string
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@microsoft/fast-html",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.9",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Microsoft",
|
|
@@ -17,7 +17,8 @@
|
|
|
17
17
|
"url": "https://github.com/Microsoft/fast/issues/new/choose"
|
|
18
18
|
},
|
|
19
19
|
"files": [
|
|
20
|
-
"./dist"
|
|
20
|
+
"./dist",
|
|
21
|
+
"./rules/*.yml"
|
|
21
22
|
],
|
|
22
23
|
"scripts": {
|
|
23
24
|
"clean": "tsc -b --clean src",
|
|
@@ -43,8 +44,9 @@
|
|
|
43
44
|
"pretest": "npm run build && npm run build-server",
|
|
44
45
|
"prettier:diff": "prettier --config ../../../.prettierrc \"**/*.{ts,html}\" --list-different",
|
|
45
46
|
"prettier": "prettier --config ../../../.prettierrc --write \"**/*.{ts,html}\"",
|
|
46
|
-
"test": "npm run build-app && playwright test --config=playwright.config.cjs",
|
|
47
|
+
"test": "npm run build-app && playwright test --config=playwright.config.cjs && npm run test:rules",
|
|
47
48
|
"test-server": "node server/dist/server.js",
|
|
49
|
+
"test:rules": "sg test --skip-snapshot-tests",
|
|
48
50
|
"install-playwright-browsers": "npm run playwright install",
|
|
49
51
|
"dev": "npm run build && npm run build-app && npm run build-server && npm run test-server"
|
|
50
52
|
},
|
|
@@ -54,17 +56,19 @@
|
|
|
54
56
|
"types": "./dist/dts/index.d.ts",
|
|
55
57
|
"default": "./dist/esm/index.js"
|
|
56
58
|
},
|
|
59
|
+
"./rules/*.yml": "./rules/*.yml",
|
|
57
60
|
"./package.json": "./package.json"
|
|
58
61
|
},
|
|
59
62
|
"sideEffects": [
|
|
60
63
|
"./dist/esm/index.js"
|
|
61
64
|
],
|
|
62
65
|
"peerDependencies": {
|
|
63
|
-
"@microsoft/fast-element": "^2.
|
|
66
|
+
"@microsoft/fast-element": "^2.3.0"
|
|
64
67
|
},
|
|
65
68
|
"devDependencies": {
|
|
69
|
+
"@ast-grep/cli": "^0.37.0",
|
|
66
70
|
"@microsoft/api-extractor": "^7.47.0",
|
|
67
|
-
"@microsoft/fast-element": "^2.
|
|
71
|
+
"@microsoft/fast-element": "^2.3.0",
|
|
68
72
|
"@playwright/test": "^1.49.0",
|
|
69
73
|
"@types/express": "^4.17.21",
|
|
70
74
|
"@types/node": "^17.0.17",
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# https://ast-grep.github.io/guide/rule-config.html#rule
|
|
2
|
+
# from: ${ref("defaultSlot")}
|
|
3
|
+
# to: f-ref="{defaultSlot}"
|
|
4
|
+
id: binding - convert attribute directives
|
|
5
|
+
language: typescript
|
|
6
|
+
utils:
|
|
7
|
+
call-expression:
|
|
8
|
+
has:
|
|
9
|
+
nthChild: 1
|
|
10
|
+
kind: call_expression
|
|
11
|
+
all:
|
|
12
|
+
- matches: identifier
|
|
13
|
+
- matches: arguments
|
|
14
|
+
identifier:
|
|
15
|
+
has:
|
|
16
|
+
nthChild: 1
|
|
17
|
+
kind: identifier
|
|
18
|
+
pattern: $DIRECTIVE
|
|
19
|
+
arguments:
|
|
20
|
+
has:
|
|
21
|
+
kind: arguments
|
|
22
|
+
matches: string
|
|
23
|
+
string:
|
|
24
|
+
has:
|
|
25
|
+
kind: string
|
|
26
|
+
matches: string-fragment
|
|
27
|
+
string-fragment:
|
|
28
|
+
has:
|
|
29
|
+
kind: string_fragment
|
|
30
|
+
pattern: $STRING
|
|
31
|
+
constraints:
|
|
32
|
+
DIRECTIVE:
|
|
33
|
+
regex: ref|slotted|children
|
|
34
|
+
rule:
|
|
35
|
+
kind: template_substitution
|
|
36
|
+
matches: call-expression
|
|
37
|
+
fix:
|
|
38
|
+
'f-$DIRECTIVE="{$STRING}"'
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# https://ast-grep.github.io/guide/rule-config.html#rule
|
|
2
|
+
# from: ${(x, c) => x.foo(c.event)}
|
|
3
|
+
# to: {foo(event)}
|
|
4
|
+
id: binding - convert call expression with event argument
|
|
5
|
+
language: typescript
|
|
6
|
+
utils:
|
|
7
|
+
arrow-function:
|
|
8
|
+
has:
|
|
9
|
+
kind: arrow_function
|
|
10
|
+
matches: call-expression
|
|
11
|
+
call-expression:
|
|
12
|
+
has:
|
|
13
|
+
kind: call_expression
|
|
14
|
+
all:
|
|
15
|
+
- matches: handler-arguments
|
|
16
|
+
- matches: handler-expression
|
|
17
|
+
handler-expression:
|
|
18
|
+
has:
|
|
19
|
+
kind: member_expression
|
|
20
|
+
matches: handler-expression-property
|
|
21
|
+
handler-expression-property:
|
|
22
|
+
has:
|
|
23
|
+
kind: property_identifier
|
|
24
|
+
pattern: $A
|
|
25
|
+
handler-arguments:
|
|
26
|
+
has:
|
|
27
|
+
kind: arguments
|
|
28
|
+
matches: handler-arguments-member-expression
|
|
29
|
+
handler-arguments-member-expression:
|
|
30
|
+
has:
|
|
31
|
+
kind: member_expression
|
|
32
|
+
matches: handler-arguments-property-identifier
|
|
33
|
+
handler-arguments-property-identifier:
|
|
34
|
+
has:
|
|
35
|
+
kind: property_identifier
|
|
36
|
+
pattern: $B
|
|
37
|
+
rule:
|
|
38
|
+
kind: template_substitution
|
|
39
|
+
matches: arrow-function
|
|
40
|
+
fix:
|
|
41
|
+
'{$A($B)}'
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# https://ast-grep.github.io/guide/rule-config.html#rule
|
|
2
|
+
# from: ${x => x.foo}
|
|
3
|
+
# to: {{foo}}
|
|
4
|
+
id: binding - convert member expression
|
|
5
|
+
language: typescript
|
|
6
|
+
utils:
|
|
7
|
+
arrow-function:
|
|
8
|
+
has:
|
|
9
|
+
kind: arrow_function
|
|
10
|
+
all:
|
|
11
|
+
- matches: identifier
|
|
12
|
+
- matches: member-expression
|
|
13
|
+
member-expression:
|
|
14
|
+
has:
|
|
15
|
+
kind: member_expression
|
|
16
|
+
nthChild: 2
|
|
17
|
+
all:
|
|
18
|
+
- matches: identifier
|
|
19
|
+
- matches: property-identifier
|
|
20
|
+
identifier:
|
|
21
|
+
has:
|
|
22
|
+
kind: identifier
|
|
23
|
+
nthChild: 1
|
|
24
|
+
property-identifier:
|
|
25
|
+
has:
|
|
26
|
+
kind: property_identifier
|
|
27
|
+
nthChild: 2
|
|
28
|
+
pattern: $A
|
|
29
|
+
rule:
|
|
30
|
+
kind: template_substitution
|
|
31
|
+
matches: arrow-function
|
|
32
|
+
fix:
|
|
33
|
+
'{{$A}}'
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# https://ast-grep.github.io/guide/rule-config.html#rule
|
|
2
|
+
# from: export const template = html`<slot></slot>`
|
|
3
|
+
# to: `<slot></slot>`
|
|
4
|
+
id: convert tag function to template literal
|
|
5
|
+
language: typescript
|
|
6
|
+
utils:
|
|
7
|
+
is-tag-template:
|
|
8
|
+
has:
|
|
9
|
+
kind: template_string
|
|
10
|
+
pattern: $B
|
|
11
|
+
rule:
|
|
12
|
+
kind: call_expression
|
|
13
|
+
matches: is-tag-template
|
|
14
|
+
pattern: $A
|
|
15
|
+
fix:
|
|
16
|
+
'$B'
|