@shopify/react-native-skia 0.1.231 → 0.1.233
Sign up to get free protection for your applications and to get access to all the features.
- package/cpp/rnskia/dom/props/FontProp.h +2 -7
- package/lib/commonjs/dom/nodes/drawings/Text.js +1 -11
- package/lib/commonjs/dom/nodes/drawings/Text.js.map +1 -1
- package/lib/commonjs/dom/types/Drawings.d.ts +1 -1
- package/lib/commonjs/dom/types/Drawings.js.map +1 -1
- package/lib/commonjs/renderer/Canvas.js +5 -0
- package/lib/commonjs/renderer/Canvas.js.map +1 -1
- package/lib/commonjs/renderer/HostConfig.js +1 -1
- package/lib/commonjs/renderer/HostConfig.js.map +1 -1
- package/lib/commonjs/renderer/Reconciler.d.ts +1 -0
- package/lib/commonjs/renderer/Reconciler.js +4 -0
- package/lib/commonjs/renderer/Reconciler.js.map +1 -1
- package/lib/commonjs/skia/types/Matrix4.d.ts +5 -0
- package/lib/commonjs/skia/types/Matrix4.js +8 -3
- package/lib/commonjs/skia/types/Matrix4.js.map +1 -1
- package/lib/commonjs/skia/types/Paragraph/Paragraph.d.ts +2 -2
- package/lib/commonjs/skia/types/Paragraph/Paragraph.js.map +1 -1
- package/lib/commonjs/skia/types/Paragraph/ParagraphStyle.d.ts +6 -6
- package/lib/commonjs/skia/types/Paragraph/ParagraphStyle.js +25 -25
- package/lib/commonjs/skia/types/Paragraph/ParagraphStyle.js.map +1 -1
- package/lib/commonjs/skia/types/Shader/Shader.js +1 -1
- package/lib/commonjs/skia/types/Shader/Shader.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkParagraphStyle.js +1 -1
- package/lib/commonjs/skia/web/JsiSkParagraphStyle.js.map +1 -1
- package/lib/commonjs/web/LoadSkiaWeb.js +4 -1
- package/lib/commonjs/web/LoadSkiaWeb.js.map +1 -1
- package/lib/module/dom/nodes/drawings/Text.js +1 -11
- package/lib/module/dom/nodes/drawings/Text.js.map +1 -1
- package/lib/module/dom/types/Drawings.d.ts +1 -1
- package/lib/module/dom/types/Drawings.js.map +1 -1
- package/lib/module/renderer/Canvas.js +5 -0
- package/lib/module/renderer/Canvas.js.map +1 -1
- package/lib/module/renderer/HostConfig.js +1 -1
- package/lib/module/renderer/HostConfig.js.map +1 -1
- package/lib/module/renderer/Reconciler.d.ts +1 -0
- package/lib/module/renderer/Reconciler.js +4 -0
- package/lib/module/renderer/Reconciler.js.map +1 -1
- package/lib/module/skia/types/Matrix4.d.ts +5 -0
- package/lib/module/skia/types/Matrix4.js +6 -4
- package/lib/module/skia/types/Matrix4.js.map +1 -1
- package/lib/module/skia/types/Paragraph/Paragraph.d.ts +2 -2
- package/lib/module/skia/types/Paragraph/Paragraph.js.map +1 -1
- package/lib/module/skia/types/Paragraph/ParagraphStyle.d.ts +6 -6
- package/lib/module/skia/types/Paragraph/ParagraphStyle.js +21 -21
- package/lib/module/skia/types/Paragraph/ParagraphStyle.js.map +1 -1
- package/lib/module/skia/types/Shader/Shader.js +1 -1
- package/lib/module/skia/types/Shader/Shader.js.map +1 -1
- package/lib/module/skia/web/JsiSkParagraphStyle.js +2 -2
- package/lib/module/skia/web/JsiSkParagraphStyle.js.map +1 -1
- package/lib/module/web/LoadSkiaWeb.js +5 -1
- package/lib/module/web/LoadSkiaWeb.js.map +1 -1
- package/lib/typescript/src/dom/types/Drawings.d.ts +1 -1
- package/lib/typescript/src/renderer/Reconciler.d.ts +1 -0
- package/lib/typescript/src/skia/types/Matrix4.d.ts +5 -0
- package/lib/typescript/src/skia/types/Paragraph/Paragraph.d.ts +2 -2
- package/lib/typescript/src/skia/types/Paragraph/ParagraphStyle.d.ts +6 -6
- package/package.json +1 -1
- package/src/dom/nodes/drawings/Text.ts +1 -14
- package/src/dom/types/Drawings.ts +1 -1
- package/src/renderer/Canvas.tsx +6 -0
- package/src/renderer/HostConfig.ts +1 -1
- package/src/renderer/Reconciler.tsx +4 -0
- package/src/skia/types/Matrix4.ts +8 -6
- package/src/skia/types/Paragraph/Paragraph.ts +2 -2
- package/src/skia/types/Paragraph/ParagraphStyle.ts +6 -6
- package/src/skia/types/Shader/Shader.ts +1 -1
- package/src/skia/web/JsiSkParagraphStyle.ts +2 -2
- package/src/web/LoadSkiaWeb.tsx +4 -1
@@ -1,27 +1,27 @@
|
|
1
|
-
export let
|
1
|
+
export let TextDirection;
|
2
2
|
|
3
|
-
(function (
|
4
|
-
|
5
|
-
|
6
|
-
})(
|
3
|
+
(function (TextDirection) {
|
4
|
+
TextDirection[TextDirection["RTL"] = 0] = "RTL";
|
5
|
+
TextDirection[TextDirection["LTR"] = 1] = "LTR";
|
6
|
+
})(TextDirection || (TextDirection = {}));
|
7
7
|
|
8
|
-
export let
|
8
|
+
export let TextAlign;
|
9
9
|
|
10
|
-
(function (
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
})(
|
10
|
+
(function (TextAlign) {
|
11
|
+
TextAlign[TextAlign["Left"] = 0] = "Left";
|
12
|
+
TextAlign[TextAlign["Right"] = 1] = "Right";
|
13
|
+
TextAlign[TextAlign["Center"] = 2] = "Center";
|
14
|
+
TextAlign[TextAlign["Justify"] = 3] = "Justify";
|
15
|
+
TextAlign[TextAlign["Start"] = 4] = "Start";
|
16
|
+
TextAlign[TextAlign["End"] = 5] = "End";
|
17
|
+
})(TextAlign || (TextAlign = {}));
|
18
18
|
|
19
|
-
export let
|
19
|
+
export let TextHeightBehavior;
|
20
20
|
|
21
|
-
(function (
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
})(
|
21
|
+
(function (TextHeightBehavior) {
|
22
|
+
TextHeightBehavior[TextHeightBehavior["All"] = 0] = "All";
|
23
|
+
TextHeightBehavior[TextHeightBehavior["DisableFirstAscent"] = 1] = "DisableFirstAscent";
|
24
|
+
TextHeightBehavior[TextHeightBehavior["DisableLastDescent"] = 2] = "DisableLastDescent";
|
25
|
+
TextHeightBehavior[TextHeightBehavior["DisableAll"] = 3] = "DisableAll";
|
26
|
+
})(TextHeightBehavior || (TextHeightBehavior = {}));
|
27
27
|
//# sourceMappingURL=ParagraphStyle.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["
|
1
|
+
{"version":3,"names":["TextDirection","TextAlign","TextHeightBehavior"],"sources":["ParagraphStyle.ts"],"sourcesContent":["import type { SkTextFontStyle, SkTextStyle } from \"./TextStyle\";\n\nexport enum TextDirection {\n RTL = 0,\n LTR = 1,\n}\nexport enum TextAlign {\n Left = 0,\n Right,\n Center,\n Justify,\n Start,\n End,\n}\n\nexport interface SkStrutStyle {\n strutEnabled?: boolean;\n fontFamilies?: string[];\n fontStyle?: SkTextFontStyle;\n fontSize?: number;\n heightMultiplier?: number;\n halfLeading?: boolean;\n leading?: number;\n forceStrutHeight?: boolean;\n}\n\nexport enum TextHeightBehavior {\n All = 0x0,\n DisableFirstAscent = 0x1,\n DisableLastDescent = 0x2,\n DisableAll = 0x1 | 0x2,\n}\n\nexport interface SkParagraphStyle {\n disableHinting?: boolean;\n ellipsis?: string;\n heightMultiplier?: number;\n maxLines?: number;\n replaceTabCharacters?: boolean;\n strutStyle?: SkStrutStyle;\n textAlign?: TextAlign;\n textDirection?: TextDirection;\n textHeightBehavior?: TextHeightBehavior;\n textStyle?: SkTextStyle;\n}\n"],"mappings":"AAEA,WAAYA,aAAZ;;WAAYA,a;EAAAA,a,CAAAA,a;EAAAA,a,CAAAA,a;GAAAA,a,KAAAA,a;;AAIZ,WAAYC,SAAZ;;WAAYA,S;EAAAA,S,CAAAA,S;EAAAA,S,CAAAA,S;EAAAA,S,CAAAA,S;EAAAA,S,CAAAA,S;EAAAA,S,CAAAA,S;EAAAA,S,CAAAA,S;GAAAA,S,KAAAA,S;;AAoBZ,WAAYC,kBAAZ;;WAAYA,kB;EAAAA,kB,CAAAA,kB;EAAAA,kB,CAAAA,kB;EAAAA,kB,CAAAA,kB;EAAAA,kB,CAAAA,kB;GAAAA,kB,KAAAA,kB"}
|
@@ -24,7 +24,7 @@ export const processUniforms = (source, uniforms, builder) => {
|
|
24
24
|
const name = source.getUniformName(i);
|
25
25
|
const value = uniforms[name];
|
26
26
|
|
27
|
-
if (
|
27
|
+
if (value === undefined) {
|
28
28
|
throw new Error( // eslint-disable-next-line max-len
|
29
29
|
`The runtime effect has the uniform value "${name}" declared, but it is missing from the uniforms property of the Runtime effect.`);
|
30
30
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["isShader","obj","__typename__","isVector","x","undefined","y","processValue","values","value","push","Array","isArray","forEach","v","Float32Array","processUniforms","source","uniforms","builder","result","uniformsCount","getUniformCount","i","name","getUniformName","Error","uniformValue","setUniform"],"sources":["Shader.ts"],"sourcesContent":["import type { SkJSIInstance } from \"../JsiInstance\";\nimport type { Vector } from \"../Point\";\nimport type { SkRuntimeEffect, SkRuntimeShaderBuilder } from \"../RuntimeEffect\";\n\nexport const isShader = (obj: SkJSIInstance<string> | null): obj is SkShader =>\n obj !== null && obj.__typename__ === \"Shader\";\n\nexport type SkShader = SkJSIInstance<\"Shader\">;\n\nexport type Uniform = number | Vector | Float32Array | Uniform[];\n\nexport interface Uniforms {\n [name: string]: Uniform;\n}\n\nconst isVector = (obj: unknown): obj is Vector =>\n // We have an issue to check property existence on JSI backed instances\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (obj as any).x !== undefined && (obj as any).y !== undefined;\n\nconst processValue = (values: number[], value: Uniform) => {\n if (typeof value === \"number\") {\n values.push(value);\n } else if (Array.isArray(value)) {\n value.forEach((v) => processValue(values, v));\n } else if (isVector(value)) {\n values.push(value.x, value.y);\n } else if (value instanceof Float32Array) {\n values.push(...value);\n }\n};\n\nexport const processUniforms = (\n source: SkRuntimeEffect,\n uniforms: Uniforms,\n builder?: SkRuntimeShaderBuilder\n) => {\n const result: number[] = [];\n const uniformsCount = source.getUniformCount();\n for (let i = 0; i < uniformsCount; i++) {\n const name = source.getUniformName(i);\n const value = uniforms[name];\n if (
|
1
|
+
{"version":3,"names":["isShader","obj","__typename__","isVector","x","undefined","y","processValue","values","value","push","Array","isArray","forEach","v","Float32Array","processUniforms","source","uniforms","builder","result","uniformsCount","getUniformCount","i","name","getUniformName","Error","uniformValue","setUniform"],"sources":["Shader.ts"],"sourcesContent":["import type { SkJSIInstance } from \"../JsiInstance\";\nimport type { Vector } from \"../Point\";\nimport type { SkRuntimeEffect, SkRuntimeShaderBuilder } from \"../RuntimeEffect\";\n\nexport const isShader = (obj: SkJSIInstance<string> | null): obj is SkShader =>\n obj !== null && obj.__typename__ === \"Shader\";\n\nexport type SkShader = SkJSIInstance<\"Shader\">;\n\nexport type Uniform = number | Vector | Float32Array | Uniform[];\n\nexport interface Uniforms {\n [name: string]: Uniform;\n}\n\nconst isVector = (obj: unknown): obj is Vector =>\n // We have an issue to check property existence on JSI backed instances\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (obj as any).x !== undefined && (obj as any).y !== undefined;\n\nconst processValue = (values: number[], value: Uniform) => {\n if (typeof value === \"number\") {\n values.push(value);\n } else if (Array.isArray(value)) {\n value.forEach((v) => processValue(values, v));\n } else if (isVector(value)) {\n values.push(value.x, value.y);\n } else if (value instanceof Float32Array) {\n values.push(...value);\n }\n};\n\nexport const processUniforms = (\n source: SkRuntimeEffect,\n uniforms: Uniforms,\n builder?: SkRuntimeShaderBuilder\n) => {\n const result: number[] = [];\n const uniformsCount = source.getUniformCount();\n for (let i = 0; i < uniformsCount; i++) {\n const name = source.getUniformName(i);\n const value = uniforms[name];\n if (value === undefined) {\n throw new Error(\n // eslint-disable-next-line max-len\n `The runtime effect has the uniform value \"${name}\" declared, but it is missing from the uniforms property of the Runtime effect.`\n );\n }\n if (builder === undefined) {\n processValue(result, value);\n } else {\n const uniformValue: number[] = [];\n processValue(uniformValue, value);\n builder.setUniform(name, uniformValue);\n result.push(...uniformValue);\n }\n }\n return result;\n};\n"],"mappings":"AAIA,OAAO,MAAMA,QAAQ,GAAIC,GAAD,IACtBA,GAAG,KAAK,IAAR,IAAgBA,GAAG,CAACC,YAAJ,KAAqB,QADhC;;AAWP,MAAMC,QAAQ,GAAIF,G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IACD,CAFD,MAEO;MACL,MAAMkB,YAAsB,GAAG,EAA/B;MACApB,YAAY,CAACoB,YAAD,EAAelB,KAAf,CAAZ;MACAU,OAAO,CAACS,UAAR,CAAmBJ,IAAnB,EAAyBG,YAAzB;MACAP,MAAM,CAACV,IAAP,CAAY,GAAGiB,YAAf;IACD;EACF;;EACD,OAAOP,MAAP;AACD,CA1BM"}
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import {
|
1
|
+
import { TextDirection } from "../types";
|
2
2
|
export class JsiSkParagraphStyle {
|
3
3
|
static toParagraphStyle(ck, value) {
|
4
4
|
var _value$disableHinting, _value$ellipsis, _value$heightMultipli, _value$maxLines, _value$replaceTabChar, _ps$strutStyle, _value$strutStyle$fon, _value$strutStyle, _value$strutStyle$fon2, _value$strutStyle2, _value$strutStyle$hei, _value$strutStyle3, _value$strutStyle$lea, _value$strutStyle4, _value$strutStyle$for, _value$strutStyle5, _ps$strutStyle$fontSt, _value$strutStyle6, _value$strutStyle6$fo, _value$strutStyle7, _value$strutStyle7$fo, _value$strutStyle8, _value$strutStyle8$fo, _value$strutStyle$hal, _value$strutStyle9, _value$strutStyle$str, _value$strutStyle10;
|
@@ -19,7 +19,7 @@ export class JsiSkParagraphStyle {
|
|
19
19
|
value: value.textAlign
|
20
20
|
} : undefined !== null && undefined !== void 0 ? undefined : ps.textAlign;
|
21
21
|
ps.textDirection = value.textDirection !== undefined ? {
|
22
|
-
value: value.textDirection ===
|
22
|
+
value: value.textDirection === TextDirection.LTR ? 1 : 0
|
23
23
|
} : ps.textDirection;
|
24
24
|
ps.textHeightBehavior = value.textHeightBehavior !== undefined ? {
|
25
25
|
value: value.textHeightBehavior
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["
|
1
|
+
{"version":3,"names":["TextDirection","JsiSkParagraphStyle","toParagraphStyle","ck","value","ps","ParagraphStyle","textStyle","color","BLACK","disableHinting","ellipsis","heightMultiplier","maxLines","replaceTabCharacters","textAlign","undefined","textDirection","LTR","textHeightBehavior","strutStyle","fontFamilies","fontSize","leading","forceStrutHeight","fontStyle","slant","width","weight","halfLeading","strutEnabled"],"sources":["JsiSkParagraphStyle.ts"],"sourcesContent":["import type { CanvasKit, ParagraphStyle } from \"canvaskit-wasm\";\n\nimport { TextDirection, type SkParagraphStyle } from \"../types\";\n\nexport class JsiSkParagraphStyle {\n static toParagraphStyle(\n ck: CanvasKit,\n value: SkParagraphStyle\n ): ParagraphStyle {\n // Seems like we need to provide the textStyle.color value, otherwise\n // the constructor crashes.\n const ps = new ck.ParagraphStyle({ textStyle: { color: ck.BLACK } });\n\n ps.disableHinting = value.disableHinting ?? ps.disableHinting;\n ps.ellipsis = value.ellipsis ?? ps.ellipsis;\n ps.heightMultiplier = value.heightMultiplier ?? ps.heightMultiplier;\n ps.maxLines = value.maxLines ?? ps.maxLines;\n ps.replaceTabCharacters =\n value.replaceTabCharacters ?? ps.replaceTabCharacters;\n ps.textAlign =\n value.textAlign !== undefined\n ? { value: value.textAlign }\n : undefined ?? ps.textAlign;\n ps.textDirection =\n value.textDirection !== undefined\n ? { value: value.textDirection === TextDirection.LTR ? 1 : 0 }\n : ps.textDirection;\n ps.textHeightBehavior =\n value.textHeightBehavior !== undefined\n ? { value: value.textHeightBehavior }\n : ps.textHeightBehavior;\n\n ps.strutStyle = ps.strutStyle ?? {};\n ps.strutStyle.fontFamilies =\n value.strutStyle?.fontFamilies ?? ps.strutStyle.fontFamilies;\n ps.strutStyle.fontSize =\n value.strutStyle?.fontSize ?? ps.strutStyle.fontSize;\n ps.strutStyle.heightMultiplier =\n value.strutStyle?.heightMultiplier ?? ps.strutStyle.heightMultiplier;\n ps.strutStyle.leading = value.strutStyle?.leading ?? ps.strutStyle.leading;\n ps.strutStyle.forceStrutHeight =\n value.strutStyle?.forceStrutHeight ?? ps.strutStyle.forceStrutHeight;\n\n ps.strutStyle.fontStyle = ps.strutStyle.fontStyle ?? {};\n\n ps.strutStyle.fontStyle.slant =\n value.strutStyle?.fontStyle?.slant !== undefined\n ? { value: value.strutStyle.fontStyle.slant }\n : ps.strutStyle.fontStyle.slant;\n ps.strutStyle.fontStyle.width =\n value.strutStyle?.fontStyle?.width !== undefined\n ? { value: value.strutStyle.fontStyle.width }\n : ps.strutStyle.fontStyle.width;\n ps.strutStyle.fontStyle.weight =\n value.strutStyle?.fontStyle?.weight !== undefined\n ? { value: value.strutStyle.fontStyle.weight }\n : ps.strutStyle.fontStyle.weight;\n ps.strutStyle.halfLeading =\n value.strutStyle?.halfLeading ?? ps.strutStyle.halfLeading;\n ps.strutStyle.strutEnabled =\n value.strutStyle?.strutEnabled ?? ps.strutStyle.strutEnabled;\n\n return ps;\n }\n}\n"],"mappings":"AAEA,SAASA,aAAT,QAAqD,UAArD;AAEA,OAAO,MAAMC,mBAAN,CAA0B;EACR,OAAhBC,gBAAgB,CACrBC,EADqB,EAErBC,KAFqB,EAGL;IAAA;;IAChB;IACA;IACA,MAAMC,EAAE,GAAG,IAAIF,EAAE,CAACG,cAAP,CAAsB;MAAEC,SAAS,EAAE;QAAEC,KAAK,EAAEL,EAAE,CAACM;MAAZ;IAAb,CAAtB,CAAX;IAEAJ,EAAE,CAACK,cAAH,4BAAoBN,KAAK,CAACM,cAA1B,yEAA4CL,EAAE,CAACK,cAA/C;IACAL,EAAE,CAACM,QAAH,sBAAcP,KAAK,CAACO,QAApB,6DAAgCN,EAAE,CAACM,QAAnC;IACAN,EAAE,CAACO,gBAAH,4BAAsBR,KAAK,CAACQ,gBAA5B,yEAAgDP,EAAE,CAACO,gBAAnD;IACAP,EAAE,CAACQ,QAAH,sBAAcT,KAAK,CAACS,QAApB,6DAAgCR,EAAE,CAACQ,QAAnC;IACAR,EAAE,CAACS,oBAAH,4BACEV,KAAK,CAACU,oBADR,yEACgCT,EAAE,CAACS,oBADnC;IAEAT,EAAE,CAACU,SAAH,GACEX,KAAK,CAACW,SAAN,KAAoBC,SAApB,GACI;MAAEZ,KAAK,EAAEA,KAAK,CAACW;IAAf,CADJ,GAEI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skit-wasm/bin/full/canvaskit";
|
4
|
+
let ckSharedPromise;
|
4
5
|
export const LoadSkiaWeb = async opts => {
|
6
|
+
var _ckSharedPromise;
|
7
|
+
|
5
8
|
if (global.CanvasKit !== undefined) {
|
6
9
|
return;
|
7
10
|
}
|
8
11
|
|
9
|
-
|
12
|
+
ckSharedPromise = (_ckSharedPromise = ckSharedPromise) !== null && _ckSharedPromise !== void 0 ? _ckSharedPromise : CanvasKitInit(opts);
|
13
|
+
const CanvasKit = await ckSharedPromise; // The CanvasKit API is stored on the global object and used
|
10
14
|
// to create the JsiSKApi in the Skia.web.ts file.
|
11
15
|
|
12
16
|
global.CanvasKit = CanvasKit;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["CanvasKitInit","LoadSkiaWeb","opts","global","CanvasKit","undefined","LoadSkia"],"sources":["LoadSkiaWeb.tsx"],"sourcesContent":["// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-ignore\nimport CanvasKitInit from \"canvaskit-wasm/bin/full/canvaskit\";\nimport type {\n CanvasKit as CanvasKitType,\n CanvasKitInitOptions,\n} from \"canvaskit-wasm\";\n\ndeclare global {\n var CanvasKit: CanvasKitType;\n}\n\nexport const LoadSkiaWeb = async (opts?: CanvasKitInitOptions) => {\n if (global.CanvasKit !== undefined) {\n return;\n }\n
|
1
|
+
{"version":3,"names":["CanvasKitInit","ckSharedPromise","LoadSkiaWeb","opts","global","CanvasKit","undefined","LoadSkia"],"sources":["LoadSkiaWeb.tsx"],"sourcesContent":["// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-ignore\nimport CanvasKitInit from \"canvaskit-wasm/bin/full/canvaskit\";\nimport type {\n CanvasKit as CanvasKitType,\n CanvasKitInitOptions,\n} from \"canvaskit-wasm\";\n\ndeclare global {\n var CanvasKit: CanvasKitType;\n}\n\nlet ckSharedPromise: Promise<CanvasKitType>;\n\nexport const LoadSkiaWeb = async (opts?: CanvasKitInitOptions) => {\n if (global.CanvasKit !== undefined) {\n return;\n }\n ckSharedPromise = ckSharedPromise ?? CanvasKitInit(opts);\n const CanvasKit = await ckSharedPromise;\n // The CanvasKit API is stored on the global object and used\n // to create the JsiSKApi in the Skia.web.ts file.\n global.CanvasKit = CanvasKit;\n};\n\n// We keep this function for backward compatibility\nexport const LoadSkia = LoadSkiaWeb;\n"],"mappings":"AAAA;AACA;AACA,OAAOA,aAAP,MAA0B,mCAA1B;AAUA,IAAIC,eAAJ;AAEA,OAAO,MAAMC,WAAW,GAAG,MAAOC,IAAP,IAAuC;EAAA;;EAChE,IAAIC,MAAM,CAACC,SAAP,KAAqBC,SAAzB,EAAoC;IAClC;EACD;;EACDL,eAAe,uBAAGA,eAAH,+DAAsBD,aAAa,CAACG,IAAD,CAAlD;EACA,MAAME,SAAS,GAAG,MAAMJ,eAAxB,CALgE,CAMhE;EACA;;EACAG,MAAM,CAACC,SAAP,GAAmBA,SAAnB;AACD,CATM,C,CAWP;;AACA,OAAO,MAAME,QAAQ,GAAGL,WAAjB"}
|
@@ -4,6 +4,7 @@ type Point = {
|
|
4
4
|
};
|
5
5
|
type Vec2 = readonly [number, number];
|
6
6
|
type Vec3 = readonly [number, number, number];
|
7
|
+
type Vec4 = readonly [number, number, number, number];
|
7
8
|
export type Matrix3 = readonly [
|
8
9
|
number,
|
9
10
|
number,
|
@@ -51,6 +52,10 @@ export declare const translate: (x: number, y: number, z?: number) => Matrix4;
|
|
51
52
|
* @worklet
|
52
53
|
*/
|
53
54
|
export declare const perspective: (p: number) => Matrix4;
|
55
|
+
/**
|
56
|
+
* @worklet
|
57
|
+
*/
|
58
|
+
export declare const matrixVecMul4: (m: Matrix4, v: Vec4) => Vec4;
|
54
59
|
/**
|
55
60
|
* @worklet
|
56
61
|
*/
|
@@ -1,10 +1,10 @@
|
|
1
1
|
import type { SkCanvas } from "../Canvas";
|
2
2
|
import type { SkJSIInstance } from "../JsiInstance";
|
3
3
|
import type { SkRect } from "../Rect";
|
4
|
-
import type {
|
4
|
+
import type { TextDirection } from "./ParagraphStyle";
|
5
5
|
export interface SkRectWithDirection {
|
6
6
|
rect: SkRect;
|
7
|
-
direction:
|
7
|
+
direction: TextDirection;
|
8
8
|
}
|
9
9
|
export interface SkParagraph extends SkJSIInstance<"Paragraph"> {
|
10
10
|
/**
|
@@ -1,9 +1,9 @@
|
|
1
1
|
import type { SkTextFontStyle, SkTextStyle } from "./TextStyle";
|
2
|
-
export declare enum
|
2
|
+
export declare enum TextDirection {
|
3
3
|
RTL = 0,
|
4
4
|
LTR = 1
|
5
5
|
}
|
6
|
-
export declare enum
|
6
|
+
export declare enum TextAlign {
|
7
7
|
Left = 0,
|
8
8
|
Right = 1,
|
9
9
|
Center = 2,
|
@@ -21,7 +21,7 @@ export interface SkStrutStyle {
|
|
21
21
|
leading?: number;
|
22
22
|
forceStrutHeight?: boolean;
|
23
23
|
}
|
24
|
-
export declare enum
|
24
|
+
export declare enum TextHeightBehavior {
|
25
25
|
All = 0,
|
26
26
|
DisableFirstAscent = 1,
|
27
27
|
DisableLastDescent = 2,
|
@@ -34,8 +34,8 @@ export interface SkParagraphStyle {
|
|
34
34
|
maxLines?: number;
|
35
35
|
replaceTabCharacters?: boolean;
|
36
36
|
strutStyle?: SkStrutStyle;
|
37
|
-
textAlign?:
|
38
|
-
textDirection?:
|
39
|
-
textHeightBehavior?:
|
37
|
+
textAlign?: TextAlign;
|
38
|
+
textDirection?: TextDirection;
|
39
|
+
textHeightBehavior?: TextHeightBehavior;
|
40
40
|
textStyle?: SkTextStyle;
|
41
41
|
}
|
package/package.json
CHANGED
@@ -23,21 +23,8 @@ export class TextNode extends JsiDrawingNode<TextProps, SkFont | null> {
|
|
23
23
|
|
24
24
|
protected deriveProps() {
|
25
25
|
const { font } = this.props;
|
26
|
-
if (font
|
27
|
-
return null;
|
28
|
-
} else if (font === undefined) {
|
29
|
-
console.warn(
|
30
|
-
"<Text />: the font property is mandatory on React Native Web"
|
31
|
-
);
|
26
|
+
if (!font) {
|
32
27
|
return null;
|
33
|
-
// return this.Skia.Font(
|
34
|
-
// this.Skia.FontMgr.System().matchFamilyStyle("System", {
|
35
|
-
// width: 5,
|
36
|
-
// weight: 400,
|
37
|
-
// slant: 0,
|
38
|
-
// }),
|
39
|
-
// 14
|
40
|
-
// );
|
41
28
|
}
|
42
29
|
return font;
|
43
30
|
}
|
package/src/renderer/Canvas.tsx
CHANGED
@@ -84,6 +84,12 @@ export const Canvas = forwardRef<SkiaDomView, CanvasProps>(
|
|
84
84
|
root.render(children);
|
85
85
|
}, [children, root, redraw]);
|
86
86
|
|
87
|
+
useEffect(() => {
|
88
|
+
return () => {
|
89
|
+
root.unmount();
|
90
|
+
};
|
91
|
+
}, [root]);
|
92
|
+
|
87
93
|
if (NATIVE_DOM) {
|
88
94
|
return (
|
89
95
|
<SkiaDomView
|
@@ -150,14 +150,16 @@ const rotatedUnitSinCos = (
|
|
150
150
|
];
|
151
151
|
};
|
152
152
|
|
153
|
-
|
153
|
+
/**
|
154
|
+
* @worklet
|
155
|
+
*/
|
156
|
+
export const matrixVecMul4 = (m: Matrix4, v: Vec4): Vec4 => {
|
154
157
|
"worklet";
|
155
|
-
const [vx, vy, vz, vw] = v;
|
156
158
|
return [
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
159
|
+
m[0] * v[0] + m[1] * v[1] + m[2] * v[2] + m[3] * v[3],
|
160
|
+
m[4] * v[0] + m[5] * v[1] + m[6] * v[2] + m[7] * v[3],
|
161
|
+
m[8] * v[0] + m[9] * v[1] + m[10] * v[2] + m[11] * v[3],
|
162
|
+
m[12] * v[0] + m[13] * v[1] + m[14] * v[2] + m[15] * v[3],
|
161
163
|
];
|
162
164
|
};
|
163
165
|
|
@@ -2,11 +2,11 @@ import type { SkCanvas } from "../Canvas";
|
|
2
2
|
import type { SkJSIInstance } from "../JsiInstance";
|
3
3
|
import type { SkRect } from "../Rect";
|
4
4
|
|
5
|
-
import type {
|
5
|
+
import type { TextDirection } from "./ParagraphStyle";
|
6
6
|
|
7
7
|
export interface SkRectWithDirection {
|
8
8
|
rect: SkRect;
|
9
|
-
direction:
|
9
|
+
direction: TextDirection;
|
10
10
|
}
|
11
11
|
|
12
12
|
export interface SkParagraph extends SkJSIInstance<"Paragraph"> {
|
@@ -1,10 +1,10 @@
|
|
1
1
|
import type { SkTextFontStyle, SkTextStyle } from "./TextStyle";
|
2
2
|
|
3
|
-
export enum
|
3
|
+
export enum TextDirection {
|
4
4
|
RTL = 0,
|
5
5
|
LTR = 1,
|
6
6
|
}
|
7
|
-
export enum
|
7
|
+
export enum TextAlign {
|
8
8
|
Left = 0,
|
9
9
|
Right,
|
10
10
|
Center,
|
@@ -24,7 +24,7 @@ export interface SkStrutStyle {
|
|
24
24
|
forceStrutHeight?: boolean;
|
25
25
|
}
|
26
26
|
|
27
|
-
export enum
|
27
|
+
export enum TextHeightBehavior {
|
28
28
|
All = 0x0,
|
29
29
|
DisableFirstAscent = 0x1,
|
30
30
|
DisableLastDescent = 0x2,
|
@@ -38,8 +38,8 @@ export interface SkParagraphStyle {
|
|
38
38
|
maxLines?: number;
|
39
39
|
replaceTabCharacters?: boolean;
|
40
40
|
strutStyle?: SkStrutStyle;
|
41
|
-
textAlign?:
|
42
|
-
textDirection?:
|
43
|
-
textHeightBehavior?:
|
41
|
+
textAlign?: TextAlign;
|
42
|
+
textDirection?: TextDirection;
|
43
|
+
textHeightBehavior?: TextHeightBehavior;
|
44
44
|
textStyle?: SkTextStyle;
|
45
45
|
}
|
@@ -40,7 +40,7 @@ export const processUniforms = (
|
|
40
40
|
for (let i = 0; i < uniformsCount; i++) {
|
41
41
|
const name = source.getUniformName(i);
|
42
42
|
const value = uniforms[name];
|
43
|
-
if (
|
43
|
+
if (value === undefined) {
|
44
44
|
throw new Error(
|
45
45
|
// eslint-disable-next-line max-len
|
46
46
|
`The runtime effect has the uniform value "${name}" declared, but it is missing from the uniforms property of the Runtime effect.`
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import type { CanvasKit, ParagraphStyle } from "canvaskit-wasm";
|
2
2
|
|
3
|
-
import {
|
3
|
+
import { TextDirection, type SkParagraphStyle } from "../types";
|
4
4
|
|
5
5
|
export class JsiSkParagraphStyle {
|
6
6
|
static toParagraphStyle(
|
@@ -23,7 +23,7 @@ export class JsiSkParagraphStyle {
|
|
23
23
|
: undefined ?? ps.textAlign;
|
24
24
|
ps.textDirection =
|
25
25
|
value.textDirection !== undefined
|
26
|
-
? { value: value.textDirection ===
|
26
|
+
? { value: value.textDirection === TextDirection.LTR ? 1 : 0 }
|
27
27
|
: ps.textDirection;
|
28
28
|
ps.textHeightBehavior =
|
29
29
|
value.textHeightBehavior !== undefined
|
package/src/web/LoadSkiaWeb.tsx
CHANGED
@@ -10,11 +10,14 @@ declare global {
|
|
10
10
|
var CanvasKit: CanvasKitType;
|
11
11
|
}
|
12
12
|
|
13
|
+
let ckSharedPromise: Promise<CanvasKitType>;
|
14
|
+
|
13
15
|
export const LoadSkiaWeb = async (opts?: CanvasKitInitOptions) => {
|
14
16
|
if (global.CanvasKit !== undefined) {
|
15
17
|
return;
|
16
18
|
}
|
17
|
-
|
19
|
+
ckSharedPromise = ckSharedPromise ?? CanvasKitInit(opts);
|
20
|
+
const CanvasKit = await ckSharedPromise;
|
18
21
|
// The CanvasKit API is stored on the global object and used
|
19
22
|
// to create the JsiSKApi in the Skia.web.ts file.
|
20
23
|
global.CanvasKit = CanvasKit;
|