@powerhousedao/connect 2.5.0-dev.22 → 2.5.0-dev.23
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/dist/assets/{app-BcXkGQiq.js → app-Alk9qrjX.js} +7 -7
- package/dist/assets/{app-BcXkGQiq.js.map → app-Alk9qrjX.js.map} +1 -1
- package/dist/assets/{ccip-CuEI6ate.js → ccip-C2kxwMKJ.js} +2 -2
- package/dist/assets/{ccip-CuEI6ate.js.map → ccip-C2kxwMKJ.js.map} +1 -1
- package/dist/assets/{content-d2haQv36.js → content-XbP7Qpdm.js} +2 -2
- package/dist/assets/{content-d2haQv36.js.map → content-XbP7Qpdm.js.map} +1 -1
- package/dist/assets/{cookie-banner-DR0V1IJG.js → cookie-banner-Dw62ggoe.js} +2 -2
- package/dist/assets/{cookie-banner-DR0V1IJG.js.map → cookie-banner-Dw62ggoe.js.map} +1 -1
- package/dist/assets/{index-CYlcJ2ja.js → index-C4XTqgMr.js} +5 -5
- package/dist/assets/{index-CYlcJ2ja.js.map → index-C4XTqgMr.js.map} +1 -1
- package/dist/assets/{index-CRQWfxlS.js → index-CU4yn4R-.js} +2 -2
- package/dist/assets/{index-CRQWfxlS.js.map → index-CU4yn4R-.js.map} +1 -1
- package/dist/assets/{index-3nfLp-u3.js → index-ClZZWwc1.js} +2 -2
- package/dist/assets/{index-3nfLp-u3.js.map → index-ClZZWwc1.js.map} +1 -1
- package/dist/assets/{index-CwT7v3QF.js → index-DWc6NEFf.js} +2 -2
- package/dist/assets/{index-CwT7v3QF.js.map → index-DWc6NEFf.js.map} +1 -1
- package/dist/assets/{index-C-s-fxTL.js → index-mfD0BTV6.js} +2 -2
- package/dist/assets/{index-C-s-fxTL.js.map → index-mfD0BTV6.js.map} +1 -1
- package/dist/assets/{isAddressEqual-DREghARX.js → isAddressEqual-s0HpRdBm.js} +2 -2
- package/dist/assets/{isAddressEqual-DREghARX.js.map → isAddressEqual-s0HpRdBm.js.map} +1 -1
- package/dist/assets/{main.B6BOUKAI.js → main.BTov0zDh.js} +3 -3
- package/dist/assets/{main.B6BOUKAI.js.map → main.BTov0zDh.js.map} +1 -1
- package/dist/assets/{nodefs-CeZROlM7.js → nodefs-Cr126LLN.js} +2 -2
- package/dist/assets/{nodefs-CeZROlM7.js.map → nodefs-Cr126LLN.js.map} +1 -1
- package/dist/assets/{opfs-ahp-DsHAic0w.js → opfs-ahp-DFXw6BcF.js} +2 -2
- package/dist/assets/{opfs-ahp-DsHAic0w.js.map → opfs-ahp-DFXw6BcF.js.map} +1 -1
- package/dist/assets/{reactor-analytics-CrgBcpoI.js → reactor-analytics-BrbBM4g5.js} +3 -3
- package/dist/assets/{reactor-analytics-CrgBcpoI.js.map → reactor-analytics-BrbBM4g5.js.map} +1 -1
- package/dist/assets/{router-DkUmzbHQ.js → router-DbdVa_mQ.js} +4 -4
- package/dist/assets/{router-DkUmzbHQ.js.map → router-DbdVa_mQ.js.map} +1 -1
- package/dist/index.html +1 -1
- package/dist/vite-envs.sh +1 -1
- package/package.json +9 -9
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var y=Object.defineProperty;var m=(s,t,e)=>t in s?y(s,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):s[t]=e;var d=(s,t,e)=>m(s,typeof t!="symbol"?t+"":t,e);import{X as $,cE as g,d4 as S,cF as w}from"./app-
|
|
2
|
-
//# sourceMappingURL=index-
|
|
1
|
+
var y=Object.defineProperty;var m=(s,t,e)=>t in s?y(s,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):s[t]=e;var d=(s,t,e)=>m(s,typeof t!="symbol"?t+"":t,e);import{X as $,cE as g,d4 as S,cF as w}from"./app-Alk9qrjX.js";import"./main.BTov0zDh.js";import"react/jsx-runtime";import"react";import"./index-C4XTqgMr.js";import"react-dom/client";import"react-dom";import"./isAddressEqual-s0HpRdBm.js";function V(s,t){const e=[],a=h(s,t,"state.global","global");e.push(...a);const o=e.filter(l=>l.type==="add").length,i=e.filter(l=>l.type==="remove").length,r={global:e.filter(l=>l.scope==="global")};return{totalChanges:e.length,additions:o,removals:i,changesByScope:r,changes:e}}function h(s,t,e,a){const o=[];if(Array.isArray(s)&&Array.isArray(t)){let n=0;for(;n<s.length;n++){const c=s[n];if(!t[n])o.push(...h(c,typeof c=="string"?"":null,`${e}[${n}]`,a));else{const u=h(c,t[n],`${e}[${n}]`,a);o.push(...u)}}for(;n<t.length;n++){const c=t[n];if(!s[n])o.push(...h(typeof c=="string"?"":null,c,`${e}[${n}]`,a));else{const u=h(s[n],c,`${e}[${n}]`,a);o.push(...u)}}return o}if(typeof s!="object"||typeof t!="object"||s===null||t===null){if(s!==t){if(typeof s=="string"&&typeof t=="string")return A(s,t,e,a);o.push({type:"remove",path:e,oldValue:s,scope:a}),o.push({type:"add",path:e,newValue:t,scope:a})}return o}const i=s,r=t,l=Object.keys(i),f=Object.keys(r);for(const n of l)n in r||o.push({type:"remove",path:`${e}.${n}`,oldValue:i[n],scope:a});for(const n of f)if(!(n in i))o.push({type:"add",path:`${e}.${n}`,newValue:r[n],scope:a});else if(i[n]!==r[n]){const c=h(i[n],r[n],`${e}.${n}`,a);o.push(...c)}return o}function A(s,t,e,a){const o=[],i=Math.max(s.length,t.length);for(let r=0;r<i;r++)r>=s.length?o.push({type:"add",path:`${e}[${r}]`,newValue:t[r],scope:a}):r>=t.length?o.push({type:"remove",path:`${e}[${r}]`,oldValue:s[r],scope:a}):s[r]!==t[r]&&(o.push({type:"remove",path:`${e}[${r}]`,oldValue:s[r],scope:a}),o.push({type:"add",path:`${e}[${r}]`,newValue:t[r],scope:a}));return o}class v{constructor(t,e=$(["processor","diff-analytics"])){d(this,"analyticsStore");d(this,"logger");this.analyticsStore=t,this.logger=e}async onStrands(t){if(t.length!==0)for(const e of t){if(e.operations.length===0)continue;const a=e.operations[0],o=g.fromString(`ph/${e.documentId}/${e.branch}/${e.scope}`);a.index===0&&await this.clearSource(o);const i=50;for(let r=0;r<e.operations.length;r+=i){const l=e.operations.slice(r,r+i),f=[];for(const n of l){const u=(await S(async()=>V(n.previousState,n.state))).changes.map(p=>this.generateInput(e.documentId,e.branch,e.scope,n.index,p.type,1,o,n.timestamp,p.path));for(f.push(...u);f.length>=i;){const p=f.splice(0,i);await this.analyticsStore.addSeriesValues(p)}}f.length>0&&await this.analyticsStore.addSeriesValues(f)}}}async onDisconnect(){}async clearSource(t){try{await this.analyticsStore.clearSeriesBySource(t,!0)}catch(e){this.logger.error("Failed to clear source",e)}}generateInput(t,e,a,o,i,r,l,f,n){const c={},u=n.split("[")[0].replaceAll(".","/");return c.changes=g.fromString(`changes/${i}`),c.document=g.fromString(`document/${t}/${e}/${a}/${o}`),c.path=g.fromString(`path/${u}`),{dimensions:c,metric:"Count",start:w.fromISO(f),source:l,value:r}}}const B=s=>t=>[{processor:new v(s.analyticsStore),filter:{branch:["main"],documentId:["*"],scope:["*"],documentType:["*"]}}];export{B as processorFactory};
|
|
2
|
+
//# sourceMappingURL=index-CU4yn4R-.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index-CRQWfxlS.js","sources":["../../../../node_modules/.pnpm/@powerhousedao+diff-analyzer@0.0.0-dev.7_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@powerhousedao/diff-analyzer/dist/lib/document-diff.js","../../../../node_modules/.pnpm/@powerhousedao+diff-analyzer@0.0.0-dev.7_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@powerhousedao/diff-analyzer/dist/processors/diff-analytics/index.js","../../../../node_modules/.pnpm/@powerhousedao+diff-analyzer@0.0.0-dev.7_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@powerhousedao/diff-analyzer/dist/processors/index.js"],"sourcesContent":["/**\n * Calculates the difference between two document states\n */\nexport function diffDocumentStates(doc1, doc2) {\n const changes = [];\n // Compare global state\n const globalChanges = diffStateObjects(doc1, doc2, \"state.global\", \"global\");\n changes.push(...globalChanges);\n // Count changes by type\n const additions = changes.filter((c) => c.type === \"add\").length;\n const removals = changes.filter((c) => c.type === \"remove\").length;\n // Group changes by scope\n const changesByScope = {\n global: changes.filter((c) => c.scope === \"global\"),\n };\n return {\n totalChanges: changes.length,\n additions,\n removals,\n changesByScope,\n changes,\n };\n}\n/**\n * Recursively compares two state objects and returns a list of changes\n */\nfunction diffStateObjects(obj1, obj2, path, scope) {\n const changes = [];\n // Handle arrays\n if (Array.isArray(obj1) && Array.isArray(obj2)) {\n let index = 0;\n for (; index < obj1.length; index++) {\n const element = obj1[index];\n if (!obj2[index]) {\n changes.push(...diffStateObjects(element, typeof element === \"string\" ? \"\" : null, `${path}[${index}]`, scope));\n }\n else {\n const elementChanges = diffStateObjects(element, obj2[index], `${path}[${index}]`, scope);\n changes.push(...elementChanges);\n }\n }\n for (; index < obj2.length; index++) {\n const element = obj2[index];\n if (!obj1[index]) {\n changes.push(...diffStateObjects(typeof element === \"string\" ? \"\" : null, element, `${path}[${index}]`, scope));\n }\n else {\n const elementChanges = diffStateObjects(obj1[index], element, `${path}[${index}]`, scope);\n changes.push(...elementChanges);\n }\n }\n return changes;\n }\n // Handle primitive values\n if (typeof obj1 !== \"object\" ||\n typeof obj2 !== \"object\" ||\n obj1 === null ||\n obj2 === null) {\n if (obj1 !== obj2) {\n // Special handling for strings to diff character by character\n if (typeof obj1 === \"string\" && typeof obj2 === \"string\") {\n return diffStateStrings(obj1, obj2, path, scope);\n }\n else {\n // For non-string primitives, treat a change as a remove + add\n changes.push({\n type: \"remove\",\n path,\n oldValue: obj1,\n scope,\n });\n changes.push({\n type: \"add\",\n path,\n newValue: obj2,\n scope,\n });\n }\n }\n return changes;\n }\n // Handle objects\n const obj1Record = obj1;\n const obj2Record = obj2;\n const obj1Keys = Object.keys(obj1Record);\n const obj2Keys = Object.keys(obj2Record);\n // First, check for removed keys\n for (const key of obj1Keys) {\n if (!(key in obj2Record)) {\n // Key was removed\n changes.push({\n type: \"remove\",\n path: `${path}.${key}`,\n oldValue: obj1Record[key],\n scope,\n });\n }\n }\n // Then, check for added keys and modified values\n for (const key of obj2Keys) {\n if (!(key in obj1Record)) {\n // Key was added\n changes.push({\n type: \"add\",\n path: `${path}.${key}`,\n newValue: obj2Record[key],\n scope,\n });\n }\n else if (obj1Record[key] !== obj2Record[key]) {\n // For object changes, recursively diff the objects\n const nestedChanges = diffStateObjects(obj1Record[key], obj2Record[key], `${path}.${key}`, scope);\n changes.push(...nestedChanges);\n }\n }\n return changes;\n}\n/**\n * Compares two strings character by character and returns a list of changes\n */\nfunction diffStateStrings(str1, str2, path, scope) {\n const changes = [];\n const maxLen = Math.max(str1.length, str2.length);\n for (let i = 0; i < maxLen; i++) {\n if (i >= str1.length) {\n // Addition of new character\n changes.push({\n type: \"add\",\n path: `${path}[${i}]`,\n newValue: str2[i],\n scope,\n });\n }\n else if (i >= str2.length) {\n // Removal of character\n changes.push({\n type: \"remove\",\n path: `${path}[${i}]`,\n oldValue: str1[i],\n scope,\n });\n }\n else if (str1[i] !== str2[i]) {\n // Character changed\n changes.push({\n type: \"remove\",\n path: `${path}[${i}]`,\n oldValue: str1[i],\n scope,\n });\n changes.push({\n type: \"add\",\n path: `${path}[${i}]`,\n newValue: str2[i],\n scope,\n });\n }\n }\n return changes;\n}\n/**\n * Generates analytics data from a state diff summary\n */\nexport function generateStateAnalyticsData(diff) {\n return {\n totalChanges: diff.totalChanges,\n changesByType: {\n add: diff.additions,\n remove: diff.removals,\n },\n changesByScope: {\n global: diff.changesByScope.global.length,\n },\n changePaths: diff.changes.map((c) => c.path),\n };\n}\n","import { AnalyticsPath, } from \"@powerhousedao/analytics-engine-core\";\nimport { DateTime } from \"luxon\";\nimport { diffDocumentStates } from \"../../lib/document-diff.js\";\nimport { childLogger } from \"document-drive\";\nimport { runAsapAsync } from \"document-drive/utils/misc\";\nexport class DiffAnalyticsProcessor {\n analyticsStore;\n logger;\n constructor(analyticsStore, logger = childLogger([\"processor\", \"diff-analytics\"])) {\n this.analyticsStore = analyticsStore;\n this.logger = logger;\n //\n }\n async onStrands(strands) {\n if (strands.length === 0) {\n return;\n }\n for (const strand of strands) {\n if (strand.operations.length === 0) {\n continue;\n }\n const firstOp = strand.operations[0];\n const source = AnalyticsPath.fromString(`ph/${strand.documentId}/${strand.branch}/${strand.scope}`);\n if (firstOp.index === 0) {\n await this.clearSource(source);\n }\n const CHUNK_SIZE = 50;\n for (let i = 0; i < strand.operations.length; i += CHUNK_SIZE) {\n const chunk = strand.operations.slice(i, i + CHUNK_SIZE);\n const buffer = [];\n for (const operation of chunk) {\n const diff = await runAsapAsync(async () => diffDocumentStates(operation.previousState, operation.state));\n const inputs = diff.changes.map((change) => this.generateInput(strand.documentId, strand.branch, strand.scope, operation.index, change.type, 1, source, operation.timestamp, change.path));\n buffer.push(...inputs);\n while (buffer.length >= CHUNK_SIZE) {\n const batch = buffer.splice(0, CHUNK_SIZE);\n await this.analyticsStore.addSeriesValues(batch);\n }\n }\n // Flush any remaining inputs\n if (buffer.length > 0) {\n await this.analyticsStore.addSeriesValues(buffer);\n }\n }\n }\n }\n async onDisconnect() { }\n async clearSource(source) {\n try {\n await this.analyticsStore.clearSeriesBySource(source, true);\n }\n catch (e) {\n this.logger.error(\"Failed to clear source\", e);\n }\n }\n generateInput(documentId, branch, scope, revision, type, value, source, timestamp, path) {\n const dimensions = {};\n const changePath = path.split(\"[\")[0].replaceAll(\".\", \"/\");\n dimensions.changes = AnalyticsPath.fromString(`changes/${type}`);\n dimensions.document = AnalyticsPath.fromString(`document/${documentId}/${branch}/${scope}/${revision}`);\n dimensions.path = AnalyticsPath.fromString(`path/${changePath}`);\n return {\n dimensions,\n metric: \"Count\",\n start: DateTime.fromISO(timestamp),\n source,\n value,\n };\n }\n}\n","/**\n * This is a scaffold file meant for customization.\n * Delete the file and run the code generator again to have it reset\n */\nimport { DiffAnalyticsProcessor } from \"./diff-analytics/index.js\";\nexport const processorFactory = (module) => (driveId) => {\n return [\n {\n processor: new DiffAnalyticsProcessor(module.analyticsStore),\n filter: {\n branch: [\"main\"],\n documentId: [\"*\"],\n scope: [\"*\"],\n documentType: [\"*\"],\n },\n },\n ];\n};\n"],"names":["diffDocumentStates","doc1","doc2","changes","globalChanges","diffStateObjects","additions","c","removals","changesByScope","obj1","obj2","path","scope","index","element","elementChanges","diffStateStrings","obj1Record","obj2Record","obj1Keys","obj2Keys","key","nestedChanges","str1","str2","maxLen","i","DiffAnalyticsProcessor","analyticsStore","logger","childLogger","__publicField","strands","strand","firstOp","source","AnalyticsPath","CHUNK_SIZE","chunk","buffer","operation","inputs","runAsapAsync","change","batch","documentId","branch","revision","type","value","timestamp","dimensions","changePath","DateTime","processorFactory","module","driveId"],"mappings":"iZAGO,SAASA,EAAmBC,EAAMC,EAAM,CAC3C,MAAMC,EAAU,CAAE,EAEZC,EAAgBC,EAAiBJ,EAAMC,EAAM,eAAgB,QAAQ,EAC3EC,EAAQ,KAAK,GAAGC,CAAa,EAE7B,MAAME,EAAYH,EAAQ,OAAQI,GAAMA,EAAE,OAAS,KAAK,EAAE,OACpDC,EAAWL,EAAQ,OAAQI,GAAMA,EAAE,OAAS,QAAQ,EAAE,OAEtDE,EAAiB,CACnB,OAAQN,EAAQ,OAAQI,GAAMA,EAAE,QAAU,QAAQ,CACrD,EACD,MAAO,CACH,aAAcJ,EAAQ,OACtB,UAAAG,EACA,SAAAE,EACA,eAAAC,EACA,QAAAN,CACH,CACL,CAIA,SAASE,EAAiBK,EAAMC,EAAMC,EAAMC,EAAO,CAC/C,MAAMV,EAAU,CAAE,EAElB,GAAI,MAAM,QAAQO,CAAI,GAAK,MAAM,QAAQC,CAAI,EAAG,CAC5C,IAAIG,EAAQ,EACZ,KAAOA,EAAQJ,EAAK,OAAQI,IAAS,CACjC,MAAMC,EAAUL,EAAKI,CAAK,EAC1B,GAAI,CAACH,EAAKG,CAAK,EACXX,EAAQ,KAAK,GAAGE,EAAiBU,EAAS,OAAOA,GAAY,SAAW,GAAK,KAAM,GAAGH,CAAI,IAAIE,CAAK,IAAKD,CAAK,CAAC,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wC,EAAa,CAAE,EACfC,EAAazC,EAAK,MAAM,GAAG,EAAE,CAAC,EAAE,WAAW,IAAK,GAAG,EACzD,OAAAwC,EAAW,QAAUf,EAAc,WAAW,WAAWY,CAAI,EAAE,EAC/DG,EAAW,SAAWf,EAAc,WAAW,YAAYS,CAAU,IAAIC,CAAM,IAAIlC,CAAK,IAAImC,CAAQ,EAAE,EACtGI,EAAW,KAAOf,EAAc,WAAW,QAAQgB,CAAU,EAAE,EACxD,CACH,WAAAD,EACA,OAAQ,QACR,MAAOE,EAAS,QAAQH,CAAS,EACjC,OAAAf,EACA,MAAAc,CACH,CACT,CACA,CChEY,MAACK,EAAoBC,GAAYC,GAClC,CACH,CACI,UAAW,IAAI7B,EAAuB4B,EAAO,cAAc,EAC3D,OAAQ,CACJ,OAAQ,CAAC,MAAM,EACf,WAAY,CAAC,GAAG,EAChB,MAAO,CAAC,GAAG,EACX,aAAc,CAAC,GAAG,CACrB,CACJ,CACJ","x_google_ignoreList":[0,1,2]}
|
|
1
|
+
{"version":3,"file":"index-CU4yn4R-.js","sources":["../../../../node_modules/.pnpm/@powerhousedao+diff-analyzer@0.0.0-dev.7_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@powerhousedao/diff-analyzer/dist/lib/document-diff.js","../../../../node_modules/.pnpm/@powerhousedao+diff-analyzer@0.0.0-dev.7_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@powerhousedao/diff-analyzer/dist/processors/diff-analytics/index.js","../../../../node_modules/.pnpm/@powerhousedao+diff-analyzer@0.0.0-dev.7_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@powerhousedao/diff-analyzer/dist/processors/index.js"],"sourcesContent":["/**\n * Calculates the difference between two document states\n */\nexport function diffDocumentStates(doc1, doc2) {\n const changes = [];\n // Compare global state\n const globalChanges = diffStateObjects(doc1, doc2, \"state.global\", \"global\");\n changes.push(...globalChanges);\n // Count changes by type\n const additions = changes.filter((c) => c.type === \"add\").length;\n const removals = changes.filter((c) => c.type === \"remove\").length;\n // Group changes by scope\n const changesByScope = {\n global: changes.filter((c) => c.scope === \"global\"),\n };\n return {\n totalChanges: changes.length,\n additions,\n removals,\n changesByScope,\n changes,\n };\n}\n/**\n * Recursively compares two state objects and returns a list of changes\n */\nfunction diffStateObjects(obj1, obj2, path, scope) {\n const changes = [];\n // Handle arrays\n if (Array.isArray(obj1) && Array.isArray(obj2)) {\n let index = 0;\n for (; index < obj1.length; index++) {\n const element = obj1[index];\n if (!obj2[index]) {\n changes.push(...diffStateObjects(element, typeof element === \"string\" ? \"\" : null, `${path}[${index}]`, scope));\n }\n else {\n const elementChanges = diffStateObjects(element, obj2[index], `${path}[${index}]`, scope);\n changes.push(...elementChanges);\n }\n }\n for (; index < obj2.length; index++) {\n const element = obj2[index];\n if (!obj1[index]) {\n changes.push(...diffStateObjects(typeof element === \"string\" ? \"\" : null, element, `${path}[${index}]`, scope));\n }\n else {\n const elementChanges = diffStateObjects(obj1[index], element, `${path}[${index}]`, scope);\n changes.push(...elementChanges);\n }\n }\n return changes;\n }\n // Handle primitive values\n if (typeof obj1 !== \"object\" ||\n typeof obj2 !== \"object\" ||\n obj1 === null ||\n obj2 === null) {\n if (obj1 !== obj2) {\n // Special handling for strings to diff character by character\n if (typeof obj1 === \"string\" && typeof obj2 === \"string\") {\n return diffStateStrings(obj1, obj2, path, scope);\n }\n else {\n // For non-string primitives, treat a change as a remove + add\n changes.push({\n type: \"remove\",\n path,\n oldValue: obj1,\n scope,\n });\n changes.push({\n type: \"add\",\n path,\n newValue: obj2,\n scope,\n });\n }\n }\n return changes;\n }\n // Handle objects\n const obj1Record = obj1;\n const obj2Record = obj2;\n const obj1Keys = Object.keys(obj1Record);\n const obj2Keys = Object.keys(obj2Record);\n // First, check for removed keys\n for (const key of obj1Keys) {\n if (!(key in obj2Record)) {\n // Key was removed\n changes.push({\n type: \"remove\",\n path: `${path}.${key}`,\n oldValue: obj1Record[key],\n scope,\n });\n }\n }\n // Then, check for added keys and modified values\n for (const key of obj2Keys) {\n if (!(key in obj1Record)) {\n // Key was added\n changes.push({\n type: \"add\",\n path: `${path}.${key}`,\n newValue: obj2Record[key],\n scope,\n });\n }\n else if (obj1Record[key] !== obj2Record[key]) {\n // For object changes, recursively diff the objects\n const nestedChanges = diffStateObjects(obj1Record[key], obj2Record[key], `${path}.${key}`, scope);\n changes.push(...nestedChanges);\n }\n }\n return changes;\n}\n/**\n * Compares two strings character by character and returns a list of changes\n */\nfunction diffStateStrings(str1, str2, path, scope) {\n const changes = [];\n const maxLen = Math.max(str1.length, str2.length);\n for (let i = 0; i < maxLen; i++) {\n if (i >= str1.length) {\n // Addition of new character\n changes.push({\n type: \"add\",\n path: `${path}[${i}]`,\n newValue: str2[i],\n scope,\n });\n }\n else if (i >= str2.length) {\n // Removal of character\n changes.push({\n type: \"remove\",\n path: `${path}[${i}]`,\n oldValue: str1[i],\n scope,\n });\n }\n else if (str1[i] !== str2[i]) {\n // Character changed\n changes.push({\n type: \"remove\",\n path: `${path}[${i}]`,\n oldValue: str1[i],\n scope,\n });\n changes.push({\n type: \"add\",\n path: `${path}[${i}]`,\n newValue: str2[i],\n scope,\n });\n }\n }\n return changes;\n}\n/**\n * Generates analytics data from a state diff summary\n */\nexport function generateStateAnalyticsData(diff) {\n return {\n totalChanges: diff.totalChanges,\n changesByType: {\n add: diff.additions,\n remove: diff.removals,\n },\n changesByScope: {\n global: diff.changesByScope.global.length,\n },\n changePaths: diff.changes.map((c) => c.path),\n };\n}\n","import { AnalyticsPath, } from \"@powerhousedao/analytics-engine-core\";\nimport { DateTime } from \"luxon\";\nimport { diffDocumentStates } from \"../../lib/document-diff.js\";\nimport { childLogger } from \"document-drive\";\nimport { runAsapAsync } from \"document-drive/utils/misc\";\nexport class DiffAnalyticsProcessor {\n analyticsStore;\n logger;\n constructor(analyticsStore, logger = childLogger([\"processor\", \"diff-analytics\"])) {\n this.analyticsStore = analyticsStore;\n this.logger = logger;\n //\n }\n async onStrands(strands) {\n if (strands.length === 0) {\n return;\n }\n for (const strand of strands) {\n if (strand.operations.length === 0) {\n continue;\n }\n const firstOp = strand.operations[0];\n const source = AnalyticsPath.fromString(`ph/${strand.documentId}/${strand.branch}/${strand.scope}`);\n if (firstOp.index === 0) {\n await this.clearSource(source);\n }\n const CHUNK_SIZE = 50;\n for (let i = 0; i < strand.operations.length; i += CHUNK_SIZE) {\n const chunk = strand.operations.slice(i, i + CHUNK_SIZE);\n const buffer = [];\n for (const operation of chunk) {\n const diff = await runAsapAsync(async () => diffDocumentStates(operation.previousState, operation.state));\n const inputs = diff.changes.map((change) => this.generateInput(strand.documentId, strand.branch, strand.scope, operation.index, change.type, 1, source, operation.timestamp, change.path));\n buffer.push(...inputs);\n while (buffer.length >= CHUNK_SIZE) {\n const batch = buffer.splice(0, CHUNK_SIZE);\n await this.analyticsStore.addSeriesValues(batch);\n }\n }\n // Flush any remaining inputs\n if (buffer.length > 0) {\n await this.analyticsStore.addSeriesValues(buffer);\n }\n }\n }\n }\n async onDisconnect() { }\n async clearSource(source) {\n try {\n await this.analyticsStore.clearSeriesBySource(source, true);\n }\n catch (e) {\n this.logger.error(\"Failed to clear source\", e);\n }\n }\n generateInput(documentId, branch, scope, revision, type, value, source, timestamp, path) {\n const dimensions = {};\n const changePath = path.split(\"[\")[0].replaceAll(\".\", \"/\");\n dimensions.changes = AnalyticsPath.fromString(`changes/${type}`);\n dimensions.document = AnalyticsPath.fromString(`document/${documentId}/${branch}/${scope}/${revision}`);\n dimensions.path = AnalyticsPath.fromString(`path/${changePath}`);\n return {\n dimensions,\n metric: \"Count\",\n start: DateTime.fromISO(timestamp),\n source,\n value,\n };\n }\n}\n","/**\n * This is a scaffold file meant for customization.\n * Delete the file and run the code generator again to have it reset\n */\nimport { DiffAnalyticsProcessor } from \"./diff-analytics/index.js\";\nexport const processorFactory = (module) => (driveId) => {\n return [\n {\n processor: new DiffAnalyticsProcessor(module.analyticsStore),\n filter: {\n branch: [\"main\"],\n documentId: [\"*\"],\n scope: [\"*\"],\n documentType: [\"*\"],\n },\n },\n ];\n};\n"],"names":["diffDocumentStates","doc1","doc2","changes","globalChanges","diffStateObjects","additions","c","removals","changesByScope","obj1","obj2","path","scope","index","element","elementChanges","diffStateStrings","obj1Record","obj2Record","obj1Keys","obj2Keys","key","nestedChanges","str1","str2","maxLen","i","DiffAnalyticsProcessor","analyticsStore","logger","childLogger","__publicField","strands","strand","firstOp","source","AnalyticsPath","CHUNK_SIZE","chunk","buffer","operation","inputs","runAsapAsync","change","batch","documentId","branch","revision","type","value","timestamp","dimensions","changePath","DateTime","processorFactory","module","driveId"],"mappings":"iZAGO,SAASA,EAAmBC,EAAMC,EAAM,CAC3C,MAAMC,EAAU,CAAE,EAEZC,EAAgBC,EAAiBJ,EAAMC,EAAM,eAAgB,QAAQ,EAC3EC,EAAQ,KAAK,GAAGC,CAAa,EAE7B,MAAME,EAAYH,EAAQ,OAAQI,GAAMA,EAAE,OAAS,KAAK,EAAE,OACpDC,EAAWL,EAAQ,OAAQI,GAAMA,EAAE,OAAS,QAAQ,EAAE,OAEtDE,EAAiB,CACnB,OAAQN,EAAQ,OAAQI,GAAMA,EAAE,QAAU,QAAQ,CACrD,EACD,MAAO,CACH,aAAcJ,EAAQ,OACtB,UAAAG,EACA,SAAAE,EACA,eAAAC,EACA,QAAAN,CACH,CACL,CAIA,SAASE,EAAiBK,EAAMC,EAAMC,EAAMC,EAAO,CAC/C,MAAMV,EAAU,CAAE,EAElB,GAAI,MAAM,QAAQO,CAAI,GAAK,MAAM,QAAQC,CAAI,EAAG,CAC5C,IAAIG,EAAQ,EACZ,KAAOA,EAAQJ,EAAK,OAAQI,IAAS,CACjC,MAAMC,EAAUL,EAAKI,CAAK,EAC1B,GAAI,CAACH,EAAKG,CAAK,EACXX,EAAQ,KAAK,GAAGE,EAAiBU,EAAS,OAAOA,GAAY,SAAW,GAAK,KAAM,GAAGH,CAAI,IAAIE,CAAK,IAAKD,CAAK,CAAC,MAE7G,CACD,MAAMG,EAAiBX,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,EAAK,MAAM,GAAG,EAAE,CAAC,EAAE,WAAW,IAAK,GAAG,EACzD,OAAAwC,EAAW,QAAUf,EAAc,WAAW,WAAWY,CAAI,EAAE,EAC/DG,EAAW,SAAWf,EAAc,WAAW,YAAYS,CAAU,IAAIC,CAAM,IAAIlC,CAAK,IAAImC,CAAQ,EAAE,EACtGI,EAAW,KAAOf,EAAc,WAAW,QAAQgB,CAAU,EAAE,EACxD,CACH,WAAAD,EACA,OAAQ,QACR,MAAOE,EAAS,QAAQH,CAAS,EACjC,OAAAf,EACA,MAAAc,CACH,CACT,CACA,CChEY,MAACK,EAAoBC,GAAYC,GAClC,CACH,CACI,UAAW,IAAI7B,EAAuB4B,EAAO,cAAc,EAC3D,OAAQ,CACJ,OAAQ,CAAC,MAAM,EACf,WAAY,CAAC,GAAG,EAChB,MAAO,CAAC,GAAG,EACX,aAAc,CAAC,GAAG,CACrB,CACJ,CACJ","x_google_ignoreList":[0,1,2]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{jsx as Z,jsxs as Pe}from"react/jsx-runtime";import{a7 as Vb,a8 as oe,a9 as On,aa as bu,ab as An,ac as vc,ad as Ht,ae as en,af as yc,ag as Fi,ah as Fs,ai as fk,aj as K,ak as dk,al as hk,am as qb,an as Ub,ao as pk,ap as Fr,aq as ht,ar as Tn,as as xe,at as mk,au as jb,av as Gb,aw as gk,ax as vk,ay as yk,az as Hb,aA as $p,aB as Ar,aC as Qp,aD as Bp,aE as Vp,aF as bk,aG as ar,aH as Pn,aI as Ok,aJ as $i,aK as $s,aL as Qs,aM as Nh,aN as Wb,aO as Zb,aP as Yb,aQ as Kb,aR as td,aS as Sk,aT as Du,aU as Tk,aV as kh,aW as wh,aX as $n,aY as zb,aZ as nd,a_ as of,a$ as Ek,b0 as Ak,b1 as Nk,b2 as kk,b3 as wk,b4 as _k,b5 as xk,b6 as Ik,b7 as Rk,b8 as Dk,b9 as Xb,ba as Ck,bb as rd,bc as id,bd as sd,be as ys,bf as Mk,bg as Jb,bh as Pk,bi as Lk,bj as it,bk as Fk,bl as $k,bm as Qk,bn as Bk,bo as Vk,bp as qk,bq as eO,br as tO,bs as nO,bt as qp,bu as Uk,bv as jk,bw as Gk,bx as Hk,by as Wk,bz as Up,bA as Zk,bB as af,bC as Yk,bD as Kk,bE as zk,bF as Xk,bG as Jk,bH as ew,bI as tw,bJ as nw,bK as rw,bL as iw,bM as sw}from"./app-
|
|
1
|
+
import{jsx as Z,jsxs as Pe}from"react/jsx-runtime";import{a7 as Vb,a8 as oe,a9 as On,aa as bu,ab as An,ac as vc,ad as Ht,ae as en,af as yc,ag as Fi,ah as Fs,ai as fk,aj as K,ak as dk,al as hk,am as qb,an as Ub,ao as pk,ap as Fr,aq as ht,ar as Tn,as as xe,at as mk,au as jb,av as Gb,aw as gk,ax as vk,ay as yk,az as Hb,aA as $p,aB as Ar,aC as Qp,aD as Bp,aE as Vp,aF as bk,aG as ar,aH as Pn,aI as Ok,aJ as $i,aK as $s,aL as Qs,aM as Nh,aN as Wb,aO as Zb,aP as Yb,aQ as Kb,aR as td,aS as Sk,aT as Du,aU as Tk,aV as kh,aW as wh,aX as $n,aY as zb,aZ as nd,a_ as of,a$ as Ek,b0 as Ak,b1 as Nk,b2 as kk,b3 as wk,b4 as _k,b5 as xk,b6 as Ik,b7 as Rk,b8 as Dk,b9 as Xb,ba as Ck,bb as rd,bc as id,bd as sd,be as ys,bf as Mk,bg as Jb,bh as Pk,bi as Lk,bj as it,bk as Fk,bl as $k,bm as Qk,bn as Bk,bo as Vk,bp as qk,bq as eO,br as tO,bs as nO,bt as qp,bu as Uk,bv as jk,bw as Gk,bx as Hk,by as Wk,bz as Up,bA as Zk,bB as af,bC as Yk,bD as Kk,bE as zk,bF as Xk,bG as Jk,bH as ew,bI as tw,bJ as nw,bK as rw,bL as iw,bM as sw}from"./app-Alk9qrjX.js";import*as Wt from"react";import Cu,{useState as Bs,useEffect as tn,createContext as ow,useContext as aw,forwardRef as _h,useRef as kt,useCallback as ge,useImperativeHandle as rO,useId as xh,memo as iO,useMemo as to}from"react";import{t as lw,co as uw,P as cw,cp as fw}from"./index-C4XTqgMr.js";import"./main.BTov0zDh.js";import"./isAddressEqual-s0HpRdBm.js";import"react-dom";import"react-dom/client";const dw=Object.freeze({major:16,minor:11,patch:0,preReleaseTag:null});function hw(n){return n instanceof Error?n:new pw(n)}class pw extends Error{constructor(e){super("Unexpected error value: "+Vb(e)),this.name="NonErrorThrown",this.thrownValue=e}}function mw(n,e,t){var r;const i=hw(n);return gw(i)?i:new oe(i.message,{nodes:(r=i.nodes)!==null&&r!==void 0?r:e,source:i.source,positions:i.positions,path:t,originalError:i})}function gw(n){return Array.isArray(n.path)}function vw(n){return{Field(e){const t=n.getFieldDef(),r=t==null?void 0:t.deprecationReason;if(t&&r!=null){const i=n.getParentType();i!=null||bu(!1),n.reportError(new oe(`The field ${i.name}.${t.name} is deprecated. ${r}`,{nodes:e}))}},Argument(e){const t=n.getArgument(),r=t==null?void 0:t.deprecationReason;if(t&&r!=null){const i=n.getDirective();if(i!=null)n.reportError(new oe(`Directive "@${i.name}" argument "${t.name}" is deprecated. ${r}`,{nodes:e}));else{const s=n.getParentType(),o=n.getFieldDef();s!=null&&o!=null||bu(!1),n.reportError(new oe(`Field "${s.name}.${o.name}" argument "${t.name}" is deprecated. ${r}`,{nodes:e}))}}},ObjectField(e){const t=On(n.getParentInputType());if(An(t)){const r=t.getFields()[e.name.value],i=r==null?void 0:r.deprecationReason;i!=null&&n.reportError(new oe(`The input field ${t.name}.${r.name} is deprecated. ${i}`,{nodes:e}))}},EnumValue(e){const t=n.getEnumValue(),r=t==null?void 0:t.deprecationReason;if(t&&r!=null){const i=On(n.getInputType());i!=null||bu(!1),n.reportError(new oe(`The enum value "${i.name}.${t.name}" is deprecated. ${r}`,{nodes:e}))}}}}function Ih(n){return bw(n,e=>!qb(e),yw)}function yw(n){return!Ub(n)&&!pk(n)}function bw(n,e,t){const r=n.getDirectives().filter(e),i=Object.values(n.getTypeMap()).filter(t);return[Ow(n),...r.map(s=>xw(s)),...i.map(s=>Tw(s))].filter(Boolean).join(`
|
|
2
2
|
|
|
3
3
|
`)}function Ow(n){if(n.description==null&&Sw(n))return;const e=[],t=n.getQueryType();t&&e.push(` query: ${t.name}`);const r=n.getMutationType();r&&e.push(` mutation: ${r.name}`);const i=n.getSubscriptionType();return i&&e.push(` subscription: ${i.name}`),Zt(n)+`schema {
|
|
4
4
|
${e.join(`
|
|
@@ -111,4 +111,4 @@ In some cases, you need to provide options to alter GraphQL's execution behavior
|
|
|
111
111
|
"errors editor"
|
|
112
112
|
`,gridTemplateRows:"auto 1fr"},children:[Pe("div",{className:"flex flex-col gap-2",style:{gridArea:"left"},children:[Z(dT,{operation:e,onAddOperationAndInitialSchema:s,updateOperationName:o,deleteOperation:a,module:t,allOperationNames:r}),Z(o$,{operation:e,focusOnMount:e.id===i,setOperationDescription:u})]}),Z("div",{className:"relative top-8",style:{gridArea:"editor"},children:Z(Sh,{doc:e.schema??"",updateDocumentInModel:h,customLinter:p})}),Pe("div",{style:{gridArea:"errors"},children:[Z("h3",{className:"my-2 text-sm font-medium text-gray-700",children:"Reducer Exceptions"}),Z(a$,{operation:e,addOperationError:f,deleteOperationError:c,setOperationErrorName:d})]})]})}function f$({module:n,allOperations:e,shouldFocusNewOperation:t,updateOperationName:r,deleteOperation:i,addOperationAndInitialSchema:s,addOperationError:o,deleteOperationError:a,setOperationErrorName:l,updateOperationSchema:u,setOperationDescription:f}){const[c,d]=Bs(null),h=xh(),p=e.map(g=>g.name).filter(g=>g!==null),m=ge(async(g,v)=>{const b=await s(g,v);return b&&d(b),b},[s,d]);return Pe("div",{children:[n.operations.map(g=>Z("div",{children:Z(c$,{operation:g,module:n,lastCreatedOperationId:c,allOperationNames:p,addOperationError:o,deleteOperationError:a,setOperationErrorName:l,onAddOperationAndInitialSchema:m,updateOperationName:r,deleteOperation:i,updateOperationSchema:u,setOperationDescription:f})},g.id)),Z("div",{className:"mt-6 w-1/2 pr-6",children:Z(dT,{onAddOperationAndInitialSchema:m,updateOperationName:r,deleteOperation:i,module:n,allOperationNames:p,focusOnMount:t},h)})]})}function Fb(n){const{module:e,modules:t,allOperations:r,lastCreatedModuleId:i,onAddModule:s,updateModuleName:o,deleteModule:a,updateOperationName:l,deleteOperation:u,addOperationAndInitialSchema:f,updateOperationSchema:c,setOperationDescription:d,addOperationError:h,deleteOperationError:p,setOperationErrorName:m}=n;return Pe("div",{className:"relative rounded-3xl bg-gray-100 p-6",children:[Pe("div",{className:"mb-2 w-1/2 pr-6",children:[Z(nR,{modules:t,module:e,onAddModule:s,updateModuleName:o}),!!e&&Z("button",{"aria-label":"Delete module",tabIndex:-1,className:"absolute right-1 top-1 p-2 text-gray-800 transition-colors hover:text-gray-500",onClick:()=>{a(e.id)},children:Z("svg",{className:"size-6",viewBox:"0 0 24 24",fill:"currentcolor",children:Z("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M16.9993 8.51506L15.4844 7L11.9994 10.4852L8.51497 7.00057L7 8.51562L10.4844 12.0003L7.00056 15.4843L8.51552 16.9994L11.9994 13.5153L15.4838 17L16.9988 15.4849L13.5144 12.0003L16.9993 8.51506Z"})})})]}),!!e&&Z(f$,{module:e,allOperations:r,shouldFocusNewOperation:e.id===i,updateOperationName:l,deleteOperation:u,addOperationAndInitialSchema:f,updateOperationSchema:c,setOperationDescription:d,addOperationError:h,deleteOperationError:p,setOperationErrorName:m})]})}function d$({modules:n,allOperations:e,addModule:t,updateModuleName:r,deleteModule:i,updateOperationName:s,deleteOperation:o,addOperationAndInitialSchema:a,updateOperationSchema:l,setOperationDescription:u,addOperationError:f,deleteOperationError:c,setOperationErrorName:d}){const[h,p]=Bs(null),m=kt(null),g=ge(async v=>{var S;const b=await t(v);return b&&(p(b),(S=m.current)==null||S.focus()),b},[t,p]);return Pe("div",{className:"flex flex-col gap-2",children:[n.map(v=>Z(Fb,{module:v,modules:n,allOperations:e,lastCreatedModuleId:h,onAddModule:g,updateModuleName:r,deleteModule:i,updateOperationName:s,deleteOperation:o,addOperationAndInitialSchema:a,updateOperationSchema:l,setOperationDescription:u,addOperationError:f,deleteOperationError:c,setOperationErrorName:d},v.id)),Z(Fb,{modules:n,allOperations:e,lastCreatedModuleId:h,onAddModule:g,updateModuleName:r,deleteModule:i,updateOperationName:s,deleteOperation:o,addOperationAndInitialSchema:a,updateOperationSchema:l,setOperationDescription:u,addOperationError:f,deleteOperationError:c,setOperationErrorName:d},"add-module"),Z("div",{ref:m,tabIndex:0,className:"size-0 overflow-hidden","aria-hidden":"true"})]})}const Th=_h((n,e)=>{const{className:t,...r}=n;return Z("button",{ref:e,...r,className:Kt("h-10 whitespace-nowrap rounded-md border border-gray-200 bg-gray-50 px-4 py-2 text-sm font-medium text-gray-800 transition-colors hover:bg-gray-100 hover:text-gray-900 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",t)})}),h$=up({String:y.string,Number:y.number,"True False":y.bool,PropertyName:y.propertyName,Null:y.null,", :":y.separator,"[ ]":y.squareBracket,"{ }":y.brace}),p$=Rs.deserialize({version:14,states:"$bOVQPOOOOQO'#Cb'#CbOnQPO'#CeOvQPO'#ClOOQO'#Cr'#CrQOQPOOOOQO'#Cg'#CgO}QPO'#CfO!SQPO'#CtOOQO,59P,59PO![QPO,59PO!aQPO'#CuOOQO,59W,59WO!iQPO,59WOVQPO,59QOqQPO'#CmO!nQPO,59`OOQO1G.k1G.kOVQPO'#CnO!vQPO,59aOOQO1G.r1G.rOOQO1G.l1G.lOOQO,59X,59XOOQO-E6k-E6kOOQO,59Y,59YOOQO-E6l-E6l",stateData:"#O~OeOS~OQSORSOSSOTSOWQO_ROgPO~OVXOgUO~O^[O~PVO[^O~O]_OVhX~OVaO~O]bO^iX~O^dO~O]_OVha~O]bO^ia~O",goto:"!kjPPPPPPkPPkqwPPPPk{!RPPP!XP!e!hXSOR^bQWQRf_TVQ_Q`WRg`QcZRicQTOQZRQe^RhbRYQR]R",nodeNames:"⚠ JsonText True False Null Number String } { Object Property PropertyName : , ] [ Array",maxTerm:25,nodeProps:[["isolate",-2,6,11,""],["openedBy",7,"{",14,"["],["closedBy",8,"}",15,"]"]],propSources:[h$],skippedNodes:[0],repeatNodeCount:2,tokenData:"(|~RaXY!WYZ!W]^!Wpq!Wrs!]|}$u}!O$z!Q!R%T!R![&c![!]&t!}#O&y#P#Q'O#Y#Z'T#b#c'r#h#i(Z#o#p(r#q#r(w~!]Oe~~!`Wpq!]qr!]rs!xs#O!]#O#P!}#P;'S!];'S;=`$o<%lO!]~!}Og~~#QXrs!]!P!Q!]#O#P!]#U#V!]#Y#Z!]#b#c!]#f#g!]#h#i!]#i#j#m~#pR!Q![#y!c!i#y#T#Z#y~#|R!Q![$V!c!i$V#T#Z$V~$YR!Q![$c!c!i$c#T#Z$c~$fR!Q![!]!c!i!]#T#Z!]~$rP;=`<%l!]~$zO]~~$}Q!Q!R%T!R![&c~%YRT~!O!P%c!g!h%w#X#Y%w~%fP!Q![%i~%nRT~!Q![%i!g!h%w#X#Y%w~%zR{|&T}!O&T!Q![&Z~&WP!Q![&Z~&`PT~!Q![&Z~&hST~!O!P%c!Q![&c!g!h%w#X#Y%w~&yO[~~'OO_~~'TO^~~'WP#T#U'Z~'^P#`#a'a~'dP#g#h'g~'jP#X#Y'm~'rOR~~'uP#i#j'x~'{P#`#a(O~(RP#`#a(U~(ZOS~~(^P#f#g(a~(dP#i#j(g~(jP#X#Y(m~(rOQ~~(wOW~~(|OV~",tokenizers:[0],topRules:{JsonText:[0,1]},tokenPrec:0}),m$=()=>n=>{try{JSON.parse(n.state.doc.toString())}catch(e){if(!(e instanceof SyntaxError))throw e;const t=g$(e,n.state.doc);return[{from:t,message:e.message,severity:"error",to:t}]}return[]};function g$(n,e){let t;return(t=n.message.match(/at position (\d+)/))?Math.min(+t[1],e.length):(t=n.message.match(/at line (\d+) column (\d+)/))?Math.min(e.line(+t[1]).from+ +t[2]-1,e.length):0}const BN=Ds.define({name:"json",parser:p$.configure({props:[dp.add({Object:xy({except:/^\s*\}/}),Array:xy({except:/^\s*\]/})}),pp.add({"Object Array":fA})]}),languageData:{closeBrackets:{brackets:["[","{",'"']},indentOnInput:/^\s*[\}\]]$/}});function v$(){return new lA(BN)}const y$=iO(function(e){const{doc:t,readonly:r=!1,updateDocumentInModel:i}=e,{editorRef:s,viewRef:o,updateListenerCompartment:a,focusHandlerCompartment:l,pasteHandlerCompartment:u,timeoutRef:f}=DN();return tn(()=>{o.current||(o.current=new ne({state:Te.create({doc:t,extensions:[...LN,Vc.of(FN),kA,BN,v$(),np(m$()),a.current.of(Cp(r,f,i)),l.current.of(Mp(r,f,i)),u.current.of(Pp(r,f,i)),Te.readOnly.of(r)]}),parent:s.current}),Ii(o.current))},[]),CN(o),MN(o.current,r,f,i,{updateListener:a.current,focusHandler:l.current,pasteHandler:u.current}),PN(o.current,t),Z("div",{ref:s})}),b$=qk,VN=Wt.forwardRef(({className:n,...e},t)=>Z(eO,{ref:t,className:Kt("flex items-center justify-center rounded-xl bg-slate-50 p-1 shadow-[inset_0px_0px_2px_rgba(255,255,255,0.50)]",n),...e}));VN.displayName=eO.displayName;const Eh=Wt.forwardRef(({className:n,...e},t)=>Z(tO,{ref:t,className:Kt("flex w-full items-center justify-center whitespace-nowrap rounded-lg p-1 text-sm text-gray-500 transition-all disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-gray-50 data-[state=active]:text-gray-800 data-[state=active]:shadow-[0px_16px_16px_-4px_rgba(0,0,0,0.10)]",n),...e}));Eh.displayName=tO.displayName;const Ah=Wt.forwardRef(({className:n,...e},t)=>Z(nO,{ref:t,className:Kt("",n),...e}));Ah.displayName=nO.displayName;function $b({modelName:n,stateSchema:e,initialValue:t,setStateSchema:r,setInitialState:i,scope:s}){const o=_S(),[a,l]=Bs(!1),u=ge(p=>l$(p,n,s),[n,s]),f=ge(()=>{l(p=>!p)},[]),c=ge(p=>r(p,s),[r,s]),d=ge(p=>i(p,s),[i,s]),h=ge(()=>{const p=t||"{}",m=nn(o);if(!m)return;const g=nn(e);if(!g)return;const v=xS(n,s);if(!v)return;const b=g.definitions.find(T=>T.kind===K.OBJECT_TYPE_DEFINITION&&T.name.value===v);if(!b||b.kind!==K.OBJECT_TYPE_DEFINITION)return;const S=V_({sharedSchemaDocumentNode:m,stateTypeDefinitionNode:b,existingValue:p});i(S,s)},[o,t,i,s]);return Pe("div",{className:"grid grid-cols-2 gap-4",children:[Pe("div",{children:[Pe("h3",{className:"mb-2 text-lg capitalize",children:[s," state schema"]}),Pe(Th,{onClick:f,className:"mb-2 flex w-fit items-center gap-2",children:[a?"Hide":"Show"," standard library",Z("svg",{className:Kt("inline-block transition-transform",a?"rotate-180":"rotate-0"),xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",children:Z("path",{d:"M11.9883 6.01172C11.4363 6.01172 10.9883 6.45972 10.9883 7.01172V13.0117H6.98828L11.9883 18.0117L16.9883 13.0117H12.9883V7.01172C12.9883 6.45972 12.5403 6.01172 11.9883 6.01172Z",fill:"black"})})]}),a&&Z(Sh,{doc:Ch,readonly:!0}),Z(Sh,{doc:e,updateDocumentInModel:c,customLinter:u})]}),Pe("div",{children:[Pe("div",{className:"flex flex-col items-end",children:[Pe("h3",{className:"mb-2 text-right text-lg capitalize",children:[s," state initial value"]}),Pe(Th,{onClick:h,className:"mb-2 flex w-fit items-center gap-2",children:["Sync with schema"," ",Z("svg",{className:"inline-block",xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:Z("path",{d:"M8.00521 1.99219C6.63588 1.99219 5.32788 2.45152 4.27588 3.28419C3.98721 3.51219 3.94321 3.93285 4.17188 4.22151C4.40054 4.51018 4.82055 4.55418 5.10921 4.32552C5.92721 3.67819 6.93921 3.32552 8.00521 3.32552C10.5825 3.32552 12.6719 5.41485 12.6719 7.99218H11.3385L13.3385 10.6588L15.3385 7.99218H14.0052C14.0052 4.67818 11.3192 1.99219 8.00521 1.99219ZM2.67188 5.32552L0.671875 7.99218H2.00521C2.00521 11.3062 4.69121 13.9922 8.00521 13.9922C9.37521 13.9922 10.6825 13.5335 11.7345 12.7002C12.0232 12.4722 12.0672 12.0515 11.8385 11.7628C11.6099 11.4742 11.1899 11.4302 10.9012 11.6588C10.0825 12.3068 9.07188 12.6588 8.00521 12.6588C5.42788 12.6588 3.33854 10.5695 3.33854 7.99218H4.67188L2.67188 5.32552Z",fill:"#343839"})})]})]}),Z(y$,{doc:t,updateDocumentInModel:d})]})]})}function O$({modelName:n,globalStateSchema:e,localStateSchema:t,globalStateInitialValue:r,localStateInitialValue:i,setStateSchema:s,setInitialState:o}){const a=ge(()=>{const l=Mh(n,"local");s(l,"local"),o("","local")},[n,s,o]);return Pe(b$,{className:"pb-8",activationMode:"manual",defaultValue:"global",children:[Z("div",{className:"my-6",children:Pe(VN,{className:"mx-auto flex max-w-sm",children:[Z(Eh,{value:"global",children:"Global"}),Z(Eh,{value:"local",children:"Local"})]})}),Z(Ah,{value:"global",tabIndex:-1,children:Z($b,{modelName:n,stateSchema:e,initialValue:r,setStateSchema:s,setInitialState:o,scope:"global"})}),Z(Ah,{value:"local",tabIndex:-1,children:t?Z($b,{modelName:n,stateSchema:t,initialValue:i,setStateSchema:s,setInitialState:o,scope:"local"}):Pe("div",{className:"",children:[Z("h3",{className:"mb-2 text-lg capitalize",children:"local state schema"}),Z(Th,{onClick:a,children:"Add local state"})]})})]})}function S$(n){const{document:e,documentNodeName:t,dispatch:r}=n,{name:i,id:s,extension:o,description:a,author:{name:l,website:u}}=to(()=>e.state.global,[e.state.global]),{state:{global:{schema:f,initialValue:c},local:{schema:d,initialValue:h}},modules:p}=to(()=>e.state.global.specifications[0],[e.state.global.specifications[0]]),m=to(()=>p.flatMap(V=>V.operations),[p]),g=kt(!i&&!!t&&m.length===0);tn(()=>{!g.current||!t||(r(qp({name:t})),MS({modelName:t,setStateSchema:(V,ee)=>{r(Up({schema:V,scope:ee}))}}),g.current=!1)},[t]);const v=to(()=>m.flatMap(V=>V.schema??[]).join(`
|
|
113
113
|
`),[m]),b=ge(V=>{ut(V,s)||r(Uk({id:V}))},[s]),S=ge(V=>{ut(V,a)||r(jk({description:V}))},[a]),T=ge(V=>{ut(V,o)||r(Gk({extension:V}))},[o]),O=ge(V=>{ut(V,i)||r(qp({name:V}))},[i]),E=ge(V=>{ut(V,l)||r(Hk({authorName:V}))},[l]),_=ge(V=>{ut(V,u??"")||r(Wk({authorWebsite:V}))},[u]),M=ge((V,ee)=>{ut(V,ee==="global"?f:d)||r(Up({schema:V,scope:ee}))},[f,d]),D=ge((V,ee)=>{ut(V,ee==="global"?c:h)||r(Zk({initialValue:V,scope:ee}))},[c,h]),C=ge(V=>new Promise(ee=>{try{if(p.some(pe=>ut(pe.name,V))){ee(void 0);return}const re=af();r(Yk({id:re,name:V})),ee(re)}catch(re){console.error("Failed to add module:",re),ee(void 0)}}),[p]),$=ge((V,ee)=>{p.some(re=>ut(re.name,ee))||r(Kk({id:V,name:ee}))},[p]),N=ge(V=>r(zk({id:V})),[]),w=ge((V,ee)=>new Promise(re=>{var pe;try{if((((pe=p.find(je=>je.id===V))==null?void 0:pe.operations.map(je=>je.name).filter(Boolean))??[]).some(je=>ut(je,ee))){re(void 0);return}const Le=af();r(Xk({id:Le,moduleId:V,name:ee})),re(Le)}catch(we){console.error("Failed to add operation:",we),re(void 0)}}),[p]),I=ge((V,ee)=>{const re=p.find(we=>we.operations.some(Le=>Le.id===V));((re==null?void 0:re.operations.map(we=>we.name).filter(Boolean))??[]).some(we=>ut(we,ee))||r(Jk({id:V,name:ee}))},[p]),R=ge((V,ee)=>{const re=m.find(pe=>pe.id===V);re!=null&&re.schema&&ut(ee,re.schema)||r(ew({id:V,schema:ee}))},[m]),Q=ge((V,ee)=>{var pe;const re=((pe=m.find(we=>we.id===V))==null?void 0:pe.description)??"";ut(re,ee)||r(tw({id:V,description:ee}))},[m]),U=ge(V=>r(nw({id:V})),[]),X=ge((V,ee)=>new Promise(re=>{try{const pe=m.find(je=>je.id===V);if(((pe==null?void 0:pe.errors.map(je=>je.name).filter(Boolean))??[]).some(je=>ut(je,ee))){re(void 0);return}const Le=af();r(rw({id:Le,operationId:V,errorName:ee})),re(Le)}catch(pe){console.error("Failed to add operation error:",pe),re(void 0)}}),[m]),te=ge(V=>r(iw({id:V})),[]),ue=ge((V,ee,re)=>{const pe=m.find(Le=>Le.id===V);((pe==null?void 0:pe.errors.map(Le=>Le.name).filter(Boolean))??[]).some(Le=>ut(Le,re))||r(sw({id:ee,errorName:re}))},[m]),ce=ge(async(V,ee)=>{try{const re=await w(V,ee);if(!re)return;try{return R(re,Q_(ee)),re}catch(pe){console.error("Failed to update operation schema:",pe);return}}catch(re){console.error("Failed to add operation and schema:",re);return}},[w,R]);return Z("main",{className:"min-h-dvh bg-gray-50",children:Z($_,{globalStateSchemaSdl:f,localStateSchemaSdl:d,operationSchemasSdl:v,children:Pe("div",{className:"mx-auto max-w-6xl px-4 pt-8",children:[Z(YI,{name:i,documentType:s,extension:o,description:a,authorName:l,authorWebsite:u??"",globalStateSchema:f,localStateSchema:d,setModelId:b,setModelDescription:S,setModelExtension:T,setModelName:O,setAuthorName:E,setAuthorWebsite:_,setStateSchema:M}),Z(Gp,{}),Pe("div",{children:[Z(O$,{modelName:i,globalStateSchema:f,globalStateInitialValue:c,localStateSchema:d,localStateInitialValue:h,setStateSchema:M,setInitialState:D}),Z(Gp,{}),Z("h3",{className:"mb-6 text-lg",children:"Global Operations"}),Z(d$,{modules:p,allOperations:m,addModule:C,updateModuleName:$,deleteModule:N,updateOperationName:I,updateOperationSchema:R,setOperationDescription:Q,deleteOperation:U,addOperationError:X,deleteOperationError:te,setOperationErrorName:ue,addOperationAndInitialSchema:ce})]})]})})})}const F$={Component:S$,documentTypes:["powerhouse/document-model"],config:{id:"document-model-editor-v2",disableExternalControls:!0,documentToolbarEnabled:!0,timelineEnabled:!0}};export{S$ as DocumentModelEditor,F$ as documentModelEditorModule};
|
|
114
|
-
//# sourceMappingURL=index-
|
|
114
|
+
//# sourceMappingURL=index-ClZZWwc1.js.map
|