onejs-core 0.3.8 → 0.3.10

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/package.json CHANGED
@@ -1,9 +1,15 @@
1
1
  {
2
2
  "name": "onejs-core",
3
3
  "description": "The JS part of OneJS, a UI framework and Scripting Engine for Unity.",
4
- "version": "0.3.8",
4
+ "version": "0.3.10",
5
5
  "main": "dist/index.js",
6
6
  "types": "typings.d.ts",
7
+ "files": [
8
+ "dist",
9
+ "definitions",
10
+ "scripts",
11
+ "typings.d.ts"
12
+ ],
7
13
  "dependencies": {
8
14
  "css-flatten": "^2.0.0",
9
15
  "css-simple-parser": "^3.0.0"
@@ -0,0 +1,92 @@
1
+ /**
2
+ * Contains code from Nick Janetakis's esbuild-copy-static-files (MIT)
3
+ */
4
+ import path from 'path'
5
+ import fs from 'fs'
6
+ import crypto from 'crypto'
7
+
8
+ function getPackagesWithAssets() {
9
+ let packagesWithAssets = [];
10
+ const nodeModulesPath = path.join(process.cwd(), 'node_modules');
11
+ const packages = fs.readdirSync(nodeModulesPath);
12
+ // console.log("There are " + packages.length + " packages in node_modules");
13
+ for (const packageName of packages) {
14
+ const pkgJsonPath = path.join(nodeModulesPath, packageName, 'package.json');
15
+
16
+ try {
17
+ const pkgJsonContent = fs.readFileSync(pkgJsonPath, 'utf8');
18
+ const pkgJson = JSON.parse(pkgJsonContent);
19
+
20
+ if (pkgJson.onejs && pkgJson.onejs['assets-path']) {
21
+
22
+ packagesWithAssets.push({
23
+ name: packageName,
24
+ src: path.join("node_modules", packageName, pkgJson.onejs['assets-path'])
25
+ });
26
+ }
27
+ } catch (error) {
28
+ if (error.code !== 'ENOENT') {
29
+ console.error(`Error processing ${packageName}:`, error);
30
+ }
31
+ }
32
+ }
33
+
34
+ // console.log("Found " + packagesWithAssets.length + " packages with assets");
35
+ return packagesWithAssets
36
+ }
37
+
38
+ const getDigest = (string) => {
39
+ const hash = crypto.createHash('md5')
40
+ const data = hash.update(string, 'utf-8')
41
+
42
+ return data.digest('hex')
43
+ }
44
+
45
+ const getFileDigest = (path) => {
46
+ if (!fs.existsSync(path)) {
47
+ return null
48
+ }
49
+
50
+ if (fs.statSync(path).isDirectory()) {
51
+ return null
52
+ }
53
+
54
+ return getDigest(fs.readFileSync(path))
55
+ }
56
+
57
+ function filter(src, dest) {
58
+ if (!fs.existsSync(dest)) {
59
+ return true
60
+ }
61
+
62
+ if (fs.statSync(dest).isDirectory()) {
63
+ return true
64
+ }
65
+
66
+ return getFileDigest(src) !== getFileDigest(dest)
67
+ }
68
+
69
+ export function copyAssetsPlugin(options = {}) {
70
+ let dest = options.dest || 'assets'
71
+ return {
72
+ name: "onejs-copy-assets",
73
+ setup(build) {
74
+ build.onEnd(async () => {
75
+ const packagesWithAssets = getPackagesWithAssets();
76
+ console.log(`[esbuild] syncing assets from:`)
77
+ for (const pkg of packagesWithAssets) {
78
+ const destPath = path.join(dest, "@" + pkg.name);
79
+ fs.cpSync(pkg.src, destPath, {
80
+ dereference: options.dereference || true,
81
+ errorOnExist: options.errorOnExist || false,
82
+ filter: options.filter || filter,
83
+ force: options.force || true,
84
+ preserveTimestamps: options.preserveTimestamps || true,
85
+ recursive: options.recursive || true,
86
+ })
87
+ console.log(`[esbuild] > ${pkg.name}`)
88
+ }
89
+ })
90
+ }
91
+ }
92
+ }
@@ -41,22 +41,3 @@ export const importTransformPlugin = {
41
41
  },
42
42
  };
43
43
 
44
- export const watchOutputPlugin = {
45
- name: "onejs-watch-output",
46
- setup(build) {
47
- build.onStart(() => {
48
- // Clear the terminal
49
- process.stdout.write('\x1Bc');
50
- console.log("[esbuild] starting build...");
51
- });
52
-
53
- build.onEnd((result) => {
54
- // if (result.errors.length > 0) {
55
- // console.error("[esbuild] build failed");
56
- // } else {
57
- // console.log("[esbuild] build succeeded");
58
- // }
59
- console.log("[esbuild] watching...");
60
- });
61
- }
62
- }
@@ -0,0 +1,3 @@
1
+ export * from "./import-transform.mjs"
2
+ export * from "./watch-output.mjs"
3
+ export * from "./copy-assets.mjs"
@@ -0,0 +1,19 @@
1
+ export const watchOutputPlugin = {
2
+ name: "onejs-watch-output",
3
+ setup(build) {
4
+ build.onStart(() => {
5
+ // Clear the terminal
6
+ process.stdout.write('\x1Bc');
7
+ console.log("[esbuild] starting build...");
8
+ });
9
+
10
+ build.onEnd((result) => {
11
+ // if (result.errors.length > 0) {
12
+ // console.error("[esbuild] build failed");
13
+ // } else {
14
+ // console.log("[esbuild] build succeeded");
15
+ // }
16
+ console.log("[esbuild] watching...");
17
+ });
18
+ }
19
+ }
@@ -64,30 +64,39 @@ exports.plugins = [
64
64
  ".duration-1000": { "transition-duration": "1000ms" },
65
65
  ".scale-none": { scale: "none" },
66
66
  ".rotate-none": { rotate: "none" },
67
+ ".text-left": { "-unity-text-align": "middle-left" },
68
+ ".text-center": { "-unity-text-align": "middle-center" },
69
+ ".text-right": { "-unity-text-align": "middle-right" },
70
+ ".text-upper-left": { "-unity-text-align": "upper-left" },
71
+ ".text-upper-center": { "-unity-text-align": "upper-center" },
72
+ ".text-upper-right": { "-unity-text-align": "upper-right" },
73
+ ".text-lower-left": { "-unity-text-align": "lower-left" },
74
+ ".text-lower-center": { "-unity-text-align": "lower-center" },
75
+ ".text-lower-right": { "-unity-text-align": "lower-right" },
67
76
  })
68
77
 
69
78
  matchUtilities({
70
79
  fontdef: (value) => ({ "-unity-font-definition": `url("${value}")` }),
71
80
  }, {})
72
81
 
73
- matchUtilities(
74
- {
75
- text: (value) => ({ "-unity-text-align": value }),
76
- },
77
- {
78
- values: {
79
- left: "middle-left",
80
- center: "middle-center",
81
- right: "middle-right",
82
- "upper-left": "upper-left",
83
- "upper-center": "upper-center",
84
- "upper-right": "upper-right",
85
- "lower-left": "lower-left",
86
- "lower-center": "lower-center",
87
- "lower-right": "lower-right",
88
- },
89
- }
90
- )
82
+ // matchUtilities(
83
+ // {
84
+ // text: (value) => ({ "-unity-text-align": value }), // This will conflict with text colors, etc
85
+ // },
86
+ // {
87
+ // values: {
88
+ // left: "middle-left",
89
+ // center: "middle-center",
90
+ // right: "middle-right",
91
+ // "upper-left": "upper-left",
92
+ // "upper-center": "upper-center",
93
+ // "upper-right": "upper-right",
94
+ // "lower-left": "lower-left",
95
+ // "lower-center": "lower-center",
96
+ // "lower-right": "lower-right",
97
+ // },
98
+ // }
99
+ // )
91
100
 
92
101
  matchUtilities(
93
102
  {
package/typings.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  /// <reference path="./definitions/index.d.ts" />
2
2
  /// <reference path="./dist/index.d.ts" />
3
3
 
4
- export * from './dist/index';
4
+ export * from './dist/index';
5
+ export * from './definitions/index';
package/.gitattributes DELETED
@@ -1,2 +0,0 @@
1
- # Auto detect text files and perform LF normalization
2
- * text=auto
@@ -1,19 +0,0 @@
1
- # name: Publish
2
- # on:
3
- # push:
4
- # branches:
5
- # - main
6
-
7
- # jobs:
8
- # publish:
9
- # runs-on: ubuntu-latest
10
-
11
- # permissions:
12
- # contents: read
13
- # id-token: write
14
-
15
- # steps:
16
- # - uses: actions/checkout@v4
17
-
18
- # - name: Publish package
19
- # run: npx jsr publish
package/.prettierrc DELETED
@@ -1,5 +0,0 @@
1
- {
2
- "printWidth": 120,
3
- "semi": false,
4
- "tabWidth": 4
5
- }
@@ -1,6 +0,0 @@
1
- {
2
- "search.exclude": {
3
- "**/dist": true,
4
- "**/node_modules": true,
5
- }
6
- }
@@ -1,3 +0,0 @@
1
- This onejs-core folder is managed by OneJS. It may get overriden during OneJS version updates. If you make any changes in here and would like to keep them, please back them up!
2
-
3
- However, you may replace this folder with the actual repository at https://github.com/DragonGround/onejs-core if that fits your workflow better. OneJS won't delete/replace any folder with a .git folder inside.
package/dom/document.ts DELETED
@@ -1,34 +0,0 @@
1
- import { DomWrapper } from "./dom"
2
-
3
- interface ElementCreationOptions {
4
- is?: string
5
- }
6
-
7
- export class DocumentWrapper {
8
- #doc: CS.OneJS.Dom.Document;
9
- #body: DomWrapper;
10
-
11
- public get body(): DomWrapper { return this.#body }
12
-
13
- constructor(doc: CS.OneJS.Dom.Document) {
14
- this.#doc = doc
15
- this.#body = new DomWrapper(doc.body)
16
- }
17
-
18
- addRuntimeUSS(uss: string): void {
19
- this.#doc.addRuntimeUSS(uss)
20
- }
21
-
22
- createElement(tagName: string, options?: ElementCreationOptions): DomWrapper {
23
- return new DomWrapper(this.#doc.createElement(tagName))
24
- }
25
-
26
- createElementNS(ns: string, tagName: string, options: ElementCreationOptions): DomWrapper {
27
- return new DomWrapper(this.#doc.createElement(tagName))
28
- }
29
-
30
-
31
- createTextNode(text: string): DomWrapper {
32
- return new DomWrapper(this.#doc.createTextNode(text))
33
- }
34
- }
package/dom/dom-style.ts DELETED
@@ -1,25 +0,0 @@
1
-
2
-
3
- export class DomStyleWrapper implements CS.OneJS.Dom.DomStyle {
4
- #domStyle: CS.OneJS.Dom.DomStyle
5
-
6
- constructor(domStyle: CS.OneJS.Dom.DomStyle) {
7
- this.#domStyle = domStyle
8
-
9
- return new Proxy(this, {
10
- set(target, prop, value) {
11
- target.setProperty(prop as string, value);
12
- return true;
13
- },
14
- get(target, prop) {
15
- return target[prop];
16
- }
17
- })
18
- }
19
-
20
- setProperty(name: string, value: any) {
21
- this.#domStyle.setProperty(name, value)
22
- }
23
- }
24
-
25
- export interface DomStyleWrapper extends CS.OneJS.Dom.DomStyle { }
package/dom/dom.ts DELETED
@@ -1,76 +0,0 @@
1
- import { DomStyleWrapper } from "./dom-style"
2
-
3
- export class DomWrapper {
4
- public get _dom(): CS.OneJS.Dom.Dom { return this.#dom }
5
- public get ve(): CS.UnityEngine.UIElements.VisualElement { return this.#dom.ve }
6
- public get childNodes(): DomWrapper[] { return (this.#dom.childNodes as any as CS.OneJS.Dom.Dom[]).map((child) => new DomWrapper(child)) }
7
- public get firstChild(): DomWrapper | null {
8
- return this.#dom.firstChild ? new DomWrapper(this.#dom.firstChild) : null;
9
- }
10
- public get parentNode(): DomWrapper | null {
11
- return this.#dom.parentNode ? new DomWrapper(this.#dom.parentNode) : null;
12
- }
13
- public get nextSibling(): DomWrapper | null {
14
- return this.#dom.nextSibling ? new DomWrapper(this.#dom.nextSibling) : null;
15
- }
16
-
17
- public get nodeType(): number { return this.#dom.nodeType }
18
- public get Id(): string { return this.#dom.Id }
19
- public set Id(value: string) { this.#dom.Id = value }
20
- public get key(): string { return this.#dom.key }
21
- public set key(value: string) { this.#dom.key = value }
22
- public get style(): DomStyleWrapper { return this.#domStyleWrapper }
23
- public get value(): any { return this.#dom.value }
24
- public get checked(): boolean { return this.#dom.checked }
25
- public get data(): any { return this.#dom.data }
26
- public set data(value: any) { this.#dom.data = value }
27
-
28
- public get classname(): string { return this.#dom.classname }
29
- public set classname(value: string) { this.#dom.classname = value }
30
-
31
- #dom: CS.OneJS.Dom.Dom
32
- #domStyleWrapper: DomStyleWrapper
33
-
34
- constructor(dom: CS.OneJS.Dom.Dom) {
35
- this.#dom = dom
36
- this.#domStyleWrapper = new DomStyleWrapper(dom.style)
37
- }
38
-
39
- appendChild(child: DomWrapper) {
40
- this.#dom.appendChild(child.#dom)
41
- }
42
-
43
- removeChild(child: DomWrapper) {
44
- this.#dom.removeChild(child.#dom)
45
- }
46
-
47
- insertBefore(a: DomWrapper, b: DomWrapper) {
48
- this.#dom.insertBefore(a?._dom, b?._dom)
49
- }
50
-
51
- clearChildren() {
52
- this.#dom.clearChildren()
53
- }
54
-
55
- focus() {
56
- this.#dom.focus()
57
- }
58
-
59
- addEventListener(type: string, listener: (event: Event) => void, useCapture?: boolean) {
60
- // @ts-ignore
61
- this.#dom.addEventListener(type, listener.bind(this), useCapture)
62
- }
63
-
64
- removeEventListener(type: string, listener: (event: Event) => void, useCapture?: boolean) {
65
- // @ts-ignore
66
- this.#dom.removeEventListener(type, listener.bind(this), useCapture)
67
- }
68
-
69
- setAttribute(name: string, value: any) {
70
- this.#dom.setAttribute(name, value)
71
- }
72
-
73
- removeAttribute(name: string) {
74
- this.#dom.removeAttribute(name)
75
- }
76
- }
package/index.ts DELETED
@@ -1,49 +0,0 @@
1
- import { DocumentWrapper } from "./dom/document";
2
- import { DomWrapper } from "./dom/dom";
3
-
4
- /**
5
- * OneJS's own h function. Use this to quickly create elements in jsx-like syntax
6
- * @param type
7
- * @param props
8
- * @param children
9
- * @returns
10
- */
11
- export function h(type: any, props: any, ...children: any[]): any {
12
- const element = typeof type === "string" ? document.createElement(type) : type;
13
-
14
- // Assign properties to the element
15
- for (const [key, value] of Object.entries(props || {})) {
16
- if (key.startsWith("on") && typeof value === "function") {
17
- element.addEventListener(key.substring(2).toLowerCase(), value);
18
- } else if (key === "style" && typeof value === "object") {
19
- Object.assign(element.style, value);
20
- } else {
21
- element.setAttribute(key, value);
22
- }
23
- }
24
-
25
- // Append children
26
- for (const child of children) {
27
- if (typeof child === "string") {
28
- element.appendChild(document.createTextNode(child));
29
- } else {
30
- element.appendChild(child);
31
- }
32
- }
33
-
34
- return element;
35
- }
36
-
37
- export { emo } from "./styling/index"
38
-
39
- declare global {
40
- interface Document extends DocumentWrapper {}
41
- interface Element extends DomWrapper {
42
- classname: string
43
- nodeType: number
44
- ve: CS.UnityEngine.UIElements.VisualElement
45
- }
46
- }
47
-
48
- // @ts-ignore
49
- globalThis.document = new DocumentWrapper(___document)
package/jsr.json DELETED
@@ -1,10 +0,0 @@
1
- {
2
- "name": "@onejs/core",
3
- "version": "0.1.20",
4
- "exports": {
5
- ".": "./index.ts",
6
- "./utils": "./index.ts",
7
- "./uss-transform-plugin.cjs": "./uss-transform-plugin.cjs",
8
- "./onejs-tw-config.cjs": "./onejs-tw-config.cjs"
9
- }
10
- }
@@ -1,44 +0,0 @@
1
-
2
-
3
- export function btoa(text: string): string {
4
- // return CS.OneJS.CommonGlobals.btoa(text);
5
- const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
6
- let str = text;
7
- let output = '';
8
-
9
- for (let i = 0; i < str.length; i += 3) {
10
- let block = (str.charCodeAt(i) << 16) | ((i + 1 < str.length ? str.charCodeAt(i + 1) : 0) << 8) | (i + 2 < str.length ? str.charCodeAt(i + 2) : 0);
11
- output += chars[(block >> 18) & 0x3F] +
12
- chars[(block >> 12) & 0x3F] +
13
- (i + 1 < str.length ? chars[(block >> 6) & 0x3F] : '=') +
14
- (i + 2 < str.length ? chars[block & 0x3F] : '=');
15
- }
16
-
17
- return output;
18
- }
19
-
20
- // function uint8ArrayToString(uint8Array) {
21
- // const chars: any = [];
22
- // for (let i = 0; i < uint8Array.length; i++) {
23
- // chars.push(String.fromCharCode(uint8Array[i]));
24
- // }
25
- // return chars.join('');
26
- // }
27
-
28
- export function atob(base64: string): string {
29
- // return CS.OneJS.CommonGlobals.atob(base64);
30
- // return CS.System.Text.Encoding.UTF8.GetString(CS.System.Convert.FromBase64String(base64))
31
- const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
32
- let str = base64.replace(/=+$/, '');
33
- let output = '';
34
-
35
- if (str.length % 4 == 1) {
36
- throw new Error('Invalid base64 string');
37
- }
38
-
39
- for (let bc = 0, bs = 0, buffer, idx = 0; buffer = str.charAt(idx++); ~buffer && (bs = bc % 4 ? bs * 64 + buffer : buffer, bc++ % 4) ? output += String.fromCharCode(255 & bs >> (-2 * bc & 6)) : 0) {
40
- buffer = chars.indexOf(buffer);
41
- }
42
-
43
- return output;
44
- }
package/styling/index.tsx DELETED
@@ -1,27 +0,0 @@
1
- import flatten from "css-flatten"
2
- import generateComponentId from "./utils/generateComponentId"
3
-
4
- export function hashAndAddRuntimeUSS(style: string) {
5
- let compId = generateComponentId(style)
6
- style = `.${compId} {${style}}`
7
- style = flatten(style)
8
- document.addRuntimeUSS(style)
9
-
10
- return compId
11
- }
12
-
13
- /**
14
- * Similar to the Emotion api, this function takes a template string and returns
15
- * a class name that can be used to style an element.
16
- * @param strings
17
- * @param values
18
- * @returns
19
- */
20
- export const emo = function (strings: TemplateStringsArray, ...values: any[]): string {
21
- let style = values.reduce((result, expr, index) => {
22
- const value = expr
23
- return result + (value ? value : "") + strings[index + 1]
24
- }, strings[0])
25
-
26
- return hashAndAddRuntimeUSS(style)
27
- }
@@ -1,21 +0,0 @@
1
- const AD_REPLACER_R = /(a)(d)/gi
2
-
3
- /* This is the "capacity" of our alphabet i.e. 2x26 for all letters plus their capitalised
4
- * counterparts */
5
- const charsLength = 52
6
-
7
- /* start at 75 for 'a' until 'z' (25) and then start at 65 for capitalised letters */
8
- const getAlphabeticChar = (code: number) => String.fromCharCode(code + (code > 25 ? 39 : 97));
9
-
10
- /* input a number, usually a hash and convert it to base-52 */
11
- export default function generateAlphabeticName(code: number) {
12
- let name = ''
13
- let x
14
-
15
- /* get a char and divide by alphabet-length */
16
- for (x = Math.abs(code); x > charsLength; x = (x / charsLength) | 0) {
17
- name = getAlphabeticChar(x % charsLength) + name
18
- }
19
-
20
- return (getAlphabeticChar(x % charsLength) + name).replace(AD_REPLACER_R, '$1-$2')
21
- }
@@ -1,6 +0,0 @@
1
- import generateAlphabeticName from './generateAlphabeticName'
2
- import { hash } from './hash'
3
-
4
- export default function generateComponentId(str: string) {
5
- return generateAlphabeticName(hash(str) >>> 0)
6
- }
@@ -1,46 +0,0 @@
1
- export const SEED = 5381;
2
-
3
- // When we have separate strings it's useful to run a progressive
4
- // version of djb2 where we pretend that we're still looping over
5
- // the same string
6
- export const phash = (h: number, x: string) => {
7
- let i = x.length;
8
-
9
- while (i) {
10
- h = (h * 33) ^ x.charCodeAt(--i);
11
- }
12
-
13
- return h;
14
- };
15
-
16
- // This is a djb2 hashing function
17
- export const hash = (x: string) => {
18
- return phash(SEED, x);
19
- };
20
-
21
- const AD_REPLACER_R = /(a)(d)/gi
22
-
23
- /* This is the "capacity" of our alphabet i.e. 2x26 for all letters plus their capitalised
24
- * counterparts */
25
- const charsLength = 52
26
-
27
- /* start at 75 for 'a' until 'z' (25) and then start at 65 for capitalised letters */
28
- const getAlphabeticChar = (code: number) => String.fromCharCode(code + (code > 25 ? 39 : 97));
29
-
30
- /* input a number, usually a hash and convert it to base-52 */
31
- export function generateAlphabeticName(code: number) {
32
- let name = ''
33
- let x
34
-
35
- /* get a char and divide by alphabet-length */
36
- for (x = Math.abs(code); x > charsLength; x = (x / charsLength) | 0) {
37
- name = getAlphabeticChar(x % charsLength) + name
38
- }
39
-
40
- return (getAlphabeticChar(x % charsLength) + name).replace(AD_REPLACER_R, '$1-$2')
41
- }
42
-
43
- export default function generateComponentId(str: string) {
44
- return generateAlphabeticName(hash(str) >>> 0)
45
- }
46
-
package/tsconfig.json DELETED
@@ -1,24 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "esnext",
4
- "module": "esnext",
5
- "lib": [ "esnext" ],
6
- "outDir": "./dist",
7
- "moduleResolution": "node",
8
- "jsx": "react",
9
- "jsxFactory": "h",
10
- "jsxFragmentFactory": "Fragment",
11
- "skipLibCheck": false,
12
- "forceConsistentCasingInFileNames": true,
13
- "declaration": true,
14
- "typeRoots": [ "./definitions" ],
15
- },
16
- "include": [
17
- "./**/*"
18
- ],
19
- "exclude": [
20
- "./node_modules",
21
- "./dist",
22
- "./typings.d.ts"
23
- ]
24
- }
@@ -1,3 +0,0 @@
1
- let palettes = [["#69d2e7", "#a7dbd8", "#e0e4cc", "#f38630", "#fa6900"], ["#fe4365", "#fc9d9a", "#f9cdad", "#c8c8a9", "#83af9b"], ["#ecd078", "#d95b43", "#c02942", "#542437", "#53777a"], ["#556270", "#4ecdc4", "#c7f464", "#ff6b6b", "#c44d58"], ["#774f38", "#e08e79", "#f1d4af", "#ece5ce", "#c5e0dc"], ["#e8ddcb", "#cdb380", "#036564", "#033649", "#031634"], ["#490a3d", "#bd1550", "#e97f02", "#f8ca00", "#8a9b0f"], ["#594f4f", "#547980", "#45ada8", "#9de0ad", "#e5fcc2"], ["#00a0b0", "#6a4a3c", "#cc333f", "#eb6841", "#edc951"], ["#e94e77", "#d68189", "#c6a49a", "#c6e5d9", "#f4ead5"], ["#3fb8af", "#7fc7af", "#dad8a7", "#ff9e9d", "#ff3d7f"], ["#d9ceb2", "#948c75", "#d5ded9", "#7a6a53", "#99b2b7"], ["#ffffff", "#cbe86b", "#f2e9e1", "#1c140d", "#cbe86b"], ["#efffcd", "#dce9be", "#555152", "#2e2633", "#99173c"], ["#343838", "#005f6b", "#008c9e", "#00b4cc", "#00dffc"], ["#413e4a", "#73626e", "#b38184", "#f0b49e", "#f7e4be"], ["#ff4e50", "#fc913a", "#f9d423", "#ede574", "#e1f5c4"], ["#99b898", "#fecea8", "#ff847c", "#e84a5f", "#2a363b"], ["#655643", "#80bca3", "#f6f7bd", "#e6ac27", "#bf4d28"], ["#00a8c6", "#40c0cb", "#f9f2e7", "#aee239", "#8fbe00"], ["#351330", "#424254", "#64908a", "#e8caa4", "#cc2a41"], ["#554236", "#f77825", "#d3ce3d", "#f1efa5", "#60b99a"], ["#5d4157", "#838689", "#a8caba", "#cad7b2", "#ebe3aa"], ["#8c2318", "#5e8c6a", "#88a65e", "#bfb35a", "#f2c45a"], ["#fad089", "#ff9c5b", "#f5634a", "#ed303c", "#3b8183"], ["#ff4242", "#f4fad2", "#d4ee5e", "#e1edb9", "#f0f2eb"], ["#f8b195", "#f67280", "#c06c84", "#6c5b7b", "#355c7d"], ["#d1e751", "#ffffff", "#000000", "#4dbce9", "#26ade4"], ["#1b676b", "#519548", "#88c425", "#bef202", "#eafde6"], ["#5e412f", "#fcebb6", "#78c0a8", "#f07818", "#f0a830"], ["#bcbdac", "#cfbe27", "#f27435", "#f02475", "#3b2d38"], ["#452632", "#91204d", "#e4844a", "#e8bf56", "#e2f7ce"], ["#eee6ab", "#c5bc8e", "#696758", "#45484b", "#36393b"], ["#f0d8a8", "#3d1c00", "#86b8b1", "#f2d694", "#fa2a00"], ["#2a044a", "#0b2e59", "#0d6759", "#7ab317", "#a0c55f"], ["#f04155", "#ff823a", "#f2f26f", "#fff7bd", "#95cfb7"], ["#b9d7d9", "#668284", "#2a2829", "#493736", "#7b3b3b"], ["#bbbb88", "#ccc68d", "#eedd99", "#eec290", "#eeaa88"], ["#b3cc57", "#ecf081", "#ffbe40", "#ef746f", "#ab3e5b"], ["#a3a948", "#edb92e", "#f85931", "#ce1836", "#009989"], ["#300030", "#480048", "#601848", "#c04848", "#f07241"], ["#67917a", "#170409", "#b8af03", "#ccbf82", "#e33258"], ["#aab3ab", "#c4cbb7", "#ebefc9", "#eee0b7", "#e8caaf"], ["#e8d5b7", "#0e2430", "#fc3a51", "#f5b349", "#e8d5b9"], ["#ab526b", "#bca297", "#c5ceae", "#f0e2a4", "#f4ebc3"], ["#607848", "#789048", "#c0d860", "#f0f0d8", "#604848"], ["#b6d8c0", "#c8d9bf", "#dadabd", "#ecdbbc", "#fedcba"], ["#a8e6ce", "#dcedc2", "#ffd3b5", "#ffaaa6", "#ff8c94"], ["#3e4147", "#fffedf", "#dfba69", "#5a2e2e", "#2a2c31"], ["#fc354c", "#29221f", "#13747d", "#0abfbc", "#fcf7c5"], ["#cc0c39", "#e6781e", "#c8cf02", "#f8fcc1", "#1693a7"], ["#1c2130", "#028f76", "#b3e099", "#ffeaad", "#d14334"], ["#a7c5bd", "#e5ddcb", "#eb7b59", "#cf4647", "#524656"], ["#dad6ca", "#1bb0ce", "#4f8699", "#6a5e72", "#563444"], ["#5c323e", "#a82743", "#e15e32", "#c0d23e", "#e5f04c"], ["#edebe6", "#d6e1c7", "#94c7b6", "#403b33", "#d3643b"], ["#fdf1cc", "#c6d6b8", "#987f69", "#e3ad40", "#fcd036"], ["#230f2b", "#f21d41", "#ebebbc", "#bce3c5", "#82b3ae"], ["#b9d3b0", "#81bda4", "#b28774", "#f88f79", "#f6aa93"], ["#3a111c", "#574951", "#83988e", "#bcdea5", "#e6f9bc"], ["#5e3929", "#cd8c52", "#b7d1a3", "#dee8be", "#fcf7d3"], ["#1c0113", "#6b0103", "#a30006", "#c21a01", "#f03c02"], ["#000000", "#9f111b", "#b11623", "#292c37", "#cccccc"], ["#382f32", "#ffeaf2", "#fcd9e5", "#fbc5d8", "#f1396d"], ["#e3dfba", "#c8d6bf", "#93ccc6", "#6cbdb5", "#1a1f1e"], ["#f6f6f6", "#e8e8e8", "#333333", "#990100", "#b90504"], ["#1b325f", "#9cc4e4", "#e9f2f9", "#3a89c9", "#f26c4f"], ["#a1dbb2", "#fee5ad", "#faca66", "#f7a541", "#f45d4c"], ["#c1b398", "#605951", "#fbeec2", "#61a6ab", "#accec0"], ["#5e9fa3", "#dcd1b4", "#fab87f", "#f87e7b", "#b05574"], ["#951f2b", "#f5f4d7", "#e0dfb1", "#a5a36c", "#535233"], ["#8dccad", "#988864", "#fea6a2", "#f9d6ac", "#ffe9af"], ["#2d2d29", "#215a6d", "#3ca2a2", "#92c7a3", "#dfece6"], ["#413d3d", "#040004", "#c8ff00", "#fa023c", "#4b000f"], ["#eff3cd", "#b2d5ba", "#61ada0", "#248f8d", "#605063"], ["#ffefd3", "#fffee4", "#d0ecea", "#9fd6d2", "#8b7a5e"], ["#cfffdd", "#b4dec1", "#5c5863", "#a85163", "#ff1f4c"], ["#9dc9ac", "#fffec7", "#f56218", "#ff9d2e", "#919167"], ["#4e395d", "#827085", "#8ebe94", "#ccfc8e", "#dc5b3e"], ["#a8a7a7", "#cc527a", "#e8175d", "#474747", "#363636"], ["#f8edd1", "#d88a8a", "#474843", "#9d9d93", "#c5cfc6"], ["#046d8b", "#309292", "#2fb8ac", "#93a42a", "#ecbe13"], ["#f38a8a", "#55443d", "#a0cab5", "#cde9ca", "#f1edd0"], ["#a70267", "#f10c49", "#fb6b41", "#f6d86b", "#339194"], ["#ff003c", "#ff8a00", "#fabe28", "#88c100", "#00c176"], ["#ffedbf", "#f7803c", "#f54828", "#2e0d23", "#f8e4c1"], ["#4e4d4a", "#353432", "#94ba65", "#2790b0", "#2b4e72"], ["#0ca5b0", "#4e3f30", "#fefeeb", "#f8f4e4", "#a5b3aa"], ["#4d3b3b", "#de6262", "#ffb88c", "#ffd0b3", "#f5e0d3"], ["#fffbb7", "#a6f6af", "#66b6ab", "#5b7c8d", "#4f2958"], ["#edf6ee", "#d1c089", "#b3204d", "#412e28", "#151101"], ["#9d7e79", "#ccac95", "#9a947c", "#748b83", "#5b756c"], ["#fcfef5", "#e9ffe1", "#cdcfb7", "#d6e6c3", "#fafbe3"], ["#9cddc8", "#bfd8ad", "#ddd9ab", "#f7af63", "#633d2e"], ["#30261c", "#403831", "#36544f", "#1f5f61", "#0b8185"], ["#aaff00", "#ffaa00", "#ff00aa", "#aa00ff", "#00aaff"], ["#d1313d", "#e5625c", "#f9bf76", "#8eb2c5", "#615375"], ["#ffe181", "#eee9e5", "#fad3b2", "#ffba7f", "#ff9c97"], ["#73c8a9", "#dee1b6", "#e1b866", "#bd5532", "#373b44"], ["#805841", "#dcf7f3", "#fffcdd", "#ffd8d8", "#f5a2a2"]]
2
-
3
- export { palettes }
@@ -1,249 +0,0 @@
1
- // import { float4, float3, quaternion } from "Unity/Mathematics" // JSR prepends a "./" to this, which messes things up
2
- // import { Color } from "UnityEngine" // TODO Somehow this bypasses unity-import-transform and leads to esbuild error
3
-
4
- type float4 = CS.Unity.Mathematics.float4
5
- const { float4: f4, float3: f3, PI } = CS.Unity.Mathematics.math
6
- const { Color } = CS.UnityEngine
7
-
8
- /*
9
- https://github.com/deanm/css-color-parser-js
10
-
11
- Minor changes were made for TS compatibility. Original License below:
12
-
13
- (c) Dean McNamee <dean@gmail.com>, 2012.
14
-
15
- Permission is hereby granted, free of charge, to any person obtaining a copy
16
- of this software and associated documentation files (the "Software"), to
17
- deal in the Software without restriction, including without limitation the
18
- rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
19
- sell copies of the Software, and to permit persons to whom the Software is
20
- furnished to do so, subject to the following conditions:
21
-
22
- The above copyright notice and this permission notice shall be included in
23
- all copies or substantial portions of the Software.
24
-
25
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
26
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
27
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
28
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
29
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
30
- FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
31
- IN THE SOFTWARE.
32
- */
33
-
34
- var kCSSColorTable = {
35
- "transparent": [0, 0, 0, 0], "aliceblue": [240, 248, 255, 1],
36
- "antiquewhite": [250, 235, 215, 1], "aqua": [0, 255, 255, 1],
37
- "aquamarine": [127, 255, 212, 1], "azure": [240, 255, 255, 1],
38
- "beige": [245, 245, 220, 1], "bisque": [255, 228, 196, 1],
39
- "black": [0, 0, 0, 1], "blanchedalmond": [255, 235, 205, 1],
40
- "blue": [0, 0, 255, 1], "blueviolet": [138, 43, 226, 1],
41
- "brown": [165, 42, 42, 1], "burlywood": [222, 184, 135, 1],
42
- "cadetblue": [95, 158, 160, 1], "chartreuse": [127, 255, 0, 1],
43
- "chocolate": [210, 105, 30, 1], "coral": [255, 127, 80, 1],
44
- "cornflowerblue": [100, 149, 237, 1], "cornsilk": [255, 248, 220, 1],
45
- "crimson": [220, 20, 60, 1], "cyan": [0, 255, 255, 1],
46
- "darkblue": [0, 0, 139, 1], "darkcyan": [0, 139, 139, 1],
47
- "darkgoldenrod": [184, 134, 11, 1], "darkgray": [169, 169, 169, 1],
48
- "darkgreen": [0, 100, 0, 1], "darkgrey": [169, 169, 169, 1],
49
- "darkkhaki": [189, 183, 107, 1], "darkmagenta": [139, 0, 139, 1],
50
- "darkolivegreen": [85, 107, 47, 1], "darkorange": [255, 140, 0, 1],
51
- "darkorchid": [153, 50, 204, 1], "darkred": [139, 0, 0, 1],
52
- "darksalmon": [233, 150, 122, 1], "darkseagreen": [143, 188, 143, 1],
53
- "darkslateblue": [72, 61, 139, 1], "darkslategray": [47, 79, 79, 1],
54
- "darkslategrey": [47, 79, 79, 1], "darkturquoise": [0, 206, 209, 1],
55
- "darkviolet": [148, 0, 211, 1], "deeppink": [255, 20, 147, 1],
56
- "deepskyblue": [0, 191, 255, 1], "dimgray": [105, 105, 105, 1],
57
- "dimgrey": [105, 105, 105, 1], "dodgerblue": [30, 144, 255, 1],
58
- "firebrick": [178, 34, 34, 1], "floralwhite": [255, 250, 240, 1],
59
- "forestgreen": [34, 139, 34, 1], "fuchsia": [255, 0, 255, 1],
60
- "gainsboro": [220, 220, 220, 1], "ghostwhite": [248, 248, 255, 1],
61
- "gold": [255, 215, 0, 1], "goldenrod": [218, 165, 32, 1],
62
- "gray": [128, 128, 128, 1], "green": [0, 128, 0, 1],
63
- "greenyellow": [173, 255, 47, 1], "grey": [128, 128, 128, 1],
64
- "honeydew": [240, 255, 240, 1], "hotpink": [255, 105, 180, 1],
65
- "indianred": [205, 92, 92, 1], "indigo": [75, 0, 130, 1],
66
- "ivory": [255, 255, 240, 1], "khaki": [240, 230, 140, 1],
67
- "lavender": [230, 230, 250, 1], "lavenderblush": [255, 240, 245, 1],
68
- "lawngreen": [124, 252, 0, 1], "lemonchiffon": [255, 250, 205, 1],
69
- "lightblue": [173, 216, 230, 1], "lightcoral": [240, 128, 128, 1],
70
- "lightcyan": [224, 255, 255, 1], "lightgoldenrodyellow": [250, 250, 210, 1],
71
- "lightgray": [211, 211, 211, 1], "lightgreen": [144, 238, 144, 1],
72
- "lightgrey": [211, 211, 211, 1], "lightpink": [255, 182, 193, 1],
73
- "lightsalmon": [255, 160, 122, 1], "lightseagreen": [32, 178, 170, 1],
74
- "lightskyblue": [135, 206, 250, 1], "lightslategray": [119, 136, 153, 1],
75
- "lightslategrey": [119, 136, 153, 1], "lightsteelblue": [176, 196, 222, 1],
76
- "lightyellow": [255, 255, 224, 1], "lime": [0, 255, 0, 1],
77
- "limegreen": [50, 205, 50, 1], "linen": [250, 240, 230, 1],
78
- "magenta": [255, 0, 255, 1], "maroon": [128, 0, 0, 1],
79
- "mediumaquamarine": [102, 205, 170, 1], "mediumblue": [0, 0, 205, 1],
80
- "mediumorchid": [186, 85, 211, 1], "mediumpurple": [147, 112, 219, 1],
81
- "mediumseagreen": [60, 179, 113, 1], "mediumslateblue": [123, 104, 238, 1],
82
- "mediumspringgreen": [0, 250, 154, 1], "mediumturquoise": [72, 209, 204, 1],
83
- "mediumvioletred": [199, 21, 133, 1], "midnightblue": [25, 25, 112, 1],
84
- "mintcream": [245, 255, 250, 1], "mistyrose": [255, 228, 225, 1],
85
- "moccasin": [255, 228, 181, 1], "navajowhite": [255, 222, 173, 1],
86
- "navy": [0, 0, 128, 1], "oldlace": [253, 245, 230, 1],
87
- "olive": [128, 128, 0, 1], "olivedrab": [107, 142, 35, 1],
88
- "orange": [255, 165, 0, 1], "orangered": [255, 69, 0, 1],
89
- "orchid": [218, 112, 214, 1], "palegoldenrod": [238, 232, 170, 1],
90
- "palegreen": [152, 251, 152, 1], "paleturquoise": [175, 238, 238, 1],
91
- "palevioletred": [219, 112, 147, 1], "papayawhip": [255, 239, 213, 1],
92
- "peachpuff": [255, 218, 185, 1], "peru": [205, 133, 63, 1],
93
- "pink": [255, 192, 203, 1], "plum": [221, 160, 221, 1],
94
- "powderblue": [176, 224, 230, 1], "purple": [128, 0, 128, 1],
95
- "rebeccapurple": [102, 51, 153, 1],
96
- "red": [255, 0, 0, 1], "rosybrown": [188, 143, 143, 1],
97
- "royalblue": [65, 105, 225, 1], "saddlebrown": [139, 69, 19, 1],
98
- "salmon": [250, 128, 114, 1], "sandybrown": [244, 164, 96, 1],
99
- "seagreen": [46, 139, 87, 1], "seashell": [255, 245, 238, 1],
100
- "sienna": [160, 82, 45, 1], "silver": [192, 192, 192, 1],
101
- "skyblue": [135, 206, 235, 1], "slateblue": [106, 90, 205, 1],
102
- "slategray": [112, 128, 144, 1], "slategrey": [112, 128, 144, 1],
103
- "snow": [255, 250, 250, 1], "springgreen": [0, 255, 127, 1],
104
- "steelblue": [70, 130, 180, 1], "tan": [210, 180, 140, 1],
105
- "teal": [0, 128, 128, 1], "thistle": [216, 191, 216, 1],
106
- "tomato": [255, 99, 71, 1], "turquoise": [64, 224, 208, 1],
107
- "violet": [238, 130, 238, 1], "wheat": [245, 222, 179, 1],
108
- "white": [255, 255, 255, 1], "whitesmoke": [245, 245, 245, 1],
109
- "yellow": [255, 255, 0, 1], "yellowgreen": [154, 205, 50, 1]
110
- }
111
-
112
- function clamp_css_byte(i: number) { // Clamp to integer 0 .. 255.
113
- i = Math.round(i); // Seems to be what Chrome does (vs truncation).
114
- return i < 0 ? 0 : i > 255 ? 255 : i;
115
- }
116
-
117
- function clamp_css_float(f: number) { // Clamp to float 0.0 .. 1.0.
118
- return f < 0 ? 0 : f > 1 ? 1 : f;
119
- }
120
-
121
- function parse_css_int(str: string) { // int or percentage.
122
- if (str[str.length - 1] === '%')
123
- return clamp_css_byte(parseFloat(str) / 100 * 255);
124
- return clamp_css_byte(parseInt(str));
125
- }
126
-
127
- function parse_css_float(str: string) { // float or percentage.
128
- if (str[str.length - 1] === '%')
129
- return clamp_css_float(parseFloat(str) / 100);
130
- return clamp_css_float(parseFloat(str));
131
- }
132
-
133
- function css_hue_to_rgb(m1: number, m2: number, h: number) {
134
- if (h < 0) h += 1;
135
- else if (h > 1) h -= 1;
136
-
137
- if (h * 6 < 1) return m1 + (m2 - m1) * h * 6;
138
- if (h * 2 < 1) return m2;
139
- if (h * 3 < 2) return m1 + (m2 - m1) * (2 / 3 - h) * 6;
140
- return m1;
141
- }
142
-
143
- function parseCSSColor(css_str: string): number[] | null {
144
- // Remove all whitespace, not compliant, but should just be more accepting.
145
- var str = css_str.replace(/ /g, '').toLowerCase();
146
-
147
- // Color keywords (and transparent) lookup.
148
- if (str in kCSSColorTable) return (kCSSColorTable as { [key: string]: number[] })[str].slice(); // dup.
149
-
150
- // #abc and #abc123 syntax.
151
- if (str[0] === '#') {
152
- if (str.length === 4) {
153
- var iv = parseInt(str.substr(1), 16); // TODO(deanm): Stricter parsing.
154
- if (!(iv >= 0 && iv <= 0xfff)) return null; // Covers NaN.
155
- return [((iv & 0xf00) >> 4) | ((iv & 0xf00) >> 8),
156
- (iv & 0xf0) | ((iv & 0xf0) >> 4),
157
- (iv & 0xf) | ((iv & 0xf) << 4),
158
- 1];
159
- } else if (str.length === 7) {
160
- var iv = parseInt(str.substr(1), 16); // TODO(deanm): Stricter parsing.
161
- if (!(iv >= 0 && iv <= 0xffffff)) return null; // Covers NaN.
162
- return [(iv & 0xff0000) >> 16,
163
- (iv & 0xff00) >> 8,
164
- iv & 0xff,
165
- 1];
166
- }
167
-
168
- return null;
169
- }
170
-
171
- var op = str.indexOf('('), ep = str.indexOf(')');
172
- if (op !== -1 && ep + 1 === str.length) {
173
- var fname = str.substr(0, op);
174
- var params = str.substr(op + 1, ep - (op + 1)).split(',');
175
- var alpha = 1; // To allow case fallthrough.
176
- switch (fname) {
177
- case 'rgba':
178
- if (params.length !== 4) return null;
179
- alpha = parse_css_float(params.pop() as string);
180
- // Fall through.
181
- case 'rgb':
182
- if (params.length !== 3) return null;
183
- return [parse_css_int(params[0]),
184
- parse_css_int(params[1]),
185
- parse_css_int(params[2]),
186
- alpha];
187
- case 'hsla':
188
- if (params.length !== 4) return null;
189
- alpha = parse_css_float(params.pop() as string);
190
- // Fall through.
191
- case 'hsl':
192
- if (params.length !== 3) return null;
193
- var h = (((parseFloat(params[0]) % 360) + 360) % 360) / 360; // 0 .. 1
194
- // NOTE(deanm): According to the CSS spec s/l should only be
195
- // percentages, but we don't bother and let float or percentage.
196
- var s = parse_css_float(params[1]);
197
- var l = parse_css_float(params[2]);
198
- var m2 = l <= 0.5 ? l * (s + 1) : l + s - l * s;
199
- var m1 = l * 2 - m2;
200
- return [clamp_css_byte(css_hue_to_rgb(m1, m2, h + 1 / 3) * 255),
201
- clamp_css_byte(css_hue_to_rgb(m1, m2, h) * 255),
202
- clamp_css_byte(css_hue_to_rgb(m1, m2, h - 1 / 3) * 255),
203
- alpha];
204
- default:
205
- return null;
206
- }
207
- }
208
-
209
- return null;
210
- }
211
-
212
- function namedColor(name: keyof typeof kCSSColorTable): Color {
213
- var c = kCSSColorTable[name]
214
- return new Color(c[0] / 255, c[1] / 255, c[2] / 255, c[3])
215
- }
216
-
217
- function namedColors(...names: (keyof typeof kCSSColorTable)[]): Color[] {
218
- let res = [] as Color[]
219
- for (const name of names) {
220
- res.push(namedColor(name))
221
- }
222
- return res
223
- }
224
-
225
- export function colorStrToF4(str: string): float4 {
226
- var c = parseCSSColor(str)
227
- if (c == null)
228
- throw `Color ${str} cannot be parsed`
229
-
230
- return f4(c[0] / 255, c[1] / 255, c[2] / 255, c[3])
231
- }
232
-
233
- /**
234
- * Can parse any css color, array of 4 values [0 to 1.0], or a plain float4
235
- */
236
- export function parseColor(input: string | number[] | float4): Color {
237
- if (Array.isArray(input)) {
238
- return new Color(input[0], input[1], input[2], input[3])
239
- } else if (typeof input === "string") {
240
- var c = parseCSSColor(input)
241
- if (c !== null) {
242
- return new Color(c[0] / 255, c[1] / 255, c[2] / 255, c[3])
243
- }
244
- return new Color(0, 0, 0, 0)
245
- }
246
- return new Color(input.x, input.y, input.z, input.w)
247
- }
248
-
249
- export { parseCSSColor, namedColor, namedColors }
@@ -1,31 +0,0 @@
1
- // import { float2, float3, float4 } from "Unity/Mathematics" // JSR prepends a "./" to this, which messes things up
2
-
3
- type float2 = CS.Unity.Mathematics.float2
4
- type float3 = CS.Unity.Mathematics.float3
5
- type float4 = CS.Unity.Mathematics.float4
6
-
7
- const { clamp, float2: f2, float3: f3, float4: f4 } = CS.Unity.Mathematics.math
8
-
9
- export function parseFloat2(input: any): float2 {
10
- if (!input)
11
- return f2(0, 0)
12
- if (Array.isArray(input))
13
- input = f2(input[0] ?? 0, input[1] ?? 0)
14
- return f2(input.x ?? 0, input.y ?? 0)
15
- }
16
-
17
- export function parseFloat3(input: any): float3 {
18
- if (!input)
19
- return f3(0, 0, 0)
20
- if (Array.isArray(input))
21
- input = f3(input[0] ?? 0, input[1] ?? 0, input[2] ?? 0)
22
- return f3(input.x ?? 0, input.y ?? 0, input.z ?? 0)
23
- }
24
-
25
- export function parseFloat4(input: any): float4 {
26
- if (!input)
27
- return f4(0, 0, 0, 0)
28
- if (Array.isArray(input))
29
- input = f4(input[0] ?? 0, input[1] ?? 0, input[2] ?? 0, input[3] ?? 0)
30
- return f4(input.x ?? 0, input.y ?? 0, input.z ?? 0, input.w ?? 0)
31
- }
package/utils/index.ts DELETED
@@ -1,12 +0,0 @@
1
- /**
2
- * @module utils
3
- *
4
- * This module contains some commonly-used utility functions.
5
- */
6
-
7
- // @ts-ignore - prevent `allowImportingTsExtensions` error
8
- export { parseColor, parseCSSColor, colorStrToF4, namedColor, namedColors } from "./color-parser"
9
- // @ts-ignore - prevent `allowImportingTsExtensions` error
10
- export { palettes } from "./color-palettes"
11
- // @ts-ignore - prevent `allowImportingTsExtensions` error
12
- export { parseFloat2, parseFloat3, parseFloat4 } from "./float-parser"
File without changes