@xtyle/core 0.6.0 → 0.7.1
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 +43 -10
- package/dist/algorithms/factory.d.ts +37 -1
- package/dist/algorithms/factory.d.ts.map +1 -1
- package/dist/algorithms/factory.js +407 -60
- package/dist/algorithms/factory.js.map +1 -1
- package/dist/audit.d.ts +36 -0
- package/dist/audit.d.ts.map +1 -1
- package/dist/audit.js +22 -0
- package/dist/audit.js.map +1 -1
- package/dist/authoring.d.ts +10 -1
- package/dist/authoring.d.ts.map +1 -1
- package/dist/authoring.js +6 -1
- package/dist/authoring.js.map +1 -1
- package/dist/baked.d.ts +14 -1
- package/dist/baked.d.ts.map +1 -1
- package/dist/baked.js +17 -0
- package/dist/baked.js.map +1 -1
- package/dist/batteries.js +11 -2
- package/dist/cli.js +58 -19
- package/dist/cli.js.map +1 -1
- package/dist/color.d.ts +6 -0
- package/dist/color.d.ts.map +1 -1
- package/dist/color.js +20 -0
- package/dist/color.js.map +1 -1
- package/dist/css/components/app-shell.d.ts.map +1 -1
- package/dist/css/components/app-shell.js +10 -0
- package/dist/css/components/app-shell.js.map +1 -1
- package/dist/css/components/avatar.d.ts.map +1 -1
- package/dist/css/components/avatar.js +8 -19
- package/dist/css/components/avatar.js.map +1 -1
- package/dist/css/components/badge.d.ts.map +1 -1
- package/dist/css/components/badge.js +3 -87
- package/dist/css/components/badge.js.map +1 -1
- package/dist/css/components/bottom-nav.d.ts +2 -0
- package/dist/css/components/bottom-nav.d.ts.map +1 -0
- package/dist/css/components/bottom-nav.js +72 -0
- package/dist/css/components/bottom-nav.js.map +1 -0
- package/dist/css/components/carousel.d.ts.map +1 -1
- package/dist/css/components/carousel.js +144 -1
- package/dist/css/components/carousel.js.map +1 -1
- package/dist/css/components/dialog.d.ts.map +1 -1
- package/dist/css/components/dialog.js +10 -4
- package/dist/css/components/dialog.js.map +1 -1
- package/dist/css/components/dot.d.ts +2 -0
- package/dist/css/components/dot.d.ts.map +1 -0
- package/dist/css/components/dot.js +72 -0
- package/dist/css/components/dot.js.map +1 -0
- package/dist/css/components/heatmap.d.ts.map +1 -1
- package/dist/css/components/heatmap.js +23 -0
- package/dist/css/components/heatmap.js.map +1 -1
- package/dist/css/components/image.d.ts.map +1 -1
- package/dist/css/components/image.js +41 -0
- package/dist/css/components/image.js.map +1 -1
- package/dist/css/components/mobile-shell.d.ts +2 -0
- package/dist/css/components/mobile-shell.d.ts.map +1 -0
- package/dist/css/components/mobile-shell.js +63 -0
- package/dist/css/components/mobile-shell.js.map +1 -0
- package/dist/css/components/panel.js +1 -1
- package/dist/css/components/qr.d.ts +2 -0
- package/dist/css/components/qr.d.ts.map +1 -0
- package/dist/css/components/qr.js +134 -0
- package/dist/css/components/qr.js.map +1 -0
- package/dist/css/components/radio.d.ts.map +1 -1
- package/dist/css/components/radio.js +49 -0
- package/dist/css/components/radio.js.map +1 -1
- package/dist/css/components/ribbon.d.ts +2 -0
- package/dist/css/components/ribbon.d.ts.map +1 -0
- package/dist/css/components/ribbon.js +65 -0
- package/dist/css/components/ribbon.js.map +1 -0
- package/dist/css/components/tree.d.ts.map +1 -1
- package/dist/css/components/tree.js +4 -1
- package/dist/css/components/tree.js.map +1 -1
- package/dist/css/components.d.ts.map +1 -1
- package/dist/css/components.js +14 -1
- package/dist/css/components.js.map +1 -1
- package/dist/css/index.d.ts +2 -0
- package/dist/css/index.d.ts.map +1 -1
- package/dist/css/index.js +2 -0
- package/dist/css/index.js.map +1 -1
- package/dist/elements/avatar.d.ts +18 -3
- package/dist/elements/avatar.d.ts.map +1 -1
- package/dist/elements/avatar.js +35 -6
- package/dist/elements/avatar.js.map +1 -1
- package/dist/elements/bottom-nav.d.ts +30 -0
- package/dist/elements/bottom-nav.d.ts.map +1 -0
- package/dist/elements/bottom-nav.js +114 -0
- package/dist/elements/bottom-nav.js.map +1 -0
- package/dist/elements/carousel.d.ts +61 -0
- package/dist/elements/carousel.d.ts.map +1 -1
- package/dist/elements/carousel.js +282 -22
- package/dist/elements/carousel.js.map +1 -1
- package/dist/elements/dialog.d.ts +3 -3
- package/dist/elements/dialog.d.ts.map +1 -1
- package/dist/elements/dialog.js.map +1 -1
- package/dist/elements/dot.d.ts +37 -0
- package/dist/elements/dot.d.ts.map +1 -0
- package/dist/elements/dot.js +104 -0
- package/dist/elements/dot.js.map +1 -0
- package/dist/elements/fragment-ssr.d.ts.map +1 -1
- package/dist/elements/fragment-ssr.js +10 -0
- package/dist/elements/fragment-ssr.js.map +1 -1
- package/dist/elements/fragments/avatar/source.generated.d.ts.map +1 -1
- package/dist/elements/fragments/avatar/source.generated.js +1 -1
- package/dist/elements/fragments/avatar/source.generated.js.map +1 -1
- package/dist/elements/fragments/badge/source.generated.d.ts.map +1 -1
- package/dist/elements/fragments/badge/source.generated.js +1 -1
- package/dist/elements/fragments/badge/source.generated.js.map +1 -1
- package/dist/elements/fragments/bottom-nav/source.generated.d.ts +25 -0
- package/dist/elements/fragments/bottom-nav/source.generated.d.ts.map +1 -0
- package/dist/elements/fragments/bottom-nav/source.generated.js +4 -0
- package/dist/elements/fragments/bottom-nav/source.generated.js.map +1 -0
- package/dist/elements/fragments/component-host.json +147 -77
- package/dist/elements/fragments/dot/source.generated.d.ts +25 -0
- package/dist/elements/fragments/dot/source.generated.d.ts.map +1 -0
- package/dist/elements/fragments/dot/source.generated.js +4 -0
- package/dist/elements/fragments/dot/source.generated.js.map +1 -0
- package/dist/elements/fragments/heatmap/source.generated.d.ts.map +1 -1
- package/dist/elements/fragments/heatmap/source.generated.js +1 -1
- package/dist/elements/fragments/heatmap/source.generated.js.map +1 -1
- package/dist/elements/fragments/icon/source.generated.d.ts.map +1 -1
- package/dist/elements/fragments/icon/source.generated.js +1 -1
- package/dist/elements/fragments/icon/source.generated.js.map +1 -1
- package/dist/elements/fragments/image/source.generated.d.ts.map +1 -1
- package/dist/elements/fragments/image/source.generated.js +1 -1
- package/dist/elements/fragments/image/source.generated.js.map +1 -1
- package/dist/elements/fragments/mobile-shell/source.generated.d.ts +25 -0
- package/dist/elements/fragments/mobile-shell/source.generated.d.ts.map +1 -0
- package/dist/elements/fragments/mobile-shell/source.generated.js +4 -0
- package/dist/elements/fragments/mobile-shell/source.generated.js.map +1 -0
- package/dist/elements/fragments/qr/source.generated.d.ts +25 -0
- package/dist/elements/fragments/qr/source.generated.d.ts.map +1 -0
- package/dist/elements/fragments/qr/source.generated.js +4 -0
- package/dist/elements/fragments/qr/source.generated.js.map +1 -0
- package/dist/elements/fragments/radio/source.generated.d.ts.map +1 -1
- package/dist/elements/fragments/radio/source.generated.js +1 -1
- package/dist/elements/fragments/radio/source.generated.js.map +1 -1
- package/dist/elements/fragments/ribbon/source.generated.d.ts +25 -0
- package/dist/elements/fragments/ribbon/source.generated.d.ts.map +1 -0
- package/dist/elements/fragments/ribbon/source.generated.js +4 -0
- package/dist/elements/fragments/ribbon/source.generated.js.map +1 -0
- package/dist/elements/fragments/segmented/source.generated.d.ts.map +1 -1
- package/dist/elements/fragments/segmented/source.generated.js +1 -1
- package/dist/elements/fragments/segmented/source.generated.js.map +1 -1
- package/dist/elements/fragments/slider/source.generated.d.ts.map +1 -1
- package/dist/elements/fragments/slider/source.generated.js +1 -1
- package/dist/elements/fragments/slider/source.generated.js.map +1 -1
- package/dist/elements/fragments/tree/source.generated.d.ts.map +1 -1
- package/dist/elements/fragments/tree/source.generated.js +1 -1
- package/dist/elements/fragments/tree/source.generated.js.map +1 -1
- package/dist/elements/heatmap.d.ts +14 -3
- package/dist/elements/heatmap.d.ts.map +1 -1
- package/dist/elements/heatmap.js +49 -18
- package/dist/elements/heatmap.js.map +1 -1
- package/dist/elements/image.d.ts +20 -1
- package/dist/elements/image.d.ts.map +1 -1
- package/dist/elements/image.js +171 -1
- package/dist/elements/image.js.map +1 -1
- package/dist/elements/index.d.ts +10 -0
- package/dist/elements/index.d.ts.map +1 -1
- package/dist/elements/index.js +10 -0
- package/dist/elements/index.js.map +1 -1
- package/dist/elements/mobile-shell.d.ts +24 -0
- package/dist/elements/mobile-shell.d.ts.map +1 -0
- package/dist/elements/mobile-shell.js +53 -0
- package/dist/elements/mobile-shell.js.map +1 -0
- package/dist/elements/qr.d.ts +65 -0
- package/dist/elements/qr.d.ts.map +1 -0
- package/dist/elements/qr.js +244 -0
- package/dist/elements/qr.js.map +1 -0
- package/dist/elements/radio.d.ts +1 -0
- package/dist/elements/radio.d.ts.map +1 -1
- package/dist/elements/radio.js +7 -1
- package/dist/elements/radio.js.map +1 -1
- package/dist/elements/ribbon.d.ts +36 -0
- package/dist/elements/ribbon.d.ts.map +1 -0
- package/dist/elements/ribbon.js +91 -0
- package/dist/elements/ribbon.js.map +1 -0
- package/dist/elements/segmented.d.ts.map +1 -1
- package/dist/elements/segmented.js +3 -0
- package/dist/elements/segmented.js.map +1 -1
- package/dist/elements/slider.d.ts +25 -1
- package/dist/elements/slider.d.ts.map +1 -1
- package/dist/elements/slider.js +122 -16
- package/dist/elements/slider.js.map +1 -1
- package/dist/elements/sparkline.d.ts +3 -1
- package/dist/elements/sparkline.d.ts.map +1 -1
- package/dist/elements/sparkline.js +13 -3
- package/dist/elements/sparkline.js.map +1 -1
- package/dist/emit/css.d.ts.map +1 -1
- package/dist/emit/css.js +5 -1
- package/dist/emit/css.js.map +1 -1
- package/dist/emit/index.d.ts +2 -1
- package/dist/emit/index.d.ts.map +1 -1
- package/dist/emit/index.js +3 -1
- package/dist/emit/index.js.map +1 -1
- package/dist/emit/monaco.d.ts.map +1 -1
- package/dist/emit/monaco.js +2 -18
- package/dist/emit/monaco.js.map +1 -1
- package/dist/emit/terminal.d.ts +9 -0
- package/dist/emit/terminal.d.ts.map +1 -0
- package/dist/emit/terminal.js +32 -0
- package/dist/emit/terminal.js.map +1 -0
- package/dist/gauntlet.d.ts.map +1 -1
- package/dist/gauntlet.js +26 -0
- package/dist/gauntlet.js.map +1 -1
- package/dist/host/algorithms-bundle.generated.d.ts.map +1 -1
- package/dist/host/algorithms-bundle.generated.js +1 -1
- package/dist/host/algorithms-bundle.generated.js.map +1 -1
- package/dist/host/authoring-prelude.generated.d.ts +1 -1
- package/dist/host/authoring-prelude.generated.d.ts.map +1 -1
- package/dist/host/authoring-prelude.generated.js +1 -1
- package/dist/host/authoring-prelude.generated.js.map +1 -1
- package/dist/host/index.d.ts.map +1 -1
- package/dist/host/index.js +12 -0
- package/dist/host/index.js.map +1 -1
- package/dist/host/registry.d.ts +34 -7
- package/dist/host/registry.d.ts.map +1 -1
- package/dist/host/registry.js +45 -11
- package/dist/host/registry.js.map +1 -1
- package/dist/icon-builder.d.ts +41 -0
- package/dist/icon-builder.d.ts.map +1 -1
- package/dist/icon-builder.js +129 -8
- package/dist/icon-builder.js.map +1 -1
- package/dist/icons.d.ts +1 -1
- package/dist/icons.d.ts.map +1 -1
- package/dist/icons.js +2 -0
- package/dist/icons.js.map +1 -1
- package/dist/index.d.ts +12 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -4
- package/dist/index.js.map +1 -1
- package/dist/knobs.d.ts +22 -0
- package/dist/knobs.d.ts.map +1 -0
- package/dist/knobs.js +63 -0
- package/dist/knobs.js.map +1 -0
- package/dist/manifest/avatar.manifest.d.ts.map +1 -1
- package/dist/manifest/avatar.manifest.js +37 -17
- package/dist/manifest/avatar.manifest.js.map +1 -1
- package/dist/manifest/badge.manifest.js +1 -1
- package/dist/manifest/badge.manifest.js.map +1 -1
- package/dist/manifest/bottom-nav.manifest.d.ts +3 -0
- package/dist/manifest/bottom-nav.manifest.d.ts.map +1 -0
- package/dist/manifest/bottom-nav.manifest.js +149 -0
- package/dist/manifest/bottom-nav.manifest.js.map +1 -0
- package/dist/manifest/carousel.manifest.d.ts.map +1 -1
- package/dist/manifest/carousel.manifest.js +58 -4
- package/dist/manifest/carousel.manifest.js.map +1 -1
- package/dist/manifest/dialog.manifest.d.ts.map +1 -1
- package/dist/manifest/dialog.manifest.js +7 -4
- package/dist/manifest/dialog.manifest.js.map +1 -1
- package/dist/manifest/dot.manifest.d.ts +3 -0
- package/dist/manifest/dot.manifest.d.ts.map +1 -0
- package/dist/manifest/dot.manifest.js +172 -0
- package/dist/manifest/dot.manifest.js.map +1 -0
- package/dist/manifest/heatmap.manifest.d.ts.map +1 -1
- package/dist/manifest/heatmap.manifest.js +60 -2
- package/dist/manifest/heatmap.manifest.js.map +1 -1
- package/dist/manifest/icon.manifest.d.ts.map +1 -1
- package/dist/manifest/icon.manifest.js +28 -1
- package/dist/manifest/icon.manifest.js.map +1 -1
- package/dist/manifest/image.manifest.d.ts.map +1 -1
- package/dist/manifest/image.manifest.js +100 -1
- package/dist/manifest/image.manifest.js.map +1 -1
- package/dist/manifest/mobile-shell.manifest.d.ts +3 -0
- package/dist/manifest/mobile-shell.manifest.d.ts.map +1 -0
- package/dist/manifest/mobile-shell.manifest.js +177 -0
- package/dist/manifest/mobile-shell.manifest.js.map +1 -0
- package/dist/manifest/panel.manifest.d.ts.map +1 -1
- package/dist/manifest/panel.manifest.js +2 -1
- package/dist/manifest/panel.manifest.js.map +1 -1
- package/dist/manifest/qr.manifest.d.ts +3 -0
- package/dist/manifest/qr.manifest.d.ts.map +1 -0
- package/dist/manifest/qr.manifest.js +314 -0
- package/dist/manifest/qr.manifest.js.map +1 -0
- package/dist/manifest/radio.manifest.d.ts.map +1 -1
- package/dist/manifest/radio.manifest.js +54 -1
- package/dist/manifest/radio.manifest.js.map +1 -1
- package/dist/manifest/registry.d.ts.map +1 -1
- package/dist/manifest/registry.js +10 -0
- package/dist/manifest/registry.js.map +1 -1
- package/dist/manifest/ribbon.manifest.d.ts +3 -0
- package/dist/manifest/ribbon.manifest.d.ts.map +1 -0
- package/dist/manifest/ribbon.manifest.js +173 -0
- package/dist/manifest/ribbon.manifest.js.map +1 -0
- package/dist/manifest/segmented.manifest.js +5 -5
- package/dist/manifest/segmented.manifest.js.map +1 -1
- package/dist/manifest/slider.manifest.d.ts.map +1 -1
- package/dist/manifest/slider.manifest.js +62 -4
- package/dist/manifest/slider.manifest.js.map +1 -1
- package/dist/manifest/sparkline.manifest.d.ts.map +1 -1
- package/dist/manifest/sparkline.manifest.js +27 -1
- package/dist/manifest/sparkline.manifest.js.map +1 -1
- package/dist/manifest/tree.manifest.d.ts.map +1 -1
- package/dist/manifest/tree.manifest.js +24 -10
- package/dist/manifest/tree.manifest.js.map +1 -1
- package/dist/markup/avatar.d.ts +33 -0
- package/dist/markup/avatar.d.ts.map +1 -1
- package/dist/markup/avatar.js +55 -5
- package/dist/markup/avatar.js.map +1 -1
- package/dist/markup/bottom-nav.d.ts +11 -0
- package/dist/markup/bottom-nav.d.ts.map +1 -0
- package/dist/markup/bottom-nav.js +3 -0
- package/dist/markup/bottom-nav.js.map +1 -0
- package/dist/markup/dialog.d.ts +3 -0
- package/dist/markup/dialog.d.ts.map +1 -1
- package/dist/markup/dialog.js.map +1 -1
- package/dist/markup/dot.d.ts +27 -0
- package/dist/markup/dot.d.ts.map +1 -0
- package/dist/markup/dot.js +27 -0
- package/dist/markup/dot.js.map +1 -0
- package/dist/markup/heatmap.d.ts +2 -2
- package/dist/markup/heatmap.d.ts.map +1 -1
- package/dist/markup/heatmap.js.map +1 -1
- package/dist/markup/image.d.ts +9 -0
- package/dist/markup/image.d.ts.map +1 -1
- package/dist/markup/image.js +24 -0
- package/dist/markup/image.js.map +1 -1
- package/dist/markup/index.d.ts +17 -7
- package/dist/markup/index.d.ts.map +1 -1
- package/dist/markup/index.js +9 -4
- package/dist/markup/index.js.map +1 -1
- package/dist/markup/mobile-shell.d.ts +3 -0
- package/dist/markup/mobile-shell.d.ts.map +1 -0
- package/dist/markup/mobile-shell.js +3 -0
- package/dist/markup/mobile-shell.js.map +1 -0
- package/dist/markup/qr.d.ts +77 -0
- package/dist/markup/qr.d.ts.map +1 -0
- package/dist/markup/qr.js +37 -0
- package/dist/markup/qr.js.map +1 -0
- package/dist/markup/radio.d.ts +1 -1
- package/dist/markup/radio.d.ts.map +1 -1
- package/dist/markup/radio.js +1 -1
- package/dist/markup/radio.js.map +1 -1
- package/dist/markup/ribbon.d.ts +23 -0
- package/dist/markup/ribbon.d.ts.map +1 -0
- package/dist/markup/ribbon.js +23 -0
- package/dist/markup/ribbon.js.map +1 -0
- package/dist/markup/segmented.d.ts +2 -0
- package/dist/markup/segmented.d.ts.map +1 -1
- package/dist/markup/segmented.js +2 -0
- package/dist/markup/segmented.js.map +1 -1
- package/dist/markup/sparkline.d.ts +8 -0
- package/dist/markup/sparkline.d.ts.map +1 -1
- package/dist/markup/sparkline.js +37 -0
- package/dist/markup/sparkline.js.map +1 -1
- package/dist/markup/tree.d.ts +15 -4
- package/dist/markup/tree.d.ts.map +1 -1
- package/dist/markup/tree.js +16 -4
- package/dist/markup/tree.js.map +1 -1
- package/dist/mcp/tools.d.ts +7 -0
- package/dist/mcp/tools.d.ts.map +1 -1
- package/dist/mcp/tools.js +65 -29
- package/dist/mcp/tools.js.map +1 -1
- package/dist/qr.d.ts +84 -0
- package/dist/qr.d.ts.map +1 -0
- package/dist/qr.js +596 -0
- package/dist/qr.js.map +1 -0
- package/dist/series.d.ts +29 -0
- package/dist/series.d.ts.map +1 -1
- package/dist/series.js +36 -0
- package/dist/series.js.map +1 -1
- package/dist/theme-file.d.ts +21 -0
- package/dist/theme-file.d.ts.map +1 -1
- package/dist/theme-file.js +42 -0
- package/dist/theme-file.js.map +1 -1
- package/dist/token-meta.d.ts.map +1 -1
- package/dist/token-meta.js +6 -0
- package/dist/token-meta.js.map +1 -1
- package/dist/types.d.ts +99 -2
- package/dist/types.d.ts.map +1 -1
- package/dist/vocab.d.ts +5 -0
- package/dist/vocab.d.ts.map +1 -1
- package/dist/vocab.js.map +1 -1
- package/manifest.json +25 -2
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authoring-prelude.generated.js","sourceRoot":"","sources":["../../src/host/authoring-prelude.generated.ts"],"names":[],"mappings":"AAAA,mDAAmD;AACnD,MAAM,CAAC,MAAM,gBAAgB,GAAG,
|
|
1
|
+
{"version":3,"file":"authoring-prelude.generated.js","sourceRoot":"","sources":["../../src/host/authoring-prelude.generated.ts"],"names":[],"mappings":"AAAA,mDAAmD;AACnD,MAAM,CAAC,MAAM,gBAAgB,GAAG,2yiNAA2yiN,CAAC"}
|
package/dist/host/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/host/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/host/index.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EACX,SAAS,EAaT,MAAM,aAAa,CAAC;AAuCrB,MAAM,WAAW,oBAAoB;IACpC;mFAC+E;IAC/E,SAAS,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,mBAAoB,SAAQ,oBAAoB;IAChE,0EAA0E;IAC1E,IAAI,CAAC,EAAE,MAAM,CAAC;CACd;AAuBD;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CACpC,MAAM,EAAE,MAAM,EACd,OAAO,GAAE,mBAAwB,GAC/B,OAAO,CAAC,SAAS,CAAC,CAGpB;AAeD;;;;;;;GAOG;AACH,wBAAsB,aAAa,CAClC,WAAW,EAAE,OAAO,EACpB,MAAM,EAAE,MAAM,EACd,OAAO,GAAE,oBAAyB,GAChC,OAAO,CAAC,SAAS,CAAC,CA+FpB"}
|
package/dist/host/index.js
CHANGED
|
@@ -2,6 +2,7 @@ import { initXript } from "@xriptjs/runtime";
|
|
|
2
2
|
import hostManifest from "../../manifest.json" with { type: "json" };
|
|
3
3
|
import { authoringPrelude } from "./authoring-prelude.generated.js";
|
|
4
4
|
import { createCuti } from "../cuti.js";
|
|
5
|
+
import { resolveKnobSpecs } from "../algorithms/factory.js";
|
|
5
6
|
import { resolveGraph } from "../graph.js";
|
|
6
7
|
/**
|
|
7
8
|
* The stub `run` for a host facade's `passes`. Pass closures cannot cross the sandbox
|
|
@@ -91,6 +92,12 @@ export async function loadAlgorithm(modManifest, source, options = {}) {
|
|
|
91
92
|
fragmentSources: { [entryScriptKey(modManifest)]: source },
|
|
92
93
|
});
|
|
93
94
|
const manifest = rt.invokeExport("manifest", []);
|
|
95
|
+
// The invariant list is *sized* from this number, so an absent one yields a zero-length list: the mod
|
|
96
|
+
// would load, report no invariants at all, and sail through the gauntlet having proven nothing. A mod
|
|
97
|
+
// that cannot say how many invariants it has does not get to be silently assumed to have none.
|
|
98
|
+
if (typeof manifest.invariantCount !== "number" || !Number.isInteger(manifest.invariantCount) || manifest.invariantCount < 0) {
|
|
99
|
+
throw new Error(`xtyle: algorithm mod's manifest() must report a non-negative integer invariantCount, got ${JSON.stringify(manifest.invariantCount)}`);
|
|
100
|
+
}
|
|
94
101
|
const graphCache = new Map();
|
|
95
102
|
const graph = (opts) => {
|
|
96
103
|
const key = JSON.stringify(opts ?? {});
|
|
@@ -133,6 +140,11 @@ export async function loadAlgorithm(modManifest, source, options = {}) {
|
|
|
133
140
|
id: modManifest.name ?? manifest.produces[0] ?? "unknown",
|
|
134
141
|
produces: manifest.produces,
|
|
135
142
|
knobs: manifest.knobs,
|
|
143
|
+
// Merged, not replaced. A mod that declares specs for *some* of its knobs — the Tier-3 case this
|
|
144
|
+
// exists for, where an author hand-writes `manifest()` and describes only the novel knob they
|
|
145
|
+
// invented — would otherwise be taken at its word for the whole list and lose the domains for
|
|
146
|
+
// every shared knob it reads. The mod's own specs win by name; the registry fills the rest.
|
|
147
|
+
knobSpecs: resolveKnobSpecs(manifest.knobs, manifest.knobSpecs ?? []),
|
|
136
148
|
categories: manifest.categories,
|
|
137
149
|
derive: (opts = {}) => resolveGraph(graph(opts)),
|
|
138
150
|
lineage: (opts = {}) => graph(opts).map(({ name, value, refs }) => refs && refs.length ? { name, value, refs } : { name, value }),
|
package/dist/host/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/host/index.ts"],"names":[],"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AK,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAC7D;QACF,UAAU;QACV,MAAM;QACN,YAAY,EAAE,CAAC,OAAsB,EAAE,EAAe,EAAE;YACvD,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC;YAC3B,MAAM,IAAI,GAAG,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;YACrC,OAAO,EAAE,QAAQ,EAAE,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,YAAY,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC;QAC9E,CAAC;KACD,CAAC;AACH,CAAC"}
|
package/dist/host/registry.d.ts
CHANGED
|
@@ -1,17 +1,44 @@
|
|
|
1
1
|
import type { Algorithm } from "../types.js";
|
|
2
2
|
/** The ids of the bundled mods the host can resolve. */
|
|
3
3
|
export declare function availableAlgorithms(): string[];
|
|
4
|
+
/**
|
|
5
|
+
* The rail a *correctness harness* loads a mod under, as opposed to the production rail the host
|
|
6
|
+
* manifest declares.
|
|
7
|
+
*
|
|
8
|
+
* `limits.timeout_ms` (5s) is an anti-runaway rail: it exists so a mod with an infinite loop cannot
|
|
9
|
+
* hang the browser generator, and it must stay tight for that. But it is not a performance budget,
|
|
10
|
+
* and a single interpreted derivation against a hostile seed already runs ~3s — so a battery that
|
|
11
|
+
* sweeps hundreds of adversarial seeds through the sandbox trips the rail on the slowest of them and
|
|
12
|
+
* reports an interrupt that says nothing about the algorithm. The harness raises the rail for itself
|
|
13
|
+
* rather than every consumer paying for it: a gauntlet run is developer-supervised and bounded by the
|
|
14
|
+
* suite, so the runaway case it guards against is already covered by the person watching it.
|
|
15
|
+
*/
|
|
16
|
+
export declare const HARNESS_TIMEOUT_MS = 60000;
|
|
17
|
+
export interface ResolveAlgorithmOptions {
|
|
18
|
+
/**
|
|
19
|
+
* Raise the sandbox's wall-clock rail, up to {@link HARNESS_TIMEOUT_MS}. Only a correctness harness
|
|
20
|
+
* should reach for this; a request above the ceiling is clamped to it rather than honored.
|
|
21
|
+
*
|
|
22
|
+
* This is a patience dial, not a confinement boundary: it governs how long the host waits before
|
|
23
|
+
* killing a mod that is spinning, and touches nothing else. The memory and stack limits hold, and
|
|
24
|
+
* the capability set a mod runs under (`color-math`, and a no-op `log`) is fixed and never
|
|
25
|
+
* parameterized — so a longer rail grants a mod no authority it did not already have.
|
|
26
|
+
*/
|
|
27
|
+
timeoutMs?: number;
|
|
28
|
+
}
|
|
4
29
|
/**
|
|
5
30
|
* Resolves an algorithm by id to its host facade: loads the algorithm's xript mod
|
|
6
31
|
* from `algorithms/<id>/`, runs it through the zero-authority sandbox, and returns
|
|
7
|
-
* an `Algorithm`. Cached per id
|
|
8
|
-
* CLI (`derive` / `coverage` / `gauntlet`)
|
|
9
|
-
* the
|
|
10
|
-
* `getAlgorithm` registry from `@xtyle/core/algorithms`
|
|
11
|
-
* test oracle and as the synchronous first-paint fallback
|
|
12
|
-
* async mod load may not have completed yet.
|
|
32
|
+
* an `Algorithm`. Cached per id (and per rail; see {@link HARNESS_TIMEOUT_MS}). This
|
|
33
|
+
* is the canonical resolution path — the whole CLI (`derive` / `coverage` / `gauntlet`)
|
|
34
|
+
* and the site's SSR derive through it, so the gauntlet proves the sandboxed mod that
|
|
35
|
+
* ships, not a baked copy. The baked `getAlgorithm` registry from `@xtyle/core/algorithms`
|
|
36
|
+
* remains as the byte-identical test oracle and as the synchronous first-paint fallback
|
|
37
|
+
* in the browser, where the async mod load may not have completed yet.
|
|
13
38
|
*/
|
|
14
|
-
export declare function resolveAlgorithm(id: string): Promise<Algorithm>;
|
|
39
|
+
export declare function resolveAlgorithm(id: string, options?: ResolveAlgorithmOptions): Promise<Algorithm>;
|
|
40
|
+
/** The algorithm an id-less caller derives with. One literal, rather than a `"xtyle-default"` in every consumer. */
|
|
41
|
+
export declare function defaultAlgorithm(): string;
|
|
15
42
|
/**
|
|
16
43
|
* Synchronous accessor for an already-resolved mod: returns the cached `Algorithm`
|
|
17
44
|
* once `resolveAlgorithm(id)` has settled, else `null`. The hosted resolution is
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/host/registry.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAW7C,wDAAwD;AACxD,wBAAgB,mBAAmB,IAAI,MAAM,EAAE,CAE9C;AAgCD;;;;;;;;;GASG;AACH,wBAAgB,gBAAgB,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC,
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/host/registry.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAW7C,wDAAwD;AACxD,wBAAgB,mBAAmB,IAAI,MAAM,EAAE,CAE9C;AAgCD;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,kBAAkB,QAAS,CAAC;AAEzC,MAAM,WAAW,uBAAuB;IACvC;;;;;;;;OAQG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACnB;AAYD;;;;;;;;;GASG;AACH,wBAAgB,gBAAgB,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,GAAE,uBAA4B,GAAG,OAAO,CAAC,SAAS,CAAC,CA4BtG;AAED,oHAAoH;AACpH,wBAAgB,gBAAgB,IAAI,MAAM,CAEzC;AAED;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAAC,EAAE,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,CAE9D"}
|
package/dist/host/registry.js
CHANGED
|
@@ -41,18 +41,45 @@ function algorithmsDir() {
|
|
|
41
41
|
}
|
|
42
42
|
const cache = new Map();
|
|
43
43
|
const resolved = new Map();
|
|
44
|
+
/**
|
|
45
|
+
* The rail a *correctness harness* loads a mod under, as opposed to the production rail the host
|
|
46
|
+
* manifest declares.
|
|
47
|
+
*
|
|
48
|
+
* `limits.timeout_ms` (5s) is an anti-runaway rail: it exists so a mod with an infinite loop cannot
|
|
49
|
+
* hang the browser generator, and it must stay tight for that. But it is not a performance budget,
|
|
50
|
+
* and a single interpreted derivation against a hostile seed already runs ~3s — so a battery that
|
|
51
|
+
* sweeps hundreds of adversarial seeds through the sandbox trips the rail on the slowest of them and
|
|
52
|
+
* reports an interrupt that says nothing about the algorithm. The harness raises the rail for itself
|
|
53
|
+
* rather than every consumer paying for it: a gauntlet run is developer-supervised and bounded by the
|
|
54
|
+
* suite, so the runaway case it guards against is already covered by the person watching it.
|
|
55
|
+
*/
|
|
56
|
+
export const HARNESS_TIMEOUT_MS = 60_000;
|
|
57
|
+
/**
|
|
58
|
+
* The rail a load actually runs under. Clamped to {@link HARNESS_TIMEOUT_MS} so the ceiling is a real
|
|
59
|
+
* bound rather than a suggestion a doc comment makes: the anti-runaway guarantee survives whatever a
|
|
60
|
+
* caller asks for, and the mod cache cannot be grown without limit by varying the rail (it is part of
|
|
61
|
+
* the cache key, so an unbounded rail means an unbounded number of QuickJS runtimes).
|
|
62
|
+
*/
|
|
63
|
+
function railFor(timeoutMs) {
|
|
64
|
+
return timeoutMs === undefined ? undefined : Math.min(timeoutMs, HARNESS_TIMEOUT_MS);
|
|
65
|
+
}
|
|
44
66
|
/**
|
|
45
67
|
* Resolves an algorithm by id to its host facade: loads the algorithm's xript mod
|
|
46
68
|
* from `algorithms/<id>/`, runs it through the zero-authority sandbox, and returns
|
|
47
|
-
* an `Algorithm`. Cached per id
|
|
48
|
-
* CLI (`derive` / `coverage` / `gauntlet`)
|
|
49
|
-
* the
|
|
50
|
-
* `getAlgorithm` registry from `@xtyle/core/algorithms`
|
|
51
|
-
* test oracle and as the synchronous first-paint fallback
|
|
52
|
-
* async mod load may not have completed yet.
|
|
69
|
+
* an `Algorithm`. Cached per id (and per rail; see {@link HARNESS_TIMEOUT_MS}). This
|
|
70
|
+
* is the canonical resolution path — the whole CLI (`derive` / `coverage` / `gauntlet`)
|
|
71
|
+
* and the site's SSR derive through it, so the gauntlet proves the sandboxed mod that
|
|
72
|
+
* ships, not a baked copy. The baked `getAlgorithm` registry from `@xtyle/core/algorithms`
|
|
73
|
+
* remains as the byte-identical test oracle and as the synchronous first-paint fallback
|
|
74
|
+
* in the browser, where the async mod load may not have completed yet.
|
|
53
75
|
*/
|
|
54
|
-
export function resolveAlgorithm(id) {
|
|
55
|
-
const
|
|
76
|
+
export function resolveAlgorithm(id, options = {}) {
|
|
77
|
+
const timeoutMs = railFor(options.timeoutMs);
|
|
78
|
+
// The rail is part of the identity of the loaded mod: a cache keyed on id alone would hand a
|
|
79
|
+
// harness the 5s-railed instance that a production caller warmed first, and the raise would silently
|
|
80
|
+
// do nothing. Keyed on the *clamped* rail, so the space is {default, harness} and no larger.
|
|
81
|
+
const key = timeoutMs === undefined ? id : `${id}@${timeoutMs}`;
|
|
82
|
+
const cached = cache.get(key);
|
|
56
83
|
if (cached)
|
|
57
84
|
return cached;
|
|
58
85
|
const dir = MOD_DIRS[id];
|
|
@@ -62,13 +89,20 @@ export function resolveAlgorithm(id) {
|
|
|
62
89
|
const modDir = join(algorithmsDir(), dir);
|
|
63
90
|
const modManifest = JSON.parse(readFileSync(join(modDir, "mod-manifest.json"), "utf8"));
|
|
64
91
|
const source = readFileSync(join(modDir, "src/mod.js"), "utf8");
|
|
65
|
-
const loaded = loadAlgorithm(modManifest, source).then((algorithm) => {
|
|
66
|
-
resolved
|
|
92
|
+
const loaded = loadAlgorithm(modManifest, source, { timeoutMs }).then((algorithm) => {
|
|
93
|
+
// `resolved` is the synchronous first-paint oracle, which wants the mod under whatever rail it
|
|
94
|
+
// was loaded with — the derivation is identical either way, so the default keeps its slot.
|
|
95
|
+
if (timeoutMs === undefined)
|
|
96
|
+
resolved.set(id, algorithm);
|
|
67
97
|
return algorithm;
|
|
68
98
|
});
|
|
69
|
-
cache.set(
|
|
99
|
+
cache.set(key, loaded);
|
|
70
100
|
return loaded;
|
|
71
101
|
}
|
|
102
|
+
/** The algorithm an id-less caller derives with. One literal, rather than a `"xtyle-default"` in every consumer. */
|
|
103
|
+
export function defaultAlgorithm() {
|
|
104
|
+
return "xtyle-default";
|
|
105
|
+
}
|
|
72
106
|
/**
|
|
73
107
|
* Synchronous accessor for an already-resolved mod: returns the cached `Algorithm`
|
|
74
108
|
* once `resolveAlgorithm(id)` has settled, else `null`. The hosted resolution is
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../../src/host/registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAE3C,MAAM,QAAQ,GAA2B;IACxC,eAAe,EAAE,eAAe;IAChC,UAAU,EAAE,UAAU;IACtB,aAAa,EAAE,aAAa;IAC5B,YAAY,EAAE,YAAY;IAC1B,UAAU,EAAE,UAAU;CACtB,CAAC;AAEF,wDAAwD;AACxD,MAAM,UAAU,mBAAmB;IAClC,OAAO,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;AAC9B,CAAC;AAED;;;;;GAKG;AACH,SAAS,kBAAkB;IAC1B,IAAI,GAAG,GAAG,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;IAClD,MAAM,EAAE,IAAI,EAAE,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC;IAC5B,OAAO,IAAI,EAAE,CAAC;QACb,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,YAAY,CAAC,CAAC;QAC1C,IAAI,UAAU,CAAC,IAAI,CA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AOG;AACH,MAAM,UAAU,iBAAiB,CAAC,EAAU;IAC3C,OAAO,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,IAAI,CAAC;AACjC,CAAC"}
|
package/dist/icon-builder.d.ts
CHANGED
|
@@ -34,6 +34,12 @@ export interface IconOutline {
|
|
|
34
34
|
export interface IconLayer {
|
|
35
35
|
/** The primitive name, a key into `ICON_PRIMITIVES` (or a short keyword resolved through `PRIMITIVE_KEYWORDS`). */
|
|
36
36
|
primitive: string;
|
|
37
|
+
/** For the `letter` primitive: the glyph to typeset, centered on the grid. Set, it renders a `<text>`
|
|
38
|
+
* in the layer's font slot instead of a library path, riding the same fill / outline / transform. */
|
|
39
|
+
glyph?: string;
|
|
40
|
+
/** For a `letter`: the font slot (`0`+) whose family typesets the glyph; default `0`. Slots 0–2 are
|
|
41
|
+
* the theme's sans / display / mono; a `---f{n}` finish overrides any slot. */
|
|
42
|
+
font?: number;
|
|
37
43
|
/** A literal color, `currentColor`, `transparent`, a token (`--accent`), or a series slot (`series:2`). Omit to inherit `currentColor`. */
|
|
38
44
|
fill?: string;
|
|
39
45
|
/** Uniform scale about the center (default 1). The grammar's `s{%}` maps here as a fraction of the full grid. */
|
|
@@ -78,6 +84,10 @@ export interface IconComposition {
|
|
|
78
84
|
/** Palette overrides from a `---pc` finish: a nibble key repaints that one slot, `*` silhouettes
|
|
79
85
|
* every painting slot. Values are literal colors, applied as a `slot:{n}` resolves. */
|
|
80
86
|
palette?: Record<string, string>;
|
|
87
|
+
/** Font-slot overrides from a `---f` finish, keyed by slot index. A slot a `letter` uses without an
|
|
88
|
+
* override falls back to `FONT_SLOT_TABLE`. Values are a resolved `font-family`: a `var(--font-*)`
|
|
89
|
+
* theme token (portable) or a literal family name (renders only where that font is loaded). */
|
|
90
|
+
fonts?: Record<number, string>;
|
|
81
91
|
}
|
|
82
92
|
export interface ComposeIconOptions {
|
|
83
93
|
/** A derived register: when present, token and series colors bake to concrete values; without it they emit `var(--…)`. */
|
|
@@ -92,6 +102,20 @@ export interface ComposeIconOptions {
|
|
|
92
102
|
* spec consults this before falling back to the canonical `SLOT_TABLE`. */
|
|
93
103
|
palette?: Record<string, string>;
|
|
94
104
|
}
|
|
105
|
+
/**
|
|
106
|
+
* The theme's font families, indexed like color slots so a `letter` picks one by number and a `---f{n}`
|
|
107
|
+
* finish overrides it the same way `---pc{nibble}` overrides a color. Slot 0 is the body sans, 1 the
|
|
108
|
+
* display face, 2 the mono — the three `--font-*` tokens the register always carries. A slot with no
|
|
109
|
+
* default (3+) falls back to slot 0 unless a `---f{n}` finish supplies one.
|
|
110
|
+
*/
|
|
111
|
+
export declare const FONT_SLOT_TABLE: Record<number, string>;
|
|
112
|
+
/**
|
|
113
|
+
* Resolve a `---f` finish value to a `font-family`. `+` reads as a space (so a Google-style
|
|
114
|
+
* `noto+sans+symbols` is one family), a bare theme alias (`sans` / `display` / `mono`) binds to that
|
|
115
|
+
* `--font-*` token, and anything else is a literal family name. A literal family only renders where the
|
|
116
|
+
* font is actually loaded; `iconFontImports` surfaces the loading snippets for the ones that need it.
|
|
117
|
+
*/
|
|
118
|
+
export declare function resolveFontSpec(raw: string): string;
|
|
95
119
|
/** The seed primitive library: shapes, frames, bars, symbols, and the functional glyphs. Each carries
|
|
96
120
|
* plain-language `tags` for search and filter; the keys are internal identifiers, not a taxonomy. */
|
|
97
121
|
export declare const ICON_PRIMITIVES: Record<string, IconPrimitive>;
|
|
@@ -144,6 +168,23 @@ export declare function composeIcon(composition: IconComposition, opts?: Compose
|
|
|
144
168
|
* plain CSS variable can't carry and re-colors with the theme for everything else.
|
|
145
169
|
*/
|
|
146
170
|
export declare function composeIconThemed(composition: IconComposition, opts?: ComposeIconOptions): string;
|
|
171
|
+
/** A font a `letter` layer needs loaded, with ready-made Google Fonts loading snippets. */
|
|
172
|
+
export interface IconFontRequirement {
|
|
173
|
+
/** The `font-family` the mark references. */
|
|
174
|
+
family: string;
|
|
175
|
+
/** A CSS `@import` that loads the family from Google Fonts. */
|
|
176
|
+
googleImport: string;
|
|
177
|
+
/** A `<link>` that loads the family from Google Fonts. */
|
|
178
|
+
googleLink: string;
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* The external font families a composition's `letter` layers need loaded, each with ready-made Google
|
|
182
|
+
* Fonts loading code. Theme-token fonts (`var(--font-*)`) are skipped: they inherit the page's own
|
|
183
|
+
* stacks and need nothing. This is the "help" for the expectation that a named font must be available
|
|
184
|
+
* for a text mark to render as authored, and the grammar's `+`-joined family is already Google's
|
|
185
|
+
* `family=` syntax, so the mapping is exact.
|
|
186
|
+
*/
|
|
187
|
+
export declare function iconFontImports(composition: IconComposition): IconFontRequirement[];
|
|
147
188
|
/** A parsed icon name: its accessible label (humanized) and the composition its spec describes. */
|
|
148
189
|
export interface ParsedIconName {
|
|
149
190
|
label: string | null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"icon-builder.d.ts","sourceRoot":"","sources":["../src/icon-builder.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAGH,OAAO,EAAiB,KAAK,YAAY,EAAE,MAAM,aAAa,CAAC;AAC/D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAOhD,4IAA4I;AAC5I,MAAM,WAAW,aAAa;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,oHAAoH;IACpH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,wGAAwG;IACxG,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;CAChB;AAED,uFAAuF;AACvF,MAAM,WAAW,WAAW;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACd;AAED,iHAAiH;AACjH,MAAM,WAAW,SAAS;IACzB,mHAAmH;IACnH,SAAS,EAAE,MAAM,CAAC;IAClB,2IAA2I;IAC3I,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,iHAAiH;IACjH,KAAK,CAAC,EAAE,MAAM,CAAC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AG,cAAc,GAAG,IAAI,CAgBjE;AAED,kHAAkH;AAClH,MAAM,MAAM,aAAa,GAAG,CAAC,IAAI,EAAE,MAAM,KAAK,cAAc,GAAG,IAAI,CAAC;AAIpE;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CAAC,SAAS,EAAE,aAAa,GAAG,IAAI,CAEpE;AAED,4HAA4H;AAC5H,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,cAAc,GAAG,IAAI,CAMnE"}
|
package/dist/icon-builder.js
CHANGED
|
@@ -56,6 +56,8 @@ const GLYPH_TAGS = {
|
|
|
56
56
|
stop: ["stop", "media", "playback", "control"],
|
|
57
57
|
"skip-forward": ["skip", "forward", "next", "media", "control"],
|
|
58
58
|
"skip-back": ["skip", "back", "previous", "media", "control"],
|
|
59
|
+
volume: ["volume", "sound", "audio", "speaker", "unmute", "media"],
|
|
60
|
+
"volume-off": ["volume", "mute", "muted", "silent", "sound", "audio", "speaker", "media"],
|
|
59
61
|
gear: ["gear", "settings", "cog", "config", "options"],
|
|
60
62
|
folder: ["folder", "directory", "files"],
|
|
61
63
|
pencil: ["pencil", "edit", "write", "draw"],
|
|
@@ -66,9 +68,63 @@ const GLYPH_TAGS = {
|
|
|
66
68
|
bookmark: ["bookmark", "save", "flag", "mark"],
|
|
67
69
|
download: ["download", "save", "import", "arrow"],
|
|
68
70
|
};
|
|
71
|
+
/**
|
|
72
|
+
* The theme's font families, indexed like color slots so a `letter` picks one by number and a `---f{n}`
|
|
73
|
+
* finish overrides it the same way `---pc{nibble}` overrides a color. Slot 0 is the body sans, 1 the
|
|
74
|
+
* display face, 2 the mono — the three `--font-*` tokens the register always carries. A slot with no
|
|
75
|
+
* default (3+) falls back to slot 0 unless a `---f{n}` finish supplies one.
|
|
76
|
+
*/
|
|
77
|
+
export const FONT_SLOT_TABLE = {
|
|
78
|
+
0: "var(--font-sans)",
|
|
79
|
+
1: "var(--font-display)",
|
|
80
|
+
2: "var(--font-mono)",
|
|
81
|
+
};
|
|
82
|
+
/** Theme-font aliases a `---f` value may name to bind a slot to a `--font-*` token — theme-reactive, and
|
|
83
|
+
* as portable as the page it lands on — instead of a literal family. */
|
|
84
|
+
const THEME_FONT_ALIASES = {
|
|
85
|
+
sans: "var(--font-sans)",
|
|
86
|
+
body: "var(--font-sans)",
|
|
87
|
+
display: "var(--font-display)",
|
|
88
|
+
mono: "var(--font-mono)",
|
|
89
|
+
};
|
|
90
|
+
/**
|
|
91
|
+
* Resolve a `---f` finish value to a `font-family`. `+` reads as a space (so a Google-style
|
|
92
|
+
* `noto+sans+symbols` is one family), a bare theme alias (`sans` / `display` / `mono`) binds to that
|
|
93
|
+
* `--font-*` token, and anything else is a literal family name. A literal family only renders where the
|
|
94
|
+
* font is actually loaded; `iconFontImports` surfaces the loading snippets for the ones that need it.
|
|
95
|
+
*/
|
|
96
|
+
export function resolveFontSpec(raw) {
|
|
97
|
+
const name = raw.replace(/\+/g, " ").trim();
|
|
98
|
+
const alias = THEME_FONT_ALIASES[name.toLowerCase()];
|
|
99
|
+
if (alias)
|
|
100
|
+
return alias;
|
|
101
|
+
// Capitalize each word so a lowercase-typed `sigmar` / `noto+sans+symbols` reads and loads as the
|
|
102
|
+
// canonical family (CSS family matching is case-insensitive, but Google's `family=` param is not); an
|
|
103
|
+
// already-capped word like `IBM` is left as typed.
|
|
104
|
+
return name
|
|
105
|
+
.split(" ")
|
|
106
|
+
.map((w) => (w ? w[0].toUpperCase() + w.slice(1) : w))
|
|
107
|
+
.join(" ");
|
|
108
|
+
}
|
|
109
|
+
/** The resolved `font-family` for a layer's font slot: a `---f` override, else the theme default, else slot 0. */
|
|
110
|
+
function fontForSlot(slot, composition) {
|
|
111
|
+
const index = slot ?? 0;
|
|
112
|
+
return (composition.fonts?.[index] ?? FONT_SLOT_TABLE[index] ?? FONT_SLOT_TABLE[0] ?? "var(--font-sans)");
|
|
113
|
+
}
|
|
114
|
+
/** The `<text>` body for a `letter` layer: the glyph centered on the 24-grid in the slot's font, with no
|
|
115
|
+
* fill of its own so the paint group's fill / color / stroke (nibble colors, `currentColor`, outlines,
|
|
116
|
+
* knockout) and the layer transform all apply exactly as they do to a path primitive. `paint-order="stroke"`
|
|
117
|
+
* draws any outline *behind* the fill, so an outlined letter reads as a solid glyph with a border hugging
|
|
118
|
+
* its silhouette rather than a centered stroke that eats into and doubles every stem. */
|
|
119
|
+
function letterBody(glyph, fontFamily) {
|
|
120
|
+
return `<text x="${CENTER}" y="${CENTER}" text-anchor="middle" dominant-baseline="central" paint-order="stroke" stroke-linejoin="round" font-size="20" font-family="${escapeAttr(fontFamily)}">${escapeAttr(glyph)}</text>`;
|
|
121
|
+
}
|
|
69
122
|
/** The seed primitive library: shapes, frames, bars, symbols, and the functional glyphs. Each carries
|
|
70
123
|
* plain-language `tags` for search and filter; the keys are internal identifiers, not a taxonomy. */
|
|
71
124
|
export const ICON_PRIMITIVES = {
|
|
125
|
+
// A parametric primitive: the grammar's `letter-<glyph>` supplies the character and font slot; this
|
|
126
|
+
// sample body is what the palette previews when no glyph is bound yet.
|
|
127
|
+
letter: { body: letterBody("A", FONT_SLOT_TABLE[1]), since: "0.7.0", tags: ["letter", "text", "glyph", "type", "character", "monogram", "initial"] },
|
|
72
128
|
"shape-circle": bare(`<circle cx="12" cy="12" r="11"/>`, ["circle", "round", "shape", "solid"]),
|
|
73
129
|
"shape-square": bare(`<rect x="1.5" y="1.5" width="21" height="21"/>`, ["square", "box", "shape", "solid"]),
|
|
74
130
|
"shape-square-1": bare(`<rect x="1.5" y="1.5" width="21" height="21" rx="2"/>`, ["square", "box", "rounded", "shape"]),
|
|
@@ -174,6 +230,17 @@ export function hasPrimitive(name) {
|
|
|
174
230
|
/** Every primitive name in the library. */
|
|
175
231
|
export const ICON_PRIMITIVE_NAMES = Object.keys(ICON_PRIMITIVES);
|
|
176
232
|
const STROKE_WIDTH = [0, 0.75, 1.25, 1.75];
|
|
233
|
+
/**
|
|
234
|
+
* The stroke width for an outline size step, pre-divided by the layer's own scale so the drawn
|
|
235
|
+
* thickness stays constant per icon rather than tracking the shape. A layer's `scale` rides on the
|
|
236
|
+
* same group the stroke does, so SVG would otherwise scale the stroke with the shape (an `s50` shape
|
|
237
|
+
* outlining at half thickness, an `s150` at 1.5×); dividing here cancels that, leaving the semantic
|
|
238
|
+
* thickness a property of the icon, not the shape's size.
|
|
239
|
+
*/
|
|
240
|
+
function outlineWidth(size, scale) {
|
|
241
|
+
const base = STROKE_WIDTH[size] ?? STROKE_WIDTH[1] ?? 0.75;
|
|
242
|
+
return base / (Math.abs(scale ?? 1) || 1);
|
|
243
|
+
}
|
|
177
244
|
/** Trims float noise from a computed coordinate. */
|
|
178
245
|
function n(value) {
|
|
179
246
|
return String(Math.round(value * 1000) / 1000);
|
|
@@ -297,13 +364,13 @@ function layerTransform(layer) {
|
|
|
297
364
|
* `color` is left unset so an inherited outline color falls through to the icon's own `currentColor`
|
|
298
365
|
* rather than the `"none"` `paintGroup` would seed, which is what made this render as a shade or a fill.
|
|
299
366
|
*/
|
|
300
|
-
function outlineGroup(body, outline, transform, opts) {
|
|
367
|
+
function outlineGroup(body, outline, scale, transform, opts) {
|
|
301
368
|
const color = resolveColor(outline.color, opts);
|
|
302
|
-
const width =
|
|
369
|
+
const width = outlineWidth(outline.size, scale);
|
|
303
370
|
const stroked = body
|
|
304
371
|
.replace(/fill="currentColor"/g, 'fill="none"')
|
|
305
372
|
.replace(/stroke="currentColor"/g, `stroke="${color}"`);
|
|
306
|
-
return `<g ${transform ? `transform="${transform}" ` : ""}fill="none" stroke="${color}" stroke-width="${width}">${stroked}</g>`;
|
|
373
|
+
return `<g ${transform ? `transform="${transform}" ` : ""}fill="none" stroke="${color}" stroke-width="${n(width)}">${stroked}</g>`;
|
|
307
374
|
}
|
|
308
375
|
function paintGroup(body, fill, layer, transform, opts) {
|
|
309
376
|
const attrs = [
|
|
@@ -312,7 +379,7 @@ function paintGroup(body, fill, layer, transform, opts) {
|
|
|
312
379
|
// seeds currentColor for any child glyph drawn in it, so a symbol matches the layer fill
|
|
313
380
|
`color="${fill}"`,
|
|
314
381
|
layer.outline && `stroke="${resolveColor(layer.outline.color, opts)}"`,
|
|
315
|
-
layer.outline && `stroke-width="${
|
|
382
|
+
layer.outline && `stroke-width="${n(outlineWidth(layer.outline.size, layer.scale))}"`,
|
|
316
383
|
layer.opacity != null && `opacity="${n(layer.opacity)}"`,
|
|
317
384
|
]
|
|
318
385
|
.filter(Boolean)
|
|
@@ -343,7 +410,11 @@ export function composeIcon(composition, opts = {}) {
|
|
|
343
410
|
let holes = 0;
|
|
344
411
|
const paletteOpts = composition.palette ? { ...opts, palette: composition.palette } : opts;
|
|
345
412
|
for (const layer of composition.layers) {
|
|
346
|
-
|
|
413
|
+
// A `letter` layer typesets its glyph at compose time (font resolved from the slot table + any
|
|
414
|
+
// `---f` override); every other primitive is a static library body.
|
|
415
|
+
const primitive = layer.glyph != null
|
|
416
|
+
? { body: letterBody(layer.glyph, fontForSlot(layer.font, composition)) }
|
|
417
|
+
: (ICON_PRIMITIVES[layer.primitive] ?? MISSING);
|
|
347
418
|
const transform = layerTransform(layer);
|
|
348
419
|
if (layer.knockout) {
|
|
349
420
|
// A normal knockout punches the shape out of the art below (white field, black shape);
|
|
@@ -359,7 +430,7 @@ export function composeIcon(composition, opts = {}) {
|
|
|
359
430
|
defs.push(`<mask id="${maskId}" maskUnits="userSpaceOnUse" x="0" y="0" width="${GRID}" height="${GRID}"><rect width="${GRID}" height="${GRID}" fill="${fieldFill}"/>${cut}</mask>`);
|
|
360
431
|
body = `<g mask="url(#${maskId})">${body}</g>`;
|
|
361
432
|
if (layer.outline)
|
|
362
|
-
body += outlineGroup(primitive.body, layer.outline, transform, paletteOpts);
|
|
433
|
+
body += outlineGroup(primitive.body, layer.outline, layer.scale, transform, paletteOpts);
|
|
363
434
|
}
|
|
364
435
|
else if (layer.invert) {
|
|
365
436
|
// Paint the fill everywhere *except* the shape — a filled field with a shape-hole.
|
|
@@ -416,7 +487,33 @@ export function composeIconThemed(composition, opts = {}) {
|
|
|
416
487
|
const dropShadow = composition.dropShadow
|
|
417
488
|
? { ...composition.dropShadow, color: bake(composition.dropShadow.color) ?? composition.dropShadow.color }
|
|
418
489
|
: undefined;
|
|
419
|
-
return composeIcon({ layers, label: composition.label, dropShadow }, { scheme: opts.scheme, className: opts.className, part: opts.part });
|
|
490
|
+
return composeIcon({ layers, label: composition.label, dropShadow, fonts: composition.fonts }, { scheme: opts.scheme, className: opts.className, part: opts.part });
|
|
491
|
+
}
|
|
492
|
+
/**
|
|
493
|
+
* The external font families a composition's `letter` layers need loaded, each with ready-made Google
|
|
494
|
+
* Fonts loading code. Theme-token fonts (`var(--font-*)`) are skipped: they inherit the page's own
|
|
495
|
+
* stacks and need nothing. This is the "help" for the expectation that a named font must be available
|
|
496
|
+
* for a text mark to render as authored, and the grammar's `+`-joined family is already Google's
|
|
497
|
+
* `family=` syntax, so the mapping is exact.
|
|
498
|
+
*/
|
|
499
|
+
export function iconFontImports(composition) {
|
|
500
|
+
const families = new Set();
|
|
501
|
+
for (const layer of composition.layers) {
|
|
502
|
+
if (layer.glyph == null)
|
|
503
|
+
continue;
|
|
504
|
+
const spec = fontForSlot(layer.font, composition);
|
|
505
|
+
if (spec.startsWith("var("))
|
|
506
|
+
continue; // a theme token is as portable as the page; nothing to load
|
|
507
|
+
families.add(spec);
|
|
508
|
+
}
|
|
509
|
+
return [...families].map((family) => {
|
|
510
|
+
const param = family.replace(/\s+/g, "+");
|
|
511
|
+
return {
|
|
512
|
+
family,
|
|
513
|
+
googleImport: `@import url('https://fonts.googleapis.com/css2?family=${param}&display=swap');`,
|
|
514
|
+
googleLink: `<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=${param}&display=swap">`,
|
|
515
|
+
};
|
|
516
|
+
});
|
|
420
517
|
}
|
|
421
518
|
const OBJECT_TOKEN = /-(?:(p|s|x|y|r|a)(-?\d+)|c([0-9a-f])|(o)([1-3])(?:c([0-9a-f]))?|(ko|fh|fv|i))/g;
|
|
422
519
|
function parseObject(segment) {
|
|
@@ -429,7 +526,19 @@ function parseObject(segment) {
|
|
|
429
526
|
let position = 5;
|
|
430
527
|
let offX = 0;
|
|
431
528
|
let offY = 0;
|
|
432
|
-
|
|
529
|
+
let rest = segment.slice(keyword.length);
|
|
530
|
+
// The `letter` primitive is parametric: its first `-`-token is the glyph and an optional `-f{n}` names
|
|
531
|
+
// the font slot, both consumed here so the shared flag loop never misreads an arbitrary glyph (`-x`,
|
|
532
|
+
// `-a`) as a transform flag.
|
|
533
|
+
if (keyword === "letter") {
|
|
534
|
+
const m = /^-(.)(?:-f(\d))?/.exec(rest);
|
|
535
|
+
if (m) {
|
|
536
|
+
layer.glyph = m[1];
|
|
537
|
+
if (m[2] != null)
|
|
538
|
+
layer.font = Number(m[2]);
|
|
539
|
+
rest = rest.slice(m[0].length);
|
|
540
|
+
}
|
|
541
|
+
}
|
|
433
542
|
OBJECT_TOKEN.lastIndex = 0;
|
|
434
543
|
let token;
|
|
435
544
|
while ((token = OBJECT_TOKEN.exec(rest))) {
|
|
@@ -500,6 +609,9 @@ function parseDropShadow(token) {
|
|
|
500
609
|
const PC_FLAG = /^pc([0-9a-f])?-(.+)$/;
|
|
501
610
|
/** Token-name aliases for a `---pc` override: bare `fg`/`bg` mean the base ink / base surface. */
|
|
502
611
|
const PC_TOKEN_ALIAS = { fg: "fg-0", bg: "bg-0" };
|
|
612
|
+
/** One `f` font-slot flag: `f{n}-{name}` sets slot `n`, `f-{name}` sets slot 0 (the default). The name
|
|
613
|
+
* runs to the end of the flag (finishes are `--`-delimited), so a multi-word family like `noto+sans` fits. */
|
|
614
|
+
const F_FLAG = /^f(\d)?-(.+)$/;
|
|
503
615
|
/**
|
|
504
616
|
* Resolve a `---pc` override value to a color spec that flows through `resolveColor`. Three shapes, so an
|
|
505
617
|
* override can stay theme-reactive instead of baking a literal color: a **hex** (`3`/`4`/`6`/`8` digits)
|
|
@@ -530,6 +642,7 @@ function pcOverrideSpec(raw) {
|
|
|
530
642
|
function parseFinish(segment) {
|
|
531
643
|
const out = {};
|
|
532
644
|
const palette = {};
|
|
645
|
+
const fonts = {};
|
|
533
646
|
for (const flag of segment.split("--")) {
|
|
534
647
|
if (!flag)
|
|
535
648
|
continue;
|
|
@@ -544,6 +657,12 @@ function parseFinish(segment) {
|
|
|
544
657
|
}
|
|
545
658
|
continue;
|
|
546
659
|
}
|
|
660
|
+
const f = F_FLAG.exec(flag);
|
|
661
|
+
if (f) {
|
|
662
|
+
const slot = f[1] != null ? Number(f[1]) : 0;
|
|
663
|
+
fonts[slot] = resolveFontSpec(f[2]);
|
|
664
|
+
continue;
|
|
665
|
+
}
|
|
547
666
|
if (flag.startsWith("d")) {
|
|
548
667
|
const shadow = parseDropShadow(flag);
|
|
549
668
|
if (shadow)
|
|
@@ -553,6 +672,8 @@ function parseFinish(segment) {
|
|
|
553
672
|
}
|
|
554
673
|
if (Object.keys(palette).length)
|
|
555
674
|
out.palette = palette;
|
|
675
|
+
if (Object.keys(fonts).length)
|
|
676
|
+
out.fonts = fonts;
|
|
556
677
|
return out;
|
|
557
678
|
}
|
|
558
679
|
/** Turns a label segment into an accessible name: `dice-3` → `dice 3`. */
|