onejs-core 0.3.10 → 0.3.12
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/.gitattributes +2 -0
- package/.github/workflows/jsr.yml +19 -0
- package/.prettierrc +5 -0
- package/.vscode/settings.json +6 -0
- package/dom/document.ts +34 -0
- package/dom/dom-style.ts +25 -0
- package/dom/dom.ts +76 -0
- package/{dist/index.js → index.ts} +49 -36
- package/jsr.json +10 -0
- package/package.json +3 -9
- package/preloads/inject.ts +44 -0
- package/scripts/switch.cjs +1 -1
- package/styling/index.tsx +27 -0
- package/{dist/styling/utils/generateAlphabeticName.js → styling/utils/generateAlphabeticName.ts} +21 -16
- package/styling/utils/generateComponentId.ts +6 -0
- package/{dist/styling/utils/hash.js → styling/utils/hash.ts} +46 -34
- package/tsconfig.json +24 -0
- package/typings.d.ts +1 -2
- package/{dist/utils/color-palettes.js → utils/color-palettes.ts} +3 -2
- package/{dist/utils/color-parser.js → utils/color-parser.ts} +249 -241
- package/utils/float-parser.ts +31 -0
- package/{dist/utils/index.js → utils/index.ts} +12 -11
- package/dist/dom/document.d.ts +0 -14
- package/dist/dom/document.js +0 -22
- package/dist/dom/dom-style.d.ts +0 -7
- package/dist/dom/dom-style.js +0 -18
- package/dist/dom/dom.d.ts +0 -32
- package/dist/dom/dom.js +0 -62
- package/dist/index.d.ts +0 -20
- package/dist/preloads/inject.d.ts +0 -2
- package/dist/preloads/inject.js +0 -35
- package/dist/styling/index.d.ts +0 -9
- package/dist/styling/index.js +0 -23
- package/dist/styling/utils/generateAlphabeticName.d.ts +0 -1
- package/dist/styling/utils/generateComponentId.d.ts +0 -1
- package/dist/styling/utils/generateComponentId.js +0 -5
- package/dist/styling/utils/hash.d.ts +0 -5
- package/dist/utils/color-palettes.d.ts +0 -2
- package/dist/utils/color-parser.d.ts +0 -161
- package/dist/utils/float-parser.d.ts +0 -7
- package/dist/utils/float-parser.js +0 -23
- package/dist/utils/index.d.ts +0 -8
package/.gitattributes
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
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
ADDED
package/dom/document.ts
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
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
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
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
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
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
|
+
}
|
|
@@ -1,36 +1,49 @@
|
|
|
1
|
-
import { DocumentWrapper } from "./dom/document";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
*
|
|
6
|
-
* @param
|
|
7
|
-
* @
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
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
ADDED
package/package.json
CHANGED
|
@@ -1,15 +1,9 @@
|
|
|
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.
|
|
5
|
-
"main": "dist/index.js",
|
|
6
|
-
"types": "typings.d.ts",
|
|
7
|
-
"files": [
|
|
8
|
-
"dist",
|
|
9
|
-
"definitions",
|
|
10
|
-
"scripts",
|
|
11
|
-
"typings.d.ts"
|
|
12
|
-
],
|
|
4
|
+
"version": "0.3.12",
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"types": "./typings.d.ts",
|
|
13
7
|
"dependencies": {
|
|
14
8
|
"css-flatten": "^2.0.0",
|
|
15
9
|
"css-simple-parser": "^3.0.0"
|
|
@@ -0,0 +1,44 @@
|
|
|
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/scripts/switch.cjs
CHANGED
|
@@ -76,7 +76,7 @@ async function Process(backend, outputDir) {
|
|
|
76
76
|
function getOneJSUnityDir() {
|
|
77
77
|
var packageJsonPath = path.join(__dirname, '../package.json')
|
|
78
78
|
var json = require(packageJsonPath)
|
|
79
|
-
return json.onejs
|
|
79
|
+
return json.onejs["unity-package-path"]
|
|
80
80
|
}
|
|
81
81
|
|
|
82
82
|
function ensureDirectoryExistence(filePath) {
|
|
@@ -0,0 +1,27 @@
|
|
|
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
|
+
}
|
package/{dist/styling/utils/generateAlphabeticName.js → styling/utils/generateAlphabeticName.ts}
RENAMED
|
@@ -1,16 +1,21 @@
|
|
|
1
|
-
const AD_REPLACER_R = /(a)(d)/gi
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
/*
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
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,34 +1,46 @@
|
|
|
1
|
-
export const SEED = 5381;
|
|
2
|
-
|
|
3
|
-
//
|
|
4
|
-
//
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
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
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
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
|
+
}
|
package/typings.d.ts
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
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
|
-
|
|
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 }
|