@schematichq/schematic-js 0.1.14 → 1.0.0
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/README.md +74 -46
- package/dist/schematic.browser.js +2 -2
- package/dist/schematic.cjs.js +12 -11
- package/dist/schematic.esm.js +12 -11
- package/package.json +24 -24
package/README.md
CHANGED
|
@@ -1,60 +1,88 @@
|
|
|
1
1
|
# schematic-js
|
|
2
2
|
|
|
3
|
+
`schematic-js` is a client-side JavaScript SDK for tracking event-based usage, identifying users, and checking flags using [Schematic](https://schematichq.com).
|
|
4
|
+
|
|
3
5
|
## Install
|
|
4
6
|
|
|
5
|
-
```
|
|
6
|
-
|
|
7
|
+
```bash
|
|
8
|
+
npm install @schematichq/schematic-js
|
|
9
|
+
# or
|
|
10
|
+
yarn add @schematichq/schematic-js
|
|
11
|
+
# or
|
|
12
|
+
pnpm add @schematichq/schematic-js
|
|
7
13
|
```
|
|
8
14
|
|
|
9
|
-
##
|
|
15
|
+
## Usage
|
|
10
16
|
|
|
11
|
-
|
|
12
|
-
yarn build
|
|
13
|
-
```
|
|
17
|
+
You can use Schematic to identify users; after this, your subsequent track events and flag checks will be associated with this user.
|
|
14
18
|
|
|
15
|
-
|
|
19
|
+
```typescript
|
|
20
|
+
import { Schematic } from "@schematichq/schematic-js";
|
|
16
21
|
|
|
17
|
-
```javascript
|
|
18
22
|
const schematic = new Schematic("your-api-key");
|
|
19
23
|
|
|
20
24
|
// Send an identify event
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}
|
|
37
|
-
schematic.identify({ keys, traits, company });
|
|
38
|
-
|
|
39
|
-
// Send a track event
|
|
40
|
-
const event = "query";
|
|
41
|
-
const traits = {
|
|
42
|
-
};
|
|
43
|
-
const company = {
|
|
44
|
-
};
|
|
45
|
-
const user = {
|
|
46
|
-
},
|
|
47
|
-
schematic.track({
|
|
48
|
-
event: "query",
|
|
49
|
-
traits: {
|
|
50
|
-
feature: "feat_cns2asuKAG2",
|
|
51
|
-
},
|
|
52
|
-
company: {
|
|
53
|
-
id: "my-company-id",
|
|
54
|
-
},
|
|
55
|
-
name: "My User",
|
|
56
|
-
user: {
|
|
57
|
-
id: "my-user-id",
|
|
58
|
-
},
|
|
25
|
+
schematic.identify({
|
|
26
|
+
keys: {
|
|
27
|
+
id: "my-user-id",
|
|
28
|
+
},
|
|
29
|
+
traits: {
|
|
30
|
+
anykey: "anyval",
|
|
31
|
+
},
|
|
32
|
+
company: {
|
|
33
|
+
name: "My Company",
|
|
34
|
+
keys: {
|
|
35
|
+
id: "my-company-id",
|
|
36
|
+
},
|
|
37
|
+
traits: {
|
|
38
|
+
location: "Atlanta, GA",
|
|
39
|
+
},
|
|
40
|
+
},
|
|
59
41
|
});
|
|
42
|
+
|
|
43
|
+
// Send a track event to record usage
|
|
44
|
+
schematic.track({ event: "query" });
|
|
45
|
+
|
|
46
|
+
// Check a flag
|
|
47
|
+
schematic.checkFlag("some-flag-key");
|
|
60
48
|
```
|
|
49
|
+
|
|
50
|
+
By default, `checkFlag` will perform a network request to get the flag value for this user. If you'd like to check all flags at once in order to minimize network requests, you can use `checkFlags`:
|
|
51
|
+
|
|
52
|
+
```typescript
|
|
53
|
+
import { Schematic } from "@schematichq/schematic-js";
|
|
54
|
+
|
|
55
|
+
const schematic = new Schematic("your-api-key");
|
|
56
|
+
|
|
57
|
+
schematic.identify({
|
|
58
|
+
keys: { id: "my-user-id" },
|
|
59
|
+
company: {
|
|
60
|
+
keys: { id: "my-company-id" },
|
|
61
|
+
},
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
schematic.checkFlags();
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
Alternatively, you can run in websocket mode, which will keep a persistent connection open to the Schematic service and receive flag updates in real time:
|
|
68
|
+
|
|
69
|
+
```typescript
|
|
70
|
+
import { Schematic } from "@schematichq/schematic-js";
|
|
71
|
+
|
|
72
|
+
const schematic = new Schematic("your-api-key", { useWebSocket: true});
|
|
73
|
+
|
|
74
|
+
schematic.identify({
|
|
75
|
+
keys: { id: "my-user-id" },
|
|
76
|
+
company: { keys: { id: "my-company-id" } },
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
schematic.checkFlag("some-flag-key");
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
## License
|
|
83
|
+
|
|
84
|
+
MIT
|
|
85
|
+
|
|
86
|
+
## Support
|
|
87
|
+
|
|
88
|
+
Need help? Please open a GitHub issue or reach out to [support@schematichq.com](mailto:support@schematichq.com) and we'll be happy to assist.
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
"use strict";(()=>{var
|
|
2
|
-
`)===0?u.substr(1,u.length):u}).forEach(function(u){var
|
|
1
|
+
"use strict";(()=>{var X=Object.create;var R=Object.defineProperty;var z=Object.getOwnPropertyDescriptor;var Y=Object.getOwnPropertyNames;var Z=Object.getPrototypeOf,ee=Object.prototype.hasOwnProperty;var te=(s,t)=>()=>(t||s((t={exports:{}}).exports,t),t.exports);var re=(s,t,n,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Y(t))!ee.call(s,o)&&o!==n&&R(s,o,{get:()=>t[o],enumerable:!(i=z(t,o))||i.enumerable});return s};var ne=(s,t,n)=>(n=s!=null?X(Z(s)):{},re(t||!s||!s.__esModule?R(n,"default",{value:s,enumerable:!0}):n,s));var V=te(j=>{(function(s){var t=function(n){var i=typeof globalThis<"u"&&globalThis||typeof s<"u"&&s||typeof i<"u"&&i,o={searchParams:"URLSearchParams"in i,iterable:"Symbol"in i&&"iterator"in Symbol,blob:"FileReader"in i&&"Blob"in i&&function(){try{return new Blob,!0}catch{return!1}}(),formData:"FormData"in i,arrayBuffer:"ArrayBuffer"in i};function y(e){return e&&DataView.prototype.isPrototypeOf(e)}if(o.arrayBuffer)var h=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],E=ArrayBuffer.isView||function(e){return e&&h.indexOf(Object.prototype.toString.call(e))>-1};function b(e){if(typeof e!="string"&&(e=String(e)),/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(e)||e==="")throw new TypeError('Invalid character in header field name: "'+e+'"');return e.toLowerCase()}function S(e){return typeof e!="string"&&(e=String(e)),e}function w(e){var r={next:function(){var a=e.shift();return{done:a===void 0,value:a}}};return o.iterable&&(r[Symbol.iterator]=function(){return r}),r}function d(e){this.map={},e instanceof d?e.forEach(function(r,a){this.append(a,r)},this):Array.isArray(e)?e.forEach(function(r){this.append(r[0],r[1])},this):e&&Object.getOwnPropertyNames(e).forEach(function(r){this.append(r,e[r])},this)}d.prototype.append=function(e,r){e=b(e),r=S(r);var a=this.map[e];this.map[e]=a?a+", "+r:r},d.prototype.delete=function(e){delete this.map[b(e)]},d.prototype.get=function(e){return e=b(e),this.has(e)?this.map[e]:null},d.prototype.has=function(e){return this.map.hasOwnProperty(b(e))},d.prototype.set=function(e,r){this.map[b(e)]=S(r)},d.prototype.forEach=function(e,r){for(var a in this.map)this.map.hasOwnProperty(a)&&e.call(r,this.map[a],a,this)},d.prototype.keys=function(){var e=[];return this.forEach(function(r,a){e.push(a)}),w(e)},d.prototype.values=function(){var e=[];return this.forEach(function(r){e.push(r)}),w(e)},d.prototype.entries=function(){var e=[];return this.forEach(function(r,a){e.push([a,r])}),w(e)},o.iterable&&(d.prototype[Symbol.iterator]=d.prototype.entries);function O(e){if(e.bodyUsed)return Promise.reject(new TypeError("Already read"));e.bodyUsed=!0}function D(e){return new Promise(function(r,a){e.onload=function(){r(e.result)},e.onerror=function(){a(e.error)}})}function M(e){var r=new FileReader,a=D(r);return r.readAsArrayBuffer(e),a}function q(e){var r=new FileReader,a=D(r);return r.readAsText(e),a}function H(e){for(var r=new Uint8Array(e),a=new Array(r.length),u=0;u<r.length;u++)a[u]=String.fromCharCode(r[u]);return a.join("")}function C(e){if(e.slice)return e.slice(0);var r=new Uint8Array(e.byteLength);return r.set(new Uint8Array(e)),r.buffer}function L(){return this.bodyUsed=!1,this._initBody=function(e){this.bodyUsed=this.bodyUsed,this._bodyInit=e,e?typeof e=="string"?this._bodyText=e:o.blob&&Blob.prototype.isPrototypeOf(e)?this._bodyBlob=e:o.formData&&FormData.prototype.isPrototypeOf(e)?this._bodyFormData=e:o.searchParams&&URLSearchParams.prototype.isPrototypeOf(e)?this._bodyText=e.toString():o.arrayBuffer&&o.blob&&y(e)?(this._bodyArrayBuffer=C(e.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):o.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(e)||E(e))?this._bodyArrayBuffer=C(e):this._bodyText=e=Object.prototype.toString.call(e):this._bodyText="",this.headers.get("content-type")||(typeof e=="string"?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):o.searchParams&&URLSearchParams.prototype.isPrototypeOf(e)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},o.blob&&(this.blob=function(){var e=O(this);if(e)return e;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){if(this._bodyArrayBuffer){var e=O(this);return e||(ArrayBuffer.isView(this._bodyArrayBuffer)?Promise.resolve(this._bodyArrayBuffer.buffer.slice(this._bodyArrayBuffer.byteOffset,this._bodyArrayBuffer.byteOffset+this._bodyArrayBuffer.byteLength)):Promise.resolve(this._bodyArrayBuffer))}else return this.blob().then(M)}),this.text=function(){var e=O(this);if(e)return e;if(this._bodyBlob)return q(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(H(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},o.formData&&(this.formData=function(){return this.text().then(J)}),this.json=function(){return this.text().then(JSON.parse)},this}var W=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function K(e){var r=e.toUpperCase();return W.indexOf(r)>-1?r:e}function v(e,r){if(!(this instanceof v))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');r=r||{};var a=r.body;if(e instanceof v){if(e.bodyUsed)throw new TypeError("Already read");this.url=e.url,this.credentials=e.credentials,r.headers||(this.headers=new d(e.headers)),this.method=e.method,this.mode=e.mode,this.signal=e.signal,!a&&e._bodyInit!=null&&(a=e._bodyInit,e.bodyUsed=!0)}else this.url=String(e);if(this.credentials=r.credentials||this.credentials||"same-origin",(r.headers||!this.headers)&&(this.headers=new d(r.headers)),this.method=K(r.method||this.method||"GET"),this.mode=r.mode||this.mode||null,this.signal=r.signal||this.signal,this.referrer=null,(this.method==="GET"||this.method==="HEAD")&&a)throw new TypeError("Body not allowed for GET or HEAD requests");if(this._initBody(a),(this.method==="GET"||this.method==="HEAD")&&(r.cache==="no-store"||r.cache==="no-cache")){var u=/([?&])_=[^&]*/;if(u.test(this.url))this.url=this.url.replace(u,"$1_="+new Date().getTime());else{var f=/\?/;this.url+=(f.test(this.url)?"&":"?")+"_="+new Date().getTime()}}}v.prototype.clone=function(){return new v(this,{body:this._bodyInit})};function J(e){var r=new FormData;return e.trim().split("&").forEach(function(a){if(a){var u=a.split("="),f=u.shift().replace(/\+/g," "),c=u.join("=").replace(/\+/g," ");r.append(decodeURIComponent(f),decodeURIComponent(c))}}),r}function Q(e){var r=new d,a=e.replace(/\r?\n[\t ]+/g," ");return a.split("\r").map(function(u){return u.indexOf(`
|
|
2
|
+
`)===0?u.substr(1,u.length):u}).forEach(function(u){var f=u.split(":"),c=f.shift().trim();if(c){var T=f.join(":").trim();r.append(c,T)}}),r}L.call(v.prototype);function m(e,r){if(!(this instanceof m))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');r||(r={}),this.type="default",this.status=r.status===void 0?200:r.status,this.ok=this.status>=200&&this.status<300,this.statusText=r.statusText===void 0?"":""+r.statusText,this.headers=new d(r.headers),this.url=r.url||"",this._initBody(e)}L.call(m.prototype),m.prototype.clone=function(){return new m(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new d(this.headers),url:this.url})},m.error=function(){var e=new m(null,{status:0,statusText:""});return e.type="error",e};var $=[301,302,303,307,308];m.redirect=function(e,r){if($.indexOf(r)===-1)throw new RangeError("Invalid status code");return new m(null,{status:r,headers:{location:e}})},n.DOMException=i.DOMException;try{new n.DOMException}catch{n.DOMException=function(r,a){this.message=r,this.name=a;var u=Error(r);this.stack=u.stack},n.DOMException.prototype=Object.create(Error.prototype),n.DOMException.prototype.constructor=n.DOMException}function k(e,r){return new Promise(function(a,u){var f=new v(e,r);if(f.signal&&f.signal.aborted)return u(new n.DOMException("Aborted","AbortError"));var c=new XMLHttpRequest;function T(){c.abort()}c.onload=function(){var p={status:c.status,statusText:c.statusText,headers:Q(c.getAllResponseHeaders()||"")};p.url="responseURL"in c?c.responseURL:p.headers.get("X-Request-URL");var P="response"in c?c.response:c.responseText;setTimeout(function(){a(new m(P,p))},0)},c.onerror=function(){setTimeout(function(){u(new TypeError("Network request failed"))},0)},c.ontimeout=function(){setTimeout(function(){u(new TypeError("Network request failed"))},0)},c.onabort=function(){setTimeout(function(){u(new n.DOMException("Aborted","AbortError"))},0)};function G(p){try{return p===""&&i.location.href?i.location.href:p}catch{return p}}c.open(f.method,G(f.url),!0),f.credentials==="include"?c.withCredentials=!0:f.credentials==="omit"&&(c.withCredentials=!1),"responseType"in c&&(o.blob?c.responseType="blob":o.arrayBuffer&&f.headers.get("Content-Type")&&f.headers.get("Content-Type").indexOf("application/octet-stream")!==-1&&(c.responseType="arraybuffer")),r&&typeof r.headers=="object"&&!(r.headers instanceof d)?Object.getOwnPropertyNames(r.headers).forEach(function(p){c.setRequestHeader(p,S(r.headers[p]))}):f.headers.forEach(function(p,P){c.setRequestHeader(P,p)}),f.signal&&(f.signal.addEventListener("abort",T),c.onreadystatechange=function(){c.readyState===4&&f.signal.removeEventListener("abort",T)}),c.send(typeof f._bodyInit>"u"?null:f._bodyInit)})}return k.polyfill=!0,i.fetch||(i.fetch=k,i.Headers=d,i.Request=v,i.Response=m),n.Headers=d,n.Request=v,n.Response=m,n.fetch=k,n}({})})(typeof self<"u"?self:j)});var l=[];for(U=0;U<256;++U)l.push((U+256).toString(16).slice(1));var U;function F(s,t=0){return(l[s[t+0]]+l[s[t+1]]+l[s[t+2]]+l[s[t+3]]+"-"+l[s[t+4]]+l[s[t+5]]+"-"+l[s[t+6]]+l[s[t+7]]+"-"+l[s[t+8]]+l[s[t+9]]+"-"+l[s[t+10]]+l[s[t+11]]+l[s[t+12]]+l[s[t+13]]+l[s[t+14]]+l[s[t+15]]).toLowerCase()}var A,ie=new Uint8Array(16);function _(){if(!A&&(A=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!A))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return A(ie)}var oe=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),I={randomUUID:oe};function se(s,t,n){if(I.randomUUID&&!t&&!s)return I.randomUUID();s=s||{};var i=s.random||(s.rng||_)();if(i[6]=i[6]&15|64,i[8]=i[8]&63|128,t){n=n||0;for(var o=0;o<16;++o)t[n+o]=i[o];return t}return F(i)}var x=se;var be=ne(V());function g(s){let t=Object.keys(s).reduce((n,i)=>{let y=Object.keys(s[i]||{}).sort().reduce((h,E)=>(h[E]=s[i][E],h),{});return n[i]=y,n},{});return JSON.stringify(t)}var N="schematicId";var B=class{apiKey;apiUrl="https://api.schematichq.com";conn=null;context={};eventQueue;eventUrl="https://c.schematichq.com";flagListener;flagValueListeners={};isPending=!0;isPendingListeners=new Set;storage;useWebSocket=!1;values={};webSocketUrl="wss://api.schematichq.com";constructor(t,n){this.apiKey=t,this.eventQueue=[],this.useWebSocket=n?.useWebSocket??!1,this.flagListener=n?.flagListener,n?.storage?this.storage=n.storage:typeof localStorage<"u"&&(this.storage=localStorage),n?.apiUrl!==void 0&&(this.apiUrl=n.apiUrl),n?.eventUrl!==void 0&&(this.eventUrl=n.eventUrl),n?.webSocketUrl!==void 0&&(this.webSocketUrl=n.webSocketUrl),typeof window<"u"&&window?.addEventListener&&window.addEventListener("beforeunload",()=>{this.flushEventQueue()})}async checkFlag(t){let{fallback:n=!1,key:i}=t,o=t.context||this.context;if(this.useWebSocket){let h=this.values[g(o)]??{};return typeof h[i]>"u"?n:h[i]}let y=`${this.apiUrl}/flags/${i}/check`;return fetch(y,{method:"POST",headers:{"X-Schematic-Api-Key":this.apiKey,"Content-Type":"application/json;charset=UTF-8"},body:JSON.stringify(o)}).then(h=>{if(!h.ok)throw new Error("Network response was not ok");return h.json()}).then(h=>h.data.value).catch(h=>(console.error("There was a problem with the fetch operation:",h),n))}checkFlags=async t=>{t=t||this.context;let n=`${this.apiUrl}/flags/check`,i=JSON.stringify(t);return fetch(n,{method:"POST",headers:{"Content-Type":"application/json;charset=UTF-8","X-Schematic-Api-Key":this.apiKey},body:i}).then(o=>{if(!o.ok)throw new Error("Network response was not ok");return o.json()}).then(o=>(o?.data?.flags??[]).reduce((y,h)=>(y[h.flag]=h.value,y),{})).catch(o=>(console.error("There was a problem with the fetch operation:",o),!1))};identify=t=>(this.setContext({company:t.company?.keys,user:t.keys}),this.handleEvent("identify",t));setContext=async t=>{if(!this.useWebSocket)return this.context=t,Promise.resolve();try{this.setIsPending(!0),this.conn||(this.conn=this.wsConnect());let n=await this.conn;await this.wsSendMessage(n,t)}catch(n){console.error("Error setting Schematic context:",n)}};track=t=>{let{company:n,user:i,event:o,traits:y}=t;return this.handleEvent("track",{company:n??this.context.company,event:o,traits:y??{},user:i??this.context.user})};flushEventQueue=()=>{for(;this.eventQueue.length>0;){let t=this.eventQueue.shift();t&&this.sendEvent(t)}};getAnonymousId=()=>{if(!this.storage)return x();let t=this.storage.getItem(N);if(typeof t<"u")return t;let n=x();return this.storage.setItem(N,n),n};handleEvent=(t,n)=>{let i={api_key:this.apiKey,body:n,sent_at:new Date().toISOString(),tracker_event_id:x(),tracker_user_id:this.getAnonymousId(),type:t};return document?.hidden?this.storeEvent(i):this.sendEvent(i)};sendEvent=async t=>{let n=`${this.eventUrl}/e`,i=JSON.stringify(t);try{await fetch(n,{method:"POST",headers:{"Content-Type":"application/json;charset=UTF-8"},body:i})}catch(o){console.error("Error sending Schematic event: ",o)}return Promise.resolve()};storeEvent=t=>(this.eventQueue.push(t),Promise.resolve());cleanup=async()=>{if(this.conn)try{(await this.conn).close()}catch(t){console.error("Error during cleanup:",t)}finally{this.conn=null}};wsConnect=()=>new Promise((t,n)=>{let i=`${this.webSocketUrl}/flags/bootstrap`,o=new WebSocket(i);o.onopen=()=>{t(o)},o.onerror=y=>{n(y)},o.onclose=()=>{this.conn=null}});wsSendMessage=(t,n)=>new Promise((i,o)=>{if(g(n)==g(this.context)){i();return}this.context=n;let y=()=>{let h=!1,E=b=>{let S=JSON.parse(b.data);g(n)in this.values||(this.values[g(n)]={}),(S.flags??[]).forEach(w=>{this.values[g(n)][w.flag]=w.value,this.notifyFlagValueListeners(w.flag)}),this.flagListener&&this.flagListener(this.getFlagValues()),this.setIsPending(!1),h||(h=!0,i())};t.addEventListener("message",E),t.send(JSON.stringify({apiKey:this.apiKey,data:n}))};t.readyState===WebSocket.OPEN?y():t.readyState===WebSocket.CONNECTING?t.addEventListener("open",y):o("WebSocket is not open or connecting")});getIsPending=()=>this.isPending;addIsPendingListener=t=>(this.isPendingListeners.add(t),()=>{this.isPendingListeners.delete(t)});setIsPending=t=>{this.isPending=t,this.isPendingListeners.forEach(n=>n())};getFlagValue=t=>this.getFlagValues()[t];getFlagValues=()=>{let t=g(this.context);return this.values[t]??{}};addFlagValueListener=(t,n)=>(t in this.flagValueListeners||(this.flagValueListeners[t]=new Set),this.flagValueListeners[t].add(n),()=>{this.flagValueListeners[t].delete(n)});notifyFlagValueListeners=t=>{(this.flagValueListeners?.[t]??[]).forEach(i=>i())}};window.Schematic=B;})();
|
|
3
3
|
/* @preserve */
|
package/dist/schematic.cjs.js
CHANGED
|
@@ -539,6 +539,16 @@ __export(src_exports, {
|
|
|
539
539
|
});
|
|
540
540
|
module.exports = __toCommonJS(src_exports);
|
|
541
541
|
|
|
542
|
+
// node_modules/uuid/dist/esm-browser/stringify.js
|
|
543
|
+
var byteToHex = [];
|
|
544
|
+
for (i = 0; i < 256; ++i) {
|
|
545
|
+
byteToHex.push((i + 256).toString(16).slice(1));
|
|
546
|
+
}
|
|
547
|
+
var i;
|
|
548
|
+
function unsafeStringify(arr, offset = 0) {
|
|
549
|
+
return (byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + "-" + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + "-" + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + "-" + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + "-" + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]).toLowerCase();
|
|
550
|
+
}
|
|
551
|
+
|
|
542
552
|
// node_modules/uuid/dist/esm-browser/rng.js
|
|
543
553
|
var getRandomValues;
|
|
544
554
|
var rnds8 = new Uint8Array(16);
|
|
@@ -552,15 +562,6 @@ function rng() {
|
|
|
552
562
|
return getRandomValues(rnds8);
|
|
553
563
|
}
|
|
554
564
|
|
|
555
|
-
// node_modules/uuid/dist/esm-browser/stringify.js
|
|
556
|
-
var byteToHex = [];
|
|
557
|
-
for (let i = 0; i < 256; ++i) {
|
|
558
|
-
byteToHex.push((i + 256).toString(16).slice(1));
|
|
559
|
-
}
|
|
560
|
-
function unsafeStringify(arr, offset = 0) {
|
|
561
|
-
return byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + "-" + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + "-" + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + "-" + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + "-" + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]];
|
|
562
|
-
}
|
|
563
|
-
|
|
564
565
|
// node_modules/uuid/dist/esm-browser/native.js
|
|
565
566
|
var randomUUID = typeof crypto !== "undefined" && crypto.randomUUID && crypto.randomUUID.bind(crypto);
|
|
566
567
|
var native_default = {
|
|
@@ -573,12 +574,12 @@ function v4(options, buf, offset) {
|
|
|
573
574
|
return native_default.randomUUID();
|
|
574
575
|
}
|
|
575
576
|
options = options || {};
|
|
576
|
-
|
|
577
|
+
var rnds = options.random || (options.rng || rng)();
|
|
577
578
|
rnds[6] = rnds[6] & 15 | 64;
|
|
578
579
|
rnds[8] = rnds[8] & 63 | 128;
|
|
579
580
|
if (buf) {
|
|
580
581
|
offset = offset || 0;
|
|
581
|
-
for (
|
|
582
|
+
for (var i = 0; i < 16; ++i) {
|
|
582
583
|
buf[offset + i] = rnds[i];
|
|
583
584
|
}
|
|
584
585
|
return buf;
|
package/dist/schematic.esm.js
CHANGED
|
@@ -526,6 +526,16 @@ var require_browser_polyfill = __commonJS({
|
|
|
526
526
|
}
|
|
527
527
|
});
|
|
528
528
|
|
|
529
|
+
// node_modules/uuid/dist/esm-browser/stringify.js
|
|
530
|
+
var byteToHex = [];
|
|
531
|
+
for (i = 0; i < 256; ++i) {
|
|
532
|
+
byteToHex.push((i + 256).toString(16).slice(1));
|
|
533
|
+
}
|
|
534
|
+
var i;
|
|
535
|
+
function unsafeStringify(arr, offset = 0) {
|
|
536
|
+
return (byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + "-" + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + "-" + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + "-" + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + "-" + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]).toLowerCase();
|
|
537
|
+
}
|
|
538
|
+
|
|
529
539
|
// node_modules/uuid/dist/esm-browser/rng.js
|
|
530
540
|
var getRandomValues;
|
|
531
541
|
var rnds8 = new Uint8Array(16);
|
|
@@ -539,15 +549,6 @@ function rng() {
|
|
|
539
549
|
return getRandomValues(rnds8);
|
|
540
550
|
}
|
|
541
551
|
|
|
542
|
-
// node_modules/uuid/dist/esm-browser/stringify.js
|
|
543
|
-
var byteToHex = [];
|
|
544
|
-
for (let i = 0; i < 256; ++i) {
|
|
545
|
-
byteToHex.push((i + 256).toString(16).slice(1));
|
|
546
|
-
}
|
|
547
|
-
function unsafeStringify(arr, offset = 0) {
|
|
548
|
-
return byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + "-" + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + "-" + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + "-" + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + "-" + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]];
|
|
549
|
-
}
|
|
550
|
-
|
|
551
552
|
// node_modules/uuid/dist/esm-browser/native.js
|
|
552
553
|
var randomUUID = typeof crypto !== "undefined" && crypto.randomUUID && crypto.randomUUID.bind(crypto);
|
|
553
554
|
var native_default = {
|
|
@@ -560,12 +561,12 @@ function v4(options, buf, offset) {
|
|
|
560
561
|
return native_default.randomUUID();
|
|
561
562
|
}
|
|
562
563
|
options = options || {};
|
|
563
|
-
|
|
564
|
+
var rnds = options.random || (options.rng || rng)();
|
|
564
565
|
rnds[6] = rnds[6] & 15 | 64;
|
|
565
566
|
rnds[8] = rnds[8] & 63 | 128;
|
|
566
567
|
if (buf) {
|
|
567
568
|
offset = offset || 0;
|
|
568
|
-
for (
|
|
569
|
+
for (var i = 0; i < 16; ++i) {
|
|
569
570
|
buf[offset + i] = rnds[i];
|
|
570
571
|
}
|
|
571
572
|
return buf;
|
package/package.json
CHANGED
|
@@ -1,35 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@schematichq/schematic-js",
|
|
3
|
+
"version": "1.0.0",
|
|
3
4
|
"main": "dist/schematic.cjs.js",
|
|
4
5
|
"module": "dist/schematic.esm.js",
|
|
5
|
-
"
|
|
6
|
-
"dependencies": {
|
|
7
|
-
"cross-fetch": "^4.0.0",
|
|
8
|
-
"uuid": "^9.0.0"
|
|
9
|
-
},
|
|
10
|
-
"devDependencies": {
|
|
11
|
-
"@microsoft/api-extractor": "^7.38.3",
|
|
12
|
-
"@types/jest": "^29.5.11",
|
|
13
|
-
"@types/uuid": "^9.0.2",
|
|
14
|
-
"@typescript-eslint/eslint-plugin": "^6.13.2",
|
|
15
|
-
"@typescript-eslint/parser": "^6.13.2",
|
|
16
|
-
"esbuild": "^0.19.9",
|
|
17
|
-
"esbuild-jest": "^0.5.0",
|
|
18
|
-
"eslint": "^8.55.0",
|
|
19
|
-
"jest": "^29.7.0",
|
|
20
|
-
"jest-environment-jsdom": "^29.7.0",
|
|
21
|
-
"jest-esbuild": "^0.3.0",
|
|
22
|
-
"jest-fetch-mock": "^3.0.3",
|
|
23
|
-
"prettier": "^3.3.1",
|
|
24
|
-
"ts-jest": "^29.1.1",
|
|
25
|
-
"typescript": "^5.0.2"
|
|
26
|
-
},
|
|
6
|
+
"types": "dist/schematic.d.ts",
|
|
27
7
|
"files": [
|
|
28
8
|
"dist/schematic.cjs.js",
|
|
29
9
|
"dist/schematic.esm.js",
|
|
30
10
|
"dist/schematic.browser.js",
|
|
31
11
|
"dist/schematic.d.ts"
|
|
32
12
|
],
|
|
13
|
+
"author": "Schematic <engineering@schematichq.com>",
|
|
33
14
|
"license": "MIT",
|
|
34
15
|
"repository": {
|
|
35
16
|
"type": "git",
|
|
@@ -46,7 +27,26 @@
|
|
|
46
27
|
"lint": "eslint src --ext ts,tsx --report-unused-disable-directives --fix",
|
|
47
28
|
"test": "jest --config jest.config.js"
|
|
48
29
|
},
|
|
49
|
-
"
|
|
50
|
-
|
|
30
|
+
"dependencies": {
|
|
31
|
+
"cross-fetch": "^4.0.0",
|
|
32
|
+
"uuid": "^10.0.0"
|
|
33
|
+
},
|
|
34
|
+
"devDependencies": {
|
|
35
|
+
"@microsoft/api-extractor": "^7.47.9",
|
|
36
|
+
"@types/jest": "^29.5.13",
|
|
37
|
+
"@types/uuid": "^10.0.0",
|
|
38
|
+
"@typescript-eslint/eslint-plugin": "^8.7.0",
|
|
39
|
+
"@typescript-eslint/parser": "^8.7.0",
|
|
40
|
+
"esbuild": "^0.24.0",
|
|
41
|
+
"esbuild-jest": "^0.5.0",
|
|
42
|
+
"eslint": "^8.57.1",
|
|
43
|
+
"jest": "^29.7.0",
|
|
44
|
+
"jest-environment-jsdom": "^29.7.0",
|
|
45
|
+
"jest-esbuild": "^0.3.0",
|
|
46
|
+
"jest-fetch-mock": "^3.0.3",
|
|
47
|
+
"prettier": "^3.3.3",
|
|
48
|
+
"ts-jest": "^29.2.5",
|
|
49
|
+
"typescript": "^5.6.2"
|
|
50
|
+
},
|
|
51
51
|
"packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
|
|
52
52
|
}
|