@ressjs/platform 0.6.0-rc.0 → 0.6.0-rc.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/index.d.ts CHANGED
@@ -11,7 +11,7 @@ export { detectPlatform } from './compat';
11
11
  export { DETECTION_LAYERS } from './detect/layers';
12
12
  export type { DetectionInput, DetectionLayer } from './detect/layers';
13
13
  export { createPlatformRegistry, defaultPlatformRegistry } from './registry/create';
14
- export { parseVariantSuffix } from './registry/parse';
14
+ export { parseVariantSuffix, PlatformTokenError } from './registry/parse';
15
15
  export { ALL_AXES, DEFAULT_AXIS_PRECEDENCE, DEFAULT_VALUES, RETIRED_TOKENS, } from './registry/defaults';
16
16
  export { DEFAULT_RULES } from './rules/user-agent';
17
17
  export { EDGE_PRESETS, readEdgeHeaders } from './rules/edge';
package/dist/index.js CHANGED
@@ -8,7 +8,7 @@
8
8
  * de nada.
9
9
  */
10
10
  Object.defineProperty(exports, "__esModule", { value: true });
11
- exports.serializePlatform = exports.platformScriptTag = exports.isWebView = exports.isTV = exports.isHandheld = exports.hasCapability = exports.DEFAULT_PLATFORM = exports.varyHeadersForAxes = exports.HEADERS_BY_AXIS = exports.PLATFORM_VARY_HEADERS = exports.PLATFORM_REQUEST_HEADERS = exports.HEADERS_V2 = exports.HEADERS_LEGACY = exports.HEADERS_CLIENT_HINTS = exports.HEADER_OVERRIDE = exports.readEdgeHeaders = exports.EDGE_PRESETS = exports.DEFAULT_RULES = exports.RETIRED_TOKENS = exports.DEFAULT_VALUES = exports.DEFAULT_AXIS_PRECEDENCE = exports.ALL_AXES = exports.parseVariantSuffix = exports.defaultPlatformRegistry = exports.createPlatformRegistry = exports.DETECTION_LAYERS = exports.detectPlatform = exports.detect = void 0;
11
+ exports.serializePlatform = exports.platformScriptTag = exports.isWebView = exports.isTV = exports.isHandheld = exports.hasCapability = exports.DEFAULT_PLATFORM = exports.varyHeadersForAxes = exports.HEADERS_BY_AXIS = exports.PLATFORM_VARY_HEADERS = exports.PLATFORM_REQUEST_HEADERS = exports.HEADERS_V2 = exports.HEADERS_LEGACY = exports.HEADERS_CLIENT_HINTS = exports.HEADER_OVERRIDE = exports.readEdgeHeaders = exports.EDGE_PRESETS = exports.DEFAULT_RULES = exports.RETIRED_TOKENS = exports.DEFAULT_VALUES = exports.DEFAULT_AXIS_PRECEDENCE = exports.ALL_AXES = exports.PlatformTokenError = exports.parseVariantSuffix = exports.defaultPlatformRegistry = exports.createPlatformRegistry = exports.DETECTION_LAYERS = exports.detectPlatform = exports.detect = void 0;
12
12
  var pipeline_1 = require("./detect/pipeline");
13
13
  Object.defineProperty(exports, "detect", { enumerable: true, get: function () { return pipeline_1.detect; } });
14
14
  var compat_1 = require("./compat");
@@ -20,6 +20,7 @@ Object.defineProperty(exports, "createPlatformRegistry", { enumerable: true, get
20
20
  Object.defineProperty(exports, "defaultPlatformRegistry", { enumerable: true, get: function () { return create_1.defaultPlatformRegistry; } });
21
21
  var parse_1 = require("./registry/parse");
22
22
  Object.defineProperty(exports, "parseVariantSuffix", { enumerable: true, get: function () { return parse_1.parseVariantSuffix; } });
23
+ Object.defineProperty(exports, "PlatformTokenError", { enumerable: true, get: function () { return parse_1.PlatformTokenError; } });
23
24
  var defaults_1 = require("./registry/defaults");
24
25
  Object.defineProperty(exports, "ALL_AXES", { enumerable: true, get: function () { return defaults_1.ALL_AXES; } });
25
26
  Object.defineProperty(exports, "DEFAULT_AXIS_PRECEDENCE", { enumerable: true, get: function () { return defaults_1.DEFAULT_AXIS_PRECEDENCE; } });
@@ -1,4 +1,32 @@
1
1
  import type { PlatformRegistry, VariantTag } from './types';
2
+ /**
3
+ * Un token de plataforma del nombre de un archivo no se pudo clasificar.
4
+ *
5
+ * Lleva los datos además del texto, para que quien lo muestre (la CLI) pueda
6
+ * darle el formato de sus demás errores sin interpretar el mensaje.
7
+ */
8
+ export declare class PlatformTokenError extends Error {
9
+ /** Estable: lo reconocen quienes no pueden importar esta clase. */
10
+ readonly code: "RESS_PLATFORM_TOKEN";
11
+ readonly kind: 'retired' | 'unknown';
12
+ readonly token: string;
13
+ readonly origin?: string;
14
+ /** Sólo `retired`: con qué se reemplaza y por qué se retiró. */
15
+ readonly replacement?: string;
16
+ readonly reason?: string;
17
+ /** Sólo `unknown`: el token válido más parecido. */
18
+ readonly suggestion?: string;
19
+ readonly valid: readonly string[];
20
+ constructor(message: string, details: {
21
+ kind: 'retired' | 'unknown';
22
+ token: string;
23
+ origin?: string;
24
+ replacement?: string;
25
+ reason?: string;
26
+ suggestion?: string;
27
+ valid: readonly string[];
28
+ });
29
+ }
2
30
  /**
3
31
  * Convierte el sufijo de un archivo de variante en tags clasificados.
4
32
  *
@@ -1,6 +1,38 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PlatformTokenError = void 0;
3
4
  exports.parseVariantSuffix = parseVariantSuffix;
5
+ /**
6
+ * Un token de plataforma del nombre de un archivo no se pudo clasificar.
7
+ *
8
+ * Lleva los datos además del texto, para que quien lo muestre (la CLI) pueda
9
+ * darle el formato de sus demás errores sin interpretar el mensaje.
10
+ */
11
+ class PlatformTokenError extends Error {
12
+ /** Estable: lo reconocen quienes no pueden importar esta clase. */
13
+ code = 'RESS_PLATFORM_TOKEN';
14
+ kind;
15
+ token;
16
+ origin;
17
+ /** Sólo `retired`: con qué se reemplaza y por qué se retiró. */
18
+ replacement;
19
+ reason;
20
+ /** Sólo `unknown`: el token válido más parecido. */
21
+ suggestion;
22
+ valid;
23
+ constructor(message, details) {
24
+ super(message);
25
+ this.name = 'PlatformTokenError';
26
+ this.kind = details.kind;
27
+ this.token = details.token;
28
+ this.origin = details.origin;
29
+ this.replacement = details.replacement;
30
+ this.reason = details.reason;
31
+ this.suggestion = details.suggestion;
32
+ this.valid = details.valid;
33
+ }
34
+ }
35
+ exports.PlatformTokenError = PlatformTokenError;
4
36
  /**
5
37
  * Convierte el sufijo de un archivo de variante en tags clasificados.
6
38
  *
@@ -40,17 +72,17 @@ function parseVariantSuffix(suffix, registry, origin) {
40
72
  * desconocido con la lista de válidos y la sugerencia más cercana.
41
73
  */
42
74
  function unknownToken(token, registry, origin) {
75
+ const valid = allTokens(registry);
43
76
  const retired = registry.retired(token);
44
77
  if (retired) {
45
- return new Error(`[ress] El token de plataforma "${token}"${where(origin)} ya no existe. ` +
78
+ return new PlatformTokenError(`[ress] El token de plataforma "${token}"${where(origin)} ya no existe. ` +
46
79
  `Usá ${retired.replacement}.\n` +
47
- `Se retiró porque ${retired.reason}.`);
80
+ `Se retiró porque ${retired.reason}.`, { kind: 'retired', token, origin, replacement: retired.replacement, reason: retired.reason, valid });
48
81
  }
49
- const valid = allTokens(registry);
50
82
  const suggestion = closest(token, valid);
51
- return new Error(`[ress] Token de plataforma desconocido: "${token}"${where(origin)}.` +
83
+ return new PlatformTokenError(`[ress] Token de plataforma desconocido: "${token}"${where(origin)}.` +
52
84
  (suggestion ? ` ¿Quisiste decir "${suggestion}"?` : '') +
53
- `\nTokens válidos: ${valid.join(', ')}.`);
85
+ `\nTokens válidos: ${valid.join(', ')}.`, { kind: 'unknown', token, origin, suggestion, valid });
54
86
  }
55
87
  const where = (origin) => (origin ? ` en "${origin}"` : '');
56
88
  function allTokens(registry) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ressjs/platform",
3
- "version": "0.6.0-rc.0",
3
+ "version": "0.6.0-rc.1",
4
4
  "description": "Modelo de plataforma de ress.js: registro de tokens y detección del cliente. Sin dependencias.",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",