wrec 0.42.0 → 0.42.1
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/dist/{wrec-RkviIlbF.js → wrec-ClOIAA9J.js} +292 -232
- package/dist/wrec-ssr.es.js +5 -5
- package/dist/wrec.es.js +1 -1
- package/package.json +10 -10
- package/scripts/lint.js +62 -0
- package/dist/wrec-ssr.d.ts +0 -97
- package/dist/wrec.d.ts +0 -97
package/dist/wrec-ssr.es.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as e, c as t, i as n, l as r, n as i, o as a, r as o, s, t as c, u as l } from "./wrec-
|
|
1
|
+
import { a as e, c as t, i as n, l as r, n as i, o as a, r as o, s, t as c, u as l } from "./wrec-ClOIAA9J.js";
|
|
2
2
|
//#region \0rolldown/runtime.js
|
|
3
3
|
var u = Object.defineProperty, d = Object.getOwnPropertyDescriptor, f = Object.getOwnPropertyNames, p = Object.prototype.hasOwnProperty, m = (e, t) => () => (e && (t = e(e = 0)), t), h = (e, t) => () => (t || (e((t = { exports: {} }).exports, t), e = null), t.exports), g = (e, t) => {
|
|
4
4
|
let n = {};
|
|
@@ -4674,7 +4674,7 @@ var u = Object.defineProperty, d = Object.getOwnPropertyDescriptor, f = Object.g
|
|
|
4674
4674
|
for (var t = 1; t < e.length; t++) e[t][0] += e[t - 1][0] + 1;
|
|
4675
4675
|
return e;
|
|
4676
4676
|
}
|
|
4677
|
-
e.default = new Map(/*
|
|
4677
|
+
e.default = new Map(/* #__PURE__ */ t([
|
|
4678
4678
|
[9, "	"],
|
|
4679
4679
|
[0, "
"],
|
|
4680
4680
|
[22, "!"],
|
|
@@ -5467,11 +5467,11 @@ var u = Object.defineProperty, d = Object.getOwnPropertyDescriptor, f = Object.g
|
|
|
5467
5467
|
}],
|
|
5468
5468
|
[0, {
|
|
5469
5469
|
v: "≪",
|
|
5470
|
-
n: new Map(/*
|
|
5470
|
+
n: new Map(/* #__PURE__ */ t([[824, "≪̸"], [7577, "≪⃒"]]))
|
|
5471
5471
|
}],
|
|
5472
5472
|
[0, {
|
|
5473
5473
|
v: "≫",
|
|
5474
|
-
n: new Map(/*
|
|
5474
|
+
n: new Map(/* #__PURE__ */ t([[824, "≫̸"], [7577, "≫⃒"]]))
|
|
5475
5475
|
}],
|
|
5476
5476
|
[0, "≬"],
|
|
5477
5477
|
[0, "≭"],
|
|
@@ -6233,7 +6233,7 @@ var u = Object.defineProperty, d = Object.getOwnPropertyDescriptor, f = Object.g
|
|
|
6233
6233
|
n: 8421,
|
|
6234
6234
|
o: "⫽⃥"
|
|
6235
6235
|
}],
|
|
6236
|
-
[44343, { n: new Map(/*
|
|
6236
|
+
[44343, { n: new Map(/* #__PURE__ */ t([
|
|
6237
6237
|
[56476, "𝒜"],
|
|
6238
6238
|
[1, "𝒞"],
|
|
6239
6239
|
[0, "𝒟"],
|
package/dist/wrec.es.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { i as e, n as t, r as n, t as r, u as i } from "./wrec-
|
|
1
|
+
import { i as e, n as t, r as n, t as r, u as i } from "./wrec-ClOIAA9J.js";
|
|
2
2
|
export { r as Wrec, i as WrecState, t as createElement, n as css, e as html };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wrec",
|
|
3
|
-
"version": "0.42.
|
|
3
|
+
"version": "0.42.1",
|
|
4
4
|
"description": "a library that greatly simplifies building web components",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"component",
|
|
@@ -45,19 +45,19 @@
|
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
47
|
"node-html-parser": "^7.1.0",
|
|
48
|
-
"typescript": "^6.0.
|
|
48
|
+
"typescript": "^6.0.3",
|
|
49
49
|
"xss": "^1.0.15"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
|
-
"@playwright/test": "^1.
|
|
53
|
-
"@types/node": "^25.
|
|
52
|
+
"@playwright/test": "^1.60.0",
|
|
53
|
+
"@types/node": "^25.9.2",
|
|
54
54
|
"get-port": "^7.2.0",
|
|
55
|
-
"jsdom": "^29.
|
|
56
|
-
"oxfmt": "^0.
|
|
57
|
-
"oxlint": "^1.
|
|
58
|
-
"vite": "^8.0.
|
|
59
|
-
"vite-plugin-dts": "^
|
|
60
|
-
"vitest": "^4.1.
|
|
55
|
+
"jsdom": "^29.1.1",
|
|
56
|
+
"oxfmt": "^0.54.0",
|
|
57
|
+
"oxlint": "^1.69.0",
|
|
58
|
+
"vite": "^8.0.16",
|
|
59
|
+
"vite-plugin-dts": "^5.0.2",
|
|
60
|
+
"vitest": "^4.1.8"
|
|
61
61
|
},
|
|
62
62
|
"moduleResolution": "bundler",
|
|
63
63
|
"scripts": {
|
package/scripts/lint.js
CHANGED
|
@@ -168,6 +168,20 @@ function analyzeCodeNode(codeNode, checker, classNode, findings, metadata) {
|
|
|
168
168
|
// Walks the expression tree and records any issues that are found.
|
|
169
169
|
function visit(node) {
|
|
170
170
|
if (ts.isPropertyAccessExpression(node) && isWrecRooted(node.expression)) {
|
|
171
|
+
if (isPrivateName(node.name)) {
|
|
172
|
+
const name = getPrivateNameText(node.name);
|
|
173
|
+
const hasPrivateMember =
|
|
174
|
+
metadata.privateMethods.has(name) || metadata.privateProperties.has(name);
|
|
175
|
+
if (!hasPrivateMember) {
|
|
176
|
+
const finding = metadata.location ? { location: metadata.location, message: name } : name;
|
|
177
|
+
uniquePush(
|
|
178
|
+
isCallCallee(node) ? findings.undefinedMethods : findings.undefinedProperties,
|
|
179
|
+
finding,
|
|
180
|
+
);
|
|
181
|
+
}
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
|
|
171
185
|
const ownerType = checker.getTypeAtLocation(node.expression);
|
|
172
186
|
const symbol = ownerType.getProperty(node.name.text);
|
|
173
187
|
if (!symbol) {
|
|
@@ -201,6 +215,18 @@ function analyzeCodeNode(codeNode, checker, classNode, findings, metadata) {
|
|
|
201
215
|
}
|
|
202
216
|
}
|
|
203
217
|
} else if (ts.isPropertyAccessExpression(callee) && isWrecRooted(callee.expression)) {
|
|
218
|
+
if (isPrivateName(callee.name)) {
|
|
219
|
+
const name = getPrivateNameText(callee.name);
|
|
220
|
+
if (!metadata.privateMethods.has(name)) {
|
|
221
|
+
uniquePush(
|
|
222
|
+
findings.undefinedMethods,
|
|
223
|
+
metadata.location ? { location: metadata.location, message: name } : name,
|
|
224
|
+
);
|
|
225
|
+
}
|
|
226
|
+
node.arguments.forEach(visit);
|
|
227
|
+
return;
|
|
228
|
+
}
|
|
229
|
+
|
|
204
230
|
const ownerType = checker.getTypeAtLocation(callee.expression);
|
|
205
231
|
const symbol = ownerType.getProperty(callee.name.text);
|
|
206
232
|
if (!symbol) {
|
|
@@ -437,6 +463,29 @@ function collectMethodCodeItems(classNode) {
|
|
|
437
463
|
return codeItems;
|
|
438
464
|
}
|
|
439
465
|
|
|
466
|
+
// Collects private instance member names defined in a component class.
|
|
467
|
+
function collectPrivateMembers(classNode) {
|
|
468
|
+
const privateMethods = new Set();
|
|
469
|
+
const privateProperties = new Set();
|
|
470
|
+
|
|
471
|
+
for (const member of classNode.members) {
|
|
472
|
+
const name = getMemberName(member);
|
|
473
|
+
if (!name?.startsWith("#")) continue;
|
|
474
|
+
|
|
475
|
+
if (ts.isMethodDeclaration(member)) {
|
|
476
|
+
privateMethods.add(name);
|
|
477
|
+
} else if (
|
|
478
|
+
ts.isGetAccessorDeclaration(member) ||
|
|
479
|
+
ts.isPropertyDeclaration(member) ||
|
|
480
|
+
ts.isSetAccessorDeclaration(member)
|
|
481
|
+
) {
|
|
482
|
+
privateProperties.add(name);
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
return { privateMethods, privateProperties };
|
|
487
|
+
}
|
|
488
|
+
|
|
440
489
|
// Collects the property names declared in
|
|
441
490
|
// a component's static properties object.
|
|
442
491
|
function collectSupportedPropertyNames(classNode) {
|
|
@@ -1243,6 +1292,11 @@ function getParameterType(checker, parameterSymbol, location, isRestArgument) {
|
|
|
1243
1292
|
return typeArguments[0] ?? parameterType;
|
|
1244
1293
|
}
|
|
1245
1294
|
|
|
1295
|
+
// Returns the text form of a private identifier.
|
|
1296
|
+
function getPrivateNameText(name) {
|
|
1297
|
+
return name.text;
|
|
1298
|
+
}
|
|
1299
|
+
|
|
1246
1300
|
// Returns the Wrec property config type name for a normalized type string.
|
|
1247
1301
|
function getPropertyConfigTypeName(typeName) {
|
|
1248
1302
|
switch (typeName) {
|
|
@@ -1482,6 +1536,11 @@ function isNumericLikeType(type) {
|
|
|
1482
1536
|
});
|
|
1483
1537
|
}
|
|
1484
1538
|
|
|
1539
|
+
// Returns whether a node is a private identifier.
|
|
1540
|
+
function isPrivateName(node) {
|
|
1541
|
+
return ts.isPrivateIdentifier(node);
|
|
1542
|
+
}
|
|
1543
|
+
|
|
1485
1544
|
// Returns whether a file defines at least one Wrec component class.
|
|
1486
1545
|
function isWrecComponentFile(filePath) {
|
|
1487
1546
|
const sourceText = fs.readFileSync(filePath, "utf8");
|
|
@@ -1535,6 +1594,7 @@ export function lintSource(filePath, sourceText, options = {}) {
|
|
|
1535
1594
|
} = extractProperties(sourceFile, checker, classNode);
|
|
1536
1595
|
const declaredPropertyTypes = collectDeclaredPropertyTypes(classNode);
|
|
1537
1596
|
const getterNames = collectGetterNames(classNode);
|
|
1597
|
+
const privateMembers = collectPrivateMembers(classNode);
|
|
1538
1598
|
const allMethods = collectClassMethods(classNode);
|
|
1539
1599
|
const findings = {
|
|
1540
1600
|
duplicateProperties,
|
|
@@ -1655,6 +1715,8 @@ export function lintSource(filePath, sourceText, options = {}) {
|
|
|
1655
1715
|
checkContextCalls: allCodeItems[index]?.checkContextCalls ?? true,
|
|
1656
1716
|
eventHandler: allCodeItems[index]?.eventHandler ?? false,
|
|
1657
1717
|
location: allCodeItems[index]?.location ?? null,
|
|
1718
|
+
privateMethods: privateMembers.privateMethods,
|
|
1719
|
+
privateProperties: privateMembers.privateProperties,
|
|
1658
1720
|
sourceFile: augmentedSourceFile,
|
|
1659
1721
|
});
|
|
1660
1722
|
});
|
package/dist/wrec-ssr.d.ts
DELETED
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
declare type ChangeCallback = (change: StateChange) => void;
|
|
2
|
-
|
|
3
|
-
export declare function createElement(name: string, attributes: StringToString, innerHTML: string): HTMLElement;
|
|
4
|
-
|
|
5
|
-
export declare function css(strings: TemplateStringsArray, ...values: unknown[]): string;
|
|
6
|
-
|
|
7
|
-
export declare function html(strings: TemplateStringsArray, ...values: unknown[]): string;
|
|
8
|
-
|
|
9
|
-
declare const HTMLElementBase: {
|
|
10
|
-
new (): HTMLElement;
|
|
11
|
-
prototype: HTMLElement;
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
declare type LooseObject = Record<string, unknown>;
|
|
15
|
-
|
|
16
|
-
declare type PropertyConfig<T = any> = {
|
|
17
|
-
computed?: string;
|
|
18
|
-
dispatch?: boolean;
|
|
19
|
-
required?: boolean;
|
|
20
|
-
type: PropertyType;
|
|
21
|
-
usedBy?: string | string[];
|
|
22
|
-
validate?: (value: T) => string | void;
|
|
23
|
-
value?: T;
|
|
24
|
-
values?: T extends string ? string[] : never;
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
declare type PropertyType = typeof Array | typeof Boolean | typeof HTMLElementBase | typeof Number | typeof Object | typeof String;
|
|
28
|
-
|
|
29
|
-
declare type StateChange = {
|
|
30
|
-
state: WrecState;
|
|
31
|
-
statePath: string;
|
|
32
|
-
oldValue: unknown;
|
|
33
|
-
newValue: unknown;
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
declare type StringToAny = Record<string, any>;
|
|
37
|
-
|
|
38
|
-
declare type StringToString = Record<string, string>;
|
|
39
|
-
|
|
40
|
-
export declare abstract class Wrec extends HTMLElementBase {
|
|
41
|
-
#private;
|
|
42
|
-
private static attrToPropMap;
|
|
43
|
-
private static propToAttrMap;
|
|
44
|
-
private static computedGraph;
|
|
45
|
-
static context: {};
|
|
46
|
-
static css: string;
|
|
47
|
-
private static elementName;
|
|
48
|
-
static formAssociated: boolean;
|
|
49
|
-
static html: string;
|
|
50
|
-
static properties: Record<string, PropertyConfig>;
|
|
51
|
-
private static propToComputedMap;
|
|
52
|
-
private static methodToExprsMap;
|
|
53
|
-
private static propToExprsMap;
|
|
54
|
-
private static registeredComputedProps;
|
|
55
|
-
private static computedPropsRegistered;
|
|
56
|
-
private static template;
|
|
57
|
-
static define(elementName: string): void;
|
|
58
|
-
constructor();
|
|
59
|
-
attributeChangedCallback(attrName: string, _oldValue: string | null, newValue: string | null): void;
|
|
60
|
-
batchSet(changes: StringToAny): void;
|
|
61
|
-
private static buildHTML;
|
|
62
|
-
changed(_statePath: string, componentProp: string, newValue: unknown): void;
|
|
63
|
-
connectedCallback(): Promise<void>;
|
|
64
|
-
disconnectedCallback(): void;
|
|
65
|
-
dispatch(name: string, detail: any): void;
|
|
66
|
-
displayIfSet(value: any, display?: string): string;
|
|
67
|
-
formAssociatedCallback(): void;
|
|
68
|
-
formResetCallback(): void;
|
|
69
|
-
private static getAttrName;
|
|
70
|
-
static getPropName(attrName: string): string;
|
|
71
|
-
static get observedAttributes(): string[];
|
|
72
|
-
propertyChangedCallback(_propName: string, _oldValue: unknown, _newValue: unknown): void;
|
|
73
|
-
ready(): void;
|
|
74
|
-
setAttributeSafe(name: string, value: string): void;
|
|
75
|
-
setFormValue(propName: string, value: string): void;
|
|
76
|
-
static ssr(properties?: StringToAny): string;
|
|
77
|
-
/**
|
|
78
|
-
* @param state - WrecState object
|
|
79
|
-
* @param map - object whose keys are state properties and
|
|
80
|
-
* whose values are component properties
|
|
81
|
-
*/
|
|
82
|
-
useState(state: WrecState, map?: StringToString): void;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
export declare class WrecState {
|
|
86
|
-
#private;
|
|
87
|
-
static get(name: string): WrecState | undefined;
|
|
88
|
-
[key: string]: unknown;
|
|
89
|
-
constructor(name: string, initial?: LooseObject);
|
|
90
|
-
constructor(name: string, persist: boolean, initial?: LooseObject);
|
|
91
|
-
subscribe(callback: ChangeCallback, paths?: string[]): () => void;
|
|
92
|
-
addProperty(propName: string, initialValue: unknown): void;
|
|
93
|
-
get id(): symbol;
|
|
94
|
-
log(): void;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
export { }
|
package/dist/wrec.d.ts
DELETED
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
declare type ChangeCallback = (change: StateChange) => void;
|
|
2
|
-
|
|
3
|
-
export declare function createElement(name: string, attributes: StringToString, innerHTML: string): HTMLElement;
|
|
4
|
-
|
|
5
|
-
export declare function css(strings: TemplateStringsArray, ...values: unknown[]): string;
|
|
6
|
-
|
|
7
|
-
export declare function html(strings: TemplateStringsArray, ...values: unknown[]): string;
|
|
8
|
-
|
|
9
|
-
declare const HTMLElementBase: {
|
|
10
|
-
new (): HTMLElement;
|
|
11
|
-
prototype: HTMLElement;
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
declare type LooseObject = Record<string, unknown>;
|
|
15
|
-
|
|
16
|
-
declare type PropertyConfig<T = any> = {
|
|
17
|
-
computed?: string;
|
|
18
|
-
dispatch?: boolean;
|
|
19
|
-
required?: boolean;
|
|
20
|
-
type: PropertyType;
|
|
21
|
-
usedBy?: string | string[];
|
|
22
|
-
validate?: (value: T) => string | void;
|
|
23
|
-
value?: T;
|
|
24
|
-
values?: T extends string ? string[] : never;
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
declare type PropertyType = typeof Array | typeof Boolean | typeof HTMLElementBase | typeof Number | typeof Object | typeof String;
|
|
28
|
-
|
|
29
|
-
declare type StateChange = {
|
|
30
|
-
state: WrecState;
|
|
31
|
-
statePath: string;
|
|
32
|
-
oldValue: unknown;
|
|
33
|
-
newValue: unknown;
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
declare type StringToAny = Record<string, any>;
|
|
37
|
-
|
|
38
|
-
declare type StringToString = Record<string, string>;
|
|
39
|
-
|
|
40
|
-
export declare abstract class Wrec extends HTMLElementBase {
|
|
41
|
-
#private;
|
|
42
|
-
private static attrToPropMap;
|
|
43
|
-
private static propToAttrMap;
|
|
44
|
-
private static computedGraph;
|
|
45
|
-
static context: {};
|
|
46
|
-
static css: string;
|
|
47
|
-
private static elementName;
|
|
48
|
-
static formAssociated: boolean;
|
|
49
|
-
static html: string;
|
|
50
|
-
static properties: Record<string, PropertyConfig>;
|
|
51
|
-
private static propToComputedMap;
|
|
52
|
-
private static methodToExprsMap;
|
|
53
|
-
private static propToExprsMap;
|
|
54
|
-
private static registeredComputedProps;
|
|
55
|
-
private static computedPropsRegistered;
|
|
56
|
-
private static template;
|
|
57
|
-
static define(elementName: string): void;
|
|
58
|
-
constructor();
|
|
59
|
-
attributeChangedCallback(attrName: string, _oldValue: string | null, newValue: string | null): void;
|
|
60
|
-
batchSet(changes: StringToAny): void;
|
|
61
|
-
private static buildHTML;
|
|
62
|
-
changed(_statePath: string, componentProp: string, newValue: unknown): void;
|
|
63
|
-
connectedCallback(): Promise<void>;
|
|
64
|
-
disconnectedCallback(): void;
|
|
65
|
-
dispatch(name: string, detail: any): void;
|
|
66
|
-
displayIfSet(value: any, display?: string): string;
|
|
67
|
-
formAssociatedCallback(): void;
|
|
68
|
-
formResetCallback(): void;
|
|
69
|
-
private static getAttrName;
|
|
70
|
-
static getPropName(attrName: string): string;
|
|
71
|
-
static get observedAttributes(): string[];
|
|
72
|
-
propertyChangedCallback(_propName: string, _oldValue: unknown, _newValue: unknown): void;
|
|
73
|
-
ready(): void;
|
|
74
|
-
setAttributeSafe(name: string, value: string): void;
|
|
75
|
-
setFormValue(propName: string, value: string): void;
|
|
76
|
-
static ssr(properties?: StringToAny): string;
|
|
77
|
-
/**
|
|
78
|
-
* @param state - WrecState object
|
|
79
|
-
* @param map - object whose keys are state properties and
|
|
80
|
-
* whose values are component properties
|
|
81
|
-
*/
|
|
82
|
-
useState(state: WrecState, map?: StringToString): void;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
export declare class WrecState {
|
|
86
|
-
#private;
|
|
87
|
-
static get(name: string): WrecState | undefined;
|
|
88
|
-
[key: string]: unknown;
|
|
89
|
-
constructor(name: string, initial?: LooseObject);
|
|
90
|
-
constructor(name: string, persist: boolean, initial?: LooseObject);
|
|
91
|
-
subscribe(callback: ChangeCallback, paths?: string[]): () => void;
|
|
92
|
-
addProperty(propName: string, initialValue: unknown): void;
|
|
93
|
-
get id(): symbol;
|
|
94
|
-
log(): void;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
export { }
|