@octane-xplat/nativescript-mason-core 0.0.1 → 1.0.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/LICENSE +201 -0
- package/README.md +198 -2
- package/artifact-inventory.json +774 -0
- package/box-shadow.d.ts +10 -0
- package/box-shadow.js +48 -0
- package/common.d.ts +485 -0
- package/common.js +2659 -0
- package/css-colors.d.ts +17 -0
- package/css-colors.js +54 -0
- package/css-environment.d.ts +49 -0
- package/css-environment.js +309 -0
- package/css-filter.d.ts +17 -0
- package/css-filter.js +140 -0
- package/css-keyframes.d.ts +41 -0
- package/css-keyframes.js +437 -0
- package/css-math.d.ts +34 -0
- package/css-math.js +300 -0
- package/css-shorthands.d.ts +65 -0
- package/css-shorthands.js +673 -0
- package/css-transform.d.ts +6 -0
- package/css-transform.js +100 -0
- package/diagnostics.d.ts +51 -0
- package/diagnostics.js +52 -0
- package/display-density.d.ts +9 -0
- package/display-density.js +20 -0
- package/fonts.d.ts +20 -0
- package/fonts.js +88 -0
- package/foreign-layout.d.ts +6 -0
- package/foreign-layout.js +151 -0
- package/gradient-stops.d.ts +25 -0
- package/gradient-stops.js +112 -0
- package/index.android.d.ts +11 -0
- package/index.android.js +9 -0
- package/index.d.ts +12 -0
- package/index.ios.d.ts +11 -0
- package/index.ios.js +9 -0
- package/ios-host-README.md +124 -0
- package/layout-types.d.ts +192 -0
- package/mask.d.ts +54 -0
- package/mask.js +26 -0
- package/native-environment.android.d.ts +3 -0
- package/native-environment.android.js +69 -0
- package/native-environment.d.ts +3 -0
- package/native-environment.ios.d.ts +3 -0
- package/native-environment.ios.js +65 -0
- package/native-types-README.md +51 -0
- package/package.json +47 -6
- package/panel-helpers.d.ts +3 -0
- package/panel-helpers.js +8 -0
- package/platforms/android/MasonCore.aar +0 -0
- package/platforms/android/include.gradle +6 -0
- package/platforms/android/manifest.json +73 -0
- package/platforms/ios/FontManager.LICENSE +201 -0
- package/platforms/ios/MasonCore.xcframework/Info.plist +43 -0
- package/platforms/ios/MasonCore.xcframework/ios-arm64/MasonCore.framework/Headers/Mason.h +25 -0
- package/platforms/ios/MasonCore.xcframework/ios-arm64/MasonCore.framework/Headers/MasonCore-Swift.h +1739 -0
- package/platforms/ios/MasonCore.xcframework/ios-arm64/MasonCore.framework/Headers/mason_native.h +601 -0
- package/platforms/ios/MasonCore.xcframework/ios-arm64/MasonCore.framework/Info.plist +0 -0
- package/platforms/ios/MasonCore.xcframework/ios-arm64/MasonCore.framework/MasonCore +0 -0
- package/platforms/ios/MasonCore.xcframework/ios-arm64/MasonCore.framework/Modules/MasonCore.swiftmodule/Project/arm64-apple-ios.swiftsourceinfo +0 -0
- package/platforms/ios/MasonCore.xcframework/ios-arm64/MasonCore.framework/Modules/MasonCore.swiftmodule/arm64-apple-ios.abi.json +100095 -0
- package/platforms/ios/MasonCore.xcframework/ios-arm64/MasonCore.framework/Modules/MasonCore.swiftmodule/arm64-apple-ios.private.swiftinterface +3174 -0
- package/platforms/ios/MasonCore.xcframework/ios-arm64/MasonCore.framework/Modules/MasonCore.swiftmodule/arm64-apple-ios.swiftdoc +0 -0
- package/platforms/ios/MasonCore.xcframework/ios-arm64/MasonCore.framework/Modules/MasonCore.swiftmodule/arm64-apple-ios.swiftinterface +3174 -0
- package/platforms/ios/MasonCore.xcframework/ios-arm64/MasonCore.framework/Modules/module.modulemap +9 -0
- package/platforms/ios/MasonCore.xcframework/ios-arm64/MasonCore.framework/SDWebImage_SDWebImage.bundle/Info.plist +0 -0
- package/platforms/ios/MasonCore.xcframework/ios-arm64/MasonCore.framework/SDWebImage_SDWebImage.bundle/PrivacyInfo.xcprivacy +23 -0
- package/platforms/ios/MasonCore.xcframework/ios-arm64-simulator/MasonCore.framework/Headers/Mason.h +25 -0
- package/platforms/ios/MasonCore.xcframework/ios-arm64-simulator/MasonCore.framework/Headers/MasonCore-Swift.h +1739 -0
- package/platforms/ios/MasonCore.xcframework/ios-arm64-simulator/MasonCore.framework/Headers/mason_native.h +601 -0
- package/platforms/ios/MasonCore.xcframework/ios-arm64-simulator/MasonCore.framework/Info.plist +0 -0
- package/platforms/ios/MasonCore.xcframework/ios-arm64-simulator/MasonCore.framework/MasonCore +0 -0
- package/platforms/ios/MasonCore.xcframework/ios-arm64-simulator/MasonCore.framework/Modules/MasonCore.swiftmodule/Project/arm64-apple-ios-simulator.swiftsourceinfo +0 -0
- package/platforms/ios/MasonCore.xcframework/ios-arm64-simulator/MasonCore.framework/Modules/MasonCore.swiftmodule/arm64-apple-ios-simulator.abi.json +100095 -0
- package/platforms/ios/MasonCore.xcframework/ios-arm64-simulator/MasonCore.framework/Modules/MasonCore.swiftmodule/arm64-apple-ios-simulator.private.swiftinterface +3174 -0
- package/platforms/ios/MasonCore.xcframework/ios-arm64-simulator/MasonCore.framework/Modules/MasonCore.swiftmodule/arm64-apple-ios-simulator.swiftdoc +0 -0
- package/platforms/ios/MasonCore.xcframework/ios-arm64-simulator/MasonCore.framework/Modules/MasonCore.swiftmodule/arm64-apple-ios-simulator.swiftinterface +3174 -0
- package/platforms/ios/MasonCore.xcframework/ios-arm64-simulator/MasonCore.framework/Modules/module.modulemap +9 -0
- package/platforms/ios/MasonCore.xcframework/ios-arm64-simulator/MasonCore.framework/SDWebImage_SDWebImage.bundle/Info.plist +0 -0
- package/platforms/ios/MasonCore.xcframework/ios-arm64-simulator/MasonCore.framework/SDWebImage_SDWebImage.bundle/PrivacyInfo.xcprivacy +23 -0
- package/platforms/ios/Package.resolved +24 -0
- package/platforms/ios/SDWebImage.LICENSE +20 -0
- package/platforms/ios/build.xcconfig +4 -0
- package/platforms/ios/device-manifest.json +213 -0
- package/platforms/ios/include/FontManager/NSCFontDescriptors.h +36 -0
- package/platforms/ios/include/FontManager/NSCFontFace.h +98 -0
- package/platforms/ios/include/FontManager/NSCFontFaceSet.h +73 -0
- package/platforms/ios/include/FontManager/NSCFontManagerUmbrella.h +7 -0
- package/platforms/ios/include/FontManager/NSCFontParser.h +22 -0
- package/platforms/ios/include/FontManager/NSCFontRegex.h +4 -0
- package/platforms/ios/include/FontManager/NSCFontResolver.h +43 -0
- package/platforms/ios/include/FontManager/NSCFontStyle.h +27 -0
- package/platforms/ios/include/FontManager/NSCFontTypes.h +41 -0
- package/platforms/ios/include/SDWebImage/NSButton+WebCache.h +340 -0
- package/platforms/ios/include/SDWebImage/NSData+ImageContentType.h +63 -0
- package/platforms/ios/include/SDWebImage/NSImage+Compatibility.h +67 -0
- package/platforms/ios/include/SDWebImage/SDAnimatedImage.h +136 -0
- package/platforms/ios/include/SDWebImage/SDAnimatedImagePlayer.h +113 -0
- package/platforms/ios/include/SDWebImage/SDAnimatedImageRep.h +33 -0
- package/platforms/ios/include/SDWebImage/SDAnimatedImageView+WebCache.h +168 -0
- package/platforms/ios/include/SDWebImage/SDAnimatedImageView.h +125 -0
- package/platforms/ios/include/SDWebImage/SDCallbackQueue.h +59 -0
- package/platforms/ios/include/SDWebImage/SDDiskCache.h +146 -0
- package/platforms/ios/include/SDWebImage/SDGraphicsImageRenderer.h +84 -0
- package/platforms/ios/include/SDWebImage/SDImageAPNGCoder.h +19 -0
- package/platforms/ios/include/SDWebImage/SDImageAWebPCoder.h +23 -0
- package/platforms/ios/include/SDWebImage/SDImageCache.h +482 -0
- package/platforms/ios/include/SDWebImage/SDImageCacheConfig.h +153 -0
- package/platforms/ios/include/SDWebImage/SDImageCacheDefine.h +179 -0
- package/platforms/ios/include/SDWebImage/SDImageCachesManager.h +81 -0
- package/platforms/ios/include/SDWebImage/SDImageCoder.h +347 -0
- package/platforms/ios/include/SDWebImage/SDImageCoderHelper.h +251 -0
- package/platforms/ios/include/SDWebImage/SDImageCodersManager.h +58 -0
- package/platforms/ios/include/SDWebImage/SDImageFrame.h +44 -0
- package/platforms/ios/include/SDWebImage/SDImageGIFCoder.h +22 -0
- package/platforms/ios/include/SDWebImage/SDImageGraphics.h +28 -0
- package/platforms/ios/include/SDWebImage/SDImageHEICCoder.h +25 -0
- package/platforms/ios/include/SDWebImage/SDImageIOAnimatedCoder.h +65 -0
- package/platforms/ios/include/SDWebImage/SDImageIOCoder.h +30 -0
- package/platforms/ios/include/SDWebImage/SDImageLoader.h +146 -0
- package/platforms/ios/include/SDWebImage/SDImageLoadersManager.h +40 -0
- package/platforms/ios/include/SDWebImage/SDImageTransformer.h +283 -0
- package/platforms/ios/include/SDWebImage/SDMemoryCache.h +78 -0
- package/platforms/ios/include/SDWebImage/SDWebImage.h +91 -0
- package/platforms/ios/include/SDWebImage/SDWebImageCacheKeyFilter.h +35 -0
- package/platforms/ios/include/SDWebImage/SDWebImageCacheSerializer.h +39 -0
- package/platforms/ios/include/SDWebImage/SDWebImageCompat.h +102 -0
- package/platforms/ios/include/SDWebImage/SDWebImageDefine.h +420 -0
- package/platforms/ios/include/SDWebImage/SDWebImageDownloader.h +320 -0
- package/platforms/ios/include/SDWebImage/SDWebImageDownloaderConfig.h +113 -0
- package/platforms/ios/include/SDWebImage/SDWebImageDownloaderDecryptor.h +52 -0
- package/platforms/ios/include/SDWebImage/SDWebImageDownloaderOperation.h +191 -0
- package/platforms/ios/include/SDWebImage/SDWebImageDownloaderRequestModifier.h +72 -0
- package/platforms/ios/include/SDWebImage/SDWebImageDownloaderResponseModifier.h +72 -0
- package/platforms/ios/include/SDWebImage/SDWebImageError.h +33 -0
- package/platforms/ios/include/SDWebImage/SDWebImageIndicator.h +119 -0
- package/platforms/ios/include/SDWebImage/SDWebImageManager.h +290 -0
- package/platforms/ios/include/SDWebImage/SDWebImageOperation.h +27 -0
- package/platforms/ios/include/SDWebImage/SDWebImageOptionsProcessor.h +78 -0
- package/platforms/ios/include/SDWebImage/SDWebImagePrefetcher.h +168 -0
- package/platforms/ios/include/SDWebImage/SDWebImageTransition.h +131 -0
- package/platforms/ios/include/SDWebImage/UIButton+WebCache.h +402 -0
- package/platforms/ios/include/SDWebImage/UIImage+ExtendedCacheData.h +24 -0
- package/platforms/ios/include/SDWebImage/UIImage+ForceDecode.h +52 -0
- package/platforms/ios/include/SDWebImage/UIImage+GIF.h +26 -0
- package/platforms/ios/include/SDWebImage/UIImage+MemoryCacheCost.h +27 -0
- package/platforms/ios/include/SDWebImage/UIImage+Metadata.h +104 -0
- package/platforms/ios/include/SDWebImage/UIImage+MultiFormat.h +81 -0
- package/platforms/ios/include/SDWebImage/UIImage+Transform.h +164 -0
- package/platforms/ios/include/SDWebImage/UIImageView+HighlightedWebCache.h +142 -0
- package/platforms/ios/include/SDWebImage/UIImageView+WebCache.h +209 -0
- package/platforms/ios/include/SDWebImage/UIView+WebCache.h +131 -0
- package/platforms/ios/include/SDWebImage/UIView+WebCacheOperation.h +52 -0
- package/platforms/ios/include/SDWebImage/UIView+WebCacheState.h +63 -0
- package/platforms/ios/include/module.modulemap +2 -0
- package/platforms/ios/manifest.json +132 -0
- package/platforms/ios/simulator-manifest.json +213 -0
- package/plugin-README.md +234 -0
- package/properties.d.ts +154 -0
- package/properties.js +2456 -0
- package/pseudo.d.ts +9 -0
- package/pseudo.js +57 -0
- package/scroll/index.android.d.ts +15 -0
- package/scroll/index.android.js +72 -0
- package/scroll/index.d.ts +5 -0
- package/scroll/index.ios.d.ts +18 -0
- package/scroll/index.ios.js +106 -0
- package/style.d.ts +768 -0
- package/style.js +7167 -0
- package/symbols.d.ts +25 -0
- package/symbols.js +41 -0
- package/tree/index.android.d.ts +11 -0
- package/tree/index.android.js +42 -0
- package/tree/index.d.ts +15 -0
- package/tree/index.ios.d.ts +26 -0
- package/tree/index.ios.js +53 -0
- package/typings/android-declarations.d.ts +4 -0
- package/typings/android.d.ts +9730 -0
- package/typings/manifest.json +45 -0
- package/typings/native.d.ts +5 -0
- package/typings/objc!FontManager.d.ts +389 -0
- package/typings/objc!MasonCore.d.ts +2472 -0
- package/typings/objc!SDWebImage.d.ts +3378 -0
- package/units.d.ts +29 -0
- package/units.js +44 -0
- package/utils/index.android.d.ts +211 -0
- package/utils/index.android.js +595 -0
- package/utils/index.ios.d.ts +222 -0
- package/utils/index.ios.js +790 -0
- package/view/index.android.d.ts +13 -0
- package/view/index.android.js +74 -0
- package/view/index.d.ts +2 -0
- package/view/index.ios.d.ts +24 -0
- package/view/index.ios.js +157 -0
package/css-colors.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resolves CSS colour functions the native parsers don't read.
|
|
3
|
+
*
|
|
4
|
+
* String-valued properties (`box-shadow`, `background`, `border`, `filter`,
|
|
5
|
+
* `text-shadow`, ...) reach Android, iOS and Windows as the CSS text, and
|
|
6
|
+
* their parsers know hex, `rgb()`/`hsl()` and named colours only, so
|
|
7
|
+
* `0 2px 4px color-mix(in oklch, #000 4%, transparent)` would draw opaque
|
|
8
|
+
* black. Each colour function is replaced by its `rgba()` value first.
|
|
9
|
+
*
|
|
10
|
+
* Values that still hold a `var()` are left alone: there's nothing to resolve
|
|
11
|
+
* against yet.
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* @param toRgba resolves one colour (`oklch(60% 0.2 240)`) to `rgba(...)`, or
|
|
15
|
+
* returns null when it can't.
|
|
16
|
+
*/
|
|
17
|
+
export declare function resolveCssColors(value: string, toRgba: (color: string) => string | null): string;
|
package/css-colors.js
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resolves CSS colour functions the native parsers don't read.
|
|
3
|
+
*
|
|
4
|
+
* String-valued properties (`box-shadow`, `background`, `border`, `filter`,
|
|
5
|
+
* `text-shadow`, ...) reach Android, iOS and Windows as the CSS text, and
|
|
6
|
+
* their parsers know hex, `rgb()`/`hsl()` and named colours only, so
|
|
7
|
+
* `0 2px 4px color-mix(in oklch, #000 4%, transparent)` would draw opaque
|
|
8
|
+
* black. Each colour function is replaced by its `rgba()` value first.
|
|
9
|
+
*
|
|
10
|
+
* Values that still hold a `var()` are left alone: there's nothing to resolve
|
|
11
|
+
* against yet.
|
|
12
|
+
*/
|
|
13
|
+
const COLOR_FUNCTION = /(?<![\w-])(color-mix|oklch|oklab|lab|lch|hwb|color|rgba?|hsla?)\(/gi;
|
|
14
|
+
// `rgb()`/`hsl()` only need resolving in their space-separated form.
|
|
15
|
+
const LEGACY_FUNCTION = /^(rgba?|hsla?)$/i;
|
|
16
|
+
const VAR = /var\(/i;
|
|
17
|
+
/**
|
|
18
|
+
* @param toRgba resolves one colour (`oklch(60% 0.2 240)`) to `rgba(...)`, or
|
|
19
|
+
* returns null when it can't.
|
|
20
|
+
*/
|
|
21
|
+
export function resolveCssColors(value, toRgba) {
|
|
22
|
+
if (!value || !value.includes('(')) {
|
|
23
|
+
return value;
|
|
24
|
+
}
|
|
25
|
+
let out = '';
|
|
26
|
+
let last = 0;
|
|
27
|
+
COLOR_FUNCTION.lastIndex = 0;
|
|
28
|
+
let match;
|
|
29
|
+
while ((match = COLOR_FUNCTION.exec(value))) {
|
|
30
|
+
const open = match.index + match[0].length - 1;
|
|
31
|
+
const close = closingParen(value, open);
|
|
32
|
+
if (close === -1) {
|
|
33
|
+
break;
|
|
34
|
+
}
|
|
35
|
+
const call = value.slice(match.index, close + 1);
|
|
36
|
+
const skip = (LEGACY_FUNCTION.test(match[1]) && call.includes(',')) || VAR.test(call);
|
|
37
|
+
out += value.slice(last, match.index) + ((skip ? null : toRgba(call)) ?? call);
|
|
38
|
+
last = close + 1;
|
|
39
|
+
COLOR_FUNCTION.lastIndex = last;
|
|
40
|
+
}
|
|
41
|
+
return last === 0 ? value : out + value.slice(last);
|
|
42
|
+
}
|
|
43
|
+
function closingParen(value, open) {
|
|
44
|
+
let depth = 0;
|
|
45
|
+
for (let i = open; i < value.length; i++) {
|
|
46
|
+
if (value[i] === '(') {
|
|
47
|
+
depth++;
|
|
48
|
+
}
|
|
49
|
+
else if (value[i] === ')' && --depth === 0) {
|
|
50
|
+
return i;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return -1;
|
|
54
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/** Native hosts supply logical (device-independent) pixels, scoped to one view subtree. */
|
|
2
|
+
export interface CssSafeAreaInsets {
|
|
3
|
+
top?: number;
|
|
4
|
+
right?: number;
|
|
5
|
+
bottom?: number;
|
|
6
|
+
left?: number;
|
|
7
|
+
}
|
|
8
|
+
export interface CssEnvironmentHost {
|
|
9
|
+
readonly parent?: CssEnvironmentHost | null;
|
|
10
|
+
on?(event: string, callback: () => void): void;
|
|
11
|
+
off?(event: string, callback: () => void): void;
|
|
12
|
+
}
|
|
13
|
+
/** The host owns window selection, native observation and subscription teardown. */
|
|
14
|
+
export interface CssEnvironmentSource {
|
|
15
|
+
read(): CssSafeAreaInsets | null;
|
|
16
|
+
subscribe(changed: () => void): () => void;
|
|
17
|
+
}
|
|
18
|
+
/** Core host lifecycle adapter: observe lazily, only when a subtree actually uses env(). */
|
|
19
|
+
export declare function registerAutomaticCssEnvironment(host: CssEnvironmentHost, create: () => CssEnvironmentSource): () => void;
|
|
20
|
+
declare const shorthand: unique symbol;
|
|
21
|
+
interface EnvironmentShorthand {
|
|
22
|
+
value: number;
|
|
23
|
+
unit: 'dip';
|
|
24
|
+
css: string;
|
|
25
|
+
[shorthand]: {
|
|
26
|
+
split: (value: string) => unknown[];
|
|
27
|
+
index: number;
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
/** Keep parse-time box shorthands pending until the effective longhand has a host context. */
|
|
31
|
+
export declare function cssEnvironmentShorthand(value: string, split: (value: string) => unknown[], count: number): unknown[] | undefined;
|
|
32
|
+
/** Direct Style box setters need the same deferred split as stylesheet shorthands. */
|
|
33
|
+
export declare function cssEnvironmentSides(value: string): unknown[] | undefined;
|
|
34
|
+
export declare function isCssEnvironmentShorthand(value: unknown): value is EnvironmentShorthand;
|
|
35
|
+
/** Publish a host's current safe area. Missing values are unavailable; zero is a real inset. */
|
|
36
|
+
export declare function setCssEnvironment(host: CssEnvironmentHost, insets: CssSafeAreaInsets | null): void;
|
|
37
|
+
/** Remove the host boundary and re-evaluate styles against their next ancestor context. */
|
|
38
|
+
export declare function clearCssEnvironment(host: CssEnvironmentHost): void;
|
|
39
|
+
/** Bind a host-owned native observer. Call the returned function when that host is disposed. */
|
|
40
|
+
export declare function bindCssEnvironment(host: CssEnvironmentHost, source: CssEnvironmentSource): () => void;
|
|
41
|
+
/** Substitute env() before the existing CSS math/unit parser; undefined means invalid/unavailable. */
|
|
42
|
+
export declare function resolveCssEnvironment(value: string, insets?: CssSafeAreaInsets): string | undefined;
|
|
43
|
+
/** Replay after reparenting/native recreation; publish changes through setCssEnvironment instead. */
|
|
44
|
+
export declare function refreshCssEnvironment(host: CssEnvironmentHost): void;
|
|
45
|
+
/** Core build adapter only: called at a leaf style setter, after cascade/var()/shorthand expansion. */
|
|
46
|
+
export declare function environmentStyleValue(target: object, name: string, value: unknown): unknown;
|
|
47
|
+
/** Stop replaying a released native style helper, including its lifecycle listeners. */
|
|
48
|
+
export declare function releaseCssEnvironmentStyle(target: object): void;
|
|
49
|
+
export {};
|
|
@@ -0,0 +1,309 @@
|
|
|
1
|
+
import { splitMargin } from './css-shorthands';
|
|
2
|
+
import { reportCssDiagnostic } from './diagnostics';
|
|
3
|
+
const environments = new WeakMap();
|
|
4
|
+
const bindings = new WeakMap();
|
|
5
|
+
const automaticSources = new WeakMap();
|
|
6
|
+
/** Core host lifecycle adapter: observe lazily, only when a subtree actually uses env(). */
|
|
7
|
+
export function registerAutomaticCssEnvironment(host, create) {
|
|
8
|
+
const entry = { create, starting: false };
|
|
9
|
+
automaticSources.set(host, entry);
|
|
10
|
+
refreshCssEnvironment(host);
|
|
11
|
+
return () => {
|
|
12
|
+
if (automaticSources.get(host) !== entry)
|
|
13
|
+
return;
|
|
14
|
+
automaticSources.delete(host);
|
|
15
|
+
entry.stop?.();
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
function ensureAutomaticEnvironment(owner) {
|
|
19
|
+
for (let host = owner; host; host = host.parent ?? undefined) {
|
|
20
|
+
const entry = automaticSources.get(host);
|
|
21
|
+
if (entry) {
|
|
22
|
+
if (!entry.stop && !entry.starting && !bindings.has(host) && !environments.has(host)) {
|
|
23
|
+
entry.starting = true;
|
|
24
|
+
try {
|
|
25
|
+
entry.stop = bindCssEnvironment(host, entry.create());
|
|
26
|
+
}
|
|
27
|
+
finally {
|
|
28
|
+
entry.starting = false;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
if (environments.has(host))
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
const sides = ['top', 'right', 'bottom', 'left'];
|
|
38
|
+
const ENV = /\benv\(/i;
|
|
39
|
+
const shorthand = Symbol('mason:environment-shorthand');
|
|
40
|
+
/** Keep parse-time box shorthands pending until the effective longhand has a host context. */
|
|
41
|
+
export function cssEnvironmentShorthand(value, split, count) {
|
|
42
|
+
if (!ENV.test(value))
|
|
43
|
+
return undefined;
|
|
44
|
+
return Array.from({ length: count }, (_, index) => ({
|
|
45
|
+
value: 0, unit: 'dip', css: value, [shorthand]: { split, index },
|
|
46
|
+
}));
|
|
47
|
+
}
|
|
48
|
+
/** Direct Style box setters need the same deferred split as stylesheet shorthands. */
|
|
49
|
+
export function cssEnvironmentSides(value) {
|
|
50
|
+
return cssEnvironmentShorthand(value, splitMargin, 4);
|
|
51
|
+
}
|
|
52
|
+
export function isCssEnvironmentShorthand(value) {
|
|
53
|
+
return !!value && typeof value === 'object' && shorthand in value;
|
|
54
|
+
}
|
|
55
|
+
function snapshot(insets) {
|
|
56
|
+
const result = {};
|
|
57
|
+
for (const side of sides) {
|
|
58
|
+
const value = insets?.[side];
|
|
59
|
+
if (value !== undefined) {
|
|
60
|
+
if (!Number.isFinite(value) || value < 0)
|
|
61
|
+
throw new RangeError(`Invalid safe-area ${side} inset.`);
|
|
62
|
+
result[side] = value;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
return result;
|
|
66
|
+
}
|
|
67
|
+
/** Publish a host's current safe area. Missing values are unavailable; zero is a real inset. */
|
|
68
|
+
export function setCssEnvironment(host, insets) {
|
|
69
|
+
const next = snapshot(insets);
|
|
70
|
+
const previous = environments.get(host);
|
|
71
|
+
if (previous && sides.every((side) => previous[side] === next[side]))
|
|
72
|
+
return;
|
|
73
|
+
// An empty environment still establishes a window boundary: don't inherit another window's insets.
|
|
74
|
+
environments.set(host, next);
|
|
75
|
+
refreshCssEnvironment(host);
|
|
76
|
+
}
|
|
77
|
+
/** Remove the host boundary and re-evaluate styles against their next ancestor context. */
|
|
78
|
+
export function clearCssEnvironment(host) {
|
|
79
|
+
if (environments.delete(host))
|
|
80
|
+
refreshCssEnvironment(host);
|
|
81
|
+
}
|
|
82
|
+
/** Bind a host-owned native observer. Call the returned function when that host is disposed. */
|
|
83
|
+
export function bindCssEnvironment(host, source) {
|
|
84
|
+
if (bindings.has(host))
|
|
85
|
+
throw new Error('This host already has a CSS environment binding.');
|
|
86
|
+
const token = {};
|
|
87
|
+
bindings.set(host, token);
|
|
88
|
+
const update = () => {
|
|
89
|
+
if (bindings.get(host) === token)
|
|
90
|
+
setCssEnvironment(host, source.read());
|
|
91
|
+
};
|
|
92
|
+
let unsubscribe;
|
|
93
|
+
try {
|
|
94
|
+
update();
|
|
95
|
+
unsubscribe = source.subscribe(update);
|
|
96
|
+
update(); // Catch a change between the first read and subscription.
|
|
97
|
+
}
|
|
98
|
+
catch (error) {
|
|
99
|
+
bindings.delete(host);
|
|
100
|
+
try {
|
|
101
|
+
unsubscribe?.();
|
|
102
|
+
}
|
|
103
|
+
finally {
|
|
104
|
+
clearCssEnvironment(host);
|
|
105
|
+
}
|
|
106
|
+
throw error;
|
|
107
|
+
}
|
|
108
|
+
return () => {
|
|
109
|
+
if (bindings.get(host) !== token)
|
|
110
|
+
return;
|
|
111
|
+
bindings.delete(host);
|
|
112
|
+
try {
|
|
113
|
+
unsubscribe?.();
|
|
114
|
+
}
|
|
115
|
+
finally {
|
|
116
|
+
clearCssEnvironment(host);
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
function context(view) {
|
|
121
|
+
for (let current = view; current; current = current.parent ?? undefined) {
|
|
122
|
+
const value = environments.get(current);
|
|
123
|
+
if (value)
|
|
124
|
+
return value;
|
|
125
|
+
}
|
|
126
|
+
return undefined;
|
|
127
|
+
}
|
|
128
|
+
// Scan balanced CSS functions, preserving strings, comments and URL payloads.
|
|
129
|
+
function close(value, start) {
|
|
130
|
+
let depth = 1;
|
|
131
|
+
for (let i = start; i < value.length; i++) {
|
|
132
|
+
if (value[i] === '\\') {
|
|
133
|
+
i++;
|
|
134
|
+
continue;
|
|
135
|
+
}
|
|
136
|
+
if (value[i] === '"' || value[i] === "'") {
|
|
137
|
+
const quote = value[i++];
|
|
138
|
+
while (i < value.length && value[i] !== quote) {
|
|
139
|
+
if (value[i] === '\\')
|
|
140
|
+
i++;
|
|
141
|
+
i++;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
else if (value[i] === '/' && value[i + 1] === '*') {
|
|
145
|
+
const end = value.indexOf('*/', i + 2);
|
|
146
|
+
if (end < 0)
|
|
147
|
+
return -1;
|
|
148
|
+
i = end + 1;
|
|
149
|
+
}
|
|
150
|
+
else if (value[i] === '(')
|
|
151
|
+
depth++;
|
|
152
|
+
else if (value[i] === ')' && --depth === 0)
|
|
153
|
+
return i;
|
|
154
|
+
}
|
|
155
|
+
return -1;
|
|
156
|
+
}
|
|
157
|
+
/** Substitute env() before the existing CSS math/unit parser; undefined means invalid/unavailable. */
|
|
158
|
+
export function resolveCssEnvironment(value, insets = {}) {
|
|
159
|
+
let result = '';
|
|
160
|
+
for (let i = 0; i < value.length;) {
|
|
161
|
+
if (value[i] === '\\') {
|
|
162
|
+
result += value.slice(i, i + 2);
|
|
163
|
+
i += 2;
|
|
164
|
+
continue;
|
|
165
|
+
}
|
|
166
|
+
if (value[i] === '"' || value[i] === "'") {
|
|
167
|
+
const start = i;
|
|
168
|
+
const quote = value[i++];
|
|
169
|
+
while (i < value.length && value[i] !== quote) {
|
|
170
|
+
if (value[i] === '\\')
|
|
171
|
+
i++;
|
|
172
|
+
i++;
|
|
173
|
+
}
|
|
174
|
+
result += value.slice(start, ++i);
|
|
175
|
+
continue;
|
|
176
|
+
}
|
|
177
|
+
if (value[i] === '/' && value[i + 1] === '*') {
|
|
178
|
+
const end = value.indexOf('*/', i + 2);
|
|
179
|
+
if (end < 0)
|
|
180
|
+
return undefined;
|
|
181
|
+
result += value.slice(i, end + 2);
|
|
182
|
+
i = end + 2;
|
|
183
|
+
continue;
|
|
184
|
+
}
|
|
185
|
+
const fn = /^([a-z_-][\w-]*)\(/i.exec(value.slice(i));
|
|
186
|
+
if (!fn) {
|
|
187
|
+
result += value[i++];
|
|
188
|
+
continue;
|
|
189
|
+
}
|
|
190
|
+
const start = i + fn[0].length;
|
|
191
|
+
const end = close(value, start);
|
|
192
|
+
if (end < 0)
|
|
193
|
+
return undefined;
|
|
194
|
+
const name = fn[1].toLowerCase();
|
|
195
|
+
const body = value.slice(start, end);
|
|
196
|
+
let replacement;
|
|
197
|
+
if (name === 'url')
|
|
198
|
+
replacement = value.slice(i, end + 1);
|
|
199
|
+
else if (name === 'env') {
|
|
200
|
+
// The first comma separates the environment name from an arbitrary fallback token sequence.
|
|
201
|
+
const comma = body.indexOf(',');
|
|
202
|
+
const identifier = (comma < 0 ? body : body.slice(0, comma)).replace(/\/\*[\s\S]*?\*\//g, ' ').trim();
|
|
203
|
+
const args = /^(-?[_a-zA-Z][_a-zA-Z0-9-]*)(?:\s+\+?\d+)*$/.exec(identifier);
|
|
204
|
+
if (!args)
|
|
205
|
+
return undefined;
|
|
206
|
+
const side = /^safe-area-inset-(top|right|bottom|left)$/.exec(identifier)?.[1];
|
|
207
|
+
const inset = side && insets[side];
|
|
208
|
+
if (typeof inset === 'number' && Number.isFinite(inset) && inset >= 0)
|
|
209
|
+
replacement = `${inset}px`;
|
|
210
|
+
else if (comma >= 0)
|
|
211
|
+
replacement = resolveCssEnvironment(body.slice(comma + 1).trim(), insets);
|
|
212
|
+
}
|
|
213
|
+
else {
|
|
214
|
+
const inner = resolveCssEnvironment(body, insets);
|
|
215
|
+
if (inner !== undefined)
|
|
216
|
+
replacement = `${fn[1]}(${inner})`;
|
|
217
|
+
}
|
|
218
|
+
if (replacement === undefined)
|
|
219
|
+
return undefined;
|
|
220
|
+
result += replacement;
|
|
221
|
+
i = end + 1;
|
|
222
|
+
}
|
|
223
|
+
return result;
|
|
224
|
+
}
|
|
225
|
+
const writesByTarget = new WeakMap();
|
|
226
|
+
const targets = new Set();
|
|
227
|
+
function replay(writes) {
|
|
228
|
+
const target = writes.target.deref();
|
|
229
|
+
if (target && writes.active) {
|
|
230
|
+
for (const [name, value] of Array.from(writes.values))
|
|
231
|
+
target[name] = value;
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
/** Replay after reparenting/native recreation; publish changes through setCssEnvironment instead. */
|
|
235
|
+
export function refreshCssEnvironment(host) {
|
|
236
|
+
for (const ref of targets) {
|
|
237
|
+
const writes = ref.deref();
|
|
238
|
+
if (!writes?.target.deref()) {
|
|
239
|
+
if (writes)
|
|
240
|
+
stopWrites(writes);
|
|
241
|
+
targets.delete(ref);
|
|
242
|
+
continue;
|
|
243
|
+
}
|
|
244
|
+
for (let view = writes.owner?.deref(); view; view = view.parent ?? undefined) {
|
|
245
|
+
if (view === host) {
|
|
246
|
+
replay(writes);
|
|
247
|
+
break;
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
/** Core build adapter only: called at a leaf style setter, after cascade/var()/shorthand expansion. */
|
|
253
|
+
export function environmentStyleValue(target, name, value) {
|
|
254
|
+
const style = target;
|
|
255
|
+
const owner = style.viewRef?.get?.() ?? style.viewRef?.deref?.() ?? style.view;
|
|
256
|
+
const text = typeof value === 'string' ? value : value?.css;
|
|
257
|
+
let writes = writesByTarget.get(target);
|
|
258
|
+
if (typeof text !== 'string' || !ENV.test(text)) {
|
|
259
|
+
writes?.values.delete(name);
|
|
260
|
+
if (writes && !writes.values.size)
|
|
261
|
+
releaseCssEnvironmentStyle(target);
|
|
262
|
+
return value;
|
|
263
|
+
}
|
|
264
|
+
ensureAutomaticEnvironment(owner);
|
|
265
|
+
if (!writes) {
|
|
266
|
+
writes = {
|
|
267
|
+
target: new WeakRef(target), owner: owner && new WeakRef(owner), values: new Map(), active: true,
|
|
268
|
+
loaded() { writes.active = true; replay(writes); },
|
|
269
|
+
unloaded() { writes.active = false; },
|
|
270
|
+
};
|
|
271
|
+
writesByTarget.set(target, writes);
|
|
272
|
+
targets.add(new WeakRef(writes));
|
|
273
|
+
owner?.on?.('loaded', writes.loaded);
|
|
274
|
+
owner?.on?.('unloaded', writes.unloaded);
|
|
275
|
+
}
|
|
276
|
+
writes.values.set(name, value);
|
|
277
|
+
let resolved = resolveCssEnvironment(text, context(owner));
|
|
278
|
+
if (resolved !== undefined && isCssEnvironmentShorthand(value)) {
|
|
279
|
+
try {
|
|
280
|
+
const pending = value[shorthand];
|
|
281
|
+
const part = pending.split(resolved)[pending.index];
|
|
282
|
+
resolved = typeof part === 'string' ? part : undefined;
|
|
283
|
+
}
|
|
284
|
+
catch {
|
|
285
|
+
resolved = undefined;
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
if (resolved === undefined) {
|
|
289
|
+
reportCssDiagnostic({ kind: 'not-implemented', name, value: text,
|
|
290
|
+
detail: 'env() is unavailable or invalid and has no usable fallback; the host must publish its window safe area' });
|
|
291
|
+
return text;
|
|
292
|
+
}
|
|
293
|
+
return resolved;
|
|
294
|
+
}
|
|
295
|
+
/** Stop replaying a released native style helper, including its lifecycle listeners. */
|
|
296
|
+
export function releaseCssEnvironmentStyle(target) {
|
|
297
|
+
const writes = writesByTarget.get(target);
|
|
298
|
+
if (!writes)
|
|
299
|
+
return;
|
|
300
|
+
stopWrites(writes);
|
|
301
|
+
writesByTarget.delete(target);
|
|
302
|
+
}
|
|
303
|
+
function stopWrites(writes) {
|
|
304
|
+
const owner = writes.owner?.deref();
|
|
305
|
+
owner?.off?.('loaded', writes.loaded);
|
|
306
|
+
owner?.off?.('unloaded', writes.unloaded);
|
|
307
|
+
writes.values.clear();
|
|
308
|
+
writes.active = false;
|
|
309
|
+
}
|
package/css-filter.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export type ColorMatrix = number[];
|
|
2
|
+
export type FilterStep = {
|
|
3
|
+
kind: 'matrix';
|
|
4
|
+
matrix: ColorMatrix;
|
|
5
|
+
} | {
|
|
6
|
+
kind: 'blur';
|
|
7
|
+
sigma: number;
|
|
8
|
+
} | {
|
|
9
|
+
kind: 'shadow';
|
|
10
|
+
x: number;
|
|
11
|
+
y: number;
|
|
12
|
+
sigma: number;
|
|
13
|
+
color: string | null;
|
|
14
|
+
};
|
|
15
|
+
export declare function composeMatrices(first: ColorMatrix, second: ColorMatrix): ColorMatrix;
|
|
16
|
+
export declare function parseCssFilter(value: string, toDip: (token: string) => number | undefined): FilterStep[];
|
|
17
|
+
export declare function encodeCssFilter(steps: FilterStep[], argbOf: (color: string | null) => number): string;
|
package/css-filter.js
ADDED
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { parseBoxShadows } from './box-shadow';
|
|
2
|
+
import { parseAngle } from './css-transform';
|
|
3
|
+
const IDENTITY = [1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0];
|
|
4
|
+
function amount(arg, fallback) {
|
|
5
|
+
const t = arg.trim();
|
|
6
|
+
if (!t)
|
|
7
|
+
return fallback;
|
|
8
|
+
const n = parseFloat(t);
|
|
9
|
+
if (!Number.isFinite(n))
|
|
10
|
+
return fallback;
|
|
11
|
+
return t.endsWith('%') ? n / 100 : n;
|
|
12
|
+
}
|
|
13
|
+
const clamp01 = (n) => Math.min(1, Math.max(0, n));
|
|
14
|
+
function rgb(rows) {
|
|
15
|
+
return [...rows[0], 0, 0, ...rows[1], 0, 0, ...rows[2], 0, 0, 0, 0, 0, 1, 0];
|
|
16
|
+
}
|
|
17
|
+
function grayscale(a) {
|
|
18
|
+
const k = 1 - clamp01(a);
|
|
19
|
+
return rgb([
|
|
20
|
+
[0.2126 + 0.7874 * k, 0.7152 - 0.7152 * k, 0.0722 - 0.0722 * k],
|
|
21
|
+
[0.2126 - 0.2126 * k, 0.7152 + 0.2848 * k, 0.0722 - 0.0722 * k],
|
|
22
|
+
[0.2126 - 0.2126 * k, 0.7152 - 0.7152 * k, 0.0722 + 0.9278 * k],
|
|
23
|
+
]);
|
|
24
|
+
}
|
|
25
|
+
function sepia(a) {
|
|
26
|
+
const k = 1 - clamp01(a);
|
|
27
|
+
return rgb([
|
|
28
|
+
[0.393 + 0.607 * k, 0.769 - 0.769 * k, 0.189 - 0.189 * k],
|
|
29
|
+
[0.349 - 0.349 * k, 0.686 + 0.314 * k, 0.168 - 0.168 * k],
|
|
30
|
+
[0.272 - 0.272 * k, 0.534 - 0.534 * k, 0.131 + 0.869 * k],
|
|
31
|
+
]);
|
|
32
|
+
}
|
|
33
|
+
function saturate(s) {
|
|
34
|
+
return rgb([
|
|
35
|
+
[0.213 + 0.787 * s, 0.715 - 0.715 * s, 0.072 - 0.072 * s],
|
|
36
|
+
[0.213 - 0.213 * s, 0.715 + 0.285 * s, 0.072 - 0.072 * s],
|
|
37
|
+
[0.213 - 0.213 * s, 0.715 - 0.715 * s, 0.072 + 0.928 * s],
|
|
38
|
+
]);
|
|
39
|
+
}
|
|
40
|
+
function hueRotate(radians) {
|
|
41
|
+
const c = Math.cos(radians);
|
|
42
|
+
const s = Math.sin(radians);
|
|
43
|
+
return rgb([
|
|
44
|
+
[0.213 + c * 0.787 - s * 0.213, 0.715 - c * 0.715 - s * 0.715, 0.072 - c * 0.072 + s * 0.928],
|
|
45
|
+
[0.213 - c * 0.213 + s * 0.143, 0.715 + c * 0.285 + s * 0.14, 0.072 - c * 0.072 - s * 0.283],
|
|
46
|
+
[0.213 - c * 0.213 - s * 0.787, 0.715 - c * 0.715 + s * 0.715, 0.072 + c * 0.928 + s * 0.072],
|
|
47
|
+
]);
|
|
48
|
+
}
|
|
49
|
+
function linear(slope, intercept) {
|
|
50
|
+
return [slope, 0, 0, 0, intercept, 0, slope, 0, 0, intercept, 0, 0, slope, 0, intercept, 0, 0, 0, 1, 0];
|
|
51
|
+
}
|
|
52
|
+
function alpha(a) {
|
|
53
|
+
return [1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, clamp01(a), 0];
|
|
54
|
+
}
|
|
55
|
+
export function composeMatrices(first, second) {
|
|
56
|
+
const out = new Array(20).fill(0);
|
|
57
|
+
for (let row = 0; row < 4; row++) {
|
|
58
|
+
for (let col = 0; col < 5; col++) {
|
|
59
|
+
let v = col === 4 ? second[row * 5 + 4] : 0;
|
|
60
|
+
for (let k = 0; k < 4; k++)
|
|
61
|
+
v += second[row * 5 + k] * first[k * 5 + col];
|
|
62
|
+
out[row * 5 + col] = v;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
return out;
|
|
66
|
+
}
|
|
67
|
+
const FUNCTION = /([a-z-]+)\s*\(((?:[^()]|\([^()]*\))*)\)/gi;
|
|
68
|
+
export function parseCssFilter(value, toDip) {
|
|
69
|
+
const steps = [];
|
|
70
|
+
const v = (value ?? '').trim();
|
|
71
|
+
if (!v || v === 'none')
|
|
72
|
+
return steps;
|
|
73
|
+
const push = (matrix) => {
|
|
74
|
+
const last = steps[steps.length - 1];
|
|
75
|
+
if (last && last.kind === 'matrix')
|
|
76
|
+
last.matrix = composeMatrices(last.matrix, matrix);
|
|
77
|
+
else
|
|
78
|
+
steps.push({ kind: 'matrix', matrix });
|
|
79
|
+
};
|
|
80
|
+
for (const match of v.matchAll(FUNCTION)) {
|
|
81
|
+
const name = match[1].toLowerCase();
|
|
82
|
+
const arg = match[2];
|
|
83
|
+
switch (name) {
|
|
84
|
+
case 'blur': {
|
|
85
|
+
const t = arg.trim();
|
|
86
|
+
const sigma = t ? (toDip(t) ?? parseFloat(t)) : 0;
|
|
87
|
+
if (Number.isFinite(sigma) && sigma > 0)
|
|
88
|
+
steps.push({ kind: 'blur', sigma });
|
|
89
|
+
break;
|
|
90
|
+
}
|
|
91
|
+
case 'grayscale':
|
|
92
|
+
push(grayscale(amount(arg, 1)));
|
|
93
|
+
break;
|
|
94
|
+
case 'sepia':
|
|
95
|
+
push(sepia(amount(arg, 1)));
|
|
96
|
+
break;
|
|
97
|
+
case 'saturate':
|
|
98
|
+
push(saturate(Math.max(0, amount(arg, 1))));
|
|
99
|
+
break;
|
|
100
|
+
case 'hue-rotate':
|
|
101
|
+
push(hueRotate(arg.trim() ? parseAngle(arg) : 0));
|
|
102
|
+
break;
|
|
103
|
+
case 'invert': {
|
|
104
|
+
const a = clamp01(amount(arg, 1));
|
|
105
|
+
push(linear(1 - 2 * a, a));
|
|
106
|
+
break;
|
|
107
|
+
}
|
|
108
|
+
case 'opacity':
|
|
109
|
+
push(alpha(amount(arg, 1)));
|
|
110
|
+
break;
|
|
111
|
+
case 'brightness':
|
|
112
|
+
push(linear(Math.max(0, amount(arg, 1)), 0));
|
|
113
|
+
break;
|
|
114
|
+
case 'contrast': {
|
|
115
|
+
const c = Math.max(0, amount(arg, 1));
|
|
116
|
+
push(linear(c, 0.5 - 0.5 * c));
|
|
117
|
+
break;
|
|
118
|
+
}
|
|
119
|
+
case 'drop-shadow': {
|
|
120
|
+
const shadow = parseBoxShadows(arg, toDip)[0];
|
|
121
|
+
if (shadow)
|
|
122
|
+
steps.push({ kind: 'shadow', x: shadow.offsetX, y: shadow.offsetY, sigma: shadow.blur / 2, color: shadow.color });
|
|
123
|
+
break;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
return steps.filter((s) => s.kind !== 'matrix' || s.matrix.some((n, i) => Math.abs(n - IDENTITY[i]) > 1e-6));
|
|
128
|
+
}
|
|
129
|
+
export function encodeCssFilter(steps, argbOf) {
|
|
130
|
+
const round = (n) => Math.round(n * 1e6) / 1e6;
|
|
131
|
+
return steps
|
|
132
|
+
.map((s) => {
|
|
133
|
+
if (s.kind === 'matrix')
|
|
134
|
+
return 'm,' + s.matrix.map(round).join(',');
|
|
135
|
+
if (s.kind === 'blur')
|
|
136
|
+
return `b,${round(s.sigma)}`;
|
|
137
|
+
return `d,${round(s.x)},${round(s.y)},${round(s.sigma)},${argbOf(s.color) >>> 0}`;
|
|
138
|
+
})
|
|
139
|
+
.join(';');
|
|
140
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { CssAnimationProperty, Style, View } from '@nativescript/core';
|
|
2
|
+
/**
|
|
3
|
+
* CSS keyframes for properties MasonKit draws itself.
|
|
4
|
+
*
|
|
5
|
+
* Core plays each keyframe interval with its native Animation, which only knows opacity,
|
|
6
|
+
* background-color, transforms, width and height. MasonKit's animatable properties are taken
|
|
7
|
+
* out of core's keyframes and interpolated every frame on the same timeline instead: delay,
|
|
8
|
+
* duration, iterations, each interval's timing function and `animation-fill-mode`.
|
|
9
|
+
*/
|
|
10
|
+
type Interpolate = (from: string, to: string, t: number) => string;
|
|
11
|
+
interface Track {
|
|
12
|
+
property: CssAnimationProperty<Style, string>;
|
|
13
|
+
interpolate: Interpolate;
|
|
14
|
+
/** [time in ms from the start of an iteration, value]; time-ordered. */
|
|
15
|
+
stops: [number, string][];
|
|
16
|
+
}
|
|
17
|
+
/** Lets keyframes animate [property] with [interpolate]; [initial] is its CSS initial value. */
|
|
18
|
+
export declare function registerKeyframeProperty(property: CssAnimationProperty<Style, string>, interpolate: Interpolate, initial: string): void;
|
|
19
|
+
/** Interpolates `<position>` lists (`mask-position`, `background-position`). */
|
|
20
|
+
export declare const interpolatePositionList: Interpolate;
|
|
21
|
+
/** Interpolates `<bg-size>` lists (`mask-size`, `background-size`). */
|
|
22
|
+
export declare const interpolateSizeList: Interpolate;
|
|
23
|
+
/** Core's keyframe curve as an easing function; `linear`, `spring` and unknown curves are linear. */
|
|
24
|
+
export declare function easing(curve: any): (t: number) => number;
|
|
25
|
+
/**
|
|
26
|
+
* The value of [track] at [time] ms into an iteration of [total] ms. [curveAt] gives the timing
|
|
27
|
+
* function of the interval starting at a time. A missing first or last keyframe uses [base], the
|
|
28
|
+
* element's own value, as CSS does.
|
|
29
|
+
*/
|
|
30
|
+
export declare function sampleTrack(track: Pick<Track, 'interpolate' | 'stops'>, base: string, total: number, time: number, curveAt: (start: number) => (t: number) => number): string;
|
|
31
|
+
/**
|
|
32
|
+
* Windows: View.animate()'s scale, rotate and translate, played per frame on the View properties
|
|
33
|
+
* (core's storyboards target a transform that doesn't show on a Mason view).
|
|
34
|
+
*/
|
|
35
|
+
export declare function animateTransforms(view: View, options: any): {
|
|
36
|
+
done: Promise<void>;
|
|
37
|
+
cancel: () => void;
|
|
38
|
+
};
|
|
39
|
+
/** Installs the keyframe hooks once. */
|
|
40
|
+
export declare function installKeyframes(): void;
|
|
41
|
+
export {};
|