@ohos-ports/layer0-prefetch 4.20.0-beta.0 → 4.20.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/node_modules/@layer0/core/README.md +50 -0
- package/node_modules/@layer0/core/build.d.ts +5 -0
- package/node_modules/@layer0/core/build.js +17 -0
- package/node_modules/@layer0/core/cache/Cache.d.ts +56 -0
- package/node_modules/@layer0/core/cache/Cache.js +138 -0
- package/node_modules/@layer0/core/cache/CacheKey.d.ts +52 -0
- package/node_modules/@layer0/core/cache/CacheKey.js +95 -0
- package/node_modules/@layer0/core/config.d.ts +53 -0
- package/node_modules/@layer0/core/config.js +113 -0
- package/node_modules/@layer0/core/constants.d.ts +214 -0
- package/node_modules/@layer0/core/constants.js +216 -0
- package/node_modules/@layer0/core/context.d.ts +38 -0
- package/node_modules/@layer0/core/context.js +98 -0
- package/node_modules/@layer0/core/default-app/all/layer0.config.js +60 -0
- package/node_modules/@layer0/core/default-app/js/routes.js +27 -0
- package/node_modules/@layer0/core/default-app/ts/routes.ts +27 -0
- package/node_modules/@layer0/core/deploy/DeploymentBuilder.d.ts +177 -0
- package/node_modules/@layer0/core/deploy/DeploymentBuilder.js +543 -0
- package/node_modules/@layer0/core/deploy/bundle-esbuild.d.ts +11 -0
- package/node_modules/@layer0/core/deploy/bundle-esbuild.js +67 -0
- package/node_modules/@layer0/core/deploy/bundle-ncc.d.ts +8 -0
- package/node_modules/@layer0/core/deploy/bundle-ncc.js +30 -0
- package/node_modules/@layer0/core/deploy/bundle-nft.d.ts +7 -0
- package/node_modules/@layer0/core/deploy/bundle-nft.js +41 -0
- package/node_modules/@layer0/core/deploy/bundle-webpack.d.ts +11 -0
- package/node_modules/@layer0/core/deploy/bundle-webpack.js +127 -0
- package/node_modules/@layer0/core/deploy/index.d.ts +19 -0
- package/node_modules/@layer0/core/deploy/index.js +6 -0
- package/node_modules/@layer0/core/deploy/listSources.d.ts +11 -0
- package/node_modules/@layer0/core/deploy/listSources.js +18 -0
- package/node_modules/@layer0/core/deploy/paths.d.ts +27 -0
- package/node_modules/@layer0/core/deploy/paths.js +33 -0
- package/node_modules/@layer0/core/deploy/resolveInPackage.d.ts +7 -0
- package/node_modules/@layer0/core/deploy/resolveInPackage.js +21 -0
- package/node_modules/@layer0/core/deploy/routeToFiles.d.ts +14 -0
- package/node_modules/@layer0/core/deploy/routeToFiles.js +24 -0
- package/node_modules/@layer0/core/dev/DevServerOptions.d.ts +33 -0
- package/node_modules/@layer0/core/dev/DevServerOptions.js +2 -0
- package/node_modules/@layer0/core/dev/createDevServer.d.ts +8 -0
- package/node_modules/@layer0/core/dev/createDevServer.js +114 -0
- package/node_modules/@layer0/core/dev/index.d.ts +3 -0
- package/node_modules/@layer0/core/dev/index.js +6 -0
- package/node_modules/@layer0/core/dev/runLocalApp.d.ts +8 -0
- package/node_modules/@layer0/core/dev/runLocalApp.js +73 -0
- package/node_modules/@layer0/core/dev/serverlessCompatibilityMiddleware.d.ts +11 -0
- package/node_modules/@layer0/core/dev/serverlessCompatibilityMiddleware.js +30 -0
- package/node_modules/@layer0/core/edge/EdgeErrorPageResponseWriter.d.ts +12 -0
- package/node_modules/@layer0/core/edge/EdgeErrorPageResponseWriter.js +22 -0
- package/node_modules/@layer0/core/edge/EdgeResponseWriter.d.ts +122 -0
- package/node_modules/@layer0/core/edge/EdgeResponseWriter.js +451 -0
- package/node_modules/@layer0/core/edge/createEdgeConfig.d.ts +16 -0
- package/node_modules/@layer0/core/edge/createEdgeConfig.js +284 -0
- package/node_modules/@layer0/core/environment.d.ts +24 -0
- package/node_modules/@layer0/core/environment.js +42 -0
- package/node_modules/@layer0/core/errors/BackendFetchError.d.ts +11 -0
- package/node_modules/@layer0/core/errors/BackendFetchError.js +17 -0
- package/node_modules/@layer0/core/errors/FrameworkBuildError.d.ts +7 -0
- package/node_modules/@layer0/core/errors/FrameworkBuildError.js +26 -0
- package/node_modules/@layer0/core/index.d.ts +3 -0
- package/node_modules/@layer0/core/index.js +9 -0
- package/node_modules/@layer0/core/init/addToPackageJson.d.ts +7 -0
- package/node_modules/@layer0/core/init/addToPackageJson.js +22 -0
- package/node_modules/@layer0/core/init/index.d.ts +2 -0
- package/node_modules/@layer0/core/init/index.js +6 -0
- package/node_modules/@layer0/core/init/init.d.ts +5 -0
- package/node_modules/@layer0/core/init/init.js +17 -0
- package/node_modules/@layer0/core/lambda/JSBackend.d.ts +30 -0
- package/node_modules/@layer0/core/lambda/JSBackend.js +51 -0
- package/node_modules/@layer0/core/lambda/RequestListenerJSBackend.d.ts +8 -0
- package/node_modules/@layer0/core/lambda/RequestListenerJSBackend.js +19 -0
- package/node_modules/@layer0/core/lambda/adaptResponseEncodingToDownstream.d.ts +17 -0
- package/node_modules/@layer0/core/lambda/adaptResponseEncodingToDownstream.js +132 -0
- package/node_modules/@layer0/core/lambda/consoleWrapper.d.ts +16 -0
- package/node_modules/@layer0/core/lambda/consoleWrapper.js +127 -0
- package/node_modules/@layer0/core/lambda/getBodyLoggingData.d.ts +10 -0
- package/node_modules/@layer0/core/lambda/getBodyLoggingData.js +108 -0
- package/node_modules/@layer0/core/lambda/handler.d.ts +1 -0
- package/node_modules/@layer0/core/lambda/handler.js +91 -0
- package/node_modules/@layer0/core/lambda/handler.js.map +7 -0
- package/node_modules/@layer0/core/lambda/innerHandler.d.ts +7 -0
- package/node_modules/@layer0/core/lambda/innerHandler.js +181 -0
- package/node_modules/@layer0/core/lambda/lambdaInstance.d.ts +29 -0
- package/node_modules/@layer0/core/lambda/lambdaInstance.js +71 -0
- package/node_modules/@layer0/core/lambda/reqResMapper.d.ts +24 -0
- package/node_modules/@layer0/core/lambda/reqResMapper.js +286 -0
- package/node_modules/@layer0/core/lambda/stdStreamsWrapper.d.ts +31 -0
- package/node_modules/@layer0/core/lambda/stdStreamsWrapper.js +196 -0
- package/node_modules/@layer0/core/lambda/toJSBackend.d.ts +10 -0
- package/node_modules/@layer0/core/lambda/toJSBackend.js +23 -0
- package/node_modules/@layer0/core/node_modules/esbuild/LICENSE.md +21 -0
- package/node_modules/@layer0/core/node_modules/esbuild/README.md +3 -0
- package/node_modules/@layer0/core/node_modules/esbuild/bin/esbuild +223 -0
- package/node_modules/@layer0/core/node_modules/esbuild/install.js +301 -0
- package/node_modules/@layer0/core/node_modules/esbuild/lib/main.d.ts +716 -0
- package/node_modules/@layer0/core/node_modules/esbuild/lib/main.js +2532 -0
- package/node_modules/@layer0/core/node_modules/esbuild/node_modules/@ohos-ports/esbuild-openharmony-arm64/README.md +3 -0
- package/node_modules/@layer0/core/node_modules/esbuild/node_modules/@ohos-ports/esbuild-openharmony-arm64/bin/esbuild +0 -0
- package/node_modules/@layer0/core/node_modules/esbuild/node_modules/@ohos-ports/esbuild-openharmony-arm64/esbuild.wasm +0 -0
- package/node_modules/@layer0/core/node_modules/esbuild/node_modules/@ohos-ports/esbuild-openharmony-arm64/package.json +28 -0
- package/node_modules/@layer0/core/node_modules/esbuild/node_modules/@ohos-ports/esbuild-openharmony-arm64/wasm_exec.js +575 -0
- package/node_modules/@layer0/core/node_modules/esbuild/node_modules/@ohos-ports/esbuild-openharmony-arm64/wasm_exec_node.js +40 -0
- package/node_modules/@layer0/core/node_modules/esbuild/package.json +78 -0
- package/node_modules/@layer0/core/package.json +132 -0
- package/node_modules/@layer0/core/parser/parseRouter.d.ts +13 -0
- package/node_modules/@layer0/core/parser/parseRouter.js +77 -0
- package/node_modules/@layer0/core/plugins/PluginBase.d.ts +18 -0
- package/node_modules/@layer0/core/plugins/PluginBase.js +19 -0
- package/node_modules/@layer0/core/router/Backend.d.ts +69 -0
- package/node_modules/@layer0/core/router/Backend.js +176 -0
- package/node_modules/@layer0/core/router/BackendOptions.d.ts +11 -0
- package/node_modules/@layer0/core/router/BackendOptions.js +2 -0
- package/node_modules/@layer0/core/router/BaseResponseWriter.d.ts +65 -0
- package/node_modules/@layer0/core/router/BaseResponseWriter.js +81 -0
- package/node_modules/@layer0/core/router/BehindEdgeResponseWriterProxy.d.ts +4 -0
- package/node_modules/@layer0/core/router/BehindEdgeResponseWriterProxy.js +89 -0
- package/node_modules/@layer0/core/router/CacheManifest.d.ts +80 -0
- package/node_modules/@layer0/core/router/CacheManifest.js +83 -0
- package/node_modules/@layer0/core/router/CacheOptions.d.ts +171 -0
- package/node_modules/@layer0/core/router/CacheOptions.js +2 -0
- package/node_modules/@layer0/core/router/CustomCacheKey.d.ts +140 -0
- package/node_modules/@layer0/core/router/CustomCacheKey.js +272 -0
- package/node_modules/@layer0/core/router/GroupConfig.d.ts +7 -0
- package/node_modules/@layer0/core/router/GroupConfig.js +20 -0
- package/node_modules/@layer0/core/router/Groups.d.ts +7 -0
- package/node_modules/@layer0/core/router/Groups.js +21 -0
- package/node_modules/@layer0/core/router/Headers.d.ts +3 -0
- package/node_modules/@layer0/core/router/Headers.js +2 -0
- package/node_modules/@layer0/core/router/PathMatcher.d.ts +51 -0
- package/node_modules/@layer0/core/router/PathMatcher.js +73 -0
- package/node_modules/@layer0/core/router/Preload.d.ts +16 -0
- package/node_modules/@layer0/core/router/Preload.js +2 -0
- package/node_modules/@layer0/core/router/PreloadRequests.d.ts +23 -0
- package/node_modules/@layer0/core/router/PreloadRequests.js +66 -0
- package/node_modules/@layer0/core/router/Request.d.ts +74 -0
- package/node_modules/@layer0/core/router/Request.js +2 -0
- package/node_modules/@layer0/core/router/RequestContext.d.ts +12 -0
- package/node_modules/@layer0/core/router/RequestContext.js +11 -0
- package/node_modules/@layer0/core/router/Response.d.ts +55 -0
- package/node_modules/@layer0/core/router/Response.js +2 -0
- package/node_modules/@layer0/core/router/ResponseWriter.d.ts +1011 -0
- package/node_modules/@layer0/core/router/ResponseWriter.js +1341 -0
- package/node_modules/@layer0/core/router/Route.d.ts +124 -0
- package/node_modules/@layer0/core/router/Route.js +280 -0
- package/node_modules/@layer0/core/router/RouteCriteria.d.ts +68 -0
- package/node_modules/@layer0/core/router/RouteCriteria.js +2 -0
- package/node_modules/@layer0/core/router/RouteGroup.d.ts +157 -0
- package/node_modules/@layer0/core/router/RouteGroup.js +223 -0
- package/node_modules/@layer0/core/router/RouteGroupList.d.ts +45 -0
- package/node_modules/@layer0/core/router/RouteGroupList.js +73 -0
- package/node_modules/@layer0/core/router/Router.d.ts +439 -0
- package/node_modules/@layer0/core/router/Router.js +907 -0
- package/node_modules/@layer0/core/router/addBuiltInRoutes.d.ts +2 -0
- package/node_modules/@layer0/core/router/addBuiltInRoutes.js +58 -0
- package/node_modules/@layer0/core/router/addPreloadHeaders.d.ts +7 -0
- package/node_modules/@layer0/core/router/addPreloadHeaders.js +57 -0
- package/node_modules/@layer0/core/router/cacheManifestFromRouter.d.ts +6 -0
- package/node_modules/@layer0/core/router/cacheManifestFromRouter.js +85 -0
- package/node_modules/@layer0/core/router/createCustomCacheKey.d.ts +27 -0
- package/node_modules/@layer0/core/router/createCustomCacheKey.js +35 -0
- package/node_modules/@layer0/core/router/deriveSurrogateKeysFromJson.d.ts +36 -0
- package/node_modules/@layer0/core/router/deriveSurrogateKeysFromJson.js +70 -0
- package/node_modules/@layer0/core/router/index.d.ts +11 -0
- package/node_modules/@layer0/core/router/index.js +17 -0
- package/node_modules/@layer0/core/router/interpolateParams.d.ts +21 -0
- package/node_modules/@layer0/core/router/interpolateParams.js +150 -0
- package/node_modules/@layer0/core/router/loadRouter.d.ts +13 -0
- package/node_modules/@layer0/core/router/loadRouter.js +29 -0
- package/node_modules/@layer0/core/router/mergeQueryString.d.ts +1 -0
- package/node_modules/@layer0/core/router/mergeQueryString.js +23 -0
- package/node_modules/@layer0/core/router/normalizeCriteria.d.ts +6 -0
- package/node_modules/@layer0/core/router/normalizeCriteria.js +20 -0
- package/node_modules/@layer0/core/router/stream.d.ts +12 -0
- package/node_modules/@layer0/core/router/stream.js +30 -0
- package/node_modules/@layer0/core/router/universalRouteUtils.d.ts +55 -0
- package/node_modules/@layer0/core/router/universalRouteUtils.js +114 -0
- package/node_modules/@layer0/core/router/validateWriter.d.ts +41 -0
- package/node_modules/@layer0/core/router/validateWriter.js +120 -0
- package/node_modules/@layer0/core/serverless.yml +30 -0
- package/node_modules/@layer0/core/source.d.ts +9 -0
- package/node_modules/@layer0/core/source.js +17 -0
- package/node_modules/@layer0/core/test-utils/MockRequest.d.ts +15 -0
- package/node_modules/@layer0/core/test-utils/MockRequest.js +36 -0
- package/node_modules/@layer0/core/test-utils/MockResponse.d.ts +7 -0
- package/node_modules/@layer0/core/test-utils/MockResponse.js +24 -0
- package/node_modules/@layer0/core/test-utils/expect-extend.d.ts +1 -0
- package/node_modules/@layer0/core/test-utils/expect-extend.js +11 -0
- package/node_modules/@layer0/core/test-utils/index.d.ts +4 -0
- package/node_modules/@layer0/core/test-utils/index.js +11 -0
- package/node_modules/@layer0/core/test-utils/matchers/toBeCachedByTheBrowser.d.ts +19 -0
- package/node_modules/@layer0/core/test-utils/matchers/toBeCachedByTheBrowser.js +45 -0
- package/node_modules/@layer0/core/test-utils/matchers/toBeCachedByTheEdge.d.ts +19 -0
- package/node_modules/@layer0/core/test-utils/matchers/toBeCachedByTheEdge.js +38 -0
- package/node_modules/@layer0/core/test-utils/matchers/toBeCachedByTheServiceWorker.d.ts +19 -0
- package/node_modules/@layer0/core/test-utils/matchers/toBeCachedByTheServiceWorker.js +45 -0
- package/node_modules/@layer0/core/test-utils/matchers/toBeServedStale.d.ts +20 -0
- package/node_modules/@layer0/core/test-utils/matchers/toBeServedStale.js +50 -0
- package/node_modules/@layer0/core/test-utils/matchers/toHaveBody.d.ts +18 -0
- package/node_modules/@layer0/core/test-utils/matchers/toHaveBody.js +40 -0
- package/node_modules/@layer0/core/test-utils/matchers/toHaveHeader.d.ts +19 -0
- package/node_modules/@layer0/core/test-utils/matchers/toHaveHeader.js +43 -0
- package/node_modules/@layer0/core/test-utils/matchers.d.ts +6 -0
- package/node_modules/@layer0/core/test-utils/matchers.js +18 -0
- package/node_modules/@layer0/core/test-utils/utils/createRouteMock.d.ts +21 -0
- package/node_modules/@layer0/core/test-utils/utils/createRouteMock.js +27 -0
- package/node_modules/@layer0/core/test-utils/utils/getBackend.d.ts +13 -0
- package/node_modules/@layer0/core/test-utils/utils/getBackend.js +30 -0
- package/node_modules/@layer0/core/test-utils/utils/getMessage.d.ts +1 -0
- package/node_modules/@layer0/core/test-utils/utils/getMessage.js +16 -0
- package/node_modules/@layer0/core/test-utils/utils/runRoute.d.ts +10 -0
- package/node_modules/@layer0/core/test-utils/utils/runRoute.js +39 -0
- package/node_modules/@layer0/core/timing.d.ts +115 -0
- package/node_modules/@layer0/core/timing.js +200 -0
- package/node_modules/@layer0/core/transform/index.d.ts +1 -0
- package/node_modules/@layer0/core/transform/index.js +4 -0
- package/node_modules/@layer0/core/transform/transformMethod.d.ts +40 -0
- package/node_modules/@layer0/core/transform/transformMethod.js +58 -0
- package/node_modules/@layer0/core/types.d.ts +102 -0
- package/node_modules/@layer0/core/types.js +30 -0
- package/node_modules/@layer0/core/utils/Tasks.d.ts +32 -0
- package/node_modules/@layer0/core/utils/Tasks.js +80 -0
- package/node_modules/@layer0/core/utils/Validator.d.ts +18 -0
- package/node_modules/@layer0/core/utils/Validator.js +178 -0
- package/node_modules/@layer0/core/utils/bindParamsToPath.d.ts +15 -0
- package/node_modules/@layer0/core/utils/bindParamsToPath.js +49 -0
- package/node_modules/@layer0/core/utils/convertParamsToBackReferences.d.ts +16 -0
- package/node_modules/@layer0/core/utils/convertParamsToBackReferences.js +45 -0
- package/node_modules/@layer0/core/utils/convertStringMatcherToRegex.d.ts +7 -0
- package/node_modules/@layer0/core/utils/convertStringMatcherToRegex.js +26 -0
- package/node_modules/@layer0/core/utils/decode.d.ts +9 -0
- package/node_modules/@layer0/core/utils/decode.js +44 -0
- package/node_modules/@layer0/core/utils/esImport.d.ts +1 -0
- package/node_modules/@layer0/core/utils/esImport.js +9 -0
- package/node_modules/@layer0/core/utils/fs.d.ts +1 -0
- package/node_modules/@layer0/core/utils/fs.js +7 -0
- package/node_modules/@layer0/core/utils/get.d.ts +6 -0
- package/node_modules/@layer0/core/utils/get.js +19 -0
- package/node_modules/@layer0/core/utils/getPackageVersion.d.ts +7 -0
- package/node_modules/@layer0/core/utils/getPackageVersion.js +19 -0
- package/node_modules/@layer0/core/utils/has.d.ts +6 -0
- package/node_modules/@layer0/core/utils/has.js +15 -0
- package/node_modules/@layer0/core/utils/identity.d.ts +7 -0
- package/node_modules/@layer0/core/utils/identity.js +12 -0
- package/node_modules/@layer0/core/utils/index.d.ts +1 -0
- package/node_modules/@layer0/core/utils/index.js +4 -0
- package/node_modules/@layer0/core/utils/isEmpty.d.ts +6 -0
- package/node_modules/@layer0/core/utils/isEmpty.js +20 -0
- package/node_modules/@layer0/core/utils/isString.d.ts +1 -0
- package/node_modules/@layer0/core/utils/isString.js +6 -0
- package/node_modules/@layer0/core/utils/logo.d.ts +5 -0
- package/node_modules/@layer0/core/utils/logo.js +27 -0
- package/node_modules/@layer0/core/utils/mapValues.d.ts +7 -0
- package/node_modules/@layer0/core/utils/mapValues.js +16 -0
- package/node_modules/@layer0/core/utils/minBy.d.ts +8 -0
- package/node_modules/@layer0/core/utils/minBy.js +41 -0
- package/node_modules/@layer0/core/utils/nonWebpackRequire.d.ts +11 -0
- package/node_modules/@layer0/core/utils/nonWebpackRequire.js +28 -0
- package/node_modules/@layer0/core/utils/packageUtils.d.ts +12 -0
- package/node_modules/@layer0/core/utils/packageUtils.js +22 -0
- package/node_modules/@layer0/core/utils/ports.d.ts +5 -0
- package/node_modules/@layer0/core/utils/ports.js +7 -0
- package/node_modules/@layer0/core/utils/readBody.d.ts +7 -0
- package/node_modules/@layer0/core/utils/readBody.js +15 -0
- package/node_modules/@layer0/core/utils/readRawBody.d.ts +9 -0
- package/node_modules/@layer0/core/utils/readRawBody.js +21 -0
- package/node_modules/@layer0/core/utils/regExpEscape.d.ts +12 -0
- package/node_modules/@layer0/core/utils/regExpEscape.js +20 -0
- package/node_modules/@layer0/core/utils/requireInternal.d.ts +7 -0
- package/node_modules/@layer0/core/utils/requireInternal.js +24 -0
- package/node_modules/@layer0/core/utils/set.d.ts +10 -0
- package/node_modules/@layer0/core/utils/set.js +21 -0
- package/node_modules/@layer0/core/utils/toEdgeRegex.d.ts +11 -0
- package/node_modules/@layer0/core/utils/toEdgeRegex.js +23 -0
- package/node_modules/@layer0/core/utils/toHttpMethodMatchRegex.d.ts +12 -0
- package/node_modules/@layer0/core/utils/toHttpMethodMatchRegex.js +17 -0
- package/node_modules/@layer0/core/utils/toLower.d.ts +1 -0
- package/node_modules/@layer0/core/utils/toLower.js +9 -0
- package/node_modules/@layer0/core/utils/validateBackends.d.ts +5 -0
- package/node_modules/@layer0/core/utils/validateBackends.js +30 -0
- package/node_modules/@layer0/core/utils/watch.d.ts +10 -0
- package/node_modules/@layer0/core/utils/watch.js +17 -0
- package/package.json +47 -3
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
/**
|
|
4
|
+
* `minBy` function instead of importing lodash.
|
|
5
|
+
*
|
|
6
|
+
* Note that this function is not entirely equivalent to lodash's but it uses far less space in the bundle.
|
|
7
|
+
*
|
|
8
|
+
* @param collection Array of items of type T
|
|
9
|
+
*/
|
|
10
|
+
function minBy(collection, iteratee) {
|
|
11
|
+
if (!collection || !collection.length) {
|
|
12
|
+
return undefined;
|
|
13
|
+
}
|
|
14
|
+
let min;
|
|
15
|
+
let minIterateeValue;
|
|
16
|
+
let minIterateeAssigned = false;
|
|
17
|
+
for (let item of collection) {
|
|
18
|
+
if (!minIterateeAssigned) {
|
|
19
|
+
min = item;
|
|
20
|
+
if (iteratee) {
|
|
21
|
+
minIterateeValue = iteratee(item);
|
|
22
|
+
}
|
|
23
|
+
minIterateeAssigned = true;
|
|
24
|
+
continue;
|
|
25
|
+
}
|
|
26
|
+
if (iteratee) {
|
|
27
|
+
const iterateeValue = iteratee(item);
|
|
28
|
+
if (iterateeValue < minIterateeValue) {
|
|
29
|
+
min = item;
|
|
30
|
+
minIterateeValue = iterateeValue;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
if (item < min) {
|
|
35
|
+
min = item;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return min;
|
|
40
|
+
}
|
|
41
|
+
exports.default = minBy;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Loads a module at runtime, ensuring that it won't be bundled by webpack. This function
|
|
3
|
+
* also ensures proper behavior on windows, *nix, and macos filesystems, even if the module
|
|
4
|
+
* path is derived from a file path with backslashes. This function will return undefined if
|
|
5
|
+
* the module could not be loaded.
|
|
6
|
+
* @param modulePath The path to the module to load
|
|
7
|
+
* @param options.ignoreErrors Will return undefined if the module fails to load
|
|
8
|
+
*/
|
|
9
|
+
export default function nonWebpackRequire(modulePath: string, { ignoreErrors }?: {
|
|
10
|
+
ignoreErrors?: boolean;
|
|
11
|
+
}): any;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const slash_1 = __importDefault(require("slash"));
|
|
7
|
+
/**
|
|
8
|
+
* Loads a module at runtime, ensuring that it won't be bundled by webpack. This function
|
|
9
|
+
* also ensures proper behavior on windows, *nix, and macos filesystems, even if the module
|
|
10
|
+
* path is derived from a file path with backslashes. This function will return undefined if
|
|
11
|
+
* the module could not be loaded.
|
|
12
|
+
* @param modulePath The path to the module to load
|
|
13
|
+
* @param options.ignoreErrors Will return undefined if the module fails to load
|
|
14
|
+
*/
|
|
15
|
+
function nonWebpackRequire(modulePath, { ignoreErrors = false } = {}) {
|
|
16
|
+
try {
|
|
17
|
+
return eval('require')(slash_1.default(modulePath));
|
|
18
|
+
}
|
|
19
|
+
catch (e) {
|
|
20
|
+
if (ignoreErrors) {
|
|
21
|
+
return undefined;
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
throw e;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
exports.default = nonWebpackRequire;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Read in the contents of package.json
|
|
3
|
+
* @param [path=package.json] Relative path to the resouce
|
|
4
|
+
* @return {Object}
|
|
5
|
+
*/
|
|
6
|
+
export declare function read(path?: string): any;
|
|
7
|
+
/**
|
|
8
|
+
* Writes the contents to package.json
|
|
9
|
+
* @param contents
|
|
10
|
+
* @param [path='package.json'] Relative path to the resouce
|
|
11
|
+
*/
|
|
12
|
+
export declare function write(contents: string, path?: string): void;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const path_1 = require("path");
|
|
4
|
+
const fs_1 = require("./fs");
|
|
5
|
+
/**
|
|
6
|
+
* Read in the contents of package.json
|
|
7
|
+
* @param [path=package.json] Relative path to the resouce
|
|
8
|
+
* @return {Object}
|
|
9
|
+
*/
|
|
10
|
+
function read(path = 'package.json') {
|
|
11
|
+
return JSON.parse(fs_1.readFileSync(path_1.join(process.cwd(), path), 'utf8'));
|
|
12
|
+
}
|
|
13
|
+
exports.read = read;
|
|
14
|
+
/**
|
|
15
|
+
* Writes the contents to package.json
|
|
16
|
+
* @param contents
|
|
17
|
+
* @param [path='package.json'] Relative path to the resouce
|
|
18
|
+
*/
|
|
19
|
+
function write(contents, path = 'package.json') {
|
|
20
|
+
fs_1.writeFileSync(path_1.join(process.cwd(), path), contents, 'utf8');
|
|
21
|
+
}
|
|
22
|
+
exports.write = write;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.port = Number(process.env.PORT) || 3000;
|
|
4
|
+
exports.jsPort = exports.port + 1;
|
|
5
|
+
exports.assetPort = exports.port + 2;
|
|
6
|
+
exports.localhost = '127.0.0.1';
|
|
7
|
+
exports.localhostWithPort = `${exports.localhost}:${exports.port}`;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
/**
|
|
4
|
+
* Reads the request body and adds it to request.body
|
|
5
|
+
* @param req
|
|
6
|
+
* @return {Promise}
|
|
7
|
+
*/
|
|
8
|
+
function readBody(req) {
|
|
9
|
+
return new Promise(resolve => {
|
|
10
|
+
req.body = '';
|
|
11
|
+
req.on('data', (chunk) => (req.body += chunk.toString()));
|
|
12
|
+
req.on('end', resolve);
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
exports.default = readBody;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import Request from '../router/Request';
|
|
3
|
+
/**
|
|
4
|
+
* Reads the request body and returns it. It can only be used once per request.
|
|
5
|
+
*
|
|
6
|
+
* @param req
|
|
7
|
+
* @return {Promise<Buffer>}
|
|
8
|
+
*/
|
|
9
|
+
export default function readRawBody(req: Request): Promise<Buffer>;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
/**
|
|
4
|
+
* Reads the request body and returns it. It can only be used once per request.
|
|
5
|
+
*
|
|
6
|
+
* @param req
|
|
7
|
+
* @return {Promise<Buffer>}
|
|
8
|
+
*/
|
|
9
|
+
function readRawBody(req) {
|
|
10
|
+
return new Promise((resolve, reject) => {
|
|
11
|
+
const chunks = [];
|
|
12
|
+
req.on('data', (chunk) => chunk && chunks.push(chunk));
|
|
13
|
+
req.on('end', () => {
|
|
14
|
+
resolve(Buffer.concat(chunks));
|
|
15
|
+
});
|
|
16
|
+
req.on('abort', (e) => {
|
|
17
|
+
reject(e);
|
|
18
|
+
});
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
exports.default = readRawBody;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Escapes a string to be compatible with a RegExp
|
|
3
|
+
* @param string
|
|
4
|
+
* @returns {String}
|
|
5
|
+
*/
|
|
6
|
+
export default function regExpEscape(string: string): string;
|
|
7
|
+
/**
|
|
8
|
+
* Converts the given string into a RegExp
|
|
9
|
+
* @param string
|
|
10
|
+
* @returns {RegExp}
|
|
11
|
+
*/
|
|
12
|
+
export declare function toRegExp(string: string): RegExp;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
/**
|
|
4
|
+
* Escapes a string to be compatible with a RegExp
|
|
5
|
+
* @param string
|
|
6
|
+
* @returns {String}
|
|
7
|
+
*/
|
|
8
|
+
function regExpEscape(string) {
|
|
9
|
+
return string.replace(/[-/\\^$*+?.()|[\]{}]/g, '\\$&');
|
|
10
|
+
}
|
|
11
|
+
exports.default = regExpEscape;
|
|
12
|
+
/**
|
|
13
|
+
* Converts the given string into a RegExp
|
|
14
|
+
* @param string
|
|
15
|
+
* @returns {RegExp}
|
|
16
|
+
*/
|
|
17
|
+
function toRegExp(string) {
|
|
18
|
+
return new RegExp(regExpEscape(string));
|
|
19
|
+
}
|
|
20
|
+
exports.toRegExp = toRegExp;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Dynamically requires the version of a package listed in @layer0/core's depedencies
|
|
3
|
+
* This allows us to ensure we are targeting the version of a package, such as globby, that is listed
|
|
4
|
+
* in @layer0/core's package.json, as opposed to whatever version may or may not be included in the user's
|
|
5
|
+
* app, which may not be compatible.
|
|
6
|
+
*/
|
|
7
|
+
export default function requireInternal(packagePath: string): any;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const nonWebpackRequire_1 = __importDefault(require("./nonWebpackRequire"));
|
|
7
|
+
/**
|
|
8
|
+
* Dynamically requires the version of a package listed in @layer0/core's depedencies
|
|
9
|
+
* This allows us to ensure we are targeting the version of a package, such as globby, that is listed
|
|
10
|
+
* in @layer0/core's package.json, as opposed to whatever version may or may not be included in the user's
|
|
11
|
+
* app, which may not be compatible.
|
|
12
|
+
*/
|
|
13
|
+
function requireInternal(packagePath) {
|
|
14
|
+
try {
|
|
15
|
+
const resolved = require.resolve(packagePath, {
|
|
16
|
+
paths: [require.resolve('@layer0/core')],
|
|
17
|
+
});
|
|
18
|
+
return nonWebpackRequire_1.default(resolved);
|
|
19
|
+
}
|
|
20
|
+
catch (e) {
|
|
21
|
+
return nonWebpackRequire_1.default(packagePath);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
exports.default = requireInternal;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `set` function instead of importing lodash.
|
|
3
|
+
*
|
|
4
|
+
* Note that this function is not entirely equivalent to lodash's but it uses far less space in the bundle.
|
|
5
|
+
*/
|
|
6
|
+
export default function set(object: {
|
|
7
|
+
[key: string]: any;
|
|
8
|
+
}, path: string, value: any): {
|
|
9
|
+
[key: string]: any;
|
|
10
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
/**
|
|
4
|
+
* `set` function instead of importing lodash.
|
|
5
|
+
*
|
|
6
|
+
* Note that this function is not entirely equivalent to lodash's but it uses far less space in the bundle.
|
|
7
|
+
*/
|
|
8
|
+
function set(object, path, value) {
|
|
9
|
+
const components = path.split('.');
|
|
10
|
+
let subObject = object;
|
|
11
|
+
for (let i = 0; i < components.length - 1; ++i) {
|
|
12
|
+
const component = components[i];
|
|
13
|
+
if (typeof subObject[component] !== 'object') {
|
|
14
|
+
subObject[component] = {};
|
|
15
|
+
}
|
|
16
|
+
subObject = subObject[component];
|
|
17
|
+
}
|
|
18
|
+
subObject[components.pop()] = value;
|
|
19
|
+
return object;
|
|
20
|
+
}
|
|
21
|
+
exports.default = set;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Converts a JavaScript Regexp instance to a string compatible with edge.
|
|
3
|
+
* See https://docs.fastly.com/en/guides/vcl-regular-expression-cheat-sheet
|
|
4
|
+
* @param regex
|
|
5
|
+
*/
|
|
6
|
+
export default function toEdgeRegex(regex: RegExp): string;
|
|
7
|
+
/**
|
|
8
|
+
* Reverse transformation. Mostly used for unit tests.
|
|
9
|
+
* @param edgeRegex
|
|
10
|
+
*/
|
|
11
|
+
export declare function fromEdgeRegex(edgeRegex: string): RegExp;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
/**
|
|
4
|
+
* Converts a JavaScript Regexp instance to a string compatible with edge.
|
|
5
|
+
* See https://docs.fastly.com/en/guides/vcl-regular-expression-cheat-sheet
|
|
6
|
+
* @param regex
|
|
7
|
+
*/
|
|
8
|
+
function toEdgeRegex(regex) {
|
|
9
|
+
return `${regex.ignoreCase ? '(?i)' : ''}${regex.source}`.replace(/\\\//g, '/');
|
|
10
|
+
}
|
|
11
|
+
exports.default = toEdgeRegex;
|
|
12
|
+
/**
|
|
13
|
+
* Reverse transformation. Mostly used for unit tests.
|
|
14
|
+
* @param edgeRegex
|
|
15
|
+
*/
|
|
16
|
+
function fromEdgeRegex(edgeRegex) {
|
|
17
|
+
const ignoreCase = edgeRegex.indexOf('(?i)') === 0;
|
|
18
|
+
if (ignoreCase) {
|
|
19
|
+
edgeRegex = edgeRegex.slice('(?i)'.length);
|
|
20
|
+
}
|
|
21
|
+
return new RegExp(edgeRegex.replace(/\//g, '/'), ignoreCase ? 'i' : '');
|
|
22
|
+
}
|
|
23
|
+
exports.fromEdgeRegex = fromEdgeRegex;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Converts an HTTP method name to RegExp that it matches in case-insensitive manner.
|
|
3
|
+
*
|
|
4
|
+
* Notes:
|
|
5
|
+
* - We use this in both cloud router and edge router to ensure that we can identify
|
|
6
|
+
* explicit POST matching (which in turn we need to only turn on POST caching when
|
|
7
|
+
* explicitly configured)
|
|
8
|
+
*
|
|
9
|
+
* @param method
|
|
10
|
+
* @private
|
|
11
|
+
*/
|
|
12
|
+
export default function toHttpMethodMatchRegex(method: string): RegExp;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
/**
|
|
4
|
+
* Converts an HTTP method name to RegExp that it matches in case-insensitive manner.
|
|
5
|
+
*
|
|
6
|
+
* Notes:
|
|
7
|
+
* - We use this in both cloud router and edge router to ensure that we can identify
|
|
8
|
+
* explicit POST matching (which in turn we need to only turn on POST caching when
|
|
9
|
+
* explicitly configured)
|
|
10
|
+
*
|
|
11
|
+
* @param method
|
|
12
|
+
* @private
|
|
13
|
+
*/
|
|
14
|
+
function toHttpMethodMatchRegex(method) {
|
|
15
|
+
return new RegExp(`^${method}$`, 'i');
|
|
16
|
+
}
|
|
17
|
+
exports.default = toHttpMethodMatchRegex;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function toLower(str: string): string;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const os_1 = require("os");
|
|
7
|
+
const constants_1 = require("../constants");
|
|
8
|
+
const config_1 = __importDefault(require("../config"));
|
|
9
|
+
/**
|
|
10
|
+
* Validates if provided backend exists in the config
|
|
11
|
+
* @param backend
|
|
12
|
+
*/
|
|
13
|
+
function validateBackends(backend) {
|
|
14
|
+
if (Object.values(constants_1.BACKENDS).includes(backend)) {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
if (config_1.default.get(`backends.${backend}`, false)) {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
const backends = Object.keys(config_1.default.get('backends'));
|
|
21
|
+
if (backends && backends.length) {
|
|
22
|
+
throw new Error(`To fix this problem use one of the "backends" configured in layer0.config.js:${os_1.EOL}${os_1.EOL}` +
|
|
23
|
+
` - ${backends.join(`${os_1.EOL} - `)}${os_1.EOL}${os_1.EOL}` +
|
|
24
|
+
`or add "${backend}" to the "backends" property in layer0.config.js.`);
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
throw new Error(`Add "${backend}" to the "backends" property in layer0.config.js.`);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
exports.default = validateBackends;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { WatchOptions } from 'chokidar';
|
|
2
|
+
/**
|
|
3
|
+
* Loads a module at runtime, ensuring that it won't be bundled by webpack. This function
|
|
4
|
+
* also ensures proper behavior on windows, *nix, and macos filesystems, even if the module
|
|
5
|
+
* path is derived from a file path with backslashes. This function will return undefined if
|
|
6
|
+
* the module could not be loaded.
|
|
7
|
+
* @param modulePath The path to the module to load
|
|
8
|
+
* @param options.ignoreErrors Will return undefined if the module fails to load
|
|
9
|
+
*/
|
|
10
|
+
export default function watch(paths: string | ReadonlyArray<string>, options?: WatchOptions): any;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* istanbul ignore file */
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
const _1 = require(".");
|
|
5
|
+
/**
|
|
6
|
+
* Loads a module at runtime, ensuring that it won't be bundled by webpack. This function
|
|
7
|
+
* also ensures proper behavior on windows, *nix, and macos filesystems, even if the module
|
|
8
|
+
* path is derived from a file path with backslashes. This function will return undefined if
|
|
9
|
+
* the module could not be loaded.
|
|
10
|
+
* @param modulePath The path to the module to load
|
|
11
|
+
* @param options.ignoreErrors Will return undefined if the module fails to load
|
|
12
|
+
*/
|
|
13
|
+
function watch(paths, options) {
|
|
14
|
+
const chokidar = _1.nonWebpackRequire('chokidar');
|
|
15
|
+
return chokidar.watch(paths, options);
|
|
16
|
+
}
|
|
17
|
+
exports.default = watch;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ohos-ports/layer0-prefetch",
|
|
3
|
-
"version": "4.20.0-beta.
|
|
3
|
+
"version": "4.20.0-beta.1",
|
|
4
4
|
"description": "Enables prefetching and caching of pages using Layer0 and Workbox.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"directories": {
|
|
@@ -15,7 +15,40 @@
|
|
|
15
15
|
"workbox-expiration": "^5.1.2",
|
|
16
16
|
"workbox-precaching": "^5.1.4",
|
|
17
17
|
"workbox-routing": "^5.1.2",
|
|
18
|
-
"workbox-strategies": "^5.1.2"
|
|
18
|
+
"workbox-strategies": "^5.1.2",
|
|
19
|
+
"@babel/parser": "^7.18.9",
|
|
20
|
+
"@babel/traverse": "^7.18.9",
|
|
21
|
+
"@types/lodash.clonedeep": "^4.5.6",
|
|
22
|
+
"ajv": "^6.12.6",
|
|
23
|
+
"babel-loader": "^8.2.2",
|
|
24
|
+
"chalk": "^4.1.2",
|
|
25
|
+
"chardet": "^1.4.0",
|
|
26
|
+
"chokidar": "^3.5.1",
|
|
27
|
+
"cls-hooked": "^4.2.2",
|
|
28
|
+
"content-type": "^1.0.4",
|
|
29
|
+
"cookie": "^0.4.1",
|
|
30
|
+
"cross-spawn": "^7.0.3",
|
|
31
|
+
"decode-uri-component": "^0.2.0",
|
|
32
|
+
"deepmerge": "^4.2.2",
|
|
33
|
+
"express": "^4.17.1",
|
|
34
|
+
"fs-extra": "^8.1.0",
|
|
35
|
+
"globby": "^11.0.2",
|
|
36
|
+
"http-proxy": "^1.18.1",
|
|
37
|
+
"lodash.clonedeep": "^4.5.0",
|
|
38
|
+
"lru-cache": "^6.0.0",
|
|
39
|
+
"mime-types": "^2.1.35",
|
|
40
|
+
"node-fetch": "^2.6.1",
|
|
41
|
+
"path-to-regexp": "^6.2.0",
|
|
42
|
+
"pino": "^6.13.3",
|
|
43
|
+
"qs": "^6.10.1",
|
|
44
|
+
"resolve-package-path": "^4.0.3",
|
|
45
|
+
"semver": "^7.3.5",
|
|
46
|
+
"shelljs": "^0.8.5",
|
|
47
|
+
"slash": "^3.0.0",
|
|
48
|
+
"tcp-port-used": "^1.0.2",
|
|
49
|
+
"ts-loader": "^8.2.0",
|
|
50
|
+
"unixify": "^1.0.0",
|
|
51
|
+
"uuid": "^8.3.2"
|
|
19
52
|
},
|
|
20
53
|
"devDependencies": {
|
|
21
54
|
"@types/cheerio": "0.22.18",
|
|
@@ -46,5 +79,16 @@
|
|
|
46
79
|
"sw/",
|
|
47
80
|
"window/",
|
|
48
81
|
"README.md"
|
|
49
|
-
]
|
|
82
|
+
],
|
|
83
|
+
"overrides": {
|
|
84
|
+
"esbuild": "npm:@ohos-ports/esbuild@0.28.1-beta.2"
|
|
85
|
+
},
|
|
86
|
+
"bundleDependencies": [
|
|
87
|
+
"@layer0/core"
|
|
88
|
+
],
|
|
89
|
+
"peerDependenciesMeta": {
|
|
90
|
+
"@layer0/devtools": {
|
|
91
|
+
"optional": true
|
|
92
|
+
}
|
|
93
|
+
}
|
|
50
94
|
}
|