@toddledev/core
Advanced tools
Comparing version 0.0.2-alpha.1 to 0.0.2-alpha.2
@@ -32,3 +32,3 @@ import { Formula, FormulaContext } from '../formula/formula'; | ||
*/ | ||
export declare const requestHash: (url: URL, request: RequestInit) => Promise<string>; | ||
export declare const requestHash: (url: URL, request: RequestInit) => number; | ||
export declare const isApiError: ({ apiName, response, formulaContext, errorFormula, performance, }: { | ||
@@ -49,1 +49,3 @@ apiName: string; | ||
export declare const createApiEvent: (eventName: "message" | "success" | "failed", detail: any) => CustomEvent<any>; | ||
export declare const sortApiObjects: (apis: Array<[string, ComponentAPI]>) => [string, ComponentAPI][]; | ||
export declare const sortApiEntries: (apis: Array<[string, LegacyToddleApi | ToddleApiV2]>) => [string, LegacyToddleApi | ToddleApiV2][]; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.createApiEvent = exports.isApiError = exports.requestHash = exports.getBaseUrl = exports.getRequestHeaders = exports.getRequestQueryParams = exports.getRequestPath = exports.applyAbortSignal = exports.getUrl = exports.createApiRequest = exports.isLegacyApi = exports.NON_BODY_RESPONSE_CODES = void 0; | ||
exports.sortApiEntries = exports.sortApiObjects = exports.createApiEvent = exports.isApiError = exports.requestHash = exports.getBaseUrl = exports.getRequestHeaders = exports.getRequestQueryParams = exports.getRequestPath = exports.applyAbortSignal = exports.getUrl = exports.createApiRequest = exports.isLegacyApi = exports.NON_BODY_RESPONSE_CODES = void 0; | ||
const collections_1 = require("@toddle/core/src/utils/collections"); | ||
const util_1 = require("@toddle/core/src/utils/util"); | ||
const formula_1 = require("../formula/formula"); | ||
const collections_1 = require("../utils/collections"); | ||
const sha1_1 = require("../utils/sha1"); | ||
const util_1 = require("../utils/util"); | ||
const hash_1 = require("../utils/hash"); | ||
const apiTypes_1 = require("./apiTypes"); | ||
const LegacyToddleApi_1 = require("./LegacyToddleApi"); | ||
const ToddleApiV2_1 = require("./ToddleApiV2"); | ||
exports.NON_BODY_RESPONSE_CODES = [101, 204, 205, 304]; | ||
@@ -136,3 +137,3 @@ const isLegacyApi = (api) => api instanceof LegacyToddleApi_1.LegacyToddleApi ? true : !('version' in api); | ||
*/ | ||
const requestHash = (url, request) => (0, sha1_1.sha1)(JSON.stringify({ | ||
const requestHash = (url, request) => (0, hash_1.hash)(JSON.stringify({ | ||
url: url.href, | ||
@@ -223,2 +224,33 @@ method: request.method, | ||
exports.createApiEvent = createApiEvent; | ||
const compareApiDependencies = (a, b) => { | ||
const isADependentOnB = a.apiReferences.has(b.name); | ||
const isBDependentOnA = b.apiReferences.has(a.name); | ||
if (isADependentOnB === isBDependentOnA) { | ||
return 0; | ||
} | ||
// 1 means A goes last - hence B is evaluated before A | ||
return isADependentOnB ? 1 : -1; | ||
}; | ||
const sortApiObjects = (apis) => { | ||
const apiMap = new Map(); | ||
const getApi = (apiObj, key) => { | ||
let api = apiMap.get(key); | ||
if (!api) { | ||
api = | ||
apiObj.version === 2 | ||
? new ToddleApiV2_1.ToddleApiV2(apiObj, key) | ||
: new LegacyToddleApi_1.LegacyToddleApi(apiObj, key); | ||
apiMap.set(key, api); | ||
} | ||
return api; | ||
}; | ||
return apis.toSorted(([aKey, aObj], [bKey, bObj]) => { | ||
const a = getApi(aObj, aKey); | ||
const b = getApi(bObj, bKey); | ||
return compareApiDependencies(a, b); | ||
}); | ||
}; | ||
exports.sortApiObjects = sortApiObjects; | ||
const sortApiEntries = (apis) => apis.toSorted(([_, a], [__, b]) => compareApiDependencies(a, b)); | ||
exports.sortApiEntries = sortApiEntries; | ||
//# sourceMappingURL=api.js.map |
@@ -95,7 +95,8 @@ "use strict"; | ||
try { | ||
if (!node.style) { | ||
return ''; | ||
} | ||
const style = (0, collections_1.omitKeys)(node.style, ['variants', 'breakpoints', 'shadows']); | ||
const styleVariants = node.variants ?? node.style.variants; | ||
const style = (0, collections_1.omitKeys)(node.style ?? {}, [ | ||
'variants', | ||
'breakpoints', | ||
'shadows', | ||
]); | ||
const styleVariants = node.variants ?? node.style?.variants; | ||
const renderVariant = (selector, style, options) => { | ||
@@ -102,0 +103,0 @@ const scrollbarStyles = Object.entries(style).filter(([key]) => key == 'scrollbar-width'); |
{ | ||
"name": "@toddledev/core", | ||
"version": "0.0.2-alpha.1", | ||
"version": "0.0.2-alpha.2", | ||
"license": "Apache-2.0", | ||
@@ -5,0 +5,0 @@ "homepage": "https://github.com/toddledev/toddle", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
No README
QualityPackage does not have a README. This may indicate a failed publish or a low quality package.
Found 1 instance in 1 package
261632
110
4233
1
4