onejs-core 0.3.46 → 1.0.7

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.
Files changed (42) hide show
  1. package/definitions/Assemblies/OneJS.Runtime.d.ts +15 -0
  2. package/definitions/jsx.d.ts +6 -1
  3. package/package.json +1 -1
  4. package/dist/dom/document.d.ts +0 -21
  5. package/dist/dom/document.js +0 -40
  6. package/dist/dom/dom-style.d.ts +0 -9
  7. package/dist/dom/dom-style.js +0 -21
  8. package/dist/dom/dom.d.ts +0 -59
  9. package/dist/dom/dom.js +0 -220
  10. package/dist/dom/selector.d.ts +0 -0
  11. package/dist/dom/selector.js +0 -0
  12. package/dist/preloads/inject.d.ts +0 -2
  13. package/dist/preloads/inject.js +0 -35
  14. package/dist/styling/index.d.ts +0 -9
  15. package/dist/styling/index.js +0 -27
  16. package/dist/styling/utils/generateAlphabeticName.d.ts +0 -1
  17. package/dist/styling/utils/generateAlphabeticName.js +0 -16
  18. package/dist/styling/utils/generateComponentId.d.ts +0 -1
  19. package/dist/styling/utils/generateComponentId.js +0 -5
  20. package/dist/styling/utils/hash.d.ts +0 -5
  21. package/dist/styling/utils/hash.js +0 -34
  22. package/dist/utils/color-palettes.d.ts +0 -2
  23. package/dist/utils/color-palettes.js +0 -2
  24. package/dist/utils/color-parser.d.ts +0 -161
  25. package/dist/utils/color-parser.js +0 -241
  26. package/dist/utils/float-parser.d.ts +0 -7
  27. package/dist/utils/float-parser.js +0 -23
  28. package/dist/utils/index.d.ts +0 -8
  29. package/dist/utils/index.js +0 -11
  30. package/dom/document.ts +0 -55
  31. package/dom/dom-style.ts +0 -31
  32. package/dom/dom.ts +0 -267
  33. package/index.ts +0 -52
  34. package/preloads/inject.ts +0 -44
  35. package/styling/index.tsx +0 -32
  36. package/styling/utils/generateAlphabeticName.ts +0 -21
  37. package/styling/utils/generateComponentId.ts +0 -6
  38. package/styling/utils/hash.ts +0 -46
  39. package/utils/color-palettes.ts +0 -3
  40. package/utils/color-parser.ts +0 -249
  41. package/utils/float-parser.ts +0 -31
  42. package/utils/index.ts +0 -12
@@ -14,6 +14,13 @@ declare namespace CS {
14
14
  // }
15
15
  // interface $Task<T> {}
16
16
  namespace OneJS {
17
+ class WebApi extends System.Object
18
+ {
19
+ protected [__keep_incompatibility]: never;
20
+ public static getText ($uri: string, $callback: System.Action$1<string>) : UnityEngine.Coroutine
21
+ public static getImage ($uri: string, $callback: System.Action$1<UnityEngine.Texture2D>) : UnityEngine.Coroutine
22
+ public constructor ()
23
+ }
17
24
  class EventfulPropertyAttribute extends System.Attribute implements System.Runtime.InteropServices._Attribute
18
25
  {
19
26
  protected [__keep_incompatibility]: never;
@@ -400,6 +407,14 @@ declare namespace CS {
400
407
  public set Colors(value: System.Array$1<UnityEngine.Color>);
401
408
  public constructor ()
402
409
  }
410
+ class Img extends UnityEngine.UIElements.VisualElement implements UnityEngine.UIElements.Experimental.ITransitionAnimations, UnityEngine.UIElements.IVisualElementScheduler, UnityEngine.UIElements.IResolvedStyle, UnityEngine.UIElements.IStylePropertyAnimations, UnityEngine.UIElements.IEventHandler, UnityEngine.UIElements.IExperimentalFeatures, UnityEngine.UIElements.ITransform
411
+ {
412
+ protected [__keep_incompatibility]: never;
413
+ public get Src(): string;
414
+ public set Src(value: string);
415
+ public SetSrc ($src: string) : void
416
+ public constructor ()
417
+ }
403
418
  }
404
419
  namespace OneJS.EngineHost {
405
420
  interface ActionCallback
@@ -469,6 +469,10 @@ declare global {
469
469
  * OneJS Elements
470
470
  */
471
471
 
472
+ interface Img extends Image {
473
+ src?: string
474
+ }
475
+
472
476
  interface GradientRect extends VisualElement {
473
477
  colors?: Color[]
474
478
  }
@@ -527,8 +531,9 @@ declare global {
527
531
  dropdownfield: DropdownField
528
532
 
529
533
  // /* OneJS Custom */
534
+ img: Img
530
535
  gradientrect: GradientRect
531
- // flipbook: Flipbook
536
+ flipbook: Flipbook
532
537
  // simplelistview: SimpleListView
533
538
  }
534
539
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
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.46",
4
+ "version": "1.0.7",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./typings.d.ts",
7
7
  "dependencies": {
@@ -1,21 +0,0 @@
1
- import { DomWrapper } from "./dom";
2
- interface ElementCreationOptions {
3
- is?: string;
4
- }
5
- export declare class DocumentWrapper {
6
- #private;
7
- get _doc(): CS.OneJS.Dom.Document;
8
- /**
9
- * The body/root element of the document. Will be null for Editor documents.
10
- */
11
- get body(): DomWrapper | null;
12
- constructor(doc: CS.OneJS.Dom.Document);
13
- addRuntimeUSS(uss: string): void;
14
- clearRuntimeStyleSheets(): void;
15
- createElement(tagName: string, options?: ElementCreationOptions): DomWrapper;
16
- createElementNS(ns: string, tagName: string, options?: ElementCreationOptions): DomWrapper;
17
- createTextNode(text: string): DomWrapper;
18
- getElementById(id: string): DomWrapper;
19
- querySelectorAll(selector: string): DomWrapper[];
20
- }
21
- export {};
@@ -1,40 +0,0 @@
1
- import { DomWrapper } from "./dom";
2
- export class DocumentWrapper {
3
- get _doc() { return this.#doc; }
4
- #doc;
5
- #body;
6
- /**
7
- * The body/root element of the document. Will be null for Editor documents.
8
- */
9
- get body() { return this.#body; }
10
- constructor(doc) {
11
- this.#doc = doc;
12
- this.#body = doc.body ? new DomWrapper(doc.body) : null;
13
- }
14
- addRuntimeUSS(uss) {
15
- this.#doc.addRuntimeUSS(uss);
16
- }
17
- clearRuntimeStyleSheets() {
18
- this.#doc.clearRuntimeStyleSheets();
19
- }
20
- createElement(tagName, options) {
21
- return new DomWrapper(this.#doc.createElement(tagName));
22
- }
23
- createElementNS(ns, tagName, options) {
24
- return new DomWrapper(this.#doc.createElement(tagName));
25
- }
26
- createTextNode(text) {
27
- return new DomWrapper(this.#doc.createTextNode(text));
28
- }
29
- getElementById(id) {
30
- return new DomWrapper(this.#doc.getElementById(id));
31
- }
32
- querySelectorAll(selector) {
33
- let doms = this.#doc.querySelectorAll(selector);
34
- let res = [];
35
- for (let i = 0; i < doms.Length; i++) {
36
- res.push(new DomWrapper(doms.get_Item(i)));
37
- }
38
- return res;
39
- }
40
- }
@@ -1,9 +0,0 @@
1
- export declare class DomStyleWrapper implements CS.OneJS.Dom.DomStyle {
2
- _domStyle: CS.OneJS.Dom.DomStyle;
3
- constructor(domStyle: CS.OneJS.Dom.DomStyle);
4
- getProperty(name: string): any;
5
- setProperty(name: string, value: any): void;
6
- }
7
- export interface DomStyleWrapper extends CS.OneJS.Dom.DomStyle {
8
- [key: string | symbol]: any;
9
- }
@@ -1,21 +0,0 @@
1
- export class DomStyleWrapper {
2
- _domStyle; // Making this public so that Proxy's setProperty can access it
3
- constructor(domStyle) {
4
- this._domStyle = domStyle;
5
- return new Proxy(this, {
6
- set(target, prop, value) {
7
- target.setProperty(prop, value);
8
- return true;
9
- },
10
- get(target, prop) {
11
- return target.getProperty(prop);
12
- }
13
- });
14
- }
15
- getProperty(name) {
16
- return this._domStyle.getProperty(name);
17
- }
18
- setProperty(name, value) {
19
- this._domStyle.setProperty(name, value);
20
- }
21
- }
package/dist/dom/dom.d.ts DELETED
@@ -1,59 +0,0 @@
1
- /// <reference path="../../definitions/modules.d.ts" />
2
- import { EventBase } from "UnityEngine/UIElements";
3
- import { DomStyleWrapper } from "./dom-style";
4
- export declare class DomWrapper {
5
- get _dom(): CS.OneJS.Dom.Dom;
6
- get ve(): CS.UnityEngine.UIElements.VisualElement;
7
- get childNodes(): DomWrapper[];
8
- get firstChild(): DomWrapper | null;
9
- get parentNode(): DomWrapper | null;
10
- get nextSibling(): DomWrapper | null;
11
- get nodeType(): number;
12
- get style(): DomStyleWrapper;
13
- get Id(): string;
14
- set Id(value: string);
15
- get key(): string;
16
- set key(value: string);
17
- get value(): any;
18
- get checked(): boolean;
19
- get data(): any;
20
- set data(value: any);
21
- get classname(): string;
22
- set classname(value: string);
23
- /**
24
- * Not using private fields because of issues with the `#private;` line
25
- * generated by tsc
26
- */
27
- dom: CS.OneJS.Dom.Dom;
28
- domStyleWrapper: DomStyleWrapper;
29
- cachedChildNodes: DomWrapper[] | null;
30
- boundListeners: WeakMap<WeakKey, any>;
31
- constructor(dom: CS.OneJS.Dom.Dom);
32
- appendChild(child: DomWrapper): void;
33
- removeChild(child: DomWrapper): void;
34
- insertBefore(a: DomWrapper, b: DomWrapper): void;
35
- insertAfter(a: DomWrapper, b: DomWrapper): void;
36
- contains(child: DomWrapper): boolean;
37
- clearChildren(): void;
38
- focus(): void;
39
- addEventListener(type: string, listener: (event: EventBase) => void, useCapture?: boolean): void;
40
- removeEventListener(type: string, listener: (event: EventBase) => void, useCapture?: boolean): void;
41
- setAttribute(name: string, value: any): void;
42
- removeAttribute(name: string): void;
43
- /**
44
- * Returns all elements matching the specified selector.
45
- * Supports basic selectors:
46
- * - Tag names: 'div'
47
- * - IDs: '#myId'
48
- * - Classes: '.myClass'
49
- * - Combinations: 'div.myClass#myId'
50
- */
51
- querySelectorAll(selector: string): DomWrapper[];
52
- /**
53
- * Returns the first element matching the specified selector.
54
- * Supports the same basic selectors as querySelectorAll.
55
- */
56
- querySelector(selector: string): DomWrapper | null;
57
- }
58
- export declare function querySelectorAll(root: DomWrapper, selector: string): DomWrapper[];
59
- export declare function querySelector(root: DomWrapper, selector: string): DomWrapper | null;
package/dist/dom/dom.js DELETED
@@ -1,220 +0,0 @@
1
- import { DomStyleWrapper } from "./dom-style";
2
- export class DomWrapper {
3
- get _dom() { return this.dom; }
4
- get ve() { return this.dom.ve; }
5
- get childNodes() {
6
- if (this.cachedChildNodes)
7
- return this.cachedChildNodes;
8
- this.cachedChildNodes = new Array(this.dom.childNodes.Length);
9
- var i = this.dom.childNodes.Length;
10
- while (i--) {
11
- this.cachedChildNodes[i] = new DomWrapper(this.dom.childNodes.get_Item(i));
12
- }
13
- return this.cachedChildNodes;
14
- }
15
- get firstChild() {
16
- return this.dom.firstChild ? new DomWrapper(this.dom.firstChild) : null;
17
- }
18
- get parentNode() {
19
- return this.dom.parentNode ? new DomWrapper(this.dom.parentNode) : null;
20
- }
21
- get nextSibling() {
22
- return this.dom.nextSibling ? new DomWrapper(this.dom.nextSibling) : null;
23
- }
24
- get nodeType() { return this.dom.nodeType; }
25
- get style() { return this.domStyleWrapper; }
26
- get Id() { return this.dom.Id; }
27
- set Id(value) { this.dom.Id = value; }
28
- get key() { return this.dom.key; }
29
- set key(value) { this.dom.key = value; }
30
- get value() { return this.dom.value; }
31
- get checked() { return this.dom.checked; }
32
- get data() { return this.dom.data; }
33
- set data(value) { this.dom.data = value; }
34
- get classname() { return this.dom.classname; }
35
- set classname(value) { this.dom.classname = value; }
36
- /**
37
- * Not using private fields because of issues with the `#private;` line
38
- * generated by tsc
39
- */
40
- dom;
41
- domStyleWrapper;
42
- cachedChildNodes = null;
43
- boundListeners = new WeakMap();
44
- constructor(dom) {
45
- this.dom = dom;
46
- this.domStyleWrapper = new DomStyleWrapper(dom.style);
47
- }
48
- appendChild(child) {
49
- if (!child)
50
- return;
51
- this.dom.appendChild(child.dom);
52
- this.cachedChildNodes = null;
53
- }
54
- removeChild(child) {
55
- if (!child)
56
- return;
57
- this.dom.removeChild(child.dom);
58
- this.cachedChildNodes = null;
59
- }
60
- insertBefore(a, b) {
61
- this.dom.insertBefore(a?._dom, b?._dom);
62
- this.cachedChildNodes = null;
63
- }
64
- insertAfter(a, b) {
65
- this.dom.insertAfter(a?._dom, b?._dom);
66
- this.cachedChildNodes = null;
67
- }
68
- contains(child) {
69
- if (!child)
70
- return false;
71
- return this.dom.contains(child._dom);
72
- }
73
- clearChildren() {
74
- this.dom.clearChildren();
75
- this.cachedChildNodes = null;
76
- }
77
- focus() {
78
- this.dom.focus();
79
- }
80
- addEventListener(type, listener, useCapture) {
81
- let boundListener = this.boundListeners.get(listener);
82
- if (!boundListener) {
83
- boundListener = listener.bind(this);
84
- this.boundListeners.set(listener, boundListener);
85
- }
86
- this.dom.addEventListener(type, boundListener, useCapture ? true : false);
87
- }
88
- removeEventListener(type, listener, useCapture) {
89
- const boundListener = this.boundListeners.get(listener);
90
- if (boundListener) {
91
- this.dom.removeEventListener(type, boundListener, useCapture ? true : false);
92
- this.boundListeners.delete(listener); // isn't strictly necessary for WeakMap, but still good practice
93
- }
94
- }
95
- setAttribute(name, value) {
96
- this.dom.setAttribute(name, value);
97
- }
98
- removeAttribute(name) {
99
- this.dom.removeAttribute(name);
100
- }
101
- /**
102
- * Returns all elements matching the specified selector.
103
- * Supports basic selectors:
104
- * - Tag names: 'div'
105
- * - IDs: '#myId'
106
- * - Classes: '.myClass'
107
- * - Combinations: 'div.myClass#myId'
108
- */
109
- querySelectorAll(selector) {
110
- const selectorInfo = parseSelector(selector);
111
- const results = [];
112
- function traverse(element) {
113
- if (elementMatchesSelector(element, selectorInfo)) {
114
- results.push(element);
115
- }
116
- for (const child of element.childNodes) {
117
- traverse(child);
118
- }
119
- }
120
- traverse(this);
121
- return results;
122
- }
123
- /**
124
- * Returns the first element matching the specified selector.
125
- * Supports the same basic selectors as querySelectorAll.
126
- */
127
- querySelector(selector) {
128
- const selectorInfo = parseSelector(selector);
129
- function traverse(element) {
130
- if (elementMatchesSelector(element, selectorInfo)) {
131
- return element;
132
- }
133
- for (const child of element.childNodes) {
134
- const match = traverse(child);
135
- if (match) {
136
- return match;
137
- }
138
- }
139
- return null;
140
- }
141
- return traverse(this);
142
- }
143
- }
144
- function parseSelector(selector) {
145
- const selectorInfo = {
146
- classes: []
147
- };
148
- // Handle ID
149
- const idMatch = selector.match(/#([^.#\s]+)/);
150
- if (idMatch) {
151
- selectorInfo.id = idMatch[1];
152
- selector = selector.replace(idMatch[0], '');
153
- }
154
- // Handle classes
155
- const classMatches = selector.match(/\.([^.#\s]+)/g);
156
- if (classMatches) {
157
- selectorInfo.classes = classMatches.map(c => c.substring(1));
158
- selector = selector.replace(/\.[^.#\s]+/g, '');
159
- }
160
- // Handle tag name (what's left after removing id and classes)
161
- const tagName = selector.trim();
162
- if (tagName) {
163
- selectorInfo.tag = tagName.toLowerCase();
164
- }
165
- return selectorInfo;
166
- }
167
- function elementMatchesSelector(element, selectorInfo) {
168
- // Check tag name
169
- if (selectorInfo.tag && element.ve.name.toLowerCase() !== selectorInfo.tag) {
170
- return false;
171
- }
172
- // Check ID
173
- if (selectorInfo.id && element.Id !== selectorInfo.id) {
174
- return false;
175
- }
176
- // Check classes
177
- if (selectorInfo.classes.length > 0) {
178
- const elementClasses = element.classname.split(' ').filter(c => c);
179
- for (const className of selectorInfo.classes) {
180
- if (!elementClasses.includes(className)) {
181
- return false;
182
- }
183
- }
184
- }
185
- return true;
186
- }
187
- export function querySelectorAll(root, selector) {
188
- const results = [];
189
- const selectorInfo = parseSelector(selector);
190
- function traverse(element) {
191
- // Check if current element matches
192
- if (elementMatchesSelector(element, selectorInfo)) {
193
- results.push(element);
194
- }
195
- // Recursively check children
196
- for (const child of element.childNodes) {
197
- traverse(child);
198
- }
199
- }
200
- traverse(root);
201
- return results;
202
- }
203
- export function querySelector(root, selector) {
204
- const selectorInfo = parseSelector(selector);
205
- function traverse(element) {
206
- // Check if current element matches
207
- if (elementMatchesSelector(element, selectorInfo)) {
208
- return element;
209
- }
210
- // Recursively check children
211
- for (const child of element.childNodes) {
212
- const match = traverse(child);
213
- if (match) {
214
- return match;
215
- }
216
- }
217
- return null;
218
- }
219
- return traverse(root);
220
- }
File without changes
File without changes
@@ -1,2 +0,0 @@
1
- export declare function btoa(text: string): string;
2
- export declare function atob(base64: string): string;
@@ -1,35 +0,0 @@
1
- export function btoa(text) {
2
- // return CS.OneJS.CommonGlobals.btoa(text);
3
- const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
4
- let str = text;
5
- let output = '';
6
- for (let i = 0; i < str.length; i += 3) {
7
- 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);
8
- output += chars[(block >> 18) & 0x3F] +
9
- chars[(block >> 12) & 0x3F] +
10
- (i + 1 < str.length ? chars[(block >> 6) & 0x3F] : '=') +
11
- (i + 2 < str.length ? chars[block & 0x3F] : '=');
12
- }
13
- return output;
14
- }
15
- // function uint8ArrayToString(uint8Array) {
16
- // const chars: any = [];
17
- // for (let i = 0; i < uint8Array.length; i++) {
18
- // chars.push(String.fromCharCode(uint8Array[i]));
19
- // }
20
- // return chars.join('');
21
- // }
22
- export function atob(base64) {
23
- // return CS.OneJS.CommonGlobals.atob(base64);
24
- // return CS.System.Text.Encoding.UTF8.GetString(CS.System.Convert.FromBase64String(base64))
25
- const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
26
- let str = base64.replace(/=+$/, '');
27
- let output = '';
28
- if (str.length % 4 == 1) {
29
- throw new Error('Invalid base64 string');
30
- }
31
- 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) {
32
- buffer = chars.indexOf(buffer);
33
- }
34
- return output;
35
- }
@@ -1,9 +0,0 @@
1
- export declare function hashAndAddRuntimeUSS(style: string): string;
2
- /**
3
- * Similar to the Emotion api, this function takes a template string and returns
4
- * a class name that can be used to style an element.
5
- * @param strings
6
- * @param values
7
- * @returns
8
- */
9
- export declare const emo: (strings: TemplateStringsArray, ...values: any[]) => string;
@@ -1,27 +0,0 @@
1
- import flatten from "css-flatten";
2
- import generateComponentId from "./utils/generateComponentId";
3
- const _pastCompIds = new Set();
4
- export function hashAndAddRuntimeUSS(style) {
5
- let compId = generateComponentId(style);
6
- if (_pastCompIds.has(compId))
7
- return compId;
8
- style = `.${compId} {${style}}`;
9
- style = flatten(style);
10
- document.addRuntimeUSS(style);
11
- _pastCompIds.add(compId);
12
- return compId;
13
- }
14
- /**
15
- * Similar to the Emotion api, this function takes a template string and returns
16
- * a class name that can be used to style an element.
17
- * @param strings
18
- * @param values
19
- * @returns
20
- */
21
- export const emo = function (strings, ...values) {
22
- let style = values.reduce((result, expr, index) => {
23
- const value = expr;
24
- return result + (value ? value : "") + strings[index + 1];
25
- }, strings[0]);
26
- return hashAndAddRuntimeUSS(style);
27
- };
@@ -1 +0,0 @@
1
- export default function generateAlphabeticName(code: number): string;
@@ -1,16 +0,0 @@
1
- const AD_REPLACER_R = /(a)(d)/gi;
2
- /* This is the "capacity" of our alphabet i.e. 2x26 for all letters plus their capitalised
3
- * counterparts */
4
- const charsLength = 52;
5
- /* start at 75 for 'a' until 'z' (25) and then start at 65 for capitalised letters */
6
- const getAlphabeticChar = (code) => String.fromCharCode(code + (code > 25 ? 39 : 97));
7
- /* input a number, usually a hash and convert it to base-52 */
8
- export default function generateAlphabeticName(code) {
9
- let name = '';
10
- let x;
11
- /* get a char and divide by alphabet-length */
12
- for (x = Math.abs(code); x > charsLength; x = (x / charsLength) | 0) {
13
- name = getAlphabeticChar(x % charsLength) + name;
14
- }
15
- return (getAlphabeticChar(x % charsLength) + name).replace(AD_REPLACER_R, '$1-$2');
16
- }
@@ -1 +0,0 @@
1
- export default function generateComponentId(str: string): string;
@@ -1,5 +0,0 @@
1
- import generateAlphabeticName from './generateAlphabeticName';
2
- import { hash } from './hash';
3
- export default function generateComponentId(str) {
4
- return generateAlphabeticName(hash(str) >>> 0);
5
- }
@@ -1,5 +0,0 @@
1
- export declare const SEED = 5381;
2
- export declare const phash: (h: number, x: string) => number;
3
- export declare const hash: (x: string) => number;
4
- export declare function generateAlphabeticName(code: number): string;
5
- export default function generateComponentId(str: string): string;
@@ -1,34 +0,0 @@
1
- export const SEED = 5381;
2
- // When we have separate strings it's useful to run a progressive
3
- // version of djb2 where we pretend that we're still looping over
4
- // the same string
5
- export const phash = (h, x) => {
6
- let i = x.length;
7
- while (i) {
8
- h = (h * 33) ^ x.charCodeAt(--i);
9
- }
10
- return h;
11
- };
12
- // This is a djb2 hashing function
13
- export const hash = (x) => {
14
- return phash(SEED, x);
15
- };
16
- const AD_REPLACER_R = /(a)(d)/gi;
17
- /* This is the "capacity" of our alphabet i.e. 2x26 for all letters plus their capitalised
18
- * counterparts */
19
- const charsLength = 52;
20
- /* start at 75 for 'a' until 'z' (25) and then start at 65 for capitalised letters */
21
- const getAlphabeticChar = (code) => String.fromCharCode(code + (code > 25 ? 39 : 97));
22
- /* input a number, usually a hash and convert it to base-52 */
23
- export function generateAlphabeticName(code) {
24
- let name = '';
25
- let x;
26
- /* get a char and divide by alphabet-length */
27
- for (x = Math.abs(code); x > charsLength; x = (x / charsLength) | 0) {
28
- name = getAlphabeticChar(x % charsLength) + name;
29
- }
30
- return (getAlphabeticChar(x % charsLength) + name).replace(AD_REPLACER_R, '$1-$2');
31
- }
32
- export default function generateComponentId(str) {
33
- return generateAlphabeticName(hash(str) >>> 0);
34
- }
@@ -1,2 +0,0 @@
1
- declare let palettes: string[][];
2
- export { palettes };
@@ -1,2 +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
- export { palettes };