fast-publicodes 1.0.0 → 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.
- package/README.md +2 -2
- package/dist/binding.d.ts +1 -0
- package/dist/engine.d.ts +6 -1
- package/dist/engine.js +28 -4
- package/dist/types.d.ts +9 -0
- package/native/fast-publicodes.darwin-arm64.node +0 -0
- package/native/fast-publicodes.darwin-x64.node +0 -0
- package/native/fast-publicodes.linux-arm64-gnu.node +0 -0
- package/native/fast-publicodes.linux-arm64-musl.node +0 -0
- package/native/fast-publicodes.linux-x64-gnu.node +0 -0
- package/native/fast-publicodes.linux-x64-musl.node +0 -0
- package/native/fast-publicodes.win32-x64-msvc.node +0 -0
- package/native/index.cjs +54 -54
- package/native/index.d.cts +6 -1
- package/package.json +1 -1
- package/wasm/fast_publicodes.d.ts +7 -1
- package/wasm/fast_publicodes.js +16 -1
- package/wasm/fast_publicodes_bg.wasm +0 -0
- package/wasm/fast_publicodes_bg.wasm.d.ts +1 -0
package/README.md
CHANGED
|
@@ -41,8 +41,8 @@ On the [modele-social](https://www.npmjs.com/package/modele-social) rules (`pnpm
|
|
|
41
41
|
|
|
42
42
|
## Limitations
|
|
43
43
|
|
|
44
|
-
- **No AST.** `evaluate()` returns `nodeValue`, `unit` and `missingVariables` without `explanation`, and rules returned by `getRule()` and `getParsedRules()` carry their metadata without their node tree. `parsePublicodes`, `reduceAST`, `transformAST`, `traverseASTNode`, `utils.cyclicDependencies`, `utils.disambiguateReferenceNode` and `utils.updateReferencesMapsFromReferenceNode` are not provided, and `evaluate()`
|
|
45
|
-
- **
|
|
44
|
+
- **No AST.** `evaluate()` returns `nodeValue`, `unit` and `missingVariables` without `explanation`, and rules returned by `getRule()` and `getParsedRules()` carry their metadata without their node tree; their `suggestions` are opaque values that only `evaluate()` reads. `parsePublicodes`, `reduceAST`, `transformAST`, `traverseASTNode`, `utils.cyclicDependencies`, `utils.disambiguateReferenceNode` and `utils.updateReferencesMapsFromReferenceNode` are not provided, and `evaluate()` accepts no AST node other than these suggestions.
|
|
45
|
+
- **Internal fields.** Of the members `publicodes` marks as internal, only `context.nodesTypes` exists, with the type inferred for each rule `getRule()` returns; `baseContext`, `publicParsedRules`, `cache`, `evaluateNode` and the rest of `context` do not.
|
|
46
46
|
- **`undefined` inside rules.** A property of a rule set to `undefined` counts as absent, where `publicodes` reads some of them as an empty value.
|
|
47
47
|
|
|
48
48
|
## Development
|
package/dist/binding.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ export interface Binding {
|
|
|
8
8
|
export interface NativeEngine {
|
|
9
9
|
setSituation(situation: string, keepPrevious: boolean, strict: boolean): object;
|
|
10
10
|
evaluate(text: string, json: boolean): object;
|
|
11
|
+
evaluateSuggestion(rule: string, name: string): object;
|
|
11
12
|
evaluations(): unknown;
|
|
12
13
|
missingVariables(evaluations: unknown, index: number): object;
|
|
13
14
|
takeWarnings(): object;
|
package/dist/engine.d.ts
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
|
-
import type { EngineOptions, EvaluatedNode, ParsedRules, Possibility, PublicodesExpression, RawPublicodes, RuleNode, Situation } from "./types.js";
|
|
1
|
+
import type { EngineOptions, EvaluatedNode, InferedType, ParsedRules, Possibility, PublicodesExpression, RawPublicodes, RuleNode, Situation } from "./types.js";
|
|
2
2
|
export declare class Engine<RuleNames extends string = string> {
|
|
3
3
|
private native;
|
|
4
4
|
private logger;
|
|
5
5
|
private publicSituation;
|
|
6
6
|
private parsedRules;
|
|
7
7
|
private rules;
|
|
8
|
+
/** `nodesTypes` alone, for the rule nodes `getRule()` returns. */
|
|
9
|
+
context: {
|
|
10
|
+
nodesTypes: WeakMap<RuleNode, InferedType>;
|
|
11
|
+
};
|
|
8
12
|
private warningTexts;
|
|
9
13
|
private unitKey;
|
|
10
14
|
/** Results by evaluated value, until the cache is reset. */
|
|
@@ -21,6 +25,7 @@ export declare class Engine<RuleNames extends string = string> {
|
|
|
21
25
|
private accept;
|
|
22
26
|
getSituation(): Situation<RuleNames>;
|
|
23
27
|
evaluate(value: PublicodesExpression): EvaluatedNode;
|
|
28
|
+
private evaluateNative;
|
|
24
29
|
getRule(dottedName: RuleNames): RuleNode<RuleNames>;
|
|
25
30
|
getParsedRules(): ParsedRules<RuleNames>;
|
|
26
31
|
getPossibilitiesFor(dottedName: RuleNames, { filterNotApplicable }?: {
|
package/dist/engine.js
CHANGED
|
@@ -63,12 +63,18 @@ function createNative(rules, options, logger, unitKey) {
|
|
|
63
63
|
throw fromNative(details);
|
|
64
64
|
}
|
|
65
65
|
}
|
|
66
|
+
/** The rule and name of each suggestion `getRule()` returns, which any engine evaluates. */
|
|
67
|
+
const suggestionSources = new WeakMap();
|
|
66
68
|
export class Engine {
|
|
67
69
|
native;
|
|
68
70
|
logger;
|
|
69
71
|
publicSituation = {};
|
|
70
72
|
parsedRules;
|
|
71
73
|
rules = new Map();
|
|
74
|
+
/** `nodesTypes` alone, for the rule nodes `getRule()` returns. */
|
|
75
|
+
context = {
|
|
76
|
+
nodesTypes: new WeakMap(),
|
|
77
|
+
};
|
|
72
78
|
warningTexts = [];
|
|
73
79
|
unitKey;
|
|
74
80
|
/** Results by evaluated value, until the cache is reset. */
|
|
@@ -134,9 +140,7 @@ export class Engine {
|
|
|
134
140
|
if (typeof value === "object" && value !== null && "nodeKind" in value) {
|
|
135
141
|
throw new PublicodesError("EngineError", "fast-publicodes n'évalue pas les nœuds d'AST", {});
|
|
136
142
|
}
|
|
137
|
-
const
|
|
138
|
-
const text = json ? toJson(value) : value;
|
|
139
|
-
const result = this.native.evaluate(text, json);
|
|
143
|
+
const result = this.evaluateNative(value);
|
|
140
144
|
this.logWarnings(result);
|
|
141
145
|
this.unitKey?.rethrow();
|
|
142
146
|
const { nodeValue, index, ...nativeUnit } = unwrap(result);
|
|
@@ -157,12 +161,31 @@ export class Engine {
|
|
|
157
161
|
this.evaluations.set(value, evaluation);
|
|
158
162
|
return evaluation;
|
|
159
163
|
}
|
|
164
|
+
evaluateNative(value) {
|
|
165
|
+
const suggestion = typeof value === "object" ? suggestionSources.get(value) : undefined;
|
|
166
|
+
if (suggestion) {
|
|
167
|
+
return this.native.evaluateSuggestion(suggestion.rule, suggestion.name);
|
|
168
|
+
}
|
|
169
|
+
const json = typeof value !== "string";
|
|
170
|
+
const text = json ? toJson(value) : value;
|
|
171
|
+
return this.native.evaluate(text, json);
|
|
172
|
+
}
|
|
160
173
|
getRule(dottedName) {
|
|
161
174
|
let rule = this.rules.get(dottedName);
|
|
162
175
|
if (!rule) {
|
|
163
176
|
const result = this.native.rule(dottedName);
|
|
164
|
-
|
|
177
|
+
const { node, type, suggestions } = JSON.parse(unwrap(result).rule);
|
|
178
|
+
rule = { ...node, suggestions: {} };
|
|
179
|
+
for (const name of suggestions) {
|
|
180
|
+
const suggestion = Object.freeze({});
|
|
181
|
+
suggestionSources.set(suggestion, { rule: dottedName, name });
|
|
182
|
+
rule.suggestions[name] = suggestion;
|
|
183
|
+
}
|
|
165
184
|
this.rules.set(dottedName, rule);
|
|
185
|
+
this.context.nodesTypes.set(rule, {
|
|
186
|
+
isNullable: type.isNullable ?? undefined,
|
|
187
|
+
type: type.type ?? undefined,
|
|
188
|
+
});
|
|
166
189
|
}
|
|
167
190
|
return rule;
|
|
168
191
|
}
|
|
@@ -212,6 +235,7 @@ export class Engine {
|
|
|
212
235
|
copy.publicSituation = { ...this.publicSituation };
|
|
213
236
|
copy.parsedRules = this.parsedRules;
|
|
214
237
|
copy.rules = this.rules;
|
|
238
|
+
copy.context = this.context;
|
|
215
239
|
copy.warningTexts = [...this.warningTexts];
|
|
216
240
|
copy.unitKey = this.unitKey;
|
|
217
241
|
copy.evaluations = copyCache ? new Map(this.evaluations) : new Map();
|
package/dist/types.d.ts
CHANGED
|
@@ -36,6 +36,8 @@ export interface RuleNode<Name extends string = string> {
|
|
|
36
36
|
private: boolean;
|
|
37
37
|
virtualRule: boolean;
|
|
38
38
|
rawNode: Rule;
|
|
39
|
+
/** What `evaluate()` takes to evaluate each suggestion, as in the rule's context. */
|
|
40
|
+
suggestions: Record<string, Suggestion>;
|
|
39
41
|
possibilities: {
|
|
40
42
|
nodeKind: "une possibilité";
|
|
41
43
|
type: "number" | "string" | "reference";
|
|
@@ -43,6 +45,13 @@ export interface RuleNode<Name extends string = string> {
|
|
|
43
45
|
explanation: Possibility[];
|
|
44
46
|
} | null;
|
|
45
47
|
}
|
|
48
|
+
/** A suggestion of a rule, which only `evaluate()` reads. */
|
|
49
|
+
export type Suggestion = Readonly<Record<string, never>>;
|
|
50
|
+
/** The type `publicodes` infers for a node. */
|
|
51
|
+
export interface InferedType {
|
|
52
|
+
isNullable: boolean | undefined;
|
|
53
|
+
type: "number" | "string" | "boolean" | "date" | undefined;
|
|
54
|
+
}
|
|
46
55
|
export type ParsedRules<RuleNames extends string = string> = Record<RuleNames, RuleNode<RuleNames>>;
|
|
47
56
|
export interface Logger {
|
|
48
57
|
log(message: string): void;
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/native/index.cjs
CHANGED
|
@@ -89,8 +89,8 @@ function requireNative() {
|
|
|
89
89
|
try {
|
|
90
90
|
const binding = require('fast-publicodes-android-arm64')
|
|
91
91
|
const bindingPackageVersion = require('fast-publicodes-android-arm64/package.json').version
|
|
92
|
-
if (bindingPackageVersion !== '1.
|
|
93
|
-
throw new Error(`Native binding package version mismatch, expected 1.
|
|
92
|
+
if (bindingPackageVersion !== '1.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
93
|
+
throw new Error(`Native binding package version mismatch, expected 1.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
94
94
|
}
|
|
95
95
|
return binding
|
|
96
96
|
} catch (e) {
|
|
@@ -105,8 +105,8 @@ function requireNative() {
|
|
|
105
105
|
try {
|
|
106
106
|
const binding = require('fast-publicodes-android-arm-eabi')
|
|
107
107
|
const bindingPackageVersion = require('fast-publicodes-android-arm-eabi/package.json').version
|
|
108
|
-
if (bindingPackageVersion !== '1.
|
|
109
|
-
throw new Error(`Native binding package version mismatch, expected 1.
|
|
108
|
+
if (bindingPackageVersion !== '1.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
109
|
+
throw new Error(`Native binding package version mismatch, expected 1.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
110
110
|
}
|
|
111
111
|
return binding
|
|
112
112
|
} catch (e) {
|
|
@@ -126,8 +126,8 @@ function requireNative() {
|
|
|
126
126
|
try {
|
|
127
127
|
const binding = require('fast-publicodes-win32-x64-gnu')
|
|
128
128
|
const bindingPackageVersion = require('fast-publicodes-win32-x64-gnu/package.json').version
|
|
129
|
-
if (bindingPackageVersion !== '1.
|
|
130
|
-
throw new Error(`Native binding package version mismatch, expected 1.
|
|
129
|
+
if (bindingPackageVersion !== '1.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
130
|
+
throw new Error(`Native binding package version mismatch, expected 1.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
131
131
|
}
|
|
132
132
|
return binding
|
|
133
133
|
} catch (e) {
|
|
@@ -142,8 +142,8 @@ function requireNative() {
|
|
|
142
142
|
try {
|
|
143
143
|
const binding = require('fast-publicodes-win32-x64-msvc')
|
|
144
144
|
const bindingPackageVersion = require('fast-publicodes-win32-x64-msvc/package.json').version
|
|
145
|
-
if (bindingPackageVersion !== '1.
|
|
146
|
-
throw new Error(`Native binding package version mismatch, expected 1.
|
|
145
|
+
if (bindingPackageVersion !== '1.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
146
|
+
throw new Error(`Native binding package version mismatch, expected 1.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
147
147
|
}
|
|
148
148
|
return binding
|
|
149
149
|
} catch (e) {
|
|
@@ -159,8 +159,8 @@ function requireNative() {
|
|
|
159
159
|
try {
|
|
160
160
|
const binding = require('fast-publicodes-win32-ia32-msvc')
|
|
161
161
|
const bindingPackageVersion = require('fast-publicodes-win32-ia32-msvc/package.json').version
|
|
162
|
-
if (bindingPackageVersion !== '1.
|
|
163
|
-
throw new Error(`Native binding package version mismatch, expected 1.
|
|
162
|
+
if (bindingPackageVersion !== '1.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
163
|
+
throw new Error(`Native binding package version mismatch, expected 1.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
164
164
|
}
|
|
165
165
|
return binding
|
|
166
166
|
} catch (e) {
|
|
@@ -175,8 +175,8 @@ function requireNative() {
|
|
|
175
175
|
try {
|
|
176
176
|
const binding = require('fast-publicodes-win32-arm64-msvc')
|
|
177
177
|
const bindingPackageVersion = require('fast-publicodes-win32-arm64-msvc/package.json').version
|
|
178
|
-
if (bindingPackageVersion !== '1.
|
|
179
|
-
throw new Error(`Native binding package version mismatch, expected 1.
|
|
178
|
+
if (bindingPackageVersion !== '1.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
179
|
+
throw new Error(`Native binding package version mismatch, expected 1.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
180
180
|
}
|
|
181
181
|
return binding
|
|
182
182
|
} catch (e) {
|
|
@@ -194,8 +194,8 @@ function requireNative() {
|
|
|
194
194
|
try {
|
|
195
195
|
const binding = require('fast-publicodes-darwin-universal')
|
|
196
196
|
const bindingPackageVersion = require('fast-publicodes-darwin-universal/package.json').version
|
|
197
|
-
if (bindingPackageVersion !== '1.
|
|
198
|
-
throw new Error(`Native binding package version mismatch, expected 1.
|
|
197
|
+
if (bindingPackageVersion !== '1.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
198
|
+
throw new Error(`Native binding package version mismatch, expected 1.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
199
199
|
}
|
|
200
200
|
return binding
|
|
201
201
|
} catch (e) {
|
|
@@ -210,8 +210,8 @@ function requireNative() {
|
|
|
210
210
|
try {
|
|
211
211
|
const binding = require('fast-publicodes-darwin-x64')
|
|
212
212
|
const bindingPackageVersion = require('fast-publicodes-darwin-x64/package.json').version
|
|
213
|
-
if (bindingPackageVersion !== '1.
|
|
214
|
-
throw new Error(`Native binding package version mismatch, expected 1.
|
|
213
|
+
if (bindingPackageVersion !== '1.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
214
|
+
throw new Error(`Native binding package version mismatch, expected 1.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
215
215
|
}
|
|
216
216
|
return binding
|
|
217
217
|
} catch (e) {
|
|
@@ -226,8 +226,8 @@ function requireNative() {
|
|
|
226
226
|
try {
|
|
227
227
|
const binding = require('fast-publicodes-darwin-arm64')
|
|
228
228
|
const bindingPackageVersion = require('fast-publicodes-darwin-arm64/package.json').version
|
|
229
|
-
if (bindingPackageVersion !== '1.
|
|
230
|
-
throw new Error(`Native binding package version mismatch, expected 1.
|
|
229
|
+
if (bindingPackageVersion !== '1.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
230
|
+
throw new Error(`Native binding package version mismatch, expected 1.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
231
231
|
}
|
|
232
232
|
return binding
|
|
233
233
|
} catch (e) {
|
|
@@ -246,8 +246,8 @@ function requireNative() {
|
|
|
246
246
|
try {
|
|
247
247
|
const binding = require('fast-publicodes-freebsd-x64')
|
|
248
248
|
const bindingPackageVersion = require('fast-publicodes-freebsd-x64/package.json').version
|
|
249
|
-
if (bindingPackageVersion !== '1.
|
|
250
|
-
throw new Error(`Native binding package version mismatch, expected 1.
|
|
249
|
+
if (bindingPackageVersion !== '1.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
250
|
+
throw new Error(`Native binding package version mismatch, expected 1.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
251
251
|
}
|
|
252
252
|
return binding
|
|
253
253
|
} catch (e) {
|
|
@@ -262,8 +262,8 @@ function requireNative() {
|
|
|
262
262
|
try {
|
|
263
263
|
const binding = require('fast-publicodes-freebsd-arm64')
|
|
264
264
|
const bindingPackageVersion = require('fast-publicodes-freebsd-arm64/package.json').version
|
|
265
|
-
if (bindingPackageVersion !== '1.
|
|
266
|
-
throw new Error(`Native binding package version mismatch, expected 1.
|
|
265
|
+
if (bindingPackageVersion !== '1.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
266
|
+
throw new Error(`Native binding package version mismatch, expected 1.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
267
267
|
}
|
|
268
268
|
return binding
|
|
269
269
|
} catch (e) {
|
|
@@ -283,8 +283,8 @@ function requireNative() {
|
|
|
283
283
|
try {
|
|
284
284
|
const binding = require('fast-publicodes-linux-x64-musl')
|
|
285
285
|
const bindingPackageVersion = require('fast-publicodes-linux-x64-musl/package.json').version
|
|
286
|
-
if (bindingPackageVersion !== '1.
|
|
287
|
-
throw new Error(`Native binding package version mismatch, expected 1.
|
|
286
|
+
if (bindingPackageVersion !== '1.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
287
|
+
throw new Error(`Native binding package version mismatch, expected 1.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
288
288
|
}
|
|
289
289
|
return binding
|
|
290
290
|
} catch (e) {
|
|
@@ -299,8 +299,8 @@ function requireNative() {
|
|
|
299
299
|
try {
|
|
300
300
|
const binding = require('fast-publicodes-linux-x64-gnu')
|
|
301
301
|
const bindingPackageVersion = require('fast-publicodes-linux-x64-gnu/package.json').version
|
|
302
|
-
if (bindingPackageVersion !== '1.
|
|
303
|
-
throw new Error(`Native binding package version mismatch, expected 1.
|
|
302
|
+
if (bindingPackageVersion !== '1.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
303
|
+
throw new Error(`Native binding package version mismatch, expected 1.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
304
304
|
}
|
|
305
305
|
return binding
|
|
306
306
|
} catch (e) {
|
|
@@ -317,8 +317,8 @@ function requireNative() {
|
|
|
317
317
|
try {
|
|
318
318
|
const binding = require('fast-publicodes-linux-arm64-musl')
|
|
319
319
|
const bindingPackageVersion = require('fast-publicodes-linux-arm64-musl/package.json').version
|
|
320
|
-
if (bindingPackageVersion !== '1.
|
|
321
|
-
throw new Error(`Native binding package version mismatch, expected 1.
|
|
320
|
+
if (bindingPackageVersion !== '1.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
321
|
+
throw new Error(`Native binding package version mismatch, expected 1.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
322
322
|
}
|
|
323
323
|
return binding
|
|
324
324
|
} catch (e) {
|
|
@@ -333,8 +333,8 @@ function requireNative() {
|
|
|
333
333
|
try {
|
|
334
334
|
const binding = require('fast-publicodes-linux-arm64-gnu')
|
|
335
335
|
const bindingPackageVersion = require('fast-publicodes-linux-arm64-gnu/package.json').version
|
|
336
|
-
if (bindingPackageVersion !== '1.
|
|
337
|
-
throw new Error(`Native binding package version mismatch, expected 1.
|
|
336
|
+
if (bindingPackageVersion !== '1.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
337
|
+
throw new Error(`Native binding package version mismatch, expected 1.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
338
338
|
}
|
|
339
339
|
return binding
|
|
340
340
|
} catch (e) {
|
|
@@ -351,8 +351,8 @@ function requireNative() {
|
|
|
351
351
|
try {
|
|
352
352
|
const binding = require('fast-publicodes-linux-arm-musleabihf')
|
|
353
353
|
const bindingPackageVersion = require('fast-publicodes-linux-arm-musleabihf/package.json').version
|
|
354
|
-
if (bindingPackageVersion !== '1.
|
|
355
|
-
throw new Error(`Native binding package version mismatch, expected 1.
|
|
354
|
+
if (bindingPackageVersion !== '1.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
355
|
+
throw new Error(`Native binding package version mismatch, expected 1.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
356
356
|
}
|
|
357
357
|
return binding
|
|
358
358
|
} catch (e) {
|
|
@@ -367,8 +367,8 @@ function requireNative() {
|
|
|
367
367
|
try {
|
|
368
368
|
const binding = require('fast-publicodes-linux-arm-gnueabihf')
|
|
369
369
|
const bindingPackageVersion = require('fast-publicodes-linux-arm-gnueabihf/package.json').version
|
|
370
|
-
if (bindingPackageVersion !== '1.
|
|
371
|
-
throw new Error(`Native binding package version mismatch, expected 1.
|
|
370
|
+
if (bindingPackageVersion !== '1.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
371
|
+
throw new Error(`Native binding package version mismatch, expected 1.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
372
372
|
}
|
|
373
373
|
return binding
|
|
374
374
|
} catch (e) {
|
|
@@ -385,8 +385,8 @@ function requireNative() {
|
|
|
385
385
|
try {
|
|
386
386
|
const binding = require('fast-publicodes-linux-loong64-musl')
|
|
387
387
|
const bindingPackageVersion = require('fast-publicodes-linux-loong64-musl/package.json').version
|
|
388
|
-
if (bindingPackageVersion !== '1.
|
|
389
|
-
throw new Error(`Native binding package version mismatch, expected 1.
|
|
388
|
+
if (bindingPackageVersion !== '1.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
389
|
+
throw new Error(`Native binding package version mismatch, expected 1.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
390
390
|
}
|
|
391
391
|
return binding
|
|
392
392
|
} catch (e) {
|
|
@@ -401,8 +401,8 @@ function requireNative() {
|
|
|
401
401
|
try {
|
|
402
402
|
const binding = require('fast-publicodes-linux-loong64-gnu')
|
|
403
403
|
const bindingPackageVersion = require('fast-publicodes-linux-loong64-gnu/package.json').version
|
|
404
|
-
if (bindingPackageVersion !== '1.
|
|
405
|
-
throw new Error(`Native binding package version mismatch, expected 1.
|
|
404
|
+
if (bindingPackageVersion !== '1.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
405
|
+
throw new Error(`Native binding package version mismatch, expected 1.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
406
406
|
}
|
|
407
407
|
return binding
|
|
408
408
|
} catch (e) {
|
|
@@ -419,8 +419,8 @@ function requireNative() {
|
|
|
419
419
|
try {
|
|
420
420
|
const binding = require('fast-publicodes-linux-riscv64-musl')
|
|
421
421
|
const bindingPackageVersion = require('fast-publicodes-linux-riscv64-musl/package.json').version
|
|
422
|
-
if (bindingPackageVersion !== '1.
|
|
423
|
-
throw new Error(`Native binding package version mismatch, expected 1.
|
|
422
|
+
if (bindingPackageVersion !== '1.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
423
|
+
throw new Error(`Native binding package version mismatch, expected 1.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
424
424
|
}
|
|
425
425
|
return binding
|
|
426
426
|
} catch (e) {
|
|
@@ -435,8 +435,8 @@ function requireNative() {
|
|
|
435
435
|
try {
|
|
436
436
|
const binding = require('fast-publicodes-linux-riscv64-gnu')
|
|
437
437
|
const bindingPackageVersion = require('fast-publicodes-linux-riscv64-gnu/package.json').version
|
|
438
|
-
if (bindingPackageVersion !== '1.
|
|
439
|
-
throw new Error(`Native binding package version mismatch, expected 1.
|
|
438
|
+
if (bindingPackageVersion !== '1.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
439
|
+
throw new Error(`Native binding package version mismatch, expected 1.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
440
440
|
}
|
|
441
441
|
return binding
|
|
442
442
|
} catch (e) {
|
|
@@ -452,8 +452,8 @@ function requireNative() {
|
|
|
452
452
|
try {
|
|
453
453
|
const binding = require('fast-publicodes-linux-ppc64-gnu')
|
|
454
454
|
const bindingPackageVersion = require('fast-publicodes-linux-ppc64-gnu/package.json').version
|
|
455
|
-
if (bindingPackageVersion !== '1.
|
|
456
|
-
throw new Error(`Native binding package version mismatch, expected 1.
|
|
455
|
+
if (bindingPackageVersion !== '1.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
456
|
+
throw new Error(`Native binding package version mismatch, expected 1.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
457
457
|
}
|
|
458
458
|
return binding
|
|
459
459
|
} catch (e) {
|
|
@@ -468,8 +468,8 @@ function requireNative() {
|
|
|
468
468
|
try {
|
|
469
469
|
const binding = require('fast-publicodes-linux-s390x-gnu')
|
|
470
470
|
const bindingPackageVersion = require('fast-publicodes-linux-s390x-gnu/package.json').version
|
|
471
|
-
if (bindingPackageVersion !== '1.
|
|
472
|
-
throw new Error(`Native binding package version mismatch, expected 1.
|
|
471
|
+
if (bindingPackageVersion !== '1.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
472
|
+
throw new Error(`Native binding package version mismatch, expected 1.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
473
473
|
}
|
|
474
474
|
return binding
|
|
475
475
|
} catch (e) {
|
|
@@ -488,8 +488,8 @@ function requireNative() {
|
|
|
488
488
|
try {
|
|
489
489
|
const binding = require('fast-publicodes-openharmony-arm64')
|
|
490
490
|
const bindingPackageVersion = require('fast-publicodes-openharmony-arm64/package.json').version
|
|
491
|
-
if (bindingPackageVersion !== '1.
|
|
492
|
-
throw new Error(`Native binding package version mismatch, expected 1.
|
|
491
|
+
if (bindingPackageVersion !== '1.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
492
|
+
throw new Error(`Native binding package version mismatch, expected 1.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
493
493
|
}
|
|
494
494
|
return binding
|
|
495
495
|
} catch (e) {
|
|
@@ -504,8 +504,8 @@ function requireNative() {
|
|
|
504
504
|
try {
|
|
505
505
|
const binding = require('fast-publicodes-openharmony-x64')
|
|
506
506
|
const bindingPackageVersion = require('fast-publicodes-openharmony-x64/package.json').version
|
|
507
|
-
if (bindingPackageVersion !== '1.
|
|
508
|
-
throw new Error(`Native binding package version mismatch, expected 1.
|
|
507
|
+
if (bindingPackageVersion !== '1.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
508
|
+
throw new Error(`Native binding package version mismatch, expected 1.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
509
509
|
}
|
|
510
510
|
return binding
|
|
511
511
|
} catch (e) {
|
|
@@ -520,8 +520,8 @@ function requireNative() {
|
|
|
520
520
|
try {
|
|
521
521
|
const binding = require('fast-publicodes-openharmony-arm')
|
|
522
522
|
const bindingPackageVersion = require('fast-publicodes-openharmony-arm/package.json').version
|
|
523
|
-
if (bindingPackageVersion !== '1.
|
|
524
|
-
throw new Error(`Native binding package version mismatch, expected 1.
|
|
523
|
+
if (bindingPackageVersion !== '1.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
524
|
+
throw new Error(`Native binding package version mismatch, expected 1.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
525
525
|
}
|
|
526
526
|
return binding
|
|
527
527
|
} catch (e) {
|
|
@@ -661,8 +661,8 @@ if (!nativeBinding || forceWasi) {
|
|
|
661
661
|
if (!candidateFailed) {
|
|
662
662
|
if (process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
663
663
|
const bindingPackageVersion = require('fast-publicodes-wasm32-wasi/package.json').version
|
|
664
|
-
if (bindingPackageVersion !== '1.
|
|
665
|
-
throw new Error(`WASI binding package version mismatch, expected 1.
|
|
664
|
+
if (bindingPackageVersion !== '1.1.0') {
|
|
665
|
+
throw new Error(`WASI binding package version mismatch, expected 1.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
666
666
|
}
|
|
667
667
|
}
|
|
668
668
|
wasiBinding = require('fast-publicodes-wasm32-wasi')
|
package/native/index.d.cts
CHANGED
|
@@ -34,6 +34,8 @@ export declare class Engine {
|
|
|
34
34
|
* JSON when `json`.
|
|
35
35
|
*/
|
|
36
36
|
evaluate(text: string, json: boolean): object
|
|
37
|
+
/** `evaluate`, for `getRule(rule).suggestions[name]`. */
|
|
38
|
+
evaluateSuggestion(rule: string, name: string): object
|
|
37
39
|
/**
|
|
38
40
|
* A handle on the expressions evaluated since the cache was last reset, for
|
|
39
41
|
* `missingVariables`.
|
|
@@ -48,7 +50,10 @@ export declare class Engine {
|
|
|
48
50
|
shallowCopy(copyCache: boolean): Engine
|
|
49
51
|
/** The names of the public rules, in definition order. */
|
|
50
52
|
ruleNames(): Array<string>
|
|
51
|
-
/**
|
|
53
|
+
/**
|
|
54
|
+
* Returns `{ rule }`, the rule node with its inferred type and the names of its suggestions,
|
|
55
|
+
* as JSON, or `{ error }`.
|
|
56
|
+
*/
|
|
52
57
|
rule(name: string): object
|
|
53
58
|
/** Returns `{ possibilities }`, as JSON, or `{ error }`. */
|
|
54
59
|
applicablePossibilities(name: string): object
|
package/package.json
CHANGED
|
@@ -15,6 +15,10 @@ export class Engine {
|
|
|
15
15
|
* Returns `{ possibilities }`, as JSON, or `{ error }`.
|
|
16
16
|
*/
|
|
17
17
|
applicablePossibilities(name: string): object;
|
|
18
|
+
/**
|
|
19
|
+
* `evaluate`, for `getRule(rule).suggestions[name]`.
|
|
20
|
+
*/
|
|
21
|
+
evaluateSuggestion(rule: string, name: string): object;
|
|
18
22
|
/**
|
|
19
23
|
* Returns `{ nodeValue, index }`, `index` locating it in `evaluations`, with `unit` the index
|
|
20
24
|
* of its unit in the table the caller keeps, or `newUnit` when it is new and takes the next
|
|
@@ -43,7 +47,8 @@ export class Engine {
|
|
|
43
47
|
*/
|
|
44
48
|
ruleNames(): string[];
|
|
45
49
|
/**
|
|
46
|
-
* Returns `{ rule }`, the rule node
|
|
50
|
+
* Returns `{ rule }`, the rule node with its inferred type and the names of its suggestions,
|
|
51
|
+
* as JSON, or `{ error }`.
|
|
47
52
|
*/
|
|
48
53
|
rule(name: string): object;
|
|
49
54
|
/**
|
|
@@ -80,6 +85,7 @@ export interface InitOutput {
|
|
|
80
85
|
readonly __wbg_evaluationshandle_free: (a: number, b: number) => void;
|
|
81
86
|
readonly engine_applicablePossibilities: (a: number, b: number, c: number) => number;
|
|
82
87
|
readonly engine_evaluate: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
88
|
+
readonly engine_evaluateSuggestion: (a: number, b: number, c: number, d: number, e: number) => number;
|
|
83
89
|
readonly engine_evaluations: (a: number) => number;
|
|
84
90
|
readonly engine_inversionFail: (a: number) => number;
|
|
85
91
|
readonly engine_missingVariables: (a: number, b: number, c: number) => number;
|
package/wasm/fast_publicodes.js
CHANGED
|
@@ -35,6 +35,20 @@ export class Engine {
|
|
|
35
35
|
const ret = wasm.engine_applicablePossibilities(this.__wbg_ptr, ptr0, len0);
|
|
36
36
|
return takeObject(ret);
|
|
37
37
|
}
|
|
38
|
+
/**
|
|
39
|
+
* `evaluate`, for `getRule(rule).suggestions[name]`.
|
|
40
|
+
* @param {string} rule
|
|
41
|
+
* @param {string} name
|
|
42
|
+
* @returns {object}
|
|
43
|
+
*/
|
|
44
|
+
evaluateSuggestion(rule, name) {
|
|
45
|
+
const ptr0 = passStringToWasm0(rule, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
46
|
+
const len0 = WASM_VECTOR_LEN;
|
|
47
|
+
const ptr1 = passStringToWasm0(name, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
48
|
+
const len1 = WASM_VECTOR_LEN;
|
|
49
|
+
const ret = wasm.engine_evaluateSuggestion(this.__wbg_ptr, ptr0, len0, ptr1, len1);
|
|
50
|
+
return takeObject(ret);
|
|
51
|
+
}
|
|
38
52
|
/**
|
|
39
53
|
* Returns `{ nodeValue, index }`, `index` locating it in `evaluations`, with `unit` the index
|
|
40
54
|
* of its unit in the table the caller keeps, or `newUnit` when it is new and takes the next
|
|
@@ -138,7 +152,8 @@ export class Engine {
|
|
|
138
152
|
}
|
|
139
153
|
}
|
|
140
154
|
/**
|
|
141
|
-
* Returns `{ rule }`, the rule node
|
|
155
|
+
* Returns `{ rule }`, the rule node with its inferred type and the names of its suggestions,
|
|
156
|
+
* as JSON, or `{ error }`.
|
|
142
157
|
* @param {string} name
|
|
143
158
|
* @returns {object}
|
|
144
159
|
*/
|
|
Binary file
|
|
@@ -5,6 +5,7 @@ export const __wbg_engine_free: (a: number, b: number) => void;
|
|
|
5
5
|
export const __wbg_evaluationshandle_free: (a: number, b: number) => void;
|
|
6
6
|
export const engine_applicablePossibilities: (a: number, b: number, c: number) => number;
|
|
7
7
|
export const engine_evaluate: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
8
|
+
export const engine_evaluateSuggestion: (a: number, b: number, c: number, d: number, e: number) => number;
|
|
8
9
|
export const engine_evaluations: (a: number) => number;
|
|
9
10
|
export const engine_inversionFail: (a: number) => number;
|
|
10
11
|
export const engine_missingVariables: (a: number, b: number, c: number) => number;
|