@cratis/scene.components 4.14.0 → 4.16.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.
Files changed (75) hide show
  1. package/cratisComponentsDescriptors.ts +5 -0
  2. package/cratisComponentsPackage.ts +9 -123
  3. package/cratisComponentsPackageManifest.ts +106 -0
  4. package/cratisComponentsRuntimePackage.ts +22 -0
  5. package/designTime/cratisComponentsDesignTime.ts +22 -0
  6. package/dist/cjs/cratisComponentsDescriptors.js +18 -0
  7. package/dist/cjs/cratisComponentsDescriptors.js.map +1 -1
  8. package/dist/cjs/cratisComponentsPackage.js +10 -141
  9. package/dist/cjs/cratisComponentsPackage.js.map +1 -1
  10. package/dist/cjs/cratisComponentsPackageManifest.js +126 -0
  11. package/dist/cjs/cratisComponentsPackageManifest.js.map +1 -0
  12. package/dist/cjs/cratisComponentsRuntimePackage.js +24 -0
  13. package/dist/cjs/cratisComponentsRuntimePackage.js.map +1 -0
  14. package/dist/cjs/designTime/cratisComponentsDesignTime.js +24 -0
  15. package/dist/cjs/designTime/cratisComponentsDesignTime.js.map +1 -0
  16. package/dist/cjs/forms/CommandFormLayoutEditor.js +73 -0
  17. package/dist/cjs/forms/CommandFormLayoutEditor.js.map +1 -0
  18. package/dist/cjs/forms/CommandFormRuntime.js +5 -3
  19. package/dist/cjs/forms/CommandFormRuntime.js.map +1 -1
  20. package/dist/cjs/forms/SceneCommandForm.js +5 -1
  21. package/dist/cjs/forms/SceneCommandForm.js.map +1 -1
  22. package/dist/cjs/forms/generateCommandFieldsAction.js +10 -1
  23. package/dist/cjs/forms/generateCommandFieldsAction.js.map +1 -1
  24. package/dist/cjs/index.js +6 -1
  25. package/dist/cjs/index.js.map +1 -1
  26. package/dist/cjs/runtime.js +15 -0
  27. package/dist/cjs/runtime.js.map +1 -0
  28. package/dist/esm/cratisComponentsDescriptors.d.ts.map +1 -1
  29. package/dist/esm/cratisComponentsDescriptors.js +18 -0
  30. package/dist/esm/cratisComponentsDescriptors.js.map +1 -1
  31. package/dist/esm/cratisComponentsPackage.d.ts +1 -2
  32. package/dist/esm/cratisComponentsPackage.d.ts.map +1 -1
  33. package/dist/esm/cratisComponentsPackage.js +10 -141
  34. package/dist/esm/cratisComponentsPackage.js.map +1 -1
  35. package/dist/esm/cratisComponentsPackageManifest.d.ts +3 -0
  36. package/dist/esm/cratisComponentsPackageManifest.d.ts.map +1 -0
  37. package/dist/esm/cratisComponentsPackageManifest.js +124 -0
  38. package/dist/esm/cratisComponentsPackageManifest.js.map +1 -0
  39. package/dist/esm/cratisComponentsRuntimePackage.d.ts +3 -0
  40. package/dist/esm/cratisComponentsRuntimePackage.d.ts.map +1 -0
  41. package/dist/esm/cratisComponentsRuntimePackage.js +22 -0
  42. package/dist/esm/cratisComponentsRuntimePackage.js.map +1 -0
  43. package/dist/esm/designTime/cratisComponentsDesignTime.d.ts +3 -0
  44. package/dist/esm/designTime/cratisComponentsDesignTime.d.ts.map +1 -0
  45. package/dist/esm/designTime/cratisComponentsDesignTime.js +22 -0
  46. package/dist/esm/designTime/cratisComponentsDesignTime.js.map +1 -0
  47. package/dist/esm/forms/CommandFormLayoutEditor.d.ts +3 -0
  48. package/dist/esm/forms/CommandFormLayoutEditor.d.ts.map +1 -0
  49. package/dist/esm/forms/CommandFormLayoutEditor.js +71 -0
  50. package/dist/esm/forms/CommandFormLayoutEditor.js.map +1 -0
  51. package/dist/esm/forms/CommandFormRuntime.d.ts +2 -1
  52. package/dist/esm/forms/CommandFormRuntime.d.ts.map +1 -1
  53. package/dist/esm/forms/CommandFormRuntime.js +6 -4
  54. package/dist/esm/forms/CommandFormRuntime.js.map +1 -1
  55. package/dist/esm/forms/SceneCommandForm.d.ts.map +1 -1
  56. package/dist/esm/forms/SceneCommandForm.js +6 -2
  57. package/dist/esm/forms/SceneCommandForm.js.map +1 -1
  58. package/dist/esm/forms/generateCommandFieldsAction.js +10 -1
  59. package/dist/esm/forms/generateCommandFieldsAction.js.map +1 -1
  60. package/dist/esm/index.d.ts +2 -0
  61. package/dist/esm/index.d.ts.map +1 -1
  62. package/dist/esm/index.js +4 -1
  63. package/dist/esm/index.js.map +1 -1
  64. package/dist/esm/runtime.d.ts +5 -0
  65. package/dist/esm/runtime.d.ts.map +1 -0
  66. package/dist/esm/runtime.js +5 -0
  67. package/dist/esm/runtime.js.map +1 -0
  68. package/dist/esm/tsconfig.tsbuildinfo +1 -1
  69. package/forms/CommandFormLayoutEditor.tsx +49 -0
  70. package/forms/CommandFormRuntime.tsx +9 -5
  71. package/forms/SceneCommandForm.tsx +2 -0
  72. package/forms/generateCommandFieldsAction.ts +5 -1
  73. package/index.ts +2 -0
  74. package/package.json +12 -7
  75. package/runtime.ts +9 -0
@@ -1,7 +1,7 @@
1
1
  import { jsx, jsxs } from 'react/jsx-runtime';
2
2
  import { AutoCommandForm } from '@cratis/components/CommandForm';
3
3
  import { CommandForm } from '@cratis/arc.react/commands';
4
- import { normalizeCommandFormLayout, validateCommandFormLayout, formWidthToCss } from '@cratis/scene.engine';
4
+ import { normalizeCommandFormLayout, validateCommandFormLayout, stackCommandFormLayout, formWidthToCss } from '@cratis/scene.engine';
5
5
  import { Guid } from '@cratis/fundamentals';
6
6
  import { CommandFormSubmit } from './CommandFormSubmit.js';
7
7
  import { ExplicitCommandField } from './ExplicitCommandField.js';
@@ -46,7 +46,7 @@ const NativeAutoCommandForm = AutoCommandForm;
46
46
  }
47
47
  return undefined;
48
48
  }
49
- /** Private lazy entry point: importing the Scene registry must not import Arc. */ function CommandFormRuntime({ command, inputs, exclude, submitLabel, columns = 1, layout }) {
49
+ /** Private lazy entry point: importing the Scene registry must not import Arc. */ function CommandFormRuntime({ command, inputs, exclude, submitLabel, columns = 1, layout, compact = false }) {
50
50
  const error = capability(command, inputs, exclude);
51
51
  if (error) return /*#__PURE__*/ jsx("div", {
52
52
  role: "alert",
@@ -54,18 +54,20 @@ const NativeAutoCommandForm = AutoCommandForm;
54
54
  });
55
55
  // The registry's never-argument constructor is erased; Arc creates this checked proxy with no args.
56
56
  if (inputs) {
57
- const formLayout = normalizeCommandFormLayout(layout, inputs);
58
- const diagnostics = validateCommandFormLayout(formLayout, inputs.map((input)=>input.property));
57
+ const authoredLayout = normalizeCommandFormLayout(layout, inputs);
58
+ const diagnostics = validateCommandFormLayout(authoredLayout, inputs.map((input)=>input.property));
59
59
  if (diagnostics.length) return /*#__PURE__*/ jsx("div", {
60
60
  role: "alert",
61
61
  children: diagnostics[0].message
62
62
  });
63
+ const formLayout = compact ? stackCommandFormLayout(authoredLayout) : authoredLayout;
63
64
  const columnsCss = formLayout.columns.map((column)=>formWidthToCss(column.width) ?? 'minmax(0, 1fr)').join(' ') || `repeat(${Math.max(1, columns)}, minmax(0, 1fr))`;
64
65
  return /*#__PURE__*/ jsxs(CommandForm, {
65
66
  command: command,
66
67
  showTitles: false,
67
68
  children: [
68
69
  /*#__PURE__*/ jsx("div", {
70
+ "data-scene-form-columns": formLayout.columns.length,
69
71
  style: {
70
72
  display: 'grid',
71
73
  gridTemplateColumns: columnsCss,
@@ -1 +1 @@
1
- {"version":3,"file":"CommandFormRuntime.js","sources":["../../../forms/CommandFormRuntime.tsx"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport type { ComponentType, ReactNode } from 'react';\nimport { AutoCommandForm } from '@cratis/components/CommandForm';\nimport { CommandForm } from '@cratis/arc.react/commands';\nimport { formWidthToCss, normalizeCommandFormLayout, validateCommandFormLayout } from '@cratis/scene.engine';\nimport { Guid } from '@cratis/fundamentals';\nimport type { BoundConstructor } from '../bindings';\nimport type { CommandInput } from './commandInputs';\nimport type { CommandFormLayout } from '@cratis/scene.model';\nimport { CommandFormSubmit } from './CommandFormSubmit';\nimport { ExplicitCommandField } from './ExplicitCommandField';\n\ninterface CommandFormRuntimeProps {\n command: BoundConstructor;\n inputs?: CommandInput[];\n exclude?: string[];\n submitLabel: string;\n columns?: number;\n layout?: CommandFormLayout;\n}\n\n// Runtime bindings erase the proxy's keys; the optional footer is a Components >=4.13 contract.\nconst NativeAutoCommandForm = AutoCommandForm as unknown as ComponentType<{\n command: BoundConstructor;\n exclude?: string[];\n footer?: ReactNode;\n}>;\n\ntype Descriptor = { name: string; type: unknown; isOptional: boolean };\n\n/** Verify the whole command before mounting any native form: partial forms must never execute. */\nfunction capability(command: BoundConstructor, inputs?: CommandInput[], exclude?: string[]): string | undefined {\n let descriptors: unknown;\n try { descriptors = (new command() as { propertyDescriptors?: unknown }).propertyDescriptors; }\n catch { return 'Unable to inspect command proxy'; }\n if (!Array.isArray(descriptors)) return 'Command proxy has no property descriptors';\n const byName = new Map<string, Descriptor>();\n for (const descriptor of descriptors) {\n if (!descriptor || typeof descriptor.name !== 'string' || !descriptor.name ||\n typeof descriptor.isOptional !== 'boolean' || byName.has(descriptor.name)) return 'Ambiguous or invalid command property descriptors';\n byName.set(descriptor.name, descriptor);\n }\n if (inputs) {\n for (const input of inputs) {\n const descriptor = byName.get(input.property);\n if (!descriptor) return `Unknown command property '${input.property}'`;\n if (descriptor.type !== (input.type === 'guid' ? Guid : String)) return `Command property '${input.property}' type does not match '${input.type}'`;\n }\n for (const descriptor of byName.values()) {\n if (!descriptor.isOptional && !inputs.some(input => input.property === descriptor.name)) return `Required command property '${descriptor.name}' has no input`;\n }\n } else {\n for (const descriptor of byName.values()) {\n if (!descriptor.isOptional && (exclude?.includes(descriptor.name) ||\n ![String, Number, Boolean, Date].includes(descriptor.type as typeof String))) {\n return `Required command property '${descriptor.name}' has no supported automatic field; declare inputs`;\n }\n }\n }\n return undefined;\n}\n\n/** Private lazy entry point: importing the Scene registry must not import Arc. */\nexport default function CommandFormRuntime({ command, inputs, exclude, submitLabel, columns = 1, layout }: CommandFormRuntimeProps) {\n const error = capability(command, inputs, exclude);\n if (error) return <div role='alert'>{error}</div>;\n // The registry's never-argument constructor is erased; Arc creates this checked proxy with no args.\n if (inputs) {\n const formLayout = normalizeCommandFormLayout(layout, inputs);\n const diagnostics = validateCommandFormLayout(formLayout, inputs.map(input => input.property));\n if (diagnostics.length) return <div role='alert'>{diagnostics[0].message}</div>;\n const columnsCss = formLayout.columns.map(column => formWidthToCss(column.width) ?? 'minmax(0, 1fr)').join(' ') || `repeat(${Math.max(1, columns)}, minmax(0, 1fr))`;\n return <CommandForm command={command as unknown as new () => object} showTitles={false}>\n <div style={{ display: 'grid', gridTemplateColumns: columnsCss, columnGap: formWidthToCss(formLayout.columnGap) ?? '1rem', rowGap: formWidthToCss(formLayout.rowGap) ?? '1rem' }}>\n {inputs.map(input => <ExplicitCommandField key={input.property} input={input} placement={formLayout.placements.find(placement => placement.field === input.property) ?? input.placement} />)}\n </div>\n <CommandFormSubmit label={submitLabel} />\n </CommandForm>;\n }\n return <NativeAutoCommandForm command={command} exclude={exclude} footer={<CommandFormSubmit label={submitLabel} />} />;\n}\n"],"names":["NativeAutoCommandForm","AutoCommandForm","capability","command","inputs","exclude","descriptors","propertyDescriptors","Array","isArray","byName","Map","descriptor","name","isOptional","has","set","input","get","property","type","Guid","String","values","some","includes","Number","Boolean","Date","undefined","CommandFormRuntime","submitLabel","columns","layout","error","_jsx","div","role","formLayout","normalizeCommandFormLayout","diagnostics","validateCommandFormLayout","map","length","message","columnsCss","column","formWidthToCss","width","join","Math","max","_jsxs","CommandForm","showTitles","style","display","gridTemplateColumns","columnGap","rowGap","ExplicitCommandField","placement","placements","find","field","CommandFormSubmit","label","footer"],"mappings":";;;;;;;;AAAA;AACA;AAsBA;AACA,MAAMA,qBAAAA,GAAwBC,eAAAA;AAQ9B,mGACA,SAASC,UAAAA,CAAWC,OAAyB,EAAEC,MAAuB,EAAEC,OAAkB,EAAA;IACtF,IAAIC,WAAAA;IACJ,IAAI;QAAEA,WAAAA,GAAe,IAAIH,OAAAA,EAAAA,CAAgDI,mBAAmB;AAAE,IAAA,CAAA,CAC9F,OAAM;QAAE,OAAO,iCAAA;AAAmC,IAAA;AAClD,IAAA,IAAI,CAACC,KAAAA,CAAMC,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AA,EAAAA;YAAkBC,KAAAA,EAAOnC;;;AACxG;;"}
1
+ {"version":3,"file":"CommandFormRuntime.js","sources":["../../../forms/CommandFormRuntime.tsx"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport type { ComponentType, ReactNode } from 'react';\nimport { AutoCommandForm } from '@cratis/components/CommandForm';\nimport { CommandForm } from '@cratis/arc.react/commands';\nimport { formWidthToCss, normalizeCommandFormLayout, stackCommandFormLayout, validateCommandFormLayout } from '@cratis/scene.engine';\nimport { Guid } from '@cratis/fundamentals';\nimport type { BoundConstructor } from '../bindings';\nimport type { CommandInput } from './commandInputs';\nimport type { CommandFormLayout } from '@cratis/scene.model';\nimport { CommandFormSubmit } from './CommandFormSubmit';\nimport { ExplicitCommandField } from './ExplicitCommandField';\n\ninterface CommandFormRuntimeProps {\n command: BoundConstructor;\n inputs?: CommandInput[];\n exclude?: string[];\n submitLabel: string;\n columns?: number;\n layout?: CommandFormLayout;\n\n /** At a compact width the fields stack in one column, in reading order. */\n compact?: boolean;\n}\n\n// Runtime bindings erase the proxy's keys; the optional footer is a Components >=4.13 contract.\nconst NativeAutoCommandForm = AutoCommandForm as unknown as ComponentType<{\n command: BoundConstructor;\n exclude?: string[];\n footer?: ReactNode;\n}>;\n\ntype Descriptor = { name: string; type: unknown; isOptional: boolean };\n\n/** Verify the whole command before mounting any native form: partial forms must never execute. */\nfunction capability(command: BoundConstructor, inputs?: CommandInput[], exclude?: string[]): string | undefined {\n let descriptors: unknown;\n try { descriptors = (new command() as { propertyDescriptors?: unknown }).propertyDescriptors; }\n catch { return 'Unable to inspect command proxy'; }\n if (!Array.isArray(descriptors)) return 'Command proxy has no property descriptors';\n const byName = new Map<string, Descriptor>();\n for (const descriptor of descriptors) {\n if (!descriptor || typeof descriptor.name !== 'string' || !descriptor.name ||\n typeof descriptor.isOptional !== 'boolean' || byName.has(descriptor.name)) return 'Ambiguous or invalid command property descriptors';\n byName.set(descriptor.name, descriptor);\n }\n if (inputs) {\n for (const input of inputs) {\n const descriptor = byName.get(input.property);\n if (!descriptor) return `Unknown command property '${input.property}'`;\n if (descriptor.type !== (input.type === 'guid' ? Guid : String)) return `Command property '${input.property}' type does not match '${input.type}'`;\n }\n for (const descriptor of byName.values()) {\n if (!descriptor.isOptional && !inputs.some(input => input.property === descriptor.name)) return `Required command property '${descriptor.name}' has no input`;\n }\n } else {\n for (const descriptor of byName.values()) {\n if (!descriptor.isOptional && (exclude?.includes(descriptor.name) ||\n ![String, Number, Boolean, Date].includes(descriptor.type as typeof String))) {\n return `Required command property '${descriptor.name}' has no supported automatic field; declare inputs`;\n }\n }\n }\n return undefined;\n}\n\n/** Private lazy entry point: importing the Scene registry must not import Arc. */\nexport default function CommandFormRuntime({ command, inputs, exclude, submitLabel, columns = 1, layout, compact = false }: CommandFormRuntimeProps) {\n const error = capability(command, inputs, exclude);\n if (error) return <div role='alert'>{error}</div>;\n // The registry's never-argument constructor is erased; Arc creates this checked proxy with no args.\n if (inputs) {\n const authoredLayout = normalizeCommandFormLayout(layout, inputs);\n const diagnostics = validateCommandFormLayout(authoredLayout, inputs.map(input => input.property));\n if (diagnostics.length) return <div role='alert'>{diagnostics[0].message}</div>;\n const formLayout = compact ? stackCommandFormLayout(authoredLayout) : authoredLayout;\n const columnsCss = formLayout.columns.map(column => formWidthToCss(column.width) ?? 'minmax(0, 1fr)').join(' ') || `repeat(${Math.max(1, columns)}, minmax(0, 1fr))`;\n return <CommandForm command={command as unknown as new () => object} showTitles={false}>\n <div data-scene-form-columns={formLayout.columns.length} style={{ display: 'grid', gridTemplateColumns: columnsCss, columnGap: formWidthToCss(formLayout.columnGap) ?? '1rem', rowGap: formWidthToCss(formLayout.rowGap) ?? '1rem' }}>\n {inputs.map(input => <ExplicitCommandField key={input.property} input={input} placement={formLayout.placements.find(placement => placement.field === input.property) ?? input.placement} />)}\n </div>\n <CommandFormSubmit label={submitLabel} />\n </CommandForm>;\n }\n return <NativeAutoCommandForm command={command} exclude={exclude} footer={<CommandFormSubmit label={submitLabel} />} />;\n}\n"],"names":["NativeAutoCommandForm","AutoCommandForm","capability","command","inputs","exclude","descriptors","propertyDescriptors","Array","isArray","byName","Map","descriptor","name","isOptional","has","set","input","get","property","type","Guid","String","values","some","includes","Number","Boolean","Date","undefined","CommandFormRuntime","submitLabel","columns","layout","compact","error","_jsx","div","role","authoredLayout","normalizeCommandFormLayout","diagnostics","validateCommandFormLayout","map","length","message","formLayout","stackCommandFormLayout","columnsCss","column","formWidthToCss","width","join","Math","max","_jsxs","CommandForm","showTitles","data-scene-form-columns","style","display","gridTemplateColumns","columnGap","rowGap","ExplicitCommandField","placement","placements","find","field","CommandFormSubmit","label","footer"],"mappings":";;;;;;;;AAAA;AACA;AAyBA;AACA,MAAMA,qBAAAA,GAAwBC,eAAAA;AAQ9B,mGACA,SAASC,UAAAA,CAAWC,OAAyB,EAAEC,MAAuB,EAAEC,OAAkB,EAAA;IACtF,IAAIC,WAAAA;IACJ,IAAI;QAAEA,WAAAA,GAAe,IAAIH,OAAAA,EAAAA,CAAgDI,mBAAmB;AAAE,IAAA,CAAA,CAC9F,OAAM;QAAE,OAAO,iCAAA;AAAmC,IAAA;AAClD,IAAA,IAAI,CAACC,KAAAA,CAAMC,OAAO,CAACH,cAAc,OAAO,2CAAA;AACxC,IAAA,MAAMI,SAAS,IAAIC,GAAAA,EAAAA;IACnB,KAAK,MAAMC,cAAcN,WAAAA,CAAa;QAClC,IAAI,CAACM,cAAc,OAAOA,UAAAA,CAAWC,IAAI,KAAK,QAAA,IAAY,CAACD,UAAAA,CAAWC,IAAI,IACtE,OAAOD,UAAAA,CAAWE,UAAU,KAAK,SAAA,IAAaJ,MAAAA,CAAOK,GAAG,CAACH,UAAAA,CAAWC,IAAI,CAAA,EAAG,OAAO,mDAAA;AACtFH,QAAAA,MAAAA,CAAOM,GAAG,CAACJ,UAAAA,CAAWC,IAAI,EAAED,UAAAA,CAAAA;AAChC,IAAA;AAC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BAAwB,+BAqBrE"}
1
+ {"version":3,"file":"SceneCommandForm.d.ts","sourceRoot":"","sources":["../../../forms/SceneCommandForm.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAC;AA0B/D,wBAAgB,gBAAgB,CAAC,EAAE,OAAO,EAAE,EAAE,wBAAwB,+BAsBrE"}
@@ -1,10 +1,11 @@
1
1
  import { jsx } from 'react/jsx-runtime';
2
2
  import { lazy } from 'react';
3
+ import { WidthSizeClass } from '@cratis/scene.model';
3
4
  import { BindingKind } from '../bindings/BindingKind.js';
4
5
  import { resolveElementBinding } from '../bindings/resolveElementBinding.js';
5
6
  import { MissingBinding } from '../bindings/MissingBinding.js';
6
7
  import { ArcRuntimeBoundary } from '../bindings/ArcRuntimeBoundary.js';
7
- import { unionProperty, numberProperty, stringProperty, stringArrayProperty } from '../properties.js';
8
+ import { unionProperty, stringProperty, numberProperty, stringArrayProperty } from '../properties.js';
8
9
  import { commandFormLayout } from './commandFormLayout.js';
9
10
  import { commandInputs } from './commandInputs.js';
10
11
 
@@ -51,7 +52,10 @@ function commandKey(command) {
51
52
  },
52
53
  ...commandFormLayout(element.properties) === undefined ? {} : {
53
54
  layout: commandFormLayout(element.properties)
54
- }
55
+ },
56
+ ...stringProperty(element.properties, 'widthSizeClass') === WidthSizeClass.Compact ? {
57
+ compact: true
58
+ } : {}
55
59
  }, commandKey(target))
56
60
  });
57
61
  }
@@ -1 +1 @@
1
- {"version":3,"file":"SceneCommandForm.js","sources":["../../../forms/SceneCommandForm.tsx"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { lazy } from 'react';\nimport { RegisteredComponentProps } from '@cratis/scene.react';\nimport { ArcRuntimeBoundary, BindingKind, MissingBinding, resolveElementBinding } from '../bindings';\nimport type { BoundConstructor } from '../bindings';\nimport { numberProperty, stringArrayProperty, stringProperty, unionProperty } from '../properties';\nimport { commandFormLayout } from './commandFormLayout';\nimport { commandInputs } from './commandInputs';\n\nconst CommandFormRuntime = lazy(() => import('./CommandFormRuntime'));\n\n// Arc's useCommand constructs the proxy only on mount. Key by the actual registered class,\n// not its Scene name (which may be re-registered with a different route or roles).\nconst commandKeys = new WeakMap<BoundConstructor, number>();\nlet nextCommandKey = 0;\nfunction commandKey(command: BoundConstructor): number {\n let key = commandKeys.get(command);\n if (key === undefined) {\n key = ++nextCommandKey;\n commandKeys.set(command, key);\n }\n return key;\n}\n\n/**\n * Auto mode follows supported native proxy descriptors; opt-in inputs bind exactly named fields\n * inside a single native Arc form. Neither mode consumes the content slot.\n */\nexport function SceneCommandForm({ element }: RegisteredComponentProps) {\n const { name, target } = resolveElementBinding(element, BindingKind.Command);\n if (!target) return <MissingBinding element={element} kind={BindingKind.Command} name={name} />;\n\n const mode = unionProperty(element.properties, 'mode', ['auto', 'manual'] as const) ?? (Object.hasOwn(element.properties, 'inputs') ? 'manual' : 'auto');\n const inputs = mode === 'manual' ? commandInputs(element.properties) : undefined;\n if (mode === 'manual' && !inputs) return <div role='alert'>Invalid command form inputs declaration</div>;\n\n return (\n <ArcRuntimeBoundary>\n <CommandFormRuntime\n key={commandKey(target)}\n command={target}\n inputs={inputs}\n exclude={stringArrayProperty(element.properties, 'exclude')}\n submitLabel={stringProperty(element.properties, 'submitLabel') ?? 'Submit'}\n {...(numberProperty(element.properties, 'columns') === undefined ? {} : { columns: numberProperty(element.properties, 'columns') })}\n {...(commandFormLayout(element.properties) === undefined ? {} : { layout: commandFormLayout(element.properties) })}\n />\n </ArcRuntimeBoundary>\n );\n}\n"],"names":["CommandFormRuntime","lazy","commandKeys","WeakMap","nextCommandKey","commandKey","command","key","get","undefined","set","SceneCommandForm","element","name","target","resolveElementBinding","BindingKind","Command","_jsx","MissingBinding","kind","mode","unionProperty","properties","Object","hasOwn","inputs","commandInputs","div","role","ArcRuntimeBoundary","exclude","stringArrayProperty","submitLabel","stringProperty","numberProperty","columns","commandFormLayout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AA;QAAIC,IAAAA,EAAK,OAAA;AAAQ,QAAA,QAAA,EAAA;;AAE3D,IAAA,qBACIX,GAAA,CAACY,kBAAAA,EAAAA;AACG,QAAA,QAAA,gBAAAZ,GAAA,CAAClB,kBAAAA,EAAAA;YAEGM,OAAAA,EAASQ,MAAAA;YACTY,MAAAA,EAAQA,MAAAA;YACRK,OAAAA,EAASC,mBAAAA,CAAoBpB,OAAAA,CAAQW,UAAU,EAAE,SAAA,CAAA;AACjDU,YAAAA,WAAAA,EAAaC,cAAAA,CAAetB,OAAAA,CAAQW,UAAU,EAAE,aAAA,CAAA,IAAkB,QAAA;AACjE,YAAA,GAAIY,eAAevB,OAAAA,CAAQW,UAAU,EAAE,SAAA,CAAA,KAAed,SAAAA,GAAY,EAAC,GAAI;gBAAE2B,OAAAA,EAASD,cAAAA,CAAevB,OAAAA,CAAQW,UAAU,EAAE,SAAA;aAAY;AACjI,YAAA,GAAIc,kBAAkBzB,OAAAA,CAAQW,UAAU,CAAA,KAAMd,SAAAA,GAAY,EAAC,GAAI;gBAAE6B,MAAAA,EAAQD,iBAAAA,CAAkBzB,QAAQW,UAAU;;WANzGlB,UAAAA,CAAWS,MAAAA,CAAAA;;AAUhC;;"}
1
+ {"version":3,"file":"SceneCommandForm.js","sources":["../../../forms/SceneCommandForm.tsx"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { lazy } from 'react';\nimport { WidthSizeClass } from '@cratis/scene.model';\nimport { RegisteredComponentProps } from '@cratis/scene.react';\nimport { ArcRuntimeBoundary, BindingKind, MissingBinding, resolveElementBinding } from '../bindings';\nimport type { BoundConstructor } from '../bindings';\nimport { numberProperty, stringArrayProperty, stringProperty, unionProperty } from '../properties';\nimport { commandFormLayout } from './commandFormLayout';\nimport { commandInputs } from './commandInputs';\n\nconst CommandFormRuntime = lazy(() => import('./CommandFormRuntime'));\n\n// Arc's useCommand constructs the proxy only on mount. Key by the actual registered class,\n// not its Scene name (which may be re-registered with a different route or roles).\nconst commandKeys = new WeakMap<BoundConstructor, number>();\nlet nextCommandKey = 0;\nfunction commandKey(command: BoundConstructor): number {\n let key = commandKeys.get(command);\n if (key === undefined) {\n key = ++nextCommandKey;\n commandKeys.set(command, key);\n }\n return key;\n}\n\n/**\n * Auto mode follows supported native proxy descriptors; opt-in inputs bind exactly named fields\n * inside a single native Arc form. Neither mode consumes the content slot.\n */\nexport function SceneCommandForm({ element }: RegisteredComponentProps) {\n const { name, target } = resolveElementBinding(element, BindingKind.Command);\n if (!target) return <MissingBinding element={element} kind={BindingKind.Command} name={name} />;\n\n const mode = unionProperty(element.properties, 'mode', ['auto', 'manual'] as const) ?? (Object.hasOwn(element.properties, 'inputs') ? 'manual' : 'auto');\n const inputs = mode === 'manual' ? commandInputs(element.properties) : undefined;\n if (mode === 'manual' && !inputs) return <div role='alert'>Invalid command form inputs declaration</div>;\n\n return (\n <ArcRuntimeBoundary>\n <CommandFormRuntime\n key={commandKey(target)}\n command={target}\n inputs={inputs}\n exclude={stringArrayProperty(element.properties, 'exclude')}\n submitLabel={stringProperty(element.properties, 'submitLabel') ?? 'Submit'}\n {...(numberProperty(element.properties, 'columns') === undefined ? {} : { columns: numberProperty(element.properties, 'columns') })}\n {...(commandFormLayout(element.properties) === undefined ? {} : { layout: commandFormLayout(element.properties) })}\n {...(stringProperty(element.properties, 'widthSizeClass') === WidthSizeClass.Compact ? { compact: true } : {})}\n />\n </ArcRuntimeBoundary>\n );\n}\n"],"names":["CommandFormRuntime","lazy","commandKeys","WeakMap","nextCommandKey","commandKey","command","key","get","undefined","set","SceneCommandForm","element","name","target","resolveElementBinding","BindingKind","Command","_jsx","MissingBinding","kind","mode","unionProperty","properties","Object","hasOwn","inputs","commandInputs","div","role","ArcRuntimeBoundary","exclude","stringArrayProperty","submitLabel","stringProperty","numberProperty","columns","commandFormLayout","layout","WidthSizeClass","Compact","compact"],"mappings":";;;;;;;;;;;AAYA,MAAMA,kBAAAA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AAA,EAAA;;AAE3D,IAAA,qBACIX,GAAA,CAACY,kBAAAA,EAAAA;AACG,QAAA,QAAA,gBAAAZ,GAAA,CAAClB,kBAAAA,EAAAA;YAEGM,OAAAA,EAASQ,MAAAA;YACTY,MAAAA,EAAQA,MAAAA;YACRK,OAAAA,EAASC,mBAAAA,CAAoBpB,OAAAA,CAAQW,UAAU,EAAE,SAAA,CAAA;AACjDU,YAAAA,WAAAA,EAAaC,cAAAA,CAAetB,OAAAA,CAAQW,UAAU,EAAE,aAAA,CAAA,IAAkB,QAAA;AACjE,YAAA,GAAIY,eAAevB,OAAAA,CAAQW,UAAU,EAAE,SAAA,CAAA,KAAed,SAAAA,GAAY,EAAC,GAAI;gBAAE2B,OAAAA,EAASD,cAAAA,CAAevB,OAAAA,CAAQW,UAAU,EAAE,SAAA;aAAY;AACjI,YAAA,GAAIc,kBAAkBzB,OAAAA,CAAQW,UAAU,CAAA,KAAMd,SAAAA,GAAY,EAAC,GAAI;gBAAE6B,MAAAA,EAAQD,iBAAAA,CAAkBzB,QAAQW,UAAU;aAAG;AAChH,YAAA,GAAIW,eAAetB,OAAAA,CAAQW,UAAU,EAAE,gBAAA,CAAA,KAAsBgB,cAAAA,CAAeC,OAAO,GAAG;gBAAEC,OAAAA,EAAS;AAAK,aAAA,GAAI;WAPtGpC,UAAAA,CAAWS,MAAAA,CAAAA;;AAWhC;;"}
@@ -11,7 +11,7 @@ const generateCommandFieldsAction = {
11
11
  description: 'Creates a deterministic editable field layout from the selected command metadata.'
12
12
  },
13
13
  isVisible: (context)=>context.element.componentName.endsWith(':commandForm'),
14
- isEnabled: (context)=>Array.isArray(context.commandMetadata?.properties) && !Array.isArray(context.element.properties.inputs),
14
+ isEnabled: (context)=>Array.isArray(context.commandMetadata?.properties) && context.element.properties.inputs === undefined,
15
15
  execute: (context)=>generateCommandFields(context)
16
16
  };
17
17
  function generateCommandFields(context) {
@@ -22,6 +22,7 @@ function generateCommandFields(context) {
22
22
  'No command metadata was supplied.'
23
23
  ]
24
24
  };
25
+ // Authored fields, or a binding that supplies them, are never overwritten.
25
26
  if (Array.isArray(context.element.properties.inputs)) {
26
27
  return {
27
28
  edits: [],
@@ -30,6 +31,14 @@ function generateCommandFields(context) {
30
31
  ]
31
32
  };
32
33
  }
34
+ if (context.element.properties.inputs !== undefined) {
35
+ return {
36
+ edits: [],
37
+ diagnostics: [
38
+ 'The form\'s fields come from a binding; Generate fields will not overwrite it.'
39
+ ]
40
+ };
41
+ }
33
42
  return {
34
43
  diagnostics: [],
35
44
  edits: [
@@ -1 +1 @@
1
- {"version":3,"file":"generateCommandFieldsAction.js","sources":["../../../forms/generateCommandFieldsAction.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { DesignTimeAction, DesignTimeActionContext, DesignTimeActionResult } from '@cratis/scene.react';\nimport { DesignTimeActionPlacement, SceneEditKind } from '@cratis/scene.model';\n\nexport const generateCommandFieldsAction: DesignTimeAction = {\n descriptor: {\n id: 'Cratis.Components.commandForm.generateFields',\n label: 'Generate fields',\n placement: DesignTimeActionPlacement.Toolbar,\n availability: 'commandForm.canGenerateFields',\n description: 'Creates a deterministic editable field layout from the selected command metadata.',\n },\n isVisible: context => context.element.componentName.endsWith(':commandForm'),\n isEnabled: context => Array.isArray(context.commandMetadata?.properties) && !Array.isArray(context.element.properties.inputs),\n execute: context => generateCommandFields(context),\n};\n\nfunction generateCommandFields(context: DesignTimeActionContext): DesignTimeActionResult {\n const properties = context.commandMetadata?.properties ?? [];\n if (!properties.length) return { edits: [], diagnostics: ['No command metadata was supplied.'] };\n if (Array.isArray(context.element.properties.inputs)) {\n return { edits: [], diagnostics: ['The form already has authored fields; Generate fields will not overwrite them.'] };\n }\n\n return {\n diagnostics: [],\n edits: [{\n kind: SceneEditKind.SetProperty,\n nodeId: context.element.id,\n path: 'inputs',\n value: properties.map((property, index) => ({\n property: property.name,\n type: property.type === 'Guid' || property.type === 'guid' ? 'guid' : 'string',\n label: property.label ?? humanize(property.name),\n column: (index % 2) + 1,\n width: '1fr',\n })),\n }],\n };\n}\n\nfunction humanize(name: string): string {\n return name.replace(/([a-z0-9])([A-Z])/g, '$1 $2').replace(/^./, value => value.toUpperCase());\n}\n"],"names":["generateCommandFieldsAction","descriptor","id","label","placement","DesignTimeActionPlacement","Toolbar","availability","description","isVisible","context","element","componentName","endsWith","isEnabled","Array","isArray","commandMetadata","properties","inputs","execute","generateCommandFields","length","edits","diagnostics","kind","SceneEditKind","SetProperty","nodeId","path","value","map","property","index","name","type","humanize","column","width","replace","toUpperCase"],"mappings":";;AAAA;AACA;MAKaA,2BAAAA,GAAgD;IACzDC,UAAAA,EAAY;QACRC,EAAAA,EAAI,8CAAA;QACJC,KAAAA,EAAO,iBAAA;AACPC,QAAAA,SAAAA,EAAWC,0BAA0BC,OAAO;QAC5CC,YAAAA,EAAc,+BAAA;QACdC,WAAAA,EAAa;AACjB,KAAA;IACAC,SAAAA,EAAWC,CAAAA,UAAWA,OAAAA,CAAQC,OAAO,CAACC,aAAa,CAACC,QAAQ,CAAC,cAAA,CAAA;AAC7DC,IAAAA,SAAAA,EAAWJ,CAAAA,OAAAA,GAAWK,KAAAA,CAAMC,OAAO,CAACN,OAAAA,CAAQO,eAAe,EAAEC,UAAAA,CAAAA,IAAe,CAACH,KAAAA,CAAMC,OAAO,CAACN,OAAAA,CAAQC,OAAO,CAACO,UAAU,CAACC,MAAM,CAAA;IAC5HC,OAAAA,EAASV,CAAAA,UAAWW,qBAAAA,CAAsBX,OAAAA;AAC9C;AAEA,SAASW,sBAAsBX,OAAgC,EAAA;AAC3D,IAAA,MAAMQ,UAAAA,GAAaR,OAAAA,CAAQO,eAAe,EAAEC,cAAc,EAAE;AAC5D,IAAA,IAAI,CAACA,UAAAA,CAAWI,MAAM,EAAE,OAAO;AAAEC,QAAAA,KAAAA,EAAO,EAAE;QAAEC,WAAAA,EAAa;AAAC,YAAA;AAAoC;AAAC,KAAA;IAC/F,IAAIT,KAAAA,CAAMC,OAAO,CAACN,OAAAA,CAAQC,OAAO,CAACO,UAAU,CAACC,MAAM,CAAA,EAAG;QAClD,OAAO;AAAEI,YAAAA,KAAAA,EAAO,EAAE;YAAEC,WAAAA,EAAa;AAAC,gBAAA;AAAiF;AAAC,SAAA;AACxH,IAAA;IAEA,OAAO;AACHA,QAAAA,WAAAA,EAAa,EAAE;QACfD,KAAAA,EAAO;AAAC,YAAA;AACJE,gBAAAA,IAAAA,EAAMC,cAAcC,WAAW;gBAC/BC,MAAAA,EAAQlB,OAAAA,CAAQC,OAAO,CAACT,EAAE;gBAC1B2B,IAAAA,EAAM,QAAA;AACNC,gBAAAA,KAAAA,EAAOZ,WAAWa,GAAG,CAAC,CAACC,QAAAA,EAAUC,SAAW;AACxCD,wBAAAA,QAAAA,EAAUA,SAASE,IAAI;wBACvBC,IAAAA,EAAMH,QAAAA,CAASG,IAAI,KAAK,MAAA,IAAUH,SAASG,IAAI,KAAK,SAAS,MAAA,GAAS,QAAA;AACtEhC,wBAAAA,KAAAA,EAAO6B,QAAAA,CAAS7B,KAAK,IAAIiC,QAAAA,CAASJ,SAASE,IAAI,CAAA;wBAC/CG,MAAAA,EAASJ,QAAQ,CAAA,GAAK,CAAA;wBACtBK,KAAAA,EAAO;qBACX,CAAA;AACJ;AAAE;AACN,KAAA;AACJ;AAEA,SAASF,SAASF,IAAY,EAAA;IAC1B,OAAOA,IAAAA,CAAKK,OAAO,CAAC,oBAAA,EAAsB,OAAA,CAAA,CAASA,OAAO,CAAC,IAAA,EAAMT,CAAAA,KAAAA,GAASA,KAAAA,CAAMU,WAAW,EAAA,CAAA;AAC/F;;"}
1
+ {"version":3,"file":"generateCommandFieldsAction.js","sources":["../../../forms/generateCommandFieldsAction.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { DesignTimeAction, DesignTimeActionContext, DesignTimeActionResult } from '@cratis/scene.react';\nimport { DesignTimeActionPlacement, SceneEditKind } from '@cratis/scene.model';\n\nexport const generateCommandFieldsAction: DesignTimeAction = {\n descriptor: {\n id: 'Cratis.Components.commandForm.generateFields',\n label: 'Generate fields',\n placement: DesignTimeActionPlacement.Toolbar,\n availability: 'commandForm.canGenerateFields',\n description: 'Creates a deterministic editable field layout from the selected command metadata.',\n },\n isVisible: context => context.element.componentName.endsWith(':commandForm'),\n isEnabled: context => Array.isArray(context.commandMetadata?.properties) && context.element.properties.inputs === undefined,\n execute: context => generateCommandFields(context),\n};\n\nfunction generateCommandFields(context: DesignTimeActionContext): DesignTimeActionResult {\n const properties = context.commandMetadata?.properties ?? [];\n if (!properties.length) return { edits: [], diagnostics: ['No command metadata was supplied.'] };\n // Authored fields, or a binding that supplies them, are never overwritten.\n if (Array.isArray(context.element.properties.inputs)) {\n return { edits: [], diagnostics: ['The form already has authored fields; Generate fields will not overwrite them.'] };\n }\n if (context.element.properties.inputs !== undefined) {\n return { edits: [], diagnostics: ['The form\\'s fields come from a binding; Generate fields will not overwrite it.'] };\n }\n\n return {\n diagnostics: [],\n edits: [{\n kind: SceneEditKind.SetProperty,\n nodeId: context.element.id,\n path: 'inputs',\n value: properties.map((property, index) => ({\n property: property.name,\n type: property.type === 'Guid' || property.type === 'guid' ? 'guid' : 'string',\n label: property.label ?? humanize(property.name),\n column: (index % 2) + 1,\n width: '1fr',\n })),\n }],\n };\n}\n\nfunction humanize(name: string): string {\n return name.replace(/([a-z0-9])([A-Z])/g, '$1 $2').replace(/^./, value => value.toUpperCase());\n}\n"],"names":["generateCommandFieldsAction","descriptor","id","label","placement","DesignTimeActionPlacement","Toolbar","availability","description","isVisible","context","element","componentName","endsWith","isEnabled","Array","isArray","commandMetadata","properties","inputs","undefined","execute","generateCommandFields","length","edits","diagnostics","kind","SceneEditKind","SetProperty","nodeId","path","value","map","property","index","name","type","humanize","column","width","replace","toUpperCase"],"mappings":";;AAAA;AACA;MAKaA,2BAAAA,GAAgD;IACzDC,UAAAA,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AA;AACJE,gBAAAA,IAAAA,EAAMC,cAAcC,WAAW;gBAC/BC,MAAAA,EAAQnB,OAAAA,CAAQC,OAAO,CAACT,EAAE;gBAC1B4B,IAAAA,EAAM,QAAA;AACNC,gBAAAA,KAAAA,EAAOb,WAAWc,GAAG,CAAC,CAACC,QAAAA,EAAUC,SAAW;AACxCD,wBAAAA,QAAAA,EAAUA,SAASE,IAAI;wBACvBC,IAAAA,EAAMH,QAAAA,CAASG,IAAI,KAAK,MAAA,IAAUH,SAASG,IAAI,KAAK,SAAS,MAAA,GAAS,QAAA;AACtEjC,wBAAAA,KAAAA,EAAO8B,QAAAA,CAAS9B,KAAK,IAAIkC,QAAAA,CAASJ,SAASE,IAAI,CAAA;wBAC/CG,MAAAA,EAASJ,QAAQ,CAAA,GAAK,CAAA;wBACtBK,KAAAA,EAAO;qBACX,CAAA;AACJ;AAAE;AACN,KAAA;AACJ;AAEA,SAASF,SAASF,IAAY,EAAA;IAC1B,OAAOA,IAAAA,CAAKK,OAAO,CAAC,oBAAA,EAAsB,OAAA,CAAA,CAASA,OAAO,CAAC,IAAA,EAAMT,CAAAA,KAAAA,GAASA,KAAAA,CAAMU,WAAW,EAAA,CAAA;AAC/F;;"}
@@ -10,4 +10,6 @@ export * from './toolbar';
10
10
  export * from './cratisComponents';
11
11
  export * from './cratisComponentsDescriptors';
12
12
  export * from './cratisComponentsPackage';
13
+ export * from './cratisComponentsRuntimePackage';
14
+ export * from './designTime/cratisComponentsDesignTime';
13
15
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../index.ts"],"names":[],"mappings":"AAGA,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,oBAAoB,CAAC;AACnC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,2BAA2B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../index.ts"],"names":[],"mappings":"AAGA,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,oBAAoB,CAAC;AACnC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,kCAAkC,CAAC;AACjD,cAAc,yCAAyC,CAAC"}
package/dist/esm/index.js CHANGED
@@ -50,5 +50,8 @@ export { SceneToolbarGroup } from './toolbar/SceneToolbarGroup.js';
50
50
  export { SceneToolbarSeparator } from './toolbar/SceneToolbarSeparator.js';
51
51
  export { cratisComponents, cratisComponentsPackageName } from './cratisComponents.js';
52
52
  export { cratisComponentsDescriptors } from './cratisComponentsDescriptors.js';
53
- export { cratisComponentsPackage, cratisComponentsPackageManifest } from './cratisComponentsPackage.js';
53
+ export { cratisComponentsPackage } from './cratisComponentsPackage.js';
54
+ export { cratisComponentsRuntimePackage } from './cratisComponentsRuntimePackage.js';
55
+ export { cratisComponentsDesignTime } from './designTime/cratisComponentsDesignTime.js';
56
+ export { cratisComponentsPackageManifest } from './cratisComponentsPackageManifest.js';
54
57
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -0,0 +1,5 @@
1
+ export * from './cratisComponents';
2
+ export * from './cratisComponentsDescriptors';
3
+ export * from './cratisComponentsPackageManifest';
4
+ export * from './cratisComponentsRuntimePackage';
5
+ //# sourceMappingURL=runtime.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../runtime.ts"],"names":[],"mappings":"AAKA,cAAc,oBAAoB,CAAC;AACnC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,mCAAmC,CAAC;AAClD,cAAc,kCAAkC,CAAC"}
@@ -0,0 +1,5 @@
1
+ export { cratisComponents, cratisComponentsPackageName } from './cratisComponents.js';
2
+ export { cratisComponentsDescriptors } from './cratisComponentsDescriptors.js';
3
+ export { cratisComponentsPackageManifest } from './cratisComponentsPackageManifest.js';
4
+ export { cratisComponentsRuntimePackage } from './cratisComponentsRuntimePackage.js';
5
+ //# sourceMappingURL=runtime.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtime.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;"}