@protontech/autofill 0.0.33835493 → 0.0.35059265

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.
@@ -1,20 +1,18 @@
1
1
  import { getComputerForFeatures } from "@protontech/autofill/features/feature";
2
- import { fieldFeatures } from "./abstract.field";
3
- import { formFeaturesComputer } from "./abstract.form";
4
- import { emailFeatures } from "./field.email";
5
- import { otpFeatures } from "./field.otp";
6
- import { passwordFeatures } from "./field.password";
7
- import { usernameFeatures } from "./field.username";
8
- import { usernameHiddenFeatures } from "./field.username-hidden";
2
+ import { setFormFeaturesComputer } from "@protontech/autofill/features/registry";
3
+ import { emailFeatureNames, fieldFeatureNames, formFeatureNames, otpFeatureNames, passwordFeatureNames, sortedEmailFeatures, sortedFieldFeatures, sortedFormFeatures, sortedOtpFeatures, sortedPasswordFeatures, sortedUsernameFeatures, sortedUsernameHiddenFeatures, usernameFeatureNames, usernameHiddenFeatureNames, } from "@protontech/autofill/features/sorted.gen";
4
+ const formFeaturesComputer = getComputerForFeatures(sortedFormFeatures, formFeatureNames);
5
+ setFormFeaturesComputer(formFeaturesComputer);
6
+ const passwordFeaturesComputer = getComputerForFeatures(sortedPasswordFeatures, passwordFeatureNames);
9
7
  export const featureProvider = {
10
- field: getComputerForFeatures(fieldFeatures),
8
+ field: getComputerForFeatures(sortedFieldFeatures, fieldFeatureNames),
11
9
  form: formFeaturesComputer,
12
- email: getComputerForFeatures(emailFeatures),
13
- "new-password": getComputerForFeatures(passwordFeatures),
14
- otp: getComputerForFeatures(otpFeatures),
15
- password: getComputerForFeatures(passwordFeatures),
16
- username: getComputerForFeatures(usernameFeatures),
17
- "username-hidden": getComputerForFeatures(usernameHiddenFeatures),
10
+ email: getComputerForFeatures(sortedEmailFeatures, emailFeatureNames),
11
+ "new-password": passwordFeaturesComputer,
12
+ otp: getComputerForFeatures(sortedOtpFeatures, otpFeatureNames),
13
+ password: passwordFeaturesComputer,
14
+ username: getComputerForFeatures(sortedUsernameFeatures, usernameFeatureNames),
15
+ "username-hidden": getComputerForFeatures(sortedUsernameHiddenFeatures, usernameHiddenFeatureNames),
18
16
  login: formFeaturesComputer,
19
17
  recovery: formFeaturesComputer,
20
18
  register: formFeaturesComputer,
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@protontech/autofill",
3
- "version": "0.0.33835493",
3
+ "version": "0.0.35059265",
4
4
  "private": false,
5
5
  "scripts": {
6
6
  "typecheck": "tsc --noEmit"
7
7
  },
8
8
  "dependencies": {
9
- "@protontech/fathom": "0.0.33835493",
10
- "@protontech/ml-inference": "0.0.33835493"
9
+ "@protontech/fathom": "0.0.35059265",
10
+ "@protontech/ml-inference": "0.0.35059265"
11
11
  },
12
12
  "devDependencies": {
13
13
  "@types/jest": "^29.5.14",
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,32 @@
1
+ import { mkdirSync, writeFileSync } from "node:fs";
2
+ import { dirname } from "node:path";
3
+ import { topologicalSort } from "../features/feature";
4
+ import { fieldFeatures } from "../features/v1/abstract.field";
5
+ import { formFeatures } from "../features/v1/abstract.form";
6
+ import { emailFeatures } from "../features/v1/field.email";
7
+ import { otpFeatures } from "../features/v1/field.otp";
8
+ import { passwordFeatures } from "../features/v1/field.password";
9
+ import { usernameFeatures } from "../features/v1/field.username";
10
+ import { usernameHiddenFeatures } from "../features/v1/field.username-hidden";
11
+ const sets = [
12
+ { name: "fieldFeatures", sourceModule: "./v1/abstract.field", features: fieldFeatures },
13
+ { name: "formFeatures", sourceModule: "./v1/abstract.form", features: formFeatures },
14
+ { name: "emailFeatures", sourceModule: "./v1/field.email", features: emailFeatures },
15
+ { name: "otpFeatures", sourceModule: "./v1/field.otp", features: otpFeatures },
16
+ { name: "passwordFeatures", sourceModule: "./v1/field.password", features: passwordFeatures },
17
+ { name: "usernameFeatures", sourceModule: "./v1/field.username", features: usernameFeatures },
18
+ { name: "usernameHiddenFeatures", sourceModule: "./v1/field.username-hidden", features: usernameHiddenFeatures },
19
+ ];
20
+ for (const { features } of sets)
21
+ topologicalSort(features);
22
+ const capitalize = (s) => s.charAt(0).toUpperCase() + s.slice(1);
23
+ const namesExport = (setName) => setName.replace(/Features$/, "FeatureNames");
24
+ const sortedExport = (setName) => `sorted${capitalize(setName)}`;
25
+ const banner = "// Generated by `bazel run //pass_ml/js/autofill:write_sorted_features` — do not edit.\n";
26
+ const imports = [`import { topologicalSort } from "@protontech/autofill/features/feature";`, ...sets.map(({ name, sourceModule }) => `import { ${name} } from "${sourceModule}";`)].join("\n");
27
+ const exports = sets.flatMap(({ name }) => [`export const ${sortedExport(name)} = topologicalSort(${name});`, `export const ${namesExport(name)} = Object.values(${name}).map((f) => f.name);`]).join("\n");
28
+ const outPath = process.argv[2];
29
+ if (!outPath)
30
+ throw new Error("usage: gen-sorted-features <out.ts>");
31
+ mkdirSync(dirname(outPath), { recursive: true });
32
+ writeFileSync(outPath, `${banner}\n${imports}\n\n${exports}\n`);