poe-code 3.0.274 → 3.0.276
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/index.js +20 -4
- package/dist/index.js.map +2 -2
- package/dist/metafile.json +1 -1
- package/package.json +1 -1
- package/packages/memory/dist/index.js +19 -3
- package/packages/memory/dist/index.js.map +2 -2
- package/packages/package-lint/dist/model.js +41 -9
- package/packages/package-lint/dist/report.js +7 -1
- package/packages/package-lint/dist/rules/exports-subpath-resolvable.js +0 -0
- package/packages/package-lint/dist/rules/index.js +9 -0
- package/packages/package-lint/dist/rules/published-bin-must-be-executable.js +32 -1
- package/packages/package-lint/dist/source-imports.js +13 -10
- package/packages/tokenfill/dist/cli.js +13 -4
- package/packages/tokenfill/dist/tokenizer.js +20 -3
package/package.json
CHANGED
|
@@ -14185,12 +14185,28 @@ var DEFAULT_ENCODING = "cl100k_base";
|
|
|
14185
14185
|
function createTokenizer(options = {}) {
|
|
14186
14186
|
const encoding = options.encoding ?? DEFAULT_ENCODING;
|
|
14187
14187
|
const tokenizer = get_encoding(encoding);
|
|
14188
|
-
const utf8Decoder = new TextDecoder();
|
|
14189
14188
|
const strictUtf8Decoder = new TextDecoder("utf-8", { fatal: true });
|
|
14190
14189
|
const encode = (text4) => tokenizer.encode(text4);
|
|
14190
|
+
const normalizeDecodeTokens = (tokens) => {
|
|
14191
|
+
if (tokens instanceof Uint32Array) {
|
|
14192
|
+
return tokens;
|
|
14193
|
+
}
|
|
14194
|
+
const tokenArray = new Uint32Array(tokens.length);
|
|
14195
|
+
tokens.forEach((token, index) => {
|
|
14196
|
+
if (!Number.isFinite(token) || !Number.isInteger(token) || token < 0 || token > 4294967295) {
|
|
14197
|
+
throw new TypeError(`token id at index ${index} must be a finite non-negative integer.`);
|
|
14198
|
+
}
|
|
14199
|
+
tokenArray[index] = token;
|
|
14200
|
+
});
|
|
14201
|
+
return tokenArray;
|
|
14202
|
+
};
|
|
14191
14203
|
const decode = (tokens) => {
|
|
14192
|
-
const tokenArray =
|
|
14193
|
-
|
|
14204
|
+
const tokenArray = normalizeDecodeTokens(tokens);
|
|
14205
|
+
try {
|
|
14206
|
+
return strictUtf8Decoder.decode(tokenizer.decode(tokenArray));
|
|
14207
|
+
} catch {
|
|
14208
|
+
throw new Error("Cannot decode tokens without corrupting UTF-8 text.");
|
|
14209
|
+
}
|
|
14194
14210
|
};
|
|
14195
14211
|
const count = (text4) => encode(text4).length;
|
|
14196
14212
|
const truncate2 = (text4, tokenCount) => {
|