@lightspeed/crane 1.3.3 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,16 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.4.0 - 2025-10-06
4
+
5
+ ### Changed
6
+
7
+ - Update CLI TypeScript type definitions to improve type safety, code organization, and maintainability.
8
+ - Update Local Preview to support external content mocking.
9
+
10
+ ### Fixed
11
+
12
+ - Fix Local Preview to correctly handle background colours in custom sections.
13
+
3
14
  ## 1.3.3 - 2025-09-23
4
15
 
5
16
  ### Added
package/dist/app.d.mts CHANGED
@@ -212,6 +212,9 @@ declare function getReactiveRef(card: Card | undefined, editorType: EditorTypes,
212
212
  highResolutionMobileImage: string;
213
213
  lowResolutionDesktopImage: string;
214
214
  highResolutionDesktopImage: string;
215
+ } | {
216
+ hasContent: boolean;
217
+ value: boolean | undefined;
215
218
  } | {
216
219
  title: string | undefined;
217
220
  type: ActionLinkType | undefined;
@@ -224,9 +227,6 @@ declare function getReactiveRef(card: Card | undefined, editorType: EditorTypes,
224
227
  hasTitle: boolean;
225
228
  hasLink: boolean;
226
229
  performAction: (() => void) | undefined;
227
- } | {
228
- hasContent: boolean;
229
- value: boolean | undefined;
230
230
  } | undefined;
231
231
 
232
232
  declare function useLogoElementContent<CONTENT>(): {
@@ -384,14 +384,622 @@ interface InstantsiteJSAPI {
384
384
 
385
385
  declare function useInstantsiteJsApi(): InstantsiteJSAPI | undefined;
386
386
 
387
- interface StorefrontSection {
387
+ // This definition file follows a somewhat unusual format. ESTree allows
388
+ // runtime type checks based on the `type` parameter. In order to explain this
389
+ // to typescript we want to use discriminated union types:
390
+ // https://github.com/Microsoft/TypeScript/pull/9163
391
+ //
392
+ // For ESTree this is a bit tricky because the high level interfaces like
393
+ // Node or Function are pulling double duty. We want to pass common fields down
394
+ // to the interfaces that extend them (like Identifier or
395
+ // ArrowFunctionExpression), but you can't extend a type union or enforce
396
+ // common fields on them. So we've split the high level interfaces into two
397
+ // types, a base type which passes down inherited fields, and a type union of
398
+ // all types which extend the base type. Only the type union is exported, and
399
+ // the union is how other types refer to the collection of inheriting types.
400
+ //
401
+ // This makes the definitions file here somewhat more difficult to maintain,
402
+ // but it has the notable advantage of making ESTree much easier to use as
403
+ // an end user.
404
+
405
+ interface BaseNodeWithoutComments {
406
+ // Every leaf interface that extends BaseNode must specify a type property.
407
+ // The type property should be a string literal. For example, Identifier
408
+ // has: `type: "Identifier"`
409
+ type: string;
410
+ loc?: SourceLocation | null | undefined;
411
+ range?: [number, number] | undefined;
412
+ }
413
+
414
+ interface BaseNode extends BaseNodeWithoutComments {
415
+ leadingComments?: Comment[] | undefined;
416
+ trailingComments?: Comment[] | undefined;
417
+ }
418
+
419
+ interface Comment extends BaseNodeWithoutComments {
420
+ type: "Line" | "Block";
421
+ value: string;
422
+ }
423
+
424
+ interface SourceLocation {
425
+ source?: string | null | undefined;
426
+ start: Position;
427
+ end: Position;
428
+ }
429
+
430
+ interface Position {
431
+ /** >= 1 */
432
+ line: number;
433
+ /** >= 0 */
434
+ column: number;
435
+ }
436
+
437
+ interface BaseFunction extends BaseNode {
438
+ params: Pattern[];
439
+ generator?: boolean | undefined;
440
+ async?: boolean | undefined;
441
+ // The body is either BlockStatement or Expression because arrow functions
442
+ // can have a body that's either. FunctionDeclarations and
443
+ // FunctionExpressions have only BlockStatement bodies.
444
+ body: BlockStatement | Expression;
445
+ }
446
+
447
+ type Statement =
448
+ | ExpressionStatement
449
+ | BlockStatement
450
+ | StaticBlock
451
+ | EmptyStatement
452
+ | DebuggerStatement
453
+ | WithStatement
454
+ | ReturnStatement
455
+ | LabeledStatement
456
+ | BreakStatement
457
+ | ContinueStatement
458
+ | IfStatement
459
+ | SwitchStatement
460
+ | ThrowStatement
461
+ | TryStatement
462
+ | WhileStatement
463
+ | DoWhileStatement
464
+ | ForStatement
465
+ | ForInStatement
466
+ | ForOfStatement
467
+ | Declaration;
468
+
469
+ interface BaseStatement extends BaseNode {}
470
+
471
+ interface EmptyStatement extends BaseStatement {
472
+ type: "EmptyStatement";
473
+ }
474
+
475
+ interface BlockStatement extends BaseStatement {
476
+ type: "BlockStatement";
477
+ body: Statement[];
478
+ innerComments?: Comment[] | undefined;
479
+ }
480
+
481
+ interface StaticBlock extends Omit<BlockStatement, "type"> {
482
+ type: "StaticBlock";
483
+ }
484
+
485
+ interface ExpressionStatement extends BaseStatement {
486
+ type: "ExpressionStatement";
487
+ expression: Expression;
488
+ }
489
+
490
+ interface IfStatement extends BaseStatement {
491
+ type: "IfStatement";
492
+ test: Expression;
493
+ consequent: Statement;
494
+ alternate?: Statement | null | undefined;
495
+ }
496
+
497
+ interface LabeledStatement extends BaseStatement {
498
+ type: "LabeledStatement";
499
+ label: Identifier;
500
+ body: Statement;
501
+ }
502
+
503
+ interface BreakStatement extends BaseStatement {
504
+ type: "BreakStatement";
505
+ label?: Identifier | null | undefined;
506
+ }
507
+
508
+ interface ContinueStatement extends BaseStatement {
509
+ type: "ContinueStatement";
510
+ label?: Identifier | null | undefined;
511
+ }
512
+
513
+ interface WithStatement extends BaseStatement {
514
+ type: "WithStatement";
515
+ object: Expression;
516
+ body: Statement;
517
+ }
518
+
519
+ interface SwitchStatement extends BaseStatement {
520
+ type: "SwitchStatement";
521
+ discriminant: Expression;
522
+ cases: SwitchCase[];
523
+ }
524
+
525
+ interface ReturnStatement extends BaseStatement {
526
+ type: "ReturnStatement";
527
+ argument?: Expression | null | undefined;
528
+ }
529
+
530
+ interface ThrowStatement extends BaseStatement {
531
+ type: "ThrowStatement";
532
+ argument: Expression;
533
+ }
534
+
535
+ interface TryStatement extends BaseStatement {
536
+ type: "TryStatement";
537
+ block: BlockStatement;
538
+ handler?: CatchClause | null | undefined;
539
+ finalizer?: BlockStatement | null | undefined;
540
+ }
541
+
542
+ interface WhileStatement extends BaseStatement {
543
+ type: "WhileStatement";
544
+ test: Expression;
545
+ body: Statement;
546
+ }
547
+
548
+ interface DoWhileStatement extends BaseStatement {
549
+ type: "DoWhileStatement";
550
+ body: Statement;
551
+ test: Expression;
552
+ }
553
+
554
+ interface ForStatement extends BaseStatement {
555
+ type: "ForStatement";
556
+ init?: VariableDeclaration | Expression | null | undefined;
557
+ test?: Expression | null | undefined;
558
+ update?: Expression | null | undefined;
559
+ body: Statement;
560
+ }
561
+
562
+ interface BaseForXStatement extends BaseStatement {
563
+ left: VariableDeclaration | Pattern;
564
+ right: Expression;
565
+ body: Statement;
566
+ }
567
+
568
+ interface ForInStatement extends BaseForXStatement {
569
+ type: "ForInStatement";
570
+ }
571
+
572
+ interface DebuggerStatement extends BaseStatement {
573
+ type: "DebuggerStatement";
574
+ }
575
+
576
+ type Declaration = FunctionDeclaration | VariableDeclaration | ClassDeclaration;
577
+
578
+ interface BaseDeclaration extends BaseStatement {}
579
+
580
+ interface MaybeNamedFunctionDeclaration extends BaseFunction, BaseDeclaration {
581
+ type: "FunctionDeclaration";
582
+ /** It is null when a function declaration is a part of the `export default function` statement */
583
+ id: Identifier | null;
584
+ body: BlockStatement;
585
+ }
586
+
587
+ interface FunctionDeclaration extends MaybeNamedFunctionDeclaration {
588
+ id: Identifier;
589
+ }
590
+
591
+ interface VariableDeclaration extends BaseDeclaration {
592
+ type: "VariableDeclaration";
593
+ declarations: VariableDeclarator[];
594
+ kind: "var" | "let" | "const";
595
+ }
596
+
597
+ interface VariableDeclarator extends BaseNode {
598
+ type: "VariableDeclarator";
599
+ id: Pattern;
600
+ init?: Expression | null | undefined;
601
+ }
602
+
603
+ interface ExpressionMap {
604
+ ArrayExpression: ArrayExpression;
605
+ ArrowFunctionExpression: ArrowFunctionExpression;
606
+ AssignmentExpression: AssignmentExpression;
607
+ AwaitExpression: AwaitExpression;
608
+ BinaryExpression: BinaryExpression;
609
+ CallExpression: CallExpression;
610
+ ChainExpression: ChainExpression;
611
+ ClassExpression: ClassExpression;
612
+ ConditionalExpression: ConditionalExpression;
613
+ FunctionExpression: FunctionExpression;
614
+ Identifier: Identifier;
615
+ ImportExpression: ImportExpression;
616
+ Literal: Literal;
617
+ LogicalExpression: LogicalExpression;
618
+ MemberExpression: MemberExpression;
619
+ MetaProperty: MetaProperty;
620
+ NewExpression: NewExpression;
621
+ ObjectExpression: ObjectExpression;
622
+ SequenceExpression: SequenceExpression;
623
+ TaggedTemplateExpression: TaggedTemplateExpression;
624
+ TemplateLiteral: TemplateLiteral;
625
+ ThisExpression: ThisExpression;
626
+ UnaryExpression: UnaryExpression;
627
+ UpdateExpression: UpdateExpression;
628
+ YieldExpression: YieldExpression;
629
+ }
630
+
631
+ type Expression = ExpressionMap[keyof ExpressionMap];
632
+
633
+ interface BaseExpression extends BaseNode {}
634
+
635
+ type ChainElement = SimpleCallExpression | MemberExpression;
636
+
637
+ interface ChainExpression extends BaseExpression {
638
+ type: "ChainExpression";
639
+ expression: ChainElement;
640
+ }
641
+
642
+ interface ThisExpression extends BaseExpression {
643
+ type: "ThisExpression";
644
+ }
645
+
646
+ interface ArrayExpression extends BaseExpression {
647
+ type: "ArrayExpression";
648
+ elements: Array<Expression | SpreadElement | null>;
649
+ }
650
+
651
+ interface ObjectExpression extends BaseExpression {
652
+ type: "ObjectExpression";
653
+ properties: Array<Property | SpreadElement>;
654
+ }
655
+
656
+ interface PrivateIdentifier extends BaseNode {
657
+ type: "PrivateIdentifier";
658
+ name: string;
659
+ }
660
+
661
+ interface Property extends BaseNode {
662
+ type: "Property";
663
+ key: Expression | PrivateIdentifier;
664
+ value: Expression | Pattern; // Could be an AssignmentProperty
665
+ kind: "init" | "get" | "set";
666
+ method: boolean;
667
+ shorthand: boolean;
668
+ computed: boolean;
669
+ }
670
+
671
+ interface PropertyDefinition extends BaseNode {
672
+ type: "PropertyDefinition";
673
+ key: Expression | PrivateIdentifier;
674
+ value?: Expression | null | undefined;
675
+ computed: boolean;
676
+ static: boolean;
677
+ }
678
+
679
+ interface FunctionExpression extends BaseFunction, BaseExpression {
680
+ id?: Identifier | null | undefined;
681
+ type: "FunctionExpression";
682
+ body: BlockStatement;
683
+ }
684
+
685
+ interface SequenceExpression extends BaseExpression {
686
+ type: "SequenceExpression";
687
+ expressions: Expression[];
688
+ }
689
+
690
+ interface UnaryExpression extends BaseExpression {
691
+ type: "UnaryExpression";
692
+ operator: UnaryOperator;
693
+ prefix: true;
694
+ argument: Expression;
695
+ }
696
+
697
+ interface BinaryExpression extends BaseExpression {
698
+ type: "BinaryExpression";
699
+ operator: BinaryOperator;
700
+ left: Expression;
701
+ right: Expression;
702
+ }
703
+
704
+ interface AssignmentExpression extends BaseExpression {
705
+ type: "AssignmentExpression";
706
+ operator: AssignmentOperator;
707
+ left: Pattern | MemberExpression;
708
+ right: Expression;
709
+ }
710
+
711
+ interface UpdateExpression extends BaseExpression {
712
+ type: "UpdateExpression";
713
+ operator: UpdateOperator;
714
+ argument: Expression;
715
+ prefix: boolean;
716
+ }
717
+
718
+ interface LogicalExpression extends BaseExpression {
719
+ type: "LogicalExpression";
720
+ operator: LogicalOperator;
721
+ left: Expression;
722
+ right: Expression;
723
+ }
724
+
725
+ interface ConditionalExpression extends BaseExpression {
726
+ type: "ConditionalExpression";
727
+ test: Expression;
728
+ alternate: Expression;
729
+ consequent: Expression;
730
+ }
731
+
732
+ interface BaseCallExpression extends BaseExpression {
733
+ callee: Expression | Super;
734
+ arguments: Array<Expression | SpreadElement>;
735
+ }
736
+ type CallExpression = SimpleCallExpression | NewExpression;
737
+
738
+ interface SimpleCallExpression extends BaseCallExpression {
739
+ type: "CallExpression";
740
+ optional: boolean;
741
+ }
742
+
743
+ interface NewExpression extends BaseCallExpression {
744
+ type: "NewExpression";
745
+ }
746
+
747
+ interface MemberExpression extends BaseExpression, BasePattern {
748
+ type: "MemberExpression";
749
+ object: Expression | Super;
750
+ property: Expression | PrivateIdentifier;
751
+ computed: boolean;
752
+ optional: boolean;
753
+ }
754
+
755
+ type Pattern = Identifier | ObjectPattern | ArrayPattern | RestElement | AssignmentPattern | MemberExpression;
756
+
757
+ interface BasePattern extends BaseNode {}
758
+
759
+ interface SwitchCase extends BaseNode {
760
+ type: "SwitchCase";
761
+ test?: Expression | null | undefined;
762
+ consequent: Statement[];
763
+ }
764
+
765
+ interface CatchClause extends BaseNode {
766
+ type: "CatchClause";
767
+ param: Pattern | null;
768
+ body: BlockStatement;
769
+ }
770
+
771
+ interface Identifier extends BaseNode, BaseExpression, BasePattern {
772
+ type: "Identifier";
773
+ name: string;
774
+ }
775
+
776
+ type Literal = SimpleLiteral | RegExpLiteral | BigIntLiteral;
777
+
778
+ interface SimpleLiteral extends BaseNode, BaseExpression {
779
+ type: "Literal";
780
+ value: string | boolean | number | null;
781
+ raw?: string | undefined;
782
+ }
783
+
784
+ interface RegExpLiteral extends BaseNode, BaseExpression {
785
+ type: "Literal";
786
+ value?: RegExp | null | undefined;
787
+ regex: {
788
+ pattern: string;
789
+ flags: string;
790
+ };
791
+ raw?: string | undefined;
792
+ }
793
+
794
+ interface BigIntLiteral extends BaseNode, BaseExpression {
795
+ type: "Literal";
796
+ value?: bigint | null | undefined;
797
+ bigint: string;
798
+ raw?: string | undefined;
799
+ }
800
+
801
+ type UnaryOperator = "-" | "+" | "!" | "~" | "typeof" | "void" | "delete";
802
+
803
+ type BinaryOperator =
804
+ | "=="
805
+ | "!="
806
+ | "==="
807
+ | "!=="
808
+ | "<"
809
+ | "<="
810
+ | ">"
811
+ | ">="
812
+ | "<<"
813
+ | ">>"
814
+ | ">>>"
815
+ | "+"
816
+ | "-"
817
+ | "*"
818
+ | "/"
819
+ | "%"
820
+ | "**"
821
+ | "|"
822
+ | "^"
823
+ | "&"
824
+ | "in"
825
+ | "instanceof";
826
+
827
+ type LogicalOperator = "||" | "&&" | "??";
828
+
829
+ type AssignmentOperator =
830
+ | "="
831
+ | "+="
832
+ | "-="
833
+ | "*="
834
+ | "/="
835
+ | "%="
836
+ | "**="
837
+ | "<<="
838
+ | ">>="
839
+ | ">>>="
840
+ | "|="
841
+ | "^="
842
+ | "&="
843
+ | "||="
844
+ | "&&="
845
+ | "??=";
846
+
847
+ type UpdateOperator = "++" | "--";
848
+
849
+ interface ForOfStatement extends BaseForXStatement {
850
+ type: "ForOfStatement";
851
+ await: boolean;
852
+ }
853
+
854
+ interface Super extends BaseNode {
855
+ type: "Super";
856
+ }
857
+
858
+ interface SpreadElement extends BaseNode {
859
+ type: "SpreadElement";
860
+ argument: Expression;
861
+ }
862
+
863
+ interface ArrowFunctionExpression extends BaseExpression, BaseFunction {
864
+ type: "ArrowFunctionExpression";
865
+ expression: boolean;
866
+ body: BlockStatement | Expression;
867
+ }
868
+
869
+ interface YieldExpression extends BaseExpression {
870
+ type: "YieldExpression";
871
+ argument?: Expression | null | undefined;
872
+ delegate: boolean;
873
+ }
874
+
875
+ interface TemplateLiteral extends BaseExpression {
876
+ type: "TemplateLiteral";
877
+ quasis: TemplateElement[];
878
+ expressions: Expression[];
879
+ }
880
+
881
+ interface TaggedTemplateExpression extends BaseExpression {
882
+ type: "TaggedTemplateExpression";
883
+ tag: Expression;
884
+ quasi: TemplateLiteral;
885
+ }
886
+
887
+ interface TemplateElement extends BaseNode {
888
+ type: "TemplateElement";
889
+ tail: boolean;
890
+ value: {
891
+ /** It is null when the template literal is tagged and the text has an invalid escape (e.g. - tag`\unicode and \u{55}`) */
892
+ cooked?: string | null | undefined;
893
+ raw: string;
894
+ };
895
+ }
896
+
897
+ interface AssignmentProperty extends Property {
898
+ value: Pattern;
899
+ kind: "init";
900
+ method: boolean; // false
901
+ }
902
+
903
+ interface ObjectPattern extends BasePattern {
904
+ type: "ObjectPattern";
905
+ properties: Array<AssignmentProperty | RestElement>;
906
+ }
907
+
908
+ interface ArrayPattern extends BasePattern {
909
+ type: "ArrayPattern";
910
+ elements: Array<Pattern | null>;
911
+ }
912
+
913
+ interface RestElement extends BasePattern {
914
+ type: "RestElement";
915
+ argument: Pattern;
916
+ }
917
+
918
+ interface AssignmentPattern extends BasePattern {
919
+ type: "AssignmentPattern";
920
+ left: Pattern;
921
+ right: Expression;
922
+ }
923
+ interface BaseClass extends BaseNode {
924
+ superClass?: Expression | null | undefined;
925
+ body: ClassBody;
926
+ }
927
+
928
+ interface ClassBody extends BaseNode {
929
+ type: "ClassBody";
930
+ body: Array<MethodDefinition | PropertyDefinition | StaticBlock>;
931
+ }
932
+
933
+ interface MethodDefinition extends BaseNode {
934
+ type: "MethodDefinition";
935
+ key: Expression | PrivateIdentifier;
936
+ value: FunctionExpression;
937
+ kind: "constructor" | "method" | "get" | "set";
938
+ computed: boolean;
939
+ static: boolean;
940
+ }
941
+
942
+ interface MaybeNamedClassDeclaration extends BaseClass, BaseDeclaration {
943
+ type: "ClassDeclaration";
944
+ /** It is null when a class declaration is a part of the `export default class` statement */
945
+ id: Identifier | null;
946
+ }
947
+
948
+ interface ClassDeclaration extends MaybeNamedClassDeclaration {
949
+ id: Identifier;
950
+ }
951
+
952
+ interface ClassExpression extends BaseClass, BaseExpression {
953
+ type: "ClassExpression";
954
+ id?: Identifier | null | undefined;
955
+ }
956
+
957
+ interface MetaProperty extends BaseExpression {
958
+ type: "MetaProperty";
959
+ meta: Identifier;
960
+ property: Identifier;
961
+ }
962
+
963
+ interface ImportExpression extends BaseExpression {
964
+ type: "ImportExpression";
965
+ source: Expression;
966
+ }
967
+
968
+ interface AwaitExpression extends BaseExpression {
969
+ type: "AwaitExpression";
970
+ argument: Expression;
971
+ }
972
+
973
+ declare module 'estree' {
974
+ export interface Decorator extends BaseNode {
975
+ type: 'Decorator';
976
+ expression: Expression;
977
+ }
978
+ interface PropertyDefinition {
979
+ decorators: undefined[];
980
+ }
981
+ interface MethodDefinition {
982
+ decorators: undefined[];
983
+ }
984
+ interface BaseClass {
985
+ decorators: undefined[];
986
+ }
987
+ }
988
+
989
+ // declare AbortSignal here for environments without DOM lib or @types/node
990
+ declare global {
991
+ // eslint-disable-next-line @typescript-eslint/no-empty-object-type
992
+ interface AbortSignal {}
993
+ }
994
+
995
+ interface TemplateStorefrontSection {
388
996
  /** Section layout identifier. When not provided, the section will use the default layout. */
389
997
  readonly id?: string;
390
998
  readonly type: 'store';
391
999
  }
392
1000
 
393
1001
  interface StorePageConfiguration {
394
- readonly sections: [StorefrontSection];
1002
+ readonly sections: [TemplateStorefrontSection];
395
1003
  }
396
1004
 
397
1005
  declare const CatalogLayoutSlot: {