@warp-drive/utilities 5.6.0-alpha.11 → 5.6.0-alpha.12
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/declarations/-private/derivations.d.ts +23 -0
- package/declarations/-private/derivations.d.ts.map +1 -0
- package/declarations/-private/handlers/auto-compress.d.ts.map +1 -1
- package/declarations/-private/handlers/gated.d.ts +15 -0
- package/declarations/-private/handlers/gated.d.ts.map +1 -0
- package/declarations/-private/handlers/utils.d.ts +33 -0
- package/declarations/-private/handlers/utils.d.ts.map +1 -0
- package/declarations/string.d.ts +1 -1
- package/dist/active-record.js +2 -2
- package/dist/handlers.js +20 -12
- package/dist/handlers.js.map +1 -1
- package/dist/{inflect-C1laviCe.js → inflect-Dr20y6b1.js} +1 -1
- package/dist/{inflect-C1laviCe.js.map → inflect-Dr20y6b1.js.map} +1 -1
- package/dist/json-api.js +2 -2
- package/dist/rest.js +2 -2
- package/dist/string.cjs +463 -0
- package/dist/string.cjs.map +1 -0
- package/dist/string.js +1 -1
- package/package.json +9 -5
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { ReactiveResource } from '@warp-drive/core/reactive';
|
|
2
|
+
/**
|
|
3
|
+
* A derivation for use by {@link ReactiveResource} that joins the given fields
|
|
4
|
+
* with the optional separator (or '' if no separator is provided).
|
|
5
|
+
*
|
|
6
|
+
* Generally you should not need to import and use this function directly.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* {
|
|
10
|
+
* name: 'fullName',
|
|
11
|
+
* kind: 'derived',
|
|
12
|
+
* type: 'concat',
|
|
13
|
+
* options: {
|
|
14
|
+
* fields: ['firstName', 'lastName'],
|
|
15
|
+
* separator: ' ',
|
|
16
|
+
* },
|
|
17
|
+
* }
|
|
18
|
+
*/
|
|
19
|
+
export declare function concat(record: ReactiveResource & {
|
|
20
|
+
[key: string]: unknown;
|
|
21
|
+
}, options: Record<string, unknown> | null, _prop: string): string;
|
|
22
|
+
export declare namespace concat { }
|
|
23
|
+
//# sourceMappingURL=derivations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"derivations.d.ts","sourceRoot":"","sources":["../../src/-private/derivations.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAGlE;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,MAAM,CACpB,MAAM,EAAE,gBAAgB,GAAG;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;CAAE,EACrD,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,EACvC,KAAK,EAAE,MAAM,GACZ,MAAM,CAQR;yBAZe,MAAM"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auto-compress.d.ts","sourceRoot":"","sources":["../../../src/-private/handlers/auto-compress.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"auto-compress.d.ts","sourceRoot":"","sources":["../../../src/-private/handlers/auto-compress.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AACxE,OAAO,KAAK,EAAc,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAMjF,eAAO,MAAM,sBAAsB,SAc/B,CAAC;AAEL,UAAU,WAAW;IACnB;;;;OAIG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;;OAIG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;;OAIG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;;OAIG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;;OAIG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;;GAGG;AACH,UAAU,kBAAkB;IAC1B;;;;;;OAMG;IACH,MAAM,CAAC,EAAE,iBAAiB,CAAC;IAE3B;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;IAEzB;;;;;;OAMG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;IAEzB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA8BG;IACH,WAAW,CAAC,EAAE,WAAW,CAAC;CAC3B;AAWD;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,qBAAa,YAAa,YAAW,OAAO;IAClC,OAAO,EAAE,QAAQ,CAAC,kBAAkB,CAAC,GAAG;QAAE,WAAW,EAAE,QAAQ,CAAC,WAAW,CAAC,CAAA;KAAE,CAAC;gBAE3E,OAAO,GAAE,kBAAuB;IAU5C,OAAO,CAAC,CAAC,EAAE,EAAE,OAAO,EAAE,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC;CA4DjF"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Future, Handler, NextFn } from '@warp-drive/core/request';
|
|
2
|
+
import type { RequestContext, StructuredDataDocument } from '@warp-drive/core/types/request';
|
|
3
|
+
/**
|
|
4
|
+
* If CheckFn returns true, the wrapped handler will be used.
|
|
5
|
+
* If CheckFn returns false, the wrapped handler will be skipped.
|
|
6
|
+
*/
|
|
7
|
+
type CheckFn = (context: RequestContext) => boolean;
|
|
8
|
+
export declare class Gate implements Handler {
|
|
9
|
+
handler: Handler;
|
|
10
|
+
checkFn: CheckFn;
|
|
11
|
+
constructor(handler: Handler, checkFn: CheckFn);
|
|
12
|
+
request<T = unknown>(context: RequestContext, next: NextFn<T>): Promise<T | StructuredDataDocument<T>> | Future<T>;
|
|
13
|
+
}
|
|
14
|
+
export {};
|
|
15
|
+
//# sourceMappingURL=gated.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gated.d.ts","sourceRoot":"","sources":["../../../src/-private/handlers/gated.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AACxE,OAAO,KAAK,EAAE,cAAc,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AAE7F;;;GAGG;AACH,KAAK,OAAO,GAAG,CAAC,OAAO,EAAE,cAAc,KAAK,OAAO,CAAC;AAEpD,qBAAa,IAAK,YAAW,OAAO;IAC1B,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,OAAO,CAAC;gBAEb,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO;IAK9C,OAAO,CAAC,CAAC,GAAG,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,GAAG,sBAAsB,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC;CAMnH"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A unique identifier for the current browser tab
|
|
3
|
+
* useful for observability/tracing and deduping
|
|
4
|
+
* across multiple tabs.
|
|
5
|
+
*/
|
|
6
|
+
export declare const TAB_ID: string;
|
|
7
|
+
/**
|
|
8
|
+
* The epoch seconds at which the tab id was generated
|
|
9
|
+
*/
|
|
10
|
+
export declare const TAB_ASSIGNED: number;
|
|
11
|
+
/**
|
|
12
|
+
* Adds the `X-Amzn-Trace-Id` header to support observability
|
|
13
|
+
* tooling around request routing.
|
|
14
|
+
*
|
|
15
|
+
* This makes use of the {@link TAB_ID} and {@link TAB_ASSIGNED}
|
|
16
|
+
* to enable tracking the browser tab of origin across multiple requests.
|
|
17
|
+
*
|
|
18
|
+
* Follows the template: `Root=1-${now}-${uuidv4};TabId=1-${epochSeconds}-${tab-uuid}`
|
|
19
|
+
*/
|
|
20
|
+
export declare function addTraceHeader(headers: Headers): Headers;
|
|
21
|
+
/**
|
|
22
|
+
* Source: https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/cloudfront-limits.html
|
|
23
|
+
* As of 2024-12-05 the maximum URL length is 8192 bytes.
|
|
24
|
+
*
|
|
25
|
+
*/
|
|
26
|
+
export declare const MAX_URL_LENGTH = 8192;
|
|
27
|
+
/**
|
|
28
|
+
* This assertion takes a URL and throws an error if the URL is longer than the maximum URL length.
|
|
29
|
+
*
|
|
30
|
+
* See also {@link MAX_URL_LENGTH}
|
|
31
|
+
*/
|
|
32
|
+
export declare function assertInvalidUrlLength(url: string | undefined): void;
|
|
33
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/-private/handlers/utils.ts"],"names":[],"mappings":"AA4BA;;;;GAIG;AACH,eAAO,MAAM,MAAM,QAAa,CAAC;AACjC;;GAEG;AACH,eAAO,MAAM,YAAY,QAAgC,CAAC;AAE1D;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,OAAO,WAK9C;AAED;;;;GAIG;AACH,eAAO,MAAM,cAAc,OAAO,CAAC;AAEnC;;;;GAIG;AACH,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,QAK7D"}
|
package/declarations/string.d.ts
CHANGED
package/dist/active-record.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { buildBaseURL, buildQueryParams } from
|
|
2
|
-
import { p as pluralize, j as underscore } from "./inflect-
|
|
1
|
+
import { buildBaseURL, buildQueryParams } from './index.js';
|
|
2
|
+
import { p as pluralize, j as underscore } from "./inflect-Dr20y6b1.js";
|
|
3
3
|
import { e as extractCacheOptions, c as copyForwardUrlOptions } from "./builder-utils-Donkk-BZ.js";
|
|
4
4
|
import { recordIdentifierFor } from '@warp-drive/core';
|
|
5
5
|
import { macroCondition, getGlobalConfig } from '@embroider/macros';
|
package/dist/handlers.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { macroCondition, getGlobalConfig } from '@embroider/macros';
|
|
1
2
|
function isCompressibleMethod(method) {
|
|
2
3
|
return method === 'POST' || method === 'PUT' || method === 'PATCH' || method === 'DELETE';
|
|
3
4
|
}
|
|
@@ -97,7 +98,8 @@ class AutoCompress {
|
|
|
97
98
|
const allowStreaming = request.options?.allowStreaming ?? this.options.allowStreaming;
|
|
98
99
|
if (forceStreaming || SupportsRequestStreams && allowStreaming) {
|
|
99
100
|
const req = Object.assign({}, request, {
|
|
100
|
-
body: stream
|
|
101
|
+
body: stream,
|
|
102
|
+
headers
|
|
101
103
|
});
|
|
102
104
|
if (SupportsRequestStreams) {
|
|
103
105
|
// @ts-expect-error untyped
|
|
@@ -109,17 +111,17 @@ class AutoCompress {
|
|
|
109
111
|
// For non-chromium browsers, we have to "pull" the stream to get the final
|
|
110
112
|
// bytes and supply the final byte array as the new request body.
|
|
111
113
|
//
|
|
112
|
-
} else {
|
|
113
|
-
// we need to pull the stream to get the final bytes
|
|
114
|
-
const resp = new Response(stream);
|
|
115
|
-
return resp.blob().then(blob => {
|
|
116
|
-
const req = Object.assign({}, request, {
|
|
117
|
-
body: blob,
|
|
118
|
-
headers
|
|
119
|
-
});
|
|
120
|
-
return next(req);
|
|
121
|
-
});
|
|
122
114
|
}
|
|
115
|
+
|
|
116
|
+
// we need to pull the stream to get the final bytes
|
|
117
|
+
const resp = new Response(stream);
|
|
118
|
+
return resp.blob().then(blob => {
|
|
119
|
+
const req = Object.assign({}, request, {
|
|
120
|
+
body: blob,
|
|
121
|
+
headers
|
|
122
|
+
});
|
|
123
|
+
return next(req);
|
|
124
|
+
});
|
|
123
125
|
}
|
|
124
126
|
}
|
|
125
127
|
function canCompress(type, constraints, size) {
|
|
@@ -135,7 +137,13 @@ function encodingForFormat(format) {
|
|
|
135
137
|
case 'deflate-raw':
|
|
136
138
|
return format;
|
|
137
139
|
default:
|
|
138
|
-
|
|
140
|
+
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
141
|
+
{
|
|
142
|
+
throw new Error(`Unsupported compression format: ${format}`);
|
|
143
|
+
}
|
|
144
|
+
})() : {};
|
|
145
|
+
// @ts-expect-error - unreachable code is reachable in production
|
|
146
|
+
return format;
|
|
139
147
|
}
|
|
140
148
|
}
|
|
141
149
|
export { AutoCompress, SupportsRequestStreams };
|
package/dist/handlers.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handlers.js","sources":["../src/-private/handlers/auto-compress.ts"],"sourcesContent":["import type { Future, Handler, NextFn } from '@warp-drive/core/request';\nimport type { HTTPMethod, RequestContext } from '@warp-drive/core/types/request';\n\nfunction isCompressibleMethod(method?: HTTPMethod): boolean {\n return method === 'POST' || method === 'PUT' || method === 'PATCH' || method === 'DELETE';\n}\n\nexport const SupportsRequestStreams = (() => {\n let duplexAccessed = false;\n\n const hasContentType = new Request('', {\n body: new ReadableStream(),\n method: 'POST',\n // @ts-expect-error untyped\n get duplex() {\n duplexAccessed = true;\n return 'half';\n },\n }).headers.has('Content-Type');\n\n return duplexAccessed && !hasContentType;\n})();\n\ninterface Constraints {\n /**\n * The minimum size at which to compress blobs\n *\n * @default 1000\n */\n Blob?: number;\n /**\n * The minimum size at which to compress array buffers\n *\n * @default 1000\n */\n ArrayBuffer?: number;\n /**\n * The minimum size at which to compress typed arrays\n *\n * @default 1000\n */\n TypedArray?: number;\n /**\n * The minimum size at which to compress data views\n *\n * @default 1000\n */\n DataView?: number;\n /**\n * The minimum size at which to compress strings\n *\n * @default 1000\n */\n String?: number;\n}\n\n/**\n * Options for configuring the AutoCompress handler.\n *\n */\ninterface CompressionOptions {\n /**\n * The compression format to use. Must be a valid\n * compression format supported by [CompressionStream](https://developer.mozilla.org/en-US/docs/Web/API/CompressionStream)\n *\n * The default is `gzip`.\n *\n */\n format?: CompressionFormat;\n\n /**\n * Some browsers support `ReadableStream` as a request body. This option\n * enables passing the compression stream as the request body instead of\n * the final compressed body when the browser supports doing so.\n *\n * This comes with several caveats:\n *\n * - the request will be put into `duplex: 'half'` mode. This should be\n * transparent to you, but it is worth noting.\n * - the request mode cannot be `no-cors` as requests with a `ReadableStream`\n * have no content length and thus are a new form of request that triggers\n * cors requirements and a preflight request.\n * - http/1.x is not supported.\n *\n * For additional reading about the restrictions of using `ReadableStream`\n * as a request body, see the [Chromium Documentation](https://developer.chrome.com/docs/capabilities/web-apis/fetch-streaming-requests#restrictions)\n *\n * Streaming can be enabled per-request in browsers which support it by\n * setting `request.options.allowStreaming` to `true`.\n *\n * Streaming can be forced even when the browser does not support it by setting\n * `request.options.forceStreaming` to `true`. This is useful if later handlers\n * in the chain can handle the request body as a stream.\n *\n * @default false\n */\n allowStreaming?: boolean;\n\n /**\n * If `true`, the request will be forced into streaming mode even\n * if the browser does not support it. This is useful if later handlers\n * in the chain can handle the request body as a stream.\n *\n * @default false\n */\n forceStreaming?: boolean;\n\n /**\n * The constraints for the request body. This is used to determine\n * whether to compress the request body or not.\n *\n * The defaults are:\n *\n * ```ts\n * {\n * Blob: 1000, // blob.size\n * ArrayBuffer: 1000, // buffer.byteLength\n * TypedArray: 1000, // array.byteLength\n * DataView: 1000, // view.byteLength\n * String: 1000, // string.length\n * }\n * ```\n *\n * The following body types are never compressed unless explicitly\n * configured by the request:\n * - `FormData`\n * - `URLSearchParams`\n * - `ReadableStream`\n *\n * A request.options.compress value of `false` will disable\n * compression for a request body of any type. While a value of\n * `true` will enable compression for the request.\n *\n * An undefined value will use the default, a value of `0` will\n * enable compression for all values, and a value of `-1` will\n * disable compression.\n *\n */\n constraints?: Constraints;\n}\n\nconst DEFAULT_CONSTRAINTS = {\n Blob: 1000,\n ArrayBuffer: 1000,\n TypedArray: 1000,\n DataView: 1000,\n String: 1000,\n};\nconst TypedArray = Object.getPrototypeOf(Uint8Array.prototype) as typeof Uint8Array;\n\n/**\n * A request handler that automatically compresses the request body\n * if the request body is a string, array buffer, blob, or form data.\n *\n * This uses the [CompressionStream API](https://developer.mozilla.org/en-US/docs/Web/API/CompressionStream)\n *\n * The compression format as well as the kinds of data to compress can be\n * configured using the `format` and `constraints` options.\n *\n * ```diff\n * +import { AutoCompress } from '@ember-data/request-utils/handlers';\n * import Fetch from '@ember-data/request/fetch';\n * import RequestManager from '@ember-data/request';\n * import Store from '@ember-data/store';\n *\n * class AppStore extends Store {\n * requestManager = new RequestManager()\n * .use([\n * + new AutoCompress(),\n * Fetch\n * ]);\n * }\n * ```\n *\n * @class AutoCompress\n * @public\n * @since 5.5.0\n */\nexport class AutoCompress implements Handler {\n declare options: Required<CompressionOptions> & { constraints: Required<Constraints> };\n\n constructor(options: CompressionOptions = {}) {\n const opts = {\n format: options.format ?? 'gzip',\n constraints: Object.assign({}, DEFAULT_CONSTRAINTS, options.constraints),\n allowStreaming: options.allowStreaming ?? false,\n forceStreaming: options.forceStreaming ?? false,\n };\n this.options = opts;\n }\n\n request<T>({ request }: RequestContext, next: NextFn<T>): Promise<T> | Future<T> {\n const { constraints } = this.options;\n const { body } = request;\n\n const shouldCompress =\n isCompressibleMethod(request.method) &&\n request.options?.compress !== false &&\n // prettier-ignore\n (request.options?.compress ? true\n : typeof body === 'string' || body instanceof String ? canCompress('String', constraints, body.length)\n : body instanceof Blob ? canCompress('Blob', constraints, body.size)\n : body instanceof ArrayBuffer ? canCompress('ArrayBuffer', constraints, body.byteLength)\n : body instanceof DataView ? canCompress('DataView', constraints, body.byteLength)\n : body instanceof TypedArray ? canCompress('TypedArray', constraints, body.byteLength)\n : false);\n\n if (!shouldCompress) return next(request);\n\n // A convenient way to convert all of the supported body types to a readable\n // stream is to use a `Response` object body\n const response = new Response(request.body);\n const stream = response.body?.pipeThrough(new CompressionStream(this.options.format));\n const headers = new Headers(request.headers);\n headers.set('Content-Encoding', encodingForFormat(this.options.format));\n\n //\n // For browsers that support it, `fetch` can receive a `ReadableStream` as\n // the body, so all we need to do is to create a new `ReadableStream` and\n // compress it on the fly\n //\n const forceStreaming = request.options?.forceStreaming ?? this.options.forceStreaming;\n const allowStreaming = request.options?.allowStreaming ?? this.options.allowStreaming;\n if (forceStreaming || (SupportsRequestStreams && allowStreaming)) {\n const req = Object.assign({}, request, {\n body: stream,\n });\n if (SupportsRequestStreams) {\n // @ts-expect-error untyped\n req.duplex = 'half';\n }\n\n return next(req);\n\n //\n // For non-chromium browsers, we have to \"pull\" the stream to get the final\n // bytes and supply the final byte array as the new request body.\n //\n } else {\n // we need to pull the stream to get the final bytes\n const resp = new Response(stream);\n return resp.blob().then((blob) => {\n const req = Object.assign({}, request, {\n body: blob,\n headers,\n });\n return next(req);\n }) as Promise<T>;\n }\n }\n}\n\nfunction canCompress(type: keyof Constraints, constraints: Required<Constraints>, size: number): boolean {\n // if we have a value of 0, we can compress anything\n if (constraints[type] === 0) return true;\n if (constraints[type] === -1) return false;\n return size >= constraints[type];\n}\n\nfunction encodingForFormat(format: CompressionFormat): string {\n switch (format) {\n case 'gzip':\n case 'deflate':\n case 'deflate-raw':\n return format;\n default:\n throw new Error(`Unsupported compression format: ${format as unknown as string}`);\n }\n}\n"],"names":["isCompressibleMethod","method","SupportsRequestStreams","duplexAccessed","hasContentType","Request","body","ReadableStream","duplex","headers","has","DEFAULT_CONSTRAINTS","Blob","ArrayBuffer","TypedArray","DataView","String","Object","getPrototypeOf","Uint8Array","prototype","AutoCompress","constructor","options","opts","format","constraints","assign","allowStreaming","forceStreaming","request","next","shouldCompress","compress","canCompress","length","size","byteLength","response","Response","stream","pipeThrough","CompressionStream","Headers","set","encodingForFormat","req","resp","blob","then","type","Error"],"mappings":"AAGA,SAASA,oBAAoBA,CAACC,MAAmB,EAAW;AAC1D,EAAA,OAAOA,MAAM,KAAK,MAAM,IAAIA,MAAM,KAAK,KAAK,IAAIA,MAAM,KAAK,OAAO,IAAIA,MAAM,KAAK,QAAQ;AAC3F;AAEaC,MAAAA,sBAAsB,GAAG,CAAC,MAAM;EAC3C,IAAIC,cAAc,GAAG,KAAK;AAE1B,EAAA,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AAW,CAACwB,IAAI,CAAC,KAAK,EAAE,EAAE,OAAO,KAAK;AAC1C,EAAA,OAAOd,IAAI,IAAIV,WAAW,CAACwB,IAAI,CAAC;AAClC;AAEA,SAASL,iBAAiBA,CAACpB,MAAyB,EAAU;AAC5D,EAAA,QAAQA,MAAM;AACZ,IAAA,KAAK,MAAM;AACX,IAAA,KAAK,SAAS;AACd,IAAA,KAAK,aAAa;AAChB,MAAA,OAAOA,MAAM;AACf,IAAA;AACE,MAAA,MAAM,IAAI0B,KAAK,CAAC,CAAmC1B,gCAAAA,EAAAA,MAAM,EAAuB,CAAC;AACrF;AACF;;;;"}
|
|
1
|
+
{"version":3,"file":"handlers.js","sources":["../src/-private/handlers/auto-compress.ts"],"sourcesContent":["import { assert } from '@warp-drive/core/build-config/macros';\nimport type { Future, Handler, NextFn } from '@warp-drive/core/request';\nimport type { HTTPMethod, RequestContext } from '@warp-drive/core/types/request';\n\nfunction isCompressibleMethod(method?: HTTPMethod): boolean {\n return method === 'POST' || method === 'PUT' || method === 'PATCH' || method === 'DELETE';\n}\n\nexport const SupportsRequestStreams = (() => {\n let duplexAccessed = false;\n\n const hasContentType = new Request('', {\n body: new ReadableStream(),\n method: 'POST',\n // @ts-expect-error untyped\n get duplex() {\n duplexAccessed = true;\n return 'half';\n },\n }).headers.has('Content-Type');\n\n return duplexAccessed && !hasContentType;\n})();\n\ninterface Constraints {\n /**\n * The minimum size at which to compress blobs\n *\n * @default 1000\n */\n Blob?: number;\n /**\n * The minimum size at which to compress array buffers\n *\n * @default 1000\n */\n ArrayBuffer?: number;\n /**\n * The minimum size at which to compress typed arrays\n *\n * @default 1000\n */\n TypedArray?: number;\n /**\n * The minimum size at which to compress data views\n *\n * @default 1000\n */\n DataView?: number;\n /**\n * The minimum size at which to compress strings\n *\n * @default 1000\n */\n String?: number;\n}\n\n/**\n * Options for configuring the AutoCompress handler.\n *\n */\ninterface CompressionOptions {\n /**\n * The compression format to use. Must be a valid\n * compression format supported by [CompressionStream](https://developer.mozilla.org/en-US/docs/Web/API/CompressionStream)\n *\n * The default is `gzip`.\n *\n */\n format?: CompressionFormat;\n\n /**\n * Some browsers support `ReadableStream` as a request body. This option\n * enables passing the compression stream as the request body instead of\n * the final compressed body when the browser supports doing so.\n *\n * This comes with several caveats:\n *\n * - the request will be put into `duplex: 'half'` mode. This should be\n * transparent to you, but it is worth noting.\n * - the request mode cannot be `no-cors` as requests with a `ReadableStream`\n * have no content length and thus are a new form of request that triggers\n * cors requirements and a preflight request.\n * - http/1.x is not supported.\n *\n * For additional reading about the restrictions of using `ReadableStream`\n * as a request body, see the [Chromium Documentation](https://developer.chrome.com/docs/capabilities/web-apis/fetch-streaming-requests#restrictions)\n *\n * Streaming can be enabled per-request in browsers which support it by\n * setting `request.options.allowStreaming` to `true`.\n *\n * Streaming can be forced even when the browser does not support it by setting\n * `request.options.forceStreaming` to `true`. This is useful if later handlers\n * in the chain can handle the request body as a stream.\n *\n * @default false\n */\n allowStreaming?: boolean;\n\n /**\n * If `true`, the request will be forced into streaming mode even\n * if the browser does not support it. This is useful if later handlers\n * in the chain can handle the request body as a stream.\n *\n * @default false\n */\n forceStreaming?: boolean;\n\n /**\n * The constraints for the request body. This is used to determine\n * whether to compress the request body or not.\n *\n * The defaults are:\n *\n * ```ts\n * {\n * Blob: 1000, // blob.size\n * ArrayBuffer: 1000, // buffer.byteLength\n * TypedArray: 1000, // array.byteLength\n * DataView: 1000, // view.byteLength\n * String: 1000, // string.length\n * }\n * ```\n *\n * The following body types are never compressed unless explicitly\n * configured by the request:\n * - `FormData`\n * - `URLSearchParams`\n * - `ReadableStream`\n *\n * A request.options.compress value of `false` will disable\n * compression for a request body of any type. While a value of\n * `true` will enable compression for the request.\n *\n * An undefined value will use the default, a value of `0` will\n * enable compression for all values, and a value of `-1` will\n * disable compression.\n *\n */\n constraints?: Constraints;\n}\n\nconst DEFAULT_CONSTRAINTS = {\n Blob: 1000,\n ArrayBuffer: 1000,\n TypedArray: 1000,\n DataView: 1000,\n String: 1000,\n};\nconst TypedArray = Object.getPrototypeOf(Uint8Array.prototype) as typeof Uint8Array;\n\n/**\n * A request handler that automatically compresses the request body\n * if the request body is a string, array buffer, blob, or form data.\n *\n * This uses the [CompressionStream API](https://developer.mozilla.org/en-US/docs/Web/API/CompressionStream)\n *\n * The compression format as well as the kinds of data to compress can be\n * configured using the `format` and `constraints` options.\n *\n * ```diff\n * +import { AutoCompress } from '@ember-data/request-utils/handlers';\n * import Fetch from '@ember-data/request/fetch';\n * import RequestManager from '@ember-data/request';\n * import Store from '@ember-data/store';\n *\n * class AppStore extends Store {\n * requestManager = new RequestManager()\n * .use([\n * + new AutoCompress(),\n * Fetch\n * ]);\n * }\n * ```\n *\n * @class AutoCompress\n * @public\n * @since 5.5.0\n */\nexport class AutoCompress implements Handler {\n declare options: Required<CompressionOptions> & { constraints: Required<Constraints> };\n\n constructor(options: CompressionOptions = {}) {\n const opts = {\n format: options.format ?? 'gzip',\n constraints: Object.assign({}, DEFAULT_CONSTRAINTS, options.constraints),\n allowStreaming: options.allowStreaming ?? false,\n forceStreaming: options.forceStreaming ?? false,\n };\n this.options = opts;\n }\n\n request<T>({ request }: RequestContext, next: NextFn<T>): Promise<T> | Future<T> {\n const { constraints } = this.options;\n const { body } = request;\n\n const shouldCompress =\n isCompressibleMethod(request.method) &&\n request.options?.compress !== false &&\n // prettier-ignore\n (request.options?.compress ? true\n : typeof body === 'string' || body instanceof String ? canCompress('String', constraints, body.length)\n : body instanceof Blob ? canCompress('Blob', constraints, body.size)\n : body instanceof ArrayBuffer ? canCompress('ArrayBuffer', constraints, body.byteLength)\n : body instanceof DataView ? canCompress('DataView', constraints, body.byteLength)\n : body instanceof TypedArray ? canCompress('TypedArray', constraints, body.byteLength)\n : false);\n\n if (!shouldCompress) return next(request);\n\n // A convenient way to convert all of the supported body types to a readable\n // stream is to use a `Response` object body\n const response = new Response(request.body);\n const stream = response.body?.pipeThrough(new CompressionStream(this.options.format));\n const headers = new Headers(request.headers);\n headers.set('Content-Encoding', encodingForFormat(this.options.format));\n\n //\n // For browsers that support it, `fetch` can receive a `ReadableStream` as\n // the body, so all we need to do is to create a new `ReadableStream` and\n // compress it on the fly\n //\n const forceStreaming = request.options?.forceStreaming ?? this.options.forceStreaming;\n const allowStreaming = request.options?.allowStreaming ?? this.options.allowStreaming;\n if (forceStreaming || (SupportsRequestStreams && allowStreaming)) {\n const req = Object.assign({}, request, {\n body: stream,\n headers,\n });\n if (SupportsRequestStreams) {\n // @ts-expect-error untyped\n req.duplex = 'half';\n }\n\n return next(req);\n\n //\n // For non-chromium browsers, we have to \"pull\" the stream to get the final\n // bytes and supply the final byte array as the new request body.\n //\n }\n\n // we need to pull the stream to get the final bytes\n const resp = new Response(stream);\n return resp.blob().then((blob) => {\n const req = Object.assign({}, request, {\n body: blob,\n headers,\n });\n return next(req);\n }) as Promise<T>;\n }\n}\n\nfunction canCompress(type: keyof Constraints, constraints: Required<Constraints>, size: number): boolean {\n // if we have a value of 0, we can compress anything\n if (constraints[type] === 0) return true;\n if (constraints[type] === -1) return false;\n return size >= constraints[type];\n}\n\nfunction encodingForFormat(format: CompressionFormat): string {\n switch (format) {\n case 'gzip':\n case 'deflate':\n case 'deflate-raw':\n return format;\n default:\n assert(`Unsupported compression format: ${format as unknown as string}`);\n // @ts-expect-error - unreachable code is reachable in production\n return format;\n }\n}\n"],"names":["isCompressibleMethod","method","SupportsRequestStreams","duplexAccessed","hasContentType","Request","body","ReadableStream","duplex","headers","has","DEFAULT_CONSTRAINTS","Blob","ArrayBuffer","TypedArray","DataView","String","Object","getPrototypeOf","Uint8Array","prototype","AutoCompress","constructor","options","opts","format","constraints","assign","allowStreaming","forceStreaming","request","next","shouldCompress","compress","canCompress","length","size","byteLength","response","Response","stream","pipeThrough","CompressionStream","Headers","set","encodingForFormat","req","resp","blob","then","type","macroCondition","getGlobalConfig","WarpDrive","env","DEBUG","test","Error"],"mappings":";;AAIA,SAASA,oBAAoBA,CAACC,MAAmB,EAAW;AAC1D,E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AI,CAACe,GAAG,CAAC;AAClB,KAAC,CAAC;AACJ;AACF;AAEA,SAASZ,WAAWA,CAACgB,IAAuB,EAAExB,WAAkC,EAAEU,IAAY,EAAW;AACvG;EACA,IAAIV,WAAW,CAACwB,IAAI,CAAC,KAAK,CAAC,EAAE,OAAO,IAAI;EACxC,IAAIxB,WAAW,CAACwB,IAAI,CAAC,KAAK,EAAE,EAAE,OAAO,KAAK;AAC1C,EAAA,OAAOd,IAAI,IAAIV,WAAW,CAACwB,IAAI,CAAC;AAClC;AAEA,SAASL,iBAAiBA,CAACpB,MAAyB,EAAU;AAC5D,EAAA,QAAQA,MAAM;AACZ,IAAA,KAAK,MAAM;AACX,IAAA,KAAK,SAAS;AACd,IAAA,KAAK,aAAa;AAChB,MAAA,OAAOA,MAAM;AACf,IAAA;MACE0B,cAAA,CAAAC,eAAA,EAAAC,CAAAA,SAAA,CAAAC,GAAA,CAAAC,KAAA,CAAA,GAAA,CAAAC,IAAA,IAAA;AAAA,QAAA;AAAA,UAAA,MAAA,IAAAC,KAAA,CAAO,CAAmChC,gCAAAA,EAAAA,MAAM,CAAuB,CAAA,CAAA;AAAA;AAAA,OAAA,EAAA,CAAA,GAAA,EAAA;AACvE;AACA,MAAA,OAAOA,MAAM;AACjB;AACF;;;;"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { LRUCache, dasherize as dasherize$1, STRING_DASHERIZE_CACHE } from '@warp-drive/core/utils/string';
|
|
2
|
-
import { InflectionRuleDefaults as defaultRules } from
|
|
2
|
+
import { InflectionRuleDefaults as defaultRules } from './-private.js';
|
|
3
3
|
import { macroCondition, getGlobalConfig } from '@embroider/macros';
|
|
4
4
|
|
|
5
5
|
// eslint-disable-next-line no-useless-escape
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inflect-C1laviCe.js","sources":["../src/-private/string/transform.ts","../src/-private/string/inflect.ts"],"sourcesContent":["import { dasherize as internalDasherize, LRUCache, STRING_DASHERIZE_CACHE } from '@warp-drive/core/utils/string';\n\n// eslint-disable-next-line no-useless-escape\nconst STRING_CAMELIZE_REGEXP_1 = /(\\-|\\_|\\.|\\s)+(.)?/g;\nconst STRING_CAMELIZE_REGEXP_2 = /(^|\\/)([A-Z])/g;\nconst CAMELIZE_CACHE = new LRUCache<string, string>((key: string) =>\n key\n .replace(STRING_CAMELIZE_REGEXP_1, (_match, _separator, chr: string | null) => (chr ? chr.toUpperCase() : ''))\n .replace(STRING_CAMELIZE_REGEXP_2, (match /*, separator, chr */) => match.toLowerCase())\n);\n\nconst STRING_UNDERSCORE_REGEXP_1 = /([a-z\\d])([A-Z]+)/g;\n// eslint-disable-next-line no-useless-escape\nconst STRING_UNDERSCORE_REGEXP_2 = /\\-|\\s+/g;\nconst UNDERSCORE_CACHE = new LRUCache<string, string>((str: string) =>\n str.replace(STRING_UNDERSCORE_REGEXP_1, '$1_$2').replace(STRING_UNDERSCORE_REGEXP_2, '_').toLowerCase()\n);\n\nconst STRING_CAPITALIZE_REGEXP = /(^|\\/)([a-z\\u00C0-\\u024F])/g;\nconst CAPITALIZE_CACHE = new LRUCache<string, string>((str: string) =>\n str.replace(STRING_CAPITALIZE_REGEXP, (match /*, separator, chr */) => match.toUpperCase())\n);\n\n/**\n * Replaces underscores, spaces, or camelCase with dashes.\n *\n * ```js\n * import { dasherize } from '@warp-drive/utilities/string';\n *\n * dasherize('innerHTML'); // 'inner-html'\n * dasherize('action_name'); // 'action-name'\n * dasherize('css-class-name'); // 'css-class-name'\n * dasherize('my favorite items'); // 'my-favorite-items'\n * dasherize('privateDocs/ownerInvoice'; // 'private-docs/owner-invoice'\n * ```\n *\n * @public\n * @param {String} str\n * @return {String}\n * @since 4.13.0\n */\nexport const dasherize = internalDasherize;\n\n/**\n * Returns the lowerCamelCase form of a string.\n *\n * ```js\n * import { camelize } from '@warp-drive/utilities/string';\n *\n * camelize('innerHTML'); // 'innerHTML'\n * camelize('action_name'); // 'actionName'\n * camelize('css-class-name'); // 'cssClassName'\n * camelize('my favorite items'); // 'myFavoriteItems'\n * camelize('My Favorite Items'); // 'myFavoriteItems'\n * camelize('private-docs/owner-invoice'); // 'privateDocs/ownerInvoice'\n * ```\n *\n * @public\n * @param {String} str\n * @return {String}\n * @since 4.13.0\n */\nexport function camelize(str: string): string {\n return CAMELIZE_CACHE.get(str);\n}\n\n/**\n * Returns the lower\\_case\\_and\\_underscored form of a string.\n *\n * ```js\n * import { underscore } from '@warp-drive/utilities/string';\n *\n * underscore('innerHTML'); // 'inner_html'\n * underscore('action_name'); // 'action_name'\n * underscore('css-class-name'); // 'css_class_name'\n * underscore('my favorite items'); // 'my_favorite_items'\n * underscore('privateDocs/ownerInvoice'); // 'private_docs/owner_invoice'\n * ```\n *\n * @public\n * @param {String} str\n * @return {String}\n * @since 4.13.0\n */\nexport function underscore(str: string): string {\n return UNDERSCORE_CACHE.get(str);\n}\n\n/**\n * Returns the Capitalized form of a string\n *\n * ```js\n * import { capitalize } from '@warp-drive/utilities/string';\n *\n * capitalize('innerHTML') // 'InnerHTML'\n * capitalize('action_name') // 'Action_name'\n * capitalize('css-class-name') // 'Css-class-name'\n * capitalize('my favorite items') // 'My favorite items'\n * capitalize('privateDocs/ownerInvoice'); // 'PrivateDocs/ownerInvoice'\n * ```\n *\n * @public\n * @param {String} str\n * @return {String}\n * @since 4.13.0\n */\nexport function capitalize(str: string): string {\n return CAPITALIZE_CACHE.get(str);\n}\n\n/**\n * Sets the maximum size of the LRUCache for all string transformation functions.\n * The default size is 10,000.\n *\n * @public\n * @param {Number} size\n * @return {void}\n * @since 4.13.0\n */\nexport function setMaxLRUCacheSize(size: number) {\n CAMELIZE_CACHE.size = size;\n UNDERSCORE_CACHE.size = size;\n CAPITALIZE_CACHE.size = size;\n STRING_DASHERIZE_CACHE.size = size;\n}\n","import { assert } from '@warp-drive/core/build-config/macros';\nimport { LRUCache } from '@warp-drive/core/utils/string';\n\nimport { defaultRules } from './inflections.ts';\nimport { capitalize } from './transform.ts';\n\nconst BLANK_REGEX = /^\\s*$/;\nconst LAST_WORD_DASHED_REGEX = /([\\w/-]+[_/\\s-])([a-z\\d]+$)/;\nconst LAST_WORD_CAMELIZED_REGEX = /([\\w/\\s-]+)([A-Z][a-z\\d]*$)/;\nconst CAMELIZED_REGEX = /[A-Z][a-z\\d]*$/;\n\nconst SINGULARS = new LRUCache<string, string>((word: string) => {\n return _singularize(word);\n});\nconst PLURALS = new LRUCache<string, string>((word: string) => {\n return _pluralize(word);\n});\nconst UNCOUNTABLE = new Set(defaultRules.uncountable);\nconst IRREGULAR: Map<string, string> = new Map();\nconst INVERSE_IRREGULAR: Map<string, string> = new Map();\nconst SINGULAR_RULES = new Map(defaultRules.singular.reverse());\nconst PLURAL_RULES = new Map(defaultRules.plurals.reverse());\n\n/**\n * Marks a word as uncountable. Uncountable words are not pluralized\n * or singularized.\n *\n * @public\n * @param {String} word\n * @return {void}\n * @since 4.13.0\n */\nexport function uncountable(word: string) {\n UNCOUNTABLE.add(word.toLowerCase());\n}\n\n/**\n * Marks a list of words as uncountable. Uncountable words are not pluralized\n * or singularized.\n *\n * @public\n * @param {Array<String>} uncountables\n * @return {void}\n * @since 4.13.0\n */\nexport function loadUncountable(uncountables: string[]) {\n uncountables.forEach((word) => {\n uncountable(word);\n });\n}\n\n/**\n * Marks a word as irregular. Irregular words have unique\n * pluralization and singularization rules.\n *\n * @public\n * @param {String} single\n * @param {String} plur\n * @return {void}\n * @since 4.13.0\n */\nexport function irregular(single: string, plur: string) {\n //pluralizing\n IRREGULAR.set(single.toLowerCase(), plur);\n IRREGULAR.set(plur.toLowerCase(), plur);\n\n //singularizing\n INVERSE_IRREGULAR.set(plur.toLowerCase(), single);\n INVERSE_IRREGULAR.set(single.toLowerCase(), single);\n}\n\n/**\n * Marks a list of word pairs as irregular. Irregular words have unique\n * pluralization and singularization rules.\n *\n * @public\n * @param {Array<Array<String>>} irregularPairs\n * @return {void}\n * @since 4.13.0\n */\nexport function loadIrregular(irregularPairs: Array<[string, string]>) {\n irregularPairs.forEach((pair) => {\n //pluralizing\n IRREGULAR.set(pair[0].toLowerCase(), pair[1]);\n IRREGULAR.set(pair[1].toLowerCase(), pair[1]);\n\n //singularizing\n INVERSE_IRREGULAR.set(pair[1].toLowerCase(), pair[0]);\n INVERSE_IRREGULAR.set(pair[0].toLowerCase(), pair[0]);\n });\n}\nloadIrregular(defaultRules.irregularPairs);\n\n/**\n * Clears the caches for singularize and pluralize.\n *\n * @public\n * @return {void}\n * @since 4.13.0\n */\nexport function clear() {\n SINGULARS.clear();\n PLURALS.clear();\n}\n\n/**\n * Resets the inflection rules to the defaults.\n *\n * @public\n * @return {void}\n * @since 4.13.0\n */\nexport function resetToDefaults() {\n clearRules();\n defaultRules.uncountable.forEach((v) => UNCOUNTABLE.add(v));\n defaultRules.singular.forEach((v) => SINGULAR_RULES.set(v[0], v[1]));\n defaultRules.plurals.forEach((v) => PLURAL_RULES.set(v[0], v[1]));\n loadIrregular(defaultRules.irregularPairs);\n}\n\n/**\n * Clears all inflection rules\n * and resets the caches for singularize and pluralize.\n *\n * @public\n * @return {void}\n * @since 4.13.0\n */\nexport function clearRules() {\n SINGULARS.clear();\n PLURALS.clear();\n UNCOUNTABLE.clear();\n IRREGULAR.clear();\n INVERSE_IRREGULAR.clear();\n SINGULAR_RULES.clear();\n PLURAL_RULES.clear();\n}\n\n/**\n * Singularizes a word.\n *\n * @public\n * @param {String} word\n * @return {String}\n * @since 4.13.0\n */\nexport function singularize(word: string) {\n assert(`singularize expects to receive a non-empty string`, typeof word === 'string' && word.length > 0);\n if (!word) return '';\n return SINGULARS.get(word);\n}\n\n/**\n * Pluralizes a word.\n *\n * @public\n * @param {String} word\n * @return {String}\n * @since 4.13.0\n */\nexport function pluralize(word: string) {\n assert(`pluralize expects to receive a non-empty string`, typeof word === 'string' && word.length > 0);\n if (!word) return '';\n return PLURALS.get(word);\n}\n\nfunction unshiftMap<K, V>(v: [K, V], map: Map<K, V>) {\n // reorder\n const rules = [v, ...map.entries()];\n map.clear();\n rules.forEach((rule) => {\n map.set(rule[0], rule[1]);\n });\n}\n\n/**\n * Adds a pluralization rule.\n *\n * @public\n * @param {RegExp} regex\n * @param {String} string\n * @return {void}\n * @since 4.13.0\n */\nexport function plural(regex: RegExp, string: string) {\n // rule requires reordering if exists, so remove it first\n if (PLURAL_RULES.has(regex)) {\n PLURAL_RULES.delete(regex);\n }\n\n // reorder\n unshiftMap([regex, string], PLURAL_RULES);\n}\n\n/**\n * Adds a singularization rule.\n *\n * @public\n * @param {RegExp} regex\n * @param {String} string\n * @return {void}\n * @since 4.13.0\n */\nexport function singular(regex: RegExp, string: string) {\n // rule requires reordering if exists, so remove it first\n if (SINGULAR_RULES.has(regex)) {\n SINGULAR_RULES.delete(regex);\n }\n\n // reorder\n unshiftMap([regex, string], SINGULAR_RULES);\n}\n\nfunction _pluralize(word: string) {\n return inflect(word, PLURAL_RULES, IRREGULAR);\n}\n\nfunction _singularize(word: string) {\n return inflect(word, SINGULAR_RULES, INVERSE_IRREGULAR);\n}\n\nfunction inflect(word: string, typeRules: Map<RegExp, string>, irregulars: Map<string, string>) {\n // empty strings\n const isBlank = !word || BLANK_REGEX.test(word);\n if (isBlank) {\n return word;\n }\n\n // basic uncountables\n const lowercase = word.toLowerCase();\n if (UNCOUNTABLE.has(lowercase)) {\n return word;\n }\n\n // adv uncountables\n const wordSplit = LAST_WORD_DASHED_REGEX.exec(word) || LAST_WORD_CAMELIZED_REGEX.exec(word);\n const lastWord = wordSplit ? wordSplit[2].toLowerCase() : null;\n if (lastWord && UNCOUNTABLE.has(lastWord)) {\n return word;\n }\n\n // handle irregulars\n const isCamelized = CAMELIZED_REGEX.test(word);\n for (let [rule, substitution] of irregulars) {\n if (lowercase.match(rule + '$')) {\n if (isCamelized && lastWord && irregulars.has(lastWord)) {\n substitution = capitalize(substitution);\n rule = capitalize(rule);\n }\n\n return word.replace(new RegExp(rule, 'i'), substitution);\n }\n }\n\n // do the actual inflection\n for (const [rule, substitution] of typeRules) {\n if (rule.test(word)) {\n return word.replace(rule, substitution);\n }\n }\n\n return word;\n}\n"],"names":["STRING_CAMELIZE_REGEXP_1","STRING_CAMELIZE_REGEXP_2","CAMELIZE_CACHE","LRUCache","key","replace","_match","_separator","chr","toUpperCase","match","toLowerCase","STRING_UNDERSCORE_REGEXP_1","STRING_UNDERSCORE_REGEXP_2","UNDERSCORE_CACHE","str","STRING_CAPITALIZE_REGEXP","CAPITALIZE_CACHE","dasherize","internalDasherize","camelize","get","underscore","capitalize","setMaxLRUCacheSize","size","STRING_DASHERIZE_CACHE","BLANK_REGEX","LAST_WORD_DASHED_REGEX","LAST_WORD_CAMELIZED_REGEX","CAMELIZED_REGEX","SINGULARS","word","_singularize","PLURALS","_pluralize","UNCOUNTABLE","Set","defaultRules","uncountable","IRREGULAR","Map","INVERSE_IRREGULAR","SINGULAR_RULES","singular","reverse","PLURAL_RULES","plurals","add","loadUncountable","uncountables","forEach","irregular","single","plur","set","loadIrregular","irregularPairs","pair","clear","resetToDefaults","clearRules","v","singularize","macroCondition","getGlobalConfig","WarpDrive","env","DEBUG","test","Error","length","pluralize","unshiftMap","map","rules","entries","rule","plural","regex","string","has","delete","inflect","typeRules","irregulars","isBlank","lowercase","wordSplit","exec","lastWord","isCamelized","substitution","RegExp"],"mappings":";;;;AAEA;AACA,MAAMA,wBAAwB,GAAG,qBAAqB;AACtD,MAAMC,wBAAwB,GAAG,gBAAgB;AACjD,MAAMC,cAAc,GAAG,IAAIC,QAAQ,CAAkBC,GAAW,IAC9DA,GAAG,CACAC,OAAO,CAACL,wBAAwB,EAAE,CAACM,MAAM,EAAEC,UAAU,EAAEC,GAAkB,KAAMA,GAAG,GAAGA,GAAG,CAACC,WAAW,EAAE,GAAG,EAAG,CAAC,CAC7GJ,OAAO,CAACJ,wBAAwB,EAAE,CAACS,KAAK,2BAA2BA,KAAK,CAACC,WAAW,EAAE,CAC3F,CAAC;AAED,MAAMC,0BAA0B,GAAG,oBAAoB;AACvD;AACA,MAAMC,0BAA0B,GAAG,SAAS;AAC5C,MAAMC,gBAAgB,GAAG,IAAIX,QAAQ,CAAkBY,GAAW,IAChEA,GAAG,CAACV,OAAO,CAACO,0BAA0B,EAAE,OAAO,CAAC,CAACP,OAAO,CAACQ,0BAA0B,EAAE,GAAG,CAAC,CAACF,WAAW,EACvG,CAAC;AAED,MAAMK,wBAAwB,GAAG,6BAA6B;AAC9D,MAAMC,gBAAgB,GAAG,IAAId,QAAQ,CAAkBY,GAAW,IAChEA,GAAG,CAACV,OAAO,CAACW,wBAAwB,EAAE,CAACN,KAAK,2BAA2BA,KAAK,CAACD,WAAW,EAAE,CAC5F,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMS,SAAS,GAAGC;;AAEzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,QAAQA,CAACL,GAAW,EAAU;AAC5C,EAAA,OAAOb,cAAc,CAACmB,GAAG,CAACN,GAAG,CAAC;AAChC;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASO,UAAUA,CAACP,GAAW,EAAU;AAC9C,EAAA,OAAOD,gBAAgB,CAACO,GAAG,CAACN,GAAG,CAAC;AAClC;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASQ,UAAUA,CAACR,GAAW,EAAU;AAC9C,EAAA,OAAOE,gBAAgB,CAACI,GAAG,CAACN,GAAG,CAAC;AAClC;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASS,kBAAkBA,CAACC,IAAY,EAAE;EAC/CvB,cAAc,CAACuB,IAAI,GAAGA,IAAI;EAC1BX,gBAAgB,CAACW,I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Q,IAAItD,WAAW,CAAC6C,GAAG,CAACS,QAAQ,CAAC,EAAE;AACzC,IAAA,OAAO1D,IAAI;AACb;;AAEA;AACA,EAAA,MAAM2D,WAAW,GAAG7D,eAAe,CAACuC,IAAI,CAACrC,IAAI,CAAC;EAC9C,KAAK,IAAI,CAAC6C,IAAI,EAAEe,YAAY,CAAC,IAAIP,UAAU,EAAE;IAC3C,IAAIE,SAAS,CAAC7E,KAAK,CAACmE,IAAI,GAAG,GAAG,CAAC,EAAE;MAC/B,IAAIc,WAAW,IAAID,QAAQ,IAAIL,UAAU,CAACJ,GAAG,CAACS,QAAQ,CAAC,EAAE;AACvDE,QAAAA,YAAY,GAAGrE,UAAU,CAACqE,YAAY,CAAC;AACvCf,QAAAA,IAAI,GAAGtD,UAAU,CAACsD,IAAI,CAAC;AACzB;AAEA,MAAA,OAAO7C,IAAI,CAAC3B,OAAO,CAAC,IAAIwF,MAAM,CAAChB,IAAI,EAAE,GAAG,CAAC,EAAEe,YAAY,CAAC;AAC1D;AACF;;AAEA;EACA,KAAK,MAAM,CAACf,IAAI,EAAEe,YAAY,CAAC,IAAIR,SAAS,EAAE;AAC5C,IAAA,IAAIP,IAAI,CAACR,IAAI,CAACrC,IAAI,CAAC,EAAE;AACnB,MAAA,OAAOA,IAAI,CAAC3B,OAAO,CAACwE,IAAI,EAAEe,YAAY,CAAC;AACzC;AACF;AAEA,EAAA,OAAO5D,IAAI;AACb;;;;"}
|
|
1
|
+
{"version":3,"file":"inflect-Dr20y6b1.js","sources":["../src/-private/string/transform.ts","../src/-private/string/inflect.ts"],"sourcesContent":["import { dasherize as internalDasherize, LRUCache, STRING_DASHERIZE_CACHE } from '@warp-drive/core/utils/string';\n\n// eslint-disable-next-line no-useless-escape\nconst STRING_CAMELIZE_REGEXP_1 = /(\\-|\\_|\\.|\\s)+(.)?/g;\nconst STRING_CAMELIZE_REGEXP_2 = /(^|\\/)([A-Z])/g;\nconst CAMELIZE_CACHE = new LRUCache<string, string>((key: string) =>\n key\n .replace(STRING_CAMELIZE_REGEXP_1, (_match, _separator, chr: string | null) => (chr ? chr.toUpperCase() : ''))\n .replace(STRING_CAMELIZE_REGEXP_2, (match /*, separator, chr */) => match.toLowerCase())\n);\n\nconst STRING_UNDERSCORE_REGEXP_1 = /([a-z\\d])([A-Z]+)/g;\n// eslint-disable-next-line no-useless-escape\nconst STRING_UNDERSCORE_REGEXP_2 = /\\-|\\s+/g;\nconst UNDERSCORE_CACHE = new LRUCache<string, string>((str: string) =>\n str.replace(STRING_UNDERSCORE_REGEXP_1, '$1_$2').replace(STRING_UNDERSCORE_REGEXP_2, '_').toLowerCase()\n);\n\nconst STRING_CAPITALIZE_REGEXP = /(^|\\/)([a-z\\u00C0-\\u024F])/g;\nconst CAPITALIZE_CACHE = new LRUCache<string, string>((str: string) =>\n str.replace(STRING_CAPITALIZE_REGEXP, (match /*, separator, chr */) => match.toUpperCase())\n);\n\n/**\n * Replaces underscores, spaces, or camelCase with dashes.\n *\n * ```js\n * import { dasherize } from '@warp-drive/utilities/string';\n *\n * dasherize('innerHTML'); // 'inner-html'\n * dasherize('action_name'); // 'action-name'\n * dasherize('css-class-name'); // 'css-class-name'\n * dasherize('my favorite items'); // 'my-favorite-items'\n * dasherize('privateDocs/ownerInvoice'; // 'private-docs/owner-invoice'\n * ```\n *\n * @public\n * @param {String} str\n * @return {String}\n * @since 4.13.0\n */\nexport const dasherize = internalDasherize;\n\n/**\n * Returns the lowerCamelCase form of a string.\n *\n * ```js\n * import { camelize } from '@warp-drive/utilities/string';\n *\n * camelize('innerHTML'); // 'innerHTML'\n * camelize('action_name'); // 'actionName'\n * camelize('css-class-name'); // 'cssClassName'\n * camelize('my favorite items'); // 'myFavoriteItems'\n * camelize('My Favorite Items'); // 'myFavoriteItems'\n * camelize('private-docs/owner-invoice'); // 'privateDocs/ownerInvoice'\n * ```\n *\n * @public\n * @param {String} str\n * @return {String}\n * @since 4.13.0\n */\nexport function camelize(str: string): string {\n return CAMELIZE_CACHE.get(str);\n}\n\n/**\n * Returns the lower\\_case\\_and\\_underscored form of a string.\n *\n * ```js\n * import { underscore } from '@warp-drive/utilities/string';\n *\n * underscore('innerHTML'); // 'inner_html'\n * underscore('action_name'); // 'action_name'\n * underscore('css-class-name'); // 'css_class_name'\n * underscore('my favorite items'); // 'my_favorite_items'\n * underscore('privateDocs/ownerInvoice'); // 'private_docs/owner_invoice'\n * ```\n *\n * @public\n * @param {String} str\n * @return {String}\n * @since 4.13.0\n */\nexport function underscore(str: string): string {\n return UNDERSCORE_CACHE.get(str);\n}\n\n/**\n * Returns the Capitalized form of a string\n *\n * ```js\n * import { capitalize } from '@warp-drive/utilities/string';\n *\n * capitalize('innerHTML') // 'InnerHTML'\n * capitalize('action_name') // 'Action_name'\n * capitalize('css-class-name') // 'Css-class-name'\n * capitalize('my favorite items') // 'My favorite items'\n * capitalize('privateDocs/ownerInvoice'); // 'PrivateDocs/ownerInvoice'\n * ```\n *\n * @public\n * @param {String} str\n * @return {String}\n * @since 4.13.0\n */\nexport function capitalize(str: string): string {\n return CAPITALIZE_CACHE.get(str);\n}\n\n/**\n * Sets the maximum size of the LRUCache for all string transformation functions.\n * The default size is 10,000.\n *\n * @public\n * @param {Number} size\n * @return {void}\n * @since 4.13.0\n */\nexport function setMaxLRUCacheSize(size: number) {\n CAMELIZE_CACHE.size = size;\n UNDERSCORE_CACHE.size = size;\n CAPITALIZE_CACHE.size = size;\n STRING_DASHERIZE_CACHE.size = size;\n}\n","import { assert } from '@warp-drive/core/build-config/macros';\nimport { LRUCache } from '@warp-drive/core/utils/string';\n\nimport { defaultRules } from './inflections.ts';\nimport { capitalize } from './transform.ts';\n\nconst BLANK_REGEX = /^\\s*$/;\nconst LAST_WORD_DASHED_REGEX = /([\\w/-]+[_/\\s-])([a-z\\d]+$)/;\nconst LAST_WORD_CAMELIZED_REGEX = /([\\w/\\s-]+)([A-Z][a-z\\d]*$)/;\nconst CAMELIZED_REGEX = /[A-Z][a-z\\d]*$/;\n\nconst SINGULARS = new LRUCache<string, string>((word: string) => {\n return _singularize(word);\n});\nconst PLURALS = new LRUCache<string, string>((word: string) => {\n return _pluralize(word);\n});\nconst UNCOUNTABLE = new Set(defaultRules.uncountable);\nconst IRREGULAR: Map<string, string> = new Map();\nconst INVERSE_IRREGULAR: Map<string, string> = new Map();\nconst SINGULAR_RULES = new Map(defaultRules.singular.reverse());\nconst PLURAL_RULES = new Map(defaultRules.plurals.reverse());\n\n/**\n * Marks a word as uncountable. Uncountable words are not pluralized\n * or singularized.\n *\n * @public\n * @param {String} word\n * @return {void}\n * @since 4.13.0\n */\nexport function uncountable(word: string) {\n UNCOUNTABLE.add(word.toLowerCase());\n}\n\n/**\n * Marks a list of words as uncountable. Uncountable words are not pluralized\n * or singularized.\n *\n * @public\n * @param {Array<String>} uncountables\n * @return {void}\n * @since 4.13.0\n */\nexport function loadUncountable(uncountables: string[]) {\n uncountables.forEach((word) => {\n uncountable(word);\n });\n}\n\n/**\n * Marks a word as irregular. Irregular words have unique\n * pluralization and singularization rules.\n *\n * @public\n * @param {String} single\n * @param {String} plur\n * @return {void}\n * @since 4.13.0\n */\nexport function irregular(single: string, plur: string) {\n //pluralizing\n IRREGULAR.set(single.toLowerCase(), plur);\n IRREGULAR.set(plur.toLowerCase(), plur);\n\n //singularizing\n INVERSE_IRREGULAR.set(plur.toLowerCase(), single);\n INVERSE_IRREGULAR.set(single.toLowerCase(), single);\n}\n\n/**\n * Marks a list of word pairs as irregular. Irregular words have unique\n * pluralization and singularization rules.\n *\n * @public\n * @param {Array<Array<String>>} irregularPairs\n * @return {void}\n * @since 4.13.0\n */\nexport function loadIrregular(irregularPairs: Array<[string, string]>) {\n irregularPairs.forEach((pair) => {\n //pluralizing\n IRREGULAR.set(pair[0].toLowerCase(), pair[1]);\n IRREGULAR.set(pair[1].toLowerCase(), pair[1]);\n\n //singularizing\n INVERSE_IRREGULAR.set(pair[1].toLowerCase(), pair[0]);\n INVERSE_IRREGULAR.set(pair[0].toLowerCase(), pair[0]);\n });\n}\nloadIrregular(defaultRules.irregularPairs);\n\n/**\n * Clears the caches for singularize and pluralize.\n *\n * @public\n * @return {void}\n * @since 4.13.0\n */\nexport function clear() {\n SINGULARS.clear();\n PLURALS.clear();\n}\n\n/**\n * Resets the inflection rules to the defaults.\n *\n * @public\n * @return {void}\n * @since 4.13.0\n */\nexport function resetToDefaults() {\n clearRules();\n defaultRules.uncountable.forEach((v) => UNCOUNTABLE.add(v));\n defaultRules.singular.forEach((v) => SINGULAR_RULES.set(v[0], v[1]));\n defaultRules.plurals.forEach((v) => PLURAL_RULES.set(v[0], v[1]));\n loadIrregular(defaultRules.irregularPairs);\n}\n\n/**\n * Clears all inflection rules\n * and resets the caches for singularize and pluralize.\n *\n * @public\n * @return {void}\n * @since 4.13.0\n */\nexport function clearRules() {\n SINGULARS.clear();\n PLURALS.clear();\n UNCOUNTABLE.clear();\n IRREGULAR.clear();\n INVERSE_IRREGULAR.clear();\n SINGULAR_RULES.clear();\n PLURAL_RULES.clear();\n}\n\n/**\n * Singularizes a word.\n *\n * @public\n * @param {String} word\n * @return {String}\n * @since 4.13.0\n */\nexport function singularize(word: string) {\n assert(`singularize expects to receive a non-empty string`, typeof word === 'string' && word.length > 0);\n if (!word) return '';\n return SINGULARS.get(word);\n}\n\n/**\n * Pluralizes a word.\n *\n * @public\n * @param {String} word\n * @return {String}\n * @since 4.13.0\n */\nexport function pluralize(word: string) {\n assert(`pluralize expects to receive a non-empty string`, typeof word === 'string' && word.length > 0);\n if (!word) return '';\n return PLURALS.get(word);\n}\n\nfunction unshiftMap<K, V>(v: [K, V], map: Map<K, V>) {\n // reorder\n const rules = [v, ...map.entries()];\n map.clear();\n rules.forEach((rule) => {\n map.set(rule[0], rule[1]);\n });\n}\n\n/**\n * Adds a pluralization rule.\n *\n * @public\n * @param {RegExp} regex\n * @param {String} string\n * @return {void}\n * @since 4.13.0\n */\nexport function plural(regex: RegExp, string: string) {\n // rule requires reordering if exists, so remove it first\n if (PLURAL_RULES.has(regex)) {\n PLURAL_RULES.delete(regex);\n }\n\n // reorder\n unshiftMap([regex, string], PLURAL_RULES);\n}\n\n/**\n * Adds a singularization rule.\n *\n * @public\n * @param {RegExp} regex\n * @param {String} string\n * @return {void}\n * @since 4.13.0\n */\nexport function singular(regex: RegExp, string: string) {\n // rule requires reordering if exists, so remove it first\n if (SINGULAR_RULES.has(regex)) {\n SINGULAR_RULES.delete(regex);\n }\n\n // reorder\n unshiftMap([regex, string], SINGULAR_RULES);\n}\n\nfunction _pluralize(word: string) {\n return inflect(word, PLURAL_RULES, IRREGULAR);\n}\n\nfunction _singularize(word: string) {\n return inflect(word, SINGULAR_RULES, INVERSE_IRREGULAR);\n}\n\nfunction inflect(word: string, typeRules: Map<RegExp, string>, irregulars: Map<string, string>) {\n // empty strings\n const isBlank = !word || BLANK_REGEX.test(word);\n if (isBlank) {\n return word;\n }\n\n // basic uncountables\n const lowercase = word.toLowerCase();\n if (UNCOUNTABLE.has(lowercase)) {\n return word;\n }\n\n // adv uncountables\n const wordSplit = LAST_WORD_DASHED_REGEX.exec(word) || LAST_WORD_CAMELIZED_REGEX.exec(word);\n const lastWord = wordSplit ? wordSplit[2].toLowerCase() : null;\n if (lastWord && UNCOUNTABLE.has(lastWord)) {\n return word;\n }\n\n // handle irregulars\n const isCamelized = CAMELIZED_REGEX.test(word);\n for (let [rule, substitution] of irregulars) {\n if (lowercase.match(rule + '$')) {\n if (isCamelized && lastWord && irregulars.has(lastWord)) {\n substitution = capitalize(substitution);\n rule = capitalize(rule);\n }\n\n return word.replace(new RegExp(rule, 'i'), substitution);\n }\n }\n\n // do the actual inflection\n for (const [rule, substitution] of typeRules) {\n if (rule.test(word)) {\n return word.replace(rule, substitution);\n }\n }\n\n return word;\n}\n"],"names":["STRING_CAMELIZE_REGEXP_1","STRING_CAMELIZE_REGEXP_2","CAMELIZE_CACHE","LRUCache","key","replace","_match","_separator","chr","toUpperCase","match","toLowerCase","STRING_UNDERSCORE_REGEXP_1","STRING_UNDERSCORE_REGEXP_2","UNDERSCORE_CACHE","str","STRING_CAPITALIZE_REGEXP","CAPITALIZE_CACHE","dasherize","internalDasherize","camelize","get","underscore","capitalize","setMaxLRUCacheSize","size","STRING_DASHERIZE_CACHE","BLANK_REGEX","LAST_WORD_DASHED_REGEX","LAST_WORD_CAMELIZED_REGEX","CAMELIZED_REGEX","SINGULARS","word","_singularize","PLURALS","_pluralize","UNCOUNTABLE","Set","defaultRules","uncountable","IRREGULAR","Map","INVERSE_IRREGULAR","SINGULAR_RULES","singular","reverse","PLURAL_RULES","plurals","add","loadUncountable","uncountables","forEach","irregular","single","plur","set","loadIrregular","irregularPairs","pair","clear","resetToDefaults","clearRules","v","singularize","macroCondition","getGlobalConfig","WarpDrive","env","DEBUG","test","Error","length","pluralize","unshiftMap","map","rules","entries","rule","plural","regex","string","has","delete","inflect","typeRules","irregulars","isBlank","lowercase","wordSplit","exec","lastWord","isCamelized","substitution","RegExp"],"mappings":";;;;AAEA;AACA,MAAMA,wBAAwB,GAAG,qBAAqB;AACtD,MAAMC,wBAAwB,GAAG,gBAAgB;AACjD,MAAMC,cAAc,GAAG,IAAIC,QAAQ,CAAkBC,GAAW,IAC9DA,GAAG,CACAC,OAAO,CAACL,wBAAwB,EAAE,CAACM,MAAM,EAAEC,UAAU,EAAEC,GAAkB,KAAMA,GAAG,GAAGA,GAAG,CAACC,WAAW,EAAE,GAAG,EAAG,CAAC,CAC7GJ,OAAO,CAACJ,wBAAwB,EAAE,CAACS,KAAK,2BAA2BA,KAAK,CAACC,WAAW,EAAE,CAC3F,CAAC;AAED,MAAMC,0BAA0B,GAAG,oBAAoB;AACvD;AACA,MAAMC,0BAA0B,GAAG,SAAS;AAC5C,MAAMC,gBAAgB,GAAG,IAAIX,QAAQ,CAAkBY,GAAW,IAChEA,GAAG,CAACV,OAAO,CAACO,0BAA0B,EAAE,OAAO,CAAC,CAACP,OAAO,CAACQ,0BAA0B,EAAE,GAAG,CAAC,CAACF,WAAW,EACvG,CAAC;AAED,MAAMK,wBAAwB,GAAG,6BAA6B;AAC9D,MAAMC,gBAAgB,GAAG,IAAId,QAAQ,CAAkBY,GAAW,IAChEA,GAAG,CAACV,OAAO,CAACW,wBAAwB,EAAE,CAACN,KAAK,2BAA2BA,KAAK,CAACD,WAAW,EAAE,CAC5F,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMS,SAAS,GAAGC;;AAEzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,QAAQA,CAACL,GAAW,EAAU;AAC5C,EAAA,OAAOb,cAAc,CAACmB,GAAG,CAACN,GAAG,CAAC;AAChC;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASO,UAAUA,CAACP,GAAW,EAAU;AAC9C,EAAA,OAAOD,gBAAgB,CAACO,GAAG,CAACN,GAAG,CAAC;AAClC;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASQ,UAAUA,CAACR,GAAW,EAAU;AAC9C,EAAA,OAAOE,gBAAgB,CAACI,GAAG,CAACN,GAAG,CAAC;AAClC;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASS,kBAAkBA,CAACC,IAAY,EAAE;EAC/CvB,cAAc,CAACuB,IAAI,GAAGA,IAAI;EAC1BX,gBAAgB,CAACW,IAAI,GAAGA,IAAI;EAC5BR,gBAAgB,CAACQ,IAAI,GAAGA,IAAI;EAC5BC,sBAAsB,CAACD,IAAI,GAAGA,IAAI;AACpC;;ACtHA,MAAME,WAAW,GAAG,OAAO;AAC3B,MAAMC,sBAAsB,GAAG,6BAA6B;AAC5D,MAAMC,yBAAy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,EAAEe,YAAY,CAAC,IAAIP,UAAU,EAAE;IAC3C,IAAIE,SAAS,CAAC7E,KAAK,CAACmE,IAAI,GAAG,GAAG,CAAC,EAAE;MAC/B,IAAIc,WAAW,IAAID,QAAQ,IAAIL,UAAU,CAACJ,GAAG,CAACS,QAAQ,CAAC,EAAE;AACvDE,QAAAA,YAAY,GAAGrE,UAAU,CAACqE,YAAY,CAAC;AACvCf,QAAAA,IAAI,GAAGtD,UAAU,CAACsD,IAAI,CAAC;AACzB;AAEA,MAAA,OAAO7C,IAAI,CAAC3B,OAAO,CAAC,IAAIwF,MAAM,CAAChB,IAAI,EAAE,GAAG,CAAC,EAAEe,YAAY,CAAC;AAC1D;AACF;;AAEA;EACA,KAAK,MAAM,CAACf,IAAI,EAAEe,YAAY,CAAC,IAAIR,SAAS,EAAE;AAC5C,IAAA,IAAIP,IAAI,CAACR,IAAI,CAACrC,IAAI,CAAC,EAAE;AACnB,MAAA,OAAOA,IAAI,CAAC3B,OAAO,CAACwE,IAAI,EAAEe,YAAY,CAAC;AACzC;AACF;AAEA,EAAA,OAAO5D,IAAI;AACb;;;;"}
|
package/dist/json-api.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { setBuildURLConfig as setBuildURLConfig$1, buildBaseURL, buildQueryParams } from
|
|
2
|
-
import { p as pluralize } from "./inflect-
|
|
1
|
+
import { setBuildURLConfig as setBuildURLConfig$1, buildBaseURL, buildQueryParams } from './index.js';
|
|
2
|
+
import { p as pluralize } from "./inflect-Dr20y6b1.js";
|
|
3
3
|
import { e as extractCacheOptions, c as copyForwardUrlOptions } from "./builder-utils-Donkk-BZ.js";
|
|
4
4
|
import { recordIdentifierFor } from '@warp-drive/core';
|
|
5
5
|
import { macroCondition, getGlobalConfig } from '@embroider/macros';
|
package/dist/rest.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { buildBaseURL, buildQueryParams } from
|
|
2
|
-
import { p as pluralize, g as camelize } from "./inflect-
|
|
1
|
+
import { buildBaseURL, buildQueryParams } from './index.js';
|
|
2
|
+
import { p as pluralize, g as camelize } from "./inflect-Dr20y6b1.js";
|
|
3
3
|
import { e as extractCacheOptions, c as copyForwardUrlOptions } from "./builder-utils-Donkk-BZ.js";
|
|
4
4
|
import { recordIdentifierFor } from '@warp-drive/core';
|
|
5
5
|
import { macroCondition, getGlobalConfig } from '@embroider/macros';
|
package/dist/string.cjs
ADDED
|
@@ -0,0 +1,463 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
+
|
|
5
|
+
const DEFAULT_MAX_CACHE_SIZE = 10_000;
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* An LRUCache implementation with upsert semantics.
|
|
9
|
+
*
|
|
10
|
+
* This implementation is *not* generic, but focuses on
|
|
11
|
+
* performance tuning for the string transformation cases
|
|
12
|
+
* where the key maps to the value very simply.
|
|
13
|
+
*
|
|
14
|
+
* It takes a work function that should generate a new value
|
|
15
|
+
* for a given key when called. It will be called when the key
|
|
16
|
+
* is not found in the cache.
|
|
17
|
+
*
|
|
18
|
+
* It keeps track of the number of hits, misses, and ejections
|
|
19
|
+
* in DEBUG envs, which is useful for tuning the cache size.
|
|
20
|
+
*
|
|
21
|
+
* This is an internal utility class for use by this module
|
|
22
|
+
* and by `@warp-drive/utilities/string`. It is not intended
|
|
23
|
+
* for use outside of these modules at this time.
|
|
24
|
+
*
|
|
25
|
+
* @internal
|
|
26
|
+
*/
|
|
27
|
+
class LRUCache {
|
|
28
|
+
// debug stats
|
|
29
|
+
|
|
30
|
+
constructor(doWork, size) {
|
|
31
|
+
this.size = size || DEFAULT_MAX_CACHE_SIZE;
|
|
32
|
+
this.state = new Map();
|
|
33
|
+
this.doWork = doWork;
|
|
34
|
+
}
|
|
35
|
+
get(key) {
|
|
36
|
+
const value = this.state.get(key);
|
|
37
|
+
if (value) {
|
|
38
|
+
this.state.delete(key);
|
|
39
|
+
this.state.set(key, value);
|
|
40
|
+
return value;
|
|
41
|
+
}
|
|
42
|
+
const newValue = this.doWork(key);
|
|
43
|
+
this.set(key, newValue);
|
|
44
|
+
return newValue;
|
|
45
|
+
}
|
|
46
|
+
set(key, value) {
|
|
47
|
+
if (this.state.size === this.size) {
|
|
48
|
+
for (const [k] of this.state) {
|
|
49
|
+
this.state.delete(k);
|
|
50
|
+
break;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
this.state.set(key, value);
|
|
54
|
+
}
|
|
55
|
+
clear() {
|
|
56
|
+
this.state.clear();
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
const STRING_DASHERIZE_REGEXP = /[ _]/g;
|
|
60
|
+
const STRING_DECAMELIZE_REGEXP = /([a-z\d])([A-Z])/g;
|
|
61
|
+
const STRING_DASHERIZE_CACHE = new LRUCache(key => key.replace(STRING_DECAMELIZE_REGEXP, '$1_$2').toLowerCase().replace(STRING_DASHERIZE_REGEXP, '-'));
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* This is an internal utility function that converts a string
|
|
65
|
+
* to a dasherized format. Library consumers should use the
|
|
66
|
+
* re-exported version from `@warp-drive/utilities/string` instead.
|
|
67
|
+
*
|
|
68
|
+
* This version is only in this location to support a deprecated
|
|
69
|
+
* behavior in the core package and will be removed in a future.
|
|
70
|
+
*
|
|
71
|
+
* @internal
|
|
72
|
+
*/
|
|
73
|
+
function dasherize$1(str) {
|
|
74
|
+
return STRING_DASHERIZE_CACHE.get(str);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
const defaultRules = {
|
|
78
|
+
plurals: [[/$/, 's'], [/s$/i, 's'], [/^(ax|test)is$/i, '$1es'], [/(octop|vir)us$/i, '$1i'], [/(octop|vir)i$/i, '$1i'], [/(alias|status|bonus)$/i, '$1es'], [/(bu)s$/i, '$1ses'], [/(buffal|tomat)o$/i, '$1oes'], [/([ti])um$/i, '$1a'], [/([ti])a$/i, '$1a'], [/sis$/i, 'ses'], [/(?:([^f])fe|([lr])f)$/i, '$1$2ves'], [/(hive)$/i, '$1s'], [/([^aeiouy]|qu)y$/i, '$1ies'], [/(x|ch|ss|sh)$/i, '$1es'], [/(matr|vert|ind)(?:ix|ex)$/i, '$1ices'], [/^(m|l)ouse$/i, '$1ice'], [/^(m|l)ice$/i, '$1ice'], [/^(ox)$/i, '$1en'], [/^(oxen)$/i, '$1'], [/(quiz)$/i, '$1zes']],
|
|
79
|
+
singular: [[/s$/i, ''], [/(ss)$/i, '$1'], [/(n)ews$/i, '$1ews'], [/([ti])a$/i, '$1um'], [/((a)naly|(b)a|(d)iagno|(p)arenthe|(p)rogno|(s)ynop|(t)he)(sis|ses)$/i, '$1sis'], [/(^analy)(sis|ses)$/i, '$1sis'], [/([^f])ves$/i, '$1fe'], [/(hive)s$/i, '$1'], [/(tive)s$/i, '$1'], [/([lr])ves$/i, '$1f'], [/([^aeiouy]|qu)ies$/i, '$1y'], [/(s)eries$/i, '$1eries'], [/(m)ovies$/i, '$1ovie'], [/(x|ch|ss|sh)es$/i, '$1'], [/^(m|l)ice$/i, '$1ouse'], [/(bus)(es)?$/i, '$1'], [/(o)es$/i, '$1'], [/(shoe)s$/i, '$1'], [/(cris|test)(is|es)$/i, '$1is'], [/^(a)x[ie]s$/i, '$1xis'], [/(octop|vir)(us|i)$/i, '$1us'], [/(alias|status|bonus)(es)?$/i, '$1'], [/^(ox)en/i, '$1'], [/(vert|ind)ices$/i, '$1ex'], [/(matr)ices$/i, '$1ix'], [/(quiz)zes$/i, '$1'], [/(database)s$/i, '$1']],
|
|
80
|
+
irregularPairs: [['person', 'people'], ['man', 'men'], ['child', 'children'], ['sex', 'sexes'], ['move', 'moves'], ['cow', 'kine'], ['zombie', 'zombies']],
|
|
81
|
+
uncountable: ['equipment', 'information', 'rice', 'money', 'species', 'series', 'fish', 'sheep', 'jeans', 'police']
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
// eslint-disable-next-line no-useless-escape
|
|
85
|
+
const STRING_CAMELIZE_REGEXP_1 = /(\-|\_|\.|\s)+(.)?/g;
|
|
86
|
+
const STRING_CAMELIZE_REGEXP_2 = /(^|\/)([A-Z])/g;
|
|
87
|
+
const CAMELIZE_CACHE = new LRUCache(key => key.replace(STRING_CAMELIZE_REGEXP_1, (_match, _separator, chr) => chr ? chr.toUpperCase() : '').replace(STRING_CAMELIZE_REGEXP_2, (match /*, separator, chr */) => match.toLowerCase()));
|
|
88
|
+
const STRING_UNDERSCORE_REGEXP_1 = /([a-z\d])([A-Z]+)/g;
|
|
89
|
+
// eslint-disable-next-line no-useless-escape
|
|
90
|
+
const STRING_UNDERSCORE_REGEXP_2 = /\-|\s+/g;
|
|
91
|
+
const UNDERSCORE_CACHE = new LRUCache(str => str.replace(STRING_UNDERSCORE_REGEXP_1, '$1_$2').replace(STRING_UNDERSCORE_REGEXP_2, '_').toLowerCase());
|
|
92
|
+
const STRING_CAPITALIZE_REGEXP = /(^|\/)([a-z\u00C0-\u024F])/g;
|
|
93
|
+
const CAPITALIZE_CACHE = new LRUCache(str => str.replace(STRING_CAPITALIZE_REGEXP, (match /*, separator, chr */) => match.toUpperCase()));
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Replaces underscores, spaces, or camelCase with dashes.
|
|
97
|
+
*
|
|
98
|
+
* ```js
|
|
99
|
+
* import { dasherize } from '@warp-drive/utilities/string';
|
|
100
|
+
*
|
|
101
|
+
* dasherize('innerHTML'); // 'inner-html'
|
|
102
|
+
* dasherize('action_name'); // 'action-name'
|
|
103
|
+
* dasherize('css-class-name'); // 'css-class-name'
|
|
104
|
+
* dasherize('my favorite items'); // 'my-favorite-items'
|
|
105
|
+
* dasherize('privateDocs/ownerInvoice'; // 'private-docs/owner-invoice'
|
|
106
|
+
* ```
|
|
107
|
+
*
|
|
108
|
+
* @public
|
|
109
|
+
* @param {String} str
|
|
110
|
+
* @return {String}
|
|
111
|
+
* @since 4.13.0
|
|
112
|
+
*/
|
|
113
|
+
const dasherize = dasherize$1;
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Returns the lowerCamelCase form of a string.
|
|
117
|
+
*
|
|
118
|
+
* ```js
|
|
119
|
+
* import { camelize } from '@warp-drive/utilities/string';
|
|
120
|
+
*
|
|
121
|
+
* camelize('innerHTML'); // 'innerHTML'
|
|
122
|
+
* camelize('action_name'); // 'actionName'
|
|
123
|
+
* camelize('css-class-name'); // 'cssClassName'
|
|
124
|
+
* camelize('my favorite items'); // 'myFavoriteItems'
|
|
125
|
+
* camelize('My Favorite Items'); // 'myFavoriteItems'
|
|
126
|
+
* camelize('private-docs/owner-invoice'); // 'privateDocs/ownerInvoice'
|
|
127
|
+
* ```
|
|
128
|
+
*
|
|
129
|
+
* @public
|
|
130
|
+
* @param {String} str
|
|
131
|
+
* @return {String}
|
|
132
|
+
* @since 4.13.0
|
|
133
|
+
*/
|
|
134
|
+
function camelize(str) {
|
|
135
|
+
return CAMELIZE_CACHE.get(str);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Returns the lower\_case\_and\_underscored form of a string.
|
|
140
|
+
*
|
|
141
|
+
* ```js
|
|
142
|
+
* import { underscore } from '@warp-drive/utilities/string';
|
|
143
|
+
*
|
|
144
|
+
* underscore('innerHTML'); // 'inner_html'
|
|
145
|
+
* underscore('action_name'); // 'action_name'
|
|
146
|
+
* underscore('css-class-name'); // 'css_class_name'
|
|
147
|
+
* underscore('my favorite items'); // 'my_favorite_items'
|
|
148
|
+
* underscore('privateDocs/ownerInvoice'); // 'private_docs/owner_invoice'
|
|
149
|
+
* ```
|
|
150
|
+
*
|
|
151
|
+
* @public
|
|
152
|
+
* @param {String} str
|
|
153
|
+
* @return {String}
|
|
154
|
+
* @since 4.13.0
|
|
155
|
+
*/
|
|
156
|
+
function underscore(str) {
|
|
157
|
+
return UNDERSCORE_CACHE.get(str);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Returns the Capitalized form of a string
|
|
162
|
+
*
|
|
163
|
+
* ```js
|
|
164
|
+
* import { capitalize } from '@warp-drive/utilities/string';
|
|
165
|
+
*
|
|
166
|
+
* capitalize('innerHTML') // 'InnerHTML'
|
|
167
|
+
* capitalize('action_name') // 'Action_name'
|
|
168
|
+
* capitalize('css-class-name') // 'Css-class-name'
|
|
169
|
+
* capitalize('my favorite items') // 'My favorite items'
|
|
170
|
+
* capitalize('privateDocs/ownerInvoice'); // 'PrivateDocs/ownerInvoice'
|
|
171
|
+
* ```
|
|
172
|
+
*
|
|
173
|
+
* @public
|
|
174
|
+
* @param {String} str
|
|
175
|
+
* @return {String}
|
|
176
|
+
* @since 4.13.0
|
|
177
|
+
*/
|
|
178
|
+
function capitalize(str) {
|
|
179
|
+
return CAPITALIZE_CACHE.get(str);
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* Sets the maximum size of the LRUCache for all string transformation functions.
|
|
184
|
+
* The default size is 10,000.
|
|
185
|
+
*
|
|
186
|
+
* @public
|
|
187
|
+
* @param {Number} size
|
|
188
|
+
* @return {void}
|
|
189
|
+
* @since 4.13.0
|
|
190
|
+
*/
|
|
191
|
+
function setMaxLRUCacheSize(size) {
|
|
192
|
+
CAMELIZE_CACHE.size = size;
|
|
193
|
+
UNDERSCORE_CACHE.size = size;
|
|
194
|
+
CAPITALIZE_CACHE.size = size;
|
|
195
|
+
STRING_DASHERIZE_CACHE.size = size;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
const BLANK_REGEX = /^\s*$/;
|
|
199
|
+
const LAST_WORD_DASHED_REGEX = /([\w/-]+[_/\s-])([a-z\d]+$)/;
|
|
200
|
+
const LAST_WORD_CAMELIZED_REGEX = /([\w/\s-]+)([A-Z][a-z\d]*$)/;
|
|
201
|
+
const CAMELIZED_REGEX = /[A-Z][a-z\d]*$/;
|
|
202
|
+
const SINGULARS = new LRUCache(word => {
|
|
203
|
+
return _singularize(word);
|
|
204
|
+
});
|
|
205
|
+
const PLURALS = new LRUCache(word => {
|
|
206
|
+
return _pluralize(word);
|
|
207
|
+
});
|
|
208
|
+
const UNCOUNTABLE = new Set(defaultRules.uncountable);
|
|
209
|
+
const IRREGULAR = new Map();
|
|
210
|
+
const INVERSE_IRREGULAR = new Map();
|
|
211
|
+
const SINGULAR_RULES = new Map(defaultRules.singular.reverse());
|
|
212
|
+
const PLURAL_RULES = new Map(defaultRules.plurals.reverse());
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* Marks a word as uncountable. Uncountable words are not pluralized
|
|
216
|
+
* or singularized.
|
|
217
|
+
*
|
|
218
|
+
* @public
|
|
219
|
+
* @param {String} word
|
|
220
|
+
* @return {void}
|
|
221
|
+
* @since 4.13.0
|
|
222
|
+
*/
|
|
223
|
+
function uncountable(word) {
|
|
224
|
+
UNCOUNTABLE.add(word.toLowerCase());
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
/**
|
|
228
|
+
* Marks a list of words as uncountable. Uncountable words are not pluralized
|
|
229
|
+
* or singularized.
|
|
230
|
+
*
|
|
231
|
+
* @public
|
|
232
|
+
* @param {Array<String>} uncountables
|
|
233
|
+
* @return {void}
|
|
234
|
+
* @since 4.13.0
|
|
235
|
+
*/
|
|
236
|
+
function loadUncountable(uncountables) {
|
|
237
|
+
uncountables.forEach(word => {
|
|
238
|
+
uncountable(word);
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
/**
|
|
243
|
+
* Marks a word as irregular. Irregular words have unique
|
|
244
|
+
* pluralization and singularization rules.
|
|
245
|
+
*
|
|
246
|
+
* @public
|
|
247
|
+
* @param {String} single
|
|
248
|
+
* @param {String} plur
|
|
249
|
+
* @return {void}
|
|
250
|
+
* @since 4.13.0
|
|
251
|
+
*/
|
|
252
|
+
function irregular(single, plur) {
|
|
253
|
+
//pluralizing
|
|
254
|
+
IRREGULAR.set(single.toLowerCase(), plur);
|
|
255
|
+
IRREGULAR.set(plur.toLowerCase(), plur);
|
|
256
|
+
|
|
257
|
+
//singularizing
|
|
258
|
+
INVERSE_IRREGULAR.set(plur.toLowerCase(), single);
|
|
259
|
+
INVERSE_IRREGULAR.set(single.toLowerCase(), single);
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
/**
|
|
263
|
+
* Marks a list of word pairs as irregular. Irregular words have unique
|
|
264
|
+
* pluralization and singularization rules.
|
|
265
|
+
*
|
|
266
|
+
* @public
|
|
267
|
+
* @param {Array<Array<String>>} irregularPairs
|
|
268
|
+
* @return {void}
|
|
269
|
+
* @since 4.13.0
|
|
270
|
+
*/
|
|
271
|
+
function loadIrregular(irregularPairs) {
|
|
272
|
+
irregularPairs.forEach(pair => {
|
|
273
|
+
//pluralizing
|
|
274
|
+
IRREGULAR.set(pair[0].toLowerCase(), pair[1]);
|
|
275
|
+
IRREGULAR.set(pair[1].toLowerCase(), pair[1]);
|
|
276
|
+
|
|
277
|
+
//singularizing
|
|
278
|
+
INVERSE_IRREGULAR.set(pair[1].toLowerCase(), pair[0]);
|
|
279
|
+
INVERSE_IRREGULAR.set(pair[0].toLowerCase(), pair[0]);
|
|
280
|
+
});
|
|
281
|
+
}
|
|
282
|
+
loadIrregular(defaultRules.irregularPairs);
|
|
283
|
+
|
|
284
|
+
/**
|
|
285
|
+
* Clears the caches for singularize and pluralize.
|
|
286
|
+
*
|
|
287
|
+
* @public
|
|
288
|
+
* @return {void}
|
|
289
|
+
* @since 4.13.0
|
|
290
|
+
*/
|
|
291
|
+
function clear() {
|
|
292
|
+
SINGULARS.clear();
|
|
293
|
+
PLURALS.clear();
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
/**
|
|
297
|
+
* Resets the inflection rules to the defaults.
|
|
298
|
+
*
|
|
299
|
+
* @public
|
|
300
|
+
* @return {void}
|
|
301
|
+
* @since 4.13.0
|
|
302
|
+
*/
|
|
303
|
+
function resetToDefaults() {
|
|
304
|
+
clearRules();
|
|
305
|
+
defaultRules.uncountable.forEach(v => UNCOUNTABLE.add(v));
|
|
306
|
+
defaultRules.singular.forEach(v => SINGULAR_RULES.set(v[0], v[1]));
|
|
307
|
+
defaultRules.plurals.forEach(v => PLURAL_RULES.set(v[0], v[1]));
|
|
308
|
+
loadIrregular(defaultRules.irregularPairs);
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
/**
|
|
312
|
+
* Clears all inflection rules
|
|
313
|
+
* and resets the caches for singularize and pluralize.
|
|
314
|
+
*
|
|
315
|
+
* @public
|
|
316
|
+
* @return {void}
|
|
317
|
+
* @since 4.13.0
|
|
318
|
+
*/
|
|
319
|
+
function clearRules() {
|
|
320
|
+
SINGULARS.clear();
|
|
321
|
+
PLURALS.clear();
|
|
322
|
+
UNCOUNTABLE.clear();
|
|
323
|
+
IRREGULAR.clear();
|
|
324
|
+
INVERSE_IRREGULAR.clear();
|
|
325
|
+
SINGULAR_RULES.clear();
|
|
326
|
+
PLURAL_RULES.clear();
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
/**
|
|
330
|
+
* Singularizes a word.
|
|
331
|
+
*
|
|
332
|
+
* @public
|
|
333
|
+
* @param {String} word
|
|
334
|
+
* @return {String}
|
|
335
|
+
* @since 4.13.0
|
|
336
|
+
*/
|
|
337
|
+
function singularize(word) {
|
|
338
|
+
if (!word) return '';
|
|
339
|
+
return SINGULARS.get(word);
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
/**
|
|
343
|
+
* Pluralizes a word.
|
|
344
|
+
*
|
|
345
|
+
* @public
|
|
346
|
+
* @param {String} word
|
|
347
|
+
* @return {String}
|
|
348
|
+
* @since 4.13.0
|
|
349
|
+
*/
|
|
350
|
+
function pluralize(word) {
|
|
351
|
+
if (!word) return '';
|
|
352
|
+
return PLURALS.get(word);
|
|
353
|
+
}
|
|
354
|
+
function unshiftMap(v, map) {
|
|
355
|
+
// reorder
|
|
356
|
+
const rules = [v, ...map.entries()];
|
|
357
|
+
map.clear();
|
|
358
|
+
rules.forEach(rule => {
|
|
359
|
+
map.set(rule[0], rule[1]);
|
|
360
|
+
});
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
/**
|
|
364
|
+
* Adds a pluralization rule.
|
|
365
|
+
*
|
|
366
|
+
* @public
|
|
367
|
+
* @param {RegExp} regex
|
|
368
|
+
* @param {String} string
|
|
369
|
+
* @return {void}
|
|
370
|
+
* @since 4.13.0
|
|
371
|
+
*/
|
|
372
|
+
function plural(regex, string) {
|
|
373
|
+
// rule requires reordering if exists, so remove it first
|
|
374
|
+
if (PLURAL_RULES.has(regex)) {
|
|
375
|
+
PLURAL_RULES.delete(regex);
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
// reorder
|
|
379
|
+
unshiftMap([regex, string], PLURAL_RULES);
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
/**
|
|
383
|
+
* Adds a singularization rule.
|
|
384
|
+
*
|
|
385
|
+
* @public
|
|
386
|
+
* @param {RegExp} regex
|
|
387
|
+
* @param {String} string
|
|
388
|
+
* @return {void}
|
|
389
|
+
* @since 4.13.0
|
|
390
|
+
*/
|
|
391
|
+
function singular(regex, string) {
|
|
392
|
+
// rule requires reordering if exists, so remove it first
|
|
393
|
+
if (SINGULAR_RULES.has(regex)) {
|
|
394
|
+
SINGULAR_RULES.delete(regex);
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
// reorder
|
|
398
|
+
unshiftMap([regex, string], SINGULAR_RULES);
|
|
399
|
+
}
|
|
400
|
+
function _pluralize(word) {
|
|
401
|
+
return inflect(word, PLURAL_RULES, IRREGULAR);
|
|
402
|
+
}
|
|
403
|
+
function _singularize(word) {
|
|
404
|
+
return inflect(word, SINGULAR_RULES, INVERSE_IRREGULAR);
|
|
405
|
+
}
|
|
406
|
+
function inflect(word, typeRules, irregulars) {
|
|
407
|
+
// empty strings
|
|
408
|
+
const isBlank = !word || BLANK_REGEX.test(word);
|
|
409
|
+
if (isBlank) {
|
|
410
|
+
return word;
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
// basic uncountables
|
|
414
|
+
const lowercase = word.toLowerCase();
|
|
415
|
+
if (UNCOUNTABLE.has(lowercase)) {
|
|
416
|
+
return word;
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
// adv uncountables
|
|
420
|
+
const wordSplit = LAST_WORD_DASHED_REGEX.exec(word) || LAST_WORD_CAMELIZED_REGEX.exec(word);
|
|
421
|
+
const lastWord = wordSplit ? wordSplit[2].toLowerCase() : null;
|
|
422
|
+
if (lastWord && UNCOUNTABLE.has(lastWord)) {
|
|
423
|
+
return word;
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
// handle irregulars
|
|
427
|
+
const isCamelized = CAMELIZED_REGEX.test(word);
|
|
428
|
+
for (let [rule, substitution] of irregulars) {
|
|
429
|
+
if (lowercase.match(rule + '$')) {
|
|
430
|
+
if (isCamelized && lastWord && irregulars.has(lastWord)) {
|
|
431
|
+
substitution = capitalize(substitution);
|
|
432
|
+
rule = capitalize(rule);
|
|
433
|
+
}
|
|
434
|
+
return word.replace(new RegExp(rule, 'i'), substitution);
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
// do the actual inflection
|
|
439
|
+
for (const [rule, substitution] of typeRules) {
|
|
440
|
+
if (rule.test(word)) {
|
|
441
|
+
return word.replace(rule, substitution);
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
return word;
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
exports.camelize = camelize;
|
|
448
|
+
exports.capitalize = capitalize;
|
|
449
|
+
exports.clear = clear;
|
|
450
|
+
exports.clearRules = clearRules;
|
|
451
|
+
exports.dasherize = dasherize;
|
|
452
|
+
exports.irregular = irregular;
|
|
453
|
+
exports.loadIrregular = loadIrregular;
|
|
454
|
+
exports.loadUncountable = loadUncountable;
|
|
455
|
+
exports.plural = plural;
|
|
456
|
+
exports.pluralize = pluralize;
|
|
457
|
+
exports.resetToDefaults = resetToDefaults;
|
|
458
|
+
exports.setMaxLRUCacheSize = setMaxLRUCacheSize;
|
|
459
|
+
exports.singular = singular;
|
|
460
|
+
exports.singularize = singularize;
|
|
461
|
+
exports.uncountable = uncountable;
|
|
462
|
+
exports.underscore = underscore;
|
|
463
|
+
//# sourceMappingURL=string.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"string.cjs","sources":["../../../node_modules/.pnpm/@warp-d_713925c1c4fbcdf3390170e659dd4c3d/node_modules/@warp-drive/core/dist/utils/string.js","../src/-private/string/inflections.ts","../src/-private/string/transform.ts","../src/-private/string/inflect.ts"],"sourcesContent":["import { macroCondition, getGlobalConfig } from '@embroider/macros';\nconst DEFAULT_MAX_CACHE_SIZE = 10_000;\n\n/**\n * An LRUCache implementation with upsert semantics.\n *\n * This implementation is *not* generic, but focuses on\n * performance tuning for the string transformation cases\n * where the key maps to the value very simply.\n *\n * It takes a work function that should generate a new value\n * for a given key when called. It will be called when the key\n * is not found in the cache.\n *\n * It keeps track of the number of hits, misses, and ejections\n * in DEBUG envs, which is useful for tuning the cache size.\n *\n * This is an internal utility class for use by this module\n * and by `@warp-drive/utilities/string`. It is not intended\n * for use outside of these modules at this time.\n *\n * @internal\n */\nclass LRUCache {\n // debug stats\n\n constructor(doWork, size) {\n this.size = size || DEFAULT_MAX_CACHE_SIZE;\n this.state = new Map();\n this.doWork = doWork;\n if (macroCondition(getGlobalConfig().WarpDrive.env.DEBUG)) {\n this._hits = 0;\n this._misses = 0;\n this._ejected = 0;\n }\n }\n get(key) {\n const value = this.state.get(key);\n if (value) {\n if (macroCondition(getGlobalConfig().WarpDrive.env.DEBUG)) {\n this._hits++;\n }\n this.state.delete(key);\n this.state.set(key, value);\n return value;\n }\n if (macroCondition(getGlobalConfig().WarpDrive.env.DEBUG)) {\n this._misses++;\n }\n const newValue = this.doWork(key);\n this.set(key, newValue);\n return newValue;\n }\n set(key, value) {\n if (this.state.size === this.size) {\n for (const [k] of this.state) {\n if (macroCondition(getGlobalConfig().WarpDrive.env.DEBUG)) {\n this._ejected++;\n }\n this.state.delete(k);\n break;\n }\n }\n this.state.set(key, value);\n }\n clear() {\n this.state.clear();\n if (macroCondition(getGlobalConfig().WarpDrive.env.DEBUG)) {\n this._hits = 0;\n this._misses = 0;\n this._ejected = 0;\n }\n }\n}\nconst STRING_DASHERIZE_REGEXP = /[ _]/g;\nconst STRING_DECAMELIZE_REGEXP = /([a-z\\d])([A-Z])/g;\nconst STRING_DASHERIZE_CACHE = new LRUCache(key => key.replace(STRING_DECAMELIZE_REGEXP, '$1_$2').toLowerCase().replace(STRING_DASHERIZE_REGEXP, '-'));\n\n/**\n * This is an internal utility function that converts a string\n * to a dasherized format. Library consumers should use the\n * re-exported version from `@warp-drive/utilities/string` instead.\n *\n * This version is only in this location to support a deprecated\n * behavior in the core package and will be removed in a future.\n *\n * @internal\n */\nfunction dasherize(str) {\n return STRING_DASHERIZE_CACHE.get(str);\n}\nexport { LRUCache, STRING_DASHERIZE_CACHE, dasherize };","export type RulesArray = Array<[RegExp, string]>;\ntype DefaultRulesType = {\n plurals: RulesArray;\n singular: RulesArray;\n irregularPairs: Array<[string, string]>;\n uncountable: string[];\n};\n\nexport const defaultRules: DefaultRulesType = {\n plurals: [\n [/$/, 's'],\n [/s$/i, 's'],\n [/^(ax|test)is$/i, '$1es'],\n [/(octop|vir)us$/i, '$1i'],\n [/(octop|vir)i$/i, '$1i'],\n [/(alias|status|bonus)$/i, '$1es'],\n [/(bu)s$/i, '$1ses'],\n [/(buffal|tomat)o$/i, '$1oes'],\n [/([ti])um$/i, '$1a'],\n [/([ti])a$/i, '$1a'],\n [/sis$/i, 'ses'],\n [/(?:([^f])fe|([lr])f)$/i, '$1$2ves'],\n [/(hive)$/i, '$1s'],\n [/([^aeiouy]|qu)y$/i, '$1ies'],\n [/(x|ch|ss|sh)$/i, '$1es'],\n [/(matr|vert|ind)(?:ix|ex)$/i, '$1ices'],\n [/^(m|l)ouse$/i, '$1ice'],\n [/^(m|l)ice$/i, '$1ice'],\n [/^(ox)$/i, '$1en'],\n [/^(oxen)$/i, '$1'],\n [/(quiz)$/i, '$1zes'],\n ],\n\n singular: [\n [/s$/i, ''],\n [/(ss)$/i, '$1'],\n [/(n)ews$/i, '$1ews'],\n [/([ti])a$/i, '$1um'],\n [/((a)naly|(b)a|(d)iagno|(p)arenthe|(p)rogno|(s)ynop|(t)he)(sis|ses)$/i, '$1sis'],\n [/(^analy)(sis|ses)$/i, '$1sis'],\n [/([^f])ves$/i, '$1fe'],\n [/(hive)s$/i, '$1'],\n [/(tive)s$/i, '$1'],\n [/([lr])ves$/i, '$1f'],\n [/([^aeiouy]|qu)ies$/i, '$1y'],\n [/(s)eries$/i, '$1eries'],\n [/(m)ovies$/i, '$1ovie'],\n [/(x|ch|ss|sh)es$/i, '$1'],\n [/^(m|l)ice$/i, '$1ouse'],\n [/(bus)(es)?$/i, '$1'],\n [/(o)es$/i, '$1'],\n [/(shoe)s$/i, '$1'],\n [/(cris|test)(is|es)$/i, '$1is'],\n [/^(a)x[ie]s$/i, '$1xis'],\n [/(octop|vir)(us|i)$/i, '$1us'],\n [/(alias|status|bonus)(es)?$/i, '$1'],\n [/^(ox)en/i, '$1'],\n [/(vert|ind)ices$/i, '$1ex'],\n [/(matr)ices$/i, '$1ix'],\n [/(quiz)zes$/i, '$1'],\n [/(database)s$/i, '$1'],\n ],\n\n irregularPairs: [\n ['person', 'people'],\n ['man', 'men'],\n ['child', 'children'],\n ['sex', 'sexes'],\n ['move', 'moves'],\n ['cow', 'kine'],\n ['zombie', 'zombies'],\n ],\n\n uncountable: ['equipment', 'information', 'rice', 'money', 'species', 'series', 'fish', 'sheep', 'jeans', 'police'],\n};\n","import { dasherize as internalDasherize, LRUCache, STRING_DASHERIZE_CACHE } from '@warp-drive/core/utils/string';\n\n// eslint-disable-next-line no-useless-escape\nconst STRING_CAMELIZE_REGEXP_1 = /(\\-|\\_|\\.|\\s)+(.)?/g;\nconst STRING_CAMELIZE_REGEXP_2 = /(^|\\/)([A-Z])/g;\nconst CAMELIZE_CACHE = new LRUCache<string, string>((key: string) =>\n key\n .replace(STRING_CAMELIZE_REGEXP_1, (_match, _separator, chr: string | null) => (chr ? chr.toUpperCase() : ''))\n .replace(STRING_CAMELIZE_REGEXP_2, (match /*, separator, chr */) => match.toLowerCase())\n);\n\nconst STRING_UNDERSCORE_REGEXP_1 = /([a-z\\d])([A-Z]+)/g;\n// eslint-disable-next-line no-useless-escape\nconst STRING_UNDERSCORE_REGEXP_2 = /\\-|\\s+/g;\nconst UNDERSCORE_CACHE = new LRUCache<string, string>((str: string) =>\n str.replace(STRING_UNDERSCORE_REGEXP_1, '$1_$2').replace(STRING_UNDERSCORE_REGEXP_2, '_').toLowerCase()\n);\n\nconst STRING_CAPITALIZE_REGEXP = /(^|\\/)([a-z\\u00C0-\\u024F])/g;\nconst CAPITALIZE_CACHE = new LRUCache<string, string>((str: string) =>\n str.replace(STRING_CAPITALIZE_REGEXP, (match /*, separator, chr */) => match.toUpperCase())\n);\n\n/**\n * Replaces underscores, spaces, or camelCase with dashes.\n *\n * ```js\n * import { dasherize } from '@warp-drive/utilities/string';\n *\n * dasherize('innerHTML'); // 'inner-html'\n * dasherize('action_name'); // 'action-name'\n * dasherize('css-class-name'); // 'css-class-name'\n * dasherize('my favorite items'); // 'my-favorite-items'\n * dasherize('privateDocs/ownerInvoice'; // 'private-docs/owner-invoice'\n * ```\n *\n * @public\n * @param {String} str\n * @return {String}\n * @since 4.13.0\n */\nexport const dasherize = internalDasherize;\n\n/**\n * Returns the lowerCamelCase form of a string.\n *\n * ```js\n * import { camelize } from '@warp-drive/utilities/string';\n *\n * camelize('innerHTML'); // 'innerHTML'\n * camelize('action_name'); // 'actionName'\n * camelize('css-class-name'); // 'cssClassName'\n * camelize('my favorite items'); // 'myFavoriteItems'\n * camelize('My Favorite Items'); // 'myFavoriteItems'\n * camelize('private-docs/owner-invoice'); // 'privateDocs/ownerInvoice'\n * ```\n *\n * @public\n * @param {String} str\n * @return {String}\n * @since 4.13.0\n */\nexport function camelize(str: string): string {\n return CAMELIZE_CACHE.get(str);\n}\n\n/**\n * Returns the lower\\_case\\_and\\_underscored form of a string.\n *\n * ```js\n * import { underscore } from '@warp-drive/utilities/string';\n *\n * underscore('innerHTML'); // 'inner_html'\n * underscore('action_name'); // 'action_name'\n * underscore('css-class-name'); // 'css_class_name'\n * underscore('my favorite items'); // 'my_favorite_items'\n * underscore('privateDocs/ownerInvoice'); // 'private_docs/owner_invoice'\n * ```\n *\n * @public\n * @param {String} str\n * @return {String}\n * @since 4.13.0\n */\nexport function underscore(str: string): string {\n return UNDERSCORE_CACHE.get(str);\n}\n\n/**\n * Returns the Capitalized form of a string\n *\n * ```js\n * import { capitalize } from '@warp-drive/utilities/string';\n *\n * capitalize('innerHTML') // 'InnerHTML'\n * capitalize('action_name') // 'Action_name'\n * capitalize('css-class-name') // 'Css-class-name'\n * capitalize('my favorite items') // 'My favorite items'\n * capitalize('privateDocs/ownerInvoice'); // 'PrivateDocs/ownerInvoice'\n * ```\n *\n * @public\n * @param {String} str\n * @return {String}\n * @since 4.13.0\n */\nexport function capitalize(str: string): string {\n return CAPITALIZE_CACHE.get(str);\n}\n\n/**\n * Sets the maximum size of the LRUCache for all string transformation functions.\n * The default size is 10,000.\n *\n * @public\n * @param {Number} size\n * @return {void}\n * @since 4.13.0\n */\nexport function setMaxLRUCacheSize(size: number) {\n CAMELIZE_CACHE.size = size;\n UNDERSCORE_CACHE.size = size;\n CAPITALIZE_CACHE.size = size;\n STRING_DASHERIZE_CACHE.size = size;\n}\n","import { assert } from '@warp-drive/core/build-config/macros';\nimport { LRUCache } from '@warp-drive/core/utils/string';\n\nimport { defaultRules } from './inflections.ts';\nimport { capitalize } from './transform.ts';\n\nconst BLANK_REGEX = /^\\s*$/;\nconst LAST_WORD_DASHED_REGEX = /([\\w/-]+[_/\\s-])([a-z\\d]+$)/;\nconst LAST_WORD_CAMELIZED_REGEX = /([\\w/\\s-]+)([A-Z][a-z\\d]*$)/;\nconst CAMELIZED_REGEX = /[A-Z][a-z\\d]*$/;\n\nconst SINGULARS = new LRUCache<string, string>((word: string) => {\n return _singularize(word);\n});\nconst PLURALS = new LRUCache<string, string>((word: string) => {\n return _pluralize(word);\n});\nconst UNCOUNTABLE = new Set(defaultRules.uncountable);\nconst IRREGULAR: Map<string, string> = new Map();\nconst INVERSE_IRREGULAR: Map<string, string> = new Map();\nconst SINGULAR_RULES = new Map(defaultRules.singular.reverse());\nconst PLURAL_RULES = new Map(defaultRules.plurals.reverse());\n\n/**\n * Marks a word as uncountable. Uncountable words are not pluralized\n * or singularized.\n *\n * @public\n * @param {String} word\n * @return {void}\n * @since 4.13.0\n */\nexport function uncountable(word: string) {\n UNCOUNTABLE.add(word.toLowerCase());\n}\n\n/**\n * Marks a list of words as uncountable. Uncountable words are not pluralized\n * or singularized.\n *\n * @public\n * @param {Array<String>} uncountables\n * @return {void}\n * @since 4.13.0\n */\nexport function loadUncountable(uncountables: string[]) {\n uncountables.forEach((word) => {\n uncountable(word);\n });\n}\n\n/**\n * Marks a word as irregular. Irregular words have unique\n * pluralization and singularization rules.\n *\n * @public\n * @param {String} single\n * @param {String} plur\n * @return {void}\n * @since 4.13.0\n */\nexport function irregular(single: string, plur: string) {\n //pluralizing\n IRREGULAR.set(single.toLowerCase(), plur);\n IRREGULAR.set(plur.toLowerCase(), plur);\n\n //singularizing\n INVERSE_IRREGULAR.set(plur.toLowerCase(), single);\n INVERSE_IRREGULAR.set(single.toLowerCase(), single);\n}\n\n/**\n * Marks a list of word pairs as irregular. Irregular words have unique\n * pluralization and singularization rules.\n *\n * @public\n * @param {Array<Array<String>>} irregularPairs\n * @return {void}\n * @since 4.13.0\n */\nexport function loadIrregular(irregularPairs: Array<[string, string]>) {\n irregularPairs.forEach((pair) => {\n //pluralizing\n IRREGULAR.set(pair[0].toLowerCase(), pair[1]);\n IRREGULAR.set(pair[1].toLowerCase(), pair[1]);\n\n //singularizing\n INVERSE_IRREGULAR.set(pair[1].toLowerCase(), pair[0]);\n INVERSE_IRREGULAR.set(pair[0].toLowerCase(), pair[0]);\n });\n}\nloadIrregular(defaultRules.irregularPairs);\n\n/**\n * Clears the caches for singularize and pluralize.\n *\n * @public\n * @return {void}\n * @since 4.13.0\n */\nexport function clear() {\n SINGULARS.clear();\n PLURALS.clear();\n}\n\n/**\n * Resets the inflection rules to the defaults.\n *\n * @public\n * @return {void}\n * @since 4.13.0\n */\nexport function resetToDefaults() {\n clearRules();\n defaultRules.uncountable.forEach((v) => UNCOUNTABLE.add(v));\n defaultRules.singular.forEach((v) => SINGULAR_RULES.set(v[0], v[1]));\n defaultRules.plurals.forEach((v) => PLURAL_RULES.set(v[0], v[1]));\n loadIrregular(defaultRules.irregularPairs);\n}\n\n/**\n * Clears all inflection rules\n * and resets the caches for singularize and pluralize.\n *\n * @public\n * @return {void}\n * @since 4.13.0\n */\nexport function clearRules() {\n SINGULARS.clear();\n PLURALS.clear();\n UNCOUNTABLE.clear();\n IRREGULAR.clear();\n INVERSE_IRREGULAR.clear();\n SINGULAR_RULES.clear();\n PLURAL_RULES.clear();\n}\n\n/**\n * Singularizes a word.\n *\n * @public\n * @param {String} word\n * @return {String}\n * @since 4.13.0\n */\nexport function singularize(word: string) {\n assert(`singularize expects to receive a non-empty string`, typeof word === 'string' && word.length > 0);\n if (!word) return '';\n return SINGULARS.get(word);\n}\n\n/**\n * Pluralizes a word.\n *\n * @public\n * @param {String} word\n * @return {String}\n * @since 4.13.0\n */\nexport function pluralize(word: string) {\n assert(`pluralize expects to receive a non-empty string`, typeof word === 'string' && word.length > 0);\n if (!word) return '';\n return PLURALS.get(word);\n}\n\nfunction unshiftMap<K, V>(v: [K, V], map: Map<K, V>) {\n // reorder\n const rules = [v, ...map.entries()];\n map.clear();\n rules.forEach((rule) => {\n map.set(rule[0], rule[1]);\n });\n}\n\n/**\n * Adds a pluralization rule.\n *\n * @public\n * @param {RegExp} regex\n * @param {String} string\n * @return {void}\n * @since 4.13.0\n */\nexport function plural(regex: RegExp, string: string) {\n // rule requires reordering if exists, so remove it first\n if (PLURAL_RULES.has(regex)) {\n PLURAL_RULES.delete(regex);\n }\n\n // reorder\n unshiftMap([regex, string], PLURAL_RULES);\n}\n\n/**\n * Adds a singularization rule.\n *\n * @public\n * @param {RegExp} regex\n * @param {String} string\n * @return {void}\n * @since 4.13.0\n */\nexport function singular(regex: RegExp, string: string) {\n // rule requires reordering if exists, so remove it first\n if (SINGULAR_RULES.has(regex)) {\n SINGULAR_RULES.delete(regex);\n }\n\n // reorder\n unshiftMap([regex, string], SINGULAR_RULES);\n}\n\nfunction _pluralize(word: string) {\n return inflect(word, PLURAL_RULES, IRREGULAR);\n}\n\nfunction _singularize(word: string) {\n return inflect(word, SINGULAR_RULES, INVERSE_IRREGULAR);\n}\n\nfunction inflect(word: string, typeRules: Map<RegExp, string>, irregulars: Map<string, string>) {\n // empty strings\n const isBlank = !word || BLANK_REGEX.test(word);\n if (isBlank) {\n return word;\n }\n\n // basic uncountables\n const lowercase = word.toLowerCase();\n if (UNCOUNTABLE.has(lowercase)) {\n return word;\n }\n\n // adv uncountables\n const wordSplit = LAST_WORD_DASHED_REGEX.exec(word) || LAST_WORD_CAMELIZED_REGEX.exec(word);\n const lastWord = wordSplit ? wordSplit[2].toLowerCase() : null;\n if (lastWord && UNCOUNTABLE.has(lastWord)) {\n return word;\n }\n\n // handle irregulars\n const isCamelized = CAMELIZED_REGEX.test(word);\n for (let [rule, substitution] of irregulars) {\n if (lowercase.match(rule + '$')) {\n if (isCamelized && lastWord && irregulars.has(lastWord)) {\n substitution = capitalize(substitution);\n rule = capitalize(rule);\n }\n\n return word.replace(new RegExp(rule, 'i'), substitution);\n }\n }\n\n // do the actual inflection\n for (const [rule, substitution] of typeRules) {\n if (rule.test(word)) {\n return word.replace(rule, substitution);\n }\n }\n\n return word;\n}\n"],"names":["DEFAULT_MAX_CACHE_SIZE","LRUCache","constructor","doWork","size","state","Map","get","key","value","delete","set","newValue","k","clear","STRING_DASHERIZE_REGEXP","STRING_DECAMELIZE_REGEXP","STRING_DASHERIZE_CACHE","replace","toLowerCase","dasherize","str","defaultRules","plurals","singular","irregularPairs","uncountable","STRING_CAMELIZE_REGEXP_1","STRING_CAMELIZE_REGEXP_2","CAMELIZE_CACHE","_match","_separator","chr","toUpperCase","match","STRING_UNDERSCORE_REGEXP_1","STRING_UNDERSCORE_REGEXP_2","UNDERSCORE_CACHE","STRING_CAPITALIZE_REGEXP","CAPITALIZE_CACHE","internalDasherize","camelize","underscore","capitalize","setMaxLRUCacheSize","BLANK_REGEX","LAST_WORD_DASHED_REGEX","LAST_WORD_CAMELIZED_REGEX","CAMELIZED_REGEX","SINGULARS","word","_singularize","PLURALS","_pluralize","UNCOUNTABLE","Set","IRREGULAR","INVERSE_IRREGULAR","SINGULAR_RULES","reverse","PLURAL_RULES","add","loadUncountable","uncountables","forEach","irregular","single","plur","loadIrregular","pair","resetToDefaults","clearRules","v","singularize","pluralize","unshiftMap","map","rules","entries","rule","plural","regex","string","has","inflect","typeRules","irregulars","isBlank","test","lowercase","wordSplit","exec","lastWord","isCamelized","substitution","RegExp"],"mappings":";;;;AACA,MAAMA,sBAAsB,GAAG,MAAM;;AAErC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,QAAQ,CAAC;AACb;;AAEAC,EAAAA,WAAWA,CAACC,MAAM,EAAEC,IAAI,EAAE;AACxB,IAAA,IAAI,CAACA,IAAI,GAAGA,IAAI,IAAIJ,sBAAsB;AAC1C,IAAA,IAAI,CAACK,KAAK,GAAG,IAAIC,GAAG,EAAE;IACtB,IAAI,CAACH,MAAM,GAAGA,MAAM;AAMtB;EACAI,GAAGA,CAACC,GAAG,EAAE;IACP,MAAMC,KAAK,GAAG,IAAI,CAACJ,KAAK,CAACE,GAAG,CAACC,GAAG,CAAC;AACjC,IAAA,IAAIC,KAAK,EAAE;AAIT,MAAA,IAAI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AI,GAAG,GAAG,CAAC,EAAE;MAC/B,IAAIc,WAAW,IAAID,QAAQ,IAAIN,UAAU,CAACH,GAAG,CAACS,QAAQ,CAAC,EAAE;AACvDE,QAAAA,YAAY,GAAGnD,UAAU,CAACmD,YAAY,CAAC;AACvCf,QAAAA,IAAI,GAAGpC,UAAU,CAACoC,IAAI,CAAC;AACzB;AAEA,MAAA,OAAO7B,IAAI,CAAChC,OAAO,CAAC,IAAI6E,MAAM,CAAChB,IAAI,EAAE,GAAG,CAAC,EAAEe,YAAY,CAAC;AAC1D;AACF;;AAEA;EACA,KAAK,MAAM,CAACf,IAAI,EAAEe,YAAY,CAAC,IAAIT,SAAS,EAAE;AAC5C,IAAA,IAAIN,IAAI,CAACS,IAAI,CAACtC,IAAI,CAAC,EAAE;AACnB,MAAA,OAAOA,IAAI,CAAChC,OAAO,CAAC6D,IAAI,EAAEe,YAAY,CAAC;AACzC;AACF;AAEA,EAAA,OAAO5C,IAAI;AACb;;;;;;;;;;;;;;;;;;;","x_google_ignoreList":[0]}
|
package/dist/string.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { g as camelize, h as capitalize, d as clear, e as clearRules, f as dasherize, i as irregular, l as loadIrregular, c as loadUncountable, b as plural, p as pluralize, r as resetToDefaults, k as setMaxLRUCacheSize, a as singular, s as singularize, u as uncountable, j as underscore } from "./inflect-
|
|
1
|
+
export { g as camelize, h as capitalize, d as clear, e as clearRules, f as dasherize, i as irregular, l as loadIrregular, c as loadUncountable, b as plural, p as pluralize, r as resetToDefaults, k as setMaxLRUCacheSize, a as singular, s as singularize, u as uncountable, j as underscore } from "./inflect-Dr20y6b1.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@warp-drive/utilities",
|
|
3
|
-
"version": "5.6.0-alpha.
|
|
3
|
+
"version": "5.6.0-alpha.12",
|
|
4
4
|
"description": "Utilities package for WarpDrive | Things your app might find useful",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ember-addon"
|
|
@@ -26,13 +26,17 @@
|
|
|
26
26
|
"types": "./declarations/index.d.ts",
|
|
27
27
|
"default": "./dist/index.js"
|
|
28
28
|
},
|
|
29
|
+
"./*.cjs": {
|
|
30
|
+
"types": "./declarations/*.d.ts",
|
|
31
|
+
"default": "./dist/*.cjs"
|
|
32
|
+
},
|
|
29
33
|
"./*": {
|
|
30
34
|
"types": "./declarations/*.d.ts",
|
|
31
35
|
"default": "./dist/*.js"
|
|
32
36
|
}
|
|
33
37
|
},
|
|
34
38
|
"peerDependencies": {
|
|
35
|
-
"@warp-drive/core": "5.6.0-alpha.
|
|
39
|
+
"@warp-drive/core": "5.6.0-alpha.12"
|
|
36
40
|
},
|
|
37
41
|
"dependencies": {
|
|
38
42
|
"@embroider/macros": "^1.16.12"
|
|
@@ -41,8 +45,8 @@
|
|
|
41
45
|
"@babel/core": "^7.26.10",
|
|
42
46
|
"@babel/plugin-transform-typescript": "^7.27.0",
|
|
43
47
|
"@babel/preset-typescript": "^7.27.0",
|
|
44
|
-
"@warp-drive/internal-config": "5.6.0-alpha.
|
|
45
|
-
"@warp-drive/core": "5.6.0-alpha.
|
|
48
|
+
"@warp-drive/internal-config": "5.6.0-alpha.12",
|
|
49
|
+
"@warp-drive/core": "5.6.0-alpha.12",
|
|
46
50
|
"decorator-transforms": "^2.3.0",
|
|
47
51
|
"expect-type": "^1.2.1",
|
|
48
52
|
"typescript": "^5.8.3",
|
|
@@ -60,7 +64,7 @@
|
|
|
60
64
|
"edition": "octane"
|
|
61
65
|
},
|
|
62
66
|
"scripts": {
|
|
63
|
-
"build:pkg": "vite build;",
|
|
67
|
+
"build:pkg": "vite build; vite build -c ./vite.config-cjs.mjs;",
|
|
64
68
|
"lint": "eslint . --quiet --cache --cache-strategy=content",
|
|
65
69
|
"sync": "echo \"syncing\"",
|
|
66
70
|
"start": "vite"
|